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