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