blob: 829323e42ca095671372ec15de5cea81a4810fea [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) {
David Härdemanc003ab12012-10-11 19:11:54 -0300521 case RC_BIT_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 Grenie5e9c85d2012-12-31 10:17:44 -03001434static void dib8090_agc_control(struct dvb_frontend *fe, u8 restart)
1435{
1436 deb_info("AGC control callback: %i\n", restart);
1437 dib0090_dcc_freq(fe, restart);
1438
1439 if (restart == 0) /* before AGC startup */
1440 dib0090_set_dc_servo(fe, 1);
1441}
1442
Olivier Greniebe9bae12011-01-04 05:42:19 -03001443static struct dib8000_config dib809x_dib8000_config[2] = {
1444 {
1445 .output_mpeg2_in_188_bytes = 1,
Olivier Grenie03245a52009-12-04 13:27:57 -03001446
Olivier Greniebe9bae12011-01-04 05:42:19 -03001447 .agc_config_count = 2,
1448 .agc = dib8090_agc_config,
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001449 .agc_control = dib8090_agc_control,
Olivier Greniebe9bae12011-01-04 05:42:19 -03001450 .pll = &dib8090_pll_config_12mhz,
1451 .tuner_is_baseband = 1,
Olivier Grenie03245a52009-12-04 13:27:57 -03001452
Olivier Greniebe9bae12011-01-04 05:42:19 -03001453 .gpio_dir = DIB8000_GPIO_DEFAULT_DIRECTIONS,
1454 .gpio_val = DIB8000_GPIO_DEFAULT_VALUES,
1455 .gpio_pwm_pos = DIB8000_GPIO_DEFAULT_PWM_POS,
Olivier Grenie03245a52009-12-04 13:27:57 -03001456
Olivier Greniebe9bae12011-01-04 05:42:19 -03001457 .hostbus_diversity = 1,
1458 .div_cfg = 0x31,
1459 .output_mode = OUTMODE_MPEG2_FIFO,
1460 .drives = 0x2d98,
1461 .diversity_delay = 48,
1462 .refclksel = 3,
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03001463 }, {
Olivier Greniebe9bae12011-01-04 05:42:19 -03001464 .output_mpeg2_in_188_bytes = 1,
1465
1466 .agc_config_count = 2,
1467 .agc = dib8090_agc_config,
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001468 .agc_control = dib8090_agc_control,
Olivier Greniebe9bae12011-01-04 05:42:19 -03001469 .pll = &dib8090_pll_config_12mhz,
1470 .tuner_is_baseband = 1,
1471
1472 .gpio_dir = DIB8000_GPIO_DEFAULT_DIRECTIONS,
1473 .gpio_val = DIB8000_GPIO_DEFAULT_VALUES,
1474 .gpio_pwm_pos = DIB8000_GPIO_DEFAULT_PWM_POS,
1475
1476 .hostbus_diversity = 1,
1477 .div_cfg = 0x31,
1478 .output_mode = OUTMODE_DIVERSITY,
1479 .drives = 0x2d08,
1480 .diversity_delay = 1,
1481 .refclksel = 3,
1482 }
1483};
1484
1485static struct dib0090_wbd_slope dib8090_wbd_table[] = {
1486 /* max freq ; cold slope ; cold offset ; warm slope ; warm offset ; wbd gain */
1487 { 120, 0, 500, 0, 500, 4 }, /* CBAND */
1488 { 170, 0, 450, 0, 450, 4 }, /* CBAND */
1489 { 380, 48, 373, 28, 259, 6 }, /* VHF */
1490 { 860, 34, 700, 36, 616, 6 }, /* high UHF */
1491 { 0xFFFF, 34, 700, 36, 616, 6 }, /* default */
Olivier Grenie03245a52009-12-04 13:27:57 -03001492};
1493
1494static struct dib0090_config dib809x_dib0090_config = {
Olivier Greniebe9bae12011-01-04 05:42:19 -03001495 .io.pll_bypass = 1,
1496 .io.pll_range = 1,
1497 .io.pll_prediv = 1,
1498 .io.pll_loopdiv = 20,
1499 .io.adc_clock_ratio = 8,
1500 .io.pll_int_loop_filt = 0,
1501 .io.clock_khz = 12000,
1502 .reset = dib80xx_tuner_reset,
1503 .sleep = dib80xx_tuner_sleep,
1504 .clkouttobamse = 1,
1505 .analog_output = 1,
1506 .i2c_address = DEFAULT_DIB0090_I2C_ADDRESS,
1507 .use_pwm_agc = 1,
1508 .clkoutdrive = 1,
1509 .get_adc_power = dib8090_get_adc_power,
1510 .freq_offset_khz_uhf = -63,
Olivier Grenie03245a52009-12-04 13:27:57 -03001511 .freq_offset_khz_vhf = -143,
Olivier Greniebe9bae12011-01-04 05:42:19 -03001512 .wbd = dib8090_wbd_table,
1513 .fref_clock_ratio = 6,
Olivier Grenie03245a52009-12-04 13:27:57 -03001514};
1515
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001516static u8 dib8090_compute_pll_parameters(struct dvb_frontend *fe)
1517{
1518 u8 optimal_pll_ratio = 20;
1519 u32 freq_adc, ratio, rest, max = 0;
1520 u8 pll_ratio;
1521
1522 for (pll_ratio = 17; pll_ratio <= 20; pll_ratio++) {
1523 freq_adc = 12 * pll_ratio * (1 << 8) / 16;
1524 ratio = ((fe->dtv_property_cache.frequency / 1000) * (1 << 8) / 1000) / freq_adc;
1525 rest = ((fe->dtv_property_cache.frequency / 1000) * (1 << 8) / 1000) - ratio * freq_adc;
1526
1527 if (rest > freq_adc / 2)
1528 rest = freq_adc - rest;
1529 deb_info("PLL ratio=%i rest=%i\n", pll_ratio, rest);
1530 if ((rest > max) && (rest > 717)) {
1531 optimal_pll_ratio = pll_ratio;
1532 max = rest;
1533 }
1534 }
1535 deb_info("optimal PLL ratio=%i\n", optimal_pll_ratio);
1536
1537 return optimal_pll_ratio;
1538}
1539
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -03001540static int dib8096_set_param_override(struct dvb_frontend *fe)
Olivier Grenie03245a52009-12-04 13:27:57 -03001541{
Olivier Greniebe9bae12011-01-04 05:42:19 -03001542 struct dvb_usb_adapter *adap = fe->dvb->priv;
1543 struct dib0700_adapter_state *state = adap->priv;
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001544 u8 pll_ratio, band = BAND_OF_FREQUENCY(fe->dtv_property_cache.frequency / 1000);
1545 u16 target, ltgain, rf_gain_limit;
1546 u32 timf;
Olivier Greniebe9bae12011-01-04 05:42:19 -03001547 int ret = 0;
1548 enum frontend_tune_state tune_state = CT_SHUTDOWN;
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001549
1550 switch (band) {
1551 default:
1552 deb_info("Warning : Rf frequency (%iHz) is not in the supported range, using VHF switch ", fe->dtv_property_cache.frequency);
1553 case BAND_VHF:
1554 dib8000_set_gpio(fe, 3, 0, 1);
1555 break;
1556 case BAND_UHF:
1557 dib8000_set_gpio(fe, 3, 0, 0);
1558 break;
1559 }
Olivier Grenie03245a52009-12-04 13:27:57 -03001560
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -03001561 ret = state->set_param_save(fe);
Olivier Greniebe9bae12011-01-04 05:42:19 -03001562 if (ret < 0)
1563 return ret;
Olivier Grenie03245a52009-12-04 13:27:57 -03001564
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001565 if (fe->dtv_property_cache.bandwidth_hz != 6000000) {
1566 deb_info("only 6MHz bandwidth is supported\n");
1567 return -EINVAL;
1568 }
Olivier Grenie03245a52009-12-04 13:27:57 -03001569
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001570 /** Update PLL if needed ratio **/
1571 dib8000_update_pll(fe, &dib8090_pll_config_12mhz, fe->dtv_property_cache.bandwidth_hz / 1000, 0);
1572
1573 /** Get optimize PLL ratio to remove spurious **/
1574 pll_ratio = dib8090_compute_pll_parameters(fe);
1575 if (pll_ratio == 17)
1576 timf = 21387946;
1577 else if (pll_ratio == 18)
1578 timf = 20199727;
1579 else if (pll_ratio == 19)
1580 timf = 19136583;
1581 else
1582 timf = 18179756;
1583
1584 /** Update ratio **/
1585 dib8000_update_pll(fe, &dib8090_pll_config_12mhz, fe->dtv_property_cache.bandwidth_hz / 1000, pll_ratio);
1586
1587 dib8000_ctrl_timf(fe, DEMOD_TIMF_SET, timf);
1588
1589 if (band != BAND_CBAND) {
1590 /* dib0090_get_wbd_target is returning any possible temperature compensated wbd-target */
1591 target = (dib0090_get_wbd_target(fe) * 8 * 18 / 33 + 1) / 2;
1592 dib8000_set_wbd_ref(fe, target);
1593 }
Olivier Grenie03245a52009-12-04 13:27:57 -03001594
Olivier Greniebe9bae12011-01-04 05:42:19 -03001595 if (band == BAND_CBAND) {
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03001596 deb_info("tuning in CBAND - soft-AGC startup\n");
1597 dib0090_set_tune_state(fe, CT_AGC_START);
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001598
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03001599 do {
1600 ret = dib0090_gain_control(fe);
1601 msleep(ret);
1602 tune_state = dib0090_get_tune_state(fe);
1603 if (tune_state == CT_AGC_STEP_0)
1604 dib8000_set_gpio(fe, 6, 0, 1);
1605 else if (tune_state == CT_AGC_STEP_1) {
1606 dib0090_get_current_gain(fe, NULL, NULL, &rf_gain_limit, &ltgain);
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001607 if (rf_gain_limit < 2000) /* activate the external attenuator in case of very high input power */
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03001608 dib8000_set_gpio(fe, 6, 0, 0);
1609 }
1610 } while (tune_state < CT_AGC_STOP);
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001611
1612 deb_info("switching to PWM AGC\n");
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03001613 dib0090_pwm_gain_reset(fe);
1614 dib8000_pwm_agc_reset(fe);
1615 dib8000_set_tune_state(fe, CT_DEMOD_START);
Olivier Greniebe9bae12011-01-04 05:42:19 -03001616 } else {
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001617 /* for everything else than CBAND we are using standard AGC */
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03001618 deb_info("not tuning in CBAND - standard AGC startup\n");
1619 dib0090_pwm_gain_reset(fe);
Olivier Greniebe9bae12011-01-04 05:42:19 -03001620 }
Olivier Grenie03245a52009-12-04 13:27:57 -03001621
Olivier Greniebe9bae12011-01-04 05:42:19 -03001622 return 0;
Olivier Grenie03245a52009-12-04 13:27:57 -03001623}
1624
1625static int dib809x_tuner_attach(struct dvb_usb_adapter *adap)
1626{
Olivier Greniebe9bae12011-01-04 05:42:19 -03001627 struct dib0700_adapter_state *st = adap->priv;
Michael Krufky77eed212011-09-06 09:31:57 -03001628 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 -03001629
Michael Krufky77eed212011-09-06 09:31:57 -03001630 if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c, &dib809x_dib0090_config) == NULL)
Olivier Greniebe9bae12011-01-04 05:42:19 -03001631 return -ENODEV;
Olivier Grenie03245a52009-12-04 13:27:57 -03001632
Michael Krufky77eed212011-09-06 09:31:57 -03001633 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
1634 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib8096_set_param_override;
Olivier Greniebe9bae12011-01-04 05:42:19 -03001635 return 0;
Olivier Grenie03245a52009-12-04 13:27:57 -03001636}
1637
1638static int stk809x_frontend_attach(struct dvb_usb_adapter *adap)
1639{
1640 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
1641 msleep(10);
1642 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
1643 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
1644 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
1645
1646 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
1647
1648 dib0700_ctrl_clock(adap->dev, 72, 1);
1649
1650 msleep(10);
1651 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
1652 msleep(10);
1653 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
1654
Olivier Grenie0c32dbd2011-08-10 05:17:18 -03001655 dib8000_i2c_enumeration(&adap->dev->i2c_adap, 1, 18, 0x80, 0);
Olivier Grenie03245a52009-12-04 13:27:57 -03001656
Michael Krufky77eed212011-09-06 09:31:57 -03001657 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 -03001658
Michael Krufky77eed212011-09-06 09:31:57 -03001659 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Olivier Grenie03245a52009-12-04 13:27:57 -03001660}
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001661
Olivier Greniebe9bae12011-01-04 05:42:19 -03001662static int nim8096md_tuner_attach(struct dvb_usb_adapter *adap)
1663{
1664 struct dib0700_adapter_state *st = adap->priv;
1665 struct i2c_adapter *tun_i2c;
Michael Krufky77eed212011-09-06 09:31:57 -03001666 struct dvb_frontend *fe_slave = dib8000_get_slave_frontend(adap->fe_adap[0].fe, 1);
Olivier Greniebe9bae12011-01-04 05:42:19 -03001667
1668 if (fe_slave) {
1669 tun_i2c = dib8000_get_i2c_master(fe_slave, DIBX000_I2C_INTERFACE_TUNER, 1);
1670 if (dvb_attach(dib0090_register, fe_slave, tun_i2c, &dib809x_dib0090_config) == NULL)
1671 return -ENODEV;
Michael Krufky77eed212011-09-06 09:31:57 -03001672 fe_slave->dvb = adap->fe_adap[0].fe->dvb;
Olivier Greniebe9bae12011-01-04 05:42:19 -03001673 fe_slave->ops.tuner_ops.set_params = dib8096_set_param_override;
1674 }
Michael Krufky77eed212011-09-06 09:31:57 -03001675 tun_i2c = dib8000_get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_TUNER, 1);
1676 if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c, &dib809x_dib0090_config) == NULL)
Olivier Greniebe9bae12011-01-04 05:42:19 -03001677 return -ENODEV;
1678
Michael Krufky77eed212011-09-06 09:31:57 -03001679 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
1680 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib8096_set_param_override;
Olivier Greniebe9bae12011-01-04 05:42:19 -03001681
1682 return 0;
1683}
1684
1685static int nim8096md_frontend_attach(struct dvb_usb_adapter *adap)
1686{
1687 struct dvb_frontend *fe_slave;
1688
1689 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03001690 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03001691 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
1692 msleep(1000);
1693 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
1694 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
1695 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
1696
1697 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
1698
1699 dib0700_ctrl_clock(adap->dev, 72, 1);
1700
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03001701 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03001702 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03001703 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03001704 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
1705
Olivier Grenie0c32dbd2011-08-10 05:17:18 -03001706 dib8000_i2c_enumeration(&adap->dev->i2c_adap, 2, 18, 0x80, 0);
Olivier Greniebe9bae12011-01-04 05:42:19 -03001707
Michael Krufky77eed212011-09-06 09:31:57 -03001708 adap->fe_adap[0].fe = dvb_attach(dib8000_attach, &adap->dev->i2c_adap, 0x80, &dib809x_dib8000_config[0]);
1709 if (adap->fe_adap[0].fe == NULL)
Olivier Greniebe9bae12011-01-04 05:42:19 -03001710 return -ENODEV;
1711
1712 fe_slave = dvb_attach(dib8000_attach, &adap->dev->i2c_adap, 0x82, &dib809x_dib8000_config[1]);
Michael Krufky77eed212011-09-06 09:31:57 -03001713 dib8000_set_slave_frontend(adap->fe_adap[0].fe, fe_slave);
Olivier Greniebe9bae12011-01-04 05:42:19 -03001714
1715 return fe_slave == NULL ? -ENODEV : 0;
1716}
1717
Olivier Grenie88f3a352011-08-10 05:28:38 -03001718/* TFE8096P */
1719static struct dibx000_agc_config dib8096p_agc_config[2] = {
1720 {
1721 .band_caps = BAND_UHF,
1722 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0,
1723 P_agc_freq_pwm_div=1, P_agc_inv_pwm1=0,
1724 P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
1725 P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5,
1726 P_agc_write=0 */
1727 .setup = (0 << 15) | (0 << 14) | (5 << 11)
1728 | (0 << 10) | (0 << 9) | (0 << 8) | (3 << 5)
1729 | (0 << 4) | (5 << 1) | (0 << 0),
1730
1731 .inv_gain = 684,
1732 .time_stabiliz = 10,
1733
1734 .alpha_level = 0,
1735 .thlock = 118,
1736
1737 .wbd_inv = 0,
1738 .wbd_ref = 1200,
1739 .wbd_sel = 3,
1740 .wbd_alpha = 5,
1741
1742 .agc1_max = 65535,
1743 .agc1_min = 0,
1744
1745 .agc2_max = 32767,
1746 .agc2_min = 0,
1747
1748 .agc1_pt1 = 0,
1749 .agc1_pt2 = 0,
1750 .agc1_pt3 = 105,
1751 .agc1_slope1 = 0,
1752 .agc1_slope2 = 156,
1753 .agc2_pt1 = 105,
1754 .agc2_pt2 = 255,
1755 .agc2_slope1 = 54,
1756 .agc2_slope2 = 0,
1757
1758 .alpha_mant = 28,
1759 .alpha_exp = 26,
1760 .beta_mant = 31,
1761 .beta_exp = 51,
1762
1763 .perform_agc_softsplit = 0,
1764 } , {
1765 .band_caps = BAND_FM | BAND_VHF | BAND_CBAND,
1766 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0,
1767 P_agc_freq_pwm_div=1, P_agc_inv_pwm1=0,
1768 P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
1769 P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5,
1770 P_agc_write=0 */
1771 .setup = (0 << 15) | (0 << 14) | (5 << 11)
1772 | (0 << 10) | (0 << 9) | (0 << 8) | (3 << 5)
1773 | (0 << 4) | (5 << 1) | (0 << 0),
1774
1775 .inv_gain = 732,
1776 .time_stabiliz = 10,
1777
1778 .alpha_level = 0,
1779 .thlock = 118,
1780
1781 .wbd_inv = 0,
1782 .wbd_ref = 1200,
1783 .wbd_sel = 3,
1784 .wbd_alpha = 5,
1785
1786 .agc1_max = 65535,
1787 .agc1_min = 0,
1788
1789 .agc2_max = 32767,
1790 .agc2_min = 0,
1791
1792 .agc1_pt1 = 0,
1793 .agc1_pt2 = 0,
1794 .agc1_pt3 = 98,
1795 .agc1_slope1 = 0,
1796 .agc1_slope2 = 167,
1797 .agc2_pt1 = 98,
1798 .agc2_pt2 = 255,
1799 .agc2_slope1 = 52,
1800 .agc2_slope2 = 0,
1801
1802 .alpha_mant = 28,
1803 .alpha_exp = 26,
1804 .beta_mant = 31,
1805 .beta_exp = 51,
1806
1807 .perform_agc_softsplit = 0,
1808 }
1809};
1810
1811static struct dibx000_bandwidth_config dib8096p_clock_config_12_mhz = {
1812 108000, 13500,
1813 1, 9, 1, 0, 0,
1814 0, 0, 0, 0, 2,
1815 (3 << 14) | (1 << 12) | (524 << 0),
1816 (0 << 25) | 0,
1817 20199729,
1818 12000000,
1819};
1820
1821static struct dib8000_config tfe8096p_dib8000_config = {
1822 .output_mpeg2_in_188_bytes = 1,
1823 .hostbus_diversity = 1,
1824 .update_lna = NULL,
1825
1826 .agc_config_count = 2,
1827 .agc = dib8096p_agc_config,
1828 .pll = &dib8096p_clock_config_12_mhz,
1829
1830 .gpio_dir = DIB8000_GPIO_DEFAULT_DIRECTIONS,
1831 .gpio_val = DIB8000_GPIO_DEFAULT_VALUES,
1832 .gpio_pwm_pos = DIB8000_GPIO_DEFAULT_PWM_POS,
1833
1834 .agc_control = NULL,
1835 .diversity_delay = 48,
1836 .output_mode = OUTMODE_MPEG2_FIFO,
1837 .enMpegOutput = 1,
1838};
1839
1840static struct dib0090_wbd_slope dib8096p_wbd_table[] = {
1841 { 380, 81, 850, 64, 540, 4},
1842 { 860, 51, 866, 21, 375, 4},
1843 {1700, 0, 250, 0, 100, 6},
1844 {2600, 0, 250, 0, 100, 6},
1845 { 0xFFFF, 0, 0, 0, 0, 0},
1846};
1847
1848static const struct dib0090_config tfe8096p_dib0090_config = {
1849 .io.clock_khz = 12000,
1850 .io.pll_bypass = 0,
1851 .io.pll_range = 0,
1852 .io.pll_prediv = 3,
1853 .io.pll_loopdiv = 6,
1854 .io.adc_clock_ratio = 0,
1855 .io.pll_int_loop_filt = 0,
1856 .reset = dib8096p_tuner_sleep,
1857 .sleep = dib8096p_tuner_sleep,
1858
1859 .freq_offset_khz_uhf = -143,
1860 .freq_offset_khz_vhf = -143,
1861
1862 .get_adc_power = dib8090_get_adc_power,
1863
1864 .clkouttobamse = 1,
1865 .analog_output = 0,
1866
1867 .wbd_vhf_offset = 0,
1868 .wbd_cband_offset = 0,
1869 .use_pwm_agc = 1,
1870 .clkoutdrive = 0,
1871
1872 .fref_clock_ratio = 1,
1873
1874 .wbd = dib8096p_wbd_table,
1875
1876 .ls_cfg_pad_drv = 0,
1877 .data_tx_drv = 0,
1878 .low_if = NULL,
1879 .in_soc = 1,
1880 .force_cband_input = 0,
1881};
1882
1883struct dibx090p_adc {
1884 u32 freq; /* RF freq MHz */
1885 u32 timf; /* New Timf */
1886 u32 pll_loopdiv; /* New prediv */
1887 u32 pll_prediv; /* New loopdiv */
1888};
1889
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001890struct dibx090p_best_adc {
1891 u32 timf;
1892 u32 pll_loopdiv;
1893 u32 pll_prediv;
Olivier Grenie88f3a352011-08-10 05:28:38 -03001894};
1895
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001896static int dib8096p_get_best_sampling(struct dvb_frontend *fe, struct dibx090p_best_adc *adc)
1897{
1898 u8 spur = 0, prediv = 0, loopdiv = 0, min_prediv = 1, max_prediv = 1;
1899 u16 xtal = 12000;
1900 u16 fcp_min = 1900; /* PLL, Minimum Frequency of phase comparator (KHz) */
1901 u16 fcp_max = 20000; /* PLL, Maximum Frequency of phase comparator (KHz) */
1902 u32 fmem_max = 140000; /* 140MHz max SDRAM freq */
1903 u32 fdem_min = 66000;
1904 u32 fcp = 0, fs = 0, fdem = 0, fmem = 0;
1905 u32 harmonic_id = 0;
1906
1907 adc->timf = 0;
1908 adc->pll_loopdiv = loopdiv;
1909 adc->pll_prediv = prediv;
1910
1911 deb_info("bandwidth = %d", fe->dtv_property_cache.bandwidth_hz);
1912
1913 /* Find Min and Max prediv */
1914 while ((xtal / max_prediv) >= fcp_min)
1915 max_prediv++;
1916
1917 max_prediv--;
1918 min_prediv = max_prediv;
1919 while ((xtal / min_prediv) <= fcp_max) {
1920 min_prediv--;
1921 if (min_prediv == 1)
1922 break;
1923 }
1924 deb_info("MIN prediv = %d : MAX prediv = %d", min_prediv, max_prediv);
1925
1926 min_prediv = 1;
1927
1928 for (prediv = min_prediv; prediv < max_prediv; prediv++) {
1929 fcp = xtal / prediv;
1930 if (fcp > fcp_min && fcp < fcp_max) {
1931 for (loopdiv = 1; loopdiv < 64; loopdiv++) {
1932 fmem = ((xtal/prediv) * loopdiv);
1933 fdem = fmem / 2;
1934 fs = fdem / 4;
1935
1936 /* test min/max system restrictions */
1937 if ((fdem >= fdem_min) && (fmem <= fmem_max) && (fs >= fe->dtv_property_cache.bandwidth_hz / 1000)) {
1938 spur = 0;
1939 /* test fs harmonics positions */
1940 for (harmonic_id = (fe->dtv_property_cache.frequency / (1000 * fs)); harmonic_id <= ((fe->dtv_property_cache.frequency / (1000 * fs)) + 1); harmonic_id++) {
1941 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)))) {
1942 spur = 1;
1943 break;
1944 }
1945 }
1946
1947 if (!spur) {
1948 adc->pll_loopdiv = loopdiv;
1949 adc->pll_prediv = prediv;
1950 adc->timf = (4260880253U / fdem) * (1 << 8);
1951 adc->timf += ((4260880253U % fdem) << 8) / fdem;
1952
1953 deb_info("RF %6d; BW %6d; Xtal %6d; Fmem %6d; Fdem %6d; Fs %6d; Prediv %2d; Loopdiv %2d; Timf %8d;", fe->dtv_property_cache.frequency, fe->dtv_property_cache.bandwidth_hz, xtal, fmem, fdem, fs, prediv, loopdiv, adc->timf);
1954 break;
1955 }
1956 }
1957 }
1958 }
1959 if (!spur)
1960 break;
1961 }
1962
1963 if (adc->pll_loopdiv == 0 && adc->pll_prediv == 0)
1964 return -EINVAL;
1965 return 0;
1966}
1967
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -03001968static int dib8096p_agc_startup(struct dvb_frontend *fe)
Olivier Grenie88f3a352011-08-10 05:28:38 -03001969{
1970 struct dvb_usb_adapter *adap = fe->dvb->priv;
1971 struct dib0700_adapter_state *state = adap->priv;
1972 struct dibx000_bandwidth_config pll;
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001973 struct dibx090p_best_adc adc;
Olivier Grenie88f3a352011-08-10 05:28:38 -03001974 u16 target;
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001975 int ret;
Olivier Grenie88f3a352011-08-10 05:28:38 -03001976
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -03001977 ret = state->set_param_save(fe);
Olivier Grenie88f3a352011-08-10 05:28:38 -03001978 if (ret < 0)
1979 return ret;
1980 memset(&pll, 0, sizeof(struct dibx000_bandwidth_config));
1981
1982 dib0090_pwm_gain_reset(fe);
1983 /* dib0090_get_wbd_target is returning any possible
1984 temperature compensated wbd-target */
1985 target = (dib0090_get_wbd_target(fe) * 8 + 1) / 2;
1986 dib8000_set_wbd_ref(fe, target);
1987
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001988 if (dib8096p_get_best_sampling(fe, &adc) == 0) {
1989 pll.pll_ratio = adc.pll_loopdiv;
1990 pll.pll_prediv = adc.pll_prediv;
Olivier Grenie88f3a352011-08-10 05:28:38 -03001991
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001992 dib0700_set_i2c_speed(adap->dev, 200);
Patrick Boettcher173a64c2013-04-22 12:45:52 -03001993 dib8000_update_pll(fe, &pll, fe->dtv_property_cache.bandwidth_hz / 1000, 0);
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001994 dib8000_ctrl_timf(fe, DEMOD_TIMF_SET, adc.timf);
1995 dib0700_set_i2c_speed(adap->dev, 1000);
Olivier Grenie88f3a352011-08-10 05:28:38 -03001996 }
1997 return 0;
1998}
1999
2000static int tfe8096p_frontend_attach(struct dvb_usb_adapter *adap)
2001{
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03002002 struct dib0700_state *st = adap->dev->priv;
2003 u32 fw_version;
2004
2005 dib0700_get_version(adap->dev, NULL, NULL, &fw_version, NULL);
2006 if (fw_version >= 0x10200)
2007 st->fw_use_new_i2c_api = 1;
2008
Olivier Grenie88f3a352011-08-10 05:28:38 -03002009 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
2010 msleep(20);
2011 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
2012 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
2013 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
2014
2015 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
2016
2017 dib0700_ctrl_clock(adap->dev, 72, 1);
2018
2019 msleep(20);
2020 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
2021 msleep(20);
2022 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
2023
2024 dib8000_i2c_enumeration(&adap->dev->i2c_adap, 1, 0x10, 0x80, 1);
2025
2026 adap->fe_adap[0].fe = dvb_attach(dib8000_attach,
2027 &adap->dev->i2c_adap, 0x80, &tfe8096p_dib8000_config);
2028
2029 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
2030}
2031
2032static int tfe8096p_tuner_attach(struct dvb_usb_adapter *adap)
2033{
2034 struct dib0700_adapter_state *st = adap->priv;
2035 struct i2c_adapter *tun_i2c = dib8096p_get_i2c_tuner(adap->fe_adap[0].fe);
2036
2037 if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c,
2038 &tfe8096p_dib0090_config) == NULL)
2039 return -ENODEV;
2040
2041 dib8000_set_gpio(adap->fe_adap[0].fe, 8, 0, 1);
2042
2043 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
2044 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib8096p_agc_startup;
2045 return 0;
2046}
2047
Olivier Greniebe9bae12011-01-04 05:42:19 -03002048/* STK9090M */
2049static int dib90x0_pid_filter(struct dvb_usb_adapter *adapter, int index, u16 pid, int onoff)
2050{
Michael Krufky77eed212011-09-06 09:31:57 -03002051 return dib9000_fw_pid_filter(adapter->fe_adap[0].fe, index, pid, onoff);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002052}
2053
2054static int dib90x0_pid_filter_ctrl(struct dvb_usb_adapter *adapter, int onoff)
2055{
Michael Krufky77eed212011-09-06 09:31:57 -03002056 return dib9000_fw_pid_filter_ctrl(adapter->fe_adap[0].fe, onoff);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002057}
2058
2059static int dib90x0_tuner_reset(struct dvb_frontend *fe, int onoff)
2060{
2061 return dib9000_set_gpio(fe, 5, 0, !onoff);
2062}
2063
2064static int dib90x0_tuner_sleep(struct dvb_frontend *fe, int onoff)
2065{
2066 return dib9000_set_gpio(fe, 0, 0, onoff);
2067}
2068
2069static int dib01x0_pmu_update(struct i2c_adapter *i2c, u16 *data, u8 len)
2070{
2071 u8 wb[4] = { 0xc >> 8, 0xc & 0xff, 0, 0 };
2072 u8 rb[2];
2073 struct i2c_msg msg[2] = {
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002074 {.addr = 0x1e >> 1, .flags = 0, .buf = wb, .len = 2},
2075 {.addr = 0x1e >> 1, .flags = I2C_M_RD, .buf = rb, .len = 2},
Olivier Greniebe9bae12011-01-04 05:42:19 -03002076 };
2077 u8 index_data;
2078
2079 dibx000_i2c_set_speed(i2c, 250);
2080
2081 if (i2c_transfer(i2c, msg, 2) != 2)
2082 return -EIO;
2083
2084 switch (rb[0] << 8 | rb[1]) {
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002085 case 0:
Olivier Greniebe9bae12011-01-04 05:42:19 -03002086 deb_info("Found DiB0170 rev1: This version of DiB0170 is not supported any longer.\n");
2087 return -EIO;
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002088 case 1:
Olivier Greniebe9bae12011-01-04 05:42:19 -03002089 deb_info("Found DiB0170 rev2");
2090 break;
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002091 case 2:
Olivier Greniebe9bae12011-01-04 05:42:19 -03002092 deb_info("Found DiB0190 rev2");
2093 break;
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002094 default:
Olivier Greniebe9bae12011-01-04 05:42:19 -03002095 deb_info("DiB01x0 not found");
2096 return -EIO;
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002097 }
Olivier Greniebe9bae12011-01-04 05:42:19 -03002098
2099 for (index_data = 0; index_data < len; index_data += 2) {
2100 wb[2] = (data[index_data + 1] >> 8) & 0xff;
2101 wb[3] = (data[index_data + 1]) & 0xff;
2102
2103 if (data[index_data] == 0) {
2104 wb[0] = (data[index_data] >> 8) & 0xff;
2105 wb[1] = (data[index_data]) & 0xff;
2106 msg[0].len = 2;
2107 if (i2c_transfer(i2c, msg, 2) != 2)
2108 return -EIO;
2109 wb[2] |= rb[0];
2110 wb[3] |= rb[1] & ~(3 << 4);
2111 }
2112
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002113 wb[0] = (data[index_data] >> 8)&0xff;
2114 wb[1] = (data[index_data])&0xff;
Olivier Greniebe9bae12011-01-04 05:42:19 -03002115 msg[0].len = 4;
2116 if (i2c_transfer(i2c, &msg[0], 1) != 1)
2117 return -EIO;
2118 }
2119 return 0;
2120}
2121
2122static struct dib9000_config stk9090m_config = {
2123 .output_mpeg2_in_188_bytes = 1,
2124 .output_mode = OUTMODE_MPEG2_FIFO,
2125 .vcxo_timer = 279620,
2126 .timing_frequency = 20452225,
2127 .demod_clock_khz = 60000,
2128 .xtal_clock_khz = 30000,
2129 .if_drives = (0 << 15) | (1 << 13) | (0 << 12) | (3 << 10) | (0 << 9) | (1 << 7) | (0 << 6) | (0 << 4) | (1 << 3) | (1 << 1) | (0),
2130 .subband = {
2131 2,
2132 {
2133 { 240, { BOARD_GPIO_COMPONENT_DEMOD, BOARD_GPIO_FUNCTION_SUBBAND_GPIO, 0x0008, 0x0000, 0x0008 } }, /* GPIO 3 to 1 for VHF */
2134 { 890, { BOARD_GPIO_COMPONENT_DEMOD, BOARD_GPIO_FUNCTION_SUBBAND_GPIO, 0x0008, 0x0000, 0x0000 } }, /* GPIO 3 to 0 for UHF */
2135 { 0 },
2136 },
2137 },
2138 .gpio_function = {
2139 { .component = BOARD_GPIO_COMPONENT_DEMOD, .function = BOARD_GPIO_FUNCTION_COMPONENT_ON, .mask = 0x10 | 0x21, .direction = 0 & ~0x21, .value = (0x10 & ~0x1) | 0x20 },
2140 { .component = BOARD_GPIO_COMPONENT_DEMOD, .function = BOARD_GPIO_FUNCTION_COMPONENT_OFF, .mask = 0x10 | 0x21, .direction = 0 & ~0x21, .value = 0 | 0x21 },
2141 },
2142};
2143
2144static struct dib9000_config nim9090md_config[2] = {
2145 {
2146 .output_mpeg2_in_188_bytes = 1,
2147 .output_mode = OUTMODE_MPEG2_FIFO,
2148 .vcxo_timer = 279620,
2149 .timing_frequency = 20452225,
2150 .demod_clock_khz = 60000,
2151 .xtal_clock_khz = 30000,
2152 .if_drives = (0 << 15) | (1 << 13) | (0 << 12) | (3 << 10) | (0 << 9) | (1 << 7) | (0 << 6) | (0 << 4) | (1 << 3) | (1 << 1) | (0),
2153 }, {
2154 .output_mpeg2_in_188_bytes = 1,
2155 .output_mode = OUTMODE_DIVERSITY,
2156 .vcxo_timer = 279620,
2157 .timing_frequency = 20452225,
2158 .demod_clock_khz = 60000,
2159 .xtal_clock_khz = 30000,
2160 .if_drives = (0 << 15) | (1 << 13) | (0 << 12) | (3 << 10) | (0 << 9) | (1 << 7) | (0 << 6) | (0 << 4) | (1 << 3) | (1 << 1) | (0),
2161 .subband = {
2162 2,
2163 {
2164 { 240, { BOARD_GPIO_COMPONENT_DEMOD, BOARD_GPIO_FUNCTION_SUBBAND_GPIO, 0x0006, 0x0000, 0x0006 } }, /* GPIO 1 and 2 to 1 for VHF */
2165 { 890, { BOARD_GPIO_COMPONENT_DEMOD, BOARD_GPIO_FUNCTION_SUBBAND_GPIO, 0x0006, 0x0000, 0x0000 } }, /* GPIO 1 and 2 to 0 for UHF */
2166 { 0 },
2167 },
2168 },
2169 .gpio_function = {
2170 { .component = BOARD_GPIO_COMPONENT_DEMOD, .function = BOARD_GPIO_FUNCTION_COMPONENT_ON, .mask = 0x10 | 0x21, .direction = 0 & ~0x21, .value = (0x10 & ~0x1) | 0x20 },
2171 { .component = BOARD_GPIO_COMPONENT_DEMOD, .function = BOARD_GPIO_FUNCTION_COMPONENT_OFF, .mask = 0x10 | 0x21, .direction = 0 & ~0x21, .value = 0 | 0x21 },
2172 },
2173 }
2174};
2175
2176static struct dib0090_config dib9090_dib0090_config = {
2177 .io.pll_bypass = 0,
2178 .io.pll_range = 1,
2179 .io.pll_prediv = 1,
2180 .io.pll_loopdiv = 8,
2181 .io.adc_clock_ratio = 8,
2182 .io.pll_int_loop_filt = 0,
2183 .io.clock_khz = 30000,
2184 .reset = dib90x0_tuner_reset,
2185 .sleep = dib90x0_tuner_sleep,
2186 .clkouttobamse = 0,
2187 .analog_output = 0,
2188 .use_pwm_agc = 0,
2189 .clkoutdrive = 0,
2190 .freq_offset_khz_uhf = 0,
2191 .freq_offset_khz_vhf = 0,
2192};
2193
2194static struct dib0090_config nim9090md_dib0090_config[2] = {
2195 {
2196 .io.pll_bypass = 0,
2197 .io.pll_range = 1,
2198 .io.pll_prediv = 1,
2199 .io.pll_loopdiv = 8,
2200 .io.adc_clock_ratio = 8,
2201 .io.pll_int_loop_filt = 0,
2202 .io.clock_khz = 30000,
2203 .reset = dib90x0_tuner_reset,
2204 .sleep = dib90x0_tuner_sleep,
2205 .clkouttobamse = 1,
2206 .analog_output = 0,
2207 .use_pwm_agc = 0,
2208 .clkoutdrive = 0,
2209 .freq_offset_khz_uhf = 0,
2210 .freq_offset_khz_vhf = 0,
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002211 }, {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002212 .io.pll_bypass = 0,
2213 .io.pll_range = 1,
2214 .io.pll_prediv = 1,
2215 .io.pll_loopdiv = 8,
2216 .io.adc_clock_ratio = 8,
2217 .io.pll_int_loop_filt = 0,
2218 .io.clock_khz = 30000,
2219 .reset = dib90x0_tuner_reset,
2220 .sleep = dib90x0_tuner_sleep,
2221 .clkouttobamse = 0,
2222 .analog_output = 0,
2223 .use_pwm_agc = 0,
2224 .clkoutdrive = 0,
2225 .freq_offset_khz_uhf = 0,
2226 .freq_offset_khz_vhf = 0,
2227 }
2228};
2229
2230
2231static int stk9090m_frontend_attach(struct dvb_usb_adapter *adap)
2232{
2233 struct dib0700_adapter_state *state = adap->priv;
2234 struct dib0700_state *st = adap->dev->priv;
2235 u32 fw_version;
2236
2237 /* Make use of the new i2c functions from FW 1.20 */
2238 dib0700_get_version(adap->dev, NULL, NULL, &fw_version, NULL);
2239 if (fw_version >= 0x10200)
2240 st->fw_use_new_i2c_api = 1;
2241 dib0700_set_i2c_speed(adap->dev, 340);
2242
2243 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002244 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002245 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
2246 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
2247 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
2248 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
2249
2250 dib0700_ctrl_clock(adap->dev, 72, 1);
2251
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002252 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002253 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002254 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002255 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
2256
2257 dib9000_i2c_enumeration(&adap->dev->i2c_adap, 1, 0x10, 0x80);
2258
2259 if (request_firmware(&state->frontend_firmware, "dib9090.fw", &adap->dev->udev->dev)) {
2260 deb_info("%s: Upload failed. (file not found?)\n", __func__);
2261 return -ENODEV;
2262 } else {
2263 deb_info("%s: firmware read %Zu bytes.\n", __func__, state->frontend_firmware->size);
2264 }
2265 stk9090m_config.microcode_B_fe_size = state->frontend_firmware->size;
2266 stk9090m_config.microcode_B_fe_buffer = state->frontend_firmware->data;
2267
Michael Krufky77eed212011-09-06 09:31:57 -03002268 adap->fe_adap[0].fe = dvb_attach(dib9000_attach, &adap->dev->i2c_adap, 0x80, &stk9090m_config);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002269
Michael Krufky77eed212011-09-06 09:31:57 -03002270 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Olivier Greniebe9bae12011-01-04 05:42:19 -03002271}
2272
2273static int dib9090_tuner_attach(struct dvb_usb_adapter *adap)
2274{
2275 struct dib0700_adapter_state *state = adap->priv;
Michael Krufky77eed212011-09-06 09:31:57 -03002276 struct i2c_adapter *i2c = dib9000_get_tuner_interface(adap->fe_adap[0].fe);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002277 u16 data_dib190[10] = {
2278 1, 0x1374,
2279 2, 0x01a2,
2280 7, 0x0020,
2281 0, 0x00ef,
2282 8, 0x0486,
2283 };
2284
Michael Krufky77eed212011-09-06 09:31:57 -03002285 if (dvb_attach(dib0090_fw_register, adap->fe_adap[0].fe, i2c, &dib9090_dib0090_config) == NULL)
Olivier Greniebe9bae12011-01-04 05:42:19 -03002286 return -ENODEV;
Michael Krufky77eed212011-09-06 09:31:57 -03002287 i2c = dib9000_get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_GPIO_1_2, 0);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002288 if (dib01x0_pmu_update(i2c, data_dib190, 10) != 0)
2289 return -ENODEV;
Olivier Grenied1190022011-08-29 10:58:47 -03002290 dib0700_set_i2c_speed(adap->dev, 1500);
Michael Krufky77eed212011-09-06 09:31:57 -03002291 if (dib9000_firmware_post_pll_init(adap->fe_adap[0].fe) < 0)
Olivier Greniebe9bae12011-01-04 05:42:19 -03002292 return -ENODEV;
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002293 release_firmware(state->frontend_firmware);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002294 return 0;
2295}
2296
2297static int nim9090md_frontend_attach(struct dvb_usb_adapter *adap)
2298{
2299 struct dib0700_adapter_state *state = adap->priv;
2300 struct dib0700_state *st = adap->dev->priv;
2301 struct i2c_adapter *i2c;
2302 struct dvb_frontend *fe_slave;
2303 u32 fw_version;
2304
2305 /* Make use of the new i2c functions from FW 1.20 */
2306 dib0700_get_version(adap->dev, NULL, NULL, &fw_version, NULL);
2307 if (fw_version >= 0x10200)
2308 st->fw_use_new_i2c_api = 1;
2309 dib0700_set_i2c_speed(adap->dev, 340);
2310
2311 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002312 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002313 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
2314 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
2315 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
2316 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
2317
2318 dib0700_ctrl_clock(adap->dev, 72, 1);
2319
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002320 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002321 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002322 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002323 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
2324
2325 if (request_firmware(&state->frontend_firmware, "dib9090.fw", &adap->dev->udev->dev)) {
2326 deb_info("%s: Upload failed. (file not found?)\n", __func__);
2327 return -EIO;
2328 } else {
2329 deb_info("%s: firmware read %Zu bytes.\n", __func__, state->frontend_firmware->size);
2330 }
2331 nim9090md_config[0].microcode_B_fe_size = state->frontend_firmware->size;
2332 nim9090md_config[0].microcode_B_fe_buffer = state->frontend_firmware->data;
2333 nim9090md_config[1].microcode_B_fe_size = state->frontend_firmware->size;
2334 nim9090md_config[1].microcode_B_fe_buffer = state->frontend_firmware->data;
2335
2336 dib9000_i2c_enumeration(&adap->dev->i2c_adap, 1, 0x20, 0x80);
Michael Krufky77eed212011-09-06 09:31:57 -03002337 adap->fe_adap[0].fe = dvb_attach(dib9000_attach, &adap->dev->i2c_adap, 0x80, &nim9090md_config[0]);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002338
Michael Krufky77eed212011-09-06 09:31:57 -03002339 if (adap->fe_adap[0].fe == NULL)
Olivier Greniebe9bae12011-01-04 05:42:19 -03002340 return -ENODEV;
2341
Michael Krufky77eed212011-09-06 09:31:57 -03002342 i2c = dib9000_get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_GPIO_3_4, 0);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002343 dib9000_i2c_enumeration(i2c, 1, 0x12, 0x82);
2344
2345 fe_slave = dvb_attach(dib9000_attach, i2c, 0x82, &nim9090md_config[1]);
Michael Krufky77eed212011-09-06 09:31:57 -03002346 dib9000_set_slave_frontend(adap->fe_adap[0].fe, fe_slave);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002347
2348 return fe_slave == NULL ? -ENODEV : 0;
2349}
2350
2351static int nim9090md_tuner_attach(struct dvb_usb_adapter *adap)
2352{
2353 struct dib0700_adapter_state *state = adap->priv;
2354 struct i2c_adapter *i2c;
2355 struct dvb_frontend *fe_slave;
2356 u16 data_dib190[10] = {
2357 1, 0x5374,
2358 2, 0x01ae,
2359 7, 0x0020,
2360 0, 0x00ef,
2361 8, 0x0406,
2362 };
Michael Krufky77eed212011-09-06 09:31:57 -03002363 i2c = dib9000_get_tuner_interface(adap->fe_adap[0].fe);
2364 if (dvb_attach(dib0090_fw_register, adap->fe_adap[0].fe, i2c, &nim9090md_dib0090_config[0]) == NULL)
Olivier Greniebe9bae12011-01-04 05:42:19 -03002365 return -ENODEV;
Michael Krufky77eed212011-09-06 09:31:57 -03002366 i2c = dib9000_get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_GPIO_1_2, 0);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002367 if (dib01x0_pmu_update(i2c, data_dib190, 10) < 0)
2368 return -ENODEV;
Olivier Grenied1190022011-08-29 10:58:47 -03002369
2370 dib0700_set_i2c_speed(adap->dev, 1500);
Michael Krufky77eed212011-09-06 09:31:57 -03002371 if (dib9000_firmware_post_pll_init(adap->fe_adap[0].fe) < 0)
Olivier Greniebe9bae12011-01-04 05:42:19 -03002372 return -ENODEV;
2373
Michael Krufky77eed212011-09-06 09:31:57 -03002374 fe_slave = dib9000_get_slave_frontend(adap->fe_adap[0].fe, 1);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002375 if (fe_slave != NULL) {
Michael Krufky77eed212011-09-06 09:31:57 -03002376 i2c = dib9000_get_component_bus_interface(adap->fe_adap[0].fe);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002377 dib9000_set_i2c_adapter(fe_slave, i2c);
2378
2379 i2c = dib9000_get_tuner_interface(fe_slave);
2380 if (dvb_attach(dib0090_fw_register, fe_slave, i2c, &nim9090md_dib0090_config[1]) == NULL)
2381 return -ENODEV;
Michael Krufky77eed212011-09-06 09:31:57 -03002382 fe_slave->dvb = adap->fe_adap[0].fe->dvb;
Olivier Grenied1190022011-08-29 10:58:47 -03002383 dib9000_fw_set_component_bus_speed(adap->fe_adap[0].fe, 1500);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002384 if (dib9000_firmware_post_pll_init(fe_slave) < 0)
2385 return -ENODEV;
2386 }
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002387 release_firmware(state->frontend_firmware);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002388
2389 return 0;
2390}
2391
2392/* NIM7090 */
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03002393static int dib7090p_get_best_sampling(struct dvb_frontend *fe , struct dibx090p_best_adc *adc)
Olivier Greniebe9bae12011-01-04 05:42:19 -03002394{
2395 u8 spur = 0, prediv = 0, loopdiv = 0, min_prediv = 1, max_prediv = 1;
2396
2397 u16 xtal = 12000;
2398 u32 fcp_min = 1900; /* PLL Minimum Frequency comparator KHz */
2399 u32 fcp_max = 20000; /* PLL Maximum Frequency comparator KHz */
2400 u32 fdem_max = 76000;
2401 u32 fdem_min = 69500;
2402 u32 fcp = 0, fs = 0, fdem = 0;
2403 u32 harmonic_id = 0;
2404
2405 adc->pll_loopdiv = loopdiv;
2406 adc->pll_prediv = prediv;
2407 adc->timf = 0;
2408
2409 deb_info("bandwidth = %d fdem_min =%d", fe->dtv_property_cache.bandwidth_hz, fdem_min);
2410
2411 /* Find Min and Max prediv */
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002412 while ((xtal/max_prediv) >= fcp_min)
Olivier Greniebe9bae12011-01-04 05:42:19 -03002413 max_prediv++;
2414
2415 max_prediv--;
2416 min_prediv = max_prediv;
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002417 while ((xtal/min_prediv) <= fcp_max) {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002418 min_prediv--;
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002419 if (min_prediv == 1)
Olivier Greniebe9bae12011-01-04 05:42:19 -03002420 break;
2421 }
2422 deb_info("MIN prediv = %d : MAX prediv = %d", min_prediv, max_prediv);
2423
2424 min_prediv = 2;
2425
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002426 for (prediv = min_prediv ; prediv < max_prediv; prediv++) {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002427 fcp = xtal / prediv;
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002428 if (fcp > fcp_min && fcp < fcp_max) {
2429 for (loopdiv = 1 ; loopdiv < 64 ; loopdiv++) {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002430 fdem = ((xtal/prediv) * loopdiv);
2431 fs = fdem / 4;
2432 /* test min/max system restrictions */
2433
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002434 if ((fdem >= fdem_min) && (fdem <= fdem_max) && (fs >= fe->dtv_property_cache.bandwidth_hz/1000)) {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002435 spur = 0;
2436 /* test fs harmonics positions */
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002437 for (harmonic_id = (fe->dtv_property_cache.frequency / (1000*fs)) ; harmonic_id <= ((fe->dtv_property_cache.frequency / (1000*fs))+1) ; harmonic_id++) {
2438 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 -03002439 spur = 1;
2440 break;
2441 }
2442 }
2443
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002444 if (!spur) {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002445 adc->pll_loopdiv = loopdiv;
2446 adc->pll_prediv = prediv;
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002447 adc->timf = 2396745143UL/fdem*(1 << 9);
2448 adc->timf += ((2396745143UL%fdem) << 9)/fdem;
Olivier Greniebe9bae12011-01-04 05:42:19 -03002449 deb_info("loopdiv=%i prediv=%i timf=%i", loopdiv, prediv, adc->timf);
2450 break;
2451 }
2452 }
2453 }
2454 }
2455 if (!spur)
2456 break;
2457 }
2458
2459
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002460 if (adc->pll_loopdiv == 0 && adc->pll_prediv == 0)
Olivier Greniebe9bae12011-01-04 05:42:19 -03002461 return -EINVAL;
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002462 else
Olivier Greniebe9bae12011-01-04 05:42:19 -03002463 return 0;
2464}
2465
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -03002466static int dib7090_agc_startup(struct dvb_frontend *fe)
Olivier Greniebe9bae12011-01-04 05:42:19 -03002467{
2468 struct dvb_usb_adapter *adap = fe->dvb->priv;
2469 struct dib0700_adapter_state *state = adap->priv;
2470 struct dibx000_bandwidth_config pll;
2471 u16 target;
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03002472 struct dibx090p_best_adc adc;
Olivier Greniebe9bae12011-01-04 05:42:19 -03002473 int ret;
2474
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -03002475 ret = state->set_param_save(fe);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002476 if (ret < 0)
2477 return ret;
2478
2479 memset(&pll, 0, sizeof(struct dibx000_bandwidth_config));
2480 dib0090_pwm_gain_reset(fe);
Olivier Grenie6724a2f2011-08-05 13:49:33 -03002481 target = (dib0090_get_wbd_target(fe) * 8 + 1) / 2;
Olivier Greniebe9bae12011-01-04 05:42:19 -03002482 dib7000p_set_wbd_ref(fe, target);
2483
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002484 if (dib7090p_get_best_sampling(fe, &adc) == 0) {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002485 pll.pll_ratio = adc.pll_loopdiv;
2486 pll.pll_prediv = adc.pll_prediv;
2487
2488 dib7000p_update_pll(fe, &pll);
2489 dib7000p_ctrl_timf(fe, DEMOD_TIMF_SET, adc.timf);
2490 }
2491 return 0;
2492}
2493
Olivier Grenie2e802862011-08-05 10:39:15 -03002494static int dib7090_agc_restart(struct dvb_frontend *fe, u8 restart)
2495{
2496 deb_info("AGC restart callback: %d", restart);
2497 if (restart == 0) /* before AGC startup */
2498 dib0090_set_dc_servo(fe, 1);
2499 return 0;
2500}
2501
Olivier Grenief45f5132012-12-31 09:47:10 -03002502static int tfe7790p_update_lna(struct dvb_frontend *fe, u16 agc_global)
Olivier Grenie6724a2f2011-08-05 13:49:33 -03002503{
Olivier Grenief45f5132012-12-31 09:47:10 -03002504 deb_info("update LNA: agc global=%i", agc_global);
Olivier Grenie6724a2f2011-08-05 13:49:33 -03002505
Olivier Grenief45f5132012-12-31 09:47:10 -03002506 if (agc_global < 25000) {
2507 dib7000p_set_gpio(fe, 8, 0, 0);
2508 dib7000p_set_agc1_min(fe, 0);
Olivier Grenie6724a2f2011-08-05 13:49:33 -03002509 } else {
Olivier Grenief45f5132012-12-31 09:47:10 -03002510 dib7000p_set_gpio(fe, 8, 0, 1);
2511 dib7000p_set_agc1_min(fe, 32768);
Olivier Grenie6724a2f2011-08-05 13:49:33 -03002512 }
2513
2514 return 0;
2515}
2516
Olivier Greniebe9bae12011-01-04 05:42:19 -03002517static struct dib0090_wbd_slope dib7090_wbd_table[] = {
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002518 { 380, 81, 850, 64, 540, 4},
2519 { 860, 51, 866, 21, 375, 4},
2520 {1700, 0, 250, 0, 100, 6},
2521 {2600, 0, 250, 0, 100, 6},
2522 { 0xFFFF, 0, 0, 0, 0, 0},
Olivier Greniebe9bae12011-01-04 05:42:19 -03002523};
2524
Olivier Greniea685dbb2011-08-05 14:10:40 -03002525static struct dibx000_agc_config dib7090_agc_config[2] = {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002526 {
2527 .band_caps = BAND_UHF,
2528 /* 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,
2529 * 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 -03002530 .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 -03002531
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002532 .inv_gain = 687,
2533 .time_stabiliz = 10,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002534
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002535 .alpha_level = 0,
2536 .thlock = 118,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002537
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002538 .wbd_inv = 0,
2539 .wbd_ref = 1200,
2540 .wbd_sel = 3,
2541 .wbd_alpha = 5,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002542
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002543 .agc1_max = 65535,
Olivier Grenie59501bb2012-12-31 09:51:17 -03002544 .agc1_min = 32768,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002545
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002546 .agc2_max = 65535,
2547 .agc2_min = 0,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002548
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002549 .agc1_pt1 = 0,
2550 .agc1_pt2 = 32,
2551 .agc1_pt3 = 114,
2552 .agc1_slope1 = 143,
2553 .agc1_slope2 = 144,
2554 .agc2_pt1 = 114,
2555 .agc2_pt2 = 227,
2556 .agc2_slope1 = 116,
2557 .agc2_slope2 = 117,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002558
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002559 .alpha_mant = 18,
2560 .alpha_exp = 0,
2561 .beta_mant = 20,
2562 .beta_exp = 59,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002563
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002564 .perform_agc_softsplit = 0,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002565 } , {
2566 .band_caps = BAND_FM | BAND_VHF | BAND_CBAND,
2567 /* 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,
2568 * 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 -03002569 .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 -03002570
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002571 .inv_gain = 732,
2572 .time_stabiliz = 10,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002573
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002574 .alpha_level = 0,
2575 .thlock = 118,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002576
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002577 .wbd_inv = 0,
2578 .wbd_ref = 1200,
2579 .wbd_sel = 3,
2580 .wbd_alpha = 5,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002581
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002582 .agc1_max = 65535,
2583 .agc1_min = 0,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002584
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002585 .agc2_max = 65535,
2586 .agc2_min = 0,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002587
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002588 .agc1_pt1 = 0,
2589 .agc1_pt2 = 0,
2590 .agc1_pt3 = 98,
2591 .agc1_slope1 = 0,
2592 .agc1_slope2 = 167,
Patrick Boettcher7f4d5272011-04-03 12:28:08 -03002593 .agc2_pt1 = 98,
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002594 .agc2_pt2 = 255,
2595 .agc2_slope1 = 104,
2596 .agc2_slope2 = 0,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002597
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002598 .alpha_mant = 18,
2599 .alpha_exp = 0,
2600 .beta_mant = 20,
2601 .beta_exp = 59,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002602
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002603 .perform_agc_softsplit = 0,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002604 }
2605};
2606
2607static struct dibx000_bandwidth_config dib7090_clock_config_12_mhz = {
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002608 60000, 15000,
2609 1, 5, 0, 0, 0,
2610 0, 0, 1, 1, 2,
2611 (3 << 14) | (1 << 12) | (524 << 0),
2612 (0 << 25) | 0,
2613 20452225,
2614 15000000,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002615};
2616
2617static struct dib7000p_config nim7090_dib7000p_config = {
2618 .output_mpeg2_in_188_bytes = 1,
2619 .hostbus_diversity = 1,
2620 .tuner_is_baseband = 1,
Olivier Grenie59501bb2012-12-31 09:51:17 -03002621 .update_lna = tfe7790p_update_lna, /* GPIO used is the same as TFE7790 */
Olivier Greniebe9bae12011-01-04 05:42:19 -03002622
2623 .agc_config_count = 2,
2624 .agc = dib7090_agc_config,
2625
2626 .bw = &dib7090_clock_config_12_mhz,
2627
2628 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
2629 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
2630 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
2631
2632 .pwm_freq_div = 0,
2633
2634 .agc_control = dib7090_agc_restart,
2635
2636 .spur_protect = 0,
2637 .disable_sample_and_hold = 0,
2638 .enable_current_mirror = 0,
2639 .diversity_delay = 0,
2640
2641 .output_mode = OUTMODE_MPEG2_FIFO,
2642 .enMpegOutput = 1,
2643};
2644
Olivier Grenie59501bb2012-12-31 09:51:17 -03002645static int tfe7090p_pvr_update_lna(struct dvb_frontend *fe, u16 agc_global)
2646{
2647 deb_info("TFE7090P-PVR update LNA: agc global=%i", agc_global);
2648 if (agc_global < 25000) {
2649 dib7000p_set_gpio(fe, 5, 0, 0);
2650 dib7000p_set_agc1_min(fe, 0);
2651 } else {
2652 dib7000p_set_gpio(fe, 5, 0, 1);
2653 dib7000p_set_agc1_min(fe, 32768);
2654 }
2655
2656 return 0;
2657}
2658
Olivier Greniebe9bae12011-01-04 05:42:19 -03002659static struct dib7000p_config tfe7090pvr_dib7000p_config[2] = {
2660 {
2661 .output_mpeg2_in_188_bytes = 1,
2662 .hostbus_diversity = 1,
2663 .tuner_is_baseband = 1,
Olivier Grenie59501bb2012-12-31 09:51:17 -03002664 .update_lna = tfe7090p_pvr_update_lna,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002665
2666 .agc_config_count = 2,
2667 .agc = dib7090_agc_config,
2668
2669 .bw = &dib7090_clock_config_12_mhz,
2670
2671 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
2672 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
2673 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
2674
2675 .pwm_freq_div = 0,
2676
2677 .agc_control = dib7090_agc_restart,
2678
2679 .spur_protect = 0,
2680 .disable_sample_and_hold = 0,
2681 .enable_current_mirror = 0,
2682 .diversity_delay = 0,
2683
2684 .output_mode = OUTMODE_MPEG2_PAR_GATED_CLK,
2685 .default_i2c_addr = 0x90,
2686 .enMpegOutput = 1,
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002687 }, {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002688 .output_mpeg2_in_188_bytes = 1,
2689 .hostbus_diversity = 1,
2690 .tuner_is_baseband = 1,
Olivier Grenie59501bb2012-12-31 09:51:17 -03002691 .update_lna = tfe7090p_pvr_update_lna,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002692
2693 .agc_config_count = 2,
2694 .agc = dib7090_agc_config,
2695
2696 .bw = &dib7090_clock_config_12_mhz,
2697
2698 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
2699 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
2700 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
2701
2702 .pwm_freq_div = 0,
2703
2704 .agc_control = dib7090_agc_restart,
2705
2706 .spur_protect = 0,
2707 .disable_sample_and_hold = 0,
2708 .enable_current_mirror = 0,
2709 .diversity_delay = 0,
2710
2711 .output_mode = OUTMODE_MPEG2_PAR_GATED_CLK,
2712 .default_i2c_addr = 0x92,
2713 .enMpegOutput = 0,
2714 }
2715};
2716
2717static const struct dib0090_config nim7090_dib0090_config = {
2718 .io.clock_khz = 12000,
2719 .io.pll_bypass = 0,
2720 .io.pll_range = 0,
2721 .io.pll_prediv = 3,
2722 .io.pll_loopdiv = 6,
2723 .io.adc_clock_ratio = 0,
2724 .io.pll_int_loop_filt = 0,
2725 .reset = dib7090_tuner_sleep,
2726 .sleep = dib7090_tuner_sleep,
2727
2728 .freq_offset_khz_uhf = 0,
2729 .freq_offset_khz_vhf = 0,
2730
2731 .get_adc_power = dib7090_get_adc_power,
2732
2733 .clkouttobamse = 1,
2734 .analog_output = 0,
2735
2736 .wbd_vhf_offset = 0,
2737 .wbd_cband_offset = 0,
2738 .use_pwm_agc = 1,
2739 .clkoutdrive = 0,
2740
2741 .fref_clock_ratio = 0,
2742
2743 .wbd = dib7090_wbd_table,
2744
2745 .ls_cfg_pad_drv = 0,
2746 .data_tx_drv = 0,
2747 .low_if = NULL,
2748 .in_soc = 1,
2749};
2750
Olivier Grenief45f5132012-12-31 09:47:10 -03002751static struct dib7000p_config tfe7790p_dib7000p_config = {
Olivier Grenieb293f302011-08-09 04:48:25 -03002752 .output_mpeg2_in_188_bytes = 1,
2753 .hostbus_diversity = 1,
2754 .tuner_is_baseband = 1,
Olivier Grenief45f5132012-12-31 09:47:10 -03002755 .update_lna = tfe7790p_update_lna,
Olivier Grenieb293f302011-08-09 04:48:25 -03002756
2757 .agc_config_count = 2,
2758 .agc = dib7090_agc_config,
2759
2760 .bw = &dib7090_clock_config_12_mhz,
2761
2762 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
2763 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
2764 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
2765
2766 .pwm_freq_div = 0,
2767
2768 .agc_control = dib7090_agc_restart,
2769
2770 .spur_protect = 0,
2771 .disable_sample_and_hold = 0,
2772 .enable_current_mirror = 0,
2773 .diversity_delay = 0,
2774
2775 .output_mode = OUTMODE_MPEG2_PAR_GATED_CLK,
2776 .enMpegOutput = 1,
2777};
2778
Olivier Grenief45f5132012-12-31 09:47:10 -03002779static const struct dib0090_config tfe7790p_dib0090_config = {
Olivier Grenieb293f302011-08-09 04:48:25 -03002780 .io.clock_khz = 12000,
2781 .io.pll_bypass = 0,
2782 .io.pll_range = 0,
2783 .io.pll_prediv = 3,
2784 .io.pll_loopdiv = 6,
2785 .io.adc_clock_ratio = 0,
2786 .io.pll_int_loop_filt = 0,
2787 .reset = dib7090_tuner_sleep,
2788 .sleep = dib7090_tuner_sleep,
2789
2790 .freq_offset_khz_uhf = 0,
2791 .freq_offset_khz_vhf = 0,
2792
2793 .get_adc_power = dib7090_get_adc_power,
2794
2795 .clkouttobamse = 1,
2796 .analog_output = 0,
2797
2798 .wbd_vhf_offset = 0,
2799 .wbd_cband_offset = 0,
2800 .use_pwm_agc = 1,
2801 .clkoutdrive = 0,
2802
2803 .fref_clock_ratio = 0,
2804
Olivier Grenief45f5132012-12-31 09:47:10 -03002805 .wbd = dib7090_wbd_table,
Olivier Grenieb293f302011-08-09 04:48:25 -03002806
2807 .ls_cfg_pad_drv = 0,
2808 .data_tx_drv = 0,
2809 .low_if = NULL,
2810 .in_soc = 1,
Olivier Grenief45f5132012-12-31 09:47:10 -03002811 .force_cband_input = 0,
2812 .is_dib7090e = 0,
Olivier Grenieb293f302011-08-09 04:48:25 -03002813 .force_crystal_mode = 1,
2814};
2815
Olivier Greniebe9bae12011-01-04 05:42:19 -03002816static const struct dib0090_config tfe7090pvr_dib0090_config[2] = {
2817 {
2818 .io.clock_khz = 12000,
2819 .io.pll_bypass = 0,
2820 .io.pll_range = 0,
2821 .io.pll_prediv = 3,
2822 .io.pll_loopdiv = 6,
2823 .io.adc_clock_ratio = 0,
2824 .io.pll_int_loop_filt = 0,
2825 .reset = dib7090_tuner_sleep,
2826 .sleep = dib7090_tuner_sleep,
2827
2828 .freq_offset_khz_uhf = 50,
2829 .freq_offset_khz_vhf = 70,
2830
2831 .get_adc_power = dib7090_get_adc_power,
2832
2833 .clkouttobamse = 1,
2834 .analog_output = 0,
2835
2836 .wbd_vhf_offset = 0,
2837 .wbd_cband_offset = 0,
2838 .use_pwm_agc = 1,
2839 .clkoutdrive = 0,
2840
2841 .fref_clock_ratio = 0,
2842
2843 .wbd = dib7090_wbd_table,
2844
2845 .ls_cfg_pad_drv = 0,
2846 .data_tx_drv = 0,
2847 .low_if = NULL,
2848 .in_soc = 1,
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002849 }, {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002850 .io.clock_khz = 12000,
2851 .io.pll_bypass = 0,
2852 .io.pll_range = 0,
2853 .io.pll_prediv = 3,
2854 .io.pll_loopdiv = 6,
2855 .io.adc_clock_ratio = 0,
2856 .io.pll_int_loop_filt = 0,
2857 .reset = dib7090_tuner_sleep,
2858 .sleep = dib7090_tuner_sleep,
2859
2860 .freq_offset_khz_uhf = -50,
2861 .freq_offset_khz_vhf = -70,
2862
2863 .get_adc_power = dib7090_get_adc_power,
2864
2865 .clkouttobamse = 1,
2866 .analog_output = 0,
2867
2868 .wbd_vhf_offset = 0,
2869 .wbd_cband_offset = 0,
2870 .use_pwm_agc = 1,
2871 .clkoutdrive = 0,
2872
2873 .fref_clock_ratio = 0,
2874
2875 .wbd = dib7090_wbd_table,
2876
2877 .ls_cfg_pad_drv = 0,
2878 .data_tx_drv = 0,
2879 .low_if = NULL,
2880 .in_soc = 1,
2881 }
2882};
2883
2884static int nim7090_frontend_attach(struct dvb_usb_adapter *adap)
2885{
2886 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002887 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002888 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
2889 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
2890 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
2891 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
2892
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002893 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002894 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002895 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002896 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
2897
2898 if (dib7000p_i2c_enumeration(&adap->dev->i2c_adap, 1, 0x10, &nim7090_dib7000p_config) != 0) {
2899 err("%s: dib7000p_i2c_enumeration failed. Cannot continue\n", __func__);
2900 return -ENODEV;
2901 }
Michael Krufky77eed212011-09-06 09:31:57 -03002902 adap->fe_adap[0].fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 0x80, &nim7090_dib7000p_config);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002903
Michael Krufky77eed212011-09-06 09:31:57 -03002904 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Olivier Greniebe9bae12011-01-04 05:42:19 -03002905}
2906
2907static int nim7090_tuner_attach(struct dvb_usb_adapter *adap)
2908{
2909 struct dib0700_adapter_state *st = adap->priv;
Michael Krufky77eed212011-09-06 09:31:57 -03002910 struct i2c_adapter *tun_i2c = dib7090_get_i2c_tuner(adap->fe_adap[0].fe);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002911
Michael Krufky77eed212011-09-06 09:31:57 -03002912 if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c, &nim7090_dib0090_config) == NULL)
Olivier Greniebe9bae12011-01-04 05:42:19 -03002913 return -ENODEV;
2914
Michael Krufky77eed212011-09-06 09:31:57 -03002915 dib7000p_set_gpio(adap->fe_adap[0].fe, 8, 0, 1);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002916
Michael Krufky77eed212011-09-06 09:31:57 -03002917 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
2918 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib7090_agc_startup;
Olivier Greniebe9bae12011-01-04 05:42:19 -03002919 return 0;
2920}
2921
2922static int tfe7090pvr_frontend0_attach(struct dvb_usb_adapter *adap)
2923{
2924 struct dib0700_state *st = adap->dev->priv;
2925
2926 /* The TFE7090 requires the dib0700 to not be in master mode */
2927 st->disable_streaming_master_mode = 1;
2928
2929 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002930 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002931 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
2932 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
2933 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
2934 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
2935
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002936 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002937 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002938 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002939 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
2940
2941 /* initialize IC 0 */
2942 if (dib7000p_i2c_enumeration(&adap->dev->i2c_adap, 1, 0x20, &tfe7090pvr_dib7000p_config[0]) != 0) {
2943 err("%s: dib7000p_i2c_enumeration failed. Cannot continue\n", __func__);
2944 return -ENODEV;
2945 }
2946
2947 dib0700_set_i2c_speed(adap->dev, 340);
Michael Krufky77eed212011-09-06 09:31:57 -03002948 adap->fe_adap[0].fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 0x90, &tfe7090pvr_dib7000p_config[0]);
2949 if (adap->fe_adap[0].fe == NULL)
Olivier Greniebe9bae12011-01-04 05:42:19 -03002950 return -ENODEV;
2951
Michael Krufky77eed212011-09-06 09:31:57 -03002952 dib7090_slave_reset(adap->fe_adap[0].fe);
Patrick Boettcher71682522011-04-03 12:44:25 -03002953
Olivier Greniebe9bae12011-01-04 05:42:19 -03002954 return 0;
2955}
2956
2957static int tfe7090pvr_frontend1_attach(struct dvb_usb_adapter *adap)
2958{
2959 struct i2c_adapter *i2c;
2960
Michael Krufky77eed212011-09-06 09:31:57 -03002961 if (adap->dev->adapter[0].fe_adap[0].fe == NULL) {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002962 err("the master dib7090 has to be initialized first");
2963 return -ENODEV; /* the master device has not been initialized */
2964 }
2965
Michael Krufky77eed212011-09-06 09:31:57 -03002966 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 -03002967 if (dib7000p_i2c_enumeration(i2c, 1, 0x10, &tfe7090pvr_dib7000p_config[1]) != 0) {
2968 err("%s: dib7000p_i2c_enumeration failed. Cannot continue\n", __func__);
2969 return -ENODEV;
2970 }
2971
Michael Krufky77eed212011-09-06 09:31:57 -03002972 adap->fe_adap[0].fe = dvb_attach(dib7000p_attach, i2c, 0x92, &tfe7090pvr_dib7000p_config[1]);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002973 dib0700_set_i2c_speed(adap->dev, 200);
2974
Michael Krufky77eed212011-09-06 09:31:57 -03002975 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Olivier Greniebe9bae12011-01-04 05:42:19 -03002976}
2977
2978static int tfe7090pvr_tuner0_attach(struct dvb_usb_adapter *adap)
2979{
2980 struct dib0700_adapter_state *st = adap->priv;
Michael Krufky77eed212011-09-06 09:31:57 -03002981 struct i2c_adapter *tun_i2c = dib7090_get_i2c_tuner(adap->fe_adap[0].fe);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002982
Michael Krufky77eed212011-09-06 09:31:57 -03002983 if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c, &tfe7090pvr_dib0090_config[0]) == NULL)
Olivier Greniebe9bae12011-01-04 05:42:19 -03002984 return -ENODEV;
2985
Michael Krufky77eed212011-09-06 09:31:57 -03002986 dib7000p_set_gpio(adap->fe_adap[0].fe, 8, 0, 1);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002987
Michael Krufky77eed212011-09-06 09:31:57 -03002988 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
2989 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib7090_agc_startup;
Olivier Greniebe9bae12011-01-04 05:42:19 -03002990 return 0;
2991}
2992
2993static int tfe7090pvr_tuner1_attach(struct dvb_usb_adapter *adap)
2994{
2995 struct dib0700_adapter_state *st = adap->priv;
Michael Krufky77eed212011-09-06 09:31:57 -03002996 struct i2c_adapter *tun_i2c = dib7090_get_i2c_tuner(adap->fe_adap[0].fe);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002997
Michael Krufky77eed212011-09-06 09:31:57 -03002998 if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c, &tfe7090pvr_dib0090_config[1]) == NULL)
Olivier Greniebe9bae12011-01-04 05:42:19 -03002999 return -ENODEV;
3000
Michael Krufky77eed212011-09-06 09:31:57 -03003001 dib7000p_set_gpio(adap->fe_adap[0].fe, 8, 0, 1);
Olivier Greniebe9bae12011-01-04 05:42:19 -03003002
Michael Krufky77eed212011-09-06 09:31:57 -03003003 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
3004 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib7090_agc_startup;
Olivier Greniebe9bae12011-01-04 05:42:19 -03003005 return 0;
3006}
3007
Olivier Grenief45f5132012-12-31 09:47:10 -03003008static int tfe7790p_frontend_attach(struct dvb_usb_adapter *adap)
Olivier Grenieb293f302011-08-09 04:48:25 -03003009{
3010 struct dib0700_state *st = adap->dev->priv;
3011
Olivier Grenief45f5132012-12-31 09:47:10 -03003012 /* The TFE7790P requires the dib0700 to not be in master mode */
Olivier Grenieb293f302011-08-09 04:48:25 -03003013 st->disable_streaming_master_mode = 1;
3014
3015 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
3016 msleep(20);
3017 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
3018 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
3019 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
3020 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
3021 msleep(20);
3022 dib0700_ctrl_clock(adap->dev, 72, 1);
3023 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
3024 msleep(20);
3025 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
3026
3027 if (dib7000p_i2c_enumeration(&adap->dev->i2c_adap,
Olivier Grenief45f5132012-12-31 09:47:10 -03003028 1, 0x10, &tfe7790p_dib7000p_config) != 0) {
Olivier Grenieb293f302011-08-09 04:48:25 -03003029 err("%s: dib7000p_i2c_enumeration failed. Cannot continue\n",
3030 __func__);
3031 return -ENODEV;
3032 }
3033 adap->fe_adap[0].fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap,
Olivier Grenief45f5132012-12-31 09:47:10 -03003034 0x80, &tfe7790p_dib7000p_config);
Olivier Grenieb293f302011-08-09 04:48:25 -03003035
3036 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
3037}
3038
Olivier Grenief45f5132012-12-31 09:47:10 -03003039static int tfe7790p_tuner_attach(struct dvb_usb_adapter *adap)
Olivier Grenieb293f302011-08-09 04:48:25 -03003040{
3041 struct dib0700_adapter_state *st = adap->priv;
3042 struct i2c_adapter *tun_i2c =
3043 dib7090_get_i2c_tuner(adap->fe_adap[0].fe);
3044
3045 if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c,
Olivier Grenief45f5132012-12-31 09:47:10 -03003046 &tfe7790p_dib0090_config) == NULL)
Olivier Grenie6724a2f2011-08-05 13:49:33 -03003047 return -ENODEV;
3048
3049 dib7000p_set_gpio(adap->fe_adap[0].fe, 8, 0, 1);
3050
3051 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
3052 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib7090_agc_startup;
3053 return 0;
3054}
3055
Patrick Boettcher01373a52007-07-30 12:49:04 -03003056/* STK7070PD */
3057static struct dib7000p_config stk7070pd_dib7000p_config[2] = {
3058 {
3059 .output_mpeg2_in_188_bytes = 1,
3060
3061 .agc_config_count = 1,
3062 .agc = &dib7070_agc_config,
3063 .bw = &dib7070_bw_config_12_mhz,
Patrick Boettcher3cb2c392008-01-25 07:25:20 -03003064 .tuner_is_baseband = 1,
3065 .spur_protect = 1,
Patrick Boettcher01373a52007-07-30 12:49:04 -03003066
3067 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
3068 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
3069 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
3070
3071 .hostbus_diversity = 1,
3072 }, {
3073 .output_mpeg2_in_188_bytes = 1,
3074
3075 .agc_config_count = 1,
3076 .agc = &dib7070_agc_config,
3077 .bw = &dib7070_bw_config_12_mhz,
Patrick Boettcher3cb2c392008-01-25 07:25:20 -03003078 .tuner_is_baseband = 1,
3079 .spur_protect = 1,
Patrick Boettcher01373a52007-07-30 12:49:04 -03003080
3081 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
3082 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
3083 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
3084
3085 .hostbus_diversity = 1,
3086 }
3087};
3088
Jiri Slaby52fd5b22012-01-10 14:11:23 -03003089static void stk7070pd_init(struct dvb_usb_device *dev)
3090{
3091 dib0700_set_gpio(dev, GPIO6, GPIO_OUT, 1);
3092 msleep(10);
3093 dib0700_set_gpio(dev, GPIO9, GPIO_OUT, 1);
3094 dib0700_set_gpio(dev, GPIO4, GPIO_OUT, 1);
3095 dib0700_set_gpio(dev, GPIO7, GPIO_OUT, 1);
3096 dib0700_set_gpio(dev, GPIO10, GPIO_OUT, 0);
3097
3098 dib0700_ctrl_clock(dev, 72, 1);
3099
3100 msleep(10);
3101 dib0700_set_gpio(dev, GPIO10, GPIO_OUT, 1);
3102}
3103
Patrick Boettcher01373a52007-07-30 12:49:04 -03003104static int stk7070pd_frontend_attach0(struct dvb_usb_adapter *adap)
3105{
Jiri Slaby52fd5b22012-01-10 14:11:23 -03003106 stk7070pd_init(adap->dev);
Patrick Boettcher01373a52007-07-30 12:49:04 -03003107
Patrick Boettcher01373a52007-07-30 12:49:04 -03003108 msleep(10);
3109 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
3110
Devin Heitmueller83c4fdf2009-01-21 01:55:45 -03003111 if (dib7000p_i2c_enumeration(&adap->dev->i2c_adap, 2, 18,
3112 stk7070pd_dib7000p_config) != 0) {
3113 err("%s: dib7000p_i2c_enumeration failed. Cannot continue\n",
3114 __func__);
3115 return -ENODEV;
3116 }
Patrick Boettcher01373a52007-07-30 12:49:04 -03003117
Michael Krufky77eed212011-09-06 09:31:57 -03003118 adap->fe_adap[0].fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 0x80, &stk7070pd_dib7000p_config[0]);
3119 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Patrick Boettcher01373a52007-07-30 12:49:04 -03003120}
3121
3122static int stk7070pd_frontend_attach1(struct dvb_usb_adapter *adap)
3123{
Michael Krufky77eed212011-09-06 09:31:57 -03003124 adap->fe_adap[0].fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 0x82, &stk7070pd_dib7000p_config[1]);
3125 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Patrick Boettcher01373a52007-07-30 12:49:04 -03003126}
3127
Jiri Slabyd43272a2012-01-10 14:11:25 -03003128static int novatd_read_status_override(struct dvb_frontend *fe,
3129 fe_status_t *stat)
3130{
3131 struct dvb_usb_adapter *adap = fe->dvb->priv;
3132 struct dvb_usb_device *dev = adap->dev;
3133 struct dib0700_state *state = dev->priv;
3134 int ret;
3135
3136 ret = state->read_status(fe, stat);
3137
3138 if (!ret)
3139 dib0700_set_gpio(dev, adap->id == 0 ? GPIO1 : GPIO0, GPIO_OUT,
3140 !!(*stat & FE_HAS_LOCK));
3141
3142 return ret;
3143}
3144
3145static int novatd_sleep_override(struct dvb_frontend* fe)
3146{
3147 struct dvb_usb_adapter *adap = fe->dvb->priv;
3148 struct dvb_usb_device *dev = adap->dev;
3149 struct dib0700_state *state = dev->priv;
3150
3151 /* turn off LED */
3152 dib0700_set_gpio(dev, adap->id == 0 ? GPIO1 : GPIO0, GPIO_OUT, 0);
3153
3154 return state->sleep(fe);
3155}
3156
Jiri Slaby2b05b882012-01-10 14:11:24 -03003157/**
3158 * novatd_frontend_attach - Nova-TD specific attach
3159 *
3160 * Nova-TD has GPIO0, 1 and 2 for LEDs. So do not fiddle with them except for
3161 * information purposes.
3162 */
3163static int novatd_frontend_attach(struct dvb_usb_adapter *adap)
3164{
3165 struct dvb_usb_device *dev = adap->dev;
Jiri Slabyd43272a2012-01-10 14:11:25 -03003166 struct dib0700_state *st = dev->priv;
Jiri Slaby2b05b882012-01-10 14:11:24 -03003167
3168 if (adap->id == 0) {
3169 stk7070pd_init(dev);
3170
3171 /* turn the power LED on, the other two off (just in case) */
3172 dib0700_set_gpio(dev, GPIO0, GPIO_OUT, 0);
3173 dib0700_set_gpio(dev, GPIO1, GPIO_OUT, 0);
3174 dib0700_set_gpio(dev, GPIO2, GPIO_OUT, 1);
3175
3176 if (dib7000p_i2c_enumeration(&dev->i2c_adap, 2, 18,
3177 stk7070pd_dib7000p_config) != 0) {
3178 err("%s: dib7000p_i2c_enumeration failed. Cannot continue\n",
3179 __func__);
3180 return -ENODEV;
3181 }
3182 }
3183
3184 adap->fe_adap[0].fe = dvb_attach(dib7000p_attach, &dev->i2c_adap,
3185 adap->id == 0 ? 0x80 : 0x82,
3186 &stk7070pd_dib7000p_config[adap->id]);
Jiri Slabyd43272a2012-01-10 14:11:25 -03003187
3188 if (adap->fe_adap[0].fe == NULL)
3189 return -ENODEV;
3190
3191 st->read_status = adap->fe_adap[0].fe->ops.read_status;
3192 adap->fe_adap[0].fe->ops.read_status = novatd_read_status_override;
3193 st->sleep = adap->fe_adap[0].fe->ops.sleep;
3194 adap->fe_adap[0].fe->ops.sleep = novatd_sleep_override;
3195
3196 return 0;
Jiri Slaby2b05b882012-01-10 14:11:24 -03003197}
3198
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03003199/* S5H1411 */
3200static struct s5h1411_config pinnacle_801e_config = {
3201 .output_mode = S5H1411_PARALLEL_OUTPUT,
3202 .gpio = S5H1411_GPIO_OFF,
3203 .mpeg_timing = S5H1411_MPEGTIMING_NONCONTINOUS_NONINVERTING_CLOCK,
3204 .qam_if = S5H1411_IF_44000,
3205 .vsb_if = S5H1411_IF_44000,
3206 .inversion = S5H1411_INVERSION_OFF,
3207 .status_mode = S5H1411_DEMODLOCKING
3208};
3209
3210/* Pinnacle PCTV HD Pro 801e GPIOs map:
3211 GPIO0 - currently unknown
3212 GPIO1 - xc5000 tuner reset
3213 GPIO2 - CX25843 sleep
3214 GPIO3 - currently unknown
3215 GPIO4 - currently unknown
3216 GPIO6 - currently unknown
3217 GPIO7 - currently unknown
3218 GPIO9 - currently unknown
3219 GPIO10 - CX25843 reset
3220 */
3221static int s5h1411_frontend_attach(struct dvb_usb_adapter *adap)
3222{
3223 struct dib0700_state *st = adap->dev->priv;
3224
3225 /* Make use of the new i2c functions from FW 1.20 */
3226 st->fw_use_new_i2c_api = 1;
3227
3228 /* The s5h1411 requires the dib0700 to not be in master mode */
3229 st->disable_streaming_master_mode = 1;
3230
3231 /* All msleep values taken from Windows USB trace */
3232 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 0);
3233 dib0700_set_gpio(adap->dev, GPIO3, GPIO_OUT, 0);
3234 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
3235 msleep(400);
3236 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
3237 msleep(60);
3238 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
3239 msleep(30);
3240 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
3241 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
3242 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
3243 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
3244 dib0700_set_gpio(adap->dev, GPIO2, GPIO_OUT, 0);
3245 msleep(30);
3246
3247 /* Put the CX25843 to sleep for now since we're in digital mode */
3248 dib0700_set_gpio(adap->dev, GPIO2, GPIO_OUT, 1);
3249
3250 /* GPIOs are initialized, do the attach */
Michael Krufky77eed212011-09-06 09:31:57 -03003251 adap->fe_adap[0].fe = dvb_attach(s5h1411_attach, &pinnacle_801e_config,
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03003252 &adap->dev->i2c_adap);
Michael Krufky77eed212011-09-06 09:31:57 -03003253 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03003254}
3255
Michael Krufky767f3b32008-09-25 09:47:07 -03003256static int dib0700_xc5000_tuner_callback(void *priv, int component,
3257 int command, int arg)
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03003258{
3259 struct dvb_usb_adapter *adap = priv;
3260
Devin Heitmueller79025a92008-10-06 12:07:48 -03003261 if (command == XC5000_TUNER_RESET) {
3262 /* Reset the tuner */
3263 dib0700_set_gpio(adap->dev, GPIO1, GPIO_OUT, 0);
Devin Heitmuellerf0f46332009-05-04 21:57:41 -03003264 msleep(10);
Devin Heitmueller79025a92008-10-06 12:07:48 -03003265 dib0700_set_gpio(adap->dev, GPIO1, GPIO_OUT, 1);
Devin Heitmuellerf0f46332009-05-04 21:57:41 -03003266 msleep(10);
Devin Heitmueller79025a92008-10-06 12:07:48 -03003267 } else {
3268 err("xc5000: unknown tuner callback command: %d\n", command);
3269 return -EINVAL;
3270 }
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03003271
3272 return 0;
3273}
3274
3275static struct xc5000_config s5h1411_xc5000_tunerconfig = {
3276 .i2c_address = 0x64,
3277 .if_khz = 5380,
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03003278};
3279
3280static int xc5000_tuner_attach(struct dvb_usb_adapter *adap)
3281{
Devin Heitmueller79025a92008-10-06 12:07:48 -03003282 /* FIXME: generalize & move to common area */
Michael Krufky77eed212011-09-06 09:31:57 -03003283 adap->fe_adap[0].fe->callback = dib0700_xc5000_tuner_callback;
Devin Heitmueller79025a92008-10-06 12:07:48 -03003284
Michael Krufky77eed212011-09-06 09:31:57 -03003285 return dvb_attach(xc5000_attach, adap->fe_adap[0].fe, &adap->dev->i2c_adap,
Michael Krufky767f3b32008-09-25 09:47:07 -03003286 &s5h1411_xc5000_tunerconfig)
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03003287 == NULL ? -ENODEV : 0;
3288}
3289
Davide Ferri8d009a02009-06-23 22:34:06 -03003290static int dib0700_xc4000_tuner_callback(void *priv, int component,
3291 int command, int arg)
3292{
3293 struct dvb_usb_adapter *adap = priv;
3294
3295 if (command == XC4000_TUNER_RESET) {
3296 /* Reset the tuner */
Michael Krufky77eed212011-09-06 09:31:57 -03003297 dib7000p_set_gpio(adap->fe_adap[0].fe, 8, 0, 0);
Davide Ferri8d009a02009-06-23 22:34:06 -03003298 msleep(10);
Michael Krufky77eed212011-09-06 09:31:57 -03003299 dib7000p_set_gpio(adap->fe_adap[0].fe, 8, 0, 1);
Davide Ferri8d009a02009-06-23 22:34:06 -03003300 } else {
3301 err("xc4000: unknown tuner callback command: %d\n", command);
3302 return -EINVAL;
3303 }
3304
3305 return 0;
3306}
3307
Devin Heitmueller8583fc82009-07-28 01:16:05 -03003308static struct dibx000_agc_config stk7700p_7000p_xc4000_agc_config = {
3309 .band_caps = BAND_UHF | BAND_VHF,
3310 .setup = 0x64,
3311 .inv_gain = 0x02c8,
3312 .time_stabiliz = 0x15,
3313 .alpha_level = 0x00,
3314 .thlock = 0x76,
3315 .wbd_inv = 0x01,
3316 .wbd_ref = 0x0b33,
3317 .wbd_sel = 0x00,
3318 .wbd_alpha = 0x02,
3319 .agc1_max = 0x00,
3320 .agc1_min = 0x00,
3321 .agc2_max = 0x9b26,
3322 .agc2_min = 0x26ca,
3323 .agc1_pt1 = 0x00,
3324 .agc1_pt2 = 0x00,
3325 .agc1_pt3 = 0x00,
3326 .agc1_slope1 = 0x00,
3327 .agc1_slope2 = 0x00,
3328 .agc2_pt1 = 0x00,
3329 .agc2_pt2 = 0x80,
3330 .agc2_slope1 = 0x1d,
3331 .agc2_slope2 = 0x1d,
Devin Heitmueller2df12512009-12-27 17:44:31 -03003332 .alpha_mant = 0x11,
Devin Heitmueller8583fc82009-07-28 01:16:05 -03003333 .alpha_exp = 0x1b,
3334 .beta_mant = 0x17,
3335 .beta_exp = 0x33,
3336 .perform_agc_softsplit = 0x00,
3337};
3338
Devin Heitmuellerf1c78d32009-10-05 00:34:04 -03003339static struct dibx000_bandwidth_config stk7700p_xc4000_pll_config = {
istvan_v@mailbox.hu341747b2011-06-06 12:54:54 -03003340 60000, 30000, /* internal, sampling */
3341 1, 8, 3, 1, 0, /* pll_cfg: prediv, ratio, range, reset, bypass */
3342 0, 0, 1, 1, 0, /* misc: refdiv, bypclk_div, IO_CLK_en_core, */
3343 /* ADClkSrc, modulo */
3344 (3 << 14) | (1 << 12) | 524, /* sad_cfg: refsel, sel, freq_15k */
3345 39370534, /* ifreq */
3346 20452225, /* timf */
3347 30000000 /* xtal */
Devin Heitmuellerf1c78d32009-10-05 00:34:04 -03003348};
3349
Devin Heitmueller01f16262009-06-24 00:07:01 -03003350/* FIXME: none of these inputs are validated yet */
3351static struct dib7000p_config pctv_340e_config = {
Devin Heitmueller62956ce2009-12-27 18:58:11 -03003352 .output_mpeg2_in_188_bytes = 1,
Devin Heitmueller01f16262009-06-24 00:07:01 -03003353
3354 .agc_config_count = 1,
Devin Heitmueller8583fc82009-07-28 01:16:05 -03003355 .agc = &stk7700p_7000p_xc4000_agc_config,
Devin Heitmuellerf1c78d32009-10-05 00:34:04 -03003356 .bw = &stk7700p_xc4000_pll_config,
Devin Heitmueller01f16262009-06-24 00:07:01 -03003357
Devin Heitmueller01f16262009-06-24 00:07:01 -03003358 .gpio_dir = DIB7000M_GPIO_DEFAULT_DIRECTIONS,
3359 .gpio_val = DIB7000M_GPIO_DEFAULT_VALUES,
3360 .gpio_pwm_pos = DIB7000M_GPIO_DEFAULT_PWM_POS,
3361};
3362
3363/* PCTV 340e GPIOs map:
3364 dib0700:
3365 GPIO2 - CX25843 sleep
3366 GPIO3 - CS5340 reset
3367 GPIO5 - IRD
3368 GPIO6 - Power Supply
3369 GPIO8 - LNA (1=off 0=on)
3370 GPIO10 - CX25843 reset
3371 dib7000:
3372 GPIO8 - xc4000 reset
3373 */
3374static int pctv340e_frontend_attach(struct dvb_usb_adapter *adap)
3375{
3376 struct dib0700_state *st = adap->dev->priv;
3377
3378 /* Power Supply on */
3379 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
3380 msleep(50);
3381 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
3382 msleep(100); /* Allow power supply to settle before probing */
3383
3384 /* cx25843 reset */
3385 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
3386 msleep(1); /* cx25843 datasheet say 350us required */
3387 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
3388
3389 /* LNA off for now */
3390 dib0700_set_gpio(adap->dev, GPIO8, GPIO_OUT, 1);
3391
3392 /* Put the CX25843 to sleep for now since we're in digital mode */
3393 dib0700_set_gpio(adap->dev, GPIO2, GPIO_OUT, 1);
3394
3395 /* FIXME: not verified yet */
3396 dib0700_ctrl_clock(adap->dev, 72, 1);
3397
Devin Heitmueller2750d9c2009-07-20 00:42:33 -03003398 msleep(500);
3399
Devin Heitmueller01f16262009-06-24 00:07:01 -03003400 if (dib7000pc_detection(&adap->dev->i2c_adap) == 0) {
3401 /* Demodulator not found for some reason? */
3402 return -ENODEV;
3403 }
3404
Michael Krufky77eed212011-09-06 09:31:57 -03003405 adap->fe_adap[0].fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 0x12,
Devin Heitmueller01f16262009-06-24 00:07:01 -03003406 &pctv_340e_config);
3407 st->is_dib7000pc = 1;
3408
Michael Krufky77eed212011-09-06 09:31:57 -03003409 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Devin Heitmueller01f16262009-06-24 00:07:01 -03003410}
3411
Devin Heitmueller8583fc82009-07-28 01:16:05 -03003412static struct xc4000_config dib7000p_xc4000_tunerconfig = {
istvan_v@mailbox.hu8edeb6e2011-06-06 13:03:44 -03003413 .i2c_address = 0x61,
3414 .default_pm = 1,
3415 .dvb_amplitude = 0,
3416 .set_smoothedcvbs = 0,
3417 .if_khz = 5400
Davide Ferri8d009a02009-06-23 22:34:06 -03003418};
3419
3420static int xc4000_tuner_attach(struct dvb_usb_adapter *adap)
3421{
Devin Heitmueller59d0c372009-06-29 21:11:02 -03003422 struct i2c_adapter *tun_i2c;
3423
3424 /* The xc4000 is not on the main i2c bus */
Michael Krufky77eed212011-09-06 09:31:57 -03003425 tun_i2c = dib7000p_get_i2c_master(adap->fe_adap[0].fe,
Devin Heitmueller59d0c372009-06-29 21:11:02 -03003426 DIBX000_I2C_INTERFACE_TUNER, 1);
3427 if (tun_i2c == NULL) {
Mauro Carvalho Chehab941830c2011-06-06 16:51:11 -03003428 printk(KERN_ERR "Could not reach tuner i2c bus\n");
Devin Heitmueller59d0c372009-06-29 21:11:02 -03003429 return 0;
3430 }
3431
3432 /* Setup the reset callback */
Michael Krufky77eed212011-09-06 09:31:57 -03003433 adap->fe_adap[0].fe->callback = dib0700_xc4000_tuner_callback;
Davide Ferri8d009a02009-06-23 22:34:06 -03003434
Michael Krufky77eed212011-09-06 09:31:57 -03003435 return dvb_attach(xc4000_attach, adap->fe_adap[0].fe, tun_i2c,
Devin Heitmueller8583fc82009-07-28 01:16:05 -03003436 &dib7000p_xc4000_tunerconfig)
Davide Ferri8d009a02009-06-23 22:34:06 -03003437 == NULL ? -ENODEV : 0;
3438}
3439
Michael Krufkyce904bc2009-01-19 01:12:55 -03003440static struct lgdt3305_config hcw_lgdt3305_config = {
3441 .i2c_addr = 0x0e,
3442 .mpeg_mode = LGDT3305_MPEG_PARALLEL,
3443 .tpclk_edge = LGDT3305_TPCLK_FALLING_EDGE,
3444 .tpvalid_polarity = LGDT3305_TP_VALID_LOW,
3445 .deny_i2c_rptr = 0,
3446 .spectral_inversion = 1,
3447 .qam_if_khz = 6000,
3448 .vsb_if_khz = 6000,
3449 .usref_8vsb = 0x0500,
3450};
3451
3452static struct mxl5007t_config hcw_mxl5007t_config = {
3453 .xtal_freq_hz = MxL_XTAL_25_MHZ,
3454 .if_freq_hz = MxL_IF_6_MHZ,
3455 .invert_if = 1,
3456};
3457
3458/* TIGER-ATSC map:
3459 GPIO0 - LNA_CTR (H: LNA power enabled, L: LNA power disabled)
3460 GPIO1 - ANT_SEL (H: VPA, L: MCX)
3461 GPIO4 - SCL2
3462 GPIO6 - EN_TUNER
3463 GPIO7 - SDA2
3464 GPIO10 - DEM_RST
3465
3466 MXL is behind LG's i2c repeater. LG is on SCL2/SDA2 gpios on the DIB
3467 */
3468static int lgdt3305_frontend_attach(struct dvb_usb_adapter *adap)
3469{
3470 struct dib0700_state *st = adap->dev->priv;
3471
3472 /* Make use of the new i2c functions from FW 1.20 */
3473 st->fw_use_new_i2c_api = 1;
3474
3475 st->disable_streaming_master_mode = 1;
3476
3477 /* fe power enable */
3478 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
3479 msleep(30);
3480 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
3481 msleep(30);
3482
3483 /* demod reset */
3484 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
3485 msleep(30);
3486 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
3487 msleep(30);
3488 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
3489 msleep(30);
3490
Michael Krufky77eed212011-09-06 09:31:57 -03003491 adap->fe_adap[0].fe = dvb_attach(lgdt3305_attach,
Michael Krufkyce904bc2009-01-19 01:12:55 -03003492 &hcw_lgdt3305_config,
3493 &adap->dev->i2c_adap);
3494
Michael Krufky77eed212011-09-06 09:31:57 -03003495 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Michael Krufkyce904bc2009-01-19 01:12:55 -03003496}
3497
3498static int mxl5007t_tuner_attach(struct dvb_usb_adapter *adap)
3499{
Michael Krufky77eed212011-09-06 09:31:57 -03003500 return dvb_attach(mxl5007t_attach, adap->fe_adap[0].fe,
Michael Krufkyce904bc2009-01-19 01:12:55 -03003501 &adap->dev->i2c_adap, 0x60,
3502 &hcw_mxl5007t_config) == NULL ? -ENODEV : 0;
3503}
3504
3505
Patrick Boettcher01373a52007-07-30 12:49:04 -03003506/* DVB-USB and USB stuff follows */
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003507struct usb_device_id dib0700_usb_id_table[] = {
Patrick Boettcher01373a52007-07-30 12:49:04 -03003508/* 0 */ { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7700P) },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03003509 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7700P_PC) },
3510 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_500) },
3511 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_500_2) },
3512 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_STICK) },
Patrick Boettcher01373a52007-07-30 12:49:04 -03003513/* 5 */ { USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR) },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03003514 { USB_DEVICE(USB_VID_COMPRO, USB_PID_COMPRO_VIDEOMATE_U500) },
3515 { USB_DEVICE(USB_VID_UNIWILL, USB_PID_UNIWILL_STK7700P) },
3516 { USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV_DONGLE_STK7700P) },
3517 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_STICK_2) },
Patrick Boettcher01373a52007-07-30 12:49:04 -03003518/* 10 */{ USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR_2) },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03003519 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV2000E) },
3520 { USB_DEVICE(USB_VID_TERRATEC,
3521 USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY) },
3522 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_TD_STICK) },
3523 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7700D) },
Patrick Boettcher01373a52007-07-30 12:49:04 -03003524/* 15 */{ USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7070P) },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03003525 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV_DVB_T_FLASH) },
3526 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7070PD) },
3527 { USB_DEVICE(USB_VID_PINNACLE,
3528 USB_PID_PINNACLE_PCTV_DUAL_DIVERSITY_DVB_T) },
3529 { USB_DEVICE(USB_VID_COMPRO, USB_PID_COMPRO_VIDEOMATE_U500_PC) },
Joachim Steigerfa3b8772007-10-08 20:08:46 -03003530/* 20 */{ USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_EXPRESS) },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03003531 { USB_DEVICE(USB_VID_GIGABYTE, USB_PID_GIGABYTE_U7000) },
3532 { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC, USB_PID_ARTEC_T14BR) },
3533 { USB_DEVICE(USB_VID_ASUS, USB_PID_ASUS_U3000) },
3534 { USB_DEVICE(USB_VID_ASUS, USB_PID_ASUS_U3100) },
3535/* 25 */{ USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_STICK_3) },
3536 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_MYTV_T) },
3537 { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_HT_USB_XE) },
3538 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_EXPRESSCARD_320CX) },
3539 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV72E) },
3540/* 30 */{ USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV73E) },
3541 { USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_EC372S) },
3542 { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_HT_EXPRESS) },
Alexander Simondc888072008-03-29 21:37:54 -03003543 { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_XXS) },
Darryl Green5da4e2c2008-03-29 21:47:43 -03003544 { USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV_DONGLE_STK7700P_2) },
Michael Krufkyaf2a8872008-09-03 17:12:24 -03003545/* 35 */{ USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_TD_STICK_52009) },
Michael Krufky9a0c04a2008-09-03 17:12:24 -03003546 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_500_3) },
Finn Thain17a370b2008-09-06 13:42:47 -03003547 { USB_DEVICE(USB_VID_GIGABYTE, USB_PID_GIGABYTE_U8000) },
Daniel Oliveira Nascimento8751aaa2008-09-07 12:39:44 -03003548 { USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_STK7700PH) },
Albert Comerma57697432008-09-07 12:43:33 -03003549 { USB_DEVICE(USB_VID_ASUS, USB_PID_ASUS_U3000H) },
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03003550/* 40 */{ USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV801E) },
Devin Heitmuellerd2fc3bf2008-09-25 06:22:23 -03003551 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV801E_SE) },
Yusuf Altinbb1b0822009-01-08 07:58:45 -03003552 { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_EXPRESS) },
Nicolas Fournierdb4b2d12009-01-13 07:15:25 -03003553 { USB_DEVICE(USB_VID_TERRATEC,
3554 USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY_2) },
sebastian.blanes@gmail.com0a6e1ed2009-02-24 14:51:43 -03003555 { USB_DEVICE(USB_VID_SONY, USB_PID_SONY_PLAYTV) },
Pascal Terjan9abb6e62009-02-26 10:31:41 -03003556/* 45 */{ USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_PD378S) },
Michael Krufkyce904bc2009-01-19 01:12:55 -03003557 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_TIGER_ATSC) },
3558 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_TIGER_ATSC_B210) },
Xoan Loureiro16ba1ee2009-03-29 08:43:36 -03003559 { USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_MC770) },
Klaus Flittner919a5482009-03-29 09:12:06 -03003560 { USB_DEVICE(USB_VID_ELGATO, USB_PID_ELGATO_EYETV_DTT) },
Armin Schenker513846e2009-04-20 11:57:49 -03003561/* 50 */{ USB_DEVICE(USB_VID_ELGATO, USB_PID_ELGATO_EYETV_DTT_Dlx) },
tomas petrf0f4ae72009-05-20 05:28:05 -03003562 { USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV_DONGLE_H) },
Patrick Boettchera9b8fe32009-05-20 05:35:02 -03003563 { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_T3) },
3564 { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_T5) },
Pete Hildebrandtc53d83c2009-08-05 11:46:38 -03003565 { USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_STK7700D) },
Olivier Grenie74b76f22009-09-02 08:19:19 -03003566/* 55 */{ USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_STK7700D_2) },
3567 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV73A) },
Patrick Boettchere4147532009-11-30 13:52:57 -03003568 { USB_DEVICE(USB_VID_PCTV, USB_PID_PINNACLE_PCTV73ESE) },
3569 { USB_DEVICE(USB_VID_PCTV, USB_PID_PINNACLE_PCTV282E) },
Olivier Grenied300bd62009-09-15 06:55:35 -03003570 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7770P) },
Patrick Boettcherdb481382009-09-15 07:16:51 -03003571/* 60 */{ USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_XXS_2) },
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03003572 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK807XPVR) },
3573 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK807XP) },
Mauro Carvalho Chehab3bfb3172010-09-03 10:50:24 -03003574 { USB_DEVICE_VER(USB_VID_PIXELVIEW, USB_PID_PIXELVIEW_SBTVD, 0x000, 0x3f00) },
S?rgio Fortier8a378e82009-09-28 04:19:21 -03003575 { USB_DEVICE(USB_VID_EVOLUTEPC, USB_PID_TVWAY_PLUS) },
Patrick Boettcher20232c42009-12-01 12:08:56 -03003576/* 65 */{ USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV73ESE) },
Patrick Boettchere4147532009-11-30 13:52:57 -03003577 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV282E) },
Olivier Grenie03245a52009-12-04 13:27:57 -03003578 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK8096GP) },
Michael Müller84e2f032010-04-26 22:18:57 -03003579 { USB_DEVICE(USB_VID_ELGATO, USB_PID_ELGATO_EYETV_DIVERSITY) },
Olivier Greniebe9bae12011-01-04 05:42:19 -03003580 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_NIM9090M) },
3581/* 70 */{ USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_NIM8096MD) },
3582 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_NIM9090MD) },
3583 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_NIM7090) },
3584 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_TFE7090PVR) },
Lukas Max Fisch498e6772011-02-08 16:51:45 -03003585 { USB_DEVICE(USB_VID_TECHNISAT, USB_PID_TECHNISAT_AIRSTAR_TELESTICK_2) },
Stéphane Elmalehd1402302011-05-21 07:33:38 -03003586/* 75 */{ USB_DEVICE(USB_VID_MEDION, USB_PID_CREATIX_CTX1921) },
Davide Ferri8d009a02009-06-23 22:34:06 -03003587 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV340E) },
Devin Heitmueller33fb1682009-06-23 22:48:02 -03003588 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV340E_SE) },
Olivier Grenief45f5132012-12-31 09:47:10 -03003589 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_TFE7790P) },
3590 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_TFE8096P) },
3591/* 80 */{ USB_DEVICE(USB_VID_ELGATO, USB_PID_ELGATO_EYETV_DTT_2) },
Michael Krufkyc859e6e2013-06-30 12:43:58 -03003592 { USB_DEVICE(USB_VID_PCTV, USB_PID_PCTV_2002E) },
3593 { USB_DEVICE(USB_VID_PCTV, USB_PID_PCTV_2002E_SE) },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03003594 { 0 } /* Terminating entry */
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003595};
3596MODULE_DEVICE_TABLE(usb, dib0700_usb_id_table);
3597
3598#define DIB0700_DEFAULT_DEVICE_PROPERTIES \
3599 .caps = DVB_USB_IS_AN_I2C_ADAPTER, \
3600 .usb_ctrl = DEVICE_SPECIFIC, \
Devin Heitmuellerbdc203e2008-09-06 13:45:27 -03003601 .firmware = "dvb-usb-dib0700-1.20.fw", \
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003602 .download_firmware = dib0700_download_firmware, \
Patrick Boettcher6958eff2006-09-19 12:51:40 -03003603 .no_reconnect = 1, \
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003604 .size_of_priv = sizeof(struct dib0700_state), \
Patrick Boettcher6958eff2006-09-19 12:51:40 -03003605 .i2c_algo = &dib0700_i2c_algo, \
3606 .identify_state = dib0700_identify_state
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003607
3608#define DIB0700_DEFAULT_STREAMING_CONFIG(ep) \
3609 .streaming_ctrl = dib0700_streaming_ctrl, \
3610 .stream = { \
3611 .type = USB_BULK, \
3612 .count = 4, \
3613 .endpoint = ep, \
3614 .u = { \
3615 .bulk = { \
3616 .buffersize = 39480, \
3617 } \
3618 } \
3619 }
3620
3621struct dvb_usb_device_properties dib0700_devices[] = {
3622 {
3623 DIB0700_DEFAULT_DEVICE_PROPERTIES,
3624
3625 .num_adapters = 1,
3626 .adapter = {
3627 {
Michael Krufky77eed212011-09-06 09:31:57 -03003628 .num_frontends = 1,
3629 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03003630 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
3631 .pid_filter_count = 32,
Olivier Greniee192a7c2011-01-14 13:58:59 -03003632 .pid_filter = stk7700p_pid_filter,
3633 .pid_filter_ctrl = stk7700p_pid_filter_ctrl,
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003634 .frontend_attach = stk7700p_frontend_attach,
3635 .tuner_attach = stk7700p_tuner_attach,
3636
3637 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03003638 }},
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003639 },
3640 },
3641
dominik67053a42007-11-10 19:23:31 -03003642 .num_device_descs = 8,
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003643 .devices = {
3644 { "DiBcom STK7700P reference design",
Tomi Koivulahti49a13762006-10-19 07:27:19 -03003645 { &dib0700_usb_id_table[0], &dib0700_usb_id_table[1] },
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003646 { NULL },
3647 },
3648 { "Hauppauge Nova-T Stick",
Stefan Trabyf9aeba42006-11-12 13:02:51 -03003649 { &dib0700_usb_id_table[4], &dib0700_usb_id_table[9], NULL },
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003650 { NULL },
3651 },
Tomi Koivulahti49a13762006-10-19 07:27:19 -03003652 { "AVerMedia AVerTV DVB-T Volar",
Jose Carlos Garcia Sogoced8fec2006-11-14 05:01:47 -03003653 { &dib0700_usb_id_table[5], &dib0700_usb_id_table[10] },
Tomi Koivulahti49a13762006-10-19 07:27:19 -03003654 { NULL },
3655 },
3656 { "Compro Videomate U500",
Patrick Boettcher1f8ca4b2007-07-30 14:24:37 -03003657 { &dib0700_usb_id_table[6], &dib0700_usb_id_table[19] },
Tomi Koivulahti49a13762006-10-19 07:27:19 -03003658 { NULL },
Henning Schroeer0ce215e2006-10-19 07:58:22 -03003659 },
3660 { "Uniwill STK7700P based (Hama and others)",
3661 { &dib0700_usb_id_table[7], NULL },
3662 { NULL },
Michael Krufky8637a872006-11-08 16:47:32 -03003663 },
3664 { "Leadtek Winfast DTV Dongle (STK7700P based)",
Patrick Boettcher1e13c8f2009-09-19 05:24:40 -03003665 { &dib0700_usb_id_table[8], &dib0700_usb_id_table[34] },
Michael Krufky8637a872006-11-08 16:47:32 -03003666 { NULL },
Joachim Steigerfa3b8772007-10-08 20:08:46 -03003667 },
3668 { "AVerMedia AVerTV DVB-T Express",
3669 { &dib0700_usb_id_table[20] },
3670 { NULL },
dominik67053a42007-11-10 19:23:31 -03003671 },
dominik67053a42007-11-10 19:23:31 -03003672 { "Gigabyte U7000",
3673 { &dib0700_usb_id_table[21], NULL },
3674 { NULL },
Tomi Koivulahti49a13762006-10-19 07:27:19 -03003675 }
Darren Saltb1139e32007-08-18 18:05:31 -03003676 },
3677
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03003678 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03003679 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03003680 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03003681 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03003682 .allowed_protos = RC_BIT_RC5 |
3683 RC_BIT_RC6_MCE |
3684 RC_BIT_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03003685 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03003686 },
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003687 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
3688
3689 .num_adapters = 2,
3690 .adapter = {
3691 {
Michael Krufky77eed212011-09-06 09:31:57 -03003692 .num_frontends = 1,
3693 .fe = {{
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003694 .frontend_attach = bristol_frontend_attach,
3695 .tuner_attach = bristol_tuner_attach,
3696
3697 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03003698 }},
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003699 }, {
Michael Krufky77eed212011-09-06 09:31:57 -03003700 .num_frontends = 1,
3701 .fe = {{
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003702 .frontend_attach = bristol_frontend_attach,
3703 .tuner_attach = bristol_tuner_attach,
3704
3705 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
Michael Krufky77eed212011-09-06 09:31:57 -03003706 }},
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003707 }
3708 },
3709
3710 .num_device_descs = 1,
3711 .devices = {
3712 { "Hauppauge Nova-T 500 Dual DVB-T",
Tomi Koivulahti49a13762006-10-19 07:27:19 -03003713 { &dib0700_usb_id_table[2], &dib0700_usb_id_table[3], NULL },
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003714 { NULL },
3715 },
Janne Grunau82f3d552007-07-30 13:50:28 -03003716 },
3717
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03003718 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03003719 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03003720 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03003721 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03003722 .allowed_protos = RC_BIT_RC5 |
3723 RC_BIT_RC6_MCE |
3724 RC_BIT_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03003725 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03003726 },
Olivier DANET54d75eb2007-07-25 14:42:54 -03003727 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
3728
3729 .num_adapters = 2,
3730 .adapter = {
3731 {
Michael Krufky77eed212011-09-06 09:31:57 -03003732 .num_frontends = 1,
3733 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03003734 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
3735 .pid_filter_count = 32,
3736 .pid_filter = stk70x0p_pid_filter,
3737 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
Olivier DANET54d75eb2007-07-25 14:42:54 -03003738 .frontend_attach = stk7700d_frontend_attach,
3739 .tuner_attach = stk7700d_tuner_attach,
3740
3741 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03003742 }},
Olivier DANET54d75eb2007-07-25 14:42:54 -03003743 }, {
Michael Krufky77eed212011-09-06 09:31:57 -03003744 .num_frontends = 1,
3745 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03003746 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
3747 .pid_filter_count = 32,
3748 .pid_filter = stk70x0p_pid_filter,
3749 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
Olivier DANET54d75eb2007-07-25 14:42:54 -03003750 .frontend_attach = stk7700d_frontend_attach,
3751 .tuner_attach = stk7700d_tuner_attach,
3752
3753 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
Michael Krufky77eed212011-09-06 09:31:57 -03003754 }},
Olivier DANET54d75eb2007-07-25 14:42:54 -03003755 }
3756 },
3757
James A Webb200e8612009-08-04 02:38:05 -03003758 .num_device_descs = 5,
Olivier DANET54d75eb2007-07-25 14:42:54 -03003759 .devices = {
3760 { "Pinnacle PCTV 2000e",
3761 { &dib0700_usb_id_table[11], NULL },
3762 { NULL },
3763 },
3764 { "Terratec Cinergy DT XS Diversity",
3765 { &dib0700_usb_id_table[12], NULL },
3766 { NULL },
3767 },
Darren Saltfaebb912007-08-18 18:04:00 -03003768 { "Hauppauge Nova-TD Stick/Elgato Eye-TV Diversity",
Olivier DANET54d75eb2007-07-25 14:42:54 -03003769 { &dib0700_usb_id_table[13], NULL },
3770 { NULL },
3771 },
Patrick Boettcher01373a52007-07-30 12:49:04 -03003772 { "DiBcom STK7700D reference design",
Patrick Boettcherb6884a12007-07-27 10:08:51 -03003773 { &dib0700_usb_id_table[14], NULL },
3774 { NULL },
Yusuf Altinbb1b0822009-01-08 07:58:45 -03003775 },
James A Webb200e8612009-08-04 02:38:05 -03003776 { "YUAN High-Tech DiBcom STK7700D",
3777 { &dib0700_usb_id_table[55], NULL },
3778 { NULL },
3779 },
Yusuf Altinbb1b0822009-01-08 07:58:45 -03003780
Olivier DANET54d75eb2007-07-25 14:42:54 -03003781 },
Janne Grunau82f3d552007-07-30 13:50:28 -03003782
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03003783 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03003784 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03003785 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03003786 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03003787 .allowed_protos = RC_BIT_RC5 |
3788 RC_BIT_RC6_MCE |
3789 RC_BIT_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03003790 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03003791 },
Patrick Boettcher01373a52007-07-30 12:49:04 -03003792 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
3793
3794 .num_adapters = 1,
3795 .adapter = {
3796 {
Michael Krufky77eed212011-09-06 09:31:57 -03003797 .num_frontends = 1,
3798 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03003799 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
3800 .pid_filter_count = 32,
3801 .pid_filter = stk70x0p_pid_filter,
3802 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
Daniel Gimpelevich132c3182008-01-25 06:02:42 -03003803 .frontend_attach = stk7700P2_frontend_attach,
3804 .tuner_attach = stk7700d_tuner_attach,
3805
3806 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03003807 }},
Daniel Gimpelevich132c3182008-01-25 06:02:42 -03003808 },
3809 },
3810
Yusuf Altinbb1b0822009-01-08 07:58:45 -03003811 .num_device_descs = 3,
Daniel Gimpelevich132c3182008-01-25 06:02:42 -03003812 .devices = {
3813 { "ASUS My Cinema U3000 Mini DVBT Tuner",
3814 { &dib0700_usb_id_table[23], NULL },
3815 { NULL },
3816 },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03003817 { "Yuan EC372S",
3818 { &dib0700_usb_id_table[31], NULL },
3819 { NULL },
Yusuf Altinbb1b0822009-01-08 07:58:45 -03003820 },
3821 { "Terratec Cinergy T Express",
3822 { &dib0700_usb_id_table[42], NULL },
3823 { NULL },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03003824 }
Chris Rankin48aa7392008-09-25 06:52:24 -03003825 },
3826
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03003827 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03003828 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03003829 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03003830 .module_name = "dib0700",
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03003831 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03003832 .allowed_protos = RC_BIT_RC5 |
3833 RC_BIT_RC6_MCE |
3834 RC_BIT_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03003835 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03003836 },
Daniel Gimpelevich132c3182008-01-25 06:02:42 -03003837 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
3838
3839 .num_adapters = 1,
3840 .adapter = {
3841 {
Michael Krufky77eed212011-09-06 09:31:57 -03003842 .num_frontends = 1,
3843 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03003844 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
3845 .pid_filter_count = 32,
3846 .pid_filter = stk70x0p_pid_filter,
3847 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
Patrick Boettcher01373a52007-07-30 12:49:04 -03003848 .frontend_attach = stk7070p_frontend_attach,
3849 .tuner_attach = dib7070p_tuner_attach,
3850
3851 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03003852 }},
Patrick Boettcher01373a52007-07-30 12:49:04 -03003853 .size_of_priv = sizeof(struct dib0700_adapter_state),
3854 },
3855 },
3856
Gianluca Gennari0bc9d392012-04-14 09:14:07 -03003857 .num_device_descs = 12,
Patrick Boettcher01373a52007-07-30 12:49:04 -03003858 .devices = {
3859 { "DiBcom STK7070P reference design",
3860 { &dib0700_usb_id_table[15], NULL },
3861 { NULL },
3862 },
3863 { "Pinnacle PCTV DVB-T Flash Stick",
3864 { &dib0700_usb_id_table[16], NULL },
3865 { NULL },
3866 },
Yousef Lamlum7999a812008-01-25 05:51:48 -03003867 { "Artec T14BR DVB-T",
3868 { &dib0700_usb_id_table[22], NULL },
3869 { NULL },
Daniel Gimpelevich132c3182008-01-25 06:02:42 -03003870 },
3871 { "ASUS My Cinema U3100 Mini DVBT Tuner",
3872 { &dib0700_usb_id_table[24], NULL },
3873 { NULL },
3874 },
Tim Taubertc7637b12008-01-25 06:16:36 -03003875 { "Hauppauge Nova-T Stick",
3876 { &dib0700_usb_id_table[25], NULL },
3877 { NULL },
3878 },
Darren Salt13b83b52008-01-25 06:20:02 -03003879 { "Hauppauge Nova-T MyTV.t",
3880 { &dib0700_usb_id_table[26], NULL },
3881 { NULL },
3882 },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03003883 { "Pinnacle PCTV 72e",
3884 { &dib0700_usb_id_table[29], NULL },
3885 { NULL },
3886 },
3887 { "Pinnacle PCTV 73e",
3888 { &dib0700_usb_id_table[30], NULL },
3889 { NULL },
3890 },
Klaus Flittner919a5482009-03-29 09:12:06 -03003891 { "Elgato EyeTV DTT",
3892 { &dib0700_usb_id_table[49], NULL },
3893 { NULL },
3894 },
Pascal Terjan9abb6e62009-02-26 10:31:41 -03003895 { "Yuan PD378S",
3896 { &dib0700_usb_id_table[45], NULL },
3897 { NULL },
3898 },
Armin Schenker513846e2009-04-20 11:57:49 -03003899 { "Elgato EyeTV Dtt Dlx PD378S",
3900 { &dib0700_usb_id_table[50], NULL },
3901 { NULL },
3902 },
Gianluca Gennari0bc9d392012-04-14 09:14:07 -03003903 { "Elgato EyeTV DTT rev. 2",
Olivier Grenief45f5132012-12-31 09:47:10 -03003904 { &dib0700_usb_id_table[80], NULL },
Gianluca Gennari0bc9d392012-04-14 09:14:07 -03003905 { NULL },
3906 },
Tim Taubertc7637b12008-01-25 06:16:36 -03003907 },
3908
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03003909 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03003910 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03003911 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03003912 .module_name = "dib0700",
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03003913 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03003914 .allowed_protos = RC_BIT_RC5 |
3915 RC_BIT_RC6_MCE |
3916 RC_BIT_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03003917 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03003918 },
Patrick Boettcher01373a52007-07-30 12:49:04 -03003919 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
3920
Olivier Grenie74b76f22009-09-02 08:19:19 -03003921 .num_adapters = 1,
3922 .adapter = {
3923 {
Michael Krufky77eed212011-09-06 09:31:57 -03003924 .num_frontends = 1,
3925 .fe = {{
Mauro Carvalho Chehab648732f2009-11-04 12:11:43 -02003926 .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,
Olivier Grenie74b76f22009-09-02 08:19:19 -03003930 .frontend_attach = stk7070p_frontend_attach,
3931 .tuner_attach = dib7070p_tuner_attach,
3932
3933 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03003934 }},
Olivier Grenie74b76f22009-09-02 08:19:19 -03003935 .size_of_priv = sizeof(struct dib0700_adapter_state),
3936 },
3937 },
3938
Patrick Boettcher20232c42009-12-01 12:08:56 -03003939 .num_device_descs = 3,
Olivier Grenie74b76f22009-09-02 08:19:19 -03003940 .devices = {
3941 { "Pinnacle PCTV 73A",
3942 { &dib0700_usb_id_table[56], NULL },
3943 { NULL },
3944 },
3945 { "Pinnacle PCTV 73e SE",
Patrick Boettcher20232c42009-12-01 12:08:56 -03003946 { &dib0700_usb_id_table[57], &dib0700_usb_id_table[65], NULL },
Olivier Grenie74b76f22009-09-02 08:19:19 -03003947 { NULL },
3948 },
3949 { "Pinnacle PCTV 282e",
Patrick Boettcher20232c42009-12-01 12:08:56 -03003950 { &dib0700_usb_id_table[58], &dib0700_usb_id_table[66], NULL },
Olivier Grenie74b76f22009-09-02 08:19:19 -03003951 { NULL },
3952 },
3953 },
3954
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03003955 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03003956 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03003957 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03003958 .module_name = "dib0700",
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03003959 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03003960 .allowed_protos = RC_BIT_RC5 |
3961 RC_BIT_RC6_MCE |
3962 RC_BIT_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03003963 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03003964 },
Olivier Grenie74b76f22009-09-02 08:19:19 -03003965 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
3966
Patrick Boettcher01373a52007-07-30 12:49:04 -03003967 .num_adapters = 2,
3968 .adapter = {
3969 {
Michael Krufky77eed212011-09-06 09:31:57 -03003970 .num_frontends = 1,
3971 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03003972 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
3973 .pid_filter_count = 32,
3974 .pid_filter = stk70x0p_pid_filter,
3975 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
Jiri Slaby2b05b882012-01-10 14:11:24 -03003976 .frontend_attach = novatd_frontend_attach,
Patrick Boettcher01373a52007-07-30 12:49:04 -03003977 .tuner_attach = dib7070p_tuner_attach,
3978
3979 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03003980 }},
Patrick Boettcher01373a52007-07-30 12:49:04 -03003981 .size_of_priv = sizeof(struct dib0700_adapter_state),
3982 }, {
Michael Krufky77eed212011-09-06 09:31:57 -03003983 .num_frontends = 1,
3984 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03003985 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
3986 .pid_filter_count = 32,
3987 .pid_filter = stk70x0p_pid_filter,
3988 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
Jiri Slaby2b05b882012-01-10 14:11:24 -03003989 .frontend_attach = novatd_frontend_attach,
Patrick Boettcher01373a52007-07-30 12:49:04 -03003990 .tuner_attach = dib7070p_tuner_attach,
3991
3992 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
Michael Krufky77eed212011-09-06 09:31:57 -03003993 }},
Patrick Boettcher01373a52007-07-30 12:49:04 -03003994 .size_of_priv = sizeof(struct dib0700_adapter_state),
3995 }
3996 },
3997
Michael Krufkyc859e6e2013-06-30 12:43:58 -03003998 .num_device_descs = 3,
Jiri Slaby9b6ba572012-01-10 14:11:22 -03003999 .devices = {
4000 { "Hauppauge Nova-TD Stick (52009)",
4001 { &dib0700_usb_id_table[35], NULL },
4002 { NULL },
4003 },
Michael Krufkyc859e6e2013-06-30 12:43:58 -03004004 { "PCTV 2002e",
4005 { &dib0700_usb_id_table[81], NULL },
4006 { NULL },
4007 },
4008 { "PCTV 2002e SE",
4009 { &dib0700_usb_id_table[82], NULL },
4010 { NULL },
4011 },
Jiri Slaby9b6ba572012-01-10 14:11:22 -03004012 },
4013
4014 .rc.core = {
4015 .rc_interval = DEFAULT_RC_INTERVAL,
4016 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4017 .module_name = "dib0700",
4018 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004019 .allowed_protos = RC_BIT_RC5 |
4020 RC_BIT_RC6_MCE |
4021 RC_BIT_NEC,
Jiri Slaby9b6ba572012-01-10 14:11:22 -03004022 .change_protocol = dib0700_change_protocol,
4023 },
4024 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4025
4026 .num_adapters = 2,
4027 .adapter = {
4028 {
4029 .num_frontends = 1,
4030 .fe = {{
4031 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4032 .pid_filter_count = 32,
4033 .pid_filter = stk70x0p_pid_filter,
4034 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
4035 .frontend_attach = stk7070pd_frontend_attach0,
4036 .tuner_attach = dib7070p_tuner_attach,
4037
4038 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
4039 }},
4040 .size_of_priv = sizeof(struct dib0700_adapter_state),
4041 }, {
4042 .num_frontends = 1,
4043 .fe = {{
4044 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4045 .pid_filter_count = 32,
4046 .pid_filter = stk70x0p_pid_filter,
4047 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
4048 .frontend_attach = stk7070pd_frontend_attach1,
4049 .tuner_attach = dib7070p_tuner_attach,
4050
4051 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
4052 }},
4053 .size_of_priv = sizeof(struct dib0700_adapter_state),
4054 }
4055 },
4056
4057 .num_device_descs = 5,
Patrick Boettcher01373a52007-07-30 12:49:04 -03004058 .devices = {
4059 { "DiBcom STK7070PD reference design",
4060 { &dib0700_usb_id_table[17], NULL },
4061 { NULL },
4062 },
4063 { "Pinnacle PCTV Dual DVB-T Diversity Stick",
4064 { &dib0700_usb_id_table[18], NULL },
4065 { NULL },
Michael Krufkyd01eb2d2008-07-03 23:43:36 -03004066 },
Michael Krufky9a0c04a2008-09-03 17:12:24 -03004067 { "Hauppauge Nova-TD-500 (84xxx)",
4068 { &dib0700_usb_id_table[36], NULL },
4069 { NULL },
Nicolas Fournierdb4b2d12009-01-13 07:15:25 -03004070 },
Patrick Boettchera9b8fe32009-05-20 05:35:02 -03004071 { "Terratec Cinergy DT USB XS Diversity/ T5",
4072 { &dib0700_usb_id_table[43],
4073 &dib0700_usb_id_table[53], NULL},
Nicolas Fournierdb4b2d12009-01-13 07:15:25 -03004074 { NULL },
sebastian.blanes@gmail.com0a6e1ed2009-02-24 14:51:43 -03004075 },
4076 { "Sony PlayTV",
4077 { &dib0700_usb_id_table[44], NULL },
4078 { NULL },
Michael Müller84e2f032010-04-26 22:18:57 -03004079 },
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004080 },
4081
4082 .rc.core = {
4083 .rc_interval = DEFAULT_RC_INTERVAL,
4084 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4085 .module_name = "dib0700",
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03004086 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004087 .allowed_protos = RC_BIT_RC5 |
4088 RC_BIT_RC6_MCE |
4089 RC_BIT_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03004090 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004091 },
4092 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4093
4094 .num_adapters = 2,
4095 .adapter = {
4096 {
Michael Krufky77eed212011-09-06 09:31:57 -03004097 .num_frontends = 1,
4098 .fe = {{
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004099 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4100 .pid_filter_count = 32,
4101 .pid_filter = stk70x0p_pid_filter,
4102 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
4103 .frontend_attach = stk7070pd_frontend_attach0,
4104 .tuner_attach = dib7070p_tuner_attach,
4105
4106 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004107 }},
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004108 .size_of_priv = sizeof(struct dib0700_adapter_state),
4109 }, {
Michael Krufky77eed212011-09-06 09:31:57 -03004110 .num_frontends = 1,
4111 .fe = {{
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004112 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4113 .pid_filter_count = 32,
4114 .pid_filter = stk70x0p_pid_filter,
4115 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
4116 .frontend_attach = stk7070pd_frontend_attach1,
4117 .tuner_attach = dib7070p_tuner_attach,
4118
4119 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
Michael Krufky77eed212011-09-06 09:31:57 -03004120 }},
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004121 .size_of_priv = sizeof(struct dib0700_adapter_state),
4122 }
4123 },
4124
4125 .num_device_descs = 1,
4126 .devices = {
Michael Müller84e2f032010-04-26 22:18:57 -03004127 { "Elgato EyeTV Diversity",
4128 { &dib0700_usb_id_table[68], NULL },
4129 { NULL },
4130 },
Arne Luehrsc985a8d2009-01-21 01:37:20 -03004131 },
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004132
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004133 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004134 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004135 .rc_codes = RC_MAP_DIB0700_NEC_TABLE,
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004136 .module_name = "dib0700",
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03004137 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004138 .allowed_protos = RC_BIT_RC5 |
4139 RC_BIT_RC6_MCE |
4140 RC_BIT_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03004141 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004142 },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03004143 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4144
4145 .num_adapters = 1,
4146 .adapter = {
4147 {
Michael Krufky77eed212011-09-06 09:31:57 -03004148 .num_frontends = 1,
4149 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03004150 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4151 .pid_filter_count = 32,
4152 .pid_filter = stk70x0p_pid_filter,
4153 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03004154 .frontend_attach = stk7700ph_frontend_attach,
4155 .tuner_attach = stk7700ph_tuner_attach,
4156
4157 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004158 }},
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03004159 .size_of_priv = sizeof(struct
4160 dib0700_adapter_state),
4161 },
4162 },
4163
Pete Hildebrandtc53d83c2009-08-05 11:46:38 -03004164 .num_device_descs = 9,
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03004165 .devices = {
4166 { "Terratec Cinergy HT USB XE",
4167 { &dib0700_usb_id_table[27], NULL },
4168 { NULL },
4169 },
4170 { "Pinnacle Expresscard 320cx",
4171 { &dib0700_usb_id_table[28], NULL },
4172 { NULL },
4173 },
4174 { "Terratec Cinergy HT Express",
4175 { &dib0700_usb_id_table[32], NULL },
4176 { NULL },
4177 },
Finn Thain17a370b2008-09-06 13:42:47 -03004178 { "Gigabyte U8000-RH",
4179 { &dib0700_usb_id_table[37], NULL },
4180 { NULL },
4181 },
Daniel Oliveira Nascimento8751aaa2008-09-07 12:39:44 -03004182 { "YUAN High-Tech STK7700PH",
4183 { &dib0700_usb_id_table[38], NULL },
4184 { NULL },
4185 },
Albert Comerma57697432008-09-07 12:43:33 -03004186 { "Asus My Cinema-U3000Hybrid",
4187 { &dib0700_usb_id_table[39], NULL },
4188 { NULL },
4189 },
Xoan Loureiro16ba1ee2009-03-29 08:43:36 -03004190 { "YUAN High-Tech MC770",
4191 { &dib0700_usb_id_table[48], NULL },
4192 { NULL },
4193 },
tomas petrf0f4ae72009-05-20 05:28:05 -03004194 { "Leadtek WinFast DTV Dongle H",
4195 { &dib0700_usb_id_table[51], NULL },
4196 { NULL },
4197 },
Pete Hildebrandtc53d83c2009-08-05 11:46:38 -03004198 { "YUAN High-Tech STK7700D",
4199 { &dib0700_usb_id_table[54], NULL },
4200 { NULL },
4201 },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03004202 },
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004203
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004204 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004205 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004206 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004207 .module_name = "dib0700",
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03004208 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004209 .allowed_protos = RC_BIT_RC5 |
4210 RC_BIT_RC6_MCE |
4211 RC_BIT_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03004212 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004213 },
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03004214 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4215 .num_adapters = 1,
4216 .adapter = {
4217 {
Michael Krufky77eed212011-09-06 09:31:57 -03004218 .num_frontends = 1,
4219 .fe = {{
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03004220 .frontend_attach = s5h1411_frontend_attach,
4221 .tuner_attach = xc5000_tuner_attach,
4222
4223 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004224 }},
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03004225 .size_of_priv = sizeof(struct
4226 dib0700_adapter_state),
4227 },
4228 },
4229
Devin Heitmuellerd2fc3bf2008-09-25 06:22:23 -03004230 .num_device_descs = 2,
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03004231 .devices = {
4232 { "Pinnacle PCTV HD Pro USB Stick",
4233 { &dib0700_usb_id_table[40], NULL },
4234 { NULL },
4235 },
Devin Heitmuellerd2fc3bf2008-09-25 06:22:23 -03004236 { "Pinnacle PCTV HD USB Stick",
4237 { &dib0700_usb_id_table[41], NULL },
4238 { NULL },
4239 },
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03004240 },
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004241
4242 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004243 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004244 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004245 .module_name = "dib0700",
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03004246 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004247 .allowed_protos = RC_BIT_RC5 |
4248 RC_BIT_RC6_MCE |
4249 RC_BIT_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03004250 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004251 },
Michael Krufkyce904bc2009-01-19 01:12:55 -03004252 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4253 .num_adapters = 1,
4254 .adapter = {
4255 {
Michael Krufky77eed212011-09-06 09:31:57 -03004256 .num_frontends = 1,
4257 .fe = {{
Michael Krufkyce904bc2009-01-19 01:12:55 -03004258 .frontend_attach = lgdt3305_frontend_attach,
4259 .tuner_attach = mxl5007t_tuner_attach,
4260
4261 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004262 }},
Michael Krufkyce904bc2009-01-19 01:12:55 -03004263 .size_of_priv = sizeof(struct
4264 dib0700_adapter_state),
4265 },
4266 },
4267
4268 .num_device_descs = 2,
4269 .devices = {
4270 { "Hauppauge ATSC MiniCard (B200)",
4271 { &dib0700_usb_id_table[46], NULL },
4272 { NULL },
4273 },
4274 { "Hauppauge ATSC MiniCard (B210)",
4275 { &dib0700_usb_id_table[47], NULL },
4276 { NULL },
4277 },
4278 },
Olivier Grenied300bd62009-09-15 06:55:35 -03004279 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4280
4281 .num_adapters = 1,
4282 .adapter = {
4283 {
Michael Krufky77eed212011-09-06 09:31:57 -03004284 .num_frontends = 1,
4285 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03004286 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4287 .pid_filter_count = 32,
4288 .pid_filter = stk70x0p_pid_filter,
4289 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
Olivier Grenie90e12ce2010-09-07 12:50:45 -03004290 .frontend_attach = stk7770p_frontend_attach,
Olivier Grenied300bd62009-09-15 06:55:35 -03004291 .tuner_attach = dib7770p_tuner_attach,
4292
4293 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004294 }},
Olivier Grenied300bd62009-09-15 06:55:35 -03004295 .size_of_priv =
Patrick Boettcherdb481382009-09-15 07:16:51 -03004296 sizeof(struct dib0700_adapter_state),
Olivier Grenied300bd62009-09-15 06:55:35 -03004297 },
4298 },
4299
Stéphane Elmalehd1402302011-05-21 07:33:38 -03004300 .num_device_descs = 4,
Olivier Grenied300bd62009-09-15 06:55:35 -03004301 .devices = {
4302 { "DiBcom STK7770P reference design",
4303 { &dib0700_usb_id_table[59], NULL },
4304 { NULL },
4305 },
Patrick Boettcher1e13c8f2009-09-19 05:24:40 -03004306 { "Terratec Cinergy T USB XXS (HD)/ T3",
4307 { &dib0700_usb_id_table[33],
4308 &dib0700_usb_id_table[52],
4309 &dib0700_usb_id_table[60], NULL},
Patrick Boettcherdb481382009-09-15 07:16:51 -03004310 { NULL },
4311 },
Lukas Max Fisch498e6772011-02-08 16:51:45 -03004312 { "TechniSat AirStar TeleStick 2",
4313 { &dib0700_usb_id_table[74], NULL },
4314 { NULL },
4315 },
Stéphane Elmalehd1402302011-05-21 07:33:38 -03004316 { "Medion CTX1921 DVB-T USB",
4317 { &dib0700_usb_id_table[75], NULL },
4318 { NULL },
4319 },
Olivier Grenied300bd62009-09-15 06:55:35 -03004320 },
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004321
4322 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004323 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004324 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004325 .module_name = "dib0700",
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03004326 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004327 .allowed_protos = RC_BIT_RC5 |
4328 RC_BIT_RC6_MCE |
4329 RC_BIT_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03004330 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004331 },
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03004332 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4333 .num_adapters = 1,
4334 .adapter = {
4335 {
Michael Krufky77eed212011-09-06 09:31:57 -03004336 .num_frontends = 1,
4337 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03004338 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4339 .pid_filter_count = 32,
Olivier Grenie03245a52009-12-04 13:27:57 -03004340 .pid_filter = stk80xx_pid_filter,
4341 .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03004342 .frontend_attach = stk807x_frontend_attach,
4343 .tuner_attach = dib807x_tuner_attach,
4344
4345 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004346 }},
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03004347 .size_of_priv =
4348 sizeof(struct dib0700_adapter_state),
4349 },
4350 },
4351
S?rgio Fortier8a378e82009-09-28 04:19:21 -03004352 .num_device_descs = 3,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03004353 .devices = {
4354 { "DiBcom STK807xP reference design",
4355 { &dib0700_usb_id_table[62], NULL },
4356 { NULL },
4357 },
Mauro Carvalho Chehabaaeab302009-09-16 09:18:26 -03004358 { "Prolink Pixelview SBTVD",
4359 { &dib0700_usb_id_table[63], NULL },
4360 { NULL },
4361 },
S?rgio Fortier8a378e82009-09-28 04:19:21 -03004362 { "EvolutePC TVWay+",
4363 { &dib0700_usb_id_table[64], NULL },
4364 { NULL },
4365 },
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03004366 },
4367
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004368 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004369 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004370 .rc_codes = RC_MAP_DIB0700_NEC_TABLE,
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004371 .module_name = "dib0700",
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03004372 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004373 .allowed_protos = RC_BIT_RC5 |
4374 RC_BIT_RC6_MCE |
4375 RC_BIT_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03004376 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004377 },
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03004378 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4379 .num_adapters = 2,
4380 .adapter = {
4381 {
Michael Krufky77eed212011-09-06 09:31:57 -03004382 .num_frontends = 1,
4383 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03004384 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4385 .pid_filter_count = 32,
Olivier Grenie03245a52009-12-04 13:27:57 -03004386 .pid_filter = stk80xx_pid_filter,
4387 .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03004388 .frontend_attach = stk807xpvr_frontend_attach0,
4389 .tuner_attach = dib807x_tuner_attach,
4390
4391 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004392 }},
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03004393 .size_of_priv =
4394 sizeof(struct dib0700_adapter_state),
4395 },
4396 {
Michael Krufky77eed212011-09-06 09:31:57 -03004397 .num_frontends = 1,
4398 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03004399 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4400 .pid_filter_count = 32,
Olivier Grenie03245a52009-12-04 13:27:57 -03004401 .pid_filter = stk80xx_pid_filter,
4402 .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03004403 .frontend_attach = stk807xpvr_frontend_attach1,
4404 .tuner_attach = dib807x_tuner_attach,
4405
4406 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
Michael Krufky77eed212011-09-06 09:31:57 -03004407 }},
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03004408 .size_of_priv =
4409 sizeof(struct dib0700_adapter_state),
4410 },
4411 },
4412
4413 .num_device_descs = 1,
4414 .devices = {
4415 { "DiBcom STK807xPVR reference design",
4416 { &dib0700_usb_id_table[61], NULL },
4417 { NULL },
4418 },
4419 },
4420
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004421 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004422 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004423 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004424 .module_name = "dib0700",
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03004425 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004426 .allowed_protos = RC_BIT_RC5 |
4427 RC_BIT_RC6_MCE |
4428 RC_BIT_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03004429 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004430 },
Olivier Grenie03245a52009-12-04 13:27:57 -03004431 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4432 .num_adapters = 1,
4433 .adapter = {
4434 {
Michael Krufky77eed212011-09-06 09:31:57 -03004435 .num_frontends = 1,
4436 .fe = {{
Olivier Grenie03245a52009-12-04 13:27:57 -03004437 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
4438 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4439 .pid_filter_count = 32,
4440 .pid_filter = stk80xx_pid_filter,
4441 .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
4442 .frontend_attach = stk809x_frontend_attach,
4443 .tuner_attach = dib809x_tuner_attach,
4444
4445 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004446 }},
Olivier Grenie03245a52009-12-04 13:27:57 -03004447 .size_of_priv =
4448 sizeof(struct dib0700_adapter_state),
4449 },
4450 },
4451
4452 .num_device_descs = 1,
4453 .devices = {
4454 { "DiBcom STK8096GP reference design",
4455 { &dib0700_usb_id_table[67], NULL },
4456 { NULL },
4457 },
4458 },
4459
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004460 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004461 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004462 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004463 .module_name = "dib0700",
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03004464 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004465 .allowed_protos = RC_BIT_RC5 |
4466 RC_BIT_RC6_MCE |
4467 RC_BIT_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03004468 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004469 },
Olivier Greniebe9bae12011-01-04 05:42:19 -03004470 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4471 .num_adapters = 1,
4472 .adapter = {
4473 {
Michael Krufky77eed212011-09-06 09:31:57 -03004474 .num_frontends = 1,
4475 .fe = {{
Olivier Greniebe9bae12011-01-04 05:42:19 -03004476 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
4477 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4478 .pid_filter_count = 32,
4479 .pid_filter = dib90x0_pid_filter,
4480 .pid_filter_ctrl = dib90x0_pid_filter_ctrl,
4481 .frontend_attach = stk9090m_frontend_attach,
4482 .tuner_attach = dib9090_tuner_attach,
4483
4484 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004485 }},
Olivier Greniebe9bae12011-01-04 05:42:19 -03004486 .size_of_priv =
4487 sizeof(struct dib0700_adapter_state),
4488 },
4489 },
4490
4491 .num_device_descs = 1,
4492 .devices = {
4493 { "DiBcom STK9090M reference design",
4494 { &dib0700_usb_id_table[69], NULL },
4495 { NULL },
4496 },
4497 },
4498
4499 .rc.core = {
4500 .rc_interval = DEFAULT_RC_INTERVAL,
4501 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4502 .module_name = "dib0700",
4503 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004504 .allowed_protos = RC_BIT_RC5 |
4505 RC_BIT_RC6_MCE |
4506 RC_BIT_NEC,
Olivier Greniebe9bae12011-01-04 05:42:19 -03004507 .change_protocol = dib0700_change_protocol,
4508 },
4509 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4510 .num_adapters = 1,
4511 .adapter = {
4512 {
Michael Krufky77eed212011-09-06 09:31:57 -03004513 .num_frontends = 1,
4514 .fe = {{
Olivier Greniebe9bae12011-01-04 05:42:19 -03004515 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
4516 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4517 .pid_filter_count = 32,
4518 .pid_filter = stk80xx_pid_filter,
4519 .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
4520 .frontend_attach = nim8096md_frontend_attach,
4521 .tuner_attach = nim8096md_tuner_attach,
4522
4523 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004524 }},
Olivier Greniebe9bae12011-01-04 05:42:19 -03004525 .size_of_priv =
4526 sizeof(struct dib0700_adapter_state),
4527 },
4528 },
4529
4530 .num_device_descs = 1,
4531 .devices = {
4532 { "DiBcom NIM8096MD reference design",
4533 { &dib0700_usb_id_table[70], NULL },
4534 { NULL },
4535 },
4536 },
4537
4538 .rc.core = {
4539 .rc_interval = DEFAULT_RC_INTERVAL,
4540 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4541 .module_name = "dib0700",
4542 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004543 .allowed_protos = RC_BIT_RC5 |
4544 RC_BIT_RC6_MCE |
4545 RC_BIT_NEC,
Olivier Greniebe9bae12011-01-04 05:42:19 -03004546 .change_protocol = dib0700_change_protocol,
4547 },
4548 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4549 .num_adapters = 1,
4550 .adapter = {
4551 {
Michael Krufky77eed212011-09-06 09:31:57 -03004552 .num_frontends = 1,
4553 .fe = {{
Olivier Greniebe9bae12011-01-04 05:42:19 -03004554 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
4555 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4556 .pid_filter_count = 32,
4557 .pid_filter = dib90x0_pid_filter,
4558 .pid_filter_ctrl = dib90x0_pid_filter_ctrl,
4559 .frontend_attach = nim9090md_frontend_attach,
4560 .tuner_attach = nim9090md_tuner_attach,
4561
4562 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004563 }},
Olivier Greniebe9bae12011-01-04 05:42:19 -03004564 .size_of_priv =
4565 sizeof(struct dib0700_adapter_state),
4566 },
4567 },
4568
4569 .num_device_descs = 1,
4570 .devices = {
4571 { "DiBcom NIM9090MD reference design",
4572 { &dib0700_usb_id_table[71], NULL },
4573 { NULL },
4574 },
4575 },
4576
4577 .rc.core = {
4578 .rc_interval = DEFAULT_RC_INTERVAL,
4579 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4580 .module_name = "dib0700",
4581 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004582 .allowed_protos = RC_BIT_RC5 |
4583 RC_BIT_RC6_MCE |
4584 RC_BIT_NEC,
Olivier Greniebe9bae12011-01-04 05:42:19 -03004585 .change_protocol = dib0700_change_protocol,
4586 },
4587 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4588 .num_adapters = 1,
4589 .adapter = {
4590 {
Michael Krufky77eed212011-09-06 09:31:57 -03004591 .num_frontends = 1,
4592 .fe = {{
Olivier Greniebe9bae12011-01-04 05:42:19 -03004593 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
4594 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4595 .pid_filter_count = 32,
4596 .pid_filter = stk70x0p_pid_filter,
4597 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
4598 .frontend_attach = nim7090_frontend_attach,
4599 .tuner_attach = nim7090_tuner_attach,
4600
4601 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004602 }},
Olivier Greniebe9bae12011-01-04 05:42:19 -03004603 .size_of_priv =
4604 sizeof(struct dib0700_adapter_state),
4605 },
4606 },
4607
4608 .num_device_descs = 1,
4609 .devices = {
4610 { "DiBcom NIM7090 reference design",
4611 { &dib0700_usb_id_table[72], NULL },
4612 { NULL },
4613 },
4614 },
4615
4616 .rc.core = {
4617 .rc_interval = DEFAULT_RC_INTERVAL,
4618 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4619 .module_name = "dib0700",
4620 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004621 .allowed_protos = RC_BIT_RC5 |
4622 RC_BIT_RC6_MCE |
4623 RC_BIT_NEC,
Olivier Greniebe9bae12011-01-04 05:42:19 -03004624 .change_protocol = dib0700_change_protocol,
4625 },
4626 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4627 .num_adapters = 2,
4628 .adapter = {
4629 {
Michael Krufky77eed212011-09-06 09:31:57 -03004630 .num_frontends = 1,
4631 .fe = {{
Olivier Greniebe9bae12011-01-04 05:42:19 -03004632 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
4633 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4634 .pid_filter_count = 32,
4635 .pid_filter = stk70x0p_pid_filter,
4636 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
4637 .frontend_attach = tfe7090pvr_frontend0_attach,
4638 .tuner_attach = tfe7090pvr_tuner0_attach,
4639
4640 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
Michael Krufky77eed212011-09-06 09:31:57 -03004641 }},
Olivier Greniebe9bae12011-01-04 05:42:19 -03004642 .size_of_priv =
4643 sizeof(struct dib0700_adapter_state),
4644 },
4645 {
Michael Krufky77eed212011-09-06 09:31:57 -03004646 .num_frontends = 1,
4647 .fe = {{
Olivier Greniebe9bae12011-01-04 05:42:19 -03004648 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
4649 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4650 .pid_filter_count = 32,
4651 .pid_filter = stk70x0p_pid_filter,
4652 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
4653 .frontend_attach = tfe7090pvr_frontend1_attach,
4654 .tuner_attach = tfe7090pvr_tuner1_attach,
4655
4656 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004657 }},
Olivier Greniebe9bae12011-01-04 05:42:19 -03004658 .size_of_priv =
4659 sizeof(struct dib0700_adapter_state),
4660 },
4661 },
4662
4663 .num_device_descs = 1,
4664 .devices = {
4665 { "DiBcom TFE7090PVR reference design",
4666 { &dib0700_usb_id_table[73], NULL },
4667 { NULL },
4668 },
4669 },
4670
4671 .rc.core = {
4672 .rc_interval = DEFAULT_RC_INTERVAL,
4673 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4674 .module_name = "dib0700",
4675 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004676 .allowed_protos = RC_BIT_RC5 |
4677 RC_BIT_RC6_MCE |
4678 RC_BIT_NEC,
Olivier Greniebe9bae12011-01-04 05:42:19 -03004679 .change_protocol = dib0700_change_protocol,
4680 },
Davide Ferri8d009a02009-06-23 22:34:06 -03004681 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4682 .num_adapters = 1,
4683 .adapter = {
4684 {
Michael Krufky77eed212011-09-06 09:31:57 -03004685 .num_frontends = 1,
4686 .fe = {{
Devin Heitmueller01f16262009-06-24 00:07:01 -03004687 .frontend_attach = pctv340e_frontend_attach,
Davide Ferri8d009a02009-06-23 22:34:06 -03004688 .tuner_attach = xc4000_tuner_attach,
4689
4690 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004691 }},
Davide Ferri8d009a02009-06-23 22:34:06 -03004692 .size_of_priv = sizeof(struct
4693 dib0700_adapter_state),
4694 },
4695 },
4696
Devin Heitmueller33fb1682009-06-23 22:48:02 -03004697 .num_device_descs = 2,
Davide Ferri8d009a02009-06-23 22:34:06 -03004698 .devices = {
4699 { "Pinnacle PCTV 340e HD Pro USB Stick",
4700 { &dib0700_usb_id_table[76], NULL },
4701 { NULL },
4702 },
Devin Heitmueller33fb1682009-06-23 22:48:02 -03004703 { "Pinnacle PCTV Hybrid Stick Solo",
4704 { &dib0700_usb_id_table[77], NULL },
4705 { NULL },
4706 },
Davide Ferri8d009a02009-06-23 22:34:06 -03004707 },
4708 .rc.core = {
4709 .rc_interval = DEFAULT_RC_INTERVAL,
4710 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4711 .module_name = "dib0700",
4712 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004713 .allowed_protos = RC_BIT_RC5 |
4714 RC_BIT_RC6_MCE |
4715 RC_BIT_NEC,
Davide Ferri8d009a02009-06-23 22:34:06 -03004716 .change_protocol = dib0700_change_protocol,
4717 },
Olivier Grenie6724a2f2011-08-05 13:49:33 -03004718 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4719 .num_adapters = 1,
4720 .adapter = {
4721 {
4722 .num_frontends = 1,
4723 .fe = {{
4724 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
4725 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4726 .pid_filter_count = 32,
4727 .pid_filter = stk70x0p_pid_filter,
4728 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
Olivier Grenief45f5132012-12-31 09:47:10 -03004729 .frontend_attach = tfe7790p_frontend_attach,
4730 .tuner_attach = tfe7790p_tuner_attach,
Olivier Grenieb293f302011-08-09 04:48:25 -03004731
4732 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
4733 } },
4734
4735 .size_of_priv =
4736 sizeof(struct dib0700_adapter_state),
4737 },
4738 },
4739
4740 .num_device_descs = 1,
4741 .devices = {
Olivier Grenief45f5132012-12-31 09:47:10 -03004742 { "DiBcom TFE7790P reference design",
4743 { &dib0700_usb_id_table[78], NULL },
Olivier Grenieb293f302011-08-09 04:48:25 -03004744 { NULL },
4745 },
4746 },
4747
4748 .rc.core = {
4749 .rc_interval = DEFAULT_RC_INTERVAL,
4750 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4751 .module_name = "dib0700",
4752 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004753 .allowed_protos = RC_BIT_RC5 |
4754 RC_BIT_RC6_MCE |
4755 RC_BIT_NEC,
Olivier Grenieb293f302011-08-09 04:48:25 -03004756 .change_protocol = dib0700_change_protocol,
4757 },
Olivier Grenie88f3a352011-08-10 05:28:38 -03004758 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4759 .num_adapters = 1,
4760 .adapter = {
4761 {
4762 .num_frontends = 1,
4763 .fe = {{
4764 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
4765 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4766 .pid_filter_count = 32,
4767 .pid_filter = stk80xx_pid_filter,
4768 .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
4769 .frontend_attach = tfe8096p_frontend_attach,
4770 .tuner_attach = tfe8096p_tuner_attach,
4771
4772 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
4773
4774 } },
4775
4776 .size_of_priv =
4777 sizeof(struct dib0700_adapter_state),
4778 },
4779 },
4780
4781 .num_device_descs = 1,
4782 .devices = {
4783 { "DiBcom TFE8096P reference design",
Olivier Grenief45f5132012-12-31 09:47:10 -03004784 { &dib0700_usb_id_table[79], NULL },
Olivier Grenie88f3a352011-08-10 05:28:38 -03004785 { NULL },
4786 },
4787 },
4788
4789 .rc.core = {
4790 .rc_interval = DEFAULT_RC_INTERVAL,
4791 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4792 .module_name = "dib0700",
4793 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004794 .allowed_protos = RC_BIT_RC5 |
4795 RC_BIT_RC6_MCE |
4796 RC_BIT_NEC,
Olivier Grenie88f3a352011-08-10 05:28:38 -03004797 .change_protocol = dib0700_change_protocol,
4798 },
Patrick Boettcher01373a52007-07-30 12:49:04 -03004799 },
Patrick Boettcherb7f54912006-09-19 12:51:37 -03004800};
4801
4802int dib0700_device_count = ARRAY_SIZE(dib0700_devices);