xref: /linux/drivers/media/usb/dvb-usb/dw2102.c (revision 44122dd6b6b872d6f1ec151f89942f66b715222c)
1786baecfSMauro Carvalho Chehab /* DVB USB framework compliant Linux driver for the
2786baecfSMauro Carvalho Chehab  *	DVBWorld DVB-S 2101, 2102, DVB-S2 2104, DVB-C 3101,
3955d00acSIgor M. Liplianin  *	TeVii S600, S630, S650, S660, S480, S421, S632
4786baecfSMauro Carvalho Chehab  *	Prof 1100, 7500,
5786baecfSMauro Carvalho Chehab  *	Geniatech SU3000 Cards
6955d00acSIgor M. Liplianin  * Copyright (C) 2008-2012 Igor M. Liplianin (liplianin@me.by)
7786baecfSMauro Carvalho Chehab  *
8786baecfSMauro Carvalho Chehab  *	This program is free software; you can redistribute it and/or modify it
9786baecfSMauro Carvalho Chehab  *	under the terms of the GNU General Public License as published by the
10786baecfSMauro Carvalho Chehab  *	Free Software Foundation, version 2.
11786baecfSMauro Carvalho Chehab  *
12786baecfSMauro Carvalho Chehab  * see Documentation/dvb/README.dvb-usb for more information
13786baecfSMauro Carvalho Chehab  */
14786baecfSMauro Carvalho Chehab #include "dw2102.h"
15786baecfSMauro Carvalho Chehab #include "si21xx.h"
16786baecfSMauro Carvalho Chehab #include "stv0299.h"
17786baecfSMauro Carvalho Chehab #include "z0194a.h"
18786baecfSMauro Carvalho Chehab #include "stv0288.h"
19786baecfSMauro Carvalho Chehab #include "stb6000.h"
20786baecfSMauro Carvalho Chehab #include "eds1547.h"
21786baecfSMauro Carvalho Chehab #include "cx24116.h"
22786baecfSMauro Carvalho Chehab #include "tda1002x.h"
23786baecfSMauro Carvalho Chehab #include "mt312.h"
24786baecfSMauro Carvalho Chehab #include "zl10039.h"
2573f0af44SKonstantin Dimitrov #include "ts2020.h"
26786baecfSMauro Carvalho Chehab #include "ds3000.h"
27786baecfSMauro Carvalho Chehab #include "stv0900.h"
28786baecfSMauro Carvalho Chehab #include "stv6110.h"
29786baecfSMauro Carvalho Chehab #include "stb6100.h"
30786baecfSMauro Carvalho Chehab #include "stb6100_proc.h"
31955d00acSIgor M. Liplianin #include "m88rs2000.h"
32b858c331SIgor M. Liplianin #include "ts2020.h"
33786baecfSMauro Carvalho Chehab 
34786baecfSMauro Carvalho Chehab #ifndef USB_PID_DW2102
35786baecfSMauro Carvalho Chehab #define USB_PID_DW2102 0x2102
36786baecfSMauro Carvalho Chehab #endif
37786baecfSMauro Carvalho Chehab 
38786baecfSMauro Carvalho Chehab #ifndef USB_PID_DW2104
39786baecfSMauro Carvalho Chehab #define USB_PID_DW2104 0x2104
40786baecfSMauro Carvalho Chehab #endif
41786baecfSMauro Carvalho Chehab 
42786baecfSMauro Carvalho Chehab #ifndef USB_PID_DW3101
43786baecfSMauro Carvalho Chehab #define USB_PID_DW3101 0x3101
44786baecfSMauro Carvalho Chehab #endif
45786baecfSMauro Carvalho Chehab 
46786baecfSMauro Carvalho Chehab #ifndef USB_PID_CINERGY_S
47786baecfSMauro Carvalho Chehab #define USB_PID_CINERGY_S 0x0064
48786baecfSMauro Carvalho Chehab #endif
49786baecfSMauro Carvalho Chehab 
50786baecfSMauro Carvalho Chehab #ifndef USB_PID_TEVII_S630
51786baecfSMauro Carvalho Chehab #define USB_PID_TEVII_S630 0xd630
52786baecfSMauro Carvalho Chehab #endif
53786baecfSMauro Carvalho Chehab 
54786baecfSMauro Carvalho Chehab #ifndef USB_PID_TEVII_S650
55786baecfSMauro Carvalho Chehab #define USB_PID_TEVII_S650 0xd650
56786baecfSMauro Carvalho Chehab #endif
57786baecfSMauro Carvalho Chehab 
58786baecfSMauro Carvalho Chehab #ifndef USB_PID_TEVII_S660
59786baecfSMauro Carvalho Chehab #define USB_PID_TEVII_S660 0xd660
60786baecfSMauro Carvalho Chehab #endif
61786baecfSMauro Carvalho Chehab 
62786baecfSMauro Carvalho Chehab #ifndef USB_PID_TEVII_S480_1
63786baecfSMauro Carvalho Chehab #define USB_PID_TEVII_S480_1 0xd481
64786baecfSMauro Carvalho Chehab #endif
65786baecfSMauro Carvalho Chehab 
66786baecfSMauro Carvalho Chehab #ifndef USB_PID_TEVII_S480_2
67786baecfSMauro Carvalho Chehab #define USB_PID_TEVII_S480_2 0xd482
68786baecfSMauro Carvalho Chehab #endif
69786baecfSMauro Carvalho Chehab 
70786baecfSMauro Carvalho Chehab #ifndef USB_PID_PROF_1100
71786baecfSMauro Carvalho Chehab #define USB_PID_PROF_1100 0xb012
72786baecfSMauro Carvalho Chehab #endif
73786baecfSMauro Carvalho Chehab 
74955d00acSIgor M. Liplianin #ifndef USB_PID_TEVII_S421
75955d00acSIgor M. Liplianin #define USB_PID_TEVII_S421 0xd421
76955d00acSIgor M. Liplianin #endif
77955d00acSIgor M. Liplianin 
78955d00acSIgor M. Liplianin #ifndef USB_PID_TEVII_S632
79955d00acSIgor M. Liplianin #define USB_PID_TEVII_S632 0xd632
80955d00acSIgor M. Liplianin #endif
81955d00acSIgor M. Liplianin 
82786baecfSMauro Carvalho Chehab #define DW210X_READ_MSG 0
83786baecfSMauro Carvalho Chehab #define DW210X_WRITE_MSG 1
84786baecfSMauro Carvalho Chehab 
85786baecfSMauro Carvalho Chehab #define REG_1F_SYMBOLRATE_BYTE0 0x1f
86786baecfSMauro Carvalho Chehab #define REG_20_SYMBOLRATE_BYTE1 0x20
87786baecfSMauro Carvalho Chehab #define REG_21_SYMBOLRATE_BYTE2 0x21
88786baecfSMauro Carvalho Chehab /* on my own*/
89786baecfSMauro Carvalho Chehab #define DW2102_VOLTAGE_CTRL (0x1800)
90786baecfSMauro Carvalho Chehab #define SU3000_STREAM_CTRL (0x1900)
91786baecfSMauro Carvalho Chehab #define DW2102_RC_QUERY (0x1a00)
92786baecfSMauro Carvalho Chehab #define DW2102_LED_CTRL (0x1b00)
93786baecfSMauro Carvalho Chehab 
946823627bSRémi Cardona #define DW2101_FIRMWARE "dvb-usb-dw2101.fw"
956823627bSRémi Cardona #define DW2102_FIRMWARE "dvb-usb-dw2102.fw"
966823627bSRémi Cardona #define DW2104_FIRMWARE "dvb-usb-dw2104.fw"
976823627bSRémi Cardona #define DW3101_FIRMWARE "dvb-usb-dw3101.fw"
986823627bSRémi Cardona #define S630_FIRMWARE   "dvb-usb-s630.fw"
996823627bSRémi Cardona #define S660_FIRMWARE   "dvb-usb-s660.fw"
1006823627bSRémi Cardona #define P1100_FIRMWARE  "dvb-usb-p1100.fw"
1016823627bSRémi Cardona #define P7500_FIRMWARE  "dvb-usb-p7500.fw"
1026823627bSRémi Cardona 
103786baecfSMauro Carvalho Chehab #define	err_str "did not find the firmware file. (%s) " \
104786baecfSMauro Carvalho Chehab 		"Please see linux/Documentation/dvb/ for more details " \
105786baecfSMauro Carvalho Chehab 		"on firmware-problems."
106786baecfSMauro Carvalho Chehab 
107786baecfSMauro Carvalho Chehab struct rc_map_dvb_usb_table_table {
108786baecfSMauro Carvalho Chehab 	struct rc_map_table *rc_keys;
109786baecfSMauro Carvalho Chehab 	int rc_keys_size;
110786baecfSMauro Carvalho Chehab };
111786baecfSMauro Carvalho Chehab 
112786baecfSMauro Carvalho Chehab struct su3000_state {
113786baecfSMauro Carvalho Chehab 	u8 initialized;
114786baecfSMauro Carvalho Chehab };
115786baecfSMauro Carvalho Chehab 
116786baecfSMauro Carvalho Chehab struct s6x0_state {
117786baecfSMauro Carvalho Chehab 	int (*old_set_voltage)(struct dvb_frontend *f, fe_sec_voltage_t v);
118786baecfSMauro Carvalho Chehab };
119786baecfSMauro Carvalho Chehab 
120786baecfSMauro Carvalho Chehab /* debug */
121786baecfSMauro Carvalho Chehab static int dvb_usb_dw2102_debug;
122786baecfSMauro Carvalho Chehab module_param_named(debug, dvb_usb_dw2102_debug, int, 0644);
123786baecfSMauro Carvalho Chehab MODULE_PARM_DESC(debug, "set debugging level (1=info 2=xfer 4=rc(or-able))."
124786baecfSMauro Carvalho Chehab 						DVB_USB_DEBUG_STATUS);
125786baecfSMauro Carvalho Chehab 
126786baecfSMauro Carvalho Chehab /* keymaps */
127786baecfSMauro Carvalho Chehab static int ir_keymap;
128786baecfSMauro Carvalho Chehab module_param_named(keymap, ir_keymap, int, 0644);
129786baecfSMauro Carvalho Chehab MODULE_PARM_DESC(keymap, "set keymap 0=default 1=dvbworld 2=tevii 3=tbs  ..."
130786baecfSMauro Carvalho Chehab 			" 256=none");
131786baecfSMauro Carvalho Chehab 
132786baecfSMauro Carvalho Chehab /* demod probe */
133786baecfSMauro Carvalho Chehab static int demod_probe = 1;
134786baecfSMauro Carvalho Chehab module_param_named(demod, demod_probe, int, 0644);
135786baecfSMauro Carvalho Chehab MODULE_PARM_DESC(demod, "demod to probe (1=cx24116 2=stv0903+stv6110 "
136786baecfSMauro Carvalho Chehab 			"4=stv0903+stb6100(or-able)).");
137786baecfSMauro Carvalho Chehab 
138786baecfSMauro Carvalho Chehab DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
139786baecfSMauro Carvalho Chehab 
140786baecfSMauro Carvalho Chehab static int dw210x_op_rw(struct usb_device *dev, u8 request, u16 value,
141786baecfSMauro Carvalho Chehab 			u16 index, u8 * data, u16 len, int flags)
142786baecfSMauro Carvalho Chehab {
143786baecfSMauro Carvalho Chehab 	int ret;
144786baecfSMauro Carvalho Chehab 	u8 *u8buf;
145786baecfSMauro Carvalho Chehab 	unsigned int pipe = (flags == DW210X_READ_MSG) ?
146786baecfSMauro Carvalho Chehab 				usb_rcvctrlpipe(dev, 0) : usb_sndctrlpipe(dev, 0);
147786baecfSMauro Carvalho Chehab 	u8 request_type = (flags == DW210X_READ_MSG) ? USB_DIR_IN : USB_DIR_OUT;
148786baecfSMauro Carvalho Chehab 
149786baecfSMauro Carvalho Chehab 	u8buf = kmalloc(len, GFP_KERNEL);
150786baecfSMauro Carvalho Chehab 	if (!u8buf)
151786baecfSMauro Carvalho Chehab 		return -ENOMEM;
152786baecfSMauro Carvalho Chehab 
153786baecfSMauro Carvalho Chehab 
154786baecfSMauro Carvalho Chehab 	if (flags == DW210X_WRITE_MSG)
155786baecfSMauro Carvalho Chehab 		memcpy(u8buf, data, len);
156786baecfSMauro Carvalho Chehab 	ret = usb_control_msg(dev, pipe, request, request_type | USB_TYPE_VENDOR,
157786baecfSMauro Carvalho Chehab 				value, index , u8buf, len, 2000);
158786baecfSMauro Carvalho Chehab 
159786baecfSMauro Carvalho Chehab 	if (flags == DW210X_READ_MSG)
160786baecfSMauro Carvalho Chehab 		memcpy(data, u8buf, len);
161786baecfSMauro Carvalho Chehab 
162786baecfSMauro Carvalho Chehab 	kfree(u8buf);
163786baecfSMauro Carvalho Chehab 	return ret;
164786baecfSMauro Carvalho Chehab }
165786baecfSMauro Carvalho Chehab 
166786baecfSMauro Carvalho Chehab /* I2C */
167786baecfSMauro Carvalho Chehab static int dw2102_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
168786baecfSMauro Carvalho Chehab 		int num)
169786baecfSMauro Carvalho Chehab {
170786baecfSMauro Carvalho Chehab 	struct dvb_usb_device *d = i2c_get_adapdata(adap);
171786baecfSMauro Carvalho Chehab 	int i = 0;
172786baecfSMauro Carvalho Chehab 	u8 buf6[] = {0x2c, 0x05, 0xc0, 0, 0, 0, 0};
173786baecfSMauro Carvalho Chehab 	u16 value;
174786baecfSMauro Carvalho Chehab 
175786baecfSMauro Carvalho Chehab 	if (!d)
176786baecfSMauro Carvalho Chehab 		return -ENODEV;
177786baecfSMauro Carvalho Chehab 	if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
178786baecfSMauro Carvalho Chehab 		return -EAGAIN;
179786baecfSMauro Carvalho Chehab 
180786baecfSMauro Carvalho Chehab 	switch (num) {
181786baecfSMauro Carvalho Chehab 	case 2:
182786baecfSMauro Carvalho Chehab 		/* read stv0299 register */
183786baecfSMauro Carvalho Chehab 		value = msg[0].buf[0];/* register */
184786baecfSMauro Carvalho Chehab 		for (i = 0; i < msg[1].len; i++) {
185786baecfSMauro Carvalho Chehab 			dw210x_op_rw(d->udev, 0xb5, value + i, 0,
186786baecfSMauro Carvalho Chehab 					buf6, 2, DW210X_READ_MSG);
187786baecfSMauro Carvalho Chehab 			msg[1].buf[i] = buf6[0];
188786baecfSMauro Carvalho Chehab 		}
189786baecfSMauro Carvalho Chehab 		break;
190786baecfSMauro Carvalho Chehab 	case 1:
191786baecfSMauro Carvalho Chehab 		switch (msg[0].addr) {
192786baecfSMauro Carvalho Chehab 		case 0x68:
193786baecfSMauro Carvalho Chehab 			/* write to stv0299 register */
194786baecfSMauro Carvalho Chehab 			buf6[0] = 0x2a;
195786baecfSMauro Carvalho Chehab 			buf6[1] = msg[0].buf[0];
196786baecfSMauro Carvalho Chehab 			buf6[2] = msg[0].buf[1];
197786baecfSMauro Carvalho Chehab 			dw210x_op_rw(d->udev, 0xb2, 0, 0,
198786baecfSMauro Carvalho Chehab 					buf6, 3, DW210X_WRITE_MSG);
199786baecfSMauro Carvalho Chehab 			break;
200786baecfSMauro Carvalho Chehab 		case 0x60:
201786baecfSMauro Carvalho Chehab 			if (msg[0].flags == 0) {
202786baecfSMauro Carvalho Chehab 			/* write to tuner pll */
203786baecfSMauro Carvalho Chehab 				buf6[0] = 0x2c;
204786baecfSMauro Carvalho Chehab 				buf6[1] = 5;
205786baecfSMauro Carvalho Chehab 				buf6[2] = 0xc0;
206786baecfSMauro Carvalho Chehab 				buf6[3] = msg[0].buf[0];
207786baecfSMauro Carvalho Chehab 				buf6[4] = msg[0].buf[1];
208786baecfSMauro Carvalho Chehab 				buf6[5] = msg[0].buf[2];
209786baecfSMauro Carvalho Chehab 				buf6[6] = msg[0].buf[3];
210786baecfSMauro Carvalho Chehab 				dw210x_op_rw(d->udev, 0xb2, 0, 0,
211786baecfSMauro Carvalho Chehab 						buf6, 7, DW210X_WRITE_MSG);
212786baecfSMauro Carvalho Chehab 			} else {
213786baecfSMauro Carvalho Chehab 			/* read from tuner */
214786baecfSMauro Carvalho Chehab 				dw210x_op_rw(d->udev, 0xb5, 0, 0,
215786baecfSMauro Carvalho Chehab 						buf6, 1, DW210X_READ_MSG);
216786baecfSMauro Carvalho Chehab 				msg[0].buf[0] = buf6[0];
217786baecfSMauro Carvalho Chehab 			}
218786baecfSMauro Carvalho Chehab 			break;
219786baecfSMauro Carvalho Chehab 		case (DW2102_RC_QUERY):
220786baecfSMauro Carvalho Chehab 			dw210x_op_rw(d->udev, 0xb8, 0, 0,
221786baecfSMauro Carvalho Chehab 					buf6, 2, DW210X_READ_MSG);
222786baecfSMauro Carvalho Chehab 			msg[0].buf[0] = buf6[0];
223786baecfSMauro Carvalho Chehab 			msg[0].buf[1] = buf6[1];
224786baecfSMauro Carvalho Chehab 			break;
225786baecfSMauro Carvalho Chehab 		case (DW2102_VOLTAGE_CTRL):
226786baecfSMauro Carvalho Chehab 			buf6[0] = 0x30;
227786baecfSMauro Carvalho Chehab 			buf6[1] = msg[0].buf[0];
228786baecfSMauro Carvalho Chehab 			dw210x_op_rw(d->udev, 0xb2, 0, 0,
229786baecfSMauro Carvalho Chehab 					buf6, 2, DW210X_WRITE_MSG);
230786baecfSMauro Carvalho Chehab 			break;
231786baecfSMauro Carvalho Chehab 		}
232786baecfSMauro Carvalho Chehab 
233786baecfSMauro Carvalho Chehab 		break;
234786baecfSMauro Carvalho Chehab 	}
235786baecfSMauro Carvalho Chehab 
236786baecfSMauro Carvalho Chehab 	mutex_unlock(&d->i2c_mutex);
237786baecfSMauro Carvalho Chehab 	return num;
238786baecfSMauro Carvalho Chehab }
239786baecfSMauro Carvalho Chehab 
240786baecfSMauro Carvalho Chehab static int dw2102_serit_i2c_transfer(struct i2c_adapter *adap,
241786baecfSMauro Carvalho Chehab 						struct i2c_msg msg[], int num)
242786baecfSMauro Carvalho Chehab {
243786baecfSMauro Carvalho Chehab 	struct dvb_usb_device *d = i2c_get_adapdata(adap);
244786baecfSMauro Carvalho Chehab 	u8 buf6[] = {0, 0, 0, 0, 0, 0, 0};
245786baecfSMauro Carvalho Chehab 
246786baecfSMauro Carvalho Chehab 	if (!d)
247786baecfSMauro Carvalho Chehab 		return -ENODEV;
248786baecfSMauro Carvalho Chehab 	if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
249786baecfSMauro Carvalho Chehab 		return -EAGAIN;
250786baecfSMauro Carvalho Chehab 
251786baecfSMauro Carvalho Chehab 	switch (num) {
252786baecfSMauro Carvalho Chehab 	case 2:
253786baecfSMauro Carvalho Chehab 		/* read si2109 register by number */
254786baecfSMauro Carvalho Chehab 		buf6[0] = msg[0].addr << 1;
255786baecfSMauro Carvalho Chehab 		buf6[1] = msg[0].len;
256786baecfSMauro Carvalho Chehab 		buf6[2] = msg[0].buf[0];
257786baecfSMauro Carvalho Chehab 		dw210x_op_rw(d->udev, 0xc2, 0, 0,
258786baecfSMauro Carvalho Chehab 				buf6, msg[0].len + 2, DW210X_WRITE_MSG);
259786baecfSMauro Carvalho Chehab 		/* read si2109 register */
260786baecfSMauro Carvalho Chehab 		dw210x_op_rw(d->udev, 0xc3, 0xd0, 0,
261786baecfSMauro Carvalho Chehab 				buf6, msg[1].len + 2, DW210X_READ_MSG);
262786baecfSMauro Carvalho Chehab 		memcpy(msg[1].buf, buf6 + 2, msg[1].len);
263786baecfSMauro Carvalho Chehab 
264786baecfSMauro Carvalho Chehab 		break;
265786baecfSMauro Carvalho Chehab 	case 1:
266786baecfSMauro Carvalho Chehab 		switch (msg[0].addr) {
267786baecfSMauro Carvalho Chehab 		case 0x68:
268786baecfSMauro Carvalho Chehab 			/* write to si2109 register */
269786baecfSMauro Carvalho Chehab 			buf6[0] = msg[0].addr << 1;
270786baecfSMauro Carvalho Chehab 			buf6[1] = msg[0].len;
271786baecfSMauro Carvalho Chehab 			memcpy(buf6 + 2, msg[0].buf, msg[0].len);
272786baecfSMauro Carvalho Chehab 			dw210x_op_rw(d->udev, 0xc2, 0, 0, buf6,
273786baecfSMauro Carvalho Chehab 					msg[0].len + 2, DW210X_WRITE_MSG);
274786baecfSMauro Carvalho Chehab 			break;
275786baecfSMauro Carvalho Chehab 		case(DW2102_RC_QUERY):
276786baecfSMauro Carvalho Chehab 			dw210x_op_rw(d->udev, 0xb8, 0, 0,
277786baecfSMauro Carvalho Chehab 					buf6, 2, DW210X_READ_MSG);
278786baecfSMauro Carvalho Chehab 			msg[0].buf[0] = buf6[0];
279786baecfSMauro Carvalho Chehab 			msg[0].buf[1] = buf6[1];
280786baecfSMauro Carvalho Chehab 			break;
281786baecfSMauro Carvalho Chehab 		case(DW2102_VOLTAGE_CTRL):
282786baecfSMauro Carvalho Chehab 			buf6[0] = 0x30;
283786baecfSMauro Carvalho Chehab 			buf6[1] = msg[0].buf[0];
284786baecfSMauro Carvalho Chehab 			dw210x_op_rw(d->udev, 0xb2, 0, 0,
285786baecfSMauro Carvalho Chehab 					buf6, 2, DW210X_WRITE_MSG);
286786baecfSMauro Carvalho Chehab 			break;
287786baecfSMauro Carvalho Chehab 		}
288786baecfSMauro Carvalho Chehab 		break;
289786baecfSMauro Carvalho Chehab 	}
290786baecfSMauro Carvalho Chehab 
291786baecfSMauro Carvalho Chehab 	mutex_unlock(&d->i2c_mutex);
292786baecfSMauro Carvalho Chehab 	return num;
293786baecfSMauro Carvalho Chehab }
294786baecfSMauro Carvalho Chehab 
295786baecfSMauro Carvalho Chehab static int dw2102_earda_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], int num)
296786baecfSMauro Carvalho Chehab {
297786baecfSMauro Carvalho Chehab 	struct dvb_usb_device *d = i2c_get_adapdata(adap);
298786baecfSMauro Carvalho Chehab 
299786baecfSMauro Carvalho Chehab 	if (!d)
300786baecfSMauro Carvalho Chehab 		return -ENODEV;
301786baecfSMauro Carvalho Chehab 	if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
302786baecfSMauro Carvalho Chehab 		return -EAGAIN;
303786baecfSMauro Carvalho Chehab 
304786baecfSMauro Carvalho Chehab 	switch (num) {
305786baecfSMauro Carvalho Chehab 	case 2: {
306786baecfSMauro Carvalho Chehab 		/* read */
307786baecfSMauro Carvalho Chehab 		/* first write first register number */
308786baecfSMauro Carvalho Chehab 		u8 ibuf[msg[1].len + 2], obuf[3];
309786baecfSMauro Carvalho Chehab 		obuf[0] = msg[0].addr << 1;
310786baecfSMauro Carvalho Chehab 		obuf[1] = msg[0].len;
311786baecfSMauro Carvalho Chehab 		obuf[2] = msg[0].buf[0];
312786baecfSMauro Carvalho Chehab 		dw210x_op_rw(d->udev, 0xc2, 0, 0,
313786baecfSMauro Carvalho Chehab 				obuf, msg[0].len + 2, DW210X_WRITE_MSG);
314786baecfSMauro Carvalho Chehab 		/* second read registers */
315786baecfSMauro Carvalho Chehab 		dw210x_op_rw(d->udev, 0xc3, 0xd1 , 0,
316786baecfSMauro Carvalho Chehab 				ibuf, msg[1].len + 2, DW210X_READ_MSG);
317786baecfSMauro Carvalho Chehab 		memcpy(msg[1].buf, ibuf + 2, msg[1].len);
318786baecfSMauro Carvalho Chehab 
319786baecfSMauro Carvalho Chehab 		break;
320786baecfSMauro Carvalho Chehab 	}
321786baecfSMauro Carvalho Chehab 	case 1:
322786baecfSMauro Carvalho Chehab 		switch (msg[0].addr) {
323786baecfSMauro Carvalho Chehab 		case 0x68: {
324786baecfSMauro Carvalho Chehab 			/* write to register */
325786baecfSMauro Carvalho Chehab 			u8 obuf[msg[0].len + 2];
326786baecfSMauro Carvalho Chehab 			obuf[0] = msg[0].addr << 1;
327786baecfSMauro Carvalho Chehab 			obuf[1] = msg[0].len;
328786baecfSMauro Carvalho Chehab 			memcpy(obuf + 2, msg[0].buf, msg[0].len);
329786baecfSMauro Carvalho Chehab 			dw210x_op_rw(d->udev, 0xc2, 0, 0,
330786baecfSMauro Carvalho Chehab 					obuf, msg[0].len + 2, DW210X_WRITE_MSG);
331786baecfSMauro Carvalho Chehab 			break;
332786baecfSMauro Carvalho Chehab 		}
333786baecfSMauro Carvalho Chehab 		case 0x61: {
334786baecfSMauro Carvalho Chehab 			/* write to tuner */
335786baecfSMauro Carvalho Chehab 			u8 obuf[msg[0].len + 2];
336786baecfSMauro Carvalho Chehab 			obuf[0] = msg[0].addr << 1;
337786baecfSMauro Carvalho Chehab 			obuf[1] = msg[0].len;
338786baecfSMauro Carvalho Chehab 			memcpy(obuf + 2, msg[0].buf, msg[0].len);
339786baecfSMauro Carvalho Chehab 			dw210x_op_rw(d->udev, 0xc2, 0, 0,
340786baecfSMauro Carvalho Chehab 					obuf, msg[0].len + 2, DW210X_WRITE_MSG);
341786baecfSMauro Carvalho Chehab 			break;
342786baecfSMauro Carvalho Chehab 		}
343786baecfSMauro Carvalho Chehab 		case(DW2102_RC_QUERY): {
344786baecfSMauro Carvalho Chehab 			u8 ibuf[2];
345786baecfSMauro Carvalho Chehab 			dw210x_op_rw(d->udev, 0xb8, 0, 0,
346786baecfSMauro Carvalho Chehab 					ibuf, 2, DW210X_READ_MSG);
347786baecfSMauro Carvalho Chehab 			memcpy(msg[0].buf, ibuf , 2);
348786baecfSMauro Carvalho Chehab 			break;
349786baecfSMauro Carvalho Chehab 		}
350786baecfSMauro Carvalho Chehab 		case(DW2102_VOLTAGE_CTRL): {
351786baecfSMauro Carvalho Chehab 			u8 obuf[2];
352786baecfSMauro Carvalho Chehab 			obuf[0] = 0x30;
353786baecfSMauro Carvalho Chehab 			obuf[1] = msg[0].buf[0];
354786baecfSMauro Carvalho Chehab 			dw210x_op_rw(d->udev, 0xb2, 0, 0,
355786baecfSMauro Carvalho Chehab 					obuf, 2, DW210X_WRITE_MSG);
356786baecfSMauro Carvalho Chehab 			break;
357786baecfSMauro Carvalho Chehab 		}
358786baecfSMauro Carvalho Chehab 		}
359786baecfSMauro Carvalho Chehab 
360786baecfSMauro Carvalho Chehab 		break;
361786baecfSMauro Carvalho Chehab 	}
362786baecfSMauro Carvalho Chehab 
363786baecfSMauro Carvalho Chehab 	mutex_unlock(&d->i2c_mutex);
364786baecfSMauro Carvalho Chehab 	return num;
365786baecfSMauro Carvalho Chehab }
366786baecfSMauro Carvalho Chehab 
367786baecfSMauro Carvalho Chehab static int dw2104_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], int num)
368786baecfSMauro Carvalho Chehab {
369786baecfSMauro Carvalho Chehab 	struct dvb_usb_device *d = i2c_get_adapdata(adap);
370786baecfSMauro Carvalho Chehab 	int len, i, j;
371786baecfSMauro Carvalho Chehab 
372786baecfSMauro Carvalho Chehab 	if (!d)
373786baecfSMauro Carvalho Chehab 		return -ENODEV;
374786baecfSMauro Carvalho Chehab 	if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
375786baecfSMauro Carvalho Chehab 		return -EAGAIN;
376786baecfSMauro Carvalho Chehab 
377786baecfSMauro Carvalho Chehab 	for (j = 0; j < num; j++) {
378786baecfSMauro Carvalho Chehab 		switch (msg[j].addr) {
379786baecfSMauro Carvalho Chehab 		case(DW2102_RC_QUERY): {
380786baecfSMauro Carvalho Chehab 			u8 ibuf[2];
381786baecfSMauro Carvalho Chehab 			dw210x_op_rw(d->udev, 0xb8, 0, 0,
382786baecfSMauro Carvalho Chehab 					ibuf, 2, DW210X_READ_MSG);
383786baecfSMauro Carvalho Chehab 			memcpy(msg[j].buf, ibuf , 2);
384786baecfSMauro Carvalho Chehab 			break;
385786baecfSMauro Carvalho Chehab 		}
386786baecfSMauro Carvalho Chehab 		case(DW2102_VOLTAGE_CTRL): {
387786baecfSMauro Carvalho Chehab 			u8 obuf[2];
388786baecfSMauro Carvalho Chehab 			obuf[0] = 0x30;
389786baecfSMauro Carvalho Chehab 			obuf[1] = msg[j].buf[0];
390786baecfSMauro Carvalho Chehab 			dw210x_op_rw(d->udev, 0xb2, 0, 0,
391786baecfSMauro Carvalho Chehab 					obuf, 2, DW210X_WRITE_MSG);
392786baecfSMauro Carvalho Chehab 			break;
393786baecfSMauro Carvalho Chehab 		}
394786baecfSMauro Carvalho Chehab 		/*case 0x55: cx24116
395786baecfSMauro Carvalho Chehab 		case 0x6a: stv0903
396786baecfSMauro Carvalho Chehab 		case 0x68: ds3000, stv0903
397786baecfSMauro Carvalho Chehab 		case 0x60: ts2020, stv6110, stb6100 */
398786baecfSMauro Carvalho Chehab 		default: {
399786baecfSMauro Carvalho Chehab 			if (msg[j].flags == I2C_M_RD) {
400786baecfSMauro Carvalho Chehab 				/* read registers */
401786baecfSMauro Carvalho Chehab 				u8  ibuf[msg[j].len + 2];
402786baecfSMauro Carvalho Chehab 				dw210x_op_rw(d->udev, 0xc3,
403786baecfSMauro Carvalho Chehab 						(msg[j].addr << 1) + 1, 0,
404786baecfSMauro Carvalho Chehab 						ibuf, msg[j].len + 2,
405786baecfSMauro Carvalho Chehab 						DW210X_READ_MSG);
406786baecfSMauro Carvalho Chehab 				memcpy(msg[j].buf, ibuf + 2, msg[j].len);
407786baecfSMauro Carvalho Chehab 			mdelay(10);
408786baecfSMauro Carvalho Chehab 			} else if (((msg[j].buf[0] == 0xb0) &&
409786baecfSMauro Carvalho Chehab 						(msg[j].addr == 0x68)) ||
410786baecfSMauro Carvalho Chehab 						((msg[j].buf[0] == 0xf7) &&
411786baecfSMauro Carvalho Chehab 						(msg[j].addr == 0x55))) {
412786baecfSMauro Carvalho Chehab 				/* write firmware */
413786baecfSMauro Carvalho Chehab 				u8 obuf[19];
414786baecfSMauro Carvalho Chehab 				obuf[0] = msg[j].addr << 1;
415786baecfSMauro Carvalho Chehab 				obuf[1] = (msg[j].len > 15 ? 17 : msg[j].len);
416786baecfSMauro Carvalho Chehab 				obuf[2] = msg[j].buf[0];
417786baecfSMauro Carvalho Chehab 				len = msg[j].len - 1;
418786baecfSMauro Carvalho Chehab 				i = 1;
419786baecfSMauro Carvalho Chehab 				do {
420786baecfSMauro Carvalho Chehab 					memcpy(obuf + 3, msg[j].buf + i,
421786baecfSMauro Carvalho Chehab 							(len > 16 ? 16 : len));
422786baecfSMauro Carvalho Chehab 					dw210x_op_rw(d->udev, 0xc2, 0, 0,
423786baecfSMauro Carvalho Chehab 						obuf, (len > 16 ? 16 : len) + 3,
424786baecfSMauro Carvalho Chehab 						DW210X_WRITE_MSG);
425786baecfSMauro Carvalho Chehab 					i += 16;
426786baecfSMauro Carvalho Chehab 					len -= 16;
427786baecfSMauro Carvalho Chehab 				} while (len > 0);
428786baecfSMauro Carvalho Chehab 			} else {
429786baecfSMauro Carvalho Chehab 				/* write registers */
430786baecfSMauro Carvalho Chehab 				u8 obuf[msg[j].len + 2];
431786baecfSMauro Carvalho Chehab 				obuf[0] = msg[j].addr << 1;
432786baecfSMauro Carvalho Chehab 				obuf[1] = msg[j].len;
433786baecfSMauro Carvalho Chehab 				memcpy(obuf + 2, msg[j].buf, msg[j].len);
434786baecfSMauro Carvalho Chehab 				dw210x_op_rw(d->udev, 0xc2, 0, 0,
435786baecfSMauro Carvalho Chehab 						obuf, msg[j].len + 2,
436786baecfSMauro Carvalho Chehab 						DW210X_WRITE_MSG);
437786baecfSMauro Carvalho Chehab 			}
438786baecfSMauro Carvalho Chehab 			break;
439786baecfSMauro Carvalho Chehab 		}
440786baecfSMauro Carvalho Chehab 		}
441786baecfSMauro Carvalho Chehab 
442786baecfSMauro Carvalho Chehab 	}
443786baecfSMauro Carvalho Chehab 
444786baecfSMauro Carvalho Chehab 	mutex_unlock(&d->i2c_mutex);
445786baecfSMauro Carvalho Chehab 	return num;
446786baecfSMauro Carvalho Chehab }
447786baecfSMauro Carvalho Chehab 
448786baecfSMauro Carvalho Chehab static int dw3101_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
449786baecfSMauro Carvalho Chehab 								int num)
450786baecfSMauro Carvalho Chehab {
451786baecfSMauro Carvalho Chehab 	struct dvb_usb_device *d = i2c_get_adapdata(adap);
452786baecfSMauro Carvalho Chehab 	int i;
453786baecfSMauro Carvalho Chehab 
454786baecfSMauro Carvalho Chehab 	if (!d)
455786baecfSMauro Carvalho Chehab 		return -ENODEV;
456786baecfSMauro Carvalho Chehab 	if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
457786baecfSMauro Carvalho Chehab 		return -EAGAIN;
458786baecfSMauro Carvalho Chehab 
459786baecfSMauro Carvalho Chehab 	switch (num) {
460786baecfSMauro Carvalho Chehab 	case 2: {
461786baecfSMauro Carvalho Chehab 		/* read */
462786baecfSMauro Carvalho Chehab 		/* first write first register number */
463786baecfSMauro Carvalho Chehab 		u8 ibuf[msg[1].len + 2], obuf[3];
464786baecfSMauro Carvalho Chehab 		obuf[0] = msg[0].addr << 1;
465786baecfSMauro Carvalho Chehab 		obuf[1] = msg[0].len;
466786baecfSMauro Carvalho Chehab 		obuf[2] = msg[0].buf[0];
467786baecfSMauro Carvalho Chehab 		dw210x_op_rw(d->udev, 0xc2, 0, 0,
468786baecfSMauro Carvalho Chehab 				obuf, msg[0].len + 2, DW210X_WRITE_MSG);
469786baecfSMauro Carvalho Chehab 		/* second read registers */
470786baecfSMauro Carvalho Chehab 		dw210x_op_rw(d->udev, 0xc3, 0x19 , 0,
471786baecfSMauro Carvalho Chehab 				ibuf, msg[1].len + 2, DW210X_READ_MSG);
472786baecfSMauro Carvalho Chehab 		memcpy(msg[1].buf, ibuf + 2, msg[1].len);
473786baecfSMauro Carvalho Chehab 
474786baecfSMauro Carvalho Chehab 		break;
475786baecfSMauro Carvalho Chehab 	}
476786baecfSMauro Carvalho Chehab 	case 1:
477786baecfSMauro Carvalho Chehab 		switch (msg[0].addr) {
478786baecfSMauro Carvalho Chehab 		case 0x60:
479786baecfSMauro Carvalho Chehab 		case 0x0c: {
480786baecfSMauro Carvalho Chehab 			/* write to register */
481786baecfSMauro Carvalho Chehab 			u8 obuf[msg[0].len + 2];
482786baecfSMauro Carvalho Chehab 			obuf[0] = msg[0].addr << 1;
483786baecfSMauro Carvalho Chehab 			obuf[1] = msg[0].len;
484786baecfSMauro Carvalho Chehab 			memcpy(obuf + 2, msg[0].buf, msg[0].len);
485786baecfSMauro Carvalho Chehab 			dw210x_op_rw(d->udev, 0xc2, 0, 0,
486786baecfSMauro Carvalho Chehab 					obuf, msg[0].len + 2, DW210X_WRITE_MSG);
487786baecfSMauro Carvalho Chehab 			break;
488786baecfSMauro Carvalho Chehab 		}
489786baecfSMauro Carvalho Chehab 		case(DW2102_RC_QUERY): {
490786baecfSMauro Carvalho Chehab 			u8 ibuf[2];
491786baecfSMauro Carvalho Chehab 			dw210x_op_rw(d->udev, 0xb8, 0, 0,
492786baecfSMauro Carvalho Chehab 					ibuf, 2, DW210X_READ_MSG);
493786baecfSMauro Carvalho Chehab 			memcpy(msg[0].buf, ibuf , 2);
494786baecfSMauro Carvalho Chehab 			break;
495786baecfSMauro Carvalho Chehab 		}
496786baecfSMauro Carvalho Chehab 		}
497786baecfSMauro Carvalho Chehab 
498786baecfSMauro Carvalho Chehab 		break;
499786baecfSMauro Carvalho Chehab 	}
500786baecfSMauro Carvalho Chehab 
501786baecfSMauro Carvalho Chehab 	for (i = 0; i < num; i++) {
502786baecfSMauro Carvalho Chehab 		deb_xfer("%02x:%02x: %s ", i, msg[i].addr,
503786baecfSMauro Carvalho Chehab 				msg[i].flags == 0 ? ">>>" : "<<<");
504786baecfSMauro Carvalho Chehab 		debug_dump(msg[i].buf, msg[i].len, deb_xfer);
505786baecfSMauro Carvalho Chehab 	}
506786baecfSMauro Carvalho Chehab 
507786baecfSMauro Carvalho Chehab 	mutex_unlock(&d->i2c_mutex);
508786baecfSMauro Carvalho Chehab 	return num;
509786baecfSMauro Carvalho Chehab }
510786baecfSMauro Carvalho Chehab 
511786baecfSMauro Carvalho Chehab static int s6x0_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
512786baecfSMauro Carvalho Chehab 								int num)
513786baecfSMauro Carvalho Chehab {
514786baecfSMauro Carvalho Chehab 	struct dvb_usb_device *d = i2c_get_adapdata(adap);
515786baecfSMauro Carvalho Chehab 	struct usb_device *udev;
516786baecfSMauro Carvalho Chehab 	int len, i, j;
517786baecfSMauro Carvalho Chehab 
518786baecfSMauro Carvalho Chehab 	if (!d)
519786baecfSMauro Carvalho Chehab 		return -ENODEV;
520786baecfSMauro Carvalho Chehab 	udev = d->udev;
521786baecfSMauro Carvalho Chehab 	if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
522786baecfSMauro Carvalho Chehab 		return -EAGAIN;
523786baecfSMauro Carvalho Chehab 
524786baecfSMauro Carvalho Chehab 	for (j = 0; j < num; j++) {
525786baecfSMauro Carvalho Chehab 		switch (msg[j].addr) {
526786baecfSMauro Carvalho Chehab 		case (DW2102_RC_QUERY): {
527786baecfSMauro Carvalho Chehab 			u8 ibuf[5];
528786baecfSMauro Carvalho Chehab 			dw210x_op_rw(d->udev, 0xb8, 0, 0,
529786baecfSMauro Carvalho Chehab 					ibuf, 5, DW210X_READ_MSG);
530786baecfSMauro Carvalho Chehab 			memcpy(msg[j].buf, ibuf + 3, 2);
531786baecfSMauro Carvalho Chehab 			break;
532786baecfSMauro Carvalho Chehab 		}
533786baecfSMauro Carvalho Chehab 		case (DW2102_VOLTAGE_CTRL): {
534786baecfSMauro Carvalho Chehab 			u8 obuf[2];
535786baecfSMauro Carvalho Chehab 
536786baecfSMauro Carvalho Chehab 			obuf[0] = 1;
537786baecfSMauro Carvalho Chehab 			obuf[1] = msg[j].buf[1];/* off-on */
538786baecfSMauro Carvalho Chehab 			dw210x_op_rw(d->udev, 0x8a, 0, 0,
539786baecfSMauro Carvalho Chehab 					obuf, 2, DW210X_WRITE_MSG);
540786baecfSMauro Carvalho Chehab 			obuf[0] = 3;
541786baecfSMauro Carvalho Chehab 			obuf[1] = msg[j].buf[0];/* 13v-18v */
542786baecfSMauro Carvalho Chehab 			dw210x_op_rw(d->udev, 0x8a, 0, 0,
543786baecfSMauro Carvalho Chehab 					obuf, 2, DW210X_WRITE_MSG);
544786baecfSMauro Carvalho Chehab 			break;
545786baecfSMauro Carvalho Chehab 		}
546786baecfSMauro Carvalho Chehab 		case (DW2102_LED_CTRL): {
547786baecfSMauro Carvalho Chehab 			u8 obuf[2];
548786baecfSMauro Carvalho Chehab 
549786baecfSMauro Carvalho Chehab 			obuf[0] = 5;
550786baecfSMauro Carvalho Chehab 			obuf[1] = msg[j].buf[0];
551786baecfSMauro Carvalho Chehab 			dw210x_op_rw(d->udev, 0x8a, 0, 0,
552786baecfSMauro Carvalho Chehab 					obuf, 2, DW210X_WRITE_MSG);
553786baecfSMauro Carvalho Chehab 			break;
554786baecfSMauro Carvalho Chehab 		}
555786baecfSMauro Carvalho Chehab 		/*case 0x55: cx24116
556786baecfSMauro Carvalho Chehab 		case 0x6a: stv0903
557955d00acSIgor M. Liplianin 		case 0x68: ds3000, stv0903, rs2000
558786baecfSMauro Carvalho Chehab 		case 0x60: ts2020, stv6110, stb6100
559786baecfSMauro Carvalho Chehab 		case 0xa0: eeprom */
560786baecfSMauro Carvalho Chehab 		default: {
561786baecfSMauro Carvalho Chehab 			if (msg[j].flags == I2C_M_RD) {
562786baecfSMauro Carvalho Chehab 				/* read registers */
563786baecfSMauro Carvalho Chehab 				u8 ibuf[msg[j].len];
564786baecfSMauro Carvalho Chehab 				dw210x_op_rw(d->udev, 0x91, 0, 0,
565786baecfSMauro Carvalho Chehab 						ibuf, msg[j].len,
566786baecfSMauro Carvalho Chehab 						DW210X_READ_MSG);
567786baecfSMauro Carvalho Chehab 				memcpy(msg[j].buf, ibuf, msg[j].len);
568786baecfSMauro Carvalho Chehab 				break;
569786baecfSMauro Carvalho Chehab 			} else if ((msg[j].buf[0] == 0xb0) &&
570786baecfSMauro Carvalho Chehab 						(msg[j].addr == 0x68)) {
571786baecfSMauro Carvalho Chehab 				/* write firmware */
572786baecfSMauro Carvalho Chehab 				u8 obuf[19];
573786baecfSMauro Carvalho Chehab 				obuf[0] = (msg[j].len > 16 ?
574786baecfSMauro Carvalho Chehab 						18 : msg[j].len + 1);
575786baecfSMauro Carvalho Chehab 				obuf[1] = msg[j].addr << 1;
576786baecfSMauro Carvalho Chehab 				obuf[2] = msg[j].buf[0];
577786baecfSMauro Carvalho Chehab 				len = msg[j].len - 1;
578786baecfSMauro Carvalho Chehab 				i = 1;
579786baecfSMauro Carvalho Chehab 				do {
580786baecfSMauro Carvalho Chehab 					memcpy(obuf + 3, msg[j].buf + i,
581786baecfSMauro Carvalho Chehab 							(len > 16 ? 16 : len));
582786baecfSMauro Carvalho Chehab 					dw210x_op_rw(d->udev, 0x80, 0, 0,
583786baecfSMauro Carvalho Chehab 						obuf, (len > 16 ? 16 : len) + 3,
584786baecfSMauro Carvalho Chehab 						DW210X_WRITE_MSG);
585786baecfSMauro Carvalho Chehab 					i += 16;
586786baecfSMauro Carvalho Chehab 					len -= 16;
587786baecfSMauro Carvalho Chehab 				} while (len > 0);
588786baecfSMauro Carvalho Chehab 			} else if (j < (num - 1)) {
589786baecfSMauro Carvalho Chehab 				/* write register addr before read */
590786baecfSMauro Carvalho Chehab 				u8 obuf[msg[j].len + 2];
591786baecfSMauro Carvalho Chehab 				obuf[0] = msg[j + 1].len;
592786baecfSMauro Carvalho Chehab 				obuf[1] = (msg[j].addr << 1);
593786baecfSMauro Carvalho Chehab 				memcpy(obuf + 2, msg[j].buf, msg[j].len);
594786baecfSMauro Carvalho Chehab 				dw210x_op_rw(d->udev,
595786baecfSMauro Carvalho Chehab 						udev->descriptor.idProduct ==
596786baecfSMauro Carvalho Chehab 						0x7500 ? 0x92 : 0x90, 0, 0,
597786baecfSMauro Carvalho Chehab 						obuf, msg[j].len + 2,
598786baecfSMauro Carvalho Chehab 						DW210X_WRITE_MSG);
599786baecfSMauro Carvalho Chehab 				break;
600786baecfSMauro Carvalho Chehab 			} else {
601786baecfSMauro Carvalho Chehab 				/* write registers */
602786baecfSMauro Carvalho Chehab 				u8 obuf[msg[j].len + 2];
603786baecfSMauro Carvalho Chehab 				obuf[0] = msg[j].len + 1;
604786baecfSMauro Carvalho Chehab 				obuf[1] = (msg[j].addr << 1);
605786baecfSMauro Carvalho Chehab 				memcpy(obuf + 2, msg[j].buf, msg[j].len);
606786baecfSMauro Carvalho Chehab 				dw210x_op_rw(d->udev, 0x80, 0, 0,
607786baecfSMauro Carvalho Chehab 						obuf, msg[j].len + 2,
608786baecfSMauro Carvalho Chehab 						DW210X_WRITE_MSG);
609786baecfSMauro Carvalho Chehab 				break;
610786baecfSMauro Carvalho Chehab 			}
611786baecfSMauro Carvalho Chehab 			break;
612786baecfSMauro Carvalho Chehab 		}
613786baecfSMauro Carvalho Chehab 		}
614786baecfSMauro Carvalho Chehab 	}
615786baecfSMauro Carvalho Chehab 
616786baecfSMauro Carvalho Chehab 	mutex_unlock(&d->i2c_mutex);
617786baecfSMauro Carvalho Chehab 	return num;
618786baecfSMauro Carvalho Chehab }
619786baecfSMauro Carvalho Chehab 
620786baecfSMauro Carvalho Chehab static int su3000_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
621786baecfSMauro Carvalho Chehab 								int num)
622786baecfSMauro Carvalho Chehab {
623786baecfSMauro Carvalho Chehab 	struct dvb_usb_device *d = i2c_get_adapdata(adap);
624786baecfSMauro Carvalho Chehab 	u8 obuf[0x40], ibuf[0x40];
625786baecfSMauro Carvalho Chehab 
626786baecfSMauro Carvalho Chehab 	if (!d)
627786baecfSMauro Carvalho Chehab 		return -ENODEV;
628786baecfSMauro Carvalho Chehab 	if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
629786baecfSMauro Carvalho Chehab 		return -EAGAIN;
630786baecfSMauro Carvalho Chehab 
631786baecfSMauro Carvalho Chehab 	switch (num) {
632786baecfSMauro Carvalho Chehab 	case 1:
633786baecfSMauro Carvalho Chehab 		switch (msg[0].addr) {
634786baecfSMauro Carvalho Chehab 		case SU3000_STREAM_CTRL:
635786baecfSMauro Carvalho Chehab 			obuf[0] = msg[0].buf[0] + 0x36;
636786baecfSMauro Carvalho Chehab 			obuf[1] = 3;
637786baecfSMauro Carvalho Chehab 			obuf[2] = 0;
638786baecfSMauro Carvalho Chehab 			if (dvb_usb_generic_rw(d, obuf, 3, ibuf, 0, 0) < 0)
639786baecfSMauro Carvalho Chehab 				err("i2c transfer failed.");
640786baecfSMauro Carvalho Chehab 			break;
641786baecfSMauro Carvalho Chehab 		case DW2102_RC_QUERY:
642786baecfSMauro Carvalho Chehab 			obuf[0] = 0x10;
643786baecfSMauro Carvalho Chehab 			if (dvb_usb_generic_rw(d, obuf, 1, ibuf, 2, 0) < 0)
644786baecfSMauro Carvalho Chehab 				err("i2c transfer failed.");
645786baecfSMauro Carvalho Chehab 			msg[0].buf[1] = ibuf[0];
646786baecfSMauro Carvalho Chehab 			msg[0].buf[0] = ibuf[1];
647786baecfSMauro Carvalho Chehab 			break;
648786baecfSMauro Carvalho Chehab 		default:
649786baecfSMauro Carvalho Chehab 			/* always i2c write*/
650786baecfSMauro Carvalho Chehab 			obuf[0] = 0x08;
651786baecfSMauro Carvalho Chehab 			obuf[1] = msg[0].addr;
652786baecfSMauro Carvalho Chehab 			obuf[2] = msg[0].len;
653786baecfSMauro Carvalho Chehab 
654786baecfSMauro Carvalho Chehab 			memcpy(&obuf[3], msg[0].buf, msg[0].len);
655786baecfSMauro Carvalho Chehab 
656786baecfSMauro Carvalho Chehab 			if (dvb_usb_generic_rw(d, obuf, msg[0].len + 3,
657786baecfSMauro Carvalho Chehab 						ibuf, 1, 0) < 0)
658786baecfSMauro Carvalho Chehab 				err("i2c transfer failed.");
659786baecfSMauro Carvalho Chehab 
660786baecfSMauro Carvalho Chehab 		}
661786baecfSMauro Carvalho Chehab 		break;
662786baecfSMauro Carvalho Chehab 	case 2:
663786baecfSMauro Carvalho Chehab 		/* always i2c read */
664786baecfSMauro Carvalho Chehab 		obuf[0] = 0x09;
665786baecfSMauro Carvalho Chehab 		obuf[1] = msg[0].len;
666786baecfSMauro Carvalho Chehab 		obuf[2] = msg[1].len;
667786baecfSMauro Carvalho Chehab 		obuf[3] = msg[0].addr;
668786baecfSMauro Carvalho Chehab 		memcpy(&obuf[4], msg[0].buf, msg[0].len);
669786baecfSMauro Carvalho Chehab 
670786baecfSMauro Carvalho Chehab 		if (dvb_usb_generic_rw(d, obuf, msg[0].len + 4,
671786baecfSMauro Carvalho Chehab 					ibuf, msg[1].len + 1, 0) < 0)
672786baecfSMauro Carvalho Chehab 			err("i2c transfer failed.");
673786baecfSMauro Carvalho Chehab 
674786baecfSMauro Carvalho Chehab 		memcpy(msg[1].buf, &ibuf[1], msg[1].len);
675786baecfSMauro Carvalho Chehab 		break;
676786baecfSMauro Carvalho Chehab 	default:
677786baecfSMauro Carvalho Chehab 		warn("more than 2 i2c messages at a time is not handled yet.");
678786baecfSMauro Carvalho Chehab 		break;
679786baecfSMauro Carvalho Chehab 	}
680786baecfSMauro Carvalho Chehab 	mutex_unlock(&d->i2c_mutex);
681786baecfSMauro Carvalho Chehab 	return num;
682786baecfSMauro Carvalho Chehab }
683786baecfSMauro Carvalho Chehab 
684786baecfSMauro Carvalho Chehab static u32 dw210x_i2c_func(struct i2c_adapter *adapter)
685786baecfSMauro Carvalho Chehab {
686786baecfSMauro Carvalho Chehab 	return I2C_FUNC_I2C;
687786baecfSMauro Carvalho Chehab }
688786baecfSMauro Carvalho Chehab 
689786baecfSMauro Carvalho Chehab static struct i2c_algorithm dw2102_i2c_algo = {
690786baecfSMauro Carvalho Chehab 	.master_xfer = dw2102_i2c_transfer,
691786baecfSMauro Carvalho Chehab 	.functionality = dw210x_i2c_func,
692786baecfSMauro Carvalho Chehab };
693786baecfSMauro Carvalho Chehab 
694786baecfSMauro Carvalho Chehab static struct i2c_algorithm dw2102_serit_i2c_algo = {
695786baecfSMauro Carvalho Chehab 	.master_xfer = dw2102_serit_i2c_transfer,
696786baecfSMauro Carvalho Chehab 	.functionality = dw210x_i2c_func,
697786baecfSMauro Carvalho Chehab };
698786baecfSMauro Carvalho Chehab 
699786baecfSMauro Carvalho Chehab static struct i2c_algorithm dw2102_earda_i2c_algo = {
700786baecfSMauro Carvalho Chehab 	.master_xfer = dw2102_earda_i2c_transfer,
701786baecfSMauro Carvalho Chehab 	.functionality = dw210x_i2c_func,
702786baecfSMauro Carvalho Chehab };
703786baecfSMauro Carvalho Chehab 
704786baecfSMauro Carvalho Chehab static struct i2c_algorithm dw2104_i2c_algo = {
705786baecfSMauro Carvalho Chehab 	.master_xfer = dw2104_i2c_transfer,
706786baecfSMauro Carvalho Chehab 	.functionality = dw210x_i2c_func,
707786baecfSMauro Carvalho Chehab };
708786baecfSMauro Carvalho Chehab 
709786baecfSMauro Carvalho Chehab static struct i2c_algorithm dw3101_i2c_algo = {
710786baecfSMauro Carvalho Chehab 	.master_xfer = dw3101_i2c_transfer,
711786baecfSMauro Carvalho Chehab 	.functionality = dw210x_i2c_func,
712786baecfSMauro Carvalho Chehab };
713786baecfSMauro Carvalho Chehab 
714786baecfSMauro Carvalho Chehab static struct i2c_algorithm s6x0_i2c_algo = {
715786baecfSMauro Carvalho Chehab 	.master_xfer = s6x0_i2c_transfer,
716786baecfSMauro Carvalho Chehab 	.functionality = dw210x_i2c_func,
717786baecfSMauro Carvalho Chehab };
718786baecfSMauro Carvalho Chehab 
719786baecfSMauro Carvalho Chehab static struct i2c_algorithm su3000_i2c_algo = {
720786baecfSMauro Carvalho Chehab 	.master_xfer = su3000_i2c_transfer,
721786baecfSMauro Carvalho Chehab 	.functionality = dw210x_i2c_func,
722786baecfSMauro Carvalho Chehab };
723786baecfSMauro Carvalho Chehab 
724786baecfSMauro Carvalho Chehab static int dw210x_read_mac_address(struct dvb_usb_device *d, u8 mac[6])
725786baecfSMauro Carvalho Chehab {
726786baecfSMauro Carvalho Chehab 	int i;
727786baecfSMauro Carvalho Chehab 	u8 ibuf[] = {0, 0};
728786baecfSMauro Carvalho Chehab 	u8 eeprom[256], eepromline[16];
729786baecfSMauro Carvalho Chehab 
730786baecfSMauro Carvalho Chehab 	for (i = 0; i < 256; i++) {
731786baecfSMauro Carvalho Chehab 		if (dw210x_op_rw(d->udev, 0xb6, 0xa0 , i, ibuf, 2, DW210X_READ_MSG) < 0) {
732786baecfSMauro Carvalho Chehab 			err("read eeprom failed.");
733786baecfSMauro Carvalho Chehab 			return -1;
734786baecfSMauro Carvalho Chehab 		} else {
735786baecfSMauro Carvalho Chehab 			eepromline[i%16] = ibuf[0];
736786baecfSMauro Carvalho Chehab 			eeprom[i] = ibuf[0];
737786baecfSMauro Carvalho Chehab 		}
738786baecfSMauro Carvalho Chehab 		if ((i % 16) == 15) {
739786baecfSMauro Carvalho Chehab 			deb_xfer("%02x: ", i - 15);
740786baecfSMauro Carvalho Chehab 			debug_dump(eepromline, 16, deb_xfer);
741786baecfSMauro Carvalho Chehab 		}
742786baecfSMauro Carvalho Chehab 	}
743786baecfSMauro Carvalho Chehab 
744786baecfSMauro Carvalho Chehab 	memcpy(mac, eeprom + 8, 6);
745786baecfSMauro Carvalho Chehab 	return 0;
746786baecfSMauro Carvalho Chehab };
747786baecfSMauro Carvalho Chehab 
748786baecfSMauro Carvalho Chehab static int s6x0_read_mac_address(struct dvb_usb_device *d, u8 mac[6])
749786baecfSMauro Carvalho Chehab {
750786baecfSMauro Carvalho Chehab 	int i, ret;
751786baecfSMauro Carvalho Chehab 	u8 ibuf[] = { 0 }, obuf[] = { 0 };
752786baecfSMauro Carvalho Chehab 	u8 eeprom[256], eepromline[16];
753786baecfSMauro Carvalho Chehab 	struct i2c_msg msg[] = {
754786baecfSMauro Carvalho Chehab 		{
755786baecfSMauro Carvalho Chehab 			.addr = 0xa0 >> 1,
756786baecfSMauro Carvalho Chehab 			.flags = 0,
757786baecfSMauro Carvalho Chehab 			.buf = obuf,
758786baecfSMauro Carvalho Chehab 			.len = 1,
759786baecfSMauro Carvalho Chehab 		}, {
760786baecfSMauro Carvalho Chehab 			.addr = 0xa0 >> 1,
761786baecfSMauro Carvalho Chehab 			.flags = I2C_M_RD,
762786baecfSMauro Carvalho Chehab 			.buf = ibuf,
763786baecfSMauro Carvalho Chehab 			.len = 1,
764786baecfSMauro Carvalho Chehab 		}
765786baecfSMauro Carvalho Chehab 	};
766786baecfSMauro Carvalho Chehab 
767786baecfSMauro Carvalho Chehab 	for (i = 0; i < 256; i++) {
768786baecfSMauro Carvalho Chehab 		obuf[0] = i;
769786baecfSMauro Carvalho Chehab 		ret = s6x0_i2c_transfer(&d->i2c_adap, msg, 2);
770786baecfSMauro Carvalho Chehab 		if (ret != 2) {
771786baecfSMauro Carvalho Chehab 			err("read eeprom failed.");
772786baecfSMauro Carvalho Chehab 			return -1;
773786baecfSMauro Carvalho Chehab 		} else {
774786baecfSMauro Carvalho Chehab 			eepromline[i % 16] = ibuf[0];
775786baecfSMauro Carvalho Chehab 			eeprom[i] = ibuf[0];
776786baecfSMauro Carvalho Chehab 		}
777786baecfSMauro Carvalho Chehab 
778786baecfSMauro Carvalho Chehab 		if ((i % 16) == 15) {
779786baecfSMauro Carvalho Chehab 			deb_xfer("%02x: ", i - 15);
780786baecfSMauro Carvalho Chehab 			debug_dump(eepromline, 16, deb_xfer);
781786baecfSMauro Carvalho Chehab 		}
782786baecfSMauro Carvalho Chehab 	}
783786baecfSMauro Carvalho Chehab 
784786baecfSMauro Carvalho Chehab 	memcpy(mac, eeprom + 16, 6);
785786baecfSMauro Carvalho Chehab 	return 0;
786786baecfSMauro Carvalho Chehab };
787786baecfSMauro Carvalho Chehab 
788786baecfSMauro Carvalho Chehab static int su3000_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
789786baecfSMauro Carvalho Chehab {
790786baecfSMauro Carvalho Chehab 	static u8 command_start[] = {0x00};
791786baecfSMauro Carvalho Chehab 	static u8 command_stop[] = {0x01};
792786baecfSMauro Carvalho Chehab 	struct i2c_msg msg = {
793786baecfSMauro Carvalho Chehab 		.addr = SU3000_STREAM_CTRL,
794786baecfSMauro Carvalho Chehab 		.flags = 0,
795786baecfSMauro Carvalho Chehab 		.buf = onoff ? command_start : command_stop,
796786baecfSMauro Carvalho Chehab 		.len = 1
797786baecfSMauro Carvalho Chehab 	};
798786baecfSMauro Carvalho Chehab 
799786baecfSMauro Carvalho Chehab 	i2c_transfer(&adap->dev->i2c_adap, &msg, 1);
800786baecfSMauro Carvalho Chehab 
801786baecfSMauro Carvalho Chehab 	return 0;
802786baecfSMauro Carvalho Chehab }
803786baecfSMauro Carvalho Chehab 
804786baecfSMauro Carvalho Chehab static int su3000_power_ctrl(struct dvb_usb_device *d, int i)
805786baecfSMauro Carvalho Chehab {
806786baecfSMauro Carvalho Chehab 	struct su3000_state *state = (struct su3000_state *)d->priv;
807786baecfSMauro Carvalho Chehab 	u8 obuf[] = {0xde, 0};
808786baecfSMauro Carvalho Chehab 
809786baecfSMauro Carvalho Chehab 	info("%s: %d, initialized %d\n", __func__, i, state->initialized);
810786baecfSMauro Carvalho Chehab 
811786baecfSMauro Carvalho Chehab 	if (i && !state->initialized) {
812786baecfSMauro Carvalho Chehab 		state->initialized = 1;
813786baecfSMauro Carvalho Chehab 		/* reset board */
814786baecfSMauro Carvalho Chehab 		dvb_usb_generic_rw(d, obuf, 2, NULL, 0, 0);
815786baecfSMauro Carvalho Chehab 	}
816786baecfSMauro Carvalho Chehab 
817786baecfSMauro Carvalho Chehab 	return 0;
818786baecfSMauro Carvalho Chehab }
819786baecfSMauro Carvalho Chehab 
820786baecfSMauro Carvalho Chehab static int su3000_read_mac_address(struct dvb_usb_device *d, u8 mac[6])
821786baecfSMauro Carvalho Chehab {
822786baecfSMauro Carvalho Chehab 	int i;
823786baecfSMauro Carvalho Chehab 	u8 obuf[] = { 0x1f, 0xf0 };
824786baecfSMauro Carvalho Chehab 	u8 ibuf[] = { 0 };
825786baecfSMauro Carvalho Chehab 	struct i2c_msg msg[] = {
826786baecfSMauro Carvalho Chehab 		{
827786baecfSMauro Carvalho Chehab 			.addr = 0x51,
828786baecfSMauro Carvalho Chehab 			.flags = 0,
829786baecfSMauro Carvalho Chehab 			.buf = obuf,
830786baecfSMauro Carvalho Chehab 			.len = 2,
831786baecfSMauro Carvalho Chehab 		}, {
832786baecfSMauro Carvalho Chehab 			.addr = 0x51,
833786baecfSMauro Carvalho Chehab 			.flags = I2C_M_RD,
834786baecfSMauro Carvalho Chehab 			.buf = ibuf,
835786baecfSMauro Carvalho Chehab 			.len = 1,
836786baecfSMauro Carvalho Chehab 
837786baecfSMauro Carvalho Chehab 		}
838786baecfSMauro Carvalho Chehab 	};
839786baecfSMauro Carvalho Chehab 
840786baecfSMauro Carvalho Chehab 	for (i = 0; i < 6; i++) {
841786baecfSMauro Carvalho Chehab 		obuf[1] = 0xf0 + i;
842786baecfSMauro Carvalho Chehab 		if (i2c_transfer(&d->i2c_adap, msg, 2) != 2)
843786baecfSMauro Carvalho Chehab 			break;
844786baecfSMauro Carvalho Chehab 		else
845786baecfSMauro Carvalho Chehab 			mac[i] = ibuf[0];
846786baecfSMauro Carvalho Chehab 
847786baecfSMauro Carvalho Chehab 		debug_dump(mac, 6, printk);
848786baecfSMauro Carvalho Chehab 	}
849786baecfSMauro Carvalho Chehab 
850786baecfSMauro Carvalho Chehab 	return 0;
851786baecfSMauro Carvalho Chehab }
852786baecfSMauro Carvalho Chehab 
853786baecfSMauro Carvalho Chehab static int su3000_identify_state(struct usb_device *udev,
854786baecfSMauro Carvalho Chehab 				 struct dvb_usb_device_properties *props,
855786baecfSMauro Carvalho Chehab 				 struct dvb_usb_device_description **desc,
856786baecfSMauro Carvalho Chehab 				 int *cold)
857786baecfSMauro Carvalho Chehab {
858786baecfSMauro Carvalho Chehab 	info("%s\n", __func__);
859786baecfSMauro Carvalho Chehab 
860786baecfSMauro Carvalho Chehab 	*cold = 0;
861786baecfSMauro Carvalho Chehab 	return 0;
862786baecfSMauro Carvalho Chehab }
863786baecfSMauro Carvalho Chehab 
864786baecfSMauro Carvalho Chehab static int dw210x_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
865786baecfSMauro Carvalho Chehab {
866786baecfSMauro Carvalho Chehab 	static u8 command_13v[] = {0x00, 0x01};
867786baecfSMauro Carvalho Chehab 	static u8 command_18v[] = {0x01, 0x01};
868786baecfSMauro Carvalho Chehab 	static u8 command_off[] = {0x00, 0x00};
869786baecfSMauro Carvalho Chehab 	struct i2c_msg msg = {
870786baecfSMauro Carvalho Chehab 		.addr = DW2102_VOLTAGE_CTRL,
871786baecfSMauro Carvalho Chehab 		.flags = 0,
872786baecfSMauro Carvalho Chehab 		.buf = command_off,
873786baecfSMauro Carvalho Chehab 		.len = 2,
874786baecfSMauro Carvalho Chehab 	};
875786baecfSMauro Carvalho Chehab 
876786baecfSMauro Carvalho Chehab 	struct dvb_usb_adapter *udev_adap =
877786baecfSMauro Carvalho Chehab 		(struct dvb_usb_adapter *)(fe->dvb->priv);
878786baecfSMauro Carvalho Chehab 	if (voltage == SEC_VOLTAGE_18)
879786baecfSMauro Carvalho Chehab 		msg.buf = command_18v;
880786baecfSMauro Carvalho Chehab 	else if (voltage == SEC_VOLTAGE_13)
881786baecfSMauro Carvalho Chehab 		msg.buf = command_13v;
882786baecfSMauro Carvalho Chehab 
883786baecfSMauro Carvalho Chehab 	i2c_transfer(&udev_adap->dev->i2c_adap, &msg, 1);
884786baecfSMauro Carvalho Chehab 
885786baecfSMauro Carvalho Chehab 	return 0;
886786baecfSMauro Carvalho Chehab }
887786baecfSMauro Carvalho Chehab 
888786baecfSMauro Carvalho Chehab static int s660_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
889786baecfSMauro Carvalho Chehab {
890786baecfSMauro Carvalho Chehab 	struct dvb_usb_adapter *d =
891786baecfSMauro Carvalho Chehab 		(struct dvb_usb_adapter *)(fe->dvb->priv);
892786baecfSMauro Carvalho Chehab 	struct s6x0_state *st = (struct s6x0_state *)d->dev->priv;
893786baecfSMauro Carvalho Chehab 
894786baecfSMauro Carvalho Chehab 	dw210x_set_voltage(fe, voltage);
895786baecfSMauro Carvalho Chehab 	if (st->old_set_voltage)
896786baecfSMauro Carvalho Chehab 		st->old_set_voltage(fe, voltage);
897786baecfSMauro Carvalho Chehab 
898786baecfSMauro Carvalho Chehab 	return 0;
899786baecfSMauro Carvalho Chehab }
900786baecfSMauro Carvalho Chehab 
901786baecfSMauro Carvalho Chehab static void dw210x_led_ctrl(struct dvb_frontend *fe, int offon)
902786baecfSMauro Carvalho Chehab {
903786baecfSMauro Carvalho Chehab 	static u8 led_off[] = { 0 };
904786baecfSMauro Carvalho Chehab 	static u8 led_on[] = { 1 };
905786baecfSMauro Carvalho Chehab 	struct i2c_msg msg = {
906786baecfSMauro Carvalho Chehab 		.addr = DW2102_LED_CTRL,
907786baecfSMauro Carvalho Chehab 		.flags = 0,
908786baecfSMauro Carvalho Chehab 		.buf = led_off,
909786baecfSMauro Carvalho Chehab 		.len = 1
910786baecfSMauro Carvalho Chehab 	};
911786baecfSMauro Carvalho Chehab 	struct dvb_usb_adapter *udev_adap =
912786baecfSMauro Carvalho Chehab 		(struct dvb_usb_adapter *)(fe->dvb->priv);
913786baecfSMauro Carvalho Chehab 
914786baecfSMauro Carvalho Chehab 	if (offon)
915786baecfSMauro Carvalho Chehab 		msg.buf = led_on;
916786baecfSMauro Carvalho Chehab 	i2c_transfer(&udev_adap->dev->i2c_adap, &msg, 1);
917786baecfSMauro Carvalho Chehab }
918786baecfSMauro Carvalho Chehab 
919786baecfSMauro Carvalho Chehab static struct stv0299_config sharp_z0194a_config = {
920786baecfSMauro Carvalho Chehab 	.demod_address = 0x68,
921786baecfSMauro Carvalho Chehab 	.inittab = sharp_z0194a_inittab,
922786baecfSMauro Carvalho Chehab 	.mclk = 88000000UL,
923786baecfSMauro Carvalho Chehab 	.invert = 1,
924786baecfSMauro Carvalho Chehab 	.skip_reinit = 0,
925786baecfSMauro Carvalho Chehab 	.lock_output = STV0299_LOCKOUTPUT_1,
926786baecfSMauro Carvalho Chehab 	.volt13_op0_op1 = STV0299_VOLT13_OP1,
927786baecfSMauro Carvalho Chehab 	.min_delay_ms = 100,
928786baecfSMauro Carvalho Chehab 	.set_symbol_rate = sharp_z0194a_set_symbol_rate,
929786baecfSMauro Carvalho Chehab };
930786baecfSMauro Carvalho Chehab 
931786baecfSMauro Carvalho Chehab static struct cx24116_config dw2104_config = {
932786baecfSMauro Carvalho Chehab 	.demod_address = 0x55,
933786baecfSMauro Carvalho Chehab 	.mpg_clk_pos_pol = 0x01,
934786baecfSMauro Carvalho Chehab };
935786baecfSMauro Carvalho Chehab 
936786baecfSMauro Carvalho Chehab static struct si21xx_config serit_sp1511lhb_config = {
937786baecfSMauro Carvalho Chehab 	.demod_address = 0x68,
938786baecfSMauro Carvalho Chehab 	.min_delay_ms = 100,
939786baecfSMauro Carvalho Chehab 
940786baecfSMauro Carvalho Chehab };
941786baecfSMauro Carvalho Chehab 
942786baecfSMauro Carvalho Chehab static struct tda10023_config dw3101_tda10023_config = {
943786baecfSMauro Carvalho Chehab 	.demod_address = 0x0c,
944786baecfSMauro Carvalho Chehab 	.invert = 1,
945786baecfSMauro Carvalho Chehab };
946786baecfSMauro Carvalho Chehab 
947786baecfSMauro Carvalho Chehab static struct mt312_config zl313_config = {
948786baecfSMauro Carvalho Chehab 	.demod_address = 0x0e,
949786baecfSMauro Carvalho Chehab };
950786baecfSMauro Carvalho Chehab 
951786baecfSMauro Carvalho Chehab static struct ds3000_config dw2104_ds3000_config = {
952786baecfSMauro Carvalho Chehab 	.demod_address = 0x68,
953786baecfSMauro Carvalho Chehab };
954786baecfSMauro Carvalho Chehab 
95573f0af44SKonstantin Dimitrov static struct ts2020_config dw2104_ts2020_config  = {
95673f0af44SKonstantin Dimitrov 	.tuner_address = 0x60,
957b858c331SIgor M. Liplianin 	.clk_out_div = 1,
95873f0af44SKonstantin Dimitrov };
95973f0af44SKonstantin Dimitrov 
96043385c8aSIgor M. Liplianin static struct ds3000_config s660_ds3000_config = {
96143385c8aSIgor M. Liplianin 	.demod_address = 0x68,
962b858c331SIgor M. Liplianin 	.ci_mode = 1,
96343385c8aSIgor M. Liplianin 	.set_lock_led = dw210x_led_ctrl,
96443385c8aSIgor M. Liplianin };
96543385c8aSIgor M. Liplianin 
966786baecfSMauro Carvalho Chehab static struct stv0900_config dw2104a_stv0900_config = {
967786baecfSMauro Carvalho Chehab 	.demod_address = 0x6a,
968786baecfSMauro Carvalho Chehab 	.demod_mode = 0,
969786baecfSMauro Carvalho Chehab 	.xtal = 27000000,
970786baecfSMauro Carvalho Chehab 	.clkmode = 3,/* 0-CLKI, 2-XTALI, else AUTO */
971786baecfSMauro Carvalho Chehab 	.diseqc_mode = 2,/* 2/3 PWM */
972786baecfSMauro Carvalho Chehab 	.tun1_maddress = 0,/* 0x60 */
973786baecfSMauro Carvalho Chehab 	.tun1_adc = 0,/* 2 Vpp */
974786baecfSMauro Carvalho Chehab 	.path1_mode = 3,
975786baecfSMauro Carvalho Chehab };
976786baecfSMauro Carvalho Chehab 
977786baecfSMauro Carvalho Chehab static struct stb6100_config dw2104a_stb6100_config = {
978786baecfSMauro Carvalho Chehab 	.tuner_address = 0x60,
979786baecfSMauro Carvalho Chehab 	.refclock = 27000000,
980786baecfSMauro Carvalho Chehab };
981786baecfSMauro Carvalho Chehab 
982786baecfSMauro Carvalho Chehab static struct stv0900_config dw2104_stv0900_config = {
983786baecfSMauro Carvalho Chehab 	.demod_address = 0x68,
984786baecfSMauro Carvalho Chehab 	.demod_mode = 0,
985786baecfSMauro Carvalho Chehab 	.xtal = 8000000,
986786baecfSMauro Carvalho Chehab 	.clkmode = 3,
987786baecfSMauro Carvalho Chehab 	.diseqc_mode = 2,
988786baecfSMauro Carvalho Chehab 	.tun1_maddress = 0,
989786baecfSMauro Carvalho Chehab 	.tun1_adc = 1,/* 1 Vpp */
990786baecfSMauro Carvalho Chehab 	.path1_mode = 3,
991786baecfSMauro Carvalho Chehab };
992786baecfSMauro Carvalho Chehab 
993786baecfSMauro Carvalho Chehab static struct stv6110_config dw2104_stv6110_config = {
994786baecfSMauro Carvalho Chehab 	.i2c_address = 0x60,
995786baecfSMauro Carvalho Chehab 	.mclk = 16000000,
996786baecfSMauro Carvalho Chehab 	.clk_div = 1,
997786baecfSMauro Carvalho Chehab };
998786baecfSMauro Carvalho Chehab 
999786baecfSMauro Carvalho Chehab static struct stv0900_config prof_7500_stv0900_config = {
1000786baecfSMauro Carvalho Chehab 	.demod_address = 0x6a,
1001786baecfSMauro Carvalho Chehab 	.demod_mode = 0,
1002786baecfSMauro Carvalho Chehab 	.xtal = 27000000,
1003786baecfSMauro Carvalho Chehab 	.clkmode = 3,/* 0-CLKI, 2-XTALI, else AUTO */
1004786baecfSMauro Carvalho Chehab 	.diseqc_mode = 2,/* 2/3 PWM */
1005786baecfSMauro Carvalho Chehab 	.tun1_maddress = 0,/* 0x60 */
1006786baecfSMauro Carvalho Chehab 	.tun1_adc = 0,/* 2 Vpp */
1007786baecfSMauro Carvalho Chehab 	.path1_mode = 3,
1008786baecfSMauro Carvalho Chehab 	.tun1_type = 3,
1009786baecfSMauro Carvalho Chehab 	.set_lock_led = dw210x_led_ctrl,
1010786baecfSMauro Carvalho Chehab };
1011786baecfSMauro Carvalho Chehab 
1012786baecfSMauro Carvalho Chehab static struct ds3000_config su3000_ds3000_config = {
1013786baecfSMauro Carvalho Chehab 	.demod_address = 0x68,
1014786baecfSMauro Carvalho Chehab 	.ci_mode = 1,
1015b858c331SIgor M. Liplianin 	.set_lock_led = dw210x_led_ctrl,
101673f0af44SKonstantin Dimitrov };
101773f0af44SKonstantin Dimitrov 
1018955d00acSIgor M. Liplianin static u8 m88rs2000_inittab[] = {
1019955d00acSIgor M. Liplianin 	DEMOD_WRITE, 0x9a, 0x30,
1020955d00acSIgor M. Liplianin 	DEMOD_WRITE, 0x00, 0x01,
1021955d00acSIgor M. Liplianin 	WRITE_DELAY, 0x19, 0x00,
1022955d00acSIgor M. Liplianin 	DEMOD_WRITE, 0x00, 0x00,
1023955d00acSIgor M. Liplianin 	DEMOD_WRITE, 0x9a, 0xb0,
1024955d00acSIgor M. Liplianin 	DEMOD_WRITE, 0x81, 0xc1,
1025955d00acSIgor M. Liplianin 	DEMOD_WRITE, 0x81, 0x81,
1026955d00acSIgor M. Liplianin 	DEMOD_WRITE, 0x86, 0xc6,
1027955d00acSIgor M. Liplianin 	DEMOD_WRITE, 0x9a, 0x30,
1028955d00acSIgor M. Liplianin 	DEMOD_WRITE, 0xf0, 0x80,
1029955d00acSIgor M. Liplianin 	DEMOD_WRITE, 0xf1, 0xbf,
1030955d00acSIgor M. Liplianin 	DEMOD_WRITE, 0xb0, 0x45,
1031955d00acSIgor M. Liplianin 	DEMOD_WRITE, 0xb2, 0x01,
1032955d00acSIgor M. Liplianin 	DEMOD_WRITE, 0x9a, 0xb0,
1033955d00acSIgor M. Liplianin 	0xff, 0xaa, 0xff
1034955d00acSIgor M. Liplianin };
1035955d00acSIgor M. Liplianin 
1036955d00acSIgor M. Liplianin static struct m88rs2000_config s421_m88rs2000_config = {
1037955d00acSIgor M. Liplianin 	.demod_addr = 0x68,
1038955d00acSIgor M. Liplianin 	.inittab = m88rs2000_inittab,
1039955d00acSIgor M. Liplianin };
1040955d00acSIgor M. Liplianin 
1041786baecfSMauro Carvalho Chehab static int dw2104_frontend_attach(struct dvb_usb_adapter *d)
1042786baecfSMauro Carvalho Chehab {
1043786baecfSMauro Carvalho Chehab 	struct dvb_tuner_ops *tuner_ops = NULL;
1044786baecfSMauro Carvalho Chehab 
1045786baecfSMauro Carvalho Chehab 	if (demod_probe & 4) {
1046786baecfSMauro Carvalho Chehab 		d->fe_adap[0].fe = dvb_attach(stv0900_attach, &dw2104a_stv0900_config,
1047786baecfSMauro Carvalho Chehab 				&d->dev->i2c_adap, 0);
1048786baecfSMauro Carvalho Chehab 		if (d->fe_adap[0].fe != NULL) {
1049786baecfSMauro Carvalho Chehab 			if (dvb_attach(stb6100_attach, d->fe_adap[0].fe,
1050786baecfSMauro Carvalho Chehab 					&dw2104a_stb6100_config,
1051786baecfSMauro Carvalho Chehab 					&d->dev->i2c_adap)) {
1052786baecfSMauro Carvalho Chehab 				tuner_ops = &d->fe_adap[0].fe->ops.tuner_ops;
1053786baecfSMauro Carvalho Chehab 				tuner_ops->set_frequency = stb6100_set_freq;
1054786baecfSMauro Carvalho Chehab 				tuner_ops->get_frequency = stb6100_get_freq;
1055786baecfSMauro Carvalho Chehab 				tuner_ops->set_bandwidth = stb6100_set_bandw;
1056786baecfSMauro Carvalho Chehab 				tuner_ops->get_bandwidth = stb6100_get_bandw;
1057786baecfSMauro Carvalho Chehab 				d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
1058786baecfSMauro Carvalho Chehab 				info("Attached STV0900+STB6100!\n");
1059786baecfSMauro Carvalho Chehab 				return 0;
1060786baecfSMauro Carvalho Chehab 			}
1061786baecfSMauro Carvalho Chehab 		}
1062786baecfSMauro Carvalho Chehab 	}
1063786baecfSMauro Carvalho Chehab 
1064786baecfSMauro Carvalho Chehab 	if (demod_probe & 2) {
1065786baecfSMauro Carvalho Chehab 		d->fe_adap[0].fe = dvb_attach(stv0900_attach, &dw2104_stv0900_config,
1066786baecfSMauro Carvalho Chehab 				&d->dev->i2c_adap, 0);
1067786baecfSMauro Carvalho Chehab 		if (d->fe_adap[0].fe != NULL) {
1068786baecfSMauro Carvalho Chehab 			if (dvb_attach(stv6110_attach, d->fe_adap[0].fe,
1069786baecfSMauro Carvalho Chehab 					&dw2104_stv6110_config,
1070786baecfSMauro Carvalho Chehab 					&d->dev->i2c_adap)) {
1071786baecfSMauro Carvalho Chehab 				d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
1072786baecfSMauro Carvalho Chehab 				info("Attached STV0900+STV6110A!\n");
1073786baecfSMauro Carvalho Chehab 				return 0;
1074786baecfSMauro Carvalho Chehab 			}
1075786baecfSMauro Carvalho Chehab 		}
1076786baecfSMauro Carvalho Chehab 	}
1077786baecfSMauro Carvalho Chehab 
1078786baecfSMauro Carvalho Chehab 	if (demod_probe & 1) {
1079786baecfSMauro Carvalho Chehab 		d->fe_adap[0].fe = dvb_attach(cx24116_attach, &dw2104_config,
1080786baecfSMauro Carvalho Chehab 				&d->dev->i2c_adap);
1081786baecfSMauro Carvalho Chehab 		if (d->fe_adap[0].fe != NULL) {
1082786baecfSMauro Carvalho Chehab 			d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
1083786baecfSMauro Carvalho Chehab 			info("Attached cx24116!\n");
1084786baecfSMauro Carvalho Chehab 			return 0;
1085786baecfSMauro Carvalho Chehab 		}
1086786baecfSMauro Carvalho Chehab 	}
1087786baecfSMauro Carvalho Chehab 
1088786baecfSMauro Carvalho Chehab 	d->fe_adap[0].fe = dvb_attach(ds3000_attach, &dw2104_ds3000_config,
1089786baecfSMauro Carvalho Chehab 			&d->dev->i2c_adap);
1090786baecfSMauro Carvalho Chehab 	if (d->fe_adap[0].fe != NULL) {
109173f0af44SKonstantin Dimitrov 		dvb_attach(ts2020_attach, d->fe_adap[0].fe,
109273f0af44SKonstantin Dimitrov 			&dw2104_ts2020_config, &d->dev->i2c_adap);
1093786baecfSMauro Carvalho Chehab 		d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
1094786baecfSMauro Carvalho Chehab 		info("Attached DS3000!\n");
1095786baecfSMauro Carvalho Chehab 		return 0;
1096786baecfSMauro Carvalho Chehab 	}
1097786baecfSMauro Carvalho Chehab 
1098786baecfSMauro Carvalho Chehab 	return -EIO;
1099786baecfSMauro Carvalho Chehab }
1100786baecfSMauro Carvalho Chehab 
1101786baecfSMauro Carvalho Chehab static struct dvb_usb_device_properties dw2102_properties;
1102786baecfSMauro Carvalho Chehab static struct dvb_usb_device_properties dw2104_properties;
1103786baecfSMauro Carvalho Chehab static struct dvb_usb_device_properties s6x0_properties;
1104786baecfSMauro Carvalho Chehab 
1105786baecfSMauro Carvalho Chehab static int dw2102_frontend_attach(struct dvb_usb_adapter *d)
1106786baecfSMauro Carvalho Chehab {
1107786baecfSMauro Carvalho Chehab 	if (dw2102_properties.i2c_algo == &dw2102_serit_i2c_algo) {
1108786baecfSMauro Carvalho Chehab 		/*dw2102_properties.adapter->tuner_attach = NULL;*/
1109786baecfSMauro Carvalho Chehab 		d->fe_adap[0].fe = dvb_attach(si21xx_attach, &serit_sp1511lhb_config,
1110786baecfSMauro Carvalho Chehab 					&d->dev->i2c_adap);
1111786baecfSMauro Carvalho Chehab 		if (d->fe_adap[0].fe != NULL) {
1112786baecfSMauro Carvalho Chehab 			d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
1113786baecfSMauro Carvalho Chehab 			info("Attached si21xx!\n");
1114786baecfSMauro Carvalho Chehab 			return 0;
1115786baecfSMauro Carvalho Chehab 		}
1116786baecfSMauro Carvalho Chehab 	}
1117786baecfSMauro Carvalho Chehab 
1118786baecfSMauro Carvalho Chehab 	if (dw2102_properties.i2c_algo == &dw2102_earda_i2c_algo) {
1119786baecfSMauro Carvalho Chehab 		d->fe_adap[0].fe = dvb_attach(stv0288_attach, &earda_config,
1120786baecfSMauro Carvalho Chehab 					&d->dev->i2c_adap);
1121786baecfSMauro Carvalho Chehab 		if (d->fe_adap[0].fe != NULL) {
1122786baecfSMauro Carvalho Chehab 			if (dvb_attach(stb6000_attach, d->fe_adap[0].fe, 0x61,
1123786baecfSMauro Carvalho Chehab 					&d->dev->i2c_adap)) {
1124786baecfSMauro Carvalho Chehab 				d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
1125786baecfSMauro Carvalho Chehab 				info("Attached stv0288!\n");
1126786baecfSMauro Carvalho Chehab 				return 0;
1127786baecfSMauro Carvalho Chehab 			}
1128786baecfSMauro Carvalho Chehab 		}
1129786baecfSMauro Carvalho Chehab 	}
1130786baecfSMauro Carvalho Chehab 
1131786baecfSMauro Carvalho Chehab 	if (dw2102_properties.i2c_algo == &dw2102_i2c_algo) {
1132786baecfSMauro Carvalho Chehab 		/*dw2102_properties.adapter->tuner_attach = dw2102_tuner_attach;*/
1133786baecfSMauro Carvalho Chehab 		d->fe_adap[0].fe = dvb_attach(stv0299_attach, &sharp_z0194a_config,
1134786baecfSMauro Carvalho Chehab 					&d->dev->i2c_adap);
1135786baecfSMauro Carvalho Chehab 		if (d->fe_adap[0].fe != NULL) {
1136786baecfSMauro Carvalho Chehab 			d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
1137786baecfSMauro Carvalho Chehab 			info("Attached stv0299!\n");
1138786baecfSMauro Carvalho Chehab 			return 0;
1139786baecfSMauro Carvalho Chehab 		}
1140786baecfSMauro Carvalho Chehab 	}
1141786baecfSMauro Carvalho Chehab 	return -EIO;
1142786baecfSMauro Carvalho Chehab }
1143786baecfSMauro Carvalho Chehab 
1144786baecfSMauro Carvalho Chehab static int dw3101_frontend_attach(struct dvb_usb_adapter *d)
1145786baecfSMauro Carvalho Chehab {
1146786baecfSMauro Carvalho Chehab 	d->fe_adap[0].fe = dvb_attach(tda10023_attach, &dw3101_tda10023_config,
1147786baecfSMauro Carvalho Chehab 				&d->dev->i2c_adap, 0x48);
1148786baecfSMauro Carvalho Chehab 	if (d->fe_adap[0].fe != NULL) {
1149786baecfSMauro Carvalho Chehab 		info("Attached tda10023!\n");
1150786baecfSMauro Carvalho Chehab 		return 0;
1151786baecfSMauro Carvalho Chehab 	}
1152786baecfSMauro Carvalho Chehab 	return -EIO;
1153786baecfSMauro Carvalho Chehab }
1154786baecfSMauro Carvalho Chehab 
1155786baecfSMauro Carvalho Chehab static int zl100313_frontend_attach(struct dvb_usb_adapter *d)
1156786baecfSMauro Carvalho Chehab {
1157786baecfSMauro Carvalho Chehab 	d->fe_adap[0].fe = dvb_attach(mt312_attach, &zl313_config,
1158786baecfSMauro Carvalho Chehab 			&d->dev->i2c_adap);
1159786baecfSMauro Carvalho Chehab 	if (d->fe_adap[0].fe != NULL) {
1160786baecfSMauro Carvalho Chehab 		if (dvb_attach(zl10039_attach, d->fe_adap[0].fe, 0x60,
1161786baecfSMauro Carvalho Chehab 				&d->dev->i2c_adap)) {
1162786baecfSMauro Carvalho Chehab 			d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
1163786baecfSMauro Carvalho Chehab 			info("Attached zl100313+zl10039!\n");
1164786baecfSMauro Carvalho Chehab 			return 0;
1165786baecfSMauro Carvalho Chehab 		}
1166786baecfSMauro Carvalho Chehab 	}
1167786baecfSMauro Carvalho Chehab 
1168786baecfSMauro Carvalho Chehab 	return -EIO;
1169786baecfSMauro Carvalho Chehab }
1170786baecfSMauro Carvalho Chehab 
1171786baecfSMauro Carvalho Chehab static int stv0288_frontend_attach(struct dvb_usb_adapter *d)
1172786baecfSMauro Carvalho Chehab {
1173786baecfSMauro Carvalho Chehab 	u8 obuf[] = {7, 1};
1174786baecfSMauro Carvalho Chehab 
1175786baecfSMauro Carvalho Chehab 	d->fe_adap[0].fe = dvb_attach(stv0288_attach, &earda_config,
1176786baecfSMauro Carvalho Chehab 			&d->dev->i2c_adap);
1177786baecfSMauro Carvalho Chehab 
1178786baecfSMauro Carvalho Chehab 	if (d->fe_adap[0].fe == NULL)
1179786baecfSMauro Carvalho Chehab 		return -EIO;
1180786baecfSMauro Carvalho Chehab 
1181786baecfSMauro Carvalho Chehab 	if (NULL == dvb_attach(stb6000_attach, d->fe_adap[0].fe, 0x61, &d->dev->i2c_adap))
1182786baecfSMauro Carvalho Chehab 		return -EIO;
1183786baecfSMauro Carvalho Chehab 
1184786baecfSMauro Carvalho Chehab 	d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
1185786baecfSMauro Carvalho Chehab 
1186786baecfSMauro Carvalho Chehab 	dw210x_op_rw(d->dev->udev, 0x8a, 0, 0, obuf, 2, DW210X_WRITE_MSG);
1187786baecfSMauro Carvalho Chehab 
1188786baecfSMauro Carvalho Chehab 	info("Attached stv0288+stb6000!\n");
1189786baecfSMauro Carvalho Chehab 
1190786baecfSMauro Carvalho Chehab 	return 0;
1191786baecfSMauro Carvalho Chehab 
1192786baecfSMauro Carvalho Chehab }
1193786baecfSMauro Carvalho Chehab 
1194786baecfSMauro Carvalho Chehab static int ds3000_frontend_attach(struct dvb_usb_adapter *d)
1195786baecfSMauro Carvalho Chehab {
1196786baecfSMauro Carvalho Chehab 	struct s6x0_state *st = (struct s6x0_state *)d->dev->priv;
1197786baecfSMauro Carvalho Chehab 	u8 obuf[] = {7, 1};
1198786baecfSMauro Carvalho Chehab 
119943385c8aSIgor M. Liplianin 	d->fe_adap[0].fe = dvb_attach(ds3000_attach, &s660_ds3000_config,
1200786baecfSMauro Carvalho Chehab 			&d->dev->i2c_adap);
1201786baecfSMauro Carvalho Chehab 
1202786baecfSMauro Carvalho Chehab 	if (d->fe_adap[0].fe == NULL)
1203786baecfSMauro Carvalho Chehab 		return -EIO;
1204786baecfSMauro Carvalho Chehab 
120573f0af44SKonstantin Dimitrov 	dvb_attach(ts2020_attach, d->fe_adap[0].fe, &dw2104_ts2020_config,
120673f0af44SKonstantin Dimitrov 		&d->dev->i2c_adap);
120773f0af44SKonstantin Dimitrov 
1208786baecfSMauro Carvalho Chehab 	st->old_set_voltage = d->fe_adap[0].fe->ops.set_voltage;
1209786baecfSMauro Carvalho Chehab 	d->fe_adap[0].fe->ops.set_voltage = s660_set_voltage;
1210786baecfSMauro Carvalho Chehab 
1211786baecfSMauro Carvalho Chehab 	dw210x_op_rw(d->dev->udev, 0x8a, 0, 0, obuf, 2, DW210X_WRITE_MSG);
1212786baecfSMauro Carvalho Chehab 
1213786baecfSMauro Carvalho Chehab 	info("Attached ds3000+ds2020!\n");
1214786baecfSMauro Carvalho Chehab 
1215786baecfSMauro Carvalho Chehab 	return 0;
1216786baecfSMauro Carvalho Chehab }
1217786baecfSMauro Carvalho Chehab 
1218786baecfSMauro Carvalho Chehab static int prof_7500_frontend_attach(struct dvb_usb_adapter *d)
1219786baecfSMauro Carvalho Chehab {
1220786baecfSMauro Carvalho Chehab 	u8 obuf[] = {7, 1};
1221786baecfSMauro Carvalho Chehab 
1222786baecfSMauro Carvalho Chehab 	d->fe_adap[0].fe = dvb_attach(stv0900_attach, &prof_7500_stv0900_config,
1223786baecfSMauro Carvalho Chehab 					&d->dev->i2c_adap, 0);
1224786baecfSMauro Carvalho Chehab 	if (d->fe_adap[0].fe == NULL)
1225786baecfSMauro Carvalho Chehab 		return -EIO;
1226786baecfSMauro Carvalho Chehab 
1227786baecfSMauro Carvalho Chehab 	d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
1228786baecfSMauro Carvalho Chehab 
1229786baecfSMauro Carvalho Chehab 	dw210x_op_rw(d->dev->udev, 0x8a, 0, 0, obuf, 2, DW210X_WRITE_MSG);
1230786baecfSMauro Carvalho Chehab 
1231786baecfSMauro Carvalho Chehab 	info("Attached STV0900+STB6100A!\n");
1232786baecfSMauro Carvalho Chehab 
1233786baecfSMauro Carvalho Chehab 	return 0;
1234786baecfSMauro Carvalho Chehab }
1235786baecfSMauro Carvalho Chehab 
1236786baecfSMauro Carvalho Chehab static int su3000_frontend_attach(struct dvb_usb_adapter *d)
1237786baecfSMauro Carvalho Chehab {
1238786baecfSMauro Carvalho Chehab 	u8 obuf[3] = { 0xe, 0x80, 0 };
1239786baecfSMauro Carvalho Chehab 	u8 ibuf[] = { 0 };
1240786baecfSMauro Carvalho Chehab 
1241786baecfSMauro Carvalho Chehab 	if (dvb_usb_generic_rw(d->dev, obuf, 3, ibuf, 1, 0) < 0)
1242786baecfSMauro Carvalho Chehab 		err("command 0x0e transfer failed.");
1243786baecfSMauro Carvalho Chehab 
1244786baecfSMauro Carvalho Chehab 	obuf[0] = 0xe;
1245b858c331SIgor M. Liplianin 	obuf[1] = 0x02;
1246b858c331SIgor M. Liplianin 	obuf[2] = 1;
1247b858c331SIgor M. Liplianin 
1248b858c331SIgor M. Liplianin 	if (dvb_usb_generic_rw(d->dev, obuf, 3, ibuf, 1, 0) < 0)
1249b858c331SIgor M. Liplianin 		err("command 0x0e transfer failed.");
1250b858c331SIgor M. Liplianin 	msleep(300);
1251b858c331SIgor M. Liplianin 
1252b858c331SIgor M. Liplianin 	obuf[0] = 0xe;
1253786baecfSMauro Carvalho Chehab 	obuf[1] = 0x83;
1254786baecfSMauro Carvalho Chehab 	obuf[2] = 0;
1255786baecfSMauro Carvalho Chehab 
1256786baecfSMauro Carvalho Chehab 	if (dvb_usb_generic_rw(d->dev, obuf, 3, ibuf, 1, 0) < 0)
1257786baecfSMauro Carvalho Chehab 		err("command 0x0e transfer failed.");
1258786baecfSMauro Carvalho Chehab 
1259786baecfSMauro Carvalho Chehab 	obuf[0] = 0xe;
1260786baecfSMauro Carvalho Chehab 	obuf[1] = 0x83;
1261786baecfSMauro Carvalho Chehab 	obuf[2] = 1;
1262786baecfSMauro Carvalho Chehab 
1263786baecfSMauro Carvalho Chehab 	if (dvb_usb_generic_rw(d->dev, obuf, 3, ibuf, 1, 0) < 0)
1264786baecfSMauro Carvalho Chehab 		err("command 0x0e transfer failed.");
1265786baecfSMauro Carvalho Chehab 
1266786baecfSMauro Carvalho Chehab 	obuf[0] = 0x51;
1267786baecfSMauro Carvalho Chehab 
1268786baecfSMauro Carvalho Chehab 	if (dvb_usb_generic_rw(d->dev, obuf, 1, ibuf, 1, 0) < 0)
1269786baecfSMauro Carvalho Chehab 		err("command 0x51 transfer failed.");
1270786baecfSMauro Carvalho Chehab 
1271786baecfSMauro Carvalho Chehab 	d->fe_adap[0].fe = dvb_attach(ds3000_attach, &su3000_ds3000_config,
1272786baecfSMauro Carvalho Chehab 					&d->dev->i2c_adap);
1273786baecfSMauro Carvalho Chehab 	if (d->fe_adap[0].fe == NULL)
1274786baecfSMauro Carvalho Chehab 		return -EIO;
1275786baecfSMauro Carvalho Chehab 
1276b858c331SIgor M. Liplianin 	if (dvb_attach(ts2020_attach, d->fe_adap[0].fe,
1277b858c331SIgor M. Liplianin 				&dw2104_ts2020_config,
1278b858c331SIgor M. Liplianin 				&d->dev->i2c_adap)) {
1279b858c331SIgor M. Liplianin 		info("Attached DS3000/TS2020!\n");
1280786baecfSMauro Carvalho Chehab 		return 0;
1281786baecfSMauro Carvalho Chehab 	}
1282786baecfSMauro Carvalho Chehab 
1283b858c331SIgor M. Liplianin 	info("Failed to attach DS3000/TS2020!\n");
1284b858c331SIgor M. Liplianin 	return -EIO;
1285b858c331SIgor M. Liplianin }
1286b858c331SIgor M. Liplianin 
1287955d00acSIgor M. Liplianin static int m88rs2000_frontend_attach(struct dvb_usb_adapter *d)
1288955d00acSIgor M. Liplianin {
1289955d00acSIgor M. Liplianin 	u8 obuf[] = { 0x51 };
1290955d00acSIgor M. Liplianin 	u8 ibuf[] = { 0 };
1291955d00acSIgor M. Liplianin 
1292955d00acSIgor M. Liplianin 	if (dvb_usb_generic_rw(d->dev, obuf, 1, ibuf, 1, 0) < 0)
1293955d00acSIgor M. Liplianin 		err("command 0x51 transfer failed.");
1294955d00acSIgor M. Liplianin 
1295955d00acSIgor M. Liplianin 	d->fe_adap[0].fe = dvb_attach(m88rs2000_attach, &s421_m88rs2000_config,
1296955d00acSIgor M. Liplianin 					&d->dev->i2c_adap);
1297b858c331SIgor M. Liplianin 
1298955d00acSIgor M. Liplianin 	if (d->fe_adap[0].fe == NULL)
1299955d00acSIgor M. Liplianin 		return -EIO;
1300955d00acSIgor M. Liplianin 
1301b858c331SIgor M. Liplianin 	if (dvb_attach(ts2020_attach, d->fe_adap[0].fe,
1302b858c331SIgor M. Liplianin 				&dw2104_ts2020_config,
1303b858c331SIgor M. Liplianin 				&d->dev->i2c_adap)) {
1304b858c331SIgor M. Liplianin 		info("Attached RS2000/TS2020!\n");
1305955d00acSIgor M. Liplianin 		return 0;
1306955d00acSIgor M. Liplianin 	}
1307955d00acSIgor M. Liplianin 
1308b858c331SIgor M. Liplianin 	info("Failed to attach RS2000/TS2020!\n");
1309b858c331SIgor M. Liplianin 	return -EIO;
1310b858c331SIgor M. Liplianin }
1311b858c331SIgor M. Liplianin 
1312786baecfSMauro Carvalho Chehab static int dw2102_tuner_attach(struct dvb_usb_adapter *adap)
1313786baecfSMauro Carvalho Chehab {
1314786baecfSMauro Carvalho Chehab 	dvb_attach(dvb_pll_attach, adap->fe_adap[0].fe, 0x60,
1315786baecfSMauro Carvalho Chehab 		&adap->dev->i2c_adap, DVB_PLL_OPERA1);
1316786baecfSMauro Carvalho Chehab 	return 0;
1317786baecfSMauro Carvalho Chehab }
1318786baecfSMauro Carvalho Chehab 
1319786baecfSMauro Carvalho Chehab static int dw3101_tuner_attach(struct dvb_usb_adapter *adap)
1320786baecfSMauro Carvalho Chehab {
1321786baecfSMauro Carvalho Chehab 	dvb_attach(dvb_pll_attach, adap->fe_adap[0].fe, 0x60,
1322786baecfSMauro Carvalho Chehab 		&adap->dev->i2c_adap, DVB_PLL_TUA6034);
1323786baecfSMauro Carvalho Chehab 
1324786baecfSMauro Carvalho Chehab 	return 0;
1325786baecfSMauro Carvalho Chehab }
1326786baecfSMauro Carvalho Chehab 
1327786baecfSMauro Carvalho Chehab static struct rc_map_table rc_map_dw210x_table[] = {
1328786baecfSMauro Carvalho Chehab 	{ 0xf80a, KEY_POWER2 },		/*power*/
1329786baecfSMauro Carvalho Chehab 	{ 0xf80c, KEY_MUTE },		/*mute*/
1330786baecfSMauro Carvalho Chehab 	{ 0xf811, KEY_1 },
1331786baecfSMauro Carvalho Chehab 	{ 0xf812, KEY_2 },
1332786baecfSMauro Carvalho Chehab 	{ 0xf813, KEY_3 },
1333786baecfSMauro Carvalho Chehab 	{ 0xf814, KEY_4 },
1334786baecfSMauro Carvalho Chehab 	{ 0xf815, KEY_5 },
1335786baecfSMauro Carvalho Chehab 	{ 0xf816, KEY_6 },
1336786baecfSMauro Carvalho Chehab 	{ 0xf817, KEY_7 },
1337786baecfSMauro Carvalho Chehab 	{ 0xf818, KEY_8 },
1338786baecfSMauro Carvalho Chehab 	{ 0xf819, KEY_9 },
1339786baecfSMauro Carvalho Chehab 	{ 0xf810, KEY_0 },
1340786baecfSMauro Carvalho Chehab 	{ 0xf81c, KEY_CHANNELUP },	/*ch+*/
1341786baecfSMauro Carvalho Chehab 	{ 0xf80f, KEY_CHANNELDOWN },	/*ch-*/
1342786baecfSMauro Carvalho Chehab 	{ 0xf81a, KEY_VOLUMEUP },	/*vol+*/
1343786baecfSMauro Carvalho Chehab 	{ 0xf80e, KEY_VOLUMEDOWN },	/*vol-*/
1344786baecfSMauro Carvalho Chehab 	{ 0xf804, KEY_RECORD },		/*rec*/
1345786baecfSMauro Carvalho Chehab 	{ 0xf809, KEY_FAVORITES },	/*fav*/
1346786baecfSMauro Carvalho Chehab 	{ 0xf808, KEY_REWIND },		/*rewind*/
1347786baecfSMauro Carvalho Chehab 	{ 0xf807, KEY_FASTFORWARD },	/*fast*/
1348786baecfSMauro Carvalho Chehab 	{ 0xf80b, KEY_PAUSE },		/*pause*/
1349786baecfSMauro Carvalho Chehab 	{ 0xf802, KEY_ESC },		/*cancel*/
1350786baecfSMauro Carvalho Chehab 	{ 0xf803, KEY_TAB },		/*tab*/
1351786baecfSMauro Carvalho Chehab 	{ 0xf800, KEY_UP },		/*up*/
1352786baecfSMauro Carvalho Chehab 	{ 0xf81f, KEY_OK },		/*ok*/
1353786baecfSMauro Carvalho Chehab 	{ 0xf801, KEY_DOWN },		/*down*/
1354786baecfSMauro Carvalho Chehab 	{ 0xf805, KEY_CAMERA },		/*cap*/
1355786baecfSMauro Carvalho Chehab 	{ 0xf806, KEY_STOP },		/*stop*/
1356786baecfSMauro Carvalho Chehab 	{ 0xf840, KEY_ZOOM },		/*full*/
1357786baecfSMauro Carvalho Chehab 	{ 0xf81e, KEY_TV },		/*tvmode*/
1358786baecfSMauro Carvalho Chehab 	{ 0xf81b, KEY_LAST },		/*recall*/
1359786baecfSMauro Carvalho Chehab };
1360786baecfSMauro Carvalho Chehab 
1361786baecfSMauro Carvalho Chehab static struct rc_map_table rc_map_tevii_table[] = {
1362786baecfSMauro Carvalho Chehab 	{ 0xf80a, KEY_POWER },
1363786baecfSMauro Carvalho Chehab 	{ 0xf80c, KEY_MUTE },
1364786baecfSMauro Carvalho Chehab 	{ 0xf811, KEY_1 },
1365786baecfSMauro Carvalho Chehab 	{ 0xf812, KEY_2 },
1366786baecfSMauro Carvalho Chehab 	{ 0xf813, KEY_3 },
1367786baecfSMauro Carvalho Chehab 	{ 0xf814, KEY_4 },
1368786baecfSMauro Carvalho Chehab 	{ 0xf815, KEY_5 },
1369786baecfSMauro Carvalho Chehab 	{ 0xf816, KEY_6 },
1370786baecfSMauro Carvalho Chehab 	{ 0xf817, KEY_7 },
1371786baecfSMauro Carvalho Chehab 	{ 0xf818, KEY_8 },
1372786baecfSMauro Carvalho Chehab 	{ 0xf819, KEY_9 },
1373786baecfSMauro Carvalho Chehab 	{ 0xf810, KEY_0 },
1374786baecfSMauro Carvalho Chehab 	{ 0xf81c, KEY_MENU },
1375786baecfSMauro Carvalho Chehab 	{ 0xf80f, KEY_VOLUMEDOWN },
1376786baecfSMauro Carvalho Chehab 	{ 0xf81a, KEY_LAST },
1377786baecfSMauro Carvalho Chehab 	{ 0xf80e, KEY_OPEN },
1378786baecfSMauro Carvalho Chehab 	{ 0xf804, KEY_RECORD },
1379786baecfSMauro Carvalho Chehab 	{ 0xf809, KEY_VOLUMEUP },
1380786baecfSMauro Carvalho Chehab 	{ 0xf808, KEY_CHANNELUP },
1381786baecfSMauro Carvalho Chehab 	{ 0xf807, KEY_PVR },
1382786baecfSMauro Carvalho Chehab 	{ 0xf80b, KEY_TIME },
1383786baecfSMauro Carvalho Chehab 	{ 0xf802, KEY_RIGHT },
1384786baecfSMauro Carvalho Chehab 	{ 0xf803, KEY_LEFT },
1385786baecfSMauro Carvalho Chehab 	{ 0xf800, KEY_UP },
1386786baecfSMauro Carvalho Chehab 	{ 0xf81f, KEY_OK },
1387786baecfSMauro Carvalho Chehab 	{ 0xf801, KEY_DOWN },
1388786baecfSMauro Carvalho Chehab 	{ 0xf805, KEY_TUNER },
1389786baecfSMauro Carvalho Chehab 	{ 0xf806, KEY_CHANNELDOWN },
1390786baecfSMauro Carvalho Chehab 	{ 0xf840, KEY_PLAYPAUSE },
1391786baecfSMauro Carvalho Chehab 	{ 0xf81e, KEY_REWIND },
1392786baecfSMauro Carvalho Chehab 	{ 0xf81b, KEY_FAVORITES },
1393786baecfSMauro Carvalho Chehab 	{ 0xf81d, KEY_BACK },
1394786baecfSMauro Carvalho Chehab 	{ 0xf84d, KEY_FASTFORWARD },
1395786baecfSMauro Carvalho Chehab 	{ 0xf844, KEY_EPG },
1396786baecfSMauro Carvalho Chehab 	{ 0xf84c, KEY_INFO },
1397786baecfSMauro Carvalho Chehab 	{ 0xf841, KEY_AB },
1398786baecfSMauro Carvalho Chehab 	{ 0xf843, KEY_AUDIO },
1399786baecfSMauro Carvalho Chehab 	{ 0xf845, KEY_SUBTITLE },
1400786baecfSMauro Carvalho Chehab 	{ 0xf84a, KEY_LIST },
1401786baecfSMauro Carvalho Chehab 	{ 0xf846, KEY_F1 },
1402786baecfSMauro Carvalho Chehab 	{ 0xf847, KEY_F2 },
1403786baecfSMauro Carvalho Chehab 	{ 0xf85e, KEY_F3 },
1404786baecfSMauro Carvalho Chehab 	{ 0xf85c, KEY_F4 },
1405786baecfSMauro Carvalho Chehab 	{ 0xf852, KEY_F5 },
1406786baecfSMauro Carvalho Chehab 	{ 0xf85a, KEY_F6 },
1407786baecfSMauro Carvalho Chehab 	{ 0xf856, KEY_MODE },
1408786baecfSMauro Carvalho Chehab 	{ 0xf858, KEY_SWITCHVIDEOMODE },
1409786baecfSMauro Carvalho Chehab };
1410786baecfSMauro Carvalho Chehab 
1411786baecfSMauro Carvalho Chehab static struct rc_map_table rc_map_tbs_table[] = {
1412786baecfSMauro Carvalho Chehab 	{ 0xf884, KEY_POWER },
1413786baecfSMauro Carvalho Chehab 	{ 0xf894, KEY_MUTE },
1414786baecfSMauro Carvalho Chehab 	{ 0xf887, KEY_1 },
1415786baecfSMauro Carvalho Chehab 	{ 0xf886, KEY_2 },
1416786baecfSMauro Carvalho Chehab 	{ 0xf885, KEY_3 },
1417786baecfSMauro Carvalho Chehab 	{ 0xf88b, KEY_4 },
1418786baecfSMauro Carvalho Chehab 	{ 0xf88a, KEY_5 },
1419786baecfSMauro Carvalho Chehab 	{ 0xf889, KEY_6 },
1420786baecfSMauro Carvalho Chehab 	{ 0xf88f, KEY_7 },
1421786baecfSMauro Carvalho Chehab 	{ 0xf88e, KEY_8 },
1422786baecfSMauro Carvalho Chehab 	{ 0xf88d, KEY_9 },
1423786baecfSMauro Carvalho Chehab 	{ 0xf892, KEY_0 },
1424786baecfSMauro Carvalho Chehab 	{ 0xf896, KEY_CHANNELUP },
1425786baecfSMauro Carvalho Chehab 	{ 0xf891, KEY_CHANNELDOWN },
1426786baecfSMauro Carvalho Chehab 	{ 0xf893, KEY_VOLUMEUP },
1427786baecfSMauro Carvalho Chehab 	{ 0xf88c, KEY_VOLUMEDOWN },
1428786baecfSMauro Carvalho Chehab 	{ 0xf883, KEY_RECORD },
1429786baecfSMauro Carvalho Chehab 	{ 0xf898, KEY_PAUSE  },
1430786baecfSMauro Carvalho Chehab 	{ 0xf899, KEY_OK },
1431786baecfSMauro Carvalho Chehab 	{ 0xf89a, KEY_SHUFFLE },
1432786baecfSMauro Carvalho Chehab 	{ 0xf881, KEY_UP },
1433786baecfSMauro Carvalho Chehab 	{ 0xf890, KEY_LEFT },
1434786baecfSMauro Carvalho Chehab 	{ 0xf882, KEY_RIGHT },
1435786baecfSMauro Carvalho Chehab 	{ 0xf888, KEY_DOWN },
1436786baecfSMauro Carvalho Chehab 	{ 0xf895, KEY_FAVORITES },
1437786baecfSMauro Carvalho Chehab 	{ 0xf897, KEY_SUBTITLE },
1438786baecfSMauro Carvalho Chehab 	{ 0xf89d, KEY_ZOOM },
1439786baecfSMauro Carvalho Chehab 	{ 0xf89f, KEY_EXIT },
1440786baecfSMauro Carvalho Chehab 	{ 0xf89e, KEY_MENU },
1441786baecfSMauro Carvalho Chehab 	{ 0xf89c, KEY_EPG },
1442786baecfSMauro Carvalho Chehab 	{ 0xf880, KEY_PREVIOUS },
1443786baecfSMauro Carvalho Chehab 	{ 0xf89b, KEY_MODE }
1444786baecfSMauro Carvalho Chehab };
1445786baecfSMauro Carvalho Chehab 
1446786baecfSMauro Carvalho Chehab static struct rc_map_table rc_map_su3000_table[] = {
1447786baecfSMauro Carvalho Chehab 	{ 0x25, KEY_POWER },	/* right-bottom Red */
1448786baecfSMauro Carvalho Chehab 	{ 0x0a, KEY_MUTE },	/* -/-- */
1449786baecfSMauro Carvalho Chehab 	{ 0x01, KEY_1 },
1450786baecfSMauro Carvalho Chehab 	{ 0x02, KEY_2 },
1451786baecfSMauro Carvalho Chehab 	{ 0x03, KEY_3 },
1452786baecfSMauro Carvalho Chehab 	{ 0x04, KEY_4 },
1453786baecfSMauro Carvalho Chehab 	{ 0x05, KEY_5 },
1454786baecfSMauro Carvalho Chehab 	{ 0x06, KEY_6 },
1455786baecfSMauro Carvalho Chehab 	{ 0x07, KEY_7 },
1456786baecfSMauro Carvalho Chehab 	{ 0x08, KEY_8 },
1457786baecfSMauro Carvalho Chehab 	{ 0x09, KEY_9 },
1458786baecfSMauro Carvalho Chehab 	{ 0x00, KEY_0 },
1459786baecfSMauro Carvalho Chehab 	{ 0x20, KEY_UP },	/* CH+ */
1460786baecfSMauro Carvalho Chehab 	{ 0x21, KEY_DOWN },	/* CH+ */
1461786baecfSMauro Carvalho Chehab 	{ 0x12, KEY_VOLUMEUP },	/* Brightness Up */
1462786baecfSMauro Carvalho Chehab 	{ 0x13, KEY_VOLUMEDOWN },/* Brightness Down */
1463786baecfSMauro Carvalho Chehab 	{ 0x1f, KEY_RECORD },
1464786baecfSMauro Carvalho Chehab 	{ 0x17, KEY_PLAY },
1465786baecfSMauro Carvalho Chehab 	{ 0x16, KEY_PAUSE },
1466786baecfSMauro Carvalho Chehab 	{ 0x0b, KEY_STOP },
1467786baecfSMauro Carvalho Chehab 	{ 0x27, KEY_FASTFORWARD },/* >> */
1468786baecfSMauro Carvalho Chehab 	{ 0x26, KEY_REWIND },	/* << */
1469786baecfSMauro Carvalho Chehab 	{ 0x0d, KEY_OK },	/* Mute */
1470786baecfSMauro Carvalho Chehab 	{ 0x11, KEY_LEFT },	/* VOL- */
1471786baecfSMauro Carvalho Chehab 	{ 0x10, KEY_RIGHT },	/* VOL+ */
1472786baecfSMauro Carvalho Chehab 	{ 0x29, KEY_BACK },	/* button under 9 */
1473786baecfSMauro Carvalho Chehab 	{ 0x2c, KEY_MENU },	/* TTX */
1474786baecfSMauro Carvalho Chehab 	{ 0x2b, KEY_EPG },	/* EPG */
1475786baecfSMauro Carvalho Chehab 	{ 0x1e, KEY_RED },	/* OSD */
1476786baecfSMauro Carvalho Chehab 	{ 0x0e, KEY_GREEN },	/* Window */
1477786baecfSMauro Carvalho Chehab 	{ 0x2d, KEY_YELLOW },	/* button under << */
1478786baecfSMauro Carvalho Chehab 	{ 0x0f, KEY_BLUE },	/* bottom yellow button */
1479786baecfSMauro Carvalho Chehab 	{ 0x14, KEY_AUDIO },	/* Snapshot */
1480786baecfSMauro Carvalho Chehab 	{ 0x38, KEY_TV },	/* TV/Radio */
1481786baecfSMauro Carvalho Chehab 	{ 0x0c, KEY_ESC }	/* upper Red button */
1482786baecfSMauro Carvalho Chehab };
1483786baecfSMauro Carvalho Chehab 
1484786baecfSMauro Carvalho Chehab static struct rc_map_dvb_usb_table_table keys_tables[] = {
1485786baecfSMauro Carvalho Chehab 	{ rc_map_dw210x_table, ARRAY_SIZE(rc_map_dw210x_table) },
1486786baecfSMauro Carvalho Chehab 	{ rc_map_tevii_table, ARRAY_SIZE(rc_map_tevii_table) },
1487786baecfSMauro Carvalho Chehab 	{ rc_map_tbs_table, ARRAY_SIZE(rc_map_tbs_table) },
1488786baecfSMauro Carvalho Chehab 	{ rc_map_su3000_table, ARRAY_SIZE(rc_map_su3000_table) },
1489786baecfSMauro Carvalho Chehab };
1490786baecfSMauro Carvalho Chehab 
1491786baecfSMauro Carvalho Chehab static int dw2102_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
1492786baecfSMauro Carvalho Chehab {
1493786baecfSMauro Carvalho Chehab 	struct rc_map_table *keymap = d->props.rc.legacy.rc_map_table;
1494786baecfSMauro Carvalho Chehab 	int keymap_size = d->props.rc.legacy.rc_map_size;
1495786baecfSMauro Carvalho Chehab 	u8 key[2];
1496786baecfSMauro Carvalho Chehab 	struct i2c_msg msg = {
1497786baecfSMauro Carvalho Chehab 		.addr = DW2102_RC_QUERY,
1498786baecfSMauro Carvalho Chehab 		.flags = I2C_M_RD,
1499786baecfSMauro Carvalho Chehab 		.buf = key,
1500786baecfSMauro Carvalho Chehab 		.len = 2
1501786baecfSMauro Carvalho Chehab 	};
1502786baecfSMauro Carvalho Chehab 	int i;
1503786baecfSMauro Carvalho Chehab 	/* override keymap */
1504786baecfSMauro Carvalho Chehab 	if ((ir_keymap > 0) && (ir_keymap <= ARRAY_SIZE(keys_tables))) {
1505786baecfSMauro Carvalho Chehab 		keymap = keys_tables[ir_keymap - 1].rc_keys ;
1506786baecfSMauro Carvalho Chehab 		keymap_size = keys_tables[ir_keymap - 1].rc_keys_size;
1507786baecfSMauro Carvalho Chehab 	} else if (ir_keymap > ARRAY_SIZE(keys_tables))
1508786baecfSMauro Carvalho Chehab 		return 0; /* none */
1509786baecfSMauro Carvalho Chehab 
1510786baecfSMauro Carvalho Chehab 	*state = REMOTE_NO_KEY_PRESSED;
1511786baecfSMauro Carvalho Chehab 	if (d->props.i2c_algo->master_xfer(&d->i2c_adap, &msg, 1) == 1) {
1512786baecfSMauro Carvalho Chehab 		for (i = 0; i < keymap_size ; i++) {
1513786baecfSMauro Carvalho Chehab 			if (rc5_data(&keymap[i]) == msg.buf[0]) {
1514786baecfSMauro Carvalho Chehab 				*state = REMOTE_KEY_PRESSED;
1515786baecfSMauro Carvalho Chehab 				*event = keymap[i].keycode;
1516786baecfSMauro Carvalho Chehab 				break;
1517786baecfSMauro Carvalho Chehab 			}
1518786baecfSMauro Carvalho Chehab 
1519786baecfSMauro Carvalho Chehab 		}
1520786baecfSMauro Carvalho Chehab 
1521786baecfSMauro Carvalho Chehab 		if ((*state) == REMOTE_KEY_PRESSED)
1522786baecfSMauro Carvalho Chehab 			deb_rc("%s: found rc key: %x, %x, event: %x\n",
1523786baecfSMauro Carvalho Chehab 					__func__, key[0], key[1], (*event));
1524786baecfSMauro Carvalho Chehab 		else if (key[0] != 0xff)
1525786baecfSMauro Carvalho Chehab 			deb_rc("%s: unknown rc key: %x, %x\n",
1526786baecfSMauro Carvalho Chehab 					__func__, key[0], key[1]);
1527786baecfSMauro Carvalho Chehab 
1528786baecfSMauro Carvalho Chehab 	}
1529786baecfSMauro Carvalho Chehab 
1530786baecfSMauro Carvalho Chehab 	return 0;
1531786baecfSMauro Carvalho Chehab }
1532786baecfSMauro Carvalho Chehab 
1533786baecfSMauro Carvalho Chehab enum dw2102_table_entry {
1534786baecfSMauro Carvalho Chehab 	CYPRESS_DW2102,
1535786baecfSMauro Carvalho Chehab 	CYPRESS_DW2101,
1536786baecfSMauro Carvalho Chehab 	CYPRESS_DW2104,
1537786baecfSMauro Carvalho Chehab 	TEVII_S650,
1538786baecfSMauro Carvalho Chehab 	TERRATEC_CINERGY_S,
1539786baecfSMauro Carvalho Chehab 	CYPRESS_DW3101,
1540786baecfSMauro Carvalho Chehab 	TEVII_S630,
1541786baecfSMauro Carvalho Chehab 	PROF_1100,
1542786baecfSMauro Carvalho Chehab 	TEVII_S660,
1543786baecfSMauro Carvalho Chehab 	PROF_7500,
1544786baecfSMauro Carvalho Chehab 	GENIATECH_SU3000,
1545786baecfSMauro Carvalho Chehab 	TERRATEC_CINERGY_S2,
1546786baecfSMauro Carvalho Chehab 	TEVII_S480_1,
1547786baecfSMauro Carvalho Chehab 	TEVII_S480_2,
1548786baecfSMauro Carvalho Chehab 	X3M_SPC1400HD,
1549955d00acSIgor M. Liplianin 	TEVII_S421,
1550955d00acSIgor M. Liplianin 	TEVII_S632,
1551*44122dd6SIgor M. Liplianin 	TERRATEC_CINERGY_S2_R2,
1552786baecfSMauro Carvalho Chehab };
1553786baecfSMauro Carvalho Chehab 
1554786baecfSMauro Carvalho Chehab static struct usb_device_id dw2102_table[] = {
1555786baecfSMauro Carvalho Chehab 	[CYPRESS_DW2102] = {USB_DEVICE(USB_VID_CYPRESS, USB_PID_DW2102)},
1556786baecfSMauro Carvalho Chehab 	[CYPRESS_DW2101] = {USB_DEVICE(USB_VID_CYPRESS, 0x2101)},
1557786baecfSMauro Carvalho Chehab 	[CYPRESS_DW2104] = {USB_DEVICE(USB_VID_CYPRESS, USB_PID_DW2104)},
1558786baecfSMauro Carvalho Chehab 	[TEVII_S650] = {USB_DEVICE(0x9022, USB_PID_TEVII_S650)},
1559786baecfSMauro Carvalho Chehab 	[TERRATEC_CINERGY_S] = {USB_DEVICE(USB_VID_TERRATEC, USB_PID_CINERGY_S)},
1560786baecfSMauro Carvalho Chehab 	[CYPRESS_DW3101] = {USB_DEVICE(USB_VID_CYPRESS, USB_PID_DW3101)},
1561786baecfSMauro Carvalho Chehab 	[TEVII_S630] = {USB_DEVICE(0x9022, USB_PID_TEVII_S630)},
1562786baecfSMauro Carvalho Chehab 	[PROF_1100] = {USB_DEVICE(0x3011, USB_PID_PROF_1100)},
1563786baecfSMauro Carvalho Chehab 	[TEVII_S660] = {USB_DEVICE(0x9022, USB_PID_TEVII_S660)},
1564786baecfSMauro Carvalho Chehab 	[PROF_7500] = {USB_DEVICE(0x3034, 0x7500)},
1565786baecfSMauro Carvalho Chehab 	[GENIATECH_SU3000] = {USB_DEVICE(0x1f4d, 0x3000)},
1566786baecfSMauro Carvalho Chehab 	[TERRATEC_CINERGY_S2] = {USB_DEVICE(USB_VID_TERRATEC, 0x00a8)},
1567786baecfSMauro Carvalho Chehab 	[TEVII_S480_1] = {USB_DEVICE(0x9022, USB_PID_TEVII_S480_1)},
1568786baecfSMauro Carvalho Chehab 	[TEVII_S480_2] = {USB_DEVICE(0x9022, USB_PID_TEVII_S480_2)},
1569786baecfSMauro Carvalho Chehab 	[X3M_SPC1400HD] = {USB_DEVICE(0x1f4d, 0x3100)},
1570955d00acSIgor M. Liplianin 	[TEVII_S421] = {USB_DEVICE(0x9022, USB_PID_TEVII_S421)},
1571955d00acSIgor M. Liplianin 	[TEVII_S632] = {USB_DEVICE(0x9022, USB_PID_TEVII_S632)},
1572*44122dd6SIgor M. Liplianin 	[TERRATEC_CINERGY_S2_R2] = {USB_DEVICE(USB_VID_TERRATEC, 0x00b0)},
1573786baecfSMauro Carvalho Chehab 	{ }
1574786baecfSMauro Carvalho Chehab };
1575786baecfSMauro Carvalho Chehab 
1576786baecfSMauro Carvalho Chehab MODULE_DEVICE_TABLE(usb, dw2102_table);
1577786baecfSMauro Carvalho Chehab 
1578786baecfSMauro Carvalho Chehab static int dw2102_load_firmware(struct usb_device *dev,
1579786baecfSMauro Carvalho Chehab 			const struct firmware *frmwr)
1580786baecfSMauro Carvalho Chehab {
1581786baecfSMauro Carvalho Chehab 	u8 *b, *p;
1582786baecfSMauro Carvalho Chehab 	int ret = 0, i;
1583786baecfSMauro Carvalho Chehab 	u8 reset;
1584786baecfSMauro Carvalho Chehab 	u8 reset16[] = {0, 0, 0, 0, 0, 0, 0};
1585786baecfSMauro Carvalho Chehab 	const struct firmware *fw;
1586786baecfSMauro Carvalho Chehab 
1587786baecfSMauro Carvalho Chehab 	switch (dev->descriptor.idProduct) {
1588786baecfSMauro Carvalho Chehab 	case 0x2101:
15896823627bSRémi Cardona 		ret = request_firmware(&fw, DW2101_FIRMWARE, &dev->dev);
1590786baecfSMauro Carvalho Chehab 		if (ret != 0) {
15916823627bSRémi Cardona 			err(err_str, DW2101_FIRMWARE);
1592786baecfSMauro Carvalho Chehab 			return ret;
1593786baecfSMauro Carvalho Chehab 		}
1594786baecfSMauro Carvalho Chehab 		break;
1595786baecfSMauro Carvalho Chehab 	default:
1596786baecfSMauro Carvalho Chehab 		fw = frmwr;
1597786baecfSMauro Carvalho Chehab 		break;
1598786baecfSMauro Carvalho Chehab 	}
1599786baecfSMauro Carvalho Chehab 	info("start downloading DW210X firmware");
1600786baecfSMauro Carvalho Chehab 	p = kmalloc(fw->size, GFP_KERNEL);
1601786baecfSMauro Carvalho Chehab 	reset = 1;
1602786baecfSMauro Carvalho Chehab 	/*stop the CPU*/
1603786baecfSMauro Carvalho Chehab 	dw210x_op_rw(dev, 0xa0, 0x7f92, 0, &reset, 1, DW210X_WRITE_MSG);
1604786baecfSMauro Carvalho Chehab 	dw210x_op_rw(dev, 0xa0, 0xe600, 0, &reset, 1, DW210X_WRITE_MSG);
1605786baecfSMauro Carvalho Chehab 
1606786baecfSMauro Carvalho Chehab 	if (p != NULL) {
1607786baecfSMauro Carvalho Chehab 		memcpy(p, fw->data, fw->size);
1608786baecfSMauro Carvalho Chehab 		for (i = 0; i < fw->size; i += 0x40) {
1609786baecfSMauro Carvalho Chehab 			b = (u8 *) p + i;
1610786baecfSMauro Carvalho Chehab 			if (dw210x_op_rw(dev, 0xa0, i, 0, b , 0x40,
1611786baecfSMauro Carvalho Chehab 					DW210X_WRITE_MSG) != 0x40) {
1612786baecfSMauro Carvalho Chehab 				err("error while transferring firmware");
1613786baecfSMauro Carvalho Chehab 				ret = -EINVAL;
1614786baecfSMauro Carvalho Chehab 				break;
1615786baecfSMauro Carvalho Chehab 			}
1616786baecfSMauro Carvalho Chehab 		}
1617786baecfSMauro Carvalho Chehab 		/* restart the CPU */
1618786baecfSMauro Carvalho Chehab 		reset = 0;
1619786baecfSMauro Carvalho Chehab 		if (ret || dw210x_op_rw(dev, 0xa0, 0x7f92, 0, &reset, 1,
1620786baecfSMauro Carvalho Chehab 					DW210X_WRITE_MSG) != 1) {
1621786baecfSMauro Carvalho Chehab 			err("could not restart the USB controller CPU.");
1622786baecfSMauro Carvalho Chehab 			ret = -EINVAL;
1623786baecfSMauro Carvalho Chehab 		}
1624786baecfSMauro Carvalho Chehab 		if (ret || dw210x_op_rw(dev, 0xa0, 0xe600, 0, &reset, 1,
1625786baecfSMauro Carvalho Chehab 					DW210X_WRITE_MSG) != 1) {
1626786baecfSMauro Carvalho Chehab 			err("could not restart the USB controller CPU.");
1627786baecfSMauro Carvalho Chehab 			ret = -EINVAL;
1628786baecfSMauro Carvalho Chehab 		}
1629786baecfSMauro Carvalho Chehab 		/* init registers */
1630786baecfSMauro Carvalho Chehab 		switch (dev->descriptor.idProduct) {
1631786baecfSMauro Carvalho Chehab 		case USB_PID_TEVII_S650:
1632786baecfSMauro Carvalho Chehab 			dw2104_properties.rc.legacy.rc_map_table = rc_map_tevii_table;
1633786baecfSMauro Carvalho Chehab 			dw2104_properties.rc.legacy.rc_map_size =
1634786baecfSMauro Carvalho Chehab 					ARRAY_SIZE(rc_map_tevii_table);
1635786baecfSMauro Carvalho Chehab 		case USB_PID_DW2104:
1636786baecfSMauro Carvalho Chehab 			reset = 1;
1637786baecfSMauro Carvalho Chehab 			dw210x_op_rw(dev, 0xc4, 0x0000, 0, &reset, 1,
1638786baecfSMauro Carvalho Chehab 					DW210X_WRITE_MSG);
1639786baecfSMauro Carvalho Chehab 			/* break omitted intentionally */
1640786baecfSMauro Carvalho Chehab 		case USB_PID_DW3101:
1641786baecfSMauro Carvalho Chehab 			reset = 0;
1642786baecfSMauro Carvalho Chehab 			dw210x_op_rw(dev, 0xbf, 0x0040, 0, &reset, 0,
1643786baecfSMauro Carvalho Chehab 					DW210X_WRITE_MSG);
1644786baecfSMauro Carvalho Chehab 			break;
1645786baecfSMauro Carvalho Chehab 		case USB_PID_CINERGY_S:
1646786baecfSMauro Carvalho Chehab 		case USB_PID_DW2102:
1647786baecfSMauro Carvalho Chehab 			dw210x_op_rw(dev, 0xbf, 0x0040, 0, &reset, 0,
1648786baecfSMauro Carvalho Chehab 					DW210X_WRITE_MSG);
1649786baecfSMauro Carvalho Chehab 			dw210x_op_rw(dev, 0xb9, 0x0000, 0, &reset16[0], 2,
1650786baecfSMauro Carvalho Chehab 					DW210X_READ_MSG);
1651786baecfSMauro Carvalho Chehab 			/* check STV0299 frontend  */
1652786baecfSMauro Carvalho Chehab 			dw210x_op_rw(dev, 0xb5, 0, 0, &reset16[0], 2,
1653786baecfSMauro Carvalho Chehab 					DW210X_READ_MSG);
1654786baecfSMauro Carvalho Chehab 			if ((reset16[0] == 0xa1) || (reset16[0] == 0x80)) {
1655786baecfSMauro Carvalho Chehab 				dw2102_properties.i2c_algo = &dw2102_i2c_algo;
1656786baecfSMauro Carvalho Chehab 				dw2102_properties.adapter->fe[0].tuner_attach = &dw2102_tuner_attach;
1657786baecfSMauro Carvalho Chehab 				break;
1658786baecfSMauro Carvalho Chehab 			} else {
1659786baecfSMauro Carvalho Chehab 				/* check STV0288 frontend  */
1660786baecfSMauro Carvalho Chehab 				reset16[0] = 0xd0;
1661786baecfSMauro Carvalho Chehab 				reset16[1] = 1;
1662786baecfSMauro Carvalho Chehab 				reset16[2] = 0;
1663786baecfSMauro Carvalho Chehab 				dw210x_op_rw(dev, 0xc2, 0, 0, &reset16[0], 3,
1664786baecfSMauro Carvalho Chehab 						DW210X_WRITE_MSG);
1665786baecfSMauro Carvalho Chehab 				dw210x_op_rw(dev, 0xc3, 0xd1, 0, &reset16[0], 3,
1666786baecfSMauro Carvalho Chehab 						DW210X_READ_MSG);
1667786baecfSMauro Carvalho Chehab 				if (reset16[2] == 0x11) {
1668786baecfSMauro Carvalho Chehab 					dw2102_properties.i2c_algo = &dw2102_earda_i2c_algo;
1669786baecfSMauro Carvalho Chehab 					break;
1670786baecfSMauro Carvalho Chehab 				}
1671786baecfSMauro Carvalho Chehab 			}
1672786baecfSMauro Carvalho Chehab 		case 0x2101:
1673786baecfSMauro Carvalho Chehab 			dw210x_op_rw(dev, 0xbc, 0x0030, 0, &reset16[0], 2,
1674786baecfSMauro Carvalho Chehab 					DW210X_READ_MSG);
1675786baecfSMauro Carvalho Chehab 			dw210x_op_rw(dev, 0xba, 0x0000, 0, &reset16[0], 7,
1676786baecfSMauro Carvalho Chehab 					DW210X_READ_MSG);
1677786baecfSMauro Carvalho Chehab 			dw210x_op_rw(dev, 0xba, 0x0000, 0, &reset16[0], 7,
1678786baecfSMauro Carvalho Chehab 					DW210X_READ_MSG);
1679786baecfSMauro Carvalho Chehab 			dw210x_op_rw(dev, 0xb9, 0x0000, 0, &reset16[0], 2,
1680786baecfSMauro Carvalho Chehab 					DW210X_READ_MSG);
1681786baecfSMauro Carvalho Chehab 			break;
1682786baecfSMauro Carvalho Chehab 		}
1683786baecfSMauro Carvalho Chehab 
1684786baecfSMauro Carvalho Chehab 		msleep(100);
1685786baecfSMauro Carvalho Chehab 		kfree(p);
1686786baecfSMauro Carvalho Chehab 	}
1687786baecfSMauro Carvalho Chehab 	return ret;
1688786baecfSMauro Carvalho Chehab }
1689786baecfSMauro Carvalho Chehab 
1690786baecfSMauro Carvalho Chehab static struct dvb_usb_device_properties dw2102_properties = {
1691786baecfSMauro Carvalho Chehab 	.caps = DVB_USB_IS_AN_I2C_ADAPTER,
1692786baecfSMauro Carvalho Chehab 	.usb_ctrl = DEVICE_SPECIFIC,
16936823627bSRémi Cardona 	.firmware = DW2102_FIRMWARE,
1694786baecfSMauro Carvalho Chehab 	.no_reconnect = 1,
1695786baecfSMauro Carvalho Chehab 
1696786baecfSMauro Carvalho Chehab 	.i2c_algo = &dw2102_serit_i2c_algo,
1697786baecfSMauro Carvalho Chehab 
1698786baecfSMauro Carvalho Chehab 	.rc.legacy = {
1699786baecfSMauro Carvalho Chehab 		.rc_map_table = rc_map_dw210x_table,
1700786baecfSMauro Carvalho Chehab 		.rc_map_size = ARRAY_SIZE(rc_map_dw210x_table),
1701786baecfSMauro Carvalho Chehab 		.rc_interval = 150,
1702786baecfSMauro Carvalho Chehab 		.rc_query = dw2102_rc_query,
1703786baecfSMauro Carvalho Chehab 	},
1704786baecfSMauro Carvalho Chehab 
1705786baecfSMauro Carvalho Chehab 	.generic_bulk_ctrl_endpoint = 0x81,
1706786baecfSMauro Carvalho Chehab 	/* parameter for the MPEG2-data transfer */
1707786baecfSMauro Carvalho Chehab 	.num_adapters = 1,
1708786baecfSMauro Carvalho Chehab 	.download_firmware = dw2102_load_firmware,
1709786baecfSMauro Carvalho Chehab 	.read_mac_address = dw210x_read_mac_address,
1710786baecfSMauro Carvalho Chehab 	.adapter = {
1711786baecfSMauro Carvalho Chehab 		{
1712786baecfSMauro Carvalho Chehab 		.num_frontends = 1,
1713786baecfSMauro Carvalho Chehab 		.fe = {{
1714786baecfSMauro Carvalho Chehab 			.frontend_attach = dw2102_frontend_attach,
1715786baecfSMauro Carvalho Chehab 			.stream = {
1716786baecfSMauro Carvalho Chehab 				.type = USB_BULK,
1717786baecfSMauro Carvalho Chehab 				.count = 8,
1718786baecfSMauro Carvalho Chehab 				.endpoint = 0x82,
1719786baecfSMauro Carvalho Chehab 				.u = {
1720786baecfSMauro Carvalho Chehab 					.bulk = {
1721786baecfSMauro Carvalho Chehab 						.buffersize = 4096,
1722786baecfSMauro Carvalho Chehab 					}
1723786baecfSMauro Carvalho Chehab 				}
1724786baecfSMauro Carvalho Chehab 			},
1725786baecfSMauro Carvalho Chehab 		}},
1726786baecfSMauro Carvalho Chehab 		}
1727786baecfSMauro Carvalho Chehab 	},
1728786baecfSMauro Carvalho Chehab 	.num_device_descs = 3,
1729786baecfSMauro Carvalho Chehab 	.devices = {
1730786baecfSMauro Carvalho Chehab 		{"DVBWorld DVB-S 2102 USB2.0",
1731786baecfSMauro Carvalho Chehab 			{&dw2102_table[CYPRESS_DW2102], NULL},
1732786baecfSMauro Carvalho Chehab 			{NULL},
1733786baecfSMauro Carvalho Chehab 		},
1734786baecfSMauro Carvalho Chehab 		{"DVBWorld DVB-S 2101 USB2.0",
1735786baecfSMauro Carvalho Chehab 			{&dw2102_table[CYPRESS_DW2101], NULL},
1736786baecfSMauro Carvalho Chehab 			{NULL},
1737786baecfSMauro Carvalho Chehab 		},
1738786baecfSMauro Carvalho Chehab 		{"TerraTec Cinergy S USB",
1739786baecfSMauro Carvalho Chehab 			{&dw2102_table[TERRATEC_CINERGY_S], NULL},
1740786baecfSMauro Carvalho Chehab 			{NULL},
1741786baecfSMauro Carvalho Chehab 		},
1742786baecfSMauro Carvalho Chehab 	}
1743786baecfSMauro Carvalho Chehab };
1744786baecfSMauro Carvalho Chehab 
1745786baecfSMauro Carvalho Chehab static struct dvb_usb_device_properties dw2104_properties = {
1746786baecfSMauro Carvalho Chehab 	.caps = DVB_USB_IS_AN_I2C_ADAPTER,
1747786baecfSMauro Carvalho Chehab 	.usb_ctrl = DEVICE_SPECIFIC,
17486823627bSRémi Cardona 	.firmware = DW2104_FIRMWARE,
1749786baecfSMauro Carvalho Chehab 	.no_reconnect = 1,
1750786baecfSMauro Carvalho Chehab 
1751786baecfSMauro Carvalho Chehab 	.i2c_algo = &dw2104_i2c_algo,
1752786baecfSMauro Carvalho Chehab 	.rc.legacy = {
1753786baecfSMauro Carvalho Chehab 		.rc_map_table = rc_map_dw210x_table,
1754786baecfSMauro Carvalho Chehab 		.rc_map_size = ARRAY_SIZE(rc_map_dw210x_table),
1755786baecfSMauro Carvalho Chehab 		.rc_interval = 150,
1756786baecfSMauro Carvalho Chehab 		.rc_query = dw2102_rc_query,
1757786baecfSMauro Carvalho Chehab 	},
1758786baecfSMauro Carvalho Chehab 
1759786baecfSMauro Carvalho Chehab 	.generic_bulk_ctrl_endpoint = 0x81,
1760786baecfSMauro Carvalho Chehab 	/* parameter for the MPEG2-data transfer */
1761786baecfSMauro Carvalho Chehab 	.num_adapters = 1,
1762786baecfSMauro Carvalho Chehab 	.download_firmware = dw2102_load_firmware,
1763786baecfSMauro Carvalho Chehab 	.read_mac_address = dw210x_read_mac_address,
1764786baecfSMauro Carvalho Chehab 	.adapter = {
1765786baecfSMauro Carvalho Chehab 		{
1766786baecfSMauro Carvalho Chehab 		.num_frontends = 1,
1767786baecfSMauro Carvalho Chehab 		.fe = {{
1768786baecfSMauro Carvalho Chehab 			.frontend_attach = dw2104_frontend_attach,
1769786baecfSMauro Carvalho Chehab 			.stream = {
1770786baecfSMauro Carvalho Chehab 				.type = USB_BULK,
1771786baecfSMauro Carvalho Chehab 				.count = 8,
1772786baecfSMauro Carvalho Chehab 				.endpoint = 0x82,
1773786baecfSMauro Carvalho Chehab 				.u = {
1774786baecfSMauro Carvalho Chehab 					.bulk = {
1775786baecfSMauro Carvalho Chehab 						.buffersize = 4096,
1776786baecfSMauro Carvalho Chehab 					}
1777786baecfSMauro Carvalho Chehab 				}
1778786baecfSMauro Carvalho Chehab 			},
1779786baecfSMauro Carvalho Chehab 		}},
1780786baecfSMauro Carvalho Chehab 		}
1781786baecfSMauro Carvalho Chehab 	},
1782786baecfSMauro Carvalho Chehab 	.num_device_descs = 2,
1783786baecfSMauro Carvalho Chehab 	.devices = {
1784786baecfSMauro Carvalho Chehab 		{ "DVBWorld DW2104 USB2.0",
1785786baecfSMauro Carvalho Chehab 			{&dw2102_table[CYPRESS_DW2104], NULL},
1786786baecfSMauro Carvalho Chehab 			{NULL},
1787786baecfSMauro Carvalho Chehab 		},
1788786baecfSMauro Carvalho Chehab 		{ "TeVii S650 USB2.0",
1789786baecfSMauro Carvalho Chehab 			{&dw2102_table[TEVII_S650], NULL},
1790786baecfSMauro Carvalho Chehab 			{NULL},
1791786baecfSMauro Carvalho Chehab 		},
1792786baecfSMauro Carvalho Chehab 	}
1793786baecfSMauro Carvalho Chehab };
1794786baecfSMauro Carvalho Chehab 
1795786baecfSMauro Carvalho Chehab static struct dvb_usb_device_properties dw3101_properties = {
1796786baecfSMauro Carvalho Chehab 	.caps = DVB_USB_IS_AN_I2C_ADAPTER,
1797786baecfSMauro Carvalho Chehab 	.usb_ctrl = DEVICE_SPECIFIC,
17986823627bSRémi Cardona 	.firmware = DW3101_FIRMWARE,
1799786baecfSMauro Carvalho Chehab 	.no_reconnect = 1,
1800786baecfSMauro Carvalho Chehab 
1801786baecfSMauro Carvalho Chehab 	.i2c_algo = &dw3101_i2c_algo,
1802786baecfSMauro Carvalho Chehab 	.rc.legacy = {
1803786baecfSMauro Carvalho Chehab 		.rc_map_table = rc_map_dw210x_table,
1804786baecfSMauro Carvalho Chehab 		.rc_map_size = ARRAY_SIZE(rc_map_dw210x_table),
1805786baecfSMauro Carvalho Chehab 		.rc_interval = 150,
1806786baecfSMauro Carvalho Chehab 		.rc_query = dw2102_rc_query,
1807786baecfSMauro Carvalho Chehab 	},
1808786baecfSMauro Carvalho Chehab 
1809786baecfSMauro Carvalho Chehab 	.generic_bulk_ctrl_endpoint = 0x81,
1810786baecfSMauro Carvalho Chehab 	/* parameter for the MPEG2-data transfer */
1811786baecfSMauro Carvalho Chehab 	.num_adapters = 1,
1812786baecfSMauro Carvalho Chehab 	.download_firmware = dw2102_load_firmware,
1813786baecfSMauro Carvalho Chehab 	.read_mac_address = dw210x_read_mac_address,
1814786baecfSMauro Carvalho Chehab 	.adapter = {
1815786baecfSMauro Carvalho Chehab 		{
1816786baecfSMauro Carvalho Chehab 		.num_frontends = 1,
1817786baecfSMauro Carvalho Chehab 		.fe = {{
1818786baecfSMauro Carvalho Chehab 			.frontend_attach = dw3101_frontend_attach,
1819786baecfSMauro Carvalho Chehab 			.tuner_attach = dw3101_tuner_attach,
1820786baecfSMauro Carvalho Chehab 			.stream = {
1821786baecfSMauro Carvalho Chehab 				.type = USB_BULK,
1822786baecfSMauro Carvalho Chehab 				.count = 8,
1823786baecfSMauro Carvalho Chehab 				.endpoint = 0x82,
1824786baecfSMauro Carvalho Chehab 				.u = {
1825786baecfSMauro Carvalho Chehab 					.bulk = {
1826786baecfSMauro Carvalho Chehab 						.buffersize = 4096,
1827786baecfSMauro Carvalho Chehab 					}
1828786baecfSMauro Carvalho Chehab 				}
1829786baecfSMauro Carvalho Chehab 			},
1830786baecfSMauro Carvalho Chehab 		}},
1831786baecfSMauro Carvalho Chehab 		}
1832786baecfSMauro Carvalho Chehab 	},
1833786baecfSMauro Carvalho Chehab 	.num_device_descs = 1,
1834786baecfSMauro Carvalho Chehab 	.devices = {
1835786baecfSMauro Carvalho Chehab 		{ "DVBWorld DVB-C 3101 USB2.0",
1836786baecfSMauro Carvalho Chehab 			{&dw2102_table[CYPRESS_DW3101], NULL},
1837786baecfSMauro Carvalho Chehab 			{NULL},
1838786baecfSMauro Carvalho Chehab 		},
1839786baecfSMauro Carvalho Chehab 	}
1840786baecfSMauro Carvalho Chehab };
1841786baecfSMauro Carvalho Chehab 
1842786baecfSMauro Carvalho Chehab static struct dvb_usb_device_properties s6x0_properties = {
1843786baecfSMauro Carvalho Chehab 	.caps = DVB_USB_IS_AN_I2C_ADAPTER,
1844786baecfSMauro Carvalho Chehab 	.usb_ctrl = DEVICE_SPECIFIC,
1845786baecfSMauro Carvalho Chehab 	.size_of_priv = sizeof(struct s6x0_state),
18466823627bSRémi Cardona 	.firmware = S630_FIRMWARE,
1847786baecfSMauro Carvalho Chehab 	.no_reconnect = 1,
1848786baecfSMauro Carvalho Chehab 
1849786baecfSMauro Carvalho Chehab 	.i2c_algo = &s6x0_i2c_algo,
1850786baecfSMauro Carvalho Chehab 	.rc.legacy = {
1851786baecfSMauro Carvalho Chehab 		.rc_map_table = rc_map_tevii_table,
1852786baecfSMauro Carvalho Chehab 		.rc_map_size = ARRAY_SIZE(rc_map_tevii_table),
1853786baecfSMauro Carvalho Chehab 		.rc_interval = 150,
1854786baecfSMauro Carvalho Chehab 		.rc_query = dw2102_rc_query,
1855786baecfSMauro Carvalho Chehab 	},
1856786baecfSMauro Carvalho Chehab 
1857786baecfSMauro Carvalho Chehab 	.generic_bulk_ctrl_endpoint = 0x81,
1858786baecfSMauro Carvalho Chehab 	.num_adapters = 1,
1859786baecfSMauro Carvalho Chehab 	.download_firmware = dw2102_load_firmware,
1860786baecfSMauro Carvalho Chehab 	.read_mac_address = s6x0_read_mac_address,
1861786baecfSMauro Carvalho Chehab 	.adapter = {
1862786baecfSMauro Carvalho Chehab 		{
1863786baecfSMauro Carvalho Chehab 		.num_frontends = 1,
1864786baecfSMauro Carvalho Chehab 		.fe = {{
1865786baecfSMauro Carvalho Chehab 			.frontend_attach = zl100313_frontend_attach,
1866786baecfSMauro Carvalho Chehab 			.stream = {
1867786baecfSMauro Carvalho Chehab 				.type = USB_BULK,
1868786baecfSMauro Carvalho Chehab 				.count = 8,
1869786baecfSMauro Carvalho Chehab 				.endpoint = 0x82,
1870786baecfSMauro Carvalho Chehab 				.u = {
1871786baecfSMauro Carvalho Chehab 					.bulk = {
1872786baecfSMauro Carvalho Chehab 						.buffersize = 4096,
1873786baecfSMauro Carvalho Chehab 					}
1874786baecfSMauro Carvalho Chehab 				}
1875786baecfSMauro Carvalho Chehab 			},
1876786baecfSMauro Carvalho Chehab 		}},
1877786baecfSMauro Carvalho Chehab 		}
1878786baecfSMauro Carvalho Chehab 	},
1879786baecfSMauro Carvalho Chehab 	.num_device_descs = 1,
1880786baecfSMauro Carvalho Chehab 	.devices = {
1881786baecfSMauro Carvalho Chehab 		{"TeVii S630 USB",
1882786baecfSMauro Carvalho Chehab 			{&dw2102_table[TEVII_S630], NULL},
1883786baecfSMauro Carvalho Chehab 			{NULL},
1884786baecfSMauro Carvalho Chehab 		},
1885786baecfSMauro Carvalho Chehab 	}
1886786baecfSMauro Carvalho Chehab };
1887786baecfSMauro Carvalho Chehab 
1888786baecfSMauro Carvalho Chehab struct dvb_usb_device_properties *p1100;
1889786baecfSMauro Carvalho Chehab static struct dvb_usb_device_description d1100 = {
1890786baecfSMauro Carvalho Chehab 	"Prof 1100 USB ",
1891786baecfSMauro Carvalho Chehab 	{&dw2102_table[PROF_1100], NULL},
1892786baecfSMauro Carvalho Chehab 	{NULL},
1893786baecfSMauro Carvalho Chehab };
1894786baecfSMauro Carvalho Chehab 
1895786baecfSMauro Carvalho Chehab struct dvb_usb_device_properties *s660;
1896786baecfSMauro Carvalho Chehab static struct dvb_usb_device_description d660 = {
1897786baecfSMauro Carvalho Chehab 	"TeVii S660 USB",
1898786baecfSMauro Carvalho Chehab 	{&dw2102_table[TEVII_S660], NULL},
1899786baecfSMauro Carvalho Chehab 	{NULL},
1900786baecfSMauro Carvalho Chehab };
1901786baecfSMauro Carvalho Chehab 
1902786baecfSMauro Carvalho Chehab static struct dvb_usb_device_description d480_1 = {
1903786baecfSMauro Carvalho Chehab 	"TeVii S480.1 USB",
1904786baecfSMauro Carvalho Chehab 	{&dw2102_table[TEVII_S480_1], NULL},
1905786baecfSMauro Carvalho Chehab 	{NULL},
1906786baecfSMauro Carvalho Chehab };
1907786baecfSMauro Carvalho Chehab 
1908786baecfSMauro Carvalho Chehab static struct dvb_usb_device_description d480_2 = {
1909786baecfSMauro Carvalho Chehab 	"TeVii S480.2 USB",
1910786baecfSMauro Carvalho Chehab 	{&dw2102_table[TEVII_S480_2], NULL},
1911786baecfSMauro Carvalho Chehab 	{NULL},
1912786baecfSMauro Carvalho Chehab };
1913786baecfSMauro Carvalho Chehab 
1914786baecfSMauro Carvalho Chehab struct dvb_usb_device_properties *p7500;
1915786baecfSMauro Carvalho Chehab static struct dvb_usb_device_description d7500 = {
1916786baecfSMauro Carvalho Chehab 	"Prof 7500 USB DVB-S2",
1917786baecfSMauro Carvalho Chehab 	{&dw2102_table[PROF_7500], NULL},
1918786baecfSMauro Carvalho Chehab 	{NULL},
1919786baecfSMauro Carvalho Chehab };
1920786baecfSMauro Carvalho Chehab 
1921955d00acSIgor M. Liplianin struct dvb_usb_device_properties *s421;
1922955d00acSIgor M. Liplianin static struct dvb_usb_device_description d421 = {
1923955d00acSIgor M. Liplianin 	"TeVii S421 PCI",
1924955d00acSIgor M. Liplianin 	{&dw2102_table[TEVII_S421], NULL},
1925955d00acSIgor M. Liplianin 	{NULL},
1926955d00acSIgor M. Liplianin };
1927955d00acSIgor M. Liplianin 
1928955d00acSIgor M. Liplianin static struct dvb_usb_device_description d632 = {
1929955d00acSIgor M. Liplianin 	"TeVii S632 USB",
1930955d00acSIgor M. Liplianin 	{&dw2102_table[TEVII_S632], NULL},
1931955d00acSIgor M. Liplianin 	{NULL},
1932955d00acSIgor M. Liplianin };
1933955d00acSIgor M. Liplianin 
1934786baecfSMauro Carvalho Chehab static struct dvb_usb_device_properties su3000_properties = {
1935786baecfSMauro Carvalho Chehab 	.caps = DVB_USB_IS_AN_I2C_ADAPTER,
1936786baecfSMauro Carvalho Chehab 	.usb_ctrl = DEVICE_SPECIFIC,
1937786baecfSMauro Carvalho Chehab 	.size_of_priv = sizeof(struct su3000_state),
1938786baecfSMauro Carvalho Chehab 	.power_ctrl = su3000_power_ctrl,
1939786baecfSMauro Carvalho Chehab 	.num_adapters = 1,
1940786baecfSMauro Carvalho Chehab 	.identify_state	= su3000_identify_state,
1941786baecfSMauro Carvalho Chehab 	.i2c_algo = &su3000_i2c_algo,
1942786baecfSMauro Carvalho Chehab 
1943786baecfSMauro Carvalho Chehab 	.rc.legacy = {
1944786baecfSMauro Carvalho Chehab 		.rc_map_table = rc_map_su3000_table,
1945786baecfSMauro Carvalho Chehab 		.rc_map_size = ARRAY_SIZE(rc_map_su3000_table),
1946786baecfSMauro Carvalho Chehab 		.rc_interval = 150,
1947786baecfSMauro Carvalho Chehab 		.rc_query = dw2102_rc_query,
1948786baecfSMauro Carvalho Chehab 	},
1949786baecfSMauro Carvalho Chehab 
1950786baecfSMauro Carvalho Chehab 	.read_mac_address = su3000_read_mac_address,
1951786baecfSMauro Carvalho Chehab 
1952786baecfSMauro Carvalho Chehab 	.generic_bulk_ctrl_endpoint = 0x01,
1953786baecfSMauro Carvalho Chehab 
1954786baecfSMauro Carvalho Chehab 	.adapter = {
1955786baecfSMauro Carvalho Chehab 		{
1956786baecfSMauro Carvalho Chehab 		.num_frontends = 1,
1957786baecfSMauro Carvalho Chehab 		.fe = {{
1958786baecfSMauro Carvalho Chehab 			.streaming_ctrl   = su3000_streaming_ctrl,
1959786baecfSMauro Carvalho Chehab 			.frontend_attach  = su3000_frontend_attach,
1960786baecfSMauro Carvalho Chehab 			.stream = {
1961786baecfSMauro Carvalho Chehab 				.type = USB_BULK,
1962786baecfSMauro Carvalho Chehab 				.count = 8,
1963786baecfSMauro Carvalho Chehab 				.endpoint = 0x82,
1964786baecfSMauro Carvalho Chehab 				.u = {
1965786baecfSMauro Carvalho Chehab 					.bulk = {
1966786baecfSMauro Carvalho Chehab 						.buffersize = 4096,
1967786baecfSMauro Carvalho Chehab 					}
1968786baecfSMauro Carvalho Chehab 				}
1969786baecfSMauro Carvalho Chehab 			}
1970786baecfSMauro Carvalho Chehab 		}},
1971786baecfSMauro Carvalho Chehab 		}
1972786baecfSMauro Carvalho Chehab 	},
1973*44122dd6SIgor M. Liplianin 	.num_device_descs = 4,
1974786baecfSMauro Carvalho Chehab 	.devices = {
1975786baecfSMauro Carvalho Chehab 		{ "SU3000HD DVB-S USB2.0",
1976786baecfSMauro Carvalho Chehab 			{ &dw2102_table[GENIATECH_SU3000], NULL },
1977786baecfSMauro Carvalho Chehab 			{ NULL },
1978786baecfSMauro Carvalho Chehab 		},
1979786baecfSMauro Carvalho Chehab 		{ "Terratec Cinergy S2 USB HD",
1980786baecfSMauro Carvalho Chehab 			{ &dw2102_table[TERRATEC_CINERGY_S2], NULL },
1981786baecfSMauro Carvalho Chehab 			{ NULL },
1982786baecfSMauro Carvalho Chehab 		},
1983786baecfSMauro Carvalho Chehab 		{ "X3M TV SPC1400HD PCI",
1984786baecfSMauro Carvalho Chehab 			{ &dw2102_table[X3M_SPC1400HD], NULL },
1985786baecfSMauro Carvalho Chehab 			{ NULL },
1986786baecfSMauro Carvalho Chehab 		},
1987*44122dd6SIgor M. Liplianin 		{ "Terratec Cinergy S2 USB HD Rev.2",
1988*44122dd6SIgor M. Liplianin 			{ &dw2102_table[TERRATEC_CINERGY_S2_R2], NULL },
1989*44122dd6SIgor M. Liplianin 			{ NULL },
1990*44122dd6SIgor M. Liplianin 		},
1991786baecfSMauro Carvalho Chehab 	}
1992786baecfSMauro Carvalho Chehab };
1993786baecfSMauro Carvalho Chehab 
1994786baecfSMauro Carvalho Chehab static int dw2102_probe(struct usb_interface *intf,
1995786baecfSMauro Carvalho Chehab 		const struct usb_device_id *id)
1996786baecfSMauro Carvalho Chehab {
1997786baecfSMauro Carvalho Chehab 	p1100 = kmemdup(&s6x0_properties,
1998786baecfSMauro Carvalho Chehab 			sizeof(struct dvb_usb_device_properties), GFP_KERNEL);
1999786baecfSMauro Carvalho Chehab 	if (!p1100)
2000786baecfSMauro Carvalho Chehab 		return -ENOMEM;
2001786baecfSMauro Carvalho Chehab 	/* copy default structure */
2002786baecfSMauro Carvalho Chehab 	/* fill only different fields */
20036823627bSRémi Cardona 	p1100->firmware = P1100_FIRMWARE;
2004786baecfSMauro Carvalho Chehab 	p1100->devices[0] = d1100;
2005786baecfSMauro Carvalho Chehab 	p1100->rc.legacy.rc_map_table = rc_map_tbs_table;
2006786baecfSMauro Carvalho Chehab 	p1100->rc.legacy.rc_map_size = ARRAY_SIZE(rc_map_tbs_table);
2007786baecfSMauro Carvalho Chehab 	p1100->adapter->fe[0].frontend_attach = stv0288_frontend_attach;
2008786baecfSMauro Carvalho Chehab 
2009786baecfSMauro Carvalho Chehab 	s660 = kmemdup(&s6x0_properties,
2010786baecfSMauro Carvalho Chehab 		       sizeof(struct dvb_usb_device_properties), GFP_KERNEL);
2011786baecfSMauro Carvalho Chehab 	if (!s660) {
2012786baecfSMauro Carvalho Chehab 		kfree(p1100);
2013786baecfSMauro Carvalho Chehab 		return -ENOMEM;
2014786baecfSMauro Carvalho Chehab 	}
20156823627bSRémi Cardona 	s660->firmware = S660_FIRMWARE;
2016786baecfSMauro Carvalho Chehab 	s660->num_device_descs = 3;
2017786baecfSMauro Carvalho Chehab 	s660->devices[0] = d660;
2018786baecfSMauro Carvalho Chehab 	s660->devices[1] = d480_1;
2019786baecfSMauro Carvalho Chehab 	s660->devices[2] = d480_2;
2020786baecfSMauro Carvalho Chehab 	s660->adapter->fe[0].frontend_attach = ds3000_frontend_attach;
2021786baecfSMauro Carvalho Chehab 
2022786baecfSMauro Carvalho Chehab 	p7500 = kmemdup(&s6x0_properties,
2023786baecfSMauro Carvalho Chehab 			sizeof(struct dvb_usb_device_properties), GFP_KERNEL);
2024786baecfSMauro Carvalho Chehab 	if (!p7500) {
2025786baecfSMauro Carvalho Chehab 		kfree(p1100);
2026786baecfSMauro Carvalho Chehab 		kfree(s660);
2027786baecfSMauro Carvalho Chehab 		return -ENOMEM;
2028786baecfSMauro Carvalho Chehab 	}
20296823627bSRémi Cardona 	p7500->firmware = P7500_FIRMWARE;
2030786baecfSMauro Carvalho Chehab 	p7500->devices[0] = d7500;
2031786baecfSMauro Carvalho Chehab 	p7500->rc.legacy.rc_map_table = rc_map_tbs_table;
2032786baecfSMauro Carvalho Chehab 	p7500->rc.legacy.rc_map_size = ARRAY_SIZE(rc_map_tbs_table);
2033786baecfSMauro Carvalho Chehab 	p7500->adapter->fe[0].frontend_attach = prof_7500_frontend_attach;
2034786baecfSMauro Carvalho Chehab 
2035955d00acSIgor M. Liplianin 
2036955d00acSIgor M. Liplianin 	s421 = kmemdup(&su3000_properties,
2037955d00acSIgor M. Liplianin 		       sizeof(struct dvb_usb_device_properties), GFP_KERNEL);
2038955d00acSIgor M. Liplianin 	if (!s421) {
2039955d00acSIgor M. Liplianin 		kfree(p1100);
2040955d00acSIgor M. Liplianin 		kfree(s660);
2041955d00acSIgor M. Liplianin 		kfree(p7500);
2042955d00acSIgor M. Liplianin 		return -ENOMEM;
2043955d00acSIgor M. Liplianin 	}
2044955d00acSIgor M. Liplianin 	s421->num_device_descs = 2;
2045955d00acSIgor M. Liplianin 	s421->devices[0] = d421;
2046955d00acSIgor M. Liplianin 	s421->devices[1] = d632;
2047955d00acSIgor M. Liplianin 	s421->adapter->fe[0].frontend_attach = m88rs2000_frontend_attach;
2048955d00acSIgor M. Liplianin 
2049786baecfSMauro Carvalho Chehab 	if (0 == dvb_usb_device_init(intf, &dw2102_properties,
2050786baecfSMauro Carvalho Chehab 			THIS_MODULE, NULL, adapter_nr) ||
2051786baecfSMauro Carvalho Chehab 	    0 == dvb_usb_device_init(intf, &dw2104_properties,
2052786baecfSMauro Carvalho Chehab 			THIS_MODULE, NULL, adapter_nr) ||
2053786baecfSMauro Carvalho Chehab 	    0 == dvb_usb_device_init(intf, &dw3101_properties,
2054786baecfSMauro Carvalho Chehab 			THIS_MODULE, NULL, adapter_nr) ||
2055786baecfSMauro Carvalho Chehab 	    0 == dvb_usb_device_init(intf, &s6x0_properties,
2056786baecfSMauro Carvalho Chehab 			THIS_MODULE, NULL, adapter_nr) ||
2057786baecfSMauro Carvalho Chehab 	    0 == dvb_usb_device_init(intf, p1100,
2058786baecfSMauro Carvalho Chehab 			THIS_MODULE, NULL, adapter_nr) ||
2059786baecfSMauro Carvalho Chehab 	    0 == dvb_usb_device_init(intf, s660,
2060786baecfSMauro Carvalho Chehab 			THIS_MODULE, NULL, adapter_nr) ||
2061786baecfSMauro Carvalho Chehab 	    0 == dvb_usb_device_init(intf, p7500,
2062786baecfSMauro Carvalho Chehab 			THIS_MODULE, NULL, adapter_nr) ||
2063955d00acSIgor M. Liplianin 	    0 == dvb_usb_device_init(intf, s421,
2064955d00acSIgor M. Liplianin 			THIS_MODULE, NULL, adapter_nr) ||
2065786baecfSMauro Carvalho Chehab 	    0 == dvb_usb_device_init(intf, &su3000_properties,
2066786baecfSMauro Carvalho Chehab 				     THIS_MODULE, NULL, adapter_nr))
2067786baecfSMauro Carvalho Chehab 		return 0;
2068786baecfSMauro Carvalho Chehab 
2069786baecfSMauro Carvalho Chehab 	return -ENODEV;
2070786baecfSMauro Carvalho Chehab }
2071786baecfSMauro Carvalho Chehab 
2072786baecfSMauro Carvalho Chehab static struct usb_driver dw2102_driver = {
2073786baecfSMauro Carvalho Chehab 	.name = "dw2102",
2074786baecfSMauro Carvalho Chehab 	.probe = dw2102_probe,
2075786baecfSMauro Carvalho Chehab 	.disconnect = dvb_usb_device_exit,
2076786baecfSMauro Carvalho Chehab 	.id_table = dw2102_table,
2077786baecfSMauro Carvalho Chehab };
2078786baecfSMauro Carvalho Chehab 
2079786baecfSMauro Carvalho Chehab module_usb_driver(dw2102_driver);
2080786baecfSMauro Carvalho Chehab 
2081786baecfSMauro Carvalho Chehab MODULE_AUTHOR("Igor M. Liplianin (c) liplianin@me.by");
2082786baecfSMauro Carvalho Chehab MODULE_DESCRIPTION("Driver for DVBWorld DVB-S 2101, 2102, DVB-S2 2104,"
2083786baecfSMauro Carvalho Chehab 			" DVB-C 3101 USB2.0,"
2084955d00acSIgor M. Liplianin 			" TeVii S600, S630, S650, S660, S480, S421, S632"
2085786baecfSMauro Carvalho Chehab 			" Prof 1100, 7500 USB2.0,"
2086786baecfSMauro Carvalho Chehab 			" Geniatech SU3000 devices");
2087786baecfSMauro Carvalho Chehab MODULE_VERSION("0.1");
2088786baecfSMauro Carvalho Chehab MODULE_LICENSE("GPL");
20896823627bSRémi Cardona MODULE_FIRMWARE(DW2101_FIRMWARE);
20906823627bSRémi Cardona MODULE_FIRMWARE(DW2102_FIRMWARE);
20916823627bSRémi Cardona MODULE_FIRMWARE(DW2104_FIRMWARE);
20926823627bSRémi Cardona MODULE_FIRMWARE(DW3101_FIRMWARE);
20936823627bSRémi Cardona MODULE_FIRMWARE(S630_FIRMWARE);
20946823627bSRémi Cardona MODULE_FIRMWARE(S660_FIRMWARE);
20956823627bSRémi Cardona MODULE_FIRMWARE(P1100_FIRMWARE);
20966823627bSRémi Cardona MODULE_FIRMWARE(P7500_FIRMWARE);
2097