]> git.karo-electronics.de Git - mv-sheeva.git/blob - drivers/media/dvb/dvb-usb/dib0700_devices.c
V4L/DVB (9046): Add support for Non-Pro version of Pinnacle PCTV HD USB Stick
[mv-sheeva.git] / drivers / media / dvb / dvb-usb / dib0700_devices.c
1 /* Linux driver for devices based on the DiBcom DiB0700 USB bridge
2  *
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.
6  *
7  *  Copyright (C) 2005-7 DiBcom, SA
8  */
9 #include "dib0700.h"
10
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"
20
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).");
25
26 struct dib0700_adapter_state {
27         int (*set_param_save) (struct dvb_frontend *, struct dvb_frontend_parameters *);
28 };
29
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] = {
33         {
34                 .i2c_address = 0x60,
35                 .clock_out   = 3,
36         }, {
37                 .i2c_address = 0x61,
38         }
39 };
40
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),
44
45         .agc1_max = 42598,
46         .agc1_min = 17694,
47         .agc2_max = 45875,
48         .agc2_min = 0,
49
50         .agc1_pt1 = 0,
51         .agc1_pt2 = 59,
52
53         .agc1_slope1 = 0,
54         .agc1_slope2 = 69,
55
56         .agc2_pt1 = 0,
57         .agc2_pt2 = 59,
58
59         .agc2_slope1 = 111,
60         .agc2_slope2 = 28,
61 };
62
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,
68         },
69         {       .agc          = &bristol_dib3000p_mt2060_agc_config,
70                 .max_time     = 0x196,
71                 .ln_adc_level = 0x1cc7,
72                 .output_mpeg2_in_188_bytes = 1,
73         }
74 };
75
76 static int bristol_frontend_attach(struct dvb_usb_adapter *adap)
77 {
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);
84
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);
89
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;
93                 }
94         }
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;
98 }
99
100 static int eeprom_read(struct i2c_adapter *adap,u8 adrs,u8 *pval)
101 {
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 },
105         };
106         if (i2c_transfer(adap, msg, 2) != 2) return -EREMOTEIO;
107         return 0;
108 }
109
110 static int bristol_tuner_attach(struct dvb_usb_adapter *adap)
111 {
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;
119         }
120         return dvb_attach(mt2060_attach,adap->fe, tun_i2c,&bristol_mt2060_config[adap->id],
121                 if1) == NULL ? -ENODEV : 0;
122 }
123
124 /* STK7700D: Pinnacle/Terratec/Hauppauge Dual DVB-T Diversity */
125
126 /* MT226x */
127 static struct dibx000_agc_config stk7700d_7000p_mt2266_agc_config[2] = {
128         {
129                 BAND_UHF, // band_caps
130
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
134
135                 1130,  // inv_gain
136                 21,  // time_stabiliz
137
138                 0,  // alpha_level
139                 118,  // thlock
140
141                 0,     // wbd_inv
142                 3530,  // wbd_ref
143                 1,     // wbd_sel
144                 0,     // wbd_alpha
145
146                 65535,  // agc1_max
147                 33770,  // agc1_min
148                 65535,  // agc2_max
149                 23592,  // agc2_min
150
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
160
161                 17,  // alpha_mant
162                 27,  // alpha_exp
163                 23,  // beta_mant
164                 51,  // beta_exp
165
166                 1,  // perform_agc_softsplit
167         }, {
168                 BAND_VHF | BAND_LBAND, // band_caps
169
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
173
174                 2372, // inv_gain
175                 21,   // time_stabiliz
176
177                 0,    // alpha_level
178                 118,  // thlock
179
180                 0,    // wbd_inv
181                 3530, // wbd_ref
182                 1,     // wbd_sel
183                 0,    // wbd_alpha
184
185                 65535, // agc1_max
186                 0,     // agc1_min
187                 65535, // agc2_max
188                 23592, // agc2_min
189
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
199
200                 17,  // alpha_mant
201                 27,  // alpha_exp
202                 23,  // beta_mant
203                 51,  // beta_exp
204
205                 1,  // perform_agc_softsplit
206         }
207 };
208
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
216 };
217
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,
222
223                 .agc_config_count = 2,
224                 .agc = stk7700d_7000p_mt2266_agc_config,
225                 .bw  = &stk7700d_mt2266_pll_config,
226
227                 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
228                 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
229                 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
230         },
231         {       .output_mpeg2_in_188_bytes = 1,
232                 .hostbus_diversity = 1,
233                 .tuner_is_baseband = 1,
234
235                 .agc_config_count = 2,
236                 .agc = stk7700d_7000p_mt2266_agc_config,
237                 .bw  = &stk7700d_mt2266_pll_config,
238
239                 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
240                 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
241                 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
242         }
243 };
244
245 static struct mt2266_config stk7700d_mt2266_config[2] = {
246         {       .i2c_address = 0x60
247         },
248         {       .i2c_address = 0x60
249         }
250 };
251
252 static int stk7700P2_frontend_attach(struct dvb_usb_adapter *adap)
253 {
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);
265         }
266
267         adap->fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap,0x80+(adap->id << 1),
268                                 &stk7700d_dib7000p_mt2266_config[adap->id]);
269
270         return adap->fe == NULL ? -ENODEV : 0;
271 }
272
273 static int stk7700d_frontend_attach(struct dvb_usb_adapter *adap)
274 {
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);
287         }
288
289         adap->fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap,0x80+(adap->id << 1),
290                                 &stk7700d_dib7000p_mt2266_config[adap->id]);
291
292         return adap->fe == NULL ? -ENODEV : 0;
293 }
294
295 static int stk7700d_tuner_attach(struct dvb_usb_adapter *adap)
296 {
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;;
301 }
302
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 */
306
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 */
312
313         712,    /* inv_gain */
314         21,     /* time_stabiliz */
315
316         0,      /* alpha_level */
317         118,    /* thlock */
318
319         0,      /* wbd_inv */
320         2867,   /* wbd_ref */
321         0,      /* wbd_sel */
322         2,      /* wbd_alpha */
323
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 */
337
338         17,     /* alpha_mant */
339         27,     /* alpha_exp */
340         23,     /* beta_mant */
341         51,     /* beta_exp */
342
343         1,      /* perform_agc_softsplit */
344 };
345
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 */
356 };
357
358 static struct dib7000p_config stk7700ph_dib7700_xc3028_config = {
359         .output_mpeg2_in_188_bytes = 1,
360         .tuner_is_baseband = 1,
361
362         .agc_config_count = 1,
363         .agc = &xc3028_agc_config,
364         .bw  = &xc3028_bw_config,
365
366         .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
367         .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
368         .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
369 };
370
371 static int stk7700ph_xc3028_callback(void *ptr, int command, int arg)
372 {
373         struct dvb_usb_adapter *adap = ptr;
374
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;
387         }
388         return 0;
389 }
390
391 static struct xc2028_ctrl stk7700ph_xc3028_ctrl = {
392         .fname = XC2028_DEFAULT_FIRMWARE,
393         .max_len = 64,
394         .demod = XC3028_FE_DIBCOM52,
395 };
396
397 static struct xc2028_config stk7700ph_xc3028_config = {
398         .i2c_addr = 0x61,
399         .callback = stk7700ph_xc3028_callback,
400         .ctrl = &stk7700ph_xc3028_ctrl,
401 };
402
403 static int stk7700ph_frontend_attach(struct dvb_usb_adapter *adap)
404 {
405         struct usb_device_descriptor *desc = &adap->dev->udev->descriptor;
406
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);
422
423         dib7000p_i2c_enumeration(&adap->dev->i2c_adap, 1, 18,
424                 &stk7700ph_dib7700_xc3028_config);
425
426         adap->fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 0x80,
427                 &stk7700ph_dib7700_xc3028_config);
428
429         return adap->fe == NULL ? -ENODEV : 0;
430 }
431
432 static int stk7700ph_tuner_attach(struct dvb_usb_adapter *adap)
433 {
434         struct i2c_adapter *tun_i2c;
435
436         tun_i2c = dib7000p_get_i2c_master(adap->fe,
437                 DIBX000_I2C_INTERFACE_TUNER, 1);
438
439         stk7700ph_xc3028_config.i2c_adap = tun_i2c;
440         stk7700ph_xc3028_config.video_dev = adap;
441
442         return dvb_attach(xc2028_attach, adap->fe, &stk7700ph_xc3028_config)
443                 == NULL ? -ENODEV : 0;
444 }
445
446 #define DEFAULT_RC_INTERVAL 150
447
448 static u8 rc_request[] = { REQUEST_POLL_RC, 0 };
449
450 /* Number of keypresses to ignore before start repeating */
451 #define RC_REPEAT_DELAY 2
452
453 static int dib0700_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
454 {
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;
465         }
466
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;
469
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]);  */
471
472         dib0700_rc_setup(d); /* reset ir sensor data to prevent false events */
473
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;
484                         }
485                         return 0;
486                 }
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;
494                         }
495                 }
496                 break;
497         }
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;
510                                         }
511
512                                         return 0;
513                                 }
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;
520                         }
521                 }
522                 break;
523         }
524         }
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;
528 }
529
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 },
606
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 },
653
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 },
682 };
683
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
687
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
691
692         712,  // inv_gain
693         41,  // time_stabiliz
694
695         0,  // alpha_level
696         118,  // thlock
697
698         0,     // wbd_inv
699         4095,  // wbd_ref
700         0,     // wbd_sel
701         0,     // wbd_alpha
702
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
716
717         21,  // alpha_mant
718         25,  // alpha_exp
719         28,  // beta_mant
720         48,  // beta_exp
721
722         1,  // perform_agc_softsplit
723         {  0,     // split_min
724            107,   // split_max
725            51800, // global_split_min
726            24700  // global_split_max
727         },
728 };
729
730 static struct dibx000_agc_config stk7700p_7000p_mt2060_agc_config = {
731         BAND_UHF | BAND_VHF,
732
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
736
737         712, // inv_gain
738         41,  // time_stabiliz
739
740         0,   // alpha_level
741         118, // thlock
742
743         0,    // wbd_inv
744         4095, // wbd_ref
745         0,    // wbd_sel
746         0,    // wbd_alpha
747
748         42598, // agc1_max
749         16384, // agc1_min
750         42598, // agc2_max
751             0, // agc2_min
752
753           0,   // agc1_pt1
754         137,   // agc1_pt2
755         255,   // agc1_pt3
756
757           0,   // agc1_slope1
758         255,   // agc1_slope2
759
760         0,     // agc2_pt1
761         0,     // agc2_pt2
762
763          0,    // agc2_slope1
764         41,    // agc2_slope2
765
766         15, // alpha_mant
767         25, // alpha_exp
768
769         28, // beta_mant
770         48, // beta_exp
771
772         0, // perform_agc_softsplit
773 };
774
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
783 };
784
785 static struct dib7000m_config stk7700p_dib7000m_config = {
786         .dvbt_mode = 1,
787         .output_mpeg2_in_188_bytes = 1,
788         .quartz_direct = 1,
789
790         .agc_config_count = 1,
791         .agc = &stk7700p_7000m_mt2060_agc_config,
792         .bw  = &stk7700p_pll_config,
793
794         .gpio_dir = DIB7000M_GPIO_DEFAULT_DIRECTIONS,
795         .gpio_val = DIB7000M_GPIO_DEFAULT_VALUES,
796         .gpio_pwm_pos = DIB7000M_GPIO_DEFAULT_PWM_POS,
797 };
798
799 static struct dib7000p_config stk7700p_dib7000p_config = {
800         .output_mpeg2_in_188_bytes = 1,
801
802         .agc_config_count = 1,
803         .agc = &stk7700p_7000p_mt2060_agc_config,
804         .bw  = &stk7700p_pll_config,
805
806         .gpio_dir = DIB7000M_GPIO_DEFAULT_DIRECTIONS,
807         .gpio_val = DIB7000M_GPIO_DEFAULT_VALUES,
808         .gpio_pwm_pos = DIB7000M_GPIO_DEFAULT_PWM_POS,
809 };
810
811 static int stk7700p_frontend_attach(struct dvb_usb_adapter *adap)
812 {
813         struct dib0700_state *st = adap->dev->priv;
814         /* unless there is no real power management in DVB - we leave the device on GPIO6 */
815
816         dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
817         dib0700_set_gpio(adap->dev, GPIO6,  GPIO_OUT, 0); msleep(50);
818
819         dib0700_set_gpio(adap->dev, GPIO6,  GPIO_OUT, 1); msleep(10);
820         dib0700_set_gpio(adap->dev, GPIO9,  GPIO_OUT, 1);
821
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);
825
826         dib0700_set_gpio(adap->dev,  GPIO0, GPIO_OUT, 1);
827
828         st->mt2060_if1[0] = 1220;
829
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);
835
836         return adap->fe == NULL ? -ENODEV : 0;
837 }
838
839 static struct mt2060_config stk7700p_mt2060_config = {
840         0x60
841 };
842
843 static int stk7700p_tuner_attach(struct dvb_usb_adapter *adap)
844 {
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;
853         }
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);
858
859         return dvb_attach(mt2060_attach, adap->fe, tun_i2c, &stk7700p_mt2060_config,
860                 if1) == NULL ? -ENODEV : 0;
861 }
862
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
869
870         600, // inv_gain
871         10,  // time_stabiliz
872
873         0,  // alpha_level
874         118,  // thlock
875
876         0,     // wbd_inv
877         3530,  // wbd_ref
878         1,     // wbd_sel
879         5,     // wbd_alpha
880
881         65535,  // agc1_max
882                 0,  // agc1_min
883
884         65535,  // agc2_max
885         0,      // agc2_min
886
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
896
897         17,  // alpha_mant
898         27,  // alpha_exp
899         23,  // beta_mant
900         51,  // beta_exp
901
902         0,  // perform_agc_softsplit
903 };
904
905 static int dib7070_tuner_reset(struct dvb_frontend *fe, int onoff)
906 {
907         return dib7000p_set_gpio(fe, 8, 0, !onoff);
908 }
909
910 static int dib7070_tuner_sleep(struct dvb_frontend *fe, int onoff)
911 {
912         return dib7000p_set_gpio(fe, 9, 0, onoff);
913 }
914
915 static struct dib0070_config dib7070p_dib0070_config[2] = {
916         {
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,
927
928         }
929 };
930
931 static int dib7070_set_param_override(struct dvb_frontend *fe, struct dvb_frontend_parameters *fep)
932 {
933         struct dvb_usb_adapter *adap = fe->dvb->priv;
934         struct dib0700_adapter_state *state = adap->priv;
935
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;
942         }
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);
946 }
947
948 static int dib7070p_tuner_attach(struct dvb_usb_adapter *adap)
949 {
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);
952
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;
959         }
960
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;
964 }
965
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
974 };
975
976 static struct dib7000p_config dib7070p_dib7000p_config = {
977         .output_mpeg2_in_188_bytes = 1,
978
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,
984
985         .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
986         .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
987         .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
988
989         .hostbus_diversity = 1,
990 };
991
992 /* STK7070P */
993 static int stk7070p_frontend_attach(struct dvb_usb_adapter *adap)
994 {
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);
1006
1007         dib0700_ctrl_clock(adap->dev, 72, 1);
1008
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);
1013
1014         dib7000p_i2c_enumeration(&adap->dev->i2c_adap, 1, 18,
1015                 &dib7070p_dib7000p_config);
1016
1017         adap->fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 0x80,
1018                 &dib7070p_dib7000p_config);
1019         return adap->fe == NULL ? -ENODEV : 0;
1020 }
1021
1022 /* STK7070PD */
1023 static struct dib7000p_config stk7070pd_dib7000p_config[2] = {
1024         {
1025                 .output_mpeg2_in_188_bytes = 1,
1026
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,
1032
1033                 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
1034                 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
1035                 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
1036
1037                 .hostbus_diversity = 1,
1038         }, {
1039                 .output_mpeg2_in_188_bytes = 1,
1040
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,
1046
1047                 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
1048                 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
1049                 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
1050
1051                 .hostbus_diversity = 1,
1052         }
1053 };
1054
1055 static int stk7070pd_frontend_attach0(struct dvb_usb_adapter *adap)
1056 {
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);
1063
1064         dib0700_ctrl_clock(adap->dev, 72, 1);
1065
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);
1070
1071         dib7000p_i2c_enumeration(&adap->dev->i2c_adap, 2, 18, stk7070pd_dib7000p_config);
1072
1073         adap->fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 0x80, &stk7070pd_dib7000p_config[0]);
1074         return adap->fe == NULL ? -ENODEV : 0;
1075 }
1076
1077 static int stk7070pd_frontend_attach1(struct dvb_usb_adapter *adap)
1078 {
1079         adap->fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 0x82, &stk7070pd_dib7000p_config[1]);
1080         return adap->fe == NULL ? -ENODEV : 0;
1081 }
1082
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
1092 };
1093
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
1104  */
1105 static int s5h1411_frontend_attach(struct dvb_usb_adapter *adap)
1106 {
1107         struct dib0700_state *st = adap->dev->priv;
1108
1109         /* Make use of the new i2c functions from FW 1.20 */
1110         st->fw_use_new_i2c_api = 1;
1111
1112         /* The s5h1411 requires the dib0700 to not be in master mode */
1113         st->disable_streaming_master_mode = 1;
1114
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);
1130
1131         /* Put the CX25843 to sleep for now since we're in digital mode */
1132         dib0700_set_gpio(adap->dev, GPIO2, GPIO_OUT, 1);
1133
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;
1138 }
1139
1140 int dib0700_xc5000_tuner_callback(void *priv, int command, int arg)
1141 {
1142         struct dvb_usb_adapter *adap = priv;
1143
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 */
1149
1150         return 0;
1151 }
1152
1153 static struct xc5000_config s5h1411_xc5000_tunerconfig = {
1154         .i2c_address      = 0x64,
1155         .if_khz           = 5380,
1156         .tuner_callback   = dib0700_xc5000_tuner_callback
1157 };
1158
1159 static int xc5000_tuner_attach(struct dvb_usb_adapter *adap)
1160 {
1161         return dvb_attach(xc5000_attach, adap->fe, &adap->dev->i2c_adap,
1162                           &s5h1411_xc5000_tunerconfig, adap)
1163                 == NULL ? -ENODEV : 0;
1164 }
1165
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         { USB_DEVICE(USB_VID_PINNACLE,  USB_PID_PINNACLE_PCTV801E_SE) },
1212         { 0 }           /* Terminating entry */
1213 };
1214 MODULE_DEVICE_TABLE(usb, dib0700_usb_id_table);
1215
1216 #define DIB0700_DEFAULT_DEVICE_PROPERTIES \
1217         .caps              = DVB_USB_IS_AN_I2C_ADAPTER, \
1218         .usb_ctrl          = DEVICE_SPECIFIC, \
1219         .firmware          = "dvb-usb-dib0700-1.20.fw", \
1220         .download_firmware = dib0700_download_firmware, \
1221         .no_reconnect      = 1, \
1222         .size_of_priv      = sizeof(struct dib0700_state), \
1223         .i2c_algo          = &dib0700_i2c_algo, \
1224         .identify_state    = dib0700_identify_state
1225
1226 #define DIB0700_DEFAULT_STREAMING_CONFIG(ep) \
1227         .streaming_ctrl   = dib0700_streaming_ctrl, \
1228         .stream = { \
1229                 .type = USB_BULK, \
1230                 .count = 4, \
1231                 .endpoint = ep, \
1232                 .u = { \
1233                         .bulk = { \
1234                                 .buffersize = 39480, \
1235                         } \
1236                 } \
1237         }
1238
1239 struct dvb_usb_device_properties dib0700_devices[] = {
1240         {
1241                 DIB0700_DEFAULT_DEVICE_PROPERTIES,
1242
1243                 .num_adapters = 1,
1244                 .adapter = {
1245                         {
1246                                 .frontend_attach  = stk7700p_frontend_attach,
1247                                 .tuner_attach     = stk7700p_tuner_attach,
1248
1249                                 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
1250                         },
1251                 },
1252
1253                 .num_device_descs = 8,
1254                 .devices = {
1255                         {   "DiBcom STK7700P reference design",
1256                                 { &dib0700_usb_id_table[0], &dib0700_usb_id_table[1] },
1257                                 { NULL },
1258                         },
1259                         {   "Hauppauge Nova-T Stick",
1260                                 { &dib0700_usb_id_table[4], &dib0700_usb_id_table[9], NULL },
1261                                 { NULL },
1262                         },
1263                         {   "AVerMedia AVerTV DVB-T Volar",
1264                                 { &dib0700_usb_id_table[5], &dib0700_usb_id_table[10] },
1265                                 { NULL },
1266                         },
1267                         {   "Compro Videomate U500",
1268                                 { &dib0700_usb_id_table[6], &dib0700_usb_id_table[19] },
1269                                 { NULL },
1270                         },
1271                         {   "Uniwill STK7700P based (Hama and others)",
1272                                 { &dib0700_usb_id_table[7], NULL },
1273                                 { NULL },
1274                         },
1275                         {   "Leadtek Winfast DTV Dongle (STK7700P based)",
1276                                 { &dib0700_usb_id_table[8], &dib0700_usb_id_table[34] },
1277                                 { NULL },
1278                         },
1279                         {   "AVerMedia AVerTV DVB-T Express",
1280                                 { &dib0700_usb_id_table[20] },
1281                                 { NULL },
1282                         },
1283                         {   "Gigabyte U7000",
1284                                 { &dib0700_usb_id_table[21], NULL },
1285                                 { NULL },
1286                         }
1287                 },
1288
1289                 .rc_interval      = DEFAULT_RC_INTERVAL,
1290                 .rc_key_map       = dib0700_rc_keys,
1291                 .rc_key_map_size  = ARRAY_SIZE(dib0700_rc_keys),
1292                 .rc_query         = dib0700_rc_query
1293         }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
1294
1295                 .num_adapters = 2,
1296                 .adapter = {
1297                         {
1298                                 .frontend_attach  = bristol_frontend_attach,
1299                                 .tuner_attach     = bristol_tuner_attach,
1300
1301                                 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
1302                         }, {
1303                                 .frontend_attach  = bristol_frontend_attach,
1304                                 .tuner_attach     = bristol_tuner_attach,
1305
1306                                 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
1307                         }
1308                 },
1309
1310                 .num_device_descs = 1,
1311                 .devices = {
1312                         {   "Hauppauge Nova-T 500 Dual DVB-T",
1313                                 { &dib0700_usb_id_table[2], &dib0700_usb_id_table[3], NULL },
1314                                 { NULL },
1315                         },
1316                 },
1317
1318                 .rc_interval      = DEFAULT_RC_INTERVAL,
1319                 .rc_key_map       = dib0700_rc_keys,
1320                 .rc_key_map_size  = ARRAY_SIZE(dib0700_rc_keys),
1321                 .rc_query         = dib0700_rc_query
1322         }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
1323
1324                 .num_adapters = 2,
1325                 .adapter = {
1326                         {
1327                                 .frontend_attach  = stk7700d_frontend_attach,
1328                                 .tuner_attach     = stk7700d_tuner_attach,
1329
1330                                 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
1331                         }, {
1332                                 .frontend_attach  = stk7700d_frontend_attach,
1333                                 .tuner_attach     = stk7700d_tuner_attach,
1334
1335                                 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
1336                         }
1337                 },
1338
1339                 .num_device_descs = 4,
1340                 .devices = {
1341                         {   "Pinnacle PCTV 2000e",
1342                                 { &dib0700_usb_id_table[11], NULL },
1343                                 { NULL },
1344                         },
1345                         {   "Terratec Cinergy DT XS Diversity",
1346                                 { &dib0700_usb_id_table[12], NULL },
1347                                 { NULL },
1348                         },
1349                         {   "Hauppauge Nova-TD Stick/Elgato Eye-TV Diversity",
1350                                 { &dib0700_usb_id_table[13], NULL },
1351                                 { NULL },
1352                         },
1353                         {   "DiBcom STK7700D reference design",
1354                                 { &dib0700_usb_id_table[14], NULL },
1355                                 { NULL },
1356                         }
1357                 },
1358
1359                 .rc_interval      = DEFAULT_RC_INTERVAL,
1360                 .rc_key_map       = dib0700_rc_keys,
1361                 .rc_key_map_size  = ARRAY_SIZE(dib0700_rc_keys),
1362                 .rc_query         = dib0700_rc_query
1363
1364         }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
1365
1366                 .num_adapters = 1,
1367                 .adapter = {
1368                         {
1369                                 .frontend_attach  = stk7700P2_frontend_attach,
1370                                 .tuner_attach     = stk7700d_tuner_attach,
1371
1372                                 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
1373                         },
1374                 },
1375
1376                 .num_device_descs = 2,
1377                 .devices = {
1378                         {   "ASUS My Cinema U3000 Mini DVBT Tuner",
1379                                 { &dib0700_usb_id_table[23], NULL },
1380                                 { NULL },
1381                         },
1382                         {   "Yuan EC372S",
1383                                 { &dib0700_usb_id_table[31], NULL },
1384                                 { NULL },
1385                         }
1386                 }
1387         }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
1388
1389                 .num_adapters = 1,
1390                 .adapter = {
1391                         {
1392                                 .frontend_attach  = stk7070p_frontend_attach,
1393                                 .tuner_attach     = dib7070p_tuner_attach,
1394
1395                                 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
1396
1397                                 .size_of_priv     = sizeof(struct dib0700_adapter_state),
1398                         },
1399                 },
1400
1401                 .num_device_descs = 9,
1402                 .devices = {
1403                         {   "DiBcom STK7070P reference design",
1404                                 { &dib0700_usb_id_table[15], NULL },
1405                                 { NULL },
1406                         },
1407                         {   "Pinnacle PCTV DVB-T Flash Stick",
1408                                 { &dib0700_usb_id_table[16], NULL },
1409                                 { NULL },
1410                         },
1411                         {   "Artec T14BR DVB-T",
1412                                 { &dib0700_usb_id_table[22], NULL },
1413                                 { NULL },
1414                         },
1415                         {   "ASUS My Cinema U3100 Mini DVBT Tuner",
1416                                 { &dib0700_usb_id_table[24], NULL },
1417                                 { NULL },
1418                         },
1419                         {   "Hauppauge Nova-T Stick",
1420                                 { &dib0700_usb_id_table[25], NULL },
1421                                 { NULL },
1422                         },
1423                         {   "Hauppauge Nova-T MyTV.t",
1424                                 { &dib0700_usb_id_table[26], NULL },
1425                                 { NULL },
1426                         },
1427                         {   "Pinnacle PCTV 72e",
1428                                 { &dib0700_usb_id_table[29], NULL },
1429                                 { NULL },
1430                         },
1431                         {   "Pinnacle PCTV 73e",
1432                                 { &dib0700_usb_id_table[30], NULL },
1433                                 { NULL },
1434                         },
1435                         {   "Terratec Cinergy T USB XXS",
1436                                 { &dib0700_usb_id_table[33], NULL },
1437                                 { NULL },
1438                         },
1439                 },
1440
1441                 .rc_interval      = DEFAULT_RC_INTERVAL,
1442                 .rc_key_map       = dib0700_rc_keys,
1443                 .rc_key_map_size  = ARRAY_SIZE(dib0700_rc_keys),
1444                 .rc_query         = dib0700_rc_query
1445
1446         }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
1447
1448                 .num_adapters = 2,
1449                 .adapter = {
1450                         {
1451                                 .frontend_attach  = stk7070pd_frontend_attach0,
1452                                 .tuner_attach     = dib7070p_tuner_attach,
1453
1454                                 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
1455
1456                                 .size_of_priv     = sizeof(struct dib0700_adapter_state),
1457                         }, {
1458                                 .frontend_attach  = stk7070pd_frontend_attach1,
1459                                 .tuner_attach     = dib7070p_tuner_attach,
1460
1461                                 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
1462
1463                                 .size_of_priv     = sizeof(struct dib0700_adapter_state),
1464                         }
1465                 },
1466
1467                 .num_device_descs = 4,
1468                 .devices = {
1469                         {   "DiBcom STK7070PD reference design",
1470                                 { &dib0700_usb_id_table[17], NULL },
1471                                 { NULL },
1472                         },
1473                         {   "Pinnacle PCTV Dual DVB-T Diversity Stick",
1474                                 { &dib0700_usb_id_table[18], NULL },
1475                                 { NULL },
1476                         },
1477                         {   "Hauppauge Nova-TD Stick (52009)",
1478                                 { &dib0700_usb_id_table[35], NULL },
1479                                 { NULL },
1480                         },
1481                         {   "Hauppauge Nova-TD-500 (84xxx)",
1482                                 { &dib0700_usb_id_table[36], NULL },
1483                                 { NULL },
1484                         }
1485                 }
1486         }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
1487
1488                 .num_adapters = 1,
1489                 .adapter = {
1490                         {
1491                                 .frontend_attach  = stk7700ph_frontend_attach,
1492                                 .tuner_attach     = stk7700ph_tuner_attach,
1493
1494                                 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
1495
1496                                 .size_of_priv = sizeof(struct
1497                                                 dib0700_adapter_state),
1498                         },
1499                 },
1500
1501                 .num_device_descs = 5,
1502                 .devices = {
1503                         {   "Terratec Cinergy HT USB XE",
1504                                 { &dib0700_usb_id_table[27], NULL },
1505                                 { NULL },
1506                         },
1507                         {   "Pinnacle Expresscard 320cx",
1508                                 { &dib0700_usb_id_table[28], NULL },
1509                                 { NULL },
1510                         },
1511                         {   "Terratec Cinergy HT Express",
1512                                 { &dib0700_usb_id_table[32], NULL },
1513                                 { NULL },
1514                         },
1515                         {   "Gigabyte U8000-RH",
1516                                 { &dib0700_usb_id_table[37], NULL },
1517                                 { NULL },
1518                         },
1519                         {   "YUAN High-Tech STK7700PH",
1520                                 { &dib0700_usb_id_table[38], NULL },
1521                                 { NULL },
1522                         },
1523                         {   "Asus My Cinema-U3000Hybrid",
1524                                 { &dib0700_usb_id_table[39], NULL },
1525                                 { NULL },
1526                         },
1527                 },
1528                 .rc_interval      = DEFAULT_RC_INTERVAL,
1529                 .rc_key_map       = dib0700_rc_keys,
1530                 .rc_key_map_size  = ARRAY_SIZE(dib0700_rc_keys),
1531                 .rc_query         = dib0700_rc_query
1532         }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
1533                 .num_adapters = 1,
1534                 .adapter = {
1535                         {
1536                                 .frontend_attach  = s5h1411_frontend_attach,
1537                                 .tuner_attach     = xc5000_tuner_attach,
1538
1539                                 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
1540
1541                                 .size_of_priv = sizeof(struct
1542                                                 dib0700_adapter_state),
1543                         },
1544                 },
1545
1546                 .num_device_descs = 2,
1547                 .devices = {
1548                         {   "Pinnacle PCTV HD Pro USB Stick",
1549                                 { &dib0700_usb_id_table[40], NULL },
1550                                 { NULL },
1551                         },
1552                         {   "Pinnacle PCTV HD USB Stick",
1553                                 { &dib0700_usb_id_table[41], NULL },
1554                                 { NULL },
1555                         },
1556                 },
1557                 .rc_interval      = DEFAULT_RC_INTERVAL,
1558                 .rc_key_map       = dib0700_rc_keys,
1559                 .rc_key_map_size  = ARRAY_SIZE(dib0700_rc_keys),
1560                 .rc_query         = dib0700_rc_query
1561         },
1562 };
1563
1564 int dib0700_device_count = ARRAY_SIZE(dib0700_devices);