From 70a2ee6e3cca4356f59ba29344fc0b9550f64b31 Mon Sep 17 00:00:00 2001 From: Chandrakant I Viraktamath Date: Fri, 18 Sep 2020 17:13:13 +0530 Subject: [PATCH] msm: vidc: Add control to handle timestamp reorder Add control to enable/disable timestamp reordering in driver. Change-Id: I50c3f60bb8af053881073b40c6df0c74f3f0aafb Signed-off-by: Chandrakant I Viraktamath --- include/uapi/vidc/media/msm_vidc_utils.h | 2 ++ msm/vidc/msm_vdec.c | 11 +++++++++++ msm/vidc/msm_vidc.c | 5 ++--- msm/vidc/msm_vidc_common.h | 18 ++++++++++++++++++ 4 files changed, 33 insertions(+), 3 deletions(-) diff --git a/include/uapi/vidc/media/msm_vidc_utils.h b/include/uapi/vidc/media/msm_vidc_utils.h index 5359ec8e75388..4108ed84b036c 100644 --- a/include/uapi/vidc/media/msm_vidc_utils.h +++ b/include/uapi/vidc/media/msm_vidc_utils.h @@ -258,6 +258,8 @@ enum v4l2_mpeg_vidc_video_bitrate_savings_type { (V4L2_CID_MPEG_MSM_VIDC_BASE + 134) #define V4L2_CID_MPEG_VIDC_VENC_QPRANGE_BOOST \ (V4L2_CID_MPEG_MSM_VIDC_BASE + 135) +#define V4L2_CID_MPEG_VIDC_VIDEO_DISABLE_TIMESTAMP_REORDER \ + (V4L2_CID_MPEG_MSM_VIDC_BASE + 136) #define V4L2_CID_MPEG_VIDC_VIDEO_UNKNOWN \ (V4L2_CID_MPEG_MSM_VIDC_BASE + 0xFFF) diff --git a/msm/vidc/msm_vdec.c b/msm/vidc/msm_vdec.c index cadd95ced921f..bb69dede610c7 100644 --- a/msm/vidc/msm_vdec.c +++ b/msm/vidc/msm_vdec.c @@ -420,6 +420,15 @@ static struct msm_vidc_ctrl msm_vdec_ctrls[] = { .default_value = V4L2_MPEG_MSM_VIDC_DISABLE, .step = 1, }, + { + .id = V4L2_CID_MPEG_VIDC_VIDEO_DISABLE_TIMESTAMP_REORDER, + .name = "Disable TimeStamp Reorder", + .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", @@ -952,6 +961,8 @@ int msm_vdec_s_ctrl(struct msm_vidc_inst *inst, struct v4l2_ctrl *ctrl) break; case V4L2_CID_MPEG_VIDC_VIDEO_LOWLATENCY_HINT: break; + case V4L2_CID_MPEG_VIDC_VIDEO_DISABLE_TIMESTAMP_REORDER: + break; case V4L2_CID_MPEG_VIDC_VDEC_HEIF_MODE: if(get_v4l2_codec(inst) != V4L2_PIX_FMT_HEVC) break; diff --git a/msm/vidc/msm_vidc.c b/msm/vidc/msm_vidc.c index ec3e6551233d7..e9fe48f729438 100644 --- a/msm/vidc/msm_vidc.c +++ b/msm/vidc/msm_vidc.c @@ -433,7 +433,7 @@ int msm_vidc_qbuf(void *instance, struct media_device *mdev, timestamp_us = (s64)((b->timestamp.tv_sec * 1000000) + b->timestamp.tv_usec); if (is_decode_session(inst) && b->type == INPUT_MPLANE && - !is_heif_decoder(inst) && !is_secure_session(inst)) { + is_ts_reorder_allowed(inst)) { if (inst->flush_timestamps) msm_comm_release_timestamps(inst); inst->flush_timestamps = false; @@ -515,8 +515,7 @@ int msm_vidc_dqbuf(void *instance, struct v4l2_buffer *b) if (is_decode_session(inst) && b->type == OUTPUT_MPLANE && !(b->flags & V4L2_BUF_FLAG_CODECCONFIG) && - !is_heif_decoder(inst) && - !is_secure_session(inst)) + is_ts_reorder_allowed(inst)) msm_comm_fetch_ts_framerate(inst, b); return rc; diff --git a/msm/vidc/msm_vidc_common.h b/msm/vidc/msm_vidc_common.h index 42467096c2f3b..779f0c8cbf96a 100644 --- a/msm/vidc/msm_vidc_common.h +++ b/msm/vidc/msm_vidc_common.h @@ -159,6 +159,24 @@ static inline bool is_secure_session(struct msm_vidc_inst *inst) return !!(inst->flags & VIDC_SECURE); } +static inline bool is_ts_reorder_allowed(struct msm_vidc_inst *inst) +{ + struct v4l2_ctrl *ctrl; + + if (is_secure_session(inst)) + return false; + + if (inst->session_type != MSM_VIDC_DECODER) + return true; + + if (!is_heif_decoder(inst)) + return true; + + ctrl = get_ctrl(inst, + V4L2_CID_MPEG_VIDC_VIDEO_DISABLE_TIMESTAMP_REORDER); + return !ctrl->val; +} + static inline bool is_decode_session(struct msm_vidc_inst *inst) { return inst->session_type == MSM_VIDC_DECODER;