diff options
Diffstat (limited to 'linux/drivers/media/video/cx88/cx88-i2c.c')
-rw-r--r-- | linux/drivers/media/video/cx88/cx88-i2c.c | 56 |
1 files changed, 49 insertions, 7 deletions
diff --git a/linux/drivers/media/video/cx88/cx88-i2c.c b/linux/drivers/media/video/cx88/cx88-i2c.c index 02595d86c..ef04a431d 100644 --- a/linux/drivers/media/video/cx88/cx88-i2c.c +++ b/linux/drivers/media/video/cx88/cx88-i2c.c @@ -29,6 +29,19 @@ #include "cx88.h" +static unsigned int i2c_debug = 0; +MODULE_PARM(i2c_debug,"i"); +MODULE_PARM_DESC(i2c_debug,"enable debug messages [i2c]"); + +#define dprintk(level,fmt, arg...) if (i2c_debug >= level) \ + printk(KERN_DEBUG "%s: " fmt, core->name , ## arg) + +/* temporary here until new dvb-kernel code is merged ... */ +#ifndef FE_REGISTER +# define FE_REGISTER _IO ('v', 84) +# define FE_UNREGISTER _IO ('v', 85) +#endif + /* ----------------------------------------------------------------------- */ void cx8800_bit_setscl(void *data, int state) @@ -89,17 +102,43 @@ static void cx8800_dec_use(struct i2c_adapter *adap) static int attach_inform(struct i2c_client *client) { - struct cx88_core *core = i2c_get_adapdata(client->adapter); + struct cx88_core *core = i2c_get_adapdata(client->adapter); if (core->tuner_type != UNSET) cx88_call_i2c_clients(core,TUNER_SET_TYPE,&core->tuner_type); if (core->tda9887_conf) cx88_call_i2c_clients(core,TDA9887_SET_CONFIG,&core->tda9887_conf); - if (1 /* fixme: debug */) - printk("%s: i2c attach [client=%s]\n", - core->name, i2c_clientname(client)); - return 0; +#if 1 + /* FIXME: should switch to cx88_call_i2c_clients */ + if (core->dvb_adapter && client->driver->command) { + dprintk(1, "i2c attach [client=%s] dvb_adapter %p\n", + i2c_clientname(client), core->dvb_adapter); + return client->driver->command(client, FE_REGISTER, core->dvb_adapter); + } +#endif + + dprintk(1, "i2c attach [client=%s]\n", i2c_clientname(client)); + return 0; +} + +static int detach_inform(struct i2c_client *client) +{ + struct cx88_core *core = i2c_get_adapdata(client->adapter); + +#if 1 + /* FIXME: should switch to cx88_call_i2c_clients */ + /* FIXME: drop FE_UNREGISTER altogether in favor of using + * i2c_driver->detach_client() ??? */ + if (core->dvb_adapter && client->driver->command) { + dprintk(1, "i2c detach [client=%s] dvb_adapter %p\n", + i2c_clientname(client), core->dvb_adapter); + return client->driver->command(client, FE_UNREGISTER, core->dvb_adapter); + } +#endif + + dprintk(1, "i2c detach [client=%s]\n", i2c_clientname(client)); + return 0; } void cx88_call_i2c_clients(struct cx88_core *core, unsigned int cmd, void *arg) @@ -134,6 +173,7 @@ static struct i2c_adapter cx8800_i2c_adap_template = { I2C_DEVNAME("cx2388x"), .id = I2C_HW_B_BT848, .client_register = attach_inform, + .client_unregister = detach_inform, }; static struct i2c_client cx8800_i2c_client_template = { @@ -164,8 +204,10 @@ int cx88_i2c_init(struct cx88_core *core, struct pci_dev *pci) cx8800_bit_setsda(core,1); core->i2c_rc = i2c_bit_add_bus(&core->i2c_adap); - printk("%s: i2c register %s\n", core->name, - (0 == core->i2c_rc) ? "ok" : "FAILED"); + if (0 != core->i2c_rc) + printk("%s: i2c register FAILED\n", core->name); + else + dprintk(1, "i2c register ok\n"); return core->i2c_rc; } |