]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
V4L/DVB (9238): Add support for rgb565 pixel formats to vivi
authorMagnus Damm <damm@igel.co.jp>
Tue, 14 Oct 2008 15:47:35 +0000 (12:47 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Fri, 17 Oct 2008 20:25:05 +0000 (17:25 -0300)
This patch adds RGB565 pixel format support to the vivi driver. Both
little endian and big endian versions are added. The driver follows
the RGB pixel format described in Table 2-2 of the V4L2 API spec,
_not_ the older BGR interpretation described in Table 2-1.

Signed-off-by: Magnus Damm <damm@igel.co.jp>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/video/vivi.c

index 2a6ebc126c09ad6c7aa18acf271a516e740ed610..2fddba6d5b39fbc2a90b3bc70e8b6fac8787f1ef 100644 (file)
@@ -139,6 +139,16 @@ static struct vivi_fmt formats[] = {
                .fourcc   = V4L2_PIX_FMT_UYVY,
                .depth    = 16,
        },
+       {
+               .name     = "RGB565 (LE)",
+               .fourcc   = V4L2_PIX_FMT_RGB565, /* gggbbbbb rrrrrggg */
+               .depth    = 16,
+       },
+       {
+               .name     = "RGB565 (BE)",
+               .fourcc   = V4L2_PIX_FMT_RGB565X, /* rrrrrggg gggbbbbb */
+               .depth    = 16,
+       },
 };
 
 static struct vivi_fmt *get_format(struct v4l2_format *f)
@@ -301,6 +311,30 @@ static void gen_twopix(struct vivi_fh *fh, unsigned char *buf, int colorpos)
                                break;
                        }
                        break;
+               case V4L2_PIX_FMT_RGB565:
+                       switch (color) {
+                       case 0:
+                       case 2:
+                               *p = (g_u << 5) | b_v;
+                               break;
+                       case 1:
+                       case 3:
+                               *p = (r_y << 3) | (g_u >> 3);
+                               break;
+                       }
+                       break;
+               case V4L2_PIX_FMT_RGB565X:
+                       switch (color) {
+                       case 0:
+                       case 2:
+                               *p = (r_y << 3) | (g_u >> 3);
+                               break;
+                       case 1:
+                       case 3:
+                               *p = (g_u << 5) | b_v;
+                               break;
+                       }
+                       break;
                }
        }
 }
@@ -778,6 +812,12 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
                case V4L2_PIX_FMT_UYVY:
                        is_yuv = 1;
                        break;
+               case V4L2_PIX_FMT_RGB565:
+               case V4L2_PIX_FMT_RGB565X:
+                       r >>= 3;
+                       g >>= 2;
+                       b >>= 3;
+                       break;
                }
 
                if (is_yuv) {