blob: 451c5a7adfb2da284c02593f29801e87909fe403 [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
Jonathan Nieder27351b12011-12-23 19:00:45 -03001438enum dw2102_table_entry {
1439 CYPRESS_DW2102,
1440 CYPRESS_DW2101,
1441 CYPRESS_DW2104,
1442 TEVII_S650,
1443 TERRATEC_CINERGY_S,
1444 CYPRESS_DW3101,
1445 TEVII_S630,
1446 PROF_1100,
1447 TEVII_S660,
1448 PROF_7500,
1449 GENIATECH_SU3000,
1450 TERRATEC_CINERGY_S2,
1451 TEVII_S480_1,
1452 TEVII_S480_2,
1453 X3M_SPC1400HD,
1454};
1455
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001456static struct usb_device_id dw2102_table[] = {
Jonathan Nieder27351b12011-12-23 19:00:45 -03001457 [CYPRESS_DW2102] = {USB_DEVICE(USB_VID_CYPRESS, USB_PID_DW2102)},
1458 [CYPRESS_DW2101] = {USB_DEVICE(USB_VID_CYPRESS, 0x2101)},
1459 [CYPRESS_DW2104] = {USB_DEVICE(USB_VID_CYPRESS, USB_PID_DW2104)},
1460 [TEVII_S650] = {USB_DEVICE(0x9022, USB_PID_TEVII_S650)},
1461 [TERRATEC_CINERGY_S] = {USB_DEVICE(USB_VID_TERRATEC, USB_PID_CINERGY_S)},
1462 [CYPRESS_DW3101] = {USB_DEVICE(USB_VID_CYPRESS, USB_PID_DW3101)},
1463 [TEVII_S630] = {USB_DEVICE(0x9022, USB_PID_TEVII_S630)},
1464 [PROF_1100] = {USB_DEVICE(0x3011, USB_PID_PROF_1100)},
1465 [TEVII_S660] = {USB_DEVICE(0x9022, USB_PID_TEVII_S660)},
1466 [PROF_7500] = {USB_DEVICE(0x3034, 0x7500)},
1467 [GENIATECH_SU3000] = {USB_DEVICE(0x1f4d, 0x3000)},
1468 [TERRATEC_CINERGY_S2] = {USB_DEVICE(USB_VID_TERRATEC, 0x00a8)},
1469 [TEVII_S480_1] = {USB_DEVICE(0x9022, USB_PID_TEVII_S480_1)},
1470 [TEVII_S480_2] = {USB_DEVICE(0x9022, USB_PID_TEVII_S480_2)},
1471 [X3M_SPC1400HD] = {USB_DEVICE(0x1f4d, 0x3100)},
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001472 { }
1473};
1474
1475MODULE_DEVICE_TABLE(usb, dw2102_table);
1476
1477static int dw2102_load_firmware(struct usb_device *dev,
1478 const struct firmware *frmwr)
1479{
1480 u8 *b, *p;
1481 int ret = 0, i;
1482 u8 reset;
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -03001483 u8 reset16[] = {0, 0, 0, 0, 0, 0, 0};
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001484 const struct firmware *fw;
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001485 const char *fw_2101 = "dvb-usb-dw2101.fw";
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001486
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001487 switch (dev->descriptor.idProduct) {
1488 case 0x2101:
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001489 ret = request_firmware(&fw, fw_2101, &dev->dev);
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001490 if (ret != 0) {
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001491 err(err_str, fw_2101);
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001492 return ret;
1493 }
1494 break;
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001495 default:
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001496 fw = frmwr;
1497 break;
1498 }
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001499 info("start downloading DW210X firmware");
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001500 p = kmalloc(fw->size, GFP_KERNEL);
1501 reset = 1;
1502 /*stop the CPU*/
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001503 dw210x_op_rw(dev, 0xa0, 0x7f92, 0, &reset, 1, DW210X_WRITE_MSG);
1504 dw210x_op_rw(dev, 0xa0, 0xe600, 0, &reset, 1, DW210X_WRITE_MSG);
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001505
1506 if (p != NULL) {
1507 memcpy(p, fw->data, fw->size);
1508 for (i = 0; i < fw->size; i += 0x40) {
1509 b = (u8 *) p + i;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001510 if (dw210x_op_rw(dev, 0xa0, i, 0, b , 0x40,
1511 DW210X_WRITE_MSG) != 0x40) {
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001512 err("error while transferring firmware");
1513 ret = -EINVAL;
1514 break;
1515 }
1516 }
1517 /* restart the CPU */
1518 reset = 0;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001519 if (ret || dw210x_op_rw(dev, 0xa0, 0x7f92, 0, &reset, 1,
1520 DW210X_WRITE_MSG) != 1) {
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001521 err("could not restart the USB controller CPU.");
1522 ret = -EINVAL;
1523 }
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001524 if (ret || dw210x_op_rw(dev, 0xa0, 0xe600, 0, &reset, 1,
1525 DW210X_WRITE_MSG) != 1) {
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001526 err("could not restart the USB controller CPU.");
1527 ret = -EINVAL;
1528 }
1529 /* init registers */
1530 switch (dev->descriptor.idProduct) {
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001531 case USB_PID_TEVII_S650:
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03001532 dw2104_properties.rc.legacy.rc_map_table = rc_map_tevii_table;
1533 dw2104_properties.rc.legacy.rc_map_size =
1534 ARRAY_SIZE(rc_map_tevii_table);
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -03001535 case USB_PID_DW2104:
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001536 reset = 1;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001537 dw210x_op_rw(dev, 0xc4, 0x0000, 0, &reset, 1,
1538 DW210X_WRITE_MSG);
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001539 /* break omitted intentionally */
1540 case USB_PID_DW3101:
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001541 reset = 0;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001542 dw210x_op_rw(dev, 0xbf, 0x0040, 0, &reset, 0,
1543 DW210X_WRITE_MSG);
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001544 break;
Igor M. Liplianin4cc0edf2008-11-05 22:12:56 -03001545 case USB_PID_CINERGY_S:
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001546 case USB_PID_DW2102:
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001547 dw210x_op_rw(dev, 0xbf, 0x0040, 0, &reset, 0,
1548 DW210X_WRITE_MSG);
1549 dw210x_op_rw(dev, 0xb9, 0x0000, 0, &reset16[0], 2,
1550 DW210X_READ_MSG);
1551 /* check STV0299 frontend */
1552 dw210x_op_rw(dev, 0xb5, 0, 0, &reset16[0], 2,
1553 DW210X_READ_MSG);
Igor M. Liplianinea023df2008-12-04 12:49:23 -03001554 if ((reset16[0] == 0xa1) || (reset16[0] == 0x80)) {
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001555 dw2102_properties.i2c_algo = &dw2102_i2c_algo;
Michael Krufky77eed212011-09-06 09:31:57 -03001556 dw2102_properties.adapter->fe[0].tuner_attach = &dw2102_tuner_attach;
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -03001557 break;
1558 } else {
1559 /* check STV0288 frontend */
1560 reset16[0] = 0xd0;
1561 reset16[1] = 1;
1562 reset16[2] = 0;
1563 dw210x_op_rw(dev, 0xc2, 0, 0, &reset16[0], 3,
1564 DW210X_WRITE_MSG);
1565 dw210x_op_rw(dev, 0xc3, 0xd1, 0, &reset16[0], 3,
1566 DW210X_READ_MSG);
1567 if (reset16[2] == 0x11) {
1568 dw2102_properties.i2c_algo = &dw2102_earda_i2c_algo;
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -03001569 break;
1570 }
1571 }
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001572 case 0x2101:
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001573 dw210x_op_rw(dev, 0xbc, 0x0030, 0, &reset16[0], 2,
1574 DW210X_READ_MSG);
1575 dw210x_op_rw(dev, 0xba, 0x0000, 0, &reset16[0], 7,
1576 DW210X_READ_MSG);
1577 dw210x_op_rw(dev, 0xba, 0x0000, 0, &reset16[0], 7,
1578 DW210X_READ_MSG);
1579 dw210x_op_rw(dev, 0xb9, 0x0000, 0, &reset16[0], 2,
1580 DW210X_READ_MSG);
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001581 break;
1582 }
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001583
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001584 msleep(100);
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001585 kfree(p);
1586 }
1587 return ret;
1588}
1589
1590static struct dvb_usb_device_properties dw2102_properties = {
1591 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1592 .usb_ctrl = DEVICE_SPECIFIC,
1593 .firmware = "dvb-usb-dw2102.fw",
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001594 .no_reconnect = 1,
1595
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001596 .i2c_algo = &dw2102_serit_i2c_algo,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03001597
1598 .rc.legacy = {
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03001599 .rc_map_table = rc_map_dw210x_table,
1600 .rc_map_size = ARRAY_SIZE(rc_map_dw210x_table),
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03001601 .rc_interval = 150,
1602 .rc_query = dw2102_rc_query,
1603 },
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001604
1605 .generic_bulk_ctrl_endpoint = 0x81,
1606 /* parameter for the MPEG2-data transfer */
1607 .num_adapters = 1,
1608 .download_firmware = dw2102_load_firmware,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001609 .read_mac_address = dw210x_read_mac_address,
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001610 .adapter = {
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001611 {
Michael Krufky77eed212011-09-06 09:31:57 -03001612 .num_frontends = 1,
1613 .fe = {{
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001614 .frontend_attach = dw2102_frontend_attach,
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001615 .stream = {
1616 .type = USB_BULK,
1617 .count = 8,
1618 .endpoint = 0x82,
1619 .u = {
1620 .bulk = {
1621 .buffersize = 4096,
1622 }
1623 }
1624 },
Michael Krufky77eed212011-09-06 09:31:57 -03001625 }},
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001626 }
1627 },
Igor M. Liplianin4cc0edf2008-11-05 22:12:56 -03001628 .num_device_descs = 3,
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001629 .devices = {
1630 {"DVBWorld DVB-S 2102 USB2.0",
Jonathan Nieder27351b12011-12-23 19:00:45 -03001631 {&dw2102_table[CYPRESS_DW2102], NULL},
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001632 {NULL},
1633 },
1634 {"DVBWorld DVB-S 2101 USB2.0",
Jonathan Nieder27351b12011-12-23 19:00:45 -03001635 {&dw2102_table[CYPRESS_DW2101], NULL},
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001636 {NULL},
1637 },
Igor M. Liplianin4cc0edf2008-11-05 22:12:56 -03001638 {"TerraTec Cinergy S USB",
Jonathan Nieder27351b12011-12-23 19:00:45 -03001639 {&dw2102_table[TERRATEC_CINERGY_S], NULL},
Igor M. Liplianin4cc0edf2008-11-05 22:12:56 -03001640 {NULL},
1641 },
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001642 }
1643};
1644
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001645static struct dvb_usb_device_properties dw2104_properties = {
1646 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1647 .usb_ctrl = DEVICE_SPECIFIC,
1648 .firmware = "dvb-usb-dw2104.fw",
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001649 .no_reconnect = 1,
1650
1651 .i2c_algo = &dw2104_i2c_algo,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03001652 .rc.legacy = {
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03001653 .rc_map_table = rc_map_dw210x_table,
1654 .rc_map_size = ARRAY_SIZE(rc_map_dw210x_table),
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03001655 .rc_interval = 150,
1656 .rc_query = dw2102_rc_query,
1657 },
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001658
1659 .generic_bulk_ctrl_endpoint = 0x81,
1660 /* parameter for the MPEG2-data transfer */
1661 .num_adapters = 1,
1662 .download_firmware = dw2102_load_firmware,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001663 .read_mac_address = dw210x_read_mac_address,
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001664 .adapter = {
1665 {
Michael Krufky77eed212011-09-06 09:31:57 -03001666 .num_frontends = 1,
1667 .fe = {{
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001668 .frontend_attach = dw2104_frontend_attach,
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001669 .stream = {
1670 .type = USB_BULK,
1671 .count = 8,
1672 .endpoint = 0x82,
1673 .u = {
1674 .bulk = {
1675 .buffersize = 4096,
1676 }
1677 }
1678 },
Michael Krufky77eed212011-09-06 09:31:57 -03001679 }},
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001680 }
1681 },
1682 .num_device_descs = 2,
1683 .devices = {
1684 { "DVBWorld DW2104 USB2.0",
Jonathan Nieder27351b12011-12-23 19:00:45 -03001685 {&dw2102_table[CYPRESS_DW2104], NULL},
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001686 {NULL},
1687 },
1688 { "TeVii S650 USB2.0",
Jonathan Nieder27351b12011-12-23 19:00:45 -03001689 {&dw2102_table[TEVII_S650], NULL},
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001690 {NULL},
1691 },
1692 }
1693};
1694
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001695static struct dvb_usb_device_properties dw3101_properties = {
1696 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1697 .usb_ctrl = DEVICE_SPECIFIC,
1698 .firmware = "dvb-usb-dw3101.fw",
1699 .no_reconnect = 1,
1700
1701 .i2c_algo = &dw3101_i2c_algo,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03001702 .rc.legacy = {
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03001703 .rc_map_table = rc_map_dw210x_table,
1704 .rc_map_size = ARRAY_SIZE(rc_map_dw210x_table),
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03001705 .rc_interval = 150,
1706 .rc_query = dw2102_rc_query,
1707 },
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001708
1709 .generic_bulk_ctrl_endpoint = 0x81,
1710 /* parameter for the MPEG2-data transfer */
1711 .num_adapters = 1,
1712 .download_firmware = dw2102_load_firmware,
1713 .read_mac_address = dw210x_read_mac_address,
1714 .adapter = {
1715 {
Michael Krufky77eed212011-09-06 09:31:57 -03001716 .num_frontends = 1,
1717 .fe = {{
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001718 .frontend_attach = dw3101_frontend_attach,
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001719 .tuner_attach = dw3101_tuner_attach,
1720 .stream = {
1721 .type = USB_BULK,
1722 .count = 8,
1723 .endpoint = 0x82,
1724 .u = {
1725 .bulk = {
1726 .buffersize = 4096,
1727 }
1728 }
1729 },
Michael Krufky77eed212011-09-06 09:31:57 -03001730 }},
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001731 }
1732 },
1733 .num_device_descs = 1,
1734 .devices = {
1735 { "DVBWorld DVB-C 3101 USB2.0",
Jonathan Nieder27351b12011-12-23 19:00:45 -03001736 {&dw2102_table[CYPRESS_DW3101], NULL},
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001737 {NULL},
1738 },
1739 }
1740};
1741
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001742static struct dvb_usb_device_properties s6x0_properties = {
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001743 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1744 .usb_ctrl = DEVICE_SPECIFIC,
Igor M. Liplianin52c506e2011-02-25 18:41:23 -03001745 .size_of_priv = sizeof(struct s6x0_state),
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001746 .firmware = "dvb-usb-s630.fw",
1747 .no_reconnect = 1,
1748
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001749 .i2c_algo = &s6x0_i2c_algo,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03001750 .rc.legacy = {
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03001751 .rc_map_table = rc_map_tevii_table,
1752 .rc_map_size = ARRAY_SIZE(rc_map_tevii_table),
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03001753 .rc_interval = 150,
1754 .rc_query = dw2102_rc_query,
1755 },
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001756
1757 .generic_bulk_ctrl_endpoint = 0x81,
1758 .num_adapters = 1,
1759 .download_firmware = dw2102_load_firmware,
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001760 .read_mac_address = s6x0_read_mac_address,
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001761 .adapter = {
1762 {
Michael Krufky77eed212011-09-06 09:31:57 -03001763 .num_frontends = 1,
1764 .fe = {{
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001765 .frontend_attach = zl100313_frontend_attach,
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001766 .stream = {
1767 .type = USB_BULK,
1768 .count = 8,
1769 .endpoint = 0x82,
1770 .u = {
1771 .bulk = {
1772 .buffersize = 4096,
1773 }
1774 }
1775 },
Michael Krufky77eed212011-09-06 09:31:57 -03001776 }},
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001777 }
1778 },
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001779 .num_device_descs = 1,
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001780 .devices = {
1781 {"TeVii S630 USB",
Jonathan Nieder27351b12011-12-23 19:00:45 -03001782 {&dw2102_table[TEVII_S630], NULL},
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001783 {NULL},
1784 },
1785 }
1786};
1787
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001788struct dvb_usb_device_properties *p1100;
1789static struct dvb_usb_device_description d1100 = {
1790 "Prof 1100 USB ",
Jonathan Nieder27351b12011-12-23 19:00:45 -03001791 {&dw2102_table[PROF_1100], NULL},
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001792 {NULL},
1793};
1794
1795struct dvb_usb_device_properties *s660;
1796static struct dvb_usb_device_description d660 = {
1797 "TeVii S660 USB",
Jonathan Nieder27351b12011-12-23 19:00:45 -03001798 {&dw2102_table[TEVII_S660], NULL},
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001799 {NULL},
1800};
1801
Igor M. Liplianine8f50552011-02-25 18:41:23 -03001802static struct dvb_usb_device_description d480_1 = {
1803 "TeVii S480.1 USB",
Jonathan Nieder27351b12011-12-23 19:00:45 -03001804 {&dw2102_table[TEVII_S480_1], NULL},
Igor M. Liplianine8f50552011-02-25 18:41:23 -03001805 {NULL},
1806};
1807
1808static struct dvb_usb_device_description d480_2 = {
1809 "TeVii S480.2 USB",
Jonathan Nieder27351b12011-12-23 19:00:45 -03001810 {&dw2102_table[TEVII_S480_2], NULL},
Igor M. Liplianine8f50552011-02-25 18:41:23 -03001811 {NULL},
1812};
1813
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001814struct dvb_usb_device_properties *p7500;
1815static struct dvb_usb_device_description d7500 = {
1816 "Prof 7500 USB DVB-S2",
Jonathan Nieder27351b12011-12-23 19:00:45 -03001817 {&dw2102_table[PROF_7500], NULL},
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001818 {NULL},
1819};
1820
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001821static struct dvb_usb_device_properties su3000_properties = {
1822 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1823 .usb_ctrl = DEVICE_SPECIFIC,
1824 .size_of_priv = sizeof(struct su3000_state),
1825 .power_ctrl = su3000_power_ctrl,
1826 .num_adapters = 1,
1827 .identify_state = su3000_identify_state,
1828 .i2c_algo = &su3000_i2c_algo,
1829
1830 .rc.legacy = {
1831 .rc_map_table = rc_map_su3000_table,
1832 .rc_map_size = ARRAY_SIZE(rc_map_su3000_table),
1833 .rc_interval = 150,
1834 .rc_query = dw2102_rc_query,
1835 },
1836
1837 .read_mac_address = su3000_read_mac_address,
1838
1839 .generic_bulk_ctrl_endpoint = 0x01,
1840
1841 .adapter = {
1842 {
Michael Krufky77eed212011-09-06 09:31:57 -03001843 .num_frontends = 1,
1844 .fe = {{
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001845 .streaming_ctrl = su3000_streaming_ctrl,
1846 .frontend_attach = su3000_frontend_attach,
1847 .stream = {
1848 .type = USB_BULK,
1849 .count = 8,
1850 .endpoint = 0x82,
1851 .u = {
1852 .bulk = {
1853 .buffersize = 4096,
1854 }
1855 }
1856 }
Michael Krufky77eed212011-09-06 09:31:57 -03001857 }},
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001858 }
1859 },
Igor M. Liplianin5265ea52011-02-27 16:17:25 -03001860 .num_device_descs = 3,
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001861 .devices = {
1862 { "SU3000HD DVB-S USB2.0",
Jonathan Nieder27351b12011-12-23 19:00:45 -03001863 { &dw2102_table[GENIATECH_SU3000], NULL },
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001864 { NULL },
1865 },
Igor M. Liplianin2adc5912011-02-25 18:41:22 -03001866 { "Terratec Cinergy S2 USB HD",
Jonathan Nieder27351b12011-12-23 19:00:45 -03001867 { &dw2102_table[TERRATEC_CINERGY_S2], NULL },
Igor M. Liplianin2adc5912011-02-25 18:41:22 -03001868 { NULL },
1869 },
Igor M. Liplianin5265ea52011-02-27 16:17:25 -03001870 { "X3M TV SPC1400HD PCI",
Jonathan Nieder27351b12011-12-23 19:00:45 -03001871 { &dw2102_table[X3M_SPC1400HD], NULL },
Igor M. Liplianin5265ea52011-02-27 16:17:25 -03001872 { NULL },
1873 },
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001874 }
1875};
1876
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001877static int dw2102_probe(struct usb_interface *intf,
1878 const struct usb_device_id *id)
1879{
Thomas Meyer68dd9dd2011-11-17 18:43:40 -03001880 p1100 = kmemdup(&s6x0_properties,
1881 sizeof(struct dvb_usb_device_properties), GFP_KERNEL);
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001882 if (!p1100)
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001883 return -ENOMEM;
1884 /* copy default structure */
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001885 /* fill only different fields */
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001886 p1100->firmware = "dvb-usb-p1100.fw";
1887 p1100->devices[0] = d1100;
1888 p1100->rc.legacy.rc_map_table = rc_map_tbs_table;
1889 p1100->rc.legacy.rc_map_size = ARRAY_SIZE(rc_map_tbs_table);
Michael Krufky77eed212011-09-06 09:31:57 -03001890 p1100->adapter->fe[0].frontend_attach = stv0288_frontend_attach;
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001891
Thomas Meyer68dd9dd2011-11-17 18:43:40 -03001892 s660 = kmemdup(&s6x0_properties,
1893 sizeof(struct dvb_usb_device_properties), GFP_KERNEL);
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001894 if (!s660) {
1895 kfree(p1100);
1896 return -ENOMEM;
1897 }
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001898 s660->firmware = "dvb-usb-s660.fw";
Igor M. Liplianine8f50552011-02-25 18:41:23 -03001899 s660->num_device_descs = 3;
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001900 s660->devices[0] = d660;
Igor M. Liplianine8f50552011-02-25 18:41:23 -03001901 s660->devices[1] = d480_1;
1902 s660->devices[2] = d480_2;
Michael Krufky77eed212011-09-06 09:31:57 -03001903 s660->adapter->fe[0].frontend_attach = ds3000_frontend_attach;
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001904
Thomas Meyer68dd9dd2011-11-17 18:43:40 -03001905 p7500 = kmemdup(&s6x0_properties,
1906 sizeof(struct dvb_usb_device_properties), GFP_KERNEL);
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001907 if (!p7500) {
1908 kfree(p1100);
1909 kfree(s660);
1910 return -ENOMEM;
1911 }
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001912 p7500->firmware = "dvb-usb-p7500.fw";
1913 p7500->devices[0] = d7500;
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03001914 p7500->rc.legacy.rc_map_table = rc_map_tbs_table;
1915 p7500->rc.legacy.rc_map_size = ARRAY_SIZE(rc_map_tbs_table);
Michael Krufky77eed212011-09-06 09:31:57 -03001916 p7500->adapter->fe[0].frontend_attach = prof_7500_frontend_attach;
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001917
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001918 if (0 == dvb_usb_device_init(intf, &dw2102_properties,
1919 THIS_MODULE, NULL, adapter_nr) ||
1920 0 == dvb_usb_device_init(intf, &dw2104_properties,
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001921 THIS_MODULE, NULL, adapter_nr) ||
1922 0 == dvb_usb_device_init(intf, &dw3101_properties,
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001923 THIS_MODULE, NULL, adapter_nr) ||
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001924 0 == dvb_usb_device_init(intf, &s6x0_properties,
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001925 THIS_MODULE, NULL, adapter_nr) ||
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001926 0 == dvb_usb_device_init(intf, p1100,
1927 THIS_MODULE, NULL, adapter_nr) ||
1928 0 == dvb_usb_device_init(intf, s660,
1929 THIS_MODULE, NULL, adapter_nr) ||
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001930 0 == dvb_usb_device_init(intf, p7500,
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001931 THIS_MODULE, NULL, adapter_nr) ||
1932 0 == dvb_usb_device_init(intf, &su3000_properties,
1933 THIS_MODULE, NULL, adapter_nr))
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001934 return 0;
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001935
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001936 return -ENODEV;
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001937}
1938
1939static struct usb_driver dw2102_driver = {
1940 .name = "dw2102",
1941 .probe = dw2102_probe,
1942 .disconnect = dvb_usb_device_exit,
1943 .id_table = dw2102_table,
1944};
1945
Greg Kroah-Hartmanecb3b2b2011-11-18 09:46:12 -08001946module_usb_driver(dw2102_driver);
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001947
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");