blob: f61c5e367ea17b4c39f1bfe4a7d9f683382e2f31 [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"
Konstantin Dimitrov73f0af42012-12-23 19:25:38 -030025#include "ts2020.h"
Igor M. Liplianin141cc352009-11-27 14:37:35 -030026#include "ds3000.h"
27#include "stv0900.h"
28#include "stv6110.h"
29#include "stb6100.h"
30#include "stb6100_proc.h"
Igor M Liplianin7fd48282008-07-20 08:05:50 -030031
32#ifndef USB_PID_DW2102
33#define USB_PID_DW2102 0x2102
34#endif
35
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -030036#ifndef USB_PID_DW2104
37#define USB_PID_DW2104 0x2104
38#endif
39
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -030040#ifndef USB_PID_DW3101
41#define USB_PID_DW3101 0x3101
42#endif
43
Igor M. Liplianin4cc0edf2008-11-05 22:12:56 -030044#ifndef USB_PID_CINERGY_S
45#define USB_PID_CINERGY_S 0x0064
46#endif
47
Igor M. Liplianin141cc352009-11-27 14:37:35 -030048#ifndef USB_PID_TEVII_S630
49#define USB_PID_TEVII_S630 0xd630
50#endif
51
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -030052#ifndef USB_PID_TEVII_S650
53#define USB_PID_TEVII_S650 0xd650
54#endif
55
Igor M. Liplianin141cc352009-11-27 14:37:35 -030056#ifndef USB_PID_TEVII_S660
57#define USB_PID_TEVII_S660 0xd660
58#endif
59
Igor M. Liplianine8f50552011-02-25 18:41:23 -030060#ifndef USB_PID_TEVII_S480_1
61#define USB_PID_TEVII_S480_1 0xd481
62#endif
63
64#ifndef USB_PID_TEVII_S480_2
65#define USB_PID_TEVII_S480_2 0xd482
66#endif
67
Igor M. Liplianin141cc352009-11-27 14:37:35 -030068#ifndef USB_PID_PROF_1100
69#define USB_PID_PROF_1100 0xb012
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -030070#endif
71
Igor M. Liplianin21b007b2008-09-17 19:19:19 -030072#define DW210X_READ_MSG 0
73#define DW210X_WRITE_MSG 1
Igor M Liplianin7fd48282008-07-20 08:05:50 -030074
75#define REG_1F_SYMBOLRATE_BYTE0 0x1f
76#define REG_20_SYMBOLRATE_BYTE1 0x20
77#define REG_21_SYMBOLRATE_BYTE2 0x21
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -030078/* on my own*/
Igor M Liplianin7fd48282008-07-20 08:05:50 -030079#define DW2102_VOLTAGE_CTRL (0x1800)
Igor M. Liplianind2ffc442011-02-25 18:41:22 -030080#define SU3000_STREAM_CTRL (0x1900)
Igor M Liplianin7fd48282008-07-20 08:05:50 -030081#define DW2102_RC_QUERY (0x1a00)
Igor M. Liplianinfa8bae12011-02-25 18:41:22 -030082#define DW2102_LED_CTRL (0x1b00)
Igor M Liplianin7fd48282008-07-20 08:05:50 -030083
Rémi Cardona68236272012-09-28 08:59:32 -030084#define DW2101_FIRMWARE "dvb-usb-dw2101.fw"
85#define DW2102_FIRMWARE "dvb-usb-dw2102.fw"
86#define DW2104_FIRMWARE "dvb-usb-dw2104.fw"
87#define DW3101_FIRMWARE "dvb-usb-dw3101.fw"
88#define S630_FIRMWARE "dvb-usb-s630.fw"
89#define S660_FIRMWARE "dvb-usb-s660.fw"
90#define P1100_FIRMWARE "dvb-usb-p1100.fw"
91#define P7500_FIRMWARE "dvb-usb-p7500.fw"
92
Igor M. Liplianin141cc352009-11-27 14:37:35 -030093#define err_str "did not find the firmware file. (%s) " \
94 "Please see linux/Documentation/dvb/ for more details " \
95 "on firmware-problems."
96
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -030097struct rc_map_dvb_usb_table_table {
98 struct rc_map_table *rc_keys;
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -030099 int rc_keys_size;
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300100};
101
Igor M. Liplianind2ffc442011-02-25 18:41:22 -0300102struct su3000_state {
103 u8 initialized;
104};
105
Igor M. Liplianin52c506e2011-02-25 18:41:23 -0300106struct s6x0_state {
107 int (*old_set_voltage)(struct dvb_frontend *f, fe_sec_voltage_t v);
108};
109
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300110/* debug */
111static int dvb_usb_dw2102_debug;
112module_param_named(debug, dvb_usb_dw2102_debug, int, 0644);
Igor M. Liplianin8a8dad72009-06-13 08:10:24 -0300113MODULE_PARM_DESC(debug, "set debugging level (1=info 2=xfer 4=rc(or-able))."
114 DVB_USB_DEBUG_STATUS);
115
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -0300116/* keymaps */
117static int ir_keymap;
118module_param_named(keymap, ir_keymap, int, 0644);
Igor M. Liplianinfeb16e92011-02-25 18:41:22 -0300119MODULE_PARM_DESC(keymap, "set keymap 0=default 1=dvbworld 2=tevii 3=tbs ..."
120 " 256=none");
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300121
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300122/* demod probe */
123static int demod_probe = 1;
124module_param_named(demod, demod_probe, int, 0644);
125MODULE_PARM_DESC(demod, "demod to probe (1=cx24116 2=stv0903+stv6110 "
126 "4=stv0903+stb6100(or-able)).");
127
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300128DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
129
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300130static int dw210x_op_rw(struct usb_device *dev, u8 request, u16 value,
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300131 u16 index, u8 * data, u16 len, int flags)
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300132{
133 int ret;
Florian Micklerb47b8502011-03-21 15:33:44 -0300134 u8 *u8buf;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300135 unsigned int pipe = (flags == DW210X_READ_MSG) ?
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300136 usb_rcvctrlpipe(dev, 0) : usb_sndctrlpipe(dev, 0);
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300137 u8 request_type = (flags == DW210X_READ_MSG) ? USB_DIR_IN : USB_DIR_OUT;
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300138
Florian Micklerb47b8502011-03-21 15:33:44 -0300139 u8buf = kmalloc(len, GFP_KERNEL);
140 if (!u8buf)
141 return -ENOMEM;
142
143
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300144 if (flags == DW210X_WRITE_MSG)
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300145 memcpy(u8buf, data, len);
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300146 ret = usb_control_msg(dev, pipe, request, request_type | USB_TYPE_VENDOR,
147 value, index , u8buf, len, 2000);
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300148
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300149 if (flags == DW210X_READ_MSG)
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300150 memcpy(data, u8buf, len);
Florian Micklerb47b8502011-03-21 15:33:44 -0300151
152 kfree(u8buf);
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300153 return ret;
154}
155
156/* I2C */
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300157static int dw2102_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
158 int num)
159{
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -0300160 struct dvb_usb_device *d = i2c_get_adapdata(adap);
Hans Verkuild51dbec2012-04-20 03:30:11 -0300161 int i = 0;
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300162 u8 buf6[] = {0x2c, 0x05, 0xc0, 0, 0, 0, 0};
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300163 u16 value;
164
165 if (!d)
166 return -ENODEV;
167 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
168 return -EAGAIN;
169
170 switch (num) {
171 case 2:
172 /* read stv0299 register */
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300173 value = msg[0].buf[0];/* register */
174 for (i = 0; i < msg[1].len; i++) {
Hans Verkuild51dbec2012-04-20 03:30:11 -0300175 dw210x_op_rw(d->udev, 0xb5, value + i, 0,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300176 buf6, 2, DW210X_READ_MSG);
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300177 msg[1].buf[i] = buf6[0];
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300178 }
179 break;
180 case 1:
181 switch (msg[0].addr) {
182 case 0x68:
183 /* write to stv0299 register */
184 buf6[0] = 0x2a;
185 buf6[1] = msg[0].buf[0];
186 buf6[2] = msg[0].buf[1];
Hans Verkuild51dbec2012-04-20 03:30:11 -0300187 dw210x_op_rw(d->udev, 0xb2, 0, 0,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300188 buf6, 3, DW210X_WRITE_MSG);
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300189 break;
190 case 0x60:
191 if (msg[0].flags == 0) {
192 /* write to tuner pll */
193 buf6[0] = 0x2c;
194 buf6[1] = 5;
195 buf6[2] = 0xc0;
196 buf6[3] = msg[0].buf[0];
197 buf6[4] = msg[0].buf[1];
198 buf6[5] = msg[0].buf[2];
199 buf6[6] = msg[0].buf[3];
Hans Verkuild51dbec2012-04-20 03:30:11 -0300200 dw210x_op_rw(d->udev, 0xb2, 0, 0,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300201 buf6, 7, DW210X_WRITE_MSG);
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300202 } else {
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300203 /* read from tuner */
Hans Verkuild51dbec2012-04-20 03:30:11 -0300204 dw210x_op_rw(d->udev, 0xb5, 0, 0,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300205 buf6, 1, DW210X_READ_MSG);
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300206 msg[0].buf[0] = buf6[0];
207 }
208 break;
209 case (DW2102_RC_QUERY):
Hans Verkuild51dbec2012-04-20 03:30:11 -0300210 dw210x_op_rw(d->udev, 0xb8, 0, 0,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300211 buf6, 2, DW210X_READ_MSG);
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300212 msg[0].buf[0] = buf6[0];
213 msg[0].buf[1] = buf6[1];
214 break;
215 case (DW2102_VOLTAGE_CTRL):
216 buf6[0] = 0x30;
217 buf6[1] = msg[0].buf[0];
Hans Verkuild51dbec2012-04-20 03:30:11 -0300218 dw210x_op_rw(d->udev, 0xb2, 0, 0,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300219 buf6, 2, DW210X_WRITE_MSG);
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300220 break;
221 }
222
223 break;
224 }
225
226 mutex_unlock(&d->i2c_mutex);
227 return num;
228}
229
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300230static int dw2102_serit_i2c_transfer(struct i2c_adapter *adap,
231 struct i2c_msg msg[], int num)
232{
233 struct dvb_usb_device *d = i2c_get_adapdata(adap);
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300234 u8 buf6[] = {0, 0, 0, 0, 0, 0, 0};
235
236 if (!d)
237 return -ENODEV;
238 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
239 return -EAGAIN;
240
241 switch (num) {
242 case 2:
243 /* read si2109 register by number */
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300244 buf6[0] = msg[0].addr << 1;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300245 buf6[1] = msg[0].len;
246 buf6[2] = msg[0].buf[0];
Hans Verkuild51dbec2012-04-20 03:30:11 -0300247 dw210x_op_rw(d->udev, 0xc2, 0, 0,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300248 buf6, msg[0].len + 2, DW210X_WRITE_MSG);
249 /* read si2109 register */
Hans Verkuild51dbec2012-04-20 03:30:11 -0300250 dw210x_op_rw(d->udev, 0xc3, 0xd0, 0,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300251 buf6, msg[1].len + 2, DW210X_READ_MSG);
252 memcpy(msg[1].buf, buf6 + 2, msg[1].len);
253
254 break;
255 case 1:
256 switch (msg[0].addr) {
257 case 0x68:
258 /* write to si2109 register */
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300259 buf6[0] = msg[0].addr << 1;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300260 buf6[1] = msg[0].len;
261 memcpy(buf6 + 2, msg[0].buf, msg[0].len);
Hans Verkuild51dbec2012-04-20 03:30:11 -0300262 dw210x_op_rw(d->udev, 0xc2, 0, 0, buf6,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300263 msg[0].len + 2, DW210X_WRITE_MSG);
264 break;
265 case(DW2102_RC_QUERY):
Hans Verkuild51dbec2012-04-20 03:30:11 -0300266 dw210x_op_rw(d->udev, 0xb8, 0, 0,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300267 buf6, 2, DW210X_READ_MSG);
268 msg[0].buf[0] = buf6[0];
269 msg[0].buf[1] = buf6[1];
270 break;
271 case(DW2102_VOLTAGE_CTRL):
272 buf6[0] = 0x30;
273 buf6[1] = msg[0].buf[0];
Hans Verkuild51dbec2012-04-20 03:30:11 -0300274 dw210x_op_rw(d->udev, 0xb2, 0, 0,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300275 buf6, 2, DW210X_WRITE_MSG);
276 break;
277 }
278 break;
279 }
280
281 mutex_unlock(&d->i2c_mutex);
282 return num;
283}
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -0300284
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -0300285static int dw2102_earda_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], int num)
286{
287 struct dvb_usb_device *d = i2c_get_adapdata(adap);
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -0300288
289 if (!d)
290 return -ENODEV;
291 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
292 return -EAGAIN;
293
294 switch (num) {
295 case 2: {
296 /* read */
297 /* first write first register number */
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -0300298 u8 ibuf[msg[1].len + 2], obuf[3];
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300299 obuf[0] = msg[0].addr << 1;
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -0300300 obuf[1] = msg[0].len;
301 obuf[2] = msg[0].buf[0];
Hans Verkuild51dbec2012-04-20 03:30:11 -0300302 dw210x_op_rw(d->udev, 0xc2, 0, 0,
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -0300303 obuf, msg[0].len + 2, DW210X_WRITE_MSG);
304 /* second read registers */
Hans Verkuild51dbec2012-04-20 03:30:11 -0300305 dw210x_op_rw(d->udev, 0xc3, 0xd1 , 0,
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -0300306 ibuf, msg[1].len + 2, DW210X_READ_MSG);
307 memcpy(msg[1].buf, ibuf + 2, msg[1].len);
308
309 break;
310 }
311 case 1:
312 switch (msg[0].addr) {
313 case 0x68: {
314 /* write to register */
315 u8 obuf[msg[0].len + 2];
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300316 obuf[0] = msg[0].addr << 1;
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -0300317 obuf[1] = msg[0].len;
318 memcpy(obuf + 2, msg[0].buf, msg[0].len);
Hans Verkuild51dbec2012-04-20 03:30:11 -0300319 dw210x_op_rw(d->udev, 0xc2, 0, 0,
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -0300320 obuf, msg[0].len + 2, DW210X_WRITE_MSG);
321 break;
322 }
323 case 0x61: {
324 /* write to tuner */
325 u8 obuf[msg[0].len + 2];
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300326 obuf[0] = msg[0].addr << 1;
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -0300327 obuf[1] = msg[0].len;
328 memcpy(obuf + 2, msg[0].buf, msg[0].len);
Hans Verkuild51dbec2012-04-20 03:30:11 -0300329 dw210x_op_rw(d->udev, 0xc2, 0, 0,
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -0300330 obuf, msg[0].len + 2, DW210X_WRITE_MSG);
331 break;
332 }
333 case(DW2102_RC_QUERY): {
334 u8 ibuf[2];
Hans Verkuild51dbec2012-04-20 03:30:11 -0300335 dw210x_op_rw(d->udev, 0xb8, 0, 0,
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -0300336 ibuf, 2, DW210X_READ_MSG);
337 memcpy(msg[0].buf, ibuf , 2);
338 break;
339 }
340 case(DW2102_VOLTAGE_CTRL): {
341 u8 obuf[2];
342 obuf[0] = 0x30;
343 obuf[1] = msg[0].buf[0];
Hans Verkuild51dbec2012-04-20 03:30:11 -0300344 dw210x_op_rw(d->udev, 0xb2, 0, 0,
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -0300345 obuf, 2, DW210X_WRITE_MSG);
346 break;
347 }
348 }
349
350 break;
351 }
352
353 mutex_unlock(&d->i2c_mutex);
354 return num;
355}
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300356
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300357static int dw2104_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], int num)
358{
359 struct dvb_usb_device *d = i2c_get_adapdata(adap);
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300360 int len, i, j;
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300361
362 if (!d)
363 return -ENODEV;
364 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
365 return -EAGAIN;
366
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300367 for (j = 0; j < num; j++) {
368 switch (msg[j].addr) {
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300369 case(DW2102_RC_QUERY): {
370 u8 ibuf[2];
Hans Verkuild51dbec2012-04-20 03:30:11 -0300371 dw210x_op_rw(d->udev, 0xb8, 0, 0,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300372 ibuf, 2, DW210X_READ_MSG);
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300373 memcpy(msg[j].buf, ibuf , 2);
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300374 break;
375 }
376 case(DW2102_VOLTAGE_CTRL): {
377 u8 obuf[2];
378 obuf[0] = 0x30;
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300379 obuf[1] = msg[j].buf[0];
Hans Verkuild51dbec2012-04-20 03:30:11 -0300380 dw210x_op_rw(d->udev, 0xb2, 0, 0,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300381 obuf, 2, DW210X_WRITE_MSG);
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300382 break;
383 }
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300384 /*case 0x55: cx24116
385 case 0x6a: stv0903
386 case 0x68: ds3000, stv0903
387 case 0x60: ts2020, stv6110, stb6100 */
388 default: {
389 if (msg[j].flags == I2C_M_RD) {
390 /* read registers */
391 u8 ibuf[msg[j].len + 2];
Hans Verkuild51dbec2012-04-20 03:30:11 -0300392 dw210x_op_rw(d->udev, 0xc3,
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300393 (msg[j].addr << 1) + 1, 0,
394 ibuf, msg[j].len + 2,
395 DW210X_READ_MSG);
396 memcpy(msg[j].buf, ibuf + 2, msg[j].len);
397 mdelay(10);
398 } else if (((msg[j].buf[0] == 0xb0) &&
399 (msg[j].addr == 0x68)) ||
400 ((msg[j].buf[0] == 0xf7) &&
401 (msg[j].addr == 0x55))) {
402 /* write firmware */
403 u8 obuf[19];
404 obuf[0] = msg[j].addr << 1;
405 obuf[1] = (msg[j].len > 15 ? 17 : msg[j].len);
406 obuf[2] = msg[j].buf[0];
407 len = msg[j].len - 1;
408 i = 1;
409 do {
410 memcpy(obuf + 3, msg[j].buf + i,
411 (len > 16 ? 16 : len));
Hans Verkuild51dbec2012-04-20 03:30:11 -0300412 dw210x_op_rw(d->udev, 0xc2, 0, 0,
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300413 obuf, (len > 16 ? 16 : len) + 3,
414 DW210X_WRITE_MSG);
415 i += 16;
416 len -= 16;
417 } while (len > 0);
418 } else {
419 /* write registers */
420 u8 obuf[msg[j].len + 2];
421 obuf[0] = msg[j].addr << 1;
422 obuf[1] = msg[j].len;
423 memcpy(obuf + 2, msg[j].buf, msg[j].len);
Hans Verkuild51dbec2012-04-20 03:30:11 -0300424 dw210x_op_rw(d->udev, 0xc2, 0, 0,
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300425 obuf, msg[j].len + 2,
426 DW210X_WRITE_MSG);
427 }
428 break;
429 }
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300430 }
431
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300432 }
433
434 mutex_unlock(&d->i2c_mutex);
435 return num;
436}
437
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -0300438static int dw3101_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
439 int num)
440{
441 struct dvb_usb_device *d = i2c_get_adapdata(adap);
Hans Verkuild51dbec2012-04-20 03:30:11 -0300442 int i;
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -0300443
444 if (!d)
445 return -ENODEV;
446 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
447 return -EAGAIN;
448
449 switch (num) {
450 case 2: {
451 /* read */
452 /* first write first register number */
453 u8 ibuf[msg[1].len + 2], obuf[3];
454 obuf[0] = msg[0].addr << 1;
455 obuf[1] = msg[0].len;
456 obuf[2] = msg[0].buf[0];
Hans Verkuild51dbec2012-04-20 03:30:11 -0300457 dw210x_op_rw(d->udev, 0xc2, 0, 0,
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -0300458 obuf, msg[0].len + 2, DW210X_WRITE_MSG);
459 /* second read registers */
Hans Verkuild51dbec2012-04-20 03:30:11 -0300460 dw210x_op_rw(d->udev, 0xc3, 0x19 , 0,
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -0300461 ibuf, msg[1].len + 2, DW210X_READ_MSG);
462 memcpy(msg[1].buf, ibuf + 2, msg[1].len);
463
464 break;
465 }
466 case 1:
467 switch (msg[0].addr) {
468 case 0x60:
469 case 0x0c: {
470 /* write to register */
471 u8 obuf[msg[0].len + 2];
472 obuf[0] = msg[0].addr << 1;
473 obuf[1] = msg[0].len;
474 memcpy(obuf + 2, msg[0].buf, msg[0].len);
Hans Verkuild51dbec2012-04-20 03:30:11 -0300475 dw210x_op_rw(d->udev, 0xc2, 0, 0,
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -0300476 obuf, msg[0].len + 2, DW210X_WRITE_MSG);
477 break;
478 }
479 case(DW2102_RC_QUERY): {
480 u8 ibuf[2];
Hans Verkuild51dbec2012-04-20 03:30:11 -0300481 dw210x_op_rw(d->udev, 0xb8, 0, 0,
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -0300482 ibuf, 2, DW210X_READ_MSG);
483 memcpy(msg[0].buf, ibuf , 2);
484 break;
485 }
486 }
487
488 break;
489 }
490
491 for (i = 0; i < num; i++) {
492 deb_xfer("%02x:%02x: %s ", i, msg[i].addr,
493 msg[i].flags == 0 ? ">>>" : "<<<");
494 debug_dump(msg[i].buf, msg[i].len, deb_xfer);
495 }
496
497 mutex_unlock(&d->i2c_mutex);
498 return num;
499}
500
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300501static int s6x0_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300502 int num)
503{
504 struct dvb_usb_device *d = i2c_get_adapdata(adap);
Julia Lawall21ead032009-12-22 18:00:07 -0300505 struct usb_device *udev;
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300506 int len, i, j;
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300507
508 if (!d)
509 return -ENODEV;
Julia Lawall21ead032009-12-22 18:00:07 -0300510 udev = d->udev;
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300511 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
512 return -EAGAIN;
513
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300514 for (j = 0; j < num; j++) {
515 switch (msg[j].addr) {
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300516 case (DW2102_RC_QUERY): {
Igor M. Liplianin5a530cb2011-02-25 18:41:23 -0300517 u8 ibuf[5];
Hans Verkuild51dbec2012-04-20 03:30:11 -0300518 dw210x_op_rw(d->udev, 0xb8, 0, 0,
Igor M. Liplianin5a530cb2011-02-25 18:41:23 -0300519 ibuf, 5, DW210X_READ_MSG);
520 memcpy(msg[j].buf, ibuf + 3, 2);
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300521 break;
522 }
523 case (DW2102_VOLTAGE_CTRL): {
524 u8 obuf[2];
Igor M. Liplianincd79d332009-12-14 20:24:56 -0300525
526 obuf[0] = 1;
527 obuf[1] = msg[j].buf[1];/* off-on */
Hans Verkuild51dbec2012-04-20 03:30:11 -0300528 dw210x_op_rw(d->udev, 0x8a, 0, 0,
Igor M. Liplianincd79d332009-12-14 20:24:56 -0300529 obuf, 2, DW210X_WRITE_MSG);
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300530 obuf[0] = 3;
Igor M. Liplianincd79d332009-12-14 20:24:56 -0300531 obuf[1] = msg[j].buf[0];/* 13v-18v */
Hans Verkuild51dbec2012-04-20 03:30:11 -0300532 dw210x_op_rw(d->udev, 0x8a, 0, 0,
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300533 obuf, 2, DW210X_WRITE_MSG);
534 break;
535 }
Igor M. Liplianinfa8bae12011-02-25 18:41:22 -0300536 case (DW2102_LED_CTRL): {
537 u8 obuf[2];
538
539 obuf[0] = 5;
540 obuf[1] = msg[j].buf[0];
Hans Verkuild51dbec2012-04-20 03:30:11 -0300541 dw210x_op_rw(d->udev, 0x8a, 0, 0,
Igor M. Liplianinfa8bae12011-02-25 18:41:22 -0300542 obuf, 2, DW210X_WRITE_MSG);
543 break;
544 }
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300545 /*case 0x55: cx24116
546 case 0x6a: stv0903
547 case 0x68: ds3000, stv0903
548 case 0x60: ts2020, stv6110, stb6100
549 case 0xa0: eeprom */
550 default: {
551 if (msg[j].flags == I2C_M_RD) {
552 /* read registers */
553 u8 ibuf[msg[j].len];
Hans Verkuild51dbec2012-04-20 03:30:11 -0300554 dw210x_op_rw(d->udev, 0x91, 0, 0,
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300555 ibuf, msg[j].len,
556 DW210X_READ_MSG);
557 memcpy(msg[j].buf, ibuf, msg[j].len);
558 break;
559 } else if ((msg[j].buf[0] == 0xb0) &&
560 (msg[j].addr == 0x68)) {
561 /* write firmware */
562 u8 obuf[19];
563 obuf[0] = (msg[j].len > 16 ?
564 18 : msg[j].len + 1);
565 obuf[1] = msg[j].addr << 1;
566 obuf[2] = msg[j].buf[0];
567 len = msg[j].len - 1;
568 i = 1;
569 do {
570 memcpy(obuf + 3, msg[j].buf + i,
571 (len > 16 ? 16 : len));
Hans Verkuild51dbec2012-04-20 03:30:11 -0300572 dw210x_op_rw(d->udev, 0x80, 0, 0,
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300573 obuf, (len > 16 ? 16 : len) + 3,
574 DW210X_WRITE_MSG);
575 i += 16;
576 len -= 16;
577 } while (len > 0);
Igor M. Liplianina84adf42011-02-27 16:18:38 -0300578 } else if (j < (num - 1)) {
Igor M. Liplianincd79d332009-12-14 20:24:56 -0300579 /* write register addr before read */
580 u8 obuf[msg[j].len + 2];
581 obuf[0] = msg[j + 1].len;
582 obuf[1] = (msg[j].addr << 1);
583 memcpy(obuf + 2, msg[j].buf, msg[j].len);
Hans Verkuild51dbec2012-04-20 03:30:11 -0300584 dw210x_op_rw(d->udev,
Igor M. Liplianina84adf42011-02-27 16:18:38 -0300585 udev->descriptor.idProduct ==
586 0x7500 ? 0x92 : 0x90, 0, 0,
Igor M. Liplianincd79d332009-12-14 20:24:56 -0300587 obuf, msg[j].len + 2,
588 DW210X_WRITE_MSG);
589 break;
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300590 } else {
591 /* write registers */
592 u8 obuf[msg[j].len + 2];
593 obuf[0] = msg[j].len + 1;
594 obuf[1] = (msg[j].addr << 1);
595 memcpy(obuf + 2, msg[j].buf, msg[j].len);
Hans Verkuild51dbec2012-04-20 03:30:11 -0300596 dw210x_op_rw(d->udev, 0x80, 0, 0,
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300597 obuf, msg[j].len + 2,
598 DW210X_WRITE_MSG);
599 break;
600 }
601 break;
602 }
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300603 }
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300604 }
605
606 mutex_unlock(&d->i2c_mutex);
607 return num;
608}
609
Igor M. Liplianind2ffc442011-02-25 18:41:22 -0300610static int su3000_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
611 int num)
612{
613 struct dvb_usb_device *d = i2c_get_adapdata(adap);
614 u8 obuf[0x40], ibuf[0x40];
615
616 if (!d)
617 return -ENODEV;
618 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
619 return -EAGAIN;
620
621 switch (num) {
622 case 1:
623 switch (msg[0].addr) {
624 case SU3000_STREAM_CTRL:
625 obuf[0] = msg[0].buf[0] + 0x36;
626 obuf[1] = 3;
627 obuf[2] = 0;
628 if (dvb_usb_generic_rw(d, obuf, 3, ibuf, 0, 0) < 0)
629 err("i2c transfer failed.");
630 break;
631 case DW2102_RC_QUERY:
632 obuf[0] = 0x10;
633 if (dvb_usb_generic_rw(d, obuf, 1, ibuf, 2, 0) < 0)
634 err("i2c transfer failed.");
635 msg[0].buf[1] = ibuf[0];
636 msg[0].buf[0] = ibuf[1];
637 break;
638 default:
639 /* always i2c write*/
640 obuf[0] = 0x08;
641 obuf[1] = msg[0].addr;
642 obuf[2] = msg[0].len;
643
644 memcpy(&obuf[3], msg[0].buf, msg[0].len);
645
646 if (dvb_usb_generic_rw(d, obuf, msg[0].len + 3,
647 ibuf, 1, 0) < 0)
648 err("i2c transfer failed.");
649
650 }
651 break;
652 case 2:
653 /* always i2c read */
654 obuf[0] = 0x09;
655 obuf[1] = msg[0].len;
656 obuf[2] = msg[1].len;
657 obuf[3] = msg[0].addr;
658 memcpy(&obuf[4], msg[0].buf, msg[0].len);
659
660 if (dvb_usb_generic_rw(d, obuf, msg[0].len + 4,
661 ibuf, msg[1].len + 1, 0) < 0)
662 err("i2c transfer failed.");
663
664 memcpy(msg[1].buf, &ibuf[1], msg[1].len);
665 break;
666 default:
667 warn("more than 2 i2c messages at a time is not handled yet.");
668 break;
669 }
670 mutex_unlock(&d->i2c_mutex);
671 return num;
672}
673
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300674static u32 dw210x_i2c_func(struct i2c_adapter *adapter)
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300675{
676 return I2C_FUNC_I2C;
677}
678
679static struct i2c_algorithm dw2102_i2c_algo = {
680 .master_xfer = dw2102_i2c_transfer,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300681 .functionality = dw210x_i2c_func,
682};
683
684static struct i2c_algorithm dw2102_serit_i2c_algo = {
685 .master_xfer = dw2102_serit_i2c_transfer,
686 .functionality = dw210x_i2c_func,
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300687};
688
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -0300689static struct i2c_algorithm dw2102_earda_i2c_algo = {
690 .master_xfer = dw2102_earda_i2c_transfer,
691 .functionality = dw210x_i2c_func,
692};
693
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300694static struct i2c_algorithm dw2104_i2c_algo = {
695 .master_xfer = dw2104_i2c_transfer,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300696 .functionality = dw210x_i2c_func,
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300697};
698
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -0300699static struct i2c_algorithm dw3101_i2c_algo = {
700 .master_xfer = dw3101_i2c_transfer,
701 .functionality = dw210x_i2c_func,
702};
703
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300704static struct i2c_algorithm s6x0_i2c_algo = {
705 .master_xfer = s6x0_i2c_transfer,
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300706 .functionality = dw210x_i2c_func,
707};
708
Igor M. Liplianind2ffc442011-02-25 18:41:22 -0300709static struct i2c_algorithm su3000_i2c_algo = {
710 .master_xfer = su3000_i2c_transfer,
711 .functionality = dw210x_i2c_func,
712};
713
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300714static int dw210x_read_mac_address(struct dvb_usb_device *d, u8 mac[6])
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300715{
716 int i;
717 u8 ibuf[] = {0, 0};
718 u8 eeprom[256], eepromline[16];
719
720 for (i = 0; i < 256; i++) {
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300721 if (dw210x_op_rw(d->udev, 0xb6, 0xa0 , i, ibuf, 2, DW210X_READ_MSG) < 0) {
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300722 err("read eeprom failed.");
723 return -1;
724 } else {
725 eepromline[i%16] = ibuf[0];
726 eeprom[i] = ibuf[0];
727 }
728 if ((i % 16) == 15) {
729 deb_xfer("%02x: ", i - 15);
730 debug_dump(eepromline, 16, deb_xfer);
731 }
732 }
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -0300733
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300734 memcpy(mac, eeprom + 8, 6);
735 return 0;
736};
737
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300738static int s6x0_read_mac_address(struct dvb_usb_device *d, u8 mac[6])
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300739{
740 int i, ret;
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300741 u8 ibuf[] = { 0 }, obuf[] = { 0 };
742 u8 eeprom[256], eepromline[16];
743 struct i2c_msg msg[] = {
744 {
745 .addr = 0xa0 >> 1,
746 .flags = 0,
747 .buf = obuf,
748 .len = 1,
749 }, {
750 .addr = 0xa0 >> 1,
751 .flags = I2C_M_RD,
752 .buf = ibuf,
753 .len = 1,
754 }
755 };
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300756
757 for (i = 0; i < 256; i++) {
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300758 obuf[0] = i;
759 ret = s6x0_i2c_transfer(&d->i2c_adap, msg, 2);
760 if (ret != 2) {
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300761 err("read eeprom failed.");
762 return -1;
763 } else {
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300764 eepromline[i % 16] = ibuf[0];
765 eeprom[i] = ibuf[0];
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300766 }
767
768 if ((i % 16) == 15) {
769 deb_xfer("%02x: ", i - 15);
770 debug_dump(eepromline, 16, deb_xfer);
771 }
772 }
773
774 memcpy(mac, eeprom + 16, 6);
775 return 0;
776};
777
Igor M. Liplianind2ffc442011-02-25 18:41:22 -0300778static int su3000_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
779{
780 static u8 command_start[] = {0x00};
781 static u8 command_stop[] = {0x01};
782 struct i2c_msg msg = {
783 .addr = SU3000_STREAM_CTRL,
784 .flags = 0,
785 .buf = onoff ? command_start : command_stop,
786 .len = 1
787 };
788
789 i2c_transfer(&adap->dev->i2c_adap, &msg, 1);
790
791 return 0;
792}
793
794static int su3000_power_ctrl(struct dvb_usb_device *d, int i)
795{
796 struct su3000_state *state = (struct su3000_state *)d->priv;
797 u8 obuf[] = {0xde, 0};
798
799 info("%s: %d, initialized %d\n", __func__, i, state->initialized);
800
801 if (i && !state->initialized) {
802 state->initialized = 1;
803 /* reset board */
804 dvb_usb_generic_rw(d, obuf, 2, NULL, 0, 0);
805 }
806
807 return 0;
808}
809
810static int su3000_read_mac_address(struct dvb_usb_device *d, u8 mac[6])
811{
812 int i;
813 u8 obuf[] = { 0x1f, 0xf0 };
814 u8 ibuf[] = { 0 };
815 struct i2c_msg msg[] = {
816 {
817 .addr = 0x51,
818 .flags = 0,
819 .buf = obuf,
820 .len = 2,
821 }, {
822 .addr = 0x51,
823 .flags = I2C_M_RD,
824 .buf = ibuf,
825 .len = 1,
826
827 }
828 };
829
830 for (i = 0; i < 6; i++) {
831 obuf[1] = 0xf0 + i;
832 if (i2c_transfer(&d->i2c_adap, msg, 2) != 2)
833 break;
834 else
835 mac[i] = ibuf[0];
836
837 debug_dump(mac, 6, printk);
838 }
839
840 return 0;
841}
842
843static int su3000_identify_state(struct usb_device *udev,
844 struct dvb_usb_device_properties *props,
845 struct dvb_usb_device_description **desc,
846 int *cold)
847{
848 info("%s\n", __func__);
849
850 *cold = 0;
851 return 0;
852}
853
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300854static int dw210x_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300855{
Igor M. Liplianincd79d332009-12-14 20:24:56 -0300856 static u8 command_13v[] = {0x00, 0x01};
857 static u8 command_18v[] = {0x01, 0x01};
858 static u8 command_off[] = {0x00, 0x00};
859 struct i2c_msg msg = {
860 .addr = DW2102_VOLTAGE_CTRL,
861 .flags = 0,
862 .buf = command_off,
863 .len = 2,
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300864 };
865
866 struct dvb_usb_adapter *udev_adap =
867 (struct dvb_usb_adapter *)(fe->dvb->priv);
868 if (voltage == SEC_VOLTAGE_18)
Igor M. Liplianincd79d332009-12-14 20:24:56 -0300869 msg.buf = command_18v;
870 else if (voltage == SEC_VOLTAGE_13)
871 msg.buf = command_13v;
872
873 i2c_transfer(&udev_adap->dev->i2c_adap, &msg, 1);
874
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300875 return 0;
876}
877
Igor M. Liplianin52c506e2011-02-25 18:41:23 -0300878static int s660_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
879{
880 struct dvb_usb_adapter *d =
881 (struct dvb_usb_adapter *)(fe->dvb->priv);
882 struct s6x0_state *st = (struct s6x0_state *)d->dev->priv;
883
884 dw210x_set_voltage(fe, voltage);
885 if (st->old_set_voltage)
886 st->old_set_voltage(fe, voltage);
887
888 return 0;
889}
890
Igor M. Liplianinfa8bae12011-02-25 18:41:22 -0300891static void dw210x_led_ctrl(struct dvb_frontend *fe, int offon)
892{
893 static u8 led_off[] = { 0 };
894 static u8 led_on[] = { 1 };
895 struct i2c_msg msg = {
896 .addr = DW2102_LED_CTRL,
897 .flags = 0,
898 .buf = led_off,
899 .len = 1
900 };
901 struct dvb_usb_adapter *udev_adap =
902 (struct dvb_usb_adapter *)(fe->dvb->priv);
903
904 if (offon)
905 msg.buf = led_on;
906 i2c_transfer(&udev_adap->dev->i2c_adap, &msg, 1);
907}
908
Igor M. Liplianind4305c62008-10-17 13:45:55 -0300909static struct stv0299_config sharp_z0194a_config = {
910 .demod_address = 0x68,
911 .inittab = sharp_z0194a_inittab,
912 .mclk = 88000000UL,
913 .invert = 1,
914 .skip_reinit = 0,
915 .lock_output = STV0299_LOCKOUTPUT_1,
916 .volt13_op0_op1 = STV0299_VOLT13_OP1,
917 .min_delay_ms = 100,
918 .set_symbol_rate = sharp_z0194a_set_symbol_rate,
919};
920
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300921static struct cx24116_config dw2104_config = {
922 .demod_address = 0x55,
Igor M. Liplianincc8c4f32008-09-09 13:57:47 -0300923 .mpg_clk_pos_pol = 0x01,
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300924};
925
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300926static struct si21xx_config serit_sp1511lhb_config = {
927 .demod_address = 0x68,
928 .min_delay_ms = 100,
929
930};
931
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -0300932static struct tda10023_config dw3101_tda10023_config = {
933 .demod_address = 0x0c,
934 .invert = 1,
935};
936
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300937static struct mt312_config zl313_config = {
938 .demod_address = 0x0e,
939};
940
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300941static struct ds3000_config dw2104_ds3000_config = {
942 .demod_address = 0x68,
943};
944
Konstantin Dimitrov73f0af42012-12-23 19:25:38 -0300945static struct ts2020_config dw2104_ts2020_config = {
946 .tuner_address = 0x60,
947};
948
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300949static struct stv0900_config dw2104a_stv0900_config = {
950 .demod_address = 0x6a,
951 .demod_mode = 0,
952 .xtal = 27000000,
953 .clkmode = 3,/* 0-CLKI, 2-XTALI, else AUTO */
954 .diseqc_mode = 2,/* 2/3 PWM */
955 .tun1_maddress = 0,/* 0x60 */
956 .tun1_adc = 0,/* 2 Vpp */
957 .path1_mode = 3,
958};
959
960static struct stb6100_config dw2104a_stb6100_config = {
961 .tuner_address = 0x60,
962 .refclock = 27000000,
963};
964
965static struct stv0900_config dw2104_stv0900_config = {
966 .demod_address = 0x68,
967 .demod_mode = 0,
968 .xtal = 8000000,
969 .clkmode = 3,
970 .diseqc_mode = 2,
971 .tun1_maddress = 0,
972 .tun1_adc = 1,/* 1 Vpp */
973 .path1_mode = 3,
974};
975
976static struct stv6110_config dw2104_stv6110_config = {
977 .i2c_address = 0x60,
978 .mclk = 16000000,
979 .clk_div = 1,
980};
981
Igor M. Liplianincd79d332009-12-14 20:24:56 -0300982static struct stv0900_config prof_7500_stv0900_config = {
983 .demod_address = 0x6a,
984 .demod_mode = 0,
985 .xtal = 27000000,
986 .clkmode = 3,/* 0-CLKI, 2-XTALI, else AUTO */
987 .diseqc_mode = 2,/* 2/3 PWM */
988 .tun1_maddress = 0,/* 0x60 */
989 .tun1_adc = 0,/* 2 Vpp */
990 .path1_mode = 3,
991 .tun1_type = 3,
Igor M. Liplianinfa8bae12011-02-25 18:41:22 -0300992 .set_lock_led = dw210x_led_ctrl,
Igor M. Liplianincd79d332009-12-14 20:24:56 -0300993};
994
Igor M. Liplianind2ffc442011-02-25 18:41:22 -0300995static struct ds3000_config su3000_ds3000_config = {
996 .demod_address = 0x68,
997 .ci_mode = 1,
998};
999
Konstantin Dimitrov73f0af42012-12-23 19:25:38 -03001000static struct ts2020_config su3000_ts2020_config = {
1001 .tuner_address = 0x60,
1002};
1003
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001004static int dw2104_frontend_attach(struct dvb_usb_adapter *d)
1005{
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001006 struct dvb_tuner_ops *tuner_ops = NULL;
1007
1008 if (demod_probe & 4) {
Michael Krufky77eed212011-09-06 09:31:57 -03001009 d->fe_adap[0].fe = dvb_attach(stv0900_attach, &dw2104a_stv0900_config,
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001010 &d->dev->i2c_adap, 0);
Michael Krufky77eed212011-09-06 09:31:57 -03001011 if (d->fe_adap[0].fe != NULL) {
1012 if (dvb_attach(stb6100_attach, d->fe_adap[0].fe,
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001013 &dw2104a_stb6100_config,
1014 &d->dev->i2c_adap)) {
Michael Krufky77eed212011-09-06 09:31:57 -03001015 tuner_ops = &d->fe_adap[0].fe->ops.tuner_ops;
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001016 tuner_ops->set_frequency = stb6100_set_freq;
1017 tuner_ops->get_frequency = stb6100_get_freq;
1018 tuner_ops->set_bandwidth = stb6100_set_bandw;
1019 tuner_ops->get_bandwidth = stb6100_get_bandw;
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+STB6100!\n");
1022 return 0;
1023 }
1024 }
1025 }
1026
1027 if (demod_probe & 2) {
Michael Krufky77eed212011-09-06 09:31:57 -03001028 d->fe_adap[0].fe = dvb_attach(stv0900_attach, &dw2104_stv0900_config,
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001029 &d->dev->i2c_adap, 0);
Michael Krufky77eed212011-09-06 09:31:57 -03001030 if (d->fe_adap[0].fe != NULL) {
1031 if (dvb_attach(stv6110_attach, d->fe_adap[0].fe,
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001032 &dw2104_stv6110_config,
1033 &d->dev->i2c_adap)) {
Michael Krufky77eed212011-09-06 09:31:57 -03001034 d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001035 info("Attached STV0900+STV6110A!\n");
1036 return 0;
1037 }
1038 }
1039 }
1040
1041 if (demod_probe & 1) {
Michael Krufky77eed212011-09-06 09:31:57 -03001042 d->fe_adap[0].fe = dvb_attach(cx24116_attach, &dw2104_config,
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001043 &d->dev->i2c_adap);
Michael Krufky77eed212011-09-06 09:31:57 -03001044 if (d->fe_adap[0].fe != NULL) {
1045 d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001046 info("Attached cx24116!\n");
1047 return 0;
1048 }
1049 }
1050
Michael Krufky77eed212011-09-06 09:31:57 -03001051 d->fe_adap[0].fe = dvb_attach(ds3000_attach, &dw2104_ds3000_config,
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001052 &d->dev->i2c_adap);
Michael Krufky77eed212011-09-06 09:31:57 -03001053 if (d->fe_adap[0].fe != NULL) {
Konstantin Dimitrov73f0af42012-12-23 19:25:38 -03001054 dvb_attach(ts2020_attach, d->fe_adap[0].fe,
1055 &dw2104_ts2020_config, &d->dev->i2c_adap);
Michael Krufky77eed212011-09-06 09:31:57 -03001056 d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001057 info("Attached DS3000!\n");
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001058 return 0;
1059 }
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001060
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001061 return -EIO;
1062}
1063
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001064static struct dvb_usb_device_properties dw2102_properties;
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -03001065static struct dvb_usb_device_properties dw2104_properties;
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001066static struct dvb_usb_device_properties s6x0_properties;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001067
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001068static int dw2102_frontend_attach(struct dvb_usb_adapter *d)
1069{
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001070 if (dw2102_properties.i2c_algo == &dw2102_serit_i2c_algo) {
1071 /*dw2102_properties.adapter->tuner_attach = NULL;*/
Michael Krufky77eed212011-09-06 09:31:57 -03001072 d->fe_adap[0].fe = dvb_attach(si21xx_attach, &serit_sp1511lhb_config,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001073 &d->dev->i2c_adap);
Michael Krufky77eed212011-09-06 09:31:57 -03001074 if (d->fe_adap[0].fe != NULL) {
1075 d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001076 info("Attached si21xx!\n");
1077 return 0;
1078 }
1079 }
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001080
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -03001081 if (dw2102_properties.i2c_algo == &dw2102_earda_i2c_algo) {
Michael Krufky77eed212011-09-06 09:31:57 -03001082 d->fe_adap[0].fe = dvb_attach(stv0288_attach, &earda_config,
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -03001083 &d->dev->i2c_adap);
Michael Krufky77eed212011-09-06 09:31:57 -03001084 if (d->fe_adap[0].fe != NULL) {
1085 if (dvb_attach(stb6000_attach, d->fe_adap[0].fe, 0x61,
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001086 &d->dev->i2c_adap)) {
Michael Krufky77eed212011-09-06 09:31:57 -03001087 d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001088 info("Attached stv0288!\n");
1089 return 0;
1090 }
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -03001091 }
1092 }
1093
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001094 if (dw2102_properties.i2c_algo == &dw2102_i2c_algo) {
1095 /*dw2102_properties.adapter->tuner_attach = dw2102_tuner_attach;*/
Michael Krufky77eed212011-09-06 09:31:57 -03001096 d->fe_adap[0].fe = dvb_attach(stv0299_attach, &sharp_z0194a_config,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001097 &d->dev->i2c_adap);
Michael Krufky77eed212011-09-06 09:31:57 -03001098 if (d->fe_adap[0].fe != NULL) {
1099 d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001100 info("Attached stv0299!\n");
1101 return 0;
1102 }
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001103 }
1104 return -EIO;
1105}
1106
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001107static int dw3101_frontend_attach(struct dvb_usb_adapter *d)
1108{
Michael Krufky77eed212011-09-06 09:31:57 -03001109 d->fe_adap[0].fe = dvb_attach(tda10023_attach, &dw3101_tda10023_config,
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001110 &d->dev->i2c_adap, 0x48);
Michael Krufky77eed212011-09-06 09:31:57 -03001111 if (d->fe_adap[0].fe != NULL) {
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001112 info("Attached tda10023!\n");
1113 return 0;
1114 }
1115 return -EIO;
1116}
1117
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001118static int zl100313_frontend_attach(struct dvb_usb_adapter *d)
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001119{
Michael Krufky77eed212011-09-06 09:31:57 -03001120 d->fe_adap[0].fe = dvb_attach(mt312_attach, &zl313_config,
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001121 &d->dev->i2c_adap);
Michael Krufky77eed212011-09-06 09:31:57 -03001122 if (d->fe_adap[0].fe != NULL) {
1123 if (dvb_attach(zl10039_attach, d->fe_adap[0].fe, 0x60,
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001124 &d->dev->i2c_adap)) {
Michael Krufky77eed212011-09-06 09:31:57 -03001125 d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001126 info("Attached zl100313+zl10039!\n");
1127 return 0;
1128 }
1129 }
1130
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001131 return -EIO;
1132}
1133
1134static int stv0288_frontend_attach(struct dvb_usb_adapter *d)
1135{
Igor M. Liplianinfd5466d2011-02-27 16:22:52 -03001136 u8 obuf[] = {7, 1};
1137
Michael Krufky77eed212011-09-06 09:31:57 -03001138 d->fe_adap[0].fe = dvb_attach(stv0288_attach, &earda_config,
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001139 &d->dev->i2c_adap);
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001140
Michael Krufky77eed212011-09-06 09:31:57 -03001141 if (d->fe_adap[0].fe == NULL)
Igor M. Liplianinfd5466d2011-02-27 16:22:52 -03001142 return -EIO;
1143
Michael Krufky77eed212011-09-06 09:31:57 -03001144 if (NULL == dvb_attach(stb6000_attach, d->fe_adap[0].fe, 0x61, &d->dev->i2c_adap))
Igor M. Liplianinfd5466d2011-02-27 16:22:52 -03001145 return -EIO;
1146
Michael Krufky77eed212011-09-06 09:31:57 -03001147 d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
Igor M. Liplianinfd5466d2011-02-27 16:22:52 -03001148
1149 dw210x_op_rw(d->dev->udev, 0x8a, 0, 0, obuf, 2, DW210X_WRITE_MSG);
1150
1151 info("Attached stv0288+stb6000!\n");
1152
1153 return 0;
1154
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001155}
1156
1157static int ds3000_frontend_attach(struct dvb_usb_adapter *d)
1158{
Igor M. Liplianin52c506e2011-02-25 18:41:23 -03001159 struct s6x0_state *st = (struct s6x0_state *)d->dev->priv;
Igor M. Liplianin5a530cb2011-02-25 18:41:23 -03001160 u8 obuf[] = {7, 1};
Igor M. Liplianin52c506e2011-02-25 18:41:23 -03001161
Michael Krufky77eed212011-09-06 09:31:57 -03001162 d->fe_adap[0].fe = dvb_attach(ds3000_attach, &dw2104_ds3000_config,
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001163 &d->dev->i2c_adap);
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001164
Michael Krufky77eed212011-09-06 09:31:57 -03001165 if (d->fe_adap[0].fe == NULL)
Igor M. Liplianin52c506e2011-02-25 18:41:23 -03001166 return -EIO;
1167
Konstantin Dimitrov73f0af42012-12-23 19:25:38 -03001168 dvb_attach(ts2020_attach, d->fe_adap[0].fe, &dw2104_ts2020_config,
1169 &d->dev->i2c_adap);
1170
Michael Krufky77eed212011-09-06 09:31:57 -03001171 st->old_set_voltage = d->fe_adap[0].fe->ops.set_voltage;
1172 d->fe_adap[0].fe->ops.set_voltage = s660_set_voltage;
Igor M. Liplianin5a530cb2011-02-25 18:41:23 -03001173
1174 dw210x_op_rw(d->dev->udev, 0x8a, 0, 0, obuf, 2, DW210X_WRITE_MSG);
1175
Igor M. Liplianin52c506e2011-02-25 18:41:23 -03001176 info("Attached ds3000+ds2020!\n");
1177
1178 return 0;
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001179}
1180
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001181static int prof_7500_frontend_attach(struct dvb_usb_adapter *d)
1182{
Igor M. Liplianin4e59df82011-02-25 18:41:23 -03001183 u8 obuf[] = {7, 1};
1184
Michael Krufky77eed212011-09-06 09:31:57 -03001185 d->fe_adap[0].fe = dvb_attach(stv0900_attach, &prof_7500_stv0900_config,
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001186 &d->dev->i2c_adap, 0);
Michael Krufky77eed212011-09-06 09:31:57 -03001187 if (d->fe_adap[0].fe == NULL)
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001188 return -EIO;
Igor M. Liplianin4e59df82011-02-25 18:41:23 -03001189
Michael Krufky77eed212011-09-06 09:31:57 -03001190 d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001191
Igor M. Liplianin4e59df82011-02-25 18:41:23 -03001192 dw210x_op_rw(d->dev->udev, 0x8a, 0, 0, obuf, 2, DW210X_WRITE_MSG);
1193
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001194 info("Attached STV0900+STB6100A!\n");
1195
1196 return 0;
1197}
1198
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001199static int su3000_frontend_attach(struct dvb_usb_adapter *d)
1200{
1201 u8 obuf[3] = { 0xe, 0x80, 0 };
1202 u8 ibuf[] = { 0 };
1203
1204 if (dvb_usb_generic_rw(d->dev, obuf, 3, ibuf, 1, 0) < 0)
1205 err("command 0x0e transfer failed.");
1206
1207 obuf[0] = 0xe;
1208 obuf[1] = 0x83;
1209 obuf[2] = 0;
1210
1211 if (dvb_usb_generic_rw(d->dev, obuf, 3, ibuf, 1, 0) < 0)
1212 err("command 0x0e transfer failed.");
1213
1214 obuf[0] = 0xe;
1215 obuf[1] = 0x83;
1216 obuf[2] = 1;
1217
1218 if (dvb_usb_generic_rw(d->dev, obuf, 3, ibuf, 1, 0) < 0)
1219 err("command 0x0e transfer failed.");
1220
1221 obuf[0] = 0x51;
1222
1223 if (dvb_usb_generic_rw(d->dev, obuf, 1, ibuf, 1, 0) < 0)
1224 err("command 0x51 transfer failed.");
1225
Michael Krufky77eed212011-09-06 09:31:57 -03001226 d->fe_adap[0].fe = dvb_attach(ds3000_attach, &su3000_ds3000_config,
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001227 &d->dev->i2c_adap);
Michael Krufky77eed212011-09-06 09:31:57 -03001228 if (d->fe_adap[0].fe == NULL)
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001229 return -EIO;
1230
Konstantin Dimitrov73f0af42012-12-23 19:25:38 -03001231 dvb_attach(ts2020_attach, d->fe_adap[0].fe, &su3000_ts2020_config,
1232 &d->dev->i2c_adap);
1233
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001234 info("Attached DS3000!\n");
1235
1236 return 0;
1237}
1238
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001239static int dw2102_tuner_attach(struct dvb_usb_adapter *adap)
1240{
Michael Krufky77eed212011-09-06 09:31:57 -03001241 dvb_attach(dvb_pll_attach, adap->fe_adap[0].fe, 0x60,
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001242 &adap->dev->i2c_adap, DVB_PLL_OPERA1);
1243 return 0;
1244}
1245
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001246static int dw3101_tuner_attach(struct dvb_usb_adapter *adap)
1247{
Michael Krufky77eed212011-09-06 09:31:57 -03001248 dvb_attach(dvb_pll_attach, adap->fe_adap[0].fe, 0x60,
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001249 &adap->dev->i2c_adap, DVB_PLL_TUA6034);
1250
1251 return 0;
1252}
1253
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03001254static struct rc_map_table rc_map_dw210x_table[] = {
Mauro Carvalho Chehab991bd3c2011-01-24 12:18:40 -03001255 { 0xf80a, KEY_POWER2 }, /*power*/
1256 { 0xf80c, KEY_MUTE }, /*mute*/
Mauro Carvalho Chehab2e365882009-08-29 15:19:31 -03001257 { 0xf811, KEY_1 },
1258 { 0xf812, KEY_2 },
1259 { 0xf813, KEY_3 },
1260 { 0xf814, KEY_4 },
1261 { 0xf815, KEY_5 },
1262 { 0xf816, KEY_6 },
1263 { 0xf817, KEY_7 },
1264 { 0xf818, KEY_8 },
1265 { 0xf819, KEY_9 },
1266 { 0xf810, KEY_0 },
Mauro Carvalho Chehab991bd3c2011-01-24 12:18:40 -03001267 { 0xf81c, KEY_CHANNELUP }, /*ch+*/
1268 { 0xf80f, KEY_CHANNELDOWN }, /*ch-*/
1269 { 0xf81a, KEY_VOLUMEUP }, /*vol+*/
1270 { 0xf80e, KEY_VOLUMEDOWN }, /*vol-*/
1271 { 0xf804, KEY_RECORD }, /*rec*/
1272 { 0xf809, KEY_FAVORITES }, /*fav*/
1273 { 0xf808, KEY_REWIND }, /*rewind*/
1274 { 0xf807, KEY_FASTFORWARD }, /*fast*/
1275 { 0xf80b, KEY_PAUSE }, /*pause*/
1276 { 0xf802, KEY_ESC }, /*cancel*/
1277 { 0xf803, KEY_TAB }, /*tab*/
Mauro Carvalho Chehab2e365882009-08-29 15:19:31 -03001278 { 0xf800, KEY_UP }, /*up*/
Mauro Carvalho Chehab991bd3c2011-01-24 12:18:40 -03001279 { 0xf81f, KEY_OK }, /*ok*/
1280 { 0xf801, KEY_DOWN }, /*down*/
1281 { 0xf805, KEY_CAMERA }, /*cap*/
1282 { 0xf806, KEY_STOP }, /*stop*/
1283 { 0xf840, KEY_ZOOM }, /*full*/
1284 { 0xf81e, KEY_TV }, /*tvmode*/
1285 { 0xf81b, KEY_LAST }, /*recall*/
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001286};
1287
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03001288static struct rc_map_table rc_map_tevii_table[] = {
Mauro Carvalho Chehab2e365882009-08-29 15:19:31 -03001289 { 0xf80a, KEY_POWER },
1290 { 0xf80c, KEY_MUTE },
1291 { 0xf811, KEY_1 },
1292 { 0xf812, KEY_2 },
1293 { 0xf813, KEY_3 },
1294 { 0xf814, KEY_4 },
1295 { 0xf815, KEY_5 },
1296 { 0xf816, KEY_6 },
1297 { 0xf817, KEY_7 },
1298 { 0xf818, KEY_8 },
1299 { 0xf819, KEY_9 },
1300 { 0xf810, KEY_0 },
1301 { 0xf81c, KEY_MENU },
1302 { 0xf80f, KEY_VOLUMEDOWN },
1303 { 0xf81a, KEY_LAST },
1304 { 0xf80e, KEY_OPEN },
1305 { 0xf804, KEY_RECORD },
1306 { 0xf809, KEY_VOLUMEUP },
1307 { 0xf808, KEY_CHANNELUP },
1308 { 0xf807, KEY_PVR },
1309 { 0xf80b, KEY_TIME },
1310 { 0xf802, KEY_RIGHT },
1311 { 0xf803, KEY_LEFT },
1312 { 0xf800, KEY_UP },
1313 { 0xf81f, KEY_OK },
1314 { 0xf801, KEY_DOWN },
1315 { 0xf805, KEY_TUNER },
1316 { 0xf806, KEY_CHANNELDOWN },
1317 { 0xf840, KEY_PLAYPAUSE },
1318 { 0xf81e, KEY_REWIND },
1319 { 0xf81b, KEY_FAVORITES },
1320 { 0xf81d, KEY_BACK },
1321 { 0xf84d, KEY_FASTFORWARD },
1322 { 0xf844, KEY_EPG },
1323 { 0xf84c, KEY_INFO },
1324 { 0xf841, KEY_AB },
1325 { 0xf843, KEY_AUDIO },
1326 { 0xf845, KEY_SUBTITLE },
1327 { 0xf84a, KEY_LIST },
1328 { 0xf846, KEY_F1 },
1329 { 0xf847, KEY_F2 },
1330 { 0xf85e, KEY_F3 },
1331 { 0xf85c, KEY_F4 },
1332 { 0xf852, KEY_F5 },
1333 { 0xf85a, KEY_F6 },
1334 { 0xf856, KEY_MODE },
1335 { 0xf858, KEY_SWITCHVIDEOMODE },
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -03001336};
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001337
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03001338static struct rc_map_table rc_map_tbs_table[] = {
Mauro Carvalho Chehab2e365882009-08-29 15:19:31 -03001339 { 0xf884, KEY_POWER },
1340 { 0xf894, KEY_MUTE },
1341 { 0xf887, KEY_1 },
1342 { 0xf886, KEY_2 },
1343 { 0xf885, KEY_3 },
1344 { 0xf88b, KEY_4 },
1345 { 0xf88a, KEY_5 },
1346 { 0xf889, KEY_6 },
1347 { 0xf88f, KEY_7 },
1348 { 0xf88e, KEY_8 },
1349 { 0xf88d, KEY_9 },
1350 { 0xf892, KEY_0 },
1351 { 0xf896, KEY_CHANNELUP },
1352 { 0xf891, KEY_CHANNELDOWN },
1353 { 0xf893, KEY_VOLUMEUP },
1354 { 0xf88c, KEY_VOLUMEDOWN },
1355 { 0xf883, KEY_RECORD },
1356 { 0xf898, KEY_PAUSE },
1357 { 0xf899, KEY_OK },
1358 { 0xf89a, KEY_SHUFFLE },
1359 { 0xf881, KEY_UP },
1360 { 0xf890, KEY_LEFT },
1361 { 0xf882, KEY_RIGHT },
1362 { 0xf888, KEY_DOWN },
1363 { 0xf895, KEY_FAVORITES },
1364 { 0xf897, KEY_SUBTITLE },
1365 { 0xf89d, KEY_ZOOM },
1366 { 0xf89f, KEY_EXIT },
1367 { 0xf89e, KEY_MENU },
1368 { 0xf89c, KEY_EPG },
1369 { 0xf880, KEY_PREVIOUS },
1370 { 0xf89b, KEY_MODE }
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -03001371};
1372
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001373static struct rc_map_table rc_map_su3000_table[] = {
1374 { 0x25, KEY_POWER }, /* right-bottom Red */
1375 { 0x0a, KEY_MUTE }, /* -/-- */
1376 { 0x01, KEY_1 },
1377 { 0x02, KEY_2 },
1378 { 0x03, KEY_3 },
1379 { 0x04, KEY_4 },
1380 { 0x05, KEY_5 },
1381 { 0x06, KEY_6 },
1382 { 0x07, KEY_7 },
1383 { 0x08, KEY_8 },
1384 { 0x09, KEY_9 },
1385 { 0x00, KEY_0 },
1386 { 0x20, KEY_UP }, /* CH+ */
1387 { 0x21, KEY_DOWN }, /* CH+ */
1388 { 0x12, KEY_VOLUMEUP }, /* Brightness Up */
1389 { 0x13, KEY_VOLUMEDOWN },/* Brightness Down */
1390 { 0x1f, KEY_RECORD },
1391 { 0x17, KEY_PLAY },
1392 { 0x16, KEY_PAUSE },
1393 { 0x0b, KEY_STOP },
1394 { 0x27, KEY_FASTFORWARD },/* >> */
1395 { 0x26, KEY_REWIND }, /* << */
1396 { 0x0d, KEY_OK }, /* Mute */
1397 { 0x11, KEY_LEFT }, /* VOL- */
1398 { 0x10, KEY_RIGHT }, /* VOL+ */
1399 { 0x29, KEY_BACK }, /* button under 9 */
1400 { 0x2c, KEY_MENU }, /* TTX */
1401 { 0x2b, KEY_EPG }, /* EPG */
1402 { 0x1e, KEY_RED }, /* OSD */
1403 { 0x0e, KEY_GREEN }, /* Window */
1404 { 0x2d, KEY_YELLOW }, /* button under << */
1405 { 0x0f, KEY_BLUE }, /* bottom yellow button */
1406 { 0x14, KEY_AUDIO }, /* Snapshot */
1407 { 0x38, KEY_TV }, /* TV/Radio */
Justin P. Mattock70f23fd2011-05-10 10:16:21 +02001408 { 0x0c, KEY_ESC } /* upper Red button */
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001409};
1410
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03001411static struct rc_map_dvb_usb_table_table keys_tables[] = {
1412 { rc_map_dw210x_table, ARRAY_SIZE(rc_map_dw210x_table) },
1413 { rc_map_tevii_table, ARRAY_SIZE(rc_map_tevii_table) },
1414 { rc_map_tbs_table, ARRAY_SIZE(rc_map_tbs_table) },
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001415 { rc_map_su3000_table, ARRAY_SIZE(rc_map_su3000_table) },
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -03001416};
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001417
1418static int dw2102_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
1419{
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03001420 struct rc_map_table *keymap = d->props.rc.legacy.rc_map_table;
1421 int keymap_size = d->props.rc.legacy.rc_map_size;
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001422 u8 key[2];
Igor M. Liplianin8a8dad72009-06-13 08:10:24 -03001423 struct i2c_msg msg = {
1424 .addr = DW2102_RC_QUERY,
1425 .flags = I2C_M_RD,
1426 .buf = key,
1427 .len = 2
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001428 };
1429 int i;
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -03001430 /* override keymap */
1431 if ((ir_keymap > 0) && (ir_keymap <= ARRAY_SIZE(keys_tables))) {
1432 keymap = keys_tables[ir_keymap - 1].rc_keys ;
1433 keymap_size = keys_tables[ir_keymap - 1].rc_keys_size;
Igor M. Liplianinfeb16e92011-02-25 18:41:22 -03001434 } else if (ir_keymap > ARRAY_SIZE(keys_tables))
1435 return 0; /* none */
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001436
1437 *state = REMOTE_NO_KEY_PRESSED;
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001438 if (d->props.i2c_algo->master_xfer(&d->i2c_adap, &msg, 1) == 1) {
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -03001439 for (i = 0; i < keymap_size ; i++) {
Mauro Carvalho Chehab2e365882009-08-29 15:19:31 -03001440 if (rc5_data(&keymap[i]) == msg.buf[0]) {
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001441 *state = REMOTE_KEY_PRESSED;
Mauro Carvalho Chehab34abf212010-07-31 11:24:57 -03001442 *event = keymap[i].keycode;
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001443 break;
1444 }
Igor M. Liplianin8a8dad72009-06-13 08:10:24 -03001445
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001446 }
Igor M. Liplianin8a8dad72009-06-13 08:10:24 -03001447
1448 if ((*state) == REMOTE_KEY_PRESSED)
1449 deb_rc("%s: found rc key: %x, %x, event: %x\n",
1450 __func__, key[0], key[1], (*event));
1451 else if (key[0] != 0xff)
1452 deb_rc("%s: unknown rc key: %x, %x\n",
1453 __func__, key[0], key[1]);
1454
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001455 }
Igor M. Liplianin8a8dad72009-06-13 08:10:24 -03001456
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001457 return 0;
1458}
1459
Jonathan Nieder27351b12011-12-23 19:00:45 -03001460enum dw2102_table_entry {
1461 CYPRESS_DW2102,
1462 CYPRESS_DW2101,
1463 CYPRESS_DW2104,
1464 TEVII_S650,
1465 TERRATEC_CINERGY_S,
1466 CYPRESS_DW3101,
1467 TEVII_S630,
1468 PROF_1100,
1469 TEVII_S660,
1470 PROF_7500,
1471 GENIATECH_SU3000,
1472 TERRATEC_CINERGY_S2,
1473 TEVII_S480_1,
1474 TEVII_S480_2,
1475 X3M_SPC1400HD,
1476};
1477
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001478static struct usb_device_id dw2102_table[] = {
Jonathan Nieder27351b12011-12-23 19:00:45 -03001479 [CYPRESS_DW2102] = {USB_DEVICE(USB_VID_CYPRESS, USB_PID_DW2102)},
1480 [CYPRESS_DW2101] = {USB_DEVICE(USB_VID_CYPRESS, 0x2101)},
1481 [CYPRESS_DW2104] = {USB_DEVICE(USB_VID_CYPRESS, USB_PID_DW2104)},
1482 [TEVII_S650] = {USB_DEVICE(0x9022, USB_PID_TEVII_S650)},
1483 [TERRATEC_CINERGY_S] = {USB_DEVICE(USB_VID_TERRATEC, USB_PID_CINERGY_S)},
1484 [CYPRESS_DW3101] = {USB_DEVICE(USB_VID_CYPRESS, USB_PID_DW3101)},
1485 [TEVII_S630] = {USB_DEVICE(0x9022, USB_PID_TEVII_S630)},
1486 [PROF_1100] = {USB_DEVICE(0x3011, USB_PID_PROF_1100)},
1487 [TEVII_S660] = {USB_DEVICE(0x9022, USB_PID_TEVII_S660)},
1488 [PROF_7500] = {USB_DEVICE(0x3034, 0x7500)},
1489 [GENIATECH_SU3000] = {USB_DEVICE(0x1f4d, 0x3000)},
1490 [TERRATEC_CINERGY_S2] = {USB_DEVICE(USB_VID_TERRATEC, 0x00a8)},
1491 [TEVII_S480_1] = {USB_DEVICE(0x9022, USB_PID_TEVII_S480_1)},
1492 [TEVII_S480_2] = {USB_DEVICE(0x9022, USB_PID_TEVII_S480_2)},
1493 [X3M_SPC1400HD] = {USB_DEVICE(0x1f4d, 0x3100)},
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001494 { }
1495};
1496
1497MODULE_DEVICE_TABLE(usb, dw2102_table);
1498
1499static int dw2102_load_firmware(struct usb_device *dev,
1500 const struct firmware *frmwr)
1501{
1502 u8 *b, *p;
1503 int ret = 0, i;
1504 u8 reset;
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -03001505 u8 reset16[] = {0, 0, 0, 0, 0, 0, 0};
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001506 const struct firmware *fw;
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001507
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001508 switch (dev->descriptor.idProduct) {
1509 case 0x2101:
Rémi Cardona68236272012-09-28 08:59:32 -03001510 ret = request_firmware(&fw, DW2101_FIRMWARE, &dev->dev);
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001511 if (ret != 0) {
Rémi Cardona68236272012-09-28 08:59:32 -03001512 err(err_str, DW2101_FIRMWARE);
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001513 return ret;
1514 }
1515 break;
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001516 default:
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001517 fw = frmwr;
1518 break;
1519 }
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001520 info("start downloading DW210X firmware");
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001521 p = kmalloc(fw->size, GFP_KERNEL);
1522 reset = 1;
1523 /*stop the CPU*/
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001524 dw210x_op_rw(dev, 0xa0, 0x7f92, 0, &reset, 1, DW210X_WRITE_MSG);
1525 dw210x_op_rw(dev, 0xa0, 0xe600, 0, &reset, 1, DW210X_WRITE_MSG);
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001526
1527 if (p != NULL) {
1528 memcpy(p, fw->data, fw->size);
1529 for (i = 0; i < fw->size; i += 0x40) {
1530 b = (u8 *) p + i;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001531 if (dw210x_op_rw(dev, 0xa0, i, 0, b , 0x40,
1532 DW210X_WRITE_MSG) != 0x40) {
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001533 err("error while transferring firmware");
1534 ret = -EINVAL;
1535 break;
1536 }
1537 }
1538 /* restart the CPU */
1539 reset = 0;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001540 if (ret || dw210x_op_rw(dev, 0xa0, 0x7f92, 0, &reset, 1,
1541 DW210X_WRITE_MSG) != 1) {
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001542 err("could not restart the USB controller CPU.");
1543 ret = -EINVAL;
1544 }
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001545 if (ret || dw210x_op_rw(dev, 0xa0, 0xe600, 0, &reset, 1,
1546 DW210X_WRITE_MSG) != 1) {
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001547 err("could not restart the USB controller CPU.");
1548 ret = -EINVAL;
1549 }
1550 /* init registers */
1551 switch (dev->descriptor.idProduct) {
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001552 case USB_PID_TEVII_S650:
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03001553 dw2104_properties.rc.legacy.rc_map_table = rc_map_tevii_table;
1554 dw2104_properties.rc.legacy.rc_map_size =
1555 ARRAY_SIZE(rc_map_tevii_table);
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -03001556 case USB_PID_DW2104:
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001557 reset = 1;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001558 dw210x_op_rw(dev, 0xc4, 0x0000, 0, &reset, 1,
1559 DW210X_WRITE_MSG);
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001560 /* break omitted intentionally */
1561 case USB_PID_DW3101:
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001562 reset = 0;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001563 dw210x_op_rw(dev, 0xbf, 0x0040, 0, &reset, 0,
1564 DW210X_WRITE_MSG);
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001565 break;
Igor M. Liplianin4cc0edf2008-11-05 22:12:56 -03001566 case USB_PID_CINERGY_S:
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001567 case USB_PID_DW2102:
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001568 dw210x_op_rw(dev, 0xbf, 0x0040, 0, &reset, 0,
1569 DW210X_WRITE_MSG);
1570 dw210x_op_rw(dev, 0xb9, 0x0000, 0, &reset16[0], 2,
1571 DW210X_READ_MSG);
1572 /* check STV0299 frontend */
1573 dw210x_op_rw(dev, 0xb5, 0, 0, &reset16[0], 2,
1574 DW210X_READ_MSG);
Igor M. Liplianinea023df2008-12-04 12:49:23 -03001575 if ((reset16[0] == 0xa1) || (reset16[0] == 0x80)) {
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001576 dw2102_properties.i2c_algo = &dw2102_i2c_algo;
Michael Krufky77eed212011-09-06 09:31:57 -03001577 dw2102_properties.adapter->fe[0].tuner_attach = &dw2102_tuner_attach;
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -03001578 break;
1579 } else {
1580 /* check STV0288 frontend */
1581 reset16[0] = 0xd0;
1582 reset16[1] = 1;
1583 reset16[2] = 0;
1584 dw210x_op_rw(dev, 0xc2, 0, 0, &reset16[0], 3,
1585 DW210X_WRITE_MSG);
1586 dw210x_op_rw(dev, 0xc3, 0xd1, 0, &reset16[0], 3,
1587 DW210X_READ_MSG);
1588 if (reset16[2] == 0x11) {
1589 dw2102_properties.i2c_algo = &dw2102_earda_i2c_algo;
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -03001590 break;
1591 }
1592 }
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001593 case 0x2101:
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001594 dw210x_op_rw(dev, 0xbc, 0x0030, 0, &reset16[0], 2,
1595 DW210X_READ_MSG);
1596 dw210x_op_rw(dev, 0xba, 0x0000, 0, &reset16[0], 7,
1597 DW210X_READ_MSG);
1598 dw210x_op_rw(dev, 0xba, 0x0000, 0, &reset16[0], 7,
1599 DW210X_READ_MSG);
1600 dw210x_op_rw(dev, 0xb9, 0x0000, 0, &reset16[0], 2,
1601 DW210X_READ_MSG);
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001602 break;
1603 }
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001604
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001605 msleep(100);
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001606 kfree(p);
1607 }
1608 return ret;
1609}
1610
1611static struct dvb_usb_device_properties dw2102_properties = {
1612 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1613 .usb_ctrl = DEVICE_SPECIFIC,
Rémi Cardona68236272012-09-28 08:59:32 -03001614 .firmware = DW2102_FIRMWARE,
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001615 .no_reconnect = 1,
1616
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001617 .i2c_algo = &dw2102_serit_i2c_algo,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03001618
1619 .rc.legacy = {
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03001620 .rc_map_table = rc_map_dw210x_table,
1621 .rc_map_size = ARRAY_SIZE(rc_map_dw210x_table),
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03001622 .rc_interval = 150,
1623 .rc_query = dw2102_rc_query,
1624 },
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001625
1626 .generic_bulk_ctrl_endpoint = 0x81,
1627 /* parameter for the MPEG2-data transfer */
1628 .num_adapters = 1,
1629 .download_firmware = dw2102_load_firmware,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001630 .read_mac_address = dw210x_read_mac_address,
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001631 .adapter = {
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001632 {
Michael Krufky77eed212011-09-06 09:31:57 -03001633 .num_frontends = 1,
1634 .fe = {{
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001635 .frontend_attach = dw2102_frontend_attach,
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001636 .stream = {
1637 .type = USB_BULK,
1638 .count = 8,
1639 .endpoint = 0x82,
1640 .u = {
1641 .bulk = {
1642 .buffersize = 4096,
1643 }
1644 }
1645 },
Michael Krufky77eed212011-09-06 09:31:57 -03001646 }},
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001647 }
1648 },
Igor M. Liplianin4cc0edf2008-11-05 22:12:56 -03001649 .num_device_descs = 3,
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001650 .devices = {
1651 {"DVBWorld DVB-S 2102 USB2.0",
Jonathan Nieder27351b12011-12-23 19:00:45 -03001652 {&dw2102_table[CYPRESS_DW2102], NULL},
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001653 {NULL},
1654 },
1655 {"DVBWorld DVB-S 2101 USB2.0",
Jonathan Nieder27351b12011-12-23 19:00:45 -03001656 {&dw2102_table[CYPRESS_DW2101], NULL},
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001657 {NULL},
1658 },
Igor M. Liplianin4cc0edf2008-11-05 22:12:56 -03001659 {"TerraTec Cinergy S USB",
Jonathan Nieder27351b12011-12-23 19:00:45 -03001660 {&dw2102_table[TERRATEC_CINERGY_S], NULL},
Igor M. Liplianin4cc0edf2008-11-05 22:12:56 -03001661 {NULL},
1662 },
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001663 }
1664};
1665
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001666static struct dvb_usb_device_properties dw2104_properties = {
1667 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1668 .usb_ctrl = DEVICE_SPECIFIC,
Rémi Cardona68236272012-09-28 08:59:32 -03001669 .firmware = DW2104_FIRMWARE,
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001670 .no_reconnect = 1,
1671
1672 .i2c_algo = &dw2104_i2c_algo,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03001673 .rc.legacy = {
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03001674 .rc_map_table = rc_map_dw210x_table,
1675 .rc_map_size = ARRAY_SIZE(rc_map_dw210x_table),
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03001676 .rc_interval = 150,
1677 .rc_query = dw2102_rc_query,
1678 },
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001679
1680 .generic_bulk_ctrl_endpoint = 0x81,
1681 /* parameter for the MPEG2-data transfer */
1682 .num_adapters = 1,
1683 .download_firmware = dw2102_load_firmware,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001684 .read_mac_address = dw210x_read_mac_address,
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001685 .adapter = {
1686 {
Michael Krufky77eed212011-09-06 09:31:57 -03001687 .num_frontends = 1,
1688 .fe = {{
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001689 .frontend_attach = dw2104_frontend_attach,
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001690 .stream = {
1691 .type = USB_BULK,
1692 .count = 8,
1693 .endpoint = 0x82,
1694 .u = {
1695 .bulk = {
1696 .buffersize = 4096,
1697 }
1698 }
1699 },
Michael Krufky77eed212011-09-06 09:31:57 -03001700 }},
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001701 }
1702 },
1703 .num_device_descs = 2,
1704 .devices = {
1705 { "DVBWorld DW2104 USB2.0",
Jonathan Nieder27351b12011-12-23 19:00:45 -03001706 {&dw2102_table[CYPRESS_DW2104], NULL},
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001707 {NULL},
1708 },
1709 { "TeVii S650 USB2.0",
Jonathan Nieder27351b12011-12-23 19:00:45 -03001710 {&dw2102_table[TEVII_S650], NULL},
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001711 {NULL},
1712 },
1713 }
1714};
1715
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001716static struct dvb_usb_device_properties dw3101_properties = {
1717 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1718 .usb_ctrl = DEVICE_SPECIFIC,
Rémi Cardona68236272012-09-28 08:59:32 -03001719 .firmware = DW3101_FIRMWARE,
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001720 .no_reconnect = 1,
1721
1722 .i2c_algo = &dw3101_i2c_algo,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03001723 .rc.legacy = {
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03001724 .rc_map_table = rc_map_dw210x_table,
1725 .rc_map_size = ARRAY_SIZE(rc_map_dw210x_table),
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03001726 .rc_interval = 150,
1727 .rc_query = dw2102_rc_query,
1728 },
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001729
1730 .generic_bulk_ctrl_endpoint = 0x81,
1731 /* parameter for the MPEG2-data transfer */
1732 .num_adapters = 1,
1733 .download_firmware = dw2102_load_firmware,
1734 .read_mac_address = dw210x_read_mac_address,
1735 .adapter = {
1736 {
Michael Krufky77eed212011-09-06 09:31:57 -03001737 .num_frontends = 1,
1738 .fe = {{
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001739 .frontend_attach = dw3101_frontend_attach,
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001740 .tuner_attach = dw3101_tuner_attach,
1741 .stream = {
1742 .type = USB_BULK,
1743 .count = 8,
1744 .endpoint = 0x82,
1745 .u = {
1746 .bulk = {
1747 .buffersize = 4096,
1748 }
1749 }
1750 },
Michael Krufky77eed212011-09-06 09:31:57 -03001751 }},
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001752 }
1753 },
1754 .num_device_descs = 1,
1755 .devices = {
1756 { "DVBWorld DVB-C 3101 USB2.0",
Jonathan Nieder27351b12011-12-23 19:00:45 -03001757 {&dw2102_table[CYPRESS_DW3101], NULL},
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001758 {NULL},
1759 },
1760 }
1761};
1762
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001763static struct dvb_usb_device_properties s6x0_properties = {
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001764 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1765 .usb_ctrl = DEVICE_SPECIFIC,
Igor M. Liplianin52c506e2011-02-25 18:41:23 -03001766 .size_of_priv = sizeof(struct s6x0_state),
Rémi Cardona68236272012-09-28 08:59:32 -03001767 .firmware = S630_FIRMWARE,
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001768 .no_reconnect = 1,
1769
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001770 .i2c_algo = &s6x0_i2c_algo,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03001771 .rc.legacy = {
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03001772 .rc_map_table = rc_map_tevii_table,
1773 .rc_map_size = ARRAY_SIZE(rc_map_tevii_table),
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03001774 .rc_interval = 150,
1775 .rc_query = dw2102_rc_query,
1776 },
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001777
1778 .generic_bulk_ctrl_endpoint = 0x81,
1779 .num_adapters = 1,
1780 .download_firmware = dw2102_load_firmware,
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001781 .read_mac_address = s6x0_read_mac_address,
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001782 .adapter = {
1783 {
Michael Krufky77eed212011-09-06 09:31:57 -03001784 .num_frontends = 1,
1785 .fe = {{
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001786 .frontend_attach = zl100313_frontend_attach,
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001787 .stream = {
1788 .type = USB_BULK,
1789 .count = 8,
1790 .endpoint = 0x82,
1791 .u = {
1792 .bulk = {
1793 .buffersize = 4096,
1794 }
1795 }
1796 },
Michael Krufky77eed212011-09-06 09:31:57 -03001797 }},
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001798 }
1799 },
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001800 .num_device_descs = 1,
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001801 .devices = {
1802 {"TeVii S630 USB",
Jonathan Nieder27351b12011-12-23 19:00:45 -03001803 {&dw2102_table[TEVII_S630], NULL},
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001804 {NULL},
1805 },
1806 }
1807};
1808
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001809struct dvb_usb_device_properties *p1100;
1810static struct dvb_usb_device_description d1100 = {
1811 "Prof 1100 USB ",
Jonathan Nieder27351b12011-12-23 19:00:45 -03001812 {&dw2102_table[PROF_1100], NULL},
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001813 {NULL},
1814};
1815
1816struct dvb_usb_device_properties *s660;
1817static struct dvb_usb_device_description d660 = {
1818 "TeVii S660 USB",
Jonathan Nieder27351b12011-12-23 19:00:45 -03001819 {&dw2102_table[TEVII_S660], NULL},
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001820 {NULL},
1821};
1822
Igor M. Liplianine8f50552011-02-25 18:41:23 -03001823static struct dvb_usb_device_description d480_1 = {
1824 "TeVii S480.1 USB",
Jonathan Nieder27351b12011-12-23 19:00:45 -03001825 {&dw2102_table[TEVII_S480_1], NULL},
Igor M. Liplianine8f50552011-02-25 18:41:23 -03001826 {NULL},
1827};
1828
1829static struct dvb_usb_device_description d480_2 = {
1830 "TeVii S480.2 USB",
Jonathan Nieder27351b12011-12-23 19:00:45 -03001831 {&dw2102_table[TEVII_S480_2], NULL},
Igor M. Liplianine8f50552011-02-25 18:41:23 -03001832 {NULL},
1833};
1834
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001835struct dvb_usb_device_properties *p7500;
1836static struct dvb_usb_device_description d7500 = {
1837 "Prof 7500 USB DVB-S2",
Jonathan Nieder27351b12011-12-23 19:00:45 -03001838 {&dw2102_table[PROF_7500], NULL},
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001839 {NULL},
1840};
1841
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001842static struct dvb_usb_device_properties su3000_properties = {
1843 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1844 .usb_ctrl = DEVICE_SPECIFIC,
1845 .size_of_priv = sizeof(struct su3000_state),
1846 .power_ctrl = su3000_power_ctrl,
1847 .num_adapters = 1,
1848 .identify_state = su3000_identify_state,
1849 .i2c_algo = &su3000_i2c_algo,
1850
1851 .rc.legacy = {
1852 .rc_map_table = rc_map_su3000_table,
1853 .rc_map_size = ARRAY_SIZE(rc_map_su3000_table),
1854 .rc_interval = 150,
1855 .rc_query = dw2102_rc_query,
1856 },
1857
1858 .read_mac_address = su3000_read_mac_address,
1859
1860 .generic_bulk_ctrl_endpoint = 0x01,
1861
1862 .adapter = {
1863 {
Michael Krufky77eed212011-09-06 09:31:57 -03001864 .num_frontends = 1,
1865 .fe = {{
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001866 .streaming_ctrl = su3000_streaming_ctrl,
1867 .frontend_attach = su3000_frontend_attach,
1868 .stream = {
1869 .type = USB_BULK,
1870 .count = 8,
1871 .endpoint = 0x82,
1872 .u = {
1873 .bulk = {
1874 .buffersize = 4096,
1875 }
1876 }
1877 }
Michael Krufky77eed212011-09-06 09:31:57 -03001878 }},
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001879 }
1880 },
Mauro Carvalho Chehabb7e38632012-07-07 00:19:20 -03001881 .num_device_descs = 3,
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001882 .devices = {
1883 { "SU3000HD DVB-S USB2.0",
Jonathan Nieder27351b12011-12-23 19:00:45 -03001884 { &dw2102_table[GENIATECH_SU3000], NULL },
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001885 { NULL },
1886 },
Igor M. Liplianin2adc5912011-02-25 18:41:22 -03001887 { "Terratec Cinergy S2 USB HD",
Jonathan Nieder27351b12011-12-23 19:00:45 -03001888 { &dw2102_table[TERRATEC_CINERGY_S2], NULL },
Igor M. Liplianin2adc5912011-02-25 18:41:22 -03001889 { NULL },
1890 },
Igor M. Liplianin5265ea52011-02-27 16:17:25 -03001891 { "X3M TV SPC1400HD PCI",
Jonathan Nieder27351b12011-12-23 19:00:45 -03001892 { &dw2102_table[X3M_SPC1400HD], NULL },
Igor M. Liplianin5265ea52011-02-27 16:17:25 -03001893 { NULL },
1894 },
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001895 }
1896};
1897
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001898static int dw2102_probe(struct usb_interface *intf,
1899 const struct usb_device_id *id)
1900{
Thomas Meyer68dd9dd2011-11-17 18:43:40 -03001901 p1100 = kmemdup(&s6x0_properties,
1902 sizeof(struct dvb_usb_device_properties), GFP_KERNEL);
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001903 if (!p1100)
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001904 return -ENOMEM;
1905 /* copy default structure */
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001906 /* fill only different fields */
Rémi Cardona68236272012-09-28 08:59:32 -03001907 p1100->firmware = P1100_FIRMWARE;
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001908 p1100->devices[0] = d1100;
1909 p1100->rc.legacy.rc_map_table = rc_map_tbs_table;
1910 p1100->rc.legacy.rc_map_size = ARRAY_SIZE(rc_map_tbs_table);
Michael Krufky77eed212011-09-06 09:31:57 -03001911 p1100->adapter->fe[0].frontend_attach = stv0288_frontend_attach;
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001912
Thomas Meyer68dd9dd2011-11-17 18:43:40 -03001913 s660 = kmemdup(&s6x0_properties,
1914 sizeof(struct dvb_usb_device_properties), GFP_KERNEL);
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001915 if (!s660) {
1916 kfree(p1100);
1917 return -ENOMEM;
1918 }
Rémi Cardona68236272012-09-28 08:59:32 -03001919 s660->firmware = S660_FIRMWARE;
Igor M. Liplianine8f50552011-02-25 18:41:23 -03001920 s660->num_device_descs = 3;
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001921 s660->devices[0] = d660;
Igor M. Liplianine8f50552011-02-25 18:41:23 -03001922 s660->devices[1] = d480_1;
1923 s660->devices[2] = d480_2;
Michael Krufky77eed212011-09-06 09:31:57 -03001924 s660->adapter->fe[0].frontend_attach = ds3000_frontend_attach;
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001925
Thomas Meyer68dd9dd2011-11-17 18:43:40 -03001926 p7500 = kmemdup(&s6x0_properties,
1927 sizeof(struct dvb_usb_device_properties), GFP_KERNEL);
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001928 if (!p7500) {
1929 kfree(p1100);
1930 kfree(s660);
1931 return -ENOMEM;
1932 }
Rémi Cardona68236272012-09-28 08:59:32 -03001933 p7500->firmware = P7500_FIRMWARE;
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001934 p7500->devices[0] = d7500;
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03001935 p7500->rc.legacy.rc_map_table = rc_map_tbs_table;
1936 p7500->rc.legacy.rc_map_size = ARRAY_SIZE(rc_map_tbs_table);
Michael Krufky77eed212011-09-06 09:31:57 -03001937 p7500->adapter->fe[0].frontend_attach = prof_7500_frontend_attach;
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001938
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001939 if (0 == dvb_usb_device_init(intf, &dw2102_properties,
1940 THIS_MODULE, NULL, adapter_nr) ||
1941 0 == dvb_usb_device_init(intf, &dw2104_properties,
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001942 THIS_MODULE, NULL, adapter_nr) ||
1943 0 == dvb_usb_device_init(intf, &dw3101_properties,
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001944 THIS_MODULE, NULL, adapter_nr) ||
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001945 0 == dvb_usb_device_init(intf, &s6x0_properties,
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001946 THIS_MODULE, NULL, adapter_nr) ||
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001947 0 == dvb_usb_device_init(intf, p1100,
1948 THIS_MODULE, NULL, adapter_nr) ||
1949 0 == dvb_usb_device_init(intf, s660,
1950 THIS_MODULE, NULL, adapter_nr) ||
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001951 0 == dvb_usb_device_init(intf, p7500,
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001952 THIS_MODULE, NULL, adapter_nr) ||
1953 0 == dvb_usb_device_init(intf, &su3000_properties,
1954 THIS_MODULE, NULL, adapter_nr))
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001955 return 0;
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001956
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001957 return -ENODEV;
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001958}
1959
1960static struct usb_driver dw2102_driver = {
1961 .name = "dw2102",
1962 .probe = dw2102_probe,
1963 .disconnect = dvb_usb_device_exit,
1964 .id_table = dw2102_table,
1965};
1966
Greg Kroah-Hartmanecb3b2b2011-11-18 09:46:12 -08001967module_usb_driver(dw2102_driver);
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001968
1969MODULE_AUTHOR("Igor M. Liplianin (c) liplianin@me.by");
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001970MODULE_DESCRIPTION("Driver for DVBWorld DVB-S 2101, 2102, DVB-S2 2104,"
1971 " DVB-C 3101 USB2.0,"
Igor M. Liplianine8f50552011-02-25 18:41:23 -03001972 " TeVii S600, S630, S650, S660, S480,"
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001973 " Prof 1100, 7500 USB2.0,"
1974 " Geniatech SU3000 devices");
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001975MODULE_VERSION("0.1");
1976MODULE_LICENSE("GPL");
Rémi Cardona68236272012-09-28 08:59:32 -03001977MODULE_FIRMWARE(DW2101_FIRMWARE);
1978MODULE_FIRMWARE(DW2102_FIRMWARE);
1979MODULE_FIRMWARE(DW2104_FIRMWARE);
1980MODULE_FIRMWARE(DW3101_FIRMWARE);
1981MODULE_FIRMWARE(S630_FIRMWARE);
1982MODULE_FIRMWARE(S660_FIRMWARE);
1983MODULE_FIRMWARE(P1100_FIRMWARE);
1984MODULE_FIRMWARE(P7500_FIRMWARE);