V4L/DVB (9044): Add support for Pinnacle PCTV HD Pro 801e (ATSC only)
[linux-2.6/verdex.git] / drivers / media / dvb / dvb-usb / dib0700_devices.c
blob7d9efd7021296038bd014967010a23a4f6286c15
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
8 */
9 #include "dib0700.h"
11 #include "dib3000mc.h"
12 #include "dib7000m.h"
13 #include "dib7000p.h"
14 #include "mt2060.h"
15 #include "mt2266.h"
16 #include "tuner-xc2028.h"
17 #include "xc5000.h"
18 #include "s5h1411.h"
19 #include "dib0070.h"
21 static int force_lna_activation;
22 module_param(force_lna_activation, int, 0644);
23 MODULE_PARM_DESC(force_lna_activation, "force the activation of Low-Noise-Amplifyer(s) (LNA), "
24 "if applicable for the device (default: 0=automatic/off).");
26 struct dib0700_adapter_state {
27 int (*set_param_save) (struct dvb_frontend *, struct dvb_frontend_parameters *);
30 /* Hauppauge Nova-T 500 (aka Bristol)
31 * has a LNA on GPIO0 which is enabled by setting 1 */
32 static struct mt2060_config bristol_mt2060_config[2] = {
34 .i2c_address = 0x60,
35 .clock_out = 3,
36 }, {
37 .i2c_address = 0x61,
41 static struct dibx000_agc_config bristol_dib3000p_mt2060_agc_config = {
42 .band_caps = BAND_VHF | BAND_UHF,
43 .setup = (1 << 8) | (5 << 5) | (0 << 4) | (0 << 3) | (0 << 2) | (2 << 0),
45 .agc1_max = 42598,
46 .agc1_min = 17694,
47 .agc2_max = 45875,
48 .agc2_min = 0,
50 .agc1_pt1 = 0,
51 .agc1_pt2 = 59,
53 .agc1_slope1 = 0,
54 .agc1_slope2 = 69,
56 .agc2_pt1 = 0,
57 .agc2_pt2 = 59,
59 .agc2_slope1 = 111,
60 .agc2_slope2 = 28,
63 static struct dib3000mc_config bristol_dib3000mc_config[2] = {
64 { .agc = &bristol_dib3000p_mt2060_agc_config,
65 .max_time = 0x196,
66 .ln_adc_level = 0x1cc7,
67 .output_mpeg2_in_188_bytes = 1,
69 { .agc = &bristol_dib3000p_mt2060_agc_config,
70 .max_time = 0x196,
71 .ln_adc_level = 0x1cc7,
72 .output_mpeg2_in_188_bytes = 1,
76 static int bristol_frontend_attach(struct dvb_usb_adapter *adap)
78 struct dib0700_state *st = adap->dev->priv;
79 if (adap->id == 0) {
80 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0); msleep(10);
81 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1); msleep(10);
82 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0); msleep(10);
83 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1); msleep(10);
85 if (force_lna_activation)
86 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
87 else
88 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 0);
90 if (dib3000mc_i2c_enumeration(&adap->dev->i2c_adap, 2, DEFAULT_DIB3000P_I2C_ADDRESS, bristol_dib3000mc_config) != 0) {
91 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0); msleep(10);
92 return -ENODEV;
95 st->mt2060_if1[adap->id] = 1220;
96 return (adap->fe = dvb_attach(dib3000mc_attach, &adap->dev->i2c_adap,
97 (10 + adap->id) << 1, &bristol_dib3000mc_config[adap->id])) == NULL ? -ENODEV : 0;
100 static int eeprom_read(struct i2c_adapter *adap,u8 adrs,u8 *pval)
102 struct i2c_msg msg[2] = {
103 { .addr = 0x50, .flags = 0, .buf = &adrs, .len = 1 },
104 { .addr = 0x50, .flags = I2C_M_RD, .buf = pval, .len = 1 },
106 if (i2c_transfer(adap, msg, 2) != 2) return -EREMOTEIO;
107 return 0;
110 static int bristol_tuner_attach(struct dvb_usb_adapter *adap)
112 struct i2c_adapter *prim_i2c = &adap->dev->i2c_adap;
113 struct i2c_adapter *tun_i2c = dib3000mc_get_tuner_i2c_master(adap->fe, 1);
114 s8 a;
115 int if1=1220;
116 if (adap->dev->udev->descriptor.idVendor == cpu_to_le16(USB_VID_HAUPPAUGE) &&
117 adap->dev->udev->descriptor.idProduct == cpu_to_le16(USB_PID_HAUPPAUGE_NOVA_T_500_2)) {
118 if (!eeprom_read(prim_i2c,0x59 + adap->id,&a)) if1=1220+a;
120 return dvb_attach(mt2060_attach,adap->fe, tun_i2c,&bristol_mt2060_config[adap->id],
121 if1) == NULL ? -ENODEV : 0;
124 /* STK7700D: Pinnacle/Terratec/Hauppauge Dual DVB-T Diversity */
126 /* MT226x */
127 static struct dibx000_agc_config stk7700d_7000p_mt2266_agc_config[2] = {
129 BAND_UHF, // band_caps
131 /* 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,
132 * 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 */
133 (0 << 15) | (0 << 14) | (1 << 11) | (1 << 10) | (1 << 9) | (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0), // setup
135 1130, // inv_gain
136 21, // time_stabiliz
138 0, // alpha_level
139 118, // thlock
141 0, // wbd_inv
142 3530, // wbd_ref
143 1, // wbd_sel
144 0, // wbd_alpha
146 65535, // agc1_max
147 33770, // agc1_min
148 65535, // agc2_max
149 23592, // agc2_min
151 0, // agc1_pt1
152 62, // agc1_pt2
153 255, // agc1_pt3
154 64, // agc1_slope1
155 64, // agc1_slope2
156 132, // agc2_pt1
157 192, // agc2_pt2
158 80, // agc2_slope1
159 80, // agc2_slope2
161 17, // alpha_mant
162 27, // alpha_exp
163 23, // beta_mant
164 51, // beta_exp
166 1, // perform_agc_softsplit
167 }, {
168 BAND_VHF | BAND_LBAND, // band_caps
170 /* 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,
171 * 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 */
172 (0 << 15) | (0 << 14) | (1 << 11) | (1 << 10) | (1 << 9) | (0 << 8) | (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0), // setup
174 2372, // inv_gain
175 21, // time_stabiliz
177 0, // alpha_level
178 118, // thlock
180 0, // wbd_inv
181 3530, // wbd_ref
182 1, // wbd_sel
183 0, // wbd_alpha
185 65535, // agc1_max
186 0, // agc1_min
187 65535, // agc2_max
188 23592, // agc2_min
190 0, // agc1_pt1
191 128, // agc1_pt2
192 128, // agc1_pt3
193 128, // agc1_slope1
194 0, // agc1_slope2
195 128, // agc2_pt1
196 253, // agc2_pt2
197 81, // agc2_slope1
198 0, // agc2_slope2
200 17, // alpha_mant
201 27, // alpha_exp
202 23, // beta_mant
203 51, // beta_exp
205 1, // perform_agc_softsplit
209 static struct dibx000_bandwidth_config stk7700d_mt2266_pll_config = {
210 60000, 30000, // internal, sampling
211 1, 8, 3, 1, 0, // pll_cfg: prediv, ratio, range, reset, bypass
212 0, 0, 1, 1, 2, // misc: refdiv, bypclk_div, IO_CLK_en_core, ADClkSrc, modulo
213 (3 << 14) | (1 << 12) | (524 << 0), // sad_cfg: refsel, sel, freq_15k
214 0, // ifreq
215 20452225, // timf
218 static struct dib7000p_config stk7700d_dib7000p_mt2266_config[] = {
219 { .output_mpeg2_in_188_bytes = 1,
220 .hostbus_diversity = 1,
221 .tuner_is_baseband = 1,
223 .agc_config_count = 2,
224 .agc = stk7700d_7000p_mt2266_agc_config,
225 .bw = &stk7700d_mt2266_pll_config,
227 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
228 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
229 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
231 { .output_mpeg2_in_188_bytes = 1,
232 .hostbus_diversity = 1,
233 .tuner_is_baseband = 1,
235 .agc_config_count = 2,
236 .agc = stk7700d_7000p_mt2266_agc_config,
237 .bw = &stk7700d_mt2266_pll_config,
239 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
240 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
241 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
245 static struct mt2266_config stk7700d_mt2266_config[2] = {
246 { .i2c_address = 0x60
248 { .i2c_address = 0x60
252 static int stk7700P2_frontend_attach(struct dvb_usb_adapter *adap)
254 if (adap->id == 0) {
255 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
256 msleep(10);
257 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
258 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
259 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
260 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
261 msleep(10);
262 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
263 msleep(10);
264 dib7000p_i2c_enumeration(&adap->dev->i2c_adap,1,18,stk7700d_dib7000p_mt2266_config);
267 adap->fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap,0x80+(adap->id << 1),
268 &stk7700d_dib7000p_mt2266_config[adap->id]);
270 return adap->fe == NULL ? -ENODEV : 0;
273 static int stk7700d_frontend_attach(struct dvb_usb_adapter *adap)
275 if (adap->id == 0) {
276 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
277 msleep(10);
278 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
279 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
280 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
281 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
282 msleep(10);
283 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
284 msleep(10);
285 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
286 dib7000p_i2c_enumeration(&adap->dev->i2c_adap,2,18,stk7700d_dib7000p_mt2266_config);
289 adap->fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap,0x80+(adap->id << 1),
290 &stk7700d_dib7000p_mt2266_config[adap->id]);
292 return adap->fe == NULL ? -ENODEV : 0;
295 static int stk7700d_tuner_attach(struct dvb_usb_adapter *adap)
297 struct i2c_adapter *tun_i2c;
298 tun_i2c = dib7000p_get_i2c_master(adap->fe, DIBX000_I2C_INTERFACE_TUNER, 1);
299 return dvb_attach(mt2266_attach, adap->fe, tun_i2c,
300 &stk7700d_mt2266_config[adap->id]) == NULL ? -ENODEV : 0;;
303 /* STK7700-PH: Digital/Analog Hybrid Tuner, e.h. Cinergy HT USB HE */
304 static struct dibx000_agc_config xc3028_agc_config = {
305 BAND_VHF | BAND_UHF, /* band_caps */
307 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=0,
308 * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
309 * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=2, P_agc_write=0 */
310 (0 << 15) | (0 << 14) | (0 << 11) | (0 << 10) | (0 << 9) | (0 << 8) |
311 (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0), /* setup */
313 712, /* inv_gain */
314 21, /* time_stabiliz */
316 0, /* alpha_level */
317 118, /* thlock */
319 0, /* wbd_inv */
320 2867, /* wbd_ref */
321 0, /* wbd_sel */
322 2, /* wbd_alpha */
324 0, /* agc1_max */
325 0, /* agc1_min */
326 39718, /* agc2_max */
327 9930, /* agc2_min */
328 0, /* agc1_pt1 */
329 0, /* agc1_pt2 */
330 0, /* agc1_pt3 */
331 0, /* agc1_slope1 */
332 0, /* agc1_slope2 */
333 0, /* agc2_pt1 */
334 128, /* agc2_pt2 */
335 29, /* agc2_slope1 */
336 29, /* agc2_slope2 */
338 17, /* alpha_mant */
339 27, /* alpha_exp */
340 23, /* beta_mant */
341 51, /* beta_exp */
343 1, /* perform_agc_softsplit */
346 /* PLL Configuration for COFDM BW_MHz = 8.00 with external clock = 30.00 */
347 static struct dibx000_bandwidth_config xc3028_bw_config = {
348 60000, 30000, /* internal, sampling */
349 1, 8, 3, 1, 0, /* pll_cfg: prediv, ratio, range, reset, bypass */
350 0, 0, 1, 1, 0, /* misc: refdiv, bypclk_div, IO_CLK_en_core, ADClkSrc,
351 modulo */
352 (3 << 14) | (1 << 12) | (524 << 0), /* sad_cfg: refsel, sel, freq_15k */
353 (1 << 25) | 5816102, /* ifreq = 5.200000 MHz */
354 20452225, /* timf */
355 30000000, /* xtal_hz */
358 static struct dib7000p_config stk7700ph_dib7700_xc3028_config = {
359 .output_mpeg2_in_188_bytes = 1,
360 .tuner_is_baseband = 1,
362 .agc_config_count = 1,
363 .agc = &xc3028_agc_config,
364 .bw = &xc3028_bw_config,
366 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
367 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
368 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
371 static int stk7700ph_xc3028_callback(void *ptr, int command, int arg)
373 struct dvb_usb_adapter *adap = ptr;
375 switch (command) {
376 case XC2028_TUNER_RESET:
377 /* Send the tuner in then out of reset */
378 dib7000p_set_gpio(adap->fe, 8, 0, 0); msleep(10);
379 dib7000p_set_gpio(adap->fe, 8, 0, 1);
380 break;
381 case XC2028_RESET_CLK:
382 break;
383 default:
384 err("%s: unknown command %d, arg %d\n", __func__,
385 command, arg);
386 return -EINVAL;
388 return 0;
391 static struct xc2028_ctrl stk7700ph_xc3028_ctrl = {
392 .fname = XC2028_DEFAULT_FIRMWARE,
393 .max_len = 64,
394 .demod = XC3028_FE_DIBCOM52,
397 static struct xc2028_config stk7700ph_xc3028_config = {
398 .i2c_addr = 0x61,
399 .callback = stk7700ph_xc3028_callback,
400 .ctrl = &stk7700ph_xc3028_ctrl,
403 static int stk7700ph_frontend_attach(struct dvb_usb_adapter *adap)
405 struct usb_device_descriptor *desc = &adap->dev->udev->descriptor;
407 if (desc->idVendor == cpu_to_le16(USB_VID_PINNACLE) &&
408 desc->idProduct == cpu_to_le16(USB_PID_PINNACLE_EXPRESSCARD_320CX))
409 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
410 else
411 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
412 msleep(20);
413 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
414 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
415 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
416 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
417 msleep(10);
418 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
419 msleep(20);
420 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
421 msleep(10);
423 dib7000p_i2c_enumeration(&adap->dev->i2c_adap, 1, 18,
424 &stk7700ph_dib7700_xc3028_config);
426 adap->fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 0x80,
427 &stk7700ph_dib7700_xc3028_config);
429 return adap->fe == NULL ? -ENODEV : 0;
432 static int stk7700ph_tuner_attach(struct dvb_usb_adapter *adap)
434 struct i2c_adapter *tun_i2c;
436 tun_i2c = dib7000p_get_i2c_master(adap->fe,
437 DIBX000_I2C_INTERFACE_TUNER, 1);
439 stk7700ph_xc3028_config.i2c_adap = tun_i2c;
440 stk7700ph_xc3028_config.video_dev = adap;
442 return dvb_attach(xc2028_attach, adap->fe, &stk7700ph_xc3028_config)
443 == NULL ? -ENODEV : 0;
446 #define DEFAULT_RC_INTERVAL 150
448 static u8 rc_request[] = { REQUEST_POLL_RC, 0 };
450 /* Number of keypresses to ignore before start repeating */
451 #define RC_REPEAT_DELAY 2
453 static int dib0700_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
455 u8 key[4];
456 int i;
457 struct dvb_usb_rc_key *keymap = d->props.rc_key_map;
458 struct dib0700_state *st = d->priv;
459 *event = 0;
460 *state = REMOTE_NO_KEY_PRESSED;
461 i=dib0700_ctrl_rd(d,rc_request,2,key,4);
462 if (i<=0) {
463 err("RC Query Failed");
464 return -1;
467 /* losing half of KEY_0 events from Philipps rc5 remotes.. */
468 if (key[0]==0 && key[1]==0 && key[2]==0 && key[3]==0) return 0;
470 /* 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]); */
472 dib0700_rc_setup(d); /* reset ir sensor data to prevent false events */
474 switch (dvb_usb_dib0700_ir_proto) {
475 case 0: {
476 /* NEC protocol sends repeat code as 0 0 0 FF */
477 if ((key[3-2] == 0x00) && (key[3-3] == 0x00) &&
478 (key[3] == 0xFF)) {
479 st->rc_counter++;
480 if (st->rc_counter > RC_REPEAT_DELAY) {
481 *event = d->last_event;
482 *state = REMOTE_KEY_PRESSED;
483 st->rc_counter = RC_REPEAT_DELAY;
485 return 0;
487 for (i=0;i<d->props.rc_key_map_size; i++) {
488 if (keymap[i].custom == key[3-2] && keymap[i].data == key[3-3]) {
489 st->rc_counter = 0;
490 *event = keymap[i].event;
491 *state = REMOTE_KEY_PRESSED;
492 d->last_event = keymap[i].event;
493 return 0;
496 break;
498 default: {
499 /* RC-5 protocol changes toggle bit on new keypress */
500 for (i = 0; i < d->props.rc_key_map_size; i++) {
501 if (keymap[i].custom == key[3-2] && keymap[i].data == key[3-3]) {
502 if (d->last_event == keymap[i].event &&
503 key[3-1] == st->rc_toggle) {
504 st->rc_counter++;
505 /* prevents unwanted double hits */
506 if (st->rc_counter > RC_REPEAT_DELAY) {
507 *event = d->last_event;
508 *state = REMOTE_KEY_PRESSED;
509 st->rc_counter = RC_REPEAT_DELAY;
512 return 0;
514 st->rc_counter = 0;
515 *event = keymap[i].event;
516 *state = REMOTE_KEY_PRESSED;
517 st->rc_toggle = key[3-1];
518 d->last_event = keymap[i].event;
519 return 0;
522 break;
525 err("Unknown remote controller key: %2X %2X %2X %2X", (int) key[3-2], (int) key[3-3], (int) key[3-1], (int) key[3]);
526 d->last_event = 0;
527 return 0;
530 static struct dvb_usb_rc_key dib0700_rc_keys[] = {
531 /* Key codes for the tiny Pinnacle remote*/
532 { 0x07, 0x00, KEY_MUTE },
533 { 0x07, 0x01, KEY_MENU }, // Pinnacle logo
534 { 0x07, 0x39, KEY_POWER },
535 { 0x07, 0x03, KEY_VOLUMEUP },
536 { 0x07, 0x09, KEY_VOLUMEDOWN },
537 { 0x07, 0x06, KEY_CHANNELUP },
538 { 0x07, 0x0c, KEY_CHANNELDOWN },
539 { 0x07, 0x0f, KEY_1 },
540 { 0x07, 0x15, KEY_2 },
541 { 0x07, 0x10, KEY_3 },
542 { 0x07, 0x18, KEY_4 },
543 { 0x07, 0x1b, KEY_5 },
544 { 0x07, 0x1e, KEY_6 },
545 { 0x07, 0x11, KEY_7 },
546 { 0x07, 0x21, KEY_8 },
547 { 0x07, 0x12, KEY_9 },
548 { 0x07, 0x27, KEY_0 },
549 { 0x07, 0x24, KEY_SCREEN }, // 'Square' key
550 { 0x07, 0x2a, KEY_TEXT }, // 'T' key
551 { 0x07, 0x2d, KEY_REWIND },
552 { 0x07, 0x30, KEY_PLAY },
553 { 0x07, 0x33, KEY_FASTFORWARD },
554 { 0x07, 0x36, KEY_RECORD },
555 { 0x07, 0x3c, KEY_STOP },
556 { 0x07, 0x3f, KEY_CANCEL }, // '?' key
557 /* Key codes for the Terratec Cinergy DT XS Diversity, similar to cinergyT2.c */
558 { 0xeb, 0x01, KEY_POWER },
559 { 0xeb, 0x02, KEY_1 },
560 { 0xeb, 0x03, KEY_2 },
561 { 0xeb, 0x04, KEY_3 },
562 { 0xeb, 0x05, KEY_4 },
563 { 0xeb, 0x06, KEY_5 },
564 { 0xeb, 0x07, KEY_6 },
565 { 0xeb, 0x08, KEY_7 },
566 { 0xeb, 0x09, KEY_8 },
567 { 0xeb, 0x0a, KEY_9 },
568 { 0xeb, 0x0b, KEY_VIDEO },
569 { 0xeb, 0x0c, KEY_0 },
570 { 0xeb, 0x0d, KEY_REFRESH },
571 { 0xeb, 0x0f, KEY_EPG },
572 { 0xeb, 0x10, KEY_UP },
573 { 0xeb, 0x11, KEY_LEFT },
574 { 0xeb, 0x12, KEY_OK },
575 { 0xeb, 0x13, KEY_RIGHT },
576 { 0xeb, 0x14, KEY_DOWN },
577 { 0xeb, 0x16, KEY_INFO },
578 { 0xeb, 0x17, KEY_RED },
579 { 0xeb, 0x18, KEY_GREEN },
580 { 0xeb, 0x19, KEY_YELLOW },
581 { 0xeb, 0x1a, KEY_BLUE },
582 { 0xeb, 0x1b, KEY_CHANNELUP },
583 { 0xeb, 0x1c, KEY_VOLUMEUP },
584 { 0xeb, 0x1d, KEY_MUTE },
585 { 0xeb, 0x1e, KEY_VOLUMEDOWN },
586 { 0xeb, 0x1f, KEY_CHANNELDOWN },
587 { 0xeb, 0x40, KEY_PAUSE },
588 { 0xeb, 0x41, KEY_HOME },
589 { 0xeb, 0x42, KEY_MENU }, /* DVD Menu */
590 { 0xeb, 0x43, KEY_SUBTITLE },
591 { 0xeb, 0x44, KEY_TEXT }, /* Teletext */
592 { 0xeb, 0x45, KEY_DELETE },
593 { 0xeb, 0x46, KEY_TV },
594 { 0xeb, 0x47, KEY_DVD },
595 { 0xeb, 0x48, KEY_STOP },
596 { 0xeb, 0x49, KEY_VIDEO },
597 { 0xeb, 0x4a, KEY_AUDIO }, /* Music */
598 { 0xeb, 0x4b, KEY_SCREEN }, /* Pic */
599 { 0xeb, 0x4c, KEY_PLAY },
600 { 0xeb, 0x4d, KEY_BACK },
601 { 0xeb, 0x4e, KEY_REWIND },
602 { 0xeb, 0x4f, KEY_FASTFORWARD },
603 { 0xeb, 0x54, KEY_PREVIOUS },
604 { 0xeb, 0x58, KEY_RECORD },
605 { 0xeb, 0x5c, KEY_NEXT },
607 /* Key codes for the Haupauge WinTV Nova-TD, copied from nova-t-usb2.c (Nova-T USB2) */
608 { 0x1e, 0x00, KEY_0 },
609 { 0x1e, 0x01, KEY_1 },
610 { 0x1e, 0x02, KEY_2 },
611 { 0x1e, 0x03, KEY_3 },
612 { 0x1e, 0x04, KEY_4 },
613 { 0x1e, 0x05, KEY_5 },
614 { 0x1e, 0x06, KEY_6 },
615 { 0x1e, 0x07, KEY_7 },
616 { 0x1e, 0x08, KEY_8 },
617 { 0x1e, 0x09, KEY_9 },
618 { 0x1e, 0x0a, KEY_KPASTERISK },
619 { 0x1e, 0x0b, KEY_RED },
620 { 0x1e, 0x0c, KEY_RADIO },
621 { 0x1e, 0x0d, KEY_MENU },
622 { 0x1e, 0x0e, KEY_GRAVE }, /* # */
623 { 0x1e, 0x0f, KEY_MUTE },
624 { 0x1e, 0x10, KEY_VOLUMEUP },
625 { 0x1e, 0x11, KEY_VOLUMEDOWN },
626 { 0x1e, 0x12, KEY_CHANNEL },
627 { 0x1e, 0x14, KEY_UP },
628 { 0x1e, 0x15, KEY_DOWN },
629 { 0x1e, 0x16, KEY_LEFT },
630 { 0x1e, 0x17, KEY_RIGHT },
631 { 0x1e, 0x18, KEY_VIDEO },
632 { 0x1e, 0x19, KEY_AUDIO },
633 { 0x1e, 0x1a, KEY_MEDIA },
634 { 0x1e, 0x1b, KEY_EPG },
635 { 0x1e, 0x1c, KEY_TV },
636 { 0x1e, 0x1e, KEY_NEXT },
637 { 0x1e, 0x1f, KEY_BACK },
638 { 0x1e, 0x20, KEY_CHANNELUP },
639 { 0x1e, 0x21, KEY_CHANNELDOWN },
640 { 0x1e, 0x24, KEY_LAST }, /* Skip backwards */
641 { 0x1e, 0x25, KEY_OK },
642 { 0x1e, 0x29, KEY_BLUE},
643 { 0x1e, 0x2e, KEY_GREEN },
644 { 0x1e, 0x30, KEY_PAUSE },
645 { 0x1e, 0x32, KEY_REWIND },
646 { 0x1e, 0x34, KEY_FASTFORWARD },
647 { 0x1e, 0x35, KEY_PLAY },
648 { 0x1e, 0x36, KEY_STOP },
649 { 0x1e, 0x37, KEY_RECORD },
650 { 0x1e, 0x38, KEY_YELLOW },
651 { 0x1e, 0x3b, KEY_GOTO },
652 { 0x1e, 0x3d, KEY_POWER },
654 /* Key codes for the Leadtek Winfast DTV Dongle */
655 { 0x00, 0x42, KEY_POWER },
656 { 0x07, 0x7c, KEY_TUNER },
657 { 0x0f, 0x4e, KEY_PRINT }, /* PREVIEW */
658 { 0x08, 0x40, KEY_SCREEN }, /* full screen toggle*/
659 { 0x0f, 0x71, KEY_DOT }, /* frequency */
660 { 0x07, 0x43, KEY_0 },
661 { 0x0c, 0x41, KEY_1 },
662 { 0x04, 0x43, KEY_2 },
663 { 0x0b, 0x7f, KEY_3 },
664 { 0x0e, 0x41, KEY_4 },
665 { 0x06, 0x43, KEY_5 },
666 { 0x09, 0x7f, KEY_6 },
667 { 0x0d, 0x7e, KEY_7 },
668 { 0x05, 0x7c, KEY_8 },
669 { 0x0a, 0x40, KEY_9 },
670 { 0x0e, 0x4e, KEY_CLEAR },
671 { 0x04, 0x7c, KEY_CHANNEL }, /* show channel number */
672 { 0x0f, 0x41, KEY_LAST }, /* recall */
673 { 0x03, 0x42, KEY_MUTE },
674 { 0x06, 0x4c, KEY_RESERVED }, /* PIP button*/
675 { 0x01, 0x72, KEY_SHUFFLE }, /* SNAPSHOT */
676 { 0x0c, 0x4e, KEY_PLAYPAUSE }, /* TIMESHIFT */
677 { 0x0b, 0x70, KEY_RECORD },
678 { 0x03, 0x7d, KEY_VOLUMEUP },
679 { 0x01, 0x7d, KEY_VOLUMEDOWN },
680 { 0x02, 0x42, KEY_CHANNELUP },
681 { 0x00, 0x7d, KEY_CHANNELDOWN },
684 /* STK7700P: Hauppauge Nova-T Stick, AVerMedia Volar */
685 static struct dibx000_agc_config stk7700p_7000m_mt2060_agc_config = {
686 BAND_UHF | BAND_VHF, // band_caps
688 /* 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,
689 * 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 */
690 (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8) | (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0), // setup
692 712, // inv_gain
693 41, // time_stabiliz
695 0, // alpha_level
696 118, // thlock
698 0, // wbd_inv
699 4095, // wbd_ref
700 0, // wbd_sel
701 0, // wbd_alpha
703 42598, // agc1_max
704 17694, // agc1_min
705 45875, // agc2_max
706 2621, // agc2_min
707 0, // agc1_pt1
708 76, // agc1_pt2
709 139, // agc1_pt3
710 52, // agc1_slope1
711 59, // agc1_slope2
712 107, // agc2_pt1
713 172, // agc2_pt2
714 57, // agc2_slope1
715 70, // agc2_slope2
717 21, // alpha_mant
718 25, // alpha_exp
719 28, // beta_mant
720 48, // beta_exp
722 1, // perform_agc_softsplit
723 { 0, // split_min
724 107, // split_max
725 51800, // global_split_min
726 24700 // global_split_max
730 static struct dibx000_agc_config stk7700p_7000p_mt2060_agc_config = {
731 BAND_UHF | BAND_VHF,
733 /* 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,
734 * 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 */
735 (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8) | (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0), // setup
737 712, // inv_gain
738 41, // time_stabiliz
740 0, // alpha_level
741 118, // thlock
743 0, // wbd_inv
744 4095, // wbd_ref
745 0, // wbd_sel
746 0, // wbd_alpha
748 42598, // agc1_max
749 16384, // agc1_min
750 42598, // agc2_max
751 0, // agc2_min
753 0, // agc1_pt1
754 137, // agc1_pt2
755 255, // agc1_pt3
757 0, // agc1_slope1
758 255, // agc1_slope2
760 0, // agc2_pt1
761 0, // agc2_pt2
763 0, // agc2_slope1
764 41, // agc2_slope2
766 15, // alpha_mant
767 25, // alpha_exp
769 28, // beta_mant
770 48, // beta_exp
772 0, // perform_agc_softsplit
775 static struct dibx000_bandwidth_config stk7700p_pll_config = {
776 60000, 30000, // internal, sampling
777 1, 8, 3, 1, 0, // pll_cfg: prediv, ratio, range, reset, bypass
778 0, 0, 1, 1, 0, // misc: refdiv, bypclk_div, IO_CLK_en_core, ADClkSrc, modulo
779 (3 << 14) | (1 << 12) | (524 << 0), // sad_cfg: refsel, sel, freq_15k
780 60258167, // ifreq
781 20452225, // timf
782 30000000, // xtal
785 static struct dib7000m_config stk7700p_dib7000m_config = {
786 .dvbt_mode = 1,
787 .output_mpeg2_in_188_bytes = 1,
788 .quartz_direct = 1,
790 .agc_config_count = 1,
791 .agc = &stk7700p_7000m_mt2060_agc_config,
792 .bw = &stk7700p_pll_config,
794 .gpio_dir = DIB7000M_GPIO_DEFAULT_DIRECTIONS,
795 .gpio_val = DIB7000M_GPIO_DEFAULT_VALUES,
796 .gpio_pwm_pos = DIB7000M_GPIO_DEFAULT_PWM_POS,
799 static struct dib7000p_config stk7700p_dib7000p_config = {
800 .output_mpeg2_in_188_bytes = 1,
802 .agc_config_count = 1,
803 .agc = &stk7700p_7000p_mt2060_agc_config,
804 .bw = &stk7700p_pll_config,
806 .gpio_dir = DIB7000M_GPIO_DEFAULT_DIRECTIONS,
807 .gpio_val = DIB7000M_GPIO_DEFAULT_VALUES,
808 .gpio_pwm_pos = DIB7000M_GPIO_DEFAULT_PWM_POS,
811 static int stk7700p_frontend_attach(struct dvb_usb_adapter *adap)
813 struct dib0700_state *st = adap->dev->priv;
814 /* unless there is no real power management in DVB - we leave the device on GPIO6 */
816 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
817 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0); msleep(50);
819 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1); msleep(10);
820 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
822 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0); msleep(10);
823 dib0700_ctrl_clock(adap->dev, 72, 1);
824 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1); msleep(100);
826 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
828 st->mt2060_if1[0] = 1220;
830 if (dib7000pc_detection(&adap->dev->i2c_adap)) {
831 adap->fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 18, &stk7700p_dib7000p_config);
832 st->is_dib7000pc = 1;
833 } else
834 adap->fe = dvb_attach(dib7000m_attach, &adap->dev->i2c_adap, 18, &stk7700p_dib7000m_config);
836 return adap->fe == NULL ? -ENODEV : 0;
839 static struct mt2060_config stk7700p_mt2060_config = {
840 0x60
843 static int stk7700p_tuner_attach(struct dvb_usb_adapter *adap)
845 struct i2c_adapter *prim_i2c = &adap->dev->i2c_adap;
846 struct dib0700_state *st = adap->dev->priv;
847 struct i2c_adapter *tun_i2c;
848 s8 a;
849 int if1=1220;
850 if (adap->dev->udev->descriptor.idVendor == cpu_to_le16(USB_VID_HAUPPAUGE) &&
851 adap->dev->udev->descriptor.idProduct == cpu_to_le16(USB_PID_HAUPPAUGE_NOVA_T_STICK)) {
852 if (!eeprom_read(prim_i2c,0x58,&a)) if1=1220+a;
854 if (st->is_dib7000pc)
855 tun_i2c = dib7000p_get_i2c_master(adap->fe, DIBX000_I2C_INTERFACE_TUNER, 1);
856 else
857 tun_i2c = dib7000m_get_i2c_master(adap->fe, DIBX000_I2C_INTERFACE_TUNER, 1);
859 return dvb_attach(mt2060_attach, adap->fe, tun_i2c, &stk7700p_mt2060_config,
860 if1) == NULL ? -ENODEV : 0;
863 /* DIB7070 generic */
864 static struct dibx000_agc_config dib7070_agc_config = {
865 BAND_UHF | BAND_VHF | BAND_LBAND | BAND_SBAND,
866 /* 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,
867 * 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 */
868 (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0), // setup
870 600, // inv_gain
871 10, // time_stabiliz
873 0, // alpha_level
874 118, // thlock
876 0, // wbd_inv
877 3530, // wbd_ref
878 1, // wbd_sel
879 5, // wbd_alpha
881 65535, // agc1_max
882 0, // agc1_min
884 65535, // agc2_max
885 0, // agc2_min
887 0, // agc1_pt1
888 40, // agc1_pt2
889 183, // agc1_pt3
890 206, // agc1_slope1
891 255, // agc1_slope2
892 72, // agc2_pt1
893 152, // agc2_pt2
894 88, // agc2_slope1
895 90, // agc2_slope2
897 17, // alpha_mant
898 27, // alpha_exp
899 23, // beta_mant
900 51, // beta_exp
902 0, // perform_agc_softsplit
905 static int dib7070_tuner_reset(struct dvb_frontend *fe, int onoff)
907 return dib7000p_set_gpio(fe, 8, 0, !onoff);
910 static int dib7070_tuner_sleep(struct dvb_frontend *fe, int onoff)
912 return dib7000p_set_gpio(fe, 9, 0, onoff);
915 static struct dib0070_config dib7070p_dib0070_config[2] = {
917 .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
918 .reset = dib7070_tuner_reset,
919 .sleep = dib7070_tuner_sleep,
920 .clock_khz = 12000,
921 .clock_pad_drive = 4
922 }, {
923 .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
924 .reset = dib7070_tuner_reset,
925 .sleep = dib7070_tuner_sleep,
926 .clock_khz = 12000,
931 static int dib7070_set_param_override(struct dvb_frontend *fe, struct dvb_frontend_parameters *fep)
933 struct dvb_usb_adapter *adap = fe->dvb->priv;
934 struct dib0700_adapter_state *state = adap->priv;
936 u16 offset;
937 u8 band = BAND_OF_FREQUENCY(fep->frequency/1000);
938 switch (band) {
939 case BAND_VHF: offset = 950; break;
940 case BAND_UHF:
941 default: offset = 550; break;
943 deb_info("WBD for DiB7000P: %d\n", offset + dib0070_wbd_offset(fe));
944 dib7000p_set_wbd_ref(fe, offset + dib0070_wbd_offset(fe));
945 return state->set_param_save(fe, fep);
948 static int dib7070p_tuner_attach(struct dvb_usb_adapter *adap)
950 struct dib0700_adapter_state *st = adap->priv;
951 struct i2c_adapter *tun_i2c = dib7000p_get_i2c_master(adap->fe, DIBX000_I2C_INTERFACE_TUNER, 1);
953 if (adap->id == 0) {
954 if (dvb_attach(dib0070_attach, adap->fe, tun_i2c, &dib7070p_dib0070_config[0]) == NULL)
955 return -ENODEV;
956 } else {
957 if (dvb_attach(dib0070_attach, adap->fe, tun_i2c, &dib7070p_dib0070_config[1]) == NULL)
958 return -ENODEV;
961 st->set_param_save = adap->fe->ops.tuner_ops.set_params;
962 adap->fe->ops.tuner_ops.set_params = dib7070_set_param_override;
963 return 0;
966 static struct dibx000_bandwidth_config dib7070_bw_config_12_mhz = {
967 60000, 15000, // internal, sampling
968 1, 20, 3, 1, 0, // pll_cfg: prediv, ratio, range, reset, bypass
969 0, 0, 1, 1, 2, // misc: refdiv, bypclk_div, IO_CLK_en_core, ADClkSrc, modulo
970 (3 << 14) | (1 << 12) | (524 << 0), // sad_cfg: refsel, sel, freq_15k
971 (0 << 25) | 0, // ifreq = 0.000000 MHz
972 20452225, // timf
973 12000000, // xtal_hz
976 static struct dib7000p_config dib7070p_dib7000p_config = {
977 .output_mpeg2_in_188_bytes = 1,
979 .agc_config_count = 1,
980 .agc = &dib7070_agc_config,
981 .bw = &dib7070_bw_config_12_mhz,
982 .tuner_is_baseband = 1,
983 .spur_protect = 1,
985 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
986 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
987 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
989 .hostbus_diversity = 1,
992 /* STK7070P */
993 static int stk7070p_frontend_attach(struct dvb_usb_adapter *adap)
995 struct usb_device_descriptor *p = &adap->dev->udev->descriptor;
996 if (p->idVendor == cpu_to_le16(USB_VID_PINNACLE) &&
997 p->idProduct == cpu_to_le16(USB_PID_PINNACLE_PCTV72E))
998 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
999 else
1000 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
1001 msleep(10);
1002 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
1003 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
1004 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
1005 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
1007 dib0700_ctrl_clock(adap->dev, 72, 1);
1009 msleep(10);
1010 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
1011 msleep(10);
1012 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
1014 dib7000p_i2c_enumeration(&adap->dev->i2c_adap, 1, 18,
1015 &dib7070p_dib7000p_config);
1017 adap->fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 0x80,
1018 &dib7070p_dib7000p_config);
1019 return adap->fe == NULL ? -ENODEV : 0;
1022 /* STK7070PD */
1023 static struct dib7000p_config stk7070pd_dib7000p_config[2] = {
1025 .output_mpeg2_in_188_bytes = 1,
1027 .agc_config_count = 1,
1028 .agc = &dib7070_agc_config,
1029 .bw = &dib7070_bw_config_12_mhz,
1030 .tuner_is_baseband = 1,
1031 .spur_protect = 1,
1033 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
1034 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
1035 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
1037 .hostbus_diversity = 1,
1038 }, {
1039 .output_mpeg2_in_188_bytes = 1,
1041 .agc_config_count = 1,
1042 .agc = &dib7070_agc_config,
1043 .bw = &dib7070_bw_config_12_mhz,
1044 .tuner_is_baseband = 1,
1045 .spur_protect = 1,
1047 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
1048 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
1049 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
1051 .hostbus_diversity = 1,
1055 static int stk7070pd_frontend_attach0(struct dvb_usb_adapter *adap)
1057 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
1058 msleep(10);
1059 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
1060 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
1061 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
1062 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
1064 dib0700_ctrl_clock(adap->dev, 72, 1);
1066 msleep(10);
1067 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
1068 msleep(10);
1069 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
1071 dib7000p_i2c_enumeration(&adap->dev->i2c_adap, 2, 18, stk7070pd_dib7000p_config);
1073 adap->fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 0x80, &stk7070pd_dib7000p_config[0]);
1074 return adap->fe == NULL ? -ENODEV : 0;
1077 static int stk7070pd_frontend_attach1(struct dvb_usb_adapter *adap)
1079 adap->fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 0x82, &stk7070pd_dib7000p_config[1]);
1080 return adap->fe == NULL ? -ENODEV : 0;
1083 /* S5H1411 */
1084 static struct s5h1411_config pinnacle_801e_config = {
1085 .output_mode = S5H1411_PARALLEL_OUTPUT,
1086 .gpio = S5H1411_GPIO_OFF,
1087 .mpeg_timing = S5H1411_MPEGTIMING_NONCONTINOUS_NONINVERTING_CLOCK,
1088 .qam_if = S5H1411_IF_44000,
1089 .vsb_if = S5H1411_IF_44000,
1090 .inversion = S5H1411_INVERSION_OFF,
1091 .status_mode = S5H1411_DEMODLOCKING
1094 /* Pinnacle PCTV HD Pro 801e GPIOs map:
1095 GPIO0 - currently unknown
1096 GPIO1 - xc5000 tuner reset
1097 GPIO2 - CX25843 sleep
1098 GPIO3 - currently unknown
1099 GPIO4 - currently unknown
1100 GPIO6 - currently unknown
1101 GPIO7 - currently unknown
1102 GPIO9 - currently unknown
1103 GPIO10 - CX25843 reset
1105 static int s5h1411_frontend_attach(struct dvb_usb_adapter *adap)
1107 struct dib0700_state *st = adap->dev->priv;
1109 /* Make use of the new i2c functions from FW 1.20 */
1110 st->fw_use_new_i2c_api = 1;
1112 /* The s5h1411 requires the dib0700 to not be in master mode */
1113 st->disable_streaming_master_mode = 1;
1115 /* All msleep values taken from Windows USB trace */
1116 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 0);
1117 dib0700_set_gpio(adap->dev, GPIO3, GPIO_OUT, 0);
1118 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
1119 msleep(400);
1120 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
1121 msleep(60);
1122 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
1123 msleep(30);
1124 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
1125 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
1126 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
1127 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
1128 dib0700_set_gpio(adap->dev, GPIO2, GPIO_OUT, 0);
1129 msleep(30);
1131 /* Put the CX25843 to sleep for now since we're in digital mode */
1132 dib0700_set_gpio(adap->dev, GPIO2, GPIO_OUT, 1);
1134 /* GPIOs are initialized, do the attach */
1135 adap->fe = dvb_attach(s5h1411_attach, &pinnacle_801e_config,
1136 &adap->dev->i2c_adap);
1137 return adap->fe == NULL ? -ENODEV : 0;
1140 int dib0700_xc5000_tuner_callback(void *priv, int command, int arg)
1142 struct dvb_usb_adapter *adap = priv;
1144 /* Reset the tuner */
1145 dib0700_set_gpio(adap->dev, GPIO1, GPIO_OUT, 0);
1146 msleep(330); /* from Windows USB trace */
1147 dib0700_set_gpio(adap->dev, GPIO1, GPIO_OUT, 1);
1148 msleep(330); /* from Windows USB trace */
1150 return 0;
1153 static struct xc5000_config s5h1411_xc5000_tunerconfig = {
1154 .i2c_address = 0x64,
1155 .if_khz = 5380,
1156 .tuner_callback = dib0700_xc5000_tuner_callback
1159 static int xc5000_tuner_attach(struct dvb_usb_adapter *adap)
1161 return dvb_attach(xc5000_attach, adap->fe, &adap->dev->i2c_adap,
1162 &s5h1411_xc5000_tunerconfig, adap)
1163 == NULL ? -ENODEV : 0;
1166 /* DVB-USB and USB stuff follows */
1167 struct usb_device_id dib0700_usb_id_table[] = {
1168 /* 0 */ { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7700P) },
1169 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7700P_PC) },
1170 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_500) },
1171 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_500_2) },
1172 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_STICK) },
1173 /* 5 */ { USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR) },
1174 { USB_DEVICE(USB_VID_COMPRO, USB_PID_COMPRO_VIDEOMATE_U500) },
1175 { USB_DEVICE(USB_VID_UNIWILL, USB_PID_UNIWILL_STK7700P) },
1176 { USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV_DONGLE_STK7700P) },
1177 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_STICK_2) },
1178 /* 10 */{ USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR_2) },
1179 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV2000E) },
1180 { USB_DEVICE(USB_VID_TERRATEC,
1181 USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY) },
1182 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_TD_STICK) },
1183 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7700D) },
1184 /* 15 */{ USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7070P) },
1185 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV_DVB_T_FLASH) },
1186 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7070PD) },
1187 { USB_DEVICE(USB_VID_PINNACLE,
1188 USB_PID_PINNACLE_PCTV_DUAL_DIVERSITY_DVB_T) },
1189 { USB_DEVICE(USB_VID_COMPRO, USB_PID_COMPRO_VIDEOMATE_U500_PC) },
1190 /* 20 */{ USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_EXPRESS) },
1191 { USB_DEVICE(USB_VID_GIGABYTE, USB_PID_GIGABYTE_U7000) },
1192 { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC, USB_PID_ARTEC_T14BR) },
1193 { USB_DEVICE(USB_VID_ASUS, USB_PID_ASUS_U3000) },
1194 { USB_DEVICE(USB_VID_ASUS, USB_PID_ASUS_U3100) },
1195 /* 25 */{ USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_STICK_3) },
1196 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_MYTV_T) },
1197 { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_HT_USB_XE) },
1198 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_EXPRESSCARD_320CX) },
1199 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV72E) },
1200 /* 30 */{ USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV73E) },
1201 { USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_EC372S) },
1202 { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_HT_EXPRESS) },
1203 { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_XXS) },
1204 { USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV_DONGLE_STK7700P_2) },
1205 /* 35 */{ USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_TD_STICK_52009) },
1206 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_500_3) },
1207 { USB_DEVICE(USB_VID_GIGABYTE, USB_PID_GIGABYTE_U8000) },
1208 { USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_STK7700PH) },
1209 { USB_DEVICE(USB_VID_ASUS, USB_PID_ASUS_U3000H) },
1210 /* 40 */{ USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV801E) },
1211 { 0 } /* Terminating entry */
1213 MODULE_DEVICE_TABLE(usb, dib0700_usb_id_table);
1215 #define DIB0700_DEFAULT_DEVICE_PROPERTIES \
1216 .caps = DVB_USB_IS_AN_I2C_ADAPTER, \
1217 .usb_ctrl = DEVICE_SPECIFIC, \
1218 .firmware = "dvb-usb-dib0700-1.20.fw", \
1219 .download_firmware = dib0700_download_firmware, \
1220 .no_reconnect = 1, \
1221 .size_of_priv = sizeof(struct dib0700_state), \
1222 .i2c_algo = &dib0700_i2c_algo, \
1223 .identify_state = dib0700_identify_state
1225 #define DIB0700_DEFAULT_STREAMING_CONFIG(ep) \
1226 .streaming_ctrl = dib0700_streaming_ctrl, \
1227 .stream = { \
1228 .type = USB_BULK, \
1229 .count = 4, \
1230 .endpoint = ep, \
1231 .u = { \
1232 .bulk = { \
1233 .buffersize = 39480, \
1238 struct dvb_usb_device_properties dib0700_devices[] = {
1240 DIB0700_DEFAULT_DEVICE_PROPERTIES,
1242 .num_adapters = 1,
1243 .adapter = {
1245 .frontend_attach = stk7700p_frontend_attach,
1246 .tuner_attach = stk7700p_tuner_attach,
1248 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
1252 .num_device_descs = 8,
1253 .devices = {
1254 { "DiBcom STK7700P reference design",
1255 { &dib0700_usb_id_table[0], &dib0700_usb_id_table[1] },
1256 { NULL },
1258 { "Hauppauge Nova-T Stick",
1259 { &dib0700_usb_id_table[4], &dib0700_usb_id_table[9], NULL },
1260 { NULL },
1262 { "AVerMedia AVerTV DVB-T Volar",
1263 { &dib0700_usb_id_table[5], &dib0700_usb_id_table[10] },
1264 { NULL },
1266 { "Compro Videomate U500",
1267 { &dib0700_usb_id_table[6], &dib0700_usb_id_table[19] },
1268 { NULL },
1270 { "Uniwill STK7700P based (Hama and others)",
1271 { &dib0700_usb_id_table[7], NULL },
1272 { NULL },
1274 { "Leadtek Winfast DTV Dongle (STK7700P based)",
1275 { &dib0700_usb_id_table[8], &dib0700_usb_id_table[34] },
1276 { NULL },
1278 { "AVerMedia AVerTV DVB-T Express",
1279 { &dib0700_usb_id_table[20] },
1280 { NULL },
1282 { "Gigabyte U7000",
1283 { &dib0700_usb_id_table[21], NULL },
1284 { NULL },
1288 .rc_interval = DEFAULT_RC_INTERVAL,
1289 .rc_key_map = dib0700_rc_keys,
1290 .rc_key_map_size = ARRAY_SIZE(dib0700_rc_keys),
1291 .rc_query = dib0700_rc_query
1292 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
1294 .num_adapters = 2,
1295 .adapter = {
1297 .frontend_attach = bristol_frontend_attach,
1298 .tuner_attach = bristol_tuner_attach,
1300 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
1301 }, {
1302 .frontend_attach = bristol_frontend_attach,
1303 .tuner_attach = bristol_tuner_attach,
1305 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
1309 .num_device_descs = 1,
1310 .devices = {
1311 { "Hauppauge Nova-T 500 Dual DVB-T",
1312 { &dib0700_usb_id_table[2], &dib0700_usb_id_table[3], NULL },
1313 { NULL },
1317 .rc_interval = DEFAULT_RC_INTERVAL,
1318 .rc_key_map = dib0700_rc_keys,
1319 .rc_key_map_size = ARRAY_SIZE(dib0700_rc_keys),
1320 .rc_query = dib0700_rc_query
1321 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
1323 .num_adapters = 2,
1324 .adapter = {
1326 .frontend_attach = stk7700d_frontend_attach,
1327 .tuner_attach = stk7700d_tuner_attach,
1329 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
1330 }, {
1331 .frontend_attach = stk7700d_frontend_attach,
1332 .tuner_attach = stk7700d_tuner_attach,
1334 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
1338 .num_device_descs = 4,
1339 .devices = {
1340 { "Pinnacle PCTV 2000e",
1341 { &dib0700_usb_id_table[11], NULL },
1342 { NULL },
1344 { "Terratec Cinergy DT XS Diversity",
1345 { &dib0700_usb_id_table[12], NULL },
1346 { NULL },
1348 { "Hauppauge Nova-TD Stick/Elgato Eye-TV Diversity",
1349 { &dib0700_usb_id_table[13], NULL },
1350 { NULL },
1352 { "DiBcom STK7700D reference design",
1353 { &dib0700_usb_id_table[14], NULL },
1354 { NULL },
1358 .rc_interval = DEFAULT_RC_INTERVAL,
1359 .rc_key_map = dib0700_rc_keys,
1360 .rc_key_map_size = ARRAY_SIZE(dib0700_rc_keys),
1361 .rc_query = dib0700_rc_query
1363 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
1365 .num_adapters = 1,
1366 .adapter = {
1368 .frontend_attach = stk7700P2_frontend_attach,
1369 .tuner_attach = stk7700d_tuner_attach,
1371 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
1375 .num_device_descs = 2,
1376 .devices = {
1377 { "ASUS My Cinema U3000 Mini DVBT Tuner",
1378 { &dib0700_usb_id_table[23], NULL },
1379 { NULL },
1381 { "Yuan EC372S",
1382 { &dib0700_usb_id_table[31], NULL },
1383 { NULL },
1386 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
1388 .num_adapters = 1,
1389 .adapter = {
1391 .frontend_attach = stk7070p_frontend_attach,
1392 .tuner_attach = dib7070p_tuner_attach,
1394 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
1396 .size_of_priv = sizeof(struct dib0700_adapter_state),
1400 .num_device_descs = 9,
1401 .devices = {
1402 { "DiBcom STK7070P reference design",
1403 { &dib0700_usb_id_table[15], NULL },
1404 { NULL },
1406 { "Pinnacle PCTV DVB-T Flash Stick",
1407 { &dib0700_usb_id_table[16], NULL },
1408 { NULL },
1410 { "Artec T14BR DVB-T",
1411 { &dib0700_usb_id_table[22], NULL },
1412 { NULL },
1414 { "ASUS My Cinema U3100 Mini DVBT Tuner",
1415 { &dib0700_usb_id_table[24], NULL },
1416 { NULL },
1418 { "Hauppauge Nova-T Stick",
1419 { &dib0700_usb_id_table[25], NULL },
1420 { NULL },
1422 { "Hauppauge Nova-T MyTV.t",
1423 { &dib0700_usb_id_table[26], NULL },
1424 { NULL },
1426 { "Pinnacle PCTV 72e",
1427 { &dib0700_usb_id_table[29], NULL },
1428 { NULL },
1430 { "Pinnacle PCTV 73e",
1431 { &dib0700_usb_id_table[30], NULL },
1432 { NULL },
1434 { "Terratec Cinergy T USB XXS",
1435 { &dib0700_usb_id_table[33], NULL },
1436 { NULL },
1440 .rc_interval = DEFAULT_RC_INTERVAL,
1441 .rc_key_map = dib0700_rc_keys,
1442 .rc_key_map_size = ARRAY_SIZE(dib0700_rc_keys),
1443 .rc_query = dib0700_rc_query
1445 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
1447 .num_adapters = 2,
1448 .adapter = {
1450 .frontend_attach = stk7070pd_frontend_attach0,
1451 .tuner_attach = dib7070p_tuner_attach,
1453 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
1455 .size_of_priv = sizeof(struct dib0700_adapter_state),
1456 }, {
1457 .frontend_attach = stk7070pd_frontend_attach1,
1458 .tuner_attach = dib7070p_tuner_attach,
1460 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
1462 .size_of_priv = sizeof(struct dib0700_adapter_state),
1466 .num_device_descs = 4,
1467 .devices = {
1468 { "DiBcom STK7070PD reference design",
1469 { &dib0700_usb_id_table[17], NULL },
1470 { NULL },
1472 { "Pinnacle PCTV Dual DVB-T Diversity Stick",
1473 { &dib0700_usb_id_table[18], NULL },
1474 { NULL },
1476 { "Hauppauge Nova-TD Stick (52009)",
1477 { &dib0700_usb_id_table[35], NULL },
1478 { NULL },
1480 { "Hauppauge Nova-TD-500 (84xxx)",
1481 { &dib0700_usb_id_table[36], NULL },
1482 { NULL },
1485 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
1487 .num_adapters = 1,
1488 .adapter = {
1490 .frontend_attach = stk7700ph_frontend_attach,
1491 .tuner_attach = stk7700ph_tuner_attach,
1493 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
1495 .size_of_priv = sizeof(struct
1496 dib0700_adapter_state),
1500 .num_device_descs = 5,
1501 .devices = {
1502 { "Terratec Cinergy HT USB XE",
1503 { &dib0700_usb_id_table[27], NULL },
1504 { NULL },
1506 { "Pinnacle Expresscard 320cx",
1507 { &dib0700_usb_id_table[28], NULL },
1508 { NULL },
1510 { "Terratec Cinergy HT Express",
1511 { &dib0700_usb_id_table[32], NULL },
1512 { NULL },
1514 { "Gigabyte U8000-RH",
1515 { &dib0700_usb_id_table[37], NULL },
1516 { NULL },
1518 { "YUAN High-Tech STK7700PH",
1519 { &dib0700_usb_id_table[38], NULL },
1520 { NULL },
1522 { "Asus My Cinema-U3000Hybrid",
1523 { &dib0700_usb_id_table[39], NULL },
1524 { NULL },
1527 .rc_interval = DEFAULT_RC_INTERVAL,
1528 .rc_key_map = dib0700_rc_keys,
1529 .rc_key_map_size = ARRAY_SIZE(dib0700_rc_keys),
1530 .rc_query = dib0700_rc_query
1531 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
1532 .num_adapters = 1,
1533 .adapter = {
1535 .frontend_attach = s5h1411_frontend_attach,
1536 .tuner_attach = xc5000_tuner_attach,
1538 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
1540 .size_of_priv = sizeof(struct
1541 dib0700_adapter_state),
1545 .num_device_descs = 1,
1546 .devices = {
1547 { "Pinnacle PCTV HD Pro USB Stick",
1548 { &dib0700_usb_id_table[40], NULL },
1549 { NULL },
1552 .rc_interval = DEFAULT_RC_INTERVAL,
1553 .rc_key_map = dib0700_rc_keys,
1554 .rc_key_map_size = ARRAY_SIZE(dib0700_rc_keys),
1555 .rc_query = dib0700_rc_query
1559 int dib0700_device_count = ARRAY_SIZE(dib0700_devices);