blob: 292f0f14067094294d1b96bfc6ccb7d6d6483d6c [file] [log] [blame]
Patrick Boettcherb7f54912006-09-19 12:51:37 -03001/* Linux driver for devices based on the DiBcom DiB0700 USB bridge
2 *
3 * This program is free software; you can redistribute it and/or modify it
4 * under the terms of the GNU General Public License as published by the Free
5 * Software Foundation, version 2.
6 *
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03007 * Copyright (C) 2005-9 DiBcom, SA et al
Patrick Boettcherb7f54912006-09-19 12:51:37 -03008 */
9#include "dib0700.h"
10
11#include "dib3000mc.h"
Patrick Boettcher91bb9be2006-12-02 21:15:51 -020012#include "dib7000m.h"
Patrick Boettchera75763f2006-10-18 08:34:16 -030013#include "dib7000p.h"
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -030014#include "dib8000.h"
Olivier Greniebe9bae12011-01-04 05:42:19 -030015#include "dib9000.h"
Patrick Boettcherb7f54912006-09-19 12:51:37 -030016#include "mt2060.h"
Olivier DANET54d75eb2007-07-25 14:42:54 -030017#include "mt2266.h"
Albert Comerma6ca8f0b2008-03-29 21:35:57 -030018#include "tuner-xc2028.h"
Devin Heitmuellercb22cb52008-09-08 05:42:42 -030019#include "xc5000.h"
Davide Ferri8d009a02009-06-23 22:34:06 -030020#include "xc4000.h"
Devin Heitmuellercb22cb52008-09-08 05:42:42 -030021#include "s5h1411.h"
Patrick Boettcher01373a52007-07-30 12:49:04 -030022#include "dib0070.h"
Olivier Grenie03245a52009-12-04 13:27:57 -030023#include "dib0090.h"
Michael Krufkyce904bc2009-01-19 01:12:55 -030024#include "lgdt3305.h"
25#include "mxl5007t.h"
Patrick Boettcherb7f54912006-09-19 12:51:37 -030026
Patrick Boettcher7fb3fc02006-09-20 04:37:18 -030027static int force_lna_activation;
28module_param(force_lna_activation, int, 0644);
29MODULE_PARM_DESC(force_lna_activation, "force the activation of Low-Noise-Amplifyer(s) (LNA), "
30 "if applicable for the device (default: 0=automatic/off).");
31
Patrick Boettcher01373a52007-07-30 12:49:04 -030032struct dib0700_adapter_state {
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -030033 int (*set_param_save) (struct dvb_frontend *);
Olivier Greniebe9bae12011-01-04 05:42:19 -030034 const struct firmware *frontend_firmware;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -030035 struct dib7000p_ops dib7000p_ops;
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 = {
Olivier Grenie9c783032009-12-07 07:49:40 -0300222 60000, 30000,
223 1, 8, 3, 1, 0,
224 0, 0, 1, 1, 2,
225 (3 << 14) | (1 << 12) | (524 << 0),
226 0,
227 20452225,
Olivier DANET54d75eb2007-07-25 14:42:54 -0300228};
229
230static struct dib7000p_config stk7700d_dib7000p_mt2266_config[] = {
231 { .output_mpeg2_in_188_bytes = 1,
232 .hostbus_diversity = 1,
233 .tuner_is_baseband = 1,
234
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300235 .agc_config_count = 2,
236 .agc = stk7700d_7000p_mt2266_agc_config,
Olivier DANET54d75eb2007-07-25 14:42:54 -0300237 .bw = &stk7700d_mt2266_pll_config,
238
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300239 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
240 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
241 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
Olivier DANET54d75eb2007-07-25 14:42:54 -0300242 },
243 { .output_mpeg2_in_188_bytes = 1,
244 .hostbus_diversity = 1,
245 .tuner_is_baseband = 1,
246
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300247 .agc_config_count = 2,
248 .agc = stk7700d_7000p_mt2266_agc_config,
Olivier DANET54d75eb2007-07-25 14:42:54 -0300249 .bw = &stk7700d_mt2266_pll_config,
250
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300251 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
252 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
253 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
Olivier DANET54d75eb2007-07-25 14:42:54 -0300254 }
255};
256
257static struct mt2266_config stk7700d_mt2266_config[2] = {
258 { .i2c_address = 0x60
259 },
260 { .i2c_address = 0x60
261 }
262};
263
Daniel Gimpelevich132c3182008-01-25 06:02:42 -0300264static int stk7700P2_frontend_attach(struct dvb_usb_adapter *adap)
265{
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300266 struct dib0700_adapter_state *state = adap->priv;
267
268 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
269 return -ENODEV;
270
Daniel Gimpelevich132c3182008-01-25 06:02:42 -0300271 if (adap->id == 0) {
272 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
273 msleep(10);
274 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
275 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
276 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
277 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
278 msleep(10);
279 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
280 msleep(10);
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300281 if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 18,
Devin Heitmueller83c4fdf2009-01-21 01:55:45 -0300282 stk7700d_dib7000p_mt2266_config)
283 != 0) {
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300284 err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n", __func__);
285 dvb_detach(&state->dib7000p_ops);
Devin Heitmueller83c4fdf2009-01-21 01:55:45 -0300286 return -ENODEV;
287 }
Daniel Gimpelevich132c3182008-01-25 06:02:42 -0300288 }
289
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300290 adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap,
Michael Krufky2a776312011-09-16 09:26:59 -0300291 0x80 + (adap->id << 1),
292 &stk7700d_dib7000p_mt2266_config[adap->id]);
Daniel Gimpelevich132c3182008-01-25 06:02:42 -0300293
Michael Krufky77eed212011-09-06 09:31:57 -0300294 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Daniel Gimpelevich132c3182008-01-25 06:02:42 -0300295}
296
Olivier DANET54d75eb2007-07-25 14:42:54 -0300297static int stk7700d_frontend_attach(struct dvb_usb_adapter *adap)
298{
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300299 struct dib0700_adapter_state *state = adap->priv;
300
301 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
302 return -ENODEV;
303
Olivier DANET54d75eb2007-07-25 14:42:54 -0300304 if (adap->id == 0) {
305 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
306 msleep(10);
307 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
308 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
309 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
310 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
311 msleep(10);
312 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
313 msleep(10);
314 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300315 if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap, 2, 18,
Devin Heitmueller83c4fdf2009-01-21 01:55:45 -0300316 stk7700d_dib7000p_mt2266_config)
317 != 0) {
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300318 err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n", __func__);
319 dvb_detach(&state->dib7000p_ops);
Devin Heitmueller83c4fdf2009-01-21 01:55:45 -0300320 return -ENODEV;
321 }
Olivier DANET54d75eb2007-07-25 14:42:54 -0300322 }
323
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300324 adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap,
Michael Krufky2a776312011-09-16 09:26:59 -0300325 0x80 + (adap->id << 1),
326 &stk7700d_dib7000p_mt2266_config[adap->id]);
Olivier DANET54d75eb2007-07-25 14:42:54 -0300327
Michael Krufky77eed212011-09-06 09:31:57 -0300328 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Olivier DANET54d75eb2007-07-25 14:42:54 -0300329}
330
331static int stk7700d_tuner_attach(struct dvb_usb_adapter *adap)
332{
333 struct i2c_adapter *tun_i2c;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300334 struct dib0700_adapter_state *state = adap->priv;
335
336 tun_i2c = state->dib7000p_ops.get_i2c_master(adap->fe_adap[0].fe,
337 DIBX000_I2C_INTERFACE_TUNER, 1);
Michael Krufky77eed212011-09-06 09:31:57 -0300338 return dvb_attach(mt2266_attach, adap->fe_adap[0].fe, tun_i2c,
Joe Perches1ebcad72009-07-02 15:57:09 -0300339 &stk7700d_mt2266_config[adap->id]) == NULL ? -ENODEV : 0;
Olivier DANET54d75eb2007-07-25 14:42:54 -0300340}
341
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300342/* STK7700-PH: Digital/Analog Hybrid Tuner, e.h. Cinergy HT USB HE */
Harvey Harrisonb1721d02008-04-25 19:03:08 -0700343static struct dibx000_agc_config xc3028_agc_config = {
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300344 BAND_VHF | BAND_UHF, /* band_caps */
345
346 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=0,
347 * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
348 * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=2, P_agc_write=0 */
349 (0 << 15) | (0 << 14) | (0 << 11) | (0 << 10) | (0 << 9) | (0 << 8) |
350 (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0), /* setup */
351
352 712, /* inv_gain */
353 21, /* time_stabiliz */
354
355 0, /* alpha_level */
356 118, /* thlock */
357
358 0, /* wbd_inv */
359 2867, /* wbd_ref */
360 0, /* wbd_sel */
361 2, /* wbd_alpha */
362
363 0, /* agc1_max */
364 0, /* agc1_min */
365 39718, /* agc2_max */
366 9930, /* agc2_min */
367 0, /* agc1_pt1 */
368 0, /* agc1_pt2 */
369 0, /* agc1_pt3 */
370 0, /* agc1_slope1 */
371 0, /* agc1_slope2 */
372 0, /* agc2_pt1 */
373 128, /* agc2_pt2 */
374 29, /* agc2_slope1 */
375 29, /* agc2_slope2 */
376
377 17, /* alpha_mant */
378 27, /* alpha_exp */
379 23, /* beta_mant */
380 51, /* beta_exp */
381
382 1, /* perform_agc_softsplit */
383};
384
385/* PLL Configuration for COFDM BW_MHz = 8.00 with external clock = 30.00 */
Harvey Harrisonb1721d02008-04-25 19:03:08 -0700386static struct dibx000_bandwidth_config xc3028_bw_config = {
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300387 60000, 30000, /* internal, sampling */
388 1, 8, 3, 1, 0, /* pll_cfg: prediv, ratio, range, reset, bypass */
389 0, 0, 1, 1, 0, /* misc: refdiv, bypclk_div, IO_CLK_en_core, ADClkSrc,
390 modulo */
391 (3 << 14) | (1 << 12) | (524 << 0), /* sad_cfg: refsel, sel, freq_15k */
392 (1 << 25) | 5816102, /* ifreq = 5.200000 MHz */
393 20452225, /* timf */
394 30000000, /* xtal_hz */
395};
396
397static struct dib7000p_config stk7700ph_dib7700_xc3028_config = {
398 .output_mpeg2_in_188_bytes = 1,
399 .tuner_is_baseband = 1,
400
401 .agc_config_count = 1,
402 .agc = &xc3028_agc_config,
403 .bw = &xc3028_bw_config,
404
405 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
406 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
407 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
408};
409
Michael Krufkyd7cba042008-09-12 13:31:45 -0300410static int stk7700ph_xc3028_callback(void *ptr, int component,
411 int command, int arg)
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300412{
413 struct dvb_usb_adapter *adap = ptr;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300414 struct dib0700_adapter_state *state = adap->priv;
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300415
416 switch (command) {
417 case XC2028_TUNER_RESET:
418 /* Send the tuner in then out of reset */
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300419 state->dib7000p_ops.set_gpio(adap->fe_adap[0].fe, 8, 0, 0);
420 msleep(10);
421 state->dib7000p_ops.set_gpio(adap->fe_adap[0].fe, 8, 0, 1);
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300422 break;
423 case XC2028_RESET_CLK:
424 break;
425 default:
426 err("%s: unknown command %d, arg %d\n", __func__,
427 command, arg);
428 return -EINVAL;
429 }
430 return 0;
431}
432
433static struct xc2028_ctrl stk7700ph_xc3028_ctrl = {
434 .fname = XC2028_DEFAULT_FIRMWARE,
435 .max_len = 64,
436 .demod = XC3028_FE_DIBCOM52,
437};
438
439static struct xc2028_config stk7700ph_xc3028_config = {
440 .i2c_addr = 0x61,
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300441 .ctrl = &stk7700ph_xc3028_ctrl,
442};
443
444static int stk7700ph_frontend_attach(struct dvb_usb_adapter *adap)
445{
446 struct usb_device_descriptor *desc = &adap->dev->udev->descriptor;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300447 struct dib0700_adapter_state *state = adap->priv;
448
449 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
450 return -ENODEV;
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300451
Al Viroda5ee482008-05-21 00:31:21 -0300452 if (desc->idVendor == cpu_to_le16(USB_VID_PINNACLE) &&
453 desc->idProduct == cpu_to_le16(USB_PID_PINNACLE_EXPRESSCARD_320CX))
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300454 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300455 else
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300456 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300457 msleep(20);
458 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
459 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
460 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
461 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
462 msleep(10);
463 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
464 msleep(20);
465 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
466 msleep(10);
467
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300468 if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 18,
Devin Heitmueller83c4fdf2009-01-21 01:55:45 -0300469 &stk7700ph_dib7700_xc3028_config) != 0) {
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300470 err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n",
Devin Heitmueller83c4fdf2009-01-21 01:55:45 -0300471 __func__);
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300472 dvb_detach(&state->dib7000p_ops);
Devin Heitmueller83c4fdf2009-01-21 01:55:45 -0300473 return -ENODEV;
474 }
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300475
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300476 adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap, 0x80,
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300477 &stk7700ph_dib7700_xc3028_config);
478
Michael Krufky77eed212011-09-06 09:31:57 -0300479 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300480}
481
482static int stk7700ph_tuner_attach(struct dvb_usb_adapter *adap)
483{
484 struct i2c_adapter *tun_i2c;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300485 struct dib0700_adapter_state *state = adap->priv;
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300486
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300487 tun_i2c = state->dib7000p_ops.get_i2c_master(adap->fe_adap[0].fe,
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300488 DIBX000_I2C_INTERFACE_TUNER, 1);
489
490 stk7700ph_xc3028_config.i2c_adap = tun_i2c;
Michael Krufkyd7cba042008-09-12 13:31:45 -0300491
492 /* FIXME: generalize & move to common area */
Michael Krufky77eed212011-09-06 09:31:57 -0300493 adap->fe_adap[0].fe->callback = stk7700ph_xc3028_callback;
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300494
Michael Krufky77eed212011-09-06 09:31:57 -0300495 return dvb_attach(xc2028_attach, adap->fe_adap[0].fe, &stk7700ph_xc3028_config)
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300496 == NULL ? -ENODEV : 0;
497}
498
Devin Heitmueller4b330be2008-12-01 06:51:14 -0300499#define DEFAULT_RC_INTERVAL 50
Olivier DANET54d75eb2007-07-25 14:42:54 -0300500
501static u8 rc_request[] = { REQUEST_POLL_RC, 0 };
502
Patrick Boettcher58e6f952008-03-29 21:37:01 -0300503/* Number of keypresses to ignore before start repeating */
Devin Heitmueller4b330be2008-12-01 06:51:14 -0300504#define RC_REPEAT_DELAY 6
Patrick Boettcher58e6f952008-03-29 21:37:01 -0300505
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -0300506/*
507 * This function is used only when firmware is < 1.20 version. Newer
508 * firmwares use bulk mode, with functions implemented at dib0700_core,
509 * at dib0700_rc_urb_completion()
510 */
511static int dib0700_rc_query_old_firmware(struct dvb_usb_device *d)
Olivier DANET54d75eb2007-07-25 14:42:54 -0300512{
513 u8 key[4];
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -0300514 u32 keycode;
515 u8 toggle;
Olivier DANET54d75eb2007-07-25 14:42:54 -0300516 int i;
Olivier DANET54d75eb2007-07-25 14:42:54 -0300517 struct dib0700_state *st = d->priv;
Devin Heitmueller6a207102010-01-04 02:43:19 -0300518
Devin Heitmueller6a207102010-01-04 02:43:19 -0300519 if (st->fw_version >= 0x10200) {
520 /* For 1.20 firmware , We need to keep the RC polling
521 callback so we can reuse the input device setup in
522 dvb-usb-remote.c. However, the actual work is being done
523 in the bulk URB completion handler. */
524 return 0;
525 }
526
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -0300527 i = dib0700_ctrl_rd(d, rc_request, 2, key, 4);
528 if (i <= 0) {
Janne Grunau034d65e2007-07-31 08:48:40 -0300529 err("RC Query Failed");
Janne Grunau89f42672007-07-31 19:45:13 -0300530 return -1;
Olivier DANET54d75eb2007-07-25 14:42:54 -0300531 }
Patrick Boettcher58e6f952008-03-29 21:37:01 -0300532
533 /* losing half of KEY_0 events from Philipps rc5 remotes.. */
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -0300534 if (key[0] == 0 && key[1] == 0 && key[2] == 0 && key[3] == 0)
535 return 0;
Patrick Boettcher58e6f952008-03-29 21:37:01 -0300536
537 /* info("%d: %2X %2X %2X %2X",dvb_usb_dib0700_ir_proto,(int)key[3-2],(int)key[3-3],(int)key[3-1],(int)key[3]); */
538
Mauro Carvalho Chehabc4018fa2014-05-21 17:40:25 -0300539 dib0700_rc_setup(d, NULL); /* reset ir sensor data to prevent false events */
Patrick Boettcher58e6f952008-03-29 21:37:01 -0300540
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -0300541 d->last_event = 0;
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -0300542 switch (d->props.rc.core.protocol) {
David Härdemanc003ab12012-10-11 19:11:54 -0300543 case RC_BIT_NEC:
Patrick Boettcher58e6f952008-03-29 21:37:01 -0300544 /* NEC protocol sends repeat code as 0 0 0 FF */
545 if ((key[3-2] == 0x00) && (key[3-3] == 0x00) &&
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -0300546 (key[3] == 0xff))
547 keycode = d->last_event;
548 else {
549 keycode = key[3-2] << 8 | key[3-3];
550 d->last_event = keycode;
Patrick Boettcher58e6f952008-03-29 21:37:01 -0300551 }
Patrick Boettcher58e6f952008-03-29 21:37:01 -0300552
Mauro Carvalho Chehabca866742010-11-17 13:53:11 -0300553 rc_keydown(d->rc_dev, keycode, 0);
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -0300554 break;
555 default:
556 /* RC-5 protocol changes toggle bit on new keypress */
557 keycode = key[3-2] << 8 | key[3-3];
558 toggle = key[3-1];
Mauro Carvalho Chehabca866742010-11-17 13:53:11 -0300559 rc_keydown(d->rc_dev, keycode, toggle);
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -0300560
Patrick Boettcher58e6f952008-03-29 21:37:01 -0300561 break;
562 }
Olivier DANET54d75eb2007-07-25 14:42:54 -0300563 return 0;
564}
565
Patrick Boettcherb7f54912006-09-19 12:51:37 -0300566/* STK7700P: Hauppauge Nova-T Stick, AVerMedia Volar */
Patrick Boettchera75763f2006-10-18 08:34:16 -0300567static struct dibx000_agc_config stk7700p_7000m_mt2060_agc_config = {
Olivier Grenie9c783032009-12-07 07:49:40 -0300568 BAND_UHF | BAND_VHF,
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300569
570 /* 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,
571 * 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 -0300572 (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8)
573 | (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0),
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300574
Olivier Grenie9c783032009-12-07 07:49:40 -0300575 712,
576 41,
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300577
Olivier Grenie9c783032009-12-07 07:49:40 -0300578 0,
579 118,
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300580
Olivier Grenie9c783032009-12-07 07:49:40 -0300581 0,
582 4095,
583 0,
584 0,
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300585
Olivier Grenie9c783032009-12-07 07:49:40 -0300586 42598,
587 17694,
588 45875,
589 2621,
590 0,
591 76,
592 139,
593 52,
594 59,
595 107,
596 172,
597 57,
598 70,
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300599
Olivier Grenie9c783032009-12-07 07:49:40 -0300600 21,
601 25,
602 28,
603 48,
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300604
Olivier Grenie9c783032009-12-07 07:49:40 -0300605 1,
606 { 0,
607 107,
608 51800,
609 24700
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300610 },
Patrick Boettcherb7f54912006-09-19 12:51:37 -0300611};
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300612
Patrick Boettchera75763f2006-10-18 08:34:16 -0300613static struct dibx000_agc_config stk7700p_7000p_mt2060_agc_config = {
614 BAND_UHF | BAND_VHF,
615
616 /* 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,
617 * 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 -0300618 (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8)
619 | (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0),
Patrick Boettchera75763f2006-10-18 08:34:16 -0300620
Olivier Grenie9c783032009-12-07 07:49:40 -0300621 712,
622 41,
Patrick Boettchera75763f2006-10-18 08:34:16 -0300623
Olivier Grenie9c783032009-12-07 07:49:40 -0300624 0,
625 118,
Patrick Boettchera75763f2006-10-18 08:34:16 -0300626
Olivier Grenie9c783032009-12-07 07:49:40 -0300627 0,
628 4095,
629 0,
630 0,
Patrick Boettchera75763f2006-10-18 08:34:16 -0300631
Olivier Grenie9c783032009-12-07 07:49:40 -0300632 42598,
633 16384,
634 42598,
635 0,
Patrick Boettchera75763f2006-10-18 08:34:16 -0300636
Olivier Grenie9c783032009-12-07 07:49:40 -0300637 0,
638 137,
639 255,
Patrick Boettchera75763f2006-10-18 08:34:16 -0300640
Olivier Grenie9c783032009-12-07 07:49:40 -0300641 0,
642 255,
Patrick Boettchera75763f2006-10-18 08:34:16 -0300643
Olivier Grenie9c783032009-12-07 07:49:40 -0300644 0,
645 0,
Patrick Boettchera75763f2006-10-18 08:34:16 -0300646
Olivier Grenie9c783032009-12-07 07:49:40 -0300647 0,
648 41,
Patrick Boettchera75763f2006-10-18 08:34:16 -0300649
Olivier Grenie9c783032009-12-07 07:49:40 -0300650 15,
651 25,
Patrick Boettchera75763f2006-10-18 08:34:16 -0300652
Olivier Grenie9c783032009-12-07 07:49:40 -0300653 28,
654 48,
Patrick Boettchera75763f2006-10-18 08:34:16 -0300655
Olivier Grenie9c783032009-12-07 07:49:40 -0300656 0,
Patrick Boettchera75763f2006-10-18 08:34:16 -0300657};
658
659static struct dibx000_bandwidth_config stk7700p_pll_config = {
Olivier Grenie9c783032009-12-07 07:49:40 -0300660 60000, 30000,
661 1, 8, 3, 1, 0,
662 0, 0, 1, 1, 0,
663 (3 << 14) | (1 << 12) | (524 << 0),
664 60258167,
665 20452225,
666 30000000,
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300667};
668
669static struct dib7000m_config stk7700p_dib7000m_config = {
670 .dvbt_mode = 1,
671 .output_mpeg2_in_188_bytes = 1,
672 .quartz_direct = 1,
673
674 .agc_config_count = 1,
Patrick Boettchera75763f2006-10-18 08:34:16 -0300675 .agc = &stk7700p_7000m_mt2060_agc_config,
676 .bw = &stk7700p_pll_config,
677
678 .gpio_dir = DIB7000M_GPIO_DEFAULT_DIRECTIONS,
679 .gpio_val = DIB7000M_GPIO_DEFAULT_VALUES,
680 .gpio_pwm_pos = DIB7000M_GPIO_DEFAULT_PWM_POS,
681};
682
683static struct dib7000p_config stk7700p_dib7000p_config = {
684 .output_mpeg2_in_188_bytes = 1,
685
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300686 .agc_config_count = 1,
Patrick Boettchera75763f2006-10-18 08:34:16 -0300687 .agc = &stk7700p_7000p_mt2060_agc_config,
688 .bw = &stk7700p_pll_config,
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300689
690 .gpio_dir = DIB7000M_GPIO_DEFAULT_DIRECTIONS,
691 .gpio_val = DIB7000M_GPIO_DEFAULT_VALUES,
692 .gpio_pwm_pos = DIB7000M_GPIO_DEFAULT_PWM_POS,
693};
Patrick Boettcherb7f54912006-09-19 12:51:37 -0300694
695static int stk7700p_frontend_attach(struct dvb_usb_adapter *adap)
696{
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300697 struct dib0700_state *st = adap->dev->priv;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300698 struct dib0700_adapter_state *state = adap->priv;
699
700 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
701 return -ENODEV;
702
Patrick Boettcherb7f54912006-09-19 12:51:37 -0300703 /* unless there is no real power management in DVB - we leave the device on GPIO6 */
Patrick Boettchera75763f2006-10-18 08:34:16 -0300704
705 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
706 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0); msleep(50);
707
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300708 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1); msleep(10);
Patrick Boettchera75763f2006-10-18 08:34:16 -0300709 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
710
Patrick Boettcherb7f54912006-09-19 12:51:37 -0300711 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0); msleep(10);
Patrick Boettchera75763f2006-10-18 08:34:16 -0300712 dib0700_ctrl_clock(adap->dev, 72, 1);
713 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1); msleep(100);
714
715 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
Patrick Boettcherb7f54912006-09-19 12:51:37 -0300716
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300717 st->mt2060_if1[0] = 1220;
Patrick Boettchera75763f2006-10-18 08:34:16 -0300718
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300719 if (state->dib7000p_ops.dib7000pc_detection(&adap->dev->i2c_adap)) {
720 adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap, 18, &stk7700p_dib7000p_config);
Patrick Boettchera75763f2006-10-18 08:34:16 -0300721 st->is_dib7000pc = 1;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300722 } else {
723 dvb_detach(&state->dib7000p_ops);
724 memset(&state->dib7000p_ops, 0, sizeof(state->dib7000p_ops));
Michael Krufky77eed212011-09-06 09:31:57 -0300725 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 -0300726 }
Patrick Boettchera75763f2006-10-18 08:34:16 -0300727
Michael Krufky77eed212011-09-06 09:31:57 -0300728 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Patrick Boettcherb7f54912006-09-19 12:51:37 -0300729}
730
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300731static struct mt2060_config stk7700p_mt2060_config = {
732 0x60
733};
734
Patrick Boettcherb7f54912006-09-19 12:51:37 -0300735static int stk7700p_tuner_attach(struct dvb_usb_adapter *adap)
736{
Olivier DANETc52344f2008-01-25 06:50:07 -0300737 struct i2c_adapter *prim_i2c = &adap->dev->i2c_adap;
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300738 struct dib0700_state *st = adap->dev->priv;
Patrick Boettchera75763f2006-10-18 08:34:16 -0300739 struct i2c_adapter *tun_i2c;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300740 struct dib0700_adapter_state *state = adap->priv;
Olivier DANETc52344f2008-01-25 06:50:07 -0300741 s8 a;
742 int if1=1220;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300743
Al Viroda5ee482008-05-21 00:31:21 -0300744 if (adap->dev->udev->descriptor.idVendor == cpu_to_le16(USB_VID_HAUPPAUGE) &&
745 adap->dev->udev->descriptor.idProduct == cpu_to_le16(USB_PID_HAUPPAUGE_NOVA_T_STICK)) {
Olivier DANETc52344f2008-01-25 06:50:07 -0300746 if (!eeprom_read(prim_i2c,0x58,&a)) if1=1220+a;
747 }
Patrick Boettchera75763f2006-10-18 08:34:16 -0300748 if (st->is_dib7000pc)
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300749 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 -0300750 else
Michael Krufky77eed212011-09-06 09:31:57 -0300751 tun_i2c = dib7000m_get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_TUNER, 1);
Patrick Boettchera75763f2006-10-18 08:34:16 -0300752
Michael Krufky77eed212011-09-06 09:31:57 -0300753 return dvb_attach(mt2060_attach, adap->fe_adap[0].fe, tun_i2c, &stk7700p_mt2060_config,
Olivier DANETc52344f2008-01-25 06:50:07 -0300754 if1) == NULL ? -ENODEV : 0;
Patrick Boettcherb7f54912006-09-19 12:51:37 -0300755}
756
Patrick Boettcher01373a52007-07-30 12:49:04 -0300757/* DIB7070 generic */
758static struct dibx000_agc_config dib7070_agc_config = {
759 BAND_UHF | BAND_VHF | BAND_LBAND | BAND_SBAND,
760 /* 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,
761 * P_agc_inh_dc_rv_est=0, P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5, P_agc_write=0 */
Olivier Grenie9c783032009-12-07 07:49:40 -0300762 (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8)
763 | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),
Patrick Boettcher01373a52007-07-30 12:49:04 -0300764
Olivier Grenie9c783032009-12-07 07:49:40 -0300765 600,
766 10,
Patrick Boettcher01373a52007-07-30 12:49:04 -0300767
Olivier Grenie9c783032009-12-07 07:49:40 -0300768 0,
769 118,
Patrick Boettcher01373a52007-07-30 12:49:04 -0300770
Olivier Grenie9c783032009-12-07 07:49:40 -0300771 0,
772 3530,
773 1,
774 5,
Patrick Boettcher01373a52007-07-30 12:49:04 -0300775
Olivier Grenie9c783032009-12-07 07:49:40 -0300776 65535,
777 0,
Patrick Boettcher01373a52007-07-30 12:49:04 -0300778
Olivier Grenie9c783032009-12-07 07:49:40 -0300779 65535,
780 0,
Patrick Boettcher01373a52007-07-30 12:49:04 -0300781
Olivier Grenie9c783032009-12-07 07:49:40 -0300782 0,
783 40,
784 183,
785 206,
786 255,
787 72,
788 152,
789 88,
790 90,
Patrick Boettcher01373a52007-07-30 12:49:04 -0300791
Olivier Grenie9c783032009-12-07 07:49:40 -0300792 17,
793 27,
794 23,
795 51,
Patrick Boettcher01373a52007-07-30 12:49:04 -0300796
Olivier Grenie9c783032009-12-07 07:49:40 -0300797 0,
Patrick Boettcher01373a52007-07-30 12:49:04 -0300798};
799
800static int dib7070_tuner_reset(struct dvb_frontend *fe, int onoff)
801{
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300802 struct dvb_usb_adapter *adap = fe->dvb->priv;
803 struct dib0700_adapter_state *state = adap->priv;
804
Patrick Boettcher7e5ce652009-08-03 13:43:40 -0300805 deb_info("reset: %d", onoff);
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300806 return state->dib7000p_ops.set_gpio(fe, 8, 0, !onoff);
Patrick Boettcher01373a52007-07-30 12:49:04 -0300807}
808
809static int dib7070_tuner_sleep(struct dvb_frontend *fe, int onoff)
810{
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300811 struct dvb_usb_adapter *adap = fe->dvb->priv;
812 struct dib0700_adapter_state *state = adap->priv;
813
Patrick Boettcher7e5ce652009-08-03 13:43:40 -0300814 deb_info("sleep: %d", onoff);
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300815 return state->dib7000p_ops.set_gpio(fe, 9, 0, onoff);
Patrick Boettcher01373a52007-07-30 12:49:04 -0300816}
817
818static struct dib0070_config dib7070p_dib0070_config[2] = {
819 {
820 .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
821 .reset = dib7070_tuner_reset,
822 .sleep = dib7070_tuner_sleep,
823 .clock_khz = 12000,
Patrick Boettcher7e5ce652009-08-03 13:43:40 -0300824 .clock_pad_drive = 4,
825 .charge_pump = 2,
Patrick Boettcher01373a52007-07-30 12:49:04 -0300826 }, {
827 .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
828 .reset = dib7070_tuner_reset,
829 .sleep = dib7070_tuner_sleep,
830 .clock_khz = 12000,
Patrick Boettcher7e5ce652009-08-03 13:43:40 -0300831 .charge_pump = 2,
Patrick Boettcher01373a52007-07-30 12:49:04 -0300832 }
833};
834
Olivier Grenied300bd62009-09-15 06:55:35 -0300835static struct dib0070_config dib7770p_dib0070_config = {
836 .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
837 .reset = dib7070_tuner_reset,
838 .sleep = dib7070_tuner_sleep,
839 .clock_khz = 12000,
840 .clock_pad_drive = 0,
841 .flip_chip = 1,
Olivier Grenieeac1fe12009-09-23 13:41:27 -0300842 .charge_pump = 2,
Olivier Grenied300bd62009-09-15 06:55:35 -0300843};
844
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -0300845static int dib7070_set_param_override(struct dvb_frontend *fe)
Patrick Boettcher01373a52007-07-30 12:49:04 -0300846{
Mauro Carvalho Chehab47b163a2011-12-24 10:18:24 -0300847 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
Patrick Boettcher01373a52007-07-30 12:49:04 -0300848 struct dvb_usb_adapter *adap = fe->dvb->priv;
849 struct dib0700_adapter_state *state = adap->priv;
850
851 u16 offset;
Mauro Carvalho Chehab47b163a2011-12-24 10:18:24 -0300852 u8 band = BAND_OF_FREQUENCY(p->frequency/1000);
Patrick Boettcher01373a52007-07-30 12:49:04 -0300853 switch (band) {
854 case BAND_VHF: offset = 950; break;
855 case BAND_UHF:
856 default: offset = 550; break;
857 }
858 deb_info("WBD for DiB7000P: %d\n", offset + dib0070_wbd_offset(fe));
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300859 state->dib7000p_ops.set_wbd_ref(fe, offset + dib0070_wbd_offset(fe));
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -0300860 return state->set_param_save(fe);
Patrick Boettcher01373a52007-07-30 12:49:04 -0300861}
862
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -0300863static int dib7770_set_param_override(struct dvb_frontend *fe)
Olivier Grenied300bd62009-09-15 06:55:35 -0300864{
Mauro Carvalho Chehab47b163a2011-12-24 10:18:24 -0300865 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
866 struct dvb_usb_adapter *adap = fe->dvb->priv;
867 struct dib0700_adapter_state *state = adap->priv;
Olivier Grenied300bd62009-09-15 06:55:35 -0300868
869 u16 offset;
Mauro Carvalho Chehab47b163a2011-12-24 10:18:24 -0300870 u8 band = BAND_OF_FREQUENCY(p->frequency/1000);
Olivier Grenied300bd62009-09-15 06:55:35 -0300871 switch (band) {
872 case BAND_VHF:
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300873 state->dib7000p_ops.set_gpio(fe, 0, 0, 1);
Olivier Grenied300bd62009-09-15 06:55:35 -0300874 offset = 850;
875 break;
876 case BAND_UHF:
877 default:
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300878 state->dib7000p_ops.set_gpio(fe, 0, 0, 0);
Olivier Grenied300bd62009-09-15 06:55:35 -0300879 offset = 250;
880 break;
881 }
882 deb_info("WBD for DiB7000P: %d\n", offset + dib0070_wbd_offset(fe));
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300883 state->dib7000p_ops.set_wbd_ref(fe, offset + dib0070_wbd_offset(fe));
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -0300884 return state->set_param_save(fe);
Olivier Grenied300bd62009-09-15 06:55:35 -0300885}
886
887static int dib7770p_tuner_attach(struct dvb_usb_adapter *adap)
888{
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300889 struct dib0700_adapter_state *st = adap->priv;
890 struct i2c_adapter *tun_i2c = st->dib7000p_ops.get_i2c_master(adap->fe_adap[0].fe,
Olivier Grenied300bd62009-09-15 06:55:35 -0300891 DIBX000_I2C_INTERFACE_TUNER, 1);
892
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300893 if (dvb_attach(dib0070_attach, adap->fe_adap[0].fe, tun_i2c,
894 &dib7770p_dib0070_config) == NULL)
895 return -ENODEV;
Olivier Grenied300bd62009-09-15 06:55:35 -0300896
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300897 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
898 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib7770_set_param_override;
899 return 0;
Olivier Grenied300bd62009-09-15 06:55:35 -0300900}
901
Patrick Boettcher01373a52007-07-30 12:49:04 -0300902static int dib7070p_tuner_attach(struct dvb_usb_adapter *adap)
903{
904 struct dib0700_adapter_state *st = adap->priv;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300905 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 -0300906
907 if (adap->id == 0) {
Michael Krufky77eed212011-09-06 09:31:57 -0300908 if (dvb_attach(dib0070_attach, adap->fe_adap[0].fe, tun_i2c, &dib7070p_dib0070_config[0]) == NULL)
Patrick Boettcher01373a52007-07-30 12:49:04 -0300909 return -ENODEV;
910 } else {
Michael Krufky77eed212011-09-06 09:31:57 -0300911 if (dvb_attach(dib0070_attach, adap->fe_adap[0].fe, tun_i2c, &dib7070p_dib0070_config[1]) == NULL)
Patrick Boettcher01373a52007-07-30 12:49:04 -0300912 return -ENODEV;
913 }
914
Michael Krufky77eed212011-09-06 09:31:57 -0300915 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
916 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib7070_set_param_override;
Patrick Boettcher01373a52007-07-30 12:49:04 -0300917 return 0;
918}
919
Olivier Greniee192a7c2011-01-14 13:58:59 -0300920static int stk7700p_pid_filter(struct dvb_usb_adapter *adapter, int index,
921 u16 pid, int onoff)
922{
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300923 struct dib0700_adapter_state *state = adapter->priv;
Olivier Greniee192a7c2011-01-14 13:58:59 -0300924 struct dib0700_state *st = adapter->dev->priv;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300925
Olivier Greniee192a7c2011-01-14 13:58:59 -0300926 if (st->is_dib7000pc)
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300927 return state->dib7000p_ops.pid_filter(adapter->fe_adap[0].fe, index, pid, onoff);
Michael Krufky77eed212011-09-06 09:31:57 -0300928 return dib7000m_pid_filter(adapter->fe_adap[0].fe, index, pid, onoff);
Olivier Greniee192a7c2011-01-14 13:58:59 -0300929}
930
931static int stk7700p_pid_filter_ctrl(struct dvb_usb_adapter *adapter, int onoff)
932{
933 struct dib0700_state *st = adapter->dev->priv;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300934 struct dib0700_adapter_state *state = adapter->priv;
Olivier Greniee192a7c2011-01-14 13:58:59 -0300935 if (st->is_dib7000pc)
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300936 return state->dib7000p_ops.pid_filter_ctrl(adapter->fe_adap[0].fe, onoff);
Michael Krufky77eed212011-09-06 09:31:57 -0300937 return dib7000m_pid_filter_ctrl(adapter->fe_adap[0].fe, onoff);
Olivier Greniee192a7c2011-01-14 13:58:59 -0300938}
939
Olivier Grenief8731f42009-09-18 04:08:43 -0300940static int stk70x0p_pid_filter(struct dvb_usb_adapter *adapter, int index, u16 pid, int onoff)
941{
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300942 struct dib0700_adapter_state *state = adapter->priv;
943 return state->dib7000p_ops.pid_filter(adapter->fe_adap[0].fe, index, pid, onoff);
Olivier Grenief8731f42009-09-18 04:08:43 -0300944}
945
946static int stk70x0p_pid_filter_ctrl(struct dvb_usb_adapter *adapter, int onoff)
947{
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300948 struct dib0700_adapter_state *state = adapter->priv;
949 return state->dib7000p_ops.pid_filter_ctrl(adapter->fe_adap[0].fe, onoff);
Olivier Grenief8731f42009-09-18 04:08:43 -0300950}
951
Patrick Boettcher01373a52007-07-30 12:49:04 -0300952static struct dibx000_bandwidth_config dib7070_bw_config_12_mhz = {
Olivier Grenie9c783032009-12-07 07:49:40 -0300953 60000, 15000,
954 1, 20, 3, 1, 0,
955 0, 0, 1, 1, 2,
956 (3 << 14) | (1 << 12) | (524 << 0),
957 (0 << 25) | 0,
958 20452225,
959 12000000,
Patrick Boettcher01373a52007-07-30 12:49:04 -0300960};
961
962static struct dib7000p_config dib7070p_dib7000p_config = {
963 .output_mpeg2_in_188_bytes = 1,
964
965 .agc_config_count = 1,
966 .agc = &dib7070_agc_config,
967 .bw = &dib7070_bw_config_12_mhz,
Patrick Boettcher3cb2c392008-01-25 07:25:20 -0300968 .tuner_is_baseband = 1,
969 .spur_protect = 1,
Patrick Boettcher01373a52007-07-30 12:49:04 -0300970
971 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
972 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
973 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
974
975 .hostbus_diversity = 1,
976};
977
978/* STK7070P */
979static int stk7070p_frontend_attach(struct dvb_usb_adapter *adap)
980{
Al Viroda5ee482008-05-21 00:31:21 -0300981 struct usb_device_descriptor *p = &adap->dev->udev->descriptor;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300982 struct dib0700_adapter_state *state = adap->priv;
983
984 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
985 return -ENODEV;
986
Al Viroda5ee482008-05-21 00:31:21 -0300987 if (p->idVendor == cpu_to_le16(USB_VID_PINNACLE) &&
988 p->idProduct == cpu_to_le16(USB_PID_PINNACLE_PCTV72E))
989 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300990 else
Al Viroda5ee482008-05-21 00:31:21 -0300991 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
Patrick Boettcher01373a52007-07-30 12:49:04 -0300992 msleep(10);
993 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
994 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
995 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
996 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
997
998 dib0700_ctrl_clock(adap->dev, 72, 1);
999
1000 msleep(10);
1001 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
1002 msleep(10);
1003 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
1004
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03001005 if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 18,
Devin Heitmueller83c4fdf2009-01-21 01:55:45 -03001006 &dib7070p_dib7000p_config) != 0) {
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03001007 err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n",
Devin Heitmueller83c4fdf2009-01-21 01:55:45 -03001008 __func__);
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03001009 dvb_detach(&state->dib7000p_ops);
Devin Heitmueller83c4fdf2009-01-21 01:55:45 -03001010 return -ENODEV;
1011 }
Patrick Boettcher01373a52007-07-30 12:49:04 -03001012
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03001013 adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap, 0x80,
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03001014 &dib7070p_dib7000p_config);
Michael Krufky77eed212011-09-06 09:31:57 -03001015 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Patrick Boettcher01373a52007-07-30 12:49:04 -03001016}
1017
Olivier Grenie90e12ce2010-09-07 12:50:45 -03001018/* STK7770P */
1019static struct dib7000p_config dib7770p_dib7000p_config = {
1020 .output_mpeg2_in_188_bytes = 1,
1021
1022 .agc_config_count = 1,
1023 .agc = &dib7070_agc_config,
1024 .bw = &dib7070_bw_config_12_mhz,
1025 .tuner_is_baseband = 1,
1026 .spur_protect = 1,
1027
1028 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
1029 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
1030 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
1031
1032 .hostbus_diversity = 1,
1033 .enable_current_mirror = 1,
Olivier Grenie970d14c2010-09-07 12:50:46 -03001034 .disable_sample_and_hold = 0,
Olivier Grenie90e12ce2010-09-07 12:50:45 -03001035};
1036
1037static int stk7770p_frontend_attach(struct dvb_usb_adapter *adap)
1038{
1039 struct usb_device_descriptor *p = &adap->dev->udev->descriptor;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03001040 struct dib0700_adapter_state *state = adap->priv;
1041
1042 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
1043 return -ENODEV;
1044
Olivier Grenie90e12ce2010-09-07 12:50:45 -03001045 if (p->idVendor == cpu_to_le16(USB_VID_PINNACLE) &&
1046 p->idProduct == cpu_to_le16(USB_PID_PINNACLE_PCTV72E))
1047 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
1048 else
1049 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
1050 msleep(10);
1051 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
1052 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
1053 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
1054 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
1055
1056 dib0700_ctrl_clock(adap->dev, 72, 1);
1057
1058 msleep(10);
1059 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
1060 msleep(10);
1061 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
1062
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03001063 if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 18,
Olivier Grenie90e12ce2010-09-07 12:50:45 -03001064 &dib7770p_dib7000p_config) != 0) {
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03001065 err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n",
Olivier Grenie90e12ce2010-09-07 12:50:45 -03001066 __func__);
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03001067 dvb_detach(&state->dib7000p_ops);
Olivier Grenie90e12ce2010-09-07 12:50:45 -03001068 return -ENODEV;
1069 }
1070
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03001071 adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap, 0x80,
Olivier Grenie90e12ce2010-09-07 12:50:45 -03001072 &dib7770p_dib7000p_config);
Michael Krufky77eed212011-09-06 09:31:57 -03001073 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Olivier Grenie90e12ce2010-09-07 12:50:45 -03001074}
1075
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001076/* DIB807x generic */
1077static struct dibx000_agc_config dib807x_agc_config[2] = {
1078 {
1079 BAND_VHF,
1080 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0,
1081 * P_agc_freq_pwm_div=1, P_agc_inv_pwm1=0,
1082 * P_agc_inv_pwm2=0,P_agc_inh_dc_rv_est=0,
1083 * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5,
1084 * P_agc_write=0 */
1085 (0 << 15) | (0 << 14) | (7 << 11) | (0 << 10) | (0 << 9) |
1086 (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) |
1087 (0 << 0), /* setup*/
1088
1089 600, /* inv_gain*/
1090 10, /* time_stabiliz*/
1091
1092 0, /* alpha_level*/
1093 118, /* thlock*/
1094
1095 0, /* wbd_inv*/
1096 3530, /* wbd_ref*/
1097 1, /* wbd_sel*/
1098 5, /* wbd_alpha*/
1099
1100 65535, /* agc1_max*/
1101 0, /* agc1_min*/
1102
1103 65535, /* agc2_max*/
1104 0, /* agc2_min*/
1105
1106 0, /* agc1_pt1*/
1107 40, /* agc1_pt2*/
1108 183, /* agc1_pt3*/
1109 206, /* agc1_slope1*/
1110 255, /* agc1_slope2*/
1111 72, /* agc2_pt1*/
1112 152, /* agc2_pt2*/
1113 88, /* agc2_slope1*/
1114 90, /* agc2_slope2*/
1115
1116 17, /* alpha_mant*/
1117 27, /* alpha_exp*/
1118 23, /* beta_mant*/
1119 51, /* beta_exp*/
1120
1121 0, /* perform_agc_softsplit*/
1122 }, {
1123 BAND_UHF,
1124 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0,
1125 * P_agc_freq_pwm_div=1, P_agc_inv_pwm1=0,
1126 * P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
1127 * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5,
1128 * P_agc_write=0 */
1129 (0 << 15) | (0 << 14) | (1 << 11) | (0 << 10) | (0 << 9) |
1130 (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) |
1131 (0 << 0), /* setup */
1132
1133 600, /* inv_gain*/
1134 10, /* time_stabiliz*/
1135
1136 0, /* alpha_level*/
1137 118, /* thlock*/
1138
1139 0, /* wbd_inv*/
1140 3530, /* wbd_ref*/
1141 1, /* wbd_sel*/
1142 5, /* wbd_alpha*/
1143
1144 65535, /* agc1_max*/
1145 0, /* agc1_min*/
1146
1147 65535, /* agc2_max*/
1148 0, /* agc2_min*/
1149
1150 0, /* agc1_pt1*/
1151 40, /* agc1_pt2*/
1152 183, /* agc1_pt3*/
1153 206, /* agc1_slope1*/
1154 255, /* agc1_slope2*/
1155 72, /* agc2_pt1*/
1156 152, /* agc2_pt2*/
1157 88, /* agc2_slope1*/
1158 90, /* agc2_slope2*/
1159
1160 17, /* alpha_mant*/
1161 27, /* alpha_exp*/
1162 23, /* beta_mant*/
1163 51, /* beta_exp*/
1164
1165 0, /* perform_agc_softsplit*/
1166 }
1167};
1168
1169static struct dibx000_bandwidth_config dib807x_bw_config_12_mhz = {
1170 60000, 15000, /* internal, sampling*/
1171 1, 20, 3, 1, 0, /* pll_cfg: prediv, ratio, range, reset, bypass*/
1172 0, 0, 1, 1, 2, /* misc: refdiv, bypclk_div, IO_CLK_en_core,
1173 ADClkSrc, modulo */
1174 (3 << 14) | (1 << 12) | (599 << 0), /* sad_cfg: refsel, sel, freq_15k*/
1175 (0 << 25) | 0, /* ifreq = 0.000000 MHz*/
1176 18179755, /* timf*/
1177 12000000, /* xtal_hz*/
1178};
1179
1180static struct dib8000_config dib807x_dib8000_config[2] = {
1181 {
1182 .output_mpeg2_in_188_bytes = 1,
1183
1184 .agc_config_count = 2,
1185 .agc = dib807x_agc_config,
1186 .pll = &dib807x_bw_config_12_mhz,
1187 .tuner_is_baseband = 1,
1188
1189 .gpio_dir = DIB8000_GPIO_DEFAULT_DIRECTIONS,
1190 .gpio_val = DIB8000_GPIO_DEFAULT_VALUES,
1191 .gpio_pwm_pos = DIB8000_GPIO_DEFAULT_PWM_POS,
1192
1193 .hostbus_diversity = 1,
1194 .div_cfg = 1,
1195 .agc_control = &dib0070_ctrl_agc_filter,
1196 .output_mode = OUTMODE_MPEG2_FIFO,
1197 .drives = 0x2d98,
1198 }, {
1199 .output_mpeg2_in_188_bytes = 1,
1200
1201 .agc_config_count = 2,
1202 .agc = dib807x_agc_config,
1203 .pll = &dib807x_bw_config_12_mhz,
1204 .tuner_is_baseband = 1,
1205
1206 .gpio_dir = DIB8000_GPIO_DEFAULT_DIRECTIONS,
1207 .gpio_val = DIB8000_GPIO_DEFAULT_VALUES,
1208 .gpio_pwm_pos = DIB8000_GPIO_DEFAULT_PWM_POS,
1209
1210 .hostbus_diversity = 1,
1211 .agc_control = &dib0070_ctrl_agc_filter,
1212 .output_mode = OUTMODE_MPEG2_FIFO,
1213 .drives = 0x2d98,
1214 }
1215};
1216
Olivier Grenie03245a52009-12-04 13:27:57 -03001217static int dib80xx_tuner_reset(struct dvb_frontend *fe, int onoff)
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001218{
1219 return dib8000_set_gpio(fe, 5, 0, !onoff);
1220}
1221
Olivier Grenie03245a52009-12-04 13:27:57 -03001222static int dib80xx_tuner_sleep(struct dvb_frontend *fe, int onoff)
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001223{
1224 return dib8000_set_gpio(fe, 0, 0, onoff);
1225}
1226
1227static const struct dib0070_wbd_gain_cfg dib8070_wbd_gain_cfg[] = {
1228 { 240, 7},
1229 { 0xffff, 6},
1230};
1231
1232static struct dib0070_config dib807x_dib0070_config[2] = {
1233 {
1234 .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
Olivier Grenie03245a52009-12-04 13:27:57 -03001235 .reset = dib80xx_tuner_reset,
1236 .sleep = dib80xx_tuner_sleep,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001237 .clock_khz = 12000,
1238 .clock_pad_drive = 4,
1239 .vga_filter = 1,
1240 .force_crystal_mode = 1,
1241 .enable_third_order_filter = 1,
1242 .charge_pump = 0,
1243 .wbd_gain = dib8070_wbd_gain_cfg,
1244 .osc_buffer_state = 0,
1245 .freq_offset_khz_uhf = -100,
1246 .freq_offset_khz_vhf = -100,
1247 }, {
1248 .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
Olivier Grenie03245a52009-12-04 13:27:57 -03001249 .reset = dib80xx_tuner_reset,
1250 .sleep = dib80xx_tuner_sleep,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001251 .clock_khz = 12000,
1252 .clock_pad_drive = 2,
1253 .vga_filter = 1,
1254 .force_crystal_mode = 1,
1255 .enable_third_order_filter = 1,
1256 .charge_pump = 0,
1257 .wbd_gain = dib8070_wbd_gain_cfg,
1258 .osc_buffer_state = 0,
1259 .freq_offset_khz_uhf = -25,
1260 .freq_offset_khz_vhf = -25,
1261 }
1262};
1263
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -03001264static int dib807x_set_param_override(struct dvb_frontend *fe)
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001265{
Mauro Carvalho Chehab47b163a2011-12-24 10:18:24 -03001266 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001267 struct dvb_usb_adapter *adap = fe->dvb->priv;
1268 struct dib0700_adapter_state *state = adap->priv;
1269
1270 u16 offset = dib0070_wbd_offset(fe);
Mauro Carvalho Chehab47b163a2011-12-24 10:18:24 -03001271 u8 band = BAND_OF_FREQUENCY(p->frequency/1000);
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001272 switch (band) {
1273 case BAND_VHF:
1274 offset += 750;
1275 break;
1276 case BAND_UHF: /* fall-thru wanted */
1277 default:
1278 offset += 250; break;
1279 }
1280 deb_info("WBD for DiB8000: %d\n", offset);
1281 dib8000_set_wbd_ref(fe, offset);
1282
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -03001283 return state->set_param_save(fe);
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001284}
1285
1286static int dib807x_tuner_attach(struct dvb_usb_adapter *adap)
1287{
1288 struct dib0700_adapter_state *st = adap->priv;
Michael Krufky77eed212011-09-06 09:31:57 -03001289 struct i2c_adapter *tun_i2c = dib8000_get_i2c_master(adap->fe_adap[0].fe,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001290 DIBX000_I2C_INTERFACE_TUNER, 1);
1291
1292 if (adap->id == 0) {
Michael Krufky77eed212011-09-06 09:31:57 -03001293 if (dvb_attach(dib0070_attach, adap->fe_adap[0].fe, tun_i2c,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001294 &dib807x_dib0070_config[0]) == NULL)
1295 return -ENODEV;
1296 } else {
Michael Krufky77eed212011-09-06 09:31:57 -03001297 if (dvb_attach(dib0070_attach, adap->fe_adap[0].fe, tun_i2c,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001298 &dib807x_dib0070_config[1]) == NULL)
1299 return -ENODEV;
1300 }
1301
Michael Krufky77eed212011-09-06 09:31:57 -03001302 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
1303 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib807x_set_param_override;
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001304 return 0;
1305}
1306
Olivier Grenie9c783032009-12-07 07:49:40 -03001307static int stk80xx_pid_filter(struct dvb_usb_adapter *adapter, int index,
1308 u16 pid, int onoff)
Olivier Grenief8731f42009-09-18 04:08:43 -03001309{
Michael Krufky77eed212011-09-06 09:31:57 -03001310 return dib8000_pid_filter(adapter->fe_adap[0].fe, index, pid, onoff);
Olivier Grenief8731f42009-09-18 04:08:43 -03001311}
1312
Olivier Grenie9c783032009-12-07 07:49:40 -03001313static int stk80xx_pid_filter_ctrl(struct dvb_usb_adapter *adapter,
Olivier Greniebe9bae12011-01-04 05:42:19 -03001314 int onoff)
Olivier Grenief8731f42009-09-18 04:08:43 -03001315{
Michael Krufky77eed212011-09-06 09:31:57 -03001316 return dib8000_pid_filter_ctrl(adapter->fe_adap[0].fe, onoff);
Olivier Grenief8731f42009-09-18 04:08:43 -03001317}
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001318
1319/* STK807x */
1320static int stk807x_frontend_attach(struct dvb_usb_adapter *adap)
1321{
1322 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
1323 msleep(10);
1324 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
1325 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
1326 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
1327
1328 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
1329
1330 dib0700_ctrl_clock(adap->dev, 72, 1);
1331
1332 msleep(10);
1333 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
1334 msleep(10);
1335 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
1336
1337 dib8000_i2c_enumeration(&adap->dev->i2c_adap, 1, 18,
Olivier Grenie0c32dbd2011-08-10 05:17:18 -03001338 0x80, 0);
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001339
Mauro Carvalho Chehabb9bc7d52014-05-29 09:20:16 -03001340 adap->fe_adap[0].fe = dvb_attach(dib8000_init, &adap->dev->i2c_adap, 0x80,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001341 &dib807x_dib8000_config[0]);
1342
Michael Krufky77eed212011-09-06 09:31:57 -03001343 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001344}
1345
1346/* STK807xPVR */
1347static int stk807xpvr_frontend_attach0(struct dvb_usb_adapter *adap)
1348{
1349 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
1350 msleep(30);
1351 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
1352 msleep(500);
1353 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
1354 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
1355 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
1356
1357 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
1358
1359 dib0700_ctrl_clock(adap->dev, 72, 1);
1360
1361 msleep(10);
1362 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
1363 msleep(10);
1364 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
1365
1366 /* initialize IC 0 */
Olivier Grenie0c32dbd2011-08-10 05:17:18 -03001367 dib8000_i2c_enumeration(&adap->dev->i2c_adap, 1, 0x22, 0x80, 0);
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001368
Mauro Carvalho Chehabb9bc7d52014-05-29 09:20:16 -03001369 adap->fe_adap[0].fe = dvb_attach(dib8000_init, &adap->dev->i2c_adap, 0x80,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001370 &dib807x_dib8000_config[0]);
1371
Michael Krufky77eed212011-09-06 09:31:57 -03001372 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001373}
1374
1375static int stk807xpvr_frontend_attach1(struct dvb_usb_adapter *adap)
1376{
1377 /* initialize IC 1 */
Olivier Grenie0c32dbd2011-08-10 05:17:18 -03001378 dib8000_i2c_enumeration(&adap->dev->i2c_adap, 1, 0x12, 0x82, 0);
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001379
Mauro Carvalho Chehabb9bc7d52014-05-29 09:20:16 -03001380 adap->fe_adap[0].fe = dvb_attach(dib8000_init, &adap->dev->i2c_adap, 0x82,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001381 &dib807x_dib8000_config[1]);
1382
Michael Krufky77eed212011-09-06 09:31:57 -03001383 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001384}
1385
Olivier Grenie03245a52009-12-04 13:27:57 -03001386/* STK8096GP */
Olivier Greniea685dbb2011-08-05 14:10:40 -03001387static struct dibx000_agc_config dib8090_agc_config[2] = {
Olivier Greniebe9bae12011-01-04 05:42:19 -03001388 {
Olivier Grenie03245a52009-12-04 13:27:57 -03001389 BAND_UHF | BAND_VHF | BAND_LBAND | BAND_SBAND,
Olivier Grenie9c783032009-12-07 07:49:40 -03001390 /* 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 -03001391 * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
1392 * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5, P_agc_write=0 */
Olivier Grenie9c783032009-12-07 07:49:40 -03001393 (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8)
1394 | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),
Olivier Grenie03245a52009-12-04 13:27:57 -03001395
Olivier Grenie9c783032009-12-07 07:49:40 -03001396 787,
1397 10,
Olivier Grenie03245a52009-12-04 13:27:57 -03001398
Olivier Grenie9c783032009-12-07 07:49:40 -03001399 0,
1400 118,
Olivier Grenie03245a52009-12-04 13:27:57 -03001401
Olivier Grenie9c783032009-12-07 07:49:40 -03001402 0,
1403 3530,
1404 1,
1405 5,
Olivier Grenie03245a52009-12-04 13:27:57 -03001406
Olivier Grenie9c783032009-12-07 07:49:40 -03001407 65535,
1408 0,
Olivier Grenie03245a52009-12-04 13:27:57 -03001409
Olivier Grenie9c783032009-12-07 07:49:40 -03001410 65535,
1411 0,
Olivier Grenie03245a52009-12-04 13:27:57 -03001412
Olivier Grenie9c783032009-12-07 07:49:40 -03001413 0,
1414 32,
1415 114,
1416 143,
1417 144,
1418 114,
1419 227,
1420 116,
1421 117,
Olivier Grenie03245a52009-12-04 13:27:57 -03001422
Olivier Grenie9c783032009-12-07 07:49:40 -03001423 28,
1424 26,
1425 31,
1426 51,
Olivier Grenie03245a52009-12-04 13:27:57 -03001427
Olivier Grenie9c783032009-12-07 07:49:40 -03001428 0,
Olivier Greniebe9bae12011-01-04 05:42:19 -03001429 },
1430 {
Olivier Grenie03245a52009-12-04 13:27:57 -03001431 BAND_CBAND,
Olivier Grenie9c783032009-12-07 07:49:40 -03001432 /* 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 -03001433 * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
1434 * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5, P_agc_write=0 */
Olivier Grenie9c783032009-12-07 07:49:40 -03001435 (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8)
1436 | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),
Olivier Grenie03245a52009-12-04 13:27:57 -03001437
Olivier Grenie9c783032009-12-07 07:49:40 -03001438 787,
1439 10,
Olivier Grenie03245a52009-12-04 13:27:57 -03001440
Olivier Grenie9c783032009-12-07 07:49:40 -03001441 0,
1442 118,
Olivier Grenie03245a52009-12-04 13:27:57 -03001443
Olivier Grenie9c783032009-12-07 07:49:40 -03001444 0,
1445 3530,
1446 1,
1447 5,
Olivier Grenie03245a52009-12-04 13:27:57 -03001448
Olivier Grenie9c783032009-12-07 07:49:40 -03001449 0,
1450 0,
Olivier Grenie03245a52009-12-04 13:27:57 -03001451
Olivier Grenie9c783032009-12-07 07:49:40 -03001452 65535,
1453 0,
Olivier Grenie03245a52009-12-04 13:27:57 -03001454
Olivier Grenie9c783032009-12-07 07:49:40 -03001455 0,
1456 32,
1457 114,
1458 143,
1459 144,
1460 114,
1461 227,
1462 116,
1463 117,
Olivier Grenie03245a52009-12-04 13:27:57 -03001464
Olivier Grenie9c783032009-12-07 07:49:40 -03001465 28,
1466 26,
1467 31,
1468 51,
Olivier Grenie03245a52009-12-04 13:27:57 -03001469
Olivier Grenie9c783032009-12-07 07:49:40 -03001470 0,
Olivier Greniebe9bae12011-01-04 05:42:19 -03001471 }
Olivier Grenie03245a52009-12-04 13:27:57 -03001472};
1473
1474static struct dibx000_bandwidth_config dib8090_pll_config_12mhz = {
Olivier Greniebe9bae12011-01-04 05:42:19 -03001475 54000, 13500,
1476 1, 18, 3, 1, 0,
1477 0, 0, 1, 1, 2,
1478 (3 << 14) | (1 << 12) | (599 << 0),
1479 (0 << 25) | 0,
1480 20199727,
1481 12000000,
Olivier Grenie03245a52009-12-04 13:27:57 -03001482};
1483
1484static int dib8090_get_adc_power(struct dvb_frontend *fe)
1485{
Olivier Greniebe9bae12011-01-04 05:42:19 -03001486 return dib8000_get_adc_power(fe, 1);
Olivier Grenie03245a52009-12-04 13:27:57 -03001487}
1488
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001489static void dib8090_agc_control(struct dvb_frontend *fe, u8 restart)
1490{
1491 deb_info("AGC control callback: %i\n", restart);
1492 dib0090_dcc_freq(fe, restart);
1493
1494 if (restart == 0) /* before AGC startup */
1495 dib0090_set_dc_servo(fe, 1);
1496}
1497
Olivier Greniebe9bae12011-01-04 05:42:19 -03001498static struct dib8000_config dib809x_dib8000_config[2] = {
1499 {
1500 .output_mpeg2_in_188_bytes = 1,
Olivier Grenie03245a52009-12-04 13:27:57 -03001501
Olivier Greniebe9bae12011-01-04 05:42:19 -03001502 .agc_config_count = 2,
1503 .agc = dib8090_agc_config,
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001504 .agc_control = dib8090_agc_control,
Olivier Greniebe9bae12011-01-04 05:42:19 -03001505 .pll = &dib8090_pll_config_12mhz,
1506 .tuner_is_baseband = 1,
Olivier Grenie03245a52009-12-04 13:27:57 -03001507
Olivier Greniebe9bae12011-01-04 05:42:19 -03001508 .gpio_dir = DIB8000_GPIO_DEFAULT_DIRECTIONS,
1509 .gpio_val = DIB8000_GPIO_DEFAULT_VALUES,
1510 .gpio_pwm_pos = DIB8000_GPIO_DEFAULT_PWM_POS,
Olivier Grenie03245a52009-12-04 13:27:57 -03001511
Olivier Greniebe9bae12011-01-04 05:42:19 -03001512 .hostbus_diversity = 1,
1513 .div_cfg = 0x31,
1514 .output_mode = OUTMODE_MPEG2_FIFO,
1515 .drives = 0x2d98,
1516 .diversity_delay = 48,
1517 .refclksel = 3,
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03001518 }, {
Olivier Greniebe9bae12011-01-04 05:42:19 -03001519 .output_mpeg2_in_188_bytes = 1,
1520
1521 .agc_config_count = 2,
1522 .agc = dib8090_agc_config,
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001523 .agc_control = dib8090_agc_control,
Olivier Greniebe9bae12011-01-04 05:42:19 -03001524 .pll = &dib8090_pll_config_12mhz,
1525 .tuner_is_baseband = 1,
1526
1527 .gpio_dir = DIB8000_GPIO_DEFAULT_DIRECTIONS,
1528 .gpio_val = DIB8000_GPIO_DEFAULT_VALUES,
1529 .gpio_pwm_pos = DIB8000_GPIO_DEFAULT_PWM_POS,
1530
1531 .hostbus_diversity = 1,
1532 .div_cfg = 0x31,
1533 .output_mode = OUTMODE_DIVERSITY,
1534 .drives = 0x2d08,
1535 .diversity_delay = 1,
1536 .refclksel = 3,
1537 }
1538};
1539
1540static struct dib0090_wbd_slope dib8090_wbd_table[] = {
1541 /* max freq ; cold slope ; cold offset ; warm slope ; warm offset ; wbd gain */
1542 { 120, 0, 500, 0, 500, 4 }, /* CBAND */
1543 { 170, 0, 450, 0, 450, 4 }, /* CBAND */
1544 { 380, 48, 373, 28, 259, 6 }, /* VHF */
1545 { 860, 34, 700, 36, 616, 6 }, /* high UHF */
1546 { 0xFFFF, 34, 700, 36, 616, 6 }, /* default */
Olivier Grenie03245a52009-12-04 13:27:57 -03001547};
1548
1549static struct dib0090_config dib809x_dib0090_config = {
Olivier Greniebe9bae12011-01-04 05:42:19 -03001550 .io.pll_bypass = 1,
1551 .io.pll_range = 1,
1552 .io.pll_prediv = 1,
1553 .io.pll_loopdiv = 20,
1554 .io.adc_clock_ratio = 8,
1555 .io.pll_int_loop_filt = 0,
1556 .io.clock_khz = 12000,
1557 .reset = dib80xx_tuner_reset,
1558 .sleep = dib80xx_tuner_sleep,
1559 .clkouttobamse = 1,
1560 .analog_output = 1,
1561 .i2c_address = DEFAULT_DIB0090_I2C_ADDRESS,
1562 .use_pwm_agc = 1,
1563 .clkoutdrive = 1,
1564 .get_adc_power = dib8090_get_adc_power,
1565 .freq_offset_khz_uhf = -63,
Olivier Grenie03245a52009-12-04 13:27:57 -03001566 .freq_offset_khz_vhf = -143,
Olivier Greniebe9bae12011-01-04 05:42:19 -03001567 .wbd = dib8090_wbd_table,
1568 .fref_clock_ratio = 6,
Olivier Grenie03245a52009-12-04 13:27:57 -03001569};
1570
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001571static u8 dib8090_compute_pll_parameters(struct dvb_frontend *fe)
1572{
1573 u8 optimal_pll_ratio = 20;
1574 u32 freq_adc, ratio, rest, max = 0;
1575 u8 pll_ratio;
1576
1577 for (pll_ratio = 17; pll_ratio <= 20; pll_ratio++) {
1578 freq_adc = 12 * pll_ratio * (1 << 8) / 16;
1579 ratio = ((fe->dtv_property_cache.frequency / 1000) * (1 << 8) / 1000) / freq_adc;
1580 rest = ((fe->dtv_property_cache.frequency / 1000) * (1 << 8) / 1000) - ratio * freq_adc;
1581
1582 if (rest > freq_adc / 2)
1583 rest = freq_adc - rest;
1584 deb_info("PLL ratio=%i rest=%i\n", pll_ratio, rest);
1585 if ((rest > max) && (rest > 717)) {
1586 optimal_pll_ratio = pll_ratio;
1587 max = rest;
1588 }
1589 }
1590 deb_info("optimal PLL ratio=%i\n", optimal_pll_ratio);
1591
1592 return optimal_pll_ratio;
1593}
1594
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -03001595static int dib8096_set_param_override(struct dvb_frontend *fe)
Olivier Grenie03245a52009-12-04 13:27:57 -03001596{
Olivier Greniebe9bae12011-01-04 05:42:19 -03001597 struct dvb_usb_adapter *adap = fe->dvb->priv;
1598 struct dib0700_adapter_state *state = adap->priv;
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001599 u8 pll_ratio, band = BAND_OF_FREQUENCY(fe->dtv_property_cache.frequency / 1000);
1600 u16 target, ltgain, rf_gain_limit;
1601 u32 timf;
Olivier Greniebe9bae12011-01-04 05:42:19 -03001602 int ret = 0;
1603 enum frontend_tune_state tune_state = CT_SHUTDOWN;
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001604
1605 switch (band) {
1606 default:
1607 deb_info("Warning : Rf frequency (%iHz) is not in the supported range, using VHF switch ", fe->dtv_property_cache.frequency);
1608 case BAND_VHF:
1609 dib8000_set_gpio(fe, 3, 0, 1);
1610 break;
1611 case BAND_UHF:
1612 dib8000_set_gpio(fe, 3, 0, 0);
1613 break;
1614 }
Olivier Grenie03245a52009-12-04 13:27:57 -03001615
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -03001616 ret = state->set_param_save(fe);
Olivier Greniebe9bae12011-01-04 05:42:19 -03001617 if (ret < 0)
1618 return ret;
Olivier Grenie03245a52009-12-04 13:27:57 -03001619
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001620 if (fe->dtv_property_cache.bandwidth_hz != 6000000) {
1621 deb_info("only 6MHz bandwidth is supported\n");
1622 return -EINVAL;
1623 }
Olivier Grenie03245a52009-12-04 13:27:57 -03001624
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001625 /** Update PLL if needed ratio **/
1626 dib8000_update_pll(fe, &dib8090_pll_config_12mhz, fe->dtv_property_cache.bandwidth_hz / 1000, 0);
1627
1628 /** Get optimize PLL ratio to remove spurious **/
1629 pll_ratio = dib8090_compute_pll_parameters(fe);
1630 if (pll_ratio == 17)
1631 timf = 21387946;
1632 else if (pll_ratio == 18)
1633 timf = 20199727;
1634 else if (pll_ratio == 19)
1635 timf = 19136583;
1636 else
1637 timf = 18179756;
1638
1639 /** Update ratio **/
1640 dib8000_update_pll(fe, &dib8090_pll_config_12mhz, fe->dtv_property_cache.bandwidth_hz / 1000, pll_ratio);
1641
1642 dib8000_ctrl_timf(fe, DEMOD_TIMF_SET, timf);
1643
1644 if (band != BAND_CBAND) {
1645 /* dib0090_get_wbd_target is returning any possible temperature compensated wbd-target */
1646 target = (dib0090_get_wbd_target(fe) * 8 * 18 / 33 + 1) / 2;
1647 dib8000_set_wbd_ref(fe, target);
1648 }
Olivier Grenie03245a52009-12-04 13:27:57 -03001649
Olivier Greniebe9bae12011-01-04 05:42:19 -03001650 if (band == BAND_CBAND) {
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03001651 deb_info("tuning in CBAND - soft-AGC startup\n");
1652 dib0090_set_tune_state(fe, CT_AGC_START);
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001653
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03001654 do {
1655 ret = dib0090_gain_control(fe);
1656 msleep(ret);
1657 tune_state = dib0090_get_tune_state(fe);
1658 if (tune_state == CT_AGC_STEP_0)
1659 dib8000_set_gpio(fe, 6, 0, 1);
1660 else if (tune_state == CT_AGC_STEP_1) {
1661 dib0090_get_current_gain(fe, NULL, NULL, &rf_gain_limit, &ltgain);
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001662 if (rf_gain_limit < 2000) /* activate the external attenuator in case of very high input power */
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03001663 dib8000_set_gpio(fe, 6, 0, 0);
1664 }
1665 } while (tune_state < CT_AGC_STOP);
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001666
1667 deb_info("switching to PWM AGC\n");
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03001668 dib0090_pwm_gain_reset(fe);
1669 dib8000_pwm_agc_reset(fe);
1670 dib8000_set_tune_state(fe, CT_DEMOD_START);
Olivier Greniebe9bae12011-01-04 05:42:19 -03001671 } else {
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001672 /* for everything else than CBAND we are using standard AGC */
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03001673 deb_info("not tuning in CBAND - standard AGC startup\n");
1674 dib0090_pwm_gain_reset(fe);
Olivier Greniebe9bae12011-01-04 05:42:19 -03001675 }
Olivier Grenie03245a52009-12-04 13:27:57 -03001676
Olivier Greniebe9bae12011-01-04 05:42:19 -03001677 return 0;
Olivier Grenie03245a52009-12-04 13:27:57 -03001678}
1679
1680static int dib809x_tuner_attach(struct dvb_usb_adapter *adap)
1681{
Olivier Greniebe9bae12011-01-04 05:42:19 -03001682 struct dib0700_adapter_state *st = adap->priv;
Michael Krufky77eed212011-09-06 09:31:57 -03001683 struct i2c_adapter *tun_i2c = dib8000_get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_TUNER, 1);
Olivier Grenie03245a52009-12-04 13:27:57 -03001684
Michael Krufky77eed212011-09-06 09:31:57 -03001685 if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c, &dib809x_dib0090_config) == NULL)
Olivier Greniebe9bae12011-01-04 05:42:19 -03001686 return -ENODEV;
Olivier Grenie03245a52009-12-04 13:27:57 -03001687
Michael Krufky77eed212011-09-06 09:31:57 -03001688 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
1689 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib8096_set_param_override;
Olivier Greniebe9bae12011-01-04 05:42:19 -03001690 return 0;
Olivier Grenie03245a52009-12-04 13:27:57 -03001691}
1692
1693static int stk809x_frontend_attach(struct dvb_usb_adapter *adap)
1694{
1695 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
1696 msleep(10);
1697 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
1698 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
1699 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
1700
1701 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
1702
1703 dib0700_ctrl_clock(adap->dev, 72, 1);
1704
1705 msleep(10);
1706 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
1707 msleep(10);
1708 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
1709
Olivier Grenie0c32dbd2011-08-10 05:17:18 -03001710 dib8000_i2c_enumeration(&adap->dev->i2c_adap, 1, 18, 0x80, 0);
Olivier Grenie03245a52009-12-04 13:27:57 -03001711
Mauro Carvalho Chehabb9bc7d52014-05-29 09:20:16 -03001712 adap->fe_adap[0].fe = dvb_attach(dib8000_init, &adap->dev->i2c_adap, 0x80, &dib809x_dib8000_config[0]);
Olivier Grenie03245a52009-12-04 13:27:57 -03001713
Michael Krufky77eed212011-09-06 09:31:57 -03001714 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Olivier Grenie03245a52009-12-04 13:27:57 -03001715}
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001716
Olivier Greniebe9bae12011-01-04 05:42:19 -03001717static int nim8096md_tuner_attach(struct dvb_usb_adapter *adap)
1718{
1719 struct dib0700_adapter_state *st = adap->priv;
1720 struct i2c_adapter *tun_i2c;
Michael Krufky77eed212011-09-06 09:31:57 -03001721 struct dvb_frontend *fe_slave = dib8000_get_slave_frontend(adap->fe_adap[0].fe, 1);
Olivier Greniebe9bae12011-01-04 05:42:19 -03001722
1723 if (fe_slave) {
1724 tun_i2c = dib8000_get_i2c_master(fe_slave, DIBX000_I2C_INTERFACE_TUNER, 1);
1725 if (dvb_attach(dib0090_register, fe_slave, tun_i2c, &dib809x_dib0090_config) == NULL)
1726 return -ENODEV;
Michael Krufky77eed212011-09-06 09:31:57 -03001727 fe_slave->dvb = adap->fe_adap[0].fe->dvb;
Olivier Greniebe9bae12011-01-04 05:42:19 -03001728 fe_slave->ops.tuner_ops.set_params = dib8096_set_param_override;
1729 }
Michael Krufky77eed212011-09-06 09:31:57 -03001730 tun_i2c = dib8000_get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_TUNER, 1);
1731 if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c, &dib809x_dib0090_config) == NULL)
Olivier Greniebe9bae12011-01-04 05:42:19 -03001732 return -ENODEV;
1733
Michael Krufky77eed212011-09-06 09:31:57 -03001734 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
1735 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib8096_set_param_override;
Olivier Greniebe9bae12011-01-04 05:42:19 -03001736
1737 return 0;
1738}
1739
1740static int nim8096md_frontend_attach(struct dvb_usb_adapter *adap)
1741{
1742 struct dvb_frontend *fe_slave;
1743
1744 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03001745 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03001746 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
1747 msleep(1000);
1748 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
1749 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
1750 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
1751
1752 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
1753
1754 dib0700_ctrl_clock(adap->dev, 72, 1);
1755
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03001756 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03001757 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03001758 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03001759 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
1760
Olivier Grenie0c32dbd2011-08-10 05:17:18 -03001761 dib8000_i2c_enumeration(&adap->dev->i2c_adap, 2, 18, 0x80, 0);
Olivier Greniebe9bae12011-01-04 05:42:19 -03001762
Mauro Carvalho Chehabb9bc7d52014-05-29 09:20:16 -03001763 adap->fe_adap[0].fe = dvb_attach(dib8000_init, &adap->dev->i2c_adap, 0x80, &dib809x_dib8000_config[0]);
Michael Krufky77eed212011-09-06 09:31:57 -03001764 if (adap->fe_adap[0].fe == NULL)
Olivier Greniebe9bae12011-01-04 05:42:19 -03001765 return -ENODEV;
1766
Mauro Carvalho Chehabb9bc7d52014-05-29 09:20:16 -03001767 fe_slave = dvb_attach(dib8000_init, &adap->dev->i2c_adap, 0x82, &dib809x_dib8000_config[1]);
Michael Krufky77eed212011-09-06 09:31:57 -03001768 dib8000_set_slave_frontend(adap->fe_adap[0].fe, fe_slave);
Olivier Greniebe9bae12011-01-04 05:42:19 -03001769
1770 return fe_slave == NULL ? -ENODEV : 0;
1771}
1772
Olivier Grenie88f3a352011-08-10 05:28:38 -03001773/* TFE8096P */
1774static struct dibx000_agc_config dib8096p_agc_config[2] = {
1775 {
1776 .band_caps = BAND_UHF,
1777 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0,
1778 P_agc_freq_pwm_div=1, P_agc_inv_pwm1=0,
1779 P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
1780 P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5,
1781 P_agc_write=0 */
1782 .setup = (0 << 15) | (0 << 14) | (5 << 11)
1783 | (0 << 10) | (0 << 9) | (0 << 8) | (3 << 5)
1784 | (0 << 4) | (5 << 1) | (0 << 0),
1785
1786 .inv_gain = 684,
1787 .time_stabiliz = 10,
1788
1789 .alpha_level = 0,
1790 .thlock = 118,
1791
1792 .wbd_inv = 0,
1793 .wbd_ref = 1200,
1794 .wbd_sel = 3,
1795 .wbd_alpha = 5,
1796
1797 .agc1_max = 65535,
1798 .agc1_min = 0,
1799
1800 .agc2_max = 32767,
1801 .agc2_min = 0,
1802
1803 .agc1_pt1 = 0,
1804 .agc1_pt2 = 0,
1805 .agc1_pt3 = 105,
1806 .agc1_slope1 = 0,
1807 .agc1_slope2 = 156,
1808 .agc2_pt1 = 105,
1809 .agc2_pt2 = 255,
1810 .agc2_slope1 = 54,
1811 .agc2_slope2 = 0,
1812
1813 .alpha_mant = 28,
1814 .alpha_exp = 26,
1815 .beta_mant = 31,
1816 .beta_exp = 51,
1817
1818 .perform_agc_softsplit = 0,
1819 } , {
1820 .band_caps = BAND_FM | BAND_VHF | BAND_CBAND,
1821 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0,
1822 P_agc_freq_pwm_div=1, P_agc_inv_pwm1=0,
1823 P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
1824 P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5,
1825 P_agc_write=0 */
1826 .setup = (0 << 15) | (0 << 14) | (5 << 11)
1827 | (0 << 10) | (0 << 9) | (0 << 8) | (3 << 5)
1828 | (0 << 4) | (5 << 1) | (0 << 0),
1829
1830 .inv_gain = 732,
1831 .time_stabiliz = 10,
1832
1833 .alpha_level = 0,
1834 .thlock = 118,
1835
1836 .wbd_inv = 0,
1837 .wbd_ref = 1200,
1838 .wbd_sel = 3,
1839 .wbd_alpha = 5,
1840
1841 .agc1_max = 65535,
1842 .agc1_min = 0,
1843
1844 .agc2_max = 32767,
1845 .agc2_min = 0,
1846
1847 .agc1_pt1 = 0,
1848 .agc1_pt2 = 0,
1849 .agc1_pt3 = 98,
1850 .agc1_slope1 = 0,
1851 .agc1_slope2 = 167,
1852 .agc2_pt1 = 98,
1853 .agc2_pt2 = 255,
1854 .agc2_slope1 = 52,
1855 .agc2_slope2 = 0,
1856
1857 .alpha_mant = 28,
1858 .alpha_exp = 26,
1859 .beta_mant = 31,
1860 .beta_exp = 51,
1861
1862 .perform_agc_softsplit = 0,
1863 }
1864};
1865
1866static struct dibx000_bandwidth_config dib8096p_clock_config_12_mhz = {
1867 108000, 13500,
1868 1, 9, 1, 0, 0,
1869 0, 0, 0, 0, 2,
1870 (3 << 14) | (1 << 12) | (524 << 0),
1871 (0 << 25) | 0,
1872 20199729,
1873 12000000,
1874};
1875
1876static struct dib8000_config tfe8096p_dib8000_config = {
1877 .output_mpeg2_in_188_bytes = 1,
1878 .hostbus_diversity = 1,
1879 .update_lna = NULL,
1880
1881 .agc_config_count = 2,
1882 .agc = dib8096p_agc_config,
1883 .pll = &dib8096p_clock_config_12_mhz,
1884
1885 .gpio_dir = DIB8000_GPIO_DEFAULT_DIRECTIONS,
1886 .gpio_val = DIB8000_GPIO_DEFAULT_VALUES,
1887 .gpio_pwm_pos = DIB8000_GPIO_DEFAULT_PWM_POS,
1888
1889 .agc_control = NULL,
1890 .diversity_delay = 48,
1891 .output_mode = OUTMODE_MPEG2_FIFO,
1892 .enMpegOutput = 1,
1893};
1894
1895static struct dib0090_wbd_slope dib8096p_wbd_table[] = {
1896 { 380, 81, 850, 64, 540, 4},
1897 { 860, 51, 866, 21, 375, 4},
1898 {1700, 0, 250, 0, 100, 6},
1899 {2600, 0, 250, 0, 100, 6},
1900 { 0xFFFF, 0, 0, 0, 0, 0},
1901};
1902
1903static const struct dib0090_config tfe8096p_dib0090_config = {
1904 .io.clock_khz = 12000,
1905 .io.pll_bypass = 0,
1906 .io.pll_range = 0,
1907 .io.pll_prediv = 3,
1908 .io.pll_loopdiv = 6,
1909 .io.adc_clock_ratio = 0,
1910 .io.pll_int_loop_filt = 0,
1911 .reset = dib8096p_tuner_sleep,
1912 .sleep = dib8096p_tuner_sleep,
1913
1914 .freq_offset_khz_uhf = -143,
1915 .freq_offset_khz_vhf = -143,
1916
1917 .get_adc_power = dib8090_get_adc_power,
1918
1919 .clkouttobamse = 1,
1920 .analog_output = 0,
1921
1922 .wbd_vhf_offset = 0,
1923 .wbd_cband_offset = 0,
1924 .use_pwm_agc = 1,
1925 .clkoutdrive = 0,
1926
1927 .fref_clock_ratio = 1,
1928
1929 .wbd = dib8096p_wbd_table,
1930
1931 .ls_cfg_pad_drv = 0,
1932 .data_tx_drv = 0,
1933 .low_if = NULL,
1934 .in_soc = 1,
1935 .force_cband_input = 0,
1936};
1937
1938struct dibx090p_adc {
1939 u32 freq; /* RF freq MHz */
1940 u32 timf; /* New Timf */
1941 u32 pll_loopdiv; /* New prediv */
1942 u32 pll_prediv; /* New loopdiv */
1943};
1944
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001945struct dibx090p_best_adc {
1946 u32 timf;
1947 u32 pll_loopdiv;
1948 u32 pll_prediv;
Olivier Grenie88f3a352011-08-10 05:28:38 -03001949};
1950
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001951static int dib8096p_get_best_sampling(struct dvb_frontend *fe, struct dibx090p_best_adc *adc)
1952{
1953 u8 spur = 0, prediv = 0, loopdiv = 0, min_prediv = 1, max_prediv = 1;
1954 u16 xtal = 12000;
1955 u16 fcp_min = 1900; /* PLL, Minimum Frequency of phase comparator (KHz) */
1956 u16 fcp_max = 20000; /* PLL, Maximum Frequency of phase comparator (KHz) */
1957 u32 fmem_max = 140000; /* 140MHz max SDRAM freq */
1958 u32 fdem_min = 66000;
1959 u32 fcp = 0, fs = 0, fdem = 0, fmem = 0;
1960 u32 harmonic_id = 0;
1961
1962 adc->timf = 0;
1963 adc->pll_loopdiv = loopdiv;
1964 adc->pll_prediv = prediv;
1965
1966 deb_info("bandwidth = %d", fe->dtv_property_cache.bandwidth_hz);
1967
1968 /* Find Min and Max prediv */
1969 while ((xtal / max_prediv) >= fcp_min)
1970 max_prediv++;
1971
1972 max_prediv--;
1973 min_prediv = max_prediv;
1974 while ((xtal / min_prediv) <= fcp_max) {
1975 min_prediv--;
1976 if (min_prediv == 1)
1977 break;
1978 }
1979 deb_info("MIN prediv = %d : MAX prediv = %d", min_prediv, max_prediv);
1980
1981 min_prediv = 1;
1982
1983 for (prediv = min_prediv; prediv < max_prediv; prediv++) {
1984 fcp = xtal / prediv;
1985 if (fcp > fcp_min && fcp < fcp_max) {
1986 for (loopdiv = 1; loopdiv < 64; loopdiv++) {
1987 fmem = ((xtal/prediv) * loopdiv);
1988 fdem = fmem / 2;
1989 fs = fdem / 4;
1990
1991 /* test min/max system restrictions */
1992 if ((fdem >= fdem_min) && (fmem <= fmem_max) && (fs >= fe->dtv_property_cache.bandwidth_hz / 1000)) {
1993 spur = 0;
1994 /* test fs harmonics positions */
1995 for (harmonic_id = (fe->dtv_property_cache.frequency / (1000 * fs)); harmonic_id <= ((fe->dtv_property_cache.frequency / (1000 * fs)) + 1); harmonic_id++) {
1996 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)))) {
1997 spur = 1;
1998 break;
1999 }
2000 }
2001
2002 if (!spur) {
2003 adc->pll_loopdiv = loopdiv;
2004 adc->pll_prediv = prediv;
2005 adc->timf = (4260880253U / fdem) * (1 << 8);
2006 adc->timf += ((4260880253U % fdem) << 8) / fdem;
2007
2008 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);
2009 break;
2010 }
2011 }
2012 }
2013 }
2014 if (!spur)
2015 break;
2016 }
2017
2018 if (adc->pll_loopdiv == 0 && adc->pll_prediv == 0)
2019 return -EINVAL;
2020 return 0;
2021}
2022
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -03002023static int dib8096p_agc_startup(struct dvb_frontend *fe)
Olivier Grenie88f3a352011-08-10 05:28:38 -03002024{
2025 struct dvb_usb_adapter *adap = fe->dvb->priv;
2026 struct dib0700_adapter_state *state = adap->priv;
2027 struct dibx000_bandwidth_config pll;
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03002028 struct dibx090p_best_adc adc;
Olivier Grenie88f3a352011-08-10 05:28:38 -03002029 u16 target;
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03002030 int ret;
Olivier Grenie88f3a352011-08-10 05:28:38 -03002031
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -03002032 ret = state->set_param_save(fe);
Olivier Grenie88f3a352011-08-10 05:28:38 -03002033 if (ret < 0)
2034 return ret;
2035 memset(&pll, 0, sizeof(struct dibx000_bandwidth_config));
2036
2037 dib0090_pwm_gain_reset(fe);
2038 /* dib0090_get_wbd_target is returning any possible
2039 temperature compensated wbd-target */
2040 target = (dib0090_get_wbd_target(fe) * 8 + 1) / 2;
2041 dib8000_set_wbd_ref(fe, target);
2042
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03002043 if (dib8096p_get_best_sampling(fe, &adc) == 0) {
2044 pll.pll_ratio = adc.pll_loopdiv;
2045 pll.pll_prediv = adc.pll_prediv;
Olivier Grenie88f3a352011-08-10 05:28:38 -03002046
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03002047 dib0700_set_i2c_speed(adap->dev, 200);
Patrick Boettcher173a64c2013-04-22 12:45:52 -03002048 dib8000_update_pll(fe, &pll, fe->dtv_property_cache.bandwidth_hz / 1000, 0);
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03002049 dib8000_ctrl_timf(fe, DEMOD_TIMF_SET, adc.timf);
2050 dib0700_set_i2c_speed(adap->dev, 1000);
Olivier Grenie88f3a352011-08-10 05:28:38 -03002051 }
2052 return 0;
2053}
2054
2055static int tfe8096p_frontend_attach(struct dvb_usb_adapter *adap)
2056{
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03002057 struct dib0700_state *st = adap->dev->priv;
2058 u32 fw_version;
2059
2060 dib0700_get_version(adap->dev, NULL, NULL, &fw_version, NULL);
2061 if (fw_version >= 0x10200)
2062 st->fw_use_new_i2c_api = 1;
2063
Olivier Grenie88f3a352011-08-10 05:28:38 -03002064 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
2065 msleep(20);
2066 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
2067 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
2068 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
2069
2070 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
2071
2072 dib0700_ctrl_clock(adap->dev, 72, 1);
2073
2074 msleep(20);
2075 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
2076 msleep(20);
2077 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
2078
2079 dib8000_i2c_enumeration(&adap->dev->i2c_adap, 1, 0x10, 0x80, 1);
2080
Mauro Carvalho Chehabb9bc7d52014-05-29 09:20:16 -03002081 adap->fe_adap[0].fe = dvb_attach(dib8000_init,
Olivier Grenie88f3a352011-08-10 05:28:38 -03002082 &adap->dev->i2c_adap, 0x80, &tfe8096p_dib8000_config);
2083
2084 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
2085}
2086
2087static int tfe8096p_tuner_attach(struct dvb_usb_adapter *adap)
2088{
2089 struct dib0700_adapter_state *st = adap->priv;
2090 struct i2c_adapter *tun_i2c = dib8096p_get_i2c_tuner(adap->fe_adap[0].fe);
2091
2092 if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c,
2093 &tfe8096p_dib0090_config) == NULL)
2094 return -ENODEV;
2095
2096 dib8000_set_gpio(adap->fe_adap[0].fe, 8, 0, 1);
2097
2098 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
2099 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib8096p_agc_startup;
2100 return 0;
2101}
2102
Olivier Greniebe9bae12011-01-04 05:42:19 -03002103/* STK9090M */
2104static int dib90x0_pid_filter(struct dvb_usb_adapter *adapter, int index, u16 pid, int onoff)
2105{
Michael Krufky77eed212011-09-06 09:31:57 -03002106 return dib9000_fw_pid_filter(adapter->fe_adap[0].fe, index, pid, onoff);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002107}
2108
2109static int dib90x0_pid_filter_ctrl(struct dvb_usb_adapter *adapter, int onoff)
2110{
Michael Krufky77eed212011-09-06 09:31:57 -03002111 return dib9000_fw_pid_filter_ctrl(adapter->fe_adap[0].fe, onoff);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002112}
2113
2114static int dib90x0_tuner_reset(struct dvb_frontend *fe, int onoff)
2115{
2116 return dib9000_set_gpio(fe, 5, 0, !onoff);
2117}
2118
2119static int dib90x0_tuner_sleep(struct dvb_frontend *fe, int onoff)
2120{
2121 return dib9000_set_gpio(fe, 0, 0, onoff);
2122}
2123
2124static int dib01x0_pmu_update(struct i2c_adapter *i2c, u16 *data, u8 len)
2125{
2126 u8 wb[4] = { 0xc >> 8, 0xc & 0xff, 0, 0 };
2127 u8 rb[2];
2128 struct i2c_msg msg[2] = {
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002129 {.addr = 0x1e >> 1, .flags = 0, .buf = wb, .len = 2},
2130 {.addr = 0x1e >> 1, .flags = I2C_M_RD, .buf = rb, .len = 2},
Olivier Greniebe9bae12011-01-04 05:42:19 -03002131 };
2132 u8 index_data;
2133
2134 dibx000_i2c_set_speed(i2c, 250);
2135
2136 if (i2c_transfer(i2c, msg, 2) != 2)
2137 return -EIO;
2138
2139 switch (rb[0] << 8 | rb[1]) {
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002140 case 0:
Olivier Greniebe9bae12011-01-04 05:42:19 -03002141 deb_info("Found DiB0170 rev1: This version of DiB0170 is not supported any longer.\n");
2142 return -EIO;
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002143 case 1:
Olivier Greniebe9bae12011-01-04 05:42:19 -03002144 deb_info("Found DiB0170 rev2");
2145 break;
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002146 case 2:
Olivier Greniebe9bae12011-01-04 05:42:19 -03002147 deb_info("Found DiB0190 rev2");
2148 break;
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002149 default:
Olivier Greniebe9bae12011-01-04 05:42:19 -03002150 deb_info("DiB01x0 not found");
2151 return -EIO;
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002152 }
Olivier Greniebe9bae12011-01-04 05:42:19 -03002153
2154 for (index_data = 0; index_data < len; index_data += 2) {
2155 wb[2] = (data[index_data + 1] >> 8) & 0xff;
2156 wb[3] = (data[index_data + 1]) & 0xff;
2157
2158 if (data[index_data] == 0) {
2159 wb[0] = (data[index_data] >> 8) & 0xff;
2160 wb[1] = (data[index_data]) & 0xff;
2161 msg[0].len = 2;
2162 if (i2c_transfer(i2c, msg, 2) != 2)
2163 return -EIO;
2164 wb[2] |= rb[0];
2165 wb[3] |= rb[1] & ~(3 << 4);
2166 }
2167
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002168 wb[0] = (data[index_data] >> 8)&0xff;
2169 wb[1] = (data[index_data])&0xff;
Olivier Greniebe9bae12011-01-04 05:42:19 -03002170 msg[0].len = 4;
2171 if (i2c_transfer(i2c, &msg[0], 1) != 1)
2172 return -EIO;
2173 }
2174 return 0;
2175}
2176
2177static struct dib9000_config stk9090m_config = {
2178 .output_mpeg2_in_188_bytes = 1,
2179 .output_mode = OUTMODE_MPEG2_FIFO,
2180 .vcxo_timer = 279620,
2181 .timing_frequency = 20452225,
2182 .demod_clock_khz = 60000,
2183 .xtal_clock_khz = 30000,
2184 .if_drives = (0 << 15) | (1 << 13) | (0 << 12) | (3 << 10) | (0 << 9) | (1 << 7) | (0 << 6) | (0 << 4) | (1 << 3) | (1 << 1) | (0),
2185 .subband = {
2186 2,
2187 {
2188 { 240, { BOARD_GPIO_COMPONENT_DEMOD, BOARD_GPIO_FUNCTION_SUBBAND_GPIO, 0x0008, 0x0000, 0x0008 } }, /* GPIO 3 to 1 for VHF */
2189 { 890, { BOARD_GPIO_COMPONENT_DEMOD, BOARD_GPIO_FUNCTION_SUBBAND_GPIO, 0x0008, 0x0000, 0x0000 } }, /* GPIO 3 to 0 for UHF */
2190 { 0 },
2191 },
2192 },
2193 .gpio_function = {
2194 { .component = BOARD_GPIO_COMPONENT_DEMOD, .function = BOARD_GPIO_FUNCTION_COMPONENT_ON, .mask = 0x10 | 0x21, .direction = 0 & ~0x21, .value = (0x10 & ~0x1) | 0x20 },
2195 { .component = BOARD_GPIO_COMPONENT_DEMOD, .function = BOARD_GPIO_FUNCTION_COMPONENT_OFF, .mask = 0x10 | 0x21, .direction = 0 & ~0x21, .value = 0 | 0x21 },
2196 },
2197};
2198
2199static struct dib9000_config nim9090md_config[2] = {
2200 {
2201 .output_mpeg2_in_188_bytes = 1,
2202 .output_mode = OUTMODE_MPEG2_FIFO,
2203 .vcxo_timer = 279620,
2204 .timing_frequency = 20452225,
2205 .demod_clock_khz = 60000,
2206 .xtal_clock_khz = 30000,
2207 .if_drives = (0 << 15) | (1 << 13) | (0 << 12) | (3 << 10) | (0 << 9) | (1 << 7) | (0 << 6) | (0 << 4) | (1 << 3) | (1 << 1) | (0),
2208 }, {
2209 .output_mpeg2_in_188_bytes = 1,
2210 .output_mode = OUTMODE_DIVERSITY,
2211 .vcxo_timer = 279620,
2212 .timing_frequency = 20452225,
2213 .demod_clock_khz = 60000,
2214 .xtal_clock_khz = 30000,
2215 .if_drives = (0 << 15) | (1 << 13) | (0 << 12) | (3 << 10) | (0 << 9) | (1 << 7) | (0 << 6) | (0 << 4) | (1 << 3) | (1 << 1) | (0),
2216 .subband = {
2217 2,
2218 {
2219 { 240, { BOARD_GPIO_COMPONENT_DEMOD, BOARD_GPIO_FUNCTION_SUBBAND_GPIO, 0x0006, 0x0000, 0x0006 } }, /* GPIO 1 and 2 to 1 for VHF */
2220 { 890, { BOARD_GPIO_COMPONENT_DEMOD, BOARD_GPIO_FUNCTION_SUBBAND_GPIO, 0x0006, 0x0000, 0x0000 } }, /* GPIO 1 and 2 to 0 for UHF */
2221 { 0 },
2222 },
2223 },
2224 .gpio_function = {
2225 { .component = BOARD_GPIO_COMPONENT_DEMOD, .function = BOARD_GPIO_FUNCTION_COMPONENT_ON, .mask = 0x10 | 0x21, .direction = 0 & ~0x21, .value = (0x10 & ~0x1) | 0x20 },
2226 { .component = BOARD_GPIO_COMPONENT_DEMOD, .function = BOARD_GPIO_FUNCTION_COMPONENT_OFF, .mask = 0x10 | 0x21, .direction = 0 & ~0x21, .value = 0 | 0x21 },
2227 },
2228 }
2229};
2230
2231static struct dib0090_config dib9090_dib0090_config = {
2232 .io.pll_bypass = 0,
2233 .io.pll_range = 1,
2234 .io.pll_prediv = 1,
2235 .io.pll_loopdiv = 8,
2236 .io.adc_clock_ratio = 8,
2237 .io.pll_int_loop_filt = 0,
2238 .io.clock_khz = 30000,
2239 .reset = dib90x0_tuner_reset,
2240 .sleep = dib90x0_tuner_sleep,
2241 .clkouttobamse = 0,
2242 .analog_output = 0,
2243 .use_pwm_agc = 0,
2244 .clkoutdrive = 0,
2245 .freq_offset_khz_uhf = 0,
2246 .freq_offset_khz_vhf = 0,
2247};
2248
2249static struct dib0090_config nim9090md_dib0090_config[2] = {
2250 {
2251 .io.pll_bypass = 0,
2252 .io.pll_range = 1,
2253 .io.pll_prediv = 1,
2254 .io.pll_loopdiv = 8,
2255 .io.adc_clock_ratio = 8,
2256 .io.pll_int_loop_filt = 0,
2257 .io.clock_khz = 30000,
2258 .reset = dib90x0_tuner_reset,
2259 .sleep = dib90x0_tuner_sleep,
2260 .clkouttobamse = 1,
2261 .analog_output = 0,
2262 .use_pwm_agc = 0,
2263 .clkoutdrive = 0,
2264 .freq_offset_khz_uhf = 0,
2265 .freq_offset_khz_vhf = 0,
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002266 }, {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002267 .io.pll_bypass = 0,
2268 .io.pll_range = 1,
2269 .io.pll_prediv = 1,
2270 .io.pll_loopdiv = 8,
2271 .io.adc_clock_ratio = 8,
2272 .io.pll_int_loop_filt = 0,
2273 .io.clock_khz = 30000,
2274 .reset = dib90x0_tuner_reset,
2275 .sleep = dib90x0_tuner_sleep,
2276 .clkouttobamse = 0,
2277 .analog_output = 0,
2278 .use_pwm_agc = 0,
2279 .clkoutdrive = 0,
2280 .freq_offset_khz_uhf = 0,
2281 .freq_offset_khz_vhf = 0,
2282 }
2283};
2284
2285
2286static int stk9090m_frontend_attach(struct dvb_usb_adapter *adap)
2287{
2288 struct dib0700_adapter_state *state = adap->priv;
2289 struct dib0700_state *st = adap->dev->priv;
2290 u32 fw_version;
2291
2292 /* Make use of the new i2c functions from FW 1.20 */
2293 dib0700_get_version(adap->dev, NULL, NULL, &fw_version, NULL);
2294 if (fw_version >= 0x10200)
2295 st->fw_use_new_i2c_api = 1;
2296 dib0700_set_i2c_speed(adap->dev, 340);
2297
2298 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002299 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002300 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
2301 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
2302 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
2303 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
2304
2305 dib0700_ctrl_clock(adap->dev, 72, 1);
2306
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002307 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002308 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002309 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002310 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
2311
2312 dib9000_i2c_enumeration(&adap->dev->i2c_adap, 1, 0x10, 0x80);
2313
2314 if (request_firmware(&state->frontend_firmware, "dib9090.fw", &adap->dev->udev->dev)) {
2315 deb_info("%s: Upload failed. (file not found?)\n", __func__);
2316 return -ENODEV;
2317 } else {
2318 deb_info("%s: firmware read %Zu bytes.\n", __func__, state->frontend_firmware->size);
2319 }
2320 stk9090m_config.microcode_B_fe_size = state->frontend_firmware->size;
2321 stk9090m_config.microcode_B_fe_buffer = state->frontend_firmware->data;
2322
Michael Krufky77eed212011-09-06 09:31:57 -03002323 adap->fe_adap[0].fe = dvb_attach(dib9000_attach, &adap->dev->i2c_adap, 0x80, &stk9090m_config);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002324
Michael Krufky77eed212011-09-06 09:31:57 -03002325 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Olivier Greniebe9bae12011-01-04 05:42:19 -03002326}
2327
2328static int dib9090_tuner_attach(struct dvb_usb_adapter *adap)
2329{
2330 struct dib0700_adapter_state *state = adap->priv;
Michael Krufky77eed212011-09-06 09:31:57 -03002331 struct i2c_adapter *i2c = dib9000_get_tuner_interface(adap->fe_adap[0].fe);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002332 u16 data_dib190[10] = {
2333 1, 0x1374,
2334 2, 0x01a2,
2335 7, 0x0020,
2336 0, 0x00ef,
2337 8, 0x0486,
2338 };
2339
Michael Krufky77eed212011-09-06 09:31:57 -03002340 if (dvb_attach(dib0090_fw_register, adap->fe_adap[0].fe, i2c, &dib9090_dib0090_config) == NULL)
Olivier Greniebe9bae12011-01-04 05:42:19 -03002341 return -ENODEV;
Michael Krufky77eed212011-09-06 09:31:57 -03002342 i2c = dib9000_get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_GPIO_1_2, 0);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002343 if (dib01x0_pmu_update(i2c, data_dib190, 10) != 0)
2344 return -ENODEV;
Olivier Grenied1190022011-08-29 10:58:47 -03002345 dib0700_set_i2c_speed(adap->dev, 1500);
Michael Krufky77eed212011-09-06 09:31:57 -03002346 if (dib9000_firmware_post_pll_init(adap->fe_adap[0].fe) < 0)
Olivier Greniebe9bae12011-01-04 05:42:19 -03002347 return -ENODEV;
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002348 release_firmware(state->frontend_firmware);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002349 return 0;
2350}
2351
2352static int nim9090md_frontend_attach(struct dvb_usb_adapter *adap)
2353{
2354 struct dib0700_adapter_state *state = adap->priv;
2355 struct dib0700_state *st = adap->dev->priv;
2356 struct i2c_adapter *i2c;
2357 struct dvb_frontend *fe_slave;
2358 u32 fw_version;
2359
2360 /* Make use of the new i2c functions from FW 1.20 */
2361 dib0700_get_version(adap->dev, NULL, NULL, &fw_version, NULL);
2362 if (fw_version >= 0x10200)
2363 st->fw_use_new_i2c_api = 1;
2364 dib0700_set_i2c_speed(adap->dev, 340);
2365
2366 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002367 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002368 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
2369 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
2370 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
2371 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
2372
2373 dib0700_ctrl_clock(adap->dev, 72, 1);
2374
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002375 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002376 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002377 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002378 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
2379
2380 if (request_firmware(&state->frontend_firmware, "dib9090.fw", &adap->dev->udev->dev)) {
2381 deb_info("%s: Upload failed. (file not found?)\n", __func__);
2382 return -EIO;
2383 } else {
2384 deb_info("%s: firmware read %Zu bytes.\n", __func__, state->frontend_firmware->size);
2385 }
2386 nim9090md_config[0].microcode_B_fe_size = state->frontend_firmware->size;
2387 nim9090md_config[0].microcode_B_fe_buffer = state->frontend_firmware->data;
2388 nim9090md_config[1].microcode_B_fe_size = state->frontend_firmware->size;
2389 nim9090md_config[1].microcode_B_fe_buffer = state->frontend_firmware->data;
2390
2391 dib9000_i2c_enumeration(&adap->dev->i2c_adap, 1, 0x20, 0x80);
Michael Krufky77eed212011-09-06 09:31:57 -03002392 adap->fe_adap[0].fe = dvb_attach(dib9000_attach, &adap->dev->i2c_adap, 0x80, &nim9090md_config[0]);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002393
Michael Krufky77eed212011-09-06 09:31:57 -03002394 if (adap->fe_adap[0].fe == NULL)
Olivier Greniebe9bae12011-01-04 05:42:19 -03002395 return -ENODEV;
2396
Michael Krufky77eed212011-09-06 09:31:57 -03002397 i2c = dib9000_get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_GPIO_3_4, 0);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002398 dib9000_i2c_enumeration(i2c, 1, 0x12, 0x82);
2399
2400 fe_slave = dvb_attach(dib9000_attach, i2c, 0x82, &nim9090md_config[1]);
Michael Krufky77eed212011-09-06 09:31:57 -03002401 dib9000_set_slave_frontend(adap->fe_adap[0].fe, fe_slave);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002402
2403 return fe_slave == NULL ? -ENODEV : 0;
2404}
2405
2406static int nim9090md_tuner_attach(struct dvb_usb_adapter *adap)
2407{
2408 struct dib0700_adapter_state *state = adap->priv;
2409 struct i2c_adapter *i2c;
2410 struct dvb_frontend *fe_slave;
2411 u16 data_dib190[10] = {
2412 1, 0x5374,
2413 2, 0x01ae,
2414 7, 0x0020,
2415 0, 0x00ef,
2416 8, 0x0406,
2417 };
Michael Krufky77eed212011-09-06 09:31:57 -03002418 i2c = dib9000_get_tuner_interface(adap->fe_adap[0].fe);
2419 if (dvb_attach(dib0090_fw_register, adap->fe_adap[0].fe, i2c, &nim9090md_dib0090_config[0]) == NULL)
Olivier Greniebe9bae12011-01-04 05:42:19 -03002420 return -ENODEV;
Michael Krufky77eed212011-09-06 09:31:57 -03002421 i2c = dib9000_get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_GPIO_1_2, 0);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002422 if (dib01x0_pmu_update(i2c, data_dib190, 10) < 0)
2423 return -ENODEV;
Olivier Grenied1190022011-08-29 10:58:47 -03002424
2425 dib0700_set_i2c_speed(adap->dev, 1500);
Michael Krufky77eed212011-09-06 09:31:57 -03002426 if (dib9000_firmware_post_pll_init(adap->fe_adap[0].fe) < 0)
Olivier Greniebe9bae12011-01-04 05:42:19 -03002427 return -ENODEV;
2428
Michael Krufky77eed212011-09-06 09:31:57 -03002429 fe_slave = dib9000_get_slave_frontend(adap->fe_adap[0].fe, 1);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002430 if (fe_slave != NULL) {
Michael Krufky77eed212011-09-06 09:31:57 -03002431 i2c = dib9000_get_component_bus_interface(adap->fe_adap[0].fe);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002432 dib9000_set_i2c_adapter(fe_slave, i2c);
2433
2434 i2c = dib9000_get_tuner_interface(fe_slave);
2435 if (dvb_attach(dib0090_fw_register, fe_slave, i2c, &nim9090md_dib0090_config[1]) == NULL)
2436 return -ENODEV;
Michael Krufky77eed212011-09-06 09:31:57 -03002437 fe_slave->dvb = adap->fe_adap[0].fe->dvb;
Olivier Grenied1190022011-08-29 10:58:47 -03002438 dib9000_fw_set_component_bus_speed(adap->fe_adap[0].fe, 1500);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002439 if (dib9000_firmware_post_pll_init(fe_slave) < 0)
2440 return -ENODEV;
2441 }
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002442 release_firmware(state->frontend_firmware);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002443
2444 return 0;
2445}
2446
2447/* NIM7090 */
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03002448static int dib7090p_get_best_sampling(struct dvb_frontend *fe , struct dibx090p_best_adc *adc)
Olivier Greniebe9bae12011-01-04 05:42:19 -03002449{
2450 u8 spur = 0, prediv = 0, loopdiv = 0, min_prediv = 1, max_prediv = 1;
2451
2452 u16 xtal = 12000;
2453 u32 fcp_min = 1900; /* PLL Minimum Frequency comparator KHz */
2454 u32 fcp_max = 20000; /* PLL Maximum Frequency comparator KHz */
2455 u32 fdem_max = 76000;
2456 u32 fdem_min = 69500;
2457 u32 fcp = 0, fs = 0, fdem = 0;
2458 u32 harmonic_id = 0;
2459
2460 adc->pll_loopdiv = loopdiv;
2461 adc->pll_prediv = prediv;
2462 adc->timf = 0;
2463
2464 deb_info("bandwidth = %d fdem_min =%d", fe->dtv_property_cache.bandwidth_hz, fdem_min);
2465
2466 /* Find Min and Max prediv */
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002467 while ((xtal/max_prediv) >= fcp_min)
Olivier Greniebe9bae12011-01-04 05:42:19 -03002468 max_prediv++;
2469
2470 max_prediv--;
2471 min_prediv = max_prediv;
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002472 while ((xtal/min_prediv) <= fcp_max) {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002473 min_prediv--;
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002474 if (min_prediv == 1)
Olivier Greniebe9bae12011-01-04 05:42:19 -03002475 break;
2476 }
2477 deb_info("MIN prediv = %d : MAX prediv = %d", min_prediv, max_prediv);
2478
2479 min_prediv = 2;
2480
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002481 for (prediv = min_prediv ; prediv < max_prediv; prediv++) {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002482 fcp = xtal / prediv;
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002483 if (fcp > fcp_min && fcp < fcp_max) {
2484 for (loopdiv = 1 ; loopdiv < 64 ; loopdiv++) {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002485 fdem = ((xtal/prediv) * loopdiv);
2486 fs = fdem / 4;
2487 /* test min/max system restrictions */
2488
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002489 if ((fdem >= fdem_min) && (fdem <= fdem_max) && (fs >= fe->dtv_property_cache.bandwidth_hz/1000)) {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002490 spur = 0;
2491 /* test fs harmonics positions */
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002492 for (harmonic_id = (fe->dtv_property_cache.frequency / (1000*fs)) ; harmonic_id <= ((fe->dtv_property_cache.frequency / (1000*fs))+1) ; harmonic_id++) {
2493 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 -03002494 spur = 1;
2495 break;
2496 }
2497 }
2498
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002499 if (!spur) {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002500 adc->pll_loopdiv = loopdiv;
2501 adc->pll_prediv = prediv;
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002502 adc->timf = 2396745143UL/fdem*(1 << 9);
2503 adc->timf += ((2396745143UL%fdem) << 9)/fdem;
Olivier Greniebe9bae12011-01-04 05:42:19 -03002504 deb_info("loopdiv=%i prediv=%i timf=%i", loopdiv, prediv, adc->timf);
2505 break;
2506 }
2507 }
2508 }
2509 }
2510 if (!spur)
2511 break;
2512 }
2513
2514
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002515 if (adc->pll_loopdiv == 0 && adc->pll_prediv == 0)
Olivier Greniebe9bae12011-01-04 05:42:19 -03002516 return -EINVAL;
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002517 else
Olivier Greniebe9bae12011-01-04 05:42:19 -03002518 return 0;
2519}
2520
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -03002521static int dib7090_agc_startup(struct dvb_frontend *fe)
Olivier Greniebe9bae12011-01-04 05:42:19 -03002522{
2523 struct dvb_usb_adapter *adap = fe->dvb->priv;
2524 struct dib0700_adapter_state *state = adap->priv;
2525 struct dibx000_bandwidth_config pll;
2526 u16 target;
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03002527 struct dibx090p_best_adc adc;
Olivier Greniebe9bae12011-01-04 05:42:19 -03002528 int ret;
2529
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -03002530 ret = state->set_param_save(fe);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002531 if (ret < 0)
2532 return ret;
2533
2534 memset(&pll, 0, sizeof(struct dibx000_bandwidth_config));
2535 dib0090_pwm_gain_reset(fe);
Olivier Grenie6724a2f2011-08-05 13:49:33 -03002536 target = (dib0090_get_wbd_target(fe) * 8 + 1) / 2;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03002537 state->dib7000p_ops.set_wbd_ref(fe, target);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002538
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002539 if (dib7090p_get_best_sampling(fe, &adc) == 0) {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002540 pll.pll_ratio = adc.pll_loopdiv;
2541 pll.pll_prediv = adc.pll_prediv;
2542
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03002543 state->dib7000p_ops.update_pll(fe, &pll);
2544 state->dib7000p_ops.ctrl_timf(fe, DEMOD_TIMF_SET, adc.timf);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002545 }
2546 return 0;
2547}
2548
Olivier Grenie2e802862011-08-05 10:39:15 -03002549static int dib7090_agc_restart(struct dvb_frontend *fe, u8 restart)
2550{
2551 deb_info("AGC restart callback: %d", restart);
2552 if (restart == 0) /* before AGC startup */
2553 dib0090_set_dc_servo(fe, 1);
2554 return 0;
2555}
2556
Olivier Grenief45f5132012-12-31 09:47:10 -03002557static int tfe7790p_update_lna(struct dvb_frontend *fe, u16 agc_global)
Olivier Grenie6724a2f2011-08-05 13:49:33 -03002558{
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03002559 struct dvb_usb_adapter *adap = fe->dvb->priv;
2560 struct dib0700_adapter_state *state = adap->priv;
2561
Olivier Grenief45f5132012-12-31 09:47:10 -03002562 deb_info("update LNA: agc global=%i", agc_global);
Olivier Grenie6724a2f2011-08-05 13:49:33 -03002563
Olivier Grenief45f5132012-12-31 09:47:10 -03002564 if (agc_global < 25000) {
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03002565 state->dib7000p_ops.set_gpio(fe, 8, 0, 0);
2566 state->dib7000p_ops.set_agc1_min(fe, 0);
Olivier Grenie6724a2f2011-08-05 13:49:33 -03002567 } else {
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03002568 state->dib7000p_ops.set_gpio(fe, 8, 0, 1);
2569 state->dib7000p_ops.set_agc1_min(fe, 32768);
Olivier Grenie6724a2f2011-08-05 13:49:33 -03002570 }
2571
2572 return 0;
2573}
2574
Olivier Greniebe9bae12011-01-04 05:42:19 -03002575static struct dib0090_wbd_slope dib7090_wbd_table[] = {
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002576 { 380, 81, 850, 64, 540, 4},
2577 { 860, 51, 866, 21, 375, 4},
2578 {1700, 0, 250, 0, 100, 6},
2579 {2600, 0, 250, 0, 100, 6},
2580 { 0xFFFF, 0, 0, 0, 0, 0},
Olivier Greniebe9bae12011-01-04 05:42:19 -03002581};
2582
Olivier Greniea685dbb2011-08-05 14:10:40 -03002583static struct dibx000_agc_config dib7090_agc_config[2] = {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002584 {
2585 .band_caps = BAND_UHF,
2586 /* 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,
2587 * 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 -03002588 .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 -03002589
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002590 .inv_gain = 687,
2591 .time_stabiliz = 10,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002592
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002593 .alpha_level = 0,
2594 .thlock = 118,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002595
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002596 .wbd_inv = 0,
2597 .wbd_ref = 1200,
2598 .wbd_sel = 3,
2599 .wbd_alpha = 5,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002600
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002601 .agc1_max = 65535,
Olivier Grenie59501bb2012-12-31 09:51:17 -03002602 .agc1_min = 32768,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002603
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002604 .agc2_max = 65535,
2605 .agc2_min = 0,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002606
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002607 .agc1_pt1 = 0,
2608 .agc1_pt2 = 32,
2609 .agc1_pt3 = 114,
2610 .agc1_slope1 = 143,
2611 .agc1_slope2 = 144,
2612 .agc2_pt1 = 114,
2613 .agc2_pt2 = 227,
2614 .agc2_slope1 = 116,
2615 .agc2_slope2 = 117,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002616
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002617 .alpha_mant = 18,
2618 .alpha_exp = 0,
2619 .beta_mant = 20,
2620 .beta_exp = 59,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002621
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002622 .perform_agc_softsplit = 0,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002623 } , {
2624 .band_caps = BAND_FM | BAND_VHF | BAND_CBAND,
2625 /* 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,
2626 * 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 -03002627 .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 -03002628
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002629 .inv_gain = 732,
2630 .time_stabiliz = 10,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002631
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002632 .alpha_level = 0,
2633 .thlock = 118,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002634
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002635 .wbd_inv = 0,
2636 .wbd_ref = 1200,
2637 .wbd_sel = 3,
2638 .wbd_alpha = 5,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002639
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002640 .agc1_max = 65535,
2641 .agc1_min = 0,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002642
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002643 .agc2_max = 65535,
2644 .agc2_min = 0,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002645
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002646 .agc1_pt1 = 0,
2647 .agc1_pt2 = 0,
2648 .agc1_pt3 = 98,
2649 .agc1_slope1 = 0,
2650 .agc1_slope2 = 167,
Patrick Boettcher7f4d5272011-04-03 12:28:08 -03002651 .agc2_pt1 = 98,
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002652 .agc2_pt2 = 255,
2653 .agc2_slope1 = 104,
2654 .agc2_slope2 = 0,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002655
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002656 .alpha_mant = 18,
2657 .alpha_exp = 0,
2658 .beta_mant = 20,
2659 .beta_exp = 59,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002660
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002661 .perform_agc_softsplit = 0,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002662 }
2663};
2664
2665static struct dibx000_bandwidth_config dib7090_clock_config_12_mhz = {
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002666 60000, 15000,
2667 1, 5, 0, 0, 0,
2668 0, 0, 1, 1, 2,
2669 (3 << 14) | (1 << 12) | (524 << 0),
2670 (0 << 25) | 0,
2671 20452225,
2672 15000000,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002673};
2674
2675static struct dib7000p_config nim7090_dib7000p_config = {
2676 .output_mpeg2_in_188_bytes = 1,
2677 .hostbus_diversity = 1,
2678 .tuner_is_baseband = 1,
Olivier Grenie59501bb2012-12-31 09:51:17 -03002679 .update_lna = tfe7790p_update_lna, /* GPIO used is the same as TFE7790 */
Olivier Greniebe9bae12011-01-04 05:42:19 -03002680
2681 .agc_config_count = 2,
2682 .agc = dib7090_agc_config,
2683
2684 .bw = &dib7090_clock_config_12_mhz,
2685
2686 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
2687 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
2688 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
2689
2690 .pwm_freq_div = 0,
2691
2692 .agc_control = dib7090_agc_restart,
2693
2694 .spur_protect = 0,
2695 .disable_sample_and_hold = 0,
2696 .enable_current_mirror = 0,
2697 .diversity_delay = 0,
2698
2699 .output_mode = OUTMODE_MPEG2_FIFO,
2700 .enMpegOutput = 1,
2701};
2702
Olivier Grenie59501bb2012-12-31 09:51:17 -03002703static int tfe7090p_pvr_update_lna(struct dvb_frontend *fe, u16 agc_global)
2704{
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03002705 struct dvb_usb_adapter *adap = fe->dvb->priv;
2706 struct dib0700_adapter_state *state = adap->priv;
2707
Olivier Grenie59501bb2012-12-31 09:51:17 -03002708 deb_info("TFE7090P-PVR update LNA: agc global=%i", agc_global);
2709 if (agc_global < 25000) {
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03002710 state->dib7000p_ops.set_gpio(fe, 5, 0, 0);
2711 state->dib7000p_ops.set_agc1_min(fe, 0);
Olivier Grenie59501bb2012-12-31 09:51:17 -03002712 } else {
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03002713 state->dib7000p_ops.set_gpio(fe, 5, 0, 1);
2714 state->dib7000p_ops.set_agc1_min(fe, 32768);
Olivier Grenie59501bb2012-12-31 09:51:17 -03002715 }
2716
2717 return 0;
2718}
2719
Olivier Greniebe9bae12011-01-04 05:42:19 -03002720static struct dib7000p_config tfe7090pvr_dib7000p_config[2] = {
2721 {
2722 .output_mpeg2_in_188_bytes = 1,
2723 .hostbus_diversity = 1,
2724 .tuner_is_baseband = 1,
Olivier Grenie59501bb2012-12-31 09:51:17 -03002725 .update_lna = tfe7090p_pvr_update_lna,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002726
2727 .agc_config_count = 2,
2728 .agc = dib7090_agc_config,
2729
2730 .bw = &dib7090_clock_config_12_mhz,
2731
2732 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
2733 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
2734 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
2735
2736 .pwm_freq_div = 0,
2737
2738 .agc_control = dib7090_agc_restart,
2739
2740 .spur_protect = 0,
2741 .disable_sample_and_hold = 0,
2742 .enable_current_mirror = 0,
2743 .diversity_delay = 0,
2744
2745 .output_mode = OUTMODE_MPEG2_PAR_GATED_CLK,
2746 .default_i2c_addr = 0x90,
2747 .enMpegOutput = 1,
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002748 }, {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002749 .output_mpeg2_in_188_bytes = 1,
2750 .hostbus_diversity = 1,
2751 .tuner_is_baseband = 1,
Olivier Grenie59501bb2012-12-31 09:51:17 -03002752 .update_lna = tfe7090p_pvr_update_lna,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002753
2754 .agc_config_count = 2,
2755 .agc = dib7090_agc_config,
2756
2757 .bw = &dib7090_clock_config_12_mhz,
2758
2759 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
2760 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
2761 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
2762
2763 .pwm_freq_div = 0,
2764
2765 .agc_control = dib7090_agc_restart,
2766
2767 .spur_protect = 0,
2768 .disable_sample_and_hold = 0,
2769 .enable_current_mirror = 0,
2770 .diversity_delay = 0,
2771
2772 .output_mode = OUTMODE_MPEG2_PAR_GATED_CLK,
2773 .default_i2c_addr = 0x92,
2774 .enMpegOutput = 0,
2775 }
2776};
2777
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03002778static struct dib0090_config nim7090_dib0090_config = {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002779 .io.clock_khz = 12000,
2780 .io.pll_bypass = 0,
2781 .io.pll_range = 0,
2782 .io.pll_prediv = 3,
2783 .io.pll_loopdiv = 6,
2784 .io.adc_clock_ratio = 0,
2785 .io.pll_int_loop_filt = 0,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002786
2787 .freq_offset_khz_uhf = 0,
2788 .freq_offset_khz_vhf = 0,
2789
Olivier Greniebe9bae12011-01-04 05:42:19 -03002790 .clkouttobamse = 1,
2791 .analog_output = 0,
2792
2793 .wbd_vhf_offset = 0,
2794 .wbd_cband_offset = 0,
2795 .use_pwm_agc = 1,
2796 .clkoutdrive = 0,
2797
2798 .fref_clock_ratio = 0,
2799
2800 .wbd = dib7090_wbd_table,
2801
2802 .ls_cfg_pad_drv = 0,
2803 .data_tx_drv = 0,
2804 .low_if = NULL,
2805 .in_soc = 1,
2806};
2807
Olivier Grenief45f5132012-12-31 09:47:10 -03002808static struct dib7000p_config tfe7790p_dib7000p_config = {
Olivier Grenieb293f302011-08-09 04:48:25 -03002809 .output_mpeg2_in_188_bytes = 1,
2810 .hostbus_diversity = 1,
2811 .tuner_is_baseband = 1,
Olivier Grenief45f5132012-12-31 09:47:10 -03002812 .update_lna = tfe7790p_update_lna,
Olivier Grenieb293f302011-08-09 04:48:25 -03002813
2814 .agc_config_count = 2,
2815 .agc = dib7090_agc_config,
2816
2817 .bw = &dib7090_clock_config_12_mhz,
2818
2819 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
2820 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
2821 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
2822
2823 .pwm_freq_div = 0,
2824
2825 .agc_control = dib7090_agc_restart,
2826
2827 .spur_protect = 0,
2828 .disable_sample_and_hold = 0,
2829 .enable_current_mirror = 0,
2830 .diversity_delay = 0,
2831
2832 .output_mode = OUTMODE_MPEG2_PAR_GATED_CLK,
2833 .enMpegOutput = 1,
2834};
2835
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03002836static struct dib0090_config tfe7790p_dib0090_config = {
Olivier Grenieb293f302011-08-09 04:48:25 -03002837 .io.clock_khz = 12000,
2838 .io.pll_bypass = 0,
2839 .io.pll_range = 0,
2840 .io.pll_prediv = 3,
2841 .io.pll_loopdiv = 6,
2842 .io.adc_clock_ratio = 0,
2843 .io.pll_int_loop_filt = 0,
Olivier Grenieb293f302011-08-09 04:48:25 -03002844
2845 .freq_offset_khz_uhf = 0,
2846 .freq_offset_khz_vhf = 0,
2847
Olivier Grenieb293f302011-08-09 04:48:25 -03002848 .clkouttobamse = 1,
2849 .analog_output = 0,
2850
2851 .wbd_vhf_offset = 0,
2852 .wbd_cband_offset = 0,
2853 .use_pwm_agc = 1,
2854 .clkoutdrive = 0,
2855
2856 .fref_clock_ratio = 0,
2857
Olivier Grenief45f5132012-12-31 09:47:10 -03002858 .wbd = dib7090_wbd_table,
Olivier Grenieb293f302011-08-09 04:48:25 -03002859
2860 .ls_cfg_pad_drv = 0,
2861 .data_tx_drv = 0,
2862 .low_if = NULL,
2863 .in_soc = 1,
Olivier Grenief45f5132012-12-31 09:47:10 -03002864 .force_cband_input = 0,
2865 .is_dib7090e = 0,
Olivier Grenieb293f302011-08-09 04:48:25 -03002866 .force_crystal_mode = 1,
2867};
2868
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03002869static struct dib0090_config tfe7090pvr_dib0090_config[2] = {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002870 {
2871 .io.clock_khz = 12000,
2872 .io.pll_bypass = 0,
2873 .io.pll_range = 0,
2874 .io.pll_prediv = 3,
2875 .io.pll_loopdiv = 6,
2876 .io.adc_clock_ratio = 0,
2877 .io.pll_int_loop_filt = 0,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002878
2879 .freq_offset_khz_uhf = 50,
2880 .freq_offset_khz_vhf = 70,
2881
Olivier Greniebe9bae12011-01-04 05:42:19 -03002882 .clkouttobamse = 1,
2883 .analog_output = 0,
2884
2885 .wbd_vhf_offset = 0,
2886 .wbd_cband_offset = 0,
2887 .use_pwm_agc = 1,
2888 .clkoutdrive = 0,
2889
2890 .fref_clock_ratio = 0,
2891
2892 .wbd = dib7090_wbd_table,
2893
2894 .ls_cfg_pad_drv = 0,
2895 .data_tx_drv = 0,
2896 .low_if = NULL,
2897 .in_soc = 1,
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002898 }, {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002899 .io.clock_khz = 12000,
2900 .io.pll_bypass = 0,
2901 .io.pll_range = 0,
2902 .io.pll_prediv = 3,
2903 .io.pll_loopdiv = 6,
2904 .io.adc_clock_ratio = 0,
2905 .io.pll_int_loop_filt = 0,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002906
2907 .freq_offset_khz_uhf = -50,
2908 .freq_offset_khz_vhf = -70,
2909
Olivier Greniebe9bae12011-01-04 05:42:19 -03002910 .clkouttobamse = 1,
2911 .analog_output = 0,
2912
2913 .wbd_vhf_offset = 0,
2914 .wbd_cband_offset = 0,
2915 .use_pwm_agc = 1,
2916 .clkoutdrive = 0,
2917
2918 .fref_clock_ratio = 0,
2919
2920 .wbd = dib7090_wbd_table,
2921
2922 .ls_cfg_pad_drv = 0,
2923 .data_tx_drv = 0,
2924 .low_if = NULL,
2925 .in_soc = 1,
2926 }
2927};
2928
2929static int nim7090_frontend_attach(struct dvb_usb_adapter *adap)
2930{
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03002931 struct dib0700_adapter_state *state = adap->priv;
2932
2933 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
2934 return -ENODEV;
2935
Olivier Greniebe9bae12011-01-04 05:42:19 -03002936 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002937 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002938 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
2939 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
2940 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
2941 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
2942
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002943 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002944 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002945 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002946 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
2947
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03002948 if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 0x10, &nim7090_dib7000p_config) != 0) {
2949 err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n", __func__);
2950 dvb_detach(&state->dib7000p_ops);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002951 return -ENODEV;
2952 }
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03002953 adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap, 0x80, &nim7090_dib7000p_config);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002954
Michael Krufky77eed212011-09-06 09:31:57 -03002955 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Olivier Greniebe9bae12011-01-04 05:42:19 -03002956}
2957
2958static int nim7090_tuner_attach(struct dvb_usb_adapter *adap)
2959{
2960 struct dib0700_adapter_state *st = adap->priv;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03002961 struct i2c_adapter *tun_i2c = st->dib7000p_ops.get_i2c_tuner(adap->fe_adap[0].fe);
2962
2963 nim7090_dib0090_config.reset = st->dib7000p_ops.tuner_sleep,
2964 nim7090_dib0090_config.sleep = st->dib7000p_ops.tuner_sleep,
2965 nim7090_dib0090_config.get_adc_power = st->dib7000p_ops.get_adc_power;
Olivier Greniebe9bae12011-01-04 05:42:19 -03002966
Michael Krufky77eed212011-09-06 09:31:57 -03002967 if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c, &nim7090_dib0090_config) == NULL)
Olivier Greniebe9bae12011-01-04 05:42:19 -03002968 return -ENODEV;
2969
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03002970 st->dib7000p_ops.set_gpio(adap->fe_adap[0].fe, 8, 0, 1);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002971
Michael Krufky77eed212011-09-06 09:31:57 -03002972 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
2973 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib7090_agc_startup;
Olivier Greniebe9bae12011-01-04 05:42:19 -03002974 return 0;
2975}
2976
2977static int tfe7090pvr_frontend0_attach(struct dvb_usb_adapter *adap)
2978{
2979 struct dib0700_state *st = adap->dev->priv;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03002980 struct dib0700_adapter_state *state = adap->priv;
2981
2982 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
2983 return -ENODEV;
Olivier Greniebe9bae12011-01-04 05:42:19 -03002984
2985 /* The TFE7090 requires the dib0700 to not be in master mode */
2986 st->disable_streaming_master_mode = 1;
2987
2988 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002989 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002990 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
2991 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
2992 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
2993 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
2994
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002995 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002996 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002997 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002998 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
2999
3000 /* initialize IC 0 */
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003001 if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 0x20, &tfe7090pvr_dib7000p_config[0]) != 0) {
3002 err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n", __func__);
3003 dvb_detach(&state->dib7000p_ops);
Olivier Greniebe9bae12011-01-04 05:42:19 -03003004 return -ENODEV;
3005 }
3006
3007 dib0700_set_i2c_speed(adap->dev, 340);
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003008 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 -03003009 if (adap->fe_adap[0].fe == NULL)
Olivier Greniebe9bae12011-01-04 05:42:19 -03003010 return -ENODEV;
3011
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003012 state->dib7000p_ops.slave_reset(adap->fe_adap[0].fe);
Patrick Boettcher71682522011-04-03 12:44:25 -03003013
Olivier Greniebe9bae12011-01-04 05:42:19 -03003014 return 0;
3015}
3016
3017static int tfe7090pvr_frontend1_attach(struct dvb_usb_adapter *adap)
3018{
3019 struct i2c_adapter *i2c;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003020 struct dib0700_adapter_state *state = adap->priv;
Olivier Greniebe9bae12011-01-04 05:42:19 -03003021
Michael Krufky77eed212011-09-06 09:31:57 -03003022 if (adap->dev->adapter[0].fe_adap[0].fe == NULL) {
Olivier Greniebe9bae12011-01-04 05:42:19 -03003023 err("the master dib7090 has to be initialized first");
3024 return -ENODEV; /* the master device has not been initialized */
3025 }
3026
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003027 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
3028 return -ENODEV;
3029
3030 i2c = state->dib7000p_ops.get_i2c_master(adap->dev->adapter[0].fe_adap[0].fe, DIBX000_I2C_INTERFACE_GPIO_6_7, 1);
3031 if (state->dib7000p_ops.i2c_enumeration(i2c, 1, 0x10, &tfe7090pvr_dib7000p_config[1]) != 0) {
3032 err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n", __func__);
3033 dvb_detach(&state->dib7000p_ops);
Olivier Greniebe9bae12011-01-04 05:42:19 -03003034 return -ENODEV;
3035 }
3036
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003037 adap->fe_adap[0].fe = state->dib7000p_ops.init(i2c, 0x92, &tfe7090pvr_dib7000p_config[1]);
Olivier Greniebe9bae12011-01-04 05:42:19 -03003038 dib0700_set_i2c_speed(adap->dev, 200);
3039
Michael Krufky77eed212011-09-06 09:31:57 -03003040 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Olivier Greniebe9bae12011-01-04 05:42:19 -03003041}
3042
3043static int tfe7090pvr_tuner0_attach(struct dvb_usb_adapter *adap)
3044{
3045 struct dib0700_adapter_state *st = adap->priv;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003046 struct i2c_adapter *tun_i2c = st->dib7000p_ops.get_i2c_tuner(adap->fe_adap[0].fe);
3047
3048 tfe7090pvr_dib0090_config[0].reset = st->dib7000p_ops.tuner_sleep;
3049 tfe7090pvr_dib0090_config[0].sleep = st->dib7000p_ops.tuner_sleep;
3050 tfe7090pvr_dib0090_config[0].get_adc_power = st->dib7000p_ops.get_adc_power;
Olivier Greniebe9bae12011-01-04 05:42:19 -03003051
Michael Krufky77eed212011-09-06 09:31:57 -03003052 if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c, &tfe7090pvr_dib0090_config[0]) == NULL)
Olivier Greniebe9bae12011-01-04 05:42:19 -03003053 return -ENODEV;
3054
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003055 st->dib7000p_ops.set_gpio(adap->fe_adap[0].fe, 8, 0, 1);
Olivier Greniebe9bae12011-01-04 05:42:19 -03003056
Michael Krufky77eed212011-09-06 09:31:57 -03003057 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
3058 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib7090_agc_startup;
Olivier Greniebe9bae12011-01-04 05:42:19 -03003059 return 0;
3060}
3061
3062static int tfe7090pvr_tuner1_attach(struct dvb_usb_adapter *adap)
3063{
3064 struct dib0700_adapter_state *st = adap->priv;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003065 struct i2c_adapter *tun_i2c = st->dib7000p_ops.get_i2c_tuner(adap->fe_adap[0].fe);
3066
3067 tfe7090pvr_dib0090_config[1].reset = st->dib7000p_ops.tuner_sleep;
3068 tfe7090pvr_dib0090_config[1].sleep = st->dib7000p_ops.tuner_sleep;
3069 tfe7090pvr_dib0090_config[1].get_adc_power = st->dib7000p_ops.get_adc_power;
Olivier Greniebe9bae12011-01-04 05:42:19 -03003070
Michael Krufky77eed212011-09-06 09:31:57 -03003071 if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c, &tfe7090pvr_dib0090_config[1]) == NULL)
Olivier Greniebe9bae12011-01-04 05:42:19 -03003072 return -ENODEV;
3073
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003074 st->dib7000p_ops.set_gpio(adap->fe_adap[0].fe, 8, 0, 1);
Olivier Greniebe9bae12011-01-04 05:42:19 -03003075
Michael Krufky77eed212011-09-06 09:31:57 -03003076 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
3077 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib7090_agc_startup;
Olivier Greniebe9bae12011-01-04 05:42:19 -03003078 return 0;
3079}
3080
Olivier Grenief45f5132012-12-31 09:47:10 -03003081static int tfe7790p_frontend_attach(struct dvb_usb_adapter *adap)
Olivier Grenieb293f302011-08-09 04:48:25 -03003082{
3083 struct dib0700_state *st = adap->dev->priv;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003084 struct dib0700_adapter_state *state = adap->priv;
3085
3086 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
3087 return -ENODEV;
Olivier Grenieb293f302011-08-09 04:48:25 -03003088
Olivier Grenief45f5132012-12-31 09:47:10 -03003089 /* The TFE7790P requires the dib0700 to not be in master mode */
Olivier Grenieb293f302011-08-09 04:48:25 -03003090 st->disable_streaming_master_mode = 1;
3091
3092 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
3093 msleep(20);
3094 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
3095 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
3096 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
3097 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
3098 msleep(20);
3099 dib0700_ctrl_clock(adap->dev, 72, 1);
3100 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
3101 msleep(20);
3102 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
3103
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003104 if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap,
Olivier Grenief45f5132012-12-31 09:47:10 -03003105 1, 0x10, &tfe7790p_dib7000p_config) != 0) {
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003106 err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n",
Olivier Grenieb293f302011-08-09 04:48:25 -03003107 __func__);
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003108 dvb_detach(&state->dib7000p_ops);
Olivier Grenieb293f302011-08-09 04:48:25 -03003109 return -ENODEV;
3110 }
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003111 adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap,
Olivier Grenief45f5132012-12-31 09:47:10 -03003112 0x80, &tfe7790p_dib7000p_config);
Olivier Grenieb293f302011-08-09 04:48:25 -03003113
3114 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
3115}
3116
Olivier Grenief45f5132012-12-31 09:47:10 -03003117static int tfe7790p_tuner_attach(struct dvb_usb_adapter *adap)
Olivier Grenieb293f302011-08-09 04:48:25 -03003118{
3119 struct dib0700_adapter_state *st = adap->priv;
3120 struct i2c_adapter *tun_i2c =
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003121 st->dib7000p_ops.get_i2c_tuner(adap->fe_adap[0].fe);
3122
3123
3124 tfe7790p_dib0090_config.reset = st->dib7000p_ops.tuner_sleep;
3125 tfe7790p_dib0090_config.sleep = st->dib7000p_ops.tuner_sleep;
3126 tfe7790p_dib0090_config.get_adc_power = st->dib7000p_ops.get_adc_power;
Olivier Grenieb293f302011-08-09 04:48:25 -03003127
3128 if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c,
Olivier Grenief45f5132012-12-31 09:47:10 -03003129 &tfe7790p_dib0090_config) == NULL)
Olivier Grenie6724a2f2011-08-05 13:49:33 -03003130 return -ENODEV;
3131
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003132 st->dib7000p_ops.set_gpio(adap->fe_adap[0].fe, 8, 0, 1);
Olivier Grenie6724a2f2011-08-05 13:49:33 -03003133
3134 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
3135 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib7090_agc_startup;
3136 return 0;
3137}
3138
Patrick Boettcher01373a52007-07-30 12:49:04 -03003139/* STK7070PD */
3140static struct dib7000p_config stk7070pd_dib7000p_config[2] = {
3141 {
3142 .output_mpeg2_in_188_bytes = 1,
3143
3144 .agc_config_count = 1,
3145 .agc = &dib7070_agc_config,
3146 .bw = &dib7070_bw_config_12_mhz,
Patrick Boettcher3cb2c392008-01-25 07:25:20 -03003147 .tuner_is_baseband = 1,
3148 .spur_protect = 1,
Patrick Boettcher01373a52007-07-30 12:49:04 -03003149
3150 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
3151 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
3152 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
3153
3154 .hostbus_diversity = 1,
3155 }, {
3156 .output_mpeg2_in_188_bytes = 1,
3157
3158 .agc_config_count = 1,
3159 .agc = &dib7070_agc_config,
3160 .bw = &dib7070_bw_config_12_mhz,
Patrick Boettcher3cb2c392008-01-25 07:25:20 -03003161 .tuner_is_baseband = 1,
3162 .spur_protect = 1,
Patrick Boettcher01373a52007-07-30 12:49:04 -03003163
3164 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
3165 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
3166 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
3167
3168 .hostbus_diversity = 1,
3169 }
3170};
3171
Jiri Slaby52fd5b22012-01-10 14:11:23 -03003172static void stk7070pd_init(struct dvb_usb_device *dev)
3173{
3174 dib0700_set_gpio(dev, GPIO6, GPIO_OUT, 1);
3175 msleep(10);
3176 dib0700_set_gpio(dev, GPIO9, GPIO_OUT, 1);
3177 dib0700_set_gpio(dev, GPIO4, GPIO_OUT, 1);
3178 dib0700_set_gpio(dev, GPIO7, GPIO_OUT, 1);
3179 dib0700_set_gpio(dev, GPIO10, GPIO_OUT, 0);
3180
3181 dib0700_ctrl_clock(dev, 72, 1);
3182
3183 msleep(10);
3184 dib0700_set_gpio(dev, GPIO10, GPIO_OUT, 1);
3185}
3186
Patrick Boettcher01373a52007-07-30 12:49:04 -03003187static int stk7070pd_frontend_attach0(struct dvb_usb_adapter *adap)
3188{
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003189 struct dib0700_adapter_state *state = adap->priv;
3190
3191 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
3192 return -ENODEV;
3193
Jiri Slaby52fd5b22012-01-10 14:11:23 -03003194 stk7070pd_init(adap->dev);
Patrick Boettcher01373a52007-07-30 12:49:04 -03003195
Patrick Boettcher01373a52007-07-30 12:49:04 -03003196 msleep(10);
3197 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
3198
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003199 if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap, 2, 18,
Devin Heitmueller83c4fdf2009-01-21 01:55:45 -03003200 stk7070pd_dib7000p_config) != 0) {
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003201 err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n",
Devin Heitmueller83c4fdf2009-01-21 01:55:45 -03003202 __func__);
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003203 dvb_detach(&state->dib7000p_ops);
Devin Heitmueller83c4fdf2009-01-21 01:55:45 -03003204 return -ENODEV;
3205 }
Patrick Boettcher01373a52007-07-30 12:49:04 -03003206
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003207 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 -03003208 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Patrick Boettcher01373a52007-07-30 12:49:04 -03003209}
3210
3211static int stk7070pd_frontend_attach1(struct dvb_usb_adapter *adap)
3212{
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003213 struct dib0700_adapter_state *state = adap->priv;
3214
3215 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
3216 return -ENODEV;
3217
3218 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 -03003219 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Patrick Boettcher01373a52007-07-30 12:49:04 -03003220}
3221
Jiri Slabyd43272a2012-01-10 14:11:25 -03003222static int novatd_read_status_override(struct dvb_frontend *fe,
3223 fe_status_t *stat)
3224{
3225 struct dvb_usb_adapter *adap = fe->dvb->priv;
3226 struct dvb_usb_device *dev = adap->dev;
3227 struct dib0700_state *state = dev->priv;
3228 int ret;
3229
3230 ret = state->read_status(fe, stat);
3231
3232 if (!ret)
3233 dib0700_set_gpio(dev, adap->id == 0 ? GPIO1 : GPIO0, GPIO_OUT,
3234 !!(*stat & FE_HAS_LOCK));
3235
3236 return ret;
3237}
3238
3239static int novatd_sleep_override(struct dvb_frontend* fe)
3240{
3241 struct dvb_usb_adapter *adap = fe->dvb->priv;
3242 struct dvb_usb_device *dev = adap->dev;
3243 struct dib0700_state *state = dev->priv;
3244
3245 /* turn off LED */
3246 dib0700_set_gpio(dev, adap->id == 0 ? GPIO1 : GPIO0, GPIO_OUT, 0);
3247
3248 return state->sleep(fe);
3249}
3250
Jiri Slaby2b05b882012-01-10 14:11:24 -03003251/**
3252 * novatd_frontend_attach - Nova-TD specific attach
3253 *
3254 * Nova-TD has GPIO0, 1 and 2 for LEDs. So do not fiddle with them except for
3255 * information purposes.
3256 */
3257static int novatd_frontend_attach(struct dvb_usb_adapter *adap)
3258{
3259 struct dvb_usb_device *dev = adap->dev;
Jiri Slabyd43272a2012-01-10 14:11:25 -03003260 struct dib0700_state *st = dev->priv;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003261 struct dib0700_adapter_state *state = adap->priv;
3262
3263 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
3264 return -ENODEV;
Jiri Slaby2b05b882012-01-10 14:11:24 -03003265
3266 if (adap->id == 0) {
3267 stk7070pd_init(dev);
3268
3269 /* turn the power LED on, the other two off (just in case) */
3270 dib0700_set_gpio(dev, GPIO0, GPIO_OUT, 0);
3271 dib0700_set_gpio(dev, GPIO1, GPIO_OUT, 0);
3272 dib0700_set_gpio(dev, GPIO2, GPIO_OUT, 1);
3273
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003274 if (state->dib7000p_ops.i2c_enumeration(&dev->i2c_adap, 2, 18,
Jiri Slaby2b05b882012-01-10 14:11:24 -03003275 stk7070pd_dib7000p_config) != 0) {
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003276 err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n",
Jiri Slaby2b05b882012-01-10 14:11:24 -03003277 __func__);
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003278 dvb_detach(&state->dib7000p_ops);
Jiri Slaby2b05b882012-01-10 14:11:24 -03003279 return -ENODEV;
3280 }
3281 }
3282
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003283 adap->fe_adap[0].fe = state->dib7000p_ops.init(&dev->i2c_adap,
Jiri Slaby2b05b882012-01-10 14:11:24 -03003284 adap->id == 0 ? 0x80 : 0x82,
3285 &stk7070pd_dib7000p_config[adap->id]);
Jiri Slabyd43272a2012-01-10 14:11:25 -03003286
3287 if (adap->fe_adap[0].fe == NULL)
3288 return -ENODEV;
3289
3290 st->read_status = adap->fe_adap[0].fe->ops.read_status;
3291 adap->fe_adap[0].fe->ops.read_status = novatd_read_status_override;
3292 st->sleep = adap->fe_adap[0].fe->ops.sleep;
3293 adap->fe_adap[0].fe->ops.sleep = novatd_sleep_override;
3294
3295 return 0;
Jiri Slaby2b05b882012-01-10 14:11:24 -03003296}
3297
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03003298/* S5H1411 */
3299static struct s5h1411_config pinnacle_801e_config = {
3300 .output_mode = S5H1411_PARALLEL_OUTPUT,
3301 .gpio = S5H1411_GPIO_OFF,
3302 .mpeg_timing = S5H1411_MPEGTIMING_NONCONTINOUS_NONINVERTING_CLOCK,
3303 .qam_if = S5H1411_IF_44000,
3304 .vsb_if = S5H1411_IF_44000,
3305 .inversion = S5H1411_INVERSION_OFF,
3306 .status_mode = S5H1411_DEMODLOCKING
3307};
3308
3309/* Pinnacle PCTV HD Pro 801e GPIOs map:
3310 GPIO0 - currently unknown
3311 GPIO1 - xc5000 tuner reset
3312 GPIO2 - CX25843 sleep
3313 GPIO3 - currently unknown
3314 GPIO4 - currently unknown
3315 GPIO6 - currently unknown
3316 GPIO7 - currently unknown
3317 GPIO9 - currently unknown
3318 GPIO10 - CX25843 reset
3319 */
3320static int s5h1411_frontend_attach(struct dvb_usb_adapter *adap)
3321{
3322 struct dib0700_state *st = adap->dev->priv;
3323
3324 /* Make use of the new i2c functions from FW 1.20 */
3325 st->fw_use_new_i2c_api = 1;
3326
3327 /* The s5h1411 requires the dib0700 to not be in master mode */
3328 st->disable_streaming_master_mode = 1;
3329
3330 /* All msleep values taken from Windows USB trace */
3331 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 0);
3332 dib0700_set_gpio(adap->dev, GPIO3, GPIO_OUT, 0);
3333 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
3334 msleep(400);
3335 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
3336 msleep(60);
3337 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
3338 msleep(30);
3339 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
3340 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
3341 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
3342 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
3343 dib0700_set_gpio(adap->dev, GPIO2, GPIO_OUT, 0);
3344 msleep(30);
3345
3346 /* Put the CX25843 to sleep for now since we're in digital mode */
3347 dib0700_set_gpio(adap->dev, GPIO2, GPIO_OUT, 1);
3348
3349 /* GPIOs are initialized, do the attach */
Michael Krufky77eed212011-09-06 09:31:57 -03003350 adap->fe_adap[0].fe = dvb_attach(s5h1411_attach, &pinnacle_801e_config,
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03003351 &adap->dev->i2c_adap);
Michael Krufky77eed212011-09-06 09:31:57 -03003352 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03003353}
3354
Michael Krufky767f3b32008-09-25 09:47:07 -03003355static int dib0700_xc5000_tuner_callback(void *priv, int component,
3356 int command, int arg)
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03003357{
3358 struct dvb_usb_adapter *adap = priv;
3359
Devin Heitmueller79025a92008-10-06 12:07:48 -03003360 if (command == XC5000_TUNER_RESET) {
3361 /* Reset the tuner */
3362 dib0700_set_gpio(adap->dev, GPIO1, GPIO_OUT, 0);
Devin Heitmuellerf0f46332009-05-04 21:57:41 -03003363 msleep(10);
Devin Heitmueller79025a92008-10-06 12:07:48 -03003364 dib0700_set_gpio(adap->dev, GPIO1, GPIO_OUT, 1);
Devin Heitmuellerf0f46332009-05-04 21:57:41 -03003365 msleep(10);
Devin Heitmueller79025a92008-10-06 12:07:48 -03003366 } else {
3367 err("xc5000: unknown tuner callback command: %d\n", command);
3368 return -EINVAL;
3369 }
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03003370
3371 return 0;
3372}
3373
3374static struct xc5000_config s5h1411_xc5000_tunerconfig = {
3375 .i2c_address = 0x64,
3376 .if_khz = 5380,
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03003377};
3378
3379static int xc5000_tuner_attach(struct dvb_usb_adapter *adap)
3380{
Devin Heitmueller79025a92008-10-06 12:07:48 -03003381 /* FIXME: generalize & move to common area */
Michael Krufky77eed212011-09-06 09:31:57 -03003382 adap->fe_adap[0].fe->callback = dib0700_xc5000_tuner_callback;
Devin Heitmueller79025a92008-10-06 12:07:48 -03003383
Michael Krufky77eed212011-09-06 09:31:57 -03003384 return dvb_attach(xc5000_attach, adap->fe_adap[0].fe, &adap->dev->i2c_adap,
Michael Krufky767f3b32008-09-25 09:47:07 -03003385 &s5h1411_xc5000_tunerconfig)
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03003386 == NULL ? -ENODEV : 0;
3387}
3388
Davide Ferri8d009a02009-06-23 22:34:06 -03003389static int dib0700_xc4000_tuner_callback(void *priv, int component,
3390 int command, int arg)
3391{
3392 struct dvb_usb_adapter *adap = priv;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003393 struct dib0700_adapter_state *state = adap->priv;
Davide Ferri8d009a02009-06-23 22:34:06 -03003394
3395 if (command == XC4000_TUNER_RESET) {
3396 /* Reset the tuner */
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003397 state->dib7000p_ops.set_gpio(adap->fe_adap[0].fe, 8, 0, 0);
Davide Ferri8d009a02009-06-23 22:34:06 -03003398 msleep(10);
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003399 state->dib7000p_ops.set_gpio(adap->fe_adap[0].fe, 8, 0, 1);
Davide Ferri8d009a02009-06-23 22:34:06 -03003400 } else {
3401 err("xc4000: unknown tuner callback command: %d\n", command);
3402 return -EINVAL;
3403 }
3404
3405 return 0;
3406}
3407
Devin Heitmueller8583fc82009-07-28 01:16:05 -03003408static struct dibx000_agc_config stk7700p_7000p_xc4000_agc_config = {
3409 .band_caps = BAND_UHF | BAND_VHF,
3410 .setup = 0x64,
3411 .inv_gain = 0x02c8,
3412 .time_stabiliz = 0x15,
3413 .alpha_level = 0x00,
3414 .thlock = 0x76,
3415 .wbd_inv = 0x01,
3416 .wbd_ref = 0x0b33,
3417 .wbd_sel = 0x00,
3418 .wbd_alpha = 0x02,
3419 .agc1_max = 0x00,
3420 .agc1_min = 0x00,
3421 .agc2_max = 0x9b26,
3422 .agc2_min = 0x26ca,
3423 .agc1_pt1 = 0x00,
3424 .agc1_pt2 = 0x00,
3425 .agc1_pt3 = 0x00,
3426 .agc1_slope1 = 0x00,
3427 .agc1_slope2 = 0x00,
3428 .agc2_pt1 = 0x00,
3429 .agc2_pt2 = 0x80,
3430 .agc2_slope1 = 0x1d,
3431 .agc2_slope2 = 0x1d,
Devin Heitmueller2df12512009-12-27 17:44:31 -03003432 .alpha_mant = 0x11,
Devin Heitmueller8583fc82009-07-28 01:16:05 -03003433 .alpha_exp = 0x1b,
3434 .beta_mant = 0x17,
3435 .beta_exp = 0x33,
3436 .perform_agc_softsplit = 0x00,
3437};
3438
Devin Heitmuellerf1c78d32009-10-05 00:34:04 -03003439static struct dibx000_bandwidth_config stk7700p_xc4000_pll_config = {
istvan_v@mailbox.hu341747b2011-06-06 12:54:54 -03003440 60000, 30000, /* internal, sampling */
3441 1, 8, 3, 1, 0, /* pll_cfg: prediv, ratio, range, reset, bypass */
3442 0, 0, 1, 1, 0, /* misc: refdiv, bypclk_div, IO_CLK_en_core, */
3443 /* ADClkSrc, modulo */
3444 (3 << 14) | (1 << 12) | 524, /* sad_cfg: refsel, sel, freq_15k */
3445 39370534, /* ifreq */
3446 20452225, /* timf */
3447 30000000 /* xtal */
Devin Heitmuellerf1c78d32009-10-05 00:34:04 -03003448};
3449
Devin Heitmueller01f16262009-06-24 00:07:01 -03003450/* FIXME: none of these inputs are validated yet */
3451static struct dib7000p_config pctv_340e_config = {
Devin Heitmueller62956ce2009-12-27 18:58:11 -03003452 .output_mpeg2_in_188_bytes = 1,
Devin Heitmueller01f16262009-06-24 00:07:01 -03003453
3454 .agc_config_count = 1,
Devin Heitmueller8583fc82009-07-28 01:16:05 -03003455 .agc = &stk7700p_7000p_xc4000_agc_config,
Devin Heitmuellerf1c78d32009-10-05 00:34:04 -03003456 .bw = &stk7700p_xc4000_pll_config,
Devin Heitmueller01f16262009-06-24 00:07:01 -03003457
Devin Heitmueller01f16262009-06-24 00:07:01 -03003458 .gpio_dir = DIB7000M_GPIO_DEFAULT_DIRECTIONS,
3459 .gpio_val = DIB7000M_GPIO_DEFAULT_VALUES,
3460 .gpio_pwm_pos = DIB7000M_GPIO_DEFAULT_PWM_POS,
3461};
3462
3463/* PCTV 340e GPIOs map:
3464 dib0700:
3465 GPIO2 - CX25843 sleep
3466 GPIO3 - CS5340 reset
3467 GPIO5 - IRD
3468 GPIO6 - Power Supply
3469 GPIO8 - LNA (1=off 0=on)
3470 GPIO10 - CX25843 reset
3471 dib7000:
3472 GPIO8 - xc4000 reset
3473 */
3474static int pctv340e_frontend_attach(struct dvb_usb_adapter *adap)
3475{
3476 struct dib0700_state *st = adap->dev->priv;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003477 struct dib0700_adapter_state *state = adap->priv;
3478
3479 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
3480 return -ENODEV;
Devin Heitmueller01f16262009-06-24 00:07:01 -03003481
3482 /* Power Supply on */
3483 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
3484 msleep(50);
3485 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
3486 msleep(100); /* Allow power supply to settle before probing */
3487
3488 /* cx25843 reset */
3489 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
3490 msleep(1); /* cx25843 datasheet say 350us required */
3491 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
3492
3493 /* LNA off for now */
3494 dib0700_set_gpio(adap->dev, GPIO8, GPIO_OUT, 1);
3495
3496 /* Put the CX25843 to sleep for now since we're in digital mode */
3497 dib0700_set_gpio(adap->dev, GPIO2, GPIO_OUT, 1);
3498
3499 /* FIXME: not verified yet */
3500 dib0700_ctrl_clock(adap->dev, 72, 1);
3501
Devin Heitmueller2750d9c2009-07-20 00:42:33 -03003502 msleep(500);
3503
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003504 if (state->dib7000p_ops.dib7000pc_detection(&adap->dev->i2c_adap) == 0) {
Devin Heitmueller01f16262009-06-24 00:07:01 -03003505 /* Demodulator not found for some reason? */
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003506 dvb_detach(&state->dib7000p_ops);
Devin Heitmueller01f16262009-06-24 00:07:01 -03003507 return -ENODEV;
3508 }
3509
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003510 adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap, 0x12,
Devin Heitmueller01f16262009-06-24 00:07:01 -03003511 &pctv_340e_config);
3512 st->is_dib7000pc = 1;
3513
Michael Krufky77eed212011-09-06 09:31:57 -03003514 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Devin Heitmueller01f16262009-06-24 00:07:01 -03003515}
3516
Devin Heitmueller8583fc82009-07-28 01:16:05 -03003517static struct xc4000_config dib7000p_xc4000_tunerconfig = {
istvan_v@mailbox.hu8edeb6e2011-06-06 13:03:44 -03003518 .i2c_address = 0x61,
3519 .default_pm = 1,
3520 .dvb_amplitude = 0,
3521 .set_smoothedcvbs = 0,
3522 .if_khz = 5400
Davide Ferri8d009a02009-06-23 22:34:06 -03003523};
3524
3525static int xc4000_tuner_attach(struct dvb_usb_adapter *adap)
3526{
Devin Heitmueller59d0c372009-06-29 21:11:02 -03003527 struct i2c_adapter *tun_i2c;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003528 struct dib0700_adapter_state *state = adap->priv;
Devin Heitmueller59d0c372009-06-29 21:11:02 -03003529
3530 /* The xc4000 is not on the main i2c bus */
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003531 tun_i2c = state->dib7000p_ops.get_i2c_master(adap->fe_adap[0].fe,
Devin Heitmueller59d0c372009-06-29 21:11:02 -03003532 DIBX000_I2C_INTERFACE_TUNER, 1);
3533 if (tun_i2c == NULL) {
Mauro Carvalho Chehab941830c2011-06-06 16:51:11 -03003534 printk(KERN_ERR "Could not reach tuner i2c bus\n");
Devin Heitmueller59d0c372009-06-29 21:11:02 -03003535 return 0;
3536 }
3537
3538 /* Setup the reset callback */
Michael Krufky77eed212011-09-06 09:31:57 -03003539 adap->fe_adap[0].fe->callback = dib0700_xc4000_tuner_callback;
Davide Ferri8d009a02009-06-23 22:34:06 -03003540
Michael Krufky77eed212011-09-06 09:31:57 -03003541 return dvb_attach(xc4000_attach, adap->fe_adap[0].fe, tun_i2c,
Devin Heitmueller8583fc82009-07-28 01:16:05 -03003542 &dib7000p_xc4000_tunerconfig)
Davide Ferri8d009a02009-06-23 22:34:06 -03003543 == NULL ? -ENODEV : 0;
3544}
3545
Michael Krufkyce904bc2009-01-19 01:12:55 -03003546static struct lgdt3305_config hcw_lgdt3305_config = {
3547 .i2c_addr = 0x0e,
3548 .mpeg_mode = LGDT3305_MPEG_PARALLEL,
3549 .tpclk_edge = LGDT3305_TPCLK_FALLING_EDGE,
3550 .tpvalid_polarity = LGDT3305_TP_VALID_LOW,
3551 .deny_i2c_rptr = 0,
3552 .spectral_inversion = 1,
3553 .qam_if_khz = 6000,
3554 .vsb_if_khz = 6000,
3555 .usref_8vsb = 0x0500,
3556};
3557
3558static struct mxl5007t_config hcw_mxl5007t_config = {
3559 .xtal_freq_hz = MxL_XTAL_25_MHZ,
3560 .if_freq_hz = MxL_IF_6_MHZ,
3561 .invert_if = 1,
3562};
3563
3564/* TIGER-ATSC map:
3565 GPIO0 - LNA_CTR (H: LNA power enabled, L: LNA power disabled)
3566 GPIO1 - ANT_SEL (H: VPA, L: MCX)
3567 GPIO4 - SCL2
3568 GPIO6 - EN_TUNER
3569 GPIO7 - SDA2
3570 GPIO10 - DEM_RST
3571
3572 MXL is behind LG's i2c repeater. LG is on SCL2/SDA2 gpios on the DIB
3573 */
3574static int lgdt3305_frontend_attach(struct dvb_usb_adapter *adap)
3575{
3576 struct dib0700_state *st = adap->dev->priv;
3577
3578 /* Make use of the new i2c functions from FW 1.20 */
3579 st->fw_use_new_i2c_api = 1;
3580
3581 st->disable_streaming_master_mode = 1;
3582
3583 /* fe power enable */
3584 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
3585 msleep(30);
3586 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
3587 msleep(30);
3588
3589 /* demod reset */
3590 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
3591 msleep(30);
3592 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
3593 msleep(30);
3594 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
3595 msleep(30);
3596
Michael Krufky77eed212011-09-06 09:31:57 -03003597 adap->fe_adap[0].fe = dvb_attach(lgdt3305_attach,
Michael Krufkyce904bc2009-01-19 01:12:55 -03003598 &hcw_lgdt3305_config,
3599 &adap->dev->i2c_adap);
3600
Michael Krufky77eed212011-09-06 09:31:57 -03003601 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Michael Krufkyce904bc2009-01-19 01:12:55 -03003602}
3603
3604static int mxl5007t_tuner_attach(struct dvb_usb_adapter *adap)
3605{
Michael Krufky77eed212011-09-06 09:31:57 -03003606 return dvb_attach(mxl5007t_attach, adap->fe_adap[0].fe,
Michael Krufkyce904bc2009-01-19 01:12:55 -03003607 &adap->dev->i2c_adap, 0x60,
3608 &hcw_mxl5007t_config) == NULL ? -ENODEV : 0;
3609}
3610
3611
Patrick Boettcher01373a52007-07-30 12:49:04 -03003612/* DVB-USB and USB stuff follows */
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003613struct usb_device_id dib0700_usb_id_table[] = {
Patrick Boettcher01373a52007-07-30 12:49:04 -03003614/* 0 */ { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7700P) },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03003615 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7700P_PC) },
3616 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_500) },
3617 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_500_2) },
3618 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_STICK) },
Patrick Boettcher01373a52007-07-30 12:49:04 -03003619/* 5 */ { USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR) },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03003620 { USB_DEVICE(USB_VID_COMPRO, USB_PID_COMPRO_VIDEOMATE_U500) },
3621 { USB_DEVICE(USB_VID_UNIWILL, USB_PID_UNIWILL_STK7700P) },
3622 { USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV_DONGLE_STK7700P) },
3623 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_STICK_2) },
Patrick Boettcher01373a52007-07-30 12:49:04 -03003624/* 10 */{ USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR_2) },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03003625 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV2000E) },
3626 { USB_DEVICE(USB_VID_TERRATEC,
3627 USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY) },
3628 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_TD_STICK) },
3629 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7700D) },
Patrick Boettcher01373a52007-07-30 12:49:04 -03003630/* 15 */{ USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7070P) },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03003631 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV_DVB_T_FLASH) },
3632 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7070PD) },
3633 { USB_DEVICE(USB_VID_PINNACLE,
3634 USB_PID_PINNACLE_PCTV_DUAL_DIVERSITY_DVB_T) },
3635 { USB_DEVICE(USB_VID_COMPRO, USB_PID_COMPRO_VIDEOMATE_U500_PC) },
Joachim Steigerfa3b8772007-10-08 20:08:46 -03003636/* 20 */{ USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_EXPRESS) },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03003637 { USB_DEVICE(USB_VID_GIGABYTE, USB_PID_GIGABYTE_U7000) },
3638 { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC, USB_PID_ARTEC_T14BR) },
3639 { USB_DEVICE(USB_VID_ASUS, USB_PID_ASUS_U3000) },
3640 { USB_DEVICE(USB_VID_ASUS, USB_PID_ASUS_U3100) },
3641/* 25 */{ USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_STICK_3) },
3642 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_MYTV_T) },
3643 { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_HT_USB_XE) },
3644 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_EXPRESSCARD_320CX) },
3645 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV72E) },
3646/* 30 */{ USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV73E) },
3647 { USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_EC372S) },
3648 { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_HT_EXPRESS) },
Alexander Simondc888072008-03-29 21:37:54 -03003649 { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_XXS) },
Darryl Green5da4e2c2008-03-29 21:47:43 -03003650 { USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV_DONGLE_STK7700P_2) },
Michael Krufkyaf2a8872008-09-03 17:12:24 -03003651/* 35 */{ USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_TD_STICK_52009) },
Michael Krufky9a0c04a2008-09-03 17:12:24 -03003652 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_500_3) },
Finn Thain17a370b2008-09-06 13:42:47 -03003653 { USB_DEVICE(USB_VID_GIGABYTE, USB_PID_GIGABYTE_U8000) },
Daniel Oliveira Nascimento8751aaa2008-09-07 12:39:44 -03003654 { USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_STK7700PH) },
Albert Comerma57697432008-09-07 12:43:33 -03003655 { USB_DEVICE(USB_VID_ASUS, USB_PID_ASUS_U3000H) },
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03003656/* 40 */{ USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV801E) },
Devin Heitmuellerd2fc3bf2008-09-25 06:22:23 -03003657 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV801E_SE) },
Yusuf Altinbb1b0822009-01-08 07:58:45 -03003658 { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_EXPRESS) },
Nicolas Fournierdb4b2d12009-01-13 07:15:25 -03003659 { USB_DEVICE(USB_VID_TERRATEC,
3660 USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY_2) },
sebastian.blanes@gmail.com0a6e1ed2009-02-24 14:51:43 -03003661 { USB_DEVICE(USB_VID_SONY, USB_PID_SONY_PLAYTV) },
Pascal Terjan9abb6e62009-02-26 10:31:41 -03003662/* 45 */{ USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_PD378S) },
Michael Krufkyce904bc2009-01-19 01:12:55 -03003663 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_TIGER_ATSC) },
3664 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_TIGER_ATSC_B210) },
Xoan Loureiro16ba1ee2009-03-29 08:43:36 -03003665 { USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_MC770) },
Klaus Flittner919a5482009-03-29 09:12:06 -03003666 { USB_DEVICE(USB_VID_ELGATO, USB_PID_ELGATO_EYETV_DTT) },
Armin Schenker513846e2009-04-20 11:57:49 -03003667/* 50 */{ USB_DEVICE(USB_VID_ELGATO, USB_PID_ELGATO_EYETV_DTT_Dlx) },
tomas petrf0f4ae72009-05-20 05:28:05 -03003668 { USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV_DONGLE_H) },
Patrick Boettchera9b8fe32009-05-20 05:35:02 -03003669 { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_T3) },
3670 { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_T5) },
Pete Hildebrandtc53d83c2009-08-05 11:46:38 -03003671 { USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_STK7700D) },
Olivier Grenie74b76f22009-09-02 08:19:19 -03003672/* 55 */{ USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_STK7700D_2) },
3673 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV73A) },
Patrick Boettchere4147532009-11-30 13:52:57 -03003674 { USB_DEVICE(USB_VID_PCTV, USB_PID_PINNACLE_PCTV73ESE) },
3675 { USB_DEVICE(USB_VID_PCTV, USB_PID_PINNACLE_PCTV282E) },
Olivier Grenied300bd62009-09-15 06:55:35 -03003676 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7770P) },
Patrick Boettcherdb481382009-09-15 07:16:51 -03003677/* 60 */{ USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_XXS_2) },
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03003678 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK807XPVR) },
3679 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK807XP) },
Mauro Carvalho Chehab3bfb3172010-09-03 10:50:24 -03003680 { USB_DEVICE_VER(USB_VID_PIXELVIEW, USB_PID_PIXELVIEW_SBTVD, 0x000, 0x3f00) },
S?rgio Fortier8a378e82009-09-28 04:19:21 -03003681 { USB_DEVICE(USB_VID_EVOLUTEPC, USB_PID_TVWAY_PLUS) },
Patrick Boettcher20232c42009-12-01 12:08:56 -03003682/* 65 */{ USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV73ESE) },
Patrick Boettchere4147532009-11-30 13:52:57 -03003683 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV282E) },
Olivier Grenie03245a52009-12-04 13:27:57 -03003684 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK8096GP) },
Michael Müller84e2f032010-04-26 22:18:57 -03003685 { USB_DEVICE(USB_VID_ELGATO, USB_PID_ELGATO_EYETV_DIVERSITY) },
Olivier Greniebe9bae12011-01-04 05:42:19 -03003686 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_NIM9090M) },
3687/* 70 */{ USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_NIM8096MD) },
3688 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_NIM9090MD) },
3689 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_NIM7090) },
3690 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_TFE7090PVR) },
Lukas Max Fisch498e6772011-02-08 16:51:45 -03003691 { USB_DEVICE(USB_VID_TECHNISAT, USB_PID_TECHNISAT_AIRSTAR_TELESTICK_2) },
Stéphane Elmalehd1402302011-05-21 07:33:38 -03003692/* 75 */{ USB_DEVICE(USB_VID_MEDION, USB_PID_CREATIX_CTX1921) },
Davide Ferri8d009a02009-06-23 22:34:06 -03003693 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV340E) },
Devin Heitmueller33fb1682009-06-23 22:48:02 -03003694 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV340E_SE) },
Olivier Grenief45f5132012-12-31 09:47:10 -03003695 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_TFE7790P) },
3696 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_TFE8096P) },
3697/* 80 */{ USB_DEVICE(USB_VID_ELGATO, USB_PID_ELGATO_EYETV_DTT_2) },
Michael Krufkyc859e6e2013-06-30 12:43:58 -03003698 { USB_DEVICE(USB_VID_PCTV, USB_PID_PCTV_2002E) },
3699 { USB_DEVICE(USB_VID_PCTV, USB_PID_PCTV_2002E_SE) },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03003700 { 0 } /* Terminating entry */
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003701};
3702MODULE_DEVICE_TABLE(usb, dib0700_usb_id_table);
3703
3704#define DIB0700_DEFAULT_DEVICE_PROPERTIES \
3705 .caps = DVB_USB_IS_AN_I2C_ADAPTER, \
3706 .usb_ctrl = DEVICE_SPECIFIC, \
Devin Heitmuellerbdc203e2008-09-06 13:45:27 -03003707 .firmware = "dvb-usb-dib0700-1.20.fw", \
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003708 .download_firmware = dib0700_download_firmware, \
Patrick Boettcher6958eff2006-09-19 12:51:40 -03003709 .no_reconnect = 1, \
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003710 .size_of_priv = sizeof(struct dib0700_state), \
Patrick Boettcher6958eff2006-09-19 12:51:40 -03003711 .i2c_algo = &dib0700_i2c_algo, \
3712 .identify_state = dib0700_identify_state
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003713
3714#define DIB0700_DEFAULT_STREAMING_CONFIG(ep) \
3715 .streaming_ctrl = dib0700_streaming_ctrl, \
3716 .stream = { \
3717 .type = USB_BULK, \
3718 .count = 4, \
3719 .endpoint = ep, \
3720 .u = { \
3721 .bulk = { \
3722 .buffersize = 39480, \
3723 } \
3724 } \
3725 }
3726
3727struct dvb_usb_device_properties dib0700_devices[] = {
3728 {
3729 DIB0700_DEFAULT_DEVICE_PROPERTIES,
3730
3731 .num_adapters = 1,
3732 .adapter = {
3733 {
Michael Krufky77eed212011-09-06 09:31:57 -03003734 .num_frontends = 1,
3735 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03003736 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
3737 .pid_filter_count = 32,
Olivier Greniee192a7c2011-01-14 13:58:59 -03003738 .pid_filter = stk7700p_pid_filter,
3739 .pid_filter_ctrl = stk7700p_pid_filter_ctrl,
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003740 .frontend_attach = stk7700p_frontend_attach,
3741 .tuner_attach = stk7700p_tuner_attach,
3742
3743 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03003744 }},
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003745 },
3746 },
3747
dominik67053a42007-11-10 19:23:31 -03003748 .num_device_descs = 8,
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003749 .devices = {
3750 { "DiBcom STK7700P reference design",
Tomi Koivulahti49a13762006-10-19 07:27:19 -03003751 { &dib0700_usb_id_table[0], &dib0700_usb_id_table[1] },
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003752 { NULL },
3753 },
3754 { "Hauppauge Nova-T Stick",
Stefan Trabyf9aeba42006-11-12 13:02:51 -03003755 { &dib0700_usb_id_table[4], &dib0700_usb_id_table[9], NULL },
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003756 { NULL },
3757 },
Tomi Koivulahti49a13762006-10-19 07:27:19 -03003758 { "AVerMedia AVerTV DVB-T Volar",
Jose Carlos Garcia Sogoced8fec2006-11-14 05:01:47 -03003759 { &dib0700_usb_id_table[5], &dib0700_usb_id_table[10] },
Tomi Koivulahti49a13762006-10-19 07:27:19 -03003760 { NULL },
3761 },
3762 { "Compro Videomate U500",
Patrick Boettcher1f8ca4b2007-07-30 14:24:37 -03003763 { &dib0700_usb_id_table[6], &dib0700_usb_id_table[19] },
Tomi Koivulahti49a13762006-10-19 07:27:19 -03003764 { NULL },
Henning Schroeer0ce215e2006-10-19 07:58:22 -03003765 },
3766 { "Uniwill STK7700P based (Hama and others)",
3767 { &dib0700_usb_id_table[7], NULL },
3768 { NULL },
Michael Krufky8637a872006-11-08 16:47:32 -03003769 },
3770 { "Leadtek Winfast DTV Dongle (STK7700P based)",
Patrick Boettcher1e13c8f2009-09-19 05:24:40 -03003771 { &dib0700_usb_id_table[8], &dib0700_usb_id_table[34] },
Michael Krufky8637a872006-11-08 16:47:32 -03003772 { NULL },
Joachim Steigerfa3b8772007-10-08 20:08:46 -03003773 },
3774 { "AVerMedia AVerTV DVB-T Express",
3775 { &dib0700_usb_id_table[20] },
3776 { NULL },
dominik67053a42007-11-10 19:23:31 -03003777 },
dominik67053a42007-11-10 19:23:31 -03003778 { "Gigabyte U7000",
3779 { &dib0700_usb_id_table[21], NULL },
3780 { NULL },
Tomi Koivulahti49a13762006-10-19 07:27:19 -03003781 }
Darren Saltb1139e32007-08-18 18:05:31 -03003782 },
3783
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03003784 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03003785 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03003786 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03003787 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03003788 .allowed_protos = RC_BIT_RC5 |
3789 RC_BIT_RC6_MCE |
3790 RC_BIT_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03003791 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03003792 },
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003793 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
3794
3795 .num_adapters = 2,
3796 .adapter = {
3797 {
Michael Krufky77eed212011-09-06 09:31:57 -03003798 .num_frontends = 1,
3799 .fe = {{
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003800 .frontend_attach = bristol_frontend_attach,
3801 .tuner_attach = bristol_tuner_attach,
3802
3803 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03003804 }},
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003805 }, {
Michael Krufky77eed212011-09-06 09:31:57 -03003806 .num_frontends = 1,
3807 .fe = {{
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003808 .frontend_attach = bristol_frontend_attach,
3809 .tuner_attach = bristol_tuner_attach,
3810
3811 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
Michael Krufky77eed212011-09-06 09:31:57 -03003812 }},
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003813 }
3814 },
3815
3816 .num_device_descs = 1,
3817 .devices = {
3818 { "Hauppauge Nova-T 500 Dual DVB-T",
Tomi Koivulahti49a13762006-10-19 07:27:19 -03003819 { &dib0700_usb_id_table[2], &dib0700_usb_id_table[3], NULL },
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003820 { NULL },
3821 },
Janne Grunau82f3d552007-07-30 13:50:28 -03003822 },
3823
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03003824 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03003825 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03003826 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03003827 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03003828 .allowed_protos = RC_BIT_RC5 |
3829 RC_BIT_RC6_MCE |
3830 RC_BIT_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03003831 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03003832 },
Olivier DANET54d75eb2007-07-25 14:42:54 -03003833 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
3834
3835 .num_adapters = 2,
3836 .adapter = {
3837 {
Michael Krufky77eed212011-09-06 09:31:57 -03003838 .num_frontends = 1,
3839 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03003840 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
3841 .pid_filter_count = 32,
3842 .pid_filter = stk70x0p_pid_filter,
3843 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
Olivier DANET54d75eb2007-07-25 14:42:54 -03003844 .frontend_attach = stk7700d_frontend_attach,
3845 .tuner_attach = stk7700d_tuner_attach,
3846
3847 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03003848 }},
Olivier DANET54d75eb2007-07-25 14:42:54 -03003849 }, {
Michael Krufky77eed212011-09-06 09:31:57 -03003850 .num_frontends = 1,
3851 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03003852 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
3853 .pid_filter_count = 32,
3854 .pid_filter = stk70x0p_pid_filter,
3855 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
Olivier DANET54d75eb2007-07-25 14:42:54 -03003856 .frontend_attach = stk7700d_frontend_attach,
3857 .tuner_attach = stk7700d_tuner_attach,
3858
3859 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
Michael Krufky77eed212011-09-06 09:31:57 -03003860 }},
Olivier DANET54d75eb2007-07-25 14:42:54 -03003861 }
3862 },
3863
James A Webb200e8612009-08-04 02:38:05 -03003864 .num_device_descs = 5,
Olivier DANET54d75eb2007-07-25 14:42:54 -03003865 .devices = {
3866 { "Pinnacle PCTV 2000e",
3867 { &dib0700_usb_id_table[11], NULL },
3868 { NULL },
3869 },
3870 { "Terratec Cinergy DT XS Diversity",
3871 { &dib0700_usb_id_table[12], NULL },
3872 { NULL },
3873 },
Darren Saltfaebb912007-08-18 18:04:00 -03003874 { "Hauppauge Nova-TD Stick/Elgato Eye-TV Diversity",
Olivier DANET54d75eb2007-07-25 14:42:54 -03003875 { &dib0700_usb_id_table[13], NULL },
3876 { NULL },
3877 },
Patrick Boettcher01373a52007-07-30 12:49:04 -03003878 { "DiBcom STK7700D reference design",
Patrick Boettcherb6884a12007-07-27 10:08:51 -03003879 { &dib0700_usb_id_table[14], NULL },
3880 { NULL },
Yusuf Altinbb1b0822009-01-08 07:58:45 -03003881 },
James A Webb200e8612009-08-04 02:38:05 -03003882 { "YUAN High-Tech DiBcom STK7700D",
3883 { &dib0700_usb_id_table[55], NULL },
3884 { NULL },
3885 },
Yusuf Altinbb1b0822009-01-08 07:58:45 -03003886
Olivier DANET54d75eb2007-07-25 14:42:54 -03003887 },
Janne Grunau82f3d552007-07-30 13:50:28 -03003888
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03003889 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03003890 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03003891 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03003892 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03003893 .allowed_protos = RC_BIT_RC5 |
3894 RC_BIT_RC6_MCE |
3895 RC_BIT_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03003896 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03003897 },
Patrick Boettcher01373a52007-07-30 12:49:04 -03003898 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
3899
3900 .num_adapters = 1,
3901 .adapter = {
3902 {
Michael Krufky77eed212011-09-06 09:31:57 -03003903 .num_frontends = 1,
3904 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03003905 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
3906 .pid_filter_count = 32,
3907 .pid_filter = stk70x0p_pid_filter,
3908 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
Daniel Gimpelevich132c3182008-01-25 06:02:42 -03003909 .frontend_attach = stk7700P2_frontend_attach,
3910 .tuner_attach = stk7700d_tuner_attach,
3911
3912 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03003913 }},
Daniel Gimpelevich132c3182008-01-25 06:02:42 -03003914 },
3915 },
3916
Yusuf Altinbb1b0822009-01-08 07:58:45 -03003917 .num_device_descs = 3,
Daniel Gimpelevich132c3182008-01-25 06:02:42 -03003918 .devices = {
3919 { "ASUS My Cinema U3000 Mini DVBT Tuner",
3920 { &dib0700_usb_id_table[23], NULL },
3921 { NULL },
3922 },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03003923 { "Yuan EC372S",
3924 { &dib0700_usb_id_table[31], NULL },
3925 { NULL },
Yusuf Altinbb1b0822009-01-08 07:58:45 -03003926 },
3927 { "Terratec Cinergy T Express",
3928 { &dib0700_usb_id_table[42], NULL },
3929 { NULL },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03003930 }
Chris Rankin48aa7392008-09-25 06:52:24 -03003931 },
3932
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03003933 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03003934 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03003935 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03003936 .module_name = "dib0700",
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03003937 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03003938 .allowed_protos = RC_BIT_RC5 |
3939 RC_BIT_RC6_MCE |
3940 RC_BIT_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03003941 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03003942 },
Daniel Gimpelevich132c3182008-01-25 06:02:42 -03003943 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
3944
3945 .num_adapters = 1,
3946 .adapter = {
3947 {
Michael Krufky77eed212011-09-06 09:31:57 -03003948 .num_frontends = 1,
3949 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03003950 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
3951 .pid_filter_count = 32,
3952 .pid_filter = stk70x0p_pid_filter,
3953 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
Patrick Boettcher01373a52007-07-30 12:49:04 -03003954 .frontend_attach = stk7070p_frontend_attach,
3955 .tuner_attach = dib7070p_tuner_attach,
3956
3957 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03003958 }},
Patrick Boettcher01373a52007-07-30 12:49:04 -03003959 .size_of_priv = sizeof(struct dib0700_adapter_state),
3960 },
3961 },
3962
Gianluca Gennari0bc9d392012-04-14 09:14:07 -03003963 .num_device_descs = 12,
Patrick Boettcher01373a52007-07-30 12:49:04 -03003964 .devices = {
3965 { "DiBcom STK7070P reference design",
3966 { &dib0700_usb_id_table[15], NULL },
3967 { NULL },
3968 },
3969 { "Pinnacle PCTV DVB-T Flash Stick",
3970 { &dib0700_usb_id_table[16], NULL },
3971 { NULL },
3972 },
Yousef Lamlum7999a812008-01-25 05:51:48 -03003973 { "Artec T14BR DVB-T",
3974 { &dib0700_usb_id_table[22], NULL },
3975 { NULL },
Daniel Gimpelevich132c3182008-01-25 06:02:42 -03003976 },
3977 { "ASUS My Cinema U3100 Mini DVBT Tuner",
3978 { &dib0700_usb_id_table[24], NULL },
3979 { NULL },
3980 },
Tim Taubertc7637b12008-01-25 06:16:36 -03003981 { "Hauppauge Nova-T Stick",
3982 { &dib0700_usb_id_table[25], NULL },
3983 { NULL },
3984 },
Darren Salt13b83b52008-01-25 06:20:02 -03003985 { "Hauppauge Nova-T MyTV.t",
3986 { &dib0700_usb_id_table[26], NULL },
3987 { NULL },
3988 },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03003989 { "Pinnacle PCTV 72e",
3990 { &dib0700_usb_id_table[29], NULL },
3991 { NULL },
3992 },
3993 { "Pinnacle PCTV 73e",
3994 { &dib0700_usb_id_table[30], NULL },
3995 { NULL },
3996 },
Klaus Flittner919a5482009-03-29 09:12:06 -03003997 { "Elgato EyeTV DTT",
3998 { &dib0700_usb_id_table[49], NULL },
3999 { NULL },
4000 },
Pascal Terjan9abb6e62009-02-26 10:31:41 -03004001 { "Yuan PD378S",
4002 { &dib0700_usb_id_table[45], NULL },
4003 { NULL },
4004 },
Armin Schenker513846e2009-04-20 11:57:49 -03004005 { "Elgato EyeTV Dtt Dlx PD378S",
4006 { &dib0700_usb_id_table[50], NULL },
4007 { NULL },
4008 },
Gianluca Gennari0bc9d392012-04-14 09:14:07 -03004009 { "Elgato EyeTV DTT rev. 2",
Olivier Grenief45f5132012-12-31 09:47:10 -03004010 { &dib0700_usb_id_table[80], NULL },
Gianluca Gennari0bc9d392012-04-14 09:14:07 -03004011 { NULL },
4012 },
Tim Taubertc7637b12008-01-25 06:16:36 -03004013 },
4014
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004015 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004016 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004017 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004018 .module_name = "dib0700",
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03004019 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004020 .allowed_protos = RC_BIT_RC5 |
4021 RC_BIT_RC6_MCE |
4022 RC_BIT_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03004023 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004024 },
Patrick Boettcher01373a52007-07-30 12:49:04 -03004025 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4026
Olivier Grenie74b76f22009-09-02 08:19:19 -03004027 .num_adapters = 1,
4028 .adapter = {
4029 {
Michael Krufky77eed212011-09-06 09:31:57 -03004030 .num_frontends = 1,
4031 .fe = {{
Mauro Carvalho Chehab648732f2009-11-04 12:11:43 -02004032 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4033 .pid_filter_count = 32,
4034 .pid_filter = stk70x0p_pid_filter,
4035 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
Olivier Grenie74b76f22009-09-02 08:19:19 -03004036 .frontend_attach = stk7070p_frontend_attach,
4037 .tuner_attach = dib7070p_tuner_attach,
4038
4039 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004040 }},
Olivier Grenie74b76f22009-09-02 08:19:19 -03004041 .size_of_priv = sizeof(struct dib0700_adapter_state),
4042 },
4043 },
4044
Patrick Boettcher20232c42009-12-01 12:08:56 -03004045 .num_device_descs = 3,
Olivier Grenie74b76f22009-09-02 08:19:19 -03004046 .devices = {
4047 { "Pinnacle PCTV 73A",
4048 { &dib0700_usb_id_table[56], NULL },
4049 { NULL },
4050 },
4051 { "Pinnacle PCTV 73e SE",
Patrick Boettcher20232c42009-12-01 12:08:56 -03004052 { &dib0700_usb_id_table[57], &dib0700_usb_id_table[65], NULL },
Olivier Grenie74b76f22009-09-02 08:19:19 -03004053 { NULL },
4054 },
4055 { "Pinnacle PCTV 282e",
Patrick Boettcher20232c42009-12-01 12:08:56 -03004056 { &dib0700_usb_id_table[58], &dib0700_usb_id_table[66], NULL },
Olivier Grenie74b76f22009-09-02 08:19:19 -03004057 { NULL },
4058 },
4059 },
4060
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004061 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004062 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004063 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004064 .module_name = "dib0700",
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03004065 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004066 .allowed_protos = RC_BIT_RC5 |
4067 RC_BIT_RC6_MCE |
4068 RC_BIT_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03004069 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004070 },
Olivier Grenie74b76f22009-09-02 08:19:19 -03004071 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4072
Patrick Boettcher01373a52007-07-30 12:49:04 -03004073 .num_adapters = 2,
4074 .adapter = {
4075 {
Michael Krufky77eed212011-09-06 09:31:57 -03004076 .num_frontends = 1,
4077 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03004078 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4079 .pid_filter_count = 32,
4080 .pid_filter = stk70x0p_pid_filter,
4081 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
Jiri Slaby2b05b882012-01-10 14:11:24 -03004082 .frontend_attach = novatd_frontend_attach,
Patrick Boettcher01373a52007-07-30 12:49:04 -03004083 .tuner_attach = dib7070p_tuner_attach,
4084
4085 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004086 }},
Patrick Boettcher01373a52007-07-30 12:49:04 -03004087 .size_of_priv = sizeof(struct dib0700_adapter_state),
4088 }, {
Michael Krufky77eed212011-09-06 09:31:57 -03004089 .num_frontends = 1,
4090 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03004091 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4092 .pid_filter_count = 32,
4093 .pid_filter = stk70x0p_pid_filter,
4094 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
Jiri Slaby2b05b882012-01-10 14:11:24 -03004095 .frontend_attach = novatd_frontend_attach,
Patrick Boettcher01373a52007-07-30 12:49:04 -03004096 .tuner_attach = dib7070p_tuner_attach,
4097
4098 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
Michael Krufky77eed212011-09-06 09:31:57 -03004099 }},
Patrick Boettcher01373a52007-07-30 12:49:04 -03004100 .size_of_priv = sizeof(struct dib0700_adapter_state),
4101 }
4102 },
4103
Michael Krufkyc859e6e2013-06-30 12:43:58 -03004104 .num_device_descs = 3,
Jiri Slaby9b6ba572012-01-10 14:11:22 -03004105 .devices = {
4106 { "Hauppauge Nova-TD Stick (52009)",
4107 { &dib0700_usb_id_table[35], NULL },
4108 { NULL },
4109 },
Michael Krufkyc859e6e2013-06-30 12:43:58 -03004110 { "PCTV 2002e",
4111 { &dib0700_usb_id_table[81], NULL },
4112 { NULL },
4113 },
4114 { "PCTV 2002e SE",
4115 { &dib0700_usb_id_table[82], NULL },
4116 { NULL },
4117 },
Jiri Slaby9b6ba572012-01-10 14:11:22 -03004118 },
4119
4120 .rc.core = {
4121 .rc_interval = DEFAULT_RC_INTERVAL,
4122 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4123 .module_name = "dib0700",
4124 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004125 .allowed_protos = RC_BIT_RC5 |
4126 RC_BIT_RC6_MCE |
4127 RC_BIT_NEC,
Jiri Slaby9b6ba572012-01-10 14:11:22 -03004128 .change_protocol = dib0700_change_protocol,
4129 },
4130 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4131
4132 .num_adapters = 2,
4133 .adapter = {
4134 {
4135 .num_frontends = 1,
4136 .fe = {{
4137 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4138 .pid_filter_count = 32,
4139 .pid_filter = stk70x0p_pid_filter,
4140 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
4141 .frontend_attach = stk7070pd_frontend_attach0,
4142 .tuner_attach = dib7070p_tuner_attach,
4143
4144 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
4145 }},
4146 .size_of_priv = sizeof(struct dib0700_adapter_state),
4147 }, {
4148 .num_frontends = 1,
4149 .fe = {{
4150 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4151 .pid_filter_count = 32,
4152 .pid_filter = stk70x0p_pid_filter,
4153 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
4154 .frontend_attach = stk7070pd_frontend_attach1,
4155 .tuner_attach = dib7070p_tuner_attach,
4156
4157 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
4158 }},
4159 .size_of_priv = sizeof(struct dib0700_adapter_state),
4160 }
4161 },
4162
4163 .num_device_descs = 5,
Patrick Boettcher01373a52007-07-30 12:49:04 -03004164 .devices = {
4165 { "DiBcom STK7070PD reference design",
4166 { &dib0700_usb_id_table[17], NULL },
4167 { NULL },
4168 },
4169 { "Pinnacle PCTV Dual DVB-T Diversity Stick",
4170 { &dib0700_usb_id_table[18], NULL },
4171 { NULL },
Michael Krufkyd01eb2d2008-07-03 23:43:36 -03004172 },
Michael Krufky9a0c04a2008-09-03 17:12:24 -03004173 { "Hauppauge Nova-TD-500 (84xxx)",
4174 { &dib0700_usb_id_table[36], NULL },
4175 { NULL },
Nicolas Fournierdb4b2d12009-01-13 07:15:25 -03004176 },
Patrick Boettchera9b8fe32009-05-20 05:35:02 -03004177 { "Terratec Cinergy DT USB XS Diversity/ T5",
4178 { &dib0700_usb_id_table[43],
4179 &dib0700_usb_id_table[53], NULL},
Nicolas Fournierdb4b2d12009-01-13 07:15:25 -03004180 { NULL },
sebastian.blanes@gmail.com0a6e1ed2009-02-24 14:51:43 -03004181 },
4182 { "Sony PlayTV",
4183 { &dib0700_usb_id_table[44], NULL },
4184 { NULL },
Michael Müller84e2f032010-04-26 22:18:57 -03004185 },
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004186 },
4187
4188 .rc.core = {
4189 .rc_interval = DEFAULT_RC_INTERVAL,
4190 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4191 .module_name = "dib0700",
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03004192 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004193 .allowed_protos = RC_BIT_RC5 |
4194 RC_BIT_RC6_MCE |
4195 RC_BIT_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03004196 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004197 },
4198 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4199
4200 .num_adapters = 2,
4201 .adapter = {
4202 {
Michael Krufky77eed212011-09-06 09:31:57 -03004203 .num_frontends = 1,
4204 .fe = {{
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004205 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4206 .pid_filter_count = 32,
4207 .pid_filter = stk70x0p_pid_filter,
4208 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
4209 .frontend_attach = stk7070pd_frontend_attach0,
4210 .tuner_attach = dib7070p_tuner_attach,
4211
4212 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004213 }},
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004214 .size_of_priv = sizeof(struct dib0700_adapter_state),
4215 }, {
Michael Krufky77eed212011-09-06 09:31:57 -03004216 .num_frontends = 1,
4217 .fe = {{
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004218 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4219 .pid_filter_count = 32,
4220 .pid_filter = stk70x0p_pid_filter,
4221 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
4222 .frontend_attach = stk7070pd_frontend_attach1,
4223 .tuner_attach = dib7070p_tuner_attach,
4224
4225 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
Michael Krufky77eed212011-09-06 09:31:57 -03004226 }},
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004227 .size_of_priv = sizeof(struct dib0700_adapter_state),
4228 }
4229 },
4230
4231 .num_device_descs = 1,
4232 .devices = {
Michael Müller84e2f032010-04-26 22:18:57 -03004233 { "Elgato EyeTV Diversity",
4234 { &dib0700_usb_id_table[68], NULL },
4235 { NULL },
4236 },
Arne Luehrsc985a8d2009-01-21 01:37:20 -03004237 },
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004238
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004239 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004240 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004241 .rc_codes = RC_MAP_DIB0700_NEC_TABLE,
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004242 .module_name = "dib0700",
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03004243 .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,
David Härdemand8b4b582010-10-29 16:08:23 -03004247 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004248 },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03004249 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4250
4251 .num_adapters = 1,
4252 .adapter = {
4253 {
Michael Krufky77eed212011-09-06 09:31:57 -03004254 .num_frontends = 1,
4255 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03004256 .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,
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03004260 .frontend_attach = stk7700ph_frontend_attach,
4261 .tuner_attach = stk7700ph_tuner_attach,
4262
4263 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004264 }},
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03004265 .size_of_priv = sizeof(struct
4266 dib0700_adapter_state),
4267 },
4268 },
4269
Pete Hildebrandtc53d83c2009-08-05 11:46:38 -03004270 .num_device_descs = 9,
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03004271 .devices = {
4272 { "Terratec Cinergy HT USB XE",
4273 { &dib0700_usb_id_table[27], NULL },
4274 { NULL },
4275 },
4276 { "Pinnacle Expresscard 320cx",
4277 { &dib0700_usb_id_table[28], NULL },
4278 { NULL },
4279 },
4280 { "Terratec Cinergy HT Express",
4281 { &dib0700_usb_id_table[32], NULL },
4282 { NULL },
4283 },
Finn Thain17a370b2008-09-06 13:42:47 -03004284 { "Gigabyte U8000-RH",
4285 { &dib0700_usb_id_table[37], NULL },
4286 { NULL },
4287 },
Daniel Oliveira Nascimento8751aaa2008-09-07 12:39:44 -03004288 { "YUAN High-Tech STK7700PH",
4289 { &dib0700_usb_id_table[38], NULL },
4290 { NULL },
4291 },
Albert Comerma57697432008-09-07 12:43:33 -03004292 { "Asus My Cinema-U3000Hybrid",
4293 { &dib0700_usb_id_table[39], NULL },
4294 { NULL },
4295 },
Xoan Loureiro16ba1ee2009-03-29 08:43:36 -03004296 { "YUAN High-Tech MC770",
4297 { &dib0700_usb_id_table[48], NULL },
4298 { NULL },
4299 },
tomas petrf0f4ae72009-05-20 05:28:05 -03004300 { "Leadtek WinFast DTV Dongle H",
4301 { &dib0700_usb_id_table[51], NULL },
4302 { NULL },
4303 },
Pete Hildebrandtc53d83c2009-08-05 11:46:38 -03004304 { "YUAN High-Tech STK7700D",
4305 { &dib0700_usb_id_table[54], NULL },
4306 { NULL },
4307 },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03004308 },
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004309
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004310 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004311 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004312 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004313 .module_name = "dib0700",
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03004314 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004315 .allowed_protos = RC_BIT_RC5 |
4316 RC_BIT_RC6_MCE |
4317 RC_BIT_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03004318 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004319 },
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03004320 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4321 .num_adapters = 1,
4322 .adapter = {
4323 {
Michael Krufky77eed212011-09-06 09:31:57 -03004324 .num_frontends = 1,
4325 .fe = {{
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03004326 .frontend_attach = s5h1411_frontend_attach,
4327 .tuner_attach = xc5000_tuner_attach,
4328
4329 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004330 }},
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03004331 .size_of_priv = sizeof(struct
4332 dib0700_adapter_state),
4333 },
4334 },
4335
Devin Heitmuellerd2fc3bf2008-09-25 06:22:23 -03004336 .num_device_descs = 2,
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03004337 .devices = {
4338 { "Pinnacle PCTV HD Pro USB Stick",
4339 { &dib0700_usb_id_table[40], NULL },
4340 { NULL },
4341 },
Devin Heitmuellerd2fc3bf2008-09-25 06:22:23 -03004342 { "Pinnacle PCTV HD USB Stick",
4343 { &dib0700_usb_id_table[41], NULL },
4344 { NULL },
4345 },
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03004346 },
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004347
4348 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004349 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004350 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004351 .module_name = "dib0700",
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03004352 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004353 .allowed_protos = RC_BIT_RC5 |
4354 RC_BIT_RC6_MCE |
4355 RC_BIT_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03004356 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004357 },
Michael Krufkyce904bc2009-01-19 01:12:55 -03004358 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4359 .num_adapters = 1,
4360 .adapter = {
4361 {
Michael Krufky77eed212011-09-06 09:31:57 -03004362 .num_frontends = 1,
4363 .fe = {{
Michael Krufkyce904bc2009-01-19 01:12:55 -03004364 .frontend_attach = lgdt3305_frontend_attach,
4365 .tuner_attach = mxl5007t_tuner_attach,
4366
4367 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004368 }},
Michael Krufkyce904bc2009-01-19 01:12:55 -03004369 .size_of_priv = sizeof(struct
4370 dib0700_adapter_state),
4371 },
4372 },
4373
4374 .num_device_descs = 2,
4375 .devices = {
4376 { "Hauppauge ATSC MiniCard (B200)",
4377 { &dib0700_usb_id_table[46], NULL },
4378 { NULL },
4379 },
4380 { "Hauppauge ATSC MiniCard (B210)",
4381 { &dib0700_usb_id_table[47], NULL },
4382 { NULL },
4383 },
4384 },
Olivier Grenied300bd62009-09-15 06:55:35 -03004385 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4386
4387 .num_adapters = 1,
4388 .adapter = {
4389 {
Michael Krufky77eed212011-09-06 09:31:57 -03004390 .num_frontends = 1,
4391 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03004392 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4393 .pid_filter_count = 32,
4394 .pid_filter = stk70x0p_pid_filter,
4395 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
Olivier Grenie90e12ce2010-09-07 12:50:45 -03004396 .frontend_attach = stk7770p_frontend_attach,
Olivier Grenied300bd62009-09-15 06:55:35 -03004397 .tuner_attach = dib7770p_tuner_attach,
4398
4399 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004400 }},
Olivier Grenied300bd62009-09-15 06:55:35 -03004401 .size_of_priv =
Patrick Boettcherdb481382009-09-15 07:16:51 -03004402 sizeof(struct dib0700_adapter_state),
Olivier Grenied300bd62009-09-15 06:55:35 -03004403 },
4404 },
4405
Stéphane Elmalehd1402302011-05-21 07:33:38 -03004406 .num_device_descs = 4,
Olivier Grenied300bd62009-09-15 06:55:35 -03004407 .devices = {
4408 { "DiBcom STK7770P reference design",
4409 { &dib0700_usb_id_table[59], NULL },
4410 { NULL },
4411 },
Patrick Boettcher1e13c8f2009-09-19 05:24:40 -03004412 { "Terratec Cinergy T USB XXS (HD)/ T3",
4413 { &dib0700_usb_id_table[33],
4414 &dib0700_usb_id_table[52],
4415 &dib0700_usb_id_table[60], NULL},
Patrick Boettcherdb481382009-09-15 07:16:51 -03004416 { NULL },
4417 },
Lukas Max Fisch498e6772011-02-08 16:51:45 -03004418 { "TechniSat AirStar TeleStick 2",
4419 { &dib0700_usb_id_table[74], NULL },
4420 { NULL },
4421 },
Stéphane Elmalehd1402302011-05-21 07:33:38 -03004422 { "Medion CTX1921 DVB-T USB",
4423 { &dib0700_usb_id_table[75], NULL },
4424 { NULL },
4425 },
Olivier Grenied300bd62009-09-15 06:55:35 -03004426 },
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004427
4428 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004429 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004430 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004431 .module_name = "dib0700",
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03004432 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004433 .allowed_protos = RC_BIT_RC5 |
4434 RC_BIT_RC6_MCE |
4435 RC_BIT_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03004436 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004437 },
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03004438 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4439 .num_adapters = 1,
4440 .adapter = {
4441 {
Michael Krufky77eed212011-09-06 09:31:57 -03004442 .num_frontends = 1,
4443 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03004444 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4445 .pid_filter_count = 32,
Olivier Grenie03245a52009-12-04 13:27:57 -03004446 .pid_filter = stk80xx_pid_filter,
4447 .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03004448 .frontend_attach = stk807x_frontend_attach,
4449 .tuner_attach = dib807x_tuner_attach,
4450
4451 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004452 }},
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03004453 .size_of_priv =
4454 sizeof(struct dib0700_adapter_state),
4455 },
4456 },
4457
S?rgio Fortier8a378e82009-09-28 04:19:21 -03004458 .num_device_descs = 3,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03004459 .devices = {
4460 { "DiBcom STK807xP reference design",
4461 { &dib0700_usb_id_table[62], NULL },
4462 { NULL },
4463 },
Mauro Carvalho Chehabaaeab302009-09-16 09:18:26 -03004464 { "Prolink Pixelview SBTVD",
4465 { &dib0700_usb_id_table[63], NULL },
4466 { NULL },
4467 },
S?rgio Fortier8a378e82009-09-28 04:19:21 -03004468 { "EvolutePC TVWay+",
4469 { &dib0700_usb_id_table[64], NULL },
4470 { NULL },
4471 },
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03004472 },
4473
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004474 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004475 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004476 .rc_codes = RC_MAP_DIB0700_NEC_TABLE,
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004477 .module_name = "dib0700",
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03004478 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004479 .allowed_protos = RC_BIT_RC5 |
4480 RC_BIT_RC6_MCE |
4481 RC_BIT_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03004482 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004483 },
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03004484 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4485 .num_adapters = 2,
4486 .adapter = {
4487 {
Michael Krufky77eed212011-09-06 09:31:57 -03004488 .num_frontends = 1,
4489 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03004490 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4491 .pid_filter_count = 32,
Olivier Grenie03245a52009-12-04 13:27:57 -03004492 .pid_filter = stk80xx_pid_filter,
4493 .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03004494 .frontend_attach = stk807xpvr_frontend_attach0,
4495 .tuner_attach = dib807x_tuner_attach,
4496
4497 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004498 }},
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03004499 .size_of_priv =
4500 sizeof(struct dib0700_adapter_state),
4501 },
4502 {
Michael Krufky77eed212011-09-06 09:31:57 -03004503 .num_frontends = 1,
4504 .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,
Olivier Grenie03245a52009-12-04 13:27:57 -03004507 .pid_filter = stk80xx_pid_filter,
4508 .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03004509 .frontend_attach = stk807xpvr_frontend_attach1,
4510 .tuner_attach = dib807x_tuner_attach,
4511
4512 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
Michael Krufky77eed212011-09-06 09:31:57 -03004513 }},
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03004514 .size_of_priv =
4515 sizeof(struct dib0700_adapter_state),
4516 },
4517 },
4518
4519 .num_device_descs = 1,
4520 .devices = {
4521 { "DiBcom STK807xPVR reference design",
4522 { &dib0700_usb_id_table[61], NULL },
4523 { NULL },
4524 },
4525 },
4526
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004527 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004528 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004529 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004530 .module_name = "dib0700",
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03004531 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004532 .allowed_protos = RC_BIT_RC5 |
4533 RC_BIT_RC6_MCE |
4534 RC_BIT_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03004535 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004536 },
Olivier Grenie03245a52009-12-04 13:27:57 -03004537 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4538 .num_adapters = 1,
4539 .adapter = {
4540 {
Michael Krufky77eed212011-09-06 09:31:57 -03004541 .num_frontends = 1,
4542 .fe = {{
Olivier Grenie03245a52009-12-04 13:27:57 -03004543 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
4544 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4545 .pid_filter_count = 32,
4546 .pid_filter = stk80xx_pid_filter,
4547 .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
4548 .frontend_attach = stk809x_frontend_attach,
4549 .tuner_attach = dib809x_tuner_attach,
4550
4551 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004552 }},
Olivier Grenie03245a52009-12-04 13:27:57 -03004553 .size_of_priv =
4554 sizeof(struct dib0700_adapter_state),
4555 },
4556 },
4557
4558 .num_device_descs = 1,
4559 .devices = {
4560 { "DiBcom STK8096GP reference design",
4561 { &dib0700_usb_id_table[67], NULL },
4562 { NULL },
4563 },
4564 },
4565
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004566 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004567 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004568 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004569 .module_name = "dib0700",
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03004570 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004571 .allowed_protos = RC_BIT_RC5 |
4572 RC_BIT_RC6_MCE |
4573 RC_BIT_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03004574 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004575 },
Olivier Greniebe9bae12011-01-04 05:42:19 -03004576 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4577 .num_adapters = 1,
4578 .adapter = {
4579 {
Michael Krufky77eed212011-09-06 09:31:57 -03004580 .num_frontends = 1,
4581 .fe = {{
Olivier Greniebe9bae12011-01-04 05:42:19 -03004582 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
4583 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4584 .pid_filter_count = 32,
4585 .pid_filter = dib90x0_pid_filter,
4586 .pid_filter_ctrl = dib90x0_pid_filter_ctrl,
4587 .frontend_attach = stk9090m_frontend_attach,
4588 .tuner_attach = dib9090_tuner_attach,
4589
4590 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004591 }},
Olivier Greniebe9bae12011-01-04 05:42:19 -03004592 .size_of_priv =
4593 sizeof(struct dib0700_adapter_state),
4594 },
4595 },
4596
4597 .num_device_descs = 1,
4598 .devices = {
4599 { "DiBcom STK9090M reference design",
4600 { &dib0700_usb_id_table[69], NULL },
4601 { NULL },
4602 },
4603 },
4604
4605 .rc.core = {
4606 .rc_interval = DEFAULT_RC_INTERVAL,
4607 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4608 .module_name = "dib0700",
4609 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004610 .allowed_protos = RC_BIT_RC5 |
4611 RC_BIT_RC6_MCE |
4612 RC_BIT_NEC,
Olivier Greniebe9bae12011-01-04 05:42:19 -03004613 .change_protocol = dib0700_change_protocol,
4614 },
4615 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4616 .num_adapters = 1,
4617 .adapter = {
4618 {
Michael Krufky77eed212011-09-06 09:31:57 -03004619 .num_frontends = 1,
4620 .fe = {{
Olivier Greniebe9bae12011-01-04 05:42:19 -03004621 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
4622 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4623 .pid_filter_count = 32,
4624 .pid_filter = stk80xx_pid_filter,
4625 .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
4626 .frontend_attach = nim8096md_frontend_attach,
4627 .tuner_attach = nim8096md_tuner_attach,
4628
4629 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004630 }},
Olivier Greniebe9bae12011-01-04 05:42:19 -03004631 .size_of_priv =
4632 sizeof(struct dib0700_adapter_state),
4633 },
4634 },
4635
4636 .num_device_descs = 1,
4637 .devices = {
4638 { "DiBcom NIM8096MD reference design",
4639 { &dib0700_usb_id_table[70], NULL },
4640 { NULL },
4641 },
4642 },
4643
4644 .rc.core = {
4645 .rc_interval = DEFAULT_RC_INTERVAL,
4646 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4647 .module_name = "dib0700",
4648 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004649 .allowed_protos = RC_BIT_RC5 |
4650 RC_BIT_RC6_MCE |
4651 RC_BIT_NEC,
Olivier Greniebe9bae12011-01-04 05:42:19 -03004652 .change_protocol = dib0700_change_protocol,
4653 },
4654 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4655 .num_adapters = 1,
4656 .adapter = {
4657 {
Michael Krufky77eed212011-09-06 09:31:57 -03004658 .num_frontends = 1,
4659 .fe = {{
Olivier Greniebe9bae12011-01-04 05:42:19 -03004660 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
4661 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4662 .pid_filter_count = 32,
4663 .pid_filter = dib90x0_pid_filter,
4664 .pid_filter_ctrl = dib90x0_pid_filter_ctrl,
4665 .frontend_attach = nim9090md_frontend_attach,
4666 .tuner_attach = nim9090md_tuner_attach,
4667
4668 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004669 }},
Olivier Greniebe9bae12011-01-04 05:42:19 -03004670 .size_of_priv =
4671 sizeof(struct dib0700_adapter_state),
4672 },
4673 },
4674
4675 .num_device_descs = 1,
4676 .devices = {
4677 { "DiBcom NIM9090MD reference design",
4678 { &dib0700_usb_id_table[71], NULL },
4679 { NULL },
4680 },
4681 },
4682
4683 .rc.core = {
4684 .rc_interval = DEFAULT_RC_INTERVAL,
4685 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4686 .module_name = "dib0700",
4687 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004688 .allowed_protos = RC_BIT_RC5 |
4689 RC_BIT_RC6_MCE |
4690 RC_BIT_NEC,
Olivier Greniebe9bae12011-01-04 05:42:19 -03004691 .change_protocol = dib0700_change_protocol,
4692 },
4693 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4694 .num_adapters = 1,
4695 .adapter = {
4696 {
Michael Krufky77eed212011-09-06 09:31:57 -03004697 .num_frontends = 1,
4698 .fe = {{
Olivier Greniebe9bae12011-01-04 05:42:19 -03004699 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
4700 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4701 .pid_filter_count = 32,
4702 .pid_filter = stk70x0p_pid_filter,
4703 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
4704 .frontend_attach = nim7090_frontend_attach,
4705 .tuner_attach = nim7090_tuner_attach,
4706
4707 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004708 }},
Olivier Greniebe9bae12011-01-04 05:42:19 -03004709 .size_of_priv =
4710 sizeof(struct dib0700_adapter_state),
4711 },
4712 },
4713
4714 .num_device_descs = 1,
4715 .devices = {
4716 { "DiBcom NIM7090 reference design",
4717 { &dib0700_usb_id_table[72], NULL },
4718 { NULL },
4719 },
4720 },
4721
4722 .rc.core = {
4723 .rc_interval = DEFAULT_RC_INTERVAL,
4724 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4725 .module_name = "dib0700",
4726 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004727 .allowed_protos = RC_BIT_RC5 |
4728 RC_BIT_RC6_MCE |
4729 RC_BIT_NEC,
Olivier Greniebe9bae12011-01-04 05:42:19 -03004730 .change_protocol = dib0700_change_protocol,
4731 },
4732 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4733 .num_adapters = 2,
4734 .adapter = {
4735 {
Michael Krufky77eed212011-09-06 09:31:57 -03004736 .num_frontends = 1,
4737 .fe = {{
Olivier Greniebe9bae12011-01-04 05:42:19 -03004738 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
4739 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4740 .pid_filter_count = 32,
4741 .pid_filter = stk70x0p_pid_filter,
4742 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
4743 .frontend_attach = tfe7090pvr_frontend0_attach,
4744 .tuner_attach = tfe7090pvr_tuner0_attach,
4745
4746 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
Michael Krufky77eed212011-09-06 09:31:57 -03004747 }},
Olivier Greniebe9bae12011-01-04 05:42:19 -03004748 .size_of_priv =
4749 sizeof(struct dib0700_adapter_state),
4750 },
4751 {
Michael Krufky77eed212011-09-06 09:31:57 -03004752 .num_frontends = 1,
4753 .fe = {{
Olivier Greniebe9bae12011-01-04 05:42:19 -03004754 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
4755 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4756 .pid_filter_count = 32,
4757 .pid_filter = stk70x0p_pid_filter,
4758 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
4759 .frontend_attach = tfe7090pvr_frontend1_attach,
4760 .tuner_attach = tfe7090pvr_tuner1_attach,
4761
4762 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004763 }},
Olivier Greniebe9bae12011-01-04 05:42:19 -03004764 .size_of_priv =
4765 sizeof(struct dib0700_adapter_state),
4766 },
4767 },
4768
4769 .num_device_descs = 1,
4770 .devices = {
4771 { "DiBcom TFE7090PVR reference design",
4772 { &dib0700_usb_id_table[73], NULL },
4773 { NULL },
4774 },
4775 },
4776
4777 .rc.core = {
4778 .rc_interval = DEFAULT_RC_INTERVAL,
4779 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4780 .module_name = "dib0700",
4781 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004782 .allowed_protos = RC_BIT_RC5 |
4783 RC_BIT_RC6_MCE |
4784 RC_BIT_NEC,
Olivier Greniebe9bae12011-01-04 05:42:19 -03004785 .change_protocol = dib0700_change_protocol,
4786 },
Davide Ferri8d009a02009-06-23 22:34:06 -03004787 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4788 .num_adapters = 1,
4789 .adapter = {
4790 {
Michael Krufky77eed212011-09-06 09:31:57 -03004791 .num_frontends = 1,
4792 .fe = {{
Devin Heitmueller01f16262009-06-24 00:07:01 -03004793 .frontend_attach = pctv340e_frontend_attach,
Davide Ferri8d009a02009-06-23 22:34:06 -03004794 .tuner_attach = xc4000_tuner_attach,
4795
4796 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004797 }},
Davide Ferri8d009a02009-06-23 22:34:06 -03004798 .size_of_priv = sizeof(struct
4799 dib0700_adapter_state),
4800 },
4801 },
4802
Devin Heitmueller33fb1682009-06-23 22:48:02 -03004803 .num_device_descs = 2,
Davide Ferri8d009a02009-06-23 22:34:06 -03004804 .devices = {
4805 { "Pinnacle PCTV 340e HD Pro USB Stick",
4806 { &dib0700_usb_id_table[76], NULL },
4807 { NULL },
4808 },
Devin Heitmueller33fb1682009-06-23 22:48:02 -03004809 { "Pinnacle PCTV Hybrid Stick Solo",
4810 { &dib0700_usb_id_table[77], NULL },
4811 { NULL },
4812 },
Davide Ferri8d009a02009-06-23 22:34:06 -03004813 },
4814 .rc.core = {
4815 .rc_interval = DEFAULT_RC_INTERVAL,
4816 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4817 .module_name = "dib0700",
4818 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004819 .allowed_protos = RC_BIT_RC5 |
4820 RC_BIT_RC6_MCE |
4821 RC_BIT_NEC,
Davide Ferri8d009a02009-06-23 22:34:06 -03004822 .change_protocol = dib0700_change_protocol,
4823 },
Olivier Grenie6724a2f2011-08-05 13:49:33 -03004824 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4825 .num_adapters = 1,
4826 .adapter = {
4827 {
4828 .num_frontends = 1,
4829 .fe = {{
4830 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
4831 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4832 .pid_filter_count = 32,
4833 .pid_filter = stk70x0p_pid_filter,
4834 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
Olivier Grenief45f5132012-12-31 09:47:10 -03004835 .frontend_attach = tfe7790p_frontend_attach,
4836 .tuner_attach = tfe7790p_tuner_attach,
Olivier Grenieb293f302011-08-09 04:48:25 -03004837
4838 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
4839 } },
4840
4841 .size_of_priv =
4842 sizeof(struct dib0700_adapter_state),
4843 },
4844 },
4845
4846 .num_device_descs = 1,
4847 .devices = {
Olivier Grenief45f5132012-12-31 09:47:10 -03004848 { "DiBcom TFE7790P reference design",
4849 { &dib0700_usb_id_table[78], NULL },
Olivier Grenieb293f302011-08-09 04:48:25 -03004850 { NULL },
4851 },
4852 },
4853
4854 .rc.core = {
4855 .rc_interval = DEFAULT_RC_INTERVAL,
4856 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4857 .module_name = "dib0700",
4858 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004859 .allowed_protos = RC_BIT_RC5 |
4860 RC_BIT_RC6_MCE |
4861 RC_BIT_NEC,
Olivier Grenieb293f302011-08-09 04:48:25 -03004862 .change_protocol = dib0700_change_protocol,
4863 },
Olivier Grenie88f3a352011-08-10 05:28:38 -03004864 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4865 .num_adapters = 1,
4866 .adapter = {
4867 {
4868 .num_frontends = 1,
4869 .fe = {{
4870 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
4871 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4872 .pid_filter_count = 32,
4873 .pid_filter = stk80xx_pid_filter,
4874 .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
4875 .frontend_attach = tfe8096p_frontend_attach,
4876 .tuner_attach = tfe8096p_tuner_attach,
4877
4878 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
4879
4880 } },
4881
4882 .size_of_priv =
4883 sizeof(struct dib0700_adapter_state),
4884 },
4885 },
4886
4887 .num_device_descs = 1,
4888 .devices = {
4889 { "DiBcom TFE8096P reference design",
Olivier Grenief45f5132012-12-31 09:47:10 -03004890 { &dib0700_usb_id_table[79], NULL },
Olivier Grenie88f3a352011-08-10 05:28:38 -03004891 { NULL },
4892 },
4893 },
4894
4895 .rc.core = {
4896 .rc_interval = DEFAULT_RC_INTERVAL,
4897 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4898 .module_name = "dib0700",
4899 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004900 .allowed_protos = RC_BIT_RC5 |
4901 RC_BIT_RC6_MCE |
4902 RC_BIT_NEC,
Olivier Grenie88f3a352011-08-10 05:28:38 -03004903 .change_protocol = dib0700_change_protocol,
4904 },
Patrick Boettcher01373a52007-07-30 12:49:04 -03004905 },
Patrick Boettcherb7f54912006-09-19 12:51:37 -03004906};
4907
4908int dib0700_device_count = ARRAY_SIZE(dib0700_devices);