1 /* Linux driver for devices based on the DiBcom DiB0700 USB bridge
3 * This program is free software; you can redistribute it and/or modify it
4 * under the terms of the GNU General Public License as published by the Free
5 * Software Foundation, version 2.
7 * Copyright (C) 2005-7 DiBcom, SA
11 #include "dib3000mc.h"
16 #include "tuner-xc2028.h"
23 static int force_lna_activation
;
24 module_param(force_lna_activation
, int, 0644);
25 MODULE_PARM_DESC(force_lna_activation
, "force the activation of Low-Noise-Amplifyer(s) (LNA), "
26 "if applicable for the device (default: 0=automatic/off).");
28 struct dib0700_adapter_state
{
29 int (*set_param_save
) (struct dvb_frontend
*, struct dvb_frontend_parameters
*);
32 /* Hauppauge Nova-T 500 (aka Bristol)
33 * has a LNA on GPIO0 which is enabled by setting 1 */
34 static struct mt2060_config bristol_mt2060_config
[2] = {
44 static struct dibx000_agc_config bristol_dib3000p_mt2060_agc_config
= {
45 .band_caps
= BAND_VHF
| BAND_UHF
,
46 .setup
= (1 << 8) | (5 << 5) | (0 << 4) | (0 << 3) | (0 << 2) | (2 << 0),
66 static struct dib3000mc_config bristol_dib3000mc_config
[2] = {
67 { .agc
= &bristol_dib3000p_mt2060_agc_config
,
69 .ln_adc_level
= 0x1cc7,
70 .output_mpeg2_in_188_bytes
= 1,
72 { .agc
= &bristol_dib3000p_mt2060_agc_config
,
74 .ln_adc_level
= 0x1cc7,
75 .output_mpeg2_in_188_bytes
= 1,
79 static int bristol_frontend_attach(struct dvb_usb_adapter
*adap
)
81 struct dib0700_state
*st
= adap
->dev
->priv
;
83 dib0700_set_gpio(adap
->dev
, GPIO6
, GPIO_OUT
, 0); msleep(10);
84 dib0700_set_gpio(adap
->dev
, GPIO6
, GPIO_OUT
, 1); msleep(10);
85 dib0700_set_gpio(adap
->dev
, GPIO10
, GPIO_OUT
, 0); msleep(10);
86 dib0700_set_gpio(adap
->dev
, GPIO10
, GPIO_OUT
, 1); msleep(10);
88 if (force_lna_activation
)
89 dib0700_set_gpio(adap
->dev
, GPIO0
, GPIO_OUT
, 1);
91 dib0700_set_gpio(adap
->dev
, GPIO0
, GPIO_OUT
, 0);
93 if (dib3000mc_i2c_enumeration(&adap
->dev
->i2c_adap
, 2, DEFAULT_DIB3000P_I2C_ADDRESS
, bristol_dib3000mc_config
) != 0) {
94 dib0700_set_gpio(adap
->dev
, GPIO6
, GPIO_OUT
, 0); msleep(10);
98 st
->mt2060_if1
[adap
->id
] = 1220;
99 return (adap
->fe
= dvb_attach(dib3000mc_attach
, &adap
->dev
->i2c_adap
,
100 (10 + adap
->id
) << 1, &bristol_dib3000mc_config
[adap
->id
])) == NULL
? -ENODEV
: 0;
103 static int eeprom_read(struct i2c_adapter
*adap
,u8 adrs
,u8
*pval
)
105 struct i2c_msg msg
[2] = {
106 { .addr
= 0x50, .flags
= 0, .buf
= &adrs
, .len
= 1 },
107 { .addr
= 0x50, .flags
= I2C_M_RD
, .buf
= pval
, .len
= 1 },
109 if (i2c_transfer(adap
, msg
, 2) != 2) return -EREMOTEIO
;
113 static int bristol_tuner_attach(struct dvb_usb_adapter
*adap
)
115 struct i2c_adapter
*prim_i2c
= &adap
->dev
->i2c_adap
;
116 struct i2c_adapter
*tun_i2c
= dib3000mc_get_tuner_i2c_master(adap
->fe
, 1);
119 if (adap
->dev
->udev
->descriptor
.idVendor
== cpu_to_le16(USB_VID_HAUPPAUGE
) &&
120 adap
->dev
->udev
->descriptor
.idProduct
== cpu_to_le16(USB_PID_HAUPPAUGE_NOVA_T_500_2
)) {
121 if (!eeprom_read(prim_i2c
,0x59 + adap
->id
,&a
)) if1
=1220+a
;
123 return dvb_attach(mt2060_attach
,adap
->fe
, tun_i2c
,&bristol_mt2060_config
[adap
->id
],
124 if1
) == NULL
? -ENODEV
: 0;
127 /* STK7700D: Pinnacle/Terratec/Hauppauge Dual DVB-T Diversity */
130 static struct dibx000_agc_config stk7700d_7000p_mt2266_agc_config
[2] = {
132 BAND_UHF
, // band_caps
134 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=1, P_agc_inv_pwm1=1, P_agc_inv_pwm2=1,
135 * P_agc_inh_dc_rv_est=0, P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=2, P_agc_write=0 */
136 (0 << 15) | (0 << 14) | (1 << 11) | (1 << 10) | (1 << 9) | (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0), // setup
169 1, // perform_agc_softsplit
171 BAND_VHF
| BAND_LBAND
, // band_caps
173 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=1, P_agc_inv_pwm1=1, P_agc_inv_pwm2=1,
174 * P_agc_inh_dc_rv_est=0, P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=2, P_agc_write=0 */
175 (0 << 15) | (0 << 14) | (1 << 11) | (1 << 10) | (1 << 9) | (0 << 8) | (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0), // setup
208 1, // perform_agc_softsplit
212 static struct dibx000_bandwidth_config stk7700d_mt2266_pll_config
= {
213 60000, 30000, // internal, sampling
214 1, 8, 3, 1, 0, // pll_cfg: prediv, ratio, range, reset, bypass
215 0, 0, 1, 1, 2, // misc: refdiv, bypclk_div, IO_CLK_en_core, ADClkSrc, modulo
216 (3 << 14) | (1 << 12) | (524 << 0), // sad_cfg: refsel, sel, freq_15k
221 static struct dib7000p_config stk7700d_dib7000p_mt2266_config
[] = {
222 { .output_mpeg2_in_188_bytes
= 1,
223 .hostbus_diversity
= 1,
224 .tuner_is_baseband
= 1,
226 .agc_config_count
= 2,
227 .agc
= stk7700d_7000p_mt2266_agc_config
,
228 .bw
= &stk7700d_mt2266_pll_config
,
230 .gpio_dir
= DIB7000P_GPIO_DEFAULT_DIRECTIONS
,
231 .gpio_val
= DIB7000P_GPIO_DEFAULT_VALUES
,
232 .gpio_pwm_pos
= DIB7000P_GPIO_DEFAULT_PWM_POS
,
234 { .output_mpeg2_in_188_bytes
= 1,
235 .hostbus_diversity
= 1,
236 .tuner_is_baseband
= 1,
238 .agc_config_count
= 2,
239 .agc
= stk7700d_7000p_mt2266_agc_config
,
240 .bw
= &stk7700d_mt2266_pll_config
,
242 .gpio_dir
= DIB7000P_GPIO_DEFAULT_DIRECTIONS
,
243 .gpio_val
= DIB7000P_GPIO_DEFAULT_VALUES
,
244 .gpio_pwm_pos
= DIB7000P_GPIO_DEFAULT_PWM_POS
,
248 static struct mt2266_config stk7700d_mt2266_config
[2] = {
249 { .i2c_address
= 0x60
251 { .i2c_address
= 0x60
255 static int stk7700P2_frontend_attach(struct dvb_usb_adapter
*adap
)
258 dib0700_set_gpio(adap
->dev
, GPIO6
, GPIO_OUT
, 1);
260 dib0700_set_gpio(adap
->dev
, GPIO9
, GPIO_OUT
, 1);
261 dib0700_set_gpio(adap
->dev
, GPIO4
, GPIO_OUT
, 1);
262 dib0700_set_gpio(adap
->dev
, GPIO7
, GPIO_OUT
, 1);
263 dib0700_set_gpio(adap
->dev
, GPIO10
, GPIO_OUT
, 0);
265 dib0700_set_gpio(adap
->dev
, GPIO10
, GPIO_OUT
, 1);
267 if (dib7000p_i2c_enumeration(&adap
->dev
->i2c_adap
, 1, 18,
268 stk7700d_dib7000p_mt2266_config
)
270 err("%s: dib7000p_i2c_enumeration failed. Cannot continue\n", __func__
);
275 adap
->fe
= dvb_attach(dib7000p_attach
, &adap
->dev
->i2c_adap
,0x80+(adap
->id
<< 1),
276 &stk7700d_dib7000p_mt2266_config
[adap
->id
]);
278 return adap
->fe
== NULL
? -ENODEV
: 0;
281 static int stk7700d_frontend_attach(struct dvb_usb_adapter
*adap
)
284 dib0700_set_gpio(adap
->dev
, GPIO6
, GPIO_OUT
, 1);
286 dib0700_set_gpio(adap
->dev
, GPIO9
, GPIO_OUT
, 1);
287 dib0700_set_gpio(adap
->dev
, GPIO4
, GPIO_OUT
, 1);
288 dib0700_set_gpio(adap
->dev
, GPIO7
, GPIO_OUT
, 1);
289 dib0700_set_gpio(adap
->dev
, GPIO10
, GPIO_OUT
, 0);
291 dib0700_set_gpio(adap
->dev
, GPIO10
, GPIO_OUT
, 1);
293 dib0700_set_gpio(adap
->dev
, GPIO0
, GPIO_OUT
, 1);
294 if (dib7000p_i2c_enumeration(&adap
->dev
->i2c_adap
, 2, 18,
295 stk7700d_dib7000p_mt2266_config
)
297 err("%s: dib7000p_i2c_enumeration failed. Cannot continue\n", __func__
);
302 adap
->fe
= dvb_attach(dib7000p_attach
, &adap
->dev
->i2c_adap
,0x80+(adap
->id
<< 1),
303 &stk7700d_dib7000p_mt2266_config
[adap
->id
]);
305 return adap
->fe
== NULL
? -ENODEV
: 0;
308 static int stk7700d_tuner_attach(struct dvb_usb_adapter
*adap
)
310 struct i2c_adapter
*tun_i2c
;
311 tun_i2c
= dib7000p_get_i2c_master(adap
->fe
, DIBX000_I2C_INTERFACE_TUNER
, 1);
312 return dvb_attach(mt2266_attach
, adap
->fe
, tun_i2c
,
313 &stk7700d_mt2266_config
[adap
->id
]) == NULL
? -ENODEV
: 0;
316 /* STK7700-PH: Digital/Analog Hybrid Tuner, e.h. Cinergy HT USB HE */
317 static struct dibx000_agc_config xc3028_agc_config
= {
318 BAND_VHF
| BAND_UHF
, /* band_caps */
320 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=0,
321 * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
322 * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=2, P_agc_write=0 */
323 (0 << 15) | (0 << 14) | (0 << 11) | (0 << 10) | (0 << 9) | (0 << 8) |
324 (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0), /* setup */
327 21, /* time_stabiliz */
339 39718, /* agc2_max */
348 29, /* agc2_slope1 */
349 29, /* agc2_slope2 */
356 1, /* perform_agc_softsplit */
359 /* PLL Configuration for COFDM BW_MHz = 8.00 with external clock = 30.00 */
360 static struct dibx000_bandwidth_config xc3028_bw_config
= {
361 60000, 30000, /* internal, sampling */
362 1, 8, 3, 1, 0, /* pll_cfg: prediv, ratio, range, reset, bypass */
363 0, 0, 1, 1, 0, /* misc: refdiv, bypclk_div, IO_CLK_en_core, ADClkSrc,
365 (3 << 14) | (1 << 12) | (524 << 0), /* sad_cfg: refsel, sel, freq_15k */
366 (1 << 25) | 5816102, /* ifreq = 5.200000 MHz */
368 30000000, /* xtal_hz */
371 static struct dib7000p_config stk7700ph_dib7700_xc3028_config
= {
372 .output_mpeg2_in_188_bytes
= 1,
373 .tuner_is_baseband
= 1,
375 .agc_config_count
= 1,
376 .agc
= &xc3028_agc_config
,
377 .bw
= &xc3028_bw_config
,
379 .gpio_dir
= DIB7000P_GPIO_DEFAULT_DIRECTIONS
,
380 .gpio_val
= DIB7000P_GPIO_DEFAULT_VALUES
,
381 .gpio_pwm_pos
= DIB7000P_GPIO_DEFAULT_PWM_POS
,
384 static int stk7700ph_xc3028_callback(void *ptr
, int component
,
385 int command
, int arg
)
387 struct dvb_usb_adapter
*adap
= ptr
;
390 case XC2028_TUNER_RESET
:
391 /* Send the tuner in then out of reset */
392 dib7000p_set_gpio(adap
->fe
, 8, 0, 0); msleep(10);
393 dib7000p_set_gpio(adap
->fe
, 8, 0, 1);
395 case XC2028_RESET_CLK
:
398 err("%s: unknown command %d, arg %d\n", __func__
,
405 static struct xc2028_ctrl stk7700ph_xc3028_ctrl
= {
406 .fname
= XC2028_DEFAULT_FIRMWARE
,
408 .demod
= XC3028_FE_DIBCOM52
,
411 static struct xc2028_config stk7700ph_xc3028_config
= {
413 .ctrl
= &stk7700ph_xc3028_ctrl
,
416 static int stk7700ph_frontend_attach(struct dvb_usb_adapter
*adap
)
418 struct usb_device_descriptor
*desc
= &adap
->dev
->udev
->descriptor
;
420 if (desc
->idVendor
== cpu_to_le16(USB_VID_PINNACLE
) &&
421 desc
->idProduct
== cpu_to_le16(USB_PID_PINNACLE_EXPRESSCARD_320CX
))
422 dib0700_set_gpio(adap
->dev
, GPIO6
, GPIO_OUT
, 0);
424 dib0700_set_gpio(adap
->dev
, GPIO6
, GPIO_OUT
, 1);
426 dib0700_set_gpio(adap
->dev
, GPIO9
, GPIO_OUT
, 1);
427 dib0700_set_gpio(adap
->dev
, GPIO4
, GPIO_OUT
, 1);
428 dib0700_set_gpio(adap
->dev
, GPIO7
, GPIO_OUT
, 1);
429 dib0700_set_gpio(adap
->dev
, GPIO10
, GPIO_OUT
, 0);
431 dib0700_set_gpio(adap
->dev
, GPIO10
, GPIO_OUT
, 1);
433 dib0700_set_gpio(adap
->dev
, GPIO0
, GPIO_OUT
, 1);
436 if (dib7000p_i2c_enumeration(&adap
->dev
->i2c_adap
, 1, 18,
437 &stk7700ph_dib7700_xc3028_config
) != 0) {
438 err("%s: dib7000p_i2c_enumeration failed. Cannot continue\n",
443 adap
->fe
= dvb_attach(dib7000p_attach
, &adap
->dev
->i2c_adap
, 0x80,
444 &stk7700ph_dib7700_xc3028_config
);
446 return adap
->fe
== NULL
? -ENODEV
: 0;
449 static int stk7700ph_tuner_attach(struct dvb_usb_adapter
*adap
)
451 struct i2c_adapter
*tun_i2c
;
453 tun_i2c
= dib7000p_get_i2c_master(adap
->fe
,
454 DIBX000_I2C_INTERFACE_TUNER
, 1);
456 stk7700ph_xc3028_config
.i2c_adap
= tun_i2c
;
458 /* FIXME: generalize & move to common area */
459 adap
->fe
->callback
= stk7700ph_xc3028_callback
;
461 return dvb_attach(xc2028_attach
, adap
->fe
, &stk7700ph_xc3028_config
)
462 == NULL
? -ENODEV
: 0;
465 #define DEFAULT_RC_INTERVAL 50
467 static u8 rc_request
[] = { REQUEST_POLL_RC
, 0 };
469 /* Number of keypresses to ignore before start repeating */
470 #define RC_REPEAT_DELAY 6
471 #define RC_REPEAT_DELAY_V1_20 10
475 /* Used by firmware versions < 1.20 (deprecated) */
476 static int dib0700_rc_query_legacy(struct dvb_usb_device
*d
, u32
*event
,
481 struct dvb_usb_rc_key
*keymap
= d
->props
.rc_key_map
;
482 struct dib0700_state
*st
= d
->priv
;
484 *state
= REMOTE_NO_KEY_PRESSED
;
485 i
=dib0700_ctrl_rd(d
,rc_request
,2,key
,4);
487 err("RC Query Failed");
491 /* losing half of KEY_0 events from Philipps rc5 remotes.. */
492 if (key
[0]==0 && key
[1]==0 && key
[2]==0 && key
[3]==0) return 0;
494 /* info("%d: %2X %2X %2X %2X",dvb_usb_dib0700_ir_proto,(int)key[3-2],(int)key[3-3],(int)key[3-1],(int)key[3]); */
496 dib0700_rc_setup(d
); /* reset ir sensor data to prevent false events */
498 switch (dvb_usb_dib0700_ir_proto
) {
500 /* NEC protocol sends repeat code as 0 0 0 FF */
501 if ((key
[3-2] == 0x00) && (key
[3-3] == 0x00) &&
504 if (st
->rc_counter
> RC_REPEAT_DELAY
) {
505 *event
= d
->last_event
;
506 *state
= REMOTE_KEY_PRESSED
;
507 st
->rc_counter
= RC_REPEAT_DELAY
;
511 for (i
=0;i
<d
->props
.rc_key_map_size
; i
++) {
512 if (rc5_custom(&keymap
[i
]) == key
[3-2] &&
513 rc5_data(&keymap
[i
]) == key
[3-3]) {
515 *event
= keymap
[i
].event
;
516 *state
= REMOTE_KEY_PRESSED
;
517 d
->last_event
= keymap
[i
].event
;
524 /* RC-5 protocol changes toggle bit on new keypress */
525 for (i
= 0; i
< d
->props
.rc_key_map_size
; i
++) {
526 if (rc5_custom(&keymap
[i
]) == key
[3-2] &&
527 rc5_data(&keymap
[i
]) == key
[3-3]) {
528 if (d
->last_event
== keymap
[i
].event
&&
529 key
[3-1] == st
->rc_toggle
) {
531 /* prevents unwanted double hits */
532 if (st
->rc_counter
> RC_REPEAT_DELAY
) {
533 *event
= d
->last_event
;
534 *state
= REMOTE_KEY_PRESSED
;
535 st
->rc_counter
= RC_REPEAT_DELAY
;
541 *event
= keymap
[i
].event
;
542 *state
= REMOTE_KEY_PRESSED
;
543 st
->rc_toggle
= key
[3-1];
544 d
->last_event
= keymap
[i
].event
;
551 err("Unknown remote controller key: %2X %2X %2X %2X", (int) key
[3-2], (int) key
[3-3], (int) key
[3-1], (int) key
[3]);
556 /* This is the structure of the RC response packet starting in firmware 1.20 */
557 struct dib0700_rc_response
{
566 /* This supports the new IR response format for firmware v1.20 */
567 static int dib0700_rc_query_v1_20(struct dvb_usb_device
*d
, u32
*event
,
570 struct dvb_usb_rc_key
*keymap
= d
->props
.rc_key_map
;
571 struct dib0700_state
*st
= d
->priv
;
572 struct dib0700_rc_response poll_reply
;
579 /* Set initial results in case we exit the function early */
581 *state
= REMOTE_NO_KEY_PRESSED
;
583 /* Firmware v1.20 provides RC data via bulk endpoint 1 */
584 status
= usb_bulk_msg(d
->udev
, usb_rcvbulkpipe(d
->udev
, 1), buf
,
585 sizeof(buf
), &actlen
, 50);
587 /* No data available (meaning no key press) */
591 if (actlen
!= sizeof(buf
)) {
592 /* We didn't get back the 6 byte message we expected */
593 err("Unexpected RC response size [%d]", actlen
);
597 poll_reply
.report_id
= buf
[0];
598 poll_reply
.data_state
= buf
[1];
599 poll_reply
.system_msb
= buf
[2];
600 poll_reply
.system_lsb
= buf
[3];
601 poll_reply
.data
= buf
[4];
602 poll_reply
.not_data
= buf
[5];
605 info("rid=%02x ds=%02x sm=%02x sl=%02x d=%02x nd=%02x\n",
606 poll_reply.report_id, poll_reply.data_state,
607 poll_reply.system_msb, poll_reply.system_lsb,
608 poll_reply.data, poll_reply.not_data);
611 if ((poll_reply
.data
+ poll_reply
.not_data
) != 0xff) {
612 /* Key failed integrity check */
613 err("key failed integrity check: %02x %02x %02x %02x",
614 poll_reply
.system_msb
, poll_reply
.system_lsb
,
615 poll_reply
.data
, poll_reply
.not_data
);
619 /* Find the key in the map */
620 for (i
= 0; i
< d
->props
.rc_key_map_size
; i
++) {
621 if (rc5_custom(&keymap
[i
]) == poll_reply
.system_lsb
&&
622 rc5_data(&keymap
[i
]) == poll_reply
.data
) {
623 *event
= keymap
[i
].event
;
630 err("Unknown remote controller key: %02x %02x %02x %02x",
631 poll_reply
.system_msb
, poll_reply
.system_lsb
,
632 poll_reply
.data
, poll_reply
.not_data
);
637 if (poll_reply
.data_state
== 1) {
640 *event
= keymap
[i
].event
;
641 *state
= REMOTE_KEY_PRESSED
;
642 d
->last_event
= keymap
[i
].event
;
643 } else if (poll_reply
.data_state
== 2) {
647 /* prevents unwanted double hits */
648 if (st
->rc_counter
> RC_REPEAT_DELAY_V1_20
) {
649 *event
= d
->last_event
;
650 *state
= REMOTE_KEY_PRESSED
;
651 st
->rc_counter
= RC_REPEAT_DELAY_V1_20
;
654 err("Unknown data state [%d]", poll_reply
.data_state
);
660 static int dib0700_rc_query(struct dvb_usb_device
*d
, u32
*event
, int *state
)
662 struct dib0700_state
*st
= d
->priv
;
664 /* Because some people may have improperly named firmware files,
665 let's figure out whether to use the new firmware call or the legacy
666 call based on the firmware version embedded in the file */
667 if (st
->rc_func_version
== 0) {
668 u32 hwver
, romver
, ramver
, fwtype
;
669 int ret
= dib0700_get_version(d
, &hwver
, &romver
, &ramver
,
672 err("Could not determine version info");
675 if (ramver
< 0x10200)
676 st
->rc_func_version
= 1;
678 st
->rc_func_version
= 2;
681 if (st
->rc_func_version
== 2)
682 return dib0700_rc_query_v1_20(d
, event
, state
);
684 return dib0700_rc_query_legacy(d
, event
, state
);
687 static struct dvb_usb_rc_key dib0700_rc_keys
[] = {
688 /* Key codes for the tiny Pinnacle remote*/
689 { 0x0700, KEY_MUTE
},
690 { 0x0701, KEY_MENU
}, /* Pinnacle logo */
691 { 0x0739, KEY_POWER
},
692 { 0x0703, KEY_VOLUMEUP
},
693 { 0x0709, KEY_VOLUMEDOWN
},
694 { 0x0706, KEY_CHANNELUP
},
695 { 0x070c, KEY_CHANNELDOWN
},
706 { 0x0724, KEY_SCREEN
}, /* 'Square' key */
707 { 0x072a, KEY_TEXT
}, /* 'T' key */
708 { 0x072d, KEY_REWIND
},
709 { 0x0730, KEY_PLAY
},
710 { 0x0733, KEY_FASTFORWARD
},
711 { 0x0736, KEY_RECORD
},
712 { 0x073c, KEY_STOP
},
713 { 0x073f, KEY_CANCEL
}, /* '?' key */
714 /* Key codes for the Terratec Cinergy DT XS Diversity, similar to cinergyT2.c */
715 { 0xeb01, KEY_POWER
},
725 { 0xeb0b, KEY_VIDEO
},
727 { 0xeb0d, KEY_REFRESH
},
730 { 0xeb11, KEY_LEFT
},
732 { 0xeb13, KEY_RIGHT
},
733 { 0xeb14, KEY_DOWN
},
734 { 0xeb16, KEY_INFO
},
736 { 0xeb18, KEY_GREEN
},
737 { 0xeb19, KEY_YELLOW
},
738 { 0xeb1a, KEY_BLUE
},
739 { 0xeb1b, KEY_CHANNELUP
},
740 { 0xeb1c, KEY_VOLUMEUP
},
741 { 0xeb1d, KEY_MUTE
},
742 { 0xeb1e, KEY_VOLUMEDOWN
},
743 { 0xeb1f, KEY_CHANNELDOWN
},
744 { 0xeb40, KEY_PAUSE
},
745 { 0xeb41, KEY_HOME
},
746 { 0xeb42, KEY_MENU
}, /* DVD Menu */
747 { 0xeb43, KEY_SUBTITLE
},
748 { 0xeb44, KEY_TEXT
}, /* Teletext */
749 { 0xeb45, KEY_DELETE
},
752 { 0xeb48, KEY_STOP
},
753 { 0xeb49, KEY_VIDEO
},
754 { 0xeb4a, KEY_AUDIO
}, /* Music */
755 { 0xeb4b, KEY_SCREEN
}, /* Pic */
756 { 0xeb4c, KEY_PLAY
},
757 { 0xeb4d, KEY_BACK
},
758 { 0xeb4e, KEY_REWIND
},
759 { 0xeb4f, KEY_FASTFORWARD
},
760 { 0xeb54, KEY_PREVIOUS
},
761 { 0xeb58, KEY_RECORD
},
762 { 0xeb5c, KEY_NEXT
},
764 /* Key codes for the Haupauge WinTV Nova-TD, copied from nova-t-usb2.c (Nova-T USB2) */
775 { 0x1e0a, KEY_KPASTERISK
},
777 { 0x1e0c, KEY_RADIO
},
778 { 0x1e0d, KEY_MENU
},
779 { 0x1e0e, KEY_GRAVE
}, /* # */
780 { 0x1e0f, KEY_MUTE
},
781 { 0x1e10, KEY_VOLUMEUP
},
782 { 0x1e11, KEY_VOLUMEDOWN
},
783 { 0x1e12, KEY_CHANNEL
},
785 { 0x1e15, KEY_DOWN
},
786 { 0x1e16, KEY_LEFT
},
787 { 0x1e17, KEY_RIGHT
},
788 { 0x1e18, KEY_VIDEO
},
789 { 0x1e19, KEY_AUDIO
},
790 { 0x1e1a, KEY_MEDIA
},
793 { 0x1e1e, KEY_NEXT
},
794 { 0x1e1f, KEY_BACK
},
795 { 0x1e20, KEY_CHANNELUP
},
796 { 0x1e21, KEY_CHANNELDOWN
},
797 { 0x1e24, KEY_LAST
}, /* Skip backwards */
800 { 0x1e2e, KEY_GREEN
},
801 { 0x1e30, KEY_PAUSE
},
802 { 0x1e32, KEY_REWIND
},
803 { 0x1e34, KEY_FASTFORWARD
},
804 { 0x1e35, KEY_PLAY
},
805 { 0x1e36, KEY_STOP
},
806 { 0x1e37, KEY_RECORD
},
807 { 0x1e38, KEY_YELLOW
},
808 { 0x1e3b, KEY_GOTO
},
809 { 0x1e3d, KEY_POWER
},
811 /* Key codes for the Leadtek Winfast DTV Dongle */
812 { 0x0042, KEY_POWER
},
813 { 0x077c, KEY_TUNER
},
814 { 0x0f4e, KEY_PRINT
}, /* PREVIEW */
815 { 0x0840, KEY_SCREEN
}, /* full screen toggle*/
816 { 0x0f71, KEY_DOT
}, /* frequency */
827 { 0x0e4e, KEY_CLEAR
},
828 { 0x047c, KEY_CHANNEL
}, /* show channel number */
829 { 0x0f41, KEY_LAST
}, /* recall */
830 { 0x0342, KEY_MUTE
},
831 { 0x064c, KEY_RESERVED
}, /* PIP button*/
832 { 0x0172, KEY_SHUFFLE
}, /* SNAPSHOT */
833 { 0x0c4e, KEY_PLAYPAUSE
}, /* TIMESHIFT */
834 { 0x0b70, KEY_RECORD
},
835 { 0x037d, KEY_VOLUMEUP
},
836 { 0x017d, KEY_VOLUMEDOWN
},
837 { 0x0242, KEY_CHANNELUP
},
838 { 0x007d, KEY_CHANNELDOWN
},
840 /* Key codes for Nova-TD "credit card" remote control. */
851 { 0x1d0a, KEY_TEXT
},
852 { 0x1d0d, KEY_MENU
},
853 { 0x1d0f, KEY_MUTE
},
854 { 0x1d10, KEY_VOLUMEUP
},
855 { 0x1d11, KEY_VOLUMEDOWN
},
856 { 0x1d12, KEY_CHANNEL
},
858 { 0x1d15, KEY_DOWN
},
859 { 0x1d16, KEY_LEFT
},
860 { 0x1d17, KEY_RIGHT
},
862 { 0x1d1e, KEY_NEXT
},
863 { 0x1d1f, KEY_BACK
},
864 { 0x1d20, KEY_CHANNELUP
},
865 { 0x1d21, KEY_CHANNELDOWN
},
866 { 0x1d24, KEY_LAST
},
868 { 0x1d30, KEY_PAUSE
},
869 { 0x1d32, KEY_REWIND
},
870 { 0x1d34, KEY_FASTFORWARD
},
871 { 0x1d35, KEY_PLAY
},
872 { 0x1d36, KEY_STOP
},
873 { 0x1d37, KEY_RECORD
},
874 { 0x1d3b, KEY_GOTO
},
875 { 0x1d3d, KEY_POWER
},
878 /* STK7700P: Hauppauge Nova-T Stick, AVerMedia Volar */
879 static struct dibx000_agc_config stk7700p_7000m_mt2060_agc_config
= {
880 BAND_UHF
| BAND_VHF
, // band_caps
882 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=5, P_agc_inv_pwm1=0, P_agc_inv_pwm2=0,
883 * P_agc_inh_dc_rv_est=0, P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=2, P_agc_write=0 */
884 (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8) | (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0), // setup
916 1, // perform_agc_softsplit
919 51800, // global_split_min
920 24700 // global_split_max
924 static struct dibx000_agc_config stk7700p_7000p_mt2060_agc_config
= {
927 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=5, P_agc_inv_pwm1=0, P_agc_inv_pwm2=0,
928 * P_agc_inh_dc_rv_est=0, P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=2, P_agc_write=0 */
929 (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8) | (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0), // setup
966 0, // perform_agc_softsplit
969 static struct dibx000_bandwidth_config stk7700p_pll_config
= {
970 60000, 30000, // internal, sampling
971 1, 8, 3, 1, 0, // pll_cfg: prediv, ratio, range, reset, bypass
972 0, 0, 1, 1, 0, // misc: refdiv, bypclk_div, IO_CLK_en_core, ADClkSrc, modulo
973 (3 << 14) | (1 << 12) | (524 << 0), // sad_cfg: refsel, sel, freq_15k
979 static struct dib7000m_config stk7700p_dib7000m_config
= {
981 .output_mpeg2_in_188_bytes
= 1,
984 .agc_config_count
= 1,
985 .agc
= &stk7700p_7000m_mt2060_agc_config
,
986 .bw
= &stk7700p_pll_config
,
988 .gpio_dir
= DIB7000M_GPIO_DEFAULT_DIRECTIONS
,
989 .gpio_val
= DIB7000M_GPIO_DEFAULT_VALUES
,
990 .gpio_pwm_pos
= DIB7000M_GPIO_DEFAULT_PWM_POS
,
993 static struct dib7000p_config stk7700p_dib7000p_config
= {
994 .output_mpeg2_in_188_bytes
= 1,
996 .agc_config_count
= 1,
997 .agc
= &stk7700p_7000p_mt2060_agc_config
,
998 .bw
= &stk7700p_pll_config
,
1000 .gpio_dir
= DIB7000M_GPIO_DEFAULT_DIRECTIONS
,
1001 .gpio_val
= DIB7000M_GPIO_DEFAULT_VALUES
,
1002 .gpio_pwm_pos
= DIB7000M_GPIO_DEFAULT_PWM_POS
,
1005 static int stk7700p_frontend_attach(struct dvb_usb_adapter
*adap
)
1007 struct dib0700_state
*st
= adap
->dev
->priv
;
1008 /* unless there is no real power management in DVB - we leave the device on GPIO6 */
1010 dib0700_set_gpio(adap
->dev
, GPIO10
, GPIO_OUT
, 0);
1011 dib0700_set_gpio(adap
->dev
, GPIO6
, GPIO_OUT
, 0); msleep(50);
1013 dib0700_set_gpio(adap
->dev
, GPIO6
, GPIO_OUT
, 1); msleep(10);
1014 dib0700_set_gpio(adap
->dev
, GPIO9
, GPIO_OUT
, 1);
1016 dib0700_set_gpio(adap
->dev
, GPIO10
, GPIO_OUT
, 0); msleep(10);
1017 dib0700_ctrl_clock(adap
->dev
, 72, 1);
1018 dib0700_set_gpio(adap
->dev
, GPIO10
, GPIO_OUT
, 1); msleep(100);
1020 dib0700_set_gpio(adap
->dev
, GPIO0
, GPIO_OUT
, 1);
1022 st
->mt2060_if1
[0] = 1220;
1024 if (dib7000pc_detection(&adap
->dev
->i2c_adap
)) {
1025 adap
->fe
= dvb_attach(dib7000p_attach
, &adap
->dev
->i2c_adap
, 18, &stk7700p_dib7000p_config
);
1026 st
->is_dib7000pc
= 1;
1028 adap
->fe
= dvb_attach(dib7000m_attach
, &adap
->dev
->i2c_adap
, 18, &stk7700p_dib7000m_config
);
1030 return adap
->fe
== NULL
? -ENODEV
: 0;
1033 static struct mt2060_config stk7700p_mt2060_config
= {
1037 static int stk7700p_tuner_attach(struct dvb_usb_adapter
*adap
)
1039 struct i2c_adapter
*prim_i2c
= &adap
->dev
->i2c_adap
;
1040 struct dib0700_state
*st
= adap
->dev
->priv
;
1041 struct i2c_adapter
*tun_i2c
;
1044 if (adap
->dev
->udev
->descriptor
.idVendor
== cpu_to_le16(USB_VID_HAUPPAUGE
) &&
1045 adap
->dev
->udev
->descriptor
.idProduct
== cpu_to_le16(USB_PID_HAUPPAUGE_NOVA_T_STICK
)) {
1046 if (!eeprom_read(prim_i2c
,0x58,&a
)) if1
=1220+a
;
1048 if (st
->is_dib7000pc
)
1049 tun_i2c
= dib7000p_get_i2c_master(adap
->fe
, DIBX000_I2C_INTERFACE_TUNER
, 1);
1051 tun_i2c
= dib7000m_get_i2c_master(adap
->fe
, DIBX000_I2C_INTERFACE_TUNER
, 1);
1053 return dvb_attach(mt2060_attach
, adap
->fe
, tun_i2c
, &stk7700p_mt2060_config
,
1054 if1
) == NULL
? -ENODEV
: 0;
1057 /* DIB7070 generic */
1058 static struct dibx000_agc_config dib7070_agc_config
= {
1059 BAND_UHF
| BAND_VHF
| BAND_LBAND
| BAND_SBAND
,
1060 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=5, P_agc_inv_pwm1=0, P_agc_inv_pwm2=0,
1061 * P_agc_inh_dc_rv_est=0, P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5, P_agc_write=0 */
1062 (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0), // setup
1065 10, // time_stabiliz
1096 0, // perform_agc_softsplit
1099 static int dib7070_tuner_reset(struct dvb_frontend
*fe
, int onoff
)
1101 return dib7000p_set_gpio(fe
, 8, 0, !onoff
);
1104 static int dib7070_tuner_sleep(struct dvb_frontend
*fe
, int onoff
)
1106 return dib7000p_set_gpio(fe
, 9, 0, onoff
);
1109 static struct dib0070_config dib7070p_dib0070_config
[2] = {
1111 .i2c_address
= DEFAULT_DIB0070_I2C_ADDRESS
,
1112 .reset
= dib7070_tuner_reset
,
1113 .sleep
= dib7070_tuner_sleep
,
1115 .clock_pad_drive
= 4
1117 .i2c_address
= DEFAULT_DIB0070_I2C_ADDRESS
,
1118 .reset
= dib7070_tuner_reset
,
1119 .sleep
= dib7070_tuner_sleep
,
1125 static int dib7070_set_param_override(struct dvb_frontend
*fe
, struct dvb_frontend_parameters
*fep
)
1127 struct dvb_usb_adapter
*adap
= fe
->dvb
->priv
;
1128 struct dib0700_adapter_state
*state
= adap
->priv
;
1131 u8 band
= BAND_OF_FREQUENCY(fep
->frequency
/1000);
1133 case BAND_VHF
: offset
= 950; break;
1135 default: offset
= 550; break;
1137 deb_info("WBD for DiB7000P: %d\n", offset
+ dib0070_wbd_offset(fe
));
1138 dib7000p_set_wbd_ref(fe
, offset
+ dib0070_wbd_offset(fe
));
1139 return state
->set_param_save(fe
, fep
);
1142 static int dib7070p_tuner_attach(struct dvb_usb_adapter
*adap
)
1144 struct dib0700_adapter_state
*st
= adap
->priv
;
1145 struct i2c_adapter
*tun_i2c
= dib7000p_get_i2c_master(adap
->fe
, DIBX000_I2C_INTERFACE_TUNER
, 1);
1147 if (adap
->id
== 0) {
1148 if (dvb_attach(dib0070_attach
, adap
->fe
, tun_i2c
, &dib7070p_dib0070_config
[0]) == NULL
)
1151 if (dvb_attach(dib0070_attach
, adap
->fe
, tun_i2c
, &dib7070p_dib0070_config
[1]) == NULL
)
1155 st
->set_param_save
= adap
->fe
->ops
.tuner_ops
.set_params
;
1156 adap
->fe
->ops
.tuner_ops
.set_params
= dib7070_set_param_override
;
1160 static struct dibx000_bandwidth_config dib7070_bw_config_12_mhz
= {
1161 60000, 15000, // internal, sampling
1162 1, 20, 3, 1, 0, // pll_cfg: prediv, ratio, range, reset, bypass
1163 0, 0, 1, 1, 2, // misc: refdiv, bypclk_div, IO_CLK_en_core, ADClkSrc, modulo
1164 (3 << 14) | (1 << 12) | (524 << 0), // sad_cfg: refsel, sel, freq_15k
1165 (0 << 25) | 0, // ifreq = 0.000000 MHz
1167 12000000, // xtal_hz
1170 static struct dib7000p_config dib7070p_dib7000p_config
= {
1171 .output_mpeg2_in_188_bytes
= 1,
1173 .agc_config_count
= 1,
1174 .agc
= &dib7070_agc_config
,
1175 .bw
= &dib7070_bw_config_12_mhz
,
1176 .tuner_is_baseband
= 1,
1179 .gpio_dir
= DIB7000P_GPIO_DEFAULT_DIRECTIONS
,
1180 .gpio_val
= DIB7000P_GPIO_DEFAULT_VALUES
,
1181 .gpio_pwm_pos
= DIB7000P_GPIO_DEFAULT_PWM_POS
,
1183 .hostbus_diversity
= 1,
1187 static int stk7070p_frontend_attach(struct dvb_usb_adapter
*adap
)
1189 struct usb_device_descriptor
*p
= &adap
->dev
->udev
->descriptor
;
1190 if (p
->idVendor
== cpu_to_le16(USB_VID_PINNACLE
) &&
1191 p
->idProduct
== cpu_to_le16(USB_PID_PINNACLE_PCTV72E
))
1192 dib0700_set_gpio(adap
->dev
, GPIO6
, GPIO_OUT
, 0);
1194 dib0700_set_gpio(adap
->dev
, GPIO6
, GPIO_OUT
, 1);
1196 dib0700_set_gpio(adap
->dev
, GPIO9
, GPIO_OUT
, 1);
1197 dib0700_set_gpio(adap
->dev
, GPIO4
, GPIO_OUT
, 1);
1198 dib0700_set_gpio(adap
->dev
, GPIO7
, GPIO_OUT
, 1);
1199 dib0700_set_gpio(adap
->dev
, GPIO10
, GPIO_OUT
, 0);
1201 dib0700_ctrl_clock(adap
->dev
, 72, 1);
1204 dib0700_set_gpio(adap
->dev
, GPIO10
, GPIO_OUT
, 1);
1206 dib0700_set_gpio(adap
->dev
, GPIO0
, GPIO_OUT
, 1);
1208 if (dib7000p_i2c_enumeration(&adap
->dev
->i2c_adap
, 1, 18,
1209 &dib7070p_dib7000p_config
) != 0) {
1210 err("%s: dib7000p_i2c_enumeration failed. Cannot continue\n",
1215 adap
->fe
= dvb_attach(dib7000p_attach
, &adap
->dev
->i2c_adap
, 0x80,
1216 &dib7070p_dib7000p_config
);
1217 return adap
->fe
== NULL
? -ENODEV
: 0;
1221 static struct dib7000p_config stk7070pd_dib7000p_config
[2] = {
1223 .output_mpeg2_in_188_bytes
= 1,
1225 .agc_config_count
= 1,
1226 .agc
= &dib7070_agc_config
,
1227 .bw
= &dib7070_bw_config_12_mhz
,
1228 .tuner_is_baseband
= 1,
1231 .gpio_dir
= DIB7000P_GPIO_DEFAULT_DIRECTIONS
,
1232 .gpio_val
= DIB7000P_GPIO_DEFAULT_VALUES
,
1233 .gpio_pwm_pos
= DIB7000P_GPIO_DEFAULT_PWM_POS
,
1235 .hostbus_diversity
= 1,
1237 .output_mpeg2_in_188_bytes
= 1,
1239 .agc_config_count
= 1,
1240 .agc
= &dib7070_agc_config
,
1241 .bw
= &dib7070_bw_config_12_mhz
,
1242 .tuner_is_baseband
= 1,
1245 .gpio_dir
= DIB7000P_GPIO_DEFAULT_DIRECTIONS
,
1246 .gpio_val
= DIB7000P_GPIO_DEFAULT_VALUES
,
1247 .gpio_pwm_pos
= DIB7000P_GPIO_DEFAULT_PWM_POS
,
1249 .hostbus_diversity
= 1,
1253 static int stk7070pd_frontend_attach0(struct dvb_usb_adapter
*adap
)
1255 dib0700_set_gpio(adap
->dev
, GPIO6
, GPIO_OUT
, 1);
1257 dib0700_set_gpio(adap
->dev
, GPIO9
, GPIO_OUT
, 1);
1258 dib0700_set_gpio(adap
->dev
, GPIO4
, GPIO_OUT
, 1);
1259 dib0700_set_gpio(adap
->dev
, GPIO7
, GPIO_OUT
, 1);
1260 dib0700_set_gpio(adap
->dev
, GPIO10
, GPIO_OUT
, 0);
1262 dib0700_ctrl_clock(adap
->dev
, 72, 1);
1265 dib0700_set_gpio(adap
->dev
, GPIO10
, GPIO_OUT
, 1);
1267 dib0700_set_gpio(adap
->dev
, GPIO0
, GPIO_OUT
, 1);
1269 if (dib7000p_i2c_enumeration(&adap
->dev
->i2c_adap
, 2, 18,
1270 stk7070pd_dib7000p_config
) != 0) {
1271 err("%s: dib7000p_i2c_enumeration failed. Cannot continue\n",
1276 adap
->fe
= dvb_attach(dib7000p_attach
, &adap
->dev
->i2c_adap
, 0x80, &stk7070pd_dib7000p_config
[0]);
1277 return adap
->fe
== NULL
? -ENODEV
: 0;
1280 static int stk7070pd_frontend_attach1(struct dvb_usb_adapter
*adap
)
1282 adap
->fe
= dvb_attach(dib7000p_attach
, &adap
->dev
->i2c_adap
, 0x82, &stk7070pd_dib7000p_config
[1]);
1283 return adap
->fe
== NULL
? -ENODEV
: 0;
1287 static struct s5h1411_config pinnacle_801e_config
= {
1288 .output_mode
= S5H1411_PARALLEL_OUTPUT
,
1289 .gpio
= S5H1411_GPIO_OFF
,
1290 .mpeg_timing
= S5H1411_MPEGTIMING_NONCONTINOUS_NONINVERTING_CLOCK
,
1291 .qam_if
= S5H1411_IF_44000
,
1292 .vsb_if
= S5H1411_IF_44000
,
1293 .inversion
= S5H1411_INVERSION_OFF
,
1294 .status_mode
= S5H1411_DEMODLOCKING
1297 /* Pinnacle PCTV HD Pro 801e GPIOs map:
1298 GPIO0 - currently unknown
1299 GPIO1 - xc5000 tuner reset
1300 GPIO2 - CX25843 sleep
1301 GPIO3 - currently unknown
1302 GPIO4 - currently unknown
1303 GPIO6 - currently unknown
1304 GPIO7 - currently unknown
1305 GPIO9 - currently unknown
1306 GPIO10 - CX25843 reset
1308 static int s5h1411_frontend_attach(struct dvb_usb_adapter
*adap
)
1310 struct dib0700_state
*st
= adap
->dev
->priv
;
1312 /* Make use of the new i2c functions from FW 1.20 */
1313 st
->fw_use_new_i2c_api
= 1;
1315 /* The s5h1411 requires the dib0700 to not be in master mode */
1316 st
->disable_streaming_master_mode
= 1;
1318 /* All msleep values taken from Windows USB trace */
1319 dib0700_set_gpio(adap
->dev
, GPIO0
, GPIO_OUT
, 0);
1320 dib0700_set_gpio(adap
->dev
, GPIO3
, GPIO_OUT
, 0);
1321 dib0700_set_gpio(adap
->dev
, GPIO6
, GPIO_OUT
, 1);
1323 dib0700_set_gpio(adap
->dev
, GPIO10
, GPIO_OUT
, 0);
1325 dib0700_set_gpio(adap
->dev
, GPIO10
, GPIO_OUT
, 1);
1327 dib0700_set_gpio(adap
->dev
, GPIO0
, GPIO_OUT
, 1);
1328 dib0700_set_gpio(adap
->dev
, GPIO9
, GPIO_OUT
, 1);
1329 dib0700_set_gpio(adap
->dev
, GPIO4
, GPIO_OUT
, 1);
1330 dib0700_set_gpio(adap
->dev
, GPIO7
, GPIO_OUT
, 1);
1331 dib0700_set_gpio(adap
->dev
, GPIO2
, GPIO_OUT
, 0);
1334 /* Put the CX25843 to sleep for now since we're in digital mode */
1335 dib0700_set_gpio(adap
->dev
, GPIO2
, GPIO_OUT
, 1);
1337 /* GPIOs are initialized, do the attach */
1338 adap
->fe
= dvb_attach(s5h1411_attach
, &pinnacle_801e_config
,
1339 &adap
->dev
->i2c_adap
);
1340 return adap
->fe
== NULL
? -ENODEV
: 0;
1343 static int dib0700_xc5000_tuner_callback(void *priv
, int component
,
1344 int command
, int arg
)
1346 struct dvb_usb_adapter
*adap
= priv
;
1348 if (command
== XC5000_TUNER_RESET
) {
1349 /* Reset the tuner */
1350 dib0700_set_gpio(adap
->dev
, GPIO1
, GPIO_OUT
, 0);
1352 dib0700_set_gpio(adap
->dev
, GPIO1
, GPIO_OUT
, 1);
1355 err("xc5000: unknown tuner callback command: %d\n", command
);
1362 static struct xc5000_config s5h1411_xc5000_tunerconfig
= {
1363 .i2c_address
= 0x64,
1367 static int xc5000_tuner_attach(struct dvb_usb_adapter
*adap
)
1369 /* FIXME: generalize & move to common area */
1370 adap
->fe
->callback
= dib0700_xc5000_tuner_callback
;
1372 return dvb_attach(xc5000_attach
, adap
->fe
, &adap
->dev
->i2c_adap
,
1373 &s5h1411_xc5000_tunerconfig
)
1374 == NULL
? -ENODEV
: 0;
1377 static struct lgdt3305_config hcw_lgdt3305_config
= {
1379 .mpeg_mode
= LGDT3305_MPEG_PARALLEL
,
1380 .tpclk_edge
= LGDT3305_TPCLK_FALLING_EDGE
,
1381 .tpvalid_polarity
= LGDT3305_TP_VALID_LOW
,
1383 .spectral_inversion
= 1,
1386 .usref_8vsb
= 0x0500,
1389 static struct mxl5007t_config hcw_mxl5007t_config
= {
1390 .xtal_freq_hz
= MxL_XTAL_25_MHZ
,
1391 .if_freq_hz
= MxL_IF_6_MHZ
,
1396 GPIO0 - LNA_CTR (H: LNA power enabled, L: LNA power disabled)
1397 GPIO1 - ANT_SEL (H: VPA, L: MCX)
1403 MXL is behind LG's i2c repeater. LG is on SCL2/SDA2 gpios on the DIB
1405 static int lgdt3305_frontend_attach(struct dvb_usb_adapter
*adap
)
1407 struct dib0700_state
*st
= adap
->dev
->priv
;
1409 /* Make use of the new i2c functions from FW 1.20 */
1410 st
->fw_use_new_i2c_api
= 1;
1412 st
->disable_streaming_master_mode
= 1;
1414 /* fe power enable */
1415 dib0700_set_gpio(adap
->dev
, GPIO6
, GPIO_OUT
, 0);
1417 dib0700_set_gpio(adap
->dev
, GPIO6
, GPIO_OUT
, 1);
1421 dib0700_set_gpio(adap
->dev
, GPIO10
, GPIO_OUT
, 1);
1423 dib0700_set_gpio(adap
->dev
, GPIO10
, GPIO_OUT
, 0);
1425 dib0700_set_gpio(adap
->dev
, GPIO10
, GPIO_OUT
, 1);
1428 adap
->fe
= dvb_attach(lgdt3305_attach
,
1429 &hcw_lgdt3305_config
,
1430 &adap
->dev
->i2c_adap
);
1432 return adap
->fe
== NULL
? -ENODEV
: 0;
1435 static int mxl5007t_tuner_attach(struct dvb_usb_adapter
*adap
)
1437 return dvb_attach(mxl5007t_attach
, adap
->fe
,
1438 &adap
->dev
->i2c_adap
, 0x60,
1439 &hcw_mxl5007t_config
) == NULL
? -ENODEV
: 0;
1443 /* DVB-USB and USB stuff follows */
1444 struct usb_device_id dib0700_usb_id_table
[] = {
1445 /* 0 */ { USB_DEVICE(USB_VID_DIBCOM
, USB_PID_DIBCOM_STK7700P
) },
1446 { USB_DEVICE(USB_VID_DIBCOM
, USB_PID_DIBCOM_STK7700P_PC
) },
1447 { USB_DEVICE(USB_VID_HAUPPAUGE
, USB_PID_HAUPPAUGE_NOVA_T_500
) },
1448 { USB_DEVICE(USB_VID_HAUPPAUGE
, USB_PID_HAUPPAUGE_NOVA_T_500_2
) },
1449 { USB_DEVICE(USB_VID_HAUPPAUGE
, USB_PID_HAUPPAUGE_NOVA_T_STICK
) },
1450 /* 5 */ { USB_DEVICE(USB_VID_AVERMEDIA
, USB_PID_AVERMEDIA_VOLAR
) },
1451 { USB_DEVICE(USB_VID_COMPRO
, USB_PID_COMPRO_VIDEOMATE_U500
) },
1452 { USB_DEVICE(USB_VID_UNIWILL
, USB_PID_UNIWILL_STK7700P
) },
1453 { USB_DEVICE(USB_VID_LEADTEK
, USB_PID_WINFAST_DTV_DONGLE_STK7700P
) },
1454 { USB_DEVICE(USB_VID_HAUPPAUGE
, USB_PID_HAUPPAUGE_NOVA_T_STICK_2
) },
1455 /* 10 */{ USB_DEVICE(USB_VID_AVERMEDIA
, USB_PID_AVERMEDIA_VOLAR_2
) },
1456 { USB_DEVICE(USB_VID_PINNACLE
, USB_PID_PINNACLE_PCTV2000E
) },
1457 { USB_DEVICE(USB_VID_TERRATEC
,
1458 USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY
) },
1459 { USB_DEVICE(USB_VID_HAUPPAUGE
, USB_PID_HAUPPAUGE_NOVA_TD_STICK
) },
1460 { USB_DEVICE(USB_VID_DIBCOM
, USB_PID_DIBCOM_STK7700D
) },
1461 /* 15 */{ USB_DEVICE(USB_VID_DIBCOM
, USB_PID_DIBCOM_STK7070P
) },
1462 { USB_DEVICE(USB_VID_PINNACLE
, USB_PID_PINNACLE_PCTV_DVB_T_FLASH
) },
1463 { USB_DEVICE(USB_VID_DIBCOM
, USB_PID_DIBCOM_STK7070PD
) },
1464 { USB_DEVICE(USB_VID_PINNACLE
,
1465 USB_PID_PINNACLE_PCTV_DUAL_DIVERSITY_DVB_T
) },
1466 { USB_DEVICE(USB_VID_COMPRO
, USB_PID_COMPRO_VIDEOMATE_U500_PC
) },
1467 /* 20 */{ USB_DEVICE(USB_VID_AVERMEDIA
, USB_PID_AVERMEDIA_EXPRESS
) },
1468 { USB_DEVICE(USB_VID_GIGABYTE
, USB_PID_GIGABYTE_U7000
) },
1469 { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC
, USB_PID_ARTEC_T14BR
) },
1470 { USB_DEVICE(USB_VID_ASUS
, USB_PID_ASUS_U3000
) },
1471 { USB_DEVICE(USB_VID_ASUS
, USB_PID_ASUS_U3100
) },
1472 /* 25 */{ USB_DEVICE(USB_VID_HAUPPAUGE
, USB_PID_HAUPPAUGE_NOVA_T_STICK_3
) },
1473 { USB_DEVICE(USB_VID_HAUPPAUGE
, USB_PID_HAUPPAUGE_MYTV_T
) },
1474 { USB_DEVICE(USB_VID_TERRATEC
, USB_PID_TERRATEC_CINERGY_HT_USB_XE
) },
1475 { USB_DEVICE(USB_VID_PINNACLE
, USB_PID_PINNACLE_EXPRESSCARD_320CX
) },
1476 { USB_DEVICE(USB_VID_PINNACLE
, USB_PID_PINNACLE_PCTV72E
) },
1477 /* 30 */{ USB_DEVICE(USB_VID_PINNACLE
, USB_PID_PINNACLE_PCTV73E
) },
1478 { USB_DEVICE(USB_VID_YUAN
, USB_PID_YUAN_EC372S
) },
1479 { USB_DEVICE(USB_VID_TERRATEC
, USB_PID_TERRATEC_CINERGY_HT_EXPRESS
) },
1480 { USB_DEVICE(USB_VID_TERRATEC
, USB_PID_TERRATEC_CINERGY_T_XXS
) },
1481 { USB_DEVICE(USB_VID_LEADTEK
, USB_PID_WINFAST_DTV_DONGLE_STK7700P_2
) },
1482 /* 35 */{ USB_DEVICE(USB_VID_HAUPPAUGE
, USB_PID_HAUPPAUGE_NOVA_TD_STICK_52009
) },
1483 { USB_DEVICE(USB_VID_HAUPPAUGE
, USB_PID_HAUPPAUGE_NOVA_T_500_3
) },
1484 { USB_DEVICE(USB_VID_GIGABYTE
, USB_PID_GIGABYTE_U8000
) },
1485 { USB_DEVICE(USB_VID_YUAN
, USB_PID_YUAN_STK7700PH
) },
1486 { USB_DEVICE(USB_VID_ASUS
, USB_PID_ASUS_U3000H
) },
1487 /* 40 */{ USB_DEVICE(USB_VID_PINNACLE
, USB_PID_PINNACLE_PCTV801E
) },
1488 { USB_DEVICE(USB_VID_PINNACLE
, USB_PID_PINNACLE_PCTV801E_SE
) },
1489 { USB_DEVICE(USB_VID_TERRATEC
, USB_PID_TERRATEC_CINERGY_T_EXPRESS
) },
1490 { USB_DEVICE(USB_VID_TERRATEC
,
1491 USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY_2
) },
1492 { USB_DEVICE(USB_VID_SONY
, USB_PID_SONY_PLAYTV
) },
1493 /* 45 */{ USB_DEVICE(USB_VID_YUAN
, USB_PID_YUAN_PD378S
) },
1494 { USB_DEVICE(USB_VID_HAUPPAUGE
, USB_PID_HAUPPAUGE_TIGER_ATSC
) },
1495 { USB_DEVICE(USB_VID_HAUPPAUGE
, USB_PID_HAUPPAUGE_TIGER_ATSC_B210
) },
1496 { USB_DEVICE(USB_VID_YUAN
, USB_PID_YUAN_MC770
) },
1497 { USB_DEVICE(USB_VID_ELGATO
, USB_PID_ELGATO_EYETV_DTT
) },
1498 /* 50 */{ USB_DEVICE(USB_VID_ELGATO
, USB_PID_ELGATO_EYETV_DTT_Dlx
) },
1499 { USB_DEVICE(USB_VID_LEADTEK
, USB_PID_WINFAST_DTV_DONGLE_H
) },
1500 { USB_DEVICE(USB_VID_TERRATEC
, USB_PID_TERRATEC_T3
) },
1501 { USB_DEVICE(USB_VID_TERRATEC
, USB_PID_TERRATEC_T5
) },
1502 { USB_DEVICE(USB_VID_YUAN
, USB_PID_YUAN_STK7700D
) },
1503 { USB_DEVICE(USB_VID_YUAN
, USB_PID_YUAN_STK7700D_2
) },
1504 { 0 } /* Terminating entry */
1506 MODULE_DEVICE_TABLE(usb
, dib0700_usb_id_table
);
1508 #define DIB0700_DEFAULT_DEVICE_PROPERTIES \
1509 .caps = DVB_USB_IS_AN_I2C_ADAPTER, \
1510 .usb_ctrl = DEVICE_SPECIFIC, \
1511 .firmware = "dvb-usb-dib0700-1.20.fw", \
1512 .download_firmware = dib0700_download_firmware, \
1513 .no_reconnect = 1, \
1514 .size_of_priv = sizeof(struct dib0700_state), \
1515 .i2c_algo = &dib0700_i2c_algo, \
1516 .identify_state = dib0700_identify_state
1518 #define DIB0700_DEFAULT_STREAMING_CONFIG(ep) \
1519 .streaming_ctrl = dib0700_streaming_ctrl, \
1526 .buffersize = 39480, \
1531 struct dvb_usb_device_properties dib0700_devices
[] = {
1533 DIB0700_DEFAULT_DEVICE_PROPERTIES
,
1538 .frontend_attach
= stk7700p_frontend_attach
,
1539 .tuner_attach
= stk7700p_tuner_attach
,
1541 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
1545 .num_device_descs
= 8,
1547 { "DiBcom STK7700P reference design",
1548 { &dib0700_usb_id_table
[0], &dib0700_usb_id_table
[1] },
1551 { "Hauppauge Nova-T Stick",
1552 { &dib0700_usb_id_table
[4], &dib0700_usb_id_table
[9], NULL
},
1555 { "AVerMedia AVerTV DVB-T Volar",
1556 { &dib0700_usb_id_table
[5], &dib0700_usb_id_table
[10] },
1559 { "Compro Videomate U500",
1560 { &dib0700_usb_id_table
[6], &dib0700_usb_id_table
[19] },
1563 { "Uniwill STK7700P based (Hama and others)",
1564 { &dib0700_usb_id_table
[7], NULL
},
1567 { "Leadtek Winfast DTV Dongle (STK7700P based)",
1568 { &dib0700_usb_id_table
[8], &dib0700_usb_id_table
[34] },
1571 { "AVerMedia AVerTV DVB-T Express",
1572 { &dib0700_usb_id_table
[20] },
1576 { &dib0700_usb_id_table
[21], NULL
},
1581 .rc_interval
= DEFAULT_RC_INTERVAL
,
1582 .rc_key_map
= dib0700_rc_keys
,
1583 .rc_key_map_size
= ARRAY_SIZE(dib0700_rc_keys
),
1584 .rc_query
= dib0700_rc_query
1585 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES
,
1590 .frontend_attach
= bristol_frontend_attach
,
1591 .tuner_attach
= bristol_tuner_attach
,
1593 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
1595 .frontend_attach
= bristol_frontend_attach
,
1596 .tuner_attach
= bristol_tuner_attach
,
1598 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
1602 .num_device_descs
= 1,
1604 { "Hauppauge Nova-T 500 Dual DVB-T",
1605 { &dib0700_usb_id_table
[2], &dib0700_usb_id_table
[3], NULL
},
1610 .rc_interval
= DEFAULT_RC_INTERVAL
,
1611 .rc_key_map
= dib0700_rc_keys
,
1612 .rc_key_map_size
= ARRAY_SIZE(dib0700_rc_keys
),
1613 .rc_query
= dib0700_rc_query
1614 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES
,
1619 .frontend_attach
= stk7700d_frontend_attach
,
1620 .tuner_attach
= stk7700d_tuner_attach
,
1622 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
1624 .frontend_attach
= stk7700d_frontend_attach
,
1625 .tuner_attach
= stk7700d_tuner_attach
,
1627 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
1631 .num_device_descs
= 5,
1633 { "Pinnacle PCTV 2000e",
1634 { &dib0700_usb_id_table
[11], NULL
},
1637 { "Terratec Cinergy DT XS Diversity",
1638 { &dib0700_usb_id_table
[12], NULL
},
1641 { "Hauppauge Nova-TD Stick/Elgato Eye-TV Diversity",
1642 { &dib0700_usb_id_table
[13], NULL
},
1645 { "DiBcom STK7700D reference design",
1646 { &dib0700_usb_id_table
[14], NULL
},
1649 { "YUAN High-Tech DiBcom STK7700D",
1650 { &dib0700_usb_id_table
[55], NULL
},
1656 .rc_interval
= DEFAULT_RC_INTERVAL
,
1657 .rc_key_map
= dib0700_rc_keys
,
1658 .rc_key_map_size
= ARRAY_SIZE(dib0700_rc_keys
),
1659 .rc_query
= dib0700_rc_query
1661 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES
,
1666 .frontend_attach
= stk7700P2_frontend_attach
,
1667 .tuner_attach
= stk7700d_tuner_attach
,
1669 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
1673 .num_device_descs
= 3,
1675 { "ASUS My Cinema U3000 Mini DVBT Tuner",
1676 { &dib0700_usb_id_table
[23], NULL
},
1680 { &dib0700_usb_id_table
[31], NULL
},
1683 { "Terratec Cinergy T Express",
1684 { &dib0700_usb_id_table
[42], NULL
},
1689 .rc_interval
= DEFAULT_RC_INTERVAL
,
1690 .rc_key_map
= dib0700_rc_keys
,
1691 .rc_key_map_size
= ARRAY_SIZE(dib0700_rc_keys
),
1692 .rc_query
= dib0700_rc_query
1693 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES
,
1698 .frontend_attach
= stk7070p_frontend_attach
,
1699 .tuner_attach
= dib7070p_tuner_attach
,
1701 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
1703 .size_of_priv
= sizeof(struct dib0700_adapter_state
),
1707 .num_device_descs
= 12,
1709 { "DiBcom STK7070P reference design",
1710 { &dib0700_usb_id_table
[15], NULL
},
1713 { "Pinnacle PCTV DVB-T Flash Stick",
1714 { &dib0700_usb_id_table
[16], NULL
},
1717 { "Artec T14BR DVB-T",
1718 { &dib0700_usb_id_table
[22], NULL
},
1721 { "ASUS My Cinema U3100 Mini DVBT Tuner",
1722 { &dib0700_usb_id_table
[24], NULL
},
1725 { "Hauppauge Nova-T Stick",
1726 { &dib0700_usb_id_table
[25], NULL
},
1729 { "Hauppauge Nova-T MyTV.t",
1730 { &dib0700_usb_id_table
[26], NULL
},
1733 { "Pinnacle PCTV 72e",
1734 { &dib0700_usb_id_table
[29], NULL
},
1737 { "Pinnacle PCTV 73e",
1738 { &dib0700_usb_id_table
[30], NULL
},
1741 { "Terratec Cinergy T USB XXS/ T3",
1742 { &dib0700_usb_id_table
[33],
1743 &dib0700_usb_id_table
[52], NULL
},
1746 { "Elgato EyeTV DTT",
1747 { &dib0700_usb_id_table
[49], NULL
},
1751 { &dib0700_usb_id_table
[45], NULL
},
1754 { "Elgato EyeTV Dtt Dlx PD378S",
1755 { &dib0700_usb_id_table
[50], NULL
},
1760 .rc_interval
= DEFAULT_RC_INTERVAL
,
1761 .rc_key_map
= dib0700_rc_keys
,
1762 .rc_key_map_size
= ARRAY_SIZE(dib0700_rc_keys
),
1763 .rc_query
= dib0700_rc_query
1765 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES
,
1770 .frontend_attach
= stk7070pd_frontend_attach0
,
1771 .tuner_attach
= dib7070p_tuner_attach
,
1773 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
1775 .size_of_priv
= sizeof(struct dib0700_adapter_state
),
1777 .frontend_attach
= stk7070pd_frontend_attach1
,
1778 .tuner_attach
= dib7070p_tuner_attach
,
1780 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
1782 .size_of_priv
= sizeof(struct dib0700_adapter_state
),
1786 .num_device_descs
= 6,
1788 { "DiBcom STK7070PD reference design",
1789 { &dib0700_usb_id_table
[17], NULL
},
1792 { "Pinnacle PCTV Dual DVB-T Diversity Stick",
1793 { &dib0700_usb_id_table
[18], NULL
},
1796 { "Hauppauge Nova-TD Stick (52009)",
1797 { &dib0700_usb_id_table
[35], NULL
},
1800 { "Hauppauge Nova-TD-500 (84xxx)",
1801 { &dib0700_usb_id_table
[36], NULL
},
1804 { "Terratec Cinergy DT USB XS Diversity/ T5",
1805 { &dib0700_usb_id_table
[43],
1806 &dib0700_usb_id_table
[53], NULL
},
1810 { &dib0700_usb_id_table
[44], NULL
},
1814 .rc_interval
= DEFAULT_RC_INTERVAL
,
1815 .rc_key_map
= dib0700_rc_keys
,
1816 .rc_key_map_size
= ARRAY_SIZE(dib0700_rc_keys
),
1817 .rc_query
= dib0700_rc_query
1818 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES
,
1823 .frontend_attach
= stk7700ph_frontend_attach
,
1824 .tuner_attach
= stk7700ph_tuner_attach
,
1826 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
1828 .size_of_priv
= sizeof(struct
1829 dib0700_adapter_state
),
1833 .num_device_descs
= 9,
1835 { "Terratec Cinergy HT USB XE",
1836 { &dib0700_usb_id_table
[27], NULL
},
1839 { "Pinnacle Expresscard 320cx",
1840 { &dib0700_usb_id_table
[28], NULL
},
1843 { "Terratec Cinergy HT Express",
1844 { &dib0700_usb_id_table
[32], NULL
},
1847 { "Gigabyte U8000-RH",
1848 { &dib0700_usb_id_table
[37], NULL
},
1851 { "YUAN High-Tech STK7700PH",
1852 { &dib0700_usb_id_table
[38], NULL
},
1855 { "Asus My Cinema-U3000Hybrid",
1856 { &dib0700_usb_id_table
[39], NULL
},
1859 { "YUAN High-Tech MC770",
1860 { &dib0700_usb_id_table
[48], NULL
},
1863 { "Leadtek WinFast DTV Dongle H",
1864 { &dib0700_usb_id_table
[51], NULL
},
1867 { "YUAN High-Tech STK7700D",
1868 { &dib0700_usb_id_table
[54], NULL
},
1872 .rc_interval
= DEFAULT_RC_INTERVAL
,
1873 .rc_key_map
= dib0700_rc_keys
,
1874 .rc_key_map_size
= ARRAY_SIZE(dib0700_rc_keys
),
1875 .rc_query
= dib0700_rc_query
1876 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES
,
1880 .frontend_attach
= s5h1411_frontend_attach
,
1881 .tuner_attach
= xc5000_tuner_attach
,
1883 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
1885 .size_of_priv
= sizeof(struct
1886 dib0700_adapter_state
),
1890 .num_device_descs
= 2,
1892 { "Pinnacle PCTV HD Pro USB Stick",
1893 { &dib0700_usb_id_table
[40], NULL
},
1896 { "Pinnacle PCTV HD USB Stick",
1897 { &dib0700_usb_id_table
[41], NULL
},
1901 .rc_interval
= DEFAULT_RC_INTERVAL
,
1902 .rc_key_map
= dib0700_rc_keys
,
1903 .rc_key_map_size
= ARRAY_SIZE(dib0700_rc_keys
),
1904 .rc_query
= dib0700_rc_query
1905 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES
,
1909 .frontend_attach
= lgdt3305_frontend_attach
,
1910 .tuner_attach
= mxl5007t_tuner_attach
,
1912 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
1914 .size_of_priv
= sizeof(struct
1915 dib0700_adapter_state
),
1919 .num_device_descs
= 2,
1921 { "Hauppauge ATSC MiniCard (B200)",
1922 { &dib0700_usb_id_table
[46], NULL
},
1925 { "Hauppauge ATSC MiniCard (B210)",
1926 { &dib0700_usb_id_table
[47], NULL
},
1933 int dib0700_device_count
= ARRAY_SIZE(dib0700_devices
);