From e55786492dbceb0e4fc31b32c31b6dfbac280ee3 Mon Sep 17 00:00:00 2001 From: Vikash Garodia Date: Mon, 27 Apr 2020 12:38:36 +0530 Subject: [PATCH] msm: vdec: configure latency mode for decode session Static - Enable latency hint which indicates that the decode session may go into low latency mode during the session. With this configuration, video driver disables DCVS and decode batching. Dynamic - Enable or disable low latency control during the session. Based on it, video driver would decide the work mode and set the same. Change-Id: If6e85b7adb1bbe4b4bec9e4a8671db64f240cfe8 Signed-off-by: Vikash Garodia --- msm/vidc/msm_vdec.c | 40 ++++++++++++++++++++++++++++++++++++++ msm/vidc/msm_vidc_clocks.c | 1 + msm/vidc/msm_vidc_common.c | 10 ++++++++++ msm/vidc/msm_vidc_common.h | 11 +++++++++++ msm/vidc/vidc_hfi.h | 2 ++ 5 files changed, 64 insertions(+) diff --git a/msm/vidc/msm_vdec.c b/msm/vidc/msm_vdec.c index c141fb09ad87..c53353abd940 100644 --- a/msm/vidc/msm_vdec.c +++ b/msm/vidc/msm_vdec.c @@ -416,6 +416,15 @@ static struct msm_vidc_ctrl msm_vdec_ctrls[] = { .default_value = V4L2_MPEG_MSM_VIDC_DISABLE, .step = 1, }, + { + .id = V4L2_CID_MPEG_VIDC_VIDEO_LOWLATENCY_HINT, + .name = "Low Latency Hint", + .type = V4L2_CTRL_TYPE_BOOLEAN, + .minimum = V4L2_MPEG_MSM_VIDC_DISABLE, + .maximum = V4L2_MPEG_MSM_VIDC_ENABLE, + .default_value = V4L2_MPEG_MSM_VIDC_DISABLE, + .step = 1, + }, { .id = V4L2_CID_MPEG_VIDC_SUPERFRAME, .name = "Superframe", @@ -937,6 +946,8 @@ int msm_vdec_s_ctrl(struct msm_vidc_inst *inst, struct v4l2_ctrl *ctrl) inst->clk_data.low_latency_mode = !!ctrl->val; inst->batch.enable = is_batching_allowed(inst); break; + case V4L2_CID_MPEG_VIDC_VIDEO_LOWLATENCY_HINT: + break; default: s_vpr_e(inst->sid, "Unknown control %#x\n", ctrl->id); break; @@ -1313,6 +1324,32 @@ int msm_vdec_set_priority(struct msm_vidc_inst *inst) return rc; } +int msm_vdec_set_seqchng_at_syncframe(struct msm_vidc_inst *inst) +{ + int rc = 0; + struct hfi_device *hdev; + struct hfi_enable hfi_property; + + if (!inst || !inst->core) { + d_vpr_e("%s: invalid params %pK\n", __func__, inst); + return -EINVAL; + } + hdev = inst->core->device; + hfi_property.enable = is_low_latency_hint(inst); + + if (!hfi_property.enable) + return 0; + + s_vpr_h(inst->sid, "%s: %#x\n", __func__, hfi_property.enable); + rc = call_hfi_op(hdev, session_set_property, inst->session, + HFI_PROPERTY_PARAM_VDEC_SEQCHNG_AT_SYNCFRM, &hfi_property, + sizeof(hfi_property)); + if (rc) + s_vpr_e(inst->sid, "%s: set property failed\n", __func__); + + return rc; +} + int msm_vdec_set_conceal_color(struct msm_vidc_inst *inst) { int rc = 0; @@ -1447,6 +1484,9 @@ int msm_vdec_set_properties(struct msm_vidc_inst *inst) rc = msm_vdec_set_conceal_color(inst); if (rc) goto exit; + rc = msm_vdec_set_seqchng_at_syncframe(inst); + if (rc) + goto exit; } rc = msm_vdec_set_color_format(inst); diff --git a/msm/vidc/msm_vidc_clocks.c b/msm/vidc/msm_vidc_clocks.c index 5f267bc951ae..791fe244b340 100644 --- a/msm/vidc/msm_vidc_clocks.c +++ b/msm/vidc/msm_vidc_clocks.c @@ -995,6 +995,7 @@ int msm_dcvs_try_enable(struct msm_vidc_inst *inst) !(msm_vidc_clock_voting || !inst->core->resources.dcvs || inst->flags & VIDC_THUMBNAIL || + is_low_latency_hint(inst) || inst->clk_data.low_latency_mode || inst->batch.enable || is_turbo_session(inst) || diff --git a/msm/vidc/msm_vidc_common.c b/msm/vidc/msm_vidc_common.c index fa25d14376a3..af087866f1db 100644 --- a/msm/vidc/msm_vidc_common.c +++ b/msm/vidc/msm_vidc_common.c @@ -1656,6 +1656,15 @@ static void handle_event_change(enum hal_command_response cmd, void *data) } else { inst->entropy_mode = event_notify->entropy_mode; + /* configure work mode considering low latency*/ + if (is_low_latency_hint(inst)) { + rc = call_core_op(inst->core, decide_work_mode, + inst); + if (rc) + s_vpr_e(inst->sid, + "%s: Failed to decide work mode\n", + __func__); + } s_vpr_h(inst->sid, "seq: No parameter change continue session\n"); rc = call_hfi_op(hdev, session_continue, @@ -2805,6 +2814,7 @@ bool is_batching_allowed(struct msm_vidc_inst *inst) */ return (inst->batch.enable && inst->core->resources.decode_batching && + !is_low_latency_hint(inst) && is_single_session(inst, ignore_flags) && is_decode_session(inst) && !is_thumbnail_session(inst) && diff --git a/msm/vidc/msm_vidc_common.h b/msm/vidc/msm_vidc_common.h index fa48aa7ae830..806a8edb3dbd 100644 --- a/msm/vidc/msm_vidc_common.h +++ b/msm/vidc/msm_vidc_common.h @@ -127,6 +127,17 @@ static inline bool is_realtime_session(struct msm_vidc_inst *inst) return !!ctrl->val; } +static inline bool is_low_latency_hint(struct msm_vidc_inst *inst) +{ + struct v4l2_ctrl *ctrl; + + if (inst->session_type != MSM_VIDC_DECODER) + return false; + + ctrl = get_ctrl(inst, V4L2_CID_MPEG_VIDC_VIDEO_LOWLATENCY_HINT); + return !!ctrl->val; +} + static inline bool is_secure_session(struct msm_vidc_inst *inst) { return !!(inst->flags & VIDC_SECURE); diff --git a/msm/vidc/vidc_hfi.h b/msm/vidc/vidc_hfi.h index 784868e9e20c..ed078af401b5 100644 --- a/msm/vidc/vidc_hfi.h +++ b/msm/vidc/vidc_hfi.h @@ -193,6 +193,8 @@ struct hfi_extradata_header { (HFI_PROPERTY_PARAM_VDEC_OX_START + 0x0023) #define HFI_PROPERTY_PARAM_VDEC_VSP_VPP_DELAY \ (HFI_PROPERTY_PARAM_VDEC_OX_START + 0x0024) +#define HFI_PROPERTY_PARAM_VDEC_SEQCHNG_AT_SYNCFRM \ + (HFI_PROPERTY_PARAM_VDEC_OX_START + 0x0025) #define HFI_PROPERTY_CONFIG_VDEC_OX_START \ (HFI_DOMAIN_BASE_VDEC + HFI_ARCH_OX_OFFSET + 0x4000)