blob: 64132c0cf80d1f0fdb2b9ab004502c2b4a97be5d [file] [log] [blame]
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001/* DVB USB framework compliant Linux driver for the
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03002* DVBWorld DVB-S 2101, 2102, DVB-S2 2104, DVB-C 3101,
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03003* TeVii S600, S630, S650 Cards
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03004* Copyright (C) 2008,2009 Igor M. Liplianin (liplianin@me.by)
Igor M Liplianin7fd48282008-07-20 08:05:50 -03005*
6* This program is free software; you can redistribute it and/or modify it
7* under the terms of the GNU General Public License as published by the
8* Free Software Foundation, version 2.
9*
10* see Documentation/dvb/README.dvb-usb for more information
11*/
Igor M Liplianin7fd48282008-07-20 08:05:50 -030012#include "dw2102.h"
Igor M. Liplianin21b007b2008-09-17 19:19:19 -030013#include "si21xx.h"
Igor M Liplianin7fd48282008-07-20 08:05:50 -030014#include "stv0299.h"
15#include "z0194a.h"
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -030016#include "stv0288.h"
17#include "stb6000.h"
18#include "eds1547.h"
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -030019#include "cx24116.h"
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -030020#include "tda1002x.h"
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -030021#include "mt312.h"
22#include "zl10039.h"
Igor M. Liplianin141cc352009-11-27 14:37:35 -030023#include "ds3000.h"
24#include "stv0900.h"
25#include "stv6110.h"
26#include "stb6100.h"
27#include "stb6100_proc.h"
Igor M Liplianin7fd48282008-07-20 08:05:50 -030028
29#ifndef USB_PID_DW2102
30#define USB_PID_DW2102 0x2102
31#endif
32
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -030033#ifndef USB_PID_DW2104
34#define USB_PID_DW2104 0x2104
35#endif
36
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -030037#ifndef USB_PID_DW3101
38#define USB_PID_DW3101 0x3101
39#endif
40
Igor M. Liplianin4cc0edf2008-11-05 22:12:56 -030041#ifndef USB_PID_CINERGY_S
42#define USB_PID_CINERGY_S 0x0064
43#endif
44
Igor M. Liplianin141cc352009-11-27 14:37:35 -030045#ifndef USB_PID_TEVII_S630
46#define USB_PID_TEVII_S630 0xd630
47#endif
48
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -030049#ifndef USB_PID_TEVII_S650
50#define USB_PID_TEVII_S650 0xd650
51#endif
52
Igor M. Liplianin141cc352009-11-27 14:37:35 -030053#ifndef USB_PID_TEVII_S660
54#define USB_PID_TEVII_S660 0xd660
55#endif
56
57#ifndef USB_PID_PROF_1100
58#define USB_PID_PROF_1100 0xb012
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -030059#endif
60
Igor M. Liplianin21b007b2008-09-17 19:19:19 -030061#define DW210X_READ_MSG 0
62#define DW210X_WRITE_MSG 1
Igor M Liplianin7fd48282008-07-20 08:05:50 -030063
64#define REG_1F_SYMBOLRATE_BYTE0 0x1f
65#define REG_20_SYMBOLRATE_BYTE1 0x20
66#define REG_21_SYMBOLRATE_BYTE2 0x21
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -030067/* on my own*/
Igor M Liplianin7fd48282008-07-20 08:05:50 -030068#define DW2102_VOLTAGE_CTRL (0x1800)
69#define DW2102_RC_QUERY (0x1a00)
70
Igor M. Liplianin141cc352009-11-27 14:37:35 -030071#define err_str "did not find the firmware file. (%s) " \
72 "Please see linux/Documentation/dvb/ for more details " \
73 "on firmware-problems."
74
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -030075struct dvb_usb_rc_keys_table {
76 struct dvb_usb_rc_key *rc_keys;
77 int rc_keys_size;
Igor M Liplianin7fd48282008-07-20 08:05:50 -030078};
79
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -030080/* debug */
81static int dvb_usb_dw2102_debug;
82module_param_named(debug, dvb_usb_dw2102_debug, int, 0644);
Igor M. Liplianin8a8dad72009-06-13 08:10:24 -030083MODULE_PARM_DESC(debug, "set debugging level (1=info 2=xfer 4=rc(or-able))."
84 DVB_USB_DEBUG_STATUS);
85
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -030086/* keymaps */
87static int ir_keymap;
88module_param_named(keymap, ir_keymap, int, 0644);
89MODULE_PARM_DESC(keymap, "set keymap 0=default 1=dvbworld 2=tevii 3=tbs ...");
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -030090
Igor M. Liplianin141cc352009-11-27 14:37:35 -030091/* demod probe */
92static int demod_probe = 1;
93module_param_named(demod, demod_probe, int, 0644);
94MODULE_PARM_DESC(demod, "demod to probe (1=cx24116 2=stv0903+stv6110 "
95 "4=stv0903+stb6100(or-able)).");
96
Igor M Liplianin7fd48282008-07-20 08:05:50 -030097DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
98
Igor M. Liplianin21b007b2008-09-17 19:19:19 -030099static int dw210x_op_rw(struct usb_device *dev, u8 request, u16 value,
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300100 u16 index, u8 * data, u16 len, int flags)
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300101{
102 int ret;
103 u8 u8buf[len];
104
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300105 unsigned int pipe = (flags == DW210X_READ_MSG) ?
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300106 usb_rcvctrlpipe(dev, 0) : usb_sndctrlpipe(dev, 0);
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300107 u8 request_type = (flags == DW210X_READ_MSG) ? USB_DIR_IN : USB_DIR_OUT;
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300108
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300109 if (flags == DW210X_WRITE_MSG)
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300110 memcpy(u8buf, data, len);
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300111 ret = usb_control_msg(dev, pipe, request, request_type | USB_TYPE_VENDOR,
112 value, index , u8buf, len, 2000);
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300113
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300114 if (flags == DW210X_READ_MSG)
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300115 memcpy(data, u8buf, len);
116 return ret;
117}
118
119/* I2C */
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300120static int dw2102_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
121 int num)
122{
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -0300123 struct dvb_usb_device *d = i2c_get_adapdata(adap);
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300124 int i = 0, ret = 0;
125 u8 buf6[] = {0x2c, 0x05, 0xc0, 0, 0, 0, 0};
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300126 u16 value;
127
128 if (!d)
129 return -ENODEV;
130 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
131 return -EAGAIN;
132
133 switch (num) {
134 case 2:
135 /* read stv0299 register */
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300136 value = msg[0].buf[0];/* register */
137 for (i = 0; i < msg[1].len; i++) {
138 value = value + i;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300139 ret = dw210x_op_rw(d->udev, 0xb5, value, 0,
140 buf6, 2, DW210X_READ_MSG);
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300141 msg[1].buf[i] = buf6[0];
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300142 }
143 break;
144 case 1:
145 switch (msg[0].addr) {
146 case 0x68:
147 /* write to stv0299 register */
148 buf6[0] = 0x2a;
149 buf6[1] = msg[0].buf[0];
150 buf6[2] = msg[0].buf[1];
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300151 ret = dw210x_op_rw(d->udev, 0xb2, 0, 0,
152 buf6, 3, DW210X_WRITE_MSG);
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300153 break;
154 case 0x60:
155 if (msg[0].flags == 0) {
156 /* write to tuner pll */
157 buf6[0] = 0x2c;
158 buf6[1] = 5;
159 buf6[2] = 0xc0;
160 buf6[3] = msg[0].buf[0];
161 buf6[4] = msg[0].buf[1];
162 buf6[5] = msg[0].buf[2];
163 buf6[6] = msg[0].buf[3];
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300164 ret = dw210x_op_rw(d->udev, 0xb2, 0, 0,
165 buf6, 7, DW210X_WRITE_MSG);
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300166 } else {
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300167 /* read from tuner */
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300168 ret = dw210x_op_rw(d->udev, 0xb5, 0, 0,
169 buf6, 1, DW210X_READ_MSG);
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300170 msg[0].buf[0] = buf6[0];
171 }
172 break;
173 case (DW2102_RC_QUERY):
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300174 ret = dw210x_op_rw(d->udev, 0xb8, 0, 0,
175 buf6, 2, DW210X_READ_MSG);
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300176 msg[0].buf[0] = buf6[0];
177 msg[0].buf[1] = buf6[1];
178 break;
179 case (DW2102_VOLTAGE_CTRL):
180 buf6[0] = 0x30;
181 buf6[1] = msg[0].buf[0];
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300182 ret = dw210x_op_rw(d->udev, 0xb2, 0, 0,
183 buf6, 2, DW210X_WRITE_MSG);
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300184 break;
185 }
186
187 break;
188 }
189
190 mutex_unlock(&d->i2c_mutex);
191 return num;
192}
193
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300194static int dw2102_serit_i2c_transfer(struct i2c_adapter *adap,
195 struct i2c_msg msg[], int num)
196{
197 struct dvb_usb_device *d = i2c_get_adapdata(adap);
198 int ret = 0;
199 u8 buf6[] = {0, 0, 0, 0, 0, 0, 0};
200
201 if (!d)
202 return -ENODEV;
203 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
204 return -EAGAIN;
205
206 switch (num) {
207 case 2:
208 /* read si2109 register by number */
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300209 buf6[0] = msg[0].addr << 1;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300210 buf6[1] = msg[0].len;
211 buf6[2] = msg[0].buf[0];
212 ret = dw210x_op_rw(d->udev, 0xc2, 0, 0,
213 buf6, msg[0].len + 2, DW210X_WRITE_MSG);
214 /* read si2109 register */
215 ret = dw210x_op_rw(d->udev, 0xc3, 0xd0, 0,
216 buf6, msg[1].len + 2, DW210X_READ_MSG);
217 memcpy(msg[1].buf, buf6 + 2, msg[1].len);
218
219 break;
220 case 1:
221 switch (msg[0].addr) {
222 case 0x68:
223 /* write to si2109 register */
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300224 buf6[0] = msg[0].addr << 1;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300225 buf6[1] = msg[0].len;
226 memcpy(buf6 + 2, msg[0].buf, msg[0].len);
227 ret = dw210x_op_rw(d->udev, 0xc2, 0, 0, buf6,
228 msg[0].len + 2, DW210X_WRITE_MSG);
229 break;
230 case(DW2102_RC_QUERY):
231 ret = dw210x_op_rw(d->udev, 0xb8, 0, 0,
232 buf6, 2, DW210X_READ_MSG);
233 msg[0].buf[0] = buf6[0];
234 msg[0].buf[1] = buf6[1];
235 break;
236 case(DW2102_VOLTAGE_CTRL):
237 buf6[0] = 0x30;
238 buf6[1] = msg[0].buf[0];
239 ret = dw210x_op_rw(d->udev, 0xb2, 0, 0,
240 buf6, 2, DW210X_WRITE_MSG);
241 break;
242 }
243 break;
244 }
245
246 mutex_unlock(&d->i2c_mutex);
247 return num;
248}
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -0300249
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -0300250static int dw2102_earda_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], int num)
251{
252 struct dvb_usb_device *d = i2c_get_adapdata(adap);
253 int ret = 0;
254
255 if (!d)
256 return -ENODEV;
257 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
258 return -EAGAIN;
259
260 switch (num) {
261 case 2: {
262 /* read */
263 /* first write first register number */
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -0300264 u8 ibuf[msg[1].len + 2], obuf[3];
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300265 obuf[0] = msg[0].addr << 1;
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -0300266 obuf[1] = msg[0].len;
267 obuf[2] = msg[0].buf[0];
268 ret = dw210x_op_rw(d->udev, 0xc2, 0, 0,
269 obuf, msg[0].len + 2, DW210X_WRITE_MSG);
270 /* second read registers */
271 ret = dw210x_op_rw(d->udev, 0xc3, 0xd1 , 0,
272 ibuf, msg[1].len + 2, DW210X_READ_MSG);
273 memcpy(msg[1].buf, ibuf + 2, msg[1].len);
274
275 break;
276 }
277 case 1:
278 switch (msg[0].addr) {
279 case 0x68: {
280 /* write to register */
281 u8 obuf[msg[0].len + 2];
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300282 obuf[0] = msg[0].addr << 1;
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -0300283 obuf[1] = msg[0].len;
284 memcpy(obuf + 2, msg[0].buf, msg[0].len);
285 ret = dw210x_op_rw(d->udev, 0xc2, 0, 0,
286 obuf, msg[0].len + 2, DW210X_WRITE_MSG);
287 break;
288 }
289 case 0x61: {
290 /* write to tuner */
291 u8 obuf[msg[0].len + 2];
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300292 obuf[0] = msg[0].addr << 1;
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -0300293 obuf[1] = msg[0].len;
294 memcpy(obuf + 2, msg[0].buf, msg[0].len);
295 ret = dw210x_op_rw(d->udev, 0xc2, 0, 0,
296 obuf, msg[0].len + 2, DW210X_WRITE_MSG);
297 break;
298 }
299 case(DW2102_RC_QUERY): {
300 u8 ibuf[2];
301 ret = dw210x_op_rw(d->udev, 0xb8, 0, 0,
302 ibuf, 2, DW210X_READ_MSG);
303 memcpy(msg[0].buf, ibuf , 2);
304 break;
305 }
306 case(DW2102_VOLTAGE_CTRL): {
307 u8 obuf[2];
308 obuf[0] = 0x30;
309 obuf[1] = msg[0].buf[0];
310 ret = dw210x_op_rw(d->udev, 0xb2, 0, 0,
311 obuf, 2, DW210X_WRITE_MSG);
312 break;
313 }
314 }
315
316 break;
317 }
318
319 mutex_unlock(&d->i2c_mutex);
320 return num;
321}
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300322
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300323static int dw2104_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], int num)
324{
325 struct dvb_usb_device *d = i2c_get_adapdata(adap);
326 int ret = 0;
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300327 int len, i, j;
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300328
329 if (!d)
330 return -ENODEV;
331 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
332 return -EAGAIN;
333
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300334 for (j = 0; j < num; j++) {
335 switch (msg[j].addr) {
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300336 case(DW2102_RC_QUERY): {
337 u8 ibuf[2];
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300338 ret = dw210x_op_rw(d->udev, 0xb8, 0, 0,
339 ibuf, 2, DW210X_READ_MSG);
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300340 memcpy(msg[j].buf, ibuf , 2);
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300341 break;
342 }
343 case(DW2102_VOLTAGE_CTRL): {
344 u8 obuf[2];
345 obuf[0] = 0x30;
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300346 obuf[1] = msg[j].buf[0];
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300347 ret = dw210x_op_rw(d->udev, 0xb2, 0, 0,
348 obuf, 2, DW210X_WRITE_MSG);
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300349 break;
350 }
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300351 /*case 0x55: cx24116
352 case 0x6a: stv0903
353 case 0x68: ds3000, stv0903
354 case 0x60: ts2020, stv6110, stb6100 */
355 default: {
356 if (msg[j].flags == I2C_M_RD) {
357 /* read registers */
358 u8 ibuf[msg[j].len + 2];
359 ret = dw210x_op_rw(d->udev, 0xc3,
360 (msg[j].addr << 1) + 1, 0,
361 ibuf, msg[j].len + 2,
362 DW210X_READ_MSG);
363 memcpy(msg[j].buf, ibuf + 2, msg[j].len);
364 mdelay(10);
365 } else if (((msg[j].buf[0] == 0xb0) &&
366 (msg[j].addr == 0x68)) ||
367 ((msg[j].buf[0] == 0xf7) &&
368 (msg[j].addr == 0x55))) {
369 /* write firmware */
370 u8 obuf[19];
371 obuf[0] = msg[j].addr << 1;
372 obuf[1] = (msg[j].len > 15 ? 17 : msg[j].len);
373 obuf[2] = msg[j].buf[0];
374 len = msg[j].len - 1;
375 i = 1;
376 do {
377 memcpy(obuf + 3, msg[j].buf + i,
378 (len > 16 ? 16 : len));
379 ret = dw210x_op_rw(d->udev, 0xc2, 0, 0,
380 obuf, (len > 16 ? 16 : len) + 3,
381 DW210X_WRITE_MSG);
382 i += 16;
383 len -= 16;
384 } while (len > 0);
385 } else {
386 /* write registers */
387 u8 obuf[msg[j].len + 2];
388 obuf[0] = msg[j].addr << 1;
389 obuf[1] = msg[j].len;
390 memcpy(obuf + 2, msg[j].buf, msg[j].len);
391 ret = dw210x_op_rw(d->udev, 0xc2, 0, 0,
392 obuf, msg[j].len + 2,
393 DW210X_WRITE_MSG);
394 }
395 break;
396 }
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300397 }
398
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300399 }
400
401 mutex_unlock(&d->i2c_mutex);
402 return num;
403}
404
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -0300405static int dw3101_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
406 int num)
407{
408 struct dvb_usb_device *d = i2c_get_adapdata(adap);
409 int ret = 0, i;
410
411 if (!d)
412 return -ENODEV;
413 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
414 return -EAGAIN;
415
416 switch (num) {
417 case 2: {
418 /* read */
419 /* first write first register number */
420 u8 ibuf[msg[1].len + 2], obuf[3];
421 obuf[0] = msg[0].addr << 1;
422 obuf[1] = msg[0].len;
423 obuf[2] = msg[0].buf[0];
424 ret = dw210x_op_rw(d->udev, 0xc2, 0, 0,
425 obuf, msg[0].len + 2, DW210X_WRITE_MSG);
426 /* second read registers */
427 ret = dw210x_op_rw(d->udev, 0xc3, 0x19 , 0,
428 ibuf, msg[1].len + 2, DW210X_READ_MSG);
429 memcpy(msg[1].buf, ibuf + 2, msg[1].len);
430
431 break;
432 }
433 case 1:
434 switch (msg[0].addr) {
435 case 0x60:
436 case 0x0c: {
437 /* write to register */
438 u8 obuf[msg[0].len + 2];
439 obuf[0] = msg[0].addr << 1;
440 obuf[1] = msg[0].len;
441 memcpy(obuf + 2, msg[0].buf, msg[0].len);
442 ret = dw210x_op_rw(d->udev, 0xc2, 0, 0,
443 obuf, msg[0].len + 2, DW210X_WRITE_MSG);
444 break;
445 }
446 case(DW2102_RC_QUERY): {
447 u8 ibuf[2];
448 ret = dw210x_op_rw(d->udev, 0xb8, 0, 0,
449 ibuf, 2, DW210X_READ_MSG);
450 memcpy(msg[0].buf, ibuf , 2);
451 break;
452 }
453 }
454
455 break;
456 }
457
458 for (i = 0; i < num; i++) {
459 deb_xfer("%02x:%02x: %s ", i, msg[i].addr,
460 msg[i].flags == 0 ? ">>>" : "<<<");
461 debug_dump(msg[i].buf, msg[i].len, deb_xfer);
462 }
463
464 mutex_unlock(&d->i2c_mutex);
465 return num;
466}
467
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300468static int s6x0_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300469 int num)
470{
471 struct dvb_usb_device *d = i2c_get_adapdata(adap);
472 int ret = 0;
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300473 int len, i, j;
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300474
475 if (!d)
476 return -ENODEV;
477 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
478 return -EAGAIN;
479
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300480 for (j = 0; j < num; j++) {
481 switch (msg[j].addr) {
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300482 case (DW2102_RC_QUERY): {
483 u8 ibuf[4];
484 ret = dw210x_op_rw(d->udev, 0xb8, 0, 0,
485 ibuf, 4, DW210X_READ_MSG);
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300486 memcpy(msg[j].buf, ibuf + 1, 2);
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300487 break;
488 }
489 case (DW2102_VOLTAGE_CTRL): {
490 u8 obuf[2];
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300491 obuf[0] = 3;
492 obuf[1] = msg[j].buf[0];
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300493 ret = dw210x_op_rw(d->udev, 0x8a, 0, 0,
494 obuf, 2, DW210X_WRITE_MSG);
495 break;
496 }
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300497 /*case 0x55: cx24116
498 case 0x6a: stv0903
499 case 0x68: ds3000, stv0903
500 case 0x60: ts2020, stv6110, stb6100
501 case 0xa0: eeprom */
502 default: {
503 if (msg[j].flags == I2C_M_RD) {
504 /* read registers */
505 u8 ibuf[msg[j].len];
506 ret = dw210x_op_rw(d->udev, 0x91, 0, 0,
507 ibuf, msg[j].len,
508 DW210X_READ_MSG);
509 memcpy(msg[j].buf, ibuf, msg[j].len);
510 break;
511 } else if ((msg[j].buf[0] == 0xb0) &&
512 (msg[j].addr == 0x68)) {
513 /* write firmware */
514 u8 obuf[19];
515 obuf[0] = (msg[j].len > 16 ?
516 18 : msg[j].len + 1);
517 obuf[1] = msg[j].addr << 1;
518 obuf[2] = msg[j].buf[0];
519 len = msg[j].len - 1;
520 i = 1;
521 do {
522 memcpy(obuf + 3, msg[j].buf + i,
523 (len > 16 ? 16 : len));
524 ret = dw210x_op_rw(d->udev, 0x80, 0, 0,
525 obuf, (len > 16 ? 16 : len) + 3,
526 DW210X_WRITE_MSG);
527 i += 16;
528 len -= 16;
529 } while (len > 0);
530 } else {
531 /* write registers */
532 u8 obuf[msg[j].len + 2];
533 obuf[0] = msg[j].len + 1;
534 obuf[1] = (msg[j].addr << 1);
535 memcpy(obuf + 2, msg[j].buf, msg[j].len);
536 ret = dw210x_op_rw(d->udev,
537 (num > 1 ? 0x90 : 0x80), 0, 0,
538 obuf, msg[j].len + 2,
539 DW210X_WRITE_MSG);
540 break;
541 }
542 break;
543 }
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300544 }
545
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300546 msleep(3);
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300547 }
548
549 mutex_unlock(&d->i2c_mutex);
550 return num;
551}
552
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300553static u32 dw210x_i2c_func(struct i2c_adapter *adapter)
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300554{
555 return I2C_FUNC_I2C;
556}
557
558static struct i2c_algorithm dw2102_i2c_algo = {
559 .master_xfer = dw2102_i2c_transfer,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300560 .functionality = dw210x_i2c_func,
561};
562
563static struct i2c_algorithm dw2102_serit_i2c_algo = {
564 .master_xfer = dw2102_serit_i2c_transfer,
565 .functionality = dw210x_i2c_func,
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300566};
567
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -0300568static struct i2c_algorithm dw2102_earda_i2c_algo = {
569 .master_xfer = dw2102_earda_i2c_transfer,
570 .functionality = dw210x_i2c_func,
571};
572
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300573static struct i2c_algorithm dw2104_i2c_algo = {
574 .master_xfer = dw2104_i2c_transfer,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300575 .functionality = dw210x_i2c_func,
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300576};
577
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -0300578static struct i2c_algorithm dw3101_i2c_algo = {
579 .master_xfer = dw3101_i2c_transfer,
580 .functionality = dw210x_i2c_func,
581};
582
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300583static struct i2c_algorithm s6x0_i2c_algo = {
584 .master_xfer = s6x0_i2c_transfer,
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300585 .functionality = dw210x_i2c_func,
586};
587
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300588static int dw210x_read_mac_address(struct dvb_usb_device *d, u8 mac[6])
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300589{
590 int i;
591 u8 ibuf[] = {0, 0};
592 u8 eeprom[256], eepromline[16];
593
594 for (i = 0; i < 256; i++) {
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300595 if (dw210x_op_rw(d->udev, 0xb6, 0xa0 , i, ibuf, 2, DW210X_READ_MSG) < 0) {
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300596 err("read eeprom failed.");
597 return -1;
598 } else {
599 eepromline[i%16] = ibuf[0];
600 eeprom[i] = ibuf[0];
601 }
602 if ((i % 16) == 15) {
603 deb_xfer("%02x: ", i - 15);
604 debug_dump(eepromline, 16, deb_xfer);
605 }
606 }
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -0300607
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300608 memcpy(mac, eeprom + 8, 6);
609 return 0;
610};
611
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300612static int s6x0_read_mac_address(struct dvb_usb_device *d, u8 mac[6])
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300613{
614 int i, ret;
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300615 u8 ibuf[] = { 0 }, obuf[] = { 0 };
616 u8 eeprom[256], eepromline[16];
617 struct i2c_msg msg[] = {
618 {
619 .addr = 0xa0 >> 1,
620 .flags = 0,
621 .buf = obuf,
622 .len = 1,
623 }, {
624 .addr = 0xa0 >> 1,
625 .flags = I2C_M_RD,
626 .buf = ibuf,
627 .len = 1,
628 }
629 };
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300630
631 for (i = 0; i < 256; i++) {
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300632 obuf[0] = i;
633 ret = s6x0_i2c_transfer(&d->i2c_adap, msg, 2);
634 if (ret != 2) {
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300635 err("read eeprom failed.");
636 return -1;
637 } else {
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300638 eepromline[i % 16] = ibuf[0];
639 eeprom[i] = ibuf[0];
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300640 }
641
642 if ((i % 16) == 15) {
643 deb_xfer("%02x: ", i - 15);
644 debug_dump(eepromline, 16, deb_xfer);
645 }
646 }
647
648 memcpy(mac, eeprom + 16, 6);
649 return 0;
650};
651
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300652static int dw210x_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300653{
654 static u8 command_13v[1] = {0x00};
655 static u8 command_18v[1] = {0x01};
656 struct i2c_msg msg[] = {
657 {.addr = DW2102_VOLTAGE_CTRL, .flags = 0,
658 .buf = command_13v, .len = 1},
659 };
660
661 struct dvb_usb_adapter *udev_adap =
662 (struct dvb_usb_adapter *)(fe->dvb->priv);
663 if (voltage == SEC_VOLTAGE_18)
664 msg[0].buf = command_18v;
665 i2c_transfer(&udev_adap->dev->i2c_adap, msg, 1);
666 return 0;
667}
668
Igor M. Liplianind4305c62008-10-17 13:45:55 -0300669static struct stv0299_config sharp_z0194a_config = {
670 .demod_address = 0x68,
671 .inittab = sharp_z0194a_inittab,
672 .mclk = 88000000UL,
673 .invert = 1,
674 .skip_reinit = 0,
675 .lock_output = STV0299_LOCKOUTPUT_1,
676 .volt13_op0_op1 = STV0299_VOLT13_OP1,
677 .min_delay_ms = 100,
678 .set_symbol_rate = sharp_z0194a_set_symbol_rate,
679};
680
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300681static struct cx24116_config dw2104_config = {
682 .demod_address = 0x55,
Igor M. Liplianincc8c4f32008-09-09 13:57:47 -0300683 .mpg_clk_pos_pol = 0x01,
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300684};
685
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300686static struct si21xx_config serit_sp1511lhb_config = {
687 .demod_address = 0x68,
688 .min_delay_ms = 100,
689
690};
691
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -0300692static struct tda10023_config dw3101_tda10023_config = {
693 .demod_address = 0x0c,
694 .invert = 1,
695};
696
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300697static struct mt312_config zl313_config = {
698 .demod_address = 0x0e,
699};
700
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300701static struct ds3000_config dw2104_ds3000_config = {
702 .demod_address = 0x68,
703};
704
705static struct stv0900_config dw2104a_stv0900_config = {
706 .demod_address = 0x6a,
707 .demod_mode = 0,
708 .xtal = 27000000,
709 .clkmode = 3,/* 0-CLKI, 2-XTALI, else AUTO */
710 .diseqc_mode = 2,/* 2/3 PWM */
711 .tun1_maddress = 0,/* 0x60 */
712 .tun1_adc = 0,/* 2 Vpp */
713 .path1_mode = 3,
714};
715
716static struct stb6100_config dw2104a_stb6100_config = {
717 .tuner_address = 0x60,
718 .refclock = 27000000,
719};
720
721static struct stv0900_config dw2104_stv0900_config = {
722 .demod_address = 0x68,
723 .demod_mode = 0,
724 .xtal = 8000000,
725 .clkmode = 3,
726 .diseqc_mode = 2,
727 .tun1_maddress = 0,
728 .tun1_adc = 1,/* 1 Vpp */
729 .path1_mode = 3,
730};
731
732static struct stv6110_config dw2104_stv6110_config = {
733 .i2c_address = 0x60,
734 .mclk = 16000000,
735 .clk_div = 1,
736};
737
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300738static int dw2104_frontend_attach(struct dvb_usb_adapter *d)
739{
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300740 struct dvb_tuner_ops *tuner_ops = NULL;
741
742 if (demod_probe & 4) {
743 d->fe = dvb_attach(stv0900_attach, &dw2104a_stv0900_config,
744 &d->dev->i2c_adap, 0);
745 if (d->fe != NULL) {
746 if (dvb_attach(stb6100_attach, d->fe,
747 &dw2104a_stb6100_config,
748 &d->dev->i2c_adap)) {
749 tuner_ops = &d->fe->ops.tuner_ops;
750 tuner_ops->set_frequency = stb6100_set_freq;
751 tuner_ops->get_frequency = stb6100_get_freq;
752 tuner_ops->set_bandwidth = stb6100_set_bandw;
753 tuner_ops->get_bandwidth = stb6100_get_bandw;
754 d->fe->ops.set_voltage = dw210x_set_voltage;
755 info("Attached STV0900+STB6100!\n");
756 return 0;
757 }
758 }
759 }
760
761 if (demod_probe & 2) {
762 d->fe = dvb_attach(stv0900_attach, &dw2104_stv0900_config,
763 &d->dev->i2c_adap, 0);
764 if (d->fe != NULL) {
765 if (dvb_attach(stv6110_attach, d->fe,
766 &dw2104_stv6110_config,
767 &d->dev->i2c_adap)) {
768 d->fe->ops.set_voltage = dw210x_set_voltage;
769 info("Attached STV0900+STV6110A!\n");
770 return 0;
771 }
772 }
773 }
774
775 if (demod_probe & 1) {
776 d->fe = dvb_attach(cx24116_attach, &dw2104_config,
777 &d->dev->i2c_adap);
778 if (d->fe != NULL) {
779 d->fe->ops.set_voltage = dw210x_set_voltage;
780 info("Attached cx24116!\n");
781 return 0;
782 }
783 }
784
785 d->fe = dvb_attach(ds3000_attach, &dw2104_ds3000_config,
786 &d->dev->i2c_adap);
787 if (d->fe != NULL) {
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300788 d->fe->ops.set_voltage = dw210x_set_voltage;
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300789 info("Attached DS3000!\n");
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300790 return 0;
791 }
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300792
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300793 return -EIO;
794}
795
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300796static struct dvb_usb_device_properties dw2102_properties;
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -0300797static struct dvb_usb_device_properties dw2104_properties;
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300798static struct dvb_usb_device_properties s6x0_properties;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300799
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300800static int dw2102_frontend_attach(struct dvb_usb_adapter *d)
801{
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300802 if (dw2102_properties.i2c_algo == &dw2102_serit_i2c_algo) {
803 /*dw2102_properties.adapter->tuner_attach = NULL;*/
804 d->fe = dvb_attach(si21xx_attach, &serit_sp1511lhb_config,
805 &d->dev->i2c_adap);
806 if (d->fe != NULL) {
807 d->fe->ops.set_voltage = dw210x_set_voltage;
808 info("Attached si21xx!\n");
809 return 0;
810 }
811 }
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300812
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -0300813 if (dw2102_properties.i2c_algo == &dw2102_earda_i2c_algo) {
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -0300814 d->fe = dvb_attach(stv0288_attach, &earda_config,
815 &d->dev->i2c_adap);
816 if (d->fe != NULL) {
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300817 if (dvb_attach(stb6000_attach, d->fe, 0x61,
818 &d->dev->i2c_adap)) {
819 d->fe->ops.set_voltage = dw210x_set_voltage;
820 info("Attached stv0288!\n");
821 return 0;
822 }
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -0300823 }
824 }
825
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300826 if (dw2102_properties.i2c_algo == &dw2102_i2c_algo) {
827 /*dw2102_properties.adapter->tuner_attach = dw2102_tuner_attach;*/
828 d->fe = dvb_attach(stv0299_attach, &sharp_z0194a_config,
829 &d->dev->i2c_adap);
830 if (d->fe != NULL) {
831 d->fe->ops.set_voltage = dw210x_set_voltage;
832 info("Attached stv0299!\n");
833 return 0;
834 }
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300835 }
836 return -EIO;
837}
838
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -0300839static int dw3101_frontend_attach(struct dvb_usb_adapter *d)
840{
841 d->fe = dvb_attach(tda10023_attach, &dw3101_tda10023_config,
842 &d->dev->i2c_adap, 0x48);
843 if (d->fe != NULL) {
844 info("Attached tda10023!\n");
845 return 0;
846 }
847 return -EIO;
848}
849
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300850static int s6x0_frontend_attach(struct dvb_usb_adapter *d)
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300851{
852 d->fe = dvb_attach(mt312_attach, &zl313_config,
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300853 &d->dev->i2c_adap);
854 if (d->fe != NULL) {
855 if (dvb_attach(zl10039_attach, d->fe, 0x60,
856 &d->dev->i2c_adap)) {
857 d->fe->ops.set_voltage = dw210x_set_voltage;
858 info("Attached zl100313+zl10039!\n");
859 return 0;
860 }
861 }
862
863 d->fe = dvb_attach(stv0288_attach, &earda_config,
864 &d->dev->i2c_adap);
865 if (d->fe != NULL) {
866 if (dvb_attach(stb6000_attach, d->fe, 0x61,
867 &d->dev->i2c_adap)) {
868 d->fe->ops.set_voltage = dw210x_set_voltage;
869 info("Attached stv0288+stb6000!\n");
870 return 0;
871 }
872 }
873
874 d->fe = dvb_attach(ds3000_attach, &dw2104_ds3000_config,
875 &d->dev->i2c_adap);
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300876 if (d->fe != NULL) {
877 d->fe->ops.set_voltage = dw210x_set_voltage;
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300878 info("Attached ds3000+ds2020!\n");
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300879 return 0;
880 }
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300881
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300882 return -EIO;
883}
884
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300885static int dw2102_tuner_attach(struct dvb_usb_adapter *adap)
886{
887 dvb_attach(dvb_pll_attach, adap->fe, 0x60,
888 &adap->dev->i2c_adap, DVB_PLL_OPERA1);
889 return 0;
890}
891
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -0300892static int dw3101_tuner_attach(struct dvb_usb_adapter *adap)
893{
894 dvb_attach(dvb_pll_attach, adap->fe, 0x60,
895 &adap->dev->i2c_adap, DVB_PLL_TUA6034);
896
897 return 0;
898}
899
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300900static struct dvb_usb_rc_key dw210x_rc_keys[] = {
Mauro Carvalho Chehab2e365882009-08-29 15:19:31 -0300901 { 0xf80a, KEY_Q }, /*power*/
902 { 0xf80c, KEY_M }, /*mute*/
903 { 0xf811, KEY_1 },
904 { 0xf812, KEY_2 },
905 { 0xf813, KEY_3 },
906 { 0xf814, KEY_4 },
907 { 0xf815, KEY_5 },
908 { 0xf816, KEY_6 },
909 { 0xf817, KEY_7 },
910 { 0xf818, KEY_8 },
911 { 0xf819, KEY_9 },
912 { 0xf810, KEY_0 },
913 { 0xf81c, KEY_PAGEUP }, /*ch+*/
914 { 0xf80f, KEY_PAGEDOWN }, /*ch-*/
915 { 0xf81a, KEY_O }, /*vol+*/
916 { 0xf80e, KEY_Z }, /*vol-*/
917 { 0xf804, KEY_R }, /*rec*/
918 { 0xf809, KEY_D }, /*fav*/
919 { 0xf808, KEY_BACKSPACE }, /*rewind*/
920 { 0xf807, KEY_A }, /*fast*/
921 { 0xf80b, KEY_P }, /*pause*/
922 { 0xf802, KEY_ESC }, /*cancel*/
923 { 0xf803, KEY_G }, /*tab*/
924 { 0xf800, KEY_UP }, /*up*/
925 { 0xf81f, KEY_ENTER }, /*ok*/
926 { 0xf801, KEY_DOWN }, /*down*/
927 { 0xf805, KEY_C }, /*cap*/
928 { 0xf806, KEY_S }, /*stop*/
929 { 0xf840, KEY_F }, /*full*/
930 { 0xf81e, KEY_W }, /*tvmode*/
931 { 0xf81b, KEY_B }, /*recall*/
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300932};
933
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -0300934static struct dvb_usb_rc_key tevii_rc_keys[] = {
Mauro Carvalho Chehab2e365882009-08-29 15:19:31 -0300935 { 0xf80a, KEY_POWER },
936 { 0xf80c, KEY_MUTE },
937 { 0xf811, KEY_1 },
938 { 0xf812, KEY_2 },
939 { 0xf813, KEY_3 },
940 { 0xf814, KEY_4 },
941 { 0xf815, KEY_5 },
942 { 0xf816, KEY_6 },
943 { 0xf817, KEY_7 },
944 { 0xf818, KEY_8 },
945 { 0xf819, KEY_9 },
946 { 0xf810, KEY_0 },
947 { 0xf81c, KEY_MENU },
948 { 0xf80f, KEY_VOLUMEDOWN },
949 { 0xf81a, KEY_LAST },
950 { 0xf80e, KEY_OPEN },
951 { 0xf804, KEY_RECORD },
952 { 0xf809, KEY_VOLUMEUP },
953 { 0xf808, KEY_CHANNELUP },
954 { 0xf807, KEY_PVR },
955 { 0xf80b, KEY_TIME },
956 { 0xf802, KEY_RIGHT },
957 { 0xf803, KEY_LEFT },
958 { 0xf800, KEY_UP },
959 { 0xf81f, KEY_OK },
960 { 0xf801, KEY_DOWN },
961 { 0xf805, KEY_TUNER },
962 { 0xf806, KEY_CHANNELDOWN },
963 { 0xf840, KEY_PLAYPAUSE },
964 { 0xf81e, KEY_REWIND },
965 { 0xf81b, KEY_FAVORITES },
966 { 0xf81d, KEY_BACK },
967 { 0xf84d, KEY_FASTFORWARD },
968 { 0xf844, KEY_EPG },
969 { 0xf84c, KEY_INFO },
970 { 0xf841, KEY_AB },
971 { 0xf843, KEY_AUDIO },
972 { 0xf845, KEY_SUBTITLE },
973 { 0xf84a, KEY_LIST },
974 { 0xf846, KEY_F1 },
975 { 0xf847, KEY_F2 },
976 { 0xf85e, KEY_F3 },
977 { 0xf85c, KEY_F4 },
978 { 0xf852, KEY_F5 },
979 { 0xf85a, KEY_F6 },
980 { 0xf856, KEY_MODE },
981 { 0xf858, KEY_SWITCHVIDEOMODE },
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -0300982};
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300983
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -0300984static struct dvb_usb_rc_key tbs_rc_keys[] = {
Mauro Carvalho Chehab2e365882009-08-29 15:19:31 -0300985 { 0xf884, KEY_POWER },
986 { 0xf894, KEY_MUTE },
987 { 0xf887, KEY_1 },
988 { 0xf886, KEY_2 },
989 { 0xf885, KEY_3 },
990 { 0xf88b, KEY_4 },
991 { 0xf88a, KEY_5 },
992 { 0xf889, KEY_6 },
993 { 0xf88f, KEY_7 },
994 { 0xf88e, KEY_8 },
995 { 0xf88d, KEY_9 },
996 { 0xf892, KEY_0 },
997 { 0xf896, KEY_CHANNELUP },
998 { 0xf891, KEY_CHANNELDOWN },
999 { 0xf893, KEY_VOLUMEUP },
1000 { 0xf88c, KEY_VOLUMEDOWN },
1001 { 0xf883, KEY_RECORD },
1002 { 0xf898, KEY_PAUSE },
1003 { 0xf899, KEY_OK },
1004 { 0xf89a, KEY_SHUFFLE },
1005 { 0xf881, KEY_UP },
1006 { 0xf890, KEY_LEFT },
1007 { 0xf882, KEY_RIGHT },
1008 { 0xf888, KEY_DOWN },
1009 { 0xf895, KEY_FAVORITES },
1010 { 0xf897, KEY_SUBTITLE },
1011 { 0xf89d, KEY_ZOOM },
1012 { 0xf89f, KEY_EXIT },
1013 { 0xf89e, KEY_MENU },
1014 { 0xf89c, KEY_EPG },
1015 { 0xf880, KEY_PREVIOUS },
1016 { 0xf89b, KEY_MODE }
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -03001017};
1018
1019static struct dvb_usb_rc_keys_table keys_tables[] = {
1020 { dw210x_rc_keys, ARRAY_SIZE(dw210x_rc_keys) },
1021 { tevii_rc_keys, ARRAY_SIZE(tevii_rc_keys) },
1022 { tbs_rc_keys, ARRAY_SIZE(tbs_rc_keys) },
1023};
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001024
1025static int dw2102_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
1026{
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -03001027 struct dvb_usb_rc_key *keymap = d->props.rc_key_map;
1028 int keymap_size = d->props.rc_key_map_size;
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001029 u8 key[2];
Igor M. Liplianin8a8dad72009-06-13 08:10:24 -03001030 struct i2c_msg msg = {
1031 .addr = DW2102_RC_QUERY,
1032 .flags = I2C_M_RD,
1033 .buf = key,
1034 .len = 2
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001035 };
1036 int i;
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -03001037 /* override keymap */
1038 if ((ir_keymap > 0) && (ir_keymap <= ARRAY_SIZE(keys_tables))) {
1039 keymap = keys_tables[ir_keymap - 1].rc_keys ;
1040 keymap_size = keys_tables[ir_keymap - 1].rc_keys_size;
1041 }
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001042
1043 *state = REMOTE_NO_KEY_PRESSED;
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001044 if (d->props.i2c_algo->master_xfer(&d->i2c_adap, &msg, 1) == 1) {
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -03001045 for (i = 0; i < keymap_size ; i++) {
Mauro Carvalho Chehab2e365882009-08-29 15:19:31 -03001046 if (rc5_data(&keymap[i]) == msg.buf[0]) {
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001047 *state = REMOTE_KEY_PRESSED;
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -03001048 *event = keymap[i].event;
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001049 break;
1050 }
Igor M. Liplianin8a8dad72009-06-13 08:10:24 -03001051
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001052 }
Igor M. Liplianin8a8dad72009-06-13 08:10:24 -03001053
1054 if ((*state) == REMOTE_KEY_PRESSED)
1055 deb_rc("%s: found rc key: %x, %x, event: %x\n",
1056 __func__, key[0], key[1], (*event));
1057 else if (key[0] != 0xff)
1058 deb_rc("%s: unknown rc key: %x, %x\n",
1059 __func__, key[0], key[1]);
1060
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001061 }
Igor M. Liplianin8a8dad72009-06-13 08:10:24 -03001062
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001063 return 0;
1064}
1065
1066static struct usb_device_id dw2102_table[] = {
1067 {USB_DEVICE(USB_VID_CYPRESS, USB_PID_DW2102)},
1068 {USB_DEVICE(USB_VID_CYPRESS, 0x2101)},
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001069 {USB_DEVICE(USB_VID_CYPRESS, USB_PID_DW2104)},
1070 {USB_DEVICE(0x9022, USB_PID_TEVII_S650)},
Igor M. Liplianin4cc0edf2008-11-05 22:12:56 -03001071 {USB_DEVICE(USB_VID_TERRATEC, USB_PID_CINERGY_S)},
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001072 {USB_DEVICE(USB_VID_CYPRESS, USB_PID_DW3101)},
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001073 {USB_DEVICE(0x9022, USB_PID_TEVII_S630)},
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001074 {USB_DEVICE(0x3011, USB_PID_PROF_1100)},
1075 {USB_DEVICE(0x9022, USB_PID_TEVII_S660)},
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001076 { }
1077};
1078
1079MODULE_DEVICE_TABLE(usb, dw2102_table);
1080
1081static int dw2102_load_firmware(struct usb_device *dev,
1082 const struct firmware *frmwr)
1083{
1084 u8 *b, *p;
1085 int ret = 0, i;
1086 u8 reset;
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -03001087 u8 reset16[] = {0, 0, 0, 0, 0, 0, 0};
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001088 const struct firmware *fw;
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001089 const char *fw_2101 = "dvb-usb-dw2101.fw";
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001090
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001091 switch (dev->descriptor.idProduct) {
1092 case 0x2101:
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001093 ret = request_firmware(&fw, fw_2101, &dev->dev);
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001094 if (ret != 0) {
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001095 err(err_str, fw_2101);
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001096 return ret;
1097 }
1098 break;
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001099 default:
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001100 fw = frmwr;
1101 break;
1102 }
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001103 info("start downloading DW210X firmware");
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001104 p = kmalloc(fw->size, GFP_KERNEL);
1105 reset = 1;
1106 /*stop the CPU*/
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001107 dw210x_op_rw(dev, 0xa0, 0x7f92, 0, &reset, 1, DW210X_WRITE_MSG);
1108 dw210x_op_rw(dev, 0xa0, 0xe600, 0, &reset, 1, DW210X_WRITE_MSG);
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001109
1110 if (p != NULL) {
1111 memcpy(p, fw->data, fw->size);
1112 for (i = 0; i < fw->size; i += 0x40) {
1113 b = (u8 *) p + i;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001114 if (dw210x_op_rw(dev, 0xa0, i, 0, b , 0x40,
1115 DW210X_WRITE_MSG) != 0x40) {
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001116 err("error while transferring firmware");
1117 ret = -EINVAL;
1118 break;
1119 }
1120 }
1121 /* restart the CPU */
1122 reset = 0;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001123 if (ret || dw210x_op_rw(dev, 0xa0, 0x7f92, 0, &reset, 1,
1124 DW210X_WRITE_MSG) != 1) {
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001125 err("could not restart the USB controller CPU.");
1126 ret = -EINVAL;
1127 }
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001128 if (ret || dw210x_op_rw(dev, 0xa0, 0xe600, 0, &reset, 1,
1129 DW210X_WRITE_MSG) != 1) {
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001130 err("could not restart the USB controller CPU.");
1131 ret = -EINVAL;
1132 }
1133 /* init registers */
1134 switch (dev->descriptor.idProduct) {
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001135 case USB_PID_PROF_1100:
1136 s6x0_properties.rc_key_map = tbs_rc_keys;
1137 s6x0_properties.rc_key_map_size =
1138 ARRAY_SIZE(tbs_rc_keys);
1139 break;
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001140 case USB_PID_TEVII_S650:
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -03001141 dw2104_properties.rc_key_map = tevii_rc_keys;
1142 dw2104_properties.rc_key_map_size =
1143 ARRAY_SIZE(tevii_rc_keys);
1144 case USB_PID_DW2104:
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001145 reset = 1;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001146 dw210x_op_rw(dev, 0xc4, 0x0000, 0, &reset, 1,
1147 DW210X_WRITE_MSG);
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001148 /* break omitted intentionally */
1149 case USB_PID_DW3101:
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001150 reset = 0;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001151 dw210x_op_rw(dev, 0xbf, 0x0040, 0, &reset, 0,
1152 DW210X_WRITE_MSG);
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001153 break;
Igor M. Liplianin4cc0edf2008-11-05 22:12:56 -03001154 case USB_PID_CINERGY_S:
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001155 case USB_PID_DW2102:
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001156 dw210x_op_rw(dev, 0xbf, 0x0040, 0, &reset, 0,
1157 DW210X_WRITE_MSG);
1158 dw210x_op_rw(dev, 0xb9, 0x0000, 0, &reset16[0], 2,
1159 DW210X_READ_MSG);
1160 /* check STV0299 frontend */
1161 dw210x_op_rw(dev, 0xb5, 0, 0, &reset16[0], 2,
1162 DW210X_READ_MSG);
Igor M. Liplianinea023df2008-12-04 12:49:23 -03001163 if ((reset16[0] == 0xa1) || (reset16[0] == 0x80)) {
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001164 dw2102_properties.i2c_algo = &dw2102_i2c_algo;
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -03001165 dw2102_properties.adapter->tuner_attach = &dw2102_tuner_attach;
1166 break;
1167 } else {
1168 /* check STV0288 frontend */
1169 reset16[0] = 0xd0;
1170 reset16[1] = 1;
1171 reset16[2] = 0;
1172 dw210x_op_rw(dev, 0xc2, 0, 0, &reset16[0], 3,
1173 DW210X_WRITE_MSG);
1174 dw210x_op_rw(dev, 0xc3, 0xd1, 0, &reset16[0], 3,
1175 DW210X_READ_MSG);
1176 if (reset16[2] == 0x11) {
1177 dw2102_properties.i2c_algo = &dw2102_earda_i2c_algo;
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -03001178 break;
1179 }
1180 }
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001181 case 0x2101:
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001182 dw210x_op_rw(dev, 0xbc, 0x0030, 0, &reset16[0], 2,
1183 DW210X_READ_MSG);
1184 dw210x_op_rw(dev, 0xba, 0x0000, 0, &reset16[0], 7,
1185 DW210X_READ_MSG);
1186 dw210x_op_rw(dev, 0xba, 0x0000, 0, &reset16[0], 7,
1187 DW210X_READ_MSG);
1188 dw210x_op_rw(dev, 0xb9, 0x0000, 0, &reset16[0], 2,
1189 DW210X_READ_MSG);
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001190 break;
1191 }
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001192
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001193 msleep(100);
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001194 kfree(p);
1195 }
1196 return ret;
1197}
1198
1199static struct dvb_usb_device_properties dw2102_properties = {
1200 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1201 .usb_ctrl = DEVICE_SPECIFIC,
1202 .firmware = "dvb-usb-dw2102.fw",
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001203 .no_reconnect = 1,
1204
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001205 .i2c_algo = &dw2102_serit_i2c_algo,
1206 .rc_key_map = dw210x_rc_keys,
1207 .rc_key_map_size = ARRAY_SIZE(dw210x_rc_keys),
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001208 .rc_interval = 150,
1209 .rc_query = dw2102_rc_query,
1210
1211 .generic_bulk_ctrl_endpoint = 0x81,
1212 /* parameter for the MPEG2-data transfer */
1213 .num_adapters = 1,
1214 .download_firmware = dw2102_load_firmware,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001215 .read_mac_address = dw210x_read_mac_address,
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001216 .adapter = {
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001217 {
1218 .frontend_attach = dw2102_frontend_attach,
1219 .streaming_ctrl = NULL,
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -03001220 .tuner_attach = NULL,
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001221 .stream = {
1222 .type = USB_BULK,
1223 .count = 8,
1224 .endpoint = 0x82,
1225 .u = {
1226 .bulk = {
1227 .buffersize = 4096,
1228 }
1229 }
1230 },
1231 }
1232 },
Igor M. Liplianin4cc0edf2008-11-05 22:12:56 -03001233 .num_device_descs = 3,
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001234 .devices = {
1235 {"DVBWorld DVB-S 2102 USB2.0",
1236 {&dw2102_table[0], NULL},
1237 {NULL},
1238 },
1239 {"DVBWorld DVB-S 2101 USB2.0",
1240 {&dw2102_table[1], NULL},
1241 {NULL},
1242 },
Igor M. Liplianin4cc0edf2008-11-05 22:12:56 -03001243 {"TerraTec Cinergy S USB",
1244 {&dw2102_table[4], NULL},
1245 {NULL},
1246 },
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001247 }
1248};
1249
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001250static struct dvb_usb_device_properties dw2104_properties = {
1251 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1252 .usb_ctrl = DEVICE_SPECIFIC,
1253 .firmware = "dvb-usb-dw2104.fw",
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001254 .no_reconnect = 1,
1255
1256 .i2c_algo = &dw2104_i2c_algo,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001257 .rc_key_map = dw210x_rc_keys,
1258 .rc_key_map_size = ARRAY_SIZE(dw210x_rc_keys),
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001259 .rc_interval = 150,
1260 .rc_query = dw2102_rc_query,
1261
1262 .generic_bulk_ctrl_endpoint = 0x81,
1263 /* parameter for the MPEG2-data transfer */
1264 .num_adapters = 1,
1265 .download_firmware = dw2102_load_firmware,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001266 .read_mac_address = dw210x_read_mac_address,
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001267 .adapter = {
1268 {
1269 .frontend_attach = dw2104_frontend_attach,
1270 .streaming_ctrl = NULL,
1271 /*.tuner_attach = dw2104_tuner_attach,*/
1272 .stream = {
1273 .type = USB_BULK,
1274 .count = 8,
1275 .endpoint = 0x82,
1276 .u = {
1277 .bulk = {
1278 .buffersize = 4096,
1279 }
1280 }
1281 },
1282 }
1283 },
1284 .num_device_descs = 2,
1285 .devices = {
1286 { "DVBWorld DW2104 USB2.0",
1287 {&dw2102_table[2], NULL},
1288 {NULL},
1289 },
1290 { "TeVii S650 USB2.0",
1291 {&dw2102_table[3], NULL},
1292 {NULL},
1293 },
1294 }
1295};
1296
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001297static struct dvb_usb_device_properties dw3101_properties = {
1298 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1299 .usb_ctrl = DEVICE_SPECIFIC,
1300 .firmware = "dvb-usb-dw3101.fw",
1301 .no_reconnect = 1,
1302
1303 .i2c_algo = &dw3101_i2c_algo,
1304 .rc_key_map = dw210x_rc_keys,
1305 .rc_key_map_size = ARRAY_SIZE(dw210x_rc_keys),
1306 .rc_interval = 150,
1307 .rc_query = dw2102_rc_query,
1308
1309 .generic_bulk_ctrl_endpoint = 0x81,
1310 /* parameter for the MPEG2-data transfer */
1311 .num_adapters = 1,
1312 .download_firmware = dw2102_load_firmware,
1313 .read_mac_address = dw210x_read_mac_address,
1314 .adapter = {
1315 {
1316 .frontend_attach = dw3101_frontend_attach,
1317 .streaming_ctrl = NULL,
1318 .tuner_attach = dw3101_tuner_attach,
1319 .stream = {
1320 .type = USB_BULK,
1321 .count = 8,
1322 .endpoint = 0x82,
1323 .u = {
1324 .bulk = {
1325 .buffersize = 4096,
1326 }
1327 }
1328 },
1329 }
1330 },
1331 .num_device_descs = 1,
1332 .devices = {
1333 { "DVBWorld DVB-C 3101 USB2.0",
1334 {&dw2102_table[5], NULL},
1335 {NULL},
1336 },
1337 }
1338};
1339
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001340static struct dvb_usb_device_properties s6x0_properties = {
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001341 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1342 .usb_ctrl = DEVICE_SPECIFIC,
1343 .firmware = "dvb-usb-s630.fw",
1344 .no_reconnect = 1,
1345
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001346 .i2c_algo = &s6x0_i2c_algo,
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001347 .rc_key_map = tevii_rc_keys,
1348 .rc_key_map_size = ARRAY_SIZE(tevii_rc_keys),
1349 .rc_interval = 150,
1350 .rc_query = dw2102_rc_query,
1351
1352 .generic_bulk_ctrl_endpoint = 0x81,
1353 .num_adapters = 1,
1354 .download_firmware = dw2102_load_firmware,
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001355 .read_mac_address = s6x0_read_mac_address,
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001356 .adapter = {
1357 {
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001358 .frontend_attach = s6x0_frontend_attach,
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001359 .streaming_ctrl = NULL,
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001360 .tuner_attach = NULL,
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001361 .stream = {
1362 .type = USB_BULK,
1363 .count = 8,
1364 .endpoint = 0x82,
1365 .u = {
1366 .bulk = {
1367 .buffersize = 4096,
1368 }
1369 }
1370 },
1371 }
1372 },
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001373 .num_device_descs = 3,
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001374 .devices = {
1375 {"TeVii S630 USB",
1376 {&dw2102_table[6], NULL},
1377 {NULL},
1378 },
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001379 {"Prof 1100 USB ",
1380 {&dw2102_table[7], NULL},
1381 {NULL},
1382 },
1383 {"TeVii S660 USB",
1384 {&dw2102_table[8], NULL},
1385 {NULL},
1386 },
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001387 }
1388};
1389
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001390static int dw2102_probe(struct usb_interface *intf,
1391 const struct usb_device_id *id)
1392{
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001393 if (0 == dvb_usb_device_init(intf, &dw2102_properties,
1394 THIS_MODULE, NULL, adapter_nr) ||
1395 0 == dvb_usb_device_init(intf, &dw2104_properties,
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001396 THIS_MODULE, NULL, adapter_nr) ||
1397 0 == dvb_usb_device_init(intf, &dw3101_properties,
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001398 THIS_MODULE, NULL, adapter_nr) ||
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001399 0 == dvb_usb_device_init(intf, &s6x0_properties,
1400 THIS_MODULE, NULL, adapter_nr))
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001401 return 0;
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001402
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001403 return -ENODEV;
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001404}
1405
1406static struct usb_driver dw2102_driver = {
1407 .name = "dw2102",
1408 .probe = dw2102_probe,
1409 .disconnect = dvb_usb_device_exit,
1410 .id_table = dw2102_table,
1411};
1412
1413static int __init dw2102_module_init(void)
1414{
1415 int ret = usb_register(&dw2102_driver);
1416 if (ret)
1417 err("usb_register failed. Error number %d", ret);
1418
1419 return ret;
1420}
1421
1422static void __exit dw2102_module_exit(void)
1423{
1424 usb_deregister(&dw2102_driver);
1425}
1426
1427module_init(dw2102_module_init);
1428module_exit(dw2102_module_exit);
1429
1430MODULE_AUTHOR("Igor M. Liplianin (c) liplianin@me.by");
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001431MODULE_DESCRIPTION("Driver for DVBWorld DVB-S 2101, 2102, DVB-S2 2104,"
1432 " DVB-C 3101 USB2.0,"
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001433 " TeVii S600, S630, S650, S660 USB2.0,"
1434 " Prof 1100 USB2.0 devices");
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001435MODULE_VERSION("0.1");
1436MODULE_LICENSE("GPL");