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