linux-sh.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Niklas Söderlund" <niklas.soderlund+renesas@ragnatech.se>
To: linux-sh@vger.kernel.org
Subject: [RFC 3/5] [media] rcar-vin: add array of supported formats
Date: Thu, 14 Jan 2016 13:30:14 +0000	[thread overview]
Message-ID: <1452778216-31978-4-git-send-email-niklas.soderlund+renesas@ragnatech.se> (raw)

Lift over the video formats and helper from the soc_camera driver.
---
 drivers/media/platform/rcar-vin.c | 59 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 59 insertions(+)

diff --git a/drivers/media/platform/rcar-vin.c b/drivers/media/platform/rcar-vin.c
index 06616d4..a062287 100644
--- a/drivers/media/platform/rcar-vin.c
+++ b/drivers/media/platform/rcar-vin.c
@@ -34,6 +34,12 @@ enum chip_id {
 	RCAR_E1,
 };
 
+struct rcar_vin_format {
+	const char *description;
+	u32 fourcc;
+	u8 bpp;
+};
+
 struct rcar_vin {
 	void __iomem *base;
 
@@ -181,6 +187,59 @@ static irqreturn_t rcar_vin_irq(int irq, void *dev_id)
 }
 
 /* -----------------------------------------------------------------------------
+ * Video formats
+ */
+
+static const struct rcar_vin_format rcar_vin_formats[] = {
+	{
+		.description		= "NV16",
+		.fourcc			= V4L2_PIX_FMT_NV16,
+		.bpp			= 8,
+	},
+	{
+		.description		= "YUYV",
+		.fourcc			= V4L2_PIX_FMT_YUYV,
+		.bpp			= 16,
+	},
+	{
+		.description		= "UYVY",
+		.fourcc			= V4L2_PIX_FMT_UYVY,
+		.bpp			= 16,
+	},
+	{
+		.description		= "RGB565",
+		.fourcc			= V4L2_PIX_FMT_RGB565,
+		.bpp			= 16,
+	},
+	{
+		.description		= "ARGB1555",
+		.fourcc			= V4L2_PIX_FMT_RGB555X,
+		.bpp			= 16,
+	},
+	{
+		.description		= "RGB888",
+		.fourcc			= V4L2_PIX_FMT_RGB32,
+		.bpp			= 32,
+	},
+};
+
+
+
+const struct rcar_vin_format *rcar_vin_get_format_by_fourcc(u32 fourcc)
+{
+	unsigned int i;
+
+	for (i = 0; i < ARRAY_SIZE(rcar_vin_formats); ++i) {
+		const struct rcar_vin_format *format = &rcar_vin_formats[i];
+
+		if (format->fourcc = fourcc)
+			return format;
+	}
+
+	return ERR_PTR(-EINVAL);
+}
+
+/* -----------------------------------------------------------------------------
  * Platform Device Driver
  */
 
-- 
2.7.0


                 reply	other threads:[~2016-01-14 13:30 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1452778216-31978-4-git-send-email-niklas.soderlund+renesas@ragnatech.se \
    --to=niklas.soderlund+renesas@ragnatech.se \
    --cc=linux-sh@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).