diff options
author | Magnus Damm <damm@igel.co.jp> | 2008-10-14 11:47:35 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2008-10-17 16:25:05 -0400 |
commit | aeadb5d4e590ed0d678ab0bb5fe068160a49e79d (patch) | |
tree | c65312052e1bda694d97d4512451d27eb3610e13 /drivers/media/video/vivi.c | |
parent | fca36bab973303fec01b367a5be644495e8b958d (diff) |
V4L/DVB (9238): Add support for rgb565 pixel formats to vivi
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>
Diffstat (limited to 'drivers/media/video/vivi.c')
-rw-r--r-- | drivers/media/video/vivi.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/drivers/media/video/vivi.c b/drivers/media/video/vivi.c index 2a6ebc126c09..2fddba6d5b39 100644 --- a/drivers/media/video/vivi.c +++ b/drivers/media/video/vivi.c | |||
@@ -139,6 +139,16 @@ static struct vivi_fmt formats[] = { | |||
139 | .fourcc = V4L2_PIX_FMT_UYVY, | 139 | .fourcc = V4L2_PIX_FMT_UYVY, |
140 | .depth = 16, | 140 | .depth = 16, |
141 | }, | 141 | }, |
142 | { | ||
143 | .name = "RGB565 (LE)", | ||
144 | .fourcc = V4L2_PIX_FMT_RGB565, /* gggbbbbb rrrrrggg */ | ||
145 | .depth = 16, | ||
146 | }, | ||
147 | { | ||
148 | .name = "RGB565 (BE)", | ||
149 | .fourcc = V4L2_PIX_FMT_RGB565X, /* rrrrrggg gggbbbbb */ | ||
150 | .depth = 16, | ||
151 | }, | ||
142 | }; | 152 | }; |
143 | 153 | ||
144 | static struct vivi_fmt *get_format(struct v4l2_format *f) | 154 | 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) | |||
301 | break; | 311 | break; |
302 | } | 312 | } |
303 | break; | 313 | break; |
314 | case V4L2_PIX_FMT_RGB565: | ||
315 | switch (color) { | ||
316 | case 0: | ||
317 | case 2: | ||
318 | *p = (g_u << 5) | b_v; | ||
319 | break; | ||
320 | case 1: | ||
321 | case 3: | ||
322 | *p = (r_y << 3) | (g_u >> 3); | ||
323 | break; | ||
324 | } | ||
325 | break; | ||
326 | case V4L2_PIX_FMT_RGB565X: | ||
327 | switch (color) { | ||
328 | case 0: | ||
329 | case 2: | ||
330 | *p = (r_y << 3) | (g_u >> 3); | ||
331 | break; | ||
332 | case 1: | ||
333 | case 3: | ||
334 | *p = (g_u << 5) | b_v; | ||
335 | break; | ||
336 | } | ||
337 | break; | ||
304 | } | 338 | } |
305 | } | 339 | } |
306 | } | 340 | } |
@@ -778,6 +812,12 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, | |||
778 | case V4L2_PIX_FMT_UYVY: | 812 | case V4L2_PIX_FMT_UYVY: |
779 | is_yuv = 1; | 813 | is_yuv = 1; |
780 | break; | 814 | break; |
815 | case V4L2_PIX_FMT_RGB565: | ||
816 | case V4L2_PIX_FMT_RGB565X: | ||
817 | r >>= 3; | ||
818 | g >>= 2; | ||
819 | b >>= 3; | ||
820 | break; | ||
781 | } | 821 | } |
782 | 822 | ||
783 | if (is_yuv) { | 823 | if (is_yuv) { |