blob: ac70e7b79e218c9cd97adc2efee8024906f7c385 [file] [log] [blame]
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001/* DVB USB framework compliant Linux driver for the
Igor M. Liplianin2f30fb42011-02-25 18:41:23 -03002 * DVBWorld DVB-S 2101, 2102, DVB-S2 2104, DVB-C 3101,
3 * TeVii S600, S630, S650, S660, S480,
4 * Prof 1100, 7500,
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03005 * Geniatech SU3000 Cards
Igor M. Liplianin2f30fb42011-02-25 18:41:23 -03006 * 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 Liplianin7fd48282008-07-20 08:05:50 -030014#include "dw2102.h"
Igor M. Liplianin21b007b2008-09-17 19:19:19 -030015#include "si21xx.h"
Igor M Liplianin7fd48282008-07-20 08:05:50 -030016#include "stv0299.h"
17#include "z0194a.h"
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -030018#include "stv0288.h"
19#include "stb6000.h"
20#include "eds1547.h"
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -030021#include "cx24116.h"
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -030022#include "tda1002x.h"
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -030023#include "mt312.h"
24#include "zl10039.h"
Igor M. Liplianin141cc352009-11-27 14:37:35 -030025#include "ds3000.h"
26#include "stv0900.h"
27#include "stv6110.h"
28#include "stb6100.h"
29#include "stb6100_proc.h"
Igor M Liplianin7fd48282008-07-20 08:05:50 -030030
31#ifndef USB_PID_DW2102
32#define USB_PID_DW2102 0x2102
33#endif
34
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -030035#ifndef USB_PID_DW2104
36#define USB_PID_DW2104 0x2104
37#endif
38
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -030039#ifndef USB_PID_DW3101
40#define USB_PID_DW3101 0x3101
41#endif
42
Igor M. Liplianin4cc0edf2008-11-05 22:12:56 -030043#ifndef USB_PID_CINERGY_S
44#define USB_PID_CINERGY_S 0x0064
45#endif
46
Igor M. Liplianin141cc352009-11-27 14:37:35 -030047#ifndef USB_PID_TEVII_S630
48#define USB_PID_TEVII_S630 0xd630
49#endif
50
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -030051#ifndef USB_PID_TEVII_S650
52#define USB_PID_TEVII_S650 0xd650
53#endif
54
Igor M. Liplianin141cc352009-11-27 14:37:35 -030055#ifndef USB_PID_TEVII_S660
56#define USB_PID_TEVII_S660 0xd660
57#endif
58
Igor M. Liplianine8f50552011-02-25 18:41:23 -030059#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. Liplianin141cc352009-11-27 14:37:35 -030067#ifndef USB_PID_PROF_1100
68#define USB_PID_PROF_1100 0xb012
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -030069#endif
70
Igor M. Liplianin21b007b2008-09-17 19:19:19 -030071#define DW210X_READ_MSG 0
72#define DW210X_WRITE_MSG 1
Igor M Liplianin7fd48282008-07-20 08:05:50 -030073
74#define REG_1F_SYMBOLRATE_BYTE0 0x1f
75#define REG_20_SYMBOLRATE_BYTE1 0x20
76#define REG_21_SYMBOLRATE_BYTE2 0x21
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -030077/* on my own*/
Igor M Liplianin7fd48282008-07-20 08:05:50 -030078#define DW2102_VOLTAGE_CTRL (0x1800)
Igor M. Liplianind2ffc442011-02-25 18:41:22 -030079#define SU3000_STREAM_CTRL (0x1900)
Igor M Liplianin7fd48282008-07-20 08:05:50 -030080#define DW2102_RC_QUERY (0x1a00)
Igor M. Liplianinfa8bae12011-02-25 18:41:22 -030081#define DW2102_LED_CTRL (0x1b00)
Igor M Liplianin7fd48282008-07-20 08:05:50 -030082
Igor M. Liplianin141cc352009-11-27 14:37:35 -030083#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 Chehab2f4f58d2010-11-17 15:46:09 -030087struct rc_map_dvb_usb_table_table {
88 struct rc_map_table *rc_keys;
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -030089 int rc_keys_size;
Igor M Liplianin7fd48282008-07-20 08:05:50 -030090};
91
Igor M. Liplianind2ffc442011-02-25 18:41:22 -030092struct su3000_state {
93 u8 initialized;
94};
95
Igor M. Liplianin52c506e2011-02-25 18:41:23 -030096struct s6x0_state {
97 int (*old_set_voltage)(struct dvb_frontend *f, fe_sec_voltage_t v);
98};
99
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300100/* debug */
101static int dvb_usb_dw2102_debug;
102module_param_named(debug, dvb_usb_dw2102_debug, int, 0644);
Igor M. Liplianin8a8dad72009-06-13 08:10:24 -0300103MODULE_PARM_DESC(debug, "set debugging level (1=info 2=xfer 4=rc(or-able))."
104 DVB_USB_DEBUG_STATUS);
105
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -0300106/* keymaps */
107static int ir_keymap;
108module_param_named(keymap, ir_keymap, int, 0644);
Igor M. Liplianinfeb16e92011-02-25 18:41:22 -0300109MODULE_PARM_DESC(keymap, "set keymap 0=default 1=dvbworld 2=tevii 3=tbs ..."
110 " 256=none");
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300111
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300112/* demod probe */
113static int demod_probe = 1;
114module_param_named(demod, demod_probe, int, 0644);
115MODULE_PARM_DESC(demod, "demod to probe (1=cx24116 2=stv0903+stv6110 "
116 "4=stv0903+stb6100(or-able)).");
117
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300118DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
119
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300120static int dw210x_op_rw(struct usb_device *dev, u8 request, u16 value,
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300121 u16 index, u8 * data, u16 len, int flags)
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300122{
123 int ret;
124 u8 u8buf[len];
125
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300126 unsigned int pipe = (flags == DW210X_READ_MSG) ?
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300127 usb_rcvctrlpipe(dev, 0) : usb_sndctrlpipe(dev, 0);
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300128 u8 request_type = (flags == DW210X_READ_MSG) ? USB_DIR_IN : USB_DIR_OUT;
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300129
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300130 if (flags == DW210X_WRITE_MSG)
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300131 memcpy(u8buf, data, len);
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300132 ret = usb_control_msg(dev, pipe, request, request_type | USB_TYPE_VENDOR,
133 value, index , u8buf, len, 2000);
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300134
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300135 if (flags == DW210X_READ_MSG)
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300136 memcpy(data, u8buf, len);
137 return ret;
138}
139
140/* I2C */
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300141static int dw2102_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
142 int num)
143{
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -0300144 struct dvb_usb_device *d = i2c_get_adapdata(adap);
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300145 int i = 0, ret = 0;
146 u8 buf6[] = {0x2c, 0x05, 0xc0, 0, 0, 0, 0};
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300147 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 Liplianin7fd48282008-07-20 08:05:50 -0300157 value = msg[0].buf[0];/* register */
158 for (i = 0; i < msg[1].len; i++) {
159 value = value + i;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300160 ret = dw210x_op_rw(d->udev, 0xb5, value, 0,
161 buf6, 2, DW210X_READ_MSG);
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300162 msg[1].buf[i] = buf6[0];
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300163 }
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. Liplianin21b007b2008-09-17 19:19:19 -0300172 ret = dw210x_op_rw(d->udev, 0xb2, 0, 0,
173 buf6, 3, DW210X_WRITE_MSG);
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300174 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. Liplianin21b007b2008-09-17 19:19:19 -0300185 ret = dw210x_op_rw(d->udev, 0xb2, 0, 0,
186 buf6, 7, DW210X_WRITE_MSG);
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300187 } else {
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300188 /* read from tuner */
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300189 ret = dw210x_op_rw(d->udev, 0xb5, 0, 0,
190 buf6, 1, DW210X_READ_MSG);
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300191 msg[0].buf[0] = buf6[0];
192 }
193 break;
194 case (DW2102_RC_QUERY):
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300195 ret = dw210x_op_rw(d->udev, 0xb8, 0, 0,
196 buf6, 2, DW210X_READ_MSG);
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300197 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. Liplianin21b007b2008-09-17 19:19:19 -0300203 ret = dw210x_op_rw(d->udev, 0xb2, 0, 0,
204 buf6, 2, DW210X_WRITE_MSG);
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300205 break;
206 }
207
208 break;
209 }
210
211 mutex_unlock(&d->i2c_mutex);
212 return num;
213}
214
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300215static 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. Liplianin141cc352009-11-27 14:37:35 -0300230 buf6[0] = msg[0].addr << 1;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300231 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. Liplianin141cc352009-11-27 14:37:35 -0300245 buf6[0] = msg[0].addr << 1;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300246 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. Liplianin1dac77c2009-06-14 20:51:45 -0300270
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -0300271static 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. Liplianin1dac77c2009-06-14 20:51:45 -0300285 u8 ibuf[msg[1].len + 2], obuf[3];
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300286 obuf[0] = msg[0].addr << 1;
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -0300287 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. Liplianin141cc352009-11-27 14:37:35 -0300303 obuf[0] = msg[0].addr << 1;
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -0300304 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. Liplianin141cc352009-11-27 14:37:35 -0300313 obuf[0] = msg[0].addr << 1;
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -0300314 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. Liplianin21b007b2008-09-17 19:19:19 -0300343
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300344static 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. Liplianin141cc352009-11-27 14:37:35 -0300348 int len, i, j;
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300349
350 if (!d)
351 return -ENODEV;
352 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
353 return -EAGAIN;
354
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300355 for (j = 0; j < num; j++) {
356 switch (msg[j].addr) {
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300357 case(DW2102_RC_QUERY): {
358 u8 ibuf[2];
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300359 ret = dw210x_op_rw(d->udev, 0xb8, 0, 0,
360 ibuf, 2, DW210X_READ_MSG);
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300361 memcpy(msg[j].buf, ibuf , 2);
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300362 break;
363 }
364 case(DW2102_VOLTAGE_CTRL): {
365 u8 obuf[2];
366 obuf[0] = 0x30;
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300367 obuf[1] = msg[j].buf[0];
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300368 ret = dw210x_op_rw(d->udev, 0xb2, 0, 0,
369 obuf, 2, DW210X_WRITE_MSG);
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300370 break;
371 }
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300372 /*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. Liplianinfe03d5e2008-09-08 17:16:40 -0300418 }
419
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300420 }
421
422 mutex_unlock(&d->i2c_mutex);
423 return num;
424}
425
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -0300426static 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. Liplianin141cc352009-11-27 14:37:35 -0300489static int s6x0_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300490 int num)
491{
492 struct dvb_usb_device *d = i2c_get_adapdata(adap);
Julia Lawall21ead032009-12-22 18:00:07 -0300493 struct usb_device *udev;
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300494 int ret = 0;
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300495 int len, i, j;
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300496
497 if (!d)
498 return -ENODEV;
Julia Lawall21ead032009-12-22 18:00:07 -0300499 udev = d->udev;
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300500 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
501 return -EAGAIN;
502
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300503 for (j = 0; j < num; j++) {
504 switch (msg[j].addr) {
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300505 case (DW2102_RC_QUERY): {
Igor M. Liplianin5a530cb2011-02-25 18:41:23 -0300506 u8 ibuf[5];
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300507 ret = dw210x_op_rw(d->udev, 0xb8, 0, 0,
Igor M. Liplianin5a530cb2011-02-25 18:41:23 -0300508 ibuf, 5, DW210X_READ_MSG);
509 memcpy(msg[j].buf, ibuf + 3, 2);
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300510 break;
511 }
512 case (DW2102_VOLTAGE_CTRL): {
513 u8 obuf[2];
Igor M. Liplianincd79d332009-12-14 20:24:56 -0300514
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. Liplianin141cc352009-11-27 14:37:35 -0300519 obuf[0] = 3;
Igor M. Liplianincd79d332009-12-14 20:24:56 -0300520 obuf[1] = msg[j].buf[0];/* 13v-18v */
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300521 ret = dw210x_op_rw(d->udev, 0x8a, 0, 0,
522 obuf, 2, DW210X_WRITE_MSG);
523 break;
524 }
Igor M. Liplianinfa8bae12011-02-25 18:41:22 -0300525 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. Liplianin141cc352009-11-27 14:37:35 -0300534 /*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. Liplianina84adf42011-02-27 16:18:38 -0300567 } else if (j < (num - 1)) {
Igor M. Liplianincd79d332009-12-14 20:24:56 -0300568 /* write register addr before read */
569 u8 obuf[msg[j].len + 2];
570 obuf[0] = msg[j + 1].len;
571 obuf[1] = (msg[j].addr << 1);
572 memcpy(obuf + 2, msg[j].buf, msg[j].len);
Igor M. Liplianina84adf42011-02-27 16:18:38 -0300573 ret = dw210x_op_rw(d->udev,
574 udev->descriptor.idProduct ==
575 0x7500 ? 0x92 : 0x90, 0, 0,
Igor M. Liplianincd79d332009-12-14 20:24:56 -0300576 obuf, msg[j].len + 2,
577 DW210X_WRITE_MSG);
578 break;
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300579 } else {
580 /* write registers */
581 u8 obuf[msg[j].len + 2];
582 obuf[0] = msg[j].len + 1;
583 obuf[1] = (msg[j].addr << 1);
584 memcpy(obuf + 2, msg[j].buf, msg[j].len);
Igor M. Liplianina84adf42011-02-27 16:18:38 -0300585 ret = dw210x_op_rw(d->udev, 0x80, 0, 0,
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300586 obuf, msg[j].len + 2,
587 DW210X_WRITE_MSG);
588 break;
589 }
590 break;
591 }
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300592 }
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300593 }
594
595 mutex_unlock(&d->i2c_mutex);
596 return num;
597}
598
Igor M. Liplianind2ffc442011-02-25 18:41:22 -0300599static int su3000_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
600 int num)
601{
602 struct dvb_usb_device *d = i2c_get_adapdata(adap);
603 u8 obuf[0x40], ibuf[0x40];
604
605 if (!d)
606 return -ENODEV;
607 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
608 return -EAGAIN;
609
610 switch (num) {
611 case 1:
612 switch (msg[0].addr) {
613 case SU3000_STREAM_CTRL:
614 obuf[0] = msg[0].buf[0] + 0x36;
615 obuf[1] = 3;
616 obuf[2] = 0;
617 if (dvb_usb_generic_rw(d, obuf, 3, ibuf, 0, 0) < 0)
618 err("i2c transfer failed.");
619 break;
620 case DW2102_RC_QUERY:
621 obuf[0] = 0x10;
622 if (dvb_usb_generic_rw(d, obuf, 1, ibuf, 2, 0) < 0)
623 err("i2c transfer failed.");
624 msg[0].buf[1] = ibuf[0];
625 msg[0].buf[0] = ibuf[1];
626 break;
627 default:
628 /* always i2c write*/
629 obuf[0] = 0x08;
630 obuf[1] = msg[0].addr;
631 obuf[2] = msg[0].len;
632
633 memcpy(&obuf[3], msg[0].buf, msg[0].len);
634
635 if (dvb_usb_generic_rw(d, obuf, msg[0].len + 3,
636 ibuf, 1, 0) < 0)
637 err("i2c transfer failed.");
638
639 }
640 break;
641 case 2:
642 /* always i2c read */
643 obuf[0] = 0x09;
644 obuf[1] = msg[0].len;
645 obuf[2] = msg[1].len;
646 obuf[3] = msg[0].addr;
647 memcpy(&obuf[4], msg[0].buf, msg[0].len);
648
649 if (dvb_usb_generic_rw(d, obuf, msg[0].len + 4,
650 ibuf, msg[1].len + 1, 0) < 0)
651 err("i2c transfer failed.");
652
653 memcpy(msg[1].buf, &ibuf[1], msg[1].len);
654 break;
655 default:
656 warn("more than 2 i2c messages at a time is not handled yet.");
657 break;
658 }
659 mutex_unlock(&d->i2c_mutex);
660 return num;
661}
662
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300663static u32 dw210x_i2c_func(struct i2c_adapter *adapter)
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300664{
665 return I2C_FUNC_I2C;
666}
667
668static struct i2c_algorithm dw2102_i2c_algo = {
669 .master_xfer = dw2102_i2c_transfer,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300670 .functionality = dw210x_i2c_func,
671};
672
673static struct i2c_algorithm dw2102_serit_i2c_algo = {
674 .master_xfer = dw2102_serit_i2c_transfer,
675 .functionality = dw210x_i2c_func,
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300676};
677
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -0300678static struct i2c_algorithm dw2102_earda_i2c_algo = {
679 .master_xfer = dw2102_earda_i2c_transfer,
680 .functionality = dw210x_i2c_func,
681};
682
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300683static struct i2c_algorithm dw2104_i2c_algo = {
684 .master_xfer = dw2104_i2c_transfer,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300685 .functionality = dw210x_i2c_func,
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300686};
687
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -0300688static struct i2c_algorithm dw3101_i2c_algo = {
689 .master_xfer = dw3101_i2c_transfer,
690 .functionality = dw210x_i2c_func,
691};
692
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300693static struct i2c_algorithm s6x0_i2c_algo = {
694 .master_xfer = s6x0_i2c_transfer,
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300695 .functionality = dw210x_i2c_func,
696};
697
Igor M. Liplianind2ffc442011-02-25 18:41:22 -0300698static struct i2c_algorithm su3000_i2c_algo = {
699 .master_xfer = su3000_i2c_transfer,
700 .functionality = dw210x_i2c_func,
701};
702
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300703static int dw210x_read_mac_address(struct dvb_usb_device *d, u8 mac[6])
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300704{
705 int i;
706 u8 ibuf[] = {0, 0};
707 u8 eeprom[256], eepromline[16];
708
709 for (i = 0; i < 256; i++) {
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300710 if (dw210x_op_rw(d->udev, 0xb6, 0xa0 , i, ibuf, 2, DW210X_READ_MSG) < 0) {
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300711 err("read eeprom failed.");
712 return -1;
713 } else {
714 eepromline[i%16] = ibuf[0];
715 eeprom[i] = ibuf[0];
716 }
717 if ((i % 16) == 15) {
718 deb_xfer("%02x: ", i - 15);
719 debug_dump(eepromline, 16, deb_xfer);
720 }
721 }
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -0300722
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300723 memcpy(mac, eeprom + 8, 6);
724 return 0;
725};
726
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300727static int s6x0_read_mac_address(struct dvb_usb_device *d, u8 mac[6])
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300728{
729 int i, ret;
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300730 u8 ibuf[] = { 0 }, obuf[] = { 0 };
731 u8 eeprom[256], eepromline[16];
732 struct i2c_msg msg[] = {
733 {
734 .addr = 0xa0 >> 1,
735 .flags = 0,
736 .buf = obuf,
737 .len = 1,
738 }, {
739 .addr = 0xa0 >> 1,
740 .flags = I2C_M_RD,
741 .buf = ibuf,
742 .len = 1,
743 }
744 };
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300745
746 for (i = 0; i < 256; i++) {
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300747 obuf[0] = i;
748 ret = s6x0_i2c_transfer(&d->i2c_adap, msg, 2);
749 if (ret != 2) {
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300750 err("read eeprom failed.");
751 return -1;
752 } else {
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300753 eepromline[i % 16] = ibuf[0];
754 eeprom[i] = ibuf[0];
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300755 }
756
757 if ((i % 16) == 15) {
758 deb_xfer("%02x: ", i - 15);
759 debug_dump(eepromline, 16, deb_xfer);
760 }
761 }
762
763 memcpy(mac, eeprom + 16, 6);
764 return 0;
765};
766
Igor M. Liplianind2ffc442011-02-25 18:41:22 -0300767static int su3000_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
768{
769 static u8 command_start[] = {0x00};
770 static u8 command_stop[] = {0x01};
771 struct i2c_msg msg = {
772 .addr = SU3000_STREAM_CTRL,
773 .flags = 0,
774 .buf = onoff ? command_start : command_stop,
775 .len = 1
776 };
777
778 i2c_transfer(&adap->dev->i2c_adap, &msg, 1);
779
780 return 0;
781}
782
783static int su3000_power_ctrl(struct dvb_usb_device *d, int i)
784{
785 struct su3000_state *state = (struct su3000_state *)d->priv;
786 u8 obuf[] = {0xde, 0};
787
788 info("%s: %d, initialized %d\n", __func__, i, state->initialized);
789
790 if (i && !state->initialized) {
791 state->initialized = 1;
792 /* reset board */
793 dvb_usb_generic_rw(d, obuf, 2, NULL, 0, 0);
794 }
795
796 return 0;
797}
798
799static int su3000_read_mac_address(struct dvb_usb_device *d, u8 mac[6])
800{
801 int i;
802 u8 obuf[] = { 0x1f, 0xf0 };
803 u8 ibuf[] = { 0 };
804 struct i2c_msg msg[] = {
805 {
806 .addr = 0x51,
807 .flags = 0,
808 .buf = obuf,
809 .len = 2,
810 }, {
811 .addr = 0x51,
812 .flags = I2C_M_RD,
813 .buf = ibuf,
814 .len = 1,
815
816 }
817 };
818
819 for (i = 0; i < 6; i++) {
820 obuf[1] = 0xf0 + i;
821 if (i2c_transfer(&d->i2c_adap, msg, 2) != 2)
822 break;
823 else
824 mac[i] = ibuf[0];
825
826 debug_dump(mac, 6, printk);
827 }
828
829 return 0;
830}
831
832static int su3000_identify_state(struct usb_device *udev,
833 struct dvb_usb_device_properties *props,
834 struct dvb_usb_device_description **desc,
835 int *cold)
836{
837 info("%s\n", __func__);
838
839 *cold = 0;
840 return 0;
841}
842
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300843static int dw210x_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300844{
Igor M. Liplianincd79d332009-12-14 20:24:56 -0300845 static u8 command_13v[] = {0x00, 0x01};
846 static u8 command_18v[] = {0x01, 0x01};
847 static u8 command_off[] = {0x00, 0x00};
848 struct i2c_msg msg = {
849 .addr = DW2102_VOLTAGE_CTRL,
850 .flags = 0,
851 .buf = command_off,
852 .len = 2,
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300853 };
854
855 struct dvb_usb_adapter *udev_adap =
856 (struct dvb_usb_adapter *)(fe->dvb->priv);
857 if (voltage == SEC_VOLTAGE_18)
Igor M. Liplianincd79d332009-12-14 20:24:56 -0300858 msg.buf = command_18v;
859 else if (voltage == SEC_VOLTAGE_13)
860 msg.buf = command_13v;
861
862 i2c_transfer(&udev_adap->dev->i2c_adap, &msg, 1);
863
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300864 return 0;
865}
866
Igor M. Liplianin52c506e2011-02-25 18:41:23 -0300867static int s660_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
868{
869 struct dvb_usb_adapter *d =
870 (struct dvb_usb_adapter *)(fe->dvb->priv);
871 struct s6x0_state *st = (struct s6x0_state *)d->dev->priv;
872
873 dw210x_set_voltage(fe, voltage);
874 if (st->old_set_voltage)
875 st->old_set_voltage(fe, voltage);
876
877 return 0;
878}
879
Igor M. Liplianinfa8bae12011-02-25 18:41:22 -0300880static void dw210x_led_ctrl(struct dvb_frontend *fe, int offon)
881{
882 static u8 led_off[] = { 0 };
883 static u8 led_on[] = { 1 };
884 struct i2c_msg msg = {
885 .addr = DW2102_LED_CTRL,
886 .flags = 0,
887 .buf = led_off,
888 .len = 1
889 };
890 struct dvb_usb_adapter *udev_adap =
891 (struct dvb_usb_adapter *)(fe->dvb->priv);
892
893 if (offon)
894 msg.buf = led_on;
895 i2c_transfer(&udev_adap->dev->i2c_adap, &msg, 1);
896}
897
Igor M. Liplianind4305c62008-10-17 13:45:55 -0300898static struct stv0299_config sharp_z0194a_config = {
899 .demod_address = 0x68,
900 .inittab = sharp_z0194a_inittab,
901 .mclk = 88000000UL,
902 .invert = 1,
903 .skip_reinit = 0,
904 .lock_output = STV0299_LOCKOUTPUT_1,
905 .volt13_op0_op1 = STV0299_VOLT13_OP1,
906 .min_delay_ms = 100,
907 .set_symbol_rate = sharp_z0194a_set_symbol_rate,
908};
909
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300910static struct cx24116_config dw2104_config = {
911 .demod_address = 0x55,
Igor M. Liplianincc8c4f32008-09-09 13:57:47 -0300912 .mpg_clk_pos_pol = 0x01,
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300913};
914
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300915static struct si21xx_config serit_sp1511lhb_config = {
916 .demod_address = 0x68,
917 .min_delay_ms = 100,
918
919};
920
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -0300921static struct tda10023_config dw3101_tda10023_config = {
922 .demod_address = 0x0c,
923 .invert = 1,
924};
925
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300926static struct mt312_config zl313_config = {
927 .demod_address = 0x0e,
928};
929
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300930static struct ds3000_config dw2104_ds3000_config = {
931 .demod_address = 0x68,
932};
933
934static struct stv0900_config dw2104a_stv0900_config = {
935 .demod_address = 0x6a,
936 .demod_mode = 0,
937 .xtal = 27000000,
938 .clkmode = 3,/* 0-CLKI, 2-XTALI, else AUTO */
939 .diseqc_mode = 2,/* 2/3 PWM */
940 .tun1_maddress = 0,/* 0x60 */
941 .tun1_adc = 0,/* 2 Vpp */
942 .path1_mode = 3,
943};
944
945static struct stb6100_config dw2104a_stb6100_config = {
946 .tuner_address = 0x60,
947 .refclock = 27000000,
948};
949
950static struct stv0900_config dw2104_stv0900_config = {
951 .demod_address = 0x68,
952 .demod_mode = 0,
953 .xtal = 8000000,
954 .clkmode = 3,
955 .diseqc_mode = 2,
956 .tun1_maddress = 0,
957 .tun1_adc = 1,/* 1 Vpp */
958 .path1_mode = 3,
959};
960
961static struct stv6110_config dw2104_stv6110_config = {
962 .i2c_address = 0x60,
963 .mclk = 16000000,
964 .clk_div = 1,
965};
966
Igor M. Liplianincd79d332009-12-14 20:24:56 -0300967static struct stv0900_config prof_7500_stv0900_config = {
968 .demod_address = 0x6a,
969 .demod_mode = 0,
970 .xtal = 27000000,
971 .clkmode = 3,/* 0-CLKI, 2-XTALI, else AUTO */
972 .diseqc_mode = 2,/* 2/3 PWM */
973 .tun1_maddress = 0,/* 0x60 */
974 .tun1_adc = 0,/* 2 Vpp */
975 .path1_mode = 3,
976 .tun1_type = 3,
Igor M. Liplianinfa8bae12011-02-25 18:41:22 -0300977 .set_lock_led = dw210x_led_ctrl,
Igor M. Liplianincd79d332009-12-14 20:24:56 -0300978};
979
Igor M. Liplianind2ffc442011-02-25 18:41:22 -0300980static struct ds3000_config su3000_ds3000_config = {
981 .demod_address = 0x68,
982 .ci_mode = 1,
983};
984
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300985static int dw2104_frontend_attach(struct dvb_usb_adapter *d)
986{
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300987 struct dvb_tuner_ops *tuner_ops = NULL;
988
989 if (demod_probe & 4) {
990 d->fe = dvb_attach(stv0900_attach, &dw2104a_stv0900_config,
991 &d->dev->i2c_adap, 0);
992 if (d->fe != NULL) {
993 if (dvb_attach(stb6100_attach, d->fe,
994 &dw2104a_stb6100_config,
995 &d->dev->i2c_adap)) {
996 tuner_ops = &d->fe->ops.tuner_ops;
997 tuner_ops->set_frequency = stb6100_set_freq;
998 tuner_ops->get_frequency = stb6100_get_freq;
999 tuner_ops->set_bandwidth = stb6100_set_bandw;
1000 tuner_ops->get_bandwidth = stb6100_get_bandw;
1001 d->fe->ops.set_voltage = dw210x_set_voltage;
1002 info("Attached STV0900+STB6100!\n");
1003 return 0;
1004 }
1005 }
1006 }
1007
1008 if (demod_probe & 2) {
1009 d->fe = dvb_attach(stv0900_attach, &dw2104_stv0900_config,
1010 &d->dev->i2c_adap, 0);
1011 if (d->fe != NULL) {
1012 if (dvb_attach(stv6110_attach, d->fe,
1013 &dw2104_stv6110_config,
1014 &d->dev->i2c_adap)) {
1015 d->fe->ops.set_voltage = dw210x_set_voltage;
1016 info("Attached STV0900+STV6110A!\n");
1017 return 0;
1018 }
1019 }
1020 }
1021
1022 if (demod_probe & 1) {
1023 d->fe = dvb_attach(cx24116_attach, &dw2104_config,
1024 &d->dev->i2c_adap);
1025 if (d->fe != NULL) {
1026 d->fe->ops.set_voltage = dw210x_set_voltage;
1027 info("Attached cx24116!\n");
1028 return 0;
1029 }
1030 }
1031
1032 d->fe = dvb_attach(ds3000_attach, &dw2104_ds3000_config,
1033 &d->dev->i2c_adap);
1034 if (d->fe != NULL) {
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001035 d->fe->ops.set_voltage = dw210x_set_voltage;
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001036 info("Attached DS3000!\n");
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001037 return 0;
1038 }
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001039
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001040 return -EIO;
1041}
1042
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001043static struct dvb_usb_device_properties dw2102_properties;
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -03001044static struct dvb_usb_device_properties dw2104_properties;
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001045static struct dvb_usb_device_properties s6x0_properties;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001046
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001047static int dw2102_frontend_attach(struct dvb_usb_adapter *d)
1048{
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001049 if (dw2102_properties.i2c_algo == &dw2102_serit_i2c_algo) {
1050 /*dw2102_properties.adapter->tuner_attach = NULL;*/
1051 d->fe = dvb_attach(si21xx_attach, &serit_sp1511lhb_config,
1052 &d->dev->i2c_adap);
1053 if (d->fe != NULL) {
1054 d->fe->ops.set_voltage = dw210x_set_voltage;
1055 info("Attached si21xx!\n");
1056 return 0;
1057 }
1058 }
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001059
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -03001060 if (dw2102_properties.i2c_algo == &dw2102_earda_i2c_algo) {
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -03001061 d->fe = dvb_attach(stv0288_attach, &earda_config,
1062 &d->dev->i2c_adap);
1063 if (d->fe != NULL) {
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001064 if (dvb_attach(stb6000_attach, d->fe, 0x61,
1065 &d->dev->i2c_adap)) {
1066 d->fe->ops.set_voltage = dw210x_set_voltage;
1067 info("Attached stv0288!\n");
1068 return 0;
1069 }
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -03001070 }
1071 }
1072
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001073 if (dw2102_properties.i2c_algo == &dw2102_i2c_algo) {
1074 /*dw2102_properties.adapter->tuner_attach = dw2102_tuner_attach;*/
1075 d->fe = dvb_attach(stv0299_attach, &sharp_z0194a_config,
1076 &d->dev->i2c_adap);
1077 if (d->fe != NULL) {
1078 d->fe->ops.set_voltage = dw210x_set_voltage;
1079 info("Attached stv0299!\n");
1080 return 0;
1081 }
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001082 }
1083 return -EIO;
1084}
1085
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001086static int dw3101_frontend_attach(struct dvb_usb_adapter *d)
1087{
1088 d->fe = dvb_attach(tda10023_attach, &dw3101_tda10023_config,
1089 &d->dev->i2c_adap, 0x48);
1090 if (d->fe != NULL) {
1091 info("Attached tda10023!\n");
1092 return 0;
1093 }
1094 return -EIO;
1095}
1096
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001097static int zl100313_frontend_attach(struct dvb_usb_adapter *d)
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001098{
1099 d->fe = dvb_attach(mt312_attach, &zl313_config,
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001100 &d->dev->i2c_adap);
1101 if (d->fe != NULL) {
1102 if (dvb_attach(zl10039_attach, d->fe, 0x60,
1103 &d->dev->i2c_adap)) {
1104 d->fe->ops.set_voltage = dw210x_set_voltage;
1105 info("Attached zl100313+zl10039!\n");
1106 return 0;
1107 }
1108 }
1109
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001110 return -EIO;
1111}
1112
1113static int stv0288_frontend_attach(struct dvb_usb_adapter *d)
1114{
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001115 d->fe = dvb_attach(stv0288_attach, &earda_config,
1116 &d->dev->i2c_adap);
1117 if (d->fe != NULL) {
1118 if (dvb_attach(stb6000_attach, d->fe, 0x61,
1119 &d->dev->i2c_adap)) {
1120 d->fe->ops.set_voltage = dw210x_set_voltage;
1121 info("Attached stv0288+stb6000!\n");
1122 return 0;
1123 }
1124 }
1125
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001126 return -EIO;
1127}
1128
1129static int ds3000_frontend_attach(struct dvb_usb_adapter *d)
1130{
Igor M. Liplianin52c506e2011-02-25 18:41:23 -03001131 struct s6x0_state *st = (struct s6x0_state *)d->dev->priv;
Igor M. Liplianin5a530cb2011-02-25 18:41:23 -03001132 u8 obuf[] = {7, 1};
Igor M. Liplianin52c506e2011-02-25 18:41:23 -03001133
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001134 d->fe = dvb_attach(ds3000_attach, &dw2104_ds3000_config,
1135 &d->dev->i2c_adap);
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001136
Igor M. Liplianin52c506e2011-02-25 18:41:23 -03001137 if (d->fe == NULL)
1138 return -EIO;
1139
1140 st->old_set_voltage = d->fe->ops.set_voltage;
1141 d->fe->ops.set_voltage = s660_set_voltage;
Igor M. Liplianin5a530cb2011-02-25 18:41:23 -03001142
1143 dw210x_op_rw(d->dev->udev, 0x8a, 0, 0, obuf, 2, DW210X_WRITE_MSG);
1144
Igor M. Liplianin52c506e2011-02-25 18:41:23 -03001145 info("Attached ds3000+ds2020!\n");
1146
1147 return 0;
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001148}
1149
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001150static int prof_7500_frontend_attach(struct dvb_usb_adapter *d)
1151{
Igor M. Liplianin4e59df82011-02-25 18:41:23 -03001152 u8 obuf[] = {7, 1};
1153
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001154 d->fe = dvb_attach(stv0900_attach, &prof_7500_stv0900_config,
1155 &d->dev->i2c_adap, 0);
1156 if (d->fe == NULL)
1157 return -EIO;
Igor M. Liplianin4e59df82011-02-25 18:41:23 -03001158
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001159 d->fe->ops.set_voltage = dw210x_set_voltage;
1160
Igor M. Liplianin4e59df82011-02-25 18:41:23 -03001161 dw210x_op_rw(d->dev->udev, 0x8a, 0, 0, obuf, 2, DW210X_WRITE_MSG);
1162
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001163 info("Attached STV0900+STB6100A!\n");
1164
1165 return 0;
1166}
1167
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001168static int su3000_frontend_attach(struct dvb_usb_adapter *d)
1169{
1170 u8 obuf[3] = { 0xe, 0x80, 0 };
1171 u8 ibuf[] = { 0 };
1172
1173 if (dvb_usb_generic_rw(d->dev, obuf, 3, ibuf, 1, 0) < 0)
1174 err("command 0x0e transfer failed.");
1175
1176 obuf[0] = 0xe;
1177 obuf[1] = 0x83;
1178 obuf[2] = 0;
1179
1180 if (dvb_usb_generic_rw(d->dev, obuf, 3, ibuf, 1, 0) < 0)
1181 err("command 0x0e transfer failed.");
1182
1183 obuf[0] = 0xe;
1184 obuf[1] = 0x83;
1185 obuf[2] = 1;
1186
1187 if (dvb_usb_generic_rw(d->dev, obuf, 3, ibuf, 1, 0) < 0)
1188 err("command 0x0e transfer failed.");
1189
1190 obuf[0] = 0x51;
1191
1192 if (dvb_usb_generic_rw(d->dev, obuf, 1, ibuf, 1, 0) < 0)
1193 err("command 0x51 transfer failed.");
1194
1195 d->fe = dvb_attach(ds3000_attach, &su3000_ds3000_config,
1196 &d->dev->i2c_adap);
1197 if (d->fe == NULL)
1198 return -EIO;
1199
1200 info("Attached DS3000!\n");
1201
1202 return 0;
1203}
1204
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001205static int dw2102_tuner_attach(struct dvb_usb_adapter *adap)
1206{
1207 dvb_attach(dvb_pll_attach, adap->fe, 0x60,
1208 &adap->dev->i2c_adap, DVB_PLL_OPERA1);
1209 return 0;
1210}
1211
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001212static int dw3101_tuner_attach(struct dvb_usb_adapter *adap)
1213{
1214 dvb_attach(dvb_pll_attach, adap->fe, 0x60,
1215 &adap->dev->i2c_adap, DVB_PLL_TUA6034);
1216
1217 return 0;
1218}
1219
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03001220static struct rc_map_table rc_map_dw210x_table[] = {
Mauro Carvalho Chehab2e365882009-08-29 15:19:31 -03001221 { 0xf80a, KEY_Q }, /*power*/
1222 { 0xf80c, KEY_M }, /*mute*/
1223 { 0xf811, KEY_1 },
1224 { 0xf812, KEY_2 },
1225 { 0xf813, KEY_3 },
1226 { 0xf814, KEY_4 },
1227 { 0xf815, KEY_5 },
1228 { 0xf816, KEY_6 },
1229 { 0xf817, KEY_7 },
1230 { 0xf818, KEY_8 },
1231 { 0xf819, KEY_9 },
1232 { 0xf810, KEY_0 },
1233 { 0xf81c, KEY_PAGEUP }, /*ch+*/
1234 { 0xf80f, KEY_PAGEDOWN }, /*ch-*/
1235 { 0xf81a, KEY_O }, /*vol+*/
1236 { 0xf80e, KEY_Z }, /*vol-*/
1237 { 0xf804, KEY_R }, /*rec*/
1238 { 0xf809, KEY_D }, /*fav*/
1239 { 0xf808, KEY_BACKSPACE }, /*rewind*/
1240 { 0xf807, KEY_A }, /*fast*/
1241 { 0xf80b, KEY_P }, /*pause*/
1242 { 0xf802, KEY_ESC }, /*cancel*/
1243 { 0xf803, KEY_G }, /*tab*/
1244 { 0xf800, KEY_UP }, /*up*/
1245 { 0xf81f, KEY_ENTER }, /*ok*/
1246 { 0xf801, KEY_DOWN }, /*down*/
1247 { 0xf805, KEY_C }, /*cap*/
1248 { 0xf806, KEY_S }, /*stop*/
1249 { 0xf840, KEY_F }, /*full*/
1250 { 0xf81e, KEY_W }, /*tvmode*/
1251 { 0xf81b, KEY_B }, /*recall*/
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001252};
1253
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03001254static struct rc_map_table rc_map_tevii_table[] = {
Mauro Carvalho Chehab2e365882009-08-29 15:19:31 -03001255 { 0xf80a, KEY_POWER },
1256 { 0xf80c, KEY_MUTE },
1257 { 0xf811, KEY_1 },
1258 { 0xf812, KEY_2 },
1259 { 0xf813, KEY_3 },
1260 { 0xf814, KEY_4 },
1261 { 0xf815, KEY_5 },
1262 { 0xf816, KEY_6 },
1263 { 0xf817, KEY_7 },
1264 { 0xf818, KEY_8 },
1265 { 0xf819, KEY_9 },
1266 { 0xf810, KEY_0 },
1267 { 0xf81c, KEY_MENU },
1268 { 0xf80f, KEY_VOLUMEDOWN },
1269 { 0xf81a, KEY_LAST },
1270 { 0xf80e, KEY_OPEN },
1271 { 0xf804, KEY_RECORD },
1272 { 0xf809, KEY_VOLUMEUP },
1273 { 0xf808, KEY_CHANNELUP },
1274 { 0xf807, KEY_PVR },
1275 { 0xf80b, KEY_TIME },
1276 { 0xf802, KEY_RIGHT },
1277 { 0xf803, KEY_LEFT },
1278 { 0xf800, KEY_UP },
1279 { 0xf81f, KEY_OK },
1280 { 0xf801, KEY_DOWN },
1281 { 0xf805, KEY_TUNER },
1282 { 0xf806, KEY_CHANNELDOWN },
1283 { 0xf840, KEY_PLAYPAUSE },
1284 { 0xf81e, KEY_REWIND },
1285 { 0xf81b, KEY_FAVORITES },
1286 { 0xf81d, KEY_BACK },
1287 { 0xf84d, KEY_FASTFORWARD },
1288 { 0xf844, KEY_EPG },
1289 { 0xf84c, KEY_INFO },
1290 { 0xf841, KEY_AB },
1291 { 0xf843, KEY_AUDIO },
1292 { 0xf845, KEY_SUBTITLE },
1293 { 0xf84a, KEY_LIST },
1294 { 0xf846, KEY_F1 },
1295 { 0xf847, KEY_F2 },
1296 { 0xf85e, KEY_F3 },
1297 { 0xf85c, KEY_F4 },
1298 { 0xf852, KEY_F5 },
1299 { 0xf85a, KEY_F6 },
1300 { 0xf856, KEY_MODE },
1301 { 0xf858, KEY_SWITCHVIDEOMODE },
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -03001302};
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001303
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03001304static struct rc_map_table rc_map_tbs_table[] = {
Mauro Carvalho Chehab2e365882009-08-29 15:19:31 -03001305 { 0xf884, KEY_POWER },
1306 { 0xf894, KEY_MUTE },
1307 { 0xf887, KEY_1 },
1308 { 0xf886, KEY_2 },
1309 { 0xf885, KEY_3 },
1310 { 0xf88b, KEY_4 },
1311 { 0xf88a, KEY_5 },
1312 { 0xf889, KEY_6 },
1313 { 0xf88f, KEY_7 },
1314 { 0xf88e, KEY_8 },
1315 { 0xf88d, KEY_9 },
1316 { 0xf892, KEY_0 },
1317 { 0xf896, KEY_CHANNELUP },
1318 { 0xf891, KEY_CHANNELDOWN },
1319 { 0xf893, KEY_VOLUMEUP },
1320 { 0xf88c, KEY_VOLUMEDOWN },
1321 { 0xf883, KEY_RECORD },
1322 { 0xf898, KEY_PAUSE },
1323 { 0xf899, KEY_OK },
1324 { 0xf89a, KEY_SHUFFLE },
1325 { 0xf881, KEY_UP },
1326 { 0xf890, KEY_LEFT },
1327 { 0xf882, KEY_RIGHT },
1328 { 0xf888, KEY_DOWN },
1329 { 0xf895, KEY_FAVORITES },
1330 { 0xf897, KEY_SUBTITLE },
1331 { 0xf89d, KEY_ZOOM },
1332 { 0xf89f, KEY_EXIT },
1333 { 0xf89e, KEY_MENU },
1334 { 0xf89c, KEY_EPG },
1335 { 0xf880, KEY_PREVIOUS },
1336 { 0xf89b, KEY_MODE }
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -03001337};
1338
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001339static struct rc_map_table rc_map_su3000_table[] = {
1340 { 0x25, KEY_POWER }, /* right-bottom Red */
1341 { 0x0a, KEY_MUTE }, /* -/-- */
1342 { 0x01, KEY_1 },
1343 { 0x02, KEY_2 },
1344 { 0x03, KEY_3 },
1345 { 0x04, KEY_4 },
1346 { 0x05, KEY_5 },
1347 { 0x06, KEY_6 },
1348 { 0x07, KEY_7 },
1349 { 0x08, KEY_8 },
1350 { 0x09, KEY_9 },
1351 { 0x00, KEY_0 },
1352 { 0x20, KEY_UP }, /* CH+ */
1353 { 0x21, KEY_DOWN }, /* CH+ */
1354 { 0x12, KEY_VOLUMEUP }, /* Brightness Up */
1355 { 0x13, KEY_VOLUMEDOWN },/* Brightness Down */
1356 { 0x1f, KEY_RECORD },
1357 { 0x17, KEY_PLAY },
1358 { 0x16, KEY_PAUSE },
1359 { 0x0b, KEY_STOP },
1360 { 0x27, KEY_FASTFORWARD },/* >> */
1361 { 0x26, KEY_REWIND }, /* << */
1362 { 0x0d, KEY_OK }, /* Mute */
1363 { 0x11, KEY_LEFT }, /* VOL- */
1364 { 0x10, KEY_RIGHT }, /* VOL+ */
1365 { 0x29, KEY_BACK }, /* button under 9 */
1366 { 0x2c, KEY_MENU }, /* TTX */
1367 { 0x2b, KEY_EPG }, /* EPG */
1368 { 0x1e, KEY_RED }, /* OSD */
1369 { 0x0e, KEY_GREEN }, /* Window */
1370 { 0x2d, KEY_YELLOW }, /* button under << */
1371 { 0x0f, KEY_BLUE }, /* bottom yellow button */
1372 { 0x14, KEY_AUDIO }, /* Snapshot */
1373 { 0x38, KEY_TV }, /* TV/Radio */
1374 { 0x0c, KEY_ESC } /* upper Red buttton */
1375};
1376
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03001377static struct rc_map_dvb_usb_table_table keys_tables[] = {
1378 { rc_map_dw210x_table, ARRAY_SIZE(rc_map_dw210x_table) },
1379 { rc_map_tevii_table, ARRAY_SIZE(rc_map_tevii_table) },
1380 { rc_map_tbs_table, ARRAY_SIZE(rc_map_tbs_table) },
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001381 { rc_map_su3000_table, ARRAY_SIZE(rc_map_su3000_table) },
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -03001382};
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001383
1384static int dw2102_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
1385{
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03001386 struct rc_map_table *keymap = d->props.rc.legacy.rc_map_table;
1387 int keymap_size = d->props.rc.legacy.rc_map_size;
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001388 u8 key[2];
Igor M. Liplianin8a8dad72009-06-13 08:10:24 -03001389 struct i2c_msg msg = {
1390 .addr = DW2102_RC_QUERY,
1391 .flags = I2C_M_RD,
1392 .buf = key,
1393 .len = 2
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001394 };
1395 int i;
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -03001396 /* override keymap */
1397 if ((ir_keymap > 0) && (ir_keymap <= ARRAY_SIZE(keys_tables))) {
1398 keymap = keys_tables[ir_keymap - 1].rc_keys ;
1399 keymap_size = keys_tables[ir_keymap - 1].rc_keys_size;
Igor M. Liplianinfeb16e92011-02-25 18:41:22 -03001400 } else if (ir_keymap > ARRAY_SIZE(keys_tables))
1401 return 0; /* none */
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001402
1403 *state = REMOTE_NO_KEY_PRESSED;
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001404 if (d->props.i2c_algo->master_xfer(&d->i2c_adap, &msg, 1) == 1) {
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -03001405 for (i = 0; i < keymap_size ; i++) {
Mauro Carvalho Chehab2e365882009-08-29 15:19:31 -03001406 if (rc5_data(&keymap[i]) == msg.buf[0]) {
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001407 *state = REMOTE_KEY_PRESSED;
Mauro Carvalho Chehab34abf212010-07-31 11:24:57 -03001408 *event = keymap[i].keycode;
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001409 break;
1410 }
Igor M. Liplianin8a8dad72009-06-13 08:10:24 -03001411
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001412 }
Igor M. Liplianin8a8dad72009-06-13 08:10:24 -03001413
1414 if ((*state) == REMOTE_KEY_PRESSED)
1415 deb_rc("%s: found rc key: %x, %x, event: %x\n",
1416 __func__, key[0], key[1], (*event));
1417 else if (key[0] != 0xff)
1418 deb_rc("%s: unknown rc key: %x, %x\n",
1419 __func__, key[0], key[1]);
1420
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001421 }
Igor M. Liplianin8a8dad72009-06-13 08:10:24 -03001422
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001423 return 0;
1424}
1425
1426static struct usb_device_id dw2102_table[] = {
1427 {USB_DEVICE(USB_VID_CYPRESS, USB_PID_DW2102)},
1428 {USB_DEVICE(USB_VID_CYPRESS, 0x2101)},
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001429 {USB_DEVICE(USB_VID_CYPRESS, USB_PID_DW2104)},
1430 {USB_DEVICE(0x9022, USB_PID_TEVII_S650)},
Igor M. Liplianin4cc0edf2008-11-05 22:12:56 -03001431 {USB_DEVICE(USB_VID_TERRATEC, USB_PID_CINERGY_S)},
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001432 {USB_DEVICE(USB_VID_CYPRESS, USB_PID_DW3101)},
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001433 {USB_DEVICE(0x9022, USB_PID_TEVII_S630)},
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001434 {USB_DEVICE(0x3011, USB_PID_PROF_1100)},
1435 {USB_DEVICE(0x9022, USB_PID_TEVII_S660)},
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001436 {USB_DEVICE(0x3034, 0x7500)},
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001437 {USB_DEVICE(0x1f4d, 0x3000)},
Igor M. Liplianin2adc5912011-02-25 18:41:22 -03001438 {USB_DEVICE(USB_VID_TERRATEC, 0x00a8)},
Igor M. Liplianine8f50552011-02-25 18:41:23 -03001439 {USB_DEVICE(0x9022, USB_PID_TEVII_S480_1)},
1440 {USB_DEVICE(0x9022, USB_PID_TEVII_S480_2)},
Igor M. Liplianin5265ea52011-02-27 16:17:25 -03001441 {USB_DEVICE(0x1f4d, 0x3100)},
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001442 { }
1443};
1444
1445MODULE_DEVICE_TABLE(usb, dw2102_table);
1446
1447static int dw2102_load_firmware(struct usb_device *dev,
1448 const struct firmware *frmwr)
1449{
1450 u8 *b, *p;
1451 int ret = 0, i;
1452 u8 reset;
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -03001453 u8 reset16[] = {0, 0, 0, 0, 0, 0, 0};
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001454 const struct firmware *fw;
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001455 const char *fw_2101 = "dvb-usb-dw2101.fw";
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001456
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001457 switch (dev->descriptor.idProduct) {
1458 case 0x2101:
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001459 ret = request_firmware(&fw, fw_2101, &dev->dev);
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001460 if (ret != 0) {
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001461 err(err_str, fw_2101);
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001462 return ret;
1463 }
1464 break;
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001465 default:
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001466 fw = frmwr;
1467 break;
1468 }
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001469 info("start downloading DW210X firmware");
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001470 p = kmalloc(fw->size, GFP_KERNEL);
1471 reset = 1;
1472 /*stop the CPU*/
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001473 dw210x_op_rw(dev, 0xa0, 0x7f92, 0, &reset, 1, DW210X_WRITE_MSG);
1474 dw210x_op_rw(dev, 0xa0, 0xe600, 0, &reset, 1, DW210X_WRITE_MSG);
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001475
1476 if (p != NULL) {
1477 memcpy(p, fw->data, fw->size);
1478 for (i = 0; i < fw->size; i += 0x40) {
1479 b = (u8 *) p + i;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001480 if (dw210x_op_rw(dev, 0xa0, i, 0, b , 0x40,
1481 DW210X_WRITE_MSG) != 0x40) {
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001482 err("error while transferring firmware");
1483 ret = -EINVAL;
1484 break;
1485 }
1486 }
1487 /* restart the CPU */
1488 reset = 0;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001489 if (ret || dw210x_op_rw(dev, 0xa0, 0x7f92, 0, &reset, 1,
1490 DW210X_WRITE_MSG) != 1) {
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001491 err("could not restart the USB controller CPU.");
1492 ret = -EINVAL;
1493 }
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001494 if (ret || dw210x_op_rw(dev, 0xa0, 0xe600, 0, &reset, 1,
1495 DW210X_WRITE_MSG) != 1) {
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001496 err("could not restart the USB controller CPU.");
1497 ret = -EINVAL;
1498 }
1499 /* init registers */
1500 switch (dev->descriptor.idProduct) {
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001501 case USB_PID_TEVII_S650:
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03001502 dw2104_properties.rc.legacy.rc_map_table = rc_map_tevii_table;
1503 dw2104_properties.rc.legacy.rc_map_size =
1504 ARRAY_SIZE(rc_map_tevii_table);
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -03001505 case USB_PID_DW2104:
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001506 reset = 1;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001507 dw210x_op_rw(dev, 0xc4, 0x0000, 0, &reset, 1,
1508 DW210X_WRITE_MSG);
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001509 /* break omitted intentionally */
1510 case USB_PID_DW3101:
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001511 reset = 0;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001512 dw210x_op_rw(dev, 0xbf, 0x0040, 0, &reset, 0,
1513 DW210X_WRITE_MSG);
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001514 break;
Igor M. Liplianin4cc0edf2008-11-05 22:12:56 -03001515 case USB_PID_CINERGY_S:
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001516 case USB_PID_DW2102:
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001517 dw210x_op_rw(dev, 0xbf, 0x0040, 0, &reset, 0,
1518 DW210X_WRITE_MSG);
1519 dw210x_op_rw(dev, 0xb9, 0x0000, 0, &reset16[0], 2,
1520 DW210X_READ_MSG);
1521 /* check STV0299 frontend */
1522 dw210x_op_rw(dev, 0xb5, 0, 0, &reset16[0], 2,
1523 DW210X_READ_MSG);
Igor M. Liplianinea023df2008-12-04 12:49:23 -03001524 if ((reset16[0] == 0xa1) || (reset16[0] == 0x80)) {
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001525 dw2102_properties.i2c_algo = &dw2102_i2c_algo;
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -03001526 dw2102_properties.adapter->tuner_attach = &dw2102_tuner_attach;
1527 break;
1528 } else {
1529 /* check STV0288 frontend */
1530 reset16[0] = 0xd0;
1531 reset16[1] = 1;
1532 reset16[2] = 0;
1533 dw210x_op_rw(dev, 0xc2, 0, 0, &reset16[0], 3,
1534 DW210X_WRITE_MSG);
1535 dw210x_op_rw(dev, 0xc3, 0xd1, 0, &reset16[0], 3,
1536 DW210X_READ_MSG);
1537 if (reset16[2] == 0x11) {
1538 dw2102_properties.i2c_algo = &dw2102_earda_i2c_algo;
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -03001539 break;
1540 }
1541 }
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001542 case 0x2101:
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001543 dw210x_op_rw(dev, 0xbc, 0x0030, 0, &reset16[0], 2,
1544 DW210X_READ_MSG);
1545 dw210x_op_rw(dev, 0xba, 0x0000, 0, &reset16[0], 7,
1546 DW210X_READ_MSG);
1547 dw210x_op_rw(dev, 0xba, 0x0000, 0, &reset16[0], 7,
1548 DW210X_READ_MSG);
1549 dw210x_op_rw(dev, 0xb9, 0x0000, 0, &reset16[0], 2,
1550 DW210X_READ_MSG);
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001551 break;
1552 }
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001553
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001554 msleep(100);
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001555 kfree(p);
1556 }
1557 return ret;
1558}
1559
1560static struct dvb_usb_device_properties dw2102_properties = {
1561 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1562 .usb_ctrl = DEVICE_SPECIFIC,
1563 .firmware = "dvb-usb-dw2102.fw",
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001564 .no_reconnect = 1,
1565
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001566 .i2c_algo = &dw2102_serit_i2c_algo,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03001567
1568 .rc.legacy = {
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03001569 .rc_map_table = rc_map_dw210x_table,
1570 .rc_map_size = ARRAY_SIZE(rc_map_dw210x_table),
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03001571 .rc_interval = 150,
1572 .rc_query = dw2102_rc_query,
1573 },
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001574
1575 .generic_bulk_ctrl_endpoint = 0x81,
1576 /* parameter for the MPEG2-data transfer */
1577 .num_adapters = 1,
1578 .download_firmware = dw2102_load_firmware,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001579 .read_mac_address = dw210x_read_mac_address,
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001580 .adapter = {
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001581 {
1582 .frontend_attach = dw2102_frontend_attach,
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001583 .stream = {
1584 .type = USB_BULK,
1585 .count = 8,
1586 .endpoint = 0x82,
1587 .u = {
1588 .bulk = {
1589 .buffersize = 4096,
1590 }
1591 }
1592 },
1593 }
1594 },
Igor M. Liplianin4cc0edf2008-11-05 22:12:56 -03001595 .num_device_descs = 3,
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001596 .devices = {
1597 {"DVBWorld DVB-S 2102 USB2.0",
1598 {&dw2102_table[0], NULL},
1599 {NULL},
1600 },
1601 {"DVBWorld DVB-S 2101 USB2.0",
1602 {&dw2102_table[1], NULL},
1603 {NULL},
1604 },
Igor M. Liplianin4cc0edf2008-11-05 22:12:56 -03001605 {"TerraTec Cinergy S USB",
1606 {&dw2102_table[4], NULL},
1607 {NULL},
1608 },
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001609 }
1610};
1611
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001612static struct dvb_usb_device_properties dw2104_properties = {
1613 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1614 .usb_ctrl = DEVICE_SPECIFIC,
1615 .firmware = "dvb-usb-dw2104.fw",
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001616 .no_reconnect = 1,
1617
1618 .i2c_algo = &dw2104_i2c_algo,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03001619 .rc.legacy = {
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03001620 .rc_map_table = rc_map_dw210x_table,
1621 .rc_map_size = ARRAY_SIZE(rc_map_dw210x_table),
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03001622 .rc_interval = 150,
1623 .rc_query = dw2102_rc_query,
1624 },
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001625
1626 .generic_bulk_ctrl_endpoint = 0x81,
1627 /* parameter for the MPEG2-data transfer */
1628 .num_adapters = 1,
1629 .download_firmware = dw2102_load_firmware,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001630 .read_mac_address = dw210x_read_mac_address,
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001631 .adapter = {
1632 {
1633 .frontend_attach = dw2104_frontend_attach,
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001634 .stream = {
1635 .type = USB_BULK,
1636 .count = 8,
1637 .endpoint = 0x82,
1638 .u = {
1639 .bulk = {
1640 .buffersize = 4096,
1641 }
1642 }
1643 },
1644 }
1645 },
1646 .num_device_descs = 2,
1647 .devices = {
1648 { "DVBWorld DW2104 USB2.0",
1649 {&dw2102_table[2], NULL},
1650 {NULL},
1651 },
1652 { "TeVii S650 USB2.0",
1653 {&dw2102_table[3], NULL},
1654 {NULL},
1655 },
1656 }
1657};
1658
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001659static struct dvb_usb_device_properties dw3101_properties = {
1660 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1661 .usb_ctrl = DEVICE_SPECIFIC,
1662 .firmware = "dvb-usb-dw3101.fw",
1663 .no_reconnect = 1,
1664
1665 .i2c_algo = &dw3101_i2c_algo,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03001666 .rc.legacy = {
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03001667 .rc_map_table = rc_map_dw210x_table,
1668 .rc_map_size = ARRAY_SIZE(rc_map_dw210x_table),
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03001669 .rc_interval = 150,
1670 .rc_query = dw2102_rc_query,
1671 },
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001672
1673 .generic_bulk_ctrl_endpoint = 0x81,
1674 /* parameter for the MPEG2-data transfer */
1675 .num_adapters = 1,
1676 .download_firmware = dw2102_load_firmware,
1677 .read_mac_address = dw210x_read_mac_address,
1678 .adapter = {
1679 {
1680 .frontend_attach = dw3101_frontend_attach,
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001681 .tuner_attach = dw3101_tuner_attach,
1682 .stream = {
1683 .type = USB_BULK,
1684 .count = 8,
1685 .endpoint = 0x82,
1686 .u = {
1687 .bulk = {
1688 .buffersize = 4096,
1689 }
1690 }
1691 },
1692 }
1693 },
1694 .num_device_descs = 1,
1695 .devices = {
1696 { "DVBWorld DVB-C 3101 USB2.0",
1697 {&dw2102_table[5], NULL},
1698 {NULL},
1699 },
1700 }
1701};
1702
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001703static struct dvb_usb_device_properties s6x0_properties = {
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001704 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1705 .usb_ctrl = DEVICE_SPECIFIC,
Igor M. Liplianin52c506e2011-02-25 18:41:23 -03001706 .size_of_priv = sizeof(struct s6x0_state),
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001707 .firmware = "dvb-usb-s630.fw",
1708 .no_reconnect = 1,
1709
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001710 .i2c_algo = &s6x0_i2c_algo,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03001711 .rc.legacy = {
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03001712 .rc_map_table = rc_map_tevii_table,
1713 .rc_map_size = ARRAY_SIZE(rc_map_tevii_table),
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03001714 .rc_interval = 150,
1715 .rc_query = dw2102_rc_query,
1716 },
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001717
1718 .generic_bulk_ctrl_endpoint = 0x81,
1719 .num_adapters = 1,
1720 .download_firmware = dw2102_load_firmware,
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001721 .read_mac_address = s6x0_read_mac_address,
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001722 .adapter = {
1723 {
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001724 .frontend_attach = zl100313_frontend_attach,
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001725 .stream = {
1726 .type = USB_BULK,
1727 .count = 8,
1728 .endpoint = 0x82,
1729 .u = {
1730 .bulk = {
1731 .buffersize = 4096,
1732 }
1733 }
1734 },
1735 }
1736 },
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001737 .num_device_descs = 1,
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001738 .devices = {
1739 {"TeVii S630 USB",
1740 {&dw2102_table[6], NULL},
1741 {NULL},
1742 },
1743 }
1744};
1745
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001746struct dvb_usb_device_properties *p1100;
1747static struct dvb_usb_device_description d1100 = {
1748 "Prof 1100 USB ",
1749 {&dw2102_table[7], NULL},
1750 {NULL},
1751};
1752
1753struct dvb_usb_device_properties *s660;
1754static struct dvb_usb_device_description d660 = {
1755 "TeVii S660 USB",
1756 {&dw2102_table[8], NULL},
1757 {NULL},
1758};
1759
Igor M. Liplianine8f50552011-02-25 18:41:23 -03001760static struct dvb_usb_device_description d480_1 = {
1761 "TeVii S480.1 USB",
1762 {&dw2102_table[12], NULL},
1763 {NULL},
1764};
1765
1766static struct dvb_usb_device_description d480_2 = {
1767 "TeVii S480.2 USB",
1768 {&dw2102_table[13], NULL},
1769 {NULL},
1770};
1771
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001772struct dvb_usb_device_properties *p7500;
1773static struct dvb_usb_device_description d7500 = {
1774 "Prof 7500 USB DVB-S2",
1775 {&dw2102_table[9], NULL},
1776 {NULL},
1777};
1778
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001779static struct dvb_usb_device_properties su3000_properties = {
1780 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1781 .usb_ctrl = DEVICE_SPECIFIC,
1782 .size_of_priv = sizeof(struct su3000_state),
1783 .power_ctrl = su3000_power_ctrl,
1784 .num_adapters = 1,
1785 .identify_state = su3000_identify_state,
1786 .i2c_algo = &su3000_i2c_algo,
1787
1788 .rc.legacy = {
1789 .rc_map_table = rc_map_su3000_table,
1790 .rc_map_size = ARRAY_SIZE(rc_map_su3000_table),
1791 .rc_interval = 150,
1792 .rc_query = dw2102_rc_query,
1793 },
1794
1795 .read_mac_address = su3000_read_mac_address,
1796
1797 .generic_bulk_ctrl_endpoint = 0x01,
1798
1799 .adapter = {
1800 {
1801 .streaming_ctrl = su3000_streaming_ctrl,
1802 .frontend_attach = su3000_frontend_attach,
1803 .stream = {
1804 .type = USB_BULK,
1805 .count = 8,
1806 .endpoint = 0x82,
1807 .u = {
1808 .bulk = {
1809 .buffersize = 4096,
1810 }
1811 }
1812 }
1813 }
1814 },
Igor M. Liplianin5265ea52011-02-27 16:17:25 -03001815 .num_device_descs = 3,
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001816 .devices = {
1817 { "SU3000HD DVB-S USB2.0",
1818 { &dw2102_table[10], NULL },
1819 { NULL },
1820 },
Igor M. Liplianin2adc5912011-02-25 18:41:22 -03001821 { "Terratec Cinergy S2 USB HD",
1822 { &dw2102_table[11], NULL },
1823 { NULL },
1824 },
Igor M. Liplianin5265ea52011-02-27 16:17:25 -03001825 { "X3M TV SPC1400HD PCI",
1826 { &dw2102_table[14], NULL },
1827 { NULL },
1828 },
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001829 }
1830};
1831
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001832static int dw2102_probe(struct usb_interface *intf,
1833 const struct usb_device_id *id)
1834{
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001835 p1100 = kzalloc(sizeof(struct dvb_usb_device_properties), GFP_KERNEL);
1836 if (!p1100)
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001837 return -ENOMEM;
1838 /* copy default structure */
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001839 memcpy(p1100, &s6x0_properties,
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001840 sizeof(struct dvb_usb_device_properties));
1841 /* fill only different fields */
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001842 p1100->firmware = "dvb-usb-p1100.fw";
1843 p1100->devices[0] = d1100;
1844 p1100->rc.legacy.rc_map_table = rc_map_tbs_table;
1845 p1100->rc.legacy.rc_map_size = ARRAY_SIZE(rc_map_tbs_table);
1846 p1100->adapter->frontend_attach = stv0288_frontend_attach;
1847
1848 s660 = kzalloc(sizeof(struct dvb_usb_device_properties), GFP_KERNEL);
1849 if (!s660) {
1850 kfree(p1100);
1851 return -ENOMEM;
1852 }
1853 memcpy(s660, &s6x0_properties,
1854 sizeof(struct dvb_usb_device_properties));
1855 s660->firmware = "dvb-usb-s660.fw";
Igor M. Liplianine8f50552011-02-25 18:41:23 -03001856 s660->num_device_descs = 3;
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001857 s660->devices[0] = d660;
Igor M. Liplianine8f50552011-02-25 18:41:23 -03001858 s660->devices[1] = d480_1;
1859 s660->devices[2] = d480_2;
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001860 s660->adapter->frontend_attach = ds3000_frontend_attach;
1861
1862 p7500 = kzalloc(sizeof(struct dvb_usb_device_properties), GFP_KERNEL);
1863 if (!p7500) {
1864 kfree(p1100);
1865 kfree(s660);
1866 return -ENOMEM;
1867 }
1868 memcpy(p7500, &s6x0_properties,
1869 sizeof(struct dvb_usb_device_properties));
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001870 p7500->firmware = "dvb-usb-p7500.fw";
1871 p7500->devices[0] = d7500;
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03001872 p7500->rc.legacy.rc_map_table = rc_map_tbs_table;
1873 p7500->rc.legacy.rc_map_size = ARRAY_SIZE(rc_map_tbs_table);
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001874 p7500->adapter->frontend_attach = prof_7500_frontend_attach;
1875
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001876 if (0 == dvb_usb_device_init(intf, &dw2102_properties,
1877 THIS_MODULE, NULL, adapter_nr) ||
1878 0 == dvb_usb_device_init(intf, &dw2104_properties,
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001879 THIS_MODULE, NULL, adapter_nr) ||
1880 0 == dvb_usb_device_init(intf, &dw3101_properties,
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001881 THIS_MODULE, NULL, adapter_nr) ||
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001882 0 == dvb_usb_device_init(intf, &s6x0_properties,
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001883 THIS_MODULE, NULL, adapter_nr) ||
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001884 0 == dvb_usb_device_init(intf, p1100,
1885 THIS_MODULE, NULL, adapter_nr) ||
1886 0 == dvb_usb_device_init(intf, s660,
1887 THIS_MODULE, NULL, adapter_nr) ||
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001888 0 == dvb_usb_device_init(intf, p7500,
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001889 THIS_MODULE, NULL, adapter_nr) ||
1890 0 == dvb_usb_device_init(intf, &su3000_properties,
1891 THIS_MODULE, NULL, adapter_nr))
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001892 return 0;
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001893
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001894 return -ENODEV;
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001895}
1896
1897static struct usb_driver dw2102_driver = {
1898 .name = "dw2102",
1899 .probe = dw2102_probe,
1900 .disconnect = dvb_usb_device_exit,
1901 .id_table = dw2102_table,
1902};
1903
1904static int __init dw2102_module_init(void)
1905{
1906 int ret = usb_register(&dw2102_driver);
1907 if (ret)
1908 err("usb_register failed. Error number %d", ret);
1909
1910 return ret;
1911}
1912
1913static void __exit dw2102_module_exit(void)
1914{
1915 usb_deregister(&dw2102_driver);
1916}
1917
1918module_init(dw2102_module_init);
1919module_exit(dw2102_module_exit);
1920
1921MODULE_AUTHOR("Igor M. Liplianin (c) liplianin@me.by");
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001922MODULE_DESCRIPTION("Driver for DVBWorld DVB-S 2101, 2102, DVB-S2 2104,"
1923 " DVB-C 3101 USB2.0,"
Igor M. Liplianine8f50552011-02-25 18:41:23 -03001924 " TeVii S600, S630, S650, S660, S480,"
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001925 " Prof 1100, 7500 USB2.0,"
1926 " Geniatech SU3000 devices");
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001927MODULE_VERSION("0.1");
1928MODULE_LICENSE("GPL");