Merge git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6
[linux-2.6-block.git] / drivers / media / dvb / dvb-usb / dib0700_devices.c
CommitLineData
b7f54910
PB
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 *
b6884a17 7 * Copyright (C) 2005-7 DiBcom, SA
b7f54910
PB
8 */
9#include "dib0700.h"
10
11#include "dib3000mc.h"
91bb9be6 12#include "dib7000m.h"
a75763ff 13#include "dib7000p.h"
b7f54910 14#include "mt2060.h"
54d75eba 15#include "mt2266.h"
6ca8f0b9 16#include "tuner-xc2028.h"
cb22cb52
DH
17#include "xc5000.h"
18#include "s5h1411.h"
01373a5c 19#include "dib0070.h"
b7f54910 20
7fb3fc0c
PB
21static int force_lna_activation;
22module_param(force_lna_activation, int, 0644);
23MODULE_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
01373a5c
PB
26struct dib0700_adapter_state {
27 int (*set_param_save) (struct dvb_frontend *, struct dvb_frontend_parameters *);
28};
29
30/* Hauppauge Nova-T 500 (aka Bristol)
b7f54910
PB
31 * has a LNA on GPIO0 which is enabled by setting 1 */
32static struct mt2060_config bristol_mt2060_config[2] = {
33 {
34 .i2c_address = 0x60,
303cbeaa 35 .clock_out = 3,
b7f54910
PB
36 }, {
37 .i2c_address = 0x61,
38 }
39};
40
41static struct dibx000_agc_config bristol_dib3000p_mt2060_agc_config = {
42 .band_caps = BAND_VHF | BAND_UHF,
01b4bf31 43 .setup = (1 << 8) | (5 << 5) | (0 << 4) | (0 << 3) | (0 << 2) | (2 << 0),
b7f54910 44
6958effe
PB
45 .agc1_max = 42598,
46 .agc1_min = 17694,
47 .agc2_max = 45875,
48 .agc2_min = 0,
b7f54910 49
6958effe
PB
50 .agc1_pt1 = 0,
51 .agc1_pt2 = 59,
b7f54910 52
6958effe
PB
53 .agc1_slope1 = 0,
54 .agc1_slope2 = 69,
b7f54910
PB
55
56 .agc2_pt1 = 0,
6958effe 57 .agc2_pt2 = 59,
b7f54910 58
6958effe
PB
59 .agc2_slope1 = 111,
60 .agc2_slope2 = 28,
b7f54910
PB
61};
62
63static 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
76static int bristol_frontend_attach(struct dvb_usb_adapter *adap)
77{
6958effe 78 struct dib0700_state *st = adap->dev->priv;
b7f54910
PB
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
7fb3fc0c
PB
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);
6958effe 89
b7f54910
PB
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 }
6958effe
PB
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;
b7f54910
PB
98}
99
4a2b1083 100static int eeprom_read(struct i2c_adapter *adap,u8 adrs,u8 *pval)
c52344fd
OD
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
b7f54910
PB
110static int bristol_tuner_attach(struct dvb_usb_adapter *adap)
111{
c52344fd 112 struct i2c_adapter *prim_i2c = &adap->dev->i2c_adap;
b7f54910 113 struct i2c_adapter *tun_i2c = dib3000mc_get_tuner_i2c_master(adap->fe, 1);
c52344fd
OD
114 s8 a;
115 int if1=1220;
da5ee486
AV
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)) {
c52344fd
OD
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;
b7f54910
PB
122}
123
01373a5c 124/* STK7700D: Pinnacle/Terratec/Hauppauge Dual DVB-T Diversity */
54d75eba 125
b6884a17
PB
126/* MT226x */
127static 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 }
54d75eba
OD
207};
208
209static 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
218static struct dib7000p_config stk7700d_dib7000p_mt2266_config[] = {
219 { .output_mpeg2_in_188_bytes = 1,
220 .hostbus_diversity = 1,
221 .tuner_is_baseband = 1,
222
b6884a17
PB
223 .agc_config_count = 2,
224 .agc = stk7700d_7000p_mt2266_agc_config,
54d75eba
OD
225 .bw = &stk7700d_mt2266_pll_config,
226
b6884a17
PB
227 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
228 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
229 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
54d75eba
OD
230 },
231 { .output_mpeg2_in_188_bytes = 1,
232 .hostbus_diversity = 1,
233 .tuner_is_baseband = 1,
234
b6884a17
PB
235 .agc_config_count = 2,
236 .agc = stk7700d_7000p_mt2266_agc_config,
54d75eba
OD
237 .bw = &stk7700d_mt2266_pll_config,
238
b6884a17
PB
239 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
240 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
241 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
54d75eba
OD
242 }
243};
244
245static struct mt2266_config stk7700d_mt2266_config[2] = {
246 { .i2c_address = 0x60
247 },
248 { .i2c_address = 0x60
249 }
250};
251
132c3188
DG
252static 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
54d75eba
OD
273static 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
295static 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
6ca8f0b9 303/* STK7700-PH: Digital/Analog Hybrid Tuner, e.h. Cinergy HT USB HE */
b1721d0d 304static struct dibx000_agc_config xc3028_agc_config = {
6ca8f0b9
AC
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 */
b1721d0d 347static struct dibx000_bandwidth_config xc3028_bw_config = {
6ca8f0b9
AC
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
358static 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
d7cba043
MK
371static int stk7700ph_xc3028_callback(void *ptr, int component,
372 int command, int arg)
6ca8f0b9
AC
373{
374 struct dvb_usb_adapter *adap = ptr;
375
376 switch (command) {
377 case XC2028_TUNER_RESET:
378 /* Send the tuner in then out of reset */
379 dib7000p_set_gpio(adap->fe, 8, 0, 0); msleep(10);
380 dib7000p_set_gpio(adap->fe, 8, 0, 1);
381 break;
382 case XC2028_RESET_CLK:
383 break;
384 default:
385 err("%s: unknown command %d, arg %d\n", __func__,
386 command, arg);
387 return -EINVAL;
388 }
389 return 0;
390}
391
392static struct xc2028_ctrl stk7700ph_xc3028_ctrl = {
393 .fname = XC2028_DEFAULT_FIRMWARE,
394 .max_len = 64,
395 .demod = XC3028_FE_DIBCOM52,
396};
397
398static struct xc2028_config stk7700ph_xc3028_config = {
399 .i2c_addr = 0x61,
6ca8f0b9
AC
400 .ctrl = &stk7700ph_xc3028_ctrl,
401};
402
403static int stk7700ph_frontend_attach(struct dvb_usb_adapter *adap)
404{
405 struct usb_device_descriptor *desc = &adap->dev->udev->descriptor;
406
da5ee486
AV
407 if (desc->idVendor == cpu_to_le16(USB_VID_PINNACLE) &&
408 desc->idProduct == cpu_to_le16(USB_PID_PINNACLE_EXPRESSCARD_320CX))
6ca8f0b9
AC
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
432static 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;
d7cba043
MK
440
441 /* FIXME: generalize & move to common area */
442 adap->fe->callback = stk7700ph_xc3028_callback;
6ca8f0b9
AC
443
444 return dvb_attach(xc2028_attach, adap->fe, &stk7700ph_xc3028_config)
445 == NULL ? -ENODEV : 0;
446}
447
54d75eba
OD
448#define DEFAULT_RC_INTERVAL 150
449
450static u8 rc_request[] = { REQUEST_POLL_RC, 0 };
451
58e6f95e
PB
452/* Number of keypresses to ignore before start repeating */
453#define RC_REPEAT_DELAY 2
454
82f3d559 455static int dib0700_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
54d75eba
OD
456{
457 u8 key[4];
458 int i;
459 struct dvb_usb_rc_key *keymap = d->props.rc_key_map;
460 struct dib0700_state *st = d->priv;
461 *event = 0;
462 *state = REMOTE_NO_KEY_PRESSED;
463 i=dib0700_ctrl_rd(d,rc_request,2,key,4);
464 if (i<=0) {
034d65ed 465 err("RC Query Failed");
89f4267d 466 return -1;
54d75eba 467 }
58e6f95e
PB
468
469 /* losing half of KEY_0 events from Philipps rc5 remotes.. */
54d75eba 470 if (key[0]==0 && key[1]==0 && key[2]==0 && key[3]==0) return 0;
58e6f95e
PB
471
472 /* 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]); */
473
474 dib0700_rc_setup(d); /* reset ir sensor data to prevent false events */
475
476 switch (dvb_usb_dib0700_ir_proto) {
477 case 0: {
478 /* NEC protocol sends repeat code as 0 0 0 FF */
479 if ((key[3-2] == 0x00) && (key[3-3] == 0x00) &&
480 (key[3] == 0xFF)) {
481 st->rc_counter++;
482 if (st->rc_counter > RC_REPEAT_DELAY) {
483 *event = d->last_event;
484 *state = REMOTE_KEY_PRESSED;
485 st->rc_counter = RC_REPEAT_DELAY;
486 }
487 return 0;
488 }
54d75eba 489 for (i=0;i<d->props.rc_key_map_size; i++) {
89f4267d 490 if (keymap[i].custom == key[3-2] && keymap[i].data == key[3-3]) {
58e6f95e
PB
491 st->rc_counter = 0;
492 *event = keymap[i].event;
493 *state = REMOTE_KEY_PRESSED;
494 d->last_event = keymap[i].event;
495 return 0;
496 }
497 }
498 break;
499 }
500 default: {
501 /* RC-5 protocol changes toggle bit on new keypress */
502 for (i = 0; i < d->props.rc_key_map_size; i++) {
503 if (keymap[i].custom == key[3-2] && keymap[i].data == key[3-3]) {
504 if (d->last_event == keymap[i].event &&
505 key[3-1] == st->rc_toggle) {
506 st->rc_counter++;
507 /* prevents unwanted double hits */
508 if (st->rc_counter > RC_REPEAT_DELAY) {
509 *event = d->last_event;
510 *state = REMOTE_KEY_PRESSED;
511 st->rc_counter = RC_REPEAT_DELAY;
512 }
513
514 return 0;
515 }
516 st->rc_counter = 0;
54d75eba
OD
517 *event = keymap[i].event;
518 *state = REMOTE_KEY_PRESSED;
58e6f95e
PB
519 st->rc_toggle = key[3-1];
520 d->last_event = keymap[i].event;
54d75eba
OD
521 return 0;
522 }
523 }
58e6f95e
PB
524 break;
525 }
54d75eba 526 }
58e6f95e
PB
527 err("Unknown remote controller key: %2X %2X %2X %2X", (int) key[3-2], (int) key[3-3], (int) key[3-1], (int) key[3]);
528 d->last_event = 0;
54d75eba
OD
529 return 0;
530}
531
82f3d559 532static struct dvb_usb_rc_key dib0700_rc_keys[] = {
54d75eba
OD
533 /* Key codes for the tiny Pinnacle remote*/
534 { 0x07, 0x00, KEY_MUTE },
535 { 0x07, 0x01, KEY_MENU }, // Pinnacle logo
536 { 0x07, 0x39, KEY_POWER },
537 { 0x07, 0x03, KEY_VOLUMEUP },
538 { 0x07, 0x09, KEY_VOLUMEDOWN },
539 { 0x07, 0x06, KEY_CHANNELUP },
540 { 0x07, 0x0c, KEY_CHANNELDOWN },
541 { 0x07, 0x0f, KEY_1 },
542 { 0x07, 0x15, KEY_2 },
543 { 0x07, 0x10, KEY_3 },
544 { 0x07, 0x18, KEY_4 },
545 { 0x07, 0x1b, KEY_5 },
546 { 0x07, 0x1e, KEY_6 },
547 { 0x07, 0x11, KEY_7 },
548 { 0x07, 0x21, KEY_8 },
549 { 0x07, 0x12, KEY_9 },
550 { 0x07, 0x27, KEY_0 },
551 { 0x07, 0x24, KEY_SCREEN }, // 'Square' key
552 { 0x07, 0x2a, KEY_TEXT }, // 'T' key
553 { 0x07, 0x2d, KEY_REWIND },
554 { 0x07, 0x30, KEY_PLAY },
555 { 0x07, 0x33, KEY_FASTFORWARD },
556 { 0x07, 0x36, KEY_RECORD },
557 { 0x07, 0x3c, KEY_STOP },
558 { 0x07, 0x3f, KEY_CANCEL }, // '?' key
559 /* Key codes for the Terratec Cinergy DT XS Diversity, similar to cinergyT2.c */
560 { 0xeb, 0x01, KEY_POWER },
561 { 0xeb, 0x02, KEY_1 },
562 { 0xeb, 0x03, KEY_2 },
563 { 0xeb, 0x04, KEY_3 },
564 { 0xeb, 0x05, KEY_4 },
565 { 0xeb, 0x06, KEY_5 },
566 { 0xeb, 0x07, KEY_6 },
567 { 0xeb, 0x08, KEY_7 },
568 { 0xeb, 0x09, KEY_8 },
569 { 0xeb, 0x0a, KEY_9 },
570 { 0xeb, 0x0b, KEY_VIDEO },
571 { 0xeb, 0x0c, KEY_0 },
572 { 0xeb, 0x0d, KEY_REFRESH },
573 { 0xeb, 0x0f, KEY_EPG },
574 { 0xeb, 0x10, KEY_UP },
575 { 0xeb, 0x11, KEY_LEFT },
576 { 0xeb, 0x12, KEY_OK },
577 { 0xeb, 0x13, KEY_RIGHT },
578 { 0xeb, 0x14, KEY_DOWN },
579 { 0xeb, 0x16, KEY_INFO },
580 { 0xeb, 0x17, KEY_RED },
581 { 0xeb, 0x18, KEY_GREEN },
582 { 0xeb, 0x19, KEY_YELLOW },
583 { 0xeb, 0x1a, KEY_BLUE },
584 { 0xeb, 0x1b, KEY_CHANNELUP },
585 { 0xeb, 0x1c, KEY_VOLUMEUP },
7161f27f 586 { 0xeb, 0x1d, KEY_MUTE },
54d75eba
OD
587 { 0xeb, 0x1e, KEY_VOLUMEDOWN },
588 { 0xeb, 0x1f, KEY_CHANNELDOWN },
589 { 0xeb, 0x40, KEY_PAUSE },
590 { 0xeb, 0x41, KEY_HOME },
591 { 0xeb, 0x42, KEY_MENU }, /* DVD Menu */
592 { 0xeb, 0x43, KEY_SUBTITLE },
593 { 0xeb, 0x44, KEY_TEXT }, /* Teletext */
594 { 0xeb, 0x45, KEY_DELETE },
595 { 0xeb, 0x46, KEY_TV },
596 { 0xeb, 0x47, KEY_DVD },
597 { 0xeb, 0x48, KEY_STOP },
598 { 0xeb, 0x49, KEY_VIDEO },
599 { 0xeb, 0x4a, KEY_AUDIO }, /* Music */
600 { 0xeb, 0x4b, KEY_SCREEN }, /* Pic */
601 { 0xeb, 0x4c, KEY_PLAY },
602 { 0xeb, 0x4d, KEY_BACK },
603 { 0xeb, 0x4e, KEY_REWIND },
604 { 0xeb, 0x4f, KEY_FASTFORWARD },
605 { 0xeb, 0x54, KEY_PREVIOUS },
606 { 0xeb, 0x58, KEY_RECORD },
7161f27f
JG
607 { 0xeb, 0x5c, KEY_NEXT },
608
609 /* Key codes for the Haupauge WinTV Nova-TD, copied from nova-t-usb2.c (Nova-T USB2) */
610 { 0x1e, 0x00, KEY_0 },
611 { 0x1e, 0x01, KEY_1 },
612 { 0x1e, 0x02, KEY_2 },
613 { 0x1e, 0x03, KEY_3 },
614 { 0x1e, 0x04, KEY_4 },
615 { 0x1e, 0x05, KEY_5 },
616 { 0x1e, 0x06, KEY_6 },
617 { 0x1e, 0x07, KEY_7 },
618 { 0x1e, 0x08, KEY_8 },
619 { 0x1e, 0x09, KEY_9 },
620 { 0x1e, 0x0a, KEY_KPASTERISK },
621 { 0x1e, 0x0b, KEY_RED },
622 { 0x1e, 0x0c, KEY_RADIO },
623 { 0x1e, 0x0d, KEY_MENU },
624 { 0x1e, 0x0e, KEY_GRAVE }, /* # */
625 { 0x1e, 0x0f, KEY_MUTE },
626 { 0x1e, 0x10, KEY_VOLUMEUP },
627 { 0x1e, 0x11, KEY_VOLUMEDOWN },
628 { 0x1e, 0x12, KEY_CHANNEL },
629 { 0x1e, 0x14, KEY_UP },
630 { 0x1e, 0x15, KEY_DOWN },
631 { 0x1e, 0x16, KEY_LEFT },
632 { 0x1e, 0x17, KEY_RIGHT },
633 { 0x1e, 0x18, KEY_VIDEO },
634 { 0x1e, 0x19, KEY_AUDIO },
635 { 0x1e, 0x1a, KEY_MEDIA },
636 { 0x1e, 0x1b, KEY_EPG },
637 { 0x1e, 0x1c, KEY_TV },
638 { 0x1e, 0x1e, KEY_NEXT },
639 { 0x1e, 0x1f, KEY_BACK },
640 { 0x1e, 0x20, KEY_CHANNELUP },
641 { 0x1e, 0x21, KEY_CHANNELDOWN },
642 { 0x1e, 0x24, KEY_LAST }, /* Skip backwards */
643 { 0x1e, 0x25, KEY_OK },
644 { 0x1e, 0x29, KEY_BLUE},
645 { 0x1e, 0x2e, KEY_GREEN },
646 { 0x1e, 0x30, KEY_PAUSE },
647 { 0x1e, 0x32, KEY_REWIND },
648 { 0x1e, 0x34, KEY_FASTFORWARD },
649 { 0x1e, 0x35, KEY_PLAY },
650 { 0x1e, 0x36, KEY_STOP },
651 { 0x1e, 0x37, KEY_RECORD },
652 { 0x1e, 0x38, KEY_YELLOW },
653 { 0x1e, 0x3b, KEY_GOTO },
654 { 0x1e, 0x3d, KEY_POWER },
48e6a017
JB
655
656 /* Key codes for the Leadtek Winfast DTV Dongle */
657 { 0x00, 0x42, KEY_POWER },
658 { 0x07, 0x7c, KEY_TUNER },
659 { 0x0f, 0x4e, KEY_PRINT }, /* PREVIEW */
660 { 0x08, 0x40, KEY_SCREEN }, /* full screen toggle*/
661 { 0x0f, 0x71, KEY_DOT }, /* frequency */
662 { 0x07, 0x43, KEY_0 },
663 { 0x0c, 0x41, KEY_1 },
664 { 0x04, 0x43, KEY_2 },
665 { 0x0b, 0x7f, KEY_3 },
666 { 0x0e, 0x41, KEY_4 },
667 { 0x06, 0x43, KEY_5 },
668 { 0x09, 0x7f, KEY_6 },
669 { 0x0d, 0x7e, KEY_7 },
670 { 0x05, 0x7c, KEY_8 },
671 { 0x0a, 0x40, KEY_9 },
672 { 0x0e, 0x4e, KEY_CLEAR },
673 { 0x04, 0x7c, KEY_CHANNEL }, /* show channel number */
674 { 0x0f, 0x41, KEY_LAST }, /* recall */
675 { 0x03, 0x42, KEY_MUTE },
676 { 0x06, 0x4c, KEY_RESERVED }, /* PIP button*/
677 { 0x01, 0x72, KEY_SHUFFLE }, /* SNAPSHOT */
678 { 0x0c, 0x4e, KEY_PLAYPAUSE }, /* TIMESHIFT */
679 { 0x0b, 0x70, KEY_RECORD },
680 { 0x03, 0x7d, KEY_VOLUMEUP },
681 { 0x01, 0x7d, KEY_VOLUMEDOWN },
682 { 0x02, 0x42, KEY_CHANNELUP },
683 { 0x00, 0x7d, KEY_CHANNELDOWN },
48aa7391
CR
684
685 /* Key codes for Nova-TD "credit card" remote control. */
686 { 0x1d, 0x00, KEY_0 },
687 { 0x1d, 0x01, KEY_1 },
688 { 0x1d, 0x02, KEY_2 },
689 { 0x1d, 0x03, KEY_3 },
690 { 0x1d, 0x04, KEY_4 },
691 { 0x1d, 0x05, KEY_5 },
692 { 0x1d, 0x06, KEY_6 },
693 { 0x1d, 0x07, KEY_7 },
694 { 0x1d, 0x08, KEY_8 },
695 { 0x1d, 0x09, KEY_9 },
696 { 0x1d, 0x0a, KEY_TEXT },
697 { 0x1d, 0x0d, KEY_MENU },
698 { 0x1d, 0x0f, KEY_MUTE },
699 { 0x1d, 0x10, KEY_VOLUMEUP },
700 { 0x1d, 0x11, KEY_VOLUMEDOWN },
701 { 0x1d, 0x12, KEY_CHANNEL },
702 { 0x1d, 0x14, KEY_UP },
703 { 0x1d, 0x15, KEY_DOWN },
704 { 0x1d, 0x16, KEY_LEFT },
705 { 0x1d, 0x17, KEY_RIGHT },
706 { 0x1d, 0x1c, KEY_TV },
707 { 0x1d, 0x1e, KEY_NEXT },
708 { 0x1d, 0x1f, KEY_BACK },
709 { 0x1d, 0x20, KEY_CHANNELUP },
710 { 0x1d, 0x21, KEY_CHANNELDOWN },
711 { 0x1d, 0x24, KEY_LAST },
712 { 0x1d, 0x25, KEY_OK },
713 { 0x1d, 0x30, KEY_PAUSE },
714 { 0x1d, 0x32, KEY_REWIND },
715 { 0x1d, 0x34, KEY_FASTFORWARD },
716 { 0x1d, 0x35, KEY_PLAY },
717 { 0x1d, 0x36, KEY_STOP },
718 { 0x1d, 0x37, KEY_RECORD },
719 { 0x1d, 0x3b, KEY_GOTO },
720 { 0x1d, 0x3d, KEY_POWER },
82f3d559 721};
54d75eba 722
b7f54910 723/* STK7700P: Hauppauge Nova-T Stick, AVerMedia Volar */
a75763ff 724static struct dibx000_agc_config stk7700p_7000m_mt2060_agc_config = {
69ea31e7
PB
725 BAND_UHF | BAND_VHF, // band_caps
726
727 /* 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,
728 * 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 */
729 (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8) | (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0), // setup
730
731 712, // inv_gain
732 41, // time_stabiliz
733
734 0, // alpha_level
735 118, // thlock
736
737 0, // wbd_inv
738 4095, // wbd_ref
739 0, // wbd_sel
740 0, // wbd_alpha
741
742 42598, // agc1_max
743 17694, // agc1_min
744 45875, // agc2_max
745 2621, // agc2_min
746 0, // agc1_pt1
747 76, // agc1_pt2
748 139, // agc1_pt3
749 52, // agc1_slope1
750 59, // agc1_slope2
751 107, // agc2_pt1
752 172, // agc2_pt2
753 57, // agc2_slope1
754 70, // agc2_slope2
755
756 21, // alpha_mant
757 25, // alpha_exp
758 28, // beta_mant
759 48, // beta_exp
760
761 1, // perform_agc_softsplit
762 { 0, // split_min
763 107, // split_max
764 51800, // global_split_min
765 24700 // global_split_max
766 },
767};
768
a75763ff
PB
769static struct dibx000_agc_config stk7700p_7000p_mt2060_agc_config = {
770 BAND_UHF | BAND_VHF,
771
772 /* 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,
773 * 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 */
774 (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8) | (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0), // setup
775
776 712, // inv_gain
777 41, // time_stabiliz
778
779 0, // alpha_level
780 118, // thlock
781
782 0, // wbd_inv
783 4095, // wbd_ref
784 0, // wbd_sel
785 0, // wbd_alpha
786
787 42598, // agc1_max
788 16384, // agc1_min
789 42598, // agc2_max
790 0, // agc2_min
791
792 0, // agc1_pt1
793 137, // agc1_pt2
794 255, // agc1_pt3
795
796 0, // agc1_slope1
797 255, // agc1_slope2
798
799 0, // agc2_pt1
800 0, // agc2_pt2
801
802 0, // agc2_slope1
803 41, // agc2_slope2
804
805 15, // alpha_mant
806 25, // alpha_exp
807
808 28, // beta_mant
809 48, // beta_exp
810
811 0, // perform_agc_softsplit
812};
813
814static struct dibx000_bandwidth_config stk7700p_pll_config = {
69ea31e7
PB
815 60000, 30000, // internal, sampling
816 1, 8, 3, 1, 0, // pll_cfg: prediv, ratio, range, reset, bypass
817 0, 0, 1, 1, 0, // misc: refdiv, bypclk_div, IO_CLK_en_core, ADClkSrc, modulo
818 (3 << 14) | (1 << 12) | (524 << 0), // sad_cfg: refsel, sel, freq_15k
819 60258167, // ifreq
820 20452225, // timf
3db78e59 821 30000000, // xtal
69ea31e7
PB
822};
823
824static struct dib7000m_config stk7700p_dib7000m_config = {
825 .dvbt_mode = 1,
826 .output_mpeg2_in_188_bytes = 1,
827 .quartz_direct = 1,
828
829 .agc_config_count = 1,
a75763ff
PB
830 .agc = &stk7700p_7000m_mt2060_agc_config,
831 .bw = &stk7700p_pll_config,
832
833 .gpio_dir = DIB7000M_GPIO_DEFAULT_DIRECTIONS,
834 .gpio_val = DIB7000M_GPIO_DEFAULT_VALUES,
835 .gpio_pwm_pos = DIB7000M_GPIO_DEFAULT_PWM_POS,
836};
837
838static struct dib7000p_config stk7700p_dib7000p_config = {
839 .output_mpeg2_in_188_bytes = 1,
840
b6884a17 841 .agc_config_count = 1,
a75763ff
PB
842 .agc = &stk7700p_7000p_mt2060_agc_config,
843 .bw = &stk7700p_pll_config,
69ea31e7
PB
844
845 .gpio_dir = DIB7000M_GPIO_DEFAULT_DIRECTIONS,
846 .gpio_val = DIB7000M_GPIO_DEFAULT_VALUES,
847 .gpio_pwm_pos = DIB7000M_GPIO_DEFAULT_PWM_POS,
b7f54910
PB
848};
849
850static int stk7700p_frontend_attach(struct dvb_usb_adapter *adap)
851{
69ea31e7 852 struct dib0700_state *st = adap->dev->priv;
b7f54910 853 /* unless there is no real power management in DVB - we leave the device on GPIO6 */
a75763ff
PB
854
855 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
856 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0); msleep(50);
857
69ea31e7 858 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1); msleep(10);
a75763ff
PB
859 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
860
b7f54910 861 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0); msleep(10);
a75763ff
PB
862 dib0700_ctrl_clock(adap->dev, 72, 1);
863 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1); msleep(100);
864
865 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
b7f54910 866
69ea31e7 867 st->mt2060_if1[0] = 1220;
a75763ff
PB
868
869 if (dib7000pc_detection(&adap->dev->i2c_adap)) {
870 adap->fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 18, &stk7700p_dib7000p_config);
871 st->is_dib7000pc = 1;
872 } else
873 adap->fe = dvb_attach(dib7000m_attach, &adap->dev->i2c_adap, 18, &stk7700p_dib7000m_config);
874
875 return adap->fe == NULL ? -ENODEV : 0;
b7f54910
PB
876}
877
69ea31e7
PB
878static struct mt2060_config stk7700p_mt2060_config = {
879 0x60
880};
881
b7f54910
PB
882static int stk7700p_tuner_attach(struct dvb_usb_adapter *adap)
883{
c52344fd 884 struct i2c_adapter *prim_i2c = &adap->dev->i2c_adap;
69ea31e7 885 struct dib0700_state *st = adap->dev->priv;
a75763ff 886 struct i2c_adapter *tun_i2c;
c52344fd
OD
887 s8 a;
888 int if1=1220;
da5ee486
AV
889 if (adap->dev->udev->descriptor.idVendor == cpu_to_le16(USB_VID_HAUPPAUGE) &&
890 adap->dev->udev->descriptor.idProduct == cpu_to_le16(USB_PID_HAUPPAUGE_NOVA_T_STICK)) {
c52344fd
OD
891 if (!eeprom_read(prim_i2c,0x58,&a)) if1=1220+a;
892 }
a75763ff
PB
893 if (st->is_dib7000pc)
894 tun_i2c = dib7000p_get_i2c_master(adap->fe, DIBX000_I2C_INTERFACE_TUNER, 1);
895 else
896 tun_i2c = dib7000m_get_i2c_master(adap->fe, DIBX000_I2C_INTERFACE_TUNER, 1);
897
898 return dvb_attach(mt2060_attach, adap->fe, tun_i2c, &stk7700p_mt2060_config,
c52344fd 899 if1) == NULL ? -ENODEV : 0;
b7f54910
PB
900}
901
01373a5c
PB
902/* DIB7070 generic */
903static struct dibx000_agc_config dib7070_agc_config = {
904 BAND_UHF | BAND_VHF | BAND_LBAND | BAND_SBAND,
905 /* 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,
906 * 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 */
907 (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0), // setup
908
909 600, // inv_gain
910 10, // time_stabiliz
911
912 0, // alpha_level
913 118, // thlock
914
915 0, // wbd_inv
916 3530, // wbd_ref
917 1, // wbd_sel
918 5, // wbd_alpha
919
920 65535, // agc1_max
921 0, // agc1_min
922
923 65535, // agc2_max
924 0, // agc2_min
925
926 0, // agc1_pt1
927 40, // agc1_pt2
928 183, // agc1_pt3
929 206, // agc1_slope1
930 255, // agc1_slope2
931 72, // agc2_pt1
932 152, // agc2_pt2
933 88, // agc2_slope1
934 90, // agc2_slope2
935
936 17, // alpha_mant
937 27, // alpha_exp
938 23, // beta_mant
939 51, // beta_exp
940
941 0, // perform_agc_softsplit
942};
943
944static int dib7070_tuner_reset(struct dvb_frontend *fe, int onoff)
945{
946 return dib7000p_set_gpio(fe, 8, 0, !onoff);
947}
948
949static int dib7070_tuner_sleep(struct dvb_frontend *fe, int onoff)
950{
951 return dib7000p_set_gpio(fe, 9, 0, onoff);
952}
953
954static struct dib0070_config dib7070p_dib0070_config[2] = {
955 {
956 .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
957 .reset = dib7070_tuner_reset,
958 .sleep = dib7070_tuner_sleep,
959 .clock_khz = 12000,
960 .clock_pad_drive = 4
961 }, {
962 .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
963 .reset = dib7070_tuner_reset,
964 .sleep = dib7070_tuner_sleep,
965 .clock_khz = 12000,
966
967 }
968};
969
970static int dib7070_set_param_override(struct dvb_frontend *fe, struct dvb_frontend_parameters *fep)
971{
972 struct dvb_usb_adapter *adap = fe->dvb->priv;
973 struct dib0700_adapter_state *state = adap->priv;
974
975 u16 offset;
976 u8 band = BAND_OF_FREQUENCY(fep->frequency/1000);
977 switch (band) {
978 case BAND_VHF: offset = 950; break;
979 case BAND_UHF:
980 default: offset = 550; break;
981 }
982 deb_info("WBD for DiB7000P: %d\n", offset + dib0070_wbd_offset(fe));
983 dib7000p_set_wbd_ref(fe, offset + dib0070_wbd_offset(fe));
984 return state->set_param_save(fe, fep);
985}
986
987static int dib7070p_tuner_attach(struct dvb_usb_adapter *adap)
988{
989 struct dib0700_adapter_state *st = adap->priv;
990 struct i2c_adapter *tun_i2c = dib7000p_get_i2c_master(adap->fe, DIBX000_I2C_INTERFACE_TUNER, 1);
991
992 if (adap->id == 0) {
993 if (dvb_attach(dib0070_attach, adap->fe, tun_i2c, &dib7070p_dib0070_config[0]) == NULL)
994 return -ENODEV;
995 } else {
996 if (dvb_attach(dib0070_attach, adap->fe, tun_i2c, &dib7070p_dib0070_config[1]) == NULL)
997 return -ENODEV;
998 }
999
1000 st->set_param_save = adap->fe->ops.tuner_ops.set_params;
1001 adap->fe->ops.tuner_ops.set_params = dib7070_set_param_override;
1002 return 0;
1003}
1004
1005static struct dibx000_bandwidth_config dib7070_bw_config_12_mhz = {
1006 60000, 15000, // internal, sampling
1007 1, 20, 3, 1, 0, // pll_cfg: prediv, ratio, range, reset, bypass
1008 0, 0, 1, 1, 2, // misc: refdiv, bypclk_div, IO_CLK_en_core, ADClkSrc, modulo
1009 (3 << 14) | (1 << 12) | (524 << 0), // sad_cfg: refsel, sel, freq_15k
1010 (0 << 25) | 0, // ifreq = 0.000000 MHz
1011 20452225, // timf
1012 12000000, // xtal_hz
1013};
1014
1015static struct dib7000p_config dib7070p_dib7000p_config = {
1016 .output_mpeg2_in_188_bytes = 1,
1017
1018 .agc_config_count = 1,
1019 .agc = &dib7070_agc_config,
1020 .bw = &dib7070_bw_config_12_mhz,
3cb2c39d
PB
1021 .tuner_is_baseband = 1,
1022 .spur_protect = 1,
01373a5c
PB
1023
1024 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
1025 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
1026 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
1027
1028 .hostbus_diversity = 1,
1029};
1030
1031/* STK7070P */
1032static int stk7070p_frontend_attach(struct dvb_usb_adapter *adap)
1033{
da5ee486
AV
1034 struct usb_device_descriptor *p = &adap->dev->udev->descriptor;
1035 if (p->idVendor == cpu_to_le16(USB_VID_PINNACLE) &&
1036 p->idProduct == cpu_to_le16(USB_PID_PINNACLE_PCTV72E))
1037 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
6ca8f0b9 1038 else
da5ee486 1039 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
01373a5c
PB
1040 msleep(10);
1041 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
1042 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
1043 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
1044 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
1045
1046 dib0700_ctrl_clock(adap->dev, 72, 1);
1047
1048 msleep(10);
1049 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
1050 msleep(10);
1051 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
1052
6ca8f0b9
AC
1053 dib7000p_i2c_enumeration(&adap->dev->i2c_adap, 1, 18,
1054 &dib7070p_dib7000p_config);
01373a5c 1055
6ca8f0b9
AC
1056 adap->fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 0x80,
1057 &dib7070p_dib7000p_config);
01373a5c
PB
1058 return adap->fe == NULL ? -ENODEV : 0;
1059}
1060
1061/* STK7070PD */
1062static struct dib7000p_config stk7070pd_dib7000p_config[2] = {
1063 {
1064 .output_mpeg2_in_188_bytes = 1,
1065
1066 .agc_config_count = 1,
1067 .agc = &dib7070_agc_config,
1068 .bw = &dib7070_bw_config_12_mhz,
3cb2c39d
PB
1069 .tuner_is_baseband = 1,
1070 .spur_protect = 1,
01373a5c
PB
1071
1072 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
1073 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
1074 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
1075
1076 .hostbus_diversity = 1,
1077 }, {
1078 .output_mpeg2_in_188_bytes = 1,
1079
1080 .agc_config_count = 1,
1081 .agc = &dib7070_agc_config,
1082 .bw = &dib7070_bw_config_12_mhz,
3cb2c39d
PB
1083 .tuner_is_baseband = 1,
1084 .spur_protect = 1,
01373a5c
PB
1085
1086 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
1087 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
1088 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
1089
1090 .hostbus_diversity = 1,
1091 }
1092};
1093
1094static int stk7070pd_frontend_attach0(struct dvb_usb_adapter *adap)
1095{
1096 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
1097 msleep(10);
1098 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
1099 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
1100 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
1101 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
1102
1103 dib0700_ctrl_clock(adap->dev, 72, 1);
1104
1105 msleep(10);
1106 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
1107 msleep(10);
1108 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
1109
1110 dib7000p_i2c_enumeration(&adap->dev->i2c_adap, 2, 18, stk7070pd_dib7000p_config);
1111
1112 adap->fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 0x80, &stk7070pd_dib7000p_config[0]);
1113 return adap->fe == NULL ? -ENODEV : 0;
1114}
1115
1116static int stk7070pd_frontend_attach1(struct dvb_usb_adapter *adap)
1117{
1118 adap->fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 0x82, &stk7070pd_dib7000p_config[1]);
1119 return adap->fe == NULL ? -ENODEV : 0;
1120}
1121
cb22cb52
DH
1122/* S5H1411 */
1123static struct s5h1411_config pinnacle_801e_config = {
1124 .output_mode = S5H1411_PARALLEL_OUTPUT,
1125 .gpio = S5H1411_GPIO_OFF,
1126 .mpeg_timing = S5H1411_MPEGTIMING_NONCONTINOUS_NONINVERTING_CLOCK,
1127 .qam_if = S5H1411_IF_44000,
1128 .vsb_if = S5H1411_IF_44000,
1129 .inversion = S5H1411_INVERSION_OFF,
1130 .status_mode = S5H1411_DEMODLOCKING
1131};
1132
1133/* Pinnacle PCTV HD Pro 801e GPIOs map:
1134 GPIO0 - currently unknown
1135 GPIO1 - xc5000 tuner reset
1136 GPIO2 - CX25843 sleep
1137 GPIO3 - currently unknown
1138 GPIO4 - currently unknown
1139 GPIO6 - currently unknown
1140 GPIO7 - currently unknown
1141 GPIO9 - currently unknown
1142 GPIO10 - CX25843 reset
1143 */
1144static int s5h1411_frontend_attach(struct dvb_usb_adapter *adap)
1145{
1146 struct dib0700_state *st = adap->dev->priv;
1147
1148 /* Make use of the new i2c functions from FW 1.20 */
1149 st->fw_use_new_i2c_api = 1;
1150
1151 /* The s5h1411 requires the dib0700 to not be in master mode */
1152 st->disable_streaming_master_mode = 1;
1153
1154 /* All msleep values taken from Windows USB trace */
1155 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 0);
1156 dib0700_set_gpio(adap->dev, GPIO3, GPIO_OUT, 0);
1157 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
1158 msleep(400);
1159 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
1160 msleep(60);
1161 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
1162 msleep(30);
1163 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
1164 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
1165 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
1166 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
1167 dib0700_set_gpio(adap->dev, GPIO2, GPIO_OUT, 0);
1168 msleep(30);
1169
1170 /* Put the CX25843 to sleep for now since we're in digital mode */
1171 dib0700_set_gpio(adap->dev, GPIO2, GPIO_OUT, 1);
1172
1173 /* GPIOs are initialized, do the attach */
1174 adap->fe = dvb_attach(s5h1411_attach, &pinnacle_801e_config,
1175 &adap->dev->i2c_adap);
1176 return adap->fe == NULL ? -ENODEV : 0;
1177}
1178
767f3b3b
MK
1179static int dib0700_xc5000_tuner_callback(void *priv, int component,
1180 int command, int arg)
cb22cb52
DH
1181{
1182 struct dvb_usb_adapter *adap = priv;
1183
79025a9e
DH
1184 if (command == XC5000_TUNER_RESET) {
1185 /* Reset the tuner */
1186 dib0700_set_gpio(adap->dev, GPIO1, GPIO_OUT, 0);
1187 msleep(330); /* from Windows USB trace */
1188 dib0700_set_gpio(adap->dev, GPIO1, GPIO_OUT, 1);
1189 msleep(330); /* from Windows USB trace */
1190 } else {
1191 err("xc5000: unknown tuner callback command: %d\n", command);
1192 return -EINVAL;
1193 }
cb22cb52
DH
1194
1195 return 0;
1196}
1197
1198static struct xc5000_config s5h1411_xc5000_tunerconfig = {
1199 .i2c_address = 0x64,
1200 .if_khz = 5380,
cb22cb52
DH
1201};
1202
1203static int xc5000_tuner_attach(struct dvb_usb_adapter *adap)
1204{
79025a9e
DH
1205 /* FIXME: generalize & move to common area */
1206 adap->fe->callback = dib0700_xc5000_tuner_callback;
1207
cb22cb52 1208 return dvb_attach(xc5000_attach, adap->fe, &adap->dev->i2c_adap,
767f3b3b 1209 &s5h1411_xc5000_tunerconfig)
cb22cb52
DH
1210 == NULL ? -ENODEV : 0;
1211}
1212
01373a5c 1213/* DVB-USB and USB stuff follows */
b7f54910 1214struct usb_device_id dib0700_usb_id_table[] = {
01373a5c 1215/* 0 */ { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7700P) },
6ca8f0b9
AC
1216 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7700P_PC) },
1217 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_500) },
1218 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_500_2) },
1219 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_STICK) },
01373a5c 1220/* 5 */ { USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR) },
6ca8f0b9
AC
1221 { USB_DEVICE(USB_VID_COMPRO, USB_PID_COMPRO_VIDEOMATE_U500) },
1222 { USB_DEVICE(USB_VID_UNIWILL, USB_PID_UNIWILL_STK7700P) },
1223 { USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV_DONGLE_STK7700P) },
1224 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_STICK_2) },
01373a5c 1225/* 10 */{ USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR_2) },
6ca8f0b9
AC
1226 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV2000E) },
1227 { USB_DEVICE(USB_VID_TERRATEC,
1228 USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY) },
1229 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_TD_STICK) },
1230 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7700D) },
01373a5c 1231/* 15 */{ USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7070P) },
6ca8f0b9
AC
1232 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV_DVB_T_FLASH) },
1233 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7070PD) },
1234 { USB_DEVICE(USB_VID_PINNACLE,
1235 USB_PID_PINNACLE_PCTV_DUAL_DIVERSITY_DVB_T) },
1236 { USB_DEVICE(USB_VID_COMPRO, USB_PID_COMPRO_VIDEOMATE_U500_PC) },
fa3b877e 1237/* 20 */{ USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_EXPRESS) },
6ca8f0b9
AC
1238 { USB_DEVICE(USB_VID_GIGABYTE, USB_PID_GIGABYTE_U7000) },
1239 { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC, USB_PID_ARTEC_T14BR) },
1240 { USB_DEVICE(USB_VID_ASUS, USB_PID_ASUS_U3000) },
1241 { USB_DEVICE(USB_VID_ASUS, USB_PID_ASUS_U3100) },
1242/* 25 */{ USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_STICK_3) },
1243 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_MYTV_T) },
1244 { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_HT_USB_XE) },
1245 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_EXPRESSCARD_320CX) },
1246 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV72E) },
1247/* 30 */{ USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV73E) },
1248 { USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_EC372S) },
1249 { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_HT_EXPRESS) },
dc88807e 1250 { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_XXS) },
5da4e2c6 1251 { USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV_DONGLE_STK7700P_2) },
af2a887c 1252/* 35 */{ USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_TD_STICK_52009) },
9a0c04a1 1253 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_500_3) },
17a370bc 1254 { USB_DEVICE(USB_VID_GIGABYTE, USB_PID_GIGABYTE_U8000) },
8751aaa6 1255 { USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_STK7700PH) },
5769743a 1256 { USB_DEVICE(USB_VID_ASUS, USB_PID_ASUS_U3000H) },
cb22cb52 1257/* 40 */{ USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV801E) },
d2fc3bfc 1258 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV801E_SE) },
6ca8f0b9 1259 { 0 } /* Terminating entry */
b7f54910
PB
1260};
1261MODULE_DEVICE_TABLE(usb, dib0700_usb_id_table);
1262
1263#define DIB0700_DEFAULT_DEVICE_PROPERTIES \
1264 .caps = DVB_USB_IS_AN_I2C_ADAPTER, \
1265 .usb_ctrl = DEVICE_SPECIFIC, \
bdc203e1 1266 .firmware = "dvb-usb-dib0700-1.20.fw", \
b7f54910 1267 .download_firmware = dib0700_download_firmware, \
6958effe 1268 .no_reconnect = 1, \
b7f54910 1269 .size_of_priv = sizeof(struct dib0700_state), \
6958effe
PB
1270 .i2c_algo = &dib0700_i2c_algo, \
1271 .identify_state = dib0700_identify_state
b7f54910
PB
1272
1273#define DIB0700_DEFAULT_STREAMING_CONFIG(ep) \
1274 .streaming_ctrl = dib0700_streaming_ctrl, \
1275 .stream = { \
1276 .type = USB_BULK, \
1277 .count = 4, \
1278 .endpoint = ep, \
1279 .u = { \
1280 .bulk = { \
1281 .buffersize = 39480, \
1282 } \
1283 } \
1284 }
1285
1286struct dvb_usb_device_properties dib0700_devices[] = {
1287 {
1288 DIB0700_DEFAULT_DEVICE_PROPERTIES,
1289
1290 .num_adapters = 1,
1291 .adapter = {
1292 {
1293 .frontend_attach = stk7700p_frontend_attach,
1294 .tuner_attach = stk7700p_tuner_attach,
1295
1296 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
1297 },
1298 },
1299
67053a40 1300 .num_device_descs = 8,
b7f54910
PB
1301 .devices = {
1302 { "DiBcom STK7700P reference design",
49a1376c 1303 { &dib0700_usb_id_table[0], &dib0700_usb_id_table[1] },
b7f54910
PB
1304 { NULL },
1305 },
1306 { "Hauppauge Nova-T Stick",
f9aeba45 1307 { &dib0700_usb_id_table[4], &dib0700_usb_id_table[9], NULL },
b7f54910
PB
1308 { NULL },
1309 },
1310 { "AVerMedia AVerTV DVB-T Volar",
ced8feca 1311 { &dib0700_usb_id_table[5], &dib0700_usb_id_table[10] },
b7f54910
PB
1312 { NULL },
1313 },
49a1376c 1314 { "Compro Videomate U500",
1f8ca4b3 1315 { &dib0700_usb_id_table[6], &dib0700_usb_id_table[19] },
49a1376c 1316 { NULL },
0ce215e1
HS
1317 },
1318 { "Uniwill STK7700P based (Hama and others)",
1319 { &dib0700_usb_id_table[7], NULL },
1320 { NULL },
8637a875
MK
1321 },
1322 { "Leadtek Winfast DTV Dongle (STK7700P based)",
5da4e2c6 1323 { &dib0700_usb_id_table[8], &dib0700_usb_id_table[34] },
8637a875 1324 { NULL },
fa3b877e
JS
1325 },
1326 { "AVerMedia AVerTV DVB-T Express",
1327 { &dib0700_usb_id_table[20] },
1328 { NULL },
67053a40 1329 },
67053a40 1330 { "Gigabyte U7000",
1331 { &dib0700_usb_id_table[21], NULL },
1332 { NULL },
49a1376c 1333 }
b1139e35
DS
1334 },
1335
1336 .rc_interval = DEFAULT_RC_INTERVAL,
1337 .rc_key_map = dib0700_rc_keys,
1338 .rc_key_map_size = ARRAY_SIZE(dib0700_rc_keys),
1339 .rc_query = dib0700_rc_query
b7f54910
PB
1340 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
1341
1342 .num_adapters = 2,
1343 .adapter = {
1344 {
1345 .frontend_attach = bristol_frontend_attach,
1346 .tuner_attach = bristol_tuner_attach,
1347
1348 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
1349 }, {
1350 .frontend_attach = bristol_frontend_attach,
1351 .tuner_attach = bristol_tuner_attach,
1352
1353 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
1354 }
1355 },
1356
1357 .num_device_descs = 1,
1358 .devices = {
1359 { "Hauppauge Nova-T 500 Dual DVB-T",
49a1376c 1360 { &dib0700_usb_id_table[2], &dib0700_usb_id_table[3], NULL },
b7f54910
PB
1361 { NULL },
1362 },
82f3d559
JG
1363 },
1364
1365 .rc_interval = DEFAULT_RC_INTERVAL,
1366 .rc_key_map = dib0700_rc_keys,
8779737b 1367 .rc_key_map_size = ARRAY_SIZE(dib0700_rc_keys),
82f3d559 1368 .rc_query = dib0700_rc_query
54d75eba
OD
1369 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
1370
1371 .num_adapters = 2,
1372 .adapter = {
1373 {
1374 .frontend_attach = stk7700d_frontend_attach,
1375 .tuner_attach = stk7700d_tuner_attach,
1376
1377 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
1378 }, {
1379 .frontend_attach = stk7700d_frontend_attach,
1380 .tuner_attach = stk7700d_tuner_attach,
1381
1382 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
1383 }
1384 },
1385
b6884a17 1386 .num_device_descs = 4,
54d75eba
OD
1387 .devices = {
1388 { "Pinnacle PCTV 2000e",
1389 { &dib0700_usb_id_table[11], NULL },
1390 { NULL },
1391 },
1392 { "Terratec Cinergy DT XS Diversity",
1393 { &dib0700_usb_id_table[12], NULL },
1394 { NULL },
1395 },
faebb914 1396 { "Hauppauge Nova-TD Stick/Elgato Eye-TV Diversity",
54d75eba
OD
1397 { &dib0700_usb_id_table[13], NULL },
1398 { NULL },
1399 },
01373a5c 1400 { "DiBcom STK7700D reference design",
b6884a17
PB
1401 { &dib0700_usb_id_table[14], NULL },
1402 { NULL },
67053a40 1403 }
54d75eba 1404 },
82f3d559 1405
54d75eba 1406 .rc_interval = DEFAULT_RC_INTERVAL,
82f3d559 1407 .rc_key_map = dib0700_rc_keys,
8779737b 1408 .rc_key_map_size = ARRAY_SIZE(dib0700_rc_keys),
82f3d559 1409 .rc_query = dib0700_rc_query
01373a5c 1410
132c3188
DG
1411 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
1412
1413 .num_adapters = 1,
1414 .adapter = {
1415 {
1416 .frontend_attach = stk7700P2_frontend_attach,
1417 .tuner_attach = stk7700d_tuner_attach,
1418
1419 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
1420 },
1421 },
1422
6ca8f0b9 1423 .num_device_descs = 2,
132c3188
DG
1424 .devices = {
1425 { "ASUS My Cinema U3000 Mini DVBT Tuner",
1426 { &dib0700_usb_id_table[23], NULL },
1427 { NULL },
1428 },
6ca8f0b9
AC
1429 { "Yuan EC372S",
1430 { &dib0700_usb_id_table[31], NULL },
1431 { NULL },
1432 }
48aa7391
CR
1433 },
1434
1435 .rc_interval = DEFAULT_RC_INTERVAL,
1436 .rc_key_map = dib0700_rc_keys,
1437 .rc_key_map_size = ARRAY_SIZE(dib0700_rc_keys),
1438 .rc_query = dib0700_rc_query
01373a5c
PB
1439 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
1440
1441 .num_adapters = 1,
1442 .adapter = {
1443 {
1444 .frontend_attach = stk7070p_frontend_attach,
1445 .tuner_attach = dib7070p_tuner_attach,
1446
1447 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
1448
1449 .size_of_priv = sizeof(struct dib0700_adapter_state),
1450 },
1451 },
1452
dc88807e 1453 .num_device_descs = 9,
01373a5c
PB
1454 .devices = {
1455 { "DiBcom STK7070P reference design",
1456 { &dib0700_usb_id_table[15], NULL },
1457 { NULL },
1458 },
1459 { "Pinnacle PCTV DVB-T Flash Stick",
1460 { &dib0700_usb_id_table[16], NULL },
1461 { NULL },
1462 },
7999a816
YL
1463 { "Artec T14BR DVB-T",
1464 { &dib0700_usb_id_table[22], NULL },
1465 { NULL },
132c3188
DG
1466 },
1467 { "ASUS My Cinema U3100 Mini DVBT Tuner",
1468 { &dib0700_usb_id_table[24], NULL },
1469 { NULL },
1470 },
c7637b1a
TT
1471 { "Hauppauge Nova-T Stick",
1472 { &dib0700_usb_id_table[25], NULL },
1473 { NULL },
1474 },
13b83b5d
DS
1475 { "Hauppauge Nova-T MyTV.t",
1476 { &dib0700_usb_id_table[26], NULL },
1477 { NULL },
1478 },
6ca8f0b9
AC
1479 { "Pinnacle PCTV 72e",
1480 { &dib0700_usb_id_table[29], NULL },
1481 { NULL },
1482 },
1483 { "Pinnacle PCTV 73e",
1484 { &dib0700_usb_id_table[30], NULL },
1485 { NULL },
1486 },
dc88807e
AS
1487 { "Terratec Cinergy T USB XXS",
1488 { &dib0700_usb_id_table[33], NULL },
1489 { NULL },
1490 },
c7637b1a
TT
1491 },
1492
1493 .rc_interval = DEFAULT_RC_INTERVAL,
1494 .rc_key_map = dib0700_rc_keys,
1495 .rc_key_map_size = ARRAY_SIZE(dib0700_rc_keys),
1496 .rc_query = dib0700_rc_query
1497
01373a5c
PB
1498 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
1499
1500 .num_adapters = 2,
1501 .adapter = {
1502 {
1503 .frontend_attach = stk7070pd_frontend_attach0,
1504 .tuner_attach = dib7070p_tuner_attach,
1505
1506 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
1507
1508 .size_of_priv = sizeof(struct dib0700_adapter_state),
1509 }, {
1510 .frontend_attach = stk7070pd_frontend_attach1,
1511 .tuner_attach = dib7070p_tuner_attach,
1512
1513 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
1514
1515 .size_of_priv = sizeof(struct dib0700_adapter_state),
1516 }
1517 },
1518
9a0c04a1 1519 .num_device_descs = 4,
01373a5c
PB
1520 .devices = {
1521 { "DiBcom STK7070PD reference design",
1522 { &dib0700_usb_id_table[17], NULL },
1523 { NULL },
1524 },
1525 { "Pinnacle PCTV Dual DVB-T Diversity Stick",
1526 { &dib0700_usb_id_table[18], NULL },
1527 { NULL },
d01eb2dc
MK
1528 },
1529 { "Hauppauge Nova-TD Stick (52009)",
1530 { &dib0700_usb_id_table[35], NULL },
1531 { NULL },
9a0c04a1
MK
1532 },
1533 { "Hauppauge Nova-TD-500 (84xxx)",
1534 { &dib0700_usb_id_table[36], NULL },
1535 { NULL },
67053a40 1536 }
01373a5c 1537 }
6ca8f0b9
AC
1538 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
1539
1540 .num_adapters = 1,
1541 .adapter = {
1542 {
1543 .frontend_attach = stk7700ph_frontend_attach,
1544 .tuner_attach = stk7700ph_tuner_attach,
1545
1546 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
1547
1548 .size_of_priv = sizeof(struct
1549 dib0700_adapter_state),
1550 },
1551 },
1552
8751aaa6 1553 .num_device_descs = 5,
6ca8f0b9
AC
1554 .devices = {
1555 { "Terratec Cinergy HT USB XE",
1556 { &dib0700_usb_id_table[27], NULL },
1557 { NULL },
1558 },
1559 { "Pinnacle Expresscard 320cx",
1560 { &dib0700_usb_id_table[28], NULL },
1561 { NULL },
1562 },
1563 { "Terratec Cinergy HT Express",
1564 { &dib0700_usb_id_table[32], NULL },
1565 { NULL },
1566 },
17a370bc
FT
1567 { "Gigabyte U8000-RH",
1568 { &dib0700_usb_id_table[37], NULL },
1569 { NULL },
1570 },
8751aaa6
DON
1571 { "YUAN High-Tech STK7700PH",
1572 { &dib0700_usb_id_table[38], NULL },
1573 { NULL },
1574 },
5769743a
AC
1575 { "Asus My Cinema-U3000Hybrid",
1576 { &dib0700_usb_id_table[39], NULL },
1577 { NULL },
1578 },
6ca8f0b9
AC
1579 },
1580 .rc_interval = DEFAULT_RC_INTERVAL,
1581 .rc_key_map = dib0700_rc_keys,
1582 .rc_key_map_size = ARRAY_SIZE(dib0700_rc_keys),
1583 .rc_query = dib0700_rc_query
cb22cb52
DH
1584 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
1585 .num_adapters = 1,
1586 .adapter = {
1587 {
1588 .frontend_attach = s5h1411_frontend_attach,
1589 .tuner_attach = xc5000_tuner_attach,
1590
1591 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
1592
1593 .size_of_priv = sizeof(struct
1594 dib0700_adapter_state),
1595 },
1596 },
1597
d2fc3bfc 1598 .num_device_descs = 2,
cb22cb52
DH
1599 .devices = {
1600 { "Pinnacle PCTV HD Pro USB Stick",
1601 { &dib0700_usb_id_table[40], NULL },
1602 { NULL },
1603 },
d2fc3bfc
DH
1604 { "Pinnacle PCTV HD USB Stick",
1605 { &dib0700_usb_id_table[41], NULL },
1606 { NULL },
1607 },
cb22cb52
DH
1608 },
1609 .rc_interval = DEFAULT_RC_INTERVAL,
1610 .rc_key_map = dib0700_rc_keys,
1611 .rc_key_map_size = ARRAY_SIZE(dib0700_rc_keys),
1612 .rc_query = dib0700_rc_query
01373a5c 1613 },
b7f54910
PB
1614};
1615
1616int dib0700_device_count = ARRAY_SIZE(dib0700_devices);