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, |
| 3 | * TeVii S600, S650 Cards |
| 4 | * Copyright (C) 2008,2009 Igor M. Liplianin (liplianin@me.by) |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify it |
| 7 | * under the terms of the GNU General Public License as published by the |
| 8 | * Free Software Foundation, version 2. |
| 9 | * |
| 10 | * see Documentation/dvb/README.dvb-usb for more information |
| 11 | */ |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 12 | #include "dw2102.h" |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 13 | #include "si21xx.h" |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 14 | #include "stv0299.h" |
| 15 | #include "z0194a.h" |
Igor M. Liplianin | 8a4949b | 2008-10-05 09:11:21 -0300 | [diff] [blame] | 16 | #include "stv0288.h" |
| 17 | #include "stb6000.h" |
| 18 | #include "eds1547.h" |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 19 | #include "cx24116.h" |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame^] | 20 | #include "tda1002x.h" |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 21 | |
| 22 | #ifndef USB_PID_DW2102 |
| 23 | #define USB_PID_DW2102 0x2102 |
| 24 | #endif |
| 25 | |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 26 | #ifndef USB_PID_DW2104 |
| 27 | #define USB_PID_DW2104 0x2104 |
| 28 | #endif |
| 29 | |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame^] | 30 | #ifndef USB_PID_DW3101 |
| 31 | #define USB_PID_DW3101 0x3101 |
| 32 | #endif |
| 33 | |
Igor M. Liplianin | 4cc0edf | 2008-11-05 22:12:56 -0300 | [diff] [blame] | 34 | #ifndef USB_PID_CINERGY_S |
| 35 | #define USB_PID_CINERGY_S 0x0064 |
| 36 | #endif |
| 37 | |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame^] | 38 | #ifndef USB_PID_TEVII_S650 |
| 39 | #define USB_PID_TEVII_S650 0xd650 |
| 40 | #endif |
| 41 | |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 42 | #define DW210X_READ_MSG 0 |
| 43 | #define DW210X_WRITE_MSG 1 |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 44 | |
| 45 | #define REG_1F_SYMBOLRATE_BYTE0 0x1f |
| 46 | #define REG_20_SYMBOLRATE_BYTE1 0x20 |
| 47 | #define REG_21_SYMBOLRATE_BYTE2 0x21 |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 48 | /* on my own*/ |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 49 | #define DW2102_VOLTAGE_CTRL (0x1800) |
| 50 | #define DW2102_RC_QUERY (0x1a00) |
| 51 | |
Igor M. Liplianin | b42e1d7 | 2009-06-14 19:41:22 -0300 | [diff] [blame] | 52 | struct dvb_usb_rc_keys_table { |
| 53 | struct dvb_usb_rc_key *rc_keys; |
| 54 | int rc_keys_size; |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 55 | }; |
| 56 | |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 57 | /* debug */ |
| 58 | static int dvb_usb_dw2102_debug; |
| 59 | module_param_named(debug, dvb_usb_dw2102_debug, int, 0644); |
Igor M. Liplianin | 8a8dad7 | 2009-06-13 08:10:24 -0300 | [diff] [blame] | 60 | MODULE_PARM_DESC(debug, "set debugging level (1=info 2=xfer 4=rc(or-able))." |
| 61 | DVB_USB_DEBUG_STATUS); |
| 62 | |
Igor M. Liplianin | b42e1d7 | 2009-06-14 19:41:22 -0300 | [diff] [blame] | 63 | /* keymaps */ |
| 64 | static int ir_keymap; |
| 65 | module_param_named(keymap, ir_keymap, int, 0644); |
| 66 | MODULE_PARM_DESC(keymap, "set keymap 0=default 1=dvbworld 2=tevii 3=tbs ..."); |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 67 | |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 68 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); |
| 69 | |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 70 | 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] | 71 | u16 index, u8 * data, u16 len, int flags) |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 72 | { |
| 73 | int ret; |
| 74 | u8 u8buf[len]; |
| 75 | |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 76 | unsigned int pipe = (flags == DW210X_READ_MSG) ? |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 77 | usb_rcvctrlpipe(dev, 0) : usb_sndctrlpipe(dev, 0); |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 78 | 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] | 79 | |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 80 | if (flags == DW210X_WRITE_MSG) |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 81 | memcpy(u8buf, data, len); |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 82 | ret = usb_control_msg(dev, pipe, request, request_type | USB_TYPE_VENDOR, |
| 83 | value, index , u8buf, len, 2000); |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 84 | |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 85 | if (flags == DW210X_READ_MSG) |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 86 | memcpy(data, u8buf, len); |
| 87 | return ret; |
| 88 | } |
| 89 | |
| 90 | /* I2C */ |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 91 | static int dw2102_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], |
| 92 | int num) |
| 93 | { |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame^] | 94 | struct dvb_usb_device *d = i2c_get_adapdata(adap); |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 95 | int i = 0, ret = 0; |
| 96 | u8 buf6[] = {0x2c, 0x05, 0xc0, 0, 0, 0, 0}; |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 97 | u16 value; |
| 98 | |
| 99 | if (!d) |
| 100 | return -ENODEV; |
| 101 | if (mutex_lock_interruptible(&d->i2c_mutex) < 0) |
| 102 | return -EAGAIN; |
| 103 | |
| 104 | switch (num) { |
| 105 | case 2: |
| 106 | /* read stv0299 register */ |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 107 | value = msg[0].buf[0];/* register */ |
| 108 | for (i = 0; i < msg[1].len; i++) { |
| 109 | value = value + i; |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 110 | ret = dw210x_op_rw(d->udev, 0xb5, value, 0, |
| 111 | buf6, 2, DW210X_READ_MSG); |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 112 | msg[1].buf[i] = buf6[0]; |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 113 | } |
| 114 | break; |
| 115 | case 1: |
| 116 | switch (msg[0].addr) { |
| 117 | case 0x68: |
| 118 | /* write to stv0299 register */ |
| 119 | buf6[0] = 0x2a; |
| 120 | buf6[1] = msg[0].buf[0]; |
| 121 | buf6[2] = msg[0].buf[1]; |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 122 | ret = dw210x_op_rw(d->udev, 0xb2, 0, 0, |
| 123 | buf6, 3, DW210X_WRITE_MSG); |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 124 | break; |
| 125 | case 0x60: |
| 126 | if (msg[0].flags == 0) { |
| 127 | /* write to tuner pll */ |
| 128 | buf6[0] = 0x2c; |
| 129 | buf6[1] = 5; |
| 130 | buf6[2] = 0xc0; |
| 131 | buf6[3] = msg[0].buf[0]; |
| 132 | buf6[4] = msg[0].buf[1]; |
| 133 | buf6[5] = msg[0].buf[2]; |
| 134 | buf6[6] = msg[0].buf[3]; |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 135 | ret = dw210x_op_rw(d->udev, 0xb2, 0, 0, |
| 136 | buf6, 7, DW210X_WRITE_MSG); |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 137 | } else { |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 138 | /* read from tuner */ |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 139 | ret = dw210x_op_rw(d->udev, 0xb5, 0, 0, |
| 140 | buf6, 1, DW210X_READ_MSG); |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 141 | msg[0].buf[0] = buf6[0]; |
| 142 | } |
| 143 | break; |
| 144 | case (DW2102_RC_QUERY): |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 145 | ret = dw210x_op_rw(d->udev, 0xb8, 0, 0, |
| 146 | buf6, 2, DW210X_READ_MSG); |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 147 | msg[0].buf[0] = buf6[0]; |
| 148 | msg[0].buf[1] = buf6[1]; |
| 149 | break; |
| 150 | case (DW2102_VOLTAGE_CTRL): |
| 151 | buf6[0] = 0x30; |
| 152 | buf6[1] = msg[0].buf[0]; |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 153 | ret = dw210x_op_rw(d->udev, 0xb2, 0, 0, |
| 154 | buf6, 2, DW210X_WRITE_MSG); |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 155 | break; |
| 156 | } |
| 157 | |
| 158 | break; |
| 159 | } |
| 160 | |
| 161 | mutex_unlock(&d->i2c_mutex); |
| 162 | return num; |
| 163 | } |
| 164 | |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 165 | static int dw2102_serit_i2c_transfer(struct i2c_adapter *adap, |
| 166 | struct i2c_msg msg[], int num) |
| 167 | { |
| 168 | struct dvb_usb_device *d = i2c_get_adapdata(adap); |
| 169 | int ret = 0; |
| 170 | u8 buf6[] = {0, 0, 0, 0, 0, 0, 0}; |
| 171 | |
| 172 | if (!d) |
| 173 | return -ENODEV; |
| 174 | if (mutex_lock_interruptible(&d->i2c_mutex) < 0) |
| 175 | return -EAGAIN; |
| 176 | |
| 177 | switch (num) { |
| 178 | case 2: |
| 179 | /* read si2109 register by number */ |
| 180 | buf6[0] = 0xd0; |
| 181 | buf6[1] = msg[0].len; |
| 182 | buf6[2] = msg[0].buf[0]; |
| 183 | ret = dw210x_op_rw(d->udev, 0xc2, 0, 0, |
| 184 | buf6, msg[0].len + 2, DW210X_WRITE_MSG); |
| 185 | /* read si2109 register */ |
| 186 | ret = dw210x_op_rw(d->udev, 0xc3, 0xd0, 0, |
| 187 | buf6, msg[1].len + 2, DW210X_READ_MSG); |
| 188 | memcpy(msg[1].buf, buf6 + 2, msg[1].len); |
| 189 | |
| 190 | break; |
| 191 | case 1: |
| 192 | switch (msg[0].addr) { |
| 193 | case 0x68: |
| 194 | /* write to si2109 register */ |
| 195 | buf6[0] = 0xd0; |
| 196 | buf6[1] = msg[0].len; |
| 197 | memcpy(buf6 + 2, msg[0].buf, msg[0].len); |
| 198 | ret = dw210x_op_rw(d->udev, 0xc2, 0, 0, buf6, |
| 199 | msg[0].len + 2, DW210X_WRITE_MSG); |
| 200 | break; |
| 201 | case(DW2102_RC_QUERY): |
| 202 | ret = dw210x_op_rw(d->udev, 0xb8, 0, 0, |
| 203 | buf6, 2, DW210X_READ_MSG); |
| 204 | msg[0].buf[0] = buf6[0]; |
| 205 | msg[0].buf[1] = buf6[1]; |
| 206 | break; |
| 207 | case(DW2102_VOLTAGE_CTRL): |
| 208 | buf6[0] = 0x30; |
| 209 | buf6[1] = msg[0].buf[0]; |
| 210 | ret = dw210x_op_rw(d->udev, 0xb2, 0, 0, |
| 211 | buf6, 2, DW210X_WRITE_MSG); |
| 212 | break; |
| 213 | } |
| 214 | break; |
| 215 | } |
| 216 | |
| 217 | mutex_unlock(&d->i2c_mutex); |
| 218 | return num; |
| 219 | } |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame^] | 220 | |
Igor M. Liplianin | 8a4949b | 2008-10-05 09:11:21 -0300 | [diff] [blame] | 221 | static int dw2102_earda_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], int num) |
| 222 | { |
| 223 | struct dvb_usb_device *d = i2c_get_adapdata(adap); |
| 224 | int ret = 0; |
| 225 | |
| 226 | if (!d) |
| 227 | return -ENODEV; |
| 228 | if (mutex_lock_interruptible(&d->i2c_mutex) < 0) |
| 229 | return -EAGAIN; |
| 230 | |
| 231 | switch (num) { |
| 232 | case 2: { |
| 233 | /* read */ |
| 234 | /* first write first register number */ |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame^] | 235 | u8 ibuf[msg[1].len + 2], obuf[3]; |
Igor M. Liplianin | 8a4949b | 2008-10-05 09:11:21 -0300 | [diff] [blame] | 236 | obuf[0] = 0xd0; |
| 237 | obuf[1] = msg[0].len; |
| 238 | obuf[2] = msg[0].buf[0]; |
| 239 | ret = dw210x_op_rw(d->udev, 0xc2, 0, 0, |
| 240 | obuf, msg[0].len + 2, DW210X_WRITE_MSG); |
| 241 | /* second read registers */ |
| 242 | ret = dw210x_op_rw(d->udev, 0xc3, 0xd1 , 0, |
| 243 | ibuf, msg[1].len + 2, DW210X_READ_MSG); |
| 244 | memcpy(msg[1].buf, ibuf + 2, msg[1].len); |
| 245 | |
| 246 | break; |
| 247 | } |
| 248 | case 1: |
| 249 | switch (msg[0].addr) { |
| 250 | case 0x68: { |
| 251 | /* write to register */ |
| 252 | u8 obuf[msg[0].len + 2]; |
| 253 | obuf[0] = 0xd0; |
| 254 | obuf[1] = msg[0].len; |
| 255 | memcpy(obuf + 2, msg[0].buf, msg[0].len); |
| 256 | ret = dw210x_op_rw(d->udev, 0xc2, 0, 0, |
| 257 | obuf, msg[0].len + 2, DW210X_WRITE_MSG); |
| 258 | break; |
| 259 | } |
| 260 | case 0x61: { |
| 261 | /* write to tuner */ |
| 262 | u8 obuf[msg[0].len + 2]; |
| 263 | obuf[0] = 0xc2; |
| 264 | obuf[1] = msg[0].len; |
| 265 | memcpy(obuf + 2, msg[0].buf, msg[0].len); |
| 266 | ret = dw210x_op_rw(d->udev, 0xc2, 0, 0, |
| 267 | obuf, msg[0].len + 2, DW210X_WRITE_MSG); |
| 268 | break; |
| 269 | } |
| 270 | case(DW2102_RC_QUERY): { |
| 271 | u8 ibuf[2]; |
| 272 | ret = dw210x_op_rw(d->udev, 0xb8, 0, 0, |
| 273 | ibuf, 2, DW210X_READ_MSG); |
| 274 | memcpy(msg[0].buf, ibuf , 2); |
| 275 | break; |
| 276 | } |
| 277 | case(DW2102_VOLTAGE_CTRL): { |
| 278 | u8 obuf[2]; |
| 279 | obuf[0] = 0x30; |
| 280 | obuf[1] = msg[0].buf[0]; |
| 281 | ret = dw210x_op_rw(d->udev, 0xb2, 0, 0, |
| 282 | obuf, 2, DW210X_WRITE_MSG); |
| 283 | break; |
| 284 | } |
| 285 | } |
| 286 | |
| 287 | break; |
| 288 | } |
| 289 | |
| 290 | mutex_unlock(&d->i2c_mutex); |
| 291 | return num; |
| 292 | } |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 293 | |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 294 | static int dw2104_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], int num) |
| 295 | { |
| 296 | struct dvb_usb_device *d = i2c_get_adapdata(adap); |
| 297 | int ret = 0; |
| 298 | int len, i; |
| 299 | |
| 300 | if (!d) |
| 301 | return -ENODEV; |
| 302 | if (mutex_lock_interruptible(&d->i2c_mutex) < 0) |
| 303 | return -EAGAIN; |
| 304 | |
| 305 | switch (num) { |
| 306 | case 2: { |
| 307 | /* read */ |
| 308 | /* first write first register number */ |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame^] | 309 | u8 ibuf[msg[1].len + 2], obuf[3]; |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 310 | obuf[0] = 0xaa; |
| 311 | obuf[1] = msg[0].len; |
| 312 | obuf[2] = msg[0].buf[0]; |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 313 | ret = dw210x_op_rw(d->udev, 0xc2, 0, 0, |
| 314 | obuf, msg[0].len + 2, DW210X_WRITE_MSG); |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 315 | /* second read registers */ |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 316 | ret = dw210x_op_rw(d->udev, 0xc3, 0xab , 0, |
| 317 | ibuf, msg[1].len + 2, DW210X_READ_MSG); |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 318 | memcpy(msg[1].buf, ibuf + 2, msg[1].len); |
| 319 | |
| 320 | break; |
| 321 | } |
| 322 | case 1: |
| 323 | switch (msg[0].addr) { |
| 324 | case 0x55: { |
| 325 | if (msg[0].buf[0] == 0xf7) { |
| 326 | /* firmware */ |
| 327 | /* Write in small blocks */ |
| 328 | u8 obuf[19]; |
| 329 | obuf[0] = 0xaa; |
| 330 | obuf[1] = 0x11; |
| 331 | obuf[2] = 0xf7; |
| 332 | len = msg[0].len - 1; |
| 333 | i = 1; |
| 334 | do { |
| 335 | memcpy(obuf + 3, msg[0].buf + i, (len > 16 ? 16 : len)); |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 336 | ret = dw210x_op_rw(d->udev, 0xc2, 0, 0, |
| 337 | obuf, (len > 16 ? 16 : len) + 3, DW210X_WRITE_MSG); |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 338 | i += 16; |
| 339 | len -= 16; |
| 340 | } while (len > 0); |
| 341 | } else { |
| 342 | /* write to register */ |
| 343 | u8 obuf[msg[0].len + 2]; |
| 344 | obuf[0] = 0xaa; |
| 345 | obuf[1] = msg[0].len; |
| 346 | memcpy(obuf + 2, msg[0].buf, msg[0].len); |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 347 | ret = dw210x_op_rw(d->udev, 0xc2, 0, 0, |
| 348 | obuf, msg[0].len + 2, DW210X_WRITE_MSG); |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 349 | } |
| 350 | break; |
| 351 | } |
| 352 | case(DW2102_RC_QUERY): { |
| 353 | u8 ibuf[2]; |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 354 | ret = dw210x_op_rw(d->udev, 0xb8, 0, 0, |
| 355 | ibuf, 2, DW210X_READ_MSG); |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 356 | memcpy(msg[0].buf, ibuf , 2); |
| 357 | break; |
| 358 | } |
| 359 | case(DW2102_VOLTAGE_CTRL): { |
| 360 | u8 obuf[2]; |
| 361 | obuf[0] = 0x30; |
| 362 | obuf[1] = msg[0].buf[0]; |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 363 | ret = dw210x_op_rw(d->udev, 0xb2, 0, 0, |
| 364 | obuf, 2, DW210X_WRITE_MSG); |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 365 | break; |
| 366 | } |
| 367 | } |
| 368 | |
| 369 | break; |
| 370 | } |
| 371 | |
| 372 | mutex_unlock(&d->i2c_mutex); |
| 373 | return num; |
| 374 | } |
| 375 | |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame^] | 376 | static int dw3101_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], |
| 377 | int num) |
| 378 | { |
| 379 | struct dvb_usb_device *d = i2c_get_adapdata(adap); |
| 380 | int ret = 0, i; |
| 381 | |
| 382 | if (!d) |
| 383 | return -ENODEV; |
| 384 | if (mutex_lock_interruptible(&d->i2c_mutex) < 0) |
| 385 | return -EAGAIN; |
| 386 | |
| 387 | switch (num) { |
| 388 | case 2: { |
| 389 | /* read */ |
| 390 | /* first write first register number */ |
| 391 | u8 ibuf[msg[1].len + 2], obuf[3]; |
| 392 | obuf[0] = msg[0].addr << 1; |
| 393 | obuf[1] = msg[0].len; |
| 394 | obuf[2] = msg[0].buf[0]; |
| 395 | ret = dw210x_op_rw(d->udev, 0xc2, 0, 0, |
| 396 | obuf, msg[0].len + 2, DW210X_WRITE_MSG); |
| 397 | /* second read registers */ |
| 398 | ret = dw210x_op_rw(d->udev, 0xc3, 0x19 , 0, |
| 399 | ibuf, msg[1].len + 2, DW210X_READ_MSG); |
| 400 | memcpy(msg[1].buf, ibuf + 2, msg[1].len); |
| 401 | |
| 402 | break; |
| 403 | } |
| 404 | case 1: |
| 405 | switch (msg[0].addr) { |
| 406 | case 0x60: |
| 407 | case 0x0c: { |
| 408 | /* write to register */ |
| 409 | u8 obuf[msg[0].len + 2]; |
| 410 | obuf[0] = msg[0].addr << 1; |
| 411 | obuf[1] = msg[0].len; |
| 412 | memcpy(obuf + 2, msg[0].buf, msg[0].len); |
| 413 | ret = dw210x_op_rw(d->udev, 0xc2, 0, 0, |
| 414 | obuf, msg[0].len + 2, DW210X_WRITE_MSG); |
| 415 | break; |
| 416 | } |
| 417 | case(DW2102_RC_QUERY): { |
| 418 | u8 ibuf[2]; |
| 419 | ret = dw210x_op_rw(d->udev, 0xb8, 0, 0, |
| 420 | ibuf, 2, DW210X_READ_MSG); |
| 421 | memcpy(msg[0].buf, ibuf , 2); |
| 422 | break; |
| 423 | } |
| 424 | } |
| 425 | |
| 426 | break; |
| 427 | } |
| 428 | |
| 429 | for (i = 0; i < num; i++) { |
| 430 | deb_xfer("%02x:%02x: %s ", i, msg[i].addr, |
| 431 | msg[i].flags == 0 ? ">>>" : "<<<"); |
| 432 | debug_dump(msg[i].buf, msg[i].len, deb_xfer); |
| 433 | } |
| 434 | |
| 435 | mutex_unlock(&d->i2c_mutex); |
| 436 | return num; |
| 437 | } |
| 438 | |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 439 | static u32 dw210x_i2c_func(struct i2c_adapter *adapter) |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 440 | { |
| 441 | return I2C_FUNC_I2C; |
| 442 | } |
| 443 | |
| 444 | static struct i2c_algorithm dw2102_i2c_algo = { |
| 445 | .master_xfer = dw2102_i2c_transfer, |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 446 | .functionality = dw210x_i2c_func, |
| 447 | }; |
| 448 | |
| 449 | static struct i2c_algorithm dw2102_serit_i2c_algo = { |
| 450 | .master_xfer = dw2102_serit_i2c_transfer, |
| 451 | .functionality = dw210x_i2c_func, |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 452 | }; |
| 453 | |
Igor M. Liplianin | 8a4949b | 2008-10-05 09:11:21 -0300 | [diff] [blame] | 454 | static struct i2c_algorithm dw2102_earda_i2c_algo = { |
| 455 | .master_xfer = dw2102_earda_i2c_transfer, |
| 456 | .functionality = dw210x_i2c_func, |
| 457 | }; |
| 458 | |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 459 | static struct i2c_algorithm dw2104_i2c_algo = { |
| 460 | .master_xfer = dw2104_i2c_transfer, |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 461 | .functionality = dw210x_i2c_func, |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 462 | }; |
| 463 | |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame^] | 464 | static struct i2c_algorithm dw3101_i2c_algo = { |
| 465 | .master_xfer = dw3101_i2c_transfer, |
| 466 | .functionality = dw210x_i2c_func, |
| 467 | }; |
| 468 | |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 469 | 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] | 470 | { |
| 471 | int i; |
| 472 | u8 ibuf[] = {0, 0}; |
| 473 | u8 eeprom[256], eepromline[16]; |
| 474 | |
| 475 | for (i = 0; i < 256; i++) { |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 476 | 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] | 477 | err("read eeprom failed."); |
| 478 | return -1; |
| 479 | } else { |
| 480 | eepromline[i%16] = ibuf[0]; |
| 481 | eeprom[i] = ibuf[0]; |
| 482 | } |
| 483 | if ((i % 16) == 15) { |
| 484 | deb_xfer("%02x: ", i - 15); |
| 485 | debug_dump(eepromline, 16, deb_xfer); |
| 486 | } |
| 487 | } |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame^] | 488 | |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 489 | memcpy(mac, eeprom + 8, 6); |
| 490 | return 0; |
| 491 | }; |
| 492 | |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 493 | 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] | 494 | { |
| 495 | static u8 command_13v[1] = {0x00}; |
| 496 | static u8 command_18v[1] = {0x01}; |
| 497 | struct i2c_msg msg[] = { |
| 498 | {.addr = DW2102_VOLTAGE_CTRL, .flags = 0, |
| 499 | .buf = command_13v, .len = 1}, |
| 500 | }; |
| 501 | |
| 502 | struct dvb_usb_adapter *udev_adap = |
| 503 | (struct dvb_usb_adapter *)(fe->dvb->priv); |
| 504 | if (voltage == SEC_VOLTAGE_18) |
| 505 | msg[0].buf = command_18v; |
| 506 | i2c_transfer(&udev_adap->dev->i2c_adap, msg, 1); |
| 507 | return 0; |
| 508 | } |
| 509 | |
Igor M. Liplianin | d4305c6 | 2008-10-17 13:45:55 -0300 | [diff] [blame] | 510 | static struct stv0299_config sharp_z0194a_config = { |
| 511 | .demod_address = 0x68, |
| 512 | .inittab = sharp_z0194a_inittab, |
| 513 | .mclk = 88000000UL, |
| 514 | .invert = 1, |
| 515 | .skip_reinit = 0, |
| 516 | .lock_output = STV0299_LOCKOUTPUT_1, |
| 517 | .volt13_op0_op1 = STV0299_VOLT13_OP1, |
| 518 | .min_delay_ms = 100, |
| 519 | .set_symbol_rate = sharp_z0194a_set_symbol_rate, |
| 520 | }; |
| 521 | |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 522 | static struct cx24116_config dw2104_config = { |
| 523 | .demod_address = 0x55, |
Igor M. Liplianin | cc8c4f3 | 2008-09-09 13:57:47 -0300 | [diff] [blame] | 524 | .mpg_clk_pos_pol = 0x01, |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 525 | }; |
| 526 | |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 527 | static struct si21xx_config serit_sp1511lhb_config = { |
| 528 | .demod_address = 0x68, |
| 529 | .min_delay_ms = 100, |
| 530 | |
| 531 | }; |
| 532 | |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame^] | 533 | static struct tda10023_config dw3101_tda10023_config = { |
| 534 | .demod_address = 0x0c, |
| 535 | .invert = 1, |
| 536 | }; |
| 537 | |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 538 | static int dw2104_frontend_attach(struct dvb_usb_adapter *d) |
| 539 | { |
| 540 | if ((d->fe = dvb_attach(cx24116_attach, &dw2104_config, |
| 541 | &d->dev->i2c_adap)) != NULL) { |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 542 | d->fe->ops.set_voltage = dw210x_set_voltage; |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 543 | info("Attached cx24116!\n"); |
| 544 | return 0; |
| 545 | } |
| 546 | return -EIO; |
| 547 | } |
| 548 | |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 549 | static struct dvb_usb_device_properties dw2102_properties; |
Igor M. Liplianin | b42e1d7 | 2009-06-14 19:41:22 -0300 | [diff] [blame] | 550 | static struct dvb_usb_device_properties dw2104_properties; |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 551 | |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 552 | static int dw2102_frontend_attach(struct dvb_usb_adapter *d) |
| 553 | { |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 554 | if (dw2102_properties.i2c_algo == &dw2102_serit_i2c_algo) { |
| 555 | /*dw2102_properties.adapter->tuner_attach = NULL;*/ |
| 556 | d->fe = dvb_attach(si21xx_attach, &serit_sp1511lhb_config, |
| 557 | &d->dev->i2c_adap); |
| 558 | if (d->fe != NULL) { |
| 559 | d->fe->ops.set_voltage = dw210x_set_voltage; |
| 560 | info("Attached si21xx!\n"); |
| 561 | return 0; |
| 562 | } |
| 563 | } |
Igor M. Liplianin | 8a4949b | 2008-10-05 09:11:21 -0300 | [diff] [blame] | 564 | if (dw2102_properties.i2c_algo == &dw2102_earda_i2c_algo) { |
| 565 | /*dw2102_properties.adapter->tuner_attach = dw2102_tuner_attach;*/ |
| 566 | d->fe = dvb_attach(stv0288_attach, &earda_config, |
| 567 | &d->dev->i2c_adap); |
| 568 | if (d->fe != NULL) { |
| 569 | d->fe->ops.set_voltage = dw210x_set_voltage; |
| 570 | info("Attached stv0288!\n"); |
| 571 | return 0; |
| 572 | } |
| 573 | } |
| 574 | |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 575 | if (dw2102_properties.i2c_algo == &dw2102_i2c_algo) { |
| 576 | /*dw2102_properties.adapter->tuner_attach = dw2102_tuner_attach;*/ |
| 577 | d->fe = dvb_attach(stv0299_attach, &sharp_z0194a_config, |
| 578 | &d->dev->i2c_adap); |
| 579 | if (d->fe != NULL) { |
| 580 | d->fe->ops.set_voltage = dw210x_set_voltage; |
| 581 | info("Attached stv0299!\n"); |
| 582 | return 0; |
| 583 | } |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 584 | } |
| 585 | return -EIO; |
| 586 | } |
| 587 | |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame^] | 588 | static int dw3101_frontend_attach(struct dvb_usb_adapter *d) |
| 589 | { |
| 590 | d->fe = dvb_attach(tda10023_attach, &dw3101_tda10023_config, |
| 591 | &d->dev->i2c_adap, 0x48); |
| 592 | if (d->fe != NULL) { |
| 593 | info("Attached tda10023!\n"); |
| 594 | return 0; |
| 595 | } |
| 596 | return -EIO; |
| 597 | } |
| 598 | |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 599 | static int dw2102_tuner_attach(struct dvb_usb_adapter *adap) |
| 600 | { |
| 601 | dvb_attach(dvb_pll_attach, adap->fe, 0x60, |
| 602 | &adap->dev->i2c_adap, DVB_PLL_OPERA1); |
| 603 | return 0; |
| 604 | } |
| 605 | |
Igor M. Liplianin | 8a4949b | 2008-10-05 09:11:21 -0300 | [diff] [blame] | 606 | static int dw2102_earda_tuner_attach(struct dvb_usb_adapter *adap) |
| 607 | { |
| 608 | dvb_attach(stb6000_attach, adap->fe, 0x61, |
| 609 | &adap->dev->i2c_adap); |
| 610 | |
| 611 | return 0; |
| 612 | } |
| 613 | |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame^] | 614 | static int dw3101_tuner_attach(struct dvb_usb_adapter *adap) |
| 615 | { |
| 616 | dvb_attach(dvb_pll_attach, adap->fe, 0x60, |
| 617 | &adap->dev->i2c_adap, DVB_PLL_TUA6034); |
| 618 | |
| 619 | return 0; |
| 620 | } |
| 621 | |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 622 | static struct dvb_usb_rc_key dw210x_rc_keys[] = { |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 623 | { 0xf8, 0x0a, KEY_Q }, /*power*/ |
| 624 | { 0xf8, 0x0c, KEY_M }, /*mute*/ |
| 625 | { 0xf8, 0x11, KEY_1 }, |
| 626 | { 0xf8, 0x12, KEY_2 }, |
| 627 | { 0xf8, 0x13, KEY_3 }, |
| 628 | { 0xf8, 0x14, KEY_4 }, |
| 629 | { 0xf8, 0x15, KEY_5 }, |
| 630 | { 0xf8, 0x16, KEY_6 }, |
| 631 | { 0xf8, 0x17, KEY_7 }, |
| 632 | { 0xf8, 0x18, KEY_8 }, |
| 633 | { 0xf8, 0x19, KEY_9 }, |
| 634 | { 0xf8, 0x10, KEY_0 }, |
| 635 | { 0xf8, 0x1c, KEY_PAGEUP }, /*ch+*/ |
| 636 | { 0xf8, 0x0f, KEY_PAGEDOWN }, /*ch-*/ |
| 637 | { 0xf8, 0x1a, KEY_O }, /*vol+*/ |
| 638 | { 0xf8, 0x0e, KEY_Z }, /*vol-*/ |
| 639 | { 0xf8, 0x04, KEY_R }, /*rec*/ |
| 640 | { 0xf8, 0x09, KEY_D }, /*fav*/ |
| 641 | { 0xf8, 0x08, KEY_BACKSPACE }, /*rewind*/ |
| 642 | { 0xf8, 0x07, KEY_A }, /*fast*/ |
| 643 | { 0xf8, 0x0b, KEY_P }, /*pause*/ |
| 644 | { 0xf8, 0x02, KEY_ESC }, /*cancel*/ |
| 645 | { 0xf8, 0x03, KEY_G }, /*tab*/ |
| 646 | { 0xf8, 0x00, KEY_UP }, /*up*/ |
| 647 | { 0xf8, 0x1f, KEY_ENTER }, /*ok*/ |
| 648 | { 0xf8, 0x01, KEY_DOWN }, /*down*/ |
| 649 | { 0xf8, 0x05, KEY_C }, /*cap*/ |
| 650 | { 0xf8, 0x06, KEY_S }, /*stop*/ |
| 651 | { 0xf8, 0x40, KEY_F }, /*full*/ |
| 652 | { 0xf8, 0x1e, KEY_W }, /*tvmode*/ |
| 653 | { 0xf8, 0x1b, KEY_B }, /*recall*/ |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 654 | }; |
| 655 | |
Igor M. Liplianin | b42e1d7 | 2009-06-14 19:41:22 -0300 | [diff] [blame] | 656 | static struct dvb_usb_rc_key tevii_rc_keys[] = { |
| 657 | { 0xf8, 0x0a, KEY_POWER }, |
| 658 | { 0xf8, 0x0c, KEY_MUTE }, |
| 659 | { 0xf8, 0x11, KEY_1 }, |
| 660 | { 0xf8, 0x12, KEY_2 }, |
| 661 | { 0xf8, 0x13, KEY_3 }, |
| 662 | { 0xf8, 0x14, KEY_4 }, |
| 663 | { 0xf8, 0x15, KEY_5 }, |
| 664 | { 0xf8, 0x16, KEY_6 }, |
| 665 | { 0xf8, 0x17, KEY_7 }, |
| 666 | { 0xf8, 0x18, KEY_8 }, |
| 667 | { 0xf8, 0x19, KEY_9 }, |
| 668 | { 0xf8, 0x10, KEY_0 }, |
| 669 | { 0xf8, 0x1c, KEY_MENU }, |
| 670 | { 0xf8, 0x0f, KEY_VOLUMEDOWN }, |
| 671 | { 0xf8, 0x1a, KEY_LAST }, |
| 672 | { 0xf8, 0x0e, KEY_OPEN }, |
| 673 | { 0xf8, 0x04, KEY_RECORD }, |
| 674 | { 0xf8, 0x09, KEY_VOLUMEUP }, |
| 675 | { 0xf8, 0x08, KEY_CHANNELUP }, |
| 676 | { 0xf8, 0x07, KEY_PVR }, |
| 677 | { 0xf8, 0x0b, KEY_TIME }, |
| 678 | { 0xf8, 0x02, KEY_RIGHT }, |
| 679 | { 0xf8, 0x03, KEY_LEFT }, |
| 680 | { 0xf8, 0x00, KEY_UP }, |
| 681 | { 0xf8, 0x1f, KEY_OK }, |
| 682 | { 0xf8, 0x01, KEY_DOWN }, |
| 683 | { 0xf8, 0x05, KEY_TUNER }, |
| 684 | { 0xf8, 0x06, KEY_CHANNELDOWN }, |
| 685 | { 0xf8, 0x40, KEY_PLAYPAUSE }, |
| 686 | { 0xf8, 0x1e, KEY_REWIND }, |
| 687 | { 0xf8, 0x1b, KEY_FAVORITES }, |
| 688 | { 0xf8, 0x1d, KEY_BACK }, |
| 689 | { 0xf8, 0x4d, KEY_FASTFORWARD }, |
| 690 | { 0xf8, 0x44, KEY_EPG }, |
| 691 | { 0xf8, 0x4c, KEY_INFO }, |
| 692 | { 0xf8, 0x41, KEY_AB }, |
| 693 | { 0xf8, 0x43, KEY_AUDIO }, |
| 694 | { 0xf8, 0x45, KEY_SUBTITLE }, |
| 695 | { 0xf8, 0x4a, KEY_LIST }, |
| 696 | { 0xf8, 0x46, KEY_F1 }, |
| 697 | { 0xf8, 0x47, KEY_F2 }, |
| 698 | { 0xf8, 0x5e, KEY_F3 }, |
| 699 | { 0xf8, 0x5c, KEY_F4 }, |
| 700 | { 0xf8, 0x52, KEY_F5 }, |
| 701 | { 0xf8, 0x5a, KEY_F6 }, |
| 702 | { 0xf8, 0x56, KEY_MODE }, |
| 703 | { 0xf8, 0x58, KEY_SWITCHVIDEOMODE }, |
| 704 | }; |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 705 | |
Igor M. Liplianin | b42e1d7 | 2009-06-14 19:41:22 -0300 | [diff] [blame] | 706 | static struct dvb_usb_rc_key tbs_rc_keys[] = { |
| 707 | { 0xf8, 0x84, KEY_POWER }, |
| 708 | { 0xf8, 0x94, KEY_MUTE }, |
| 709 | { 0xf8, 0x87, KEY_1 }, |
| 710 | { 0xf8, 0x86, KEY_2 }, |
| 711 | { 0xf8, 0x85, KEY_3 }, |
| 712 | { 0xf8, 0x8b, KEY_4 }, |
| 713 | { 0xf8, 0x8a, KEY_5 }, |
| 714 | { 0xf8, 0x89, KEY_6 }, |
| 715 | { 0xf8, 0x8f, KEY_7 }, |
| 716 | { 0xf8, 0x8e, KEY_8 }, |
| 717 | { 0xf8, 0x8d, KEY_9 }, |
| 718 | { 0xf8, 0x92, KEY_0 }, |
| 719 | { 0xf8, 0x96, KEY_CHANNELUP }, |
| 720 | { 0xf8, 0x91, KEY_CHANNELDOWN }, |
| 721 | { 0xf8, 0x93, KEY_VOLUMEUP }, |
| 722 | { 0xf8, 0x8c, KEY_VOLUMEDOWN }, |
| 723 | { 0xf8, 0x83, KEY_RECORD }, |
| 724 | { 0xf8, 0x98, KEY_PAUSE }, |
| 725 | { 0xf8, 0x99, KEY_OK }, |
| 726 | { 0xf8, 0x9a, KEY_SHUFFLE }, |
| 727 | { 0xf8, 0x81, KEY_UP }, |
| 728 | { 0xf8, 0x90, KEY_LEFT }, |
| 729 | { 0xf8, 0x82, KEY_RIGHT }, |
| 730 | { 0xf8, 0x88, KEY_DOWN }, |
| 731 | { 0xf8, 0x95, KEY_FAVORITES }, |
| 732 | { 0xf8, 0x97, KEY_SUBTITLE }, |
| 733 | { 0xf8, 0x9d, KEY_ZOOM }, |
| 734 | { 0xf8, 0x9f, KEY_EXIT }, |
| 735 | { 0xf8, 0x9e, KEY_MENU }, |
| 736 | { 0xf8, 0x9c, KEY_EPG }, |
| 737 | { 0xf8, 0x80, KEY_PREVIOUS }, |
| 738 | { 0xf8, 0x9b, KEY_MODE } |
| 739 | }; |
| 740 | |
| 741 | static struct dvb_usb_rc_keys_table keys_tables[] = { |
| 742 | { dw210x_rc_keys, ARRAY_SIZE(dw210x_rc_keys) }, |
| 743 | { tevii_rc_keys, ARRAY_SIZE(tevii_rc_keys) }, |
| 744 | { tbs_rc_keys, ARRAY_SIZE(tbs_rc_keys) }, |
| 745 | }; |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 746 | |
| 747 | static int dw2102_rc_query(struct dvb_usb_device *d, u32 *event, int *state) |
| 748 | { |
Igor M. Liplianin | b42e1d7 | 2009-06-14 19:41:22 -0300 | [diff] [blame] | 749 | struct dvb_usb_rc_key *keymap = d->props.rc_key_map; |
| 750 | int keymap_size = d->props.rc_key_map_size; |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 751 | u8 key[2]; |
Igor M. Liplianin | 8a8dad7 | 2009-06-13 08:10:24 -0300 | [diff] [blame] | 752 | struct i2c_msg msg = { |
| 753 | .addr = DW2102_RC_QUERY, |
| 754 | .flags = I2C_M_RD, |
| 755 | .buf = key, |
| 756 | .len = 2 |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 757 | }; |
| 758 | int i; |
Igor M. Liplianin | b42e1d7 | 2009-06-14 19:41:22 -0300 | [diff] [blame] | 759 | /* override keymap */ |
| 760 | if ((ir_keymap > 0) && (ir_keymap <= ARRAY_SIZE(keys_tables))) { |
| 761 | keymap = keys_tables[ir_keymap - 1].rc_keys ; |
| 762 | keymap_size = keys_tables[ir_keymap - 1].rc_keys_size; |
| 763 | } |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 764 | |
| 765 | *state = REMOTE_NO_KEY_PRESSED; |
Igor M. Liplianin | 8a8dad7 | 2009-06-13 08:10:24 -0300 | [diff] [blame] | 766 | if (dw2102_i2c_transfer(&d->i2c_adap, &msg, 1) == 1) { |
Igor M. Liplianin | b42e1d7 | 2009-06-14 19:41:22 -0300 | [diff] [blame] | 767 | for (i = 0; i < keymap_size ; i++) { |
| 768 | if (keymap[i].data == msg.buf[0]) { |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 769 | *state = REMOTE_KEY_PRESSED; |
Igor M. Liplianin | b42e1d7 | 2009-06-14 19:41:22 -0300 | [diff] [blame] | 770 | *event = keymap[i].event; |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 771 | break; |
| 772 | } |
Igor M. Liplianin | 8a8dad7 | 2009-06-13 08:10:24 -0300 | [diff] [blame] | 773 | |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 774 | } |
Igor M. Liplianin | 8a8dad7 | 2009-06-13 08:10:24 -0300 | [diff] [blame] | 775 | |
| 776 | if ((*state) == REMOTE_KEY_PRESSED) |
| 777 | deb_rc("%s: found rc key: %x, %x, event: %x\n", |
| 778 | __func__, key[0], key[1], (*event)); |
| 779 | else if (key[0] != 0xff) |
| 780 | deb_rc("%s: unknown rc key: %x, %x\n", |
| 781 | __func__, key[0], key[1]); |
| 782 | |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 783 | } |
Igor M. Liplianin | 8a8dad7 | 2009-06-13 08:10:24 -0300 | [diff] [blame] | 784 | |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 785 | return 0; |
| 786 | } |
| 787 | |
| 788 | static struct usb_device_id dw2102_table[] = { |
| 789 | {USB_DEVICE(USB_VID_CYPRESS, USB_PID_DW2102)}, |
| 790 | {USB_DEVICE(USB_VID_CYPRESS, 0x2101)}, |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame^] | 791 | {USB_DEVICE(USB_VID_CYPRESS, USB_PID_DW2104)}, |
| 792 | {USB_DEVICE(0x9022, USB_PID_TEVII_S650)}, |
Igor M. Liplianin | 4cc0edf | 2008-11-05 22:12:56 -0300 | [diff] [blame] | 793 | {USB_DEVICE(USB_VID_TERRATEC, USB_PID_CINERGY_S)}, |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame^] | 794 | {USB_DEVICE(USB_VID_CYPRESS, USB_PID_DW3101)}, |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 795 | { } |
| 796 | }; |
| 797 | |
| 798 | MODULE_DEVICE_TABLE(usb, dw2102_table); |
| 799 | |
| 800 | static int dw2102_load_firmware(struct usb_device *dev, |
| 801 | const struct firmware *frmwr) |
| 802 | { |
| 803 | u8 *b, *p; |
| 804 | int ret = 0, i; |
| 805 | u8 reset; |
Igor M. Liplianin | 8a4949b | 2008-10-05 09:11:21 -0300 | [diff] [blame] | 806 | u8 reset16[] = {0, 0, 0, 0, 0, 0, 0}; |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 807 | const struct firmware *fw; |
| 808 | const char *filename = "dvb-usb-dw2101.fw"; |
| 809 | switch (dev->descriptor.idProduct) { |
| 810 | case 0x2101: |
| 811 | ret = request_firmware(&fw, filename, &dev->dev); |
| 812 | if (ret != 0) { |
| 813 | err("did not find the firmware file. (%s) " |
| 814 | "Please see linux/Documentation/dvb/ for more details " |
| 815 | "on firmware-problems.", filename); |
| 816 | return ret; |
| 817 | } |
| 818 | break; |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 819 | default: |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 820 | fw = frmwr; |
| 821 | break; |
| 822 | } |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 823 | info("start downloading DW210X firmware"); |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 824 | p = kmalloc(fw->size, GFP_KERNEL); |
| 825 | reset = 1; |
| 826 | /*stop the CPU*/ |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 827 | dw210x_op_rw(dev, 0xa0, 0x7f92, 0, &reset, 1, DW210X_WRITE_MSG); |
| 828 | 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] | 829 | |
| 830 | if (p != NULL) { |
| 831 | memcpy(p, fw->data, fw->size); |
| 832 | for (i = 0; i < fw->size; i += 0x40) { |
| 833 | b = (u8 *) p + i; |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 834 | if (dw210x_op_rw(dev, 0xa0, i, 0, b , 0x40, |
| 835 | DW210X_WRITE_MSG) != 0x40) { |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 836 | err("error while transferring firmware"); |
| 837 | ret = -EINVAL; |
| 838 | break; |
| 839 | } |
| 840 | } |
| 841 | /* restart the CPU */ |
| 842 | reset = 0; |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 843 | if (ret || dw210x_op_rw(dev, 0xa0, 0x7f92, 0, &reset, 1, |
| 844 | DW210X_WRITE_MSG) != 1) { |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 845 | err("could not restart the USB controller CPU."); |
| 846 | ret = -EINVAL; |
| 847 | } |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 848 | if (ret || dw210x_op_rw(dev, 0xa0, 0xe600, 0, &reset, 1, |
| 849 | DW210X_WRITE_MSG) != 1) { |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 850 | err("could not restart the USB controller CPU."); |
| 851 | ret = -EINVAL; |
| 852 | } |
| 853 | /* init registers */ |
| 854 | switch (dev->descriptor.idProduct) { |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame^] | 855 | case USB_PID_TEVII_S650: |
Igor M. Liplianin | b42e1d7 | 2009-06-14 19:41:22 -0300 | [diff] [blame] | 856 | dw2104_properties.rc_key_map = tevii_rc_keys; |
| 857 | dw2104_properties.rc_key_map_size = |
| 858 | ARRAY_SIZE(tevii_rc_keys); |
| 859 | case USB_PID_DW2104: |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 860 | reset = 1; |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 861 | dw210x_op_rw(dev, 0xc4, 0x0000, 0, &reset, 1, |
| 862 | DW210X_WRITE_MSG); |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame^] | 863 | /* break omitted intentionally */ |
| 864 | case USB_PID_DW3101: |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 865 | reset = 0; |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 866 | dw210x_op_rw(dev, 0xbf, 0x0040, 0, &reset, 0, |
| 867 | DW210X_WRITE_MSG); |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 868 | break; |
Igor M. Liplianin | 4cc0edf | 2008-11-05 22:12:56 -0300 | [diff] [blame] | 869 | case USB_PID_CINERGY_S: |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 870 | case USB_PID_DW2102: |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 871 | dw210x_op_rw(dev, 0xbf, 0x0040, 0, &reset, 0, |
| 872 | DW210X_WRITE_MSG); |
| 873 | dw210x_op_rw(dev, 0xb9, 0x0000, 0, &reset16[0], 2, |
| 874 | DW210X_READ_MSG); |
| 875 | /* check STV0299 frontend */ |
| 876 | dw210x_op_rw(dev, 0xb5, 0, 0, &reset16[0], 2, |
| 877 | DW210X_READ_MSG); |
Igor M. Liplianin | ea023df | 2008-12-04 12:49:23 -0300 | [diff] [blame] | 878 | if ((reset16[0] == 0xa1) || (reset16[0] == 0x80)) { |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 879 | dw2102_properties.i2c_algo = &dw2102_i2c_algo; |
Igor M. Liplianin | 8a4949b | 2008-10-05 09:11:21 -0300 | [diff] [blame] | 880 | dw2102_properties.adapter->tuner_attach = &dw2102_tuner_attach; |
| 881 | break; |
| 882 | } else { |
| 883 | /* check STV0288 frontend */ |
| 884 | reset16[0] = 0xd0; |
| 885 | reset16[1] = 1; |
| 886 | reset16[2] = 0; |
| 887 | dw210x_op_rw(dev, 0xc2, 0, 0, &reset16[0], 3, |
| 888 | DW210X_WRITE_MSG); |
| 889 | dw210x_op_rw(dev, 0xc3, 0xd1, 0, &reset16[0], 3, |
| 890 | DW210X_READ_MSG); |
| 891 | if (reset16[2] == 0x11) { |
| 892 | dw2102_properties.i2c_algo = &dw2102_earda_i2c_algo; |
| 893 | dw2102_properties.adapter->tuner_attach = &dw2102_earda_tuner_attach; |
| 894 | break; |
| 895 | } |
| 896 | } |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 897 | case 0x2101: |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 898 | dw210x_op_rw(dev, 0xbc, 0x0030, 0, &reset16[0], 2, |
| 899 | DW210X_READ_MSG); |
| 900 | dw210x_op_rw(dev, 0xba, 0x0000, 0, &reset16[0], 7, |
| 901 | DW210X_READ_MSG); |
| 902 | dw210x_op_rw(dev, 0xba, 0x0000, 0, &reset16[0], 7, |
| 903 | DW210X_READ_MSG); |
| 904 | dw210x_op_rw(dev, 0xb9, 0x0000, 0, &reset16[0], 2, |
| 905 | DW210X_READ_MSG); |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 906 | break; |
| 907 | } |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame^] | 908 | |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 909 | msleep(100); |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 910 | kfree(p); |
| 911 | } |
| 912 | return ret; |
| 913 | } |
| 914 | |
| 915 | static struct dvb_usb_device_properties dw2102_properties = { |
| 916 | .caps = DVB_USB_IS_AN_I2C_ADAPTER, |
| 917 | .usb_ctrl = DEVICE_SPECIFIC, |
| 918 | .firmware = "dvb-usb-dw2102.fw", |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 919 | .no_reconnect = 1, |
| 920 | |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 921 | .i2c_algo = &dw2102_serit_i2c_algo, |
| 922 | .rc_key_map = dw210x_rc_keys, |
| 923 | .rc_key_map_size = ARRAY_SIZE(dw210x_rc_keys), |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 924 | .rc_interval = 150, |
| 925 | .rc_query = dw2102_rc_query, |
| 926 | |
| 927 | .generic_bulk_ctrl_endpoint = 0x81, |
| 928 | /* parameter for the MPEG2-data transfer */ |
| 929 | .num_adapters = 1, |
| 930 | .download_firmware = dw2102_load_firmware, |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 931 | .read_mac_address = dw210x_read_mac_address, |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame^] | 932 | .adapter = { |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 933 | { |
| 934 | .frontend_attach = dw2102_frontend_attach, |
| 935 | .streaming_ctrl = NULL, |
Igor M. Liplianin | 8a4949b | 2008-10-05 09:11:21 -0300 | [diff] [blame] | 936 | .tuner_attach = NULL, |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 937 | .stream = { |
| 938 | .type = USB_BULK, |
| 939 | .count = 8, |
| 940 | .endpoint = 0x82, |
| 941 | .u = { |
| 942 | .bulk = { |
| 943 | .buffersize = 4096, |
| 944 | } |
| 945 | } |
| 946 | }, |
| 947 | } |
| 948 | }, |
Igor M. Liplianin | 4cc0edf | 2008-11-05 22:12:56 -0300 | [diff] [blame] | 949 | .num_device_descs = 3, |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 950 | .devices = { |
| 951 | {"DVBWorld DVB-S 2102 USB2.0", |
| 952 | {&dw2102_table[0], NULL}, |
| 953 | {NULL}, |
| 954 | }, |
| 955 | {"DVBWorld DVB-S 2101 USB2.0", |
| 956 | {&dw2102_table[1], NULL}, |
| 957 | {NULL}, |
| 958 | }, |
Igor M. Liplianin | 4cc0edf | 2008-11-05 22:12:56 -0300 | [diff] [blame] | 959 | {"TerraTec Cinergy S USB", |
| 960 | {&dw2102_table[4], NULL}, |
| 961 | {NULL}, |
| 962 | }, |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 963 | } |
| 964 | }; |
| 965 | |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 966 | static struct dvb_usb_device_properties dw2104_properties = { |
| 967 | .caps = DVB_USB_IS_AN_I2C_ADAPTER, |
| 968 | .usb_ctrl = DEVICE_SPECIFIC, |
| 969 | .firmware = "dvb-usb-dw2104.fw", |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 970 | .no_reconnect = 1, |
| 971 | |
| 972 | .i2c_algo = &dw2104_i2c_algo, |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 973 | .rc_key_map = dw210x_rc_keys, |
| 974 | .rc_key_map_size = ARRAY_SIZE(dw210x_rc_keys), |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 975 | .rc_interval = 150, |
| 976 | .rc_query = dw2102_rc_query, |
| 977 | |
| 978 | .generic_bulk_ctrl_endpoint = 0x81, |
| 979 | /* parameter for the MPEG2-data transfer */ |
| 980 | .num_adapters = 1, |
| 981 | .download_firmware = dw2102_load_firmware, |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 982 | .read_mac_address = dw210x_read_mac_address, |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 983 | .adapter = { |
| 984 | { |
| 985 | .frontend_attach = dw2104_frontend_attach, |
| 986 | .streaming_ctrl = NULL, |
| 987 | /*.tuner_attach = dw2104_tuner_attach,*/ |
| 988 | .stream = { |
| 989 | .type = USB_BULK, |
| 990 | .count = 8, |
| 991 | .endpoint = 0x82, |
| 992 | .u = { |
| 993 | .bulk = { |
| 994 | .buffersize = 4096, |
| 995 | } |
| 996 | } |
| 997 | }, |
| 998 | } |
| 999 | }, |
| 1000 | .num_device_descs = 2, |
| 1001 | .devices = { |
| 1002 | { "DVBWorld DW2104 USB2.0", |
| 1003 | {&dw2102_table[2], NULL}, |
| 1004 | {NULL}, |
| 1005 | }, |
| 1006 | { "TeVii S650 USB2.0", |
| 1007 | {&dw2102_table[3], NULL}, |
| 1008 | {NULL}, |
| 1009 | }, |
| 1010 | } |
| 1011 | }; |
| 1012 | |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame^] | 1013 | static struct dvb_usb_device_properties dw3101_properties = { |
| 1014 | .caps = DVB_USB_IS_AN_I2C_ADAPTER, |
| 1015 | .usb_ctrl = DEVICE_SPECIFIC, |
| 1016 | .firmware = "dvb-usb-dw3101.fw", |
| 1017 | .no_reconnect = 1, |
| 1018 | |
| 1019 | .i2c_algo = &dw3101_i2c_algo, |
| 1020 | .rc_key_map = dw210x_rc_keys, |
| 1021 | .rc_key_map_size = ARRAY_SIZE(dw210x_rc_keys), |
| 1022 | .rc_interval = 150, |
| 1023 | .rc_query = dw2102_rc_query, |
| 1024 | |
| 1025 | .generic_bulk_ctrl_endpoint = 0x81, |
| 1026 | /* parameter for the MPEG2-data transfer */ |
| 1027 | .num_adapters = 1, |
| 1028 | .download_firmware = dw2102_load_firmware, |
| 1029 | .read_mac_address = dw210x_read_mac_address, |
| 1030 | .adapter = { |
| 1031 | { |
| 1032 | .frontend_attach = dw3101_frontend_attach, |
| 1033 | .streaming_ctrl = NULL, |
| 1034 | .tuner_attach = dw3101_tuner_attach, |
| 1035 | .stream = { |
| 1036 | .type = USB_BULK, |
| 1037 | .count = 8, |
| 1038 | .endpoint = 0x82, |
| 1039 | .u = { |
| 1040 | .bulk = { |
| 1041 | .buffersize = 4096, |
| 1042 | } |
| 1043 | } |
| 1044 | }, |
| 1045 | } |
| 1046 | }, |
| 1047 | .num_device_descs = 1, |
| 1048 | .devices = { |
| 1049 | { "DVBWorld DVB-C 3101 USB2.0", |
| 1050 | {&dw2102_table[5], NULL}, |
| 1051 | {NULL}, |
| 1052 | }, |
| 1053 | } |
| 1054 | }; |
| 1055 | |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1056 | static int dw2102_probe(struct usb_interface *intf, |
| 1057 | const struct usb_device_id *id) |
| 1058 | { |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 1059 | if (0 == dvb_usb_device_init(intf, &dw2102_properties, |
| 1060 | THIS_MODULE, NULL, adapter_nr) || |
| 1061 | 0 == dvb_usb_device_init(intf, &dw2104_properties, |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame^] | 1062 | THIS_MODULE, NULL, adapter_nr) || |
| 1063 | 0 == dvb_usb_device_init(intf, &dw3101_properties, |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 1064 | THIS_MODULE, NULL, adapter_nr)) { |
| 1065 | return 0; |
| 1066 | } |
| 1067 | return -ENODEV; |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1068 | } |
| 1069 | |
| 1070 | static struct usb_driver dw2102_driver = { |
| 1071 | .name = "dw2102", |
| 1072 | .probe = dw2102_probe, |
| 1073 | .disconnect = dvb_usb_device_exit, |
| 1074 | .id_table = dw2102_table, |
| 1075 | }; |
| 1076 | |
| 1077 | static int __init dw2102_module_init(void) |
| 1078 | { |
| 1079 | int ret = usb_register(&dw2102_driver); |
| 1080 | if (ret) |
| 1081 | err("usb_register failed. Error number %d", ret); |
| 1082 | |
| 1083 | return ret; |
| 1084 | } |
| 1085 | |
| 1086 | static void __exit dw2102_module_exit(void) |
| 1087 | { |
| 1088 | usb_deregister(&dw2102_driver); |
| 1089 | } |
| 1090 | |
| 1091 | module_init(dw2102_module_init); |
| 1092 | module_exit(dw2102_module_exit); |
| 1093 | |
| 1094 | MODULE_AUTHOR("Igor M. Liplianin (c) liplianin@me.by"); |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame^] | 1095 | MODULE_DESCRIPTION("Driver for DVBWorld DVB-S 2101, 2102, DVB-S2 2104," |
| 1096 | " DVB-C 3101 USB2.0," |
| 1097 | " TeVii S600, S650 USB2.0 devices"); |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1098 | MODULE_VERSION("0.1"); |
| 1099 | MODULE_LICENSE("GPL"); |