33 #define DVB_USB_LOG_PREFIX "technisat-usb2"
45 "set debugging level (bit-mask: 1=info,2=eeprom,4=i2c,8=rc)." \
50 static int disable_led_control;
53 "disable LED control of the device "
54 "(default: 0 - LED control is active).");
66 #define deb_info(args...) dprintk(debug, 0x01, args)
67 #define deb_eeprom(args...) dprintk(debug, 0x02, args)
68 #define deb_i2c(args...) dprintk(debug, 0x04, args)
69 #define deb_rc(args...) dprintk(debug, 0x08, args)
72 #define SET_IFCLK_TO_EXTERNAL_TSCLK_VENDOR_REQUEST 0xB3
73 #define SET_FRONT_END_RESET_VENDOR_REQUEST 0xB4
74 #define GET_VERSION_INFO_VENDOR_REQUEST 0xB5
75 #define SET_GREEN_LED_VENDOR_REQUEST 0xB6
76 #define SET_RED_LED_VENDOR_REQUEST 0xB7
77 #define GET_IR_DATA_VENDOR_REQUEST 0xB8
78 #define SET_LED_TIMER_DIVIDER_VENDOR_REQUEST 0xB9
79 #define SET_USB_REENUMERATION 0xBA
82 #define I2C_SPEED_100KHZ_BIT 0x40
84 #define I2C_STATUS_NAK 7
85 #define I2C_STATUS_OK 8
87 static int technisat_usb2_i2c_access(
struct usb_device *
udev,
91 int ret, actual_length;
93 deb_i2c(
"i2c-access: %02x, tx: ", device_addr);
98 err(
"i2c TX buffer can't exceed 62 bytes (dev 0x%02x)",
103 err(
"i2c RX buffer can't exceed 62 bytes (dev 0x%02x)",
109 b[1] = device_addr << 1;
118 usb_sndbulkpipe(udev, 0x01),
123 err(
"i2c-error: out failed %02x = %d", device_addr, ret);
128 usb_rcvbulkpipe(udev, 0x01),
129 b, 64, &actual_length, 1000);
131 err(
"i2c-error: in failed %02x = %d", device_addr, ret);
136 err(
"i2c-error: %02x = %d", device_addr, b[0]);
169 for (
i = 0;
i < num;
i++) {
171 ret = technisat_usb2_i2c_access(d->
udev, msg[
i+1].
addr,
173 msg[i+1].
buf, msg[i+1].
len);
178 ret = technisat_usb2_i2c_access(d->
udev, msg[
i].
addr,
200 .master_xfer = technisat_usb2_i2c_xfer,
201 .functionality = technisat_usb2_i2c_func,
205 static void technisat_usb2_frontend_reset(
struct usb_device *
udev)
232 if (disable_led_control && state !=
LED_OFF)
266 led,
sizeof(led), 500);
283 (red << 8) | green, 0,
303 if (fe->
ops.read_status(fe, &status) != 0)
309 if (fe->
ops.read_ber(fe, &ber) != 0)
315 technisat_usb2_set_led(state->
dev, 0,
LED_ON);
317 technisat_usb2_set_led(state->
dev, 0,
LED_OFF);
326 static int technisat_usb2_identify_state(
struct usb_device *udev,
335 err(
"could not set alternate setting to 0");
337 info(
"set alternate setting");
345 version,
sizeof(version), 500);
350 info(
"firmware version: %d.%d", version[1], version[2]);
364 if (disable_led_control)
368 technisat_usb2_set_led(d, 0,
LED_OFF);
370 technisat_usb2_set_led(d, 1,
LED_ON);
383 for (j = 0; j < 256 * 4; j += 16) {
385 if (technisat_usb2_i2c_access(d->
udev, 0x50 + j / 256, ®, 1, b, 16) != 0)
388 deb_eeprom(
"EEPROM: %01x%02x: ", j / 256, reg);
389 for (i = 0; i < 16; i++)
404 static int technisat_usb2_eeprom_lrc_read(
struct dvb_usb_device *d,
407 u8 bo = offset & 0xff;
410 .
addr = 0x50 | ((offset >> 8) & 0x3),
414 .addr = 0x50 | ((offset >> 8) & 0x3),
428 technisat_usb2_calc_lrc(b, length - 1) == b[length - 1];
437 #define EEPROM_MAC_START 0x3f8
438 #define EEPROM_MAC_TOTAL 8
439 static int technisat_usb2_read_mac_address(
struct dvb_usb_device *d,
453 static int technisat_usb2_set_voltage(
struct dvb_frontend *fe,
474 for (i = 0; i < 3; i++)
505 struct usb_device *udev = a->
dev->udev;
516 &technisat_usb2_stv6110x_config,
535 if (a->
fe_adap[0].fe->ops.init)
549 err(
"could not set IF_CLK to external");
551 a->
fe_adap[0].fe->ops.set_voltage = technisat_usb2_set_voltage;
555 sizeof(a->
fe_adap[0].fe->ops.info.name));
562 technisat_usb2_set_led_timer(a->
dev, 1, 1);
572 #define NOMINAL_IR_BIT_TRANSITION_TIME_US 889
573 #define NOMINAL_IR_BIT_TIME_US (2 * NOMINAL_IR_BIT_TRANSITION_TIME_US)
575 #define FIRMWARE_CLOCK_TICK 83333
576 #define FIRMWARE_CLOCK_DIVISOR 256
578 #define IR_PERCENT_TOLERANCE 15
580 #define NOMINAL_IR_BIT_TRANSITION_TICKS ((NOMINAL_IR_BIT_TRANSITION_TIME_US * 1000 * 1000) / FIRMWARE_CLOCK_TICK)
581 #define NOMINAL_IR_BIT_TRANSITION_TICK_COUNT (NOMINAL_IR_BIT_TRANSITION_TICKS / FIRMWARE_CLOCK_DIVISOR)
583 #define NOMINAL_IR_BIT_TIME_TICKS ((NOMINAL_IR_BIT_TIME_US * 1000 * 1000) / FIRMWARE_CLOCK_TICK)
584 #define NOMINAL_IR_BIT_TIME_TICK_COUNT (NOMINAL_IR_BIT_TIME_TICKS / FIRMWARE_CLOCK_DIVISOR)
586 #define MINIMUM_IR_BIT_TRANSITION_TICK_COUNT (NOMINAL_IR_BIT_TRANSITION_TICK_COUNT - ((NOMINAL_IR_BIT_TRANSITION_TICK_COUNT * IR_PERCENT_TOLERANCE) / 100))
587 #define MAXIMUM_IR_BIT_TRANSITION_TICK_COUNT (NOMINAL_IR_BIT_TRANSITION_TICK_COUNT + ((NOMINAL_IR_BIT_TRANSITION_TICK_COUNT * IR_PERCENT_TOLERANCE) / 100))
589 #define MINIMUM_IR_BIT_TIME_TICK_COUNT (NOMINAL_IR_BIT_TIME_TICK_COUNT - ((NOMINAL_IR_BIT_TIME_TICK_COUNT * IR_PERCENT_TOLERANCE) / 100))
590 #define MAXIMUM_IR_BIT_TIME_TICK_COUNT (NOMINAL_IR_BIT_TIME_TICK_COUNT + ((NOMINAL_IR_BIT_TIME_TICK_COUNT * IR_PERCENT_TOLERANCE) / 100))
620 buf,
sizeof(buf), 500);
661 int ret = technisat_usb2_get_ir(d);
669 if (!disable_led_control)
688 .identify_state = technisat_usb2_identify_state,
689 .firmware =
"dvb-usb-SkyStar_USB_HD_FW_v17_63.HEX.fw",
693 .i2c_algo = &technisat_usb2_i2c_algo,
695 .power_ctrl = technisat_usb2_power_ctrl,
696 .read_mac_address = technisat_usb2_read_mac_address,
703 .frontend_attach = technisat_usb2_frontend_attach,
722 .num_device_descs = 1,
724 {
"Technisat SkyStar USB HD (DVB-S/S2)",
725 { &technisat_usb2_id_table[0],
NULL },
733 .module_name =
"technisat-usb2",
734 .rc_query = technisat_usb2_rc_query,
746 &dev, adapter_nr) != 0)
753 if (!disable_led_control) {
755 technisat_usb2_green_led_control);
764 static void technisat_usb2_disconnect(
struct usb_interface *intf)
778 static struct usb_driver technisat_usb2_driver = {
779 .name =
"dvb_usb_technisat_usb2",
780 .probe = technisat_usb2_probe,
781 .disconnect = technisat_usb2_disconnect,
782 .id_table = technisat_usb2_id_table,