summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Hunold <devnull@localhost>2004-08-18 15:57:36 +0000
committerMichael Hunold <devnull@localhost>2004-08-18 15:57:36 +0000
commita03d5d477ea0fae0a3516f96625431acb0cf31b2 (patch)
treeed7d2164735e563affd15c3030a6f8d8e815eb50
parentb8e91d008210ae8c8bdaee397a3215583b6d24a6 (diff)
downloadmediapointer-dvb-s2-a03d5d477ea0fae0a3516f96625431acb0cf31b2.tar.gz
mediapointer-dvb-s2-a03d5d477ea0fae0a3516f96625431acb0cf31b2.tar.bz2
- port from dvb i2c to kernel i2c *untested*
-rw-r--r--linux/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c83
1 files changed, 70 insertions, 13 deletions
diff --git a/linux/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c b/linux/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c
index 2427077b7..a0607e253 100644
--- a/linux/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c
+++ b/linux/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c
@@ -84,6 +84,8 @@ struct ttusb {
struct dvb_adapter *adapter;
struct usb_device *dev;
+ struct i2c_adapter i2c_adap;
+
int disconnecting;
int iso_streaming;
@@ -246,10 +248,9 @@ static int ttusb_i2c_msg(struct ttusb *ttusb,
return rcv_len;
}
-static int ttusb_i2c_xfer(struct dvb_i2c_bus *i2c, const struct i2c_msg msg[],
- int num)
+static int master_xfer(struct i2c_adapter* adapter, struct i2c_msg msg[], int num)
{
- struct ttusb *ttusb = i2c->data;
+ struct ttusb *ttusb = i2c_get_adapdata(adapter);
int i = 0;
int inc;
@@ -518,7 +519,7 @@ static int ttusb_set_tone(struct ttusb *ttusb, fe_sec_tone_mode_t tone)
static int ttusb_lnb_ioctl(struct dvb_frontend *fe, unsigned int cmd, void *arg)
{
- struct ttusb *ttusb = fe->i2c->data;
+ struct ttusb *ttusb = fe->before_after_data;
switch (cmd) {
case FE_SET_VOLTAGE:
@@ -1072,6 +1073,38 @@ static struct file_operations stc_fops = {
};
#endif
+u32 functionality(struct i2c_adapter *adapter)
+{
+ return I2C_FUNC_I2C;
+}
+
+static struct i2c_algorithm ttusb_dec_algo = {
+ .name = "ttusb dec i2c algorithm",
+ .id = I2C_ALGO_BIT,
+ .master_xfer = master_xfer,
+ .functionality = functionality,
+};
+
+int client_register(struct i2c_client *client)
+{
+ struct ttusb *ttusb = (struct ttusb*)i2c_get_adapdata(client->adapter);
+
+ if (client->driver->command)
+ return client->driver->command(client, FE_REGISTER, ttusb->adapter);
+
+ return 0;
+}
+
+int client_unregister(struct i2c_client *client)
+{
+ struct ttusb *ttusb = (struct ttusb*)i2c_get_adapdata(client->adapter);
+
+ if (client->driver->command)
+ return client->driver->command(client, FE_UNREGISTER, ttusb->adapter);
+
+ return 0;
+}
+
static int ttusb_probe(struct usb_interface *intf, const struct usb_device_id *id)
{
struct usb_device *udev;
@@ -1110,7 +1143,25 @@ static int ttusb_probe(struct usb_interface *intf, const struct usb_device_id *i
dvb_register_adapter(&ttusb->adapter, "Technotrend/Hauppauge Nova-USB", THIS_MODULE);
- dvb_register_i2c_bus(ttusb_i2c_xfer, ttusb, ttusb->adapter, 0);
+ /* i2c */
+ memset(&ttusb->i2c_adap, 0, sizeof(struct i2c_adapter));
+ strcpy(ttusb->i2c_adap.name, "TTUSB DEC");
+
+ i2c_set_adapdata(&ttusb->i2c_adap, ttusb);
+
+ ttusb->i2c_adap.class = I2C_CLASS_TV_DIGITAL;
+ ttusb->i2c_adap.algo = &ttusb_dec_algo;
+ ttusb->i2c_adap.algo_data = NULL;
+ ttusb->i2c_adap.id = I2C_ALGO_BIT;
+ ttusb->i2c_adap.client_register = client_register;
+ ttusb->i2c_adap.client_unregister = client_unregister;
+
+ result = i2c_add_adapter(&ttusb->i2c_adap);
+ if (result) {
+ dvb_unregister_adapter (ttusb->adapter);
+ return result;
+ }
+
dvb_add_frontend_ioctls(ttusb->adapter, ttusb_lnb_ioctl, NULL,
ttusb);
@@ -1130,9 +1181,10 @@ static int ttusb_probe(struct usb_interface *intf, const struct usb_device_id *i
ttusb->dvb_demux.write_to_decoder = NULL;
if ((result = dvb_dmx_init(&ttusb->dvb_demux)) < 0) {
- printk("ttusb_dvb: dvb_dmx_init failed (errno = %d)\n",
- result);
- goto err;
+ printk("ttusb_dvb: dvb_dmx_init failed (errno = %d)\n", result);
+ i2c_del_adapter(&ttusb->i2c_adap);
+ dvb_unregister_adapter (ttusb->adapter);
+ return -ENODEV;
}
//FIXME dmxdev (nur WAS?)
ttusb->dmxdev.filternum = ttusb->dvb_demux.filternum;
@@ -1143,15 +1195,20 @@ static int ttusb_probe(struct usb_interface *intf, const struct usb_device_id *i
printk("ttusb_dvb: dvb_dmxdev_init failed (errno = %d)\n",
result);
dvb_dmx_release(&ttusb->dvb_demux);
- goto err;
+ i2c_del_adapter(&ttusb->i2c_adap);
+ dvb_unregister_adapter (ttusb->adapter);
+ return -ENODEV;
}
- if (dvb_net_init
- (ttusb->adapter, &ttusb->dvbnet, &ttusb->dvb_demux.dmx)) {
+ if (dvb_net_init(ttusb->adapter, &ttusb->dvbnet, &ttusb->dvb_demux.dmx)) {
printk("ttusb_dvb: dvb_net_init failed!\n");
+ dvb_dmxdev_release(&ttusb->dmxdev);
+ dvb_dmx_release(&ttusb->dvb_demux);
+ i2c_del_adapter(&ttusb->i2c_adap);
+ dvb_unregister_adapter (ttusb->adapter);
+ return -ENODEV;
}
- err:
#if 0
ttusb->stc_devfs_handle =
devfs_register(ttusb->adapter->devfs_handle, TTUSB_BUDGET_NAME,
@@ -1179,7 +1236,7 @@ static void ttusb_disconnect(struct usb_interface *intf)
dvb_dmxdev_release(&ttusb->dmxdev);
dvb_dmx_release(&ttusb->dvb_demux);
- dvb_unregister_i2c_bus(ttusb_i2c_xfer, ttusb->adapter, 0);
+ i2c_del_adapter(&ttusb->i2c_adap);
dvb_unregister_adapter(ttusb->adapter);
ttusb_free_iso_urbs(ttusb);