linux-sh.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC 3/5] [media] rcar-vin: add array of supported formats
@ 2016-01-14 13:30 Niklas Söderlund
  0 siblings, 0 replies; only message in thread
From: Niklas Söderlund @ 2016-01-14 13:30 UTC (permalink / raw)
  To: linux-sh

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


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2016-01-14 13:30 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-14 13:30 [RFC 3/5] [media] rcar-vin: add array of supported formats Niklas Söderlund

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