blob: 90cee380d3aa2b7433196098d0974b18f5e42ce5 [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;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -030035 struct dib7000p_ops dib7000p_ops;
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -030036 struct dib8000_ops dib8000_ops;
Patrick Boettcher01373a52007-07-30 12:49:04 -030037};
38
39/* Hauppauge Nova-T 500 (aka Bristol)
Patrick Boettcherb7f54912006-09-19 12:51:37 -030040 * has a LNA on GPIO0 which is enabled by setting 1 */
41static struct mt2060_config bristol_mt2060_config[2] = {
42 {
43 .i2c_address = 0x60,
Patrick Boettcher303cbea2006-09-19 12:51:56 -030044 .clock_out = 3,
Patrick Boettcherb7f54912006-09-19 12:51:37 -030045 }, {
46 .i2c_address = 0x61,
47 }
48};
49
Devin Heitmueller99afb982008-11-15 07:13:07 -030050
Patrick Boettcherb7f54912006-09-19 12:51:37 -030051static struct dibx000_agc_config bristol_dib3000p_mt2060_agc_config = {
52 .band_caps = BAND_VHF | BAND_UHF,
Patrick Boettcher01b4bf32006-09-19 12:51:53 -030053 .setup = (1 << 8) | (5 << 5) | (0 << 4) | (0 << 3) | (0 << 2) | (2 << 0),
Patrick Boettcherb7f54912006-09-19 12:51:37 -030054
Patrick Boettcher6958eff2006-09-19 12:51:40 -030055 .agc1_max = 42598,
56 .agc1_min = 17694,
57 .agc2_max = 45875,
58 .agc2_min = 0,
Patrick Boettcherb7f54912006-09-19 12:51:37 -030059
Patrick Boettcher6958eff2006-09-19 12:51:40 -030060 .agc1_pt1 = 0,
61 .agc1_pt2 = 59,
Patrick Boettcherb7f54912006-09-19 12:51:37 -030062
Patrick Boettcher6958eff2006-09-19 12:51:40 -030063 .agc1_slope1 = 0,
64 .agc1_slope2 = 69,
Patrick Boettcherb7f54912006-09-19 12:51:37 -030065
66 .agc2_pt1 = 0,
Patrick Boettcher6958eff2006-09-19 12:51:40 -030067 .agc2_pt2 = 59,
Patrick Boettcherb7f54912006-09-19 12:51:37 -030068
Patrick Boettcher6958eff2006-09-19 12:51:40 -030069 .agc2_slope1 = 111,
70 .agc2_slope2 = 28,
Patrick Boettcherb7f54912006-09-19 12:51:37 -030071};
72
73static struct dib3000mc_config bristol_dib3000mc_config[2] = {
74 { .agc = &bristol_dib3000p_mt2060_agc_config,
75 .max_time = 0x196,
76 .ln_adc_level = 0x1cc7,
77 .output_mpeg2_in_188_bytes = 1,
78 },
79 { .agc = &bristol_dib3000p_mt2060_agc_config,
80 .max_time = 0x196,
81 .ln_adc_level = 0x1cc7,
82 .output_mpeg2_in_188_bytes = 1,
83 }
84};
85
86static int bristol_frontend_attach(struct dvb_usb_adapter *adap)
87{
Patrick Boettcher6958eff2006-09-19 12:51:40 -030088 struct dib0700_state *st = adap->dev->priv;
Patrick Boettcherb7f54912006-09-19 12:51:37 -030089 if (adap->id == 0) {
90 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0); msleep(10);
91 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1); msleep(10);
92 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0); msleep(10);
93 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1); msleep(10);
94
Patrick Boettcher7fb3fc02006-09-20 04:37:18 -030095 if (force_lna_activation)
96 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
97 else
98 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 0);
Patrick Boettcher6958eff2006-09-19 12:51:40 -030099
Patrick Boettcherb7f54912006-09-19 12:51:37 -0300100 if (dib3000mc_i2c_enumeration(&adap->dev->i2c_adap, 2, DEFAULT_DIB3000P_I2C_ADDRESS, bristol_dib3000mc_config) != 0) {
101 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0); msleep(10);
102 return -ENODEV;
103 }
104 }
Patrick Boettcher6958eff2006-09-19 12:51:40 -0300105 st->mt2060_if1[adap->id] = 1220;
Michael Krufky77eed212011-09-06 09:31:57 -0300106 return (adap->fe_adap[0].fe = dvb_attach(dib3000mc_attach, &adap->dev->i2c_adap,
Patrick Boettcher6958eff2006-09-19 12:51:40 -0300107 (10 + adap->id) << 1, &bristol_dib3000mc_config[adap->id])) == NULL ? -ENODEV : 0;
Patrick Boettcherb7f54912006-09-19 12:51:37 -0300108}
109
Patrick Boettcher4a2b1082008-01-25 07:32:58 -0300110static int eeprom_read(struct i2c_adapter *adap,u8 adrs,u8 *pval)
Olivier DANETc52344f2008-01-25 06:50:07 -0300111{
112 struct i2c_msg msg[2] = {
113 { .addr = 0x50, .flags = 0, .buf = &adrs, .len = 1 },
114 { .addr = 0x50, .flags = I2C_M_RD, .buf = pval, .len = 1 },
115 };
116 if (i2c_transfer(adap, msg, 2) != 2) return -EREMOTEIO;
117 return 0;
118}
119
Patrick Boettcherb7f54912006-09-19 12:51:37 -0300120static int bristol_tuner_attach(struct dvb_usb_adapter *adap)
121{
Olivier DANETc52344f2008-01-25 06:50:07 -0300122 struct i2c_adapter *prim_i2c = &adap->dev->i2c_adap;
Michael Krufky77eed212011-09-06 09:31:57 -0300123 struct i2c_adapter *tun_i2c = dib3000mc_get_tuner_i2c_master(adap->fe_adap[0].fe, 1);
Olivier DANETc52344f2008-01-25 06:50:07 -0300124 s8 a;
125 int if1=1220;
Al Viroda5ee482008-05-21 00:31:21 -0300126 if (adap->dev->udev->descriptor.idVendor == cpu_to_le16(USB_VID_HAUPPAUGE) &&
127 adap->dev->udev->descriptor.idProduct == cpu_to_le16(USB_PID_HAUPPAUGE_NOVA_T_500_2)) {
Olivier DANETc52344f2008-01-25 06:50:07 -0300128 if (!eeprom_read(prim_i2c,0x59 + adap->id,&a)) if1=1220+a;
129 }
Michael Krufky9a9677a2011-09-13 01:32:11 -0300130 return dvb_attach(mt2060_attach, adap->fe_adap[0].fe, tun_i2c,
131 &bristol_mt2060_config[adap->id], if1) == NULL ?
132 -ENODEV : 0;
Patrick Boettcherb7f54912006-09-19 12:51:37 -0300133}
134
Patrick Boettcher01373a52007-07-30 12:49:04 -0300135/* STK7700D: Pinnacle/Terratec/Hauppauge Dual DVB-T Diversity */
Olivier DANET54d75eb2007-07-25 14:42:54 -0300136
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300137/* MT226x */
138static struct dibx000_agc_config stk7700d_7000p_mt2266_agc_config[2] = {
139 {
Olivier Grenie9c783032009-12-07 07:49:40 -0300140 BAND_UHF,
Olivier DANET54d75eb2007-07-25 14:42:54 -0300141
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300142 /* 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,
143 * 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 -0300144 (0 << 15) | (0 << 14) | (1 << 11) | (1 << 10) | (1 << 9) | (0 << 8)
145 | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),
Olivier DANET54d75eb2007-07-25 14:42:54 -0300146
Olivier Grenie9c783032009-12-07 07:49:40 -0300147 1130,
148 21,
Olivier DANET54d75eb2007-07-25 14:42:54 -0300149
Olivier Grenie9c783032009-12-07 07:49:40 -0300150 0,
151 118,
Olivier DANET54d75eb2007-07-25 14:42:54 -0300152
Olivier Grenie9c783032009-12-07 07:49:40 -0300153 0,
154 3530,
155 1,
156 0,
Olivier DANET54d75eb2007-07-25 14:42:54 -0300157
Olivier Grenie9c783032009-12-07 07:49:40 -0300158 65535,
159 33770,
160 65535,
161 23592,
Olivier DANET54d75eb2007-07-25 14:42:54 -0300162
Olivier Grenie9c783032009-12-07 07:49:40 -0300163 0,
164 62,
165 255,
166 64,
167 64,
168 132,
169 192,
170 80,
171 80,
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300172
Olivier Grenie9c783032009-12-07 07:49:40 -0300173 17,
174 27,
175 23,
176 51,
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300177
Olivier Grenie9c783032009-12-07 07:49:40 -0300178 1,
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300179 }, {
Olivier Grenie9c783032009-12-07 07:49:40 -0300180 BAND_VHF | BAND_LBAND,
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300181
182 /* 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,
183 * 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 -0300184 (0 << 15) | (0 << 14) | (1 << 11) | (1 << 10) | (1 << 9) | (0 << 8)
185 | (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0),
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300186
Olivier Grenie9c783032009-12-07 07:49:40 -0300187 2372,
188 21,
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300189
Olivier Grenie9c783032009-12-07 07:49:40 -0300190 0,
191 118,
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300192
Olivier Grenie9c783032009-12-07 07:49:40 -0300193 0,
194 3530,
195 1,
196 0,
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300197
Olivier Grenie9c783032009-12-07 07:49:40 -0300198 65535,
199 0,
200 65535,
201 23592,
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300202
Olivier Grenie9c783032009-12-07 07:49:40 -0300203 0,
204 128,
205 128,
206 128,
207 0,
208 128,
209 253,
210 81,
211 0,
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300212
Olivier Grenie9c783032009-12-07 07:49:40 -0300213 17,
214 27,
215 23,
216 51,
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300217
Olivier Grenie9c783032009-12-07 07:49:40 -0300218 1,
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300219 }
Olivier DANET54d75eb2007-07-25 14:42:54 -0300220};
221
222static struct dibx000_bandwidth_config stk7700d_mt2266_pll_config = {
Mauro Carvalho Chehab09628b22014-09-22 18:57:45 -0300223 .internal = 60000,
224 .sampling = 30000,
225 .pll_prediv = 1,
226 .pll_ratio = 8,
227 .pll_range = 3,
228 .pll_reset = 1,
229 .pll_bypass = 0,
230 .enable_refdiv = 0,
231 .bypclk_div = 0,
232 .IO_CLK_en_core = 1,
233 .ADClkSrc = 1,
234 .modulo = 2,
235 .sad_cfg = (3 << 14) | (1 << 12) | (524 << 0),
236 .ifreq = 0,
237 .timf = 20452225,
Olivier DANET54d75eb2007-07-25 14:42:54 -0300238};
239
240static struct dib7000p_config stk7700d_dib7000p_mt2266_config[] = {
241 { .output_mpeg2_in_188_bytes = 1,
242 .hostbus_diversity = 1,
243 .tuner_is_baseband = 1,
244
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300245 .agc_config_count = 2,
246 .agc = stk7700d_7000p_mt2266_agc_config,
Olivier DANET54d75eb2007-07-25 14:42:54 -0300247 .bw = &stk7700d_mt2266_pll_config,
248
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300249 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
250 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
251 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
Olivier DANET54d75eb2007-07-25 14:42:54 -0300252 },
253 { .output_mpeg2_in_188_bytes = 1,
254 .hostbus_diversity = 1,
255 .tuner_is_baseband = 1,
256
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300257 .agc_config_count = 2,
258 .agc = stk7700d_7000p_mt2266_agc_config,
Olivier DANET54d75eb2007-07-25 14:42:54 -0300259 .bw = &stk7700d_mt2266_pll_config,
260
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300261 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
262 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
263 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
Olivier DANET54d75eb2007-07-25 14:42:54 -0300264 }
265};
266
267static struct mt2266_config stk7700d_mt2266_config[2] = {
268 { .i2c_address = 0x60
269 },
270 { .i2c_address = 0x60
271 }
272};
273
Daniel Gimpelevich132c3182008-01-25 06:02:42 -0300274static int stk7700P2_frontend_attach(struct dvb_usb_adapter *adap)
275{
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300276 struct dib0700_adapter_state *state = adap->priv;
277
278 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
279 return -ENODEV;
280
Daniel Gimpelevich132c3182008-01-25 06:02:42 -0300281 if (adap->id == 0) {
282 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
283 msleep(10);
284 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
285 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
286 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
287 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
288 msleep(10);
289 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
290 msleep(10);
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300291 if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 18,
Devin Heitmueller83c4fdf2009-01-21 01:55:45 -0300292 stk7700d_dib7000p_mt2266_config)
293 != 0) {
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300294 err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n", __func__);
295 dvb_detach(&state->dib7000p_ops);
Devin Heitmueller83c4fdf2009-01-21 01:55:45 -0300296 return -ENODEV;
297 }
Daniel Gimpelevich132c3182008-01-25 06:02:42 -0300298 }
299
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300300 adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap,
Michael Krufky2a776312011-09-16 09:26:59 -0300301 0x80 + (adap->id << 1),
302 &stk7700d_dib7000p_mt2266_config[adap->id]);
Daniel Gimpelevich132c3182008-01-25 06:02:42 -0300303
Michael Krufky77eed212011-09-06 09:31:57 -0300304 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Daniel Gimpelevich132c3182008-01-25 06:02:42 -0300305}
306
Olivier DANET54d75eb2007-07-25 14:42:54 -0300307static int stk7700d_frontend_attach(struct dvb_usb_adapter *adap)
308{
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300309 struct dib0700_adapter_state *state = adap->priv;
310
311 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
312 return -ENODEV;
313
Olivier DANET54d75eb2007-07-25 14:42:54 -0300314 if (adap->id == 0) {
315 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
316 msleep(10);
317 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
318 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
319 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
320 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
321 msleep(10);
322 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
323 msleep(10);
324 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300325 if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap, 2, 18,
Devin Heitmueller83c4fdf2009-01-21 01:55:45 -0300326 stk7700d_dib7000p_mt2266_config)
327 != 0) {
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300328 err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n", __func__);
329 dvb_detach(&state->dib7000p_ops);
Devin Heitmueller83c4fdf2009-01-21 01:55:45 -0300330 return -ENODEV;
331 }
Olivier DANET54d75eb2007-07-25 14:42:54 -0300332 }
333
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300334 adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap,
Michael Krufky2a776312011-09-16 09:26:59 -0300335 0x80 + (adap->id << 1),
336 &stk7700d_dib7000p_mt2266_config[adap->id]);
Olivier DANET54d75eb2007-07-25 14:42:54 -0300337
Michael Krufky77eed212011-09-06 09:31:57 -0300338 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Olivier DANET54d75eb2007-07-25 14:42:54 -0300339}
340
341static int stk7700d_tuner_attach(struct dvb_usb_adapter *adap)
342{
343 struct i2c_adapter *tun_i2c;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300344 struct dib0700_adapter_state *state = adap->priv;
345
346 tun_i2c = state->dib7000p_ops.get_i2c_master(adap->fe_adap[0].fe,
347 DIBX000_I2C_INTERFACE_TUNER, 1);
Michael Krufky77eed212011-09-06 09:31:57 -0300348 return dvb_attach(mt2266_attach, adap->fe_adap[0].fe, tun_i2c,
Joe Perches1ebcad72009-07-02 15:57:09 -0300349 &stk7700d_mt2266_config[adap->id]) == NULL ? -ENODEV : 0;
Olivier DANET54d75eb2007-07-25 14:42:54 -0300350}
351
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300352/* STK7700-PH: Digital/Analog Hybrid Tuner, e.h. Cinergy HT USB HE */
Harvey Harrisonb1721d02008-04-25 19:03:08 -0700353static struct dibx000_agc_config xc3028_agc_config = {
Mauro Carvalho Chehab09628b22014-09-22 18:57:45 -0300354 .band_caps = BAND_VHF | BAND_UHF,
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300355 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=0,
356 * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
357 * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=2, P_agc_write=0 */
Mauro Carvalho Chehab09628b22014-09-22 18:57:45 -0300358 .setup = (0 << 15) | (0 << 14) | (0 << 11) | (0 << 10) | (0 << 9) | (0 << 8) | (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0),
359 .inv_gain = 712,
360 .time_stabiliz = 21,
361 .alpha_level = 0,
362 .thlock = 118,
363 .wbd_inv = 0,
364 .wbd_ref = 2867,
365 .wbd_sel = 0,
366 .wbd_alpha = 2,
367 .agc1_max = 0,
368 .agc1_min = 0,
369 .agc2_max = 39718,
370 .agc2_min = 9930,
371 .agc1_pt1 = 0,
372 .agc1_pt2 = 0,
373 .agc1_pt3 = 0,
374 .agc1_slope1 = 0,
375 .agc1_slope2 = 0,
376 .agc2_pt1 = 0,
377 .agc2_pt2 = 128,
378 .agc2_slope1 = 29,
379 .agc2_slope2 = 29,
380 .alpha_mant = 17,
381 .alpha_exp = 27,
382 .beta_mant = 23,
383 .beta_exp = 51,
384 .perform_agc_softsplit = 1,
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300385};
386
387/* PLL Configuration for COFDM BW_MHz = 8.00 with external clock = 30.00 */
Harvey Harrisonb1721d02008-04-25 19:03:08 -0700388static struct dibx000_bandwidth_config xc3028_bw_config = {
Mauro Carvalho Chehab09628b22014-09-22 18:57:45 -0300389 .internal = 60000,
390 .sampling = 30000,
391 .pll_prediv = 1,
392 .pll_ratio = 8,
393 .pll_range = 3,
394 .pll_reset = 1,
395 .pll_bypass = 0,
396 .enable_refdiv = 0,
397 .bypclk_div = 0,
398 .IO_CLK_en_core = 1,
399 .ADClkSrc = 1,
400 .modulo = 0,
401 .sad_cfg = (3 << 14) | (1 << 12) | (524 << 0), /* sad_cfg: refsel, sel, freq_15k */
402 .ifreq = (1 << 25) | 5816102, /* ifreq = 5.200000 MHz */
403 .timf = 20452225,
404 .xtal_hz = 30000000,
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300405};
406
407static struct dib7000p_config stk7700ph_dib7700_xc3028_config = {
408 .output_mpeg2_in_188_bytes = 1,
409 .tuner_is_baseband = 1,
410
411 .agc_config_count = 1,
412 .agc = &xc3028_agc_config,
413 .bw = &xc3028_bw_config,
414
415 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
416 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
417 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
418};
419
Michael Krufkyd7cba042008-09-12 13:31:45 -0300420static int stk7700ph_xc3028_callback(void *ptr, int component,
421 int command, int arg)
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300422{
423 struct dvb_usb_adapter *adap = ptr;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300424 struct dib0700_adapter_state *state = adap->priv;
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300425
426 switch (command) {
427 case XC2028_TUNER_RESET:
428 /* Send the tuner in then out of reset */
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300429 state->dib7000p_ops.set_gpio(adap->fe_adap[0].fe, 8, 0, 0);
430 msleep(10);
431 state->dib7000p_ops.set_gpio(adap->fe_adap[0].fe, 8, 0, 1);
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300432 break;
433 case XC2028_RESET_CLK:
434 break;
435 default:
436 err("%s: unknown command %d, arg %d\n", __func__,
437 command, arg);
438 return -EINVAL;
439 }
440 return 0;
441}
442
443static struct xc2028_ctrl stk7700ph_xc3028_ctrl = {
444 .fname = XC2028_DEFAULT_FIRMWARE,
445 .max_len = 64,
446 .demod = XC3028_FE_DIBCOM52,
447};
448
449static struct xc2028_config stk7700ph_xc3028_config = {
450 .i2c_addr = 0x61,
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300451 .ctrl = &stk7700ph_xc3028_ctrl,
452};
453
454static int stk7700ph_frontend_attach(struct dvb_usb_adapter *adap)
455{
456 struct usb_device_descriptor *desc = &adap->dev->udev->descriptor;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300457 struct dib0700_adapter_state *state = adap->priv;
458
459 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
460 return -ENODEV;
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300461
Al Viroda5ee482008-05-21 00:31:21 -0300462 if (desc->idVendor == cpu_to_le16(USB_VID_PINNACLE) &&
463 desc->idProduct == cpu_to_le16(USB_PID_PINNACLE_EXPRESSCARD_320CX))
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300464 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300465 else
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300466 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300467 msleep(20);
468 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
469 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
470 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
471 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
472 msleep(10);
473 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
474 msleep(20);
475 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
476 msleep(10);
477
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300478 if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 18,
Devin Heitmueller83c4fdf2009-01-21 01:55:45 -0300479 &stk7700ph_dib7700_xc3028_config) != 0) {
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300480 err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n",
Devin Heitmueller83c4fdf2009-01-21 01:55:45 -0300481 __func__);
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300482 dvb_detach(&state->dib7000p_ops);
Devin Heitmueller83c4fdf2009-01-21 01:55:45 -0300483 return -ENODEV;
484 }
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300485
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300486 adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap, 0x80,
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300487 &stk7700ph_dib7700_xc3028_config);
488
Michael Krufky77eed212011-09-06 09:31:57 -0300489 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300490}
491
492static int stk7700ph_tuner_attach(struct dvb_usb_adapter *adap)
493{
494 struct i2c_adapter *tun_i2c;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300495 struct dib0700_adapter_state *state = adap->priv;
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300496
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300497 tun_i2c = state->dib7000p_ops.get_i2c_master(adap->fe_adap[0].fe,
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300498 DIBX000_I2C_INTERFACE_TUNER, 1);
499
500 stk7700ph_xc3028_config.i2c_adap = tun_i2c;
Michael Krufkyd7cba042008-09-12 13:31:45 -0300501
502 /* FIXME: generalize & move to common area */
Michael Krufky77eed212011-09-06 09:31:57 -0300503 adap->fe_adap[0].fe->callback = stk7700ph_xc3028_callback;
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300504
Michael Krufky77eed212011-09-06 09:31:57 -0300505 return dvb_attach(xc2028_attach, adap->fe_adap[0].fe, &stk7700ph_xc3028_config)
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300506 == NULL ? -ENODEV : 0;
507}
508
Devin Heitmueller4b330be2008-12-01 06:51:14 -0300509#define DEFAULT_RC_INTERVAL 50
Olivier DANET54d75eb2007-07-25 14:42:54 -0300510
511static u8 rc_request[] = { REQUEST_POLL_RC, 0 };
512
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -0300513/*
514 * This function is used only when firmware is < 1.20 version. Newer
515 * firmwares use bulk mode, with functions implemented at dib0700_core,
516 * at dib0700_rc_urb_completion()
517 */
518static int dib0700_rc_query_old_firmware(struct dvb_usb_device *d)
Olivier DANET54d75eb2007-07-25 14:42:54 -0300519{
520 u8 key[4];
David Härdeman120703f2014-04-03 20:31:30 -0300521 enum rc_type protocol;
522 u32 scancode;
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -0300523 u8 toggle;
Olivier DANET54d75eb2007-07-25 14:42:54 -0300524 int i;
Olivier DANET54d75eb2007-07-25 14:42:54 -0300525 struct dib0700_state *st = d->priv;
Devin Heitmueller6a207102010-01-04 02:43:19 -0300526
Devin Heitmueller6a207102010-01-04 02:43:19 -0300527 if (st->fw_version >= 0x10200) {
528 /* For 1.20 firmware , We need to keep the RC polling
529 callback so we can reuse the input device setup in
530 dvb-usb-remote.c. However, the actual work is being done
531 in the bulk URB completion handler. */
532 return 0;
533 }
534
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -0300535 i = dib0700_ctrl_rd(d, rc_request, 2, key, 4);
536 if (i <= 0) {
Janne Grunau034d65e2007-07-31 08:48:40 -0300537 err("RC Query Failed");
Janne Grunau89f42672007-07-31 19:45:13 -0300538 return -1;
Olivier DANET54d75eb2007-07-25 14:42:54 -0300539 }
Patrick Boettcher58e6f952008-03-29 21:37:01 -0300540
541 /* losing half of KEY_0 events from Philipps rc5 remotes.. */
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -0300542 if (key[0] == 0 && key[1] == 0 && key[2] == 0 && key[3] == 0)
543 return 0;
Patrick Boettcher58e6f952008-03-29 21:37:01 -0300544
545 /* 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]); */
546
Mauro Carvalho Chehabc4018fa2014-05-21 17:40:25 -0300547 dib0700_rc_setup(d, NULL); /* reset ir sensor data to prevent false events */
Patrick Boettcher58e6f952008-03-29 21:37:01 -0300548
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -0300549 switch (d->props.rc.core.protocol) {
David Härdemanc003ab12012-10-11 19:11:54 -0300550 case RC_BIT_NEC:
Patrick Boettcher58e6f952008-03-29 21:37:01 -0300551 /* NEC protocol sends repeat code as 0 0 0 FF */
552 if ((key[3-2] == 0x00) && (key[3-3] == 0x00) &&
David Härdeman120703f2014-04-03 20:31:30 -0300553 (key[3] == 0xff)) {
554 rc_repeat(d->rc_dev);
555 return 0;
Patrick Boettcher58e6f952008-03-29 21:37:01 -0300556 }
Patrick Boettcher58e6f952008-03-29 21:37:01 -0300557
David Härdeman120703f2014-04-03 20:31:30 -0300558 protocol = RC_TYPE_NEC;
559 scancode = RC_SCANCODE_NEC(key[3-2], key[3-3]);
560 toggle = 0;
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -0300561 break;
David Härdeman120703f2014-04-03 20:31:30 -0300562
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -0300563 default:
564 /* RC-5 protocol changes toggle bit on new keypress */
David Härdeman120703f2014-04-03 20:31:30 -0300565 protocol = RC_TYPE_RC5;
566 scancode = RC_SCANCODE_RC5(key[3-2], key[3-3]);
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -0300567 toggle = key[3-1];
Patrick Boettcher58e6f952008-03-29 21:37:01 -0300568 break;
569 }
David Härdeman120703f2014-04-03 20:31:30 -0300570
571 rc_keydown(d->rc_dev, protocol, scancode, toggle);
Olivier DANET54d75eb2007-07-25 14:42:54 -0300572 return 0;
573}
574
Patrick Boettcherb7f54912006-09-19 12:51:37 -0300575/* STK7700P: Hauppauge Nova-T Stick, AVerMedia Volar */
Patrick Boettchera75763f2006-10-18 08:34:16 -0300576static struct dibx000_agc_config stk7700p_7000m_mt2060_agc_config = {
Olivier Grenie9c783032009-12-07 07:49:40 -0300577 BAND_UHF | BAND_VHF,
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300578
579 /* 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,
580 * 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 -0300581 (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8)
582 | (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0),
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300583
Olivier Grenie9c783032009-12-07 07:49:40 -0300584 712,
585 41,
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300586
Olivier Grenie9c783032009-12-07 07:49:40 -0300587 0,
588 118,
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300589
Olivier Grenie9c783032009-12-07 07:49:40 -0300590 0,
591 4095,
592 0,
593 0,
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300594
Olivier Grenie9c783032009-12-07 07:49:40 -0300595 42598,
596 17694,
597 45875,
598 2621,
599 0,
600 76,
601 139,
602 52,
603 59,
604 107,
605 172,
606 57,
607 70,
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300608
Olivier Grenie9c783032009-12-07 07:49:40 -0300609 21,
610 25,
611 28,
612 48,
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300613
Olivier Grenie9c783032009-12-07 07:49:40 -0300614 1,
615 { 0,
616 107,
617 51800,
618 24700
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300619 },
Patrick Boettcherb7f54912006-09-19 12:51:37 -0300620};
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300621
Patrick Boettchera75763f2006-10-18 08:34:16 -0300622static struct dibx000_agc_config stk7700p_7000p_mt2060_agc_config = {
Mauro Carvalho Chehab09628b22014-09-22 18:57:45 -0300623 .band_caps = BAND_UHF | BAND_VHF,
Patrick Boettchera75763f2006-10-18 08:34:16 -0300624 /* 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,
625 * 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 */
Mauro Carvalho Chehab09628b22014-09-22 18:57:45 -0300626 .setup = (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8) | (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0),
627 .inv_gain = 712,
628 .time_stabiliz = 41,
629 .alpha_level = 0,
630 .thlock = 118,
631 .wbd_inv = 0,
632 .wbd_ref = 4095,
633 .wbd_sel = 0,
634 .wbd_alpha = 0,
635 .agc1_max = 42598,
636 .agc1_min = 16384,
637 .agc2_max = 42598,
638 .agc2_min = 0,
639 .agc1_pt1 = 0,
640 .agc1_pt2 = 137,
641 .agc1_pt3 = 255,
642 .agc1_slope1 = 0,
643 .agc1_slope2 = 255,
644 .agc2_pt1 = 0,
645 .agc2_pt2 = 0,
646 .agc2_slope1 = 0,
647 .agc2_slope2 = 41,
648 .alpha_mant = 15,
649 .alpha_exp = 25,
650 .beta_mant = 28,
651 .beta_exp = 48,
652 .perform_agc_softsplit = 0,
Patrick Boettchera75763f2006-10-18 08:34:16 -0300653};
654
655static struct dibx000_bandwidth_config stk7700p_pll_config = {
Mauro Carvalho Chehab09628b22014-09-22 18:57:45 -0300656 .internal = 60000,
657 .sampling = 30000,
658 .pll_prediv = 1,
659 .pll_ratio = 8,
660 .pll_range = 3,
661 .pll_reset = 1,
662 .pll_bypass = 0,
663 .enable_refdiv = 0,
664 .bypclk_div = 0,
665 .IO_CLK_en_core = 1,
666 .ADClkSrc = 1,
667 .modulo = 0,
668 .sad_cfg = (3 << 14) | (1 << 12) | (524 << 0),
669 .ifreq = 60258167,
670 .timf = 20452225,
671 .xtal_hz = 30000000,
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300672};
673
674static struct dib7000m_config stk7700p_dib7000m_config = {
675 .dvbt_mode = 1,
676 .output_mpeg2_in_188_bytes = 1,
677 .quartz_direct = 1,
678
679 .agc_config_count = 1,
Patrick Boettchera75763f2006-10-18 08:34:16 -0300680 .agc = &stk7700p_7000m_mt2060_agc_config,
681 .bw = &stk7700p_pll_config,
682
683 .gpio_dir = DIB7000M_GPIO_DEFAULT_DIRECTIONS,
684 .gpio_val = DIB7000M_GPIO_DEFAULT_VALUES,
685 .gpio_pwm_pos = DIB7000M_GPIO_DEFAULT_PWM_POS,
686};
687
688static struct dib7000p_config stk7700p_dib7000p_config = {
689 .output_mpeg2_in_188_bytes = 1,
690
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300691 .agc_config_count = 1,
Patrick Boettchera75763f2006-10-18 08:34:16 -0300692 .agc = &stk7700p_7000p_mt2060_agc_config,
693 .bw = &stk7700p_pll_config,
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300694
695 .gpio_dir = DIB7000M_GPIO_DEFAULT_DIRECTIONS,
696 .gpio_val = DIB7000M_GPIO_DEFAULT_VALUES,
697 .gpio_pwm_pos = DIB7000M_GPIO_DEFAULT_PWM_POS,
698};
Patrick Boettcherb7f54912006-09-19 12:51:37 -0300699
700static int stk7700p_frontend_attach(struct dvb_usb_adapter *adap)
701{
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300702 struct dib0700_state *st = adap->dev->priv;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300703 struct dib0700_adapter_state *state = adap->priv;
704
705 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
706 return -ENODEV;
707
Patrick Boettcherb7f54912006-09-19 12:51:37 -0300708 /* unless there is no real power management in DVB - we leave the device on GPIO6 */
Patrick Boettchera75763f2006-10-18 08:34:16 -0300709
710 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
711 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0); msleep(50);
712
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300713 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1); msleep(10);
Patrick Boettchera75763f2006-10-18 08:34:16 -0300714 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
715
Patrick Boettcherb7f54912006-09-19 12:51:37 -0300716 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0); msleep(10);
Patrick Boettchera75763f2006-10-18 08:34:16 -0300717 dib0700_ctrl_clock(adap->dev, 72, 1);
718 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1); msleep(100);
719
720 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
Patrick Boettcherb7f54912006-09-19 12:51:37 -0300721
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300722 st->mt2060_if1[0] = 1220;
Patrick Boettchera75763f2006-10-18 08:34:16 -0300723
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300724 if (state->dib7000p_ops.dib7000pc_detection(&adap->dev->i2c_adap)) {
725 adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap, 18, &stk7700p_dib7000p_config);
Patrick Boettchera75763f2006-10-18 08:34:16 -0300726 st->is_dib7000pc = 1;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300727 } else {
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300728 memset(&state->dib7000p_ops, 0, sizeof(state->dib7000p_ops));
Michael Krufky77eed212011-09-06 09:31:57 -0300729 adap->fe_adap[0].fe = dvb_attach(dib7000m_attach, &adap->dev->i2c_adap, 18, &stk7700p_dib7000m_config);
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300730 }
Patrick Boettchera75763f2006-10-18 08:34:16 -0300731
Michael Krufky77eed212011-09-06 09:31:57 -0300732 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Patrick Boettcherb7f54912006-09-19 12:51:37 -0300733}
734
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300735static struct mt2060_config stk7700p_mt2060_config = {
736 0x60
737};
738
Patrick Boettcherb7f54912006-09-19 12:51:37 -0300739static int stk7700p_tuner_attach(struct dvb_usb_adapter *adap)
740{
Olivier DANETc52344f2008-01-25 06:50:07 -0300741 struct i2c_adapter *prim_i2c = &adap->dev->i2c_adap;
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300742 struct dib0700_state *st = adap->dev->priv;
Patrick Boettchera75763f2006-10-18 08:34:16 -0300743 struct i2c_adapter *tun_i2c;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300744 struct dib0700_adapter_state *state = adap->priv;
Olivier DANETc52344f2008-01-25 06:50:07 -0300745 s8 a;
746 int if1=1220;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300747
Al Viroda5ee482008-05-21 00:31:21 -0300748 if (adap->dev->udev->descriptor.idVendor == cpu_to_le16(USB_VID_HAUPPAUGE) &&
749 adap->dev->udev->descriptor.idProduct == cpu_to_le16(USB_PID_HAUPPAUGE_NOVA_T_STICK)) {
Olivier DANETc52344f2008-01-25 06:50:07 -0300750 if (!eeprom_read(prim_i2c,0x58,&a)) if1=1220+a;
751 }
Patrick Boettchera75763f2006-10-18 08:34:16 -0300752 if (st->is_dib7000pc)
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300753 tun_i2c = state->dib7000p_ops.get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_TUNER, 1);
Patrick Boettchera75763f2006-10-18 08:34:16 -0300754 else
Michael Krufky77eed212011-09-06 09:31:57 -0300755 tun_i2c = dib7000m_get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_TUNER, 1);
Patrick Boettchera75763f2006-10-18 08:34:16 -0300756
Michael Krufky77eed212011-09-06 09:31:57 -0300757 return dvb_attach(mt2060_attach, adap->fe_adap[0].fe, tun_i2c, &stk7700p_mt2060_config,
Olivier DANETc52344f2008-01-25 06:50:07 -0300758 if1) == NULL ? -ENODEV : 0;
Patrick Boettcherb7f54912006-09-19 12:51:37 -0300759}
760
Patrick Boettcher01373a52007-07-30 12:49:04 -0300761/* DIB7070 generic */
762static struct dibx000_agc_config dib7070_agc_config = {
Mauro Carvalho Chehab09628b22014-09-22 18:57:45 -0300763 .band_caps = BAND_UHF | BAND_VHF | BAND_LBAND | BAND_SBAND,
Patrick Boettcher01373a52007-07-30 12:49:04 -0300764 /* 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,
765 * 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 */
Mauro Carvalho Chehab09628b22014-09-22 18:57:45 -0300766 .setup = (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),
767 .inv_gain = 600,
768 .time_stabiliz = 10,
769 .alpha_level = 0,
770 .thlock = 118,
771 .wbd_inv = 0,
772 .wbd_ref = 3530,
773 .wbd_sel = 1,
774 .wbd_alpha = 5,
775 .agc1_max = 65535,
776 .agc1_min = 0,
777 .agc2_max = 65535,
778 .agc2_min = 0,
779 .agc1_pt1 = 0,
780 .agc1_pt2 = 40,
781 .agc1_pt3 = 183,
782 .agc1_slope1 = 206,
783 .agc1_slope2 = 255,
784 .agc2_pt1 = 72,
785 .agc2_pt2 = 152,
786 .agc2_slope1 = 88,
787 .agc2_slope2 = 90,
788 .alpha_mant = 17,
789 .alpha_exp = 27,
790 .beta_mant = 23,
791 .beta_exp = 51,
792 .perform_agc_softsplit = 0,
Patrick Boettcher01373a52007-07-30 12:49:04 -0300793};
794
795static int dib7070_tuner_reset(struct dvb_frontend *fe, int onoff)
796{
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300797 struct dvb_usb_adapter *adap = fe->dvb->priv;
798 struct dib0700_adapter_state *state = adap->priv;
799
Patrick Boettcher7e5ce652009-08-03 13:43:40 -0300800 deb_info("reset: %d", onoff);
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300801 return state->dib7000p_ops.set_gpio(fe, 8, 0, !onoff);
Patrick Boettcher01373a52007-07-30 12:49:04 -0300802}
803
804static int dib7070_tuner_sleep(struct dvb_frontend *fe, int onoff)
805{
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300806 struct dvb_usb_adapter *adap = fe->dvb->priv;
807 struct dib0700_adapter_state *state = adap->priv;
808
Patrick Boettcher7e5ce652009-08-03 13:43:40 -0300809 deb_info("sleep: %d", onoff);
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300810 return state->dib7000p_ops.set_gpio(fe, 9, 0, onoff);
Patrick Boettcher01373a52007-07-30 12:49:04 -0300811}
812
813static struct dib0070_config dib7070p_dib0070_config[2] = {
814 {
815 .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
816 .reset = dib7070_tuner_reset,
817 .sleep = dib7070_tuner_sleep,
818 .clock_khz = 12000,
Patrick Boettcher7e5ce652009-08-03 13:43:40 -0300819 .clock_pad_drive = 4,
820 .charge_pump = 2,
Patrick Boettcher01373a52007-07-30 12:49:04 -0300821 }, {
822 .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
823 .reset = dib7070_tuner_reset,
824 .sleep = dib7070_tuner_sleep,
825 .clock_khz = 12000,
Patrick Boettcher7e5ce652009-08-03 13:43:40 -0300826 .charge_pump = 2,
Patrick Boettcher01373a52007-07-30 12:49:04 -0300827 }
828};
829
Olivier Grenied300bd62009-09-15 06:55:35 -0300830static struct dib0070_config dib7770p_dib0070_config = {
831 .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
832 .reset = dib7070_tuner_reset,
833 .sleep = dib7070_tuner_sleep,
834 .clock_khz = 12000,
835 .clock_pad_drive = 0,
836 .flip_chip = 1,
Olivier Grenieeac1fe12009-09-23 13:41:27 -0300837 .charge_pump = 2,
Olivier Grenied300bd62009-09-15 06:55:35 -0300838};
839
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -0300840static int dib7070_set_param_override(struct dvb_frontend *fe)
Patrick Boettcher01373a52007-07-30 12:49:04 -0300841{
Mauro Carvalho Chehab47b163a2011-12-24 10:18:24 -0300842 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
Patrick Boettcher01373a52007-07-30 12:49:04 -0300843 struct dvb_usb_adapter *adap = fe->dvb->priv;
844 struct dib0700_adapter_state *state = adap->priv;
845
846 u16 offset;
Mauro Carvalho Chehab47b163a2011-12-24 10:18:24 -0300847 u8 band = BAND_OF_FREQUENCY(p->frequency/1000);
Patrick Boettcher01373a52007-07-30 12:49:04 -0300848 switch (band) {
849 case BAND_VHF: offset = 950; break;
850 case BAND_UHF:
851 default: offset = 550; break;
852 }
853 deb_info("WBD for DiB7000P: %d\n", offset + dib0070_wbd_offset(fe));
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300854 state->dib7000p_ops.set_wbd_ref(fe, offset + dib0070_wbd_offset(fe));
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -0300855 return state->set_param_save(fe);
Patrick Boettcher01373a52007-07-30 12:49:04 -0300856}
857
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -0300858static int dib7770_set_param_override(struct dvb_frontend *fe)
Olivier Grenied300bd62009-09-15 06:55:35 -0300859{
Mauro Carvalho Chehab47b163a2011-12-24 10:18:24 -0300860 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
861 struct dvb_usb_adapter *adap = fe->dvb->priv;
862 struct dib0700_adapter_state *state = adap->priv;
Olivier Grenied300bd62009-09-15 06:55:35 -0300863
Mauro Carvalho Chehab316c46b2015-04-29 17:16:27 -0300864 u16 offset;
865 u8 band = BAND_OF_FREQUENCY(p->frequency/1000);
866 switch (band) {
867 case BAND_VHF:
868 state->dib7000p_ops.set_gpio(fe, 0, 0, 1);
869 offset = 850;
870 break;
871 case BAND_UHF:
872 default:
873 state->dib7000p_ops.set_gpio(fe, 0, 0, 0);
874 offset = 250;
875 break;
876 }
877 deb_info("WBD for DiB7000P: %d\n", offset + dib0070_wbd_offset(fe));
878 state->dib7000p_ops.set_wbd_ref(fe, offset + dib0070_wbd_offset(fe));
879 return state->set_param_save(fe);
Olivier Grenied300bd62009-09-15 06:55:35 -0300880}
881
882static int dib7770p_tuner_attach(struct dvb_usb_adapter *adap)
883{
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300884 struct dib0700_adapter_state *st = adap->priv;
885 struct i2c_adapter *tun_i2c = st->dib7000p_ops.get_i2c_master(adap->fe_adap[0].fe,
Olivier Grenied300bd62009-09-15 06:55:35 -0300886 DIBX000_I2C_INTERFACE_TUNER, 1);
887
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300888 if (dvb_attach(dib0070_attach, adap->fe_adap[0].fe, tun_i2c,
889 &dib7770p_dib0070_config) == NULL)
890 return -ENODEV;
Olivier Grenied300bd62009-09-15 06:55:35 -0300891
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300892 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
893 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib7770_set_param_override;
894 return 0;
Olivier Grenied300bd62009-09-15 06:55:35 -0300895}
896
Patrick Boettcher01373a52007-07-30 12:49:04 -0300897static int dib7070p_tuner_attach(struct dvb_usb_adapter *adap)
898{
899 struct dib0700_adapter_state *st = adap->priv;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300900 struct i2c_adapter *tun_i2c = st->dib7000p_ops.get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_TUNER, 1);
Patrick Boettcher01373a52007-07-30 12:49:04 -0300901
902 if (adap->id == 0) {
Michael Krufky77eed212011-09-06 09:31:57 -0300903 if (dvb_attach(dib0070_attach, adap->fe_adap[0].fe, tun_i2c, &dib7070p_dib0070_config[0]) == NULL)
Patrick Boettcher01373a52007-07-30 12:49:04 -0300904 return -ENODEV;
905 } else {
Michael Krufky77eed212011-09-06 09:31:57 -0300906 if (dvb_attach(dib0070_attach, adap->fe_adap[0].fe, tun_i2c, &dib7070p_dib0070_config[1]) == NULL)
Patrick Boettcher01373a52007-07-30 12:49:04 -0300907 return -ENODEV;
908 }
909
Michael Krufky77eed212011-09-06 09:31:57 -0300910 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
911 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib7070_set_param_override;
Patrick Boettcher01373a52007-07-30 12:49:04 -0300912 return 0;
913}
914
Olivier Greniee192a7c2011-01-14 13:58:59 -0300915static int stk7700p_pid_filter(struct dvb_usb_adapter *adapter, int index,
916 u16 pid, int onoff)
917{
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300918 struct dib0700_adapter_state *state = adapter->priv;
Olivier Greniee192a7c2011-01-14 13:58:59 -0300919 struct dib0700_state *st = adapter->dev->priv;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300920
Olivier Greniee192a7c2011-01-14 13:58:59 -0300921 if (st->is_dib7000pc)
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300922 return state->dib7000p_ops.pid_filter(adapter->fe_adap[0].fe, index, pid, onoff);
Michael Krufky77eed212011-09-06 09:31:57 -0300923 return dib7000m_pid_filter(adapter->fe_adap[0].fe, index, pid, onoff);
Olivier Greniee192a7c2011-01-14 13:58:59 -0300924}
925
926static int stk7700p_pid_filter_ctrl(struct dvb_usb_adapter *adapter, int onoff)
927{
928 struct dib0700_state *st = adapter->dev->priv;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300929 struct dib0700_adapter_state *state = adapter->priv;
Olivier Greniee192a7c2011-01-14 13:58:59 -0300930 if (st->is_dib7000pc)
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300931 return state->dib7000p_ops.pid_filter_ctrl(adapter->fe_adap[0].fe, onoff);
Michael Krufky77eed212011-09-06 09:31:57 -0300932 return dib7000m_pid_filter_ctrl(adapter->fe_adap[0].fe, onoff);
Olivier Greniee192a7c2011-01-14 13:58:59 -0300933}
934
Olivier Grenief8731f42009-09-18 04:08:43 -0300935static int stk70x0p_pid_filter(struct dvb_usb_adapter *adapter, int index, u16 pid, int onoff)
936{
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300937 struct dib0700_adapter_state *state = adapter->priv;
938 return state->dib7000p_ops.pid_filter(adapter->fe_adap[0].fe, index, pid, onoff);
Olivier Grenief8731f42009-09-18 04:08:43 -0300939}
940
941static int stk70x0p_pid_filter_ctrl(struct dvb_usb_adapter *adapter, int onoff)
942{
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300943 struct dib0700_adapter_state *state = adapter->priv;
944 return state->dib7000p_ops.pid_filter_ctrl(adapter->fe_adap[0].fe, onoff);
Olivier Grenief8731f42009-09-18 04:08:43 -0300945}
946
Patrick Boettcher01373a52007-07-30 12:49:04 -0300947static struct dibx000_bandwidth_config dib7070_bw_config_12_mhz = {
Mauro Carvalho Chehab09628b22014-09-22 18:57:45 -0300948 .internal = 60000,
949 .sampling = 15000,
950 .pll_prediv = 1,
951 .pll_ratio = 20,
952 .pll_range = 3,
953 .pll_reset = 1,
954 .pll_bypass = 0,
955 .enable_refdiv = 0,
956 .bypclk_div = 0,
957 .IO_CLK_en_core = 1,
958 .ADClkSrc = 1,
959 .modulo = 2,
960 .sad_cfg = (3 << 14) | (1 << 12) | (524 << 0),
961 .ifreq = (0 << 25) | 0,
962 .timf = 20452225,
963 .xtal_hz = 12000000,
Patrick Boettcher01373a52007-07-30 12:49:04 -0300964};
965
966static struct dib7000p_config dib7070p_dib7000p_config = {
967 .output_mpeg2_in_188_bytes = 1,
968
969 .agc_config_count = 1,
970 .agc = &dib7070_agc_config,
971 .bw = &dib7070_bw_config_12_mhz,
Patrick Boettcher3cb2c392008-01-25 07:25:20 -0300972 .tuner_is_baseband = 1,
973 .spur_protect = 1,
Patrick Boettcher01373a52007-07-30 12:49:04 -0300974
975 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
976 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
977 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
978
979 .hostbus_diversity = 1,
980};
981
982/* STK7070P */
983static int stk7070p_frontend_attach(struct dvb_usb_adapter *adap)
984{
Al Viroda5ee482008-05-21 00:31:21 -0300985 struct usb_device_descriptor *p = &adap->dev->udev->descriptor;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300986 struct dib0700_adapter_state *state = adap->priv;
987
988 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
989 return -ENODEV;
990
Al Viroda5ee482008-05-21 00:31:21 -0300991 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);
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300994 else
Al Viroda5ee482008-05-21 00:31:21 -0300995 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
Patrick Boettcher01373a52007-07-30 12:49:04 -0300996 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
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03001009 if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 18,
Devin Heitmueller83c4fdf2009-01-21 01:55:45 -03001010 &dib7070p_dib7000p_config) != 0) {
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03001011 err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n",
Devin Heitmueller83c4fdf2009-01-21 01:55:45 -03001012 __func__);
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03001013 dvb_detach(&state->dib7000p_ops);
Devin Heitmueller83c4fdf2009-01-21 01:55:45 -03001014 return -ENODEV;
1015 }
Patrick Boettcher01373a52007-07-30 12:49:04 -03001016
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03001017 adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap, 0x80,
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03001018 &dib7070p_dib7000p_config);
Michael Krufky77eed212011-09-06 09:31:57 -03001019 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Patrick Boettcher01373a52007-07-30 12:49:04 -03001020}
1021
Olivier Grenie90e12ce2010-09-07 12:50:45 -03001022/* STK7770P */
1023static struct dib7000p_config dib7770p_dib7000p_config = {
1024 .output_mpeg2_in_188_bytes = 1,
1025
1026 .agc_config_count = 1,
1027 .agc = &dib7070_agc_config,
1028 .bw = &dib7070_bw_config_12_mhz,
1029 .tuner_is_baseband = 1,
1030 .spur_protect = 1,
1031
1032 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
1033 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
1034 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
1035
1036 .hostbus_diversity = 1,
1037 .enable_current_mirror = 1,
Olivier Grenie970d14c2010-09-07 12:50:46 -03001038 .disable_sample_and_hold = 0,
Olivier Grenie90e12ce2010-09-07 12:50:45 -03001039};
1040
1041static int stk7770p_frontend_attach(struct dvb_usb_adapter *adap)
1042{
1043 struct usb_device_descriptor *p = &adap->dev->udev->descriptor;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03001044 struct dib0700_adapter_state *state = adap->priv;
1045
1046 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
1047 return -ENODEV;
1048
Olivier Grenie90e12ce2010-09-07 12:50:45 -03001049 if (p->idVendor == cpu_to_le16(USB_VID_PINNACLE) &&
1050 p->idProduct == cpu_to_le16(USB_PID_PINNACLE_PCTV72E))
1051 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
1052 else
1053 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
1054 msleep(10);
1055 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
1056 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
1057 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
1058 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
1059
1060 dib0700_ctrl_clock(adap->dev, 72, 1);
1061
1062 msleep(10);
1063 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
1064 msleep(10);
1065 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
1066
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03001067 if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 18,
Olivier Grenie90e12ce2010-09-07 12:50:45 -03001068 &dib7770p_dib7000p_config) != 0) {
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03001069 err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n",
Olivier Grenie90e12ce2010-09-07 12:50:45 -03001070 __func__);
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03001071 dvb_detach(&state->dib7000p_ops);
Olivier Grenie90e12ce2010-09-07 12:50:45 -03001072 return -ENODEV;
1073 }
1074
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03001075 adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap, 0x80,
Olivier Grenie90e12ce2010-09-07 12:50:45 -03001076 &dib7770p_dib7000p_config);
Michael Krufky77eed212011-09-06 09:31:57 -03001077 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Olivier Grenie90e12ce2010-09-07 12:50:45 -03001078}
1079
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001080/* DIB807x generic */
1081static struct dibx000_agc_config dib807x_agc_config[2] = {
1082 {
1083 BAND_VHF,
1084 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0,
1085 * P_agc_freq_pwm_div=1, P_agc_inv_pwm1=0,
1086 * P_agc_inv_pwm2=0,P_agc_inh_dc_rv_est=0,
1087 * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5,
1088 * P_agc_write=0 */
1089 (0 << 15) | (0 << 14) | (7 << 11) | (0 << 10) | (0 << 9) |
1090 (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) |
1091 (0 << 0), /* setup*/
1092
1093 600, /* inv_gain*/
1094 10, /* time_stabiliz*/
1095
1096 0, /* alpha_level*/
1097 118, /* thlock*/
1098
1099 0, /* wbd_inv*/
1100 3530, /* wbd_ref*/
1101 1, /* wbd_sel*/
1102 5, /* wbd_alpha*/
1103
1104 65535, /* agc1_max*/
1105 0, /* agc1_min*/
1106
1107 65535, /* agc2_max*/
1108 0, /* agc2_min*/
1109
1110 0, /* agc1_pt1*/
1111 40, /* agc1_pt2*/
1112 183, /* agc1_pt3*/
1113 206, /* agc1_slope1*/
1114 255, /* agc1_slope2*/
1115 72, /* agc2_pt1*/
1116 152, /* agc2_pt2*/
1117 88, /* agc2_slope1*/
1118 90, /* agc2_slope2*/
1119
1120 17, /* alpha_mant*/
1121 27, /* alpha_exp*/
1122 23, /* beta_mant*/
1123 51, /* beta_exp*/
1124
1125 0, /* perform_agc_softsplit*/
1126 }, {
1127 BAND_UHF,
1128 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0,
1129 * P_agc_freq_pwm_div=1, P_agc_inv_pwm1=0,
1130 * P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
1131 * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5,
1132 * P_agc_write=0 */
1133 (0 << 15) | (0 << 14) | (1 << 11) | (0 << 10) | (0 << 9) |
1134 (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) |
1135 (0 << 0), /* setup */
1136
1137 600, /* inv_gain*/
1138 10, /* time_stabiliz*/
1139
1140 0, /* alpha_level*/
1141 118, /* thlock*/
1142
1143 0, /* wbd_inv*/
1144 3530, /* wbd_ref*/
1145 1, /* wbd_sel*/
1146 5, /* wbd_alpha*/
1147
1148 65535, /* agc1_max*/
1149 0, /* agc1_min*/
1150
1151 65535, /* agc2_max*/
1152 0, /* agc2_min*/
1153
1154 0, /* agc1_pt1*/
1155 40, /* agc1_pt2*/
1156 183, /* agc1_pt3*/
1157 206, /* agc1_slope1*/
1158 255, /* agc1_slope2*/
1159 72, /* agc2_pt1*/
1160 152, /* agc2_pt2*/
1161 88, /* agc2_slope1*/
1162 90, /* agc2_slope2*/
1163
1164 17, /* alpha_mant*/
1165 27, /* alpha_exp*/
1166 23, /* beta_mant*/
1167 51, /* beta_exp*/
1168
1169 0, /* perform_agc_softsplit*/
1170 }
1171};
1172
1173static struct dibx000_bandwidth_config dib807x_bw_config_12_mhz = {
Mauro Carvalho Chehab09628b22014-09-22 18:57:45 -03001174 .internal = 60000,
1175 .sampling = 15000,
1176 .pll_prediv = 1,
1177 .pll_ratio = 20,
1178 .pll_range = 3,
1179 .pll_reset = 1,
1180 .pll_bypass = 0,
1181 .enable_refdiv = 0,
1182 .bypclk_div = 0,
1183 .IO_CLK_en_core = 1,
1184 .ADClkSrc = 1,
1185 .modulo = 2,
1186 .sad_cfg = (3 << 14) | (1 << 12) | (599 << 0), /* sad_cfg: refsel, sel, freq_15k*/
1187 .ifreq = (0 << 25) | 0, /* ifreq = 0.000000 MHz*/
1188 .timf = 18179755,
1189 .xtal_hz = 12000000,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001190};
1191
1192static struct dib8000_config dib807x_dib8000_config[2] = {
1193 {
1194 .output_mpeg2_in_188_bytes = 1,
1195
1196 .agc_config_count = 2,
1197 .agc = dib807x_agc_config,
1198 .pll = &dib807x_bw_config_12_mhz,
1199 .tuner_is_baseband = 1,
1200
1201 .gpio_dir = DIB8000_GPIO_DEFAULT_DIRECTIONS,
1202 .gpio_val = DIB8000_GPIO_DEFAULT_VALUES,
1203 .gpio_pwm_pos = DIB8000_GPIO_DEFAULT_PWM_POS,
1204
1205 .hostbus_diversity = 1,
1206 .div_cfg = 1,
1207 .agc_control = &dib0070_ctrl_agc_filter,
1208 .output_mode = OUTMODE_MPEG2_FIFO,
1209 .drives = 0x2d98,
1210 }, {
1211 .output_mpeg2_in_188_bytes = 1,
1212
1213 .agc_config_count = 2,
1214 .agc = dib807x_agc_config,
1215 .pll = &dib807x_bw_config_12_mhz,
1216 .tuner_is_baseband = 1,
1217
1218 .gpio_dir = DIB8000_GPIO_DEFAULT_DIRECTIONS,
1219 .gpio_val = DIB8000_GPIO_DEFAULT_VALUES,
1220 .gpio_pwm_pos = DIB8000_GPIO_DEFAULT_PWM_POS,
1221
1222 .hostbus_diversity = 1,
1223 .agc_control = &dib0070_ctrl_agc_filter,
1224 .output_mode = OUTMODE_MPEG2_FIFO,
1225 .drives = 0x2d98,
1226 }
1227};
1228
Olivier Grenie03245a52009-12-04 13:27:57 -03001229static int dib80xx_tuner_reset(struct dvb_frontend *fe, int onoff)
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001230{
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001231 struct dvb_usb_adapter *adap = fe->dvb->priv;
1232 struct dib0700_adapter_state *state = adap->priv;
1233
1234 return state->dib8000_ops.set_gpio(fe, 5, 0, !onoff);
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001235}
1236
Olivier Grenie03245a52009-12-04 13:27:57 -03001237static int dib80xx_tuner_sleep(struct dvb_frontend *fe, int onoff)
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001238{
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001239 struct dvb_usb_adapter *adap = fe->dvb->priv;
1240 struct dib0700_adapter_state *state = adap->priv;
1241
1242 return state->dib8000_ops.set_gpio(fe, 0, 0, onoff);
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001243}
1244
1245static const struct dib0070_wbd_gain_cfg dib8070_wbd_gain_cfg[] = {
1246 { 240, 7},
1247 { 0xffff, 6},
1248};
1249
1250static struct dib0070_config dib807x_dib0070_config[2] = {
1251 {
1252 .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
Olivier Grenie03245a52009-12-04 13:27:57 -03001253 .reset = dib80xx_tuner_reset,
1254 .sleep = dib80xx_tuner_sleep,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001255 .clock_khz = 12000,
1256 .clock_pad_drive = 4,
1257 .vga_filter = 1,
1258 .force_crystal_mode = 1,
1259 .enable_third_order_filter = 1,
1260 .charge_pump = 0,
1261 .wbd_gain = dib8070_wbd_gain_cfg,
1262 .osc_buffer_state = 0,
1263 .freq_offset_khz_uhf = -100,
1264 .freq_offset_khz_vhf = -100,
1265 }, {
1266 .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
Olivier Grenie03245a52009-12-04 13:27:57 -03001267 .reset = dib80xx_tuner_reset,
1268 .sleep = dib80xx_tuner_sleep,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001269 .clock_khz = 12000,
1270 .clock_pad_drive = 2,
1271 .vga_filter = 1,
1272 .force_crystal_mode = 1,
1273 .enable_third_order_filter = 1,
1274 .charge_pump = 0,
1275 .wbd_gain = dib8070_wbd_gain_cfg,
1276 .osc_buffer_state = 0,
1277 .freq_offset_khz_uhf = -25,
1278 .freq_offset_khz_vhf = -25,
1279 }
1280};
1281
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -03001282static int dib807x_set_param_override(struct dvb_frontend *fe)
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001283{
Mauro Carvalho Chehab47b163a2011-12-24 10:18:24 -03001284 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001285 struct dvb_usb_adapter *adap = fe->dvb->priv;
1286 struct dib0700_adapter_state *state = adap->priv;
1287
1288 u16 offset = dib0070_wbd_offset(fe);
Mauro Carvalho Chehab47b163a2011-12-24 10:18:24 -03001289 u8 band = BAND_OF_FREQUENCY(p->frequency/1000);
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001290 switch (band) {
1291 case BAND_VHF:
1292 offset += 750;
1293 break;
1294 case BAND_UHF: /* fall-thru wanted */
1295 default:
1296 offset += 250; break;
1297 }
1298 deb_info("WBD for DiB8000: %d\n", offset);
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001299 state->dib8000_ops.set_wbd_ref(fe, offset);
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001300
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -03001301 return state->set_param_save(fe);
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001302}
1303
1304static int dib807x_tuner_attach(struct dvb_usb_adapter *adap)
1305{
1306 struct dib0700_adapter_state *st = adap->priv;
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001307 struct i2c_adapter *tun_i2c = st->dib8000_ops.get_i2c_master(adap->fe_adap[0].fe,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001308 DIBX000_I2C_INTERFACE_TUNER, 1);
1309
1310 if (adap->id == 0) {
Michael Krufky77eed212011-09-06 09:31:57 -03001311 if (dvb_attach(dib0070_attach, adap->fe_adap[0].fe, tun_i2c,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001312 &dib807x_dib0070_config[0]) == NULL)
1313 return -ENODEV;
1314 } else {
Michael Krufky77eed212011-09-06 09:31:57 -03001315 if (dvb_attach(dib0070_attach, adap->fe_adap[0].fe, tun_i2c,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001316 &dib807x_dib0070_config[1]) == NULL)
1317 return -ENODEV;
1318 }
1319
Michael Krufky77eed212011-09-06 09:31:57 -03001320 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
1321 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib807x_set_param_override;
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001322 return 0;
1323}
1324
Olivier Grenie9c783032009-12-07 07:49:40 -03001325static int stk80xx_pid_filter(struct dvb_usb_adapter *adapter, int index,
1326 u16 pid, int onoff)
Olivier Grenief8731f42009-09-18 04:08:43 -03001327{
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001328 struct dib0700_adapter_state *state = adapter->priv;
1329
1330 return state->dib8000_ops.pid_filter(adapter->fe_adap[0].fe, index, pid, onoff);
Olivier Grenief8731f42009-09-18 04:08:43 -03001331}
1332
Olivier Grenie9c783032009-12-07 07:49:40 -03001333static int stk80xx_pid_filter_ctrl(struct dvb_usb_adapter *adapter,
Olivier Greniebe9bae12011-01-04 05:42:19 -03001334 int onoff)
Olivier Grenief8731f42009-09-18 04:08:43 -03001335{
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001336 struct dib0700_adapter_state *state = adapter->priv;
1337
1338 return state->dib8000_ops.pid_filter_ctrl(adapter->fe_adap[0].fe, onoff);
Olivier Grenief8731f42009-09-18 04:08:43 -03001339}
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001340
1341/* STK807x */
1342static int stk807x_frontend_attach(struct dvb_usb_adapter *adap)
1343{
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001344 struct dib0700_adapter_state *state = adap->priv;
1345
1346 if (!dvb_attach(dib8000_attach, &state->dib8000_ops))
1347 return -ENODEV;
1348
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001349 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
1350 msleep(10);
1351 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
1352 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
1353 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
1354
1355 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
1356
1357 dib0700_ctrl_clock(adap->dev, 72, 1);
1358
1359 msleep(10);
1360 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
1361 msleep(10);
1362 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
1363
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001364 state->dib8000_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 18,
Olivier Grenie0c32dbd2011-08-10 05:17:18 -03001365 0x80, 0);
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001366
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001367 adap->fe_adap[0].fe = state->dib8000_ops.init(&adap->dev->i2c_adap, 0x80,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001368 &dib807x_dib8000_config[0]);
1369
Michael Krufky77eed212011-09-06 09:31:57 -03001370 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001371}
1372
1373/* STK807xPVR */
1374static int stk807xpvr_frontend_attach0(struct dvb_usb_adapter *adap)
1375{
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001376 struct dib0700_adapter_state *state = adap->priv;
1377
1378 if (!dvb_attach(dib8000_attach, &state->dib8000_ops))
1379 return -ENODEV;
1380
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001381 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
1382 msleep(30);
1383 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
1384 msleep(500);
1385 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
1386 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
1387 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
1388
1389 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
1390
1391 dib0700_ctrl_clock(adap->dev, 72, 1);
1392
1393 msleep(10);
1394 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
1395 msleep(10);
1396 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
1397
1398 /* initialize IC 0 */
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001399 state->dib8000_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 0x22, 0x80, 0);
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001400
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001401 adap->fe_adap[0].fe = state->dib8000_ops.init(&adap->dev->i2c_adap, 0x80,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001402 &dib807x_dib8000_config[0]);
1403
Michael Krufky77eed212011-09-06 09:31:57 -03001404 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001405}
1406
1407static int stk807xpvr_frontend_attach1(struct dvb_usb_adapter *adap)
1408{
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001409 struct dib0700_adapter_state *state = adap->priv;
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001410
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001411 if (!dvb_attach(dib8000_attach, &state->dib8000_ops))
1412 return -ENODEV;
1413
1414 /* initialize IC 1 */
1415 state->dib8000_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 0x12, 0x82, 0);
1416
1417 adap->fe_adap[0].fe = state->dib8000_ops.init(&adap->dev->i2c_adap, 0x82,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001418 &dib807x_dib8000_config[1]);
1419
Michael Krufky77eed212011-09-06 09:31:57 -03001420 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001421}
1422
Olivier Grenie03245a52009-12-04 13:27:57 -03001423/* STK8096GP */
Olivier Greniea685dbb2011-08-05 14:10:40 -03001424static struct dibx000_agc_config dib8090_agc_config[2] = {
Olivier Greniebe9bae12011-01-04 05:42:19 -03001425 {
Mauro Carvalho Chehab40d1a7c2014-07-04 14:15:34 -03001426 .band_caps = BAND_UHF | BAND_VHF | BAND_LBAND | BAND_SBAND,
Olivier Grenie9c783032009-12-07 07:49:40 -03001427 /* 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 -03001428 * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
1429 * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5, P_agc_write=0 */
Mauro Carvalho Chehab40d1a7c2014-07-04 14:15:34 -03001430 .setup = (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8)
Olivier Grenie9c783032009-12-07 07:49:40 -03001431 | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),
Olivier Grenie03245a52009-12-04 13:27:57 -03001432
Mauro Carvalho Chehab40d1a7c2014-07-04 14:15:34 -03001433 .inv_gain = 787,
1434 .time_stabiliz = 10,
Olivier Grenie03245a52009-12-04 13:27:57 -03001435
Mauro Carvalho Chehab40d1a7c2014-07-04 14:15:34 -03001436 .alpha_level = 0,
1437 .thlock = 118,
Olivier Grenie03245a52009-12-04 13:27:57 -03001438
Mauro Carvalho Chehab40d1a7c2014-07-04 14:15:34 -03001439 .wbd_inv = 0,
1440 .wbd_ref = 3530,
1441 .wbd_sel = 1,
1442 .wbd_alpha = 5,
Olivier Grenie03245a52009-12-04 13:27:57 -03001443
Mauro Carvalho Chehab40d1a7c2014-07-04 14:15:34 -03001444 .agc1_max = 65535,
1445 .agc1_min = 0,
Olivier Grenie03245a52009-12-04 13:27:57 -03001446
Mauro Carvalho Chehab40d1a7c2014-07-04 14:15:34 -03001447 .agc2_max = 65535,
1448 .agc2_min = 0,
Olivier Grenie03245a52009-12-04 13:27:57 -03001449
Mauro Carvalho Chehab40d1a7c2014-07-04 14:15:34 -03001450 .agc1_pt1 = 0,
1451 .agc1_pt2 = 32,
1452 .agc1_pt3 = 114,
1453 .agc1_slope1 = 143,
1454 .agc1_slope2 = 144,
1455 .agc2_pt1 = 114,
1456 .agc2_pt2 = 227,
1457 .agc2_slope1 = 116,
1458 .agc2_slope2 = 117,
Olivier Grenie03245a52009-12-04 13:27:57 -03001459
Mauro Carvalho Chehab40d1a7c2014-07-04 14:15:34 -03001460 .alpha_mant = 28,
1461 .alpha_exp = 26,
1462 .beta_mant = 31,
1463 .beta_exp = 51,
Olivier Grenie03245a52009-12-04 13:27:57 -03001464
Mauro Carvalho Chehab40d1a7c2014-07-04 14:15:34 -03001465 .perform_agc_softsplit = 0,
Olivier Greniebe9bae12011-01-04 05:42:19 -03001466 },
1467 {
Mauro Carvalho Chehab40d1a7c2014-07-04 14:15:34 -03001468 .band_caps = BAND_CBAND,
Olivier Grenie9c783032009-12-07 07:49:40 -03001469 /* 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 -03001470 * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
1471 * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5, P_agc_write=0 */
Mauro Carvalho Chehab40d1a7c2014-07-04 14:15:34 -03001472 .setup = (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8)
Olivier Grenie9c783032009-12-07 07:49:40 -03001473 | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),
Olivier Grenie03245a52009-12-04 13:27:57 -03001474
Mauro Carvalho Chehab40d1a7c2014-07-04 14:15:34 -03001475 .inv_gain = 787,
1476 .time_stabiliz = 10,
Olivier Grenie03245a52009-12-04 13:27:57 -03001477
Mauro Carvalho Chehab40d1a7c2014-07-04 14:15:34 -03001478 .alpha_level = 0,
1479 .thlock = 118,
Olivier Grenie03245a52009-12-04 13:27:57 -03001480
Mauro Carvalho Chehab40d1a7c2014-07-04 14:15:34 -03001481 .wbd_inv = 0,
1482 .wbd_ref = 3530,
1483 .wbd_sel = 1,
1484 .wbd_alpha = 5,
Olivier Grenie03245a52009-12-04 13:27:57 -03001485
Mauro Carvalho Chehab40d1a7c2014-07-04 14:15:34 -03001486 .agc1_max = 0,
1487 .agc1_min = 0,
Olivier Grenie03245a52009-12-04 13:27:57 -03001488
Mauro Carvalho Chehab40d1a7c2014-07-04 14:15:34 -03001489 .agc2_max = 65535,
1490 .agc2_min = 0,
Olivier Grenie03245a52009-12-04 13:27:57 -03001491
Mauro Carvalho Chehab40d1a7c2014-07-04 14:15:34 -03001492 .agc1_pt1 = 0,
1493 .agc1_pt2 = 32,
1494 .agc1_pt3 = 114,
1495 .agc1_slope1 = 143,
1496 .agc1_slope2 = 144,
1497 .agc2_pt1 = 114,
1498 .agc2_pt2 = 227,
1499 .agc2_slope1 = 116,
1500 .agc2_slope2 = 117,
Olivier Grenie03245a52009-12-04 13:27:57 -03001501
Mauro Carvalho Chehab40d1a7c2014-07-04 14:15:34 -03001502 .alpha_mant = 28,
1503 .alpha_exp = 26,
1504 .beta_mant = 31,
1505 .beta_exp = 51,
Olivier Grenie03245a52009-12-04 13:27:57 -03001506
Mauro Carvalho Chehab40d1a7c2014-07-04 14:15:34 -03001507 .perform_agc_softsplit = 0,
Olivier Greniebe9bae12011-01-04 05:42:19 -03001508 }
Olivier Grenie03245a52009-12-04 13:27:57 -03001509};
1510
1511static struct dibx000_bandwidth_config dib8090_pll_config_12mhz = {
Mauro Carvalho Chehab40d1a7c2014-07-04 14:15:34 -03001512 .internal = 54000,
1513 .sampling = 13500,
1514
1515 .pll_prediv = 1,
1516 .pll_ratio = 18,
1517 .pll_range = 3,
1518 .pll_reset = 1,
1519 .pll_bypass = 0,
1520
1521 .enable_refdiv = 0,
1522 .bypclk_div = 0,
1523 .IO_CLK_en_core = 1,
1524 .ADClkSrc = 1,
1525 .modulo = 2,
1526
1527 .sad_cfg = (3 << 14) | (1 << 12) | (599 << 0),
1528
1529 .ifreq = (0 << 25) | 0,
1530 .timf = 20199727,
1531
1532 .xtal_hz = 12000000,
Olivier Grenie03245a52009-12-04 13:27:57 -03001533};
1534
1535static int dib8090_get_adc_power(struct dvb_frontend *fe)
1536{
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001537 struct dvb_usb_adapter *adap = fe->dvb->priv;
1538 struct dib0700_adapter_state *state = adap->priv;
1539
1540 return state->dib8000_ops.get_adc_power(fe, 1);
Olivier Grenie03245a52009-12-04 13:27:57 -03001541}
1542
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001543static void dib8090_agc_control(struct dvb_frontend *fe, u8 restart)
1544{
1545 deb_info("AGC control callback: %i\n", restart);
1546 dib0090_dcc_freq(fe, restart);
1547
1548 if (restart == 0) /* before AGC startup */
1549 dib0090_set_dc_servo(fe, 1);
1550}
1551
Olivier Greniebe9bae12011-01-04 05:42:19 -03001552static struct dib8000_config dib809x_dib8000_config[2] = {
1553 {
1554 .output_mpeg2_in_188_bytes = 1,
Olivier Grenie03245a52009-12-04 13:27:57 -03001555
Olivier Greniebe9bae12011-01-04 05:42:19 -03001556 .agc_config_count = 2,
1557 .agc = dib8090_agc_config,
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001558 .agc_control = dib8090_agc_control,
Olivier Greniebe9bae12011-01-04 05:42:19 -03001559 .pll = &dib8090_pll_config_12mhz,
1560 .tuner_is_baseband = 1,
Olivier Grenie03245a52009-12-04 13:27:57 -03001561
Olivier Greniebe9bae12011-01-04 05:42:19 -03001562 .gpio_dir = DIB8000_GPIO_DEFAULT_DIRECTIONS,
1563 .gpio_val = DIB8000_GPIO_DEFAULT_VALUES,
1564 .gpio_pwm_pos = DIB8000_GPIO_DEFAULT_PWM_POS,
Olivier Grenie03245a52009-12-04 13:27:57 -03001565
Olivier Greniebe9bae12011-01-04 05:42:19 -03001566 .hostbus_diversity = 1,
1567 .div_cfg = 0x31,
1568 .output_mode = OUTMODE_MPEG2_FIFO,
1569 .drives = 0x2d98,
1570 .diversity_delay = 48,
1571 .refclksel = 3,
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03001572 }, {
Olivier Greniebe9bae12011-01-04 05:42:19 -03001573 .output_mpeg2_in_188_bytes = 1,
1574
1575 .agc_config_count = 2,
1576 .agc = dib8090_agc_config,
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001577 .agc_control = dib8090_agc_control,
Olivier Greniebe9bae12011-01-04 05:42:19 -03001578 .pll = &dib8090_pll_config_12mhz,
1579 .tuner_is_baseband = 1,
1580
1581 .gpio_dir = DIB8000_GPIO_DEFAULT_DIRECTIONS,
1582 .gpio_val = DIB8000_GPIO_DEFAULT_VALUES,
1583 .gpio_pwm_pos = DIB8000_GPIO_DEFAULT_PWM_POS,
1584
1585 .hostbus_diversity = 1,
1586 .div_cfg = 0x31,
1587 .output_mode = OUTMODE_DIVERSITY,
1588 .drives = 0x2d08,
1589 .diversity_delay = 1,
1590 .refclksel = 3,
1591 }
1592};
1593
1594static struct dib0090_wbd_slope dib8090_wbd_table[] = {
1595 /* max freq ; cold slope ; cold offset ; warm slope ; warm offset ; wbd gain */
1596 { 120, 0, 500, 0, 500, 4 }, /* CBAND */
1597 { 170, 0, 450, 0, 450, 4 }, /* CBAND */
1598 { 380, 48, 373, 28, 259, 6 }, /* VHF */
1599 { 860, 34, 700, 36, 616, 6 }, /* high UHF */
1600 { 0xFFFF, 34, 700, 36, 616, 6 }, /* default */
Olivier Grenie03245a52009-12-04 13:27:57 -03001601};
1602
1603static struct dib0090_config dib809x_dib0090_config = {
Olivier Greniebe9bae12011-01-04 05:42:19 -03001604 .io.pll_bypass = 1,
1605 .io.pll_range = 1,
1606 .io.pll_prediv = 1,
1607 .io.pll_loopdiv = 20,
1608 .io.adc_clock_ratio = 8,
1609 .io.pll_int_loop_filt = 0,
1610 .io.clock_khz = 12000,
1611 .reset = dib80xx_tuner_reset,
1612 .sleep = dib80xx_tuner_sleep,
1613 .clkouttobamse = 1,
1614 .analog_output = 1,
1615 .i2c_address = DEFAULT_DIB0090_I2C_ADDRESS,
1616 .use_pwm_agc = 1,
1617 .clkoutdrive = 1,
1618 .get_adc_power = dib8090_get_adc_power,
1619 .freq_offset_khz_uhf = -63,
Olivier Grenie03245a52009-12-04 13:27:57 -03001620 .freq_offset_khz_vhf = -143,
Olivier Greniebe9bae12011-01-04 05:42:19 -03001621 .wbd = dib8090_wbd_table,
1622 .fref_clock_ratio = 6,
Olivier Grenie03245a52009-12-04 13:27:57 -03001623};
1624
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001625static u8 dib8090_compute_pll_parameters(struct dvb_frontend *fe)
1626{
1627 u8 optimal_pll_ratio = 20;
1628 u32 freq_adc, ratio, rest, max = 0;
1629 u8 pll_ratio;
1630
1631 for (pll_ratio = 17; pll_ratio <= 20; pll_ratio++) {
1632 freq_adc = 12 * pll_ratio * (1 << 8) / 16;
1633 ratio = ((fe->dtv_property_cache.frequency / 1000) * (1 << 8) / 1000) / freq_adc;
1634 rest = ((fe->dtv_property_cache.frequency / 1000) * (1 << 8) / 1000) - ratio * freq_adc;
1635
1636 if (rest > freq_adc / 2)
1637 rest = freq_adc - rest;
1638 deb_info("PLL ratio=%i rest=%i\n", pll_ratio, rest);
1639 if ((rest > max) && (rest > 717)) {
1640 optimal_pll_ratio = pll_ratio;
1641 max = rest;
1642 }
1643 }
1644 deb_info("optimal PLL ratio=%i\n", optimal_pll_ratio);
1645
1646 return optimal_pll_ratio;
1647}
1648
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -03001649static int dib8096_set_param_override(struct dvb_frontend *fe)
Olivier Grenie03245a52009-12-04 13:27:57 -03001650{
Olivier Greniebe9bae12011-01-04 05:42:19 -03001651 struct dvb_usb_adapter *adap = fe->dvb->priv;
1652 struct dib0700_adapter_state *state = adap->priv;
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001653 u8 pll_ratio, band = BAND_OF_FREQUENCY(fe->dtv_property_cache.frequency / 1000);
1654 u16 target, ltgain, rf_gain_limit;
1655 u32 timf;
Olivier Greniebe9bae12011-01-04 05:42:19 -03001656 int ret = 0;
1657 enum frontend_tune_state tune_state = CT_SHUTDOWN;
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001658
1659 switch (band) {
1660 default:
1661 deb_info("Warning : Rf frequency (%iHz) is not in the supported range, using VHF switch ", fe->dtv_property_cache.frequency);
1662 case BAND_VHF:
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001663 state->dib8000_ops.set_gpio(fe, 3, 0, 1);
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001664 break;
1665 case BAND_UHF:
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001666 state->dib8000_ops.set_gpio(fe, 3, 0, 0);
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001667 break;
1668 }
Olivier Grenie03245a52009-12-04 13:27:57 -03001669
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -03001670 ret = state->set_param_save(fe);
Olivier Greniebe9bae12011-01-04 05:42:19 -03001671 if (ret < 0)
1672 return ret;
Olivier Grenie03245a52009-12-04 13:27:57 -03001673
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001674 if (fe->dtv_property_cache.bandwidth_hz != 6000000) {
1675 deb_info("only 6MHz bandwidth is supported\n");
1676 return -EINVAL;
1677 }
Olivier Grenie03245a52009-12-04 13:27:57 -03001678
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001679 /** Update PLL if needed ratio **/
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001680 state->dib8000_ops.update_pll(fe, &dib8090_pll_config_12mhz, fe->dtv_property_cache.bandwidth_hz / 1000, 0);
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001681
1682 /** Get optimize PLL ratio to remove spurious **/
1683 pll_ratio = dib8090_compute_pll_parameters(fe);
1684 if (pll_ratio == 17)
1685 timf = 21387946;
1686 else if (pll_ratio == 18)
1687 timf = 20199727;
1688 else if (pll_ratio == 19)
1689 timf = 19136583;
1690 else
1691 timf = 18179756;
1692
1693 /** Update ratio **/
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001694 state->dib8000_ops.update_pll(fe, &dib8090_pll_config_12mhz, fe->dtv_property_cache.bandwidth_hz / 1000, pll_ratio);
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001695
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001696 state->dib8000_ops.ctrl_timf(fe, DEMOD_TIMF_SET, timf);
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001697
1698 if (band != BAND_CBAND) {
1699 /* dib0090_get_wbd_target is returning any possible temperature compensated wbd-target */
1700 target = (dib0090_get_wbd_target(fe) * 8 * 18 / 33 + 1) / 2;
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001701 state->dib8000_ops.set_wbd_ref(fe, target);
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001702 }
Olivier Grenie03245a52009-12-04 13:27:57 -03001703
Olivier Greniebe9bae12011-01-04 05:42:19 -03001704 if (band == BAND_CBAND) {
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03001705 deb_info("tuning in CBAND - soft-AGC startup\n");
1706 dib0090_set_tune_state(fe, CT_AGC_START);
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001707
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03001708 do {
1709 ret = dib0090_gain_control(fe);
1710 msleep(ret);
1711 tune_state = dib0090_get_tune_state(fe);
1712 if (tune_state == CT_AGC_STEP_0)
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001713 state->dib8000_ops.set_gpio(fe, 6, 0, 1);
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03001714 else if (tune_state == CT_AGC_STEP_1) {
1715 dib0090_get_current_gain(fe, NULL, NULL, &rf_gain_limit, &ltgain);
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001716 if (rf_gain_limit < 2000) /* activate the external attenuator in case of very high input power */
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001717 state->dib8000_ops.set_gpio(fe, 6, 0, 0);
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03001718 }
1719 } while (tune_state < CT_AGC_STOP);
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001720
1721 deb_info("switching to PWM AGC\n");
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03001722 dib0090_pwm_gain_reset(fe);
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001723 state->dib8000_ops.pwm_agc_reset(fe);
1724 state->dib8000_ops.set_tune_state(fe, CT_DEMOD_START);
Olivier Greniebe9bae12011-01-04 05:42:19 -03001725 } else {
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001726 /* for everything else than CBAND we are using standard AGC */
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03001727 deb_info("not tuning in CBAND - standard AGC startup\n");
1728 dib0090_pwm_gain_reset(fe);
Olivier Greniebe9bae12011-01-04 05:42:19 -03001729 }
Olivier Grenie03245a52009-12-04 13:27:57 -03001730
Olivier Greniebe9bae12011-01-04 05:42:19 -03001731 return 0;
Olivier Grenie03245a52009-12-04 13:27:57 -03001732}
1733
1734static int dib809x_tuner_attach(struct dvb_usb_adapter *adap)
1735{
Olivier Greniebe9bae12011-01-04 05:42:19 -03001736 struct dib0700_adapter_state *st = adap->priv;
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001737 struct i2c_adapter *tun_i2c = st->dib8000_ops.get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_TUNER, 1);
Olivier Grenie03245a52009-12-04 13:27:57 -03001738
Michael Krufky77eed212011-09-06 09:31:57 -03001739 if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c, &dib809x_dib0090_config) == NULL)
Olivier Greniebe9bae12011-01-04 05:42:19 -03001740 return -ENODEV;
Olivier Grenie03245a52009-12-04 13:27:57 -03001741
Michael Krufky77eed212011-09-06 09:31:57 -03001742 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
1743 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib8096_set_param_override;
Olivier Greniebe9bae12011-01-04 05:42:19 -03001744 return 0;
Olivier Grenie03245a52009-12-04 13:27:57 -03001745}
1746
1747static int stk809x_frontend_attach(struct dvb_usb_adapter *adap)
1748{
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001749 struct dib0700_adapter_state *state = adap->priv;
1750
1751 if (!dvb_attach(dib8000_attach, &state->dib8000_ops))
1752 return -ENODEV;
1753
Olivier Grenie03245a52009-12-04 13:27:57 -03001754 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
1755 msleep(10);
1756 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
1757 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
1758 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
1759
1760 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
1761
1762 dib0700_ctrl_clock(adap->dev, 72, 1);
1763
1764 msleep(10);
1765 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
1766 msleep(10);
1767 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
1768
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001769 state->dib8000_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 18, 0x80, 0);
Olivier Grenie03245a52009-12-04 13:27:57 -03001770
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001771 adap->fe_adap[0].fe = state->dib8000_ops.init(&adap->dev->i2c_adap, 0x80, &dib809x_dib8000_config[0]);
Olivier Grenie03245a52009-12-04 13:27:57 -03001772
Michael Krufky77eed212011-09-06 09:31:57 -03001773 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Olivier Grenie03245a52009-12-04 13:27:57 -03001774}
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001775
Olivier Greniebe9bae12011-01-04 05:42:19 -03001776static int nim8096md_tuner_attach(struct dvb_usb_adapter *adap)
1777{
1778 struct dib0700_adapter_state *st = adap->priv;
1779 struct i2c_adapter *tun_i2c;
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001780 struct dvb_frontend *fe_slave = st->dib8000_ops.get_slave_frontend(adap->fe_adap[0].fe, 1);
Olivier Greniebe9bae12011-01-04 05:42:19 -03001781
1782 if (fe_slave) {
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001783 tun_i2c = st->dib8000_ops.get_i2c_master(fe_slave, DIBX000_I2C_INTERFACE_TUNER, 1);
Olivier Greniebe9bae12011-01-04 05:42:19 -03001784 if (dvb_attach(dib0090_register, fe_slave, tun_i2c, &dib809x_dib0090_config) == NULL)
1785 return -ENODEV;
Michael Krufky77eed212011-09-06 09:31:57 -03001786 fe_slave->dvb = adap->fe_adap[0].fe->dvb;
Olivier Greniebe9bae12011-01-04 05:42:19 -03001787 fe_slave->ops.tuner_ops.set_params = dib8096_set_param_override;
1788 }
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001789 tun_i2c = st->dib8000_ops.get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_TUNER, 1);
Michael Krufky77eed212011-09-06 09:31:57 -03001790 if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c, &dib809x_dib0090_config) == NULL)
Olivier Greniebe9bae12011-01-04 05:42:19 -03001791 return -ENODEV;
1792
Michael Krufky77eed212011-09-06 09:31:57 -03001793 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
1794 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib8096_set_param_override;
Olivier Greniebe9bae12011-01-04 05:42:19 -03001795
1796 return 0;
1797}
1798
1799static int nim8096md_frontend_attach(struct dvb_usb_adapter *adap)
1800{
1801 struct dvb_frontend *fe_slave;
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001802 struct dib0700_adapter_state *state = adap->priv;
1803
1804 if (!dvb_attach(dib8000_attach, &state->dib8000_ops))
1805 return -ENODEV;
Olivier Greniebe9bae12011-01-04 05:42:19 -03001806
1807 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03001808 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03001809 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
1810 msleep(1000);
1811 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
1812 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
1813 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
1814
1815 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
1816
1817 dib0700_ctrl_clock(adap->dev, 72, 1);
1818
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03001819 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03001820 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03001821 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03001822 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
1823
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001824 state->dib8000_ops.i2c_enumeration(&adap->dev->i2c_adap, 2, 18, 0x80, 0);
Olivier Greniebe9bae12011-01-04 05:42:19 -03001825
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001826 adap->fe_adap[0].fe = state->dib8000_ops.init(&adap->dev->i2c_adap, 0x80, &dib809x_dib8000_config[0]);
Michael Krufky77eed212011-09-06 09:31:57 -03001827 if (adap->fe_adap[0].fe == NULL)
Olivier Greniebe9bae12011-01-04 05:42:19 -03001828 return -ENODEV;
1829
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001830 /* Needed to increment refcount */
1831 if (!dvb_attach(dib8000_attach, &state->dib8000_ops))
1832 return -ENODEV;
1833
1834 fe_slave = state->dib8000_ops.init(&adap->dev->i2c_adap, 0x82, &dib809x_dib8000_config[1]);
1835 state->dib8000_ops.set_slave_frontend(adap->fe_adap[0].fe, fe_slave);
Olivier Greniebe9bae12011-01-04 05:42:19 -03001836
1837 return fe_slave == NULL ? -ENODEV : 0;
1838}
1839
Olivier Grenie88f3a352011-08-10 05:28:38 -03001840/* TFE8096P */
1841static struct dibx000_agc_config dib8096p_agc_config[2] = {
1842 {
1843 .band_caps = BAND_UHF,
1844 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0,
1845 P_agc_freq_pwm_div=1, P_agc_inv_pwm1=0,
1846 P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
1847 P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5,
1848 P_agc_write=0 */
1849 .setup = (0 << 15) | (0 << 14) | (5 << 11)
1850 | (0 << 10) | (0 << 9) | (0 << 8) | (3 << 5)
1851 | (0 << 4) | (5 << 1) | (0 << 0),
1852
1853 .inv_gain = 684,
1854 .time_stabiliz = 10,
1855
1856 .alpha_level = 0,
1857 .thlock = 118,
1858
1859 .wbd_inv = 0,
1860 .wbd_ref = 1200,
1861 .wbd_sel = 3,
1862 .wbd_alpha = 5,
1863
1864 .agc1_max = 65535,
1865 .agc1_min = 0,
1866
1867 .agc2_max = 32767,
1868 .agc2_min = 0,
1869
1870 .agc1_pt1 = 0,
1871 .agc1_pt2 = 0,
1872 .agc1_pt3 = 105,
1873 .agc1_slope1 = 0,
1874 .agc1_slope2 = 156,
1875 .agc2_pt1 = 105,
1876 .agc2_pt2 = 255,
1877 .agc2_slope1 = 54,
1878 .agc2_slope2 = 0,
1879
1880 .alpha_mant = 28,
1881 .alpha_exp = 26,
1882 .beta_mant = 31,
1883 .beta_exp = 51,
1884
1885 .perform_agc_softsplit = 0,
1886 } , {
1887 .band_caps = BAND_FM | BAND_VHF | BAND_CBAND,
1888 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0,
1889 P_agc_freq_pwm_div=1, P_agc_inv_pwm1=0,
1890 P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
1891 P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5,
1892 P_agc_write=0 */
1893 .setup = (0 << 15) | (0 << 14) | (5 << 11)
1894 | (0 << 10) | (0 << 9) | (0 << 8) | (3 << 5)
1895 | (0 << 4) | (5 << 1) | (0 << 0),
1896
1897 .inv_gain = 732,
1898 .time_stabiliz = 10,
1899
1900 .alpha_level = 0,
1901 .thlock = 118,
1902
1903 .wbd_inv = 0,
1904 .wbd_ref = 1200,
1905 .wbd_sel = 3,
1906 .wbd_alpha = 5,
1907
1908 .agc1_max = 65535,
1909 .agc1_min = 0,
1910
1911 .agc2_max = 32767,
1912 .agc2_min = 0,
1913
1914 .agc1_pt1 = 0,
1915 .agc1_pt2 = 0,
1916 .agc1_pt3 = 98,
1917 .agc1_slope1 = 0,
1918 .agc1_slope2 = 167,
1919 .agc2_pt1 = 98,
1920 .agc2_pt2 = 255,
1921 .agc2_slope1 = 52,
1922 .agc2_slope2 = 0,
1923
1924 .alpha_mant = 28,
1925 .alpha_exp = 26,
1926 .beta_mant = 31,
1927 .beta_exp = 51,
1928
1929 .perform_agc_softsplit = 0,
1930 }
1931};
1932
1933static struct dibx000_bandwidth_config dib8096p_clock_config_12_mhz = {
Mauro Carvalho Chehab09628b22014-09-22 18:57:45 -03001934 .internal = 108000,
1935 .sampling = 13500,
1936 .pll_prediv = 1,
1937 .pll_ratio = 9,
1938 .pll_range = 1,
1939 .pll_reset = 0,
1940 .pll_bypass = 0,
1941 .enable_refdiv = 0,
1942 .bypclk_div = 0,
1943 .IO_CLK_en_core = 0,
1944 .ADClkSrc = 0,
1945 .modulo = 2,
1946 .sad_cfg = (3 << 14) | (1 << 12) | (524 << 0),
1947 .ifreq = (0 << 25) | 0,
1948 .timf = 20199729,
1949 .xtal_hz = 12000000,
Olivier Grenie88f3a352011-08-10 05:28:38 -03001950};
1951
1952static struct dib8000_config tfe8096p_dib8000_config = {
1953 .output_mpeg2_in_188_bytes = 1,
1954 .hostbus_diversity = 1,
1955 .update_lna = NULL,
1956
1957 .agc_config_count = 2,
1958 .agc = dib8096p_agc_config,
1959 .pll = &dib8096p_clock_config_12_mhz,
1960
1961 .gpio_dir = DIB8000_GPIO_DEFAULT_DIRECTIONS,
1962 .gpio_val = DIB8000_GPIO_DEFAULT_VALUES,
1963 .gpio_pwm_pos = DIB8000_GPIO_DEFAULT_PWM_POS,
1964
1965 .agc_control = NULL,
1966 .diversity_delay = 48,
1967 .output_mode = OUTMODE_MPEG2_FIFO,
1968 .enMpegOutput = 1,
1969};
1970
1971static struct dib0090_wbd_slope dib8096p_wbd_table[] = {
1972 { 380, 81, 850, 64, 540, 4},
1973 { 860, 51, 866, 21, 375, 4},
1974 {1700, 0, 250, 0, 100, 6},
1975 {2600, 0, 250, 0, 100, 6},
1976 { 0xFFFF, 0, 0, 0, 0, 0},
1977};
1978
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001979static struct dib0090_config tfe8096p_dib0090_config = {
Olivier Grenie88f3a352011-08-10 05:28:38 -03001980 .io.clock_khz = 12000,
1981 .io.pll_bypass = 0,
1982 .io.pll_range = 0,
1983 .io.pll_prediv = 3,
1984 .io.pll_loopdiv = 6,
1985 .io.adc_clock_ratio = 0,
1986 .io.pll_int_loop_filt = 0,
Olivier Grenie88f3a352011-08-10 05:28:38 -03001987
1988 .freq_offset_khz_uhf = -143,
1989 .freq_offset_khz_vhf = -143,
1990
1991 .get_adc_power = dib8090_get_adc_power,
1992
1993 .clkouttobamse = 1,
1994 .analog_output = 0,
1995
1996 .wbd_vhf_offset = 0,
1997 .wbd_cband_offset = 0,
1998 .use_pwm_agc = 1,
1999 .clkoutdrive = 0,
2000
2001 .fref_clock_ratio = 1,
2002
Olivier Grenie88f3a352011-08-10 05:28:38 -03002003 .ls_cfg_pad_drv = 0,
2004 .data_tx_drv = 0,
2005 .low_if = NULL,
2006 .in_soc = 1,
2007 .force_cband_input = 0,
2008};
2009
2010struct dibx090p_adc {
2011 u32 freq; /* RF freq MHz */
2012 u32 timf; /* New Timf */
2013 u32 pll_loopdiv; /* New prediv */
2014 u32 pll_prediv; /* New loopdiv */
2015};
2016
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03002017struct dibx090p_best_adc {
2018 u32 timf;
2019 u32 pll_loopdiv;
2020 u32 pll_prediv;
Olivier Grenie88f3a352011-08-10 05:28:38 -03002021};
2022
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03002023static int dib8096p_get_best_sampling(struct dvb_frontend *fe, struct dibx090p_best_adc *adc)
2024{
2025 u8 spur = 0, prediv = 0, loopdiv = 0, min_prediv = 1, max_prediv = 1;
2026 u16 xtal = 12000;
2027 u16 fcp_min = 1900; /* PLL, Minimum Frequency of phase comparator (KHz) */
2028 u16 fcp_max = 20000; /* PLL, Maximum Frequency of phase comparator (KHz) */
2029 u32 fmem_max = 140000; /* 140MHz max SDRAM freq */
2030 u32 fdem_min = 66000;
2031 u32 fcp = 0, fs = 0, fdem = 0, fmem = 0;
2032 u32 harmonic_id = 0;
2033
2034 adc->timf = 0;
2035 adc->pll_loopdiv = loopdiv;
2036 adc->pll_prediv = prediv;
2037
2038 deb_info("bandwidth = %d", fe->dtv_property_cache.bandwidth_hz);
2039
2040 /* Find Min and Max prediv */
2041 while ((xtal / max_prediv) >= fcp_min)
2042 max_prediv++;
2043
2044 max_prediv--;
2045 min_prediv = max_prediv;
2046 while ((xtal / min_prediv) <= fcp_max) {
2047 min_prediv--;
2048 if (min_prediv == 1)
2049 break;
2050 }
2051 deb_info("MIN prediv = %d : MAX prediv = %d", min_prediv, max_prediv);
2052
2053 min_prediv = 1;
2054
2055 for (prediv = min_prediv; prediv < max_prediv; prediv++) {
2056 fcp = xtal / prediv;
2057 if (fcp > fcp_min && fcp < fcp_max) {
2058 for (loopdiv = 1; loopdiv < 64; loopdiv++) {
2059 fmem = ((xtal/prediv) * loopdiv);
2060 fdem = fmem / 2;
2061 fs = fdem / 4;
2062
2063 /* test min/max system restrictions */
2064 if ((fdem >= fdem_min) && (fmem <= fmem_max) && (fs >= fe->dtv_property_cache.bandwidth_hz / 1000)) {
2065 spur = 0;
2066 /* test fs harmonics positions */
2067 for (harmonic_id = (fe->dtv_property_cache.frequency / (1000 * fs)); harmonic_id <= ((fe->dtv_property_cache.frequency / (1000 * fs)) + 1); harmonic_id++) {
2068 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)))) {
2069 spur = 1;
2070 break;
2071 }
2072 }
2073
2074 if (!spur) {
2075 adc->pll_loopdiv = loopdiv;
2076 adc->pll_prediv = prediv;
2077 adc->timf = (4260880253U / fdem) * (1 << 8);
2078 adc->timf += ((4260880253U % fdem) << 8) / fdem;
2079
2080 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);
2081 break;
2082 }
2083 }
2084 }
2085 }
2086 if (!spur)
2087 break;
2088 }
2089
2090 if (adc->pll_loopdiv == 0 && adc->pll_prediv == 0)
2091 return -EINVAL;
2092 return 0;
2093}
2094
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -03002095static int dib8096p_agc_startup(struct dvb_frontend *fe)
Olivier Grenie88f3a352011-08-10 05:28:38 -03002096{
2097 struct dvb_usb_adapter *adap = fe->dvb->priv;
2098 struct dib0700_adapter_state *state = adap->priv;
2099 struct dibx000_bandwidth_config pll;
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03002100 struct dibx090p_best_adc adc;
Olivier Grenie88f3a352011-08-10 05:28:38 -03002101 u16 target;
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03002102 int ret;
Olivier Grenie88f3a352011-08-10 05:28:38 -03002103
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -03002104 ret = state->set_param_save(fe);
Olivier Grenie88f3a352011-08-10 05:28:38 -03002105 if (ret < 0)
2106 return ret;
2107 memset(&pll, 0, sizeof(struct dibx000_bandwidth_config));
2108
2109 dib0090_pwm_gain_reset(fe);
2110 /* dib0090_get_wbd_target is returning any possible
2111 temperature compensated wbd-target */
2112 target = (dib0090_get_wbd_target(fe) * 8 + 1) / 2;
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03002113 state->dib8000_ops.set_wbd_ref(fe, target);
Olivier Grenie88f3a352011-08-10 05:28:38 -03002114
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03002115 if (dib8096p_get_best_sampling(fe, &adc) == 0) {
2116 pll.pll_ratio = adc.pll_loopdiv;
2117 pll.pll_prediv = adc.pll_prediv;
Olivier Grenie88f3a352011-08-10 05:28:38 -03002118
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03002119 dib0700_set_i2c_speed(adap->dev, 200);
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03002120 state->dib8000_ops.update_pll(fe, &pll, fe->dtv_property_cache.bandwidth_hz / 1000, 0);
2121 state->dib8000_ops.ctrl_timf(fe, DEMOD_TIMF_SET, adc.timf);
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03002122 dib0700_set_i2c_speed(adap->dev, 1000);
Olivier Grenie88f3a352011-08-10 05:28:38 -03002123 }
2124 return 0;
2125}
2126
2127static int tfe8096p_frontend_attach(struct dvb_usb_adapter *adap)
2128{
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03002129 struct dib0700_state *st = adap->dev->priv;
2130 u32 fw_version;
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03002131 struct dib0700_adapter_state *state = adap->priv;
2132
2133 if (!dvb_attach(dib8000_attach, &state->dib8000_ops))
2134 return -ENODEV;
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03002135
2136 dib0700_get_version(adap->dev, NULL, NULL, &fw_version, NULL);
2137 if (fw_version >= 0x10200)
2138 st->fw_use_new_i2c_api = 1;
2139
Olivier Grenie88f3a352011-08-10 05:28:38 -03002140 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
2141 msleep(20);
2142 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
2143 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
2144 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
2145
2146 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
2147
2148 dib0700_ctrl_clock(adap->dev, 72, 1);
2149
2150 msleep(20);
2151 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
2152 msleep(20);
2153 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
2154
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03002155 state->dib8000_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 0x10, 0x80, 1);
Olivier Grenie88f3a352011-08-10 05:28:38 -03002156
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03002157 adap->fe_adap[0].fe = state->dib8000_ops.init(&adap->dev->i2c_adap,
2158 0x80, &tfe8096p_dib8000_config);
Olivier Grenie88f3a352011-08-10 05:28:38 -03002159
2160 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
2161}
2162
2163static int tfe8096p_tuner_attach(struct dvb_usb_adapter *adap)
2164{
2165 struct dib0700_adapter_state *st = adap->priv;
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03002166 struct i2c_adapter *tun_i2c = st->dib8000_ops.get_i2c_tuner(adap->fe_adap[0].fe);
2167
2168 tfe8096p_dib0090_config.reset = st->dib8000_ops.tuner_sleep;
2169 tfe8096p_dib0090_config.sleep = st->dib8000_ops.tuner_sleep;
2170 tfe8096p_dib0090_config.wbd = dib8096p_wbd_table;
Olivier Grenie88f3a352011-08-10 05:28:38 -03002171
2172 if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c,
2173 &tfe8096p_dib0090_config) == NULL)
2174 return -ENODEV;
2175
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03002176 st->dib8000_ops.set_gpio(adap->fe_adap[0].fe, 8, 0, 1);
Olivier Grenie88f3a352011-08-10 05:28:38 -03002177
2178 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
2179 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib8096p_agc_startup;
2180 return 0;
2181}
2182
Olivier Greniebe9bae12011-01-04 05:42:19 -03002183/* STK9090M */
2184static int dib90x0_pid_filter(struct dvb_usb_adapter *adapter, int index, u16 pid, int onoff)
2185{
Michael Krufky77eed212011-09-06 09:31:57 -03002186 return dib9000_fw_pid_filter(adapter->fe_adap[0].fe, index, pid, onoff);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002187}
2188
2189static int dib90x0_pid_filter_ctrl(struct dvb_usb_adapter *adapter, int onoff)
2190{
Michael Krufky77eed212011-09-06 09:31:57 -03002191 return dib9000_fw_pid_filter_ctrl(adapter->fe_adap[0].fe, onoff);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002192}
2193
2194static int dib90x0_tuner_reset(struct dvb_frontend *fe, int onoff)
2195{
2196 return dib9000_set_gpio(fe, 5, 0, !onoff);
2197}
2198
2199static int dib90x0_tuner_sleep(struct dvb_frontend *fe, int onoff)
2200{
2201 return dib9000_set_gpio(fe, 0, 0, onoff);
2202}
2203
2204static int dib01x0_pmu_update(struct i2c_adapter *i2c, u16 *data, u8 len)
2205{
2206 u8 wb[4] = { 0xc >> 8, 0xc & 0xff, 0, 0 };
2207 u8 rb[2];
2208 struct i2c_msg msg[2] = {
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002209 {.addr = 0x1e >> 1, .flags = 0, .buf = wb, .len = 2},
2210 {.addr = 0x1e >> 1, .flags = I2C_M_RD, .buf = rb, .len = 2},
Olivier Greniebe9bae12011-01-04 05:42:19 -03002211 };
2212 u8 index_data;
2213
2214 dibx000_i2c_set_speed(i2c, 250);
2215
2216 if (i2c_transfer(i2c, msg, 2) != 2)
2217 return -EIO;
2218
2219 switch (rb[0] << 8 | rb[1]) {
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002220 case 0:
Olivier Greniebe9bae12011-01-04 05:42:19 -03002221 deb_info("Found DiB0170 rev1: This version of DiB0170 is not supported any longer.\n");
2222 return -EIO;
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002223 case 1:
Olivier Greniebe9bae12011-01-04 05:42:19 -03002224 deb_info("Found DiB0170 rev2");
2225 break;
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002226 case 2:
Olivier Greniebe9bae12011-01-04 05:42:19 -03002227 deb_info("Found DiB0190 rev2");
2228 break;
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002229 default:
Olivier Greniebe9bae12011-01-04 05:42:19 -03002230 deb_info("DiB01x0 not found");
2231 return -EIO;
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002232 }
Olivier Greniebe9bae12011-01-04 05:42:19 -03002233
2234 for (index_data = 0; index_data < len; index_data += 2) {
2235 wb[2] = (data[index_data + 1] >> 8) & 0xff;
2236 wb[3] = (data[index_data + 1]) & 0xff;
2237
2238 if (data[index_data] == 0) {
2239 wb[0] = (data[index_data] >> 8) & 0xff;
2240 wb[1] = (data[index_data]) & 0xff;
2241 msg[0].len = 2;
2242 if (i2c_transfer(i2c, msg, 2) != 2)
2243 return -EIO;
2244 wb[2] |= rb[0];
2245 wb[3] |= rb[1] & ~(3 << 4);
2246 }
2247
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002248 wb[0] = (data[index_data] >> 8)&0xff;
2249 wb[1] = (data[index_data])&0xff;
Olivier Greniebe9bae12011-01-04 05:42:19 -03002250 msg[0].len = 4;
2251 if (i2c_transfer(i2c, &msg[0], 1) != 1)
2252 return -EIO;
2253 }
2254 return 0;
2255}
2256
2257static struct dib9000_config stk9090m_config = {
2258 .output_mpeg2_in_188_bytes = 1,
2259 .output_mode = OUTMODE_MPEG2_FIFO,
2260 .vcxo_timer = 279620,
2261 .timing_frequency = 20452225,
2262 .demod_clock_khz = 60000,
2263 .xtal_clock_khz = 30000,
2264 .if_drives = (0 << 15) | (1 << 13) | (0 << 12) | (3 << 10) | (0 << 9) | (1 << 7) | (0 << 6) | (0 << 4) | (1 << 3) | (1 << 1) | (0),
2265 .subband = {
2266 2,
2267 {
2268 { 240, { BOARD_GPIO_COMPONENT_DEMOD, BOARD_GPIO_FUNCTION_SUBBAND_GPIO, 0x0008, 0x0000, 0x0008 } }, /* GPIO 3 to 1 for VHF */
2269 { 890, { BOARD_GPIO_COMPONENT_DEMOD, BOARD_GPIO_FUNCTION_SUBBAND_GPIO, 0x0008, 0x0000, 0x0000 } }, /* GPIO 3 to 0 for UHF */
2270 { 0 },
2271 },
2272 },
2273 .gpio_function = {
2274 { .component = BOARD_GPIO_COMPONENT_DEMOD, .function = BOARD_GPIO_FUNCTION_COMPONENT_ON, .mask = 0x10 | 0x21, .direction = 0 & ~0x21, .value = (0x10 & ~0x1) | 0x20 },
2275 { .component = BOARD_GPIO_COMPONENT_DEMOD, .function = BOARD_GPIO_FUNCTION_COMPONENT_OFF, .mask = 0x10 | 0x21, .direction = 0 & ~0x21, .value = 0 | 0x21 },
2276 },
2277};
2278
2279static struct dib9000_config nim9090md_config[2] = {
2280 {
2281 .output_mpeg2_in_188_bytes = 1,
2282 .output_mode = OUTMODE_MPEG2_FIFO,
2283 .vcxo_timer = 279620,
2284 .timing_frequency = 20452225,
2285 .demod_clock_khz = 60000,
2286 .xtal_clock_khz = 30000,
2287 .if_drives = (0 << 15) | (1 << 13) | (0 << 12) | (3 << 10) | (0 << 9) | (1 << 7) | (0 << 6) | (0 << 4) | (1 << 3) | (1 << 1) | (0),
2288 }, {
2289 .output_mpeg2_in_188_bytes = 1,
2290 .output_mode = OUTMODE_DIVERSITY,
2291 .vcxo_timer = 279620,
2292 .timing_frequency = 20452225,
2293 .demod_clock_khz = 60000,
2294 .xtal_clock_khz = 30000,
2295 .if_drives = (0 << 15) | (1 << 13) | (0 << 12) | (3 << 10) | (0 << 9) | (1 << 7) | (0 << 6) | (0 << 4) | (1 << 3) | (1 << 1) | (0),
2296 .subband = {
2297 2,
2298 {
2299 { 240, { BOARD_GPIO_COMPONENT_DEMOD, BOARD_GPIO_FUNCTION_SUBBAND_GPIO, 0x0006, 0x0000, 0x0006 } }, /* GPIO 1 and 2 to 1 for VHF */
2300 { 890, { BOARD_GPIO_COMPONENT_DEMOD, BOARD_GPIO_FUNCTION_SUBBAND_GPIO, 0x0006, 0x0000, 0x0000 } }, /* GPIO 1 and 2 to 0 for UHF */
2301 { 0 },
2302 },
2303 },
2304 .gpio_function = {
2305 { .component = BOARD_GPIO_COMPONENT_DEMOD, .function = BOARD_GPIO_FUNCTION_COMPONENT_ON, .mask = 0x10 | 0x21, .direction = 0 & ~0x21, .value = (0x10 & ~0x1) | 0x20 },
2306 { .component = BOARD_GPIO_COMPONENT_DEMOD, .function = BOARD_GPIO_FUNCTION_COMPONENT_OFF, .mask = 0x10 | 0x21, .direction = 0 & ~0x21, .value = 0 | 0x21 },
2307 },
2308 }
2309};
2310
2311static struct dib0090_config dib9090_dib0090_config = {
2312 .io.pll_bypass = 0,
2313 .io.pll_range = 1,
2314 .io.pll_prediv = 1,
2315 .io.pll_loopdiv = 8,
2316 .io.adc_clock_ratio = 8,
2317 .io.pll_int_loop_filt = 0,
2318 .io.clock_khz = 30000,
2319 .reset = dib90x0_tuner_reset,
2320 .sleep = dib90x0_tuner_sleep,
2321 .clkouttobamse = 0,
2322 .analog_output = 0,
2323 .use_pwm_agc = 0,
2324 .clkoutdrive = 0,
2325 .freq_offset_khz_uhf = 0,
2326 .freq_offset_khz_vhf = 0,
2327};
2328
2329static struct dib0090_config nim9090md_dib0090_config[2] = {
2330 {
2331 .io.pll_bypass = 0,
2332 .io.pll_range = 1,
2333 .io.pll_prediv = 1,
2334 .io.pll_loopdiv = 8,
2335 .io.adc_clock_ratio = 8,
2336 .io.pll_int_loop_filt = 0,
2337 .io.clock_khz = 30000,
2338 .reset = dib90x0_tuner_reset,
2339 .sleep = dib90x0_tuner_sleep,
2340 .clkouttobamse = 1,
2341 .analog_output = 0,
2342 .use_pwm_agc = 0,
2343 .clkoutdrive = 0,
2344 .freq_offset_khz_uhf = 0,
2345 .freq_offset_khz_vhf = 0,
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002346 }, {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002347 .io.pll_bypass = 0,
2348 .io.pll_range = 1,
2349 .io.pll_prediv = 1,
2350 .io.pll_loopdiv = 8,
2351 .io.adc_clock_ratio = 8,
2352 .io.pll_int_loop_filt = 0,
2353 .io.clock_khz = 30000,
2354 .reset = dib90x0_tuner_reset,
2355 .sleep = dib90x0_tuner_sleep,
2356 .clkouttobamse = 0,
2357 .analog_output = 0,
2358 .use_pwm_agc = 0,
2359 .clkoutdrive = 0,
2360 .freq_offset_khz_uhf = 0,
2361 .freq_offset_khz_vhf = 0,
2362 }
2363};
2364
2365
2366static int stk9090m_frontend_attach(struct dvb_usb_adapter *adap)
2367{
2368 struct dib0700_adapter_state *state = adap->priv;
2369 struct dib0700_state *st = adap->dev->priv;
2370 u32 fw_version;
2371
2372 /* Make use of the new i2c functions from FW 1.20 */
2373 dib0700_get_version(adap->dev, NULL, NULL, &fw_version, NULL);
2374 if (fw_version >= 0x10200)
2375 st->fw_use_new_i2c_api = 1;
2376 dib0700_set_i2c_speed(adap->dev, 340);
2377
2378 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002379 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002380 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
2381 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
2382 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
2383 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
2384
2385 dib0700_ctrl_clock(adap->dev, 72, 1);
2386
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002387 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002388 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002389 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002390 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
2391
2392 dib9000_i2c_enumeration(&adap->dev->i2c_adap, 1, 0x10, 0x80);
2393
2394 if (request_firmware(&state->frontend_firmware, "dib9090.fw", &adap->dev->udev->dev)) {
2395 deb_info("%s: Upload failed. (file not found?)\n", __func__);
2396 return -ENODEV;
2397 } else {
2398 deb_info("%s: firmware read %Zu bytes.\n", __func__, state->frontend_firmware->size);
2399 }
2400 stk9090m_config.microcode_B_fe_size = state->frontend_firmware->size;
2401 stk9090m_config.microcode_B_fe_buffer = state->frontend_firmware->data;
2402
Michael Krufky77eed212011-09-06 09:31:57 -03002403 adap->fe_adap[0].fe = dvb_attach(dib9000_attach, &adap->dev->i2c_adap, 0x80, &stk9090m_config);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002404
Michael Krufky77eed212011-09-06 09:31:57 -03002405 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Olivier Greniebe9bae12011-01-04 05:42:19 -03002406}
2407
2408static int dib9090_tuner_attach(struct dvb_usb_adapter *adap)
2409{
2410 struct dib0700_adapter_state *state = adap->priv;
Michael Krufky77eed212011-09-06 09:31:57 -03002411 struct i2c_adapter *i2c = dib9000_get_tuner_interface(adap->fe_adap[0].fe);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002412 u16 data_dib190[10] = {
2413 1, 0x1374,
2414 2, 0x01a2,
2415 7, 0x0020,
2416 0, 0x00ef,
2417 8, 0x0486,
2418 };
2419
Michael Krufky77eed212011-09-06 09:31:57 -03002420 if (dvb_attach(dib0090_fw_register, adap->fe_adap[0].fe, i2c, &dib9090_dib0090_config) == NULL)
Olivier Greniebe9bae12011-01-04 05:42:19 -03002421 return -ENODEV;
Michael Krufky77eed212011-09-06 09:31:57 -03002422 i2c = dib9000_get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_GPIO_1_2, 0);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002423 if (dib01x0_pmu_update(i2c, data_dib190, 10) != 0)
2424 return -ENODEV;
Olivier Grenied1190022011-08-29 10:58:47 -03002425 dib0700_set_i2c_speed(adap->dev, 1500);
Michael Krufky77eed212011-09-06 09:31:57 -03002426 if (dib9000_firmware_post_pll_init(adap->fe_adap[0].fe) < 0)
Olivier Greniebe9bae12011-01-04 05:42:19 -03002427 return -ENODEV;
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002428 release_firmware(state->frontend_firmware);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002429 return 0;
2430}
2431
2432static int nim9090md_frontend_attach(struct dvb_usb_adapter *adap)
2433{
2434 struct dib0700_adapter_state *state = adap->priv;
2435 struct dib0700_state *st = adap->dev->priv;
2436 struct i2c_adapter *i2c;
2437 struct dvb_frontend *fe_slave;
2438 u32 fw_version;
2439
2440 /* Make use of the new i2c functions from FW 1.20 */
2441 dib0700_get_version(adap->dev, NULL, NULL, &fw_version, NULL);
2442 if (fw_version >= 0x10200)
2443 st->fw_use_new_i2c_api = 1;
2444 dib0700_set_i2c_speed(adap->dev, 340);
2445
2446 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002447 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002448 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
2449 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
2450 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
2451 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
2452
2453 dib0700_ctrl_clock(adap->dev, 72, 1);
2454
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002455 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002456 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002457 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002458 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
2459
2460 if (request_firmware(&state->frontend_firmware, "dib9090.fw", &adap->dev->udev->dev)) {
2461 deb_info("%s: Upload failed. (file not found?)\n", __func__);
2462 return -EIO;
2463 } else {
2464 deb_info("%s: firmware read %Zu bytes.\n", __func__, state->frontend_firmware->size);
2465 }
2466 nim9090md_config[0].microcode_B_fe_size = state->frontend_firmware->size;
2467 nim9090md_config[0].microcode_B_fe_buffer = state->frontend_firmware->data;
2468 nim9090md_config[1].microcode_B_fe_size = state->frontend_firmware->size;
2469 nim9090md_config[1].microcode_B_fe_buffer = state->frontend_firmware->data;
2470
2471 dib9000_i2c_enumeration(&adap->dev->i2c_adap, 1, 0x20, 0x80);
Michael Krufky77eed212011-09-06 09:31:57 -03002472 adap->fe_adap[0].fe = dvb_attach(dib9000_attach, &adap->dev->i2c_adap, 0x80, &nim9090md_config[0]);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002473
Michael Krufky77eed212011-09-06 09:31:57 -03002474 if (adap->fe_adap[0].fe == NULL)
Olivier Greniebe9bae12011-01-04 05:42:19 -03002475 return -ENODEV;
2476
Michael Krufky77eed212011-09-06 09:31:57 -03002477 i2c = dib9000_get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_GPIO_3_4, 0);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002478 dib9000_i2c_enumeration(i2c, 1, 0x12, 0x82);
2479
2480 fe_slave = dvb_attach(dib9000_attach, i2c, 0x82, &nim9090md_config[1]);
Michael Krufky77eed212011-09-06 09:31:57 -03002481 dib9000_set_slave_frontend(adap->fe_adap[0].fe, fe_slave);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002482
2483 return fe_slave == NULL ? -ENODEV : 0;
2484}
2485
2486static int nim9090md_tuner_attach(struct dvb_usb_adapter *adap)
2487{
2488 struct dib0700_adapter_state *state = adap->priv;
2489 struct i2c_adapter *i2c;
2490 struct dvb_frontend *fe_slave;
2491 u16 data_dib190[10] = {
2492 1, 0x5374,
2493 2, 0x01ae,
2494 7, 0x0020,
2495 0, 0x00ef,
2496 8, 0x0406,
2497 };
Michael Krufky77eed212011-09-06 09:31:57 -03002498 i2c = dib9000_get_tuner_interface(adap->fe_adap[0].fe);
2499 if (dvb_attach(dib0090_fw_register, adap->fe_adap[0].fe, i2c, &nim9090md_dib0090_config[0]) == NULL)
Olivier Greniebe9bae12011-01-04 05:42:19 -03002500 return -ENODEV;
Michael Krufky77eed212011-09-06 09:31:57 -03002501 i2c = dib9000_get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_GPIO_1_2, 0);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002502 if (dib01x0_pmu_update(i2c, data_dib190, 10) < 0)
2503 return -ENODEV;
Olivier Grenied1190022011-08-29 10:58:47 -03002504
2505 dib0700_set_i2c_speed(adap->dev, 1500);
Michael Krufky77eed212011-09-06 09:31:57 -03002506 if (dib9000_firmware_post_pll_init(adap->fe_adap[0].fe) < 0)
Olivier Greniebe9bae12011-01-04 05:42:19 -03002507 return -ENODEV;
2508
Michael Krufky77eed212011-09-06 09:31:57 -03002509 fe_slave = dib9000_get_slave_frontend(adap->fe_adap[0].fe, 1);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002510 if (fe_slave != NULL) {
Michael Krufky77eed212011-09-06 09:31:57 -03002511 i2c = dib9000_get_component_bus_interface(adap->fe_adap[0].fe);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002512 dib9000_set_i2c_adapter(fe_slave, i2c);
2513
2514 i2c = dib9000_get_tuner_interface(fe_slave);
2515 if (dvb_attach(dib0090_fw_register, fe_slave, i2c, &nim9090md_dib0090_config[1]) == NULL)
2516 return -ENODEV;
Michael Krufky77eed212011-09-06 09:31:57 -03002517 fe_slave->dvb = adap->fe_adap[0].fe->dvb;
Olivier Grenied1190022011-08-29 10:58:47 -03002518 dib9000_fw_set_component_bus_speed(adap->fe_adap[0].fe, 1500);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002519 if (dib9000_firmware_post_pll_init(fe_slave) < 0)
2520 return -ENODEV;
2521 }
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002522 release_firmware(state->frontend_firmware);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002523
2524 return 0;
2525}
2526
2527/* NIM7090 */
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03002528static int dib7090p_get_best_sampling(struct dvb_frontend *fe , struct dibx090p_best_adc *adc)
Olivier Greniebe9bae12011-01-04 05:42:19 -03002529{
2530 u8 spur = 0, prediv = 0, loopdiv = 0, min_prediv = 1, max_prediv = 1;
2531
2532 u16 xtal = 12000;
2533 u32 fcp_min = 1900; /* PLL Minimum Frequency comparator KHz */
2534 u32 fcp_max = 20000; /* PLL Maximum Frequency comparator KHz */
2535 u32 fdem_max = 76000;
2536 u32 fdem_min = 69500;
2537 u32 fcp = 0, fs = 0, fdem = 0;
2538 u32 harmonic_id = 0;
2539
2540 adc->pll_loopdiv = loopdiv;
2541 adc->pll_prediv = prediv;
2542 adc->timf = 0;
2543
2544 deb_info("bandwidth = %d fdem_min =%d", fe->dtv_property_cache.bandwidth_hz, fdem_min);
2545
2546 /* Find Min and Max prediv */
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002547 while ((xtal/max_prediv) >= fcp_min)
Olivier Greniebe9bae12011-01-04 05:42:19 -03002548 max_prediv++;
2549
2550 max_prediv--;
2551 min_prediv = max_prediv;
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002552 while ((xtal/min_prediv) <= fcp_max) {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002553 min_prediv--;
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002554 if (min_prediv == 1)
Olivier Greniebe9bae12011-01-04 05:42:19 -03002555 break;
2556 }
2557 deb_info("MIN prediv = %d : MAX prediv = %d", min_prediv, max_prediv);
2558
2559 min_prediv = 2;
2560
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002561 for (prediv = min_prediv ; prediv < max_prediv; prediv++) {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002562 fcp = xtal / prediv;
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002563 if (fcp > fcp_min && fcp < fcp_max) {
2564 for (loopdiv = 1 ; loopdiv < 64 ; loopdiv++) {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002565 fdem = ((xtal/prediv) * loopdiv);
2566 fs = fdem / 4;
2567 /* test min/max system restrictions */
2568
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002569 if ((fdem >= fdem_min) && (fdem <= fdem_max) && (fs >= fe->dtv_property_cache.bandwidth_hz/1000)) {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002570 spur = 0;
2571 /* test fs harmonics positions */
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002572 for (harmonic_id = (fe->dtv_property_cache.frequency / (1000*fs)) ; harmonic_id <= ((fe->dtv_property_cache.frequency / (1000*fs))+1) ; harmonic_id++) {
2573 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 -03002574 spur = 1;
2575 break;
2576 }
2577 }
2578
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002579 if (!spur) {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002580 adc->pll_loopdiv = loopdiv;
2581 adc->pll_prediv = prediv;
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002582 adc->timf = 2396745143UL/fdem*(1 << 9);
2583 adc->timf += ((2396745143UL%fdem) << 9)/fdem;
Olivier Greniebe9bae12011-01-04 05:42:19 -03002584 deb_info("loopdiv=%i prediv=%i timf=%i", loopdiv, prediv, adc->timf);
2585 break;
2586 }
2587 }
2588 }
2589 }
2590 if (!spur)
2591 break;
2592 }
2593
2594
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002595 if (adc->pll_loopdiv == 0 && adc->pll_prediv == 0)
Olivier Greniebe9bae12011-01-04 05:42:19 -03002596 return -EINVAL;
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002597 else
Olivier Greniebe9bae12011-01-04 05:42:19 -03002598 return 0;
2599}
2600
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -03002601static int dib7090_agc_startup(struct dvb_frontend *fe)
Olivier Greniebe9bae12011-01-04 05:42:19 -03002602{
2603 struct dvb_usb_adapter *adap = fe->dvb->priv;
2604 struct dib0700_adapter_state *state = adap->priv;
2605 struct dibx000_bandwidth_config pll;
2606 u16 target;
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03002607 struct dibx090p_best_adc adc;
Olivier Greniebe9bae12011-01-04 05:42:19 -03002608 int ret;
2609
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -03002610 ret = state->set_param_save(fe);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002611 if (ret < 0)
2612 return ret;
2613
2614 memset(&pll, 0, sizeof(struct dibx000_bandwidth_config));
2615 dib0090_pwm_gain_reset(fe);
Olivier Grenie6724a2f2011-08-05 13:49:33 -03002616 target = (dib0090_get_wbd_target(fe) * 8 + 1) / 2;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03002617 state->dib7000p_ops.set_wbd_ref(fe, target);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002618
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002619 if (dib7090p_get_best_sampling(fe, &adc) == 0) {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002620 pll.pll_ratio = adc.pll_loopdiv;
2621 pll.pll_prediv = adc.pll_prediv;
2622
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03002623 state->dib7000p_ops.update_pll(fe, &pll);
2624 state->dib7000p_ops.ctrl_timf(fe, DEMOD_TIMF_SET, adc.timf);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002625 }
2626 return 0;
2627}
2628
Olivier Grenie2e802862011-08-05 10:39:15 -03002629static int dib7090_agc_restart(struct dvb_frontend *fe, u8 restart)
2630{
2631 deb_info("AGC restart callback: %d", restart);
2632 if (restart == 0) /* before AGC startup */
2633 dib0090_set_dc_servo(fe, 1);
2634 return 0;
2635}
2636
Olivier Grenief45f5132012-12-31 09:47:10 -03002637static int tfe7790p_update_lna(struct dvb_frontend *fe, u16 agc_global)
Olivier Grenie6724a2f2011-08-05 13:49:33 -03002638{
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03002639 struct dvb_usb_adapter *adap = fe->dvb->priv;
2640 struct dib0700_adapter_state *state = adap->priv;
2641
Olivier Grenief45f5132012-12-31 09:47:10 -03002642 deb_info("update LNA: agc global=%i", agc_global);
Olivier Grenie6724a2f2011-08-05 13:49:33 -03002643
Olivier Grenief45f5132012-12-31 09:47:10 -03002644 if (agc_global < 25000) {
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03002645 state->dib7000p_ops.set_gpio(fe, 8, 0, 0);
2646 state->dib7000p_ops.set_agc1_min(fe, 0);
Olivier Grenie6724a2f2011-08-05 13:49:33 -03002647 } else {
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03002648 state->dib7000p_ops.set_gpio(fe, 8, 0, 1);
2649 state->dib7000p_ops.set_agc1_min(fe, 32768);
Olivier Grenie6724a2f2011-08-05 13:49:33 -03002650 }
2651
2652 return 0;
2653}
2654
Olivier Greniebe9bae12011-01-04 05:42:19 -03002655static struct dib0090_wbd_slope dib7090_wbd_table[] = {
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002656 { 380, 81, 850, 64, 540, 4},
2657 { 860, 51, 866, 21, 375, 4},
2658 {1700, 0, 250, 0, 100, 6},
2659 {2600, 0, 250, 0, 100, 6},
2660 { 0xFFFF, 0, 0, 0, 0, 0},
Olivier Greniebe9bae12011-01-04 05:42:19 -03002661};
2662
Olivier Greniea685dbb2011-08-05 14:10:40 -03002663static struct dibx000_agc_config dib7090_agc_config[2] = {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002664 {
2665 .band_caps = BAND_UHF,
2666 /* 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,
2667 * 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 -03002668 .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 -03002669
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002670 .inv_gain = 687,
2671 .time_stabiliz = 10,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002672
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002673 .alpha_level = 0,
2674 .thlock = 118,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002675
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002676 .wbd_inv = 0,
2677 .wbd_ref = 1200,
2678 .wbd_sel = 3,
2679 .wbd_alpha = 5,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002680
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002681 .agc1_max = 65535,
Olivier Grenie59501bb2012-12-31 09:51:17 -03002682 .agc1_min = 32768,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002683
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002684 .agc2_max = 65535,
2685 .agc2_min = 0,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002686
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002687 .agc1_pt1 = 0,
2688 .agc1_pt2 = 32,
2689 .agc1_pt3 = 114,
2690 .agc1_slope1 = 143,
2691 .agc1_slope2 = 144,
2692 .agc2_pt1 = 114,
2693 .agc2_pt2 = 227,
2694 .agc2_slope1 = 116,
2695 .agc2_slope2 = 117,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002696
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002697 .alpha_mant = 18,
2698 .alpha_exp = 0,
2699 .beta_mant = 20,
2700 .beta_exp = 59,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002701
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002702 .perform_agc_softsplit = 0,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002703 } , {
2704 .band_caps = BAND_FM | BAND_VHF | BAND_CBAND,
2705 /* 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,
2706 * 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 -03002707 .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 -03002708
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002709 .inv_gain = 732,
2710 .time_stabiliz = 10,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002711
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002712 .alpha_level = 0,
2713 .thlock = 118,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002714
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002715 .wbd_inv = 0,
2716 .wbd_ref = 1200,
2717 .wbd_sel = 3,
2718 .wbd_alpha = 5,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002719
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002720 .agc1_max = 65535,
2721 .agc1_min = 0,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002722
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002723 .agc2_max = 65535,
2724 .agc2_min = 0,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002725
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002726 .agc1_pt1 = 0,
2727 .agc1_pt2 = 0,
2728 .agc1_pt3 = 98,
2729 .agc1_slope1 = 0,
2730 .agc1_slope2 = 167,
Patrick Boettcher7f4d5272011-04-03 12:28:08 -03002731 .agc2_pt1 = 98,
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002732 .agc2_pt2 = 255,
2733 .agc2_slope1 = 104,
2734 .agc2_slope2 = 0,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002735
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002736 .alpha_mant = 18,
2737 .alpha_exp = 0,
2738 .beta_mant = 20,
2739 .beta_exp = 59,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002740
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002741 .perform_agc_softsplit = 0,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002742 }
2743};
2744
2745static struct dibx000_bandwidth_config dib7090_clock_config_12_mhz = {
Mauro Carvalho Chehab09628b22014-09-22 18:57:45 -03002746 .internal = 60000,
2747 .sampling = 15000,
2748 .pll_prediv = 1,
2749 .pll_ratio = 5,
2750 .pll_range = 0,
2751 .pll_reset = 0,
2752 .pll_bypass = 0,
2753 .enable_refdiv = 0,
2754 .bypclk_div = 0,
2755 .IO_CLK_en_core = 1,
2756 .ADClkSrc = 1,
2757 .modulo = 2,
2758 .sad_cfg = (3 << 14) | (1 << 12) | (524 << 0),
2759 .ifreq = (0 << 25) | 0,
2760 .timf = 20452225,
2761 .xtal_hz = 15000000,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002762};
2763
2764static struct dib7000p_config nim7090_dib7000p_config = {
2765 .output_mpeg2_in_188_bytes = 1,
2766 .hostbus_diversity = 1,
2767 .tuner_is_baseband = 1,
Olivier Grenie59501bb2012-12-31 09:51:17 -03002768 .update_lna = tfe7790p_update_lna, /* GPIO used is the same as TFE7790 */
Olivier Greniebe9bae12011-01-04 05:42:19 -03002769
2770 .agc_config_count = 2,
2771 .agc = dib7090_agc_config,
2772
2773 .bw = &dib7090_clock_config_12_mhz,
2774
2775 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
2776 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
2777 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
2778
2779 .pwm_freq_div = 0,
2780
2781 .agc_control = dib7090_agc_restart,
2782
2783 .spur_protect = 0,
2784 .disable_sample_and_hold = 0,
2785 .enable_current_mirror = 0,
2786 .diversity_delay = 0,
2787
2788 .output_mode = OUTMODE_MPEG2_FIFO,
2789 .enMpegOutput = 1,
2790};
2791
Olivier Grenie59501bb2012-12-31 09:51:17 -03002792static int tfe7090p_pvr_update_lna(struct dvb_frontend *fe, u16 agc_global)
2793{
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03002794 struct dvb_usb_adapter *adap = fe->dvb->priv;
2795 struct dib0700_adapter_state *state = adap->priv;
2796
Olivier Grenie59501bb2012-12-31 09:51:17 -03002797 deb_info("TFE7090P-PVR update LNA: agc global=%i", agc_global);
2798 if (agc_global < 25000) {
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03002799 state->dib7000p_ops.set_gpio(fe, 5, 0, 0);
2800 state->dib7000p_ops.set_agc1_min(fe, 0);
Olivier Grenie59501bb2012-12-31 09:51:17 -03002801 } else {
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03002802 state->dib7000p_ops.set_gpio(fe, 5, 0, 1);
2803 state->dib7000p_ops.set_agc1_min(fe, 32768);
Olivier Grenie59501bb2012-12-31 09:51:17 -03002804 }
2805
2806 return 0;
2807}
2808
Olivier Greniebe9bae12011-01-04 05:42:19 -03002809static struct dib7000p_config tfe7090pvr_dib7000p_config[2] = {
2810 {
2811 .output_mpeg2_in_188_bytes = 1,
2812 .hostbus_diversity = 1,
2813 .tuner_is_baseband = 1,
Olivier Grenie59501bb2012-12-31 09:51:17 -03002814 .update_lna = tfe7090p_pvr_update_lna,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002815
2816 .agc_config_count = 2,
2817 .agc = dib7090_agc_config,
2818
2819 .bw = &dib7090_clock_config_12_mhz,
2820
2821 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
2822 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
2823 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
2824
2825 .pwm_freq_div = 0,
2826
2827 .agc_control = dib7090_agc_restart,
2828
2829 .spur_protect = 0,
2830 .disable_sample_and_hold = 0,
2831 .enable_current_mirror = 0,
2832 .diversity_delay = 0,
2833
2834 .output_mode = OUTMODE_MPEG2_PAR_GATED_CLK,
2835 .default_i2c_addr = 0x90,
2836 .enMpegOutput = 1,
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002837 }, {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002838 .output_mpeg2_in_188_bytes = 1,
2839 .hostbus_diversity = 1,
2840 .tuner_is_baseband = 1,
Olivier Grenie59501bb2012-12-31 09:51:17 -03002841 .update_lna = tfe7090p_pvr_update_lna,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002842
2843 .agc_config_count = 2,
2844 .agc = dib7090_agc_config,
2845
2846 .bw = &dib7090_clock_config_12_mhz,
2847
2848 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
2849 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
2850 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
2851
2852 .pwm_freq_div = 0,
2853
2854 .agc_control = dib7090_agc_restart,
2855
2856 .spur_protect = 0,
2857 .disable_sample_and_hold = 0,
2858 .enable_current_mirror = 0,
2859 .diversity_delay = 0,
2860
2861 .output_mode = OUTMODE_MPEG2_PAR_GATED_CLK,
2862 .default_i2c_addr = 0x92,
2863 .enMpegOutput = 0,
2864 }
2865};
2866
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03002867static struct dib0090_config nim7090_dib0090_config = {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002868 .io.clock_khz = 12000,
2869 .io.pll_bypass = 0,
2870 .io.pll_range = 0,
2871 .io.pll_prediv = 3,
2872 .io.pll_loopdiv = 6,
2873 .io.adc_clock_ratio = 0,
2874 .io.pll_int_loop_filt = 0,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002875
2876 .freq_offset_khz_uhf = 0,
2877 .freq_offset_khz_vhf = 0,
2878
Olivier Greniebe9bae12011-01-04 05:42:19 -03002879 .clkouttobamse = 1,
2880 .analog_output = 0,
2881
2882 .wbd_vhf_offset = 0,
2883 .wbd_cband_offset = 0,
2884 .use_pwm_agc = 1,
2885 .clkoutdrive = 0,
2886
2887 .fref_clock_ratio = 0,
2888
2889 .wbd = dib7090_wbd_table,
2890
2891 .ls_cfg_pad_drv = 0,
2892 .data_tx_drv = 0,
2893 .low_if = NULL,
2894 .in_soc = 1,
2895};
2896
Olivier Grenief45f5132012-12-31 09:47:10 -03002897static struct dib7000p_config tfe7790p_dib7000p_config = {
Olivier Grenieb293f302011-08-09 04:48:25 -03002898 .output_mpeg2_in_188_bytes = 1,
2899 .hostbus_diversity = 1,
2900 .tuner_is_baseband = 1,
Olivier Grenief45f5132012-12-31 09:47:10 -03002901 .update_lna = tfe7790p_update_lna,
Olivier Grenieb293f302011-08-09 04:48:25 -03002902
2903 .agc_config_count = 2,
2904 .agc = dib7090_agc_config,
2905
2906 .bw = &dib7090_clock_config_12_mhz,
2907
2908 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
2909 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
2910 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
2911
2912 .pwm_freq_div = 0,
2913
2914 .agc_control = dib7090_agc_restart,
2915
2916 .spur_protect = 0,
2917 .disable_sample_and_hold = 0,
2918 .enable_current_mirror = 0,
2919 .diversity_delay = 0,
2920
2921 .output_mode = OUTMODE_MPEG2_PAR_GATED_CLK,
2922 .enMpegOutput = 1,
2923};
2924
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03002925static struct dib0090_config tfe7790p_dib0090_config = {
Olivier Grenieb293f302011-08-09 04:48:25 -03002926 .io.clock_khz = 12000,
2927 .io.pll_bypass = 0,
2928 .io.pll_range = 0,
2929 .io.pll_prediv = 3,
2930 .io.pll_loopdiv = 6,
2931 .io.adc_clock_ratio = 0,
2932 .io.pll_int_loop_filt = 0,
Olivier Grenieb293f302011-08-09 04:48:25 -03002933
2934 .freq_offset_khz_uhf = 0,
2935 .freq_offset_khz_vhf = 0,
2936
Olivier Grenieb293f302011-08-09 04:48:25 -03002937 .clkouttobamse = 1,
2938 .analog_output = 0,
2939
2940 .wbd_vhf_offset = 0,
2941 .wbd_cband_offset = 0,
2942 .use_pwm_agc = 1,
2943 .clkoutdrive = 0,
2944
2945 .fref_clock_ratio = 0,
2946
Olivier Grenief45f5132012-12-31 09:47:10 -03002947 .wbd = dib7090_wbd_table,
Olivier Grenieb293f302011-08-09 04:48:25 -03002948
2949 .ls_cfg_pad_drv = 0,
2950 .data_tx_drv = 0,
2951 .low_if = NULL,
2952 .in_soc = 1,
Olivier Grenief45f5132012-12-31 09:47:10 -03002953 .force_cband_input = 0,
2954 .is_dib7090e = 0,
Olivier Grenieb293f302011-08-09 04:48:25 -03002955 .force_crystal_mode = 1,
2956};
2957
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03002958static struct dib0090_config tfe7090pvr_dib0090_config[2] = {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002959 {
2960 .io.clock_khz = 12000,
2961 .io.pll_bypass = 0,
2962 .io.pll_range = 0,
2963 .io.pll_prediv = 3,
2964 .io.pll_loopdiv = 6,
2965 .io.adc_clock_ratio = 0,
2966 .io.pll_int_loop_filt = 0,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002967
2968 .freq_offset_khz_uhf = 50,
2969 .freq_offset_khz_vhf = 70,
2970
Olivier Greniebe9bae12011-01-04 05:42:19 -03002971 .clkouttobamse = 1,
2972 .analog_output = 0,
2973
2974 .wbd_vhf_offset = 0,
2975 .wbd_cband_offset = 0,
2976 .use_pwm_agc = 1,
2977 .clkoutdrive = 0,
2978
2979 .fref_clock_ratio = 0,
2980
2981 .wbd = dib7090_wbd_table,
2982
2983 .ls_cfg_pad_drv = 0,
2984 .data_tx_drv = 0,
2985 .low_if = NULL,
2986 .in_soc = 1,
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002987 }, {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002988 .io.clock_khz = 12000,
2989 .io.pll_bypass = 0,
2990 .io.pll_range = 0,
2991 .io.pll_prediv = 3,
2992 .io.pll_loopdiv = 6,
2993 .io.adc_clock_ratio = 0,
2994 .io.pll_int_loop_filt = 0,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002995
2996 .freq_offset_khz_uhf = -50,
2997 .freq_offset_khz_vhf = -70,
2998
Olivier Greniebe9bae12011-01-04 05:42:19 -03002999 .clkouttobamse = 1,
3000 .analog_output = 0,
3001
3002 .wbd_vhf_offset = 0,
3003 .wbd_cband_offset = 0,
3004 .use_pwm_agc = 1,
3005 .clkoutdrive = 0,
3006
3007 .fref_clock_ratio = 0,
3008
3009 .wbd = dib7090_wbd_table,
3010
3011 .ls_cfg_pad_drv = 0,
3012 .data_tx_drv = 0,
3013 .low_if = NULL,
3014 .in_soc = 1,
3015 }
3016};
3017
3018static int nim7090_frontend_attach(struct dvb_usb_adapter *adap)
3019{
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003020 struct dib0700_adapter_state *state = adap->priv;
3021
3022 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
3023 return -ENODEV;
3024
Olivier Greniebe9bae12011-01-04 05:42:19 -03003025 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03003026 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03003027 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
3028 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
3029 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
3030 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
3031
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03003032 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03003033 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03003034 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03003035 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
3036
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003037 if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 0x10, &nim7090_dib7000p_config) != 0) {
3038 err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n", __func__);
3039 dvb_detach(&state->dib7000p_ops);
Olivier Greniebe9bae12011-01-04 05:42:19 -03003040 return -ENODEV;
3041 }
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003042 adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap, 0x80, &nim7090_dib7000p_config);
Olivier Greniebe9bae12011-01-04 05:42:19 -03003043
Michael Krufky77eed212011-09-06 09:31:57 -03003044 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Olivier Greniebe9bae12011-01-04 05:42:19 -03003045}
3046
3047static int nim7090_tuner_attach(struct dvb_usb_adapter *adap)
3048{
3049 struct dib0700_adapter_state *st = adap->priv;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003050 struct i2c_adapter *tun_i2c = st->dib7000p_ops.get_i2c_tuner(adap->fe_adap[0].fe);
3051
3052 nim7090_dib0090_config.reset = st->dib7000p_ops.tuner_sleep,
3053 nim7090_dib0090_config.sleep = st->dib7000p_ops.tuner_sleep,
3054 nim7090_dib0090_config.get_adc_power = st->dib7000p_ops.get_adc_power;
Olivier Greniebe9bae12011-01-04 05:42:19 -03003055
Michael Krufky77eed212011-09-06 09:31:57 -03003056 if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c, &nim7090_dib0090_config) == NULL)
Olivier Greniebe9bae12011-01-04 05:42:19 -03003057 return -ENODEV;
3058
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003059 st->dib7000p_ops.set_gpio(adap->fe_adap[0].fe, 8, 0, 1);
Olivier Greniebe9bae12011-01-04 05:42:19 -03003060
Michael Krufky77eed212011-09-06 09:31:57 -03003061 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
3062 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib7090_agc_startup;
Olivier Greniebe9bae12011-01-04 05:42:19 -03003063 return 0;
3064}
3065
3066static int tfe7090pvr_frontend0_attach(struct dvb_usb_adapter *adap)
3067{
3068 struct dib0700_state *st = adap->dev->priv;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003069 struct dib0700_adapter_state *state = adap->priv;
3070
3071 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
3072 return -ENODEV;
Olivier Greniebe9bae12011-01-04 05:42:19 -03003073
3074 /* The TFE7090 requires the dib0700 to not be in master mode */
3075 st->disable_streaming_master_mode = 1;
3076
3077 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03003078 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03003079 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
3080 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
3081 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
3082 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
3083
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03003084 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03003085 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03003086 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03003087 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
3088
3089 /* initialize IC 0 */
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003090 if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 0x20, &tfe7090pvr_dib7000p_config[0]) != 0) {
3091 err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n", __func__);
3092 dvb_detach(&state->dib7000p_ops);
Olivier Greniebe9bae12011-01-04 05:42:19 -03003093 return -ENODEV;
3094 }
3095
3096 dib0700_set_i2c_speed(adap->dev, 340);
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003097 adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap, 0x90, &tfe7090pvr_dib7000p_config[0]);
Michael Krufky77eed212011-09-06 09:31:57 -03003098 if (adap->fe_adap[0].fe == NULL)
Olivier Greniebe9bae12011-01-04 05:42:19 -03003099 return -ENODEV;
3100
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003101 state->dib7000p_ops.slave_reset(adap->fe_adap[0].fe);
Patrick Boettcher71682522011-04-03 12:44:25 -03003102
Olivier Greniebe9bae12011-01-04 05:42:19 -03003103 return 0;
3104}
3105
3106static int tfe7090pvr_frontend1_attach(struct dvb_usb_adapter *adap)
3107{
3108 struct i2c_adapter *i2c;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003109 struct dib0700_adapter_state *state = adap->priv;
Olivier Greniebe9bae12011-01-04 05:42:19 -03003110
Michael Krufky77eed212011-09-06 09:31:57 -03003111 if (adap->dev->adapter[0].fe_adap[0].fe == NULL) {
Olivier Greniebe9bae12011-01-04 05:42:19 -03003112 err("the master dib7090 has to be initialized first");
3113 return -ENODEV; /* the master device has not been initialized */
3114 }
3115
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003116 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
3117 return -ENODEV;
3118
3119 i2c = state->dib7000p_ops.get_i2c_master(adap->dev->adapter[0].fe_adap[0].fe, DIBX000_I2C_INTERFACE_GPIO_6_7, 1);
3120 if (state->dib7000p_ops.i2c_enumeration(i2c, 1, 0x10, &tfe7090pvr_dib7000p_config[1]) != 0) {
3121 err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n", __func__);
3122 dvb_detach(&state->dib7000p_ops);
Olivier Greniebe9bae12011-01-04 05:42:19 -03003123 return -ENODEV;
3124 }
3125
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003126 adap->fe_adap[0].fe = state->dib7000p_ops.init(i2c, 0x92, &tfe7090pvr_dib7000p_config[1]);
Olivier Greniebe9bae12011-01-04 05:42:19 -03003127 dib0700_set_i2c_speed(adap->dev, 200);
3128
Michael Krufky77eed212011-09-06 09:31:57 -03003129 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Olivier Greniebe9bae12011-01-04 05:42:19 -03003130}
3131
3132static int tfe7090pvr_tuner0_attach(struct dvb_usb_adapter *adap)
3133{
3134 struct dib0700_adapter_state *st = adap->priv;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003135 struct i2c_adapter *tun_i2c = st->dib7000p_ops.get_i2c_tuner(adap->fe_adap[0].fe);
3136
3137 tfe7090pvr_dib0090_config[0].reset = st->dib7000p_ops.tuner_sleep;
3138 tfe7090pvr_dib0090_config[0].sleep = st->dib7000p_ops.tuner_sleep;
3139 tfe7090pvr_dib0090_config[0].get_adc_power = st->dib7000p_ops.get_adc_power;
Olivier Greniebe9bae12011-01-04 05:42:19 -03003140
Michael Krufky77eed212011-09-06 09:31:57 -03003141 if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c, &tfe7090pvr_dib0090_config[0]) == NULL)
Olivier Greniebe9bae12011-01-04 05:42:19 -03003142 return -ENODEV;
3143
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003144 st->dib7000p_ops.set_gpio(adap->fe_adap[0].fe, 8, 0, 1);
Olivier Greniebe9bae12011-01-04 05:42:19 -03003145
Michael Krufky77eed212011-09-06 09:31:57 -03003146 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
3147 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib7090_agc_startup;
Olivier Greniebe9bae12011-01-04 05:42:19 -03003148 return 0;
3149}
3150
3151static int tfe7090pvr_tuner1_attach(struct dvb_usb_adapter *adap)
3152{
3153 struct dib0700_adapter_state *st = adap->priv;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003154 struct i2c_adapter *tun_i2c = st->dib7000p_ops.get_i2c_tuner(adap->fe_adap[0].fe);
3155
3156 tfe7090pvr_dib0090_config[1].reset = st->dib7000p_ops.tuner_sleep;
3157 tfe7090pvr_dib0090_config[1].sleep = st->dib7000p_ops.tuner_sleep;
3158 tfe7090pvr_dib0090_config[1].get_adc_power = st->dib7000p_ops.get_adc_power;
Olivier Greniebe9bae12011-01-04 05:42:19 -03003159
Michael Krufky77eed212011-09-06 09:31:57 -03003160 if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c, &tfe7090pvr_dib0090_config[1]) == NULL)
Olivier Greniebe9bae12011-01-04 05:42:19 -03003161 return -ENODEV;
3162
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003163 st->dib7000p_ops.set_gpio(adap->fe_adap[0].fe, 8, 0, 1);
Olivier Greniebe9bae12011-01-04 05:42:19 -03003164
Michael Krufky77eed212011-09-06 09:31:57 -03003165 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
3166 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib7090_agc_startup;
Olivier Greniebe9bae12011-01-04 05:42:19 -03003167 return 0;
3168}
3169
Olivier Grenief45f5132012-12-31 09:47:10 -03003170static int tfe7790p_frontend_attach(struct dvb_usb_adapter *adap)
Olivier Grenieb293f302011-08-09 04:48:25 -03003171{
3172 struct dib0700_state *st = adap->dev->priv;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003173 struct dib0700_adapter_state *state = adap->priv;
3174
3175 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
3176 return -ENODEV;
Olivier Grenieb293f302011-08-09 04:48:25 -03003177
Olivier Grenief45f5132012-12-31 09:47:10 -03003178 /* The TFE7790P requires the dib0700 to not be in master mode */
Olivier Grenieb293f302011-08-09 04:48:25 -03003179 st->disable_streaming_master_mode = 1;
3180
3181 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
3182 msleep(20);
3183 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
3184 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
3185 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
3186 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
3187 msleep(20);
3188 dib0700_ctrl_clock(adap->dev, 72, 1);
3189 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
3190 msleep(20);
3191 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
3192
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003193 if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap,
Olivier Grenief45f5132012-12-31 09:47:10 -03003194 1, 0x10, &tfe7790p_dib7000p_config) != 0) {
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003195 err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n",
Olivier Grenieb293f302011-08-09 04:48:25 -03003196 __func__);
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003197 dvb_detach(&state->dib7000p_ops);
Olivier Grenieb293f302011-08-09 04:48:25 -03003198 return -ENODEV;
3199 }
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003200 adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap,
Olivier Grenief45f5132012-12-31 09:47:10 -03003201 0x80, &tfe7790p_dib7000p_config);
Olivier Grenieb293f302011-08-09 04:48:25 -03003202
3203 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
3204}
3205
Olivier Grenief45f5132012-12-31 09:47:10 -03003206static int tfe7790p_tuner_attach(struct dvb_usb_adapter *adap)
Olivier Grenieb293f302011-08-09 04:48:25 -03003207{
3208 struct dib0700_adapter_state *st = adap->priv;
3209 struct i2c_adapter *tun_i2c =
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003210 st->dib7000p_ops.get_i2c_tuner(adap->fe_adap[0].fe);
3211
3212
3213 tfe7790p_dib0090_config.reset = st->dib7000p_ops.tuner_sleep;
3214 tfe7790p_dib0090_config.sleep = st->dib7000p_ops.tuner_sleep;
3215 tfe7790p_dib0090_config.get_adc_power = st->dib7000p_ops.get_adc_power;
Olivier Grenieb293f302011-08-09 04:48:25 -03003216
3217 if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c,
Olivier Grenief45f5132012-12-31 09:47:10 -03003218 &tfe7790p_dib0090_config) == NULL)
Olivier Grenie6724a2f2011-08-05 13:49:33 -03003219 return -ENODEV;
3220
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003221 st->dib7000p_ops.set_gpio(adap->fe_adap[0].fe, 8, 0, 1);
Olivier Grenie6724a2f2011-08-05 13:49:33 -03003222
3223 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
3224 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib7090_agc_startup;
3225 return 0;
3226}
3227
Patrick Boettcher01373a52007-07-30 12:49:04 -03003228/* STK7070PD */
3229static struct dib7000p_config stk7070pd_dib7000p_config[2] = {
3230 {
3231 .output_mpeg2_in_188_bytes = 1,
3232
3233 .agc_config_count = 1,
3234 .agc = &dib7070_agc_config,
3235 .bw = &dib7070_bw_config_12_mhz,
Patrick Boettcher3cb2c392008-01-25 07:25:20 -03003236 .tuner_is_baseband = 1,
3237 .spur_protect = 1,
Patrick Boettcher01373a52007-07-30 12:49:04 -03003238
3239 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
3240 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
3241 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
3242
3243 .hostbus_diversity = 1,
3244 }, {
3245 .output_mpeg2_in_188_bytes = 1,
3246
3247 .agc_config_count = 1,
3248 .agc = &dib7070_agc_config,
3249 .bw = &dib7070_bw_config_12_mhz,
Patrick Boettcher3cb2c392008-01-25 07:25:20 -03003250 .tuner_is_baseband = 1,
3251 .spur_protect = 1,
Patrick Boettcher01373a52007-07-30 12:49:04 -03003252
3253 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
3254 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
3255 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
3256
3257 .hostbus_diversity = 1,
3258 }
3259};
3260
Jiri Slaby52fd5b22012-01-10 14:11:23 -03003261static void stk7070pd_init(struct dvb_usb_device *dev)
3262{
3263 dib0700_set_gpio(dev, GPIO6, GPIO_OUT, 1);
3264 msleep(10);
3265 dib0700_set_gpio(dev, GPIO9, GPIO_OUT, 1);
3266 dib0700_set_gpio(dev, GPIO4, GPIO_OUT, 1);
3267 dib0700_set_gpio(dev, GPIO7, GPIO_OUT, 1);
3268 dib0700_set_gpio(dev, GPIO10, GPIO_OUT, 0);
3269
3270 dib0700_ctrl_clock(dev, 72, 1);
3271
3272 msleep(10);
3273 dib0700_set_gpio(dev, GPIO10, GPIO_OUT, 1);
3274}
3275
Patrick Boettcher01373a52007-07-30 12:49:04 -03003276static int stk7070pd_frontend_attach0(struct dvb_usb_adapter *adap)
3277{
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003278 struct dib0700_adapter_state *state = adap->priv;
3279
3280 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
3281 return -ENODEV;
3282
Jiri Slaby52fd5b22012-01-10 14:11:23 -03003283 stk7070pd_init(adap->dev);
Patrick Boettcher01373a52007-07-30 12:49:04 -03003284
Patrick Boettcher01373a52007-07-30 12:49:04 -03003285 msleep(10);
3286 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
3287
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003288 if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap, 2, 18,
Devin Heitmueller83c4fdf2009-01-21 01:55:45 -03003289 stk7070pd_dib7000p_config) != 0) {
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003290 err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n",
Devin Heitmueller83c4fdf2009-01-21 01:55:45 -03003291 __func__);
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003292 dvb_detach(&state->dib7000p_ops);
Devin Heitmueller83c4fdf2009-01-21 01:55:45 -03003293 return -ENODEV;
3294 }
Patrick Boettcher01373a52007-07-30 12:49:04 -03003295
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003296 adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap, 0x80, &stk7070pd_dib7000p_config[0]);
Michael Krufky77eed212011-09-06 09:31:57 -03003297 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Patrick Boettcher01373a52007-07-30 12:49:04 -03003298}
3299
3300static int stk7070pd_frontend_attach1(struct dvb_usb_adapter *adap)
3301{
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003302 struct dib0700_adapter_state *state = adap->priv;
3303
3304 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
3305 return -ENODEV;
3306
3307 adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap, 0x82, &stk7070pd_dib7000p_config[1]);
Michael Krufky77eed212011-09-06 09:31:57 -03003308 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Patrick Boettcher01373a52007-07-30 12:49:04 -03003309}
3310
Jiri Slabyd43272a2012-01-10 14:11:25 -03003311static int novatd_read_status_override(struct dvb_frontend *fe,
3312 fe_status_t *stat)
3313{
3314 struct dvb_usb_adapter *adap = fe->dvb->priv;
3315 struct dvb_usb_device *dev = adap->dev;
3316 struct dib0700_state *state = dev->priv;
3317 int ret;
3318
3319 ret = state->read_status(fe, stat);
3320
3321 if (!ret)
3322 dib0700_set_gpio(dev, adap->id == 0 ? GPIO1 : GPIO0, GPIO_OUT,
3323 !!(*stat & FE_HAS_LOCK));
3324
3325 return ret;
3326}
3327
3328static int novatd_sleep_override(struct dvb_frontend* fe)
3329{
3330 struct dvb_usb_adapter *adap = fe->dvb->priv;
3331 struct dvb_usb_device *dev = adap->dev;
3332 struct dib0700_state *state = dev->priv;
3333
3334 /* turn off LED */
3335 dib0700_set_gpio(dev, adap->id == 0 ? GPIO1 : GPIO0, GPIO_OUT, 0);
3336
3337 return state->sleep(fe);
3338}
3339
Jiri Slaby2b05b882012-01-10 14:11:24 -03003340/**
3341 * novatd_frontend_attach - Nova-TD specific attach
3342 *
3343 * Nova-TD has GPIO0, 1 and 2 for LEDs. So do not fiddle with them except for
3344 * information purposes.
3345 */
3346static int novatd_frontend_attach(struct dvb_usb_adapter *adap)
3347{
3348 struct dvb_usb_device *dev = adap->dev;
Jiri Slabyd43272a2012-01-10 14:11:25 -03003349 struct dib0700_state *st = dev->priv;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003350 struct dib0700_adapter_state *state = adap->priv;
3351
3352 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
3353 return -ENODEV;
Jiri Slaby2b05b882012-01-10 14:11:24 -03003354
3355 if (adap->id == 0) {
3356 stk7070pd_init(dev);
3357
3358 /* turn the power LED on, the other two off (just in case) */
3359 dib0700_set_gpio(dev, GPIO0, GPIO_OUT, 0);
3360 dib0700_set_gpio(dev, GPIO1, GPIO_OUT, 0);
3361 dib0700_set_gpio(dev, GPIO2, GPIO_OUT, 1);
3362
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003363 if (state->dib7000p_ops.i2c_enumeration(&dev->i2c_adap, 2, 18,
Jiri Slaby2b05b882012-01-10 14:11:24 -03003364 stk7070pd_dib7000p_config) != 0) {
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003365 err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n",
Jiri Slaby2b05b882012-01-10 14:11:24 -03003366 __func__);
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003367 dvb_detach(&state->dib7000p_ops);
Jiri Slaby2b05b882012-01-10 14:11:24 -03003368 return -ENODEV;
3369 }
3370 }
3371
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003372 adap->fe_adap[0].fe = state->dib7000p_ops.init(&dev->i2c_adap,
Jiri Slaby2b05b882012-01-10 14:11:24 -03003373 adap->id == 0 ? 0x80 : 0x82,
3374 &stk7070pd_dib7000p_config[adap->id]);
Jiri Slabyd43272a2012-01-10 14:11:25 -03003375
3376 if (adap->fe_adap[0].fe == NULL)
3377 return -ENODEV;
3378
3379 st->read_status = adap->fe_adap[0].fe->ops.read_status;
3380 adap->fe_adap[0].fe->ops.read_status = novatd_read_status_override;
3381 st->sleep = adap->fe_adap[0].fe->ops.sleep;
3382 adap->fe_adap[0].fe->ops.sleep = novatd_sleep_override;
3383
3384 return 0;
Jiri Slaby2b05b882012-01-10 14:11:24 -03003385}
3386
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03003387/* S5H1411 */
3388static struct s5h1411_config pinnacle_801e_config = {
3389 .output_mode = S5H1411_PARALLEL_OUTPUT,
3390 .gpio = S5H1411_GPIO_OFF,
3391 .mpeg_timing = S5H1411_MPEGTIMING_NONCONTINOUS_NONINVERTING_CLOCK,
3392 .qam_if = S5H1411_IF_44000,
3393 .vsb_if = S5H1411_IF_44000,
3394 .inversion = S5H1411_INVERSION_OFF,
3395 .status_mode = S5H1411_DEMODLOCKING
3396};
3397
3398/* Pinnacle PCTV HD Pro 801e GPIOs map:
3399 GPIO0 - currently unknown
3400 GPIO1 - xc5000 tuner reset
3401 GPIO2 - CX25843 sleep
3402 GPIO3 - currently unknown
3403 GPIO4 - currently unknown
3404 GPIO6 - currently unknown
3405 GPIO7 - currently unknown
3406 GPIO9 - currently unknown
3407 GPIO10 - CX25843 reset
3408 */
3409static int s5h1411_frontend_attach(struct dvb_usb_adapter *adap)
3410{
3411 struct dib0700_state *st = adap->dev->priv;
3412
3413 /* Make use of the new i2c functions from FW 1.20 */
3414 st->fw_use_new_i2c_api = 1;
3415
3416 /* The s5h1411 requires the dib0700 to not be in master mode */
3417 st->disable_streaming_master_mode = 1;
3418
3419 /* All msleep values taken from Windows USB trace */
3420 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 0);
3421 dib0700_set_gpio(adap->dev, GPIO3, GPIO_OUT, 0);
3422 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
3423 msleep(400);
3424 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
3425 msleep(60);
3426 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
3427 msleep(30);
3428 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
3429 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
3430 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
3431 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
3432 dib0700_set_gpio(adap->dev, GPIO2, GPIO_OUT, 0);
3433 msleep(30);
3434
3435 /* Put the CX25843 to sleep for now since we're in digital mode */
3436 dib0700_set_gpio(adap->dev, GPIO2, GPIO_OUT, 1);
3437
3438 /* GPIOs are initialized, do the attach */
Michael Krufky77eed212011-09-06 09:31:57 -03003439 adap->fe_adap[0].fe = dvb_attach(s5h1411_attach, &pinnacle_801e_config,
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03003440 &adap->dev->i2c_adap);
Michael Krufky77eed212011-09-06 09:31:57 -03003441 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03003442}
3443
Michael Krufky767f3b32008-09-25 09:47:07 -03003444static int dib0700_xc5000_tuner_callback(void *priv, int component,
3445 int command, int arg)
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03003446{
3447 struct dvb_usb_adapter *adap = priv;
3448
Devin Heitmueller79025a92008-10-06 12:07:48 -03003449 if (command == XC5000_TUNER_RESET) {
3450 /* Reset the tuner */
3451 dib0700_set_gpio(adap->dev, GPIO1, GPIO_OUT, 0);
Devin Heitmuellerf0f46332009-05-04 21:57:41 -03003452 msleep(10);
Devin Heitmueller79025a92008-10-06 12:07:48 -03003453 dib0700_set_gpio(adap->dev, GPIO1, GPIO_OUT, 1);
Devin Heitmuellerf0f46332009-05-04 21:57:41 -03003454 msleep(10);
Devin Heitmueller79025a92008-10-06 12:07:48 -03003455 } else {
3456 err("xc5000: unknown tuner callback command: %d\n", command);
3457 return -EINVAL;
3458 }
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03003459
3460 return 0;
3461}
3462
3463static struct xc5000_config s5h1411_xc5000_tunerconfig = {
3464 .i2c_address = 0x64,
3465 .if_khz = 5380,
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03003466};
3467
3468static int xc5000_tuner_attach(struct dvb_usb_adapter *adap)
3469{
Devin Heitmueller79025a92008-10-06 12:07:48 -03003470 /* FIXME: generalize & move to common area */
Michael Krufky77eed212011-09-06 09:31:57 -03003471 adap->fe_adap[0].fe->callback = dib0700_xc5000_tuner_callback;
Devin Heitmueller79025a92008-10-06 12:07:48 -03003472
Michael Krufky77eed212011-09-06 09:31:57 -03003473 return dvb_attach(xc5000_attach, adap->fe_adap[0].fe, &adap->dev->i2c_adap,
Michael Krufky767f3b32008-09-25 09:47:07 -03003474 &s5h1411_xc5000_tunerconfig)
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03003475 == NULL ? -ENODEV : 0;
3476}
3477
Davide Ferri8d009a02009-06-23 22:34:06 -03003478static int dib0700_xc4000_tuner_callback(void *priv, int component,
3479 int command, int arg)
3480{
3481 struct dvb_usb_adapter *adap = priv;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003482 struct dib0700_adapter_state *state = adap->priv;
Davide Ferri8d009a02009-06-23 22:34:06 -03003483
3484 if (command == XC4000_TUNER_RESET) {
3485 /* Reset the tuner */
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003486 state->dib7000p_ops.set_gpio(adap->fe_adap[0].fe, 8, 0, 0);
Davide Ferri8d009a02009-06-23 22:34:06 -03003487 msleep(10);
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003488 state->dib7000p_ops.set_gpio(adap->fe_adap[0].fe, 8, 0, 1);
Davide Ferri8d009a02009-06-23 22:34:06 -03003489 } else {
3490 err("xc4000: unknown tuner callback command: %d\n", command);
3491 return -EINVAL;
3492 }
3493
3494 return 0;
3495}
3496
Devin Heitmueller8583fc82009-07-28 01:16:05 -03003497static struct dibx000_agc_config stk7700p_7000p_xc4000_agc_config = {
3498 .band_caps = BAND_UHF | BAND_VHF,
3499 .setup = 0x64,
3500 .inv_gain = 0x02c8,
3501 .time_stabiliz = 0x15,
3502 .alpha_level = 0x00,
3503 .thlock = 0x76,
3504 .wbd_inv = 0x01,
3505 .wbd_ref = 0x0b33,
3506 .wbd_sel = 0x00,
3507 .wbd_alpha = 0x02,
3508 .agc1_max = 0x00,
3509 .agc1_min = 0x00,
3510 .agc2_max = 0x9b26,
3511 .agc2_min = 0x26ca,
3512 .agc1_pt1 = 0x00,
3513 .agc1_pt2 = 0x00,
3514 .agc1_pt3 = 0x00,
3515 .agc1_slope1 = 0x00,
3516 .agc1_slope2 = 0x00,
3517 .agc2_pt1 = 0x00,
3518 .agc2_pt2 = 0x80,
3519 .agc2_slope1 = 0x1d,
3520 .agc2_slope2 = 0x1d,
Devin Heitmueller2df12512009-12-27 17:44:31 -03003521 .alpha_mant = 0x11,
Devin Heitmueller8583fc82009-07-28 01:16:05 -03003522 .alpha_exp = 0x1b,
3523 .beta_mant = 0x17,
3524 .beta_exp = 0x33,
3525 .perform_agc_softsplit = 0x00,
3526};
3527
Devin Heitmuellerf1c78d32009-10-05 00:34:04 -03003528static struct dibx000_bandwidth_config stk7700p_xc4000_pll_config = {
Mauro Carvalho Chehab09628b22014-09-22 18:57:45 -03003529 .internal = 60000,
3530 .sampling = 30000,
3531 .pll_prediv = 1,
3532 .pll_ratio = 8,
3533 .pll_range = 3,
3534 .pll_reset = 1,
3535 .pll_bypass = 0,
3536 .enable_refdiv = 0,
3537 .bypclk_div = 0,
3538 .IO_CLK_en_core = 1,
3539 .ADClkSrc = 1,
3540 .modulo = 0,
3541 .sad_cfg = (3 << 14) | (1 << 12) | 524, /* sad_cfg: refsel, sel, freq_15k */
3542 .ifreq = 39370534,
3543 .timf = 20452225,
3544 .xtal_hz = 30000000
Devin Heitmuellerf1c78d32009-10-05 00:34:04 -03003545};
3546
Devin Heitmueller01f16262009-06-24 00:07:01 -03003547/* FIXME: none of these inputs are validated yet */
3548static struct dib7000p_config pctv_340e_config = {
Devin Heitmueller62956ce2009-12-27 18:58:11 -03003549 .output_mpeg2_in_188_bytes = 1,
Devin Heitmueller01f16262009-06-24 00:07:01 -03003550
3551 .agc_config_count = 1,
Devin Heitmueller8583fc82009-07-28 01:16:05 -03003552 .agc = &stk7700p_7000p_xc4000_agc_config,
Devin Heitmuellerf1c78d32009-10-05 00:34:04 -03003553 .bw = &stk7700p_xc4000_pll_config,
Devin Heitmueller01f16262009-06-24 00:07:01 -03003554
Devin Heitmueller01f16262009-06-24 00:07:01 -03003555 .gpio_dir = DIB7000M_GPIO_DEFAULT_DIRECTIONS,
3556 .gpio_val = DIB7000M_GPIO_DEFAULT_VALUES,
3557 .gpio_pwm_pos = DIB7000M_GPIO_DEFAULT_PWM_POS,
3558};
3559
3560/* PCTV 340e GPIOs map:
3561 dib0700:
3562 GPIO2 - CX25843 sleep
3563 GPIO3 - CS5340 reset
3564 GPIO5 - IRD
3565 GPIO6 - Power Supply
3566 GPIO8 - LNA (1=off 0=on)
3567 GPIO10 - CX25843 reset
3568 dib7000:
3569 GPIO8 - xc4000 reset
3570 */
3571static int pctv340e_frontend_attach(struct dvb_usb_adapter *adap)
3572{
3573 struct dib0700_state *st = adap->dev->priv;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003574 struct dib0700_adapter_state *state = adap->priv;
3575
3576 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
3577 return -ENODEV;
Devin Heitmueller01f16262009-06-24 00:07:01 -03003578
3579 /* Power Supply on */
3580 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
3581 msleep(50);
3582 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
3583 msleep(100); /* Allow power supply to settle before probing */
3584
3585 /* cx25843 reset */
3586 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
3587 msleep(1); /* cx25843 datasheet say 350us required */
3588 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
3589
3590 /* LNA off for now */
3591 dib0700_set_gpio(adap->dev, GPIO8, GPIO_OUT, 1);
3592
3593 /* Put the CX25843 to sleep for now since we're in digital mode */
3594 dib0700_set_gpio(adap->dev, GPIO2, GPIO_OUT, 1);
3595
3596 /* FIXME: not verified yet */
3597 dib0700_ctrl_clock(adap->dev, 72, 1);
3598
Devin Heitmueller2750d9c2009-07-20 00:42:33 -03003599 msleep(500);
3600
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003601 if (state->dib7000p_ops.dib7000pc_detection(&adap->dev->i2c_adap) == 0) {
Devin Heitmueller01f16262009-06-24 00:07:01 -03003602 /* Demodulator not found for some reason? */
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003603 dvb_detach(&state->dib7000p_ops);
Devin Heitmueller01f16262009-06-24 00:07:01 -03003604 return -ENODEV;
3605 }
3606
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003607 adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap, 0x12,
Devin Heitmueller01f16262009-06-24 00:07:01 -03003608 &pctv_340e_config);
3609 st->is_dib7000pc = 1;
3610
Michael Krufky77eed212011-09-06 09:31:57 -03003611 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Devin Heitmueller01f16262009-06-24 00:07:01 -03003612}
3613
Devin Heitmueller8583fc82009-07-28 01:16:05 -03003614static struct xc4000_config dib7000p_xc4000_tunerconfig = {
istvan_v@mailbox.hu8edeb6e2011-06-06 13:03:44 -03003615 .i2c_address = 0x61,
3616 .default_pm = 1,
3617 .dvb_amplitude = 0,
3618 .set_smoothedcvbs = 0,
3619 .if_khz = 5400
Davide Ferri8d009a02009-06-23 22:34:06 -03003620};
3621
3622static int xc4000_tuner_attach(struct dvb_usb_adapter *adap)
3623{
Devin Heitmueller59d0c372009-06-29 21:11:02 -03003624 struct i2c_adapter *tun_i2c;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003625 struct dib0700_adapter_state *state = adap->priv;
Devin Heitmueller59d0c372009-06-29 21:11:02 -03003626
3627 /* The xc4000 is not on the main i2c bus */
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003628 tun_i2c = state->dib7000p_ops.get_i2c_master(adap->fe_adap[0].fe,
Devin Heitmueller59d0c372009-06-29 21:11:02 -03003629 DIBX000_I2C_INTERFACE_TUNER, 1);
3630 if (tun_i2c == NULL) {
Mauro Carvalho Chehab941830c2011-06-06 16:51:11 -03003631 printk(KERN_ERR "Could not reach tuner i2c bus\n");
Devin Heitmueller59d0c372009-06-29 21:11:02 -03003632 return 0;
3633 }
3634
3635 /* Setup the reset callback */
Michael Krufky77eed212011-09-06 09:31:57 -03003636 adap->fe_adap[0].fe->callback = dib0700_xc4000_tuner_callback;
Davide Ferri8d009a02009-06-23 22:34:06 -03003637
Michael Krufky77eed212011-09-06 09:31:57 -03003638 return dvb_attach(xc4000_attach, adap->fe_adap[0].fe, tun_i2c,
Devin Heitmueller8583fc82009-07-28 01:16:05 -03003639 &dib7000p_xc4000_tunerconfig)
Davide Ferri8d009a02009-06-23 22:34:06 -03003640 == NULL ? -ENODEV : 0;
3641}
3642
Michael Krufkyce904bc2009-01-19 01:12:55 -03003643static struct lgdt3305_config hcw_lgdt3305_config = {
3644 .i2c_addr = 0x0e,
3645 .mpeg_mode = LGDT3305_MPEG_PARALLEL,
3646 .tpclk_edge = LGDT3305_TPCLK_FALLING_EDGE,
3647 .tpvalid_polarity = LGDT3305_TP_VALID_LOW,
3648 .deny_i2c_rptr = 0,
3649 .spectral_inversion = 1,
3650 .qam_if_khz = 6000,
3651 .vsb_if_khz = 6000,
3652 .usref_8vsb = 0x0500,
3653};
3654
3655static struct mxl5007t_config hcw_mxl5007t_config = {
3656 .xtal_freq_hz = MxL_XTAL_25_MHZ,
3657 .if_freq_hz = MxL_IF_6_MHZ,
3658 .invert_if = 1,
3659};
3660
3661/* TIGER-ATSC map:
3662 GPIO0 - LNA_CTR (H: LNA power enabled, L: LNA power disabled)
3663 GPIO1 - ANT_SEL (H: VPA, L: MCX)
3664 GPIO4 - SCL2
3665 GPIO6 - EN_TUNER
3666 GPIO7 - SDA2
3667 GPIO10 - DEM_RST
3668
3669 MXL is behind LG's i2c repeater. LG is on SCL2/SDA2 gpios on the DIB
3670 */
3671static int lgdt3305_frontend_attach(struct dvb_usb_adapter *adap)
3672{
3673 struct dib0700_state *st = adap->dev->priv;
3674
3675 /* Make use of the new i2c functions from FW 1.20 */
3676 st->fw_use_new_i2c_api = 1;
3677
3678 st->disable_streaming_master_mode = 1;
3679
3680 /* fe power enable */
3681 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
3682 msleep(30);
3683 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
3684 msleep(30);
3685
3686 /* demod reset */
3687 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
3688 msleep(30);
3689 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
3690 msleep(30);
3691 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
3692 msleep(30);
3693
Michael Krufky77eed212011-09-06 09:31:57 -03003694 adap->fe_adap[0].fe = dvb_attach(lgdt3305_attach,
Michael Krufkyce904bc2009-01-19 01:12:55 -03003695 &hcw_lgdt3305_config,
3696 &adap->dev->i2c_adap);
3697
Michael Krufky77eed212011-09-06 09:31:57 -03003698 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Michael Krufkyce904bc2009-01-19 01:12:55 -03003699}
3700
3701static int mxl5007t_tuner_attach(struct dvb_usb_adapter *adap)
3702{
Michael Krufky77eed212011-09-06 09:31:57 -03003703 return dvb_attach(mxl5007t_attach, adap->fe_adap[0].fe,
Michael Krufkyce904bc2009-01-19 01:12:55 -03003704 &adap->dev->i2c_adap, 0x60,
3705 &hcw_mxl5007t_config) == NULL ? -ENODEV : 0;
3706}
3707
3708
Patrick Boettcher01373a52007-07-30 12:49:04 -03003709/* DVB-USB and USB stuff follows */
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003710struct usb_device_id dib0700_usb_id_table[] = {
Patrick Boettcher01373a52007-07-30 12:49:04 -03003711/* 0 */ { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7700P) },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03003712 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7700P_PC) },
3713 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_500) },
3714 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_500_2) },
3715 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_STICK) },
Patrick Boettcher01373a52007-07-30 12:49:04 -03003716/* 5 */ { USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR) },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03003717 { USB_DEVICE(USB_VID_COMPRO, USB_PID_COMPRO_VIDEOMATE_U500) },
3718 { USB_DEVICE(USB_VID_UNIWILL, USB_PID_UNIWILL_STK7700P) },
3719 { USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV_DONGLE_STK7700P) },
3720 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_STICK_2) },
Patrick Boettcher01373a52007-07-30 12:49:04 -03003721/* 10 */{ USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR_2) },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03003722 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV2000E) },
3723 { USB_DEVICE(USB_VID_TERRATEC,
3724 USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY) },
3725 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_TD_STICK) },
3726 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7700D) },
Patrick Boettcher01373a52007-07-30 12:49:04 -03003727/* 15 */{ USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7070P) },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03003728 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV_DVB_T_FLASH) },
3729 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7070PD) },
3730 { USB_DEVICE(USB_VID_PINNACLE,
3731 USB_PID_PINNACLE_PCTV_DUAL_DIVERSITY_DVB_T) },
3732 { USB_DEVICE(USB_VID_COMPRO, USB_PID_COMPRO_VIDEOMATE_U500_PC) },
Joachim Steigerfa3b8772007-10-08 20:08:46 -03003733/* 20 */{ USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_EXPRESS) },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03003734 { USB_DEVICE(USB_VID_GIGABYTE, USB_PID_GIGABYTE_U7000) },
3735 { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC, USB_PID_ARTEC_T14BR) },
3736 { USB_DEVICE(USB_VID_ASUS, USB_PID_ASUS_U3000) },
3737 { USB_DEVICE(USB_VID_ASUS, USB_PID_ASUS_U3100) },
3738/* 25 */{ USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_STICK_3) },
3739 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_MYTV_T) },
3740 { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_HT_USB_XE) },
3741 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_EXPRESSCARD_320CX) },
3742 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV72E) },
3743/* 30 */{ USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV73E) },
3744 { USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_EC372S) },
3745 { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_HT_EXPRESS) },
Alexander Simondc888072008-03-29 21:37:54 -03003746 { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_XXS) },
Darryl Green5da4e2c2008-03-29 21:47:43 -03003747 { USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV_DONGLE_STK7700P_2) },
Michael Krufkyaf2a8872008-09-03 17:12:24 -03003748/* 35 */{ USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_TD_STICK_52009) },
Michael Krufky9a0c04a2008-09-03 17:12:24 -03003749 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_500_3) },
Finn Thain17a370b2008-09-06 13:42:47 -03003750 { USB_DEVICE(USB_VID_GIGABYTE, USB_PID_GIGABYTE_U8000) },
Daniel Oliveira Nascimento8751aaa2008-09-07 12:39:44 -03003751 { USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_STK7700PH) },
Albert Comerma57697432008-09-07 12:43:33 -03003752 { USB_DEVICE(USB_VID_ASUS, USB_PID_ASUS_U3000H) },
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03003753/* 40 */{ USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV801E) },
Devin Heitmuellerd2fc3bf2008-09-25 06:22:23 -03003754 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV801E_SE) },
Yusuf Altinbb1b0822009-01-08 07:58:45 -03003755 { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_EXPRESS) },
Nicolas Fournierdb4b2d12009-01-13 07:15:25 -03003756 { USB_DEVICE(USB_VID_TERRATEC,
3757 USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY_2) },
sebastian.blanes@gmail.com0a6e1ed2009-02-24 14:51:43 -03003758 { USB_DEVICE(USB_VID_SONY, USB_PID_SONY_PLAYTV) },
Pascal Terjan9abb6e62009-02-26 10:31:41 -03003759/* 45 */{ USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_PD378S) },
Michael Krufkyce904bc2009-01-19 01:12:55 -03003760 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_TIGER_ATSC) },
3761 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_TIGER_ATSC_B210) },
Xoan Loureiro16ba1ee2009-03-29 08:43:36 -03003762 { USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_MC770) },
Klaus Flittner919a5482009-03-29 09:12:06 -03003763 { USB_DEVICE(USB_VID_ELGATO, USB_PID_ELGATO_EYETV_DTT) },
Armin Schenker513846e2009-04-20 11:57:49 -03003764/* 50 */{ USB_DEVICE(USB_VID_ELGATO, USB_PID_ELGATO_EYETV_DTT_Dlx) },
tomas petrf0f4ae72009-05-20 05:28:05 -03003765 { USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV_DONGLE_H) },
Patrick Boettchera9b8fe32009-05-20 05:35:02 -03003766 { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_T3) },
3767 { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_T5) },
Pete Hildebrandtc53d83c2009-08-05 11:46:38 -03003768 { USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_STK7700D) },
Olivier Grenie74b76f22009-09-02 08:19:19 -03003769/* 55 */{ USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_STK7700D_2) },
3770 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV73A) },
Patrick Boettchere4147532009-11-30 13:52:57 -03003771 { USB_DEVICE(USB_VID_PCTV, USB_PID_PINNACLE_PCTV73ESE) },
3772 { USB_DEVICE(USB_VID_PCTV, USB_PID_PINNACLE_PCTV282E) },
Olivier Grenied300bd62009-09-15 06:55:35 -03003773 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7770P) },
Patrick Boettcherdb481382009-09-15 07:16:51 -03003774/* 60 */{ USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_XXS_2) },
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03003775 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK807XPVR) },
3776 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK807XP) },
Mauro Carvalho Chehab3bfb3172010-09-03 10:50:24 -03003777 { USB_DEVICE_VER(USB_VID_PIXELVIEW, USB_PID_PIXELVIEW_SBTVD, 0x000, 0x3f00) },
S?rgio Fortier8a378e82009-09-28 04:19:21 -03003778 { USB_DEVICE(USB_VID_EVOLUTEPC, USB_PID_TVWAY_PLUS) },
Patrick Boettcher20232c42009-12-01 12:08:56 -03003779/* 65 */{ USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV73ESE) },
Patrick Boettchere4147532009-11-30 13:52:57 -03003780 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV282E) },
Olivier Grenie03245a52009-12-04 13:27:57 -03003781 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK8096GP) },
Michael Müller84e2f032010-04-26 22:18:57 -03003782 { USB_DEVICE(USB_VID_ELGATO, USB_PID_ELGATO_EYETV_DIVERSITY) },
Olivier Greniebe9bae12011-01-04 05:42:19 -03003783 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_NIM9090M) },
3784/* 70 */{ USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_NIM8096MD) },
3785 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_NIM9090MD) },
3786 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_NIM7090) },
3787 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_TFE7090PVR) },
Lukas Max Fisch498e6772011-02-08 16:51:45 -03003788 { USB_DEVICE(USB_VID_TECHNISAT, USB_PID_TECHNISAT_AIRSTAR_TELESTICK_2) },
Stéphane Elmalehd1402302011-05-21 07:33:38 -03003789/* 75 */{ USB_DEVICE(USB_VID_MEDION, USB_PID_CREATIX_CTX1921) },
Davide Ferri8d009a02009-06-23 22:34:06 -03003790 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV340E) },
Devin Heitmueller33fb1682009-06-23 22:48:02 -03003791 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV340E_SE) },
Olivier Grenief45f5132012-12-31 09:47:10 -03003792 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_TFE7790P) },
3793 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_TFE8096P) },
3794/* 80 */{ USB_DEVICE(USB_VID_ELGATO, USB_PID_ELGATO_EYETV_DTT_2) },
Michael Krufkyc859e6e2013-06-30 12:43:58 -03003795 { USB_DEVICE(USB_VID_PCTV, USB_PID_PCTV_2002E) },
3796 { USB_DEVICE(USB_VID_PCTV, USB_PID_PCTV_2002E_SE) },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03003797 { 0 } /* Terminating entry */
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003798};
3799MODULE_DEVICE_TABLE(usb, dib0700_usb_id_table);
3800
3801#define DIB0700_DEFAULT_DEVICE_PROPERTIES \
3802 .caps = DVB_USB_IS_AN_I2C_ADAPTER, \
3803 .usb_ctrl = DEVICE_SPECIFIC, \
Devin Heitmuellerbdc203e2008-09-06 13:45:27 -03003804 .firmware = "dvb-usb-dib0700-1.20.fw", \
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003805 .download_firmware = dib0700_download_firmware, \
Patrick Boettcher6958eff2006-09-19 12:51:40 -03003806 .no_reconnect = 1, \
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003807 .size_of_priv = sizeof(struct dib0700_state), \
Patrick Boettcher6958eff2006-09-19 12:51:40 -03003808 .i2c_algo = &dib0700_i2c_algo, \
3809 .identify_state = dib0700_identify_state
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003810
3811#define DIB0700_DEFAULT_STREAMING_CONFIG(ep) \
3812 .streaming_ctrl = dib0700_streaming_ctrl, \
3813 .stream = { \
3814 .type = USB_BULK, \
3815 .count = 4, \
3816 .endpoint = ep, \
3817 .u = { \
3818 .bulk = { \
3819 .buffersize = 39480, \
3820 } \
3821 } \
3822 }
3823
3824struct dvb_usb_device_properties dib0700_devices[] = {
3825 {
3826 DIB0700_DEFAULT_DEVICE_PROPERTIES,
3827
3828 .num_adapters = 1,
3829 .adapter = {
3830 {
Michael Krufky77eed212011-09-06 09:31:57 -03003831 .num_frontends = 1,
3832 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03003833 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
3834 .pid_filter_count = 32,
Olivier Greniee192a7c2011-01-14 13:58:59 -03003835 .pid_filter = stk7700p_pid_filter,
3836 .pid_filter_ctrl = stk7700p_pid_filter_ctrl,
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003837 .frontend_attach = stk7700p_frontend_attach,
3838 .tuner_attach = stk7700p_tuner_attach,
3839
3840 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03003841 }},
James Harper9e334c72014-06-08 21:24:20 -03003842 .size_of_priv = sizeof(struct dib0700_adapter_state),
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003843 },
3844 },
3845
dominik67053a42007-11-10 19:23:31 -03003846 .num_device_descs = 8,
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003847 .devices = {
3848 { "DiBcom STK7700P reference design",
Tomi Koivulahti49a13762006-10-19 07:27:19 -03003849 { &dib0700_usb_id_table[0], &dib0700_usb_id_table[1] },
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003850 { NULL },
3851 },
3852 { "Hauppauge Nova-T Stick",
Stefan Trabyf9aeba42006-11-12 13:02:51 -03003853 { &dib0700_usb_id_table[4], &dib0700_usb_id_table[9], NULL },
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003854 { NULL },
3855 },
Tomi Koivulahti49a13762006-10-19 07:27:19 -03003856 { "AVerMedia AVerTV DVB-T Volar",
Jose Carlos Garcia Sogoced8fec2006-11-14 05:01:47 -03003857 { &dib0700_usb_id_table[5], &dib0700_usb_id_table[10] },
Tomi Koivulahti49a13762006-10-19 07:27:19 -03003858 { NULL },
3859 },
3860 { "Compro Videomate U500",
Patrick Boettcher1f8ca4b2007-07-30 14:24:37 -03003861 { &dib0700_usb_id_table[6], &dib0700_usb_id_table[19] },
Tomi Koivulahti49a13762006-10-19 07:27:19 -03003862 { NULL },
Henning Schroeer0ce215e2006-10-19 07:58:22 -03003863 },
3864 { "Uniwill STK7700P based (Hama and others)",
3865 { &dib0700_usb_id_table[7], NULL },
3866 { NULL },
Michael Krufky8637a872006-11-08 16:47:32 -03003867 },
3868 { "Leadtek Winfast DTV Dongle (STK7700P based)",
Patrick Boettcher1e13c8f2009-09-19 05:24:40 -03003869 { &dib0700_usb_id_table[8], &dib0700_usb_id_table[34] },
Michael Krufky8637a872006-11-08 16:47:32 -03003870 { NULL },
Joachim Steigerfa3b8772007-10-08 20:08:46 -03003871 },
3872 { "AVerMedia AVerTV DVB-T Express",
3873 { &dib0700_usb_id_table[20] },
3874 { NULL },
dominik67053a42007-11-10 19:23:31 -03003875 },
dominik67053a42007-11-10 19:23:31 -03003876 { "Gigabyte U7000",
3877 { &dib0700_usb_id_table[21], NULL },
3878 { NULL },
Tomi Koivulahti49a13762006-10-19 07:27:19 -03003879 }
Darren Saltb1139e32007-08-18 18:05:31 -03003880 },
3881
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03003882 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03003883 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03003884 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03003885 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03003886 .allowed_protos = RC_BIT_RC5 |
3887 RC_BIT_RC6_MCE |
3888 RC_BIT_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03003889 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03003890 },
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003891 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
3892
3893 .num_adapters = 2,
3894 .adapter = {
3895 {
Michael Krufky77eed212011-09-06 09:31:57 -03003896 .num_frontends = 1,
3897 .fe = {{
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003898 .frontend_attach = bristol_frontend_attach,
3899 .tuner_attach = bristol_tuner_attach,
3900
3901 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03003902 }},
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003903 }, {
Michael Krufky77eed212011-09-06 09:31:57 -03003904 .num_frontends = 1,
3905 .fe = {{
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003906 .frontend_attach = bristol_frontend_attach,
3907 .tuner_attach = bristol_tuner_attach,
3908
3909 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
Michael Krufky77eed212011-09-06 09:31:57 -03003910 }},
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003911 }
3912 },
3913
3914 .num_device_descs = 1,
3915 .devices = {
3916 { "Hauppauge Nova-T 500 Dual DVB-T",
Tomi Koivulahti49a13762006-10-19 07:27:19 -03003917 { &dib0700_usb_id_table[2], &dib0700_usb_id_table[3], NULL },
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003918 { NULL },
3919 },
Janne Grunau82f3d552007-07-30 13:50:28 -03003920 },
3921
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03003922 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03003923 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03003924 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03003925 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03003926 .allowed_protos = RC_BIT_RC5 |
3927 RC_BIT_RC6_MCE |
3928 RC_BIT_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03003929 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03003930 },
Olivier DANET54d75eb2007-07-25 14:42:54 -03003931 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
3932
3933 .num_adapters = 2,
3934 .adapter = {
3935 {
Michael Krufky77eed212011-09-06 09:31:57 -03003936 .num_frontends = 1,
3937 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03003938 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
3939 .pid_filter_count = 32,
3940 .pid_filter = stk70x0p_pid_filter,
3941 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
Olivier DANET54d75eb2007-07-25 14:42:54 -03003942 .frontend_attach = stk7700d_frontend_attach,
3943 .tuner_attach = stk7700d_tuner_attach,
3944
3945 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03003946 }},
Olivier DANET54d75eb2007-07-25 14:42:54 -03003947 }, {
Michael Krufky77eed212011-09-06 09:31:57 -03003948 .num_frontends = 1,
3949 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03003950 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
3951 .pid_filter_count = 32,
3952 .pid_filter = stk70x0p_pid_filter,
3953 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
Olivier DANET54d75eb2007-07-25 14:42:54 -03003954 .frontend_attach = stk7700d_frontend_attach,
3955 .tuner_attach = stk7700d_tuner_attach,
3956
3957 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
Michael Krufky77eed212011-09-06 09:31:57 -03003958 }},
Olivier DANET54d75eb2007-07-25 14:42:54 -03003959 }
3960 },
3961
James A Webb200e8612009-08-04 02:38:05 -03003962 .num_device_descs = 5,
Olivier DANET54d75eb2007-07-25 14:42:54 -03003963 .devices = {
3964 { "Pinnacle PCTV 2000e",
3965 { &dib0700_usb_id_table[11], NULL },
3966 { NULL },
3967 },
3968 { "Terratec Cinergy DT XS Diversity",
3969 { &dib0700_usb_id_table[12], NULL },
3970 { NULL },
3971 },
Darren Saltfaebb912007-08-18 18:04:00 -03003972 { "Hauppauge Nova-TD Stick/Elgato Eye-TV Diversity",
Olivier DANET54d75eb2007-07-25 14:42:54 -03003973 { &dib0700_usb_id_table[13], NULL },
3974 { NULL },
3975 },
Patrick Boettcher01373a52007-07-30 12:49:04 -03003976 { "DiBcom STK7700D reference design",
Patrick Boettcherb6884a12007-07-27 10:08:51 -03003977 { &dib0700_usb_id_table[14], NULL },
3978 { NULL },
Yusuf Altinbb1b0822009-01-08 07:58:45 -03003979 },
James A Webb200e8612009-08-04 02:38:05 -03003980 { "YUAN High-Tech DiBcom STK7700D",
3981 { &dib0700_usb_id_table[55], NULL },
3982 { NULL },
3983 },
Yusuf Altinbb1b0822009-01-08 07:58:45 -03003984
Olivier DANET54d75eb2007-07-25 14:42:54 -03003985 },
Janne Grunau82f3d552007-07-30 13:50:28 -03003986
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03003987 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03003988 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03003989 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03003990 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03003991 .allowed_protos = RC_BIT_RC5 |
3992 RC_BIT_RC6_MCE |
3993 RC_BIT_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03003994 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03003995 },
Patrick Boettcher01373a52007-07-30 12:49:04 -03003996 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
3997
3998 .num_adapters = 1,
3999 .adapter = {
4000 {
Michael Krufky77eed212011-09-06 09:31:57 -03004001 .num_frontends = 1,
4002 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03004003 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4004 .pid_filter_count = 32,
4005 .pid_filter = stk70x0p_pid_filter,
4006 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
Daniel Gimpelevich132c3182008-01-25 06:02:42 -03004007 .frontend_attach = stk7700P2_frontend_attach,
4008 .tuner_attach = stk7700d_tuner_attach,
4009
4010 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004011 }},
Daniel Gimpelevich132c3182008-01-25 06:02:42 -03004012 },
4013 },
4014
Yusuf Altinbb1b0822009-01-08 07:58:45 -03004015 .num_device_descs = 3,
Daniel Gimpelevich132c3182008-01-25 06:02:42 -03004016 .devices = {
4017 { "ASUS My Cinema U3000 Mini DVBT Tuner",
4018 { &dib0700_usb_id_table[23], NULL },
4019 { NULL },
4020 },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03004021 { "Yuan EC372S",
4022 { &dib0700_usb_id_table[31], NULL },
4023 { NULL },
Yusuf Altinbb1b0822009-01-08 07:58:45 -03004024 },
4025 { "Terratec Cinergy T Express",
4026 { &dib0700_usb_id_table[42], NULL },
4027 { NULL },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03004028 }
Chris Rankin48aa7392008-09-25 06:52:24 -03004029 },
4030
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004031 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004032 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004033 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004034 .module_name = "dib0700",
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03004035 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004036 .allowed_protos = RC_BIT_RC5 |
4037 RC_BIT_RC6_MCE |
4038 RC_BIT_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03004039 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004040 },
Daniel Gimpelevich132c3182008-01-25 06:02:42 -03004041 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4042
4043 .num_adapters = 1,
4044 .adapter = {
4045 {
Michael Krufky77eed212011-09-06 09:31:57 -03004046 .num_frontends = 1,
4047 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03004048 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4049 .pid_filter_count = 32,
4050 .pid_filter = stk70x0p_pid_filter,
4051 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
Patrick Boettcher01373a52007-07-30 12:49:04 -03004052 .frontend_attach = stk7070p_frontend_attach,
4053 .tuner_attach = dib7070p_tuner_attach,
4054
4055 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004056 }},
Patrick Boettcher01373a52007-07-30 12:49:04 -03004057 .size_of_priv = sizeof(struct dib0700_adapter_state),
4058 },
4059 },
4060
Gianluca Gennari0bc9d392012-04-14 09:14:07 -03004061 .num_device_descs = 12,
Patrick Boettcher01373a52007-07-30 12:49:04 -03004062 .devices = {
4063 { "DiBcom STK7070P reference design",
4064 { &dib0700_usb_id_table[15], NULL },
4065 { NULL },
4066 },
4067 { "Pinnacle PCTV DVB-T Flash Stick",
4068 { &dib0700_usb_id_table[16], NULL },
4069 { NULL },
4070 },
Yousef Lamlum7999a812008-01-25 05:51:48 -03004071 { "Artec T14BR DVB-T",
4072 { &dib0700_usb_id_table[22], NULL },
4073 { NULL },
Daniel Gimpelevich132c3182008-01-25 06:02:42 -03004074 },
4075 { "ASUS My Cinema U3100 Mini DVBT Tuner",
4076 { &dib0700_usb_id_table[24], NULL },
4077 { NULL },
4078 },
Tim Taubertc7637b12008-01-25 06:16:36 -03004079 { "Hauppauge Nova-T Stick",
4080 { &dib0700_usb_id_table[25], NULL },
4081 { NULL },
4082 },
Darren Salt13b83b52008-01-25 06:20:02 -03004083 { "Hauppauge Nova-T MyTV.t",
4084 { &dib0700_usb_id_table[26], NULL },
4085 { NULL },
4086 },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03004087 { "Pinnacle PCTV 72e",
4088 { &dib0700_usb_id_table[29], NULL },
4089 { NULL },
4090 },
4091 { "Pinnacle PCTV 73e",
4092 { &dib0700_usb_id_table[30], NULL },
4093 { NULL },
4094 },
Klaus Flittner919a5482009-03-29 09:12:06 -03004095 { "Elgato EyeTV DTT",
4096 { &dib0700_usb_id_table[49], NULL },
4097 { NULL },
4098 },
Pascal Terjan9abb6e62009-02-26 10:31:41 -03004099 { "Yuan PD378S",
4100 { &dib0700_usb_id_table[45], NULL },
4101 { NULL },
4102 },
Armin Schenker513846e2009-04-20 11:57:49 -03004103 { "Elgato EyeTV Dtt Dlx PD378S",
4104 { &dib0700_usb_id_table[50], NULL },
4105 { NULL },
4106 },
Gianluca Gennari0bc9d392012-04-14 09:14:07 -03004107 { "Elgato EyeTV DTT rev. 2",
Olivier Grenief45f5132012-12-31 09:47:10 -03004108 { &dib0700_usb_id_table[80], NULL },
Gianluca Gennari0bc9d392012-04-14 09:14:07 -03004109 { NULL },
4110 },
Tim Taubertc7637b12008-01-25 06:16:36 -03004111 },
4112
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004113 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004114 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004115 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004116 .module_name = "dib0700",
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03004117 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004118 .allowed_protos = RC_BIT_RC5 |
4119 RC_BIT_RC6_MCE |
4120 RC_BIT_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03004121 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004122 },
Patrick Boettcher01373a52007-07-30 12:49:04 -03004123 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4124
Olivier Grenie74b76f22009-09-02 08:19:19 -03004125 .num_adapters = 1,
4126 .adapter = {
4127 {
Michael Krufky77eed212011-09-06 09:31:57 -03004128 .num_frontends = 1,
4129 .fe = {{
Mauro Carvalho Chehab648732f2009-11-04 12:11:43 -02004130 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4131 .pid_filter_count = 32,
4132 .pid_filter = stk70x0p_pid_filter,
4133 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
Olivier Grenie74b76f22009-09-02 08:19:19 -03004134 .frontend_attach = stk7070p_frontend_attach,
4135 .tuner_attach = dib7070p_tuner_attach,
4136
4137 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004138 }},
Olivier Grenie74b76f22009-09-02 08:19:19 -03004139 .size_of_priv = sizeof(struct dib0700_adapter_state),
4140 },
4141 },
4142
Patrick Boettcher20232c42009-12-01 12:08:56 -03004143 .num_device_descs = 3,
Olivier Grenie74b76f22009-09-02 08:19:19 -03004144 .devices = {
4145 { "Pinnacle PCTV 73A",
4146 { &dib0700_usb_id_table[56], NULL },
4147 { NULL },
4148 },
4149 { "Pinnacle PCTV 73e SE",
Patrick Boettcher20232c42009-12-01 12:08:56 -03004150 { &dib0700_usb_id_table[57], &dib0700_usb_id_table[65], NULL },
Olivier Grenie74b76f22009-09-02 08:19:19 -03004151 { NULL },
4152 },
4153 { "Pinnacle PCTV 282e",
Patrick Boettcher20232c42009-12-01 12:08:56 -03004154 { &dib0700_usb_id_table[58], &dib0700_usb_id_table[66], NULL },
Olivier Grenie74b76f22009-09-02 08:19:19 -03004155 { NULL },
4156 },
4157 },
4158
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004159 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004160 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004161 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004162 .module_name = "dib0700",
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03004163 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004164 .allowed_protos = RC_BIT_RC5 |
4165 RC_BIT_RC6_MCE |
4166 RC_BIT_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03004167 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004168 },
Olivier Grenie74b76f22009-09-02 08:19:19 -03004169 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4170
Patrick Boettcher01373a52007-07-30 12:49:04 -03004171 .num_adapters = 2,
4172 .adapter = {
4173 {
Michael Krufky77eed212011-09-06 09:31:57 -03004174 .num_frontends = 1,
4175 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03004176 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4177 .pid_filter_count = 32,
4178 .pid_filter = stk70x0p_pid_filter,
4179 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
Jiri Slaby2b05b882012-01-10 14:11:24 -03004180 .frontend_attach = novatd_frontend_attach,
Patrick Boettcher01373a52007-07-30 12:49:04 -03004181 .tuner_attach = dib7070p_tuner_attach,
4182
4183 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004184 }},
Patrick Boettcher01373a52007-07-30 12:49:04 -03004185 .size_of_priv = sizeof(struct dib0700_adapter_state),
4186 }, {
Michael Krufky77eed212011-09-06 09:31:57 -03004187 .num_frontends = 1,
4188 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03004189 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4190 .pid_filter_count = 32,
4191 .pid_filter = stk70x0p_pid_filter,
4192 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
Jiri Slaby2b05b882012-01-10 14:11:24 -03004193 .frontend_attach = novatd_frontend_attach,
Patrick Boettcher01373a52007-07-30 12:49:04 -03004194 .tuner_attach = dib7070p_tuner_attach,
4195
4196 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
Michael Krufky77eed212011-09-06 09:31:57 -03004197 }},
Patrick Boettcher01373a52007-07-30 12:49:04 -03004198 .size_of_priv = sizeof(struct dib0700_adapter_state),
4199 }
4200 },
4201
Michael Krufkyc859e6e2013-06-30 12:43:58 -03004202 .num_device_descs = 3,
Jiri Slaby9b6ba572012-01-10 14:11:22 -03004203 .devices = {
4204 { "Hauppauge Nova-TD Stick (52009)",
4205 { &dib0700_usb_id_table[35], NULL },
4206 { NULL },
4207 },
Michael Krufkyc859e6e2013-06-30 12:43:58 -03004208 { "PCTV 2002e",
4209 { &dib0700_usb_id_table[81], NULL },
4210 { NULL },
4211 },
4212 { "PCTV 2002e SE",
4213 { &dib0700_usb_id_table[82], NULL },
4214 { NULL },
4215 },
Jiri Slaby9b6ba572012-01-10 14:11:22 -03004216 },
4217
4218 .rc.core = {
4219 .rc_interval = DEFAULT_RC_INTERVAL,
4220 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4221 .module_name = "dib0700",
4222 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004223 .allowed_protos = RC_BIT_RC5 |
4224 RC_BIT_RC6_MCE |
4225 RC_BIT_NEC,
Jiri Slaby9b6ba572012-01-10 14:11:22 -03004226 .change_protocol = dib0700_change_protocol,
4227 },
4228 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4229
4230 .num_adapters = 2,
4231 .adapter = {
4232 {
4233 .num_frontends = 1,
4234 .fe = {{
4235 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4236 .pid_filter_count = 32,
4237 .pid_filter = stk70x0p_pid_filter,
4238 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
4239 .frontend_attach = stk7070pd_frontend_attach0,
4240 .tuner_attach = dib7070p_tuner_attach,
4241
4242 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
4243 }},
4244 .size_of_priv = sizeof(struct dib0700_adapter_state),
4245 }, {
4246 .num_frontends = 1,
4247 .fe = {{
4248 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4249 .pid_filter_count = 32,
4250 .pid_filter = stk70x0p_pid_filter,
4251 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
4252 .frontend_attach = stk7070pd_frontend_attach1,
4253 .tuner_attach = dib7070p_tuner_attach,
4254
4255 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
4256 }},
4257 .size_of_priv = sizeof(struct dib0700_adapter_state),
4258 }
4259 },
4260
4261 .num_device_descs = 5,
Patrick Boettcher01373a52007-07-30 12:49:04 -03004262 .devices = {
4263 { "DiBcom STK7070PD reference design",
4264 { &dib0700_usb_id_table[17], NULL },
4265 { NULL },
4266 },
4267 { "Pinnacle PCTV Dual DVB-T Diversity Stick",
4268 { &dib0700_usb_id_table[18], NULL },
4269 { NULL },
Michael Krufkyd01eb2d2008-07-03 23:43:36 -03004270 },
Michael Krufky9a0c04a2008-09-03 17:12:24 -03004271 { "Hauppauge Nova-TD-500 (84xxx)",
4272 { &dib0700_usb_id_table[36], NULL },
4273 { NULL },
Nicolas Fournierdb4b2d12009-01-13 07:15:25 -03004274 },
Patrick Boettchera9b8fe32009-05-20 05:35:02 -03004275 { "Terratec Cinergy DT USB XS Diversity/ T5",
4276 { &dib0700_usb_id_table[43],
4277 &dib0700_usb_id_table[53], NULL},
Nicolas Fournierdb4b2d12009-01-13 07:15:25 -03004278 { NULL },
sebastian.blanes@gmail.com0a6e1ed2009-02-24 14:51:43 -03004279 },
4280 { "Sony PlayTV",
4281 { &dib0700_usb_id_table[44], NULL },
4282 { NULL },
Michael Müller84e2f032010-04-26 22:18:57 -03004283 },
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004284 },
4285
4286 .rc.core = {
4287 .rc_interval = DEFAULT_RC_INTERVAL,
4288 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4289 .module_name = "dib0700",
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03004290 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004291 .allowed_protos = RC_BIT_RC5 |
4292 RC_BIT_RC6_MCE |
4293 RC_BIT_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03004294 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004295 },
4296 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4297
4298 .num_adapters = 2,
4299 .adapter = {
4300 {
Michael Krufky77eed212011-09-06 09:31:57 -03004301 .num_frontends = 1,
4302 .fe = {{
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004303 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4304 .pid_filter_count = 32,
4305 .pid_filter = stk70x0p_pid_filter,
4306 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
4307 .frontend_attach = stk7070pd_frontend_attach0,
4308 .tuner_attach = dib7070p_tuner_attach,
4309
4310 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004311 }},
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004312 .size_of_priv = sizeof(struct dib0700_adapter_state),
4313 }, {
Michael Krufky77eed212011-09-06 09:31:57 -03004314 .num_frontends = 1,
4315 .fe = {{
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004316 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4317 .pid_filter_count = 32,
4318 .pid_filter = stk70x0p_pid_filter,
4319 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
4320 .frontend_attach = stk7070pd_frontend_attach1,
4321 .tuner_attach = dib7070p_tuner_attach,
4322
4323 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
Michael Krufky77eed212011-09-06 09:31:57 -03004324 }},
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004325 .size_of_priv = sizeof(struct dib0700_adapter_state),
4326 }
4327 },
4328
4329 .num_device_descs = 1,
4330 .devices = {
Michael Müller84e2f032010-04-26 22:18:57 -03004331 { "Elgato EyeTV Diversity",
4332 { &dib0700_usb_id_table[68], NULL },
4333 { NULL },
4334 },
Arne Luehrsc985a8d2009-01-21 01:37:20 -03004335 },
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004336
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004337 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004338 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004339 .rc_codes = RC_MAP_DIB0700_NEC_TABLE,
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004340 .module_name = "dib0700",
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03004341 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004342 .allowed_protos = RC_BIT_RC5 |
4343 RC_BIT_RC6_MCE |
4344 RC_BIT_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03004345 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004346 },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03004347 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4348
4349 .num_adapters = 1,
4350 .adapter = {
4351 {
Michael Krufky77eed212011-09-06 09:31:57 -03004352 .num_frontends = 1,
4353 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03004354 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4355 .pid_filter_count = 32,
4356 .pid_filter = stk70x0p_pid_filter,
4357 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03004358 .frontend_attach = stk7700ph_frontend_attach,
4359 .tuner_attach = stk7700ph_tuner_attach,
4360
4361 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004362 }},
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03004363 .size_of_priv = sizeof(struct
4364 dib0700_adapter_state),
4365 },
4366 },
4367
Pete Hildebrandtc53d83c2009-08-05 11:46:38 -03004368 .num_device_descs = 9,
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03004369 .devices = {
4370 { "Terratec Cinergy HT USB XE",
4371 { &dib0700_usb_id_table[27], NULL },
4372 { NULL },
4373 },
4374 { "Pinnacle Expresscard 320cx",
4375 { &dib0700_usb_id_table[28], NULL },
4376 { NULL },
4377 },
4378 { "Terratec Cinergy HT Express",
4379 { &dib0700_usb_id_table[32], NULL },
4380 { NULL },
4381 },
Finn Thain17a370b2008-09-06 13:42:47 -03004382 { "Gigabyte U8000-RH",
4383 { &dib0700_usb_id_table[37], NULL },
4384 { NULL },
4385 },
Daniel Oliveira Nascimento8751aaa2008-09-07 12:39:44 -03004386 { "YUAN High-Tech STK7700PH",
4387 { &dib0700_usb_id_table[38], NULL },
4388 { NULL },
4389 },
Albert Comerma57697432008-09-07 12:43:33 -03004390 { "Asus My Cinema-U3000Hybrid",
4391 { &dib0700_usb_id_table[39], NULL },
4392 { NULL },
4393 },
Xoan Loureiro16ba1ee2009-03-29 08:43:36 -03004394 { "YUAN High-Tech MC770",
4395 { &dib0700_usb_id_table[48], NULL },
4396 { NULL },
4397 },
tomas petrf0f4ae72009-05-20 05:28:05 -03004398 { "Leadtek WinFast DTV Dongle H",
4399 { &dib0700_usb_id_table[51], NULL },
4400 { NULL },
4401 },
Pete Hildebrandtc53d83c2009-08-05 11:46:38 -03004402 { "YUAN High-Tech STK7700D",
4403 { &dib0700_usb_id_table[54], NULL },
4404 { NULL },
4405 },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03004406 },
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004407
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004408 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004409 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004410 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004411 .module_name = "dib0700",
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03004412 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004413 .allowed_protos = RC_BIT_RC5 |
4414 RC_BIT_RC6_MCE |
4415 RC_BIT_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03004416 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004417 },
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03004418 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4419 .num_adapters = 1,
4420 .adapter = {
4421 {
Michael Krufky77eed212011-09-06 09:31:57 -03004422 .num_frontends = 1,
4423 .fe = {{
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03004424 .frontend_attach = s5h1411_frontend_attach,
4425 .tuner_attach = xc5000_tuner_attach,
4426
4427 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004428 }},
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03004429 .size_of_priv = sizeof(struct
4430 dib0700_adapter_state),
4431 },
4432 },
4433
Devin Heitmuellerd2fc3bf2008-09-25 06:22:23 -03004434 .num_device_descs = 2,
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03004435 .devices = {
4436 { "Pinnacle PCTV HD Pro USB Stick",
4437 { &dib0700_usb_id_table[40], NULL },
4438 { NULL },
4439 },
Devin Heitmuellerd2fc3bf2008-09-25 06:22:23 -03004440 { "Pinnacle PCTV HD USB Stick",
4441 { &dib0700_usb_id_table[41], NULL },
4442 { NULL },
4443 },
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03004444 },
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004445
4446 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004447 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004448 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004449 .module_name = "dib0700",
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03004450 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004451 .allowed_protos = RC_BIT_RC5 |
4452 RC_BIT_RC6_MCE |
4453 RC_BIT_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03004454 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004455 },
Michael Krufkyce904bc2009-01-19 01:12:55 -03004456 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4457 .num_adapters = 1,
4458 .adapter = {
4459 {
Michael Krufky77eed212011-09-06 09:31:57 -03004460 .num_frontends = 1,
4461 .fe = {{
Michael Krufkyce904bc2009-01-19 01:12:55 -03004462 .frontend_attach = lgdt3305_frontend_attach,
4463 .tuner_attach = mxl5007t_tuner_attach,
4464
4465 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004466 }},
Michael Krufkyce904bc2009-01-19 01:12:55 -03004467 .size_of_priv = sizeof(struct
4468 dib0700_adapter_state),
4469 },
4470 },
4471
4472 .num_device_descs = 2,
4473 .devices = {
4474 { "Hauppauge ATSC MiniCard (B200)",
4475 { &dib0700_usb_id_table[46], NULL },
4476 { NULL },
4477 },
4478 { "Hauppauge ATSC MiniCard (B210)",
4479 { &dib0700_usb_id_table[47], NULL },
4480 { NULL },
4481 },
4482 },
Olivier Grenied300bd62009-09-15 06:55:35 -03004483 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4484
4485 .num_adapters = 1,
4486 .adapter = {
4487 {
Michael Krufky77eed212011-09-06 09:31:57 -03004488 .num_frontends = 1,
4489 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03004490 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4491 .pid_filter_count = 32,
4492 .pid_filter = stk70x0p_pid_filter,
4493 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
Olivier Grenie90e12ce2010-09-07 12:50:45 -03004494 .frontend_attach = stk7770p_frontend_attach,
Olivier Grenied300bd62009-09-15 06:55:35 -03004495 .tuner_attach = dib7770p_tuner_attach,
4496
4497 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004498 }},
Olivier Grenied300bd62009-09-15 06:55:35 -03004499 .size_of_priv =
Patrick Boettcherdb481382009-09-15 07:16:51 -03004500 sizeof(struct dib0700_adapter_state),
Olivier Grenied300bd62009-09-15 06:55:35 -03004501 },
4502 },
4503
Stéphane Elmalehd1402302011-05-21 07:33:38 -03004504 .num_device_descs = 4,
Olivier Grenied300bd62009-09-15 06:55:35 -03004505 .devices = {
4506 { "DiBcom STK7770P reference design",
4507 { &dib0700_usb_id_table[59], NULL },
4508 { NULL },
4509 },
Patrick Boettcher1e13c8f2009-09-19 05:24:40 -03004510 { "Terratec Cinergy T USB XXS (HD)/ T3",
4511 { &dib0700_usb_id_table[33],
4512 &dib0700_usb_id_table[52],
4513 &dib0700_usb_id_table[60], NULL},
Patrick Boettcherdb481382009-09-15 07:16:51 -03004514 { NULL },
4515 },
Lukas Max Fisch498e6772011-02-08 16:51:45 -03004516 { "TechniSat AirStar TeleStick 2",
4517 { &dib0700_usb_id_table[74], NULL },
4518 { NULL },
4519 },
Stéphane Elmalehd1402302011-05-21 07:33:38 -03004520 { "Medion CTX1921 DVB-T USB",
4521 { &dib0700_usb_id_table[75], NULL },
4522 { NULL },
4523 },
Olivier Grenied300bd62009-09-15 06:55:35 -03004524 },
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004525
4526 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004527 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004528 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004529 .module_name = "dib0700",
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03004530 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004531 .allowed_protos = RC_BIT_RC5 |
4532 RC_BIT_RC6_MCE |
4533 RC_BIT_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03004534 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004535 },
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03004536 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4537 .num_adapters = 1,
4538 .adapter = {
4539 {
Michael Krufky77eed212011-09-06 09:31:57 -03004540 .num_frontends = 1,
4541 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03004542 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4543 .pid_filter_count = 32,
Olivier Grenie03245a52009-12-04 13:27:57 -03004544 .pid_filter = stk80xx_pid_filter,
4545 .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03004546 .frontend_attach = stk807x_frontend_attach,
4547 .tuner_attach = dib807x_tuner_attach,
4548
4549 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004550 }},
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03004551 .size_of_priv =
4552 sizeof(struct dib0700_adapter_state),
4553 },
4554 },
4555
S?rgio Fortier8a378e82009-09-28 04:19:21 -03004556 .num_device_descs = 3,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03004557 .devices = {
4558 { "DiBcom STK807xP reference design",
4559 { &dib0700_usb_id_table[62], NULL },
4560 { NULL },
4561 },
Mauro Carvalho Chehabaaeab302009-09-16 09:18:26 -03004562 { "Prolink Pixelview SBTVD",
4563 { &dib0700_usb_id_table[63], NULL },
4564 { NULL },
4565 },
S?rgio Fortier8a378e82009-09-28 04:19:21 -03004566 { "EvolutePC TVWay+",
4567 { &dib0700_usb_id_table[64], NULL },
4568 { NULL },
4569 },
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03004570 },
4571
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004572 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004573 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004574 .rc_codes = RC_MAP_DIB0700_NEC_TABLE,
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004575 .module_name = "dib0700",
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03004576 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004577 .allowed_protos = RC_BIT_RC5 |
4578 RC_BIT_RC6_MCE |
4579 RC_BIT_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03004580 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004581 },
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03004582 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4583 .num_adapters = 2,
4584 .adapter = {
4585 {
Michael Krufky77eed212011-09-06 09:31:57 -03004586 .num_frontends = 1,
4587 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03004588 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4589 .pid_filter_count = 32,
Olivier Grenie03245a52009-12-04 13:27:57 -03004590 .pid_filter = stk80xx_pid_filter,
4591 .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03004592 .frontend_attach = stk807xpvr_frontend_attach0,
4593 .tuner_attach = dib807x_tuner_attach,
4594
4595 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004596 }},
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03004597 .size_of_priv =
4598 sizeof(struct dib0700_adapter_state),
4599 },
4600 {
Michael Krufky77eed212011-09-06 09:31:57 -03004601 .num_frontends = 1,
4602 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03004603 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4604 .pid_filter_count = 32,
Olivier Grenie03245a52009-12-04 13:27:57 -03004605 .pid_filter = stk80xx_pid_filter,
4606 .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03004607 .frontend_attach = stk807xpvr_frontend_attach1,
4608 .tuner_attach = dib807x_tuner_attach,
4609
4610 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
Michael Krufky77eed212011-09-06 09:31:57 -03004611 }},
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03004612 .size_of_priv =
4613 sizeof(struct dib0700_adapter_state),
4614 },
4615 },
4616
4617 .num_device_descs = 1,
4618 .devices = {
4619 { "DiBcom STK807xPVR reference design",
4620 { &dib0700_usb_id_table[61], NULL },
4621 { NULL },
4622 },
4623 },
4624
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004625 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004626 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004627 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004628 .module_name = "dib0700",
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03004629 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004630 .allowed_protos = RC_BIT_RC5 |
4631 RC_BIT_RC6_MCE |
4632 RC_BIT_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03004633 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004634 },
Olivier Grenie03245a52009-12-04 13:27:57 -03004635 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4636 .num_adapters = 1,
4637 .adapter = {
4638 {
Michael Krufky77eed212011-09-06 09:31:57 -03004639 .num_frontends = 1,
4640 .fe = {{
Olivier Grenie03245a52009-12-04 13:27:57 -03004641 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
4642 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4643 .pid_filter_count = 32,
4644 .pid_filter = stk80xx_pid_filter,
4645 .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
4646 .frontend_attach = stk809x_frontend_attach,
4647 .tuner_attach = dib809x_tuner_attach,
4648
4649 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004650 }},
Olivier Grenie03245a52009-12-04 13:27:57 -03004651 .size_of_priv =
4652 sizeof(struct dib0700_adapter_state),
4653 },
4654 },
4655
4656 .num_device_descs = 1,
4657 .devices = {
4658 { "DiBcom STK8096GP reference design",
4659 { &dib0700_usb_id_table[67], NULL },
4660 { NULL },
4661 },
4662 },
4663
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004664 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004665 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004666 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004667 .module_name = "dib0700",
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03004668 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004669 .allowed_protos = RC_BIT_RC5 |
4670 RC_BIT_RC6_MCE |
4671 RC_BIT_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03004672 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004673 },
Olivier Greniebe9bae12011-01-04 05:42:19 -03004674 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4675 .num_adapters = 1,
4676 .adapter = {
4677 {
Michael Krufky77eed212011-09-06 09:31:57 -03004678 .num_frontends = 1,
4679 .fe = {{
Olivier Greniebe9bae12011-01-04 05:42:19 -03004680 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
4681 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4682 .pid_filter_count = 32,
4683 .pid_filter = dib90x0_pid_filter,
4684 .pid_filter_ctrl = dib90x0_pid_filter_ctrl,
4685 .frontend_attach = stk9090m_frontend_attach,
4686 .tuner_attach = dib9090_tuner_attach,
4687
4688 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004689 }},
Olivier Greniebe9bae12011-01-04 05:42:19 -03004690 .size_of_priv =
4691 sizeof(struct dib0700_adapter_state),
4692 },
4693 },
4694
4695 .num_device_descs = 1,
4696 .devices = {
4697 { "DiBcom STK9090M reference design",
4698 { &dib0700_usb_id_table[69], NULL },
4699 { NULL },
4700 },
4701 },
4702
4703 .rc.core = {
4704 .rc_interval = DEFAULT_RC_INTERVAL,
4705 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4706 .module_name = "dib0700",
4707 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004708 .allowed_protos = RC_BIT_RC5 |
4709 RC_BIT_RC6_MCE |
4710 RC_BIT_NEC,
Olivier Greniebe9bae12011-01-04 05:42:19 -03004711 .change_protocol = dib0700_change_protocol,
4712 },
4713 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4714 .num_adapters = 1,
4715 .adapter = {
4716 {
Michael Krufky77eed212011-09-06 09:31:57 -03004717 .num_frontends = 1,
4718 .fe = {{
Olivier Greniebe9bae12011-01-04 05:42:19 -03004719 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
4720 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4721 .pid_filter_count = 32,
4722 .pid_filter = stk80xx_pid_filter,
4723 .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
4724 .frontend_attach = nim8096md_frontend_attach,
4725 .tuner_attach = nim8096md_tuner_attach,
4726
4727 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004728 }},
Olivier Greniebe9bae12011-01-04 05:42:19 -03004729 .size_of_priv =
4730 sizeof(struct dib0700_adapter_state),
4731 },
4732 },
4733
4734 .num_device_descs = 1,
4735 .devices = {
4736 { "DiBcom NIM8096MD reference design",
4737 { &dib0700_usb_id_table[70], NULL },
4738 { NULL },
4739 },
4740 },
4741
4742 .rc.core = {
4743 .rc_interval = DEFAULT_RC_INTERVAL,
4744 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4745 .module_name = "dib0700",
4746 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004747 .allowed_protos = RC_BIT_RC5 |
4748 RC_BIT_RC6_MCE |
4749 RC_BIT_NEC,
Olivier Greniebe9bae12011-01-04 05:42:19 -03004750 .change_protocol = dib0700_change_protocol,
4751 },
4752 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4753 .num_adapters = 1,
4754 .adapter = {
4755 {
Michael Krufky77eed212011-09-06 09:31:57 -03004756 .num_frontends = 1,
4757 .fe = {{
Olivier Greniebe9bae12011-01-04 05:42:19 -03004758 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
4759 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4760 .pid_filter_count = 32,
4761 .pid_filter = dib90x0_pid_filter,
4762 .pid_filter_ctrl = dib90x0_pid_filter_ctrl,
4763 .frontend_attach = nim9090md_frontend_attach,
4764 .tuner_attach = nim9090md_tuner_attach,
4765
4766 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004767 }},
Olivier Greniebe9bae12011-01-04 05:42:19 -03004768 .size_of_priv =
4769 sizeof(struct dib0700_adapter_state),
4770 },
4771 },
4772
4773 .num_device_descs = 1,
4774 .devices = {
4775 { "DiBcom NIM9090MD reference design",
4776 { &dib0700_usb_id_table[71], NULL },
4777 { NULL },
4778 },
4779 },
4780
4781 .rc.core = {
4782 .rc_interval = DEFAULT_RC_INTERVAL,
4783 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4784 .module_name = "dib0700",
4785 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004786 .allowed_protos = RC_BIT_RC5 |
4787 RC_BIT_RC6_MCE |
4788 RC_BIT_NEC,
Olivier Greniebe9bae12011-01-04 05:42:19 -03004789 .change_protocol = dib0700_change_protocol,
4790 },
4791 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4792 .num_adapters = 1,
4793 .adapter = {
4794 {
Michael Krufky77eed212011-09-06 09:31:57 -03004795 .num_frontends = 1,
4796 .fe = {{
Olivier Greniebe9bae12011-01-04 05:42:19 -03004797 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
4798 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4799 .pid_filter_count = 32,
4800 .pid_filter = stk70x0p_pid_filter,
4801 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
4802 .frontend_attach = nim7090_frontend_attach,
4803 .tuner_attach = nim7090_tuner_attach,
4804
4805 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004806 }},
Olivier Greniebe9bae12011-01-04 05:42:19 -03004807 .size_of_priv =
4808 sizeof(struct dib0700_adapter_state),
4809 },
4810 },
4811
4812 .num_device_descs = 1,
4813 .devices = {
4814 { "DiBcom NIM7090 reference design",
4815 { &dib0700_usb_id_table[72], NULL },
4816 { NULL },
4817 },
4818 },
4819
4820 .rc.core = {
4821 .rc_interval = DEFAULT_RC_INTERVAL,
4822 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4823 .module_name = "dib0700",
4824 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004825 .allowed_protos = RC_BIT_RC5 |
4826 RC_BIT_RC6_MCE |
4827 RC_BIT_NEC,
Olivier Greniebe9bae12011-01-04 05:42:19 -03004828 .change_protocol = dib0700_change_protocol,
4829 },
4830 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4831 .num_adapters = 2,
4832 .adapter = {
4833 {
Michael Krufky77eed212011-09-06 09:31:57 -03004834 .num_frontends = 1,
4835 .fe = {{
Olivier Greniebe9bae12011-01-04 05:42:19 -03004836 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
4837 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4838 .pid_filter_count = 32,
4839 .pid_filter = stk70x0p_pid_filter,
4840 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
4841 .frontend_attach = tfe7090pvr_frontend0_attach,
4842 .tuner_attach = tfe7090pvr_tuner0_attach,
4843
4844 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
Michael Krufky77eed212011-09-06 09:31:57 -03004845 }},
Olivier Greniebe9bae12011-01-04 05:42:19 -03004846 .size_of_priv =
4847 sizeof(struct dib0700_adapter_state),
4848 },
4849 {
Michael Krufky77eed212011-09-06 09:31:57 -03004850 .num_frontends = 1,
4851 .fe = {{
Olivier Greniebe9bae12011-01-04 05:42:19 -03004852 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
4853 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4854 .pid_filter_count = 32,
4855 .pid_filter = stk70x0p_pid_filter,
4856 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
4857 .frontend_attach = tfe7090pvr_frontend1_attach,
4858 .tuner_attach = tfe7090pvr_tuner1_attach,
4859
4860 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004861 }},
Olivier Greniebe9bae12011-01-04 05:42:19 -03004862 .size_of_priv =
4863 sizeof(struct dib0700_adapter_state),
4864 },
4865 },
4866
4867 .num_device_descs = 1,
4868 .devices = {
4869 { "DiBcom TFE7090PVR reference design",
4870 { &dib0700_usb_id_table[73], NULL },
4871 { NULL },
4872 },
4873 },
4874
4875 .rc.core = {
4876 .rc_interval = DEFAULT_RC_INTERVAL,
4877 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4878 .module_name = "dib0700",
4879 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004880 .allowed_protos = RC_BIT_RC5 |
4881 RC_BIT_RC6_MCE |
4882 RC_BIT_NEC,
Olivier Greniebe9bae12011-01-04 05:42:19 -03004883 .change_protocol = dib0700_change_protocol,
4884 },
Davide Ferri8d009a02009-06-23 22:34:06 -03004885 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4886 .num_adapters = 1,
4887 .adapter = {
4888 {
Michael Krufky77eed212011-09-06 09:31:57 -03004889 .num_frontends = 1,
4890 .fe = {{
Devin Heitmueller01f16262009-06-24 00:07:01 -03004891 .frontend_attach = pctv340e_frontend_attach,
Davide Ferri8d009a02009-06-23 22:34:06 -03004892 .tuner_attach = xc4000_tuner_attach,
4893
4894 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004895 }},
Davide Ferri8d009a02009-06-23 22:34:06 -03004896 .size_of_priv = sizeof(struct
4897 dib0700_adapter_state),
4898 },
4899 },
4900
Devin Heitmueller33fb1682009-06-23 22:48:02 -03004901 .num_device_descs = 2,
Davide Ferri8d009a02009-06-23 22:34:06 -03004902 .devices = {
4903 { "Pinnacle PCTV 340e HD Pro USB Stick",
4904 { &dib0700_usb_id_table[76], NULL },
4905 { NULL },
4906 },
Devin Heitmueller33fb1682009-06-23 22:48:02 -03004907 { "Pinnacle PCTV Hybrid Stick Solo",
4908 { &dib0700_usb_id_table[77], NULL },
4909 { NULL },
4910 },
Davide Ferri8d009a02009-06-23 22:34:06 -03004911 },
4912 .rc.core = {
4913 .rc_interval = DEFAULT_RC_INTERVAL,
4914 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4915 .module_name = "dib0700",
4916 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004917 .allowed_protos = RC_BIT_RC5 |
4918 RC_BIT_RC6_MCE |
4919 RC_BIT_NEC,
Davide Ferri8d009a02009-06-23 22:34:06 -03004920 .change_protocol = dib0700_change_protocol,
4921 },
Olivier Grenie6724a2f2011-08-05 13:49:33 -03004922 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4923 .num_adapters = 1,
4924 .adapter = {
4925 {
4926 .num_frontends = 1,
4927 .fe = {{
4928 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
4929 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4930 .pid_filter_count = 32,
4931 .pid_filter = stk70x0p_pid_filter,
4932 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
Olivier Grenief45f5132012-12-31 09:47:10 -03004933 .frontend_attach = tfe7790p_frontend_attach,
4934 .tuner_attach = tfe7790p_tuner_attach,
Olivier Grenieb293f302011-08-09 04:48:25 -03004935
4936 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
4937 } },
4938
4939 .size_of_priv =
4940 sizeof(struct dib0700_adapter_state),
4941 },
4942 },
4943
4944 .num_device_descs = 1,
4945 .devices = {
Olivier Grenief45f5132012-12-31 09:47:10 -03004946 { "DiBcom TFE7790P reference design",
4947 { &dib0700_usb_id_table[78], NULL },
Olivier Grenieb293f302011-08-09 04:48:25 -03004948 { NULL },
4949 },
4950 },
4951
4952 .rc.core = {
4953 .rc_interval = DEFAULT_RC_INTERVAL,
4954 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4955 .module_name = "dib0700",
4956 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004957 .allowed_protos = RC_BIT_RC5 |
4958 RC_BIT_RC6_MCE |
4959 RC_BIT_NEC,
Olivier Grenieb293f302011-08-09 04:48:25 -03004960 .change_protocol = dib0700_change_protocol,
4961 },
Olivier Grenie88f3a352011-08-10 05:28:38 -03004962 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4963 .num_adapters = 1,
4964 .adapter = {
4965 {
4966 .num_frontends = 1,
4967 .fe = {{
4968 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
4969 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4970 .pid_filter_count = 32,
4971 .pid_filter = stk80xx_pid_filter,
4972 .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
4973 .frontend_attach = tfe8096p_frontend_attach,
4974 .tuner_attach = tfe8096p_tuner_attach,
4975
4976 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
4977
4978 } },
4979
4980 .size_of_priv =
4981 sizeof(struct dib0700_adapter_state),
4982 },
4983 },
4984
4985 .num_device_descs = 1,
4986 .devices = {
4987 { "DiBcom TFE8096P reference design",
Olivier Grenief45f5132012-12-31 09:47:10 -03004988 { &dib0700_usb_id_table[79], NULL },
Olivier Grenie88f3a352011-08-10 05:28:38 -03004989 { NULL },
4990 },
4991 },
4992
4993 .rc.core = {
4994 .rc_interval = DEFAULT_RC_INTERVAL,
4995 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4996 .module_name = "dib0700",
4997 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004998 .allowed_protos = RC_BIT_RC5 |
4999 RC_BIT_RC6_MCE |
5000 RC_BIT_NEC,
Olivier Grenie88f3a352011-08-10 05:28:38 -03005001 .change_protocol = dib0700_change_protocol,
5002 },
Patrick Boettcher01373a52007-07-30 12:49:04 -03005003 },
Patrick Boettcherb7f54912006-09-19 12:51:37 -03005004};
5005
5006int dib0700_device_count = ARRAY_SIZE(dib0700_devices);