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