v4l: fixed some issues of the v4l codec. [1/1]
authorNanxin Qin <nanxin.qin@amlogic.com>
Thu, 21 May 2020 03:18:07 +0000 (11:18 +0800)
committerHui Zhang <hui.zhang@amlogic.com>
Thu, 28 May 2020 02:37:54 +0000 (19:37 -0700)
PD#SWPL-26430

Problem:
1. the first picture output 2 times.
2. exception calltrace was found when exit multi-inst playbacks

Solution:
1. the first frame of es must be removed after probe done.
2. clean vb2 buffers status when cmd stream stop.

Verify:
u212

Change-Id: Ic90a5a48e0e2f966e150dc76ba7902a8a9920f3e
Signed-off-by: Nanxin Qin <nanxin.qin@amlogic.com>
drivers/amvdec_ports/aml_vcodec_dec.c

index df2788114b52985ed4e97fe516327df8ad8998de..fb88ce51c77a207425170cd166d8aec4d04148e9 100644 (file)
@@ -2134,6 +2134,10 @@ static void vb2ops_vdec_buf_queue(struct vb2_buffer *vb)
        if (ctx->is_drm_mode && src_mem.model == VB2_MEMORY_DMABUF) {
                v4l2_m2m_src_buf_remove(ctx->m2m_ctx);
                aml_recycle_dma_buffers(ctx);
+       } else if (ctx->param_sets_from_ucode) {
+               v4l2_m2m_src_buf_remove(ctx->m2m_ctx);
+               v4l2_m2m_buf_done(to_vb2_v4l2_buffer(vb),
+                       VB2_BUF_STATE_DONE);
        }
 
        if (vdec_if_get_param(ctx, GET_PARAM_PIC_INFO, &ctx->picinfo)) {
@@ -2335,16 +2339,25 @@ static void vb2ops_vdec_stop_streaming(struct vb2_queue *q)
        codec_mm_bufs_cnt_clean(q);
 
        if (V4L2_TYPE_IS_OUTPUT(q->type)) {
+               if (ctx->is_drm_mode && q->memory == VB2_MEMORY_DMABUF)
+                       aml_recycle_dma_buffers(ctx);
+
                while ((vb2_v4l2 = v4l2_m2m_src_buf_remove(ctx->m2m_ctx)))
                        v4l2_m2m_buf_done(vb2_v4l2, VB2_BUF_STATE_ERROR);
 
-               if (ctx->is_drm_mode && q->memory == VB2_MEMORY_DMABUF)
-                       aml_recycle_dma_buffers(ctx);
+               for (i = 0; i < q->num_buffers; ++i) {
+                       vb2_v4l2 = to_vb2_v4l2_buffer(q->bufs[i]);
+                       if (vb2_v4l2->vb2_buf.state == VB2_BUF_STATE_ACTIVE)
+                               v4l2_m2m_buf_done(vb2_v4l2, VB2_BUF_STATE_ERROR);
+               }
        } else {
                /* clean output cache and decoder status . */
                if (ctx->state > AML_STATE_INIT)
                        aml_vdec_reset(ctx);
 
+               while ((vb2_v4l2 = v4l2_m2m_dst_buf_remove(ctx->m2m_ctx)))
+                       v4l2_m2m_buf_done(vb2_v4l2, VB2_BUF_STATE_ERROR);
+
                for (i = 0; i < q->num_buffers; ++i) {
                        vb2_v4l2 = to_vb2_v4l2_buffer(q->bufs[i]);
                        buf = container_of(vb2_v4l2, struct aml_video_dec_buf, vb);