All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: linux-media@vger.kernel.org
Cc: Guennadi Liakhovetski <g.liakhovetski@gmx.de>,
	Sascha Hauer <s.hauer@pengutronix.de>
Subject: [PATCH 2/4] pcm990 baseboard: add camera bus width switch setting
Date: Wed, 11 Mar 2009 11:06:14 +0100	[thread overview]
Message-ID: <1236765976-20581-3-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1236765976-20581-2-git-send-email-s.hauer@pengutronix.de>

Some Phytec cameras have a I2C GPIO expander which allows it to
switch between different sensor bus widths. This was previously
handled in the camera driver. Since handling of this switch
varies on several boards the cameras are used on, the board
support seems a better place to handle the switch

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 arch/arm/mach-pxa/pcm990-baseboard.c |   50 +++++++++++++++++++++++++++------
 1 files changed, 41 insertions(+), 9 deletions(-)

diff --git a/arch/arm/mach-pxa/pcm990-baseboard.c b/arch/arm/mach-pxa/pcm990-baseboard.c
index 34841c7..e9feb89 100644
--- a/arch/arm/mach-pxa/pcm990-baseboard.c
+++ b/arch/arm/mach-pxa/pcm990-baseboard.c
@@ -381,14 +381,46 @@ static struct pca953x_platform_data pca9536_data = {
 	.gpio_base	= NR_BUILTIN_GPIO + 1,
 };
 
-static struct soc_camera_link iclink[] = {
-	{
-		.bus_id	= 0, /* Must match with the camera ID above */
-		.gpio	= NR_BUILTIN_GPIO + 1,
-	}, {
-		.bus_id	= 0, /* Must match with the camera ID above */
-		.gpio	= -ENXIO,
+static int gpio_bus_switch;
+
+static int pcm990_camera_set_bus_param(struct device *dev,
+		unsigned long flags)
+{
+	if (gpio_bus_switch <= 0)
+		return 0;
+
+	if (flags & SOCAM_DATAWIDTH_8)
+		gpio_set_value(NR_BUILTIN_GPIO + 1, 1);
+	else
+		gpio_set_value(NR_BUILTIN_GPIO + 1, 0);
+
+	return 0;
+}
+
+static unsigned long pcm990_camera_query_bus_param(struct device *dev)
+{
+	int ret;
+
+	if (!gpio_bus_switch) {
+		ret = gpio_request(NR_BUILTIN_GPIO + 1, "camera");
+		if (!ret) {
+			gpio_bus_switch = NR_BUILTIN_GPIO + 1;
+			gpio_direction_output(gpio_bus_switch, 0);
+		} else
+			gpio_bus_switch = -1;
 	}
+
+	if (gpio_bus_switch > 0)
+		return SOCAM_DATAWIDTH_8 | SOCAM_DATAWIDTH_10;
+	else
+		return SOCAM_DATAWIDTH_10;
+}
+
+static struct soc_camera_link iclink = {
+	.bus_id	= 0, /* Must match with the camera ID above */
+	.query_bus_param = pcm990_camera_query_bus_param,
+	.set_bus_param = pcm990_camera_set_bus_param,
+	.gpio	= NR_BUILTIN_GPIO + 1,
 };
 
 /* Board I2C devices. */
@@ -399,10 +431,10 @@ static struct i2c_board_info __initdata pcm990_i2c_devices[] = {
 		.platform_data = &pca9536_data,
 	}, {
 		I2C_BOARD_INFO("mt9v022", 0x48),
-		.platform_data = &iclink[0], /* With extender */
+		.platform_data = &iclink, /* With extender */
 	}, {
 		I2C_BOARD_INFO("mt9m001", 0x5d),
-		.platform_data = &iclink[0], /* With extender */
+		.platform_data = &iclink, /* With extender */
 	},
 };
 #endif /* CONFIG_VIDEO_PXA27x ||CONFIG_VIDEO_PXA27x_MODULE */
-- 
1.5.6.5


  reply	other threads:[~2009-03-11 10:07 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-11 10:06 [PATCH 0/4] soc-camera: setting the buswidth of camera sensors Sascha Hauer
2009-03-11 10:06 ` [PATCH 1/4] soc-camera: add board hook to specify the buswidth for " Sascha Hauer
2009-03-11 10:06   ` Sascha Hauer [this message]
2009-03-11 10:06     ` [PATCH 3/4] mt9m001: allow setting of bus width from board code Sascha Hauer
2009-03-11 10:06       ` [PATCH 4/4] mt9v022: " Sascha Hauer
2009-03-12  9:43         ` Guennadi Liakhovetski
2009-03-12  9:21       ` [PATCH 3/4] mt9m001: " Guennadi Liakhovetski
2009-03-12  8:31     ` [PATCH 2/4] pcm990 baseboard: add camera bus width switch setting Guennadi Liakhovetski
2009-03-12  8:40       ` Sascha Hauer
2009-03-12  8:40     ` Guennadi Liakhovetski
2009-03-12  9:12       ` Sascha Hauer
2009-03-12  9:25         ` Guennadi Liakhovetski
2009-03-12  9:47           ` Sascha Hauer
2009-03-12  8:11   ` [PATCH 1/4] soc-camera: add board hook to specify the buswidth for camera sensors Guennadi Liakhovetski

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=1236765976-20581-3-git-send-email-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=g.liakhovetski@gmx.de \
    --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.