@@ -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,
@@ -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. */
@@ -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);