public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Magnus Damm <magnus.damm@gmail.com>
To: video4linux-list@redhat.com
Cc: v4l-dvb-maintainer@linuxtv.org, mchehab@infradead.org
Subject: [PATCH 04/05] video: Add support for rgb565 pixel formats to vivi
Date: Tue, 14 Oct 2008 21:47:35 +0900	[thread overview]
Message-ID: <20081014124735.5194.46887.sendpatchset@rx1.opensource.se> (raw)
In-Reply-To: <20081014124651.5194.93168.sendpatchset@rx1.opensource.se>

From: Magnus Damm <damm@igel.co.jp>

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>
---

 drivers/media/video/vivi.c |   40 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)

--- 0018/drivers/media/video/vivi.c
+++ work/drivers/media/video/vivi.c	2008-10-14 20:28:17.000000000 +0900
@@ -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 *f
 				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 f
 		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) {

--
video4linux-list mailing list
Unsubscribe mailto:video4linux-list-request@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list

  parent reply	other threads:[~2008-10-14 12:48 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-14 12:46 [PATCH 00/05] video: Extended vivi pixel format support Magnus Damm
2008-10-14 12:46 ` [PATCH 01/05] video: Precalculate vivi yuv values Magnus Damm
2008-10-14 12:47 ` [PATCH 02/05] video: Teach vivi about multiple pixel formats Magnus Damm
2008-10-14 12:47 ` [PATCH 03/05] video: Add uyvy pixel format support to vivi Magnus Damm
2008-10-14 12:47 ` Magnus Damm [this message]
2008-10-14 12:47 ` [PATCH 05/05] video: Add support for rgb555 pixel formats " Magnus Damm

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20081014124735.5194.46887.sendpatchset@rx1.opensource.se \
    --to=magnus.damm@gmail.com \
    --cc=mchehab@infradead.org \
    --cc=v4l-dvb-maintainer@linuxtv.org \
    --cc=video4linux-list@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox