Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ryusuke...
[GitHub/mt8127/android_kernel_alcatel_ttab.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 *
ba3fe3a9 7 * Copyright (C) 2005-9 DiBcom, SA et al
b7f54910
PB
8 */
9#include "dib0700.h"
10
11#include "dib3000mc.h"
91bb9be6 12#include "dib7000m.h"
a75763ff 13#include "dib7000p.h"
ba3fe3a9 14#include "dib8000.h"
be9bae10 15#include "dib9000.h"
b7f54910 16#include "mt2060.h"
54d75eba 17#include "mt2266.h"
6ca8f0b9 18#include "tuner-xc2028.h"
cb22cb52
DH
19#include "xc5000.h"
20#include "s5h1411.h"
01373a5c 21#include "dib0070.h"
03245a5e 22#include "dib0090.h"
ce904bcb
MK
23#include "lgdt3305.h"
24#include "mxl5007t.h"
b7f54910 25
7fb3fc0c
PB
26static int force_lna_activation;
27module_param(force_lna_activation, int, 0644);
28MODULE_PARM_DESC(force_lna_activation, "force the activation of Low-Noise-Amplifyer(s) (LNA), "
29 "if applicable for the device (default: 0=automatic/off).");
30
01373a5c
PB
31struct dib0700_adapter_state {
32 int (*set_param_save) (struct dvb_frontend *, struct dvb_frontend_parameters *);
be9bae10 33 const struct firmware *frontend_firmware;
01373a5c
PB
34};
35
36/* Hauppauge Nova-T 500 (aka Bristol)
b7f54910
PB
37 * has a LNA on GPIO0 which is enabled by setting 1 */
38static struct mt2060_config bristol_mt2060_config[2] = {
39 {
40 .i2c_address = 0x60,
303cbeaa 41 .clock_out = 3,
b7f54910
PB
42 }, {
43 .i2c_address = 0x61,
44 }
45};
46
99afb989 47
b7f54910
PB
48static struct dibx000_agc_config bristol_dib3000p_mt2060_agc_config = {
49 .band_caps = BAND_VHF | BAND_UHF,
01b4bf31 50 .setup = (1 << 8) | (5 << 5) | (0 << 4) | (0 << 3) | (0 << 2) | (2 << 0),
b7f54910 51
6958effe
PB
52 .agc1_max = 42598,
53 .agc1_min = 17694,
54 .agc2_max = 45875,
55 .agc2_min = 0,
b7f54910 56
6958effe
PB
57 .agc1_pt1 = 0,
58 .agc1_pt2 = 59,
b7f54910 59
6958effe
PB
60 .agc1_slope1 = 0,
61 .agc1_slope2 = 69,
b7f54910
PB
62
63 .agc2_pt1 = 0,
6958effe 64 .agc2_pt2 = 59,
b7f54910 65
6958effe
PB
66 .agc2_slope1 = 111,
67 .agc2_slope2 = 28,
b7f54910
PB
68};
69
70static struct dib3000mc_config bristol_dib3000mc_config[2] = {
71 { .agc = &bristol_dib3000p_mt2060_agc_config,
72 .max_time = 0x196,
73 .ln_adc_level = 0x1cc7,
74 .output_mpeg2_in_188_bytes = 1,
75 },
76 { .agc = &bristol_dib3000p_mt2060_agc_config,
77 .max_time = 0x196,
78 .ln_adc_level = 0x1cc7,
79 .output_mpeg2_in_188_bytes = 1,
80 }
81};
82
83static int bristol_frontend_attach(struct dvb_usb_adapter *adap)
84{
6958effe 85 struct dib0700_state *st = adap->dev->priv;
b7f54910
PB
86 if (adap->id == 0) {
87 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0); msleep(10);
88 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1); msleep(10);
89 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0); msleep(10);
90 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1); msleep(10);
91
7fb3fc0c
PB
92 if (force_lna_activation)
93 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
94 else
95 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 0);
6958effe 96
b7f54910
PB
97 if (dib3000mc_i2c_enumeration(&adap->dev->i2c_adap, 2, DEFAULT_DIB3000P_I2C_ADDRESS, bristol_dib3000mc_config) != 0) {
98 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0); msleep(10);
99 return -ENODEV;
100 }
101 }
6958effe
PB
102 st->mt2060_if1[adap->id] = 1220;
103 return (adap->fe = dvb_attach(dib3000mc_attach, &adap->dev->i2c_adap,
104 (10 + adap->id) << 1, &bristol_dib3000mc_config[adap->id])) == NULL ? -ENODEV : 0;
b7f54910
PB
105}
106
4a2b1083 107static int eeprom_read(struct i2c_adapter *adap,u8 adrs,u8 *pval)
c52344fd
OD
108{
109 struct i2c_msg msg[2] = {
110 { .addr = 0x50, .flags = 0, .buf = &adrs, .len = 1 },
111 { .addr = 0x50, .flags = I2C_M_RD, .buf = pval, .len = 1 },
112 };
113 if (i2c_transfer(adap, msg, 2) != 2) return -EREMOTEIO;
114 return 0;
115}
116
b7f54910
PB
117static int bristol_tuner_attach(struct dvb_usb_adapter *adap)
118{
c52344fd 119 struct i2c_adapter *prim_i2c = &adap->dev->i2c_adap;
b7f54910 120 struct i2c_adapter *tun_i2c = dib3000mc_get_tuner_i2c_master(adap->fe, 1);
c52344fd
OD
121 s8 a;
122 int if1=1220;
da5ee486
AV
123 if (adap->dev->udev->descriptor.idVendor == cpu_to_le16(USB_VID_HAUPPAUGE) &&
124 adap->dev->udev->descriptor.idProduct == cpu_to_le16(USB_PID_HAUPPAUGE_NOVA_T_500_2)) {
c52344fd
OD
125 if (!eeprom_read(prim_i2c,0x59 + adap->id,&a)) if1=1220+a;
126 }
127 return dvb_attach(mt2060_attach,adap->fe, tun_i2c,&bristol_mt2060_config[adap->id],
128 if1) == NULL ? -ENODEV : 0;
b7f54910
PB
129}
130
01373a5c 131/* STK7700D: Pinnacle/Terratec/Hauppauge Dual DVB-T Diversity */
54d75eba 132
b6884a17
PB
133/* MT226x */
134static struct dibx000_agc_config stk7700d_7000p_mt2266_agc_config[2] = {
135 {
9c783036 136 BAND_UHF,
b6884a17
PB
137
138 /* 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,
139 * 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 */
9c783036
OG
140 (0 << 15) | (0 << 14) | (1 << 11) | (1 << 10) | (1 << 9) | (0 << 8)
141 | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),
142
143 1130,
144 21,
145
146 0,
147 118,
148
149 0,
150 3530,
151 1,
152 0,
153
154 65535,
155 33770,
156 65535,
157 23592,
158
159 0,
160 62,
161 255,
162 64,
163 64,
164 132,
165 192,
166 80,
167 80,
168
169 17,
170 27,
171 23,
172 51,
173
174 1,
b6884a17 175 }, {
9c783036 176 BAND_VHF | BAND_LBAND,
b6884a17
PB
177
178 /* 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,
179 * 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 */
9c783036
OG
180 (0 << 15) | (0 << 14) | (1 << 11) | (1 << 10) | (1 << 9) | (0 << 8)
181 | (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0),
182
183 2372,
184 21,
185
186 0,
187 118,
188
189 0,
190 3530,
191 1,
192 0,
193
194 65535,
195 0,
196 65535,
197 23592,
198
199 0,
200 128,
201 128,
202 128,
203 0,
204 128,
205 253,
206 81,
207 0,
208
209 17,
210 27,
211 23,
212 51,
213
214 1,
b6884a17 215 }
54d75eba
OD
216};
217
218static struct dibx000_bandwidth_config stk7700d_mt2266_pll_config = {
9c783036
OG
219 60000, 30000,
220 1, 8, 3, 1, 0,
221 0, 0, 1, 1, 2,
222 (3 << 14) | (1 << 12) | (524 << 0),
223 0,
224 20452225,
54d75eba
OD
225};
226
227static struct dib7000p_config stk7700d_dib7000p_mt2266_config[] = {
228 { .output_mpeg2_in_188_bytes = 1,
229 .hostbus_diversity = 1,
230 .tuner_is_baseband = 1,
231
b6884a17
PB
232 .agc_config_count = 2,
233 .agc = stk7700d_7000p_mt2266_agc_config,
54d75eba
OD
234 .bw = &stk7700d_mt2266_pll_config,
235
b6884a17
PB
236 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
237 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
238 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
54d75eba
OD
239 },
240 { .output_mpeg2_in_188_bytes = 1,
241 .hostbus_diversity = 1,
242 .tuner_is_baseband = 1,
243
b6884a17
PB
244 .agc_config_count = 2,
245 .agc = stk7700d_7000p_mt2266_agc_config,
54d75eba
OD
246 .bw = &stk7700d_mt2266_pll_config,
247
b6884a17
PB
248 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
249 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
250 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
54d75eba
OD
251 }
252};
253
254static struct mt2266_config stk7700d_mt2266_config[2] = {
255 { .i2c_address = 0x60
256 },
257 { .i2c_address = 0x60
258 }
259};
260
132c3188
DG
261static int stk7700P2_frontend_attach(struct dvb_usb_adapter *adap)
262{
263 if (adap->id == 0) {
264 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
265 msleep(10);
266 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
267 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
268 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
269 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
270 msleep(10);
271 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
272 msleep(10);
83c4fdf7
DH
273 if (dib7000p_i2c_enumeration(&adap->dev->i2c_adap, 1, 18,
274 stk7700d_dib7000p_mt2266_config)
275 != 0) {
276 err("%s: dib7000p_i2c_enumeration failed. Cannot continue\n", __func__);
277 return -ENODEV;
278 }
132c3188
DG
279 }
280
281 adap->fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap,0x80+(adap->id << 1),
282 &stk7700d_dib7000p_mt2266_config[adap->id]);
283
284 return adap->fe == NULL ? -ENODEV : 0;
285}
286
54d75eba
OD
287static int stk7700d_frontend_attach(struct dvb_usb_adapter *adap)
288{
289 if (adap->id == 0) {
290 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
291 msleep(10);
292 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
293 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
294 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
295 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
296 msleep(10);
297 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
298 msleep(10);
299 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
83c4fdf7
DH
300 if (dib7000p_i2c_enumeration(&adap->dev->i2c_adap, 2, 18,
301 stk7700d_dib7000p_mt2266_config)
302 != 0) {
303 err("%s: dib7000p_i2c_enumeration failed. Cannot continue\n", __func__);
304 return -ENODEV;
305 }
54d75eba
OD
306 }
307
308 adap->fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap,0x80+(adap->id << 1),
309 &stk7700d_dib7000p_mt2266_config[adap->id]);
310
311 return adap->fe == NULL ? -ENODEV : 0;
312}
313
314static int stk7700d_tuner_attach(struct dvb_usb_adapter *adap)
315{
316 struct i2c_adapter *tun_i2c;
317 tun_i2c = dib7000p_get_i2c_master(adap->fe, DIBX000_I2C_INTERFACE_TUNER, 1);
318 return dvb_attach(mt2266_attach, adap->fe, tun_i2c,
1ebcad77 319 &stk7700d_mt2266_config[adap->id]) == NULL ? -ENODEV : 0;
54d75eba
OD
320}
321
6ca8f0b9 322/* STK7700-PH: Digital/Analog Hybrid Tuner, e.h. Cinergy HT USB HE */
b1721d0d 323static struct dibx000_agc_config xc3028_agc_config = {
6ca8f0b9
AC
324 BAND_VHF | BAND_UHF, /* band_caps */
325
326 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=0,
327 * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
328 * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=2, P_agc_write=0 */
329 (0 << 15) | (0 << 14) | (0 << 11) | (0 << 10) | (0 << 9) | (0 << 8) |
330 (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0), /* setup */
331
332 712, /* inv_gain */
333 21, /* time_stabiliz */
334
335 0, /* alpha_level */
336 118, /* thlock */
337
338 0, /* wbd_inv */
339 2867, /* wbd_ref */
340 0, /* wbd_sel */
341 2, /* wbd_alpha */
342
343 0, /* agc1_max */
344 0, /* agc1_min */
345 39718, /* agc2_max */
346 9930, /* agc2_min */
347 0, /* agc1_pt1 */
348 0, /* agc1_pt2 */
349 0, /* agc1_pt3 */
350 0, /* agc1_slope1 */
351 0, /* agc1_slope2 */
352 0, /* agc2_pt1 */
353 128, /* agc2_pt2 */
354 29, /* agc2_slope1 */
355 29, /* agc2_slope2 */
356
357 17, /* alpha_mant */
358 27, /* alpha_exp */
359 23, /* beta_mant */
360 51, /* beta_exp */
361
362 1, /* perform_agc_softsplit */
363};
364
365/* PLL Configuration for COFDM BW_MHz = 8.00 with external clock = 30.00 */
b1721d0d 366static struct dibx000_bandwidth_config xc3028_bw_config = {
6ca8f0b9
AC
367 60000, 30000, /* internal, sampling */
368 1, 8, 3, 1, 0, /* pll_cfg: prediv, ratio, range, reset, bypass */
369 0, 0, 1, 1, 0, /* misc: refdiv, bypclk_div, IO_CLK_en_core, ADClkSrc,
370 modulo */
371 (3 << 14) | (1 << 12) | (524 << 0), /* sad_cfg: refsel, sel, freq_15k */
372 (1 << 25) | 5816102, /* ifreq = 5.200000 MHz */
373 20452225, /* timf */
374 30000000, /* xtal_hz */
375};
376
377static struct dib7000p_config stk7700ph_dib7700_xc3028_config = {
378 .output_mpeg2_in_188_bytes = 1,
379 .tuner_is_baseband = 1,
380
381 .agc_config_count = 1,
382 .agc = &xc3028_agc_config,
383 .bw = &xc3028_bw_config,
384
385 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
386 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
387 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
388};
389
d7cba043
MK
390static int stk7700ph_xc3028_callback(void *ptr, int component,
391 int command, int arg)
6ca8f0b9
AC
392{
393 struct dvb_usb_adapter *adap = ptr;
394
395 switch (command) {
396 case XC2028_TUNER_RESET:
397 /* Send the tuner in then out of reset */
398 dib7000p_set_gpio(adap->fe, 8, 0, 0); msleep(10);
399 dib7000p_set_gpio(adap->fe, 8, 0, 1);
400 break;
401 case XC2028_RESET_CLK:
402 break;
403 default:
404 err("%s: unknown command %d, arg %d\n", __func__,
405 command, arg);
406 return -EINVAL;
407 }
408 return 0;
409}
410
411static struct xc2028_ctrl stk7700ph_xc3028_ctrl = {
412 .fname = XC2028_DEFAULT_FIRMWARE,
413 .max_len = 64,
414 .demod = XC3028_FE_DIBCOM52,
415};
416
417static struct xc2028_config stk7700ph_xc3028_config = {
418 .i2c_addr = 0x61,
6ca8f0b9
AC
419 .ctrl = &stk7700ph_xc3028_ctrl,
420};
421
422static int stk7700ph_frontend_attach(struct dvb_usb_adapter *adap)
423{
424 struct usb_device_descriptor *desc = &adap->dev->udev->descriptor;
425
da5ee486
AV
426 if (desc->idVendor == cpu_to_le16(USB_VID_PINNACLE) &&
427 desc->idProduct == cpu_to_le16(USB_PID_PINNACLE_EXPRESSCARD_320CX))
6ca8f0b9
AC
428 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
429 else
430 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
431 msleep(20);
432 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
433 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
434 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
435 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
436 msleep(10);
437 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
438 msleep(20);
439 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
440 msleep(10);
441
83c4fdf7
DH
442 if (dib7000p_i2c_enumeration(&adap->dev->i2c_adap, 1, 18,
443 &stk7700ph_dib7700_xc3028_config) != 0) {
444 err("%s: dib7000p_i2c_enumeration failed. Cannot continue\n",
445 __func__);
446 return -ENODEV;
447 }
6ca8f0b9
AC
448
449 adap->fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 0x80,
450 &stk7700ph_dib7700_xc3028_config);
451
452 return adap->fe == NULL ? -ENODEV : 0;
453}
454
455static int stk7700ph_tuner_attach(struct dvb_usb_adapter *adap)
456{
457 struct i2c_adapter *tun_i2c;
458
459 tun_i2c = dib7000p_get_i2c_master(adap->fe,
460 DIBX000_I2C_INTERFACE_TUNER, 1);
461
462 stk7700ph_xc3028_config.i2c_adap = tun_i2c;
d7cba043
MK
463
464 /* FIXME: generalize & move to common area */
465 adap->fe->callback = stk7700ph_xc3028_callback;
6ca8f0b9
AC
466
467 return dvb_attach(xc2028_attach, adap->fe, &stk7700ph_xc3028_config)
468 == NULL ? -ENODEV : 0;
469}
470
4b330bee 471#define DEFAULT_RC_INTERVAL 50
54d75eba
OD
472
473static u8 rc_request[] = { REQUEST_POLL_RC, 0 };
474
58e6f95e 475/* Number of keypresses to ignore before start repeating */
4b330bee 476#define RC_REPEAT_DELAY 6
58e6f95e 477
72b39310
MCC
478/*
479 * This function is used only when firmware is < 1.20 version. Newer
480 * firmwares use bulk mode, with functions implemented at dib0700_core,
481 * at dib0700_rc_urb_completion()
482 */
483static int dib0700_rc_query_old_firmware(struct dvb_usb_device *d)
54d75eba
OD
484{
485 u8 key[4];
72b39310
MCC
486 u32 keycode;
487 u8 toggle;
54d75eba 488 int i;
54d75eba 489 struct dib0700_state *st = d->priv;
6a207100 490
6a207100
DH
491 if (st->fw_version >= 0x10200) {
492 /* For 1.20 firmware , We need to keep the RC polling
493 callback so we can reuse the input device setup in
494 dvb-usb-remote.c. However, the actual work is being done
495 in the bulk URB completion handler. */
496 return 0;
497 }
498
72b39310
MCC
499 i = dib0700_ctrl_rd(d, rc_request, 2, key, 4);
500 if (i <= 0) {
034d65ed 501 err("RC Query Failed");
89f4267d 502 return -1;
54d75eba 503 }
58e6f95e
PB
504
505 /* losing half of KEY_0 events from Philipps rc5 remotes.. */
72b39310
MCC
506 if (key[0] == 0 && key[1] == 0 && key[2] == 0 && key[3] == 0)
507 return 0;
58e6f95e
PB
508
509 /* 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]); */
510
511 dib0700_rc_setup(d); /* reset ir sensor data to prevent false events */
512
72b39310 513 d->last_event = 0;
0ffd1ab3 514 switch (d->props.rc.core.protocol) {
52b66144 515 case RC_TYPE_NEC:
58e6f95e
PB
516 /* NEC protocol sends repeat code as 0 0 0 FF */
517 if ((key[3-2] == 0x00) && (key[3-3] == 0x00) &&
72b39310
MCC
518 (key[3] == 0xff))
519 keycode = d->last_event;
520 else {
521 keycode = key[3-2] << 8 | key[3-3];
522 d->last_event = keycode;
58e6f95e 523 }
72b39310 524
ca86674b 525 rc_keydown(d->rc_dev, keycode, 0);
58e6f95e 526 break;
72b39310 527 default:
58e6f95e 528 /* RC-5 protocol changes toggle bit on new keypress */
72b39310
MCC
529 keycode = key[3-2] << 8 | key[3-3];
530 toggle = key[3-1];
ca86674b 531 rc_keydown(d->rc_dev, keycode, toggle);
72b39310 532
58e6f95e
PB
533 break;
534 }
54d75eba
OD
535 return 0;
536}
537
b7f54910 538/* STK7700P: Hauppauge Nova-T Stick, AVerMedia Volar */
a75763ff 539static struct dibx000_agc_config stk7700p_7000m_mt2060_agc_config = {
9c783036 540 BAND_UHF | BAND_VHF,
69ea31e7
PB
541
542 /* 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,
543 * 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 */
9c783036
OG
544 (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8)
545 | (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0),
546
547 712,
548 41,
549
550 0,
551 118,
552
553 0,
554 4095,
555 0,
556 0,
557
558 42598,
559 17694,
560 45875,
561 2621,
562 0,
563 76,
564 139,
565 52,
566 59,
567 107,
568 172,
569 57,
570 70,
571
572 21,
573 25,
574 28,
575 48,
576
577 1,
578 { 0,
579 107,
580 51800,
581 24700
69ea31e7
PB
582 },
583};
584
a75763ff
PB
585static struct dibx000_agc_config stk7700p_7000p_mt2060_agc_config = {
586 BAND_UHF | BAND_VHF,
587
588 /* 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,
589 * 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 */
9c783036
OG
590 (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8)
591 | (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0),
a75763ff 592
9c783036
OG
593 712,
594 41,
a75763ff 595
9c783036
OG
596 0,
597 118,
a75763ff 598
9c783036
OG
599 0,
600 4095,
601 0,
602 0,
a75763ff 603
9c783036
OG
604 42598,
605 16384,
606 42598,
607 0,
a75763ff 608
9c783036
OG
609 0,
610 137,
611 255,
a75763ff 612
9c783036
OG
613 0,
614 255,
a75763ff 615
9c783036
OG
616 0,
617 0,
a75763ff 618
9c783036
OG
619 0,
620 41,
a75763ff 621
9c783036
OG
622 15,
623 25,
a75763ff 624
9c783036
OG
625 28,
626 48,
a75763ff 627
9c783036 628 0,
a75763ff
PB
629};
630
631static struct dibx000_bandwidth_config stk7700p_pll_config = {
9c783036
OG
632 60000, 30000,
633 1, 8, 3, 1, 0,
634 0, 0, 1, 1, 0,
635 (3 << 14) | (1 << 12) | (524 << 0),
636 60258167,
637 20452225,
638 30000000,
69ea31e7
PB
639};
640
641static struct dib7000m_config stk7700p_dib7000m_config = {
642 .dvbt_mode = 1,
643 .output_mpeg2_in_188_bytes = 1,
644 .quartz_direct = 1,
645
646 .agc_config_count = 1,
a75763ff
PB
647 .agc = &stk7700p_7000m_mt2060_agc_config,
648 .bw = &stk7700p_pll_config,
649
650 .gpio_dir = DIB7000M_GPIO_DEFAULT_DIRECTIONS,
651 .gpio_val = DIB7000M_GPIO_DEFAULT_VALUES,
652 .gpio_pwm_pos = DIB7000M_GPIO_DEFAULT_PWM_POS,
653};
654
655static struct dib7000p_config stk7700p_dib7000p_config = {
656 .output_mpeg2_in_188_bytes = 1,
657
b6884a17 658 .agc_config_count = 1,
a75763ff
PB
659 .agc = &stk7700p_7000p_mt2060_agc_config,
660 .bw = &stk7700p_pll_config,
69ea31e7
PB
661
662 .gpio_dir = DIB7000M_GPIO_DEFAULT_DIRECTIONS,
663 .gpio_val = DIB7000M_GPIO_DEFAULT_VALUES,
664 .gpio_pwm_pos = DIB7000M_GPIO_DEFAULT_PWM_POS,
b7f54910
PB
665};
666
667static int stk7700p_frontend_attach(struct dvb_usb_adapter *adap)
668{
69ea31e7 669 struct dib0700_state *st = adap->dev->priv;
b7f54910 670 /* unless there is no real power management in DVB - we leave the device on GPIO6 */
a75763ff
PB
671
672 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
673 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0); msleep(50);
674
69ea31e7 675 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1); msleep(10);
a75763ff
PB
676 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
677
b7f54910 678 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0); msleep(10);
a75763ff
PB
679 dib0700_ctrl_clock(adap->dev, 72, 1);
680 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1); msleep(100);
681
682 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
b7f54910 683
69ea31e7 684 st->mt2060_if1[0] = 1220;
a75763ff
PB
685
686 if (dib7000pc_detection(&adap->dev->i2c_adap)) {
687 adap->fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 18, &stk7700p_dib7000p_config);
688 st->is_dib7000pc = 1;
689 } else
690 adap->fe = dvb_attach(dib7000m_attach, &adap->dev->i2c_adap, 18, &stk7700p_dib7000m_config);
691
692 return adap->fe == NULL ? -ENODEV : 0;
b7f54910
PB
693}
694
69ea31e7
PB
695static struct mt2060_config stk7700p_mt2060_config = {
696 0x60
697};
698
b7f54910
PB
699static int stk7700p_tuner_attach(struct dvb_usb_adapter *adap)
700{
c52344fd 701 struct i2c_adapter *prim_i2c = &adap->dev->i2c_adap;
69ea31e7 702 struct dib0700_state *st = adap->dev->priv;
a75763ff 703 struct i2c_adapter *tun_i2c;
c52344fd
OD
704 s8 a;
705 int if1=1220;
da5ee486
AV
706 if (adap->dev->udev->descriptor.idVendor == cpu_to_le16(USB_VID_HAUPPAUGE) &&
707 adap->dev->udev->descriptor.idProduct == cpu_to_le16(USB_PID_HAUPPAUGE_NOVA_T_STICK)) {
c52344fd
OD
708 if (!eeprom_read(prim_i2c,0x58,&a)) if1=1220+a;
709 }
a75763ff
PB
710 if (st->is_dib7000pc)
711 tun_i2c = dib7000p_get_i2c_master(adap->fe, DIBX000_I2C_INTERFACE_TUNER, 1);
712 else
713 tun_i2c = dib7000m_get_i2c_master(adap->fe, DIBX000_I2C_INTERFACE_TUNER, 1);
714
715 return dvb_attach(mt2060_attach, adap->fe, tun_i2c, &stk7700p_mt2060_config,
c52344fd 716 if1) == NULL ? -ENODEV : 0;
b7f54910
PB
717}
718
01373a5c
PB
719/* DIB7070 generic */
720static struct dibx000_agc_config dib7070_agc_config = {
721 BAND_UHF | BAND_VHF | BAND_LBAND | BAND_SBAND,
722 /* 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,
723 * 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 */
9c783036
OG
724 (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8)
725 | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),
726
727 600,
728 10,
729
730 0,
731 118,
732
733 0,
734 3530,
735 1,
736 5,
737
738 65535,
739 0,
740
741 65535,
742 0,
743
744 0,
745 40,
746 183,
747 206,
748 255,
749 72,
750 152,
751 88,
752 90,
753
754 17,
755 27,
756 23,
757 51,
758
759 0,
01373a5c
PB
760};
761
762static int dib7070_tuner_reset(struct dvb_frontend *fe, int onoff)
763{
7e5ce651 764 deb_info("reset: %d", onoff);
01373a5c
PB
765 return dib7000p_set_gpio(fe, 8, 0, !onoff);
766}
767
768static int dib7070_tuner_sleep(struct dvb_frontend *fe, int onoff)
769{
7e5ce651 770 deb_info("sleep: %d", onoff);
01373a5c
PB
771 return dib7000p_set_gpio(fe, 9, 0, onoff);
772}
773
774static struct dib0070_config dib7070p_dib0070_config[2] = {
775 {
776 .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
777 .reset = dib7070_tuner_reset,
778 .sleep = dib7070_tuner_sleep,
779 .clock_khz = 12000,
7e5ce651
PB
780 .clock_pad_drive = 4,
781 .charge_pump = 2,
01373a5c
PB
782 }, {
783 .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
784 .reset = dib7070_tuner_reset,
785 .sleep = dib7070_tuner_sleep,
786 .clock_khz = 12000,
7e5ce651 787 .charge_pump = 2,
01373a5c
PB
788 }
789};
790
d300bd69
OG
791static struct dib0070_config dib7770p_dib0070_config = {
792 .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
793 .reset = dib7070_tuner_reset,
794 .sleep = dib7070_tuner_sleep,
795 .clock_khz = 12000,
796 .clock_pad_drive = 0,
797 .flip_chip = 1,
eac1fe10 798 .charge_pump = 2,
d300bd69
OG
799};
800
01373a5c
PB
801static int dib7070_set_param_override(struct dvb_frontend *fe, struct dvb_frontend_parameters *fep)
802{
803 struct dvb_usb_adapter *adap = fe->dvb->priv;
804 struct dib0700_adapter_state *state = adap->priv;
805
806 u16 offset;
807 u8 band = BAND_OF_FREQUENCY(fep->frequency/1000);
808 switch (band) {
809 case BAND_VHF: offset = 950; break;
810 case BAND_UHF:
811 default: offset = 550; break;
812 }
813 deb_info("WBD for DiB7000P: %d\n", offset + dib0070_wbd_offset(fe));
814 dib7000p_set_wbd_ref(fe, offset + dib0070_wbd_offset(fe));
815 return state->set_param_save(fe, fep);
816}
817
d300bd69
OG
818static int dib7770_set_param_override(struct dvb_frontend *fe,
819 struct dvb_frontend_parameters *fep)
820{
821 struct dvb_usb_adapter *adap = fe->dvb->priv;
822 struct dib0700_adapter_state *state = adap->priv;
823
824 u16 offset;
825 u8 band = BAND_OF_FREQUENCY(fep->frequency/1000);
826 switch (band) {
827 case BAND_VHF:
828 dib7000p_set_gpio(fe, 0, 0, 1);
829 offset = 850;
830 break;
831 case BAND_UHF:
832 default:
833 dib7000p_set_gpio(fe, 0, 0, 0);
834 offset = 250;
835 break;
836 }
837 deb_info("WBD for DiB7000P: %d\n", offset + dib0070_wbd_offset(fe));
838 dib7000p_set_wbd_ref(fe, offset + dib0070_wbd_offset(fe));
839 return state->set_param_save(fe, fep);
840}
841
842static int dib7770p_tuner_attach(struct dvb_usb_adapter *adap)
843{
844 struct dib0700_adapter_state *st = adap->priv;
845 struct i2c_adapter *tun_i2c = dib7000p_get_i2c_master(adap->fe,
846 DIBX000_I2C_INTERFACE_TUNER, 1);
847
848 if (dvb_attach(dib0070_attach, adap->fe, tun_i2c,
849 &dib7770p_dib0070_config) == NULL)
850 return -ENODEV;
851
852 st->set_param_save = adap->fe->ops.tuner_ops.set_params;
853 adap->fe->ops.tuner_ops.set_params = dib7770_set_param_override;
854 return 0;
855}
856
01373a5c
PB
857static int dib7070p_tuner_attach(struct dvb_usb_adapter *adap)
858{
859 struct dib0700_adapter_state *st = adap->priv;
860 struct i2c_adapter *tun_i2c = dib7000p_get_i2c_master(adap->fe, DIBX000_I2C_INTERFACE_TUNER, 1);
861
862 if (adap->id == 0) {
863 if (dvb_attach(dib0070_attach, adap->fe, tun_i2c, &dib7070p_dib0070_config[0]) == NULL)
864 return -ENODEV;
865 } else {
866 if (dvb_attach(dib0070_attach, adap->fe, tun_i2c, &dib7070p_dib0070_config[1]) == NULL)
867 return -ENODEV;
868 }
869
870 st->set_param_save = adap->fe->ops.tuner_ops.set_params;
871 adap->fe->ops.tuner_ops.set_params = dib7070_set_param_override;
872 return 0;
873}
874
e192a7cf
OG
875static int stk7700p_pid_filter(struct dvb_usb_adapter *adapter, int index,
876 u16 pid, int onoff)
877{
878 struct dib0700_state *st = adapter->dev->priv;
879 if (st->is_dib7000pc)
880 return dib7000p_pid_filter(adapter->fe, index, pid, onoff);
881 return dib7000m_pid_filter(adapter->fe, index, pid, onoff);
882}
883
884static int stk7700p_pid_filter_ctrl(struct dvb_usb_adapter *adapter, int onoff)
885{
886 struct dib0700_state *st = adapter->dev->priv;
887 if (st->is_dib7000pc)
888 return dib7000p_pid_filter_ctrl(adapter->fe, onoff);
889 return dib7000m_pid_filter_ctrl(adapter->fe, onoff);
890}
891
f8731f4d
OG
892static int stk70x0p_pid_filter(struct dvb_usb_adapter *adapter, int index, u16 pid, int onoff)
893{
894 return dib7000p_pid_filter(adapter->fe, index, pid, onoff);
895}
896
897static int stk70x0p_pid_filter_ctrl(struct dvb_usb_adapter *adapter, int onoff)
898{
899 return dib7000p_pid_filter_ctrl(adapter->fe, onoff);
900}
901
01373a5c 902static struct dibx000_bandwidth_config dib7070_bw_config_12_mhz = {
9c783036
OG
903 60000, 15000,
904 1, 20, 3, 1, 0,
905 0, 0, 1, 1, 2,
906 (3 << 14) | (1 << 12) | (524 << 0),
907 (0 << 25) | 0,
908 20452225,
909 12000000,
01373a5c
PB
910};
911
912static struct dib7000p_config dib7070p_dib7000p_config = {
913 .output_mpeg2_in_188_bytes = 1,
914
915 .agc_config_count = 1,
916 .agc = &dib7070_agc_config,
917 .bw = &dib7070_bw_config_12_mhz,
3cb2c39d
PB
918 .tuner_is_baseband = 1,
919 .spur_protect = 1,
01373a5c
PB
920
921 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
922 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
923 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
924
925 .hostbus_diversity = 1,
926};
927
928/* STK7070P */
929static int stk7070p_frontend_attach(struct dvb_usb_adapter *adap)
930{
da5ee486
AV
931 struct usb_device_descriptor *p = &adap->dev->udev->descriptor;
932 if (p->idVendor == cpu_to_le16(USB_VID_PINNACLE) &&
933 p->idProduct == cpu_to_le16(USB_PID_PINNACLE_PCTV72E))
934 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
6ca8f0b9 935 else
da5ee486 936 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
01373a5c
PB
937 msleep(10);
938 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
939 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
940 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
941 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
942
943 dib0700_ctrl_clock(adap->dev, 72, 1);
944
945 msleep(10);
946 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
947 msleep(10);
948 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
949
83c4fdf7
DH
950 if (dib7000p_i2c_enumeration(&adap->dev->i2c_adap, 1, 18,
951 &dib7070p_dib7000p_config) != 0) {
952 err("%s: dib7000p_i2c_enumeration failed. Cannot continue\n",
953 __func__);
954 return -ENODEV;
955 }
01373a5c 956
6ca8f0b9
AC
957 adap->fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 0x80,
958 &dib7070p_dib7000p_config);
01373a5c
PB
959 return adap->fe == NULL ? -ENODEV : 0;
960}
961
90e12cec
OG
962/* STK7770P */
963static struct dib7000p_config dib7770p_dib7000p_config = {
964 .output_mpeg2_in_188_bytes = 1,
965
966 .agc_config_count = 1,
967 .agc = &dib7070_agc_config,
968 .bw = &dib7070_bw_config_12_mhz,
969 .tuner_is_baseband = 1,
970 .spur_protect = 1,
971
972 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
973 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
974 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
975
976 .hostbus_diversity = 1,
977 .enable_current_mirror = 1,
970d14c6 978 .disable_sample_and_hold = 0,
90e12cec
OG
979};
980
981static int stk7770p_frontend_attach(struct dvb_usb_adapter *adap)
982{
983 struct usb_device_descriptor *p = &adap->dev->udev->descriptor;
984 if (p->idVendor == cpu_to_le16(USB_VID_PINNACLE) &&
985 p->idProduct == cpu_to_le16(USB_PID_PINNACLE_PCTV72E))
986 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
987 else
988 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
989 msleep(10);
990 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
991 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
992 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
993 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
994
995 dib0700_ctrl_clock(adap->dev, 72, 1);
996
997 msleep(10);
998 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
999 msleep(10);
1000 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
1001
1002 if (dib7000p_i2c_enumeration(&adap->dev->i2c_adap, 1, 18,
1003 &dib7770p_dib7000p_config) != 0) {
1004 err("%s: dib7000p_i2c_enumeration failed. Cannot continue\n",
1005 __func__);
1006 return -ENODEV;
1007 }
1008
1009 adap->fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 0x80,
1010 &dib7770p_dib7000p_config);
1011 return adap->fe == NULL ? -ENODEV : 0;
1012}
1013
ba3fe3a9
PB
1014/* DIB807x generic */
1015static struct dibx000_agc_config dib807x_agc_config[2] = {
1016 {
1017 BAND_VHF,
1018 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0,
1019 * P_agc_freq_pwm_div=1, P_agc_inv_pwm1=0,
1020 * P_agc_inv_pwm2=0,P_agc_inh_dc_rv_est=0,
1021 * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5,
1022 * P_agc_write=0 */
1023 (0 << 15) | (0 << 14) | (7 << 11) | (0 << 10) | (0 << 9) |
1024 (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) |
1025 (0 << 0), /* setup*/
1026
1027 600, /* inv_gain*/
1028 10, /* time_stabiliz*/
1029
1030 0, /* alpha_level*/
1031 118, /* thlock*/
1032
1033 0, /* wbd_inv*/
1034 3530, /* wbd_ref*/
1035 1, /* wbd_sel*/
1036 5, /* wbd_alpha*/
1037
1038 65535, /* agc1_max*/
1039 0, /* agc1_min*/
1040
1041 65535, /* agc2_max*/
1042 0, /* agc2_min*/
1043
1044 0, /* agc1_pt1*/
1045 40, /* agc1_pt2*/
1046 183, /* agc1_pt3*/
1047 206, /* agc1_slope1*/
1048 255, /* agc1_slope2*/
1049 72, /* agc2_pt1*/
1050 152, /* agc2_pt2*/
1051 88, /* agc2_slope1*/
1052 90, /* agc2_slope2*/
1053
1054 17, /* alpha_mant*/
1055 27, /* alpha_exp*/
1056 23, /* beta_mant*/
1057 51, /* beta_exp*/
1058
1059 0, /* perform_agc_softsplit*/
1060 }, {
1061 BAND_UHF,
1062 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0,
1063 * P_agc_freq_pwm_div=1, P_agc_inv_pwm1=0,
1064 * P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
1065 * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5,
1066 * P_agc_write=0 */
1067 (0 << 15) | (0 << 14) | (1 << 11) | (0 << 10) | (0 << 9) |
1068 (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) |
1069 (0 << 0), /* setup */
1070
1071 600, /* inv_gain*/
1072 10, /* time_stabiliz*/
1073
1074 0, /* alpha_level*/
1075 118, /* thlock*/
1076
1077 0, /* wbd_inv*/
1078 3530, /* wbd_ref*/
1079 1, /* wbd_sel*/
1080 5, /* wbd_alpha*/
1081
1082 65535, /* agc1_max*/
1083 0, /* agc1_min*/
1084
1085 65535, /* agc2_max*/
1086 0, /* agc2_min*/
1087
1088 0, /* agc1_pt1*/
1089 40, /* agc1_pt2*/
1090 183, /* agc1_pt3*/
1091 206, /* agc1_slope1*/
1092 255, /* agc1_slope2*/
1093 72, /* agc2_pt1*/
1094 152, /* agc2_pt2*/
1095 88, /* agc2_slope1*/
1096 90, /* agc2_slope2*/
1097
1098 17, /* alpha_mant*/
1099 27, /* alpha_exp*/
1100 23, /* beta_mant*/
1101 51, /* beta_exp*/
1102
1103 0, /* perform_agc_softsplit*/
1104 }
1105};
1106
1107static struct dibx000_bandwidth_config dib807x_bw_config_12_mhz = {
1108 60000, 15000, /* internal, sampling*/
1109 1, 20, 3, 1, 0, /* pll_cfg: prediv, ratio, range, reset, bypass*/
1110 0, 0, 1, 1, 2, /* misc: refdiv, bypclk_div, IO_CLK_en_core,
1111 ADClkSrc, modulo */
1112 (3 << 14) | (1 << 12) | (599 << 0), /* sad_cfg: refsel, sel, freq_15k*/
1113 (0 << 25) | 0, /* ifreq = 0.000000 MHz*/
1114 18179755, /* timf*/
1115 12000000, /* xtal_hz*/
1116};
1117
1118static struct dib8000_config dib807x_dib8000_config[2] = {
1119 {
1120 .output_mpeg2_in_188_bytes = 1,
1121
1122 .agc_config_count = 2,
1123 .agc = dib807x_agc_config,
1124 .pll = &dib807x_bw_config_12_mhz,
1125 .tuner_is_baseband = 1,
1126
1127 .gpio_dir = DIB8000_GPIO_DEFAULT_DIRECTIONS,
1128 .gpio_val = DIB8000_GPIO_DEFAULT_VALUES,
1129 .gpio_pwm_pos = DIB8000_GPIO_DEFAULT_PWM_POS,
1130
1131 .hostbus_diversity = 1,
1132 .div_cfg = 1,
1133 .agc_control = &dib0070_ctrl_agc_filter,
1134 .output_mode = OUTMODE_MPEG2_FIFO,
1135 .drives = 0x2d98,
1136 }, {
1137 .output_mpeg2_in_188_bytes = 1,
1138
1139 .agc_config_count = 2,
1140 .agc = dib807x_agc_config,
1141 .pll = &dib807x_bw_config_12_mhz,
1142 .tuner_is_baseband = 1,
1143
1144 .gpio_dir = DIB8000_GPIO_DEFAULT_DIRECTIONS,
1145 .gpio_val = DIB8000_GPIO_DEFAULT_VALUES,
1146 .gpio_pwm_pos = DIB8000_GPIO_DEFAULT_PWM_POS,
1147
1148 .hostbus_diversity = 1,
1149 .agc_control = &dib0070_ctrl_agc_filter,
1150 .output_mode = OUTMODE_MPEG2_FIFO,
1151 .drives = 0x2d98,
1152 }
1153};
1154
03245a5e 1155static int dib80xx_tuner_reset(struct dvb_frontend *fe, int onoff)
ba3fe3a9
PB
1156{
1157 return dib8000_set_gpio(fe, 5, 0, !onoff);
1158}
1159
03245a5e 1160static int dib80xx_tuner_sleep(struct dvb_frontend *fe, int onoff)
ba3fe3a9
PB
1161{
1162 return dib8000_set_gpio(fe, 0, 0, onoff);
1163}
1164
1165static const struct dib0070_wbd_gain_cfg dib8070_wbd_gain_cfg[] = {
1166 { 240, 7},
1167 { 0xffff, 6},
1168};
1169
1170static struct dib0070_config dib807x_dib0070_config[2] = {
1171 {
1172 .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
03245a5e
OG
1173 .reset = dib80xx_tuner_reset,
1174 .sleep = dib80xx_tuner_sleep,
ba3fe3a9
PB
1175 .clock_khz = 12000,
1176 .clock_pad_drive = 4,
1177 .vga_filter = 1,
1178 .force_crystal_mode = 1,
1179 .enable_third_order_filter = 1,
1180 .charge_pump = 0,
1181 .wbd_gain = dib8070_wbd_gain_cfg,
1182 .osc_buffer_state = 0,
1183 .freq_offset_khz_uhf = -100,
1184 .freq_offset_khz_vhf = -100,
1185 }, {
1186 .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
03245a5e
OG
1187 .reset = dib80xx_tuner_reset,
1188 .sleep = dib80xx_tuner_sleep,
ba3fe3a9
PB
1189 .clock_khz = 12000,
1190 .clock_pad_drive = 2,
1191 .vga_filter = 1,
1192 .force_crystal_mode = 1,
1193 .enable_third_order_filter = 1,
1194 .charge_pump = 0,
1195 .wbd_gain = dib8070_wbd_gain_cfg,
1196 .osc_buffer_state = 0,
1197 .freq_offset_khz_uhf = -25,
1198 .freq_offset_khz_vhf = -25,
1199 }
1200};
1201
1202static int dib807x_set_param_override(struct dvb_frontend *fe,
1203 struct dvb_frontend_parameters *fep)
1204{
1205 struct dvb_usb_adapter *adap = fe->dvb->priv;
1206 struct dib0700_adapter_state *state = adap->priv;
1207
1208 u16 offset = dib0070_wbd_offset(fe);
1209 u8 band = BAND_OF_FREQUENCY(fep->frequency/1000);
1210 switch (band) {
1211 case BAND_VHF:
1212 offset += 750;
1213 break;
1214 case BAND_UHF: /* fall-thru wanted */
1215 default:
1216 offset += 250; break;
1217 }
1218 deb_info("WBD for DiB8000: %d\n", offset);
1219 dib8000_set_wbd_ref(fe, offset);
1220
1221 return state->set_param_save(fe, fep);
1222}
1223
1224static int dib807x_tuner_attach(struct dvb_usb_adapter *adap)
1225{
1226 struct dib0700_adapter_state *st = adap->priv;
1227 struct i2c_adapter *tun_i2c = dib8000_get_i2c_master(adap->fe,
1228 DIBX000_I2C_INTERFACE_TUNER, 1);
1229
1230 if (adap->id == 0) {
1231 if (dvb_attach(dib0070_attach, adap->fe, tun_i2c,
1232 &dib807x_dib0070_config[0]) == NULL)
1233 return -ENODEV;
1234 } else {
1235 if (dvb_attach(dib0070_attach, adap->fe, tun_i2c,
1236 &dib807x_dib0070_config[1]) == NULL)
1237 return -ENODEV;
1238 }
1239
1240 st->set_param_save = adap->fe->ops.tuner_ops.set_params;
1241 adap->fe->ops.tuner_ops.set_params = dib807x_set_param_override;
1242 return 0;
1243}
1244
9c783036
OG
1245static int stk80xx_pid_filter(struct dvb_usb_adapter *adapter, int index,
1246 u16 pid, int onoff)
f8731f4d 1247{
be9bae10 1248 return dib8000_pid_filter(adapter->fe, index, pid, onoff);
f8731f4d
OG
1249}
1250
9c783036 1251static int stk80xx_pid_filter_ctrl(struct dvb_usb_adapter *adapter,
be9bae10 1252 int onoff)
f8731f4d 1253{
be9bae10 1254 return dib8000_pid_filter_ctrl(adapter->fe, onoff);
f8731f4d 1255}
ba3fe3a9
PB
1256
1257/* STK807x */
1258static int stk807x_frontend_attach(struct dvb_usb_adapter *adap)
1259{
1260 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
1261 msleep(10);
1262 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
1263 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
1264 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
1265
1266 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
1267
1268 dib0700_ctrl_clock(adap->dev, 72, 1);
1269
1270 msleep(10);
1271 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
1272 msleep(10);
1273 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
1274
1275 dib8000_i2c_enumeration(&adap->dev->i2c_adap, 1, 18,
1276 0x80);
1277
1278 adap->fe = dvb_attach(dib8000_attach, &adap->dev->i2c_adap, 0x80,
1279 &dib807x_dib8000_config[0]);
1280
1281 return adap->fe == NULL ? -ENODEV : 0;
1282}
1283
1284/* STK807xPVR */
1285static int stk807xpvr_frontend_attach0(struct dvb_usb_adapter *adap)
1286{
1287 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
1288 msleep(30);
1289 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
1290 msleep(500);
1291 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
1292 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
1293 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
1294
1295 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
1296
1297 dib0700_ctrl_clock(adap->dev, 72, 1);
1298
1299 msleep(10);
1300 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
1301 msleep(10);
1302 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
1303
1304 /* initialize IC 0 */
9542f502 1305 dib8000_i2c_enumeration(&adap->dev->i2c_adap, 1, 0x22, 0x80);
ba3fe3a9
PB
1306
1307 adap->fe = dvb_attach(dib8000_attach, &adap->dev->i2c_adap, 0x80,
1308 &dib807x_dib8000_config[0]);
1309
1310 return adap->fe == NULL ? -ENODEV : 0;
1311}
1312
1313static int stk807xpvr_frontend_attach1(struct dvb_usb_adapter *adap)
1314{
1315 /* initialize IC 1 */
9542f502 1316 dib8000_i2c_enumeration(&adap->dev->i2c_adap, 1, 0x12, 0x82);
ba3fe3a9
PB
1317
1318 adap->fe = dvb_attach(dib8000_attach, &adap->dev->i2c_adap, 0x82,
1319 &dib807x_dib8000_config[1]);
1320
1321 return adap->fe == NULL ? -ENODEV : 0;
1322}
1323
03245a5e
OG
1324/* STK8096GP */
1325struct dibx000_agc_config dib8090_agc_config[2] = {
be9bae10 1326 {
03245a5e 1327 BAND_UHF | BAND_VHF | BAND_LBAND | BAND_SBAND,
9c783036 1328 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=1,
be9bae10
OG
1329 * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
1330 * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5, P_agc_write=0 */
9c783036
OG
1331 (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8)
1332 | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),
1333
1334 787,
1335 10,
1336
1337 0,
1338 118,
1339
1340 0,
1341 3530,
1342 1,
1343 5,
1344
1345 65535,
1346 0,
1347
1348 65535,
1349 0,
1350
1351 0,
1352 32,
1353 114,
1354 143,
1355 144,
1356 114,
1357 227,
1358 116,
1359 117,
1360
1361 28,
1362 26,
1363 31,
1364 51,
1365
1366 0,
be9bae10
OG
1367 },
1368 {
03245a5e 1369 BAND_CBAND,
9c783036 1370 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=1,
be9bae10
OG
1371 * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
1372 * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5, P_agc_write=0 */
9c783036
OG
1373 (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8)
1374 | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),
1375
1376 787,
1377 10,
1378
1379 0,
1380 118,
1381
1382 0,
1383 3530,
1384 1,
1385 5,
1386
1387 0,
1388 0,
1389
1390 65535,
1391 0,
1392
1393 0,
1394 32,
1395 114,
1396 143,
1397 144,
1398 114,
1399 227,
1400 116,
1401 117,
1402
1403 28,
1404 26,
1405 31,
1406 51,
1407
1408 0,
be9bae10 1409 }
03245a5e
OG
1410};
1411
1412static struct dibx000_bandwidth_config dib8090_pll_config_12mhz = {
be9bae10
OG
1413 54000, 13500,
1414 1, 18, 3, 1, 0,
1415 0, 0, 1, 1, 2,
1416 (3 << 14) | (1 << 12) | (599 << 0),
1417 (0 << 25) | 0,
1418 20199727,
1419 12000000,
03245a5e
OG
1420};
1421
1422static int dib8090_get_adc_power(struct dvb_frontend *fe)
1423{
be9bae10
OG
1424 return dib8000_get_adc_power(fe, 1);
1425}
1426
1427static struct dib8000_config dib809x_dib8000_config[2] = {
1428 {
1429 .output_mpeg2_in_188_bytes = 1,
1430
1431 .agc_config_count = 2,
1432 .agc = dib8090_agc_config,
1433 .agc_control = dib0090_dcc_freq,
1434 .pll = &dib8090_pll_config_12mhz,
1435 .tuner_is_baseband = 1,
1436
1437 .gpio_dir = DIB8000_GPIO_DEFAULT_DIRECTIONS,
1438 .gpio_val = DIB8000_GPIO_DEFAULT_VALUES,
1439 .gpio_pwm_pos = DIB8000_GPIO_DEFAULT_PWM_POS,
1440
1441 .hostbus_diversity = 1,
1442 .div_cfg = 0x31,
1443 .output_mode = OUTMODE_MPEG2_FIFO,
1444 .drives = 0x2d98,
1445 .diversity_delay = 48,
1446 .refclksel = 3,
b4d6046e 1447 }, {
be9bae10
OG
1448 .output_mpeg2_in_188_bytes = 1,
1449
1450 .agc_config_count = 2,
1451 .agc = dib8090_agc_config,
1452 .agc_control = dib0090_dcc_freq,
1453 .pll = &dib8090_pll_config_12mhz,
1454 .tuner_is_baseband = 1,
1455
1456 .gpio_dir = DIB8000_GPIO_DEFAULT_DIRECTIONS,
1457 .gpio_val = DIB8000_GPIO_DEFAULT_VALUES,
1458 .gpio_pwm_pos = DIB8000_GPIO_DEFAULT_PWM_POS,
1459
1460 .hostbus_diversity = 1,
1461 .div_cfg = 0x31,
1462 .output_mode = OUTMODE_DIVERSITY,
1463 .drives = 0x2d08,
1464 .diversity_delay = 1,
1465 .refclksel = 3,
1466 }
1467};
1468
1469static struct dib0090_wbd_slope dib8090_wbd_table[] = {
1470 /* max freq ; cold slope ; cold offset ; warm slope ; warm offset ; wbd gain */
1471 { 120, 0, 500, 0, 500, 4 }, /* CBAND */
1472 { 170, 0, 450, 0, 450, 4 }, /* CBAND */
1473 { 380, 48, 373, 28, 259, 6 }, /* VHF */
1474 { 860, 34, 700, 36, 616, 6 }, /* high UHF */
1475 { 0xFFFF, 34, 700, 36, 616, 6 }, /* default */
1476};
1477
1478static struct dib0090_config dib809x_dib0090_config = {
1479 .io.pll_bypass = 1,
1480 .io.pll_range = 1,
1481 .io.pll_prediv = 1,
1482 .io.pll_loopdiv = 20,
1483 .io.adc_clock_ratio = 8,
1484 .io.pll_int_loop_filt = 0,
1485 .io.clock_khz = 12000,
1486 .reset = dib80xx_tuner_reset,
1487 .sleep = dib80xx_tuner_sleep,
1488 .clkouttobamse = 1,
1489 .analog_output = 1,
1490 .i2c_address = DEFAULT_DIB0090_I2C_ADDRESS,
1491 .use_pwm_agc = 1,
1492 .clkoutdrive = 1,
1493 .get_adc_power = dib8090_get_adc_power,
1494 .freq_offset_khz_uhf = -63,
1495 .freq_offset_khz_vhf = -143,
1496 .wbd = dib8090_wbd_table,
1497 .fref_clock_ratio = 6,
1498};
1499
1500static int dib8096_set_param_override(struct dvb_frontend *fe,
1501 struct dvb_frontend_parameters *fep)
1502{
1503 struct dvb_usb_adapter *adap = fe->dvb->priv;
1504 struct dib0700_adapter_state *state = adap->priv;
1505 u8 band = BAND_OF_FREQUENCY(fep->frequency/1000);
1506 u16 target;
1507 int ret = 0;
1508 enum frontend_tune_state tune_state = CT_SHUTDOWN;
1509 u16 ltgain, rf_gain_limit;
1510
1511 ret = state->set_param_save(fe, fep);
1512 if (ret < 0)
1513 return ret;
1514
1515 target = (dib0090_get_wbd_offset(fe) * 8 * 18 / 33 + 1) / 2;
1516 dib8000_set_wbd_ref(fe, target);
1517
1518
1519 if (band == BAND_CBAND) {
b4d6046e
OG
1520 deb_info("tuning in CBAND - soft-AGC startup\n");
1521 dib0090_set_tune_state(fe, CT_AGC_START);
1522 do {
1523 ret = dib0090_gain_control(fe);
1524 msleep(ret);
1525 tune_state = dib0090_get_tune_state(fe);
1526 if (tune_state == CT_AGC_STEP_0)
1527 dib8000_set_gpio(fe, 6, 0, 1);
1528 else if (tune_state == CT_AGC_STEP_1) {
1529 dib0090_get_current_gain(fe, NULL, NULL, &rf_gain_limit, &ltgain);
1530 if (rf_gain_limit == 0)
1531 dib8000_set_gpio(fe, 6, 0, 0);
1532 }
1533 } while (tune_state < CT_AGC_STOP);
1534 dib0090_pwm_gain_reset(fe);
1535 dib8000_pwm_agc_reset(fe);
1536 dib8000_set_tune_state(fe, CT_DEMOD_START);
be9bae10 1537 } else {
b4d6046e
OG
1538 deb_info("not tuning in CBAND - standard AGC startup\n");
1539 dib0090_pwm_gain_reset(fe);
be9bae10
OG
1540 }
1541
1542 return 0;
1543}
1544
1545static int dib809x_tuner_attach(struct dvb_usb_adapter *adap)
1546{
1547 struct dib0700_adapter_state *st = adap->priv;
1548 struct i2c_adapter *tun_i2c = dib8000_get_i2c_master(adap->fe, DIBX000_I2C_INTERFACE_TUNER, 1);
1549
1550 if (dvb_attach(dib0090_register, adap->fe, tun_i2c, &dib809x_dib0090_config) == NULL)
1551 return -ENODEV;
1552
1553 st->set_param_save = adap->fe->ops.tuner_ops.set_params;
1554 adap->fe->ops.tuner_ops.set_params = dib8096_set_param_override;
1555 return 0;
1556}
1557
1558static int stk809x_frontend_attach(struct dvb_usb_adapter *adap)
1559{
1560 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
1561 msleep(10);
1562 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
1563 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
1564 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
1565
1566 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
1567
1568 dib0700_ctrl_clock(adap->dev, 72, 1);
1569
1570 msleep(10);
1571 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
1572 msleep(10);
1573 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
1574
1575 dib8000_i2c_enumeration(&adap->dev->i2c_adap, 1, 18, 0x80);
1576
1577 adap->fe = dvb_attach(dib8000_attach, &adap->dev->i2c_adap, 0x80, &dib809x_dib8000_config[0]);
1578
1579 return adap->fe == NULL ? -ENODEV : 0;
1580}
1581
1582static int nim8096md_tuner_attach(struct dvb_usb_adapter *adap)
1583{
1584 struct dib0700_adapter_state *st = adap->priv;
1585 struct i2c_adapter *tun_i2c;
1586 struct dvb_frontend *fe_slave = dib8000_get_slave_frontend(adap->fe, 1);
1587
1588 if (fe_slave) {
1589 tun_i2c = dib8000_get_i2c_master(fe_slave, DIBX000_I2C_INTERFACE_TUNER, 1);
1590 if (dvb_attach(dib0090_register, fe_slave, tun_i2c, &dib809x_dib0090_config) == NULL)
1591 return -ENODEV;
1592 fe_slave->dvb = adap->fe->dvb;
1593 fe_slave->ops.tuner_ops.set_params = dib8096_set_param_override;
1594 }
1595 tun_i2c = dib8000_get_i2c_master(adap->fe, DIBX000_I2C_INTERFACE_TUNER, 1);
1596 if (dvb_attach(dib0090_register, adap->fe, tun_i2c, &dib809x_dib0090_config) == NULL)
1597 return -ENODEV;
1598
1599 st->set_param_save = adap->fe->ops.tuner_ops.set_params;
1600 adap->fe->ops.tuner_ops.set_params = dib8096_set_param_override;
1601
1602 return 0;
1603}
1604
1605static int nim8096md_frontend_attach(struct dvb_usb_adapter *adap)
1606{
1607 struct dvb_frontend *fe_slave;
1608
1609 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
b4d6046e 1610 msleep(20);
be9bae10
OG
1611 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
1612 msleep(1000);
1613 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
1614 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
1615 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
1616
1617 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
1618
1619 dib0700_ctrl_clock(adap->dev, 72, 1);
1620
b4d6046e 1621 msleep(20);
be9bae10 1622 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
b4d6046e 1623 msleep(20);
be9bae10
OG
1624 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
1625
1626 dib8000_i2c_enumeration(&adap->dev->i2c_adap, 2, 18, 0x80);
1627
1628 adap->fe = dvb_attach(dib8000_attach, &adap->dev->i2c_adap, 0x80, &dib809x_dib8000_config[0]);
1629 if (adap->fe == NULL)
1630 return -ENODEV;
1631
1632 fe_slave = dvb_attach(dib8000_attach, &adap->dev->i2c_adap, 0x82, &dib809x_dib8000_config[1]);
1633 dib8000_set_slave_frontend(adap->fe, fe_slave);
1634
1635 return fe_slave == NULL ? -ENODEV : 0;
1636}
1637
1638/* STK9090M */
1639static int dib90x0_pid_filter(struct dvb_usb_adapter *adapter, int index, u16 pid, int onoff)
1640{
1641 return dib9000_fw_pid_filter(adapter->fe, index, pid, onoff);
1642}
1643
1644static int dib90x0_pid_filter_ctrl(struct dvb_usb_adapter *adapter, int onoff)
1645{
1646 return dib9000_fw_pid_filter_ctrl(adapter->fe, onoff);
1647}
1648
1649static int dib90x0_tuner_reset(struct dvb_frontend *fe, int onoff)
1650{
1651 return dib9000_set_gpio(fe, 5, 0, !onoff);
1652}
1653
1654static int dib90x0_tuner_sleep(struct dvb_frontend *fe, int onoff)
1655{
1656 return dib9000_set_gpio(fe, 0, 0, onoff);
1657}
1658
1659static int dib01x0_pmu_update(struct i2c_adapter *i2c, u16 *data, u8 len)
1660{
1661 u8 wb[4] = { 0xc >> 8, 0xc & 0xff, 0, 0 };
1662 u8 rb[2];
1663 struct i2c_msg msg[2] = {
b4d6046e
OG
1664 {.addr = 0x1e >> 1, .flags = 0, .buf = wb, .len = 2},
1665 {.addr = 0x1e >> 1, .flags = I2C_M_RD, .buf = rb, .len = 2},
be9bae10
OG
1666 };
1667 u8 index_data;
1668
1669 dibx000_i2c_set_speed(i2c, 250);
1670
1671 if (i2c_transfer(i2c, msg, 2) != 2)
1672 return -EIO;
1673
1674 switch (rb[0] << 8 | rb[1]) {
b4d6046e 1675 case 0:
be9bae10
OG
1676 deb_info("Found DiB0170 rev1: This version of DiB0170 is not supported any longer.\n");
1677 return -EIO;
b4d6046e 1678 case 1:
be9bae10
OG
1679 deb_info("Found DiB0170 rev2");
1680 break;
b4d6046e 1681 case 2:
be9bae10
OG
1682 deb_info("Found DiB0190 rev2");
1683 break;
b4d6046e 1684 default:
be9bae10
OG
1685 deb_info("DiB01x0 not found");
1686 return -EIO;
b4d6046e 1687 }
be9bae10
OG
1688
1689 for (index_data = 0; index_data < len; index_data += 2) {
1690 wb[2] = (data[index_data + 1] >> 8) & 0xff;
1691 wb[3] = (data[index_data + 1]) & 0xff;
1692
1693 if (data[index_data] == 0) {
1694 wb[0] = (data[index_data] >> 8) & 0xff;
1695 wb[1] = (data[index_data]) & 0xff;
1696 msg[0].len = 2;
1697 if (i2c_transfer(i2c, msg, 2) != 2)
1698 return -EIO;
1699 wb[2] |= rb[0];
1700 wb[3] |= rb[1] & ~(3 << 4);
1701 }
1702
b4d6046e
OG
1703 wb[0] = (data[index_data] >> 8)&0xff;
1704 wb[1] = (data[index_data])&0xff;
be9bae10
OG
1705 msg[0].len = 4;
1706 if (i2c_transfer(i2c, &msg[0], 1) != 1)
1707 return -EIO;
1708 }
1709 return 0;
1710}
1711
1712static struct dib9000_config stk9090m_config = {
1713 .output_mpeg2_in_188_bytes = 1,
1714 .output_mode = OUTMODE_MPEG2_FIFO,
1715 .vcxo_timer = 279620,
1716 .timing_frequency = 20452225,
1717 .demod_clock_khz = 60000,
1718 .xtal_clock_khz = 30000,
1719 .if_drives = (0 << 15) | (1 << 13) | (0 << 12) | (3 << 10) | (0 << 9) | (1 << 7) | (0 << 6) | (0 << 4) | (1 << 3) | (1 << 1) | (0),
1720 .subband = {
1721 2,
1722 {
1723 { 240, { BOARD_GPIO_COMPONENT_DEMOD, BOARD_GPIO_FUNCTION_SUBBAND_GPIO, 0x0008, 0x0000, 0x0008 } }, /* GPIO 3 to 1 for VHF */
1724 { 890, { BOARD_GPIO_COMPONENT_DEMOD, BOARD_GPIO_FUNCTION_SUBBAND_GPIO, 0x0008, 0x0000, 0x0000 } }, /* GPIO 3 to 0 for UHF */
1725 { 0 },
1726 },
1727 },
1728 .gpio_function = {
1729 { .component = BOARD_GPIO_COMPONENT_DEMOD, .function = BOARD_GPIO_FUNCTION_COMPONENT_ON, .mask = 0x10 | 0x21, .direction = 0 & ~0x21, .value = (0x10 & ~0x1) | 0x20 },
1730 { .component = BOARD_GPIO_COMPONENT_DEMOD, .function = BOARD_GPIO_FUNCTION_COMPONENT_OFF, .mask = 0x10 | 0x21, .direction = 0 & ~0x21, .value = 0 | 0x21 },
1731 },
1732};
1733
1734static struct dib9000_config nim9090md_config[2] = {
1735 {
1736 .output_mpeg2_in_188_bytes = 1,
1737 .output_mode = OUTMODE_MPEG2_FIFO,
1738 .vcxo_timer = 279620,
1739 .timing_frequency = 20452225,
1740 .demod_clock_khz = 60000,
1741 .xtal_clock_khz = 30000,
1742 .if_drives = (0 << 15) | (1 << 13) | (0 << 12) | (3 << 10) | (0 << 9) | (1 << 7) | (0 << 6) | (0 << 4) | (1 << 3) | (1 << 1) | (0),
1743 }, {
1744 .output_mpeg2_in_188_bytes = 1,
1745 .output_mode = OUTMODE_DIVERSITY,
1746 .vcxo_timer = 279620,
1747 .timing_frequency = 20452225,
1748 .demod_clock_khz = 60000,
1749 .xtal_clock_khz = 30000,
1750 .if_drives = (0 << 15) | (1 << 13) | (0 << 12) | (3 << 10) | (0 << 9) | (1 << 7) | (0 << 6) | (0 << 4) | (1 << 3) | (1 << 1) | (0),
1751 .subband = {
1752 2,
1753 {
1754 { 240, { BOARD_GPIO_COMPONENT_DEMOD, BOARD_GPIO_FUNCTION_SUBBAND_GPIO, 0x0006, 0x0000, 0x0006 } }, /* GPIO 1 and 2 to 1 for VHF */
1755 { 890, { BOARD_GPIO_COMPONENT_DEMOD, BOARD_GPIO_FUNCTION_SUBBAND_GPIO, 0x0006, 0x0000, 0x0000 } }, /* GPIO 1 and 2 to 0 for UHF */
1756 { 0 },
1757 },
1758 },
1759 .gpio_function = {
1760 { .component = BOARD_GPIO_COMPONENT_DEMOD, .function = BOARD_GPIO_FUNCTION_COMPONENT_ON, .mask = 0x10 | 0x21, .direction = 0 & ~0x21, .value = (0x10 & ~0x1) | 0x20 },
1761 { .component = BOARD_GPIO_COMPONENT_DEMOD, .function = BOARD_GPIO_FUNCTION_COMPONENT_OFF, .mask = 0x10 | 0x21, .direction = 0 & ~0x21, .value = 0 | 0x21 },
1762 },
1763 }
1764};
1765
1766static struct dib0090_config dib9090_dib0090_config = {
1767 .io.pll_bypass = 0,
1768 .io.pll_range = 1,
1769 .io.pll_prediv = 1,
1770 .io.pll_loopdiv = 8,
1771 .io.adc_clock_ratio = 8,
1772 .io.pll_int_loop_filt = 0,
1773 .io.clock_khz = 30000,
1774 .reset = dib90x0_tuner_reset,
1775 .sleep = dib90x0_tuner_sleep,
1776 .clkouttobamse = 0,
1777 .analog_output = 0,
1778 .use_pwm_agc = 0,
1779 .clkoutdrive = 0,
1780 .freq_offset_khz_uhf = 0,
1781 .freq_offset_khz_vhf = 0,
1782};
1783
1784static struct dib0090_config nim9090md_dib0090_config[2] = {
1785 {
1786 .io.pll_bypass = 0,
1787 .io.pll_range = 1,
1788 .io.pll_prediv = 1,
1789 .io.pll_loopdiv = 8,
1790 .io.adc_clock_ratio = 8,
1791 .io.pll_int_loop_filt = 0,
1792 .io.clock_khz = 30000,
1793 .reset = dib90x0_tuner_reset,
1794 .sleep = dib90x0_tuner_sleep,
1795 .clkouttobamse = 1,
1796 .analog_output = 0,
1797 .use_pwm_agc = 0,
1798 .clkoutdrive = 0,
1799 .freq_offset_khz_uhf = 0,
1800 .freq_offset_khz_vhf = 0,
b4d6046e 1801 }, {
be9bae10
OG
1802 .io.pll_bypass = 0,
1803 .io.pll_range = 1,
1804 .io.pll_prediv = 1,
1805 .io.pll_loopdiv = 8,
1806 .io.adc_clock_ratio = 8,
1807 .io.pll_int_loop_filt = 0,
1808 .io.clock_khz = 30000,
1809 .reset = dib90x0_tuner_reset,
1810 .sleep = dib90x0_tuner_sleep,
1811 .clkouttobamse = 0,
1812 .analog_output = 0,
1813 .use_pwm_agc = 0,
1814 .clkoutdrive = 0,
1815 .freq_offset_khz_uhf = 0,
1816 .freq_offset_khz_vhf = 0,
1817 }
1818};
1819
1820
1821static int stk9090m_frontend_attach(struct dvb_usb_adapter *adap)
1822{
1823 struct dib0700_adapter_state *state = adap->priv;
1824 struct dib0700_state *st = adap->dev->priv;
1825 u32 fw_version;
1826
1827 /* Make use of the new i2c functions from FW 1.20 */
1828 dib0700_get_version(adap->dev, NULL, NULL, &fw_version, NULL);
1829 if (fw_version >= 0x10200)
1830 st->fw_use_new_i2c_api = 1;
1831 dib0700_set_i2c_speed(adap->dev, 340);
1832
1833 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
b4d6046e 1834 msleep(20);
be9bae10
OG
1835 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
1836 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
1837 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
1838 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
1839
1840 dib0700_ctrl_clock(adap->dev, 72, 1);
1841
b4d6046e 1842 msleep(20);
be9bae10 1843 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
b4d6046e 1844 msleep(20);
be9bae10
OG
1845 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
1846
1847 dib9000_i2c_enumeration(&adap->dev->i2c_adap, 1, 0x10, 0x80);
1848
1849 if (request_firmware(&state->frontend_firmware, "dib9090.fw", &adap->dev->udev->dev)) {
1850 deb_info("%s: Upload failed. (file not found?)\n", __func__);
1851 return -ENODEV;
1852 } else {
1853 deb_info("%s: firmware read %Zu bytes.\n", __func__, state->frontend_firmware->size);
1854 }
1855 stk9090m_config.microcode_B_fe_size = state->frontend_firmware->size;
1856 stk9090m_config.microcode_B_fe_buffer = state->frontend_firmware->data;
1857
1858 adap->fe = dvb_attach(dib9000_attach, &adap->dev->i2c_adap, 0x80, &stk9090m_config);
1859
1860 return adap->fe == NULL ? -ENODEV : 0;
1861}
1862
1863static int dib9090_tuner_attach(struct dvb_usb_adapter *adap)
1864{
1865 struct dib0700_adapter_state *state = adap->priv;
1866 struct i2c_adapter *i2c = dib9000_get_tuner_interface(adap->fe);
1867 u16 data_dib190[10] = {
1868 1, 0x1374,
1869 2, 0x01a2,
1870 7, 0x0020,
1871 0, 0x00ef,
1872 8, 0x0486,
1873 };
1874
1875 if (dvb_attach(dib0090_fw_register, adap->fe, i2c, &dib9090_dib0090_config) == NULL)
1876 return -ENODEV;
1877 i2c = dib9000_get_i2c_master(adap->fe, DIBX000_I2C_INTERFACE_GPIO_1_2, 0);
1878 if (dib01x0_pmu_update(i2c, data_dib190, 10) != 0)
1879 return -ENODEV;
1880 dib0700_set_i2c_speed(adap->dev, 2000);
1881 if (dib9000_firmware_post_pll_init(adap->fe) < 0)
1882 return -ENODEV;
b4d6046e 1883 release_firmware(state->frontend_firmware);
be9bae10
OG
1884 return 0;
1885}
1886
1887static int nim9090md_frontend_attach(struct dvb_usb_adapter *adap)
1888{
1889 struct dib0700_adapter_state *state = adap->priv;
1890 struct dib0700_state *st = adap->dev->priv;
1891 struct i2c_adapter *i2c;
1892 struct dvb_frontend *fe_slave;
1893 u32 fw_version;
1894
1895 /* Make use of the new i2c functions from FW 1.20 */
1896 dib0700_get_version(adap->dev, NULL, NULL, &fw_version, NULL);
1897 if (fw_version >= 0x10200)
1898 st->fw_use_new_i2c_api = 1;
1899 dib0700_set_i2c_speed(adap->dev, 340);
1900
1901 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
b4d6046e 1902 msleep(20);
be9bae10
OG
1903 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
1904 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
1905 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
1906 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
1907
1908 dib0700_ctrl_clock(adap->dev, 72, 1);
1909
b4d6046e 1910 msleep(20);
be9bae10 1911 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
b4d6046e 1912 msleep(20);
be9bae10
OG
1913 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
1914
1915 if (request_firmware(&state->frontend_firmware, "dib9090.fw", &adap->dev->udev->dev)) {
1916 deb_info("%s: Upload failed. (file not found?)\n", __func__);
1917 return -EIO;
1918 } else {
1919 deb_info("%s: firmware read %Zu bytes.\n", __func__, state->frontend_firmware->size);
1920 }
1921 nim9090md_config[0].microcode_B_fe_size = state->frontend_firmware->size;
1922 nim9090md_config[0].microcode_B_fe_buffer = state->frontend_firmware->data;
1923 nim9090md_config[1].microcode_B_fe_size = state->frontend_firmware->size;
1924 nim9090md_config[1].microcode_B_fe_buffer = state->frontend_firmware->data;
1925
1926 dib9000_i2c_enumeration(&adap->dev->i2c_adap, 1, 0x20, 0x80);
1927 adap->fe = dvb_attach(dib9000_attach, &adap->dev->i2c_adap, 0x80, &nim9090md_config[0]);
1928
1929 if (adap->fe == NULL)
1930 return -ENODEV;
1931
1932 i2c = dib9000_get_i2c_master(adap->fe, DIBX000_I2C_INTERFACE_GPIO_3_4, 0);
1933 dib9000_i2c_enumeration(i2c, 1, 0x12, 0x82);
1934
1935 fe_slave = dvb_attach(dib9000_attach, i2c, 0x82, &nim9090md_config[1]);
1936 dib9000_set_slave_frontend(adap->fe, fe_slave);
1937
1938 return fe_slave == NULL ? -ENODEV : 0;
03245a5e
OG
1939}
1940
be9bae10
OG
1941static int nim9090md_tuner_attach(struct dvb_usb_adapter *adap)
1942{
1943 struct dib0700_adapter_state *state = adap->priv;
1944 struct i2c_adapter *i2c;
1945 struct dvb_frontend *fe_slave;
1946 u16 data_dib190[10] = {
1947 1, 0x5374,
1948 2, 0x01ae,
1949 7, 0x0020,
1950 0, 0x00ef,
1951 8, 0x0406,
1952 };
1953 i2c = dib9000_get_tuner_interface(adap->fe);
1954 if (dvb_attach(dib0090_fw_register, adap->fe, i2c, &nim9090md_dib0090_config[0]) == NULL)
1955 return -ENODEV;
1956 i2c = dib9000_get_i2c_master(adap->fe, DIBX000_I2C_INTERFACE_GPIO_1_2, 0);
1957 if (dib01x0_pmu_update(i2c, data_dib190, 10) < 0)
1958 return -ENODEV;
1959 dib0700_set_i2c_speed(adap->dev, 2000);
1960 if (dib9000_firmware_post_pll_init(adap->fe) < 0)
1961 return -ENODEV;
1962
1963 fe_slave = dib9000_get_slave_frontend(adap->fe, 1);
1964 if (fe_slave != NULL) {
1965 i2c = dib9000_get_component_bus_interface(adap->fe);
1966 dib9000_set_i2c_adapter(fe_slave, i2c);
1967
1968 i2c = dib9000_get_tuner_interface(fe_slave);
1969 if (dvb_attach(dib0090_fw_register, fe_slave, i2c, &nim9090md_dib0090_config[1]) == NULL)
1970 return -ENODEV;
1971 fe_slave->dvb = adap->fe->dvb;
1972 dib9000_fw_set_component_bus_speed(adap->fe, 2000);
1973 if (dib9000_firmware_post_pll_init(fe_slave) < 0)
1974 return -ENODEV;
1975 }
b4d6046e 1976 release_firmware(state->frontend_firmware);
be9bae10
OG
1977
1978 return 0;
1979}
1980
1981/* NIM7090 */
1982struct dib7090p_best_adc {
1983 u32 timf;
1984 u32 pll_loopdiv;
1985 u32 pll_prediv;
1986};
1987
1988static int dib7090p_get_best_sampling(struct dvb_frontend *fe , struct dib7090p_best_adc *adc)
1989{
1990 u8 spur = 0, prediv = 0, loopdiv = 0, min_prediv = 1, max_prediv = 1;
1991
1992 u16 xtal = 12000;
1993 u32 fcp_min = 1900; /* PLL Minimum Frequency comparator KHz */
1994 u32 fcp_max = 20000; /* PLL Maximum Frequency comparator KHz */
1995 u32 fdem_max = 76000;
1996 u32 fdem_min = 69500;
1997 u32 fcp = 0, fs = 0, fdem = 0;
1998 u32 harmonic_id = 0;
1999
2000 adc->pll_loopdiv = loopdiv;
2001 adc->pll_prediv = prediv;
2002 adc->timf = 0;
2003
2004 deb_info("bandwidth = %d fdem_min =%d", fe->dtv_property_cache.bandwidth_hz, fdem_min);
2005
2006 /* Find Min and Max prediv */
b4d6046e 2007 while ((xtal/max_prediv) >= fcp_min)
be9bae10
OG
2008 max_prediv++;
2009
2010 max_prediv--;
2011 min_prediv = max_prediv;
b4d6046e 2012 while ((xtal/min_prediv) <= fcp_max) {
be9bae10 2013 min_prediv--;
b4d6046e 2014 if (min_prediv == 1)
be9bae10
OG
2015 break;
2016 }
2017 deb_info("MIN prediv = %d : MAX prediv = %d", min_prediv, max_prediv);
2018
2019 min_prediv = 2;
2020
b4d6046e 2021 for (prediv = min_prediv ; prediv < max_prediv; prediv++) {
be9bae10 2022 fcp = xtal / prediv;
b4d6046e
OG
2023 if (fcp > fcp_min && fcp < fcp_max) {
2024 for (loopdiv = 1 ; loopdiv < 64 ; loopdiv++) {
be9bae10
OG
2025 fdem = ((xtal/prediv) * loopdiv);
2026 fs = fdem / 4;
2027 /* test min/max system restrictions */
2028
b4d6046e 2029 if ((fdem >= fdem_min) && (fdem <= fdem_max) && (fs >= fe->dtv_property_cache.bandwidth_hz/1000)) {
be9bae10
OG
2030 spur = 0;
2031 /* test fs harmonics positions */
b4d6046e
OG
2032 for (harmonic_id = (fe->dtv_property_cache.frequency / (1000*fs)) ; harmonic_id <= ((fe->dtv_property_cache.frequency / (1000*fs))+1) ; harmonic_id++) {
2033 if (((fs*harmonic_id) >= ((fe->dtv_property_cache.frequency/1000) - (fe->dtv_property_cache.bandwidth_hz/2000))) && ((fs*harmonic_id) <= ((fe->dtv_property_cache.frequency/1000) + (fe->dtv_property_cache.bandwidth_hz/2000)))) {
be9bae10
OG
2034 spur = 1;
2035 break;
2036 }
2037 }
2038
b4d6046e 2039 if (!spur) {
be9bae10
OG
2040 adc->pll_loopdiv = loopdiv;
2041 adc->pll_prediv = prediv;
b4d6046e
OG
2042 adc->timf = 2396745143UL/fdem*(1 << 9);
2043 adc->timf += ((2396745143UL%fdem) << 9)/fdem;
be9bae10
OG
2044 deb_info("loopdiv=%i prediv=%i timf=%i", loopdiv, prediv, adc->timf);
2045 break;
2046 }
2047 }
2048 }
2049 }
2050 if (!spur)
2051 break;
2052 }
2053
2054
b4d6046e 2055 if (adc->pll_loopdiv == 0 && adc->pll_prediv == 0)
be9bae10 2056 return -EINVAL;
b4d6046e 2057 else
be9bae10
OG
2058 return 0;
2059}
2060
2061static int dib7090_agc_startup(struct dvb_frontend *fe, struct dvb_frontend_parameters *fep)
2062{
2063 struct dvb_usb_adapter *adap = fe->dvb->priv;
2064 struct dib0700_adapter_state *state = adap->priv;
2065 struct dibx000_bandwidth_config pll;
2066 u16 target;
2067 struct dib7090p_best_adc adc;
2068 int ret;
2069
2070 ret = state->set_param_save(fe, fep);
2071 if (ret < 0)
2072 return ret;
2073
2074 memset(&pll, 0, sizeof(struct dibx000_bandwidth_config));
2075 dib0090_pwm_gain_reset(fe);
2076 target = (dib0090_get_wbd_offset(fe) * 8 + 1) / 2;
2077 dib7000p_set_wbd_ref(fe, target);
2078
b4d6046e 2079 if (dib7090p_get_best_sampling(fe, &adc) == 0) {
be9bae10
OG
2080 pll.pll_ratio = adc.pll_loopdiv;
2081 pll.pll_prediv = adc.pll_prediv;
2082
2083 dib7000p_update_pll(fe, &pll);
2084 dib7000p_ctrl_timf(fe, DEMOD_TIMF_SET, adc.timf);
2085 }
2086 return 0;
2087}
2088
2089static struct dib0090_wbd_slope dib7090_wbd_table[] = {
b4d6046e
OG
2090 { 380, 81, 850, 64, 540, 4},
2091 { 860, 51, 866, 21, 375, 4},
2092 {1700, 0, 250, 0, 100, 6},
2093 {2600, 0, 250, 0, 100, 6},
2094 { 0xFFFF, 0, 0, 0, 0, 0},
03245a5e
OG
2095};
2096
be9bae10
OG
2097struct dibx000_agc_config dib7090_agc_config[2] = {
2098 {
2099 .band_caps = BAND_UHF,
2100 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=1, P_agc_inv_pwm1=0, P_agc_inv_pwm2=0,
2101 * 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 */
b4d6046e 2102 .setup = (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),
be9bae10 2103
b4d6046e
OG
2104 .inv_gain = 687,
2105 .time_stabiliz = 10,
be9bae10 2106
b4d6046e
OG
2107 .alpha_level = 0,
2108 .thlock = 118,
be9bae10 2109
b4d6046e
OG
2110 .wbd_inv = 0,
2111 .wbd_ref = 1200,
2112 .wbd_sel = 3,
2113 .wbd_alpha = 5,
be9bae10 2114
b4d6046e
OG
2115 .agc1_max = 65535,
2116 .agc1_min = 0,
be9bae10 2117
b4d6046e
OG
2118 .agc2_max = 65535,
2119 .agc2_min = 0,
be9bae10 2120
b4d6046e
OG
2121 .agc1_pt1 = 0,
2122 .agc1_pt2 = 32,
2123 .agc1_pt3 = 114,
2124 .agc1_slope1 = 143,
2125 .agc1_slope2 = 144,
2126 .agc2_pt1 = 114,
2127 .agc2_pt2 = 227,
2128 .agc2_slope1 = 116,
2129 .agc2_slope2 = 117,
be9bae10 2130
b4d6046e
OG
2131 .alpha_mant = 18,
2132 .alpha_exp = 0,
2133 .beta_mant = 20,
2134 .beta_exp = 59,
be9bae10 2135
b4d6046e 2136 .perform_agc_softsplit = 0,
be9bae10
OG
2137 } , {
2138 .band_caps = BAND_FM | BAND_VHF | BAND_CBAND,
2139 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=1, P_agc_inv_pwm1=0, P_agc_inv_pwm2=0,
2140 * 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 */
b4d6046e 2141 .setup = (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),
be9bae10 2142
b4d6046e
OG
2143 .inv_gain = 732,
2144 .time_stabiliz = 10,
be9bae10 2145
b4d6046e
OG
2146 .alpha_level = 0,
2147 .thlock = 118,
be9bae10 2148
b4d6046e
OG
2149 .wbd_inv = 0,
2150 .wbd_ref = 1200,
2151 .wbd_sel = 3,
2152 .wbd_alpha = 5,
be9bae10 2153
b4d6046e
OG
2154 .agc1_max = 65535,
2155 .agc1_min = 0,
be9bae10 2156
b4d6046e
OG
2157 .agc2_max = 65535,
2158 .agc2_min = 0,
be9bae10 2159
b4d6046e
OG
2160 .agc1_pt1 = 0,
2161 .agc1_pt2 = 0,
2162 .agc1_pt3 = 98,
2163 .agc1_slope1 = 0,
2164 .agc1_slope2 = 167,
7f4d527f 2165 .agc2_pt1 = 98,
b4d6046e
OG
2166 .agc2_pt2 = 255,
2167 .agc2_slope1 = 104,
2168 .agc2_slope2 = 0,
be9bae10 2169
b4d6046e
OG
2170 .alpha_mant = 18,
2171 .alpha_exp = 0,
2172 .beta_mant = 20,
2173 .beta_exp = 59,
be9bae10 2174
b4d6046e 2175 .perform_agc_softsplit = 0,
be9bae10
OG
2176 }
2177};
2178
2179static struct dibx000_bandwidth_config dib7090_clock_config_12_mhz = {
b4d6046e
OG
2180 60000, 15000,
2181 1, 5, 0, 0, 0,
2182 0, 0, 1, 1, 2,
2183 (3 << 14) | (1 << 12) | (524 << 0),
2184 (0 << 25) | 0,
2185 20452225,
2186 15000000,
be9bae10
OG
2187};
2188
2189static struct dib7000p_config nim7090_dib7000p_config = {
2190 .output_mpeg2_in_188_bytes = 1,
2191 .hostbus_diversity = 1,
2192 .tuner_is_baseband = 1,
2193 .update_lna = NULL,
2194
2195 .agc_config_count = 2,
2196 .agc = dib7090_agc_config,
2197
2198 .bw = &dib7090_clock_config_12_mhz,
2199
2200 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
2201 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
2202 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
2203
2204 .pwm_freq_div = 0,
2205
2206 .agc_control = dib7090_agc_restart,
2207
2208 .spur_protect = 0,
2209 .disable_sample_and_hold = 0,
2210 .enable_current_mirror = 0,
2211 .diversity_delay = 0,
2212
2213 .output_mode = OUTMODE_MPEG2_FIFO,
2214 .enMpegOutput = 1,
2215};
2216
2217static struct dib7000p_config tfe7090pvr_dib7000p_config[2] = {
2218 {
2219 .output_mpeg2_in_188_bytes = 1,
2220 .hostbus_diversity = 1,
2221 .tuner_is_baseband = 1,
2222 .update_lna = NULL,
2223
2224 .agc_config_count = 2,
2225 .agc = dib7090_agc_config,
2226
2227 .bw = &dib7090_clock_config_12_mhz,
2228
2229 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
2230 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
2231 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
2232
2233 .pwm_freq_div = 0,
2234
2235 .agc_control = dib7090_agc_restart,
2236
2237 .spur_protect = 0,
2238 .disable_sample_and_hold = 0,
2239 .enable_current_mirror = 0,
2240 .diversity_delay = 0,
2241
2242 .output_mode = OUTMODE_MPEG2_PAR_GATED_CLK,
2243 .default_i2c_addr = 0x90,
2244 .enMpegOutput = 1,
b4d6046e 2245 }, {
be9bae10
OG
2246 .output_mpeg2_in_188_bytes = 1,
2247 .hostbus_diversity = 1,
2248 .tuner_is_baseband = 1,
2249 .update_lna = NULL,
2250
2251 .agc_config_count = 2,
2252 .agc = dib7090_agc_config,
2253
2254 .bw = &dib7090_clock_config_12_mhz,
2255
2256 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
2257 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
2258 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
2259
2260 .pwm_freq_div = 0,
2261
2262 .agc_control = dib7090_agc_restart,
2263
2264 .spur_protect = 0,
2265 .disable_sample_and_hold = 0,
2266 .enable_current_mirror = 0,
2267 .diversity_delay = 0,
2268
2269 .output_mode = OUTMODE_MPEG2_PAR_GATED_CLK,
2270 .default_i2c_addr = 0x92,
2271 .enMpegOutput = 0,
2272 }
2273};
2274
2275static const struct dib0090_config nim7090_dib0090_config = {
2276 .io.clock_khz = 12000,
2277 .io.pll_bypass = 0,
2278 .io.pll_range = 0,
2279 .io.pll_prediv = 3,
2280 .io.pll_loopdiv = 6,
2281 .io.adc_clock_ratio = 0,
2282 .io.pll_int_loop_filt = 0,
2283 .reset = dib7090_tuner_sleep,
2284 .sleep = dib7090_tuner_sleep,
2285
2286 .freq_offset_khz_uhf = 0,
2287 .freq_offset_khz_vhf = 0,
2288
2289 .get_adc_power = dib7090_get_adc_power,
2290
2291 .clkouttobamse = 1,
2292 .analog_output = 0,
2293
2294 .wbd_vhf_offset = 0,
2295 .wbd_cband_offset = 0,
2296 .use_pwm_agc = 1,
2297 .clkoutdrive = 0,
2298
2299 .fref_clock_ratio = 0,
2300
2301 .wbd = dib7090_wbd_table,
2302
2303 .ls_cfg_pad_drv = 0,
2304 .data_tx_drv = 0,
2305 .low_if = NULL,
2306 .in_soc = 1,
2307};
2308
2309static const struct dib0090_config tfe7090pvr_dib0090_config[2] = {
2310 {
2311 .io.clock_khz = 12000,
2312 .io.pll_bypass = 0,
2313 .io.pll_range = 0,
2314 .io.pll_prediv = 3,
2315 .io.pll_loopdiv = 6,
2316 .io.adc_clock_ratio = 0,
2317 .io.pll_int_loop_filt = 0,
2318 .reset = dib7090_tuner_sleep,
2319 .sleep = dib7090_tuner_sleep,
2320
2321 .freq_offset_khz_uhf = 50,
2322 .freq_offset_khz_vhf = 70,
2323
2324 .get_adc_power = dib7090_get_adc_power,
2325
2326 .clkouttobamse = 1,
2327 .analog_output = 0,
2328
2329 .wbd_vhf_offset = 0,
2330 .wbd_cband_offset = 0,
2331 .use_pwm_agc = 1,
2332 .clkoutdrive = 0,
2333
2334 .fref_clock_ratio = 0,
2335
2336 .wbd = dib7090_wbd_table,
2337
2338 .ls_cfg_pad_drv = 0,
2339 .data_tx_drv = 0,
2340 .low_if = NULL,
2341 .in_soc = 1,
b4d6046e 2342 }, {
be9bae10
OG
2343 .io.clock_khz = 12000,
2344 .io.pll_bypass = 0,
2345 .io.pll_range = 0,
2346 .io.pll_prediv = 3,
2347 .io.pll_loopdiv = 6,
2348 .io.adc_clock_ratio = 0,
2349 .io.pll_int_loop_filt = 0,
2350 .reset = dib7090_tuner_sleep,
2351 .sleep = dib7090_tuner_sleep,
2352
2353 .freq_offset_khz_uhf = -50,
2354 .freq_offset_khz_vhf = -70,
2355
2356 .get_adc_power = dib7090_get_adc_power,
2357
2358 .clkouttobamse = 1,
2359 .analog_output = 0,
2360
2361 .wbd_vhf_offset = 0,
2362 .wbd_cband_offset = 0,
2363 .use_pwm_agc = 1,
2364 .clkoutdrive = 0,
2365
2366 .fref_clock_ratio = 0,
2367
2368 .wbd = dib7090_wbd_table,
2369
2370 .ls_cfg_pad_drv = 0,
2371 .data_tx_drv = 0,
2372 .low_if = NULL,
2373 .in_soc = 1,
2374 }
2375};
2376
2377static int nim7090_frontend_attach(struct dvb_usb_adapter *adap)
2378{
2379 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
b4d6046e 2380 msleep(20);
be9bae10
OG
2381 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
2382 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
2383 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
2384 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
2385
b4d6046e 2386 msleep(20);
be9bae10 2387 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
b4d6046e 2388 msleep(20);
be9bae10 2389 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
03245a5e 2390
be9bae10
OG
2391 if (dib7000p_i2c_enumeration(&adap->dev->i2c_adap, 1, 0x10, &nim7090_dib7000p_config) != 0) {
2392 err("%s: dib7000p_i2c_enumeration failed. Cannot continue\n", __func__);
2393 return -ENODEV;
2394 }
2395 adap->fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 0x80, &nim7090_dib7000p_config);
03245a5e 2396
be9bae10 2397 return adap->fe == NULL ? -ENODEV : 0;
03245a5e
OG
2398}
2399
be9bae10 2400static int nim7090_tuner_attach(struct dvb_usb_adapter *adap)
03245a5e 2401{
be9bae10
OG
2402 struct dib0700_adapter_state *st = adap->priv;
2403 struct i2c_adapter *tun_i2c = dib7090_get_i2c_tuner(adap->fe);
2404
2405 if (dvb_attach(dib0090_register, adap->fe, tun_i2c, &nim7090_dib0090_config) == NULL)
2406 return -ENODEV;
03245a5e 2407
be9bae10 2408 dib7000p_set_gpio(adap->fe, 8, 0, 1);
03245a5e 2409
be9bae10
OG
2410 st->set_param_save = adap->fe->ops.tuner_ops.set_params;
2411 adap->fe->ops.tuner_ops.set_params = dib7090_agc_startup;
2412 return 0;
03245a5e
OG
2413}
2414
be9bae10 2415static int tfe7090pvr_frontend0_attach(struct dvb_usb_adapter *adap)
03245a5e 2416{
be9bae10
OG
2417 struct dib0700_state *st = adap->dev->priv;
2418
2419 /* The TFE7090 requires the dib0700 to not be in master mode */
2420 st->disable_streaming_master_mode = 1;
2421
03245a5e 2422 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
b4d6046e 2423 msleep(20);
03245a5e
OG
2424 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
2425 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
2426 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
03245a5e
OG
2427 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
2428
b4d6046e 2429 msleep(20);
03245a5e 2430 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
b4d6046e 2431 msleep(20);
03245a5e
OG
2432 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
2433
be9bae10
OG
2434 /* initialize IC 0 */
2435 if (dib7000p_i2c_enumeration(&adap->dev->i2c_adap, 1, 0x20, &tfe7090pvr_dib7000p_config[0]) != 0) {
2436 err("%s: dib7000p_i2c_enumeration failed. Cannot continue\n", __func__);
2437 return -ENODEV;
2438 }
03245a5e 2439
be9bae10
OG
2440 dib0700_set_i2c_speed(adap->dev, 340);
2441 adap->fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 0x90, &tfe7090pvr_dib7000p_config[0]);
be9bae10
OG
2442 if (adap->fe == NULL)
2443 return -ENODEV;
2444
71682520
PB
2445 dib7090_slave_reset(adap->fe);
2446
be9bae10
OG
2447 return 0;
2448}
2449
2450static int tfe7090pvr_frontend1_attach(struct dvb_usb_adapter *adap)
2451{
2452 struct i2c_adapter *i2c;
2453
2454 if (adap->dev->adapter[0].fe == NULL) {
2455 err("the master dib7090 has to be initialized first");
2456 return -ENODEV; /* the master device has not been initialized */
2457 }
2458
2459 i2c = dib7000p_get_i2c_master(adap->dev->adapter[0].fe, DIBX000_I2C_INTERFACE_GPIO_6_7, 1);
2460 if (dib7000p_i2c_enumeration(i2c, 1, 0x10, &tfe7090pvr_dib7000p_config[1]) != 0) {
2461 err("%s: dib7000p_i2c_enumeration failed. Cannot continue\n", __func__);
2462 return -ENODEV;
2463 }
2464
2465 adap->fe = dvb_attach(dib7000p_attach, i2c, 0x92, &tfe7090pvr_dib7000p_config[1]);
2466 dib0700_set_i2c_speed(adap->dev, 200);
2467
2468 return adap->fe == NULL ? -ENODEV : 0;
2469}
2470
2471static int tfe7090pvr_tuner0_attach(struct dvb_usb_adapter *adap)
2472{
2473 struct dib0700_adapter_state *st = adap->priv;
2474 struct i2c_adapter *tun_i2c = dib7090_get_i2c_tuner(adap->fe);
2475
2476 if (dvb_attach(dib0090_register, adap->fe, tun_i2c, &tfe7090pvr_dib0090_config[0]) == NULL)
2477 return -ENODEV;
2478
2479 dib7000p_set_gpio(adap->fe, 8, 0, 1);
2480
2481 st->set_param_save = adap->fe->ops.tuner_ops.set_params;
2482 adap->fe->ops.tuner_ops.set_params = dib7090_agc_startup;
2483 return 0;
2484}
2485
2486static int tfe7090pvr_tuner1_attach(struct dvb_usb_adapter *adap)
2487{
2488 struct dib0700_adapter_state *st = adap->priv;
2489 struct i2c_adapter *tun_i2c = dib7090_get_i2c_tuner(adap->fe);
2490
2491 if (dvb_attach(dib0090_register, adap->fe, tun_i2c, &tfe7090pvr_dib0090_config[1]) == NULL)
2492 return -ENODEV;
2493
2494 dib7000p_set_gpio(adap->fe, 8, 0, 1);
2495
2496 st->set_param_save = adap->fe->ops.tuner_ops.set_params;
2497 adap->fe->ops.tuner_ops.set_params = dib7090_agc_startup;
2498 return 0;
03245a5e 2499}
ba3fe3a9 2500
01373a5c
PB
2501/* STK7070PD */
2502static struct dib7000p_config stk7070pd_dib7000p_config[2] = {
2503 {
2504 .output_mpeg2_in_188_bytes = 1,
2505
2506 .agc_config_count = 1,
2507 .agc = &dib7070_agc_config,
2508 .bw = &dib7070_bw_config_12_mhz,
3cb2c39d
PB
2509 .tuner_is_baseband = 1,
2510 .spur_protect = 1,
01373a5c
PB
2511
2512 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
2513 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
2514 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
2515
2516 .hostbus_diversity = 1,
2517 }, {
2518 .output_mpeg2_in_188_bytes = 1,
2519
2520 .agc_config_count = 1,
2521 .agc = &dib7070_agc_config,
2522 .bw = &dib7070_bw_config_12_mhz,
3cb2c39d
PB
2523 .tuner_is_baseband = 1,
2524 .spur_protect = 1,
01373a5c
PB
2525
2526 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
2527 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
2528 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
2529
2530 .hostbus_diversity = 1,
2531 }
2532};
2533
2534static int stk7070pd_frontend_attach0(struct dvb_usb_adapter *adap)
2535{
2536 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
2537 msleep(10);
2538 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
2539 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
2540 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
2541 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
2542
2543 dib0700_ctrl_clock(adap->dev, 72, 1);
2544
2545 msleep(10);
2546 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
2547 msleep(10);
2548 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
2549
83c4fdf7
DH
2550 if (dib7000p_i2c_enumeration(&adap->dev->i2c_adap, 2, 18,
2551 stk7070pd_dib7000p_config) != 0) {
2552 err("%s: dib7000p_i2c_enumeration failed. Cannot continue\n",
2553 __func__);
2554 return -ENODEV;
2555 }
01373a5c
PB
2556
2557 adap->fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 0x80, &stk7070pd_dib7000p_config[0]);
2558 return adap->fe == NULL ? -ENODEV : 0;
2559}
2560
2561static int stk7070pd_frontend_attach1(struct dvb_usb_adapter *adap)
2562{
2563 adap->fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 0x82, &stk7070pd_dib7000p_config[1]);
2564 return adap->fe == NULL ? -ENODEV : 0;
2565}
2566
cb22cb52
DH
2567/* S5H1411 */
2568static struct s5h1411_config pinnacle_801e_config = {
2569 .output_mode = S5H1411_PARALLEL_OUTPUT,
2570 .gpio = S5H1411_GPIO_OFF,
2571 .mpeg_timing = S5H1411_MPEGTIMING_NONCONTINOUS_NONINVERTING_CLOCK,
2572 .qam_if = S5H1411_IF_44000,
2573 .vsb_if = S5H1411_IF_44000,
2574 .inversion = S5H1411_INVERSION_OFF,
2575 .status_mode = S5H1411_DEMODLOCKING
2576};
2577
2578/* Pinnacle PCTV HD Pro 801e GPIOs map:
2579 GPIO0 - currently unknown
2580 GPIO1 - xc5000 tuner reset
2581 GPIO2 - CX25843 sleep
2582 GPIO3 - currently unknown
2583 GPIO4 - currently unknown
2584 GPIO6 - currently unknown
2585 GPIO7 - currently unknown
2586 GPIO9 - currently unknown
2587 GPIO10 - CX25843 reset
2588 */
2589static int s5h1411_frontend_attach(struct dvb_usb_adapter *adap)
2590{
2591 struct dib0700_state *st = adap->dev->priv;
2592
2593 /* Make use of the new i2c functions from FW 1.20 */
2594 st->fw_use_new_i2c_api = 1;
2595
2596 /* The s5h1411 requires the dib0700 to not be in master mode */
2597 st->disable_streaming_master_mode = 1;
2598
2599 /* All msleep values taken from Windows USB trace */
2600 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 0);
2601 dib0700_set_gpio(adap->dev, GPIO3, GPIO_OUT, 0);
2602 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
2603 msleep(400);
2604 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
2605 msleep(60);
2606 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
2607 msleep(30);
2608 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
2609 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
2610 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
2611 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
2612 dib0700_set_gpio(adap->dev, GPIO2, GPIO_OUT, 0);
2613 msleep(30);
2614
2615 /* Put the CX25843 to sleep for now since we're in digital mode */
2616 dib0700_set_gpio(adap->dev, GPIO2, GPIO_OUT, 1);
2617
2618 /* GPIOs are initialized, do the attach */
2619 adap->fe = dvb_attach(s5h1411_attach, &pinnacle_801e_config,
2620 &adap->dev->i2c_adap);
2621 return adap->fe == NULL ? -ENODEV : 0;
2622}
2623
767f3b3b
MK
2624static int dib0700_xc5000_tuner_callback(void *priv, int component,
2625 int command, int arg)
cb22cb52
DH
2626{
2627 struct dvb_usb_adapter *adap = priv;
2628
79025a9e
DH
2629 if (command == XC5000_TUNER_RESET) {
2630 /* Reset the tuner */
2631 dib0700_set_gpio(adap->dev, GPIO1, GPIO_OUT, 0);
f0f4633a 2632 msleep(10);
79025a9e 2633 dib0700_set_gpio(adap->dev, GPIO1, GPIO_OUT, 1);
f0f4633a 2634 msleep(10);
79025a9e
DH
2635 } else {
2636 err("xc5000: unknown tuner callback command: %d\n", command);
2637 return -EINVAL;
2638 }
cb22cb52
DH
2639
2640 return 0;
2641}
2642
2643static struct xc5000_config s5h1411_xc5000_tunerconfig = {
2644 .i2c_address = 0x64,
2645 .if_khz = 5380,
cb22cb52
DH
2646};
2647
2648static int xc5000_tuner_attach(struct dvb_usb_adapter *adap)
2649{
79025a9e
DH
2650 /* FIXME: generalize & move to common area */
2651 adap->fe->callback = dib0700_xc5000_tuner_callback;
2652
cb22cb52 2653 return dvb_attach(xc5000_attach, adap->fe, &adap->dev->i2c_adap,
767f3b3b 2654 &s5h1411_xc5000_tunerconfig)
cb22cb52
DH
2655 == NULL ? -ENODEV : 0;
2656}
2657
ce904bcb
MK
2658static struct lgdt3305_config hcw_lgdt3305_config = {
2659 .i2c_addr = 0x0e,
2660 .mpeg_mode = LGDT3305_MPEG_PARALLEL,
2661 .tpclk_edge = LGDT3305_TPCLK_FALLING_EDGE,
2662 .tpvalid_polarity = LGDT3305_TP_VALID_LOW,
2663 .deny_i2c_rptr = 0,
2664 .spectral_inversion = 1,
2665 .qam_if_khz = 6000,
2666 .vsb_if_khz = 6000,
2667 .usref_8vsb = 0x0500,
2668};
2669
2670static struct mxl5007t_config hcw_mxl5007t_config = {
2671 .xtal_freq_hz = MxL_XTAL_25_MHZ,
2672 .if_freq_hz = MxL_IF_6_MHZ,
2673 .invert_if = 1,
2674};
2675
2676/* TIGER-ATSC map:
2677 GPIO0 - LNA_CTR (H: LNA power enabled, L: LNA power disabled)
2678 GPIO1 - ANT_SEL (H: VPA, L: MCX)
2679 GPIO4 - SCL2
2680 GPIO6 - EN_TUNER
2681 GPIO7 - SDA2
2682 GPIO10 - DEM_RST
2683
2684 MXL is behind LG's i2c repeater. LG is on SCL2/SDA2 gpios on the DIB
2685 */
2686static int lgdt3305_frontend_attach(struct dvb_usb_adapter *adap)
2687{
2688 struct dib0700_state *st = adap->dev->priv;
2689
2690 /* Make use of the new i2c functions from FW 1.20 */
2691 st->fw_use_new_i2c_api = 1;
2692
2693 st->disable_streaming_master_mode = 1;
2694
2695 /* fe power enable */
2696 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
2697 msleep(30);
2698 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
2699 msleep(30);
2700
2701 /* demod reset */
2702 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
2703 msleep(30);
2704 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
2705 msleep(30);
2706 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
2707 msleep(30);
2708
2709 adap->fe = dvb_attach(lgdt3305_attach,
2710 &hcw_lgdt3305_config,
2711 &adap->dev->i2c_adap);
2712
2713 return adap->fe == NULL ? -ENODEV : 0;
2714}
2715
2716static int mxl5007t_tuner_attach(struct dvb_usb_adapter *adap)
2717{
2718 return dvb_attach(mxl5007t_attach, adap->fe,
2719 &adap->dev->i2c_adap, 0x60,
2720 &hcw_mxl5007t_config) == NULL ? -ENODEV : 0;
2721}
2722
2723
01373a5c 2724/* DVB-USB and USB stuff follows */
b7f54910 2725struct usb_device_id dib0700_usb_id_table[] = {
01373a5c 2726/* 0 */ { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7700P) },
6ca8f0b9
AC
2727 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7700P_PC) },
2728 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_500) },
2729 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_500_2) },
2730 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_STICK) },
01373a5c 2731/* 5 */ { USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR) },
6ca8f0b9
AC
2732 { USB_DEVICE(USB_VID_COMPRO, USB_PID_COMPRO_VIDEOMATE_U500) },
2733 { USB_DEVICE(USB_VID_UNIWILL, USB_PID_UNIWILL_STK7700P) },
2734 { USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV_DONGLE_STK7700P) },
2735 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_STICK_2) },
01373a5c 2736/* 10 */{ USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR_2) },
6ca8f0b9
AC
2737 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV2000E) },
2738 { USB_DEVICE(USB_VID_TERRATEC,
2739 USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY) },
2740 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_TD_STICK) },
2741 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7700D) },
01373a5c 2742/* 15 */{ USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7070P) },
6ca8f0b9
AC
2743 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV_DVB_T_FLASH) },
2744 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7070PD) },
2745 { USB_DEVICE(USB_VID_PINNACLE,
2746 USB_PID_PINNACLE_PCTV_DUAL_DIVERSITY_DVB_T) },
2747 { USB_DEVICE(USB_VID_COMPRO, USB_PID_COMPRO_VIDEOMATE_U500_PC) },
fa3b877e 2748/* 20 */{ USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_EXPRESS) },
6ca8f0b9
AC
2749 { USB_DEVICE(USB_VID_GIGABYTE, USB_PID_GIGABYTE_U7000) },
2750 { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC, USB_PID_ARTEC_T14BR) },
2751 { USB_DEVICE(USB_VID_ASUS, USB_PID_ASUS_U3000) },
2752 { USB_DEVICE(USB_VID_ASUS, USB_PID_ASUS_U3100) },
2753/* 25 */{ USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_STICK_3) },
2754 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_MYTV_T) },
2755 { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_HT_USB_XE) },
2756 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_EXPRESSCARD_320CX) },
2757 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV72E) },
2758/* 30 */{ USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV73E) },
2759 { USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_EC372S) },
2760 { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_HT_EXPRESS) },
dc88807e 2761 { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_XXS) },
5da4e2c6 2762 { USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV_DONGLE_STK7700P_2) },
af2a887c 2763/* 35 */{ USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_TD_STICK_52009) },
9a0c04a1 2764 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_500_3) },
17a370bc 2765 { USB_DEVICE(USB_VID_GIGABYTE, USB_PID_GIGABYTE_U8000) },
8751aaa6 2766 { USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_STK7700PH) },
5769743a 2767 { USB_DEVICE(USB_VID_ASUS, USB_PID_ASUS_U3000H) },
cb22cb52 2768/* 40 */{ USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV801E) },
d2fc3bfc 2769 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV801E_SE) },
bb1b082e 2770 { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_EXPRESS) },
db4b2d19
NF
2771 { USB_DEVICE(USB_VID_TERRATEC,
2772 USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY_2) },
0a6e1ed2 2773 { USB_DEVICE(USB_VID_SONY, USB_PID_SONY_PLAYTV) },
9abb6e6f 2774/* 45 */{ USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_PD378S) },
ce904bcb
MK
2775 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_TIGER_ATSC) },
2776 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_TIGER_ATSC_B210) },
16ba1ee5 2777 { USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_MC770) },
919a5488 2778 { USB_DEVICE(USB_VID_ELGATO, USB_PID_ELGATO_EYETV_DTT) },
513846ec 2779/* 50 */{ USB_DEVICE(USB_VID_ELGATO, USB_PID_ELGATO_EYETV_DTT_Dlx) },
f0f4ae76 2780 { USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV_DONGLE_H) },
a9b8fe30
PB
2781 { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_T3) },
2782 { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_T5) },
c53d83cc 2783 { USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_STK7700D) },
74b76f21
OG
2784/* 55 */{ USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_STK7700D_2) },
2785 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV73A) },
e414753c
PB
2786 { USB_DEVICE(USB_VID_PCTV, USB_PID_PINNACLE_PCTV73ESE) },
2787 { USB_DEVICE(USB_VID_PCTV, USB_PID_PINNACLE_PCTV282E) },
d300bd69 2788 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7770P) },
db48138f 2789/* 60 */{ USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_XXS_2) },
ba3fe3a9
PB
2790 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK807XPVR) },
2791 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK807XP) },
3bfb317f 2792 { USB_DEVICE_VER(USB_VID_PIXELVIEW, USB_PID_PIXELVIEW_SBTVD, 0x000, 0x3f00) },
8a378e85 2793 { USB_DEVICE(USB_VID_EVOLUTEPC, USB_PID_TVWAY_PLUS) },
20232c47 2794/* 65 */{ USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV73ESE) },
e414753c 2795 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV282E) },
03245a5e 2796 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK8096GP) },
84e2f037 2797 { USB_DEVICE(USB_VID_ELGATO, USB_PID_ELGATO_EYETV_DIVERSITY) },
be9bae10
OG
2798 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_NIM9090M) },
2799/* 70 */{ USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_NIM8096MD) },
2800 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_NIM9090MD) },
2801 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_NIM7090) },
2802 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_TFE7090PVR) },
498e677c 2803 { USB_DEVICE(USB_VID_TECHNISAT, USB_PID_TECHNISAT_AIRSTAR_TELESTICK_2) },
d1402307 2804/* 75 */{ USB_DEVICE(USB_VID_MEDION, USB_PID_CREATIX_CTX1921) },
6ca8f0b9 2805 { 0 } /* Terminating entry */
b7f54910
PB
2806};
2807MODULE_DEVICE_TABLE(usb, dib0700_usb_id_table);
2808
2809#define DIB0700_DEFAULT_DEVICE_PROPERTIES \
2810 .caps = DVB_USB_IS_AN_I2C_ADAPTER, \
2811 .usb_ctrl = DEVICE_SPECIFIC, \
bdc203e1 2812 .firmware = "dvb-usb-dib0700-1.20.fw", \
b7f54910 2813 .download_firmware = dib0700_download_firmware, \
6958effe 2814 .no_reconnect = 1, \
b7f54910 2815 .size_of_priv = sizeof(struct dib0700_state), \
6958effe
PB
2816 .i2c_algo = &dib0700_i2c_algo, \
2817 .identify_state = dib0700_identify_state
b7f54910
PB
2818
2819#define DIB0700_DEFAULT_STREAMING_CONFIG(ep) \
2820 .streaming_ctrl = dib0700_streaming_ctrl, \
2821 .stream = { \
2822 .type = USB_BULK, \
2823 .count = 4, \
2824 .endpoint = ep, \
2825 .u = { \
2826 .bulk = { \
2827 .buffersize = 39480, \
2828 } \
2829 } \
2830 }
2831
2832struct dvb_usb_device_properties dib0700_devices[] = {
2833 {
2834 DIB0700_DEFAULT_DEVICE_PROPERTIES,
2835
2836 .num_adapters = 1,
2837 .adapter = {
2838 {
f8731f4d
OG
2839 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
2840 .pid_filter_count = 32,
e192a7cf
OG
2841 .pid_filter = stk7700p_pid_filter,
2842 .pid_filter_ctrl = stk7700p_pid_filter_ctrl,
b7f54910
PB
2843 .frontend_attach = stk7700p_frontend_attach,
2844 .tuner_attach = stk7700p_tuner_attach,
2845
2846 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
2847 },
2848 },
2849
67053a40 2850 .num_device_descs = 8,
b7f54910
PB
2851 .devices = {
2852 { "DiBcom STK7700P reference design",
49a1376c 2853 { &dib0700_usb_id_table[0], &dib0700_usb_id_table[1] },
b7f54910
PB
2854 { NULL },
2855 },
2856 { "Hauppauge Nova-T Stick",
f9aeba45 2857 { &dib0700_usb_id_table[4], &dib0700_usb_id_table[9], NULL },
b7f54910
PB
2858 { NULL },
2859 },
2860 { "AVerMedia AVerTV DVB-T Volar",
ced8feca 2861 { &dib0700_usb_id_table[5], &dib0700_usb_id_table[10] },
b7f54910
PB
2862 { NULL },
2863 },
49a1376c 2864 { "Compro Videomate U500",
1f8ca4b3 2865 { &dib0700_usb_id_table[6], &dib0700_usb_id_table[19] },
49a1376c 2866 { NULL },
0ce215e1
HS
2867 },
2868 { "Uniwill STK7700P based (Hama and others)",
2869 { &dib0700_usb_id_table[7], NULL },
2870 { NULL },
8637a875
MK
2871 },
2872 { "Leadtek Winfast DTV Dongle (STK7700P based)",
1e13c8f0 2873 { &dib0700_usb_id_table[8], &dib0700_usb_id_table[34] },
8637a875 2874 { NULL },
fa3b877e
JS
2875 },
2876 { "AVerMedia AVerTV DVB-T Express",
2877 { &dib0700_usb_id_table[20] },
2878 { NULL },
67053a40 2879 },
67053a40 2880 { "Gigabyte U7000",
2881 { &dib0700_usb_id_table[21], NULL },
2882 { NULL },
49a1376c 2883 }
b1139e35
DS
2884 },
2885
72b39310 2886 .rc.core = {
f72a27b8 2887 .rc_interval = DEFAULT_RC_INTERVAL,
5af935cc 2888 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
0ffd1ab3 2889 .rc_query = dib0700_rc_query_old_firmware,
52b66144
MCC
2890 .allowed_protos = RC_TYPE_RC5 |
2891 RC_TYPE_RC6 |
2892 RC_TYPE_NEC,
d8b4b582 2893 .change_protocol = dib0700_change_protocol,
f72a27b8 2894 },
b7f54910
PB
2895 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
2896
2897 .num_adapters = 2,
2898 .adapter = {
2899 {
2900 .frontend_attach = bristol_frontend_attach,
2901 .tuner_attach = bristol_tuner_attach,
2902
2903 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
2904 }, {
2905 .frontend_attach = bristol_frontend_attach,
2906 .tuner_attach = bristol_tuner_attach,
2907
2908 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
2909 }
2910 },
2911
2912 .num_device_descs = 1,
2913 .devices = {
2914 { "Hauppauge Nova-T 500 Dual DVB-T",
49a1376c 2915 { &dib0700_usb_id_table[2], &dib0700_usb_id_table[3], NULL },
b7f54910
PB
2916 { NULL },
2917 },
82f3d559
JG
2918 },
2919
72b39310 2920 .rc.core = {
f72a27b8 2921 .rc_interval = DEFAULT_RC_INTERVAL,
5af935cc 2922 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
0ffd1ab3 2923 .rc_query = dib0700_rc_query_old_firmware,
52b66144
MCC
2924 .allowed_protos = RC_TYPE_RC5 |
2925 RC_TYPE_RC6 |
2926 RC_TYPE_NEC,
d8b4b582 2927 .change_protocol = dib0700_change_protocol,
f72a27b8 2928 },
54d75eba
OD
2929 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
2930
2931 .num_adapters = 2,
2932 .adapter = {
2933 {
f8731f4d
OG
2934 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
2935 .pid_filter_count = 32,
2936 .pid_filter = stk70x0p_pid_filter,
2937 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
54d75eba
OD
2938 .frontend_attach = stk7700d_frontend_attach,
2939 .tuner_attach = stk7700d_tuner_attach,
2940
2941 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
2942 }, {
f8731f4d
OG
2943 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
2944 .pid_filter_count = 32,
2945 .pid_filter = stk70x0p_pid_filter,
2946 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
54d75eba
OD
2947 .frontend_attach = stk7700d_frontend_attach,
2948 .tuner_attach = stk7700d_tuner_attach,
2949
2950 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
2951 }
2952 },
2953
200e861c 2954 .num_device_descs = 5,
54d75eba
OD
2955 .devices = {
2956 { "Pinnacle PCTV 2000e",
2957 { &dib0700_usb_id_table[11], NULL },
2958 { NULL },
2959 },
2960 { "Terratec Cinergy DT XS Diversity",
2961 { &dib0700_usb_id_table[12], NULL },
2962 { NULL },
2963 },
faebb914 2964 { "Hauppauge Nova-TD Stick/Elgato Eye-TV Diversity",
54d75eba
OD
2965 { &dib0700_usb_id_table[13], NULL },
2966 { NULL },
2967 },
01373a5c 2968 { "DiBcom STK7700D reference design",
b6884a17
PB
2969 { &dib0700_usb_id_table[14], NULL },
2970 { NULL },
bb1b082e 2971 },
200e861c
JW
2972 { "YUAN High-Tech DiBcom STK7700D",
2973 { &dib0700_usb_id_table[55], NULL },
2974 { NULL },
2975 },
bb1b082e 2976
54d75eba 2977 },
82f3d559 2978
72b39310 2979 .rc.core = {
f72a27b8 2980 .rc_interval = DEFAULT_RC_INTERVAL,
5af935cc 2981 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
0ffd1ab3 2982 .rc_query = dib0700_rc_query_old_firmware,
52b66144
MCC
2983 .allowed_protos = RC_TYPE_RC5 |
2984 RC_TYPE_RC6 |
2985 RC_TYPE_NEC,
d8b4b582 2986 .change_protocol = dib0700_change_protocol,
f72a27b8 2987 },
132c3188
DG
2988 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
2989
2990 .num_adapters = 1,
2991 .adapter = {
2992 {
f8731f4d
OG
2993 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
2994 .pid_filter_count = 32,
2995 .pid_filter = stk70x0p_pid_filter,
2996 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
132c3188
DG
2997 .frontend_attach = stk7700P2_frontend_attach,
2998 .tuner_attach = stk7700d_tuner_attach,
2999
3000 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
3001 },
3002 },
3003
bb1b082e 3004 .num_device_descs = 3,
132c3188
DG
3005 .devices = {
3006 { "ASUS My Cinema U3000 Mini DVBT Tuner",
3007 { &dib0700_usb_id_table[23], NULL },
3008 { NULL },
3009 },
6ca8f0b9
AC
3010 { "Yuan EC372S",
3011 { &dib0700_usb_id_table[31], NULL },
3012 { NULL },
bb1b082e
YA
3013 },
3014 { "Terratec Cinergy T Express",
3015 { &dib0700_usb_id_table[42], NULL },
3016 { NULL },
6ca8f0b9 3017 }
48aa7391
CR
3018 },
3019
72b39310 3020 .rc.core = {
f72a27b8 3021 .rc_interval = DEFAULT_RC_INTERVAL,
5af935cc 3022 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
72b39310 3023 .module_name = "dib0700",
0ffd1ab3 3024 .rc_query = dib0700_rc_query_old_firmware,
52b66144
MCC
3025 .allowed_protos = RC_TYPE_RC5 |
3026 RC_TYPE_RC6 |
3027 RC_TYPE_NEC,
d8b4b582 3028 .change_protocol = dib0700_change_protocol,
f72a27b8 3029 },
01373a5c
PB
3030 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
3031
3032 .num_adapters = 1,
3033 .adapter = {
3034 {
f8731f4d
OG
3035 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
3036 .pid_filter_count = 32,
3037 .pid_filter = stk70x0p_pid_filter,
3038 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
01373a5c
PB
3039 .frontend_attach = stk7070p_frontend_attach,
3040 .tuner_attach = dib7070p_tuner_attach,
3041
3042 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
3043
3044 .size_of_priv = sizeof(struct dib0700_adapter_state),
3045 },
3046 },
3047
1e13c8f0 3048 .num_device_descs = 11,
01373a5c
PB
3049 .devices = {
3050 { "DiBcom STK7070P reference design",
3051 { &dib0700_usb_id_table[15], NULL },
3052 { NULL },
3053 },
3054 { "Pinnacle PCTV DVB-T Flash Stick",
3055 { &dib0700_usb_id_table[16], NULL },
3056 { NULL },
3057 },
7999a816
YL
3058 { "Artec T14BR DVB-T",
3059 { &dib0700_usb_id_table[22], NULL },
3060 { NULL },
132c3188
DG
3061 },
3062 { "ASUS My Cinema U3100 Mini DVBT Tuner",
3063 { &dib0700_usb_id_table[24], NULL },
3064 { NULL },
3065 },
c7637b1a
TT
3066 { "Hauppauge Nova-T Stick",
3067 { &dib0700_usb_id_table[25], NULL },
3068 { NULL },
3069 },
13b83b5d
DS
3070 { "Hauppauge Nova-T MyTV.t",
3071 { &dib0700_usb_id_table[26], NULL },
3072 { NULL },
3073 },
6ca8f0b9
AC
3074 { "Pinnacle PCTV 72e",
3075 { &dib0700_usb_id_table[29], NULL },
3076 { NULL },
3077 },
3078 { "Pinnacle PCTV 73e",
3079 { &dib0700_usb_id_table[30], NULL },
3080 { NULL },
3081 },
919a5488
KF
3082 { "Elgato EyeTV DTT",
3083 { &dib0700_usb_id_table[49], NULL },
3084 { NULL },
3085 },
9abb6e6f
PT
3086 { "Yuan PD378S",
3087 { &dib0700_usb_id_table[45], NULL },
3088 { NULL },
3089 },
513846ec
AS
3090 { "Elgato EyeTV Dtt Dlx PD378S",
3091 { &dib0700_usb_id_table[50], NULL },
3092 { NULL },
3093 },
c7637b1a
TT
3094 },
3095
72b39310 3096 .rc.core = {
f72a27b8 3097 .rc_interval = DEFAULT_RC_INTERVAL,
5af935cc 3098 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
72b39310 3099 .module_name = "dib0700",
0ffd1ab3 3100 .rc_query = dib0700_rc_query_old_firmware,
52b66144
MCC
3101 .allowed_protos = RC_TYPE_RC5 |
3102 RC_TYPE_RC6 |
3103 RC_TYPE_NEC,
d8b4b582 3104 .change_protocol = dib0700_change_protocol,
f72a27b8 3105 },
74b76f21
OG
3106 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
3107
3108 .num_adapters = 1,
3109 .adapter = {
3110 {
648732fc
MCC
3111 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
3112 .pid_filter_count = 32,
3113 .pid_filter = stk70x0p_pid_filter,
3114 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
74b76f21
OG
3115 .frontend_attach = stk7070p_frontend_attach,
3116 .tuner_attach = dib7070p_tuner_attach,
3117
3118 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
3119
3120 .size_of_priv = sizeof(struct dib0700_adapter_state),
3121 },
3122 },
3123
20232c47 3124 .num_device_descs = 3,
74b76f21
OG
3125 .devices = {
3126 { "Pinnacle PCTV 73A",
3127 { &dib0700_usb_id_table[56], NULL },
3128 { NULL },
3129 },
3130 { "Pinnacle PCTV 73e SE",
20232c47 3131 { &dib0700_usb_id_table[57], &dib0700_usb_id_table[65], NULL },
74b76f21
OG
3132 { NULL },
3133 },
3134 { "Pinnacle PCTV 282e",
20232c47 3135 { &dib0700_usb_id_table[58], &dib0700_usb_id_table[66], NULL },
74b76f21
OG
3136 { NULL },
3137 },
3138 },
3139
72b39310 3140 .rc.core = {
f72a27b8 3141 .rc_interval = DEFAULT_RC_INTERVAL,
5af935cc 3142 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
72b39310 3143 .module_name = "dib0700",
0ffd1ab3 3144 .rc_query = dib0700_rc_query_old_firmware,
52b66144
MCC
3145 .allowed_protos = RC_TYPE_RC5 |
3146 RC_TYPE_RC6 |
3147 RC_TYPE_NEC,
d8b4b582 3148 .change_protocol = dib0700_change_protocol,
f72a27b8 3149 },
01373a5c
PB
3150 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
3151
3152 .num_adapters = 2,
3153 .adapter = {
3154 {
f8731f4d
OG
3155 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
3156 .pid_filter_count = 32,
3157 .pid_filter = stk70x0p_pid_filter,
3158 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
01373a5c
PB
3159 .frontend_attach = stk7070pd_frontend_attach0,
3160 .tuner_attach = dib7070p_tuner_attach,
3161
3162 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
3163
3164 .size_of_priv = sizeof(struct dib0700_adapter_state),
3165 }, {
f8731f4d
OG
3166 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
3167 .pid_filter_count = 32,
3168 .pid_filter = stk70x0p_pid_filter,
3169 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
01373a5c
PB
3170 .frontend_attach = stk7070pd_frontend_attach1,
3171 .tuner_attach = dib7070p_tuner_attach,
3172
3173 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
3174
3175 .size_of_priv = sizeof(struct dib0700_adapter_state),
3176 }
3177 },
3178
5af935cc 3179 .num_device_descs = 6,
01373a5c
PB
3180 .devices = {
3181 { "DiBcom STK7070PD reference design",
3182 { &dib0700_usb_id_table[17], NULL },
3183 { NULL },
3184 },
3185 { "Pinnacle PCTV Dual DVB-T Diversity Stick",
3186 { &dib0700_usb_id_table[18], NULL },
3187 { NULL },
d01eb2dc
MK
3188 },
3189 { "Hauppauge Nova-TD Stick (52009)",
3190 { &dib0700_usb_id_table[35], NULL },
3191 { NULL },
9a0c04a1
MK
3192 },
3193 { "Hauppauge Nova-TD-500 (84xxx)",
3194 { &dib0700_usb_id_table[36], NULL },
3195 { NULL },
db4b2d19 3196 },
a9b8fe30
PB
3197 { "Terratec Cinergy DT USB XS Diversity/ T5",
3198 { &dib0700_usb_id_table[43],
3199 &dib0700_usb_id_table[53], NULL},
db4b2d19 3200 { NULL },
0a6e1ed2 3201 },
3202 { "Sony PlayTV",
3203 { &dib0700_usb_id_table[44], NULL },
3204 { NULL },
84e2f037 3205 },
5af935cc
MCC
3206 },
3207
3208 .rc.core = {
3209 .rc_interval = DEFAULT_RC_INTERVAL,
3210 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
3211 .module_name = "dib0700",
0ffd1ab3 3212 .rc_query = dib0700_rc_query_old_firmware,
52b66144
MCC
3213 .allowed_protos = RC_TYPE_RC5 |
3214 RC_TYPE_RC6 |
3215 RC_TYPE_NEC,
d8b4b582 3216 .change_protocol = dib0700_change_protocol,
5af935cc
MCC
3217 },
3218 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
3219
3220 .num_adapters = 2,
3221 .adapter = {
3222 {
3223 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
3224 .pid_filter_count = 32,
3225 .pid_filter = stk70x0p_pid_filter,
3226 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
3227 .frontend_attach = stk7070pd_frontend_attach0,
3228 .tuner_attach = dib7070p_tuner_attach,
3229
3230 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
3231
3232 .size_of_priv = sizeof(struct dib0700_adapter_state),
3233 }, {
3234 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
3235 .pid_filter_count = 32,
3236 .pid_filter = stk70x0p_pid_filter,
3237 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
3238 .frontend_attach = stk7070pd_frontend_attach1,
3239 .tuner_attach = dib7070p_tuner_attach,
3240
3241 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
3242
3243 .size_of_priv = sizeof(struct dib0700_adapter_state),
3244 }
3245 },
3246
3247 .num_device_descs = 1,
3248 .devices = {
84e2f037
MM
3249 { "Elgato EyeTV Diversity",
3250 { &dib0700_usb_id_table[68], NULL },
3251 { NULL },
3252 },
c985a8dc 3253 },
f72a27b8 3254
72b39310 3255 .rc.core = {
f72a27b8 3256 .rc_interval = DEFAULT_RC_INTERVAL,
5af935cc 3257 .rc_codes = RC_MAP_DIB0700_NEC_TABLE,
72b39310 3258 .module_name = "dib0700",
0ffd1ab3 3259 .rc_query = dib0700_rc_query_old_firmware,
52b66144
MCC
3260 .allowed_protos = RC_TYPE_RC5 |
3261 RC_TYPE_RC6 |
3262 RC_TYPE_NEC,
d8b4b582 3263 .change_protocol = dib0700_change_protocol,
f72a27b8 3264 },
6ca8f0b9
AC
3265 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
3266
3267 .num_adapters = 1,
3268 .adapter = {
3269 {
f8731f4d
OG
3270 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
3271 .pid_filter_count = 32,
3272 .pid_filter = stk70x0p_pid_filter,
3273 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
6ca8f0b9
AC
3274 .frontend_attach = stk7700ph_frontend_attach,
3275 .tuner_attach = stk7700ph_tuner_attach,
3276
3277 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
3278
3279 .size_of_priv = sizeof(struct
3280 dib0700_adapter_state),
3281 },
3282 },
3283
c53d83cc 3284 .num_device_descs = 9,
6ca8f0b9
AC
3285 .devices = {
3286 { "Terratec Cinergy HT USB XE",
3287 { &dib0700_usb_id_table[27], NULL },
3288 { NULL },
3289 },
3290 { "Pinnacle Expresscard 320cx",
3291 { &dib0700_usb_id_table[28], NULL },
3292 { NULL },
3293 },
3294 { "Terratec Cinergy HT Express",
3295 { &dib0700_usb_id_table[32], NULL },
3296 { NULL },
3297 },
17a370bc
FT
3298 { "Gigabyte U8000-RH",
3299 { &dib0700_usb_id_table[37], NULL },
3300 { NULL },
3301 },
8751aaa6
DON
3302 { "YUAN High-Tech STK7700PH",
3303 { &dib0700_usb_id_table[38], NULL },
3304 { NULL },
3305 },
5769743a
AC
3306 { "Asus My Cinema-U3000Hybrid",
3307 { &dib0700_usb_id_table[39], NULL },
3308 { NULL },
3309 },
16ba1ee5
XL
3310 { "YUAN High-Tech MC770",
3311 { &dib0700_usb_id_table[48], NULL },
3312 { NULL },
3313 },
f0f4ae76 3314 { "Leadtek WinFast DTV Dongle H",
3315 { &dib0700_usb_id_table[51], NULL },
3316 { NULL },
3317 },
c53d83cc
PH
3318 { "YUAN High-Tech STK7700D",
3319 { &dib0700_usb_id_table[54], NULL },
3320 { NULL },
3321 },
6ca8f0b9 3322 },
f72a27b8 3323
72b39310 3324 .rc.core = {
f72a27b8 3325 .rc_interval = DEFAULT_RC_INTERVAL,
5af935cc 3326 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
72b39310 3327 .module_name = "dib0700",
0ffd1ab3 3328 .rc_query = dib0700_rc_query_old_firmware,
52b66144
MCC
3329 .allowed_protos = RC_TYPE_RC5 |
3330 RC_TYPE_RC6 |
3331 RC_TYPE_NEC,
d8b4b582 3332 .change_protocol = dib0700_change_protocol,
f72a27b8 3333 },
cb22cb52
DH
3334 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
3335 .num_adapters = 1,
3336 .adapter = {
3337 {
3338 .frontend_attach = s5h1411_frontend_attach,
3339 .tuner_attach = xc5000_tuner_attach,
3340
3341 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
3342
3343 .size_of_priv = sizeof(struct
3344 dib0700_adapter_state),
3345 },
3346 },
3347
d2fc3bfc 3348 .num_device_descs = 2,
cb22cb52
DH
3349 .devices = {
3350 { "Pinnacle PCTV HD Pro USB Stick",
3351 { &dib0700_usb_id_table[40], NULL },
3352 { NULL },
3353 },
d2fc3bfc
DH
3354 { "Pinnacle PCTV HD USB Stick",
3355 { &dib0700_usb_id_table[41], NULL },
3356 { NULL },
3357 },
cb22cb52 3358 },
72b39310
MCC
3359
3360 .rc.core = {
f72a27b8 3361 .rc_interval = DEFAULT_RC_INTERVAL,
5af935cc 3362 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
72b39310 3363 .module_name = "dib0700",
0ffd1ab3 3364 .rc_query = dib0700_rc_query_old_firmware,
52b66144
MCC
3365 .allowed_protos = RC_TYPE_RC5 |
3366 RC_TYPE_RC6 |
3367 RC_TYPE_NEC,
d8b4b582 3368 .change_protocol = dib0700_change_protocol,
f72a27b8 3369 },
ce904bcb
MK
3370 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
3371 .num_adapters = 1,
3372 .adapter = {
3373 {
3374 .frontend_attach = lgdt3305_frontend_attach,
3375 .tuner_attach = mxl5007t_tuner_attach,
3376
3377 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
3378
3379 .size_of_priv = sizeof(struct
3380 dib0700_adapter_state),
3381 },
3382 },
3383
3384 .num_device_descs = 2,
3385 .devices = {
3386 { "Hauppauge ATSC MiniCard (B200)",
3387 { &dib0700_usb_id_table[46], NULL },
3388 { NULL },
3389 },
3390 { "Hauppauge ATSC MiniCard (B210)",
3391 { &dib0700_usb_id_table[47], NULL },
3392 { NULL },
3393 },
3394 },
d300bd69
OG
3395 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
3396
3397 .num_adapters = 1,
3398 .adapter = {
3399 {
f8731f4d
OG
3400 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
3401 .pid_filter_count = 32,
3402 .pid_filter = stk70x0p_pid_filter,
3403 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
90e12cec 3404 .frontend_attach = stk7770p_frontend_attach,
d300bd69
OG
3405 .tuner_attach = dib7770p_tuner_attach,
3406
3407 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
3408
3409 .size_of_priv =
db48138f 3410 sizeof(struct dib0700_adapter_state),
d300bd69
OG
3411 },
3412 },
3413
d1402307 3414 .num_device_descs = 4,
d300bd69
OG
3415 .devices = {
3416 { "DiBcom STK7770P reference design",
3417 { &dib0700_usb_id_table[59], NULL },
3418 { NULL },
3419 },
1e13c8f0
PB
3420 { "Terratec Cinergy T USB XXS (HD)/ T3",
3421 { &dib0700_usb_id_table[33],
3422 &dib0700_usb_id_table[52],
3423 &dib0700_usb_id_table[60], NULL},
db48138f
PB
3424 { NULL },
3425 },
498e677c
LMF
3426 { "TechniSat AirStar TeleStick 2",
3427 { &dib0700_usb_id_table[74], NULL },
3428 { NULL },
3429 },
d1402307
SE
3430 { "Medion CTX1921 DVB-T USB",
3431 { &dib0700_usb_id_table[75], NULL },
3432 { NULL },
3433 },
d300bd69 3434 },
72b39310
MCC
3435
3436 .rc.core = {
f72a27b8 3437 .rc_interval = DEFAULT_RC_INTERVAL,
5af935cc 3438 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
72b39310 3439 .module_name = "dib0700",
0ffd1ab3 3440 .rc_query = dib0700_rc_query_old_firmware,
52b66144
MCC
3441 .allowed_protos = RC_TYPE_RC5 |
3442 RC_TYPE_RC6 |
3443 RC_TYPE_NEC,
d8b4b582 3444 .change_protocol = dib0700_change_protocol,
f72a27b8 3445 },
ba3fe3a9
PB
3446 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
3447 .num_adapters = 1,
3448 .adapter = {
3449 {
f8731f4d
OG
3450 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
3451 .pid_filter_count = 32,
03245a5e
OG
3452 .pid_filter = stk80xx_pid_filter,
3453 .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
ba3fe3a9
PB
3454 .frontend_attach = stk807x_frontend_attach,
3455 .tuner_attach = dib807x_tuner_attach,
3456
3457 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
3458
3459 .size_of_priv =
3460 sizeof(struct dib0700_adapter_state),
3461 },
3462 },
3463
8a378e85 3464 .num_device_descs = 3,
ba3fe3a9
PB
3465 .devices = {
3466 { "DiBcom STK807xP reference design",
3467 { &dib0700_usb_id_table[62], NULL },
3468 { NULL },
3469 },
aaeab30f
MCC
3470 { "Prolink Pixelview SBTVD",
3471 { &dib0700_usb_id_table[63], NULL },
3472 { NULL },
3473 },
8a378e85
F
3474 { "EvolutePC TVWay+",
3475 { &dib0700_usb_id_table[64], NULL },
3476 { NULL },
3477 },
ba3fe3a9
PB
3478 },
3479
72b39310 3480 .rc.core = {
f72a27b8 3481 .rc_interval = DEFAULT_RC_INTERVAL,
5af935cc 3482 .rc_codes = RC_MAP_DIB0700_NEC_TABLE,
72b39310 3483 .module_name = "dib0700",
0ffd1ab3 3484 .rc_query = dib0700_rc_query_old_firmware,
52b66144
MCC
3485 .allowed_protos = RC_TYPE_RC5 |
3486 RC_TYPE_RC6 |
3487 RC_TYPE_NEC,
d8b4b582 3488 .change_protocol = dib0700_change_protocol,
f72a27b8 3489 },
ba3fe3a9
PB
3490 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
3491 .num_adapters = 2,
3492 .adapter = {
3493 {
f8731f4d
OG
3494 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
3495 .pid_filter_count = 32,
03245a5e
OG
3496 .pid_filter = stk80xx_pid_filter,
3497 .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
ba3fe3a9
PB
3498 .frontend_attach = stk807xpvr_frontend_attach0,
3499 .tuner_attach = dib807x_tuner_attach,
3500
3501 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
3502
3503 .size_of_priv =
3504 sizeof(struct dib0700_adapter_state),
3505 },
3506 {
f8731f4d
OG
3507 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
3508 .pid_filter_count = 32,
03245a5e
OG
3509 .pid_filter = stk80xx_pid_filter,
3510 .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
ba3fe3a9
PB
3511 .frontend_attach = stk807xpvr_frontend_attach1,
3512 .tuner_attach = dib807x_tuner_attach,
3513
3514 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
3515
3516 .size_of_priv =
3517 sizeof(struct dib0700_adapter_state),
3518 },
3519 },
3520
3521 .num_device_descs = 1,
3522 .devices = {
3523 { "DiBcom STK807xPVR reference design",
3524 { &dib0700_usb_id_table[61], NULL },
3525 { NULL },
3526 },
3527 },
3528
72b39310 3529 .rc.core = {
f72a27b8 3530 .rc_interval = DEFAULT_RC_INTERVAL,
5af935cc 3531 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
72b39310 3532 .module_name = "dib0700",
0ffd1ab3 3533 .rc_query = dib0700_rc_query_old_firmware,
52b66144
MCC
3534 .allowed_protos = RC_TYPE_RC5 |
3535 RC_TYPE_RC6 |
3536 RC_TYPE_NEC,
d8b4b582 3537 .change_protocol = dib0700_change_protocol,
f72a27b8 3538 },
03245a5e
OG
3539 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
3540 .num_adapters = 1,
3541 .adapter = {
3542 {
3543 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
3544 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
3545 .pid_filter_count = 32,
3546 .pid_filter = stk80xx_pid_filter,
3547 .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
3548 .frontend_attach = stk809x_frontend_attach,
3549 .tuner_attach = dib809x_tuner_attach,
3550
3551 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
3552
3553 .size_of_priv =
3554 sizeof(struct dib0700_adapter_state),
3555 },
3556 },
3557
3558 .num_device_descs = 1,
3559 .devices = {
3560 { "DiBcom STK8096GP reference design",
3561 { &dib0700_usb_id_table[67], NULL },
3562 { NULL },
3563 },
3564 },
3565
be9bae10
OG
3566 .rc.core = {
3567 .rc_interval = DEFAULT_RC_INTERVAL,
3568 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
3569 .module_name = "dib0700",
3570 .rc_query = dib0700_rc_query_old_firmware,
3571 .allowed_protos = RC_TYPE_RC5 |
3572 RC_TYPE_RC6 |
3573 RC_TYPE_NEC,
3574 .change_protocol = dib0700_change_protocol,
3575 },
3576 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
3577 .num_adapters = 1,
3578 .adapter = {
3579 {
3580 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
3581 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
3582 .pid_filter_count = 32,
3583 .pid_filter = dib90x0_pid_filter,
3584 .pid_filter_ctrl = dib90x0_pid_filter_ctrl,
3585 .frontend_attach = stk9090m_frontend_attach,
3586 .tuner_attach = dib9090_tuner_attach,
3587
3588 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
3589
3590 .size_of_priv =
3591 sizeof(struct dib0700_adapter_state),
3592 },
3593 },
3594
3595 .num_device_descs = 1,
3596 .devices = {
3597 { "DiBcom STK9090M reference design",
3598 { &dib0700_usb_id_table[69], NULL },
3599 { NULL },
3600 },
3601 },
3602
3603 .rc.core = {
3604 .rc_interval = DEFAULT_RC_INTERVAL,
3605 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
3606 .module_name = "dib0700",
3607 .rc_query = dib0700_rc_query_old_firmware,
3608 .allowed_protos = RC_TYPE_RC5 |
3609 RC_TYPE_RC6 |
3610 RC_TYPE_NEC,
3611 .change_protocol = dib0700_change_protocol,
3612 },
3613 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
3614 .num_adapters = 1,
3615 .adapter = {
3616 {
3617 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
3618 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
3619 .pid_filter_count = 32,
3620 .pid_filter = stk80xx_pid_filter,
3621 .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
3622 .frontend_attach = nim8096md_frontend_attach,
3623 .tuner_attach = nim8096md_tuner_attach,
3624
3625 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
3626
3627 .size_of_priv =
3628 sizeof(struct dib0700_adapter_state),
3629 },
3630 },
3631
3632 .num_device_descs = 1,
3633 .devices = {
3634 { "DiBcom NIM8096MD reference design",
3635 { &dib0700_usb_id_table[70], NULL },
3636 { NULL },
3637 },
3638 },
3639
3640 .rc.core = {
3641 .rc_interval = DEFAULT_RC_INTERVAL,
3642 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
3643 .module_name = "dib0700",
3644 .rc_query = dib0700_rc_query_old_firmware,
3645 .allowed_protos = RC_TYPE_RC5 |
3646 RC_TYPE_RC6 |
3647 RC_TYPE_NEC,
3648 .change_protocol = dib0700_change_protocol,
3649 },
3650 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
3651 .num_adapters = 1,
3652 .adapter = {
3653 {
3654 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
3655 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
3656 .pid_filter_count = 32,
3657 .pid_filter = dib90x0_pid_filter,
3658 .pid_filter_ctrl = dib90x0_pid_filter_ctrl,
3659 .frontend_attach = nim9090md_frontend_attach,
3660 .tuner_attach = nim9090md_tuner_attach,
3661
3662 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
3663
3664 .size_of_priv =
3665 sizeof(struct dib0700_adapter_state),
3666 },
3667 },
3668
3669 .num_device_descs = 1,
3670 .devices = {
3671 { "DiBcom NIM9090MD reference design",
3672 { &dib0700_usb_id_table[71], NULL },
3673 { NULL },
3674 },
3675 },
3676
3677 .rc.core = {
3678 .rc_interval = DEFAULT_RC_INTERVAL,
3679 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
3680 .module_name = "dib0700",
3681 .rc_query = dib0700_rc_query_old_firmware,
3682 .allowed_protos = RC_TYPE_RC5 |
3683 RC_TYPE_RC6 |
3684 RC_TYPE_NEC,
3685 .change_protocol = dib0700_change_protocol,
3686 },
3687 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
3688 .num_adapters = 1,
3689 .adapter = {
3690 {
3691 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
3692 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
3693 .pid_filter_count = 32,
3694 .pid_filter = stk70x0p_pid_filter,
3695 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
3696 .frontend_attach = nim7090_frontend_attach,
3697 .tuner_attach = nim7090_tuner_attach,
3698
3699 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
3700
3701 .size_of_priv =
3702 sizeof(struct dib0700_adapter_state),
3703 },
3704 },
3705
3706 .num_device_descs = 1,
3707 .devices = {
3708 { "DiBcom NIM7090 reference design",
3709 { &dib0700_usb_id_table[72], NULL },
3710 { NULL },
3711 },
3712 },
3713
3714 .rc.core = {
3715 .rc_interval = DEFAULT_RC_INTERVAL,
3716 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
3717 .module_name = "dib0700",
3718 .rc_query = dib0700_rc_query_old_firmware,
3719 .allowed_protos = RC_TYPE_RC5 |
3720 RC_TYPE_RC6 |
3721 RC_TYPE_NEC,
3722 .change_protocol = dib0700_change_protocol,
3723 },
3724 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
3725 .num_adapters = 2,
3726 .adapter = {
3727 {
3728 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
3729 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
3730 .pid_filter_count = 32,
3731 .pid_filter = stk70x0p_pid_filter,
3732 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
3733 .frontend_attach = tfe7090pvr_frontend0_attach,
3734 .tuner_attach = tfe7090pvr_tuner0_attach,
3735
3736 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
3737
3738 .size_of_priv =
3739 sizeof(struct dib0700_adapter_state),
3740 },
3741 {
3742 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
3743 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
3744 .pid_filter_count = 32,
3745 .pid_filter = stk70x0p_pid_filter,
3746 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
3747 .frontend_attach = tfe7090pvr_frontend1_attach,
3748 .tuner_attach = tfe7090pvr_tuner1_attach,
3749
3750 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
3751
3752 .size_of_priv =
3753 sizeof(struct dib0700_adapter_state),
3754 },
3755 },
3756
3757 .num_device_descs = 1,
3758 .devices = {
3759 { "DiBcom TFE7090PVR reference design",
3760 { &dib0700_usb_id_table[73], NULL },
3761 { NULL },
3762 },
3763 },
3764
72b39310 3765 .rc.core = {
f72a27b8 3766 .rc_interval = DEFAULT_RC_INTERVAL,
5af935cc 3767 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
72b39310 3768 .module_name = "dib0700",
0ffd1ab3 3769 .rc_query = dib0700_rc_query_old_firmware,
52b66144
MCC
3770 .allowed_protos = RC_TYPE_RC5 |
3771 RC_TYPE_RC6 |
3772 RC_TYPE_NEC,
d8b4b582 3773 .change_protocol = dib0700_change_protocol,
f72a27b8 3774 },
01373a5c 3775 },
b7f54910
PB
3776};
3777
3778int dib0700_device_count = ARRAY_SIZE(dib0700_devices);