v4l2: skip size check for dmabuf on output port [1/1]
authorSong Zhao <song.zhao@amlogic.com>
Thu, 30 Apr 2020 23:39:05 +0000 (16:39 -0700)
committerSong Zhao <song.zhao@amlogic.com>
Thu, 30 Apr 2020 23:52:22 +0000 (16:52 -0700)
PD#SWPL-25323

Problem:
When dmabuf is used on output port, the size of it is decided by the
allocator. But when REQBUFS is called to setup the vb2 queue, the
minimium size of plane is returned by queue_setup(). It will lead to a
sanity check failure in __qbuf_dmabuf().

Solution:
When dmabuf mode is used on output port. queue_setup() will return size
0 for it. And vb2 will use the size of the dmabuf itself.

Verify:
U212 + Cobalt + WV

Change-Id: I47c375f587fd40f4b187d747a58ef8ff0f4214ca
Signed-off-by: Song Zhao <song.zhao@amlogic.com>
drivers/amvdec_ports/aml_vcodec_dec.c

index 83cc40d2dbb26ac9e8618f2ec40dbb624a3c41d3..df2788114b52985ed4e97fe516327df8ad8998de 100644 (file)
@@ -1246,6 +1246,12 @@ static int vidioc_decoder_reqbufs(struct file *file, void *priv,
                                        ctx->state, rb->count, ctx->dpb_size);
                        //rb->count = ctx->dpb_size;
                }
+       } else {
+               if (rb->memory == VB2_MEMORY_DMABUF) {
+                       v4l_dbg(ctx, V4L_DEBUG_CODEC_INPUT,
+                                       "%s, output_dma_mode set", __func__);
+                       ctx->output_dma_mode = true;
+               }
        }
 
        return v4l2_m2m_ioctl_reqbufs(file, priv, rb);
@@ -1988,6 +1994,8 @@ static int vb2ops_vdec_queue_setup(struct vb2_queue *vq,
 
                for (i = 0; i < *nplanes; i++) {
                        sizes[i] = q_data->sizeimage[i];
+                       if (V4L2_TYPE_IS_OUTPUT(vq->type) && ctx->output_dma_mode)
+                               sizes[i] = 0;
                        //alloc_devs[i] = &ctx->dev->plat_dev->dev;
                        alloc_devs[i] = v4l_get_dev_from_codec_mm();//alloc mm from the codec mm
                }
@@ -2010,6 +2018,10 @@ static int vb2ops_vdec_buf_prepare(struct vb2_buffer *vb)
                "%s, type: %d, idx: %d\n",
                __func__, vb->vb2_queue->type, vb->index);
 
+       if (vb->memory == VB2_MEMORY_DMABUF
+               && V4L2_TYPE_IS_OUTPUT(vb->vb2_queue->type))
+               return 0;
+
        q_data = aml_vdec_get_q_data(ctx, vb->vb2_queue->type);
 
        for (i = 0; i < q_data->fmt->num_planes; i++) {
@@ -2105,12 +2117,6 @@ static void vb2ops_vdec_buf_queue(struct vb2_buffer *vb)
        src_mem.size    = vb->planes[0].bytesused;
        src_mem.model   = vb->memory;
 
-       if (vb->memory == VB2_MEMORY_DMABUF) {
-               v4l_dbg(ctx, V4L_DEBUG_CODEC_INPUT,
-                               "%s, output_dma_mode set", __func__);
-               ctx->output_dma_mode = true;
-       }
-
        if (vdec_if_probe(ctx, &src_mem, NULL)) {
                v4l2_m2m_src_buf_remove(ctx->m2m_ctx);