All of lore.kernel.org
 help / color / mirror / Atom feed
From: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
To: Linux Media Mailing List <linux-media@vger.kernel.org>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	Deepthy Ravi <deepthy.ravi@ti.com>
Subject: [PATCH 1/9] V4L: soc-camera: add a function to lookup xlate by mediabus code
Date: Thu, 29 Sep 2011 18:18:49 +0200	[thread overview]
Message-ID: <1317313137-4403-2-git-send-email-g.liakhovetski@gmx.de> (raw)
In-Reply-To: <1317313137-4403-1-git-send-email-g.liakhovetski@gmx.de>

In addition to a helper function, performing a format translation table
lookup by a fourcc value, a similar function is now needed to lookup
translation table entries by mediabus codes.

Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
---
 drivers/media/video/soc_camera.c |   25 ++++++++++++++++++++++++-
 include/media/soc_camera.h       |    6 +++++-
 2 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/drivers/media/video/soc_camera.c b/drivers/media/video/soc_camera.c
index b72580c..ba409ac 100644
--- a/drivers/media/video/soc_camera.c
+++ b/drivers/media/video/soc_camera.c
@@ -112,7 +112,7 @@ static int soc_camera_power_off(struct soc_camera_device *icd,
 }
 
 const struct soc_camera_format_xlate *soc_camera_xlate_by_fourcc(
-	struct soc_camera_device *icd, unsigned int fourcc)
+	const struct soc_camera_device *icd, u32 fourcc)
 {
 	unsigned int i;
 
@@ -123,6 +123,29 @@ const struct soc_camera_format_xlate *soc_camera_xlate_by_fourcc(
 }
 EXPORT_SYMBOL(soc_camera_xlate_by_fourcc);
 
+/*
+ * Warning: the mediabus code -> fourcc mapping is not unique, this is why we
+ * need a hint of a preferred fourcc value. Use 0 if unknown.
+ */
+const struct soc_camera_format_xlate *soc_camera_xlate_by_mcode(
+	const struct soc_camera_device *icd, enum v4l2_mbus_pixelcode code,
+	u32 fourcc)
+{
+	unsigned int i;
+	struct soc_camera_format_xlate *xlate = NULL;
+
+	for (i = 0; i < icd->num_user_formats; i++)
+		if (icd->user_formats[i].code == code) {
+			if (icd->user_formats[i].host_fmt->fourcc == fourcc)
+				return icd->user_formats + i;
+			/* Prefer the first one */
+			if (!xlate)
+				xlate = icd->user_formats + i;
+		}
+	return xlate;
+}
+EXPORT_SYMBOL(soc_camera_xlate_by_mcode);
+
 /**
  * soc_camera_apply_board_flags() - apply platform SOCAM_SENSOR_INVERT_* flags
  * @icl:	camera platform parameters
diff --git a/include/media/soc_camera.h b/include/media/soc_camera.h
index b1377b9..22e4bee 100644
--- a/include/media/soc_camera.h
+++ b/include/media/soc_camera.h
@@ -174,7 +174,11 @@ int soc_camera_host_register(struct soc_camera_host *ici);
 void soc_camera_host_unregister(struct soc_camera_host *ici);
 
 const struct soc_camera_format_xlate *soc_camera_xlate_by_fourcc(
-	struct soc_camera_device *icd, unsigned int fourcc);
+	const struct soc_camera_device *icd, u32 fourcc);
+
+const struct soc_camera_format_xlate *soc_camera_xlate_by_mcode(
+	const struct soc_camera_device *icd, enum v4l2_mbus_pixelcode code,
+	u32 fourcc);
 
 /**
  * struct soc_camera_format_xlate - match between host and sensor formats
-- 
1.7.2.5


  reply	other threads:[~2011-09-29 16:19 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-29 16:18 [PATCH 0/9] Media Controller for soc-camera Guennadi Liakhovetski
2011-09-29 16:18 ` Guennadi Liakhovetski [this message]
2011-09-29 16:18 ` [PATCH 2/9] sh_mobile_ceu_camera: simplify scaling and cropping algorithms Guennadi Liakhovetski
2011-09-29 16:18 ` [PATCH 3/9] V4L: soc-camera: remove redundant parameter from the .set_bus_param() method Guennadi Liakhovetski
2011-09-29 16:18 ` [PATCH 4/9] V4L: add convenience macros to the subdevice / Media Controller API Guennadi Liakhovetski
2011-09-29 16:18 ` [PATCH 5/9] V4L: soc-camera: move bus parameter configuration to .vidioc_streamon() Guennadi Liakhovetski
2011-09-29 16:18 ` [PATCH 6/9] V4L: soc-camera: prepare hooks for Media Controller wrapper Guennadi Liakhovetski
2011-10-03 10:32   ` Laurent Pinchart
2011-09-29 16:18 ` [PATCH 7/9] V4L: soc-camera: add a " Guennadi Liakhovetski
2011-10-03 11:05   ` Laurent Pinchart
2011-10-03 15:29     ` Guennadi Liakhovetski
2011-10-03 20:44       ` Laurent Pinchart
2011-10-04 17:34         ` Guennadi Liakhovetski
2011-10-05 21:15           ` Laurent Pinchart
2011-09-29 16:18 ` [PATCH 8/9] V4L: mt9t112: add pad level operations Guennadi Liakhovetski
2011-10-03 11:14   ` Laurent Pinchart
2011-09-29 16:18 ` [PATCH 9/9] V4L: imx074: " Guennadi Liakhovetski
2011-10-03 11:21 ` [PATCH 0/9] Media Controller for soc-camera Laurent Pinchart

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=1317313137-4403-2-git-send-email-g.liakhovetski@gmx.de \
    --to=g.liakhovetski@gmx.de \
    --cc=deepthy.ravi@ti.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.