diff --git a/include/uapi/vidc/media/msm_vidc_utils.h b/include/uapi/vidc/media/msm_vidc_utils.h index 5359ec8e7538..4108ed84b036 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 cadd95ced921..bb69dede610c 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 ec3e6551233d..e9fe48f72943 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 42467096c2f3..779f0c8cbf96 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;