[media] em28xx: add support for registering multiple i2c buses
Register both buses 0 and 1 via I2C API. For now, bus 0 is used
only by eeprom on all known devices. Later patches will be needed
if this changes in the future.
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
diff --git a/drivers/media/usb/em28xx/em28xx.h b/drivers/media/usb/em28xx/em28xx.h
index 43eb1c6..f6ac1df 100644
--- a/drivers/media/usb/em28xx/em28xx.h
+++ b/drivers/media/usb/em28xx/em28xx.h
@@ -375,7 +375,7 @@
int vchannels;
int tuner_type;
int tuner_addr;
- int def_i2c_bus; /* Default I2C bus */
+ unsigned def_i2c_bus; /* Default I2C bus */
/* i2c flags */
unsigned int tda9887_conf;
@@ -460,6 +460,13 @@
enum v4l2_buf_type type;
};
+struct em28xx_i2c_bus {
+ struct em28xx *dev;
+
+ unsigned bus;
+};
+
+
/* main device struct */
struct em28xx {
/* generic device properties */
@@ -515,8 +522,12 @@
/* i2c i/o */
struct i2c_adapter i2c_adap[NUM_I2C_BUSES];
struct i2c_client i2c_client[NUM_I2C_BUSES];
+ struct em28xx_i2c_bus i2c_bus[NUM_I2C_BUSES];
+
unsigned char eeprom_addrwidth_16bit:1;
- int def_i2c_bus; /* Default I2C bus */
+ unsigned def_i2c_bus; /* Default I2C bus */
+ unsigned cur_i2c_bus; /* Current I2C bus */
+ struct rt_mutex i2c_bus_lock;
/* video for linux */
int users; /* user count for exclusive use */
@@ -638,9 +649,9 @@
};
/* Provided by em28xx-i2c.c */
-void em28xx_do_i2c_scan(struct em28xx *dev);
-int em28xx_i2c_register(struct em28xx *dev);
-int em28xx_i2c_unregister(struct em28xx *dev);
+void em28xx_do_i2c_scan(struct em28xx *dev, unsigned bus);
+int em28xx_i2c_register(struct em28xx *dev, unsigned bus);
+int em28xx_i2c_unregister(struct em28xx *dev, unsigned bus);
/* Provided by em28xx-core.c */
int em28xx_read_reg_req_len(struct em28xx *dev, u8 req, u16 reg,