All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eduardo Valentin <eduardo.valentin@nokia.com>
To: Hans Verkuil <hverkuil@xs4all.nl>,
	Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Cc: Linux Media Mailing List <linux-media@vger.kernel.org>,
	Magnus Damm <magnus.damm@gmail.com>,
	Robert Jarzmik <robert.jarzmik@free.fr>,
	Darius Augulis <augulis.darius@gmail.com>,
	Paul Mundt <lethal@linux-sh.org>,
	Eduardo Valentin <eduardo.valentin@nokia.com>
Subject: [RFC] v4l2_subdev i2c: Add i2c board info to v4l2_i2c_new_subdev
Date: Fri, 22 May 2009 13:45:15 +0300	[thread overview]
Message-ID: <1242989115-14948-1-git-send-email-eduardo.valentin@nokia.com> (raw)
In-Reply-To: <20090522085827.GA1964@esdhcp037198.research.nokia.com>

From: Eduardo Valentin <eduardo.valentin@nokia.com>

Device drivers of v4l2_subdev devices may want to have
i2c board info data. This patch adds an helper function
to allow bridge drivers to pass board specific data to
v4l2_subdev drivers.

For those drivers which need to support kernel versions
bellow 2.6.26, a .s_config callback was added. The
idea of this callback is to pass board configuration
as well. In that case, the bridge driver should call
the .s_config of subdevs manually.

Priority: normal

Signed-off-by: "Eduardo Valentin <eduardo.valentin@nokia.com>"

diff -r 315bc4b65b4f -r 778e5e5ecc68 linux/drivers/media/video/v4l2-common.c
--- a/linux/drivers/media/video/v4l2-common.c	Sun May 17 12:28:55 2009 +0000
+++ b/linux/drivers/media/video/v4l2-common.c	Fri May 22 12:59:44 2009 +0300
@@ -819,15 +819,16 @@
 
 
 /* Load an i2c sub-device. */
-struct v4l2_subdev *v4l2_i2c_new_subdev(struct v4l2_device *v4l2_dev,
-		struct i2c_adapter *adapter,
-		const char *module_name, const char *client_type, u8 addr)
+static struct v4l2_subdev *__v4l2_i2c_new_subdev(struct v4l2_device *v4l2_dev,
+		struct i2c_adapter *adapter, const char *module_name,
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 26)
+		struct i2c_board_info *info)
+#else
+		u8 addr)
+#endif
 {
 	struct v4l2_subdev *sd = NULL;
 	struct i2c_client *client;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 26)
-	struct i2c_board_info info;
-#endif
 
 	BUG_ON(!v4l2_dev);
 
@@ -835,14 +836,8 @@
 		request_module(module_name);
 
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 26)
-	/* Setup the i2c board info with the device type and
-	   the device address. */
-	memset(&info, 0, sizeof(info));
-	strlcpy(info.type, client_type, sizeof(info.type));
-	info.addr = addr;
-
 	/* Create the i2c client */
-	client = i2c_new_device(adapter, &info);
+	client = i2c_new_device(adapter, info);
 #else
 	/* Legacy code: loading the module automatically
 	   probes and creates the i2c_client on the adapter.
@@ -877,8 +872,39 @@
 #endif
 	return sd;
 }
+
+struct v4l2_subdev *v4l2_i2c_new_subdev(struct v4l2_device *v4l2_dev,
+		struct i2c_adapter *adapter,
+		const char *module_name, const char *client_type, u8 addr)
+{
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 26)
+	struct i2c_board_info info;
+
+	/* Setup the i2c board info with the device type and
+	   the device address. */
+	memset(&info, 0, sizeof(info));
+	strlcpy(info.type, client_type, sizeof(info.type));
+	info.addr = addr;
+
+	return __v4l2_i2c_new_subdev(v4l2_dev, adapter, module_name,
+					&info);
+#else
+	return __v4l2_i2c_new_subdev(v4l2_dev, adapter, module_name,
+					addr);
+#endif
+}
 EXPORT_SYMBOL_GPL(v4l2_i2c_new_subdev);
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 26)
+struct v4l2_subdev *v4l2_i2c_new_subdev_board_info(struct v4l2_device *v4l2_dev,
+		struct i2c_adapter *adapter, const char *module_name,
+		struct i2c_board_info *i)
+{
+	return __v4l2_i2c_new_subdev(v4l2_dev, adapter, module_name, i);
+}
+EXPORT_SYMBOL_GPL(v4l2_i2c_new_subdev_board_info);
+#endif
+
 /* Probe and load an i2c sub-device. */
 struct v4l2_subdev *v4l2_i2c_new_probed_subdev(struct v4l2_device *v4l2_dev,
 	struct i2c_adapter *adapter,
diff -r 315bc4b65b4f -r 778e5e5ecc68 linux/include/media/v4l2-common.h
--- a/linux/include/media/v4l2-common.h	Sun May 17 12:28:55 2009 +0000
+++ b/linux/include/media/v4l2-common.h	Fri May 22 12:59:44 2009 +0300
@@ -130,6 +130,7 @@
 struct i2c_driver;
 struct i2c_adapter;
 struct i2c_client;
+struct i2c_board_info;
 struct i2c_device_id;
 struct v4l2_device;
 struct v4l2_subdev;
@@ -147,6 +148,13 @@
 struct v4l2_subdev *v4l2_i2c_new_subdev(struct v4l2_device *v4l2_dev,
 		struct i2c_adapter *adapter,
 		const char *module_name, const char *client_type, u8 addr);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 26)
+/* Same as v4l2_i2c_new_subdev, but with opportunity to pass i2c_board_info
+   to client device */
+struct v4l2_subdev *v4l2_i2c_new_subdev_board_info(struct v4l2_device *v4l2_dev,
+		struct i2c_adapter *adapter, const char *module_name,
+		struct i2c_board_info *i);
+#endif
 /* Probe and load an i2c module and return an initialized v4l2_subdev struct.
    Only call request_module if module_name != NULL.
    The client_type argument is the name of the chip that's on the adapter. */
diff -r 315bc4b65b4f -r 778e5e5ecc68 linux/include/media/v4l2-subdev.h
--- a/linux/include/media/v4l2-subdev.h	Sun May 17 12:28:55 2009 +0000
+++ b/linux/include/media/v4l2-subdev.h	Fri May 22 12:59:44 2009 +0300
@@ -96,6 +96,7 @@
 struct v4l2_subdev_core_ops {
 	int (*g_chip_ident)(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip);
 	int (*log_status)(struct v4l2_subdev *sd);
+	int (*s_config)(struct v4l2_subdev *sd, void *config_data);
 	int (*init)(struct v4l2_subdev *sd, u32 val);
 	int (*load_fw)(struct v4l2_subdev *sd);
 	int (*reset)(struct v4l2_subdev *sd, u32 val);

  reply	other threads:[~2009-05-22 10:50 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-15 17:18 [PATCH 00/10 v2] soc-camera conversions Guennadi Liakhovetski
2009-05-15 17:18 ` [PATCH 01/10 v2] soc-camera: prepare soc_camera_platform.c and its users for conversion Guennadi Liakhovetski
2009-05-15 17:19 ` [PATCH 02/10 v2] ARM: convert pcm037 to the new platform-device soc-camera interface Guennadi Liakhovetski
2009-05-20  7:38   ` Sascha Hauer
2009-05-20  9:01     ` Guennadi Liakhovetski
2009-05-20 11:23       ` Sascha Hauer
2009-05-20 12:07         ` Guennadi Liakhovetski
2009-05-22 10:58     ` [PATCH] pcm037: add MT9T031 camera support Guennadi Liakhovetski
2009-05-15 17:19 ` [PATCH 03/10 v2] soc_camera_platform: pass device pointer from soc-camera core on .add_device() Guennadi Liakhovetski
2009-05-15 17:19 ` [PATCH 04/10 v2] soc-camera: convert to platform device Guennadi Liakhovetski
2009-05-15 17:19 ` [PATCH 05/10 v2] sh: soc-camera updates Guennadi Liakhovetski
2009-05-15 17:19 ` [PATCH 06/10 v2] soc-camera: remove unused .iface from struct soc_camera_platform_info Guennadi Liakhovetski
2009-05-15 17:20 ` [PATCH 07/10 v2] sh: prepare board-ap325rxa.c for v4l2-subdev conversion Guennadi Liakhovetski
2009-05-15 17:20 ` [PATCH 08/10 v2] v4l2-subdev: add a v4l2_i2c_subdev_board() function Guennadi Liakhovetski
2009-05-21 13:53   ` Hans Verkuil
2009-05-21 15:33     ` Guennadi Liakhovetski
2009-05-22  8:58       ` Eduardo Valentin
2009-05-22 10:45         ` Eduardo Valentin [this message]
2009-05-22 11:55         ` Hans Verkuil
2009-05-22 12:16           ` Guennadi Liakhovetski
2009-05-22 12:58             ` Hans Verkuil
2009-05-22 13:14               ` Eduardo Valentin
2009-05-25 10:18                 ` Eduardo Valentin
2009-05-25 10:37                   ` [PATCH 1/1] v4l2_subdev i2c: Add v4l2_i2c_new_subdev_board i2c helper function Eduardo Valentin
2009-05-15 17:20 ` [RFC 09/10 v2] v4l2-subdev: re-add s_standby to v4l2_subdev_core_ops Guennadi Liakhovetski
2009-05-21 13:33   ` Hans Verkuil
2009-05-22 14:23     ` Guennadi Liakhovetski
2009-05-22 14:30       ` Hans Verkuil
2009-05-22 16:44       ` Robert Jarzmik
2009-05-22 17:37         ` Guennadi Liakhovetski
2009-05-23 11:49           ` Robert Jarzmik
2009-05-23 15:17             ` Guennadi Liakhovetski
2009-05-15 17:20 ` [PATCH/RFC 10/10 v2] soc-camera: (partially) convert to v4l2-(sub)dev API Guennadi Liakhovetski
2009-05-15 17:31 ` [PATCH 00/10 v2] soc-camera conversions Guennadi Liakhovetski
2009-05-19  3:05 ` Paul Mundt
2009-06-08 19:19   ` Guennadi Liakhovetski
2009-06-09 13:26     ` Paul Mundt

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=1242989115-14948-1-git-send-email-eduardo.valentin@nokia.com \
    --to=eduardo.valentin@nokia.com \
    --cc=augulis.darius@gmail.com \
    --cc=g.liakhovetski@gmx.de \
    --cc=hverkuil@xs4all.nl \
    --cc=lethal@linux-sh.org \
    --cc=linux-media@vger.kernel.org \
    --cc=magnus.damm@gmail.com \
    --cc=robert.jarzmik@free.fr \
    /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.