X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fmedia%2Fdvb%2Fttusb-budget%2Fdvb-ttusb-budget.c;h=6ceae38125c7546990623d62028e35c56750f4a1;hb=43bc926fffd92024b46cafaf7350d669ba9ca884;hp=0485faa51b4d02f4f8199843385941f2f4deb45b;hpb=6a77f38946aaee1cd85eeec6cf4229b204c15071;p=linux-2.6.git diff --git a/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c b/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c index 0485faa51..6ceae3812 100644 --- a/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c +++ b/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c @@ -18,12 +18,14 @@ #include #include #include -#include +#include +#include #include "dvb_frontend.h" #include "dmxdev.h" #include "dvb_demux.h" #include "dvb_net.h" +#include "ves1820.h" #include "cx22700.h" #include "tda1004x.h" #include "stv0299.h" @@ -41,12 +43,12 @@ so the best way is maybe to keep TTUSB_HWSECTIONS undef'd and just parse TS data. USB bandwith will be a problem when having large datastreams, especially for dvb-net, but hey, that's not my problem. - + TTUSB_DISEQC, TTUSB_TONE: let the STC do the diseqc/tone stuff. this isn't supported at least with my TTUSB, so let it undef'd unless you want to implement another frontend. never tested. - + DEBUG: define it to > 3 for really hardcore debugging. you probably don't want this unless the device doesn't load at all. > 2 for bandwidth statistics. @@ -67,6 +69,7 @@ MODULE_PARM_DESC(debug, "Turn on/off debugging (default:off)."); #define TTUSB_MAXFILTER 16 /* ??? */ #endif +#define TTUSB_REV_2_2 0x22 #define TTUSB_BUDGET_NAME "ttusb_stc_fw" /** @@ -78,12 +81,11 @@ struct ttusb { struct dmxdev dmxdev; struct dvb_net dvbnet; - /* our semaphore, for channel allocation/deallocation */ - struct semaphore sem; /* and one for USB access. */ - struct semaphore semusb; + struct mutex semi2c; + struct mutex semusb; - struct dvb_adapter *adapter; + struct dvb_adapter adapter; struct usb_device *dev; struct i2c_adapter i2c_adap; @@ -118,21 +120,10 @@ struct ttusb { int cc; /* MuxCounter - will increment on EVERY MUX PACKET */ /* (including stuffing. yes. really.) */ - u8 last_result[32]; - struct ttusb_channel { - struct ttusb *ttusb; - struct dvb_demux_feed *dvbdmxfeed; + int revision; - int active; - int id; - int pid; - int type; /* 1 - TS, 2 - Filter */ -#ifdef TTUSB_HWSECTIONS - int filterstate[TTUSB_MAXFILTER]; /* 0: not busy, 1: busy */ -#endif - } channel[TTUSB_MAXCHANNEL]; #if 0 devfs_handle_t stc_devfs_handle; #endif @@ -158,31 +149,31 @@ static int ttusb_cmd(struct ttusb *ttusb, printk("\n"); #endif - if (down_interruptible(&ttusb->semusb) < 0) + if (mutex_lock_interruptible(&ttusb->semusb) < 0) return -EAGAIN; err = usb_bulk_msg(ttusb->dev, ttusb->bulk_out_pipe, - (u8 *) data, len, &actual_len, HZ); + (u8 *) data, len, &actual_len, 1000); if (err != 0) { dprintk("%s: usb_bulk_msg(send) failed, err == %i!\n", __FUNCTION__, err); - up(&ttusb->semusb); + mutex_unlock(&ttusb->semusb); return err; } if (actual_len != len) { dprintk("%s: only wrote %d of %d bytes\n", __FUNCTION__, actual_len, len); - up(&ttusb->semusb); + mutex_unlock(&ttusb->semusb); return -1; } err = usb_bulk_msg(ttusb->dev, ttusb->bulk_in_pipe, - ttusb->last_result, 32, &actual_len, HZ); + ttusb->last_result, 32, &actual_len, 1000); if (err != 0) { printk("%s: failed, receive error %d\n", __FUNCTION__, err); - up(&ttusb->semusb); + mutex_unlock(&ttusb->semusb); return err; } #if DEBUG >= 3 @@ -193,14 +184,14 @@ static int ttusb_cmd(struct ttusb *ttusb, printk("\n"); #endif if (!needresult) - up(&ttusb->semusb); + mutex_unlock(&ttusb->semusb); return 0; } static int ttusb_result(struct ttusb *ttusb, u8 * data, int len) { memcpy(data, ttusb->last_result, len); - up(&ttusb->semusb); + mutex_unlock(&ttusb->semusb); return 0; } @@ -233,8 +224,8 @@ static int ttusb_i2c_msg(struct ttusb *ttusb, err = ttusb_result(ttusb, b, 0x20); - /* check if the i2c transaction was successful */ - if ((snd_len != b[5]) || (rcv_len != b[6])) return -EREMOTEIO; + /* check if the i2c transaction was successful */ + if ((snd_len != b[5]) || (rcv_len != b[6])) return -EREMOTEIO; if (rcv_len > 0) { @@ -252,13 +243,13 @@ static int ttusb_i2c_msg(struct ttusb *ttusb, return rcv_len; } -static int master_xfer(struct i2c_adapter* adapter, struct i2c_msg msg[], int num) +static int master_xfer(struct i2c_adapter* adapter, struct i2c_msg *msg, int num) { struct ttusb *ttusb = i2c_get_adapdata(adapter); int i = 0; int inc; - if (down_interruptible(&ttusb->sem) < 0) + if (mutex_lock_interruptible(&ttusb->semi2c) < 0) return -EAGAIN; while (i < num) { @@ -292,7 +283,7 @@ static int master_xfer(struct i2c_adapter* adapter, struct i2c_msg msg[], int nu i += inc; } - up(&ttusb->sem); + mutex_unlock(&ttusb->semi2c); return i; } @@ -445,13 +436,17 @@ static int ttusb_init_controller(struct ttusb *ttusb) if (memcmp(get_version + 4, "V 0.0", 5) && memcmp(get_version + 4, "V 1.1", 5) && - memcmp(get_version + 4, "V 2.1", 5)) { + memcmp(get_version + 4, "V 2.1", 5) && + memcmp(get_version + 4, "V 2.2", 5)) { printk ("%s: unknown STC version %c%c%c%c%c, please report!\n", __FUNCTION__, get_version[4], get_version[5], get_version[6], get_version[7], get_version[8]); } + ttusb->revision = ((get_version[6] - '0') << 4) | + (get_version[8] - '0'); + err = ttusb_cmd(ttusb, get_dsp_version, sizeof(get_dsp_version), 1); if (err) @@ -468,7 +463,7 @@ static int ttusb_init_controller(struct ttusb *ttusb) #ifdef TTUSB_DISEQC static int ttusb_send_diseqc(struct dvb_frontend* fe, - const struct dvb_diseqc_master_cmd *cmd) + const struct dvb_diseqc_master_cmd *cmd) { struct ttusb* ttusb = (struct ttusb*) fe->dvb->priv; u8 b[12] = { 0xaa, ++ttusb->c, 0x18 }; @@ -491,6 +486,31 @@ static int ttusb_send_diseqc(struct dvb_frontend* fe, } #endif +static int lnbp21_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage) +{ + struct ttusb* ttusb = (struct ttusb*) fe->dvb->priv; + int ret; + u8 data[1]; + struct i2c_msg msg = { .addr = 0x08, .flags = 0, .buf = data, .len = sizeof(data) }; + + switch(voltage) { + case SEC_VOLTAGE_OFF: + data[0] = 0x00; + break; + case SEC_VOLTAGE_13: + data[0] = 0x44; + break; + case SEC_VOLTAGE_18: + data[0] = 0x4c; + break; + default: + return -EINVAL; + }; + + ret = i2c_transfer(&ttusb->i2c_adap, &msg, 1); + return (ret != 1) ? -EIO : 0; +} + static int ttusb_update_lnb(struct ttusb *ttusb) { u8 b[] = { 0xaa, ++ttusb->c, 0x16, 5, /*power: */ 1, @@ -550,7 +570,8 @@ static void ttusb_handle_sec_data(struct ttusb_channel *channel, const u8 * data, int len); #endif -static int numpkt = 0, lastj, numts, numstuff, numsec, numinvalid; +static int numpkt = 0, numts, numstuff, numsec, numinvalid; +static unsigned long lastj; static void ttusb_process_muxpack(struct ttusb *ttusb, const u8 * muxpack, int len) @@ -667,8 +688,7 @@ static void ttusb_process_frame(struct ttusb *ttusb, u8 * data, int len) memcpy(ttusb->muxpack + ttusb->muxpack_ptr, data, avail); ttusb->muxpack_ptr += avail; - if (ttusb->muxpack_ptr > 264) - BUG(); + BUG_ON(ttusb->muxpack_ptr > 264); data += avail; len -= avail; /* determine length */ @@ -759,7 +779,7 @@ static void ttusb_iso_irq(struct urb *urb, struct pt_regs *ptregs) u8 *data; int len; numpkt++; - if ((jiffies - lastj) >= HZ) { + if (time_after_eq(jiffies, lastj + HZ)) { #if DEBUG > 2 printk ("frames/s: %d (ts: %d, stuff %d, sec: %d, invalid: %d, all: %d)\n", @@ -831,7 +851,7 @@ static void ttusb_stop_iso_xfer(struct ttusb *ttusb) int i; for (i = 0; i < ISO_BUF_COUNT; i++) - usb_unlink_urb(ttusb->iso_urb[i]); + usb_kill_urb(ttusb->iso_urb[i]); ttusb->iso_streaming = 0; } @@ -888,15 +908,13 @@ static int ttusb_start_iso_xfer(struct ttusb *ttusb) } #ifdef TTUSB_HWSECTIONS -static void ttusb_handle_ts_data(struct ttusb_channel *channel, const u8 * data, +static void ttusb_handle_ts_data(struct dvb_demux_feed *dvbdmxfeed, const u8 * data, int len) { - struct dvb_demux_feed *dvbdmxfeed = channel->dvbdmxfeed; - dvbdmxfeed->cb.ts(data, len, 0, 0, &dvbdmxfeed->feed.ts, 0); } -static void ttusb_handle_sec_data(struct ttusb_channel *channel, const u8 * data, +static void ttusb_handle_sec_data(struct dvb_demux_feed *dvbdmxfeed, const u8 * data, int len) { // struct dvb_demux_feed *dvbdmxfeed = channel->dvbdmxfeed; @@ -905,31 +923,10 @@ static void ttusb_handle_sec_data(struct ttusb_channel *channel, const u8 * data } #endif -static struct ttusb_channel *ttusb_channel_allocate(struct ttusb *ttusb) -{ - int i; - - if (down_interruptible(&ttusb->sem)) - return NULL; - - /* lock! */ - for (i = 0; i < TTUSB_MAXCHANNEL; ++i) { - if (!ttusb->channel[i].active) { - ttusb->channel[i].active = 1; - up(&ttusb->sem); - return ttusb->channel + i; - } - } - - up(&ttusb->sem); - - return NULL; -} - static int ttusb_start_feed(struct dvb_demux_feed *dvbdmxfeed) { struct ttusb *ttusb = (struct ttusb *) dvbdmxfeed->demux; - struct ttusb_channel *channel; + int feed_type = 1; dprintk("ttusb_start_feed\n"); @@ -949,35 +946,22 @@ static int ttusb_start_feed(struct dvb_demux_feed *dvbdmxfeed) case DMX_TS_PES_TELETEXT: case DMX_TS_PES_PCR: case DMX_TS_PES_OTHER: - channel = ttusb_channel_allocate(ttusb); break; default: return -EINVAL; } - } else { - channel = ttusb_channel_allocate(ttusb); } - if (!channel) - return -EBUSY; - - dvbdmxfeed->priv = channel; - channel->dvbdmxfeed = dvbdmxfeed; - - channel->pid = dvbdmxfeed->pid; - #ifdef TTUSB_HWSECTIONS +#error TODO: allocate filters if (dvbdmxfeed->type == DMX_TYPE_TS) { - channel->type = 1; + feed_type = 1; } else if (dvbdmxfeed->type == DMX_TYPE_SEC) { - channel->type = 2; -#error TODO: allocate filters + feed_type = 2; } -#else - channel->type = 1; #endif - ttusb_set_channel(ttusb, channel->id, channel->type, channel->pid); + ttusb_set_channel(ttusb, dvbdmxfeed->index, feed_type, dvbdmxfeed->pid); if (0 == ttusb->running_feed_count++) ttusb_start_iso_xfer(ttusb); @@ -987,17 +971,13 @@ static int ttusb_start_feed(struct dvb_demux_feed *dvbdmxfeed) static int ttusb_stop_feed(struct dvb_demux_feed *dvbdmxfeed) { - struct ttusb_channel *channel = - (struct ttusb_channel *) dvbdmxfeed->priv; struct ttusb *ttusb = (struct ttusb *) dvbdmxfeed->demux; - ttusb_del_channel(channel->ttusb, channel->id); + ttusb_del_channel(ttusb, dvbdmxfeed->index); if (--ttusb->running_feed_count == 0) ttusb_stop_iso_xfer(ttusb); - channel->active = 0; - return 0; } @@ -1086,7 +1066,7 @@ static int alps_tdmb7_pll_set(struct dvb_frontend* fe, struct dvb_frontend_param return 0; } -struct cx22700_config alps_tdmb7_config = { +static struct cx22700_config alps_tdmb7_config = { .demod_address = 0x43, .pll_set = alps_tdmb7_pll_set, }; @@ -1201,10 +1181,51 @@ static struct tda1004x_config philips_tdm1316l_config = { .request_firmware = philips_tdm1316l_request_firmware, }; +static u8 alps_bsbe1_inittab[] = { + 0x01, 0x15, + 0x02, 0x30, + 0x03, 0x00, + 0x04, 0x7d, /* F22FR = 0x7d, F22 = f_VCO / 128 / 0x7d = 22 kHz */ + 0x05, 0x35, /* I2CT = 0, SCLT = 1, SDAT = 1 */ + 0x06, 0x40, /* DAC not used, set to high impendance mode */ + 0x07, 0x00, /* DAC LSB */ + 0x08, 0x40, /* DiSEqC off, LNB power on OP2/LOCK pin on */ + 0x09, 0x00, /* FIFO */ + 0x0c, 0x51, /* OP1 ctl = Normal, OP1 val = 1 (LNB Power ON) */ + 0x0d, 0x82, /* DC offset compensation = ON, beta_agc1 = 2 */ + 0x0e, 0x23, /* alpha_tmg = 2, beta_tmg = 3 */ + 0x10, 0x3f, // AGC2 0x3d + 0x11, 0x84, + 0x12, 0xb9, + 0x15, 0xc9, // lock detector threshold + 0x16, 0x00, + 0x17, 0x00, + 0x18, 0x00, + 0x19, 0x00, + 0x1a, 0x00, + 0x1f, 0x50, + 0x20, 0x00, + 0x21, 0x00, + 0x22, 0x00, + 0x23, 0x00, + 0x28, 0x00, // out imp: normal out type: parallel FEC mode:0 + 0x29, 0x1e, // 1/2 threshold + 0x2a, 0x14, // 2/3 threshold + 0x2b, 0x0f, // 3/4 threshold + 0x2c, 0x09, // 5/6 threshold + 0x2d, 0x05, // 7/8 threshold + 0x2e, 0x01, + 0x31, 0x1f, // test all FECs + 0x32, 0x19, // viterbi and synchro search + 0x33, 0xfc, // rs control + 0x34, 0x93, // error control + 0x0f, 0x92, + 0xff, 0xff +}; static u8 alps_bsru6_inittab[] = { 0x01, 0x15, - 0x02, 0x00, + 0x02, 0x30, 0x03, 0x00, 0x04, 0x7d, /* F22FR = 0x7d, F22 = f_VCO / 128 / 0x7d = 22 kHz */ 0x05, 0x35, /* I2CT = 0, SCLT = 1, SDAT = 1 */ @@ -1217,7 +1238,7 @@ static u8 alps_bsru6_inittab[] = { 0x0e, 0x23, /* alpha_tmg = 2, beta_tmg = 3 */ 0x10, 0x3f, // AGC2 0x3d 0x11, 0x84, - 0x12, 0xb5, // Lock detect: -64 Carrier freq detect:on + 0x12, 0xb9, 0x15, 0xc9, // lock detector threshold 0x16, 0x00, 0x17, 0x00, @@ -1244,7 +1265,7 @@ static u8 alps_bsru6_inittab[] = { 0xff, 0xff }; -static int alps_bsru6_set_symbol_rate(struct dvb_frontend *fe, u32 srate, u32 ratio) +static int alps_stv0299_set_symbol_rate(struct dvb_frontend *fe, u32 srate, u32 ratio) { u8 aclk = 0; u8 bclk = 0; @@ -1278,7 +1299,7 @@ static int alps_bsru6_set_symbol_rate(struct dvb_frontend *fe, u32 srate, u32 ra return 0; } -static int alps_bsru6_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params) +static int philips_tsa5059_pll_set(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct dvb_frontend_parameters *params) { struct ttusb* ttusb = (struct ttusb*) fe->dvb->priv; u8 buf[4]; @@ -1295,27 +1316,29 @@ static int alps_bsru6_pll_set(struct dvb_frontend *fe, struct dvb_frontend_param buf[3] = 0xC4; if (params->frequency > 1530000) - buf[3] = 0xc0; + buf[3] = 0xC0; - if (i2c_transfer(&ttusb->i2c_adap, &msg, 1) != 1) + /* BSBE1 wants XCE bit set */ + if (ttusb->revision == TTUSB_REV_2_2) + buf[3] |= 0x20; + + if (i2c_transfer(i2c, &msg, 1) != 1) return -EIO; return 0; } -static struct stv0299_config alps_bsru6_config = { - +static struct stv0299_config alps_stv0299_config = { .demod_address = 0x68, .inittab = alps_bsru6_inittab, .mclk = 88000000UL, .invert = 1, - .enhanced_tuning = 0, .skip_reinit = 0, .lock_output = STV0229_LOCKOUTPUT_1, .volt13_op0_op1 = STV0299_VOLT13_OP1, .min_delay_ms = 100, - .set_symbol_rate = alps_bsru6_set_symbol_rate, - .pll_set = alps_bsru6_pll_set, + .set_symbol_rate = alps_stv0299_set_symbol_rate, + .pll_set = philips_tsa5059_pll_set, }; static int ttusb_novas_grundig_29504_491_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params) @@ -1325,7 +1348,7 @@ static int ttusb_novas_grundig_29504_491_pll_set(struct dvb_frontend *fe, struct u32 div; struct i2c_msg msg = {.addr = 0x61,.flags = 0,.buf = buf,.len = sizeof(buf) }; - div = params->frequency / 125; + div = params->frequency / 125; buf[0] = (div >> 8) & 0x7f; buf[1] = div & 0xff; @@ -1344,16 +1367,62 @@ static struct tda8083_config ttusb_novas_grundig_29504_491_config = { .pll_set = ttusb_novas_grundig_29504_491_pll_set, }; +static int alps_tdbe2_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) +{ + struct ttusb* ttusb = fe->dvb->priv; + u32 div; + u8 data[4]; + struct i2c_msg msg = { .addr = 0x62, .flags = 0, .buf = data, .len = sizeof(data) }; + + div = (params->frequency + 35937500 + 31250) / 62500; + + data[0] = (div >> 8) & 0x7f; + data[1] = div & 0xff; + data[2] = 0x85 | ((div >> 10) & 0x60); + data[3] = (params->frequency < 174000000 ? 0x88 : params->frequency < 470000000 ? 0x84 : 0x81); + + if (i2c_transfer (&ttusb->i2c_adap, &msg, 1) != 1) + return -EIO; + + return 0; +} + + +static struct ves1820_config alps_tdbe2_config = { + .demod_address = 0x09, + .xin = 57840000UL, + .invert = 1, + .selagc = VES1820_SELAGC_SIGNAMPERR, + .pll_set = alps_tdbe2_pll_set, +}; + +static u8 read_pwm(struct ttusb* ttusb) +{ + u8 b = 0xff; + u8 pwm; + struct i2c_msg msg[] = { { .addr = 0x50,.flags = 0,.buf = &b,.len = 1 }, + { .addr = 0x50,.flags = I2C_M_RD,.buf = &pwm,.len = 1} }; + + if ((i2c_transfer(&ttusb->i2c_adap, msg, 2) != 2) || (pwm == 0xff)) + pwm = 0x48; + + return pwm; +} static void frontend_init(struct ttusb* ttusb) { switch(le16_to_cpu(ttusb->dev->descriptor.idProduct)) { - case 0x1003: // Hauppauge/TT Nova-USB-S budget (stv0299/ALPS BSRU6(tsa5059) - // try the ALPS BSRU6 first - ttusb->fe = stv0299_attach(&alps_bsru6_config, &ttusb->i2c_adap); + case 0x1003: // Hauppauge/TT Nova-USB-S budget (stv0299/ALPS BSRU6|BSBE1(tsa5059)) + // try the stv0299 based first + ttusb->fe = stv0299_attach(&alps_stv0299_config, &ttusb->i2c_adap); if (ttusb->fe != NULL) { - ttusb->fe->ops->set_voltage = ttusb_set_voltage; + if(ttusb->revision == TTUSB_REV_2_2) { // ALPS BSBE1 + alps_stv0299_config.inittab = alps_bsbe1_inittab; + ttusb->fe->ops->set_voltage = lnbp21_set_voltage; + } else { // ALPS BSRU6 + ttusb->fe->ops->set_voltage = ttusb_set_voltage; + } break; } @@ -1366,6 +1435,12 @@ static void frontend_init(struct ttusb* ttusb) break; + case 0x1004: // Hauppauge/TT DVB-C budget (ves1820/ALPS TDBE2(sp5659)) + ttusb->fe = ves1820_attach(&alps_tdbe2_config, &ttusb->i2c_adap, read_pwm(ttusb)); + if (ttusb->fe != NULL) + break; + break; + case 0x1005: // Hauppauge/TT Nova-USB-t budget (tda10046/Philips td1316(tda6651tt) OR cx22700/ALPS TDMB7(??)) // try the ALPS TDMB7 first ttusb->fe = cx22700_attach(&alps_tdmb7_config, &ttusb->i2c_adap); @@ -1384,7 +1459,7 @@ static void frontend_init(struct ttusb* ttusb) le16_to_cpu(ttusb->dev->descriptor.idVendor), le16_to_cpu(ttusb->dev->descriptor.idProduct)); } else { - if (dvb_register_frontend(ttusb->adapter, ttusb->fe)) { + if (dvb_register_frontend(&ttusb->adapter, ttusb->fe)) { printk("dvb-ttusb-budget: Frontend registration failed!\n"); if (ttusb->fe->ops->release) ttusb->fe->ops->release(ttusb->fe); @@ -1396,8 +1471,6 @@ static void frontend_init(struct ttusb* ttusb) static struct i2c_algorithm ttusb_dec_algo = { - .name = "ttusb dec i2c algorithm", - .id = I2C_ALGO_BIT, .master_xfer = master_xfer, .functionality = functionality, }; @@ -1406,29 +1479,25 @@ static int ttusb_probe(struct usb_interface *intf, const struct usb_device_id *i { struct usb_device *udev; struct ttusb *ttusb; - int result, channel; + int result; dprintk("%s: TTUSB DVB connected\n", __FUNCTION__); udev = interface_to_usbdev(intf); - if (intf->altsetting->desc.bInterfaceNumber != 1) return -ENODEV; + if (intf->altsetting->desc.bInterfaceNumber != 1) return -ENODEV; - if (!(ttusb = kmalloc(sizeof(struct ttusb), GFP_KERNEL))) + if (!(ttusb = kzalloc(sizeof(struct ttusb), GFP_KERNEL))) return -ENOMEM; - memset(ttusb, 0, sizeof(struct ttusb)); - - for (channel = 0; channel < TTUSB_MAXCHANNEL; ++channel) { - ttusb->channel[channel].id = channel; - ttusb->channel[channel].ttusb = ttusb; - } - ttusb->dev = udev; ttusb->c = 0; ttusb->mux_state = 0; - sema_init(&ttusb->sem, 0); - sema_init(&ttusb->semusb, 1); + mutex_init(&ttusb->semi2c); + + mutex_lock(&ttusb->semi2c); + + mutex_init(&ttusb->semusb); ttusb_setup_interfaces(ttusb); @@ -1436,10 +1505,14 @@ static int ttusb_probe(struct usb_interface *intf, const struct usb_device_id *i if (ttusb_init_controller(ttusb)) printk("ttusb_init_controller: error\n"); - up(&ttusb->sem); + mutex_unlock(&ttusb->semi2c); - dvb_register_adapter(&ttusb->adapter, "Technotrend/Hauppauge Nova-USB", THIS_MODULE); - ttusb->adapter->priv = ttusb; + if ((result = dvb_register_adapter(&ttusb->adapter, "Technotrend/Hauppauge Nova-USB", THIS_MODULE)) < 0) { + ttusb_free_iso_urbs(ttusb); + kfree(ttusb); + return result; + } + ttusb->adapter.priv = ttusb; /* i2c */ memset(&ttusb->i2c_adap, 0, sizeof(struct i2c_adapter)); @@ -1448,17 +1521,16 @@ static int ttusb_probe(struct usb_interface *intf, const struct usb_device_id *i i2c_set_adapdata(&ttusb->i2c_adap, ttusb); #ifdef I2C_ADAP_CLASS_TV_DIGITAL - ttusb->i2c_adap.class = I2C_ADAP_CLASS_TV_DIGITAL; + ttusb->i2c_adap.class = I2C_ADAP_CLASS_TV_DIGITAL; #else - ttusb->i2c_adap.class = I2C_CLASS_TV_DIGITAL; + ttusb->i2c_adap.class = I2C_CLASS_TV_DIGITAL; #endif ttusb->i2c_adap.algo = &ttusb_dec_algo; ttusb->i2c_adap.algo_data = NULL; - ttusb->i2c_adap.id = I2C_ALGO_BIT; result = i2c_add_adapter(&ttusb->i2c_adap); if (result) { - dvb_unregister_adapter (ttusb->adapter); + dvb_unregister_adapter (&ttusb->adapter); return result; } @@ -1480,7 +1552,7 @@ static int ttusb_probe(struct usb_interface *intf, const struct usb_device_id *i if ((result = dvb_dmx_init(&ttusb->dvb_demux)) < 0) { printk("ttusb_dvb: dvb_dmx_init failed (errno = %d)\n", result); i2c_del_adapter(&ttusb->i2c_adap); - dvb_unregister_adapter (ttusb->adapter); + dvb_unregister_adapter (&ttusb->adapter); return -ENODEV; } //FIXME dmxdev (nur WAS?) @@ -1488,21 +1560,21 @@ static int ttusb_probe(struct usb_interface *intf, const struct usb_device_id *i ttusb->dmxdev.demux = &ttusb->dvb_demux.dmx; ttusb->dmxdev.capabilities = 0; - if ((result = dvb_dmxdev_init(&ttusb->dmxdev, ttusb->adapter)) < 0) { + if ((result = dvb_dmxdev_init(&ttusb->dmxdev, &ttusb->adapter)) < 0) { printk("ttusb_dvb: dvb_dmxdev_init failed (errno = %d)\n", result); dvb_dmx_release(&ttusb->dvb_demux); i2c_del_adapter(&ttusb->i2c_adap); - dvb_unregister_adapter (ttusb->adapter); + 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); + dvb_unregister_adapter (&ttusb->adapter); return -ENODEV; } @@ -1536,7 +1608,7 @@ static void ttusb_disconnect(struct usb_interface *intf) dvb_dmx_release(&ttusb->dvb_demux); if (ttusb->fe != NULL) dvb_unregister_frontend(ttusb->fe); i2c_del_adapter(&ttusb->i2c_adap); - dvb_unregister_adapter(ttusb->adapter); + dvb_unregister_adapter(&ttusb->adapter); ttusb_free_iso_urbs(ttusb); @@ -1547,7 +1619,7 @@ static void ttusb_disconnect(struct usb_interface *intf) static struct usb_device_id ttusb_table[] = { {USB_DEVICE(0xb48, 0x1003)}, -/* {USB_DEVICE(0xb48, 0x1004)},UNDEFINED HARDWARE - mail linuxtv.org list*/ /* to be confirmed ???? */ + {USB_DEVICE(0xb48, 0x1004)}, {USB_DEVICE(0xb48, 0x1005)}, {} }; @@ -1555,10 +1627,10 @@ static struct usb_device_id ttusb_table[] = { MODULE_DEVICE_TABLE(usb, ttusb_table); static struct usb_driver ttusb_driver = { - .name = "Technotrend/Hauppauge USB-Nova", - .probe = ttusb_probe, - .disconnect = ttusb_disconnect, - .id_table = ttusb_table, + .name = "ttusb", + .probe = ttusb_probe, + .disconnect = ttusb_disconnect, + .id_table = ttusb_table, }; static int __init ttusb_init(void)