From cc97f61b4b346af0363dcee45882f8a76326a304 Mon Sep 17 00:00:00 2001 From: Vikash Garodia Date: Thu, 22 Oct 2020 02:09:48 +0530 Subject: [PATCH] msm: venc: add support for boost for holi For holi, boost is set as 15%. With the change, a level of 15% can be set to video firmware. Also ensure that the boost is set only when client has set the boost control. CRs-Fixed: 2810440 Change-Id: Ib4e4c5511c57daa78b405f8a92c2ee924b1cc1bd Signed-off-by: Vikash Garodia --- msm/vidc/msm_venc.c | 19 ++++++++++++++++--- msm/vidc/msm_vidc_internal.h | 1 + 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/msm/vidc/msm_venc.c b/msm/vidc/msm_venc.c index a1c1b1021839..55e05e41e5a6 100644 --- a/msm/vidc/msm_venc.c +++ b/msm/vidc/msm_venc.c @@ -1970,6 +1970,9 @@ int msm_venc_s_ctrl(struct msm_vidc_inst *inst, struct v4l2_ctrl *ctrl) case V4L2_CID_MPEG_VIDC_VIDEO_FULL_RANGE: inst->full_range = ctrl->val; break; + case V4L2_CID_MPEG_VIDC_VENC_BITRATE_BOOST: + inst->boost_enabled = true; + break; case V4L2_CID_MPEG_VIDEO_H264_ENTROPY_MODE: inst->entropy_mode = msm_comm_v4l2_to_hfi( V4L2_CID_MPEG_VIDEO_H264_ENTROPY_MODE, @@ -2010,7 +2013,6 @@ int msm_venc_s_ctrl(struct msm_vidc_inst *inst, struct v4l2_ctrl *ctrl) case V4L2_CID_MPEG_VIDEO_VBV_DELAY: case V4L2_CID_MPEG_VIDEO_H264_CHROMA_QP_INDEX_OFFSET: case V4L2_CID_MPEG_VIDC_VENC_BITRATE_SAVINGS: - case V4L2_CID_MPEG_VIDC_VENC_BITRATE_BOOST: case V4L2_CID_MPEG_VIDC_VENC_QPRANGE_BOOST: case V4L2_CID_MPEG_VIDC_SUPERFRAME: s_vpr_h(sid, "Control set: ID : 0x%x Val : %d\n", @@ -3493,12 +3495,14 @@ int msm_venc_set_bitrate_boost_margin(struct msm_vidc_inst *inst, u32 enable) struct v4l2_ctrl *ctrl = NULL; struct hfi_bitrate_boost_margin boost_margin; int minqp, maxqp; + uint32_t vpu; if (!inst || !inst->core) { d_vpr_e("%s: invalid params %pK\n", __func__, inst); return -EINVAL; } hdev = inst->core->device; + vpu = inst->core->platform_data->vpu_ver; if (!enable) { boost_margin.margin = 0; @@ -3507,11 +3511,20 @@ int msm_venc_set_bitrate_boost_margin(struct msm_vidc_inst *inst, u32 enable) ctrl = get_ctrl(inst, V4L2_CID_MPEG_VIDC_VENC_BITRATE_BOOST); - /* Mapped value to 0, 25 or 50*/ + /* + * For certain SOC, default value should be 0 unless client enabled + */ + if (!inst->boost_enabled && vpu == VPU_VERSION_AR50_LITE) { + ctrl->val = 0; + update_ctrl(ctrl, 0, inst->sid); + } + /* Mapped value to 0, 15, 25 or 50*/ if (ctrl->val >= 50) boost_margin.margin = 50; - else + else if (ctrl->val >= 25) boost_margin.margin = (u32)(ctrl->val/25) * 25; + else + boost_margin.margin = (u32)(ctrl->val/15) * 15; setprop: s_vpr_h(inst->sid, "%s: %d\n", __func__, boost_margin.margin); diff --git a/msm/vidc/msm_vidc_internal.h b/msm/vidc/msm_vidc_internal.h index 2c1d1c4c7d41..b85e43d1b270 100644 --- a/msm/vidc/msm_vidc_internal.h +++ b/msm/vidc/msm_vidc_internal.h @@ -589,6 +589,7 @@ struct msm_vidc_inst { u64 last_qbuf_time_ns; bool active; bool has_bframe; + bool boost_enabled; bool boost_qp_enabled; u32 boost_min_qp; u32 boost_max_qp;