Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 1 | /* DVB USB framework compliant Linux driver for the |
Igor M. Liplianin | 2f30fb4 | 2011-02-25 18:41:23 -0300 | [diff] [blame] | 2 | * DVBWorld DVB-S 2101, 2102, DVB-S2 2104, DVB-C 3101, |
| 3 | * TeVii S600, S630, S650, S660, S480, |
| 4 | * Prof 1100, 7500, |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 5 | * Geniatech SU3000 Cards |
Igor M. Liplianin | 2f30fb4 | 2011-02-25 18:41:23 -0300 | [diff] [blame] | 6 | * Copyright (C) 2008-2011 Igor M. Liplianin (liplianin@me.by) |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify it |
| 9 | * under the terms of the GNU General Public License as published by the |
| 10 | * Free Software Foundation, version 2. |
| 11 | * |
| 12 | * see Documentation/dvb/README.dvb-usb for more information |
| 13 | */ |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 14 | #include "dw2102.h" |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 15 | #include "si21xx.h" |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 16 | #include "stv0299.h" |
| 17 | #include "z0194a.h" |
Igor M. Liplianin | 8a4949b | 2008-10-05 09:11:21 -0300 | [diff] [blame] | 18 | #include "stv0288.h" |
| 19 | #include "stb6000.h" |
| 20 | #include "eds1547.h" |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 21 | #include "cx24116.h" |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 22 | #include "tda1002x.h" |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 23 | #include "mt312.h" |
| 24 | #include "zl10039.h" |
Konstantin Dimitrov | 73f0af4 | 2012-12-23 19:25:38 -0300 | [diff] [blame^] | 25 | #include "ts2020.h" |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 26 | #include "ds3000.h" |
| 27 | #include "stv0900.h" |
| 28 | #include "stv6110.h" |
| 29 | #include "stb6100.h" |
| 30 | #include "stb6100_proc.h" |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 31 | |
| 32 | #ifndef USB_PID_DW2102 |
| 33 | #define USB_PID_DW2102 0x2102 |
| 34 | #endif |
| 35 | |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 36 | #ifndef USB_PID_DW2104 |
| 37 | #define USB_PID_DW2104 0x2104 |
| 38 | #endif |
| 39 | |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 40 | #ifndef USB_PID_DW3101 |
| 41 | #define USB_PID_DW3101 0x3101 |
| 42 | #endif |
| 43 | |
Igor M. Liplianin | 4cc0edf | 2008-11-05 22:12:56 -0300 | [diff] [blame] | 44 | #ifndef USB_PID_CINERGY_S |
| 45 | #define USB_PID_CINERGY_S 0x0064 |
| 46 | #endif |
| 47 | |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 48 | #ifndef USB_PID_TEVII_S630 |
| 49 | #define USB_PID_TEVII_S630 0xd630 |
| 50 | #endif |
| 51 | |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 52 | #ifndef USB_PID_TEVII_S650 |
| 53 | #define USB_PID_TEVII_S650 0xd650 |
| 54 | #endif |
| 55 | |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 56 | #ifndef USB_PID_TEVII_S660 |
| 57 | #define USB_PID_TEVII_S660 0xd660 |
| 58 | #endif |
| 59 | |
Igor M. Liplianin | e8f5055 | 2011-02-25 18:41:23 -0300 | [diff] [blame] | 60 | #ifndef USB_PID_TEVII_S480_1 |
| 61 | #define USB_PID_TEVII_S480_1 0xd481 |
| 62 | #endif |
| 63 | |
| 64 | #ifndef USB_PID_TEVII_S480_2 |
| 65 | #define USB_PID_TEVII_S480_2 0xd482 |
| 66 | #endif |
| 67 | |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 68 | #ifndef USB_PID_PROF_1100 |
| 69 | #define USB_PID_PROF_1100 0xb012 |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 70 | #endif |
| 71 | |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 72 | #define DW210X_READ_MSG 0 |
| 73 | #define DW210X_WRITE_MSG 1 |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 74 | |
| 75 | #define REG_1F_SYMBOLRATE_BYTE0 0x1f |
| 76 | #define REG_20_SYMBOLRATE_BYTE1 0x20 |
| 77 | #define REG_21_SYMBOLRATE_BYTE2 0x21 |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 78 | /* on my own*/ |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 79 | #define DW2102_VOLTAGE_CTRL (0x1800) |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 80 | #define SU3000_STREAM_CTRL (0x1900) |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 81 | #define DW2102_RC_QUERY (0x1a00) |
Igor M. Liplianin | fa8bae1 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 82 | #define DW2102_LED_CTRL (0x1b00) |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 83 | |
Rémi Cardona | 6823627 | 2012-09-28 08:59:32 -0300 | [diff] [blame] | 84 | #define DW2101_FIRMWARE "dvb-usb-dw2101.fw" |
| 85 | #define DW2102_FIRMWARE "dvb-usb-dw2102.fw" |
| 86 | #define DW2104_FIRMWARE "dvb-usb-dw2104.fw" |
| 87 | #define DW3101_FIRMWARE "dvb-usb-dw3101.fw" |
| 88 | #define S630_FIRMWARE "dvb-usb-s630.fw" |
| 89 | #define S660_FIRMWARE "dvb-usb-s660.fw" |
| 90 | #define P1100_FIRMWARE "dvb-usb-p1100.fw" |
| 91 | #define P7500_FIRMWARE "dvb-usb-p7500.fw" |
| 92 | |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 93 | #define err_str "did not find the firmware file. (%s) " \ |
| 94 | "Please see linux/Documentation/dvb/ for more details " \ |
| 95 | "on firmware-problems." |
| 96 | |
Mauro Carvalho Chehab | 2f4f58d | 2010-11-17 15:46:09 -0300 | [diff] [blame] | 97 | struct rc_map_dvb_usb_table_table { |
| 98 | struct rc_map_table *rc_keys; |
Igor M. Liplianin | b42e1d7 | 2009-06-14 19:41:22 -0300 | [diff] [blame] | 99 | int rc_keys_size; |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 100 | }; |
| 101 | |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 102 | struct su3000_state { |
| 103 | u8 initialized; |
| 104 | }; |
| 105 | |
Igor M. Liplianin | 52c506e | 2011-02-25 18:41:23 -0300 | [diff] [blame] | 106 | struct s6x0_state { |
| 107 | int (*old_set_voltage)(struct dvb_frontend *f, fe_sec_voltage_t v); |
| 108 | }; |
| 109 | |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 110 | /* debug */ |
| 111 | static int dvb_usb_dw2102_debug; |
| 112 | module_param_named(debug, dvb_usb_dw2102_debug, int, 0644); |
Igor M. Liplianin | 8a8dad7 | 2009-06-13 08:10:24 -0300 | [diff] [blame] | 113 | MODULE_PARM_DESC(debug, "set debugging level (1=info 2=xfer 4=rc(or-able))." |
| 114 | DVB_USB_DEBUG_STATUS); |
| 115 | |
Igor M. Liplianin | b42e1d7 | 2009-06-14 19:41:22 -0300 | [diff] [blame] | 116 | /* keymaps */ |
| 117 | static int ir_keymap; |
| 118 | module_param_named(keymap, ir_keymap, int, 0644); |
Igor M. Liplianin | feb16e9 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 119 | MODULE_PARM_DESC(keymap, "set keymap 0=default 1=dvbworld 2=tevii 3=tbs ..." |
| 120 | " 256=none"); |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 121 | |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 122 | /* demod probe */ |
| 123 | static int demod_probe = 1; |
| 124 | module_param_named(demod, demod_probe, int, 0644); |
| 125 | MODULE_PARM_DESC(demod, "demod to probe (1=cx24116 2=stv0903+stv6110 " |
| 126 | "4=stv0903+stb6100(or-able))."); |
| 127 | |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 128 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); |
| 129 | |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 130 | static int dw210x_op_rw(struct usb_device *dev, u8 request, u16 value, |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 131 | u16 index, u8 * data, u16 len, int flags) |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 132 | { |
| 133 | int ret; |
Florian Mickler | b47b850 | 2011-03-21 15:33:44 -0300 | [diff] [blame] | 134 | u8 *u8buf; |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 135 | unsigned int pipe = (flags == DW210X_READ_MSG) ? |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 136 | usb_rcvctrlpipe(dev, 0) : usb_sndctrlpipe(dev, 0); |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 137 | u8 request_type = (flags == DW210X_READ_MSG) ? USB_DIR_IN : USB_DIR_OUT; |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 138 | |
Florian Mickler | b47b850 | 2011-03-21 15:33:44 -0300 | [diff] [blame] | 139 | u8buf = kmalloc(len, GFP_KERNEL); |
| 140 | if (!u8buf) |
| 141 | return -ENOMEM; |
| 142 | |
| 143 | |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 144 | if (flags == DW210X_WRITE_MSG) |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 145 | memcpy(u8buf, data, len); |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 146 | ret = usb_control_msg(dev, pipe, request, request_type | USB_TYPE_VENDOR, |
| 147 | value, index , u8buf, len, 2000); |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 148 | |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 149 | if (flags == DW210X_READ_MSG) |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 150 | memcpy(data, u8buf, len); |
Florian Mickler | b47b850 | 2011-03-21 15:33:44 -0300 | [diff] [blame] | 151 | |
| 152 | kfree(u8buf); |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 153 | return ret; |
| 154 | } |
| 155 | |
| 156 | /* I2C */ |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 157 | static int dw2102_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], |
| 158 | int num) |
| 159 | { |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 160 | struct dvb_usb_device *d = i2c_get_adapdata(adap); |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 161 | int i = 0; |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 162 | u8 buf6[] = {0x2c, 0x05, 0xc0, 0, 0, 0, 0}; |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 163 | u16 value; |
| 164 | |
| 165 | if (!d) |
| 166 | return -ENODEV; |
| 167 | if (mutex_lock_interruptible(&d->i2c_mutex) < 0) |
| 168 | return -EAGAIN; |
| 169 | |
| 170 | switch (num) { |
| 171 | case 2: |
| 172 | /* read stv0299 register */ |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 173 | value = msg[0].buf[0];/* register */ |
| 174 | for (i = 0; i < msg[1].len; i++) { |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 175 | dw210x_op_rw(d->udev, 0xb5, value + i, 0, |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 176 | buf6, 2, DW210X_READ_MSG); |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 177 | msg[1].buf[i] = buf6[0]; |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 178 | } |
| 179 | break; |
| 180 | case 1: |
| 181 | switch (msg[0].addr) { |
| 182 | case 0x68: |
| 183 | /* write to stv0299 register */ |
| 184 | buf6[0] = 0x2a; |
| 185 | buf6[1] = msg[0].buf[0]; |
| 186 | buf6[2] = msg[0].buf[1]; |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 187 | dw210x_op_rw(d->udev, 0xb2, 0, 0, |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 188 | buf6, 3, DW210X_WRITE_MSG); |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 189 | break; |
| 190 | case 0x60: |
| 191 | if (msg[0].flags == 0) { |
| 192 | /* write to tuner pll */ |
| 193 | buf6[0] = 0x2c; |
| 194 | buf6[1] = 5; |
| 195 | buf6[2] = 0xc0; |
| 196 | buf6[3] = msg[0].buf[0]; |
| 197 | buf6[4] = msg[0].buf[1]; |
| 198 | buf6[5] = msg[0].buf[2]; |
| 199 | buf6[6] = msg[0].buf[3]; |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 200 | dw210x_op_rw(d->udev, 0xb2, 0, 0, |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 201 | buf6, 7, DW210X_WRITE_MSG); |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 202 | } else { |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 203 | /* read from tuner */ |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 204 | dw210x_op_rw(d->udev, 0xb5, 0, 0, |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 205 | buf6, 1, DW210X_READ_MSG); |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 206 | msg[0].buf[0] = buf6[0]; |
| 207 | } |
| 208 | break; |
| 209 | case (DW2102_RC_QUERY): |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 210 | dw210x_op_rw(d->udev, 0xb8, 0, 0, |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 211 | buf6, 2, DW210X_READ_MSG); |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 212 | msg[0].buf[0] = buf6[0]; |
| 213 | msg[0].buf[1] = buf6[1]; |
| 214 | break; |
| 215 | case (DW2102_VOLTAGE_CTRL): |
| 216 | buf6[0] = 0x30; |
| 217 | buf6[1] = msg[0].buf[0]; |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 218 | dw210x_op_rw(d->udev, 0xb2, 0, 0, |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 219 | buf6, 2, DW210X_WRITE_MSG); |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 220 | break; |
| 221 | } |
| 222 | |
| 223 | break; |
| 224 | } |
| 225 | |
| 226 | mutex_unlock(&d->i2c_mutex); |
| 227 | return num; |
| 228 | } |
| 229 | |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 230 | static int dw2102_serit_i2c_transfer(struct i2c_adapter *adap, |
| 231 | struct i2c_msg msg[], int num) |
| 232 | { |
| 233 | struct dvb_usb_device *d = i2c_get_adapdata(adap); |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 234 | u8 buf6[] = {0, 0, 0, 0, 0, 0, 0}; |
| 235 | |
| 236 | if (!d) |
| 237 | return -ENODEV; |
| 238 | if (mutex_lock_interruptible(&d->i2c_mutex) < 0) |
| 239 | return -EAGAIN; |
| 240 | |
| 241 | switch (num) { |
| 242 | case 2: |
| 243 | /* read si2109 register by number */ |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 244 | buf6[0] = msg[0].addr << 1; |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 245 | buf6[1] = msg[0].len; |
| 246 | buf6[2] = msg[0].buf[0]; |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 247 | dw210x_op_rw(d->udev, 0xc2, 0, 0, |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 248 | buf6, msg[0].len + 2, DW210X_WRITE_MSG); |
| 249 | /* read si2109 register */ |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 250 | dw210x_op_rw(d->udev, 0xc3, 0xd0, 0, |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 251 | buf6, msg[1].len + 2, DW210X_READ_MSG); |
| 252 | memcpy(msg[1].buf, buf6 + 2, msg[1].len); |
| 253 | |
| 254 | break; |
| 255 | case 1: |
| 256 | switch (msg[0].addr) { |
| 257 | case 0x68: |
| 258 | /* write to si2109 register */ |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 259 | buf6[0] = msg[0].addr << 1; |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 260 | buf6[1] = msg[0].len; |
| 261 | memcpy(buf6 + 2, msg[0].buf, msg[0].len); |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 262 | dw210x_op_rw(d->udev, 0xc2, 0, 0, buf6, |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 263 | msg[0].len + 2, DW210X_WRITE_MSG); |
| 264 | break; |
| 265 | case(DW2102_RC_QUERY): |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 266 | dw210x_op_rw(d->udev, 0xb8, 0, 0, |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 267 | buf6, 2, DW210X_READ_MSG); |
| 268 | msg[0].buf[0] = buf6[0]; |
| 269 | msg[0].buf[1] = buf6[1]; |
| 270 | break; |
| 271 | case(DW2102_VOLTAGE_CTRL): |
| 272 | buf6[0] = 0x30; |
| 273 | buf6[1] = msg[0].buf[0]; |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 274 | dw210x_op_rw(d->udev, 0xb2, 0, 0, |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 275 | buf6, 2, DW210X_WRITE_MSG); |
| 276 | break; |
| 277 | } |
| 278 | break; |
| 279 | } |
| 280 | |
| 281 | mutex_unlock(&d->i2c_mutex); |
| 282 | return num; |
| 283 | } |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 284 | |
Igor M. Liplianin | 8a4949b | 2008-10-05 09:11:21 -0300 | [diff] [blame] | 285 | static int dw2102_earda_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], int num) |
| 286 | { |
| 287 | struct dvb_usb_device *d = i2c_get_adapdata(adap); |
Igor M. Liplianin | 8a4949b | 2008-10-05 09:11:21 -0300 | [diff] [blame] | 288 | |
| 289 | if (!d) |
| 290 | return -ENODEV; |
| 291 | if (mutex_lock_interruptible(&d->i2c_mutex) < 0) |
| 292 | return -EAGAIN; |
| 293 | |
| 294 | switch (num) { |
| 295 | case 2: { |
| 296 | /* read */ |
| 297 | /* first write first register number */ |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 298 | u8 ibuf[msg[1].len + 2], obuf[3]; |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 299 | obuf[0] = msg[0].addr << 1; |
Igor M. Liplianin | 8a4949b | 2008-10-05 09:11:21 -0300 | [diff] [blame] | 300 | obuf[1] = msg[0].len; |
| 301 | obuf[2] = msg[0].buf[0]; |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 302 | dw210x_op_rw(d->udev, 0xc2, 0, 0, |
Igor M. Liplianin | 8a4949b | 2008-10-05 09:11:21 -0300 | [diff] [blame] | 303 | obuf, msg[0].len + 2, DW210X_WRITE_MSG); |
| 304 | /* second read registers */ |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 305 | dw210x_op_rw(d->udev, 0xc3, 0xd1 , 0, |
Igor M. Liplianin | 8a4949b | 2008-10-05 09:11:21 -0300 | [diff] [blame] | 306 | ibuf, msg[1].len + 2, DW210X_READ_MSG); |
| 307 | memcpy(msg[1].buf, ibuf + 2, msg[1].len); |
| 308 | |
| 309 | break; |
| 310 | } |
| 311 | case 1: |
| 312 | switch (msg[0].addr) { |
| 313 | case 0x68: { |
| 314 | /* write to register */ |
| 315 | u8 obuf[msg[0].len + 2]; |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 316 | obuf[0] = msg[0].addr << 1; |
Igor M. Liplianin | 8a4949b | 2008-10-05 09:11:21 -0300 | [diff] [blame] | 317 | obuf[1] = msg[0].len; |
| 318 | memcpy(obuf + 2, msg[0].buf, msg[0].len); |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 319 | dw210x_op_rw(d->udev, 0xc2, 0, 0, |
Igor M. Liplianin | 8a4949b | 2008-10-05 09:11:21 -0300 | [diff] [blame] | 320 | obuf, msg[0].len + 2, DW210X_WRITE_MSG); |
| 321 | break; |
| 322 | } |
| 323 | case 0x61: { |
| 324 | /* write to tuner */ |
| 325 | u8 obuf[msg[0].len + 2]; |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 326 | obuf[0] = msg[0].addr << 1; |
Igor M. Liplianin | 8a4949b | 2008-10-05 09:11:21 -0300 | [diff] [blame] | 327 | obuf[1] = msg[0].len; |
| 328 | memcpy(obuf + 2, msg[0].buf, msg[0].len); |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 329 | dw210x_op_rw(d->udev, 0xc2, 0, 0, |
Igor M. Liplianin | 8a4949b | 2008-10-05 09:11:21 -0300 | [diff] [blame] | 330 | obuf, msg[0].len + 2, DW210X_WRITE_MSG); |
| 331 | break; |
| 332 | } |
| 333 | case(DW2102_RC_QUERY): { |
| 334 | u8 ibuf[2]; |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 335 | dw210x_op_rw(d->udev, 0xb8, 0, 0, |
Igor M. Liplianin | 8a4949b | 2008-10-05 09:11:21 -0300 | [diff] [blame] | 336 | ibuf, 2, DW210X_READ_MSG); |
| 337 | memcpy(msg[0].buf, ibuf , 2); |
| 338 | break; |
| 339 | } |
| 340 | case(DW2102_VOLTAGE_CTRL): { |
| 341 | u8 obuf[2]; |
| 342 | obuf[0] = 0x30; |
| 343 | obuf[1] = msg[0].buf[0]; |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 344 | dw210x_op_rw(d->udev, 0xb2, 0, 0, |
Igor M. Liplianin | 8a4949b | 2008-10-05 09:11:21 -0300 | [diff] [blame] | 345 | obuf, 2, DW210X_WRITE_MSG); |
| 346 | break; |
| 347 | } |
| 348 | } |
| 349 | |
| 350 | break; |
| 351 | } |
| 352 | |
| 353 | mutex_unlock(&d->i2c_mutex); |
| 354 | return num; |
| 355 | } |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 356 | |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 357 | static int dw2104_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], int num) |
| 358 | { |
| 359 | struct dvb_usb_device *d = i2c_get_adapdata(adap); |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 360 | int len, i, j; |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 361 | |
| 362 | if (!d) |
| 363 | return -ENODEV; |
| 364 | if (mutex_lock_interruptible(&d->i2c_mutex) < 0) |
| 365 | return -EAGAIN; |
| 366 | |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 367 | for (j = 0; j < num; j++) { |
| 368 | switch (msg[j].addr) { |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 369 | case(DW2102_RC_QUERY): { |
| 370 | u8 ibuf[2]; |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 371 | dw210x_op_rw(d->udev, 0xb8, 0, 0, |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 372 | ibuf, 2, DW210X_READ_MSG); |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 373 | memcpy(msg[j].buf, ibuf , 2); |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 374 | break; |
| 375 | } |
| 376 | case(DW2102_VOLTAGE_CTRL): { |
| 377 | u8 obuf[2]; |
| 378 | obuf[0] = 0x30; |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 379 | obuf[1] = msg[j].buf[0]; |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 380 | dw210x_op_rw(d->udev, 0xb2, 0, 0, |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 381 | obuf, 2, DW210X_WRITE_MSG); |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 382 | break; |
| 383 | } |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 384 | /*case 0x55: cx24116 |
| 385 | case 0x6a: stv0903 |
| 386 | case 0x68: ds3000, stv0903 |
| 387 | case 0x60: ts2020, stv6110, stb6100 */ |
| 388 | default: { |
| 389 | if (msg[j].flags == I2C_M_RD) { |
| 390 | /* read registers */ |
| 391 | u8 ibuf[msg[j].len + 2]; |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 392 | dw210x_op_rw(d->udev, 0xc3, |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 393 | (msg[j].addr << 1) + 1, 0, |
| 394 | ibuf, msg[j].len + 2, |
| 395 | DW210X_READ_MSG); |
| 396 | memcpy(msg[j].buf, ibuf + 2, msg[j].len); |
| 397 | mdelay(10); |
| 398 | } else if (((msg[j].buf[0] == 0xb0) && |
| 399 | (msg[j].addr == 0x68)) || |
| 400 | ((msg[j].buf[0] == 0xf7) && |
| 401 | (msg[j].addr == 0x55))) { |
| 402 | /* write firmware */ |
| 403 | u8 obuf[19]; |
| 404 | obuf[0] = msg[j].addr << 1; |
| 405 | obuf[1] = (msg[j].len > 15 ? 17 : msg[j].len); |
| 406 | obuf[2] = msg[j].buf[0]; |
| 407 | len = msg[j].len - 1; |
| 408 | i = 1; |
| 409 | do { |
| 410 | memcpy(obuf + 3, msg[j].buf + i, |
| 411 | (len > 16 ? 16 : len)); |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 412 | dw210x_op_rw(d->udev, 0xc2, 0, 0, |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 413 | obuf, (len > 16 ? 16 : len) + 3, |
| 414 | DW210X_WRITE_MSG); |
| 415 | i += 16; |
| 416 | len -= 16; |
| 417 | } while (len > 0); |
| 418 | } else { |
| 419 | /* write registers */ |
| 420 | u8 obuf[msg[j].len + 2]; |
| 421 | obuf[0] = msg[j].addr << 1; |
| 422 | obuf[1] = msg[j].len; |
| 423 | memcpy(obuf + 2, msg[j].buf, msg[j].len); |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 424 | dw210x_op_rw(d->udev, 0xc2, 0, 0, |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 425 | obuf, msg[j].len + 2, |
| 426 | DW210X_WRITE_MSG); |
| 427 | } |
| 428 | break; |
| 429 | } |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 430 | } |
| 431 | |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 432 | } |
| 433 | |
| 434 | mutex_unlock(&d->i2c_mutex); |
| 435 | return num; |
| 436 | } |
| 437 | |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 438 | static int dw3101_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], |
| 439 | int num) |
| 440 | { |
| 441 | struct dvb_usb_device *d = i2c_get_adapdata(adap); |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 442 | int i; |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 443 | |
| 444 | if (!d) |
| 445 | return -ENODEV; |
| 446 | if (mutex_lock_interruptible(&d->i2c_mutex) < 0) |
| 447 | return -EAGAIN; |
| 448 | |
| 449 | switch (num) { |
| 450 | case 2: { |
| 451 | /* read */ |
| 452 | /* first write first register number */ |
| 453 | u8 ibuf[msg[1].len + 2], obuf[3]; |
| 454 | obuf[0] = msg[0].addr << 1; |
| 455 | obuf[1] = msg[0].len; |
| 456 | obuf[2] = msg[0].buf[0]; |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 457 | dw210x_op_rw(d->udev, 0xc2, 0, 0, |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 458 | obuf, msg[0].len + 2, DW210X_WRITE_MSG); |
| 459 | /* second read registers */ |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 460 | dw210x_op_rw(d->udev, 0xc3, 0x19 , 0, |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 461 | ibuf, msg[1].len + 2, DW210X_READ_MSG); |
| 462 | memcpy(msg[1].buf, ibuf + 2, msg[1].len); |
| 463 | |
| 464 | break; |
| 465 | } |
| 466 | case 1: |
| 467 | switch (msg[0].addr) { |
| 468 | case 0x60: |
| 469 | case 0x0c: { |
| 470 | /* write to register */ |
| 471 | u8 obuf[msg[0].len + 2]; |
| 472 | obuf[0] = msg[0].addr << 1; |
| 473 | obuf[1] = msg[0].len; |
| 474 | memcpy(obuf + 2, msg[0].buf, msg[0].len); |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 475 | dw210x_op_rw(d->udev, 0xc2, 0, 0, |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 476 | obuf, msg[0].len + 2, DW210X_WRITE_MSG); |
| 477 | break; |
| 478 | } |
| 479 | case(DW2102_RC_QUERY): { |
| 480 | u8 ibuf[2]; |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 481 | dw210x_op_rw(d->udev, 0xb8, 0, 0, |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 482 | ibuf, 2, DW210X_READ_MSG); |
| 483 | memcpy(msg[0].buf, ibuf , 2); |
| 484 | break; |
| 485 | } |
| 486 | } |
| 487 | |
| 488 | break; |
| 489 | } |
| 490 | |
| 491 | for (i = 0; i < num; i++) { |
| 492 | deb_xfer("%02x:%02x: %s ", i, msg[i].addr, |
| 493 | msg[i].flags == 0 ? ">>>" : "<<<"); |
| 494 | debug_dump(msg[i].buf, msg[i].len, deb_xfer); |
| 495 | } |
| 496 | |
| 497 | mutex_unlock(&d->i2c_mutex); |
| 498 | return num; |
| 499 | } |
| 500 | |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 501 | static int s6x0_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 502 | int num) |
| 503 | { |
| 504 | struct dvb_usb_device *d = i2c_get_adapdata(adap); |
Julia Lawall | 21ead03 | 2009-12-22 18:00:07 -0300 | [diff] [blame] | 505 | struct usb_device *udev; |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 506 | int len, i, j; |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 507 | |
| 508 | if (!d) |
| 509 | return -ENODEV; |
Julia Lawall | 21ead03 | 2009-12-22 18:00:07 -0300 | [diff] [blame] | 510 | udev = d->udev; |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 511 | if (mutex_lock_interruptible(&d->i2c_mutex) < 0) |
| 512 | return -EAGAIN; |
| 513 | |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 514 | for (j = 0; j < num; j++) { |
| 515 | switch (msg[j].addr) { |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 516 | case (DW2102_RC_QUERY): { |
Igor M. Liplianin | 5a530cb | 2011-02-25 18:41:23 -0300 | [diff] [blame] | 517 | u8 ibuf[5]; |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 518 | dw210x_op_rw(d->udev, 0xb8, 0, 0, |
Igor M. Liplianin | 5a530cb | 2011-02-25 18:41:23 -0300 | [diff] [blame] | 519 | ibuf, 5, DW210X_READ_MSG); |
| 520 | memcpy(msg[j].buf, ibuf + 3, 2); |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 521 | break; |
| 522 | } |
| 523 | case (DW2102_VOLTAGE_CTRL): { |
| 524 | u8 obuf[2]; |
Igor M. Liplianin | cd79d33 | 2009-12-14 20:24:56 -0300 | [diff] [blame] | 525 | |
| 526 | obuf[0] = 1; |
| 527 | obuf[1] = msg[j].buf[1];/* off-on */ |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 528 | dw210x_op_rw(d->udev, 0x8a, 0, 0, |
Igor M. Liplianin | cd79d33 | 2009-12-14 20:24:56 -0300 | [diff] [blame] | 529 | obuf, 2, DW210X_WRITE_MSG); |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 530 | obuf[0] = 3; |
Igor M. Liplianin | cd79d33 | 2009-12-14 20:24:56 -0300 | [diff] [blame] | 531 | obuf[1] = msg[j].buf[0];/* 13v-18v */ |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 532 | dw210x_op_rw(d->udev, 0x8a, 0, 0, |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 533 | obuf, 2, DW210X_WRITE_MSG); |
| 534 | break; |
| 535 | } |
Igor M. Liplianin | fa8bae1 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 536 | case (DW2102_LED_CTRL): { |
| 537 | u8 obuf[2]; |
| 538 | |
| 539 | obuf[0] = 5; |
| 540 | obuf[1] = msg[j].buf[0]; |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 541 | dw210x_op_rw(d->udev, 0x8a, 0, 0, |
Igor M. Liplianin | fa8bae1 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 542 | obuf, 2, DW210X_WRITE_MSG); |
| 543 | break; |
| 544 | } |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 545 | /*case 0x55: cx24116 |
| 546 | case 0x6a: stv0903 |
| 547 | case 0x68: ds3000, stv0903 |
| 548 | case 0x60: ts2020, stv6110, stb6100 |
| 549 | case 0xa0: eeprom */ |
| 550 | default: { |
| 551 | if (msg[j].flags == I2C_M_RD) { |
| 552 | /* read registers */ |
| 553 | u8 ibuf[msg[j].len]; |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 554 | dw210x_op_rw(d->udev, 0x91, 0, 0, |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 555 | ibuf, msg[j].len, |
| 556 | DW210X_READ_MSG); |
| 557 | memcpy(msg[j].buf, ibuf, msg[j].len); |
| 558 | break; |
| 559 | } else if ((msg[j].buf[0] == 0xb0) && |
| 560 | (msg[j].addr == 0x68)) { |
| 561 | /* write firmware */ |
| 562 | u8 obuf[19]; |
| 563 | obuf[0] = (msg[j].len > 16 ? |
| 564 | 18 : msg[j].len + 1); |
| 565 | obuf[1] = msg[j].addr << 1; |
| 566 | obuf[2] = msg[j].buf[0]; |
| 567 | len = msg[j].len - 1; |
| 568 | i = 1; |
| 569 | do { |
| 570 | memcpy(obuf + 3, msg[j].buf + i, |
| 571 | (len > 16 ? 16 : len)); |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 572 | dw210x_op_rw(d->udev, 0x80, 0, 0, |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 573 | obuf, (len > 16 ? 16 : len) + 3, |
| 574 | DW210X_WRITE_MSG); |
| 575 | i += 16; |
| 576 | len -= 16; |
| 577 | } while (len > 0); |
Igor M. Liplianin | a84adf4 | 2011-02-27 16:18:38 -0300 | [diff] [blame] | 578 | } else if (j < (num - 1)) { |
Igor M. Liplianin | cd79d33 | 2009-12-14 20:24:56 -0300 | [diff] [blame] | 579 | /* write register addr before read */ |
| 580 | u8 obuf[msg[j].len + 2]; |
| 581 | obuf[0] = msg[j + 1].len; |
| 582 | obuf[1] = (msg[j].addr << 1); |
| 583 | memcpy(obuf + 2, msg[j].buf, msg[j].len); |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 584 | dw210x_op_rw(d->udev, |
Igor M. Liplianin | a84adf4 | 2011-02-27 16:18:38 -0300 | [diff] [blame] | 585 | udev->descriptor.idProduct == |
| 586 | 0x7500 ? 0x92 : 0x90, 0, 0, |
Igor M. Liplianin | cd79d33 | 2009-12-14 20:24:56 -0300 | [diff] [blame] | 587 | obuf, msg[j].len + 2, |
| 588 | DW210X_WRITE_MSG); |
| 589 | break; |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 590 | } else { |
| 591 | /* write registers */ |
| 592 | u8 obuf[msg[j].len + 2]; |
| 593 | obuf[0] = msg[j].len + 1; |
| 594 | obuf[1] = (msg[j].addr << 1); |
| 595 | memcpy(obuf + 2, msg[j].buf, msg[j].len); |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 596 | dw210x_op_rw(d->udev, 0x80, 0, 0, |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 597 | obuf, msg[j].len + 2, |
| 598 | DW210X_WRITE_MSG); |
| 599 | break; |
| 600 | } |
| 601 | break; |
| 602 | } |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 603 | } |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 604 | } |
| 605 | |
| 606 | mutex_unlock(&d->i2c_mutex); |
| 607 | return num; |
| 608 | } |
| 609 | |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 610 | static int su3000_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], |
| 611 | int num) |
| 612 | { |
| 613 | struct dvb_usb_device *d = i2c_get_adapdata(adap); |
| 614 | u8 obuf[0x40], ibuf[0x40]; |
| 615 | |
| 616 | if (!d) |
| 617 | return -ENODEV; |
| 618 | if (mutex_lock_interruptible(&d->i2c_mutex) < 0) |
| 619 | return -EAGAIN; |
| 620 | |
| 621 | switch (num) { |
| 622 | case 1: |
| 623 | switch (msg[0].addr) { |
| 624 | case SU3000_STREAM_CTRL: |
| 625 | obuf[0] = msg[0].buf[0] + 0x36; |
| 626 | obuf[1] = 3; |
| 627 | obuf[2] = 0; |
| 628 | if (dvb_usb_generic_rw(d, obuf, 3, ibuf, 0, 0) < 0) |
| 629 | err("i2c transfer failed."); |
| 630 | break; |
| 631 | case DW2102_RC_QUERY: |
| 632 | obuf[0] = 0x10; |
| 633 | if (dvb_usb_generic_rw(d, obuf, 1, ibuf, 2, 0) < 0) |
| 634 | err("i2c transfer failed."); |
| 635 | msg[0].buf[1] = ibuf[0]; |
| 636 | msg[0].buf[0] = ibuf[1]; |
| 637 | break; |
| 638 | default: |
| 639 | /* always i2c write*/ |
| 640 | obuf[0] = 0x08; |
| 641 | obuf[1] = msg[0].addr; |
| 642 | obuf[2] = msg[0].len; |
| 643 | |
| 644 | memcpy(&obuf[3], msg[0].buf, msg[0].len); |
| 645 | |
| 646 | if (dvb_usb_generic_rw(d, obuf, msg[0].len + 3, |
| 647 | ibuf, 1, 0) < 0) |
| 648 | err("i2c transfer failed."); |
| 649 | |
| 650 | } |
| 651 | break; |
| 652 | case 2: |
| 653 | /* always i2c read */ |
| 654 | obuf[0] = 0x09; |
| 655 | obuf[1] = msg[0].len; |
| 656 | obuf[2] = msg[1].len; |
| 657 | obuf[3] = msg[0].addr; |
| 658 | memcpy(&obuf[4], msg[0].buf, msg[0].len); |
| 659 | |
| 660 | if (dvb_usb_generic_rw(d, obuf, msg[0].len + 4, |
| 661 | ibuf, msg[1].len + 1, 0) < 0) |
| 662 | err("i2c transfer failed."); |
| 663 | |
| 664 | memcpy(msg[1].buf, &ibuf[1], msg[1].len); |
| 665 | break; |
| 666 | default: |
| 667 | warn("more than 2 i2c messages at a time is not handled yet."); |
| 668 | break; |
| 669 | } |
| 670 | mutex_unlock(&d->i2c_mutex); |
| 671 | return num; |
| 672 | } |
| 673 | |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 674 | static u32 dw210x_i2c_func(struct i2c_adapter *adapter) |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 675 | { |
| 676 | return I2C_FUNC_I2C; |
| 677 | } |
| 678 | |
| 679 | static struct i2c_algorithm dw2102_i2c_algo = { |
| 680 | .master_xfer = dw2102_i2c_transfer, |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 681 | .functionality = dw210x_i2c_func, |
| 682 | }; |
| 683 | |
| 684 | static struct i2c_algorithm dw2102_serit_i2c_algo = { |
| 685 | .master_xfer = dw2102_serit_i2c_transfer, |
| 686 | .functionality = dw210x_i2c_func, |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 687 | }; |
| 688 | |
Igor M. Liplianin | 8a4949b | 2008-10-05 09:11:21 -0300 | [diff] [blame] | 689 | static struct i2c_algorithm dw2102_earda_i2c_algo = { |
| 690 | .master_xfer = dw2102_earda_i2c_transfer, |
| 691 | .functionality = dw210x_i2c_func, |
| 692 | }; |
| 693 | |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 694 | static struct i2c_algorithm dw2104_i2c_algo = { |
| 695 | .master_xfer = dw2104_i2c_transfer, |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 696 | .functionality = dw210x_i2c_func, |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 697 | }; |
| 698 | |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 699 | static struct i2c_algorithm dw3101_i2c_algo = { |
| 700 | .master_xfer = dw3101_i2c_transfer, |
| 701 | .functionality = dw210x_i2c_func, |
| 702 | }; |
| 703 | |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 704 | static struct i2c_algorithm s6x0_i2c_algo = { |
| 705 | .master_xfer = s6x0_i2c_transfer, |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 706 | .functionality = dw210x_i2c_func, |
| 707 | }; |
| 708 | |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 709 | static struct i2c_algorithm su3000_i2c_algo = { |
| 710 | .master_xfer = su3000_i2c_transfer, |
| 711 | .functionality = dw210x_i2c_func, |
| 712 | }; |
| 713 | |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 714 | static int dw210x_read_mac_address(struct dvb_usb_device *d, u8 mac[6]) |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 715 | { |
| 716 | int i; |
| 717 | u8 ibuf[] = {0, 0}; |
| 718 | u8 eeprom[256], eepromline[16]; |
| 719 | |
| 720 | for (i = 0; i < 256; i++) { |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 721 | if (dw210x_op_rw(d->udev, 0xb6, 0xa0 , i, ibuf, 2, DW210X_READ_MSG) < 0) { |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 722 | err("read eeprom failed."); |
| 723 | return -1; |
| 724 | } else { |
| 725 | eepromline[i%16] = ibuf[0]; |
| 726 | eeprom[i] = ibuf[0]; |
| 727 | } |
| 728 | if ((i % 16) == 15) { |
| 729 | deb_xfer("%02x: ", i - 15); |
| 730 | debug_dump(eepromline, 16, deb_xfer); |
| 731 | } |
| 732 | } |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 733 | |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 734 | memcpy(mac, eeprom + 8, 6); |
| 735 | return 0; |
| 736 | }; |
| 737 | |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 738 | static int s6x0_read_mac_address(struct dvb_usb_device *d, u8 mac[6]) |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 739 | { |
| 740 | int i, ret; |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 741 | u8 ibuf[] = { 0 }, obuf[] = { 0 }; |
| 742 | u8 eeprom[256], eepromline[16]; |
| 743 | struct i2c_msg msg[] = { |
| 744 | { |
| 745 | .addr = 0xa0 >> 1, |
| 746 | .flags = 0, |
| 747 | .buf = obuf, |
| 748 | .len = 1, |
| 749 | }, { |
| 750 | .addr = 0xa0 >> 1, |
| 751 | .flags = I2C_M_RD, |
| 752 | .buf = ibuf, |
| 753 | .len = 1, |
| 754 | } |
| 755 | }; |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 756 | |
| 757 | for (i = 0; i < 256; i++) { |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 758 | obuf[0] = i; |
| 759 | ret = s6x0_i2c_transfer(&d->i2c_adap, msg, 2); |
| 760 | if (ret != 2) { |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 761 | err("read eeprom failed."); |
| 762 | return -1; |
| 763 | } else { |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 764 | eepromline[i % 16] = ibuf[0]; |
| 765 | eeprom[i] = ibuf[0]; |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 766 | } |
| 767 | |
| 768 | if ((i % 16) == 15) { |
| 769 | deb_xfer("%02x: ", i - 15); |
| 770 | debug_dump(eepromline, 16, deb_xfer); |
| 771 | } |
| 772 | } |
| 773 | |
| 774 | memcpy(mac, eeprom + 16, 6); |
| 775 | return 0; |
| 776 | }; |
| 777 | |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 778 | static int su3000_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff) |
| 779 | { |
| 780 | static u8 command_start[] = {0x00}; |
| 781 | static u8 command_stop[] = {0x01}; |
| 782 | struct i2c_msg msg = { |
| 783 | .addr = SU3000_STREAM_CTRL, |
| 784 | .flags = 0, |
| 785 | .buf = onoff ? command_start : command_stop, |
| 786 | .len = 1 |
| 787 | }; |
| 788 | |
| 789 | i2c_transfer(&adap->dev->i2c_adap, &msg, 1); |
| 790 | |
| 791 | return 0; |
| 792 | } |
| 793 | |
| 794 | static int su3000_power_ctrl(struct dvb_usb_device *d, int i) |
| 795 | { |
| 796 | struct su3000_state *state = (struct su3000_state *)d->priv; |
| 797 | u8 obuf[] = {0xde, 0}; |
| 798 | |
| 799 | info("%s: %d, initialized %d\n", __func__, i, state->initialized); |
| 800 | |
| 801 | if (i && !state->initialized) { |
| 802 | state->initialized = 1; |
| 803 | /* reset board */ |
| 804 | dvb_usb_generic_rw(d, obuf, 2, NULL, 0, 0); |
| 805 | } |
| 806 | |
| 807 | return 0; |
| 808 | } |
| 809 | |
| 810 | static int su3000_read_mac_address(struct dvb_usb_device *d, u8 mac[6]) |
| 811 | { |
| 812 | int i; |
| 813 | u8 obuf[] = { 0x1f, 0xf0 }; |
| 814 | u8 ibuf[] = { 0 }; |
| 815 | struct i2c_msg msg[] = { |
| 816 | { |
| 817 | .addr = 0x51, |
| 818 | .flags = 0, |
| 819 | .buf = obuf, |
| 820 | .len = 2, |
| 821 | }, { |
| 822 | .addr = 0x51, |
| 823 | .flags = I2C_M_RD, |
| 824 | .buf = ibuf, |
| 825 | .len = 1, |
| 826 | |
| 827 | } |
| 828 | }; |
| 829 | |
| 830 | for (i = 0; i < 6; i++) { |
| 831 | obuf[1] = 0xf0 + i; |
| 832 | if (i2c_transfer(&d->i2c_adap, msg, 2) != 2) |
| 833 | break; |
| 834 | else |
| 835 | mac[i] = ibuf[0]; |
| 836 | |
| 837 | debug_dump(mac, 6, printk); |
| 838 | } |
| 839 | |
| 840 | return 0; |
| 841 | } |
| 842 | |
| 843 | static int su3000_identify_state(struct usb_device *udev, |
| 844 | struct dvb_usb_device_properties *props, |
| 845 | struct dvb_usb_device_description **desc, |
| 846 | int *cold) |
| 847 | { |
| 848 | info("%s\n", __func__); |
| 849 | |
| 850 | *cold = 0; |
| 851 | return 0; |
| 852 | } |
| 853 | |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 854 | static int dw210x_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage) |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 855 | { |
Igor M. Liplianin | cd79d33 | 2009-12-14 20:24:56 -0300 | [diff] [blame] | 856 | static u8 command_13v[] = {0x00, 0x01}; |
| 857 | static u8 command_18v[] = {0x01, 0x01}; |
| 858 | static u8 command_off[] = {0x00, 0x00}; |
| 859 | struct i2c_msg msg = { |
| 860 | .addr = DW2102_VOLTAGE_CTRL, |
| 861 | .flags = 0, |
| 862 | .buf = command_off, |
| 863 | .len = 2, |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 864 | }; |
| 865 | |
| 866 | struct dvb_usb_adapter *udev_adap = |
| 867 | (struct dvb_usb_adapter *)(fe->dvb->priv); |
| 868 | if (voltage == SEC_VOLTAGE_18) |
Igor M. Liplianin | cd79d33 | 2009-12-14 20:24:56 -0300 | [diff] [blame] | 869 | msg.buf = command_18v; |
| 870 | else if (voltage == SEC_VOLTAGE_13) |
| 871 | msg.buf = command_13v; |
| 872 | |
| 873 | i2c_transfer(&udev_adap->dev->i2c_adap, &msg, 1); |
| 874 | |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 875 | return 0; |
| 876 | } |
| 877 | |
Igor M. Liplianin | 52c506e | 2011-02-25 18:41:23 -0300 | [diff] [blame] | 878 | static int s660_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage) |
| 879 | { |
| 880 | struct dvb_usb_adapter *d = |
| 881 | (struct dvb_usb_adapter *)(fe->dvb->priv); |
| 882 | struct s6x0_state *st = (struct s6x0_state *)d->dev->priv; |
| 883 | |
| 884 | dw210x_set_voltage(fe, voltage); |
| 885 | if (st->old_set_voltage) |
| 886 | st->old_set_voltage(fe, voltage); |
| 887 | |
| 888 | return 0; |
| 889 | } |
| 890 | |
Igor M. Liplianin | fa8bae1 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 891 | static void dw210x_led_ctrl(struct dvb_frontend *fe, int offon) |
| 892 | { |
| 893 | static u8 led_off[] = { 0 }; |
| 894 | static u8 led_on[] = { 1 }; |
| 895 | struct i2c_msg msg = { |
| 896 | .addr = DW2102_LED_CTRL, |
| 897 | .flags = 0, |
| 898 | .buf = led_off, |
| 899 | .len = 1 |
| 900 | }; |
| 901 | struct dvb_usb_adapter *udev_adap = |
| 902 | (struct dvb_usb_adapter *)(fe->dvb->priv); |
| 903 | |
| 904 | if (offon) |
| 905 | msg.buf = led_on; |
| 906 | i2c_transfer(&udev_adap->dev->i2c_adap, &msg, 1); |
| 907 | } |
| 908 | |
Igor M. Liplianin | d4305c6 | 2008-10-17 13:45:55 -0300 | [diff] [blame] | 909 | static struct stv0299_config sharp_z0194a_config = { |
| 910 | .demod_address = 0x68, |
| 911 | .inittab = sharp_z0194a_inittab, |
| 912 | .mclk = 88000000UL, |
| 913 | .invert = 1, |
| 914 | .skip_reinit = 0, |
| 915 | .lock_output = STV0299_LOCKOUTPUT_1, |
| 916 | .volt13_op0_op1 = STV0299_VOLT13_OP1, |
| 917 | .min_delay_ms = 100, |
| 918 | .set_symbol_rate = sharp_z0194a_set_symbol_rate, |
| 919 | }; |
| 920 | |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 921 | static struct cx24116_config dw2104_config = { |
| 922 | .demod_address = 0x55, |
Igor M. Liplianin | cc8c4f3 | 2008-09-09 13:57:47 -0300 | [diff] [blame] | 923 | .mpg_clk_pos_pol = 0x01, |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 924 | }; |
| 925 | |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 926 | static struct si21xx_config serit_sp1511lhb_config = { |
| 927 | .demod_address = 0x68, |
| 928 | .min_delay_ms = 100, |
| 929 | |
| 930 | }; |
| 931 | |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 932 | static struct tda10023_config dw3101_tda10023_config = { |
| 933 | .demod_address = 0x0c, |
| 934 | .invert = 1, |
| 935 | }; |
| 936 | |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 937 | static struct mt312_config zl313_config = { |
| 938 | .demod_address = 0x0e, |
| 939 | }; |
| 940 | |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 941 | static struct ds3000_config dw2104_ds3000_config = { |
| 942 | .demod_address = 0x68, |
| 943 | }; |
| 944 | |
Konstantin Dimitrov | 73f0af4 | 2012-12-23 19:25:38 -0300 | [diff] [blame^] | 945 | static struct ts2020_config dw2104_ts2020_config = { |
| 946 | .tuner_address = 0x60, |
| 947 | }; |
| 948 | |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 949 | static struct stv0900_config dw2104a_stv0900_config = { |
| 950 | .demod_address = 0x6a, |
| 951 | .demod_mode = 0, |
| 952 | .xtal = 27000000, |
| 953 | .clkmode = 3,/* 0-CLKI, 2-XTALI, else AUTO */ |
| 954 | .diseqc_mode = 2,/* 2/3 PWM */ |
| 955 | .tun1_maddress = 0,/* 0x60 */ |
| 956 | .tun1_adc = 0,/* 2 Vpp */ |
| 957 | .path1_mode = 3, |
| 958 | }; |
| 959 | |
| 960 | static struct stb6100_config dw2104a_stb6100_config = { |
| 961 | .tuner_address = 0x60, |
| 962 | .refclock = 27000000, |
| 963 | }; |
| 964 | |
| 965 | static struct stv0900_config dw2104_stv0900_config = { |
| 966 | .demod_address = 0x68, |
| 967 | .demod_mode = 0, |
| 968 | .xtal = 8000000, |
| 969 | .clkmode = 3, |
| 970 | .diseqc_mode = 2, |
| 971 | .tun1_maddress = 0, |
| 972 | .tun1_adc = 1,/* 1 Vpp */ |
| 973 | .path1_mode = 3, |
| 974 | }; |
| 975 | |
| 976 | static struct stv6110_config dw2104_stv6110_config = { |
| 977 | .i2c_address = 0x60, |
| 978 | .mclk = 16000000, |
| 979 | .clk_div = 1, |
| 980 | }; |
| 981 | |
Igor M. Liplianin | cd79d33 | 2009-12-14 20:24:56 -0300 | [diff] [blame] | 982 | static struct stv0900_config prof_7500_stv0900_config = { |
| 983 | .demod_address = 0x6a, |
| 984 | .demod_mode = 0, |
| 985 | .xtal = 27000000, |
| 986 | .clkmode = 3,/* 0-CLKI, 2-XTALI, else AUTO */ |
| 987 | .diseqc_mode = 2,/* 2/3 PWM */ |
| 988 | .tun1_maddress = 0,/* 0x60 */ |
| 989 | .tun1_adc = 0,/* 2 Vpp */ |
| 990 | .path1_mode = 3, |
| 991 | .tun1_type = 3, |
Igor M. Liplianin | fa8bae1 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 992 | .set_lock_led = dw210x_led_ctrl, |
Igor M. Liplianin | cd79d33 | 2009-12-14 20:24:56 -0300 | [diff] [blame] | 993 | }; |
| 994 | |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 995 | static struct ds3000_config su3000_ds3000_config = { |
| 996 | .demod_address = 0x68, |
| 997 | .ci_mode = 1, |
| 998 | }; |
| 999 | |
Konstantin Dimitrov | 73f0af4 | 2012-12-23 19:25:38 -0300 | [diff] [blame^] | 1000 | static struct ts2020_config su3000_ts2020_config = { |
| 1001 | .tuner_address = 0x60, |
| 1002 | }; |
| 1003 | |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 1004 | static int dw2104_frontend_attach(struct dvb_usb_adapter *d) |
| 1005 | { |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 1006 | struct dvb_tuner_ops *tuner_ops = NULL; |
| 1007 | |
| 1008 | if (demod_probe & 4) { |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1009 | d->fe_adap[0].fe = dvb_attach(stv0900_attach, &dw2104a_stv0900_config, |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 1010 | &d->dev->i2c_adap, 0); |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1011 | if (d->fe_adap[0].fe != NULL) { |
| 1012 | if (dvb_attach(stb6100_attach, d->fe_adap[0].fe, |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 1013 | &dw2104a_stb6100_config, |
| 1014 | &d->dev->i2c_adap)) { |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1015 | tuner_ops = &d->fe_adap[0].fe->ops.tuner_ops; |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 1016 | tuner_ops->set_frequency = stb6100_set_freq; |
| 1017 | tuner_ops->get_frequency = stb6100_get_freq; |
| 1018 | tuner_ops->set_bandwidth = stb6100_set_bandw; |
| 1019 | tuner_ops->get_bandwidth = stb6100_get_bandw; |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1020 | d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage; |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 1021 | info("Attached STV0900+STB6100!\n"); |
| 1022 | return 0; |
| 1023 | } |
| 1024 | } |
| 1025 | } |
| 1026 | |
| 1027 | if (demod_probe & 2) { |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1028 | d->fe_adap[0].fe = dvb_attach(stv0900_attach, &dw2104_stv0900_config, |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 1029 | &d->dev->i2c_adap, 0); |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1030 | if (d->fe_adap[0].fe != NULL) { |
| 1031 | if (dvb_attach(stv6110_attach, d->fe_adap[0].fe, |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 1032 | &dw2104_stv6110_config, |
| 1033 | &d->dev->i2c_adap)) { |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1034 | d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage; |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 1035 | info("Attached STV0900+STV6110A!\n"); |
| 1036 | return 0; |
| 1037 | } |
| 1038 | } |
| 1039 | } |
| 1040 | |
| 1041 | if (demod_probe & 1) { |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1042 | d->fe_adap[0].fe = dvb_attach(cx24116_attach, &dw2104_config, |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 1043 | &d->dev->i2c_adap); |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1044 | if (d->fe_adap[0].fe != NULL) { |
| 1045 | d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage; |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 1046 | info("Attached cx24116!\n"); |
| 1047 | return 0; |
| 1048 | } |
| 1049 | } |
| 1050 | |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1051 | d->fe_adap[0].fe = dvb_attach(ds3000_attach, &dw2104_ds3000_config, |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 1052 | &d->dev->i2c_adap); |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1053 | if (d->fe_adap[0].fe != NULL) { |
Konstantin Dimitrov | 73f0af4 | 2012-12-23 19:25:38 -0300 | [diff] [blame^] | 1054 | dvb_attach(ts2020_attach, d->fe_adap[0].fe, |
| 1055 | &dw2104_ts2020_config, &d->dev->i2c_adap); |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1056 | d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage; |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 1057 | info("Attached DS3000!\n"); |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 1058 | return 0; |
| 1059 | } |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 1060 | |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 1061 | return -EIO; |
| 1062 | } |
| 1063 | |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 1064 | static struct dvb_usb_device_properties dw2102_properties; |
Igor M. Liplianin | b42e1d7 | 2009-06-14 19:41:22 -0300 | [diff] [blame] | 1065 | static struct dvb_usb_device_properties dw2104_properties; |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 1066 | static struct dvb_usb_device_properties s6x0_properties; |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 1067 | |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1068 | static int dw2102_frontend_attach(struct dvb_usb_adapter *d) |
| 1069 | { |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 1070 | if (dw2102_properties.i2c_algo == &dw2102_serit_i2c_algo) { |
| 1071 | /*dw2102_properties.adapter->tuner_attach = NULL;*/ |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1072 | d->fe_adap[0].fe = dvb_attach(si21xx_attach, &serit_sp1511lhb_config, |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 1073 | &d->dev->i2c_adap); |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1074 | if (d->fe_adap[0].fe != NULL) { |
| 1075 | d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage; |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 1076 | info("Attached si21xx!\n"); |
| 1077 | return 0; |
| 1078 | } |
| 1079 | } |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 1080 | |
Igor M. Liplianin | 8a4949b | 2008-10-05 09:11:21 -0300 | [diff] [blame] | 1081 | if (dw2102_properties.i2c_algo == &dw2102_earda_i2c_algo) { |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1082 | d->fe_adap[0].fe = dvb_attach(stv0288_attach, &earda_config, |
Igor M. Liplianin | 8a4949b | 2008-10-05 09:11:21 -0300 | [diff] [blame] | 1083 | &d->dev->i2c_adap); |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1084 | if (d->fe_adap[0].fe != NULL) { |
| 1085 | if (dvb_attach(stb6000_attach, d->fe_adap[0].fe, 0x61, |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 1086 | &d->dev->i2c_adap)) { |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1087 | d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage; |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 1088 | info("Attached stv0288!\n"); |
| 1089 | return 0; |
| 1090 | } |
Igor M. Liplianin | 8a4949b | 2008-10-05 09:11:21 -0300 | [diff] [blame] | 1091 | } |
| 1092 | } |
| 1093 | |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 1094 | if (dw2102_properties.i2c_algo == &dw2102_i2c_algo) { |
| 1095 | /*dw2102_properties.adapter->tuner_attach = dw2102_tuner_attach;*/ |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1096 | d->fe_adap[0].fe = dvb_attach(stv0299_attach, &sharp_z0194a_config, |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 1097 | &d->dev->i2c_adap); |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1098 | if (d->fe_adap[0].fe != NULL) { |
| 1099 | d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage; |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 1100 | info("Attached stv0299!\n"); |
| 1101 | return 0; |
| 1102 | } |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1103 | } |
| 1104 | return -EIO; |
| 1105 | } |
| 1106 | |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 1107 | static int dw3101_frontend_attach(struct dvb_usb_adapter *d) |
| 1108 | { |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1109 | d->fe_adap[0].fe = dvb_attach(tda10023_attach, &dw3101_tda10023_config, |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 1110 | &d->dev->i2c_adap, 0x48); |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1111 | if (d->fe_adap[0].fe != NULL) { |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 1112 | info("Attached tda10023!\n"); |
| 1113 | return 0; |
| 1114 | } |
| 1115 | return -EIO; |
| 1116 | } |
| 1117 | |
Igor M. Liplianin | 195288d | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 1118 | static int zl100313_frontend_attach(struct dvb_usb_adapter *d) |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 1119 | { |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1120 | d->fe_adap[0].fe = dvb_attach(mt312_attach, &zl313_config, |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 1121 | &d->dev->i2c_adap); |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1122 | if (d->fe_adap[0].fe != NULL) { |
| 1123 | if (dvb_attach(zl10039_attach, d->fe_adap[0].fe, 0x60, |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 1124 | &d->dev->i2c_adap)) { |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1125 | d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage; |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 1126 | info("Attached zl100313+zl10039!\n"); |
| 1127 | return 0; |
| 1128 | } |
| 1129 | } |
| 1130 | |
Igor M. Liplianin | 195288d | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 1131 | return -EIO; |
| 1132 | } |
| 1133 | |
| 1134 | static int stv0288_frontend_attach(struct dvb_usb_adapter *d) |
| 1135 | { |
Igor M. Liplianin | fd5466d | 2011-02-27 16:22:52 -0300 | [diff] [blame] | 1136 | u8 obuf[] = {7, 1}; |
| 1137 | |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1138 | d->fe_adap[0].fe = dvb_attach(stv0288_attach, &earda_config, |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 1139 | &d->dev->i2c_adap); |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 1140 | |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1141 | if (d->fe_adap[0].fe == NULL) |
Igor M. Liplianin | fd5466d | 2011-02-27 16:22:52 -0300 | [diff] [blame] | 1142 | return -EIO; |
| 1143 | |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1144 | if (NULL == dvb_attach(stb6000_attach, d->fe_adap[0].fe, 0x61, &d->dev->i2c_adap)) |
Igor M. Liplianin | fd5466d | 2011-02-27 16:22:52 -0300 | [diff] [blame] | 1145 | return -EIO; |
| 1146 | |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1147 | d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage; |
Igor M. Liplianin | fd5466d | 2011-02-27 16:22:52 -0300 | [diff] [blame] | 1148 | |
| 1149 | dw210x_op_rw(d->dev->udev, 0x8a, 0, 0, obuf, 2, DW210X_WRITE_MSG); |
| 1150 | |
| 1151 | info("Attached stv0288+stb6000!\n"); |
| 1152 | |
| 1153 | return 0; |
| 1154 | |
Igor M. Liplianin | 195288d | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 1155 | } |
| 1156 | |
| 1157 | static int ds3000_frontend_attach(struct dvb_usb_adapter *d) |
| 1158 | { |
Igor M. Liplianin | 52c506e | 2011-02-25 18:41:23 -0300 | [diff] [blame] | 1159 | struct s6x0_state *st = (struct s6x0_state *)d->dev->priv; |
Igor M. Liplianin | 5a530cb | 2011-02-25 18:41:23 -0300 | [diff] [blame] | 1160 | u8 obuf[] = {7, 1}; |
Igor M. Liplianin | 52c506e | 2011-02-25 18:41:23 -0300 | [diff] [blame] | 1161 | |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1162 | d->fe_adap[0].fe = dvb_attach(ds3000_attach, &dw2104_ds3000_config, |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 1163 | &d->dev->i2c_adap); |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 1164 | |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1165 | if (d->fe_adap[0].fe == NULL) |
Igor M. Liplianin | 52c506e | 2011-02-25 18:41:23 -0300 | [diff] [blame] | 1166 | return -EIO; |
| 1167 | |
Konstantin Dimitrov | 73f0af4 | 2012-12-23 19:25:38 -0300 | [diff] [blame^] | 1168 | dvb_attach(ts2020_attach, d->fe_adap[0].fe, &dw2104_ts2020_config, |
| 1169 | &d->dev->i2c_adap); |
| 1170 | |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1171 | st->old_set_voltage = d->fe_adap[0].fe->ops.set_voltage; |
| 1172 | d->fe_adap[0].fe->ops.set_voltage = s660_set_voltage; |
Igor M. Liplianin | 5a530cb | 2011-02-25 18:41:23 -0300 | [diff] [blame] | 1173 | |
| 1174 | dw210x_op_rw(d->dev->udev, 0x8a, 0, 0, obuf, 2, DW210X_WRITE_MSG); |
| 1175 | |
Igor M. Liplianin | 52c506e | 2011-02-25 18:41:23 -0300 | [diff] [blame] | 1176 | info("Attached ds3000+ds2020!\n"); |
| 1177 | |
| 1178 | return 0; |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 1179 | } |
| 1180 | |
Igor M. Liplianin | cd79d33 | 2009-12-14 20:24:56 -0300 | [diff] [blame] | 1181 | static int prof_7500_frontend_attach(struct dvb_usb_adapter *d) |
| 1182 | { |
Igor M. Liplianin | 4e59df8 | 2011-02-25 18:41:23 -0300 | [diff] [blame] | 1183 | u8 obuf[] = {7, 1}; |
| 1184 | |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1185 | d->fe_adap[0].fe = dvb_attach(stv0900_attach, &prof_7500_stv0900_config, |
Igor M. Liplianin | cd79d33 | 2009-12-14 20:24:56 -0300 | [diff] [blame] | 1186 | &d->dev->i2c_adap, 0); |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1187 | if (d->fe_adap[0].fe == NULL) |
Igor M. Liplianin | cd79d33 | 2009-12-14 20:24:56 -0300 | [diff] [blame] | 1188 | return -EIO; |
Igor M. Liplianin | 4e59df8 | 2011-02-25 18:41:23 -0300 | [diff] [blame] | 1189 | |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1190 | d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage; |
Igor M. Liplianin | cd79d33 | 2009-12-14 20:24:56 -0300 | [diff] [blame] | 1191 | |
Igor M. Liplianin | 4e59df8 | 2011-02-25 18:41:23 -0300 | [diff] [blame] | 1192 | dw210x_op_rw(d->dev->udev, 0x8a, 0, 0, obuf, 2, DW210X_WRITE_MSG); |
| 1193 | |
Igor M. Liplianin | cd79d33 | 2009-12-14 20:24:56 -0300 | [diff] [blame] | 1194 | info("Attached STV0900+STB6100A!\n"); |
| 1195 | |
| 1196 | return 0; |
| 1197 | } |
| 1198 | |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 1199 | static int su3000_frontend_attach(struct dvb_usb_adapter *d) |
| 1200 | { |
| 1201 | u8 obuf[3] = { 0xe, 0x80, 0 }; |
| 1202 | u8 ibuf[] = { 0 }; |
| 1203 | |
| 1204 | if (dvb_usb_generic_rw(d->dev, obuf, 3, ibuf, 1, 0) < 0) |
| 1205 | err("command 0x0e transfer failed."); |
| 1206 | |
| 1207 | obuf[0] = 0xe; |
| 1208 | obuf[1] = 0x83; |
| 1209 | obuf[2] = 0; |
| 1210 | |
| 1211 | if (dvb_usb_generic_rw(d->dev, obuf, 3, ibuf, 1, 0) < 0) |
| 1212 | err("command 0x0e transfer failed."); |
| 1213 | |
| 1214 | obuf[0] = 0xe; |
| 1215 | obuf[1] = 0x83; |
| 1216 | obuf[2] = 1; |
| 1217 | |
| 1218 | if (dvb_usb_generic_rw(d->dev, obuf, 3, ibuf, 1, 0) < 0) |
| 1219 | err("command 0x0e transfer failed."); |
| 1220 | |
| 1221 | obuf[0] = 0x51; |
| 1222 | |
| 1223 | if (dvb_usb_generic_rw(d->dev, obuf, 1, ibuf, 1, 0) < 0) |
| 1224 | err("command 0x51 transfer failed."); |
| 1225 | |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1226 | d->fe_adap[0].fe = dvb_attach(ds3000_attach, &su3000_ds3000_config, |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 1227 | &d->dev->i2c_adap); |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1228 | if (d->fe_adap[0].fe == NULL) |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 1229 | return -EIO; |
| 1230 | |
Konstantin Dimitrov | 73f0af4 | 2012-12-23 19:25:38 -0300 | [diff] [blame^] | 1231 | dvb_attach(ts2020_attach, d->fe_adap[0].fe, &su3000_ts2020_config, |
| 1232 | &d->dev->i2c_adap); |
| 1233 | |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 1234 | info("Attached DS3000!\n"); |
| 1235 | |
| 1236 | return 0; |
| 1237 | } |
| 1238 | |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1239 | static int dw2102_tuner_attach(struct dvb_usb_adapter *adap) |
| 1240 | { |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1241 | dvb_attach(dvb_pll_attach, adap->fe_adap[0].fe, 0x60, |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1242 | &adap->dev->i2c_adap, DVB_PLL_OPERA1); |
| 1243 | return 0; |
| 1244 | } |
| 1245 | |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 1246 | static int dw3101_tuner_attach(struct dvb_usb_adapter *adap) |
| 1247 | { |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1248 | dvb_attach(dvb_pll_attach, adap->fe_adap[0].fe, 0x60, |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 1249 | &adap->dev->i2c_adap, DVB_PLL_TUA6034); |
| 1250 | |
| 1251 | return 0; |
| 1252 | } |
| 1253 | |
Mauro Carvalho Chehab | 2f4f58d | 2010-11-17 15:46:09 -0300 | [diff] [blame] | 1254 | static struct rc_map_table rc_map_dw210x_table[] = { |
Mauro Carvalho Chehab | 991bd3c | 2011-01-24 12:18:40 -0300 | [diff] [blame] | 1255 | { 0xf80a, KEY_POWER2 }, /*power*/ |
| 1256 | { 0xf80c, KEY_MUTE }, /*mute*/ |
Mauro Carvalho Chehab | 2e36588 | 2009-08-29 15:19:31 -0300 | [diff] [blame] | 1257 | { 0xf811, KEY_1 }, |
| 1258 | { 0xf812, KEY_2 }, |
| 1259 | { 0xf813, KEY_3 }, |
| 1260 | { 0xf814, KEY_4 }, |
| 1261 | { 0xf815, KEY_5 }, |
| 1262 | { 0xf816, KEY_6 }, |
| 1263 | { 0xf817, KEY_7 }, |
| 1264 | { 0xf818, KEY_8 }, |
| 1265 | { 0xf819, KEY_9 }, |
| 1266 | { 0xf810, KEY_0 }, |
Mauro Carvalho Chehab | 991bd3c | 2011-01-24 12:18:40 -0300 | [diff] [blame] | 1267 | { 0xf81c, KEY_CHANNELUP }, /*ch+*/ |
| 1268 | { 0xf80f, KEY_CHANNELDOWN }, /*ch-*/ |
| 1269 | { 0xf81a, KEY_VOLUMEUP }, /*vol+*/ |
| 1270 | { 0xf80e, KEY_VOLUMEDOWN }, /*vol-*/ |
| 1271 | { 0xf804, KEY_RECORD }, /*rec*/ |
| 1272 | { 0xf809, KEY_FAVORITES }, /*fav*/ |
| 1273 | { 0xf808, KEY_REWIND }, /*rewind*/ |
| 1274 | { 0xf807, KEY_FASTFORWARD }, /*fast*/ |
| 1275 | { 0xf80b, KEY_PAUSE }, /*pause*/ |
| 1276 | { 0xf802, KEY_ESC }, /*cancel*/ |
| 1277 | { 0xf803, KEY_TAB }, /*tab*/ |
Mauro Carvalho Chehab | 2e36588 | 2009-08-29 15:19:31 -0300 | [diff] [blame] | 1278 | { 0xf800, KEY_UP }, /*up*/ |
Mauro Carvalho Chehab | 991bd3c | 2011-01-24 12:18:40 -0300 | [diff] [blame] | 1279 | { 0xf81f, KEY_OK }, /*ok*/ |
| 1280 | { 0xf801, KEY_DOWN }, /*down*/ |
| 1281 | { 0xf805, KEY_CAMERA }, /*cap*/ |
| 1282 | { 0xf806, KEY_STOP }, /*stop*/ |
| 1283 | { 0xf840, KEY_ZOOM }, /*full*/ |
| 1284 | { 0xf81e, KEY_TV }, /*tvmode*/ |
| 1285 | { 0xf81b, KEY_LAST }, /*recall*/ |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1286 | }; |
| 1287 | |
Mauro Carvalho Chehab | 2f4f58d | 2010-11-17 15:46:09 -0300 | [diff] [blame] | 1288 | static struct rc_map_table rc_map_tevii_table[] = { |
Mauro Carvalho Chehab | 2e36588 | 2009-08-29 15:19:31 -0300 | [diff] [blame] | 1289 | { 0xf80a, KEY_POWER }, |
| 1290 | { 0xf80c, KEY_MUTE }, |
| 1291 | { 0xf811, KEY_1 }, |
| 1292 | { 0xf812, KEY_2 }, |
| 1293 | { 0xf813, KEY_3 }, |
| 1294 | { 0xf814, KEY_4 }, |
| 1295 | { 0xf815, KEY_5 }, |
| 1296 | { 0xf816, KEY_6 }, |
| 1297 | { 0xf817, KEY_7 }, |
| 1298 | { 0xf818, KEY_8 }, |
| 1299 | { 0xf819, KEY_9 }, |
| 1300 | { 0xf810, KEY_0 }, |
| 1301 | { 0xf81c, KEY_MENU }, |
| 1302 | { 0xf80f, KEY_VOLUMEDOWN }, |
| 1303 | { 0xf81a, KEY_LAST }, |
| 1304 | { 0xf80e, KEY_OPEN }, |
| 1305 | { 0xf804, KEY_RECORD }, |
| 1306 | { 0xf809, KEY_VOLUMEUP }, |
| 1307 | { 0xf808, KEY_CHANNELUP }, |
| 1308 | { 0xf807, KEY_PVR }, |
| 1309 | { 0xf80b, KEY_TIME }, |
| 1310 | { 0xf802, KEY_RIGHT }, |
| 1311 | { 0xf803, KEY_LEFT }, |
| 1312 | { 0xf800, KEY_UP }, |
| 1313 | { 0xf81f, KEY_OK }, |
| 1314 | { 0xf801, KEY_DOWN }, |
| 1315 | { 0xf805, KEY_TUNER }, |
| 1316 | { 0xf806, KEY_CHANNELDOWN }, |
| 1317 | { 0xf840, KEY_PLAYPAUSE }, |
| 1318 | { 0xf81e, KEY_REWIND }, |
| 1319 | { 0xf81b, KEY_FAVORITES }, |
| 1320 | { 0xf81d, KEY_BACK }, |
| 1321 | { 0xf84d, KEY_FASTFORWARD }, |
| 1322 | { 0xf844, KEY_EPG }, |
| 1323 | { 0xf84c, KEY_INFO }, |
| 1324 | { 0xf841, KEY_AB }, |
| 1325 | { 0xf843, KEY_AUDIO }, |
| 1326 | { 0xf845, KEY_SUBTITLE }, |
| 1327 | { 0xf84a, KEY_LIST }, |
| 1328 | { 0xf846, KEY_F1 }, |
| 1329 | { 0xf847, KEY_F2 }, |
| 1330 | { 0xf85e, KEY_F3 }, |
| 1331 | { 0xf85c, KEY_F4 }, |
| 1332 | { 0xf852, KEY_F5 }, |
| 1333 | { 0xf85a, KEY_F6 }, |
| 1334 | { 0xf856, KEY_MODE }, |
| 1335 | { 0xf858, KEY_SWITCHVIDEOMODE }, |
Igor M. Liplianin | b42e1d7 | 2009-06-14 19:41:22 -0300 | [diff] [blame] | 1336 | }; |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1337 | |
Mauro Carvalho Chehab | 2f4f58d | 2010-11-17 15:46:09 -0300 | [diff] [blame] | 1338 | static struct rc_map_table rc_map_tbs_table[] = { |
Mauro Carvalho Chehab | 2e36588 | 2009-08-29 15:19:31 -0300 | [diff] [blame] | 1339 | { 0xf884, KEY_POWER }, |
| 1340 | { 0xf894, KEY_MUTE }, |
| 1341 | { 0xf887, KEY_1 }, |
| 1342 | { 0xf886, KEY_2 }, |
| 1343 | { 0xf885, KEY_3 }, |
| 1344 | { 0xf88b, KEY_4 }, |
| 1345 | { 0xf88a, KEY_5 }, |
| 1346 | { 0xf889, KEY_6 }, |
| 1347 | { 0xf88f, KEY_7 }, |
| 1348 | { 0xf88e, KEY_8 }, |
| 1349 | { 0xf88d, KEY_9 }, |
| 1350 | { 0xf892, KEY_0 }, |
| 1351 | { 0xf896, KEY_CHANNELUP }, |
| 1352 | { 0xf891, KEY_CHANNELDOWN }, |
| 1353 | { 0xf893, KEY_VOLUMEUP }, |
| 1354 | { 0xf88c, KEY_VOLUMEDOWN }, |
| 1355 | { 0xf883, KEY_RECORD }, |
| 1356 | { 0xf898, KEY_PAUSE }, |
| 1357 | { 0xf899, KEY_OK }, |
| 1358 | { 0xf89a, KEY_SHUFFLE }, |
| 1359 | { 0xf881, KEY_UP }, |
| 1360 | { 0xf890, KEY_LEFT }, |
| 1361 | { 0xf882, KEY_RIGHT }, |
| 1362 | { 0xf888, KEY_DOWN }, |
| 1363 | { 0xf895, KEY_FAVORITES }, |
| 1364 | { 0xf897, KEY_SUBTITLE }, |
| 1365 | { 0xf89d, KEY_ZOOM }, |
| 1366 | { 0xf89f, KEY_EXIT }, |
| 1367 | { 0xf89e, KEY_MENU }, |
| 1368 | { 0xf89c, KEY_EPG }, |
| 1369 | { 0xf880, KEY_PREVIOUS }, |
| 1370 | { 0xf89b, KEY_MODE } |
Igor M. Liplianin | b42e1d7 | 2009-06-14 19:41:22 -0300 | [diff] [blame] | 1371 | }; |
| 1372 | |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 1373 | static struct rc_map_table rc_map_su3000_table[] = { |
| 1374 | { 0x25, KEY_POWER }, /* right-bottom Red */ |
| 1375 | { 0x0a, KEY_MUTE }, /* -/-- */ |
| 1376 | { 0x01, KEY_1 }, |
| 1377 | { 0x02, KEY_2 }, |
| 1378 | { 0x03, KEY_3 }, |
| 1379 | { 0x04, KEY_4 }, |
| 1380 | { 0x05, KEY_5 }, |
| 1381 | { 0x06, KEY_6 }, |
| 1382 | { 0x07, KEY_7 }, |
| 1383 | { 0x08, KEY_8 }, |
| 1384 | { 0x09, KEY_9 }, |
| 1385 | { 0x00, KEY_0 }, |
| 1386 | { 0x20, KEY_UP }, /* CH+ */ |
| 1387 | { 0x21, KEY_DOWN }, /* CH+ */ |
| 1388 | { 0x12, KEY_VOLUMEUP }, /* Brightness Up */ |
| 1389 | { 0x13, KEY_VOLUMEDOWN },/* Brightness Down */ |
| 1390 | { 0x1f, KEY_RECORD }, |
| 1391 | { 0x17, KEY_PLAY }, |
| 1392 | { 0x16, KEY_PAUSE }, |
| 1393 | { 0x0b, KEY_STOP }, |
| 1394 | { 0x27, KEY_FASTFORWARD },/* >> */ |
| 1395 | { 0x26, KEY_REWIND }, /* << */ |
| 1396 | { 0x0d, KEY_OK }, /* Mute */ |
| 1397 | { 0x11, KEY_LEFT }, /* VOL- */ |
| 1398 | { 0x10, KEY_RIGHT }, /* VOL+ */ |
| 1399 | { 0x29, KEY_BACK }, /* button under 9 */ |
| 1400 | { 0x2c, KEY_MENU }, /* TTX */ |
| 1401 | { 0x2b, KEY_EPG }, /* EPG */ |
| 1402 | { 0x1e, KEY_RED }, /* OSD */ |
| 1403 | { 0x0e, KEY_GREEN }, /* Window */ |
| 1404 | { 0x2d, KEY_YELLOW }, /* button under << */ |
| 1405 | { 0x0f, KEY_BLUE }, /* bottom yellow button */ |
| 1406 | { 0x14, KEY_AUDIO }, /* Snapshot */ |
| 1407 | { 0x38, KEY_TV }, /* TV/Radio */ |
Justin P. Mattock | 70f23fd | 2011-05-10 10:16:21 +0200 | [diff] [blame] | 1408 | { 0x0c, KEY_ESC } /* upper Red button */ |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 1409 | }; |
| 1410 | |
Mauro Carvalho Chehab | 2f4f58d | 2010-11-17 15:46:09 -0300 | [diff] [blame] | 1411 | static struct rc_map_dvb_usb_table_table keys_tables[] = { |
| 1412 | { rc_map_dw210x_table, ARRAY_SIZE(rc_map_dw210x_table) }, |
| 1413 | { rc_map_tevii_table, ARRAY_SIZE(rc_map_tevii_table) }, |
| 1414 | { rc_map_tbs_table, ARRAY_SIZE(rc_map_tbs_table) }, |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 1415 | { rc_map_su3000_table, ARRAY_SIZE(rc_map_su3000_table) }, |
Igor M. Liplianin | b42e1d7 | 2009-06-14 19:41:22 -0300 | [diff] [blame] | 1416 | }; |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1417 | |
| 1418 | static int dw2102_rc_query(struct dvb_usb_device *d, u32 *event, int *state) |
| 1419 | { |
Mauro Carvalho Chehab | 2f4f58d | 2010-11-17 15:46:09 -0300 | [diff] [blame] | 1420 | struct rc_map_table *keymap = d->props.rc.legacy.rc_map_table; |
| 1421 | int keymap_size = d->props.rc.legacy.rc_map_size; |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1422 | u8 key[2]; |
Igor M. Liplianin | 8a8dad7 | 2009-06-13 08:10:24 -0300 | [diff] [blame] | 1423 | struct i2c_msg msg = { |
| 1424 | .addr = DW2102_RC_QUERY, |
| 1425 | .flags = I2C_M_RD, |
| 1426 | .buf = key, |
| 1427 | .len = 2 |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1428 | }; |
| 1429 | int i; |
Igor M. Liplianin | b42e1d7 | 2009-06-14 19:41:22 -0300 | [diff] [blame] | 1430 | /* override keymap */ |
| 1431 | if ((ir_keymap > 0) && (ir_keymap <= ARRAY_SIZE(keys_tables))) { |
| 1432 | keymap = keys_tables[ir_keymap - 1].rc_keys ; |
| 1433 | keymap_size = keys_tables[ir_keymap - 1].rc_keys_size; |
Igor M. Liplianin | feb16e9 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 1434 | } else if (ir_keymap > ARRAY_SIZE(keys_tables)) |
| 1435 | return 0; /* none */ |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1436 | |
| 1437 | *state = REMOTE_NO_KEY_PRESSED; |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 1438 | if (d->props.i2c_algo->master_xfer(&d->i2c_adap, &msg, 1) == 1) { |
Igor M. Liplianin | b42e1d7 | 2009-06-14 19:41:22 -0300 | [diff] [blame] | 1439 | for (i = 0; i < keymap_size ; i++) { |
Mauro Carvalho Chehab | 2e36588 | 2009-08-29 15:19:31 -0300 | [diff] [blame] | 1440 | if (rc5_data(&keymap[i]) == msg.buf[0]) { |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1441 | *state = REMOTE_KEY_PRESSED; |
Mauro Carvalho Chehab | 34abf21 | 2010-07-31 11:24:57 -0300 | [diff] [blame] | 1442 | *event = keymap[i].keycode; |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1443 | break; |
| 1444 | } |
Igor M. Liplianin | 8a8dad7 | 2009-06-13 08:10:24 -0300 | [diff] [blame] | 1445 | |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1446 | } |
Igor M. Liplianin | 8a8dad7 | 2009-06-13 08:10:24 -0300 | [diff] [blame] | 1447 | |
| 1448 | if ((*state) == REMOTE_KEY_PRESSED) |
| 1449 | deb_rc("%s: found rc key: %x, %x, event: %x\n", |
| 1450 | __func__, key[0], key[1], (*event)); |
| 1451 | else if (key[0] != 0xff) |
| 1452 | deb_rc("%s: unknown rc key: %x, %x\n", |
| 1453 | __func__, key[0], key[1]); |
| 1454 | |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1455 | } |
Igor M. Liplianin | 8a8dad7 | 2009-06-13 08:10:24 -0300 | [diff] [blame] | 1456 | |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1457 | return 0; |
| 1458 | } |
| 1459 | |
Jonathan Nieder | 27351b1 | 2011-12-23 19:00:45 -0300 | [diff] [blame] | 1460 | enum dw2102_table_entry { |
| 1461 | CYPRESS_DW2102, |
| 1462 | CYPRESS_DW2101, |
| 1463 | CYPRESS_DW2104, |
| 1464 | TEVII_S650, |
| 1465 | TERRATEC_CINERGY_S, |
| 1466 | CYPRESS_DW3101, |
| 1467 | TEVII_S630, |
| 1468 | PROF_1100, |
| 1469 | TEVII_S660, |
| 1470 | PROF_7500, |
| 1471 | GENIATECH_SU3000, |
| 1472 | TERRATEC_CINERGY_S2, |
| 1473 | TEVII_S480_1, |
| 1474 | TEVII_S480_2, |
| 1475 | X3M_SPC1400HD, |
| 1476 | }; |
| 1477 | |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1478 | static struct usb_device_id dw2102_table[] = { |
Jonathan Nieder | 27351b1 | 2011-12-23 19:00:45 -0300 | [diff] [blame] | 1479 | [CYPRESS_DW2102] = {USB_DEVICE(USB_VID_CYPRESS, USB_PID_DW2102)}, |
| 1480 | [CYPRESS_DW2101] = {USB_DEVICE(USB_VID_CYPRESS, 0x2101)}, |
| 1481 | [CYPRESS_DW2104] = {USB_DEVICE(USB_VID_CYPRESS, USB_PID_DW2104)}, |
| 1482 | [TEVII_S650] = {USB_DEVICE(0x9022, USB_PID_TEVII_S650)}, |
| 1483 | [TERRATEC_CINERGY_S] = {USB_DEVICE(USB_VID_TERRATEC, USB_PID_CINERGY_S)}, |
| 1484 | [CYPRESS_DW3101] = {USB_DEVICE(USB_VID_CYPRESS, USB_PID_DW3101)}, |
| 1485 | [TEVII_S630] = {USB_DEVICE(0x9022, USB_PID_TEVII_S630)}, |
| 1486 | [PROF_1100] = {USB_DEVICE(0x3011, USB_PID_PROF_1100)}, |
| 1487 | [TEVII_S660] = {USB_DEVICE(0x9022, USB_PID_TEVII_S660)}, |
| 1488 | [PROF_7500] = {USB_DEVICE(0x3034, 0x7500)}, |
| 1489 | [GENIATECH_SU3000] = {USB_DEVICE(0x1f4d, 0x3000)}, |
| 1490 | [TERRATEC_CINERGY_S2] = {USB_DEVICE(USB_VID_TERRATEC, 0x00a8)}, |
| 1491 | [TEVII_S480_1] = {USB_DEVICE(0x9022, USB_PID_TEVII_S480_1)}, |
| 1492 | [TEVII_S480_2] = {USB_DEVICE(0x9022, USB_PID_TEVII_S480_2)}, |
| 1493 | [X3M_SPC1400HD] = {USB_DEVICE(0x1f4d, 0x3100)}, |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1494 | { } |
| 1495 | }; |
| 1496 | |
| 1497 | MODULE_DEVICE_TABLE(usb, dw2102_table); |
| 1498 | |
| 1499 | static int dw2102_load_firmware(struct usb_device *dev, |
| 1500 | const struct firmware *frmwr) |
| 1501 | { |
| 1502 | u8 *b, *p; |
| 1503 | int ret = 0, i; |
| 1504 | u8 reset; |
Igor M. Liplianin | 8a4949b | 2008-10-05 09:11:21 -0300 | [diff] [blame] | 1505 | u8 reset16[] = {0, 0, 0, 0, 0, 0, 0}; |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1506 | const struct firmware *fw; |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 1507 | |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1508 | switch (dev->descriptor.idProduct) { |
| 1509 | case 0x2101: |
Rémi Cardona | 6823627 | 2012-09-28 08:59:32 -0300 | [diff] [blame] | 1510 | ret = request_firmware(&fw, DW2101_FIRMWARE, &dev->dev); |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1511 | if (ret != 0) { |
Rémi Cardona | 6823627 | 2012-09-28 08:59:32 -0300 | [diff] [blame] | 1512 | err(err_str, DW2101_FIRMWARE); |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1513 | return ret; |
| 1514 | } |
| 1515 | break; |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 1516 | default: |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1517 | fw = frmwr; |
| 1518 | break; |
| 1519 | } |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 1520 | info("start downloading DW210X firmware"); |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1521 | p = kmalloc(fw->size, GFP_KERNEL); |
| 1522 | reset = 1; |
| 1523 | /*stop the CPU*/ |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 1524 | dw210x_op_rw(dev, 0xa0, 0x7f92, 0, &reset, 1, DW210X_WRITE_MSG); |
| 1525 | dw210x_op_rw(dev, 0xa0, 0xe600, 0, &reset, 1, DW210X_WRITE_MSG); |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1526 | |
| 1527 | if (p != NULL) { |
| 1528 | memcpy(p, fw->data, fw->size); |
| 1529 | for (i = 0; i < fw->size; i += 0x40) { |
| 1530 | b = (u8 *) p + i; |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 1531 | if (dw210x_op_rw(dev, 0xa0, i, 0, b , 0x40, |
| 1532 | DW210X_WRITE_MSG) != 0x40) { |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1533 | err("error while transferring firmware"); |
| 1534 | ret = -EINVAL; |
| 1535 | break; |
| 1536 | } |
| 1537 | } |
| 1538 | /* restart the CPU */ |
| 1539 | reset = 0; |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 1540 | if (ret || dw210x_op_rw(dev, 0xa0, 0x7f92, 0, &reset, 1, |
| 1541 | DW210X_WRITE_MSG) != 1) { |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1542 | err("could not restart the USB controller CPU."); |
| 1543 | ret = -EINVAL; |
| 1544 | } |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 1545 | if (ret || dw210x_op_rw(dev, 0xa0, 0xe600, 0, &reset, 1, |
| 1546 | DW210X_WRITE_MSG) != 1) { |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1547 | err("could not restart the USB controller CPU."); |
| 1548 | ret = -EINVAL; |
| 1549 | } |
| 1550 | /* init registers */ |
| 1551 | switch (dev->descriptor.idProduct) { |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 1552 | case USB_PID_TEVII_S650: |
Mauro Carvalho Chehab | 2f4f58d | 2010-11-17 15:46:09 -0300 | [diff] [blame] | 1553 | dw2104_properties.rc.legacy.rc_map_table = rc_map_tevii_table; |
| 1554 | dw2104_properties.rc.legacy.rc_map_size = |
| 1555 | ARRAY_SIZE(rc_map_tevii_table); |
Igor M. Liplianin | b42e1d7 | 2009-06-14 19:41:22 -0300 | [diff] [blame] | 1556 | case USB_PID_DW2104: |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 1557 | reset = 1; |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 1558 | dw210x_op_rw(dev, 0xc4, 0x0000, 0, &reset, 1, |
| 1559 | DW210X_WRITE_MSG); |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 1560 | /* break omitted intentionally */ |
| 1561 | case USB_PID_DW3101: |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 1562 | reset = 0; |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 1563 | dw210x_op_rw(dev, 0xbf, 0x0040, 0, &reset, 0, |
| 1564 | DW210X_WRITE_MSG); |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 1565 | break; |
Igor M. Liplianin | 4cc0edf | 2008-11-05 22:12:56 -0300 | [diff] [blame] | 1566 | case USB_PID_CINERGY_S: |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1567 | case USB_PID_DW2102: |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 1568 | dw210x_op_rw(dev, 0xbf, 0x0040, 0, &reset, 0, |
| 1569 | DW210X_WRITE_MSG); |
| 1570 | dw210x_op_rw(dev, 0xb9, 0x0000, 0, &reset16[0], 2, |
| 1571 | DW210X_READ_MSG); |
| 1572 | /* check STV0299 frontend */ |
| 1573 | dw210x_op_rw(dev, 0xb5, 0, 0, &reset16[0], 2, |
| 1574 | DW210X_READ_MSG); |
Igor M. Liplianin | ea023df | 2008-12-04 12:49:23 -0300 | [diff] [blame] | 1575 | if ((reset16[0] == 0xa1) || (reset16[0] == 0x80)) { |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 1576 | dw2102_properties.i2c_algo = &dw2102_i2c_algo; |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1577 | dw2102_properties.adapter->fe[0].tuner_attach = &dw2102_tuner_attach; |
Igor M. Liplianin | 8a4949b | 2008-10-05 09:11:21 -0300 | [diff] [blame] | 1578 | break; |
| 1579 | } else { |
| 1580 | /* check STV0288 frontend */ |
| 1581 | reset16[0] = 0xd0; |
| 1582 | reset16[1] = 1; |
| 1583 | reset16[2] = 0; |
| 1584 | dw210x_op_rw(dev, 0xc2, 0, 0, &reset16[0], 3, |
| 1585 | DW210X_WRITE_MSG); |
| 1586 | dw210x_op_rw(dev, 0xc3, 0xd1, 0, &reset16[0], 3, |
| 1587 | DW210X_READ_MSG); |
| 1588 | if (reset16[2] == 0x11) { |
| 1589 | dw2102_properties.i2c_algo = &dw2102_earda_i2c_algo; |
Igor M. Liplianin | 8a4949b | 2008-10-05 09:11:21 -0300 | [diff] [blame] | 1590 | break; |
| 1591 | } |
| 1592 | } |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1593 | case 0x2101: |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 1594 | dw210x_op_rw(dev, 0xbc, 0x0030, 0, &reset16[0], 2, |
| 1595 | DW210X_READ_MSG); |
| 1596 | dw210x_op_rw(dev, 0xba, 0x0000, 0, &reset16[0], 7, |
| 1597 | DW210X_READ_MSG); |
| 1598 | dw210x_op_rw(dev, 0xba, 0x0000, 0, &reset16[0], 7, |
| 1599 | DW210X_READ_MSG); |
| 1600 | dw210x_op_rw(dev, 0xb9, 0x0000, 0, &reset16[0], 2, |
| 1601 | DW210X_READ_MSG); |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1602 | break; |
| 1603 | } |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 1604 | |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 1605 | msleep(100); |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1606 | kfree(p); |
| 1607 | } |
| 1608 | return ret; |
| 1609 | } |
| 1610 | |
| 1611 | static struct dvb_usb_device_properties dw2102_properties = { |
| 1612 | .caps = DVB_USB_IS_AN_I2C_ADAPTER, |
| 1613 | .usb_ctrl = DEVICE_SPECIFIC, |
Rémi Cardona | 6823627 | 2012-09-28 08:59:32 -0300 | [diff] [blame] | 1614 | .firmware = DW2102_FIRMWARE, |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1615 | .no_reconnect = 1, |
| 1616 | |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 1617 | .i2c_algo = &dw2102_serit_i2c_algo, |
Mauro Carvalho Chehab | f72a27b | 2010-07-31 18:04:09 -0300 | [diff] [blame] | 1618 | |
| 1619 | .rc.legacy = { |
Mauro Carvalho Chehab | 2f4f58d | 2010-11-17 15:46:09 -0300 | [diff] [blame] | 1620 | .rc_map_table = rc_map_dw210x_table, |
| 1621 | .rc_map_size = ARRAY_SIZE(rc_map_dw210x_table), |
Mauro Carvalho Chehab | f72a27b | 2010-07-31 18:04:09 -0300 | [diff] [blame] | 1622 | .rc_interval = 150, |
| 1623 | .rc_query = dw2102_rc_query, |
| 1624 | }, |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1625 | |
| 1626 | .generic_bulk_ctrl_endpoint = 0x81, |
| 1627 | /* parameter for the MPEG2-data transfer */ |
| 1628 | .num_adapters = 1, |
| 1629 | .download_firmware = dw2102_load_firmware, |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 1630 | .read_mac_address = dw210x_read_mac_address, |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 1631 | .adapter = { |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1632 | { |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1633 | .num_frontends = 1, |
| 1634 | .fe = {{ |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1635 | .frontend_attach = dw2102_frontend_attach, |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1636 | .stream = { |
| 1637 | .type = USB_BULK, |
| 1638 | .count = 8, |
| 1639 | .endpoint = 0x82, |
| 1640 | .u = { |
| 1641 | .bulk = { |
| 1642 | .buffersize = 4096, |
| 1643 | } |
| 1644 | } |
| 1645 | }, |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1646 | }}, |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1647 | } |
| 1648 | }, |
Igor M. Liplianin | 4cc0edf | 2008-11-05 22:12:56 -0300 | [diff] [blame] | 1649 | .num_device_descs = 3, |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1650 | .devices = { |
| 1651 | {"DVBWorld DVB-S 2102 USB2.0", |
Jonathan Nieder | 27351b1 | 2011-12-23 19:00:45 -0300 | [diff] [blame] | 1652 | {&dw2102_table[CYPRESS_DW2102], NULL}, |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1653 | {NULL}, |
| 1654 | }, |
| 1655 | {"DVBWorld DVB-S 2101 USB2.0", |
Jonathan Nieder | 27351b1 | 2011-12-23 19:00:45 -0300 | [diff] [blame] | 1656 | {&dw2102_table[CYPRESS_DW2101], NULL}, |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1657 | {NULL}, |
| 1658 | }, |
Igor M. Liplianin | 4cc0edf | 2008-11-05 22:12:56 -0300 | [diff] [blame] | 1659 | {"TerraTec Cinergy S USB", |
Jonathan Nieder | 27351b1 | 2011-12-23 19:00:45 -0300 | [diff] [blame] | 1660 | {&dw2102_table[TERRATEC_CINERGY_S], NULL}, |
Igor M. Liplianin | 4cc0edf | 2008-11-05 22:12:56 -0300 | [diff] [blame] | 1661 | {NULL}, |
| 1662 | }, |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1663 | } |
| 1664 | }; |
| 1665 | |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 1666 | static struct dvb_usb_device_properties dw2104_properties = { |
| 1667 | .caps = DVB_USB_IS_AN_I2C_ADAPTER, |
| 1668 | .usb_ctrl = DEVICE_SPECIFIC, |
Rémi Cardona | 6823627 | 2012-09-28 08:59:32 -0300 | [diff] [blame] | 1669 | .firmware = DW2104_FIRMWARE, |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 1670 | .no_reconnect = 1, |
| 1671 | |
| 1672 | .i2c_algo = &dw2104_i2c_algo, |
Mauro Carvalho Chehab | f72a27b | 2010-07-31 18:04:09 -0300 | [diff] [blame] | 1673 | .rc.legacy = { |
Mauro Carvalho Chehab | 2f4f58d | 2010-11-17 15:46:09 -0300 | [diff] [blame] | 1674 | .rc_map_table = rc_map_dw210x_table, |
| 1675 | .rc_map_size = ARRAY_SIZE(rc_map_dw210x_table), |
Mauro Carvalho Chehab | f72a27b | 2010-07-31 18:04:09 -0300 | [diff] [blame] | 1676 | .rc_interval = 150, |
| 1677 | .rc_query = dw2102_rc_query, |
| 1678 | }, |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 1679 | |
| 1680 | .generic_bulk_ctrl_endpoint = 0x81, |
| 1681 | /* parameter for the MPEG2-data transfer */ |
| 1682 | .num_adapters = 1, |
| 1683 | .download_firmware = dw2102_load_firmware, |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 1684 | .read_mac_address = dw210x_read_mac_address, |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 1685 | .adapter = { |
| 1686 | { |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1687 | .num_frontends = 1, |
| 1688 | .fe = {{ |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 1689 | .frontend_attach = dw2104_frontend_attach, |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 1690 | .stream = { |
| 1691 | .type = USB_BULK, |
| 1692 | .count = 8, |
| 1693 | .endpoint = 0x82, |
| 1694 | .u = { |
| 1695 | .bulk = { |
| 1696 | .buffersize = 4096, |
| 1697 | } |
| 1698 | } |
| 1699 | }, |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1700 | }}, |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 1701 | } |
| 1702 | }, |
| 1703 | .num_device_descs = 2, |
| 1704 | .devices = { |
| 1705 | { "DVBWorld DW2104 USB2.0", |
Jonathan Nieder | 27351b1 | 2011-12-23 19:00:45 -0300 | [diff] [blame] | 1706 | {&dw2102_table[CYPRESS_DW2104], NULL}, |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 1707 | {NULL}, |
| 1708 | }, |
| 1709 | { "TeVii S650 USB2.0", |
Jonathan Nieder | 27351b1 | 2011-12-23 19:00:45 -0300 | [diff] [blame] | 1710 | {&dw2102_table[TEVII_S650], NULL}, |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 1711 | {NULL}, |
| 1712 | }, |
| 1713 | } |
| 1714 | }; |
| 1715 | |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 1716 | static struct dvb_usb_device_properties dw3101_properties = { |
| 1717 | .caps = DVB_USB_IS_AN_I2C_ADAPTER, |
| 1718 | .usb_ctrl = DEVICE_SPECIFIC, |
Rémi Cardona | 6823627 | 2012-09-28 08:59:32 -0300 | [diff] [blame] | 1719 | .firmware = DW3101_FIRMWARE, |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 1720 | .no_reconnect = 1, |
| 1721 | |
| 1722 | .i2c_algo = &dw3101_i2c_algo, |
Mauro Carvalho Chehab | f72a27b | 2010-07-31 18:04:09 -0300 | [diff] [blame] | 1723 | .rc.legacy = { |
Mauro Carvalho Chehab | 2f4f58d | 2010-11-17 15:46:09 -0300 | [diff] [blame] | 1724 | .rc_map_table = rc_map_dw210x_table, |
| 1725 | .rc_map_size = ARRAY_SIZE(rc_map_dw210x_table), |
Mauro Carvalho Chehab | f72a27b | 2010-07-31 18:04:09 -0300 | [diff] [blame] | 1726 | .rc_interval = 150, |
| 1727 | .rc_query = dw2102_rc_query, |
| 1728 | }, |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 1729 | |
| 1730 | .generic_bulk_ctrl_endpoint = 0x81, |
| 1731 | /* parameter for the MPEG2-data transfer */ |
| 1732 | .num_adapters = 1, |
| 1733 | .download_firmware = dw2102_load_firmware, |
| 1734 | .read_mac_address = dw210x_read_mac_address, |
| 1735 | .adapter = { |
| 1736 | { |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1737 | .num_frontends = 1, |
| 1738 | .fe = {{ |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 1739 | .frontend_attach = dw3101_frontend_attach, |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 1740 | .tuner_attach = dw3101_tuner_attach, |
| 1741 | .stream = { |
| 1742 | .type = USB_BULK, |
| 1743 | .count = 8, |
| 1744 | .endpoint = 0x82, |
| 1745 | .u = { |
| 1746 | .bulk = { |
| 1747 | .buffersize = 4096, |
| 1748 | } |
| 1749 | } |
| 1750 | }, |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1751 | }}, |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 1752 | } |
| 1753 | }, |
| 1754 | .num_device_descs = 1, |
| 1755 | .devices = { |
| 1756 | { "DVBWorld DVB-C 3101 USB2.0", |
Jonathan Nieder | 27351b1 | 2011-12-23 19:00:45 -0300 | [diff] [blame] | 1757 | {&dw2102_table[CYPRESS_DW3101], NULL}, |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 1758 | {NULL}, |
| 1759 | }, |
| 1760 | } |
| 1761 | }; |
| 1762 | |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 1763 | static struct dvb_usb_device_properties s6x0_properties = { |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 1764 | .caps = DVB_USB_IS_AN_I2C_ADAPTER, |
| 1765 | .usb_ctrl = DEVICE_SPECIFIC, |
Igor M. Liplianin | 52c506e | 2011-02-25 18:41:23 -0300 | [diff] [blame] | 1766 | .size_of_priv = sizeof(struct s6x0_state), |
Rémi Cardona | 6823627 | 2012-09-28 08:59:32 -0300 | [diff] [blame] | 1767 | .firmware = S630_FIRMWARE, |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 1768 | .no_reconnect = 1, |
| 1769 | |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 1770 | .i2c_algo = &s6x0_i2c_algo, |
Mauro Carvalho Chehab | f72a27b | 2010-07-31 18:04:09 -0300 | [diff] [blame] | 1771 | .rc.legacy = { |
Mauro Carvalho Chehab | 2f4f58d | 2010-11-17 15:46:09 -0300 | [diff] [blame] | 1772 | .rc_map_table = rc_map_tevii_table, |
| 1773 | .rc_map_size = ARRAY_SIZE(rc_map_tevii_table), |
Mauro Carvalho Chehab | f72a27b | 2010-07-31 18:04:09 -0300 | [diff] [blame] | 1774 | .rc_interval = 150, |
| 1775 | .rc_query = dw2102_rc_query, |
| 1776 | }, |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 1777 | |
| 1778 | .generic_bulk_ctrl_endpoint = 0x81, |
| 1779 | .num_adapters = 1, |
| 1780 | .download_firmware = dw2102_load_firmware, |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 1781 | .read_mac_address = s6x0_read_mac_address, |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 1782 | .adapter = { |
| 1783 | { |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1784 | .num_frontends = 1, |
| 1785 | .fe = {{ |
Igor M. Liplianin | 195288d | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 1786 | .frontend_attach = zl100313_frontend_attach, |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 1787 | .stream = { |
| 1788 | .type = USB_BULK, |
| 1789 | .count = 8, |
| 1790 | .endpoint = 0x82, |
| 1791 | .u = { |
| 1792 | .bulk = { |
| 1793 | .buffersize = 4096, |
| 1794 | } |
| 1795 | } |
| 1796 | }, |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1797 | }}, |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 1798 | } |
| 1799 | }, |
Igor M. Liplianin | 195288d | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 1800 | .num_device_descs = 1, |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 1801 | .devices = { |
| 1802 | {"TeVii S630 USB", |
Jonathan Nieder | 27351b1 | 2011-12-23 19:00:45 -0300 | [diff] [blame] | 1803 | {&dw2102_table[TEVII_S630], NULL}, |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 1804 | {NULL}, |
| 1805 | }, |
| 1806 | } |
| 1807 | }; |
| 1808 | |
Igor M. Liplianin | 195288d | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 1809 | struct dvb_usb_device_properties *p1100; |
| 1810 | static struct dvb_usb_device_description d1100 = { |
| 1811 | "Prof 1100 USB ", |
Jonathan Nieder | 27351b1 | 2011-12-23 19:00:45 -0300 | [diff] [blame] | 1812 | {&dw2102_table[PROF_1100], NULL}, |
Igor M. Liplianin | 195288d | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 1813 | {NULL}, |
| 1814 | }; |
| 1815 | |
| 1816 | struct dvb_usb_device_properties *s660; |
| 1817 | static struct dvb_usb_device_description d660 = { |
| 1818 | "TeVii S660 USB", |
Jonathan Nieder | 27351b1 | 2011-12-23 19:00:45 -0300 | [diff] [blame] | 1819 | {&dw2102_table[TEVII_S660], NULL}, |
Igor M. Liplianin | 195288d | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 1820 | {NULL}, |
| 1821 | }; |
| 1822 | |
Igor M. Liplianin | e8f5055 | 2011-02-25 18:41:23 -0300 | [diff] [blame] | 1823 | static struct dvb_usb_device_description d480_1 = { |
| 1824 | "TeVii S480.1 USB", |
Jonathan Nieder | 27351b1 | 2011-12-23 19:00:45 -0300 | [diff] [blame] | 1825 | {&dw2102_table[TEVII_S480_1], NULL}, |
Igor M. Liplianin | e8f5055 | 2011-02-25 18:41:23 -0300 | [diff] [blame] | 1826 | {NULL}, |
| 1827 | }; |
| 1828 | |
| 1829 | static struct dvb_usb_device_description d480_2 = { |
| 1830 | "TeVii S480.2 USB", |
Jonathan Nieder | 27351b1 | 2011-12-23 19:00:45 -0300 | [diff] [blame] | 1831 | {&dw2102_table[TEVII_S480_2], NULL}, |
Igor M. Liplianin | e8f5055 | 2011-02-25 18:41:23 -0300 | [diff] [blame] | 1832 | {NULL}, |
| 1833 | }; |
| 1834 | |
Igor M. Liplianin | cd79d33 | 2009-12-14 20:24:56 -0300 | [diff] [blame] | 1835 | struct dvb_usb_device_properties *p7500; |
| 1836 | static struct dvb_usb_device_description d7500 = { |
| 1837 | "Prof 7500 USB DVB-S2", |
Jonathan Nieder | 27351b1 | 2011-12-23 19:00:45 -0300 | [diff] [blame] | 1838 | {&dw2102_table[PROF_7500], NULL}, |
Igor M. Liplianin | cd79d33 | 2009-12-14 20:24:56 -0300 | [diff] [blame] | 1839 | {NULL}, |
| 1840 | }; |
| 1841 | |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 1842 | static struct dvb_usb_device_properties su3000_properties = { |
| 1843 | .caps = DVB_USB_IS_AN_I2C_ADAPTER, |
| 1844 | .usb_ctrl = DEVICE_SPECIFIC, |
| 1845 | .size_of_priv = sizeof(struct su3000_state), |
| 1846 | .power_ctrl = su3000_power_ctrl, |
| 1847 | .num_adapters = 1, |
| 1848 | .identify_state = su3000_identify_state, |
| 1849 | .i2c_algo = &su3000_i2c_algo, |
| 1850 | |
| 1851 | .rc.legacy = { |
| 1852 | .rc_map_table = rc_map_su3000_table, |
| 1853 | .rc_map_size = ARRAY_SIZE(rc_map_su3000_table), |
| 1854 | .rc_interval = 150, |
| 1855 | .rc_query = dw2102_rc_query, |
| 1856 | }, |
| 1857 | |
| 1858 | .read_mac_address = su3000_read_mac_address, |
| 1859 | |
| 1860 | .generic_bulk_ctrl_endpoint = 0x01, |
| 1861 | |
| 1862 | .adapter = { |
| 1863 | { |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1864 | .num_frontends = 1, |
| 1865 | .fe = {{ |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 1866 | .streaming_ctrl = su3000_streaming_ctrl, |
| 1867 | .frontend_attach = su3000_frontend_attach, |
| 1868 | .stream = { |
| 1869 | .type = USB_BULK, |
| 1870 | .count = 8, |
| 1871 | .endpoint = 0x82, |
| 1872 | .u = { |
| 1873 | .bulk = { |
| 1874 | .buffersize = 4096, |
| 1875 | } |
| 1876 | } |
| 1877 | } |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1878 | }}, |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 1879 | } |
| 1880 | }, |
Mauro Carvalho Chehab | b7e3863 | 2012-07-07 00:19:20 -0300 | [diff] [blame] | 1881 | .num_device_descs = 3, |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 1882 | .devices = { |
| 1883 | { "SU3000HD DVB-S USB2.0", |
Jonathan Nieder | 27351b1 | 2011-12-23 19:00:45 -0300 | [diff] [blame] | 1884 | { &dw2102_table[GENIATECH_SU3000], NULL }, |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 1885 | { NULL }, |
| 1886 | }, |
Igor M. Liplianin | 2adc591 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 1887 | { "Terratec Cinergy S2 USB HD", |
Jonathan Nieder | 27351b1 | 2011-12-23 19:00:45 -0300 | [diff] [blame] | 1888 | { &dw2102_table[TERRATEC_CINERGY_S2], NULL }, |
Igor M. Liplianin | 2adc591 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 1889 | { NULL }, |
| 1890 | }, |
Igor M. Liplianin | 5265ea5 | 2011-02-27 16:17:25 -0300 | [diff] [blame] | 1891 | { "X3M TV SPC1400HD PCI", |
Jonathan Nieder | 27351b1 | 2011-12-23 19:00:45 -0300 | [diff] [blame] | 1892 | { &dw2102_table[X3M_SPC1400HD], NULL }, |
Igor M. Liplianin | 5265ea5 | 2011-02-27 16:17:25 -0300 | [diff] [blame] | 1893 | { NULL }, |
| 1894 | }, |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 1895 | } |
| 1896 | }; |
| 1897 | |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1898 | static int dw2102_probe(struct usb_interface *intf, |
| 1899 | const struct usb_device_id *id) |
| 1900 | { |
Thomas Meyer | 68dd9dd | 2011-11-17 18:43:40 -0300 | [diff] [blame] | 1901 | p1100 = kmemdup(&s6x0_properties, |
| 1902 | sizeof(struct dvb_usb_device_properties), GFP_KERNEL); |
Igor M. Liplianin | 195288d | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 1903 | if (!p1100) |
Igor M. Liplianin | cd79d33 | 2009-12-14 20:24:56 -0300 | [diff] [blame] | 1904 | return -ENOMEM; |
| 1905 | /* copy default structure */ |
Igor M. Liplianin | cd79d33 | 2009-12-14 20:24:56 -0300 | [diff] [blame] | 1906 | /* fill only different fields */ |
Rémi Cardona | 6823627 | 2012-09-28 08:59:32 -0300 | [diff] [blame] | 1907 | p1100->firmware = P1100_FIRMWARE; |
Igor M. Liplianin | 195288d | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 1908 | p1100->devices[0] = d1100; |
| 1909 | p1100->rc.legacy.rc_map_table = rc_map_tbs_table; |
| 1910 | p1100->rc.legacy.rc_map_size = ARRAY_SIZE(rc_map_tbs_table); |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1911 | p1100->adapter->fe[0].frontend_attach = stv0288_frontend_attach; |
Igor M. Liplianin | 195288d | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 1912 | |
Thomas Meyer | 68dd9dd | 2011-11-17 18:43:40 -0300 | [diff] [blame] | 1913 | s660 = kmemdup(&s6x0_properties, |
| 1914 | sizeof(struct dvb_usb_device_properties), GFP_KERNEL); |
Igor M. Liplianin | 195288d | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 1915 | if (!s660) { |
| 1916 | kfree(p1100); |
| 1917 | return -ENOMEM; |
| 1918 | } |
Rémi Cardona | 6823627 | 2012-09-28 08:59:32 -0300 | [diff] [blame] | 1919 | s660->firmware = S660_FIRMWARE; |
Igor M. Liplianin | e8f5055 | 2011-02-25 18:41:23 -0300 | [diff] [blame] | 1920 | s660->num_device_descs = 3; |
Igor M. Liplianin | 195288d | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 1921 | s660->devices[0] = d660; |
Igor M. Liplianin | e8f5055 | 2011-02-25 18:41:23 -0300 | [diff] [blame] | 1922 | s660->devices[1] = d480_1; |
| 1923 | s660->devices[2] = d480_2; |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1924 | s660->adapter->fe[0].frontend_attach = ds3000_frontend_attach; |
Igor M. Liplianin | 195288d | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 1925 | |
Thomas Meyer | 68dd9dd | 2011-11-17 18:43:40 -0300 | [diff] [blame] | 1926 | p7500 = kmemdup(&s6x0_properties, |
| 1927 | sizeof(struct dvb_usb_device_properties), GFP_KERNEL); |
Igor M. Liplianin | 195288d | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 1928 | if (!p7500) { |
| 1929 | kfree(p1100); |
| 1930 | kfree(s660); |
| 1931 | return -ENOMEM; |
| 1932 | } |
Rémi Cardona | 6823627 | 2012-09-28 08:59:32 -0300 | [diff] [blame] | 1933 | p7500->firmware = P7500_FIRMWARE; |
Igor M. Liplianin | cd79d33 | 2009-12-14 20:24:56 -0300 | [diff] [blame] | 1934 | p7500->devices[0] = d7500; |
Mauro Carvalho Chehab | 2f4f58d | 2010-11-17 15:46:09 -0300 | [diff] [blame] | 1935 | p7500->rc.legacy.rc_map_table = rc_map_tbs_table; |
| 1936 | p7500->rc.legacy.rc_map_size = ARRAY_SIZE(rc_map_tbs_table); |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1937 | p7500->adapter->fe[0].frontend_attach = prof_7500_frontend_attach; |
Igor M. Liplianin | cd79d33 | 2009-12-14 20:24:56 -0300 | [diff] [blame] | 1938 | |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 1939 | if (0 == dvb_usb_device_init(intf, &dw2102_properties, |
| 1940 | THIS_MODULE, NULL, adapter_nr) || |
| 1941 | 0 == dvb_usb_device_init(intf, &dw2104_properties, |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 1942 | THIS_MODULE, NULL, adapter_nr) || |
| 1943 | 0 == dvb_usb_device_init(intf, &dw3101_properties, |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 1944 | THIS_MODULE, NULL, adapter_nr) || |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 1945 | 0 == dvb_usb_device_init(intf, &s6x0_properties, |
Igor M. Liplianin | cd79d33 | 2009-12-14 20:24:56 -0300 | [diff] [blame] | 1946 | THIS_MODULE, NULL, adapter_nr) || |
Igor M. Liplianin | 195288d | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 1947 | 0 == dvb_usb_device_init(intf, p1100, |
| 1948 | THIS_MODULE, NULL, adapter_nr) || |
| 1949 | 0 == dvb_usb_device_init(intf, s660, |
| 1950 | THIS_MODULE, NULL, adapter_nr) || |
Igor M. Liplianin | cd79d33 | 2009-12-14 20:24:56 -0300 | [diff] [blame] | 1951 | 0 == dvb_usb_device_init(intf, p7500, |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 1952 | THIS_MODULE, NULL, adapter_nr) || |
| 1953 | 0 == dvb_usb_device_init(intf, &su3000_properties, |
| 1954 | THIS_MODULE, NULL, adapter_nr)) |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 1955 | return 0; |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 1956 | |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 1957 | return -ENODEV; |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1958 | } |
| 1959 | |
| 1960 | static struct usb_driver dw2102_driver = { |
| 1961 | .name = "dw2102", |
| 1962 | .probe = dw2102_probe, |
| 1963 | .disconnect = dvb_usb_device_exit, |
| 1964 | .id_table = dw2102_table, |
| 1965 | }; |
| 1966 | |
Greg Kroah-Hartman | ecb3b2b | 2011-11-18 09:46:12 -0800 | [diff] [blame] | 1967 | module_usb_driver(dw2102_driver); |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1968 | |
| 1969 | MODULE_AUTHOR("Igor M. Liplianin (c) liplianin@me.by"); |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 1970 | MODULE_DESCRIPTION("Driver for DVBWorld DVB-S 2101, 2102, DVB-S2 2104," |
| 1971 | " DVB-C 3101 USB2.0," |
Igor M. Liplianin | e8f5055 | 2011-02-25 18:41:23 -0300 | [diff] [blame] | 1972 | " TeVii S600, S630, S650, S660, S480," |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 1973 | " Prof 1100, 7500 USB2.0," |
| 1974 | " Geniatech SU3000 devices"); |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1975 | MODULE_VERSION("0.1"); |
| 1976 | MODULE_LICENSE("GPL"); |
Rémi Cardona | 6823627 | 2012-09-28 08:59:32 -0300 | [diff] [blame] | 1977 | MODULE_FIRMWARE(DW2101_FIRMWARE); |
| 1978 | MODULE_FIRMWARE(DW2102_FIRMWARE); |
| 1979 | MODULE_FIRMWARE(DW2104_FIRMWARE); |
| 1980 | MODULE_FIRMWARE(DW3101_FIRMWARE); |
| 1981 | MODULE_FIRMWARE(S630_FIRMWARE); |
| 1982 | MODULE_FIRMWARE(S660_FIRMWARE); |
| 1983 | MODULE_FIRMWARE(P1100_FIRMWARE); |
| 1984 | MODULE_FIRMWARE(P7500_FIRMWARE); |