MLK-20924-2: ISI: add checking for the number of requested buffer
authorGuoniu.Zhou <guoniu.zhou@nxp.com>
Thu, 14 Feb 2019 02:48:03 +0000 (10:48 +0800)
committerLeonard Crestez <leonard.crestez@nxp.com>
Wed, 17 Apr 2019 23:51:34 +0000 (02:51 +0300)
For the number of requested source buffer, driver need one at least.
For the number of requested destination buffer, driver need three at least.

Signed-off-by: Guoniu.Zhou <guoniu.zhou@nxp.com>
(cherry picked from commit c3d33d6ad971b2e03c034e14696d64549245f918)
(cherry picked from commit 36e36d3c529a16b7b00faddf967bfbf828309a56)

drivers/media/platform/imx8/mxc-isi-m2m.c

index a629bbc..709ea0a 100644 (file)
@@ -173,6 +173,7 @@ static int m2m_vb2_queue_setup(struct vb2_queue *q,
 {
        struct mxc_isi_ctx *mxc_ctx = vb2_get_drv_priv(q);
        struct mxc_isi_dev *mxc_isi = mxc_ctx->isi_dev;
+       struct device *dev = &mxc_isi->pdev->dev;
        struct mxc_isi_frame *frame;
        struct mxc_isi_fmt *fmt;
        unsigned long wh;
@@ -180,15 +181,19 @@ static int m2m_vb2_queue_setup(struct vb2_queue *q,
 
        dev_dbg(&mxc_isi->pdev->dev, "%s\n", __func__);
 
-       if (*num_buffers < 1) {
-               dev_err(&mxc_isi->pdev->dev, "%s at least need one buffer\n", __func__);
-               return -EINVAL;
-       }
-
-       if (q->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
+       if (q->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
+               if (*num_buffers < 3) {
+                       dev_err(dev, "%s at least need 3 buffer\n", __func__);
+                       return -EINVAL;
+               }
                frame = &mxc_isi->m2m.dst_f;
-       else
+       } else {
+               if (*num_buffers < 1) {
+                       dev_err(dev, "%s at least need one buffer\n", __func__);
+                       return -EINVAL;
+               }
                frame = &mxc_isi->m2m.src_f;
+       }
 
        fmt = frame->fmt;
        if (fmt == NULL)
@@ -342,7 +347,7 @@ static void m2m_vb2_stop_streaming(struct vb2_queue *q)
 static struct vb2_ops mxc_m2m_vb2_qops = {
        .queue_setup            = m2m_vb2_queue_setup,
        .buf_prepare            = m2m_vb2_buffer_prepare,
-       .buf_queue                      = m2m_vb2_buffer_queue,
+       .buf_queue              = m2m_vb2_buffer_queue,
        .wait_prepare           = vb2_ops_wait_prepare,
        .wait_finish            = vb2_ops_wait_finish,
        .start_streaming        = m2m_vb2_start_streaming,