25 #define DVB_USB_LOG_PREFIX "ttusb2"
40 static int dvb_usb_ttusb2_debug;
41 #define deb_info(args...) dprintk(dvb_usb_ttusb2_debug,0x01,args)
44 static int dvb_usb_ttusb2_debug_ci;
50 #define ci_dbg(format, arg...) \
52 if (dvb_usb_ttusb2_debug_ci) \
53 printk(KERN_DEBUG DVB_USB_LOG_PREFIX \
54 ": %s " format "\n" , __func__, ## arg); \
75 u8 *wbuf,
int wlen,
u8 *rbuf,
int rlen)
103 (rlen > 0 && r[3] != rlen)) {
104 warn(
"there might have been an error during control message transfer. (rlen = %d, was %d)",rlen,r[3]);
111 memcpy(rbuf, &r[4], rlen);
120 static int tt3650_ci_msg(
struct dvb_usb_device *d,
u8 cmd,
u8 *
data,
unsigned int write_len,
unsigned int read_len)
124 ret = ttusb2_msg(d, cmd, data, write_len, rx, read_len);
126 memcpy(data, rx, read_len);
130 static int tt3650_ci_msg_locked(
struct dvb_ca_en50221 *
ca,
u8 cmd,
u8 *data,
unsigned int write_len,
unsigned int read_len)
137 ret = tt3650_ci_msg(d, cmd, data, write_len, read_len);
151 buf[0] = (address >> 8) & 0x0F;
157 ci_dbg(
"%04x -> %d 0x%02x", address, ret, buf[2]);
169 ci_dbg(
"%d 0x%04x 0x%02x", slot, address, value);
174 buf[0] = (address >> 8) & 0x0F;
181 static int tt3650_ci_read_cam_control(
struct dvb_ca_en50221 *ca,
int slot,
u8 address)
189 buf[0] = address & 3;
193 ci_dbg(
"0x%02x -> %d 0x%02x", address, ret, buf[1]);
201 static int tt3650_ci_write_cam_control(
struct dvb_ca_en50221 *ca,
int slot,
u8 address,
u8 value)
205 ci_dbg(
"%d 0x%02x 0x%02x", slot, address, value);
221 ci_dbg(
"%d %d", slot, enable);
232 if (enable != buf[0]) {
233 err(
"CI not %sabled.", enable ?
"en" :
"dis");
240 static int tt3650_ci_slot_shutdown(
struct dvb_ca_en50221 *ca,
int slot)
242 return tt3650_ci_set_video_port(ca, slot, 0);
245 static int tt3650_ci_slot_ts_enable(
struct dvb_ca_en50221 *ca,
int slot)
247 return tt3650_ci_set_video_port(ca, slot, 1);
250 static int tt3650_ci_slot_reset(
struct dvb_ca_en50221 *ca,
int slot)
324 if (
NULL == state->
ca.data)
343 state->
ca.read_attribute_mem = tt3650_ci_read_attribute_mem;
344 state->
ca.write_attribute_mem = tt3650_ci_write_attribute_mem;
345 state->
ca.read_cam_control = tt3650_ci_read_cam_control;
346 state->
ca.write_cam_control = tt3650_ci_write_cam_control;
347 state->
ca.slot_reset = tt3650_ci_slot_reset;
348 state->
ca.slot_shutdown = tt3650_ci_slot_shutdown;
349 state->
ca.slot_ts_enable = tt3650_ci_slot_ts_enable;
350 state->
ca.poll_slot_status = tt3650_ci_poll_slot_status;
358 err(
"Cannot initialize CI: Error %d.", ret);
363 info(
"CI initialized.");
371 static u8 obuf[60], ibuf[60];
372 int i, write_read,
read;
378 warn(
"more than 2 i2c messages at a time is not handled yet. TODO.");
380 for (i = 0; i < num; i++) {
384 obuf[0] = (msg[
i].
addr << 1) | (write_read | read);
388 obuf[1] = msg[
i].
len;
392 obuf[2] = msg[i+1].
len;
394 obuf[2] = msg[
i].
len;
398 memcpy(&obuf[3], msg[i].buf, msg[i].len);
400 if (ttusb2_msg(d,
CMD_I2C_XFER, obuf, obuf[1]+3, ibuf, obuf[2] + 3) < 0) {
401 err(
"i2c transfer failed.");
406 memcpy(msg[i+1].buf, &ibuf[3], msg[i+1].len);
409 memcpy(msg[i].buf, &ibuf[3], msg[i].len);
422 .master_xfer = ttusb2_i2c_xfer,
423 .functionality = ttusb2_i2c_func,
427 #define CMD_GET_IR_CODE 0x1b
442 deb_info(
"%s: cmd=0x%02x sys=0x%02x\n", __func__, rx[2], rx[3]);
454 static int ttusb2_identify_state (
struct usb_device *
udev,
struct
458 *cold = udev->descriptor.iManufacturer == 0 && udev->descriptor.iProduct == 0;
506 static int ttusb2_frontend_tda10086_attach(
struct dvb_usb_adapter *adap)
509 err(
"set interface to alts=3 failed");
512 deb_info(
"TDA10086 attach failed\n");
519 static int ttusb2_ct3650_i2c_gate_ctrl(
struct dvb_frontend *fe,
int enable)
523 return adap->
fe_adap[0].fe->ops.i2c_gate_ctrl(adap->
fe_adap[0].fe, enable);
526 static int ttusb2_frontend_tda10023_attach(
struct dvb_usb_adapter *adap)
529 err(
"set interface to alts=3 failed");
534 &tda10023_config, &adap->
dev->i2c_adap, 0x48);
537 deb_info(
"TDA10023 attach failed\n");
540 tt3650_ci_init(adap);
543 &tda10048_config, &adap->
dev->i2c_adap);
546 deb_info(
"TDA10048 attach failed\n");
551 adap->
fe_adap[1].fe->ops.i2c_gate_ctrl = ttusb2_ct3650_i2c_gate_ctrl;
579 deb_info(
"TDA8263 attach failed\n");
631 .firmware =
"dvb-usb-pctv-400e-01.fw",
640 .streaming_ctrl =
NULL,
642 .frontend_attach = ttusb2_frontend_tda10086_attach,
643 .tuner_attach = ttusb2_tuner_tda826x_attach,
662 .power_ctrl = ttusb2_power_ctrl,
663 .identify_state = ttusb2_identify_state,
665 .i2c_algo = &ttusb2_i2c_algo,
667 .generic_bulk_ctrl_endpoint = 0x01,
669 .num_device_descs = 2,
671 {
"Pinnacle 400e DVB-S USB2.0",
672 { &ttusb2_table[0],
NULL },
675 {
"Pinnacle 450e DVB-S USB2.0",
676 { &ttusb2_table[1],
NULL },
686 .firmware =
"dvb-usb-tt-s2400-01.fw",
695 .streaming_ctrl =
NULL,
697 .frontend_attach = ttusb2_frontend_tda10086_attach,
698 .tuner_attach = ttusb2_tuner_tda826x_attach,
717 .power_ctrl = ttusb2_power_ctrl,
718 .identify_state = ttusb2_identify_state,
720 .i2c_algo = &ttusb2_i2c_algo,
722 .generic_bulk_ctrl_endpoint = 0x01,
724 .num_device_descs = 1,
726 {
"Technotrend TT-connect S-2400",
727 { &ttusb2_table[2],
NULL },
743 .rc_query = tt3650_rc_query,
752 .streaming_ctrl =
NULL,
754 .frontend_attach = ttusb2_frontend_tda10023_attach,
755 .tuner_attach = ttusb2_tuner_tda827x_attach,
771 .streaming_ctrl =
NULL,
773 .frontend_attach = ttusb2_frontend_tda10023_attach,
774 .tuner_attach = ttusb2_tuner_tda827x_attach,
793 .power_ctrl = ttusb2_power_ctrl,
794 .identify_state = ttusb2_identify_state,
796 .i2c_algo = &ttusb2_i2c_algo,
798 .generic_bulk_ctrl_endpoint = 0x01,
800 .num_device_descs = 1,
802 {
"Technotrend TT-connect CT-3650",
803 .warm_ids = { &ttusb2_table[3],
NULL },
808 static struct usb_driver ttusb2_driver = {
809 .name =
"dvb_usb_ttusb2",
810 .probe = ttusb2_probe,
811 .disconnect = ttusb2_usb_disconnect,
812 .id_table = ttusb2_table,