blob: e5c2bd2b2be859ec4852957eaaebeb84f3eb0732 [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"
Olivier Greniebe9bae12011-01-04 05:42:19 -030015#include "dib9000.h"
Patrick Boettcherb7f54912006-09-19 12:51:37 -030016#include "mt2060.h"
Olivier DANET54d75eb2007-07-25 14:42:54 -030017#include "mt2266.h"
Albert Comerma6ca8f0b2008-03-29 21:35:57 -030018#include "tuner-xc2028.h"
Devin Heitmuellercb22cb52008-09-08 05:42:42 -030019#include "xc5000.h"
Davide Ferri8d009a02009-06-23 22:34:06 -030020#include "xc4000.h"
Devin Heitmuellercb22cb52008-09-08 05:42:42 -030021#include "s5h1411.h"
Patrick Boettcher01373a52007-07-30 12:49:04 -030022#include "dib0070.h"
Olivier Grenie03245a52009-12-04 13:27:57 -030023#include "dib0090.h"
Michael Krufkyce904bc2009-01-19 01:12:55 -030024#include "lgdt3305.h"
25#include "mxl5007t.h"
Patrick Boettcherb7f54912006-09-19 12:51:37 -030026
Patrick Boettcher7fb3fc02006-09-20 04:37:18 -030027static int force_lna_activation;
28module_param(force_lna_activation, int, 0644);
29MODULE_PARM_DESC(force_lna_activation, "force the activation of Low-Noise-Amplifyer(s) (LNA), "
30 "if applicable for the device (default: 0=automatic/off).");
31
Patrick Boettcher01373a52007-07-30 12:49:04 -030032struct dib0700_adapter_state {
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -030033 int (*set_param_save) (struct dvb_frontend *);
Olivier Greniebe9bae12011-01-04 05:42:19 -030034 const struct firmware *frontend_firmware;
Patrick Boettcher01373a52007-07-30 12:49:04 -030035};
36
37/* Hauppauge Nova-T 500 (aka Bristol)
Patrick Boettcherb7f54912006-09-19 12:51:37 -030038 * has a LNA on GPIO0 which is enabled by setting 1 */
39static struct mt2060_config bristol_mt2060_config[2] = {
40 {
41 .i2c_address = 0x60,
Patrick Boettcher303cbea2006-09-19 12:51:56 -030042 .clock_out = 3,
Patrick Boettcherb7f54912006-09-19 12:51:37 -030043 }, {
44 .i2c_address = 0x61,
45 }
46};
47
Devin Heitmueller99afb982008-11-15 07:13:07 -030048
Patrick Boettcherb7f54912006-09-19 12:51:37 -030049static struct dibx000_agc_config bristol_dib3000p_mt2060_agc_config = {
50 .band_caps = BAND_VHF | BAND_UHF,
Patrick Boettcher01b4bf32006-09-19 12:51:53 -030051 .setup = (1 << 8) | (5 << 5) | (0 << 4) | (0 << 3) | (0 << 2) | (2 << 0),
Patrick Boettcherb7f54912006-09-19 12:51:37 -030052
Patrick Boettcher6958eff2006-09-19 12:51:40 -030053 .agc1_max = 42598,
54 .agc1_min = 17694,
55 .agc2_max = 45875,
56 .agc2_min = 0,
Patrick Boettcherb7f54912006-09-19 12:51:37 -030057
Patrick Boettcher6958eff2006-09-19 12:51:40 -030058 .agc1_pt1 = 0,
59 .agc1_pt2 = 59,
Patrick Boettcherb7f54912006-09-19 12:51:37 -030060
Patrick Boettcher6958eff2006-09-19 12:51:40 -030061 .agc1_slope1 = 0,
62 .agc1_slope2 = 69,
Patrick Boettcherb7f54912006-09-19 12:51:37 -030063
64 .agc2_pt1 = 0,
Patrick Boettcher6958eff2006-09-19 12:51:40 -030065 .agc2_pt2 = 59,
Patrick Boettcherb7f54912006-09-19 12:51:37 -030066
Patrick Boettcher6958eff2006-09-19 12:51:40 -030067 .agc2_slope1 = 111,
68 .agc2_slope2 = 28,
Patrick Boettcherb7f54912006-09-19 12:51:37 -030069};
70
71static struct dib3000mc_config bristol_dib3000mc_config[2] = {
72 { .agc = &bristol_dib3000p_mt2060_agc_config,
73 .max_time = 0x196,
74 .ln_adc_level = 0x1cc7,
75 .output_mpeg2_in_188_bytes = 1,
76 },
77 { .agc = &bristol_dib3000p_mt2060_agc_config,
78 .max_time = 0x196,
79 .ln_adc_level = 0x1cc7,
80 .output_mpeg2_in_188_bytes = 1,
81 }
82};
83
84static int bristol_frontend_attach(struct dvb_usb_adapter *adap)
85{
Patrick Boettcher6958eff2006-09-19 12:51:40 -030086 struct dib0700_state *st = adap->dev->priv;
Patrick Boettcherb7f54912006-09-19 12:51:37 -030087 if (adap->id == 0) {
88 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0); msleep(10);
89 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1); msleep(10);
90 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0); msleep(10);
91 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1); msleep(10);
92
Patrick Boettcher7fb3fc02006-09-20 04:37:18 -030093 if (force_lna_activation)
94 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
95 else
96 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 0);
Patrick Boettcher6958eff2006-09-19 12:51:40 -030097
Patrick Boettcherb7f54912006-09-19 12:51:37 -030098 if (dib3000mc_i2c_enumeration(&adap->dev->i2c_adap, 2, DEFAULT_DIB3000P_I2C_ADDRESS, bristol_dib3000mc_config) != 0) {
99 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0); msleep(10);
100 return -ENODEV;
101 }
102 }
Patrick Boettcher6958eff2006-09-19 12:51:40 -0300103 st->mt2060_if1[adap->id] = 1220;
Michael Krufky77eed212011-09-06 09:31:57 -0300104 return (adap->fe_adap[0].fe = dvb_attach(dib3000mc_attach, &adap->dev->i2c_adap,
Patrick Boettcher6958eff2006-09-19 12:51:40 -0300105 (10 + adap->id) << 1, &bristol_dib3000mc_config[adap->id])) == NULL ? -ENODEV : 0;
Patrick Boettcherb7f54912006-09-19 12:51:37 -0300106}
107
Patrick Boettcher4a2b1082008-01-25 07:32:58 -0300108static int eeprom_read(struct i2c_adapter *adap,u8 adrs,u8 *pval)
Olivier DANETc52344f2008-01-25 06:50:07 -0300109{
110 struct i2c_msg msg[2] = {
111 { .addr = 0x50, .flags = 0, .buf = &adrs, .len = 1 },
112 { .addr = 0x50, .flags = I2C_M_RD, .buf = pval, .len = 1 },
113 };
114 if (i2c_transfer(adap, msg, 2) != 2) return -EREMOTEIO;
115 return 0;
116}
117
Patrick Boettcherb7f54912006-09-19 12:51:37 -0300118static int bristol_tuner_attach(struct dvb_usb_adapter *adap)
119{
Olivier DANETc52344f2008-01-25 06:50:07 -0300120 struct i2c_adapter *prim_i2c = &adap->dev->i2c_adap;
Michael Krufky77eed212011-09-06 09:31:57 -0300121 struct i2c_adapter *tun_i2c = dib3000mc_get_tuner_i2c_master(adap->fe_adap[0].fe, 1);
Olivier DANETc52344f2008-01-25 06:50:07 -0300122 s8 a;
123 int if1=1220;
Al Viroda5ee482008-05-21 00:31:21 -0300124 if (adap->dev->udev->descriptor.idVendor == cpu_to_le16(USB_VID_HAUPPAUGE) &&
125 adap->dev->udev->descriptor.idProduct == cpu_to_le16(USB_PID_HAUPPAUGE_NOVA_T_500_2)) {
Olivier DANETc52344f2008-01-25 06:50:07 -0300126 if (!eeprom_read(prim_i2c,0x59 + adap->id,&a)) if1=1220+a;
127 }
Michael Krufky9a9677a2011-09-13 01:32:11 -0300128 return dvb_attach(mt2060_attach, adap->fe_adap[0].fe, tun_i2c,
129 &bristol_mt2060_config[adap->id], if1) == NULL ?
130 -ENODEV : 0;
Patrick Boettcherb7f54912006-09-19 12:51:37 -0300131}
132
Patrick Boettcher01373a52007-07-30 12:49:04 -0300133/* STK7700D: Pinnacle/Terratec/Hauppauge Dual DVB-T Diversity */
Olivier DANET54d75eb2007-07-25 14:42:54 -0300134
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300135/* MT226x */
136static struct dibx000_agc_config stk7700d_7000p_mt2266_agc_config[2] = {
137 {
Olivier Grenie9c783032009-12-07 07:49:40 -0300138 BAND_UHF,
Olivier DANET54d75eb2007-07-25 14:42:54 -0300139
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300140 /* 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,
141 * 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 -0300142 (0 << 15) | (0 << 14) | (1 << 11) | (1 << 10) | (1 << 9) | (0 << 8)
143 | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),
Olivier DANET54d75eb2007-07-25 14:42:54 -0300144
Olivier Grenie9c783032009-12-07 07:49:40 -0300145 1130,
146 21,
Olivier DANET54d75eb2007-07-25 14:42:54 -0300147
Olivier Grenie9c783032009-12-07 07:49:40 -0300148 0,
149 118,
Olivier DANET54d75eb2007-07-25 14:42:54 -0300150
Olivier Grenie9c783032009-12-07 07:49:40 -0300151 0,
152 3530,
153 1,
154 0,
Olivier DANET54d75eb2007-07-25 14:42:54 -0300155
Olivier Grenie9c783032009-12-07 07:49:40 -0300156 65535,
157 33770,
158 65535,
159 23592,
Olivier DANET54d75eb2007-07-25 14:42:54 -0300160
Olivier Grenie9c783032009-12-07 07:49:40 -0300161 0,
162 62,
163 255,
164 64,
165 64,
166 132,
167 192,
168 80,
169 80,
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300170
Olivier Grenie9c783032009-12-07 07:49:40 -0300171 17,
172 27,
173 23,
174 51,
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300175
Olivier Grenie9c783032009-12-07 07:49:40 -0300176 1,
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300177 }, {
Olivier Grenie9c783032009-12-07 07:49:40 -0300178 BAND_VHF | BAND_LBAND,
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300179
180 /* 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,
181 * 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 -0300182 (0 << 15) | (0 << 14) | (1 << 11) | (1 << 10) | (1 << 9) | (0 << 8)
183 | (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0),
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300184
Olivier Grenie9c783032009-12-07 07:49:40 -0300185 2372,
186 21,
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300187
Olivier Grenie9c783032009-12-07 07:49:40 -0300188 0,
189 118,
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300190
Olivier Grenie9c783032009-12-07 07:49:40 -0300191 0,
192 3530,
193 1,
194 0,
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300195
Olivier Grenie9c783032009-12-07 07:49:40 -0300196 65535,
197 0,
198 65535,
199 23592,
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300200
Olivier Grenie9c783032009-12-07 07:49:40 -0300201 0,
202 128,
203 128,
204 128,
205 0,
206 128,
207 253,
208 81,
209 0,
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300210
Olivier Grenie9c783032009-12-07 07:49:40 -0300211 17,
212 27,
213 23,
214 51,
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300215
Olivier Grenie9c783032009-12-07 07:49:40 -0300216 1,
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300217 }
Olivier DANET54d75eb2007-07-25 14:42:54 -0300218};
219
220static struct dibx000_bandwidth_config stk7700d_mt2266_pll_config = {
Olivier Grenie9c783032009-12-07 07:49:40 -0300221 60000, 30000,
222 1, 8, 3, 1, 0,
223 0, 0, 1, 1, 2,
224 (3 << 14) | (1 << 12) | (524 << 0),
225 0,
226 20452225,
Olivier DANET54d75eb2007-07-25 14:42:54 -0300227};
228
229static struct dib7000p_config stk7700d_dib7000p_mt2266_config[] = {
230 { .output_mpeg2_in_188_bytes = 1,
231 .hostbus_diversity = 1,
232 .tuner_is_baseband = 1,
233
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300234 .agc_config_count = 2,
235 .agc = stk7700d_7000p_mt2266_agc_config,
Olivier DANET54d75eb2007-07-25 14:42:54 -0300236 .bw = &stk7700d_mt2266_pll_config,
237
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300238 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
239 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
240 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
Olivier DANET54d75eb2007-07-25 14:42:54 -0300241 },
242 { .output_mpeg2_in_188_bytes = 1,
243 .hostbus_diversity = 1,
244 .tuner_is_baseband = 1,
245
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300246 .agc_config_count = 2,
247 .agc = stk7700d_7000p_mt2266_agc_config,
Olivier DANET54d75eb2007-07-25 14:42:54 -0300248 .bw = &stk7700d_mt2266_pll_config,
249
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300250 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
251 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
252 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
Olivier DANET54d75eb2007-07-25 14:42:54 -0300253 }
254};
255
256static struct mt2266_config stk7700d_mt2266_config[2] = {
257 { .i2c_address = 0x60
258 },
259 { .i2c_address = 0x60
260 }
261};
262
Daniel Gimpelevich132c3182008-01-25 06:02:42 -0300263static int stk7700P2_frontend_attach(struct dvb_usb_adapter *adap)
264{
265 if (adap->id == 0) {
266 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
267 msleep(10);
268 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
269 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
270 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
271 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
272 msleep(10);
273 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
274 msleep(10);
Devin Heitmueller83c4fdf2009-01-21 01:55:45 -0300275 if (dib7000p_i2c_enumeration(&adap->dev->i2c_adap, 1, 18,
276 stk7700d_dib7000p_mt2266_config)
277 != 0) {
278 err("%s: dib7000p_i2c_enumeration failed. Cannot continue\n", __func__);
279 return -ENODEV;
280 }
Daniel Gimpelevich132c3182008-01-25 06:02:42 -0300281 }
282
Michael Krufky2a776312011-09-16 09:26:59 -0300283 adap->fe_adap[0].fe =
284 dvb_attach(dib7000p_attach, &adap->dev->i2c_adap,
285 0x80 + (adap->id << 1),
286 &stk7700d_dib7000p_mt2266_config[adap->id]);
Daniel Gimpelevich132c3182008-01-25 06:02:42 -0300287
Michael Krufky77eed212011-09-06 09:31:57 -0300288 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Daniel Gimpelevich132c3182008-01-25 06:02:42 -0300289}
290
Olivier DANET54d75eb2007-07-25 14:42:54 -0300291static int stk7700d_frontend_attach(struct dvb_usb_adapter *adap)
292{
293 if (adap->id == 0) {
294 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
295 msleep(10);
296 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
297 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
298 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
299 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
300 msleep(10);
301 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
302 msleep(10);
303 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
Devin Heitmueller83c4fdf2009-01-21 01:55:45 -0300304 if (dib7000p_i2c_enumeration(&adap->dev->i2c_adap, 2, 18,
305 stk7700d_dib7000p_mt2266_config)
306 != 0) {
307 err("%s: dib7000p_i2c_enumeration failed. Cannot continue\n", __func__);
308 return -ENODEV;
309 }
Olivier DANET54d75eb2007-07-25 14:42:54 -0300310 }
311
Michael Krufky2a776312011-09-16 09:26:59 -0300312 adap->fe_adap[0].fe =
313 dvb_attach(dib7000p_attach, &adap->dev->i2c_adap,
314 0x80 + (adap->id << 1),
315 &stk7700d_dib7000p_mt2266_config[adap->id]);
Olivier DANET54d75eb2007-07-25 14:42:54 -0300316
Michael Krufky77eed212011-09-06 09:31:57 -0300317 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Olivier DANET54d75eb2007-07-25 14:42:54 -0300318}
319
320static int stk7700d_tuner_attach(struct dvb_usb_adapter *adap)
321{
322 struct i2c_adapter *tun_i2c;
Michael Krufky77eed212011-09-06 09:31:57 -0300323 tun_i2c = dib7000p_get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_TUNER, 1);
324 return dvb_attach(mt2266_attach, adap->fe_adap[0].fe, tun_i2c,
Joe Perches1ebcad72009-07-02 15:57:09 -0300325 &stk7700d_mt2266_config[adap->id]) == NULL ? -ENODEV : 0;
Olivier DANET54d75eb2007-07-25 14:42:54 -0300326}
327
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300328/* STK7700-PH: Digital/Analog Hybrid Tuner, e.h. Cinergy HT USB HE */
Harvey Harrisonb1721d02008-04-25 19:03:08 -0700329static struct dibx000_agc_config xc3028_agc_config = {
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300330 BAND_VHF | BAND_UHF, /* band_caps */
331
332 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=0,
333 * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
334 * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=2, P_agc_write=0 */
335 (0 << 15) | (0 << 14) | (0 << 11) | (0 << 10) | (0 << 9) | (0 << 8) |
336 (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0), /* setup */
337
338 712, /* inv_gain */
339 21, /* time_stabiliz */
340
341 0, /* alpha_level */
342 118, /* thlock */
343
344 0, /* wbd_inv */
345 2867, /* wbd_ref */
346 0, /* wbd_sel */
347 2, /* wbd_alpha */
348
349 0, /* agc1_max */
350 0, /* agc1_min */
351 39718, /* agc2_max */
352 9930, /* agc2_min */
353 0, /* agc1_pt1 */
354 0, /* agc1_pt2 */
355 0, /* agc1_pt3 */
356 0, /* agc1_slope1 */
357 0, /* agc1_slope2 */
358 0, /* agc2_pt1 */
359 128, /* agc2_pt2 */
360 29, /* agc2_slope1 */
361 29, /* agc2_slope2 */
362
363 17, /* alpha_mant */
364 27, /* alpha_exp */
365 23, /* beta_mant */
366 51, /* beta_exp */
367
368 1, /* perform_agc_softsplit */
369};
370
371/* PLL Configuration for COFDM BW_MHz = 8.00 with external clock = 30.00 */
Harvey Harrisonb1721d02008-04-25 19:03:08 -0700372static struct dibx000_bandwidth_config xc3028_bw_config = {
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300373 60000, 30000, /* internal, sampling */
374 1, 8, 3, 1, 0, /* pll_cfg: prediv, ratio, range, reset, bypass */
375 0, 0, 1, 1, 0, /* misc: refdiv, bypclk_div, IO_CLK_en_core, ADClkSrc,
376 modulo */
377 (3 << 14) | (1 << 12) | (524 << 0), /* sad_cfg: refsel, sel, freq_15k */
378 (1 << 25) | 5816102, /* ifreq = 5.200000 MHz */
379 20452225, /* timf */
380 30000000, /* xtal_hz */
381};
382
383static struct dib7000p_config stk7700ph_dib7700_xc3028_config = {
384 .output_mpeg2_in_188_bytes = 1,
385 .tuner_is_baseband = 1,
386
387 .agc_config_count = 1,
388 .agc = &xc3028_agc_config,
389 .bw = &xc3028_bw_config,
390
391 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
392 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
393 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
394};
395
Michael Krufkyd7cba042008-09-12 13:31:45 -0300396static int stk7700ph_xc3028_callback(void *ptr, int component,
397 int command, int arg)
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300398{
399 struct dvb_usb_adapter *adap = ptr;
400
401 switch (command) {
402 case XC2028_TUNER_RESET:
403 /* Send the tuner in then out of reset */
Michael Krufky77eed212011-09-06 09:31:57 -0300404 dib7000p_set_gpio(adap->fe_adap[0].fe, 8, 0, 0); msleep(10);
405 dib7000p_set_gpio(adap->fe_adap[0].fe, 8, 0, 1);
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300406 break;
407 case XC2028_RESET_CLK:
408 break;
409 default:
410 err("%s: unknown command %d, arg %d\n", __func__,
411 command, arg);
412 return -EINVAL;
413 }
414 return 0;
415}
416
417static struct xc2028_ctrl stk7700ph_xc3028_ctrl = {
418 .fname = XC2028_DEFAULT_FIRMWARE,
419 .max_len = 64,
420 .demod = XC3028_FE_DIBCOM52,
421};
422
423static struct xc2028_config stk7700ph_xc3028_config = {
424 .i2c_addr = 0x61,
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300425 .ctrl = &stk7700ph_xc3028_ctrl,
426};
427
428static int stk7700ph_frontend_attach(struct dvb_usb_adapter *adap)
429{
430 struct usb_device_descriptor *desc = &adap->dev->udev->descriptor;
431
Al Viroda5ee482008-05-21 00:31:21 -0300432 if (desc->idVendor == cpu_to_le16(USB_VID_PINNACLE) &&
433 desc->idProduct == cpu_to_le16(USB_PID_PINNACLE_EXPRESSCARD_320CX))
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300434 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
435 else
436 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
437 msleep(20);
438 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
439 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
440 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
441 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
442 msleep(10);
443 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
444 msleep(20);
445 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
446 msleep(10);
447
Devin Heitmueller83c4fdf2009-01-21 01:55:45 -0300448 if (dib7000p_i2c_enumeration(&adap->dev->i2c_adap, 1, 18,
449 &stk7700ph_dib7700_xc3028_config) != 0) {
450 err("%s: dib7000p_i2c_enumeration failed. Cannot continue\n",
451 __func__);
452 return -ENODEV;
453 }
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300454
Michael Krufky77eed212011-09-06 09:31:57 -0300455 adap->fe_adap[0].fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 0x80,
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300456 &stk7700ph_dib7700_xc3028_config);
457
Michael Krufky77eed212011-09-06 09:31:57 -0300458 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300459}
460
461static int stk7700ph_tuner_attach(struct dvb_usb_adapter *adap)
462{
463 struct i2c_adapter *tun_i2c;
464
Michael Krufky77eed212011-09-06 09:31:57 -0300465 tun_i2c = dib7000p_get_i2c_master(adap->fe_adap[0].fe,
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300466 DIBX000_I2C_INTERFACE_TUNER, 1);
467
468 stk7700ph_xc3028_config.i2c_adap = tun_i2c;
Michael Krufkyd7cba042008-09-12 13:31:45 -0300469
470 /* FIXME: generalize & move to common area */
Michael Krufky77eed212011-09-06 09:31:57 -0300471 adap->fe_adap[0].fe->callback = stk7700ph_xc3028_callback;
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300472
Michael Krufky77eed212011-09-06 09:31:57 -0300473 return dvb_attach(xc2028_attach, adap->fe_adap[0].fe, &stk7700ph_xc3028_config)
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300474 == NULL ? -ENODEV : 0;
475}
476
Devin Heitmueller4b330be2008-12-01 06:51:14 -0300477#define DEFAULT_RC_INTERVAL 50
Olivier DANET54d75eb2007-07-25 14:42:54 -0300478
479static u8 rc_request[] = { REQUEST_POLL_RC, 0 };
480
Patrick Boettcher58e6f952008-03-29 21:37:01 -0300481/* Number of keypresses to ignore before start repeating */
Devin Heitmueller4b330be2008-12-01 06:51:14 -0300482#define RC_REPEAT_DELAY 6
Patrick Boettcher58e6f952008-03-29 21:37:01 -0300483
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -0300484/*
485 * This function is used only when firmware is < 1.20 version. Newer
486 * firmwares use bulk mode, with functions implemented at dib0700_core,
487 * at dib0700_rc_urb_completion()
488 */
489static int dib0700_rc_query_old_firmware(struct dvb_usb_device *d)
Olivier DANET54d75eb2007-07-25 14:42:54 -0300490{
491 u8 key[4];
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -0300492 u32 keycode;
493 u8 toggle;
Olivier DANET54d75eb2007-07-25 14:42:54 -0300494 int i;
Olivier DANET54d75eb2007-07-25 14:42:54 -0300495 struct dib0700_state *st = d->priv;
Devin Heitmueller6a207102010-01-04 02:43:19 -0300496
Devin Heitmueller6a207102010-01-04 02:43:19 -0300497 if (st->fw_version >= 0x10200) {
498 /* For 1.20 firmware , We need to keep the RC polling
499 callback so we can reuse the input device setup in
500 dvb-usb-remote.c. However, the actual work is being done
501 in the bulk URB completion handler. */
502 return 0;
503 }
504
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -0300505 i = dib0700_ctrl_rd(d, rc_request, 2, key, 4);
506 if (i <= 0) {
Janne Grunau034d65e2007-07-31 08:48:40 -0300507 err("RC Query Failed");
Janne Grunau89f42672007-07-31 19:45:13 -0300508 return -1;
Olivier DANET54d75eb2007-07-25 14:42:54 -0300509 }
Patrick Boettcher58e6f952008-03-29 21:37:01 -0300510
511 /* losing half of KEY_0 events from Philipps rc5 remotes.. */
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -0300512 if (key[0] == 0 && key[1] == 0 && key[2] == 0 && key[3] == 0)
513 return 0;
Patrick Boettcher58e6f952008-03-29 21:37:01 -0300514
515 /* 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]); */
516
517 dib0700_rc_setup(d); /* reset ir sensor data to prevent false events */
518
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -0300519 d->last_event = 0;
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -0300520 switch (d->props.rc.core.protocol) {
Mauro Carvalho Chehab52b66142010-11-17 14:20:52 -0300521 case RC_TYPE_NEC:
Patrick Boettcher58e6f952008-03-29 21:37:01 -0300522 /* NEC protocol sends repeat code as 0 0 0 FF */
523 if ((key[3-2] == 0x00) && (key[3-3] == 0x00) &&
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -0300524 (key[3] == 0xff))
525 keycode = d->last_event;
526 else {
527 keycode = key[3-2] << 8 | key[3-3];
528 d->last_event = keycode;
Patrick Boettcher58e6f952008-03-29 21:37:01 -0300529 }
Patrick Boettcher58e6f952008-03-29 21:37:01 -0300530
Mauro Carvalho Chehabca866742010-11-17 13:53:11 -0300531 rc_keydown(d->rc_dev, keycode, 0);
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -0300532 break;
533 default:
534 /* RC-5 protocol changes toggle bit on new keypress */
535 keycode = key[3-2] << 8 | key[3-3];
536 toggle = key[3-1];
Mauro Carvalho Chehabca866742010-11-17 13:53:11 -0300537 rc_keydown(d->rc_dev, keycode, toggle);
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -0300538
Patrick Boettcher58e6f952008-03-29 21:37:01 -0300539 break;
540 }
Olivier DANET54d75eb2007-07-25 14:42:54 -0300541 return 0;
542}
543
Patrick Boettcherb7f54912006-09-19 12:51:37 -0300544/* STK7700P: Hauppauge Nova-T Stick, AVerMedia Volar */
Patrick Boettchera75763f2006-10-18 08:34:16 -0300545static struct dibx000_agc_config stk7700p_7000m_mt2060_agc_config = {
Olivier Grenie9c783032009-12-07 07:49:40 -0300546 BAND_UHF | BAND_VHF,
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300547
548 /* 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,
549 * 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 -0300550 (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8)
551 | (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0),
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300552
Olivier Grenie9c783032009-12-07 07:49:40 -0300553 712,
554 41,
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300555
Olivier Grenie9c783032009-12-07 07:49:40 -0300556 0,
557 118,
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300558
Olivier Grenie9c783032009-12-07 07:49:40 -0300559 0,
560 4095,
561 0,
562 0,
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300563
Olivier Grenie9c783032009-12-07 07:49:40 -0300564 42598,
565 17694,
566 45875,
567 2621,
568 0,
569 76,
570 139,
571 52,
572 59,
573 107,
574 172,
575 57,
576 70,
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300577
Olivier Grenie9c783032009-12-07 07:49:40 -0300578 21,
579 25,
580 28,
581 48,
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300582
Olivier Grenie9c783032009-12-07 07:49:40 -0300583 1,
584 { 0,
585 107,
586 51800,
587 24700
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300588 },
Patrick Boettcherb7f54912006-09-19 12:51:37 -0300589};
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300590
Patrick Boettchera75763f2006-10-18 08:34:16 -0300591static struct dibx000_agc_config stk7700p_7000p_mt2060_agc_config = {
592 BAND_UHF | BAND_VHF,
593
594 /* 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,
595 * 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 -0300596 (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8)
597 | (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0),
Patrick Boettchera75763f2006-10-18 08:34:16 -0300598
Olivier Grenie9c783032009-12-07 07:49:40 -0300599 712,
600 41,
Patrick Boettchera75763f2006-10-18 08:34:16 -0300601
Olivier Grenie9c783032009-12-07 07:49:40 -0300602 0,
603 118,
Patrick Boettchera75763f2006-10-18 08:34:16 -0300604
Olivier Grenie9c783032009-12-07 07:49:40 -0300605 0,
606 4095,
607 0,
608 0,
Patrick Boettchera75763f2006-10-18 08:34:16 -0300609
Olivier Grenie9c783032009-12-07 07:49:40 -0300610 42598,
611 16384,
612 42598,
613 0,
Patrick Boettchera75763f2006-10-18 08:34:16 -0300614
Olivier Grenie9c783032009-12-07 07:49:40 -0300615 0,
616 137,
617 255,
Patrick Boettchera75763f2006-10-18 08:34:16 -0300618
Olivier Grenie9c783032009-12-07 07:49:40 -0300619 0,
620 255,
Patrick Boettchera75763f2006-10-18 08:34:16 -0300621
Olivier Grenie9c783032009-12-07 07:49:40 -0300622 0,
623 0,
Patrick Boettchera75763f2006-10-18 08:34:16 -0300624
Olivier Grenie9c783032009-12-07 07:49:40 -0300625 0,
626 41,
Patrick Boettchera75763f2006-10-18 08:34:16 -0300627
Olivier Grenie9c783032009-12-07 07:49:40 -0300628 15,
629 25,
Patrick Boettchera75763f2006-10-18 08:34:16 -0300630
Olivier Grenie9c783032009-12-07 07:49:40 -0300631 28,
632 48,
Patrick Boettchera75763f2006-10-18 08:34:16 -0300633
Olivier Grenie9c783032009-12-07 07:49:40 -0300634 0,
Patrick Boettchera75763f2006-10-18 08:34:16 -0300635};
636
637static struct dibx000_bandwidth_config stk7700p_pll_config = {
Olivier Grenie9c783032009-12-07 07:49:40 -0300638 60000, 30000,
639 1, 8, 3, 1, 0,
640 0, 0, 1, 1, 0,
641 (3 << 14) | (1 << 12) | (524 << 0),
642 60258167,
643 20452225,
644 30000000,
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300645};
646
647static struct dib7000m_config stk7700p_dib7000m_config = {
648 .dvbt_mode = 1,
649 .output_mpeg2_in_188_bytes = 1,
650 .quartz_direct = 1,
651
652 .agc_config_count = 1,
Patrick Boettchera75763f2006-10-18 08:34:16 -0300653 .agc = &stk7700p_7000m_mt2060_agc_config,
654 .bw = &stk7700p_pll_config,
655
656 .gpio_dir = DIB7000M_GPIO_DEFAULT_DIRECTIONS,
657 .gpio_val = DIB7000M_GPIO_DEFAULT_VALUES,
658 .gpio_pwm_pos = DIB7000M_GPIO_DEFAULT_PWM_POS,
659};
660
661static struct dib7000p_config stk7700p_dib7000p_config = {
662 .output_mpeg2_in_188_bytes = 1,
663
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300664 .agc_config_count = 1,
Patrick Boettchera75763f2006-10-18 08:34:16 -0300665 .agc = &stk7700p_7000p_mt2060_agc_config,
666 .bw = &stk7700p_pll_config,
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300667
668 .gpio_dir = DIB7000M_GPIO_DEFAULT_DIRECTIONS,
669 .gpio_val = DIB7000M_GPIO_DEFAULT_VALUES,
670 .gpio_pwm_pos = DIB7000M_GPIO_DEFAULT_PWM_POS,
671};
Patrick Boettcherb7f54912006-09-19 12:51:37 -0300672
673static int stk7700p_frontend_attach(struct dvb_usb_adapter *adap)
674{
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300675 struct dib0700_state *st = adap->dev->priv;
Patrick Boettcherb7f54912006-09-19 12:51:37 -0300676 /* unless there is no real power management in DVB - we leave the device on GPIO6 */
Patrick Boettchera75763f2006-10-18 08:34:16 -0300677
678 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
679 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0); msleep(50);
680
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300681 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1); msleep(10);
Patrick Boettchera75763f2006-10-18 08:34:16 -0300682 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
683
Patrick Boettcherb7f54912006-09-19 12:51:37 -0300684 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0); msleep(10);
Patrick Boettchera75763f2006-10-18 08:34:16 -0300685 dib0700_ctrl_clock(adap->dev, 72, 1);
686 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1); msleep(100);
687
688 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
Patrick Boettcherb7f54912006-09-19 12:51:37 -0300689
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300690 st->mt2060_if1[0] = 1220;
Patrick Boettchera75763f2006-10-18 08:34:16 -0300691
692 if (dib7000pc_detection(&adap->dev->i2c_adap)) {
Michael Krufky77eed212011-09-06 09:31:57 -0300693 adap->fe_adap[0].fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 18, &stk7700p_dib7000p_config);
Patrick Boettchera75763f2006-10-18 08:34:16 -0300694 st->is_dib7000pc = 1;
695 } else
Michael Krufky77eed212011-09-06 09:31:57 -0300696 adap->fe_adap[0].fe = dvb_attach(dib7000m_attach, &adap->dev->i2c_adap, 18, &stk7700p_dib7000m_config);
Patrick Boettchera75763f2006-10-18 08:34:16 -0300697
Michael Krufky77eed212011-09-06 09:31:57 -0300698 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Patrick Boettcherb7f54912006-09-19 12:51:37 -0300699}
700
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300701static struct mt2060_config stk7700p_mt2060_config = {
702 0x60
703};
704
Patrick Boettcherb7f54912006-09-19 12:51:37 -0300705static int stk7700p_tuner_attach(struct dvb_usb_adapter *adap)
706{
Olivier DANETc52344f2008-01-25 06:50:07 -0300707 struct i2c_adapter *prim_i2c = &adap->dev->i2c_adap;
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300708 struct dib0700_state *st = adap->dev->priv;
Patrick Boettchera75763f2006-10-18 08:34:16 -0300709 struct i2c_adapter *tun_i2c;
Olivier DANETc52344f2008-01-25 06:50:07 -0300710 s8 a;
711 int if1=1220;
Al Viroda5ee482008-05-21 00:31:21 -0300712 if (adap->dev->udev->descriptor.idVendor == cpu_to_le16(USB_VID_HAUPPAUGE) &&
713 adap->dev->udev->descriptor.idProduct == cpu_to_le16(USB_PID_HAUPPAUGE_NOVA_T_STICK)) {
Olivier DANETc52344f2008-01-25 06:50:07 -0300714 if (!eeprom_read(prim_i2c,0x58,&a)) if1=1220+a;
715 }
Patrick Boettchera75763f2006-10-18 08:34:16 -0300716 if (st->is_dib7000pc)
Michael Krufky77eed212011-09-06 09:31:57 -0300717 tun_i2c = dib7000p_get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_TUNER, 1);
Patrick Boettchera75763f2006-10-18 08:34:16 -0300718 else
Michael Krufky77eed212011-09-06 09:31:57 -0300719 tun_i2c = dib7000m_get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_TUNER, 1);
Patrick Boettchera75763f2006-10-18 08:34:16 -0300720
Michael Krufky77eed212011-09-06 09:31:57 -0300721 return dvb_attach(mt2060_attach, adap->fe_adap[0].fe, tun_i2c, &stk7700p_mt2060_config,
Olivier DANETc52344f2008-01-25 06:50:07 -0300722 if1) == NULL ? -ENODEV : 0;
Patrick Boettcherb7f54912006-09-19 12:51:37 -0300723}
724
Patrick Boettcher01373a52007-07-30 12:49:04 -0300725/* DIB7070 generic */
726static struct dibx000_agc_config dib7070_agc_config = {
727 BAND_UHF | BAND_VHF | BAND_LBAND | BAND_SBAND,
728 /* 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,
729 * 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 -0300730 (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8)
731 | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),
Patrick Boettcher01373a52007-07-30 12:49:04 -0300732
Olivier Grenie9c783032009-12-07 07:49:40 -0300733 600,
734 10,
Patrick Boettcher01373a52007-07-30 12:49:04 -0300735
Olivier Grenie9c783032009-12-07 07:49:40 -0300736 0,
737 118,
Patrick Boettcher01373a52007-07-30 12:49:04 -0300738
Olivier Grenie9c783032009-12-07 07:49:40 -0300739 0,
740 3530,
741 1,
742 5,
Patrick Boettcher01373a52007-07-30 12:49:04 -0300743
Olivier Grenie9c783032009-12-07 07:49:40 -0300744 65535,
745 0,
Patrick Boettcher01373a52007-07-30 12:49:04 -0300746
Olivier Grenie9c783032009-12-07 07:49:40 -0300747 65535,
748 0,
Patrick Boettcher01373a52007-07-30 12:49:04 -0300749
Olivier Grenie9c783032009-12-07 07:49:40 -0300750 0,
751 40,
752 183,
753 206,
754 255,
755 72,
756 152,
757 88,
758 90,
Patrick Boettcher01373a52007-07-30 12:49:04 -0300759
Olivier Grenie9c783032009-12-07 07:49:40 -0300760 17,
761 27,
762 23,
763 51,
Patrick Boettcher01373a52007-07-30 12:49:04 -0300764
Olivier Grenie9c783032009-12-07 07:49:40 -0300765 0,
Patrick Boettcher01373a52007-07-30 12:49:04 -0300766};
767
768static int dib7070_tuner_reset(struct dvb_frontend *fe, int onoff)
769{
Patrick Boettcher7e5ce652009-08-03 13:43:40 -0300770 deb_info("reset: %d", onoff);
Patrick Boettcher01373a52007-07-30 12:49:04 -0300771 return dib7000p_set_gpio(fe, 8, 0, !onoff);
772}
773
774static int dib7070_tuner_sleep(struct dvb_frontend *fe, int onoff)
775{
Patrick Boettcher7e5ce652009-08-03 13:43:40 -0300776 deb_info("sleep: %d", onoff);
Patrick Boettcher01373a52007-07-30 12:49:04 -0300777 return dib7000p_set_gpio(fe, 9, 0, onoff);
778}
779
780static struct dib0070_config dib7070p_dib0070_config[2] = {
781 {
782 .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
783 .reset = dib7070_tuner_reset,
784 .sleep = dib7070_tuner_sleep,
785 .clock_khz = 12000,
Patrick Boettcher7e5ce652009-08-03 13:43:40 -0300786 .clock_pad_drive = 4,
787 .charge_pump = 2,
Patrick Boettcher01373a52007-07-30 12:49:04 -0300788 }, {
789 .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
790 .reset = dib7070_tuner_reset,
791 .sleep = dib7070_tuner_sleep,
792 .clock_khz = 12000,
Patrick Boettcher7e5ce652009-08-03 13:43:40 -0300793 .charge_pump = 2,
Patrick Boettcher01373a52007-07-30 12:49:04 -0300794 }
795};
796
Olivier Grenied300bd62009-09-15 06:55:35 -0300797static struct dib0070_config dib7770p_dib0070_config = {
798 .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
799 .reset = dib7070_tuner_reset,
800 .sleep = dib7070_tuner_sleep,
801 .clock_khz = 12000,
802 .clock_pad_drive = 0,
803 .flip_chip = 1,
Olivier Grenieeac1fe12009-09-23 13:41:27 -0300804 .charge_pump = 2,
Olivier Grenied300bd62009-09-15 06:55:35 -0300805};
806
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -0300807static int dib7070_set_param_override(struct dvb_frontend *fe)
Patrick Boettcher01373a52007-07-30 12:49:04 -0300808{
Mauro Carvalho Chehab47b163a2011-12-24 10:18:24 -0300809 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
Patrick Boettcher01373a52007-07-30 12:49:04 -0300810 struct dvb_usb_adapter *adap = fe->dvb->priv;
811 struct dib0700_adapter_state *state = adap->priv;
812
813 u16 offset;
Mauro Carvalho Chehab47b163a2011-12-24 10:18:24 -0300814 u8 band = BAND_OF_FREQUENCY(p->frequency/1000);
Patrick Boettcher01373a52007-07-30 12:49:04 -0300815 switch (band) {
816 case BAND_VHF: offset = 950; break;
817 case BAND_UHF:
818 default: offset = 550; break;
819 }
820 deb_info("WBD for DiB7000P: %d\n", offset + dib0070_wbd_offset(fe));
821 dib7000p_set_wbd_ref(fe, offset + dib0070_wbd_offset(fe));
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -0300822 return state->set_param_save(fe);
Patrick Boettcher01373a52007-07-30 12:49:04 -0300823}
824
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -0300825static int dib7770_set_param_override(struct dvb_frontend *fe)
Olivier Grenied300bd62009-09-15 06:55:35 -0300826{
Mauro Carvalho Chehab47b163a2011-12-24 10:18:24 -0300827 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
828 struct dvb_usb_adapter *adap = fe->dvb->priv;
829 struct dib0700_adapter_state *state = adap->priv;
Olivier Grenied300bd62009-09-15 06:55:35 -0300830
831 u16 offset;
Mauro Carvalho Chehab47b163a2011-12-24 10:18:24 -0300832 u8 band = BAND_OF_FREQUENCY(p->frequency/1000);
Olivier Grenied300bd62009-09-15 06:55:35 -0300833 switch (band) {
834 case BAND_VHF:
835 dib7000p_set_gpio(fe, 0, 0, 1);
836 offset = 850;
837 break;
838 case BAND_UHF:
839 default:
840 dib7000p_set_gpio(fe, 0, 0, 0);
841 offset = 250;
842 break;
843 }
844 deb_info("WBD for DiB7000P: %d\n", offset + dib0070_wbd_offset(fe));
845 dib7000p_set_wbd_ref(fe, offset + dib0070_wbd_offset(fe));
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -0300846 return state->set_param_save(fe);
Olivier Grenied300bd62009-09-15 06:55:35 -0300847}
848
849static int dib7770p_tuner_attach(struct dvb_usb_adapter *adap)
850{
851 struct dib0700_adapter_state *st = adap->priv;
Michael Krufky77eed212011-09-06 09:31:57 -0300852 struct i2c_adapter *tun_i2c = dib7000p_get_i2c_master(adap->fe_adap[0].fe,
Olivier Grenied300bd62009-09-15 06:55:35 -0300853 DIBX000_I2C_INTERFACE_TUNER, 1);
854
Michael Krufky77eed212011-09-06 09:31:57 -0300855 if (dvb_attach(dib0070_attach, adap->fe_adap[0].fe, tun_i2c,
Michael Krufky6e1ce98d2011-09-13 01:08:44 -0300856 &dib7770p_dib0070_config) == NULL)
Olivier Grenied300bd62009-09-15 06:55:35 -0300857 return -ENODEV;
858
Michael Krufky77eed212011-09-06 09:31:57 -0300859 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
860 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib7770_set_param_override;
Olivier Grenied300bd62009-09-15 06:55:35 -0300861 return 0;
862}
863
Patrick Boettcher01373a52007-07-30 12:49:04 -0300864static int dib7070p_tuner_attach(struct dvb_usb_adapter *adap)
865{
866 struct dib0700_adapter_state *st = adap->priv;
Michael Krufky77eed212011-09-06 09:31:57 -0300867 struct i2c_adapter *tun_i2c = dib7000p_get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_TUNER, 1);
Patrick Boettcher01373a52007-07-30 12:49:04 -0300868
869 if (adap->id == 0) {
Michael Krufky77eed212011-09-06 09:31:57 -0300870 if (dvb_attach(dib0070_attach, adap->fe_adap[0].fe, tun_i2c, &dib7070p_dib0070_config[0]) == NULL)
Patrick Boettcher01373a52007-07-30 12:49:04 -0300871 return -ENODEV;
872 } else {
Michael Krufky77eed212011-09-06 09:31:57 -0300873 if (dvb_attach(dib0070_attach, adap->fe_adap[0].fe, tun_i2c, &dib7070p_dib0070_config[1]) == NULL)
Patrick Boettcher01373a52007-07-30 12:49:04 -0300874 return -ENODEV;
875 }
876
Michael Krufky77eed212011-09-06 09:31:57 -0300877 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
878 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib7070_set_param_override;
Patrick Boettcher01373a52007-07-30 12:49:04 -0300879 return 0;
880}
881
Olivier Greniee192a7c2011-01-14 13:58:59 -0300882static int stk7700p_pid_filter(struct dvb_usb_adapter *adapter, int index,
883 u16 pid, int onoff)
884{
885 struct dib0700_state *st = adapter->dev->priv;
886 if (st->is_dib7000pc)
Michael Krufky77eed212011-09-06 09:31:57 -0300887 return dib7000p_pid_filter(adapter->fe_adap[0].fe, index, pid, onoff);
888 return dib7000m_pid_filter(adapter->fe_adap[0].fe, index, pid, onoff);
Olivier Greniee192a7c2011-01-14 13:58:59 -0300889}
890
891static int stk7700p_pid_filter_ctrl(struct dvb_usb_adapter *adapter, int onoff)
892{
893 struct dib0700_state *st = adapter->dev->priv;
894 if (st->is_dib7000pc)
Michael Krufky77eed212011-09-06 09:31:57 -0300895 return dib7000p_pid_filter_ctrl(adapter->fe_adap[0].fe, onoff);
896 return dib7000m_pid_filter_ctrl(adapter->fe_adap[0].fe, onoff);
Olivier Greniee192a7c2011-01-14 13:58:59 -0300897}
898
Olivier Grenief8731f42009-09-18 04:08:43 -0300899static int stk70x0p_pid_filter(struct dvb_usb_adapter *adapter, int index, u16 pid, int onoff)
900{
Michael Krufkye3e59b02011-09-11 19:47:49 -0300901 return dib7000p_pid_filter(adapter->fe_adap[0].fe, index, pid, onoff);
Olivier Grenief8731f42009-09-18 04:08:43 -0300902}
903
904static int stk70x0p_pid_filter_ctrl(struct dvb_usb_adapter *adapter, int onoff)
905{
Michael Krufkye3e59b02011-09-11 19:47:49 -0300906 return dib7000p_pid_filter_ctrl(adapter->fe_adap[0].fe, onoff);
Olivier Grenief8731f42009-09-18 04:08:43 -0300907}
908
Patrick Boettcher01373a52007-07-30 12:49:04 -0300909static struct dibx000_bandwidth_config dib7070_bw_config_12_mhz = {
Olivier Grenie9c783032009-12-07 07:49:40 -0300910 60000, 15000,
911 1, 20, 3, 1, 0,
912 0, 0, 1, 1, 2,
913 (3 << 14) | (1 << 12) | (524 << 0),
914 (0 << 25) | 0,
915 20452225,
916 12000000,
Patrick Boettcher01373a52007-07-30 12:49:04 -0300917};
918
919static struct dib7000p_config dib7070p_dib7000p_config = {
920 .output_mpeg2_in_188_bytes = 1,
921
922 .agc_config_count = 1,
923 .agc = &dib7070_agc_config,
924 .bw = &dib7070_bw_config_12_mhz,
Patrick Boettcher3cb2c392008-01-25 07:25:20 -0300925 .tuner_is_baseband = 1,
926 .spur_protect = 1,
Patrick Boettcher01373a52007-07-30 12:49:04 -0300927
928 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
929 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
930 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
931
932 .hostbus_diversity = 1,
933};
934
935/* STK7070P */
936static int stk7070p_frontend_attach(struct dvb_usb_adapter *adap)
937{
Al Viroda5ee482008-05-21 00:31:21 -0300938 struct usb_device_descriptor *p = &adap->dev->udev->descriptor;
939 if (p->idVendor == cpu_to_le16(USB_VID_PINNACLE) &&
940 p->idProduct == cpu_to_le16(USB_PID_PINNACLE_PCTV72E))
941 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300942 else
Al Viroda5ee482008-05-21 00:31:21 -0300943 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
Patrick Boettcher01373a52007-07-30 12:49:04 -0300944 msleep(10);
945 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
946 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
947 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
948 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
949
950 dib0700_ctrl_clock(adap->dev, 72, 1);
951
952 msleep(10);
953 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
954 msleep(10);
955 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
956
Devin Heitmueller83c4fdf2009-01-21 01:55:45 -0300957 if (dib7000p_i2c_enumeration(&adap->dev->i2c_adap, 1, 18,
958 &dib7070p_dib7000p_config) != 0) {
959 err("%s: dib7000p_i2c_enumeration failed. Cannot continue\n",
960 __func__);
961 return -ENODEV;
962 }
Patrick Boettcher01373a52007-07-30 12:49:04 -0300963
Michael Krufky77eed212011-09-06 09:31:57 -0300964 adap->fe_adap[0].fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 0x80,
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300965 &dib7070p_dib7000p_config);
Michael Krufky77eed212011-09-06 09:31:57 -0300966 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Patrick Boettcher01373a52007-07-30 12:49:04 -0300967}
968
Olivier Grenie90e12ce2010-09-07 12:50:45 -0300969/* STK7770P */
970static struct dib7000p_config dib7770p_dib7000p_config = {
971 .output_mpeg2_in_188_bytes = 1,
972
973 .agc_config_count = 1,
974 .agc = &dib7070_agc_config,
975 .bw = &dib7070_bw_config_12_mhz,
976 .tuner_is_baseband = 1,
977 .spur_protect = 1,
978
979 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
980 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
981 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
982
983 .hostbus_diversity = 1,
984 .enable_current_mirror = 1,
Olivier Grenie970d14c2010-09-07 12:50:46 -0300985 .disable_sample_and_hold = 0,
Olivier Grenie90e12ce2010-09-07 12:50:45 -0300986};
987
988static int stk7770p_frontend_attach(struct dvb_usb_adapter *adap)
989{
990 struct usb_device_descriptor *p = &adap->dev->udev->descriptor;
991 if (p->idVendor == cpu_to_le16(USB_VID_PINNACLE) &&
992 p->idProduct == cpu_to_le16(USB_PID_PINNACLE_PCTV72E))
993 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
994 else
995 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
996 msleep(10);
997 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
998 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
999 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
1000 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
1001
1002 dib0700_ctrl_clock(adap->dev, 72, 1);
1003
1004 msleep(10);
1005 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
1006 msleep(10);
1007 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
1008
1009 if (dib7000p_i2c_enumeration(&adap->dev->i2c_adap, 1, 18,
1010 &dib7770p_dib7000p_config) != 0) {
1011 err("%s: dib7000p_i2c_enumeration failed. Cannot continue\n",
1012 __func__);
1013 return -ENODEV;
1014 }
1015
Michael Krufky77eed212011-09-06 09:31:57 -03001016 adap->fe_adap[0].fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 0x80,
Olivier Grenie90e12ce2010-09-07 12:50:45 -03001017 &dib7770p_dib7000p_config);
Michael Krufky77eed212011-09-06 09:31:57 -03001018 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Olivier Grenie90e12ce2010-09-07 12:50:45 -03001019}
1020
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001021/* DIB807x generic */
1022static struct dibx000_agc_config dib807x_agc_config[2] = {
1023 {
1024 BAND_VHF,
1025 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0,
1026 * P_agc_freq_pwm_div=1, P_agc_inv_pwm1=0,
1027 * P_agc_inv_pwm2=0,P_agc_inh_dc_rv_est=0,
1028 * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5,
1029 * P_agc_write=0 */
1030 (0 << 15) | (0 << 14) | (7 << 11) | (0 << 10) | (0 << 9) |
1031 (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) |
1032 (0 << 0), /* setup*/
1033
1034 600, /* inv_gain*/
1035 10, /* time_stabiliz*/
1036
1037 0, /* alpha_level*/
1038 118, /* thlock*/
1039
1040 0, /* wbd_inv*/
1041 3530, /* wbd_ref*/
1042 1, /* wbd_sel*/
1043 5, /* wbd_alpha*/
1044
1045 65535, /* agc1_max*/
1046 0, /* agc1_min*/
1047
1048 65535, /* agc2_max*/
1049 0, /* agc2_min*/
1050
1051 0, /* agc1_pt1*/
1052 40, /* agc1_pt2*/
1053 183, /* agc1_pt3*/
1054 206, /* agc1_slope1*/
1055 255, /* agc1_slope2*/
1056 72, /* agc2_pt1*/
1057 152, /* agc2_pt2*/
1058 88, /* agc2_slope1*/
1059 90, /* agc2_slope2*/
1060
1061 17, /* alpha_mant*/
1062 27, /* alpha_exp*/
1063 23, /* beta_mant*/
1064 51, /* beta_exp*/
1065
1066 0, /* perform_agc_softsplit*/
1067 }, {
1068 BAND_UHF,
1069 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0,
1070 * P_agc_freq_pwm_div=1, P_agc_inv_pwm1=0,
1071 * P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
1072 * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5,
1073 * P_agc_write=0 */
1074 (0 << 15) | (0 << 14) | (1 << 11) | (0 << 10) | (0 << 9) |
1075 (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) |
1076 (0 << 0), /* setup */
1077
1078 600, /* inv_gain*/
1079 10, /* time_stabiliz*/
1080
1081 0, /* alpha_level*/
1082 118, /* thlock*/
1083
1084 0, /* wbd_inv*/
1085 3530, /* wbd_ref*/
1086 1, /* wbd_sel*/
1087 5, /* wbd_alpha*/
1088
1089 65535, /* agc1_max*/
1090 0, /* agc1_min*/
1091
1092 65535, /* agc2_max*/
1093 0, /* agc2_min*/
1094
1095 0, /* agc1_pt1*/
1096 40, /* agc1_pt2*/
1097 183, /* agc1_pt3*/
1098 206, /* agc1_slope1*/
1099 255, /* agc1_slope2*/
1100 72, /* agc2_pt1*/
1101 152, /* agc2_pt2*/
1102 88, /* agc2_slope1*/
1103 90, /* agc2_slope2*/
1104
1105 17, /* alpha_mant*/
1106 27, /* alpha_exp*/
1107 23, /* beta_mant*/
1108 51, /* beta_exp*/
1109
1110 0, /* perform_agc_softsplit*/
1111 }
1112};
1113
1114static struct dibx000_bandwidth_config dib807x_bw_config_12_mhz = {
1115 60000, 15000, /* internal, sampling*/
1116 1, 20, 3, 1, 0, /* pll_cfg: prediv, ratio, range, reset, bypass*/
1117 0, 0, 1, 1, 2, /* misc: refdiv, bypclk_div, IO_CLK_en_core,
1118 ADClkSrc, modulo */
1119 (3 << 14) | (1 << 12) | (599 << 0), /* sad_cfg: refsel, sel, freq_15k*/
1120 (0 << 25) | 0, /* ifreq = 0.000000 MHz*/
1121 18179755, /* timf*/
1122 12000000, /* xtal_hz*/
1123};
1124
1125static struct dib8000_config dib807x_dib8000_config[2] = {
1126 {
1127 .output_mpeg2_in_188_bytes = 1,
1128
1129 .agc_config_count = 2,
1130 .agc = dib807x_agc_config,
1131 .pll = &dib807x_bw_config_12_mhz,
1132 .tuner_is_baseband = 1,
1133
1134 .gpio_dir = DIB8000_GPIO_DEFAULT_DIRECTIONS,
1135 .gpio_val = DIB8000_GPIO_DEFAULT_VALUES,
1136 .gpio_pwm_pos = DIB8000_GPIO_DEFAULT_PWM_POS,
1137
1138 .hostbus_diversity = 1,
1139 .div_cfg = 1,
1140 .agc_control = &dib0070_ctrl_agc_filter,
1141 .output_mode = OUTMODE_MPEG2_FIFO,
1142 .drives = 0x2d98,
1143 }, {
1144 .output_mpeg2_in_188_bytes = 1,
1145
1146 .agc_config_count = 2,
1147 .agc = dib807x_agc_config,
1148 .pll = &dib807x_bw_config_12_mhz,
1149 .tuner_is_baseband = 1,
1150
1151 .gpio_dir = DIB8000_GPIO_DEFAULT_DIRECTIONS,
1152 .gpio_val = DIB8000_GPIO_DEFAULT_VALUES,
1153 .gpio_pwm_pos = DIB8000_GPIO_DEFAULT_PWM_POS,
1154
1155 .hostbus_diversity = 1,
1156 .agc_control = &dib0070_ctrl_agc_filter,
1157 .output_mode = OUTMODE_MPEG2_FIFO,
1158 .drives = 0x2d98,
1159 }
1160};
1161
Olivier Grenie03245a52009-12-04 13:27:57 -03001162static int dib80xx_tuner_reset(struct dvb_frontend *fe, int onoff)
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001163{
1164 return dib8000_set_gpio(fe, 5, 0, !onoff);
1165}
1166
Olivier Grenie03245a52009-12-04 13:27:57 -03001167static int dib80xx_tuner_sleep(struct dvb_frontend *fe, int onoff)
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001168{
1169 return dib8000_set_gpio(fe, 0, 0, onoff);
1170}
1171
1172static const struct dib0070_wbd_gain_cfg dib8070_wbd_gain_cfg[] = {
1173 { 240, 7},
1174 { 0xffff, 6},
1175};
1176
1177static struct dib0070_config dib807x_dib0070_config[2] = {
1178 {
1179 .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
Olivier Grenie03245a52009-12-04 13:27:57 -03001180 .reset = dib80xx_tuner_reset,
1181 .sleep = dib80xx_tuner_sleep,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001182 .clock_khz = 12000,
1183 .clock_pad_drive = 4,
1184 .vga_filter = 1,
1185 .force_crystal_mode = 1,
1186 .enable_third_order_filter = 1,
1187 .charge_pump = 0,
1188 .wbd_gain = dib8070_wbd_gain_cfg,
1189 .osc_buffer_state = 0,
1190 .freq_offset_khz_uhf = -100,
1191 .freq_offset_khz_vhf = -100,
1192 }, {
1193 .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
Olivier Grenie03245a52009-12-04 13:27:57 -03001194 .reset = dib80xx_tuner_reset,
1195 .sleep = dib80xx_tuner_sleep,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001196 .clock_khz = 12000,
1197 .clock_pad_drive = 2,
1198 .vga_filter = 1,
1199 .force_crystal_mode = 1,
1200 .enable_third_order_filter = 1,
1201 .charge_pump = 0,
1202 .wbd_gain = dib8070_wbd_gain_cfg,
1203 .osc_buffer_state = 0,
1204 .freq_offset_khz_uhf = -25,
1205 .freq_offset_khz_vhf = -25,
1206 }
1207};
1208
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -03001209static int dib807x_set_param_override(struct dvb_frontend *fe)
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001210{
Mauro Carvalho Chehab47b163a2011-12-24 10:18:24 -03001211 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001212 struct dvb_usb_adapter *adap = fe->dvb->priv;
1213 struct dib0700_adapter_state *state = adap->priv;
1214
1215 u16 offset = dib0070_wbd_offset(fe);
Mauro Carvalho Chehab47b163a2011-12-24 10:18:24 -03001216 u8 band = BAND_OF_FREQUENCY(p->frequency/1000);
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001217 switch (band) {
1218 case BAND_VHF:
1219 offset += 750;
1220 break;
1221 case BAND_UHF: /* fall-thru wanted */
1222 default:
1223 offset += 250; break;
1224 }
1225 deb_info("WBD for DiB8000: %d\n", offset);
1226 dib8000_set_wbd_ref(fe, offset);
1227
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -03001228 return state->set_param_save(fe);
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001229}
1230
1231static int dib807x_tuner_attach(struct dvb_usb_adapter *adap)
1232{
1233 struct dib0700_adapter_state *st = adap->priv;
Michael Krufky77eed212011-09-06 09:31:57 -03001234 struct i2c_adapter *tun_i2c = dib8000_get_i2c_master(adap->fe_adap[0].fe,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001235 DIBX000_I2C_INTERFACE_TUNER, 1);
1236
1237 if (adap->id == 0) {
Michael Krufky77eed212011-09-06 09:31:57 -03001238 if (dvb_attach(dib0070_attach, adap->fe_adap[0].fe, tun_i2c,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001239 &dib807x_dib0070_config[0]) == NULL)
1240 return -ENODEV;
1241 } else {
Michael Krufky77eed212011-09-06 09:31:57 -03001242 if (dvb_attach(dib0070_attach, adap->fe_adap[0].fe, tun_i2c,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001243 &dib807x_dib0070_config[1]) == NULL)
1244 return -ENODEV;
1245 }
1246
Michael Krufky77eed212011-09-06 09:31:57 -03001247 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
1248 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib807x_set_param_override;
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001249 return 0;
1250}
1251
Olivier Grenie9c783032009-12-07 07:49:40 -03001252static int stk80xx_pid_filter(struct dvb_usb_adapter *adapter, int index,
1253 u16 pid, int onoff)
Olivier Grenief8731f42009-09-18 04:08:43 -03001254{
Michael Krufky77eed212011-09-06 09:31:57 -03001255 return dib8000_pid_filter(adapter->fe_adap[0].fe, index, pid, onoff);
Olivier Grenief8731f42009-09-18 04:08:43 -03001256}
1257
Olivier Grenie9c783032009-12-07 07:49:40 -03001258static int stk80xx_pid_filter_ctrl(struct dvb_usb_adapter *adapter,
Olivier Greniebe9bae12011-01-04 05:42:19 -03001259 int onoff)
Olivier Grenief8731f42009-09-18 04:08:43 -03001260{
Michael Krufky77eed212011-09-06 09:31:57 -03001261 return dib8000_pid_filter_ctrl(adapter->fe_adap[0].fe, onoff);
Olivier Grenief8731f42009-09-18 04:08:43 -03001262}
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001263
1264/* STK807x */
1265static int stk807x_frontend_attach(struct dvb_usb_adapter *adap)
1266{
1267 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
1268 msleep(10);
1269 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
1270 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
1271 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
1272
1273 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
1274
1275 dib0700_ctrl_clock(adap->dev, 72, 1);
1276
1277 msleep(10);
1278 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
1279 msleep(10);
1280 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
1281
1282 dib8000_i2c_enumeration(&adap->dev->i2c_adap, 1, 18,
Olivier Grenie0c32dbd2011-08-10 05:17:18 -03001283 0x80, 0);
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001284
Michael Krufky77eed212011-09-06 09:31:57 -03001285 adap->fe_adap[0].fe = dvb_attach(dib8000_attach, &adap->dev->i2c_adap, 0x80,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001286 &dib807x_dib8000_config[0]);
1287
Michael Krufky77eed212011-09-06 09:31:57 -03001288 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001289}
1290
1291/* STK807xPVR */
1292static int stk807xpvr_frontend_attach0(struct dvb_usb_adapter *adap)
1293{
1294 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
1295 msleep(30);
1296 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
1297 msleep(500);
1298 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
1299 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
1300 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
1301
1302 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
1303
1304 dib0700_ctrl_clock(adap->dev, 72, 1);
1305
1306 msleep(10);
1307 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
1308 msleep(10);
1309 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
1310
1311 /* initialize IC 0 */
Olivier Grenie0c32dbd2011-08-10 05:17:18 -03001312 dib8000_i2c_enumeration(&adap->dev->i2c_adap, 1, 0x22, 0x80, 0);
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001313
Michael Krufky77eed212011-09-06 09:31:57 -03001314 adap->fe_adap[0].fe = dvb_attach(dib8000_attach, &adap->dev->i2c_adap, 0x80,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001315 &dib807x_dib8000_config[0]);
1316
Michael Krufky77eed212011-09-06 09:31:57 -03001317 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001318}
1319
1320static int stk807xpvr_frontend_attach1(struct dvb_usb_adapter *adap)
1321{
1322 /* initialize IC 1 */
Olivier Grenie0c32dbd2011-08-10 05:17:18 -03001323 dib8000_i2c_enumeration(&adap->dev->i2c_adap, 1, 0x12, 0x82, 0);
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001324
Michael Krufky77eed212011-09-06 09:31:57 -03001325 adap->fe_adap[0].fe = dvb_attach(dib8000_attach, &adap->dev->i2c_adap, 0x82,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001326 &dib807x_dib8000_config[1]);
1327
Michael Krufky77eed212011-09-06 09:31:57 -03001328 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001329}
1330
Olivier Grenie03245a52009-12-04 13:27:57 -03001331/* STK8096GP */
Olivier Greniea685dbb2011-08-05 14:10:40 -03001332static struct dibx000_agc_config dib8090_agc_config[2] = {
Olivier Greniebe9bae12011-01-04 05:42:19 -03001333 {
Olivier Grenie03245a52009-12-04 13:27:57 -03001334 BAND_UHF | BAND_VHF | BAND_LBAND | BAND_SBAND,
Olivier Grenie9c783032009-12-07 07:49:40 -03001335 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=1,
Olivier Greniebe9bae12011-01-04 05:42:19 -03001336 * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
1337 * 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 -03001338 (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8)
1339 | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),
Olivier Grenie03245a52009-12-04 13:27:57 -03001340
Olivier Grenie9c783032009-12-07 07:49:40 -03001341 787,
1342 10,
Olivier Grenie03245a52009-12-04 13:27:57 -03001343
Olivier Grenie9c783032009-12-07 07:49:40 -03001344 0,
1345 118,
Olivier Grenie03245a52009-12-04 13:27:57 -03001346
Olivier Grenie9c783032009-12-07 07:49:40 -03001347 0,
1348 3530,
1349 1,
1350 5,
Olivier Grenie03245a52009-12-04 13:27:57 -03001351
Olivier Grenie9c783032009-12-07 07:49:40 -03001352 65535,
1353 0,
Olivier Grenie03245a52009-12-04 13:27:57 -03001354
Olivier Grenie9c783032009-12-07 07:49:40 -03001355 65535,
1356 0,
Olivier Grenie03245a52009-12-04 13:27:57 -03001357
Olivier Grenie9c783032009-12-07 07:49:40 -03001358 0,
1359 32,
1360 114,
1361 143,
1362 144,
1363 114,
1364 227,
1365 116,
1366 117,
Olivier Grenie03245a52009-12-04 13:27:57 -03001367
Olivier Grenie9c783032009-12-07 07:49:40 -03001368 28,
1369 26,
1370 31,
1371 51,
Olivier Grenie03245a52009-12-04 13:27:57 -03001372
Olivier Grenie9c783032009-12-07 07:49:40 -03001373 0,
Olivier Greniebe9bae12011-01-04 05:42:19 -03001374 },
1375 {
Olivier Grenie03245a52009-12-04 13:27:57 -03001376 BAND_CBAND,
Olivier Grenie9c783032009-12-07 07:49:40 -03001377 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=1,
Olivier Greniebe9bae12011-01-04 05:42:19 -03001378 * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
1379 * 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 -03001380 (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8)
1381 | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),
Olivier Grenie03245a52009-12-04 13:27:57 -03001382
Olivier Grenie9c783032009-12-07 07:49:40 -03001383 787,
1384 10,
Olivier Grenie03245a52009-12-04 13:27:57 -03001385
Olivier Grenie9c783032009-12-07 07:49:40 -03001386 0,
1387 118,
Olivier Grenie03245a52009-12-04 13:27:57 -03001388
Olivier Grenie9c783032009-12-07 07:49:40 -03001389 0,
1390 3530,
1391 1,
1392 5,
Olivier Grenie03245a52009-12-04 13:27:57 -03001393
Olivier Grenie9c783032009-12-07 07:49:40 -03001394 0,
1395 0,
Olivier Grenie03245a52009-12-04 13:27:57 -03001396
Olivier Grenie9c783032009-12-07 07:49:40 -03001397 65535,
1398 0,
Olivier Grenie03245a52009-12-04 13:27:57 -03001399
Olivier Grenie9c783032009-12-07 07:49:40 -03001400 0,
1401 32,
1402 114,
1403 143,
1404 144,
1405 114,
1406 227,
1407 116,
1408 117,
Olivier Grenie03245a52009-12-04 13:27:57 -03001409
Olivier Grenie9c783032009-12-07 07:49:40 -03001410 28,
1411 26,
1412 31,
1413 51,
Olivier Grenie03245a52009-12-04 13:27:57 -03001414
Olivier Grenie9c783032009-12-07 07:49:40 -03001415 0,
Olivier Greniebe9bae12011-01-04 05:42:19 -03001416 }
Olivier Grenie03245a52009-12-04 13:27:57 -03001417};
1418
1419static struct dibx000_bandwidth_config dib8090_pll_config_12mhz = {
Olivier Greniebe9bae12011-01-04 05:42:19 -03001420 54000, 13500,
1421 1, 18, 3, 1, 0,
1422 0, 0, 1, 1, 2,
1423 (3 << 14) | (1 << 12) | (599 << 0),
1424 (0 << 25) | 0,
1425 20199727,
1426 12000000,
Olivier Grenie03245a52009-12-04 13:27:57 -03001427};
1428
1429static int dib8090_get_adc_power(struct dvb_frontend *fe)
1430{
Olivier Greniebe9bae12011-01-04 05:42:19 -03001431 return dib8000_get_adc_power(fe, 1);
Olivier Grenie03245a52009-12-04 13:27:57 -03001432}
1433
Olivier Greniebe9bae12011-01-04 05:42:19 -03001434static struct dib8000_config dib809x_dib8000_config[2] = {
1435 {
1436 .output_mpeg2_in_188_bytes = 1,
Olivier Grenie03245a52009-12-04 13:27:57 -03001437
Olivier Greniebe9bae12011-01-04 05:42:19 -03001438 .agc_config_count = 2,
1439 .agc = dib8090_agc_config,
1440 .agc_control = dib0090_dcc_freq,
1441 .pll = &dib8090_pll_config_12mhz,
1442 .tuner_is_baseband = 1,
Olivier Grenie03245a52009-12-04 13:27:57 -03001443
Olivier Greniebe9bae12011-01-04 05:42:19 -03001444 .gpio_dir = DIB8000_GPIO_DEFAULT_DIRECTIONS,
1445 .gpio_val = DIB8000_GPIO_DEFAULT_VALUES,
1446 .gpio_pwm_pos = DIB8000_GPIO_DEFAULT_PWM_POS,
Olivier Grenie03245a52009-12-04 13:27:57 -03001447
Olivier Greniebe9bae12011-01-04 05:42:19 -03001448 .hostbus_diversity = 1,
1449 .div_cfg = 0x31,
1450 .output_mode = OUTMODE_MPEG2_FIFO,
1451 .drives = 0x2d98,
1452 .diversity_delay = 48,
1453 .refclksel = 3,
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03001454 }, {
Olivier Greniebe9bae12011-01-04 05:42:19 -03001455 .output_mpeg2_in_188_bytes = 1,
1456
1457 .agc_config_count = 2,
1458 .agc = dib8090_agc_config,
1459 .agc_control = dib0090_dcc_freq,
1460 .pll = &dib8090_pll_config_12mhz,
1461 .tuner_is_baseband = 1,
1462
1463 .gpio_dir = DIB8000_GPIO_DEFAULT_DIRECTIONS,
1464 .gpio_val = DIB8000_GPIO_DEFAULT_VALUES,
1465 .gpio_pwm_pos = DIB8000_GPIO_DEFAULT_PWM_POS,
1466
1467 .hostbus_diversity = 1,
1468 .div_cfg = 0x31,
1469 .output_mode = OUTMODE_DIVERSITY,
1470 .drives = 0x2d08,
1471 .diversity_delay = 1,
1472 .refclksel = 3,
1473 }
1474};
1475
1476static struct dib0090_wbd_slope dib8090_wbd_table[] = {
1477 /* max freq ; cold slope ; cold offset ; warm slope ; warm offset ; wbd gain */
1478 { 120, 0, 500, 0, 500, 4 }, /* CBAND */
1479 { 170, 0, 450, 0, 450, 4 }, /* CBAND */
1480 { 380, 48, 373, 28, 259, 6 }, /* VHF */
1481 { 860, 34, 700, 36, 616, 6 }, /* high UHF */
1482 { 0xFFFF, 34, 700, 36, 616, 6 }, /* default */
Olivier Grenie03245a52009-12-04 13:27:57 -03001483};
1484
1485static struct dib0090_config dib809x_dib0090_config = {
Olivier Greniebe9bae12011-01-04 05:42:19 -03001486 .io.pll_bypass = 1,
1487 .io.pll_range = 1,
1488 .io.pll_prediv = 1,
1489 .io.pll_loopdiv = 20,
1490 .io.adc_clock_ratio = 8,
1491 .io.pll_int_loop_filt = 0,
1492 .io.clock_khz = 12000,
1493 .reset = dib80xx_tuner_reset,
1494 .sleep = dib80xx_tuner_sleep,
1495 .clkouttobamse = 1,
1496 .analog_output = 1,
1497 .i2c_address = DEFAULT_DIB0090_I2C_ADDRESS,
1498 .use_pwm_agc = 1,
1499 .clkoutdrive = 1,
1500 .get_adc_power = dib8090_get_adc_power,
1501 .freq_offset_khz_uhf = -63,
Olivier Grenie03245a52009-12-04 13:27:57 -03001502 .freq_offset_khz_vhf = -143,
Olivier Greniebe9bae12011-01-04 05:42:19 -03001503 .wbd = dib8090_wbd_table,
1504 .fref_clock_ratio = 6,
Olivier Grenie03245a52009-12-04 13:27:57 -03001505};
1506
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -03001507static int dib8096_set_param_override(struct dvb_frontend *fe)
Olivier Grenie03245a52009-12-04 13:27:57 -03001508{
Mauro Carvalho Chehab47b163a2011-12-24 10:18:24 -03001509 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
Olivier Greniebe9bae12011-01-04 05:42:19 -03001510 struct dvb_usb_adapter *adap = fe->dvb->priv;
1511 struct dib0700_adapter_state *state = adap->priv;
Mauro Carvalho Chehab47b163a2011-12-24 10:18:24 -03001512 u8 band = BAND_OF_FREQUENCY(p->frequency/1000);
Olivier Greniebe9bae12011-01-04 05:42:19 -03001513 u16 target;
1514 int ret = 0;
1515 enum frontend_tune_state tune_state = CT_SHUTDOWN;
1516 u16 ltgain, rf_gain_limit;
Olivier Grenie03245a52009-12-04 13:27:57 -03001517
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -03001518 ret = state->set_param_save(fe);
Olivier Greniebe9bae12011-01-04 05:42:19 -03001519 if (ret < 0)
1520 return ret;
Olivier Grenie03245a52009-12-04 13:27:57 -03001521
Olivier Grenie6724a2f2011-08-05 13:49:33 -03001522 target = (dib0090_get_wbd_target(fe) * 8 * 18 / 33 + 1) / 2;
Olivier Greniebe9bae12011-01-04 05:42:19 -03001523 dib8000_set_wbd_ref(fe, target);
Olivier Grenie03245a52009-12-04 13:27:57 -03001524
1525
Olivier Greniebe9bae12011-01-04 05:42:19 -03001526 if (band == BAND_CBAND) {
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03001527 deb_info("tuning in CBAND - soft-AGC startup\n");
1528 dib0090_set_tune_state(fe, CT_AGC_START);
1529 do {
1530 ret = dib0090_gain_control(fe);
1531 msleep(ret);
1532 tune_state = dib0090_get_tune_state(fe);
1533 if (tune_state == CT_AGC_STEP_0)
1534 dib8000_set_gpio(fe, 6, 0, 1);
1535 else if (tune_state == CT_AGC_STEP_1) {
1536 dib0090_get_current_gain(fe, NULL, NULL, &rf_gain_limit, &ltgain);
1537 if (rf_gain_limit == 0)
1538 dib8000_set_gpio(fe, 6, 0, 0);
1539 }
1540 } while (tune_state < CT_AGC_STOP);
1541 dib0090_pwm_gain_reset(fe);
1542 dib8000_pwm_agc_reset(fe);
1543 dib8000_set_tune_state(fe, CT_DEMOD_START);
Olivier Greniebe9bae12011-01-04 05:42:19 -03001544 } else {
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03001545 deb_info("not tuning in CBAND - standard AGC startup\n");
1546 dib0090_pwm_gain_reset(fe);
Olivier Greniebe9bae12011-01-04 05:42:19 -03001547 }
Olivier Grenie03245a52009-12-04 13:27:57 -03001548
Olivier Greniebe9bae12011-01-04 05:42:19 -03001549 return 0;
Olivier Grenie03245a52009-12-04 13:27:57 -03001550}
1551
1552static int dib809x_tuner_attach(struct dvb_usb_adapter *adap)
1553{
Olivier Greniebe9bae12011-01-04 05:42:19 -03001554 struct dib0700_adapter_state *st = adap->priv;
Michael Krufky77eed212011-09-06 09:31:57 -03001555 struct i2c_adapter *tun_i2c = dib8000_get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_TUNER, 1);
Olivier Grenie03245a52009-12-04 13:27:57 -03001556
Michael Krufky77eed212011-09-06 09:31:57 -03001557 if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c, &dib809x_dib0090_config) == NULL)
Olivier Greniebe9bae12011-01-04 05:42:19 -03001558 return -ENODEV;
Olivier Grenie03245a52009-12-04 13:27:57 -03001559
Michael Krufky77eed212011-09-06 09:31:57 -03001560 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
1561 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib8096_set_param_override;
Olivier Greniebe9bae12011-01-04 05:42:19 -03001562 return 0;
Olivier Grenie03245a52009-12-04 13:27:57 -03001563}
1564
1565static int stk809x_frontend_attach(struct dvb_usb_adapter *adap)
1566{
1567 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
1568 msleep(10);
1569 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
1570 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
1571 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
1572
1573 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
1574
1575 dib0700_ctrl_clock(adap->dev, 72, 1);
1576
1577 msleep(10);
1578 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
1579 msleep(10);
1580 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
1581
Olivier Grenie0c32dbd2011-08-10 05:17:18 -03001582 dib8000_i2c_enumeration(&adap->dev->i2c_adap, 1, 18, 0x80, 0);
Olivier Grenie03245a52009-12-04 13:27:57 -03001583
Michael Krufky77eed212011-09-06 09:31:57 -03001584 adap->fe_adap[0].fe = dvb_attach(dib8000_attach, &adap->dev->i2c_adap, 0x80, &dib809x_dib8000_config[0]);
Olivier Grenie03245a52009-12-04 13:27:57 -03001585
Michael Krufky77eed212011-09-06 09:31:57 -03001586 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Olivier Grenie03245a52009-12-04 13:27:57 -03001587}
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001588
Olivier Greniebe9bae12011-01-04 05:42:19 -03001589static int nim8096md_tuner_attach(struct dvb_usb_adapter *adap)
1590{
1591 struct dib0700_adapter_state *st = adap->priv;
1592 struct i2c_adapter *tun_i2c;
Michael Krufky77eed212011-09-06 09:31:57 -03001593 struct dvb_frontend *fe_slave = dib8000_get_slave_frontend(adap->fe_adap[0].fe, 1);
Olivier Greniebe9bae12011-01-04 05:42:19 -03001594
1595 if (fe_slave) {
1596 tun_i2c = dib8000_get_i2c_master(fe_slave, DIBX000_I2C_INTERFACE_TUNER, 1);
1597 if (dvb_attach(dib0090_register, fe_slave, tun_i2c, &dib809x_dib0090_config) == NULL)
1598 return -ENODEV;
Michael Krufky77eed212011-09-06 09:31:57 -03001599 fe_slave->dvb = adap->fe_adap[0].fe->dvb;
Olivier Greniebe9bae12011-01-04 05:42:19 -03001600 fe_slave->ops.tuner_ops.set_params = dib8096_set_param_override;
1601 }
Michael Krufky77eed212011-09-06 09:31:57 -03001602 tun_i2c = dib8000_get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_TUNER, 1);
1603 if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c, &dib809x_dib0090_config) == NULL)
Olivier Greniebe9bae12011-01-04 05:42:19 -03001604 return -ENODEV;
1605
Michael Krufky77eed212011-09-06 09:31:57 -03001606 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
1607 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib8096_set_param_override;
Olivier Greniebe9bae12011-01-04 05:42:19 -03001608
1609 return 0;
1610}
1611
1612static int nim8096md_frontend_attach(struct dvb_usb_adapter *adap)
1613{
1614 struct dvb_frontend *fe_slave;
1615
1616 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03001617 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03001618 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
1619 msleep(1000);
1620 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
1621 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
1622 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
1623
1624 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
1625
1626 dib0700_ctrl_clock(adap->dev, 72, 1);
1627
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03001628 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03001629 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03001630 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03001631 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
1632
Olivier Grenie0c32dbd2011-08-10 05:17:18 -03001633 dib8000_i2c_enumeration(&adap->dev->i2c_adap, 2, 18, 0x80, 0);
Olivier Greniebe9bae12011-01-04 05:42:19 -03001634
Michael Krufky77eed212011-09-06 09:31:57 -03001635 adap->fe_adap[0].fe = dvb_attach(dib8000_attach, &adap->dev->i2c_adap, 0x80, &dib809x_dib8000_config[0]);
1636 if (adap->fe_adap[0].fe == NULL)
Olivier Greniebe9bae12011-01-04 05:42:19 -03001637 return -ENODEV;
1638
1639 fe_slave = dvb_attach(dib8000_attach, &adap->dev->i2c_adap, 0x82, &dib809x_dib8000_config[1]);
Michael Krufky77eed212011-09-06 09:31:57 -03001640 dib8000_set_slave_frontend(adap->fe_adap[0].fe, fe_slave);
Olivier Greniebe9bae12011-01-04 05:42:19 -03001641
1642 return fe_slave == NULL ? -ENODEV : 0;
1643}
1644
Olivier Grenie88f3a352011-08-10 05:28:38 -03001645/* TFE8096P */
1646static struct dibx000_agc_config dib8096p_agc_config[2] = {
1647 {
1648 .band_caps = BAND_UHF,
1649 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0,
1650 P_agc_freq_pwm_div=1, P_agc_inv_pwm1=0,
1651 P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
1652 P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5,
1653 P_agc_write=0 */
1654 .setup = (0 << 15) | (0 << 14) | (5 << 11)
1655 | (0 << 10) | (0 << 9) | (0 << 8) | (3 << 5)
1656 | (0 << 4) | (5 << 1) | (0 << 0),
1657
1658 .inv_gain = 684,
1659 .time_stabiliz = 10,
1660
1661 .alpha_level = 0,
1662 .thlock = 118,
1663
1664 .wbd_inv = 0,
1665 .wbd_ref = 1200,
1666 .wbd_sel = 3,
1667 .wbd_alpha = 5,
1668
1669 .agc1_max = 65535,
1670 .agc1_min = 0,
1671
1672 .agc2_max = 32767,
1673 .agc2_min = 0,
1674
1675 .agc1_pt1 = 0,
1676 .agc1_pt2 = 0,
1677 .agc1_pt3 = 105,
1678 .agc1_slope1 = 0,
1679 .agc1_slope2 = 156,
1680 .agc2_pt1 = 105,
1681 .agc2_pt2 = 255,
1682 .agc2_slope1 = 54,
1683 .agc2_slope2 = 0,
1684
1685 .alpha_mant = 28,
1686 .alpha_exp = 26,
1687 .beta_mant = 31,
1688 .beta_exp = 51,
1689
1690 .perform_agc_softsplit = 0,
1691 } , {
1692 .band_caps = BAND_FM | BAND_VHF | BAND_CBAND,
1693 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0,
1694 P_agc_freq_pwm_div=1, P_agc_inv_pwm1=0,
1695 P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
1696 P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5,
1697 P_agc_write=0 */
1698 .setup = (0 << 15) | (0 << 14) | (5 << 11)
1699 | (0 << 10) | (0 << 9) | (0 << 8) | (3 << 5)
1700 | (0 << 4) | (5 << 1) | (0 << 0),
1701
1702 .inv_gain = 732,
1703 .time_stabiliz = 10,
1704
1705 .alpha_level = 0,
1706 .thlock = 118,
1707
1708 .wbd_inv = 0,
1709 .wbd_ref = 1200,
1710 .wbd_sel = 3,
1711 .wbd_alpha = 5,
1712
1713 .agc1_max = 65535,
1714 .agc1_min = 0,
1715
1716 .agc2_max = 32767,
1717 .agc2_min = 0,
1718
1719 .agc1_pt1 = 0,
1720 .agc1_pt2 = 0,
1721 .agc1_pt3 = 98,
1722 .agc1_slope1 = 0,
1723 .agc1_slope2 = 167,
1724 .agc2_pt1 = 98,
1725 .agc2_pt2 = 255,
1726 .agc2_slope1 = 52,
1727 .agc2_slope2 = 0,
1728
1729 .alpha_mant = 28,
1730 .alpha_exp = 26,
1731 .beta_mant = 31,
1732 .beta_exp = 51,
1733
1734 .perform_agc_softsplit = 0,
1735 }
1736};
1737
1738static struct dibx000_bandwidth_config dib8096p_clock_config_12_mhz = {
1739 108000, 13500,
1740 1, 9, 1, 0, 0,
1741 0, 0, 0, 0, 2,
1742 (3 << 14) | (1 << 12) | (524 << 0),
1743 (0 << 25) | 0,
1744 20199729,
1745 12000000,
1746};
1747
1748static struct dib8000_config tfe8096p_dib8000_config = {
1749 .output_mpeg2_in_188_bytes = 1,
1750 .hostbus_diversity = 1,
1751 .update_lna = NULL,
1752
1753 .agc_config_count = 2,
1754 .agc = dib8096p_agc_config,
1755 .pll = &dib8096p_clock_config_12_mhz,
1756
1757 .gpio_dir = DIB8000_GPIO_DEFAULT_DIRECTIONS,
1758 .gpio_val = DIB8000_GPIO_DEFAULT_VALUES,
1759 .gpio_pwm_pos = DIB8000_GPIO_DEFAULT_PWM_POS,
1760
1761 .agc_control = NULL,
1762 .diversity_delay = 48,
1763 .output_mode = OUTMODE_MPEG2_FIFO,
1764 .enMpegOutput = 1,
1765};
1766
1767static struct dib0090_wbd_slope dib8096p_wbd_table[] = {
1768 { 380, 81, 850, 64, 540, 4},
1769 { 860, 51, 866, 21, 375, 4},
1770 {1700, 0, 250, 0, 100, 6},
1771 {2600, 0, 250, 0, 100, 6},
1772 { 0xFFFF, 0, 0, 0, 0, 0},
1773};
1774
1775static const struct dib0090_config tfe8096p_dib0090_config = {
1776 .io.clock_khz = 12000,
1777 .io.pll_bypass = 0,
1778 .io.pll_range = 0,
1779 .io.pll_prediv = 3,
1780 .io.pll_loopdiv = 6,
1781 .io.adc_clock_ratio = 0,
1782 .io.pll_int_loop_filt = 0,
1783 .reset = dib8096p_tuner_sleep,
1784 .sleep = dib8096p_tuner_sleep,
1785
1786 .freq_offset_khz_uhf = -143,
1787 .freq_offset_khz_vhf = -143,
1788
1789 .get_adc_power = dib8090_get_adc_power,
1790
1791 .clkouttobamse = 1,
1792 .analog_output = 0,
1793
1794 .wbd_vhf_offset = 0,
1795 .wbd_cband_offset = 0,
1796 .use_pwm_agc = 1,
1797 .clkoutdrive = 0,
1798
1799 .fref_clock_ratio = 1,
1800
1801 .wbd = dib8096p_wbd_table,
1802
1803 .ls_cfg_pad_drv = 0,
1804 .data_tx_drv = 0,
1805 .low_if = NULL,
1806 .in_soc = 1,
1807 .force_cband_input = 0,
1808};
1809
1810struct dibx090p_adc {
1811 u32 freq; /* RF freq MHz */
1812 u32 timf; /* New Timf */
1813 u32 pll_loopdiv; /* New prediv */
1814 u32 pll_prediv; /* New loopdiv */
1815};
1816
1817struct dibx090p_adc dib8090p_adc_tab[] = {
1818 { 50000, 17043521, 16, 3}, /* 64 MHz */
1819 {878000, 20199729, 9, 1}, /* 60 MHz */
1820 {0xffffffff, 0, 0, 0}, /* 60 MHz */
1821};
1822
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -03001823static int dib8096p_agc_startup(struct dvb_frontend *fe)
Olivier Grenie88f3a352011-08-10 05:28:38 -03001824{
Mauro Carvalho Chehab47b163a2011-12-24 10:18:24 -03001825 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
Olivier Grenie88f3a352011-08-10 05:28:38 -03001826 struct dvb_usb_adapter *adap = fe->dvb->priv;
1827 struct dib0700_adapter_state *state = adap->priv;
1828 struct dibx000_bandwidth_config pll;
1829 u16 target;
1830 int better_sampling_freq = 0, ret;
1831 struct dibx090p_adc *adc_table = &dib8090p_adc_tab[0];
1832
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -03001833 ret = state->set_param_save(fe);
Olivier Grenie88f3a352011-08-10 05:28:38 -03001834 if (ret < 0)
1835 return ret;
1836 memset(&pll, 0, sizeof(struct dibx000_bandwidth_config));
1837
1838 dib0090_pwm_gain_reset(fe);
1839 /* dib0090_get_wbd_target is returning any possible
1840 temperature compensated wbd-target */
1841 target = (dib0090_get_wbd_target(fe) * 8 + 1) / 2;
1842 dib8000_set_wbd_ref(fe, target);
1843
1844
Mauro Carvalho Chehab47b163a2011-12-24 10:18:24 -03001845 while (p->frequency / 1000 > adc_table->freq) {
Olivier Grenie88f3a352011-08-10 05:28:38 -03001846 better_sampling_freq = 1;
1847 adc_table++;
1848 }
1849
1850 if ((adc_table->freq != 0xffffffff) && better_sampling_freq) {
1851 pll.pll_ratio = adc_table->pll_loopdiv;
1852 pll.pll_prediv = adc_table->pll_prediv;
1853 dib8000_update_pll(fe, &pll);
1854 dib8000_ctrl_timf(fe, DEMOD_TIMF_SET, adc_table->timf);
1855 }
1856 return 0;
1857}
1858
1859static int tfe8096p_frontend_attach(struct dvb_usb_adapter *adap)
1860{
1861 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
1862 msleep(20);
1863 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
1864 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
1865 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
1866
1867 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
1868
1869 dib0700_ctrl_clock(adap->dev, 72, 1);
1870
1871 msleep(20);
1872 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
1873 msleep(20);
1874 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
1875
1876 dib8000_i2c_enumeration(&adap->dev->i2c_adap, 1, 0x10, 0x80, 1);
1877
1878 adap->fe_adap[0].fe = dvb_attach(dib8000_attach,
1879 &adap->dev->i2c_adap, 0x80, &tfe8096p_dib8000_config);
1880
1881 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
1882}
1883
1884static int tfe8096p_tuner_attach(struct dvb_usb_adapter *adap)
1885{
1886 struct dib0700_adapter_state *st = adap->priv;
1887 struct i2c_adapter *tun_i2c = dib8096p_get_i2c_tuner(adap->fe_adap[0].fe);
1888
1889 if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c,
1890 &tfe8096p_dib0090_config) == NULL)
1891 return -ENODEV;
1892
1893 dib8000_set_gpio(adap->fe_adap[0].fe, 8, 0, 1);
1894
1895 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
1896 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib8096p_agc_startup;
1897 return 0;
1898}
1899
Olivier Greniebe9bae12011-01-04 05:42:19 -03001900/* STK9090M */
1901static int dib90x0_pid_filter(struct dvb_usb_adapter *adapter, int index, u16 pid, int onoff)
1902{
Michael Krufky77eed212011-09-06 09:31:57 -03001903 return dib9000_fw_pid_filter(adapter->fe_adap[0].fe, index, pid, onoff);
Olivier Greniebe9bae12011-01-04 05:42:19 -03001904}
1905
1906static int dib90x0_pid_filter_ctrl(struct dvb_usb_adapter *adapter, int onoff)
1907{
Michael Krufky77eed212011-09-06 09:31:57 -03001908 return dib9000_fw_pid_filter_ctrl(adapter->fe_adap[0].fe, onoff);
Olivier Greniebe9bae12011-01-04 05:42:19 -03001909}
1910
1911static int dib90x0_tuner_reset(struct dvb_frontend *fe, int onoff)
1912{
1913 return dib9000_set_gpio(fe, 5, 0, !onoff);
1914}
1915
1916static int dib90x0_tuner_sleep(struct dvb_frontend *fe, int onoff)
1917{
1918 return dib9000_set_gpio(fe, 0, 0, onoff);
1919}
1920
1921static int dib01x0_pmu_update(struct i2c_adapter *i2c, u16 *data, u8 len)
1922{
1923 u8 wb[4] = { 0xc >> 8, 0xc & 0xff, 0, 0 };
1924 u8 rb[2];
1925 struct i2c_msg msg[2] = {
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03001926 {.addr = 0x1e >> 1, .flags = 0, .buf = wb, .len = 2},
1927 {.addr = 0x1e >> 1, .flags = I2C_M_RD, .buf = rb, .len = 2},
Olivier Greniebe9bae12011-01-04 05:42:19 -03001928 };
1929 u8 index_data;
1930
1931 dibx000_i2c_set_speed(i2c, 250);
1932
1933 if (i2c_transfer(i2c, msg, 2) != 2)
1934 return -EIO;
1935
1936 switch (rb[0] << 8 | rb[1]) {
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03001937 case 0:
Olivier Greniebe9bae12011-01-04 05:42:19 -03001938 deb_info("Found DiB0170 rev1: This version of DiB0170 is not supported any longer.\n");
1939 return -EIO;
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03001940 case 1:
Olivier Greniebe9bae12011-01-04 05:42:19 -03001941 deb_info("Found DiB0170 rev2");
1942 break;
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03001943 case 2:
Olivier Greniebe9bae12011-01-04 05:42:19 -03001944 deb_info("Found DiB0190 rev2");
1945 break;
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03001946 default:
Olivier Greniebe9bae12011-01-04 05:42:19 -03001947 deb_info("DiB01x0 not found");
1948 return -EIO;
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03001949 }
Olivier Greniebe9bae12011-01-04 05:42:19 -03001950
1951 for (index_data = 0; index_data < len; index_data += 2) {
1952 wb[2] = (data[index_data + 1] >> 8) & 0xff;
1953 wb[3] = (data[index_data + 1]) & 0xff;
1954
1955 if (data[index_data] == 0) {
1956 wb[0] = (data[index_data] >> 8) & 0xff;
1957 wb[1] = (data[index_data]) & 0xff;
1958 msg[0].len = 2;
1959 if (i2c_transfer(i2c, msg, 2) != 2)
1960 return -EIO;
1961 wb[2] |= rb[0];
1962 wb[3] |= rb[1] & ~(3 << 4);
1963 }
1964
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03001965 wb[0] = (data[index_data] >> 8)&0xff;
1966 wb[1] = (data[index_data])&0xff;
Olivier Greniebe9bae12011-01-04 05:42:19 -03001967 msg[0].len = 4;
1968 if (i2c_transfer(i2c, &msg[0], 1) != 1)
1969 return -EIO;
1970 }
1971 return 0;
1972}
1973
1974static struct dib9000_config stk9090m_config = {
1975 .output_mpeg2_in_188_bytes = 1,
1976 .output_mode = OUTMODE_MPEG2_FIFO,
1977 .vcxo_timer = 279620,
1978 .timing_frequency = 20452225,
1979 .demod_clock_khz = 60000,
1980 .xtal_clock_khz = 30000,
1981 .if_drives = (0 << 15) | (1 << 13) | (0 << 12) | (3 << 10) | (0 << 9) | (1 << 7) | (0 << 6) | (0 << 4) | (1 << 3) | (1 << 1) | (0),
1982 .subband = {
1983 2,
1984 {
1985 { 240, { BOARD_GPIO_COMPONENT_DEMOD, BOARD_GPIO_FUNCTION_SUBBAND_GPIO, 0x0008, 0x0000, 0x0008 } }, /* GPIO 3 to 1 for VHF */
1986 { 890, { BOARD_GPIO_COMPONENT_DEMOD, BOARD_GPIO_FUNCTION_SUBBAND_GPIO, 0x0008, 0x0000, 0x0000 } }, /* GPIO 3 to 0 for UHF */
1987 { 0 },
1988 },
1989 },
1990 .gpio_function = {
1991 { .component = BOARD_GPIO_COMPONENT_DEMOD, .function = BOARD_GPIO_FUNCTION_COMPONENT_ON, .mask = 0x10 | 0x21, .direction = 0 & ~0x21, .value = (0x10 & ~0x1) | 0x20 },
1992 { .component = BOARD_GPIO_COMPONENT_DEMOD, .function = BOARD_GPIO_FUNCTION_COMPONENT_OFF, .mask = 0x10 | 0x21, .direction = 0 & ~0x21, .value = 0 | 0x21 },
1993 },
1994};
1995
1996static struct dib9000_config nim9090md_config[2] = {
1997 {
1998 .output_mpeg2_in_188_bytes = 1,
1999 .output_mode = OUTMODE_MPEG2_FIFO,
2000 .vcxo_timer = 279620,
2001 .timing_frequency = 20452225,
2002 .demod_clock_khz = 60000,
2003 .xtal_clock_khz = 30000,
2004 .if_drives = (0 << 15) | (1 << 13) | (0 << 12) | (3 << 10) | (0 << 9) | (1 << 7) | (0 << 6) | (0 << 4) | (1 << 3) | (1 << 1) | (0),
2005 }, {
2006 .output_mpeg2_in_188_bytes = 1,
2007 .output_mode = OUTMODE_DIVERSITY,
2008 .vcxo_timer = 279620,
2009 .timing_frequency = 20452225,
2010 .demod_clock_khz = 60000,
2011 .xtal_clock_khz = 30000,
2012 .if_drives = (0 << 15) | (1 << 13) | (0 << 12) | (3 << 10) | (0 << 9) | (1 << 7) | (0 << 6) | (0 << 4) | (1 << 3) | (1 << 1) | (0),
2013 .subband = {
2014 2,
2015 {
2016 { 240, { BOARD_GPIO_COMPONENT_DEMOD, BOARD_GPIO_FUNCTION_SUBBAND_GPIO, 0x0006, 0x0000, 0x0006 } }, /* GPIO 1 and 2 to 1 for VHF */
2017 { 890, { BOARD_GPIO_COMPONENT_DEMOD, BOARD_GPIO_FUNCTION_SUBBAND_GPIO, 0x0006, 0x0000, 0x0000 } }, /* GPIO 1 and 2 to 0 for UHF */
2018 { 0 },
2019 },
2020 },
2021 .gpio_function = {
2022 { .component = BOARD_GPIO_COMPONENT_DEMOD, .function = BOARD_GPIO_FUNCTION_COMPONENT_ON, .mask = 0x10 | 0x21, .direction = 0 & ~0x21, .value = (0x10 & ~0x1) | 0x20 },
2023 { .component = BOARD_GPIO_COMPONENT_DEMOD, .function = BOARD_GPIO_FUNCTION_COMPONENT_OFF, .mask = 0x10 | 0x21, .direction = 0 & ~0x21, .value = 0 | 0x21 },
2024 },
2025 }
2026};
2027
2028static struct dib0090_config dib9090_dib0090_config = {
2029 .io.pll_bypass = 0,
2030 .io.pll_range = 1,
2031 .io.pll_prediv = 1,
2032 .io.pll_loopdiv = 8,
2033 .io.adc_clock_ratio = 8,
2034 .io.pll_int_loop_filt = 0,
2035 .io.clock_khz = 30000,
2036 .reset = dib90x0_tuner_reset,
2037 .sleep = dib90x0_tuner_sleep,
2038 .clkouttobamse = 0,
2039 .analog_output = 0,
2040 .use_pwm_agc = 0,
2041 .clkoutdrive = 0,
2042 .freq_offset_khz_uhf = 0,
2043 .freq_offset_khz_vhf = 0,
2044};
2045
2046static struct dib0090_config nim9090md_dib0090_config[2] = {
2047 {
2048 .io.pll_bypass = 0,
2049 .io.pll_range = 1,
2050 .io.pll_prediv = 1,
2051 .io.pll_loopdiv = 8,
2052 .io.adc_clock_ratio = 8,
2053 .io.pll_int_loop_filt = 0,
2054 .io.clock_khz = 30000,
2055 .reset = dib90x0_tuner_reset,
2056 .sleep = dib90x0_tuner_sleep,
2057 .clkouttobamse = 1,
2058 .analog_output = 0,
2059 .use_pwm_agc = 0,
2060 .clkoutdrive = 0,
2061 .freq_offset_khz_uhf = 0,
2062 .freq_offset_khz_vhf = 0,
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002063 }, {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002064 .io.pll_bypass = 0,
2065 .io.pll_range = 1,
2066 .io.pll_prediv = 1,
2067 .io.pll_loopdiv = 8,
2068 .io.adc_clock_ratio = 8,
2069 .io.pll_int_loop_filt = 0,
2070 .io.clock_khz = 30000,
2071 .reset = dib90x0_tuner_reset,
2072 .sleep = dib90x0_tuner_sleep,
2073 .clkouttobamse = 0,
2074 .analog_output = 0,
2075 .use_pwm_agc = 0,
2076 .clkoutdrive = 0,
2077 .freq_offset_khz_uhf = 0,
2078 .freq_offset_khz_vhf = 0,
2079 }
2080};
2081
2082
2083static int stk9090m_frontend_attach(struct dvb_usb_adapter *adap)
2084{
2085 struct dib0700_adapter_state *state = adap->priv;
2086 struct dib0700_state *st = adap->dev->priv;
2087 u32 fw_version;
2088
2089 /* Make use of the new i2c functions from FW 1.20 */
2090 dib0700_get_version(adap->dev, NULL, NULL, &fw_version, NULL);
2091 if (fw_version >= 0x10200)
2092 st->fw_use_new_i2c_api = 1;
2093 dib0700_set_i2c_speed(adap->dev, 340);
2094
2095 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002096 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002097 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
2098 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
2099 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
2100 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
2101
2102 dib0700_ctrl_clock(adap->dev, 72, 1);
2103
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002104 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002105 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002106 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002107 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
2108
2109 dib9000_i2c_enumeration(&adap->dev->i2c_adap, 1, 0x10, 0x80);
2110
2111 if (request_firmware(&state->frontend_firmware, "dib9090.fw", &adap->dev->udev->dev)) {
2112 deb_info("%s: Upload failed. (file not found?)\n", __func__);
2113 return -ENODEV;
2114 } else {
2115 deb_info("%s: firmware read %Zu bytes.\n", __func__, state->frontend_firmware->size);
2116 }
2117 stk9090m_config.microcode_B_fe_size = state->frontend_firmware->size;
2118 stk9090m_config.microcode_B_fe_buffer = state->frontend_firmware->data;
2119
Michael Krufky77eed212011-09-06 09:31:57 -03002120 adap->fe_adap[0].fe = dvb_attach(dib9000_attach, &adap->dev->i2c_adap, 0x80, &stk9090m_config);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002121
Michael Krufky77eed212011-09-06 09:31:57 -03002122 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Olivier Greniebe9bae12011-01-04 05:42:19 -03002123}
2124
2125static int dib9090_tuner_attach(struct dvb_usb_adapter *adap)
2126{
2127 struct dib0700_adapter_state *state = adap->priv;
Michael Krufky77eed212011-09-06 09:31:57 -03002128 struct i2c_adapter *i2c = dib9000_get_tuner_interface(adap->fe_adap[0].fe);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002129 u16 data_dib190[10] = {
2130 1, 0x1374,
2131 2, 0x01a2,
2132 7, 0x0020,
2133 0, 0x00ef,
2134 8, 0x0486,
2135 };
2136
Michael Krufky77eed212011-09-06 09:31:57 -03002137 if (dvb_attach(dib0090_fw_register, adap->fe_adap[0].fe, i2c, &dib9090_dib0090_config) == NULL)
Olivier Greniebe9bae12011-01-04 05:42:19 -03002138 return -ENODEV;
Michael Krufky77eed212011-09-06 09:31:57 -03002139 i2c = dib9000_get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_GPIO_1_2, 0);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002140 if (dib01x0_pmu_update(i2c, data_dib190, 10) != 0)
2141 return -ENODEV;
Olivier Grenied1190022011-08-29 10:58:47 -03002142 dib0700_set_i2c_speed(adap->dev, 1500);
Michael Krufky77eed212011-09-06 09:31:57 -03002143 if (dib9000_firmware_post_pll_init(adap->fe_adap[0].fe) < 0)
Olivier Greniebe9bae12011-01-04 05:42:19 -03002144 return -ENODEV;
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002145 release_firmware(state->frontend_firmware);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002146 return 0;
2147}
2148
2149static int nim9090md_frontend_attach(struct dvb_usb_adapter *adap)
2150{
2151 struct dib0700_adapter_state *state = adap->priv;
2152 struct dib0700_state *st = adap->dev->priv;
2153 struct i2c_adapter *i2c;
2154 struct dvb_frontend *fe_slave;
2155 u32 fw_version;
2156
2157 /* Make use of the new i2c functions from FW 1.20 */
2158 dib0700_get_version(adap->dev, NULL, NULL, &fw_version, NULL);
2159 if (fw_version >= 0x10200)
2160 st->fw_use_new_i2c_api = 1;
2161 dib0700_set_i2c_speed(adap->dev, 340);
2162
2163 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002164 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002165 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
2166 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
2167 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
2168 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
2169
2170 dib0700_ctrl_clock(adap->dev, 72, 1);
2171
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002172 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002173 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002174 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002175 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
2176
2177 if (request_firmware(&state->frontend_firmware, "dib9090.fw", &adap->dev->udev->dev)) {
2178 deb_info("%s: Upload failed. (file not found?)\n", __func__);
2179 return -EIO;
2180 } else {
2181 deb_info("%s: firmware read %Zu bytes.\n", __func__, state->frontend_firmware->size);
2182 }
2183 nim9090md_config[0].microcode_B_fe_size = state->frontend_firmware->size;
2184 nim9090md_config[0].microcode_B_fe_buffer = state->frontend_firmware->data;
2185 nim9090md_config[1].microcode_B_fe_size = state->frontend_firmware->size;
2186 nim9090md_config[1].microcode_B_fe_buffer = state->frontend_firmware->data;
2187
2188 dib9000_i2c_enumeration(&adap->dev->i2c_adap, 1, 0x20, 0x80);
Michael Krufky77eed212011-09-06 09:31:57 -03002189 adap->fe_adap[0].fe = dvb_attach(dib9000_attach, &adap->dev->i2c_adap, 0x80, &nim9090md_config[0]);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002190
Michael Krufky77eed212011-09-06 09:31:57 -03002191 if (adap->fe_adap[0].fe == NULL)
Olivier Greniebe9bae12011-01-04 05:42:19 -03002192 return -ENODEV;
2193
Michael Krufky77eed212011-09-06 09:31:57 -03002194 i2c = dib9000_get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_GPIO_3_4, 0);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002195 dib9000_i2c_enumeration(i2c, 1, 0x12, 0x82);
2196
2197 fe_slave = dvb_attach(dib9000_attach, i2c, 0x82, &nim9090md_config[1]);
Michael Krufky77eed212011-09-06 09:31:57 -03002198 dib9000_set_slave_frontend(adap->fe_adap[0].fe, fe_slave);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002199
2200 return fe_slave == NULL ? -ENODEV : 0;
2201}
2202
2203static int nim9090md_tuner_attach(struct dvb_usb_adapter *adap)
2204{
2205 struct dib0700_adapter_state *state = adap->priv;
2206 struct i2c_adapter *i2c;
2207 struct dvb_frontend *fe_slave;
2208 u16 data_dib190[10] = {
2209 1, 0x5374,
2210 2, 0x01ae,
2211 7, 0x0020,
2212 0, 0x00ef,
2213 8, 0x0406,
2214 };
Michael Krufky77eed212011-09-06 09:31:57 -03002215 i2c = dib9000_get_tuner_interface(adap->fe_adap[0].fe);
2216 if (dvb_attach(dib0090_fw_register, adap->fe_adap[0].fe, i2c, &nim9090md_dib0090_config[0]) == NULL)
Olivier Greniebe9bae12011-01-04 05:42:19 -03002217 return -ENODEV;
Michael Krufky77eed212011-09-06 09:31:57 -03002218 i2c = dib9000_get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_GPIO_1_2, 0);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002219 if (dib01x0_pmu_update(i2c, data_dib190, 10) < 0)
2220 return -ENODEV;
Olivier Grenied1190022011-08-29 10:58:47 -03002221
2222 dib0700_set_i2c_speed(adap->dev, 1500);
Michael Krufky77eed212011-09-06 09:31:57 -03002223 if (dib9000_firmware_post_pll_init(adap->fe_adap[0].fe) < 0)
Olivier Greniebe9bae12011-01-04 05:42:19 -03002224 return -ENODEV;
2225
Michael Krufky77eed212011-09-06 09:31:57 -03002226 fe_slave = dib9000_get_slave_frontend(adap->fe_adap[0].fe, 1);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002227 if (fe_slave != NULL) {
Michael Krufky77eed212011-09-06 09:31:57 -03002228 i2c = dib9000_get_component_bus_interface(adap->fe_adap[0].fe);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002229 dib9000_set_i2c_adapter(fe_slave, i2c);
2230
2231 i2c = dib9000_get_tuner_interface(fe_slave);
2232 if (dvb_attach(dib0090_fw_register, fe_slave, i2c, &nim9090md_dib0090_config[1]) == NULL)
2233 return -ENODEV;
Michael Krufky77eed212011-09-06 09:31:57 -03002234 fe_slave->dvb = adap->fe_adap[0].fe->dvb;
Olivier Grenied1190022011-08-29 10:58:47 -03002235 dib9000_fw_set_component_bus_speed(adap->fe_adap[0].fe, 1500);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002236 if (dib9000_firmware_post_pll_init(fe_slave) < 0)
2237 return -ENODEV;
2238 }
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002239 release_firmware(state->frontend_firmware);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002240
2241 return 0;
2242}
2243
2244/* NIM7090 */
2245struct dib7090p_best_adc {
2246 u32 timf;
2247 u32 pll_loopdiv;
2248 u32 pll_prediv;
2249};
2250
2251static int dib7090p_get_best_sampling(struct dvb_frontend *fe , struct dib7090p_best_adc *adc)
2252{
2253 u8 spur = 0, prediv = 0, loopdiv = 0, min_prediv = 1, max_prediv = 1;
2254
2255 u16 xtal = 12000;
2256 u32 fcp_min = 1900; /* PLL Minimum Frequency comparator KHz */
2257 u32 fcp_max = 20000; /* PLL Maximum Frequency comparator KHz */
2258 u32 fdem_max = 76000;
2259 u32 fdem_min = 69500;
2260 u32 fcp = 0, fs = 0, fdem = 0;
2261 u32 harmonic_id = 0;
2262
2263 adc->pll_loopdiv = loopdiv;
2264 adc->pll_prediv = prediv;
2265 adc->timf = 0;
2266
2267 deb_info("bandwidth = %d fdem_min =%d", fe->dtv_property_cache.bandwidth_hz, fdem_min);
2268
2269 /* Find Min and Max prediv */
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002270 while ((xtal/max_prediv) >= fcp_min)
Olivier Greniebe9bae12011-01-04 05:42:19 -03002271 max_prediv++;
2272
2273 max_prediv--;
2274 min_prediv = max_prediv;
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002275 while ((xtal/min_prediv) <= fcp_max) {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002276 min_prediv--;
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002277 if (min_prediv == 1)
Olivier Greniebe9bae12011-01-04 05:42:19 -03002278 break;
2279 }
2280 deb_info("MIN prediv = %d : MAX prediv = %d", min_prediv, max_prediv);
2281
2282 min_prediv = 2;
2283
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002284 for (prediv = min_prediv ; prediv < max_prediv; prediv++) {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002285 fcp = xtal / prediv;
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002286 if (fcp > fcp_min && fcp < fcp_max) {
2287 for (loopdiv = 1 ; loopdiv < 64 ; loopdiv++) {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002288 fdem = ((xtal/prediv) * loopdiv);
2289 fs = fdem / 4;
2290 /* test min/max system restrictions */
2291
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002292 if ((fdem >= fdem_min) && (fdem <= fdem_max) && (fs >= fe->dtv_property_cache.bandwidth_hz/1000)) {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002293 spur = 0;
2294 /* test fs harmonics positions */
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002295 for (harmonic_id = (fe->dtv_property_cache.frequency / (1000*fs)) ; harmonic_id <= ((fe->dtv_property_cache.frequency / (1000*fs))+1) ; harmonic_id++) {
2296 if (((fs*harmonic_id) >= ((fe->dtv_property_cache.frequency/1000) - (fe->dtv_property_cache.bandwidth_hz/2000))) && ((fs*harmonic_id) <= ((fe->dtv_property_cache.frequency/1000) + (fe->dtv_property_cache.bandwidth_hz/2000)))) {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002297 spur = 1;
2298 break;
2299 }
2300 }
2301
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002302 if (!spur) {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002303 adc->pll_loopdiv = loopdiv;
2304 adc->pll_prediv = prediv;
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002305 adc->timf = 2396745143UL/fdem*(1 << 9);
2306 adc->timf += ((2396745143UL%fdem) << 9)/fdem;
Olivier Greniebe9bae12011-01-04 05:42:19 -03002307 deb_info("loopdiv=%i prediv=%i timf=%i", loopdiv, prediv, adc->timf);
2308 break;
2309 }
2310 }
2311 }
2312 }
2313 if (!spur)
2314 break;
2315 }
2316
2317
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002318 if (adc->pll_loopdiv == 0 && adc->pll_prediv == 0)
Olivier Greniebe9bae12011-01-04 05:42:19 -03002319 return -EINVAL;
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002320 else
Olivier Greniebe9bae12011-01-04 05:42:19 -03002321 return 0;
2322}
2323
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -03002324static int dib7090_agc_startup(struct dvb_frontend *fe)
Olivier Greniebe9bae12011-01-04 05:42:19 -03002325{
2326 struct dvb_usb_adapter *adap = fe->dvb->priv;
2327 struct dib0700_adapter_state *state = adap->priv;
2328 struct dibx000_bandwidth_config pll;
2329 u16 target;
2330 struct dib7090p_best_adc adc;
2331 int ret;
2332
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -03002333 ret = state->set_param_save(fe);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002334 if (ret < 0)
2335 return ret;
2336
2337 memset(&pll, 0, sizeof(struct dibx000_bandwidth_config));
2338 dib0090_pwm_gain_reset(fe);
Olivier Grenie6724a2f2011-08-05 13:49:33 -03002339 target = (dib0090_get_wbd_target(fe) * 8 + 1) / 2;
Olivier Greniebe9bae12011-01-04 05:42:19 -03002340 dib7000p_set_wbd_ref(fe, target);
2341
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002342 if (dib7090p_get_best_sampling(fe, &adc) == 0) {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002343 pll.pll_ratio = adc.pll_loopdiv;
2344 pll.pll_prediv = adc.pll_prediv;
2345
2346 dib7000p_update_pll(fe, &pll);
2347 dib7000p_ctrl_timf(fe, DEMOD_TIMF_SET, adc.timf);
2348 }
2349 return 0;
2350}
2351
Olivier Grenie2e802862011-08-05 10:39:15 -03002352static int dib7090_agc_restart(struct dvb_frontend *fe, u8 restart)
2353{
2354 deb_info("AGC restart callback: %d", restart);
2355 if (restart == 0) /* before AGC startup */
2356 dib0090_set_dc_servo(fe, 1);
2357 return 0;
2358}
2359
Olivier Grenie6724a2f2011-08-05 13:49:33 -03002360static int dib7090e_update_lna(struct dvb_frontend *fe, u16 agc_global)
2361{
2362 u16 agc1 = 0, agc2, wbd = 0, wbd_target, wbd_offset, threshold_agc1;
2363 s16 wbd_delta;
2364
2365 if ((fe->dtv_property_cache.frequency) < 400000000)
2366 threshold_agc1 = 25000;
2367 else
2368 threshold_agc1 = 30000;
2369
2370 wbd_target = (dib0090_get_wbd_target(fe)*8+1)/2;
2371 wbd_offset = dib0090_get_wbd_offset(fe);
2372 dib7000p_get_agc_values(fe, NULL, &agc1, &agc2, &wbd);
2373 wbd_delta = (s16)wbd - (((s16)wbd_offset+10)*4) ;
2374
2375 deb_info("update lna, agc_global=%d agc1=%d agc2=%d",
2376 agc_global, agc1, agc2);
2377 deb_info("update lna, wbd=%d wbd target=%d wbd offset=%d wbd delta=%d",
2378 wbd, wbd_target, wbd_offset, wbd_delta);
2379
2380 if ((agc1 < threshold_agc1) && (wbd_delta > 0)) {
2381 dib0090_set_switch(fe, 1, 1, 1);
2382 dib0090_set_vga(fe, 0);
2383 dib0090_update_rframp_7090(fe, 0);
2384 dib0090_update_tuning_table_7090(fe, 0);
2385 } else {
2386 dib0090_set_vga(fe, 1);
2387 dib0090_update_rframp_7090(fe, 1);
2388 dib0090_update_tuning_table_7090(fe, 1);
2389 dib0090_set_switch(fe, 0, 0, 0);
2390 }
2391
2392 return 0;
2393}
2394
Olivier Greniebe9bae12011-01-04 05:42:19 -03002395static struct dib0090_wbd_slope dib7090_wbd_table[] = {
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002396 { 380, 81, 850, 64, 540, 4},
2397 { 860, 51, 866, 21, 375, 4},
2398 {1700, 0, 250, 0, 100, 6},
2399 {2600, 0, 250, 0, 100, 6},
2400 { 0xFFFF, 0, 0, 0, 0, 0},
Olivier Greniebe9bae12011-01-04 05:42:19 -03002401};
2402
Olivier Grenie6724a2f2011-08-05 13:49:33 -03002403static struct dib0090_wbd_slope dib7090e_wbd_table[] = {
2404 { 380, 81, 850, 64, 540, 4},
2405 { 700, 51, 866, 21, 320, 4},
2406 { 860, 48, 666, 18, 330, 6},
2407 {1700, 0, 250, 0, 100, 6},
2408 {2600, 0, 250, 0, 100, 6},
2409 { 0xFFFF, 0, 0, 0, 0, 0},
2410};
2411
Olivier Greniea685dbb2011-08-05 14:10:40 -03002412static struct dibx000_agc_config dib7090_agc_config[2] = {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002413 {
2414 .band_caps = BAND_UHF,
2415 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=1, P_agc_inv_pwm1=0, P_agc_inv_pwm2=0,
2416 * 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 Grenieb4d6046e2011-01-04 13:08:14 -03002417 .setup = (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),
Olivier Greniebe9bae12011-01-04 05:42:19 -03002418
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002419 .inv_gain = 687,
2420 .time_stabiliz = 10,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002421
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002422 .alpha_level = 0,
2423 .thlock = 118,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002424
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002425 .wbd_inv = 0,
2426 .wbd_ref = 1200,
2427 .wbd_sel = 3,
2428 .wbd_alpha = 5,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002429
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002430 .agc1_max = 65535,
2431 .agc1_min = 0,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002432
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002433 .agc2_max = 65535,
2434 .agc2_min = 0,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002435
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002436 .agc1_pt1 = 0,
2437 .agc1_pt2 = 32,
2438 .agc1_pt3 = 114,
2439 .agc1_slope1 = 143,
2440 .agc1_slope2 = 144,
2441 .agc2_pt1 = 114,
2442 .agc2_pt2 = 227,
2443 .agc2_slope1 = 116,
2444 .agc2_slope2 = 117,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002445
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002446 .alpha_mant = 18,
2447 .alpha_exp = 0,
2448 .beta_mant = 20,
2449 .beta_exp = 59,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002450
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002451 .perform_agc_softsplit = 0,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002452 } , {
2453 .band_caps = BAND_FM | BAND_VHF | BAND_CBAND,
2454 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=1, P_agc_inv_pwm1=0, P_agc_inv_pwm2=0,
2455 * 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 Grenieb4d6046e2011-01-04 13:08:14 -03002456 .setup = (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),
Olivier Greniebe9bae12011-01-04 05:42:19 -03002457
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002458 .inv_gain = 732,
2459 .time_stabiliz = 10,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002460
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002461 .alpha_level = 0,
2462 .thlock = 118,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002463
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002464 .wbd_inv = 0,
2465 .wbd_ref = 1200,
2466 .wbd_sel = 3,
2467 .wbd_alpha = 5,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002468
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002469 .agc1_max = 65535,
2470 .agc1_min = 0,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002471
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002472 .agc2_max = 65535,
2473 .agc2_min = 0,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002474
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002475 .agc1_pt1 = 0,
2476 .agc1_pt2 = 0,
2477 .agc1_pt3 = 98,
2478 .agc1_slope1 = 0,
2479 .agc1_slope2 = 167,
Patrick Boettcher7f4d5272011-04-03 12:28:08 -03002480 .agc2_pt1 = 98,
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002481 .agc2_pt2 = 255,
2482 .agc2_slope1 = 104,
2483 .agc2_slope2 = 0,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002484
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002485 .alpha_mant = 18,
2486 .alpha_exp = 0,
2487 .beta_mant = 20,
2488 .beta_exp = 59,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002489
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002490 .perform_agc_softsplit = 0,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002491 }
2492};
2493
2494static struct dibx000_bandwidth_config dib7090_clock_config_12_mhz = {
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002495 60000, 15000,
2496 1, 5, 0, 0, 0,
2497 0, 0, 1, 1, 2,
2498 (3 << 14) | (1 << 12) | (524 << 0),
2499 (0 << 25) | 0,
2500 20452225,
2501 15000000,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002502};
2503
2504static struct dib7000p_config nim7090_dib7000p_config = {
2505 .output_mpeg2_in_188_bytes = 1,
2506 .hostbus_diversity = 1,
2507 .tuner_is_baseband = 1,
2508 .update_lna = NULL,
2509
2510 .agc_config_count = 2,
2511 .agc = dib7090_agc_config,
2512
2513 .bw = &dib7090_clock_config_12_mhz,
2514
2515 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
2516 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
2517 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
2518
2519 .pwm_freq_div = 0,
2520
2521 .agc_control = dib7090_agc_restart,
2522
2523 .spur_protect = 0,
2524 .disable_sample_and_hold = 0,
2525 .enable_current_mirror = 0,
2526 .diversity_delay = 0,
2527
2528 .output_mode = OUTMODE_MPEG2_FIFO,
2529 .enMpegOutput = 1,
2530};
2531
2532static struct dib7000p_config tfe7090pvr_dib7000p_config[2] = {
2533 {
2534 .output_mpeg2_in_188_bytes = 1,
2535 .hostbus_diversity = 1,
2536 .tuner_is_baseband = 1,
2537 .update_lna = NULL,
2538
2539 .agc_config_count = 2,
2540 .agc = dib7090_agc_config,
2541
2542 .bw = &dib7090_clock_config_12_mhz,
2543
2544 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
2545 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
2546 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
2547
2548 .pwm_freq_div = 0,
2549
2550 .agc_control = dib7090_agc_restart,
2551
2552 .spur_protect = 0,
2553 .disable_sample_and_hold = 0,
2554 .enable_current_mirror = 0,
2555 .diversity_delay = 0,
2556
2557 .output_mode = OUTMODE_MPEG2_PAR_GATED_CLK,
2558 .default_i2c_addr = 0x90,
2559 .enMpegOutput = 1,
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002560 }, {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002561 .output_mpeg2_in_188_bytes = 1,
2562 .hostbus_diversity = 1,
2563 .tuner_is_baseband = 1,
2564 .update_lna = NULL,
2565
2566 .agc_config_count = 2,
2567 .agc = dib7090_agc_config,
2568
2569 .bw = &dib7090_clock_config_12_mhz,
2570
2571 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
2572 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
2573 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
2574
2575 .pwm_freq_div = 0,
2576
2577 .agc_control = dib7090_agc_restart,
2578
2579 .spur_protect = 0,
2580 .disable_sample_and_hold = 0,
2581 .enable_current_mirror = 0,
2582 .diversity_delay = 0,
2583
2584 .output_mode = OUTMODE_MPEG2_PAR_GATED_CLK,
2585 .default_i2c_addr = 0x92,
2586 .enMpegOutput = 0,
2587 }
2588};
2589
Olivier Grenie6724a2f2011-08-05 13:49:33 -03002590static struct dib7000p_config tfe7090e_dib7000p_config = {
2591 .output_mpeg2_in_188_bytes = 1,
2592 .hostbus_diversity = 1,
2593 .tuner_is_baseband = 1,
2594 .update_lna = dib7090e_update_lna,
2595
2596 .agc_config_count = 2,
2597 .agc = dib7090_agc_config,
2598
2599 .bw = &dib7090_clock_config_12_mhz,
2600
2601 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
2602 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
2603 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
2604
2605 .pwm_freq_div = 0,
2606
2607 .agc_control = dib7090_agc_restart,
2608
2609 .spur_protect = 0,
2610 .disable_sample_and_hold = 0,
2611 .enable_current_mirror = 0,
2612 .diversity_delay = 0,
2613
2614 .output_mode = OUTMODE_MPEG2_FIFO,
2615 .enMpegOutput = 1,
2616};
2617
Olivier Greniebe9bae12011-01-04 05:42:19 -03002618static const struct dib0090_config nim7090_dib0090_config = {
2619 .io.clock_khz = 12000,
2620 .io.pll_bypass = 0,
2621 .io.pll_range = 0,
2622 .io.pll_prediv = 3,
2623 .io.pll_loopdiv = 6,
2624 .io.adc_clock_ratio = 0,
2625 .io.pll_int_loop_filt = 0,
2626 .reset = dib7090_tuner_sleep,
2627 .sleep = dib7090_tuner_sleep,
2628
2629 .freq_offset_khz_uhf = 0,
2630 .freq_offset_khz_vhf = 0,
2631
2632 .get_adc_power = dib7090_get_adc_power,
2633
2634 .clkouttobamse = 1,
2635 .analog_output = 0,
2636
2637 .wbd_vhf_offset = 0,
2638 .wbd_cband_offset = 0,
2639 .use_pwm_agc = 1,
2640 .clkoutdrive = 0,
2641
2642 .fref_clock_ratio = 0,
2643
2644 .wbd = dib7090_wbd_table,
2645
2646 .ls_cfg_pad_drv = 0,
2647 .data_tx_drv = 0,
2648 .low_if = NULL,
2649 .in_soc = 1,
2650};
2651
Olivier Grenie6724a2f2011-08-05 13:49:33 -03002652static const struct dib0090_config tfe7090e_dib0090_config = {
2653 .io.clock_khz = 12000,
2654 .io.pll_bypass = 0,
2655 .io.pll_range = 0,
2656 .io.pll_prediv = 3,
2657 .io.pll_loopdiv = 6,
2658 .io.adc_clock_ratio = 0,
2659 .io.pll_int_loop_filt = 0,
2660 .reset = dib7090_tuner_sleep,
2661 .sleep = dib7090_tuner_sleep,
2662
2663 .freq_offset_khz_uhf = 0,
2664 .freq_offset_khz_vhf = 0,
2665
2666 .get_adc_power = dib7090_get_adc_power,
2667
2668 .clkouttobamse = 1,
2669 .analog_output = 0,
2670
2671 .wbd_vhf_offset = 0,
2672 .wbd_cband_offset = 0,
2673 .use_pwm_agc = 1,
2674 .clkoutdrive = 0,
2675
2676 .fref_clock_ratio = 0,
2677
2678 .wbd = dib7090e_wbd_table,
2679
2680 .ls_cfg_pad_drv = 0,
2681 .data_tx_drv = 0,
2682 .low_if = NULL,
2683 .in_soc = 1,
2684 .force_cband_input = 1,
2685 .is_dib7090e = 1,
2686};
2687
Olivier Grenieb293f302011-08-09 04:48:25 -03002688static struct dib7000p_config tfe7790e_dib7000p_config = {
2689 .output_mpeg2_in_188_bytes = 1,
2690 .hostbus_diversity = 1,
2691 .tuner_is_baseband = 1,
2692 .update_lna = dib7090e_update_lna,
2693
2694 .agc_config_count = 2,
2695 .agc = dib7090_agc_config,
2696
2697 .bw = &dib7090_clock_config_12_mhz,
2698
2699 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
2700 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
2701 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
2702
2703 .pwm_freq_div = 0,
2704
2705 .agc_control = dib7090_agc_restart,
2706
2707 .spur_protect = 0,
2708 .disable_sample_and_hold = 0,
2709 .enable_current_mirror = 0,
2710 .diversity_delay = 0,
2711
2712 .output_mode = OUTMODE_MPEG2_PAR_GATED_CLK,
2713 .enMpegOutput = 1,
2714};
2715
2716static const struct dib0090_config tfe7790e_dib0090_config = {
2717 .io.clock_khz = 12000,
2718 .io.pll_bypass = 0,
2719 .io.pll_range = 0,
2720 .io.pll_prediv = 3,
2721 .io.pll_loopdiv = 6,
2722 .io.adc_clock_ratio = 0,
2723 .io.pll_int_loop_filt = 0,
2724 .reset = dib7090_tuner_sleep,
2725 .sleep = dib7090_tuner_sleep,
2726
2727 .freq_offset_khz_uhf = 0,
2728 .freq_offset_khz_vhf = 0,
2729
2730 .get_adc_power = dib7090_get_adc_power,
2731
2732 .clkouttobamse = 1,
2733 .analog_output = 0,
2734
2735 .wbd_vhf_offset = 0,
2736 .wbd_cband_offset = 0,
2737 .use_pwm_agc = 1,
2738 .clkoutdrive = 0,
2739
2740 .fref_clock_ratio = 0,
2741
2742 .wbd = dib7090e_wbd_table,
2743
2744 .ls_cfg_pad_drv = 0,
2745 .data_tx_drv = 0,
2746 .low_if = NULL,
2747 .in_soc = 1,
2748 .force_cband_input = 1,
2749 .is_dib7090e = 1,
2750 .force_crystal_mode = 1,
2751};
2752
Olivier Greniebe9bae12011-01-04 05:42:19 -03002753static const struct dib0090_config tfe7090pvr_dib0090_config[2] = {
2754 {
2755 .io.clock_khz = 12000,
2756 .io.pll_bypass = 0,
2757 .io.pll_range = 0,
2758 .io.pll_prediv = 3,
2759 .io.pll_loopdiv = 6,
2760 .io.adc_clock_ratio = 0,
2761 .io.pll_int_loop_filt = 0,
2762 .reset = dib7090_tuner_sleep,
2763 .sleep = dib7090_tuner_sleep,
2764
2765 .freq_offset_khz_uhf = 50,
2766 .freq_offset_khz_vhf = 70,
2767
2768 .get_adc_power = dib7090_get_adc_power,
2769
2770 .clkouttobamse = 1,
2771 .analog_output = 0,
2772
2773 .wbd_vhf_offset = 0,
2774 .wbd_cband_offset = 0,
2775 .use_pwm_agc = 1,
2776 .clkoutdrive = 0,
2777
2778 .fref_clock_ratio = 0,
2779
2780 .wbd = dib7090_wbd_table,
2781
2782 .ls_cfg_pad_drv = 0,
2783 .data_tx_drv = 0,
2784 .low_if = NULL,
2785 .in_soc = 1,
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002786 }, {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002787 .io.clock_khz = 12000,
2788 .io.pll_bypass = 0,
2789 .io.pll_range = 0,
2790 .io.pll_prediv = 3,
2791 .io.pll_loopdiv = 6,
2792 .io.adc_clock_ratio = 0,
2793 .io.pll_int_loop_filt = 0,
2794 .reset = dib7090_tuner_sleep,
2795 .sleep = dib7090_tuner_sleep,
2796
2797 .freq_offset_khz_uhf = -50,
2798 .freq_offset_khz_vhf = -70,
2799
2800 .get_adc_power = dib7090_get_adc_power,
2801
2802 .clkouttobamse = 1,
2803 .analog_output = 0,
2804
2805 .wbd_vhf_offset = 0,
2806 .wbd_cband_offset = 0,
2807 .use_pwm_agc = 1,
2808 .clkoutdrive = 0,
2809
2810 .fref_clock_ratio = 0,
2811
2812 .wbd = dib7090_wbd_table,
2813
2814 .ls_cfg_pad_drv = 0,
2815 .data_tx_drv = 0,
2816 .low_if = NULL,
2817 .in_soc = 1,
2818 }
2819};
2820
2821static int nim7090_frontend_attach(struct dvb_usb_adapter *adap)
2822{
2823 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002824 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002825 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
2826 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
2827 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
2828 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
2829
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002830 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002831 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002832 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002833 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
2834
2835 if (dib7000p_i2c_enumeration(&adap->dev->i2c_adap, 1, 0x10, &nim7090_dib7000p_config) != 0) {
2836 err("%s: dib7000p_i2c_enumeration failed. Cannot continue\n", __func__);
2837 return -ENODEV;
2838 }
Michael Krufky77eed212011-09-06 09:31:57 -03002839 adap->fe_adap[0].fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 0x80, &nim7090_dib7000p_config);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002840
Michael Krufky77eed212011-09-06 09:31:57 -03002841 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Olivier Greniebe9bae12011-01-04 05:42:19 -03002842}
2843
2844static int nim7090_tuner_attach(struct dvb_usb_adapter *adap)
2845{
2846 struct dib0700_adapter_state *st = adap->priv;
Michael Krufky77eed212011-09-06 09:31:57 -03002847 struct i2c_adapter *tun_i2c = dib7090_get_i2c_tuner(adap->fe_adap[0].fe);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002848
Michael Krufky77eed212011-09-06 09:31:57 -03002849 if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c, &nim7090_dib0090_config) == NULL)
Olivier Greniebe9bae12011-01-04 05:42:19 -03002850 return -ENODEV;
2851
Michael Krufky77eed212011-09-06 09:31:57 -03002852 dib7000p_set_gpio(adap->fe_adap[0].fe, 8, 0, 1);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002853
Michael Krufky77eed212011-09-06 09:31:57 -03002854 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
2855 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib7090_agc_startup;
Olivier Greniebe9bae12011-01-04 05:42:19 -03002856 return 0;
2857}
2858
2859static int tfe7090pvr_frontend0_attach(struct dvb_usb_adapter *adap)
2860{
2861 struct dib0700_state *st = adap->dev->priv;
2862
2863 /* The TFE7090 requires the dib0700 to not be in master mode */
2864 st->disable_streaming_master_mode = 1;
2865
2866 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002867 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002868 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
2869 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
2870 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
2871 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
2872
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002873 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002874 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002875 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002876 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
2877
2878 /* initialize IC 0 */
2879 if (dib7000p_i2c_enumeration(&adap->dev->i2c_adap, 1, 0x20, &tfe7090pvr_dib7000p_config[0]) != 0) {
2880 err("%s: dib7000p_i2c_enumeration failed. Cannot continue\n", __func__);
2881 return -ENODEV;
2882 }
2883
2884 dib0700_set_i2c_speed(adap->dev, 340);
Michael Krufky77eed212011-09-06 09:31:57 -03002885 adap->fe_adap[0].fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 0x90, &tfe7090pvr_dib7000p_config[0]);
2886 if (adap->fe_adap[0].fe == NULL)
Olivier Greniebe9bae12011-01-04 05:42:19 -03002887 return -ENODEV;
2888
Michael Krufky77eed212011-09-06 09:31:57 -03002889 dib7090_slave_reset(adap->fe_adap[0].fe);
Patrick Boettcher71682522011-04-03 12:44:25 -03002890
Olivier Greniebe9bae12011-01-04 05:42:19 -03002891 return 0;
2892}
2893
2894static int tfe7090pvr_frontend1_attach(struct dvb_usb_adapter *adap)
2895{
2896 struct i2c_adapter *i2c;
2897
Michael Krufky77eed212011-09-06 09:31:57 -03002898 if (adap->dev->adapter[0].fe_adap[0].fe == NULL) {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002899 err("the master dib7090 has to be initialized first");
2900 return -ENODEV; /* the master device has not been initialized */
2901 }
2902
Michael Krufky77eed212011-09-06 09:31:57 -03002903 i2c = dib7000p_get_i2c_master(adap->dev->adapter[0].fe_adap[0].fe, DIBX000_I2C_INTERFACE_GPIO_6_7, 1);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002904 if (dib7000p_i2c_enumeration(i2c, 1, 0x10, &tfe7090pvr_dib7000p_config[1]) != 0) {
2905 err("%s: dib7000p_i2c_enumeration failed. Cannot continue\n", __func__);
2906 return -ENODEV;
2907 }
2908
Michael Krufky77eed212011-09-06 09:31:57 -03002909 adap->fe_adap[0].fe = dvb_attach(dib7000p_attach, i2c, 0x92, &tfe7090pvr_dib7000p_config[1]);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002910 dib0700_set_i2c_speed(adap->dev, 200);
2911
Michael Krufky77eed212011-09-06 09:31:57 -03002912 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Olivier Greniebe9bae12011-01-04 05:42:19 -03002913}
2914
2915static int tfe7090pvr_tuner0_attach(struct dvb_usb_adapter *adap)
2916{
2917 struct dib0700_adapter_state *st = adap->priv;
Michael Krufky77eed212011-09-06 09:31:57 -03002918 struct i2c_adapter *tun_i2c = dib7090_get_i2c_tuner(adap->fe_adap[0].fe);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002919
Michael Krufky77eed212011-09-06 09:31:57 -03002920 if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c, &tfe7090pvr_dib0090_config[0]) == NULL)
Olivier Greniebe9bae12011-01-04 05:42:19 -03002921 return -ENODEV;
2922
Michael Krufky77eed212011-09-06 09:31:57 -03002923 dib7000p_set_gpio(adap->fe_adap[0].fe, 8, 0, 1);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002924
Michael Krufky77eed212011-09-06 09:31:57 -03002925 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
2926 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib7090_agc_startup;
Olivier Greniebe9bae12011-01-04 05:42:19 -03002927 return 0;
2928}
2929
2930static int tfe7090pvr_tuner1_attach(struct dvb_usb_adapter *adap)
2931{
2932 struct dib0700_adapter_state *st = adap->priv;
Michael Krufky77eed212011-09-06 09:31:57 -03002933 struct i2c_adapter *tun_i2c = dib7090_get_i2c_tuner(adap->fe_adap[0].fe);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002934
Michael Krufky77eed212011-09-06 09:31:57 -03002935 if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c, &tfe7090pvr_dib0090_config[1]) == NULL)
Olivier Greniebe9bae12011-01-04 05:42:19 -03002936 return -ENODEV;
2937
Michael Krufky77eed212011-09-06 09:31:57 -03002938 dib7000p_set_gpio(adap->fe_adap[0].fe, 8, 0, 1);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002939
Michael Krufky77eed212011-09-06 09:31:57 -03002940 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
2941 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib7090_agc_startup;
Olivier Greniebe9bae12011-01-04 05:42:19 -03002942 return 0;
2943}
2944
Olivier Grenie6724a2f2011-08-05 13:49:33 -03002945static int tfe7090e_frontend_attach(struct dvb_usb_adapter *adap)
2946{
2947 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
2948 msleep(20);
2949 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
2950 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
2951 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
2952 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
2953
2954 msleep(20);
2955 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
2956 msleep(20);
2957 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
2958
2959 if (dib7000p_i2c_enumeration(&adap->dev->i2c_adap,
2960 1, 0x10, &tfe7090e_dib7000p_config) != 0) {
2961 err("%s: dib7000p_i2c_enumeration failed. Cannot continue\n",
2962 __func__);
2963 return -ENODEV;
2964 }
2965 adap->fe_adap[0].fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap,
2966 0x80, &tfe7090e_dib7000p_config);
2967
2968 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
2969}
2970
Olivier Grenieb293f302011-08-09 04:48:25 -03002971static int tfe7790e_frontend_attach(struct dvb_usb_adapter *adap)
2972{
2973 struct dib0700_state *st = adap->dev->priv;
2974
2975 /* The TFE7790E requires the dib0700 to not be in master mode */
2976 st->disable_streaming_master_mode = 1;
2977
2978 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
2979 msleep(20);
2980 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
2981 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
2982 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
2983 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
2984 msleep(20);
2985 dib0700_ctrl_clock(adap->dev, 72, 1);
2986 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
2987 msleep(20);
2988 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
2989
2990 if (dib7000p_i2c_enumeration(&adap->dev->i2c_adap,
2991 1, 0x10, &tfe7790e_dib7000p_config) != 0) {
2992 err("%s: dib7000p_i2c_enumeration failed. Cannot continue\n",
2993 __func__);
2994 return -ENODEV;
2995 }
2996 adap->fe_adap[0].fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap,
2997 0x80, &tfe7790e_dib7000p_config);
2998
2999 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
3000}
3001
3002static int tfe7790e_tuner_attach(struct dvb_usb_adapter *adap)
3003{
3004 struct dib0700_adapter_state *st = adap->priv;
3005 struct i2c_adapter *tun_i2c =
3006 dib7090_get_i2c_tuner(adap->fe_adap[0].fe);
3007
3008 if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c,
3009 &tfe7790e_dib0090_config) == NULL)
3010 return -ENODEV;
3011
3012 dib7000p_set_gpio(adap->fe_adap[0].fe, 8, 0, 1);
3013
3014 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
3015 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib7090_agc_startup;
3016 return 0;
3017}
3018
Olivier Grenie6724a2f2011-08-05 13:49:33 -03003019static int tfe7090e_tuner_attach(struct dvb_usb_adapter *adap)
3020{
3021 struct dib0700_adapter_state *st = adap->priv;
3022 struct i2c_adapter *tun_i2c =
3023 dib7090_get_i2c_tuner(adap->fe_adap[0].fe);
3024
3025 if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c,
3026 &tfe7090e_dib0090_config) == NULL)
3027 return -ENODEV;
3028
3029 dib7000p_set_gpio(adap->fe_adap[0].fe, 8, 0, 1);
3030
3031 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
3032 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib7090_agc_startup;
3033 return 0;
3034}
3035
Patrick Boettcher01373a52007-07-30 12:49:04 -03003036/* STK7070PD */
3037static struct dib7000p_config stk7070pd_dib7000p_config[2] = {
3038 {
3039 .output_mpeg2_in_188_bytes = 1,
3040
3041 .agc_config_count = 1,
3042 .agc = &dib7070_agc_config,
3043 .bw = &dib7070_bw_config_12_mhz,
Patrick Boettcher3cb2c392008-01-25 07:25:20 -03003044 .tuner_is_baseband = 1,
3045 .spur_protect = 1,
Patrick Boettcher01373a52007-07-30 12:49:04 -03003046
3047 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
3048 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
3049 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
3050
3051 .hostbus_diversity = 1,
3052 }, {
3053 .output_mpeg2_in_188_bytes = 1,
3054
3055 .agc_config_count = 1,
3056 .agc = &dib7070_agc_config,
3057 .bw = &dib7070_bw_config_12_mhz,
Patrick Boettcher3cb2c392008-01-25 07:25:20 -03003058 .tuner_is_baseband = 1,
3059 .spur_protect = 1,
Patrick Boettcher01373a52007-07-30 12:49:04 -03003060
3061 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
3062 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
3063 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
3064
3065 .hostbus_diversity = 1,
3066 }
3067};
3068
Jiri Slaby52fd5b22012-01-10 14:11:23 -03003069static void stk7070pd_init(struct dvb_usb_device *dev)
3070{
3071 dib0700_set_gpio(dev, GPIO6, GPIO_OUT, 1);
3072 msleep(10);
3073 dib0700_set_gpio(dev, GPIO9, GPIO_OUT, 1);
3074 dib0700_set_gpio(dev, GPIO4, GPIO_OUT, 1);
3075 dib0700_set_gpio(dev, GPIO7, GPIO_OUT, 1);
3076 dib0700_set_gpio(dev, GPIO10, GPIO_OUT, 0);
3077
3078 dib0700_ctrl_clock(dev, 72, 1);
3079
3080 msleep(10);
3081 dib0700_set_gpio(dev, GPIO10, GPIO_OUT, 1);
3082}
3083
Patrick Boettcher01373a52007-07-30 12:49:04 -03003084static int stk7070pd_frontend_attach0(struct dvb_usb_adapter *adap)
3085{
Jiri Slaby52fd5b22012-01-10 14:11:23 -03003086 stk7070pd_init(adap->dev);
Patrick Boettcher01373a52007-07-30 12:49:04 -03003087
Patrick Boettcher01373a52007-07-30 12:49:04 -03003088 msleep(10);
3089 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
3090
Devin Heitmueller83c4fdf2009-01-21 01:55:45 -03003091 if (dib7000p_i2c_enumeration(&adap->dev->i2c_adap, 2, 18,
3092 stk7070pd_dib7000p_config) != 0) {
3093 err("%s: dib7000p_i2c_enumeration failed. Cannot continue\n",
3094 __func__);
3095 return -ENODEV;
3096 }
Patrick Boettcher01373a52007-07-30 12:49:04 -03003097
Michael Krufky77eed212011-09-06 09:31:57 -03003098 adap->fe_adap[0].fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 0x80, &stk7070pd_dib7000p_config[0]);
3099 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Patrick Boettcher01373a52007-07-30 12:49:04 -03003100}
3101
3102static int stk7070pd_frontend_attach1(struct dvb_usb_adapter *adap)
3103{
Michael Krufky77eed212011-09-06 09:31:57 -03003104 adap->fe_adap[0].fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 0x82, &stk7070pd_dib7000p_config[1]);
3105 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Patrick Boettcher01373a52007-07-30 12:49:04 -03003106}
3107
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03003108/* S5H1411 */
3109static struct s5h1411_config pinnacle_801e_config = {
3110 .output_mode = S5H1411_PARALLEL_OUTPUT,
3111 .gpio = S5H1411_GPIO_OFF,
3112 .mpeg_timing = S5H1411_MPEGTIMING_NONCONTINOUS_NONINVERTING_CLOCK,
3113 .qam_if = S5H1411_IF_44000,
3114 .vsb_if = S5H1411_IF_44000,
3115 .inversion = S5H1411_INVERSION_OFF,
3116 .status_mode = S5H1411_DEMODLOCKING
3117};
3118
3119/* Pinnacle PCTV HD Pro 801e GPIOs map:
3120 GPIO0 - currently unknown
3121 GPIO1 - xc5000 tuner reset
3122 GPIO2 - CX25843 sleep
3123 GPIO3 - currently unknown
3124 GPIO4 - currently unknown
3125 GPIO6 - currently unknown
3126 GPIO7 - currently unknown
3127 GPIO9 - currently unknown
3128 GPIO10 - CX25843 reset
3129 */
3130static int s5h1411_frontend_attach(struct dvb_usb_adapter *adap)
3131{
3132 struct dib0700_state *st = adap->dev->priv;
3133
3134 /* Make use of the new i2c functions from FW 1.20 */
3135 st->fw_use_new_i2c_api = 1;
3136
3137 /* The s5h1411 requires the dib0700 to not be in master mode */
3138 st->disable_streaming_master_mode = 1;
3139
3140 /* All msleep values taken from Windows USB trace */
3141 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 0);
3142 dib0700_set_gpio(adap->dev, GPIO3, GPIO_OUT, 0);
3143 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
3144 msleep(400);
3145 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
3146 msleep(60);
3147 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
3148 msleep(30);
3149 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
3150 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
3151 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
3152 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
3153 dib0700_set_gpio(adap->dev, GPIO2, GPIO_OUT, 0);
3154 msleep(30);
3155
3156 /* Put the CX25843 to sleep for now since we're in digital mode */
3157 dib0700_set_gpio(adap->dev, GPIO2, GPIO_OUT, 1);
3158
3159 /* GPIOs are initialized, do the attach */
Michael Krufky77eed212011-09-06 09:31:57 -03003160 adap->fe_adap[0].fe = dvb_attach(s5h1411_attach, &pinnacle_801e_config,
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03003161 &adap->dev->i2c_adap);
Michael Krufky77eed212011-09-06 09:31:57 -03003162 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03003163}
3164
Michael Krufky767f3b32008-09-25 09:47:07 -03003165static int dib0700_xc5000_tuner_callback(void *priv, int component,
3166 int command, int arg)
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03003167{
3168 struct dvb_usb_adapter *adap = priv;
3169
Devin Heitmueller79025a92008-10-06 12:07:48 -03003170 if (command == XC5000_TUNER_RESET) {
3171 /* Reset the tuner */
3172 dib0700_set_gpio(adap->dev, GPIO1, GPIO_OUT, 0);
Devin Heitmuellerf0f46332009-05-04 21:57:41 -03003173 msleep(10);
Devin Heitmueller79025a92008-10-06 12:07:48 -03003174 dib0700_set_gpio(adap->dev, GPIO1, GPIO_OUT, 1);
Devin Heitmuellerf0f46332009-05-04 21:57:41 -03003175 msleep(10);
Devin Heitmueller79025a92008-10-06 12:07:48 -03003176 } else {
3177 err("xc5000: unknown tuner callback command: %d\n", command);
3178 return -EINVAL;
3179 }
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03003180
3181 return 0;
3182}
3183
3184static struct xc5000_config s5h1411_xc5000_tunerconfig = {
3185 .i2c_address = 0x64,
3186 .if_khz = 5380,
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03003187};
3188
3189static int xc5000_tuner_attach(struct dvb_usb_adapter *adap)
3190{
Devin Heitmueller79025a92008-10-06 12:07:48 -03003191 /* FIXME: generalize & move to common area */
Michael Krufky77eed212011-09-06 09:31:57 -03003192 adap->fe_adap[0].fe->callback = dib0700_xc5000_tuner_callback;
Devin Heitmueller79025a92008-10-06 12:07:48 -03003193
Michael Krufky77eed212011-09-06 09:31:57 -03003194 return dvb_attach(xc5000_attach, adap->fe_adap[0].fe, &adap->dev->i2c_adap,
Michael Krufky767f3b32008-09-25 09:47:07 -03003195 &s5h1411_xc5000_tunerconfig)
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03003196 == NULL ? -ENODEV : 0;
3197}
3198
Davide Ferri8d009a02009-06-23 22:34:06 -03003199static int dib0700_xc4000_tuner_callback(void *priv, int component,
3200 int command, int arg)
3201{
3202 struct dvb_usb_adapter *adap = priv;
3203
3204 if (command == XC4000_TUNER_RESET) {
3205 /* Reset the tuner */
Michael Krufky77eed212011-09-06 09:31:57 -03003206 dib7000p_set_gpio(adap->fe_adap[0].fe, 8, 0, 0);
Davide Ferri8d009a02009-06-23 22:34:06 -03003207 msleep(10);
Michael Krufky77eed212011-09-06 09:31:57 -03003208 dib7000p_set_gpio(adap->fe_adap[0].fe, 8, 0, 1);
Davide Ferri8d009a02009-06-23 22:34:06 -03003209 } else {
3210 err("xc4000: unknown tuner callback command: %d\n", command);
3211 return -EINVAL;
3212 }
3213
3214 return 0;
3215}
3216
Devin Heitmueller8583fc82009-07-28 01:16:05 -03003217static struct dibx000_agc_config stk7700p_7000p_xc4000_agc_config = {
3218 .band_caps = BAND_UHF | BAND_VHF,
3219 .setup = 0x64,
3220 .inv_gain = 0x02c8,
3221 .time_stabiliz = 0x15,
3222 .alpha_level = 0x00,
3223 .thlock = 0x76,
3224 .wbd_inv = 0x01,
3225 .wbd_ref = 0x0b33,
3226 .wbd_sel = 0x00,
3227 .wbd_alpha = 0x02,
3228 .agc1_max = 0x00,
3229 .agc1_min = 0x00,
3230 .agc2_max = 0x9b26,
3231 .agc2_min = 0x26ca,
3232 .agc1_pt1 = 0x00,
3233 .agc1_pt2 = 0x00,
3234 .agc1_pt3 = 0x00,
3235 .agc1_slope1 = 0x00,
3236 .agc1_slope2 = 0x00,
3237 .agc2_pt1 = 0x00,
3238 .agc2_pt2 = 0x80,
3239 .agc2_slope1 = 0x1d,
3240 .agc2_slope2 = 0x1d,
Devin Heitmueller2df12512009-12-27 17:44:31 -03003241 .alpha_mant = 0x11,
Devin Heitmueller8583fc82009-07-28 01:16:05 -03003242 .alpha_exp = 0x1b,
3243 .beta_mant = 0x17,
3244 .beta_exp = 0x33,
3245 .perform_agc_softsplit = 0x00,
3246};
3247
Devin Heitmuellerf1c78d32009-10-05 00:34:04 -03003248static struct dibx000_bandwidth_config stk7700p_xc4000_pll_config = {
istvan_v@mailbox.hu341747b2011-06-06 12:54:54 -03003249 60000, 30000, /* internal, sampling */
3250 1, 8, 3, 1, 0, /* pll_cfg: prediv, ratio, range, reset, bypass */
3251 0, 0, 1, 1, 0, /* misc: refdiv, bypclk_div, IO_CLK_en_core, */
3252 /* ADClkSrc, modulo */
3253 (3 << 14) | (1 << 12) | 524, /* sad_cfg: refsel, sel, freq_15k */
3254 39370534, /* ifreq */
3255 20452225, /* timf */
3256 30000000 /* xtal */
Devin Heitmuellerf1c78d32009-10-05 00:34:04 -03003257};
3258
Devin Heitmueller01f16262009-06-24 00:07:01 -03003259/* FIXME: none of these inputs are validated yet */
3260static struct dib7000p_config pctv_340e_config = {
Devin Heitmueller62956ce2009-12-27 18:58:11 -03003261 .output_mpeg2_in_188_bytes = 1,
Devin Heitmueller01f16262009-06-24 00:07:01 -03003262
3263 .agc_config_count = 1,
Devin Heitmueller8583fc82009-07-28 01:16:05 -03003264 .agc = &stk7700p_7000p_xc4000_agc_config,
Devin Heitmuellerf1c78d32009-10-05 00:34:04 -03003265 .bw = &stk7700p_xc4000_pll_config,
Devin Heitmueller01f16262009-06-24 00:07:01 -03003266
Devin Heitmueller01f16262009-06-24 00:07:01 -03003267 .gpio_dir = DIB7000M_GPIO_DEFAULT_DIRECTIONS,
3268 .gpio_val = DIB7000M_GPIO_DEFAULT_VALUES,
3269 .gpio_pwm_pos = DIB7000M_GPIO_DEFAULT_PWM_POS,
3270};
3271
3272/* PCTV 340e GPIOs map:
3273 dib0700:
3274 GPIO2 - CX25843 sleep
3275 GPIO3 - CS5340 reset
3276 GPIO5 - IRD
3277 GPIO6 - Power Supply
3278 GPIO8 - LNA (1=off 0=on)
3279 GPIO10 - CX25843 reset
3280 dib7000:
3281 GPIO8 - xc4000 reset
3282 */
3283static int pctv340e_frontend_attach(struct dvb_usb_adapter *adap)
3284{
3285 struct dib0700_state *st = adap->dev->priv;
3286
3287 /* Power Supply on */
3288 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
3289 msleep(50);
3290 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
3291 msleep(100); /* Allow power supply to settle before probing */
3292
3293 /* cx25843 reset */
3294 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
3295 msleep(1); /* cx25843 datasheet say 350us required */
3296 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
3297
3298 /* LNA off for now */
3299 dib0700_set_gpio(adap->dev, GPIO8, GPIO_OUT, 1);
3300
3301 /* Put the CX25843 to sleep for now since we're in digital mode */
3302 dib0700_set_gpio(adap->dev, GPIO2, GPIO_OUT, 1);
3303
3304 /* FIXME: not verified yet */
3305 dib0700_ctrl_clock(adap->dev, 72, 1);
3306
Devin Heitmueller2750d9c2009-07-20 00:42:33 -03003307 msleep(500);
3308
Devin Heitmueller01f16262009-06-24 00:07:01 -03003309 if (dib7000pc_detection(&adap->dev->i2c_adap) == 0) {
3310 /* Demodulator not found for some reason? */
3311 return -ENODEV;
3312 }
3313
Michael Krufky77eed212011-09-06 09:31:57 -03003314 adap->fe_adap[0].fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 0x12,
Devin Heitmueller01f16262009-06-24 00:07:01 -03003315 &pctv_340e_config);
3316 st->is_dib7000pc = 1;
3317
Michael Krufky77eed212011-09-06 09:31:57 -03003318 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Devin Heitmueller01f16262009-06-24 00:07:01 -03003319}
3320
Devin Heitmueller8583fc82009-07-28 01:16:05 -03003321static struct xc4000_config dib7000p_xc4000_tunerconfig = {
istvan_v@mailbox.hu8edeb6e2011-06-06 13:03:44 -03003322 .i2c_address = 0x61,
3323 .default_pm = 1,
3324 .dvb_amplitude = 0,
3325 .set_smoothedcvbs = 0,
3326 .if_khz = 5400
Davide Ferri8d009a02009-06-23 22:34:06 -03003327};
3328
3329static int xc4000_tuner_attach(struct dvb_usb_adapter *adap)
3330{
Devin Heitmueller59d0c372009-06-29 21:11:02 -03003331 struct i2c_adapter *tun_i2c;
3332
3333 /* The xc4000 is not on the main i2c bus */
Michael Krufky77eed212011-09-06 09:31:57 -03003334 tun_i2c = dib7000p_get_i2c_master(adap->fe_adap[0].fe,
Devin Heitmueller59d0c372009-06-29 21:11:02 -03003335 DIBX000_I2C_INTERFACE_TUNER, 1);
3336 if (tun_i2c == NULL) {
Mauro Carvalho Chehab941830c2011-06-06 16:51:11 -03003337 printk(KERN_ERR "Could not reach tuner i2c bus\n");
Devin Heitmueller59d0c372009-06-29 21:11:02 -03003338 return 0;
3339 }
3340
3341 /* Setup the reset callback */
Michael Krufky77eed212011-09-06 09:31:57 -03003342 adap->fe_adap[0].fe->callback = dib0700_xc4000_tuner_callback;
Davide Ferri8d009a02009-06-23 22:34:06 -03003343
Michael Krufky77eed212011-09-06 09:31:57 -03003344 return dvb_attach(xc4000_attach, adap->fe_adap[0].fe, tun_i2c,
Devin Heitmueller8583fc82009-07-28 01:16:05 -03003345 &dib7000p_xc4000_tunerconfig)
Davide Ferri8d009a02009-06-23 22:34:06 -03003346 == NULL ? -ENODEV : 0;
3347}
3348
Michael Krufkyce904bc2009-01-19 01:12:55 -03003349static struct lgdt3305_config hcw_lgdt3305_config = {
3350 .i2c_addr = 0x0e,
3351 .mpeg_mode = LGDT3305_MPEG_PARALLEL,
3352 .tpclk_edge = LGDT3305_TPCLK_FALLING_EDGE,
3353 .tpvalid_polarity = LGDT3305_TP_VALID_LOW,
3354 .deny_i2c_rptr = 0,
3355 .spectral_inversion = 1,
3356 .qam_if_khz = 6000,
3357 .vsb_if_khz = 6000,
3358 .usref_8vsb = 0x0500,
3359};
3360
3361static struct mxl5007t_config hcw_mxl5007t_config = {
3362 .xtal_freq_hz = MxL_XTAL_25_MHZ,
3363 .if_freq_hz = MxL_IF_6_MHZ,
3364 .invert_if = 1,
3365};
3366
3367/* TIGER-ATSC map:
3368 GPIO0 - LNA_CTR (H: LNA power enabled, L: LNA power disabled)
3369 GPIO1 - ANT_SEL (H: VPA, L: MCX)
3370 GPIO4 - SCL2
3371 GPIO6 - EN_TUNER
3372 GPIO7 - SDA2
3373 GPIO10 - DEM_RST
3374
3375 MXL is behind LG's i2c repeater. LG is on SCL2/SDA2 gpios on the DIB
3376 */
3377static int lgdt3305_frontend_attach(struct dvb_usb_adapter *adap)
3378{
3379 struct dib0700_state *st = adap->dev->priv;
3380
3381 /* Make use of the new i2c functions from FW 1.20 */
3382 st->fw_use_new_i2c_api = 1;
3383
3384 st->disable_streaming_master_mode = 1;
3385
3386 /* fe power enable */
3387 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
3388 msleep(30);
3389 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
3390 msleep(30);
3391
3392 /* demod reset */
3393 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
3394 msleep(30);
3395 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
3396 msleep(30);
3397 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
3398 msleep(30);
3399
Michael Krufky77eed212011-09-06 09:31:57 -03003400 adap->fe_adap[0].fe = dvb_attach(lgdt3305_attach,
Michael Krufkyce904bc2009-01-19 01:12:55 -03003401 &hcw_lgdt3305_config,
3402 &adap->dev->i2c_adap);
3403
Michael Krufky77eed212011-09-06 09:31:57 -03003404 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Michael Krufkyce904bc2009-01-19 01:12:55 -03003405}
3406
3407static int mxl5007t_tuner_attach(struct dvb_usb_adapter *adap)
3408{
Michael Krufky77eed212011-09-06 09:31:57 -03003409 return dvb_attach(mxl5007t_attach, adap->fe_adap[0].fe,
Michael Krufkyce904bc2009-01-19 01:12:55 -03003410 &adap->dev->i2c_adap, 0x60,
3411 &hcw_mxl5007t_config) == NULL ? -ENODEV : 0;
3412}
3413
3414
Patrick Boettcher01373a52007-07-30 12:49:04 -03003415/* DVB-USB and USB stuff follows */
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003416struct usb_device_id dib0700_usb_id_table[] = {
Patrick Boettcher01373a52007-07-30 12:49:04 -03003417/* 0 */ { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7700P) },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03003418 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7700P_PC) },
3419 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_500) },
3420 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_500_2) },
3421 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_STICK) },
Patrick Boettcher01373a52007-07-30 12:49:04 -03003422/* 5 */ { USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR) },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03003423 { USB_DEVICE(USB_VID_COMPRO, USB_PID_COMPRO_VIDEOMATE_U500) },
3424 { USB_DEVICE(USB_VID_UNIWILL, USB_PID_UNIWILL_STK7700P) },
3425 { USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV_DONGLE_STK7700P) },
3426 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_STICK_2) },
Patrick Boettcher01373a52007-07-30 12:49:04 -03003427/* 10 */{ USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR_2) },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03003428 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV2000E) },
3429 { USB_DEVICE(USB_VID_TERRATEC,
3430 USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY) },
3431 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_TD_STICK) },
3432 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7700D) },
Patrick Boettcher01373a52007-07-30 12:49:04 -03003433/* 15 */{ USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7070P) },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03003434 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV_DVB_T_FLASH) },
3435 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7070PD) },
3436 { USB_DEVICE(USB_VID_PINNACLE,
3437 USB_PID_PINNACLE_PCTV_DUAL_DIVERSITY_DVB_T) },
3438 { USB_DEVICE(USB_VID_COMPRO, USB_PID_COMPRO_VIDEOMATE_U500_PC) },
Joachim Steigerfa3b8772007-10-08 20:08:46 -03003439/* 20 */{ USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_EXPRESS) },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03003440 { USB_DEVICE(USB_VID_GIGABYTE, USB_PID_GIGABYTE_U7000) },
3441 { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC, USB_PID_ARTEC_T14BR) },
3442 { USB_DEVICE(USB_VID_ASUS, USB_PID_ASUS_U3000) },
3443 { USB_DEVICE(USB_VID_ASUS, USB_PID_ASUS_U3100) },
3444/* 25 */{ USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_STICK_3) },
3445 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_MYTV_T) },
3446 { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_HT_USB_XE) },
3447 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_EXPRESSCARD_320CX) },
3448 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV72E) },
3449/* 30 */{ USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV73E) },
3450 { USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_EC372S) },
3451 { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_HT_EXPRESS) },
Alexander Simondc888072008-03-29 21:37:54 -03003452 { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_XXS) },
Darryl Green5da4e2c2008-03-29 21:47:43 -03003453 { USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV_DONGLE_STK7700P_2) },
Michael Krufkyaf2a8872008-09-03 17:12:24 -03003454/* 35 */{ USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_TD_STICK_52009) },
Michael Krufky9a0c04a2008-09-03 17:12:24 -03003455 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_500_3) },
Finn Thain17a370b2008-09-06 13:42:47 -03003456 { USB_DEVICE(USB_VID_GIGABYTE, USB_PID_GIGABYTE_U8000) },
Daniel Oliveira Nascimento8751aaa2008-09-07 12:39:44 -03003457 { USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_STK7700PH) },
Albert Comerma57697432008-09-07 12:43:33 -03003458 { USB_DEVICE(USB_VID_ASUS, USB_PID_ASUS_U3000H) },
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03003459/* 40 */{ USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV801E) },
Devin Heitmuellerd2fc3bf2008-09-25 06:22:23 -03003460 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV801E_SE) },
Yusuf Altinbb1b0822009-01-08 07:58:45 -03003461 { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_EXPRESS) },
Nicolas Fournierdb4b2d12009-01-13 07:15:25 -03003462 { USB_DEVICE(USB_VID_TERRATEC,
3463 USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY_2) },
sebastian.blanes@gmail.com0a6e1ed2009-02-24 14:51:43 -03003464 { USB_DEVICE(USB_VID_SONY, USB_PID_SONY_PLAYTV) },
Pascal Terjan9abb6e62009-02-26 10:31:41 -03003465/* 45 */{ USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_PD378S) },
Michael Krufkyce904bc2009-01-19 01:12:55 -03003466 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_TIGER_ATSC) },
3467 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_TIGER_ATSC_B210) },
Xoan Loureiro16ba1ee2009-03-29 08:43:36 -03003468 { USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_MC770) },
Klaus Flittner919a5482009-03-29 09:12:06 -03003469 { USB_DEVICE(USB_VID_ELGATO, USB_PID_ELGATO_EYETV_DTT) },
Armin Schenker513846e2009-04-20 11:57:49 -03003470/* 50 */{ USB_DEVICE(USB_VID_ELGATO, USB_PID_ELGATO_EYETV_DTT_Dlx) },
tomas petrf0f4ae72009-05-20 05:28:05 -03003471 { USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV_DONGLE_H) },
Patrick Boettchera9b8fe32009-05-20 05:35:02 -03003472 { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_T3) },
3473 { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_T5) },
Pete Hildebrandtc53d83c2009-08-05 11:46:38 -03003474 { USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_STK7700D) },
Olivier Grenie74b76f22009-09-02 08:19:19 -03003475/* 55 */{ USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_STK7700D_2) },
3476 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV73A) },
Patrick Boettchere4147532009-11-30 13:52:57 -03003477 { USB_DEVICE(USB_VID_PCTV, USB_PID_PINNACLE_PCTV73ESE) },
3478 { USB_DEVICE(USB_VID_PCTV, USB_PID_PINNACLE_PCTV282E) },
Olivier Grenied300bd62009-09-15 06:55:35 -03003479 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7770P) },
Patrick Boettcherdb481382009-09-15 07:16:51 -03003480/* 60 */{ USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_XXS_2) },
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03003481 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK807XPVR) },
3482 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK807XP) },
Mauro Carvalho Chehab3bfb3172010-09-03 10:50:24 -03003483 { USB_DEVICE_VER(USB_VID_PIXELVIEW, USB_PID_PIXELVIEW_SBTVD, 0x000, 0x3f00) },
S?rgio Fortier8a378e82009-09-28 04:19:21 -03003484 { USB_DEVICE(USB_VID_EVOLUTEPC, USB_PID_TVWAY_PLUS) },
Patrick Boettcher20232c42009-12-01 12:08:56 -03003485/* 65 */{ USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV73ESE) },
Patrick Boettchere4147532009-11-30 13:52:57 -03003486 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV282E) },
Olivier Grenie03245a52009-12-04 13:27:57 -03003487 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK8096GP) },
Michael Müller84e2f032010-04-26 22:18:57 -03003488 { USB_DEVICE(USB_VID_ELGATO, USB_PID_ELGATO_EYETV_DIVERSITY) },
Olivier Greniebe9bae12011-01-04 05:42:19 -03003489 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_NIM9090M) },
3490/* 70 */{ USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_NIM8096MD) },
3491 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_NIM9090MD) },
3492 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_NIM7090) },
3493 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_TFE7090PVR) },
Lukas Max Fisch498e6772011-02-08 16:51:45 -03003494 { USB_DEVICE(USB_VID_TECHNISAT, USB_PID_TECHNISAT_AIRSTAR_TELESTICK_2) },
Stéphane Elmalehd1402302011-05-21 07:33:38 -03003495/* 75 */{ USB_DEVICE(USB_VID_MEDION, USB_PID_CREATIX_CTX1921) },
Davide Ferri8d009a02009-06-23 22:34:06 -03003496 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV340E) },
Devin Heitmueller33fb1682009-06-23 22:48:02 -03003497 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV340E_SE) },
Olivier Grenie6724a2f2011-08-05 13:49:33 -03003498 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_TFE7090E) },
Olivier Grenieb293f302011-08-09 04:48:25 -03003499 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_TFE7790E) },
Olivier Grenie88f3a352011-08-10 05:28:38 -03003500/* 80 */{ USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_TFE8096P) },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03003501 { 0 } /* Terminating entry */
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003502};
3503MODULE_DEVICE_TABLE(usb, dib0700_usb_id_table);
3504
3505#define DIB0700_DEFAULT_DEVICE_PROPERTIES \
3506 .caps = DVB_USB_IS_AN_I2C_ADAPTER, \
3507 .usb_ctrl = DEVICE_SPECIFIC, \
Devin Heitmuellerbdc203e2008-09-06 13:45:27 -03003508 .firmware = "dvb-usb-dib0700-1.20.fw", \
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003509 .download_firmware = dib0700_download_firmware, \
Patrick Boettcher6958eff2006-09-19 12:51:40 -03003510 .no_reconnect = 1, \
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003511 .size_of_priv = sizeof(struct dib0700_state), \
Patrick Boettcher6958eff2006-09-19 12:51:40 -03003512 .i2c_algo = &dib0700_i2c_algo, \
3513 .identify_state = dib0700_identify_state
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003514
3515#define DIB0700_DEFAULT_STREAMING_CONFIG(ep) \
3516 .streaming_ctrl = dib0700_streaming_ctrl, \
3517 .stream = { \
3518 .type = USB_BULK, \
3519 .count = 4, \
3520 .endpoint = ep, \
3521 .u = { \
3522 .bulk = { \
3523 .buffersize = 39480, \
3524 } \
3525 } \
3526 }
3527
3528struct dvb_usb_device_properties dib0700_devices[] = {
3529 {
3530 DIB0700_DEFAULT_DEVICE_PROPERTIES,
3531
3532 .num_adapters = 1,
3533 .adapter = {
3534 {
Michael Krufky77eed212011-09-06 09:31:57 -03003535 .num_frontends = 1,
3536 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03003537 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
3538 .pid_filter_count = 32,
Olivier Greniee192a7c2011-01-14 13:58:59 -03003539 .pid_filter = stk7700p_pid_filter,
3540 .pid_filter_ctrl = stk7700p_pid_filter_ctrl,
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003541 .frontend_attach = stk7700p_frontend_attach,
3542 .tuner_attach = stk7700p_tuner_attach,
3543
3544 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03003545 }},
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003546 },
3547 },
3548
dominik67053a42007-11-10 19:23:31 -03003549 .num_device_descs = 8,
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003550 .devices = {
3551 { "DiBcom STK7700P reference design",
Tomi Koivulahti49a13762006-10-19 07:27:19 -03003552 { &dib0700_usb_id_table[0], &dib0700_usb_id_table[1] },
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003553 { NULL },
3554 },
3555 { "Hauppauge Nova-T Stick",
Stefan Trabyf9aeba42006-11-12 13:02:51 -03003556 { &dib0700_usb_id_table[4], &dib0700_usb_id_table[9], NULL },
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003557 { NULL },
3558 },
Tomi Koivulahti49a13762006-10-19 07:27:19 -03003559 { "AVerMedia AVerTV DVB-T Volar",
Jose Carlos Garcia Sogoced8fec2006-11-14 05:01:47 -03003560 { &dib0700_usb_id_table[5], &dib0700_usb_id_table[10] },
Tomi Koivulahti49a13762006-10-19 07:27:19 -03003561 { NULL },
3562 },
3563 { "Compro Videomate U500",
Patrick Boettcher1f8ca4b2007-07-30 14:24:37 -03003564 { &dib0700_usb_id_table[6], &dib0700_usb_id_table[19] },
Tomi Koivulahti49a13762006-10-19 07:27:19 -03003565 { NULL },
Henning Schroeer0ce215e2006-10-19 07:58:22 -03003566 },
3567 { "Uniwill STK7700P based (Hama and others)",
3568 { &dib0700_usb_id_table[7], NULL },
3569 { NULL },
Michael Krufky8637a872006-11-08 16:47:32 -03003570 },
3571 { "Leadtek Winfast DTV Dongle (STK7700P based)",
Patrick Boettcher1e13c8f2009-09-19 05:24:40 -03003572 { &dib0700_usb_id_table[8], &dib0700_usb_id_table[34] },
Michael Krufky8637a872006-11-08 16:47:32 -03003573 { NULL },
Joachim Steigerfa3b8772007-10-08 20:08:46 -03003574 },
3575 { "AVerMedia AVerTV DVB-T Express",
3576 { &dib0700_usb_id_table[20] },
3577 { NULL },
dominik67053a42007-11-10 19:23:31 -03003578 },
dominik67053a42007-11-10 19:23:31 -03003579 { "Gigabyte U7000",
3580 { &dib0700_usb_id_table[21], NULL },
3581 { NULL },
Tomi Koivulahti49a13762006-10-19 07:27:19 -03003582 }
Darren Saltb1139e32007-08-18 18:05:31 -03003583 },
3584
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03003585 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03003586 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03003587 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03003588 .rc_query = dib0700_rc_query_old_firmware,
Mauro Carvalho Chehab52b66142010-11-17 14:20:52 -03003589 .allowed_protos = RC_TYPE_RC5 |
3590 RC_TYPE_RC6 |
3591 RC_TYPE_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03003592 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03003593 },
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003594 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
3595
3596 .num_adapters = 2,
3597 .adapter = {
3598 {
Michael Krufky77eed212011-09-06 09:31:57 -03003599 .num_frontends = 1,
3600 .fe = {{
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003601 .frontend_attach = bristol_frontend_attach,
3602 .tuner_attach = bristol_tuner_attach,
3603
3604 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03003605 }},
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003606 }, {
Michael Krufky77eed212011-09-06 09:31:57 -03003607 .num_frontends = 1,
3608 .fe = {{
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003609 .frontend_attach = bristol_frontend_attach,
3610 .tuner_attach = bristol_tuner_attach,
3611
3612 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
Michael Krufky77eed212011-09-06 09:31:57 -03003613 }},
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003614 }
3615 },
3616
3617 .num_device_descs = 1,
3618 .devices = {
3619 { "Hauppauge Nova-T 500 Dual DVB-T",
Tomi Koivulahti49a13762006-10-19 07:27:19 -03003620 { &dib0700_usb_id_table[2], &dib0700_usb_id_table[3], NULL },
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003621 { NULL },
3622 },
Janne Grunau82f3d552007-07-30 13:50:28 -03003623 },
3624
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03003625 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03003626 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03003627 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03003628 .rc_query = dib0700_rc_query_old_firmware,
Mauro Carvalho Chehab52b66142010-11-17 14:20:52 -03003629 .allowed_protos = RC_TYPE_RC5 |
3630 RC_TYPE_RC6 |
3631 RC_TYPE_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03003632 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03003633 },
Olivier DANET54d75eb2007-07-25 14:42:54 -03003634 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
3635
3636 .num_adapters = 2,
3637 .adapter = {
3638 {
Michael Krufky77eed212011-09-06 09:31:57 -03003639 .num_frontends = 1,
3640 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03003641 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
3642 .pid_filter_count = 32,
3643 .pid_filter = stk70x0p_pid_filter,
3644 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
Olivier DANET54d75eb2007-07-25 14:42:54 -03003645 .frontend_attach = stk7700d_frontend_attach,
3646 .tuner_attach = stk7700d_tuner_attach,
3647
3648 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03003649 }},
Olivier DANET54d75eb2007-07-25 14:42:54 -03003650 }, {
Michael Krufky77eed212011-09-06 09:31:57 -03003651 .num_frontends = 1,
3652 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03003653 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
3654 .pid_filter_count = 32,
3655 .pid_filter = stk70x0p_pid_filter,
3656 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
Olivier DANET54d75eb2007-07-25 14:42:54 -03003657 .frontend_attach = stk7700d_frontend_attach,
3658 .tuner_attach = stk7700d_tuner_attach,
3659
3660 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
Michael Krufky77eed212011-09-06 09:31:57 -03003661 }},
Olivier DANET54d75eb2007-07-25 14:42:54 -03003662 }
3663 },
3664
James A Webb200e8612009-08-04 02:38:05 -03003665 .num_device_descs = 5,
Olivier DANET54d75eb2007-07-25 14:42:54 -03003666 .devices = {
3667 { "Pinnacle PCTV 2000e",
3668 { &dib0700_usb_id_table[11], NULL },
3669 { NULL },
3670 },
3671 { "Terratec Cinergy DT XS Diversity",
3672 { &dib0700_usb_id_table[12], NULL },
3673 { NULL },
3674 },
Darren Saltfaebb912007-08-18 18:04:00 -03003675 { "Hauppauge Nova-TD Stick/Elgato Eye-TV Diversity",
Olivier DANET54d75eb2007-07-25 14:42:54 -03003676 { &dib0700_usb_id_table[13], NULL },
3677 { NULL },
3678 },
Patrick Boettcher01373a52007-07-30 12:49:04 -03003679 { "DiBcom STK7700D reference design",
Patrick Boettcherb6884a12007-07-27 10:08:51 -03003680 { &dib0700_usb_id_table[14], NULL },
3681 { NULL },
Yusuf Altinbb1b0822009-01-08 07:58:45 -03003682 },
James A Webb200e8612009-08-04 02:38:05 -03003683 { "YUAN High-Tech DiBcom STK7700D",
3684 { &dib0700_usb_id_table[55], NULL },
3685 { NULL },
3686 },
Yusuf Altinbb1b0822009-01-08 07:58:45 -03003687
Olivier DANET54d75eb2007-07-25 14:42:54 -03003688 },
Janne Grunau82f3d552007-07-30 13:50:28 -03003689
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03003690 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03003691 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03003692 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03003693 .rc_query = dib0700_rc_query_old_firmware,
Mauro Carvalho Chehab52b66142010-11-17 14:20:52 -03003694 .allowed_protos = RC_TYPE_RC5 |
3695 RC_TYPE_RC6 |
3696 RC_TYPE_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03003697 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03003698 },
Patrick Boettcher01373a52007-07-30 12:49:04 -03003699 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
3700
3701 .num_adapters = 1,
3702 .adapter = {
3703 {
Michael Krufky77eed212011-09-06 09:31:57 -03003704 .num_frontends = 1,
3705 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03003706 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
3707 .pid_filter_count = 32,
3708 .pid_filter = stk70x0p_pid_filter,
3709 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
Daniel Gimpelevich132c3182008-01-25 06:02:42 -03003710 .frontend_attach = stk7700P2_frontend_attach,
3711 .tuner_attach = stk7700d_tuner_attach,
3712
3713 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03003714 }},
Daniel Gimpelevich132c3182008-01-25 06:02:42 -03003715 },
3716 },
3717
Yusuf Altinbb1b0822009-01-08 07:58:45 -03003718 .num_device_descs = 3,
Daniel Gimpelevich132c3182008-01-25 06:02:42 -03003719 .devices = {
3720 { "ASUS My Cinema U3000 Mini DVBT Tuner",
3721 { &dib0700_usb_id_table[23], NULL },
3722 { NULL },
3723 },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03003724 { "Yuan EC372S",
3725 { &dib0700_usb_id_table[31], NULL },
3726 { NULL },
Yusuf Altinbb1b0822009-01-08 07:58:45 -03003727 },
3728 { "Terratec Cinergy T Express",
3729 { &dib0700_usb_id_table[42], NULL },
3730 { NULL },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03003731 }
Chris Rankin48aa7392008-09-25 06:52:24 -03003732 },
3733
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03003734 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03003735 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03003736 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03003737 .module_name = "dib0700",
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03003738 .rc_query = dib0700_rc_query_old_firmware,
Mauro Carvalho Chehab52b66142010-11-17 14:20:52 -03003739 .allowed_protos = RC_TYPE_RC5 |
3740 RC_TYPE_RC6 |
3741 RC_TYPE_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03003742 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03003743 },
Daniel Gimpelevich132c3182008-01-25 06:02:42 -03003744 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
3745
3746 .num_adapters = 1,
3747 .adapter = {
3748 {
Michael Krufky77eed212011-09-06 09:31:57 -03003749 .num_frontends = 1,
3750 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03003751 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
3752 .pid_filter_count = 32,
3753 .pid_filter = stk70x0p_pid_filter,
3754 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
Patrick Boettcher01373a52007-07-30 12:49:04 -03003755 .frontend_attach = stk7070p_frontend_attach,
3756 .tuner_attach = dib7070p_tuner_attach,
3757
3758 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03003759 }},
Patrick Boettcher01373a52007-07-30 12:49:04 -03003760 .size_of_priv = sizeof(struct dib0700_adapter_state),
3761 },
3762 },
3763
Patrick Boettcher1e13c8f2009-09-19 05:24:40 -03003764 .num_device_descs = 11,
Patrick Boettcher01373a52007-07-30 12:49:04 -03003765 .devices = {
3766 { "DiBcom STK7070P reference design",
3767 { &dib0700_usb_id_table[15], NULL },
3768 { NULL },
3769 },
3770 { "Pinnacle PCTV DVB-T Flash Stick",
3771 { &dib0700_usb_id_table[16], NULL },
3772 { NULL },
3773 },
Yousef Lamlum7999a812008-01-25 05:51:48 -03003774 { "Artec T14BR DVB-T",
3775 { &dib0700_usb_id_table[22], NULL },
3776 { NULL },
Daniel Gimpelevich132c3182008-01-25 06:02:42 -03003777 },
3778 { "ASUS My Cinema U3100 Mini DVBT Tuner",
3779 { &dib0700_usb_id_table[24], NULL },
3780 { NULL },
3781 },
Tim Taubertc7637b12008-01-25 06:16:36 -03003782 { "Hauppauge Nova-T Stick",
3783 { &dib0700_usb_id_table[25], NULL },
3784 { NULL },
3785 },
Darren Salt13b83b52008-01-25 06:20:02 -03003786 { "Hauppauge Nova-T MyTV.t",
3787 { &dib0700_usb_id_table[26], NULL },
3788 { NULL },
3789 },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03003790 { "Pinnacle PCTV 72e",
3791 { &dib0700_usb_id_table[29], NULL },
3792 { NULL },
3793 },
3794 { "Pinnacle PCTV 73e",
3795 { &dib0700_usb_id_table[30], NULL },
3796 { NULL },
3797 },
Klaus Flittner919a5482009-03-29 09:12:06 -03003798 { "Elgato EyeTV DTT",
3799 { &dib0700_usb_id_table[49], NULL },
3800 { NULL },
3801 },
Pascal Terjan9abb6e62009-02-26 10:31:41 -03003802 { "Yuan PD378S",
3803 { &dib0700_usb_id_table[45], NULL },
3804 { NULL },
3805 },
Armin Schenker513846e2009-04-20 11:57:49 -03003806 { "Elgato EyeTV Dtt Dlx PD378S",
3807 { &dib0700_usb_id_table[50], NULL },
3808 { NULL },
3809 },
Tim Taubertc7637b12008-01-25 06:16:36 -03003810 },
3811
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03003812 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03003813 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03003814 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03003815 .module_name = "dib0700",
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03003816 .rc_query = dib0700_rc_query_old_firmware,
Mauro Carvalho Chehab52b66142010-11-17 14:20:52 -03003817 .allowed_protos = RC_TYPE_RC5 |
3818 RC_TYPE_RC6 |
3819 RC_TYPE_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03003820 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03003821 },
Patrick Boettcher01373a52007-07-30 12:49:04 -03003822 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
3823
Olivier Grenie74b76f22009-09-02 08:19:19 -03003824 .num_adapters = 1,
3825 .adapter = {
3826 {
Michael Krufky77eed212011-09-06 09:31:57 -03003827 .num_frontends = 1,
3828 .fe = {{
Mauro Carvalho Chehab648732f2009-11-04 12:11:43 -02003829 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
3830 .pid_filter_count = 32,
3831 .pid_filter = stk70x0p_pid_filter,
3832 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
Olivier Grenie74b76f22009-09-02 08:19:19 -03003833 .frontend_attach = stk7070p_frontend_attach,
3834 .tuner_attach = dib7070p_tuner_attach,
3835
3836 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03003837 }},
Olivier Grenie74b76f22009-09-02 08:19:19 -03003838 .size_of_priv = sizeof(struct dib0700_adapter_state),
3839 },
3840 },
3841
Patrick Boettcher20232c42009-12-01 12:08:56 -03003842 .num_device_descs = 3,
Olivier Grenie74b76f22009-09-02 08:19:19 -03003843 .devices = {
3844 { "Pinnacle PCTV 73A",
3845 { &dib0700_usb_id_table[56], NULL },
3846 { NULL },
3847 },
3848 { "Pinnacle PCTV 73e SE",
Patrick Boettcher20232c42009-12-01 12:08:56 -03003849 { &dib0700_usb_id_table[57], &dib0700_usb_id_table[65], NULL },
Olivier Grenie74b76f22009-09-02 08:19:19 -03003850 { NULL },
3851 },
3852 { "Pinnacle PCTV 282e",
Patrick Boettcher20232c42009-12-01 12:08:56 -03003853 { &dib0700_usb_id_table[58], &dib0700_usb_id_table[66], NULL },
Olivier Grenie74b76f22009-09-02 08:19:19 -03003854 { NULL },
3855 },
3856 },
3857
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03003858 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03003859 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03003860 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03003861 .module_name = "dib0700",
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03003862 .rc_query = dib0700_rc_query_old_firmware,
Mauro Carvalho Chehab52b66142010-11-17 14:20:52 -03003863 .allowed_protos = RC_TYPE_RC5 |
3864 RC_TYPE_RC6 |
3865 RC_TYPE_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03003866 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03003867 },
Olivier Grenie74b76f22009-09-02 08:19:19 -03003868 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
3869
Patrick Boettcher01373a52007-07-30 12:49:04 -03003870 .num_adapters = 2,
3871 .adapter = {
3872 {
Michael Krufky77eed212011-09-06 09:31:57 -03003873 .num_frontends = 1,
3874 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03003875 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
3876 .pid_filter_count = 32,
3877 .pid_filter = stk70x0p_pid_filter,
3878 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
Patrick Boettcher01373a52007-07-30 12:49:04 -03003879 .frontend_attach = stk7070pd_frontend_attach0,
3880 .tuner_attach = dib7070p_tuner_attach,
3881
3882 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03003883 }},
Patrick Boettcher01373a52007-07-30 12:49:04 -03003884 .size_of_priv = sizeof(struct dib0700_adapter_state),
3885 }, {
Michael Krufky77eed212011-09-06 09:31:57 -03003886 .num_frontends = 1,
3887 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03003888 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
3889 .pid_filter_count = 32,
3890 .pid_filter = stk70x0p_pid_filter,
3891 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
Patrick Boettcher01373a52007-07-30 12:49:04 -03003892 .frontend_attach = stk7070pd_frontend_attach1,
3893 .tuner_attach = dib7070p_tuner_attach,
3894
3895 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
Michael Krufky77eed212011-09-06 09:31:57 -03003896 }},
Patrick Boettcher01373a52007-07-30 12:49:04 -03003897 .size_of_priv = sizeof(struct dib0700_adapter_state),
3898 }
3899 },
3900
Jiri Slaby9b6ba572012-01-10 14:11:22 -03003901 .num_device_descs = 1,
3902 .devices = {
3903 { "Hauppauge Nova-TD Stick (52009)",
3904 { &dib0700_usb_id_table[35], NULL },
3905 { NULL },
3906 },
3907 },
3908
3909 .rc.core = {
3910 .rc_interval = DEFAULT_RC_INTERVAL,
3911 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
3912 .module_name = "dib0700",
3913 .rc_query = dib0700_rc_query_old_firmware,
3914 .allowed_protos = RC_TYPE_RC5 |
3915 RC_TYPE_RC6 |
3916 RC_TYPE_NEC,
3917 .change_protocol = dib0700_change_protocol,
3918 },
3919 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
3920
3921 .num_adapters = 2,
3922 .adapter = {
3923 {
3924 .num_frontends = 1,
3925 .fe = {{
3926 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
3927 .pid_filter_count = 32,
3928 .pid_filter = stk70x0p_pid_filter,
3929 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
3930 .frontend_attach = stk7070pd_frontend_attach0,
3931 .tuner_attach = dib7070p_tuner_attach,
3932
3933 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
3934 }},
3935 .size_of_priv = sizeof(struct dib0700_adapter_state),
3936 }, {
3937 .num_frontends = 1,
3938 .fe = {{
3939 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
3940 .pid_filter_count = 32,
3941 .pid_filter = stk70x0p_pid_filter,
3942 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
3943 .frontend_attach = stk7070pd_frontend_attach1,
3944 .tuner_attach = dib7070p_tuner_attach,
3945
3946 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
3947 }},
3948 .size_of_priv = sizeof(struct dib0700_adapter_state),
3949 }
3950 },
3951
3952 .num_device_descs = 5,
Patrick Boettcher01373a52007-07-30 12:49:04 -03003953 .devices = {
3954 { "DiBcom STK7070PD reference design",
3955 { &dib0700_usb_id_table[17], NULL },
3956 { NULL },
3957 },
3958 { "Pinnacle PCTV Dual DVB-T Diversity Stick",
3959 { &dib0700_usb_id_table[18], NULL },
3960 { NULL },
Michael Krufkyd01eb2d2008-07-03 23:43:36 -03003961 },
Michael Krufky9a0c04a2008-09-03 17:12:24 -03003962 { "Hauppauge Nova-TD-500 (84xxx)",
3963 { &dib0700_usb_id_table[36], NULL },
3964 { NULL },
Nicolas Fournierdb4b2d12009-01-13 07:15:25 -03003965 },
Patrick Boettchera9b8fe32009-05-20 05:35:02 -03003966 { "Terratec Cinergy DT USB XS Diversity/ T5",
3967 { &dib0700_usb_id_table[43],
3968 &dib0700_usb_id_table[53], NULL},
Nicolas Fournierdb4b2d12009-01-13 07:15:25 -03003969 { NULL },
sebastian.blanes@gmail.com0a6e1ed2009-02-24 14:51:43 -03003970 },
3971 { "Sony PlayTV",
3972 { &dib0700_usb_id_table[44], NULL },
3973 { NULL },
Michael Müller84e2f032010-04-26 22:18:57 -03003974 },
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03003975 },
3976
3977 .rc.core = {
3978 .rc_interval = DEFAULT_RC_INTERVAL,
3979 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
3980 .module_name = "dib0700",
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03003981 .rc_query = dib0700_rc_query_old_firmware,
Mauro Carvalho Chehab52b66142010-11-17 14:20:52 -03003982 .allowed_protos = RC_TYPE_RC5 |
3983 RC_TYPE_RC6 |
3984 RC_TYPE_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03003985 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03003986 },
3987 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
3988
3989 .num_adapters = 2,
3990 .adapter = {
3991 {
Michael Krufky77eed212011-09-06 09:31:57 -03003992 .num_frontends = 1,
3993 .fe = {{
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03003994 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
3995 .pid_filter_count = 32,
3996 .pid_filter = stk70x0p_pid_filter,
3997 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
3998 .frontend_attach = stk7070pd_frontend_attach0,
3999 .tuner_attach = dib7070p_tuner_attach,
4000
4001 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004002 }},
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004003 .size_of_priv = sizeof(struct dib0700_adapter_state),
4004 }, {
Michael Krufky77eed212011-09-06 09:31:57 -03004005 .num_frontends = 1,
4006 .fe = {{
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004007 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4008 .pid_filter_count = 32,
4009 .pid_filter = stk70x0p_pid_filter,
4010 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
4011 .frontend_attach = stk7070pd_frontend_attach1,
4012 .tuner_attach = dib7070p_tuner_attach,
4013
4014 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
Michael Krufky77eed212011-09-06 09:31:57 -03004015 }},
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004016 .size_of_priv = sizeof(struct dib0700_adapter_state),
4017 }
4018 },
4019
4020 .num_device_descs = 1,
4021 .devices = {
Michael Müller84e2f032010-04-26 22:18:57 -03004022 { "Elgato EyeTV Diversity",
4023 { &dib0700_usb_id_table[68], NULL },
4024 { NULL },
4025 },
Arne Luehrsc985a8d2009-01-21 01:37:20 -03004026 },
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004027
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004028 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004029 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004030 .rc_codes = RC_MAP_DIB0700_NEC_TABLE,
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004031 .module_name = "dib0700",
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03004032 .rc_query = dib0700_rc_query_old_firmware,
Mauro Carvalho Chehab52b66142010-11-17 14:20:52 -03004033 .allowed_protos = RC_TYPE_RC5 |
4034 RC_TYPE_RC6 |
4035 RC_TYPE_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03004036 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004037 },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03004038 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4039
4040 .num_adapters = 1,
4041 .adapter = {
4042 {
Michael Krufky77eed212011-09-06 09:31:57 -03004043 .num_frontends = 1,
4044 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03004045 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4046 .pid_filter_count = 32,
4047 .pid_filter = stk70x0p_pid_filter,
4048 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03004049 .frontend_attach = stk7700ph_frontend_attach,
4050 .tuner_attach = stk7700ph_tuner_attach,
4051
4052 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004053 }},
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03004054 .size_of_priv = sizeof(struct
4055 dib0700_adapter_state),
4056 },
4057 },
4058
Pete Hildebrandtc53d83c2009-08-05 11:46:38 -03004059 .num_device_descs = 9,
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03004060 .devices = {
4061 { "Terratec Cinergy HT USB XE",
4062 { &dib0700_usb_id_table[27], NULL },
4063 { NULL },
4064 },
4065 { "Pinnacle Expresscard 320cx",
4066 { &dib0700_usb_id_table[28], NULL },
4067 { NULL },
4068 },
4069 { "Terratec Cinergy HT Express",
4070 { &dib0700_usb_id_table[32], NULL },
4071 { NULL },
4072 },
Finn Thain17a370b2008-09-06 13:42:47 -03004073 { "Gigabyte U8000-RH",
4074 { &dib0700_usb_id_table[37], NULL },
4075 { NULL },
4076 },
Daniel Oliveira Nascimento8751aaa2008-09-07 12:39:44 -03004077 { "YUAN High-Tech STK7700PH",
4078 { &dib0700_usb_id_table[38], NULL },
4079 { NULL },
4080 },
Albert Comerma57697432008-09-07 12:43:33 -03004081 { "Asus My Cinema-U3000Hybrid",
4082 { &dib0700_usb_id_table[39], NULL },
4083 { NULL },
4084 },
Xoan Loureiro16ba1ee2009-03-29 08:43:36 -03004085 { "YUAN High-Tech MC770",
4086 { &dib0700_usb_id_table[48], NULL },
4087 { NULL },
4088 },
tomas petrf0f4ae72009-05-20 05:28:05 -03004089 { "Leadtek WinFast DTV Dongle H",
4090 { &dib0700_usb_id_table[51], NULL },
4091 { NULL },
4092 },
Pete Hildebrandtc53d83c2009-08-05 11:46:38 -03004093 { "YUAN High-Tech STK7700D",
4094 { &dib0700_usb_id_table[54], NULL },
4095 { NULL },
4096 },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03004097 },
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004098
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004099 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004100 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004101 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004102 .module_name = "dib0700",
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03004103 .rc_query = dib0700_rc_query_old_firmware,
Mauro Carvalho Chehab52b66142010-11-17 14:20:52 -03004104 .allowed_protos = RC_TYPE_RC5 |
4105 RC_TYPE_RC6 |
4106 RC_TYPE_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03004107 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004108 },
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03004109 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4110 .num_adapters = 1,
4111 .adapter = {
4112 {
Michael Krufky77eed212011-09-06 09:31:57 -03004113 .num_frontends = 1,
4114 .fe = {{
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03004115 .frontend_attach = s5h1411_frontend_attach,
4116 .tuner_attach = xc5000_tuner_attach,
4117
4118 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004119 }},
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03004120 .size_of_priv = sizeof(struct
4121 dib0700_adapter_state),
4122 },
4123 },
4124
Devin Heitmuellerd2fc3bf2008-09-25 06:22:23 -03004125 .num_device_descs = 2,
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03004126 .devices = {
4127 { "Pinnacle PCTV HD Pro USB Stick",
4128 { &dib0700_usb_id_table[40], NULL },
4129 { NULL },
4130 },
Devin Heitmuellerd2fc3bf2008-09-25 06:22:23 -03004131 { "Pinnacle PCTV HD USB Stick",
4132 { &dib0700_usb_id_table[41], NULL },
4133 { NULL },
4134 },
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03004135 },
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004136
4137 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004138 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004139 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004140 .module_name = "dib0700",
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03004141 .rc_query = dib0700_rc_query_old_firmware,
Mauro Carvalho Chehab52b66142010-11-17 14:20:52 -03004142 .allowed_protos = RC_TYPE_RC5 |
4143 RC_TYPE_RC6 |
4144 RC_TYPE_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03004145 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004146 },
Michael Krufkyce904bc2009-01-19 01:12:55 -03004147 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4148 .num_adapters = 1,
4149 .adapter = {
4150 {
Michael Krufky77eed212011-09-06 09:31:57 -03004151 .num_frontends = 1,
4152 .fe = {{
Michael Krufkyce904bc2009-01-19 01:12:55 -03004153 .frontend_attach = lgdt3305_frontend_attach,
4154 .tuner_attach = mxl5007t_tuner_attach,
4155
4156 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004157 }},
Michael Krufkyce904bc2009-01-19 01:12:55 -03004158 .size_of_priv = sizeof(struct
4159 dib0700_adapter_state),
4160 },
4161 },
4162
4163 .num_device_descs = 2,
4164 .devices = {
4165 { "Hauppauge ATSC MiniCard (B200)",
4166 { &dib0700_usb_id_table[46], NULL },
4167 { NULL },
4168 },
4169 { "Hauppauge ATSC MiniCard (B210)",
4170 { &dib0700_usb_id_table[47], NULL },
4171 { NULL },
4172 },
4173 },
Olivier Grenied300bd62009-09-15 06:55:35 -03004174 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4175
4176 .num_adapters = 1,
4177 .adapter = {
4178 {
Michael Krufky77eed212011-09-06 09:31:57 -03004179 .num_frontends = 1,
4180 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03004181 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4182 .pid_filter_count = 32,
4183 .pid_filter = stk70x0p_pid_filter,
4184 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
Olivier Grenie90e12ce2010-09-07 12:50:45 -03004185 .frontend_attach = stk7770p_frontend_attach,
Olivier Grenied300bd62009-09-15 06:55:35 -03004186 .tuner_attach = dib7770p_tuner_attach,
4187
4188 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004189 }},
Olivier Grenied300bd62009-09-15 06:55:35 -03004190 .size_of_priv =
Patrick Boettcherdb481382009-09-15 07:16:51 -03004191 sizeof(struct dib0700_adapter_state),
Olivier Grenied300bd62009-09-15 06:55:35 -03004192 },
4193 },
4194
Stéphane Elmalehd1402302011-05-21 07:33:38 -03004195 .num_device_descs = 4,
Olivier Grenied300bd62009-09-15 06:55:35 -03004196 .devices = {
4197 { "DiBcom STK7770P reference design",
4198 { &dib0700_usb_id_table[59], NULL },
4199 { NULL },
4200 },
Patrick Boettcher1e13c8f2009-09-19 05:24:40 -03004201 { "Terratec Cinergy T USB XXS (HD)/ T3",
4202 { &dib0700_usb_id_table[33],
4203 &dib0700_usb_id_table[52],
4204 &dib0700_usb_id_table[60], NULL},
Patrick Boettcherdb481382009-09-15 07:16:51 -03004205 { NULL },
4206 },
Lukas Max Fisch498e6772011-02-08 16:51:45 -03004207 { "TechniSat AirStar TeleStick 2",
4208 { &dib0700_usb_id_table[74], NULL },
4209 { NULL },
4210 },
Stéphane Elmalehd1402302011-05-21 07:33:38 -03004211 { "Medion CTX1921 DVB-T USB",
4212 { &dib0700_usb_id_table[75], NULL },
4213 { NULL },
4214 },
Olivier Grenied300bd62009-09-15 06:55:35 -03004215 },
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004216
4217 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004218 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004219 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004220 .module_name = "dib0700",
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03004221 .rc_query = dib0700_rc_query_old_firmware,
Mauro Carvalho Chehab52b66142010-11-17 14:20:52 -03004222 .allowed_protos = RC_TYPE_RC5 |
4223 RC_TYPE_RC6 |
4224 RC_TYPE_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03004225 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004226 },
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03004227 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4228 .num_adapters = 1,
4229 .adapter = {
4230 {
Michael Krufky77eed212011-09-06 09:31:57 -03004231 .num_frontends = 1,
4232 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03004233 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4234 .pid_filter_count = 32,
Olivier Grenie03245a52009-12-04 13:27:57 -03004235 .pid_filter = stk80xx_pid_filter,
4236 .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03004237 .frontend_attach = stk807x_frontend_attach,
4238 .tuner_attach = dib807x_tuner_attach,
4239
4240 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004241 }},
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03004242 .size_of_priv =
4243 sizeof(struct dib0700_adapter_state),
4244 },
4245 },
4246
S?rgio Fortier8a378e82009-09-28 04:19:21 -03004247 .num_device_descs = 3,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03004248 .devices = {
4249 { "DiBcom STK807xP reference design",
4250 { &dib0700_usb_id_table[62], NULL },
4251 { NULL },
4252 },
Mauro Carvalho Chehabaaeab302009-09-16 09:18:26 -03004253 { "Prolink Pixelview SBTVD",
4254 { &dib0700_usb_id_table[63], NULL },
4255 { NULL },
4256 },
S?rgio Fortier8a378e82009-09-28 04:19:21 -03004257 { "EvolutePC TVWay+",
4258 { &dib0700_usb_id_table[64], NULL },
4259 { NULL },
4260 },
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03004261 },
4262
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004263 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004264 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004265 .rc_codes = RC_MAP_DIB0700_NEC_TABLE,
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004266 .module_name = "dib0700",
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03004267 .rc_query = dib0700_rc_query_old_firmware,
Mauro Carvalho Chehab52b66142010-11-17 14:20:52 -03004268 .allowed_protos = RC_TYPE_RC5 |
4269 RC_TYPE_RC6 |
4270 RC_TYPE_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03004271 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004272 },
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03004273 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4274 .num_adapters = 2,
4275 .adapter = {
4276 {
Michael Krufky77eed212011-09-06 09:31:57 -03004277 .num_frontends = 1,
4278 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03004279 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4280 .pid_filter_count = 32,
Olivier Grenie03245a52009-12-04 13:27:57 -03004281 .pid_filter = stk80xx_pid_filter,
4282 .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03004283 .frontend_attach = stk807xpvr_frontend_attach0,
4284 .tuner_attach = dib807x_tuner_attach,
4285
4286 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004287 }},
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03004288 .size_of_priv =
4289 sizeof(struct dib0700_adapter_state),
4290 },
4291 {
Michael Krufky77eed212011-09-06 09:31:57 -03004292 .num_frontends = 1,
4293 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03004294 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4295 .pid_filter_count = 32,
Olivier Grenie03245a52009-12-04 13:27:57 -03004296 .pid_filter = stk80xx_pid_filter,
4297 .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03004298 .frontend_attach = stk807xpvr_frontend_attach1,
4299 .tuner_attach = dib807x_tuner_attach,
4300
4301 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
Michael Krufky77eed212011-09-06 09:31:57 -03004302 }},
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03004303 .size_of_priv =
4304 sizeof(struct dib0700_adapter_state),
4305 },
4306 },
4307
4308 .num_device_descs = 1,
4309 .devices = {
4310 { "DiBcom STK807xPVR reference design",
4311 { &dib0700_usb_id_table[61], NULL },
4312 { NULL },
4313 },
4314 },
4315
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004316 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004317 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004318 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004319 .module_name = "dib0700",
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03004320 .rc_query = dib0700_rc_query_old_firmware,
Mauro Carvalho Chehab52b66142010-11-17 14:20:52 -03004321 .allowed_protos = RC_TYPE_RC5 |
4322 RC_TYPE_RC6 |
4323 RC_TYPE_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03004324 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004325 },
Olivier Grenie03245a52009-12-04 13:27:57 -03004326 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4327 .num_adapters = 1,
4328 .adapter = {
4329 {
Michael Krufky77eed212011-09-06 09:31:57 -03004330 .num_frontends = 1,
4331 .fe = {{
Olivier Grenie03245a52009-12-04 13:27:57 -03004332 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
4333 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4334 .pid_filter_count = 32,
4335 .pid_filter = stk80xx_pid_filter,
4336 .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
4337 .frontend_attach = stk809x_frontend_attach,
4338 .tuner_attach = dib809x_tuner_attach,
4339
4340 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004341 }},
Olivier Grenie03245a52009-12-04 13:27:57 -03004342 .size_of_priv =
4343 sizeof(struct dib0700_adapter_state),
4344 },
4345 },
4346
4347 .num_device_descs = 1,
4348 .devices = {
4349 { "DiBcom STK8096GP reference design",
4350 { &dib0700_usb_id_table[67], NULL },
4351 { NULL },
4352 },
4353 },
4354
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004355 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004356 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004357 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004358 .module_name = "dib0700",
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03004359 .rc_query = dib0700_rc_query_old_firmware,
Mauro Carvalho Chehab52b66142010-11-17 14:20:52 -03004360 .allowed_protos = RC_TYPE_RC5 |
4361 RC_TYPE_RC6 |
4362 RC_TYPE_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03004363 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004364 },
Olivier Greniebe9bae12011-01-04 05:42:19 -03004365 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4366 .num_adapters = 1,
4367 .adapter = {
4368 {
Michael Krufky77eed212011-09-06 09:31:57 -03004369 .num_frontends = 1,
4370 .fe = {{
Olivier Greniebe9bae12011-01-04 05:42:19 -03004371 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
4372 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4373 .pid_filter_count = 32,
4374 .pid_filter = dib90x0_pid_filter,
4375 .pid_filter_ctrl = dib90x0_pid_filter_ctrl,
4376 .frontend_attach = stk9090m_frontend_attach,
4377 .tuner_attach = dib9090_tuner_attach,
4378
4379 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004380 }},
Olivier Greniebe9bae12011-01-04 05:42:19 -03004381 .size_of_priv =
4382 sizeof(struct dib0700_adapter_state),
4383 },
4384 },
4385
4386 .num_device_descs = 1,
4387 .devices = {
4388 { "DiBcom STK9090M reference design",
4389 { &dib0700_usb_id_table[69], NULL },
4390 { NULL },
4391 },
4392 },
4393
4394 .rc.core = {
4395 .rc_interval = DEFAULT_RC_INTERVAL,
4396 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4397 .module_name = "dib0700",
4398 .rc_query = dib0700_rc_query_old_firmware,
4399 .allowed_protos = RC_TYPE_RC5 |
4400 RC_TYPE_RC6 |
4401 RC_TYPE_NEC,
4402 .change_protocol = dib0700_change_protocol,
4403 },
4404 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4405 .num_adapters = 1,
4406 .adapter = {
4407 {
Michael Krufky77eed212011-09-06 09:31:57 -03004408 .num_frontends = 1,
4409 .fe = {{
Olivier Greniebe9bae12011-01-04 05:42:19 -03004410 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
4411 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4412 .pid_filter_count = 32,
4413 .pid_filter = stk80xx_pid_filter,
4414 .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
4415 .frontend_attach = nim8096md_frontend_attach,
4416 .tuner_attach = nim8096md_tuner_attach,
4417
4418 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004419 }},
Olivier Greniebe9bae12011-01-04 05:42:19 -03004420 .size_of_priv =
4421 sizeof(struct dib0700_adapter_state),
4422 },
4423 },
4424
4425 .num_device_descs = 1,
4426 .devices = {
4427 { "DiBcom NIM8096MD reference design",
4428 { &dib0700_usb_id_table[70], NULL },
4429 { NULL },
4430 },
4431 },
4432
4433 .rc.core = {
4434 .rc_interval = DEFAULT_RC_INTERVAL,
4435 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4436 .module_name = "dib0700",
4437 .rc_query = dib0700_rc_query_old_firmware,
4438 .allowed_protos = RC_TYPE_RC5 |
4439 RC_TYPE_RC6 |
4440 RC_TYPE_NEC,
4441 .change_protocol = dib0700_change_protocol,
4442 },
4443 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4444 .num_adapters = 1,
4445 .adapter = {
4446 {
Michael Krufky77eed212011-09-06 09:31:57 -03004447 .num_frontends = 1,
4448 .fe = {{
Olivier Greniebe9bae12011-01-04 05:42:19 -03004449 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
4450 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4451 .pid_filter_count = 32,
4452 .pid_filter = dib90x0_pid_filter,
4453 .pid_filter_ctrl = dib90x0_pid_filter_ctrl,
4454 .frontend_attach = nim9090md_frontend_attach,
4455 .tuner_attach = nim9090md_tuner_attach,
4456
4457 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004458 }},
Olivier Greniebe9bae12011-01-04 05:42:19 -03004459 .size_of_priv =
4460 sizeof(struct dib0700_adapter_state),
4461 },
4462 },
4463
4464 .num_device_descs = 1,
4465 .devices = {
4466 { "DiBcom NIM9090MD reference design",
4467 { &dib0700_usb_id_table[71], NULL },
4468 { NULL },
4469 },
4470 },
4471
4472 .rc.core = {
4473 .rc_interval = DEFAULT_RC_INTERVAL,
4474 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4475 .module_name = "dib0700",
4476 .rc_query = dib0700_rc_query_old_firmware,
4477 .allowed_protos = RC_TYPE_RC5 |
4478 RC_TYPE_RC6 |
4479 RC_TYPE_NEC,
4480 .change_protocol = dib0700_change_protocol,
4481 },
4482 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4483 .num_adapters = 1,
4484 .adapter = {
4485 {
Michael Krufky77eed212011-09-06 09:31:57 -03004486 .num_frontends = 1,
4487 .fe = {{
Olivier Greniebe9bae12011-01-04 05:42:19 -03004488 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
4489 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4490 .pid_filter_count = 32,
4491 .pid_filter = stk70x0p_pid_filter,
4492 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
4493 .frontend_attach = nim7090_frontend_attach,
4494 .tuner_attach = nim7090_tuner_attach,
4495
4496 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004497 }},
Olivier Greniebe9bae12011-01-04 05:42:19 -03004498 .size_of_priv =
4499 sizeof(struct dib0700_adapter_state),
4500 },
4501 },
4502
4503 .num_device_descs = 1,
4504 .devices = {
4505 { "DiBcom NIM7090 reference design",
4506 { &dib0700_usb_id_table[72], NULL },
4507 { NULL },
4508 },
4509 },
4510
4511 .rc.core = {
4512 .rc_interval = DEFAULT_RC_INTERVAL,
4513 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4514 .module_name = "dib0700",
4515 .rc_query = dib0700_rc_query_old_firmware,
4516 .allowed_protos = RC_TYPE_RC5 |
4517 RC_TYPE_RC6 |
4518 RC_TYPE_NEC,
4519 .change_protocol = dib0700_change_protocol,
4520 },
4521 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4522 .num_adapters = 2,
4523 .adapter = {
4524 {
Michael Krufky77eed212011-09-06 09:31:57 -03004525 .num_frontends = 1,
4526 .fe = {{
Olivier Greniebe9bae12011-01-04 05:42:19 -03004527 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
4528 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4529 .pid_filter_count = 32,
4530 .pid_filter = stk70x0p_pid_filter,
4531 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
4532 .frontend_attach = tfe7090pvr_frontend0_attach,
4533 .tuner_attach = tfe7090pvr_tuner0_attach,
4534
4535 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
Michael Krufky77eed212011-09-06 09:31:57 -03004536 }},
Olivier Greniebe9bae12011-01-04 05:42:19 -03004537 .size_of_priv =
4538 sizeof(struct dib0700_adapter_state),
4539 },
4540 {
Michael Krufky77eed212011-09-06 09:31:57 -03004541 .num_frontends = 1,
4542 .fe = {{
Olivier Greniebe9bae12011-01-04 05:42:19 -03004543 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
4544 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4545 .pid_filter_count = 32,
4546 .pid_filter = stk70x0p_pid_filter,
4547 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
4548 .frontend_attach = tfe7090pvr_frontend1_attach,
4549 .tuner_attach = tfe7090pvr_tuner1_attach,
4550
4551 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004552 }},
Olivier Greniebe9bae12011-01-04 05:42:19 -03004553 .size_of_priv =
4554 sizeof(struct dib0700_adapter_state),
4555 },
4556 },
4557
4558 .num_device_descs = 1,
4559 .devices = {
4560 { "DiBcom TFE7090PVR reference design",
4561 { &dib0700_usb_id_table[73], NULL },
4562 { NULL },
4563 },
4564 },
4565
4566 .rc.core = {
4567 .rc_interval = DEFAULT_RC_INTERVAL,
4568 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4569 .module_name = "dib0700",
4570 .rc_query = dib0700_rc_query_old_firmware,
4571 .allowed_protos = RC_TYPE_RC5 |
4572 RC_TYPE_RC6 |
4573 RC_TYPE_NEC,
4574 .change_protocol = dib0700_change_protocol,
4575 },
Davide Ferri8d009a02009-06-23 22:34:06 -03004576 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4577 .num_adapters = 1,
4578 .adapter = {
4579 {
Michael Krufky77eed212011-09-06 09:31:57 -03004580 .num_frontends = 1,
4581 .fe = {{
Devin Heitmueller01f16262009-06-24 00:07:01 -03004582 .frontend_attach = pctv340e_frontend_attach,
Davide Ferri8d009a02009-06-23 22:34:06 -03004583 .tuner_attach = xc4000_tuner_attach,
4584
4585 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004586 }},
Davide Ferri8d009a02009-06-23 22:34:06 -03004587 .size_of_priv = sizeof(struct
4588 dib0700_adapter_state),
4589 },
4590 },
4591
Devin Heitmueller33fb1682009-06-23 22:48:02 -03004592 .num_device_descs = 2,
Davide Ferri8d009a02009-06-23 22:34:06 -03004593 .devices = {
4594 { "Pinnacle PCTV 340e HD Pro USB Stick",
4595 { &dib0700_usb_id_table[76], NULL },
4596 { NULL },
4597 },
Devin Heitmueller33fb1682009-06-23 22:48:02 -03004598 { "Pinnacle PCTV Hybrid Stick Solo",
4599 { &dib0700_usb_id_table[77], NULL },
4600 { NULL },
4601 },
Davide Ferri8d009a02009-06-23 22:34:06 -03004602 },
4603 .rc.core = {
4604 .rc_interval = DEFAULT_RC_INTERVAL,
4605 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4606 .module_name = "dib0700",
4607 .rc_query = dib0700_rc_query_old_firmware,
4608 .allowed_protos = RC_TYPE_RC5 |
4609 RC_TYPE_RC6 |
4610 RC_TYPE_NEC,
4611 .change_protocol = dib0700_change_protocol,
4612 },
Olivier Grenie6724a2f2011-08-05 13:49:33 -03004613 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4614 .num_adapters = 1,
4615 .adapter = {
4616 {
4617 .num_frontends = 1,
4618 .fe = {{
4619 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
4620 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4621 .pid_filter_count = 32,
4622 .pid_filter = stk70x0p_pid_filter,
4623 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
4624 .frontend_attach = tfe7090e_frontend_attach,
4625 .tuner_attach = tfe7090e_tuner_attach,
4626
4627 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
4628 } },
4629
4630 .size_of_priv =
4631 sizeof(struct dib0700_adapter_state),
4632 },
4633 },
4634
4635 .num_device_descs = 1,
4636 .devices = {
4637 { "DiBcom TFE7090E reference design",
4638 { &dib0700_usb_id_table[78], NULL },
4639 { NULL },
4640 },
4641 },
4642
4643 .rc.core = {
4644 .rc_interval = DEFAULT_RC_INTERVAL,
4645 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4646 .module_name = "dib0700",
4647 .rc_query = dib0700_rc_query_old_firmware,
4648 .allowed_protos = RC_TYPE_RC5 |
4649 RC_TYPE_RC6 |
4650 RC_TYPE_NEC,
4651 .change_protocol = dib0700_change_protocol,
4652 },
Olivier Grenieb293f302011-08-09 04:48:25 -03004653 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4654 .num_adapters = 1,
4655 .adapter = {
4656 {
4657 .num_frontends = 1,
4658 .fe = {{
4659 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
4660 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4661 .pid_filter_count = 32,
4662 .pid_filter = stk70x0p_pid_filter,
4663 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
4664 .frontend_attach = tfe7790e_frontend_attach,
4665 .tuner_attach = tfe7790e_tuner_attach,
4666
4667 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
4668 } },
4669
4670 .size_of_priv =
4671 sizeof(struct dib0700_adapter_state),
4672 },
4673 },
4674
4675 .num_device_descs = 1,
4676 .devices = {
4677 { "DiBcom TFE7790E reference design",
4678 { &dib0700_usb_id_table[79], NULL },
4679 { NULL },
4680 },
4681 },
4682
4683 .rc.core = {
4684 .rc_interval = DEFAULT_RC_INTERVAL,
4685 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4686 .module_name = "dib0700",
4687 .rc_query = dib0700_rc_query_old_firmware,
4688 .allowed_protos = RC_TYPE_RC5 |
4689 RC_TYPE_RC6 |
4690 RC_TYPE_NEC,
4691 .change_protocol = dib0700_change_protocol,
4692 },
Olivier Grenie88f3a352011-08-10 05:28:38 -03004693 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4694 .num_adapters = 1,
4695 .adapter = {
4696 {
4697 .num_frontends = 1,
4698 .fe = {{
4699 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
4700 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4701 .pid_filter_count = 32,
4702 .pid_filter = stk80xx_pid_filter,
4703 .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
4704 .frontend_attach = tfe8096p_frontend_attach,
4705 .tuner_attach = tfe8096p_tuner_attach,
4706
4707 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
4708
4709 } },
4710
4711 .size_of_priv =
4712 sizeof(struct dib0700_adapter_state),
4713 },
4714 },
4715
4716 .num_device_descs = 1,
4717 .devices = {
4718 { "DiBcom TFE8096P reference design",
4719 { &dib0700_usb_id_table[80], NULL },
4720 { NULL },
4721 },
4722 },
4723
4724 .rc.core = {
4725 .rc_interval = DEFAULT_RC_INTERVAL,
4726 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4727 .module_name = "dib0700",
4728 .rc_query = dib0700_rc_query_old_firmware,
4729 .allowed_protos = RC_TYPE_RC5 |
4730 RC_TYPE_RC6 |
4731 RC_TYPE_NEC,
4732 .change_protocol = dib0700_change_protocol,
4733 },
Patrick Boettcher01373a52007-07-30 12:49:04 -03004734 },
Patrick Boettcherb7f54912006-09-19 12:51:37 -03004735};
4736
4737int dib0700_device_count = ARRAY_SIZE(dib0700_devices);