blob: 85ab3fa48f9a881d40705e657dc4c292ed4d856f [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);
Mauro Carvalho Chehabf319ed92016-10-18 17:44:15 -020029MODULE_PARM_DESC(force_lna_activation, "force the activation of Low-Noise-Amplifyer(s) (LNA), if applicable for the device (default: 0=automatic/off).");
Patrick Boettcher7fb3fc02006-09-20 04:37:18 -030030
Patrick Boettcher01373a52007-07-30 12:49:04 -030031struct dib0700_adapter_state {
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -030032 int (*set_param_save) (struct dvb_frontend *);
Olivier Greniebe9bae12011-01-04 05:42:19 -030033 const struct firmware *frontend_firmware;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -030034 struct dib7000p_ops dib7000p_ops;
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -030035 struct dib8000_ops dib8000_ops;
Patrick Boettcher01373a52007-07-30 12:49:04 -030036};
37
38/* Hauppauge Nova-T 500 (aka Bristol)
Patrick Boettcherb7f54912006-09-19 12:51:37 -030039 * has a LNA on GPIO0 which is enabled by setting 1 */
40static struct mt2060_config bristol_mt2060_config[2] = {
41 {
42 .i2c_address = 0x60,
Patrick Boettcher303cbea2006-09-19 12:51:56 -030043 .clock_out = 3,
Patrick Boettcherb7f54912006-09-19 12:51:37 -030044 }, {
45 .i2c_address = 0x61,
46 }
47};
48
Devin Heitmueller99afb982008-11-15 07:13:07 -030049
Patrick Boettcherb7f54912006-09-19 12:51:37 -030050static struct dibx000_agc_config bristol_dib3000p_mt2060_agc_config = {
51 .band_caps = BAND_VHF | BAND_UHF,
Patrick Boettcher01b4bf32006-09-19 12:51:53 -030052 .setup = (1 << 8) | (5 << 5) | (0 << 4) | (0 << 3) | (0 << 2) | (2 << 0),
Patrick Boettcherb7f54912006-09-19 12:51:37 -030053
Patrick Boettcher6958eff2006-09-19 12:51:40 -030054 .agc1_max = 42598,
55 .agc1_min = 17694,
56 .agc2_max = 45875,
57 .agc2_min = 0,
Patrick Boettcherb7f54912006-09-19 12:51:37 -030058
Patrick Boettcher6958eff2006-09-19 12:51:40 -030059 .agc1_pt1 = 0,
60 .agc1_pt2 = 59,
Patrick Boettcherb7f54912006-09-19 12:51:37 -030061
Patrick Boettcher6958eff2006-09-19 12:51:40 -030062 .agc1_slope1 = 0,
63 .agc1_slope2 = 69,
Patrick Boettcherb7f54912006-09-19 12:51:37 -030064
65 .agc2_pt1 = 0,
Patrick Boettcher6958eff2006-09-19 12:51:40 -030066 .agc2_pt2 = 59,
Patrick Boettcherb7f54912006-09-19 12:51:37 -030067
Patrick Boettcher6958eff2006-09-19 12:51:40 -030068 .agc2_slope1 = 111,
69 .agc2_slope2 = 28,
Patrick Boettcherb7f54912006-09-19 12:51:37 -030070};
71
72static struct dib3000mc_config bristol_dib3000mc_config[2] = {
73 { .agc = &bristol_dib3000p_mt2060_agc_config,
74 .max_time = 0x196,
75 .ln_adc_level = 0x1cc7,
76 .output_mpeg2_in_188_bytes = 1,
77 },
78 { .agc = &bristol_dib3000p_mt2060_agc_config,
79 .max_time = 0x196,
80 .ln_adc_level = 0x1cc7,
81 .output_mpeg2_in_188_bytes = 1,
82 }
83};
84
85static int bristol_frontend_attach(struct dvb_usb_adapter *adap)
86{
Patrick Boettcher6958eff2006-09-19 12:51:40 -030087 struct dib0700_state *st = adap->dev->priv;
Patrick Boettcherb7f54912006-09-19 12:51:37 -030088 if (adap->id == 0) {
89 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0); msleep(10);
90 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1); msleep(10);
91 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0); msleep(10);
92 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1); msleep(10);
93
Patrick Boettcher7fb3fc02006-09-20 04:37:18 -030094 if (force_lna_activation)
95 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
96 else
97 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 0);
Patrick Boettcher6958eff2006-09-19 12:51:40 -030098
Patrick Boettcherb7f54912006-09-19 12:51:37 -030099 if (dib3000mc_i2c_enumeration(&adap->dev->i2c_adap, 2, DEFAULT_DIB3000P_I2C_ADDRESS, bristol_dib3000mc_config) != 0) {
100 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0); msleep(10);
101 return -ENODEV;
102 }
103 }
Patrick Boettcher6958eff2006-09-19 12:51:40 -0300104 st->mt2060_if1[adap->id] = 1220;
Michael Krufky77eed212011-09-06 09:31:57 -0300105 return (adap->fe_adap[0].fe = dvb_attach(dib3000mc_attach, &adap->dev->i2c_adap,
Patrick Boettcher6958eff2006-09-19 12:51:40 -0300106 (10 + adap->id) << 1, &bristol_dib3000mc_config[adap->id])) == NULL ? -ENODEV : 0;
Patrick Boettcherb7f54912006-09-19 12:51:37 -0300107}
108
Patrick Boettcher4a2b1082008-01-25 07:32:58 -0300109static int eeprom_read(struct i2c_adapter *adap,u8 adrs,u8 *pval)
Olivier DANETc52344f2008-01-25 06:50:07 -0300110{
111 struct i2c_msg msg[2] = {
112 { .addr = 0x50, .flags = 0, .buf = &adrs, .len = 1 },
113 { .addr = 0x50, .flags = I2C_M_RD, .buf = pval, .len = 1 },
114 };
115 if (i2c_transfer(adap, msg, 2) != 2) return -EREMOTEIO;
116 return 0;
117}
118
Patrick Boettcherb7f54912006-09-19 12:51:37 -0300119static int bristol_tuner_attach(struct dvb_usb_adapter *adap)
120{
Olivier DANETc52344f2008-01-25 06:50:07 -0300121 struct i2c_adapter *prim_i2c = &adap->dev->i2c_adap;
Michael Krufky77eed212011-09-06 09:31:57 -0300122 struct i2c_adapter *tun_i2c = dib3000mc_get_tuner_i2c_master(adap->fe_adap[0].fe, 1);
Olivier DANETc52344f2008-01-25 06:50:07 -0300123 s8 a;
124 int if1=1220;
Al Viroda5ee482008-05-21 00:31:21 -0300125 if (adap->dev->udev->descriptor.idVendor == cpu_to_le16(USB_VID_HAUPPAUGE) &&
126 adap->dev->udev->descriptor.idProduct == cpu_to_le16(USB_PID_HAUPPAUGE_NOVA_T_500_2)) {
Olivier DANETc52344f2008-01-25 06:50:07 -0300127 if (!eeprom_read(prim_i2c,0x59 + adap->id,&a)) if1=1220+a;
128 }
Michael Krufky9a9677a2011-09-13 01:32:11 -0300129 return dvb_attach(mt2060_attach, adap->fe_adap[0].fe, tun_i2c,
130 &bristol_mt2060_config[adap->id], if1) == NULL ?
131 -ENODEV : 0;
Patrick Boettcherb7f54912006-09-19 12:51:37 -0300132}
133
Patrick Boettcher01373a52007-07-30 12:49:04 -0300134/* STK7700D: Pinnacle/Terratec/Hauppauge Dual DVB-T Diversity */
Olivier DANET54d75eb2007-07-25 14:42:54 -0300135
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300136/* MT226x */
137static struct dibx000_agc_config stk7700d_7000p_mt2266_agc_config[2] = {
138 {
Olivier Grenie9c783032009-12-07 07:49:40 -0300139 BAND_UHF,
Olivier DANET54d75eb2007-07-25 14:42:54 -0300140
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300141 /* 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,
142 * 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 -0300143 (0 << 15) | (0 << 14) | (1 << 11) | (1 << 10) | (1 << 9) | (0 << 8)
144 | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),
Olivier DANET54d75eb2007-07-25 14:42:54 -0300145
Olivier Grenie9c783032009-12-07 07:49:40 -0300146 1130,
147 21,
Olivier DANET54d75eb2007-07-25 14:42:54 -0300148
Olivier Grenie9c783032009-12-07 07:49:40 -0300149 0,
150 118,
Olivier DANET54d75eb2007-07-25 14:42:54 -0300151
Olivier Grenie9c783032009-12-07 07:49:40 -0300152 0,
153 3530,
154 1,
155 0,
Olivier DANET54d75eb2007-07-25 14:42:54 -0300156
Olivier Grenie9c783032009-12-07 07:49:40 -0300157 65535,
158 33770,
159 65535,
160 23592,
Olivier DANET54d75eb2007-07-25 14:42:54 -0300161
Olivier Grenie9c783032009-12-07 07:49:40 -0300162 0,
163 62,
164 255,
165 64,
166 64,
167 132,
168 192,
169 80,
170 80,
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300171
Olivier Grenie9c783032009-12-07 07:49:40 -0300172 17,
173 27,
174 23,
175 51,
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300176
Olivier Grenie9c783032009-12-07 07:49:40 -0300177 1,
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300178 }, {
Olivier Grenie9c783032009-12-07 07:49:40 -0300179 BAND_VHF | BAND_LBAND,
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300180
181 /* 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,
182 * 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 -0300183 (0 << 15) | (0 << 14) | (1 << 11) | (1 << 10) | (1 << 9) | (0 << 8)
184 | (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0),
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300185
Olivier Grenie9c783032009-12-07 07:49:40 -0300186 2372,
187 21,
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300188
Olivier Grenie9c783032009-12-07 07:49:40 -0300189 0,
190 118,
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300191
Olivier Grenie9c783032009-12-07 07:49:40 -0300192 0,
193 3530,
194 1,
195 0,
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300196
Olivier Grenie9c783032009-12-07 07:49:40 -0300197 65535,
198 0,
199 65535,
200 23592,
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300201
Olivier Grenie9c783032009-12-07 07:49:40 -0300202 0,
203 128,
204 128,
205 128,
206 0,
207 128,
208 253,
209 81,
210 0,
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300211
Olivier Grenie9c783032009-12-07 07:49:40 -0300212 17,
213 27,
214 23,
215 51,
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300216
Olivier Grenie9c783032009-12-07 07:49:40 -0300217 1,
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300218 }
Olivier DANET54d75eb2007-07-25 14:42:54 -0300219};
220
221static struct dibx000_bandwidth_config stk7700d_mt2266_pll_config = {
Mauro Carvalho Chehab09628b22014-09-22 18:57:45 -0300222 .internal = 60000,
223 .sampling = 30000,
224 .pll_prediv = 1,
225 .pll_ratio = 8,
226 .pll_range = 3,
227 .pll_reset = 1,
228 .pll_bypass = 0,
229 .enable_refdiv = 0,
230 .bypclk_div = 0,
231 .IO_CLK_en_core = 1,
232 .ADClkSrc = 1,
233 .modulo = 2,
234 .sad_cfg = (3 << 14) | (1 << 12) | (524 << 0),
235 .ifreq = 0,
236 .timf = 20452225,
Olivier DANET54d75eb2007-07-25 14:42:54 -0300237};
238
239static struct dib7000p_config stk7700d_dib7000p_mt2266_config[] = {
240 { .output_mpeg2_in_188_bytes = 1,
241 .hostbus_diversity = 1,
242 .tuner_is_baseband = 1,
243
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300244 .agc_config_count = 2,
245 .agc = stk7700d_7000p_mt2266_agc_config,
Olivier DANET54d75eb2007-07-25 14:42:54 -0300246 .bw = &stk7700d_mt2266_pll_config,
247
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300248 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
249 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
250 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
Olivier DANET54d75eb2007-07-25 14:42:54 -0300251 },
252 { .output_mpeg2_in_188_bytes = 1,
253 .hostbus_diversity = 1,
254 .tuner_is_baseband = 1,
255
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300256 .agc_config_count = 2,
257 .agc = stk7700d_7000p_mt2266_agc_config,
Olivier DANET54d75eb2007-07-25 14:42:54 -0300258 .bw = &stk7700d_mt2266_pll_config,
259
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300260 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
261 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
262 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
Olivier DANET54d75eb2007-07-25 14:42:54 -0300263 }
264};
265
266static struct mt2266_config stk7700d_mt2266_config[2] = {
267 { .i2c_address = 0x60
268 },
269 { .i2c_address = 0x60
270 }
271};
272
Daniel Gimpelevich132c3182008-01-25 06:02:42 -0300273static int stk7700P2_frontend_attach(struct dvb_usb_adapter *adap)
274{
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300275 struct dib0700_adapter_state *state = adap->priv;
276
277 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
278 return -ENODEV;
279
Daniel Gimpelevich132c3182008-01-25 06:02:42 -0300280 if (adap->id == 0) {
281 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
282 msleep(10);
283 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
284 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
285 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
286 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
287 msleep(10);
288 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
289 msleep(10);
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300290 if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 18,
Devin Heitmueller83c4fdf2009-01-21 01:55:45 -0300291 stk7700d_dib7000p_mt2266_config)
292 != 0) {
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300293 err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n", __func__);
294 dvb_detach(&state->dib7000p_ops);
Devin Heitmueller83c4fdf2009-01-21 01:55:45 -0300295 return -ENODEV;
296 }
Daniel Gimpelevich132c3182008-01-25 06:02:42 -0300297 }
298
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300299 adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap,
Michael Krufky2a776312011-09-16 09:26:59 -0300300 0x80 + (adap->id << 1),
301 &stk7700d_dib7000p_mt2266_config[adap->id]);
Daniel Gimpelevich132c3182008-01-25 06:02:42 -0300302
Michael Krufky77eed212011-09-06 09:31:57 -0300303 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Daniel Gimpelevich132c3182008-01-25 06:02:42 -0300304}
305
Olivier DANET54d75eb2007-07-25 14:42:54 -0300306static int stk7700d_frontend_attach(struct dvb_usb_adapter *adap)
307{
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300308 struct dib0700_adapter_state *state = adap->priv;
309
310 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
311 return -ENODEV;
312
Olivier DANET54d75eb2007-07-25 14:42:54 -0300313 if (adap->id == 0) {
314 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
315 msleep(10);
316 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
317 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
318 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
319 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
320 msleep(10);
321 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
322 msleep(10);
323 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300324 if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap, 2, 18,
Devin Heitmueller83c4fdf2009-01-21 01:55:45 -0300325 stk7700d_dib7000p_mt2266_config)
326 != 0) {
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300327 err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n", __func__);
328 dvb_detach(&state->dib7000p_ops);
Devin Heitmueller83c4fdf2009-01-21 01:55:45 -0300329 return -ENODEV;
330 }
Olivier DANET54d75eb2007-07-25 14:42:54 -0300331 }
332
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300333 adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap,
Michael Krufky2a776312011-09-16 09:26:59 -0300334 0x80 + (adap->id << 1),
335 &stk7700d_dib7000p_mt2266_config[adap->id]);
Olivier DANET54d75eb2007-07-25 14:42:54 -0300336
Michael Krufky77eed212011-09-06 09:31:57 -0300337 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Olivier DANET54d75eb2007-07-25 14:42:54 -0300338}
339
340static int stk7700d_tuner_attach(struct dvb_usb_adapter *adap)
341{
342 struct i2c_adapter *tun_i2c;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300343 struct dib0700_adapter_state *state = adap->priv;
344
345 tun_i2c = state->dib7000p_ops.get_i2c_master(adap->fe_adap[0].fe,
346 DIBX000_I2C_INTERFACE_TUNER, 1);
Michael Krufky77eed212011-09-06 09:31:57 -0300347 return dvb_attach(mt2266_attach, adap->fe_adap[0].fe, tun_i2c,
Joe Perches1ebcad72009-07-02 15:57:09 -0300348 &stk7700d_mt2266_config[adap->id]) == NULL ? -ENODEV : 0;
Olivier DANET54d75eb2007-07-25 14:42:54 -0300349}
350
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300351/* STK7700-PH: Digital/Analog Hybrid Tuner, e.h. Cinergy HT USB HE */
Harvey Harrisonb1721d02008-04-25 19:03:08 -0700352static struct dibx000_agc_config xc3028_agc_config = {
Mauro Carvalho Chehab09628b22014-09-22 18:57:45 -0300353 .band_caps = BAND_VHF | BAND_UHF,
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300354 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=0,
355 * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
356 * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=2, P_agc_write=0 */
Mauro Carvalho Chehab09628b22014-09-22 18:57:45 -0300357 .setup = (0 << 15) | (0 << 14) | (0 << 11) | (0 << 10) | (0 << 9) | (0 << 8) | (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0),
358 .inv_gain = 712,
359 .time_stabiliz = 21,
360 .alpha_level = 0,
361 .thlock = 118,
362 .wbd_inv = 0,
363 .wbd_ref = 2867,
364 .wbd_sel = 0,
365 .wbd_alpha = 2,
366 .agc1_max = 0,
367 .agc1_min = 0,
368 .agc2_max = 39718,
369 .agc2_min = 9930,
370 .agc1_pt1 = 0,
371 .agc1_pt2 = 0,
372 .agc1_pt3 = 0,
373 .agc1_slope1 = 0,
374 .agc1_slope2 = 0,
375 .agc2_pt1 = 0,
376 .agc2_pt2 = 128,
377 .agc2_slope1 = 29,
378 .agc2_slope2 = 29,
379 .alpha_mant = 17,
380 .alpha_exp = 27,
381 .beta_mant = 23,
382 .beta_exp = 51,
383 .perform_agc_softsplit = 1,
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300384};
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 = {
Mauro Carvalho Chehab09628b22014-09-22 18:57:45 -0300388 .internal = 60000,
389 .sampling = 30000,
390 .pll_prediv = 1,
391 .pll_ratio = 8,
392 .pll_range = 3,
393 .pll_reset = 1,
394 .pll_bypass = 0,
395 .enable_refdiv = 0,
396 .bypclk_div = 0,
397 .IO_CLK_en_core = 1,
398 .ADClkSrc = 1,
399 .modulo = 0,
400 .sad_cfg = (3 << 14) | (1 << 12) | (524 << 0), /* sad_cfg: refsel, sel, freq_15k */
401 .ifreq = (1 << 25) | 5816102, /* ifreq = 5.200000 MHz */
402 .timf = 20452225,
403 .xtal_hz = 30000000,
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300404};
405
406static struct dib7000p_config stk7700ph_dib7700_xc3028_config = {
407 .output_mpeg2_in_188_bytes = 1,
408 .tuner_is_baseband = 1,
409
410 .agc_config_count = 1,
411 .agc = &xc3028_agc_config,
412 .bw = &xc3028_bw_config,
413
414 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
415 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
416 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
417};
418
Michael Krufkyd7cba042008-09-12 13:31:45 -0300419static int stk7700ph_xc3028_callback(void *ptr, int component,
420 int command, int arg)
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300421{
422 struct dvb_usb_adapter *adap = ptr;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300423 struct dib0700_adapter_state *state = adap->priv;
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300424
425 switch (command) {
426 case XC2028_TUNER_RESET:
427 /* Send the tuner in then out of reset */
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300428 state->dib7000p_ops.set_gpio(adap->fe_adap[0].fe, 8, 0, 0);
429 msleep(10);
430 state->dib7000p_ops.set_gpio(adap->fe_adap[0].fe, 8, 0, 1);
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300431 break;
432 case XC2028_RESET_CLK:
433 break;
434 default:
435 err("%s: unknown command %d, arg %d\n", __func__,
436 command, arg);
437 return -EINVAL;
438 }
439 return 0;
440}
441
442static struct xc2028_ctrl stk7700ph_xc3028_ctrl = {
443 .fname = XC2028_DEFAULT_FIRMWARE,
444 .max_len = 64,
445 .demod = XC3028_FE_DIBCOM52,
446};
447
448static struct xc2028_config stk7700ph_xc3028_config = {
449 .i2c_addr = 0x61,
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300450 .ctrl = &stk7700ph_xc3028_ctrl,
451};
452
453static int stk7700ph_frontend_attach(struct dvb_usb_adapter *adap)
454{
455 struct usb_device_descriptor *desc = &adap->dev->udev->descriptor;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300456 struct dib0700_adapter_state *state = adap->priv;
457
458 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
459 return -ENODEV;
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300460
Al Viroda5ee482008-05-21 00:31:21 -0300461 if (desc->idVendor == cpu_to_le16(USB_VID_PINNACLE) &&
462 desc->idProduct == cpu_to_le16(USB_PID_PINNACLE_EXPRESSCARD_320CX))
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300463 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300464 else
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300465 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300466 msleep(20);
467 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
468 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
469 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
470 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
471 msleep(10);
472 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
473 msleep(20);
474 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
475 msleep(10);
476
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300477 if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 18,
Devin Heitmueller83c4fdf2009-01-21 01:55:45 -0300478 &stk7700ph_dib7700_xc3028_config) != 0) {
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300479 err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n",
Devin Heitmueller83c4fdf2009-01-21 01:55:45 -0300480 __func__);
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300481 dvb_detach(&state->dib7000p_ops);
Devin Heitmueller83c4fdf2009-01-21 01:55:45 -0300482 return -ENODEV;
483 }
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300484
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300485 adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap, 0x80,
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300486 &stk7700ph_dib7700_xc3028_config);
487
Michael Krufky77eed212011-09-06 09:31:57 -0300488 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300489}
490
491static int stk7700ph_tuner_attach(struct dvb_usb_adapter *adap)
492{
493 struct i2c_adapter *tun_i2c;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300494 struct dib0700_adapter_state *state = adap->priv;
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300495
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300496 tun_i2c = state->dib7000p_ops.get_i2c_master(adap->fe_adap[0].fe,
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300497 DIBX000_I2C_INTERFACE_TUNER, 1);
498
499 stk7700ph_xc3028_config.i2c_adap = tun_i2c;
Michael Krufkyd7cba042008-09-12 13:31:45 -0300500
501 /* FIXME: generalize & move to common area */
Michael Krufky77eed212011-09-06 09:31:57 -0300502 adap->fe_adap[0].fe->callback = stk7700ph_xc3028_callback;
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300503
Michael Krufky77eed212011-09-06 09:31:57 -0300504 return dvb_attach(xc2028_attach, adap->fe_adap[0].fe, &stk7700ph_xc3028_config)
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300505 == NULL ? -ENODEV : 0;
506}
507
Devin Heitmueller4b330be2008-12-01 06:51:14 -0300508#define DEFAULT_RC_INTERVAL 50
Olivier DANET54d75eb2007-07-25 14:42:54 -0300509
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -0300510/*
511 * This function is used only when firmware is < 1.20 version. Newer
512 * firmwares use bulk mode, with functions implemented at dib0700_core,
513 * at dib0700_rc_urb_completion()
514 */
515static int dib0700_rc_query_old_firmware(struct dvb_usb_device *d)
Olivier DANET54d75eb2007-07-25 14:42:54 -0300516{
David Härdeman120703f2014-04-03 20:31:30 -0300517 enum rc_type protocol;
518 u32 scancode;
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -0300519 u8 toggle;
Olivier DANET54d75eb2007-07-25 14:42:54 -0300520 int i;
Olivier DANET54d75eb2007-07-25 14:42:54 -0300521 struct dib0700_state *st = d->priv;
Devin Heitmueller6a207102010-01-04 02:43:19 -0300522
Devin Heitmueller6a207102010-01-04 02:43:19 -0300523 if (st->fw_version >= 0x10200) {
524 /* For 1.20 firmware , We need to keep the RC polling
525 callback so we can reuse the input device setup in
526 dvb-usb-remote.c. However, the actual work is being done
527 in the bulk URB completion handler. */
528 return 0;
529 }
530
Mauro Carvalho Chehabbd1f9762016-10-07 06:40:24 -0300531 st->buf[0] = REQUEST_POLL_RC;
532 st->buf[1] = 0;
533
534 i = dib0700_ctrl_rd(d, st->buf, 2, st->buf, 4);
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -0300535 if (i <= 0) {
Janne Grunau034d65e2007-07-31 08:48:40 -0300536 err("RC Query Failed");
Mauro Carvalho Chehabbd1f9762016-10-07 06:40:24 -0300537 return -EIO;
Olivier DANET54d75eb2007-07-25 14:42:54 -0300538 }
Patrick Boettcher58e6f952008-03-29 21:37:01 -0300539
540 /* losing half of KEY_0 events from Philipps rc5 remotes.. */
Mauro Carvalho Chehabbd1f9762016-10-07 06:40:24 -0300541 if (st->buf[0] == 0 && st->buf[1] == 0
542 && st->buf[2] == 0 && st->buf[3] == 0)
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -0300543 return 0;
Patrick Boettcher58e6f952008-03-29 21:37:01 -0300544
Mauro Carvalho Chehabbd1f9762016-10-07 06:40:24 -0300545 /* info("%d: %2X %2X %2X %2X",dvb_usb_dib0700_ir_proto,(int)st->buf[3 - 2],(int)st->buf[3 - 3],(int)st->buf[3 - 1],(int)st->buf[3]); */
Patrick Boettcher58e6f952008-03-29 21:37:01 -0300546
Mauro Carvalho Chehabc4018fa2014-05-21 17:40:25 -0300547 dib0700_rc_setup(d, NULL); /* reset ir sensor data to prevent false events */
Patrick Boettcher58e6f952008-03-29 21:37:01 -0300548
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -0300549 switch (d->props.rc.core.protocol) {
David Härdemanc003ab12012-10-11 19:11:54 -0300550 case RC_BIT_NEC:
Patrick Boettcher58e6f952008-03-29 21:37:01 -0300551 /* NEC protocol sends repeat code as 0 0 0 FF */
Mauro Carvalho Chehabbd1f9762016-10-07 06:40:24 -0300552 if ((st->buf[3 - 2] == 0x00) && (st->buf[3 - 3] == 0x00) &&
553 (st->buf[3] == 0xff)) {
David Härdeman120703f2014-04-03 20:31:30 -0300554 rc_repeat(d->rc_dev);
555 return 0;
Patrick Boettcher58e6f952008-03-29 21:37:01 -0300556 }
Patrick Boettcher58e6f952008-03-29 21:37:01 -0300557
David Härdeman120703f2014-04-03 20:31:30 -0300558 protocol = RC_TYPE_NEC;
Mauro Carvalho Chehabbd1f9762016-10-07 06:40:24 -0300559 scancode = RC_SCANCODE_NEC(st->buf[3 - 2], st->buf[3 - 3]);
David Härdeman120703f2014-04-03 20:31:30 -0300560 toggle = 0;
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -0300561 break;
David Härdeman120703f2014-04-03 20:31:30 -0300562
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -0300563 default:
564 /* RC-5 protocol changes toggle bit on new keypress */
David Härdeman120703f2014-04-03 20:31:30 -0300565 protocol = RC_TYPE_RC5;
Mauro Carvalho Chehabbd1f9762016-10-07 06:40:24 -0300566 scancode = RC_SCANCODE_RC5(st->buf[3 - 2], st->buf[3 - 3]);
567 toggle = st->buf[3 - 1];
Patrick Boettcher58e6f952008-03-29 21:37:01 -0300568 break;
569 }
David Härdeman120703f2014-04-03 20:31:30 -0300570
571 rc_keydown(d->rc_dev, protocol, scancode, toggle);
Olivier DANET54d75eb2007-07-25 14:42:54 -0300572 return 0;
573}
574
Patrick Boettcherb7f54912006-09-19 12:51:37 -0300575/* STK7700P: Hauppauge Nova-T Stick, AVerMedia Volar */
Patrick Boettchera75763f2006-10-18 08:34:16 -0300576static struct dibx000_agc_config stk7700p_7000m_mt2060_agc_config = {
Olivier Grenie9c783032009-12-07 07:49:40 -0300577 BAND_UHF | BAND_VHF,
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300578
579 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=5, P_agc_inv_pwm1=0, P_agc_inv_pwm2=0,
580 * P_agc_inh_dc_rv_est=0, P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=2, P_agc_write=0 */
Olivier Grenie9c783032009-12-07 07:49:40 -0300581 (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8)
582 | (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0),
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300583
Olivier Grenie9c783032009-12-07 07:49:40 -0300584 712,
585 41,
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300586
Olivier Grenie9c783032009-12-07 07:49:40 -0300587 0,
588 118,
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300589
Olivier Grenie9c783032009-12-07 07:49:40 -0300590 0,
591 4095,
592 0,
593 0,
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300594
Olivier Grenie9c783032009-12-07 07:49:40 -0300595 42598,
596 17694,
597 45875,
598 2621,
599 0,
600 76,
601 139,
602 52,
603 59,
604 107,
605 172,
606 57,
607 70,
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300608
Olivier Grenie9c783032009-12-07 07:49:40 -0300609 21,
610 25,
611 28,
612 48,
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300613
Olivier Grenie9c783032009-12-07 07:49:40 -0300614 1,
615 { 0,
616 107,
617 51800,
618 24700
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300619 },
Patrick Boettcherb7f54912006-09-19 12:51:37 -0300620};
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300621
Patrick Boettchera75763f2006-10-18 08:34:16 -0300622static struct dibx000_agc_config stk7700p_7000p_mt2060_agc_config = {
Mauro Carvalho Chehab09628b22014-09-22 18:57:45 -0300623 .band_caps = BAND_UHF | BAND_VHF,
Patrick Boettchera75763f2006-10-18 08:34:16 -0300624 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=5, P_agc_inv_pwm1=0, P_agc_inv_pwm2=0,
625 * P_agc_inh_dc_rv_est=0, P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=2, P_agc_write=0 */
Mauro Carvalho Chehab09628b22014-09-22 18:57:45 -0300626 .setup = (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8) | (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0),
627 .inv_gain = 712,
628 .time_stabiliz = 41,
629 .alpha_level = 0,
630 .thlock = 118,
631 .wbd_inv = 0,
632 .wbd_ref = 4095,
633 .wbd_sel = 0,
634 .wbd_alpha = 0,
635 .agc1_max = 42598,
636 .agc1_min = 16384,
637 .agc2_max = 42598,
638 .agc2_min = 0,
639 .agc1_pt1 = 0,
640 .agc1_pt2 = 137,
641 .agc1_pt3 = 255,
642 .agc1_slope1 = 0,
643 .agc1_slope2 = 255,
644 .agc2_pt1 = 0,
645 .agc2_pt2 = 0,
646 .agc2_slope1 = 0,
647 .agc2_slope2 = 41,
648 .alpha_mant = 15,
649 .alpha_exp = 25,
650 .beta_mant = 28,
651 .beta_exp = 48,
652 .perform_agc_softsplit = 0,
Patrick Boettchera75763f2006-10-18 08:34:16 -0300653};
654
655static struct dibx000_bandwidth_config stk7700p_pll_config = {
Mauro Carvalho Chehab09628b22014-09-22 18:57:45 -0300656 .internal = 60000,
657 .sampling = 30000,
658 .pll_prediv = 1,
659 .pll_ratio = 8,
660 .pll_range = 3,
661 .pll_reset = 1,
662 .pll_bypass = 0,
663 .enable_refdiv = 0,
664 .bypclk_div = 0,
665 .IO_CLK_en_core = 1,
666 .ADClkSrc = 1,
667 .modulo = 0,
668 .sad_cfg = (3 << 14) | (1 << 12) | (524 << 0),
669 .ifreq = 60258167,
670 .timf = 20452225,
671 .xtal_hz = 30000000,
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300672};
673
674static struct dib7000m_config stk7700p_dib7000m_config = {
675 .dvbt_mode = 1,
676 .output_mpeg2_in_188_bytes = 1,
677 .quartz_direct = 1,
678
679 .agc_config_count = 1,
Patrick Boettchera75763f2006-10-18 08:34:16 -0300680 .agc = &stk7700p_7000m_mt2060_agc_config,
681 .bw = &stk7700p_pll_config,
682
683 .gpio_dir = DIB7000M_GPIO_DEFAULT_DIRECTIONS,
684 .gpio_val = DIB7000M_GPIO_DEFAULT_VALUES,
685 .gpio_pwm_pos = DIB7000M_GPIO_DEFAULT_PWM_POS,
686};
687
688static struct dib7000p_config stk7700p_dib7000p_config = {
689 .output_mpeg2_in_188_bytes = 1,
690
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300691 .agc_config_count = 1,
Patrick Boettchera75763f2006-10-18 08:34:16 -0300692 .agc = &stk7700p_7000p_mt2060_agc_config,
693 .bw = &stk7700p_pll_config,
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300694
695 .gpio_dir = DIB7000M_GPIO_DEFAULT_DIRECTIONS,
696 .gpio_val = DIB7000M_GPIO_DEFAULT_VALUES,
697 .gpio_pwm_pos = DIB7000M_GPIO_DEFAULT_PWM_POS,
698};
Patrick Boettcherb7f54912006-09-19 12:51:37 -0300699
700static int stk7700p_frontend_attach(struct dvb_usb_adapter *adap)
701{
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300702 struct dib0700_state *st = adap->dev->priv;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300703 struct dib0700_adapter_state *state = adap->priv;
704
705 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
706 return -ENODEV;
707
Patrick Boettcherb7f54912006-09-19 12:51:37 -0300708 /* unless there is no real power management in DVB - we leave the device on GPIO6 */
Patrick Boettchera75763f2006-10-18 08:34:16 -0300709
710 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
711 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0); msleep(50);
712
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300713 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1); msleep(10);
Patrick Boettchera75763f2006-10-18 08:34:16 -0300714 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
715
Patrick Boettcherb7f54912006-09-19 12:51:37 -0300716 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0); msleep(10);
Patrick Boettchera75763f2006-10-18 08:34:16 -0300717 dib0700_ctrl_clock(adap->dev, 72, 1);
718 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1); msleep(100);
719
720 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
Patrick Boettcherb7f54912006-09-19 12:51:37 -0300721
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300722 st->mt2060_if1[0] = 1220;
Patrick Boettchera75763f2006-10-18 08:34:16 -0300723
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300724 if (state->dib7000p_ops.dib7000pc_detection(&adap->dev->i2c_adap)) {
725 adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap, 18, &stk7700p_dib7000p_config);
Patrick Boettchera75763f2006-10-18 08:34:16 -0300726 st->is_dib7000pc = 1;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300727 } else {
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300728 memset(&state->dib7000p_ops, 0, sizeof(state->dib7000p_ops));
Michael Krufky77eed212011-09-06 09:31:57 -0300729 adap->fe_adap[0].fe = dvb_attach(dib7000m_attach, &adap->dev->i2c_adap, 18, &stk7700p_dib7000m_config);
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300730 }
Patrick Boettchera75763f2006-10-18 08:34:16 -0300731
Michael Krufky77eed212011-09-06 09:31:57 -0300732 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Patrick Boettcherb7f54912006-09-19 12:51:37 -0300733}
734
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300735static struct mt2060_config stk7700p_mt2060_config = {
736 0x60
737};
738
Patrick Boettcherb7f54912006-09-19 12:51:37 -0300739static int stk7700p_tuner_attach(struct dvb_usb_adapter *adap)
740{
Olivier DANETc52344f2008-01-25 06:50:07 -0300741 struct i2c_adapter *prim_i2c = &adap->dev->i2c_adap;
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300742 struct dib0700_state *st = adap->dev->priv;
Patrick Boettchera75763f2006-10-18 08:34:16 -0300743 struct i2c_adapter *tun_i2c;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300744 struct dib0700_adapter_state *state = adap->priv;
Olivier DANETc52344f2008-01-25 06:50:07 -0300745 s8 a;
746 int if1=1220;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300747
Al Viroda5ee482008-05-21 00:31:21 -0300748 if (adap->dev->udev->descriptor.idVendor == cpu_to_le16(USB_VID_HAUPPAUGE) &&
749 adap->dev->udev->descriptor.idProduct == cpu_to_le16(USB_PID_HAUPPAUGE_NOVA_T_STICK)) {
Olivier DANETc52344f2008-01-25 06:50:07 -0300750 if (!eeprom_read(prim_i2c,0x58,&a)) if1=1220+a;
751 }
Patrick Boettchera75763f2006-10-18 08:34:16 -0300752 if (st->is_dib7000pc)
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300753 tun_i2c = state->dib7000p_ops.get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_TUNER, 1);
Patrick Boettchera75763f2006-10-18 08:34:16 -0300754 else
Michael Krufky77eed212011-09-06 09:31:57 -0300755 tun_i2c = dib7000m_get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_TUNER, 1);
Patrick Boettchera75763f2006-10-18 08:34:16 -0300756
Michael Krufky77eed212011-09-06 09:31:57 -0300757 return dvb_attach(mt2060_attach, adap->fe_adap[0].fe, tun_i2c, &stk7700p_mt2060_config,
Olivier DANETc52344f2008-01-25 06:50:07 -0300758 if1) == NULL ? -ENODEV : 0;
Patrick Boettcherb7f54912006-09-19 12:51:37 -0300759}
760
Patrick Boettcher01373a52007-07-30 12:49:04 -0300761/* DIB7070 generic */
762static struct dibx000_agc_config dib7070_agc_config = {
Mauro Carvalho Chehab09628b22014-09-22 18:57:45 -0300763 .band_caps = BAND_UHF | BAND_VHF | BAND_LBAND | BAND_SBAND,
Patrick Boettcher01373a52007-07-30 12:49:04 -0300764 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=5, P_agc_inv_pwm1=0, P_agc_inv_pwm2=0,
765 * P_agc_inh_dc_rv_est=0, P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5, P_agc_write=0 */
Mauro Carvalho Chehab09628b22014-09-22 18:57:45 -0300766 .setup = (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),
767 .inv_gain = 600,
768 .time_stabiliz = 10,
769 .alpha_level = 0,
770 .thlock = 118,
771 .wbd_inv = 0,
772 .wbd_ref = 3530,
773 .wbd_sel = 1,
774 .wbd_alpha = 5,
775 .agc1_max = 65535,
776 .agc1_min = 0,
777 .agc2_max = 65535,
778 .agc2_min = 0,
779 .agc1_pt1 = 0,
780 .agc1_pt2 = 40,
781 .agc1_pt3 = 183,
782 .agc1_slope1 = 206,
783 .agc1_slope2 = 255,
784 .agc2_pt1 = 72,
785 .agc2_pt2 = 152,
786 .agc2_slope1 = 88,
787 .agc2_slope2 = 90,
788 .alpha_mant = 17,
789 .alpha_exp = 27,
790 .beta_mant = 23,
791 .beta_exp = 51,
792 .perform_agc_softsplit = 0,
Patrick Boettcher01373a52007-07-30 12:49:04 -0300793};
794
795static int dib7070_tuner_reset(struct dvb_frontend *fe, int onoff)
796{
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300797 struct dvb_usb_adapter *adap = fe->dvb->priv;
798 struct dib0700_adapter_state *state = adap->priv;
799
Patrick Boettcher7e5ce652009-08-03 13:43:40 -0300800 deb_info("reset: %d", onoff);
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300801 return state->dib7000p_ops.set_gpio(fe, 8, 0, !onoff);
Patrick Boettcher01373a52007-07-30 12:49:04 -0300802}
803
804static int dib7070_tuner_sleep(struct dvb_frontend *fe, int onoff)
805{
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300806 struct dvb_usb_adapter *adap = fe->dvb->priv;
807 struct dib0700_adapter_state *state = adap->priv;
808
Patrick Boettcher7e5ce652009-08-03 13:43:40 -0300809 deb_info("sleep: %d", onoff);
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300810 return state->dib7000p_ops.set_gpio(fe, 9, 0, onoff);
Patrick Boettcher01373a52007-07-30 12:49:04 -0300811}
812
813static struct dib0070_config dib7070p_dib0070_config[2] = {
814 {
815 .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
816 .reset = dib7070_tuner_reset,
817 .sleep = dib7070_tuner_sleep,
818 .clock_khz = 12000,
Patrick Boettcher7e5ce652009-08-03 13:43:40 -0300819 .clock_pad_drive = 4,
820 .charge_pump = 2,
Patrick Boettcher01373a52007-07-30 12:49:04 -0300821 }, {
822 .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
823 .reset = dib7070_tuner_reset,
824 .sleep = dib7070_tuner_sleep,
825 .clock_khz = 12000,
Patrick Boettcher7e5ce652009-08-03 13:43:40 -0300826 .charge_pump = 2,
Patrick Boettcher01373a52007-07-30 12:49:04 -0300827 }
828};
829
Olivier Grenied300bd62009-09-15 06:55:35 -0300830static struct dib0070_config dib7770p_dib0070_config = {
831 .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
832 .reset = dib7070_tuner_reset,
833 .sleep = dib7070_tuner_sleep,
834 .clock_khz = 12000,
835 .clock_pad_drive = 0,
836 .flip_chip = 1,
Olivier Grenieeac1fe12009-09-23 13:41:27 -0300837 .charge_pump = 2,
Olivier Grenied300bd62009-09-15 06:55:35 -0300838};
839
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -0300840static int dib7070_set_param_override(struct dvb_frontend *fe)
Patrick Boettcher01373a52007-07-30 12:49:04 -0300841{
Mauro Carvalho Chehab47b163a2011-12-24 10:18:24 -0300842 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
Patrick Boettcher01373a52007-07-30 12:49:04 -0300843 struct dvb_usb_adapter *adap = fe->dvb->priv;
844 struct dib0700_adapter_state *state = adap->priv;
845
846 u16 offset;
Mauro Carvalho Chehab47b163a2011-12-24 10:18:24 -0300847 u8 band = BAND_OF_FREQUENCY(p->frequency/1000);
Patrick Boettcher01373a52007-07-30 12:49:04 -0300848 switch (band) {
849 case BAND_VHF: offset = 950; break;
850 case BAND_UHF:
851 default: offset = 550; break;
852 }
853 deb_info("WBD for DiB7000P: %d\n", offset + dib0070_wbd_offset(fe));
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300854 state->dib7000p_ops.set_wbd_ref(fe, offset + dib0070_wbd_offset(fe));
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -0300855 return state->set_param_save(fe);
Patrick Boettcher01373a52007-07-30 12:49:04 -0300856}
857
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -0300858static int dib7770_set_param_override(struct dvb_frontend *fe)
Olivier Grenied300bd62009-09-15 06:55:35 -0300859{
Mauro Carvalho Chehab47b163a2011-12-24 10:18:24 -0300860 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
861 struct dvb_usb_adapter *adap = fe->dvb->priv;
862 struct dib0700_adapter_state *state = adap->priv;
Olivier Grenied300bd62009-09-15 06:55:35 -0300863
Mauro Carvalho Chehab316c46b2015-04-29 17:16:27 -0300864 u16 offset;
865 u8 band = BAND_OF_FREQUENCY(p->frequency/1000);
866 switch (band) {
867 case BAND_VHF:
868 state->dib7000p_ops.set_gpio(fe, 0, 0, 1);
869 offset = 850;
870 break;
871 case BAND_UHF:
872 default:
873 state->dib7000p_ops.set_gpio(fe, 0, 0, 0);
874 offset = 250;
875 break;
876 }
877 deb_info("WBD for DiB7000P: %d\n", offset + dib0070_wbd_offset(fe));
878 state->dib7000p_ops.set_wbd_ref(fe, offset + dib0070_wbd_offset(fe));
879 return state->set_param_save(fe);
Olivier Grenied300bd62009-09-15 06:55:35 -0300880}
881
882static int dib7770p_tuner_attach(struct dvb_usb_adapter *adap)
883{
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300884 struct dib0700_adapter_state *st = adap->priv;
885 struct i2c_adapter *tun_i2c = st->dib7000p_ops.get_i2c_master(adap->fe_adap[0].fe,
Olivier Grenied300bd62009-09-15 06:55:35 -0300886 DIBX000_I2C_INTERFACE_TUNER, 1);
887
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300888 if (dvb_attach(dib0070_attach, adap->fe_adap[0].fe, tun_i2c,
889 &dib7770p_dib0070_config) == NULL)
890 return -ENODEV;
Olivier Grenied300bd62009-09-15 06:55:35 -0300891
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300892 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
893 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib7770_set_param_override;
894 return 0;
Olivier Grenied300bd62009-09-15 06:55:35 -0300895}
896
Patrick Boettcher01373a52007-07-30 12:49:04 -0300897static int dib7070p_tuner_attach(struct dvb_usb_adapter *adap)
898{
899 struct dib0700_adapter_state *st = adap->priv;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300900 struct i2c_adapter *tun_i2c = st->dib7000p_ops.get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_TUNER, 1);
Patrick Boettcher01373a52007-07-30 12:49:04 -0300901
902 if (adap->id == 0) {
Michael Krufky77eed212011-09-06 09:31:57 -0300903 if (dvb_attach(dib0070_attach, adap->fe_adap[0].fe, tun_i2c, &dib7070p_dib0070_config[0]) == NULL)
Patrick Boettcher01373a52007-07-30 12:49:04 -0300904 return -ENODEV;
905 } else {
Michael Krufky77eed212011-09-06 09:31:57 -0300906 if (dvb_attach(dib0070_attach, adap->fe_adap[0].fe, tun_i2c, &dib7070p_dib0070_config[1]) == NULL)
Patrick Boettcher01373a52007-07-30 12:49:04 -0300907 return -ENODEV;
908 }
909
Michael Krufky77eed212011-09-06 09:31:57 -0300910 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
911 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib7070_set_param_override;
Patrick Boettcher01373a52007-07-30 12:49:04 -0300912 return 0;
913}
914
Olivier Greniee192a7c2011-01-14 13:58:59 -0300915static int stk7700p_pid_filter(struct dvb_usb_adapter *adapter, int index,
916 u16 pid, int onoff)
917{
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300918 struct dib0700_adapter_state *state = adapter->priv;
Olivier Greniee192a7c2011-01-14 13:58:59 -0300919 struct dib0700_state *st = adapter->dev->priv;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300920
Olivier Greniee192a7c2011-01-14 13:58:59 -0300921 if (st->is_dib7000pc)
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300922 return state->dib7000p_ops.pid_filter(adapter->fe_adap[0].fe, index, pid, onoff);
Michael Krufky77eed212011-09-06 09:31:57 -0300923 return dib7000m_pid_filter(adapter->fe_adap[0].fe, index, pid, onoff);
Olivier Greniee192a7c2011-01-14 13:58:59 -0300924}
925
926static int stk7700p_pid_filter_ctrl(struct dvb_usb_adapter *adapter, int onoff)
927{
928 struct dib0700_state *st = adapter->dev->priv;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300929 struct dib0700_adapter_state *state = adapter->priv;
Olivier Greniee192a7c2011-01-14 13:58:59 -0300930 if (st->is_dib7000pc)
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300931 return state->dib7000p_ops.pid_filter_ctrl(adapter->fe_adap[0].fe, onoff);
Michael Krufky77eed212011-09-06 09:31:57 -0300932 return dib7000m_pid_filter_ctrl(adapter->fe_adap[0].fe, onoff);
Olivier Greniee192a7c2011-01-14 13:58:59 -0300933}
934
Olivier Grenief8731f42009-09-18 04:08:43 -0300935static int stk70x0p_pid_filter(struct dvb_usb_adapter *adapter, int index, u16 pid, int onoff)
936{
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300937 struct dib0700_adapter_state *state = adapter->priv;
938 return state->dib7000p_ops.pid_filter(adapter->fe_adap[0].fe, index, pid, onoff);
Olivier Grenief8731f42009-09-18 04:08:43 -0300939}
940
941static int stk70x0p_pid_filter_ctrl(struct dvb_usb_adapter *adapter, int onoff)
942{
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300943 struct dib0700_adapter_state *state = adapter->priv;
944 return state->dib7000p_ops.pid_filter_ctrl(adapter->fe_adap[0].fe, onoff);
Olivier Grenief8731f42009-09-18 04:08:43 -0300945}
946
Patrick Boettcher01373a52007-07-30 12:49:04 -0300947static struct dibx000_bandwidth_config dib7070_bw_config_12_mhz = {
Mauro Carvalho Chehab09628b22014-09-22 18:57:45 -0300948 .internal = 60000,
949 .sampling = 15000,
950 .pll_prediv = 1,
951 .pll_ratio = 20,
952 .pll_range = 3,
953 .pll_reset = 1,
954 .pll_bypass = 0,
955 .enable_refdiv = 0,
956 .bypclk_div = 0,
957 .IO_CLK_en_core = 1,
958 .ADClkSrc = 1,
959 .modulo = 2,
960 .sad_cfg = (3 << 14) | (1 << 12) | (524 << 0),
961 .ifreq = (0 << 25) | 0,
962 .timf = 20452225,
963 .xtal_hz = 12000000,
Patrick Boettcher01373a52007-07-30 12:49:04 -0300964};
965
966static struct dib7000p_config dib7070p_dib7000p_config = {
967 .output_mpeg2_in_188_bytes = 1,
968
969 .agc_config_count = 1,
970 .agc = &dib7070_agc_config,
971 .bw = &dib7070_bw_config_12_mhz,
Patrick Boettcher3cb2c392008-01-25 07:25:20 -0300972 .tuner_is_baseband = 1,
973 .spur_protect = 1,
Patrick Boettcher01373a52007-07-30 12:49:04 -0300974
975 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
976 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
977 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
978
979 .hostbus_diversity = 1,
980};
981
982/* STK7070P */
983static int stk7070p_frontend_attach(struct dvb_usb_adapter *adap)
984{
Al Viroda5ee482008-05-21 00:31:21 -0300985 struct usb_device_descriptor *p = &adap->dev->udev->descriptor;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300986 struct dib0700_adapter_state *state = adap->priv;
987
988 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
989 return -ENODEV;
990
Al Viroda5ee482008-05-21 00:31:21 -0300991 if (p->idVendor == cpu_to_le16(USB_VID_PINNACLE) &&
992 p->idProduct == cpu_to_le16(USB_PID_PINNACLE_PCTV72E))
993 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300994 else
Al Viroda5ee482008-05-21 00:31:21 -0300995 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
Patrick Boettcher01373a52007-07-30 12:49:04 -0300996 msleep(10);
997 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
998 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
999 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
1000 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
1001
1002 dib0700_ctrl_clock(adap->dev, 72, 1);
1003
1004 msleep(10);
1005 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
1006 msleep(10);
1007 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
1008
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03001009 if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 18,
Devin Heitmueller83c4fdf2009-01-21 01:55:45 -03001010 &dib7070p_dib7000p_config) != 0) {
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03001011 err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n",
Devin Heitmueller83c4fdf2009-01-21 01:55:45 -03001012 __func__);
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03001013 dvb_detach(&state->dib7000p_ops);
Devin Heitmueller83c4fdf2009-01-21 01:55:45 -03001014 return -ENODEV;
1015 }
Patrick Boettcher01373a52007-07-30 12:49:04 -03001016
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03001017 adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap, 0x80,
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03001018 &dib7070p_dib7000p_config);
Michael Krufky77eed212011-09-06 09:31:57 -03001019 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Patrick Boettcher01373a52007-07-30 12:49:04 -03001020}
1021
Olivier Grenie90e12ce2010-09-07 12:50:45 -03001022/* STK7770P */
1023static struct dib7000p_config dib7770p_dib7000p_config = {
1024 .output_mpeg2_in_188_bytes = 1,
1025
1026 .agc_config_count = 1,
1027 .agc = &dib7070_agc_config,
1028 .bw = &dib7070_bw_config_12_mhz,
1029 .tuner_is_baseband = 1,
1030 .spur_protect = 1,
1031
1032 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
1033 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
1034 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
1035
1036 .hostbus_diversity = 1,
1037 .enable_current_mirror = 1,
Olivier Grenie970d14c2010-09-07 12:50:46 -03001038 .disable_sample_and_hold = 0,
Olivier Grenie90e12ce2010-09-07 12:50:45 -03001039};
1040
1041static int stk7770p_frontend_attach(struct dvb_usb_adapter *adap)
1042{
1043 struct usb_device_descriptor *p = &adap->dev->udev->descriptor;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03001044 struct dib0700_adapter_state *state = adap->priv;
1045
1046 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
1047 return -ENODEV;
1048
Olivier Grenie90e12ce2010-09-07 12:50:45 -03001049 if (p->idVendor == cpu_to_le16(USB_VID_PINNACLE) &&
1050 p->idProduct == cpu_to_le16(USB_PID_PINNACLE_PCTV72E))
1051 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
1052 else
1053 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
1054 msleep(10);
1055 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
1056 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
1057 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
1058 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
1059
1060 dib0700_ctrl_clock(adap->dev, 72, 1);
1061
1062 msleep(10);
1063 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
1064 msleep(10);
1065 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
1066
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03001067 if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 18,
Olivier Grenie90e12ce2010-09-07 12:50:45 -03001068 &dib7770p_dib7000p_config) != 0) {
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03001069 err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n",
Olivier Grenie90e12ce2010-09-07 12:50:45 -03001070 __func__);
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03001071 dvb_detach(&state->dib7000p_ops);
Olivier Grenie90e12ce2010-09-07 12:50:45 -03001072 return -ENODEV;
1073 }
1074
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03001075 adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap, 0x80,
Olivier Grenie90e12ce2010-09-07 12:50:45 -03001076 &dib7770p_dib7000p_config);
Michael Krufky77eed212011-09-06 09:31:57 -03001077 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Olivier Grenie90e12ce2010-09-07 12:50:45 -03001078}
1079
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001080/* DIB807x generic */
1081static struct dibx000_agc_config dib807x_agc_config[2] = {
1082 {
1083 BAND_VHF,
1084 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0,
1085 * P_agc_freq_pwm_div=1, P_agc_inv_pwm1=0,
1086 * P_agc_inv_pwm2=0,P_agc_inh_dc_rv_est=0,
1087 * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5,
1088 * P_agc_write=0 */
1089 (0 << 15) | (0 << 14) | (7 << 11) | (0 << 10) | (0 << 9) |
1090 (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) |
1091 (0 << 0), /* setup*/
1092
1093 600, /* inv_gain*/
1094 10, /* time_stabiliz*/
1095
1096 0, /* alpha_level*/
1097 118, /* thlock*/
1098
1099 0, /* wbd_inv*/
1100 3530, /* wbd_ref*/
1101 1, /* wbd_sel*/
1102 5, /* wbd_alpha*/
1103
1104 65535, /* agc1_max*/
1105 0, /* agc1_min*/
1106
1107 65535, /* agc2_max*/
1108 0, /* agc2_min*/
1109
1110 0, /* agc1_pt1*/
1111 40, /* agc1_pt2*/
1112 183, /* agc1_pt3*/
1113 206, /* agc1_slope1*/
1114 255, /* agc1_slope2*/
1115 72, /* agc2_pt1*/
1116 152, /* agc2_pt2*/
1117 88, /* agc2_slope1*/
1118 90, /* agc2_slope2*/
1119
1120 17, /* alpha_mant*/
1121 27, /* alpha_exp*/
1122 23, /* beta_mant*/
1123 51, /* beta_exp*/
1124
1125 0, /* perform_agc_softsplit*/
1126 }, {
1127 BAND_UHF,
1128 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0,
1129 * P_agc_freq_pwm_div=1, P_agc_inv_pwm1=0,
1130 * P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
1131 * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5,
1132 * P_agc_write=0 */
1133 (0 << 15) | (0 << 14) | (1 << 11) | (0 << 10) | (0 << 9) |
1134 (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) |
1135 (0 << 0), /* setup */
1136
1137 600, /* inv_gain*/
1138 10, /* time_stabiliz*/
1139
1140 0, /* alpha_level*/
1141 118, /* thlock*/
1142
1143 0, /* wbd_inv*/
1144 3530, /* wbd_ref*/
1145 1, /* wbd_sel*/
1146 5, /* wbd_alpha*/
1147
1148 65535, /* agc1_max*/
1149 0, /* agc1_min*/
1150
1151 65535, /* agc2_max*/
1152 0, /* agc2_min*/
1153
1154 0, /* agc1_pt1*/
1155 40, /* agc1_pt2*/
1156 183, /* agc1_pt3*/
1157 206, /* agc1_slope1*/
1158 255, /* agc1_slope2*/
1159 72, /* agc2_pt1*/
1160 152, /* agc2_pt2*/
1161 88, /* agc2_slope1*/
1162 90, /* agc2_slope2*/
1163
1164 17, /* alpha_mant*/
1165 27, /* alpha_exp*/
1166 23, /* beta_mant*/
1167 51, /* beta_exp*/
1168
1169 0, /* perform_agc_softsplit*/
1170 }
1171};
1172
1173static struct dibx000_bandwidth_config dib807x_bw_config_12_mhz = {
Mauro Carvalho Chehab09628b22014-09-22 18:57:45 -03001174 .internal = 60000,
1175 .sampling = 15000,
1176 .pll_prediv = 1,
1177 .pll_ratio = 20,
1178 .pll_range = 3,
1179 .pll_reset = 1,
1180 .pll_bypass = 0,
1181 .enable_refdiv = 0,
1182 .bypclk_div = 0,
1183 .IO_CLK_en_core = 1,
1184 .ADClkSrc = 1,
1185 .modulo = 2,
1186 .sad_cfg = (3 << 14) | (1 << 12) | (599 << 0), /* sad_cfg: refsel, sel, freq_15k*/
1187 .ifreq = (0 << 25) | 0, /* ifreq = 0.000000 MHz*/
1188 .timf = 18179755,
1189 .xtal_hz = 12000000,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001190};
1191
1192static struct dib8000_config dib807x_dib8000_config[2] = {
1193 {
1194 .output_mpeg2_in_188_bytes = 1,
1195
1196 .agc_config_count = 2,
1197 .agc = dib807x_agc_config,
1198 .pll = &dib807x_bw_config_12_mhz,
1199 .tuner_is_baseband = 1,
1200
1201 .gpio_dir = DIB8000_GPIO_DEFAULT_DIRECTIONS,
1202 .gpio_val = DIB8000_GPIO_DEFAULT_VALUES,
1203 .gpio_pwm_pos = DIB8000_GPIO_DEFAULT_PWM_POS,
1204
1205 .hostbus_diversity = 1,
1206 .div_cfg = 1,
1207 .agc_control = &dib0070_ctrl_agc_filter,
1208 .output_mode = OUTMODE_MPEG2_FIFO,
1209 .drives = 0x2d98,
1210 }, {
1211 .output_mpeg2_in_188_bytes = 1,
1212
1213 .agc_config_count = 2,
1214 .agc = dib807x_agc_config,
1215 .pll = &dib807x_bw_config_12_mhz,
1216 .tuner_is_baseband = 1,
1217
1218 .gpio_dir = DIB8000_GPIO_DEFAULT_DIRECTIONS,
1219 .gpio_val = DIB8000_GPIO_DEFAULT_VALUES,
1220 .gpio_pwm_pos = DIB8000_GPIO_DEFAULT_PWM_POS,
1221
1222 .hostbus_diversity = 1,
1223 .agc_control = &dib0070_ctrl_agc_filter,
1224 .output_mode = OUTMODE_MPEG2_FIFO,
1225 .drives = 0x2d98,
1226 }
1227};
1228
Olivier Grenie03245a52009-12-04 13:27:57 -03001229static int dib80xx_tuner_reset(struct dvb_frontend *fe, int onoff)
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001230{
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001231 struct dvb_usb_adapter *adap = fe->dvb->priv;
1232 struct dib0700_adapter_state *state = adap->priv;
1233
1234 return state->dib8000_ops.set_gpio(fe, 5, 0, !onoff);
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001235}
1236
Olivier Grenie03245a52009-12-04 13:27:57 -03001237static int dib80xx_tuner_sleep(struct dvb_frontend *fe, int onoff)
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001238{
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001239 struct dvb_usb_adapter *adap = fe->dvb->priv;
1240 struct dib0700_adapter_state *state = adap->priv;
1241
1242 return state->dib8000_ops.set_gpio(fe, 0, 0, onoff);
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001243}
1244
1245static const struct dib0070_wbd_gain_cfg dib8070_wbd_gain_cfg[] = {
1246 { 240, 7},
1247 { 0xffff, 6},
1248};
1249
1250static struct dib0070_config dib807x_dib0070_config[2] = {
1251 {
1252 .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
Olivier Grenie03245a52009-12-04 13:27:57 -03001253 .reset = dib80xx_tuner_reset,
1254 .sleep = dib80xx_tuner_sleep,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001255 .clock_khz = 12000,
1256 .clock_pad_drive = 4,
1257 .vga_filter = 1,
1258 .force_crystal_mode = 1,
1259 .enable_third_order_filter = 1,
1260 .charge_pump = 0,
1261 .wbd_gain = dib8070_wbd_gain_cfg,
1262 .osc_buffer_state = 0,
1263 .freq_offset_khz_uhf = -100,
1264 .freq_offset_khz_vhf = -100,
1265 }, {
1266 .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
Olivier Grenie03245a52009-12-04 13:27:57 -03001267 .reset = dib80xx_tuner_reset,
1268 .sleep = dib80xx_tuner_sleep,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001269 .clock_khz = 12000,
1270 .clock_pad_drive = 2,
1271 .vga_filter = 1,
1272 .force_crystal_mode = 1,
1273 .enable_third_order_filter = 1,
1274 .charge_pump = 0,
1275 .wbd_gain = dib8070_wbd_gain_cfg,
1276 .osc_buffer_state = 0,
1277 .freq_offset_khz_uhf = -25,
1278 .freq_offset_khz_vhf = -25,
1279 }
1280};
1281
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -03001282static int dib807x_set_param_override(struct dvb_frontend *fe)
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001283{
Mauro Carvalho Chehab47b163a2011-12-24 10:18:24 -03001284 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001285 struct dvb_usb_adapter *adap = fe->dvb->priv;
1286 struct dib0700_adapter_state *state = adap->priv;
1287
1288 u16 offset = dib0070_wbd_offset(fe);
Mauro Carvalho Chehab47b163a2011-12-24 10:18:24 -03001289 u8 band = BAND_OF_FREQUENCY(p->frequency/1000);
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001290 switch (band) {
1291 case BAND_VHF:
1292 offset += 750;
1293 break;
1294 case BAND_UHF: /* fall-thru wanted */
1295 default:
1296 offset += 250; break;
1297 }
1298 deb_info("WBD for DiB8000: %d\n", offset);
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001299 state->dib8000_ops.set_wbd_ref(fe, offset);
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001300
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -03001301 return state->set_param_save(fe);
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001302}
1303
1304static int dib807x_tuner_attach(struct dvb_usb_adapter *adap)
1305{
1306 struct dib0700_adapter_state *st = adap->priv;
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001307 struct i2c_adapter *tun_i2c = st->dib8000_ops.get_i2c_master(adap->fe_adap[0].fe,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001308 DIBX000_I2C_INTERFACE_TUNER, 1);
1309
1310 if (adap->id == 0) {
Michael Krufky77eed212011-09-06 09:31:57 -03001311 if (dvb_attach(dib0070_attach, adap->fe_adap[0].fe, tun_i2c,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001312 &dib807x_dib0070_config[0]) == NULL)
1313 return -ENODEV;
1314 } else {
Michael Krufky77eed212011-09-06 09:31:57 -03001315 if (dvb_attach(dib0070_attach, adap->fe_adap[0].fe, tun_i2c,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001316 &dib807x_dib0070_config[1]) == NULL)
1317 return -ENODEV;
1318 }
1319
Michael Krufky77eed212011-09-06 09:31:57 -03001320 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
1321 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib807x_set_param_override;
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001322 return 0;
1323}
1324
Olivier Grenie9c783032009-12-07 07:49:40 -03001325static int stk80xx_pid_filter(struct dvb_usb_adapter *adapter, int index,
1326 u16 pid, int onoff)
Olivier Grenief8731f42009-09-18 04:08:43 -03001327{
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001328 struct dib0700_adapter_state *state = adapter->priv;
1329
1330 return state->dib8000_ops.pid_filter(adapter->fe_adap[0].fe, index, pid, onoff);
Olivier Grenief8731f42009-09-18 04:08:43 -03001331}
1332
Olivier Grenie9c783032009-12-07 07:49:40 -03001333static int stk80xx_pid_filter_ctrl(struct dvb_usb_adapter *adapter,
Olivier Greniebe9bae12011-01-04 05:42:19 -03001334 int onoff)
Olivier Grenief8731f42009-09-18 04:08:43 -03001335{
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001336 struct dib0700_adapter_state *state = adapter->priv;
1337
1338 return state->dib8000_ops.pid_filter_ctrl(adapter->fe_adap[0].fe, onoff);
Olivier Grenief8731f42009-09-18 04:08:43 -03001339}
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001340
1341/* STK807x */
1342static int stk807x_frontend_attach(struct dvb_usb_adapter *adap)
1343{
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001344 struct dib0700_adapter_state *state = adap->priv;
1345
1346 if (!dvb_attach(dib8000_attach, &state->dib8000_ops))
1347 return -ENODEV;
1348
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001349 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
1350 msleep(10);
1351 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
1352 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
1353 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
1354
1355 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
1356
1357 dib0700_ctrl_clock(adap->dev, 72, 1);
1358
1359 msleep(10);
1360 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
1361 msleep(10);
1362 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
1363
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001364 state->dib8000_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 18,
Olivier Grenie0c32dbd2011-08-10 05:17:18 -03001365 0x80, 0);
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001366
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001367 adap->fe_adap[0].fe = state->dib8000_ops.init(&adap->dev->i2c_adap, 0x80,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001368 &dib807x_dib8000_config[0]);
1369
Michael Krufky77eed212011-09-06 09:31:57 -03001370 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001371}
1372
1373/* STK807xPVR */
1374static int stk807xpvr_frontend_attach0(struct dvb_usb_adapter *adap)
1375{
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001376 struct dib0700_adapter_state *state = adap->priv;
1377
1378 if (!dvb_attach(dib8000_attach, &state->dib8000_ops))
1379 return -ENODEV;
1380
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001381 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
1382 msleep(30);
1383 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
1384 msleep(500);
1385 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
1386 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
1387 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
1388
1389 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
1390
1391 dib0700_ctrl_clock(adap->dev, 72, 1);
1392
1393 msleep(10);
1394 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
1395 msleep(10);
1396 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
1397
1398 /* initialize IC 0 */
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001399 state->dib8000_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 0x22, 0x80, 0);
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001400
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001401 adap->fe_adap[0].fe = state->dib8000_ops.init(&adap->dev->i2c_adap, 0x80,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001402 &dib807x_dib8000_config[0]);
1403
Michael Krufky77eed212011-09-06 09:31:57 -03001404 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001405}
1406
1407static int stk807xpvr_frontend_attach1(struct dvb_usb_adapter *adap)
1408{
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001409 struct dib0700_adapter_state *state = adap->priv;
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001410
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001411 if (!dvb_attach(dib8000_attach, &state->dib8000_ops))
1412 return -ENODEV;
1413
1414 /* initialize IC 1 */
1415 state->dib8000_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 0x12, 0x82, 0);
1416
1417 adap->fe_adap[0].fe = state->dib8000_ops.init(&adap->dev->i2c_adap, 0x82,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001418 &dib807x_dib8000_config[1]);
1419
Michael Krufky77eed212011-09-06 09:31:57 -03001420 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001421}
1422
Olivier Grenie03245a52009-12-04 13:27:57 -03001423/* STK8096GP */
Olivier Greniea685dbb2011-08-05 14:10:40 -03001424static struct dibx000_agc_config dib8090_agc_config[2] = {
Olivier Greniebe9bae12011-01-04 05:42:19 -03001425 {
Mauro Carvalho Chehab40d1a7c2014-07-04 14:15:34 -03001426 .band_caps = BAND_UHF | BAND_VHF | BAND_LBAND | BAND_SBAND,
Olivier Grenie9c783032009-12-07 07:49:40 -03001427 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=1,
Olivier Greniebe9bae12011-01-04 05:42:19 -03001428 * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
1429 * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5, P_agc_write=0 */
Mauro Carvalho Chehab40d1a7c2014-07-04 14:15:34 -03001430 .setup = (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8)
Olivier Grenie9c783032009-12-07 07:49:40 -03001431 | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),
Olivier Grenie03245a52009-12-04 13:27:57 -03001432
Mauro Carvalho Chehab40d1a7c2014-07-04 14:15:34 -03001433 .inv_gain = 787,
1434 .time_stabiliz = 10,
Olivier Grenie03245a52009-12-04 13:27:57 -03001435
Mauro Carvalho Chehab40d1a7c2014-07-04 14:15:34 -03001436 .alpha_level = 0,
1437 .thlock = 118,
Olivier Grenie03245a52009-12-04 13:27:57 -03001438
Mauro Carvalho Chehab40d1a7c2014-07-04 14:15:34 -03001439 .wbd_inv = 0,
1440 .wbd_ref = 3530,
1441 .wbd_sel = 1,
1442 .wbd_alpha = 5,
Olivier Grenie03245a52009-12-04 13:27:57 -03001443
Mauro Carvalho Chehab40d1a7c2014-07-04 14:15:34 -03001444 .agc1_max = 65535,
1445 .agc1_min = 0,
Olivier Grenie03245a52009-12-04 13:27:57 -03001446
Mauro Carvalho Chehab40d1a7c2014-07-04 14:15:34 -03001447 .agc2_max = 65535,
1448 .agc2_min = 0,
Olivier Grenie03245a52009-12-04 13:27:57 -03001449
Mauro Carvalho Chehab40d1a7c2014-07-04 14:15:34 -03001450 .agc1_pt1 = 0,
1451 .agc1_pt2 = 32,
1452 .agc1_pt3 = 114,
1453 .agc1_slope1 = 143,
1454 .agc1_slope2 = 144,
1455 .agc2_pt1 = 114,
1456 .agc2_pt2 = 227,
1457 .agc2_slope1 = 116,
1458 .agc2_slope2 = 117,
Olivier Grenie03245a52009-12-04 13:27:57 -03001459
Mauro Carvalho Chehab40d1a7c2014-07-04 14:15:34 -03001460 .alpha_mant = 28,
1461 .alpha_exp = 26,
1462 .beta_mant = 31,
1463 .beta_exp = 51,
Olivier Grenie03245a52009-12-04 13:27:57 -03001464
Mauro Carvalho Chehab40d1a7c2014-07-04 14:15:34 -03001465 .perform_agc_softsplit = 0,
Olivier Greniebe9bae12011-01-04 05:42:19 -03001466 },
1467 {
Mauro Carvalho Chehab40d1a7c2014-07-04 14:15:34 -03001468 .band_caps = BAND_CBAND,
Olivier Grenie9c783032009-12-07 07:49:40 -03001469 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=1,
Olivier Greniebe9bae12011-01-04 05:42:19 -03001470 * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
1471 * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5, P_agc_write=0 */
Mauro Carvalho Chehab40d1a7c2014-07-04 14:15:34 -03001472 .setup = (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8)
Olivier Grenie9c783032009-12-07 07:49:40 -03001473 | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),
Olivier Grenie03245a52009-12-04 13:27:57 -03001474
Mauro Carvalho Chehab40d1a7c2014-07-04 14:15:34 -03001475 .inv_gain = 787,
1476 .time_stabiliz = 10,
Olivier Grenie03245a52009-12-04 13:27:57 -03001477
Mauro Carvalho Chehab40d1a7c2014-07-04 14:15:34 -03001478 .alpha_level = 0,
1479 .thlock = 118,
Olivier Grenie03245a52009-12-04 13:27:57 -03001480
Mauro Carvalho Chehab40d1a7c2014-07-04 14:15:34 -03001481 .wbd_inv = 0,
1482 .wbd_ref = 3530,
1483 .wbd_sel = 1,
1484 .wbd_alpha = 5,
Olivier Grenie03245a52009-12-04 13:27:57 -03001485
Mauro Carvalho Chehab40d1a7c2014-07-04 14:15:34 -03001486 .agc1_max = 0,
1487 .agc1_min = 0,
Olivier Grenie03245a52009-12-04 13:27:57 -03001488
Mauro Carvalho Chehab40d1a7c2014-07-04 14:15:34 -03001489 .agc2_max = 65535,
1490 .agc2_min = 0,
Olivier Grenie03245a52009-12-04 13:27:57 -03001491
Mauro Carvalho Chehab40d1a7c2014-07-04 14:15:34 -03001492 .agc1_pt1 = 0,
1493 .agc1_pt2 = 32,
1494 .agc1_pt3 = 114,
1495 .agc1_slope1 = 143,
1496 .agc1_slope2 = 144,
1497 .agc2_pt1 = 114,
1498 .agc2_pt2 = 227,
1499 .agc2_slope1 = 116,
1500 .agc2_slope2 = 117,
Olivier Grenie03245a52009-12-04 13:27:57 -03001501
Mauro Carvalho Chehab40d1a7c2014-07-04 14:15:34 -03001502 .alpha_mant = 28,
1503 .alpha_exp = 26,
1504 .beta_mant = 31,
1505 .beta_exp = 51,
Olivier Grenie03245a52009-12-04 13:27:57 -03001506
Mauro Carvalho Chehab40d1a7c2014-07-04 14:15:34 -03001507 .perform_agc_softsplit = 0,
Olivier Greniebe9bae12011-01-04 05:42:19 -03001508 }
Olivier Grenie03245a52009-12-04 13:27:57 -03001509};
1510
1511static struct dibx000_bandwidth_config dib8090_pll_config_12mhz = {
Mauro Carvalho Chehab40d1a7c2014-07-04 14:15:34 -03001512 .internal = 54000,
1513 .sampling = 13500,
1514
1515 .pll_prediv = 1,
1516 .pll_ratio = 18,
1517 .pll_range = 3,
1518 .pll_reset = 1,
1519 .pll_bypass = 0,
1520
1521 .enable_refdiv = 0,
1522 .bypclk_div = 0,
1523 .IO_CLK_en_core = 1,
1524 .ADClkSrc = 1,
1525 .modulo = 2,
1526
1527 .sad_cfg = (3 << 14) | (1 << 12) | (599 << 0),
1528
1529 .ifreq = (0 << 25) | 0,
1530 .timf = 20199727,
1531
1532 .xtal_hz = 12000000,
Olivier Grenie03245a52009-12-04 13:27:57 -03001533};
1534
1535static int dib8090_get_adc_power(struct dvb_frontend *fe)
1536{
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001537 struct dvb_usb_adapter *adap = fe->dvb->priv;
1538 struct dib0700_adapter_state *state = adap->priv;
1539
1540 return state->dib8000_ops.get_adc_power(fe, 1);
Olivier Grenie03245a52009-12-04 13:27:57 -03001541}
1542
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001543static void dib8090_agc_control(struct dvb_frontend *fe, u8 restart)
1544{
1545 deb_info("AGC control callback: %i\n", restart);
1546 dib0090_dcc_freq(fe, restart);
1547
1548 if (restart == 0) /* before AGC startup */
1549 dib0090_set_dc_servo(fe, 1);
1550}
1551
Olivier Greniebe9bae12011-01-04 05:42:19 -03001552static struct dib8000_config dib809x_dib8000_config[2] = {
1553 {
1554 .output_mpeg2_in_188_bytes = 1,
Olivier Grenie03245a52009-12-04 13:27:57 -03001555
Olivier Greniebe9bae12011-01-04 05:42:19 -03001556 .agc_config_count = 2,
1557 .agc = dib8090_agc_config,
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001558 .agc_control = dib8090_agc_control,
Olivier Greniebe9bae12011-01-04 05:42:19 -03001559 .pll = &dib8090_pll_config_12mhz,
1560 .tuner_is_baseband = 1,
Olivier Grenie03245a52009-12-04 13:27:57 -03001561
Olivier Greniebe9bae12011-01-04 05:42:19 -03001562 .gpio_dir = DIB8000_GPIO_DEFAULT_DIRECTIONS,
1563 .gpio_val = DIB8000_GPIO_DEFAULT_VALUES,
1564 .gpio_pwm_pos = DIB8000_GPIO_DEFAULT_PWM_POS,
Olivier Grenie03245a52009-12-04 13:27:57 -03001565
Olivier Greniebe9bae12011-01-04 05:42:19 -03001566 .hostbus_diversity = 1,
1567 .div_cfg = 0x31,
1568 .output_mode = OUTMODE_MPEG2_FIFO,
1569 .drives = 0x2d98,
1570 .diversity_delay = 48,
1571 .refclksel = 3,
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03001572 }, {
Olivier Greniebe9bae12011-01-04 05:42:19 -03001573 .output_mpeg2_in_188_bytes = 1,
1574
1575 .agc_config_count = 2,
1576 .agc = dib8090_agc_config,
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001577 .agc_control = dib8090_agc_control,
Olivier Greniebe9bae12011-01-04 05:42:19 -03001578 .pll = &dib8090_pll_config_12mhz,
1579 .tuner_is_baseband = 1,
1580
1581 .gpio_dir = DIB8000_GPIO_DEFAULT_DIRECTIONS,
1582 .gpio_val = DIB8000_GPIO_DEFAULT_VALUES,
1583 .gpio_pwm_pos = DIB8000_GPIO_DEFAULT_PWM_POS,
1584
1585 .hostbus_diversity = 1,
1586 .div_cfg = 0x31,
1587 .output_mode = OUTMODE_DIVERSITY,
1588 .drives = 0x2d08,
1589 .diversity_delay = 1,
1590 .refclksel = 3,
1591 }
1592};
1593
1594static struct dib0090_wbd_slope dib8090_wbd_table[] = {
1595 /* max freq ; cold slope ; cold offset ; warm slope ; warm offset ; wbd gain */
1596 { 120, 0, 500, 0, 500, 4 }, /* CBAND */
1597 { 170, 0, 450, 0, 450, 4 }, /* CBAND */
1598 { 380, 48, 373, 28, 259, 6 }, /* VHF */
1599 { 860, 34, 700, 36, 616, 6 }, /* high UHF */
1600 { 0xFFFF, 34, 700, 36, 616, 6 }, /* default */
Olivier Grenie03245a52009-12-04 13:27:57 -03001601};
1602
1603static struct dib0090_config dib809x_dib0090_config = {
Olivier Greniebe9bae12011-01-04 05:42:19 -03001604 .io.pll_bypass = 1,
1605 .io.pll_range = 1,
1606 .io.pll_prediv = 1,
1607 .io.pll_loopdiv = 20,
1608 .io.adc_clock_ratio = 8,
1609 .io.pll_int_loop_filt = 0,
1610 .io.clock_khz = 12000,
1611 .reset = dib80xx_tuner_reset,
1612 .sleep = dib80xx_tuner_sleep,
1613 .clkouttobamse = 1,
1614 .analog_output = 1,
1615 .i2c_address = DEFAULT_DIB0090_I2C_ADDRESS,
1616 .use_pwm_agc = 1,
1617 .clkoutdrive = 1,
1618 .get_adc_power = dib8090_get_adc_power,
1619 .freq_offset_khz_uhf = -63,
Olivier Grenie03245a52009-12-04 13:27:57 -03001620 .freq_offset_khz_vhf = -143,
Olivier Greniebe9bae12011-01-04 05:42:19 -03001621 .wbd = dib8090_wbd_table,
1622 .fref_clock_ratio = 6,
Olivier Grenie03245a52009-12-04 13:27:57 -03001623};
1624
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001625static u8 dib8090_compute_pll_parameters(struct dvb_frontend *fe)
1626{
1627 u8 optimal_pll_ratio = 20;
1628 u32 freq_adc, ratio, rest, max = 0;
1629 u8 pll_ratio;
1630
1631 for (pll_ratio = 17; pll_ratio <= 20; pll_ratio++) {
1632 freq_adc = 12 * pll_ratio * (1 << 8) / 16;
1633 ratio = ((fe->dtv_property_cache.frequency / 1000) * (1 << 8) / 1000) / freq_adc;
1634 rest = ((fe->dtv_property_cache.frequency / 1000) * (1 << 8) / 1000) - ratio * freq_adc;
1635
1636 if (rest > freq_adc / 2)
1637 rest = freq_adc - rest;
1638 deb_info("PLL ratio=%i rest=%i\n", pll_ratio, rest);
1639 if ((rest > max) && (rest > 717)) {
1640 optimal_pll_ratio = pll_ratio;
1641 max = rest;
1642 }
1643 }
1644 deb_info("optimal PLL ratio=%i\n", optimal_pll_ratio);
1645
1646 return optimal_pll_ratio;
1647}
1648
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -03001649static int dib8096_set_param_override(struct dvb_frontend *fe)
Olivier Grenie03245a52009-12-04 13:27:57 -03001650{
Olivier Greniebe9bae12011-01-04 05:42:19 -03001651 struct dvb_usb_adapter *adap = fe->dvb->priv;
1652 struct dib0700_adapter_state *state = adap->priv;
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001653 u8 pll_ratio, band = BAND_OF_FREQUENCY(fe->dtv_property_cache.frequency / 1000);
1654 u16 target, ltgain, rf_gain_limit;
1655 u32 timf;
Olivier Greniebe9bae12011-01-04 05:42:19 -03001656 int ret = 0;
1657 enum frontend_tune_state tune_state = CT_SHUTDOWN;
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001658
1659 switch (band) {
1660 default:
1661 deb_info("Warning : Rf frequency (%iHz) is not in the supported range, using VHF switch ", fe->dtv_property_cache.frequency);
1662 case BAND_VHF:
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001663 state->dib8000_ops.set_gpio(fe, 3, 0, 1);
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001664 break;
1665 case BAND_UHF:
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001666 state->dib8000_ops.set_gpio(fe, 3, 0, 0);
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001667 break;
1668 }
Olivier Grenie03245a52009-12-04 13:27:57 -03001669
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -03001670 ret = state->set_param_save(fe);
Olivier Greniebe9bae12011-01-04 05:42:19 -03001671 if (ret < 0)
1672 return ret;
Olivier Grenie03245a52009-12-04 13:27:57 -03001673
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001674 if (fe->dtv_property_cache.bandwidth_hz != 6000000) {
1675 deb_info("only 6MHz bandwidth is supported\n");
1676 return -EINVAL;
1677 }
Olivier Grenie03245a52009-12-04 13:27:57 -03001678
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001679 /** Update PLL if needed ratio **/
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001680 state->dib8000_ops.update_pll(fe, &dib8090_pll_config_12mhz, fe->dtv_property_cache.bandwidth_hz / 1000, 0);
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001681
1682 /** Get optimize PLL ratio to remove spurious **/
1683 pll_ratio = dib8090_compute_pll_parameters(fe);
1684 if (pll_ratio == 17)
1685 timf = 21387946;
1686 else if (pll_ratio == 18)
1687 timf = 20199727;
1688 else if (pll_ratio == 19)
1689 timf = 19136583;
1690 else
1691 timf = 18179756;
1692
1693 /** Update ratio **/
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001694 state->dib8000_ops.update_pll(fe, &dib8090_pll_config_12mhz, fe->dtv_property_cache.bandwidth_hz / 1000, pll_ratio);
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001695
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001696 state->dib8000_ops.ctrl_timf(fe, DEMOD_TIMF_SET, timf);
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001697
1698 if (band != BAND_CBAND) {
1699 /* dib0090_get_wbd_target is returning any possible temperature compensated wbd-target */
1700 target = (dib0090_get_wbd_target(fe) * 8 * 18 / 33 + 1) / 2;
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001701 state->dib8000_ops.set_wbd_ref(fe, target);
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001702 }
Olivier Grenie03245a52009-12-04 13:27:57 -03001703
Olivier Greniebe9bae12011-01-04 05:42:19 -03001704 if (band == BAND_CBAND) {
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03001705 deb_info("tuning in CBAND - soft-AGC startup\n");
1706 dib0090_set_tune_state(fe, CT_AGC_START);
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001707
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03001708 do {
1709 ret = dib0090_gain_control(fe);
1710 msleep(ret);
1711 tune_state = dib0090_get_tune_state(fe);
1712 if (tune_state == CT_AGC_STEP_0)
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001713 state->dib8000_ops.set_gpio(fe, 6, 0, 1);
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03001714 else if (tune_state == CT_AGC_STEP_1) {
1715 dib0090_get_current_gain(fe, NULL, NULL, &rf_gain_limit, &ltgain);
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001716 if (rf_gain_limit < 2000) /* activate the external attenuator in case of very high input power */
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001717 state->dib8000_ops.set_gpio(fe, 6, 0, 0);
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03001718 }
1719 } while (tune_state < CT_AGC_STOP);
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001720
1721 deb_info("switching to PWM AGC\n");
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03001722 dib0090_pwm_gain_reset(fe);
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001723 state->dib8000_ops.pwm_agc_reset(fe);
1724 state->dib8000_ops.set_tune_state(fe, CT_DEMOD_START);
Olivier Greniebe9bae12011-01-04 05:42:19 -03001725 } else {
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001726 /* for everything else than CBAND we are using standard AGC */
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03001727 deb_info("not tuning in CBAND - standard AGC startup\n");
1728 dib0090_pwm_gain_reset(fe);
Olivier Greniebe9bae12011-01-04 05:42:19 -03001729 }
Olivier Grenie03245a52009-12-04 13:27:57 -03001730
Olivier Greniebe9bae12011-01-04 05:42:19 -03001731 return 0;
Olivier Grenie03245a52009-12-04 13:27:57 -03001732}
1733
1734static int dib809x_tuner_attach(struct dvb_usb_adapter *adap)
1735{
Olivier Greniebe9bae12011-01-04 05:42:19 -03001736 struct dib0700_adapter_state *st = adap->priv;
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001737 struct i2c_adapter *tun_i2c = st->dib8000_ops.get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_TUNER, 1);
Olivier Grenie03245a52009-12-04 13:27:57 -03001738
Nicolas Sugino91be2602015-11-26 19:00:28 -02001739 if (adap->id == 0) {
1740 if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c, &dib809x_dib0090_config) == NULL)
1741 return -ENODEV;
1742 } else {
1743 if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c, &dib809x_dib0090_config) == NULL)
1744 return -ENODEV;
1745 }
Olivier Grenie03245a52009-12-04 13:27:57 -03001746
Michael Krufky77eed212011-09-06 09:31:57 -03001747 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
1748 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib8096_set_param_override;
Olivier Greniebe9bae12011-01-04 05:42:19 -03001749 return 0;
Olivier Grenie03245a52009-12-04 13:27:57 -03001750}
1751
1752static int stk809x_frontend_attach(struct dvb_usb_adapter *adap)
1753{
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001754 struct dib0700_adapter_state *state = adap->priv;
1755
1756 if (!dvb_attach(dib8000_attach, &state->dib8000_ops))
1757 return -ENODEV;
1758
Olivier Grenie03245a52009-12-04 13:27:57 -03001759 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
1760 msleep(10);
1761 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
1762 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
1763 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
1764
1765 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
1766
1767 dib0700_ctrl_clock(adap->dev, 72, 1);
1768
1769 msleep(10);
1770 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
1771 msleep(10);
1772 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
1773
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001774 state->dib8000_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 18, 0x80, 0);
Olivier Grenie03245a52009-12-04 13:27:57 -03001775
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001776 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 -03001777
Michael Krufky77eed212011-09-06 09:31:57 -03001778 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Olivier Grenie03245a52009-12-04 13:27:57 -03001779}
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001780
Nicolas Sugino91be2602015-11-26 19:00:28 -02001781static int stk809x_frontend1_attach(struct dvb_usb_adapter *adap)
1782{
1783 struct dib0700_adapter_state *state = adap->priv;
1784
1785 if (!dvb_attach(dib8000_attach, &state->dib8000_ops))
1786 return -ENODEV;
1787
1788 state->dib8000_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 0x10, 0x82, 0);
1789
1790 adap->fe_adap[0].fe = state->dib8000_ops.init(&adap->dev->i2c_adap, 0x82, &dib809x_dib8000_config[1]);
1791
1792 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
1793}
1794
Olivier Greniebe9bae12011-01-04 05:42:19 -03001795static int nim8096md_tuner_attach(struct dvb_usb_adapter *adap)
1796{
1797 struct dib0700_adapter_state *st = adap->priv;
1798 struct i2c_adapter *tun_i2c;
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001799 struct dvb_frontend *fe_slave = st->dib8000_ops.get_slave_frontend(adap->fe_adap[0].fe, 1);
Olivier Greniebe9bae12011-01-04 05:42:19 -03001800
1801 if (fe_slave) {
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001802 tun_i2c = st->dib8000_ops.get_i2c_master(fe_slave, DIBX000_I2C_INTERFACE_TUNER, 1);
Olivier Greniebe9bae12011-01-04 05:42:19 -03001803 if (dvb_attach(dib0090_register, fe_slave, tun_i2c, &dib809x_dib0090_config) == NULL)
1804 return -ENODEV;
Michael Krufky77eed212011-09-06 09:31:57 -03001805 fe_slave->dvb = adap->fe_adap[0].fe->dvb;
Olivier Greniebe9bae12011-01-04 05:42:19 -03001806 fe_slave->ops.tuner_ops.set_params = dib8096_set_param_override;
1807 }
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001808 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 -03001809 if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c, &dib809x_dib0090_config) == NULL)
Olivier Greniebe9bae12011-01-04 05:42:19 -03001810 return -ENODEV;
1811
Michael Krufky77eed212011-09-06 09:31:57 -03001812 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
1813 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib8096_set_param_override;
Olivier Greniebe9bae12011-01-04 05:42:19 -03001814
1815 return 0;
1816}
1817
1818static int nim8096md_frontend_attach(struct dvb_usb_adapter *adap)
1819{
1820 struct dvb_frontend *fe_slave;
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001821 struct dib0700_adapter_state *state = adap->priv;
1822
1823 if (!dvb_attach(dib8000_attach, &state->dib8000_ops))
1824 return -ENODEV;
Olivier Greniebe9bae12011-01-04 05:42:19 -03001825
1826 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03001827 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03001828 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
1829 msleep(1000);
1830 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
1831 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
1832 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
1833
1834 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
1835
1836 dib0700_ctrl_clock(adap->dev, 72, 1);
1837
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03001838 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03001839 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03001840 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03001841 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
1842
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001843 state->dib8000_ops.i2c_enumeration(&adap->dev->i2c_adap, 2, 18, 0x80, 0);
Olivier Greniebe9bae12011-01-04 05:42:19 -03001844
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001845 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 -03001846 if (adap->fe_adap[0].fe == NULL)
Olivier Greniebe9bae12011-01-04 05:42:19 -03001847 return -ENODEV;
1848
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001849 /* Needed to increment refcount */
1850 if (!dvb_attach(dib8000_attach, &state->dib8000_ops))
1851 return -ENODEV;
1852
1853 fe_slave = state->dib8000_ops.init(&adap->dev->i2c_adap, 0x82, &dib809x_dib8000_config[1]);
1854 state->dib8000_ops.set_slave_frontend(adap->fe_adap[0].fe, fe_slave);
Olivier Greniebe9bae12011-01-04 05:42:19 -03001855
1856 return fe_slave == NULL ? -ENODEV : 0;
1857}
1858
Olivier Grenie88f3a352011-08-10 05:28:38 -03001859/* TFE8096P */
1860static struct dibx000_agc_config dib8096p_agc_config[2] = {
1861 {
1862 .band_caps = BAND_UHF,
1863 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0,
1864 P_agc_freq_pwm_div=1, P_agc_inv_pwm1=0,
1865 P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
1866 P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5,
1867 P_agc_write=0 */
1868 .setup = (0 << 15) | (0 << 14) | (5 << 11)
1869 | (0 << 10) | (0 << 9) | (0 << 8) | (3 << 5)
1870 | (0 << 4) | (5 << 1) | (0 << 0),
1871
1872 .inv_gain = 684,
1873 .time_stabiliz = 10,
1874
1875 .alpha_level = 0,
1876 .thlock = 118,
1877
1878 .wbd_inv = 0,
1879 .wbd_ref = 1200,
1880 .wbd_sel = 3,
1881 .wbd_alpha = 5,
1882
1883 .agc1_max = 65535,
1884 .agc1_min = 0,
1885
1886 .agc2_max = 32767,
1887 .agc2_min = 0,
1888
1889 .agc1_pt1 = 0,
1890 .agc1_pt2 = 0,
1891 .agc1_pt3 = 105,
1892 .agc1_slope1 = 0,
1893 .agc1_slope2 = 156,
1894 .agc2_pt1 = 105,
1895 .agc2_pt2 = 255,
1896 .agc2_slope1 = 54,
1897 .agc2_slope2 = 0,
1898
1899 .alpha_mant = 28,
1900 .alpha_exp = 26,
1901 .beta_mant = 31,
1902 .beta_exp = 51,
1903
1904 .perform_agc_softsplit = 0,
1905 } , {
1906 .band_caps = BAND_FM | BAND_VHF | BAND_CBAND,
1907 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0,
1908 P_agc_freq_pwm_div=1, P_agc_inv_pwm1=0,
1909 P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
1910 P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5,
1911 P_agc_write=0 */
1912 .setup = (0 << 15) | (0 << 14) | (5 << 11)
1913 | (0 << 10) | (0 << 9) | (0 << 8) | (3 << 5)
1914 | (0 << 4) | (5 << 1) | (0 << 0),
1915
1916 .inv_gain = 732,
1917 .time_stabiliz = 10,
1918
1919 .alpha_level = 0,
1920 .thlock = 118,
1921
1922 .wbd_inv = 0,
1923 .wbd_ref = 1200,
1924 .wbd_sel = 3,
1925 .wbd_alpha = 5,
1926
1927 .agc1_max = 65535,
1928 .agc1_min = 0,
1929
1930 .agc2_max = 32767,
1931 .agc2_min = 0,
1932
1933 .agc1_pt1 = 0,
1934 .agc1_pt2 = 0,
1935 .agc1_pt3 = 98,
1936 .agc1_slope1 = 0,
1937 .agc1_slope2 = 167,
1938 .agc2_pt1 = 98,
1939 .agc2_pt2 = 255,
1940 .agc2_slope1 = 52,
1941 .agc2_slope2 = 0,
1942
1943 .alpha_mant = 28,
1944 .alpha_exp = 26,
1945 .beta_mant = 31,
1946 .beta_exp = 51,
1947
1948 .perform_agc_softsplit = 0,
1949 }
1950};
1951
1952static struct dibx000_bandwidth_config dib8096p_clock_config_12_mhz = {
Mauro Carvalho Chehab09628b22014-09-22 18:57:45 -03001953 .internal = 108000,
1954 .sampling = 13500,
1955 .pll_prediv = 1,
1956 .pll_ratio = 9,
1957 .pll_range = 1,
1958 .pll_reset = 0,
1959 .pll_bypass = 0,
1960 .enable_refdiv = 0,
1961 .bypclk_div = 0,
1962 .IO_CLK_en_core = 0,
1963 .ADClkSrc = 0,
1964 .modulo = 2,
1965 .sad_cfg = (3 << 14) | (1 << 12) | (524 << 0),
1966 .ifreq = (0 << 25) | 0,
1967 .timf = 20199729,
1968 .xtal_hz = 12000000,
Olivier Grenie88f3a352011-08-10 05:28:38 -03001969};
1970
1971static struct dib8000_config tfe8096p_dib8000_config = {
1972 .output_mpeg2_in_188_bytes = 1,
1973 .hostbus_diversity = 1,
1974 .update_lna = NULL,
1975
1976 .agc_config_count = 2,
1977 .agc = dib8096p_agc_config,
1978 .pll = &dib8096p_clock_config_12_mhz,
1979
1980 .gpio_dir = DIB8000_GPIO_DEFAULT_DIRECTIONS,
1981 .gpio_val = DIB8000_GPIO_DEFAULT_VALUES,
1982 .gpio_pwm_pos = DIB8000_GPIO_DEFAULT_PWM_POS,
1983
1984 .agc_control = NULL,
1985 .diversity_delay = 48,
1986 .output_mode = OUTMODE_MPEG2_FIFO,
1987 .enMpegOutput = 1,
1988};
1989
1990static struct dib0090_wbd_slope dib8096p_wbd_table[] = {
1991 { 380, 81, 850, 64, 540, 4},
1992 { 860, 51, 866, 21, 375, 4},
1993 {1700, 0, 250, 0, 100, 6},
1994 {2600, 0, 250, 0, 100, 6},
1995 { 0xFFFF, 0, 0, 0, 0, 0},
1996};
1997
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001998static struct dib0090_config tfe8096p_dib0090_config = {
Olivier Grenie88f3a352011-08-10 05:28:38 -03001999 .io.clock_khz = 12000,
2000 .io.pll_bypass = 0,
2001 .io.pll_range = 0,
2002 .io.pll_prediv = 3,
2003 .io.pll_loopdiv = 6,
2004 .io.adc_clock_ratio = 0,
2005 .io.pll_int_loop_filt = 0,
Olivier Grenie88f3a352011-08-10 05:28:38 -03002006
2007 .freq_offset_khz_uhf = -143,
2008 .freq_offset_khz_vhf = -143,
2009
2010 .get_adc_power = dib8090_get_adc_power,
2011
2012 .clkouttobamse = 1,
2013 .analog_output = 0,
2014
2015 .wbd_vhf_offset = 0,
2016 .wbd_cband_offset = 0,
2017 .use_pwm_agc = 1,
2018 .clkoutdrive = 0,
2019
2020 .fref_clock_ratio = 1,
2021
Olivier Grenie88f3a352011-08-10 05:28:38 -03002022 .ls_cfg_pad_drv = 0,
2023 .data_tx_drv = 0,
2024 .low_if = NULL,
2025 .in_soc = 1,
2026 .force_cband_input = 0,
2027};
2028
2029struct dibx090p_adc {
2030 u32 freq; /* RF freq MHz */
2031 u32 timf; /* New Timf */
2032 u32 pll_loopdiv; /* New prediv */
2033 u32 pll_prediv; /* New loopdiv */
2034};
2035
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03002036struct dibx090p_best_adc {
2037 u32 timf;
2038 u32 pll_loopdiv;
2039 u32 pll_prediv;
Olivier Grenie88f3a352011-08-10 05:28:38 -03002040};
2041
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03002042static int dib8096p_get_best_sampling(struct dvb_frontend *fe, struct dibx090p_best_adc *adc)
2043{
2044 u8 spur = 0, prediv = 0, loopdiv = 0, min_prediv = 1, max_prediv = 1;
2045 u16 xtal = 12000;
2046 u16 fcp_min = 1900; /* PLL, Minimum Frequency of phase comparator (KHz) */
2047 u16 fcp_max = 20000; /* PLL, Maximum Frequency of phase comparator (KHz) */
2048 u32 fmem_max = 140000; /* 140MHz max SDRAM freq */
2049 u32 fdem_min = 66000;
2050 u32 fcp = 0, fs = 0, fdem = 0, fmem = 0;
2051 u32 harmonic_id = 0;
2052
2053 adc->timf = 0;
2054 adc->pll_loopdiv = loopdiv;
2055 adc->pll_prediv = prediv;
2056
2057 deb_info("bandwidth = %d", fe->dtv_property_cache.bandwidth_hz);
2058
2059 /* Find Min and Max prediv */
2060 while ((xtal / max_prediv) >= fcp_min)
2061 max_prediv++;
2062
2063 max_prediv--;
2064 min_prediv = max_prediv;
2065 while ((xtal / min_prediv) <= fcp_max) {
2066 min_prediv--;
2067 if (min_prediv == 1)
2068 break;
2069 }
2070 deb_info("MIN prediv = %d : MAX prediv = %d", min_prediv, max_prediv);
2071
2072 min_prediv = 1;
2073
2074 for (prediv = min_prediv; prediv < max_prediv; prediv++) {
2075 fcp = xtal / prediv;
2076 if (fcp > fcp_min && fcp < fcp_max) {
2077 for (loopdiv = 1; loopdiv < 64; loopdiv++) {
2078 fmem = ((xtal/prediv) * loopdiv);
2079 fdem = fmem / 2;
2080 fs = fdem / 4;
2081
2082 /* test min/max system restrictions */
2083 if ((fdem >= fdem_min) && (fmem <= fmem_max) && (fs >= fe->dtv_property_cache.bandwidth_hz / 1000)) {
2084 spur = 0;
2085 /* test fs harmonics positions */
2086 for (harmonic_id = (fe->dtv_property_cache.frequency / (1000 * fs)); harmonic_id <= ((fe->dtv_property_cache.frequency / (1000 * fs)) + 1); harmonic_id++) {
2087 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)))) {
2088 spur = 1;
2089 break;
2090 }
2091 }
2092
2093 if (!spur) {
2094 adc->pll_loopdiv = loopdiv;
2095 adc->pll_prediv = prediv;
2096 adc->timf = (4260880253U / fdem) * (1 << 8);
2097 adc->timf += ((4260880253U % fdem) << 8) / fdem;
2098
2099 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);
2100 break;
2101 }
2102 }
2103 }
2104 }
2105 if (!spur)
2106 break;
2107 }
2108
2109 if (adc->pll_loopdiv == 0 && adc->pll_prediv == 0)
2110 return -EINVAL;
2111 return 0;
2112}
2113
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -03002114static int dib8096p_agc_startup(struct dvb_frontend *fe)
Olivier Grenie88f3a352011-08-10 05:28:38 -03002115{
2116 struct dvb_usb_adapter *adap = fe->dvb->priv;
2117 struct dib0700_adapter_state *state = adap->priv;
2118 struct dibx000_bandwidth_config pll;
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03002119 struct dibx090p_best_adc adc;
Olivier Grenie88f3a352011-08-10 05:28:38 -03002120 u16 target;
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03002121 int ret;
Olivier Grenie88f3a352011-08-10 05:28:38 -03002122
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -03002123 ret = state->set_param_save(fe);
Olivier Grenie88f3a352011-08-10 05:28:38 -03002124 if (ret < 0)
2125 return ret;
2126 memset(&pll, 0, sizeof(struct dibx000_bandwidth_config));
2127
2128 dib0090_pwm_gain_reset(fe);
2129 /* dib0090_get_wbd_target is returning any possible
2130 temperature compensated wbd-target */
2131 target = (dib0090_get_wbd_target(fe) * 8 + 1) / 2;
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03002132 state->dib8000_ops.set_wbd_ref(fe, target);
Olivier Grenie88f3a352011-08-10 05:28:38 -03002133
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03002134 if (dib8096p_get_best_sampling(fe, &adc) == 0) {
2135 pll.pll_ratio = adc.pll_loopdiv;
2136 pll.pll_prediv = adc.pll_prediv;
Olivier Grenie88f3a352011-08-10 05:28:38 -03002137
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03002138 dib0700_set_i2c_speed(adap->dev, 200);
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03002139 state->dib8000_ops.update_pll(fe, &pll, fe->dtv_property_cache.bandwidth_hz / 1000, 0);
2140 state->dib8000_ops.ctrl_timf(fe, DEMOD_TIMF_SET, adc.timf);
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03002141 dib0700_set_i2c_speed(adap->dev, 1000);
Olivier Grenie88f3a352011-08-10 05:28:38 -03002142 }
2143 return 0;
2144}
2145
2146static int tfe8096p_frontend_attach(struct dvb_usb_adapter *adap)
2147{
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03002148 struct dib0700_state *st = adap->dev->priv;
2149 u32 fw_version;
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03002150 struct dib0700_adapter_state *state = adap->priv;
2151
2152 if (!dvb_attach(dib8000_attach, &state->dib8000_ops))
2153 return -ENODEV;
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03002154
2155 dib0700_get_version(adap->dev, NULL, NULL, &fw_version, NULL);
2156 if (fw_version >= 0x10200)
2157 st->fw_use_new_i2c_api = 1;
2158
Olivier Grenie88f3a352011-08-10 05:28:38 -03002159 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
2160 msleep(20);
2161 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
2162 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
2163 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
2164
2165 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
2166
2167 dib0700_ctrl_clock(adap->dev, 72, 1);
2168
2169 msleep(20);
2170 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
2171 msleep(20);
2172 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
2173
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03002174 state->dib8000_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 0x10, 0x80, 1);
Olivier Grenie88f3a352011-08-10 05:28:38 -03002175
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03002176 adap->fe_adap[0].fe = state->dib8000_ops.init(&adap->dev->i2c_adap,
2177 0x80, &tfe8096p_dib8000_config);
Olivier Grenie88f3a352011-08-10 05:28:38 -03002178
2179 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
2180}
2181
2182static int tfe8096p_tuner_attach(struct dvb_usb_adapter *adap)
2183{
2184 struct dib0700_adapter_state *st = adap->priv;
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03002185 struct i2c_adapter *tun_i2c = st->dib8000_ops.get_i2c_tuner(adap->fe_adap[0].fe);
2186
2187 tfe8096p_dib0090_config.reset = st->dib8000_ops.tuner_sleep;
2188 tfe8096p_dib0090_config.sleep = st->dib8000_ops.tuner_sleep;
2189 tfe8096p_dib0090_config.wbd = dib8096p_wbd_table;
Olivier Grenie88f3a352011-08-10 05:28:38 -03002190
2191 if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c,
2192 &tfe8096p_dib0090_config) == NULL)
2193 return -ENODEV;
2194
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03002195 st->dib8000_ops.set_gpio(adap->fe_adap[0].fe, 8, 0, 1);
Olivier Grenie88f3a352011-08-10 05:28:38 -03002196
2197 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
2198 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib8096p_agc_startup;
2199 return 0;
2200}
2201
Olivier Greniebe9bae12011-01-04 05:42:19 -03002202/* STK9090M */
2203static int dib90x0_pid_filter(struct dvb_usb_adapter *adapter, int index, u16 pid, int onoff)
2204{
Michael Krufky77eed212011-09-06 09:31:57 -03002205 return dib9000_fw_pid_filter(adapter->fe_adap[0].fe, index, pid, onoff);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002206}
2207
2208static int dib90x0_pid_filter_ctrl(struct dvb_usb_adapter *adapter, int onoff)
2209{
Michael Krufky77eed212011-09-06 09:31:57 -03002210 return dib9000_fw_pid_filter_ctrl(adapter->fe_adap[0].fe, onoff);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002211}
2212
2213static int dib90x0_tuner_reset(struct dvb_frontend *fe, int onoff)
2214{
2215 return dib9000_set_gpio(fe, 5, 0, !onoff);
2216}
2217
2218static int dib90x0_tuner_sleep(struct dvb_frontend *fe, int onoff)
2219{
2220 return dib9000_set_gpio(fe, 0, 0, onoff);
2221}
2222
2223static int dib01x0_pmu_update(struct i2c_adapter *i2c, u16 *data, u8 len)
2224{
2225 u8 wb[4] = { 0xc >> 8, 0xc & 0xff, 0, 0 };
2226 u8 rb[2];
2227 struct i2c_msg msg[2] = {
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002228 {.addr = 0x1e >> 1, .flags = 0, .buf = wb, .len = 2},
2229 {.addr = 0x1e >> 1, .flags = I2C_M_RD, .buf = rb, .len = 2},
Olivier Greniebe9bae12011-01-04 05:42:19 -03002230 };
2231 u8 index_data;
2232
2233 dibx000_i2c_set_speed(i2c, 250);
2234
2235 if (i2c_transfer(i2c, msg, 2) != 2)
2236 return -EIO;
2237
2238 switch (rb[0] << 8 | rb[1]) {
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002239 case 0:
Olivier Greniebe9bae12011-01-04 05:42:19 -03002240 deb_info("Found DiB0170 rev1: This version of DiB0170 is not supported any longer.\n");
2241 return -EIO;
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002242 case 1:
Olivier Greniebe9bae12011-01-04 05:42:19 -03002243 deb_info("Found DiB0170 rev2");
2244 break;
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002245 case 2:
Olivier Greniebe9bae12011-01-04 05:42:19 -03002246 deb_info("Found DiB0190 rev2");
2247 break;
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002248 default:
Olivier Greniebe9bae12011-01-04 05:42:19 -03002249 deb_info("DiB01x0 not found");
2250 return -EIO;
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002251 }
Olivier Greniebe9bae12011-01-04 05:42:19 -03002252
2253 for (index_data = 0; index_data < len; index_data += 2) {
2254 wb[2] = (data[index_data + 1] >> 8) & 0xff;
2255 wb[3] = (data[index_data + 1]) & 0xff;
2256
2257 if (data[index_data] == 0) {
2258 wb[0] = (data[index_data] >> 8) & 0xff;
2259 wb[1] = (data[index_data]) & 0xff;
2260 msg[0].len = 2;
2261 if (i2c_transfer(i2c, msg, 2) != 2)
2262 return -EIO;
2263 wb[2] |= rb[0];
2264 wb[3] |= rb[1] & ~(3 << 4);
2265 }
2266
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002267 wb[0] = (data[index_data] >> 8)&0xff;
2268 wb[1] = (data[index_data])&0xff;
Olivier Greniebe9bae12011-01-04 05:42:19 -03002269 msg[0].len = 4;
2270 if (i2c_transfer(i2c, &msg[0], 1) != 1)
2271 return -EIO;
2272 }
2273 return 0;
2274}
2275
2276static struct dib9000_config stk9090m_config = {
2277 .output_mpeg2_in_188_bytes = 1,
2278 .output_mode = OUTMODE_MPEG2_FIFO,
2279 .vcxo_timer = 279620,
2280 .timing_frequency = 20452225,
2281 .demod_clock_khz = 60000,
2282 .xtal_clock_khz = 30000,
2283 .if_drives = (0 << 15) | (1 << 13) | (0 << 12) | (3 << 10) | (0 << 9) | (1 << 7) | (0 << 6) | (0 << 4) | (1 << 3) | (1 << 1) | (0),
2284 .subband = {
2285 2,
2286 {
2287 { 240, { BOARD_GPIO_COMPONENT_DEMOD, BOARD_GPIO_FUNCTION_SUBBAND_GPIO, 0x0008, 0x0000, 0x0008 } }, /* GPIO 3 to 1 for VHF */
2288 { 890, { BOARD_GPIO_COMPONENT_DEMOD, BOARD_GPIO_FUNCTION_SUBBAND_GPIO, 0x0008, 0x0000, 0x0000 } }, /* GPIO 3 to 0 for UHF */
2289 { 0 },
2290 },
2291 },
2292 .gpio_function = {
2293 { .component = BOARD_GPIO_COMPONENT_DEMOD, .function = BOARD_GPIO_FUNCTION_COMPONENT_ON, .mask = 0x10 | 0x21, .direction = 0 & ~0x21, .value = (0x10 & ~0x1) | 0x20 },
2294 { .component = BOARD_GPIO_COMPONENT_DEMOD, .function = BOARD_GPIO_FUNCTION_COMPONENT_OFF, .mask = 0x10 | 0x21, .direction = 0 & ~0x21, .value = 0 | 0x21 },
2295 },
2296};
2297
2298static struct dib9000_config nim9090md_config[2] = {
2299 {
2300 .output_mpeg2_in_188_bytes = 1,
2301 .output_mode = OUTMODE_MPEG2_FIFO,
2302 .vcxo_timer = 279620,
2303 .timing_frequency = 20452225,
2304 .demod_clock_khz = 60000,
2305 .xtal_clock_khz = 30000,
2306 .if_drives = (0 << 15) | (1 << 13) | (0 << 12) | (3 << 10) | (0 << 9) | (1 << 7) | (0 << 6) | (0 << 4) | (1 << 3) | (1 << 1) | (0),
2307 }, {
2308 .output_mpeg2_in_188_bytes = 1,
2309 .output_mode = OUTMODE_DIVERSITY,
2310 .vcxo_timer = 279620,
2311 .timing_frequency = 20452225,
2312 .demod_clock_khz = 60000,
2313 .xtal_clock_khz = 30000,
2314 .if_drives = (0 << 15) | (1 << 13) | (0 << 12) | (3 << 10) | (0 << 9) | (1 << 7) | (0 << 6) | (0 << 4) | (1 << 3) | (1 << 1) | (0),
2315 .subband = {
2316 2,
2317 {
2318 { 240, { BOARD_GPIO_COMPONENT_DEMOD, BOARD_GPIO_FUNCTION_SUBBAND_GPIO, 0x0006, 0x0000, 0x0006 } }, /* GPIO 1 and 2 to 1 for VHF */
2319 { 890, { BOARD_GPIO_COMPONENT_DEMOD, BOARD_GPIO_FUNCTION_SUBBAND_GPIO, 0x0006, 0x0000, 0x0000 } }, /* GPIO 1 and 2 to 0 for UHF */
2320 { 0 },
2321 },
2322 },
2323 .gpio_function = {
2324 { .component = BOARD_GPIO_COMPONENT_DEMOD, .function = BOARD_GPIO_FUNCTION_COMPONENT_ON, .mask = 0x10 | 0x21, .direction = 0 & ~0x21, .value = (0x10 & ~0x1) | 0x20 },
2325 { .component = BOARD_GPIO_COMPONENT_DEMOD, .function = BOARD_GPIO_FUNCTION_COMPONENT_OFF, .mask = 0x10 | 0x21, .direction = 0 & ~0x21, .value = 0 | 0x21 },
2326 },
2327 }
2328};
2329
2330static struct dib0090_config dib9090_dib0090_config = {
2331 .io.pll_bypass = 0,
2332 .io.pll_range = 1,
2333 .io.pll_prediv = 1,
2334 .io.pll_loopdiv = 8,
2335 .io.adc_clock_ratio = 8,
2336 .io.pll_int_loop_filt = 0,
2337 .io.clock_khz = 30000,
2338 .reset = dib90x0_tuner_reset,
2339 .sleep = dib90x0_tuner_sleep,
2340 .clkouttobamse = 0,
2341 .analog_output = 0,
2342 .use_pwm_agc = 0,
2343 .clkoutdrive = 0,
2344 .freq_offset_khz_uhf = 0,
2345 .freq_offset_khz_vhf = 0,
2346};
2347
2348static struct dib0090_config nim9090md_dib0090_config[2] = {
2349 {
2350 .io.pll_bypass = 0,
2351 .io.pll_range = 1,
2352 .io.pll_prediv = 1,
2353 .io.pll_loopdiv = 8,
2354 .io.adc_clock_ratio = 8,
2355 .io.pll_int_loop_filt = 0,
2356 .io.clock_khz = 30000,
2357 .reset = dib90x0_tuner_reset,
2358 .sleep = dib90x0_tuner_sleep,
2359 .clkouttobamse = 1,
2360 .analog_output = 0,
2361 .use_pwm_agc = 0,
2362 .clkoutdrive = 0,
2363 .freq_offset_khz_uhf = 0,
2364 .freq_offset_khz_vhf = 0,
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002365 }, {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002366 .io.pll_bypass = 0,
2367 .io.pll_range = 1,
2368 .io.pll_prediv = 1,
2369 .io.pll_loopdiv = 8,
2370 .io.adc_clock_ratio = 8,
2371 .io.pll_int_loop_filt = 0,
2372 .io.clock_khz = 30000,
2373 .reset = dib90x0_tuner_reset,
2374 .sleep = dib90x0_tuner_sleep,
2375 .clkouttobamse = 0,
2376 .analog_output = 0,
2377 .use_pwm_agc = 0,
2378 .clkoutdrive = 0,
2379 .freq_offset_khz_uhf = 0,
2380 .freq_offset_khz_vhf = 0,
2381 }
2382};
2383
2384
2385static int stk9090m_frontend_attach(struct dvb_usb_adapter *adap)
2386{
2387 struct dib0700_adapter_state *state = adap->priv;
2388 struct dib0700_state *st = adap->dev->priv;
2389 u32 fw_version;
2390
2391 /* Make use of the new i2c functions from FW 1.20 */
2392 dib0700_get_version(adap->dev, NULL, NULL, &fw_version, NULL);
2393 if (fw_version >= 0x10200)
2394 st->fw_use_new_i2c_api = 1;
2395 dib0700_set_i2c_speed(adap->dev, 340);
2396
2397 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002398 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002399 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
2400 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
2401 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
2402 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
2403
2404 dib0700_ctrl_clock(adap->dev, 72, 1);
2405
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002406 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002407 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002408 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002409 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
2410
2411 dib9000_i2c_enumeration(&adap->dev->i2c_adap, 1, 0x10, 0x80);
2412
2413 if (request_firmware(&state->frontend_firmware, "dib9090.fw", &adap->dev->udev->dev)) {
2414 deb_info("%s: Upload failed. (file not found?)\n", __func__);
2415 return -ENODEV;
2416 } else {
Alexey Dobriyan5b5e0922017-02-27 14:30:02 -08002417 deb_info("%s: firmware read %zu bytes.\n", __func__, state->frontend_firmware->size);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002418 }
2419 stk9090m_config.microcode_B_fe_size = state->frontend_firmware->size;
2420 stk9090m_config.microcode_B_fe_buffer = state->frontend_firmware->data;
2421
Michael Krufky77eed212011-09-06 09:31:57 -03002422 adap->fe_adap[0].fe = dvb_attach(dib9000_attach, &adap->dev->i2c_adap, 0x80, &stk9090m_config);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002423
Michael Krufky77eed212011-09-06 09:31:57 -03002424 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Olivier Greniebe9bae12011-01-04 05:42:19 -03002425}
2426
2427static int dib9090_tuner_attach(struct dvb_usb_adapter *adap)
2428{
2429 struct dib0700_adapter_state *state = adap->priv;
Michael Krufky77eed212011-09-06 09:31:57 -03002430 struct i2c_adapter *i2c = dib9000_get_tuner_interface(adap->fe_adap[0].fe);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002431 u16 data_dib190[10] = {
2432 1, 0x1374,
2433 2, 0x01a2,
2434 7, 0x0020,
2435 0, 0x00ef,
2436 8, 0x0486,
2437 };
2438
Michael Krufky77eed212011-09-06 09:31:57 -03002439 if (dvb_attach(dib0090_fw_register, adap->fe_adap[0].fe, i2c, &dib9090_dib0090_config) == NULL)
Olivier Greniebe9bae12011-01-04 05:42:19 -03002440 return -ENODEV;
Michael Krufky77eed212011-09-06 09:31:57 -03002441 i2c = dib9000_get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_GPIO_1_2, 0);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002442 if (dib01x0_pmu_update(i2c, data_dib190, 10) != 0)
2443 return -ENODEV;
Olivier Grenied1190022011-08-29 10:58:47 -03002444 dib0700_set_i2c_speed(adap->dev, 1500);
Michael Krufky77eed212011-09-06 09:31:57 -03002445 if (dib9000_firmware_post_pll_init(adap->fe_adap[0].fe) < 0)
Olivier Greniebe9bae12011-01-04 05:42:19 -03002446 return -ENODEV;
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002447 release_firmware(state->frontend_firmware);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002448 return 0;
2449}
2450
2451static int nim9090md_frontend_attach(struct dvb_usb_adapter *adap)
2452{
2453 struct dib0700_adapter_state *state = adap->priv;
2454 struct dib0700_state *st = adap->dev->priv;
2455 struct i2c_adapter *i2c;
2456 struct dvb_frontend *fe_slave;
2457 u32 fw_version;
2458
2459 /* Make use of the new i2c functions from FW 1.20 */
2460 dib0700_get_version(adap->dev, NULL, NULL, &fw_version, NULL);
2461 if (fw_version >= 0x10200)
2462 st->fw_use_new_i2c_api = 1;
2463 dib0700_set_i2c_speed(adap->dev, 340);
2464
2465 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002466 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002467 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
2468 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
2469 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
2470 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
2471
2472 dib0700_ctrl_clock(adap->dev, 72, 1);
2473
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002474 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002475 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002476 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002477 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
2478
2479 if (request_firmware(&state->frontend_firmware, "dib9090.fw", &adap->dev->udev->dev)) {
2480 deb_info("%s: Upload failed. (file not found?)\n", __func__);
2481 return -EIO;
2482 } else {
Alexey Dobriyan5b5e0922017-02-27 14:30:02 -08002483 deb_info("%s: firmware read %zu bytes.\n", __func__, state->frontend_firmware->size);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002484 }
2485 nim9090md_config[0].microcode_B_fe_size = state->frontend_firmware->size;
2486 nim9090md_config[0].microcode_B_fe_buffer = state->frontend_firmware->data;
2487 nim9090md_config[1].microcode_B_fe_size = state->frontend_firmware->size;
2488 nim9090md_config[1].microcode_B_fe_buffer = state->frontend_firmware->data;
2489
2490 dib9000_i2c_enumeration(&adap->dev->i2c_adap, 1, 0x20, 0x80);
Michael Krufky77eed212011-09-06 09:31:57 -03002491 adap->fe_adap[0].fe = dvb_attach(dib9000_attach, &adap->dev->i2c_adap, 0x80, &nim9090md_config[0]);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002492
Michael Krufky77eed212011-09-06 09:31:57 -03002493 if (adap->fe_adap[0].fe == NULL)
Olivier Greniebe9bae12011-01-04 05:42:19 -03002494 return -ENODEV;
2495
Michael Krufky77eed212011-09-06 09:31:57 -03002496 i2c = dib9000_get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_GPIO_3_4, 0);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002497 dib9000_i2c_enumeration(i2c, 1, 0x12, 0x82);
2498
2499 fe_slave = dvb_attach(dib9000_attach, i2c, 0x82, &nim9090md_config[1]);
Michael Krufky77eed212011-09-06 09:31:57 -03002500 dib9000_set_slave_frontend(adap->fe_adap[0].fe, fe_slave);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002501
2502 return fe_slave == NULL ? -ENODEV : 0;
2503}
2504
2505static int nim9090md_tuner_attach(struct dvb_usb_adapter *adap)
2506{
2507 struct dib0700_adapter_state *state = adap->priv;
2508 struct i2c_adapter *i2c;
2509 struct dvb_frontend *fe_slave;
2510 u16 data_dib190[10] = {
2511 1, 0x5374,
2512 2, 0x01ae,
2513 7, 0x0020,
2514 0, 0x00ef,
2515 8, 0x0406,
2516 };
Michael Krufky77eed212011-09-06 09:31:57 -03002517 i2c = dib9000_get_tuner_interface(adap->fe_adap[0].fe);
2518 if (dvb_attach(dib0090_fw_register, adap->fe_adap[0].fe, i2c, &nim9090md_dib0090_config[0]) == NULL)
Olivier Greniebe9bae12011-01-04 05:42:19 -03002519 return -ENODEV;
Michael Krufky77eed212011-09-06 09:31:57 -03002520 i2c = dib9000_get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_GPIO_1_2, 0);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002521 if (dib01x0_pmu_update(i2c, data_dib190, 10) < 0)
2522 return -ENODEV;
Olivier Grenied1190022011-08-29 10:58:47 -03002523
2524 dib0700_set_i2c_speed(adap->dev, 1500);
Michael Krufky77eed212011-09-06 09:31:57 -03002525 if (dib9000_firmware_post_pll_init(adap->fe_adap[0].fe) < 0)
Olivier Greniebe9bae12011-01-04 05:42:19 -03002526 return -ENODEV;
2527
Michael Krufky77eed212011-09-06 09:31:57 -03002528 fe_slave = dib9000_get_slave_frontend(adap->fe_adap[0].fe, 1);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002529 if (fe_slave != NULL) {
Michael Krufky77eed212011-09-06 09:31:57 -03002530 i2c = dib9000_get_component_bus_interface(adap->fe_adap[0].fe);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002531 dib9000_set_i2c_adapter(fe_slave, i2c);
2532
2533 i2c = dib9000_get_tuner_interface(fe_slave);
2534 if (dvb_attach(dib0090_fw_register, fe_slave, i2c, &nim9090md_dib0090_config[1]) == NULL)
2535 return -ENODEV;
Michael Krufky77eed212011-09-06 09:31:57 -03002536 fe_slave->dvb = adap->fe_adap[0].fe->dvb;
Olivier Grenied1190022011-08-29 10:58:47 -03002537 dib9000_fw_set_component_bus_speed(adap->fe_adap[0].fe, 1500);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002538 if (dib9000_firmware_post_pll_init(fe_slave) < 0)
2539 return -ENODEV;
2540 }
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002541 release_firmware(state->frontend_firmware);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002542
2543 return 0;
2544}
2545
2546/* NIM7090 */
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03002547static int dib7090p_get_best_sampling(struct dvb_frontend *fe , struct dibx090p_best_adc *adc)
Olivier Greniebe9bae12011-01-04 05:42:19 -03002548{
2549 u8 spur = 0, prediv = 0, loopdiv = 0, min_prediv = 1, max_prediv = 1;
2550
2551 u16 xtal = 12000;
2552 u32 fcp_min = 1900; /* PLL Minimum Frequency comparator KHz */
2553 u32 fcp_max = 20000; /* PLL Maximum Frequency comparator KHz */
2554 u32 fdem_max = 76000;
2555 u32 fdem_min = 69500;
2556 u32 fcp = 0, fs = 0, fdem = 0;
2557 u32 harmonic_id = 0;
2558
2559 adc->pll_loopdiv = loopdiv;
2560 adc->pll_prediv = prediv;
2561 adc->timf = 0;
2562
2563 deb_info("bandwidth = %d fdem_min =%d", fe->dtv_property_cache.bandwidth_hz, fdem_min);
2564
2565 /* Find Min and Max prediv */
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002566 while ((xtal/max_prediv) >= fcp_min)
Olivier Greniebe9bae12011-01-04 05:42:19 -03002567 max_prediv++;
2568
2569 max_prediv--;
2570 min_prediv = max_prediv;
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002571 while ((xtal/min_prediv) <= fcp_max) {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002572 min_prediv--;
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002573 if (min_prediv == 1)
Olivier Greniebe9bae12011-01-04 05:42:19 -03002574 break;
2575 }
2576 deb_info("MIN prediv = %d : MAX prediv = %d", min_prediv, max_prediv);
2577
2578 min_prediv = 2;
2579
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002580 for (prediv = min_prediv ; prediv < max_prediv; prediv++) {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002581 fcp = xtal / prediv;
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002582 if (fcp > fcp_min && fcp < fcp_max) {
2583 for (loopdiv = 1 ; loopdiv < 64 ; loopdiv++) {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002584 fdem = ((xtal/prediv) * loopdiv);
2585 fs = fdem / 4;
2586 /* test min/max system restrictions */
2587
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002588 if ((fdem >= fdem_min) && (fdem <= fdem_max) && (fs >= fe->dtv_property_cache.bandwidth_hz/1000)) {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002589 spur = 0;
2590 /* test fs harmonics positions */
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002591 for (harmonic_id = (fe->dtv_property_cache.frequency / (1000*fs)) ; harmonic_id <= ((fe->dtv_property_cache.frequency / (1000*fs))+1) ; harmonic_id++) {
2592 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 -03002593 spur = 1;
2594 break;
2595 }
2596 }
2597
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002598 if (!spur) {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002599 adc->pll_loopdiv = loopdiv;
2600 adc->pll_prediv = prediv;
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002601 adc->timf = 2396745143UL/fdem*(1 << 9);
2602 adc->timf += ((2396745143UL%fdem) << 9)/fdem;
Olivier Greniebe9bae12011-01-04 05:42:19 -03002603 deb_info("loopdiv=%i prediv=%i timf=%i", loopdiv, prediv, adc->timf);
2604 break;
2605 }
2606 }
2607 }
2608 }
2609 if (!spur)
2610 break;
2611 }
2612
2613
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002614 if (adc->pll_loopdiv == 0 && adc->pll_prediv == 0)
Olivier Greniebe9bae12011-01-04 05:42:19 -03002615 return -EINVAL;
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002616 else
Olivier Greniebe9bae12011-01-04 05:42:19 -03002617 return 0;
2618}
2619
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -03002620static int dib7090_agc_startup(struct dvb_frontend *fe)
Olivier Greniebe9bae12011-01-04 05:42:19 -03002621{
2622 struct dvb_usb_adapter *adap = fe->dvb->priv;
2623 struct dib0700_adapter_state *state = adap->priv;
2624 struct dibx000_bandwidth_config pll;
2625 u16 target;
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03002626 struct dibx090p_best_adc adc;
Olivier Greniebe9bae12011-01-04 05:42:19 -03002627 int ret;
2628
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -03002629 ret = state->set_param_save(fe);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002630 if (ret < 0)
2631 return ret;
2632
2633 memset(&pll, 0, sizeof(struct dibx000_bandwidth_config));
2634 dib0090_pwm_gain_reset(fe);
Olivier Grenie6724a2f2011-08-05 13:49:33 -03002635 target = (dib0090_get_wbd_target(fe) * 8 + 1) / 2;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03002636 state->dib7000p_ops.set_wbd_ref(fe, target);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002637
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002638 if (dib7090p_get_best_sampling(fe, &adc) == 0) {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002639 pll.pll_ratio = adc.pll_loopdiv;
2640 pll.pll_prediv = adc.pll_prediv;
2641
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03002642 state->dib7000p_ops.update_pll(fe, &pll);
2643 state->dib7000p_ops.ctrl_timf(fe, DEMOD_TIMF_SET, adc.timf);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002644 }
2645 return 0;
2646}
2647
Olivier Grenie2e802862011-08-05 10:39:15 -03002648static int dib7090_agc_restart(struct dvb_frontend *fe, u8 restart)
2649{
2650 deb_info("AGC restart callback: %d", restart);
2651 if (restart == 0) /* before AGC startup */
2652 dib0090_set_dc_servo(fe, 1);
2653 return 0;
2654}
2655
Olivier Grenief45f5132012-12-31 09:47:10 -03002656static int tfe7790p_update_lna(struct dvb_frontend *fe, u16 agc_global)
Olivier Grenie6724a2f2011-08-05 13:49:33 -03002657{
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03002658 struct dvb_usb_adapter *adap = fe->dvb->priv;
2659 struct dib0700_adapter_state *state = adap->priv;
2660
Olivier Grenief45f5132012-12-31 09:47:10 -03002661 deb_info("update LNA: agc global=%i", agc_global);
Olivier Grenie6724a2f2011-08-05 13:49:33 -03002662
Olivier Grenief45f5132012-12-31 09:47:10 -03002663 if (agc_global < 25000) {
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03002664 state->dib7000p_ops.set_gpio(fe, 8, 0, 0);
2665 state->dib7000p_ops.set_agc1_min(fe, 0);
Olivier Grenie6724a2f2011-08-05 13:49:33 -03002666 } else {
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03002667 state->dib7000p_ops.set_gpio(fe, 8, 0, 1);
2668 state->dib7000p_ops.set_agc1_min(fe, 32768);
Olivier Grenie6724a2f2011-08-05 13:49:33 -03002669 }
2670
2671 return 0;
2672}
2673
Olivier Greniebe9bae12011-01-04 05:42:19 -03002674static struct dib0090_wbd_slope dib7090_wbd_table[] = {
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002675 { 380, 81, 850, 64, 540, 4},
2676 { 860, 51, 866, 21, 375, 4},
2677 {1700, 0, 250, 0, 100, 6},
2678 {2600, 0, 250, 0, 100, 6},
2679 { 0xFFFF, 0, 0, 0, 0, 0},
Olivier Greniebe9bae12011-01-04 05:42:19 -03002680};
2681
Olivier Greniea685dbb2011-08-05 14:10:40 -03002682static struct dibx000_agc_config dib7090_agc_config[2] = {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002683 {
2684 .band_caps = BAND_UHF,
2685 /* 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,
2686 * 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 -03002687 .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 -03002688
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002689 .inv_gain = 687,
2690 .time_stabiliz = 10,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002691
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002692 .alpha_level = 0,
2693 .thlock = 118,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002694
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002695 .wbd_inv = 0,
2696 .wbd_ref = 1200,
2697 .wbd_sel = 3,
2698 .wbd_alpha = 5,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002699
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002700 .agc1_max = 65535,
Olivier Grenie59501bb2012-12-31 09:51:17 -03002701 .agc1_min = 32768,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002702
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002703 .agc2_max = 65535,
2704 .agc2_min = 0,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002705
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002706 .agc1_pt1 = 0,
2707 .agc1_pt2 = 32,
2708 .agc1_pt3 = 114,
2709 .agc1_slope1 = 143,
2710 .agc1_slope2 = 144,
2711 .agc2_pt1 = 114,
2712 .agc2_pt2 = 227,
2713 .agc2_slope1 = 116,
2714 .agc2_slope2 = 117,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002715
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002716 .alpha_mant = 18,
2717 .alpha_exp = 0,
2718 .beta_mant = 20,
2719 .beta_exp = 59,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002720
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002721 .perform_agc_softsplit = 0,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002722 } , {
2723 .band_caps = BAND_FM | BAND_VHF | BAND_CBAND,
2724 /* 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,
2725 * 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 -03002726 .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 -03002727
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002728 .inv_gain = 732,
2729 .time_stabiliz = 10,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002730
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002731 .alpha_level = 0,
2732 .thlock = 118,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002733
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002734 .wbd_inv = 0,
2735 .wbd_ref = 1200,
2736 .wbd_sel = 3,
2737 .wbd_alpha = 5,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002738
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002739 .agc1_max = 65535,
2740 .agc1_min = 0,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002741
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002742 .agc2_max = 65535,
2743 .agc2_min = 0,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002744
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002745 .agc1_pt1 = 0,
2746 .agc1_pt2 = 0,
2747 .agc1_pt3 = 98,
2748 .agc1_slope1 = 0,
2749 .agc1_slope2 = 167,
Patrick Boettcher7f4d5272011-04-03 12:28:08 -03002750 .agc2_pt1 = 98,
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002751 .agc2_pt2 = 255,
2752 .agc2_slope1 = 104,
2753 .agc2_slope2 = 0,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002754
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002755 .alpha_mant = 18,
2756 .alpha_exp = 0,
2757 .beta_mant = 20,
2758 .beta_exp = 59,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002759
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002760 .perform_agc_softsplit = 0,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002761 }
2762};
2763
2764static struct dibx000_bandwidth_config dib7090_clock_config_12_mhz = {
Mauro Carvalho Chehab09628b22014-09-22 18:57:45 -03002765 .internal = 60000,
2766 .sampling = 15000,
2767 .pll_prediv = 1,
2768 .pll_ratio = 5,
2769 .pll_range = 0,
2770 .pll_reset = 0,
2771 .pll_bypass = 0,
2772 .enable_refdiv = 0,
2773 .bypclk_div = 0,
2774 .IO_CLK_en_core = 1,
2775 .ADClkSrc = 1,
2776 .modulo = 2,
2777 .sad_cfg = (3 << 14) | (1 << 12) | (524 << 0),
2778 .ifreq = (0 << 25) | 0,
2779 .timf = 20452225,
2780 .xtal_hz = 15000000,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002781};
2782
2783static struct dib7000p_config nim7090_dib7000p_config = {
2784 .output_mpeg2_in_188_bytes = 1,
2785 .hostbus_diversity = 1,
2786 .tuner_is_baseband = 1,
Olivier Grenie59501bb2012-12-31 09:51:17 -03002787 .update_lna = tfe7790p_update_lna, /* GPIO used is the same as TFE7790 */
Olivier Greniebe9bae12011-01-04 05:42:19 -03002788
2789 .agc_config_count = 2,
2790 .agc = dib7090_agc_config,
2791
2792 .bw = &dib7090_clock_config_12_mhz,
2793
2794 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
2795 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
2796 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
2797
2798 .pwm_freq_div = 0,
2799
2800 .agc_control = dib7090_agc_restart,
2801
2802 .spur_protect = 0,
2803 .disable_sample_and_hold = 0,
2804 .enable_current_mirror = 0,
2805 .diversity_delay = 0,
2806
2807 .output_mode = OUTMODE_MPEG2_FIFO,
2808 .enMpegOutput = 1,
2809};
2810
Olivier Grenie59501bb2012-12-31 09:51:17 -03002811static int tfe7090p_pvr_update_lna(struct dvb_frontend *fe, u16 agc_global)
2812{
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03002813 struct dvb_usb_adapter *adap = fe->dvb->priv;
2814 struct dib0700_adapter_state *state = adap->priv;
2815
Olivier Grenie59501bb2012-12-31 09:51:17 -03002816 deb_info("TFE7090P-PVR update LNA: agc global=%i", agc_global);
2817 if (agc_global < 25000) {
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03002818 state->dib7000p_ops.set_gpio(fe, 5, 0, 0);
2819 state->dib7000p_ops.set_agc1_min(fe, 0);
Olivier Grenie59501bb2012-12-31 09:51:17 -03002820 } else {
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03002821 state->dib7000p_ops.set_gpio(fe, 5, 0, 1);
2822 state->dib7000p_ops.set_agc1_min(fe, 32768);
Olivier Grenie59501bb2012-12-31 09:51:17 -03002823 }
2824
2825 return 0;
2826}
2827
Olivier Greniebe9bae12011-01-04 05:42:19 -03002828static struct dib7000p_config tfe7090pvr_dib7000p_config[2] = {
2829 {
2830 .output_mpeg2_in_188_bytes = 1,
2831 .hostbus_diversity = 1,
2832 .tuner_is_baseband = 1,
Olivier Grenie59501bb2012-12-31 09:51:17 -03002833 .update_lna = tfe7090p_pvr_update_lna,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002834
2835 .agc_config_count = 2,
2836 .agc = dib7090_agc_config,
2837
2838 .bw = &dib7090_clock_config_12_mhz,
2839
2840 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
2841 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
2842 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
2843
2844 .pwm_freq_div = 0,
2845
2846 .agc_control = dib7090_agc_restart,
2847
2848 .spur_protect = 0,
2849 .disable_sample_and_hold = 0,
2850 .enable_current_mirror = 0,
2851 .diversity_delay = 0,
2852
2853 .output_mode = OUTMODE_MPEG2_PAR_GATED_CLK,
2854 .default_i2c_addr = 0x90,
2855 .enMpegOutput = 1,
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002856 }, {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002857 .output_mpeg2_in_188_bytes = 1,
2858 .hostbus_diversity = 1,
2859 .tuner_is_baseband = 1,
Olivier Grenie59501bb2012-12-31 09:51:17 -03002860 .update_lna = tfe7090p_pvr_update_lna,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002861
2862 .agc_config_count = 2,
2863 .agc = dib7090_agc_config,
2864
2865 .bw = &dib7090_clock_config_12_mhz,
2866
2867 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
2868 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
2869 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
2870
2871 .pwm_freq_div = 0,
2872
2873 .agc_control = dib7090_agc_restart,
2874
2875 .spur_protect = 0,
2876 .disable_sample_and_hold = 0,
2877 .enable_current_mirror = 0,
2878 .diversity_delay = 0,
2879
2880 .output_mode = OUTMODE_MPEG2_PAR_GATED_CLK,
2881 .default_i2c_addr = 0x92,
2882 .enMpegOutput = 0,
2883 }
2884};
2885
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03002886static struct dib0090_config nim7090_dib0090_config = {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002887 .io.clock_khz = 12000,
2888 .io.pll_bypass = 0,
2889 .io.pll_range = 0,
2890 .io.pll_prediv = 3,
2891 .io.pll_loopdiv = 6,
2892 .io.adc_clock_ratio = 0,
2893 .io.pll_int_loop_filt = 0,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002894
2895 .freq_offset_khz_uhf = 0,
2896 .freq_offset_khz_vhf = 0,
2897
Olivier Greniebe9bae12011-01-04 05:42:19 -03002898 .clkouttobamse = 1,
2899 .analog_output = 0,
2900
2901 .wbd_vhf_offset = 0,
2902 .wbd_cband_offset = 0,
2903 .use_pwm_agc = 1,
2904 .clkoutdrive = 0,
2905
2906 .fref_clock_ratio = 0,
2907
2908 .wbd = dib7090_wbd_table,
2909
2910 .ls_cfg_pad_drv = 0,
2911 .data_tx_drv = 0,
2912 .low_if = NULL,
2913 .in_soc = 1,
2914};
2915
Olivier Grenief45f5132012-12-31 09:47:10 -03002916static struct dib7000p_config tfe7790p_dib7000p_config = {
Olivier Grenieb293f302011-08-09 04:48:25 -03002917 .output_mpeg2_in_188_bytes = 1,
2918 .hostbus_diversity = 1,
2919 .tuner_is_baseband = 1,
Olivier Grenief45f5132012-12-31 09:47:10 -03002920 .update_lna = tfe7790p_update_lna,
Olivier Grenieb293f302011-08-09 04:48:25 -03002921
2922 .agc_config_count = 2,
2923 .agc = dib7090_agc_config,
2924
2925 .bw = &dib7090_clock_config_12_mhz,
2926
2927 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
2928 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
2929 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
2930
2931 .pwm_freq_div = 0,
2932
2933 .agc_control = dib7090_agc_restart,
2934
2935 .spur_protect = 0,
2936 .disable_sample_and_hold = 0,
2937 .enable_current_mirror = 0,
2938 .diversity_delay = 0,
2939
2940 .output_mode = OUTMODE_MPEG2_PAR_GATED_CLK,
2941 .enMpegOutput = 1,
2942};
2943
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03002944static struct dib0090_config tfe7790p_dib0090_config = {
Olivier Grenieb293f302011-08-09 04:48:25 -03002945 .io.clock_khz = 12000,
2946 .io.pll_bypass = 0,
2947 .io.pll_range = 0,
2948 .io.pll_prediv = 3,
2949 .io.pll_loopdiv = 6,
2950 .io.adc_clock_ratio = 0,
2951 .io.pll_int_loop_filt = 0,
Olivier Grenieb293f302011-08-09 04:48:25 -03002952
2953 .freq_offset_khz_uhf = 0,
2954 .freq_offset_khz_vhf = 0,
2955
Olivier Grenieb293f302011-08-09 04:48:25 -03002956 .clkouttobamse = 1,
2957 .analog_output = 0,
2958
2959 .wbd_vhf_offset = 0,
2960 .wbd_cband_offset = 0,
2961 .use_pwm_agc = 1,
2962 .clkoutdrive = 0,
2963
2964 .fref_clock_ratio = 0,
2965
Olivier Grenief45f5132012-12-31 09:47:10 -03002966 .wbd = dib7090_wbd_table,
Olivier Grenieb293f302011-08-09 04:48:25 -03002967
2968 .ls_cfg_pad_drv = 0,
2969 .data_tx_drv = 0,
2970 .low_if = NULL,
2971 .in_soc = 1,
Olivier Grenief45f5132012-12-31 09:47:10 -03002972 .force_cband_input = 0,
2973 .is_dib7090e = 0,
Olivier Grenieb293f302011-08-09 04:48:25 -03002974 .force_crystal_mode = 1,
2975};
2976
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03002977static struct dib0090_config tfe7090pvr_dib0090_config[2] = {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002978 {
2979 .io.clock_khz = 12000,
2980 .io.pll_bypass = 0,
2981 .io.pll_range = 0,
2982 .io.pll_prediv = 3,
2983 .io.pll_loopdiv = 6,
2984 .io.adc_clock_ratio = 0,
2985 .io.pll_int_loop_filt = 0,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002986
2987 .freq_offset_khz_uhf = 50,
2988 .freq_offset_khz_vhf = 70,
2989
Olivier Greniebe9bae12011-01-04 05:42:19 -03002990 .clkouttobamse = 1,
2991 .analog_output = 0,
2992
2993 .wbd_vhf_offset = 0,
2994 .wbd_cband_offset = 0,
2995 .use_pwm_agc = 1,
2996 .clkoutdrive = 0,
2997
2998 .fref_clock_ratio = 0,
2999
3000 .wbd = dib7090_wbd_table,
3001
3002 .ls_cfg_pad_drv = 0,
3003 .data_tx_drv = 0,
3004 .low_if = NULL,
3005 .in_soc = 1,
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03003006 }, {
Olivier Greniebe9bae12011-01-04 05:42:19 -03003007 .io.clock_khz = 12000,
3008 .io.pll_bypass = 0,
3009 .io.pll_range = 0,
3010 .io.pll_prediv = 3,
3011 .io.pll_loopdiv = 6,
3012 .io.adc_clock_ratio = 0,
3013 .io.pll_int_loop_filt = 0,
Olivier Greniebe9bae12011-01-04 05:42:19 -03003014
3015 .freq_offset_khz_uhf = -50,
3016 .freq_offset_khz_vhf = -70,
3017
Olivier Greniebe9bae12011-01-04 05:42:19 -03003018 .clkouttobamse = 1,
3019 .analog_output = 0,
3020
3021 .wbd_vhf_offset = 0,
3022 .wbd_cband_offset = 0,
3023 .use_pwm_agc = 1,
3024 .clkoutdrive = 0,
3025
3026 .fref_clock_ratio = 0,
3027
3028 .wbd = dib7090_wbd_table,
3029
3030 .ls_cfg_pad_drv = 0,
3031 .data_tx_drv = 0,
3032 .low_if = NULL,
3033 .in_soc = 1,
3034 }
3035};
3036
3037static int nim7090_frontend_attach(struct dvb_usb_adapter *adap)
3038{
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003039 struct dib0700_adapter_state *state = adap->priv;
3040
3041 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
3042 return -ENODEV;
3043
Olivier Greniebe9bae12011-01-04 05:42:19 -03003044 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03003045 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03003046 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
3047 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
3048 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
3049 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
3050
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03003051 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03003052 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03003053 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03003054 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
3055
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003056 if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 0x10, &nim7090_dib7000p_config) != 0) {
3057 err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n", __func__);
3058 dvb_detach(&state->dib7000p_ops);
Olivier Greniebe9bae12011-01-04 05:42:19 -03003059 return -ENODEV;
3060 }
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003061 adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap, 0x80, &nim7090_dib7000p_config);
Olivier Greniebe9bae12011-01-04 05:42:19 -03003062
Michael Krufky77eed212011-09-06 09:31:57 -03003063 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Olivier Greniebe9bae12011-01-04 05:42:19 -03003064}
3065
3066static int nim7090_tuner_attach(struct dvb_usb_adapter *adap)
3067{
3068 struct dib0700_adapter_state *st = adap->priv;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003069 struct i2c_adapter *tun_i2c = st->dib7000p_ops.get_i2c_tuner(adap->fe_adap[0].fe);
3070
3071 nim7090_dib0090_config.reset = st->dib7000p_ops.tuner_sleep,
3072 nim7090_dib0090_config.sleep = st->dib7000p_ops.tuner_sleep,
3073 nim7090_dib0090_config.get_adc_power = st->dib7000p_ops.get_adc_power;
Olivier Greniebe9bae12011-01-04 05:42:19 -03003074
Michael Krufky77eed212011-09-06 09:31:57 -03003075 if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c, &nim7090_dib0090_config) == NULL)
Olivier Greniebe9bae12011-01-04 05:42:19 -03003076 return -ENODEV;
3077
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003078 st->dib7000p_ops.set_gpio(adap->fe_adap[0].fe, 8, 0, 1);
Olivier Greniebe9bae12011-01-04 05:42:19 -03003079
Michael Krufky77eed212011-09-06 09:31:57 -03003080 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
3081 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib7090_agc_startup;
Olivier Greniebe9bae12011-01-04 05:42:19 -03003082 return 0;
3083}
3084
3085static int tfe7090pvr_frontend0_attach(struct dvb_usb_adapter *adap)
3086{
3087 struct dib0700_state *st = adap->dev->priv;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003088 struct dib0700_adapter_state *state = adap->priv;
3089
3090 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
3091 return -ENODEV;
Olivier Greniebe9bae12011-01-04 05:42:19 -03003092
3093 /* The TFE7090 requires the dib0700 to not be in master mode */
3094 st->disable_streaming_master_mode = 1;
3095
3096 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03003097 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03003098 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
3099 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
3100 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
3101 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
3102
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03003103 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03003104 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03003105 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03003106 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
3107
3108 /* initialize IC 0 */
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003109 if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 0x20, &tfe7090pvr_dib7000p_config[0]) != 0) {
3110 err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n", __func__);
3111 dvb_detach(&state->dib7000p_ops);
Olivier Greniebe9bae12011-01-04 05:42:19 -03003112 return -ENODEV;
3113 }
3114
3115 dib0700_set_i2c_speed(adap->dev, 340);
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003116 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 -03003117 if (adap->fe_adap[0].fe == NULL)
Olivier Greniebe9bae12011-01-04 05:42:19 -03003118 return -ENODEV;
3119
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003120 state->dib7000p_ops.slave_reset(adap->fe_adap[0].fe);
Patrick Boettcher71682522011-04-03 12:44:25 -03003121
Olivier Greniebe9bae12011-01-04 05:42:19 -03003122 return 0;
3123}
3124
3125static int tfe7090pvr_frontend1_attach(struct dvb_usb_adapter *adap)
3126{
3127 struct i2c_adapter *i2c;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003128 struct dib0700_adapter_state *state = adap->priv;
Olivier Greniebe9bae12011-01-04 05:42:19 -03003129
Michael Krufky77eed212011-09-06 09:31:57 -03003130 if (adap->dev->adapter[0].fe_adap[0].fe == NULL) {
Olivier Greniebe9bae12011-01-04 05:42:19 -03003131 err("the master dib7090 has to be initialized first");
3132 return -ENODEV; /* the master device has not been initialized */
3133 }
3134
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003135 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
3136 return -ENODEV;
3137
3138 i2c = state->dib7000p_ops.get_i2c_master(adap->dev->adapter[0].fe_adap[0].fe, DIBX000_I2C_INTERFACE_GPIO_6_7, 1);
3139 if (state->dib7000p_ops.i2c_enumeration(i2c, 1, 0x10, &tfe7090pvr_dib7000p_config[1]) != 0) {
3140 err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n", __func__);
3141 dvb_detach(&state->dib7000p_ops);
Olivier Greniebe9bae12011-01-04 05:42:19 -03003142 return -ENODEV;
3143 }
3144
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003145 adap->fe_adap[0].fe = state->dib7000p_ops.init(i2c, 0x92, &tfe7090pvr_dib7000p_config[1]);
Olivier Greniebe9bae12011-01-04 05:42:19 -03003146 dib0700_set_i2c_speed(adap->dev, 200);
3147
Michael Krufky77eed212011-09-06 09:31:57 -03003148 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Olivier Greniebe9bae12011-01-04 05:42:19 -03003149}
3150
3151static int tfe7090pvr_tuner0_attach(struct dvb_usb_adapter *adap)
3152{
3153 struct dib0700_adapter_state *st = adap->priv;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003154 struct i2c_adapter *tun_i2c = st->dib7000p_ops.get_i2c_tuner(adap->fe_adap[0].fe);
3155
3156 tfe7090pvr_dib0090_config[0].reset = st->dib7000p_ops.tuner_sleep;
3157 tfe7090pvr_dib0090_config[0].sleep = st->dib7000p_ops.tuner_sleep;
3158 tfe7090pvr_dib0090_config[0].get_adc_power = st->dib7000p_ops.get_adc_power;
Olivier Greniebe9bae12011-01-04 05:42:19 -03003159
Michael Krufky77eed212011-09-06 09:31:57 -03003160 if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c, &tfe7090pvr_dib0090_config[0]) == NULL)
Olivier Greniebe9bae12011-01-04 05:42:19 -03003161 return -ENODEV;
3162
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003163 st->dib7000p_ops.set_gpio(adap->fe_adap[0].fe, 8, 0, 1);
Olivier Greniebe9bae12011-01-04 05:42:19 -03003164
Michael Krufky77eed212011-09-06 09:31:57 -03003165 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
3166 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib7090_agc_startup;
Olivier Greniebe9bae12011-01-04 05:42:19 -03003167 return 0;
3168}
3169
3170static int tfe7090pvr_tuner1_attach(struct dvb_usb_adapter *adap)
3171{
3172 struct dib0700_adapter_state *st = adap->priv;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003173 struct i2c_adapter *tun_i2c = st->dib7000p_ops.get_i2c_tuner(adap->fe_adap[0].fe);
3174
3175 tfe7090pvr_dib0090_config[1].reset = st->dib7000p_ops.tuner_sleep;
3176 tfe7090pvr_dib0090_config[1].sleep = st->dib7000p_ops.tuner_sleep;
3177 tfe7090pvr_dib0090_config[1].get_adc_power = st->dib7000p_ops.get_adc_power;
Olivier Greniebe9bae12011-01-04 05:42:19 -03003178
Michael Krufky77eed212011-09-06 09:31:57 -03003179 if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c, &tfe7090pvr_dib0090_config[1]) == NULL)
Olivier Greniebe9bae12011-01-04 05:42:19 -03003180 return -ENODEV;
3181
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003182 st->dib7000p_ops.set_gpio(adap->fe_adap[0].fe, 8, 0, 1);
Olivier Greniebe9bae12011-01-04 05:42:19 -03003183
Michael Krufky77eed212011-09-06 09:31:57 -03003184 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
3185 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib7090_agc_startup;
Olivier Greniebe9bae12011-01-04 05:42:19 -03003186 return 0;
3187}
3188
Olivier Grenief45f5132012-12-31 09:47:10 -03003189static int tfe7790p_frontend_attach(struct dvb_usb_adapter *adap)
Olivier Grenieb293f302011-08-09 04:48:25 -03003190{
3191 struct dib0700_state *st = adap->dev->priv;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003192 struct dib0700_adapter_state *state = adap->priv;
3193
3194 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
3195 return -ENODEV;
Olivier Grenieb293f302011-08-09 04:48:25 -03003196
Olivier Grenief45f5132012-12-31 09:47:10 -03003197 /* The TFE7790P requires the dib0700 to not be in master mode */
Olivier Grenieb293f302011-08-09 04:48:25 -03003198 st->disable_streaming_master_mode = 1;
3199
3200 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
3201 msleep(20);
3202 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
3203 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
3204 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
3205 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
3206 msleep(20);
3207 dib0700_ctrl_clock(adap->dev, 72, 1);
3208 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
3209 msleep(20);
3210 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
3211
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003212 if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap,
Olivier Grenief45f5132012-12-31 09:47:10 -03003213 1, 0x10, &tfe7790p_dib7000p_config) != 0) {
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003214 err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n",
Olivier Grenieb293f302011-08-09 04:48:25 -03003215 __func__);
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003216 dvb_detach(&state->dib7000p_ops);
Olivier Grenieb293f302011-08-09 04:48:25 -03003217 return -ENODEV;
3218 }
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003219 adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap,
Olivier Grenief45f5132012-12-31 09:47:10 -03003220 0x80, &tfe7790p_dib7000p_config);
Olivier Grenieb293f302011-08-09 04:48:25 -03003221
3222 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
3223}
3224
Olivier Grenief45f5132012-12-31 09:47:10 -03003225static int tfe7790p_tuner_attach(struct dvb_usb_adapter *adap)
Olivier Grenieb293f302011-08-09 04:48:25 -03003226{
3227 struct dib0700_adapter_state *st = adap->priv;
3228 struct i2c_adapter *tun_i2c =
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003229 st->dib7000p_ops.get_i2c_tuner(adap->fe_adap[0].fe);
3230
3231
3232 tfe7790p_dib0090_config.reset = st->dib7000p_ops.tuner_sleep;
3233 tfe7790p_dib0090_config.sleep = st->dib7000p_ops.tuner_sleep;
3234 tfe7790p_dib0090_config.get_adc_power = st->dib7000p_ops.get_adc_power;
Olivier Grenieb293f302011-08-09 04:48:25 -03003235
3236 if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c,
Olivier Grenief45f5132012-12-31 09:47:10 -03003237 &tfe7790p_dib0090_config) == NULL)
Olivier Grenie6724a2f2011-08-05 13:49:33 -03003238 return -ENODEV;
3239
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003240 st->dib7000p_ops.set_gpio(adap->fe_adap[0].fe, 8, 0, 1);
Olivier Grenie6724a2f2011-08-05 13:49:33 -03003241
3242 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
3243 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib7090_agc_startup;
3244 return 0;
3245}
3246
Patrick Boettcher01373a52007-07-30 12:49:04 -03003247/* STK7070PD */
3248static struct dib7000p_config stk7070pd_dib7000p_config[2] = {
3249 {
3250 .output_mpeg2_in_188_bytes = 1,
3251
3252 .agc_config_count = 1,
3253 .agc = &dib7070_agc_config,
3254 .bw = &dib7070_bw_config_12_mhz,
Patrick Boettcher3cb2c392008-01-25 07:25:20 -03003255 .tuner_is_baseband = 1,
3256 .spur_protect = 1,
Patrick Boettcher01373a52007-07-30 12:49:04 -03003257
3258 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
3259 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
3260 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
3261
3262 .hostbus_diversity = 1,
3263 }, {
3264 .output_mpeg2_in_188_bytes = 1,
3265
3266 .agc_config_count = 1,
3267 .agc = &dib7070_agc_config,
3268 .bw = &dib7070_bw_config_12_mhz,
Patrick Boettcher3cb2c392008-01-25 07:25:20 -03003269 .tuner_is_baseband = 1,
3270 .spur_protect = 1,
Patrick Boettcher01373a52007-07-30 12:49:04 -03003271
3272 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
3273 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
3274 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
3275
3276 .hostbus_diversity = 1,
3277 }
3278};
3279
Jiri Slaby52fd5b22012-01-10 14:11:23 -03003280static void stk7070pd_init(struct dvb_usb_device *dev)
3281{
3282 dib0700_set_gpio(dev, GPIO6, GPIO_OUT, 1);
3283 msleep(10);
3284 dib0700_set_gpio(dev, GPIO9, GPIO_OUT, 1);
3285 dib0700_set_gpio(dev, GPIO4, GPIO_OUT, 1);
3286 dib0700_set_gpio(dev, GPIO7, GPIO_OUT, 1);
3287 dib0700_set_gpio(dev, GPIO10, GPIO_OUT, 0);
3288
3289 dib0700_ctrl_clock(dev, 72, 1);
3290
3291 msleep(10);
3292 dib0700_set_gpio(dev, GPIO10, GPIO_OUT, 1);
3293}
3294
Patrick Boettcher01373a52007-07-30 12:49:04 -03003295static int stk7070pd_frontend_attach0(struct dvb_usb_adapter *adap)
3296{
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003297 struct dib0700_adapter_state *state = adap->priv;
3298
3299 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
3300 return -ENODEV;
3301
Jiri Slaby52fd5b22012-01-10 14:11:23 -03003302 stk7070pd_init(adap->dev);
Patrick Boettcher01373a52007-07-30 12:49:04 -03003303
Patrick Boettcher01373a52007-07-30 12:49:04 -03003304 msleep(10);
3305 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
3306
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003307 if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap, 2, 18,
Devin Heitmueller83c4fdf2009-01-21 01:55:45 -03003308 stk7070pd_dib7000p_config) != 0) {
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003309 err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n",
Devin Heitmueller83c4fdf2009-01-21 01:55:45 -03003310 __func__);
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003311 dvb_detach(&state->dib7000p_ops);
Devin Heitmueller83c4fdf2009-01-21 01:55:45 -03003312 return -ENODEV;
3313 }
Patrick Boettcher01373a52007-07-30 12:49:04 -03003314
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003315 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 -03003316 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Patrick Boettcher01373a52007-07-30 12:49:04 -03003317}
3318
3319static int stk7070pd_frontend_attach1(struct dvb_usb_adapter *adap)
3320{
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003321 struct dib0700_adapter_state *state = adap->priv;
3322
3323 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
3324 return -ENODEV;
3325
3326 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 -03003327 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Patrick Boettcher01373a52007-07-30 12:49:04 -03003328}
3329
Jiri Slabyd43272a2012-01-10 14:11:25 -03003330static int novatd_read_status_override(struct dvb_frontend *fe,
Mauro Carvalho Chehab0df289a2015-06-07 14:53:52 -03003331 enum fe_status *stat)
Jiri Slabyd43272a2012-01-10 14:11:25 -03003332{
3333 struct dvb_usb_adapter *adap = fe->dvb->priv;
3334 struct dvb_usb_device *dev = adap->dev;
3335 struct dib0700_state *state = dev->priv;
3336 int ret;
3337
3338 ret = state->read_status(fe, stat);
3339
3340 if (!ret)
3341 dib0700_set_gpio(dev, adap->id == 0 ? GPIO1 : GPIO0, GPIO_OUT,
3342 !!(*stat & FE_HAS_LOCK));
3343
3344 return ret;
3345}
3346
3347static int novatd_sleep_override(struct dvb_frontend* fe)
3348{
3349 struct dvb_usb_adapter *adap = fe->dvb->priv;
3350 struct dvb_usb_device *dev = adap->dev;
3351 struct dib0700_state *state = dev->priv;
3352
3353 /* turn off LED */
3354 dib0700_set_gpio(dev, adap->id == 0 ? GPIO1 : GPIO0, GPIO_OUT, 0);
3355
3356 return state->sleep(fe);
3357}
3358
Jiri Slaby2b05b882012-01-10 14:11:24 -03003359/**
3360 * novatd_frontend_attach - Nova-TD specific attach
3361 *
3362 * Nova-TD has GPIO0, 1 and 2 for LEDs. So do not fiddle with them except for
3363 * information purposes.
3364 */
3365static int novatd_frontend_attach(struct dvb_usb_adapter *adap)
3366{
3367 struct dvb_usb_device *dev = adap->dev;
Jiri Slabyd43272a2012-01-10 14:11:25 -03003368 struct dib0700_state *st = dev->priv;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003369 struct dib0700_adapter_state *state = adap->priv;
3370
3371 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
3372 return -ENODEV;
Jiri Slaby2b05b882012-01-10 14:11:24 -03003373
3374 if (adap->id == 0) {
3375 stk7070pd_init(dev);
3376
3377 /* turn the power LED on, the other two off (just in case) */
3378 dib0700_set_gpio(dev, GPIO0, GPIO_OUT, 0);
3379 dib0700_set_gpio(dev, GPIO1, GPIO_OUT, 0);
3380 dib0700_set_gpio(dev, GPIO2, GPIO_OUT, 1);
3381
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003382 if (state->dib7000p_ops.i2c_enumeration(&dev->i2c_adap, 2, 18,
Jiri Slaby2b05b882012-01-10 14:11:24 -03003383 stk7070pd_dib7000p_config) != 0) {
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003384 err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n",
Jiri Slaby2b05b882012-01-10 14:11:24 -03003385 __func__);
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003386 dvb_detach(&state->dib7000p_ops);
Jiri Slaby2b05b882012-01-10 14:11:24 -03003387 return -ENODEV;
3388 }
3389 }
3390
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003391 adap->fe_adap[0].fe = state->dib7000p_ops.init(&dev->i2c_adap,
Jiri Slaby2b05b882012-01-10 14:11:24 -03003392 adap->id == 0 ? 0x80 : 0x82,
3393 &stk7070pd_dib7000p_config[adap->id]);
Jiri Slabyd43272a2012-01-10 14:11:25 -03003394
3395 if (adap->fe_adap[0].fe == NULL)
3396 return -ENODEV;
3397
3398 st->read_status = adap->fe_adap[0].fe->ops.read_status;
3399 adap->fe_adap[0].fe->ops.read_status = novatd_read_status_override;
3400 st->sleep = adap->fe_adap[0].fe->ops.sleep;
3401 adap->fe_adap[0].fe->ops.sleep = novatd_sleep_override;
3402
3403 return 0;
Jiri Slaby2b05b882012-01-10 14:11:24 -03003404}
3405
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03003406/* S5H1411 */
3407static struct s5h1411_config pinnacle_801e_config = {
3408 .output_mode = S5H1411_PARALLEL_OUTPUT,
3409 .gpio = S5H1411_GPIO_OFF,
3410 .mpeg_timing = S5H1411_MPEGTIMING_NONCONTINOUS_NONINVERTING_CLOCK,
3411 .qam_if = S5H1411_IF_44000,
3412 .vsb_if = S5H1411_IF_44000,
3413 .inversion = S5H1411_INVERSION_OFF,
3414 .status_mode = S5H1411_DEMODLOCKING
3415};
3416
3417/* Pinnacle PCTV HD Pro 801e GPIOs map:
3418 GPIO0 - currently unknown
3419 GPIO1 - xc5000 tuner reset
3420 GPIO2 - CX25843 sleep
3421 GPIO3 - currently unknown
3422 GPIO4 - currently unknown
3423 GPIO6 - currently unknown
3424 GPIO7 - currently unknown
3425 GPIO9 - currently unknown
3426 GPIO10 - CX25843 reset
3427 */
3428static int s5h1411_frontend_attach(struct dvb_usb_adapter *adap)
3429{
3430 struct dib0700_state *st = adap->dev->priv;
3431
3432 /* Make use of the new i2c functions from FW 1.20 */
3433 st->fw_use_new_i2c_api = 1;
3434
3435 /* The s5h1411 requires the dib0700 to not be in master mode */
3436 st->disable_streaming_master_mode = 1;
3437
3438 /* All msleep values taken from Windows USB trace */
3439 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 0);
3440 dib0700_set_gpio(adap->dev, GPIO3, GPIO_OUT, 0);
3441 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
3442 msleep(400);
3443 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
3444 msleep(60);
3445 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
3446 msleep(30);
3447 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
3448 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
3449 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
3450 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
3451 dib0700_set_gpio(adap->dev, GPIO2, GPIO_OUT, 0);
3452 msleep(30);
3453
3454 /* Put the CX25843 to sleep for now since we're in digital mode */
3455 dib0700_set_gpio(adap->dev, GPIO2, GPIO_OUT, 1);
3456
3457 /* GPIOs are initialized, do the attach */
Michael Krufky77eed212011-09-06 09:31:57 -03003458 adap->fe_adap[0].fe = dvb_attach(s5h1411_attach, &pinnacle_801e_config,
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03003459 &adap->dev->i2c_adap);
Michael Krufky77eed212011-09-06 09:31:57 -03003460 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03003461}
3462
Michael Krufky767f3b32008-09-25 09:47:07 -03003463static int dib0700_xc5000_tuner_callback(void *priv, int component,
3464 int command, int arg)
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03003465{
3466 struct dvb_usb_adapter *adap = priv;
3467
Devin Heitmueller79025a92008-10-06 12:07:48 -03003468 if (command == XC5000_TUNER_RESET) {
3469 /* Reset the tuner */
3470 dib0700_set_gpio(adap->dev, GPIO1, GPIO_OUT, 0);
Devin Heitmuellerf0f46332009-05-04 21:57:41 -03003471 msleep(10);
Devin Heitmueller79025a92008-10-06 12:07:48 -03003472 dib0700_set_gpio(adap->dev, GPIO1, GPIO_OUT, 1);
Devin Heitmuellerf0f46332009-05-04 21:57:41 -03003473 msleep(10);
Devin Heitmueller79025a92008-10-06 12:07:48 -03003474 } else {
3475 err("xc5000: unknown tuner callback command: %d\n", command);
3476 return -EINVAL;
3477 }
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03003478
3479 return 0;
3480}
3481
3482static struct xc5000_config s5h1411_xc5000_tunerconfig = {
3483 .i2c_address = 0x64,
3484 .if_khz = 5380,
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03003485};
3486
3487static int xc5000_tuner_attach(struct dvb_usb_adapter *adap)
3488{
Devin Heitmueller79025a92008-10-06 12:07:48 -03003489 /* FIXME: generalize & move to common area */
Michael Krufky77eed212011-09-06 09:31:57 -03003490 adap->fe_adap[0].fe->callback = dib0700_xc5000_tuner_callback;
Devin Heitmueller79025a92008-10-06 12:07:48 -03003491
Michael Krufky77eed212011-09-06 09:31:57 -03003492 return dvb_attach(xc5000_attach, adap->fe_adap[0].fe, &adap->dev->i2c_adap,
Michael Krufky767f3b32008-09-25 09:47:07 -03003493 &s5h1411_xc5000_tunerconfig)
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03003494 == NULL ? -ENODEV : 0;
3495}
3496
Davide Ferri8d009a02009-06-23 22:34:06 -03003497static int dib0700_xc4000_tuner_callback(void *priv, int component,
3498 int command, int arg)
3499{
3500 struct dvb_usb_adapter *adap = priv;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003501 struct dib0700_adapter_state *state = adap->priv;
Davide Ferri8d009a02009-06-23 22:34:06 -03003502
3503 if (command == XC4000_TUNER_RESET) {
3504 /* Reset the tuner */
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003505 state->dib7000p_ops.set_gpio(adap->fe_adap[0].fe, 8, 0, 0);
Davide Ferri8d009a02009-06-23 22:34:06 -03003506 msleep(10);
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003507 state->dib7000p_ops.set_gpio(adap->fe_adap[0].fe, 8, 0, 1);
Davide Ferri8d009a02009-06-23 22:34:06 -03003508 } else {
3509 err("xc4000: unknown tuner callback command: %d\n", command);
3510 return -EINVAL;
3511 }
3512
3513 return 0;
3514}
3515
Devin Heitmueller8583fc82009-07-28 01:16:05 -03003516static struct dibx000_agc_config stk7700p_7000p_xc4000_agc_config = {
3517 .band_caps = BAND_UHF | BAND_VHF,
3518 .setup = 0x64,
3519 .inv_gain = 0x02c8,
3520 .time_stabiliz = 0x15,
3521 .alpha_level = 0x00,
3522 .thlock = 0x76,
3523 .wbd_inv = 0x01,
3524 .wbd_ref = 0x0b33,
3525 .wbd_sel = 0x00,
3526 .wbd_alpha = 0x02,
3527 .agc1_max = 0x00,
3528 .agc1_min = 0x00,
3529 .agc2_max = 0x9b26,
3530 .agc2_min = 0x26ca,
3531 .agc1_pt1 = 0x00,
3532 .agc1_pt2 = 0x00,
3533 .agc1_pt3 = 0x00,
3534 .agc1_slope1 = 0x00,
3535 .agc1_slope2 = 0x00,
3536 .agc2_pt1 = 0x00,
3537 .agc2_pt2 = 0x80,
3538 .agc2_slope1 = 0x1d,
3539 .agc2_slope2 = 0x1d,
Devin Heitmueller2df12512009-12-27 17:44:31 -03003540 .alpha_mant = 0x11,
Devin Heitmueller8583fc82009-07-28 01:16:05 -03003541 .alpha_exp = 0x1b,
3542 .beta_mant = 0x17,
3543 .beta_exp = 0x33,
3544 .perform_agc_softsplit = 0x00,
3545};
3546
Devin Heitmuellerf1c78d32009-10-05 00:34:04 -03003547static struct dibx000_bandwidth_config stk7700p_xc4000_pll_config = {
Mauro Carvalho Chehab09628b22014-09-22 18:57:45 -03003548 .internal = 60000,
3549 .sampling = 30000,
3550 .pll_prediv = 1,
3551 .pll_ratio = 8,
3552 .pll_range = 3,
3553 .pll_reset = 1,
3554 .pll_bypass = 0,
3555 .enable_refdiv = 0,
3556 .bypclk_div = 0,
3557 .IO_CLK_en_core = 1,
3558 .ADClkSrc = 1,
3559 .modulo = 0,
3560 .sad_cfg = (3 << 14) | (1 << 12) | 524, /* sad_cfg: refsel, sel, freq_15k */
3561 .ifreq = 39370534,
3562 .timf = 20452225,
3563 .xtal_hz = 30000000
Devin Heitmuellerf1c78d32009-10-05 00:34:04 -03003564};
3565
Devin Heitmueller01f16262009-06-24 00:07:01 -03003566/* FIXME: none of these inputs are validated yet */
3567static struct dib7000p_config pctv_340e_config = {
Devin Heitmueller62956ce2009-12-27 18:58:11 -03003568 .output_mpeg2_in_188_bytes = 1,
Devin Heitmueller01f16262009-06-24 00:07:01 -03003569
3570 .agc_config_count = 1,
Devin Heitmueller8583fc82009-07-28 01:16:05 -03003571 .agc = &stk7700p_7000p_xc4000_agc_config,
Devin Heitmuellerf1c78d32009-10-05 00:34:04 -03003572 .bw = &stk7700p_xc4000_pll_config,
Devin Heitmueller01f16262009-06-24 00:07:01 -03003573
Devin Heitmueller01f16262009-06-24 00:07:01 -03003574 .gpio_dir = DIB7000M_GPIO_DEFAULT_DIRECTIONS,
3575 .gpio_val = DIB7000M_GPIO_DEFAULT_VALUES,
3576 .gpio_pwm_pos = DIB7000M_GPIO_DEFAULT_PWM_POS,
3577};
3578
3579/* PCTV 340e GPIOs map:
3580 dib0700:
3581 GPIO2 - CX25843 sleep
3582 GPIO3 - CS5340 reset
3583 GPIO5 - IRD
3584 GPIO6 - Power Supply
3585 GPIO8 - LNA (1=off 0=on)
3586 GPIO10 - CX25843 reset
3587 dib7000:
3588 GPIO8 - xc4000 reset
3589 */
3590static int pctv340e_frontend_attach(struct dvb_usb_adapter *adap)
3591{
3592 struct dib0700_state *st = adap->dev->priv;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003593 struct dib0700_adapter_state *state = adap->priv;
3594
3595 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
3596 return -ENODEV;
Devin Heitmueller01f16262009-06-24 00:07:01 -03003597
3598 /* Power Supply on */
3599 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
3600 msleep(50);
3601 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
3602 msleep(100); /* Allow power supply to settle before probing */
3603
3604 /* cx25843 reset */
3605 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
3606 msleep(1); /* cx25843 datasheet say 350us required */
3607 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
3608
3609 /* LNA off for now */
3610 dib0700_set_gpio(adap->dev, GPIO8, GPIO_OUT, 1);
3611
3612 /* Put the CX25843 to sleep for now since we're in digital mode */
3613 dib0700_set_gpio(adap->dev, GPIO2, GPIO_OUT, 1);
3614
3615 /* FIXME: not verified yet */
3616 dib0700_ctrl_clock(adap->dev, 72, 1);
3617
Devin Heitmueller2750d9c2009-07-20 00:42:33 -03003618 msleep(500);
3619
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003620 if (state->dib7000p_ops.dib7000pc_detection(&adap->dev->i2c_adap) == 0) {
Devin Heitmueller01f16262009-06-24 00:07:01 -03003621 /* Demodulator not found for some reason? */
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003622 dvb_detach(&state->dib7000p_ops);
Devin Heitmueller01f16262009-06-24 00:07:01 -03003623 return -ENODEV;
3624 }
3625
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003626 adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap, 0x12,
Devin Heitmueller01f16262009-06-24 00:07:01 -03003627 &pctv_340e_config);
3628 st->is_dib7000pc = 1;
3629
Michael Krufky77eed212011-09-06 09:31:57 -03003630 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Devin Heitmueller01f16262009-06-24 00:07:01 -03003631}
3632
Devin Heitmueller8583fc82009-07-28 01:16:05 -03003633static struct xc4000_config dib7000p_xc4000_tunerconfig = {
istvan_v@mailbox.hu8edeb6e2011-06-06 13:03:44 -03003634 .i2c_address = 0x61,
3635 .default_pm = 1,
3636 .dvb_amplitude = 0,
3637 .set_smoothedcvbs = 0,
3638 .if_khz = 5400
Davide Ferri8d009a02009-06-23 22:34:06 -03003639};
3640
3641static int xc4000_tuner_attach(struct dvb_usb_adapter *adap)
3642{
Devin Heitmueller59d0c372009-06-29 21:11:02 -03003643 struct i2c_adapter *tun_i2c;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003644 struct dib0700_adapter_state *state = adap->priv;
Devin Heitmueller59d0c372009-06-29 21:11:02 -03003645
3646 /* The xc4000 is not on the main i2c bus */
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003647 tun_i2c = state->dib7000p_ops.get_i2c_master(adap->fe_adap[0].fe,
Devin Heitmueller59d0c372009-06-29 21:11:02 -03003648 DIBX000_I2C_INTERFACE_TUNER, 1);
3649 if (tun_i2c == NULL) {
Mauro Carvalho Chehab941830c2011-06-06 16:51:11 -03003650 printk(KERN_ERR "Could not reach tuner i2c bus\n");
Devin Heitmueller59d0c372009-06-29 21:11:02 -03003651 return 0;
3652 }
3653
3654 /* Setup the reset callback */
Michael Krufky77eed212011-09-06 09:31:57 -03003655 adap->fe_adap[0].fe->callback = dib0700_xc4000_tuner_callback;
Davide Ferri8d009a02009-06-23 22:34:06 -03003656
Michael Krufky77eed212011-09-06 09:31:57 -03003657 return dvb_attach(xc4000_attach, adap->fe_adap[0].fe, tun_i2c,
Devin Heitmueller8583fc82009-07-28 01:16:05 -03003658 &dib7000p_xc4000_tunerconfig)
Davide Ferri8d009a02009-06-23 22:34:06 -03003659 == NULL ? -ENODEV : 0;
3660}
3661
Michael Krufkyce904bc2009-01-19 01:12:55 -03003662static struct lgdt3305_config hcw_lgdt3305_config = {
3663 .i2c_addr = 0x0e,
3664 .mpeg_mode = LGDT3305_MPEG_PARALLEL,
3665 .tpclk_edge = LGDT3305_TPCLK_FALLING_EDGE,
3666 .tpvalid_polarity = LGDT3305_TP_VALID_LOW,
3667 .deny_i2c_rptr = 0,
3668 .spectral_inversion = 1,
3669 .qam_if_khz = 6000,
3670 .vsb_if_khz = 6000,
3671 .usref_8vsb = 0x0500,
3672};
3673
3674static struct mxl5007t_config hcw_mxl5007t_config = {
3675 .xtal_freq_hz = MxL_XTAL_25_MHZ,
3676 .if_freq_hz = MxL_IF_6_MHZ,
3677 .invert_if = 1,
3678};
3679
3680/* TIGER-ATSC map:
3681 GPIO0 - LNA_CTR (H: LNA power enabled, L: LNA power disabled)
3682 GPIO1 - ANT_SEL (H: VPA, L: MCX)
3683 GPIO4 - SCL2
3684 GPIO6 - EN_TUNER
3685 GPIO7 - SDA2
3686 GPIO10 - DEM_RST
3687
3688 MXL is behind LG's i2c repeater. LG is on SCL2/SDA2 gpios on the DIB
3689 */
3690static int lgdt3305_frontend_attach(struct dvb_usb_adapter *adap)
3691{
3692 struct dib0700_state *st = adap->dev->priv;
3693
3694 /* Make use of the new i2c functions from FW 1.20 */
3695 st->fw_use_new_i2c_api = 1;
3696
3697 st->disable_streaming_master_mode = 1;
3698
3699 /* fe power enable */
3700 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
3701 msleep(30);
3702 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
3703 msleep(30);
3704
3705 /* demod reset */
3706 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
3707 msleep(30);
3708 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
3709 msleep(30);
3710 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
3711 msleep(30);
3712
Michael Krufky77eed212011-09-06 09:31:57 -03003713 adap->fe_adap[0].fe = dvb_attach(lgdt3305_attach,
Michael Krufkyce904bc2009-01-19 01:12:55 -03003714 &hcw_lgdt3305_config,
3715 &adap->dev->i2c_adap);
3716
Michael Krufky77eed212011-09-06 09:31:57 -03003717 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Michael Krufkyce904bc2009-01-19 01:12:55 -03003718}
3719
3720static int mxl5007t_tuner_attach(struct dvb_usb_adapter *adap)
3721{
Michael Krufky77eed212011-09-06 09:31:57 -03003722 return dvb_attach(mxl5007t_attach, adap->fe_adap[0].fe,
Michael Krufkyce904bc2009-01-19 01:12:55 -03003723 &adap->dev->i2c_adap, 0x60,
3724 &hcw_mxl5007t_config) == NULL ? -ENODEV : 0;
3725}
3726
3727
Patrick Boettcher01373a52007-07-30 12:49:04 -03003728/* DVB-USB and USB stuff follows */
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003729struct usb_device_id dib0700_usb_id_table[] = {
Patrick Boettcher01373a52007-07-30 12:49:04 -03003730/* 0 */ { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7700P) },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03003731 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7700P_PC) },
3732 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_500) },
3733 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_500_2) },
3734 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_STICK) },
Patrick Boettcher01373a52007-07-30 12:49:04 -03003735/* 5 */ { USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR) },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03003736 { USB_DEVICE(USB_VID_COMPRO, USB_PID_COMPRO_VIDEOMATE_U500) },
3737 { USB_DEVICE(USB_VID_UNIWILL, USB_PID_UNIWILL_STK7700P) },
3738 { USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV_DONGLE_STK7700P) },
3739 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_STICK_2) },
Patrick Boettcher01373a52007-07-30 12:49:04 -03003740/* 10 */{ USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR_2) },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03003741 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV2000E) },
3742 { USB_DEVICE(USB_VID_TERRATEC,
3743 USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY) },
3744 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_TD_STICK) },
3745 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7700D) },
Patrick Boettcher01373a52007-07-30 12:49:04 -03003746/* 15 */{ USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7070P) },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03003747 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV_DVB_T_FLASH) },
3748 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7070PD) },
3749 { USB_DEVICE(USB_VID_PINNACLE,
3750 USB_PID_PINNACLE_PCTV_DUAL_DIVERSITY_DVB_T) },
3751 { USB_DEVICE(USB_VID_COMPRO, USB_PID_COMPRO_VIDEOMATE_U500_PC) },
Joachim Steigerfa3b8772007-10-08 20:08:46 -03003752/* 20 */{ USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_EXPRESS) },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03003753 { USB_DEVICE(USB_VID_GIGABYTE, USB_PID_GIGABYTE_U7000) },
3754 { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC, USB_PID_ARTEC_T14BR) },
3755 { USB_DEVICE(USB_VID_ASUS, USB_PID_ASUS_U3000) },
3756 { USB_DEVICE(USB_VID_ASUS, USB_PID_ASUS_U3100) },
3757/* 25 */{ USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_STICK_3) },
3758 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_MYTV_T) },
3759 { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_HT_USB_XE) },
3760 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_EXPRESSCARD_320CX) },
3761 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV72E) },
3762/* 30 */{ USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV73E) },
3763 { USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_EC372S) },
3764 { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_HT_EXPRESS) },
Alexander Simondc888072008-03-29 21:37:54 -03003765 { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_XXS) },
Darryl Green5da4e2c2008-03-29 21:47:43 -03003766 { USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV_DONGLE_STK7700P_2) },
Michael Krufkyaf2a8872008-09-03 17:12:24 -03003767/* 35 */{ USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_TD_STICK_52009) },
Michael Krufky9a0c04a2008-09-03 17:12:24 -03003768 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_500_3) },
Finn Thain17a370b2008-09-06 13:42:47 -03003769 { USB_DEVICE(USB_VID_GIGABYTE, USB_PID_GIGABYTE_U8000) },
Daniel Oliveira Nascimento8751aaa2008-09-07 12:39:44 -03003770 { USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_STK7700PH) },
Albert Comerma57697432008-09-07 12:43:33 -03003771 { USB_DEVICE(USB_VID_ASUS, USB_PID_ASUS_U3000H) },
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03003772/* 40 */{ USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV801E) },
Devin Heitmuellerd2fc3bf2008-09-25 06:22:23 -03003773 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV801E_SE) },
Yusuf Altinbb1b0822009-01-08 07:58:45 -03003774 { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_EXPRESS) },
Nicolas Fournierdb4b2d12009-01-13 07:15:25 -03003775 { USB_DEVICE(USB_VID_TERRATEC,
3776 USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY_2) },
sebastian.blanes@gmail.com0a6e1ed2009-02-24 14:51:43 -03003777 { USB_DEVICE(USB_VID_SONY, USB_PID_SONY_PLAYTV) },
Pascal Terjan9abb6e62009-02-26 10:31:41 -03003778/* 45 */{ USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_PD378S) },
Michael Krufkyce904bc2009-01-19 01:12:55 -03003779 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_TIGER_ATSC) },
3780 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_TIGER_ATSC_B210) },
Xoan Loureiro16ba1ee2009-03-29 08:43:36 -03003781 { USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_MC770) },
Klaus Flittner919a5482009-03-29 09:12:06 -03003782 { USB_DEVICE(USB_VID_ELGATO, USB_PID_ELGATO_EYETV_DTT) },
Armin Schenker513846e2009-04-20 11:57:49 -03003783/* 50 */{ USB_DEVICE(USB_VID_ELGATO, USB_PID_ELGATO_EYETV_DTT_Dlx) },
tomas petrf0f4ae72009-05-20 05:28:05 -03003784 { USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV_DONGLE_H) },
Patrick Boettchera9b8fe32009-05-20 05:35:02 -03003785 { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_T3) },
3786 { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_T5) },
Pete Hildebrandtc53d83c2009-08-05 11:46:38 -03003787 { USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_STK7700D) },
Olivier Grenie74b76f22009-09-02 08:19:19 -03003788/* 55 */{ USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_STK7700D_2) },
3789 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV73A) },
Patrick Boettchere4147532009-11-30 13:52:57 -03003790 { USB_DEVICE(USB_VID_PCTV, USB_PID_PINNACLE_PCTV73ESE) },
3791 { USB_DEVICE(USB_VID_PCTV, USB_PID_PINNACLE_PCTV282E) },
Olivier Grenied300bd62009-09-15 06:55:35 -03003792 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7770P) },
Patrick Boettcherdb481382009-09-15 07:16:51 -03003793/* 60 */{ USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_XXS_2) },
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03003794 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK807XPVR) },
3795 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK807XP) },
Mauro Carvalho Chehab3bfb3172010-09-03 10:50:24 -03003796 { USB_DEVICE_VER(USB_VID_PIXELVIEW, USB_PID_PIXELVIEW_SBTVD, 0x000, 0x3f00) },
S?rgio Fortier8a378e82009-09-28 04:19:21 -03003797 { USB_DEVICE(USB_VID_EVOLUTEPC, USB_PID_TVWAY_PLUS) },
Patrick Boettcher20232c42009-12-01 12:08:56 -03003798/* 65 */{ USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV73ESE) },
Patrick Boettchere4147532009-11-30 13:52:57 -03003799 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV282E) },
Olivier Grenie03245a52009-12-04 13:27:57 -03003800 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK8096GP) },
Michael Müller84e2f032010-04-26 22:18:57 -03003801 { USB_DEVICE(USB_VID_ELGATO, USB_PID_ELGATO_EYETV_DIVERSITY) },
Olivier Greniebe9bae12011-01-04 05:42:19 -03003802 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_NIM9090M) },
3803/* 70 */{ USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_NIM8096MD) },
3804 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_NIM9090MD) },
3805 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_NIM7090) },
3806 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_TFE7090PVR) },
Lukas Max Fisch498e6772011-02-08 16:51:45 -03003807 { USB_DEVICE(USB_VID_TECHNISAT, USB_PID_TECHNISAT_AIRSTAR_TELESTICK_2) },
Stéphane Elmalehd1402302011-05-21 07:33:38 -03003808/* 75 */{ USB_DEVICE(USB_VID_MEDION, USB_PID_CREATIX_CTX1921) },
Davide Ferri8d009a02009-06-23 22:34:06 -03003809 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV340E) },
Devin Heitmueller33fb1682009-06-23 22:48:02 -03003810 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV340E_SE) },
Olivier Grenief45f5132012-12-31 09:47:10 -03003811 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_TFE7790P) },
3812 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_TFE8096P) },
3813/* 80 */{ USB_DEVICE(USB_VID_ELGATO, USB_PID_ELGATO_EYETV_DTT_2) },
Michael Krufkyc859e6e2013-06-30 12:43:58 -03003814 { USB_DEVICE(USB_VID_PCTV, USB_PID_PCTV_2002E) },
3815 { USB_DEVICE(USB_VID_PCTV, USB_PID_PCTV_2002E_SE) },
Nicolas Sugino91be2602015-11-26 19:00:28 -02003816 { USB_DEVICE(USB_VID_PCTV, USB_PID_DIBCOM_STK8096PVR) },
Alejandro Torradoec788792016-04-18 13:37:00 -03003817 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK8096PVR) },
Piotr Oleszczyk430ae122017-02-01 18:26:42 -02003818 { USB_DEVICE(USB_VID_HAMA, USB_PID_HAMA_DVBT_HYBRID) },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03003819 { 0 } /* Terminating entry */
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003820};
3821MODULE_DEVICE_TABLE(usb, dib0700_usb_id_table);
3822
3823#define DIB0700_DEFAULT_DEVICE_PROPERTIES \
3824 .caps = DVB_USB_IS_AN_I2C_ADAPTER, \
3825 .usb_ctrl = DEVICE_SPECIFIC, \
Devin Heitmuellerbdc203e2008-09-06 13:45:27 -03003826 .firmware = "dvb-usb-dib0700-1.20.fw", \
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003827 .download_firmware = dib0700_download_firmware, \
Patrick Boettcher6958eff2006-09-19 12:51:40 -03003828 .no_reconnect = 1, \
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003829 .size_of_priv = sizeof(struct dib0700_state), \
Patrick Boettcher6958eff2006-09-19 12:51:40 -03003830 .i2c_algo = &dib0700_i2c_algo, \
3831 .identify_state = dib0700_identify_state
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003832
3833#define DIB0700_DEFAULT_STREAMING_CONFIG(ep) \
3834 .streaming_ctrl = dib0700_streaming_ctrl, \
3835 .stream = { \
3836 .type = USB_BULK, \
3837 .count = 4, \
3838 .endpoint = ep, \
3839 .u = { \
3840 .bulk = { \
3841 .buffersize = 39480, \
3842 } \
3843 } \
3844 }
3845
Mauro Carvalho Chehab0fae1992015-05-13 18:51:19 -03003846#define DIB0700_NUM_FRONTENDS(n) \
3847 .num_frontends = n, \
3848 .size_of_priv = sizeof(struct dib0700_adapter_state)
3849
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003850struct dvb_usb_device_properties dib0700_devices[] = {
3851 {
3852 DIB0700_DEFAULT_DEVICE_PROPERTIES,
3853
3854 .num_adapters = 1,
3855 .adapter = {
3856 {
Mauro Carvalho Chehab0fae1992015-05-13 18:51:19 -03003857 DIB0700_NUM_FRONTENDS(1),
Michael Krufky77eed212011-09-06 09:31:57 -03003858 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03003859 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
3860 .pid_filter_count = 32,
Olivier Greniee192a7c2011-01-14 13:58:59 -03003861 .pid_filter = stk7700p_pid_filter,
3862 .pid_filter_ctrl = stk7700p_pid_filter_ctrl,
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003863 .frontend_attach = stk7700p_frontend_attach,
3864 .tuner_attach = stk7700p_tuner_attach,
3865
3866 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03003867 }},
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003868 },
3869 },
3870
dominik67053a42007-11-10 19:23:31 -03003871 .num_device_descs = 8,
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003872 .devices = {
3873 { "DiBcom STK7700P reference design",
Tomi Koivulahti49a13762006-10-19 07:27:19 -03003874 { &dib0700_usb_id_table[0], &dib0700_usb_id_table[1] },
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003875 { NULL },
3876 },
3877 { "Hauppauge Nova-T Stick",
Stefan Trabyf9aeba42006-11-12 13:02:51 -03003878 { &dib0700_usb_id_table[4], &dib0700_usb_id_table[9], NULL },
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003879 { NULL },
3880 },
Tomi Koivulahti49a13762006-10-19 07:27:19 -03003881 { "AVerMedia AVerTV DVB-T Volar",
Jose Carlos Garcia Sogoced8fec2006-11-14 05:01:47 -03003882 { &dib0700_usb_id_table[5], &dib0700_usb_id_table[10] },
Tomi Koivulahti49a13762006-10-19 07:27:19 -03003883 { NULL },
3884 },
3885 { "Compro Videomate U500",
Patrick Boettcher1f8ca4b2007-07-30 14:24:37 -03003886 { &dib0700_usb_id_table[6], &dib0700_usb_id_table[19] },
Tomi Koivulahti49a13762006-10-19 07:27:19 -03003887 { NULL },
Henning Schroeer0ce215e2006-10-19 07:58:22 -03003888 },
3889 { "Uniwill STK7700P based (Hama and others)",
3890 { &dib0700_usb_id_table[7], NULL },
3891 { NULL },
Michael Krufky8637a872006-11-08 16:47:32 -03003892 },
3893 { "Leadtek Winfast DTV Dongle (STK7700P based)",
Patrick Boettcher1e13c8f2009-09-19 05:24:40 -03003894 { &dib0700_usb_id_table[8], &dib0700_usb_id_table[34] },
Michael Krufky8637a872006-11-08 16:47:32 -03003895 { NULL },
Joachim Steigerfa3b8772007-10-08 20:08:46 -03003896 },
3897 { "AVerMedia AVerTV DVB-T Express",
3898 { &dib0700_usb_id_table[20] },
3899 { NULL },
dominik67053a42007-11-10 19:23:31 -03003900 },
dominik67053a42007-11-10 19:23:31 -03003901 { "Gigabyte U7000",
3902 { &dib0700_usb_id_table[21], NULL },
3903 { NULL },
Tomi Koivulahti49a13762006-10-19 07:27:19 -03003904 }
Darren Saltb1139e32007-08-18 18:05:31 -03003905 },
3906
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03003907 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03003908 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03003909 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03003910 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03003911 .allowed_protos = RC_BIT_RC5 |
3912 RC_BIT_RC6_MCE |
3913 RC_BIT_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03003914 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03003915 },
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003916 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
3917
3918 .num_adapters = 2,
3919 .adapter = {
3920 {
Mauro Carvalho Chehab0fae1992015-05-13 18:51:19 -03003921 DIB0700_NUM_FRONTENDS(1),
Michael Krufky77eed212011-09-06 09:31:57 -03003922 .fe = {{
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003923 .frontend_attach = bristol_frontend_attach,
3924 .tuner_attach = bristol_tuner_attach,
3925
3926 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03003927 }},
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003928 }, {
Mauro Carvalho Chehab0fae1992015-05-13 18:51:19 -03003929 DIB0700_NUM_FRONTENDS(1),
Michael Krufky77eed212011-09-06 09:31:57 -03003930 .fe = {{
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003931 .frontend_attach = bristol_frontend_attach,
3932 .tuner_attach = bristol_tuner_attach,
3933
3934 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
Michael Krufky77eed212011-09-06 09:31:57 -03003935 }},
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003936 }
3937 },
3938
3939 .num_device_descs = 1,
3940 .devices = {
3941 { "Hauppauge Nova-T 500 Dual DVB-T",
Tomi Koivulahti49a13762006-10-19 07:27:19 -03003942 { &dib0700_usb_id_table[2], &dib0700_usb_id_table[3], NULL },
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003943 { NULL },
3944 },
Janne Grunau82f3d552007-07-30 13:50:28 -03003945 },
3946
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03003947 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03003948 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03003949 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03003950 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03003951 .allowed_protos = RC_BIT_RC5 |
3952 RC_BIT_RC6_MCE |
3953 RC_BIT_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03003954 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03003955 },
Olivier DANET54d75eb2007-07-25 14:42:54 -03003956 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
3957
3958 .num_adapters = 2,
3959 .adapter = {
3960 {
Mauro Carvalho Chehab0fae1992015-05-13 18:51:19 -03003961 DIB0700_NUM_FRONTENDS(1),
Michael Krufky77eed212011-09-06 09:31:57 -03003962 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03003963 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
3964 .pid_filter_count = 32,
3965 .pid_filter = stk70x0p_pid_filter,
3966 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
Olivier DANET54d75eb2007-07-25 14:42:54 -03003967 .frontend_attach = stk7700d_frontend_attach,
3968 .tuner_attach = stk7700d_tuner_attach,
3969
3970 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03003971 }},
Olivier DANET54d75eb2007-07-25 14:42:54 -03003972 }, {
Mauro Carvalho Chehab0fae1992015-05-13 18:51:19 -03003973 DIB0700_NUM_FRONTENDS(1),
Michael Krufky77eed212011-09-06 09:31:57 -03003974 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03003975 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
3976 .pid_filter_count = 32,
3977 .pid_filter = stk70x0p_pid_filter,
3978 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
Olivier DANET54d75eb2007-07-25 14:42:54 -03003979 .frontend_attach = stk7700d_frontend_attach,
3980 .tuner_attach = stk7700d_tuner_attach,
3981
3982 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
Michael Krufky77eed212011-09-06 09:31:57 -03003983 }},
Olivier DANET54d75eb2007-07-25 14:42:54 -03003984 }
3985 },
3986
James A Webb200e8612009-08-04 02:38:05 -03003987 .num_device_descs = 5,
Olivier DANET54d75eb2007-07-25 14:42:54 -03003988 .devices = {
3989 { "Pinnacle PCTV 2000e",
3990 { &dib0700_usb_id_table[11], NULL },
3991 { NULL },
3992 },
3993 { "Terratec Cinergy DT XS Diversity",
3994 { &dib0700_usb_id_table[12], NULL },
3995 { NULL },
3996 },
Darren Saltfaebb912007-08-18 18:04:00 -03003997 { "Hauppauge Nova-TD Stick/Elgato Eye-TV Diversity",
Olivier DANET54d75eb2007-07-25 14:42:54 -03003998 { &dib0700_usb_id_table[13], NULL },
3999 { NULL },
4000 },
Patrick Boettcher01373a52007-07-30 12:49:04 -03004001 { "DiBcom STK7700D reference design",
Patrick Boettcherb6884a12007-07-27 10:08:51 -03004002 { &dib0700_usb_id_table[14], NULL },
4003 { NULL },
Yusuf Altinbb1b0822009-01-08 07:58:45 -03004004 },
James A Webb200e8612009-08-04 02:38:05 -03004005 { "YUAN High-Tech DiBcom STK7700D",
4006 { &dib0700_usb_id_table[55], NULL },
4007 { NULL },
4008 },
Yusuf Altinbb1b0822009-01-08 07:58:45 -03004009
Olivier DANET54d75eb2007-07-25 14:42:54 -03004010 },
Janne Grunau82f3d552007-07-30 13:50:28 -03004011
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004012 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004013 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004014 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03004015 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004016 .allowed_protos = RC_BIT_RC5 |
4017 RC_BIT_RC6_MCE |
4018 RC_BIT_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03004019 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004020 },
Patrick Boettcher01373a52007-07-30 12:49:04 -03004021 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4022
4023 .num_adapters = 1,
4024 .adapter = {
4025 {
Mauro Carvalho Chehab0fae1992015-05-13 18:51:19 -03004026 DIB0700_NUM_FRONTENDS(1),
Michael Krufky77eed212011-09-06 09:31:57 -03004027 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03004028 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4029 .pid_filter_count = 32,
4030 .pid_filter = stk70x0p_pid_filter,
4031 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
Daniel Gimpelevich132c3182008-01-25 06:02:42 -03004032 .frontend_attach = stk7700P2_frontend_attach,
4033 .tuner_attach = stk7700d_tuner_attach,
4034
4035 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004036 }},
Daniel Gimpelevich132c3182008-01-25 06:02:42 -03004037 },
4038 },
4039
Yusuf Altinbb1b0822009-01-08 07:58:45 -03004040 .num_device_descs = 3,
Daniel Gimpelevich132c3182008-01-25 06:02:42 -03004041 .devices = {
4042 { "ASUS My Cinema U3000 Mini DVBT Tuner",
4043 { &dib0700_usb_id_table[23], NULL },
4044 { NULL },
4045 },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03004046 { "Yuan EC372S",
4047 { &dib0700_usb_id_table[31], NULL },
4048 { NULL },
Yusuf Altinbb1b0822009-01-08 07:58:45 -03004049 },
4050 { "Terratec Cinergy T Express",
4051 { &dib0700_usb_id_table[42], NULL },
4052 { NULL },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03004053 }
Chris Rankin48aa7392008-09-25 06:52:24 -03004054 },
4055
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004056 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004057 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004058 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004059 .module_name = "dib0700",
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03004060 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004061 .allowed_protos = RC_BIT_RC5 |
4062 RC_BIT_RC6_MCE |
4063 RC_BIT_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03004064 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004065 },
Daniel Gimpelevich132c3182008-01-25 06:02:42 -03004066 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4067
4068 .num_adapters = 1,
4069 .adapter = {
4070 {
Mauro Carvalho Chehab0fae1992015-05-13 18:51:19 -03004071 DIB0700_NUM_FRONTENDS(1),
Michael Krufky77eed212011-09-06 09:31:57 -03004072 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03004073 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4074 .pid_filter_count = 32,
4075 .pid_filter = stk70x0p_pid_filter,
4076 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
Patrick Boettcher01373a52007-07-30 12:49:04 -03004077 .frontend_attach = stk7070p_frontend_attach,
4078 .tuner_attach = dib7070p_tuner_attach,
4079
4080 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004081 }},
Patrick Boettcher01373a52007-07-30 12:49:04 -03004082 },
4083 },
4084
Gianluca Gennari0bc9d392012-04-14 09:14:07 -03004085 .num_device_descs = 12,
Patrick Boettcher01373a52007-07-30 12:49:04 -03004086 .devices = {
4087 { "DiBcom STK7070P reference design",
4088 { &dib0700_usb_id_table[15], NULL },
4089 { NULL },
4090 },
4091 { "Pinnacle PCTV DVB-T Flash Stick",
4092 { &dib0700_usb_id_table[16], NULL },
4093 { NULL },
4094 },
Yousef Lamlum7999a812008-01-25 05:51:48 -03004095 { "Artec T14BR DVB-T",
4096 { &dib0700_usb_id_table[22], NULL },
4097 { NULL },
Daniel Gimpelevich132c3182008-01-25 06:02:42 -03004098 },
4099 { "ASUS My Cinema U3100 Mini DVBT Tuner",
4100 { &dib0700_usb_id_table[24], NULL },
4101 { NULL },
4102 },
Tim Taubertc7637b12008-01-25 06:16:36 -03004103 { "Hauppauge Nova-T Stick",
4104 { &dib0700_usb_id_table[25], NULL },
4105 { NULL },
4106 },
Darren Salt13b83b52008-01-25 06:20:02 -03004107 { "Hauppauge Nova-T MyTV.t",
4108 { &dib0700_usb_id_table[26], NULL },
4109 { NULL },
4110 },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03004111 { "Pinnacle PCTV 72e",
4112 { &dib0700_usb_id_table[29], NULL },
4113 { NULL },
4114 },
4115 { "Pinnacle PCTV 73e",
4116 { &dib0700_usb_id_table[30], NULL },
4117 { NULL },
4118 },
Klaus Flittner919a5482009-03-29 09:12:06 -03004119 { "Elgato EyeTV DTT",
4120 { &dib0700_usb_id_table[49], NULL },
4121 { NULL },
4122 },
Pascal Terjan9abb6e62009-02-26 10:31:41 -03004123 { "Yuan PD378S",
4124 { &dib0700_usb_id_table[45], NULL },
4125 { NULL },
4126 },
Armin Schenker513846e2009-04-20 11:57:49 -03004127 { "Elgato EyeTV Dtt Dlx PD378S",
4128 { &dib0700_usb_id_table[50], NULL },
4129 { NULL },
4130 },
Gianluca Gennari0bc9d392012-04-14 09:14:07 -03004131 { "Elgato EyeTV DTT rev. 2",
Olivier Grenief45f5132012-12-31 09:47:10 -03004132 { &dib0700_usb_id_table[80], NULL },
Gianluca Gennari0bc9d392012-04-14 09:14:07 -03004133 { NULL },
4134 },
Tim Taubertc7637b12008-01-25 06:16:36 -03004135 },
4136
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004137 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004138 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004139 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004140 .module_name = "dib0700",
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03004141 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004142 .allowed_protos = RC_BIT_RC5 |
4143 RC_BIT_RC6_MCE |
4144 RC_BIT_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03004145 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004146 },
Patrick Boettcher01373a52007-07-30 12:49:04 -03004147 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4148
Olivier Grenie74b76f22009-09-02 08:19:19 -03004149 .num_adapters = 1,
4150 .adapter = {
4151 {
Mauro Carvalho Chehab0fae1992015-05-13 18:51:19 -03004152 DIB0700_NUM_FRONTENDS(1),
Michael Krufky77eed212011-09-06 09:31:57 -03004153 .fe = {{
Mauro Carvalho Chehab648732f2009-11-04 12:11:43 -02004154 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4155 .pid_filter_count = 32,
4156 .pid_filter = stk70x0p_pid_filter,
4157 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
Olivier Grenie74b76f22009-09-02 08:19:19 -03004158 .frontend_attach = stk7070p_frontend_attach,
4159 .tuner_attach = dib7070p_tuner_attach,
4160
4161 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004162 }},
Olivier Grenie74b76f22009-09-02 08:19:19 -03004163 },
4164 },
4165
Patrick Boettcher20232c42009-12-01 12:08:56 -03004166 .num_device_descs = 3,
Olivier Grenie74b76f22009-09-02 08:19:19 -03004167 .devices = {
4168 { "Pinnacle PCTV 73A",
4169 { &dib0700_usb_id_table[56], NULL },
4170 { NULL },
4171 },
4172 { "Pinnacle PCTV 73e SE",
Patrick Boettcher20232c42009-12-01 12:08:56 -03004173 { &dib0700_usb_id_table[57], &dib0700_usb_id_table[65], NULL },
Olivier Grenie74b76f22009-09-02 08:19:19 -03004174 { NULL },
4175 },
4176 { "Pinnacle PCTV 282e",
Patrick Boettcher20232c42009-12-01 12:08:56 -03004177 { &dib0700_usb_id_table[58], &dib0700_usb_id_table[66], NULL },
Olivier Grenie74b76f22009-09-02 08:19:19 -03004178 { NULL },
4179 },
4180 },
4181
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004182 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004183 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004184 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004185 .module_name = "dib0700",
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03004186 .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,
David Härdemand8b4b582010-10-29 16:08:23 -03004190 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004191 },
Olivier Grenie74b76f22009-09-02 08:19:19 -03004192 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4193
Patrick Boettcher01373a52007-07-30 12:49:04 -03004194 .num_adapters = 2,
4195 .adapter = {
4196 {
Mauro Carvalho Chehab0fae1992015-05-13 18:51:19 -03004197 DIB0700_NUM_FRONTENDS(1),
Michael Krufky77eed212011-09-06 09:31:57 -03004198 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03004199 .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,
Jiri Slaby2b05b882012-01-10 14:11:24 -03004203 .frontend_attach = novatd_frontend_attach,
Patrick Boettcher01373a52007-07-30 12:49:04 -03004204 .tuner_attach = dib7070p_tuner_attach,
4205
4206 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004207 }},
Patrick Boettcher01373a52007-07-30 12:49:04 -03004208 }, {
Mauro Carvalho Chehab0fae1992015-05-13 18:51:19 -03004209 DIB0700_NUM_FRONTENDS(1),
Michael Krufky77eed212011-09-06 09:31:57 -03004210 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03004211 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4212 .pid_filter_count = 32,
4213 .pid_filter = stk70x0p_pid_filter,
4214 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
Jiri Slaby2b05b882012-01-10 14:11:24 -03004215 .frontend_attach = novatd_frontend_attach,
Patrick Boettcher01373a52007-07-30 12:49:04 -03004216 .tuner_attach = dib7070p_tuner_attach,
4217
4218 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
Michael Krufky77eed212011-09-06 09:31:57 -03004219 }},
Patrick Boettcher01373a52007-07-30 12:49:04 -03004220 }
4221 },
4222
Michael Krufkyc859e6e2013-06-30 12:43:58 -03004223 .num_device_descs = 3,
Jiri Slaby9b6ba572012-01-10 14:11:22 -03004224 .devices = {
4225 { "Hauppauge Nova-TD Stick (52009)",
4226 { &dib0700_usb_id_table[35], NULL },
4227 { NULL },
4228 },
Michael Krufkyc859e6e2013-06-30 12:43:58 -03004229 { "PCTV 2002e",
4230 { &dib0700_usb_id_table[81], NULL },
4231 { NULL },
4232 },
4233 { "PCTV 2002e SE",
4234 { &dib0700_usb_id_table[82], NULL },
4235 { NULL },
4236 },
Jiri Slaby9b6ba572012-01-10 14:11:22 -03004237 },
4238
4239 .rc.core = {
4240 .rc_interval = DEFAULT_RC_INTERVAL,
4241 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4242 .module_name = "dib0700",
4243 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004244 .allowed_protos = RC_BIT_RC5 |
4245 RC_BIT_RC6_MCE |
4246 RC_BIT_NEC,
Jiri Slaby9b6ba572012-01-10 14:11:22 -03004247 .change_protocol = dib0700_change_protocol,
4248 },
4249 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4250
4251 .num_adapters = 2,
4252 .adapter = {
4253 {
Mauro Carvalho Chehab0fae1992015-05-13 18:51:19 -03004254 DIB0700_NUM_FRONTENDS(1),
Jiri Slaby9b6ba572012-01-10 14:11:22 -03004255 .fe = {{
4256 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4257 .pid_filter_count = 32,
4258 .pid_filter = stk70x0p_pid_filter,
4259 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
4260 .frontend_attach = stk7070pd_frontend_attach0,
4261 .tuner_attach = dib7070p_tuner_attach,
4262
4263 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
4264 }},
Jiri Slaby9b6ba572012-01-10 14:11:22 -03004265 }, {
Mauro Carvalho Chehab0fae1992015-05-13 18:51:19 -03004266 DIB0700_NUM_FRONTENDS(1),
Jiri Slaby9b6ba572012-01-10 14:11:22 -03004267 .fe = {{
4268 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4269 .pid_filter_count = 32,
4270 .pid_filter = stk70x0p_pid_filter,
4271 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
4272 .frontend_attach = stk7070pd_frontend_attach1,
4273 .tuner_attach = dib7070p_tuner_attach,
4274
4275 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
4276 }},
Jiri Slaby9b6ba572012-01-10 14:11:22 -03004277 }
4278 },
4279
4280 .num_device_descs = 5,
Patrick Boettcher01373a52007-07-30 12:49:04 -03004281 .devices = {
4282 { "DiBcom STK7070PD reference design",
4283 { &dib0700_usb_id_table[17], NULL },
4284 { NULL },
4285 },
4286 { "Pinnacle PCTV Dual DVB-T Diversity Stick",
4287 { &dib0700_usb_id_table[18], NULL },
4288 { NULL },
Michael Krufkyd01eb2d2008-07-03 23:43:36 -03004289 },
Michael Krufky9a0c04a2008-09-03 17:12:24 -03004290 { "Hauppauge Nova-TD-500 (84xxx)",
4291 { &dib0700_usb_id_table[36], NULL },
4292 { NULL },
Nicolas Fournierdb4b2d12009-01-13 07:15:25 -03004293 },
Patrick Boettchera9b8fe32009-05-20 05:35:02 -03004294 { "Terratec Cinergy DT USB XS Diversity/ T5",
4295 { &dib0700_usb_id_table[43],
4296 &dib0700_usb_id_table[53], NULL},
Nicolas Fournierdb4b2d12009-01-13 07:15:25 -03004297 { NULL },
sebastian.blanes@gmail.com0a6e1ed2009-02-24 14:51:43 -03004298 },
4299 { "Sony PlayTV",
4300 { &dib0700_usb_id_table[44], NULL },
4301 { NULL },
Michael Müller84e2f032010-04-26 22:18:57 -03004302 },
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004303 },
4304
4305 .rc.core = {
4306 .rc_interval = DEFAULT_RC_INTERVAL,
4307 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4308 .module_name = "dib0700",
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03004309 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004310 .allowed_protos = RC_BIT_RC5 |
4311 RC_BIT_RC6_MCE |
4312 RC_BIT_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03004313 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004314 },
4315 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4316
4317 .num_adapters = 2,
4318 .adapter = {
4319 {
Mauro Carvalho Chehab0fae1992015-05-13 18:51:19 -03004320 DIB0700_NUM_FRONTENDS(1),
Michael Krufky77eed212011-09-06 09:31:57 -03004321 .fe = {{
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004322 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4323 .pid_filter_count = 32,
4324 .pid_filter = stk70x0p_pid_filter,
4325 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
4326 .frontend_attach = stk7070pd_frontend_attach0,
4327 .tuner_attach = dib7070p_tuner_attach,
4328
4329 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004330 }},
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004331 }, {
Mauro Carvalho Chehab0fae1992015-05-13 18:51:19 -03004332 DIB0700_NUM_FRONTENDS(1),
Michael Krufky77eed212011-09-06 09:31:57 -03004333 .fe = {{
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004334 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4335 .pid_filter_count = 32,
4336 .pid_filter = stk70x0p_pid_filter,
4337 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
4338 .frontend_attach = stk7070pd_frontend_attach1,
4339 .tuner_attach = dib7070p_tuner_attach,
4340
4341 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
Michael Krufky77eed212011-09-06 09:31:57 -03004342 }},
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004343 }
4344 },
4345
4346 .num_device_descs = 1,
4347 .devices = {
Michael Müller84e2f032010-04-26 22:18:57 -03004348 { "Elgato EyeTV Diversity",
4349 { &dib0700_usb_id_table[68], NULL },
4350 { NULL },
4351 },
Arne Luehrsc985a8d2009-01-21 01:37:20 -03004352 },
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004353
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004354 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004355 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004356 .rc_codes = RC_MAP_DIB0700_NEC_TABLE,
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004357 .module_name = "dib0700",
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03004358 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004359 .allowed_protos = RC_BIT_RC5 |
4360 RC_BIT_RC6_MCE |
4361 RC_BIT_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03004362 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004363 },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03004364 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4365
4366 .num_adapters = 1,
4367 .adapter = {
4368 {
Mauro Carvalho Chehab0fae1992015-05-13 18:51:19 -03004369 DIB0700_NUM_FRONTENDS(1),
Michael Krufky77eed212011-09-06 09:31:57 -03004370 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03004371 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4372 .pid_filter_count = 32,
4373 .pid_filter = stk70x0p_pid_filter,
4374 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03004375 .frontend_attach = stk7700ph_frontend_attach,
4376 .tuner_attach = stk7700ph_tuner_attach,
4377
4378 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004379 }},
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03004380 },
4381 },
4382
Piotr Oleszczyk430ae122017-02-01 18:26:42 -02004383 .num_device_descs = 10,
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03004384 .devices = {
4385 { "Terratec Cinergy HT USB XE",
4386 { &dib0700_usb_id_table[27], NULL },
4387 { NULL },
4388 },
4389 { "Pinnacle Expresscard 320cx",
4390 { &dib0700_usb_id_table[28], NULL },
4391 { NULL },
4392 },
4393 { "Terratec Cinergy HT Express",
4394 { &dib0700_usb_id_table[32], NULL },
4395 { NULL },
4396 },
Finn Thain17a370b2008-09-06 13:42:47 -03004397 { "Gigabyte U8000-RH",
4398 { &dib0700_usb_id_table[37], NULL },
4399 { NULL },
4400 },
Daniel Oliveira Nascimento8751aaa2008-09-07 12:39:44 -03004401 { "YUAN High-Tech STK7700PH",
4402 { &dib0700_usb_id_table[38], NULL },
4403 { NULL },
4404 },
Albert Comerma57697432008-09-07 12:43:33 -03004405 { "Asus My Cinema-U3000Hybrid",
4406 { &dib0700_usb_id_table[39], NULL },
4407 { NULL },
4408 },
Xoan Loureiro16ba1ee2009-03-29 08:43:36 -03004409 { "YUAN High-Tech MC770",
4410 { &dib0700_usb_id_table[48], NULL },
4411 { NULL },
4412 },
tomas petrf0f4ae72009-05-20 05:28:05 -03004413 { "Leadtek WinFast DTV Dongle H",
4414 { &dib0700_usb_id_table[51], NULL },
4415 { NULL },
4416 },
Pete Hildebrandtc53d83c2009-08-05 11:46:38 -03004417 { "YUAN High-Tech STK7700D",
4418 { &dib0700_usb_id_table[54], NULL },
4419 { NULL },
4420 },
Piotr Oleszczyk430ae122017-02-01 18:26:42 -02004421 { "Hama DVB=T Hybrid USB Stick",
4422 { &dib0700_usb_id_table[85], NULL },
4423 { NULL },
4424 },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03004425 },
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004426
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004427 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004428 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004429 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004430 .module_name = "dib0700",
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03004431 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004432 .allowed_protos = RC_BIT_RC5 |
4433 RC_BIT_RC6_MCE |
4434 RC_BIT_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03004435 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004436 },
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03004437 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4438 .num_adapters = 1,
4439 .adapter = {
4440 {
Mauro Carvalho Chehab0fae1992015-05-13 18:51:19 -03004441 DIB0700_NUM_FRONTENDS(1),
Michael Krufky77eed212011-09-06 09:31:57 -03004442 .fe = {{
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03004443 .frontend_attach = s5h1411_frontend_attach,
4444 .tuner_attach = xc5000_tuner_attach,
4445
4446 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004447 }},
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03004448 },
4449 },
4450
Devin Heitmuellerd2fc3bf2008-09-25 06:22:23 -03004451 .num_device_descs = 2,
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03004452 .devices = {
4453 { "Pinnacle PCTV HD Pro USB Stick",
4454 { &dib0700_usb_id_table[40], NULL },
4455 { NULL },
4456 },
Devin Heitmuellerd2fc3bf2008-09-25 06:22:23 -03004457 { "Pinnacle PCTV HD USB Stick",
4458 { &dib0700_usb_id_table[41], NULL },
4459 { NULL },
4460 },
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03004461 },
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004462
4463 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004464 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004465 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004466 .module_name = "dib0700",
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03004467 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004468 .allowed_protos = RC_BIT_RC5 |
4469 RC_BIT_RC6_MCE |
4470 RC_BIT_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03004471 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004472 },
Michael Krufkyce904bc2009-01-19 01:12:55 -03004473 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4474 .num_adapters = 1,
4475 .adapter = {
4476 {
Mauro Carvalho Chehab0fae1992015-05-13 18:51:19 -03004477 DIB0700_NUM_FRONTENDS(1),
Michael Krufky77eed212011-09-06 09:31:57 -03004478 .fe = {{
Michael Krufkyce904bc2009-01-19 01:12:55 -03004479 .frontend_attach = lgdt3305_frontend_attach,
4480 .tuner_attach = mxl5007t_tuner_attach,
4481
4482 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004483 }},
Michael Krufkyce904bc2009-01-19 01:12:55 -03004484 },
4485 },
4486
4487 .num_device_descs = 2,
4488 .devices = {
4489 { "Hauppauge ATSC MiniCard (B200)",
4490 { &dib0700_usb_id_table[46], NULL },
4491 { NULL },
4492 },
4493 { "Hauppauge ATSC MiniCard (B210)",
4494 { &dib0700_usb_id_table[47], NULL },
4495 { NULL },
4496 },
4497 },
Olivier Grenied300bd62009-09-15 06:55:35 -03004498 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4499
4500 .num_adapters = 1,
4501 .adapter = {
4502 {
Mauro Carvalho Chehab0fae1992015-05-13 18:51:19 -03004503 DIB0700_NUM_FRONTENDS(1),
Michael Krufky77eed212011-09-06 09:31:57 -03004504 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03004505 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4506 .pid_filter_count = 32,
4507 .pid_filter = stk70x0p_pid_filter,
4508 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
Olivier Grenie90e12ce2010-09-07 12:50:45 -03004509 .frontend_attach = stk7770p_frontend_attach,
Olivier Grenied300bd62009-09-15 06:55:35 -03004510 .tuner_attach = dib7770p_tuner_attach,
4511
4512 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004513 }},
Olivier Grenied300bd62009-09-15 06:55:35 -03004514 },
4515 },
4516
Stéphane Elmalehd1402302011-05-21 07:33:38 -03004517 .num_device_descs = 4,
Olivier Grenied300bd62009-09-15 06:55:35 -03004518 .devices = {
4519 { "DiBcom STK7770P reference design",
4520 { &dib0700_usb_id_table[59], NULL },
4521 { NULL },
4522 },
Patrick Boettcher1e13c8f2009-09-19 05:24:40 -03004523 { "Terratec Cinergy T USB XXS (HD)/ T3",
4524 { &dib0700_usb_id_table[33],
4525 &dib0700_usb_id_table[52],
4526 &dib0700_usb_id_table[60], NULL},
Patrick Boettcherdb481382009-09-15 07:16:51 -03004527 { NULL },
4528 },
Lukas Max Fisch498e6772011-02-08 16:51:45 -03004529 { "TechniSat AirStar TeleStick 2",
4530 { &dib0700_usb_id_table[74], NULL },
4531 { NULL },
4532 },
Stéphane Elmalehd1402302011-05-21 07:33:38 -03004533 { "Medion CTX1921 DVB-T USB",
4534 { &dib0700_usb_id_table[75], NULL },
4535 { NULL },
4536 },
Olivier Grenied300bd62009-09-15 06:55:35 -03004537 },
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004538
4539 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004540 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004541 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004542 .module_name = "dib0700",
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03004543 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004544 .allowed_protos = RC_BIT_RC5 |
4545 RC_BIT_RC6_MCE |
4546 RC_BIT_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03004547 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004548 },
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03004549 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4550 .num_adapters = 1,
4551 .adapter = {
4552 {
Mauro Carvalho Chehab0fae1992015-05-13 18:51:19 -03004553 DIB0700_NUM_FRONTENDS(1),
Michael Krufky77eed212011-09-06 09:31:57 -03004554 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03004555 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4556 .pid_filter_count = 32,
Olivier Grenie03245a52009-12-04 13:27:57 -03004557 .pid_filter = stk80xx_pid_filter,
4558 .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03004559 .frontend_attach = stk807x_frontend_attach,
4560 .tuner_attach = dib807x_tuner_attach,
4561
4562 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004563 }},
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03004564 },
4565 },
4566
S?rgio Fortier8a378e82009-09-28 04:19:21 -03004567 .num_device_descs = 3,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03004568 .devices = {
4569 { "DiBcom STK807xP reference design",
4570 { &dib0700_usb_id_table[62], NULL },
4571 { NULL },
4572 },
Mauro Carvalho Chehabaaeab302009-09-16 09:18:26 -03004573 { "Prolink Pixelview SBTVD",
4574 { &dib0700_usb_id_table[63], NULL },
4575 { NULL },
4576 },
S?rgio Fortier8a378e82009-09-28 04:19:21 -03004577 { "EvolutePC TVWay+",
4578 { &dib0700_usb_id_table[64], NULL },
4579 { NULL },
4580 },
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03004581 },
4582
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004583 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004584 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004585 .rc_codes = RC_MAP_DIB0700_NEC_TABLE,
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004586 .module_name = "dib0700",
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03004587 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004588 .allowed_protos = RC_BIT_RC5 |
4589 RC_BIT_RC6_MCE |
4590 RC_BIT_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03004591 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004592 },
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03004593 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4594 .num_adapters = 2,
4595 .adapter = {
4596 {
Mauro Carvalho Chehab0fae1992015-05-13 18:51:19 -03004597 DIB0700_NUM_FRONTENDS(1),
Michael Krufky77eed212011-09-06 09:31:57 -03004598 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03004599 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4600 .pid_filter_count = 32,
Olivier Grenie03245a52009-12-04 13:27:57 -03004601 .pid_filter = stk80xx_pid_filter,
4602 .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03004603 .frontend_attach = stk807xpvr_frontend_attach0,
4604 .tuner_attach = dib807x_tuner_attach,
4605
4606 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004607 }},
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03004608 },
4609 {
Mauro Carvalho Chehab0fae1992015-05-13 18:51:19 -03004610 DIB0700_NUM_FRONTENDS(1),
Michael Krufky77eed212011-09-06 09:31:57 -03004611 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03004612 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4613 .pid_filter_count = 32,
Olivier Grenie03245a52009-12-04 13:27:57 -03004614 .pid_filter = stk80xx_pid_filter,
4615 .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03004616 .frontend_attach = stk807xpvr_frontend_attach1,
4617 .tuner_attach = dib807x_tuner_attach,
4618
4619 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
Michael Krufky77eed212011-09-06 09:31:57 -03004620 }},
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03004621 },
4622 },
4623
4624 .num_device_descs = 1,
4625 .devices = {
4626 { "DiBcom STK807xPVR reference design",
4627 { &dib0700_usb_id_table[61], NULL },
4628 { NULL },
4629 },
4630 },
4631
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004632 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004633 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004634 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004635 .module_name = "dib0700",
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03004636 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004637 .allowed_protos = RC_BIT_RC5 |
4638 RC_BIT_RC6_MCE |
4639 RC_BIT_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03004640 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004641 },
Olivier Grenie03245a52009-12-04 13:27:57 -03004642 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4643 .num_adapters = 1,
4644 .adapter = {
4645 {
Mauro Carvalho Chehab0fae1992015-05-13 18:51:19 -03004646 DIB0700_NUM_FRONTENDS(1),
Michael Krufky77eed212011-09-06 09:31:57 -03004647 .fe = {{
Olivier Grenie03245a52009-12-04 13:27:57 -03004648 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
4649 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4650 .pid_filter_count = 32,
4651 .pid_filter = stk80xx_pid_filter,
4652 .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
4653 .frontend_attach = stk809x_frontend_attach,
4654 .tuner_attach = dib809x_tuner_attach,
4655
4656 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004657 }},
Olivier Grenie03245a52009-12-04 13:27:57 -03004658 },
4659 },
4660
4661 .num_device_descs = 1,
4662 .devices = {
4663 { "DiBcom STK8096GP reference design",
4664 { &dib0700_usb_id_table[67], NULL },
4665 { NULL },
4666 },
4667 },
4668
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004669 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004670 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004671 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004672 .module_name = "dib0700",
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03004673 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004674 .allowed_protos = RC_BIT_RC5 |
4675 RC_BIT_RC6_MCE |
4676 RC_BIT_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03004677 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004678 },
Olivier Greniebe9bae12011-01-04 05:42:19 -03004679 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4680 .num_adapters = 1,
4681 .adapter = {
4682 {
Mauro Carvalho Chehab0fae1992015-05-13 18:51:19 -03004683 DIB0700_NUM_FRONTENDS(1),
Michael Krufky77eed212011-09-06 09:31:57 -03004684 .fe = {{
Olivier Greniebe9bae12011-01-04 05:42:19 -03004685 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
4686 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4687 .pid_filter_count = 32,
4688 .pid_filter = dib90x0_pid_filter,
4689 .pid_filter_ctrl = dib90x0_pid_filter_ctrl,
4690 .frontend_attach = stk9090m_frontend_attach,
4691 .tuner_attach = dib9090_tuner_attach,
4692
4693 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004694 }},
Olivier Greniebe9bae12011-01-04 05:42:19 -03004695 },
4696 },
4697
4698 .num_device_descs = 1,
4699 .devices = {
4700 { "DiBcom STK9090M reference design",
4701 { &dib0700_usb_id_table[69], 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 {
Mauro Carvalho Chehab0fae1992015-05-13 18:51:19 -03004720 DIB0700_NUM_FRONTENDS(1),
Michael Krufky77eed212011-09-06 09:31:57 -03004721 .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 = stk80xx_pid_filter,
4726 .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
4727 .frontend_attach = nim8096md_frontend_attach,
4728 .tuner_attach = nim8096md_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 },
4733 },
4734
4735 .num_device_descs = 1,
4736 .devices = {
4737 { "DiBcom NIM8096MD reference design",
4738 { &dib0700_usb_id_table[70], NULL },
4739 { NULL },
4740 },
4741 },
4742
4743 .rc.core = {
4744 .rc_interval = DEFAULT_RC_INTERVAL,
4745 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4746 .module_name = "dib0700",
4747 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004748 .allowed_protos = RC_BIT_RC5 |
4749 RC_BIT_RC6_MCE |
4750 RC_BIT_NEC,
Olivier Greniebe9bae12011-01-04 05:42:19 -03004751 .change_protocol = dib0700_change_protocol,
4752 },
4753 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4754 .num_adapters = 1,
4755 .adapter = {
4756 {
Mauro Carvalho Chehab0fae1992015-05-13 18:51:19 -03004757 DIB0700_NUM_FRONTENDS(1),
Michael Krufky77eed212011-09-06 09:31:57 -03004758 .fe = {{
Olivier Greniebe9bae12011-01-04 05:42:19 -03004759 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
4760 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4761 .pid_filter_count = 32,
4762 .pid_filter = dib90x0_pid_filter,
4763 .pid_filter_ctrl = dib90x0_pid_filter_ctrl,
4764 .frontend_attach = nim9090md_frontend_attach,
4765 .tuner_attach = nim9090md_tuner_attach,
4766
4767 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004768 }},
Olivier Greniebe9bae12011-01-04 05:42:19 -03004769 },
4770 },
4771
4772 .num_device_descs = 1,
4773 .devices = {
4774 { "DiBcom NIM9090MD reference design",
4775 { &dib0700_usb_id_table[71], NULL },
4776 { NULL },
4777 },
4778 },
4779
4780 .rc.core = {
4781 .rc_interval = DEFAULT_RC_INTERVAL,
4782 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4783 .module_name = "dib0700",
4784 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004785 .allowed_protos = RC_BIT_RC5 |
4786 RC_BIT_RC6_MCE |
4787 RC_BIT_NEC,
Olivier Greniebe9bae12011-01-04 05:42:19 -03004788 .change_protocol = dib0700_change_protocol,
4789 },
4790 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4791 .num_adapters = 1,
4792 .adapter = {
4793 {
Mauro Carvalho Chehab0fae1992015-05-13 18:51:19 -03004794 DIB0700_NUM_FRONTENDS(1),
Michael Krufky77eed212011-09-06 09:31:57 -03004795 .fe = {{
Olivier Greniebe9bae12011-01-04 05:42:19 -03004796 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
4797 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4798 .pid_filter_count = 32,
4799 .pid_filter = stk70x0p_pid_filter,
4800 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
4801 .frontend_attach = nim7090_frontend_attach,
4802 .tuner_attach = nim7090_tuner_attach,
4803
4804 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004805 }},
Olivier Greniebe9bae12011-01-04 05:42:19 -03004806 },
4807 },
4808
4809 .num_device_descs = 1,
4810 .devices = {
4811 { "DiBcom NIM7090 reference design",
4812 { &dib0700_usb_id_table[72], NULL },
4813 { NULL },
4814 },
4815 },
4816
4817 .rc.core = {
4818 .rc_interval = DEFAULT_RC_INTERVAL,
4819 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4820 .module_name = "dib0700",
4821 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004822 .allowed_protos = RC_BIT_RC5 |
4823 RC_BIT_RC6_MCE |
4824 RC_BIT_NEC,
Olivier Greniebe9bae12011-01-04 05:42:19 -03004825 .change_protocol = dib0700_change_protocol,
4826 },
4827 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4828 .num_adapters = 2,
4829 .adapter = {
4830 {
Mauro Carvalho Chehab0fae1992015-05-13 18:51:19 -03004831 DIB0700_NUM_FRONTENDS(1),
Michael Krufky77eed212011-09-06 09:31:57 -03004832 .fe = {{
Olivier Greniebe9bae12011-01-04 05:42:19 -03004833 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
4834 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4835 .pid_filter_count = 32,
4836 .pid_filter = stk70x0p_pid_filter,
4837 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
4838 .frontend_attach = tfe7090pvr_frontend0_attach,
4839 .tuner_attach = tfe7090pvr_tuner0_attach,
4840
4841 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
Michael Krufky77eed212011-09-06 09:31:57 -03004842 }},
Olivier Greniebe9bae12011-01-04 05:42:19 -03004843 },
4844 {
Mauro Carvalho Chehab0fae1992015-05-13 18:51:19 -03004845 DIB0700_NUM_FRONTENDS(1),
Michael Krufky77eed212011-09-06 09:31:57 -03004846 .fe = {{
Olivier Greniebe9bae12011-01-04 05:42:19 -03004847 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
4848 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4849 .pid_filter_count = 32,
4850 .pid_filter = stk70x0p_pid_filter,
4851 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
4852 .frontend_attach = tfe7090pvr_frontend1_attach,
4853 .tuner_attach = tfe7090pvr_tuner1_attach,
4854
4855 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004856 }},
Olivier Greniebe9bae12011-01-04 05:42:19 -03004857 },
4858 },
4859
4860 .num_device_descs = 1,
4861 .devices = {
4862 { "DiBcom TFE7090PVR reference design",
4863 { &dib0700_usb_id_table[73], NULL },
4864 { NULL },
4865 },
4866 },
4867
4868 .rc.core = {
4869 .rc_interval = DEFAULT_RC_INTERVAL,
4870 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4871 .module_name = "dib0700",
4872 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004873 .allowed_protos = RC_BIT_RC5 |
4874 RC_BIT_RC6_MCE |
4875 RC_BIT_NEC,
Olivier Greniebe9bae12011-01-04 05:42:19 -03004876 .change_protocol = dib0700_change_protocol,
4877 },
Davide Ferri8d009a02009-06-23 22:34:06 -03004878 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4879 .num_adapters = 1,
4880 .adapter = {
4881 {
Mauro Carvalho Chehab0fae1992015-05-13 18:51:19 -03004882 DIB0700_NUM_FRONTENDS(1),
Michael Krufky77eed212011-09-06 09:31:57 -03004883 .fe = {{
Devin Heitmueller01f16262009-06-24 00:07:01 -03004884 .frontend_attach = pctv340e_frontend_attach,
Davide Ferri8d009a02009-06-23 22:34:06 -03004885 .tuner_attach = xc4000_tuner_attach,
4886
4887 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004888 }},
Davide Ferri8d009a02009-06-23 22:34:06 -03004889 },
4890 },
4891
Devin Heitmueller33fb1682009-06-23 22:48:02 -03004892 .num_device_descs = 2,
Davide Ferri8d009a02009-06-23 22:34:06 -03004893 .devices = {
4894 { "Pinnacle PCTV 340e HD Pro USB Stick",
4895 { &dib0700_usb_id_table[76], NULL },
4896 { NULL },
4897 },
Devin Heitmueller33fb1682009-06-23 22:48:02 -03004898 { "Pinnacle PCTV Hybrid Stick Solo",
4899 { &dib0700_usb_id_table[77], NULL },
4900 { NULL },
4901 },
Davide Ferri8d009a02009-06-23 22:34:06 -03004902 },
4903 .rc.core = {
4904 .rc_interval = DEFAULT_RC_INTERVAL,
4905 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4906 .module_name = "dib0700",
4907 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004908 .allowed_protos = RC_BIT_RC5 |
4909 RC_BIT_RC6_MCE |
4910 RC_BIT_NEC,
Davide Ferri8d009a02009-06-23 22:34:06 -03004911 .change_protocol = dib0700_change_protocol,
4912 },
Olivier Grenie6724a2f2011-08-05 13:49:33 -03004913 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4914 .num_adapters = 1,
4915 .adapter = {
4916 {
Mauro Carvalho Chehab0fae1992015-05-13 18:51:19 -03004917 DIB0700_NUM_FRONTENDS(1),
Olivier Grenie6724a2f2011-08-05 13:49:33 -03004918 .fe = {{
4919 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
4920 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4921 .pid_filter_count = 32,
4922 .pid_filter = stk70x0p_pid_filter,
4923 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
Olivier Grenief45f5132012-12-31 09:47:10 -03004924 .frontend_attach = tfe7790p_frontend_attach,
4925 .tuner_attach = tfe7790p_tuner_attach,
Olivier Grenieb293f302011-08-09 04:48:25 -03004926
4927 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
4928 } },
Olivier Grenieb293f302011-08-09 04:48:25 -03004929 },
4930 },
4931
4932 .num_device_descs = 1,
4933 .devices = {
Olivier Grenief45f5132012-12-31 09:47:10 -03004934 { "DiBcom TFE7790P reference design",
4935 { &dib0700_usb_id_table[78], NULL },
Olivier Grenieb293f302011-08-09 04:48:25 -03004936 { NULL },
4937 },
4938 },
4939
4940 .rc.core = {
4941 .rc_interval = DEFAULT_RC_INTERVAL,
4942 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4943 .module_name = "dib0700",
4944 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004945 .allowed_protos = RC_BIT_RC5 |
4946 RC_BIT_RC6_MCE |
4947 RC_BIT_NEC,
Olivier Grenieb293f302011-08-09 04:48:25 -03004948 .change_protocol = dib0700_change_protocol,
4949 },
Olivier Grenie88f3a352011-08-10 05:28:38 -03004950 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4951 .num_adapters = 1,
4952 .adapter = {
4953 {
Mauro Carvalho Chehab0fae1992015-05-13 18:51:19 -03004954 DIB0700_NUM_FRONTENDS(1),
Olivier Grenie88f3a352011-08-10 05:28:38 -03004955 .fe = {{
4956 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
4957 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4958 .pid_filter_count = 32,
4959 .pid_filter = stk80xx_pid_filter,
4960 .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
4961 .frontend_attach = tfe8096p_frontend_attach,
4962 .tuner_attach = tfe8096p_tuner_attach,
4963
4964 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
4965
4966 } },
Olivier Grenie88f3a352011-08-10 05:28:38 -03004967 },
4968 },
4969
4970 .num_device_descs = 1,
4971 .devices = {
4972 { "DiBcom TFE8096P reference design",
Olivier Grenief45f5132012-12-31 09:47:10 -03004973 { &dib0700_usb_id_table[79], NULL },
Olivier Grenie88f3a352011-08-10 05:28:38 -03004974 { NULL },
4975 },
4976 },
4977
4978 .rc.core = {
4979 .rc_interval = DEFAULT_RC_INTERVAL,
4980 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4981 .module_name = "dib0700",
4982 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004983 .allowed_protos = RC_BIT_RC5 |
4984 RC_BIT_RC6_MCE |
4985 RC_BIT_NEC,
Olivier Grenie88f3a352011-08-10 05:28:38 -03004986 .change_protocol = dib0700_change_protocol,
4987 },
Nicolas Sugino91be2602015-11-26 19:00:28 -02004988 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4989 .num_adapters = 2,
4990 .adapter = {
4991 {
4992 .num_frontends = 1,
4993 .fe = {{
4994 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
4995 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4996 .pid_filter_count = 32,
4997 .pid_filter = stk80xx_pid_filter,
4998 .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
4999 .frontend_attach = stk809x_frontend_attach,
5000 .tuner_attach = dib809x_tuner_attach,
5001
5002 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
5003 } },
5004 .size_of_priv =
5005 sizeof(struct dib0700_adapter_state),
5006 }, {
5007 .num_frontends = 1,
5008 .fe = { {
5009 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
5010 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
5011 .pid_filter_count = 32,
5012 .pid_filter = stk80xx_pid_filter,
5013 .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
5014 .frontend_attach = stk809x_frontend1_attach,
5015 .tuner_attach = dib809x_tuner_attach,
5016
5017 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
5018 } },
5019 .size_of_priv =
5020 sizeof(struct dib0700_adapter_state),
5021 },
5022 },
5023 .num_device_descs = 1,
5024 .devices = {
5025 { "DiBcom STK8096-PVR reference design",
Alejandro Torradoec788792016-04-18 13:37:00 -03005026 { &dib0700_usb_id_table[83],
5027 &dib0700_usb_id_table[84], NULL},
Nicolas Sugino91be2602015-11-26 19:00:28 -02005028 { NULL },
5029 },
5030 },
5031
5032 .rc.core = {
5033 .rc_interval = DEFAULT_RC_INTERVAL,
5034 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
5035 .module_name = "dib0700",
5036 .rc_query = dib0700_rc_query_old_firmware,
5037 .allowed_protos = RC_BIT_RC5 |
5038 RC_BIT_RC6_MCE |
5039 RC_BIT_NEC,
5040 .change_protocol = dib0700_change_protocol,
5041 },
Patrick Boettcher01373a52007-07-30 12:49:04 -03005042 },
Patrick Boettcherb7f54912006-09-19 12:51:37 -03005043};
5044
5045int dib0700_device_count = ARRAY_SIZE(dib0700_devices);