blob: f103ec1fe82ed0e89b9c0f4918682a367f072f33 [file] [log] [blame]
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001/* DVB USB framework compliant Linux driver for the
Igor M. Liplianin2f30fb42011-02-25 18:41:23 -03002 * DVBWorld DVB-S 2101, 2102, DVB-S2 2104, DVB-C 3101,
3 * TeVii S600, S630, S650, S660, S480,
4 * Prof 1100, 7500,
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03005 * Geniatech SU3000 Cards
Igor M. Liplianin2f30fb42011-02-25 18:41:23 -03006 * Copyright (C) 2008-2011 Igor M. Liplianin (liplianin@me.by)
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation, version 2.
11 *
12 * see Documentation/dvb/README.dvb-usb for more information
13 */
Igor M Liplianin7fd48282008-07-20 08:05:50 -030014#include "dw2102.h"
Igor M. Liplianin21b007b2008-09-17 19:19:19 -030015#include "si21xx.h"
Igor M Liplianin7fd48282008-07-20 08:05:50 -030016#include "stv0299.h"
17#include "z0194a.h"
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -030018#include "stv0288.h"
19#include "stb6000.h"
20#include "eds1547.h"
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -030021#include "cx24116.h"
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -030022#include "tda1002x.h"
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -030023#include "mt312.h"
24#include "zl10039.h"
Igor M. Liplianin141cc352009-11-27 14:37:35 -030025#include "ds3000.h"
26#include "stv0900.h"
27#include "stv6110.h"
28#include "stb6100.h"
29#include "stb6100_proc.h"
Igor M Liplianin7fd48282008-07-20 08:05:50 -030030
31#ifndef USB_PID_DW2102
32#define USB_PID_DW2102 0x2102
33#endif
34
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -030035#ifndef USB_PID_DW2104
36#define USB_PID_DW2104 0x2104
37#endif
38
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -030039#ifndef USB_PID_DW3101
40#define USB_PID_DW3101 0x3101
41#endif
42
Igor M. Liplianin4cc0edf2008-11-05 22:12:56 -030043#ifndef USB_PID_CINERGY_S
44#define USB_PID_CINERGY_S 0x0064
45#endif
46
Igor M. Liplianin141cc352009-11-27 14:37:35 -030047#ifndef USB_PID_TEVII_S630
48#define USB_PID_TEVII_S630 0xd630
49#endif
50
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -030051#ifndef USB_PID_TEVII_S650
52#define USB_PID_TEVII_S650 0xd650
53#endif
54
Igor M. Liplianin141cc352009-11-27 14:37:35 -030055#ifndef USB_PID_TEVII_S660
56#define USB_PID_TEVII_S660 0xd660
57#endif
58
Igor M. Liplianine8f50552011-02-25 18:41:23 -030059#ifndef USB_PID_TEVII_S480_1
60#define USB_PID_TEVII_S480_1 0xd481
61#endif
62
63#ifndef USB_PID_TEVII_S480_2
64#define USB_PID_TEVII_S480_2 0xd482
65#endif
66
Igor M. Liplianin141cc352009-11-27 14:37:35 -030067#ifndef USB_PID_PROF_1100
68#define USB_PID_PROF_1100 0xb012
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -030069#endif
70
Igor M. Liplianin21b007b2008-09-17 19:19:19 -030071#define DW210X_READ_MSG 0
72#define DW210X_WRITE_MSG 1
Igor M Liplianin7fd48282008-07-20 08:05:50 -030073
74#define REG_1F_SYMBOLRATE_BYTE0 0x1f
75#define REG_20_SYMBOLRATE_BYTE1 0x20
76#define REG_21_SYMBOLRATE_BYTE2 0x21
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -030077/* on my own*/
Igor M Liplianin7fd48282008-07-20 08:05:50 -030078#define DW2102_VOLTAGE_CTRL (0x1800)
Igor M. Liplianind2ffc442011-02-25 18:41:22 -030079#define SU3000_STREAM_CTRL (0x1900)
Igor M Liplianin7fd48282008-07-20 08:05:50 -030080#define DW2102_RC_QUERY (0x1a00)
Igor M. Liplianinfa8bae12011-02-25 18:41:22 -030081#define DW2102_LED_CTRL (0x1b00)
Igor M Liplianin7fd48282008-07-20 08:05:50 -030082
Igor M. Liplianin141cc352009-11-27 14:37:35 -030083#define err_str "did not find the firmware file. (%s) " \
84 "Please see linux/Documentation/dvb/ for more details " \
85 "on firmware-problems."
86
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -030087struct rc_map_dvb_usb_table_table {
88 struct rc_map_table *rc_keys;
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -030089 int rc_keys_size;
Igor M Liplianin7fd48282008-07-20 08:05:50 -030090};
91
Igor M. Liplianind2ffc442011-02-25 18:41:22 -030092struct su3000_state {
93 u8 initialized;
94};
95
Igor M. Liplianin52c506e2011-02-25 18:41:23 -030096struct s6x0_state {
97 int (*old_set_voltage)(struct dvb_frontend *f, fe_sec_voltage_t v);
98};
99
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300100/* debug */
101static int dvb_usb_dw2102_debug;
102module_param_named(debug, dvb_usb_dw2102_debug, int, 0644);
Igor M. Liplianin8a8dad72009-06-13 08:10:24 -0300103MODULE_PARM_DESC(debug, "set debugging level (1=info 2=xfer 4=rc(or-able))."
104 DVB_USB_DEBUG_STATUS);
105
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -0300106/* keymaps */
107static int ir_keymap;
108module_param_named(keymap, ir_keymap, int, 0644);
Igor M. Liplianinfeb16e92011-02-25 18:41:22 -0300109MODULE_PARM_DESC(keymap, "set keymap 0=default 1=dvbworld 2=tevii 3=tbs ..."
110 " 256=none");
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300111
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300112/* demod probe */
113static int demod_probe = 1;
114module_param_named(demod, demod_probe, int, 0644);
115MODULE_PARM_DESC(demod, "demod to probe (1=cx24116 2=stv0903+stv6110 "
116 "4=stv0903+stb6100(or-able)).");
117
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300118DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
119
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300120static int dw210x_op_rw(struct usb_device *dev, u8 request, u16 value,
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300121 u16 index, u8 * data, u16 len, int flags)
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300122{
123 int ret;
Florian Micklerb47b8502011-03-21 15:33:44 -0300124 u8 *u8buf;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300125 unsigned int pipe = (flags == DW210X_READ_MSG) ?
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300126 usb_rcvctrlpipe(dev, 0) : usb_sndctrlpipe(dev, 0);
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300127 u8 request_type = (flags == DW210X_READ_MSG) ? USB_DIR_IN : USB_DIR_OUT;
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300128
Florian Micklerb47b8502011-03-21 15:33:44 -0300129 u8buf = kmalloc(len, GFP_KERNEL);
130 if (!u8buf)
131 return -ENOMEM;
132
133
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300134 if (flags == DW210X_WRITE_MSG)
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300135 memcpy(u8buf, data, len);
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300136 ret = usb_control_msg(dev, pipe, request, request_type | USB_TYPE_VENDOR,
137 value, index , u8buf, len, 2000);
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300138
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300139 if (flags == DW210X_READ_MSG)
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300140 memcpy(data, u8buf, len);
Florian Micklerb47b8502011-03-21 15:33:44 -0300141
142 kfree(u8buf);
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300143 return ret;
144}
145
146/* I2C */
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300147static int dw2102_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
148 int num)
149{
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -0300150 struct dvb_usb_device *d = i2c_get_adapdata(adap);
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300151 int i = 0, ret = 0;
152 u8 buf6[] = {0x2c, 0x05, 0xc0, 0, 0, 0, 0};
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300153 u16 value;
154
155 if (!d)
156 return -ENODEV;
157 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
158 return -EAGAIN;
159
160 switch (num) {
161 case 2:
162 /* read stv0299 register */
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300163 value = msg[0].buf[0];/* register */
164 for (i = 0; i < msg[1].len; i++) {
Igor M. Liplianinb16af292011-02-27 16:22:57 -0300165 ret = dw210x_op_rw(d->udev, 0xb5, value + i, 0,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300166 buf6, 2, DW210X_READ_MSG);
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300167 msg[1].buf[i] = buf6[0];
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300168 }
169 break;
170 case 1:
171 switch (msg[0].addr) {
172 case 0x68:
173 /* write to stv0299 register */
174 buf6[0] = 0x2a;
175 buf6[1] = msg[0].buf[0];
176 buf6[2] = msg[0].buf[1];
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300177 ret = dw210x_op_rw(d->udev, 0xb2, 0, 0,
178 buf6, 3, DW210X_WRITE_MSG);
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300179 break;
180 case 0x60:
181 if (msg[0].flags == 0) {
182 /* write to tuner pll */
183 buf6[0] = 0x2c;
184 buf6[1] = 5;
185 buf6[2] = 0xc0;
186 buf6[3] = msg[0].buf[0];
187 buf6[4] = msg[0].buf[1];
188 buf6[5] = msg[0].buf[2];
189 buf6[6] = msg[0].buf[3];
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300190 ret = dw210x_op_rw(d->udev, 0xb2, 0, 0,
191 buf6, 7, DW210X_WRITE_MSG);
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300192 } else {
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300193 /* read from tuner */
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300194 ret = dw210x_op_rw(d->udev, 0xb5, 0, 0,
195 buf6, 1, DW210X_READ_MSG);
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300196 msg[0].buf[0] = buf6[0];
197 }
198 break;
199 case (DW2102_RC_QUERY):
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300200 ret = dw210x_op_rw(d->udev, 0xb8, 0, 0,
201 buf6, 2, DW210X_READ_MSG);
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300202 msg[0].buf[0] = buf6[0];
203 msg[0].buf[1] = buf6[1];
204 break;
205 case (DW2102_VOLTAGE_CTRL):
206 buf6[0] = 0x30;
207 buf6[1] = msg[0].buf[0];
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300208 ret = dw210x_op_rw(d->udev, 0xb2, 0, 0,
209 buf6, 2, DW210X_WRITE_MSG);
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300210 break;
211 }
212
213 break;
214 }
215
216 mutex_unlock(&d->i2c_mutex);
217 return num;
218}
219
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300220static int dw2102_serit_i2c_transfer(struct i2c_adapter *adap,
221 struct i2c_msg msg[], int num)
222{
223 struct dvb_usb_device *d = i2c_get_adapdata(adap);
224 int ret = 0;
225 u8 buf6[] = {0, 0, 0, 0, 0, 0, 0};
226
227 if (!d)
228 return -ENODEV;
229 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
230 return -EAGAIN;
231
232 switch (num) {
233 case 2:
234 /* read si2109 register by number */
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300235 buf6[0] = msg[0].addr << 1;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300236 buf6[1] = msg[0].len;
237 buf6[2] = msg[0].buf[0];
238 ret = dw210x_op_rw(d->udev, 0xc2, 0, 0,
239 buf6, msg[0].len + 2, DW210X_WRITE_MSG);
240 /* read si2109 register */
241 ret = dw210x_op_rw(d->udev, 0xc3, 0xd0, 0,
242 buf6, msg[1].len + 2, DW210X_READ_MSG);
243 memcpy(msg[1].buf, buf6 + 2, msg[1].len);
244
245 break;
246 case 1:
247 switch (msg[0].addr) {
248 case 0x68:
249 /* write to si2109 register */
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300250 buf6[0] = msg[0].addr << 1;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300251 buf6[1] = msg[0].len;
252 memcpy(buf6 + 2, msg[0].buf, msg[0].len);
253 ret = dw210x_op_rw(d->udev, 0xc2, 0, 0, buf6,
254 msg[0].len + 2, DW210X_WRITE_MSG);
255 break;
256 case(DW2102_RC_QUERY):
257 ret = dw210x_op_rw(d->udev, 0xb8, 0, 0,
258 buf6, 2, DW210X_READ_MSG);
259 msg[0].buf[0] = buf6[0];
260 msg[0].buf[1] = buf6[1];
261 break;
262 case(DW2102_VOLTAGE_CTRL):
263 buf6[0] = 0x30;
264 buf6[1] = msg[0].buf[0];
265 ret = dw210x_op_rw(d->udev, 0xb2, 0, 0,
266 buf6, 2, DW210X_WRITE_MSG);
267 break;
268 }
269 break;
270 }
271
272 mutex_unlock(&d->i2c_mutex);
273 return num;
274}
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -0300275
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -0300276static int dw2102_earda_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], int num)
277{
278 struct dvb_usb_device *d = i2c_get_adapdata(adap);
279 int ret = 0;
280
281 if (!d)
282 return -ENODEV;
283 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
284 return -EAGAIN;
285
286 switch (num) {
287 case 2: {
288 /* read */
289 /* first write first register number */
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -0300290 u8 ibuf[msg[1].len + 2], obuf[3];
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300291 obuf[0] = msg[0].addr << 1;
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -0300292 obuf[1] = msg[0].len;
293 obuf[2] = msg[0].buf[0];
294 ret = dw210x_op_rw(d->udev, 0xc2, 0, 0,
295 obuf, msg[0].len + 2, DW210X_WRITE_MSG);
296 /* second read registers */
297 ret = dw210x_op_rw(d->udev, 0xc3, 0xd1 , 0,
298 ibuf, msg[1].len + 2, DW210X_READ_MSG);
299 memcpy(msg[1].buf, ibuf + 2, msg[1].len);
300
301 break;
302 }
303 case 1:
304 switch (msg[0].addr) {
305 case 0x68: {
306 /* write to register */
307 u8 obuf[msg[0].len + 2];
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300308 obuf[0] = msg[0].addr << 1;
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -0300309 obuf[1] = msg[0].len;
310 memcpy(obuf + 2, msg[0].buf, msg[0].len);
311 ret = dw210x_op_rw(d->udev, 0xc2, 0, 0,
312 obuf, msg[0].len + 2, DW210X_WRITE_MSG);
313 break;
314 }
315 case 0x61: {
316 /* write to tuner */
317 u8 obuf[msg[0].len + 2];
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300318 obuf[0] = msg[0].addr << 1;
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -0300319 obuf[1] = msg[0].len;
320 memcpy(obuf + 2, msg[0].buf, msg[0].len);
321 ret = dw210x_op_rw(d->udev, 0xc2, 0, 0,
322 obuf, msg[0].len + 2, DW210X_WRITE_MSG);
323 break;
324 }
325 case(DW2102_RC_QUERY): {
326 u8 ibuf[2];
327 ret = dw210x_op_rw(d->udev, 0xb8, 0, 0,
328 ibuf, 2, DW210X_READ_MSG);
329 memcpy(msg[0].buf, ibuf , 2);
330 break;
331 }
332 case(DW2102_VOLTAGE_CTRL): {
333 u8 obuf[2];
334 obuf[0] = 0x30;
335 obuf[1] = msg[0].buf[0];
336 ret = dw210x_op_rw(d->udev, 0xb2, 0, 0,
337 obuf, 2, DW210X_WRITE_MSG);
338 break;
339 }
340 }
341
342 break;
343 }
344
345 mutex_unlock(&d->i2c_mutex);
346 return num;
347}
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300348
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300349static int dw2104_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], int num)
350{
351 struct dvb_usb_device *d = i2c_get_adapdata(adap);
352 int ret = 0;
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300353 int len, i, j;
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300354
355 if (!d)
356 return -ENODEV;
357 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
358 return -EAGAIN;
359
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300360 for (j = 0; j < num; j++) {
361 switch (msg[j].addr) {
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300362 case(DW2102_RC_QUERY): {
363 u8 ibuf[2];
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300364 ret = dw210x_op_rw(d->udev, 0xb8, 0, 0,
365 ibuf, 2, DW210X_READ_MSG);
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300366 memcpy(msg[j].buf, ibuf , 2);
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300367 break;
368 }
369 case(DW2102_VOLTAGE_CTRL): {
370 u8 obuf[2];
371 obuf[0] = 0x30;
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300372 obuf[1] = msg[j].buf[0];
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300373 ret = dw210x_op_rw(d->udev, 0xb2, 0, 0,
374 obuf, 2, DW210X_WRITE_MSG);
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300375 break;
376 }
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300377 /*case 0x55: cx24116
378 case 0x6a: stv0903
379 case 0x68: ds3000, stv0903
380 case 0x60: ts2020, stv6110, stb6100 */
381 default: {
382 if (msg[j].flags == I2C_M_RD) {
383 /* read registers */
384 u8 ibuf[msg[j].len + 2];
385 ret = dw210x_op_rw(d->udev, 0xc3,
386 (msg[j].addr << 1) + 1, 0,
387 ibuf, msg[j].len + 2,
388 DW210X_READ_MSG);
389 memcpy(msg[j].buf, ibuf + 2, msg[j].len);
390 mdelay(10);
391 } else if (((msg[j].buf[0] == 0xb0) &&
392 (msg[j].addr == 0x68)) ||
393 ((msg[j].buf[0] == 0xf7) &&
394 (msg[j].addr == 0x55))) {
395 /* write firmware */
396 u8 obuf[19];
397 obuf[0] = msg[j].addr << 1;
398 obuf[1] = (msg[j].len > 15 ? 17 : msg[j].len);
399 obuf[2] = msg[j].buf[0];
400 len = msg[j].len - 1;
401 i = 1;
402 do {
403 memcpy(obuf + 3, msg[j].buf + i,
404 (len > 16 ? 16 : len));
405 ret = dw210x_op_rw(d->udev, 0xc2, 0, 0,
406 obuf, (len > 16 ? 16 : len) + 3,
407 DW210X_WRITE_MSG);
408 i += 16;
409 len -= 16;
410 } while (len > 0);
411 } else {
412 /* write registers */
413 u8 obuf[msg[j].len + 2];
414 obuf[0] = msg[j].addr << 1;
415 obuf[1] = msg[j].len;
416 memcpy(obuf + 2, msg[j].buf, msg[j].len);
417 ret = dw210x_op_rw(d->udev, 0xc2, 0, 0,
418 obuf, msg[j].len + 2,
419 DW210X_WRITE_MSG);
420 }
421 break;
422 }
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300423 }
424
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300425 }
426
427 mutex_unlock(&d->i2c_mutex);
428 return num;
429}
430
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -0300431static int dw3101_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
432 int num)
433{
434 struct dvb_usb_device *d = i2c_get_adapdata(adap);
435 int ret = 0, i;
436
437 if (!d)
438 return -ENODEV;
439 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
440 return -EAGAIN;
441
442 switch (num) {
443 case 2: {
444 /* read */
445 /* first write first register number */
446 u8 ibuf[msg[1].len + 2], obuf[3];
447 obuf[0] = msg[0].addr << 1;
448 obuf[1] = msg[0].len;
449 obuf[2] = msg[0].buf[0];
450 ret = dw210x_op_rw(d->udev, 0xc2, 0, 0,
451 obuf, msg[0].len + 2, DW210X_WRITE_MSG);
452 /* second read registers */
453 ret = dw210x_op_rw(d->udev, 0xc3, 0x19 , 0,
454 ibuf, msg[1].len + 2, DW210X_READ_MSG);
455 memcpy(msg[1].buf, ibuf + 2, msg[1].len);
456
457 break;
458 }
459 case 1:
460 switch (msg[0].addr) {
461 case 0x60:
462 case 0x0c: {
463 /* write to register */
464 u8 obuf[msg[0].len + 2];
465 obuf[0] = msg[0].addr << 1;
466 obuf[1] = msg[0].len;
467 memcpy(obuf + 2, msg[0].buf, msg[0].len);
468 ret = dw210x_op_rw(d->udev, 0xc2, 0, 0,
469 obuf, msg[0].len + 2, DW210X_WRITE_MSG);
470 break;
471 }
472 case(DW2102_RC_QUERY): {
473 u8 ibuf[2];
474 ret = dw210x_op_rw(d->udev, 0xb8, 0, 0,
475 ibuf, 2, DW210X_READ_MSG);
476 memcpy(msg[0].buf, ibuf , 2);
477 break;
478 }
479 }
480
481 break;
482 }
483
484 for (i = 0; i < num; i++) {
485 deb_xfer("%02x:%02x: %s ", i, msg[i].addr,
486 msg[i].flags == 0 ? ">>>" : "<<<");
487 debug_dump(msg[i].buf, msg[i].len, deb_xfer);
488 }
489
490 mutex_unlock(&d->i2c_mutex);
491 return num;
492}
493
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300494static int s6x0_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300495 int num)
496{
497 struct dvb_usb_device *d = i2c_get_adapdata(adap);
Julia Lawall21ead032009-12-22 18:00:07 -0300498 struct usb_device *udev;
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300499 int ret = 0;
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300500 int len, i, j;
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300501
502 if (!d)
503 return -ENODEV;
Julia Lawall21ead032009-12-22 18:00:07 -0300504 udev = d->udev;
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300505 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
506 return -EAGAIN;
507
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300508 for (j = 0; j < num; j++) {
509 switch (msg[j].addr) {
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300510 case (DW2102_RC_QUERY): {
Igor M. Liplianin5a530cb2011-02-25 18:41:23 -0300511 u8 ibuf[5];
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300512 ret = dw210x_op_rw(d->udev, 0xb8, 0, 0,
Igor M. Liplianin5a530cb2011-02-25 18:41:23 -0300513 ibuf, 5, DW210X_READ_MSG);
514 memcpy(msg[j].buf, ibuf + 3, 2);
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300515 break;
516 }
517 case (DW2102_VOLTAGE_CTRL): {
518 u8 obuf[2];
Igor M. Liplianincd79d332009-12-14 20:24:56 -0300519
520 obuf[0] = 1;
521 obuf[1] = msg[j].buf[1];/* off-on */
522 ret = dw210x_op_rw(d->udev, 0x8a, 0, 0,
523 obuf, 2, DW210X_WRITE_MSG);
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300524 obuf[0] = 3;
Igor M. Liplianincd79d332009-12-14 20:24:56 -0300525 obuf[1] = msg[j].buf[0];/* 13v-18v */
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300526 ret = dw210x_op_rw(d->udev, 0x8a, 0, 0,
527 obuf, 2, DW210X_WRITE_MSG);
528 break;
529 }
Igor M. Liplianinfa8bae12011-02-25 18:41:22 -0300530 case (DW2102_LED_CTRL): {
531 u8 obuf[2];
532
533 obuf[0] = 5;
534 obuf[1] = msg[j].buf[0];
535 ret = dw210x_op_rw(d->udev, 0x8a, 0, 0,
536 obuf, 2, DW210X_WRITE_MSG);
537 break;
538 }
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300539 /*case 0x55: cx24116
540 case 0x6a: stv0903
541 case 0x68: ds3000, stv0903
542 case 0x60: ts2020, stv6110, stb6100
543 case 0xa0: eeprom */
544 default: {
545 if (msg[j].flags == I2C_M_RD) {
546 /* read registers */
547 u8 ibuf[msg[j].len];
548 ret = dw210x_op_rw(d->udev, 0x91, 0, 0,
549 ibuf, msg[j].len,
550 DW210X_READ_MSG);
551 memcpy(msg[j].buf, ibuf, msg[j].len);
552 break;
553 } else if ((msg[j].buf[0] == 0xb0) &&
554 (msg[j].addr == 0x68)) {
555 /* write firmware */
556 u8 obuf[19];
557 obuf[0] = (msg[j].len > 16 ?
558 18 : msg[j].len + 1);
559 obuf[1] = msg[j].addr << 1;
560 obuf[2] = msg[j].buf[0];
561 len = msg[j].len - 1;
562 i = 1;
563 do {
564 memcpy(obuf + 3, msg[j].buf + i,
565 (len > 16 ? 16 : len));
566 ret = dw210x_op_rw(d->udev, 0x80, 0, 0,
567 obuf, (len > 16 ? 16 : len) + 3,
568 DW210X_WRITE_MSG);
569 i += 16;
570 len -= 16;
571 } while (len > 0);
Igor M. Liplianina84adf42011-02-27 16:18:38 -0300572 } else if (j < (num - 1)) {
Igor M. Liplianincd79d332009-12-14 20:24:56 -0300573 /* write register addr before read */
574 u8 obuf[msg[j].len + 2];
575 obuf[0] = msg[j + 1].len;
576 obuf[1] = (msg[j].addr << 1);
577 memcpy(obuf + 2, msg[j].buf, msg[j].len);
Igor M. Liplianina84adf42011-02-27 16:18:38 -0300578 ret = dw210x_op_rw(d->udev,
579 udev->descriptor.idProduct ==
580 0x7500 ? 0x92 : 0x90, 0, 0,
Igor M. Liplianincd79d332009-12-14 20:24:56 -0300581 obuf, msg[j].len + 2,
582 DW210X_WRITE_MSG);
583 break;
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300584 } else {
585 /* write registers */
586 u8 obuf[msg[j].len + 2];
587 obuf[0] = msg[j].len + 1;
588 obuf[1] = (msg[j].addr << 1);
589 memcpy(obuf + 2, msg[j].buf, msg[j].len);
Igor M. Liplianina84adf42011-02-27 16:18:38 -0300590 ret = dw210x_op_rw(d->udev, 0x80, 0, 0,
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300591 obuf, msg[j].len + 2,
592 DW210X_WRITE_MSG);
593 break;
594 }
595 break;
596 }
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300597 }
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300598 }
599
600 mutex_unlock(&d->i2c_mutex);
601 return num;
602}
603
Igor M. Liplianind2ffc442011-02-25 18:41:22 -0300604static int su3000_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
605 int num)
606{
607 struct dvb_usb_device *d = i2c_get_adapdata(adap);
608 u8 obuf[0x40], ibuf[0x40];
609
610 if (!d)
611 return -ENODEV;
612 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
613 return -EAGAIN;
614
615 switch (num) {
616 case 1:
617 switch (msg[0].addr) {
618 case SU3000_STREAM_CTRL:
619 obuf[0] = msg[0].buf[0] + 0x36;
620 obuf[1] = 3;
621 obuf[2] = 0;
622 if (dvb_usb_generic_rw(d, obuf, 3, ibuf, 0, 0) < 0)
623 err("i2c transfer failed.");
624 break;
625 case DW2102_RC_QUERY:
626 obuf[0] = 0x10;
627 if (dvb_usb_generic_rw(d, obuf, 1, ibuf, 2, 0) < 0)
628 err("i2c transfer failed.");
629 msg[0].buf[1] = ibuf[0];
630 msg[0].buf[0] = ibuf[1];
631 break;
632 default:
633 /* always i2c write*/
634 obuf[0] = 0x08;
635 obuf[1] = msg[0].addr;
636 obuf[2] = msg[0].len;
637
638 memcpy(&obuf[3], msg[0].buf, msg[0].len);
639
640 if (dvb_usb_generic_rw(d, obuf, msg[0].len + 3,
641 ibuf, 1, 0) < 0)
642 err("i2c transfer failed.");
643
644 }
645 break;
646 case 2:
647 /* always i2c read */
648 obuf[0] = 0x09;
649 obuf[1] = msg[0].len;
650 obuf[2] = msg[1].len;
651 obuf[3] = msg[0].addr;
652 memcpy(&obuf[4], msg[0].buf, msg[0].len);
653
654 if (dvb_usb_generic_rw(d, obuf, msg[0].len + 4,
655 ibuf, msg[1].len + 1, 0) < 0)
656 err("i2c transfer failed.");
657
658 memcpy(msg[1].buf, &ibuf[1], msg[1].len);
659 break;
660 default:
661 warn("more than 2 i2c messages at a time is not handled yet.");
662 break;
663 }
664 mutex_unlock(&d->i2c_mutex);
665 return num;
666}
667
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300668static u32 dw210x_i2c_func(struct i2c_adapter *adapter)
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300669{
670 return I2C_FUNC_I2C;
671}
672
673static struct i2c_algorithm dw2102_i2c_algo = {
674 .master_xfer = dw2102_i2c_transfer,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300675 .functionality = dw210x_i2c_func,
676};
677
678static struct i2c_algorithm dw2102_serit_i2c_algo = {
679 .master_xfer = dw2102_serit_i2c_transfer,
680 .functionality = dw210x_i2c_func,
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300681};
682
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -0300683static struct i2c_algorithm dw2102_earda_i2c_algo = {
684 .master_xfer = dw2102_earda_i2c_transfer,
685 .functionality = dw210x_i2c_func,
686};
687
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300688static struct i2c_algorithm dw2104_i2c_algo = {
689 .master_xfer = dw2104_i2c_transfer,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300690 .functionality = dw210x_i2c_func,
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300691};
692
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -0300693static struct i2c_algorithm dw3101_i2c_algo = {
694 .master_xfer = dw3101_i2c_transfer,
695 .functionality = dw210x_i2c_func,
696};
697
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300698static struct i2c_algorithm s6x0_i2c_algo = {
699 .master_xfer = s6x0_i2c_transfer,
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300700 .functionality = dw210x_i2c_func,
701};
702
Igor M. Liplianind2ffc442011-02-25 18:41:22 -0300703static struct i2c_algorithm su3000_i2c_algo = {
704 .master_xfer = su3000_i2c_transfer,
705 .functionality = dw210x_i2c_func,
706};
707
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300708static int dw210x_read_mac_address(struct dvb_usb_device *d, u8 mac[6])
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300709{
710 int i;
711 u8 ibuf[] = {0, 0};
712 u8 eeprom[256], eepromline[16];
713
714 for (i = 0; i < 256; i++) {
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300715 if (dw210x_op_rw(d->udev, 0xb6, 0xa0 , i, ibuf, 2, DW210X_READ_MSG) < 0) {
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300716 err("read eeprom failed.");
717 return -1;
718 } else {
719 eepromline[i%16] = ibuf[0];
720 eeprom[i] = ibuf[0];
721 }
722 if ((i % 16) == 15) {
723 deb_xfer("%02x: ", i - 15);
724 debug_dump(eepromline, 16, deb_xfer);
725 }
726 }
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -0300727
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300728 memcpy(mac, eeprom + 8, 6);
729 return 0;
730};
731
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300732static int s6x0_read_mac_address(struct dvb_usb_device *d, u8 mac[6])
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300733{
734 int i, ret;
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300735 u8 ibuf[] = { 0 }, obuf[] = { 0 };
736 u8 eeprom[256], eepromline[16];
737 struct i2c_msg msg[] = {
738 {
739 .addr = 0xa0 >> 1,
740 .flags = 0,
741 .buf = obuf,
742 .len = 1,
743 }, {
744 .addr = 0xa0 >> 1,
745 .flags = I2C_M_RD,
746 .buf = ibuf,
747 .len = 1,
748 }
749 };
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300750
751 for (i = 0; i < 256; i++) {
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300752 obuf[0] = i;
753 ret = s6x0_i2c_transfer(&d->i2c_adap, msg, 2);
754 if (ret != 2) {
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300755 err("read eeprom failed.");
756 return -1;
757 } else {
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300758 eepromline[i % 16] = ibuf[0];
759 eeprom[i] = ibuf[0];
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300760 }
761
762 if ((i % 16) == 15) {
763 deb_xfer("%02x: ", i - 15);
764 debug_dump(eepromline, 16, deb_xfer);
765 }
766 }
767
768 memcpy(mac, eeprom + 16, 6);
769 return 0;
770};
771
Igor M. Liplianind2ffc442011-02-25 18:41:22 -0300772static int su3000_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
773{
774 static u8 command_start[] = {0x00};
775 static u8 command_stop[] = {0x01};
776 struct i2c_msg msg = {
777 .addr = SU3000_STREAM_CTRL,
778 .flags = 0,
779 .buf = onoff ? command_start : command_stop,
780 .len = 1
781 };
782
783 i2c_transfer(&adap->dev->i2c_adap, &msg, 1);
784
785 return 0;
786}
787
788static int su3000_power_ctrl(struct dvb_usb_device *d, int i)
789{
790 struct su3000_state *state = (struct su3000_state *)d->priv;
791 u8 obuf[] = {0xde, 0};
792
793 info("%s: %d, initialized %d\n", __func__, i, state->initialized);
794
795 if (i && !state->initialized) {
796 state->initialized = 1;
797 /* reset board */
798 dvb_usb_generic_rw(d, obuf, 2, NULL, 0, 0);
799 }
800
801 return 0;
802}
803
804static int su3000_read_mac_address(struct dvb_usb_device *d, u8 mac[6])
805{
806 int i;
807 u8 obuf[] = { 0x1f, 0xf0 };
808 u8 ibuf[] = { 0 };
809 struct i2c_msg msg[] = {
810 {
811 .addr = 0x51,
812 .flags = 0,
813 .buf = obuf,
814 .len = 2,
815 }, {
816 .addr = 0x51,
817 .flags = I2C_M_RD,
818 .buf = ibuf,
819 .len = 1,
820
821 }
822 };
823
824 for (i = 0; i < 6; i++) {
825 obuf[1] = 0xf0 + i;
826 if (i2c_transfer(&d->i2c_adap, msg, 2) != 2)
827 break;
828 else
829 mac[i] = ibuf[0];
830
831 debug_dump(mac, 6, printk);
832 }
833
834 return 0;
835}
836
837static int su3000_identify_state(struct usb_device *udev,
838 struct dvb_usb_device_properties *props,
839 struct dvb_usb_device_description **desc,
840 int *cold)
841{
842 info("%s\n", __func__);
843
844 *cold = 0;
845 return 0;
846}
847
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300848static int dw210x_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300849{
Igor M. Liplianincd79d332009-12-14 20:24:56 -0300850 static u8 command_13v[] = {0x00, 0x01};
851 static u8 command_18v[] = {0x01, 0x01};
852 static u8 command_off[] = {0x00, 0x00};
853 struct i2c_msg msg = {
854 .addr = DW2102_VOLTAGE_CTRL,
855 .flags = 0,
856 .buf = command_off,
857 .len = 2,
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300858 };
859
860 struct dvb_usb_adapter *udev_adap =
861 (struct dvb_usb_adapter *)(fe->dvb->priv);
862 if (voltage == SEC_VOLTAGE_18)
Igor M. Liplianincd79d332009-12-14 20:24:56 -0300863 msg.buf = command_18v;
864 else if (voltage == SEC_VOLTAGE_13)
865 msg.buf = command_13v;
866
867 i2c_transfer(&udev_adap->dev->i2c_adap, &msg, 1);
868
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300869 return 0;
870}
871
Igor M. Liplianin52c506e2011-02-25 18:41:23 -0300872static int s660_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
873{
874 struct dvb_usb_adapter *d =
875 (struct dvb_usb_adapter *)(fe->dvb->priv);
876 struct s6x0_state *st = (struct s6x0_state *)d->dev->priv;
877
878 dw210x_set_voltage(fe, voltage);
879 if (st->old_set_voltage)
880 st->old_set_voltage(fe, voltage);
881
882 return 0;
883}
884
Igor M. Liplianinfa8bae12011-02-25 18:41:22 -0300885static void dw210x_led_ctrl(struct dvb_frontend *fe, int offon)
886{
887 static u8 led_off[] = { 0 };
888 static u8 led_on[] = { 1 };
889 struct i2c_msg msg = {
890 .addr = DW2102_LED_CTRL,
891 .flags = 0,
892 .buf = led_off,
893 .len = 1
894 };
895 struct dvb_usb_adapter *udev_adap =
896 (struct dvb_usb_adapter *)(fe->dvb->priv);
897
898 if (offon)
899 msg.buf = led_on;
900 i2c_transfer(&udev_adap->dev->i2c_adap, &msg, 1);
901}
902
Igor M. Liplianind4305c62008-10-17 13:45:55 -0300903static struct stv0299_config sharp_z0194a_config = {
904 .demod_address = 0x68,
905 .inittab = sharp_z0194a_inittab,
906 .mclk = 88000000UL,
907 .invert = 1,
908 .skip_reinit = 0,
909 .lock_output = STV0299_LOCKOUTPUT_1,
910 .volt13_op0_op1 = STV0299_VOLT13_OP1,
911 .min_delay_ms = 100,
912 .set_symbol_rate = sharp_z0194a_set_symbol_rate,
913};
914
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300915static struct cx24116_config dw2104_config = {
916 .demod_address = 0x55,
Igor M. Liplianincc8c4f32008-09-09 13:57:47 -0300917 .mpg_clk_pos_pol = 0x01,
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300918};
919
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300920static struct si21xx_config serit_sp1511lhb_config = {
921 .demod_address = 0x68,
922 .min_delay_ms = 100,
923
924};
925
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -0300926static struct tda10023_config dw3101_tda10023_config = {
927 .demod_address = 0x0c,
928 .invert = 1,
929};
930
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300931static struct mt312_config zl313_config = {
932 .demod_address = 0x0e,
933};
934
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300935static struct ds3000_config dw2104_ds3000_config = {
936 .demod_address = 0x68,
937};
938
939static struct stv0900_config dw2104a_stv0900_config = {
940 .demod_address = 0x6a,
941 .demod_mode = 0,
942 .xtal = 27000000,
943 .clkmode = 3,/* 0-CLKI, 2-XTALI, else AUTO */
944 .diseqc_mode = 2,/* 2/3 PWM */
945 .tun1_maddress = 0,/* 0x60 */
946 .tun1_adc = 0,/* 2 Vpp */
947 .path1_mode = 3,
948};
949
950static struct stb6100_config dw2104a_stb6100_config = {
951 .tuner_address = 0x60,
952 .refclock = 27000000,
953};
954
955static struct stv0900_config dw2104_stv0900_config = {
956 .demod_address = 0x68,
957 .demod_mode = 0,
958 .xtal = 8000000,
959 .clkmode = 3,
960 .diseqc_mode = 2,
961 .tun1_maddress = 0,
962 .tun1_adc = 1,/* 1 Vpp */
963 .path1_mode = 3,
964};
965
966static struct stv6110_config dw2104_stv6110_config = {
967 .i2c_address = 0x60,
968 .mclk = 16000000,
969 .clk_div = 1,
970};
971
Igor M. Liplianincd79d332009-12-14 20:24:56 -0300972static struct stv0900_config prof_7500_stv0900_config = {
973 .demod_address = 0x6a,
974 .demod_mode = 0,
975 .xtal = 27000000,
976 .clkmode = 3,/* 0-CLKI, 2-XTALI, else AUTO */
977 .diseqc_mode = 2,/* 2/3 PWM */
978 .tun1_maddress = 0,/* 0x60 */
979 .tun1_adc = 0,/* 2 Vpp */
980 .path1_mode = 3,
981 .tun1_type = 3,
Igor M. Liplianinfa8bae12011-02-25 18:41:22 -0300982 .set_lock_led = dw210x_led_ctrl,
Igor M. Liplianincd79d332009-12-14 20:24:56 -0300983};
984
Igor M. Liplianind2ffc442011-02-25 18:41:22 -0300985static struct ds3000_config su3000_ds3000_config = {
986 .demod_address = 0x68,
987 .ci_mode = 1,
988};
989
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300990static int dw2104_frontend_attach(struct dvb_usb_adapter *d)
991{
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300992 struct dvb_tuner_ops *tuner_ops = NULL;
993
994 if (demod_probe & 4) {
Michael Krufky77eed212011-09-06 09:31:57 -0300995 d->fe_adap[0].fe = dvb_attach(stv0900_attach, &dw2104a_stv0900_config,
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300996 &d->dev->i2c_adap, 0);
Michael Krufky77eed212011-09-06 09:31:57 -0300997 if (d->fe_adap[0].fe != NULL) {
998 if (dvb_attach(stb6100_attach, d->fe_adap[0].fe,
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300999 &dw2104a_stb6100_config,
1000 &d->dev->i2c_adap)) {
Michael Krufky77eed212011-09-06 09:31:57 -03001001 tuner_ops = &d->fe_adap[0].fe->ops.tuner_ops;
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001002 tuner_ops->set_frequency = stb6100_set_freq;
1003 tuner_ops->get_frequency = stb6100_get_freq;
1004 tuner_ops->set_bandwidth = stb6100_set_bandw;
1005 tuner_ops->get_bandwidth = stb6100_get_bandw;
Michael Krufky77eed212011-09-06 09:31:57 -03001006 d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001007 info("Attached STV0900+STB6100!\n");
1008 return 0;
1009 }
1010 }
1011 }
1012
1013 if (demod_probe & 2) {
Michael Krufky77eed212011-09-06 09:31:57 -03001014 d->fe_adap[0].fe = dvb_attach(stv0900_attach, &dw2104_stv0900_config,
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001015 &d->dev->i2c_adap, 0);
Michael Krufky77eed212011-09-06 09:31:57 -03001016 if (d->fe_adap[0].fe != NULL) {
1017 if (dvb_attach(stv6110_attach, d->fe_adap[0].fe,
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001018 &dw2104_stv6110_config,
1019 &d->dev->i2c_adap)) {
Michael Krufky77eed212011-09-06 09:31:57 -03001020 d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001021 info("Attached STV0900+STV6110A!\n");
1022 return 0;
1023 }
1024 }
1025 }
1026
1027 if (demod_probe & 1) {
Michael Krufky77eed212011-09-06 09:31:57 -03001028 d->fe_adap[0].fe = dvb_attach(cx24116_attach, &dw2104_config,
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001029 &d->dev->i2c_adap);
Michael Krufky77eed212011-09-06 09:31:57 -03001030 if (d->fe_adap[0].fe != NULL) {
1031 d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001032 info("Attached cx24116!\n");
1033 return 0;
1034 }
1035 }
1036
Michael Krufky77eed212011-09-06 09:31:57 -03001037 d->fe_adap[0].fe = dvb_attach(ds3000_attach, &dw2104_ds3000_config,
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001038 &d->dev->i2c_adap);
Michael Krufky77eed212011-09-06 09:31:57 -03001039 if (d->fe_adap[0].fe != NULL) {
1040 d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001041 info("Attached DS3000!\n");
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001042 return 0;
1043 }
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001044
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001045 return -EIO;
1046}
1047
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001048static struct dvb_usb_device_properties dw2102_properties;
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -03001049static struct dvb_usb_device_properties dw2104_properties;
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001050static struct dvb_usb_device_properties s6x0_properties;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001051
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001052static int dw2102_frontend_attach(struct dvb_usb_adapter *d)
1053{
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001054 if (dw2102_properties.i2c_algo == &dw2102_serit_i2c_algo) {
1055 /*dw2102_properties.adapter->tuner_attach = NULL;*/
Michael Krufky77eed212011-09-06 09:31:57 -03001056 d->fe_adap[0].fe = dvb_attach(si21xx_attach, &serit_sp1511lhb_config,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001057 &d->dev->i2c_adap);
Michael Krufky77eed212011-09-06 09:31:57 -03001058 if (d->fe_adap[0].fe != NULL) {
1059 d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001060 info("Attached si21xx!\n");
1061 return 0;
1062 }
1063 }
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001064
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -03001065 if (dw2102_properties.i2c_algo == &dw2102_earda_i2c_algo) {
Michael Krufky77eed212011-09-06 09:31:57 -03001066 d->fe_adap[0].fe = dvb_attach(stv0288_attach, &earda_config,
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -03001067 &d->dev->i2c_adap);
Michael Krufky77eed212011-09-06 09:31:57 -03001068 if (d->fe_adap[0].fe != NULL) {
1069 if (dvb_attach(stb6000_attach, d->fe_adap[0].fe, 0x61,
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001070 &d->dev->i2c_adap)) {
Michael Krufky77eed212011-09-06 09:31:57 -03001071 d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001072 info("Attached stv0288!\n");
1073 return 0;
1074 }
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -03001075 }
1076 }
1077
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001078 if (dw2102_properties.i2c_algo == &dw2102_i2c_algo) {
1079 /*dw2102_properties.adapter->tuner_attach = dw2102_tuner_attach;*/
Michael Krufky77eed212011-09-06 09:31:57 -03001080 d->fe_adap[0].fe = dvb_attach(stv0299_attach, &sharp_z0194a_config,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001081 &d->dev->i2c_adap);
Michael Krufky77eed212011-09-06 09:31:57 -03001082 if (d->fe_adap[0].fe != NULL) {
1083 d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001084 info("Attached stv0299!\n");
1085 return 0;
1086 }
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001087 }
1088 return -EIO;
1089}
1090
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001091static int dw3101_frontend_attach(struct dvb_usb_adapter *d)
1092{
Michael Krufky77eed212011-09-06 09:31:57 -03001093 d->fe_adap[0].fe = dvb_attach(tda10023_attach, &dw3101_tda10023_config,
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001094 &d->dev->i2c_adap, 0x48);
Michael Krufky77eed212011-09-06 09:31:57 -03001095 if (d->fe_adap[0].fe != NULL) {
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001096 info("Attached tda10023!\n");
1097 return 0;
1098 }
1099 return -EIO;
1100}
1101
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001102static int zl100313_frontend_attach(struct dvb_usb_adapter *d)
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001103{
Michael Krufky77eed212011-09-06 09:31:57 -03001104 d->fe_adap[0].fe = dvb_attach(mt312_attach, &zl313_config,
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001105 &d->dev->i2c_adap);
Michael Krufky77eed212011-09-06 09:31:57 -03001106 if (d->fe_adap[0].fe != NULL) {
1107 if (dvb_attach(zl10039_attach, d->fe_adap[0].fe, 0x60,
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001108 &d->dev->i2c_adap)) {
Michael Krufky77eed212011-09-06 09:31:57 -03001109 d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001110 info("Attached zl100313+zl10039!\n");
1111 return 0;
1112 }
1113 }
1114
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001115 return -EIO;
1116}
1117
1118static int stv0288_frontend_attach(struct dvb_usb_adapter *d)
1119{
Igor M. Liplianinfd5466d2011-02-27 16:22:52 -03001120 u8 obuf[] = {7, 1};
1121
Michael Krufky77eed212011-09-06 09:31:57 -03001122 d->fe_adap[0].fe = dvb_attach(stv0288_attach, &earda_config,
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001123 &d->dev->i2c_adap);
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001124
Michael Krufky77eed212011-09-06 09:31:57 -03001125 if (d->fe_adap[0].fe == NULL)
Igor M. Liplianinfd5466d2011-02-27 16:22:52 -03001126 return -EIO;
1127
Michael Krufky77eed212011-09-06 09:31:57 -03001128 if (NULL == dvb_attach(stb6000_attach, d->fe_adap[0].fe, 0x61, &d->dev->i2c_adap))
Igor M. Liplianinfd5466d2011-02-27 16:22:52 -03001129 return -EIO;
1130
Michael Krufky77eed212011-09-06 09:31:57 -03001131 d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
Igor M. Liplianinfd5466d2011-02-27 16:22:52 -03001132
1133 dw210x_op_rw(d->dev->udev, 0x8a, 0, 0, obuf, 2, DW210X_WRITE_MSG);
1134
1135 info("Attached stv0288+stb6000!\n");
1136
1137 return 0;
1138
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001139}
1140
1141static int ds3000_frontend_attach(struct dvb_usb_adapter *d)
1142{
Igor M. Liplianin52c506e2011-02-25 18:41:23 -03001143 struct s6x0_state *st = (struct s6x0_state *)d->dev->priv;
Igor M. Liplianin5a530cb2011-02-25 18:41:23 -03001144 u8 obuf[] = {7, 1};
Igor M. Liplianin52c506e2011-02-25 18:41:23 -03001145
Michael Krufky77eed212011-09-06 09:31:57 -03001146 d->fe_adap[0].fe = dvb_attach(ds3000_attach, &dw2104_ds3000_config,
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001147 &d->dev->i2c_adap);
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001148
Michael Krufky77eed212011-09-06 09:31:57 -03001149 if (d->fe_adap[0].fe == NULL)
Igor M. Liplianin52c506e2011-02-25 18:41:23 -03001150 return -EIO;
1151
Michael Krufky77eed212011-09-06 09:31:57 -03001152 st->old_set_voltage = d->fe_adap[0].fe->ops.set_voltage;
1153 d->fe_adap[0].fe->ops.set_voltage = s660_set_voltage;
Igor M. Liplianin5a530cb2011-02-25 18:41:23 -03001154
1155 dw210x_op_rw(d->dev->udev, 0x8a, 0, 0, obuf, 2, DW210X_WRITE_MSG);
1156
Igor M. Liplianin52c506e2011-02-25 18:41:23 -03001157 info("Attached ds3000+ds2020!\n");
1158
1159 return 0;
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001160}
1161
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001162static int prof_7500_frontend_attach(struct dvb_usb_adapter *d)
1163{
Igor M. Liplianin4e59df82011-02-25 18:41:23 -03001164 u8 obuf[] = {7, 1};
1165
Michael Krufky77eed212011-09-06 09:31:57 -03001166 d->fe_adap[0].fe = dvb_attach(stv0900_attach, &prof_7500_stv0900_config,
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001167 &d->dev->i2c_adap, 0);
Michael Krufky77eed212011-09-06 09:31:57 -03001168 if (d->fe_adap[0].fe == NULL)
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001169 return -EIO;
Igor M. Liplianin4e59df82011-02-25 18:41:23 -03001170
Michael Krufky77eed212011-09-06 09:31:57 -03001171 d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001172
Igor M. Liplianin4e59df82011-02-25 18:41:23 -03001173 dw210x_op_rw(d->dev->udev, 0x8a, 0, 0, obuf, 2, DW210X_WRITE_MSG);
1174
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001175 info("Attached STV0900+STB6100A!\n");
1176
1177 return 0;
1178}
1179
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001180static int su3000_frontend_attach(struct dvb_usb_adapter *d)
1181{
1182 u8 obuf[3] = { 0xe, 0x80, 0 };
1183 u8 ibuf[] = { 0 };
1184
1185 if (dvb_usb_generic_rw(d->dev, obuf, 3, ibuf, 1, 0) < 0)
1186 err("command 0x0e transfer failed.");
1187
1188 obuf[0] = 0xe;
1189 obuf[1] = 0x83;
1190 obuf[2] = 0;
1191
1192 if (dvb_usb_generic_rw(d->dev, obuf, 3, ibuf, 1, 0) < 0)
1193 err("command 0x0e transfer failed.");
1194
1195 obuf[0] = 0xe;
1196 obuf[1] = 0x83;
1197 obuf[2] = 1;
1198
1199 if (dvb_usb_generic_rw(d->dev, obuf, 3, ibuf, 1, 0) < 0)
1200 err("command 0x0e transfer failed.");
1201
1202 obuf[0] = 0x51;
1203
1204 if (dvb_usb_generic_rw(d->dev, obuf, 1, ibuf, 1, 0) < 0)
1205 err("command 0x51 transfer failed.");
1206
Michael Krufky77eed212011-09-06 09:31:57 -03001207 d->fe_adap[0].fe = dvb_attach(ds3000_attach, &su3000_ds3000_config,
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001208 &d->dev->i2c_adap);
Michael Krufky77eed212011-09-06 09:31:57 -03001209 if (d->fe_adap[0].fe == NULL)
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001210 return -EIO;
1211
1212 info("Attached DS3000!\n");
1213
1214 return 0;
1215}
1216
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001217static int dw2102_tuner_attach(struct dvb_usb_adapter *adap)
1218{
Michael Krufky77eed212011-09-06 09:31:57 -03001219 dvb_attach(dvb_pll_attach, adap->fe_adap[0].fe, 0x60,
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001220 &adap->dev->i2c_adap, DVB_PLL_OPERA1);
1221 return 0;
1222}
1223
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001224static int dw3101_tuner_attach(struct dvb_usb_adapter *adap)
1225{
Michael Krufky77eed212011-09-06 09:31:57 -03001226 dvb_attach(dvb_pll_attach, adap->fe_adap[0].fe, 0x60,
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001227 &adap->dev->i2c_adap, DVB_PLL_TUA6034);
1228
1229 return 0;
1230}
1231
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03001232static struct rc_map_table rc_map_dw210x_table[] = {
Mauro Carvalho Chehab991bd3c2011-01-24 12:18:40 -03001233 { 0xf80a, KEY_POWER2 }, /*power*/
1234 { 0xf80c, KEY_MUTE }, /*mute*/
Mauro Carvalho Chehab2e365882009-08-29 15:19:31 -03001235 { 0xf811, KEY_1 },
1236 { 0xf812, KEY_2 },
1237 { 0xf813, KEY_3 },
1238 { 0xf814, KEY_4 },
1239 { 0xf815, KEY_5 },
1240 { 0xf816, KEY_6 },
1241 { 0xf817, KEY_7 },
1242 { 0xf818, KEY_8 },
1243 { 0xf819, KEY_9 },
1244 { 0xf810, KEY_0 },
Mauro Carvalho Chehab991bd3c2011-01-24 12:18:40 -03001245 { 0xf81c, KEY_CHANNELUP }, /*ch+*/
1246 { 0xf80f, KEY_CHANNELDOWN }, /*ch-*/
1247 { 0xf81a, KEY_VOLUMEUP }, /*vol+*/
1248 { 0xf80e, KEY_VOLUMEDOWN }, /*vol-*/
1249 { 0xf804, KEY_RECORD }, /*rec*/
1250 { 0xf809, KEY_FAVORITES }, /*fav*/
1251 { 0xf808, KEY_REWIND }, /*rewind*/
1252 { 0xf807, KEY_FASTFORWARD }, /*fast*/
1253 { 0xf80b, KEY_PAUSE }, /*pause*/
1254 { 0xf802, KEY_ESC }, /*cancel*/
1255 { 0xf803, KEY_TAB }, /*tab*/
Mauro Carvalho Chehab2e365882009-08-29 15:19:31 -03001256 { 0xf800, KEY_UP }, /*up*/
Mauro Carvalho Chehab991bd3c2011-01-24 12:18:40 -03001257 { 0xf81f, KEY_OK }, /*ok*/
1258 { 0xf801, KEY_DOWN }, /*down*/
1259 { 0xf805, KEY_CAMERA }, /*cap*/
1260 { 0xf806, KEY_STOP }, /*stop*/
1261 { 0xf840, KEY_ZOOM }, /*full*/
1262 { 0xf81e, KEY_TV }, /*tvmode*/
1263 { 0xf81b, KEY_LAST }, /*recall*/
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001264};
1265
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03001266static struct rc_map_table rc_map_tevii_table[] = {
Mauro Carvalho Chehab2e365882009-08-29 15:19:31 -03001267 { 0xf80a, KEY_POWER },
1268 { 0xf80c, KEY_MUTE },
1269 { 0xf811, KEY_1 },
1270 { 0xf812, KEY_2 },
1271 { 0xf813, KEY_3 },
1272 { 0xf814, KEY_4 },
1273 { 0xf815, KEY_5 },
1274 { 0xf816, KEY_6 },
1275 { 0xf817, KEY_7 },
1276 { 0xf818, KEY_8 },
1277 { 0xf819, KEY_9 },
1278 { 0xf810, KEY_0 },
1279 { 0xf81c, KEY_MENU },
1280 { 0xf80f, KEY_VOLUMEDOWN },
1281 { 0xf81a, KEY_LAST },
1282 { 0xf80e, KEY_OPEN },
1283 { 0xf804, KEY_RECORD },
1284 { 0xf809, KEY_VOLUMEUP },
1285 { 0xf808, KEY_CHANNELUP },
1286 { 0xf807, KEY_PVR },
1287 { 0xf80b, KEY_TIME },
1288 { 0xf802, KEY_RIGHT },
1289 { 0xf803, KEY_LEFT },
1290 { 0xf800, KEY_UP },
1291 { 0xf81f, KEY_OK },
1292 { 0xf801, KEY_DOWN },
1293 { 0xf805, KEY_TUNER },
1294 { 0xf806, KEY_CHANNELDOWN },
1295 { 0xf840, KEY_PLAYPAUSE },
1296 { 0xf81e, KEY_REWIND },
1297 { 0xf81b, KEY_FAVORITES },
1298 { 0xf81d, KEY_BACK },
1299 { 0xf84d, KEY_FASTFORWARD },
1300 { 0xf844, KEY_EPG },
1301 { 0xf84c, KEY_INFO },
1302 { 0xf841, KEY_AB },
1303 { 0xf843, KEY_AUDIO },
1304 { 0xf845, KEY_SUBTITLE },
1305 { 0xf84a, KEY_LIST },
1306 { 0xf846, KEY_F1 },
1307 { 0xf847, KEY_F2 },
1308 { 0xf85e, KEY_F3 },
1309 { 0xf85c, KEY_F4 },
1310 { 0xf852, KEY_F5 },
1311 { 0xf85a, KEY_F6 },
1312 { 0xf856, KEY_MODE },
1313 { 0xf858, KEY_SWITCHVIDEOMODE },
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -03001314};
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001315
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03001316static struct rc_map_table rc_map_tbs_table[] = {
Mauro Carvalho Chehab2e365882009-08-29 15:19:31 -03001317 { 0xf884, KEY_POWER },
1318 { 0xf894, KEY_MUTE },
1319 { 0xf887, KEY_1 },
1320 { 0xf886, KEY_2 },
1321 { 0xf885, KEY_3 },
1322 { 0xf88b, KEY_4 },
1323 { 0xf88a, KEY_5 },
1324 { 0xf889, KEY_6 },
1325 { 0xf88f, KEY_7 },
1326 { 0xf88e, KEY_8 },
1327 { 0xf88d, KEY_9 },
1328 { 0xf892, KEY_0 },
1329 { 0xf896, KEY_CHANNELUP },
1330 { 0xf891, KEY_CHANNELDOWN },
1331 { 0xf893, KEY_VOLUMEUP },
1332 { 0xf88c, KEY_VOLUMEDOWN },
1333 { 0xf883, KEY_RECORD },
1334 { 0xf898, KEY_PAUSE },
1335 { 0xf899, KEY_OK },
1336 { 0xf89a, KEY_SHUFFLE },
1337 { 0xf881, KEY_UP },
1338 { 0xf890, KEY_LEFT },
1339 { 0xf882, KEY_RIGHT },
1340 { 0xf888, KEY_DOWN },
1341 { 0xf895, KEY_FAVORITES },
1342 { 0xf897, KEY_SUBTITLE },
1343 { 0xf89d, KEY_ZOOM },
1344 { 0xf89f, KEY_EXIT },
1345 { 0xf89e, KEY_MENU },
1346 { 0xf89c, KEY_EPG },
1347 { 0xf880, KEY_PREVIOUS },
1348 { 0xf89b, KEY_MODE }
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -03001349};
1350
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001351static struct rc_map_table rc_map_su3000_table[] = {
1352 { 0x25, KEY_POWER }, /* right-bottom Red */
1353 { 0x0a, KEY_MUTE }, /* -/-- */
1354 { 0x01, KEY_1 },
1355 { 0x02, KEY_2 },
1356 { 0x03, KEY_3 },
1357 { 0x04, KEY_4 },
1358 { 0x05, KEY_5 },
1359 { 0x06, KEY_6 },
1360 { 0x07, KEY_7 },
1361 { 0x08, KEY_8 },
1362 { 0x09, KEY_9 },
1363 { 0x00, KEY_0 },
1364 { 0x20, KEY_UP }, /* CH+ */
1365 { 0x21, KEY_DOWN }, /* CH+ */
1366 { 0x12, KEY_VOLUMEUP }, /* Brightness Up */
1367 { 0x13, KEY_VOLUMEDOWN },/* Brightness Down */
1368 { 0x1f, KEY_RECORD },
1369 { 0x17, KEY_PLAY },
1370 { 0x16, KEY_PAUSE },
1371 { 0x0b, KEY_STOP },
1372 { 0x27, KEY_FASTFORWARD },/* >> */
1373 { 0x26, KEY_REWIND }, /* << */
1374 { 0x0d, KEY_OK }, /* Mute */
1375 { 0x11, KEY_LEFT }, /* VOL- */
1376 { 0x10, KEY_RIGHT }, /* VOL+ */
1377 { 0x29, KEY_BACK }, /* button under 9 */
1378 { 0x2c, KEY_MENU }, /* TTX */
1379 { 0x2b, KEY_EPG }, /* EPG */
1380 { 0x1e, KEY_RED }, /* OSD */
1381 { 0x0e, KEY_GREEN }, /* Window */
1382 { 0x2d, KEY_YELLOW }, /* button under << */
1383 { 0x0f, KEY_BLUE }, /* bottom yellow button */
1384 { 0x14, KEY_AUDIO }, /* Snapshot */
1385 { 0x38, KEY_TV }, /* TV/Radio */
Justin P. Mattock70f23fd2011-05-10 10:16:21 +02001386 { 0x0c, KEY_ESC } /* upper Red button */
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001387};
1388
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03001389static struct rc_map_dvb_usb_table_table keys_tables[] = {
1390 { rc_map_dw210x_table, ARRAY_SIZE(rc_map_dw210x_table) },
1391 { rc_map_tevii_table, ARRAY_SIZE(rc_map_tevii_table) },
1392 { rc_map_tbs_table, ARRAY_SIZE(rc_map_tbs_table) },
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001393 { rc_map_su3000_table, ARRAY_SIZE(rc_map_su3000_table) },
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -03001394};
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001395
1396static int dw2102_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
1397{
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03001398 struct rc_map_table *keymap = d->props.rc.legacy.rc_map_table;
1399 int keymap_size = d->props.rc.legacy.rc_map_size;
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001400 u8 key[2];
Igor M. Liplianin8a8dad72009-06-13 08:10:24 -03001401 struct i2c_msg msg = {
1402 .addr = DW2102_RC_QUERY,
1403 .flags = I2C_M_RD,
1404 .buf = key,
1405 .len = 2
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001406 };
1407 int i;
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -03001408 /* override keymap */
1409 if ((ir_keymap > 0) && (ir_keymap <= ARRAY_SIZE(keys_tables))) {
1410 keymap = keys_tables[ir_keymap - 1].rc_keys ;
1411 keymap_size = keys_tables[ir_keymap - 1].rc_keys_size;
Igor M. Liplianinfeb16e92011-02-25 18:41:22 -03001412 } else if (ir_keymap > ARRAY_SIZE(keys_tables))
1413 return 0; /* none */
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001414
1415 *state = REMOTE_NO_KEY_PRESSED;
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001416 if (d->props.i2c_algo->master_xfer(&d->i2c_adap, &msg, 1) == 1) {
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -03001417 for (i = 0; i < keymap_size ; i++) {
Mauro Carvalho Chehab2e365882009-08-29 15:19:31 -03001418 if (rc5_data(&keymap[i]) == msg.buf[0]) {
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001419 *state = REMOTE_KEY_PRESSED;
Mauro Carvalho Chehab34abf212010-07-31 11:24:57 -03001420 *event = keymap[i].keycode;
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001421 break;
1422 }
Igor M. Liplianin8a8dad72009-06-13 08:10:24 -03001423
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001424 }
Igor M. Liplianin8a8dad72009-06-13 08:10:24 -03001425
1426 if ((*state) == REMOTE_KEY_PRESSED)
1427 deb_rc("%s: found rc key: %x, %x, event: %x\n",
1428 __func__, key[0], key[1], (*event));
1429 else if (key[0] != 0xff)
1430 deb_rc("%s: unknown rc key: %x, %x\n",
1431 __func__, key[0], key[1]);
1432
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001433 }
Igor M. Liplianin8a8dad72009-06-13 08:10:24 -03001434
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001435 return 0;
1436}
1437
1438static struct usb_device_id dw2102_table[] = {
1439 {USB_DEVICE(USB_VID_CYPRESS, USB_PID_DW2102)},
1440 {USB_DEVICE(USB_VID_CYPRESS, 0x2101)},
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001441 {USB_DEVICE(USB_VID_CYPRESS, USB_PID_DW2104)},
1442 {USB_DEVICE(0x9022, USB_PID_TEVII_S650)},
Igor M. Liplianin4cc0edf2008-11-05 22:12:56 -03001443 {USB_DEVICE(USB_VID_TERRATEC, USB_PID_CINERGY_S)},
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001444 {USB_DEVICE(USB_VID_CYPRESS, USB_PID_DW3101)},
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001445 {USB_DEVICE(0x9022, USB_PID_TEVII_S630)},
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001446 {USB_DEVICE(0x3011, USB_PID_PROF_1100)},
1447 {USB_DEVICE(0x9022, USB_PID_TEVII_S660)},
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001448 {USB_DEVICE(0x3034, 0x7500)},
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001449 {USB_DEVICE(0x1f4d, 0x3000)},
Igor M. Liplianin2adc5912011-02-25 18:41:22 -03001450 {USB_DEVICE(USB_VID_TERRATEC, 0x00a8)},
Igor M. Liplianine8f50552011-02-25 18:41:23 -03001451 {USB_DEVICE(0x9022, USB_PID_TEVII_S480_1)},
1452 {USB_DEVICE(0x9022, USB_PID_TEVII_S480_2)},
Igor M. Liplianin5265ea52011-02-27 16:17:25 -03001453 {USB_DEVICE(0x1f4d, 0x3100)},
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001454 { }
1455};
1456
1457MODULE_DEVICE_TABLE(usb, dw2102_table);
1458
1459static int dw2102_load_firmware(struct usb_device *dev,
1460 const struct firmware *frmwr)
1461{
1462 u8 *b, *p;
1463 int ret = 0, i;
1464 u8 reset;
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -03001465 u8 reset16[] = {0, 0, 0, 0, 0, 0, 0};
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001466 const struct firmware *fw;
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001467 const char *fw_2101 = "dvb-usb-dw2101.fw";
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001468
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001469 switch (dev->descriptor.idProduct) {
1470 case 0x2101:
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001471 ret = request_firmware(&fw, fw_2101, &dev->dev);
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001472 if (ret != 0) {
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001473 err(err_str, fw_2101);
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001474 return ret;
1475 }
1476 break;
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001477 default:
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001478 fw = frmwr;
1479 break;
1480 }
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001481 info("start downloading DW210X firmware");
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001482 p = kmalloc(fw->size, GFP_KERNEL);
1483 reset = 1;
1484 /*stop the CPU*/
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001485 dw210x_op_rw(dev, 0xa0, 0x7f92, 0, &reset, 1, DW210X_WRITE_MSG);
1486 dw210x_op_rw(dev, 0xa0, 0xe600, 0, &reset, 1, DW210X_WRITE_MSG);
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001487
1488 if (p != NULL) {
1489 memcpy(p, fw->data, fw->size);
1490 for (i = 0; i < fw->size; i += 0x40) {
1491 b = (u8 *) p + i;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001492 if (dw210x_op_rw(dev, 0xa0, i, 0, b , 0x40,
1493 DW210X_WRITE_MSG) != 0x40) {
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001494 err("error while transferring firmware");
1495 ret = -EINVAL;
1496 break;
1497 }
1498 }
1499 /* restart the CPU */
1500 reset = 0;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001501 if (ret || dw210x_op_rw(dev, 0xa0, 0x7f92, 0, &reset, 1,
1502 DW210X_WRITE_MSG) != 1) {
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001503 err("could not restart the USB controller CPU.");
1504 ret = -EINVAL;
1505 }
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001506 if (ret || dw210x_op_rw(dev, 0xa0, 0xe600, 0, &reset, 1,
1507 DW210X_WRITE_MSG) != 1) {
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001508 err("could not restart the USB controller CPU.");
1509 ret = -EINVAL;
1510 }
1511 /* init registers */
1512 switch (dev->descriptor.idProduct) {
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001513 case USB_PID_TEVII_S650:
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03001514 dw2104_properties.rc.legacy.rc_map_table = rc_map_tevii_table;
1515 dw2104_properties.rc.legacy.rc_map_size =
1516 ARRAY_SIZE(rc_map_tevii_table);
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -03001517 case USB_PID_DW2104:
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001518 reset = 1;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001519 dw210x_op_rw(dev, 0xc4, 0x0000, 0, &reset, 1,
1520 DW210X_WRITE_MSG);
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001521 /* break omitted intentionally */
1522 case USB_PID_DW3101:
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001523 reset = 0;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001524 dw210x_op_rw(dev, 0xbf, 0x0040, 0, &reset, 0,
1525 DW210X_WRITE_MSG);
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001526 break;
Igor M. Liplianin4cc0edf2008-11-05 22:12:56 -03001527 case USB_PID_CINERGY_S:
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001528 case USB_PID_DW2102:
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001529 dw210x_op_rw(dev, 0xbf, 0x0040, 0, &reset, 0,
1530 DW210X_WRITE_MSG);
1531 dw210x_op_rw(dev, 0xb9, 0x0000, 0, &reset16[0], 2,
1532 DW210X_READ_MSG);
1533 /* check STV0299 frontend */
1534 dw210x_op_rw(dev, 0xb5, 0, 0, &reset16[0], 2,
1535 DW210X_READ_MSG);
Igor M. Liplianinea023df2008-12-04 12:49:23 -03001536 if ((reset16[0] == 0xa1) || (reset16[0] == 0x80)) {
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001537 dw2102_properties.i2c_algo = &dw2102_i2c_algo;
Michael Krufky77eed212011-09-06 09:31:57 -03001538 dw2102_properties.adapter->fe[0].tuner_attach = &dw2102_tuner_attach;
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -03001539 break;
1540 } else {
1541 /* check STV0288 frontend */
1542 reset16[0] = 0xd0;
1543 reset16[1] = 1;
1544 reset16[2] = 0;
1545 dw210x_op_rw(dev, 0xc2, 0, 0, &reset16[0], 3,
1546 DW210X_WRITE_MSG);
1547 dw210x_op_rw(dev, 0xc3, 0xd1, 0, &reset16[0], 3,
1548 DW210X_READ_MSG);
1549 if (reset16[2] == 0x11) {
1550 dw2102_properties.i2c_algo = &dw2102_earda_i2c_algo;
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -03001551 break;
1552 }
1553 }
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001554 case 0x2101:
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001555 dw210x_op_rw(dev, 0xbc, 0x0030, 0, &reset16[0], 2,
1556 DW210X_READ_MSG);
1557 dw210x_op_rw(dev, 0xba, 0x0000, 0, &reset16[0], 7,
1558 DW210X_READ_MSG);
1559 dw210x_op_rw(dev, 0xba, 0x0000, 0, &reset16[0], 7,
1560 DW210X_READ_MSG);
1561 dw210x_op_rw(dev, 0xb9, 0x0000, 0, &reset16[0], 2,
1562 DW210X_READ_MSG);
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001563 break;
1564 }
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001565
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001566 msleep(100);
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001567 kfree(p);
1568 }
1569 return ret;
1570}
1571
1572static struct dvb_usb_device_properties dw2102_properties = {
1573 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1574 .usb_ctrl = DEVICE_SPECIFIC,
1575 .firmware = "dvb-usb-dw2102.fw",
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001576 .no_reconnect = 1,
1577
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001578 .i2c_algo = &dw2102_serit_i2c_algo,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03001579
1580 .rc.legacy = {
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03001581 .rc_map_table = rc_map_dw210x_table,
1582 .rc_map_size = ARRAY_SIZE(rc_map_dw210x_table),
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03001583 .rc_interval = 150,
1584 .rc_query = dw2102_rc_query,
1585 },
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001586
1587 .generic_bulk_ctrl_endpoint = 0x81,
1588 /* parameter for the MPEG2-data transfer */
1589 .num_adapters = 1,
1590 .download_firmware = dw2102_load_firmware,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001591 .read_mac_address = dw210x_read_mac_address,
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001592 .adapter = {
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001593 {
Michael Krufky77eed212011-09-06 09:31:57 -03001594 .num_frontends = 1,
1595 .fe = {{
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001596 .frontend_attach = dw2102_frontend_attach,
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001597 .stream = {
1598 .type = USB_BULK,
1599 .count = 8,
1600 .endpoint = 0x82,
1601 .u = {
1602 .bulk = {
1603 .buffersize = 4096,
1604 }
1605 }
1606 },
Michael Krufky77eed212011-09-06 09:31:57 -03001607 }},
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001608 }
1609 },
Igor M. Liplianin4cc0edf2008-11-05 22:12:56 -03001610 .num_device_descs = 3,
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001611 .devices = {
1612 {"DVBWorld DVB-S 2102 USB2.0",
1613 {&dw2102_table[0], NULL},
1614 {NULL},
1615 },
1616 {"DVBWorld DVB-S 2101 USB2.0",
1617 {&dw2102_table[1], NULL},
1618 {NULL},
1619 },
Igor M. Liplianin4cc0edf2008-11-05 22:12:56 -03001620 {"TerraTec Cinergy S USB",
1621 {&dw2102_table[4], NULL},
1622 {NULL},
1623 },
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001624 }
1625};
1626
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001627static struct dvb_usb_device_properties dw2104_properties = {
1628 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1629 .usb_ctrl = DEVICE_SPECIFIC,
1630 .firmware = "dvb-usb-dw2104.fw",
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001631 .no_reconnect = 1,
1632
1633 .i2c_algo = &dw2104_i2c_algo,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03001634 .rc.legacy = {
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03001635 .rc_map_table = rc_map_dw210x_table,
1636 .rc_map_size = ARRAY_SIZE(rc_map_dw210x_table),
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03001637 .rc_interval = 150,
1638 .rc_query = dw2102_rc_query,
1639 },
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001640
1641 .generic_bulk_ctrl_endpoint = 0x81,
1642 /* parameter for the MPEG2-data transfer */
1643 .num_adapters = 1,
1644 .download_firmware = dw2102_load_firmware,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001645 .read_mac_address = dw210x_read_mac_address,
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001646 .adapter = {
1647 {
Michael Krufky77eed212011-09-06 09:31:57 -03001648 .num_frontends = 1,
1649 .fe = {{
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001650 .frontend_attach = dw2104_frontend_attach,
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001651 .stream = {
1652 .type = USB_BULK,
1653 .count = 8,
1654 .endpoint = 0x82,
1655 .u = {
1656 .bulk = {
1657 .buffersize = 4096,
1658 }
1659 }
1660 },
Michael Krufky77eed212011-09-06 09:31:57 -03001661 }},
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001662 }
1663 },
1664 .num_device_descs = 2,
1665 .devices = {
1666 { "DVBWorld DW2104 USB2.0",
1667 {&dw2102_table[2], NULL},
1668 {NULL},
1669 },
1670 { "TeVii S650 USB2.0",
1671 {&dw2102_table[3], NULL},
1672 {NULL},
1673 },
1674 }
1675};
1676
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001677static struct dvb_usb_device_properties dw3101_properties = {
1678 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1679 .usb_ctrl = DEVICE_SPECIFIC,
1680 .firmware = "dvb-usb-dw3101.fw",
1681 .no_reconnect = 1,
1682
1683 .i2c_algo = &dw3101_i2c_algo,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03001684 .rc.legacy = {
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03001685 .rc_map_table = rc_map_dw210x_table,
1686 .rc_map_size = ARRAY_SIZE(rc_map_dw210x_table),
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03001687 .rc_interval = 150,
1688 .rc_query = dw2102_rc_query,
1689 },
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001690
1691 .generic_bulk_ctrl_endpoint = 0x81,
1692 /* parameter for the MPEG2-data transfer */
1693 .num_adapters = 1,
1694 .download_firmware = dw2102_load_firmware,
1695 .read_mac_address = dw210x_read_mac_address,
1696 .adapter = {
1697 {
Michael Krufky77eed212011-09-06 09:31:57 -03001698 .num_frontends = 1,
1699 .fe = {{
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001700 .frontend_attach = dw3101_frontend_attach,
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001701 .tuner_attach = dw3101_tuner_attach,
1702 .stream = {
1703 .type = USB_BULK,
1704 .count = 8,
1705 .endpoint = 0x82,
1706 .u = {
1707 .bulk = {
1708 .buffersize = 4096,
1709 }
1710 }
1711 },
Michael Krufky77eed212011-09-06 09:31:57 -03001712 }},
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001713 }
1714 },
1715 .num_device_descs = 1,
1716 .devices = {
1717 { "DVBWorld DVB-C 3101 USB2.0",
1718 {&dw2102_table[5], NULL},
1719 {NULL},
1720 },
1721 }
1722};
1723
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001724static struct dvb_usb_device_properties s6x0_properties = {
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001725 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1726 .usb_ctrl = DEVICE_SPECIFIC,
Igor M. Liplianin52c506e2011-02-25 18:41:23 -03001727 .size_of_priv = sizeof(struct s6x0_state),
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001728 .firmware = "dvb-usb-s630.fw",
1729 .no_reconnect = 1,
1730
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001731 .i2c_algo = &s6x0_i2c_algo,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03001732 .rc.legacy = {
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03001733 .rc_map_table = rc_map_tevii_table,
1734 .rc_map_size = ARRAY_SIZE(rc_map_tevii_table),
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03001735 .rc_interval = 150,
1736 .rc_query = dw2102_rc_query,
1737 },
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001738
1739 .generic_bulk_ctrl_endpoint = 0x81,
1740 .num_adapters = 1,
1741 .download_firmware = dw2102_load_firmware,
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001742 .read_mac_address = s6x0_read_mac_address,
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001743 .adapter = {
1744 {
Michael Krufky77eed212011-09-06 09:31:57 -03001745 .num_frontends = 1,
1746 .fe = {{
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001747 .frontend_attach = zl100313_frontend_attach,
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001748 .stream = {
1749 .type = USB_BULK,
1750 .count = 8,
1751 .endpoint = 0x82,
1752 .u = {
1753 .bulk = {
1754 .buffersize = 4096,
1755 }
1756 }
1757 },
Michael Krufky77eed212011-09-06 09:31:57 -03001758 }},
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001759 }
1760 },
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001761 .num_device_descs = 1,
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001762 .devices = {
1763 {"TeVii S630 USB",
1764 {&dw2102_table[6], NULL},
1765 {NULL},
1766 },
1767 }
1768};
1769
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001770struct dvb_usb_device_properties *p1100;
1771static struct dvb_usb_device_description d1100 = {
1772 "Prof 1100 USB ",
1773 {&dw2102_table[7], NULL},
1774 {NULL},
1775};
1776
1777struct dvb_usb_device_properties *s660;
1778static struct dvb_usb_device_description d660 = {
1779 "TeVii S660 USB",
1780 {&dw2102_table[8], NULL},
1781 {NULL},
1782};
1783
Igor M. Liplianine8f50552011-02-25 18:41:23 -03001784static struct dvb_usb_device_description d480_1 = {
1785 "TeVii S480.1 USB",
1786 {&dw2102_table[12], NULL},
1787 {NULL},
1788};
1789
1790static struct dvb_usb_device_description d480_2 = {
1791 "TeVii S480.2 USB",
1792 {&dw2102_table[13], NULL},
1793 {NULL},
1794};
1795
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001796struct dvb_usb_device_properties *p7500;
1797static struct dvb_usb_device_description d7500 = {
1798 "Prof 7500 USB DVB-S2",
1799 {&dw2102_table[9], NULL},
1800 {NULL},
1801};
1802
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001803static struct dvb_usb_device_properties su3000_properties = {
1804 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1805 .usb_ctrl = DEVICE_SPECIFIC,
1806 .size_of_priv = sizeof(struct su3000_state),
1807 .power_ctrl = su3000_power_ctrl,
1808 .num_adapters = 1,
1809 .identify_state = su3000_identify_state,
1810 .i2c_algo = &su3000_i2c_algo,
1811
1812 .rc.legacy = {
1813 .rc_map_table = rc_map_su3000_table,
1814 .rc_map_size = ARRAY_SIZE(rc_map_su3000_table),
1815 .rc_interval = 150,
1816 .rc_query = dw2102_rc_query,
1817 },
1818
1819 .read_mac_address = su3000_read_mac_address,
1820
1821 .generic_bulk_ctrl_endpoint = 0x01,
1822
1823 .adapter = {
1824 {
Michael Krufky77eed212011-09-06 09:31:57 -03001825 .num_frontends = 1,
1826 .fe = {{
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001827 .streaming_ctrl = su3000_streaming_ctrl,
1828 .frontend_attach = su3000_frontend_attach,
1829 .stream = {
1830 .type = USB_BULK,
1831 .count = 8,
1832 .endpoint = 0x82,
1833 .u = {
1834 .bulk = {
1835 .buffersize = 4096,
1836 }
1837 }
1838 }
Michael Krufky77eed212011-09-06 09:31:57 -03001839 }},
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001840 }
1841 },
Igor M. Liplianin5265ea52011-02-27 16:17:25 -03001842 .num_device_descs = 3,
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001843 .devices = {
1844 { "SU3000HD DVB-S USB2.0",
1845 { &dw2102_table[10], NULL },
1846 { NULL },
1847 },
Igor M. Liplianin2adc5912011-02-25 18:41:22 -03001848 { "Terratec Cinergy S2 USB HD",
1849 { &dw2102_table[11], NULL },
1850 { NULL },
1851 },
Igor M. Liplianin5265ea52011-02-27 16:17:25 -03001852 { "X3M TV SPC1400HD PCI",
1853 { &dw2102_table[14], NULL },
1854 { NULL },
1855 },
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001856 }
1857};
1858
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001859static int dw2102_probe(struct usb_interface *intf,
1860 const struct usb_device_id *id)
1861{
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001862 p1100 = kzalloc(sizeof(struct dvb_usb_device_properties), GFP_KERNEL);
1863 if (!p1100)
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001864 return -ENOMEM;
1865 /* copy default structure */
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001866 memcpy(p1100, &s6x0_properties,
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001867 sizeof(struct dvb_usb_device_properties));
1868 /* fill only different fields */
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001869 p1100->firmware = "dvb-usb-p1100.fw";
1870 p1100->devices[0] = d1100;
1871 p1100->rc.legacy.rc_map_table = rc_map_tbs_table;
1872 p1100->rc.legacy.rc_map_size = ARRAY_SIZE(rc_map_tbs_table);
Michael Krufky77eed212011-09-06 09:31:57 -03001873 p1100->adapter->fe[0].frontend_attach = stv0288_frontend_attach;
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001874
1875 s660 = kzalloc(sizeof(struct dvb_usb_device_properties), GFP_KERNEL);
1876 if (!s660) {
1877 kfree(p1100);
1878 return -ENOMEM;
1879 }
1880 memcpy(s660, &s6x0_properties,
1881 sizeof(struct dvb_usb_device_properties));
1882 s660->firmware = "dvb-usb-s660.fw";
Igor M. Liplianine8f50552011-02-25 18:41:23 -03001883 s660->num_device_descs = 3;
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001884 s660->devices[0] = d660;
Igor M. Liplianine8f50552011-02-25 18:41:23 -03001885 s660->devices[1] = d480_1;
1886 s660->devices[2] = d480_2;
Michael Krufky77eed212011-09-06 09:31:57 -03001887 s660->adapter->fe[0].frontend_attach = ds3000_frontend_attach;
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001888
1889 p7500 = kzalloc(sizeof(struct dvb_usb_device_properties), GFP_KERNEL);
1890 if (!p7500) {
1891 kfree(p1100);
1892 kfree(s660);
1893 return -ENOMEM;
1894 }
1895 memcpy(p7500, &s6x0_properties,
1896 sizeof(struct dvb_usb_device_properties));
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001897 p7500->firmware = "dvb-usb-p7500.fw";
1898 p7500->devices[0] = d7500;
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03001899 p7500->rc.legacy.rc_map_table = rc_map_tbs_table;
1900 p7500->rc.legacy.rc_map_size = ARRAY_SIZE(rc_map_tbs_table);
Michael Krufky77eed212011-09-06 09:31:57 -03001901 p7500->adapter->fe[0].frontend_attach = prof_7500_frontend_attach;
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001902
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001903 if (0 == dvb_usb_device_init(intf, &dw2102_properties,
1904 THIS_MODULE, NULL, adapter_nr) ||
1905 0 == dvb_usb_device_init(intf, &dw2104_properties,
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001906 THIS_MODULE, NULL, adapter_nr) ||
1907 0 == dvb_usb_device_init(intf, &dw3101_properties,
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001908 THIS_MODULE, NULL, adapter_nr) ||
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001909 0 == dvb_usb_device_init(intf, &s6x0_properties,
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001910 THIS_MODULE, NULL, adapter_nr) ||
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001911 0 == dvb_usb_device_init(intf, p1100,
1912 THIS_MODULE, NULL, adapter_nr) ||
1913 0 == dvb_usb_device_init(intf, s660,
1914 THIS_MODULE, NULL, adapter_nr) ||
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001915 0 == dvb_usb_device_init(intf, p7500,
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001916 THIS_MODULE, NULL, adapter_nr) ||
1917 0 == dvb_usb_device_init(intf, &su3000_properties,
1918 THIS_MODULE, NULL, adapter_nr))
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001919 return 0;
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001920
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001921 return -ENODEV;
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001922}
1923
1924static struct usb_driver dw2102_driver = {
1925 .name = "dw2102",
1926 .probe = dw2102_probe,
1927 .disconnect = dvb_usb_device_exit,
1928 .id_table = dw2102_table,
1929};
1930
1931static int __init dw2102_module_init(void)
1932{
1933 int ret = usb_register(&dw2102_driver);
1934 if (ret)
1935 err("usb_register failed. Error number %d", ret);
1936
1937 return ret;
1938}
1939
1940static void __exit dw2102_module_exit(void)
1941{
1942 usb_deregister(&dw2102_driver);
1943}
1944
1945module_init(dw2102_module_init);
1946module_exit(dw2102_module_exit);
1947
1948MODULE_AUTHOR("Igor M. Liplianin (c) liplianin@me.by");
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001949MODULE_DESCRIPTION("Driver for DVBWorld DVB-S 2101, 2102, DVB-S2 2104,"
1950 " DVB-C 3101 USB2.0,"
Igor M. Liplianine8f50552011-02-25 18:41:23 -03001951 " TeVii S600, S630, S650, S660, S480,"
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001952 " Prof 1100, 7500 USB2.0,"
1953 " Geniatech SU3000 devices");
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001954MODULE_VERSION("0.1");
1955MODULE_LICENSE("GPL");