1 /* DVB USB compliant linux driver for Conexant USB reference design.
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.
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
14 * TODO: Use the cx25840-driver for the analogue part
16 * Copyright (C) 2005 Patrick Boettcher (patrick.boettcher@desy.de)
17 * Copyright (C) 2006 Michael Krufky (mkrufky@linuxtv.org)
18 * Copyright (C) 2006, 2007 Chris Pascoe (c.pascoe@itee.uq.edu.au)
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.
24 * see Documentation/dvb/README.dvb-usb for more information
26 #include <media/tuner.h>
33 #include "mt352_priv.h"
35 #include "tuner-xc2028.h"
36 #include "tuner-simple.h"
39 static int dvb_usb_cxusb_debug
;
40 module_param_named(debug
, dvb_usb_cxusb_debug
, int, 0644);
41 MODULE_PARM_DESC(debug
, "set debugging level (1=rc (or-able))." DVB_USB_DEBUG_STATUS
);
43 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr
);
45 #define deb_info(args...) dprintk(dvb_usb_cxusb_debug,0x01,args)
46 #define deb_i2c(args...) if (d->udev->descriptor.idVendor == USB_VID_MEDION) \
47 dprintk(dvb_usb_cxusb_debug,0x01,args)
49 static int cxusb_ctrl_msg(struct dvb_usb_device
*d
,
50 u8 cmd
, u8
*wbuf
, int wlen
, u8
*rbuf
, int rlen
)
52 int wo
= (rbuf
== NULL
|| rlen
== 0); /* write-only */
54 memset(sndbuf
, 0, 1+wlen
);
57 memcpy(&sndbuf
[1], wbuf
, wlen
);
59 return dvb_usb_generic_write(d
, sndbuf
, 1+wlen
);
61 return dvb_usb_generic_rw(d
, sndbuf
, 1+wlen
, rbuf
, rlen
, 0);
65 static void cxusb_gpio_tuner(struct dvb_usb_device
*d
, int onoff
)
67 struct cxusb_state
*st
= d
->priv
;
70 if (st
->gpio_write_state
[GPIO_TUNER
] == onoff
)
75 cxusb_ctrl_msg(d
, CMD_GPIO_WRITE
, o
, 2, &i
, 1);
78 deb_info("gpio_write failed.\n");
80 st
->gpio_write_state
[GPIO_TUNER
] = onoff
;
83 static int cxusb_bluebird_gpio_rw(struct dvb_usb_device
*d
, u8 changemask
,
89 o
[0] = 0xff & ~changemask
; /* mask of bits to keep */
90 o
[1] = newval
& changemask
; /* new values for bits */
92 rc
= cxusb_ctrl_msg(d
, CMD_BLUEBIRD_GPIO_RW
, o
, 2, &gpio_state
, 1);
93 if (rc
< 0 || (gpio_state
& changemask
) != (newval
& changemask
))
94 deb_info("bluebird_gpio_write failed.\n");
96 return rc
< 0 ? rc
: gpio_state
;
99 static void cxusb_bluebird_gpio_pulse(struct dvb_usb_device
*d
, u8 pin
, int low
)
101 cxusb_bluebird_gpio_rw(d
, pin
, low
? 0 : pin
);
103 cxusb_bluebird_gpio_rw(d
, pin
, low
? pin
: 0);
106 static void cxusb_nano2_led(struct dvb_usb_device
*d
, int onoff
)
108 cxusb_bluebird_gpio_rw(d
, 0x40, onoff
? 0 : 0x40);
112 static int cxusb_i2c_xfer(struct i2c_adapter
*adap
, struct i2c_msg msg
[],
115 struct dvb_usb_device
*d
= i2c_get_adapdata(adap
);
118 if (mutex_lock_interruptible(&d
->i2c_mutex
) < 0)
121 for (i
= 0; i
< num
; i
++) {
123 if (d
->udev
->descriptor
.idVendor
== USB_VID_MEDION
)
124 switch (msg
[i
].addr
) {
126 cxusb_gpio_tuner(d
, 0);
129 cxusb_gpio_tuner(d
, 1);
133 if (msg
[i
].flags
& I2C_M_RD
) {
135 u8 obuf
[3], ibuf
[1+msg
[i
].len
];
137 obuf
[1] = msg
[i
].len
;
138 obuf
[2] = msg
[i
].addr
;
139 if (cxusb_ctrl_msg(d
, CMD_I2C_READ
,
141 ibuf
, 1+msg
[i
].len
) < 0) {
142 warn("i2c read failed");
145 memcpy(msg
[i
].buf
, &ibuf
[1], msg
[i
].len
);
146 } else if (i
+1 < num
&& (msg
[i
+1].flags
& I2C_M_RD
) &&
147 msg
[i
].addr
== msg
[i
+1].addr
) {
148 /* write to then read from same address */
149 u8 obuf
[3+msg
[i
].len
], ibuf
[1+msg
[i
+1].len
];
150 obuf
[0] = msg
[i
].len
;
151 obuf
[1] = msg
[i
+1].len
;
152 obuf
[2] = msg
[i
].addr
;
153 memcpy(&obuf
[3], msg
[i
].buf
, msg
[i
].len
);
155 if (cxusb_ctrl_msg(d
, CMD_I2C_READ
,
157 ibuf
, 1+msg
[i
+1].len
) < 0)
161 deb_i2c("i2c read may have failed\n");
163 memcpy(msg
[i
+1].buf
, &ibuf
[1], msg
[i
+1].len
);
168 u8 obuf
[2+msg
[i
].len
], ibuf
;
169 obuf
[0] = msg
[i
].addr
;
170 obuf
[1] = msg
[i
].len
;
171 memcpy(&obuf
[2], msg
[i
].buf
, msg
[i
].len
);
173 if (cxusb_ctrl_msg(d
, CMD_I2C_WRITE
, obuf
,
174 2+msg
[i
].len
, &ibuf
,1) < 0)
177 deb_i2c("i2c write may have failed\n");
181 mutex_unlock(&d
->i2c_mutex
);
182 return i
== num
? num
: -EREMOTEIO
;
185 static u32
cxusb_i2c_func(struct i2c_adapter
*adapter
)
190 static struct i2c_algorithm cxusb_i2c_algo
= {
191 .master_xfer
= cxusb_i2c_xfer
,
192 .functionality
= cxusb_i2c_func
,
195 static int cxusb_power_ctrl(struct dvb_usb_device
*d
, int onoff
)
199 return cxusb_ctrl_msg(d
, CMD_POWER_ON
, &b
, 1, NULL
, 0);
201 return cxusb_ctrl_msg(d
, CMD_POWER_OFF
, &b
, 1, NULL
, 0);
204 static int cxusb_bluebird_power_ctrl(struct dvb_usb_device
*d
, int onoff
)
208 return cxusb_ctrl_msg(d
, CMD_POWER_ON
, &b
, 1, NULL
, 0);
213 static int cxusb_nano2_power_ctrl(struct dvb_usb_device
*d
, int onoff
)
217 rc
= cxusb_power_ctrl(d
, onoff
);
219 cxusb_nano2_led(d
, 0);
224 static int cxusb_streaming_ctrl(struct dvb_usb_adapter
*adap
, int onoff
)
226 u8 buf
[2] = { 0x03, 0x00 };
228 cxusb_ctrl_msg(adap
->dev
, CMD_STREAMING_ON
, buf
, 2, NULL
, 0);
230 cxusb_ctrl_msg(adap
->dev
, CMD_STREAMING_OFF
, NULL
, 0, NULL
, 0);
235 static int cxusb_rc_query(struct dvb_usb_device
*d
, u32
*event
, int *state
)
237 struct dvb_usb_rc_key
*keymap
= d
->props
.rc_key_map
;
241 cxusb_ctrl_msg(d
, CMD_GET_IR_CODE
, NULL
, 0, ircode
, 4);
244 *state
= REMOTE_NO_KEY_PRESSED
;
246 for (i
= 0; i
< d
->props
.rc_key_map_size
; i
++) {
247 if (keymap
[i
].custom
== ircode
[2] &&
248 keymap
[i
].data
== ircode
[3]) {
249 *event
= keymap
[i
].event
;
250 *state
= REMOTE_KEY_PRESSED
;
259 static int cxusb_bluebird2_rc_query(struct dvb_usb_device
*d
, u32
*event
,
262 struct dvb_usb_rc_key
*keymap
= d
->props
.rc_key_map
;
265 struct i2c_msg msg
= { .addr
= 0x6b, .flags
= I2C_M_RD
,
266 .buf
= ircode
, .len
= 4 };
269 *state
= REMOTE_NO_KEY_PRESSED
;
271 if (cxusb_i2c_xfer(&d
->i2c_adap
, &msg
, 1) != 1)
274 for (i
= 0; i
< d
->props
.rc_key_map_size
; i
++) {
275 if (keymap
[i
].custom
== ircode
[1] &&
276 keymap
[i
].data
== ircode
[2]) {
277 *event
= keymap
[i
].event
;
278 *state
= REMOTE_KEY_PRESSED
;
287 static struct dvb_usb_rc_key dvico_mce_rc_keys
[] = {
288 { 0xfe, 0x02, KEY_TV
},
289 { 0xfe, 0x0e, KEY_MP3
},
290 { 0xfe, 0x1a, KEY_DVD
},
291 { 0xfe, 0x1e, KEY_FAVORITES
},
292 { 0xfe, 0x16, KEY_SETUP
},
293 { 0xfe, 0x46, KEY_POWER2
},
294 { 0xfe, 0x0a, KEY_EPG
},
295 { 0xfe, 0x49, KEY_BACK
},
296 { 0xfe, 0x4d, KEY_MENU
},
297 { 0xfe, 0x51, KEY_UP
},
298 { 0xfe, 0x5b, KEY_LEFT
},
299 { 0xfe, 0x5f, KEY_RIGHT
},
300 { 0xfe, 0x53, KEY_DOWN
},
301 { 0xfe, 0x5e, KEY_OK
},
302 { 0xfe, 0x59, KEY_INFO
},
303 { 0xfe, 0x55, KEY_TAB
},
304 { 0xfe, 0x0f, KEY_PREVIOUSSONG
},/* Replay */
305 { 0xfe, 0x12, KEY_NEXTSONG
}, /* Skip */
306 { 0xfe, 0x42, KEY_ENTER
}, /* Windows/Start */
307 { 0xfe, 0x15, KEY_VOLUMEUP
},
308 { 0xfe, 0x05, KEY_VOLUMEDOWN
},
309 { 0xfe, 0x11, KEY_CHANNELUP
},
310 { 0xfe, 0x09, KEY_CHANNELDOWN
},
311 { 0xfe, 0x52, KEY_CAMERA
},
312 { 0xfe, 0x5a, KEY_TUNER
}, /* Live */
313 { 0xfe, 0x19, KEY_OPEN
},
314 { 0xfe, 0x0b, KEY_1
},
315 { 0xfe, 0x17, KEY_2
},
316 { 0xfe, 0x1b, KEY_3
},
317 { 0xfe, 0x07, KEY_4
},
318 { 0xfe, 0x50, KEY_5
},
319 { 0xfe, 0x54, KEY_6
},
320 { 0xfe, 0x48, KEY_7
},
321 { 0xfe, 0x4c, KEY_8
},
322 { 0xfe, 0x58, KEY_9
},
323 { 0xfe, 0x13, KEY_ANGLE
}, /* Aspect */
324 { 0xfe, 0x03, KEY_0
},
325 { 0xfe, 0x1f, KEY_ZOOM
},
326 { 0xfe, 0x43, KEY_REWIND
},
327 { 0xfe, 0x47, KEY_PLAYPAUSE
},
328 { 0xfe, 0x4f, KEY_FASTFORWARD
},
329 { 0xfe, 0x57, KEY_MUTE
},
330 { 0xfe, 0x0d, KEY_STOP
},
331 { 0xfe, 0x01, KEY_RECORD
},
332 { 0xfe, 0x4e, KEY_POWER
},
335 static struct dvb_usb_rc_key dvico_portable_rc_keys
[] = {
336 { 0xfc, 0x02, KEY_SETUP
}, /* Profile */
337 { 0xfc, 0x43, KEY_POWER2
},
338 { 0xfc, 0x06, KEY_EPG
},
339 { 0xfc, 0x5a, KEY_BACK
},
340 { 0xfc, 0x05, KEY_MENU
},
341 { 0xfc, 0x47, KEY_INFO
},
342 { 0xfc, 0x01, KEY_TAB
},
343 { 0xfc, 0x42, KEY_PREVIOUSSONG
},/* Replay */
344 { 0xfc, 0x49, KEY_VOLUMEUP
},
345 { 0xfc, 0x09, KEY_VOLUMEDOWN
},
346 { 0xfc, 0x54, KEY_CHANNELUP
},
347 { 0xfc, 0x0b, KEY_CHANNELDOWN
},
348 { 0xfc, 0x16, KEY_CAMERA
},
349 { 0xfc, 0x40, KEY_TUNER
}, /* ATV/DTV */
350 { 0xfc, 0x45, KEY_OPEN
},
351 { 0xfc, 0x19, KEY_1
},
352 { 0xfc, 0x18, KEY_2
},
353 { 0xfc, 0x1b, KEY_3
},
354 { 0xfc, 0x1a, KEY_4
},
355 { 0xfc, 0x58, KEY_5
},
356 { 0xfc, 0x59, KEY_6
},
357 { 0xfc, 0x15, KEY_7
},
358 { 0xfc, 0x14, KEY_8
},
359 { 0xfc, 0x17, KEY_9
},
360 { 0xfc, 0x44, KEY_ANGLE
}, /* Aspect */
361 { 0xfc, 0x55, KEY_0
},
362 { 0xfc, 0x07, KEY_ZOOM
},
363 { 0xfc, 0x0a, KEY_REWIND
},
364 { 0xfc, 0x08, KEY_PLAYPAUSE
},
365 { 0xfc, 0x4b, KEY_FASTFORWARD
},
366 { 0xfc, 0x5b, KEY_MUTE
},
367 { 0xfc, 0x04, KEY_STOP
},
368 { 0xfc, 0x56, KEY_RECORD
},
369 { 0xfc, 0x57, KEY_POWER
},
370 { 0xfc, 0x41, KEY_UNKNOWN
}, /* INPUT */
371 { 0xfc, 0x00, KEY_UNKNOWN
}, /* HD */
374 static int cxusb_dee1601_demod_init(struct dvb_frontend
* fe
)
376 static u8 clock_config
[] = { CLOCK_CTL
, 0x38, 0x28 };
377 static u8 reset
[] = { RESET
, 0x80 };
378 static u8 adc_ctl_1_cfg
[] = { ADC_CTL_1
, 0x40 };
379 static u8 agc_cfg
[] = { AGC_TARGET
, 0x28, 0x20 };
380 static u8 gpp_ctl_cfg
[] = { GPP_CTL
, 0x33 };
381 static u8 capt_range_cfg
[] = { CAPT_RANGE
, 0x32 };
383 mt352_write(fe
, clock_config
, sizeof(clock_config
));
385 mt352_write(fe
, reset
, sizeof(reset
));
386 mt352_write(fe
, adc_ctl_1_cfg
, sizeof(adc_ctl_1_cfg
));
388 mt352_write(fe
, agc_cfg
, sizeof(agc_cfg
));
389 mt352_write(fe
, gpp_ctl_cfg
, sizeof(gpp_ctl_cfg
));
390 mt352_write(fe
, capt_range_cfg
, sizeof(capt_range_cfg
));
395 static int cxusb_mt352_demod_init(struct dvb_frontend
* fe
)
396 { /* used in both lgz201 and th7579 */
397 static u8 clock_config
[] = { CLOCK_CTL
, 0x38, 0x29 };
398 static u8 reset
[] = { RESET
, 0x80 };
399 static u8 adc_ctl_1_cfg
[] = { ADC_CTL_1
, 0x40 };
400 static u8 agc_cfg
[] = { AGC_TARGET
, 0x24, 0x20 };
401 static u8 gpp_ctl_cfg
[] = { GPP_CTL
, 0x33 };
402 static u8 capt_range_cfg
[] = { CAPT_RANGE
, 0x32 };
404 mt352_write(fe
, clock_config
, sizeof(clock_config
));
406 mt352_write(fe
, reset
, sizeof(reset
));
407 mt352_write(fe
, adc_ctl_1_cfg
, sizeof(adc_ctl_1_cfg
));
409 mt352_write(fe
, agc_cfg
, sizeof(agc_cfg
));
410 mt352_write(fe
, gpp_ctl_cfg
, sizeof(gpp_ctl_cfg
));
411 mt352_write(fe
, capt_range_cfg
, sizeof(capt_range_cfg
));
415 static struct cx22702_config cxusb_cx22702_config
= {
416 .demod_address
= 0x63,
417 .output_mode
= CX22702_PARALLEL_OUTPUT
,
420 static struct lgdt330x_config cxusb_lgdt3303_config
= {
421 .demod_address
= 0x0e,
422 .demod_chip
= LGDT3303
,
425 static struct mt352_config cxusb_dee1601_config
= {
426 .demod_address
= 0x0f,
427 .demod_init
= cxusb_dee1601_demod_init
,
430 static struct zl10353_config cxusb_zl10353_dee1601_config
= {
431 .demod_address
= 0x0f,
435 static struct mt352_config cxusb_mt352_config
= {
436 /* used in both lgz201 and th7579 */
437 .demod_address
= 0x0f,
438 .demod_init
= cxusb_mt352_demod_init
,
441 static struct zl10353_config cxusb_zl10353_xc3028_config
= {
442 .demod_address
= 0x0f,
448 static struct mt352_config cxusb_mt352_xc3028_config
= {
449 .demod_address
= 0x0f,
452 .demod_init
= cxusb_mt352_demod_init
,
455 /* Callbacks for DVB USB */
456 static int cxusb_fmd1216me_tuner_attach(struct dvb_usb_adapter
*adap
)
458 dvb_attach(simple_tuner_attach
, adap
->fe
,
459 &adap
->dev
->i2c_adap
, 0x61,
460 TUNER_PHILIPS_FMD1216ME_MK3
);
464 static int cxusb_dee1601_tuner_attach(struct dvb_usb_adapter
*adap
)
466 dvb_attach(dvb_pll_attach
, adap
->fe
, 0x61,
467 NULL
, DVB_PLL_THOMSON_DTT7579
);
471 static int cxusb_lgz201_tuner_attach(struct dvb_usb_adapter
*adap
)
473 dvb_attach(dvb_pll_attach
, adap
->fe
, 0x61, NULL
, DVB_PLL_LG_Z201
);
477 static int cxusb_dtt7579_tuner_attach(struct dvb_usb_adapter
*adap
)
479 dvb_attach(dvb_pll_attach
, adap
->fe
, 0x60,
480 NULL
, DVB_PLL_THOMSON_DTT7579
);
484 static int cxusb_lgh064f_tuner_attach(struct dvb_usb_adapter
*adap
)
486 dvb_attach(simple_tuner_attach
, adap
->fe
,
487 &adap
->dev
->i2c_adap
, 0x61, TUNER_LG_TDVS_H06XF
);
491 static int dvico_bluebird_xc2028_callback(void *ptr
, int command
, int arg
)
493 struct dvb_usb_device
*d
= ptr
;
496 case XC2028_TUNER_RESET
:
497 deb_info("%s: XC2028_TUNER_RESET %d\n", __func__
, arg
);
498 cxusb_bluebird_gpio_pulse(d
, 0x01, 1);
500 case XC2028_RESET_CLK
:
501 deb_info("%s: XC2028_RESET_CLK %d\n", __func__
, arg
);
504 deb_info("%s: unknown command %d, arg %d\n", __func__
,
512 static int cxusb_dvico_xc3028_tuner_attach(struct dvb_usb_adapter
*adap
)
514 struct dvb_frontend
*fe
;
515 struct xc2028_config cfg
= {
516 .i2c_adap
= &adap
->dev
->i2c_adap
,
518 .callback
= dvico_bluebird_xc2028_callback
,
520 static struct xc2028_ctrl ctl
= {
521 .fname
= "xc3028-dvico-au-01.fw",
523 .scode_table
= XC3028_FE_ZARLINK456
,
526 fe
= dvb_attach(xc2028_attach
, adap
->fe
, &cfg
);
527 if (fe
== NULL
|| fe
->ops
.tuner_ops
.set_config
== NULL
)
530 fe
->ops
.tuner_ops
.set_config(fe
, &ctl
);
535 static int cxusb_cx22702_frontend_attach(struct dvb_usb_adapter
*adap
)
538 if (usb_set_interface(adap
->dev
->udev
, 0, 6) < 0)
539 err("set interface failed");
541 cxusb_ctrl_msg(adap
->dev
, CMD_DIGITAL
, NULL
, 0, &b
, 1);
543 if ((adap
->fe
= dvb_attach(cx22702_attach
, &cxusb_cx22702_config
,
544 &adap
->dev
->i2c_adap
)) != NULL
)
550 static int cxusb_lgdt3303_frontend_attach(struct dvb_usb_adapter
*adap
)
552 if (usb_set_interface(adap
->dev
->udev
, 0, 7) < 0)
553 err("set interface failed");
555 cxusb_ctrl_msg(adap
->dev
, CMD_DIGITAL
, NULL
, 0, NULL
, 0);
557 if ((adap
->fe
= dvb_attach(lgdt330x_attach
, &cxusb_lgdt3303_config
,
558 &adap
->dev
->i2c_adap
)) != NULL
)
564 static int cxusb_mt352_frontend_attach(struct dvb_usb_adapter
*adap
)
566 /* used in both lgz201 and th7579 */
567 if (usb_set_interface(adap
->dev
->udev
, 0, 0) < 0)
568 err("set interface failed");
570 cxusb_ctrl_msg(adap
->dev
, CMD_DIGITAL
, NULL
, 0, NULL
, 0);
572 if ((adap
->fe
= dvb_attach(mt352_attach
, &cxusb_mt352_config
,
573 &adap
->dev
->i2c_adap
)) != NULL
)
579 static int cxusb_dee1601_frontend_attach(struct dvb_usb_adapter
*adap
)
581 if (usb_set_interface(adap
->dev
->udev
, 0, 0) < 0)
582 err("set interface failed");
584 cxusb_ctrl_msg(adap
->dev
, CMD_DIGITAL
, NULL
, 0, NULL
, 0);
586 if (((adap
->fe
= dvb_attach(mt352_attach
, &cxusb_dee1601_config
,
587 &adap
->dev
->i2c_adap
)) != NULL
) ||
588 ((adap
->fe
= dvb_attach(zl10353_attach
,
589 &cxusb_zl10353_dee1601_config
,
590 &adap
->dev
->i2c_adap
)) != NULL
))
596 static int cxusb_dualdig4_frontend_attach(struct dvb_usb_adapter
*adap
)
600 struct i2c_msg msg
= { .addr
= 0x6b, .flags
= I2C_M_RD
,
601 .buf
= ircode
, .len
= 4 };
603 if (usb_set_interface(adap
->dev
->udev
, 0, 1) < 0)
604 err("set interface failed");
606 cxusb_ctrl_msg(adap
->dev
, CMD_DIGITAL
, NULL
, 0, NULL
, 0);
608 /* reset the tuner and demodulator */
609 cxusb_bluebird_gpio_rw(adap
->dev
, 0x04, 0);
610 cxusb_bluebird_gpio_pulse(adap
->dev
, 0x01, 1);
611 cxusb_bluebird_gpio_pulse(adap
->dev
, 0x02, 1);
613 if ((adap
->fe
= dvb_attach(zl10353_attach
,
614 &cxusb_zl10353_xc3028_config
,
615 &adap
->dev
->i2c_adap
)) == NULL
)
618 /* try to determine if there is no IR decoder on the I2C bus */
619 for (i
= 0; adap
->dev
->props
.rc_key_map
!= NULL
&& i
< 5; i
++) {
621 if (cxusb_i2c_xfer(&adap
->dev
->i2c_adap
, &msg
, 1) != 1)
623 if (ircode
[0] == 0 && ircode
[1] == 0)
625 if (ircode
[2] + ircode
[3] != 0xff) {
627 adap
->dev
->props
.rc_key_map
= NULL
;
628 info("No IR receiver detected on this device.");
636 static int cxusb_nano2_frontend_attach(struct dvb_usb_adapter
*adap
)
638 if (usb_set_interface(adap
->dev
->udev
, 0, 1) < 0)
639 err("set interface failed");
641 cxusb_ctrl_msg(adap
->dev
, CMD_DIGITAL
, NULL
, 0, NULL
, 0);
643 /* reset the tuner and demodulator */
644 cxusb_bluebird_gpio_rw(adap
->dev
, 0x04, 0);
645 cxusb_bluebird_gpio_pulse(adap
->dev
, 0x01, 1);
646 cxusb_bluebird_gpio_pulse(adap
->dev
, 0x02, 1);
648 if ((adap
->fe
= dvb_attach(zl10353_attach
,
649 &cxusb_zl10353_xc3028_config
,
650 &adap
->dev
->i2c_adap
)) != NULL
)
653 if ((adap
->fe
= dvb_attach(mt352_attach
,
654 &cxusb_mt352_xc3028_config
,
655 &adap
->dev
->i2c_adap
)) != NULL
)
662 * DViCO has shipped two devices with the same USB ID, but only one of them
663 * needs a firmware download. Check the device class details to see if they
664 * have non-default values to decide whether the device is actually cold or
665 * not, and forget a match if it turns out we selected the wrong device.
667 static int bluebird_fx2_identify_state(struct usb_device
*udev
,
668 struct dvb_usb_device_properties
*props
,
669 struct dvb_usb_device_description
**desc
,
674 *cold
= udev
->descriptor
.bDeviceClass
== 0xff &&
675 udev
->descriptor
.bDeviceSubClass
== 0xff &&
676 udev
->descriptor
.bDeviceProtocol
== 0xff;
678 if (*cold
&& !wascold
)
685 * DViCO bluebird firmware needs the "warm" product ID to be patched into the
686 * firmware file before download.
689 static const int dvico_firmware_id_offsets
[] = { 6638, 3204 };
690 static int bluebird_patch_dvico_firmware_download(struct usb_device
*udev
,
691 const struct firmware
*fw
)
695 for (pos
= 0; pos
< ARRAY_SIZE(dvico_firmware_id_offsets
); pos
++) {
696 int idoff
= dvico_firmware_id_offsets
[pos
];
698 if (fw
->size
< idoff
+ 4)
701 if (fw
->data
[idoff
] == (USB_VID_DVICO
& 0xff) &&
702 fw
->data
[idoff
+ 1] == USB_VID_DVICO
>> 8) {
703 fw
->data
[idoff
+ 2] =
704 le16_to_cpu(udev
->descriptor
.idProduct
) + 1;
705 fw
->data
[idoff
+ 3] =
706 le16_to_cpu(udev
->descriptor
.idProduct
) >> 8;
708 return usb_cypress_load_firmware(udev
, fw
, CYPRESS_FX2
);
715 /* DVB USB Driver stuff */
716 static struct dvb_usb_device_properties cxusb_medion_properties
;
717 static struct dvb_usb_device_properties cxusb_bluebird_lgh064f_properties
;
718 static struct dvb_usb_device_properties cxusb_bluebird_dee1601_properties
;
719 static struct dvb_usb_device_properties cxusb_bluebird_lgz201_properties
;
720 static struct dvb_usb_device_properties cxusb_bluebird_dtt7579_properties
;
721 static struct dvb_usb_device_properties cxusb_bluebird_dualdig4_properties
;
722 static struct dvb_usb_device_properties cxusb_bluebird_nano2_properties
;
723 static struct dvb_usb_device_properties cxusb_bluebird_nano2_needsfirmware_properties
;
725 static int cxusb_probe(struct usb_interface
*intf
,
726 const struct usb_device_id
*id
)
728 if (0 == dvb_usb_device_init(intf
, &cxusb_medion_properties
,
729 THIS_MODULE
, NULL
, adapter_nr
) ||
730 0 == dvb_usb_device_init(intf
, &cxusb_bluebird_lgh064f_properties
,
731 THIS_MODULE
, NULL
, adapter_nr
) ||
732 0 == dvb_usb_device_init(intf
, &cxusb_bluebird_dee1601_properties
,
733 THIS_MODULE
, NULL
, adapter_nr
) ||
734 0 == dvb_usb_device_init(intf
, &cxusb_bluebird_lgz201_properties
,
735 THIS_MODULE
, NULL
, adapter_nr
) ||
736 0 == dvb_usb_device_init(intf
, &cxusb_bluebird_dtt7579_properties
,
737 THIS_MODULE
, NULL
, adapter_nr
) ||
738 0 == dvb_usb_device_init(intf
, &cxusb_bluebird_dualdig4_properties
,
739 THIS_MODULE
, NULL
, adapter_nr
) ||
740 0 == dvb_usb_device_init(intf
, &cxusb_bluebird_nano2_properties
,
741 THIS_MODULE
, NULL
, adapter_nr
) ||
742 0 == dvb_usb_device_init(intf
,
743 &cxusb_bluebird_nano2_needsfirmware_properties
,
744 THIS_MODULE
, NULL
, adapter_nr
))
750 static struct usb_device_id cxusb_table
[] = {
751 { USB_DEVICE(USB_VID_MEDION
, USB_PID_MEDION_MD95700
) },
752 { USB_DEVICE(USB_VID_DVICO
, USB_PID_DVICO_BLUEBIRD_LG064F_COLD
) },
753 { USB_DEVICE(USB_VID_DVICO
, USB_PID_DVICO_BLUEBIRD_LG064F_WARM
) },
754 { USB_DEVICE(USB_VID_DVICO
, USB_PID_DVICO_BLUEBIRD_DUAL_1_COLD
) },
755 { USB_DEVICE(USB_VID_DVICO
, USB_PID_DVICO_BLUEBIRD_DUAL_1_WARM
) },
756 { USB_DEVICE(USB_VID_DVICO
, USB_PID_DVICO_BLUEBIRD_LGZ201_COLD
) },
757 { USB_DEVICE(USB_VID_DVICO
, USB_PID_DVICO_BLUEBIRD_LGZ201_WARM
) },
758 { USB_DEVICE(USB_VID_DVICO
, USB_PID_DVICO_BLUEBIRD_TH7579_COLD
) },
759 { USB_DEVICE(USB_VID_DVICO
, USB_PID_DVICO_BLUEBIRD_TH7579_WARM
) },
760 { USB_DEVICE(USB_VID_DVICO
, USB_PID_DIGITALNOW_BLUEBIRD_DUAL_1_COLD
) },
761 { USB_DEVICE(USB_VID_DVICO
, USB_PID_DIGITALNOW_BLUEBIRD_DUAL_1_WARM
) },
762 { USB_DEVICE(USB_VID_DVICO
, USB_PID_DVICO_BLUEBIRD_DUAL_2_COLD
) },
763 { USB_DEVICE(USB_VID_DVICO
, USB_PID_DVICO_BLUEBIRD_DUAL_2_WARM
) },
764 { USB_DEVICE(USB_VID_DVICO
, USB_PID_DVICO_BLUEBIRD_DUAL_4
) },
765 { USB_DEVICE(USB_VID_DVICO
, USB_PID_DVICO_BLUEBIRD_DVB_T_NANO_2
) },
766 { USB_DEVICE(USB_VID_DVICO
, USB_PID_DVICO_BLUEBIRD_DVB_T_NANO_2_NFW_WARM
) },
767 {} /* Terminating entry */
769 MODULE_DEVICE_TABLE (usb
, cxusb_table
);
771 static struct dvb_usb_device_properties cxusb_medion_properties
= {
772 .caps
= DVB_USB_IS_AN_I2C_ADAPTER
,
774 .usb_ctrl
= CYPRESS_FX2
,
776 .size_of_priv
= sizeof(struct cxusb_state
),
781 .streaming_ctrl
= cxusb_streaming_ctrl
,
782 .frontend_attach
= cxusb_cx22702_frontend_attach
,
783 .tuner_attach
= cxusb_fmd1216me_tuner_attach
,
784 /* parameter for the MPEG2-data transfer */
798 .power_ctrl
= cxusb_power_ctrl
,
800 .i2c_algo
= &cxusb_i2c_algo
,
802 .generic_bulk_ctrl_endpoint
= 0x01,
804 .num_device_descs
= 1,
806 { "Medion MD95700 (MDUSBTV-HYBRID)",
808 { &cxusb_table
[0], NULL
},
813 static struct dvb_usb_device_properties cxusb_bluebird_lgh064f_properties
= {
814 .caps
= DVB_USB_IS_AN_I2C_ADAPTER
,
816 .usb_ctrl
= DEVICE_SPECIFIC
,
817 .firmware
= "dvb-usb-bluebird-01.fw",
818 .download_firmware
= bluebird_patch_dvico_firmware_download
,
819 /* use usb alt setting 0 for EP4 transfer (dvb-t),
820 use usb alt setting 7 for EP2 transfer (atsc) */
822 .size_of_priv
= sizeof(struct cxusb_state
),
827 .streaming_ctrl
= cxusb_streaming_ctrl
,
828 .frontend_attach
= cxusb_lgdt3303_frontend_attach
,
829 .tuner_attach
= cxusb_lgh064f_tuner_attach
,
831 /* parameter for the MPEG2-data transfer */
845 .power_ctrl
= cxusb_bluebird_power_ctrl
,
847 .i2c_algo
= &cxusb_i2c_algo
,
850 .rc_key_map
= dvico_portable_rc_keys
,
851 .rc_key_map_size
= ARRAY_SIZE(dvico_portable_rc_keys
),
852 .rc_query
= cxusb_rc_query
,
854 .generic_bulk_ctrl_endpoint
= 0x01,
856 .num_device_descs
= 1,
858 { "DViCO FusionHDTV5 USB Gold",
859 { &cxusb_table
[1], NULL
},
860 { &cxusb_table
[2], NULL
},
865 static struct dvb_usb_device_properties cxusb_bluebird_dee1601_properties
= {
866 .caps
= DVB_USB_IS_AN_I2C_ADAPTER
,
868 .usb_ctrl
= DEVICE_SPECIFIC
,
869 .firmware
= "dvb-usb-bluebird-01.fw",
870 .download_firmware
= bluebird_patch_dvico_firmware_download
,
871 /* use usb alt setting 0 for EP4 transfer (dvb-t),
872 use usb alt setting 7 for EP2 transfer (atsc) */
874 .size_of_priv
= sizeof(struct cxusb_state
),
879 .streaming_ctrl
= cxusb_streaming_ctrl
,
880 .frontend_attach
= cxusb_dee1601_frontend_attach
,
881 .tuner_attach
= cxusb_dee1601_tuner_attach
,
882 /* parameter for the MPEG2-data transfer */
896 .power_ctrl
= cxusb_bluebird_power_ctrl
,
898 .i2c_algo
= &cxusb_i2c_algo
,
901 .rc_key_map
= dvico_mce_rc_keys
,
902 .rc_key_map_size
= ARRAY_SIZE(dvico_mce_rc_keys
),
903 .rc_query
= cxusb_rc_query
,
905 .generic_bulk_ctrl_endpoint
= 0x01,
907 .num_device_descs
= 3,
909 { "DViCO FusionHDTV DVB-T Dual USB",
910 { &cxusb_table
[3], NULL
},
911 { &cxusb_table
[4], NULL
},
913 { "DigitalNow DVB-T Dual USB",
914 { &cxusb_table
[9], NULL
},
915 { &cxusb_table
[10], NULL
},
917 { "DViCO FusionHDTV DVB-T Dual Digital 2",
918 { &cxusb_table
[11], NULL
},
919 { &cxusb_table
[12], NULL
},
924 static struct dvb_usb_device_properties cxusb_bluebird_lgz201_properties
= {
925 .caps
= DVB_USB_IS_AN_I2C_ADAPTER
,
927 .usb_ctrl
= DEVICE_SPECIFIC
,
928 .firmware
= "dvb-usb-bluebird-01.fw",
929 .download_firmware
= bluebird_patch_dvico_firmware_download
,
930 /* use usb alt setting 0 for EP4 transfer (dvb-t),
931 use usb alt setting 7 for EP2 transfer (atsc) */
933 .size_of_priv
= sizeof(struct cxusb_state
),
938 .streaming_ctrl
= cxusb_streaming_ctrl
,
939 .frontend_attach
= cxusb_mt352_frontend_attach
,
940 .tuner_attach
= cxusb_lgz201_tuner_attach
,
942 /* parameter for the MPEG2-data transfer */
955 .power_ctrl
= cxusb_bluebird_power_ctrl
,
957 .i2c_algo
= &cxusb_i2c_algo
,
960 .rc_key_map
= dvico_portable_rc_keys
,
961 .rc_key_map_size
= ARRAY_SIZE(dvico_portable_rc_keys
),
962 .rc_query
= cxusb_rc_query
,
964 .generic_bulk_ctrl_endpoint
= 0x01,
965 .num_device_descs
= 1,
967 { "DViCO FusionHDTV DVB-T USB (LGZ201)",
968 { &cxusb_table
[5], NULL
},
969 { &cxusb_table
[6], NULL
},
974 static struct dvb_usb_device_properties cxusb_bluebird_dtt7579_properties
= {
975 .caps
= DVB_USB_IS_AN_I2C_ADAPTER
,
977 .usb_ctrl
= DEVICE_SPECIFIC
,
978 .firmware
= "dvb-usb-bluebird-01.fw",
979 .download_firmware
= bluebird_patch_dvico_firmware_download
,
980 /* use usb alt setting 0 for EP4 transfer (dvb-t),
981 use usb alt setting 7 for EP2 transfer (atsc) */
983 .size_of_priv
= sizeof(struct cxusb_state
),
988 .streaming_ctrl
= cxusb_streaming_ctrl
,
989 .frontend_attach
= cxusb_mt352_frontend_attach
,
990 .tuner_attach
= cxusb_dtt7579_tuner_attach
,
992 /* parameter for the MPEG2-data transfer */
1005 .power_ctrl
= cxusb_bluebird_power_ctrl
,
1007 .i2c_algo
= &cxusb_i2c_algo
,
1010 .rc_key_map
= dvico_portable_rc_keys
,
1011 .rc_key_map_size
= ARRAY_SIZE(dvico_portable_rc_keys
),
1012 .rc_query
= cxusb_rc_query
,
1014 .generic_bulk_ctrl_endpoint
= 0x01,
1016 .num_device_descs
= 1,
1018 { "DViCO FusionHDTV DVB-T USB (TH7579)",
1019 { &cxusb_table
[7], NULL
},
1020 { &cxusb_table
[8], NULL
},
1025 static struct dvb_usb_device_properties cxusb_bluebird_dualdig4_properties
= {
1026 .caps
= DVB_USB_IS_AN_I2C_ADAPTER
,
1028 .usb_ctrl
= CYPRESS_FX2
,
1030 .size_of_priv
= sizeof(struct cxusb_state
),
1035 .streaming_ctrl
= cxusb_streaming_ctrl
,
1036 .frontend_attach
= cxusb_dualdig4_frontend_attach
,
1037 .tuner_attach
= cxusb_dvico_xc3028_tuner_attach
,
1038 /* parameter for the MPEG2-data transfer */
1052 .power_ctrl
= cxusb_power_ctrl
,
1054 .i2c_algo
= &cxusb_i2c_algo
,
1056 .generic_bulk_ctrl_endpoint
= 0x01,
1059 .rc_key_map
= dvico_mce_rc_keys
,
1060 .rc_key_map_size
= ARRAY_SIZE(dvico_mce_rc_keys
),
1061 .rc_query
= cxusb_bluebird2_rc_query
,
1063 .num_device_descs
= 1,
1065 { "DViCO FusionHDTV DVB-T Dual Digital 4",
1067 { &cxusb_table
[13], NULL
},
1072 static struct dvb_usb_device_properties cxusb_bluebird_nano2_properties
= {
1073 .caps
= DVB_USB_IS_AN_I2C_ADAPTER
,
1075 .usb_ctrl
= CYPRESS_FX2
,
1076 .identify_state
= bluebird_fx2_identify_state
,
1078 .size_of_priv
= sizeof(struct cxusb_state
),
1083 .streaming_ctrl
= cxusb_streaming_ctrl
,
1084 .frontend_attach
= cxusb_nano2_frontend_attach
,
1085 .tuner_attach
= cxusb_dvico_xc3028_tuner_attach
,
1086 /* parameter for the MPEG2-data transfer */
1100 .power_ctrl
= cxusb_nano2_power_ctrl
,
1102 .i2c_algo
= &cxusb_i2c_algo
,
1104 .generic_bulk_ctrl_endpoint
= 0x01,
1107 .rc_key_map
= dvico_portable_rc_keys
,
1108 .rc_key_map_size
= ARRAY_SIZE(dvico_portable_rc_keys
),
1109 .rc_query
= cxusb_bluebird2_rc_query
,
1111 .num_device_descs
= 1,
1113 { "DViCO FusionHDTV DVB-T NANO2",
1115 { &cxusb_table
[14], NULL
},
1120 static struct dvb_usb_device_properties cxusb_bluebird_nano2_needsfirmware_properties
= {
1121 .caps
= DVB_USB_IS_AN_I2C_ADAPTER
,
1123 .usb_ctrl
= DEVICE_SPECIFIC
,
1124 .firmware
= "dvb-usb-bluebird-02.fw",
1125 .download_firmware
= bluebird_patch_dvico_firmware_download
,
1126 .identify_state
= bluebird_fx2_identify_state
,
1128 .size_of_priv
= sizeof(struct cxusb_state
),
1133 .streaming_ctrl
= cxusb_streaming_ctrl
,
1134 .frontend_attach
= cxusb_nano2_frontend_attach
,
1135 .tuner_attach
= cxusb_dvico_xc3028_tuner_attach
,
1136 /* parameter for the MPEG2-data transfer */
1150 .power_ctrl
= cxusb_nano2_power_ctrl
,
1152 .i2c_algo
= &cxusb_i2c_algo
,
1154 .generic_bulk_ctrl_endpoint
= 0x01,
1157 .rc_key_map
= dvico_portable_rc_keys
,
1158 .rc_key_map_size
= ARRAY_SIZE(dvico_portable_rc_keys
),
1159 .rc_query
= cxusb_rc_query
,
1161 .num_device_descs
= 1,
1163 { "DViCO FusionHDTV DVB-T NANO2 w/o firmware",
1164 { &cxusb_table
[14], NULL
},
1165 { &cxusb_table
[15], NULL
},
1170 static struct usb_driver cxusb_driver
= {
1171 .name
= "dvb_usb_cxusb",
1172 .probe
= cxusb_probe
,
1173 .disconnect
= dvb_usb_device_exit
,
1174 .id_table
= cxusb_table
,
1178 static int __init
cxusb_module_init(void)
1181 if ((result
= usb_register(&cxusb_driver
))) {
1182 err("usb_register failed. Error number %d",result
);
1189 static void __exit
cxusb_module_exit(void)
1191 /* deregister this driver from the USB subsystem */
1192 usb_deregister(&cxusb_driver
);
1195 module_init (cxusb_module_init
);
1196 module_exit (cxusb_module_exit
);
1198 MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>");
1199 MODULE_AUTHOR("Michael Krufky <mkrufky@linuxtv.org>");
1200 MODULE_AUTHOR("Chris Pascoe <c.pascoe@itee.uq.edu.au>");
1201 MODULE_DESCRIPTION("Driver for Conexant USB2.0 hybrid reference design");
1202 MODULE_VERSION("1.0-alpha");
1203 MODULE_LICENSE("GPL");