blob: 0ab377e3d6f2db6e0efb71b2073a2cf77024cff9 [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. Liplianincd79d332009-12-14 20:24:56 -03003* TeVii S600, S630, S650,
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03004* Prof 1100, 7500,
5 * Geniatech SU3000 Cards
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03006* Copyright (C) 2008,2009 Igor M. Liplianin (liplianin@me.by)
Igor M Liplianin7fd48282008-07-20 08:05:50 -03007*
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
59#ifndef USB_PID_PROF_1100
60#define USB_PID_PROF_1100 0xb012
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -030061#endif
62
Igor M. Liplianin21b007b2008-09-17 19:19:19 -030063#define DW210X_READ_MSG 0
64#define DW210X_WRITE_MSG 1
Igor M Liplianin7fd48282008-07-20 08:05:50 -030065
66#define REG_1F_SYMBOLRATE_BYTE0 0x1f
67#define REG_20_SYMBOLRATE_BYTE1 0x20
68#define REG_21_SYMBOLRATE_BYTE2 0x21
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -030069/* on my own*/
Igor M Liplianin7fd48282008-07-20 08:05:50 -030070#define DW2102_VOLTAGE_CTRL (0x1800)
Igor M. Liplianind2ffc442011-02-25 18:41:22 -030071#define SU3000_STREAM_CTRL (0x1900)
Igor M Liplianin7fd48282008-07-20 08:05:50 -030072#define DW2102_RC_QUERY (0x1a00)
Igor M. Liplianinfa8bae12011-02-25 18:41:22 -030073#define DW2102_LED_CTRL (0x1b00)
Igor M Liplianin7fd48282008-07-20 08:05:50 -030074
Igor M. Liplianin141cc352009-11-27 14:37:35 -030075#define err_str "did not find the firmware file. (%s) " \
76 "Please see linux/Documentation/dvb/ for more details " \
77 "on firmware-problems."
78
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -030079struct rc_map_dvb_usb_table_table {
80 struct rc_map_table *rc_keys;
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -030081 int rc_keys_size;
Igor M Liplianin7fd48282008-07-20 08:05:50 -030082};
83
Igor M. Liplianind2ffc442011-02-25 18:41:22 -030084struct su3000_state {
85 u8 initialized;
86};
87
Igor M. Liplianin52c506e2011-02-25 18:41:23 -030088struct s6x0_state {
89 int (*old_set_voltage)(struct dvb_frontend *f, fe_sec_voltage_t v);
90};
91
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -030092/* debug */
93static int dvb_usb_dw2102_debug;
94module_param_named(debug, dvb_usb_dw2102_debug, int, 0644);
Igor M. Liplianin8a8dad72009-06-13 08:10:24 -030095MODULE_PARM_DESC(debug, "set debugging level (1=info 2=xfer 4=rc(or-able))."
96 DVB_USB_DEBUG_STATUS);
97
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -030098/* keymaps */
99static int ir_keymap;
100module_param_named(keymap, ir_keymap, int, 0644);
Igor M. Liplianinfeb16e92011-02-25 18:41:22 -0300101MODULE_PARM_DESC(keymap, "set keymap 0=default 1=dvbworld 2=tevii 3=tbs ..."
102 " 256=none");
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300103
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300104/* demod probe */
105static int demod_probe = 1;
106module_param_named(demod, demod_probe, int, 0644);
107MODULE_PARM_DESC(demod, "demod to probe (1=cx24116 2=stv0903+stv6110 "
108 "4=stv0903+stb6100(or-able)).");
109
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300110DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
111
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300112static int dw210x_op_rw(struct usb_device *dev, u8 request, u16 value,
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300113 u16 index, u8 * data, u16 len, int flags)
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300114{
115 int ret;
116 u8 u8buf[len];
117
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300118 unsigned int pipe = (flags == DW210X_READ_MSG) ?
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300119 usb_rcvctrlpipe(dev, 0) : usb_sndctrlpipe(dev, 0);
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300120 u8 request_type = (flags == DW210X_READ_MSG) ? USB_DIR_IN : USB_DIR_OUT;
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300121
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300122 if (flags == DW210X_WRITE_MSG)
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300123 memcpy(u8buf, data, len);
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300124 ret = usb_control_msg(dev, pipe, request, request_type | USB_TYPE_VENDOR,
125 value, index , u8buf, len, 2000);
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300126
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300127 if (flags == DW210X_READ_MSG)
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300128 memcpy(data, u8buf, len);
129 return ret;
130}
131
132/* I2C */
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300133static int dw2102_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
134 int num)
135{
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -0300136 struct dvb_usb_device *d = i2c_get_adapdata(adap);
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300137 int i = 0, ret = 0;
138 u8 buf6[] = {0x2c, 0x05, 0xc0, 0, 0, 0, 0};
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300139 u16 value;
140
141 if (!d)
142 return -ENODEV;
143 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
144 return -EAGAIN;
145
146 switch (num) {
147 case 2:
148 /* read stv0299 register */
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300149 value = msg[0].buf[0];/* register */
150 for (i = 0; i < msg[1].len; i++) {
151 value = value + i;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300152 ret = dw210x_op_rw(d->udev, 0xb5, value, 0,
153 buf6, 2, DW210X_READ_MSG);
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300154 msg[1].buf[i] = buf6[0];
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300155 }
156 break;
157 case 1:
158 switch (msg[0].addr) {
159 case 0x68:
160 /* write to stv0299 register */
161 buf6[0] = 0x2a;
162 buf6[1] = msg[0].buf[0];
163 buf6[2] = msg[0].buf[1];
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300164 ret = dw210x_op_rw(d->udev, 0xb2, 0, 0,
165 buf6, 3, DW210X_WRITE_MSG);
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300166 break;
167 case 0x60:
168 if (msg[0].flags == 0) {
169 /* write to tuner pll */
170 buf6[0] = 0x2c;
171 buf6[1] = 5;
172 buf6[2] = 0xc0;
173 buf6[3] = msg[0].buf[0];
174 buf6[4] = msg[0].buf[1];
175 buf6[5] = msg[0].buf[2];
176 buf6[6] = msg[0].buf[3];
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300177 ret = dw210x_op_rw(d->udev, 0xb2, 0, 0,
178 buf6, 7, DW210X_WRITE_MSG);
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300179 } else {
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300180 /* read from tuner */
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300181 ret = dw210x_op_rw(d->udev, 0xb5, 0, 0,
182 buf6, 1, DW210X_READ_MSG);
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300183 msg[0].buf[0] = buf6[0];
184 }
185 break;
186 case (DW2102_RC_QUERY):
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300187 ret = dw210x_op_rw(d->udev, 0xb8, 0, 0,
188 buf6, 2, DW210X_READ_MSG);
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300189 msg[0].buf[0] = buf6[0];
190 msg[0].buf[1] = buf6[1];
191 break;
192 case (DW2102_VOLTAGE_CTRL):
193 buf6[0] = 0x30;
194 buf6[1] = msg[0].buf[0];
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300195 ret = dw210x_op_rw(d->udev, 0xb2, 0, 0,
196 buf6, 2, DW210X_WRITE_MSG);
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300197 break;
198 }
199
200 break;
201 }
202
203 mutex_unlock(&d->i2c_mutex);
204 return num;
205}
206
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300207static int dw2102_serit_i2c_transfer(struct i2c_adapter *adap,
208 struct i2c_msg msg[], int num)
209{
210 struct dvb_usb_device *d = i2c_get_adapdata(adap);
211 int ret = 0;
212 u8 buf6[] = {0, 0, 0, 0, 0, 0, 0};
213
214 if (!d)
215 return -ENODEV;
216 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
217 return -EAGAIN;
218
219 switch (num) {
220 case 2:
221 /* read si2109 register by number */
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300222 buf6[0] = msg[0].addr << 1;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300223 buf6[1] = msg[0].len;
224 buf6[2] = msg[0].buf[0];
225 ret = dw210x_op_rw(d->udev, 0xc2, 0, 0,
226 buf6, msg[0].len + 2, DW210X_WRITE_MSG);
227 /* read si2109 register */
228 ret = dw210x_op_rw(d->udev, 0xc3, 0xd0, 0,
229 buf6, msg[1].len + 2, DW210X_READ_MSG);
230 memcpy(msg[1].buf, buf6 + 2, msg[1].len);
231
232 break;
233 case 1:
234 switch (msg[0].addr) {
235 case 0x68:
236 /* write to si2109 register */
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300237 buf6[0] = msg[0].addr << 1;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300238 buf6[1] = msg[0].len;
239 memcpy(buf6 + 2, msg[0].buf, msg[0].len);
240 ret = dw210x_op_rw(d->udev, 0xc2, 0, 0, buf6,
241 msg[0].len + 2, DW210X_WRITE_MSG);
242 break;
243 case(DW2102_RC_QUERY):
244 ret = dw210x_op_rw(d->udev, 0xb8, 0, 0,
245 buf6, 2, DW210X_READ_MSG);
246 msg[0].buf[0] = buf6[0];
247 msg[0].buf[1] = buf6[1];
248 break;
249 case(DW2102_VOLTAGE_CTRL):
250 buf6[0] = 0x30;
251 buf6[1] = msg[0].buf[0];
252 ret = dw210x_op_rw(d->udev, 0xb2, 0, 0,
253 buf6, 2, DW210X_WRITE_MSG);
254 break;
255 }
256 break;
257 }
258
259 mutex_unlock(&d->i2c_mutex);
260 return num;
261}
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -0300262
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -0300263static int dw2102_earda_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], int num)
264{
265 struct dvb_usb_device *d = i2c_get_adapdata(adap);
266 int ret = 0;
267
268 if (!d)
269 return -ENODEV;
270 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
271 return -EAGAIN;
272
273 switch (num) {
274 case 2: {
275 /* read */
276 /* first write first register number */
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -0300277 u8 ibuf[msg[1].len + 2], obuf[3];
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300278 obuf[0] = msg[0].addr << 1;
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -0300279 obuf[1] = msg[0].len;
280 obuf[2] = msg[0].buf[0];
281 ret = dw210x_op_rw(d->udev, 0xc2, 0, 0,
282 obuf, msg[0].len + 2, DW210X_WRITE_MSG);
283 /* second read registers */
284 ret = dw210x_op_rw(d->udev, 0xc3, 0xd1 , 0,
285 ibuf, msg[1].len + 2, DW210X_READ_MSG);
286 memcpy(msg[1].buf, ibuf + 2, msg[1].len);
287
288 break;
289 }
290 case 1:
291 switch (msg[0].addr) {
292 case 0x68: {
293 /* write to register */
294 u8 obuf[msg[0].len + 2];
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300295 obuf[0] = msg[0].addr << 1;
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -0300296 obuf[1] = msg[0].len;
297 memcpy(obuf + 2, msg[0].buf, msg[0].len);
298 ret = dw210x_op_rw(d->udev, 0xc2, 0, 0,
299 obuf, msg[0].len + 2, DW210X_WRITE_MSG);
300 break;
301 }
302 case 0x61: {
303 /* write to tuner */
304 u8 obuf[msg[0].len + 2];
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300305 obuf[0] = msg[0].addr << 1;
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -0300306 obuf[1] = msg[0].len;
307 memcpy(obuf + 2, msg[0].buf, msg[0].len);
308 ret = dw210x_op_rw(d->udev, 0xc2, 0, 0,
309 obuf, msg[0].len + 2, DW210X_WRITE_MSG);
310 break;
311 }
312 case(DW2102_RC_QUERY): {
313 u8 ibuf[2];
314 ret = dw210x_op_rw(d->udev, 0xb8, 0, 0,
315 ibuf, 2, DW210X_READ_MSG);
316 memcpy(msg[0].buf, ibuf , 2);
317 break;
318 }
319 case(DW2102_VOLTAGE_CTRL): {
320 u8 obuf[2];
321 obuf[0] = 0x30;
322 obuf[1] = msg[0].buf[0];
323 ret = dw210x_op_rw(d->udev, 0xb2, 0, 0,
324 obuf, 2, DW210X_WRITE_MSG);
325 break;
326 }
327 }
328
329 break;
330 }
331
332 mutex_unlock(&d->i2c_mutex);
333 return num;
334}
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300335
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300336static int dw2104_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], int num)
337{
338 struct dvb_usb_device *d = i2c_get_adapdata(adap);
339 int ret = 0;
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300340 int len, i, j;
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300341
342 if (!d)
343 return -ENODEV;
344 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
345 return -EAGAIN;
346
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300347 for (j = 0; j < num; j++) {
348 switch (msg[j].addr) {
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300349 case(DW2102_RC_QUERY): {
350 u8 ibuf[2];
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300351 ret = dw210x_op_rw(d->udev, 0xb8, 0, 0,
352 ibuf, 2, DW210X_READ_MSG);
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300353 memcpy(msg[j].buf, ibuf , 2);
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300354 break;
355 }
356 case(DW2102_VOLTAGE_CTRL): {
357 u8 obuf[2];
358 obuf[0] = 0x30;
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300359 obuf[1] = msg[j].buf[0];
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300360 ret = dw210x_op_rw(d->udev, 0xb2, 0, 0,
361 obuf, 2, DW210X_WRITE_MSG);
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300362 break;
363 }
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300364 /*case 0x55: cx24116
365 case 0x6a: stv0903
366 case 0x68: ds3000, stv0903
367 case 0x60: ts2020, stv6110, stb6100 */
368 default: {
369 if (msg[j].flags == I2C_M_RD) {
370 /* read registers */
371 u8 ibuf[msg[j].len + 2];
372 ret = dw210x_op_rw(d->udev, 0xc3,
373 (msg[j].addr << 1) + 1, 0,
374 ibuf, msg[j].len + 2,
375 DW210X_READ_MSG);
376 memcpy(msg[j].buf, ibuf + 2, msg[j].len);
377 mdelay(10);
378 } else if (((msg[j].buf[0] == 0xb0) &&
379 (msg[j].addr == 0x68)) ||
380 ((msg[j].buf[0] == 0xf7) &&
381 (msg[j].addr == 0x55))) {
382 /* write firmware */
383 u8 obuf[19];
384 obuf[0] = msg[j].addr << 1;
385 obuf[1] = (msg[j].len > 15 ? 17 : msg[j].len);
386 obuf[2] = msg[j].buf[0];
387 len = msg[j].len - 1;
388 i = 1;
389 do {
390 memcpy(obuf + 3, msg[j].buf + i,
391 (len > 16 ? 16 : len));
392 ret = dw210x_op_rw(d->udev, 0xc2, 0, 0,
393 obuf, (len > 16 ? 16 : len) + 3,
394 DW210X_WRITE_MSG);
395 i += 16;
396 len -= 16;
397 } while (len > 0);
398 } else {
399 /* write registers */
400 u8 obuf[msg[j].len + 2];
401 obuf[0] = msg[j].addr << 1;
402 obuf[1] = msg[j].len;
403 memcpy(obuf + 2, msg[j].buf, msg[j].len);
404 ret = dw210x_op_rw(d->udev, 0xc2, 0, 0,
405 obuf, msg[j].len + 2,
406 DW210X_WRITE_MSG);
407 }
408 break;
409 }
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300410 }
411
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300412 }
413
414 mutex_unlock(&d->i2c_mutex);
415 return num;
416}
417
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -0300418static int dw3101_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
419 int num)
420{
421 struct dvb_usb_device *d = i2c_get_adapdata(adap);
422 int ret = 0, i;
423
424 if (!d)
425 return -ENODEV;
426 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
427 return -EAGAIN;
428
429 switch (num) {
430 case 2: {
431 /* read */
432 /* first write first register number */
433 u8 ibuf[msg[1].len + 2], obuf[3];
434 obuf[0] = msg[0].addr << 1;
435 obuf[1] = msg[0].len;
436 obuf[2] = msg[0].buf[0];
437 ret = dw210x_op_rw(d->udev, 0xc2, 0, 0,
438 obuf, msg[0].len + 2, DW210X_WRITE_MSG);
439 /* second read registers */
440 ret = dw210x_op_rw(d->udev, 0xc3, 0x19 , 0,
441 ibuf, msg[1].len + 2, DW210X_READ_MSG);
442 memcpy(msg[1].buf, ibuf + 2, msg[1].len);
443
444 break;
445 }
446 case 1:
447 switch (msg[0].addr) {
448 case 0x60:
449 case 0x0c: {
450 /* write to register */
451 u8 obuf[msg[0].len + 2];
452 obuf[0] = msg[0].addr << 1;
453 obuf[1] = msg[0].len;
454 memcpy(obuf + 2, msg[0].buf, msg[0].len);
455 ret = dw210x_op_rw(d->udev, 0xc2, 0, 0,
456 obuf, msg[0].len + 2, DW210X_WRITE_MSG);
457 break;
458 }
459 case(DW2102_RC_QUERY): {
460 u8 ibuf[2];
461 ret = dw210x_op_rw(d->udev, 0xb8, 0, 0,
462 ibuf, 2, DW210X_READ_MSG);
463 memcpy(msg[0].buf, ibuf , 2);
464 break;
465 }
466 }
467
468 break;
469 }
470
471 for (i = 0; i < num; i++) {
472 deb_xfer("%02x:%02x: %s ", i, msg[i].addr,
473 msg[i].flags == 0 ? ">>>" : "<<<");
474 debug_dump(msg[i].buf, msg[i].len, deb_xfer);
475 }
476
477 mutex_unlock(&d->i2c_mutex);
478 return num;
479}
480
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300481static int s6x0_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300482 int num)
483{
484 struct dvb_usb_device *d = i2c_get_adapdata(adap);
Julia Lawall21ead032009-12-22 18:00:07 -0300485 struct usb_device *udev;
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300486 int ret = 0;
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300487 int len, i, j;
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300488
489 if (!d)
490 return -ENODEV;
Julia Lawall21ead032009-12-22 18:00:07 -0300491 udev = d->udev;
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300492 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
493 return -EAGAIN;
494
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300495 for (j = 0; j < num; j++) {
496 switch (msg[j].addr) {
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300497 case (DW2102_RC_QUERY): {
498 u8 ibuf[4];
499 ret = dw210x_op_rw(d->udev, 0xb8, 0, 0,
500 ibuf, 4, DW210X_READ_MSG);
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300501 memcpy(msg[j].buf, ibuf + 1, 2);
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300502 break;
503 }
504 case (DW2102_VOLTAGE_CTRL): {
505 u8 obuf[2];
Igor M. Liplianincd79d332009-12-14 20:24:56 -0300506
507 obuf[0] = 1;
508 obuf[1] = msg[j].buf[1];/* off-on */
509 ret = dw210x_op_rw(d->udev, 0x8a, 0, 0,
510 obuf, 2, DW210X_WRITE_MSG);
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300511 obuf[0] = 3;
Igor M. Liplianincd79d332009-12-14 20:24:56 -0300512 obuf[1] = msg[j].buf[0];/* 13v-18v */
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300513 ret = dw210x_op_rw(d->udev, 0x8a, 0, 0,
514 obuf, 2, DW210X_WRITE_MSG);
515 break;
516 }
Igor M. Liplianinfa8bae12011-02-25 18:41:22 -0300517 case (DW2102_LED_CTRL): {
518 u8 obuf[2];
519
520 obuf[0] = 5;
521 obuf[1] = msg[j].buf[0];
522 ret = dw210x_op_rw(d->udev, 0x8a, 0, 0,
523 obuf, 2, DW210X_WRITE_MSG);
524 break;
525 }
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300526 /*case 0x55: cx24116
527 case 0x6a: stv0903
528 case 0x68: ds3000, stv0903
529 case 0x60: ts2020, stv6110, stb6100
530 case 0xa0: eeprom */
531 default: {
532 if (msg[j].flags == I2C_M_RD) {
533 /* read registers */
534 u8 ibuf[msg[j].len];
535 ret = dw210x_op_rw(d->udev, 0x91, 0, 0,
536 ibuf, msg[j].len,
537 DW210X_READ_MSG);
538 memcpy(msg[j].buf, ibuf, msg[j].len);
539 break;
540 } else if ((msg[j].buf[0] == 0xb0) &&
541 (msg[j].addr == 0x68)) {
542 /* write firmware */
543 u8 obuf[19];
544 obuf[0] = (msg[j].len > 16 ?
545 18 : msg[j].len + 1);
546 obuf[1] = msg[j].addr << 1;
547 obuf[2] = msg[j].buf[0];
548 len = msg[j].len - 1;
549 i = 1;
550 do {
551 memcpy(obuf + 3, msg[j].buf + i,
552 (len > 16 ? 16 : len));
553 ret = dw210x_op_rw(d->udev, 0x80, 0, 0,
554 obuf, (len > 16 ? 16 : len) + 3,
555 DW210X_WRITE_MSG);
556 i += 16;
557 len -= 16;
558 } while (len > 0);
Igor M. Liplianincd79d332009-12-14 20:24:56 -0300559 } else if ((udev->descriptor.idProduct == 0x7500)
560 && (j < (num - 1))) {
561 /* write register addr before read */
562 u8 obuf[msg[j].len + 2];
563 obuf[0] = msg[j + 1].len;
564 obuf[1] = (msg[j].addr << 1);
565 memcpy(obuf + 2, msg[j].buf, msg[j].len);
566 ret = dw210x_op_rw(d->udev, 0x92, 0, 0,
567 obuf, msg[j].len + 2,
568 DW210X_WRITE_MSG);
569 break;
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300570 } else {
571 /* write registers */
572 u8 obuf[msg[j].len + 2];
573 obuf[0] = msg[j].len + 1;
574 obuf[1] = (msg[j].addr << 1);
575 memcpy(obuf + 2, msg[j].buf, msg[j].len);
576 ret = dw210x_op_rw(d->udev,
577 (num > 1 ? 0x90 : 0x80), 0, 0,
578 obuf, msg[j].len + 2,
579 DW210X_WRITE_MSG);
580 break;
581 }
582 break;
583 }
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300584 }
585
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300586 msleep(3);
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300587 }
588
589 mutex_unlock(&d->i2c_mutex);
590 return num;
591}
592
Igor M. Liplianind2ffc442011-02-25 18:41:22 -0300593static int su3000_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
594 int num)
595{
596 struct dvb_usb_device *d = i2c_get_adapdata(adap);
597 u8 obuf[0x40], ibuf[0x40];
598
599 if (!d)
600 return -ENODEV;
601 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
602 return -EAGAIN;
603
604 switch (num) {
605 case 1:
606 switch (msg[0].addr) {
607 case SU3000_STREAM_CTRL:
608 obuf[0] = msg[0].buf[0] + 0x36;
609 obuf[1] = 3;
610 obuf[2] = 0;
611 if (dvb_usb_generic_rw(d, obuf, 3, ibuf, 0, 0) < 0)
612 err("i2c transfer failed.");
613 break;
614 case DW2102_RC_QUERY:
615 obuf[0] = 0x10;
616 if (dvb_usb_generic_rw(d, obuf, 1, ibuf, 2, 0) < 0)
617 err("i2c transfer failed.");
618 msg[0].buf[1] = ibuf[0];
619 msg[0].buf[0] = ibuf[1];
620 break;
621 default:
622 /* always i2c write*/
623 obuf[0] = 0x08;
624 obuf[1] = msg[0].addr;
625 obuf[2] = msg[0].len;
626
627 memcpy(&obuf[3], msg[0].buf, msg[0].len);
628
629 if (dvb_usb_generic_rw(d, obuf, msg[0].len + 3,
630 ibuf, 1, 0) < 0)
631 err("i2c transfer failed.");
632
633 }
634 break;
635 case 2:
636 /* always i2c read */
637 obuf[0] = 0x09;
638 obuf[1] = msg[0].len;
639 obuf[2] = msg[1].len;
640 obuf[3] = msg[0].addr;
641 memcpy(&obuf[4], msg[0].buf, msg[0].len);
642
643 if (dvb_usb_generic_rw(d, obuf, msg[0].len + 4,
644 ibuf, msg[1].len + 1, 0) < 0)
645 err("i2c transfer failed.");
646
647 memcpy(msg[1].buf, &ibuf[1], msg[1].len);
648 break;
649 default:
650 warn("more than 2 i2c messages at a time is not handled yet.");
651 break;
652 }
653 mutex_unlock(&d->i2c_mutex);
654 return num;
655}
656
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300657static u32 dw210x_i2c_func(struct i2c_adapter *adapter)
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300658{
659 return I2C_FUNC_I2C;
660}
661
662static struct i2c_algorithm dw2102_i2c_algo = {
663 .master_xfer = dw2102_i2c_transfer,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300664 .functionality = dw210x_i2c_func,
665};
666
667static struct i2c_algorithm dw2102_serit_i2c_algo = {
668 .master_xfer = dw2102_serit_i2c_transfer,
669 .functionality = dw210x_i2c_func,
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300670};
671
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -0300672static struct i2c_algorithm dw2102_earda_i2c_algo = {
673 .master_xfer = dw2102_earda_i2c_transfer,
674 .functionality = dw210x_i2c_func,
675};
676
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300677static struct i2c_algorithm dw2104_i2c_algo = {
678 .master_xfer = dw2104_i2c_transfer,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300679 .functionality = dw210x_i2c_func,
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300680};
681
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -0300682static struct i2c_algorithm dw3101_i2c_algo = {
683 .master_xfer = dw3101_i2c_transfer,
684 .functionality = dw210x_i2c_func,
685};
686
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300687static struct i2c_algorithm s6x0_i2c_algo = {
688 .master_xfer = s6x0_i2c_transfer,
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300689 .functionality = dw210x_i2c_func,
690};
691
Igor M. Liplianind2ffc442011-02-25 18:41:22 -0300692static struct i2c_algorithm su3000_i2c_algo = {
693 .master_xfer = su3000_i2c_transfer,
694 .functionality = dw210x_i2c_func,
695};
696
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300697static int dw210x_read_mac_address(struct dvb_usb_device *d, u8 mac[6])
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300698{
699 int i;
700 u8 ibuf[] = {0, 0};
701 u8 eeprom[256], eepromline[16];
702
703 for (i = 0; i < 256; i++) {
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300704 if (dw210x_op_rw(d->udev, 0xb6, 0xa0 , i, ibuf, 2, DW210X_READ_MSG) < 0) {
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300705 err("read eeprom failed.");
706 return -1;
707 } else {
708 eepromline[i%16] = ibuf[0];
709 eeprom[i] = ibuf[0];
710 }
711 if ((i % 16) == 15) {
712 deb_xfer("%02x: ", i - 15);
713 debug_dump(eepromline, 16, deb_xfer);
714 }
715 }
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -0300716
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300717 memcpy(mac, eeprom + 8, 6);
718 return 0;
719};
720
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300721static int s6x0_read_mac_address(struct dvb_usb_device *d, u8 mac[6])
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300722{
723 int i, ret;
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300724 u8 ibuf[] = { 0 }, obuf[] = { 0 };
725 u8 eeprom[256], eepromline[16];
726 struct i2c_msg msg[] = {
727 {
728 .addr = 0xa0 >> 1,
729 .flags = 0,
730 .buf = obuf,
731 .len = 1,
732 }, {
733 .addr = 0xa0 >> 1,
734 .flags = I2C_M_RD,
735 .buf = ibuf,
736 .len = 1,
737 }
738 };
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300739
740 for (i = 0; i < 256; i++) {
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300741 obuf[0] = i;
742 ret = s6x0_i2c_transfer(&d->i2c_adap, msg, 2);
743 if (ret != 2) {
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300744 err("read eeprom failed.");
745 return -1;
746 } else {
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300747 eepromline[i % 16] = ibuf[0];
748 eeprom[i] = ibuf[0];
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300749 }
750
751 if ((i % 16) == 15) {
752 deb_xfer("%02x: ", i - 15);
753 debug_dump(eepromline, 16, deb_xfer);
754 }
755 }
756
757 memcpy(mac, eeprom + 16, 6);
758 return 0;
759};
760
Igor M. Liplianind2ffc442011-02-25 18:41:22 -0300761static int su3000_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
762{
763 static u8 command_start[] = {0x00};
764 static u8 command_stop[] = {0x01};
765 struct i2c_msg msg = {
766 .addr = SU3000_STREAM_CTRL,
767 .flags = 0,
768 .buf = onoff ? command_start : command_stop,
769 .len = 1
770 };
771
772 i2c_transfer(&adap->dev->i2c_adap, &msg, 1);
773
774 return 0;
775}
776
777static int su3000_power_ctrl(struct dvb_usb_device *d, int i)
778{
779 struct su3000_state *state = (struct su3000_state *)d->priv;
780 u8 obuf[] = {0xde, 0};
781
782 info("%s: %d, initialized %d\n", __func__, i, state->initialized);
783
784 if (i && !state->initialized) {
785 state->initialized = 1;
786 /* reset board */
787 dvb_usb_generic_rw(d, obuf, 2, NULL, 0, 0);
788 }
789
790 return 0;
791}
792
793static int su3000_read_mac_address(struct dvb_usb_device *d, u8 mac[6])
794{
795 int i;
796 u8 obuf[] = { 0x1f, 0xf0 };
797 u8 ibuf[] = { 0 };
798 struct i2c_msg msg[] = {
799 {
800 .addr = 0x51,
801 .flags = 0,
802 .buf = obuf,
803 .len = 2,
804 }, {
805 .addr = 0x51,
806 .flags = I2C_M_RD,
807 .buf = ibuf,
808 .len = 1,
809
810 }
811 };
812
813 for (i = 0; i < 6; i++) {
814 obuf[1] = 0xf0 + i;
815 if (i2c_transfer(&d->i2c_adap, msg, 2) != 2)
816 break;
817 else
818 mac[i] = ibuf[0];
819
820 debug_dump(mac, 6, printk);
821 }
822
823 return 0;
824}
825
826static int su3000_identify_state(struct usb_device *udev,
827 struct dvb_usb_device_properties *props,
828 struct dvb_usb_device_description **desc,
829 int *cold)
830{
831 info("%s\n", __func__);
832
833 *cold = 0;
834 return 0;
835}
836
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300837static int dw210x_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300838{
Igor M. Liplianincd79d332009-12-14 20:24:56 -0300839 static u8 command_13v[] = {0x00, 0x01};
840 static u8 command_18v[] = {0x01, 0x01};
841 static u8 command_off[] = {0x00, 0x00};
842 struct i2c_msg msg = {
843 .addr = DW2102_VOLTAGE_CTRL,
844 .flags = 0,
845 .buf = command_off,
846 .len = 2,
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300847 };
848
849 struct dvb_usb_adapter *udev_adap =
850 (struct dvb_usb_adapter *)(fe->dvb->priv);
851 if (voltage == SEC_VOLTAGE_18)
Igor M. Liplianincd79d332009-12-14 20:24:56 -0300852 msg.buf = command_18v;
853 else if (voltage == SEC_VOLTAGE_13)
854 msg.buf = command_13v;
855
856 i2c_transfer(&udev_adap->dev->i2c_adap, &msg, 1);
857
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300858 return 0;
859}
860
Igor M. Liplianin52c506e2011-02-25 18:41:23 -0300861static int s660_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
862{
863 struct dvb_usb_adapter *d =
864 (struct dvb_usb_adapter *)(fe->dvb->priv);
865 struct s6x0_state *st = (struct s6x0_state *)d->dev->priv;
866
867 dw210x_set_voltage(fe, voltage);
868 if (st->old_set_voltage)
869 st->old_set_voltage(fe, voltage);
870
871 return 0;
872}
873
Igor M. Liplianinfa8bae12011-02-25 18:41:22 -0300874static void dw210x_led_ctrl(struct dvb_frontend *fe, int offon)
875{
876 static u8 led_off[] = { 0 };
877 static u8 led_on[] = { 1 };
878 struct i2c_msg msg = {
879 .addr = DW2102_LED_CTRL,
880 .flags = 0,
881 .buf = led_off,
882 .len = 1
883 };
884 struct dvb_usb_adapter *udev_adap =
885 (struct dvb_usb_adapter *)(fe->dvb->priv);
886
887 if (offon)
888 msg.buf = led_on;
889 i2c_transfer(&udev_adap->dev->i2c_adap, &msg, 1);
890}
891
Igor M. Liplianind4305c62008-10-17 13:45:55 -0300892static struct stv0299_config sharp_z0194a_config = {
893 .demod_address = 0x68,
894 .inittab = sharp_z0194a_inittab,
895 .mclk = 88000000UL,
896 .invert = 1,
897 .skip_reinit = 0,
898 .lock_output = STV0299_LOCKOUTPUT_1,
899 .volt13_op0_op1 = STV0299_VOLT13_OP1,
900 .min_delay_ms = 100,
901 .set_symbol_rate = sharp_z0194a_set_symbol_rate,
902};
903
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300904static struct cx24116_config dw2104_config = {
905 .demod_address = 0x55,
Igor M. Liplianincc8c4f32008-09-09 13:57:47 -0300906 .mpg_clk_pos_pol = 0x01,
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300907};
908
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300909static struct si21xx_config serit_sp1511lhb_config = {
910 .demod_address = 0x68,
911 .min_delay_ms = 100,
912
913};
914
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -0300915static struct tda10023_config dw3101_tda10023_config = {
916 .demod_address = 0x0c,
917 .invert = 1,
918};
919
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300920static struct mt312_config zl313_config = {
921 .demod_address = 0x0e,
922};
923
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300924static struct ds3000_config dw2104_ds3000_config = {
925 .demod_address = 0x68,
926};
927
928static struct stv0900_config dw2104a_stv0900_config = {
929 .demod_address = 0x6a,
930 .demod_mode = 0,
931 .xtal = 27000000,
932 .clkmode = 3,/* 0-CLKI, 2-XTALI, else AUTO */
933 .diseqc_mode = 2,/* 2/3 PWM */
934 .tun1_maddress = 0,/* 0x60 */
935 .tun1_adc = 0,/* 2 Vpp */
936 .path1_mode = 3,
937};
938
939static struct stb6100_config dw2104a_stb6100_config = {
940 .tuner_address = 0x60,
941 .refclock = 27000000,
942};
943
944static struct stv0900_config dw2104_stv0900_config = {
945 .demod_address = 0x68,
946 .demod_mode = 0,
947 .xtal = 8000000,
948 .clkmode = 3,
949 .diseqc_mode = 2,
950 .tun1_maddress = 0,
951 .tun1_adc = 1,/* 1 Vpp */
952 .path1_mode = 3,
953};
954
955static struct stv6110_config dw2104_stv6110_config = {
956 .i2c_address = 0x60,
957 .mclk = 16000000,
958 .clk_div = 1,
959};
960
Igor M. Liplianincd79d332009-12-14 20:24:56 -0300961static struct stv0900_config prof_7500_stv0900_config = {
962 .demod_address = 0x6a,
963 .demod_mode = 0,
964 .xtal = 27000000,
965 .clkmode = 3,/* 0-CLKI, 2-XTALI, else AUTO */
966 .diseqc_mode = 2,/* 2/3 PWM */
967 .tun1_maddress = 0,/* 0x60 */
968 .tun1_adc = 0,/* 2 Vpp */
969 .path1_mode = 3,
970 .tun1_type = 3,
Igor M. Liplianinfa8bae12011-02-25 18:41:22 -0300971 .set_lock_led = dw210x_led_ctrl,
Igor M. Liplianincd79d332009-12-14 20:24:56 -0300972};
973
Igor M. Liplianind2ffc442011-02-25 18:41:22 -0300974static struct ds3000_config su3000_ds3000_config = {
975 .demod_address = 0x68,
976 .ci_mode = 1,
977};
978
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300979static int dw2104_frontend_attach(struct dvb_usb_adapter *d)
980{
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300981 struct dvb_tuner_ops *tuner_ops = NULL;
982
983 if (demod_probe & 4) {
984 d->fe = dvb_attach(stv0900_attach, &dw2104a_stv0900_config,
985 &d->dev->i2c_adap, 0);
986 if (d->fe != NULL) {
987 if (dvb_attach(stb6100_attach, d->fe,
988 &dw2104a_stb6100_config,
989 &d->dev->i2c_adap)) {
990 tuner_ops = &d->fe->ops.tuner_ops;
991 tuner_ops->set_frequency = stb6100_set_freq;
992 tuner_ops->get_frequency = stb6100_get_freq;
993 tuner_ops->set_bandwidth = stb6100_set_bandw;
994 tuner_ops->get_bandwidth = stb6100_get_bandw;
995 d->fe->ops.set_voltage = dw210x_set_voltage;
996 info("Attached STV0900+STB6100!\n");
997 return 0;
998 }
999 }
1000 }
1001
1002 if (demod_probe & 2) {
1003 d->fe = dvb_attach(stv0900_attach, &dw2104_stv0900_config,
1004 &d->dev->i2c_adap, 0);
1005 if (d->fe != NULL) {
1006 if (dvb_attach(stv6110_attach, d->fe,
1007 &dw2104_stv6110_config,
1008 &d->dev->i2c_adap)) {
1009 d->fe->ops.set_voltage = dw210x_set_voltage;
1010 info("Attached STV0900+STV6110A!\n");
1011 return 0;
1012 }
1013 }
1014 }
1015
1016 if (demod_probe & 1) {
1017 d->fe = dvb_attach(cx24116_attach, &dw2104_config,
1018 &d->dev->i2c_adap);
1019 if (d->fe != NULL) {
1020 d->fe->ops.set_voltage = dw210x_set_voltage;
1021 info("Attached cx24116!\n");
1022 return 0;
1023 }
1024 }
1025
1026 d->fe = dvb_attach(ds3000_attach, &dw2104_ds3000_config,
1027 &d->dev->i2c_adap);
1028 if (d->fe != NULL) {
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001029 d->fe->ops.set_voltage = dw210x_set_voltage;
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001030 info("Attached DS3000!\n");
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001031 return 0;
1032 }
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001033
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001034 return -EIO;
1035}
1036
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001037static struct dvb_usb_device_properties dw2102_properties;
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -03001038static struct dvb_usb_device_properties dw2104_properties;
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001039static struct dvb_usb_device_properties s6x0_properties;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001040
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001041static int dw2102_frontend_attach(struct dvb_usb_adapter *d)
1042{
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001043 if (dw2102_properties.i2c_algo == &dw2102_serit_i2c_algo) {
1044 /*dw2102_properties.adapter->tuner_attach = NULL;*/
1045 d->fe = dvb_attach(si21xx_attach, &serit_sp1511lhb_config,
1046 &d->dev->i2c_adap);
1047 if (d->fe != NULL) {
1048 d->fe->ops.set_voltage = dw210x_set_voltage;
1049 info("Attached si21xx!\n");
1050 return 0;
1051 }
1052 }
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001053
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -03001054 if (dw2102_properties.i2c_algo == &dw2102_earda_i2c_algo) {
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -03001055 d->fe = dvb_attach(stv0288_attach, &earda_config,
1056 &d->dev->i2c_adap);
1057 if (d->fe != NULL) {
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001058 if (dvb_attach(stb6000_attach, d->fe, 0x61,
1059 &d->dev->i2c_adap)) {
1060 d->fe->ops.set_voltage = dw210x_set_voltage;
1061 info("Attached stv0288!\n");
1062 return 0;
1063 }
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -03001064 }
1065 }
1066
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001067 if (dw2102_properties.i2c_algo == &dw2102_i2c_algo) {
1068 /*dw2102_properties.adapter->tuner_attach = dw2102_tuner_attach;*/
1069 d->fe = dvb_attach(stv0299_attach, &sharp_z0194a_config,
1070 &d->dev->i2c_adap);
1071 if (d->fe != NULL) {
1072 d->fe->ops.set_voltage = dw210x_set_voltage;
1073 info("Attached stv0299!\n");
1074 return 0;
1075 }
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001076 }
1077 return -EIO;
1078}
1079
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001080static int dw3101_frontend_attach(struct dvb_usb_adapter *d)
1081{
1082 d->fe = dvb_attach(tda10023_attach, &dw3101_tda10023_config,
1083 &d->dev->i2c_adap, 0x48);
1084 if (d->fe != NULL) {
1085 info("Attached tda10023!\n");
1086 return 0;
1087 }
1088 return -EIO;
1089}
1090
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001091static int zl100313_frontend_attach(struct dvb_usb_adapter *d)
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001092{
1093 d->fe = dvb_attach(mt312_attach, &zl313_config,
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001094 &d->dev->i2c_adap);
1095 if (d->fe != NULL) {
1096 if (dvb_attach(zl10039_attach, d->fe, 0x60,
1097 &d->dev->i2c_adap)) {
1098 d->fe->ops.set_voltage = dw210x_set_voltage;
1099 info("Attached zl100313+zl10039!\n");
1100 return 0;
1101 }
1102 }
1103
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001104 return -EIO;
1105}
1106
1107static int stv0288_frontend_attach(struct dvb_usb_adapter *d)
1108{
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001109 d->fe = dvb_attach(stv0288_attach, &earda_config,
1110 &d->dev->i2c_adap);
1111 if (d->fe != NULL) {
1112 if (dvb_attach(stb6000_attach, d->fe, 0x61,
1113 &d->dev->i2c_adap)) {
1114 d->fe->ops.set_voltage = dw210x_set_voltage;
1115 info("Attached stv0288+stb6000!\n");
1116 return 0;
1117 }
1118 }
1119
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001120 return -EIO;
1121}
1122
1123static int ds3000_frontend_attach(struct dvb_usb_adapter *d)
1124{
Igor M. Liplianin52c506e2011-02-25 18:41:23 -03001125 struct s6x0_state *st = (struct s6x0_state *)d->dev->priv;
1126
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001127 d->fe = dvb_attach(ds3000_attach, &dw2104_ds3000_config,
1128 &d->dev->i2c_adap);
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001129
Igor M. Liplianin52c506e2011-02-25 18:41:23 -03001130 if (d->fe == NULL)
1131 return -EIO;
1132
1133 st->old_set_voltage = d->fe->ops.set_voltage;
1134 d->fe->ops.set_voltage = s660_set_voltage;
1135 info("Attached ds3000+ds2020!\n");
1136
1137 return 0;
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001138}
1139
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001140static int prof_7500_frontend_attach(struct dvb_usb_adapter *d)
1141{
Igor M. Liplianin4e59df82011-02-25 18:41:23 -03001142 u8 obuf[] = {7, 1};
1143
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001144 d->fe = dvb_attach(stv0900_attach, &prof_7500_stv0900_config,
1145 &d->dev->i2c_adap, 0);
1146 if (d->fe == NULL)
1147 return -EIO;
Igor M. Liplianin4e59df82011-02-25 18:41:23 -03001148
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001149 d->fe->ops.set_voltage = dw210x_set_voltage;
1150
Igor M. Liplianin4e59df82011-02-25 18:41:23 -03001151 dw210x_op_rw(d->dev->udev, 0x8a, 0, 0, obuf, 2, DW210X_WRITE_MSG);
1152
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001153 info("Attached STV0900+STB6100A!\n");
1154
1155 return 0;
1156}
1157
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001158static int su3000_frontend_attach(struct dvb_usb_adapter *d)
1159{
1160 u8 obuf[3] = { 0xe, 0x80, 0 };
1161 u8 ibuf[] = { 0 };
1162
1163 if (dvb_usb_generic_rw(d->dev, obuf, 3, ibuf, 1, 0) < 0)
1164 err("command 0x0e transfer failed.");
1165
1166 obuf[0] = 0xe;
1167 obuf[1] = 0x83;
1168 obuf[2] = 0;
1169
1170 if (dvb_usb_generic_rw(d->dev, obuf, 3, ibuf, 1, 0) < 0)
1171 err("command 0x0e transfer failed.");
1172
1173 obuf[0] = 0xe;
1174 obuf[1] = 0x83;
1175 obuf[2] = 1;
1176
1177 if (dvb_usb_generic_rw(d->dev, obuf, 3, ibuf, 1, 0) < 0)
1178 err("command 0x0e transfer failed.");
1179
1180 obuf[0] = 0x51;
1181
1182 if (dvb_usb_generic_rw(d->dev, obuf, 1, ibuf, 1, 0) < 0)
1183 err("command 0x51 transfer failed.");
1184
1185 d->fe = dvb_attach(ds3000_attach, &su3000_ds3000_config,
1186 &d->dev->i2c_adap);
1187 if (d->fe == NULL)
1188 return -EIO;
1189
1190 info("Attached DS3000!\n");
1191
1192 return 0;
1193}
1194
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001195static int dw2102_tuner_attach(struct dvb_usb_adapter *adap)
1196{
1197 dvb_attach(dvb_pll_attach, adap->fe, 0x60,
1198 &adap->dev->i2c_adap, DVB_PLL_OPERA1);
1199 return 0;
1200}
1201
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001202static int dw3101_tuner_attach(struct dvb_usb_adapter *adap)
1203{
1204 dvb_attach(dvb_pll_attach, adap->fe, 0x60,
1205 &adap->dev->i2c_adap, DVB_PLL_TUA6034);
1206
1207 return 0;
1208}
1209
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03001210static struct rc_map_table rc_map_dw210x_table[] = {
Mauro Carvalho Chehab2e365882009-08-29 15:19:31 -03001211 { 0xf80a, KEY_Q }, /*power*/
1212 { 0xf80c, KEY_M }, /*mute*/
1213 { 0xf811, KEY_1 },
1214 { 0xf812, KEY_2 },
1215 { 0xf813, KEY_3 },
1216 { 0xf814, KEY_4 },
1217 { 0xf815, KEY_5 },
1218 { 0xf816, KEY_6 },
1219 { 0xf817, KEY_7 },
1220 { 0xf818, KEY_8 },
1221 { 0xf819, KEY_9 },
1222 { 0xf810, KEY_0 },
1223 { 0xf81c, KEY_PAGEUP }, /*ch+*/
1224 { 0xf80f, KEY_PAGEDOWN }, /*ch-*/
1225 { 0xf81a, KEY_O }, /*vol+*/
1226 { 0xf80e, KEY_Z }, /*vol-*/
1227 { 0xf804, KEY_R }, /*rec*/
1228 { 0xf809, KEY_D }, /*fav*/
1229 { 0xf808, KEY_BACKSPACE }, /*rewind*/
1230 { 0xf807, KEY_A }, /*fast*/
1231 { 0xf80b, KEY_P }, /*pause*/
1232 { 0xf802, KEY_ESC }, /*cancel*/
1233 { 0xf803, KEY_G }, /*tab*/
1234 { 0xf800, KEY_UP }, /*up*/
1235 { 0xf81f, KEY_ENTER }, /*ok*/
1236 { 0xf801, KEY_DOWN }, /*down*/
1237 { 0xf805, KEY_C }, /*cap*/
1238 { 0xf806, KEY_S }, /*stop*/
1239 { 0xf840, KEY_F }, /*full*/
1240 { 0xf81e, KEY_W }, /*tvmode*/
1241 { 0xf81b, KEY_B }, /*recall*/
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001242};
1243
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03001244static struct rc_map_table rc_map_tevii_table[] = {
Mauro Carvalho Chehab2e365882009-08-29 15:19:31 -03001245 { 0xf80a, KEY_POWER },
1246 { 0xf80c, KEY_MUTE },
1247 { 0xf811, KEY_1 },
1248 { 0xf812, KEY_2 },
1249 { 0xf813, KEY_3 },
1250 { 0xf814, KEY_4 },
1251 { 0xf815, KEY_5 },
1252 { 0xf816, KEY_6 },
1253 { 0xf817, KEY_7 },
1254 { 0xf818, KEY_8 },
1255 { 0xf819, KEY_9 },
1256 { 0xf810, KEY_0 },
1257 { 0xf81c, KEY_MENU },
1258 { 0xf80f, KEY_VOLUMEDOWN },
1259 { 0xf81a, KEY_LAST },
1260 { 0xf80e, KEY_OPEN },
1261 { 0xf804, KEY_RECORD },
1262 { 0xf809, KEY_VOLUMEUP },
1263 { 0xf808, KEY_CHANNELUP },
1264 { 0xf807, KEY_PVR },
1265 { 0xf80b, KEY_TIME },
1266 { 0xf802, KEY_RIGHT },
1267 { 0xf803, KEY_LEFT },
1268 { 0xf800, KEY_UP },
1269 { 0xf81f, KEY_OK },
1270 { 0xf801, KEY_DOWN },
1271 { 0xf805, KEY_TUNER },
1272 { 0xf806, KEY_CHANNELDOWN },
1273 { 0xf840, KEY_PLAYPAUSE },
1274 { 0xf81e, KEY_REWIND },
1275 { 0xf81b, KEY_FAVORITES },
1276 { 0xf81d, KEY_BACK },
1277 { 0xf84d, KEY_FASTFORWARD },
1278 { 0xf844, KEY_EPG },
1279 { 0xf84c, KEY_INFO },
1280 { 0xf841, KEY_AB },
1281 { 0xf843, KEY_AUDIO },
1282 { 0xf845, KEY_SUBTITLE },
1283 { 0xf84a, KEY_LIST },
1284 { 0xf846, KEY_F1 },
1285 { 0xf847, KEY_F2 },
1286 { 0xf85e, KEY_F3 },
1287 { 0xf85c, KEY_F4 },
1288 { 0xf852, KEY_F5 },
1289 { 0xf85a, KEY_F6 },
1290 { 0xf856, KEY_MODE },
1291 { 0xf858, KEY_SWITCHVIDEOMODE },
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -03001292};
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001293
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03001294static struct rc_map_table rc_map_tbs_table[] = {
Mauro Carvalho Chehab2e365882009-08-29 15:19:31 -03001295 { 0xf884, KEY_POWER },
1296 { 0xf894, KEY_MUTE },
1297 { 0xf887, KEY_1 },
1298 { 0xf886, KEY_2 },
1299 { 0xf885, KEY_3 },
1300 { 0xf88b, KEY_4 },
1301 { 0xf88a, KEY_5 },
1302 { 0xf889, KEY_6 },
1303 { 0xf88f, KEY_7 },
1304 { 0xf88e, KEY_8 },
1305 { 0xf88d, KEY_9 },
1306 { 0xf892, KEY_0 },
1307 { 0xf896, KEY_CHANNELUP },
1308 { 0xf891, KEY_CHANNELDOWN },
1309 { 0xf893, KEY_VOLUMEUP },
1310 { 0xf88c, KEY_VOLUMEDOWN },
1311 { 0xf883, KEY_RECORD },
1312 { 0xf898, KEY_PAUSE },
1313 { 0xf899, KEY_OK },
1314 { 0xf89a, KEY_SHUFFLE },
1315 { 0xf881, KEY_UP },
1316 { 0xf890, KEY_LEFT },
1317 { 0xf882, KEY_RIGHT },
1318 { 0xf888, KEY_DOWN },
1319 { 0xf895, KEY_FAVORITES },
1320 { 0xf897, KEY_SUBTITLE },
1321 { 0xf89d, KEY_ZOOM },
1322 { 0xf89f, KEY_EXIT },
1323 { 0xf89e, KEY_MENU },
1324 { 0xf89c, KEY_EPG },
1325 { 0xf880, KEY_PREVIOUS },
1326 { 0xf89b, KEY_MODE }
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -03001327};
1328
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001329static struct rc_map_table rc_map_su3000_table[] = {
1330 { 0x25, KEY_POWER }, /* right-bottom Red */
1331 { 0x0a, KEY_MUTE }, /* -/-- */
1332 { 0x01, KEY_1 },
1333 { 0x02, KEY_2 },
1334 { 0x03, KEY_3 },
1335 { 0x04, KEY_4 },
1336 { 0x05, KEY_5 },
1337 { 0x06, KEY_6 },
1338 { 0x07, KEY_7 },
1339 { 0x08, KEY_8 },
1340 { 0x09, KEY_9 },
1341 { 0x00, KEY_0 },
1342 { 0x20, KEY_UP }, /* CH+ */
1343 { 0x21, KEY_DOWN }, /* CH+ */
1344 { 0x12, KEY_VOLUMEUP }, /* Brightness Up */
1345 { 0x13, KEY_VOLUMEDOWN },/* Brightness Down */
1346 { 0x1f, KEY_RECORD },
1347 { 0x17, KEY_PLAY },
1348 { 0x16, KEY_PAUSE },
1349 { 0x0b, KEY_STOP },
1350 { 0x27, KEY_FASTFORWARD },/* >> */
1351 { 0x26, KEY_REWIND }, /* << */
1352 { 0x0d, KEY_OK }, /* Mute */
1353 { 0x11, KEY_LEFT }, /* VOL- */
1354 { 0x10, KEY_RIGHT }, /* VOL+ */
1355 { 0x29, KEY_BACK }, /* button under 9 */
1356 { 0x2c, KEY_MENU }, /* TTX */
1357 { 0x2b, KEY_EPG }, /* EPG */
1358 { 0x1e, KEY_RED }, /* OSD */
1359 { 0x0e, KEY_GREEN }, /* Window */
1360 { 0x2d, KEY_YELLOW }, /* button under << */
1361 { 0x0f, KEY_BLUE }, /* bottom yellow button */
1362 { 0x14, KEY_AUDIO }, /* Snapshot */
1363 { 0x38, KEY_TV }, /* TV/Radio */
1364 { 0x0c, KEY_ESC } /* upper Red buttton */
1365};
1366
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03001367static struct rc_map_dvb_usb_table_table keys_tables[] = {
1368 { rc_map_dw210x_table, ARRAY_SIZE(rc_map_dw210x_table) },
1369 { rc_map_tevii_table, ARRAY_SIZE(rc_map_tevii_table) },
1370 { rc_map_tbs_table, ARRAY_SIZE(rc_map_tbs_table) },
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001371 { rc_map_su3000_table, ARRAY_SIZE(rc_map_su3000_table) },
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -03001372};
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001373
1374static int dw2102_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
1375{
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03001376 struct rc_map_table *keymap = d->props.rc.legacy.rc_map_table;
1377 int keymap_size = d->props.rc.legacy.rc_map_size;
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001378 u8 key[2];
Igor M. Liplianin8a8dad72009-06-13 08:10:24 -03001379 struct i2c_msg msg = {
1380 .addr = DW2102_RC_QUERY,
1381 .flags = I2C_M_RD,
1382 .buf = key,
1383 .len = 2
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001384 };
1385 int i;
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -03001386 /* override keymap */
1387 if ((ir_keymap > 0) && (ir_keymap <= ARRAY_SIZE(keys_tables))) {
1388 keymap = keys_tables[ir_keymap - 1].rc_keys ;
1389 keymap_size = keys_tables[ir_keymap - 1].rc_keys_size;
Igor M. Liplianinfeb16e92011-02-25 18:41:22 -03001390 } else if (ir_keymap > ARRAY_SIZE(keys_tables))
1391 return 0; /* none */
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001392
1393 *state = REMOTE_NO_KEY_PRESSED;
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001394 if (d->props.i2c_algo->master_xfer(&d->i2c_adap, &msg, 1) == 1) {
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -03001395 for (i = 0; i < keymap_size ; i++) {
Mauro Carvalho Chehab2e365882009-08-29 15:19:31 -03001396 if (rc5_data(&keymap[i]) == msg.buf[0]) {
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001397 *state = REMOTE_KEY_PRESSED;
Mauro Carvalho Chehab34abf212010-07-31 11:24:57 -03001398 *event = keymap[i].keycode;
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001399 break;
1400 }
Igor M. Liplianin8a8dad72009-06-13 08:10:24 -03001401
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001402 }
Igor M. Liplianin8a8dad72009-06-13 08:10:24 -03001403
1404 if ((*state) == REMOTE_KEY_PRESSED)
1405 deb_rc("%s: found rc key: %x, %x, event: %x\n",
1406 __func__, key[0], key[1], (*event));
1407 else if (key[0] != 0xff)
1408 deb_rc("%s: unknown rc key: %x, %x\n",
1409 __func__, key[0], key[1]);
1410
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001411 }
Igor M. Liplianin8a8dad72009-06-13 08:10:24 -03001412
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001413 return 0;
1414}
1415
1416static struct usb_device_id dw2102_table[] = {
1417 {USB_DEVICE(USB_VID_CYPRESS, USB_PID_DW2102)},
1418 {USB_DEVICE(USB_VID_CYPRESS, 0x2101)},
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001419 {USB_DEVICE(USB_VID_CYPRESS, USB_PID_DW2104)},
1420 {USB_DEVICE(0x9022, USB_PID_TEVII_S650)},
Igor M. Liplianin4cc0edf2008-11-05 22:12:56 -03001421 {USB_DEVICE(USB_VID_TERRATEC, USB_PID_CINERGY_S)},
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001422 {USB_DEVICE(USB_VID_CYPRESS, USB_PID_DW3101)},
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001423 {USB_DEVICE(0x9022, USB_PID_TEVII_S630)},
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001424 {USB_DEVICE(0x3011, USB_PID_PROF_1100)},
1425 {USB_DEVICE(0x9022, USB_PID_TEVII_S660)},
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001426 {USB_DEVICE(0x3034, 0x7500)},
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001427 {USB_DEVICE(0x1f4d, 0x3000)},
Igor M. Liplianin2adc5912011-02-25 18:41:22 -03001428 {USB_DEVICE(USB_VID_TERRATEC, 0x00a8)},
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001429 { }
1430};
1431
1432MODULE_DEVICE_TABLE(usb, dw2102_table);
1433
1434static int dw2102_load_firmware(struct usb_device *dev,
1435 const struct firmware *frmwr)
1436{
1437 u8 *b, *p;
1438 int ret = 0, i;
1439 u8 reset;
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -03001440 u8 reset16[] = {0, 0, 0, 0, 0, 0, 0};
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001441 const struct firmware *fw;
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001442 const char *fw_2101 = "dvb-usb-dw2101.fw";
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001443
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001444 switch (dev->descriptor.idProduct) {
1445 case 0x2101:
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001446 ret = request_firmware(&fw, fw_2101, &dev->dev);
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001447 if (ret != 0) {
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001448 err(err_str, fw_2101);
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001449 return ret;
1450 }
1451 break;
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001452 default:
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001453 fw = frmwr;
1454 break;
1455 }
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001456 info("start downloading DW210X firmware");
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001457 p = kmalloc(fw->size, GFP_KERNEL);
1458 reset = 1;
1459 /*stop the CPU*/
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001460 dw210x_op_rw(dev, 0xa0, 0x7f92, 0, &reset, 1, DW210X_WRITE_MSG);
1461 dw210x_op_rw(dev, 0xa0, 0xe600, 0, &reset, 1, DW210X_WRITE_MSG);
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001462
1463 if (p != NULL) {
1464 memcpy(p, fw->data, fw->size);
1465 for (i = 0; i < fw->size; i += 0x40) {
1466 b = (u8 *) p + i;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001467 if (dw210x_op_rw(dev, 0xa0, i, 0, b , 0x40,
1468 DW210X_WRITE_MSG) != 0x40) {
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001469 err("error while transferring firmware");
1470 ret = -EINVAL;
1471 break;
1472 }
1473 }
1474 /* restart the CPU */
1475 reset = 0;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001476 if (ret || dw210x_op_rw(dev, 0xa0, 0x7f92, 0, &reset, 1,
1477 DW210X_WRITE_MSG) != 1) {
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001478 err("could not restart the USB controller CPU.");
1479 ret = -EINVAL;
1480 }
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001481 if (ret || dw210x_op_rw(dev, 0xa0, 0xe600, 0, &reset, 1,
1482 DW210X_WRITE_MSG) != 1) {
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001483 err("could not restart the USB controller CPU.");
1484 ret = -EINVAL;
1485 }
1486 /* init registers */
1487 switch (dev->descriptor.idProduct) {
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001488 case USB_PID_TEVII_S650:
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03001489 dw2104_properties.rc.legacy.rc_map_table = rc_map_tevii_table;
1490 dw2104_properties.rc.legacy.rc_map_size =
1491 ARRAY_SIZE(rc_map_tevii_table);
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -03001492 case USB_PID_DW2104:
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001493 reset = 1;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001494 dw210x_op_rw(dev, 0xc4, 0x0000, 0, &reset, 1,
1495 DW210X_WRITE_MSG);
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001496 /* break omitted intentionally */
1497 case USB_PID_DW3101:
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001498 reset = 0;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001499 dw210x_op_rw(dev, 0xbf, 0x0040, 0, &reset, 0,
1500 DW210X_WRITE_MSG);
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001501 break;
Igor M. Liplianin4cc0edf2008-11-05 22:12:56 -03001502 case USB_PID_CINERGY_S:
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001503 case USB_PID_DW2102:
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001504 dw210x_op_rw(dev, 0xbf, 0x0040, 0, &reset, 0,
1505 DW210X_WRITE_MSG);
1506 dw210x_op_rw(dev, 0xb9, 0x0000, 0, &reset16[0], 2,
1507 DW210X_READ_MSG);
1508 /* check STV0299 frontend */
1509 dw210x_op_rw(dev, 0xb5, 0, 0, &reset16[0], 2,
1510 DW210X_READ_MSG);
Igor M. Liplianinea023df2008-12-04 12:49:23 -03001511 if ((reset16[0] == 0xa1) || (reset16[0] == 0x80)) {
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001512 dw2102_properties.i2c_algo = &dw2102_i2c_algo;
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -03001513 dw2102_properties.adapter->tuner_attach = &dw2102_tuner_attach;
1514 break;
1515 } else {
1516 /* check STV0288 frontend */
1517 reset16[0] = 0xd0;
1518 reset16[1] = 1;
1519 reset16[2] = 0;
1520 dw210x_op_rw(dev, 0xc2, 0, 0, &reset16[0], 3,
1521 DW210X_WRITE_MSG);
1522 dw210x_op_rw(dev, 0xc3, 0xd1, 0, &reset16[0], 3,
1523 DW210X_READ_MSG);
1524 if (reset16[2] == 0x11) {
1525 dw2102_properties.i2c_algo = &dw2102_earda_i2c_algo;
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -03001526 break;
1527 }
1528 }
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001529 case 0x2101:
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001530 dw210x_op_rw(dev, 0xbc, 0x0030, 0, &reset16[0], 2,
1531 DW210X_READ_MSG);
1532 dw210x_op_rw(dev, 0xba, 0x0000, 0, &reset16[0], 7,
1533 DW210X_READ_MSG);
1534 dw210x_op_rw(dev, 0xba, 0x0000, 0, &reset16[0], 7,
1535 DW210X_READ_MSG);
1536 dw210x_op_rw(dev, 0xb9, 0x0000, 0, &reset16[0], 2,
1537 DW210X_READ_MSG);
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001538 break;
1539 }
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001540
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001541 msleep(100);
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001542 kfree(p);
1543 }
1544 return ret;
1545}
1546
1547static struct dvb_usb_device_properties dw2102_properties = {
1548 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1549 .usb_ctrl = DEVICE_SPECIFIC,
1550 .firmware = "dvb-usb-dw2102.fw",
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001551 .no_reconnect = 1,
1552
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001553 .i2c_algo = &dw2102_serit_i2c_algo,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03001554
1555 .rc.legacy = {
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03001556 .rc_map_table = rc_map_dw210x_table,
1557 .rc_map_size = ARRAY_SIZE(rc_map_dw210x_table),
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03001558 .rc_interval = 150,
1559 .rc_query = dw2102_rc_query,
1560 },
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001561
1562 .generic_bulk_ctrl_endpoint = 0x81,
1563 /* parameter for the MPEG2-data transfer */
1564 .num_adapters = 1,
1565 .download_firmware = dw2102_load_firmware,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001566 .read_mac_address = dw210x_read_mac_address,
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001567 .adapter = {
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001568 {
1569 .frontend_attach = dw2102_frontend_attach,
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001570 .stream = {
1571 .type = USB_BULK,
1572 .count = 8,
1573 .endpoint = 0x82,
1574 .u = {
1575 .bulk = {
1576 .buffersize = 4096,
1577 }
1578 }
1579 },
1580 }
1581 },
Igor M. Liplianin4cc0edf2008-11-05 22:12:56 -03001582 .num_device_descs = 3,
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001583 .devices = {
1584 {"DVBWorld DVB-S 2102 USB2.0",
1585 {&dw2102_table[0], NULL},
1586 {NULL},
1587 },
1588 {"DVBWorld DVB-S 2101 USB2.0",
1589 {&dw2102_table[1], NULL},
1590 {NULL},
1591 },
Igor M. Liplianin4cc0edf2008-11-05 22:12:56 -03001592 {"TerraTec Cinergy S USB",
1593 {&dw2102_table[4], NULL},
1594 {NULL},
1595 },
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001596 }
1597};
1598
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001599static struct dvb_usb_device_properties dw2104_properties = {
1600 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1601 .usb_ctrl = DEVICE_SPECIFIC,
1602 .firmware = "dvb-usb-dw2104.fw",
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001603 .no_reconnect = 1,
1604
1605 .i2c_algo = &dw2104_i2c_algo,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03001606 .rc.legacy = {
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03001607 .rc_map_table = rc_map_dw210x_table,
1608 .rc_map_size = ARRAY_SIZE(rc_map_dw210x_table),
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03001609 .rc_interval = 150,
1610 .rc_query = dw2102_rc_query,
1611 },
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001612
1613 .generic_bulk_ctrl_endpoint = 0x81,
1614 /* parameter for the MPEG2-data transfer */
1615 .num_adapters = 1,
1616 .download_firmware = dw2102_load_firmware,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001617 .read_mac_address = dw210x_read_mac_address,
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001618 .adapter = {
1619 {
1620 .frontend_attach = dw2104_frontend_attach,
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001621 .stream = {
1622 .type = USB_BULK,
1623 .count = 8,
1624 .endpoint = 0x82,
1625 .u = {
1626 .bulk = {
1627 .buffersize = 4096,
1628 }
1629 }
1630 },
1631 }
1632 },
1633 .num_device_descs = 2,
1634 .devices = {
1635 { "DVBWorld DW2104 USB2.0",
1636 {&dw2102_table[2], NULL},
1637 {NULL},
1638 },
1639 { "TeVii S650 USB2.0",
1640 {&dw2102_table[3], NULL},
1641 {NULL},
1642 },
1643 }
1644};
1645
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001646static struct dvb_usb_device_properties dw3101_properties = {
1647 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1648 .usb_ctrl = DEVICE_SPECIFIC,
1649 .firmware = "dvb-usb-dw3101.fw",
1650 .no_reconnect = 1,
1651
1652 .i2c_algo = &dw3101_i2c_algo,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03001653 .rc.legacy = {
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03001654 .rc_map_table = rc_map_dw210x_table,
1655 .rc_map_size = ARRAY_SIZE(rc_map_dw210x_table),
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03001656 .rc_interval = 150,
1657 .rc_query = dw2102_rc_query,
1658 },
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001659
1660 .generic_bulk_ctrl_endpoint = 0x81,
1661 /* parameter for the MPEG2-data transfer */
1662 .num_adapters = 1,
1663 .download_firmware = dw2102_load_firmware,
1664 .read_mac_address = dw210x_read_mac_address,
1665 .adapter = {
1666 {
1667 .frontend_attach = dw3101_frontend_attach,
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001668 .tuner_attach = dw3101_tuner_attach,
1669 .stream = {
1670 .type = USB_BULK,
1671 .count = 8,
1672 .endpoint = 0x82,
1673 .u = {
1674 .bulk = {
1675 .buffersize = 4096,
1676 }
1677 }
1678 },
1679 }
1680 },
1681 .num_device_descs = 1,
1682 .devices = {
1683 { "DVBWorld DVB-C 3101 USB2.0",
1684 {&dw2102_table[5], NULL},
1685 {NULL},
1686 },
1687 }
1688};
1689
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001690static struct dvb_usb_device_properties s6x0_properties = {
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001691 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1692 .usb_ctrl = DEVICE_SPECIFIC,
Igor M. Liplianin52c506e2011-02-25 18:41:23 -03001693 .size_of_priv = sizeof(struct s6x0_state),
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001694 .firmware = "dvb-usb-s630.fw",
1695 .no_reconnect = 1,
1696
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001697 .i2c_algo = &s6x0_i2c_algo,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03001698 .rc.legacy = {
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03001699 .rc_map_table = rc_map_tevii_table,
1700 .rc_map_size = ARRAY_SIZE(rc_map_tevii_table),
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03001701 .rc_interval = 150,
1702 .rc_query = dw2102_rc_query,
1703 },
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001704
1705 .generic_bulk_ctrl_endpoint = 0x81,
1706 .num_adapters = 1,
1707 .download_firmware = dw2102_load_firmware,
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001708 .read_mac_address = s6x0_read_mac_address,
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001709 .adapter = {
1710 {
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001711 .frontend_attach = zl100313_frontend_attach,
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001712 .stream = {
1713 .type = USB_BULK,
1714 .count = 8,
1715 .endpoint = 0x82,
1716 .u = {
1717 .bulk = {
1718 .buffersize = 4096,
1719 }
1720 }
1721 },
1722 }
1723 },
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001724 .num_device_descs = 1,
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001725 .devices = {
1726 {"TeVii S630 USB",
1727 {&dw2102_table[6], NULL},
1728 {NULL},
1729 },
1730 }
1731};
1732
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001733struct dvb_usb_device_properties *p1100;
1734static struct dvb_usb_device_description d1100 = {
1735 "Prof 1100 USB ",
1736 {&dw2102_table[7], NULL},
1737 {NULL},
1738};
1739
1740struct dvb_usb_device_properties *s660;
1741static struct dvb_usb_device_description d660 = {
1742 "TeVii S660 USB",
1743 {&dw2102_table[8], NULL},
1744 {NULL},
1745};
1746
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001747struct dvb_usb_device_properties *p7500;
1748static struct dvb_usb_device_description d7500 = {
1749 "Prof 7500 USB DVB-S2",
1750 {&dw2102_table[9], NULL},
1751 {NULL},
1752};
1753
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001754static struct dvb_usb_device_properties su3000_properties = {
1755 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1756 .usb_ctrl = DEVICE_SPECIFIC,
1757 .size_of_priv = sizeof(struct su3000_state),
1758 .power_ctrl = su3000_power_ctrl,
1759 .num_adapters = 1,
1760 .identify_state = su3000_identify_state,
1761 .i2c_algo = &su3000_i2c_algo,
1762
1763 .rc.legacy = {
1764 .rc_map_table = rc_map_su3000_table,
1765 .rc_map_size = ARRAY_SIZE(rc_map_su3000_table),
1766 .rc_interval = 150,
1767 .rc_query = dw2102_rc_query,
1768 },
1769
1770 .read_mac_address = su3000_read_mac_address,
1771
1772 .generic_bulk_ctrl_endpoint = 0x01,
1773
1774 .adapter = {
1775 {
1776 .streaming_ctrl = su3000_streaming_ctrl,
1777 .frontend_attach = su3000_frontend_attach,
1778 .stream = {
1779 .type = USB_BULK,
1780 .count = 8,
1781 .endpoint = 0x82,
1782 .u = {
1783 .bulk = {
1784 .buffersize = 4096,
1785 }
1786 }
1787 }
1788 }
1789 },
Igor M. Liplianin2adc5912011-02-25 18:41:22 -03001790 .num_device_descs = 2,
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001791 .devices = {
1792 { "SU3000HD DVB-S USB2.0",
1793 { &dw2102_table[10], NULL },
1794 { NULL },
1795 },
Igor M. Liplianin2adc5912011-02-25 18:41:22 -03001796 { "Terratec Cinergy S2 USB HD",
1797 { &dw2102_table[11], NULL },
1798 { NULL },
1799 },
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001800 }
1801};
1802
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001803static int dw2102_probe(struct usb_interface *intf,
1804 const struct usb_device_id *id)
1805{
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001806 p1100 = kzalloc(sizeof(struct dvb_usb_device_properties), GFP_KERNEL);
1807 if (!p1100)
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001808 return -ENOMEM;
1809 /* copy default structure */
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001810 memcpy(p1100, &s6x0_properties,
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001811 sizeof(struct dvb_usb_device_properties));
1812 /* fill only different fields */
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001813 p1100->firmware = "dvb-usb-p1100.fw";
1814 p1100->devices[0] = d1100;
1815 p1100->rc.legacy.rc_map_table = rc_map_tbs_table;
1816 p1100->rc.legacy.rc_map_size = ARRAY_SIZE(rc_map_tbs_table);
1817 p1100->adapter->frontend_attach = stv0288_frontend_attach;
1818
1819 s660 = kzalloc(sizeof(struct dvb_usb_device_properties), GFP_KERNEL);
1820 if (!s660) {
1821 kfree(p1100);
1822 return -ENOMEM;
1823 }
1824 memcpy(s660, &s6x0_properties,
1825 sizeof(struct dvb_usb_device_properties));
1826 s660->firmware = "dvb-usb-s660.fw";
1827 s660->devices[0] = d660;
1828 s660->adapter->frontend_attach = ds3000_frontend_attach;
1829
1830 p7500 = kzalloc(sizeof(struct dvb_usb_device_properties), GFP_KERNEL);
1831 if (!p7500) {
1832 kfree(p1100);
1833 kfree(s660);
1834 return -ENOMEM;
1835 }
1836 memcpy(p7500, &s6x0_properties,
1837 sizeof(struct dvb_usb_device_properties));
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001838 p7500->firmware = "dvb-usb-p7500.fw";
1839 p7500->devices[0] = d7500;
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03001840 p7500->rc.legacy.rc_map_table = rc_map_tbs_table;
1841 p7500->rc.legacy.rc_map_size = ARRAY_SIZE(rc_map_tbs_table);
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001842 p7500->adapter->frontend_attach = prof_7500_frontend_attach;
1843
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001844 if (0 == dvb_usb_device_init(intf, &dw2102_properties,
1845 THIS_MODULE, NULL, adapter_nr) ||
1846 0 == dvb_usb_device_init(intf, &dw2104_properties,
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001847 THIS_MODULE, NULL, adapter_nr) ||
1848 0 == dvb_usb_device_init(intf, &dw3101_properties,
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001849 THIS_MODULE, NULL, adapter_nr) ||
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001850 0 == dvb_usb_device_init(intf, &s6x0_properties,
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001851 THIS_MODULE, NULL, adapter_nr) ||
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001852 0 == dvb_usb_device_init(intf, p1100,
1853 THIS_MODULE, NULL, adapter_nr) ||
1854 0 == dvb_usb_device_init(intf, s660,
1855 THIS_MODULE, NULL, adapter_nr) ||
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001856 0 == dvb_usb_device_init(intf, p7500,
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001857 THIS_MODULE, NULL, adapter_nr) ||
1858 0 == dvb_usb_device_init(intf, &su3000_properties,
1859 THIS_MODULE, NULL, adapter_nr))
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001860 return 0;
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001861
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001862 return -ENODEV;
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001863}
1864
1865static struct usb_driver dw2102_driver = {
1866 .name = "dw2102",
1867 .probe = dw2102_probe,
1868 .disconnect = dvb_usb_device_exit,
1869 .id_table = dw2102_table,
1870};
1871
1872static int __init dw2102_module_init(void)
1873{
1874 int ret = usb_register(&dw2102_driver);
1875 if (ret)
1876 err("usb_register failed. Error number %d", ret);
1877
1878 return ret;
1879}
1880
1881static void __exit dw2102_module_exit(void)
1882{
1883 usb_deregister(&dw2102_driver);
1884}
1885
1886module_init(dw2102_module_init);
1887module_exit(dw2102_module_exit);
1888
1889MODULE_AUTHOR("Igor M. Liplianin (c) liplianin@me.by");
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001890MODULE_DESCRIPTION("Driver for DVBWorld DVB-S 2101, 2102, DVB-S2 2104,"
1891 " DVB-C 3101 USB2.0,"
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001892 " TeVii S600, S630, S650, S660 USB2.0,"
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001893 " Prof 1100, 7500 USB2.0,"
1894 " Geniatech SU3000 devices");
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001895MODULE_VERSION("0.1");
1896MODULE_LICENSE("GPL");