• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* DVB USB compliant linux driver for Conexant USB reference design.
2  *
3  * The Conexant reference design I saw on their website was only for analogue
4  * capturing (using the cx25842). The box I took to write this driver (reverse
5  * engineered) is the one labeled Medion MD95700. In addition to the cx25842
6  * for analogue capturing it also has a cx22702 DVB-T demodulator on the main
7  * board. Besides it has a atiremote (X10) and a USB2.0 hub onboard.
8  *
9  * Maybe it is a little bit premature to call this driver cxusb, but I assume
10  * the USB protocol is identical or at least inherited from the reference
11  * design, so it can be reused for the "analogue-only" device (if it will
12  * appear at all).
13  *
14  * TODO: Use the cx25840-driver for the analogue part
15  *
16  * Copyright (C) 2005 Patrick Boettcher (patrick.boettcher@posteo.de)
17  * Copyright (C) 2006 Michael Krufky (mkrufky@linuxtv.org)
18  * Copyright (C) 2006, 2007 Chris Pascoe (c.pascoe@itee.uq.edu.au)
19  *
20  *   This program is free software; you can redistribute it and/or modify it
21  *   under the terms of the GNU General Public License as published by the Free
22  *   Software Foundation, version 2.
23  *
24  * see Documentation/dvb/README.dvb-usb for more information
25  */
26 #include <media/tuner.h>
27 #include <linux/vmalloc.h>
28 #include <linux/slab.h>
29 
30 #include "cxusb.h"
31 
32 #include "cx22702.h"
33 #include "lgdt330x.h"
34 #include "mt352.h"
35 #include "mt352_priv.h"
36 #include "zl10353.h"
37 #include "tuner-xc2028.h"
38 #include "tuner-simple.h"
39 #include "mxl5005s.h"
40 #include "max2165.h"
41 #include "dib7000p.h"
42 #include "dib0070.h"
43 #include "lgs8gxx.h"
44 #include "atbm8830.h"
45 #include "si2168.h"
46 #include "si2157.h"
47 
48 /* debug */
49 static int dvb_usb_cxusb_debug;
50 module_param_named(debug, dvb_usb_cxusb_debug, int, 0644);
51 MODULE_PARM_DESC(debug, "set debugging level (1=rc (or-able))." DVB_USB_DEBUG_STATUS);
52 
53 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
54 
55 #define deb_info(args...)   dprintk(dvb_usb_cxusb_debug, 0x03, args)
56 #define deb_i2c(args...)    dprintk(dvb_usb_cxusb_debug, 0x02, args)
57 
cxusb_ctrl_msg(struct dvb_usb_device * d,u8 cmd,u8 * wbuf,int wlen,u8 * rbuf,int rlen)58 static int cxusb_ctrl_msg(struct dvb_usb_device *d,
59 			  u8 cmd, u8 *wbuf, int wlen, u8 *rbuf, int rlen)
60 {
61 	struct cxusb_state *st = d->priv;
62 	int ret;
63 
64 	if (1 + wlen > MAX_XFER_SIZE) {
65 		warn("i2c wr: len=%d is too big!\n", wlen);
66 		return -EOPNOTSUPP;
67 	}
68 
69 	if (rlen > MAX_XFER_SIZE) {
70 		warn("i2c rd: len=%d is too big!\n", rlen);
71 		return -EOPNOTSUPP;
72 	}
73 
74 	mutex_lock(&d->data_mutex);
75 	st->data[0] = cmd;
76 	memcpy(&st->data[1], wbuf, wlen);
77 	ret = dvb_usb_generic_rw(d, st->data, 1 + wlen, st->data, rlen, 0);
78 	if (!ret && rbuf && rlen)
79 		memcpy(rbuf, st->data, rlen);
80 
81 	mutex_unlock(&d->data_mutex);
82 	return ret;
83 }
84 
85 /* GPIO */
cxusb_gpio_tuner(struct dvb_usb_device * d,int onoff)86 static void cxusb_gpio_tuner(struct dvb_usb_device *d, int onoff)
87 {
88 	struct cxusb_state *st = d->priv;
89 	u8 o[2], i;
90 
91 	if (st->gpio_write_state[GPIO_TUNER] == onoff)
92 		return;
93 
94 	o[0] = GPIO_TUNER;
95 	o[1] = onoff;
96 	cxusb_ctrl_msg(d, CMD_GPIO_WRITE, o, 2, &i, 1);
97 
98 	if (i != 0x01)
99 		deb_info("gpio_write failed.\n");
100 
101 	st->gpio_write_state[GPIO_TUNER] = onoff;
102 }
103 
cxusb_bluebird_gpio_rw(struct dvb_usb_device * d,u8 changemask,u8 newval)104 static int cxusb_bluebird_gpio_rw(struct dvb_usb_device *d, u8 changemask,
105 				 u8 newval)
106 {
107 	u8 o[2], gpio_state;
108 	int rc;
109 
110 	o[0] = 0xff & ~changemask;	/* mask of bits to keep */
111 	o[1] = newval & changemask;	/* new values for bits  */
112 
113 	rc = cxusb_ctrl_msg(d, CMD_BLUEBIRD_GPIO_RW, o, 2, &gpio_state, 1);
114 	if (rc < 0 || (gpio_state & changemask) != (newval & changemask))
115 		deb_info("bluebird_gpio_write failed.\n");
116 
117 	return rc < 0 ? rc : gpio_state;
118 }
119 
cxusb_bluebird_gpio_pulse(struct dvb_usb_device * d,u8 pin,int low)120 static void cxusb_bluebird_gpio_pulse(struct dvb_usb_device *d, u8 pin, int low)
121 {
122 	cxusb_bluebird_gpio_rw(d, pin, low ? 0 : pin);
123 	msleep(5);
124 	cxusb_bluebird_gpio_rw(d, pin, low ? pin : 0);
125 }
126 
cxusb_nano2_led(struct dvb_usb_device * d,int onoff)127 static void cxusb_nano2_led(struct dvb_usb_device *d, int onoff)
128 {
129 	cxusb_bluebird_gpio_rw(d, 0x40, onoff ? 0 : 0x40);
130 }
131 
cxusb_d680_dmb_gpio_tuner(struct dvb_usb_device * d,u8 addr,int onoff)132 static int cxusb_d680_dmb_gpio_tuner(struct dvb_usb_device *d,
133 		u8 addr, int onoff)
134 {
135 	u8  o[2] = {addr, onoff};
136 	u8  i;
137 	int rc;
138 
139 	rc = cxusb_ctrl_msg(d, CMD_GPIO_WRITE, o, 2, &i, 1);
140 
141 	if (rc < 0)
142 		return rc;
143 	if (i == 0x01)
144 		return 0;
145 	else {
146 		deb_info("gpio_write failed.\n");
147 		return -EIO;
148 	}
149 }
150 
151 /* I2C */
cxusb_i2c_xfer(struct i2c_adapter * adap,struct i2c_msg msg[],int num)152 static int cxusb_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
153 			  int num)
154 {
155 	struct dvb_usb_device *d = i2c_get_adapdata(adap);
156 	int ret;
157 	int i;
158 
159 	if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
160 		return -EAGAIN;
161 
162 	for (i = 0; i < num; i++) {
163 
164 		if (le16_to_cpu(d->udev->descriptor.idVendor) == USB_VID_MEDION)
165 			switch (msg[i].addr) {
166 			case 0x63:
167 				cxusb_gpio_tuner(d, 0);
168 				break;
169 			default:
170 				cxusb_gpio_tuner(d, 1);
171 				break;
172 			}
173 
174 		if (msg[i].flags & I2C_M_RD) {
175 			/* read only */
176 			u8 obuf[3], ibuf[MAX_XFER_SIZE];
177 
178 			if (1 + msg[i].len > sizeof(ibuf)) {
179 				warn("i2c rd: len=%d is too big!\n",
180 				     msg[i].len);
181 				ret = -EOPNOTSUPP;
182 				goto unlock;
183 			}
184 			obuf[0] = 0;
185 			obuf[1] = msg[i].len;
186 			obuf[2] = msg[i].addr;
187 			if (cxusb_ctrl_msg(d, CMD_I2C_READ,
188 					   obuf, 3,
189 					   ibuf, 1+msg[i].len) < 0) {
190 				warn("i2c read failed");
191 				break;
192 			}
193 			memcpy(msg[i].buf, &ibuf[1], msg[i].len);
194 		} else if (i+1 < num && (msg[i+1].flags & I2C_M_RD) &&
195 			   msg[i].addr == msg[i+1].addr) {
196 			/* write to then read from same address */
197 			u8 obuf[MAX_XFER_SIZE], ibuf[MAX_XFER_SIZE];
198 
199 			if (3 + msg[i].len > sizeof(obuf)) {
200 				warn("i2c wr: len=%d is too big!\n",
201 				     msg[i].len);
202 				ret = -EOPNOTSUPP;
203 				goto unlock;
204 			}
205 			if (1 + msg[i + 1].len > sizeof(ibuf)) {
206 				warn("i2c rd: len=%d is too big!\n",
207 				     msg[i + 1].len);
208 				ret = -EOPNOTSUPP;
209 				goto unlock;
210 			}
211 			obuf[0] = msg[i].len;
212 			obuf[1] = msg[i+1].len;
213 			obuf[2] = msg[i].addr;
214 			memcpy(&obuf[3], msg[i].buf, msg[i].len);
215 
216 			if (cxusb_ctrl_msg(d, CMD_I2C_READ,
217 					   obuf, 3+msg[i].len,
218 					   ibuf, 1+msg[i+1].len) < 0)
219 				break;
220 
221 			if (ibuf[0] != 0x08)
222 				deb_i2c("i2c read may have failed\n");
223 
224 			memcpy(msg[i+1].buf, &ibuf[1], msg[i+1].len);
225 
226 			i++;
227 		} else {
228 			/* write only */
229 			u8 obuf[MAX_XFER_SIZE], ibuf;
230 
231 			if (2 + msg[i].len > sizeof(obuf)) {
232 				warn("i2c wr: len=%d is too big!\n",
233 				     msg[i].len);
234 				ret = -EOPNOTSUPP;
235 				goto unlock;
236 			}
237 			obuf[0] = msg[i].addr;
238 			obuf[1] = msg[i].len;
239 			memcpy(&obuf[2], msg[i].buf, msg[i].len);
240 
241 			if (cxusb_ctrl_msg(d, CMD_I2C_WRITE, obuf,
242 					   2+msg[i].len, &ibuf,1) < 0)
243 				break;
244 			if (ibuf != 0x08)
245 				deb_i2c("i2c write may have failed\n");
246 		}
247 	}
248 
249 	if (i == num)
250 		ret = num;
251 	else
252 		ret = -EREMOTEIO;
253 
254 unlock:
255 	mutex_unlock(&d->i2c_mutex);
256 	return ret;
257 }
258 
cxusb_i2c_func(struct i2c_adapter * adapter)259 static u32 cxusb_i2c_func(struct i2c_adapter *adapter)
260 {
261 	return I2C_FUNC_I2C;
262 }
263 
264 static struct i2c_algorithm cxusb_i2c_algo = {
265 	.master_xfer   = cxusb_i2c_xfer,
266 	.functionality = cxusb_i2c_func,
267 };
268 
cxusb_power_ctrl(struct dvb_usb_device * d,int onoff)269 static int cxusb_power_ctrl(struct dvb_usb_device *d, int onoff)
270 {
271 	u8 b = 0;
272 	if (onoff)
273 		return cxusb_ctrl_msg(d, CMD_POWER_ON, &b, 1, NULL, 0);
274 	else
275 		return cxusb_ctrl_msg(d, CMD_POWER_OFF, &b, 1, NULL, 0);
276 }
277 
cxusb_aver_power_ctrl(struct dvb_usb_device * d,int onoff)278 static int cxusb_aver_power_ctrl(struct dvb_usb_device *d, int onoff)
279 {
280 	int ret;
281 	if (!onoff)
282 		return cxusb_ctrl_msg(d, CMD_POWER_OFF, NULL, 0, NULL, 0);
283 	if (d->state == DVB_USB_STATE_INIT &&
284 	    usb_set_interface(d->udev, 0, 0) < 0)
285 		err("set interface failed");
286 	do {} while (!(ret = cxusb_ctrl_msg(d, CMD_POWER_ON, NULL, 0, NULL, 0)) &&
287 		   !(ret = cxusb_ctrl_msg(d, 0x15, NULL, 0, NULL, 0)) &&
288 		   !(ret = cxusb_ctrl_msg(d, 0x17, NULL, 0, NULL, 0)) && 0);
289 	if (!ret) {
290 		/* FIXME: We don't know why, but we need to configure the
291 		 * lgdt3303 with the register settings below on resume */
292 		int i;
293 		u8 buf, bufs[] = {
294 			0x0e, 0x2, 0x00, 0x7f,
295 			0x0e, 0x2, 0x02, 0xfe,
296 			0x0e, 0x2, 0x02, 0x01,
297 			0x0e, 0x2, 0x00, 0x03,
298 			0x0e, 0x2, 0x0d, 0x40,
299 			0x0e, 0x2, 0x0e, 0x87,
300 			0x0e, 0x2, 0x0f, 0x8e,
301 			0x0e, 0x2, 0x10, 0x01,
302 			0x0e, 0x2, 0x14, 0xd7,
303 			0x0e, 0x2, 0x47, 0x88,
304 		};
305 		msleep(20);
306 		for (i = 0; i < sizeof(bufs)/sizeof(u8); i += 4/sizeof(u8)) {
307 			ret = cxusb_ctrl_msg(d, CMD_I2C_WRITE,
308 					     bufs+i, 4, &buf, 1);
309 			if (ret)
310 				break;
311 			if (buf != 0x8)
312 				return -EREMOTEIO;
313 		}
314 	}
315 	return ret;
316 }
317 
cxusb_bluebird_power_ctrl(struct dvb_usb_device * d,int onoff)318 static int cxusb_bluebird_power_ctrl(struct dvb_usb_device *d, int onoff)
319 {
320 	u8 b = 0;
321 	if (onoff)
322 		return cxusb_ctrl_msg(d, CMD_POWER_ON, &b, 1, NULL, 0);
323 	else
324 		return 0;
325 }
326 
cxusb_nano2_power_ctrl(struct dvb_usb_device * d,int onoff)327 static int cxusb_nano2_power_ctrl(struct dvb_usb_device *d, int onoff)
328 {
329 	int rc = 0;
330 
331 	rc = cxusb_power_ctrl(d, onoff);
332 	if (!onoff)
333 		cxusb_nano2_led(d, 0);
334 
335 	return rc;
336 }
337 
cxusb_d680_dmb_power_ctrl(struct dvb_usb_device * d,int onoff)338 static int cxusb_d680_dmb_power_ctrl(struct dvb_usb_device *d, int onoff)
339 {
340 	int ret;
341 	u8  b;
342 	ret = cxusb_power_ctrl(d, onoff);
343 	if (!onoff)
344 		return ret;
345 
346 	msleep(128);
347 	cxusb_ctrl_msg(d, CMD_DIGITAL, NULL, 0, &b, 1);
348 	msleep(100);
349 	return ret;
350 }
351 
cxusb_streaming_ctrl(struct dvb_usb_adapter * adap,int onoff)352 static int cxusb_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
353 {
354 	u8 buf[2] = { 0x03, 0x00 };
355 	if (onoff)
356 		cxusb_ctrl_msg(adap->dev, CMD_STREAMING_ON, buf, 2, NULL, 0);
357 	else
358 		cxusb_ctrl_msg(adap->dev, CMD_STREAMING_OFF, NULL, 0, NULL, 0);
359 
360 	return 0;
361 }
362 
cxusb_aver_streaming_ctrl(struct dvb_usb_adapter * adap,int onoff)363 static int cxusb_aver_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
364 {
365 	if (onoff)
366 		cxusb_ctrl_msg(adap->dev, CMD_AVER_STREAM_ON, NULL, 0, NULL, 0);
367 	else
368 		cxusb_ctrl_msg(adap->dev, CMD_AVER_STREAM_OFF,
369 			       NULL, 0, NULL, 0);
370 	return 0;
371 }
372 
cxusb_read_status(struct dvb_frontend * fe,enum fe_status * status)373 static int cxusb_read_status(struct dvb_frontend *fe,
374 				  enum fe_status *status)
375 {
376 	struct dvb_usb_adapter *adap = (struct dvb_usb_adapter *)fe->dvb->priv;
377 	struct cxusb_state *state = (struct cxusb_state *)adap->dev->priv;
378 	int ret;
379 
380 	ret = state->fe_read_status(fe, status);
381 
382 	/* it need resync slave fifo when signal change from unlock to lock.*/
383 	if ((*status & FE_HAS_LOCK) && (!state->last_lock)) {
384 		mutex_lock(&state->stream_mutex);
385 		cxusb_streaming_ctrl(adap, 1);
386 		mutex_unlock(&state->stream_mutex);
387 	}
388 
389 	state->last_lock = (*status & FE_HAS_LOCK) ? 1 : 0;
390 	return ret;
391 }
392 
cxusb_d680_dmb_drain_message(struct dvb_usb_device * d)393 static void cxusb_d680_dmb_drain_message(struct dvb_usb_device *d)
394 {
395 	int       ep = d->props.generic_bulk_ctrl_endpoint;
396 	const int timeout = 100;
397 	const int junk_len = 32;
398 	u8        *junk;
399 	int       rd_count;
400 
401 	/* Discard remaining data in video pipe */
402 	junk = kmalloc(junk_len, GFP_KERNEL);
403 	if (!junk)
404 		return;
405 	while (1) {
406 		if (usb_bulk_msg(d->udev,
407 			usb_rcvbulkpipe(d->udev, ep),
408 			junk, junk_len, &rd_count, timeout) < 0)
409 			break;
410 		if (!rd_count)
411 			break;
412 	}
413 	kfree(junk);
414 }
415 
cxusb_d680_dmb_drain_video(struct dvb_usb_device * d)416 static void cxusb_d680_dmb_drain_video(struct dvb_usb_device *d)
417 {
418 	struct usb_data_stream_properties *p = &d->props.adapter[0].fe[0].stream;
419 	const int timeout = 100;
420 	const int junk_len = p->u.bulk.buffersize;
421 	u8        *junk;
422 	int       rd_count;
423 
424 	/* Discard remaining data in video pipe */
425 	junk = kmalloc(junk_len, GFP_KERNEL);
426 	if (!junk)
427 		return;
428 	while (1) {
429 		if (usb_bulk_msg(d->udev,
430 			usb_rcvbulkpipe(d->udev, p->endpoint),
431 			junk, junk_len, &rd_count, timeout) < 0)
432 			break;
433 		if (!rd_count)
434 			break;
435 	}
436 	kfree(junk);
437 }
438 
cxusb_d680_dmb_streaming_ctrl(struct dvb_usb_adapter * adap,int onoff)439 static int cxusb_d680_dmb_streaming_ctrl(
440 		struct dvb_usb_adapter *adap, int onoff)
441 {
442 	if (onoff) {
443 		u8 buf[2] = { 0x03, 0x00 };
444 		cxusb_d680_dmb_drain_video(adap->dev);
445 		return cxusb_ctrl_msg(adap->dev, CMD_STREAMING_ON,
446 			buf, sizeof(buf), NULL, 0);
447 	} else {
448 		int ret = cxusb_ctrl_msg(adap->dev,
449 			CMD_STREAMING_OFF, NULL, 0, NULL, 0);
450 		return ret;
451 	}
452 }
453 
cxusb_rc_query(struct dvb_usb_device * d)454 static int cxusb_rc_query(struct dvb_usb_device *d)
455 {
456 	u8 ircode[4];
457 
458 	if (cxusb_ctrl_msg(d, CMD_GET_IR_CODE, NULL, 0, ircode, 4) < 0)
459 		return 0;
460 
461 	if (ircode[2] || ircode[3])
462 		rc_keydown(d->rc_dev, RC_PROTO_NEC,
463 			   RC_SCANCODE_NEC(~ircode[2] & 0xff, ircode[3]), 0);
464 	return 0;
465 }
466 
cxusb_bluebird2_rc_query(struct dvb_usb_device * d)467 static int cxusb_bluebird2_rc_query(struct dvb_usb_device *d)
468 {
469 	u8 ircode[4];
470 	struct i2c_msg msg = { .addr = 0x6b, .flags = I2C_M_RD,
471 			       .buf = ircode, .len = 4 };
472 
473 	if (cxusb_i2c_xfer(&d->i2c_adap, &msg, 1) != 1)
474 		return 0;
475 
476 	if (ircode[1] || ircode[2])
477 		rc_keydown(d->rc_dev, RC_PROTO_NEC,
478 			   RC_SCANCODE_NEC(~ircode[1] & 0xff, ircode[2]), 0);
479 	return 0;
480 }
481 
cxusb_d680_dmb_rc_query(struct dvb_usb_device * d)482 static int cxusb_d680_dmb_rc_query(struct dvb_usb_device *d)
483 {
484 	u8 ircode[2];
485 
486 	if (cxusb_ctrl_msg(d, 0x10, NULL, 0, ircode, 2) < 0)
487 		return 0;
488 
489 	if (ircode[0] || ircode[1])
490 		rc_keydown(d->rc_dev, RC_PROTO_UNKNOWN,
491 			   RC_SCANCODE_RC5(ircode[0], ircode[1]), 0);
492 	return 0;
493 }
494 
cxusb_dee1601_demod_init(struct dvb_frontend * fe)495 static int cxusb_dee1601_demod_init(struct dvb_frontend* fe)
496 {
497 	static u8 clock_config []  = { CLOCK_CTL,  0x38, 0x28 };
498 	static u8 reset []         = { RESET,      0x80 };
499 	static u8 adc_ctl_1_cfg [] = { ADC_CTL_1,  0x40 };
500 	static u8 agc_cfg []       = { AGC_TARGET, 0x28, 0x20 };
501 	static u8 gpp_ctl_cfg []   = { GPP_CTL,    0x33 };
502 	static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
503 
504 	mt352_write(fe, clock_config,   sizeof(clock_config));
505 	udelay(200);
506 	mt352_write(fe, reset,          sizeof(reset));
507 	mt352_write(fe, adc_ctl_1_cfg,  sizeof(adc_ctl_1_cfg));
508 
509 	mt352_write(fe, agc_cfg,        sizeof(agc_cfg));
510 	mt352_write(fe, gpp_ctl_cfg,    sizeof(gpp_ctl_cfg));
511 	mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
512 
513 	return 0;
514 }
515 
cxusb_mt352_demod_init(struct dvb_frontend * fe)516 static int cxusb_mt352_demod_init(struct dvb_frontend* fe)
517 {	/* used in both lgz201 and th7579 */
518 	static u8 clock_config []  = { CLOCK_CTL,  0x38, 0x29 };
519 	static u8 reset []         = { RESET,      0x80 };
520 	static u8 adc_ctl_1_cfg [] = { ADC_CTL_1,  0x40 };
521 	static u8 agc_cfg []       = { AGC_TARGET, 0x24, 0x20 };
522 	static u8 gpp_ctl_cfg []   = { GPP_CTL,    0x33 };
523 	static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
524 
525 	mt352_write(fe, clock_config,   sizeof(clock_config));
526 	udelay(200);
527 	mt352_write(fe, reset,          sizeof(reset));
528 	mt352_write(fe, adc_ctl_1_cfg,  sizeof(adc_ctl_1_cfg));
529 
530 	mt352_write(fe, agc_cfg,        sizeof(agc_cfg));
531 	mt352_write(fe, gpp_ctl_cfg,    sizeof(gpp_ctl_cfg));
532 	mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
533 	return 0;
534 }
535 
536 static struct cx22702_config cxusb_cx22702_config = {
537 	.demod_address = 0x63,
538 	.output_mode = CX22702_PARALLEL_OUTPUT,
539 };
540 
541 static struct lgdt330x_config cxusb_lgdt3303_config = {
542 	.demod_address = 0x0e,
543 	.demod_chip    = LGDT3303,
544 };
545 
546 static struct lgdt330x_config cxusb_aver_lgdt3303_config = {
547 	.demod_address       = 0x0e,
548 	.demod_chip          = LGDT3303,
549 	.clock_polarity_flip = 2,
550 };
551 
552 static struct mt352_config cxusb_dee1601_config = {
553 	.demod_address = 0x0f,
554 	.demod_init    = cxusb_dee1601_demod_init,
555 };
556 
557 static struct zl10353_config cxusb_zl10353_dee1601_config = {
558 	.demod_address = 0x0f,
559 	.parallel_ts = 1,
560 };
561 
562 static struct mt352_config cxusb_mt352_config = {
563 	/* used in both lgz201 and th7579 */
564 	.demod_address = 0x0f,
565 	.demod_init    = cxusb_mt352_demod_init,
566 };
567 
568 static struct zl10353_config cxusb_zl10353_xc3028_config = {
569 	.demod_address = 0x0f,
570 	.if2 = 45600,
571 	.no_tuner = 1,
572 	.parallel_ts = 1,
573 };
574 
575 static struct zl10353_config cxusb_zl10353_xc3028_config_no_i2c_gate = {
576 	.demod_address = 0x0f,
577 	.if2 = 45600,
578 	.no_tuner = 1,
579 	.parallel_ts = 1,
580 	.disable_i2c_gate_ctrl = 1,
581 };
582 
583 static struct mt352_config cxusb_mt352_xc3028_config = {
584 	.demod_address = 0x0f,
585 	.if2 = 4560,
586 	.no_tuner = 1,
587 	.demod_init = cxusb_mt352_demod_init,
588 };
589 
590 /* FIXME: needs tweaking */
591 static struct mxl5005s_config aver_a868r_tuner = {
592 	.i2c_address     = 0x63,
593 	.if_freq         = 6000000UL,
594 	.xtal_freq       = CRYSTAL_FREQ_16000000HZ,
595 	.agc_mode        = MXL_SINGLE_AGC,
596 	.tracking_filter = MXL_TF_C,
597 	.rssi_enable     = MXL_RSSI_ENABLE,
598 	.cap_select      = MXL_CAP_SEL_ENABLE,
599 	.div_out         = MXL_DIV_OUT_4,
600 	.clock_out       = MXL_CLOCK_OUT_DISABLE,
601 	.output_load     = MXL5005S_IF_OUTPUT_LOAD_200_OHM,
602 	.top		 = MXL5005S_TOP_25P2,
603 	.mod_mode        = MXL_DIGITAL_MODE,
604 	.if_mode         = MXL_ZERO_IF,
605 	.AgcMasterByte   = 0x00,
606 };
607 
608 /* FIXME: needs tweaking */
609 static struct mxl5005s_config d680_dmb_tuner = {
610 	.i2c_address     = 0x63,
611 	.if_freq         = 36125000UL,
612 	.xtal_freq       = CRYSTAL_FREQ_16000000HZ,
613 	.agc_mode        = MXL_SINGLE_AGC,
614 	.tracking_filter = MXL_TF_C,
615 	.rssi_enable     = MXL_RSSI_ENABLE,
616 	.cap_select      = MXL_CAP_SEL_ENABLE,
617 	.div_out         = MXL_DIV_OUT_4,
618 	.clock_out       = MXL_CLOCK_OUT_DISABLE,
619 	.output_load     = MXL5005S_IF_OUTPUT_LOAD_200_OHM,
620 	.top		 = MXL5005S_TOP_25P2,
621 	.mod_mode        = MXL_DIGITAL_MODE,
622 	.if_mode         = MXL_ZERO_IF,
623 	.AgcMasterByte   = 0x00,
624 };
625 
626 static struct max2165_config mygica_d689_max2165_cfg = {
627 	.i2c_address = 0x60,
628 	.osc_clk = 20
629 };
630 
631 /* Callbacks for DVB USB */
cxusb_fmd1216me_tuner_attach(struct dvb_usb_adapter * adap)632 static int cxusb_fmd1216me_tuner_attach(struct dvb_usb_adapter *adap)
633 {
634 	dvb_attach(simple_tuner_attach, adap->fe_adap[0].fe,
635 		   &adap->dev->i2c_adap, 0x61,
636 		   TUNER_PHILIPS_FMD1216ME_MK3);
637 	return 0;
638 }
639 
cxusb_dee1601_tuner_attach(struct dvb_usb_adapter * adap)640 static int cxusb_dee1601_tuner_attach(struct dvb_usb_adapter *adap)
641 {
642 	dvb_attach(dvb_pll_attach, adap->fe_adap[0].fe, 0x61,
643 		   NULL, DVB_PLL_THOMSON_DTT7579);
644 	return 0;
645 }
646 
cxusb_lgz201_tuner_attach(struct dvb_usb_adapter * adap)647 static int cxusb_lgz201_tuner_attach(struct dvb_usb_adapter *adap)
648 {
649 	dvb_attach(dvb_pll_attach, adap->fe_adap[0].fe, 0x61, NULL, DVB_PLL_LG_Z201);
650 	return 0;
651 }
652 
cxusb_dtt7579_tuner_attach(struct dvb_usb_adapter * adap)653 static int cxusb_dtt7579_tuner_attach(struct dvb_usb_adapter *adap)
654 {
655 	dvb_attach(dvb_pll_attach, adap->fe_adap[0].fe, 0x60,
656 		   NULL, DVB_PLL_THOMSON_DTT7579);
657 	return 0;
658 }
659 
cxusb_lgh064f_tuner_attach(struct dvb_usb_adapter * adap)660 static int cxusb_lgh064f_tuner_attach(struct dvb_usb_adapter *adap)
661 {
662 	dvb_attach(simple_tuner_attach, adap->fe_adap[0].fe,
663 		   &adap->dev->i2c_adap, 0x61, TUNER_LG_TDVS_H06XF);
664 	return 0;
665 }
666 
dvico_bluebird_xc2028_callback(void * ptr,int component,int command,int arg)667 static int dvico_bluebird_xc2028_callback(void *ptr, int component,
668 					  int command, int arg)
669 {
670 	struct dvb_usb_adapter *adap = ptr;
671 	struct dvb_usb_device *d = adap->dev;
672 
673 	switch (command) {
674 	case XC2028_TUNER_RESET:
675 		deb_info("%s: XC2028_TUNER_RESET %d\n", __func__, arg);
676 		cxusb_bluebird_gpio_pulse(d, 0x01, 1);
677 		break;
678 	case XC2028_RESET_CLK:
679 		deb_info("%s: XC2028_RESET_CLK %d\n", __func__, arg);
680 		break;
681 	case XC2028_I2C_FLUSH:
682 		break;
683 	default:
684 		deb_info("%s: unknown command %d, arg %d\n", __func__,
685 			 command, arg);
686 		return -EINVAL;
687 	}
688 
689 	return 0;
690 }
691 
cxusb_dvico_xc3028_tuner_attach(struct dvb_usb_adapter * adap)692 static int cxusb_dvico_xc3028_tuner_attach(struct dvb_usb_adapter *adap)
693 {
694 	struct dvb_frontend	 *fe;
695 	struct xc2028_config	  cfg = {
696 		.i2c_adap  = &adap->dev->i2c_adap,
697 		.i2c_addr  = 0x61,
698 	};
699 	static struct xc2028_ctrl ctl = {
700 		.fname       = XC2028_DEFAULT_FIRMWARE,
701 		.max_len     = 64,
702 		.demod       = XC3028_FE_ZARLINK456,
703 	};
704 
705 	/* FIXME: generalize & move to common area */
706 	adap->fe_adap[0].fe->callback = dvico_bluebird_xc2028_callback;
707 
708 	fe = dvb_attach(xc2028_attach, adap->fe_adap[0].fe, &cfg);
709 	if (fe == NULL || fe->ops.tuner_ops.set_config == NULL)
710 		return -EIO;
711 
712 	fe->ops.tuner_ops.set_config(fe, &ctl);
713 
714 	return 0;
715 }
716 
cxusb_mxl5003s_tuner_attach(struct dvb_usb_adapter * adap)717 static int cxusb_mxl5003s_tuner_attach(struct dvb_usb_adapter *adap)
718 {
719 	dvb_attach(mxl5005s_attach, adap->fe_adap[0].fe,
720 		   &adap->dev->i2c_adap, &aver_a868r_tuner);
721 	return 0;
722 }
723 
cxusb_d680_dmb_tuner_attach(struct dvb_usb_adapter * adap)724 static int cxusb_d680_dmb_tuner_attach(struct dvb_usb_adapter *adap)
725 {
726 	struct dvb_frontend *fe;
727 	fe = dvb_attach(mxl5005s_attach, adap->fe_adap[0].fe,
728 			&adap->dev->i2c_adap, &d680_dmb_tuner);
729 	return (fe == NULL) ? -EIO : 0;
730 }
731 
cxusb_mygica_d689_tuner_attach(struct dvb_usb_adapter * adap)732 static int cxusb_mygica_d689_tuner_attach(struct dvb_usb_adapter *adap)
733 {
734 	struct dvb_frontend *fe;
735 	fe = dvb_attach(max2165_attach, adap->fe_adap[0].fe,
736 			&adap->dev->i2c_adap, &mygica_d689_max2165_cfg);
737 	return (fe == NULL) ? -EIO : 0;
738 }
739 
cxusb_cx22702_frontend_attach(struct dvb_usb_adapter * adap)740 static int cxusb_cx22702_frontend_attach(struct dvb_usb_adapter *adap)
741 {
742 	u8 b;
743 	if (usb_set_interface(adap->dev->udev, 0, 6) < 0)
744 		err("set interface failed");
745 
746 	cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, &b, 1);
747 
748 	adap->fe_adap[0].fe = dvb_attach(cx22702_attach, &cxusb_cx22702_config,
749 					 &adap->dev->i2c_adap);
750 	if ((adap->fe_adap[0].fe) != NULL)
751 		return 0;
752 
753 	return -EIO;
754 }
755 
cxusb_lgdt3303_frontend_attach(struct dvb_usb_adapter * adap)756 static int cxusb_lgdt3303_frontend_attach(struct dvb_usb_adapter *adap)
757 {
758 	if (usb_set_interface(adap->dev->udev, 0, 7) < 0)
759 		err("set interface failed");
760 
761 	cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
762 
763 	adap->fe_adap[0].fe = dvb_attach(lgdt330x_attach,
764 					 &cxusb_lgdt3303_config,
765 					 &adap->dev->i2c_adap);
766 	if ((adap->fe_adap[0].fe) != NULL)
767 		return 0;
768 
769 	return -EIO;
770 }
771 
cxusb_aver_lgdt3303_frontend_attach(struct dvb_usb_adapter * adap)772 static int cxusb_aver_lgdt3303_frontend_attach(struct dvb_usb_adapter *adap)
773 {
774 	adap->fe_adap[0].fe = dvb_attach(lgdt330x_attach, &cxusb_aver_lgdt3303_config,
775 			      &adap->dev->i2c_adap);
776 	if (adap->fe_adap[0].fe != NULL)
777 		return 0;
778 
779 	return -EIO;
780 }
781 
cxusb_mt352_frontend_attach(struct dvb_usb_adapter * adap)782 static int cxusb_mt352_frontend_attach(struct dvb_usb_adapter *adap)
783 {
784 	/* used in both lgz201 and th7579 */
785 	if (usb_set_interface(adap->dev->udev, 0, 0) < 0)
786 		err("set interface failed");
787 
788 	cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
789 
790 	adap->fe_adap[0].fe = dvb_attach(mt352_attach, &cxusb_mt352_config,
791 					 &adap->dev->i2c_adap);
792 	if ((adap->fe_adap[0].fe) != NULL)
793 		return 0;
794 
795 	return -EIO;
796 }
797 
cxusb_dee1601_frontend_attach(struct dvb_usb_adapter * adap)798 static int cxusb_dee1601_frontend_attach(struct dvb_usb_adapter *adap)
799 {
800 	if (usb_set_interface(adap->dev->udev, 0, 0) < 0)
801 		err("set interface failed");
802 
803 	cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
804 
805 	adap->fe_adap[0].fe = dvb_attach(mt352_attach, &cxusb_dee1601_config,
806 					 &adap->dev->i2c_adap);
807 	if ((adap->fe_adap[0].fe) != NULL)
808 		return 0;
809 
810 	adap->fe_adap[0].fe = dvb_attach(zl10353_attach,
811 					 &cxusb_zl10353_dee1601_config,
812 					 &adap->dev->i2c_adap);
813 	if ((adap->fe_adap[0].fe) != NULL)
814 		return 0;
815 
816 	return -EIO;
817 }
818 
cxusb_dualdig4_frontend_attach(struct dvb_usb_adapter * adap)819 static int cxusb_dualdig4_frontend_attach(struct dvb_usb_adapter *adap)
820 {
821 	u8 ircode[4];
822 	int i;
823 	struct i2c_msg msg = { .addr = 0x6b, .flags = I2C_M_RD,
824 			       .buf = ircode, .len = 4 };
825 
826 	if (usb_set_interface(adap->dev->udev, 0, 1) < 0)
827 		err("set interface failed");
828 
829 	cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
830 
831 	/* reset the tuner and demodulator */
832 	cxusb_bluebird_gpio_rw(adap->dev, 0x04, 0);
833 	cxusb_bluebird_gpio_pulse(adap->dev, 0x01, 1);
834 	cxusb_bluebird_gpio_pulse(adap->dev, 0x02, 1);
835 
836 	adap->fe_adap[0].fe =
837 		dvb_attach(zl10353_attach,
838 			   &cxusb_zl10353_xc3028_config_no_i2c_gate,
839 			   &adap->dev->i2c_adap);
840 	if ((adap->fe_adap[0].fe) == NULL)
841 		return -EIO;
842 
843 	/* try to determine if there is no IR decoder on the I2C bus */
844 	for (i = 0; adap->dev->props.rc.core.rc_codes && i < 5; i++) {
845 		msleep(20);
846 		if (cxusb_i2c_xfer(&adap->dev->i2c_adap, &msg, 1) != 1)
847 			goto no_IR;
848 		if (ircode[0] == 0 && ircode[1] == 0)
849 			continue;
850 		if (ircode[2] + ircode[3] != 0xff) {
851 no_IR:
852 			adap->dev->props.rc.core.rc_codes = NULL;
853 			info("No IR receiver detected on this device.");
854 			break;
855 		}
856 	}
857 
858 	return 0;
859 }
860 
861 static struct dibx000_agc_config dib7070_agc_config = {
862 	.band_caps = BAND_UHF | BAND_VHF | BAND_LBAND | BAND_SBAND,
863 
864 	/*
865 	 * P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=5,
866 	 * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
867 	 * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5, P_agc_write=0
868 	 */
869 	.setup = (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) |
870 		 (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),
871 	.inv_gain = 600,
872 	.time_stabiliz = 10,
873 	.alpha_level = 0,
874 	.thlock = 118,
875 	.wbd_inv = 0,
876 	.wbd_ref = 3530,
877 	.wbd_sel = 1,
878 	.wbd_alpha = 5,
879 	.agc1_max = 65535,
880 	.agc1_min = 0,
881 	.agc2_max = 65535,
882 	.agc2_min = 0,
883 	.agc1_pt1 = 0,
884 	.agc1_pt2 = 40,
885 	.agc1_pt3 = 183,
886 	.agc1_slope1 = 206,
887 	.agc1_slope2 = 255,
888 	.agc2_pt1 = 72,
889 	.agc2_pt2 = 152,
890 	.agc2_slope1 = 88,
891 	.agc2_slope2 = 90,
892 	.alpha_mant = 17,
893 	.alpha_exp = 27,
894 	.beta_mant = 23,
895 	.beta_exp = 51,
896 	.perform_agc_softsplit = 0,
897 };
898 
899 static struct dibx000_bandwidth_config dib7070_bw_config_12_mhz = {
900 	.internal = 60000,
901 	.sampling = 15000,
902 	.pll_prediv = 1,
903 	.pll_ratio = 20,
904 	.pll_range = 3,
905 	.pll_reset = 1,
906 	.pll_bypass = 0,
907 	.enable_refdiv = 0,
908 	.bypclk_div = 0,
909 	.IO_CLK_en_core = 1,
910 	.ADClkSrc = 1,
911 	.modulo = 2,
912 	/* refsel, sel, freq_15k */
913 	.sad_cfg = (3 << 14) | (1 << 12) | (524 << 0),
914 	.ifreq = (0 << 25) | 0,
915 	.timf = 20452225,
916 	.xtal_hz = 12000000,
917 };
918 
919 static struct dib7000p_config cxusb_dualdig4_rev2_config = {
920 	.output_mode = OUTMODE_MPEG2_PAR_GATED_CLK,
921 	.output_mpeg2_in_188_bytes = 1,
922 
923 	.agc_config_count = 1,
924 	.agc = &dib7070_agc_config,
925 	.bw  = &dib7070_bw_config_12_mhz,
926 	.tuner_is_baseband = 1,
927 	.spur_protect = 1,
928 
929 	.gpio_dir = 0xfcef,
930 	.gpio_val = 0x0110,
931 
932 	.gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
933 
934 	.hostbus_diversity = 1,
935 };
936 
937 struct dib0700_adapter_state {
938 	int (*set_param_save)(struct dvb_frontend *);
939 	struct dib7000p_ops dib7000p_ops;
940 };
941 
cxusb_dualdig4_rev2_frontend_attach(struct dvb_usb_adapter * adap)942 static int cxusb_dualdig4_rev2_frontend_attach(struct dvb_usb_adapter *adap)
943 {
944 	struct dib0700_adapter_state *state = adap->priv;
945 
946 	if (usb_set_interface(adap->dev->udev, 0, 1) < 0)
947 		err("set interface failed");
948 
949 	cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
950 
951 	cxusb_bluebird_gpio_pulse(adap->dev, 0x02, 1);
952 
953 	if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
954 		return -ENODEV;
955 
956 	if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 18,
957 				       &cxusb_dualdig4_rev2_config) < 0) {
958 		printk(KERN_WARNING "Unable to enumerate dib7000p\n");
959 		return -ENODEV;
960 	}
961 
962 	adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap, 0x80,
963 					      &cxusb_dualdig4_rev2_config);
964 	if (adap->fe_adap[0].fe == NULL)
965 		return -EIO;
966 
967 	return 0;
968 }
969 
dib7070_tuner_reset(struct dvb_frontend * fe,int onoff)970 static int dib7070_tuner_reset(struct dvb_frontend *fe, int onoff)
971 {
972 	struct dvb_usb_adapter *adap = fe->dvb->priv;
973 	struct dib0700_adapter_state *state = adap->priv;
974 
975 	return state->dib7000p_ops.set_gpio(fe, 8, 0, !onoff);
976 }
977 
dib7070_tuner_sleep(struct dvb_frontend * fe,int onoff)978 static int dib7070_tuner_sleep(struct dvb_frontend *fe, int onoff)
979 {
980 	return 0;
981 }
982 
983 static struct dib0070_config dib7070p_dib0070_config = {
984 	.i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
985 	.reset = dib7070_tuner_reset,
986 	.sleep = dib7070_tuner_sleep,
987 	.clock_khz = 12000,
988 };
989 
dib7070_set_param_override(struct dvb_frontend * fe)990 static int dib7070_set_param_override(struct dvb_frontend *fe)
991 {
992 	struct dtv_frontend_properties *p = &fe->dtv_property_cache;
993 	struct dvb_usb_adapter *adap = fe->dvb->priv;
994 	struct dib0700_adapter_state *state = adap->priv;
995 
996 	u16 offset;
997 	u8 band = BAND_OF_FREQUENCY(p->frequency/1000);
998 	switch (band) {
999 	case BAND_VHF: offset = 950; break;
1000 	default:
1001 	case BAND_UHF: offset = 550; break;
1002 	}
1003 
1004 	state->dib7000p_ops.set_wbd_ref(fe, offset + dib0070_wbd_offset(fe));
1005 
1006 	return state->set_param_save(fe);
1007 }
1008 
cxusb_dualdig4_rev2_tuner_attach(struct dvb_usb_adapter * adap)1009 static int cxusb_dualdig4_rev2_tuner_attach(struct dvb_usb_adapter *adap)
1010 {
1011 	struct dib0700_adapter_state *st = adap->priv;
1012 	struct i2c_adapter *tun_i2c;
1013 
1014 	/*
1015 	 * No need to call dvb7000p_attach here, as it was called
1016 	 * already, as frontend_attach method is called first, and
1017 	 * tuner_attach is only called on sucess.
1018 	 */
1019 	tun_i2c = st->dib7000p_ops.get_i2c_master(adap->fe_adap[0].fe,
1020 					DIBX000_I2C_INTERFACE_TUNER, 1);
1021 
1022 	if (dvb_attach(dib0070_attach, adap->fe_adap[0].fe, tun_i2c,
1023 	    &dib7070p_dib0070_config) == NULL)
1024 		return -ENODEV;
1025 
1026 	st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
1027 	adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib7070_set_param_override;
1028 	return 0;
1029 }
1030 
cxusb_nano2_frontend_attach(struct dvb_usb_adapter * adap)1031 static int cxusb_nano2_frontend_attach(struct dvb_usb_adapter *adap)
1032 {
1033 	if (usb_set_interface(adap->dev->udev, 0, 1) < 0)
1034 		err("set interface failed");
1035 
1036 	cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
1037 
1038 	/* reset the tuner and demodulator */
1039 	cxusb_bluebird_gpio_rw(adap->dev, 0x04, 0);
1040 	cxusb_bluebird_gpio_pulse(adap->dev, 0x01, 1);
1041 	cxusb_bluebird_gpio_pulse(adap->dev, 0x02, 1);
1042 
1043 	adap->fe_adap[0].fe = dvb_attach(zl10353_attach,
1044 					 &cxusb_zl10353_xc3028_config,
1045 					 &adap->dev->i2c_adap);
1046 	if ((adap->fe_adap[0].fe) != NULL)
1047 		return 0;
1048 
1049 	adap->fe_adap[0].fe = dvb_attach(mt352_attach,
1050 					 &cxusb_mt352_xc3028_config,
1051 					 &adap->dev->i2c_adap);
1052 	if ((adap->fe_adap[0].fe) != NULL)
1053 		return 0;
1054 
1055 	return -EIO;
1056 }
1057 
1058 static struct lgs8gxx_config d680_lgs8gl5_cfg = {
1059 	.prod = LGS8GXX_PROD_LGS8GL5,
1060 	.demod_address = 0x19,
1061 	.serial_ts = 0,
1062 	.ts_clk_pol = 0,
1063 	.ts_clk_gated = 1,
1064 	.if_clk_freq = 30400, /* 30.4 MHz */
1065 	.if_freq = 5725, /* 5.725 MHz */
1066 	.if_neg_center = 0,
1067 	.ext_adc = 0,
1068 	.adc_signed = 0,
1069 	.if_neg_edge = 0,
1070 };
1071 
cxusb_d680_dmb_frontend_attach(struct dvb_usb_adapter * adap)1072 static int cxusb_d680_dmb_frontend_attach(struct dvb_usb_adapter *adap)
1073 {
1074 	struct dvb_usb_device *d = adap->dev;
1075 	int n;
1076 
1077 	/* Select required USB configuration */
1078 	if (usb_set_interface(d->udev, 0, 0) < 0)
1079 		err("set interface failed");
1080 
1081 	/* Unblock all USB pipes */
1082 	usb_clear_halt(d->udev,
1083 		usb_sndbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint));
1084 	usb_clear_halt(d->udev,
1085 		usb_rcvbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint));
1086 	usb_clear_halt(d->udev,
1087 		usb_rcvbulkpipe(d->udev, d->props.adapter[0].fe[0].stream.endpoint));
1088 
1089 	/* Drain USB pipes to avoid hang after reboot */
1090 	for (n = 0;  n < 5;  n++) {
1091 		cxusb_d680_dmb_drain_message(d);
1092 		cxusb_d680_dmb_drain_video(d);
1093 		msleep(200);
1094 	}
1095 
1096 	/* Reset the tuner */
1097 	if (cxusb_d680_dmb_gpio_tuner(d, 0x07, 0) < 0) {
1098 		err("clear tuner gpio failed");
1099 		return -EIO;
1100 	}
1101 	msleep(100);
1102 	if (cxusb_d680_dmb_gpio_tuner(d, 0x07, 1) < 0) {
1103 		err("set tuner gpio failed");
1104 		return -EIO;
1105 	}
1106 	msleep(100);
1107 
1108 	/* Attach frontend */
1109 	adap->fe_adap[0].fe = dvb_attach(lgs8gxx_attach, &d680_lgs8gl5_cfg, &d->i2c_adap);
1110 	if (adap->fe_adap[0].fe == NULL)
1111 		return -EIO;
1112 
1113 	return 0;
1114 }
1115 
1116 static struct atbm8830_config mygica_d689_atbm8830_cfg = {
1117 	.prod = ATBM8830_PROD_8830,
1118 	.demod_address = 0x40,
1119 	.serial_ts = 0,
1120 	.ts_sampling_edge = 1,
1121 	.ts_clk_gated = 0,
1122 	.osc_clk_freq = 30400, /* in kHz */
1123 	.if_freq = 0, /* zero IF */
1124 	.zif_swap_iq = 1,
1125 	.agc_min = 0x2E,
1126 	.agc_max = 0x90,
1127 	.agc_hold_loop = 0,
1128 };
1129 
cxusb_mygica_d689_frontend_attach(struct dvb_usb_adapter * adap)1130 static int cxusb_mygica_d689_frontend_attach(struct dvb_usb_adapter *adap)
1131 {
1132 	struct dvb_usb_device *d = adap->dev;
1133 
1134 	/* Select required USB configuration */
1135 	if (usb_set_interface(d->udev, 0, 0) < 0)
1136 		err("set interface failed");
1137 
1138 	/* Unblock all USB pipes */
1139 	usb_clear_halt(d->udev,
1140 		usb_sndbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint));
1141 	usb_clear_halt(d->udev,
1142 		usb_rcvbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint));
1143 	usb_clear_halt(d->udev,
1144 		usb_rcvbulkpipe(d->udev, d->props.adapter[0].fe[0].stream.endpoint));
1145 
1146 
1147 	/* Reset the tuner */
1148 	if (cxusb_d680_dmb_gpio_tuner(d, 0x07, 0) < 0) {
1149 		err("clear tuner gpio failed");
1150 		return -EIO;
1151 	}
1152 	msleep(100);
1153 	if (cxusb_d680_dmb_gpio_tuner(d, 0x07, 1) < 0) {
1154 		err("set tuner gpio failed");
1155 		return -EIO;
1156 	}
1157 	msleep(100);
1158 
1159 	/* Attach frontend */
1160 	adap->fe_adap[0].fe = dvb_attach(atbm8830_attach, &mygica_d689_atbm8830_cfg,
1161 		&d->i2c_adap);
1162 	if (adap->fe_adap[0].fe == NULL)
1163 		return -EIO;
1164 
1165 	return 0;
1166 }
1167 
cxusb_mygica_t230_frontend_attach(struct dvb_usb_adapter * adap)1168 static int cxusb_mygica_t230_frontend_attach(struct dvb_usb_adapter *adap)
1169 {
1170 	struct dvb_usb_device *d = adap->dev;
1171 	struct cxusb_state *st = d->priv;
1172 	struct i2c_adapter *adapter;
1173 	struct i2c_client *client_demod;
1174 	struct i2c_client *client_tuner;
1175 	struct i2c_board_info info;
1176 	struct si2168_config si2168_config;
1177 	struct si2157_config si2157_config;
1178 
1179 	/* Select required USB configuration */
1180 	if (usb_set_interface(d->udev, 0, 0) < 0)
1181 		err("set interface failed");
1182 
1183 	/* Unblock all USB pipes */
1184 	usb_clear_halt(d->udev,
1185 		usb_sndbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint));
1186 	usb_clear_halt(d->udev,
1187 		usb_rcvbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint));
1188 	usb_clear_halt(d->udev,
1189 		usb_rcvbulkpipe(d->udev, d->props.adapter[0].fe[0].stream.endpoint));
1190 
1191 	/* attach frontend */
1192 	si2168_config.i2c_adapter = &adapter;
1193 	si2168_config.fe = &adap->fe_adap[0].fe;
1194 	si2168_config.ts_mode = SI2168_TS_PARALLEL;
1195 	si2168_config.ts_clock_inv = 1;
1196 	memset(&info, 0, sizeof(struct i2c_board_info));
1197 	strlcpy(info.type, "si2168", I2C_NAME_SIZE);
1198 	info.addr = 0x64;
1199 	info.platform_data = &si2168_config;
1200 	request_module(info.type);
1201 	client_demod = i2c_new_device(&d->i2c_adap, &info);
1202 	if (client_demod == NULL || client_demod->dev.driver == NULL)
1203 		return -ENODEV;
1204 
1205 	if (!try_module_get(client_demod->dev.driver->owner)) {
1206 		i2c_unregister_device(client_demod);
1207 		return -ENODEV;
1208 	}
1209 
1210 	st->i2c_client_demod = client_demod;
1211 
1212 	/* attach tuner */
1213 	memset(&si2157_config, 0, sizeof(si2157_config));
1214 	si2157_config.fe = adap->fe_adap[0].fe;
1215 	si2157_config.if_port = 1;
1216 	memset(&info, 0, sizeof(struct i2c_board_info));
1217 	strlcpy(info.type, "si2157", I2C_NAME_SIZE);
1218 	info.addr = 0x60;
1219 	info.platform_data = &si2157_config;
1220 	request_module(info.type);
1221 	client_tuner = i2c_new_device(adapter, &info);
1222 	if (client_tuner == NULL || client_tuner->dev.driver == NULL) {
1223 		module_put(client_demod->dev.driver->owner);
1224 		i2c_unregister_device(client_demod);
1225 		return -ENODEV;
1226 	}
1227 	if (!try_module_get(client_tuner->dev.driver->owner)) {
1228 		i2c_unregister_device(client_tuner);
1229 		module_put(client_demod->dev.driver->owner);
1230 		i2c_unregister_device(client_demod);
1231 		return -ENODEV;
1232 	}
1233 
1234 	st->i2c_client_tuner = client_tuner;
1235 
1236 	/* hook fe: need to resync the slave fifo when signal locks. */
1237 	mutex_init(&st->stream_mutex);
1238 	st->last_lock = 0;
1239 	st->fe_read_status = adap->fe_adap[0].fe->ops.read_status;
1240 	adap->fe_adap[0].fe->ops.read_status = cxusb_read_status;
1241 
1242 	return 0;
1243 }
1244 
cxusb_mygica_t230c_frontend_attach(struct dvb_usb_adapter * adap)1245 static int cxusb_mygica_t230c_frontend_attach(struct dvb_usb_adapter *adap)
1246 {
1247 	struct dvb_usb_device *d = adap->dev;
1248 	struct cxusb_state *st = d->priv;
1249 	struct i2c_adapter *adapter;
1250 	struct i2c_client *client_demod;
1251 	struct i2c_client *client_tuner;
1252 	struct i2c_board_info info;
1253 	struct si2168_config si2168_config;
1254 	struct si2157_config si2157_config;
1255 
1256 	/* Select required USB configuration */
1257 	if (usb_set_interface(d->udev, 0, 0) < 0)
1258 		err("set interface failed");
1259 
1260 	/* Unblock all USB pipes */
1261 	usb_clear_halt(d->udev,
1262 		usb_sndbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint));
1263 	usb_clear_halt(d->udev,
1264 		usb_rcvbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint));
1265 	usb_clear_halt(d->udev,
1266 		usb_rcvbulkpipe(d->udev, d->props.adapter[0].fe[0].stream.endpoint));
1267 
1268 	/* attach frontend */
1269 	memset(&si2168_config, 0, sizeof(si2168_config));
1270 	si2168_config.i2c_adapter = &adapter;
1271 	si2168_config.fe = &adap->fe_adap[0].fe;
1272 	si2168_config.ts_mode = SI2168_TS_PARALLEL;
1273 	si2168_config.ts_clock_inv = 1;
1274 	memset(&info, 0, sizeof(struct i2c_board_info));
1275 	strlcpy(info.type, "si2168", I2C_NAME_SIZE);
1276 	info.addr = 0x64;
1277 	info.platform_data = &si2168_config;
1278 	request_module(info.type);
1279 	client_demod = i2c_new_device(&d->i2c_adap, &info);
1280 	if (client_demod == NULL || client_demod->dev.driver == NULL)
1281 		return -ENODEV;
1282 
1283 	if (!try_module_get(client_demod->dev.driver->owner)) {
1284 		i2c_unregister_device(client_demod);
1285 		return -ENODEV;
1286 	}
1287 
1288 	/* attach tuner */
1289 	memset(&si2157_config, 0, sizeof(si2157_config));
1290 	si2157_config.fe = adap->fe_adap[0].fe;
1291 	memset(&info, 0, sizeof(struct i2c_board_info));
1292 	strlcpy(info.type, "si2141", I2C_NAME_SIZE);
1293 	info.addr = 0x60;
1294 	info.platform_data = &si2157_config;
1295 	request_module("si2157");
1296 	client_tuner = i2c_new_device(adapter, &info);
1297 	if (client_tuner == NULL || client_tuner->dev.driver == NULL) {
1298 		module_put(client_demod->dev.driver->owner);
1299 		i2c_unregister_device(client_demod);
1300 		return -ENODEV;
1301 	}
1302 	if (!try_module_get(client_tuner->dev.driver->owner)) {
1303 		i2c_unregister_device(client_tuner);
1304 		module_put(client_demod->dev.driver->owner);
1305 		i2c_unregister_device(client_demod);
1306 		return -ENODEV;
1307 	}
1308 
1309 	st->i2c_client_demod = client_demod;
1310 	st->i2c_client_tuner = client_tuner;
1311 
1312 	/* hook fe: need to resync the slave fifo when signal locks. */
1313 	mutex_init(&st->stream_mutex);
1314 	st->last_lock = 0;
1315 	st->fe_read_status = adap->fe_adap[0].fe->ops.read_status;
1316 	adap->fe_adap[0].fe->ops.read_status = cxusb_read_status;
1317 
1318 	return 0;
1319 }
1320 
1321 /*
1322  * DViCO has shipped two devices with the same USB ID, but only one of them
1323  * needs a firmware download.  Check the device class details to see if they
1324  * have non-default values to decide whether the device is actually cold or
1325  * not, and forget a match if it turns out we selected the wrong device.
1326  */
bluebird_fx2_identify_state(struct usb_device * udev,struct dvb_usb_device_properties * props,struct dvb_usb_device_description ** desc,int * cold)1327 static int bluebird_fx2_identify_state(struct usb_device *udev,
1328 				       struct dvb_usb_device_properties *props,
1329 				       struct dvb_usb_device_description **desc,
1330 				       int *cold)
1331 {
1332 	int wascold = *cold;
1333 
1334 	*cold = udev->descriptor.bDeviceClass == 0xff &&
1335 		udev->descriptor.bDeviceSubClass == 0xff &&
1336 		udev->descriptor.bDeviceProtocol == 0xff;
1337 
1338 	if (*cold && !wascold)
1339 		*desc = NULL;
1340 
1341 	return 0;
1342 }
1343 
1344 /*
1345  * DViCO bluebird firmware needs the "warm" product ID to be patched into the
1346  * firmware file before download.
1347  */
1348 
1349 static const int dvico_firmware_id_offsets[] = { 6638, 3204 };
bluebird_patch_dvico_firmware_download(struct usb_device * udev,const struct firmware * fw)1350 static int bluebird_patch_dvico_firmware_download(struct usb_device *udev,
1351 						  const struct firmware *fw)
1352 {
1353 	int pos;
1354 
1355 	for (pos = 0; pos < ARRAY_SIZE(dvico_firmware_id_offsets); pos++) {
1356 		int idoff = dvico_firmware_id_offsets[pos];
1357 
1358 		if (fw->size < idoff + 4)
1359 			continue;
1360 
1361 		if (fw->data[idoff] == (USB_VID_DVICO & 0xff) &&
1362 		    fw->data[idoff + 1] == USB_VID_DVICO >> 8) {
1363 			struct firmware new_fw;
1364 			u8 *new_fw_data = vmalloc(fw->size);
1365 			int ret;
1366 
1367 			if (!new_fw_data)
1368 				return -ENOMEM;
1369 
1370 			memcpy(new_fw_data, fw->data, fw->size);
1371 			new_fw.size = fw->size;
1372 			new_fw.data = new_fw_data;
1373 
1374 			new_fw_data[idoff + 2] =
1375 				le16_to_cpu(udev->descriptor.idProduct) + 1;
1376 			new_fw_data[idoff + 3] =
1377 				le16_to_cpu(udev->descriptor.idProduct) >> 8;
1378 
1379 			ret = usb_cypress_load_firmware(udev, &new_fw,
1380 							CYPRESS_FX2);
1381 			vfree(new_fw_data);
1382 			return ret;
1383 		}
1384 	}
1385 
1386 	return -EINVAL;
1387 }
1388 
1389 /* DVB USB Driver stuff */
1390 static struct dvb_usb_device_properties cxusb_medion_properties;
1391 static struct dvb_usb_device_properties cxusb_bluebird_lgh064f_properties;
1392 static struct dvb_usb_device_properties cxusb_bluebird_dee1601_properties;
1393 static struct dvb_usb_device_properties cxusb_bluebird_lgz201_properties;
1394 static struct dvb_usb_device_properties cxusb_bluebird_dtt7579_properties;
1395 static struct dvb_usb_device_properties cxusb_bluebird_dualdig4_properties;
1396 static struct dvb_usb_device_properties cxusb_bluebird_dualdig4_rev2_properties;
1397 static struct dvb_usb_device_properties cxusb_bluebird_nano2_properties;
1398 static struct dvb_usb_device_properties cxusb_bluebird_nano2_needsfirmware_properties;
1399 static struct dvb_usb_device_properties cxusb_aver_a868r_properties;
1400 static struct dvb_usb_device_properties cxusb_d680_dmb_properties;
1401 static struct dvb_usb_device_properties cxusb_mygica_d689_properties;
1402 static struct dvb_usb_device_properties cxusb_mygica_t230_properties;
1403 static struct dvb_usb_device_properties cxusb_mygica_t230c_properties;
1404 
cxusb_probe(struct usb_interface * intf,const struct usb_device_id * id)1405 static int cxusb_probe(struct usb_interface *intf,
1406 		       const struct usb_device_id *id)
1407 {
1408 	if (0 == dvb_usb_device_init(intf, &cxusb_medion_properties,
1409 				     THIS_MODULE, NULL, adapter_nr) ||
1410 	    0 == dvb_usb_device_init(intf, &cxusb_bluebird_lgh064f_properties,
1411 				     THIS_MODULE, NULL, adapter_nr) ||
1412 	    0 == dvb_usb_device_init(intf, &cxusb_bluebird_dee1601_properties,
1413 				     THIS_MODULE, NULL, adapter_nr) ||
1414 	    0 == dvb_usb_device_init(intf, &cxusb_bluebird_lgz201_properties,
1415 				     THIS_MODULE, NULL, adapter_nr) ||
1416 	    0 == dvb_usb_device_init(intf, &cxusb_bluebird_dtt7579_properties,
1417 				     THIS_MODULE, NULL, adapter_nr) ||
1418 	    0 == dvb_usb_device_init(intf, &cxusb_bluebird_dualdig4_properties,
1419 				     THIS_MODULE, NULL, adapter_nr) ||
1420 	    0 == dvb_usb_device_init(intf, &cxusb_bluebird_nano2_properties,
1421 				     THIS_MODULE, NULL, adapter_nr) ||
1422 	    0 == dvb_usb_device_init(intf,
1423 				&cxusb_bluebird_nano2_needsfirmware_properties,
1424 				     THIS_MODULE, NULL, adapter_nr) ||
1425 	    0 == dvb_usb_device_init(intf, &cxusb_aver_a868r_properties,
1426 				     THIS_MODULE, NULL, adapter_nr) ||
1427 	    0 == dvb_usb_device_init(intf,
1428 				     &cxusb_bluebird_dualdig4_rev2_properties,
1429 				     THIS_MODULE, NULL, adapter_nr) ||
1430 	    0 == dvb_usb_device_init(intf, &cxusb_d680_dmb_properties,
1431 				     THIS_MODULE, NULL, adapter_nr) ||
1432 	    0 == dvb_usb_device_init(intf, &cxusb_mygica_d689_properties,
1433 				     THIS_MODULE, NULL, adapter_nr) ||
1434 	    0 == dvb_usb_device_init(intf, &cxusb_mygica_t230_properties,
1435 				     THIS_MODULE, NULL, adapter_nr) ||
1436 	    0 == dvb_usb_device_init(intf, &cxusb_mygica_t230c_properties,
1437 				     THIS_MODULE, NULL, adapter_nr) ||
1438 	    0)
1439 		return 0;
1440 
1441 	return -EINVAL;
1442 }
1443 
cxusb_disconnect(struct usb_interface * intf)1444 static void cxusb_disconnect(struct usb_interface *intf)
1445 {
1446 	struct dvb_usb_device *d = usb_get_intfdata(intf);
1447 	struct cxusb_state *st = d->priv;
1448 	struct i2c_client *client;
1449 
1450 	/* remove I2C client for tuner */
1451 	client = st->i2c_client_tuner;
1452 	if (client) {
1453 		module_put(client->dev.driver->owner);
1454 		i2c_unregister_device(client);
1455 	}
1456 
1457 	/* remove I2C client for demodulator */
1458 	client = st->i2c_client_demod;
1459 	if (client) {
1460 		module_put(client->dev.driver->owner);
1461 		i2c_unregister_device(client);
1462 	}
1463 
1464 	dvb_usb_device_exit(intf);
1465 }
1466 
1467 enum cxusb_table_index {
1468 	MEDION_MD95700,
1469 	DVICO_BLUEBIRD_LG064F_COLD,
1470 	DVICO_BLUEBIRD_LG064F_WARM,
1471 	DVICO_BLUEBIRD_DUAL_1_COLD,
1472 	DVICO_BLUEBIRD_DUAL_1_WARM,
1473 	DVICO_BLUEBIRD_LGZ201_COLD,
1474 	DVICO_BLUEBIRD_LGZ201_WARM,
1475 	DVICO_BLUEBIRD_TH7579_COLD,
1476 	DVICO_BLUEBIRD_TH7579_WARM,
1477 	DIGITALNOW_BLUEBIRD_DUAL_1_COLD,
1478 	DIGITALNOW_BLUEBIRD_DUAL_1_WARM,
1479 	DVICO_BLUEBIRD_DUAL_2_COLD,
1480 	DVICO_BLUEBIRD_DUAL_2_WARM,
1481 	DVICO_BLUEBIRD_DUAL_4,
1482 	DVICO_BLUEBIRD_DVB_T_NANO_2,
1483 	DVICO_BLUEBIRD_DVB_T_NANO_2_NFW_WARM,
1484 	AVERMEDIA_VOLAR_A868R,
1485 	DVICO_BLUEBIRD_DUAL_4_REV_2,
1486 	CONEXANT_D680_DMB,
1487 	MYGICA_D689,
1488 	MYGICA_T230,
1489 	MYGICA_T230C,
1490 	NR__cxusb_table_index
1491 };
1492 
1493 static struct usb_device_id cxusb_table[NR__cxusb_table_index + 1] = {
1494 	[MEDION_MD95700] = {
1495 		USB_DEVICE(USB_VID_MEDION, USB_PID_MEDION_MD95700)
1496 	},
1497 	[DVICO_BLUEBIRD_LG064F_COLD] = {
1498 		USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LG064F_COLD)
1499 	},
1500 	[DVICO_BLUEBIRD_LG064F_WARM] = {
1501 		USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LG064F_WARM)
1502 	},
1503 	[DVICO_BLUEBIRD_DUAL_1_COLD] = {
1504 		USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_1_COLD)
1505 	},
1506 	[DVICO_BLUEBIRD_DUAL_1_WARM] = {
1507 		USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_1_WARM)
1508 	},
1509 	[DVICO_BLUEBIRD_LGZ201_COLD] = {
1510 		USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LGZ201_COLD)
1511 	},
1512 	[DVICO_BLUEBIRD_LGZ201_WARM] = {
1513 		USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LGZ201_WARM)
1514 	},
1515 	[DVICO_BLUEBIRD_TH7579_COLD] = {
1516 		USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_TH7579_COLD)
1517 	},
1518 	[DVICO_BLUEBIRD_TH7579_WARM] = {
1519 		USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_TH7579_WARM)
1520 	},
1521 	[DIGITALNOW_BLUEBIRD_DUAL_1_COLD] = {
1522 		USB_DEVICE(USB_VID_DVICO, USB_PID_DIGITALNOW_BLUEBIRD_DUAL_1_COLD)
1523 	},
1524 	[DIGITALNOW_BLUEBIRD_DUAL_1_WARM] = {
1525 		USB_DEVICE(USB_VID_DVICO, USB_PID_DIGITALNOW_BLUEBIRD_DUAL_1_WARM)
1526 	},
1527 	[DVICO_BLUEBIRD_DUAL_2_COLD] = {
1528 		USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_2_COLD)
1529 	},
1530 	[DVICO_BLUEBIRD_DUAL_2_WARM] = {
1531 		USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_2_WARM)
1532 	},
1533 	[DVICO_BLUEBIRD_DUAL_4] = {
1534 		USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_4)
1535 	},
1536 	[DVICO_BLUEBIRD_DVB_T_NANO_2] = {
1537 		USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DVB_T_NANO_2)
1538 	},
1539 	[DVICO_BLUEBIRD_DVB_T_NANO_2_NFW_WARM] = {
1540 		USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DVB_T_NANO_2_NFW_WARM)
1541 	},
1542 	[AVERMEDIA_VOLAR_A868R] = {
1543 		USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR_A868R)
1544 	},
1545 	[DVICO_BLUEBIRD_DUAL_4_REV_2] = {
1546 		USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_4_REV_2)
1547 	},
1548 	[CONEXANT_D680_DMB] = {
1549 		USB_DEVICE(USB_VID_CONEXANT, USB_PID_CONEXANT_D680_DMB)
1550 	},
1551 	[MYGICA_D689] = {
1552 		USB_DEVICE(USB_VID_CONEXANT, USB_PID_MYGICA_D689)
1553 	},
1554 	[MYGICA_T230] = {
1555 		USB_DEVICE(USB_VID_CONEXANT, USB_PID_MYGICA_T230)
1556 	},
1557 	[MYGICA_T230C] = {
1558 		USB_DEVICE(USB_VID_CONEXANT, USB_PID_MYGICA_T230+1)
1559 	},
1560 	{}		/* Terminating entry */
1561 };
1562 MODULE_DEVICE_TABLE (usb, cxusb_table);
1563 
1564 static struct dvb_usb_device_properties cxusb_medion_properties = {
1565 	.caps = DVB_USB_IS_AN_I2C_ADAPTER,
1566 
1567 	.usb_ctrl = CYPRESS_FX2,
1568 
1569 	.size_of_priv     = sizeof(struct cxusb_state),
1570 
1571 	.num_adapters = 1,
1572 	.adapter = {
1573 		{
1574 		.num_frontends = 1,
1575 		.fe = {{
1576 			.streaming_ctrl   = cxusb_streaming_ctrl,
1577 			.frontend_attach  = cxusb_cx22702_frontend_attach,
1578 			.tuner_attach     = cxusb_fmd1216me_tuner_attach,
1579 			/* parameter for the MPEG2-data transfer */
1580 					.stream = {
1581 						.type = USB_BULK,
1582 				.count = 5,
1583 				.endpoint = 0x02,
1584 				.u = {
1585 					.bulk = {
1586 						.buffersize = 8192,
1587 					}
1588 				}
1589 			},
1590 		}},
1591 		},
1592 	},
1593 	.power_ctrl       = cxusb_power_ctrl,
1594 
1595 	.i2c_algo         = &cxusb_i2c_algo,
1596 
1597 	.generic_bulk_ctrl_endpoint = 0x01,
1598 
1599 	.num_device_descs = 1,
1600 	.devices = {
1601 		{   "Medion MD95700 (MDUSBTV-HYBRID)",
1602 			{ NULL },
1603 			{ &cxusb_table[MEDION_MD95700], NULL },
1604 		},
1605 	}
1606 };
1607 
1608 static struct dvb_usb_device_properties cxusb_bluebird_lgh064f_properties = {
1609 	.caps = DVB_USB_IS_AN_I2C_ADAPTER,
1610 
1611 	.usb_ctrl          = DEVICE_SPECIFIC,
1612 	.firmware          = "dvb-usb-bluebird-01.fw",
1613 	.download_firmware = bluebird_patch_dvico_firmware_download,
1614 	/* use usb alt setting 0 for EP4 transfer (dvb-t),
1615 	   use usb alt setting 7 for EP2 transfer (atsc) */
1616 
1617 	.size_of_priv     = sizeof(struct cxusb_state),
1618 
1619 	.num_adapters = 1,
1620 	.adapter = {
1621 		{
1622 		.num_frontends = 1,
1623 		.fe = {{
1624 			.streaming_ctrl   = cxusb_streaming_ctrl,
1625 			.frontend_attach  = cxusb_lgdt3303_frontend_attach,
1626 			.tuner_attach     = cxusb_lgh064f_tuner_attach,
1627 
1628 			/* parameter for the MPEG2-data transfer */
1629 					.stream = {
1630 						.type = USB_BULK,
1631 				.count = 5,
1632 				.endpoint = 0x02,
1633 				.u = {
1634 					.bulk = {
1635 						.buffersize = 8192,
1636 					}
1637 				}
1638 			},
1639 		}},
1640 		},
1641 	},
1642 
1643 	.power_ctrl       = cxusb_bluebird_power_ctrl,
1644 
1645 	.i2c_algo         = &cxusb_i2c_algo,
1646 
1647 	.rc.core = {
1648 		.rc_interval	= 100,
1649 		.rc_codes	= RC_MAP_DVICO_PORTABLE,
1650 		.module_name	= KBUILD_MODNAME,
1651 		.rc_query	= cxusb_rc_query,
1652 		.allowed_protos = RC_PROTO_BIT_NEC,
1653 	},
1654 
1655 	.generic_bulk_ctrl_endpoint = 0x01,
1656 
1657 	.num_device_descs = 1,
1658 	.devices = {
1659 		{   "DViCO FusionHDTV5 USB Gold",
1660 			{ &cxusb_table[DVICO_BLUEBIRD_LG064F_COLD], NULL },
1661 			{ &cxusb_table[DVICO_BLUEBIRD_LG064F_WARM], NULL },
1662 		},
1663 	}
1664 };
1665 
1666 static struct dvb_usb_device_properties cxusb_bluebird_dee1601_properties = {
1667 	.caps = DVB_USB_IS_AN_I2C_ADAPTER,
1668 
1669 	.usb_ctrl          = DEVICE_SPECIFIC,
1670 	.firmware          = "dvb-usb-bluebird-01.fw",
1671 	.download_firmware = bluebird_patch_dvico_firmware_download,
1672 	/* use usb alt setting 0 for EP4 transfer (dvb-t),
1673 	   use usb alt setting 7 for EP2 transfer (atsc) */
1674 
1675 	.size_of_priv     = sizeof(struct cxusb_state),
1676 
1677 	.num_adapters = 1,
1678 	.adapter = {
1679 		{
1680 		.num_frontends = 1,
1681 		.fe = {{
1682 			.streaming_ctrl   = cxusb_streaming_ctrl,
1683 			.frontend_attach  = cxusb_dee1601_frontend_attach,
1684 			.tuner_attach     = cxusb_dee1601_tuner_attach,
1685 			/* parameter for the MPEG2-data transfer */
1686 			.stream = {
1687 				.type = USB_BULK,
1688 				.count = 5,
1689 				.endpoint = 0x04,
1690 				.u = {
1691 					.bulk = {
1692 						.buffersize = 8192,
1693 					}
1694 				}
1695 			},
1696 		}},
1697 		},
1698 	},
1699 
1700 	.power_ctrl       = cxusb_bluebird_power_ctrl,
1701 
1702 	.i2c_algo         = &cxusb_i2c_algo,
1703 
1704 	.rc.core = {
1705 		.rc_interval	= 100,
1706 		.rc_codes	= RC_MAP_DVICO_MCE,
1707 		.module_name	= KBUILD_MODNAME,
1708 		.rc_query	= cxusb_rc_query,
1709 		.allowed_protos = RC_PROTO_BIT_NEC,
1710 	},
1711 
1712 	.generic_bulk_ctrl_endpoint = 0x01,
1713 
1714 	.num_device_descs = 3,
1715 	.devices = {
1716 		{   "DViCO FusionHDTV DVB-T Dual USB",
1717 			{ &cxusb_table[DVICO_BLUEBIRD_DUAL_1_COLD], NULL },
1718 			{ &cxusb_table[DVICO_BLUEBIRD_DUAL_1_WARM], NULL },
1719 		},
1720 		{   "DigitalNow DVB-T Dual USB",
1721 			{ &cxusb_table[DIGITALNOW_BLUEBIRD_DUAL_1_COLD],  NULL },
1722 			{ &cxusb_table[DIGITALNOW_BLUEBIRD_DUAL_1_WARM], NULL },
1723 		},
1724 		{   "DViCO FusionHDTV DVB-T Dual Digital 2",
1725 			{ &cxusb_table[DVICO_BLUEBIRD_DUAL_2_COLD], NULL },
1726 			{ &cxusb_table[DVICO_BLUEBIRD_DUAL_2_WARM], NULL },
1727 		},
1728 	}
1729 };
1730 
1731 static struct dvb_usb_device_properties cxusb_bluebird_lgz201_properties = {
1732 	.caps = DVB_USB_IS_AN_I2C_ADAPTER,
1733 
1734 	.usb_ctrl          = DEVICE_SPECIFIC,
1735 	.firmware          = "dvb-usb-bluebird-01.fw",
1736 	.download_firmware = bluebird_patch_dvico_firmware_download,
1737 	/* use usb alt setting 0 for EP4 transfer (dvb-t),
1738 	   use usb alt setting 7 for EP2 transfer (atsc) */
1739 
1740 	.size_of_priv     = sizeof(struct cxusb_state),
1741 
1742 	.num_adapters = 2,
1743 	.adapter = {
1744 		{
1745 		.num_frontends = 1,
1746 		.fe = {{
1747 			.streaming_ctrl   = cxusb_streaming_ctrl,
1748 			.frontend_attach  = cxusb_mt352_frontend_attach,
1749 			.tuner_attach     = cxusb_lgz201_tuner_attach,
1750 
1751 			/* parameter for the MPEG2-data transfer */
1752 			.stream = {
1753 				.type = USB_BULK,
1754 				.count = 5,
1755 				.endpoint = 0x04,
1756 				.u = {
1757 					.bulk = {
1758 						.buffersize = 8192,
1759 					}
1760 				}
1761 			},
1762 		}},
1763 		},
1764 	},
1765 	.power_ctrl       = cxusb_bluebird_power_ctrl,
1766 
1767 	.i2c_algo         = &cxusb_i2c_algo,
1768 
1769 	.rc.core = {
1770 		.rc_interval	= 100,
1771 		.rc_codes	= RC_MAP_DVICO_PORTABLE,
1772 		.module_name	= KBUILD_MODNAME,
1773 		.rc_query	= cxusb_rc_query,
1774 		.allowed_protos = RC_PROTO_BIT_NEC,
1775 	},
1776 
1777 	.generic_bulk_ctrl_endpoint = 0x01,
1778 	.num_device_descs = 1,
1779 	.devices = {
1780 		{   "DViCO FusionHDTV DVB-T USB (LGZ201)",
1781 			{ &cxusb_table[DVICO_BLUEBIRD_LGZ201_COLD], NULL },
1782 			{ &cxusb_table[DVICO_BLUEBIRD_LGZ201_WARM], NULL },
1783 		},
1784 	}
1785 };
1786 
1787 static struct dvb_usb_device_properties cxusb_bluebird_dtt7579_properties = {
1788 	.caps = DVB_USB_IS_AN_I2C_ADAPTER,
1789 
1790 	.usb_ctrl          = DEVICE_SPECIFIC,
1791 	.firmware          = "dvb-usb-bluebird-01.fw",
1792 	.download_firmware = bluebird_patch_dvico_firmware_download,
1793 	/* use usb alt setting 0 for EP4 transfer (dvb-t),
1794 	   use usb alt setting 7 for EP2 transfer (atsc) */
1795 
1796 	.size_of_priv     = sizeof(struct cxusb_state),
1797 
1798 	.num_adapters = 1,
1799 	.adapter = {
1800 		{
1801 		.num_frontends = 1,
1802 		.fe = {{
1803 			.streaming_ctrl   = cxusb_streaming_ctrl,
1804 			.frontend_attach  = cxusb_mt352_frontend_attach,
1805 			.tuner_attach     = cxusb_dtt7579_tuner_attach,
1806 
1807 			/* parameter for the MPEG2-data transfer */
1808 			.stream = {
1809 				.type = USB_BULK,
1810 				.count = 5,
1811 				.endpoint = 0x04,
1812 				.u = {
1813 					.bulk = {
1814 						.buffersize = 8192,
1815 					}
1816 				}
1817 			},
1818 		}},
1819 		},
1820 	},
1821 	.power_ctrl       = cxusb_bluebird_power_ctrl,
1822 
1823 	.i2c_algo         = &cxusb_i2c_algo,
1824 
1825 	.rc.core = {
1826 		.rc_interval	= 100,
1827 		.rc_codes	= RC_MAP_DVICO_PORTABLE,
1828 		.module_name	= KBUILD_MODNAME,
1829 		.rc_query	= cxusb_rc_query,
1830 		.allowed_protos = RC_PROTO_BIT_NEC,
1831 	},
1832 
1833 	.generic_bulk_ctrl_endpoint = 0x01,
1834 
1835 	.num_device_descs = 1,
1836 	.devices = {
1837 		{   "DViCO FusionHDTV DVB-T USB (TH7579)",
1838 			{ &cxusb_table[DVICO_BLUEBIRD_TH7579_COLD], NULL },
1839 			{ &cxusb_table[DVICO_BLUEBIRD_TH7579_WARM], NULL },
1840 		},
1841 	}
1842 };
1843 
1844 static struct dvb_usb_device_properties cxusb_bluebird_dualdig4_properties = {
1845 	.caps = DVB_USB_IS_AN_I2C_ADAPTER,
1846 
1847 	.usb_ctrl         = CYPRESS_FX2,
1848 
1849 	.size_of_priv     = sizeof(struct cxusb_state),
1850 
1851 	.num_adapters = 1,
1852 	.adapter = {
1853 		{
1854 		.num_frontends = 1,
1855 		.fe = {{
1856 			.streaming_ctrl   = cxusb_streaming_ctrl,
1857 			.frontend_attach  = cxusb_dualdig4_frontend_attach,
1858 			.tuner_attach     = cxusb_dvico_xc3028_tuner_attach,
1859 			/* parameter for the MPEG2-data transfer */
1860 			.stream = {
1861 				.type = USB_BULK,
1862 				.count = 5,
1863 				.endpoint = 0x02,
1864 				.u = {
1865 					.bulk = {
1866 						.buffersize = 8192,
1867 					}
1868 				}
1869 			},
1870 		}},
1871 		},
1872 	},
1873 
1874 	.power_ctrl       = cxusb_power_ctrl,
1875 
1876 	.i2c_algo         = &cxusb_i2c_algo,
1877 
1878 	.generic_bulk_ctrl_endpoint = 0x01,
1879 
1880 	.rc.core = {
1881 		.rc_interval	= 100,
1882 		.rc_codes	= RC_MAP_DVICO_MCE,
1883 		.module_name	= KBUILD_MODNAME,
1884 		.rc_query	= cxusb_bluebird2_rc_query,
1885 		.allowed_protos = RC_PROTO_BIT_NEC,
1886 	},
1887 
1888 	.num_device_descs = 1,
1889 	.devices = {
1890 		{   "DViCO FusionHDTV DVB-T Dual Digital 4",
1891 			{ NULL },
1892 			{ &cxusb_table[DVICO_BLUEBIRD_DUAL_4], NULL },
1893 		},
1894 	}
1895 };
1896 
1897 static struct dvb_usb_device_properties cxusb_bluebird_nano2_properties = {
1898 	.caps = DVB_USB_IS_AN_I2C_ADAPTER,
1899 
1900 	.usb_ctrl         = CYPRESS_FX2,
1901 	.identify_state   = bluebird_fx2_identify_state,
1902 
1903 	.size_of_priv     = sizeof(struct cxusb_state),
1904 
1905 	.num_adapters = 1,
1906 	.adapter = {
1907 		{
1908 		.num_frontends = 1,
1909 		.fe = {{
1910 			.streaming_ctrl   = cxusb_streaming_ctrl,
1911 			.frontend_attach  = cxusb_nano2_frontend_attach,
1912 			.tuner_attach     = cxusb_dvico_xc3028_tuner_attach,
1913 			/* parameter for the MPEG2-data transfer */
1914 			.stream = {
1915 				.type = USB_BULK,
1916 				.count = 5,
1917 				.endpoint = 0x02,
1918 				.u = {
1919 					.bulk = {
1920 						.buffersize = 8192,
1921 					}
1922 				}
1923 			},
1924 		}},
1925 		},
1926 	},
1927 
1928 	.power_ctrl       = cxusb_nano2_power_ctrl,
1929 
1930 	.i2c_algo         = &cxusb_i2c_algo,
1931 
1932 	.generic_bulk_ctrl_endpoint = 0x01,
1933 
1934 	.rc.core = {
1935 		.rc_interval	= 100,
1936 		.rc_codes	= RC_MAP_DVICO_PORTABLE,
1937 		.module_name	= KBUILD_MODNAME,
1938 		.rc_query       = cxusb_bluebird2_rc_query,
1939 		.allowed_protos = RC_PROTO_BIT_NEC,
1940 	},
1941 
1942 	.num_device_descs = 1,
1943 	.devices = {
1944 		{   "DViCO FusionHDTV DVB-T NANO2",
1945 			{ NULL },
1946 			{ &cxusb_table[DVICO_BLUEBIRD_DVB_T_NANO_2], NULL },
1947 		},
1948 	}
1949 };
1950 
1951 static struct dvb_usb_device_properties cxusb_bluebird_nano2_needsfirmware_properties = {
1952 	.caps = DVB_USB_IS_AN_I2C_ADAPTER,
1953 
1954 	.usb_ctrl          = DEVICE_SPECIFIC,
1955 	.firmware          = "dvb-usb-bluebird-02.fw",
1956 	.download_firmware = bluebird_patch_dvico_firmware_download,
1957 	.identify_state    = bluebird_fx2_identify_state,
1958 
1959 	.size_of_priv      = sizeof(struct cxusb_state),
1960 
1961 	.num_adapters = 1,
1962 	.adapter = {
1963 		{
1964 		.num_frontends = 1,
1965 		.fe = {{
1966 			.streaming_ctrl   = cxusb_streaming_ctrl,
1967 			.frontend_attach  = cxusb_nano2_frontend_attach,
1968 			.tuner_attach     = cxusb_dvico_xc3028_tuner_attach,
1969 			/* parameter for the MPEG2-data transfer */
1970 			.stream = {
1971 				.type = USB_BULK,
1972 				.count = 5,
1973 				.endpoint = 0x02,
1974 				.u = {
1975 					.bulk = {
1976 						.buffersize = 8192,
1977 					}
1978 				}
1979 			},
1980 		}},
1981 		},
1982 	},
1983 
1984 	.power_ctrl       = cxusb_nano2_power_ctrl,
1985 
1986 	.i2c_algo         = &cxusb_i2c_algo,
1987 
1988 	.generic_bulk_ctrl_endpoint = 0x01,
1989 
1990 	.rc.core = {
1991 		.rc_interval	= 100,
1992 		.rc_codes	= RC_MAP_DVICO_PORTABLE,
1993 		.module_name	= KBUILD_MODNAME,
1994 		.rc_query	= cxusb_rc_query,
1995 		.allowed_protos = RC_PROTO_BIT_NEC,
1996 	},
1997 
1998 	.num_device_descs = 1,
1999 	.devices = {
2000 		{   "DViCO FusionHDTV DVB-T NANO2 w/o firmware",
2001 			{ &cxusb_table[DVICO_BLUEBIRD_DVB_T_NANO_2], NULL },
2002 			{ &cxusb_table[DVICO_BLUEBIRD_DVB_T_NANO_2_NFW_WARM], NULL },
2003 		},
2004 	}
2005 };
2006 
2007 static struct dvb_usb_device_properties cxusb_aver_a868r_properties = {
2008 	.caps = DVB_USB_IS_AN_I2C_ADAPTER,
2009 
2010 	.usb_ctrl         = CYPRESS_FX2,
2011 
2012 	.size_of_priv     = sizeof(struct cxusb_state),
2013 
2014 	.num_adapters = 1,
2015 	.adapter = {
2016 		{
2017 		.num_frontends = 1,
2018 		.fe = {{
2019 			.streaming_ctrl   = cxusb_aver_streaming_ctrl,
2020 			.frontend_attach  = cxusb_aver_lgdt3303_frontend_attach,
2021 			.tuner_attach     = cxusb_mxl5003s_tuner_attach,
2022 			/* parameter for the MPEG2-data transfer */
2023 			.stream = {
2024 				.type = USB_BULK,
2025 				.count = 5,
2026 				.endpoint = 0x04,
2027 				.u = {
2028 					.bulk = {
2029 						.buffersize = 8192,
2030 					}
2031 				}
2032 			},
2033 		}},
2034 		},
2035 	},
2036 	.power_ctrl       = cxusb_aver_power_ctrl,
2037 
2038 	.i2c_algo         = &cxusb_i2c_algo,
2039 
2040 	.generic_bulk_ctrl_endpoint = 0x01,
2041 
2042 	.num_device_descs = 1,
2043 	.devices = {
2044 		{   "AVerMedia AVerTVHD Volar (A868R)",
2045 			{ NULL },
2046 			{ &cxusb_table[AVERMEDIA_VOLAR_A868R], NULL },
2047 		},
2048 	}
2049 };
2050 
2051 static
2052 struct dvb_usb_device_properties cxusb_bluebird_dualdig4_rev2_properties = {
2053 	.caps = DVB_USB_IS_AN_I2C_ADAPTER,
2054 
2055 	.usb_ctrl         = CYPRESS_FX2,
2056 
2057 	.size_of_priv     = sizeof(struct cxusb_state),
2058 
2059 	.num_adapters = 1,
2060 	.adapter = {
2061 		{
2062 		.size_of_priv    = sizeof(struct dib0700_adapter_state),
2063 		.num_frontends = 1,
2064 		.fe = {{
2065 			.streaming_ctrl  = cxusb_streaming_ctrl,
2066 			.frontend_attach = cxusb_dualdig4_rev2_frontend_attach,
2067 			.tuner_attach    = cxusb_dualdig4_rev2_tuner_attach,
2068 			/* parameter for the MPEG2-data transfer */
2069 			.stream = {
2070 				.type = USB_BULK,
2071 				.count = 7,
2072 				.endpoint = 0x02,
2073 				.u = {
2074 					.bulk = {
2075 						.buffersize = 4096,
2076 					}
2077 				}
2078 			},
2079 		}},
2080 		},
2081 	},
2082 
2083 	.power_ctrl       = cxusb_bluebird_power_ctrl,
2084 
2085 	.i2c_algo         = &cxusb_i2c_algo,
2086 
2087 	.generic_bulk_ctrl_endpoint = 0x01,
2088 
2089 	.rc.core = {
2090 		.rc_interval	= 100,
2091 		.rc_codes	= RC_MAP_DVICO_MCE,
2092 		.module_name	= KBUILD_MODNAME,
2093 		.rc_query	= cxusb_rc_query,
2094 		.allowed_protos = RC_PROTO_BIT_NEC,
2095 	},
2096 
2097 	.num_device_descs = 1,
2098 	.devices = {
2099 		{   "DViCO FusionHDTV DVB-T Dual Digital 4 (rev 2)",
2100 			{ NULL },
2101 			{ &cxusb_table[DVICO_BLUEBIRD_DUAL_4_REV_2], NULL },
2102 		},
2103 	}
2104 };
2105 
2106 static struct dvb_usb_device_properties cxusb_d680_dmb_properties = {
2107 	.caps = DVB_USB_IS_AN_I2C_ADAPTER,
2108 
2109 	.usb_ctrl         = CYPRESS_FX2,
2110 
2111 	.size_of_priv     = sizeof(struct cxusb_state),
2112 
2113 	.num_adapters = 1,
2114 	.adapter = {
2115 		{
2116 		.num_frontends = 1,
2117 		.fe = {{
2118 			.streaming_ctrl   = cxusb_d680_dmb_streaming_ctrl,
2119 			.frontend_attach  = cxusb_d680_dmb_frontend_attach,
2120 			.tuner_attach     = cxusb_d680_dmb_tuner_attach,
2121 
2122 			/* parameter for the MPEG2-data transfer */
2123 			.stream = {
2124 				.type = USB_BULK,
2125 				.count = 5,
2126 				.endpoint = 0x02,
2127 				.u = {
2128 					.bulk = {
2129 						.buffersize = 8192,
2130 					}
2131 				}
2132 			},
2133 		}},
2134 		},
2135 	},
2136 
2137 	.power_ctrl       = cxusb_d680_dmb_power_ctrl,
2138 
2139 	.i2c_algo         = &cxusb_i2c_algo,
2140 
2141 	.generic_bulk_ctrl_endpoint = 0x01,
2142 
2143 	.rc.core = {
2144 		.rc_interval	= 100,
2145 		.rc_codes	= RC_MAP_D680_DMB,
2146 		.module_name	= KBUILD_MODNAME,
2147 		.rc_query       = cxusb_d680_dmb_rc_query,
2148 		.allowed_protos = RC_PROTO_BIT_UNKNOWN,
2149 	},
2150 
2151 	.num_device_descs = 1,
2152 	.devices = {
2153 		{
2154 			"Conexant DMB-TH Stick",
2155 			{ NULL },
2156 			{ &cxusb_table[CONEXANT_D680_DMB], NULL },
2157 		},
2158 	}
2159 };
2160 
2161 static struct dvb_usb_device_properties cxusb_mygica_d689_properties = {
2162 	.caps = DVB_USB_IS_AN_I2C_ADAPTER,
2163 
2164 	.usb_ctrl         = CYPRESS_FX2,
2165 
2166 	.size_of_priv     = sizeof(struct cxusb_state),
2167 
2168 	.num_adapters = 1,
2169 	.adapter = {
2170 		{
2171 		.num_frontends = 1,
2172 		.fe = {{
2173 			.streaming_ctrl   = cxusb_d680_dmb_streaming_ctrl,
2174 			.frontend_attach  = cxusb_mygica_d689_frontend_attach,
2175 			.tuner_attach     = cxusb_mygica_d689_tuner_attach,
2176 
2177 			/* parameter for the MPEG2-data transfer */
2178 			.stream = {
2179 				.type = USB_BULK,
2180 				.count = 5,
2181 				.endpoint = 0x02,
2182 				.u = {
2183 					.bulk = {
2184 						.buffersize = 8192,
2185 					}
2186 				}
2187 			},
2188 		}},
2189 		},
2190 	},
2191 
2192 	.power_ctrl       = cxusb_d680_dmb_power_ctrl,
2193 
2194 	.i2c_algo         = &cxusb_i2c_algo,
2195 
2196 	.generic_bulk_ctrl_endpoint = 0x01,
2197 
2198 	.rc.core = {
2199 		.rc_interval	= 100,
2200 		.rc_codes	= RC_MAP_D680_DMB,
2201 		.module_name	= KBUILD_MODNAME,
2202 		.rc_query       = cxusb_d680_dmb_rc_query,
2203 		.allowed_protos = RC_PROTO_BIT_UNKNOWN,
2204 	},
2205 
2206 	.num_device_descs = 1,
2207 	.devices = {
2208 		{
2209 			"Mygica D689 DMB-TH",
2210 			{ NULL },
2211 			{ &cxusb_table[MYGICA_D689], NULL },
2212 		},
2213 	}
2214 };
2215 
2216 static struct dvb_usb_device_properties cxusb_mygica_t230_properties = {
2217 	.caps = DVB_USB_IS_AN_I2C_ADAPTER,
2218 
2219 	.usb_ctrl         = CYPRESS_FX2,
2220 
2221 	.size_of_priv     = sizeof(struct cxusb_state),
2222 
2223 	.num_adapters = 1,
2224 	.adapter = {
2225 		{
2226 		.num_frontends = 1,
2227 		.fe = {{
2228 			.streaming_ctrl   = cxusb_streaming_ctrl,
2229 			.frontend_attach  = cxusb_mygica_t230_frontend_attach,
2230 
2231 			/* parameter for the MPEG2-data transfer */
2232 			.stream = {
2233 				.type = USB_BULK,
2234 				.count = 5,
2235 				.endpoint = 0x02,
2236 				.u = {
2237 					.bulk = {
2238 						.buffersize = 8192,
2239 					}
2240 				}
2241 			},
2242 		} },
2243 		},
2244 	},
2245 
2246 	.power_ctrl       = cxusb_d680_dmb_power_ctrl,
2247 
2248 	.i2c_algo         = &cxusb_i2c_algo,
2249 
2250 	.generic_bulk_ctrl_endpoint = 0x01,
2251 
2252 	.rc.core = {
2253 		.rc_interval	= 100,
2254 		.rc_codes	= RC_MAP_TOTAL_MEDIA_IN_HAND_02,
2255 		.module_name	= KBUILD_MODNAME,
2256 		.rc_query       = cxusb_d680_dmb_rc_query,
2257 		.allowed_protos = RC_PROTO_BIT_UNKNOWN,
2258 	},
2259 
2260 	.num_device_descs = 1,
2261 	.devices = {
2262 		{
2263 			"Mygica T230 DVB-T/T2/C",
2264 			{ NULL },
2265 			{ &cxusb_table[MYGICA_T230], NULL },
2266 		},
2267 	}
2268 };
2269 
2270 static struct dvb_usb_device_properties cxusb_mygica_t230c_properties = {
2271 	.caps = DVB_USB_IS_AN_I2C_ADAPTER,
2272 
2273 	.usb_ctrl         = CYPRESS_FX2,
2274 
2275 	.size_of_priv     = sizeof(struct cxusb_state),
2276 
2277 	.num_adapters = 1,
2278 	.adapter = {
2279 		{
2280 		.num_frontends = 1,
2281 		.fe = {{
2282 			.streaming_ctrl   = cxusb_streaming_ctrl,
2283 			.frontend_attach  = cxusb_mygica_t230c_frontend_attach,
2284 
2285 			/* parameter for the MPEG2-data transfer */
2286 			.stream = {
2287 				.type = USB_BULK,
2288 				.count = 5,
2289 				.endpoint = 0x02,
2290 				.u = {
2291 					.bulk = {
2292 						.buffersize = 8192,
2293 					}
2294 				}
2295 			},
2296 		} },
2297 		},
2298 	},
2299 
2300 	.power_ctrl       = cxusb_d680_dmb_power_ctrl,
2301 
2302 	.i2c_algo         = &cxusb_i2c_algo,
2303 
2304 	.generic_bulk_ctrl_endpoint = 0x01,
2305 
2306 	.rc.core = {
2307 		.rc_interval	= 100,
2308 		.rc_codes	= RC_MAP_TOTAL_MEDIA_IN_HAND_02,
2309 		.module_name	= KBUILD_MODNAME,
2310 		.rc_query       = cxusb_d680_dmb_rc_query,
2311 		.allowed_protos = RC_PROTO_BIT_UNKNOWN,
2312 	},
2313 
2314 	.num_device_descs = 1,
2315 	.devices = {
2316 		{
2317 			"Mygica T230C DVB-T/T2/C",
2318 			{ NULL },
2319 			{ &cxusb_table[MYGICA_T230C], NULL },
2320 		},
2321 	}
2322 };
2323 
2324 static struct usb_driver cxusb_driver = {
2325 	.name		= "dvb_usb_cxusb",
2326 	.probe		= cxusb_probe,
2327 	.disconnect     = cxusb_disconnect,
2328 	.id_table	= cxusb_table,
2329 };
2330 
2331 module_usb_driver(cxusb_driver);
2332 
2333 MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@posteo.de>");
2334 MODULE_AUTHOR("Michael Krufky <mkrufky@linuxtv.org>");
2335 MODULE_AUTHOR("Chris Pascoe <c.pascoe@itee.uq.edu.au>");
2336 MODULE_DESCRIPTION("Driver for Conexant USB2.0 hybrid reference design");
2337 MODULE_VERSION("1.0-alpha");
2338 MODULE_LICENSE("GPL");
2339