[media] soc-camera: Support user-configurable line stride
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Wed, 21 Mar 2012 11:03:28 +0000 (08:03 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Tue, 15 May 2012 19:12:54 +0000 (16:12 -0300)
Add a capabilities field to the soc_camera_host structure to flag hosts
that support user-configurable line strides. soc_camera_try_fmt() then
passes the user-provided bytesperline and sizeimage format fields to
such hosts, and expects the host to check (and fix if needed) the
values.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
[g.liakhovetski@gmx.de: fix a typo in mx2_camera.c]
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/video/mx2_camera.c
drivers/media/video/soc_camera.c
include/media/soc_camera.h

index b63168781cfedcbc6c34d746b687e8bdff6db9a2..ecd83faf90380fbec2389e53b725ac605df2903f 100644 (file)
@@ -1787,6 +1787,8 @@ static int __devinit mx2_camera_probe(struct platform_device *pdev)
        pcdev->soc_host.priv            = pcdev;
        pcdev->soc_host.v4l2_dev.dev    = &pdev->dev;
        pcdev->soc_host.nr              = pdev->id;
+       if (cpu_is_mx25())
+               pcdev->soc_host.capabilities = SOCAM_HOST_CAP_STRIDE;
 
        pcdev->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev);
        if (IS_ERR(pcdev->alloc_ctx)) {
index 5e3274e557564194d07d6fbc6600aeaf21b138bf..cfac53544ba677f4a5103ab9675cad9bd1da4590 100644 (file)
@@ -171,8 +171,10 @@ static int soc_camera_try_fmt(struct soc_camera_device *icd,
        dev_dbg(icd->pdev, "TRY_FMT(%c%c%c%c, %ux%u)\n",
                pixfmtstr(pix->pixelformat), pix->width, pix->height);
 
-       pix->bytesperline = 0;
-       pix->sizeimage = 0;
+       if (!(ici->capabilities & SOCAM_HOST_CAP_STRIDE)) {
+               pix->bytesperline = 0;
+               pix->sizeimage = 0;
+       }
 
        ret = ici->ops->try_fmt(icd, f);
        if (ret < 0)
index a87062c393b54f174f59f4270775ea69cc479971..d865dcf9879fe18092241e074807b1600ff57bbf 100644 (file)
@@ -56,11 +56,15 @@ struct soc_camera_device {
        };
 };
 
+/* Host supports programmable stride */
+#define SOCAM_HOST_CAP_STRIDE          (1 << 0)
+
 struct soc_camera_host {
        struct v4l2_device v4l2_dev;
        struct list_head list;
        struct mutex host_lock;         /* Protect during probing */
        unsigned char nr;               /* Host number */
+       u32 capabilities;
        void *priv;
        const char *drv_name;
        struct soc_camera_host_ops *ops;