Linux kernel & device driver programming

Cross-Referenced Linux and Device Driver Code

[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ]
Version: [ 2.6.11.8 ] [ 2.6.25 ] [ 2.6.25.8 ] [ 2.6.31.13 ] Architecture: [ i386 ]
  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 "dib0070.h"
 18 
 19 static int force_lna_activation;
 20 module_param(force_lna_activation, int, 0644);
 21 MODULE_PARM_DESC(force_lna_activation, "force the activation of Low-Noise-Amplifyer(s) (LNA), "
 22                 "if applicable for the device (default: 0=automatic/off).");
 23 
 24 struct dib0700_adapter_state {
 25         int (*set_param_save) (struct dvb_frontend *, struct dvb_frontend_parameters *);
 26 };
 27 
 28 /* Hauppauge Nova-T 500 (aka Bristol)
 29  *  has a LNA on GPIO0 which is enabled by setting 1 */
 30 static struct mt2060_config bristol_mt2060_config[2] = {
 31         {
 32                 .i2c_address = 0x60,
 33                 .clock_out   = 3,
 34         }, {
 35                 .i2c_address = 0x61,
 36         }
 37 };
 38 
 39 static struct dibx000_agc_config bristol_dib3000p_mt2060_agc_config = {
 40         .band_caps = BAND_VHF | BAND_UHF,
 41         .setup     = (1 << 8) | (5 << 5) | (0 << 4) | (0 << 3) | (0 << 2) | (2 << 0),
 42 
 43         .agc1_max = 42598,
 44         .agc1_min = 17694,
 45         .agc2_max = 45875,
 46         .agc2_min = 0,
 47 
 48         .agc1_pt1 = 0,
 49         .agc1_pt2 = 59,
 50 
 51         .agc1_slope1 = 0,
 52         .agc1_slope2 = 69,
 53 
 54         .agc2_pt1 = 0,
 55         .agc2_pt2 = 59,
 56 
 57         .agc2_slope1 = 111,
 58         .agc2_slope2 = 28,
 59 };
 60 
 61 static struct dib3000mc_config bristol_dib3000mc_config[2] = {
 62         {       .agc          = &bristol_dib3000p_mt2060_agc_config,
 63                 .max_time     = 0x196,
 64                 .ln_adc_level = 0x1cc7,
 65                 .output_mpeg2_in_188_bytes = 1,
 66         },
 67         {       .agc          = &bristol_dib3000p_mt2060_agc_config,
 68                 .max_time     = 0x196,
 69                 .ln_adc_level = 0x1cc7,
 70                 .output_mpeg2_in_188_bytes = 1,
 71         }
 72 };
 73 
 74 static int bristol_frontend_attach(struct dvb_usb_adapter *adap)
 75 {
 76         struct dib0700_state *st = adap->dev->priv;
 77         if (adap->id == 0) {
 78                 dib0700_set_gpio(adap->dev, GPIO6,  GPIO_OUT, 0); msleep(10);
 79                 dib0700_set_gpio(adap->dev, GPIO6,  GPIO_OUT, 1); msleep(10);
 80                 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0); msleep(10);
 81                 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1); msleep(10);
 82 
 83                 if (force_lna_activation)
 84                         dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
 85                 else
 86                         dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 0);
 87 
 88                 if (dib3000mc_i2c_enumeration(&adap->dev->i2c_adap, 2, DEFAULT_DIB3000P_I2C_ADDRESS, bristol_dib3000mc_config) != 0) {
 89                         dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0); msleep(10);
 90                         return -ENODEV;
 91                 }
 92         }
 93         st->mt2060_if1[adap->id] = 1220;
 94         return (adap->fe = dvb_attach(dib3000mc_attach, &adap->dev->i2c_adap,
 95                 (10 + adap->id) << 1, &bristol_dib3000mc_config[adap->id])) == NULL ? -ENODEV : 0;
 96 }
 97 
 98 static int eeprom_read(struct i2c_adapter *adap,u8 adrs,u8 *pval)
 99 {
100         struct i2c_msg msg[2] = {
101                 { .addr = 0x50, .flags = 0,        .buf = &adrs, .len = 1 },
102                 { .addr = 0x50, .flags = I2C_M_RD, .buf = pval,  .len = 1 },
103         };
104         if (i2c_transfer(adap, msg, 2) != 2) return -EREMOTEIO;
105         return 0;
106 }
107 
108 static int bristol_tuner_attach(struct dvb_usb_adapter *adap)
109 {
110         struct i2c_adapter *prim_i2c = &adap->dev->i2c_adap;
111         struct i2c_adapter *tun_i2c = dib3000mc_get_tuner_i2c_master(adap->fe, 1);
112         s8 a;
113         int if1=1220;
114         if (adap->dev->udev->descriptor.idVendor  == USB_VID_HAUPPAUGE &&
115                 adap->dev->udev->descriptor.idProduct == USB_PID_HAUPPAUGE_NOVA_T_500_2) {
116                 if (!eeprom_read(prim_i2c,0x59 + adap->id,&a)) if1=1220+a;
117         }
118         return dvb_attach(mt2060_attach,adap->fe, tun_i2c,&bristol_mt2060_config[adap->id],
119                 if1) == NULL ? -ENODEV : 0;
120 }
121 
122 /* STK7700D: Pinnacle/Terratec/Hauppauge Dual DVB-T Diversity */
123 
124 /* MT226x */
125 static struct dibx000_agc_config stk7700d_7000p_mt2266_agc_config[2] = {
126         {
127                 BAND_UHF, // band_caps
128 
129                 /* 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,
130                 * 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 */
131                 (0 << 15) | (0 << 14) | (1 << 11) | (1 << 10) | (1 << 9) | (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0), // setup
132 
133                 1130,  // inv_gain
134                 21,  // time_stabiliz
135 
136                 0,  // alpha_level
137                 118,  // thlock
138 
139                 0,     // wbd_inv
140                 3530,  // wbd_ref
141                 1,     // wbd_sel
142                 0,     // wbd_alpha
143 
144                 65535,  // agc1_max
145                 33770,  // agc1_min
146                 65535,  // agc2_max
147                 23592,  // agc2_min
148 
149                 0,    // agc1_pt1
150                 62,   // agc1_pt2
151                 255,  // agc1_pt3
152                 64,   // agc1_slope1
153                 64,   // agc1_slope2
154                 132,  // agc2_pt1
155                 192,  // agc2_pt2
156                 80,   // agc2_slope1
157                 80,   // agc2_slope2
158 
159                 17,  // alpha_mant
160                 27,  // alpha_exp
161                 23,  // beta_mant
162                 51,  // beta_exp
163 
164                 1,  // perform_agc_softsplit
165         }, {
166                 BAND_VHF | BAND_LBAND, // band_caps
167 
168                 /* 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,
169                 * 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 */
170                 (0 << 15) | (0 << 14) | (1 << 11) | (1 << 10) | (1 << 9) | (0 << 8) | (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0), // setup
171 
172                 2372, // inv_gain
173                 21,   // time_stabiliz
174 
175                 0,    // alpha_level
176                 118,  // thlock
177 
178                 0,    // wbd_inv
179                 3530, // wbd_ref
180                 1,     // wbd_sel
181                 0,    // wbd_alpha
182 
183                 65535, // agc1_max
184                 0,     // agc1_min
185                 65535, // agc2_max
186                 23592, // agc2_min
187 
188                 0,    // agc1_pt1
189                 128,  // agc1_pt2
190                 128,  // agc1_pt3
191                 128,  // agc1_slope1
192                 0,    // agc1_slope2
193                 128,  // agc2_pt1
194                 253,  // agc2_pt2
195                 81,   // agc2_slope1
196                 0,    // agc2_slope2
197 
198                 17,  // alpha_mant
199                 27,  // alpha_exp
200                 23,  // beta_mant
201                 51,  // beta_exp
202 
203                 1,  // perform_agc_softsplit
204         }
205 };
206 
207 static struct dibx000_bandwidth_config stk7700d_mt2266_pll_config = {
208         60000, 30000, // internal, sampling
209         1, 8, 3, 1, 0, // pll_cfg: prediv, ratio, range, reset, bypass
210         0, 0, 1, 1, 2, // misc: refdiv, bypclk_div, IO_CLK_en_core, ADClkSrc, modulo
211         (3 << 14) | (1 << 12) | (524 << 0), // sad_cfg: refsel, sel, freq_15k
212         0, // ifreq
213         20452225, // timf
214 };
215 
216 static struct dib7000p_config stk7700d_dib7000p_mt2266_config[] = {
217         {       .output_mpeg2_in_188_bytes = 1,
218                 .hostbus_diversity = 1,
219                 .tuner_is_baseband = 1,
220 
221                 .agc_config_count = 2,
222                 .agc = stk7700d_7000p_mt2266_agc_config,
223                 .bw  = &stk7700d_mt2266_pll_config,
224 
225                 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
226                 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
227                 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
228         },
229         {       .output_mpeg2_in_188_bytes = 1,
230                 .hostbus_diversity = 1,
231                 .tuner_is_baseband = 1,
232 
233                 .agc_config_count = 2,
234                 .agc = stk7700d_7000p_mt2266_agc_config,
235                 .bw  = &stk7700d_mt2266_pll_config,
236 
237                 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
238                 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
239                 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
240         }
241 };
242 
243 static struct mt2266_config stk7700d_mt2266_config[2] = {
244         {       .i2c_address = 0x60
245         },
246         {       .i2c_address = 0x60
247         }
248 };
249 
250 static int stk7700P2_frontend_attach(struct dvb_usb_adapter *adap)
251 {
252         if (adap->id == 0) {
253                 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
254                 msleep(10);
255                 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
256                 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
257                 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
258                 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
259                 msleep(10);
260                 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
261                 msleep(10);
262                 dib7000p_i2c_enumeration(&adap->dev->i2c_adap,1,18,stk7700d_dib7000p_mt2266_config);
263         }
264 
265         adap->fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap,0x80+(adap->id << 1),
266                                 &stk7700d_dib7000p_mt2266_config[adap->id]);
267 
268         return adap->fe == NULL ? -ENODEV : 0;
269 }
270 
271 static int stk7700d_frontend_attach(struct dvb_usb_adapter *adap)
272 {
273         if (adap->id == 0) {
274                 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
275                 msleep(10);
276                 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
277                 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
278                 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
279                 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
280                 msleep(10);
281                 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
282                 msleep(10);
283                 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
284                 dib7000p_i2c_enumeration(&adap->dev->i2c_adap,2,18,stk7700d_dib7000p_mt2266_config);
285         }
286 
287         adap->fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap,0x80+(adap->id << 1),
288                                 &stk7700d_dib7000p_mt2266_config[adap->id]);
289 
290         return adap->fe == NULL ? -ENODEV : 0;
291 }
292 
293 static int stk7700d_tuner_attach(struct dvb_usb_adapter *adap)
294 {
295         struct i2c_adapter *tun_i2c;
296         tun_i2c = dib7000p_get_i2c_master(adap->fe, DIBX000_I2C_INTERFACE_TUNER, 1);
297         return dvb_attach(mt2266_attach, adap->fe, tun_i2c,
298                 &stk7700d_mt2266_config[adap->id]) == NULL ? -ENODEV : 0;;
299 }
300 
301 /* STK7700-PH: Digital/Analog Hybrid Tuner, e.h. Cinergy HT USB HE */
302 struct dibx000_agc_config xc3028_agc_config = {
303         BAND_VHF | BAND_UHF,       /* band_caps */
304 
305         /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=0,
306          * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
307          * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=2, P_agc_write=0 */
308         (0 << 15) | (0 << 14) | (0 << 11) | (0 << 10) | (0 << 9) | (0 << 8) |
309         (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0), /* setup */
310 
311         712,    /* inv_gain */
312         21,     /* time_stabiliz */
313 
314         0,      /* alpha_level */
315         118,    /* thlock */
316 
317         0,      /* wbd_inv */
318         2867,   /* wbd_ref */
319         0,      /* wbd_sel */
320         2,      /* wbd_alpha */
321 
322         0,      /* agc1_max */
323         0,      /* agc1_min */
324         39718,  /* agc2_max */
325         9930,   /* agc2_min */
326         0,      /* agc1_pt1 */
327         0,      /* agc1_pt2 */
328         0,      /* agc1_pt3 */
329         0,      /* agc1_slope1 */
330         0,      /* agc1_slope2 */
331         0,      /* agc2_pt1 */
332         128,    /* agc2_pt2 */
333         29,     /* agc2_slope1 */
334         29,     /* agc2_slope2 */
335 
336         17,     /* alpha_mant */
337         27,     /* alpha_exp */
338         23,     /* beta_mant */
339         51,     /* beta_exp */
340 
341         1,      /* perform_agc_softsplit */
342 };
343 
344 /* PLL Configuration for COFDM BW_MHz = 8.00 with external clock = 30.00 */
345 struct dibx000_bandwidth_config xc3028_bw_config = {
346         60000, 30000, /* internal, sampling */
347         1, 8, 3, 1, 0, /* pll_cfg: prediv, ratio, range, reset, bypass */
348         0, 0, 1, 1, 0, /* misc: refdiv, bypclk_div, IO_CLK_en_core, ADClkSrc,
349                           modulo */
350         (3 << 14) | (1 << 12) | (524 << 0), /* sad_cfg: refsel, sel, freq_15k */
351         (1 << 25) | 5816102, /* ifreq = 5.200000 MHz */
352         20452225, /* timf */
353         30000000, /* xtal_hz */
354 };
355 
356 static struct dib7000p_config stk7700ph_dib7700_xc3028_config = {
357         .output_mpeg2_in_188_bytes = 1,
358         .tuner_is_baseband = 1,
359 
360         .agc_config_count = 1,
361         .agc = &xc3028_agc_config,
362         .bw  = &xc3028_bw_config,
363 
364         .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
365         .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
366         .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
367 };
368 
369 static int stk7700ph_xc3028_callback(void *ptr, int command, int arg)
370 {
371         struct dvb_usb_adapter *adap = ptr;
372 
373         switch (command) {
374         case XC2028_TUNER_RESET:
375                 /* Send the tuner in then out of reset */
376                 dib7000p_set_gpio(adap->fe, 8, 0, 0); msleep(10);
377                 dib7000p_set_gpio(adap->fe, 8, 0, 1);
378                 break;
379         case XC2028_RESET_CLK:
380                 break;
381         default:
382                 err("%s: unknown command %d, arg %d\n", __func__,
383                         command, arg);
384                 return -EINVAL;
385         }
386         return 0;
387 }
388 
389 static struct xc2028_ctrl stk7700ph_xc3028_ctrl = {
390         .fname = XC2028_DEFAULT_FIRMWARE,
391         .max_len = 64,
392         .demod = XC3028_FE_DIBCOM52,
393 };
394 
395 static struct xc2028_config stk7700ph_xc3028_config = {
396         .i2c_addr = 0x61,
397         .callback = stk7700ph_xc3028_callback,
398         .ctrl = &stk7700ph_xc3028_ctrl,
399 };
400 
401 static int stk7700ph_frontend_attach(struct dvb_usb_adapter *adap)
402 {
403         struct usb_device_descriptor *desc = &adap->dev->udev->descriptor;
404 
405         if (desc->idVendor  == USB_VID_PINNACLE &&
406             desc->idProduct == USB_PID_PINNACLE_EXPRESSCARD_320CX)
407         dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
408         else
409         dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
410         msleep(20);
411         dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
412         dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
413         dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
414         dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
415         msleep(10);
416         dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
417         msleep(20);
418         dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
419         msleep(10);
420 
421         dib7000p_i2c_enumeration(&adap->dev->i2c_adap, 1, 18,
422                 &stk7700ph_dib7700_xc3028_config);
423 
424         adap->fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 0x80,
425                 &stk7700ph_dib7700_xc3028_config);
426 
427         return adap->fe == NULL ? -ENODEV : 0;
428 }
429 
430 static int stk7700ph_tuner_attach(struct dvb_usb_adapter *adap)
431 {
432         struct i2c_adapter *tun_i2c;
433 
434         tun_i2c = dib7000p_get_i2c_master(adap->fe,
435                 DIBX000_I2C_INTERFACE_TUNER, 1);
436 
437         stk7700ph_xc3028_config.i2c_adap = tun_i2c;
438         stk7700ph_xc3028_config.video_dev = adap;
439 
440         return dvb_attach(xc2028_attach, adap->fe, &stk7700ph_xc3028_config)
441                 == NULL ? -ENODEV : 0;
442 }
443 
444 #define DEFAULT_RC_INTERVAL 150
445 
446 static u8 rc_request[] = { REQUEST_POLL_RC, 0 };
447 
448 static int dib0700_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
449 {
450         u8 key[4];
451         int i;
452         struct dvb_usb_rc_key *keymap = d->props.rc_key_map;
453         struct dib0700_state *st = d->priv;
454         *event = 0;
455         *state = REMOTE_NO_KEY_PRESSED;
456         i=dib0700_ctrl_rd(d,rc_request,2,key,4);
457         if (i<=0) {
458                 err("RC Query Failed");
459                 return -1;
460         }
461         if (key[0]==0 && key[1]==0 && key[2]==0 && key[3]==0) return 0;
462         if (key[3-1]!=st->rc_toggle) {
463                 for (i=0;i<d->props.rc_key_map_size; i++) {
464                         if (keymap[i].custom == key[3-2] && keymap[i].data == key[3-3]) {
465                                 *event = keymap[i].event;
466                                 *state = REMOTE_KEY_PRESSED;
467                                 st->rc_toggle=key[3-1];
468                                 return 0;
469                         }
470                 }
471                 err("Unknown remote controller key : %2X %2X",(int)key[3-2],(int)key[3-3]);
472         }
473         return 0;
474 }
475 
476 static struct dvb_usb_rc_key dib0700_rc_keys[] = {
477         /* Key codes for the tiny Pinnacle remote*/
478         { 0x07, 0x00, KEY_MUTE },
479         { 0x07, 0x01, KEY_MENU }, // Pinnacle logo
480         { 0x07, 0x39, KEY_POWER },
481         { 0x07, 0x03, KEY_VOLUMEUP },
482         { 0x07, 0x09, KEY_VOLUMEDOWN },
483         { 0x07, 0x06, KEY_CHANNELUP },
484         { 0x07, 0x0c, KEY_CHANNELDOWN },
485         { 0x07, 0x0f, KEY_1 },
486         { 0x07, 0x15, KEY_2 },
487         { 0x07, 0x10, KEY_3 },
488         { 0x07, 0x18, KEY_4 },
489         { 0x07, 0x1b, KEY_5 },
490         { 0x07, 0x1e, KEY_6 },
491         { 0x07, 0x11, KEY_7 },
492         { 0x07, 0x21, KEY_8 },
493         { 0x07, 0x12, KEY_9 },
494         { 0x07, 0x27, KEY_0 },
495         { 0x07, 0x24, KEY_SCREEN }, // 'Square' key
496         { 0x07, 0x2a, KEY_TEXT },   // 'T' key
497         { 0x07, 0x2d, KEY_REWIND },
498         { 0x07, 0x30, KEY_PLAY },
499         { 0x07, 0x33, KEY_FASTFORWARD },
500         { 0x07, 0x36, KEY_RECORD },
501         { 0x07, 0x3c, KEY_STOP },
502         { 0x07, 0x3f, KEY_CANCEL }, // '?' key
503         /* Key codes for the Terratec Cinergy DT XS Diversity, similar to cinergyT2.c */
504         { 0xeb, 0x01, KEY_POWER },
505         { 0xeb, 0x02, KEY_1 },
506         { 0xeb, 0x03, KEY_2 },
507         { 0xeb, 0x04, KEY_3 },
508         { 0xeb, 0x05, KEY_4 },
509         { 0xeb, 0x06, KEY_5 },
510         { 0xeb, 0x07, KEY_6 },
511         { 0xeb, 0x08, KEY_7 },
512         { 0xeb, 0x09, KEY_8 },
513         { 0xeb, 0x0a, KEY_9 },
514         { 0xeb, 0x0b, KEY_VIDEO },
515         { 0xeb, 0x0c, KEY_0 },
516         { 0xeb, 0x0d, KEY_REFRESH },
517         { 0xeb, 0x0f, KEY_EPG },
518         { 0xeb, 0x10, KEY_UP },
519         { 0xeb, 0x11, KEY_LEFT },
520         { 0xeb, 0x12, KEY_OK },
521         { 0xeb, 0x13, KEY_RIGHT },
522         { 0xeb, 0x14, KEY_DOWN },
523         { 0xeb, 0x16, KEY_INFO },
524         { 0xeb, 0x17, KEY_RED },
525         { 0xeb, 0x18, KEY_GREEN },
526         { 0xeb, 0x19, KEY_YELLOW },
527         { 0xeb, 0x1a, KEY_BLUE },
528         { 0xeb, 0x1b, KEY_CHANNELUP },
529         { 0xeb, 0x1c, KEY_VOLUMEUP },
530         { 0xeb, 0x1d, KEY_MUTE },
531         { 0xeb, 0x1e, KEY_VOLUMEDOWN },
532         { 0xeb, 0x1f, KEY_CHANNELDOWN },
533         { 0xeb, 0x40, KEY_PAUSE },
534         { 0xeb, 0x41, KEY_HOME },
535         { 0xeb, 0x42, KEY_MENU }, /* DVD Menu */
536         { 0xeb, 0x43, KEY_SUBTITLE },
537         { 0xeb, 0x44, KEY_TEXT }, /* Teletext */
538         { 0xeb, 0x45, KEY_DELETE },
539         { 0xeb, 0x46, KEY_TV },
540         { 0xeb, 0x47, KEY_DVD },
541         { 0xeb, 0x48, KEY_STOP },
542         { 0xeb, 0x49, KEY_VIDEO },
543         { 0xeb, 0x4a, KEY_AUDIO }, /* Music */
544         { 0xeb, 0x4b, KEY_SCREEN }, /* Pic */
545         { 0xeb, 0x4c, KEY_PLAY },
546         { 0xeb, 0x4d, KEY_BACK },
547         { 0xeb, 0x4e, KEY_REWIND },
548         { 0xeb, 0x4f, KEY_FASTFORWARD },
549         { 0xeb, 0x54, KEY_PREVIOUS },
550         { 0xeb, 0x58, KEY_RECORD },
551         { 0xeb, 0x5c, KEY_NEXT },
552 
553         /* Key codes for the Haupauge WinTV Nova-TD, copied from nova-t-usb2.c (Nova-T USB2) */
554         { 0x1e, 0x00, KEY_0 },
555         { 0x1e, 0x01, KEY_1 },
556         { 0x1e, 0x02, KEY_2 },
557         { 0x1e, 0x03, KEY_3 },
558         { 0x1e, 0x04, KEY_4 },
559         { 0x1e, 0x05, KEY_5 },
560         { 0x1e, 0x06, KEY_6 },
561         { 0x1e, 0x07, KEY_7 },
562         { 0x1e, 0x08, KEY_8 },
563         { 0x1e, 0x09, KEY_9 },
564         { 0x1e, 0x0a, KEY_KPASTERISK },
565         { 0x1e, 0x0b, KEY_RED },
566         { 0x1e, 0x0c, KEY_RADIO },
567         { 0x1e, 0x0d, KEY_MENU },
568         { 0x1e, 0x0e, KEY_GRAVE }, /* # */
569         { 0x1e, 0x0f, KEY_MUTE },
570         { 0x1e, 0x10, KEY_VOLUMEUP },
571         { 0x1e, 0x11, KEY_VOLUMEDOWN },
572         { 0x1e, 0x12, KEY_CHANNEL },
573         { 0x1e, 0x14, KEY_UP },
574         { 0x1e, 0x15, KEY_DOWN },
575         { 0x1e, 0x16, KEY_LEFT },
576         { 0x1e, 0x17, KEY_RIGHT },
577         { 0x1e, 0x18, KEY_VIDEO },
578         { 0x1e, 0x19, KEY_AUDIO },
579         { 0x1e, 0x1a, KEY_MEDIA },
580         { 0x1e, 0x1b, KEY_EPG },
581         { 0x1e, 0x1c, KEY_TV },
582         { 0x1e, 0x1e, KEY_NEXT },
583         { 0x1e, 0x1f, KEY_BACK },
584         { 0x1e, 0x20, KEY_CHANNELUP },
585         { 0x1e, 0x21, KEY_CHANNELDOWN },
586         { 0x1e, 0x24, KEY_LAST }, /* Skip backwards */
587         { 0x1e, 0x25, KEY_OK },
588         { 0x1e, 0x29, KEY_BLUE},
589         { 0x1e, 0x2e, KEY_GREEN },
590         { 0x1e, 0x30, KEY_PAUSE },
591         { 0x1e, 0x32, KEY_REWIND },
592         { 0x1e, 0x34, KEY_FASTFORWARD },
593         { 0x1e, 0x35, KEY_PLAY },
594         { 0x1e, 0x36, KEY_STOP },
595         { 0x1e, 0x37, KEY_RECORD },
596         { 0x1e, 0x38, KEY_YELLOW },
597         { 0x1e, 0x3b, KEY_GOTO },
598         { 0x1e, 0x3d, KEY_POWER },
599 
600         /* Key codes for the Leadtek Winfast DTV Dongle */
601         { 0x00, 0x42, KEY_POWER },
602         { 0x07, 0x7c, KEY_TUNER },
603         { 0x0f, 0x4e, KEY_PRINT }, /* PREVIEW */
604         { 0x08, 0x40, KEY_SCREEN }, /* full screen toggle*/
605         { 0x0f, 0x71, KEY_DOT }, /* frequency */
606         { 0x07, 0x43, KEY_0 },
607         { 0x0c, 0x41, KEY_1 },
608         { 0x04, 0x43, KEY_2 },
609         { 0x0b, 0x7f, KEY_3 },
610         { 0x0e, 0x41, KEY_4 },
611         { 0x06, 0x43, KEY_5 },
612         { 0x09, 0x7f, KEY_6 },
613         { 0x0d, 0x7e, KEY_7 },
614         { 0x05, 0x7c, KEY_8 },
615         { 0x0a, 0x40, KEY_9 },
616         { 0x0e, 0x4e, KEY_CLEAR },
617         { 0x04, 0x7c, KEY_CHANNEL }, /* show channel number */
618         { 0x0f, 0x41, KEY_LAST }, /* recall */
619         { 0x03, 0x42, KEY_MUTE },
620         { 0x06, 0x4c, KEY_RESERVED }, /* PIP button*/
621         { 0x01, 0x72, KEY_SHUFFLE }, /* SNAPSHOT */
622         { 0x0c, 0x4e, KEY_PLAYPAUSE }, /* TIMESHIFT */
623         { 0x0b, 0x70, KEY_RECORD },
624         { 0x03, 0x7d, KEY_VOLUMEUP },
625         { 0x01, 0x7d, KEY_VOLUMEDOWN },
626         { 0x02, 0x42, KEY_CHANNELUP },
627         { 0x00, 0x7d, KEY_CHANNELDOWN },
628 };
629 
630 /* STK7700P: Hauppauge Nova-T Stick, AVerMedia Volar */
631 static struct dibx000_agc_config stk7700p_7000m_mt2060_agc_config = {
632         BAND_UHF | BAND_VHF,       // band_caps
633 
634         /* 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,
635          * 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 */
636         (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8) | (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0), // setup
637 
638         712,  // inv_gain
639         41,  // time_stabiliz
640 
641         0,  // alpha_level
642         118,  // thlock
643 
644         0,     // wbd_inv
645         4095,  // wbd_ref
646         0,     // wbd_sel
647         0,     // wbd_alpha
648 
649         42598,  // agc1_max
650         17694,  // agc1_min
651         45875,  // agc2_max
652         2621,  // agc2_min
653         0,  // agc1_pt1
654         76,  // agc1_pt2
655         139,  // agc1_pt3
656         52,  // agc1_slope1
657         59,  // agc1_slope2
658         107,  // agc2_pt1
659         172,  // agc2_pt2
660         57,  // agc2_slope1
661         70,  // agc2_slope2
662 
663         21,  // alpha_mant
664         25,  // alpha_exp
665         28,  // beta_mant
666         48,  // beta_exp
667 
668         1,  // perform_agc_softsplit
669         {  0,     // split_min
670            107,   // split_max
671            51800, // global_split_min
672            24700  // global_split_max
673         },
674 };
675 
676 static struct dibx000_agc_config stk7700p_7000p_mt2060_agc_config = {
677         BAND_UHF | BAND_VHF,
678 
679         /* 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,
680          * 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 */
681         (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8) | (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0), // setup
682 
683         712, // inv_gain
684         41,  // time_stabiliz
685 
686         0,   // alpha_level
687         118, // thlock
688 
689         0,    // wbd_inv
690         4095, // wbd_ref
691         0,    // wbd_sel
692         0,    // wbd_alpha
693 
694         42598, // agc1_max
695         16384, // agc1_min
696         42598, // agc2_max
697             0, // agc2_min
698 
699           0,   // agc1_pt1
700         137,   // agc1_pt2
701         255,   // agc1_pt3
702 
703           0,   // agc1_slope1
704         255,   // agc1_slope2
705 
706         0,     // agc2_pt1
707         0,     // agc2_pt2
708 
709          0,    // agc2_slope1
710         41,    // agc2_slope2
711 
712         15, // alpha_mant
713         25, // alpha_exp
714 
715         28, // beta_mant
716         48, // beta_exp
717 
718         0, // perform_agc_softsplit
719 };
720 
721 static struct dibx000_bandwidth_config stk7700p_pll_config = {
722         60000, 30000, // internal, sampling
723         1, 8, 3, 1, 0, // pll_cfg: prediv, ratio, range, reset, bypass
724         0, 0, 1, 1, 0, // misc: refdiv, bypclk_div, IO_CLK_en_core, ADClkSrc, modulo
725         (3 << 14) | (1 << 12) | (524 << 0), // sad_cfg: refsel, sel, freq_15k
726         60258167, // ifreq
727         20452225, // timf
728         30000000, // xtal
729 };
730 
731 static struct dib7000m_config stk7700p_dib7000m_config = {
732         .dvbt_mode = 1,
733         .output_mpeg2_in_188_bytes = 1,
734         .quartz_direct = 1,
735 
736         .agc_config_count = 1,
737         .agc = &stk7700p_7000m_mt2060_agc_config,
738         .bw  = &stk7700p_pll_config,
739 
740         .gpio_dir = DIB7000M_GPIO_DEFAULT_DIRECTIONS,
741         .gpio_val = DIB7000M_GPIO_DEFAULT_VALUES,
742         .gpio_pwm_pos = DIB7000M_GPIO_DEFAULT_PWM_POS,
743 };
744 
745 static struct dib7000p_config stk7700p_dib7000p_config = {
746         .output_mpeg2_in_188_bytes = 1,
747 
748         .agc_config_count = 1,
749         .agc = &stk7700p_7000p_mt2060_agc_config,
750         .bw  = &stk7700p_pll_config,
751 
752         .gpio_dir = DIB7000M_GPIO_DEFAULT_DIRECTIONS,
753         .gpio_val = DIB7000M_GPIO_DEFAULT_VALUES,
754         .gpio_pwm_pos = DIB7000M_GPIO_DEFAULT_PWM_POS,
755 };
756 
757 static int stk7700p_frontend_attach(struct dvb_usb_adapter *adap)
758 {
759         struct dib0700_state *st = adap->dev->priv;
760         /* unless there is no real power management in DVB - we leave the device on GPIO6 */
761 
762         dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
763         dib0700_set_gpio(adap->dev, GPIO6,  GPIO_OUT, 0); msleep(50);
764 
765         dib0700_set_gpio(adap->dev, GPIO6,  GPIO_OUT, 1); msleep(10);
766         dib0700_set_gpio(adap->dev, GPIO9,  GPIO_OUT, 1);
767 
768         dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0); msleep(10);
769         dib0700_ctrl_clock(adap->dev, 72, 1);
770         dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1); msleep(100);
771 
772         dib0700_set_gpio(adap->dev,  GPIO0, GPIO_OUT, 1);
773 
774         st->mt2060_if1[0] = 1220;
775 
776         if (dib7000pc_detection(&adap->dev->i2c_adap)) {
777                 adap->fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 18, &stk7700p_dib7000p_config);
778                 st->is_dib7000pc = 1;
779         } else
780                 adap->fe = dvb_attach(dib7000m_attach, &adap->dev->i2c_adap, 18, &stk7700p_dib7000m_config);
781 
782         return adap->fe == NULL ? -ENODEV : 0;
783 }
784 
785 static struct mt2060_config stk7700p_mt2060_config = {
786         0x60
787 };
788 
789 static int stk7700p_tuner_attach(struct dvb_usb_adapter *adap)
790 {
791         struct i2c_adapter *prim_i2c = &adap->dev->i2c_adap;
792         struct dib0700_state *st = adap->dev->priv;
793         struct i2c_adapter *tun_i2c;
794         s8 a;
795         int if1=1220;
796         if (adap->dev->udev->descriptor.idVendor  == USB_VID_HAUPPAUGE &&
797                 adap->dev->udev->descriptor.idProduct == USB_PID_HAUPPAUGE_NOVA_T_STICK) {
798                 if (!eeprom_read(prim_i2c,0x58,&a)) if1=1220+a;
799         }
800         if (st->is_dib7000pc)
801                 tun_i2c = dib7000p_get_i2c_master(adap->fe, DIBX000_I2C_INTERFACE_TUNER, 1);
802         else
803                 tun_i2c = dib7000m_get_i2c_master(adap->fe, DIBX000_I2C_INTERFACE_TUNER, 1);
804 
805         return dvb_attach(mt2060_attach, adap->fe, tun_i2c, &stk7700p_mt2060_config,
806                 if1) == NULL ? -ENODEV : 0;
807 }
808 
809 /* DIB7070 generic */
810 static struct dibx000_agc_config dib7070_agc_config = {
811         BAND_UHF | BAND_VHF | BAND_LBAND | BAND_SBAND,
812         /* 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,
813          * 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 */
814         (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0), // setup
815 
816         600, // inv_gain
817         10,  // time_stabiliz
818 
819         0,  // alpha_level
820         118,  // thlock
821 
822         0,     // wbd_inv
823         3530,  // wbd_ref
824         1,     // wbd_sel
825         5,     // wbd_alpha
826 
827         65535,  // agc1_max
828                 0,  // agc1_min
829 
830         65535,  // agc2_max
831         0,      // agc2_min
832 
833         0,      // agc1_pt1
834         40,     // agc1_pt2
835         183,    // agc1_pt3
836         206,    // agc1_slope1
837         255,    // agc1_slope2
838         72,     // agc2_pt1
839         152,    // agc2_pt2
840         88,     // agc2_slope1
841         90,     // agc2_slope2
842 
843         17,  // alpha_mant
844         27,  // alpha_exp
845         23,  // beta_mant
846         51,  // beta_exp
847 
848         0,  // perform_agc_softsplit
849 };
850 
851 static int dib7070_tuner_reset(struct dvb_frontend *fe, int onoff)
852 {
853         return dib7000p_set_gpio(fe, 8, 0, !onoff);
854 }
855 
856 static int dib7070_tuner_sleep(struct dvb_frontend *fe, int onoff)
857 {
858         return dib7000p_set_gpio(fe, 9, 0, onoff);
859 }
860 
861 static struct dib0070_config dib7070p_dib0070_config[2] = {
862         {
863                 .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
864                 .reset = dib7070_tuner_reset,
865                 .sleep = dib7070_tuner_sleep,
866                 .clock_khz = 12000,
867                 .clock_pad_drive = 4
868         }, {
869                 .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
870                 .reset = dib7070_tuner_reset,
871                 .sleep = dib7070_tuner_sleep,
872                 .clock_khz = 12000,
873 
874         }
875 };
876 
877 static int dib7070_set_param_override(struct dvb_frontend *fe, struct dvb_frontend_parameters *fep)
878 {
879         struct dvb_usb_adapter *adap = fe->dvb->priv;
880         struct dib0700_adapter_state *state = adap->priv;
881 
882         u16 offset;
883         u8 band = BAND_OF_FREQUENCY(fep->frequency/1000);
884         switch (band) {
885                 case BAND_VHF: offset = 950; break;
886                 case BAND_UHF:
887                 default: offset = 550; break;
888         }
889         deb_info("WBD for DiB7000P: %d\n", offset + dib0070_wbd_offset(fe));
890         dib7000p_set_wbd_ref(fe, offset + dib0070_wbd_offset(fe));
891         return state->set_param_save(fe, fep);
892 }
893 
894 static int dib7070p_tuner_attach(struct dvb_usb_adapter *adap)
895 {
896         struct dib0700_adapter_state *st = adap->priv;
897         struct i2c_adapter *tun_i2c = dib7000p_get_i2c_master(adap->fe, DIBX000_I2C_INTERFACE_TUNER, 1);
898 
899         if (adap->id == 0) {
900                 if (dvb_attach(dib0070_attach, adap->fe, tun_i2c, &dib7070p_dib0070_config[0]) == NULL)
901                         return -ENODEV;
902         } else {
903                 if (dvb_attach(dib0070_attach, adap->fe, tun_i2c, &dib7070p_dib0070_config[1]) == NULL)
904                         return -ENODEV;
905         }
906 
907         st->set_param_save = adap->fe->ops.tuner_ops.set_params;
908         adap->fe->ops.tuner_ops.set_params = dib7070_set_param_override;
909         return 0;
910 }
911 
912 static struct dibx000_bandwidth_config dib7070_bw_config_12_mhz = {
913         60000, 15000, // internal, sampling
914         1, 20, 3, 1, 0, // pll_cfg: prediv, ratio, range, reset, bypass
915         0, 0, 1, 1, 2, // misc: refdiv, bypclk_div, IO_CLK_en_core, ADClkSrc, modulo
916         (3 << 14) | (1 << 12) | (524 << 0), // sad_cfg: refsel, sel, freq_15k
917         (0 << 25) | 0, // ifreq = 0.000000 MHz
918         20452225, // timf
919         12000000, // xtal_hz
920 };
921 
922 static struct dib7000p_config dib7070p_dib7000p_config = {
923         .output_mpeg2_in_188_bytes = 1,
924 
925         .agc_config_count = 1,
926         .agc = &dib7070_agc_config,
927         .bw  = &dib7070_bw_config_12_mhz,
928         .tuner_is_baseband = 1,
929         .spur_protect = 1,
930 
931         .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
932         .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
933         .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
934 
935         .hostbus_diversity = 1,
936 };
937 
938 /* STK7070P */
939 static int stk7070p_frontend_attach(struct dvb_usb_adapter *adap)
940 {
941         if (adap->dev->udev->descriptor.idVendor  == USB_VID_PINNACLE &&
942         adap->dev->udev->descriptor.idProduct == USB_PID_PINNACLE_PCTV72E)
943         dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
944         else
945         dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
946         msleep(10);
947         dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
948         dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
949         dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
950         dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
951 
952         dib0700_ctrl_clock(adap->dev, 72, 1);
953 
954         msleep(10);
955         dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
956         msleep(10);
957         dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
958 
959         dib7000p_i2c_enumeration(&adap->dev->i2c_adap, 1, 18,
960                 &dib7070p_dib7000p_config);
961 
962         adap->fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 0x80,
963                 &dib7070p_dib7000p_config);
964         return adap->fe == NULL ? -ENODEV : 0;
965 }
966 
967 /* STK7070PD */
968 static struct dib7000p_config stk7070pd_dib7000p_config[2] = {
969         {
970                 .output_mpeg2_in_188_bytes = 1,
971 
972                 .agc_config_count = 1,
973                 .agc = &dib7070_agc_config,
974                 .bw  = &dib7070_bw_config_12_mhz,
975                 .tuner_is_baseband = 1,
976                 .spur_protect = 1,
977 
978                 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
979                 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
980                 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
981 
982                 .hostbus_diversity = 1,
983         }, {
984                 .output_mpeg2_in_188_bytes = 1,
985 
986                 .agc_config_count = 1,
987                 .agc = &dib7070_agc_config,
988                 .bw  = &dib7070_bw_config_12_mhz,
989                 .tuner_is_baseband = 1,
990                 .spur_protect = 1,
991 
992                 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
993                 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
994                 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
995 
996                 .hostbus_diversity = 1,
997         }
998 };
999 
1000 static int stk7070pd_frontend_attach0(struct dvb_usb_adapter *adap)
1001 {
1002         dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
1003         msleep(10);
1004         dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
1005         dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
1006         dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
1007         dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
1008 
1009         dib0700_ctrl_clock(adap->dev, 72, 1);
1010 
1011         msleep(10);
1012         dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
1013         msleep(10);
1014         dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
1015 
1016         dib7000p_i2c_enumeration(&adap->dev->i2c_adap, 2, 18, stk7070pd_dib7000p_config);
1017 
1018         adap->fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 0x80, &stk7070pd_dib7000p_config[0]);
1019         return adap->fe == NULL ? -ENODEV : 0;
1020 }
1021 
1022 static int stk7070pd_frontend_attach1(struct dvb_usb_adapter *adap)
1023 {
1024         adap->fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 0x82, &stk7070pd_dib7000p_config[1]);
1025         return adap->fe == NULL ? -ENODEV : 0;
1026 }
1027 
1028 /* DVB-USB and USB stuff follows */
1029 struct usb_device_id dib0700_usb_id_table[] = {
1030 /* 0 */ { USB_DEVICE(USB_VID_DIBCOM,    USB_PID_DIBCOM_STK7700P) },
1031         { USB_DEVICE(USB_VID_DIBCOM,    USB_PID_DIBCOM_STK7700P_PC) },
1032         { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_500) },
1033         { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_500_2) },
1034         { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_STICK) },
1035 /* 5 */ { USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR) },
1036         { USB_DEVICE(USB_VID_COMPRO,    USB_PID_COMPRO_VIDEOMATE_U500) },
1037         { USB_DEVICE(USB_VID_UNIWILL,   USB_PID_UNIWILL_STK7700P) },
1038         { USB_DEVICE(USB_VID_LEADTEK,   USB_PID_WINFAST_DTV_DONGLE_STK7700P) },
1039         { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_STICK_2) },
1040 /* 10 */{ USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR_2) },
1041         { USB_DEVICE(USB_VID_PINNACLE,  USB_PID_PINNACLE_PCTV2000E) },
1042         { USB_DEVICE(USB_VID_TERRATEC,
1043                         USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY) },
1044         { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_TD_STICK) },
1045         { USB_DEVICE(USB_VID_DIBCOM,    USB_PID_DIBCOM_STK7700D) },
1046 /* 15 */{ USB_DEVICE(USB_VID_DIBCOM,    USB_PID_DIBCOM_STK7070P) },
1047         { USB_DEVICE(USB_VID_PINNACLE,  USB_PID_PINNACLE_PCTV_DVB_T_FLASH) },
1048         { USB_DEVICE(USB_VID_DIBCOM,    USB_PID_DIBCOM_STK7070PD) },
1049         { USB_DEVICE(USB_VID_PINNACLE,
1050                         USB_PID_PINNACLE_PCTV_DUAL_DIVERSITY_DVB_T) },
1051         { USB_DEVICE(USB_VID_COMPRO,    USB_PID_COMPRO_VIDEOMATE_U500_PC) },
1052 /* 20 */{ USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_EXPRESS) },
1053         { USB_DEVICE(USB_VID_GIGABYTE,  USB_PID_GIGABYTE_U7000) },
1054         { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC, USB_PID_ARTEC_T14BR) },
1055         { USB_DEVICE(USB_VID_ASUS,      USB_PID_ASUS_U3000) },
1056         { USB_DEVICE(USB_VID_ASUS,      USB_PID_ASUS_U3100) },
1057 /* 25 */{ USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_STICK_3) },
1058         { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_MYTV_T) },
1059         { USB_DEVICE(USB_VID_TERRATEC,  USB_PID_TERRATEC_CINERGY_HT_USB_XE) },
1060         { USB_DEVICE(USB_VID_PINNACLE,  USB_PID_PINNACLE_EXPRESSCARD_320CX) },
1061         { USB_DEVICE(USB_VID_PINNACLE,  USB_PID_PINNACLE_PCTV72E) },
1062 /* 30 */{ USB_DEVICE(USB_VID_PINNACLE,  USB_PID_PINNACLE_PCTV73E) },
1063         { USB_DEVICE(USB_VID_YUAN,      USB_PID_YUAN_EC372S) },
1064         { USB_DEVICE(USB_VID_TERRATEC,  USB_PID_TERRATEC_CINERGY_HT_EXPRESS) },
1065         { 0 }           /* Terminating entry */
1066 };
1067 MODULE_DEVICE_TABLE(usb, dib0700_usb_id_table);
1068 
1069 #define DIB0700_DEFAULT_DEVICE_PROPERTIES \
1070         .caps              = DVB_USB_IS_AN_I2C_ADAPTER, \
1071         .usb_ctrl          = DEVICE_SPECIFIC, \
1072         .firmware          = "dvb-usb-dib0700-1.10.fw", \
1073         .download_firmware = dib0700_download_firmware, \
1074         .no_reconnect      = 1, \
1075         .size_of_priv      = sizeof(struct dib0700_state), \
1076         .i2c_algo          = &dib0700_i2c_algo, \
1077         .identify_state    = dib0700_identify_state
1078 
1079 #define DIB0700_DEFAULT_STREAMING_CONFIG(ep) \
1080         .streaming_ctrl   = dib0700_streaming_ctrl, \
1081         .stream = { \
1082                 .type = USB_BULK, \
1083                 .count = 4, \
1084                 .endpoint = ep, \
1085                 .u = { \
1086                         .bulk = { \
1087                                 .buffersize = 39480, \
1088                         } \
1089                 } \
1090         }
1091 
1092 struct dvb_usb_device_properties dib0700_devices[] = {
1093         {
1094                 DIB0700_DEFAULT_DEVICE_PROPERTIES,
1095 
1096                 .num_adapters = 1,
1097                 .adapter = {
1098                         {
1099                                 .frontend_attach  = stk7700p_frontend_attach,
1100                                 .tuner_attach     = stk7700p_tuner_attach,
1101 
1102                                 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
1103                         },
1104                 },
1105 
1106                 .num_device_descs = 8,
1107                 .devices = {
1108                         {   "DiBcom STK7700P reference design",
1109                                 { &dib0700_usb_id_table[0], &dib0700_usb_id_table[1] },
1110                                 { NULL },
1111                         },
1112                         {   "Hauppauge Nova-T Stick",
1113                                 { &dib0700_usb_id_table[4], &dib0700_usb_id_table[9], NULL },
1114                                 { NULL },
1115                         },
1116                         {   "AVerMedia AVerTV DVB-T Volar",
1117                                 { &dib0700_usb_id_table[5], &dib0700_usb_id_table[10] },
1118                                 { NULL },
1119                         },
1120                         {   "Compro Videomate U500",
1121                                 { &dib0700_usb_id_table[6], &dib0700_usb_id_table[19] },
1122                                 { NULL },
1123                         },
1124                         {   "Uniwill STK7700P based (Hama and others)",
1125                                 { &dib0700_usb_id_table[7], NULL },
1126                                 { NULL },
1127                         },
1128                         {   "Leadtek Winfast DTV Dongle (STK7700P based)",
1129                                 { &dib0700_usb_id_table[8], NULL },
1130                                 { NULL },
1131                         },
1132                         {   "AVerMedia AVerTV DVB-T Express",
1133                                 { &dib0700_usb_id_table[20] },
1134                                 { NULL },
1135                         },
1136                         {   "Gigabyte U7000",
1137                                 { &dib0700_usb_id_table[21], NULL },
1138                                 { NULL },
1139                         }
1140                 },
1141 
1142                 .rc_interval      = DEFAULT_RC_INTERVAL,
1143                 .rc_key_map       = dib0700_rc_keys,
1144                 .rc_key_map_size  = ARRAY_SIZE(dib0700_rc_keys),
1145                 .rc_query         = dib0700_rc_query
1146         }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
1147 
1148                 .num_adapters = 2,
1149                 .adapter = {
1150                         {
1151                                 .frontend_attach  = bristol_frontend_attach,
1152                                 .tuner_attach     = bristol_tuner_attach,
1153 
1154                                 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
1155                         }, {
1156                                 .frontend_attach  = bristol_frontend_attach,
1157                                 .tuner_attach     = bristol_tuner_attach,
1158 
1159                                 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
1160                         }
1161                 },
1162 
1163                 .num_device_descs = 1,
1164                 .devices = {
1165                         {   "Hauppauge Nova-T 500 Dual DVB-T",
1166                                 { &dib0700_usb_id_table[2], &dib0700_usb_id_table[3], NULL },
1167                                 { NULL },
1168                         },
1169                 },
1170 
1171                 .rc_interval      = DEFAULT_RC_INTERVAL,
1172                 .rc_key_map       = dib0700_rc_keys,
1173                 .rc_key_map_size  = ARRAY_SIZE(dib0700_rc_keys),
1174                 .rc_query         = dib0700_rc_query
1175         }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
1176 
1177                 .num_adapters = 2,
1178                 .adapter = {
1179                         {
1180                                 .frontend_attach  = stk7700d_frontend_attach,
1181                                 .tuner_attach     = stk7700d_tuner_attach,
1182 
1183                                 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
1184                         }, {
1185                                 .frontend_attach  = stk7700d_frontend_attach,
1186                                 .tuner_attach     = stk7700d_tuner_attach,
1187 
1188                                 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
1189                         }
1190                 },
1191 
1192                 .num_device_descs = 4,
1193                 .devices = {
1194                         {   "Pinnacle PCTV 2000e",
1195                                 { &dib0700_usb_id_table[11], NULL },
1196                                 { NULL },
1197                         },
1198                         {   "Terratec Cinergy DT XS Diversity",
1199                                 { &dib0700_usb_id_table[12], NULL },
1200                                 { NULL },
1201                         },
1202                         {   "Hauppauge Nova-TD Stick/Elgato Eye-TV Diversity",
1203                                 { &dib0700_usb_id_table[13], NULL },
1204                                 { NULL },
1205                         },
1206                         {   "DiBcom STK7700D reference design",
1207                                 { &dib0700_usb_id_table[14], NULL },
1208                                 { NULL },
1209                         }
1210                 },
1211 
1212                 .rc_interval      = DEFAULT_RC_INTERVAL,
1213                 .rc_key_map       = dib0700_rc_keys,
1214                 .rc_key_map_size  = ARRAY_SIZE(dib0700_rc_keys),
1215                 .rc_query         = dib0700_rc_query
1216 
1217         }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
1218 
1219                 .num_adapters = 1,
1220                 .adapter = {
1221                         {
1222                                 .frontend_attach  = stk7700P2_frontend_attach,
1223                                 .tuner_attach     = stk7700d_tuner_attach,
1224 
1225                                 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
1226                         },
1227                 },
1228 
1229                 .num_device_descs = 2,
1230                 .devices = {
1231                         {   "ASUS My Cinema U3000 Mini DVBT Tuner",
1232                                 { &dib0700_usb_id_table[23], NULL },
1233                                 { NULL },
1234                         },
1235                         {   "Yuan EC372S",
1236                                 { &dib0700_usb_id_table[31], NULL },
1237                                 { NULL },
1238                         }
1239                 }
1240         }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
1241 
1242                 .num_adapters = 1,
1243                 .adapter = {
1244                         {
1245                                 .frontend_attach  = stk7070p_frontend_attach,
1246                                 .tuner_attach     = dib7070p_tuner_attach,
1247 
1248                                 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
1249 
1250                                 .size_of_priv     = sizeof(struct dib0700_adapter_state),
1251                         },
1252                 },
1253 
1254                 .num_device_descs = 8,
1255                 .devices = {
1256                         {   "DiBcom STK7070P reference design",
1257                                 { &dib0700_usb_id_table[15], NULL },
1258                                 { NULL },
1259                         },
1260                         {   "Pinnacle PCTV DVB-T Flash Stick",
1261                                 { &dib0700_usb_id_table[16], NULL },
1262                                 { NULL },
1263                         },
1264                         {   "Artec T14BR DVB-T",
1265                                 { &dib0700_usb_id_table[22], NULL },
1266                                 { NULL },
1267                         },
1268                         {   "ASUS My Cinema U3100 Mini DVBT Tuner",
1269                                 { &dib0700_usb_id_table[24], NULL },
1270                                 { NULL },
1271                         },
1272                         {   "Hauppauge Nova-T Stick",
1273                                 { &dib0700_usb_id_table[25], NULL },
1274                                 { NULL },
1275                         },
1276                         {   "Hauppauge Nova-T MyTV.t",
1277                                 { &dib0700_usb_id_table[26], NULL },
1278                                 { NULL },
1279                         },
1280                         {   "Pinnacle PCTV 72e",
1281                                 { &dib0700_usb_id_table[29], NULL },
1282                                 { NULL },
1283                         },
1284                         {   "Pinnacle PCTV 73e",
1285                                 { &dib0700_usb_id_table[30], NULL },
1286                                 { NULL },
1287                         },
1288                 },
1289 
1290                 .rc_interval      = DEFAULT_RC_INTERVAL,
1291                 .rc_key_map       = dib0700_rc_keys,
1292                 .rc_key_map_size  = ARRAY_SIZE(dib0700_rc_keys),
1293                 .rc_query         = dib0700_rc_query
1294 
1295         }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
1296 
1297                 .num_adapters = 2,
1298                 .adapter = {
1299                         {
1300                                 .frontend_attach  = stk7070pd_frontend_attach0,
1301                                 .tuner_attach     = dib7070p_tuner_attach,
1302 
1303                                 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
1304 
1305                                 .size_of_priv     = sizeof(struct dib0700_adapter_state),
1306                         }, {
1307                                 .frontend_attach  = stk7070pd_frontend_attach1,
1308                                 .tuner_attach     = dib7070p_tuner_attach,
1309 
1310                                 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
1311 
1312                                 .size_of_priv     = sizeof(struct dib0700_adapter_state),
1313                         }
1314                 },
1315 
1316                 .num_device_descs = 2,
1317                 .devices = {
1318                         {   "DiBcom STK7070PD reference design",
1319                                 { &dib0700_usb_id_table[17], NULL },
1320                                 { NULL },
1321                         },
1322                         {   "Pinnacle PCTV Dual DVB-T Diversity Stick",
1323                                 { &dib0700_usb_id_table[18], NULL },
1324                                 { NULL },
1325                         }
1326                 }
1327         }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
1328 
1329                 .num_adapters = 1,
1330                 .adapter = {
1331                         {
1332                                 .frontend_attach  = stk7700ph_frontend_attach,
1333                                 .tuner_attach     = stk7700ph_tuner_attach,
1334 
1335                                 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
1336 
1337                                 .size_of_priv = sizeof(struct
1338                                                 dib0700_adapter_state),
1339                         },
1340                 },
1341 
1342                 .num_device_descs = 3,
1343                 .devices = {
1344                         {   "Terratec Cinergy HT USB XE",
1345                                 { &dib0700_usb_id_table[27], NULL },
1346                                 { NULL },
1347                         },
1348                         {   "Pinnacle Expresscard 320cx",
1349                                 { &dib0700_usb_id_table[28], NULL },
1350                                 { NULL },
1351                         },
1352                         {   "Terratec Cinergy HT Express",
1353                                 { &dib0700_usb_id_table[32], NULL },
1354                                 { NULL },
1355                         },
1356                 },
1357                 .rc_interval      = DEFAULT_RC_INTERVAL,
1358                 .rc_key_map       = dib0700_rc_keys,
1359                 .rc_key_map_size  = ARRAY_SIZE(dib0700_rc_keys),
1360                 .rc_query         = dib0700_rc_query
1361         },
1362 };
1363 
1364 int dib0700_device_count = ARRAY_SIZE(dib0700_devices);
1365 
  This page was automatically generated by the LXR engine.