diff --git a/driver/vidc/src/msm_vdec.c b/driver/vidc/src/msm_vdec.c index 45c135d4e8..7125b2282c 100644 --- a/driver/vidc/src/msm_vdec.c +++ b/driver/vidc/src/msm_vdec.c @@ -2516,6 +2516,8 @@ int msm_vdec_inst_init(struct msm_vidc_inst *inst) inst->decode_batch.enable = true; inst->decode_batch.size = MAX_DEC_BATCH_SIZE; } + if (core->capabilities[DCVS].value) + inst->power.dcvs_mode = true; f = &inst->fmts[INPUT_PORT]; f->type = INPUT_MPLANE; diff --git a/driver/vidc/src/msm_venc.c b/driver/vidc/src/msm_venc.c index ce6afaebf3..38cee30ec3 100644 --- a/driver/vidc/src/msm_venc.c +++ b/driver/vidc/src/msm_venc.c @@ -1731,6 +1731,10 @@ int msm_venc_inst_init(struct msm_vidc_inst *inst) i_vpr_h(inst, "%s()\n", __func__); core = inst->core; + + if (core->capabilities[DCVS].value) + inst->power.dcvs_mode = true; + f = &inst->fmts[OUTPUT_PORT]; f->type = OUTPUT_MPLANE; f->fmt.pix_mp.width = DEFAULT_WIDTH; diff --git a/driver/vidc/src/msm_vidc_buffer.c b/driver/vidc/src/msm_vidc_buffer.c index 56546f7912..c444b27c08 100644 --- a/driver/vidc/src/msm_vidc_buffer.c +++ b/driver/vidc/src/msm_vidc_buffer.c @@ -117,8 +117,9 @@ u32 msm_vidc_input_extra_count(struct msm_vidc_inst *inst) } } } else if (is_encode_session(inst)) { - /* add dcvs buffers */ - count = DCVS_ENC_EXTRA_INPUT_BUFFERS; + /* add dcvs buffers, if platform supports dcvs */ + if (core->capabilities[DCVS].value) + count = DCVS_ENC_EXTRA_INPUT_BUFFERS; } return count; @@ -143,8 +144,9 @@ u32 msm_vidc_output_extra_count(struct msm_vidc_inst *inst) return 0; if (is_decode_session(inst)) { - /* add dcvs buffers */ - count = DCVS_DEC_EXTRA_OUTPUT_BUFFERS; + /* add dcvs buffers, if platform supports dcvs */ + if (core->capabilities[DCVS].value) + count = DCVS_DEC_EXTRA_OUTPUT_BUFFERS; /* * if decode batching enabled, ensure minimum batch size * count of extra output buffers added on output port diff --git a/driver/vidc/src/msm_vidc_control.c b/driver/vidc/src/msm_vidc_control.c index 3a9572972c..3407d6a361 100644 --- a/driver/vidc/src/msm_vidc_control.c +++ b/driver/vidc/src/msm_vidc_control.c @@ -644,7 +644,7 @@ static int msm_vidc_update_buffer_count_if_needed(struct msm_vidc_inst* inst, int rc = 0; bool update_input_port = false, update_output_port = false; - if (!inst || !inst->capabilities || !ctrl) { + if (!inst || !ctrl) { d_vpr_e("%s: invalid parameters\n", __func__); return -EINVAL; } @@ -658,6 +658,7 @@ static int msm_vidc_update_buffer_count_if_needed(struct msm_vidc_inst* inst, update_input_port = true; break; case V4L2_CID_MPEG_VIDC_THUMBNAIL_MODE: + case V4L2_CID_MPEG_VIDC_PRIORITY: update_input_port = true; update_output_port = true; break; @@ -752,6 +753,17 @@ int msm_v4l2_op_s_ctrl(struct v4l2_ctrl *ctrl) rc = msm_vidc_adjust_session_priority(inst, ctrl); if (rc) return rc; + + /** + * This is the last static s_ctrl from client(commit point). So update + * input & output counts to reflect final buffer counts based on dcvs + * & decoder_batching enable/disable. So client is expected to query + * for final counts after setting priority control. + */ + if (is_decode_session(inst)) + inst->decode_batch.enable = msm_vidc_allow_decode_batch(inst); + + msm_vidc_allow_dcvs(inst); } if (is_meta_ctrl(ctrl->id)) { if (cap_id == META_DPB_TAG_LIST) { diff --git a/driver/vidc/src/msm_vidc_driver.c b/driver/vidc/src/msm_vidc_driver.c index 94aba9d51f..72e79250a4 100644 --- a/driver/vidc/src/msm_vidc_driver.c +++ b/driver/vidc/src/msm_vidc_driver.c @@ -2712,6 +2712,12 @@ void msm_vidc_allow_dcvs(struct msm_vidc_inst *inst) goto exit; } + allow = !is_lowlatency_session(inst); + if (!allow) { + i_vpr_h(inst, "%s: lowlatency session\n", __func__); + goto exit; + } + exit: i_vpr_h(inst, "%s: dcvs: %s\n", __func__, allow ? "enabled" : "disabled"); @@ -2721,14 +2727,17 @@ exit: bool msm_vidc_allow_decode_batch(struct msm_vidc_inst *inst) { + struct msm_vidc_inst_capability *capability; struct msm_vidc_core *core; bool allow = false; + u32 value = 0; - if (!inst || !inst->core) { + if (!inst || !inst->core || !inst->capabilities) { d_vpr_e("%s: invalid params\n", __func__); return false; } core = inst->core; + capability = inst->capabilities; allow = inst->decode_batch.enable; if (!allow) { @@ -2778,6 +2787,22 @@ bool msm_vidc_allow_decode_batch(struct msm_vidc_inst *inst) goto exit; } + value = msm_vidc_get_fps(inst); + allow = value < capability->cap[BATCH_FPS].value; + if (!allow) { + i_vpr_h(inst, "%s: unsupported fps %u, max %u\n", __func__, + value, capability->cap[BATCH_FPS].value); + goto exit; + } + + value = msm_vidc_get_mbs_per_frame(inst); + allow = value < capability->cap[BATCH_MBPF].value; + if (!allow) { + i_vpr_h(inst, "%s: unsupported mbpf %u, max %u\n", __func__, + value, capability->cap[BATCH_MBPF].value); + goto exit; + } + exit: i_vpr_h(inst, "%s: batching: %s\n", __func__, allow ? "enabled" : "disabled"); @@ -4090,7 +4115,7 @@ int msm_vidc_core_init(struct msm_vidc_core *core) { int rc = 0; - if (!core || !core->platform) { + if (!core || !core->capabilities) { d_vpr_e("%s: invalid params\n", __func__); return -EINVAL; }