[media] media: blackfin: bfin_capture: improve queue_setup() callback
authorLad, Prabhakar <prabhakar.csengg@gmail.com>
Sun, 8 Mar 2015 14:40:41 +0000 (11:40 -0300)
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>
Thu, 2 Apr 2015 21:11:18 +0000 (18:11 -0300)
This patch does the following:
a: returns -EINVAL in case format image size is less
   then current image size.
b: assigns nbuffers to two in case the total of vq->num_buffers
   and nbuffers is less then the number of buffers required by driver.
c: sets the sizes[0] of plane according to the fmt passed or which is
   being set in the device.

Signed-off-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Tested-by: Scott Jiang <scott.jiang.linux@gmail.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
drivers/media/platform/blackfin/bfin_capture.c

index a5881297c9ea9ae9678c30d4a93a7554d81ab536..bf7e9997b794a7cd8e1e9964061c5b03ccd046ca 100644 (file)
@@ -44,7 +44,6 @@
 #include <media/blackfin/ppi.h>
 
 #define CAPTURE_DRV_NAME        "bfin_capture"
-#define BCAP_MIN_NUM_BUF        2
 
 struct bcap_format {
        char *desc;
@@ -292,11 +291,14 @@ static int bcap_queue_setup(struct vb2_queue *vq,
 {
        struct bcap_device *bcap_dev = vb2_get_drv_priv(vq);
 
-       if (*nbuffers < BCAP_MIN_NUM_BUF)
-               *nbuffers = BCAP_MIN_NUM_BUF;
+       if (fmt && fmt->fmt.pix.sizeimage < bcap_dev->fmt.sizeimage)
+               return -EINVAL;
+
+       if (vq->num_buffers + *nbuffers < 2)
+               *nbuffers = 2;
 
        *nplanes = 1;
-       sizes[0] = bcap_dev->fmt.sizeimage;
+       sizes[0] = fmt ? fmt->fmt.pix.sizeimage : bcap_dev->fmt.sizeimage;
        alloc_ctxs[0] = bcap_dev->alloc_ctx;
 
        return 0;