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-6 DiBcom, SA
11 #include "dib3000mc.h"
16 static int force_lna_activation
;
17 module_param(force_lna_activation
, int, 0644);
18 MODULE_PARM_DESC(force_lna_activation
, "force the activation of Low-Noise-Amplifyer(s) (LNA), "
19 "if applicable for the device (default: 0=automatic/off).");
21 /* Hauppauge Nova-T 500
22 * has a LNA on GPIO0 which is enabled by setting 1 */
23 static struct mt2060_config bristol_mt2060_config
[2] = {
32 static struct dibx000_agc_config bristol_dib3000p_mt2060_agc_config
= {
33 .band_caps
= BAND_VHF
| BAND_UHF
,
34 .setup
= (1 << 8) | (5 << 5) | (0 << 4) | (0 << 3) | (0 << 2) | (2 << 0),
54 static struct dib3000mc_config bristol_dib3000mc_config
[2] = {
55 { .agc
= &bristol_dib3000p_mt2060_agc_config
,
57 .ln_adc_level
= 0x1cc7,
58 .output_mpeg2_in_188_bytes
= 1,
60 { .agc
= &bristol_dib3000p_mt2060_agc_config
,
62 .ln_adc_level
= 0x1cc7,
63 .output_mpeg2_in_188_bytes
= 1,
67 static int bristol_frontend_attach(struct dvb_usb_adapter
*adap
)
69 struct dib0700_state
*st
= adap
->dev
->priv
;
71 dib0700_set_gpio(adap
->dev
, GPIO6
, GPIO_OUT
, 0); msleep(10);
72 dib0700_set_gpio(adap
->dev
, GPIO6
, GPIO_OUT
, 1); msleep(10);
73 dib0700_set_gpio(adap
->dev
, GPIO10
, GPIO_OUT
, 0); msleep(10);
74 dib0700_set_gpio(adap
->dev
, GPIO10
, GPIO_OUT
, 1); msleep(10);
76 if (force_lna_activation
)
77 dib0700_set_gpio(adap
->dev
, GPIO0
, GPIO_OUT
, 1);
79 dib0700_set_gpio(adap
->dev
, GPIO0
, GPIO_OUT
, 0);
81 if (dib3000mc_i2c_enumeration(&adap
->dev
->i2c_adap
, 2, DEFAULT_DIB3000P_I2C_ADDRESS
, bristol_dib3000mc_config
) != 0) {
82 dib0700_set_gpio(adap
->dev
, GPIO6
, GPIO_OUT
, 0); msleep(10);
86 st
->mt2060_if1
[adap
->id
] = 1220;
87 return (adap
->fe
= dvb_attach(dib3000mc_attach
, &adap
->dev
->i2c_adap
,
88 (10 + adap
->id
) << 1, &bristol_dib3000mc_config
[adap
->id
])) == NULL
? -ENODEV
: 0;
91 static int bristol_tuner_attach(struct dvb_usb_adapter
*adap
)
93 struct dib0700_state
*st
= adap
->dev
->priv
;
94 struct i2c_adapter
*tun_i2c
= dib3000mc_get_tuner_i2c_master(adap
->fe
, 1);
95 return dvb_attach(mt2060_attach
,adap
->fe
, tun_i2c
, &bristol_mt2060_config
[adap
->id
],
96 st
->mt2060_if1
[adap
->id
]) == NULL
? -ENODEV
: 0;
99 /* STK7700P: Hauppauge Nova-T Stick, AVerMedia Volar */
100 static struct dibx000_agc_config stk7700p_7000m_mt2060_agc_config
= {
101 BAND_UHF
| BAND_VHF
, // band_caps
103 /* 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,
104 * 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 */
105 (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8) | (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0), // setup
137 1, // perform_agc_softsplit
140 51800, // global_split_min
141 24700 // global_split_max
145 static struct dibx000_agc_config stk7700p_7000p_mt2060_agc_config
= {
148 /* 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,
149 * 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 */
150 (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8) | (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0), // setup
187 0, // perform_agc_softsplit
190 static struct dibx000_bandwidth_config stk7700p_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, 0, // 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 dib7000m_config stk7700p_dib7000m_config
= {
201 .output_mpeg2_in_188_bytes
= 1,
204 .agc_config_count
= 1,
205 .agc
= &stk7700p_7000m_mt2060_agc_config
,
206 .bw
= &stk7700p_pll_config
,
208 .gpio_dir
= DIB7000M_GPIO_DEFAULT_DIRECTIONS
,
209 .gpio_val
= DIB7000M_GPIO_DEFAULT_VALUES
,
210 .gpio_pwm_pos
= DIB7000M_GPIO_DEFAULT_PWM_POS
,
213 static struct dib7000p_config stk7700p_dib7000p_config
= {
214 .output_mpeg2_in_188_bytes
= 1,
216 .agc
= &stk7700p_7000p_mt2060_agc_config
,
217 .bw
= &stk7700p_pll_config
,
219 .gpio_dir
= DIB7000M_GPIO_DEFAULT_DIRECTIONS
,
220 .gpio_val
= DIB7000M_GPIO_DEFAULT_VALUES
,
221 .gpio_pwm_pos
= DIB7000M_GPIO_DEFAULT_PWM_POS
,
224 static int stk7700p_frontend_attach(struct dvb_usb_adapter
*adap
)
226 struct dib0700_state
*st
= adap
->dev
->priv
;
227 /* unless there is no real power management in DVB - we leave the device on GPIO6 */
229 dib0700_set_gpio(adap
->dev
, GPIO10
, GPIO_OUT
, 0);
230 dib0700_set_gpio(adap
->dev
, GPIO6
, GPIO_OUT
, 0); msleep(50);
232 dib0700_set_gpio(adap
->dev
, GPIO6
, GPIO_OUT
, 1); msleep(10);
233 dib0700_set_gpio(adap
->dev
, GPIO9
, GPIO_OUT
, 1);
235 dib0700_set_gpio(adap
->dev
, GPIO10
, GPIO_OUT
, 0); msleep(10);
236 dib0700_ctrl_clock(adap
->dev
, 72, 1);
237 dib0700_set_gpio(adap
->dev
, GPIO10
, GPIO_OUT
, 1); msleep(100);
239 dib0700_set_gpio(adap
->dev
, GPIO0
, GPIO_OUT
, 1);
241 st
->mt2060_if1
[0] = 1220;
243 if (dib7000pc_detection(&adap
->dev
->i2c_adap
)) {
244 adap
->fe
= dvb_attach(dib7000p_attach
, &adap
->dev
->i2c_adap
, 18, &stk7700p_dib7000p_config
);
245 st
->is_dib7000pc
= 1;
247 adap
->fe
= dvb_attach(dib7000m_attach
, &adap
->dev
->i2c_adap
, 18, &stk7700p_dib7000m_config
);
249 return adap
->fe
== NULL
? -ENODEV
: 0;
252 static struct mt2060_config stk7700p_mt2060_config
= {
256 static int stk7700p_tuner_attach(struct dvb_usb_adapter
*adap
)
258 struct dib0700_state
*st
= adap
->dev
->priv
;
259 struct i2c_adapter
*tun_i2c
;
261 if (st
->is_dib7000pc
)
262 tun_i2c
= dib7000p_get_i2c_master(adap
->fe
, DIBX000_I2C_INTERFACE_TUNER
, 1);
264 tun_i2c
= dib7000m_get_i2c_master(adap
->fe
, DIBX000_I2C_INTERFACE_TUNER
, 1);
266 return dvb_attach(mt2060_attach
, adap
->fe
, tun_i2c
, &stk7700p_mt2060_config
,
267 st
->mt2060_if1
[0]) == NULL
? -ENODEV
: 0;
270 struct usb_device_id dib0700_usb_id_table
[] = {
271 { USB_DEVICE(USB_VID_DIBCOM
, USB_PID_DIBCOM_STK7700P
) },
272 { USB_DEVICE(USB_VID_DIBCOM
, USB_PID_DIBCOM_STK7700P_PC
) },
274 { USB_DEVICE(USB_VID_HAUPPAUGE
, USB_PID_HAUPPAUGE_NOVA_T_500
) },
275 { USB_DEVICE(USB_VID_HAUPPAUGE
, USB_PID_HAUPPAUGE_NOVA_T_500_2
) },
276 { USB_DEVICE(USB_VID_HAUPPAUGE
, USB_PID_HAUPPAUGE_NOVA_T_STICK
) },
277 { USB_DEVICE(USB_VID_AVERMEDIA
, USB_PID_AVERMEDIA_VOLAR
) },
278 { USB_DEVICE(USB_VID_COMPRO
, USB_PID_COMPRO_VIDEOMATE_U500
) },
279 { USB_DEVICE(USB_VID_UNIWILL
, USB_PID_UNIWILL_STK7700P
) },
280 { USB_DEVICE(USB_VID_LEADTEK
, USB_PID_WINFAST_DTV_DONGLE_STK7700P
) },
281 { USB_DEVICE(USB_VID_HAUPPAUGE
, USB_PID_HAUPPAUGE_NOVA_T_STICK_2
) },
282 { USB_DEVICE(USB_VID_AVERMEDIA
, USB_PID_AVERMEDIA_VOLAR_2
) },
283 { } /* Terminating entry */
285 MODULE_DEVICE_TABLE(usb
, dib0700_usb_id_table
);
287 #define DIB0700_DEFAULT_DEVICE_PROPERTIES \
288 .caps = DVB_USB_IS_AN_I2C_ADAPTER, \
289 .usb_ctrl = DEVICE_SPECIFIC, \
290 .firmware = "dvb-usb-dib0700-01.fw", \
291 .download_firmware = dib0700_download_firmware, \
293 .size_of_priv = sizeof(struct dib0700_state), \
294 .i2c_algo = &dib0700_i2c_algo, \
295 .identify_state = dib0700_identify_state
297 #define DIB0700_DEFAULT_STREAMING_CONFIG(ep) \
298 .streaming_ctrl = dib0700_streaming_ctrl, \
305 .buffersize = 39480, \
310 struct dvb_usb_device_properties dib0700_devices
[] = {
312 DIB0700_DEFAULT_DEVICE_PROPERTIES
,
317 .frontend_attach
= stk7700p_frontend_attach
,
318 .tuner_attach
= stk7700p_tuner_attach
,
320 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
324 .num_device_descs
= 6,
326 { "DiBcom STK7700P reference design",
327 { &dib0700_usb_id_table
[0], &dib0700_usb_id_table
[1] },
330 { "Hauppauge Nova-T Stick",
331 { &dib0700_usb_id_table
[4], &dib0700_usb_id_table
[9], NULL
},
334 { "AVerMedia AVerTV DVB-T Volar",
335 { &dib0700_usb_id_table
[5], &dib0700_usb_id_table
[10] },
338 { "Compro Videomate U500",
339 { &dib0700_usb_id_table
[6], NULL
},
342 { "Uniwill STK7700P based (Hama and others)",
343 { &dib0700_usb_id_table
[7], NULL
},
346 { "Leadtek Winfast DTV Dongle (STK7700P based)",
347 { &dib0700_usb_id_table
[8], NULL
},
351 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES
,
356 .frontend_attach
= bristol_frontend_attach
,
357 .tuner_attach
= bristol_tuner_attach
,
359 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
361 .frontend_attach
= bristol_frontend_attach
,
362 .tuner_attach
= bristol_tuner_attach
,
364 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
368 .num_device_descs
= 1,
370 { "Hauppauge Nova-T 500 Dual DVB-T",
371 { &dib0700_usb_id_table
[2], &dib0700_usb_id_table
[3], NULL
},
378 int dib0700_device_count
= ARRAY_SIZE(dib0700_devices
);