Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

media: amphion: decoder implement display delay enable

amphion vpu support a low latency mode,
when V4L2_CID_MPEG_VIDEO_DEC_DISPLAY_DELAY_ENABLE is enabled,
decoder can display frame immediately after it's decoded.
Only h264 is support yet.

Fixes: 6de8d628df6e ("media: amphion: add v4l2 m2m vpu decoder stateful driver")
Signed-off-by: Ming Qian <ming.qian@nxp.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>

authored by

Ming Qian and committed by
Mauro Carvalho Chehab
ffa331d9 46ff24ef

+37 -2
+32
drivers/media/platform/amphion/vdec.c
··· 168 168 {0, 0, 0, 0}, 169 169 }; 170 170 171 + static int vdec_op_s_ctrl(struct v4l2_ctrl *ctrl) 172 + { 173 + struct vpu_inst *inst = ctrl_to_inst(ctrl); 174 + struct vdec_t *vdec = inst->priv; 175 + int ret = 0; 176 + 177 + vpu_inst_lock(inst); 178 + switch (ctrl->id) { 179 + case V4L2_CID_MPEG_VIDEO_DEC_DISPLAY_DELAY_ENABLE: 180 + vdec->params.display_delay_enable = ctrl->val; 181 + break; 182 + case V4L2_CID_MPEG_VIDEO_DEC_DISPLAY_DELAY: 183 + vdec->params.display_delay = ctrl->val; 184 + break; 185 + default: 186 + ret = -EINVAL; 187 + break; 188 + } 189 + vpu_inst_unlock(inst); 190 + 191 + return ret; 192 + } 193 + 171 194 static const struct v4l2_ctrl_ops vdec_ctrl_ops = { 195 + .s_ctrl = vdec_op_s_ctrl, 172 196 .g_volatile_ctrl = vpu_helper_g_volatile_ctrl, 173 197 }; 174 198 ··· 204 180 ret = v4l2_ctrl_handler_init(&inst->ctrl_handler, 20); 205 181 if (ret) 206 182 return ret; 183 + 184 + v4l2_ctrl_new_std(&inst->ctrl_handler, &vdec_ctrl_ops, 185 + V4L2_CID_MPEG_VIDEO_DEC_DISPLAY_DELAY, 186 + 0, 0, 1, 0); 187 + 188 + v4l2_ctrl_new_std(&inst->ctrl_handler, &vdec_ctrl_ops, 189 + V4L2_CID_MPEG_VIDEO_DEC_DISPLAY_DELAY_ENABLE, 190 + 0, 1, 1, 0); 207 191 208 192 ctrl = v4l2_ctrl_new_std(&inst->ctrl_handler, &vdec_ctrl_ops, 209 193 V4L2_CID_MIN_BUFFERS_FOR_CAPTURE, 1, 32, 1, 2);
+2 -1
drivers/media/platform/amphion/vpu_codec.h
··· 55 55 struct vpu_decode_params { 56 56 u32 codec_format; 57 57 u32 output_format; 58 - u32 b_dis_reorder; 58 + u32 display_delay_enable; 59 + u32 display_delay; 59 60 u32 b_non_frame; 60 61 u32 frame_count; 61 62 u32 end_flag;
+3 -1
drivers/media/platform/amphion/vpu_malone.c
··· 641 641 hc->jpg[instance].jpg_mjpeg_interlaced = 0; 642 642 } 643 643 644 - hc->codec_param[instance].disp_imm = params->b_dis_reorder ? 1 : 0; 644 + hc->codec_param[instance].disp_imm = params->display_delay_enable ? 1 : 0; 645 + if (malone_format != MALONE_FMT_AVC) 646 + hc->codec_param[instance].disp_imm = 0; 645 647 hc->codec_param[instance].dbglog_enable = 0; 646 648 iface->dbglog_desc.level = 0; 647 649