summaryrefslogtreecommitdiff
path: root/linux/drivers/media/video
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil@xs4all.nl>2007-09-12 13:32:50 +0200
committerHans Verkuil <hverkuil@xs4all.nl>2007-09-12 13:32:50 +0200
commit30e50fe332679825e6f54936c7c5e97bf109584d (patch)
treedb84205596207a8503b4133d6bc75fbd30342b6c /linux/drivers/media/video
parent55c585d89d06e29009f8bdc652c54e3de0993c4a (diff)
downloadmediapointer-dvb-s2-30e50fe332679825e6f54936c7c5e97bf109584d.tar.gz
mediapointer-dvb-s2-30e50fe332679825e6f54936c7c5e97bf109584d.tar.bz2
v4l2: add support for bus-based I2C drivers
From: Hans Verkuil <hverkuil@xs4all.nl> Two new headers were added: one for I2C drivers that are only used by V4L2 drivers converted to the new bus-based I2C API, and one that can be used by both converted and unconverted drivers (at the expense of some additional overhead). To support the legacy I2C API a helper function was added to v4l2-common.c. These headers take care of all the 'boilerplate' code that all V4L2 I2C drivers have in common and will automatically support the bus-based I2C API introduced in kernel 2.6.22. Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org> --- linux/drivers/media/video/v4l2-common.c | 37 +++++ linux/include/media/v4l2-common.h | 11 + linux/include/media/v4l2-i2c-drv-legacy.h | 207 ++++++++++++++++++++++++++++++ linux/include/media/v4l2-i2c-drv.h | 199 ++++++++++++++++++++++++++++ 4 files changed, 454 insertions(+)
Diffstat (limited to 'linux/drivers/media/video')
-rw-r--r--linux/drivers/media/video/v4l2-common.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/linux/drivers/media/video/v4l2-common.c b/linux/drivers/media/video/v4l2-common.c
index 476b5ea5a..ef4514369 100644
--- a/linux/drivers/media/video/v4l2-common.c
+++ b/linux/drivers/media/video/v4l2-common.c
@@ -1625,6 +1625,41 @@ int v4l2_chip_match_host(u32 match_type, u32 match_chip)
/* ----------------------------------------------------------------- */
+/* Helper function for I2C legacy drivers */
+
+int v4l2_i2c_attach(struct i2c_adapter *adapter, int address, struct i2c_driver *driver,
+ const char *name, int (*probe)(struct i2c_client *))
+{
+ struct i2c_client *client;
+ int err;
+
+ client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL);
+ if (client == 0)
+ return -ENOMEM;
+
+ client->addr = address;
+ client->adapter = adapter;
+ client->driver = driver;
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,15)
+ client->flags = I2C_CLIENT_ALLOW_USE;
+#endif
+ snprintf(client->name, sizeof(client->name) - 1, name);
+
+ err = probe(client);
+ if (err == 0) {
+ i2c_attach_client(client);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+ MOD_INC_USE_COUNT;
+#endif
+ }
+ else {
+ kfree(client);
+ }
+ return err;
+}
+
+/* ----------------------------------------------------------------- */
+
EXPORT_SYMBOL(v4l2_norm_to_name);
EXPORT_SYMBOL(v4l2_video_std_construct);
@@ -1650,6 +1685,8 @@ EXPORT_SYMBOL(v4l2_chip_match_i2c_client);
EXPORT_SYMBOL(v4l2_chip_ident_i2c_client);
EXPORT_SYMBOL(v4l2_chip_match_host);
+EXPORT_SYMBOL(v4l2_i2c_attach);
+
/*
* Local variables:
* c-basic-offset: 8