go7007: Convert to the new i2c device binding model
PATCH 1/1 go7007: Convert to the new i2c device binding model
Move the go7007 driver away from the legacy i2c binding model, which is going away really soon now.
I am puzzled by the s2250 I2C address, 0x86 really doesn't fit in 7 bits, there must be something wrong.
---
This needs testing.
drivers/staging/go7007/go7007-driver.c | 11 +++- drivers/staging/go7007/go7007-i2c.c | 83 ------------------------------- drivers/staging/go7007/go7007-priv.h | 1 drivers/staging/go7007/go7007-usb.c | 14 ++++- drivers/staging/go7007/s2250-board.c | 75 ++++++++++++---------------- drivers/staging/go7007/wis-i2c.h | 9 --- drivers/staging/go7007/wis-ov7640.c | 54 +++++--------------- drivers/staging/go7007/wis-saa7113.c | 60 +++++++--------------- drivers/staging/go7007/wis-saa7115.c | 60 +++++++--------------- drivers/staging/go7007/wis-sony-tuner.c | 60 ++++++---------------- drivers/staging/go7007/wis-tw2804.c | 57 ++++++--------------- drivers/staging/go7007/wis-tw9903.c | 60 +++++++--------------- drivers/staging/go7007/wis-uda1342.c | 52 +++++-------------- 13 files changed, 179 insertions(+), 417 deletions(-)
drivers/staging/go7007/go7007-driver.c +9 -2
@@ -191,8 +191,10 @@ int go7007_reset_encoder(struct go7007 */* * Attempt to instantiate an I2C client by ID, probably loading a module. */ -static int init_i2c_module (struct i2c_adapter *adapter,int id,int addr) +static int init_i2c_module (struct i2c_adapter *adapter,const char *type, +int id,int addr) { +struct i2c_board_info info;char *modname;switch (id) {
@@ -226,7 +228,11 @@ static int init_i2c_module(struct i2c_ad }if (modname !=NULL )request_module (modname); -if (wis_i2c_probe_device (adapter, id, addr) ==1 ) + +memset (&info,0 ,sizeof (struct i2c_board_info )); + info.addr = addr; +strlcpy (info.type, type,I2C_NAME_SIZE ); +if (!i2c_new_device (adapter, &info))return 0 ;if (modname !=NULL ) printk(KERN_INFO
@@ -266,6 +272,7 @@ int go7007_register_encoder(struct go700if (go->i2c_adapter_online) {for (i =0 ; i < go->board_info->num_i2c_devs; ++i)init_i2c_module (&go->i2c_adapter, + go->board_info->i2c_devs[i].type, go->board_info->i2c_devs[i].id, go->board_info->i2c_devs[i].addr);if (go->board_id ==GO7007_BOARDID_ADLINK_MPG24 )
drivers/staging/go7007/go7007-i2c.c +0 -83
96 lines not on this page · raw message
drivers/staging/go7007/go7007-priv.h +1 -0
@@ -87,6 +87,7 @@ struct go7007_board_info {int audio_main_div;int num_i2c_devs;struct { +const char *type;int id;int addr; } i2c_devs[4 ];
drivers/staging/go7007/go7007-usb.c +11 -3
@@ -91,6 +91,7 @@ static struct go7007_usb_board board_mat .num_i2c_devs = 1, .i2c_devs = { { + .type = "wis_saa7115", .id = I2C_DRIVERID_WIS_SAA7115, .addr = 0x20, },
@@ -127,6 +128,7 @@ static struct go7007_usb_board board_mat .num_i2c_devs = 1, .i2c_devs = { { + .type = "wis_saa7113", .id = I2C_DRIVERID_WIS_SAA7113, .addr = 0x25, },
@@ -164,6 +166,7 @@ static struct go7007_usb_board board_sta .num_i2c_devs = 1, .i2c_devs = { { + .type = "wis_saa7115", .id = I2C_DRIVERID_WIS_SAA7115, .addr = 0x20, },
@@ -209,14 +212,17 @@ static struct go7007_usb_board board_px_ .num_i2c_devs = 3, .i2c_devs = { { + .type = "wis_saa7115", .id = I2C_DRIVERID_WIS_SAA7115, .addr = 0x20, }, { + .type = "wis_uda1342", .id = I2C_DRIVERID_WIS_UDA1342, .addr = 0x1a, }, { + .type = "wis_sony_tuner", .id = I2C_DRIVERID_WIS_SONY_TUNER, .addr = 0x60, },
@@ -264,6 +270,7 @@ static struct go7007_usb_board board_xme .num_i2c_devs = 1, .i2c_devs = { { + .type = "wis_ov7640", .id = I2C_DRIVERID_WIS_OV7640, .addr = 0x21, },
@@ -296,6 +303,7 @@ static struct go7007_usb_board board_mat .num_i2c_devs = 1, .i2c_devs = { { + .type = "wis_tw9903", .id = I2C_DRIVERID_WIS_TW9903, .addr = 0x44, },
@@ -385,6 +393,7 @@ static struct go7007_usb_board board_adl .num_i2c_devs = 1, .i2c_devs = { { + .type = "wis_twTW2804", .id = I2C_DRIVERID_WIS_TW2804, .addr = 0x00, /* yes, really */ },
@@ -415,8 +424,9 @@ static struct go7007_usb_board board_sen .num_i2c_devs = 1, .i2c_devs = { { + .type = "s2250_board", .id = I2C_DRIVERID_S2250, - .addr = 0x34, + .addr = 0x86, /* ?? */ }, }, .num_inputs = 2,
@@ -943,9 +953,7 @@ static struct i2c_algorithm go7007_usb_astatic struct i2c_adapter go7007_usb_adap_templ = { .owner =THIS_MODULE , - .class =I2C_CLASS_TV_ANALOG , .name ="WIS GO7007SB EZ-USB" , - .id =I2C_ALGO_GO7007_USB , .algo = &go7007_usb_algo, };
drivers/staging/go7007/s2250-board.c +34 -41
174 lines not on this page · raw message
drivers/staging/go7007/wis-i2c.h +0 -9
@@ -24,21 +24,12 @@#define I2C_DRIVERID_WIS_OV7640 0xf0f5#define I2C_DRIVERID_WIS_TW2804 0xf0f6#define I2C_DRIVERID_S2250 0xf0f7 -#define I2C_ALGO_GO7007 0xf00000 -#define I2C_ALGO_GO7007_USB 0xf10000/* Flag to indicate that the client needs to be accessed with SCCB semantics */ /* We re-use the I2C_M_TEN value so the flag passes through the masks in the * core I2C code. Major kludge, but the I2C layer ain't exactly flexible. */ #define I2C_CLIENT_SCCB 0x10 -typedef int (*found_proc ) (struct i2c_adapter *,int ,int ); -int wis_i2c_add_driver (unsigned int id,found_proc found_proc); -void wis_i2c_del_driver (found_proc found_proc); - -int wis_i2c_probe_device (struct i2c_adapter *adapter, -unsigned int id,int addr); -/* Definitions for new video decoder commands */ struct video_decoder_resolution {
drivers/staging/go7007/wis-ov7640.c +16 -38
92 lines not on this page · raw message
drivers/staging/go7007/wis-saa7113.c +19 -41
109 lines not on this page · raw message
drivers/staging/go7007/wis-saa7115.c +19 -41
109 lines not on this page · raw message
drivers/staging/go7007/wis-sony-tuner.c +18 -42
103 lines not on this page · raw message
drivers/staging/go7007/wis-tw2804.c +18 -39
100 lines not on this page · raw message
drivers/staging/go7007/wis-tw9903.c +19 -41
108 lines not on this page · raw message
drivers/staging/go7007/wis-uda1342.c +15 -37
88 lines not on this page · raw message
Signature · 1 line
Jean Delvare
drivers/staging/go7007/go7007-usb.c static struct go7007_usb_board board_sen
Quoted 7 lines · Jean Delvare
I am puzzled by the s2250 I2C address,
0x86really doesn't fit in 7 bits, there must be something wrong.drivers/staging/go7007/go7007-usb.c +1
-2- .addr = 0x34, + .addr = 0x86, /* ?? */ -#define S2250_VIDDEC 0x86
Many I2C controllers use an 8-bit address register, with the lowest bit being the read/write bit (because this is the order in which the bits are transmitted over the bus). So it looks as if the actual address _is_ 0x34; the S2250_VIDDEC symbol is probably a relict of the old driver that programmed the I2C controller directly.
Best regards,
Clemens
Hallo Clemens,
Quoted 7 lines · Clemens Ladisch
Quoted 5 lines · Jean Delvare
I am puzzled by the s2250 I2C address,
0x86really doesn't fit in 7 bits, there must be something wrong.drivers/staging/go7007/go7007-usb.c +1
-1- .addr = 0x34, + .addr = 0x86, /* ?? */
Quoted 6 lines
Quoted 1 line
-#define
S2250_VIDDEC0x86Many I2C controllers use an 8-bit address register, with the lowest bit being the read/write bit (because this is the order in which the bits are transmitted over the bus). So it looks as if the actual address _is_
0x34;
0x86 >> 1 is actually 0x43, not 0x34. 0x34 is the address for the audio part of the device:
#define TLV320_ADDRESS 0x34
The original code was a little messy and used the same i2c_client for both parts, changing the address on the fly.
That being said, I think you are probably right, the 7-bit device's address is probably 0x43 for video. And now that we mention that, probably 0x34 for audio is incorrect as well. "TLV320" suggests some incarnation of the TI TLV320 series, many of which are already supported in the kernel, and all I've seen had address 0x18, 0x19, 0x1a or 0x1b. Given that 0x34 >> 1 is 0x1a... it's a good hint that 0x34 wasn't a 7-bit address value, right?
I'll change the addresses to 0x43 for video and 0x1a for audio. Updated patch coming.
Quoted 2 lines
the
S2250_VIDDECsymbol is probably a relict of the old driver that programmed the I2C controller directly.
Could be. But then this means that the driver as it stands in the kernel today, doesn't work. Which, in a way, is good news, as it means I can push my changes immediately. Even if I got the conversion wrong, it won't be more broken than it already was ;)
Thanks,
Signature · 1 line
Jean Delvare