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
31 #include "mt352_priv.h"
33 #include "tuner-xc2028.h"
34 #include "tuner-xc2028-types.h"
37 static int dvb_usb_cxusb_debug
;
38 module_param_named(debug
, dvb_usb_cxusb_debug
, int, 0644);
39 MODULE_PARM_DESC(debug
, "set debugging level (1=rc (or-able))." DVB_USB_DEBUG_STATUS
);
40 #define deb_info(args...) dprintk(dvb_usb_cxusb_debug,0x01,args)
41 #define deb_i2c(args...) if (d->udev->descriptor.idVendor == USB_VID_MEDION) \
42 dprintk(dvb_usb_cxusb_debug,0x01,args)
44 static int cxusb_ctrl_msg(struct dvb_usb_device
*d
,
45 u8 cmd
, u8
*wbuf
, int wlen
, u8
*rbuf
, int rlen
)
47 int wo
= (rbuf
== NULL
|| rlen
== 0); /* write-only */
49 memset(sndbuf
, 0, 1+wlen
);
52 memcpy(&sndbuf
[1], wbuf
, wlen
);
54 return dvb_usb_generic_write(d
, sndbuf
, 1+wlen
);
56 return dvb_usb_generic_rw(d
, sndbuf
, 1+wlen
, rbuf
, rlen
, 0);
60 static void cxusb_gpio_tuner(struct dvb_usb_device
*d
, int onoff
)
62 struct cxusb_state
*st
= d
->priv
;
65 if (st
->gpio_write_state
[GPIO_TUNER
] == onoff
)
70 cxusb_ctrl_msg(d
, CMD_GPIO_WRITE
, o
, 2, &i
, 1);
73 deb_info("gpio_write failed.\n");
75 st
->gpio_write_state
[GPIO_TUNER
] = onoff
;
78 static int cxusb_bluebird_gpio_rw(struct dvb_usb_device
*d
, u8 changemask
,
84 o
[0] = 0xff & ~changemask
; /* mask of bits to keep */
85 o
[1] = newval
& changemask
; /* new values for bits */
87 rc
= cxusb_ctrl_msg(d
, CMD_BLUEBIRD_GPIO_RW
, o
, 2, &gpio_state
, 1);
88 if (rc
< 0 || (gpio_state
& changemask
) != (newval
& changemask
))
89 deb_info("bluebird_gpio_write failed.\n");
91 return rc
< 0 ? rc
: gpio_state
;
94 static void cxusb_bluebird_gpio_pulse(struct dvb_usb_device
*d
, u8 pin
, int low
)
96 cxusb_bluebird_gpio_rw(d
, pin
, low
? 0 : pin
);
98 cxusb_bluebird_gpio_rw(d
, pin
, low
? pin
: 0);
101 static void cxusb_nano2_led(struct dvb_usb_device
*d
, int onoff
)
103 cxusb_bluebird_gpio_rw(d
, 0x40, onoff
? 0 : 0x40);
107 static int cxusb_i2c_xfer(struct i2c_adapter
*adap
, struct i2c_msg msg
[],
110 struct dvb_usb_device
*d
= i2c_get_adapdata(adap
);
113 if (mutex_lock_interruptible(&d
->i2c_mutex
) < 0)
116 for (i
= 0; i
< num
; i
++) {
118 if (d
->udev
->descriptor
.idVendor
== USB_VID_MEDION
)
119 switch (msg
[i
].addr
) {
121 cxusb_gpio_tuner(d
, 0);
124 cxusb_gpio_tuner(d
, 1);
128 if (msg
[i
].flags
& I2C_M_RD
) {
130 u8 obuf
[3], ibuf
[1+msg
[i
].len
];
132 obuf
[1] = msg
[i
].len
;
133 obuf
[2] = msg
[i
].addr
;
134 if (cxusb_ctrl_msg(d
, CMD_I2C_READ
,
136 ibuf
, 1+msg
[i
].len
) < 0) {
137 warn("i2c read failed");
140 memcpy(msg
[i
].buf
, &ibuf
[1], msg
[i
].len
);
141 } else if (i
+1 < num
&& (msg
[i
+1].flags
& I2C_M_RD
) &&
142 msg
[i
].addr
== msg
[i
+1].addr
) {
143 /* write to then read from same address */
144 u8 obuf
[3+msg
[i
].len
], ibuf
[1+msg
[i
+1].len
];
145 obuf
[0] = msg
[i
].len
;
146 obuf
[1] = msg
[i
+1].len
;
147 obuf
[2] = msg
[i
].addr
;
148 memcpy(&obuf
[3], msg
[i
].buf
, msg
[i
].len
);
150 if (cxusb_ctrl_msg(d
, CMD_I2C_READ
,
152 ibuf
, 1+msg
[i
+1].len
) < 0)
156 deb_i2c("i2c read may have failed\n");
158 memcpy(msg
[i
+1].buf
, &ibuf
[1], msg
[i
+1].len
);
163 u8 obuf
[2+msg
[i
].len
], ibuf
;
164 obuf
[0] = msg
[i
].addr
;
165 obuf
[1] = msg
[i
].len
;
166 memcpy(&obuf
[2], msg
[i
].buf
, msg
[i
].len
);
168 if (cxusb_ctrl_msg(d
, CMD_I2C_WRITE
, obuf
,
169 2+msg
[i
].len
, &ibuf
,1) < 0)
172 deb_i2c("i2c write may have failed\n");
176 mutex_unlock(&d
->i2c_mutex
);
177 return i
== num
? num
: -EREMOTEIO
;
180 static u32
cxusb_i2c_func(struct i2c_adapter
*adapter
)
185 static struct i2c_algorithm cxusb_i2c_algo
= {
186 .master_xfer
= cxusb_i2c_xfer
,
187 .functionality
= cxusb_i2c_func
,
190 static int cxusb_power_ctrl(struct dvb_usb_device
*d
, int onoff
)
194 return cxusb_ctrl_msg(d
, CMD_POWER_ON
, &b
, 1, NULL
, 0);
196 return cxusb_ctrl_msg(d
, CMD_POWER_OFF
, &b
, 1, NULL
, 0);
199 static int cxusb_bluebird_power_ctrl(struct dvb_usb_device
*d
, int onoff
)
203 return cxusb_ctrl_msg(d
, CMD_POWER_ON
, &b
, 1, NULL
, 0);
208 static int cxusb_nano2_power_ctrl(struct dvb_usb_device
*d
, int onoff
)
212 rc
= cxusb_power_ctrl(d
, onoff
);
214 cxusb_nano2_led(d
, 0);
219 static int cxusb_streaming_ctrl(struct dvb_usb_adapter
*adap
, int onoff
)
221 u8 buf
[2] = { 0x03, 0x00 };
223 cxusb_ctrl_msg(adap
->dev
, CMD_STREAMING_ON
, buf
, 2, NULL
, 0);
225 cxusb_ctrl_msg(adap
->dev
, CMD_STREAMING_OFF
, NULL
, 0, NULL
, 0);
230 static int cxusb_rc_query(struct dvb_usb_device
*d
, u32
*event
, int *state
)
232 struct dvb_usb_rc_key
*keymap
= d
->props
.rc_key_map
;
236 cxusb_ctrl_msg(d
, CMD_GET_IR_CODE
, NULL
, 0, ircode
, 4);
239 *state
= REMOTE_NO_KEY_PRESSED
;
241 for (i
= 0; i
< d
->props
.rc_key_map_size
; i
++) {
242 if (keymap
[i
].custom
== ircode
[2] &&
243 keymap
[i
].data
== ircode
[3]) {
244 *event
= keymap
[i
].event
;
245 *state
= REMOTE_KEY_PRESSED
;
254 static int cxusb_bluebird2_rc_query(struct dvb_usb_device
*d
, u32
*event
,
257 struct dvb_usb_rc_key
*keymap
= d
->props
.rc_key_map
;
260 struct i2c_msg msg
= { .addr
= 0x6b, .flags
= I2C_M_RD
,
261 .buf
= ircode
, .len
= 4 };
264 *state
= REMOTE_NO_KEY_PRESSED
;
266 if (cxusb_i2c_xfer(&d
->i2c_adap
, &msg
, 1) != 1)
269 for (i
= 0; i
< d
->props
.rc_key_map_size
; i
++) {
270 if (keymap
[i
].custom
== ircode
[1] &&
271 keymap
[i
].data
== ircode
[2]) {
272 *event
= keymap
[i
].event
;
273 *state
= REMOTE_KEY_PRESSED
;
282 static struct dvb_usb_rc_key dvico_mce_rc_keys
[] = {
283 { 0xfe, 0x02, KEY_TV
},
284 { 0xfe, 0x0e, KEY_MP3
},
285 { 0xfe, 0x1a, KEY_DVD
},
286 { 0xfe, 0x1e, KEY_FAVORITES
},
287 { 0xfe, 0x16, KEY_SETUP
},
288 { 0xfe, 0x46, KEY_POWER2
},
289 { 0xfe, 0x0a, KEY_EPG
},
290 { 0xfe, 0x49, KEY_BACK
},
291 { 0xfe, 0x4d, KEY_MENU
},
292 { 0xfe, 0x51, KEY_UP
},
293 { 0xfe, 0x5b, KEY_LEFT
},
294 { 0xfe, 0x5f, KEY_RIGHT
},
295 { 0xfe, 0x53, KEY_DOWN
},
296 { 0xfe, 0x5e, KEY_OK
},
297 { 0xfe, 0x59, KEY_INFO
},
298 { 0xfe, 0x55, KEY_TAB
},
299 { 0xfe, 0x0f, KEY_PREVIOUSSONG
},/* Replay */
300 { 0xfe, 0x12, KEY_NEXTSONG
}, /* Skip */
301 { 0xfe, 0x42, KEY_ENTER
}, /* Windows/Start */
302 { 0xfe, 0x15, KEY_VOLUMEUP
},
303 { 0xfe, 0x05, KEY_VOLUMEDOWN
},
304 { 0xfe, 0x11, KEY_CHANNELUP
},
305 { 0xfe, 0x09, KEY_CHANNELDOWN
},
306 { 0xfe, 0x52, KEY_CAMERA
},
307 { 0xfe, 0x5a, KEY_TUNER
}, /* Live */
308 { 0xfe, 0x19, KEY_OPEN
},
309 { 0xfe, 0x0b, KEY_1
},
310 { 0xfe, 0x17, KEY_2
},
311 { 0xfe, 0x1b, KEY_3
},
312 { 0xfe, 0x07, KEY_4
},
313 { 0xfe, 0x50, KEY_5
},
314 { 0xfe, 0x54, KEY_6
},
315 { 0xfe, 0x48, KEY_7
},
316 { 0xfe, 0x4c, KEY_8
},
317 { 0xfe, 0x58, KEY_9
},
318 { 0xfe, 0x13, KEY_ANGLE
}, /* Aspect */
319 { 0xfe, 0x03, KEY_0
},
320 { 0xfe, 0x1f, KEY_ZOOM
},
321 { 0xfe, 0x43, KEY_REWIND
},
322 { 0xfe, 0x47, KEY_PLAYPAUSE
},
323 { 0xfe, 0x4f, KEY_FASTFORWARD
},
324 { 0xfe, 0x57, KEY_MUTE
},
325 { 0xfe, 0x0d, KEY_STOP
},
326 { 0xfe, 0x01, KEY_RECORD
},
327 { 0xfe, 0x4e, KEY_POWER
},
330 static struct dvb_usb_rc_key dvico_portable_rc_keys
[] = {
331 { 0xfc, 0x02, KEY_SETUP
}, /* Profile */
332 { 0xfc, 0x43, KEY_POWER2
},
333 { 0xfc, 0x06, KEY_EPG
},
334 { 0xfc, 0x5a, KEY_BACK
},
335 { 0xfc, 0x05, KEY_MENU
},
336 { 0xfc, 0x47, KEY_INFO
},
337 { 0xfc, 0x01, KEY_TAB
},
338 { 0xfc, 0x42, KEY_PREVIOUSSONG
},/* Replay */
339 { 0xfc, 0x49, KEY_VOLUMEUP
},
340 { 0xfc, 0x09, KEY_VOLUMEDOWN
},
341 { 0xfc, 0x54, KEY_CHANNELUP
},
342 { 0xfc, 0x0b, KEY_CHANNELDOWN
},
343 { 0xfc, 0x16, KEY_CAMERA
},
344 { 0xfc, 0x40, KEY_TUNER
}, /* ATV/DTV */
345 { 0xfc, 0x45, KEY_OPEN
},
346 { 0xfc, 0x19, KEY_1
},
347 { 0xfc, 0x18, KEY_2
},
348 { 0xfc, 0x1b, KEY_3
},
349 { 0xfc, 0x1a, KEY_4
},
350 { 0xfc, 0x58, KEY_5
},
351 { 0xfc, 0x59, KEY_6
},
352 { 0xfc, 0x15, KEY_7
},
353 { 0xfc, 0x14, KEY_8
},
354 { 0xfc, 0x17, KEY_9
},
355 { 0xfc, 0x44, KEY_ANGLE
}, /* Aspect */
356 { 0xfc, 0x55, KEY_0
},
357 { 0xfc, 0x07, KEY_ZOOM
},
358 { 0xfc, 0x0a, KEY_REWIND
},
359 { 0xfc, 0x08, KEY_PLAYPAUSE
},
360 { 0xfc, 0x4b, KEY_FASTFORWARD
},
361 { 0xfc, 0x5b, KEY_MUTE
},
362 { 0xfc, 0x04, KEY_STOP
},
363 { 0xfc, 0x56, KEY_RECORD
},
364 { 0xfc, 0x57, KEY_POWER
},
365 { 0xfc, 0x41, KEY_UNKNOWN
}, /* INPUT */
366 { 0xfc, 0x00, KEY_UNKNOWN
}, /* HD */
369 static int cxusb_dee1601_demod_init(struct dvb_frontend
* fe
)
371 static u8 clock_config
[] = { CLOCK_CTL
, 0x38, 0x28 };
372 static u8 reset
[] = { RESET
, 0x80 };
373 static u8 adc_ctl_1_cfg
[] = { ADC_CTL_1
, 0x40 };
374 static u8 agc_cfg
[] = { AGC_TARGET
, 0x28, 0x20 };
375 static u8 gpp_ctl_cfg
[] = { GPP_CTL
, 0x33 };
376 static u8 capt_range_cfg
[] = { CAPT_RANGE
, 0x32 };
378 mt352_write(fe
, clock_config
, sizeof(clock_config
));
380 mt352_write(fe
, reset
, sizeof(reset
));
381 mt352_write(fe
, adc_ctl_1_cfg
, sizeof(adc_ctl_1_cfg
));
383 mt352_write(fe
, agc_cfg
, sizeof(agc_cfg
));
384 mt352_write(fe
, gpp_ctl_cfg
, sizeof(gpp_ctl_cfg
));
385 mt352_write(fe
, capt_range_cfg
, sizeof(capt_range_cfg
));
390 static int cxusb_mt352_demod_init(struct dvb_frontend
* fe
)
391 { /* used in both lgz201 and th7579 */
392 static u8 clock_config
[] = { CLOCK_CTL
, 0x38, 0x29 };
393 static u8 reset
[] = { RESET
, 0x80 };
394 static u8 adc_ctl_1_cfg
[] = { ADC_CTL_1
, 0x40 };
395 static u8 agc_cfg
[] = { AGC_TARGET
, 0x24, 0x20 };
396 static u8 gpp_ctl_cfg
[] = { GPP_CTL
, 0x33 };
397 static u8 capt_range_cfg
[] = { CAPT_RANGE
, 0x32 };
399 mt352_write(fe
, clock_config
, sizeof(clock_config
));
401 mt352_write(fe
, reset
, sizeof(reset
));
402 mt352_write(fe
, adc_ctl_1_cfg
, sizeof(adc_ctl_1_cfg
));
404 mt352_write(fe
, agc_cfg
, sizeof(agc_cfg
));
405 mt352_write(fe
, gpp_ctl_cfg
, sizeof(gpp_ctl_cfg
));
406 mt352_write(fe
, capt_range_cfg
, sizeof(capt_range_cfg
));
410 static struct cx22702_config cxusb_cx22702_config
= {
411 .demod_address
= 0x63,
412 .output_mode
= CX22702_PARALLEL_OUTPUT
,
415 static struct lgdt330x_config cxusb_lgdt3303_config
= {
416 .demod_address
= 0x0e,
417 .demod_chip
= LGDT3303
,
420 static struct mt352_config cxusb_dee1601_config
= {
421 .demod_address
= 0x0f,
422 .demod_init
= cxusb_dee1601_demod_init
,
425 static struct zl10353_config cxusb_zl10353_dee1601_config
= {
426 .demod_address
= 0x0f,
430 static struct mt352_config cxusb_mt352_config
= {
431 /* used in both lgz201 and th7579 */
432 .demod_address
= 0x0f,
433 .demod_init
= cxusb_mt352_demod_init
,
436 static struct zl10353_config cxusb_zl10353_xc3028_config
= {
437 .demod_address
= 0x0f,
443 /* Callbacks for DVB USB */
444 static int cxusb_fmd1216me_tuner_attach(struct dvb_usb_adapter
*adap
)
446 dvb_attach(dvb_pll_attach
, adap
->fe
, 0x61, &adap
->dev
->i2c_adap
,
451 static int cxusb_dee1601_tuner_attach(struct dvb_usb_adapter
*adap
)
453 dvb_attach(dvb_pll_attach
, adap
->fe
, 0x61,
454 NULL
, DVB_PLL_THOMSON_DTT7579
);
458 static int cxusb_lgz201_tuner_attach(struct dvb_usb_adapter
*adap
)
460 dvb_attach(dvb_pll_attach
, adap
->fe
, 0x61, NULL
, DVB_PLL_LG_Z201
);
464 static int cxusb_dtt7579_tuner_attach(struct dvb_usb_adapter
*adap
)
466 dvb_attach(dvb_pll_attach
, adap
->fe
, 0x60,
467 NULL
, DVB_PLL_THOMSON_DTT7579
);
471 static int cxusb_lgh064f_tuner_attach(struct dvb_usb_adapter
*adap
)
473 dvb_attach(dvb_pll_attach
, adap
->fe
, 0x61, &adap
->dev
->i2c_adap
,
474 DVB_PLL_LG_TDVS_H06XF
);
478 static int dvico_bluebird_xc2028_callback(void *ptr
, int command
, int arg
)
480 struct dvb_usb_device
*d
= ptr
;
483 case XC2028_TUNER_RESET
:
484 deb_info("%s: XC2028_TUNER_RESET %d\n", __FUNCTION__
, arg
);
485 cxusb_bluebird_gpio_pulse(d
, 0x01, 1);
487 case XC2028_RESET_CLK
:
488 deb_info("%s: XC2028_RESET_CLK %d\n", __FUNCTION__
, arg
);
491 deb_info("%s: unknown command %d, arg %d\n", __FUNCTION__
,
499 static int cxusb_dvico_xc3028_tuner_attach(struct dvb_usb_adapter
*adap
)
501 struct dvb_frontend
*fe
;
502 struct xc2028_config cfg
= {
503 .i2c_adap
= &adap
->dev
->i2c_adap
,
505 .video_dev
= adap
->dev
,
506 .callback
= dvico_bluebird_xc2028_callback
,
508 static struct xc2028_ctrl ctl
= {
509 .type
= XC2028_FIRM_NORMAL
,
510 .fname
= "xc3028-dvico-au-01.fw",
512 .scode_table
= ZARLINK456
,
515 fe
= dvb_attach(xc2028_attach
, adap
->fe
, &cfg
);
516 if (fe
== NULL
|| fe
->ops
.tuner_ops
.set_config
== NULL
)
519 fe
->ops
.tuner_ops
.set_config(fe
, &ctl
);
524 static int cxusb_cx22702_frontend_attach(struct dvb_usb_adapter
*adap
)
527 if (usb_set_interface(adap
->dev
->udev
, 0, 6) < 0)
528 err("set interface failed");
530 cxusb_ctrl_msg(adap
->dev
, CMD_DIGITAL
, NULL
, 0, &b
, 1);
532 if ((adap
->fe
= dvb_attach(cx22702_attach
, &cxusb_cx22702_config
,
533 &adap
->dev
->i2c_adap
)) != NULL
)
539 static int cxusb_lgdt3303_frontend_attach(struct dvb_usb_adapter
*adap
)
541 if (usb_set_interface(adap
->dev
->udev
, 0, 7) < 0)
542 err("set interface failed");
544 cxusb_ctrl_msg(adap
->dev
, CMD_DIGITAL
, NULL
, 0, NULL
, 0);
546 if ((adap
->fe
= dvb_attach(lgdt330x_attach
, &cxusb_lgdt3303_config
,
547 &adap
->dev
->i2c_adap
)) != NULL
)
553 static int cxusb_mt352_frontend_attach(struct dvb_usb_adapter
*adap
)
555 /* used in both lgz201 and th7579 */
556 if (usb_set_interface(adap
->dev
->udev
, 0, 0) < 0)
557 err("set interface failed");
559 cxusb_ctrl_msg(adap
->dev
, CMD_DIGITAL
, NULL
, 0, NULL
, 0);
561 if ((adap
->fe
= dvb_attach(mt352_attach
, &cxusb_mt352_config
,
562 &adap
->dev
->i2c_adap
)) != NULL
)
568 static int cxusb_dee1601_frontend_attach(struct dvb_usb_adapter
*adap
)
570 if (usb_set_interface(adap
->dev
->udev
, 0, 0) < 0)
571 err("set interface failed");
573 cxusb_ctrl_msg(adap
->dev
, CMD_DIGITAL
, NULL
, 0, NULL
, 0);
575 if (((adap
->fe
= dvb_attach(mt352_attach
, &cxusb_dee1601_config
,
576 &adap
->dev
->i2c_adap
)) != NULL
) ||
577 ((adap
->fe
= dvb_attach(zl10353_attach
,
578 &cxusb_zl10353_dee1601_config
,
579 &adap
->dev
->i2c_adap
)) != NULL
))
585 static int cxusb_dualdig4_frontend_attach(struct dvb_usb_adapter
*adap
)
589 struct i2c_msg msg
= { .addr
= 0x6b, .flags
= I2C_M_RD
,
590 .buf
= ircode
, .len
= 4 };
592 if (usb_set_interface(adap
->dev
->udev
, 0, 1) < 0)
593 err("set interface failed");
595 cxusb_ctrl_msg(adap
->dev
, CMD_DIGITAL
, NULL
, 0, NULL
, 0);
597 /* reset the tuner and demodulator */
598 cxusb_bluebird_gpio_rw(adap
->dev
, 0x04, 0);
599 cxusb_bluebird_gpio_pulse(adap
->dev
, 0x01, 1);
600 cxusb_bluebird_gpio_pulse(adap
->dev
, 0x02, 1);
602 if ((adap
->fe
= dvb_attach(zl10353_attach
,
603 &cxusb_zl10353_xc3028_config
,
604 &adap
->dev
->i2c_adap
)) == NULL
)
607 /* try to determine if there is no IR decoder on the I2C bus */
608 for (i
= 0; adap
->dev
->props
.rc_key_map
!= NULL
&& i
< 5; i
++) {
610 if (cxusb_i2c_xfer(&adap
->dev
->i2c_adap
, &msg
, 1) != 1)
612 if (ircode
[0] == 0 && ircode
[1] == 0)
614 if (ircode
[2] + ircode
[3] != 0xff) {
616 adap
->dev
->props
.rc_key_map
= NULL
;
617 info("No IR receiver detected on this device.");
625 static int cxusb_nano2_frontend_attach(struct dvb_usb_adapter
*adap
)
627 if (usb_set_interface(adap
->dev
->udev
, 0, 1) < 0)
628 err("set interface failed");
630 cxusb_ctrl_msg(adap
->dev
, CMD_DIGITAL
, NULL
, 0, NULL
, 0);
632 /* reset the tuner and demodulator */
633 cxusb_bluebird_gpio_rw(adap
->dev
, 0x04, 0);
634 cxusb_bluebird_gpio_pulse(adap
->dev
, 0x01, 1);
635 cxusb_bluebird_gpio_pulse(adap
->dev
, 0x02, 1);
637 if ((adap
->fe
= dvb_attach(zl10353_attach
,
638 &cxusb_zl10353_xc3028_config
,
639 &adap
->dev
->i2c_adap
)) != NULL
)
646 * DViCO bluebird firmware needs the "warm" product ID to be patched into the
647 * firmware file before download.
650 #define BLUEBIRD_01_ID_OFFSET 6638
651 static int bluebird_patch_dvico_firmware_download(struct usb_device
*udev
,
652 const struct firmware
*fw
)
654 if (fw
->size
< BLUEBIRD_01_ID_OFFSET
+ 4)
657 if (fw
->data
[BLUEBIRD_01_ID_OFFSET
] == (USB_VID_DVICO
& 0xff) &&
658 fw
->data
[BLUEBIRD_01_ID_OFFSET
+ 1] == USB_VID_DVICO
>> 8) {
660 fw
->data
[BLUEBIRD_01_ID_OFFSET
+ 2] =
661 le16_to_cpu(udev
->descriptor
.idProduct
) + 1;
662 fw
->data
[BLUEBIRD_01_ID_OFFSET
+ 3] =
663 le16_to_cpu(udev
->descriptor
.idProduct
) >> 8;
665 return usb_cypress_load_firmware(udev
, fw
, CYPRESS_FX2
);
671 /* DVB USB Driver stuff */
672 static struct dvb_usb_device_properties cxusb_medion_properties
;
673 static struct dvb_usb_device_properties cxusb_bluebird_lgh064f_properties
;
674 static struct dvb_usb_device_properties cxusb_bluebird_dee1601_properties
;
675 static struct dvb_usb_device_properties cxusb_bluebird_lgz201_properties
;
676 static struct dvb_usb_device_properties cxusb_bluebird_dtt7579_properties
;
677 static struct dvb_usb_device_properties cxusb_bluebird_dualdig4_properties
;
678 static struct dvb_usb_device_properties cxusb_bluebird_nano2_properties
;
680 static int cxusb_probe(struct usb_interface
*intf
,
681 const struct usb_device_id
*id
)
683 if (dvb_usb_device_init(intf
,&cxusb_medion_properties
,THIS_MODULE
,NULL
) == 0 ||
684 dvb_usb_device_init(intf
,&cxusb_bluebird_lgh064f_properties
,THIS_MODULE
,NULL
) == 0 ||
685 dvb_usb_device_init(intf
,&cxusb_bluebird_dee1601_properties
,THIS_MODULE
,NULL
) == 0 ||
686 dvb_usb_device_init(intf
,&cxusb_bluebird_lgz201_properties
,THIS_MODULE
,NULL
) == 0 ||
687 dvb_usb_device_init(intf
,&cxusb_bluebird_dtt7579_properties
,THIS_MODULE
,NULL
) == 0 ||
688 dvb_usb_device_init(intf
,&cxusb_bluebird_dualdig4_properties
,THIS_MODULE
,NULL
) == 0 ||
689 dvb_usb_device_init(intf
,&cxusb_bluebird_nano2_properties
,THIS_MODULE
,NULL
) == 0) {
696 static struct usb_device_id cxusb_table
[] = {
697 { USB_DEVICE(USB_VID_MEDION
, USB_PID_MEDION_MD95700
) },
698 { USB_DEVICE(USB_VID_DVICO
, USB_PID_DVICO_BLUEBIRD_LG064F_COLD
) },
699 { USB_DEVICE(USB_VID_DVICO
, USB_PID_DVICO_BLUEBIRD_LG064F_WARM
) },
700 { USB_DEVICE(USB_VID_DVICO
, USB_PID_DVICO_BLUEBIRD_DUAL_1_COLD
) },
701 { USB_DEVICE(USB_VID_DVICO
, USB_PID_DVICO_BLUEBIRD_DUAL_1_WARM
) },
702 { USB_DEVICE(USB_VID_DVICO
, USB_PID_DVICO_BLUEBIRD_LGZ201_COLD
) },
703 { USB_DEVICE(USB_VID_DVICO
, USB_PID_DVICO_BLUEBIRD_LGZ201_WARM
) },
704 { USB_DEVICE(USB_VID_DVICO
, USB_PID_DVICO_BLUEBIRD_TH7579_COLD
) },
705 { USB_DEVICE(USB_VID_DVICO
, USB_PID_DVICO_BLUEBIRD_TH7579_WARM
) },
706 { USB_DEVICE(USB_VID_DVICO
, USB_PID_DIGITALNOW_BLUEBIRD_DUAL_1_COLD
) },
707 { USB_DEVICE(USB_VID_DVICO
, USB_PID_DIGITALNOW_BLUEBIRD_DUAL_1_WARM
) },
708 { USB_DEVICE(USB_VID_DVICO
, USB_PID_DVICO_BLUEBIRD_DUAL_2_COLD
) },
709 { USB_DEVICE(USB_VID_DVICO
, USB_PID_DVICO_BLUEBIRD_DUAL_2_WARM
) },
710 { USB_DEVICE(USB_VID_DVICO
, USB_PID_DVICO_BLUEBIRD_DUAL_4
) },
711 { USB_DEVICE(USB_VID_DVICO
, USB_PID_DVICO_BLUEBIRD_DVB_T_NANO_2
) },
712 {} /* Terminating entry */
714 MODULE_DEVICE_TABLE (usb
, cxusb_table
);
716 static struct dvb_usb_device_properties cxusb_medion_properties
= {
717 .caps
= DVB_USB_IS_AN_I2C_ADAPTER
,
719 .usb_ctrl
= CYPRESS_FX2
,
721 .size_of_priv
= sizeof(struct cxusb_state
),
726 .streaming_ctrl
= cxusb_streaming_ctrl
,
727 .frontend_attach
= cxusb_cx22702_frontend_attach
,
728 .tuner_attach
= cxusb_fmd1216me_tuner_attach
,
729 /* parameter for the MPEG2-data transfer */
743 .power_ctrl
= cxusb_power_ctrl
,
745 .i2c_algo
= &cxusb_i2c_algo
,
747 .generic_bulk_ctrl_endpoint
= 0x01,
749 .num_device_descs
= 1,
751 { "Medion MD95700 (MDUSBTV-HYBRID)",
753 { &cxusb_table
[0], NULL
},
758 static struct dvb_usb_device_properties cxusb_bluebird_lgh064f_properties
= {
759 .caps
= DVB_USB_IS_AN_I2C_ADAPTER
,
761 .usb_ctrl
= DEVICE_SPECIFIC
,
762 .firmware
= "dvb-usb-bluebird-01.fw",
763 .download_firmware
= bluebird_patch_dvico_firmware_download
,
764 /* use usb alt setting 0 for EP4 transfer (dvb-t),
765 use usb alt setting 7 for EP2 transfer (atsc) */
767 .size_of_priv
= sizeof(struct cxusb_state
),
772 .streaming_ctrl
= cxusb_streaming_ctrl
,
773 .frontend_attach
= cxusb_lgdt3303_frontend_attach
,
774 .tuner_attach
= cxusb_lgh064f_tuner_attach
,
776 /* parameter for the MPEG2-data transfer */
790 .power_ctrl
= cxusb_bluebird_power_ctrl
,
792 .i2c_algo
= &cxusb_i2c_algo
,
795 .rc_key_map
= dvico_portable_rc_keys
,
796 .rc_key_map_size
= ARRAY_SIZE(dvico_portable_rc_keys
),
797 .rc_query
= cxusb_rc_query
,
799 .generic_bulk_ctrl_endpoint
= 0x01,
801 .num_device_descs
= 1,
803 { "DViCO FusionHDTV5 USB Gold",
804 { &cxusb_table
[1], NULL
},
805 { &cxusb_table
[2], NULL
},
810 static struct dvb_usb_device_properties cxusb_bluebird_dee1601_properties
= {
811 .caps
= DVB_USB_IS_AN_I2C_ADAPTER
,
813 .usb_ctrl
= DEVICE_SPECIFIC
,
814 .firmware
= "dvb-usb-bluebird-01.fw",
815 .download_firmware
= bluebird_patch_dvico_firmware_download
,
816 /* use usb alt setting 0 for EP4 transfer (dvb-t),
817 use usb alt setting 7 for EP2 transfer (atsc) */
819 .size_of_priv
= sizeof(struct cxusb_state
),
824 .streaming_ctrl
= cxusb_streaming_ctrl
,
825 .frontend_attach
= cxusb_dee1601_frontend_attach
,
826 .tuner_attach
= cxusb_dee1601_tuner_attach
,
827 /* parameter for the MPEG2-data transfer */
841 .power_ctrl
= cxusb_bluebird_power_ctrl
,
843 .i2c_algo
= &cxusb_i2c_algo
,
846 .rc_key_map
= dvico_mce_rc_keys
,
847 .rc_key_map_size
= ARRAY_SIZE(dvico_mce_rc_keys
),
848 .rc_query
= cxusb_rc_query
,
850 .generic_bulk_ctrl_endpoint
= 0x01,
852 .num_device_descs
= 3,
854 { "DViCO FusionHDTV DVB-T Dual USB",
855 { &cxusb_table
[3], NULL
},
856 { &cxusb_table
[4], NULL
},
858 { "DigitalNow DVB-T Dual USB",
859 { &cxusb_table
[9], NULL
},
860 { &cxusb_table
[10], NULL
},
862 { "DViCO FusionHDTV DVB-T Dual Digital 2",
863 { &cxusb_table
[11], NULL
},
864 { &cxusb_table
[12], NULL
},
869 static struct dvb_usb_device_properties cxusb_bluebird_lgz201_properties
= {
870 .caps
= DVB_USB_IS_AN_I2C_ADAPTER
,
872 .usb_ctrl
= DEVICE_SPECIFIC
,
873 .firmware
= "dvb-usb-bluebird-01.fw",
874 .download_firmware
= bluebird_patch_dvico_firmware_download
,
875 /* use usb alt setting 0 for EP4 transfer (dvb-t),
876 use usb alt setting 7 for EP2 transfer (atsc) */
878 .size_of_priv
= sizeof(struct cxusb_state
),
883 .streaming_ctrl
= cxusb_streaming_ctrl
,
884 .frontend_attach
= cxusb_mt352_frontend_attach
,
885 .tuner_attach
= cxusb_lgz201_tuner_attach
,
887 /* parameter for the MPEG2-data transfer */
900 .power_ctrl
= cxusb_bluebird_power_ctrl
,
902 .i2c_algo
= &cxusb_i2c_algo
,
905 .rc_key_map
= dvico_portable_rc_keys
,
906 .rc_key_map_size
= ARRAY_SIZE(dvico_portable_rc_keys
),
907 .rc_query
= cxusb_rc_query
,
909 .generic_bulk_ctrl_endpoint
= 0x01,
910 .num_device_descs
= 1,
912 { "DViCO FusionHDTV DVB-T USB (LGZ201)",
913 { &cxusb_table
[5], NULL
},
914 { &cxusb_table
[6], NULL
},
919 static struct dvb_usb_device_properties cxusb_bluebird_dtt7579_properties
= {
920 .caps
= DVB_USB_IS_AN_I2C_ADAPTER
,
922 .usb_ctrl
= DEVICE_SPECIFIC
,
923 .firmware
= "dvb-usb-bluebird-01.fw",
924 .download_firmware
= bluebird_patch_dvico_firmware_download
,
925 /* use usb alt setting 0 for EP4 transfer (dvb-t),
926 use usb alt setting 7 for EP2 transfer (atsc) */
928 .size_of_priv
= sizeof(struct cxusb_state
),
933 .streaming_ctrl
= cxusb_streaming_ctrl
,
934 .frontend_attach
= cxusb_mt352_frontend_attach
,
935 .tuner_attach
= cxusb_dtt7579_tuner_attach
,
937 /* parameter for the MPEG2-data transfer */
950 .power_ctrl
= cxusb_bluebird_power_ctrl
,
952 .i2c_algo
= &cxusb_i2c_algo
,
955 .rc_key_map
= dvico_portable_rc_keys
,
956 .rc_key_map_size
= ARRAY_SIZE(dvico_portable_rc_keys
),
957 .rc_query
= cxusb_rc_query
,
959 .generic_bulk_ctrl_endpoint
= 0x01,
961 .num_device_descs
= 1,
963 { "DViCO FusionHDTV DVB-T USB (TH7579)",
964 { &cxusb_table
[7], NULL
},
965 { &cxusb_table
[8], NULL
},
970 static struct dvb_usb_device_properties cxusb_bluebird_dualdig4_properties
= {
971 .caps
= DVB_USB_IS_AN_I2C_ADAPTER
,
973 .usb_ctrl
= CYPRESS_FX2
,
975 .size_of_priv
= sizeof(struct cxusb_state
),
980 .streaming_ctrl
= cxusb_streaming_ctrl
,
981 .frontend_attach
= cxusb_dualdig4_frontend_attach
,
982 .tuner_attach
= cxusb_dvico_xc3028_tuner_attach
,
983 /* parameter for the MPEG2-data transfer */
997 .power_ctrl
= cxusb_power_ctrl
,
999 .i2c_algo
= &cxusb_i2c_algo
,
1001 .generic_bulk_ctrl_endpoint
= 0x01,
1004 .rc_key_map
= dvico_mce_rc_keys
,
1005 .rc_key_map_size
= ARRAY_SIZE(dvico_mce_rc_keys
),
1006 .rc_query
= cxusb_bluebird2_rc_query
,
1008 .num_device_descs
= 1,
1010 { "DViCO FusionHDTV DVB-T Dual Digital 4",
1012 { &cxusb_table
[13], NULL
},
1017 static struct dvb_usb_device_properties cxusb_bluebird_nano2_properties
= {
1018 .caps
= DVB_USB_IS_AN_I2C_ADAPTER
,
1020 .usb_ctrl
= CYPRESS_FX2
,
1022 .size_of_priv
= sizeof(struct cxusb_state
),
1027 .streaming_ctrl
= cxusb_streaming_ctrl
,
1028 .frontend_attach
= cxusb_nano2_frontend_attach
,
1029 .tuner_attach
= cxusb_dvico_xc3028_tuner_attach
,
1030 /* parameter for the MPEG2-data transfer */
1044 .power_ctrl
= cxusb_nano2_power_ctrl
,
1046 .i2c_algo
= &cxusb_i2c_algo
,
1048 .generic_bulk_ctrl_endpoint
= 0x01,
1051 .rc_key_map
= dvico_portable_rc_keys
,
1052 .rc_key_map_size
= ARRAY_SIZE(dvico_portable_rc_keys
),
1053 .rc_query
= cxusb_bluebird2_rc_query
,
1055 .num_device_descs
= 1,
1057 { "DViCO FusionHDTV DVB-T NANO2",
1059 { &cxusb_table
[14], NULL
},
1064 static struct usb_driver cxusb_driver
= {
1065 .name
= "dvb_usb_cxusb",
1066 .probe
= cxusb_probe
,
1067 .disconnect
= dvb_usb_device_exit
,
1068 .id_table
= cxusb_table
,
1072 static int __init
cxusb_module_init(void)
1075 if ((result
= usb_register(&cxusb_driver
))) {
1076 err("usb_register failed. Error number %d",result
);
1083 static void __exit
cxusb_module_exit(void)
1085 /* deregister this driver from the USB subsystem */
1086 usb_deregister(&cxusb_driver
);
1089 module_init (cxusb_module_init
);
1090 module_exit (cxusb_module_exit
);
1092 MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>");
1093 MODULE_AUTHOR("Michael Krufky <mkrufky@linuxtv.org>");
1094 MODULE_AUTHOR("Chris Pascoe <c.pascoe@itee.uq.edu.au>");
1095 MODULE_DESCRIPTION("Driver for Conexant USB2.0 hybrid reference design");
1096 MODULE_VERSION("1.0-alpha");
1097 MODULE_LICENSE("GPL");