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"
18 static int force_lna_activation;
19 module_param(force_lna_activation, int, 0644);
20 MODULE_PARM_DESC(force_lna_activation, "force the activation of Low-Noise-Amplifyer(s) (LNA), "
21 "if applicable for the device (default: 0=automatic/off).");
23 struct dib0700_adapter_state {
24 int (*set_param_save) (struct dvb_frontend *, struct dvb_frontend_parameters *);
27 /* Hauppauge Nova-T 500 (aka Bristol)
28 * has a LNA on GPIO0 which is enabled by setting 1 */
29 static struct mt2060_config bristol_mt2060_config[2] = {
38 static struct dibx000_agc_config bristol_dib3000p_mt2060_agc_config = {
39 .band_caps = BAND_VHF | BAND_UHF,
40 .setup = (1 << 8) | (5 << 5) | (0 << 4) | (0 << 3) | (0 << 2) | (2 << 0),
60 static struct dib3000mc_config bristol_dib3000mc_config[2] = {
61 { .agc = &bristol_dib3000p_mt2060_agc_config,
63 .ln_adc_level = 0x1cc7,
64 .output_mpeg2_in_188_bytes = 1,
66 { .agc = &bristol_dib3000p_mt2060_agc_config,
68 .ln_adc_level = 0x1cc7,
69 .output_mpeg2_in_188_bytes = 1,
73 static int bristol_frontend_attach(struct dvb_usb_adapter *adap)
75 struct dib0700_state *st = adap->dev->priv;
77 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0); msleep(10);
78 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1); msleep(10);
79 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0); msleep(10);
80 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1); msleep(10);
82 if (force_lna_activation)
83 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
85 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 0);
87 if (dib3000mc_i2c_enumeration(&adap->dev->i2c_adap, 2, DEFAULT_DIB3000P_I2C_ADDRESS, bristol_dib3000mc_config) != 0) {
88 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0); msleep(10);
92 st->mt2060_if1[adap->id] = 1220;
93 return (adap->fe = dvb_attach(dib3000mc_attach, &adap->dev->i2c_adap,
94 (10 + adap->id) << 1, &bristol_dib3000mc_config[adap->id])) == NULL ? -ENODEV : 0;
97 static int bristol_tuner_attach(struct dvb_usb_adapter *adap)
99 struct dib0700_state *st = adap->dev->priv;
100 struct i2c_adapter *tun_i2c = dib3000mc_get_tuner_i2c_master(adap->fe, 1);
101 return dvb_attach(mt2060_attach,adap->fe, tun_i2c, &bristol_mt2060_config[adap->id],
102 st->mt2060_if1[adap->id]) == NULL ? -ENODEV : 0;
105 /* STK7700D: Pinnacle/Terratec/Hauppauge Dual DVB-T Diversity */
108 static struct dibx000_agc_config stk7700d_7000p_mt2266_agc_config[2] = {
110 BAND_UHF, // band_caps
112 /* 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,
113 * 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 */
114 (0 << 15) | (0 << 14) | (1 << 11) | (1 << 10) | (1 << 9) | (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0), // setup
147 1, // perform_agc_softsplit
149 BAND_VHF | BAND_LBAND, // band_caps
151 /* 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,
152 * 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 */
153 (0 << 15) | (0 << 14) | (1 << 11) | (1 << 10) | (1 << 9) | (0 << 8) | (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0), // setup
186 1, // perform_agc_softsplit
190 static struct dibx000_bandwidth_config stk7700d_mt2266_pll_config = {
191 60000, 30000, // internal, sampling
192 1, 8, 3, 1, 0, // pll_cfg: prediv, ratio, range, reset, bypass
193 0, 0, 1, 1, 2, // misc: refdiv, bypclk_div, IO_CLK_en_core, ADClkSrc, modulo
194 (3 << 14) | (1 << 12) | (524 << 0), // sad_cfg: refsel, sel, freq_15k
199 static struct dib7000p_config stk7700d_dib7000p_mt2266_config[] = {
200 { .output_mpeg2_in_188_bytes = 1,
201 .hostbus_diversity = 1,
202 .tuner_is_baseband = 1,
204 .agc_config_count = 2,
205 .agc = stk7700d_7000p_mt2266_agc_config,
206 .bw = &stk7700d_mt2266_pll_config,
208 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
209 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
210 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
212 { .output_mpeg2_in_188_bytes = 1,
213 .hostbus_diversity = 1,
214 .tuner_is_baseband = 1,
216 .agc_config_count = 2,
217 .agc = stk7700d_7000p_mt2266_agc_config,
218 .bw = &stk7700d_mt2266_pll_config,
220 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
221 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
222 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
226 static struct mt2266_config stk7700d_mt2266_config[2] = {
227 { .i2c_address = 0x60
229 { .i2c_address = 0x60
233 static int stk7700d_frontend_attach(struct dvb_usb_adapter *adap)
236 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
238 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
239 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
240 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
241 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
243 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
245 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
246 dib7000p_i2c_enumeration(&adap->dev->i2c_adap,2,18,stk7700d_dib7000p_mt2266_config);
249 adap->fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap,0x80+(adap->id << 1),
250 &stk7700d_dib7000p_mt2266_config[adap->id]);
252 return adap->fe == NULL ? -ENODEV : 0;
255 static int stk7700d_tuner_attach(struct dvb_usb_adapter *adap)
257 struct i2c_adapter *tun_i2c;
258 tun_i2c = dib7000p_get_i2c_master(adap->fe, DIBX000_I2C_INTERFACE_TUNER, 1);
259 return dvb_attach(mt2266_attach, adap->fe, tun_i2c,
260 &stk7700d_mt2266_config[adap->id]) == NULL ? -ENODEV : 0;;
263 #define DEFAULT_RC_INTERVAL 150
265 static u8 rc_request[] = { REQUEST_POLL_RC, 0 };
267 static int dib0700_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
271 struct dvb_usb_rc_key *keymap = d->props.rc_key_map;
272 struct dib0700_state *st = d->priv;
274 *state = REMOTE_NO_KEY_PRESSED;
275 i=dib0700_ctrl_rd(d,rc_request,2,key,4);
277 err("RC Query Failed\n");
280 if (key[0]==0 && key[1]==0 && key[2]==0 && key[3]==0) return 0;
281 if (key[1]!=st->rc_toggle) {
282 for (i=0;i<d->props.rc_key_map_size; i++) {
283 if (keymap[i].custom == key[2] && keymap[i].data == key[3]) {
284 *event = keymap[i].event;
285 *state = REMOTE_KEY_PRESSED;
286 st->rc_toggle=key[1];
290 err("Unknown remote controller key : %2X %2X\n",(int)key[2],(int)key[3]);
295 static struct dvb_usb_rc_key dib0700_rc_keys[] = {
296 /* Key codes for the tiny Pinnacle remote*/
297 { 0x07, 0x00, KEY_MUTE },
298 { 0x07, 0x01, KEY_MENU }, // Pinnacle logo
299 { 0x07, 0x39, KEY_POWER },
300 { 0x07, 0x03, KEY_VOLUMEUP },
301 { 0x07, 0x09, KEY_VOLUMEDOWN },
302 { 0x07, 0x06, KEY_CHANNELUP },
303 { 0x07, 0x0c, KEY_CHANNELDOWN },
304 { 0x07, 0x0f, KEY_1 },
305 { 0x07, 0x15, KEY_2 },
306 { 0x07, 0x10, KEY_3 },
307 { 0x07, 0x18, KEY_4 },
308 { 0x07, 0x1b, KEY_5 },
309 { 0x07, 0x1e, KEY_6 },
310 { 0x07, 0x11, KEY_7 },
311 { 0x07, 0x21, KEY_8 },
312 { 0x07, 0x12, KEY_9 },
313 { 0x07, 0x27, KEY_0 },
314 { 0x07, 0x24, KEY_SCREEN }, // 'Square' key
315 { 0x07, 0x2a, KEY_TEXT }, // 'T' key
316 { 0x07, 0x2d, KEY_REWIND },
317 { 0x07, 0x30, KEY_PLAY },
318 { 0x07, 0x33, KEY_FASTFORWARD },
319 { 0x07, 0x36, KEY_RECORD },
320 { 0x07, 0x3c, KEY_STOP },
321 { 0x07, 0x3f, KEY_CANCEL }, // '?' key
322 /* Key codes for the Terratec Cinergy DT XS Diversity, similar to cinergyT2.c */
323 { 0xeb, 0x01, KEY_POWER },
324 { 0xeb, 0x02, KEY_1 },
325 { 0xeb, 0x03, KEY_2 },
326 { 0xeb, 0x04, KEY_3 },
327 { 0xeb, 0x05, KEY_4 },
328 { 0xeb, 0x06, KEY_5 },
329 { 0xeb, 0x07, KEY_6 },
330 { 0xeb, 0x08, KEY_7 },
331 { 0xeb, 0x09, KEY_8 },
332 { 0xeb, 0x0a, KEY_9 },
333 { 0xeb, 0x0b, KEY_VIDEO },
334 { 0xeb, 0x0c, KEY_0 },
335 { 0xeb, 0x0d, KEY_REFRESH },
336 { 0xeb, 0x0f, KEY_EPG },
337 { 0xeb, 0x10, KEY_UP },
338 { 0xeb, 0x11, KEY_LEFT },
339 { 0xeb, 0x12, KEY_OK },
340 { 0xeb, 0x13, KEY_RIGHT },
341 { 0xeb, 0x14, KEY_DOWN },
342 { 0xeb, 0x16, KEY_INFO },
343 { 0xeb, 0x17, KEY_RED },
344 { 0xeb, 0x18, KEY_GREEN },
345 { 0xeb, 0x19, KEY_YELLOW },
346 { 0xeb, 0x1a, KEY_BLUE },
347 { 0xeb, 0x1b, KEY_CHANNELUP },
348 { 0xeb, 0x1c, KEY_VOLUMEUP },
349 { 0xeb, 0x1d, KEY_MUTE },
350 { 0xeb, 0x1e, KEY_VOLUMEDOWN },
351 { 0xeb, 0x1f, KEY_CHANNELDOWN },
352 { 0xeb, 0x40, KEY_PAUSE },
353 { 0xeb, 0x41, KEY_HOME },
354 { 0xeb, 0x42, KEY_MENU }, /* DVD Menu */
355 { 0xeb, 0x43, KEY_SUBTITLE },
356 { 0xeb, 0x44, KEY_TEXT }, /* Teletext */
357 { 0xeb, 0x45, KEY_DELETE },
358 { 0xeb, 0x46, KEY_TV },
359 { 0xeb, 0x47, KEY_DVD },
360 { 0xeb, 0x48, KEY_STOP },
361 { 0xeb, 0x49, KEY_VIDEO },
362 { 0xeb, 0x4a, KEY_AUDIO }, /* Music */
363 { 0xeb, 0x4b, KEY_SCREEN }, /* Pic */
364 { 0xeb, 0x4c, KEY_PLAY },
365 { 0xeb, 0x4d, KEY_BACK },
366 { 0xeb, 0x4e, KEY_REWIND },
367 { 0xeb, 0x4f, KEY_FASTFORWARD },
368 { 0xeb, 0x54, KEY_PREVIOUS },
369 { 0xeb, 0x58, KEY_RECORD },
370 { 0xeb, 0x5c, KEY_NEXT }
373 /* STK7700P: Hauppauge Nova-T Stick, AVerMedia Volar */
374 static struct dibx000_agc_config stk7700p_7000m_mt2060_agc_config = {
375 BAND_UHF | BAND_VHF, // band_caps
377 /* 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,
378 * 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 */
379 (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8) | (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0), // setup
411 1, // perform_agc_softsplit
414 51800, // global_split_min
415 24700 // global_split_max
419 static struct dibx000_agc_config stk7700p_7000p_mt2060_agc_config = {
422 /* 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,
423 * 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 */
424 (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8) | (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0), // setup
461 0, // perform_agc_softsplit
464 static struct dibx000_bandwidth_config stk7700p_pll_config = {
465 60000, 30000, // internal, sampling
466 1, 8, 3, 1, 0, // pll_cfg: prediv, ratio, range, reset, bypass
467 0, 0, 1, 1, 0, // misc: refdiv, bypclk_div, IO_CLK_en_core, ADClkSrc, modulo
468 (3 << 14) | (1 << 12) | (524 << 0), // sad_cfg: refsel, sel, freq_15k
473 static struct dib7000m_config stk7700p_dib7000m_config = {
475 .output_mpeg2_in_188_bytes = 1,
478 .agc_config_count = 1,
479 .agc = &stk7700p_7000m_mt2060_agc_config,
480 .bw = &stk7700p_pll_config,
482 .gpio_dir = DIB7000M_GPIO_DEFAULT_DIRECTIONS,
483 .gpio_val = DIB7000M_GPIO_DEFAULT_VALUES,
484 .gpio_pwm_pos = DIB7000M_GPIO_DEFAULT_PWM_POS,
487 static struct dib7000p_config stk7700p_dib7000p_config = {
488 .output_mpeg2_in_188_bytes = 1,
490 .agc_config_count = 1,
491 .agc = &stk7700p_7000p_mt2060_agc_config,
492 .bw = &stk7700p_pll_config,
494 .gpio_dir = DIB7000M_GPIO_DEFAULT_DIRECTIONS,
495 .gpio_val = DIB7000M_GPIO_DEFAULT_VALUES,
496 .gpio_pwm_pos = DIB7000M_GPIO_DEFAULT_PWM_POS,
499 static int stk7700p_frontend_attach(struct dvb_usb_adapter *adap)
501 struct dib0700_state *st = adap->dev->priv;
502 /* unless there is no real power management in DVB - we leave the device on GPIO6 */
504 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
505 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0); msleep(50);
507 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1); msleep(10);
508 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
510 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0); msleep(10);
511 dib0700_ctrl_clock(adap->dev, 72, 1);
512 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1); msleep(100);
514 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
516 st->mt2060_if1[0] = 1220;
518 if (dib7000pc_detection(&adap->dev->i2c_adap)) {
519 adap->fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 18, &stk7700p_dib7000p_config);
520 st->is_dib7000pc = 1;
522 adap->fe = dvb_attach(dib7000m_attach, &adap->dev->i2c_adap, 18, &stk7700p_dib7000m_config);
524 return adap->fe == NULL ? -ENODEV : 0;
527 static struct mt2060_config stk7700p_mt2060_config = {
531 static int stk7700p_tuner_attach(struct dvb_usb_adapter *adap)
533 struct dib0700_state *st = adap->dev->priv;
534 struct i2c_adapter *tun_i2c;
536 if (st->is_dib7000pc)
537 tun_i2c = dib7000p_get_i2c_master(adap->fe, DIBX000_I2C_INTERFACE_TUNER, 1);
539 tun_i2c = dib7000m_get_i2c_master(adap->fe, DIBX000_I2C_INTERFACE_TUNER, 1);
541 return dvb_attach(mt2060_attach, adap->fe, tun_i2c, &stk7700p_mt2060_config,
542 st->mt2060_if1[0]) == NULL ? -ENODEV : 0;
545 /* DIB7070 generic */
546 static struct dibx000_agc_config dib7070_agc_config = {
547 BAND_UHF | BAND_VHF | BAND_LBAND | BAND_SBAND,
548 /* 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,
549 * 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 */
550 (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0), // setup
584 0, // perform_agc_softsplit
587 static int dib7070_tuner_reset(struct dvb_frontend *fe, int onoff)
589 return dib7000p_set_gpio(fe, 8, 0, !onoff);
592 static int dib7070_tuner_sleep(struct dvb_frontend *fe, int onoff)
594 return dib7000p_set_gpio(fe, 9, 0, onoff);
597 static struct dib0070_config dib7070p_dib0070_config[2] = {
599 .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
600 .reset = dib7070_tuner_reset,
601 .sleep = dib7070_tuner_sleep,
605 .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
606 .reset = dib7070_tuner_reset,
607 .sleep = dib7070_tuner_sleep,
613 static int dib7070_set_param_override(struct dvb_frontend *fe, struct dvb_frontend_parameters *fep)
615 struct dvb_usb_adapter *adap = fe->dvb->priv;
616 struct dib0700_adapter_state *state = adap->priv;
619 u8 band = BAND_OF_FREQUENCY(fep->frequency/1000);
621 case BAND_VHF: offset = 950; break;
623 default: offset = 550; break;
625 deb_info("WBD for DiB7000P: %d\n", offset + dib0070_wbd_offset(fe));
626 dib7000p_set_wbd_ref(fe, offset + dib0070_wbd_offset(fe));
627 return state->set_param_save(fe, fep);
630 static int dib7070p_tuner_attach(struct dvb_usb_adapter *adap)
632 struct dib0700_adapter_state *st = adap->priv;
633 struct i2c_adapter *tun_i2c = dib7000p_get_i2c_master(adap->fe, DIBX000_I2C_INTERFACE_TUNER, 1);
636 if (dvb_attach(dib0070_attach, adap->fe, tun_i2c, &dib7070p_dib0070_config[0]) == NULL)
639 if (dvb_attach(dib0070_attach, adap->fe, tun_i2c, &dib7070p_dib0070_config[1]) == NULL)
643 st->set_param_save = adap->fe->ops.tuner_ops.set_params;
644 adap->fe->ops.tuner_ops.set_params = dib7070_set_param_override;
648 static struct dibx000_bandwidth_config dib7070_bw_config_12_mhz = {
649 60000, 15000, // internal, sampling
650 1, 20, 3, 1, 0, // pll_cfg: prediv, ratio, range, reset, bypass
651 0, 0, 1, 1, 2, // misc: refdiv, bypclk_div, IO_CLK_en_core, ADClkSrc, modulo
652 (3 << 14) | (1 << 12) | (524 << 0), // sad_cfg: refsel, sel, freq_15k
653 (0 << 25) | 0, // ifreq = 0.000000 MHz
658 static struct dib7000p_config dib7070p_dib7000p_config = {
659 .output_mpeg2_in_188_bytes = 1,
661 .agc_config_count = 1,
662 .agc = &dib7070_agc_config,
663 .bw = &dib7070_bw_config_12_mhz,
665 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
666 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
667 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
669 .hostbus_diversity = 1,
673 static int stk7070p_frontend_attach(struct dvb_usb_adapter *adap)
675 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
677 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
678 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
679 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
680 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
682 dib0700_ctrl_clock(adap->dev, 72, 1);
685 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
687 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
689 dib7000p_i2c_enumeration(&adap->dev->i2c_adap, 1, 18, &dib7070p_dib7000p_config);
691 adap->fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 0x80, &dib7070p_dib7000p_config);
692 return adap->fe == NULL ? -ENODEV : 0;
696 static struct dib7000p_config stk7070pd_dib7000p_config[2] = {
698 .output_mpeg2_in_188_bytes = 1,
700 .agc_config_count = 1,
701 .agc = &dib7070_agc_config,
702 .bw = &dib7070_bw_config_12_mhz,
704 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
705 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
706 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
708 .hostbus_diversity = 1,
710 .output_mpeg2_in_188_bytes = 1,
712 .agc_config_count = 1,
713 .agc = &dib7070_agc_config,
714 .bw = &dib7070_bw_config_12_mhz,
716 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
717 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
718 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
720 .hostbus_diversity = 1,
724 static int stk7070pd_frontend_attach0(struct dvb_usb_adapter *adap)
726 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
728 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
729 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
730 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
731 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
733 dib0700_ctrl_clock(adap->dev, 72, 1);
736 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
738 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
740 dib7000p_i2c_enumeration(&adap->dev->i2c_adap, 2, 18, stk7070pd_dib7000p_config);
742 adap->fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 0x80, &stk7070pd_dib7000p_config[0]);
743 return adap->fe == NULL ? -ENODEV : 0;
746 static int stk7070pd_frontend_attach1(struct dvb_usb_adapter *adap)
748 adap->fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 0x82, &stk7070pd_dib7000p_config[1]);
749 return adap->fe == NULL ? -ENODEV : 0;
752 /* DVB-USB and USB stuff follows */
753 struct usb_device_id dib0700_usb_id_table[] = {
754 /* 0 */ { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7700P) },
755 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7700P_PC) },
757 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_500) },
758 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_500_2) },
759 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_STICK) },
760 /* 5 */ { USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR) },
761 { USB_DEVICE(USB_VID_COMPRO, USB_PID_COMPRO_VIDEOMATE_U500) },
762 { USB_DEVICE(USB_VID_UNIWILL, USB_PID_UNIWILL_STK7700P) },
763 { USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV_DONGLE_STK7700P) },
764 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_STICK_2) },
765 /* 10 */{ USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR_2) },
766 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV2000E) },
767 { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY) },
768 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_TD_STICK) },
769 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7700D) },
770 /* 15 */{ USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7070P) },
771 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV_DVB_T_FLASH) },
772 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7070PD) },
773 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV_DUAL_DIVERSITY_DVB_T) },
774 { 0 } /* Terminating entry */
776 MODULE_DEVICE_TABLE(usb, dib0700_usb_id_table);
778 #define DIB0700_DEFAULT_DEVICE_PROPERTIES \
779 .caps = DVB_USB_IS_AN_I2C_ADAPTER, \
780 .usb_ctrl = DEVICE_SPECIFIC, \
781 .firmware = "dvb-usb-dib0700-03-pre1.fw", \
782 .download_firmware = dib0700_download_firmware, \
784 .size_of_priv = sizeof(struct dib0700_state), \
785 .i2c_algo = &dib0700_i2c_algo, \
786 .identify_state = dib0700_identify_state
788 #define DIB0700_DEFAULT_STREAMING_CONFIG(ep) \
789 .streaming_ctrl = dib0700_streaming_ctrl, \
796 .buffersize = 39480, \
801 struct dvb_usb_device_properties dib0700_devices[] = {
803 DIB0700_DEFAULT_DEVICE_PROPERTIES,
808 .frontend_attach = stk7700p_frontend_attach,
809 .tuner_attach = stk7700p_tuner_attach,
811 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
815 .num_device_descs = 6,
817 { "DiBcom STK7700P reference design",
818 { &dib0700_usb_id_table[0], &dib0700_usb_id_table[1] },
821 { "Hauppauge Nova-T Stick",
822 { &dib0700_usb_id_table[4], &dib0700_usb_id_table[9], NULL },
825 { "AVerMedia AVerTV DVB-T Volar",
826 { &dib0700_usb_id_table[5], &dib0700_usb_id_table[10] },
829 { "Compro Videomate U500",
830 { &dib0700_usb_id_table[6], NULL },
833 { "Uniwill STK7700P based (Hama and others)",
834 { &dib0700_usb_id_table[7], NULL },
837 { "Leadtek Winfast DTV Dongle (STK7700P based)",
838 { &dib0700_usb_id_table[8], NULL },
842 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
847 .frontend_attach = bristol_frontend_attach,
848 .tuner_attach = bristol_tuner_attach,
850 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
852 .frontend_attach = bristol_frontend_attach,
853 .tuner_attach = bristol_tuner_attach,
855 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
859 .num_device_descs = 1,
861 { "Hauppauge Nova-T 500 Dual DVB-T",
862 { &dib0700_usb_id_table[2], &dib0700_usb_id_table[3], NULL },
867 .rc_interval = DEFAULT_RC_INTERVAL,
868 .rc_key_map = dib0700_rc_keys,
869 .rc_key_map_size = sizeof(dib0700_rc_keys),
870 .rc_query = dib0700_rc_query
871 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
876 .frontend_attach = stk7700d_frontend_attach,
877 .tuner_attach = stk7700d_tuner_attach,
879 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
881 .frontend_attach = stk7700d_frontend_attach,
882 .tuner_attach = stk7700d_tuner_attach,
884 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
888 .num_device_descs = 4,
890 { "Pinnacle PCTV 2000e",
891 { &dib0700_usb_id_table[11], NULL },
894 { "Terratec Cinergy DT XS Diversity",
895 { &dib0700_usb_id_table[12], NULL },
898 { "Haupauge Nova-TD Stick/Elgato Eye-TV Diversity",
899 { &dib0700_usb_id_table[13], NULL },
902 { "DiBcom STK7700D reference design",
903 { &dib0700_usb_id_table[14], NULL },
908 .rc_interval = DEFAULT_RC_INTERVAL,
909 .rc_key_map = dib0700_rc_keys,
910 .rc_key_map_size = sizeof(dib0700_rc_keys),
911 .rc_query = dib0700_rc_query
913 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
918 .frontend_attach = stk7070p_frontend_attach,
919 .tuner_attach = dib7070p_tuner_attach,
921 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
923 .size_of_priv = sizeof(struct dib0700_adapter_state),
927 .num_device_descs = 2,
929 { "DiBcom STK7070P reference design",
930 { &dib0700_usb_id_table[15], NULL },
933 { "Pinnacle PCTV DVB-T Flash Stick",
934 { &dib0700_usb_id_table[16], NULL },
938 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
943 .frontend_attach = stk7070pd_frontend_attach0,
944 .tuner_attach = dib7070p_tuner_attach,
946 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
948 .size_of_priv = sizeof(struct dib0700_adapter_state),
950 .frontend_attach = stk7070pd_frontend_attach1,
951 .tuner_attach = dib7070p_tuner_attach,
953 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
955 .size_of_priv = sizeof(struct dib0700_adapter_state),
959 .num_device_descs = 2,
961 { "DiBcom STK7070PD reference design",
962 { &dib0700_usb_id_table[17], NULL },
965 { "Pinnacle PCTV Dual DVB-T Diversity Stick",
966 { &dib0700_usb_id_table[18], NULL },
973 int dib0700_device_count = ARRAY_SIZE(dib0700_devices);