Commit 16545aa3 authored by Dikshita Agarwal's avatar Dikshita Agarwal Committed by Mauro Carvalho Chehab

media: venus: Set buffer to FW based on FW min count requirement.

- Get the min buffer count required by FW from source event change
  and use the same value to decide actual buffer count and for
  buffer size calculation.
- Setup DPB and OPB buffers after session continue incase of
  reconfig.
Signed-off-by: default avatarDikshita Agarwal <dikshita@codeaurora.org>
Signed-off-by: default avatarStanimir Varbanov <stanimir.varbanov@linaro.org>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent fa622c3d
...@@ -409,6 +409,7 @@ struct venus_inst { ...@@ -409,6 +409,7 @@ struct venus_inst {
u32 width; u32 width;
u32 height; u32 height;
struct v4l2_rect crop; struct v4l2_rect crop;
u32 fw_min_cnt;
u32 out_width; u32 out_width;
u32 out_height; u32 out_height;
u32 colorspace; u32 colorspace;
......
...@@ -623,9 +623,15 @@ int venus_helper_get_bufreq(struct venus_inst *inst, u32 type, ...@@ -623,9 +623,15 @@ int venus_helper_get_bufreq(struct venus_inst *inst, u32 type,
if (req) if (req)
memset(req, 0, sizeof(*req)); memset(req, 0, sizeof(*req));
if (type == HFI_BUFFER_OUTPUT || type == HFI_BUFFER_OUTPUT2)
req->count_min = inst->fw_min_cnt;
ret = platform_get_bufreq(inst, type, req); ret = platform_get_bufreq(inst, type, req);
if (!ret) if (!ret) {
if (type == HFI_BUFFER_OUTPUT || type == HFI_BUFFER_OUTPUT2)
inst->fw_min_cnt = req->count_min;
return 0; return 0;
}
ret = hfi_session_get_property(inst, ptype, &hprop); ret = hfi_session_get_property(inst, ptype, &hprop);
if (ret) if (ret)
......
...@@ -167,6 +167,7 @@ ...@@ -167,6 +167,7 @@
#define HFI_PROPERTY_PARAM_VDEC_RECOVERY_POINT_SEI_EXTRADATA 0x120300c #define HFI_PROPERTY_PARAM_VDEC_RECOVERY_POINT_SEI_EXTRADATA 0x120300c
#define HFI_PROPERTY_PARAM_VDEC_THUMBNAIL_MODE 0x120300d #define HFI_PROPERTY_PARAM_VDEC_THUMBNAIL_MODE 0x120300d
#define HFI_PROPERTY_PARAM_VDEC_FRAME_ASSEMBLY 0x120300e #define HFI_PROPERTY_PARAM_VDEC_FRAME_ASSEMBLY 0x120300e
#define HFI_PROPERTY_PARAM_VDEC_DPB_COUNTS 0x120300e
#define HFI_PROPERTY_PARAM_VDEC_VC1_FRAMEDISP_EXTRADATA 0x1203011 #define HFI_PROPERTY_PARAM_VDEC_VC1_FRAMEDISP_EXTRADATA 0x1203011
#define HFI_PROPERTY_PARAM_VDEC_VC1_SEQDISP_EXTRADATA 0x1203012 #define HFI_PROPERTY_PARAM_VDEC_VC1_SEQDISP_EXTRADATA 0x1203012
#define HFI_PROPERTY_PARAM_VDEC_TIMESTAMP_EXTRADATA 0x1203013 #define HFI_PROPERTY_PARAM_VDEC_TIMESTAMP_EXTRADATA 0x1203013
...@@ -915,6 +916,14 @@ struct hfi_extradata_input_crop { ...@@ -915,6 +916,14 @@ struct hfi_extradata_input_crop {
u32 height; u32 height;
}; };
struct hfi_dpb_counts {
u32 max_dpb_count;
u32 max_ref_frames;
u32 max_dec_buffering;
u32 max_reorder_frames;
u32 fw_min_cnt;
};
#define HFI_COLOR_FORMAT_MONOCHROME 0x01 #define HFI_COLOR_FORMAT_MONOCHROME 0x01
#define HFI_COLOR_FORMAT_NV12 0x02 #define HFI_COLOR_FORMAT_NV12 0x02
#define HFI_COLOR_FORMAT_NV21 0x03 #define HFI_COLOR_FORMAT_NV21 0x03
......
...@@ -32,6 +32,7 @@ static void event_seq_changed(struct venus_core *core, struct venus_inst *inst, ...@@ -32,6 +32,7 @@ static void event_seq_changed(struct venus_core *core, struct venus_inst *inst,
struct hfi_colour_space *colour_info; struct hfi_colour_space *colour_info;
struct hfi_buffer_requirements *bufreq; struct hfi_buffer_requirements *bufreq;
struct hfi_extradata_input_crop *crop; struct hfi_extradata_input_crop *crop;
struct hfi_dpb_counts *dpb_count;
u8 *data_ptr; u8 *data_ptr;
u32 ptype; u32 ptype;
...@@ -110,6 +111,12 @@ static void event_seq_changed(struct venus_core *core, struct venus_inst *inst, ...@@ -110,6 +111,12 @@ static void event_seq_changed(struct venus_core *core, struct venus_inst *inst,
event.input_crop.height = crop->height; event.input_crop.height = crop->height;
data_ptr += sizeof(*crop); data_ptr += sizeof(*crop);
break; break;
case HFI_PROPERTY_PARAM_VDEC_DPB_COUNTS:
data_ptr += sizeof(u32);
dpb_count = (struct hfi_dpb_counts *)data_ptr;
event.buf_count = dpb_count->fw_min_cnt;
data_ptr += sizeof(*dpb_count);
break;
default: default:
break; break;
} }
......
...@@ -1164,7 +1164,7 @@ static int output_buffer_count(u32 session_type, u32 codec) ...@@ -1164,7 +1164,7 @@ static int output_buffer_count(u32 session_type, u32 codec)
output_min_count = 6; output_min_count = 6;
break; break;
case V4L2_PIX_FMT_VP9: case V4L2_PIX_FMT_VP9:
output_min_count = 9; output_min_count = 11;
break; break;
case V4L2_PIX_FMT_H264: case V4L2_PIX_FMT_H264:
case V4L2_PIX_FMT_HEVC: case V4L2_PIX_FMT_HEVC:
...@@ -1213,6 +1213,8 @@ static int bufreq_dec(struct hfi_plat_buffers_params *params, u32 buftype, ...@@ -1213,6 +1213,8 @@ static int bufreq_dec(struct hfi_plat_buffers_params *params, u32 buftype,
} }
out_min_count = output_buffer_count(VIDC_SESSION_TYPE_DEC, codec); out_min_count = output_buffer_count(VIDC_SESSION_TYPE_DEC, codec);
/* Max of driver and FW count */
out_min_count = max(out_min_count, bufreq->count_min);
bufreq->type = buftype; bufreq->type = buftype;
bufreq->region_size = 0; bufreq->region_size = 0;
...@@ -1237,7 +1239,7 @@ static int bufreq_dec(struct hfi_plat_buffers_params *params, u32 buftype, ...@@ -1237,7 +1239,7 @@ static int bufreq_dec(struct hfi_plat_buffers_params *params, u32 buftype,
} else if (buftype == HFI_BUFFER_INTERNAL_SCRATCH(version)) { } else if (buftype == HFI_BUFFER_INTERNAL_SCRATCH(version)) {
bufreq->size = dec_ops->scratch(width, height, is_interlaced); bufreq->size = dec_ops->scratch(width, height, is_interlaced);
} else if (buftype == HFI_BUFFER_INTERNAL_SCRATCH_1(version)) { } else if (buftype == HFI_BUFFER_INTERNAL_SCRATCH_1(version)) {
bufreq->size = dec_ops->scratch1(width, height, out_min_count, bufreq->size = dec_ops->scratch1(width, height, VB2_MAX_FRAME,
is_secondary_output, is_secondary_output,
num_vpp_pipes); num_vpp_pipes);
} else if (buftype == HFI_BUFFER_INTERNAL_PERSIST_1) { } else if (buftype == HFI_BUFFER_INTERNAL_PERSIST_1) {
......
...@@ -986,23 +986,23 @@ static int vdec_start_capture(struct venus_inst *inst) ...@@ -986,23 +986,23 @@ static int vdec_start_capture(struct venus_inst *inst)
if (ret) if (ret)
goto err; goto err;
venus_pm_load_scale(inst);
inst->next_buf_last = false;
ret = venus_helper_alloc_dpb_bufs(inst); ret = venus_helper_alloc_dpb_bufs(inst);
if (ret) if (ret)
goto err; goto err;
ret = venus_helper_queue_dpb_bufs(inst); ret = hfi_session_continue(inst);
if (ret) if (ret)
goto free_dpb_bufs; goto free_dpb_bufs;
ret = venus_helper_process_initial_cap_bufs(inst); ret = venus_helper_queue_dpb_bufs(inst);
if (ret) if (ret)
goto free_dpb_bufs; goto free_dpb_bufs;
venus_pm_load_scale(inst); ret = venus_helper_process_initial_cap_bufs(inst);
inst->next_buf_last = false;
ret = hfi_session_continue(inst);
if (ret) if (ret)
goto free_dpb_bufs; goto free_dpb_bufs;
...@@ -1409,6 +1409,11 @@ static void vdec_event_change(struct venus_inst *inst, ...@@ -1409,6 +1409,11 @@ static void vdec_event_change(struct venus_inst *inst,
inst->crop.height = ev_data->height; inst->crop.height = ev_data->height;
} }
inst->fw_min_cnt = ev_data->buf_count;
/* overwriting this to 11 for vp9 due to fw bug */
if (inst->hfi_codec == HFI_VIDEO_CODEC_VP9)
inst->fw_min_cnt = 11;
inst->out_width = ev_data->width; inst->out_width = ev_data->width;
inst->out_height = ev_data->height; inst->out_height = ev_data->height;
...@@ -1512,6 +1517,7 @@ static void vdec_inst_init(struct venus_inst *inst) ...@@ -1512,6 +1517,7 @@ static void vdec_inst_init(struct venus_inst *inst)
inst->crop.top = 0; inst->crop.top = 0;
inst->crop.width = inst->width; inst->crop.width = inst->width;
inst->crop.height = inst->height; inst->crop.height = inst->height;
inst->fw_min_cnt = 8;
inst->out_width = frame_width_min(inst); inst->out_width = frame_width_min(inst);
inst->out_height = frame_height_min(inst); inst->out_height = frame_height_min(inst);
inst->fps = 30; inst->fps = 30;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment