diff options
author | Michael Hunold <devnull@localhost> | 2004-06-07 11:04:17 +0000 |
---|---|---|
committer | Michael Hunold <devnull@localhost> | 2004-06-07 11:04:17 +0000 |
commit | 8b5e9cf37b74a644c1848c56898652b6cab0e0ab (patch) | |
tree | 671a6570ad460d14cf2066463a48afe036d243b4 | |
parent | 0d7010a658293464af09c668b740df361712693a (diff) | |
download | mediapointer-dvb-s2-8b5e9cf37b74a644c1848c56898652b6cab0e0ab.tar.gz mediapointer-dvb-s2-8b5e9cf37b74a644c1848c56898652b6cab0e0ab.tar.bz2 |
- this patch allows the skystar2 driver to work with frontends which are converted to use kernel I2C (stv0299). Thanks to Vadim Catana
-rw-r--r-- | linux/drivers/media/dvb/b2c2/skystar2.c | 81 |
1 files changed, 80 insertions, 1 deletions
diff --git a/linux/drivers/media/dvb/b2c2/skystar2.c b/linux/drivers/media/dvb/b2c2/skystar2.c index 59f595f68..bbb3e4506 100644 --- a/linux/drivers/media/dvb/b2c2/skystar2.c +++ b/linux/drivers/media/dvb/b2c2/skystar2.c @@ -35,6 +35,7 @@ #include <linux/delay.h> #include <linux/pci.h> #include <linux/init.h> +#include <linux/version.h> #include <asm/io.h> @@ -91,6 +92,7 @@ struct adapter { struct dmx_frontend hw_frontend; struct dmx_frontend mem_frontend; struct dvb_i2c_bus *i2c_bus; + struct i2c_adapter i2c_adap; struct dvb_net dvbnet; struct semaphore i2c_sem; @@ -2229,6 +2231,49 @@ static int flexcop_diseqc_ioctl(struct dvb_frontend *fe, unsigned int cmd, void return 0; } + +int client_register(struct i2c_client *client) +{ + struct adapter *adapter = (struct adapter*)i2c_get_adapdata(client->adapter); + + dprintk("client_register\n"); + + return client->driver->command(client, FE_REGISTER, adapter->dvb_adapter); +} + +int client_unregister(struct i2c_client *client) +{ + struct adapter *adapter = (struct adapter*)i2c_get_adapdata(client->adapter); + + dprintk("client_unregister\n"); + + return client->driver->command(client, FE_UNREGISTER, adapter->dvb_adapter); +} + +static int flexcop_i2c_xfer(struct i2c_adapter *i2c_adapter, struct i2c_msg msg[], int num) +{ + struct adapter *adapter = i2c_get_adapdata(i2c_adapter); + + dprintk("flexcop_i2c_xfer\n"); + + return master_xfer(adapter->i2c_bus, msg, num); +} + +u32 flexcop_i2c_func(struct i2c_adapter *adapter) +{ + printk("flexcop_i2c_func\n"); + + return I2C_FUNC_I2C; +} + +static struct i2c_algorithm flexcop_algo = { + .name = "flexcop i2c algorithm", + .id = I2C_ALGO_BIT, + .master_xfer = flexcop_i2c_xfer, + .functionality = flexcop_i2c_func, +}; + + static int skystar2_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { struct adapter *adapter; @@ -2259,10 +2304,42 @@ static int skystar2_probe(struct pci_dev *pdev, const struct pci_device_id *ent) init_MUTEX(&adapter->i2c_sem); + + memset(&adapter->i2c_adap, 0, sizeof(struct i2c_adapter)); + strcpy(adapter->i2c_adap.name, "Technisat SkyStar2 driver"); + +#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) ) + adapter->i2c_adap.data = adapter; +#else + i2c_set_adapdata(&adapter->i2c_adap, adapter); + + #ifdef I2C_ADAP_CLASS_TV_DIGITAL + adapter->i2c_adap.class = I2C_ADAP_CLASS_TV_DIGITAL; + #else + adapter->i2c_adap.class = I2C_CLASS_TV_DIGITAL; + #endif + +#endif + adapter->i2c_adap.algo = &flexcop_algo; + adapter->i2c_adap.algo_data = NULL; + adapter->i2c_adap.id = I2C_ALGO_BIT; + adapter->i2c_adap.client_register = client_register; + adapter->i2c_adap.client_unregister = client_unregister; + + adapter->i2c_bus = dvb_register_i2c_bus(master_xfer, adapter, adapter->dvb_adapter, 0); - if (!adapter->i2c_bus) + if (!adapter->i2c_bus) { + dvb_unregister_adapter (adapter->dvb_adapter); + return -ENOMEM; + } + + + if (i2c_add_adapter(&adapter->i2c_adap) < 0) { + dvb_unregister_i2c_bus (master_xfer, adapter->i2c_bus->adapter, adapter->i2c_bus->id); + dvb_unregister_adapter (adapter->dvb_adapter); return -ENOMEM; + } dvb_add_frontend_ioctls(adapter->dvb_adapter, flexcop_diseqc_ioctl, NULL, adapter); @@ -2328,6 +2405,8 @@ static void skystar2_remove(struct pci_dev *pdev) if (adapter->dvb_adapter != NULL) { dvb_remove_frontend_ioctls(adapter->dvb_adapter, flexcop_diseqc_ioctl, NULL); + i2c_del_adapter(&adapter->i2c_adap); + if (adapter->i2c_bus != NULL) dvb_unregister_i2c_bus(master_xfer, adapter->i2c_bus->adapter, adapter->i2c_bus->id); |