blob: 83a35524a82a9138eb7285a2c5ba7805980836d7 [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,
4* Prof 1100, 7500 Cards
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03005* Copyright (C) 2008,2009 Igor M. Liplianin (liplianin@me.by)
Igor M Liplianin7fd48282008-07-20 08:05:50 -03006*
7* This program is free software; you can redistribute it and/or modify it
8* under the terms of the GNU General Public License as published by the
9* Free Software Foundation, version 2.
10*
11* see Documentation/dvb/README.dvb-usb for more information
12*/
Igor M Liplianin7fd48282008-07-20 08:05:50 -030013#include "dw2102.h"
Igor M. Liplianin21b007b2008-09-17 19:19:19 -030014#include "si21xx.h"
Igor M Liplianin7fd48282008-07-20 08:05:50 -030015#include "stv0299.h"
16#include "z0194a.h"
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -030017#include "stv0288.h"
18#include "stb6000.h"
19#include "eds1547.h"
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -030020#include "cx24116.h"
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -030021#include "tda1002x.h"
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -030022#include "mt312.h"
23#include "zl10039.h"
Igor M. Liplianin141cc352009-11-27 14:37:35 -030024#include "ds3000.h"
25#include "stv0900.h"
26#include "stv6110.h"
27#include "stb6100.h"
28#include "stb6100_proc.h"
Igor M Liplianin7fd48282008-07-20 08:05:50 -030029
30#ifndef USB_PID_DW2102
31#define USB_PID_DW2102 0x2102
32#endif
33
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -030034#ifndef USB_PID_DW2104
35#define USB_PID_DW2104 0x2104
36#endif
37
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -030038#ifndef USB_PID_DW3101
39#define USB_PID_DW3101 0x3101
40#endif
41
Igor M. Liplianin4cc0edf2008-11-05 22:12:56 -030042#ifndef USB_PID_CINERGY_S
43#define USB_PID_CINERGY_S 0x0064
44#endif
45
Igor M. Liplianin141cc352009-11-27 14:37:35 -030046#ifndef USB_PID_TEVII_S630
47#define USB_PID_TEVII_S630 0xd630
48#endif
49
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -030050#ifndef USB_PID_TEVII_S650
51#define USB_PID_TEVII_S650 0xd650
52#endif
53
Igor M. Liplianin141cc352009-11-27 14:37:35 -030054#ifndef USB_PID_TEVII_S660
55#define USB_PID_TEVII_S660 0xd660
56#endif
57
58#ifndef USB_PID_PROF_1100
59#define USB_PID_PROF_1100 0xb012
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -030060#endif
61
Igor M. Liplianin21b007b2008-09-17 19:19:19 -030062#define DW210X_READ_MSG 0
63#define DW210X_WRITE_MSG 1
Igor M Liplianin7fd48282008-07-20 08:05:50 -030064
65#define REG_1F_SYMBOLRATE_BYTE0 0x1f
66#define REG_20_SYMBOLRATE_BYTE1 0x20
67#define REG_21_SYMBOLRATE_BYTE2 0x21
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -030068/* on my own*/
Igor M Liplianin7fd48282008-07-20 08:05:50 -030069#define DW2102_VOLTAGE_CTRL (0x1800)
70#define DW2102_RC_QUERY (0x1a00)
71
Igor M. Liplianin141cc352009-11-27 14:37:35 -030072#define err_str "did not find the firmware file. (%s) " \
73 "Please see linux/Documentation/dvb/ for more details " \
74 "on firmware-problems."
75
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -030076struct dvb_usb_rc_keys_table {
77 struct dvb_usb_rc_key *rc_keys;
78 int rc_keys_size;
Igor M Liplianin7fd48282008-07-20 08:05:50 -030079};
80
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -030081/* debug */
82static int dvb_usb_dw2102_debug;
83module_param_named(debug, dvb_usb_dw2102_debug, int, 0644);
Igor M. Liplianin8a8dad72009-06-13 08:10:24 -030084MODULE_PARM_DESC(debug, "set debugging level (1=info 2=xfer 4=rc(or-able))."
85 DVB_USB_DEBUG_STATUS);
86
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -030087/* keymaps */
88static int ir_keymap;
89module_param_named(keymap, ir_keymap, int, 0644);
90MODULE_PARM_DESC(keymap, "set keymap 0=default 1=dvbworld 2=tevii 3=tbs ...");
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -030091
Igor M. Liplianin141cc352009-11-27 14:37:35 -030092/* demod probe */
93static int demod_probe = 1;
94module_param_named(demod, demod_probe, int, 0644);
95MODULE_PARM_DESC(demod, "demod to probe (1=cx24116 2=stv0903+stv6110 "
96 "4=stv0903+stb6100(or-able)).");
97
Igor M Liplianin7fd48282008-07-20 08:05:50 -030098DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
99
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300100static int dw210x_op_rw(struct usb_device *dev, u8 request, u16 value,
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300101 u16 index, u8 * data, u16 len, int flags)
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300102{
103 int ret;
104 u8 u8buf[len];
105
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300106 unsigned int pipe = (flags == DW210X_READ_MSG) ?
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300107 usb_rcvctrlpipe(dev, 0) : usb_sndctrlpipe(dev, 0);
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300108 u8 request_type = (flags == DW210X_READ_MSG) ? USB_DIR_IN : USB_DIR_OUT;
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300109
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300110 if (flags == DW210X_WRITE_MSG)
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300111 memcpy(u8buf, data, len);
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300112 ret = usb_control_msg(dev, pipe, request, request_type | USB_TYPE_VENDOR,
113 value, index , u8buf, len, 2000);
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300114
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300115 if (flags == DW210X_READ_MSG)
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300116 memcpy(data, u8buf, len);
117 return ret;
118}
119
120/* I2C */
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300121static int dw2102_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
122 int num)
123{
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -0300124 struct dvb_usb_device *d = i2c_get_adapdata(adap);
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300125 int i = 0, ret = 0;
126 u8 buf6[] = {0x2c, 0x05, 0xc0, 0, 0, 0, 0};
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300127 u16 value;
128
129 if (!d)
130 return -ENODEV;
131 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
132 return -EAGAIN;
133
134 switch (num) {
135 case 2:
136 /* read stv0299 register */
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300137 value = msg[0].buf[0];/* register */
138 for (i = 0; i < msg[1].len; i++) {
139 value = value + i;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300140 ret = dw210x_op_rw(d->udev, 0xb5, value, 0,
141 buf6, 2, DW210X_READ_MSG);
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300142 msg[1].buf[i] = buf6[0];
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300143 }
144 break;
145 case 1:
146 switch (msg[0].addr) {
147 case 0x68:
148 /* write to stv0299 register */
149 buf6[0] = 0x2a;
150 buf6[1] = msg[0].buf[0];
151 buf6[2] = msg[0].buf[1];
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300152 ret = dw210x_op_rw(d->udev, 0xb2, 0, 0,
153 buf6, 3, DW210X_WRITE_MSG);
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300154 break;
155 case 0x60:
156 if (msg[0].flags == 0) {
157 /* write to tuner pll */
158 buf6[0] = 0x2c;
159 buf6[1] = 5;
160 buf6[2] = 0xc0;
161 buf6[3] = msg[0].buf[0];
162 buf6[4] = msg[0].buf[1];
163 buf6[5] = msg[0].buf[2];
164 buf6[6] = msg[0].buf[3];
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300165 ret = dw210x_op_rw(d->udev, 0xb2, 0, 0,
166 buf6, 7, DW210X_WRITE_MSG);
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300167 } else {
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300168 /* read from tuner */
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300169 ret = dw210x_op_rw(d->udev, 0xb5, 0, 0,
170 buf6, 1, DW210X_READ_MSG);
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300171 msg[0].buf[0] = buf6[0];
172 }
173 break;
174 case (DW2102_RC_QUERY):
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300175 ret = dw210x_op_rw(d->udev, 0xb8, 0, 0,
176 buf6, 2, DW210X_READ_MSG);
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300177 msg[0].buf[0] = buf6[0];
178 msg[0].buf[1] = buf6[1];
179 break;
180 case (DW2102_VOLTAGE_CTRL):
181 buf6[0] = 0x30;
182 buf6[1] = msg[0].buf[0];
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300183 ret = dw210x_op_rw(d->udev, 0xb2, 0, 0,
184 buf6, 2, DW210X_WRITE_MSG);
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300185 break;
186 }
187
188 break;
189 }
190
191 mutex_unlock(&d->i2c_mutex);
192 return num;
193}
194
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300195static int dw2102_serit_i2c_transfer(struct i2c_adapter *adap,
196 struct i2c_msg msg[], int num)
197{
198 struct dvb_usb_device *d = i2c_get_adapdata(adap);
199 int ret = 0;
200 u8 buf6[] = {0, 0, 0, 0, 0, 0, 0};
201
202 if (!d)
203 return -ENODEV;
204 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
205 return -EAGAIN;
206
207 switch (num) {
208 case 2:
209 /* read si2109 register by number */
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300210 buf6[0] = msg[0].addr << 1;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300211 buf6[1] = msg[0].len;
212 buf6[2] = msg[0].buf[0];
213 ret = dw210x_op_rw(d->udev, 0xc2, 0, 0,
214 buf6, msg[0].len + 2, DW210X_WRITE_MSG);
215 /* read si2109 register */
216 ret = dw210x_op_rw(d->udev, 0xc3, 0xd0, 0,
217 buf6, msg[1].len + 2, DW210X_READ_MSG);
218 memcpy(msg[1].buf, buf6 + 2, msg[1].len);
219
220 break;
221 case 1:
222 switch (msg[0].addr) {
223 case 0x68:
224 /* write to si2109 register */
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300225 buf6[0] = msg[0].addr << 1;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300226 buf6[1] = msg[0].len;
227 memcpy(buf6 + 2, msg[0].buf, msg[0].len);
228 ret = dw210x_op_rw(d->udev, 0xc2, 0, 0, buf6,
229 msg[0].len + 2, DW210X_WRITE_MSG);
230 break;
231 case(DW2102_RC_QUERY):
232 ret = dw210x_op_rw(d->udev, 0xb8, 0, 0,
233 buf6, 2, DW210X_READ_MSG);
234 msg[0].buf[0] = buf6[0];
235 msg[0].buf[1] = buf6[1];
236 break;
237 case(DW2102_VOLTAGE_CTRL):
238 buf6[0] = 0x30;
239 buf6[1] = msg[0].buf[0];
240 ret = dw210x_op_rw(d->udev, 0xb2, 0, 0,
241 buf6, 2, DW210X_WRITE_MSG);
242 break;
243 }
244 break;
245 }
246
247 mutex_unlock(&d->i2c_mutex);
248 return num;
249}
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -0300250
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -0300251static int dw2102_earda_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], int num)
252{
253 struct dvb_usb_device *d = i2c_get_adapdata(adap);
254 int ret = 0;
255
256 if (!d)
257 return -ENODEV;
258 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
259 return -EAGAIN;
260
261 switch (num) {
262 case 2: {
263 /* read */
264 /* first write first register number */
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -0300265 u8 ibuf[msg[1].len + 2], obuf[3];
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300266 obuf[0] = msg[0].addr << 1;
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -0300267 obuf[1] = msg[0].len;
268 obuf[2] = msg[0].buf[0];
269 ret = dw210x_op_rw(d->udev, 0xc2, 0, 0,
270 obuf, msg[0].len + 2, DW210X_WRITE_MSG);
271 /* second read registers */
272 ret = dw210x_op_rw(d->udev, 0xc3, 0xd1 , 0,
273 ibuf, msg[1].len + 2, DW210X_READ_MSG);
274 memcpy(msg[1].buf, ibuf + 2, msg[1].len);
275
276 break;
277 }
278 case 1:
279 switch (msg[0].addr) {
280 case 0x68: {
281 /* write to register */
282 u8 obuf[msg[0].len + 2];
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300283 obuf[0] = msg[0].addr << 1;
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -0300284 obuf[1] = msg[0].len;
285 memcpy(obuf + 2, msg[0].buf, msg[0].len);
286 ret = dw210x_op_rw(d->udev, 0xc2, 0, 0,
287 obuf, msg[0].len + 2, DW210X_WRITE_MSG);
288 break;
289 }
290 case 0x61: {
291 /* write to tuner */
292 u8 obuf[msg[0].len + 2];
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300293 obuf[0] = msg[0].addr << 1;
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -0300294 obuf[1] = msg[0].len;
295 memcpy(obuf + 2, msg[0].buf, msg[0].len);
296 ret = dw210x_op_rw(d->udev, 0xc2, 0, 0,
297 obuf, msg[0].len + 2, DW210X_WRITE_MSG);
298 break;
299 }
300 case(DW2102_RC_QUERY): {
301 u8 ibuf[2];
302 ret = dw210x_op_rw(d->udev, 0xb8, 0, 0,
303 ibuf, 2, DW210X_READ_MSG);
304 memcpy(msg[0].buf, ibuf , 2);
305 break;
306 }
307 case(DW2102_VOLTAGE_CTRL): {
308 u8 obuf[2];
309 obuf[0] = 0x30;
310 obuf[1] = msg[0].buf[0];
311 ret = dw210x_op_rw(d->udev, 0xb2, 0, 0,
312 obuf, 2, DW210X_WRITE_MSG);
313 break;
314 }
315 }
316
317 break;
318 }
319
320 mutex_unlock(&d->i2c_mutex);
321 return num;
322}
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300323
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300324static int dw2104_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], int num)
325{
326 struct dvb_usb_device *d = i2c_get_adapdata(adap);
327 int ret = 0;
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300328 int len, i, j;
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300329
330 if (!d)
331 return -ENODEV;
332 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
333 return -EAGAIN;
334
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300335 for (j = 0; j < num; j++) {
336 switch (msg[j].addr) {
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300337 case(DW2102_RC_QUERY): {
338 u8 ibuf[2];
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300339 ret = dw210x_op_rw(d->udev, 0xb8, 0, 0,
340 ibuf, 2, DW210X_READ_MSG);
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300341 memcpy(msg[j].buf, ibuf , 2);
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300342 break;
343 }
344 case(DW2102_VOLTAGE_CTRL): {
345 u8 obuf[2];
346 obuf[0] = 0x30;
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300347 obuf[1] = msg[j].buf[0];
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300348 ret = dw210x_op_rw(d->udev, 0xb2, 0, 0,
349 obuf, 2, DW210X_WRITE_MSG);
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300350 break;
351 }
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300352 /*case 0x55: cx24116
353 case 0x6a: stv0903
354 case 0x68: ds3000, stv0903
355 case 0x60: ts2020, stv6110, stb6100 */
356 default: {
357 if (msg[j].flags == I2C_M_RD) {
358 /* read registers */
359 u8 ibuf[msg[j].len + 2];
360 ret = dw210x_op_rw(d->udev, 0xc3,
361 (msg[j].addr << 1) + 1, 0,
362 ibuf, msg[j].len + 2,
363 DW210X_READ_MSG);
364 memcpy(msg[j].buf, ibuf + 2, msg[j].len);
365 mdelay(10);
366 } else if (((msg[j].buf[0] == 0xb0) &&
367 (msg[j].addr == 0x68)) ||
368 ((msg[j].buf[0] == 0xf7) &&
369 (msg[j].addr == 0x55))) {
370 /* write firmware */
371 u8 obuf[19];
372 obuf[0] = msg[j].addr << 1;
373 obuf[1] = (msg[j].len > 15 ? 17 : msg[j].len);
374 obuf[2] = msg[j].buf[0];
375 len = msg[j].len - 1;
376 i = 1;
377 do {
378 memcpy(obuf + 3, msg[j].buf + i,
379 (len > 16 ? 16 : len));
380 ret = dw210x_op_rw(d->udev, 0xc2, 0, 0,
381 obuf, (len > 16 ? 16 : len) + 3,
382 DW210X_WRITE_MSG);
383 i += 16;
384 len -= 16;
385 } while (len > 0);
386 } else {
387 /* write registers */
388 u8 obuf[msg[j].len + 2];
389 obuf[0] = msg[j].addr << 1;
390 obuf[1] = msg[j].len;
391 memcpy(obuf + 2, msg[j].buf, msg[j].len);
392 ret = dw210x_op_rw(d->udev, 0xc2, 0, 0,
393 obuf, msg[j].len + 2,
394 DW210X_WRITE_MSG);
395 }
396 break;
397 }
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300398 }
399
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300400 }
401
402 mutex_unlock(&d->i2c_mutex);
403 return num;
404}
405
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -0300406static int dw3101_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
407 int num)
408{
409 struct dvb_usb_device *d = i2c_get_adapdata(adap);
410 int ret = 0, i;
411
412 if (!d)
413 return -ENODEV;
414 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
415 return -EAGAIN;
416
417 switch (num) {
418 case 2: {
419 /* read */
420 /* first write first register number */
421 u8 ibuf[msg[1].len + 2], obuf[3];
422 obuf[0] = msg[0].addr << 1;
423 obuf[1] = msg[0].len;
424 obuf[2] = msg[0].buf[0];
425 ret = dw210x_op_rw(d->udev, 0xc2, 0, 0,
426 obuf, msg[0].len + 2, DW210X_WRITE_MSG);
427 /* second read registers */
428 ret = dw210x_op_rw(d->udev, 0xc3, 0x19 , 0,
429 ibuf, msg[1].len + 2, DW210X_READ_MSG);
430 memcpy(msg[1].buf, ibuf + 2, msg[1].len);
431
432 break;
433 }
434 case 1:
435 switch (msg[0].addr) {
436 case 0x60:
437 case 0x0c: {
438 /* write to register */
439 u8 obuf[msg[0].len + 2];
440 obuf[0] = msg[0].addr << 1;
441 obuf[1] = msg[0].len;
442 memcpy(obuf + 2, msg[0].buf, msg[0].len);
443 ret = dw210x_op_rw(d->udev, 0xc2, 0, 0,
444 obuf, msg[0].len + 2, DW210X_WRITE_MSG);
445 break;
446 }
447 case(DW2102_RC_QUERY): {
448 u8 ibuf[2];
449 ret = dw210x_op_rw(d->udev, 0xb8, 0, 0,
450 ibuf, 2, DW210X_READ_MSG);
451 memcpy(msg[0].buf, ibuf , 2);
452 break;
453 }
454 }
455
456 break;
457 }
458
459 for (i = 0; i < num; i++) {
460 deb_xfer("%02x:%02x: %s ", i, msg[i].addr,
461 msg[i].flags == 0 ? ">>>" : "<<<");
462 debug_dump(msg[i].buf, msg[i].len, deb_xfer);
463 }
464
465 mutex_unlock(&d->i2c_mutex);
466 return num;
467}
468
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300469static int s6x0_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300470 int num)
471{
472 struct dvb_usb_device *d = i2c_get_adapdata(adap);
Igor M. Liplianincd79d332009-12-14 20:24:56 -0300473 struct usb_device *udev = d->udev;
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300474 int ret = 0;
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300475 int len, i, j;
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300476
477 if (!d)
478 return -ENODEV;
479 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
480 return -EAGAIN;
481
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300482 for (j = 0; j < num; j++) {
483 switch (msg[j].addr) {
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300484 case (DW2102_RC_QUERY): {
485 u8 ibuf[4];
486 ret = dw210x_op_rw(d->udev, 0xb8, 0, 0,
487 ibuf, 4, DW210X_READ_MSG);
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300488 memcpy(msg[j].buf, ibuf + 1, 2);
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300489 break;
490 }
491 case (DW2102_VOLTAGE_CTRL): {
492 u8 obuf[2];
Igor M. Liplianincd79d332009-12-14 20:24:56 -0300493
494 obuf[0] = 1;
495 obuf[1] = msg[j].buf[1];/* off-on */
496 ret = dw210x_op_rw(d->udev, 0x8a, 0, 0,
497 obuf, 2, DW210X_WRITE_MSG);
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300498 obuf[0] = 3;
Igor M. Liplianincd79d332009-12-14 20:24:56 -0300499 obuf[1] = msg[j].buf[0];/* 13v-18v */
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300500 ret = dw210x_op_rw(d->udev, 0x8a, 0, 0,
501 obuf, 2, DW210X_WRITE_MSG);
502 break;
503 }
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300504 /*case 0x55: cx24116
505 case 0x6a: stv0903
506 case 0x68: ds3000, stv0903
507 case 0x60: ts2020, stv6110, stb6100
508 case 0xa0: eeprom */
509 default: {
510 if (msg[j].flags == I2C_M_RD) {
511 /* read registers */
512 u8 ibuf[msg[j].len];
513 ret = dw210x_op_rw(d->udev, 0x91, 0, 0,
514 ibuf, msg[j].len,
515 DW210X_READ_MSG);
516 memcpy(msg[j].buf, ibuf, msg[j].len);
517 break;
518 } else if ((msg[j].buf[0] == 0xb0) &&
519 (msg[j].addr == 0x68)) {
520 /* write firmware */
521 u8 obuf[19];
522 obuf[0] = (msg[j].len > 16 ?
523 18 : msg[j].len + 1);
524 obuf[1] = msg[j].addr << 1;
525 obuf[2] = msg[j].buf[0];
526 len = msg[j].len - 1;
527 i = 1;
528 do {
529 memcpy(obuf + 3, msg[j].buf + i,
530 (len > 16 ? 16 : len));
531 ret = dw210x_op_rw(d->udev, 0x80, 0, 0,
532 obuf, (len > 16 ? 16 : len) + 3,
533 DW210X_WRITE_MSG);
534 i += 16;
535 len -= 16;
536 } while (len > 0);
Igor M. Liplianincd79d332009-12-14 20:24:56 -0300537 } else if ((udev->descriptor.idProduct == 0x7500)
538 && (j < (num - 1))) {
539 /* write register addr before read */
540 u8 obuf[msg[j].len + 2];
541 obuf[0] = msg[j + 1].len;
542 obuf[1] = (msg[j].addr << 1);
543 memcpy(obuf + 2, msg[j].buf, msg[j].len);
544 ret = dw210x_op_rw(d->udev, 0x92, 0, 0,
545 obuf, msg[j].len + 2,
546 DW210X_WRITE_MSG);
547 break;
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300548 } else {
549 /* write registers */
550 u8 obuf[msg[j].len + 2];
551 obuf[0] = msg[j].len + 1;
552 obuf[1] = (msg[j].addr << 1);
553 memcpy(obuf + 2, msg[j].buf, msg[j].len);
554 ret = dw210x_op_rw(d->udev,
555 (num > 1 ? 0x90 : 0x80), 0, 0,
556 obuf, msg[j].len + 2,
557 DW210X_WRITE_MSG);
558 break;
559 }
560 break;
561 }
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300562 }
563
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300564 msleep(3);
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300565 }
566
567 mutex_unlock(&d->i2c_mutex);
568 return num;
569}
570
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300571static u32 dw210x_i2c_func(struct i2c_adapter *adapter)
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300572{
573 return I2C_FUNC_I2C;
574}
575
576static struct i2c_algorithm dw2102_i2c_algo = {
577 .master_xfer = dw2102_i2c_transfer,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300578 .functionality = dw210x_i2c_func,
579};
580
581static struct i2c_algorithm dw2102_serit_i2c_algo = {
582 .master_xfer = dw2102_serit_i2c_transfer,
583 .functionality = dw210x_i2c_func,
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300584};
585
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -0300586static struct i2c_algorithm dw2102_earda_i2c_algo = {
587 .master_xfer = dw2102_earda_i2c_transfer,
588 .functionality = dw210x_i2c_func,
589};
590
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300591static struct i2c_algorithm dw2104_i2c_algo = {
592 .master_xfer = dw2104_i2c_transfer,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300593 .functionality = dw210x_i2c_func,
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300594};
595
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -0300596static struct i2c_algorithm dw3101_i2c_algo = {
597 .master_xfer = dw3101_i2c_transfer,
598 .functionality = dw210x_i2c_func,
599};
600
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300601static struct i2c_algorithm s6x0_i2c_algo = {
602 .master_xfer = s6x0_i2c_transfer,
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300603 .functionality = dw210x_i2c_func,
604};
605
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300606static int dw210x_read_mac_address(struct dvb_usb_device *d, u8 mac[6])
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300607{
608 int i;
609 u8 ibuf[] = {0, 0};
610 u8 eeprom[256], eepromline[16];
611
612 for (i = 0; i < 256; i++) {
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300613 if (dw210x_op_rw(d->udev, 0xb6, 0xa0 , i, ibuf, 2, DW210X_READ_MSG) < 0) {
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300614 err("read eeprom failed.");
615 return -1;
616 } else {
617 eepromline[i%16] = ibuf[0];
618 eeprom[i] = ibuf[0];
619 }
620 if ((i % 16) == 15) {
621 deb_xfer("%02x: ", i - 15);
622 debug_dump(eepromline, 16, deb_xfer);
623 }
624 }
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -0300625
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300626 memcpy(mac, eeprom + 8, 6);
627 return 0;
628};
629
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300630static int s6x0_read_mac_address(struct dvb_usb_device *d, u8 mac[6])
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300631{
632 int i, ret;
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300633 u8 ibuf[] = { 0 }, obuf[] = { 0 };
634 u8 eeprom[256], eepromline[16];
635 struct i2c_msg msg[] = {
636 {
637 .addr = 0xa0 >> 1,
638 .flags = 0,
639 .buf = obuf,
640 .len = 1,
641 }, {
642 .addr = 0xa0 >> 1,
643 .flags = I2C_M_RD,
644 .buf = ibuf,
645 .len = 1,
646 }
647 };
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300648
649 for (i = 0; i < 256; i++) {
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300650 obuf[0] = i;
651 ret = s6x0_i2c_transfer(&d->i2c_adap, msg, 2);
652 if (ret != 2) {
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300653 err("read eeprom failed.");
654 return -1;
655 } else {
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300656 eepromline[i % 16] = ibuf[0];
657 eeprom[i] = ibuf[0];
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300658 }
659
660 if ((i % 16) == 15) {
661 deb_xfer("%02x: ", i - 15);
662 debug_dump(eepromline, 16, deb_xfer);
663 }
664 }
665
666 memcpy(mac, eeprom + 16, 6);
667 return 0;
668};
669
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300670static int dw210x_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300671{
Igor M. Liplianincd79d332009-12-14 20:24:56 -0300672 static u8 command_13v[] = {0x00, 0x01};
673 static u8 command_18v[] = {0x01, 0x01};
674 static u8 command_off[] = {0x00, 0x00};
675 struct i2c_msg msg = {
676 .addr = DW2102_VOLTAGE_CTRL,
677 .flags = 0,
678 .buf = command_off,
679 .len = 2,
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300680 };
681
682 struct dvb_usb_adapter *udev_adap =
683 (struct dvb_usb_adapter *)(fe->dvb->priv);
684 if (voltage == SEC_VOLTAGE_18)
Igor M. Liplianincd79d332009-12-14 20:24:56 -0300685 msg.buf = command_18v;
686 else if (voltage == SEC_VOLTAGE_13)
687 msg.buf = command_13v;
688
689 i2c_transfer(&udev_adap->dev->i2c_adap, &msg, 1);
690
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300691 return 0;
692}
693
Igor M. Liplianind4305c62008-10-17 13:45:55 -0300694static struct stv0299_config sharp_z0194a_config = {
695 .demod_address = 0x68,
696 .inittab = sharp_z0194a_inittab,
697 .mclk = 88000000UL,
698 .invert = 1,
699 .skip_reinit = 0,
700 .lock_output = STV0299_LOCKOUTPUT_1,
701 .volt13_op0_op1 = STV0299_VOLT13_OP1,
702 .min_delay_ms = 100,
703 .set_symbol_rate = sharp_z0194a_set_symbol_rate,
704};
705
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300706static struct cx24116_config dw2104_config = {
707 .demod_address = 0x55,
Igor M. Liplianincc8c4f32008-09-09 13:57:47 -0300708 .mpg_clk_pos_pol = 0x01,
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300709};
710
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300711static struct si21xx_config serit_sp1511lhb_config = {
712 .demod_address = 0x68,
713 .min_delay_ms = 100,
714
715};
716
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -0300717static struct tda10023_config dw3101_tda10023_config = {
718 .demod_address = 0x0c,
719 .invert = 1,
720};
721
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300722static struct mt312_config zl313_config = {
723 .demod_address = 0x0e,
724};
725
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300726static struct ds3000_config dw2104_ds3000_config = {
727 .demod_address = 0x68,
728};
729
730static struct stv0900_config dw2104a_stv0900_config = {
731 .demod_address = 0x6a,
732 .demod_mode = 0,
733 .xtal = 27000000,
734 .clkmode = 3,/* 0-CLKI, 2-XTALI, else AUTO */
735 .diseqc_mode = 2,/* 2/3 PWM */
736 .tun1_maddress = 0,/* 0x60 */
737 .tun1_adc = 0,/* 2 Vpp */
738 .path1_mode = 3,
739};
740
741static struct stb6100_config dw2104a_stb6100_config = {
742 .tuner_address = 0x60,
743 .refclock = 27000000,
744};
745
746static struct stv0900_config dw2104_stv0900_config = {
747 .demod_address = 0x68,
748 .demod_mode = 0,
749 .xtal = 8000000,
750 .clkmode = 3,
751 .diseqc_mode = 2,
752 .tun1_maddress = 0,
753 .tun1_adc = 1,/* 1 Vpp */
754 .path1_mode = 3,
755};
756
757static struct stv6110_config dw2104_stv6110_config = {
758 .i2c_address = 0x60,
759 .mclk = 16000000,
760 .clk_div = 1,
761};
762
Igor M. Liplianincd79d332009-12-14 20:24:56 -0300763static struct stv0900_config prof_7500_stv0900_config = {
764 .demod_address = 0x6a,
765 .demod_mode = 0,
766 .xtal = 27000000,
767 .clkmode = 3,/* 0-CLKI, 2-XTALI, else AUTO */
768 .diseqc_mode = 2,/* 2/3 PWM */
769 .tun1_maddress = 0,/* 0x60 */
770 .tun1_adc = 0,/* 2 Vpp */
771 .path1_mode = 3,
772 .tun1_type = 3,
773};
774
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300775static int dw2104_frontend_attach(struct dvb_usb_adapter *d)
776{
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300777 struct dvb_tuner_ops *tuner_ops = NULL;
778
779 if (demod_probe & 4) {
780 d->fe = dvb_attach(stv0900_attach, &dw2104a_stv0900_config,
781 &d->dev->i2c_adap, 0);
782 if (d->fe != NULL) {
783 if (dvb_attach(stb6100_attach, d->fe,
784 &dw2104a_stb6100_config,
785 &d->dev->i2c_adap)) {
786 tuner_ops = &d->fe->ops.tuner_ops;
787 tuner_ops->set_frequency = stb6100_set_freq;
788 tuner_ops->get_frequency = stb6100_get_freq;
789 tuner_ops->set_bandwidth = stb6100_set_bandw;
790 tuner_ops->get_bandwidth = stb6100_get_bandw;
791 d->fe->ops.set_voltage = dw210x_set_voltage;
792 info("Attached STV0900+STB6100!\n");
793 return 0;
794 }
795 }
796 }
797
798 if (demod_probe & 2) {
799 d->fe = dvb_attach(stv0900_attach, &dw2104_stv0900_config,
800 &d->dev->i2c_adap, 0);
801 if (d->fe != NULL) {
802 if (dvb_attach(stv6110_attach, d->fe,
803 &dw2104_stv6110_config,
804 &d->dev->i2c_adap)) {
805 d->fe->ops.set_voltage = dw210x_set_voltage;
806 info("Attached STV0900+STV6110A!\n");
807 return 0;
808 }
809 }
810 }
811
812 if (demod_probe & 1) {
813 d->fe = dvb_attach(cx24116_attach, &dw2104_config,
814 &d->dev->i2c_adap);
815 if (d->fe != NULL) {
816 d->fe->ops.set_voltage = dw210x_set_voltage;
817 info("Attached cx24116!\n");
818 return 0;
819 }
820 }
821
822 d->fe = dvb_attach(ds3000_attach, &dw2104_ds3000_config,
823 &d->dev->i2c_adap);
824 if (d->fe != NULL) {
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300825 d->fe->ops.set_voltage = dw210x_set_voltage;
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300826 info("Attached DS3000!\n");
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300827 return 0;
828 }
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300829
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300830 return -EIO;
831}
832
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300833static struct dvb_usb_device_properties dw2102_properties;
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -0300834static struct dvb_usb_device_properties dw2104_properties;
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300835static struct dvb_usb_device_properties s6x0_properties;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300836
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300837static int dw2102_frontend_attach(struct dvb_usb_adapter *d)
838{
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300839 if (dw2102_properties.i2c_algo == &dw2102_serit_i2c_algo) {
840 /*dw2102_properties.adapter->tuner_attach = NULL;*/
841 d->fe = dvb_attach(si21xx_attach, &serit_sp1511lhb_config,
842 &d->dev->i2c_adap);
843 if (d->fe != NULL) {
844 d->fe->ops.set_voltage = dw210x_set_voltage;
845 info("Attached si21xx!\n");
846 return 0;
847 }
848 }
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300849
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -0300850 if (dw2102_properties.i2c_algo == &dw2102_earda_i2c_algo) {
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -0300851 d->fe = dvb_attach(stv0288_attach, &earda_config,
852 &d->dev->i2c_adap);
853 if (d->fe != NULL) {
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300854 if (dvb_attach(stb6000_attach, d->fe, 0x61,
855 &d->dev->i2c_adap)) {
856 d->fe->ops.set_voltage = dw210x_set_voltage;
857 info("Attached stv0288!\n");
858 return 0;
859 }
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -0300860 }
861 }
862
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300863 if (dw2102_properties.i2c_algo == &dw2102_i2c_algo) {
864 /*dw2102_properties.adapter->tuner_attach = dw2102_tuner_attach;*/
865 d->fe = dvb_attach(stv0299_attach, &sharp_z0194a_config,
866 &d->dev->i2c_adap);
867 if (d->fe != NULL) {
868 d->fe->ops.set_voltage = dw210x_set_voltage;
869 info("Attached stv0299!\n");
870 return 0;
871 }
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300872 }
873 return -EIO;
874}
875
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -0300876static int dw3101_frontend_attach(struct dvb_usb_adapter *d)
877{
878 d->fe = dvb_attach(tda10023_attach, &dw3101_tda10023_config,
879 &d->dev->i2c_adap, 0x48);
880 if (d->fe != NULL) {
881 info("Attached tda10023!\n");
882 return 0;
883 }
884 return -EIO;
885}
886
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300887static int s6x0_frontend_attach(struct dvb_usb_adapter *d)
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300888{
889 d->fe = dvb_attach(mt312_attach, &zl313_config,
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300890 &d->dev->i2c_adap);
891 if (d->fe != NULL) {
892 if (dvb_attach(zl10039_attach, d->fe, 0x60,
893 &d->dev->i2c_adap)) {
894 d->fe->ops.set_voltage = dw210x_set_voltage;
895 info("Attached zl100313+zl10039!\n");
896 return 0;
897 }
898 }
899
900 d->fe = dvb_attach(stv0288_attach, &earda_config,
901 &d->dev->i2c_adap);
902 if (d->fe != NULL) {
903 if (dvb_attach(stb6000_attach, d->fe, 0x61,
904 &d->dev->i2c_adap)) {
905 d->fe->ops.set_voltage = dw210x_set_voltage;
906 info("Attached stv0288+stb6000!\n");
907 return 0;
908 }
909 }
910
911 d->fe = dvb_attach(ds3000_attach, &dw2104_ds3000_config,
912 &d->dev->i2c_adap);
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300913 if (d->fe != NULL) {
914 d->fe->ops.set_voltage = dw210x_set_voltage;
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300915 info("Attached ds3000+ds2020!\n");
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300916 return 0;
917 }
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300918
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300919 return -EIO;
920}
921
Igor M. Liplianincd79d332009-12-14 20:24:56 -0300922static int prof_7500_frontend_attach(struct dvb_usb_adapter *d)
923{
924 d->fe = dvb_attach(stv0900_attach, &prof_7500_stv0900_config,
925 &d->dev->i2c_adap, 0);
926 if (d->fe == NULL)
927 return -EIO;
928 d->fe->ops.set_voltage = dw210x_set_voltage;
929
930 info("Attached STV0900+STB6100A!\n");
931
932 return 0;
933}
934
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300935static int dw2102_tuner_attach(struct dvb_usb_adapter *adap)
936{
937 dvb_attach(dvb_pll_attach, adap->fe, 0x60,
938 &adap->dev->i2c_adap, DVB_PLL_OPERA1);
939 return 0;
940}
941
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -0300942static int dw3101_tuner_attach(struct dvb_usb_adapter *adap)
943{
944 dvb_attach(dvb_pll_attach, adap->fe, 0x60,
945 &adap->dev->i2c_adap, DVB_PLL_TUA6034);
946
947 return 0;
948}
949
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300950static struct dvb_usb_rc_key dw210x_rc_keys[] = {
Mauro Carvalho Chehab2e365882009-08-29 15:19:31 -0300951 { 0xf80a, KEY_Q }, /*power*/
952 { 0xf80c, KEY_M }, /*mute*/
953 { 0xf811, KEY_1 },
954 { 0xf812, KEY_2 },
955 { 0xf813, KEY_3 },
956 { 0xf814, KEY_4 },
957 { 0xf815, KEY_5 },
958 { 0xf816, KEY_6 },
959 { 0xf817, KEY_7 },
960 { 0xf818, KEY_8 },
961 { 0xf819, KEY_9 },
962 { 0xf810, KEY_0 },
963 { 0xf81c, KEY_PAGEUP }, /*ch+*/
964 { 0xf80f, KEY_PAGEDOWN }, /*ch-*/
965 { 0xf81a, KEY_O }, /*vol+*/
966 { 0xf80e, KEY_Z }, /*vol-*/
967 { 0xf804, KEY_R }, /*rec*/
968 { 0xf809, KEY_D }, /*fav*/
969 { 0xf808, KEY_BACKSPACE }, /*rewind*/
970 { 0xf807, KEY_A }, /*fast*/
971 { 0xf80b, KEY_P }, /*pause*/
972 { 0xf802, KEY_ESC }, /*cancel*/
973 { 0xf803, KEY_G }, /*tab*/
974 { 0xf800, KEY_UP }, /*up*/
975 { 0xf81f, KEY_ENTER }, /*ok*/
976 { 0xf801, KEY_DOWN }, /*down*/
977 { 0xf805, KEY_C }, /*cap*/
978 { 0xf806, KEY_S }, /*stop*/
979 { 0xf840, KEY_F }, /*full*/
980 { 0xf81e, KEY_W }, /*tvmode*/
981 { 0xf81b, KEY_B }, /*recall*/
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300982};
983
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -0300984static struct dvb_usb_rc_key tevii_rc_keys[] = {
Mauro Carvalho Chehab2e365882009-08-29 15:19:31 -0300985 { 0xf80a, KEY_POWER },
986 { 0xf80c, KEY_MUTE },
987 { 0xf811, KEY_1 },
988 { 0xf812, KEY_2 },
989 { 0xf813, KEY_3 },
990 { 0xf814, KEY_4 },
991 { 0xf815, KEY_5 },
992 { 0xf816, KEY_6 },
993 { 0xf817, KEY_7 },
994 { 0xf818, KEY_8 },
995 { 0xf819, KEY_9 },
996 { 0xf810, KEY_0 },
997 { 0xf81c, KEY_MENU },
998 { 0xf80f, KEY_VOLUMEDOWN },
999 { 0xf81a, KEY_LAST },
1000 { 0xf80e, KEY_OPEN },
1001 { 0xf804, KEY_RECORD },
1002 { 0xf809, KEY_VOLUMEUP },
1003 { 0xf808, KEY_CHANNELUP },
1004 { 0xf807, KEY_PVR },
1005 { 0xf80b, KEY_TIME },
1006 { 0xf802, KEY_RIGHT },
1007 { 0xf803, KEY_LEFT },
1008 { 0xf800, KEY_UP },
1009 { 0xf81f, KEY_OK },
1010 { 0xf801, KEY_DOWN },
1011 { 0xf805, KEY_TUNER },
1012 { 0xf806, KEY_CHANNELDOWN },
1013 { 0xf840, KEY_PLAYPAUSE },
1014 { 0xf81e, KEY_REWIND },
1015 { 0xf81b, KEY_FAVORITES },
1016 { 0xf81d, KEY_BACK },
1017 { 0xf84d, KEY_FASTFORWARD },
1018 { 0xf844, KEY_EPG },
1019 { 0xf84c, KEY_INFO },
1020 { 0xf841, KEY_AB },
1021 { 0xf843, KEY_AUDIO },
1022 { 0xf845, KEY_SUBTITLE },
1023 { 0xf84a, KEY_LIST },
1024 { 0xf846, KEY_F1 },
1025 { 0xf847, KEY_F2 },
1026 { 0xf85e, KEY_F3 },
1027 { 0xf85c, KEY_F4 },
1028 { 0xf852, KEY_F5 },
1029 { 0xf85a, KEY_F6 },
1030 { 0xf856, KEY_MODE },
1031 { 0xf858, KEY_SWITCHVIDEOMODE },
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -03001032};
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001033
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -03001034static struct dvb_usb_rc_key tbs_rc_keys[] = {
Mauro Carvalho Chehab2e365882009-08-29 15:19:31 -03001035 { 0xf884, KEY_POWER },
1036 { 0xf894, KEY_MUTE },
1037 { 0xf887, KEY_1 },
1038 { 0xf886, KEY_2 },
1039 { 0xf885, KEY_3 },
1040 { 0xf88b, KEY_4 },
1041 { 0xf88a, KEY_5 },
1042 { 0xf889, KEY_6 },
1043 { 0xf88f, KEY_7 },
1044 { 0xf88e, KEY_8 },
1045 { 0xf88d, KEY_9 },
1046 { 0xf892, KEY_0 },
1047 { 0xf896, KEY_CHANNELUP },
1048 { 0xf891, KEY_CHANNELDOWN },
1049 { 0xf893, KEY_VOLUMEUP },
1050 { 0xf88c, KEY_VOLUMEDOWN },
1051 { 0xf883, KEY_RECORD },
1052 { 0xf898, KEY_PAUSE },
1053 { 0xf899, KEY_OK },
1054 { 0xf89a, KEY_SHUFFLE },
1055 { 0xf881, KEY_UP },
1056 { 0xf890, KEY_LEFT },
1057 { 0xf882, KEY_RIGHT },
1058 { 0xf888, KEY_DOWN },
1059 { 0xf895, KEY_FAVORITES },
1060 { 0xf897, KEY_SUBTITLE },
1061 { 0xf89d, KEY_ZOOM },
1062 { 0xf89f, KEY_EXIT },
1063 { 0xf89e, KEY_MENU },
1064 { 0xf89c, KEY_EPG },
1065 { 0xf880, KEY_PREVIOUS },
1066 { 0xf89b, KEY_MODE }
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -03001067};
1068
1069static struct dvb_usb_rc_keys_table keys_tables[] = {
1070 { dw210x_rc_keys, ARRAY_SIZE(dw210x_rc_keys) },
1071 { tevii_rc_keys, ARRAY_SIZE(tevii_rc_keys) },
1072 { tbs_rc_keys, ARRAY_SIZE(tbs_rc_keys) },
1073};
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001074
1075static int dw2102_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
1076{
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -03001077 struct dvb_usb_rc_key *keymap = d->props.rc_key_map;
1078 int keymap_size = d->props.rc_key_map_size;
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001079 u8 key[2];
Igor M. Liplianin8a8dad72009-06-13 08:10:24 -03001080 struct i2c_msg msg = {
1081 .addr = DW2102_RC_QUERY,
1082 .flags = I2C_M_RD,
1083 .buf = key,
1084 .len = 2
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001085 };
1086 int i;
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -03001087 /* override keymap */
1088 if ((ir_keymap > 0) && (ir_keymap <= ARRAY_SIZE(keys_tables))) {
1089 keymap = keys_tables[ir_keymap - 1].rc_keys ;
1090 keymap_size = keys_tables[ir_keymap - 1].rc_keys_size;
1091 }
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001092
1093 *state = REMOTE_NO_KEY_PRESSED;
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001094 if (d->props.i2c_algo->master_xfer(&d->i2c_adap, &msg, 1) == 1) {
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -03001095 for (i = 0; i < keymap_size ; i++) {
Mauro Carvalho Chehab2e365882009-08-29 15:19:31 -03001096 if (rc5_data(&keymap[i]) == msg.buf[0]) {
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001097 *state = REMOTE_KEY_PRESSED;
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -03001098 *event = keymap[i].event;
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001099 break;
1100 }
Igor M. Liplianin8a8dad72009-06-13 08:10:24 -03001101
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001102 }
Igor M. Liplianin8a8dad72009-06-13 08:10:24 -03001103
1104 if ((*state) == REMOTE_KEY_PRESSED)
1105 deb_rc("%s: found rc key: %x, %x, event: %x\n",
1106 __func__, key[0], key[1], (*event));
1107 else if (key[0] != 0xff)
1108 deb_rc("%s: unknown rc key: %x, %x\n",
1109 __func__, key[0], key[1]);
1110
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001111 }
Igor M. Liplianin8a8dad72009-06-13 08:10:24 -03001112
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001113 return 0;
1114}
1115
1116static struct usb_device_id dw2102_table[] = {
1117 {USB_DEVICE(USB_VID_CYPRESS, USB_PID_DW2102)},
1118 {USB_DEVICE(USB_VID_CYPRESS, 0x2101)},
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001119 {USB_DEVICE(USB_VID_CYPRESS, USB_PID_DW2104)},
1120 {USB_DEVICE(0x9022, USB_PID_TEVII_S650)},
Igor M. Liplianin4cc0edf2008-11-05 22:12:56 -03001121 {USB_DEVICE(USB_VID_TERRATEC, USB_PID_CINERGY_S)},
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001122 {USB_DEVICE(USB_VID_CYPRESS, USB_PID_DW3101)},
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001123 {USB_DEVICE(0x9022, USB_PID_TEVII_S630)},
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001124 {USB_DEVICE(0x3011, USB_PID_PROF_1100)},
1125 {USB_DEVICE(0x9022, USB_PID_TEVII_S660)},
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001126 {USB_DEVICE(0x3034, 0x7500)},
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001127 { }
1128};
1129
1130MODULE_DEVICE_TABLE(usb, dw2102_table);
1131
1132static int dw2102_load_firmware(struct usb_device *dev,
1133 const struct firmware *frmwr)
1134{
1135 u8 *b, *p;
1136 int ret = 0, i;
1137 u8 reset;
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -03001138 u8 reset16[] = {0, 0, 0, 0, 0, 0, 0};
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001139 const struct firmware *fw;
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001140 const char *fw_2101 = "dvb-usb-dw2101.fw";
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001141
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001142 switch (dev->descriptor.idProduct) {
1143 case 0x2101:
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001144 ret = request_firmware(&fw, fw_2101, &dev->dev);
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001145 if (ret != 0) {
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001146 err(err_str, fw_2101);
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001147 return ret;
1148 }
1149 break;
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001150 default:
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001151 fw = frmwr;
1152 break;
1153 }
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001154 info("start downloading DW210X firmware");
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001155 p = kmalloc(fw->size, GFP_KERNEL);
1156 reset = 1;
1157 /*stop the CPU*/
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001158 dw210x_op_rw(dev, 0xa0, 0x7f92, 0, &reset, 1, DW210X_WRITE_MSG);
1159 dw210x_op_rw(dev, 0xa0, 0xe600, 0, &reset, 1, DW210X_WRITE_MSG);
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001160
1161 if (p != NULL) {
1162 memcpy(p, fw->data, fw->size);
1163 for (i = 0; i < fw->size; i += 0x40) {
1164 b = (u8 *) p + i;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001165 if (dw210x_op_rw(dev, 0xa0, i, 0, b , 0x40,
1166 DW210X_WRITE_MSG) != 0x40) {
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001167 err("error while transferring firmware");
1168 ret = -EINVAL;
1169 break;
1170 }
1171 }
1172 /* restart the CPU */
1173 reset = 0;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001174 if (ret || dw210x_op_rw(dev, 0xa0, 0x7f92, 0, &reset, 1,
1175 DW210X_WRITE_MSG) != 1) {
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001176 err("could not restart the USB controller CPU.");
1177 ret = -EINVAL;
1178 }
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001179 if (ret || dw210x_op_rw(dev, 0xa0, 0xe600, 0, &reset, 1,
1180 DW210X_WRITE_MSG) != 1) {
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001181 err("could not restart the USB controller CPU.");
1182 ret = -EINVAL;
1183 }
1184 /* init registers */
1185 switch (dev->descriptor.idProduct) {
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001186 case USB_PID_PROF_1100:
1187 s6x0_properties.rc_key_map = tbs_rc_keys;
1188 s6x0_properties.rc_key_map_size =
1189 ARRAY_SIZE(tbs_rc_keys);
1190 break;
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001191 case USB_PID_TEVII_S650:
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -03001192 dw2104_properties.rc_key_map = tevii_rc_keys;
1193 dw2104_properties.rc_key_map_size =
1194 ARRAY_SIZE(tevii_rc_keys);
1195 case USB_PID_DW2104:
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001196 reset = 1;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001197 dw210x_op_rw(dev, 0xc4, 0x0000, 0, &reset, 1,
1198 DW210X_WRITE_MSG);
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001199 /* break omitted intentionally */
1200 case USB_PID_DW3101:
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001201 reset = 0;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001202 dw210x_op_rw(dev, 0xbf, 0x0040, 0, &reset, 0,
1203 DW210X_WRITE_MSG);
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001204 break;
Igor M. Liplianin4cc0edf2008-11-05 22:12:56 -03001205 case USB_PID_CINERGY_S:
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001206 case USB_PID_DW2102:
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001207 dw210x_op_rw(dev, 0xbf, 0x0040, 0, &reset, 0,
1208 DW210X_WRITE_MSG);
1209 dw210x_op_rw(dev, 0xb9, 0x0000, 0, &reset16[0], 2,
1210 DW210X_READ_MSG);
1211 /* check STV0299 frontend */
1212 dw210x_op_rw(dev, 0xb5, 0, 0, &reset16[0], 2,
1213 DW210X_READ_MSG);
Igor M. Liplianinea023df2008-12-04 12:49:23 -03001214 if ((reset16[0] == 0xa1) || (reset16[0] == 0x80)) {
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001215 dw2102_properties.i2c_algo = &dw2102_i2c_algo;
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -03001216 dw2102_properties.adapter->tuner_attach = &dw2102_tuner_attach;
1217 break;
1218 } else {
1219 /* check STV0288 frontend */
1220 reset16[0] = 0xd0;
1221 reset16[1] = 1;
1222 reset16[2] = 0;
1223 dw210x_op_rw(dev, 0xc2, 0, 0, &reset16[0], 3,
1224 DW210X_WRITE_MSG);
1225 dw210x_op_rw(dev, 0xc3, 0xd1, 0, &reset16[0], 3,
1226 DW210X_READ_MSG);
1227 if (reset16[2] == 0x11) {
1228 dw2102_properties.i2c_algo = &dw2102_earda_i2c_algo;
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -03001229 break;
1230 }
1231 }
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001232 case 0x2101:
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001233 dw210x_op_rw(dev, 0xbc, 0x0030, 0, &reset16[0], 2,
1234 DW210X_READ_MSG);
1235 dw210x_op_rw(dev, 0xba, 0x0000, 0, &reset16[0], 7,
1236 DW210X_READ_MSG);
1237 dw210x_op_rw(dev, 0xba, 0x0000, 0, &reset16[0], 7,
1238 DW210X_READ_MSG);
1239 dw210x_op_rw(dev, 0xb9, 0x0000, 0, &reset16[0], 2,
1240 DW210X_READ_MSG);
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001241 break;
1242 }
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001243
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001244 msleep(100);
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001245 kfree(p);
1246 }
1247 return ret;
1248}
1249
1250static struct dvb_usb_device_properties dw2102_properties = {
1251 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1252 .usb_ctrl = DEVICE_SPECIFIC,
1253 .firmware = "dvb-usb-dw2102.fw",
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001254 .no_reconnect = 1,
1255
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001256 .i2c_algo = &dw2102_serit_i2c_algo,
1257 .rc_key_map = dw210x_rc_keys,
1258 .rc_key_map_size = ARRAY_SIZE(dw210x_rc_keys),
Igor M Liplianin7fd48282008-07-20 08:05:50 -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. Liplianin1dac77c2009-06-14 20:51:45 -03001267 .adapter = {
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001268 {
1269 .frontend_attach = dw2102_frontend_attach,
1270 .streaming_ctrl = NULL,
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -03001271 .tuner_attach = NULL,
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001272 .stream = {
1273 .type = USB_BULK,
1274 .count = 8,
1275 .endpoint = 0x82,
1276 .u = {
1277 .bulk = {
1278 .buffersize = 4096,
1279 }
1280 }
1281 },
1282 }
1283 },
Igor M. Liplianin4cc0edf2008-11-05 22:12:56 -03001284 .num_device_descs = 3,
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001285 .devices = {
1286 {"DVBWorld DVB-S 2102 USB2.0",
1287 {&dw2102_table[0], NULL},
1288 {NULL},
1289 },
1290 {"DVBWorld DVB-S 2101 USB2.0",
1291 {&dw2102_table[1], NULL},
1292 {NULL},
1293 },
Igor M. Liplianin4cc0edf2008-11-05 22:12:56 -03001294 {"TerraTec Cinergy S USB",
1295 {&dw2102_table[4], NULL},
1296 {NULL},
1297 },
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001298 }
1299};
1300
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001301static struct dvb_usb_device_properties dw2104_properties = {
1302 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1303 .usb_ctrl = DEVICE_SPECIFIC,
1304 .firmware = "dvb-usb-dw2104.fw",
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001305 .no_reconnect = 1,
1306
1307 .i2c_algo = &dw2104_i2c_algo,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001308 .rc_key_map = dw210x_rc_keys,
1309 .rc_key_map_size = ARRAY_SIZE(dw210x_rc_keys),
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001310 .rc_interval = 150,
1311 .rc_query = dw2102_rc_query,
1312
1313 .generic_bulk_ctrl_endpoint = 0x81,
1314 /* parameter for the MPEG2-data transfer */
1315 .num_adapters = 1,
1316 .download_firmware = dw2102_load_firmware,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001317 .read_mac_address = dw210x_read_mac_address,
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001318 .adapter = {
1319 {
1320 .frontend_attach = dw2104_frontend_attach,
1321 .streaming_ctrl = NULL,
1322 /*.tuner_attach = dw2104_tuner_attach,*/
1323 .stream = {
1324 .type = USB_BULK,
1325 .count = 8,
1326 .endpoint = 0x82,
1327 .u = {
1328 .bulk = {
1329 .buffersize = 4096,
1330 }
1331 }
1332 },
1333 }
1334 },
1335 .num_device_descs = 2,
1336 .devices = {
1337 { "DVBWorld DW2104 USB2.0",
1338 {&dw2102_table[2], NULL},
1339 {NULL},
1340 },
1341 { "TeVii S650 USB2.0",
1342 {&dw2102_table[3], NULL},
1343 {NULL},
1344 },
1345 }
1346};
1347
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001348static struct dvb_usb_device_properties dw3101_properties = {
1349 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1350 .usb_ctrl = DEVICE_SPECIFIC,
1351 .firmware = "dvb-usb-dw3101.fw",
1352 .no_reconnect = 1,
1353
1354 .i2c_algo = &dw3101_i2c_algo,
1355 .rc_key_map = dw210x_rc_keys,
1356 .rc_key_map_size = ARRAY_SIZE(dw210x_rc_keys),
1357 .rc_interval = 150,
1358 .rc_query = dw2102_rc_query,
1359
1360 .generic_bulk_ctrl_endpoint = 0x81,
1361 /* parameter for the MPEG2-data transfer */
1362 .num_adapters = 1,
1363 .download_firmware = dw2102_load_firmware,
1364 .read_mac_address = dw210x_read_mac_address,
1365 .adapter = {
1366 {
1367 .frontend_attach = dw3101_frontend_attach,
1368 .streaming_ctrl = NULL,
1369 .tuner_attach = dw3101_tuner_attach,
1370 .stream = {
1371 .type = USB_BULK,
1372 .count = 8,
1373 .endpoint = 0x82,
1374 .u = {
1375 .bulk = {
1376 .buffersize = 4096,
1377 }
1378 }
1379 },
1380 }
1381 },
1382 .num_device_descs = 1,
1383 .devices = {
1384 { "DVBWorld DVB-C 3101 USB2.0",
1385 {&dw2102_table[5], NULL},
1386 {NULL},
1387 },
1388 }
1389};
1390
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001391static struct dvb_usb_device_properties s6x0_properties = {
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001392 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1393 .usb_ctrl = DEVICE_SPECIFIC,
1394 .firmware = "dvb-usb-s630.fw",
1395 .no_reconnect = 1,
1396
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001397 .i2c_algo = &s6x0_i2c_algo,
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001398 .rc_key_map = tevii_rc_keys,
1399 .rc_key_map_size = ARRAY_SIZE(tevii_rc_keys),
1400 .rc_interval = 150,
1401 .rc_query = dw2102_rc_query,
1402
1403 .generic_bulk_ctrl_endpoint = 0x81,
1404 .num_adapters = 1,
1405 .download_firmware = dw2102_load_firmware,
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001406 .read_mac_address = s6x0_read_mac_address,
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001407 .adapter = {
1408 {
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001409 .frontend_attach = s6x0_frontend_attach,
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001410 .streaming_ctrl = NULL,
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001411 .tuner_attach = NULL,
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001412 .stream = {
1413 .type = USB_BULK,
1414 .count = 8,
1415 .endpoint = 0x82,
1416 .u = {
1417 .bulk = {
1418 .buffersize = 4096,
1419 }
1420 }
1421 },
1422 }
1423 },
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001424 .num_device_descs = 3,
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001425 .devices = {
1426 {"TeVii S630 USB",
1427 {&dw2102_table[6], NULL},
1428 {NULL},
1429 },
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001430 {"Prof 1100 USB ",
1431 {&dw2102_table[7], NULL},
1432 {NULL},
1433 },
1434 {"TeVii S660 USB",
1435 {&dw2102_table[8], NULL},
1436 {NULL},
1437 },
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001438 }
1439};
1440
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001441struct dvb_usb_device_properties *p7500;
1442static struct dvb_usb_device_description d7500 = {
1443 "Prof 7500 USB DVB-S2",
1444 {&dw2102_table[9], NULL},
1445 {NULL},
1446};
1447
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001448static int dw2102_probe(struct usb_interface *intf,
1449 const struct usb_device_id *id)
1450{
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001451
1452 p7500 = kzalloc(sizeof(struct dvb_usb_device_properties), GFP_KERNEL);
1453 if (!p7500)
1454 return -ENOMEM;
1455 /* copy default structure */
1456 memcpy(p7500, &s6x0_properties,
1457 sizeof(struct dvb_usb_device_properties));
1458 /* fill only different fields */
1459 p7500->firmware = "dvb-usb-p7500.fw";
1460 p7500->devices[0] = d7500;
1461 p7500->rc_key_map = tbs_rc_keys;
1462 p7500->rc_key_map_size = ARRAY_SIZE(tbs_rc_keys);
1463 p7500->adapter->frontend_attach = prof_7500_frontend_attach;
1464
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001465 if (0 == dvb_usb_device_init(intf, &dw2102_properties,
1466 THIS_MODULE, NULL, adapter_nr) ||
1467 0 == dvb_usb_device_init(intf, &dw2104_properties,
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001468 THIS_MODULE, NULL, adapter_nr) ||
1469 0 == dvb_usb_device_init(intf, &dw3101_properties,
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001470 THIS_MODULE, NULL, adapter_nr) ||
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001471 0 == dvb_usb_device_init(intf, &s6x0_properties,
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001472 THIS_MODULE, NULL, adapter_nr) ||
1473 0 == dvb_usb_device_init(intf, p7500,
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001474 THIS_MODULE, NULL, adapter_nr))
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001475 return 0;
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001476
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001477 return -ENODEV;
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001478}
1479
1480static struct usb_driver dw2102_driver = {
1481 .name = "dw2102",
1482 .probe = dw2102_probe,
1483 .disconnect = dvb_usb_device_exit,
1484 .id_table = dw2102_table,
1485};
1486
1487static int __init dw2102_module_init(void)
1488{
1489 int ret = usb_register(&dw2102_driver);
1490 if (ret)
1491 err("usb_register failed. Error number %d", ret);
1492
1493 return ret;
1494}
1495
1496static void __exit dw2102_module_exit(void)
1497{
1498 usb_deregister(&dw2102_driver);
1499}
1500
1501module_init(dw2102_module_init);
1502module_exit(dw2102_module_exit);
1503
1504MODULE_AUTHOR("Igor M. Liplianin (c) liplianin@me.by");
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001505MODULE_DESCRIPTION("Driver for DVBWorld DVB-S 2101, 2102, DVB-S2 2104,"
1506 " DVB-C 3101 USB2.0,"
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001507 " TeVii S600, S630, S650, S660 USB2.0,"
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001508 " Prof 1100, 7500 USB2.0 devices");
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001509MODULE_VERSION("0.1");
1510MODULE_LICENSE("GPL");