NV12/21/16/61 had been added every time
UYVY/VYUY/YUYV/YVYU appears on get_formats.
This patch modify this problem.

Signed-off-by: Kuninori Morimoto <[email protected]>
---
[before]
Format NV12   (12 bits, NV12): Planar NV12
Format NV21   (12 bits, NV21): Planar NV21
Format unknown (0x3631564e) ( 0 bits, NV16): Unknown 0x3631564e
Format unknown (0x3136564e) ( 0 bits, NV61): Unknown 0x3136564e
Format YUYV   (16 bits, YUYV): Packed YUY2
Format NV12   (12 bits, NV12): Planar NV12
Format NV21   (12 bits, NV21): Planar NV21
Format unknown (0x3631564e) ( 0 bits, NV16): Unknown 0x3631564e
Format unknown (0x3136564e) ( 0 bits, NV61): Unknown 0x3136564e
Format unknown (0x55595659) ( 0 bits, YVYU): Packed YVYU
Format NV12   (12 bits, NV12): Planar NV12
Format NV21   (12 bits, NV21): Planar NV21
Format unknown (0x3631564e) ( 0 bits, NV16): Unknown 0x3631564e
Format unknown (0x3136564e) ( 0 bits, NV61): Unknown 0x3136564e
Format UYVY   (16 bits, UYVY): Packed UYVY
Format RGB555 (16 bits, RGB555): BGR 15-bit
Format RGB555X (16 bits, RGB555X): Unknown 0x51424752
Format RGB565 (16 bits, RGB565): BGR 16-bit
Format RGB565X (16 bits, RGB565X): Unknown 0x52424752

[after]
Format NV12   (12 bits, NV12): Planar NV12
Format NV21   (12 bits, NV21): Planar NV21
Format unknown (0x3631564e) ( 0 bits, NV16): Unknown 0x3631564e
Format unknown (0x3136564e) ( 0 bits, NV61): Unknown 0x3136564e
Format YUYV   (16 bits, YUYV): Packed YUY2
Format unknown (0x55595659) ( 0 bits, YVYU): Packed YVYU
Format UYVY   (16 bits, UYVY): Packed UYVY
Format RGB555 (16 bits, RGB555): BGR 15-bit
Format RGB555X (16 bits, RGB555X): Unknown 0x51424752
Format RGB565 (16 bits, RGB565): BGR 16-bit
Format RGB565X (16 bits, RGB565X): Unknown 0x52424752

 drivers/media/video/sh_mobile_ceu_camera.c |   64 ++++++++++++++++------------
 1 files changed, 36 insertions(+), 28 deletions(-)

diff --git a/drivers/media/video/sh_mobile_ceu_camera.c 
b/drivers/media/video/sh_mobile_ceu_camera.c
index 9a2586b..9cde91a 100644
--- a/drivers/media/video/sh_mobile_ceu_camera.c
+++ b/drivers/media/video/sh_mobile_ceu_camera.c
@@ -555,42 +555,50 @@ static int sh_mobile_ceu_get_formats(struct 
soc_camera_device *icd, int idx,
                                     struct soc_camera_format_xlate *xlate)
 {
        struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
-       int ret, k, n;
+       int ret, i, k, n;
        int formats = 0;
 
        ret = sh_mobile_ceu_try_bus_param(icd);
        if (ret < 0)
                return 0;
 
-       switch (icd->formats[idx].fourcc) {
-       case V4L2_PIX_FMT_UYVY:
-       case V4L2_PIX_FMT_VYUY:
-       case V4L2_PIX_FMT_YUYV:
-       case V4L2_PIX_FMT_YVYU:
-               n = ARRAY_SIZE(sh_mobile_ceu_formats);
-               formats += n;
-               for (k = 0; xlate && k < n; k++) {
-                       xlate->host_fmt = &sh_mobile_ceu_formats[k];
-                       xlate->cam_fmt = icd->formats + idx;
-                       xlate->buswidth = icd->formats[idx].depth;
-                       xlate++;
-                       dev_dbg(&ici->dev, "Providing format %s using %s\n",
-                               sh_mobile_ceu_formats[k].name,
-                               icd->formats[idx].name);
-               }
-       default:
-               /* Generic pass-through */
-               formats++;
-               if (xlate) {
-                       xlate->host_fmt = icd->formats + idx;
-                       xlate->cam_fmt = icd->formats + idx;
-                       xlate->buswidth = icd->formats[idx].depth;
-                       xlate++;
-                       dev_dbg(&ici->dev,
-                               "Providing format %s in pass-through mode\n",
-                               icd->formats[idx].name);
+       /* yuv color format check when idx == 0 */
+       if (idx)
+               goto yuv_check_done;
+
+       for (i = 0 ; i < icd->num_formats ; i++) {
+               switch (icd->formats[i].fourcc) {
+               case V4L2_PIX_FMT_UYVY:
+               case V4L2_PIX_FMT_VYUY:
+               case V4L2_PIX_FMT_YUYV:
+               case V4L2_PIX_FMT_YVYU:
+                       n = ARRAY_SIZE(sh_mobile_ceu_formats);
+                       formats += n;
+                       for (k = 0; xlate && k < n; k++) {
+                               xlate->host_fmt = &sh_mobile_ceu_formats[k];
+                               xlate->cam_fmt = icd->formats + i;
+                               xlate->buswidth = icd->formats[i].depth;
+                               xlate++;
+                               dev_dbg(&ici->dev,
+                                       "Providing format %s using %s\n",
+                                       sh_mobile_ceu_formats[k].name,
+                                       icd->formats[i].name);
+                       }
+                       goto yuv_check_done;
                }
        }
+yuv_check_done:
+
+       formats++;
+       if (xlate) {
+               xlate->host_fmt = icd->formats + idx;
+               xlate->cam_fmt = icd->formats + idx;
+               xlate->buswidth = icd->formats[idx].depth;
+               xlate++;
+               dev_dbg(&ici->dev,
+                       "Providing format %s in pass-through mode\n",
+                       icd->formats[idx].name);
+       }
 
        return formats;
 }
-- 
1.5.6.3

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to