blob: ce47d3f1c8502a1774a3eee1b518d0cd5821247d [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 = {
Olivier Grenie9c783032009-12-07 07:49:40 -0300223 60000, 30000,
224 1, 8, 3, 1, 0,
225 0, 0, 1, 1, 2,
226 (3 << 14) | (1 << 12) | (524 << 0),
227 0,
228 20452225,
Olivier DANET54d75eb2007-07-25 14:42:54 -0300229};
230
231static struct dib7000p_config stk7700d_dib7000p_mt2266_config[] = {
232 { .output_mpeg2_in_188_bytes = 1,
233 .hostbus_diversity = 1,
234 .tuner_is_baseband = 1,
235
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300236 .agc_config_count = 2,
237 .agc = stk7700d_7000p_mt2266_agc_config,
Olivier DANET54d75eb2007-07-25 14:42:54 -0300238 .bw = &stk7700d_mt2266_pll_config,
239
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300240 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
241 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
242 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
Olivier DANET54d75eb2007-07-25 14:42:54 -0300243 },
244 { .output_mpeg2_in_188_bytes = 1,
245 .hostbus_diversity = 1,
246 .tuner_is_baseband = 1,
247
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300248 .agc_config_count = 2,
249 .agc = stk7700d_7000p_mt2266_agc_config,
Olivier DANET54d75eb2007-07-25 14:42:54 -0300250 .bw = &stk7700d_mt2266_pll_config,
251
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300252 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
253 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
254 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
Olivier DANET54d75eb2007-07-25 14:42:54 -0300255 }
256};
257
258static struct mt2266_config stk7700d_mt2266_config[2] = {
259 { .i2c_address = 0x60
260 },
261 { .i2c_address = 0x60
262 }
263};
264
Daniel Gimpelevich132c3182008-01-25 06:02:42 -0300265static int stk7700P2_frontend_attach(struct dvb_usb_adapter *adap)
266{
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300267 struct dib0700_adapter_state *state = adap->priv;
268
269 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
270 return -ENODEV;
271
Daniel Gimpelevich132c3182008-01-25 06:02:42 -0300272 if (adap->id == 0) {
273 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
274 msleep(10);
275 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
276 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
277 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
278 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
279 msleep(10);
280 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
281 msleep(10);
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300282 if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 18,
Devin Heitmueller83c4fdf2009-01-21 01:55:45 -0300283 stk7700d_dib7000p_mt2266_config)
284 != 0) {
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300285 err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n", __func__);
286 dvb_detach(&state->dib7000p_ops);
Devin Heitmueller83c4fdf2009-01-21 01:55:45 -0300287 return -ENODEV;
288 }
Daniel Gimpelevich132c3182008-01-25 06:02:42 -0300289 }
290
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300291 adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap,
Michael Krufky2a776312011-09-16 09:26:59 -0300292 0x80 + (adap->id << 1),
293 &stk7700d_dib7000p_mt2266_config[adap->id]);
Daniel Gimpelevich132c3182008-01-25 06:02:42 -0300294
Michael Krufky77eed212011-09-06 09:31:57 -0300295 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Daniel Gimpelevich132c3182008-01-25 06:02:42 -0300296}
297
Olivier DANET54d75eb2007-07-25 14:42:54 -0300298static int stk7700d_frontend_attach(struct dvb_usb_adapter *adap)
299{
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300300 struct dib0700_adapter_state *state = adap->priv;
301
302 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
303 return -ENODEV;
304
Olivier DANET54d75eb2007-07-25 14:42:54 -0300305 if (adap->id == 0) {
306 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
307 msleep(10);
308 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
309 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
310 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
311 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
312 msleep(10);
313 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
314 msleep(10);
315 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300316 if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap, 2, 18,
Devin Heitmueller83c4fdf2009-01-21 01:55:45 -0300317 stk7700d_dib7000p_mt2266_config)
318 != 0) {
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300319 err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n", __func__);
320 dvb_detach(&state->dib7000p_ops);
Devin Heitmueller83c4fdf2009-01-21 01:55:45 -0300321 return -ENODEV;
322 }
Olivier DANET54d75eb2007-07-25 14:42:54 -0300323 }
324
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300325 adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap,
Michael Krufky2a776312011-09-16 09:26:59 -0300326 0x80 + (adap->id << 1),
327 &stk7700d_dib7000p_mt2266_config[adap->id]);
Olivier DANET54d75eb2007-07-25 14:42:54 -0300328
Michael Krufky77eed212011-09-06 09:31:57 -0300329 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Olivier DANET54d75eb2007-07-25 14:42:54 -0300330}
331
332static int stk7700d_tuner_attach(struct dvb_usb_adapter *adap)
333{
334 struct i2c_adapter *tun_i2c;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300335 struct dib0700_adapter_state *state = adap->priv;
336
337 tun_i2c = state->dib7000p_ops.get_i2c_master(adap->fe_adap[0].fe,
338 DIBX000_I2C_INTERFACE_TUNER, 1);
Michael Krufky77eed212011-09-06 09:31:57 -0300339 return dvb_attach(mt2266_attach, adap->fe_adap[0].fe, tun_i2c,
Joe Perches1ebcad72009-07-02 15:57:09 -0300340 &stk7700d_mt2266_config[adap->id]) == NULL ? -ENODEV : 0;
Olivier DANET54d75eb2007-07-25 14:42:54 -0300341}
342
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300343/* STK7700-PH: Digital/Analog Hybrid Tuner, e.h. Cinergy HT USB HE */
Harvey Harrisonb1721d02008-04-25 19:03:08 -0700344static struct dibx000_agc_config xc3028_agc_config = {
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300345 BAND_VHF | BAND_UHF, /* band_caps */
346
347 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=0,
348 * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
349 * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=2, P_agc_write=0 */
350 (0 << 15) | (0 << 14) | (0 << 11) | (0 << 10) | (0 << 9) | (0 << 8) |
351 (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0), /* setup */
352
353 712, /* inv_gain */
354 21, /* time_stabiliz */
355
356 0, /* alpha_level */
357 118, /* thlock */
358
359 0, /* wbd_inv */
360 2867, /* wbd_ref */
361 0, /* wbd_sel */
362 2, /* wbd_alpha */
363
364 0, /* agc1_max */
365 0, /* agc1_min */
366 39718, /* agc2_max */
367 9930, /* agc2_min */
368 0, /* agc1_pt1 */
369 0, /* agc1_pt2 */
370 0, /* agc1_pt3 */
371 0, /* agc1_slope1 */
372 0, /* agc1_slope2 */
373 0, /* agc2_pt1 */
374 128, /* agc2_pt2 */
375 29, /* agc2_slope1 */
376 29, /* agc2_slope2 */
377
378 17, /* alpha_mant */
379 27, /* alpha_exp */
380 23, /* beta_mant */
381 51, /* beta_exp */
382
383 1, /* perform_agc_softsplit */
384};
385
386/* PLL Configuration for COFDM BW_MHz = 8.00 with external clock = 30.00 */
Harvey Harrisonb1721d02008-04-25 19:03:08 -0700387static struct dibx000_bandwidth_config xc3028_bw_config = {
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300388 60000, 30000, /* internal, sampling */
389 1, 8, 3, 1, 0, /* pll_cfg: prediv, ratio, range, reset, bypass */
390 0, 0, 1, 1, 0, /* misc: refdiv, bypclk_div, IO_CLK_en_core, ADClkSrc,
391 modulo */
392 (3 << 14) | (1 << 12) | (524 << 0), /* sad_cfg: refsel, sel, freq_15k */
393 (1 << 25) | 5816102, /* ifreq = 5.200000 MHz */
394 20452225, /* timf */
395 30000000, /* xtal_hz */
396};
397
398static struct dib7000p_config stk7700ph_dib7700_xc3028_config = {
399 .output_mpeg2_in_188_bytes = 1,
400 .tuner_is_baseband = 1,
401
402 .agc_config_count = 1,
403 .agc = &xc3028_agc_config,
404 .bw = &xc3028_bw_config,
405
406 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
407 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
408 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
409};
410
Michael Krufkyd7cba042008-09-12 13:31:45 -0300411static int stk7700ph_xc3028_callback(void *ptr, int component,
412 int command, int arg)
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300413{
414 struct dvb_usb_adapter *adap = ptr;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300415 struct dib0700_adapter_state *state = adap->priv;
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300416
417 switch (command) {
418 case XC2028_TUNER_RESET:
419 /* Send the tuner in then out of reset */
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300420 state->dib7000p_ops.set_gpio(adap->fe_adap[0].fe, 8, 0, 0);
421 msleep(10);
422 state->dib7000p_ops.set_gpio(adap->fe_adap[0].fe, 8, 0, 1);
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300423 break;
424 case XC2028_RESET_CLK:
425 break;
426 default:
427 err("%s: unknown command %d, arg %d\n", __func__,
428 command, arg);
429 return -EINVAL;
430 }
431 return 0;
432}
433
434static struct xc2028_ctrl stk7700ph_xc3028_ctrl = {
435 .fname = XC2028_DEFAULT_FIRMWARE,
436 .max_len = 64,
437 .demod = XC3028_FE_DIBCOM52,
438};
439
440static struct xc2028_config stk7700ph_xc3028_config = {
441 .i2c_addr = 0x61,
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300442 .ctrl = &stk7700ph_xc3028_ctrl,
443};
444
445static int stk7700ph_frontend_attach(struct dvb_usb_adapter *adap)
446{
447 struct usb_device_descriptor *desc = &adap->dev->udev->descriptor;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300448 struct dib0700_adapter_state *state = adap->priv;
449
450 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
451 return -ENODEV;
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300452
Al Viroda5ee482008-05-21 00:31:21 -0300453 if (desc->idVendor == cpu_to_le16(USB_VID_PINNACLE) &&
454 desc->idProduct == cpu_to_le16(USB_PID_PINNACLE_EXPRESSCARD_320CX))
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300455 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300456 else
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300457 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300458 msleep(20);
459 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
460 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
461 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
462 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
463 msleep(10);
464 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
465 msleep(20);
466 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
467 msleep(10);
468
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300469 if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 18,
Devin Heitmueller83c4fdf2009-01-21 01:55:45 -0300470 &stk7700ph_dib7700_xc3028_config) != 0) {
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300471 err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n",
Devin Heitmueller83c4fdf2009-01-21 01:55:45 -0300472 __func__);
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300473 dvb_detach(&state->dib7000p_ops);
Devin Heitmueller83c4fdf2009-01-21 01:55:45 -0300474 return -ENODEV;
475 }
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300476
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300477 adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap, 0x80,
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300478 &stk7700ph_dib7700_xc3028_config);
479
Michael Krufky77eed212011-09-06 09:31:57 -0300480 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300481}
482
483static int stk7700ph_tuner_attach(struct dvb_usb_adapter *adap)
484{
485 struct i2c_adapter *tun_i2c;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300486 struct dib0700_adapter_state *state = adap->priv;
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300487
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300488 tun_i2c = state->dib7000p_ops.get_i2c_master(adap->fe_adap[0].fe,
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300489 DIBX000_I2C_INTERFACE_TUNER, 1);
490
491 stk7700ph_xc3028_config.i2c_adap = tun_i2c;
Michael Krufkyd7cba042008-09-12 13:31:45 -0300492
493 /* FIXME: generalize & move to common area */
Michael Krufky77eed212011-09-06 09:31:57 -0300494 adap->fe_adap[0].fe->callback = stk7700ph_xc3028_callback;
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300495
Michael Krufky77eed212011-09-06 09:31:57 -0300496 return dvb_attach(xc2028_attach, adap->fe_adap[0].fe, &stk7700ph_xc3028_config)
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300497 == NULL ? -ENODEV : 0;
498}
499
Devin Heitmueller4b330be2008-12-01 06:51:14 -0300500#define DEFAULT_RC_INTERVAL 50
Olivier DANET54d75eb2007-07-25 14:42:54 -0300501
502static u8 rc_request[] = { REQUEST_POLL_RC, 0 };
503
Patrick Boettcher58e6f952008-03-29 21:37:01 -0300504/* Number of keypresses to ignore before start repeating */
Devin Heitmueller4b330be2008-12-01 06:51:14 -0300505#define RC_REPEAT_DELAY 6
Patrick Boettcher58e6f952008-03-29 21:37:01 -0300506
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -0300507/*
508 * This function is used only when firmware is < 1.20 version. Newer
509 * firmwares use bulk mode, with functions implemented at dib0700_core,
510 * at dib0700_rc_urb_completion()
511 */
512static int dib0700_rc_query_old_firmware(struct dvb_usb_device *d)
Olivier DANET54d75eb2007-07-25 14:42:54 -0300513{
514 u8 key[4];
David Härdeman120703f2014-04-03 20:31:30 -0300515 enum rc_type protocol;
516 u32 scancode;
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -0300517 u8 toggle;
Olivier DANET54d75eb2007-07-25 14:42:54 -0300518 int i;
Olivier DANET54d75eb2007-07-25 14:42:54 -0300519 struct dib0700_state *st = d->priv;
Devin Heitmueller6a207102010-01-04 02:43:19 -0300520
Devin Heitmueller6a207102010-01-04 02:43:19 -0300521 if (st->fw_version >= 0x10200) {
522 /* For 1.20 firmware , We need to keep the RC polling
523 callback so we can reuse the input device setup in
524 dvb-usb-remote.c. However, the actual work is being done
525 in the bulk URB completion handler. */
526 return 0;
527 }
528
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -0300529 i = dib0700_ctrl_rd(d, rc_request, 2, key, 4);
530 if (i <= 0) {
Janne Grunau034d65e2007-07-31 08:48:40 -0300531 err("RC Query Failed");
Janne Grunau89f42672007-07-31 19:45:13 -0300532 return -1;
Olivier DANET54d75eb2007-07-25 14:42:54 -0300533 }
Patrick Boettcher58e6f952008-03-29 21:37:01 -0300534
535 /* losing half of KEY_0 events from Philipps rc5 remotes.. */
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -0300536 if (key[0] == 0 && key[1] == 0 && key[2] == 0 && key[3] == 0)
537 return 0;
Patrick Boettcher58e6f952008-03-29 21:37:01 -0300538
539 /* 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]); */
540
Mauro Carvalho Chehabc4018fa2014-05-21 17:40:25 -0300541 dib0700_rc_setup(d, NULL); /* reset ir sensor data to prevent false events */
Patrick Boettcher58e6f952008-03-29 21:37:01 -0300542
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -0300543 switch (d->props.rc.core.protocol) {
David Härdemanc003ab12012-10-11 19:11:54 -0300544 case RC_BIT_NEC:
Patrick Boettcher58e6f952008-03-29 21:37:01 -0300545 /* NEC protocol sends repeat code as 0 0 0 FF */
546 if ((key[3-2] == 0x00) && (key[3-3] == 0x00) &&
David Härdeman120703f2014-04-03 20:31:30 -0300547 (key[3] == 0xff)) {
548 rc_repeat(d->rc_dev);
549 return 0;
Patrick Boettcher58e6f952008-03-29 21:37:01 -0300550 }
Patrick Boettcher58e6f952008-03-29 21:37:01 -0300551
David Härdeman120703f2014-04-03 20:31:30 -0300552 protocol = RC_TYPE_NEC;
553 scancode = RC_SCANCODE_NEC(key[3-2], key[3-3]);
554 toggle = 0;
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -0300555 break;
David Härdeman120703f2014-04-03 20:31:30 -0300556
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -0300557 default:
558 /* RC-5 protocol changes toggle bit on new keypress */
David Härdeman120703f2014-04-03 20:31:30 -0300559 protocol = RC_TYPE_RC5;
560 scancode = RC_SCANCODE_RC5(key[3-2], key[3-3]);
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -0300561 toggle = key[3-1];
Patrick Boettcher58e6f952008-03-29 21:37:01 -0300562 break;
563 }
David Härdeman120703f2014-04-03 20:31:30 -0300564
565 rc_keydown(d->rc_dev, protocol, scancode, toggle);
Olivier DANET54d75eb2007-07-25 14:42:54 -0300566 return 0;
567}
568
Patrick Boettcherb7f54912006-09-19 12:51:37 -0300569/* STK7700P: Hauppauge Nova-T Stick, AVerMedia Volar */
Patrick Boettchera75763f2006-10-18 08:34:16 -0300570static struct dibx000_agc_config stk7700p_7000m_mt2060_agc_config = {
Olivier Grenie9c783032009-12-07 07:49:40 -0300571 BAND_UHF | BAND_VHF,
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300572
573 /* 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,
574 * 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 -0300575 (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8)
576 | (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0),
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300577
Olivier Grenie9c783032009-12-07 07:49:40 -0300578 712,
579 41,
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300580
Olivier Grenie9c783032009-12-07 07:49:40 -0300581 0,
582 118,
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300583
Olivier Grenie9c783032009-12-07 07:49:40 -0300584 0,
585 4095,
586 0,
587 0,
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300588
Olivier Grenie9c783032009-12-07 07:49:40 -0300589 42598,
590 17694,
591 45875,
592 2621,
593 0,
594 76,
595 139,
596 52,
597 59,
598 107,
599 172,
600 57,
601 70,
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300602
Olivier Grenie9c783032009-12-07 07:49:40 -0300603 21,
604 25,
605 28,
606 48,
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300607
Olivier Grenie9c783032009-12-07 07:49:40 -0300608 1,
609 { 0,
610 107,
611 51800,
612 24700
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300613 },
Patrick Boettcherb7f54912006-09-19 12:51:37 -0300614};
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300615
Patrick Boettchera75763f2006-10-18 08:34:16 -0300616static struct dibx000_agc_config stk7700p_7000p_mt2060_agc_config = {
617 BAND_UHF | BAND_VHF,
618
619 /* 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,
620 * 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 -0300621 (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8)
622 | (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0),
Patrick Boettchera75763f2006-10-18 08:34:16 -0300623
Olivier Grenie9c783032009-12-07 07:49:40 -0300624 712,
625 41,
Patrick Boettchera75763f2006-10-18 08:34:16 -0300626
Olivier Grenie9c783032009-12-07 07:49:40 -0300627 0,
628 118,
Patrick Boettchera75763f2006-10-18 08:34:16 -0300629
Olivier Grenie9c783032009-12-07 07:49:40 -0300630 0,
631 4095,
632 0,
633 0,
Patrick Boettchera75763f2006-10-18 08:34:16 -0300634
Olivier Grenie9c783032009-12-07 07:49:40 -0300635 42598,
636 16384,
637 42598,
638 0,
Patrick Boettchera75763f2006-10-18 08:34:16 -0300639
Olivier Grenie9c783032009-12-07 07:49:40 -0300640 0,
641 137,
642 255,
Patrick Boettchera75763f2006-10-18 08:34:16 -0300643
Olivier Grenie9c783032009-12-07 07:49:40 -0300644 0,
645 255,
Patrick Boettchera75763f2006-10-18 08:34:16 -0300646
Olivier Grenie9c783032009-12-07 07:49:40 -0300647 0,
648 0,
Patrick Boettchera75763f2006-10-18 08:34:16 -0300649
Olivier Grenie9c783032009-12-07 07:49:40 -0300650 0,
651 41,
Patrick Boettchera75763f2006-10-18 08:34:16 -0300652
Olivier Grenie9c783032009-12-07 07:49:40 -0300653 15,
654 25,
Patrick Boettchera75763f2006-10-18 08:34:16 -0300655
Olivier Grenie9c783032009-12-07 07:49:40 -0300656 28,
657 48,
Patrick Boettchera75763f2006-10-18 08:34:16 -0300658
Olivier Grenie9c783032009-12-07 07:49:40 -0300659 0,
Patrick Boettchera75763f2006-10-18 08:34:16 -0300660};
661
662static struct dibx000_bandwidth_config stk7700p_pll_config = {
Olivier Grenie9c783032009-12-07 07:49:40 -0300663 60000, 30000,
664 1, 8, 3, 1, 0,
665 0, 0, 1, 1, 0,
666 (3 << 14) | (1 << 12) | (524 << 0),
667 60258167,
668 20452225,
669 30000000,
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300670};
671
672static struct dib7000m_config stk7700p_dib7000m_config = {
673 .dvbt_mode = 1,
674 .output_mpeg2_in_188_bytes = 1,
675 .quartz_direct = 1,
676
677 .agc_config_count = 1,
Patrick Boettchera75763f2006-10-18 08:34:16 -0300678 .agc = &stk7700p_7000m_mt2060_agc_config,
679 .bw = &stk7700p_pll_config,
680
681 .gpio_dir = DIB7000M_GPIO_DEFAULT_DIRECTIONS,
682 .gpio_val = DIB7000M_GPIO_DEFAULT_VALUES,
683 .gpio_pwm_pos = DIB7000M_GPIO_DEFAULT_PWM_POS,
684};
685
686static struct dib7000p_config stk7700p_dib7000p_config = {
687 .output_mpeg2_in_188_bytes = 1,
688
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300689 .agc_config_count = 1,
Patrick Boettchera75763f2006-10-18 08:34:16 -0300690 .agc = &stk7700p_7000p_mt2060_agc_config,
691 .bw = &stk7700p_pll_config,
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300692
693 .gpio_dir = DIB7000M_GPIO_DEFAULT_DIRECTIONS,
694 .gpio_val = DIB7000M_GPIO_DEFAULT_VALUES,
695 .gpio_pwm_pos = DIB7000M_GPIO_DEFAULT_PWM_POS,
696};
Patrick Boettcherb7f54912006-09-19 12:51:37 -0300697
698static int stk7700p_frontend_attach(struct dvb_usb_adapter *adap)
699{
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300700 struct dib0700_state *st = adap->dev->priv;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300701 struct dib0700_adapter_state *state = adap->priv;
702
703 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
704 return -ENODEV;
705
Patrick Boettcherb7f54912006-09-19 12:51:37 -0300706 /* unless there is no real power management in DVB - we leave the device on GPIO6 */
Patrick Boettchera75763f2006-10-18 08:34:16 -0300707
708 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
709 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0); msleep(50);
710
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300711 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1); msleep(10);
Patrick Boettchera75763f2006-10-18 08:34:16 -0300712 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
713
Patrick Boettcherb7f54912006-09-19 12:51:37 -0300714 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0); msleep(10);
Patrick Boettchera75763f2006-10-18 08:34:16 -0300715 dib0700_ctrl_clock(adap->dev, 72, 1);
716 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1); msleep(100);
717
718 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
Patrick Boettcherb7f54912006-09-19 12:51:37 -0300719
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300720 st->mt2060_if1[0] = 1220;
Patrick Boettchera75763f2006-10-18 08:34:16 -0300721
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300722 if (state->dib7000p_ops.dib7000pc_detection(&adap->dev->i2c_adap)) {
723 adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap, 18, &stk7700p_dib7000p_config);
Patrick Boettchera75763f2006-10-18 08:34:16 -0300724 st->is_dib7000pc = 1;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300725 } else {
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300726 memset(&state->dib7000p_ops, 0, sizeof(state->dib7000p_ops));
Michael Krufky77eed212011-09-06 09:31:57 -0300727 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 -0300728 }
Patrick Boettchera75763f2006-10-18 08:34:16 -0300729
Michael Krufky77eed212011-09-06 09:31:57 -0300730 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Patrick Boettcherb7f54912006-09-19 12:51:37 -0300731}
732
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300733static struct mt2060_config stk7700p_mt2060_config = {
734 0x60
735};
736
Patrick Boettcherb7f54912006-09-19 12:51:37 -0300737static int stk7700p_tuner_attach(struct dvb_usb_adapter *adap)
738{
Olivier DANETc52344f2008-01-25 06:50:07 -0300739 struct i2c_adapter *prim_i2c = &adap->dev->i2c_adap;
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300740 struct dib0700_state *st = adap->dev->priv;
Patrick Boettchera75763f2006-10-18 08:34:16 -0300741 struct i2c_adapter *tun_i2c;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300742 struct dib0700_adapter_state *state = adap->priv;
Olivier DANETc52344f2008-01-25 06:50:07 -0300743 s8 a;
744 int if1=1220;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300745
Al Viroda5ee482008-05-21 00:31:21 -0300746 if (adap->dev->udev->descriptor.idVendor == cpu_to_le16(USB_VID_HAUPPAUGE) &&
747 adap->dev->udev->descriptor.idProduct == cpu_to_le16(USB_PID_HAUPPAUGE_NOVA_T_STICK)) {
Olivier DANETc52344f2008-01-25 06:50:07 -0300748 if (!eeprom_read(prim_i2c,0x58,&a)) if1=1220+a;
749 }
Patrick Boettchera75763f2006-10-18 08:34:16 -0300750 if (st->is_dib7000pc)
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300751 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 -0300752 else
Michael Krufky77eed212011-09-06 09:31:57 -0300753 tun_i2c = dib7000m_get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_TUNER, 1);
Patrick Boettchera75763f2006-10-18 08:34:16 -0300754
Michael Krufky77eed212011-09-06 09:31:57 -0300755 return dvb_attach(mt2060_attach, adap->fe_adap[0].fe, tun_i2c, &stk7700p_mt2060_config,
Olivier DANETc52344f2008-01-25 06:50:07 -0300756 if1) == NULL ? -ENODEV : 0;
Patrick Boettcherb7f54912006-09-19 12:51:37 -0300757}
758
Patrick Boettcher01373a52007-07-30 12:49:04 -0300759/* DIB7070 generic */
760static struct dibx000_agc_config dib7070_agc_config = {
761 BAND_UHF | BAND_VHF | BAND_LBAND | BAND_SBAND,
762 /* 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,
763 * P_agc_inh_dc_rv_est=0, P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5, P_agc_write=0 */
Olivier Grenie9c783032009-12-07 07:49:40 -0300764 (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8)
765 | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),
Patrick Boettcher01373a52007-07-30 12:49:04 -0300766
Olivier Grenie9c783032009-12-07 07:49:40 -0300767 600,
768 10,
Patrick Boettcher01373a52007-07-30 12:49:04 -0300769
Olivier Grenie9c783032009-12-07 07:49:40 -0300770 0,
771 118,
Patrick Boettcher01373a52007-07-30 12:49:04 -0300772
Olivier Grenie9c783032009-12-07 07:49:40 -0300773 0,
774 3530,
775 1,
776 5,
Patrick Boettcher01373a52007-07-30 12:49:04 -0300777
Olivier Grenie9c783032009-12-07 07:49:40 -0300778 65535,
779 0,
Patrick Boettcher01373a52007-07-30 12:49:04 -0300780
Olivier Grenie9c783032009-12-07 07:49:40 -0300781 65535,
782 0,
Patrick Boettcher01373a52007-07-30 12:49:04 -0300783
Olivier Grenie9c783032009-12-07 07:49:40 -0300784 0,
785 40,
786 183,
787 206,
788 255,
789 72,
790 152,
791 88,
792 90,
Patrick Boettcher01373a52007-07-30 12:49:04 -0300793
Olivier Grenie9c783032009-12-07 07:49:40 -0300794 17,
795 27,
796 23,
797 51,
Patrick Boettcher01373a52007-07-30 12:49:04 -0300798
Olivier Grenie9c783032009-12-07 07:49:40 -0300799 0,
Patrick Boettcher01373a52007-07-30 12:49:04 -0300800};
801
802static int dib7070_tuner_reset(struct dvb_frontend *fe, int onoff)
803{
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300804 struct dvb_usb_adapter *adap = fe->dvb->priv;
805 struct dib0700_adapter_state *state = adap->priv;
806
Patrick Boettcher7e5ce652009-08-03 13:43:40 -0300807 deb_info("reset: %d", onoff);
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300808 return state->dib7000p_ops.set_gpio(fe, 8, 0, !onoff);
Patrick Boettcher01373a52007-07-30 12:49:04 -0300809}
810
811static int dib7070_tuner_sleep(struct dvb_frontend *fe, int onoff)
812{
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300813 struct dvb_usb_adapter *adap = fe->dvb->priv;
814 struct dib0700_adapter_state *state = adap->priv;
815
Patrick Boettcher7e5ce652009-08-03 13:43:40 -0300816 deb_info("sleep: %d", onoff);
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300817 return state->dib7000p_ops.set_gpio(fe, 9, 0, onoff);
Patrick Boettcher01373a52007-07-30 12:49:04 -0300818}
819
820static struct dib0070_config dib7070p_dib0070_config[2] = {
821 {
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 .clock_pad_drive = 4,
827 .charge_pump = 2,
Patrick Boettcher01373a52007-07-30 12:49:04 -0300828 }, {
829 .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
830 .reset = dib7070_tuner_reset,
831 .sleep = dib7070_tuner_sleep,
832 .clock_khz = 12000,
Patrick Boettcher7e5ce652009-08-03 13:43:40 -0300833 .charge_pump = 2,
Patrick Boettcher01373a52007-07-30 12:49:04 -0300834 }
835};
836
Olivier Grenied300bd62009-09-15 06:55:35 -0300837static struct dib0070_config dib7770p_dib0070_config = {
838 .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
839 .reset = dib7070_tuner_reset,
840 .sleep = dib7070_tuner_sleep,
841 .clock_khz = 12000,
842 .clock_pad_drive = 0,
843 .flip_chip = 1,
Olivier Grenieeac1fe12009-09-23 13:41:27 -0300844 .charge_pump = 2,
Olivier Grenied300bd62009-09-15 06:55:35 -0300845};
846
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -0300847static int dib7070_set_param_override(struct dvb_frontend *fe)
Patrick Boettcher01373a52007-07-30 12:49:04 -0300848{
Mauro Carvalho Chehab47b163a2011-12-24 10:18:24 -0300849 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
Patrick Boettcher01373a52007-07-30 12:49:04 -0300850 struct dvb_usb_adapter *adap = fe->dvb->priv;
851 struct dib0700_adapter_state *state = adap->priv;
852
853 u16 offset;
Mauro Carvalho Chehab47b163a2011-12-24 10:18:24 -0300854 u8 band = BAND_OF_FREQUENCY(p->frequency/1000);
Patrick Boettcher01373a52007-07-30 12:49:04 -0300855 switch (band) {
856 case BAND_VHF: offset = 950; break;
857 case BAND_UHF:
858 default: offset = 550; break;
859 }
860 deb_info("WBD for DiB7000P: %d\n", offset + dib0070_wbd_offset(fe));
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300861 state->dib7000p_ops.set_wbd_ref(fe, offset + dib0070_wbd_offset(fe));
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -0300862 return state->set_param_save(fe);
Patrick Boettcher01373a52007-07-30 12:49:04 -0300863}
864
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -0300865static int dib7770_set_param_override(struct dvb_frontend *fe)
Olivier Grenied300bd62009-09-15 06:55:35 -0300866{
Mauro Carvalho Chehab47b163a2011-12-24 10:18:24 -0300867 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
868 struct dvb_usb_adapter *adap = fe->dvb->priv;
869 struct dib0700_adapter_state *state = adap->priv;
Olivier Grenied300bd62009-09-15 06:55:35 -0300870
871 u16 offset;
Mauro Carvalho Chehab47b163a2011-12-24 10:18:24 -0300872 u8 band = BAND_OF_FREQUENCY(p->frequency/1000);
Olivier Grenied300bd62009-09-15 06:55:35 -0300873 switch (band) {
874 case BAND_VHF:
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300875 state->dib7000p_ops.set_gpio(fe, 0, 0, 1);
Olivier Grenied300bd62009-09-15 06:55:35 -0300876 offset = 850;
877 break;
878 case BAND_UHF:
879 default:
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300880 state->dib7000p_ops.set_gpio(fe, 0, 0, 0);
Olivier Grenied300bd62009-09-15 06:55:35 -0300881 offset = 250;
882 break;
883 }
884 deb_info("WBD for DiB7000P: %d\n", offset + dib0070_wbd_offset(fe));
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300885 state->dib7000p_ops.set_wbd_ref(fe, offset + dib0070_wbd_offset(fe));
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -0300886 return state->set_param_save(fe);
Olivier Grenied300bd62009-09-15 06:55:35 -0300887}
888
889static int dib7770p_tuner_attach(struct dvb_usb_adapter *adap)
890{
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300891 struct dib0700_adapter_state *st = adap->priv;
892 struct i2c_adapter *tun_i2c = st->dib7000p_ops.get_i2c_master(adap->fe_adap[0].fe,
Olivier Grenied300bd62009-09-15 06:55:35 -0300893 DIBX000_I2C_INTERFACE_TUNER, 1);
894
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300895 if (dvb_attach(dib0070_attach, adap->fe_adap[0].fe, tun_i2c,
896 &dib7770p_dib0070_config) == NULL)
897 return -ENODEV;
Olivier Grenied300bd62009-09-15 06:55:35 -0300898
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300899 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
900 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib7770_set_param_override;
901 return 0;
Olivier Grenied300bd62009-09-15 06:55:35 -0300902}
903
Patrick Boettcher01373a52007-07-30 12:49:04 -0300904static int dib7070p_tuner_attach(struct dvb_usb_adapter *adap)
905{
906 struct dib0700_adapter_state *st = adap->priv;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300907 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 -0300908
909 if (adap->id == 0) {
Michael Krufky77eed212011-09-06 09:31:57 -0300910 if (dvb_attach(dib0070_attach, adap->fe_adap[0].fe, tun_i2c, &dib7070p_dib0070_config[0]) == NULL)
Patrick Boettcher01373a52007-07-30 12:49:04 -0300911 return -ENODEV;
912 } else {
Michael Krufky77eed212011-09-06 09:31:57 -0300913 if (dvb_attach(dib0070_attach, adap->fe_adap[0].fe, tun_i2c, &dib7070p_dib0070_config[1]) == NULL)
Patrick Boettcher01373a52007-07-30 12:49:04 -0300914 return -ENODEV;
915 }
916
Michael Krufky77eed212011-09-06 09:31:57 -0300917 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
918 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib7070_set_param_override;
Patrick Boettcher01373a52007-07-30 12:49:04 -0300919 return 0;
920}
921
Olivier Greniee192a7c2011-01-14 13:58:59 -0300922static int stk7700p_pid_filter(struct dvb_usb_adapter *adapter, int index,
923 u16 pid, int onoff)
924{
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300925 struct dib0700_adapter_state *state = adapter->priv;
Olivier Greniee192a7c2011-01-14 13:58:59 -0300926 struct dib0700_state *st = adapter->dev->priv;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300927
Olivier Greniee192a7c2011-01-14 13:58:59 -0300928 if (st->is_dib7000pc)
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300929 return state->dib7000p_ops.pid_filter(adapter->fe_adap[0].fe, index, pid, onoff);
Michael Krufky77eed212011-09-06 09:31:57 -0300930 return dib7000m_pid_filter(adapter->fe_adap[0].fe, index, pid, onoff);
Olivier Greniee192a7c2011-01-14 13:58:59 -0300931}
932
933static int stk7700p_pid_filter_ctrl(struct dvb_usb_adapter *adapter, int onoff)
934{
935 struct dib0700_state *st = adapter->dev->priv;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300936 struct dib0700_adapter_state *state = adapter->priv;
Olivier Greniee192a7c2011-01-14 13:58:59 -0300937 if (st->is_dib7000pc)
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300938 return state->dib7000p_ops.pid_filter_ctrl(adapter->fe_adap[0].fe, onoff);
Michael Krufky77eed212011-09-06 09:31:57 -0300939 return dib7000m_pid_filter_ctrl(adapter->fe_adap[0].fe, onoff);
Olivier Greniee192a7c2011-01-14 13:58:59 -0300940}
941
Olivier Grenief8731f42009-09-18 04:08:43 -0300942static int stk70x0p_pid_filter(struct dvb_usb_adapter *adapter, int index, u16 pid, int onoff)
943{
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300944 struct dib0700_adapter_state *state = adapter->priv;
945 return state->dib7000p_ops.pid_filter(adapter->fe_adap[0].fe, index, pid, onoff);
Olivier Grenief8731f42009-09-18 04:08:43 -0300946}
947
948static int stk70x0p_pid_filter_ctrl(struct dvb_usb_adapter *adapter, int onoff)
949{
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300950 struct dib0700_adapter_state *state = adapter->priv;
951 return state->dib7000p_ops.pid_filter_ctrl(adapter->fe_adap[0].fe, onoff);
Olivier Grenief8731f42009-09-18 04:08:43 -0300952}
953
Patrick Boettcher01373a52007-07-30 12:49:04 -0300954static struct dibx000_bandwidth_config dib7070_bw_config_12_mhz = {
Olivier Grenie9c783032009-12-07 07:49:40 -0300955 60000, 15000,
956 1, 20, 3, 1, 0,
957 0, 0, 1, 1, 2,
958 (3 << 14) | (1 << 12) | (524 << 0),
959 (0 << 25) | 0,
960 20452225,
961 12000000,
Patrick Boettcher01373a52007-07-30 12:49:04 -0300962};
963
964static struct dib7000p_config dib7070p_dib7000p_config = {
965 .output_mpeg2_in_188_bytes = 1,
966
967 .agc_config_count = 1,
968 .agc = &dib7070_agc_config,
969 .bw = &dib7070_bw_config_12_mhz,
Patrick Boettcher3cb2c392008-01-25 07:25:20 -0300970 .tuner_is_baseband = 1,
971 .spur_protect = 1,
Patrick Boettcher01373a52007-07-30 12:49:04 -0300972
973 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
974 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
975 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
976
977 .hostbus_diversity = 1,
978};
979
980/* STK7070P */
981static int stk7070p_frontend_attach(struct dvb_usb_adapter *adap)
982{
Al Viroda5ee482008-05-21 00:31:21 -0300983 struct usb_device_descriptor *p = &adap->dev->udev->descriptor;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300984 struct dib0700_adapter_state *state = adap->priv;
985
986 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
987 return -ENODEV;
988
Al Viroda5ee482008-05-21 00:31:21 -0300989 if (p->idVendor == cpu_to_le16(USB_VID_PINNACLE) &&
990 p->idProduct == cpu_to_le16(USB_PID_PINNACLE_PCTV72E))
991 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300992 else
Al Viroda5ee482008-05-21 00:31:21 -0300993 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
Patrick Boettcher01373a52007-07-30 12:49:04 -0300994 msleep(10);
995 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
996 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
997 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
998 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
999
1000 dib0700_ctrl_clock(adap->dev, 72, 1);
1001
1002 msleep(10);
1003 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
1004 msleep(10);
1005 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
1006
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03001007 if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 18,
Devin Heitmueller83c4fdf2009-01-21 01:55:45 -03001008 &dib7070p_dib7000p_config) != 0) {
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03001009 err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n",
Devin Heitmueller83c4fdf2009-01-21 01:55:45 -03001010 __func__);
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03001011 dvb_detach(&state->dib7000p_ops);
Devin Heitmueller83c4fdf2009-01-21 01:55:45 -03001012 return -ENODEV;
1013 }
Patrick Boettcher01373a52007-07-30 12:49:04 -03001014
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03001015 adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap, 0x80,
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03001016 &dib7070p_dib7000p_config);
Michael Krufky77eed212011-09-06 09:31:57 -03001017 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Patrick Boettcher01373a52007-07-30 12:49:04 -03001018}
1019
Olivier Grenie90e12ce2010-09-07 12:50:45 -03001020/* STK7770P */
1021static struct dib7000p_config dib7770p_dib7000p_config = {
1022 .output_mpeg2_in_188_bytes = 1,
1023
1024 .agc_config_count = 1,
1025 .agc = &dib7070_agc_config,
1026 .bw = &dib7070_bw_config_12_mhz,
1027 .tuner_is_baseband = 1,
1028 .spur_protect = 1,
1029
1030 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
1031 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
1032 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
1033
1034 .hostbus_diversity = 1,
1035 .enable_current_mirror = 1,
Olivier Grenie970d14c2010-09-07 12:50:46 -03001036 .disable_sample_and_hold = 0,
Olivier Grenie90e12ce2010-09-07 12:50:45 -03001037};
1038
1039static int stk7770p_frontend_attach(struct dvb_usb_adapter *adap)
1040{
1041 struct usb_device_descriptor *p = &adap->dev->udev->descriptor;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03001042 struct dib0700_adapter_state *state = adap->priv;
1043
1044 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
1045 return -ENODEV;
1046
Olivier Grenie90e12ce2010-09-07 12:50:45 -03001047 if (p->idVendor == cpu_to_le16(USB_VID_PINNACLE) &&
1048 p->idProduct == cpu_to_le16(USB_PID_PINNACLE_PCTV72E))
1049 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
1050 else
1051 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
1052 msleep(10);
1053 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
1054 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
1055 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
1056 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
1057
1058 dib0700_ctrl_clock(adap->dev, 72, 1);
1059
1060 msleep(10);
1061 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
1062 msleep(10);
1063 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
1064
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03001065 if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 18,
Olivier Grenie90e12ce2010-09-07 12:50:45 -03001066 &dib7770p_dib7000p_config) != 0) {
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03001067 err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n",
Olivier Grenie90e12ce2010-09-07 12:50:45 -03001068 __func__);
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03001069 dvb_detach(&state->dib7000p_ops);
Olivier Grenie90e12ce2010-09-07 12:50:45 -03001070 return -ENODEV;
1071 }
1072
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03001073 adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap, 0x80,
Olivier Grenie90e12ce2010-09-07 12:50:45 -03001074 &dib7770p_dib7000p_config);
Michael Krufky77eed212011-09-06 09:31:57 -03001075 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Olivier Grenie90e12ce2010-09-07 12:50:45 -03001076}
1077
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001078/* DIB807x generic */
1079static struct dibx000_agc_config dib807x_agc_config[2] = {
1080 {
1081 BAND_VHF,
1082 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0,
1083 * P_agc_freq_pwm_div=1, P_agc_inv_pwm1=0,
1084 * P_agc_inv_pwm2=0,P_agc_inh_dc_rv_est=0,
1085 * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5,
1086 * P_agc_write=0 */
1087 (0 << 15) | (0 << 14) | (7 << 11) | (0 << 10) | (0 << 9) |
1088 (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) |
1089 (0 << 0), /* setup*/
1090
1091 600, /* inv_gain*/
1092 10, /* time_stabiliz*/
1093
1094 0, /* alpha_level*/
1095 118, /* thlock*/
1096
1097 0, /* wbd_inv*/
1098 3530, /* wbd_ref*/
1099 1, /* wbd_sel*/
1100 5, /* wbd_alpha*/
1101
1102 65535, /* agc1_max*/
1103 0, /* agc1_min*/
1104
1105 65535, /* agc2_max*/
1106 0, /* agc2_min*/
1107
1108 0, /* agc1_pt1*/
1109 40, /* agc1_pt2*/
1110 183, /* agc1_pt3*/
1111 206, /* agc1_slope1*/
1112 255, /* agc1_slope2*/
1113 72, /* agc2_pt1*/
1114 152, /* agc2_pt2*/
1115 88, /* agc2_slope1*/
1116 90, /* agc2_slope2*/
1117
1118 17, /* alpha_mant*/
1119 27, /* alpha_exp*/
1120 23, /* beta_mant*/
1121 51, /* beta_exp*/
1122
1123 0, /* perform_agc_softsplit*/
1124 }, {
1125 BAND_UHF,
1126 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0,
1127 * P_agc_freq_pwm_div=1, P_agc_inv_pwm1=0,
1128 * P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
1129 * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5,
1130 * P_agc_write=0 */
1131 (0 << 15) | (0 << 14) | (1 << 11) | (0 << 10) | (0 << 9) |
1132 (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) |
1133 (0 << 0), /* setup */
1134
1135 600, /* inv_gain*/
1136 10, /* time_stabiliz*/
1137
1138 0, /* alpha_level*/
1139 118, /* thlock*/
1140
1141 0, /* wbd_inv*/
1142 3530, /* wbd_ref*/
1143 1, /* wbd_sel*/
1144 5, /* wbd_alpha*/
1145
1146 65535, /* agc1_max*/
1147 0, /* agc1_min*/
1148
1149 65535, /* agc2_max*/
1150 0, /* agc2_min*/
1151
1152 0, /* agc1_pt1*/
1153 40, /* agc1_pt2*/
1154 183, /* agc1_pt3*/
1155 206, /* agc1_slope1*/
1156 255, /* agc1_slope2*/
1157 72, /* agc2_pt1*/
1158 152, /* agc2_pt2*/
1159 88, /* agc2_slope1*/
1160 90, /* agc2_slope2*/
1161
1162 17, /* alpha_mant*/
1163 27, /* alpha_exp*/
1164 23, /* beta_mant*/
1165 51, /* beta_exp*/
1166
1167 0, /* perform_agc_softsplit*/
1168 }
1169};
1170
1171static struct dibx000_bandwidth_config dib807x_bw_config_12_mhz = {
1172 60000, 15000, /* internal, sampling*/
1173 1, 20, 3, 1, 0, /* pll_cfg: prediv, ratio, range, reset, bypass*/
1174 0, 0, 1, 1, 2, /* misc: refdiv, bypclk_div, IO_CLK_en_core,
1175 ADClkSrc, modulo */
1176 (3 << 14) | (1 << 12) | (599 << 0), /* sad_cfg: refsel, sel, freq_15k*/
1177 (0 << 25) | 0, /* ifreq = 0.000000 MHz*/
1178 18179755, /* timf*/
1179 12000000, /* xtal_hz*/
1180};
1181
1182static struct dib8000_config dib807x_dib8000_config[2] = {
1183 {
1184 .output_mpeg2_in_188_bytes = 1,
1185
1186 .agc_config_count = 2,
1187 .agc = dib807x_agc_config,
1188 .pll = &dib807x_bw_config_12_mhz,
1189 .tuner_is_baseband = 1,
1190
1191 .gpio_dir = DIB8000_GPIO_DEFAULT_DIRECTIONS,
1192 .gpio_val = DIB8000_GPIO_DEFAULT_VALUES,
1193 .gpio_pwm_pos = DIB8000_GPIO_DEFAULT_PWM_POS,
1194
1195 .hostbus_diversity = 1,
1196 .div_cfg = 1,
1197 .agc_control = &dib0070_ctrl_agc_filter,
1198 .output_mode = OUTMODE_MPEG2_FIFO,
1199 .drives = 0x2d98,
1200 }, {
1201 .output_mpeg2_in_188_bytes = 1,
1202
1203 .agc_config_count = 2,
1204 .agc = dib807x_agc_config,
1205 .pll = &dib807x_bw_config_12_mhz,
1206 .tuner_is_baseband = 1,
1207
1208 .gpio_dir = DIB8000_GPIO_DEFAULT_DIRECTIONS,
1209 .gpio_val = DIB8000_GPIO_DEFAULT_VALUES,
1210 .gpio_pwm_pos = DIB8000_GPIO_DEFAULT_PWM_POS,
1211
1212 .hostbus_diversity = 1,
1213 .agc_control = &dib0070_ctrl_agc_filter,
1214 .output_mode = OUTMODE_MPEG2_FIFO,
1215 .drives = 0x2d98,
1216 }
1217};
1218
Olivier Grenie03245a52009-12-04 13:27:57 -03001219static int dib80xx_tuner_reset(struct dvb_frontend *fe, int onoff)
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001220{
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001221 struct dvb_usb_adapter *adap = fe->dvb->priv;
1222 struct dib0700_adapter_state *state = adap->priv;
1223
1224 return state->dib8000_ops.set_gpio(fe, 5, 0, !onoff);
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001225}
1226
Olivier Grenie03245a52009-12-04 13:27:57 -03001227static int dib80xx_tuner_sleep(struct dvb_frontend *fe, int onoff)
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001228{
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001229 struct dvb_usb_adapter *adap = fe->dvb->priv;
1230 struct dib0700_adapter_state *state = adap->priv;
1231
1232 return state->dib8000_ops.set_gpio(fe, 0, 0, onoff);
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001233}
1234
1235static const struct dib0070_wbd_gain_cfg dib8070_wbd_gain_cfg[] = {
1236 { 240, 7},
1237 { 0xffff, 6},
1238};
1239
1240static struct dib0070_config dib807x_dib0070_config[2] = {
1241 {
1242 .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
Olivier Grenie03245a52009-12-04 13:27:57 -03001243 .reset = dib80xx_tuner_reset,
1244 .sleep = dib80xx_tuner_sleep,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001245 .clock_khz = 12000,
1246 .clock_pad_drive = 4,
1247 .vga_filter = 1,
1248 .force_crystal_mode = 1,
1249 .enable_third_order_filter = 1,
1250 .charge_pump = 0,
1251 .wbd_gain = dib8070_wbd_gain_cfg,
1252 .osc_buffer_state = 0,
1253 .freq_offset_khz_uhf = -100,
1254 .freq_offset_khz_vhf = -100,
1255 }, {
1256 .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
Olivier Grenie03245a52009-12-04 13:27:57 -03001257 .reset = dib80xx_tuner_reset,
1258 .sleep = dib80xx_tuner_sleep,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001259 .clock_khz = 12000,
1260 .clock_pad_drive = 2,
1261 .vga_filter = 1,
1262 .force_crystal_mode = 1,
1263 .enable_third_order_filter = 1,
1264 .charge_pump = 0,
1265 .wbd_gain = dib8070_wbd_gain_cfg,
1266 .osc_buffer_state = 0,
1267 .freq_offset_khz_uhf = -25,
1268 .freq_offset_khz_vhf = -25,
1269 }
1270};
1271
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -03001272static int dib807x_set_param_override(struct dvb_frontend *fe)
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001273{
Mauro Carvalho Chehab47b163a2011-12-24 10:18:24 -03001274 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001275 struct dvb_usb_adapter *adap = fe->dvb->priv;
1276 struct dib0700_adapter_state *state = adap->priv;
1277
1278 u16 offset = dib0070_wbd_offset(fe);
Mauro Carvalho Chehab47b163a2011-12-24 10:18:24 -03001279 u8 band = BAND_OF_FREQUENCY(p->frequency/1000);
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001280 switch (band) {
1281 case BAND_VHF:
1282 offset += 750;
1283 break;
1284 case BAND_UHF: /* fall-thru wanted */
1285 default:
1286 offset += 250; break;
1287 }
1288 deb_info("WBD for DiB8000: %d\n", offset);
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001289 state->dib8000_ops.set_wbd_ref(fe, offset);
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001290
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -03001291 return state->set_param_save(fe);
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001292}
1293
1294static int dib807x_tuner_attach(struct dvb_usb_adapter *adap)
1295{
1296 struct dib0700_adapter_state *st = adap->priv;
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001297 struct i2c_adapter *tun_i2c = st->dib8000_ops.get_i2c_master(adap->fe_adap[0].fe,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001298 DIBX000_I2C_INTERFACE_TUNER, 1);
1299
1300 if (adap->id == 0) {
Michael Krufky77eed212011-09-06 09:31:57 -03001301 if (dvb_attach(dib0070_attach, adap->fe_adap[0].fe, tun_i2c,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001302 &dib807x_dib0070_config[0]) == NULL)
1303 return -ENODEV;
1304 } else {
Michael Krufky77eed212011-09-06 09:31:57 -03001305 if (dvb_attach(dib0070_attach, adap->fe_adap[0].fe, tun_i2c,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001306 &dib807x_dib0070_config[1]) == NULL)
1307 return -ENODEV;
1308 }
1309
Michael Krufky77eed212011-09-06 09:31:57 -03001310 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
1311 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib807x_set_param_override;
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001312 return 0;
1313}
1314
Olivier Grenie9c783032009-12-07 07:49:40 -03001315static int stk80xx_pid_filter(struct dvb_usb_adapter *adapter, int index,
1316 u16 pid, int onoff)
Olivier Grenief8731f42009-09-18 04:08:43 -03001317{
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001318 struct dib0700_adapter_state *state = adapter->priv;
1319
1320 return state->dib8000_ops.pid_filter(adapter->fe_adap[0].fe, index, pid, onoff);
Olivier Grenief8731f42009-09-18 04:08:43 -03001321}
1322
Olivier Grenie9c783032009-12-07 07:49:40 -03001323static int stk80xx_pid_filter_ctrl(struct dvb_usb_adapter *adapter,
Olivier Greniebe9bae12011-01-04 05:42:19 -03001324 int onoff)
Olivier Grenief8731f42009-09-18 04:08:43 -03001325{
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001326 struct dib0700_adapter_state *state = adapter->priv;
1327
1328 return state->dib8000_ops.pid_filter_ctrl(adapter->fe_adap[0].fe, onoff);
Olivier Grenief8731f42009-09-18 04:08:43 -03001329}
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001330
1331/* STK807x */
1332static int stk807x_frontend_attach(struct dvb_usb_adapter *adap)
1333{
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001334 struct dib0700_adapter_state *state = adap->priv;
1335
1336 if (!dvb_attach(dib8000_attach, &state->dib8000_ops))
1337 return -ENODEV;
1338
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001339 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
1340 msleep(10);
1341 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
1342 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
1343 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
1344
1345 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
1346
1347 dib0700_ctrl_clock(adap->dev, 72, 1);
1348
1349 msleep(10);
1350 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
1351 msleep(10);
1352 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
1353
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001354 state->dib8000_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 18,
Olivier Grenie0c32dbd2011-08-10 05:17:18 -03001355 0x80, 0);
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001356
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001357 adap->fe_adap[0].fe = state->dib8000_ops.init(&adap->dev->i2c_adap, 0x80,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001358 &dib807x_dib8000_config[0]);
1359
Michael Krufky77eed212011-09-06 09:31:57 -03001360 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001361}
1362
1363/* STK807xPVR */
1364static int stk807xpvr_frontend_attach0(struct dvb_usb_adapter *adap)
1365{
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001366 struct dib0700_adapter_state *state = adap->priv;
1367
1368 if (!dvb_attach(dib8000_attach, &state->dib8000_ops))
1369 return -ENODEV;
1370
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001371 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
1372 msleep(30);
1373 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
1374 msleep(500);
1375 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
1376 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
1377 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
1378
1379 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
1380
1381 dib0700_ctrl_clock(adap->dev, 72, 1);
1382
1383 msleep(10);
1384 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
1385 msleep(10);
1386 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
1387
1388 /* initialize IC 0 */
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001389 state->dib8000_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 0x22, 0x80, 0);
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001390
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001391 adap->fe_adap[0].fe = state->dib8000_ops.init(&adap->dev->i2c_adap, 0x80,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001392 &dib807x_dib8000_config[0]);
1393
Michael Krufky77eed212011-09-06 09:31:57 -03001394 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001395}
1396
1397static int stk807xpvr_frontend_attach1(struct dvb_usb_adapter *adap)
1398{
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001399 struct dib0700_adapter_state *state = adap->priv;
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001400
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001401 if (!dvb_attach(dib8000_attach, &state->dib8000_ops))
1402 return -ENODEV;
1403
1404 /* initialize IC 1 */
1405 state->dib8000_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 0x12, 0x82, 0);
1406
1407 adap->fe_adap[0].fe = state->dib8000_ops.init(&adap->dev->i2c_adap, 0x82,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001408 &dib807x_dib8000_config[1]);
1409
Michael Krufky77eed212011-09-06 09:31:57 -03001410 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001411}
1412
Olivier Grenie03245a52009-12-04 13:27:57 -03001413/* STK8096GP */
Olivier Greniea685dbb2011-08-05 14:10:40 -03001414static struct dibx000_agc_config dib8090_agc_config[2] = {
Olivier Greniebe9bae12011-01-04 05:42:19 -03001415 {
Mauro Carvalho Chehab40d1a7c2014-07-04 14:15:34 -03001416 .band_caps = BAND_UHF | BAND_VHF | BAND_LBAND | BAND_SBAND,
Olivier Grenie9c783032009-12-07 07:49:40 -03001417 /* 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 -03001418 * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
1419 * 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 -03001420 .setup = (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8)
Olivier Grenie9c783032009-12-07 07:49:40 -03001421 | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),
Olivier Grenie03245a52009-12-04 13:27:57 -03001422
Mauro Carvalho Chehab40d1a7c2014-07-04 14:15:34 -03001423 .inv_gain = 787,
1424 .time_stabiliz = 10,
Olivier Grenie03245a52009-12-04 13:27:57 -03001425
Mauro Carvalho Chehab40d1a7c2014-07-04 14:15:34 -03001426 .alpha_level = 0,
1427 .thlock = 118,
Olivier Grenie03245a52009-12-04 13:27:57 -03001428
Mauro Carvalho Chehab40d1a7c2014-07-04 14:15:34 -03001429 .wbd_inv = 0,
1430 .wbd_ref = 3530,
1431 .wbd_sel = 1,
1432 .wbd_alpha = 5,
Olivier Grenie03245a52009-12-04 13:27:57 -03001433
Mauro Carvalho Chehab40d1a7c2014-07-04 14:15:34 -03001434 .agc1_max = 65535,
1435 .agc1_min = 0,
Olivier Grenie03245a52009-12-04 13:27:57 -03001436
Mauro Carvalho Chehab40d1a7c2014-07-04 14:15:34 -03001437 .agc2_max = 65535,
1438 .agc2_min = 0,
Olivier Grenie03245a52009-12-04 13:27:57 -03001439
Mauro Carvalho Chehab40d1a7c2014-07-04 14:15:34 -03001440 .agc1_pt1 = 0,
1441 .agc1_pt2 = 32,
1442 .agc1_pt3 = 114,
1443 .agc1_slope1 = 143,
1444 .agc1_slope2 = 144,
1445 .agc2_pt1 = 114,
1446 .agc2_pt2 = 227,
1447 .agc2_slope1 = 116,
1448 .agc2_slope2 = 117,
Olivier Grenie03245a52009-12-04 13:27:57 -03001449
Mauro Carvalho Chehab40d1a7c2014-07-04 14:15:34 -03001450 .alpha_mant = 28,
1451 .alpha_exp = 26,
1452 .beta_mant = 31,
1453 .beta_exp = 51,
Olivier Grenie03245a52009-12-04 13:27:57 -03001454
Mauro Carvalho Chehab40d1a7c2014-07-04 14:15:34 -03001455 .perform_agc_softsplit = 0,
Olivier Greniebe9bae12011-01-04 05:42:19 -03001456 },
1457 {
Mauro Carvalho Chehab40d1a7c2014-07-04 14:15:34 -03001458 .band_caps = BAND_CBAND,
Olivier Grenie9c783032009-12-07 07:49:40 -03001459 /* 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 -03001460 * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
1461 * 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 -03001462 .setup = (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8)
Olivier Grenie9c783032009-12-07 07:49:40 -03001463 | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),
Olivier Grenie03245a52009-12-04 13:27:57 -03001464
Mauro Carvalho Chehab40d1a7c2014-07-04 14:15:34 -03001465 .inv_gain = 787,
1466 .time_stabiliz = 10,
Olivier Grenie03245a52009-12-04 13:27:57 -03001467
Mauro Carvalho Chehab40d1a7c2014-07-04 14:15:34 -03001468 .alpha_level = 0,
1469 .thlock = 118,
Olivier Grenie03245a52009-12-04 13:27:57 -03001470
Mauro Carvalho Chehab40d1a7c2014-07-04 14:15:34 -03001471 .wbd_inv = 0,
1472 .wbd_ref = 3530,
1473 .wbd_sel = 1,
1474 .wbd_alpha = 5,
Olivier Grenie03245a52009-12-04 13:27:57 -03001475
Mauro Carvalho Chehab40d1a7c2014-07-04 14:15:34 -03001476 .agc1_max = 0,
1477 .agc1_min = 0,
Olivier Grenie03245a52009-12-04 13:27:57 -03001478
Mauro Carvalho Chehab40d1a7c2014-07-04 14:15:34 -03001479 .agc2_max = 65535,
1480 .agc2_min = 0,
Olivier Grenie03245a52009-12-04 13:27:57 -03001481
Mauro Carvalho Chehab40d1a7c2014-07-04 14:15:34 -03001482 .agc1_pt1 = 0,
1483 .agc1_pt2 = 32,
1484 .agc1_pt3 = 114,
1485 .agc1_slope1 = 143,
1486 .agc1_slope2 = 144,
1487 .agc2_pt1 = 114,
1488 .agc2_pt2 = 227,
1489 .agc2_slope1 = 116,
1490 .agc2_slope2 = 117,
Olivier Grenie03245a52009-12-04 13:27:57 -03001491
Mauro Carvalho Chehab40d1a7c2014-07-04 14:15:34 -03001492 .alpha_mant = 28,
1493 .alpha_exp = 26,
1494 .beta_mant = 31,
1495 .beta_exp = 51,
Olivier Grenie03245a52009-12-04 13:27:57 -03001496
Mauro Carvalho Chehab40d1a7c2014-07-04 14:15:34 -03001497 .perform_agc_softsplit = 0,
Olivier Greniebe9bae12011-01-04 05:42:19 -03001498 }
Olivier Grenie03245a52009-12-04 13:27:57 -03001499};
1500
1501static struct dibx000_bandwidth_config dib8090_pll_config_12mhz = {
Mauro Carvalho Chehab40d1a7c2014-07-04 14:15:34 -03001502 .internal = 54000,
1503 .sampling = 13500,
1504
1505 .pll_prediv = 1,
1506 .pll_ratio = 18,
1507 .pll_range = 3,
1508 .pll_reset = 1,
1509 .pll_bypass = 0,
1510
1511 .enable_refdiv = 0,
1512 .bypclk_div = 0,
1513 .IO_CLK_en_core = 1,
1514 .ADClkSrc = 1,
1515 .modulo = 2,
1516
1517 .sad_cfg = (3 << 14) | (1 << 12) | (599 << 0),
1518
1519 .ifreq = (0 << 25) | 0,
1520 .timf = 20199727,
1521
1522 .xtal_hz = 12000000,
Olivier Grenie03245a52009-12-04 13:27:57 -03001523};
1524
1525static int dib8090_get_adc_power(struct dvb_frontend *fe)
1526{
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001527 struct dvb_usb_adapter *adap = fe->dvb->priv;
1528 struct dib0700_adapter_state *state = adap->priv;
1529
1530 return state->dib8000_ops.get_adc_power(fe, 1);
Olivier Grenie03245a52009-12-04 13:27:57 -03001531}
1532
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001533static void dib8090_agc_control(struct dvb_frontend *fe, u8 restart)
1534{
1535 deb_info("AGC control callback: %i\n", restart);
1536 dib0090_dcc_freq(fe, restart);
1537
1538 if (restart == 0) /* before AGC startup */
1539 dib0090_set_dc_servo(fe, 1);
1540}
1541
Olivier Greniebe9bae12011-01-04 05:42:19 -03001542static struct dib8000_config dib809x_dib8000_config[2] = {
1543 {
1544 .output_mpeg2_in_188_bytes = 1,
Olivier Grenie03245a52009-12-04 13:27:57 -03001545
Olivier Greniebe9bae12011-01-04 05:42:19 -03001546 .agc_config_count = 2,
1547 .agc = dib8090_agc_config,
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001548 .agc_control = dib8090_agc_control,
Olivier Greniebe9bae12011-01-04 05:42:19 -03001549 .pll = &dib8090_pll_config_12mhz,
1550 .tuner_is_baseband = 1,
Olivier Grenie03245a52009-12-04 13:27:57 -03001551
Olivier Greniebe9bae12011-01-04 05:42:19 -03001552 .gpio_dir = DIB8000_GPIO_DEFAULT_DIRECTIONS,
1553 .gpio_val = DIB8000_GPIO_DEFAULT_VALUES,
1554 .gpio_pwm_pos = DIB8000_GPIO_DEFAULT_PWM_POS,
Olivier Grenie03245a52009-12-04 13:27:57 -03001555
Olivier Greniebe9bae12011-01-04 05:42:19 -03001556 .hostbus_diversity = 1,
1557 .div_cfg = 0x31,
1558 .output_mode = OUTMODE_MPEG2_FIFO,
1559 .drives = 0x2d98,
1560 .diversity_delay = 48,
1561 .refclksel = 3,
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03001562 }, {
Olivier Greniebe9bae12011-01-04 05:42:19 -03001563 .output_mpeg2_in_188_bytes = 1,
1564
1565 .agc_config_count = 2,
1566 .agc = dib8090_agc_config,
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001567 .agc_control = dib8090_agc_control,
Olivier Greniebe9bae12011-01-04 05:42:19 -03001568 .pll = &dib8090_pll_config_12mhz,
1569 .tuner_is_baseband = 1,
1570
1571 .gpio_dir = DIB8000_GPIO_DEFAULT_DIRECTIONS,
1572 .gpio_val = DIB8000_GPIO_DEFAULT_VALUES,
1573 .gpio_pwm_pos = DIB8000_GPIO_DEFAULT_PWM_POS,
1574
1575 .hostbus_diversity = 1,
1576 .div_cfg = 0x31,
1577 .output_mode = OUTMODE_DIVERSITY,
1578 .drives = 0x2d08,
1579 .diversity_delay = 1,
1580 .refclksel = 3,
1581 }
1582};
1583
1584static struct dib0090_wbd_slope dib8090_wbd_table[] = {
1585 /* max freq ; cold slope ; cold offset ; warm slope ; warm offset ; wbd gain */
1586 { 120, 0, 500, 0, 500, 4 }, /* CBAND */
1587 { 170, 0, 450, 0, 450, 4 }, /* CBAND */
1588 { 380, 48, 373, 28, 259, 6 }, /* VHF */
1589 { 860, 34, 700, 36, 616, 6 }, /* high UHF */
1590 { 0xFFFF, 34, 700, 36, 616, 6 }, /* default */
Olivier Grenie03245a52009-12-04 13:27:57 -03001591};
1592
1593static struct dib0090_config dib809x_dib0090_config = {
Olivier Greniebe9bae12011-01-04 05:42:19 -03001594 .io.pll_bypass = 1,
1595 .io.pll_range = 1,
1596 .io.pll_prediv = 1,
1597 .io.pll_loopdiv = 20,
1598 .io.adc_clock_ratio = 8,
1599 .io.pll_int_loop_filt = 0,
1600 .io.clock_khz = 12000,
1601 .reset = dib80xx_tuner_reset,
1602 .sleep = dib80xx_tuner_sleep,
1603 .clkouttobamse = 1,
1604 .analog_output = 1,
1605 .i2c_address = DEFAULT_DIB0090_I2C_ADDRESS,
1606 .use_pwm_agc = 1,
1607 .clkoutdrive = 1,
1608 .get_adc_power = dib8090_get_adc_power,
1609 .freq_offset_khz_uhf = -63,
Olivier Grenie03245a52009-12-04 13:27:57 -03001610 .freq_offset_khz_vhf = -143,
Olivier Greniebe9bae12011-01-04 05:42:19 -03001611 .wbd = dib8090_wbd_table,
1612 .fref_clock_ratio = 6,
Olivier Grenie03245a52009-12-04 13:27:57 -03001613};
1614
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001615static u8 dib8090_compute_pll_parameters(struct dvb_frontend *fe)
1616{
1617 u8 optimal_pll_ratio = 20;
1618 u32 freq_adc, ratio, rest, max = 0;
1619 u8 pll_ratio;
1620
1621 for (pll_ratio = 17; pll_ratio <= 20; pll_ratio++) {
1622 freq_adc = 12 * pll_ratio * (1 << 8) / 16;
1623 ratio = ((fe->dtv_property_cache.frequency / 1000) * (1 << 8) / 1000) / freq_adc;
1624 rest = ((fe->dtv_property_cache.frequency / 1000) * (1 << 8) / 1000) - ratio * freq_adc;
1625
1626 if (rest > freq_adc / 2)
1627 rest = freq_adc - rest;
1628 deb_info("PLL ratio=%i rest=%i\n", pll_ratio, rest);
1629 if ((rest > max) && (rest > 717)) {
1630 optimal_pll_ratio = pll_ratio;
1631 max = rest;
1632 }
1633 }
1634 deb_info("optimal PLL ratio=%i\n", optimal_pll_ratio);
1635
1636 return optimal_pll_ratio;
1637}
1638
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -03001639static int dib8096_set_param_override(struct dvb_frontend *fe)
Olivier Grenie03245a52009-12-04 13:27:57 -03001640{
Olivier Greniebe9bae12011-01-04 05:42:19 -03001641 struct dvb_usb_adapter *adap = fe->dvb->priv;
1642 struct dib0700_adapter_state *state = adap->priv;
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001643 u8 pll_ratio, band = BAND_OF_FREQUENCY(fe->dtv_property_cache.frequency / 1000);
1644 u16 target, ltgain, rf_gain_limit;
1645 u32 timf;
Olivier Greniebe9bae12011-01-04 05:42:19 -03001646 int ret = 0;
1647 enum frontend_tune_state tune_state = CT_SHUTDOWN;
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001648
1649 switch (band) {
1650 default:
1651 deb_info("Warning : Rf frequency (%iHz) is not in the supported range, using VHF switch ", fe->dtv_property_cache.frequency);
1652 case BAND_VHF:
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001653 state->dib8000_ops.set_gpio(fe, 3, 0, 1);
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001654 break;
1655 case BAND_UHF:
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001656 state->dib8000_ops.set_gpio(fe, 3, 0, 0);
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001657 break;
1658 }
Olivier Grenie03245a52009-12-04 13:27:57 -03001659
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -03001660 ret = state->set_param_save(fe);
Olivier Greniebe9bae12011-01-04 05:42:19 -03001661 if (ret < 0)
1662 return ret;
Olivier Grenie03245a52009-12-04 13:27:57 -03001663
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001664 if (fe->dtv_property_cache.bandwidth_hz != 6000000) {
1665 deb_info("only 6MHz bandwidth is supported\n");
1666 return -EINVAL;
1667 }
Olivier Grenie03245a52009-12-04 13:27:57 -03001668
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001669 /** Update PLL if needed ratio **/
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001670 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 -03001671
1672 /** Get optimize PLL ratio to remove spurious **/
1673 pll_ratio = dib8090_compute_pll_parameters(fe);
1674 if (pll_ratio == 17)
1675 timf = 21387946;
1676 else if (pll_ratio == 18)
1677 timf = 20199727;
1678 else if (pll_ratio == 19)
1679 timf = 19136583;
1680 else
1681 timf = 18179756;
1682
1683 /** Update ratio **/
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001684 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 -03001685
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001686 state->dib8000_ops.ctrl_timf(fe, DEMOD_TIMF_SET, timf);
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001687
1688 if (band != BAND_CBAND) {
1689 /* dib0090_get_wbd_target is returning any possible temperature compensated wbd-target */
1690 target = (dib0090_get_wbd_target(fe) * 8 * 18 / 33 + 1) / 2;
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001691 state->dib8000_ops.set_wbd_ref(fe, target);
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001692 }
Olivier Grenie03245a52009-12-04 13:27:57 -03001693
Olivier Greniebe9bae12011-01-04 05:42:19 -03001694 if (band == BAND_CBAND) {
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03001695 deb_info("tuning in CBAND - soft-AGC startup\n");
1696 dib0090_set_tune_state(fe, CT_AGC_START);
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001697
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03001698 do {
1699 ret = dib0090_gain_control(fe);
1700 msleep(ret);
1701 tune_state = dib0090_get_tune_state(fe);
1702 if (tune_state == CT_AGC_STEP_0)
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001703 state->dib8000_ops.set_gpio(fe, 6, 0, 1);
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03001704 else if (tune_state == CT_AGC_STEP_1) {
1705 dib0090_get_current_gain(fe, NULL, NULL, &rf_gain_limit, &ltgain);
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001706 if (rf_gain_limit < 2000) /* activate the external attenuator in case of very high input power */
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001707 state->dib8000_ops.set_gpio(fe, 6, 0, 0);
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03001708 }
1709 } while (tune_state < CT_AGC_STOP);
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001710
1711 deb_info("switching to PWM AGC\n");
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03001712 dib0090_pwm_gain_reset(fe);
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001713 state->dib8000_ops.pwm_agc_reset(fe);
1714 state->dib8000_ops.set_tune_state(fe, CT_DEMOD_START);
Olivier Greniebe9bae12011-01-04 05:42:19 -03001715 } else {
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001716 /* for everything else than CBAND we are using standard AGC */
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03001717 deb_info("not tuning in CBAND - standard AGC startup\n");
1718 dib0090_pwm_gain_reset(fe);
Olivier Greniebe9bae12011-01-04 05:42:19 -03001719 }
Olivier Grenie03245a52009-12-04 13:27:57 -03001720
Olivier Greniebe9bae12011-01-04 05:42:19 -03001721 return 0;
Olivier Grenie03245a52009-12-04 13:27:57 -03001722}
1723
1724static int dib809x_tuner_attach(struct dvb_usb_adapter *adap)
1725{
Olivier Greniebe9bae12011-01-04 05:42:19 -03001726 struct dib0700_adapter_state *st = adap->priv;
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001727 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 -03001728
Michael Krufky77eed212011-09-06 09:31:57 -03001729 if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c, &dib809x_dib0090_config) == NULL)
Olivier Greniebe9bae12011-01-04 05:42:19 -03001730 return -ENODEV;
Olivier Grenie03245a52009-12-04 13:27:57 -03001731
Michael Krufky77eed212011-09-06 09:31:57 -03001732 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
1733 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib8096_set_param_override;
Olivier Greniebe9bae12011-01-04 05:42:19 -03001734 return 0;
Olivier Grenie03245a52009-12-04 13:27:57 -03001735}
1736
1737static int stk809x_frontend_attach(struct dvb_usb_adapter *adap)
1738{
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001739 struct dib0700_adapter_state *state = adap->priv;
1740
1741 if (!dvb_attach(dib8000_attach, &state->dib8000_ops))
1742 return -ENODEV;
1743
Olivier Grenie03245a52009-12-04 13:27:57 -03001744 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
1745 msleep(10);
1746 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
1747 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
1748 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
1749
1750 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
1751
1752 dib0700_ctrl_clock(adap->dev, 72, 1);
1753
1754 msleep(10);
1755 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
1756 msleep(10);
1757 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
1758
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001759 state->dib8000_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 18, 0x80, 0);
Olivier Grenie03245a52009-12-04 13:27:57 -03001760
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001761 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 -03001762
Michael Krufky77eed212011-09-06 09:31:57 -03001763 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Olivier Grenie03245a52009-12-04 13:27:57 -03001764}
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001765
Olivier Greniebe9bae12011-01-04 05:42:19 -03001766static int nim8096md_tuner_attach(struct dvb_usb_adapter *adap)
1767{
1768 struct dib0700_adapter_state *st = adap->priv;
1769 struct i2c_adapter *tun_i2c;
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001770 struct dvb_frontend *fe_slave = st->dib8000_ops.get_slave_frontend(adap->fe_adap[0].fe, 1);
Olivier Greniebe9bae12011-01-04 05:42:19 -03001771
1772 if (fe_slave) {
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001773 tun_i2c = st->dib8000_ops.get_i2c_master(fe_slave, DIBX000_I2C_INTERFACE_TUNER, 1);
Olivier Greniebe9bae12011-01-04 05:42:19 -03001774 if (dvb_attach(dib0090_register, fe_slave, tun_i2c, &dib809x_dib0090_config) == NULL)
1775 return -ENODEV;
Michael Krufky77eed212011-09-06 09:31:57 -03001776 fe_slave->dvb = adap->fe_adap[0].fe->dvb;
Olivier Greniebe9bae12011-01-04 05:42:19 -03001777 fe_slave->ops.tuner_ops.set_params = dib8096_set_param_override;
1778 }
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001779 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 -03001780 if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c, &dib809x_dib0090_config) == NULL)
Olivier Greniebe9bae12011-01-04 05:42:19 -03001781 return -ENODEV;
1782
Michael Krufky77eed212011-09-06 09:31:57 -03001783 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
1784 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib8096_set_param_override;
Olivier Greniebe9bae12011-01-04 05:42:19 -03001785
1786 return 0;
1787}
1788
1789static int nim8096md_frontend_attach(struct dvb_usb_adapter *adap)
1790{
1791 struct dvb_frontend *fe_slave;
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001792 struct dib0700_adapter_state *state = adap->priv;
1793
1794 if (!dvb_attach(dib8000_attach, &state->dib8000_ops))
1795 return -ENODEV;
Olivier Greniebe9bae12011-01-04 05:42:19 -03001796
1797 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03001798 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03001799 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
1800 msleep(1000);
1801 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
1802 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
1803 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
1804
1805 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
1806
1807 dib0700_ctrl_clock(adap->dev, 72, 1);
1808
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03001809 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03001810 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03001811 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03001812 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
1813
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001814 state->dib8000_ops.i2c_enumeration(&adap->dev->i2c_adap, 2, 18, 0x80, 0);
Olivier Greniebe9bae12011-01-04 05:42:19 -03001815
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001816 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 -03001817 if (adap->fe_adap[0].fe == NULL)
Olivier Greniebe9bae12011-01-04 05:42:19 -03001818 return -ENODEV;
1819
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001820 /* Needed to increment refcount */
1821 if (!dvb_attach(dib8000_attach, &state->dib8000_ops))
1822 return -ENODEV;
1823
1824 fe_slave = state->dib8000_ops.init(&adap->dev->i2c_adap, 0x82, &dib809x_dib8000_config[1]);
1825 state->dib8000_ops.set_slave_frontend(adap->fe_adap[0].fe, fe_slave);
Olivier Greniebe9bae12011-01-04 05:42:19 -03001826
1827 return fe_slave == NULL ? -ENODEV : 0;
1828}
1829
Olivier Grenie88f3a352011-08-10 05:28:38 -03001830/* TFE8096P */
1831static struct dibx000_agc_config dib8096p_agc_config[2] = {
1832 {
1833 .band_caps = BAND_UHF,
1834 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0,
1835 P_agc_freq_pwm_div=1, P_agc_inv_pwm1=0,
1836 P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
1837 P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5,
1838 P_agc_write=0 */
1839 .setup = (0 << 15) | (0 << 14) | (5 << 11)
1840 | (0 << 10) | (0 << 9) | (0 << 8) | (3 << 5)
1841 | (0 << 4) | (5 << 1) | (0 << 0),
1842
1843 .inv_gain = 684,
1844 .time_stabiliz = 10,
1845
1846 .alpha_level = 0,
1847 .thlock = 118,
1848
1849 .wbd_inv = 0,
1850 .wbd_ref = 1200,
1851 .wbd_sel = 3,
1852 .wbd_alpha = 5,
1853
1854 .agc1_max = 65535,
1855 .agc1_min = 0,
1856
1857 .agc2_max = 32767,
1858 .agc2_min = 0,
1859
1860 .agc1_pt1 = 0,
1861 .agc1_pt2 = 0,
1862 .agc1_pt3 = 105,
1863 .agc1_slope1 = 0,
1864 .agc1_slope2 = 156,
1865 .agc2_pt1 = 105,
1866 .agc2_pt2 = 255,
1867 .agc2_slope1 = 54,
1868 .agc2_slope2 = 0,
1869
1870 .alpha_mant = 28,
1871 .alpha_exp = 26,
1872 .beta_mant = 31,
1873 .beta_exp = 51,
1874
1875 .perform_agc_softsplit = 0,
1876 } , {
1877 .band_caps = BAND_FM | BAND_VHF | BAND_CBAND,
1878 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0,
1879 P_agc_freq_pwm_div=1, P_agc_inv_pwm1=0,
1880 P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
1881 P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5,
1882 P_agc_write=0 */
1883 .setup = (0 << 15) | (0 << 14) | (5 << 11)
1884 | (0 << 10) | (0 << 9) | (0 << 8) | (3 << 5)
1885 | (0 << 4) | (5 << 1) | (0 << 0),
1886
1887 .inv_gain = 732,
1888 .time_stabiliz = 10,
1889
1890 .alpha_level = 0,
1891 .thlock = 118,
1892
1893 .wbd_inv = 0,
1894 .wbd_ref = 1200,
1895 .wbd_sel = 3,
1896 .wbd_alpha = 5,
1897
1898 .agc1_max = 65535,
1899 .agc1_min = 0,
1900
1901 .agc2_max = 32767,
1902 .agc2_min = 0,
1903
1904 .agc1_pt1 = 0,
1905 .agc1_pt2 = 0,
1906 .agc1_pt3 = 98,
1907 .agc1_slope1 = 0,
1908 .agc1_slope2 = 167,
1909 .agc2_pt1 = 98,
1910 .agc2_pt2 = 255,
1911 .agc2_slope1 = 52,
1912 .agc2_slope2 = 0,
1913
1914 .alpha_mant = 28,
1915 .alpha_exp = 26,
1916 .beta_mant = 31,
1917 .beta_exp = 51,
1918
1919 .perform_agc_softsplit = 0,
1920 }
1921};
1922
1923static struct dibx000_bandwidth_config dib8096p_clock_config_12_mhz = {
1924 108000, 13500,
1925 1, 9, 1, 0, 0,
1926 0, 0, 0, 0, 2,
1927 (3 << 14) | (1 << 12) | (524 << 0),
1928 (0 << 25) | 0,
1929 20199729,
1930 12000000,
1931};
1932
1933static struct dib8000_config tfe8096p_dib8000_config = {
1934 .output_mpeg2_in_188_bytes = 1,
1935 .hostbus_diversity = 1,
1936 .update_lna = NULL,
1937
1938 .agc_config_count = 2,
1939 .agc = dib8096p_agc_config,
1940 .pll = &dib8096p_clock_config_12_mhz,
1941
1942 .gpio_dir = DIB8000_GPIO_DEFAULT_DIRECTIONS,
1943 .gpio_val = DIB8000_GPIO_DEFAULT_VALUES,
1944 .gpio_pwm_pos = DIB8000_GPIO_DEFAULT_PWM_POS,
1945
1946 .agc_control = NULL,
1947 .diversity_delay = 48,
1948 .output_mode = OUTMODE_MPEG2_FIFO,
1949 .enMpegOutput = 1,
1950};
1951
1952static struct dib0090_wbd_slope dib8096p_wbd_table[] = {
1953 { 380, 81, 850, 64, 540, 4},
1954 { 860, 51, 866, 21, 375, 4},
1955 {1700, 0, 250, 0, 100, 6},
1956 {2600, 0, 250, 0, 100, 6},
1957 { 0xFFFF, 0, 0, 0, 0, 0},
1958};
1959
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001960static struct dib0090_config tfe8096p_dib0090_config = {
Olivier Grenie88f3a352011-08-10 05:28:38 -03001961 .io.clock_khz = 12000,
1962 .io.pll_bypass = 0,
1963 .io.pll_range = 0,
1964 .io.pll_prediv = 3,
1965 .io.pll_loopdiv = 6,
1966 .io.adc_clock_ratio = 0,
1967 .io.pll_int_loop_filt = 0,
Olivier Grenie88f3a352011-08-10 05:28:38 -03001968
1969 .freq_offset_khz_uhf = -143,
1970 .freq_offset_khz_vhf = -143,
1971
1972 .get_adc_power = dib8090_get_adc_power,
1973
1974 .clkouttobamse = 1,
1975 .analog_output = 0,
1976
1977 .wbd_vhf_offset = 0,
1978 .wbd_cband_offset = 0,
1979 .use_pwm_agc = 1,
1980 .clkoutdrive = 0,
1981
1982 .fref_clock_ratio = 1,
1983
Olivier Grenie88f3a352011-08-10 05:28:38 -03001984 .ls_cfg_pad_drv = 0,
1985 .data_tx_drv = 0,
1986 .low_if = NULL,
1987 .in_soc = 1,
1988 .force_cband_input = 0,
1989};
1990
1991struct dibx090p_adc {
1992 u32 freq; /* RF freq MHz */
1993 u32 timf; /* New Timf */
1994 u32 pll_loopdiv; /* New prediv */
1995 u32 pll_prediv; /* New loopdiv */
1996};
1997
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001998struct dibx090p_best_adc {
1999 u32 timf;
2000 u32 pll_loopdiv;
2001 u32 pll_prediv;
Olivier Grenie88f3a352011-08-10 05:28:38 -03002002};
2003
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03002004static int dib8096p_get_best_sampling(struct dvb_frontend *fe, struct dibx090p_best_adc *adc)
2005{
2006 u8 spur = 0, prediv = 0, loopdiv = 0, min_prediv = 1, max_prediv = 1;
2007 u16 xtal = 12000;
2008 u16 fcp_min = 1900; /* PLL, Minimum Frequency of phase comparator (KHz) */
2009 u16 fcp_max = 20000; /* PLL, Maximum Frequency of phase comparator (KHz) */
2010 u32 fmem_max = 140000; /* 140MHz max SDRAM freq */
2011 u32 fdem_min = 66000;
2012 u32 fcp = 0, fs = 0, fdem = 0, fmem = 0;
2013 u32 harmonic_id = 0;
2014
2015 adc->timf = 0;
2016 adc->pll_loopdiv = loopdiv;
2017 adc->pll_prediv = prediv;
2018
2019 deb_info("bandwidth = %d", fe->dtv_property_cache.bandwidth_hz);
2020
2021 /* Find Min and Max prediv */
2022 while ((xtal / max_prediv) >= fcp_min)
2023 max_prediv++;
2024
2025 max_prediv--;
2026 min_prediv = max_prediv;
2027 while ((xtal / min_prediv) <= fcp_max) {
2028 min_prediv--;
2029 if (min_prediv == 1)
2030 break;
2031 }
2032 deb_info("MIN prediv = %d : MAX prediv = %d", min_prediv, max_prediv);
2033
2034 min_prediv = 1;
2035
2036 for (prediv = min_prediv; prediv < max_prediv; prediv++) {
2037 fcp = xtal / prediv;
2038 if (fcp > fcp_min && fcp < fcp_max) {
2039 for (loopdiv = 1; loopdiv < 64; loopdiv++) {
2040 fmem = ((xtal/prediv) * loopdiv);
2041 fdem = fmem / 2;
2042 fs = fdem / 4;
2043
2044 /* test min/max system restrictions */
2045 if ((fdem >= fdem_min) && (fmem <= fmem_max) && (fs >= fe->dtv_property_cache.bandwidth_hz / 1000)) {
2046 spur = 0;
2047 /* test fs harmonics positions */
2048 for (harmonic_id = (fe->dtv_property_cache.frequency / (1000 * fs)); harmonic_id <= ((fe->dtv_property_cache.frequency / (1000 * fs)) + 1); harmonic_id++) {
2049 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)))) {
2050 spur = 1;
2051 break;
2052 }
2053 }
2054
2055 if (!spur) {
2056 adc->pll_loopdiv = loopdiv;
2057 adc->pll_prediv = prediv;
2058 adc->timf = (4260880253U / fdem) * (1 << 8);
2059 adc->timf += ((4260880253U % fdem) << 8) / fdem;
2060
2061 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);
2062 break;
2063 }
2064 }
2065 }
2066 }
2067 if (!spur)
2068 break;
2069 }
2070
2071 if (adc->pll_loopdiv == 0 && adc->pll_prediv == 0)
2072 return -EINVAL;
2073 return 0;
2074}
2075
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -03002076static int dib8096p_agc_startup(struct dvb_frontend *fe)
Olivier Grenie88f3a352011-08-10 05:28:38 -03002077{
2078 struct dvb_usb_adapter *adap = fe->dvb->priv;
2079 struct dib0700_adapter_state *state = adap->priv;
2080 struct dibx000_bandwidth_config pll;
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03002081 struct dibx090p_best_adc adc;
Olivier Grenie88f3a352011-08-10 05:28:38 -03002082 u16 target;
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03002083 int ret;
Olivier Grenie88f3a352011-08-10 05:28:38 -03002084
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -03002085 ret = state->set_param_save(fe);
Olivier Grenie88f3a352011-08-10 05:28:38 -03002086 if (ret < 0)
2087 return ret;
2088 memset(&pll, 0, sizeof(struct dibx000_bandwidth_config));
2089
2090 dib0090_pwm_gain_reset(fe);
2091 /* dib0090_get_wbd_target is returning any possible
2092 temperature compensated wbd-target */
2093 target = (dib0090_get_wbd_target(fe) * 8 + 1) / 2;
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03002094 state->dib8000_ops.set_wbd_ref(fe, target);
Olivier Grenie88f3a352011-08-10 05:28:38 -03002095
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03002096 if (dib8096p_get_best_sampling(fe, &adc) == 0) {
2097 pll.pll_ratio = adc.pll_loopdiv;
2098 pll.pll_prediv = adc.pll_prediv;
Olivier Grenie88f3a352011-08-10 05:28:38 -03002099
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03002100 dib0700_set_i2c_speed(adap->dev, 200);
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03002101 state->dib8000_ops.update_pll(fe, &pll, fe->dtv_property_cache.bandwidth_hz / 1000, 0);
2102 state->dib8000_ops.ctrl_timf(fe, DEMOD_TIMF_SET, adc.timf);
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03002103 dib0700_set_i2c_speed(adap->dev, 1000);
Olivier Grenie88f3a352011-08-10 05:28:38 -03002104 }
2105 return 0;
2106}
2107
2108static int tfe8096p_frontend_attach(struct dvb_usb_adapter *adap)
2109{
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03002110 struct dib0700_state *st = adap->dev->priv;
2111 u32 fw_version;
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03002112 struct dib0700_adapter_state *state = adap->priv;
2113
2114 if (!dvb_attach(dib8000_attach, &state->dib8000_ops))
2115 return -ENODEV;
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03002116
2117 dib0700_get_version(adap->dev, NULL, NULL, &fw_version, NULL);
2118 if (fw_version >= 0x10200)
2119 st->fw_use_new_i2c_api = 1;
2120
Olivier Grenie88f3a352011-08-10 05:28:38 -03002121 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
2122 msleep(20);
2123 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
2124 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
2125 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
2126
2127 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
2128
2129 dib0700_ctrl_clock(adap->dev, 72, 1);
2130
2131 msleep(20);
2132 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
2133 msleep(20);
2134 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
2135
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03002136 state->dib8000_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 0x10, 0x80, 1);
Olivier Grenie88f3a352011-08-10 05:28:38 -03002137
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03002138 adap->fe_adap[0].fe = state->dib8000_ops.init(&adap->dev->i2c_adap,
2139 0x80, &tfe8096p_dib8000_config);
Olivier Grenie88f3a352011-08-10 05:28:38 -03002140
2141 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
2142}
2143
2144static int tfe8096p_tuner_attach(struct dvb_usb_adapter *adap)
2145{
2146 struct dib0700_adapter_state *st = adap->priv;
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03002147 struct i2c_adapter *tun_i2c = st->dib8000_ops.get_i2c_tuner(adap->fe_adap[0].fe);
2148
2149 tfe8096p_dib0090_config.reset = st->dib8000_ops.tuner_sleep;
2150 tfe8096p_dib0090_config.sleep = st->dib8000_ops.tuner_sleep;
2151 tfe8096p_dib0090_config.wbd = dib8096p_wbd_table;
Olivier Grenie88f3a352011-08-10 05:28:38 -03002152
2153 if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c,
2154 &tfe8096p_dib0090_config) == NULL)
2155 return -ENODEV;
2156
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03002157 st->dib8000_ops.set_gpio(adap->fe_adap[0].fe, 8, 0, 1);
Olivier Grenie88f3a352011-08-10 05:28:38 -03002158
2159 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
2160 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib8096p_agc_startup;
2161 return 0;
2162}
2163
Olivier Greniebe9bae12011-01-04 05:42:19 -03002164/* STK9090M */
2165static int dib90x0_pid_filter(struct dvb_usb_adapter *adapter, int index, u16 pid, int onoff)
2166{
Michael Krufky77eed212011-09-06 09:31:57 -03002167 return dib9000_fw_pid_filter(adapter->fe_adap[0].fe, index, pid, onoff);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002168}
2169
2170static int dib90x0_pid_filter_ctrl(struct dvb_usb_adapter *adapter, int onoff)
2171{
Michael Krufky77eed212011-09-06 09:31:57 -03002172 return dib9000_fw_pid_filter_ctrl(adapter->fe_adap[0].fe, onoff);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002173}
2174
2175static int dib90x0_tuner_reset(struct dvb_frontend *fe, int onoff)
2176{
2177 return dib9000_set_gpio(fe, 5, 0, !onoff);
2178}
2179
2180static int dib90x0_tuner_sleep(struct dvb_frontend *fe, int onoff)
2181{
2182 return dib9000_set_gpio(fe, 0, 0, onoff);
2183}
2184
2185static int dib01x0_pmu_update(struct i2c_adapter *i2c, u16 *data, u8 len)
2186{
2187 u8 wb[4] = { 0xc >> 8, 0xc & 0xff, 0, 0 };
2188 u8 rb[2];
2189 struct i2c_msg msg[2] = {
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002190 {.addr = 0x1e >> 1, .flags = 0, .buf = wb, .len = 2},
2191 {.addr = 0x1e >> 1, .flags = I2C_M_RD, .buf = rb, .len = 2},
Olivier Greniebe9bae12011-01-04 05:42:19 -03002192 };
2193 u8 index_data;
2194
2195 dibx000_i2c_set_speed(i2c, 250);
2196
2197 if (i2c_transfer(i2c, msg, 2) != 2)
2198 return -EIO;
2199
2200 switch (rb[0] << 8 | rb[1]) {
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002201 case 0:
Olivier Greniebe9bae12011-01-04 05:42:19 -03002202 deb_info("Found DiB0170 rev1: This version of DiB0170 is not supported any longer.\n");
2203 return -EIO;
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002204 case 1:
Olivier Greniebe9bae12011-01-04 05:42:19 -03002205 deb_info("Found DiB0170 rev2");
2206 break;
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002207 case 2:
Olivier Greniebe9bae12011-01-04 05:42:19 -03002208 deb_info("Found DiB0190 rev2");
2209 break;
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002210 default:
Olivier Greniebe9bae12011-01-04 05:42:19 -03002211 deb_info("DiB01x0 not found");
2212 return -EIO;
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002213 }
Olivier Greniebe9bae12011-01-04 05:42:19 -03002214
2215 for (index_data = 0; index_data < len; index_data += 2) {
2216 wb[2] = (data[index_data + 1] >> 8) & 0xff;
2217 wb[3] = (data[index_data + 1]) & 0xff;
2218
2219 if (data[index_data] == 0) {
2220 wb[0] = (data[index_data] >> 8) & 0xff;
2221 wb[1] = (data[index_data]) & 0xff;
2222 msg[0].len = 2;
2223 if (i2c_transfer(i2c, msg, 2) != 2)
2224 return -EIO;
2225 wb[2] |= rb[0];
2226 wb[3] |= rb[1] & ~(3 << 4);
2227 }
2228
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002229 wb[0] = (data[index_data] >> 8)&0xff;
2230 wb[1] = (data[index_data])&0xff;
Olivier Greniebe9bae12011-01-04 05:42:19 -03002231 msg[0].len = 4;
2232 if (i2c_transfer(i2c, &msg[0], 1) != 1)
2233 return -EIO;
2234 }
2235 return 0;
2236}
2237
2238static struct dib9000_config stk9090m_config = {
2239 .output_mpeg2_in_188_bytes = 1,
2240 .output_mode = OUTMODE_MPEG2_FIFO,
2241 .vcxo_timer = 279620,
2242 .timing_frequency = 20452225,
2243 .demod_clock_khz = 60000,
2244 .xtal_clock_khz = 30000,
2245 .if_drives = (0 << 15) | (1 << 13) | (0 << 12) | (3 << 10) | (0 << 9) | (1 << 7) | (0 << 6) | (0 << 4) | (1 << 3) | (1 << 1) | (0),
2246 .subband = {
2247 2,
2248 {
2249 { 240, { BOARD_GPIO_COMPONENT_DEMOD, BOARD_GPIO_FUNCTION_SUBBAND_GPIO, 0x0008, 0x0000, 0x0008 } }, /* GPIO 3 to 1 for VHF */
2250 { 890, { BOARD_GPIO_COMPONENT_DEMOD, BOARD_GPIO_FUNCTION_SUBBAND_GPIO, 0x0008, 0x0000, 0x0000 } }, /* GPIO 3 to 0 for UHF */
2251 { 0 },
2252 },
2253 },
2254 .gpio_function = {
2255 { .component = BOARD_GPIO_COMPONENT_DEMOD, .function = BOARD_GPIO_FUNCTION_COMPONENT_ON, .mask = 0x10 | 0x21, .direction = 0 & ~0x21, .value = (0x10 & ~0x1) | 0x20 },
2256 { .component = BOARD_GPIO_COMPONENT_DEMOD, .function = BOARD_GPIO_FUNCTION_COMPONENT_OFF, .mask = 0x10 | 0x21, .direction = 0 & ~0x21, .value = 0 | 0x21 },
2257 },
2258};
2259
2260static struct dib9000_config nim9090md_config[2] = {
2261 {
2262 .output_mpeg2_in_188_bytes = 1,
2263 .output_mode = OUTMODE_MPEG2_FIFO,
2264 .vcxo_timer = 279620,
2265 .timing_frequency = 20452225,
2266 .demod_clock_khz = 60000,
2267 .xtal_clock_khz = 30000,
2268 .if_drives = (0 << 15) | (1 << 13) | (0 << 12) | (3 << 10) | (0 << 9) | (1 << 7) | (0 << 6) | (0 << 4) | (1 << 3) | (1 << 1) | (0),
2269 }, {
2270 .output_mpeg2_in_188_bytes = 1,
2271 .output_mode = OUTMODE_DIVERSITY,
2272 .vcxo_timer = 279620,
2273 .timing_frequency = 20452225,
2274 .demod_clock_khz = 60000,
2275 .xtal_clock_khz = 30000,
2276 .if_drives = (0 << 15) | (1 << 13) | (0 << 12) | (3 << 10) | (0 << 9) | (1 << 7) | (0 << 6) | (0 << 4) | (1 << 3) | (1 << 1) | (0),
2277 .subband = {
2278 2,
2279 {
2280 { 240, { BOARD_GPIO_COMPONENT_DEMOD, BOARD_GPIO_FUNCTION_SUBBAND_GPIO, 0x0006, 0x0000, 0x0006 } }, /* GPIO 1 and 2 to 1 for VHF */
2281 { 890, { BOARD_GPIO_COMPONENT_DEMOD, BOARD_GPIO_FUNCTION_SUBBAND_GPIO, 0x0006, 0x0000, 0x0000 } }, /* GPIO 1 and 2 to 0 for UHF */
2282 { 0 },
2283 },
2284 },
2285 .gpio_function = {
2286 { .component = BOARD_GPIO_COMPONENT_DEMOD, .function = BOARD_GPIO_FUNCTION_COMPONENT_ON, .mask = 0x10 | 0x21, .direction = 0 & ~0x21, .value = (0x10 & ~0x1) | 0x20 },
2287 { .component = BOARD_GPIO_COMPONENT_DEMOD, .function = BOARD_GPIO_FUNCTION_COMPONENT_OFF, .mask = 0x10 | 0x21, .direction = 0 & ~0x21, .value = 0 | 0x21 },
2288 },
2289 }
2290};
2291
2292static struct dib0090_config dib9090_dib0090_config = {
2293 .io.pll_bypass = 0,
2294 .io.pll_range = 1,
2295 .io.pll_prediv = 1,
2296 .io.pll_loopdiv = 8,
2297 .io.adc_clock_ratio = 8,
2298 .io.pll_int_loop_filt = 0,
2299 .io.clock_khz = 30000,
2300 .reset = dib90x0_tuner_reset,
2301 .sleep = dib90x0_tuner_sleep,
2302 .clkouttobamse = 0,
2303 .analog_output = 0,
2304 .use_pwm_agc = 0,
2305 .clkoutdrive = 0,
2306 .freq_offset_khz_uhf = 0,
2307 .freq_offset_khz_vhf = 0,
2308};
2309
2310static struct dib0090_config nim9090md_dib0090_config[2] = {
2311 {
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 = 1,
2322 .analog_output = 0,
2323 .use_pwm_agc = 0,
2324 .clkoutdrive = 0,
2325 .freq_offset_khz_uhf = 0,
2326 .freq_offset_khz_vhf = 0,
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002327 }, {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002328 .io.pll_bypass = 0,
2329 .io.pll_range = 1,
2330 .io.pll_prediv = 1,
2331 .io.pll_loopdiv = 8,
2332 .io.adc_clock_ratio = 8,
2333 .io.pll_int_loop_filt = 0,
2334 .io.clock_khz = 30000,
2335 .reset = dib90x0_tuner_reset,
2336 .sleep = dib90x0_tuner_sleep,
2337 .clkouttobamse = 0,
2338 .analog_output = 0,
2339 .use_pwm_agc = 0,
2340 .clkoutdrive = 0,
2341 .freq_offset_khz_uhf = 0,
2342 .freq_offset_khz_vhf = 0,
2343 }
2344};
2345
2346
2347static int stk9090m_frontend_attach(struct dvb_usb_adapter *adap)
2348{
2349 struct dib0700_adapter_state *state = adap->priv;
2350 struct dib0700_state *st = adap->dev->priv;
2351 u32 fw_version;
2352
2353 /* Make use of the new i2c functions from FW 1.20 */
2354 dib0700_get_version(adap->dev, NULL, NULL, &fw_version, NULL);
2355 if (fw_version >= 0x10200)
2356 st->fw_use_new_i2c_api = 1;
2357 dib0700_set_i2c_speed(adap->dev, 340);
2358
2359 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002360 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002361 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
2362 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
2363 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
2364 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
2365
2366 dib0700_ctrl_clock(adap->dev, 72, 1);
2367
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002368 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002369 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002370 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002371 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
2372
2373 dib9000_i2c_enumeration(&adap->dev->i2c_adap, 1, 0x10, 0x80);
2374
2375 if (request_firmware(&state->frontend_firmware, "dib9090.fw", &adap->dev->udev->dev)) {
2376 deb_info("%s: Upload failed. (file not found?)\n", __func__);
2377 return -ENODEV;
2378 } else {
2379 deb_info("%s: firmware read %Zu bytes.\n", __func__, state->frontend_firmware->size);
2380 }
2381 stk9090m_config.microcode_B_fe_size = state->frontend_firmware->size;
2382 stk9090m_config.microcode_B_fe_buffer = state->frontend_firmware->data;
2383
Michael Krufky77eed212011-09-06 09:31:57 -03002384 adap->fe_adap[0].fe = dvb_attach(dib9000_attach, &adap->dev->i2c_adap, 0x80, &stk9090m_config);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002385
Michael Krufky77eed212011-09-06 09:31:57 -03002386 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Olivier Greniebe9bae12011-01-04 05:42:19 -03002387}
2388
2389static int dib9090_tuner_attach(struct dvb_usb_adapter *adap)
2390{
2391 struct dib0700_adapter_state *state = adap->priv;
Michael Krufky77eed212011-09-06 09:31:57 -03002392 struct i2c_adapter *i2c = dib9000_get_tuner_interface(adap->fe_adap[0].fe);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002393 u16 data_dib190[10] = {
2394 1, 0x1374,
2395 2, 0x01a2,
2396 7, 0x0020,
2397 0, 0x00ef,
2398 8, 0x0486,
2399 };
2400
Michael Krufky77eed212011-09-06 09:31:57 -03002401 if (dvb_attach(dib0090_fw_register, adap->fe_adap[0].fe, i2c, &dib9090_dib0090_config) == NULL)
Olivier Greniebe9bae12011-01-04 05:42:19 -03002402 return -ENODEV;
Michael Krufky77eed212011-09-06 09:31:57 -03002403 i2c = dib9000_get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_GPIO_1_2, 0);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002404 if (dib01x0_pmu_update(i2c, data_dib190, 10) != 0)
2405 return -ENODEV;
Olivier Grenied1190022011-08-29 10:58:47 -03002406 dib0700_set_i2c_speed(adap->dev, 1500);
Michael Krufky77eed212011-09-06 09:31:57 -03002407 if (dib9000_firmware_post_pll_init(adap->fe_adap[0].fe) < 0)
Olivier Greniebe9bae12011-01-04 05:42:19 -03002408 return -ENODEV;
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002409 release_firmware(state->frontend_firmware);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002410 return 0;
2411}
2412
2413static int nim9090md_frontend_attach(struct dvb_usb_adapter *adap)
2414{
2415 struct dib0700_adapter_state *state = adap->priv;
2416 struct dib0700_state *st = adap->dev->priv;
2417 struct i2c_adapter *i2c;
2418 struct dvb_frontend *fe_slave;
2419 u32 fw_version;
2420
2421 /* Make use of the new i2c functions from FW 1.20 */
2422 dib0700_get_version(adap->dev, NULL, NULL, &fw_version, NULL);
2423 if (fw_version >= 0x10200)
2424 st->fw_use_new_i2c_api = 1;
2425 dib0700_set_i2c_speed(adap->dev, 340);
2426
2427 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002428 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002429 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
2430 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
2431 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
2432 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
2433
2434 dib0700_ctrl_clock(adap->dev, 72, 1);
2435
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002436 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002437 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002438 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002439 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
2440
2441 if (request_firmware(&state->frontend_firmware, "dib9090.fw", &adap->dev->udev->dev)) {
2442 deb_info("%s: Upload failed. (file not found?)\n", __func__);
2443 return -EIO;
2444 } else {
2445 deb_info("%s: firmware read %Zu bytes.\n", __func__, state->frontend_firmware->size);
2446 }
2447 nim9090md_config[0].microcode_B_fe_size = state->frontend_firmware->size;
2448 nim9090md_config[0].microcode_B_fe_buffer = state->frontend_firmware->data;
2449 nim9090md_config[1].microcode_B_fe_size = state->frontend_firmware->size;
2450 nim9090md_config[1].microcode_B_fe_buffer = state->frontend_firmware->data;
2451
2452 dib9000_i2c_enumeration(&adap->dev->i2c_adap, 1, 0x20, 0x80);
Michael Krufky77eed212011-09-06 09:31:57 -03002453 adap->fe_adap[0].fe = dvb_attach(dib9000_attach, &adap->dev->i2c_adap, 0x80, &nim9090md_config[0]);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002454
Michael Krufky77eed212011-09-06 09:31:57 -03002455 if (adap->fe_adap[0].fe == NULL)
Olivier Greniebe9bae12011-01-04 05:42:19 -03002456 return -ENODEV;
2457
Michael Krufky77eed212011-09-06 09:31:57 -03002458 i2c = dib9000_get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_GPIO_3_4, 0);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002459 dib9000_i2c_enumeration(i2c, 1, 0x12, 0x82);
2460
2461 fe_slave = dvb_attach(dib9000_attach, i2c, 0x82, &nim9090md_config[1]);
Michael Krufky77eed212011-09-06 09:31:57 -03002462 dib9000_set_slave_frontend(adap->fe_adap[0].fe, fe_slave);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002463
2464 return fe_slave == NULL ? -ENODEV : 0;
2465}
2466
2467static int nim9090md_tuner_attach(struct dvb_usb_adapter *adap)
2468{
2469 struct dib0700_adapter_state *state = adap->priv;
2470 struct i2c_adapter *i2c;
2471 struct dvb_frontend *fe_slave;
2472 u16 data_dib190[10] = {
2473 1, 0x5374,
2474 2, 0x01ae,
2475 7, 0x0020,
2476 0, 0x00ef,
2477 8, 0x0406,
2478 };
Michael Krufky77eed212011-09-06 09:31:57 -03002479 i2c = dib9000_get_tuner_interface(adap->fe_adap[0].fe);
2480 if (dvb_attach(dib0090_fw_register, adap->fe_adap[0].fe, i2c, &nim9090md_dib0090_config[0]) == NULL)
Olivier Greniebe9bae12011-01-04 05:42:19 -03002481 return -ENODEV;
Michael Krufky77eed212011-09-06 09:31:57 -03002482 i2c = dib9000_get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_GPIO_1_2, 0);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002483 if (dib01x0_pmu_update(i2c, data_dib190, 10) < 0)
2484 return -ENODEV;
Olivier Grenied1190022011-08-29 10:58:47 -03002485
2486 dib0700_set_i2c_speed(adap->dev, 1500);
Michael Krufky77eed212011-09-06 09:31:57 -03002487 if (dib9000_firmware_post_pll_init(adap->fe_adap[0].fe) < 0)
Olivier Greniebe9bae12011-01-04 05:42:19 -03002488 return -ENODEV;
2489
Michael Krufky77eed212011-09-06 09:31:57 -03002490 fe_slave = dib9000_get_slave_frontend(adap->fe_adap[0].fe, 1);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002491 if (fe_slave != NULL) {
Michael Krufky77eed212011-09-06 09:31:57 -03002492 i2c = dib9000_get_component_bus_interface(adap->fe_adap[0].fe);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002493 dib9000_set_i2c_adapter(fe_slave, i2c);
2494
2495 i2c = dib9000_get_tuner_interface(fe_slave);
2496 if (dvb_attach(dib0090_fw_register, fe_slave, i2c, &nim9090md_dib0090_config[1]) == NULL)
2497 return -ENODEV;
Michael Krufky77eed212011-09-06 09:31:57 -03002498 fe_slave->dvb = adap->fe_adap[0].fe->dvb;
Olivier Grenied1190022011-08-29 10:58:47 -03002499 dib9000_fw_set_component_bus_speed(adap->fe_adap[0].fe, 1500);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002500 if (dib9000_firmware_post_pll_init(fe_slave) < 0)
2501 return -ENODEV;
2502 }
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002503 release_firmware(state->frontend_firmware);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002504
2505 return 0;
2506}
2507
2508/* NIM7090 */
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03002509static int dib7090p_get_best_sampling(struct dvb_frontend *fe , struct dibx090p_best_adc *adc)
Olivier Greniebe9bae12011-01-04 05:42:19 -03002510{
2511 u8 spur = 0, prediv = 0, loopdiv = 0, min_prediv = 1, max_prediv = 1;
2512
2513 u16 xtal = 12000;
2514 u32 fcp_min = 1900; /* PLL Minimum Frequency comparator KHz */
2515 u32 fcp_max = 20000; /* PLL Maximum Frequency comparator KHz */
2516 u32 fdem_max = 76000;
2517 u32 fdem_min = 69500;
2518 u32 fcp = 0, fs = 0, fdem = 0;
2519 u32 harmonic_id = 0;
2520
2521 adc->pll_loopdiv = loopdiv;
2522 adc->pll_prediv = prediv;
2523 adc->timf = 0;
2524
2525 deb_info("bandwidth = %d fdem_min =%d", fe->dtv_property_cache.bandwidth_hz, fdem_min);
2526
2527 /* Find Min and Max prediv */
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002528 while ((xtal/max_prediv) >= fcp_min)
Olivier Greniebe9bae12011-01-04 05:42:19 -03002529 max_prediv++;
2530
2531 max_prediv--;
2532 min_prediv = max_prediv;
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002533 while ((xtal/min_prediv) <= fcp_max) {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002534 min_prediv--;
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002535 if (min_prediv == 1)
Olivier Greniebe9bae12011-01-04 05:42:19 -03002536 break;
2537 }
2538 deb_info("MIN prediv = %d : MAX prediv = %d", min_prediv, max_prediv);
2539
2540 min_prediv = 2;
2541
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002542 for (prediv = min_prediv ; prediv < max_prediv; prediv++) {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002543 fcp = xtal / prediv;
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002544 if (fcp > fcp_min && fcp < fcp_max) {
2545 for (loopdiv = 1 ; loopdiv < 64 ; loopdiv++) {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002546 fdem = ((xtal/prediv) * loopdiv);
2547 fs = fdem / 4;
2548 /* test min/max system restrictions */
2549
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002550 if ((fdem >= fdem_min) && (fdem <= fdem_max) && (fs >= fe->dtv_property_cache.bandwidth_hz/1000)) {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002551 spur = 0;
2552 /* test fs harmonics positions */
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002553 for (harmonic_id = (fe->dtv_property_cache.frequency / (1000*fs)) ; harmonic_id <= ((fe->dtv_property_cache.frequency / (1000*fs))+1) ; harmonic_id++) {
2554 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 -03002555 spur = 1;
2556 break;
2557 }
2558 }
2559
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002560 if (!spur) {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002561 adc->pll_loopdiv = loopdiv;
2562 adc->pll_prediv = prediv;
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002563 adc->timf = 2396745143UL/fdem*(1 << 9);
2564 adc->timf += ((2396745143UL%fdem) << 9)/fdem;
Olivier Greniebe9bae12011-01-04 05:42:19 -03002565 deb_info("loopdiv=%i prediv=%i timf=%i", loopdiv, prediv, adc->timf);
2566 break;
2567 }
2568 }
2569 }
2570 }
2571 if (!spur)
2572 break;
2573 }
2574
2575
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002576 if (adc->pll_loopdiv == 0 && adc->pll_prediv == 0)
Olivier Greniebe9bae12011-01-04 05:42:19 -03002577 return -EINVAL;
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002578 else
Olivier Greniebe9bae12011-01-04 05:42:19 -03002579 return 0;
2580}
2581
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -03002582static int dib7090_agc_startup(struct dvb_frontend *fe)
Olivier Greniebe9bae12011-01-04 05:42:19 -03002583{
2584 struct dvb_usb_adapter *adap = fe->dvb->priv;
2585 struct dib0700_adapter_state *state = adap->priv;
2586 struct dibx000_bandwidth_config pll;
2587 u16 target;
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03002588 struct dibx090p_best_adc adc;
Olivier Greniebe9bae12011-01-04 05:42:19 -03002589 int ret;
2590
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -03002591 ret = state->set_param_save(fe);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002592 if (ret < 0)
2593 return ret;
2594
2595 memset(&pll, 0, sizeof(struct dibx000_bandwidth_config));
2596 dib0090_pwm_gain_reset(fe);
Olivier Grenie6724a2f2011-08-05 13:49:33 -03002597 target = (dib0090_get_wbd_target(fe) * 8 + 1) / 2;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03002598 state->dib7000p_ops.set_wbd_ref(fe, target);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002599
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002600 if (dib7090p_get_best_sampling(fe, &adc) == 0) {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002601 pll.pll_ratio = adc.pll_loopdiv;
2602 pll.pll_prediv = adc.pll_prediv;
2603
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03002604 state->dib7000p_ops.update_pll(fe, &pll);
2605 state->dib7000p_ops.ctrl_timf(fe, DEMOD_TIMF_SET, adc.timf);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002606 }
2607 return 0;
2608}
2609
Olivier Grenie2e802862011-08-05 10:39:15 -03002610static int dib7090_agc_restart(struct dvb_frontend *fe, u8 restart)
2611{
2612 deb_info("AGC restart callback: %d", restart);
2613 if (restart == 0) /* before AGC startup */
2614 dib0090_set_dc_servo(fe, 1);
2615 return 0;
2616}
2617
Olivier Grenief45f5132012-12-31 09:47:10 -03002618static int tfe7790p_update_lna(struct dvb_frontend *fe, u16 agc_global)
Olivier Grenie6724a2f2011-08-05 13:49:33 -03002619{
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03002620 struct dvb_usb_adapter *adap = fe->dvb->priv;
2621 struct dib0700_adapter_state *state = adap->priv;
2622
Olivier Grenief45f5132012-12-31 09:47:10 -03002623 deb_info("update LNA: agc global=%i", agc_global);
Olivier Grenie6724a2f2011-08-05 13:49:33 -03002624
Olivier Grenief45f5132012-12-31 09:47:10 -03002625 if (agc_global < 25000) {
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03002626 state->dib7000p_ops.set_gpio(fe, 8, 0, 0);
2627 state->dib7000p_ops.set_agc1_min(fe, 0);
Olivier Grenie6724a2f2011-08-05 13:49:33 -03002628 } else {
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03002629 state->dib7000p_ops.set_gpio(fe, 8, 0, 1);
2630 state->dib7000p_ops.set_agc1_min(fe, 32768);
Olivier Grenie6724a2f2011-08-05 13:49:33 -03002631 }
2632
2633 return 0;
2634}
2635
Olivier Greniebe9bae12011-01-04 05:42:19 -03002636static struct dib0090_wbd_slope dib7090_wbd_table[] = {
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002637 { 380, 81, 850, 64, 540, 4},
2638 { 860, 51, 866, 21, 375, 4},
2639 {1700, 0, 250, 0, 100, 6},
2640 {2600, 0, 250, 0, 100, 6},
2641 { 0xFFFF, 0, 0, 0, 0, 0},
Olivier Greniebe9bae12011-01-04 05:42:19 -03002642};
2643
Olivier Greniea685dbb2011-08-05 14:10:40 -03002644static struct dibx000_agc_config dib7090_agc_config[2] = {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002645 {
2646 .band_caps = BAND_UHF,
2647 /* 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,
2648 * 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 -03002649 .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 -03002650
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002651 .inv_gain = 687,
2652 .time_stabiliz = 10,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002653
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002654 .alpha_level = 0,
2655 .thlock = 118,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002656
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002657 .wbd_inv = 0,
2658 .wbd_ref = 1200,
2659 .wbd_sel = 3,
2660 .wbd_alpha = 5,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002661
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002662 .agc1_max = 65535,
Olivier Grenie59501bb2012-12-31 09:51:17 -03002663 .agc1_min = 32768,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002664
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002665 .agc2_max = 65535,
2666 .agc2_min = 0,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002667
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002668 .agc1_pt1 = 0,
2669 .agc1_pt2 = 32,
2670 .agc1_pt3 = 114,
2671 .agc1_slope1 = 143,
2672 .agc1_slope2 = 144,
2673 .agc2_pt1 = 114,
2674 .agc2_pt2 = 227,
2675 .agc2_slope1 = 116,
2676 .agc2_slope2 = 117,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002677
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002678 .alpha_mant = 18,
2679 .alpha_exp = 0,
2680 .beta_mant = 20,
2681 .beta_exp = 59,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002682
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002683 .perform_agc_softsplit = 0,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002684 } , {
2685 .band_caps = BAND_FM | BAND_VHF | BAND_CBAND,
2686 /* 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,
2687 * 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 -03002688 .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 -03002689
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002690 .inv_gain = 732,
2691 .time_stabiliz = 10,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002692
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002693 .alpha_level = 0,
2694 .thlock = 118,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002695
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002696 .wbd_inv = 0,
2697 .wbd_ref = 1200,
2698 .wbd_sel = 3,
2699 .wbd_alpha = 5,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002700
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002701 .agc1_max = 65535,
2702 .agc1_min = 0,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002703
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002704 .agc2_max = 65535,
2705 .agc2_min = 0,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002706
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002707 .agc1_pt1 = 0,
2708 .agc1_pt2 = 0,
2709 .agc1_pt3 = 98,
2710 .agc1_slope1 = 0,
2711 .agc1_slope2 = 167,
Patrick Boettcher7f4d5272011-04-03 12:28:08 -03002712 .agc2_pt1 = 98,
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002713 .agc2_pt2 = 255,
2714 .agc2_slope1 = 104,
2715 .agc2_slope2 = 0,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002716
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002717 .alpha_mant = 18,
2718 .alpha_exp = 0,
2719 .beta_mant = 20,
2720 .beta_exp = 59,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002721
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002722 .perform_agc_softsplit = 0,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002723 }
2724};
2725
2726static struct dibx000_bandwidth_config dib7090_clock_config_12_mhz = {
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002727 60000, 15000,
2728 1, 5, 0, 0, 0,
2729 0, 0, 1, 1, 2,
2730 (3 << 14) | (1 << 12) | (524 << 0),
2731 (0 << 25) | 0,
2732 20452225,
2733 15000000,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002734};
2735
2736static struct dib7000p_config nim7090_dib7000p_config = {
2737 .output_mpeg2_in_188_bytes = 1,
2738 .hostbus_diversity = 1,
2739 .tuner_is_baseband = 1,
Olivier Grenie59501bb2012-12-31 09:51:17 -03002740 .update_lna = tfe7790p_update_lna, /* GPIO used is the same as TFE7790 */
Olivier Greniebe9bae12011-01-04 05:42:19 -03002741
2742 .agc_config_count = 2,
2743 .agc = dib7090_agc_config,
2744
2745 .bw = &dib7090_clock_config_12_mhz,
2746
2747 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
2748 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
2749 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
2750
2751 .pwm_freq_div = 0,
2752
2753 .agc_control = dib7090_agc_restart,
2754
2755 .spur_protect = 0,
2756 .disable_sample_and_hold = 0,
2757 .enable_current_mirror = 0,
2758 .diversity_delay = 0,
2759
2760 .output_mode = OUTMODE_MPEG2_FIFO,
2761 .enMpegOutput = 1,
2762};
2763
Olivier Grenie59501bb2012-12-31 09:51:17 -03002764static int tfe7090p_pvr_update_lna(struct dvb_frontend *fe, u16 agc_global)
2765{
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03002766 struct dvb_usb_adapter *adap = fe->dvb->priv;
2767 struct dib0700_adapter_state *state = adap->priv;
2768
Olivier Grenie59501bb2012-12-31 09:51:17 -03002769 deb_info("TFE7090P-PVR update LNA: agc global=%i", agc_global);
2770 if (agc_global < 25000) {
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03002771 state->dib7000p_ops.set_gpio(fe, 5, 0, 0);
2772 state->dib7000p_ops.set_agc1_min(fe, 0);
Olivier Grenie59501bb2012-12-31 09:51:17 -03002773 } else {
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03002774 state->dib7000p_ops.set_gpio(fe, 5, 0, 1);
2775 state->dib7000p_ops.set_agc1_min(fe, 32768);
Olivier Grenie59501bb2012-12-31 09:51:17 -03002776 }
2777
2778 return 0;
2779}
2780
Olivier Greniebe9bae12011-01-04 05:42:19 -03002781static struct dib7000p_config tfe7090pvr_dib7000p_config[2] = {
2782 {
2783 .output_mpeg2_in_188_bytes = 1,
2784 .hostbus_diversity = 1,
2785 .tuner_is_baseband = 1,
Olivier Grenie59501bb2012-12-31 09:51:17 -03002786 .update_lna = tfe7090p_pvr_update_lna,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002787
2788 .agc_config_count = 2,
2789 .agc = dib7090_agc_config,
2790
2791 .bw = &dib7090_clock_config_12_mhz,
2792
2793 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
2794 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
2795 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
2796
2797 .pwm_freq_div = 0,
2798
2799 .agc_control = dib7090_agc_restart,
2800
2801 .spur_protect = 0,
2802 .disable_sample_and_hold = 0,
2803 .enable_current_mirror = 0,
2804 .diversity_delay = 0,
2805
2806 .output_mode = OUTMODE_MPEG2_PAR_GATED_CLK,
2807 .default_i2c_addr = 0x90,
2808 .enMpegOutput = 1,
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002809 }, {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002810 .output_mpeg2_in_188_bytes = 1,
2811 .hostbus_diversity = 1,
2812 .tuner_is_baseband = 1,
Olivier Grenie59501bb2012-12-31 09:51:17 -03002813 .update_lna = tfe7090p_pvr_update_lna,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002814
2815 .agc_config_count = 2,
2816 .agc = dib7090_agc_config,
2817
2818 .bw = &dib7090_clock_config_12_mhz,
2819
2820 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
2821 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
2822 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
2823
2824 .pwm_freq_div = 0,
2825
2826 .agc_control = dib7090_agc_restart,
2827
2828 .spur_protect = 0,
2829 .disable_sample_and_hold = 0,
2830 .enable_current_mirror = 0,
2831 .diversity_delay = 0,
2832
2833 .output_mode = OUTMODE_MPEG2_PAR_GATED_CLK,
2834 .default_i2c_addr = 0x92,
2835 .enMpegOutput = 0,
2836 }
2837};
2838
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03002839static struct dib0090_config nim7090_dib0090_config = {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002840 .io.clock_khz = 12000,
2841 .io.pll_bypass = 0,
2842 .io.pll_range = 0,
2843 .io.pll_prediv = 3,
2844 .io.pll_loopdiv = 6,
2845 .io.adc_clock_ratio = 0,
2846 .io.pll_int_loop_filt = 0,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002847
2848 .freq_offset_khz_uhf = 0,
2849 .freq_offset_khz_vhf = 0,
2850
Olivier Greniebe9bae12011-01-04 05:42:19 -03002851 .clkouttobamse = 1,
2852 .analog_output = 0,
2853
2854 .wbd_vhf_offset = 0,
2855 .wbd_cband_offset = 0,
2856 .use_pwm_agc = 1,
2857 .clkoutdrive = 0,
2858
2859 .fref_clock_ratio = 0,
2860
2861 .wbd = dib7090_wbd_table,
2862
2863 .ls_cfg_pad_drv = 0,
2864 .data_tx_drv = 0,
2865 .low_if = NULL,
2866 .in_soc = 1,
2867};
2868
Olivier Grenief45f5132012-12-31 09:47:10 -03002869static struct dib7000p_config tfe7790p_dib7000p_config = {
Olivier Grenieb293f302011-08-09 04:48:25 -03002870 .output_mpeg2_in_188_bytes = 1,
2871 .hostbus_diversity = 1,
2872 .tuner_is_baseband = 1,
Olivier Grenief45f5132012-12-31 09:47:10 -03002873 .update_lna = tfe7790p_update_lna,
Olivier Grenieb293f302011-08-09 04:48:25 -03002874
2875 .agc_config_count = 2,
2876 .agc = dib7090_agc_config,
2877
2878 .bw = &dib7090_clock_config_12_mhz,
2879
2880 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
2881 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
2882 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
2883
2884 .pwm_freq_div = 0,
2885
2886 .agc_control = dib7090_agc_restart,
2887
2888 .spur_protect = 0,
2889 .disable_sample_and_hold = 0,
2890 .enable_current_mirror = 0,
2891 .diversity_delay = 0,
2892
2893 .output_mode = OUTMODE_MPEG2_PAR_GATED_CLK,
2894 .enMpegOutput = 1,
2895};
2896
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03002897static struct dib0090_config tfe7790p_dib0090_config = {
Olivier Grenieb293f302011-08-09 04:48:25 -03002898 .io.clock_khz = 12000,
2899 .io.pll_bypass = 0,
2900 .io.pll_range = 0,
2901 .io.pll_prediv = 3,
2902 .io.pll_loopdiv = 6,
2903 .io.adc_clock_ratio = 0,
2904 .io.pll_int_loop_filt = 0,
Olivier Grenieb293f302011-08-09 04:48:25 -03002905
2906 .freq_offset_khz_uhf = 0,
2907 .freq_offset_khz_vhf = 0,
2908
Olivier Grenieb293f302011-08-09 04:48:25 -03002909 .clkouttobamse = 1,
2910 .analog_output = 0,
2911
2912 .wbd_vhf_offset = 0,
2913 .wbd_cband_offset = 0,
2914 .use_pwm_agc = 1,
2915 .clkoutdrive = 0,
2916
2917 .fref_clock_ratio = 0,
2918
Olivier Grenief45f5132012-12-31 09:47:10 -03002919 .wbd = dib7090_wbd_table,
Olivier Grenieb293f302011-08-09 04:48:25 -03002920
2921 .ls_cfg_pad_drv = 0,
2922 .data_tx_drv = 0,
2923 .low_if = NULL,
2924 .in_soc = 1,
Olivier Grenief45f5132012-12-31 09:47:10 -03002925 .force_cband_input = 0,
2926 .is_dib7090e = 0,
Olivier Grenieb293f302011-08-09 04:48:25 -03002927 .force_crystal_mode = 1,
2928};
2929
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03002930static struct dib0090_config tfe7090pvr_dib0090_config[2] = {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002931 {
2932 .io.clock_khz = 12000,
2933 .io.pll_bypass = 0,
2934 .io.pll_range = 0,
2935 .io.pll_prediv = 3,
2936 .io.pll_loopdiv = 6,
2937 .io.adc_clock_ratio = 0,
2938 .io.pll_int_loop_filt = 0,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002939
2940 .freq_offset_khz_uhf = 50,
2941 .freq_offset_khz_vhf = 70,
2942
Olivier Greniebe9bae12011-01-04 05:42:19 -03002943 .clkouttobamse = 1,
2944 .analog_output = 0,
2945
2946 .wbd_vhf_offset = 0,
2947 .wbd_cband_offset = 0,
2948 .use_pwm_agc = 1,
2949 .clkoutdrive = 0,
2950
2951 .fref_clock_ratio = 0,
2952
2953 .wbd = dib7090_wbd_table,
2954
2955 .ls_cfg_pad_drv = 0,
2956 .data_tx_drv = 0,
2957 .low_if = NULL,
2958 .in_soc = 1,
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002959 }, {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002960 .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,
2987 }
2988};
2989
2990static int nim7090_frontend_attach(struct dvb_usb_adapter *adap)
2991{
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03002992 struct dib0700_adapter_state *state = adap->priv;
2993
2994 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
2995 return -ENODEV;
2996
Olivier Greniebe9bae12011-01-04 05:42:19 -03002997 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002998 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002999 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
3000 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
3001 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
3002 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
3003
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03003004 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03003005 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03003006 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03003007 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
3008
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003009 if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 0x10, &nim7090_dib7000p_config) != 0) {
3010 err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n", __func__);
3011 dvb_detach(&state->dib7000p_ops);
Olivier Greniebe9bae12011-01-04 05:42:19 -03003012 return -ENODEV;
3013 }
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003014 adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap, 0x80, &nim7090_dib7000p_config);
Olivier Greniebe9bae12011-01-04 05:42:19 -03003015
Michael Krufky77eed212011-09-06 09:31:57 -03003016 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Olivier Greniebe9bae12011-01-04 05:42:19 -03003017}
3018
3019static int nim7090_tuner_attach(struct dvb_usb_adapter *adap)
3020{
3021 struct dib0700_adapter_state *st = adap->priv;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003022 struct i2c_adapter *tun_i2c = st->dib7000p_ops.get_i2c_tuner(adap->fe_adap[0].fe);
3023
3024 nim7090_dib0090_config.reset = st->dib7000p_ops.tuner_sleep,
3025 nim7090_dib0090_config.sleep = st->dib7000p_ops.tuner_sleep,
3026 nim7090_dib0090_config.get_adc_power = st->dib7000p_ops.get_adc_power;
Olivier Greniebe9bae12011-01-04 05:42:19 -03003027
Michael Krufky77eed212011-09-06 09:31:57 -03003028 if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c, &nim7090_dib0090_config) == NULL)
Olivier Greniebe9bae12011-01-04 05:42:19 -03003029 return -ENODEV;
3030
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003031 st->dib7000p_ops.set_gpio(adap->fe_adap[0].fe, 8, 0, 1);
Olivier Greniebe9bae12011-01-04 05:42:19 -03003032
Michael Krufky77eed212011-09-06 09:31:57 -03003033 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
3034 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib7090_agc_startup;
Olivier Greniebe9bae12011-01-04 05:42:19 -03003035 return 0;
3036}
3037
3038static int tfe7090pvr_frontend0_attach(struct dvb_usb_adapter *adap)
3039{
3040 struct dib0700_state *st = adap->dev->priv;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003041 struct dib0700_adapter_state *state = adap->priv;
3042
3043 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
3044 return -ENODEV;
Olivier Greniebe9bae12011-01-04 05:42:19 -03003045
3046 /* The TFE7090 requires the dib0700 to not be in master mode */
3047 st->disable_streaming_master_mode = 1;
3048
3049 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03003050 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03003051 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
3052 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
3053 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
3054 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
3055
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03003056 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03003057 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03003058 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03003059 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
3060
3061 /* initialize IC 0 */
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003062 if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 0x20, &tfe7090pvr_dib7000p_config[0]) != 0) {
3063 err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n", __func__);
3064 dvb_detach(&state->dib7000p_ops);
Olivier Greniebe9bae12011-01-04 05:42:19 -03003065 return -ENODEV;
3066 }
3067
3068 dib0700_set_i2c_speed(adap->dev, 340);
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003069 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 -03003070 if (adap->fe_adap[0].fe == NULL)
Olivier Greniebe9bae12011-01-04 05:42:19 -03003071 return -ENODEV;
3072
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003073 state->dib7000p_ops.slave_reset(adap->fe_adap[0].fe);
Patrick Boettcher71682522011-04-03 12:44:25 -03003074
Olivier Greniebe9bae12011-01-04 05:42:19 -03003075 return 0;
3076}
3077
3078static int tfe7090pvr_frontend1_attach(struct dvb_usb_adapter *adap)
3079{
3080 struct i2c_adapter *i2c;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003081 struct dib0700_adapter_state *state = adap->priv;
Olivier Greniebe9bae12011-01-04 05:42:19 -03003082
Michael Krufky77eed212011-09-06 09:31:57 -03003083 if (adap->dev->adapter[0].fe_adap[0].fe == NULL) {
Olivier Greniebe9bae12011-01-04 05:42:19 -03003084 err("the master dib7090 has to be initialized first");
3085 return -ENODEV; /* the master device has not been initialized */
3086 }
3087
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003088 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
3089 return -ENODEV;
3090
3091 i2c = state->dib7000p_ops.get_i2c_master(adap->dev->adapter[0].fe_adap[0].fe, DIBX000_I2C_INTERFACE_GPIO_6_7, 1);
3092 if (state->dib7000p_ops.i2c_enumeration(i2c, 1, 0x10, &tfe7090pvr_dib7000p_config[1]) != 0) {
3093 err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n", __func__);
3094 dvb_detach(&state->dib7000p_ops);
Olivier Greniebe9bae12011-01-04 05:42:19 -03003095 return -ENODEV;
3096 }
3097
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003098 adap->fe_adap[0].fe = state->dib7000p_ops.init(i2c, 0x92, &tfe7090pvr_dib7000p_config[1]);
Olivier Greniebe9bae12011-01-04 05:42:19 -03003099 dib0700_set_i2c_speed(adap->dev, 200);
3100
Michael Krufky77eed212011-09-06 09:31:57 -03003101 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Olivier Greniebe9bae12011-01-04 05:42:19 -03003102}
3103
3104static int tfe7090pvr_tuner0_attach(struct dvb_usb_adapter *adap)
3105{
3106 struct dib0700_adapter_state *st = adap->priv;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003107 struct i2c_adapter *tun_i2c = st->dib7000p_ops.get_i2c_tuner(adap->fe_adap[0].fe);
3108
3109 tfe7090pvr_dib0090_config[0].reset = st->dib7000p_ops.tuner_sleep;
3110 tfe7090pvr_dib0090_config[0].sleep = st->dib7000p_ops.tuner_sleep;
3111 tfe7090pvr_dib0090_config[0].get_adc_power = st->dib7000p_ops.get_adc_power;
Olivier Greniebe9bae12011-01-04 05:42:19 -03003112
Michael Krufky77eed212011-09-06 09:31:57 -03003113 if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c, &tfe7090pvr_dib0090_config[0]) == NULL)
Olivier Greniebe9bae12011-01-04 05:42:19 -03003114 return -ENODEV;
3115
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003116 st->dib7000p_ops.set_gpio(adap->fe_adap[0].fe, 8, 0, 1);
Olivier Greniebe9bae12011-01-04 05:42:19 -03003117
Michael Krufky77eed212011-09-06 09:31:57 -03003118 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
3119 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib7090_agc_startup;
Olivier Greniebe9bae12011-01-04 05:42:19 -03003120 return 0;
3121}
3122
3123static int tfe7090pvr_tuner1_attach(struct dvb_usb_adapter *adap)
3124{
3125 struct dib0700_adapter_state *st = adap->priv;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003126 struct i2c_adapter *tun_i2c = st->dib7000p_ops.get_i2c_tuner(adap->fe_adap[0].fe);
3127
3128 tfe7090pvr_dib0090_config[1].reset = st->dib7000p_ops.tuner_sleep;
3129 tfe7090pvr_dib0090_config[1].sleep = st->dib7000p_ops.tuner_sleep;
3130 tfe7090pvr_dib0090_config[1].get_adc_power = st->dib7000p_ops.get_adc_power;
Olivier Greniebe9bae12011-01-04 05:42:19 -03003131
Michael Krufky77eed212011-09-06 09:31:57 -03003132 if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c, &tfe7090pvr_dib0090_config[1]) == NULL)
Olivier Greniebe9bae12011-01-04 05:42:19 -03003133 return -ENODEV;
3134
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003135 st->dib7000p_ops.set_gpio(adap->fe_adap[0].fe, 8, 0, 1);
Olivier Greniebe9bae12011-01-04 05:42:19 -03003136
Michael Krufky77eed212011-09-06 09:31:57 -03003137 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
3138 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib7090_agc_startup;
Olivier Greniebe9bae12011-01-04 05:42:19 -03003139 return 0;
3140}
3141
Olivier Grenief45f5132012-12-31 09:47:10 -03003142static int tfe7790p_frontend_attach(struct dvb_usb_adapter *adap)
Olivier Grenieb293f302011-08-09 04:48:25 -03003143{
3144 struct dib0700_state *st = adap->dev->priv;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003145 struct dib0700_adapter_state *state = adap->priv;
3146
3147 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
3148 return -ENODEV;
Olivier Grenieb293f302011-08-09 04:48:25 -03003149
Olivier Grenief45f5132012-12-31 09:47:10 -03003150 /* The TFE7790P requires the dib0700 to not be in master mode */
Olivier Grenieb293f302011-08-09 04:48:25 -03003151 st->disable_streaming_master_mode = 1;
3152
3153 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
3154 msleep(20);
3155 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
3156 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
3157 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
3158 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
3159 msleep(20);
3160 dib0700_ctrl_clock(adap->dev, 72, 1);
3161 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
3162 msleep(20);
3163 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
3164
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003165 if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap,
Olivier Grenief45f5132012-12-31 09:47:10 -03003166 1, 0x10, &tfe7790p_dib7000p_config) != 0) {
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003167 err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n",
Olivier Grenieb293f302011-08-09 04:48:25 -03003168 __func__);
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003169 dvb_detach(&state->dib7000p_ops);
Olivier Grenieb293f302011-08-09 04:48:25 -03003170 return -ENODEV;
3171 }
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003172 adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap,
Olivier Grenief45f5132012-12-31 09:47:10 -03003173 0x80, &tfe7790p_dib7000p_config);
Olivier Grenieb293f302011-08-09 04:48:25 -03003174
3175 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
3176}
3177
Olivier Grenief45f5132012-12-31 09:47:10 -03003178static int tfe7790p_tuner_attach(struct dvb_usb_adapter *adap)
Olivier Grenieb293f302011-08-09 04:48:25 -03003179{
3180 struct dib0700_adapter_state *st = adap->priv;
3181 struct i2c_adapter *tun_i2c =
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003182 st->dib7000p_ops.get_i2c_tuner(adap->fe_adap[0].fe);
3183
3184
3185 tfe7790p_dib0090_config.reset = st->dib7000p_ops.tuner_sleep;
3186 tfe7790p_dib0090_config.sleep = st->dib7000p_ops.tuner_sleep;
3187 tfe7790p_dib0090_config.get_adc_power = st->dib7000p_ops.get_adc_power;
Olivier Grenieb293f302011-08-09 04:48:25 -03003188
3189 if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c,
Olivier Grenief45f5132012-12-31 09:47:10 -03003190 &tfe7790p_dib0090_config) == NULL)
Olivier Grenie6724a2f2011-08-05 13:49:33 -03003191 return -ENODEV;
3192
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003193 st->dib7000p_ops.set_gpio(adap->fe_adap[0].fe, 8, 0, 1);
Olivier Grenie6724a2f2011-08-05 13:49:33 -03003194
3195 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
3196 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib7090_agc_startup;
3197 return 0;
3198}
3199
Patrick Boettcher01373a52007-07-30 12:49:04 -03003200/* STK7070PD */
3201static struct dib7000p_config stk7070pd_dib7000p_config[2] = {
3202 {
3203 .output_mpeg2_in_188_bytes = 1,
3204
3205 .agc_config_count = 1,
3206 .agc = &dib7070_agc_config,
3207 .bw = &dib7070_bw_config_12_mhz,
Patrick Boettcher3cb2c392008-01-25 07:25:20 -03003208 .tuner_is_baseband = 1,
3209 .spur_protect = 1,
Patrick Boettcher01373a52007-07-30 12:49:04 -03003210
3211 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
3212 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
3213 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
3214
3215 .hostbus_diversity = 1,
3216 }, {
3217 .output_mpeg2_in_188_bytes = 1,
3218
3219 .agc_config_count = 1,
3220 .agc = &dib7070_agc_config,
3221 .bw = &dib7070_bw_config_12_mhz,
Patrick Boettcher3cb2c392008-01-25 07:25:20 -03003222 .tuner_is_baseband = 1,
3223 .spur_protect = 1,
Patrick Boettcher01373a52007-07-30 12:49:04 -03003224
3225 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
3226 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
3227 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
3228
3229 .hostbus_diversity = 1,
3230 }
3231};
3232
Jiri Slaby52fd5b22012-01-10 14:11:23 -03003233static void stk7070pd_init(struct dvb_usb_device *dev)
3234{
3235 dib0700_set_gpio(dev, GPIO6, GPIO_OUT, 1);
3236 msleep(10);
3237 dib0700_set_gpio(dev, GPIO9, GPIO_OUT, 1);
3238 dib0700_set_gpio(dev, GPIO4, GPIO_OUT, 1);
3239 dib0700_set_gpio(dev, GPIO7, GPIO_OUT, 1);
3240 dib0700_set_gpio(dev, GPIO10, GPIO_OUT, 0);
3241
3242 dib0700_ctrl_clock(dev, 72, 1);
3243
3244 msleep(10);
3245 dib0700_set_gpio(dev, GPIO10, GPIO_OUT, 1);
3246}
3247
Patrick Boettcher01373a52007-07-30 12:49:04 -03003248static int stk7070pd_frontend_attach0(struct dvb_usb_adapter *adap)
3249{
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003250 struct dib0700_adapter_state *state = adap->priv;
3251
3252 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
3253 return -ENODEV;
3254
Jiri Slaby52fd5b22012-01-10 14:11:23 -03003255 stk7070pd_init(adap->dev);
Patrick Boettcher01373a52007-07-30 12:49:04 -03003256
Patrick Boettcher01373a52007-07-30 12:49:04 -03003257 msleep(10);
3258 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
3259
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003260 if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap, 2, 18,
Devin Heitmueller83c4fdf2009-01-21 01:55:45 -03003261 stk7070pd_dib7000p_config) != 0) {
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003262 err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n",
Devin Heitmueller83c4fdf2009-01-21 01:55:45 -03003263 __func__);
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003264 dvb_detach(&state->dib7000p_ops);
Devin Heitmueller83c4fdf2009-01-21 01:55:45 -03003265 return -ENODEV;
3266 }
Patrick Boettcher01373a52007-07-30 12:49:04 -03003267
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003268 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 -03003269 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Patrick Boettcher01373a52007-07-30 12:49:04 -03003270}
3271
3272static int stk7070pd_frontend_attach1(struct dvb_usb_adapter *adap)
3273{
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003274 struct dib0700_adapter_state *state = adap->priv;
3275
3276 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
3277 return -ENODEV;
3278
3279 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 -03003280 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Patrick Boettcher01373a52007-07-30 12:49:04 -03003281}
3282
Jiri Slabyd43272a2012-01-10 14:11:25 -03003283static int novatd_read_status_override(struct dvb_frontend *fe,
3284 fe_status_t *stat)
3285{
3286 struct dvb_usb_adapter *adap = fe->dvb->priv;
3287 struct dvb_usb_device *dev = adap->dev;
3288 struct dib0700_state *state = dev->priv;
3289 int ret;
3290
3291 ret = state->read_status(fe, stat);
3292
3293 if (!ret)
3294 dib0700_set_gpio(dev, adap->id == 0 ? GPIO1 : GPIO0, GPIO_OUT,
3295 !!(*stat & FE_HAS_LOCK));
3296
3297 return ret;
3298}
3299
3300static int novatd_sleep_override(struct dvb_frontend* fe)
3301{
3302 struct dvb_usb_adapter *adap = fe->dvb->priv;
3303 struct dvb_usb_device *dev = adap->dev;
3304 struct dib0700_state *state = dev->priv;
3305
3306 /* turn off LED */
3307 dib0700_set_gpio(dev, adap->id == 0 ? GPIO1 : GPIO0, GPIO_OUT, 0);
3308
3309 return state->sleep(fe);
3310}
3311
Jiri Slaby2b05b882012-01-10 14:11:24 -03003312/**
3313 * novatd_frontend_attach - Nova-TD specific attach
3314 *
3315 * Nova-TD has GPIO0, 1 and 2 for LEDs. So do not fiddle with them except for
3316 * information purposes.
3317 */
3318static int novatd_frontend_attach(struct dvb_usb_adapter *adap)
3319{
3320 struct dvb_usb_device *dev = adap->dev;
Jiri Slabyd43272a2012-01-10 14:11:25 -03003321 struct dib0700_state *st = dev->priv;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003322 struct dib0700_adapter_state *state = adap->priv;
3323
3324 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
3325 return -ENODEV;
Jiri Slaby2b05b882012-01-10 14:11:24 -03003326
3327 if (adap->id == 0) {
3328 stk7070pd_init(dev);
3329
3330 /* turn the power LED on, the other two off (just in case) */
3331 dib0700_set_gpio(dev, GPIO0, GPIO_OUT, 0);
3332 dib0700_set_gpio(dev, GPIO1, GPIO_OUT, 0);
3333 dib0700_set_gpio(dev, GPIO2, GPIO_OUT, 1);
3334
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003335 if (state->dib7000p_ops.i2c_enumeration(&dev->i2c_adap, 2, 18,
Jiri Slaby2b05b882012-01-10 14:11:24 -03003336 stk7070pd_dib7000p_config) != 0) {
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003337 err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n",
Jiri Slaby2b05b882012-01-10 14:11:24 -03003338 __func__);
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003339 dvb_detach(&state->dib7000p_ops);
Jiri Slaby2b05b882012-01-10 14:11:24 -03003340 return -ENODEV;
3341 }
3342 }
3343
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003344 adap->fe_adap[0].fe = state->dib7000p_ops.init(&dev->i2c_adap,
Jiri Slaby2b05b882012-01-10 14:11:24 -03003345 adap->id == 0 ? 0x80 : 0x82,
3346 &stk7070pd_dib7000p_config[adap->id]);
Jiri Slabyd43272a2012-01-10 14:11:25 -03003347
3348 if (adap->fe_adap[0].fe == NULL)
3349 return -ENODEV;
3350
3351 st->read_status = adap->fe_adap[0].fe->ops.read_status;
3352 adap->fe_adap[0].fe->ops.read_status = novatd_read_status_override;
3353 st->sleep = adap->fe_adap[0].fe->ops.sleep;
3354 adap->fe_adap[0].fe->ops.sleep = novatd_sleep_override;
3355
3356 return 0;
Jiri Slaby2b05b882012-01-10 14:11:24 -03003357}
3358
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03003359/* S5H1411 */
3360static struct s5h1411_config pinnacle_801e_config = {
3361 .output_mode = S5H1411_PARALLEL_OUTPUT,
3362 .gpio = S5H1411_GPIO_OFF,
3363 .mpeg_timing = S5H1411_MPEGTIMING_NONCONTINOUS_NONINVERTING_CLOCK,
3364 .qam_if = S5H1411_IF_44000,
3365 .vsb_if = S5H1411_IF_44000,
3366 .inversion = S5H1411_INVERSION_OFF,
3367 .status_mode = S5H1411_DEMODLOCKING
3368};
3369
3370/* Pinnacle PCTV HD Pro 801e GPIOs map:
3371 GPIO0 - currently unknown
3372 GPIO1 - xc5000 tuner reset
3373 GPIO2 - CX25843 sleep
3374 GPIO3 - currently unknown
3375 GPIO4 - currently unknown
3376 GPIO6 - currently unknown
3377 GPIO7 - currently unknown
3378 GPIO9 - currently unknown
3379 GPIO10 - CX25843 reset
3380 */
3381static int s5h1411_frontend_attach(struct dvb_usb_adapter *adap)
3382{
3383 struct dib0700_state *st = adap->dev->priv;
3384
3385 /* Make use of the new i2c functions from FW 1.20 */
3386 st->fw_use_new_i2c_api = 1;
3387
3388 /* The s5h1411 requires the dib0700 to not be in master mode */
3389 st->disable_streaming_master_mode = 1;
3390
3391 /* All msleep values taken from Windows USB trace */
3392 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 0);
3393 dib0700_set_gpio(adap->dev, GPIO3, GPIO_OUT, 0);
3394 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
3395 msleep(400);
3396 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
3397 msleep(60);
3398 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
3399 msleep(30);
3400 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
3401 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
3402 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
3403 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
3404 dib0700_set_gpio(adap->dev, GPIO2, GPIO_OUT, 0);
3405 msleep(30);
3406
3407 /* Put the CX25843 to sleep for now since we're in digital mode */
3408 dib0700_set_gpio(adap->dev, GPIO2, GPIO_OUT, 1);
3409
3410 /* GPIOs are initialized, do the attach */
Michael Krufky77eed212011-09-06 09:31:57 -03003411 adap->fe_adap[0].fe = dvb_attach(s5h1411_attach, &pinnacle_801e_config,
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03003412 &adap->dev->i2c_adap);
Michael Krufky77eed212011-09-06 09:31:57 -03003413 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03003414}
3415
Michael Krufky767f3b32008-09-25 09:47:07 -03003416static int dib0700_xc5000_tuner_callback(void *priv, int component,
3417 int command, int arg)
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03003418{
3419 struct dvb_usb_adapter *adap = priv;
3420
Devin Heitmueller79025a92008-10-06 12:07:48 -03003421 if (command == XC5000_TUNER_RESET) {
3422 /* Reset the tuner */
3423 dib0700_set_gpio(adap->dev, GPIO1, GPIO_OUT, 0);
Devin Heitmuellerf0f46332009-05-04 21:57:41 -03003424 msleep(10);
Devin Heitmueller79025a92008-10-06 12:07:48 -03003425 dib0700_set_gpio(adap->dev, GPIO1, GPIO_OUT, 1);
Devin Heitmuellerf0f46332009-05-04 21:57:41 -03003426 msleep(10);
Devin Heitmueller79025a92008-10-06 12:07:48 -03003427 } else {
3428 err("xc5000: unknown tuner callback command: %d\n", command);
3429 return -EINVAL;
3430 }
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03003431
3432 return 0;
3433}
3434
3435static struct xc5000_config s5h1411_xc5000_tunerconfig = {
3436 .i2c_address = 0x64,
3437 .if_khz = 5380,
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03003438};
3439
3440static int xc5000_tuner_attach(struct dvb_usb_adapter *adap)
3441{
Devin Heitmueller79025a92008-10-06 12:07:48 -03003442 /* FIXME: generalize & move to common area */
Michael Krufky77eed212011-09-06 09:31:57 -03003443 adap->fe_adap[0].fe->callback = dib0700_xc5000_tuner_callback;
Devin Heitmueller79025a92008-10-06 12:07:48 -03003444
Michael Krufky77eed212011-09-06 09:31:57 -03003445 return dvb_attach(xc5000_attach, adap->fe_adap[0].fe, &adap->dev->i2c_adap,
Michael Krufky767f3b32008-09-25 09:47:07 -03003446 &s5h1411_xc5000_tunerconfig)
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03003447 == NULL ? -ENODEV : 0;
3448}
3449
Davide Ferri8d009a02009-06-23 22:34:06 -03003450static int dib0700_xc4000_tuner_callback(void *priv, int component,
3451 int command, int arg)
3452{
3453 struct dvb_usb_adapter *adap = priv;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003454 struct dib0700_adapter_state *state = adap->priv;
Davide Ferri8d009a02009-06-23 22:34:06 -03003455
3456 if (command == XC4000_TUNER_RESET) {
3457 /* Reset the tuner */
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003458 state->dib7000p_ops.set_gpio(adap->fe_adap[0].fe, 8, 0, 0);
Davide Ferri8d009a02009-06-23 22:34:06 -03003459 msleep(10);
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003460 state->dib7000p_ops.set_gpio(adap->fe_adap[0].fe, 8, 0, 1);
Davide Ferri8d009a02009-06-23 22:34:06 -03003461 } else {
3462 err("xc4000: unknown tuner callback command: %d\n", command);
3463 return -EINVAL;
3464 }
3465
3466 return 0;
3467}
3468
Devin Heitmueller8583fc82009-07-28 01:16:05 -03003469static struct dibx000_agc_config stk7700p_7000p_xc4000_agc_config = {
3470 .band_caps = BAND_UHF | BAND_VHF,
3471 .setup = 0x64,
3472 .inv_gain = 0x02c8,
3473 .time_stabiliz = 0x15,
3474 .alpha_level = 0x00,
3475 .thlock = 0x76,
3476 .wbd_inv = 0x01,
3477 .wbd_ref = 0x0b33,
3478 .wbd_sel = 0x00,
3479 .wbd_alpha = 0x02,
3480 .agc1_max = 0x00,
3481 .agc1_min = 0x00,
3482 .agc2_max = 0x9b26,
3483 .agc2_min = 0x26ca,
3484 .agc1_pt1 = 0x00,
3485 .agc1_pt2 = 0x00,
3486 .agc1_pt3 = 0x00,
3487 .agc1_slope1 = 0x00,
3488 .agc1_slope2 = 0x00,
3489 .agc2_pt1 = 0x00,
3490 .agc2_pt2 = 0x80,
3491 .agc2_slope1 = 0x1d,
3492 .agc2_slope2 = 0x1d,
Devin Heitmueller2df12512009-12-27 17:44:31 -03003493 .alpha_mant = 0x11,
Devin Heitmueller8583fc82009-07-28 01:16:05 -03003494 .alpha_exp = 0x1b,
3495 .beta_mant = 0x17,
3496 .beta_exp = 0x33,
3497 .perform_agc_softsplit = 0x00,
3498};
3499
Devin Heitmuellerf1c78d32009-10-05 00:34:04 -03003500static struct dibx000_bandwidth_config stk7700p_xc4000_pll_config = {
istvan_v@mailbox.hu341747b2011-06-06 12:54:54 -03003501 60000, 30000, /* internal, sampling */
3502 1, 8, 3, 1, 0, /* pll_cfg: prediv, ratio, range, reset, bypass */
3503 0, 0, 1, 1, 0, /* misc: refdiv, bypclk_div, IO_CLK_en_core, */
3504 /* ADClkSrc, modulo */
3505 (3 << 14) | (1 << 12) | 524, /* sad_cfg: refsel, sel, freq_15k */
3506 39370534, /* ifreq */
3507 20452225, /* timf */
3508 30000000 /* xtal */
Devin Heitmuellerf1c78d32009-10-05 00:34:04 -03003509};
3510
Devin Heitmueller01f16262009-06-24 00:07:01 -03003511/* FIXME: none of these inputs are validated yet */
3512static struct dib7000p_config pctv_340e_config = {
Devin Heitmueller62956ce2009-12-27 18:58:11 -03003513 .output_mpeg2_in_188_bytes = 1,
Devin Heitmueller01f16262009-06-24 00:07:01 -03003514
3515 .agc_config_count = 1,
Devin Heitmueller8583fc82009-07-28 01:16:05 -03003516 .agc = &stk7700p_7000p_xc4000_agc_config,
Devin Heitmuellerf1c78d32009-10-05 00:34:04 -03003517 .bw = &stk7700p_xc4000_pll_config,
Devin Heitmueller01f16262009-06-24 00:07:01 -03003518
Devin Heitmueller01f16262009-06-24 00:07:01 -03003519 .gpio_dir = DIB7000M_GPIO_DEFAULT_DIRECTIONS,
3520 .gpio_val = DIB7000M_GPIO_DEFAULT_VALUES,
3521 .gpio_pwm_pos = DIB7000M_GPIO_DEFAULT_PWM_POS,
3522};
3523
3524/* PCTV 340e GPIOs map:
3525 dib0700:
3526 GPIO2 - CX25843 sleep
3527 GPIO3 - CS5340 reset
3528 GPIO5 - IRD
3529 GPIO6 - Power Supply
3530 GPIO8 - LNA (1=off 0=on)
3531 GPIO10 - CX25843 reset
3532 dib7000:
3533 GPIO8 - xc4000 reset
3534 */
3535static int pctv340e_frontend_attach(struct dvb_usb_adapter *adap)
3536{
3537 struct dib0700_state *st = adap->dev->priv;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003538 struct dib0700_adapter_state *state = adap->priv;
3539
3540 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
3541 return -ENODEV;
Devin Heitmueller01f16262009-06-24 00:07:01 -03003542
3543 /* Power Supply on */
3544 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
3545 msleep(50);
3546 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
3547 msleep(100); /* Allow power supply to settle before probing */
3548
3549 /* cx25843 reset */
3550 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
3551 msleep(1); /* cx25843 datasheet say 350us required */
3552 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
3553
3554 /* LNA off for now */
3555 dib0700_set_gpio(adap->dev, GPIO8, GPIO_OUT, 1);
3556
3557 /* Put the CX25843 to sleep for now since we're in digital mode */
3558 dib0700_set_gpio(adap->dev, GPIO2, GPIO_OUT, 1);
3559
3560 /* FIXME: not verified yet */
3561 dib0700_ctrl_clock(adap->dev, 72, 1);
3562
Devin Heitmueller2750d9c2009-07-20 00:42:33 -03003563 msleep(500);
3564
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003565 if (state->dib7000p_ops.dib7000pc_detection(&adap->dev->i2c_adap) == 0) {
Devin Heitmueller01f16262009-06-24 00:07:01 -03003566 /* Demodulator not found for some reason? */
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003567 dvb_detach(&state->dib7000p_ops);
Devin Heitmueller01f16262009-06-24 00:07:01 -03003568 return -ENODEV;
3569 }
3570
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003571 adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap, 0x12,
Devin Heitmueller01f16262009-06-24 00:07:01 -03003572 &pctv_340e_config);
3573 st->is_dib7000pc = 1;
3574
Michael Krufky77eed212011-09-06 09:31:57 -03003575 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Devin Heitmueller01f16262009-06-24 00:07:01 -03003576}
3577
Devin Heitmueller8583fc82009-07-28 01:16:05 -03003578static struct xc4000_config dib7000p_xc4000_tunerconfig = {
istvan_v@mailbox.hu8edeb6e2011-06-06 13:03:44 -03003579 .i2c_address = 0x61,
3580 .default_pm = 1,
3581 .dvb_amplitude = 0,
3582 .set_smoothedcvbs = 0,
3583 .if_khz = 5400
Davide Ferri8d009a02009-06-23 22:34:06 -03003584};
3585
3586static int xc4000_tuner_attach(struct dvb_usb_adapter *adap)
3587{
Devin Heitmueller59d0c372009-06-29 21:11:02 -03003588 struct i2c_adapter *tun_i2c;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003589 struct dib0700_adapter_state *state = adap->priv;
Devin Heitmueller59d0c372009-06-29 21:11:02 -03003590
3591 /* The xc4000 is not on the main i2c bus */
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003592 tun_i2c = state->dib7000p_ops.get_i2c_master(adap->fe_adap[0].fe,
Devin Heitmueller59d0c372009-06-29 21:11:02 -03003593 DIBX000_I2C_INTERFACE_TUNER, 1);
3594 if (tun_i2c == NULL) {
Mauro Carvalho Chehab941830c2011-06-06 16:51:11 -03003595 printk(KERN_ERR "Could not reach tuner i2c bus\n");
Devin Heitmueller59d0c372009-06-29 21:11:02 -03003596 return 0;
3597 }
3598
3599 /* Setup the reset callback */
Michael Krufky77eed212011-09-06 09:31:57 -03003600 adap->fe_adap[0].fe->callback = dib0700_xc4000_tuner_callback;
Davide Ferri8d009a02009-06-23 22:34:06 -03003601
Michael Krufky77eed212011-09-06 09:31:57 -03003602 return dvb_attach(xc4000_attach, adap->fe_adap[0].fe, tun_i2c,
Devin Heitmueller8583fc82009-07-28 01:16:05 -03003603 &dib7000p_xc4000_tunerconfig)
Davide Ferri8d009a02009-06-23 22:34:06 -03003604 == NULL ? -ENODEV : 0;
3605}
3606
Michael Krufkyce904bc2009-01-19 01:12:55 -03003607static struct lgdt3305_config hcw_lgdt3305_config = {
3608 .i2c_addr = 0x0e,
3609 .mpeg_mode = LGDT3305_MPEG_PARALLEL,
3610 .tpclk_edge = LGDT3305_TPCLK_FALLING_EDGE,
3611 .tpvalid_polarity = LGDT3305_TP_VALID_LOW,
3612 .deny_i2c_rptr = 0,
3613 .spectral_inversion = 1,
3614 .qam_if_khz = 6000,
3615 .vsb_if_khz = 6000,
3616 .usref_8vsb = 0x0500,
3617};
3618
3619static struct mxl5007t_config hcw_mxl5007t_config = {
3620 .xtal_freq_hz = MxL_XTAL_25_MHZ,
3621 .if_freq_hz = MxL_IF_6_MHZ,
3622 .invert_if = 1,
3623};
3624
3625/* TIGER-ATSC map:
3626 GPIO0 - LNA_CTR (H: LNA power enabled, L: LNA power disabled)
3627 GPIO1 - ANT_SEL (H: VPA, L: MCX)
3628 GPIO4 - SCL2
3629 GPIO6 - EN_TUNER
3630 GPIO7 - SDA2
3631 GPIO10 - DEM_RST
3632
3633 MXL is behind LG's i2c repeater. LG is on SCL2/SDA2 gpios on the DIB
3634 */
3635static int lgdt3305_frontend_attach(struct dvb_usb_adapter *adap)
3636{
3637 struct dib0700_state *st = adap->dev->priv;
3638
3639 /* Make use of the new i2c functions from FW 1.20 */
3640 st->fw_use_new_i2c_api = 1;
3641
3642 st->disable_streaming_master_mode = 1;
3643
3644 /* fe power enable */
3645 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
3646 msleep(30);
3647 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
3648 msleep(30);
3649
3650 /* demod reset */
3651 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
3652 msleep(30);
3653 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
3654 msleep(30);
3655 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
3656 msleep(30);
3657
Michael Krufky77eed212011-09-06 09:31:57 -03003658 adap->fe_adap[0].fe = dvb_attach(lgdt3305_attach,
Michael Krufkyce904bc2009-01-19 01:12:55 -03003659 &hcw_lgdt3305_config,
3660 &adap->dev->i2c_adap);
3661
Michael Krufky77eed212011-09-06 09:31:57 -03003662 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Michael Krufkyce904bc2009-01-19 01:12:55 -03003663}
3664
3665static int mxl5007t_tuner_attach(struct dvb_usb_adapter *adap)
3666{
Michael Krufky77eed212011-09-06 09:31:57 -03003667 return dvb_attach(mxl5007t_attach, adap->fe_adap[0].fe,
Michael Krufkyce904bc2009-01-19 01:12:55 -03003668 &adap->dev->i2c_adap, 0x60,
3669 &hcw_mxl5007t_config) == NULL ? -ENODEV : 0;
3670}
3671
3672
Patrick Boettcher01373a52007-07-30 12:49:04 -03003673/* DVB-USB and USB stuff follows */
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003674struct usb_device_id dib0700_usb_id_table[] = {
Patrick Boettcher01373a52007-07-30 12:49:04 -03003675/* 0 */ { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7700P) },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03003676 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7700P_PC) },
3677 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_500) },
3678 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_500_2) },
3679 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_STICK) },
Patrick Boettcher01373a52007-07-30 12:49:04 -03003680/* 5 */ { USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR) },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03003681 { USB_DEVICE(USB_VID_COMPRO, USB_PID_COMPRO_VIDEOMATE_U500) },
3682 { USB_DEVICE(USB_VID_UNIWILL, USB_PID_UNIWILL_STK7700P) },
3683 { USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV_DONGLE_STK7700P) },
3684 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_STICK_2) },
Patrick Boettcher01373a52007-07-30 12:49:04 -03003685/* 10 */{ USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR_2) },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03003686 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV2000E) },
3687 { USB_DEVICE(USB_VID_TERRATEC,
3688 USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY) },
3689 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_TD_STICK) },
3690 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7700D) },
Patrick Boettcher01373a52007-07-30 12:49:04 -03003691/* 15 */{ USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7070P) },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03003692 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV_DVB_T_FLASH) },
3693 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7070PD) },
3694 { USB_DEVICE(USB_VID_PINNACLE,
3695 USB_PID_PINNACLE_PCTV_DUAL_DIVERSITY_DVB_T) },
3696 { USB_DEVICE(USB_VID_COMPRO, USB_PID_COMPRO_VIDEOMATE_U500_PC) },
Joachim Steigerfa3b8772007-10-08 20:08:46 -03003697/* 20 */{ USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_EXPRESS) },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03003698 { USB_DEVICE(USB_VID_GIGABYTE, USB_PID_GIGABYTE_U7000) },
3699 { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC, USB_PID_ARTEC_T14BR) },
3700 { USB_DEVICE(USB_VID_ASUS, USB_PID_ASUS_U3000) },
3701 { USB_DEVICE(USB_VID_ASUS, USB_PID_ASUS_U3100) },
3702/* 25 */{ USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_STICK_3) },
3703 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_MYTV_T) },
3704 { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_HT_USB_XE) },
3705 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_EXPRESSCARD_320CX) },
3706 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV72E) },
3707/* 30 */{ USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV73E) },
3708 { USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_EC372S) },
3709 { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_HT_EXPRESS) },
Alexander Simondc888072008-03-29 21:37:54 -03003710 { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_XXS) },
Darryl Green5da4e2c2008-03-29 21:47:43 -03003711 { USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV_DONGLE_STK7700P_2) },
Michael Krufkyaf2a8872008-09-03 17:12:24 -03003712/* 35 */{ USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_TD_STICK_52009) },
Michael Krufky9a0c04a2008-09-03 17:12:24 -03003713 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_500_3) },
Finn Thain17a370b2008-09-06 13:42:47 -03003714 { USB_DEVICE(USB_VID_GIGABYTE, USB_PID_GIGABYTE_U8000) },
Daniel Oliveira Nascimento8751aaa2008-09-07 12:39:44 -03003715 { USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_STK7700PH) },
Albert Comerma57697432008-09-07 12:43:33 -03003716 { USB_DEVICE(USB_VID_ASUS, USB_PID_ASUS_U3000H) },
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03003717/* 40 */{ USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV801E) },
Devin Heitmuellerd2fc3bf2008-09-25 06:22:23 -03003718 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV801E_SE) },
Yusuf Altinbb1b0822009-01-08 07:58:45 -03003719 { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_EXPRESS) },
Nicolas Fournierdb4b2d12009-01-13 07:15:25 -03003720 { USB_DEVICE(USB_VID_TERRATEC,
3721 USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY_2) },
sebastian.blanes@gmail.com0a6e1ed2009-02-24 14:51:43 -03003722 { USB_DEVICE(USB_VID_SONY, USB_PID_SONY_PLAYTV) },
Pascal Terjan9abb6e62009-02-26 10:31:41 -03003723/* 45 */{ USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_PD378S) },
Michael Krufkyce904bc2009-01-19 01:12:55 -03003724 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_TIGER_ATSC) },
3725 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_TIGER_ATSC_B210) },
Xoan Loureiro16ba1ee2009-03-29 08:43:36 -03003726 { USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_MC770) },
Klaus Flittner919a5482009-03-29 09:12:06 -03003727 { USB_DEVICE(USB_VID_ELGATO, USB_PID_ELGATO_EYETV_DTT) },
Armin Schenker513846e2009-04-20 11:57:49 -03003728/* 50 */{ USB_DEVICE(USB_VID_ELGATO, USB_PID_ELGATO_EYETV_DTT_Dlx) },
tomas petrf0f4ae72009-05-20 05:28:05 -03003729 { USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV_DONGLE_H) },
Patrick Boettchera9b8fe32009-05-20 05:35:02 -03003730 { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_T3) },
3731 { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_T5) },
Pete Hildebrandtc53d83c2009-08-05 11:46:38 -03003732 { USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_STK7700D) },
Olivier Grenie74b76f22009-09-02 08:19:19 -03003733/* 55 */{ USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_STK7700D_2) },
3734 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV73A) },
Patrick Boettchere4147532009-11-30 13:52:57 -03003735 { USB_DEVICE(USB_VID_PCTV, USB_PID_PINNACLE_PCTV73ESE) },
3736 { USB_DEVICE(USB_VID_PCTV, USB_PID_PINNACLE_PCTV282E) },
Olivier Grenied300bd62009-09-15 06:55:35 -03003737 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7770P) },
Patrick Boettcherdb481382009-09-15 07:16:51 -03003738/* 60 */{ USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_XXS_2) },
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03003739 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK807XPVR) },
3740 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK807XP) },
Mauro Carvalho Chehab3bfb3172010-09-03 10:50:24 -03003741 { USB_DEVICE_VER(USB_VID_PIXELVIEW, USB_PID_PIXELVIEW_SBTVD, 0x000, 0x3f00) },
S?rgio Fortier8a378e82009-09-28 04:19:21 -03003742 { USB_DEVICE(USB_VID_EVOLUTEPC, USB_PID_TVWAY_PLUS) },
Patrick Boettcher20232c42009-12-01 12:08:56 -03003743/* 65 */{ USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV73ESE) },
Patrick Boettchere4147532009-11-30 13:52:57 -03003744 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV282E) },
Olivier Grenie03245a52009-12-04 13:27:57 -03003745 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK8096GP) },
Michael Müller84e2f032010-04-26 22:18:57 -03003746 { USB_DEVICE(USB_VID_ELGATO, USB_PID_ELGATO_EYETV_DIVERSITY) },
Olivier Greniebe9bae12011-01-04 05:42:19 -03003747 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_NIM9090M) },
3748/* 70 */{ USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_NIM8096MD) },
3749 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_NIM9090MD) },
3750 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_NIM7090) },
3751 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_TFE7090PVR) },
Lukas Max Fisch498e6772011-02-08 16:51:45 -03003752 { USB_DEVICE(USB_VID_TECHNISAT, USB_PID_TECHNISAT_AIRSTAR_TELESTICK_2) },
Stéphane Elmalehd1402302011-05-21 07:33:38 -03003753/* 75 */{ USB_DEVICE(USB_VID_MEDION, USB_PID_CREATIX_CTX1921) },
Davide Ferri8d009a02009-06-23 22:34:06 -03003754 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV340E) },
Devin Heitmueller33fb1682009-06-23 22:48:02 -03003755 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV340E_SE) },
Olivier Grenief45f5132012-12-31 09:47:10 -03003756 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_TFE7790P) },
3757 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_TFE8096P) },
3758/* 80 */{ USB_DEVICE(USB_VID_ELGATO, USB_PID_ELGATO_EYETV_DTT_2) },
Michael Krufkyc859e6e2013-06-30 12:43:58 -03003759 { USB_DEVICE(USB_VID_PCTV, USB_PID_PCTV_2002E) },
3760 { USB_DEVICE(USB_VID_PCTV, USB_PID_PCTV_2002E_SE) },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03003761 { 0 } /* Terminating entry */
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003762};
3763MODULE_DEVICE_TABLE(usb, dib0700_usb_id_table);
3764
3765#define DIB0700_DEFAULT_DEVICE_PROPERTIES \
3766 .caps = DVB_USB_IS_AN_I2C_ADAPTER, \
3767 .usb_ctrl = DEVICE_SPECIFIC, \
Devin Heitmuellerbdc203e2008-09-06 13:45:27 -03003768 .firmware = "dvb-usb-dib0700-1.20.fw", \
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003769 .download_firmware = dib0700_download_firmware, \
Patrick Boettcher6958eff2006-09-19 12:51:40 -03003770 .no_reconnect = 1, \
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003771 .size_of_priv = sizeof(struct dib0700_state), \
Patrick Boettcher6958eff2006-09-19 12:51:40 -03003772 .i2c_algo = &dib0700_i2c_algo, \
3773 .identify_state = dib0700_identify_state
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003774
3775#define DIB0700_DEFAULT_STREAMING_CONFIG(ep) \
3776 .streaming_ctrl = dib0700_streaming_ctrl, \
3777 .stream = { \
3778 .type = USB_BULK, \
3779 .count = 4, \
3780 .endpoint = ep, \
3781 .u = { \
3782 .bulk = { \
3783 .buffersize = 39480, \
3784 } \
3785 } \
3786 }
3787
3788struct dvb_usb_device_properties dib0700_devices[] = {
3789 {
3790 DIB0700_DEFAULT_DEVICE_PROPERTIES,
3791
3792 .num_adapters = 1,
3793 .adapter = {
3794 {
Michael Krufky77eed212011-09-06 09:31:57 -03003795 .num_frontends = 1,
3796 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03003797 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
3798 .pid_filter_count = 32,
Olivier Greniee192a7c2011-01-14 13:58:59 -03003799 .pid_filter = stk7700p_pid_filter,
3800 .pid_filter_ctrl = stk7700p_pid_filter_ctrl,
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003801 .frontend_attach = stk7700p_frontend_attach,
3802 .tuner_attach = stk7700p_tuner_attach,
3803
3804 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03003805 }},
James Harper9e334c72014-06-08 21:24:20 -03003806 .size_of_priv = sizeof(struct dib0700_adapter_state),
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003807 },
3808 },
3809
dominik67053a42007-11-10 19:23:31 -03003810 .num_device_descs = 8,
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003811 .devices = {
3812 { "DiBcom STK7700P reference design",
Tomi Koivulahti49a13762006-10-19 07:27:19 -03003813 { &dib0700_usb_id_table[0], &dib0700_usb_id_table[1] },
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003814 { NULL },
3815 },
3816 { "Hauppauge Nova-T Stick",
Stefan Trabyf9aeba42006-11-12 13:02:51 -03003817 { &dib0700_usb_id_table[4], &dib0700_usb_id_table[9], NULL },
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003818 { NULL },
3819 },
Tomi Koivulahti49a13762006-10-19 07:27:19 -03003820 { "AVerMedia AVerTV DVB-T Volar",
Jose Carlos Garcia Sogoced8fec2006-11-14 05:01:47 -03003821 { &dib0700_usb_id_table[5], &dib0700_usb_id_table[10] },
Tomi Koivulahti49a13762006-10-19 07:27:19 -03003822 { NULL },
3823 },
3824 { "Compro Videomate U500",
Patrick Boettcher1f8ca4b2007-07-30 14:24:37 -03003825 { &dib0700_usb_id_table[6], &dib0700_usb_id_table[19] },
Tomi Koivulahti49a13762006-10-19 07:27:19 -03003826 { NULL },
Henning Schroeer0ce215e2006-10-19 07:58:22 -03003827 },
3828 { "Uniwill STK7700P based (Hama and others)",
3829 { &dib0700_usb_id_table[7], NULL },
3830 { NULL },
Michael Krufky8637a872006-11-08 16:47:32 -03003831 },
3832 { "Leadtek Winfast DTV Dongle (STK7700P based)",
Patrick Boettcher1e13c8f2009-09-19 05:24:40 -03003833 { &dib0700_usb_id_table[8], &dib0700_usb_id_table[34] },
Michael Krufky8637a872006-11-08 16:47:32 -03003834 { NULL },
Joachim Steigerfa3b8772007-10-08 20:08:46 -03003835 },
3836 { "AVerMedia AVerTV DVB-T Express",
3837 { &dib0700_usb_id_table[20] },
3838 { NULL },
dominik67053a42007-11-10 19:23:31 -03003839 },
dominik67053a42007-11-10 19:23:31 -03003840 { "Gigabyte U7000",
3841 { &dib0700_usb_id_table[21], NULL },
3842 { NULL },
Tomi Koivulahti49a13762006-10-19 07:27:19 -03003843 }
Darren Saltb1139e32007-08-18 18:05:31 -03003844 },
3845
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03003846 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03003847 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03003848 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03003849 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03003850 .allowed_protos = RC_BIT_RC5 |
3851 RC_BIT_RC6_MCE |
3852 RC_BIT_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03003853 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03003854 },
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003855 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
3856
3857 .num_adapters = 2,
3858 .adapter = {
3859 {
Michael Krufky77eed212011-09-06 09:31:57 -03003860 .num_frontends = 1,
3861 .fe = {{
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003862 .frontend_attach = bristol_frontend_attach,
3863 .tuner_attach = bristol_tuner_attach,
3864
3865 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03003866 }},
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003867 }, {
Michael Krufky77eed212011-09-06 09:31:57 -03003868 .num_frontends = 1,
3869 .fe = {{
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003870 .frontend_attach = bristol_frontend_attach,
3871 .tuner_attach = bristol_tuner_attach,
3872
3873 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
Michael Krufky77eed212011-09-06 09:31:57 -03003874 }},
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003875 }
3876 },
3877
3878 .num_device_descs = 1,
3879 .devices = {
3880 { "Hauppauge Nova-T 500 Dual DVB-T",
Tomi Koivulahti49a13762006-10-19 07:27:19 -03003881 { &dib0700_usb_id_table[2], &dib0700_usb_id_table[3], NULL },
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003882 { NULL },
3883 },
Janne Grunau82f3d552007-07-30 13:50:28 -03003884 },
3885
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03003886 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03003887 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03003888 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03003889 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03003890 .allowed_protos = RC_BIT_RC5 |
3891 RC_BIT_RC6_MCE |
3892 RC_BIT_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03003893 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03003894 },
Olivier DANET54d75eb2007-07-25 14:42:54 -03003895 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
3896
3897 .num_adapters = 2,
3898 .adapter = {
3899 {
Michael Krufky77eed212011-09-06 09:31:57 -03003900 .num_frontends = 1,
3901 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03003902 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
3903 .pid_filter_count = 32,
3904 .pid_filter = stk70x0p_pid_filter,
3905 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
Olivier DANET54d75eb2007-07-25 14:42:54 -03003906 .frontend_attach = stk7700d_frontend_attach,
3907 .tuner_attach = stk7700d_tuner_attach,
3908
3909 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03003910 }},
Olivier DANET54d75eb2007-07-25 14:42:54 -03003911 }, {
Michael Krufky77eed212011-09-06 09:31:57 -03003912 .num_frontends = 1,
3913 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03003914 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
3915 .pid_filter_count = 32,
3916 .pid_filter = stk70x0p_pid_filter,
3917 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
Olivier DANET54d75eb2007-07-25 14:42:54 -03003918 .frontend_attach = stk7700d_frontend_attach,
3919 .tuner_attach = stk7700d_tuner_attach,
3920
3921 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
Michael Krufky77eed212011-09-06 09:31:57 -03003922 }},
Olivier DANET54d75eb2007-07-25 14:42:54 -03003923 }
3924 },
3925
James A Webb200e8612009-08-04 02:38:05 -03003926 .num_device_descs = 5,
Olivier DANET54d75eb2007-07-25 14:42:54 -03003927 .devices = {
3928 { "Pinnacle PCTV 2000e",
3929 { &dib0700_usb_id_table[11], NULL },
3930 { NULL },
3931 },
3932 { "Terratec Cinergy DT XS Diversity",
3933 { &dib0700_usb_id_table[12], NULL },
3934 { NULL },
3935 },
Darren Saltfaebb912007-08-18 18:04:00 -03003936 { "Hauppauge Nova-TD Stick/Elgato Eye-TV Diversity",
Olivier DANET54d75eb2007-07-25 14:42:54 -03003937 { &dib0700_usb_id_table[13], NULL },
3938 { NULL },
3939 },
Patrick Boettcher01373a52007-07-30 12:49:04 -03003940 { "DiBcom STK7700D reference design",
Patrick Boettcherb6884a12007-07-27 10:08:51 -03003941 { &dib0700_usb_id_table[14], NULL },
3942 { NULL },
Yusuf Altinbb1b0822009-01-08 07:58:45 -03003943 },
James A Webb200e8612009-08-04 02:38:05 -03003944 { "YUAN High-Tech DiBcom STK7700D",
3945 { &dib0700_usb_id_table[55], NULL },
3946 { NULL },
3947 },
Yusuf Altinbb1b0822009-01-08 07:58:45 -03003948
Olivier DANET54d75eb2007-07-25 14:42:54 -03003949 },
Janne Grunau82f3d552007-07-30 13:50:28 -03003950
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03003951 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03003952 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03003953 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03003954 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03003955 .allowed_protos = RC_BIT_RC5 |
3956 RC_BIT_RC6_MCE |
3957 RC_BIT_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03003958 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03003959 },
Patrick Boettcher01373a52007-07-30 12:49:04 -03003960 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
3961
3962 .num_adapters = 1,
3963 .adapter = {
3964 {
Michael Krufky77eed212011-09-06 09:31:57 -03003965 .num_frontends = 1,
3966 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03003967 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
3968 .pid_filter_count = 32,
3969 .pid_filter = stk70x0p_pid_filter,
3970 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
Daniel Gimpelevich132c3182008-01-25 06:02:42 -03003971 .frontend_attach = stk7700P2_frontend_attach,
3972 .tuner_attach = stk7700d_tuner_attach,
3973
3974 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03003975 }},
Daniel Gimpelevich132c3182008-01-25 06:02:42 -03003976 },
3977 },
3978
Yusuf Altinbb1b0822009-01-08 07:58:45 -03003979 .num_device_descs = 3,
Daniel Gimpelevich132c3182008-01-25 06:02:42 -03003980 .devices = {
3981 { "ASUS My Cinema U3000 Mini DVBT Tuner",
3982 { &dib0700_usb_id_table[23], NULL },
3983 { NULL },
3984 },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03003985 { "Yuan EC372S",
3986 { &dib0700_usb_id_table[31], NULL },
3987 { NULL },
Yusuf Altinbb1b0822009-01-08 07:58:45 -03003988 },
3989 { "Terratec Cinergy T Express",
3990 { &dib0700_usb_id_table[42], NULL },
3991 { NULL },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03003992 }
Chris Rankin48aa7392008-09-25 06:52:24 -03003993 },
3994
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03003995 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03003996 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03003997 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03003998 .module_name = "dib0700",
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03003999 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004000 .allowed_protos = RC_BIT_RC5 |
4001 RC_BIT_RC6_MCE |
4002 RC_BIT_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03004003 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004004 },
Daniel Gimpelevich132c3182008-01-25 06:02:42 -03004005 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4006
4007 .num_adapters = 1,
4008 .adapter = {
4009 {
Michael Krufky77eed212011-09-06 09:31:57 -03004010 .num_frontends = 1,
4011 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03004012 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4013 .pid_filter_count = 32,
4014 .pid_filter = stk70x0p_pid_filter,
4015 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
Patrick Boettcher01373a52007-07-30 12:49:04 -03004016 .frontend_attach = stk7070p_frontend_attach,
4017 .tuner_attach = dib7070p_tuner_attach,
4018
4019 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004020 }},
Patrick Boettcher01373a52007-07-30 12:49:04 -03004021 .size_of_priv = sizeof(struct dib0700_adapter_state),
4022 },
4023 },
4024
Gianluca Gennari0bc9d392012-04-14 09:14:07 -03004025 .num_device_descs = 12,
Patrick Boettcher01373a52007-07-30 12:49:04 -03004026 .devices = {
4027 { "DiBcom STK7070P reference design",
4028 { &dib0700_usb_id_table[15], NULL },
4029 { NULL },
4030 },
4031 { "Pinnacle PCTV DVB-T Flash Stick",
4032 { &dib0700_usb_id_table[16], NULL },
4033 { NULL },
4034 },
Yousef Lamlum7999a812008-01-25 05:51:48 -03004035 { "Artec T14BR DVB-T",
4036 { &dib0700_usb_id_table[22], NULL },
4037 { NULL },
Daniel Gimpelevich132c3182008-01-25 06:02:42 -03004038 },
4039 { "ASUS My Cinema U3100 Mini DVBT Tuner",
4040 { &dib0700_usb_id_table[24], NULL },
4041 { NULL },
4042 },
Tim Taubertc7637b12008-01-25 06:16:36 -03004043 { "Hauppauge Nova-T Stick",
4044 { &dib0700_usb_id_table[25], NULL },
4045 { NULL },
4046 },
Darren Salt13b83b52008-01-25 06:20:02 -03004047 { "Hauppauge Nova-T MyTV.t",
4048 { &dib0700_usb_id_table[26], NULL },
4049 { NULL },
4050 },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03004051 { "Pinnacle PCTV 72e",
4052 { &dib0700_usb_id_table[29], NULL },
4053 { NULL },
4054 },
4055 { "Pinnacle PCTV 73e",
4056 { &dib0700_usb_id_table[30], NULL },
4057 { NULL },
4058 },
Klaus Flittner919a5482009-03-29 09:12:06 -03004059 { "Elgato EyeTV DTT",
4060 { &dib0700_usb_id_table[49], NULL },
4061 { NULL },
4062 },
Pascal Terjan9abb6e62009-02-26 10:31:41 -03004063 { "Yuan PD378S",
4064 { &dib0700_usb_id_table[45], NULL },
4065 { NULL },
4066 },
Armin Schenker513846e2009-04-20 11:57:49 -03004067 { "Elgato EyeTV Dtt Dlx PD378S",
4068 { &dib0700_usb_id_table[50], NULL },
4069 { NULL },
4070 },
Gianluca Gennari0bc9d392012-04-14 09:14:07 -03004071 { "Elgato EyeTV DTT rev. 2",
Olivier Grenief45f5132012-12-31 09:47:10 -03004072 { &dib0700_usb_id_table[80], NULL },
Gianluca Gennari0bc9d392012-04-14 09:14:07 -03004073 { NULL },
4074 },
Tim Taubertc7637b12008-01-25 06:16:36 -03004075 },
4076
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004077 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004078 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004079 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004080 .module_name = "dib0700",
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03004081 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004082 .allowed_protos = RC_BIT_RC5 |
4083 RC_BIT_RC6_MCE |
4084 RC_BIT_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03004085 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004086 },
Patrick Boettcher01373a52007-07-30 12:49:04 -03004087 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4088
Olivier Grenie74b76f22009-09-02 08:19:19 -03004089 .num_adapters = 1,
4090 .adapter = {
4091 {
Michael Krufky77eed212011-09-06 09:31:57 -03004092 .num_frontends = 1,
4093 .fe = {{
Mauro Carvalho Chehab648732f2009-11-04 12:11:43 -02004094 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4095 .pid_filter_count = 32,
4096 .pid_filter = stk70x0p_pid_filter,
4097 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
Olivier Grenie74b76f22009-09-02 08:19:19 -03004098 .frontend_attach = stk7070p_frontend_attach,
4099 .tuner_attach = dib7070p_tuner_attach,
4100
4101 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004102 }},
Olivier Grenie74b76f22009-09-02 08:19:19 -03004103 .size_of_priv = sizeof(struct dib0700_adapter_state),
4104 },
4105 },
4106
Patrick Boettcher20232c42009-12-01 12:08:56 -03004107 .num_device_descs = 3,
Olivier Grenie74b76f22009-09-02 08:19:19 -03004108 .devices = {
4109 { "Pinnacle PCTV 73A",
4110 { &dib0700_usb_id_table[56], NULL },
4111 { NULL },
4112 },
4113 { "Pinnacle PCTV 73e SE",
Patrick Boettcher20232c42009-12-01 12:08:56 -03004114 { &dib0700_usb_id_table[57], &dib0700_usb_id_table[65], NULL },
Olivier Grenie74b76f22009-09-02 08:19:19 -03004115 { NULL },
4116 },
4117 { "Pinnacle PCTV 282e",
Patrick Boettcher20232c42009-12-01 12:08:56 -03004118 { &dib0700_usb_id_table[58], &dib0700_usb_id_table[66], NULL },
Olivier Grenie74b76f22009-09-02 08:19:19 -03004119 { NULL },
4120 },
4121 },
4122
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004123 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004124 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004125 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004126 .module_name = "dib0700",
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03004127 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004128 .allowed_protos = RC_BIT_RC5 |
4129 RC_BIT_RC6_MCE |
4130 RC_BIT_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03004131 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004132 },
Olivier Grenie74b76f22009-09-02 08:19:19 -03004133 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4134
Patrick Boettcher01373a52007-07-30 12:49:04 -03004135 .num_adapters = 2,
4136 .adapter = {
4137 {
Michael Krufky77eed212011-09-06 09:31:57 -03004138 .num_frontends = 1,
4139 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03004140 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4141 .pid_filter_count = 32,
4142 .pid_filter = stk70x0p_pid_filter,
4143 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
Jiri Slaby2b05b882012-01-10 14:11:24 -03004144 .frontend_attach = novatd_frontend_attach,
Patrick Boettcher01373a52007-07-30 12:49:04 -03004145 .tuner_attach = dib7070p_tuner_attach,
4146
4147 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004148 }},
Patrick Boettcher01373a52007-07-30 12:49:04 -03004149 .size_of_priv = sizeof(struct dib0700_adapter_state),
4150 }, {
Michael Krufky77eed212011-09-06 09:31:57 -03004151 .num_frontends = 1,
4152 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03004153 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4154 .pid_filter_count = 32,
4155 .pid_filter = stk70x0p_pid_filter,
4156 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
Jiri Slaby2b05b882012-01-10 14:11:24 -03004157 .frontend_attach = novatd_frontend_attach,
Patrick Boettcher01373a52007-07-30 12:49:04 -03004158 .tuner_attach = dib7070p_tuner_attach,
4159
4160 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
Michael Krufky77eed212011-09-06 09:31:57 -03004161 }},
Patrick Boettcher01373a52007-07-30 12:49:04 -03004162 .size_of_priv = sizeof(struct dib0700_adapter_state),
4163 }
4164 },
4165
Michael Krufkyc859e6e2013-06-30 12:43:58 -03004166 .num_device_descs = 3,
Jiri Slaby9b6ba572012-01-10 14:11:22 -03004167 .devices = {
4168 { "Hauppauge Nova-TD Stick (52009)",
4169 { &dib0700_usb_id_table[35], NULL },
4170 { NULL },
4171 },
Michael Krufkyc859e6e2013-06-30 12:43:58 -03004172 { "PCTV 2002e",
4173 { &dib0700_usb_id_table[81], NULL },
4174 { NULL },
4175 },
4176 { "PCTV 2002e SE",
4177 { &dib0700_usb_id_table[82], NULL },
4178 { NULL },
4179 },
Jiri Slaby9b6ba572012-01-10 14:11:22 -03004180 },
4181
4182 .rc.core = {
4183 .rc_interval = DEFAULT_RC_INTERVAL,
4184 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4185 .module_name = "dib0700",
4186 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004187 .allowed_protos = RC_BIT_RC5 |
4188 RC_BIT_RC6_MCE |
4189 RC_BIT_NEC,
Jiri Slaby9b6ba572012-01-10 14:11:22 -03004190 .change_protocol = dib0700_change_protocol,
4191 },
4192 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4193
4194 .num_adapters = 2,
4195 .adapter = {
4196 {
4197 .num_frontends = 1,
4198 .fe = {{
4199 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4200 .pid_filter_count = 32,
4201 .pid_filter = stk70x0p_pid_filter,
4202 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
4203 .frontend_attach = stk7070pd_frontend_attach0,
4204 .tuner_attach = dib7070p_tuner_attach,
4205
4206 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
4207 }},
4208 .size_of_priv = sizeof(struct dib0700_adapter_state),
4209 }, {
4210 .num_frontends = 1,
4211 .fe = {{
4212 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4213 .pid_filter_count = 32,
4214 .pid_filter = stk70x0p_pid_filter,
4215 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
4216 .frontend_attach = stk7070pd_frontend_attach1,
4217 .tuner_attach = dib7070p_tuner_attach,
4218
4219 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
4220 }},
4221 .size_of_priv = sizeof(struct dib0700_adapter_state),
4222 }
4223 },
4224
4225 .num_device_descs = 5,
Patrick Boettcher01373a52007-07-30 12:49:04 -03004226 .devices = {
4227 { "DiBcom STK7070PD reference design",
4228 { &dib0700_usb_id_table[17], NULL },
4229 { NULL },
4230 },
4231 { "Pinnacle PCTV Dual DVB-T Diversity Stick",
4232 { &dib0700_usb_id_table[18], NULL },
4233 { NULL },
Michael Krufkyd01eb2d2008-07-03 23:43:36 -03004234 },
Michael Krufky9a0c04a2008-09-03 17:12:24 -03004235 { "Hauppauge Nova-TD-500 (84xxx)",
4236 { &dib0700_usb_id_table[36], NULL },
4237 { NULL },
Nicolas Fournierdb4b2d12009-01-13 07:15:25 -03004238 },
Patrick Boettchera9b8fe32009-05-20 05:35:02 -03004239 { "Terratec Cinergy DT USB XS Diversity/ T5",
4240 { &dib0700_usb_id_table[43],
4241 &dib0700_usb_id_table[53], NULL},
Nicolas Fournierdb4b2d12009-01-13 07:15:25 -03004242 { NULL },
sebastian.blanes@gmail.com0a6e1ed2009-02-24 14:51:43 -03004243 },
4244 { "Sony PlayTV",
4245 { &dib0700_usb_id_table[44], NULL },
4246 { NULL },
Michael Müller84e2f032010-04-26 22:18:57 -03004247 },
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004248 },
4249
4250 .rc.core = {
4251 .rc_interval = DEFAULT_RC_INTERVAL,
4252 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4253 .module_name = "dib0700",
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03004254 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004255 .allowed_protos = RC_BIT_RC5 |
4256 RC_BIT_RC6_MCE |
4257 RC_BIT_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03004258 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004259 },
4260 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4261
4262 .num_adapters = 2,
4263 .adapter = {
4264 {
Michael Krufky77eed212011-09-06 09:31:57 -03004265 .num_frontends = 1,
4266 .fe = {{
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004267 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4268 .pid_filter_count = 32,
4269 .pid_filter = stk70x0p_pid_filter,
4270 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
4271 .frontend_attach = stk7070pd_frontend_attach0,
4272 .tuner_attach = dib7070p_tuner_attach,
4273
4274 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004275 }},
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004276 .size_of_priv = sizeof(struct dib0700_adapter_state),
4277 }, {
Michael Krufky77eed212011-09-06 09:31:57 -03004278 .num_frontends = 1,
4279 .fe = {{
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004280 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4281 .pid_filter_count = 32,
4282 .pid_filter = stk70x0p_pid_filter,
4283 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
4284 .frontend_attach = stk7070pd_frontend_attach1,
4285 .tuner_attach = dib7070p_tuner_attach,
4286
4287 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
Michael Krufky77eed212011-09-06 09:31:57 -03004288 }},
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004289 .size_of_priv = sizeof(struct dib0700_adapter_state),
4290 }
4291 },
4292
4293 .num_device_descs = 1,
4294 .devices = {
Michael Müller84e2f032010-04-26 22:18:57 -03004295 { "Elgato EyeTV Diversity",
4296 { &dib0700_usb_id_table[68], NULL },
4297 { NULL },
4298 },
Arne Luehrsc985a8d2009-01-21 01:37:20 -03004299 },
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004300
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004301 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004302 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004303 .rc_codes = RC_MAP_DIB0700_NEC_TABLE,
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004304 .module_name = "dib0700",
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03004305 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004306 .allowed_protos = RC_BIT_RC5 |
4307 RC_BIT_RC6_MCE |
4308 RC_BIT_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03004309 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004310 },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03004311 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4312
4313 .num_adapters = 1,
4314 .adapter = {
4315 {
Michael Krufky77eed212011-09-06 09:31:57 -03004316 .num_frontends = 1,
4317 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03004318 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4319 .pid_filter_count = 32,
4320 .pid_filter = stk70x0p_pid_filter,
4321 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03004322 .frontend_attach = stk7700ph_frontend_attach,
4323 .tuner_attach = stk7700ph_tuner_attach,
4324
4325 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004326 }},
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03004327 .size_of_priv = sizeof(struct
4328 dib0700_adapter_state),
4329 },
4330 },
4331
Pete Hildebrandtc53d83c2009-08-05 11:46:38 -03004332 .num_device_descs = 9,
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03004333 .devices = {
4334 { "Terratec Cinergy HT USB XE",
4335 { &dib0700_usb_id_table[27], NULL },
4336 { NULL },
4337 },
4338 { "Pinnacle Expresscard 320cx",
4339 { &dib0700_usb_id_table[28], NULL },
4340 { NULL },
4341 },
4342 { "Terratec Cinergy HT Express",
4343 { &dib0700_usb_id_table[32], NULL },
4344 { NULL },
4345 },
Finn Thain17a370b2008-09-06 13:42:47 -03004346 { "Gigabyte U8000-RH",
4347 { &dib0700_usb_id_table[37], NULL },
4348 { NULL },
4349 },
Daniel Oliveira Nascimento8751aaa2008-09-07 12:39:44 -03004350 { "YUAN High-Tech STK7700PH",
4351 { &dib0700_usb_id_table[38], NULL },
4352 { NULL },
4353 },
Albert Comerma57697432008-09-07 12:43:33 -03004354 { "Asus My Cinema-U3000Hybrid",
4355 { &dib0700_usb_id_table[39], NULL },
4356 { NULL },
4357 },
Xoan Loureiro16ba1ee2009-03-29 08:43:36 -03004358 { "YUAN High-Tech MC770",
4359 { &dib0700_usb_id_table[48], NULL },
4360 { NULL },
4361 },
tomas petrf0f4ae72009-05-20 05:28:05 -03004362 { "Leadtek WinFast DTV Dongle H",
4363 { &dib0700_usb_id_table[51], NULL },
4364 { NULL },
4365 },
Pete Hildebrandtc53d83c2009-08-05 11:46:38 -03004366 { "YUAN High-Tech STK7700D",
4367 { &dib0700_usb_id_table[54], NULL },
4368 { NULL },
4369 },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03004370 },
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004371
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004372 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004373 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004374 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004375 .module_name = "dib0700",
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03004376 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004377 .allowed_protos = RC_BIT_RC5 |
4378 RC_BIT_RC6_MCE |
4379 RC_BIT_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03004380 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004381 },
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03004382 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4383 .num_adapters = 1,
4384 .adapter = {
4385 {
Michael Krufky77eed212011-09-06 09:31:57 -03004386 .num_frontends = 1,
4387 .fe = {{
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03004388 .frontend_attach = s5h1411_frontend_attach,
4389 .tuner_attach = xc5000_tuner_attach,
4390
4391 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004392 }},
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03004393 .size_of_priv = sizeof(struct
4394 dib0700_adapter_state),
4395 },
4396 },
4397
Devin Heitmuellerd2fc3bf2008-09-25 06:22:23 -03004398 .num_device_descs = 2,
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03004399 .devices = {
4400 { "Pinnacle PCTV HD Pro USB Stick",
4401 { &dib0700_usb_id_table[40], NULL },
4402 { NULL },
4403 },
Devin Heitmuellerd2fc3bf2008-09-25 06:22:23 -03004404 { "Pinnacle PCTV HD USB Stick",
4405 { &dib0700_usb_id_table[41], NULL },
4406 { NULL },
4407 },
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03004408 },
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004409
4410 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004411 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004412 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004413 .module_name = "dib0700",
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03004414 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004415 .allowed_protos = RC_BIT_RC5 |
4416 RC_BIT_RC6_MCE |
4417 RC_BIT_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03004418 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004419 },
Michael Krufkyce904bc2009-01-19 01:12:55 -03004420 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4421 .num_adapters = 1,
4422 .adapter = {
4423 {
Michael Krufky77eed212011-09-06 09:31:57 -03004424 .num_frontends = 1,
4425 .fe = {{
Michael Krufkyce904bc2009-01-19 01:12:55 -03004426 .frontend_attach = lgdt3305_frontend_attach,
4427 .tuner_attach = mxl5007t_tuner_attach,
4428
4429 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004430 }},
Michael Krufkyce904bc2009-01-19 01:12:55 -03004431 .size_of_priv = sizeof(struct
4432 dib0700_adapter_state),
4433 },
4434 },
4435
4436 .num_device_descs = 2,
4437 .devices = {
4438 { "Hauppauge ATSC MiniCard (B200)",
4439 { &dib0700_usb_id_table[46], NULL },
4440 { NULL },
4441 },
4442 { "Hauppauge ATSC MiniCard (B210)",
4443 { &dib0700_usb_id_table[47], NULL },
4444 { NULL },
4445 },
4446 },
Olivier Grenied300bd62009-09-15 06:55:35 -03004447 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4448
4449 .num_adapters = 1,
4450 .adapter = {
4451 {
Michael Krufky77eed212011-09-06 09:31:57 -03004452 .num_frontends = 1,
4453 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03004454 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4455 .pid_filter_count = 32,
4456 .pid_filter = stk70x0p_pid_filter,
4457 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
Olivier Grenie90e12ce2010-09-07 12:50:45 -03004458 .frontend_attach = stk7770p_frontend_attach,
Olivier Grenied300bd62009-09-15 06:55:35 -03004459 .tuner_attach = dib7770p_tuner_attach,
4460
4461 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004462 }},
Olivier Grenied300bd62009-09-15 06:55:35 -03004463 .size_of_priv =
Patrick Boettcherdb481382009-09-15 07:16:51 -03004464 sizeof(struct dib0700_adapter_state),
Olivier Grenied300bd62009-09-15 06:55:35 -03004465 },
4466 },
4467
Stéphane Elmalehd1402302011-05-21 07:33:38 -03004468 .num_device_descs = 4,
Olivier Grenied300bd62009-09-15 06:55:35 -03004469 .devices = {
4470 { "DiBcom STK7770P reference design",
4471 { &dib0700_usb_id_table[59], NULL },
4472 { NULL },
4473 },
Patrick Boettcher1e13c8f2009-09-19 05:24:40 -03004474 { "Terratec Cinergy T USB XXS (HD)/ T3",
4475 { &dib0700_usb_id_table[33],
4476 &dib0700_usb_id_table[52],
4477 &dib0700_usb_id_table[60], NULL},
Patrick Boettcherdb481382009-09-15 07:16:51 -03004478 { NULL },
4479 },
Lukas Max Fisch498e6772011-02-08 16:51:45 -03004480 { "TechniSat AirStar TeleStick 2",
4481 { &dib0700_usb_id_table[74], NULL },
4482 { NULL },
4483 },
Stéphane Elmalehd1402302011-05-21 07:33:38 -03004484 { "Medion CTX1921 DVB-T USB",
4485 { &dib0700_usb_id_table[75], NULL },
4486 { NULL },
4487 },
Olivier Grenied300bd62009-09-15 06:55:35 -03004488 },
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004489
4490 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004491 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004492 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004493 .module_name = "dib0700",
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03004494 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004495 .allowed_protos = RC_BIT_RC5 |
4496 RC_BIT_RC6_MCE |
4497 RC_BIT_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03004498 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004499 },
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03004500 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4501 .num_adapters = 1,
4502 .adapter = {
4503 {
Michael Krufky77eed212011-09-06 09:31:57 -03004504 .num_frontends = 1,
4505 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03004506 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4507 .pid_filter_count = 32,
Olivier Grenie03245a52009-12-04 13:27:57 -03004508 .pid_filter = stk80xx_pid_filter,
4509 .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03004510 .frontend_attach = stk807x_frontend_attach,
4511 .tuner_attach = dib807x_tuner_attach,
4512
4513 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004514 }},
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03004515 .size_of_priv =
4516 sizeof(struct dib0700_adapter_state),
4517 },
4518 },
4519
S?rgio Fortier8a378e82009-09-28 04:19:21 -03004520 .num_device_descs = 3,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03004521 .devices = {
4522 { "DiBcom STK807xP reference design",
4523 { &dib0700_usb_id_table[62], NULL },
4524 { NULL },
4525 },
Mauro Carvalho Chehabaaeab302009-09-16 09:18:26 -03004526 { "Prolink Pixelview SBTVD",
4527 { &dib0700_usb_id_table[63], NULL },
4528 { NULL },
4529 },
S?rgio Fortier8a378e82009-09-28 04:19:21 -03004530 { "EvolutePC TVWay+",
4531 { &dib0700_usb_id_table[64], NULL },
4532 { NULL },
4533 },
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03004534 },
4535
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004536 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004537 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004538 .rc_codes = RC_MAP_DIB0700_NEC_TABLE,
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004539 .module_name = "dib0700",
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03004540 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004541 .allowed_protos = RC_BIT_RC5 |
4542 RC_BIT_RC6_MCE |
4543 RC_BIT_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03004544 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004545 },
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03004546 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4547 .num_adapters = 2,
4548 .adapter = {
4549 {
Michael Krufky77eed212011-09-06 09:31:57 -03004550 .num_frontends = 1,
4551 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03004552 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4553 .pid_filter_count = 32,
Olivier Grenie03245a52009-12-04 13:27:57 -03004554 .pid_filter = stk80xx_pid_filter,
4555 .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03004556 .frontend_attach = stk807xpvr_frontend_attach0,
4557 .tuner_attach = dib807x_tuner_attach,
4558
4559 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004560 }},
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03004561 .size_of_priv =
4562 sizeof(struct dib0700_adapter_state),
4563 },
4564 {
Michael Krufky77eed212011-09-06 09:31:57 -03004565 .num_frontends = 1,
4566 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03004567 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4568 .pid_filter_count = 32,
Olivier Grenie03245a52009-12-04 13:27:57 -03004569 .pid_filter = stk80xx_pid_filter,
4570 .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03004571 .frontend_attach = stk807xpvr_frontend_attach1,
4572 .tuner_attach = dib807x_tuner_attach,
4573
4574 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
Michael Krufky77eed212011-09-06 09:31:57 -03004575 }},
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03004576 .size_of_priv =
4577 sizeof(struct dib0700_adapter_state),
4578 },
4579 },
4580
4581 .num_device_descs = 1,
4582 .devices = {
4583 { "DiBcom STK807xPVR reference design",
4584 { &dib0700_usb_id_table[61], NULL },
4585 { NULL },
4586 },
4587 },
4588
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004589 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004590 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004591 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004592 .module_name = "dib0700",
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03004593 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004594 .allowed_protos = RC_BIT_RC5 |
4595 RC_BIT_RC6_MCE |
4596 RC_BIT_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03004597 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004598 },
Olivier Grenie03245a52009-12-04 13:27:57 -03004599 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4600 .num_adapters = 1,
4601 .adapter = {
4602 {
Michael Krufky77eed212011-09-06 09:31:57 -03004603 .num_frontends = 1,
4604 .fe = {{
Olivier Grenie03245a52009-12-04 13:27:57 -03004605 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
4606 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4607 .pid_filter_count = 32,
4608 .pid_filter = stk80xx_pid_filter,
4609 .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
4610 .frontend_attach = stk809x_frontend_attach,
4611 .tuner_attach = dib809x_tuner_attach,
4612
4613 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004614 }},
Olivier Grenie03245a52009-12-04 13:27:57 -03004615 .size_of_priv =
4616 sizeof(struct dib0700_adapter_state),
4617 },
4618 },
4619
4620 .num_device_descs = 1,
4621 .devices = {
4622 { "DiBcom STK8096GP reference design",
4623 { &dib0700_usb_id_table[67], NULL },
4624 { NULL },
4625 },
4626 },
4627
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004628 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004629 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004630 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004631 .module_name = "dib0700",
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03004632 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004633 .allowed_protos = RC_BIT_RC5 |
4634 RC_BIT_RC6_MCE |
4635 RC_BIT_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03004636 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004637 },
Olivier Greniebe9bae12011-01-04 05:42:19 -03004638 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4639 .num_adapters = 1,
4640 .adapter = {
4641 {
Michael Krufky77eed212011-09-06 09:31:57 -03004642 .num_frontends = 1,
4643 .fe = {{
Olivier Greniebe9bae12011-01-04 05:42:19 -03004644 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
4645 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4646 .pid_filter_count = 32,
4647 .pid_filter = dib90x0_pid_filter,
4648 .pid_filter_ctrl = dib90x0_pid_filter_ctrl,
4649 .frontend_attach = stk9090m_frontend_attach,
4650 .tuner_attach = dib9090_tuner_attach,
4651
4652 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004653 }},
Olivier Greniebe9bae12011-01-04 05:42:19 -03004654 .size_of_priv =
4655 sizeof(struct dib0700_adapter_state),
4656 },
4657 },
4658
4659 .num_device_descs = 1,
4660 .devices = {
4661 { "DiBcom STK9090M reference design",
4662 { &dib0700_usb_id_table[69], NULL },
4663 { NULL },
4664 },
4665 },
4666
4667 .rc.core = {
4668 .rc_interval = DEFAULT_RC_INTERVAL,
4669 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4670 .module_name = "dib0700",
4671 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004672 .allowed_protos = RC_BIT_RC5 |
4673 RC_BIT_RC6_MCE |
4674 RC_BIT_NEC,
Olivier Greniebe9bae12011-01-04 05:42:19 -03004675 .change_protocol = dib0700_change_protocol,
4676 },
4677 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4678 .num_adapters = 1,
4679 .adapter = {
4680 {
Michael Krufky77eed212011-09-06 09:31:57 -03004681 .num_frontends = 1,
4682 .fe = {{
Olivier Greniebe9bae12011-01-04 05:42:19 -03004683 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
4684 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4685 .pid_filter_count = 32,
4686 .pid_filter = stk80xx_pid_filter,
4687 .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
4688 .frontend_attach = nim8096md_frontend_attach,
4689 .tuner_attach = nim8096md_tuner_attach,
4690
4691 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004692 }},
Olivier Greniebe9bae12011-01-04 05:42:19 -03004693 .size_of_priv =
4694 sizeof(struct dib0700_adapter_state),
4695 },
4696 },
4697
4698 .num_device_descs = 1,
4699 .devices = {
4700 { "DiBcom NIM8096MD reference design",
4701 { &dib0700_usb_id_table[70], NULL },
4702 { NULL },
4703 },
4704 },
4705
4706 .rc.core = {
4707 .rc_interval = DEFAULT_RC_INTERVAL,
4708 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4709 .module_name = "dib0700",
4710 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004711 .allowed_protos = RC_BIT_RC5 |
4712 RC_BIT_RC6_MCE |
4713 RC_BIT_NEC,
Olivier Greniebe9bae12011-01-04 05:42:19 -03004714 .change_protocol = dib0700_change_protocol,
4715 },
4716 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4717 .num_adapters = 1,
4718 .adapter = {
4719 {
Michael Krufky77eed212011-09-06 09:31:57 -03004720 .num_frontends = 1,
4721 .fe = {{
Olivier Greniebe9bae12011-01-04 05:42:19 -03004722 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
4723 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4724 .pid_filter_count = 32,
4725 .pid_filter = dib90x0_pid_filter,
4726 .pid_filter_ctrl = dib90x0_pid_filter_ctrl,
4727 .frontend_attach = nim9090md_frontend_attach,
4728 .tuner_attach = nim9090md_tuner_attach,
4729
4730 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004731 }},
Olivier Greniebe9bae12011-01-04 05:42:19 -03004732 .size_of_priv =
4733 sizeof(struct dib0700_adapter_state),
4734 },
4735 },
4736
4737 .num_device_descs = 1,
4738 .devices = {
4739 { "DiBcom NIM9090MD reference design",
4740 { &dib0700_usb_id_table[71], NULL },
4741 { NULL },
4742 },
4743 },
4744
4745 .rc.core = {
4746 .rc_interval = DEFAULT_RC_INTERVAL,
4747 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4748 .module_name = "dib0700",
4749 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004750 .allowed_protos = RC_BIT_RC5 |
4751 RC_BIT_RC6_MCE |
4752 RC_BIT_NEC,
Olivier Greniebe9bae12011-01-04 05:42:19 -03004753 .change_protocol = dib0700_change_protocol,
4754 },
4755 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4756 .num_adapters = 1,
4757 .adapter = {
4758 {
Michael Krufky77eed212011-09-06 09:31:57 -03004759 .num_frontends = 1,
4760 .fe = {{
Olivier Greniebe9bae12011-01-04 05:42:19 -03004761 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
4762 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4763 .pid_filter_count = 32,
4764 .pid_filter = stk70x0p_pid_filter,
4765 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
4766 .frontend_attach = nim7090_frontend_attach,
4767 .tuner_attach = nim7090_tuner_attach,
4768
4769 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004770 }},
Olivier Greniebe9bae12011-01-04 05:42:19 -03004771 .size_of_priv =
4772 sizeof(struct dib0700_adapter_state),
4773 },
4774 },
4775
4776 .num_device_descs = 1,
4777 .devices = {
4778 { "DiBcom NIM7090 reference design",
4779 { &dib0700_usb_id_table[72], NULL },
4780 { NULL },
4781 },
4782 },
4783
4784 .rc.core = {
4785 .rc_interval = DEFAULT_RC_INTERVAL,
4786 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4787 .module_name = "dib0700",
4788 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004789 .allowed_protos = RC_BIT_RC5 |
4790 RC_BIT_RC6_MCE |
4791 RC_BIT_NEC,
Olivier Greniebe9bae12011-01-04 05:42:19 -03004792 .change_protocol = dib0700_change_protocol,
4793 },
4794 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4795 .num_adapters = 2,
4796 .adapter = {
4797 {
Michael Krufky77eed212011-09-06 09:31:57 -03004798 .num_frontends = 1,
4799 .fe = {{
Olivier Greniebe9bae12011-01-04 05:42:19 -03004800 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
4801 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4802 .pid_filter_count = 32,
4803 .pid_filter = stk70x0p_pid_filter,
4804 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
4805 .frontend_attach = tfe7090pvr_frontend0_attach,
4806 .tuner_attach = tfe7090pvr_tuner0_attach,
4807
4808 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
Michael Krufky77eed212011-09-06 09:31:57 -03004809 }},
Olivier Greniebe9bae12011-01-04 05:42:19 -03004810 .size_of_priv =
4811 sizeof(struct dib0700_adapter_state),
4812 },
4813 {
Michael Krufky77eed212011-09-06 09:31:57 -03004814 .num_frontends = 1,
4815 .fe = {{
Olivier Greniebe9bae12011-01-04 05:42:19 -03004816 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
4817 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4818 .pid_filter_count = 32,
4819 .pid_filter = stk70x0p_pid_filter,
4820 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
4821 .frontend_attach = tfe7090pvr_frontend1_attach,
4822 .tuner_attach = tfe7090pvr_tuner1_attach,
4823
4824 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004825 }},
Olivier Greniebe9bae12011-01-04 05:42:19 -03004826 .size_of_priv =
4827 sizeof(struct dib0700_adapter_state),
4828 },
4829 },
4830
4831 .num_device_descs = 1,
4832 .devices = {
4833 { "DiBcom TFE7090PVR reference design",
4834 { &dib0700_usb_id_table[73], NULL },
4835 { NULL },
4836 },
4837 },
4838
4839 .rc.core = {
4840 .rc_interval = DEFAULT_RC_INTERVAL,
4841 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4842 .module_name = "dib0700",
4843 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004844 .allowed_protos = RC_BIT_RC5 |
4845 RC_BIT_RC6_MCE |
4846 RC_BIT_NEC,
Olivier Greniebe9bae12011-01-04 05:42:19 -03004847 .change_protocol = dib0700_change_protocol,
4848 },
Davide Ferri8d009a02009-06-23 22:34:06 -03004849 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4850 .num_adapters = 1,
4851 .adapter = {
4852 {
Michael Krufky77eed212011-09-06 09:31:57 -03004853 .num_frontends = 1,
4854 .fe = {{
Devin Heitmueller01f16262009-06-24 00:07:01 -03004855 .frontend_attach = pctv340e_frontend_attach,
Davide Ferri8d009a02009-06-23 22:34:06 -03004856 .tuner_attach = xc4000_tuner_attach,
4857
4858 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004859 }},
Davide Ferri8d009a02009-06-23 22:34:06 -03004860 .size_of_priv = sizeof(struct
4861 dib0700_adapter_state),
4862 },
4863 },
4864
Devin Heitmueller33fb1682009-06-23 22:48:02 -03004865 .num_device_descs = 2,
Davide Ferri8d009a02009-06-23 22:34:06 -03004866 .devices = {
4867 { "Pinnacle PCTV 340e HD Pro USB Stick",
4868 { &dib0700_usb_id_table[76], NULL },
4869 { NULL },
4870 },
Devin Heitmueller33fb1682009-06-23 22:48:02 -03004871 { "Pinnacle PCTV Hybrid Stick Solo",
4872 { &dib0700_usb_id_table[77], NULL },
4873 { NULL },
4874 },
Davide Ferri8d009a02009-06-23 22:34:06 -03004875 },
4876 .rc.core = {
4877 .rc_interval = DEFAULT_RC_INTERVAL,
4878 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4879 .module_name = "dib0700",
4880 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004881 .allowed_protos = RC_BIT_RC5 |
4882 RC_BIT_RC6_MCE |
4883 RC_BIT_NEC,
Davide Ferri8d009a02009-06-23 22:34:06 -03004884 .change_protocol = dib0700_change_protocol,
4885 },
Olivier Grenie6724a2f2011-08-05 13:49:33 -03004886 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4887 .num_adapters = 1,
4888 .adapter = {
4889 {
4890 .num_frontends = 1,
4891 .fe = {{
4892 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
4893 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4894 .pid_filter_count = 32,
4895 .pid_filter = stk70x0p_pid_filter,
4896 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
Olivier Grenief45f5132012-12-31 09:47:10 -03004897 .frontend_attach = tfe7790p_frontend_attach,
4898 .tuner_attach = tfe7790p_tuner_attach,
Olivier Grenieb293f302011-08-09 04:48:25 -03004899
4900 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
4901 } },
4902
4903 .size_of_priv =
4904 sizeof(struct dib0700_adapter_state),
4905 },
4906 },
4907
4908 .num_device_descs = 1,
4909 .devices = {
Olivier Grenief45f5132012-12-31 09:47:10 -03004910 { "DiBcom TFE7790P reference design",
4911 { &dib0700_usb_id_table[78], NULL },
Olivier Grenieb293f302011-08-09 04:48:25 -03004912 { NULL },
4913 },
4914 },
4915
4916 .rc.core = {
4917 .rc_interval = DEFAULT_RC_INTERVAL,
4918 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4919 .module_name = "dib0700",
4920 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004921 .allowed_protos = RC_BIT_RC5 |
4922 RC_BIT_RC6_MCE |
4923 RC_BIT_NEC,
Olivier Grenieb293f302011-08-09 04:48:25 -03004924 .change_protocol = dib0700_change_protocol,
4925 },
Olivier Grenie88f3a352011-08-10 05:28:38 -03004926 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4927 .num_adapters = 1,
4928 .adapter = {
4929 {
4930 .num_frontends = 1,
4931 .fe = {{
4932 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
4933 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4934 .pid_filter_count = 32,
4935 .pid_filter = stk80xx_pid_filter,
4936 .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
4937 .frontend_attach = tfe8096p_frontend_attach,
4938 .tuner_attach = tfe8096p_tuner_attach,
4939
4940 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
4941
4942 } },
4943
4944 .size_of_priv =
4945 sizeof(struct dib0700_adapter_state),
4946 },
4947 },
4948
4949 .num_device_descs = 1,
4950 .devices = {
4951 { "DiBcom TFE8096P reference design",
Olivier Grenief45f5132012-12-31 09:47:10 -03004952 { &dib0700_usb_id_table[79], NULL },
Olivier Grenie88f3a352011-08-10 05:28:38 -03004953 { NULL },
4954 },
4955 },
4956
4957 .rc.core = {
4958 .rc_interval = DEFAULT_RC_INTERVAL,
4959 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4960 .module_name = "dib0700",
4961 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004962 .allowed_protos = RC_BIT_RC5 |
4963 RC_BIT_RC6_MCE |
4964 RC_BIT_NEC,
Olivier Grenie88f3a352011-08-10 05:28:38 -03004965 .change_protocol = dib0700_change_protocol,
4966 },
Patrick Boettcher01373a52007-07-30 12:49:04 -03004967 },
Patrick Boettcherb7f54912006-09-19 12:51:37 -03004968};
4969
4970int dib0700_device_count = ARRAY_SIZE(dib0700_devices);