blob: d4673c71dff5c7928830b4bf5ac4830e02b2243c [file] [log] [blame]
Patrick Boettcherb7f54912006-09-19 12:51:37 -03001/* 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 *
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03007 * Copyright (C) 2005-9 DiBcom, SA et al
Patrick Boettcherb7f54912006-09-19 12:51:37 -03008 */
9#include "dib0700.h"
10
11#include "dib3000mc.h"
Patrick Boettcher91bb9be2006-12-02 21:15:51 -020012#include "dib7000m.h"
Patrick Boettchera75763f2006-10-18 08:34:16 -030013#include "dib7000p.h"
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -030014#include "dib8000.h"
Patrick Boettcherb7f54912006-09-19 12:51:37 -030015#include "mt2060.h"
Olivier DANET54d75eb2007-07-25 14:42:54 -030016#include "mt2266.h"
Albert Comerma6ca8f0b2008-03-29 21:35:57 -030017#include "tuner-xc2028.h"
Devin Heitmuellercb22cb52008-09-08 05:42:42 -030018#include "xc5000.h"
19#include "s5h1411.h"
Patrick Boettcher01373a52007-07-30 12:49:04 -030020#include "dib0070.h"
Olivier Grenie03245a52009-12-04 13:27:57 -030021#include "dib0090.h"
Michael Krufkyce904bc2009-01-19 01:12:55 -030022#include "lgdt3305.h"
23#include "mxl5007t.h"
Patrick Boettcherb7f54912006-09-19 12:51:37 -030024
Patrick Boettcher7fb3fc02006-09-20 04:37:18 -030025static int force_lna_activation;
26module_param(force_lna_activation, int, 0644);
27MODULE_PARM_DESC(force_lna_activation, "force the activation of Low-Noise-Amplifyer(s) (LNA), "
28 "if applicable for the device (default: 0=automatic/off).");
29
Patrick Boettcher01373a52007-07-30 12:49:04 -030030struct dib0700_adapter_state {
31 int (*set_param_save) (struct dvb_frontend *, struct dvb_frontend_parameters *);
32};
33
34/* Hauppauge Nova-T 500 (aka Bristol)
Patrick Boettcherb7f54912006-09-19 12:51:37 -030035 * has a LNA on GPIO0 which is enabled by setting 1 */
36static struct mt2060_config bristol_mt2060_config[2] = {
37 {
38 .i2c_address = 0x60,
Patrick Boettcher303cbea2006-09-19 12:51:56 -030039 .clock_out = 3,
Patrick Boettcherb7f54912006-09-19 12:51:37 -030040 }, {
41 .i2c_address = 0x61,
42 }
43};
44
Devin Heitmueller99afb982008-11-15 07:13:07 -030045
Patrick Boettcherb7f54912006-09-19 12:51:37 -030046static struct dibx000_agc_config bristol_dib3000p_mt2060_agc_config = {
47 .band_caps = BAND_VHF | BAND_UHF,
Patrick Boettcher01b4bf32006-09-19 12:51:53 -030048 .setup = (1 << 8) | (5 << 5) | (0 << 4) | (0 << 3) | (0 << 2) | (2 << 0),
Patrick Boettcherb7f54912006-09-19 12:51:37 -030049
Patrick Boettcher6958eff2006-09-19 12:51:40 -030050 .agc1_max = 42598,
51 .agc1_min = 17694,
52 .agc2_max = 45875,
53 .agc2_min = 0,
Patrick Boettcherb7f54912006-09-19 12:51:37 -030054
Patrick Boettcher6958eff2006-09-19 12:51:40 -030055 .agc1_pt1 = 0,
56 .agc1_pt2 = 59,
Patrick Boettcherb7f54912006-09-19 12:51:37 -030057
Patrick Boettcher6958eff2006-09-19 12:51:40 -030058 .agc1_slope1 = 0,
59 .agc1_slope2 = 69,
Patrick Boettcherb7f54912006-09-19 12:51:37 -030060
61 .agc2_pt1 = 0,
Patrick Boettcher6958eff2006-09-19 12:51:40 -030062 .agc2_pt2 = 59,
Patrick Boettcherb7f54912006-09-19 12:51:37 -030063
Patrick Boettcher6958eff2006-09-19 12:51:40 -030064 .agc2_slope1 = 111,
65 .agc2_slope2 = 28,
Patrick Boettcherb7f54912006-09-19 12:51:37 -030066};
67
68static struct dib3000mc_config bristol_dib3000mc_config[2] = {
69 { .agc = &bristol_dib3000p_mt2060_agc_config,
70 .max_time = 0x196,
71 .ln_adc_level = 0x1cc7,
72 .output_mpeg2_in_188_bytes = 1,
73 },
74 { .agc = &bristol_dib3000p_mt2060_agc_config,
75 .max_time = 0x196,
76 .ln_adc_level = 0x1cc7,
77 .output_mpeg2_in_188_bytes = 1,
78 }
79};
80
81static int bristol_frontend_attach(struct dvb_usb_adapter *adap)
82{
Patrick Boettcher6958eff2006-09-19 12:51:40 -030083 struct dib0700_state *st = adap->dev->priv;
Patrick Boettcherb7f54912006-09-19 12:51:37 -030084 if (adap->id == 0) {
85 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0); msleep(10);
86 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1); msleep(10);
87 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0); msleep(10);
88 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1); msleep(10);
89
Patrick Boettcher7fb3fc02006-09-20 04:37:18 -030090 if (force_lna_activation)
91 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
92 else
93 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 0);
Patrick Boettcher6958eff2006-09-19 12:51:40 -030094
Patrick Boettcherb7f54912006-09-19 12:51:37 -030095 if (dib3000mc_i2c_enumeration(&adap->dev->i2c_adap, 2, DEFAULT_DIB3000P_I2C_ADDRESS, bristol_dib3000mc_config) != 0) {
96 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0); msleep(10);
97 return -ENODEV;
98 }
99 }
Patrick Boettcher6958eff2006-09-19 12:51:40 -0300100 st->mt2060_if1[adap->id] = 1220;
101 return (adap->fe = dvb_attach(dib3000mc_attach, &adap->dev->i2c_adap,
102 (10 + adap->id) << 1, &bristol_dib3000mc_config[adap->id])) == NULL ? -ENODEV : 0;
Patrick Boettcherb7f54912006-09-19 12:51:37 -0300103}
104
Patrick Boettcher4a2b1082008-01-25 07:32:58 -0300105static int eeprom_read(struct i2c_adapter *adap,u8 adrs,u8 *pval)
Olivier DANETc52344f2008-01-25 06:50:07 -0300106{
107 struct i2c_msg msg[2] = {
108 { .addr = 0x50, .flags = 0, .buf = &adrs, .len = 1 },
109 { .addr = 0x50, .flags = I2C_M_RD, .buf = pval, .len = 1 },
110 };
111 if (i2c_transfer(adap, msg, 2) != 2) return -EREMOTEIO;
112 return 0;
113}
114
Patrick Boettcherb7f54912006-09-19 12:51:37 -0300115static int bristol_tuner_attach(struct dvb_usb_adapter *adap)
116{
Olivier DANETc52344f2008-01-25 06:50:07 -0300117 struct i2c_adapter *prim_i2c = &adap->dev->i2c_adap;
Patrick Boettcherb7f54912006-09-19 12:51:37 -0300118 struct i2c_adapter *tun_i2c = dib3000mc_get_tuner_i2c_master(adap->fe, 1);
Olivier DANETc52344f2008-01-25 06:50:07 -0300119 s8 a;
120 int if1=1220;
Al Viroda5ee482008-05-21 00:31:21 -0300121 if (adap->dev->udev->descriptor.idVendor == cpu_to_le16(USB_VID_HAUPPAUGE) &&
122 adap->dev->udev->descriptor.idProduct == cpu_to_le16(USB_PID_HAUPPAUGE_NOVA_T_500_2)) {
Olivier DANETc52344f2008-01-25 06:50:07 -0300123 if (!eeprom_read(prim_i2c,0x59 + adap->id,&a)) if1=1220+a;
124 }
125 return dvb_attach(mt2060_attach,adap->fe, tun_i2c,&bristol_mt2060_config[adap->id],
126 if1) == NULL ? -ENODEV : 0;
Patrick Boettcherb7f54912006-09-19 12:51:37 -0300127}
128
Patrick Boettcher01373a52007-07-30 12:49:04 -0300129/* STK7700D: Pinnacle/Terratec/Hauppauge Dual DVB-T Diversity */
Olivier DANET54d75eb2007-07-25 14:42:54 -0300130
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300131/* MT226x */
132static struct dibx000_agc_config stk7700d_7000p_mt2266_agc_config[2] = {
133 {
Olivier Grenie9c783032009-12-07 07:49:40 -0300134 BAND_UHF,
Olivier DANET54d75eb2007-07-25 14:42:54 -0300135
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300136 /* 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,
137 * 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 */
Olivier Grenie9c783032009-12-07 07:49:40 -0300138 (0 << 15) | (0 << 14) | (1 << 11) | (1 << 10) | (1 << 9) | (0 << 8)
139 | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),
Olivier DANET54d75eb2007-07-25 14:42:54 -0300140
Olivier Grenie9c783032009-12-07 07:49:40 -0300141 1130,
142 21,
Olivier DANET54d75eb2007-07-25 14:42:54 -0300143
Olivier Grenie9c783032009-12-07 07:49:40 -0300144 0,
145 118,
Olivier DANET54d75eb2007-07-25 14:42:54 -0300146
Olivier Grenie9c783032009-12-07 07:49:40 -0300147 0,
148 3530,
149 1,
150 0,
Olivier DANET54d75eb2007-07-25 14:42:54 -0300151
Olivier Grenie9c783032009-12-07 07:49:40 -0300152 65535,
153 33770,
154 65535,
155 23592,
Olivier DANET54d75eb2007-07-25 14:42:54 -0300156
Olivier Grenie9c783032009-12-07 07:49:40 -0300157 0,
158 62,
159 255,
160 64,
161 64,
162 132,
163 192,
164 80,
165 80,
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300166
Olivier Grenie9c783032009-12-07 07:49:40 -0300167 17,
168 27,
169 23,
170 51,
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300171
Olivier Grenie9c783032009-12-07 07:49:40 -0300172 1,
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300173 }, {
Olivier Grenie9c783032009-12-07 07:49:40 -0300174 BAND_VHF | BAND_LBAND,
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300175
176 /* 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,
177 * 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 */
Olivier Grenie9c783032009-12-07 07:49:40 -0300178 (0 << 15) | (0 << 14) | (1 << 11) | (1 << 10) | (1 << 9) | (0 << 8)
179 | (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0),
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300180
Olivier Grenie9c783032009-12-07 07:49:40 -0300181 2372,
182 21,
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300183
Olivier Grenie9c783032009-12-07 07:49:40 -0300184 0,
185 118,
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300186
Olivier Grenie9c783032009-12-07 07:49:40 -0300187 0,
188 3530,
189 1,
190 0,
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300191
Olivier Grenie9c783032009-12-07 07:49:40 -0300192 65535,
193 0,
194 65535,
195 23592,
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300196
Olivier Grenie9c783032009-12-07 07:49:40 -0300197 0,
198 128,
199 128,
200 128,
201 0,
202 128,
203 253,
204 81,
205 0,
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300206
Olivier Grenie9c783032009-12-07 07:49:40 -0300207 17,
208 27,
209 23,
210 51,
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300211
Olivier Grenie9c783032009-12-07 07:49:40 -0300212 1,
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300213 }
Olivier DANET54d75eb2007-07-25 14:42:54 -0300214};
215
216static struct dibx000_bandwidth_config stk7700d_mt2266_pll_config = {
Olivier Grenie9c783032009-12-07 07:49:40 -0300217 60000, 30000,
218 1, 8, 3, 1, 0,
219 0, 0, 1, 1, 2,
220 (3 << 14) | (1 << 12) | (524 << 0),
221 0,
222 20452225,
Olivier DANET54d75eb2007-07-25 14:42:54 -0300223};
224
225static struct dib7000p_config stk7700d_dib7000p_mt2266_config[] = {
226 { .output_mpeg2_in_188_bytes = 1,
227 .hostbus_diversity = 1,
228 .tuner_is_baseband = 1,
229
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300230 .agc_config_count = 2,
231 .agc = stk7700d_7000p_mt2266_agc_config,
Olivier DANET54d75eb2007-07-25 14:42:54 -0300232 .bw = &stk7700d_mt2266_pll_config,
233
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300234 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
235 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
236 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
Olivier DANET54d75eb2007-07-25 14:42:54 -0300237 },
238 { .output_mpeg2_in_188_bytes = 1,
239 .hostbus_diversity = 1,
240 .tuner_is_baseband = 1,
241
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300242 .agc_config_count = 2,
243 .agc = stk7700d_7000p_mt2266_agc_config,
Olivier DANET54d75eb2007-07-25 14:42:54 -0300244 .bw = &stk7700d_mt2266_pll_config,
245
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300246 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
247 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
248 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
Olivier DANET54d75eb2007-07-25 14:42:54 -0300249 }
250};
251
252static struct mt2266_config stk7700d_mt2266_config[2] = {
253 { .i2c_address = 0x60
254 },
255 { .i2c_address = 0x60
256 }
257};
258
Daniel Gimpelevich132c3182008-01-25 06:02:42 -0300259static int stk7700P2_frontend_attach(struct dvb_usb_adapter *adap)
260{
261 if (adap->id == 0) {
262 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
263 msleep(10);
264 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
265 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
266 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
267 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
268 msleep(10);
269 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
270 msleep(10);
Devin Heitmueller83c4fdf2009-01-21 01:55:45 -0300271 if (dib7000p_i2c_enumeration(&adap->dev->i2c_adap, 1, 18,
272 stk7700d_dib7000p_mt2266_config)
273 != 0) {
274 err("%s: dib7000p_i2c_enumeration failed. Cannot continue\n", __func__);
275 return -ENODEV;
276 }
Daniel Gimpelevich132c3182008-01-25 06:02:42 -0300277 }
278
279 adap->fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap,0x80+(adap->id << 1),
280 &stk7700d_dib7000p_mt2266_config[adap->id]);
281
282 return adap->fe == NULL ? -ENODEV : 0;
283}
284
Olivier DANET54d75eb2007-07-25 14:42:54 -0300285static int stk7700d_frontend_attach(struct dvb_usb_adapter *adap)
286{
287 if (adap->id == 0) {
288 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
289 msleep(10);
290 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
291 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
292 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
293 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
294 msleep(10);
295 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
296 msleep(10);
297 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
Devin Heitmueller83c4fdf2009-01-21 01:55:45 -0300298 if (dib7000p_i2c_enumeration(&adap->dev->i2c_adap, 2, 18,
299 stk7700d_dib7000p_mt2266_config)
300 != 0) {
301 err("%s: dib7000p_i2c_enumeration failed. Cannot continue\n", __func__);
302 return -ENODEV;
303 }
Olivier DANET54d75eb2007-07-25 14:42:54 -0300304 }
305
306 adap->fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap,0x80+(adap->id << 1),
307 &stk7700d_dib7000p_mt2266_config[adap->id]);
308
309 return adap->fe == NULL ? -ENODEV : 0;
310}
311
312static int stk7700d_tuner_attach(struct dvb_usb_adapter *adap)
313{
314 struct i2c_adapter *tun_i2c;
315 tun_i2c = dib7000p_get_i2c_master(adap->fe, DIBX000_I2C_INTERFACE_TUNER, 1);
316 return dvb_attach(mt2266_attach, adap->fe, tun_i2c,
Joe Perches1ebcad72009-07-02 15:57:09 -0300317 &stk7700d_mt2266_config[adap->id]) == NULL ? -ENODEV : 0;
Olivier DANET54d75eb2007-07-25 14:42:54 -0300318}
319
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300320/* STK7700-PH: Digital/Analog Hybrid Tuner, e.h. Cinergy HT USB HE */
Harvey Harrisonb1721d02008-04-25 19:03:08 -0700321static struct dibx000_agc_config xc3028_agc_config = {
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300322 BAND_VHF | BAND_UHF, /* band_caps */
323
324 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=0,
325 * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
326 * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=2, P_agc_write=0 */
327 (0 << 15) | (0 << 14) | (0 << 11) | (0 << 10) | (0 << 9) | (0 << 8) |
328 (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0), /* setup */
329
330 712, /* inv_gain */
331 21, /* time_stabiliz */
332
333 0, /* alpha_level */
334 118, /* thlock */
335
336 0, /* wbd_inv */
337 2867, /* wbd_ref */
338 0, /* wbd_sel */
339 2, /* wbd_alpha */
340
341 0, /* agc1_max */
342 0, /* agc1_min */
343 39718, /* agc2_max */
344 9930, /* agc2_min */
345 0, /* agc1_pt1 */
346 0, /* agc1_pt2 */
347 0, /* agc1_pt3 */
348 0, /* agc1_slope1 */
349 0, /* agc1_slope2 */
350 0, /* agc2_pt1 */
351 128, /* agc2_pt2 */
352 29, /* agc2_slope1 */
353 29, /* agc2_slope2 */
354
355 17, /* alpha_mant */
356 27, /* alpha_exp */
357 23, /* beta_mant */
358 51, /* beta_exp */
359
360 1, /* perform_agc_softsplit */
361};
362
363/* PLL Configuration for COFDM BW_MHz = 8.00 with external clock = 30.00 */
Harvey Harrisonb1721d02008-04-25 19:03:08 -0700364static struct dibx000_bandwidth_config xc3028_bw_config = {
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300365 60000, 30000, /* internal, sampling */
366 1, 8, 3, 1, 0, /* pll_cfg: prediv, ratio, range, reset, bypass */
367 0, 0, 1, 1, 0, /* misc: refdiv, bypclk_div, IO_CLK_en_core, ADClkSrc,
368 modulo */
369 (3 << 14) | (1 << 12) | (524 << 0), /* sad_cfg: refsel, sel, freq_15k */
370 (1 << 25) | 5816102, /* ifreq = 5.200000 MHz */
371 20452225, /* timf */
372 30000000, /* xtal_hz */
373};
374
375static struct dib7000p_config stk7700ph_dib7700_xc3028_config = {
376 .output_mpeg2_in_188_bytes = 1,
377 .tuner_is_baseband = 1,
378
379 .agc_config_count = 1,
380 .agc = &xc3028_agc_config,
381 .bw = &xc3028_bw_config,
382
383 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
384 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
385 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
386};
387
Michael Krufkyd7cba042008-09-12 13:31:45 -0300388static int stk7700ph_xc3028_callback(void *ptr, int component,
389 int command, int arg)
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300390{
391 struct dvb_usb_adapter *adap = ptr;
392
393 switch (command) {
394 case XC2028_TUNER_RESET:
395 /* Send the tuner in then out of reset */
396 dib7000p_set_gpio(adap->fe, 8, 0, 0); msleep(10);
397 dib7000p_set_gpio(adap->fe, 8, 0, 1);
398 break;
399 case XC2028_RESET_CLK:
400 break;
401 default:
402 err("%s: unknown command %d, arg %d\n", __func__,
403 command, arg);
404 return -EINVAL;
405 }
406 return 0;
407}
408
409static struct xc2028_ctrl stk7700ph_xc3028_ctrl = {
410 .fname = XC2028_DEFAULT_FIRMWARE,
411 .max_len = 64,
412 .demod = XC3028_FE_DIBCOM52,
413};
414
415static struct xc2028_config stk7700ph_xc3028_config = {
416 .i2c_addr = 0x61,
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300417 .ctrl = &stk7700ph_xc3028_ctrl,
418};
419
420static int stk7700ph_frontend_attach(struct dvb_usb_adapter *adap)
421{
422 struct usb_device_descriptor *desc = &adap->dev->udev->descriptor;
423
Al Viroda5ee482008-05-21 00:31:21 -0300424 if (desc->idVendor == cpu_to_le16(USB_VID_PINNACLE) &&
425 desc->idProduct == cpu_to_le16(USB_PID_PINNACLE_EXPRESSCARD_320CX))
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300426 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
427 else
428 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
429 msleep(20);
430 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
431 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
432 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
433 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
434 msleep(10);
435 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
436 msleep(20);
437 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
438 msleep(10);
439
Devin Heitmueller83c4fdf2009-01-21 01:55:45 -0300440 if (dib7000p_i2c_enumeration(&adap->dev->i2c_adap, 1, 18,
441 &stk7700ph_dib7700_xc3028_config) != 0) {
442 err("%s: dib7000p_i2c_enumeration failed. Cannot continue\n",
443 __func__);
444 return -ENODEV;
445 }
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300446
447 adap->fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 0x80,
448 &stk7700ph_dib7700_xc3028_config);
449
450 return adap->fe == NULL ? -ENODEV : 0;
451}
452
453static int stk7700ph_tuner_attach(struct dvb_usb_adapter *adap)
454{
455 struct i2c_adapter *tun_i2c;
456
457 tun_i2c = dib7000p_get_i2c_master(adap->fe,
458 DIBX000_I2C_INTERFACE_TUNER, 1);
459
460 stk7700ph_xc3028_config.i2c_adap = tun_i2c;
Michael Krufkyd7cba042008-09-12 13:31:45 -0300461
462 /* FIXME: generalize & move to common area */
463 adap->fe->callback = stk7700ph_xc3028_callback;
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300464
465 return dvb_attach(xc2028_attach, adap->fe, &stk7700ph_xc3028_config)
466 == NULL ? -ENODEV : 0;
467}
468
Devin Heitmueller4b330be2008-12-01 06:51:14 -0300469#define DEFAULT_RC_INTERVAL 50
Olivier DANET54d75eb2007-07-25 14:42:54 -0300470
471static u8 rc_request[] = { REQUEST_POLL_RC, 0 };
472
Patrick Boettcher58e6f952008-03-29 21:37:01 -0300473/* Number of keypresses to ignore before start repeating */
Devin Heitmueller4b330be2008-12-01 06:51:14 -0300474#define RC_REPEAT_DELAY 6
475#define RC_REPEAT_DELAY_V1_20 10
Patrick Boettcher58e6f952008-03-29 21:37:01 -0300476
Devin Heitmueller99afb982008-11-15 07:13:07 -0300477
478
479/* Used by firmware versions < 1.20 (deprecated) */
480static int dib0700_rc_query_legacy(struct dvb_usb_device *d, u32 *event,
481 int *state)
Olivier DANET54d75eb2007-07-25 14:42:54 -0300482{
483 u8 key[4];
484 int i;
485 struct dvb_usb_rc_key *keymap = d->props.rc_key_map;
486 struct dib0700_state *st = d->priv;
487 *event = 0;
488 *state = REMOTE_NO_KEY_PRESSED;
489 i=dib0700_ctrl_rd(d,rc_request,2,key,4);
490 if (i<=0) {
Janne Grunau034d65e2007-07-31 08:48:40 -0300491 err("RC Query Failed");
Janne Grunau89f42672007-07-31 19:45:13 -0300492 return -1;
Olivier DANET54d75eb2007-07-25 14:42:54 -0300493 }
Patrick Boettcher58e6f952008-03-29 21:37:01 -0300494
495 /* losing half of KEY_0 events from Philipps rc5 remotes.. */
Olivier DANET54d75eb2007-07-25 14:42:54 -0300496 if (key[0]==0 && key[1]==0 && key[2]==0 && key[3]==0) return 0;
Patrick Boettcher58e6f952008-03-29 21:37:01 -0300497
498 /* 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]); */
499
500 dib0700_rc_setup(d); /* reset ir sensor data to prevent false events */
501
502 switch (dvb_usb_dib0700_ir_proto) {
503 case 0: {
504 /* NEC protocol sends repeat code as 0 0 0 FF */
505 if ((key[3-2] == 0x00) && (key[3-3] == 0x00) &&
506 (key[3] == 0xFF)) {
507 st->rc_counter++;
508 if (st->rc_counter > RC_REPEAT_DELAY) {
509 *event = d->last_event;
510 *state = REMOTE_KEY_PRESSED;
511 st->rc_counter = RC_REPEAT_DELAY;
512 }
513 return 0;
514 }
Olivier DANET54d75eb2007-07-25 14:42:54 -0300515 for (i=0;i<d->props.rc_key_map_size; i++) {
Mauro Carvalho Chehab2e365882009-08-29 15:19:31 -0300516 if (rc5_custom(&keymap[i]) == key[3-2] &&
517 rc5_data(&keymap[i]) == key[3-3]) {
Patrick Boettcher58e6f952008-03-29 21:37:01 -0300518 st->rc_counter = 0;
Olivier DANET54d75eb2007-07-25 14:42:54 -0300519 *event = keymap[i].event;
520 *state = REMOTE_KEY_PRESSED;
Patrick Boettcher58e6f952008-03-29 21:37:01 -0300521 d->last_event = keymap[i].event;
Olivier DANET54d75eb2007-07-25 14:42:54 -0300522 return 0;
523 }
524 }
Patrick Boettcher58e6f952008-03-29 21:37:01 -0300525 break;
Olivier DANET54d75eb2007-07-25 14:42:54 -0300526 }
Patrick Boettcher58e6f952008-03-29 21:37:01 -0300527 default: {
528 /* RC-5 protocol changes toggle bit on new keypress */
529 for (i = 0; i < d->props.rc_key_map_size; i++) {
Mauro Carvalho Chehab2e365882009-08-29 15:19:31 -0300530 if (rc5_custom(&keymap[i]) == key[3-2] &&
531 rc5_data(&keymap[i]) == key[3-3]) {
Patrick Boettcher58e6f952008-03-29 21:37:01 -0300532 if (d->last_event == keymap[i].event &&
533 key[3-1] == st->rc_toggle) {
534 st->rc_counter++;
535 /* prevents unwanted double hits */
536 if (st->rc_counter > RC_REPEAT_DELAY) {
537 *event = d->last_event;
538 *state = REMOTE_KEY_PRESSED;
539 st->rc_counter = RC_REPEAT_DELAY;
540 }
541
542 return 0;
543 }
544 st->rc_counter = 0;
545 *event = keymap[i].event;
546 *state = REMOTE_KEY_PRESSED;
547 st->rc_toggle = key[3-1];
548 d->last_event = keymap[i].event;
549 return 0;
550 }
551 }
552 break;
553 }
554 }
555 err("Unknown remote controller key: %2X %2X %2X %2X", (int) key[3-2], (int) key[3-3], (int) key[3-1], (int) key[3]);
556 d->last_event = 0;
Olivier DANET54d75eb2007-07-25 14:42:54 -0300557 return 0;
558}
559
Devin Heitmueller99afb982008-11-15 07:13:07 -0300560/* This is the structure of the RC response packet starting in firmware 1.20 */
561struct dib0700_rc_response {
562 u8 report_id;
563 u8 data_state;
Mauro Carvalho Chehabaa15c0a2009-09-26 13:29:35 -0300564 u16 system;
Devin Heitmueller99afb982008-11-15 07:13:07 -0300565 u8 data;
566 u8 not_data;
567};
568
569/* This supports the new IR response format for firmware v1.20 */
570static int dib0700_rc_query_v1_20(struct dvb_usb_device *d, u32 *event,
571 int *state)
572{
573 struct dvb_usb_rc_key *keymap = d->props.rc_key_map;
574 struct dib0700_state *st = d->priv;
575 struct dib0700_rc_response poll_reply;
576 u8 buf[6];
577 int i;
578 int status;
579 int actlen;
580 int found = 0;
581
582 /* Set initial results in case we exit the function early */
583 *event = 0;
584 *state = REMOTE_NO_KEY_PRESSED;
585
586 /* Firmware v1.20 provides RC data via bulk endpoint 1 */
587 status = usb_bulk_msg(d->udev, usb_rcvbulkpipe(d->udev, 1), buf,
588 sizeof(buf), &actlen, 50);
589 if (status < 0) {
590 /* No data available (meaning no key press) */
591 return 0;
592 }
593
Mauro Carvalho Chehabaa15c0a2009-09-26 13:29:35 -0300594
595 switch (dvb_usb_dib0700_ir_proto) {
596 case 0:
597 poll_reply.report_id = 0;
598 poll_reply.data_state = 1;
599 poll_reply.system = buf[2];
600 poll_reply.data = buf[4];
601 poll_reply.not_data = buf[5];
602
603 /* NEC protocol sends repeat code as 0 0 0 FF */
604 if ((poll_reply.system == 0x00) && (poll_reply.data == 0x00)
605 && (poll_reply.not_data == 0xff)) {
606 poll_reply.data_state = 2;
607 break;
608 }
609 break;
610 default:
Olivier Grenie03245a52009-12-04 13:27:57 -0300611 if (actlen != sizeof(buf)) {
612 /* We didn't get back the 6 byte message we expected */
613 err("Unexpected RC response size [%d]", actlen);
614 return -1;
615 }
Mauro Carvalho Chehabaa15c0a2009-09-26 13:29:35 -0300616
Olivier Grenie03245a52009-12-04 13:27:57 -0300617 poll_reply.report_id = buf[0];
618 poll_reply.data_state = buf[1];
Mauro Carvalho Chehabaa15c0a2009-09-26 13:29:35 -0300619 poll_reply.system = (buf[2] << 8) | buf[3];
Olivier Grenie03245a52009-12-04 13:27:57 -0300620 poll_reply.data = buf[4];
621 poll_reply.not_data = buf[5];
Mauro Carvalho Chehabaa15c0a2009-09-26 13:29:35 -0300622
623 break;
Devin Heitmueller99afb982008-11-15 07:13:07 -0300624 }
625
Devin Heitmueller99afb982008-11-15 07:13:07 -0300626 if ((poll_reply.data + poll_reply.not_data) != 0xff) {
627 /* Key failed integrity check */
Mauro Carvalho Chehabaa15c0a2009-09-26 13:29:35 -0300628 err("key failed integrity check: %04x %02x %02x",
629 poll_reply.system,
Devin Heitmueller99afb982008-11-15 07:13:07 -0300630 poll_reply.data, poll_reply.not_data);
631 return -1;
632 }
633
Mauro Carvalho Chehabaa15c0a2009-09-26 13:29:35 -0300634
Devin Heitmueller99afb982008-11-15 07:13:07 -0300635 /* Find the key in the map */
636 for (i = 0; i < d->props.rc_key_map_size; i++) {
Mauro Carvalho Chehabaa15c0a2009-09-26 13:29:35 -0300637 if (rc5_custom(&keymap[i]) == (poll_reply.system & 0xff) &&
Olivier Grenie03245a52009-12-04 13:27:57 -0300638 rc5_data(&keymap[i]) == poll_reply.data) {
Devin Heitmueller99afb982008-11-15 07:13:07 -0300639 *event = keymap[i].event;
640 found = 1;
641 break;
642 }
643 }
644
645 if (found == 0) {
Mauro Carvalho Chehabaa15c0a2009-09-26 13:29:35 -0300646 err("Unknown remote controller key: %04x %02x %02x",
Olivier Grenie03245a52009-12-04 13:27:57 -0300647 poll_reply.system,
648 poll_reply.data, poll_reply.not_data);
Devin Heitmueller99afb982008-11-15 07:13:07 -0300649 d->last_event = 0;
650 return 0;
651 }
652
653 if (poll_reply.data_state == 1) {
654 /* New key hit */
655 st->rc_counter = 0;
656 *event = keymap[i].event;
657 *state = REMOTE_KEY_PRESSED;
658 d->last_event = keymap[i].event;
659 } else if (poll_reply.data_state == 2) {
660 /* Key repeated */
661 st->rc_counter++;
662
663 /* prevents unwanted double hits */
664 if (st->rc_counter > RC_REPEAT_DELAY_V1_20) {
665 *event = d->last_event;
666 *state = REMOTE_KEY_PRESSED;
667 st->rc_counter = RC_REPEAT_DELAY_V1_20;
668 }
669 } else {
670 err("Unknown data state [%d]", poll_reply.data_state);
671 }
672
673 return 0;
674}
675
676static int dib0700_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
677{
678 struct dib0700_state *st = d->priv;
679
680 /* Because some people may have improperly named firmware files,
681 let's figure out whether to use the new firmware call or the legacy
682 call based on the firmware version embedded in the file */
683 if (st->rc_func_version == 0) {
684 u32 hwver, romver, ramver, fwtype;
685 int ret = dib0700_get_version(d, &hwver, &romver, &ramver,
686 &fwtype);
687 if (ret < 0) {
688 err("Could not determine version info");
689 return -1;
690 }
691 if (ramver < 0x10200)
692 st->rc_func_version = 1;
693 else
694 st->rc_func_version = 2;
695 }
696
697 if (st->rc_func_version == 2)
698 return dib0700_rc_query_v1_20(d, event, state);
699 else
700 return dib0700_rc_query_legacy(d, event, state);
701}
702
Janne Grunau82f3d552007-07-30 13:50:28 -0300703static struct dvb_usb_rc_key dib0700_rc_keys[] = {
Olivier DANET54d75eb2007-07-25 14:42:54 -0300704 /* Key codes for the tiny Pinnacle remote*/
Mauro Carvalho Chehab2e365882009-08-29 15:19:31 -0300705 { 0x0700, KEY_MUTE },
706 { 0x0701, KEY_MENU }, /* Pinnacle logo */
707 { 0x0739, KEY_POWER },
708 { 0x0703, KEY_VOLUMEUP },
709 { 0x0709, KEY_VOLUMEDOWN },
710 { 0x0706, KEY_CHANNELUP },
711 { 0x070c, KEY_CHANNELDOWN },
712 { 0x070f, KEY_1 },
713 { 0x0715, KEY_2 },
714 { 0x0710, KEY_3 },
715 { 0x0718, KEY_4 },
716 { 0x071b, KEY_5 },
717 { 0x071e, KEY_6 },
718 { 0x0711, KEY_7 },
719 { 0x0721, KEY_8 },
720 { 0x0712, KEY_9 },
721 { 0x0727, KEY_0 },
722 { 0x0724, KEY_SCREEN }, /* 'Square' key */
723 { 0x072a, KEY_TEXT }, /* 'T' key */
724 { 0x072d, KEY_REWIND },
725 { 0x0730, KEY_PLAY },
726 { 0x0733, KEY_FASTFORWARD },
727 { 0x0736, KEY_RECORD },
728 { 0x073c, KEY_STOP },
729 { 0x073f, KEY_CANCEL }, /* '?' key */
Olivier DANET54d75eb2007-07-25 14:42:54 -0300730 /* Key codes for the Terratec Cinergy DT XS Diversity, similar to cinergyT2.c */
Mauro Carvalho Chehab2e365882009-08-29 15:19:31 -0300731 { 0xeb01, KEY_POWER },
732 { 0xeb02, KEY_1 },
733 { 0xeb03, KEY_2 },
734 { 0xeb04, KEY_3 },
735 { 0xeb05, KEY_4 },
736 { 0xeb06, KEY_5 },
737 { 0xeb07, KEY_6 },
738 { 0xeb08, KEY_7 },
739 { 0xeb09, KEY_8 },
740 { 0xeb0a, KEY_9 },
741 { 0xeb0b, KEY_VIDEO },
742 { 0xeb0c, KEY_0 },
743 { 0xeb0d, KEY_REFRESH },
744 { 0xeb0f, KEY_EPG },
745 { 0xeb10, KEY_UP },
746 { 0xeb11, KEY_LEFT },
747 { 0xeb12, KEY_OK },
748 { 0xeb13, KEY_RIGHT },
749 { 0xeb14, KEY_DOWN },
750 { 0xeb16, KEY_INFO },
751 { 0xeb17, KEY_RED },
752 { 0xeb18, KEY_GREEN },
753 { 0xeb19, KEY_YELLOW },
754 { 0xeb1a, KEY_BLUE },
755 { 0xeb1b, KEY_CHANNELUP },
756 { 0xeb1c, KEY_VOLUMEUP },
757 { 0xeb1d, KEY_MUTE },
758 { 0xeb1e, KEY_VOLUMEDOWN },
759 { 0xeb1f, KEY_CHANNELDOWN },
760 { 0xeb40, KEY_PAUSE },
761 { 0xeb41, KEY_HOME },
762 { 0xeb42, KEY_MENU }, /* DVD Menu */
763 { 0xeb43, KEY_SUBTITLE },
764 { 0xeb44, KEY_TEXT }, /* Teletext */
765 { 0xeb45, KEY_DELETE },
766 { 0xeb46, KEY_TV },
767 { 0xeb47, KEY_DVD },
768 { 0xeb48, KEY_STOP },
769 { 0xeb49, KEY_VIDEO },
770 { 0xeb4a, KEY_AUDIO }, /* Music */
771 { 0xeb4b, KEY_SCREEN }, /* Pic */
772 { 0xeb4c, KEY_PLAY },
773 { 0xeb4d, KEY_BACK },
774 { 0xeb4e, KEY_REWIND },
775 { 0xeb4f, KEY_FASTFORWARD },
776 { 0xeb54, KEY_PREVIOUS },
777 { 0xeb58, KEY_RECORD },
778 { 0xeb5c, KEY_NEXT },
Janne Grunau7161f272007-07-30 13:54:55 -0300779
780 /* Key codes for the Haupauge WinTV Nova-TD, copied from nova-t-usb2.c (Nova-T USB2) */
Mauro Carvalho Chehab2e365882009-08-29 15:19:31 -0300781 { 0x1e00, KEY_0 },
782 { 0x1e01, KEY_1 },
783 { 0x1e02, KEY_2 },
784 { 0x1e03, KEY_3 },
785 { 0x1e04, KEY_4 },
786 { 0x1e05, KEY_5 },
787 { 0x1e06, KEY_6 },
788 { 0x1e07, KEY_7 },
789 { 0x1e08, KEY_8 },
790 { 0x1e09, KEY_9 },
791 { 0x1e0a, KEY_KPASTERISK },
792 { 0x1e0b, KEY_RED },
793 { 0x1e0c, KEY_RADIO },
794 { 0x1e0d, KEY_MENU },
795 { 0x1e0e, KEY_GRAVE }, /* # */
796 { 0x1e0f, KEY_MUTE },
797 { 0x1e10, KEY_VOLUMEUP },
798 { 0x1e11, KEY_VOLUMEDOWN },
799 { 0x1e12, KEY_CHANNEL },
800 { 0x1e14, KEY_UP },
801 { 0x1e15, KEY_DOWN },
802 { 0x1e16, KEY_LEFT },
803 { 0x1e17, KEY_RIGHT },
804 { 0x1e18, KEY_VIDEO },
805 { 0x1e19, KEY_AUDIO },
806 { 0x1e1a, KEY_MEDIA },
807 { 0x1e1b, KEY_EPG },
808 { 0x1e1c, KEY_TV },
809 { 0x1e1e, KEY_NEXT },
810 { 0x1e1f, KEY_BACK },
811 { 0x1e20, KEY_CHANNELUP },
812 { 0x1e21, KEY_CHANNELDOWN },
813 { 0x1e24, KEY_LAST }, /* Skip backwards */
814 { 0x1e25, KEY_OK },
815 { 0x1e29, KEY_BLUE},
816 { 0x1e2e, KEY_GREEN },
817 { 0x1e30, KEY_PAUSE },
818 { 0x1e32, KEY_REWIND },
819 { 0x1e34, KEY_FASTFORWARD },
820 { 0x1e35, KEY_PLAY },
821 { 0x1e36, KEY_STOP },
822 { 0x1e37, KEY_RECORD },
823 { 0x1e38, KEY_YELLOW },
824 { 0x1e3b, KEY_GOTO },
825 { 0x1e3d, KEY_POWER },
Jaroslav Barton48e6a012007-11-10 19:17:45 -0300826
827 /* Key codes for the Leadtek Winfast DTV Dongle */
Mauro Carvalho Chehab2e365882009-08-29 15:19:31 -0300828 { 0x0042, KEY_POWER },
829 { 0x077c, KEY_TUNER },
830 { 0x0f4e, KEY_PRINT }, /* PREVIEW */
831 { 0x0840, KEY_SCREEN }, /* full screen toggle*/
832 { 0x0f71, KEY_DOT }, /* frequency */
833 { 0x0743, KEY_0 },
834 { 0x0c41, KEY_1 },
835 { 0x0443, KEY_2 },
836 { 0x0b7f, KEY_3 },
837 { 0x0e41, KEY_4 },
838 { 0x0643, KEY_5 },
839 { 0x097f, KEY_6 },
840 { 0x0d7e, KEY_7 },
841 { 0x057c, KEY_8 },
842 { 0x0a40, KEY_9 },
843 { 0x0e4e, KEY_CLEAR },
844 { 0x047c, KEY_CHANNEL }, /* show channel number */
845 { 0x0f41, KEY_LAST }, /* recall */
846 { 0x0342, KEY_MUTE },
847 { 0x064c, KEY_RESERVED }, /* PIP button*/
848 { 0x0172, KEY_SHUFFLE }, /* SNAPSHOT */
849 { 0x0c4e, KEY_PLAYPAUSE }, /* TIMESHIFT */
850 { 0x0b70, KEY_RECORD },
851 { 0x037d, KEY_VOLUMEUP },
852 { 0x017d, KEY_VOLUMEDOWN },
853 { 0x0242, KEY_CHANNELUP },
854 { 0x007d, KEY_CHANNELDOWN },
Chris Rankin48aa7392008-09-25 06:52:24 -0300855
856 /* Key codes for Nova-TD "credit card" remote control. */
Mauro Carvalho Chehab2e365882009-08-29 15:19:31 -0300857 { 0x1d00, KEY_0 },
858 { 0x1d01, KEY_1 },
859 { 0x1d02, KEY_2 },
860 { 0x1d03, KEY_3 },
861 { 0x1d04, KEY_4 },
862 { 0x1d05, KEY_5 },
863 { 0x1d06, KEY_6 },
864 { 0x1d07, KEY_7 },
865 { 0x1d08, KEY_8 },
866 { 0x1d09, KEY_9 },
867 { 0x1d0a, KEY_TEXT },
868 { 0x1d0d, KEY_MENU },
869 { 0x1d0f, KEY_MUTE },
870 { 0x1d10, KEY_VOLUMEUP },
871 { 0x1d11, KEY_VOLUMEDOWN },
872 { 0x1d12, KEY_CHANNEL },
873 { 0x1d14, KEY_UP },
874 { 0x1d15, KEY_DOWN },
875 { 0x1d16, KEY_LEFT },
876 { 0x1d17, KEY_RIGHT },
877 { 0x1d1c, KEY_TV },
878 { 0x1d1e, KEY_NEXT },
879 { 0x1d1f, KEY_BACK },
880 { 0x1d20, KEY_CHANNELUP },
881 { 0x1d21, KEY_CHANNELDOWN },
882 { 0x1d24, KEY_LAST },
883 { 0x1d25, KEY_OK },
884 { 0x1d30, KEY_PAUSE },
885 { 0x1d32, KEY_REWIND },
886 { 0x1d34, KEY_FASTFORWARD },
887 { 0x1d35, KEY_PLAY },
888 { 0x1d36, KEY_STOP },
889 { 0x1d37, KEY_RECORD },
890 { 0x1d3b, KEY_GOTO },
891 { 0x1d3d, KEY_POWER },
Mauro Carvalho Chehab4c5128b2009-09-26 13:31:31 -0300892
893 /* Key codes for the Pixelview SBTVD remote (proto NEC) */
894 { 0x8613, KEY_MUTE },
895 { 0x8612, KEY_POWER },
896 { 0x8601, KEY_1 },
897 { 0x8602, KEY_2 },
898 { 0x8603, KEY_3 },
899 { 0x8604, KEY_4 },
900 { 0x8605, KEY_5 },
901 { 0x8606, KEY_6 },
902 { 0x8607, KEY_7 },
903 { 0x8608, KEY_8 },
904 { 0x8609, KEY_9 },
905 { 0x8600, KEY_0 },
906 { 0x860d, KEY_CHANNELUP },
907 { 0x8619, KEY_CHANNELDOWN },
908 { 0x8610, KEY_VOLUMEUP },
909 { 0x860c, KEY_VOLUMEDOWN },
910
911 { 0x860a, KEY_CAMERA },
912 { 0x860b, KEY_ZOOM },
913 { 0x861b, KEY_BACKSPACE },
914 { 0x8615, KEY_ENTER },
915
916 { 0x861d, KEY_UP },
917 { 0x861e, KEY_DOWN },
918 { 0x860e, KEY_LEFT },
919 { 0x860f, KEY_RIGHT },
920
921 { 0x8618, KEY_RECORD },
922 { 0x861a, KEY_STOP },
Sergio C Fortierc86c82b2009-11-04 15:55:09 -0300923
924 /* Key codes for the EvolutePC TVWay+ remote (proto NEC) */
925 { 0x7a00, KEY_MENU },
926 { 0x7a01, KEY_RECORD },
927 { 0x7a02, KEY_PLAY },
928 { 0x7a03, KEY_STOP },
929 { 0x7a10, KEY_CHANNELUP },
930 { 0x7a11, KEY_CHANNELDOWN },
931 { 0x7a12, KEY_VOLUMEUP },
932 { 0x7a13, KEY_VOLUMEDOWN },
933 { 0x7a40, KEY_POWER },
934 { 0x7a41, KEY_MUTE },
Janne Grunau82f3d552007-07-30 13:50:28 -0300935};
Olivier DANET54d75eb2007-07-25 14:42:54 -0300936
Patrick Boettcherb7f54912006-09-19 12:51:37 -0300937/* STK7700P: Hauppauge Nova-T Stick, AVerMedia Volar */
Patrick Boettchera75763f2006-10-18 08:34:16 -0300938static struct dibx000_agc_config stk7700p_7000m_mt2060_agc_config = {
Olivier Grenie9c783032009-12-07 07:49:40 -0300939 BAND_UHF | BAND_VHF,
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300940
941 /* 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,
942 * 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 */
Olivier Grenie9c783032009-12-07 07:49:40 -0300943 (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8)
944 | (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0),
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300945
Olivier Grenie9c783032009-12-07 07:49:40 -0300946 712,
947 41,
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300948
Olivier Grenie9c783032009-12-07 07:49:40 -0300949 0,
950 118,
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300951
Olivier Grenie9c783032009-12-07 07:49:40 -0300952 0,
953 4095,
954 0,
955 0,
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300956
Olivier Grenie9c783032009-12-07 07:49:40 -0300957 42598,
958 17694,
959 45875,
960 2621,
961 0,
962 76,
963 139,
964 52,
965 59,
966 107,
967 172,
968 57,
969 70,
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300970
Olivier Grenie9c783032009-12-07 07:49:40 -0300971 21,
972 25,
973 28,
974 48,
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300975
Olivier Grenie9c783032009-12-07 07:49:40 -0300976 1,
977 { 0,
978 107,
979 51800,
980 24700
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300981 },
Patrick Boettcherb7f54912006-09-19 12:51:37 -0300982};
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300983
Patrick Boettchera75763f2006-10-18 08:34:16 -0300984static struct dibx000_agc_config stk7700p_7000p_mt2060_agc_config = {
985 BAND_UHF | BAND_VHF,
986
987 /* 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,
988 * 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 */
Olivier Grenie9c783032009-12-07 07:49:40 -0300989 (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8)
990 | (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0),
Patrick Boettchera75763f2006-10-18 08:34:16 -0300991
Olivier Grenie9c783032009-12-07 07:49:40 -0300992 712,
993 41,
Patrick Boettchera75763f2006-10-18 08:34:16 -0300994
Olivier Grenie9c783032009-12-07 07:49:40 -0300995 0,
996 118,
Patrick Boettchera75763f2006-10-18 08:34:16 -0300997
Olivier Grenie9c783032009-12-07 07:49:40 -0300998 0,
999 4095,
1000 0,
1001 0,
Patrick Boettchera75763f2006-10-18 08:34:16 -03001002
Olivier Grenie9c783032009-12-07 07:49:40 -03001003 42598,
1004 16384,
1005 42598,
1006 0,
Patrick Boettchera75763f2006-10-18 08:34:16 -03001007
Olivier Grenie9c783032009-12-07 07:49:40 -03001008 0,
1009 137,
1010 255,
Patrick Boettchera75763f2006-10-18 08:34:16 -03001011
Olivier Grenie9c783032009-12-07 07:49:40 -03001012 0,
1013 255,
Patrick Boettchera75763f2006-10-18 08:34:16 -03001014
Olivier Grenie9c783032009-12-07 07:49:40 -03001015 0,
1016 0,
Patrick Boettchera75763f2006-10-18 08:34:16 -03001017
Olivier Grenie9c783032009-12-07 07:49:40 -03001018 0,
1019 41,
Patrick Boettchera75763f2006-10-18 08:34:16 -03001020
Olivier Grenie9c783032009-12-07 07:49:40 -03001021 15,
1022 25,
Patrick Boettchera75763f2006-10-18 08:34:16 -03001023
Olivier Grenie9c783032009-12-07 07:49:40 -03001024 28,
1025 48,
Patrick Boettchera75763f2006-10-18 08:34:16 -03001026
Olivier Grenie9c783032009-12-07 07:49:40 -03001027 0,
Patrick Boettchera75763f2006-10-18 08:34:16 -03001028};
1029
1030static struct dibx000_bandwidth_config stk7700p_pll_config = {
Olivier Grenie9c783032009-12-07 07:49:40 -03001031 60000, 30000,
1032 1, 8, 3, 1, 0,
1033 0, 0, 1, 1, 0,
1034 (3 << 14) | (1 << 12) | (524 << 0),
1035 60258167,
1036 20452225,
1037 30000000,
Patrick Boettcher69ea31e2006-10-17 18:28:14 -03001038};
1039
1040static struct dib7000m_config stk7700p_dib7000m_config = {
1041 .dvbt_mode = 1,
1042 .output_mpeg2_in_188_bytes = 1,
1043 .quartz_direct = 1,
1044
1045 .agc_config_count = 1,
Patrick Boettchera75763f2006-10-18 08:34:16 -03001046 .agc = &stk7700p_7000m_mt2060_agc_config,
1047 .bw = &stk7700p_pll_config,
1048
1049 .gpio_dir = DIB7000M_GPIO_DEFAULT_DIRECTIONS,
1050 .gpio_val = DIB7000M_GPIO_DEFAULT_VALUES,
1051 .gpio_pwm_pos = DIB7000M_GPIO_DEFAULT_PWM_POS,
1052};
1053
1054static struct dib7000p_config stk7700p_dib7000p_config = {
1055 .output_mpeg2_in_188_bytes = 1,
1056
Patrick Boettcherb6884a12007-07-27 10:08:51 -03001057 .agc_config_count = 1,
Patrick Boettchera75763f2006-10-18 08:34:16 -03001058 .agc = &stk7700p_7000p_mt2060_agc_config,
1059 .bw = &stk7700p_pll_config,
Patrick Boettcher69ea31e2006-10-17 18:28:14 -03001060
1061 .gpio_dir = DIB7000M_GPIO_DEFAULT_DIRECTIONS,
1062 .gpio_val = DIB7000M_GPIO_DEFAULT_VALUES,
1063 .gpio_pwm_pos = DIB7000M_GPIO_DEFAULT_PWM_POS,
1064};
Patrick Boettcherb7f54912006-09-19 12:51:37 -03001065
1066static int stk7700p_frontend_attach(struct dvb_usb_adapter *adap)
1067{
Patrick Boettcher69ea31e2006-10-17 18:28:14 -03001068 struct dib0700_state *st = adap->dev->priv;
Patrick Boettcherb7f54912006-09-19 12:51:37 -03001069 /* unless there is no real power management in DVB - we leave the device on GPIO6 */
Patrick Boettchera75763f2006-10-18 08:34:16 -03001070
1071 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
1072 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0); msleep(50);
1073
Patrick Boettcher69ea31e2006-10-17 18:28:14 -03001074 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1); msleep(10);
Patrick Boettchera75763f2006-10-18 08:34:16 -03001075 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
1076
Patrick Boettcherb7f54912006-09-19 12:51:37 -03001077 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0); msleep(10);
Patrick Boettchera75763f2006-10-18 08:34:16 -03001078 dib0700_ctrl_clock(adap->dev, 72, 1);
1079 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1); msleep(100);
1080
1081 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
Patrick Boettcherb7f54912006-09-19 12:51:37 -03001082
Patrick Boettcher69ea31e2006-10-17 18:28:14 -03001083 st->mt2060_if1[0] = 1220;
Patrick Boettchera75763f2006-10-18 08:34:16 -03001084
1085 if (dib7000pc_detection(&adap->dev->i2c_adap)) {
1086 adap->fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 18, &stk7700p_dib7000p_config);
1087 st->is_dib7000pc = 1;
1088 } else
1089 adap->fe = dvb_attach(dib7000m_attach, &adap->dev->i2c_adap, 18, &stk7700p_dib7000m_config);
1090
1091 return adap->fe == NULL ? -ENODEV : 0;
Patrick Boettcherb7f54912006-09-19 12:51:37 -03001092}
1093
Patrick Boettcher69ea31e2006-10-17 18:28:14 -03001094static struct mt2060_config stk7700p_mt2060_config = {
1095 0x60
1096};
1097
Patrick Boettcherb7f54912006-09-19 12:51:37 -03001098static int stk7700p_tuner_attach(struct dvb_usb_adapter *adap)
1099{
Olivier DANETc52344f2008-01-25 06:50:07 -03001100 struct i2c_adapter *prim_i2c = &adap->dev->i2c_adap;
Patrick Boettcher69ea31e2006-10-17 18:28:14 -03001101 struct dib0700_state *st = adap->dev->priv;
Patrick Boettchera75763f2006-10-18 08:34:16 -03001102 struct i2c_adapter *tun_i2c;
Olivier DANETc52344f2008-01-25 06:50:07 -03001103 s8 a;
1104 int if1=1220;
Al Viroda5ee482008-05-21 00:31:21 -03001105 if (adap->dev->udev->descriptor.idVendor == cpu_to_le16(USB_VID_HAUPPAUGE) &&
1106 adap->dev->udev->descriptor.idProduct == cpu_to_le16(USB_PID_HAUPPAUGE_NOVA_T_STICK)) {
Olivier DANETc52344f2008-01-25 06:50:07 -03001107 if (!eeprom_read(prim_i2c,0x58,&a)) if1=1220+a;
1108 }
Patrick Boettchera75763f2006-10-18 08:34:16 -03001109 if (st->is_dib7000pc)
1110 tun_i2c = dib7000p_get_i2c_master(adap->fe, DIBX000_I2C_INTERFACE_TUNER, 1);
1111 else
1112 tun_i2c = dib7000m_get_i2c_master(adap->fe, DIBX000_I2C_INTERFACE_TUNER, 1);
1113
1114 return dvb_attach(mt2060_attach, adap->fe, tun_i2c, &stk7700p_mt2060_config,
Olivier DANETc52344f2008-01-25 06:50:07 -03001115 if1) == NULL ? -ENODEV : 0;
Patrick Boettcherb7f54912006-09-19 12:51:37 -03001116}
1117
Patrick Boettcher01373a52007-07-30 12:49:04 -03001118/* DIB7070 generic */
1119static struct dibx000_agc_config dib7070_agc_config = {
1120 BAND_UHF | BAND_VHF | BAND_LBAND | BAND_SBAND,
1121 /* 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,
1122 * 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 */
Olivier Grenie9c783032009-12-07 07:49:40 -03001123 (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8)
1124 | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),
Patrick Boettcher01373a52007-07-30 12:49:04 -03001125
Olivier Grenie9c783032009-12-07 07:49:40 -03001126 600,
1127 10,
Patrick Boettcher01373a52007-07-30 12:49:04 -03001128
Olivier Grenie9c783032009-12-07 07:49:40 -03001129 0,
1130 118,
Patrick Boettcher01373a52007-07-30 12:49:04 -03001131
Olivier Grenie9c783032009-12-07 07:49:40 -03001132 0,
1133 3530,
1134 1,
1135 5,
Patrick Boettcher01373a52007-07-30 12:49:04 -03001136
Olivier Grenie9c783032009-12-07 07:49:40 -03001137 65535,
1138 0,
Patrick Boettcher01373a52007-07-30 12:49:04 -03001139
Olivier Grenie9c783032009-12-07 07:49:40 -03001140 65535,
1141 0,
Patrick Boettcher01373a52007-07-30 12:49:04 -03001142
Olivier Grenie9c783032009-12-07 07:49:40 -03001143 0,
1144 40,
1145 183,
1146 206,
1147 255,
1148 72,
1149 152,
1150 88,
1151 90,
Patrick Boettcher01373a52007-07-30 12:49:04 -03001152
Olivier Grenie9c783032009-12-07 07:49:40 -03001153 17,
1154 27,
1155 23,
1156 51,
Patrick Boettcher01373a52007-07-30 12:49:04 -03001157
Olivier Grenie9c783032009-12-07 07:49:40 -03001158 0,
Patrick Boettcher01373a52007-07-30 12:49:04 -03001159};
1160
1161static int dib7070_tuner_reset(struct dvb_frontend *fe, int onoff)
1162{
Patrick Boettcher7e5ce652009-08-03 13:43:40 -03001163 deb_info("reset: %d", onoff);
Patrick Boettcher01373a52007-07-30 12:49:04 -03001164 return dib7000p_set_gpio(fe, 8, 0, !onoff);
1165}
1166
1167static int dib7070_tuner_sleep(struct dvb_frontend *fe, int onoff)
1168{
Patrick Boettcher7e5ce652009-08-03 13:43:40 -03001169 deb_info("sleep: %d", onoff);
Patrick Boettcher01373a52007-07-30 12:49:04 -03001170 return dib7000p_set_gpio(fe, 9, 0, onoff);
1171}
1172
1173static struct dib0070_config dib7070p_dib0070_config[2] = {
1174 {
1175 .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
1176 .reset = dib7070_tuner_reset,
1177 .sleep = dib7070_tuner_sleep,
1178 .clock_khz = 12000,
Patrick Boettcher7e5ce652009-08-03 13:43:40 -03001179 .clock_pad_drive = 4,
1180 .charge_pump = 2,
Patrick Boettcher01373a52007-07-30 12:49:04 -03001181 }, {
1182 .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
1183 .reset = dib7070_tuner_reset,
1184 .sleep = dib7070_tuner_sleep,
1185 .clock_khz = 12000,
Patrick Boettcher7e5ce652009-08-03 13:43:40 -03001186 .charge_pump = 2,
Patrick Boettcher01373a52007-07-30 12:49:04 -03001187 }
1188};
1189
Olivier Grenied300bd62009-09-15 06:55:35 -03001190static struct dib0070_config dib7770p_dib0070_config = {
1191 .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
1192 .reset = dib7070_tuner_reset,
1193 .sleep = dib7070_tuner_sleep,
1194 .clock_khz = 12000,
1195 .clock_pad_drive = 0,
1196 .flip_chip = 1,
Olivier Grenieeac1fe12009-09-23 13:41:27 -03001197 .charge_pump = 2,
Olivier Grenied300bd62009-09-15 06:55:35 -03001198};
1199
Patrick Boettcher01373a52007-07-30 12:49:04 -03001200static int dib7070_set_param_override(struct dvb_frontend *fe, struct dvb_frontend_parameters *fep)
1201{
1202 struct dvb_usb_adapter *adap = fe->dvb->priv;
1203 struct dib0700_adapter_state *state = adap->priv;
1204
1205 u16 offset;
1206 u8 band = BAND_OF_FREQUENCY(fep->frequency/1000);
1207 switch (band) {
1208 case BAND_VHF: offset = 950; break;
1209 case BAND_UHF:
1210 default: offset = 550; break;
1211 }
1212 deb_info("WBD for DiB7000P: %d\n", offset + dib0070_wbd_offset(fe));
1213 dib7000p_set_wbd_ref(fe, offset + dib0070_wbd_offset(fe));
1214 return state->set_param_save(fe, fep);
1215}
1216
Olivier Grenied300bd62009-09-15 06:55:35 -03001217static int dib7770_set_param_override(struct dvb_frontend *fe,
1218 struct dvb_frontend_parameters *fep)
1219{
1220 struct dvb_usb_adapter *adap = fe->dvb->priv;
1221 struct dib0700_adapter_state *state = adap->priv;
1222
1223 u16 offset;
1224 u8 band = BAND_OF_FREQUENCY(fep->frequency/1000);
1225 switch (band) {
1226 case BAND_VHF:
1227 dib7000p_set_gpio(fe, 0, 0, 1);
1228 offset = 850;
1229 break;
1230 case BAND_UHF:
1231 default:
1232 dib7000p_set_gpio(fe, 0, 0, 0);
1233 offset = 250;
1234 break;
1235 }
1236 deb_info("WBD for DiB7000P: %d\n", offset + dib0070_wbd_offset(fe));
1237 dib7000p_set_wbd_ref(fe, offset + dib0070_wbd_offset(fe));
1238 return state->set_param_save(fe, fep);
1239}
1240
1241static int dib7770p_tuner_attach(struct dvb_usb_adapter *adap)
1242{
1243 struct dib0700_adapter_state *st = adap->priv;
1244 struct i2c_adapter *tun_i2c = dib7000p_get_i2c_master(adap->fe,
1245 DIBX000_I2C_INTERFACE_TUNER, 1);
1246
1247 if (dvb_attach(dib0070_attach, adap->fe, tun_i2c,
1248 &dib7770p_dib0070_config) == NULL)
1249 return -ENODEV;
1250
1251 st->set_param_save = adap->fe->ops.tuner_ops.set_params;
1252 adap->fe->ops.tuner_ops.set_params = dib7770_set_param_override;
1253 return 0;
1254}
1255
Patrick Boettcher01373a52007-07-30 12:49:04 -03001256static int dib7070p_tuner_attach(struct dvb_usb_adapter *adap)
1257{
1258 struct dib0700_adapter_state *st = adap->priv;
1259 struct i2c_adapter *tun_i2c = dib7000p_get_i2c_master(adap->fe, DIBX000_I2C_INTERFACE_TUNER, 1);
1260
1261 if (adap->id == 0) {
1262 if (dvb_attach(dib0070_attach, adap->fe, tun_i2c, &dib7070p_dib0070_config[0]) == NULL)
1263 return -ENODEV;
1264 } else {
1265 if (dvb_attach(dib0070_attach, adap->fe, tun_i2c, &dib7070p_dib0070_config[1]) == NULL)
1266 return -ENODEV;
1267 }
1268
1269 st->set_param_save = adap->fe->ops.tuner_ops.set_params;
1270 adap->fe->ops.tuner_ops.set_params = dib7070_set_param_override;
1271 return 0;
1272}
1273
Olivier Grenief8731f42009-09-18 04:08:43 -03001274static int stk70x0p_pid_filter(struct dvb_usb_adapter *adapter, int index, u16 pid, int onoff)
1275{
1276 return dib7000p_pid_filter(adapter->fe, index, pid, onoff);
1277}
1278
1279static int stk70x0p_pid_filter_ctrl(struct dvb_usb_adapter *adapter, int onoff)
1280{
1281 return dib7000p_pid_filter_ctrl(adapter->fe, onoff);
1282}
1283
Patrick Boettcher01373a52007-07-30 12:49:04 -03001284static struct dibx000_bandwidth_config dib7070_bw_config_12_mhz = {
Olivier Grenie9c783032009-12-07 07:49:40 -03001285 60000, 15000,
1286 1, 20, 3, 1, 0,
1287 0, 0, 1, 1, 2,
1288 (3 << 14) | (1 << 12) | (524 << 0),
1289 (0 << 25) | 0,
1290 20452225,
1291 12000000,
Patrick Boettcher01373a52007-07-30 12:49:04 -03001292};
1293
1294static struct dib7000p_config dib7070p_dib7000p_config = {
1295 .output_mpeg2_in_188_bytes = 1,
1296
1297 .agc_config_count = 1,
1298 .agc = &dib7070_agc_config,
1299 .bw = &dib7070_bw_config_12_mhz,
Patrick Boettcher3cb2c392008-01-25 07:25:20 -03001300 .tuner_is_baseband = 1,
1301 .spur_protect = 1,
Patrick Boettcher01373a52007-07-30 12:49:04 -03001302
1303 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
1304 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
1305 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
1306
1307 .hostbus_diversity = 1,
1308};
1309
1310/* STK7070P */
1311static int stk7070p_frontend_attach(struct dvb_usb_adapter *adap)
1312{
Al Viroda5ee482008-05-21 00:31:21 -03001313 struct usb_device_descriptor *p = &adap->dev->udev->descriptor;
1314 if (p->idVendor == cpu_to_le16(USB_VID_PINNACLE) &&
1315 p->idProduct == cpu_to_le16(USB_PID_PINNACLE_PCTV72E))
1316 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03001317 else
Al Viroda5ee482008-05-21 00:31:21 -03001318 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
Patrick Boettcher01373a52007-07-30 12:49:04 -03001319 msleep(10);
1320 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
1321 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
1322 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
1323 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
1324
1325 dib0700_ctrl_clock(adap->dev, 72, 1);
1326
1327 msleep(10);
1328 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
1329 msleep(10);
1330 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
1331
Devin Heitmueller83c4fdf2009-01-21 01:55:45 -03001332 if (dib7000p_i2c_enumeration(&adap->dev->i2c_adap, 1, 18,
1333 &dib7070p_dib7000p_config) != 0) {
1334 err("%s: dib7000p_i2c_enumeration failed. Cannot continue\n",
1335 __func__);
1336 return -ENODEV;
1337 }
Patrick Boettcher01373a52007-07-30 12:49:04 -03001338
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03001339 adap->fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 0x80,
1340 &dib7070p_dib7000p_config);
Patrick Boettcher01373a52007-07-30 12:49:04 -03001341 return adap->fe == NULL ? -ENODEV : 0;
1342}
1343
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001344/* DIB807x generic */
1345static struct dibx000_agc_config dib807x_agc_config[2] = {
1346 {
1347 BAND_VHF,
1348 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0,
1349 * P_agc_freq_pwm_div=1, P_agc_inv_pwm1=0,
1350 * P_agc_inv_pwm2=0,P_agc_inh_dc_rv_est=0,
1351 * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5,
1352 * P_agc_write=0 */
1353 (0 << 15) | (0 << 14) | (7 << 11) | (0 << 10) | (0 << 9) |
1354 (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) |
1355 (0 << 0), /* setup*/
1356
1357 600, /* inv_gain*/
1358 10, /* time_stabiliz*/
1359
1360 0, /* alpha_level*/
1361 118, /* thlock*/
1362
1363 0, /* wbd_inv*/
1364 3530, /* wbd_ref*/
1365 1, /* wbd_sel*/
1366 5, /* wbd_alpha*/
1367
1368 65535, /* agc1_max*/
1369 0, /* agc1_min*/
1370
1371 65535, /* agc2_max*/
1372 0, /* agc2_min*/
1373
1374 0, /* agc1_pt1*/
1375 40, /* agc1_pt2*/
1376 183, /* agc1_pt3*/
1377 206, /* agc1_slope1*/
1378 255, /* agc1_slope2*/
1379 72, /* agc2_pt1*/
1380 152, /* agc2_pt2*/
1381 88, /* agc2_slope1*/
1382 90, /* agc2_slope2*/
1383
1384 17, /* alpha_mant*/
1385 27, /* alpha_exp*/
1386 23, /* beta_mant*/
1387 51, /* beta_exp*/
1388
1389 0, /* perform_agc_softsplit*/
1390 }, {
1391 BAND_UHF,
1392 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0,
1393 * P_agc_freq_pwm_div=1, P_agc_inv_pwm1=0,
1394 * P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
1395 * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5,
1396 * P_agc_write=0 */
1397 (0 << 15) | (0 << 14) | (1 << 11) | (0 << 10) | (0 << 9) |
1398 (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) |
1399 (0 << 0), /* setup */
1400
1401 600, /* inv_gain*/
1402 10, /* time_stabiliz*/
1403
1404 0, /* alpha_level*/
1405 118, /* thlock*/
1406
1407 0, /* wbd_inv*/
1408 3530, /* wbd_ref*/
1409 1, /* wbd_sel*/
1410 5, /* wbd_alpha*/
1411
1412 65535, /* agc1_max*/
1413 0, /* agc1_min*/
1414
1415 65535, /* agc2_max*/
1416 0, /* agc2_min*/
1417
1418 0, /* agc1_pt1*/
1419 40, /* agc1_pt2*/
1420 183, /* agc1_pt3*/
1421 206, /* agc1_slope1*/
1422 255, /* agc1_slope2*/
1423 72, /* agc2_pt1*/
1424 152, /* agc2_pt2*/
1425 88, /* agc2_slope1*/
1426 90, /* agc2_slope2*/
1427
1428 17, /* alpha_mant*/
1429 27, /* alpha_exp*/
1430 23, /* beta_mant*/
1431 51, /* beta_exp*/
1432
1433 0, /* perform_agc_softsplit*/
1434 }
1435};
1436
1437static struct dibx000_bandwidth_config dib807x_bw_config_12_mhz = {
1438 60000, 15000, /* internal, sampling*/
1439 1, 20, 3, 1, 0, /* pll_cfg: prediv, ratio, range, reset, bypass*/
1440 0, 0, 1, 1, 2, /* misc: refdiv, bypclk_div, IO_CLK_en_core,
1441 ADClkSrc, modulo */
1442 (3 << 14) | (1 << 12) | (599 << 0), /* sad_cfg: refsel, sel, freq_15k*/
1443 (0 << 25) | 0, /* ifreq = 0.000000 MHz*/
1444 18179755, /* timf*/
1445 12000000, /* xtal_hz*/
1446};
1447
1448static struct dib8000_config dib807x_dib8000_config[2] = {
1449 {
1450 .output_mpeg2_in_188_bytes = 1,
1451
1452 .agc_config_count = 2,
1453 .agc = dib807x_agc_config,
1454 .pll = &dib807x_bw_config_12_mhz,
1455 .tuner_is_baseband = 1,
1456
1457 .gpio_dir = DIB8000_GPIO_DEFAULT_DIRECTIONS,
1458 .gpio_val = DIB8000_GPIO_DEFAULT_VALUES,
1459 .gpio_pwm_pos = DIB8000_GPIO_DEFAULT_PWM_POS,
1460
1461 .hostbus_diversity = 1,
1462 .div_cfg = 1,
1463 .agc_control = &dib0070_ctrl_agc_filter,
1464 .output_mode = OUTMODE_MPEG2_FIFO,
1465 .drives = 0x2d98,
1466 }, {
1467 .output_mpeg2_in_188_bytes = 1,
1468
1469 .agc_config_count = 2,
1470 .agc = dib807x_agc_config,
1471 .pll = &dib807x_bw_config_12_mhz,
1472 .tuner_is_baseband = 1,
1473
1474 .gpio_dir = DIB8000_GPIO_DEFAULT_DIRECTIONS,
1475 .gpio_val = DIB8000_GPIO_DEFAULT_VALUES,
1476 .gpio_pwm_pos = DIB8000_GPIO_DEFAULT_PWM_POS,
1477
1478 .hostbus_diversity = 1,
1479 .agc_control = &dib0070_ctrl_agc_filter,
1480 .output_mode = OUTMODE_MPEG2_FIFO,
1481 .drives = 0x2d98,
1482 }
1483};
1484
Olivier Grenie03245a52009-12-04 13:27:57 -03001485static int dib80xx_tuner_reset(struct dvb_frontend *fe, int onoff)
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001486{
1487 return dib8000_set_gpio(fe, 5, 0, !onoff);
1488}
1489
Olivier Grenie03245a52009-12-04 13:27:57 -03001490static int dib80xx_tuner_sleep(struct dvb_frontend *fe, int onoff)
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001491{
1492 return dib8000_set_gpio(fe, 0, 0, onoff);
1493}
1494
1495static const struct dib0070_wbd_gain_cfg dib8070_wbd_gain_cfg[] = {
1496 { 240, 7},
1497 { 0xffff, 6},
1498};
1499
1500static struct dib0070_config dib807x_dib0070_config[2] = {
1501 {
1502 .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
Olivier Grenie03245a52009-12-04 13:27:57 -03001503 .reset = dib80xx_tuner_reset,
1504 .sleep = dib80xx_tuner_sleep,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001505 .clock_khz = 12000,
1506 .clock_pad_drive = 4,
1507 .vga_filter = 1,
1508 .force_crystal_mode = 1,
1509 .enable_third_order_filter = 1,
1510 .charge_pump = 0,
1511 .wbd_gain = dib8070_wbd_gain_cfg,
1512 .osc_buffer_state = 0,
1513 .freq_offset_khz_uhf = -100,
1514 .freq_offset_khz_vhf = -100,
1515 }, {
1516 .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
Olivier Grenie03245a52009-12-04 13:27:57 -03001517 .reset = dib80xx_tuner_reset,
1518 .sleep = dib80xx_tuner_sleep,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001519 .clock_khz = 12000,
1520 .clock_pad_drive = 2,
1521 .vga_filter = 1,
1522 .force_crystal_mode = 1,
1523 .enable_third_order_filter = 1,
1524 .charge_pump = 0,
1525 .wbd_gain = dib8070_wbd_gain_cfg,
1526 .osc_buffer_state = 0,
1527 .freq_offset_khz_uhf = -25,
1528 .freq_offset_khz_vhf = -25,
1529 }
1530};
1531
1532static int dib807x_set_param_override(struct dvb_frontend *fe,
1533 struct dvb_frontend_parameters *fep)
1534{
1535 struct dvb_usb_adapter *adap = fe->dvb->priv;
1536 struct dib0700_adapter_state *state = adap->priv;
1537
1538 u16 offset = dib0070_wbd_offset(fe);
1539 u8 band = BAND_OF_FREQUENCY(fep->frequency/1000);
1540 switch (band) {
1541 case BAND_VHF:
1542 offset += 750;
1543 break;
1544 case BAND_UHF: /* fall-thru wanted */
1545 default:
1546 offset += 250; break;
1547 }
1548 deb_info("WBD for DiB8000: %d\n", offset);
1549 dib8000_set_wbd_ref(fe, offset);
1550
1551 return state->set_param_save(fe, fep);
1552}
1553
1554static int dib807x_tuner_attach(struct dvb_usb_adapter *adap)
1555{
1556 struct dib0700_adapter_state *st = adap->priv;
1557 struct i2c_adapter *tun_i2c = dib8000_get_i2c_master(adap->fe,
1558 DIBX000_I2C_INTERFACE_TUNER, 1);
1559
1560 if (adap->id == 0) {
1561 if (dvb_attach(dib0070_attach, adap->fe, tun_i2c,
1562 &dib807x_dib0070_config[0]) == NULL)
1563 return -ENODEV;
1564 } else {
1565 if (dvb_attach(dib0070_attach, adap->fe, tun_i2c,
1566 &dib807x_dib0070_config[1]) == NULL)
1567 return -ENODEV;
1568 }
1569
1570 st->set_param_save = adap->fe->ops.tuner_ops.set_params;
1571 adap->fe->ops.tuner_ops.set_params = dib807x_set_param_override;
1572 return 0;
1573}
1574
Olivier Grenie9c783032009-12-07 07:49:40 -03001575static int stk80xx_pid_filter(struct dvb_usb_adapter *adapter, int index,
1576 u16 pid, int onoff)
Olivier Grenief8731f42009-09-18 04:08:43 -03001577{
1578 return dib8000_pid_filter(adapter->fe, index, pid, onoff);
1579}
1580
Olivier Grenie9c783032009-12-07 07:49:40 -03001581static int stk80xx_pid_filter_ctrl(struct dvb_usb_adapter *adapter,
1582 int onoff)
Olivier Grenief8731f42009-09-18 04:08:43 -03001583{
1584 return dib8000_pid_filter_ctrl(adapter->fe, onoff);
1585}
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001586
1587/* STK807x */
1588static int stk807x_frontend_attach(struct dvb_usb_adapter *adap)
1589{
1590 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
1591 msleep(10);
1592 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
1593 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
1594 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
1595
1596 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
1597
1598 dib0700_ctrl_clock(adap->dev, 72, 1);
1599
1600 msleep(10);
1601 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
1602 msleep(10);
1603 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
1604
1605 dib8000_i2c_enumeration(&adap->dev->i2c_adap, 1, 18,
1606 0x80);
1607
1608 adap->fe = dvb_attach(dib8000_attach, &adap->dev->i2c_adap, 0x80,
1609 &dib807x_dib8000_config[0]);
1610
1611 return adap->fe == NULL ? -ENODEV : 0;
1612}
1613
1614/* STK807xPVR */
1615static int stk807xpvr_frontend_attach0(struct dvb_usb_adapter *adap)
1616{
1617 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
1618 msleep(30);
1619 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
1620 msleep(500);
1621 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
1622 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
1623 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
1624
1625 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
1626
1627 dib0700_ctrl_clock(adap->dev, 72, 1);
1628
1629 msleep(10);
1630 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
1631 msleep(10);
1632 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
1633
1634 /* initialize IC 0 */
1635 dib8000_i2c_enumeration(&adap->dev->i2c_adap, 1, 0x12, 0x80);
1636
1637 adap->fe = dvb_attach(dib8000_attach, &adap->dev->i2c_adap, 0x80,
1638 &dib807x_dib8000_config[0]);
1639
1640 return adap->fe == NULL ? -ENODEV : 0;
1641}
1642
1643static int stk807xpvr_frontend_attach1(struct dvb_usb_adapter *adap)
1644{
1645 /* initialize IC 1 */
1646 dib8000_i2c_enumeration(&adap->dev->i2c_adap, 1, 0x22, 0x82);
1647
1648 adap->fe = dvb_attach(dib8000_attach, &adap->dev->i2c_adap, 0x82,
1649 &dib807x_dib8000_config[1]);
1650
1651 return adap->fe == NULL ? -ENODEV : 0;
1652}
1653
Olivier Grenie03245a52009-12-04 13:27:57 -03001654/* STK8096GP */
1655struct dibx000_agc_config dib8090_agc_config[2] = {
1656 {
1657 BAND_UHF | BAND_VHF | BAND_LBAND | BAND_SBAND,
Olivier Grenie9c783032009-12-07 07:49:40 -03001658 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=1,
1659 * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
1660 * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5, P_agc_write=0 */
1661 (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8)
1662 | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),
Olivier Grenie03245a52009-12-04 13:27:57 -03001663
Olivier Grenie9c783032009-12-07 07:49:40 -03001664 787,
1665 10,
Olivier Grenie03245a52009-12-04 13:27:57 -03001666
Olivier Grenie9c783032009-12-07 07:49:40 -03001667 0,
1668 118,
Olivier Grenie03245a52009-12-04 13:27:57 -03001669
Olivier Grenie9c783032009-12-07 07:49:40 -03001670 0,
1671 3530,
1672 1,
1673 5,
Olivier Grenie03245a52009-12-04 13:27:57 -03001674
Olivier Grenie9c783032009-12-07 07:49:40 -03001675 65535,
1676 0,
Olivier Grenie03245a52009-12-04 13:27:57 -03001677
Olivier Grenie9c783032009-12-07 07:49:40 -03001678 65535,
1679 0,
Olivier Grenie03245a52009-12-04 13:27:57 -03001680
Olivier Grenie9c783032009-12-07 07:49:40 -03001681 0,
1682 32,
1683 114,
1684 143,
1685 144,
1686 114,
1687 227,
1688 116,
1689 117,
Olivier Grenie03245a52009-12-04 13:27:57 -03001690
Olivier Grenie9c783032009-12-07 07:49:40 -03001691 28,
1692 26,
1693 31,
1694 51,
Olivier Grenie03245a52009-12-04 13:27:57 -03001695
Olivier Grenie9c783032009-12-07 07:49:40 -03001696 0,
Olivier Grenie03245a52009-12-04 13:27:57 -03001697 },
1698 {
1699 BAND_CBAND,
Olivier Grenie9c783032009-12-07 07:49:40 -03001700 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=1,
1701 * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
1702 * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5, P_agc_write=0 */
1703 (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8)
1704 | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),
Olivier Grenie03245a52009-12-04 13:27:57 -03001705
Olivier Grenie9c783032009-12-07 07:49:40 -03001706 787,
1707 10,
Olivier Grenie03245a52009-12-04 13:27:57 -03001708
Olivier Grenie9c783032009-12-07 07:49:40 -03001709 0,
1710 118,
Olivier Grenie03245a52009-12-04 13:27:57 -03001711
Olivier Grenie9c783032009-12-07 07:49:40 -03001712 0,
1713 3530,
1714 1,
1715 5,
Olivier Grenie03245a52009-12-04 13:27:57 -03001716
Olivier Grenie9c783032009-12-07 07:49:40 -03001717 0,
1718 0,
Olivier Grenie03245a52009-12-04 13:27:57 -03001719
Olivier Grenie9c783032009-12-07 07:49:40 -03001720 65535,
1721 0,
Olivier Grenie03245a52009-12-04 13:27:57 -03001722
Olivier Grenie9c783032009-12-07 07:49:40 -03001723 0,
1724 32,
1725 114,
1726 143,
1727 144,
1728 114,
1729 227,
1730 116,
1731 117,
Olivier Grenie03245a52009-12-04 13:27:57 -03001732
Olivier Grenie9c783032009-12-07 07:49:40 -03001733 28,
1734 26,
1735 31,
1736 51,
Olivier Grenie03245a52009-12-04 13:27:57 -03001737
Olivier Grenie9c783032009-12-07 07:49:40 -03001738 0,
Olivier Grenie03245a52009-12-04 13:27:57 -03001739 }
1740};
1741
1742static struct dibx000_bandwidth_config dib8090_pll_config_12mhz = {
Olivier Grenie9c783032009-12-07 07:49:40 -03001743 54000, 13500,
1744 1, 18, 3, 1, 0,
1745 0, 0, 1, 1, 2,
1746 (3 << 14) | (1 << 12) | (599 << 0),
1747 (0 << 25) | 0,
1748 20199727,
1749 12000000,
Olivier Grenie03245a52009-12-04 13:27:57 -03001750};
1751
1752static int dib8090_get_adc_power(struct dvb_frontend *fe)
1753{
1754 return dib8000_get_adc_power(fe, 1);
1755}
1756
1757static struct dib8000_config dib809x_dib8000_config = {
1758 .output_mpeg2_in_188_bytes = 1,
1759
1760 .agc_config_count = 2,
1761 .agc = dib8090_agc_config,
1762 .agc_control = dib0090_dcc_freq,
1763 .pll = &dib8090_pll_config_12mhz,
1764 .tuner_is_baseband = 1,
1765
1766 .gpio_dir = DIB8000_GPIO_DEFAULT_DIRECTIONS,
1767 .gpio_val = DIB8000_GPIO_DEFAULT_VALUES,
1768 .gpio_pwm_pos = DIB8000_GPIO_DEFAULT_PWM_POS,
1769
1770 .hostbus_diversity = 1,
1771 .div_cfg = 0x31,
1772 .output_mode = OUTMODE_MPEG2_FIFO,
1773 .drives = 0x2d98,
1774 .diversity_delay = 144,
1775 .refclksel = 3,
1776};
1777
1778static struct dib0090_config dib809x_dib0090_config = {
1779 .io.pll_bypass = 1,
1780 .io.pll_range = 1,
1781 .io.pll_prediv = 1,
1782 .io.pll_loopdiv = 20,
1783 .io.adc_clock_ratio = 8,
1784 .io.pll_int_loop_filt = 0,
1785 .io.clock_khz = 12000,
1786 .reset = dib80xx_tuner_reset,
1787 .sleep = dib80xx_tuner_sleep,
1788 .clkouttobamse = 1,
1789 .analog_output = 1,
1790 .i2c_address = DEFAULT_DIB0090_I2C_ADDRESS,
1791 .wbd_vhf_offset = 100,
1792 .wbd_cband_offset = 450,
1793 .use_pwm_agc = 1,
1794 .clkoutdrive = 1,
1795 .get_adc_power = dib8090_get_adc_power,
1796 .freq_offset_khz_uhf = 0,
1797 .freq_offset_khz_vhf = -143,
1798};
1799
1800static int dib8096_set_param_override(struct dvb_frontend *fe,
1801 struct dvb_frontend_parameters *fep)
1802{
1803 struct dvb_usb_adapter *adap = fe->dvb->priv;
1804 struct dib0700_adapter_state *state = adap->priv;
1805 u8 band = BAND_OF_FREQUENCY(fep->frequency/1000);
1806 u16 offset;
1807 int ret = 0;
1808 enum frontend_tune_state tune_state = CT_SHUTDOWN;
1809 u16 ltgain, rf_gain_limit;
1810
1811 ret = state->set_param_save(fe, fep);
1812 if (ret < 0)
1813 return ret;
1814
1815 switch (band) {
Olivier Grenie9c783032009-12-07 07:49:40 -03001816 case BAND_VHF:
Olivier Grenie03245a52009-12-04 13:27:57 -03001817 offset = 100;
1818 break;
Olivier Grenie9c783032009-12-07 07:49:40 -03001819 case BAND_UHF:
Olivier Grenie03245a52009-12-04 13:27:57 -03001820 offset = 550;
1821 break;
Olivier Grenie9c783032009-12-07 07:49:40 -03001822 default:
Olivier Grenie03245a52009-12-04 13:27:57 -03001823 offset = 0;
1824 break;
1825 }
1826 offset += (dib0090_get_wbd_offset(fe) * 8 * 18 / 33 + 1) / 2;
1827 dib8000_set_wbd_ref(fe, offset);
1828
1829
Olivier Grenie9c783032009-12-07 07:49:40 -03001830 if (band == BAND_CBAND) {
Olivier Grenie03245a52009-12-04 13:27:57 -03001831 deb_info("tuning in CBAND - soft-AGC startup\n");
1832 /* TODO specific wbd target for dib0090 - needed for startup ? */
1833 dib0090_set_tune_state(fe, CT_AGC_START);
Olivier Grenie9c783032009-12-07 07:49:40 -03001834 do {
1835 ret = dib0090_gain_control(fe);
1836 msleep(ret);
1837 tune_state = dib0090_get_tune_state(fe);
1838 if (tune_state == CT_AGC_STEP_0)
1839 dib8000_set_gpio(fe, 6, 0, 1);
1840 else if (tune_state == CT_AGC_STEP_1) {
1841 dib0090_get_current_gain(fe, NULL, NULL, &rf_gain_limit, &ltgain);
1842 if (rf_gain_limit == 0)
1843 dib8000_set_gpio(fe, 6, 0, 0);
1844 }
1845 } while (tune_state < CT_AGC_STOP);
Olivier Grenie03245a52009-12-04 13:27:57 -03001846 dib0090_pwm_gain_reset(fe);
1847 dib8000_pwm_agc_reset(fe);
1848 dib8000_set_tune_state(fe, CT_DEMOD_START);
Olivier Grenie9c783032009-12-07 07:49:40 -03001849 } else {
Olivier Grenie03245a52009-12-04 13:27:57 -03001850 deb_info("not tuning in CBAND - standard AGC startup\n");
1851 dib0090_pwm_gain_reset(fe);
1852 }
1853
1854 return 0;
1855}
1856
1857static int dib809x_tuner_attach(struct dvb_usb_adapter *adap)
1858{
1859 struct dib0700_adapter_state *st = adap->priv;
1860 struct i2c_adapter *tun_i2c = dib8000_get_i2c_master(adap->fe, DIBX000_I2C_INTERFACE_TUNER, 1);
1861
1862 if (dvb_attach(dib0090_register, adap->fe, tun_i2c, &dib809x_dib0090_config) == NULL)
1863 return -ENODEV;
1864
1865 st->set_param_save = adap->fe->ops.tuner_ops.set_params;
1866 adap->fe->ops.tuner_ops.set_params = dib8096_set_param_override;
1867 return 0;
1868}
1869
1870static int stk809x_frontend_attach(struct dvb_usb_adapter *adap)
1871{
1872 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
1873 msleep(10);
1874 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
1875 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
1876 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
1877
1878 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
1879
1880 dib0700_ctrl_clock(adap->dev, 72, 1);
1881
1882 msleep(10);
1883 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
1884 msleep(10);
1885 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
1886
1887 dib8000_i2c_enumeration(&adap->dev->i2c_adap, 1, 18, 0x80);
1888
1889 adap->fe = dvb_attach(dib8000_attach, &adap->dev->i2c_adap, 0x80, &dib809x_dib8000_config);
1890
1891 return adap->fe == NULL ? -ENODEV : 0;
1892}
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001893
Patrick Boettcher01373a52007-07-30 12:49:04 -03001894/* STK7070PD */
1895static struct dib7000p_config stk7070pd_dib7000p_config[2] = {
1896 {
1897 .output_mpeg2_in_188_bytes = 1,
1898
1899 .agc_config_count = 1,
1900 .agc = &dib7070_agc_config,
1901 .bw = &dib7070_bw_config_12_mhz,
Patrick Boettcher3cb2c392008-01-25 07:25:20 -03001902 .tuner_is_baseband = 1,
1903 .spur_protect = 1,
Patrick Boettcher01373a52007-07-30 12:49:04 -03001904
1905 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
1906 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
1907 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
1908
1909 .hostbus_diversity = 1,
1910 }, {
1911 .output_mpeg2_in_188_bytes = 1,
1912
1913 .agc_config_count = 1,
1914 .agc = &dib7070_agc_config,
1915 .bw = &dib7070_bw_config_12_mhz,
Patrick Boettcher3cb2c392008-01-25 07:25:20 -03001916 .tuner_is_baseband = 1,
1917 .spur_protect = 1,
Patrick Boettcher01373a52007-07-30 12:49:04 -03001918
1919 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
1920 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
1921 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
1922
1923 .hostbus_diversity = 1,
1924 }
1925};
1926
1927static int stk7070pd_frontend_attach0(struct dvb_usb_adapter *adap)
1928{
1929 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
1930 msleep(10);
1931 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
1932 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
1933 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
1934 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
1935
1936 dib0700_ctrl_clock(adap->dev, 72, 1);
1937
1938 msleep(10);
1939 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
1940 msleep(10);
1941 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
1942
Devin Heitmueller83c4fdf2009-01-21 01:55:45 -03001943 if (dib7000p_i2c_enumeration(&adap->dev->i2c_adap, 2, 18,
1944 stk7070pd_dib7000p_config) != 0) {
1945 err("%s: dib7000p_i2c_enumeration failed. Cannot continue\n",
1946 __func__);
1947 return -ENODEV;
1948 }
Patrick Boettcher01373a52007-07-30 12:49:04 -03001949
1950 adap->fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 0x80, &stk7070pd_dib7000p_config[0]);
1951 return adap->fe == NULL ? -ENODEV : 0;
1952}
1953
1954static int stk7070pd_frontend_attach1(struct dvb_usb_adapter *adap)
1955{
1956 adap->fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 0x82, &stk7070pd_dib7000p_config[1]);
1957 return adap->fe == NULL ? -ENODEV : 0;
1958}
1959
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03001960/* S5H1411 */
1961static struct s5h1411_config pinnacle_801e_config = {
1962 .output_mode = S5H1411_PARALLEL_OUTPUT,
1963 .gpio = S5H1411_GPIO_OFF,
1964 .mpeg_timing = S5H1411_MPEGTIMING_NONCONTINOUS_NONINVERTING_CLOCK,
1965 .qam_if = S5H1411_IF_44000,
1966 .vsb_if = S5H1411_IF_44000,
1967 .inversion = S5H1411_INVERSION_OFF,
1968 .status_mode = S5H1411_DEMODLOCKING
1969};
1970
1971/* Pinnacle PCTV HD Pro 801e GPIOs map:
1972 GPIO0 - currently unknown
1973 GPIO1 - xc5000 tuner reset
1974 GPIO2 - CX25843 sleep
1975 GPIO3 - currently unknown
1976 GPIO4 - currently unknown
1977 GPIO6 - currently unknown
1978 GPIO7 - currently unknown
1979 GPIO9 - currently unknown
1980 GPIO10 - CX25843 reset
1981 */
1982static int s5h1411_frontend_attach(struct dvb_usb_adapter *adap)
1983{
1984 struct dib0700_state *st = adap->dev->priv;
1985
1986 /* Make use of the new i2c functions from FW 1.20 */
1987 st->fw_use_new_i2c_api = 1;
1988
1989 /* The s5h1411 requires the dib0700 to not be in master mode */
1990 st->disable_streaming_master_mode = 1;
1991
1992 /* All msleep values taken from Windows USB trace */
1993 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 0);
1994 dib0700_set_gpio(adap->dev, GPIO3, GPIO_OUT, 0);
1995 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
1996 msleep(400);
1997 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
1998 msleep(60);
1999 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
2000 msleep(30);
2001 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
2002 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
2003 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
2004 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
2005 dib0700_set_gpio(adap->dev, GPIO2, GPIO_OUT, 0);
2006 msleep(30);
2007
2008 /* Put the CX25843 to sleep for now since we're in digital mode */
2009 dib0700_set_gpio(adap->dev, GPIO2, GPIO_OUT, 1);
2010
2011 /* GPIOs are initialized, do the attach */
2012 adap->fe = dvb_attach(s5h1411_attach, &pinnacle_801e_config,
2013 &adap->dev->i2c_adap);
2014 return adap->fe == NULL ? -ENODEV : 0;
2015}
2016
Michael Krufky767f3b32008-09-25 09:47:07 -03002017static int dib0700_xc5000_tuner_callback(void *priv, int component,
2018 int command, int arg)
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03002019{
2020 struct dvb_usb_adapter *adap = priv;
2021
Devin Heitmueller79025a92008-10-06 12:07:48 -03002022 if (command == XC5000_TUNER_RESET) {
2023 /* Reset the tuner */
2024 dib0700_set_gpio(adap->dev, GPIO1, GPIO_OUT, 0);
Devin Heitmuellerf0f46332009-05-04 21:57:41 -03002025 msleep(10);
Devin Heitmueller79025a92008-10-06 12:07:48 -03002026 dib0700_set_gpio(adap->dev, GPIO1, GPIO_OUT, 1);
Devin Heitmuellerf0f46332009-05-04 21:57:41 -03002027 msleep(10);
Devin Heitmueller79025a92008-10-06 12:07:48 -03002028 } else {
2029 err("xc5000: unknown tuner callback command: %d\n", command);
2030 return -EINVAL;
2031 }
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03002032
2033 return 0;
2034}
2035
2036static struct xc5000_config s5h1411_xc5000_tunerconfig = {
2037 .i2c_address = 0x64,
2038 .if_khz = 5380,
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03002039};
2040
2041static int xc5000_tuner_attach(struct dvb_usb_adapter *adap)
2042{
Devin Heitmueller79025a92008-10-06 12:07:48 -03002043 /* FIXME: generalize & move to common area */
2044 adap->fe->callback = dib0700_xc5000_tuner_callback;
2045
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03002046 return dvb_attach(xc5000_attach, adap->fe, &adap->dev->i2c_adap,
Michael Krufky767f3b32008-09-25 09:47:07 -03002047 &s5h1411_xc5000_tunerconfig)
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03002048 == NULL ? -ENODEV : 0;
2049}
2050
Michael Krufkyce904bc2009-01-19 01:12:55 -03002051static struct lgdt3305_config hcw_lgdt3305_config = {
2052 .i2c_addr = 0x0e,
2053 .mpeg_mode = LGDT3305_MPEG_PARALLEL,
2054 .tpclk_edge = LGDT3305_TPCLK_FALLING_EDGE,
2055 .tpvalid_polarity = LGDT3305_TP_VALID_LOW,
2056 .deny_i2c_rptr = 0,
2057 .spectral_inversion = 1,
2058 .qam_if_khz = 6000,
2059 .vsb_if_khz = 6000,
2060 .usref_8vsb = 0x0500,
2061};
2062
2063static struct mxl5007t_config hcw_mxl5007t_config = {
2064 .xtal_freq_hz = MxL_XTAL_25_MHZ,
2065 .if_freq_hz = MxL_IF_6_MHZ,
2066 .invert_if = 1,
2067};
2068
2069/* TIGER-ATSC map:
2070 GPIO0 - LNA_CTR (H: LNA power enabled, L: LNA power disabled)
2071 GPIO1 - ANT_SEL (H: VPA, L: MCX)
2072 GPIO4 - SCL2
2073 GPIO6 - EN_TUNER
2074 GPIO7 - SDA2
2075 GPIO10 - DEM_RST
2076
2077 MXL is behind LG's i2c repeater. LG is on SCL2/SDA2 gpios on the DIB
2078 */
2079static int lgdt3305_frontend_attach(struct dvb_usb_adapter *adap)
2080{
2081 struct dib0700_state *st = adap->dev->priv;
2082
2083 /* Make use of the new i2c functions from FW 1.20 */
2084 st->fw_use_new_i2c_api = 1;
2085
2086 st->disable_streaming_master_mode = 1;
2087
2088 /* fe power enable */
2089 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
2090 msleep(30);
2091 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
2092 msleep(30);
2093
2094 /* demod reset */
2095 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
2096 msleep(30);
2097 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
2098 msleep(30);
2099 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
2100 msleep(30);
2101
2102 adap->fe = dvb_attach(lgdt3305_attach,
2103 &hcw_lgdt3305_config,
2104 &adap->dev->i2c_adap);
2105
2106 return adap->fe == NULL ? -ENODEV : 0;
2107}
2108
2109static int mxl5007t_tuner_attach(struct dvb_usb_adapter *adap)
2110{
2111 return dvb_attach(mxl5007t_attach, adap->fe,
2112 &adap->dev->i2c_adap, 0x60,
2113 &hcw_mxl5007t_config) == NULL ? -ENODEV : 0;
2114}
2115
2116
Patrick Boettcher01373a52007-07-30 12:49:04 -03002117/* DVB-USB and USB stuff follows */
Patrick Boettcherb7f54912006-09-19 12:51:37 -03002118struct usb_device_id dib0700_usb_id_table[] = {
Patrick Boettcher01373a52007-07-30 12:49:04 -03002119/* 0 */ { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7700P) },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03002120 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7700P_PC) },
2121 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_500) },
2122 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_500_2) },
2123 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_STICK) },
Patrick Boettcher01373a52007-07-30 12:49:04 -03002124/* 5 */ { USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR) },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03002125 { USB_DEVICE(USB_VID_COMPRO, USB_PID_COMPRO_VIDEOMATE_U500) },
2126 { USB_DEVICE(USB_VID_UNIWILL, USB_PID_UNIWILL_STK7700P) },
2127 { USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV_DONGLE_STK7700P) },
2128 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_STICK_2) },
Patrick Boettcher01373a52007-07-30 12:49:04 -03002129/* 10 */{ USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR_2) },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03002130 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV2000E) },
2131 { USB_DEVICE(USB_VID_TERRATEC,
2132 USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY) },
2133 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_TD_STICK) },
2134 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7700D) },
Patrick Boettcher01373a52007-07-30 12:49:04 -03002135/* 15 */{ USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7070P) },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03002136 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV_DVB_T_FLASH) },
2137 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7070PD) },
2138 { USB_DEVICE(USB_VID_PINNACLE,
2139 USB_PID_PINNACLE_PCTV_DUAL_DIVERSITY_DVB_T) },
2140 { USB_DEVICE(USB_VID_COMPRO, USB_PID_COMPRO_VIDEOMATE_U500_PC) },
Joachim Steigerfa3b8772007-10-08 20:08:46 -03002141/* 20 */{ USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_EXPRESS) },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03002142 { USB_DEVICE(USB_VID_GIGABYTE, USB_PID_GIGABYTE_U7000) },
2143 { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC, USB_PID_ARTEC_T14BR) },
2144 { USB_DEVICE(USB_VID_ASUS, USB_PID_ASUS_U3000) },
2145 { USB_DEVICE(USB_VID_ASUS, USB_PID_ASUS_U3100) },
2146/* 25 */{ USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_STICK_3) },
2147 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_MYTV_T) },
2148 { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_HT_USB_XE) },
2149 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_EXPRESSCARD_320CX) },
2150 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV72E) },
2151/* 30 */{ USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV73E) },
2152 { USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_EC372S) },
2153 { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_HT_EXPRESS) },
Alexander Simondc888072008-03-29 21:37:54 -03002154 { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_XXS) },
Darryl Green5da4e2c2008-03-29 21:47:43 -03002155 { USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV_DONGLE_STK7700P_2) },
Michael Krufkyaf2a8872008-09-03 17:12:24 -03002156/* 35 */{ USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_TD_STICK_52009) },
Michael Krufky9a0c04a2008-09-03 17:12:24 -03002157 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_500_3) },
Finn Thain17a370b2008-09-06 13:42:47 -03002158 { USB_DEVICE(USB_VID_GIGABYTE, USB_PID_GIGABYTE_U8000) },
Daniel Oliveira Nascimento8751aaa2008-09-07 12:39:44 -03002159 { USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_STK7700PH) },
Albert Comerma57697432008-09-07 12:43:33 -03002160 { USB_DEVICE(USB_VID_ASUS, USB_PID_ASUS_U3000H) },
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03002161/* 40 */{ USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV801E) },
Devin Heitmuellerd2fc3bf2008-09-25 06:22:23 -03002162 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV801E_SE) },
Yusuf Altinbb1b0822009-01-08 07:58:45 -03002163 { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_EXPRESS) },
Nicolas Fournierdb4b2d12009-01-13 07:15:25 -03002164 { USB_DEVICE(USB_VID_TERRATEC,
2165 USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY_2) },
sebastian.blanes@gmail.com0a6e1ed2009-02-24 14:51:43 -03002166 { USB_DEVICE(USB_VID_SONY, USB_PID_SONY_PLAYTV) },
Pascal Terjan9abb6e62009-02-26 10:31:41 -03002167/* 45 */{ USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_PD378S) },
Michael Krufkyce904bc2009-01-19 01:12:55 -03002168 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_TIGER_ATSC) },
2169 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_TIGER_ATSC_B210) },
Xoan Loureiro16ba1ee2009-03-29 08:43:36 -03002170 { USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_MC770) },
Klaus Flittner919a5482009-03-29 09:12:06 -03002171 { USB_DEVICE(USB_VID_ELGATO, USB_PID_ELGATO_EYETV_DTT) },
Armin Schenker513846e2009-04-20 11:57:49 -03002172/* 50 */{ USB_DEVICE(USB_VID_ELGATO, USB_PID_ELGATO_EYETV_DTT_Dlx) },
tomas petrf0f4ae72009-05-20 05:28:05 -03002173 { USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV_DONGLE_H) },
Patrick Boettchera9b8fe32009-05-20 05:35:02 -03002174 { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_T3) },
2175 { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_T5) },
Pete Hildebrandtc53d83c2009-08-05 11:46:38 -03002176 { USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_STK7700D) },
Olivier Grenie74b76f22009-09-02 08:19:19 -03002177/* 55 */{ USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_STK7700D_2) },
2178 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV73A) },
Patrick Boettchere4147532009-11-30 13:52:57 -03002179 { USB_DEVICE(USB_VID_PCTV, USB_PID_PINNACLE_PCTV73ESE) },
2180 { USB_DEVICE(USB_VID_PCTV, USB_PID_PINNACLE_PCTV282E) },
Olivier Grenied300bd62009-09-15 06:55:35 -03002181 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7770P) },
Patrick Boettcherdb481382009-09-15 07:16:51 -03002182/* 60 */{ USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_XXS_2) },
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03002183 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK807XPVR) },
2184 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK807XP) },
Mauro Carvalho Chehabaaeab302009-09-16 09:18:26 -03002185 { USB_DEVICE(USB_VID_PIXELVIEW, USB_PID_PIXELVIEW_SBTVD) },
S?rgio Fortier8a378e82009-09-28 04:19:21 -03002186 { USB_DEVICE(USB_VID_EVOLUTEPC, USB_PID_TVWAY_PLUS) },
Patrick Boettcher20232c42009-12-01 12:08:56 -03002187/* 65 */{ USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV73ESE) },
Patrick Boettchere4147532009-11-30 13:52:57 -03002188 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV282E) },
Olivier Grenie03245a52009-12-04 13:27:57 -03002189 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK8096GP) },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03002190 { 0 } /* Terminating entry */
Patrick Boettcherb7f54912006-09-19 12:51:37 -03002191};
2192MODULE_DEVICE_TABLE(usb, dib0700_usb_id_table);
2193
2194#define DIB0700_DEFAULT_DEVICE_PROPERTIES \
2195 .caps = DVB_USB_IS_AN_I2C_ADAPTER, \
2196 .usb_ctrl = DEVICE_SPECIFIC, \
Devin Heitmuellerbdc203e2008-09-06 13:45:27 -03002197 .firmware = "dvb-usb-dib0700-1.20.fw", \
Patrick Boettcherb7f54912006-09-19 12:51:37 -03002198 .download_firmware = dib0700_download_firmware, \
Patrick Boettcher6958eff2006-09-19 12:51:40 -03002199 .no_reconnect = 1, \
Patrick Boettcherb7f54912006-09-19 12:51:37 -03002200 .size_of_priv = sizeof(struct dib0700_state), \
Patrick Boettcher6958eff2006-09-19 12:51:40 -03002201 .i2c_algo = &dib0700_i2c_algo, \
2202 .identify_state = dib0700_identify_state
Patrick Boettcherb7f54912006-09-19 12:51:37 -03002203
2204#define DIB0700_DEFAULT_STREAMING_CONFIG(ep) \
2205 .streaming_ctrl = dib0700_streaming_ctrl, \
2206 .stream = { \
2207 .type = USB_BULK, \
2208 .count = 4, \
2209 .endpoint = ep, \
2210 .u = { \
2211 .bulk = { \
2212 .buffersize = 39480, \
2213 } \
2214 } \
2215 }
2216
2217struct dvb_usb_device_properties dib0700_devices[] = {
2218 {
2219 DIB0700_DEFAULT_DEVICE_PROPERTIES,
2220
2221 .num_adapters = 1,
2222 .adapter = {
2223 {
Olivier Grenief8731f42009-09-18 04:08:43 -03002224 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
2225 .pid_filter_count = 32,
2226 .pid_filter = stk70x0p_pid_filter,
2227 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
Patrick Boettcherb7f54912006-09-19 12:51:37 -03002228 .frontend_attach = stk7700p_frontend_attach,
2229 .tuner_attach = stk7700p_tuner_attach,
2230
2231 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
2232 },
2233 },
2234
dominik67053a42007-11-10 19:23:31 -03002235 .num_device_descs = 8,
Patrick Boettcherb7f54912006-09-19 12:51:37 -03002236 .devices = {
2237 { "DiBcom STK7700P reference design",
Tomi Koivulahti49a13762006-10-19 07:27:19 -03002238 { &dib0700_usb_id_table[0], &dib0700_usb_id_table[1] },
Patrick Boettcherb7f54912006-09-19 12:51:37 -03002239 { NULL },
2240 },
2241 { "Hauppauge Nova-T Stick",
Stefan Trabyf9aeba42006-11-12 13:02:51 -03002242 { &dib0700_usb_id_table[4], &dib0700_usb_id_table[9], NULL },
Patrick Boettcherb7f54912006-09-19 12:51:37 -03002243 { NULL },
2244 },
Tomi Koivulahti49a13762006-10-19 07:27:19 -03002245 { "AVerMedia AVerTV DVB-T Volar",
Jose Carlos Garcia Sogoced8fec2006-11-14 05:01:47 -03002246 { &dib0700_usb_id_table[5], &dib0700_usb_id_table[10] },
Tomi Koivulahti49a13762006-10-19 07:27:19 -03002247 { NULL },
2248 },
2249 { "Compro Videomate U500",
Patrick Boettcher1f8ca4b2007-07-30 14:24:37 -03002250 { &dib0700_usb_id_table[6], &dib0700_usb_id_table[19] },
Tomi Koivulahti49a13762006-10-19 07:27:19 -03002251 { NULL },
Henning Schroeer0ce215e2006-10-19 07:58:22 -03002252 },
2253 { "Uniwill STK7700P based (Hama and others)",
2254 { &dib0700_usb_id_table[7], NULL },
2255 { NULL },
Michael Krufky8637a872006-11-08 16:47:32 -03002256 },
2257 { "Leadtek Winfast DTV Dongle (STK7700P based)",
Patrick Boettcher1e13c8f2009-09-19 05:24:40 -03002258 { &dib0700_usb_id_table[8], &dib0700_usb_id_table[34] },
Michael Krufky8637a872006-11-08 16:47:32 -03002259 { NULL },
Joachim Steigerfa3b8772007-10-08 20:08:46 -03002260 },
2261 { "AVerMedia AVerTV DVB-T Express",
2262 { &dib0700_usb_id_table[20] },
2263 { NULL },
dominik67053a42007-11-10 19:23:31 -03002264 },
dominik67053a42007-11-10 19:23:31 -03002265 { "Gigabyte U7000",
2266 { &dib0700_usb_id_table[21], NULL },
2267 { NULL },
Tomi Koivulahti49a13762006-10-19 07:27:19 -03002268 }
Darren Saltb1139e32007-08-18 18:05:31 -03002269 },
2270
2271 .rc_interval = DEFAULT_RC_INTERVAL,
2272 .rc_key_map = dib0700_rc_keys,
2273 .rc_key_map_size = ARRAY_SIZE(dib0700_rc_keys),
2274 .rc_query = dib0700_rc_query
Patrick Boettcherb7f54912006-09-19 12:51:37 -03002275 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
2276
2277 .num_adapters = 2,
2278 .adapter = {
2279 {
2280 .frontend_attach = bristol_frontend_attach,
2281 .tuner_attach = bristol_tuner_attach,
2282
2283 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
2284 }, {
2285 .frontend_attach = bristol_frontend_attach,
2286 .tuner_attach = bristol_tuner_attach,
2287
2288 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
2289 }
2290 },
2291
2292 .num_device_descs = 1,
2293 .devices = {
2294 { "Hauppauge Nova-T 500 Dual DVB-T",
Tomi Koivulahti49a13762006-10-19 07:27:19 -03002295 { &dib0700_usb_id_table[2], &dib0700_usb_id_table[3], NULL },
Patrick Boettcherb7f54912006-09-19 12:51:37 -03002296 { NULL },
2297 },
Janne Grunau82f3d552007-07-30 13:50:28 -03002298 },
2299
2300 .rc_interval = DEFAULT_RC_INTERVAL,
2301 .rc_key_map = dib0700_rc_keys,
Patrick Boettcher87797372007-07-30 17:02:17 -03002302 .rc_key_map_size = ARRAY_SIZE(dib0700_rc_keys),
Janne Grunau82f3d552007-07-30 13:50:28 -03002303 .rc_query = dib0700_rc_query
Olivier DANET54d75eb2007-07-25 14:42:54 -03002304 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
2305
2306 .num_adapters = 2,
2307 .adapter = {
2308 {
Olivier Grenief8731f42009-09-18 04:08:43 -03002309 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
2310 .pid_filter_count = 32,
2311 .pid_filter = stk70x0p_pid_filter,
2312 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
Olivier DANET54d75eb2007-07-25 14:42:54 -03002313 .frontend_attach = stk7700d_frontend_attach,
2314 .tuner_attach = stk7700d_tuner_attach,
2315
2316 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
2317 }, {
Olivier Grenief8731f42009-09-18 04:08:43 -03002318 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
2319 .pid_filter_count = 32,
2320 .pid_filter = stk70x0p_pid_filter,
2321 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
Olivier DANET54d75eb2007-07-25 14:42:54 -03002322 .frontend_attach = stk7700d_frontend_attach,
2323 .tuner_attach = stk7700d_tuner_attach,
2324
2325 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
2326 }
2327 },
2328
James A Webb200e8612009-08-04 02:38:05 -03002329 .num_device_descs = 5,
Olivier DANET54d75eb2007-07-25 14:42:54 -03002330 .devices = {
2331 { "Pinnacle PCTV 2000e",
2332 { &dib0700_usb_id_table[11], NULL },
2333 { NULL },
2334 },
2335 { "Terratec Cinergy DT XS Diversity",
2336 { &dib0700_usb_id_table[12], NULL },
2337 { NULL },
2338 },
Darren Saltfaebb912007-08-18 18:04:00 -03002339 { "Hauppauge Nova-TD Stick/Elgato Eye-TV Diversity",
Olivier DANET54d75eb2007-07-25 14:42:54 -03002340 { &dib0700_usb_id_table[13], NULL },
2341 { NULL },
2342 },
Patrick Boettcher01373a52007-07-30 12:49:04 -03002343 { "DiBcom STK7700D reference design",
Patrick Boettcherb6884a12007-07-27 10:08:51 -03002344 { &dib0700_usb_id_table[14], NULL },
2345 { NULL },
Yusuf Altinbb1b0822009-01-08 07:58:45 -03002346 },
James A Webb200e8612009-08-04 02:38:05 -03002347 { "YUAN High-Tech DiBcom STK7700D",
2348 { &dib0700_usb_id_table[55], NULL },
2349 { NULL },
2350 },
Yusuf Altinbb1b0822009-01-08 07:58:45 -03002351
Olivier DANET54d75eb2007-07-25 14:42:54 -03002352 },
Janne Grunau82f3d552007-07-30 13:50:28 -03002353
Olivier DANET54d75eb2007-07-25 14:42:54 -03002354 .rc_interval = DEFAULT_RC_INTERVAL,
Janne Grunau82f3d552007-07-30 13:50:28 -03002355 .rc_key_map = dib0700_rc_keys,
Patrick Boettcher87797372007-07-30 17:02:17 -03002356 .rc_key_map_size = ARRAY_SIZE(dib0700_rc_keys),
Janne Grunau82f3d552007-07-30 13:50:28 -03002357 .rc_query = dib0700_rc_query
Patrick Boettcher01373a52007-07-30 12:49:04 -03002358
2359 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
2360
2361 .num_adapters = 1,
2362 .adapter = {
2363 {
Olivier Grenief8731f42009-09-18 04:08:43 -03002364 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
2365 .pid_filter_count = 32,
2366 .pid_filter = stk70x0p_pid_filter,
2367 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
Daniel Gimpelevich132c3182008-01-25 06:02:42 -03002368 .frontend_attach = stk7700P2_frontend_attach,
2369 .tuner_attach = stk7700d_tuner_attach,
2370
2371 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
2372 },
2373 },
2374
Yusuf Altinbb1b0822009-01-08 07:58:45 -03002375 .num_device_descs = 3,
Daniel Gimpelevich132c3182008-01-25 06:02:42 -03002376 .devices = {
2377 { "ASUS My Cinema U3000 Mini DVBT Tuner",
2378 { &dib0700_usb_id_table[23], NULL },
2379 { NULL },
2380 },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03002381 { "Yuan EC372S",
2382 { &dib0700_usb_id_table[31], NULL },
2383 { NULL },
Yusuf Altinbb1b0822009-01-08 07:58:45 -03002384 },
2385 { "Terratec Cinergy T Express",
2386 { &dib0700_usb_id_table[42], NULL },
2387 { NULL },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03002388 }
Chris Rankin48aa7392008-09-25 06:52:24 -03002389 },
2390
2391 .rc_interval = DEFAULT_RC_INTERVAL,
2392 .rc_key_map = dib0700_rc_keys,
2393 .rc_key_map_size = ARRAY_SIZE(dib0700_rc_keys),
2394 .rc_query = dib0700_rc_query
Daniel Gimpelevich132c3182008-01-25 06:02:42 -03002395 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
2396
2397 .num_adapters = 1,
2398 .adapter = {
2399 {
Olivier Grenief8731f42009-09-18 04:08:43 -03002400 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
2401 .pid_filter_count = 32,
2402 .pid_filter = stk70x0p_pid_filter,
2403 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
Patrick Boettcher01373a52007-07-30 12:49:04 -03002404 .frontend_attach = stk7070p_frontend_attach,
2405 .tuner_attach = dib7070p_tuner_attach,
2406
2407 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
2408
2409 .size_of_priv = sizeof(struct dib0700_adapter_state),
2410 },
2411 },
2412
Patrick Boettcher1e13c8f2009-09-19 05:24:40 -03002413 .num_device_descs = 11,
Patrick Boettcher01373a52007-07-30 12:49:04 -03002414 .devices = {
2415 { "DiBcom STK7070P reference design",
2416 { &dib0700_usb_id_table[15], NULL },
2417 { NULL },
2418 },
2419 { "Pinnacle PCTV DVB-T Flash Stick",
2420 { &dib0700_usb_id_table[16], NULL },
2421 { NULL },
2422 },
Yousef Lamlum7999a812008-01-25 05:51:48 -03002423 { "Artec T14BR DVB-T",
2424 { &dib0700_usb_id_table[22], NULL },
2425 { NULL },
Daniel Gimpelevich132c3182008-01-25 06:02:42 -03002426 },
2427 { "ASUS My Cinema U3100 Mini DVBT Tuner",
2428 { &dib0700_usb_id_table[24], NULL },
2429 { NULL },
2430 },
Tim Taubertc7637b12008-01-25 06:16:36 -03002431 { "Hauppauge Nova-T Stick",
2432 { &dib0700_usb_id_table[25], NULL },
2433 { NULL },
2434 },
Darren Salt13b83b52008-01-25 06:20:02 -03002435 { "Hauppauge Nova-T MyTV.t",
2436 { &dib0700_usb_id_table[26], NULL },
2437 { NULL },
2438 },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03002439 { "Pinnacle PCTV 72e",
2440 { &dib0700_usb_id_table[29], NULL },
2441 { NULL },
2442 },
2443 { "Pinnacle PCTV 73e",
2444 { &dib0700_usb_id_table[30], NULL },
2445 { NULL },
2446 },
Klaus Flittner919a5482009-03-29 09:12:06 -03002447 { "Elgato EyeTV DTT",
2448 { &dib0700_usb_id_table[49], NULL },
2449 { NULL },
2450 },
Pascal Terjan9abb6e62009-02-26 10:31:41 -03002451 { "Yuan PD378S",
2452 { &dib0700_usb_id_table[45], NULL },
2453 { NULL },
2454 },
Armin Schenker513846e2009-04-20 11:57:49 -03002455 { "Elgato EyeTV Dtt Dlx PD378S",
2456 { &dib0700_usb_id_table[50], NULL },
2457 { NULL },
2458 },
Tim Taubertc7637b12008-01-25 06:16:36 -03002459 },
2460
2461 .rc_interval = DEFAULT_RC_INTERVAL,
2462 .rc_key_map = dib0700_rc_keys,
2463 .rc_key_map_size = ARRAY_SIZE(dib0700_rc_keys),
2464 .rc_query = dib0700_rc_query
2465
Patrick Boettcher01373a52007-07-30 12:49:04 -03002466 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
2467
Olivier Grenie74b76f22009-09-02 08:19:19 -03002468 .num_adapters = 1,
2469 .adapter = {
2470 {
Mauro Carvalho Chehab648732f2009-11-04 12:11:43 -02002471 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
2472 .pid_filter_count = 32,
2473 .pid_filter = stk70x0p_pid_filter,
2474 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
Olivier Grenie74b76f22009-09-02 08:19:19 -03002475 .frontend_attach = stk7070p_frontend_attach,
2476 .tuner_attach = dib7070p_tuner_attach,
2477
2478 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
2479
2480 .size_of_priv = sizeof(struct dib0700_adapter_state),
2481 },
2482 },
2483
Patrick Boettcher20232c42009-12-01 12:08:56 -03002484 .num_device_descs = 3,
Olivier Grenie74b76f22009-09-02 08:19:19 -03002485 .devices = {
2486 { "Pinnacle PCTV 73A",
2487 { &dib0700_usb_id_table[56], NULL },
2488 { NULL },
2489 },
2490 { "Pinnacle PCTV 73e SE",
Patrick Boettcher20232c42009-12-01 12:08:56 -03002491 { &dib0700_usb_id_table[57], &dib0700_usb_id_table[65], NULL },
Olivier Grenie74b76f22009-09-02 08:19:19 -03002492 { NULL },
2493 },
2494 { "Pinnacle PCTV 282e",
Patrick Boettcher20232c42009-12-01 12:08:56 -03002495 { &dib0700_usb_id_table[58], &dib0700_usb_id_table[66], NULL },
Olivier Grenie74b76f22009-09-02 08:19:19 -03002496 { NULL },
2497 },
2498 },
2499
2500 .rc_interval = DEFAULT_RC_INTERVAL,
2501 .rc_key_map = dib0700_rc_keys,
2502 .rc_key_map_size = ARRAY_SIZE(dib0700_rc_keys),
2503 .rc_query = dib0700_rc_query
2504
2505 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
2506
Patrick Boettcher01373a52007-07-30 12:49:04 -03002507 .num_adapters = 2,
2508 .adapter = {
2509 {
Olivier Grenief8731f42009-09-18 04:08:43 -03002510 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
2511 .pid_filter_count = 32,
2512 .pid_filter = stk70x0p_pid_filter,
2513 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
Patrick Boettcher01373a52007-07-30 12:49:04 -03002514 .frontend_attach = stk7070pd_frontend_attach0,
2515 .tuner_attach = dib7070p_tuner_attach,
2516
2517 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
2518
2519 .size_of_priv = sizeof(struct dib0700_adapter_state),
2520 }, {
Olivier Grenief8731f42009-09-18 04:08:43 -03002521 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
2522 .pid_filter_count = 32,
2523 .pid_filter = stk70x0p_pid_filter,
2524 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
Patrick Boettcher01373a52007-07-30 12:49:04 -03002525 .frontend_attach = stk7070pd_frontend_attach1,
2526 .tuner_attach = dib7070p_tuner_attach,
2527
2528 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
2529
2530 .size_of_priv = sizeof(struct dib0700_adapter_state),
2531 }
2532 },
2533
sebastian.blanes@gmail.com0a6e1ed2009-02-24 14:51:43 -03002534 .num_device_descs = 6,
Patrick Boettcher01373a52007-07-30 12:49:04 -03002535 .devices = {
2536 { "DiBcom STK7070PD reference design",
2537 { &dib0700_usb_id_table[17], NULL },
2538 { NULL },
2539 },
2540 { "Pinnacle PCTV Dual DVB-T Diversity Stick",
2541 { &dib0700_usb_id_table[18], NULL },
2542 { NULL },
Michael Krufkyd01eb2d2008-07-03 23:43:36 -03002543 },
2544 { "Hauppauge Nova-TD Stick (52009)",
2545 { &dib0700_usb_id_table[35], NULL },
2546 { NULL },
Michael Krufky9a0c04a2008-09-03 17:12:24 -03002547 },
2548 { "Hauppauge Nova-TD-500 (84xxx)",
2549 { &dib0700_usb_id_table[36], NULL },
2550 { NULL },
Nicolas Fournierdb4b2d12009-01-13 07:15:25 -03002551 },
Patrick Boettchera9b8fe32009-05-20 05:35:02 -03002552 { "Terratec Cinergy DT USB XS Diversity/ T5",
2553 { &dib0700_usb_id_table[43],
2554 &dib0700_usb_id_table[53], NULL},
Nicolas Fournierdb4b2d12009-01-13 07:15:25 -03002555 { NULL },
sebastian.blanes@gmail.com0a6e1ed2009-02-24 14:51:43 -03002556 },
2557 { "Sony PlayTV",
2558 { &dib0700_usb_id_table[44], NULL },
2559 { NULL },
dominik67053a42007-11-10 19:23:31 -03002560 }
Arne Luehrsc985a8d2009-01-21 01:37:20 -03002561 },
2562 .rc_interval = DEFAULT_RC_INTERVAL,
2563 .rc_key_map = dib0700_rc_keys,
2564 .rc_key_map_size = ARRAY_SIZE(dib0700_rc_keys),
2565 .rc_query = dib0700_rc_query
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03002566 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
2567
2568 .num_adapters = 1,
2569 .adapter = {
2570 {
Olivier Grenief8731f42009-09-18 04:08:43 -03002571 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
2572 .pid_filter_count = 32,
2573 .pid_filter = stk70x0p_pid_filter,
2574 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03002575 .frontend_attach = stk7700ph_frontend_attach,
2576 .tuner_attach = stk7700ph_tuner_attach,
2577
2578 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
2579
2580 .size_of_priv = sizeof(struct
2581 dib0700_adapter_state),
2582 },
2583 },
2584
Pete Hildebrandtc53d83c2009-08-05 11:46:38 -03002585 .num_device_descs = 9,
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03002586 .devices = {
2587 { "Terratec Cinergy HT USB XE",
2588 { &dib0700_usb_id_table[27], NULL },
2589 { NULL },
2590 },
2591 { "Pinnacle Expresscard 320cx",
2592 { &dib0700_usb_id_table[28], NULL },
2593 { NULL },
2594 },
2595 { "Terratec Cinergy HT Express",
2596 { &dib0700_usb_id_table[32], NULL },
2597 { NULL },
2598 },
Finn Thain17a370b2008-09-06 13:42:47 -03002599 { "Gigabyte U8000-RH",
2600 { &dib0700_usb_id_table[37], NULL },
2601 { NULL },
2602 },
Daniel Oliveira Nascimento8751aaa2008-09-07 12:39:44 -03002603 { "YUAN High-Tech STK7700PH",
2604 { &dib0700_usb_id_table[38], NULL },
2605 { NULL },
2606 },
Albert Comerma57697432008-09-07 12:43:33 -03002607 { "Asus My Cinema-U3000Hybrid",
2608 { &dib0700_usb_id_table[39], NULL },
2609 { NULL },
2610 },
Xoan Loureiro16ba1ee2009-03-29 08:43:36 -03002611 { "YUAN High-Tech MC770",
2612 { &dib0700_usb_id_table[48], NULL },
2613 { NULL },
2614 },
tomas petrf0f4ae72009-05-20 05:28:05 -03002615 { "Leadtek WinFast DTV Dongle H",
2616 { &dib0700_usb_id_table[51], NULL },
2617 { NULL },
2618 },
Pete Hildebrandtc53d83c2009-08-05 11:46:38 -03002619 { "YUAN High-Tech STK7700D",
2620 { &dib0700_usb_id_table[54], NULL },
2621 { NULL },
2622 },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03002623 },
2624 .rc_interval = DEFAULT_RC_INTERVAL,
2625 .rc_key_map = dib0700_rc_keys,
2626 .rc_key_map_size = ARRAY_SIZE(dib0700_rc_keys),
2627 .rc_query = dib0700_rc_query
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03002628 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
2629 .num_adapters = 1,
2630 .adapter = {
2631 {
2632 .frontend_attach = s5h1411_frontend_attach,
2633 .tuner_attach = xc5000_tuner_attach,
2634
2635 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
2636
2637 .size_of_priv = sizeof(struct
2638 dib0700_adapter_state),
2639 },
2640 },
2641
Devin Heitmuellerd2fc3bf2008-09-25 06:22:23 -03002642 .num_device_descs = 2,
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03002643 .devices = {
2644 { "Pinnacle PCTV HD Pro USB Stick",
2645 { &dib0700_usb_id_table[40], NULL },
2646 { NULL },
2647 },
Devin Heitmuellerd2fc3bf2008-09-25 06:22:23 -03002648 { "Pinnacle PCTV HD USB Stick",
2649 { &dib0700_usb_id_table[41], NULL },
2650 { NULL },
2651 },
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03002652 },
2653 .rc_interval = DEFAULT_RC_INTERVAL,
2654 .rc_key_map = dib0700_rc_keys,
2655 .rc_key_map_size = ARRAY_SIZE(dib0700_rc_keys),
2656 .rc_query = dib0700_rc_query
Michael Krufkyce904bc2009-01-19 01:12:55 -03002657 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
2658 .num_adapters = 1,
2659 .adapter = {
2660 {
2661 .frontend_attach = lgdt3305_frontend_attach,
2662 .tuner_attach = mxl5007t_tuner_attach,
2663
2664 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
2665
2666 .size_of_priv = sizeof(struct
2667 dib0700_adapter_state),
2668 },
2669 },
2670
2671 .num_device_descs = 2,
2672 .devices = {
2673 { "Hauppauge ATSC MiniCard (B200)",
2674 { &dib0700_usb_id_table[46], NULL },
2675 { NULL },
2676 },
2677 { "Hauppauge ATSC MiniCard (B210)",
2678 { &dib0700_usb_id_table[47], NULL },
2679 { NULL },
2680 },
2681 },
Olivier Grenied300bd62009-09-15 06:55:35 -03002682 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
2683
2684 .num_adapters = 1,
2685 .adapter = {
2686 {
Olivier Grenief8731f42009-09-18 04:08:43 -03002687 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
2688 .pid_filter_count = 32,
2689 .pid_filter = stk70x0p_pid_filter,
2690 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
Olivier Grenied300bd62009-09-15 06:55:35 -03002691 .frontend_attach = stk7070p_frontend_attach,
2692 .tuner_attach = dib7770p_tuner_attach,
2693
2694 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
2695
2696 .size_of_priv =
Patrick Boettcherdb481382009-09-15 07:16:51 -03002697 sizeof(struct dib0700_adapter_state),
Olivier Grenied300bd62009-09-15 06:55:35 -03002698 },
2699 },
2700
Patrick Boettcherdb481382009-09-15 07:16:51 -03002701 .num_device_descs = 2,
Olivier Grenied300bd62009-09-15 06:55:35 -03002702 .devices = {
2703 { "DiBcom STK7770P reference design",
2704 { &dib0700_usb_id_table[59], NULL },
2705 { NULL },
2706 },
Patrick Boettcher1e13c8f2009-09-19 05:24:40 -03002707 { "Terratec Cinergy T USB XXS (HD)/ T3",
2708 { &dib0700_usb_id_table[33],
2709 &dib0700_usb_id_table[52],
2710 &dib0700_usb_id_table[60], NULL},
Patrick Boettcherdb481382009-09-15 07:16:51 -03002711 { NULL },
2712 },
Olivier Grenied300bd62009-09-15 06:55:35 -03002713 },
Olivier Grenied300bd62009-09-15 06:55:35 -03002714 .rc_interval = DEFAULT_RC_INTERVAL,
2715 .rc_key_map = dib0700_rc_keys,
2716 .rc_key_map_size = ARRAY_SIZE(dib0700_rc_keys),
2717 .rc_query = dib0700_rc_query
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03002718 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
2719 .num_adapters = 1,
2720 .adapter = {
2721 {
Olivier Grenief8731f42009-09-18 04:08:43 -03002722 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
2723 .pid_filter_count = 32,
Olivier Grenie03245a52009-12-04 13:27:57 -03002724 .pid_filter = stk80xx_pid_filter,
2725 .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03002726 .frontend_attach = stk807x_frontend_attach,
2727 .tuner_attach = dib807x_tuner_attach,
2728
2729 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
2730
2731 .size_of_priv =
2732 sizeof(struct dib0700_adapter_state),
2733 },
2734 },
2735
S?rgio Fortier8a378e82009-09-28 04:19:21 -03002736 .num_device_descs = 3,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03002737 .devices = {
2738 { "DiBcom STK807xP reference design",
2739 { &dib0700_usb_id_table[62], NULL },
2740 { NULL },
2741 },
Mauro Carvalho Chehabaaeab302009-09-16 09:18:26 -03002742 { "Prolink Pixelview SBTVD",
2743 { &dib0700_usb_id_table[63], NULL },
2744 { NULL },
2745 },
S?rgio Fortier8a378e82009-09-28 04:19:21 -03002746 { "EvolutePC TVWay+",
2747 { &dib0700_usb_id_table[64], NULL },
2748 { NULL },
2749 },
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03002750 },
2751
2752 .rc_interval = DEFAULT_RC_INTERVAL,
2753 .rc_key_map = dib0700_rc_keys,
2754 .rc_key_map_size = ARRAY_SIZE(dib0700_rc_keys),
2755 .rc_query = dib0700_rc_query
2756
2757 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
2758 .num_adapters = 2,
2759 .adapter = {
2760 {
Olivier Grenief8731f42009-09-18 04:08:43 -03002761 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
2762 .pid_filter_count = 32,
Olivier Grenie03245a52009-12-04 13:27:57 -03002763 .pid_filter = stk80xx_pid_filter,
2764 .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03002765 .frontend_attach = stk807xpvr_frontend_attach0,
2766 .tuner_attach = dib807x_tuner_attach,
2767
2768 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
2769
2770 .size_of_priv =
2771 sizeof(struct dib0700_adapter_state),
2772 },
2773 {
Olivier Grenief8731f42009-09-18 04:08:43 -03002774 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
2775 .pid_filter_count = 32,
Olivier Grenie03245a52009-12-04 13:27:57 -03002776 .pid_filter = stk80xx_pid_filter,
2777 .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03002778 .frontend_attach = stk807xpvr_frontend_attach1,
2779 .tuner_attach = dib807x_tuner_attach,
2780
2781 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
2782
2783 .size_of_priv =
2784 sizeof(struct dib0700_adapter_state),
2785 },
2786 },
2787
2788 .num_device_descs = 1,
2789 .devices = {
2790 { "DiBcom STK807xPVR reference design",
2791 { &dib0700_usb_id_table[61], NULL },
2792 { NULL },
2793 },
2794 },
2795
2796 .rc_interval = DEFAULT_RC_INTERVAL,
2797 .rc_key_map = dib0700_rc_keys,
2798 .rc_key_map_size = ARRAY_SIZE(dib0700_rc_keys),
2799 .rc_query = dib0700_rc_query
Olivier Grenie03245a52009-12-04 13:27:57 -03002800 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
2801 .num_adapters = 1,
2802 .adapter = {
2803 {
2804 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
2805 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
2806 .pid_filter_count = 32,
2807 .pid_filter = stk80xx_pid_filter,
2808 .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
2809 .frontend_attach = stk809x_frontend_attach,
2810 .tuner_attach = dib809x_tuner_attach,
2811
2812 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
2813
2814 .size_of_priv =
2815 sizeof(struct dib0700_adapter_state),
2816 },
2817 },
2818
2819 .num_device_descs = 1,
2820 .devices = {
2821 { "DiBcom STK8096GP reference design",
2822 { &dib0700_usb_id_table[67], NULL },
2823 { NULL },
2824 },
2825 },
2826
2827 .rc_interval = DEFAULT_RC_INTERVAL,
2828 .rc_key_map = dib0700_rc_keys,
2829 .rc_key_map_size = ARRAY_SIZE(dib0700_rc_keys),
2830 .rc_query = dib0700_rc_query
Patrick Boettcher01373a52007-07-30 12:49:04 -03002831 },
Patrick Boettcherb7f54912006-09-19 12:51:37 -03002832};
2833
2834int dib0700_device_count = ARRAY_SIZE(dib0700_devices);