blob: d067bb77534ff5cf577cf0dd35646a2a82d68ade [file] [log] [blame]
Patrick Boettcherb7f54912006-09-19 12:51:37 -03001/* Linux driver for devices based on the DiBcom DiB0700 USB bridge
2 *
3 * This program is free software; you can redistribute it and/or modify it
4 * under the terms of the GNU General Public License as published by the Free
5 * Software Foundation, version 2.
6 *
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03007 * Copyright (C) 2005-9 DiBcom, SA et al
Patrick Boettcherb7f54912006-09-19 12:51:37 -03008 */
9#include "dib0700.h"
10
11#include "dib3000mc.h"
Patrick Boettcher91bb9be2006-12-02 21:15:51 -020012#include "dib7000m.h"
Patrick Boettchera75763f2006-10-18 08:34:16 -030013#include "dib7000p.h"
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -030014#include "dib8000.h"
Olivier Greniebe9bae12011-01-04 05:42:19 -030015#include "dib9000.h"
Patrick Boettcherb7f54912006-09-19 12:51:37 -030016#include "mt2060.h"
Olivier DANET54d75eb2007-07-25 14:42:54 -030017#include "mt2266.h"
Albert Comerma6ca8f0b2008-03-29 21:35:57 -030018#include "tuner-xc2028.h"
Devin Heitmuellercb22cb52008-09-08 05:42:42 -030019#include "xc5000.h"
Davide Ferri8d009a02009-06-23 22:34:06 -030020#include "xc4000.h"
Devin Heitmuellercb22cb52008-09-08 05:42:42 -030021#include "s5h1411.h"
Patrick Boettcher01373a52007-07-30 12:49:04 -030022#include "dib0070.h"
Olivier Grenie03245a52009-12-04 13:27:57 -030023#include "dib0090.h"
Michael Krufkyce904bc2009-01-19 01:12:55 -030024#include "lgdt3305.h"
25#include "mxl5007t.h"
Patrick Boettcherb7f54912006-09-19 12:51:37 -030026
Patrick Boettcher7fb3fc02006-09-20 04:37:18 -030027static int force_lna_activation;
28module_param(force_lna_activation, int, 0644);
29MODULE_PARM_DESC(force_lna_activation, "force the activation of Low-Noise-Amplifyer(s) (LNA), "
30 "if applicable for the device (default: 0=automatic/off).");
31
Patrick Boettcher01373a52007-07-30 12:49:04 -030032struct dib0700_adapter_state {
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -030033 int (*set_param_save) (struct dvb_frontend *);
Olivier Greniebe9bae12011-01-04 05:42:19 -030034 const struct firmware *frontend_firmware;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -030035 struct dib7000p_ops dib7000p_ops;
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -030036 struct dib8000_ops dib8000_ops;
Patrick Boettcher01373a52007-07-30 12:49:04 -030037};
38
39/* Hauppauge Nova-T 500 (aka Bristol)
Patrick Boettcherb7f54912006-09-19 12:51:37 -030040 * has a LNA on GPIO0 which is enabled by setting 1 */
41static struct mt2060_config bristol_mt2060_config[2] = {
42 {
43 .i2c_address = 0x60,
Patrick Boettcher303cbea2006-09-19 12:51:56 -030044 .clock_out = 3,
Patrick Boettcherb7f54912006-09-19 12:51:37 -030045 }, {
46 .i2c_address = 0x61,
47 }
48};
49
Devin Heitmueller99afb982008-11-15 07:13:07 -030050
Patrick Boettcherb7f54912006-09-19 12:51:37 -030051static struct dibx000_agc_config bristol_dib3000p_mt2060_agc_config = {
52 .band_caps = BAND_VHF | BAND_UHF,
Patrick Boettcher01b4bf32006-09-19 12:51:53 -030053 .setup = (1 << 8) | (5 << 5) | (0 << 4) | (0 << 3) | (0 << 2) | (2 << 0),
Patrick Boettcherb7f54912006-09-19 12:51:37 -030054
Patrick Boettcher6958eff2006-09-19 12:51:40 -030055 .agc1_max = 42598,
56 .agc1_min = 17694,
57 .agc2_max = 45875,
58 .agc2_min = 0,
Patrick Boettcherb7f54912006-09-19 12:51:37 -030059
Patrick Boettcher6958eff2006-09-19 12:51:40 -030060 .agc1_pt1 = 0,
61 .agc1_pt2 = 59,
Patrick Boettcherb7f54912006-09-19 12:51:37 -030062
Patrick Boettcher6958eff2006-09-19 12:51:40 -030063 .agc1_slope1 = 0,
64 .agc1_slope2 = 69,
Patrick Boettcherb7f54912006-09-19 12:51:37 -030065
66 .agc2_pt1 = 0,
Patrick Boettcher6958eff2006-09-19 12:51:40 -030067 .agc2_pt2 = 59,
Patrick Boettcherb7f54912006-09-19 12:51:37 -030068
Patrick Boettcher6958eff2006-09-19 12:51:40 -030069 .agc2_slope1 = 111,
70 .agc2_slope2 = 28,
Patrick Boettcherb7f54912006-09-19 12:51:37 -030071};
72
73static struct dib3000mc_config bristol_dib3000mc_config[2] = {
74 { .agc = &bristol_dib3000p_mt2060_agc_config,
75 .max_time = 0x196,
76 .ln_adc_level = 0x1cc7,
77 .output_mpeg2_in_188_bytes = 1,
78 },
79 { .agc = &bristol_dib3000p_mt2060_agc_config,
80 .max_time = 0x196,
81 .ln_adc_level = 0x1cc7,
82 .output_mpeg2_in_188_bytes = 1,
83 }
84};
85
86static int bristol_frontend_attach(struct dvb_usb_adapter *adap)
87{
Patrick Boettcher6958eff2006-09-19 12:51:40 -030088 struct dib0700_state *st = adap->dev->priv;
Patrick Boettcherb7f54912006-09-19 12:51:37 -030089 if (adap->id == 0) {
90 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0); msleep(10);
91 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1); msleep(10);
92 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0); msleep(10);
93 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1); msleep(10);
94
Patrick Boettcher7fb3fc02006-09-20 04:37:18 -030095 if (force_lna_activation)
96 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
97 else
98 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 0);
Patrick Boettcher6958eff2006-09-19 12:51:40 -030099
Patrick Boettcherb7f54912006-09-19 12:51:37 -0300100 if (dib3000mc_i2c_enumeration(&adap->dev->i2c_adap, 2, DEFAULT_DIB3000P_I2C_ADDRESS, bristol_dib3000mc_config) != 0) {
101 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0); msleep(10);
102 return -ENODEV;
103 }
104 }
Patrick Boettcher6958eff2006-09-19 12:51:40 -0300105 st->mt2060_if1[adap->id] = 1220;
Michael Krufky77eed212011-09-06 09:31:57 -0300106 return (adap->fe_adap[0].fe = dvb_attach(dib3000mc_attach, &adap->dev->i2c_adap,
Patrick Boettcher6958eff2006-09-19 12:51:40 -0300107 (10 + adap->id) << 1, &bristol_dib3000mc_config[adap->id])) == NULL ? -ENODEV : 0;
Patrick Boettcherb7f54912006-09-19 12:51:37 -0300108}
109
Patrick Boettcher4a2b1082008-01-25 07:32:58 -0300110static int eeprom_read(struct i2c_adapter *adap,u8 adrs,u8 *pval)
Olivier DANETc52344f2008-01-25 06:50:07 -0300111{
112 struct i2c_msg msg[2] = {
113 { .addr = 0x50, .flags = 0, .buf = &adrs, .len = 1 },
114 { .addr = 0x50, .flags = I2C_M_RD, .buf = pval, .len = 1 },
115 };
116 if (i2c_transfer(adap, msg, 2) != 2) return -EREMOTEIO;
117 return 0;
118}
119
Patrick Boettcherb7f54912006-09-19 12:51:37 -0300120static int bristol_tuner_attach(struct dvb_usb_adapter *adap)
121{
Olivier DANETc52344f2008-01-25 06:50:07 -0300122 struct i2c_adapter *prim_i2c = &adap->dev->i2c_adap;
Michael Krufky77eed212011-09-06 09:31:57 -0300123 struct i2c_adapter *tun_i2c = dib3000mc_get_tuner_i2c_master(adap->fe_adap[0].fe, 1);
Olivier DANETc52344f2008-01-25 06:50:07 -0300124 s8 a;
125 int if1=1220;
Al Viroda5ee482008-05-21 00:31:21 -0300126 if (adap->dev->udev->descriptor.idVendor == cpu_to_le16(USB_VID_HAUPPAUGE) &&
127 adap->dev->udev->descriptor.idProduct == cpu_to_le16(USB_PID_HAUPPAUGE_NOVA_T_500_2)) {
Olivier DANETc52344f2008-01-25 06:50:07 -0300128 if (!eeprom_read(prim_i2c,0x59 + adap->id,&a)) if1=1220+a;
129 }
Michael Krufky9a9677a2011-09-13 01:32:11 -0300130 return dvb_attach(mt2060_attach, adap->fe_adap[0].fe, tun_i2c,
131 &bristol_mt2060_config[adap->id], if1) == NULL ?
132 -ENODEV : 0;
Patrick Boettcherb7f54912006-09-19 12:51:37 -0300133}
134
Patrick Boettcher01373a52007-07-30 12:49:04 -0300135/* STK7700D: Pinnacle/Terratec/Hauppauge Dual DVB-T Diversity */
Olivier DANET54d75eb2007-07-25 14:42:54 -0300136
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300137/* MT226x */
138static struct dibx000_agc_config stk7700d_7000p_mt2266_agc_config[2] = {
139 {
Olivier Grenie9c783032009-12-07 07:49:40 -0300140 BAND_UHF,
Olivier DANET54d75eb2007-07-25 14:42:54 -0300141
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300142 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=1, P_agc_inv_pwm1=1, P_agc_inv_pwm2=1,
143 * P_agc_inh_dc_rv_est=0, P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=2, P_agc_write=0 */
Olivier Grenie9c783032009-12-07 07:49:40 -0300144 (0 << 15) | (0 << 14) | (1 << 11) | (1 << 10) | (1 << 9) | (0 << 8)
145 | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),
Olivier DANET54d75eb2007-07-25 14:42:54 -0300146
Olivier Grenie9c783032009-12-07 07:49:40 -0300147 1130,
148 21,
Olivier DANET54d75eb2007-07-25 14:42:54 -0300149
Olivier Grenie9c783032009-12-07 07:49:40 -0300150 0,
151 118,
Olivier DANET54d75eb2007-07-25 14:42:54 -0300152
Olivier Grenie9c783032009-12-07 07:49:40 -0300153 0,
154 3530,
155 1,
156 0,
Olivier DANET54d75eb2007-07-25 14:42:54 -0300157
Olivier Grenie9c783032009-12-07 07:49:40 -0300158 65535,
159 33770,
160 65535,
161 23592,
Olivier DANET54d75eb2007-07-25 14:42:54 -0300162
Olivier Grenie9c783032009-12-07 07:49:40 -0300163 0,
164 62,
165 255,
166 64,
167 64,
168 132,
169 192,
170 80,
171 80,
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300172
Olivier Grenie9c783032009-12-07 07:49:40 -0300173 17,
174 27,
175 23,
176 51,
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300177
Olivier Grenie9c783032009-12-07 07:49:40 -0300178 1,
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300179 }, {
Olivier Grenie9c783032009-12-07 07:49:40 -0300180 BAND_VHF | BAND_LBAND,
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300181
182 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=1, P_agc_inv_pwm1=1, P_agc_inv_pwm2=1,
183 * P_agc_inh_dc_rv_est=0, P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=2, P_agc_write=0 */
Olivier Grenie9c783032009-12-07 07:49:40 -0300184 (0 << 15) | (0 << 14) | (1 << 11) | (1 << 10) | (1 << 9) | (0 << 8)
185 | (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0),
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300186
Olivier Grenie9c783032009-12-07 07:49:40 -0300187 2372,
188 21,
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300189
Olivier Grenie9c783032009-12-07 07:49:40 -0300190 0,
191 118,
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300192
Olivier Grenie9c783032009-12-07 07:49:40 -0300193 0,
194 3530,
195 1,
196 0,
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300197
Olivier Grenie9c783032009-12-07 07:49:40 -0300198 65535,
199 0,
200 65535,
201 23592,
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300202
Olivier Grenie9c783032009-12-07 07:49:40 -0300203 0,
204 128,
205 128,
206 128,
207 0,
208 128,
209 253,
210 81,
211 0,
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300212
Olivier Grenie9c783032009-12-07 07:49:40 -0300213 17,
214 27,
215 23,
216 51,
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300217
Olivier Grenie9c783032009-12-07 07:49:40 -0300218 1,
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300219 }
Olivier DANET54d75eb2007-07-25 14:42:54 -0300220};
221
222static struct dibx000_bandwidth_config stk7700d_mt2266_pll_config = {
Olivier Grenie9c783032009-12-07 07:49:40 -0300223 60000, 30000,
224 1, 8, 3, 1, 0,
225 0, 0, 1, 1, 2,
226 (3 << 14) | (1 << 12) | (524 << 0),
227 0,
228 20452225,
Olivier DANET54d75eb2007-07-25 14:42:54 -0300229};
230
231static struct dib7000p_config stk7700d_dib7000p_mt2266_config[] = {
232 { .output_mpeg2_in_188_bytes = 1,
233 .hostbus_diversity = 1,
234 .tuner_is_baseband = 1,
235
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300236 .agc_config_count = 2,
237 .agc = stk7700d_7000p_mt2266_agc_config,
Olivier DANET54d75eb2007-07-25 14:42:54 -0300238 .bw = &stk7700d_mt2266_pll_config,
239
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300240 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
241 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
242 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
Olivier DANET54d75eb2007-07-25 14:42:54 -0300243 },
244 { .output_mpeg2_in_188_bytes = 1,
245 .hostbus_diversity = 1,
246 .tuner_is_baseband = 1,
247
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300248 .agc_config_count = 2,
249 .agc = stk7700d_7000p_mt2266_agc_config,
Olivier DANET54d75eb2007-07-25 14:42:54 -0300250 .bw = &stk7700d_mt2266_pll_config,
251
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300252 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
253 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
254 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
Olivier DANET54d75eb2007-07-25 14:42:54 -0300255 }
256};
257
258static struct mt2266_config stk7700d_mt2266_config[2] = {
259 { .i2c_address = 0x60
260 },
261 { .i2c_address = 0x60
262 }
263};
264
Daniel Gimpelevich132c3182008-01-25 06:02:42 -0300265static int stk7700P2_frontend_attach(struct dvb_usb_adapter *adap)
266{
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300267 struct dib0700_adapter_state *state = adap->priv;
268
269 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
270 return -ENODEV;
271
Daniel Gimpelevich132c3182008-01-25 06:02:42 -0300272 if (adap->id == 0) {
273 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
274 msleep(10);
275 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
276 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
277 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
278 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
279 msleep(10);
280 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
281 msleep(10);
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300282 if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 18,
Devin Heitmueller83c4fdf2009-01-21 01:55:45 -0300283 stk7700d_dib7000p_mt2266_config)
284 != 0) {
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300285 err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n", __func__);
286 dvb_detach(&state->dib7000p_ops);
Devin Heitmueller83c4fdf2009-01-21 01:55:45 -0300287 return -ENODEV;
288 }
Daniel Gimpelevich132c3182008-01-25 06:02:42 -0300289 }
290
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300291 adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap,
Michael Krufky2a776312011-09-16 09:26:59 -0300292 0x80 + (adap->id << 1),
293 &stk7700d_dib7000p_mt2266_config[adap->id]);
Daniel Gimpelevich132c3182008-01-25 06:02:42 -0300294
Michael Krufky77eed212011-09-06 09:31:57 -0300295 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Daniel Gimpelevich132c3182008-01-25 06:02:42 -0300296}
297
Olivier DANET54d75eb2007-07-25 14:42:54 -0300298static int stk7700d_frontend_attach(struct dvb_usb_adapter *adap)
299{
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300300 struct dib0700_adapter_state *state = adap->priv;
301
302 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
303 return -ENODEV;
304
Olivier DANET54d75eb2007-07-25 14:42:54 -0300305 if (adap->id == 0) {
306 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
307 msleep(10);
308 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
309 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
310 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
311 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
312 msleep(10);
313 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
314 msleep(10);
315 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300316 if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap, 2, 18,
Devin Heitmueller83c4fdf2009-01-21 01:55:45 -0300317 stk7700d_dib7000p_mt2266_config)
318 != 0) {
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300319 err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n", __func__);
320 dvb_detach(&state->dib7000p_ops);
Devin Heitmueller83c4fdf2009-01-21 01:55:45 -0300321 return -ENODEV;
322 }
Olivier DANET54d75eb2007-07-25 14:42:54 -0300323 }
324
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300325 adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap,
Michael Krufky2a776312011-09-16 09:26:59 -0300326 0x80 + (adap->id << 1),
327 &stk7700d_dib7000p_mt2266_config[adap->id]);
Olivier DANET54d75eb2007-07-25 14:42:54 -0300328
Michael Krufky77eed212011-09-06 09:31:57 -0300329 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Olivier DANET54d75eb2007-07-25 14:42:54 -0300330}
331
332static int stk7700d_tuner_attach(struct dvb_usb_adapter *adap)
333{
334 struct i2c_adapter *tun_i2c;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300335 struct dib0700_adapter_state *state = adap->priv;
336
337 tun_i2c = state->dib7000p_ops.get_i2c_master(adap->fe_adap[0].fe,
338 DIBX000_I2C_INTERFACE_TUNER, 1);
Michael Krufky77eed212011-09-06 09:31:57 -0300339 return dvb_attach(mt2266_attach, adap->fe_adap[0].fe, tun_i2c,
Joe Perches1ebcad72009-07-02 15:57:09 -0300340 &stk7700d_mt2266_config[adap->id]) == NULL ? -ENODEV : 0;
Olivier DANET54d75eb2007-07-25 14:42:54 -0300341}
342
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300343/* STK7700-PH: Digital/Analog Hybrid Tuner, e.h. Cinergy HT USB HE */
Harvey Harrisonb1721d02008-04-25 19:03:08 -0700344static struct dibx000_agc_config xc3028_agc_config = {
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300345 BAND_VHF | BAND_UHF, /* band_caps */
346
347 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=0,
348 * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
349 * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=2, P_agc_write=0 */
350 (0 << 15) | (0 << 14) | (0 << 11) | (0 << 10) | (0 << 9) | (0 << 8) |
351 (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0), /* setup */
352
353 712, /* inv_gain */
354 21, /* time_stabiliz */
355
356 0, /* alpha_level */
357 118, /* thlock */
358
359 0, /* wbd_inv */
360 2867, /* wbd_ref */
361 0, /* wbd_sel */
362 2, /* wbd_alpha */
363
364 0, /* agc1_max */
365 0, /* agc1_min */
366 39718, /* agc2_max */
367 9930, /* agc2_min */
368 0, /* agc1_pt1 */
369 0, /* agc1_pt2 */
370 0, /* agc1_pt3 */
371 0, /* agc1_slope1 */
372 0, /* agc1_slope2 */
373 0, /* agc2_pt1 */
374 128, /* agc2_pt2 */
375 29, /* agc2_slope1 */
376 29, /* agc2_slope2 */
377
378 17, /* alpha_mant */
379 27, /* alpha_exp */
380 23, /* beta_mant */
381 51, /* beta_exp */
382
383 1, /* perform_agc_softsplit */
384};
385
386/* PLL Configuration for COFDM BW_MHz = 8.00 with external clock = 30.00 */
Harvey Harrisonb1721d02008-04-25 19:03:08 -0700387static struct dibx000_bandwidth_config xc3028_bw_config = {
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300388 60000, 30000, /* internal, sampling */
389 1, 8, 3, 1, 0, /* pll_cfg: prediv, ratio, range, reset, bypass */
390 0, 0, 1, 1, 0, /* misc: refdiv, bypclk_div, IO_CLK_en_core, ADClkSrc,
391 modulo */
392 (3 << 14) | (1 << 12) | (524 << 0), /* sad_cfg: refsel, sel, freq_15k */
393 (1 << 25) | 5816102, /* ifreq = 5.200000 MHz */
394 20452225, /* timf */
395 30000000, /* xtal_hz */
396};
397
398static struct dib7000p_config stk7700ph_dib7700_xc3028_config = {
399 .output_mpeg2_in_188_bytes = 1,
400 .tuner_is_baseband = 1,
401
402 .agc_config_count = 1,
403 .agc = &xc3028_agc_config,
404 .bw = &xc3028_bw_config,
405
406 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
407 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
408 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
409};
410
Michael Krufkyd7cba042008-09-12 13:31:45 -0300411static int stk7700ph_xc3028_callback(void *ptr, int component,
412 int command, int arg)
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300413{
414 struct dvb_usb_adapter *adap = ptr;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300415 struct dib0700_adapter_state *state = adap->priv;
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300416
417 switch (command) {
418 case XC2028_TUNER_RESET:
419 /* Send the tuner in then out of reset */
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300420 state->dib7000p_ops.set_gpio(adap->fe_adap[0].fe, 8, 0, 0);
421 msleep(10);
422 state->dib7000p_ops.set_gpio(adap->fe_adap[0].fe, 8, 0, 1);
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300423 break;
424 case XC2028_RESET_CLK:
425 break;
426 default:
427 err("%s: unknown command %d, arg %d\n", __func__,
428 command, arg);
429 return -EINVAL;
430 }
431 return 0;
432}
433
434static struct xc2028_ctrl stk7700ph_xc3028_ctrl = {
435 .fname = XC2028_DEFAULT_FIRMWARE,
436 .max_len = 64,
437 .demod = XC3028_FE_DIBCOM52,
438};
439
440static struct xc2028_config stk7700ph_xc3028_config = {
441 .i2c_addr = 0x61,
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300442 .ctrl = &stk7700ph_xc3028_ctrl,
443};
444
445static int stk7700ph_frontend_attach(struct dvb_usb_adapter *adap)
446{
447 struct usb_device_descriptor *desc = &adap->dev->udev->descriptor;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300448 struct dib0700_adapter_state *state = adap->priv;
449
450 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
451 return -ENODEV;
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300452
Al Viroda5ee482008-05-21 00:31:21 -0300453 if (desc->idVendor == cpu_to_le16(USB_VID_PINNACLE) &&
454 desc->idProduct == cpu_to_le16(USB_PID_PINNACLE_EXPRESSCARD_320CX))
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300455 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300456 else
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300457 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300458 msleep(20);
459 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
460 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
461 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
462 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
463 msleep(10);
464 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
465 msleep(20);
466 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
467 msleep(10);
468
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300469 if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 18,
Devin Heitmueller83c4fdf2009-01-21 01:55:45 -0300470 &stk7700ph_dib7700_xc3028_config) != 0) {
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300471 err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n",
Devin Heitmueller83c4fdf2009-01-21 01:55:45 -0300472 __func__);
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300473 dvb_detach(&state->dib7000p_ops);
Devin Heitmueller83c4fdf2009-01-21 01:55:45 -0300474 return -ENODEV;
475 }
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300476
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300477 adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap, 0x80,
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300478 &stk7700ph_dib7700_xc3028_config);
479
Michael Krufky77eed212011-09-06 09:31:57 -0300480 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300481}
482
483static int stk7700ph_tuner_attach(struct dvb_usb_adapter *adap)
484{
485 struct i2c_adapter *tun_i2c;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300486 struct dib0700_adapter_state *state = adap->priv;
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300487
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300488 tun_i2c = state->dib7000p_ops.get_i2c_master(adap->fe_adap[0].fe,
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300489 DIBX000_I2C_INTERFACE_TUNER, 1);
490
491 stk7700ph_xc3028_config.i2c_adap = tun_i2c;
Michael Krufkyd7cba042008-09-12 13:31:45 -0300492
493 /* FIXME: generalize & move to common area */
Michael Krufky77eed212011-09-06 09:31:57 -0300494 adap->fe_adap[0].fe->callback = stk7700ph_xc3028_callback;
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300495
Michael Krufky77eed212011-09-06 09:31:57 -0300496 return dvb_attach(xc2028_attach, adap->fe_adap[0].fe, &stk7700ph_xc3028_config)
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300497 == NULL ? -ENODEV : 0;
498}
499
Devin Heitmueller4b330be2008-12-01 06:51:14 -0300500#define DEFAULT_RC_INTERVAL 50
Olivier DANET54d75eb2007-07-25 14:42:54 -0300501
502static u8 rc_request[] = { REQUEST_POLL_RC, 0 };
503
Patrick Boettcher58e6f952008-03-29 21:37:01 -0300504/* Number of keypresses to ignore before start repeating */
Devin Heitmueller4b330be2008-12-01 06:51:14 -0300505#define RC_REPEAT_DELAY 6
Patrick Boettcher58e6f952008-03-29 21:37:01 -0300506
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -0300507/*
508 * This function is used only when firmware is < 1.20 version. Newer
509 * firmwares use bulk mode, with functions implemented at dib0700_core,
510 * at dib0700_rc_urb_completion()
511 */
512static int dib0700_rc_query_old_firmware(struct dvb_usb_device *d)
Olivier DANET54d75eb2007-07-25 14:42:54 -0300513{
514 u8 key[4];
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -0300515 u32 keycode;
516 u8 toggle;
Olivier DANET54d75eb2007-07-25 14:42:54 -0300517 int i;
Olivier DANET54d75eb2007-07-25 14:42:54 -0300518 struct dib0700_state *st = d->priv;
Devin Heitmueller6a207102010-01-04 02:43:19 -0300519
Devin Heitmueller6a207102010-01-04 02:43:19 -0300520 if (st->fw_version >= 0x10200) {
521 /* For 1.20 firmware , We need to keep the RC polling
522 callback so we can reuse the input device setup in
523 dvb-usb-remote.c. However, the actual work is being done
524 in the bulk URB completion handler. */
525 return 0;
526 }
527
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -0300528 i = dib0700_ctrl_rd(d, rc_request, 2, key, 4);
529 if (i <= 0) {
Janne Grunau034d65e2007-07-31 08:48:40 -0300530 err("RC Query Failed");
Janne Grunau89f42672007-07-31 19:45:13 -0300531 return -1;
Olivier DANET54d75eb2007-07-25 14:42:54 -0300532 }
Patrick Boettcher58e6f952008-03-29 21:37:01 -0300533
534 /* losing half of KEY_0 events from Philipps rc5 remotes.. */
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -0300535 if (key[0] == 0 && key[1] == 0 && key[2] == 0 && key[3] == 0)
536 return 0;
Patrick Boettcher58e6f952008-03-29 21:37:01 -0300537
538 /* 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]); */
539
Mauro Carvalho Chehabc4018fa2014-05-21 17:40:25 -0300540 dib0700_rc_setup(d, NULL); /* reset ir sensor data to prevent false events */
Patrick Boettcher58e6f952008-03-29 21:37:01 -0300541
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -0300542 d->last_event = 0;
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -0300543 switch (d->props.rc.core.protocol) {
David Härdemanc003ab12012-10-11 19:11:54 -0300544 case RC_BIT_NEC:
Patrick Boettcher58e6f952008-03-29 21:37:01 -0300545 /* NEC protocol sends repeat code as 0 0 0 FF */
546 if ((key[3-2] == 0x00) && (key[3-3] == 0x00) &&
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -0300547 (key[3] == 0xff))
548 keycode = d->last_event;
549 else {
550 keycode = key[3-2] << 8 | key[3-3];
551 d->last_event = keycode;
Patrick Boettcher58e6f952008-03-29 21:37:01 -0300552 }
Patrick Boettcher58e6f952008-03-29 21:37:01 -0300553
Mauro Carvalho Chehabca866742010-11-17 13:53:11 -0300554 rc_keydown(d->rc_dev, keycode, 0);
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -0300555 break;
556 default:
557 /* RC-5 protocol changes toggle bit on new keypress */
558 keycode = key[3-2] << 8 | key[3-3];
559 toggle = key[3-1];
Mauro Carvalho Chehabca866742010-11-17 13:53:11 -0300560 rc_keydown(d->rc_dev, keycode, toggle);
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -0300561
Patrick Boettcher58e6f952008-03-29 21:37:01 -0300562 break;
563 }
Olivier DANET54d75eb2007-07-25 14:42:54 -0300564 return 0;
565}
566
Patrick Boettcherb7f54912006-09-19 12:51:37 -0300567/* STK7700P: Hauppauge Nova-T Stick, AVerMedia Volar */
Patrick Boettchera75763f2006-10-18 08:34:16 -0300568static struct dibx000_agc_config stk7700p_7000m_mt2060_agc_config = {
Olivier Grenie9c783032009-12-07 07:49:40 -0300569 BAND_UHF | BAND_VHF,
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300570
571 /* 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,
572 * 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 -0300573 (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8)
574 | (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0),
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300575
Olivier Grenie9c783032009-12-07 07:49:40 -0300576 712,
577 41,
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300578
Olivier Grenie9c783032009-12-07 07:49:40 -0300579 0,
580 118,
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300581
Olivier Grenie9c783032009-12-07 07:49:40 -0300582 0,
583 4095,
584 0,
585 0,
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300586
Olivier Grenie9c783032009-12-07 07:49:40 -0300587 42598,
588 17694,
589 45875,
590 2621,
591 0,
592 76,
593 139,
594 52,
595 59,
596 107,
597 172,
598 57,
599 70,
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300600
Olivier Grenie9c783032009-12-07 07:49:40 -0300601 21,
602 25,
603 28,
604 48,
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300605
Olivier Grenie9c783032009-12-07 07:49:40 -0300606 1,
607 { 0,
608 107,
609 51800,
610 24700
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300611 },
Patrick Boettcherb7f54912006-09-19 12:51:37 -0300612};
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300613
Patrick Boettchera75763f2006-10-18 08:34:16 -0300614static struct dibx000_agc_config stk7700p_7000p_mt2060_agc_config = {
615 BAND_UHF | BAND_VHF,
616
617 /* 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,
618 * 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 -0300619 (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8)
620 | (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0),
Patrick Boettchera75763f2006-10-18 08:34:16 -0300621
Olivier Grenie9c783032009-12-07 07:49:40 -0300622 712,
623 41,
Patrick Boettchera75763f2006-10-18 08:34:16 -0300624
Olivier Grenie9c783032009-12-07 07:49:40 -0300625 0,
626 118,
Patrick Boettchera75763f2006-10-18 08:34:16 -0300627
Olivier Grenie9c783032009-12-07 07:49:40 -0300628 0,
629 4095,
630 0,
631 0,
Patrick Boettchera75763f2006-10-18 08:34:16 -0300632
Olivier Grenie9c783032009-12-07 07:49:40 -0300633 42598,
634 16384,
635 42598,
636 0,
Patrick Boettchera75763f2006-10-18 08:34:16 -0300637
Olivier Grenie9c783032009-12-07 07:49:40 -0300638 0,
639 137,
640 255,
Patrick Boettchera75763f2006-10-18 08:34:16 -0300641
Olivier Grenie9c783032009-12-07 07:49:40 -0300642 0,
643 255,
Patrick Boettchera75763f2006-10-18 08:34:16 -0300644
Olivier Grenie9c783032009-12-07 07:49:40 -0300645 0,
646 0,
Patrick Boettchera75763f2006-10-18 08:34:16 -0300647
Olivier Grenie9c783032009-12-07 07:49:40 -0300648 0,
649 41,
Patrick Boettchera75763f2006-10-18 08:34:16 -0300650
Olivier Grenie9c783032009-12-07 07:49:40 -0300651 15,
652 25,
Patrick Boettchera75763f2006-10-18 08:34:16 -0300653
Olivier Grenie9c783032009-12-07 07:49:40 -0300654 28,
655 48,
Patrick Boettchera75763f2006-10-18 08:34:16 -0300656
Olivier Grenie9c783032009-12-07 07:49:40 -0300657 0,
Patrick Boettchera75763f2006-10-18 08:34:16 -0300658};
659
660static struct dibx000_bandwidth_config stk7700p_pll_config = {
Olivier Grenie9c783032009-12-07 07:49:40 -0300661 60000, 30000,
662 1, 8, 3, 1, 0,
663 0, 0, 1, 1, 0,
664 (3 << 14) | (1 << 12) | (524 << 0),
665 60258167,
666 20452225,
667 30000000,
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300668};
669
670static struct dib7000m_config stk7700p_dib7000m_config = {
671 .dvbt_mode = 1,
672 .output_mpeg2_in_188_bytes = 1,
673 .quartz_direct = 1,
674
675 .agc_config_count = 1,
Patrick Boettchera75763f2006-10-18 08:34:16 -0300676 .agc = &stk7700p_7000m_mt2060_agc_config,
677 .bw = &stk7700p_pll_config,
678
679 .gpio_dir = DIB7000M_GPIO_DEFAULT_DIRECTIONS,
680 .gpio_val = DIB7000M_GPIO_DEFAULT_VALUES,
681 .gpio_pwm_pos = DIB7000M_GPIO_DEFAULT_PWM_POS,
682};
683
684static struct dib7000p_config stk7700p_dib7000p_config = {
685 .output_mpeg2_in_188_bytes = 1,
686
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300687 .agc_config_count = 1,
Patrick Boettchera75763f2006-10-18 08:34:16 -0300688 .agc = &stk7700p_7000p_mt2060_agc_config,
689 .bw = &stk7700p_pll_config,
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300690
691 .gpio_dir = DIB7000M_GPIO_DEFAULT_DIRECTIONS,
692 .gpio_val = DIB7000M_GPIO_DEFAULT_VALUES,
693 .gpio_pwm_pos = DIB7000M_GPIO_DEFAULT_PWM_POS,
694};
Patrick Boettcherb7f54912006-09-19 12:51:37 -0300695
696static int stk7700p_frontend_attach(struct dvb_usb_adapter *adap)
697{
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300698 struct dib0700_state *st = adap->dev->priv;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300699 struct dib0700_adapter_state *state = adap->priv;
700
701 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
702 return -ENODEV;
703
Patrick Boettcherb7f54912006-09-19 12:51:37 -0300704 /* unless there is no real power management in DVB - we leave the device on GPIO6 */
Patrick Boettchera75763f2006-10-18 08:34:16 -0300705
706 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
707 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0); msleep(50);
708
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300709 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1); msleep(10);
Patrick Boettchera75763f2006-10-18 08:34:16 -0300710 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
711
Patrick Boettcherb7f54912006-09-19 12:51:37 -0300712 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0); msleep(10);
Patrick Boettchera75763f2006-10-18 08:34:16 -0300713 dib0700_ctrl_clock(adap->dev, 72, 1);
714 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1); msleep(100);
715
716 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
Patrick Boettcherb7f54912006-09-19 12:51:37 -0300717
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300718 st->mt2060_if1[0] = 1220;
Patrick Boettchera75763f2006-10-18 08:34:16 -0300719
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300720 if (state->dib7000p_ops.dib7000pc_detection(&adap->dev->i2c_adap)) {
721 adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap, 18, &stk7700p_dib7000p_config);
Patrick Boettchera75763f2006-10-18 08:34:16 -0300722 st->is_dib7000pc = 1;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300723 } else {
724 dvb_detach(&state->dib7000p_ops);
725 memset(&state->dib7000p_ops, 0, sizeof(state->dib7000p_ops));
Michael Krufky77eed212011-09-06 09:31:57 -0300726 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 -0300727 }
Patrick Boettchera75763f2006-10-18 08:34:16 -0300728
Michael Krufky77eed212011-09-06 09:31:57 -0300729 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Patrick Boettcherb7f54912006-09-19 12:51:37 -0300730}
731
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300732static struct mt2060_config stk7700p_mt2060_config = {
733 0x60
734};
735
Patrick Boettcherb7f54912006-09-19 12:51:37 -0300736static int stk7700p_tuner_attach(struct dvb_usb_adapter *adap)
737{
Olivier DANETc52344f2008-01-25 06:50:07 -0300738 struct i2c_adapter *prim_i2c = &adap->dev->i2c_adap;
Patrick Boettcher69ea31e2006-10-17 18:28:14 -0300739 struct dib0700_state *st = adap->dev->priv;
Patrick Boettchera75763f2006-10-18 08:34:16 -0300740 struct i2c_adapter *tun_i2c;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300741 struct dib0700_adapter_state *state = adap->priv;
Olivier DANETc52344f2008-01-25 06:50:07 -0300742 s8 a;
743 int if1=1220;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300744
Al Viroda5ee482008-05-21 00:31:21 -0300745 if (adap->dev->udev->descriptor.idVendor == cpu_to_le16(USB_VID_HAUPPAUGE) &&
746 adap->dev->udev->descriptor.idProduct == cpu_to_le16(USB_PID_HAUPPAUGE_NOVA_T_STICK)) {
Olivier DANETc52344f2008-01-25 06:50:07 -0300747 if (!eeprom_read(prim_i2c,0x58,&a)) if1=1220+a;
748 }
Patrick Boettchera75763f2006-10-18 08:34:16 -0300749 if (st->is_dib7000pc)
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300750 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 -0300751 else
Michael Krufky77eed212011-09-06 09:31:57 -0300752 tun_i2c = dib7000m_get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_TUNER, 1);
Patrick Boettchera75763f2006-10-18 08:34:16 -0300753
Michael Krufky77eed212011-09-06 09:31:57 -0300754 return dvb_attach(mt2060_attach, adap->fe_adap[0].fe, tun_i2c, &stk7700p_mt2060_config,
Olivier DANETc52344f2008-01-25 06:50:07 -0300755 if1) == NULL ? -ENODEV : 0;
Patrick Boettcherb7f54912006-09-19 12:51:37 -0300756}
757
Patrick Boettcher01373a52007-07-30 12:49:04 -0300758/* DIB7070 generic */
759static struct dibx000_agc_config dib7070_agc_config = {
760 BAND_UHF | BAND_VHF | BAND_LBAND | BAND_SBAND,
761 /* 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,
762 * 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 -0300763 (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8)
764 | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),
Patrick Boettcher01373a52007-07-30 12:49:04 -0300765
Olivier Grenie9c783032009-12-07 07:49:40 -0300766 600,
767 10,
Patrick Boettcher01373a52007-07-30 12:49:04 -0300768
Olivier Grenie9c783032009-12-07 07:49:40 -0300769 0,
770 118,
Patrick Boettcher01373a52007-07-30 12:49:04 -0300771
Olivier Grenie9c783032009-12-07 07:49:40 -0300772 0,
773 3530,
774 1,
775 5,
Patrick Boettcher01373a52007-07-30 12:49:04 -0300776
Olivier Grenie9c783032009-12-07 07:49:40 -0300777 65535,
778 0,
Patrick Boettcher01373a52007-07-30 12:49:04 -0300779
Olivier Grenie9c783032009-12-07 07:49:40 -0300780 65535,
781 0,
Patrick Boettcher01373a52007-07-30 12:49:04 -0300782
Olivier Grenie9c783032009-12-07 07:49:40 -0300783 0,
784 40,
785 183,
786 206,
787 255,
788 72,
789 152,
790 88,
791 90,
Patrick Boettcher01373a52007-07-30 12:49:04 -0300792
Olivier Grenie9c783032009-12-07 07:49:40 -0300793 17,
794 27,
795 23,
796 51,
Patrick Boettcher01373a52007-07-30 12:49:04 -0300797
Olivier Grenie9c783032009-12-07 07:49:40 -0300798 0,
Patrick Boettcher01373a52007-07-30 12:49:04 -0300799};
800
801static int dib7070_tuner_reset(struct dvb_frontend *fe, int onoff)
802{
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300803 struct dvb_usb_adapter *adap = fe->dvb->priv;
804 struct dib0700_adapter_state *state = adap->priv;
805
Patrick Boettcher7e5ce652009-08-03 13:43:40 -0300806 deb_info("reset: %d", onoff);
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300807 return state->dib7000p_ops.set_gpio(fe, 8, 0, !onoff);
Patrick Boettcher01373a52007-07-30 12:49:04 -0300808}
809
810static int dib7070_tuner_sleep(struct dvb_frontend *fe, int onoff)
811{
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300812 struct dvb_usb_adapter *adap = fe->dvb->priv;
813 struct dib0700_adapter_state *state = adap->priv;
814
Patrick Boettcher7e5ce652009-08-03 13:43:40 -0300815 deb_info("sleep: %d", onoff);
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300816 return state->dib7000p_ops.set_gpio(fe, 9, 0, onoff);
Patrick Boettcher01373a52007-07-30 12:49:04 -0300817}
818
819static struct dib0070_config dib7070p_dib0070_config[2] = {
820 {
821 .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
822 .reset = dib7070_tuner_reset,
823 .sleep = dib7070_tuner_sleep,
824 .clock_khz = 12000,
Patrick Boettcher7e5ce652009-08-03 13:43:40 -0300825 .clock_pad_drive = 4,
826 .charge_pump = 2,
Patrick Boettcher01373a52007-07-30 12:49:04 -0300827 }, {
828 .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
829 .reset = dib7070_tuner_reset,
830 .sleep = dib7070_tuner_sleep,
831 .clock_khz = 12000,
Patrick Boettcher7e5ce652009-08-03 13:43:40 -0300832 .charge_pump = 2,
Patrick Boettcher01373a52007-07-30 12:49:04 -0300833 }
834};
835
Olivier Grenied300bd62009-09-15 06:55:35 -0300836static struct dib0070_config dib7770p_dib0070_config = {
837 .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
838 .reset = dib7070_tuner_reset,
839 .sleep = dib7070_tuner_sleep,
840 .clock_khz = 12000,
841 .clock_pad_drive = 0,
842 .flip_chip = 1,
Olivier Grenieeac1fe12009-09-23 13:41:27 -0300843 .charge_pump = 2,
Olivier Grenied300bd62009-09-15 06:55:35 -0300844};
845
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -0300846static int dib7070_set_param_override(struct dvb_frontend *fe)
Patrick Boettcher01373a52007-07-30 12:49:04 -0300847{
Mauro Carvalho Chehab47b163a2011-12-24 10:18:24 -0300848 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
Patrick Boettcher01373a52007-07-30 12:49:04 -0300849 struct dvb_usb_adapter *adap = fe->dvb->priv;
850 struct dib0700_adapter_state *state = adap->priv;
851
852 u16 offset;
Mauro Carvalho Chehab47b163a2011-12-24 10:18:24 -0300853 u8 band = BAND_OF_FREQUENCY(p->frequency/1000);
Patrick Boettcher01373a52007-07-30 12:49:04 -0300854 switch (band) {
855 case BAND_VHF: offset = 950; break;
856 case BAND_UHF:
857 default: offset = 550; break;
858 }
859 deb_info("WBD for DiB7000P: %d\n", offset + dib0070_wbd_offset(fe));
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300860 state->dib7000p_ops.set_wbd_ref(fe, offset + dib0070_wbd_offset(fe));
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -0300861 return state->set_param_save(fe);
Patrick Boettcher01373a52007-07-30 12:49:04 -0300862}
863
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -0300864static int dib7770_set_param_override(struct dvb_frontend *fe)
Olivier Grenied300bd62009-09-15 06:55:35 -0300865{
Mauro Carvalho Chehab47b163a2011-12-24 10:18:24 -0300866 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
867 struct dvb_usb_adapter *adap = fe->dvb->priv;
868 struct dib0700_adapter_state *state = adap->priv;
Olivier Grenied300bd62009-09-15 06:55:35 -0300869
870 u16 offset;
Mauro Carvalho Chehab47b163a2011-12-24 10:18:24 -0300871 u8 band = BAND_OF_FREQUENCY(p->frequency/1000);
Olivier Grenied300bd62009-09-15 06:55:35 -0300872 switch (band) {
873 case BAND_VHF:
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300874 state->dib7000p_ops.set_gpio(fe, 0, 0, 1);
Olivier Grenied300bd62009-09-15 06:55:35 -0300875 offset = 850;
876 break;
877 case BAND_UHF:
878 default:
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300879 state->dib7000p_ops.set_gpio(fe, 0, 0, 0);
Olivier Grenied300bd62009-09-15 06:55:35 -0300880 offset = 250;
881 break;
882 }
883 deb_info("WBD for DiB7000P: %d\n", offset + dib0070_wbd_offset(fe));
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300884 state->dib7000p_ops.set_wbd_ref(fe, offset + dib0070_wbd_offset(fe));
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -0300885 return state->set_param_save(fe);
Olivier Grenied300bd62009-09-15 06:55:35 -0300886}
887
888static int dib7770p_tuner_attach(struct dvb_usb_adapter *adap)
889{
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300890 struct dib0700_adapter_state *st = adap->priv;
891 struct i2c_adapter *tun_i2c = st->dib7000p_ops.get_i2c_master(adap->fe_adap[0].fe,
Olivier Grenied300bd62009-09-15 06:55:35 -0300892 DIBX000_I2C_INTERFACE_TUNER, 1);
893
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300894 if (dvb_attach(dib0070_attach, adap->fe_adap[0].fe, tun_i2c,
895 &dib7770p_dib0070_config) == NULL)
896 return -ENODEV;
Olivier Grenied300bd62009-09-15 06:55:35 -0300897
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300898 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
899 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib7770_set_param_override;
900 return 0;
Olivier Grenied300bd62009-09-15 06:55:35 -0300901}
902
Patrick Boettcher01373a52007-07-30 12:49:04 -0300903static int dib7070p_tuner_attach(struct dvb_usb_adapter *adap)
904{
905 struct dib0700_adapter_state *st = adap->priv;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300906 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 -0300907
908 if (adap->id == 0) {
Michael Krufky77eed212011-09-06 09:31:57 -0300909 if (dvb_attach(dib0070_attach, adap->fe_adap[0].fe, tun_i2c, &dib7070p_dib0070_config[0]) == NULL)
Patrick Boettcher01373a52007-07-30 12:49:04 -0300910 return -ENODEV;
911 } else {
Michael Krufky77eed212011-09-06 09:31:57 -0300912 if (dvb_attach(dib0070_attach, adap->fe_adap[0].fe, tun_i2c, &dib7070p_dib0070_config[1]) == NULL)
Patrick Boettcher01373a52007-07-30 12:49:04 -0300913 return -ENODEV;
914 }
915
Michael Krufky77eed212011-09-06 09:31:57 -0300916 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
917 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib7070_set_param_override;
Patrick Boettcher01373a52007-07-30 12:49:04 -0300918 return 0;
919}
920
Olivier Greniee192a7c2011-01-14 13:58:59 -0300921static int stk7700p_pid_filter(struct dvb_usb_adapter *adapter, int index,
922 u16 pid, int onoff)
923{
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300924 struct dib0700_adapter_state *state = adapter->priv;
Olivier Greniee192a7c2011-01-14 13:58:59 -0300925 struct dib0700_state *st = adapter->dev->priv;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300926
Olivier Greniee192a7c2011-01-14 13:58:59 -0300927 if (st->is_dib7000pc)
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300928 return state->dib7000p_ops.pid_filter(adapter->fe_adap[0].fe, index, pid, onoff);
Michael Krufky77eed212011-09-06 09:31:57 -0300929 return dib7000m_pid_filter(adapter->fe_adap[0].fe, index, pid, onoff);
Olivier Greniee192a7c2011-01-14 13:58:59 -0300930}
931
932static int stk7700p_pid_filter_ctrl(struct dvb_usb_adapter *adapter, int onoff)
933{
934 struct dib0700_state *st = adapter->dev->priv;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300935 struct dib0700_adapter_state *state = adapter->priv;
Olivier Greniee192a7c2011-01-14 13:58:59 -0300936 if (st->is_dib7000pc)
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300937 return state->dib7000p_ops.pid_filter_ctrl(adapter->fe_adap[0].fe, onoff);
Michael Krufky77eed212011-09-06 09:31:57 -0300938 return dib7000m_pid_filter_ctrl(adapter->fe_adap[0].fe, onoff);
Olivier Greniee192a7c2011-01-14 13:58:59 -0300939}
940
Olivier Grenief8731f42009-09-18 04:08:43 -0300941static int stk70x0p_pid_filter(struct dvb_usb_adapter *adapter, int index, u16 pid, int onoff)
942{
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300943 struct dib0700_adapter_state *state = adapter->priv;
944 return state->dib7000p_ops.pid_filter(adapter->fe_adap[0].fe, index, pid, onoff);
Olivier Grenief8731f42009-09-18 04:08:43 -0300945}
946
947static int stk70x0p_pid_filter_ctrl(struct dvb_usb_adapter *adapter, int onoff)
948{
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300949 struct dib0700_adapter_state *state = adapter->priv;
950 return state->dib7000p_ops.pid_filter_ctrl(adapter->fe_adap[0].fe, onoff);
Olivier Grenief8731f42009-09-18 04:08:43 -0300951}
952
Patrick Boettcher01373a52007-07-30 12:49:04 -0300953static struct dibx000_bandwidth_config dib7070_bw_config_12_mhz = {
Olivier Grenie9c783032009-12-07 07:49:40 -0300954 60000, 15000,
955 1, 20, 3, 1, 0,
956 0, 0, 1, 1, 2,
957 (3 << 14) | (1 << 12) | (524 << 0),
958 (0 << 25) | 0,
959 20452225,
960 12000000,
Patrick Boettcher01373a52007-07-30 12:49:04 -0300961};
962
963static struct dib7000p_config dib7070p_dib7000p_config = {
964 .output_mpeg2_in_188_bytes = 1,
965
966 .agc_config_count = 1,
967 .agc = &dib7070_agc_config,
968 .bw = &dib7070_bw_config_12_mhz,
Patrick Boettcher3cb2c392008-01-25 07:25:20 -0300969 .tuner_is_baseband = 1,
970 .spur_protect = 1,
Patrick Boettcher01373a52007-07-30 12:49:04 -0300971
972 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
973 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
974 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
975
976 .hostbus_diversity = 1,
977};
978
979/* STK7070P */
980static int stk7070p_frontend_attach(struct dvb_usb_adapter *adap)
981{
Al Viroda5ee482008-05-21 00:31:21 -0300982 struct usb_device_descriptor *p = &adap->dev->udev->descriptor;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -0300983 struct dib0700_adapter_state *state = adap->priv;
984
985 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
986 return -ENODEV;
987
Al Viroda5ee482008-05-21 00:31:21 -0300988 if (p->idVendor == cpu_to_le16(USB_VID_PINNACLE) &&
989 p->idProduct == cpu_to_le16(USB_PID_PINNACLE_PCTV72E))
990 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
Albert Comerma6ca8f0b2008-03-29 21:35:57 -0300991 else
Al Viroda5ee482008-05-21 00:31:21 -0300992 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
Patrick Boettcher01373a52007-07-30 12:49:04 -0300993 msleep(10);
994 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
995 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
996 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
997 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
998
999 dib0700_ctrl_clock(adap->dev, 72, 1);
1000
1001 msleep(10);
1002 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
1003 msleep(10);
1004 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
1005
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03001006 if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 18,
Devin Heitmueller83c4fdf2009-01-21 01:55:45 -03001007 &dib7070p_dib7000p_config) != 0) {
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03001008 err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n",
Devin Heitmueller83c4fdf2009-01-21 01:55:45 -03001009 __func__);
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03001010 dvb_detach(&state->dib7000p_ops);
Devin Heitmueller83c4fdf2009-01-21 01:55:45 -03001011 return -ENODEV;
1012 }
Patrick Boettcher01373a52007-07-30 12:49:04 -03001013
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03001014 adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap, 0x80,
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03001015 &dib7070p_dib7000p_config);
Michael Krufky77eed212011-09-06 09:31:57 -03001016 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Patrick Boettcher01373a52007-07-30 12:49:04 -03001017}
1018
Olivier Grenie90e12ce2010-09-07 12:50:45 -03001019/* STK7770P */
1020static struct dib7000p_config dib7770p_dib7000p_config = {
1021 .output_mpeg2_in_188_bytes = 1,
1022
1023 .agc_config_count = 1,
1024 .agc = &dib7070_agc_config,
1025 .bw = &dib7070_bw_config_12_mhz,
1026 .tuner_is_baseband = 1,
1027 .spur_protect = 1,
1028
1029 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
1030 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
1031 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
1032
1033 .hostbus_diversity = 1,
1034 .enable_current_mirror = 1,
Olivier Grenie970d14c2010-09-07 12:50:46 -03001035 .disable_sample_and_hold = 0,
Olivier Grenie90e12ce2010-09-07 12:50:45 -03001036};
1037
1038static int stk7770p_frontend_attach(struct dvb_usb_adapter *adap)
1039{
1040 struct usb_device_descriptor *p = &adap->dev->udev->descriptor;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03001041 struct dib0700_adapter_state *state = adap->priv;
1042
1043 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
1044 return -ENODEV;
1045
Olivier Grenie90e12ce2010-09-07 12:50:45 -03001046 if (p->idVendor == cpu_to_le16(USB_VID_PINNACLE) &&
1047 p->idProduct == cpu_to_le16(USB_PID_PINNACLE_PCTV72E))
1048 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
1049 else
1050 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
1051 msleep(10);
1052 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
1053 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
1054 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
1055 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
1056
1057 dib0700_ctrl_clock(adap->dev, 72, 1);
1058
1059 msleep(10);
1060 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
1061 msleep(10);
1062 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
1063
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03001064 if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 18,
Olivier Grenie90e12ce2010-09-07 12:50:45 -03001065 &dib7770p_dib7000p_config) != 0) {
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03001066 err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n",
Olivier Grenie90e12ce2010-09-07 12:50:45 -03001067 __func__);
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03001068 dvb_detach(&state->dib7000p_ops);
Olivier Grenie90e12ce2010-09-07 12:50:45 -03001069 return -ENODEV;
1070 }
1071
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03001072 adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap, 0x80,
Olivier Grenie90e12ce2010-09-07 12:50:45 -03001073 &dib7770p_dib7000p_config);
Michael Krufky77eed212011-09-06 09:31:57 -03001074 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Olivier Grenie90e12ce2010-09-07 12:50:45 -03001075}
1076
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001077/* DIB807x generic */
1078static struct dibx000_agc_config dib807x_agc_config[2] = {
1079 {
1080 BAND_VHF,
1081 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0,
1082 * P_agc_freq_pwm_div=1, P_agc_inv_pwm1=0,
1083 * P_agc_inv_pwm2=0,P_agc_inh_dc_rv_est=0,
1084 * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5,
1085 * P_agc_write=0 */
1086 (0 << 15) | (0 << 14) | (7 << 11) | (0 << 10) | (0 << 9) |
1087 (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) |
1088 (0 << 0), /* setup*/
1089
1090 600, /* inv_gain*/
1091 10, /* time_stabiliz*/
1092
1093 0, /* alpha_level*/
1094 118, /* thlock*/
1095
1096 0, /* wbd_inv*/
1097 3530, /* wbd_ref*/
1098 1, /* wbd_sel*/
1099 5, /* wbd_alpha*/
1100
1101 65535, /* agc1_max*/
1102 0, /* agc1_min*/
1103
1104 65535, /* agc2_max*/
1105 0, /* agc2_min*/
1106
1107 0, /* agc1_pt1*/
1108 40, /* agc1_pt2*/
1109 183, /* agc1_pt3*/
1110 206, /* agc1_slope1*/
1111 255, /* agc1_slope2*/
1112 72, /* agc2_pt1*/
1113 152, /* agc2_pt2*/
1114 88, /* agc2_slope1*/
1115 90, /* agc2_slope2*/
1116
1117 17, /* alpha_mant*/
1118 27, /* alpha_exp*/
1119 23, /* beta_mant*/
1120 51, /* beta_exp*/
1121
1122 0, /* perform_agc_softsplit*/
1123 }, {
1124 BAND_UHF,
1125 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0,
1126 * P_agc_freq_pwm_div=1, P_agc_inv_pwm1=0,
1127 * P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
1128 * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5,
1129 * P_agc_write=0 */
1130 (0 << 15) | (0 << 14) | (1 << 11) | (0 << 10) | (0 << 9) |
1131 (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) |
1132 (0 << 0), /* setup */
1133
1134 600, /* inv_gain*/
1135 10, /* time_stabiliz*/
1136
1137 0, /* alpha_level*/
1138 118, /* thlock*/
1139
1140 0, /* wbd_inv*/
1141 3530, /* wbd_ref*/
1142 1, /* wbd_sel*/
1143 5, /* wbd_alpha*/
1144
1145 65535, /* agc1_max*/
1146 0, /* agc1_min*/
1147
1148 65535, /* agc2_max*/
1149 0, /* agc2_min*/
1150
1151 0, /* agc1_pt1*/
1152 40, /* agc1_pt2*/
1153 183, /* agc1_pt3*/
1154 206, /* agc1_slope1*/
1155 255, /* agc1_slope2*/
1156 72, /* agc2_pt1*/
1157 152, /* agc2_pt2*/
1158 88, /* agc2_slope1*/
1159 90, /* agc2_slope2*/
1160
1161 17, /* alpha_mant*/
1162 27, /* alpha_exp*/
1163 23, /* beta_mant*/
1164 51, /* beta_exp*/
1165
1166 0, /* perform_agc_softsplit*/
1167 }
1168};
1169
1170static struct dibx000_bandwidth_config dib807x_bw_config_12_mhz = {
1171 60000, 15000, /* internal, sampling*/
1172 1, 20, 3, 1, 0, /* pll_cfg: prediv, ratio, range, reset, bypass*/
1173 0, 0, 1, 1, 2, /* misc: refdiv, bypclk_div, IO_CLK_en_core,
1174 ADClkSrc, modulo */
1175 (3 << 14) | (1 << 12) | (599 << 0), /* sad_cfg: refsel, sel, freq_15k*/
1176 (0 << 25) | 0, /* ifreq = 0.000000 MHz*/
1177 18179755, /* timf*/
1178 12000000, /* xtal_hz*/
1179};
1180
1181static struct dib8000_config dib807x_dib8000_config[2] = {
1182 {
1183 .output_mpeg2_in_188_bytes = 1,
1184
1185 .agc_config_count = 2,
1186 .agc = dib807x_agc_config,
1187 .pll = &dib807x_bw_config_12_mhz,
1188 .tuner_is_baseband = 1,
1189
1190 .gpio_dir = DIB8000_GPIO_DEFAULT_DIRECTIONS,
1191 .gpio_val = DIB8000_GPIO_DEFAULT_VALUES,
1192 .gpio_pwm_pos = DIB8000_GPIO_DEFAULT_PWM_POS,
1193
1194 .hostbus_diversity = 1,
1195 .div_cfg = 1,
1196 .agc_control = &dib0070_ctrl_agc_filter,
1197 .output_mode = OUTMODE_MPEG2_FIFO,
1198 .drives = 0x2d98,
1199 }, {
1200 .output_mpeg2_in_188_bytes = 1,
1201
1202 .agc_config_count = 2,
1203 .agc = dib807x_agc_config,
1204 .pll = &dib807x_bw_config_12_mhz,
1205 .tuner_is_baseband = 1,
1206
1207 .gpio_dir = DIB8000_GPIO_DEFAULT_DIRECTIONS,
1208 .gpio_val = DIB8000_GPIO_DEFAULT_VALUES,
1209 .gpio_pwm_pos = DIB8000_GPIO_DEFAULT_PWM_POS,
1210
1211 .hostbus_diversity = 1,
1212 .agc_control = &dib0070_ctrl_agc_filter,
1213 .output_mode = OUTMODE_MPEG2_FIFO,
1214 .drives = 0x2d98,
1215 }
1216};
1217
Olivier Grenie03245a52009-12-04 13:27:57 -03001218static int dib80xx_tuner_reset(struct dvb_frontend *fe, int onoff)
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001219{
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001220 struct dvb_usb_adapter *adap = fe->dvb->priv;
1221 struct dib0700_adapter_state *state = adap->priv;
1222
1223 return state->dib8000_ops.set_gpio(fe, 5, 0, !onoff);
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001224}
1225
Olivier Grenie03245a52009-12-04 13:27:57 -03001226static int dib80xx_tuner_sleep(struct dvb_frontend *fe, int onoff)
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001227{
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001228 struct dvb_usb_adapter *adap = fe->dvb->priv;
1229 struct dib0700_adapter_state *state = adap->priv;
1230
1231 return state->dib8000_ops.set_gpio(fe, 0, 0, onoff);
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001232}
1233
1234static const struct dib0070_wbd_gain_cfg dib8070_wbd_gain_cfg[] = {
1235 { 240, 7},
1236 { 0xffff, 6},
1237};
1238
1239static struct dib0070_config dib807x_dib0070_config[2] = {
1240 {
1241 .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
Olivier Grenie03245a52009-12-04 13:27:57 -03001242 .reset = dib80xx_tuner_reset,
1243 .sleep = dib80xx_tuner_sleep,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001244 .clock_khz = 12000,
1245 .clock_pad_drive = 4,
1246 .vga_filter = 1,
1247 .force_crystal_mode = 1,
1248 .enable_third_order_filter = 1,
1249 .charge_pump = 0,
1250 .wbd_gain = dib8070_wbd_gain_cfg,
1251 .osc_buffer_state = 0,
1252 .freq_offset_khz_uhf = -100,
1253 .freq_offset_khz_vhf = -100,
1254 }, {
1255 .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
Olivier Grenie03245a52009-12-04 13:27:57 -03001256 .reset = dib80xx_tuner_reset,
1257 .sleep = dib80xx_tuner_sleep,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001258 .clock_khz = 12000,
1259 .clock_pad_drive = 2,
1260 .vga_filter = 1,
1261 .force_crystal_mode = 1,
1262 .enable_third_order_filter = 1,
1263 .charge_pump = 0,
1264 .wbd_gain = dib8070_wbd_gain_cfg,
1265 .osc_buffer_state = 0,
1266 .freq_offset_khz_uhf = -25,
1267 .freq_offset_khz_vhf = -25,
1268 }
1269};
1270
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -03001271static int dib807x_set_param_override(struct dvb_frontend *fe)
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001272{
Mauro Carvalho Chehab47b163a2011-12-24 10:18:24 -03001273 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001274 struct dvb_usb_adapter *adap = fe->dvb->priv;
1275 struct dib0700_adapter_state *state = adap->priv;
1276
1277 u16 offset = dib0070_wbd_offset(fe);
Mauro Carvalho Chehab47b163a2011-12-24 10:18:24 -03001278 u8 band = BAND_OF_FREQUENCY(p->frequency/1000);
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001279 switch (band) {
1280 case BAND_VHF:
1281 offset += 750;
1282 break;
1283 case BAND_UHF: /* fall-thru wanted */
1284 default:
1285 offset += 250; break;
1286 }
1287 deb_info("WBD for DiB8000: %d\n", offset);
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001288 state->dib8000_ops.set_wbd_ref(fe, offset);
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001289
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -03001290 return state->set_param_save(fe);
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001291}
1292
1293static int dib807x_tuner_attach(struct dvb_usb_adapter *adap)
1294{
1295 struct dib0700_adapter_state *st = adap->priv;
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001296 struct i2c_adapter *tun_i2c = st->dib8000_ops.get_i2c_master(adap->fe_adap[0].fe,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001297 DIBX000_I2C_INTERFACE_TUNER, 1);
1298
1299 if (adap->id == 0) {
Michael Krufky77eed212011-09-06 09:31:57 -03001300 if (dvb_attach(dib0070_attach, adap->fe_adap[0].fe, tun_i2c,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001301 &dib807x_dib0070_config[0]) == NULL)
1302 return -ENODEV;
1303 } else {
Michael Krufky77eed212011-09-06 09:31:57 -03001304 if (dvb_attach(dib0070_attach, adap->fe_adap[0].fe, tun_i2c,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001305 &dib807x_dib0070_config[1]) == NULL)
1306 return -ENODEV;
1307 }
1308
Michael Krufky77eed212011-09-06 09:31:57 -03001309 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
1310 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib807x_set_param_override;
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001311 return 0;
1312}
1313
Olivier Grenie9c783032009-12-07 07:49:40 -03001314static int stk80xx_pid_filter(struct dvb_usb_adapter *adapter, int index,
1315 u16 pid, int onoff)
Olivier Grenief8731f42009-09-18 04:08:43 -03001316{
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001317 struct dib0700_adapter_state *state = adapter->priv;
1318
1319 return state->dib8000_ops.pid_filter(adapter->fe_adap[0].fe, index, pid, onoff);
Olivier Grenief8731f42009-09-18 04:08:43 -03001320}
1321
Olivier Grenie9c783032009-12-07 07:49:40 -03001322static int stk80xx_pid_filter_ctrl(struct dvb_usb_adapter *adapter,
Olivier Greniebe9bae12011-01-04 05:42:19 -03001323 int onoff)
Olivier Grenief8731f42009-09-18 04:08:43 -03001324{
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001325 struct dib0700_adapter_state *state = adapter->priv;
1326
1327 return state->dib8000_ops.pid_filter_ctrl(adapter->fe_adap[0].fe, onoff);
Olivier Grenief8731f42009-09-18 04:08:43 -03001328}
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001329
1330/* STK807x */
1331static int stk807x_frontend_attach(struct dvb_usb_adapter *adap)
1332{
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001333 struct dib0700_adapter_state *state = adap->priv;
1334
1335 if (!dvb_attach(dib8000_attach, &state->dib8000_ops))
1336 return -ENODEV;
1337
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001338 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
1339 msleep(10);
1340 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
1341 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
1342 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
1343
1344 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
1345
1346 dib0700_ctrl_clock(adap->dev, 72, 1);
1347
1348 msleep(10);
1349 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
1350 msleep(10);
1351 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
1352
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001353 state->dib8000_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 18,
Olivier Grenie0c32dbd2011-08-10 05:17:18 -03001354 0x80, 0);
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001355
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001356 adap->fe_adap[0].fe = state->dib8000_ops.init(&adap->dev->i2c_adap, 0x80,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001357 &dib807x_dib8000_config[0]);
1358
Michael Krufky77eed212011-09-06 09:31:57 -03001359 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001360}
1361
1362/* STK807xPVR */
1363static int stk807xpvr_frontend_attach0(struct dvb_usb_adapter *adap)
1364{
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001365 struct dib0700_adapter_state *state = adap->priv;
1366
1367 if (!dvb_attach(dib8000_attach, &state->dib8000_ops))
1368 return -ENODEV;
1369
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001370 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
1371 msleep(30);
1372 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
1373 msleep(500);
1374 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
1375 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
1376 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
1377
1378 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
1379
1380 dib0700_ctrl_clock(adap->dev, 72, 1);
1381
1382 msleep(10);
1383 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
1384 msleep(10);
1385 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
1386
1387 /* initialize IC 0 */
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001388 state->dib8000_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 0x22, 0x80, 0);
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001389
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001390 adap->fe_adap[0].fe = state->dib8000_ops.init(&adap->dev->i2c_adap, 0x80,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001391 &dib807x_dib8000_config[0]);
1392
Michael Krufky77eed212011-09-06 09:31:57 -03001393 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001394}
1395
1396static int stk807xpvr_frontend_attach1(struct dvb_usb_adapter *adap)
1397{
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001398 struct dib0700_adapter_state *state = adap->priv;
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001399
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001400 if (!dvb_attach(dib8000_attach, &state->dib8000_ops))
1401 return -ENODEV;
1402
1403 /* initialize IC 1 */
1404 state->dib8000_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 0x12, 0x82, 0);
1405
1406 adap->fe_adap[0].fe = state->dib8000_ops.init(&adap->dev->i2c_adap, 0x82,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001407 &dib807x_dib8000_config[1]);
1408
Michael Krufky77eed212011-09-06 09:31:57 -03001409 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001410}
1411
Olivier Grenie03245a52009-12-04 13:27:57 -03001412/* STK8096GP */
Olivier Greniea685dbb2011-08-05 14:10:40 -03001413static struct dibx000_agc_config dib8090_agc_config[2] = {
Olivier Greniebe9bae12011-01-04 05:42:19 -03001414 {
Olivier Grenie03245a52009-12-04 13:27:57 -03001415 BAND_UHF | BAND_VHF | BAND_LBAND | BAND_SBAND,
Olivier Grenie9c783032009-12-07 07:49:40 -03001416 /* 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 -03001417 * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
1418 * 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 -03001419 (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8)
1420 | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),
Olivier Grenie03245a52009-12-04 13:27:57 -03001421
Olivier Grenie9c783032009-12-07 07:49:40 -03001422 787,
1423 10,
Olivier Grenie03245a52009-12-04 13:27:57 -03001424
Olivier Grenie9c783032009-12-07 07:49:40 -03001425 0,
1426 118,
Olivier Grenie03245a52009-12-04 13:27:57 -03001427
Olivier Grenie9c783032009-12-07 07:49:40 -03001428 0,
1429 3530,
1430 1,
1431 5,
Olivier Grenie03245a52009-12-04 13:27:57 -03001432
Olivier Grenie9c783032009-12-07 07:49:40 -03001433 65535,
1434 0,
Olivier Grenie03245a52009-12-04 13:27:57 -03001435
Olivier Grenie9c783032009-12-07 07:49:40 -03001436 65535,
1437 0,
Olivier Grenie03245a52009-12-04 13:27:57 -03001438
Olivier Grenie9c783032009-12-07 07:49:40 -03001439 0,
1440 32,
1441 114,
1442 143,
1443 144,
1444 114,
1445 227,
1446 116,
1447 117,
Olivier Grenie03245a52009-12-04 13:27:57 -03001448
Olivier Grenie9c783032009-12-07 07:49:40 -03001449 28,
1450 26,
1451 31,
1452 51,
Olivier Grenie03245a52009-12-04 13:27:57 -03001453
Olivier Grenie9c783032009-12-07 07:49:40 -03001454 0,
Olivier Greniebe9bae12011-01-04 05:42:19 -03001455 },
1456 {
Olivier Grenie03245a52009-12-04 13:27:57 -03001457 BAND_CBAND,
Olivier Grenie9c783032009-12-07 07:49:40 -03001458 /* 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 -03001459 * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
1460 * 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 -03001461 (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8)
1462 | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),
Olivier Grenie03245a52009-12-04 13:27:57 -03001463
Olivier Grenie9c783032009-12-07 07:49:40 -03001464 787,
1465 10,
Olivier Grenie03245a52009-12-04 13:27:57 -03001466
Olivier Grenie9c783032009-12-07 07:49:40 -03001467 0,
1468 118,
Olivier Grenie03245a52009-12-04 13:27:57 -03001469
Olivier Grenie9c783032009-12-07 07:49:40 -03001470 0,
1471 3530,
1472 1,
1473 5,
Olivier Grenie03245a52009-12-04 13:27:57 -03001474
Olivier Grenie9c783032009-12-07 07:49:40 -03001475 0,
1476 0,
Olivier Grenie03245a52009-12-04 13:27:57 -03001477
Olivier Grenie9c783032009-12-07 07:49:40 -03001478 65535,
1479 0,
Olivier Grenie03245a52009-12-04 13:27:57 -03001480
Olivier Grenie9c783032009-12-07 07:49:40 -03001481 0,
1482 32,
1483 114,
1484 143,
1485 144,
1486 114,
1487 227,
1488 116,
1489 117,
Olivier Grenie03245a52009-12-04 13:27:57 -03001490
Olivier Grenie9c783032009-12-07 07:49:40 -03001491 28,
1492 26,
1493 31,
1494 51,
Olivier Grenie03245a52009-12-04 13:27:57 -03001495
Olivier Grenie9c783032009-12-07 07:49:40 -03001496 0,
Olivier Greniebe9bae12011-01-04 05:42:19 -03001497 }
Olivier Grenie03245a52009-12-04 13:27:57 -03001498};
1499
1500static struct dibx000_bandwidth_config dib8090_pll_config_12mhz = {
Olivier Greniebe9bae12011-01-04 05:42:19 -03001501 54000, 13500,
1502 1, 18, 3, 1, 0,
1503 0, 0, 1, 1, 2,
1504 (3 << 14) | (1 << 12) | (599 << 0),
1505 (0 << 25) | 0,
1506 20199727,
1507 12000000,
Olivier Grenie03245a52009-12-04 13:27:57 -03001508};
1509
1510static int dib8090_get_adc_power(struct dvb_frontend *fe)
1511{
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001512 struct dvb_usb_adapter *adap = fe->dvb->priv;
1513 struct dib0700_adapter_state *state = adap->priv;
1514
1515 return state->dib8000_ops.get_adc_power(fe, 1);
Olivier Grenie03245a52009-12-04 13:27:57 -03001516}
1517
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001518static void dib8090_agc_control(struct dvb_frontend *fe, u8 restart)
1519{
1520 deb_info("AGC control callback: %i\n", restart);
1521 dib0090_dcc_freq(fe, restart);
1522
1523 if (restart == 0) /* before AGC startup */
1524 dib0090_set_dc_servo(fe, 1);
1525}
1526
Olivier Greniebe9bae12011-01-04 05:42:19 -03001527static struct dib8000_config dib809x_dib8000_config[2] = {
1528 {
1529 .output_mpeg2_in_188_bytes = 1,
Olivier Grenie03245a52009-12-04 13:27:57 -03001530
Olivier Greniebe9bae12011-01-04 05:42:19 -03001531 .agc_config_count = 2,
1532 .agc = dib8090_agc_config,
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001533 .agc_control = dib8090_agc_control,
Olivier Greniebe9bae12011-01-04 05:42:19 -03001534 .pll = &dib8090_pll_config_12mhz,
1535 .tuner_is_baseband = 1,
Olivier Grenie03245a52009-12-04 13:27:57 -03001536
Olivier Greniebe9bae12011-01-04 05:42:19 -03001537 .gpio_dir = DIB8000_GPIO_DEFAULT_DIRECTIONS,
1538 .gpio_val = DIB8000_GPIO_DEFAULT_VALUES,
1539 .gpio_pwm_pos = DIB8000_GPIO_DEFAULT_PWM_POS,
Olivier Grenie03245a52009-12-04 13:27:57 -03001540
Olivier Greniebe9bae12011-01-04 05:42:19 -03001541 .hostbus_diversity = 1,
1542 .div_cfg = 0x31,
1543 .output_mode = OUTMODE_MPEG2_FIFO,
1544 .drives = 0x2d98,
1545 .diversity_delay = 48,
1546 .refclksel = 3,
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03001547 }, {
Olivier Greniebe9bae12011-01-04 05:42:19 -03001548 .output_mpeg2_in_188_bytes = 1,
1549
1550 .agc_config_count = 2,
1551 .agc = dib8090_agc_config,
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001552 .agc_control = dib8090_agc_control,
Olivier Greniebe9bae12011-01-04 05:42:19 -03001553 .pll = &dib8090_pll_config_12mhz,
1554 .tuner_is_baseband = 1,
1555
1556 .gpio_dir = DIB8000_GPIO_DEFAULT_DIRECTIONS,
1557 .gpio_val = DIB8000_GPIO_DEFAULT_VALUES,
1558 .gpio_pwm_pos = DIB8000_GPIO_DEFAULT_PWM_POS,
1559
1560 .hostbus_diversity = 1,
1561 .div_cfg = 0x31,
1562 .output_mode = OUTMODE_DIVERSITY,
1563 .drives = 0x2d08,
1564 .diversity_delay = 1,
1565 .refclksel = 3,
1566 }
1567};
1568
1569static struct dib0090_wbd_slope dib8090_wbd_table[] = {
1570 /* max freq ; cold slope ; cold offset ; warm slope ; warm offset ; wbd gain */
1571 { 120, 0, 500, 0, 500, 4 }, /* CBAND */
1572 { 170, 0, 450, 0, 450, 4 }, /* CBAND */
1573 { 380, 48, 373, 28, 259, 6 }, /* VHF */
1574 { 860, 34, 700, 36, 616, 6 }, /* high UHF */
1575 { 0xFFFF, 34, 700, 36, 616, 6 }, /* default */
Olivier Grenie03245a52009-12-04 13:27:57 -03001576};
1577
1578static struct dib0090_config dib809x_dib0090_config = {
Olivier Greniebe9bae12011-01-04 05:42:19 -03001579 .io.pll_bypass = 1,
1580 .io.pll_range = 1,
1581 .io.pll_prediv = 1,
1582 .io.pll_loopdiv = 20,
1583 .io.adc_clock_ratio = 8,
1584 .io.pll_int_loop_filt = 0,
1585 .io.clock_khz = 12000,
1586 .reset = dib80xx_tuner_reset,
1587 .sleep = dib80xx_tuner_sleep,
1588 .clkouttobamse = 1,
1589 .analog_output = 1,
1590 .i2c_address = DEFAULT_DIB0090_I2C_ADDRESS,
1591 .use_pwm_agc = 1,
1592 .clkoutdrive = 1,
1593 .get_adc_power = dib8090_get_adc_power,
1594 .freq_offset_khz_uhf = -63,
Olivier Grenie03245a52009-12-04 13:27:57 -03001595 .freq_offset_khz_vhf = -143,
Olivier Greniebe9bae12011-01-04 05:42:19 -03001596 .wbd = dib8090_wbd_table,
1597 .fref_clock_ratio = 6,
Olivier Grenie03245a52009-12-04 13:27:57 -03001598};
1599
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001600static u8 dib8090_compute_pll_parameters(struct dvb_frontend *fe)
1601{
1602 u8 optimal_pll_ratio = 20;
1603 u32 freq_adc, ratio, rest, max = 0;
1604 u8 pll_ratio;
1605
1606 for (pll_ratio = 17; pll_ratio <= 20; pll_ratio++) {
1607 freq_adc = 12 * pll_ratio * (1 << 8) / 16;
1608 ratio = ((fe->dtv_property_cache.frequency / 1000) * (1 << 8) / 1000) / freq_adc;
1609 rest = ((fe->dtv_property_cache.frequency / 1000) * (1 << 8) / 1000) - ratio * freq_adc;
1610
1611 if (rest > freq_adc / 2)
1612 rest = freq_adc - rest;
1613 deb_info("PLL ratio=%i rest=%i\n", pll_ratio, rest);
1614 if ((rest > max) && (rest > 717)) {
1615 optimal_pll_ratio = pll_ratio;
1616 max = rest;
1617 }
1618 }
1619 deb_info("optimal PLL ratio=%i\n", optimal_pll_ratio);
1620
1621 return optimal_pll_ratio;
1622}
1623
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -03001624static int dib8096_set_param_override(struct dvb_frontend *fe)
Olivier Grenie03245a52009-12-04 13:27:57 -03001625{
Olivier Greniebe9bae12011-01-04 05:42:19 -03001626 struct dvb_usb_adapter *adap = fe->dvb->priv;
1627 struct dib0700_adapter_state *state = adap->priv;
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001628 u8 pll_ratio, band = BAND_OF_FREQUENCY(fe->dtv_property_cache.frequency / 1000);
1629 u16 target, ltgain, rf_gain_limit;
1630 u32 timf;
Olivier Greniebe9bae12011-01-04 05:42:19 -03001631 int ret = 0;
1632 enum frontend_tune_state tune_state = CT_SHUTDOWN;
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001633
1634 switch (band) {
1635 default:
1636 deb_info("Warning : Rf frequency (%iHz) is not in the supported range, using VHF switch ", fe->dtv_property_cache.frequency);
1637 case BAND_VHF:
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001638 state->dib8000_ops.set_gpio(fe, 3, 0, 1);
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001639 break;
1640 case BAND_UHF:
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001641 state->dib8000_ops.set_gpio(fe, 3, 0, 0);
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001642 break;
1643 }
Olivier Grenie03245a52009-12-04 13:27:57 -03001644
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -03001645 ret = state->set_param_save(fe);
Olivier Greniebe9bae12011-01-04 05:42:19 -03001646 if (ret < 0)
1647 return ret;
Olivier Grenie03245a52009-12-04 13:27:57 -03001648
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001649 if (fe->dtv_property_cache.bandwidth_hz != 6000000) {
1650 deb_info("only 6MHz bandwidth is supported\n");
1651 return -EINVAL;
1652 }
Olivier Grenie03245a52009-12-04 13:27:57 -03001653
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001654 /** Update PLL if needed ratio **/
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001655 state->dib8000_ops.update_pll(fe, &dib8090_pll_config_12mhz, fe->dtv_property_cache.bandwidth_hz / 1000, 0);
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001656
1657 /** Get optimize PLL ratio to remove spurious **/
1658 pll_ratio = dib8090_compute_pll_parameters(fe);
1659 if (pll_ratio == 17)
1660 timf = 21387946;
1661 else if (pll_ratio == 18)
1662 timf = 20199727;
1663 else if (pll_ratio == 19)
1664 timf = 19136583;
1665 else
1666 timf = 18179756;
1667
1668 /** Update ratio **/
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001669 state->dib8000_ops.update_pll(fe, &dib8090_pll_config_12mhz, fe->dtv_property_cache.bandwidth_hz / 1000, pll_ratio);
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001670
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001671 state->dib8000_ops.ctrl_timf(fe, DEMOD_TIMF_SET, timf);
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001672
1673 if (band != BAND_CBAND) {
1674 /* dib0090_get_wbd_target is returning any possible temperature compensated wbd-target */
1675 target = (dib0090_get_wbd_target(fe) * 8 * 18 / 33 + 1) / 2;
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001676 state->dib8000_ops.set_wbd_ref(fe, target);
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001677 }
Olivier Grenie03245a52009-12-04 13:27:57 -03001678
Olivier Greniebe9bae12011-01-04 05:42:19 -03001679 if (band == BAND_CBAND) {
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03001680 deb_info("tuning in CBAND - soft-AGC startup\n");
1681 dib0090_set_tune_state(fe, CT_AGC_START);
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001682
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03001683 do {
1684 ret = dib0090_gain_control(fe);
1685 msleep(ret);
1686 tune_state = dib0090_get_tune_state(fe);
1687 if (tune_state == CT_AGC_STEP_0)
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001688 state->dib8000_ops.set_gpio(fe, 6, 0, 1);
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03001689 else if (tune_state == CT_AGC_STEP_1) {
1690 dib0090_get_current_gain(fe, NULL, NULL, &rf_gain_limit, &ltgain);
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001691 if (rf_gain_limit < 2000) /* activate the external attenuator in case of very high input power */
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001692 state->dib8000_ops.set_gpio(fe, 6, 0, 0);
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03001693 }
1694 } while (tune_state < CT_AGC_STOP);
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001695
1696 deb_info("switching to PWM AGC\n");
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03001697 dib0090_pwm_gain_reset(fe);
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001698 state->dib8000_ops.pwm_agc_reset(fe);
1699 state->dib8000_ops.set_tune_state(fe, CT_DEMOD_START);
Olivier Greniebe9bae12011-01-04 05:42:19 -03001700 } else {
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001701 /* for everything else than CBAND we are using standard AGC */
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03001702 deb_info("not tuning in CBAND - standard AGC startup\n");
1703 dib0090_pwm_gain_reset(fe);
Olivier Greniebe9bae12011-01-04 05:42:19 -03001704 }
Olivier Grenie03245a52009-12-04 13:27:57 -03001705
Olivier Greniebe9bae12011-01-04 05:42:19 -03001706 return 0;
Olivier Grenie03245a52009-12-04 13:27:57 -03001707}
1708
1709static int dib809x_tuner_attach(struct dvb_usb_adapter *adap)
1710{
Olivier Greniebe9bae12011-01-04 05:42:19 -03001711 struct dib0700_adapter_state *st = adap->priv;
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001712 struct i2c_adapter *tun_i2c = st->dib8000_ops.get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_TUNER, 1);
Olivier Grenie03245a52009-12-04 13:27:57 -03001713
Michael Krufky77eed212011-09-06 09:31:57 -03001714 if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c, &dib809x_dib0090_config) == NULL)
Olivier Greniebe9bae12011-01-04 05:42:19 -03001715 return -ENODEV;
Olivier Grenie03245a52009-12-04 13:27:57 -03001716
Michael Krufky77eed212011-09-06 09:31:57 -03001717 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
1718 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib8096_set_param_override;
Olivier Greniebe9bae12011-01-04 05:42:19 -03001719 return 0;
Olivier Grenie03245a52009-12-04 13:27:57 -03001720}
1721
1722static int stk809x_frontend_attach(struct dvb_usb_adapter *adap)
1723{
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001724 struct dib0700_adapter_state *state = adap->priv;
1725
1726 if (!dvb_attach(dib8000_attach, &state->dib8000_ops))
1727 return -ENODEV;
1728
Olivier Grenie03245a52009-12-04 13:27:57 -03001729 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
1730 msleep(10);
1731 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
1732 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
1733 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
1734
1735 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
1736
1737 dib0700_ctrl_clock(adap->dev, 72, 1);
1738
1739 msleep(10);
1740 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
1741 msleep(10);
1742 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
1743
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001744 state->dib8000_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 18, 0x80, 0);
Olivier Grenie03245a52009-12-04 13:27:57 -03001745
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001746 adap->fe_adap[0].fe = state->dib8000_ops.init(&adap->dev->i2c_adap, 0x80, &dib809x_dib8000_config[0]);
Olivier Grenie03245a52009-12-04 13:27:57 -03001747
Michael Krufky77eed212011-09-06 09:31:57 -03001748 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Olivier Grenie03245a52009-12-04 13:27:57 -03001749}
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03001750
Olivier Greniebe9bae12011-01-04 05:42:19 -03001751static int nim8096md_tuner_attach(struct dvb_usb_adapter *adap)
1752{
1753 struct dib0700_adapter_state *st = adap->priv;
1754 struct i2c_adapter *tun_i2c;
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001755 struct dvb_frontend *fe_slave = st->dib8000_ops.get_slave_frontend(adap->fe_adap[0].fe, 1);
Olivier Greniebe9bae12011-01-04 05:42:19 -03001756
1757 if (fe_slave) {
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001758 tun_i2c = st->dib8000_ops.get_i2c_master(fe_slave, DIBX000_I2C_INTERFACE_TUNER, 1);
Olivier Greniebe9bae12011-01-04 05:42:19 -03001759 if (dvb_attach(dib0090_register, fe_slave, tun_i2c, &dib809x_dib0090_config) == NULL)
1760 return -ENODEV;
Michael Krufky77eed212011-09-06 09:31:57 -03001761 fe_slave->dvb = adap->fe_adap[0].fe->dvb;
Olivier Greniebe9bae12011-01-04 05:42:19 -03001762 fe_slave->ops.tuner_ops.set_params = dib8096_set_param_override;
1763 }
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001764 tun_i2c = st->dib8000_ops.get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_TUNER, 1);
Michael Krufky77eed212011-09-06 09:31:57 -03001765 if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c, &dib809x_dib0090_config) == NULL)
Olivier Greniebe9bae12011-01-04 05:42:19 -03001766 return -ENODEV;
1767
Michael Krufky77eed212011-09-06 09:31:57 -03001768 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
1769 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib8096_set_param_override;
Olivier Greniebe9bae12011-01-04 05:42:19 -03001770
1771 return 0;
1772}
1773
1774static int nim8096md_frontend_attach(struct dvb_usb_adapter *adap)
1775{
1776 struct dvb_frontend *fe_slave;
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001777 struct dib0700_adapter_state *state = adap->priv;
1778
1779 if (!dvb_attach(dib8000_attach, &state->dib8000_ops))
1780 return -ENODEV;
Olivier Greniebe9bae12011-01-04 05:42:19 -03001781
1782 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03001783 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03001784 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
1785 msleep(1000);
1786 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
1787 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
1788 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
1789
1790 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
1791
1792 dib0700_ctrl_clock(adap->dev, 72, 1);
1793
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03001794 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03001795 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03001796 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03001797 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
1798
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001799 state->dib8000_ops.i2c_enumeration(&adap->dev->i2c_adap, 2, 18, 0x80, 0);
Olivier Greniebe9bae12011-01-04 05:42:19 -03001800
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001801 adap->fe_adap[0].fe = state->dib8000_ops.init(&adap->dev->i2c_adap, 0x80, &dib809x_dib8000_config[0]);
Michael Krufky77eed212011-09-06 09:31:57 -03001802 if (adap->fe_adap[0].fe == NULL)
Olivier Greniebe9bae12011-01-04 05:42:19 -03001803 return -ENODEV;
1804
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001805 /* Needed to increment refcount */
1806 if (!dvb_attach(dib8000_attach, &state->dib8000_ops))
1807 return -ENODEV;
1808
1809 fe_slave = state->dib8000_ops.init(&adap->dev->i2c_adap, 0x82, &dib809x_dib8000_config[1]);
1810 state->dib8000_ops.set_slave_frontend(adap->fe_adap[0].fe, fe_slave);
Olivier Greniebe9bae12011-01-04 05:42:19 -03001811
1812 return fe_slave == NULL ? -ENODEV : 0;
1813}
1814
Olivier Grenie88f3a352011-08-10 05:28:38 -03001815/* TFE8096P */
1816static struct dibx000_agc_config dib8096p_agc_config[2] = {
1817 {
1818 .band_caps = BAND_UHF,
1819 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0,
1820 P_agc_freq_pwm_div=1, P_agc_inv_pwm1=0,
1821 P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
1822 P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5,
1823 P_agc_write=0 */
1824 .setup = (0 << 15) | (0 << 14) | (5 << 11)
1825 | (0 << 10) | (0 << 9) | (0 << 8) | (3 << 5)
1826 | (0 << 4) | (5 << 1) | (0 << 0),
1827
1828 .inv_gain = 684,
1829 .time_stabiliz = 10,
1830
1831 .alpha_level = 0,
1832 .thlock = 118,
1833
1834 .wbd_inv = 0,
1835 .wbd_ref = 1200,
1836 .wbd_sel = 3,
1837 .wbd_alpha = 5,
1838
1839 .agc1_max = 65535,
1840 .agc1_min = 0,
1841
1842 .agc2_max = 32767,
1843 .agc2_min = 0,
1844
1845 .agc1_pt1 = 0,
1846 .agc1_pt2 = 0,
1847 .agc1_pt3 = 105,
1848 .agc1_slope1 = 0,
1849 .agc1_slope2 = 156,
1850 .agc2_pt1 = 105,
1851 .agc2_pt2 = 255,
1852 .agc2_slope1 = 54,
1853 .agc2_slope2 = 0,
1854
1855 .alpha_mant = 28,
1856 .alpha_exp = 26,
1857 .beta_mant = 31,
1858 .beta_exp = 51,
1859
1860 .perform_agc_softsplit = 0,
1861 } , {
1862 .band_caps = BAND_FM | BAND_VHF | BAND_CBAND,
1863 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0,
1864 P_agc_freq_pwm_div=1, P_agc_inv_pwm1=0,
1865 P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
1866 P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5,
1867 P_agc_write=0 */
1868 .setup = (0 << 15) | (0 << 14) | (5 << 11)
1869 | (0 << 10) | (0 << 9) | (0 << 8) | (3 << 5)
1870 | (0 << 4) | (5 << 1) | (0 << 0),
1871
1872 .inv_gain = 732,
1873 .time_stabiliz = 10,
1874
1875 .alpha_level = 0,
1876 .thlock = 118,
1877
1878 .wbd_inv = 0,
1879 .wbd_ref = 1200,
1880 .wbd_sel = 3,
1881 .wbd_alpha = 5,
1882
1883 .agc1_max = 65535,
1884 .agc1_min = 0,
1885
1886 .agc2_max = 32767,
1887 .agc2_min = 0,
1888
1889 .agc1_pt1 = 0,
1890 .agc1_pt2 = 0,
1891 .agc1_pt3 = 98,
1892 .agc1_slope1 = 0,
1893 .agc1_slope2 = 167,
1894 .agc2_pt1 = 98,
1895 .agc2_pt2 = 255,
1896 .agc2_slope1 = 52,
1897 .agc2_slope2 = 0,
1898
1899 .alpha_mant = 28,
1900 .alpha_exp = 26,
1901 .beta_mant = 31,
1902 .beta_exp = 51,
1903
1904 .perform_agc_softsplit = 0,
1905 }
1906};
1907
1908static struct dibx000_bandwidth_config dib8096p_clock_config_12_mhz = {
1909 108000, 13500,
1910 1, 9, 1, 0, 0,
1911 0, 0, 0, 0, 2,
1912 (3 << 14) | (1 << 12) | (524 << 0),
1913 (0 << 25) | 0,
1914 20199729,
1915 12000000,
1916};
1917
1918static struct dib8000_config tfe8096p_dib8000_config = {
1919 .output_mpeg2_in_188_bytes = 1,
1920 .hostbus_diversity = 1,
1921 .update_lna = NULL,
1922
1923 .agc_config_count = 2,
1924 .agc = dib8096p_agc_config,
1925 .pll = &dib8096p_clock_config_12_mhz,
1926
1927 .gpio_dir = DIB8000_GPIO_DEFAULT_DIRECTIONS,
1928 .gpio_val = DIB8000_GPIO_DEFAULT_VALUES,
1929 .gpio_pwm_pos = DIB8000_GPIO_DEFAULT_PWM_POS,
1930
1931 .agc_control = NULL,
1932 .diversity_delay = 48,
1933 .output_mode = OUTMODE_MPEG2_FIFO,
1934 .enMpegOutput = 1,
1935};
1936
1937static struct dib0090_wbd_slope dib8096p_wbd_table[] = {
1938 { 380, 81, 850, 64, 540, 4},
1939 { 860, 51, 866, 21, 375, 4},
1940 {1700, 0, 250, 0, 100, 6},
1941 {2600, 0, 250, 0, 100, 6},
1942 { 0xFFFF, 0, 0, 0, 0, 0},
1943};
1944
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03001945static struct dib0090_config tfe8096p_dib0090_config = {
Olivier Grenie88f3a352011-08-10 05:28:38 -03001946 .io.clock_khz = 12000,
1947 .io.pll_bypass = 0,
1948 .io.pll_range = 0,
1949 .io.pll_prediv = 3,
1950 .io.pll_loopdiv = 6,
1951 .io.adc_clock_ratio = 0,
1952 .io.pll_int_loop_filt = 0,
Olivier Grenie88f3a352011-08-10 05:28:38 -03001953
1954 .freq_offset_khz_uhf = -143,
1955 .freq_offset_khz_vhf = -143,
1956
1957 .get_adc_power = dib8090_get_adc_power,
1958
1959 .clkouttobamse = 1,
1960 .analog_output = 0,
1961
1962 .wbd_vhf_offset = 0,
1963 .wbd_cband_offset = 0,
1964 .use_pwm_agc = 1,
1965 .clkoutdrive = 0,
1966
1967 .fref_clock_ratio = 1,
1968
Olivier Grenie88f3a352011-08-10 05:28:38 -03001969 .ls_cfg_pad_drv = 0,
1970 .data_tx_drv = 0,
1971 .low_if = NULL,
1972 .in_soc = 1,
1973 .force_cband_input = 0,
1974};
1975
1976struct dibx090p_adc {
1977 u32 freq; /* RF freq MHz */
1978 u32 timf; /* New Timf */
1979 u32 pll_loopdiv; /* New prediv */
1980 u32 pll_prediv; /* New loopdiv */
1981};
1982
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001983struct dibx090p_best_adc {
1984 u32 timf;
1985 u32 pll_loopdiv;
1986 u32 pll_prediv;
Olivier Grenie88f3a352011-08-10 05:28:38 -03001987};
1988
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03001989static int dib8096p_get_best_sampling(struct dvb_frontend *fe, struct dibx090p_best_adc *adc)
1990{
1991 u8 spur = 0, prediv = 0, loopdiv = 0, min_prediv = 1, max_prediv = 1;
1992 u16 xtal = 12000;
1993 u16 fcp_min = 1900; /* PLL, Minimum Frequency of phase comparator (KHz) */
1994 u16 fcp_max = 20000; /* PLL, Maximum Frequency of phase comparator (KHz) */
1995 u32 fmem_max = 140000; /* 140MHz max SDRAM freq */
1996 u32 fdem_min = 66000;
1997 u32 fcp = 0, fs = 0, fdem = 0, fmem = 0;
1998 u32 harmonic_id = 0;
1999
2000 adc->timf = 0;
2001 adc->pll_loopdiv = loopdiv;
2002 adc->pll_prediv = prediv;
2003
2004 deb_info("bandwidth = %d", fe->dtv_property_cache.bandwidth_hz);
2005
2006 /* Find Min and Max prediv */
2007 while ((xtal / max_prediv) >= fcp_min)
2008 max_prediv++;
2009
2010 max_prediv--;
2011 min_prediv = max_prediv;
2012 while ((xtal / min_prediv) <= fcp_max) {
2013 min_prediv--;
2014 if (min_prediv == 1)
2015 break;
2016 }
2017 deb_info("MIN prediv = %d : MAX prediv = %d", min_prediv, max_prediv);
2018
2019 min_prediv = 1;
2020
2021 for (prediv = min_prediv; prediv < max_prediv; prediv++) {
2022 fcp = xtal / prediv;
2023 if (fcp > fcp_min && fcp < fcp_max) {
2024 for (loopdiv = 1; loopdiv < 64; loopdiv++) {
2025 fmem = ((xtal/prediv) * loopdiv);
2026 fdem = fmem / 2;
2027 fs = fdem / 4;
2028
2029 /* test min/max system restrictions */
2030 if ((fdem >= fdem_min) && (fmem <= fmem_max) && (fs >= fe->dtv_property_cache.bandwidth_hz / 1000)) {
2031 spur = 0;
2032 /* test fs harmonics positions */
2033 for (harmonic_id = (fe->dtv_property_cache.frequency / (1000 * fs)); harmonic_id <= ((fe->dtv_property_cache.frequency / (1000 * fs)) + 1); harmonic_id++) {
2034 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)))) {
2035 spur = 1;
2036 break;
2037 }
2038 }
2039
2040 if (!spur) {
2041 adc->pll_loopdiv = loopdiv;
2042 adc->pll_prediv = prediv;
2043 adc->timf = (4260880253U / fdem) * (1 << 8);
2044 adc->timf += ((4260880253U % fdem) << 8) / fdem;
2045
2046 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);
2047 break;
2048 }
2049 }
2050 }
2051 }
2052 if (!spur)
2053 break;
2054 }
2055
2056 if (adc->pll_loopdiv == 0 && adc->pll_prediv == 0)
2057 return -EINVAL;
2058 return 0;
2059}
2060
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -03002061static int dib8096p_agc_startup(struct dvb_frontend *fe)
Olivier Grenie88f3a352011-08-10 05:28:38 -03002062{
2063 struct dvb_usb_adapter *adap = fe->dvb->priv;
2064 struct dib0700_adapter_state *state = adap->priv;
2065 struct dibx000_bandwidth_config pll;
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03002066 struct dibx090p_best_adc adc;
Olivier Grenie88f3a352011-08-10 05:28:38 -03002067 u16 target;
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03002068 int ret;
Olivier Grenie88f3a352011-08-10 05:28:38 -03002069
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -03002070 ret = state->set_param_save(fe);
Olivier Grenie88f3a352011-08-10 05:28:38 -03002071 if (ret < 0)
2072 return ret;
2073 memset(&pll, 0, sizeof(struct dibx000_bandwidth_config));
2074
2075 dib0090_pwm_gain_reset(fe);
2076 /* dib0090_get_wbd_target is returning any possible
2077 temperature compensated wbd-target */
2078 target = (dib0090_get_wbd_target(fe) * 8 + 1) / 2;
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03002079 state->dib8000_ops.set_wbd_ref(fe, target);
Olivier Grenie88f3a352011-08-10 05:28:38 -03002080
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03002081 if (dib8096p_get_best_sampling(fe, &adc) == 0) {
2082 pll.pll_ratio = adc.pll_loopdiv;
2083 pll.pll_prediv = adc.pll_prediv;
Olivier Grenie88f3a352011-08-10 05:28:38 -03002084
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03002085 dib0700_set_i2c_speed(adap->dev, 200);
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03002086 state->dib8000_ops.update_pll(fe, &pll, fe->dtv_property_cache.bandwidth_hz / 1000, 0);
2087 state->dib8000_ops.ctrl_timf(fe, DEMOD_TIMF_SET, adc.timf);
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03002088 dib0700_set_i2c_speed(adap->dev, 1000);
Olivier Grenie88f3a352011-08-10 05:28:38 -03002089 }
2090 return 0;
2091}
2092
2093static int tfe8096p_frontend_attach(struct dvb_usb_adapter *adap)
2094{
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03002095 struct dib0700_state *st = adap->dev->priv;
2096 u32 fw_version;
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03002097 struct dib0700_adapter_state *state = adap->priv;
2098
2099 if (!dvb_attach(dib8000_attach, &state->dib8000_ops))
2100 return -ENODEV;
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03002101
2102 dib0700_get_version(adap->dev, NULL, NULL, &fw_version, NULL);
2103 if (fw_version >= 0x10200)
2104 st->fw_use_new_i2c_api = 1;
2105
Olivier Grenie88f3a352011-08-10 05:28:38 -03002106 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
2107 msleep(20);
2108 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
2109 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
2110 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
2111
2112 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
2113
2114 dib0700_ctrl_clock(adap->dev, 72, 1);
2115
2116 msleep(20);
2117 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
2118 msleep(20);
2119 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
2120
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03002121 state->dib8000_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 0x10, 0x80, 1);
Olivier Grenie88f3a352011-08-10 05:28:38 -03002122
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03002123 adap->fe_adap[0].fe = state->dib8000_ops.init(&adap->dev->i2c_adap,
2124 0x80, &tfe8096p_dib8000_config);
Olivier Grenie88f3a352011-08-10 05:28:38 -03002125
2126 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
2127}
2128
2129static int tfe8096p_tuner_attach(struct dvb_usb_adapter *adap)
2130{
2131 struct dib0700_adapter_state *st = adap->priv;
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03002132 struct i2c_adapter *tun_i2c = st->dib8000_ops.get_i2c_tuner(adap->fe_adap[0].fe);
2133
2134 tfe8096p_dib0090_config.reset = st->dib8000_ops.tuner_sleep;
2135 tfe8096p_dib0090_config.sleep = st->dib8000_ops.tuner_sleep;
2136 tfe8096p_dib0090_config.wbd = dib8096p_wbd_table;
Olivier Grenie88f3a352011-08-10 05:28:38 -03002137
2138 if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c,
2139 &tfe8096p_dib0090_config) == NULL)
2140 return -ENODEV;
2141
Mauro Carvalho Chehabd44913c2014-05-29 09:20:17 -03002142 st->dib8000_ops.set_gpio(adap->fe_adap[0].fe, 8, 0, 1);
Olivier Grenie88f3a352011-08-10 05:28:38 -03002143
2144 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
2145 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib8096p_agc_startup;
2146 return 0;
2147}
2148
Olivier Greniebe9bae12011-01-04 05:42:19 -03002149/* STK9090M */
2150static int dib90x0_pid_filter(struct dvb_usb_adapter *adapter, int index, u16 pid, int onoff)
2151{
Michael Krufky77eed212011-09-06 09:31:57 -03002152 return dib9000_fw_pid_filter(adapter->fe_adap[0].fe, index, pid, onoff);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002153}
2154
2155static int dib90x0_pid_filter_ctrl(struct dvb_usb_adapter *adapter, int onoff)
2156{
Michael Krufky77eed212011-09-06 09:31:57 -03002157 return dib9000_fw_pid_filter_ctrl(adapter->fe_adap[0].fe, onoff);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002158}
2159
2160static int dib90x0_tuner_reset(struct dvb_frontend *fe, int onoff)
2161{
2162 return dib9000_set_gpio(fe, 5, 0, !onoff);
2163}
2164
2165static int dib90x0_tuner_sleep(struct dvb_frontend *fe, int onoff)
2166{
2167 return dib9000_set_gpio(fe, 0, 0, onoff);
2168}
2169
2170static int dib01x0_pmu_update(struct i2c_adapter *i2c, u16 *data, u8 len)
2171{
2172 u8 wb[4] = { 0xc >> 8, 0xc & 0xff, 0, 0 };
2173 u8 rb[2];
2174 struct i2c_msg msg[2] = {
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002175 {.addr = 0x1e >> 1, .flags = 0, .buf = wb, .len = 2},
2176 {.addr = 0x1e >> 1, .flags = I2C_M_RD, .buf = rb, .len = 2},
Olivier Greniebe9bae12011-01-04 05:42:19 -03002177 };
2178 u8 index_data;
2179
2180 dibx000_i2c_set_speed(i2c, 250);
2181
2182 if (i2c_transfer(i2c, msg, 2) != 2)
2183 return -EIO;
2184
2185 switch (rb[0] << 8 | rb[1]) {
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002186 case 0:
Olivier Greniebe9bae12011-01-04 05:42:19 -03002187 deb_info("Found DiB0170 rev1: This version of DiB0170 is not supported any longer.\n");
2188 return -EIO;
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002189 case 1:
Olivier Greniebe9bae12011-01-04 05:42:19 -03002190 deb_info("Found DiB0170 rev2");
2191 break;
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002192 case 2:
Olivier Greniebe9bae12011-01-04 05:42:19 -03002193 deb_info("Found DiB0190 rev2");
2194 break;
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002195 default:
Olivier Greniebe9bae12011-01-04 05:42:19 -03002196 deb_info("DiB01x0 not found");
2197 return -EIO;
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002198 }
Olivier Greniebe9bae12011-01-04 05:42:19 -03002199
2200 for (index_data = 0; index_data < len; index_data += 2) {
2201 wb[2] = (data[index_data + 1] >> 8) & 0xff;
2202 wb[3] = (data[index_data + 1]) & 0xff;
2203
2204 if (data[index_data] == 0) {
2205 wb[0] = (data[index_data] >> 8) & 0xff;
2206 wb[1] = (data[index_data]) & 0xff;
2207 msg[0].len = 2;
2208 if (i2c_transfer(i2c, msg, 2) != 2)
2209 return -EIO;
2210 wb[2] |= rb[0];
2211 wb[3] |= rb[1] & ~(3 << 4);
2212 }
2213
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002214 wb[0] = (data[index_data] >> 8)&0xff;
2215 wb[1] = (data[index_data])&0xff;
Olivier Greniebe9bae12011-01-04 05:42:19 -03002216 msg[0].len = 4;
2217 if (i2c_transfer(i2c, &msg[0], 1) != 1)
2218 return -EIO;
2219 }
2220 return 0;
2221}
2222
2223static struct dib9000_config stk9090m_config = {
2224 .output_mpeg2_in_188_bytes = 1,
2225 .output_mode = OUTMODE_MPEG2_FIFO,
2226 .vcxo_timer = 279620,
2227 .timing_frequency = 20452225,
2228 .demod_clock_khz = 60000,
2229 .xtal_clock_khz = 30000,
2230 .if_drives = (0 << 15) | (1 << 13) | (0 << 12) | (3 << 10) | (0 << 9) | (1 << 7) | (0 << 6) | (0 << 4) | (1 << 3) | (1 << 1) | (0),
2231 .subband = {
2232 2,
2233 {
2234 { 240, { BOARD_GPIO_COMPONENT_DEMOD, BOARD_GPIO_FUNCTION_SUBBAND_GPIO, 0x0008, 0x0000, 0x0008 } }, /* GPIO 3 to 1 for VHF */
2235 { 890, { BOARD_GPIO_COMPONENT_DEMOD, BOARD_GPIO_FUNCTION_SUBBAND_GPIO, 0x0008, 0x0000, 0x0000 } }, /* GPIO 3 to 0 for UHF */
2236 { 0 },
2237 },
2238 },
2239 .gpio_function = {
2240 { .component = BOARD_GPIO_COMPONENT_DEMOD, .function = BOARD_GPIO_FUNCTION_COMPONENT_ON, .mask = 0x10 | 0x21, .direction = 0 & ~0x21, .value = (0x10 & ~0x1) | 0x20 },
2241 { .component = BOARD_GPIO_COMPONENT_DEMOD, .function = BOARD_GPIO_FUNCTION_COMPONENT_OFF, .mask = 0x10 | 0x21, .direction = 0 & ~0x21, .value = 0 | 0x21 },
2242 },
2243};
2244
2245static struct dib9000_config nim9090md_config[2] = {
2246 {
2247 .output_mpeg2_in_188_bytes = 1,
2248 .output_mode = OUTMODE_MPEG2_FIFO,
2249 .vcxo_timer = 279620,
2250 .timing_frequency = 20452225,
2251 .demod_clock_khz = 60000,
2252 .xtal_clock_khz = 30000,
2253 .if_drives = (0 << 15) | (1 << 13) | (0 << 12) | (3 << 10) | (0 << 9) | (1 << 7) | (0 << 6) | (0 << 4) | (1 << 3) | (1 << 1) | (0),
2254 }, {
2255 .output_mpeg2_in_188_bytes = 1,
2256 .output_mode = OUTMODE_DIVERSITY,
2257 .vcxo_timer = 279620,
2258 .timing_frequency = 20452225,
2259 .demod_clock_khz = 60000,
2260 .xtal_clock_khz = 30000,
2261 .if_drives = (0 << 15) | (1 << 13) | (0 << 12) | (3 << 10) | (0 << 9) | (1 << 7) | (0 << 6) | (0 << 4) | (1 << 3) | (1 << 1) | (0),
2262 .subband = {
2263 2,
2264 {
2265 { 240, { BOARD_GPIO_COMPONENT_DEMOD, BOARD_GPIO_FUNCTION_SUBBAND_GPIO, 0x0006, 0x0000, 0x0006 } }, /* GPIO 1 and 2 to 1 for VHF */
2266 { 890, { BOARD_GPIO_COMPONENT_DEMOD, BOARD_GPIO_FUNCTION_SUBBAND_GPIO, 0x0006, 0x0000, 0x0000 } }, /* GPIO 1 and 2 to 0 for UHF */
2267 { 0 },
2268 },
2269 },
2270 .gpio_function = {
2271 { .component = BOARD_GPIO_COMPONENT_DEMOD, .function = BOARD_GPIO_FUNCTION_COMPONENT_ON, .mask = 0x10 | 0x21, .direction = 0 & ~0x21, .value = (0x10 & ~0x1) | 0x20 },
2272 { .component = BOARD_GPIO_COMPONENT_DEMOD, .function = BOARD_GPIO_FUNCTION_COMPONENT_OFF, .mask = 0x10 | 0x21, .direction = 0 & ~0x21, .value = 0 | 0x21 },
2273 },
2274 }
2275};
2276
2277static struct dib0090_config dib9090_dib0090_config = {
2278 .io.pll_bypass = 0,
2279 .io.pll_range = 1,
2280 .io.pll_prediv = 1,
2281 .io.pll_loopdiv = 8,
2282 .io.adc_clock_ratio = 8,
2283 .io.pll_int_loop_filt = 0,
2284 .io.clock_khz = 30000,
2285 .reset = dib90x0_tuner_reset,
2286 .sleep = dib90x0_tuner_sleep,
2287 .clkouttobamse = 0,
2288 .analog_output = 0,
2289 .use_pwm_agc = 0,
2290 .clkoutdrive = 0,
2291 .freq_offset_khz_uhf = 0,
2292 .freq_offset_khz_vhf = 0,
2293};
2294
2295static struct dib0090_config nim9090md_dib0090_config[2] = {
2296 {
2297 .io.pll_bypass = 0,
2298 .io.pll_range = 1,
2299 .io.pll_prediv = 1,
2300 .io.pll_loopdiv = 8,
2301 .io.adc_clock_ratio = 8,
2302 .io.pll_int_loop_filt = 0,
2303 .io.clock_khz = 30000,
2304 .reset = dib90x0_tuner_reset,
2305 .sleep = dib90x0_tuner_sleep,
2306 .clkouttobamse = 1,
2307 .analog_output = 0,
2308 .use_pwm_agc = 0,
2309 .clkoutdrive = 0,
2310 .freq_offset_khz_uhf = 0,
2311 .freq_offset_khz_vhf = 0,
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002312 }, {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002313 .io.pll_bypass = 0,
2314 .io.pll_range = 1,
2315 .io.pll_prediv = 1,
2316 .io.pll_loopdiv = 8,
2317 .io.adc_clock_ratio = 8,
2318 .io.pll_int_loop_filt = 0,
2319 .io.clock_khz = 30000,
2320 .reset = dib90x0_tuner_reset,
2321 .sleep = dib90x0_tuner_sleep,
2322 .clkouttobamse = 0,
2323 .analog_output = 0,
2324 .use_pwm_agc = 0,
2325 .clkoutdrive = 0,
2326 .freq_offset_khz_uhf = 0,
2327 .freq_offset_khz_vhf = 0,
2328 }
2329};
2330
2331
2332static int stk9090m_frontend_attach(struct dvb_usb_adapter *adap)
2333{
2334 struct dib0700_adapter_state *state = adap->priv;
2335 struct dib0700_state *st = adap->dev->priv;
2336 u32 fw_version;
2337
2338 /* Make use of the new i2c functions from FW 1.20 */
2339 dib0700_get_version(adap->dev, NULL, NULL, &fw_version, NULL);
2340 if (fw_version >= 0x10200)
2341 st->fw_use_new_i2c_api = 1;
2342 dib0700_set_i2c_speed(adap->dev, 340);
2343
2344 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002345 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002346 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
2347 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
2348 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
2349 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
2350
2351 dib0700_ctrl_clock(adap->dev, 72, 1);
2352
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002353 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002354 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002355 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002356 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
2357
2358 dib9000_i2c_enumeration(&adap->dev->i2c_adap, 1, 0x10, 0x80);
2359
2360 if (request_firmware(&state->frontend_firmware, "dib9090.fw", &adap->dev->udev->dev)) {
2361 deb_info("%s: Upload failed. (file not found?)\n", __func__);
2362 return -ENODEV;
2363 } else {
2364 deb_info("%s: firmware read %Zu bytes.\n", __func__, state->frontend_firmware->size);
2365 }
2366 stk9090m_config.microcode_B_fe_size = state->frontend_firmware->size;
2367 stk9090m_config.microcode_B_fe_buffer = state->frontend_firmware->data;
2368
Michael Krufky77eed212011-09-06 09:31:57 -03002369 adap->fe_adap[0].fe = dvb_attach(dib9000_attach, &adap->dev->i2c_adap, 0x80, &stk9090m_config);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002370
Michael Krufky77eed212011-09-06 09:31:57 -03002371 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Olivier Greniebe9bae12011-01-04 05:42:19 -03002372}
2373
2374static int dib9090_tuner_attach(struct dvb_usb_adapter *adap)
2375{
2376 struct dib0700_adapter_state *state = adap->priv;
Michael Krufky77eed212011-09-06 09:31:57 -03002377 struct i2c_adapter *i2c = dib9000_get_tuner_interface(adap->fe_adap[0].fe);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002378 u16 data_dib190[10] = {
2379 1, 0x1374,
2380 2, 0x01a2,
2381 7, 0x0020,
2382 0, 0x00ef,
2383 8, 0x0486,
2384 };
2385
Michael Krufky77eed212011-09-06 09:31:57 -03002386 if (dvb_attach(dib0090_fw_register, adap->fe_adap[0].fe, i2c, &dib9090_dib0090_config) == NULL)
Olivier Greniebe9bae12011-01-04 05:42:19 -03002387 return -ENODEV;
Michael Krufky77eed212011-09-06 09:31:57 -03002388 i2c = dib9000_get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_GPIO_1_2, 0);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002389 if (dib01x0_pmu_update(i2c, data_dib190, 10) != 0)
2390 return -ENODEV;
Olivier Grenied1190022011-08-29 10:58:47 -03002391 dib0700_set_i2c_speed(adap->dev, 1500);
Michael Krufky77eed212011-09-06 09:31:57 -03002392 if (dib9000_firmware_post_pll_init(adap->fe_adap[0].fe) < 0)
Olivier Greniebe9bae12011-01-04 05:42:19 -03002393 return -ENODEV;
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002394 release_firmware(state->frontend_firmware);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002395 return 0;
2396}
2397
2398static int nim9090md_frontend_attach(struct dvb_usb_adapter *adap)
2399{
2400 struct dib0700_adapter_state *state = adap->priv;
2401 struct dib0700_state *st = adap->dev->priv;
2402 struct i2c_adapter *i2c;
2403 struct dvb_frontend *fe_slave;
2404 u32 fw_version;
2405
2406 /* Make use of the new i2c functions from FW 1.20 */
2407 dib0700_get_version(adap->dev, NULL, NULL, &fw_version, NULL);
2408 if (fw_version >= 0x10200)
2409 st->fw_use_new_i2c_api = 1;
2410 dib0700_set_i2c_speed(adap->dev, 340);
2411
2412 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002413 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002414 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
2415 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
2416 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
2417 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
2418
2419 dib0700_ctrl_clock(adap->dev, 72, 1);
2420
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002421 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002422 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002423 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002424 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
2425
2426 if (request_firmware(&state->frontend_firmware, "dib9090.fw", &adap->dev->udev->dev)) {
2427 deb_info("%s: Upload failed. (file not found?)\n", __func__);
2428 return -EIO;
2429 } else {
2430 deb_info("%s: firmware read %Zu bytes.\n", __func__, state->frontend_firmware->size);
2431 }
2432 nim9090md_config[0].microcode_B_fe_size = state->frontend_firmware->size;
2433 nim9090md_config[0].microcode_B_fe_buffer = state->frontend_firmware->data;
2434 nim9090md_config[1].microcode_B_fe_size = state->frontend_firmware->size;
2435 nim9090md_config[1].microcode_B_fe_buffer = state->frontend_firmware->data;
2436
2437 dib9000_i2c_enumeration(&adap->dev->i2c_adap, 1, 0x20, 0x80);
Michael Krufky77eed212011-09-06 09:31:57 -03002438 adap->fe_adap[0].fe = dvb_attach(dib9000_attach, &adap->dev->i2c_adap, 0x80, &nim9090md_config[0]);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002439
Michael Krufky77eed212011-09-06 09:31:57 -03002440 if (adap->fe_adap[0].fe == NULL)
Olivier Greniebe9bae12011-01-04 05:42:19 -03002441 return -ENODEV;
2442
Michael Krufky77eed212011-09-06 09:31:57 -03002443 i2c = dib9000_get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_GPIO_3_4, 0);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002444 dib9000_i2c_enumeration(i2c, 1, 0x12, 0x82);
2445
2446 fe_slave = dvb_attach(dib9000_attach, i2c, 0x82, &nim9090md_config[1]);
Michael Krufky77eed212011-09-06 09:31:57 -03002447 dib9000_set_slave_frontend(adap->fe_adap[0].fe, fe_slave);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002448
2449 return fe_slave == NULL ? -ENODEV : 0;
2450}
2451
2452static int nim9090md_tuner_attach(struct dvb_usb_adapter *adap)
2453{
2454 struct dib0700_adapter_state *state = adap->priv;
2455 struct i2c_adapter *i2c;
2456 struct dvb_frontend *fe_slave;
2457 u16 data_dib190[10] = {
2458 1, 0x5374,
2459 2, 0x01ae,
2460 7, 0x0020,
2461 0, 0x00ef,
2462 8, 0x0406,
2463 };
Michael Krufky77eed212011-09-06 09:31:57 -03002464 i2c = dib9000_get_tuner_interface(adap->fe_adap[0].fe);
2465 if (dvb_attach(dib0090_fw_register, adap->fe_adap[0].fe, i2c, &nim9090md_dib0090_config[0]) == NULL)
Olivier Greniebe9bae12011-01-04 05:42:19 -03002466 return -ENODEV;
Michael Krufky77eed212011-09-06 09:31:57 -03002467 i2c = dib9000_get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_GPIO_1_2, 0);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002468 if (dib01x0_pmu_update(i2c, data_dib190, 10) < 0)
2469 return -ENODEV;
Olivier Grenied1190022011-08-29 10:58:47 -03002470
2471 dib0700_set_i2c_speed(adap->dev, 1500);
Michael Krufky77eed212011-09-06 09:31:57 -03002472 if (dib9000_firmware_post_pll_init(adap->fe_adap[0].fe) < 0)
Olivier Greniebe9bae12011-01-04 05:42:19 -03002473 return -ENODEV;
2474
Michael Krufky77eed212011-09-06 09:31:57 -03002475 fe_slave = dib9000_get_slave_frontend(adap->fe_adap[0].fe, 1);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002476 if (fe_slave != NULL) {
Michael Krufky77eed212011-09-06 09:31:57 -03002477 i2c = dib9000_get_component_bus_interface(adap->fe_adap[0].fe);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002478 dib9000_set_i2c_adapter(fe_slave, i2c);
2479
2480 i2c = dib9000_get_tuner_interface(fe_slave);
2481 if (dvb_attach(dib0090_fw_register, fe_slave, i2c, &nim9090md_dib0090_config[1]) == NULL)
2482 return -ENODEV;
Michael Krufky77eed212011-09-06 09:31:57 -03002483 fe_slave->dvb = adap->fe_adap[0].fe->dvb;
Olivier Grenied1190022011-08-29 10:58:47 -03002484 dib9000_fw_set_component_bus_speed(adap->fe_adap[0].fe, 1500);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002485 if (dib9000_firmware_post_pll_init(fe_slave) < 0)
2486 return -ENODEV;
2487 }
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002488 release_firmware(state->frontend_firmware);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002489
2490 return 0;
2491}
2492
2493/* NIM7090 */
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03002494static int dib7090p_get_best_sampling(struct dvb_frontend *fe , struct dibx090p_best_adc *adc)
Olivier Greniebe9bae12011-01-04 05:42:19 -03002495{
2496 u8 spur = 0, prediv = 0, loopdiv = 0, min_prediv = 1, max_prediv = 1;
2497
2498 u16 xtal = 12000;
2499 u32 fcp_min = 1900; /* PLL Minimum Frequency comparator KHz */
2500 u32 fcp_max = 20000; /* PLL Maximum Frequency comparator KHz */
2501 u32 fdem_max = 76000;
2502 u32 fdem_min = 69500;
2503 u32 fcp = 0, fs = 0, fdem = 0;
2504 u32 harmonic_id = 0;
2505
2506 adc->pll_loopdiv = loopdiv;
2507 adc->pll_prediv = prediv;
2508 adc->timf = 0;
2509
2510 deb_info("bandwidth = %d fdem_min =%d", fe->dtv_property_cache.bandwidth_hz, fdem_min);
2511
2512 /* Find Min and Max prediv */
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002513 while ((xtal/max_prediv) >= fcp_min)
Olivier Greniebe9bae12011-01-04 05:42:19 -03002514 max_prediv++;
2515
2516 max_prediv--;
2517 min_prediv = max_prediv;
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002518 while ((xtal/min_prediv) <= fcp_max) {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002519 min_prediv--;
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002520 if (min_prediv == 1)
Olivier Greniebe9bae12011-01-04 05:42:19 -03002521 break;
2522 }
2523 deb_info("MIN prediv = %d : MAX prediv = %d", min_prediv, max_prediv);
2524
2525 min_prediv = 2;
2526
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002527 for (prediv = min_prediv ; prediv < max_prediv; prediv++) {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002528 fcp = xtal / prediv;
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002529 if (fcp > fcp_min && fcp < fcp_max) {
2530 for (loopdiv = 1 ; loopdiv < 64 ; loopdiv++) {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002531 fdem = ((xtal/prediv) * loopdiv);
2532 fs = fdem / 4;
2533 /* test min/max system restrictions */
2534
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002535 if ((fdem >= fdem_min) && (fdem <= fdem_max) && (fs >= fe->dtv_property_cache.bandwidth_hz/1000)) {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002536 spur = 0;
2537 /* test fs harmonics positions */
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002538 for (harmonic_id = (fe->dtv_property_cache.frequency / (1000*fs)) ; harmonic_id <= ((fe->dtv_property_cache.frequency / (1000*fs))+1) ; harmonic_id++) {
2539 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 -03002540 spur = 1;
2541 break;
2542 }
2543 }
2544
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002545 if (!spur) {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002546 adc->pll_loopdiv = loopdiv;
2547 adc->pll_prediv = prediv;
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002548 adc->timf = 2396745143UL/fdem*(1 << 9);
2549 adc->timf += ((2396745143UL%fdem) << 9)/fdem;
Olivier Greniebe9bae12011-01-04 05:42:19 -03002550 deb_info("loopdiv=%i prediv=%i timf=%i", loopdiv, prediv, adc->timf);
2551 break;
2552 }
2553 }
2554 }
2555 }
2556 if (!spur)
2557 break;
2558 }
2559
2560
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002561 if (adc->pll_loopdiv == 0 && adc->pll_prediv == 0)
Olivier Greniebe9bae12011-01-04 05:42:19 -03002562 return -EINVAL;
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002563 else
Olivier Greniebe9bae12011-01-04 05:42:19 -03002564 return 0;
2565}
2566
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -03002567static int dib7090_agc_startup(struct dvb_frontend *fe)
Olivier Greniebe9bae12011-01-04 05:42:19 -03002568{
2569 struct dvb_usb_adapter *adap = fe->dvb->priv;
2570 struct dib0700_adapter_state *state = adap->priv;
2571 struct dibx000_bandwidth_config pll;
2572 u16 target;
Olivier Grenie5e9c85d2012-12-31 10:17:44 -03002573 struct dibx090p_best_adc adc;
Olivier Greniebe9bae12011-01-04 05:42:19 -03002574 int ret;
2575
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -03002576 ret = state->set_param_save(fe);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002577 if (ret < 0)
2578 return ret;
2579
2580 memset(&pll, 0, sizeof(struct dibx000_bandwidth_config));
2581 dib0090_pwm_gain_reset(fe);
Olivier Grenie6724a2f2011-08-05 13:49:33 -03002582 target = (dib0090_get_wbd_target(fe) * 8 + 1) / 2;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03002583 state->dib7000p_ops.set_wbd_ref(fe, target);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002584
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002585 if (dib7090p_get_best_sampling(fe, &adc) == 0) {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002586 pll.pll_ratio = adc.pll_loopdiv;
2587 pll.pll_prediv = adc.pll_prediv;
2588
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03002589 state->dib7000p_ops.update_pll(fe, &pll);
2590 state->dib7000p_ops.ctrl_timf(fe, DEMOD_TIMF_SET, adc.timf);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002591 }
2592 return 0;
2593}
2594
Olivier Grenie2e802862011-08-05 10:39:15 -03002595static int dib7090_agc_restart(struct dvb_frontend *fe, u8 restart)
2596{
2597 deb_info("AGC restart callback: %d", restart);
2598 if (restart == 0) /* before AGC startup */
2599 dib0090_set_dc_servo(fe, 1);
2600 return 0;
2601}
2602
Olivier Grenief45f5132012-12-31 09:47:10 -03002603static int tfe7790p_update_lna(struct dvb_frontend *fe, u16 agc_global)
Olivier Grenie6724a2f2011-08-05 13:49:33 -03002604{
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03002605 struct dvb_usb_adapter *adap = fe->dvb->priv;
2606 struct dib0700_adapter_state *state = adap->priv;
2607
Olivier Grenief45f5132012-12-31 09:47:10 -03002608 deb_info("update LNA: agc global=%i", agc_global);
Olivier Grenie6724a2f2011-08-05 13:49:33 -03002609
Olivier Grenief45f5132012-12-31 09:47:10 -03002610 if (agc_global < 25000) {
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03002611 state->dib7000p_ops.set_gpio(fe, 8, 0, 0);
2612 state->dib7000p_ops.set_agc1_min(fe, 0);
Olivier Grenie6724a2f2011-08-05 13:49:33 -03002613 } else {
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03002614 state->dib7000p_ops.set_gpio(fe, 8, 0, 1);
2615 state->dib7000p_ops.set_agc1_min(fe, 32768);
Olivier Grenie6724a2f2011-08-05 13:49:33 -03002616 }
2617
2618 return 0;
2619}
2620
Olivier Greniebe9bae12011-01-04 05:42:19 -03002621static struct dib0090_wbd_slope dib7090_wbd_table[] = {
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002622 { 380, 81, 850, 64, 540, 4},
2623 { 860, 51, 866, 21, 375, 4},
2624 {1700, 0, 250, 0, 100, 6},
2625 {2600, 0, 250, 0, 100, 6},
2626 { 0xFFFF, 0, 0, 0, 0, 0},
Olivier Greniebe9bae12011-01-04 05:42:19 -03002627};
2628
Olivier Greniea685dbb2011-08-05 14:10:40 -03002629static struct dibx000_agc_config dib7090_agc_config[2] = {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002630 {
2631 .band_caps = BAND_UHF,
2632 /* 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,
2633 * 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 -03002634 .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 -03002635
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002636 .inv_gain = 687,
2637 .time_stabiliz = 10,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002638
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002639 .alpha_level = 0,
2640 .thlock = 118,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002641
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002642 .wbd_inv = 0,
2643 .wbd_ref = 1200,
2644 .wbd_sel = 3,
2645 .wbd_alpha = 5,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002646
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002647 .agc1_max = 65535,
Olivier Grenie59501bb2012-12-31 09:51:17 -03002648 .agc1_min = 32768,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002649
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002650 .agc2_max = 65535,
2651 .agc2_min = 0,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002652
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002653 .agc1_pt1 = 0,
2654 .agc1_pt2 = 32,
2655 .agc1_pt3 = 114,
2656 .agc1_slope1 = 143,
2657 .agc1_slope2 = 144,
2658 .agc2_pt1 = 114,
2659 .agc2_pt2 = 227,
2660 .agc2_slope1 = 116,
2661 .agc2_slope2 = 117,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002662
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002663 .alpha_mant = 18,
2664 .alpha_exp = 0,
2665 .beta_mant = 20,
2666 .beta_exp = 59,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002667
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002668 .perform_agc_softsplit = 0,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002669 } , {
2670 .band_caps = BAND_FM | BAND_VHF | BAND_CBAND,
2671 /* 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,
2672 * 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 -03002673 .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 -03002674
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002675 .inv_gain = 732,
2676 .time_stabiliz = 10,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002677
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002678 .alpha_level = 0,
2679 .thlock = 118,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002680
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002681 .wbd_inv = 0,
2682 .wbd_ref = 1200,
2683 .wbd_sel = 3,
2684 .wbd_alpha = 5,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002685
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002686 .agc1_max = 65535,
2687 .agc1_min = 0,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002688
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002689 .agc2_max = 65535,
2690 .agc2_min = 0,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002691
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002692 .agc1_pt1 = 0,
2693 .agc1_pt2 = 0,
2694 .agc1_pt3 = 98,
2695 .agc1_slope1 = 0,
2696 .agc1_slope2 = 167,
Patrick Boettcher7f4d5272011-04-03 12:28:08 -03002697 .agc2_pt1 = 98,
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002698 .agc2_pt2 = 255,
2699 .agc2_slope1 = 104,
2700 .agc2_slope2 = 0,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002701
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002702 .alpha_mant = 18,
2703 .alpha_exp = 0,
2704 .beta_mant = 20,
2705 .beta_exp = 59,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002706
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002707 .perform_agc_softsplit = 0,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002708 }
2709};
2710
2711static struct dibx000_bandwidth_config dib7090_clock_config_12_mhz = {
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002712 60000, 15000,
2713 1, 5, 0, 0, 0,
2714 0, 0, 1, 1, 2,
2715 (3 << 14) | (1 << 12) | (524 << 0),
2716 (0 << 25) | 0,
2717 20452225,
2718 15000000,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002719};
2720
2721static struct dib7000p_config nim7090_dib7000p_config = {
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 = tfe7790p_update_lna, /* GPIO used is the same as TFE7790 */
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_FIFO,
2746 .enMpegOutput = 1,
2747};
2748
Olivier Grenie59501bb2012-12-31 09:51:17 -03002749static int tfe7090p_pvr_update_lna(struct dvb_frontend *fe, u16 agc_global)
2750{
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03002751 struct dvb_usb_adapter *adap = fe->dvb->priv;
2752 struct dib0700_adapter_state *state = adap->priv;
2753
Olivier Grenie59501bb2012-12-31 09:51:17 -03002754 deb_info("TFE7090P-PVR update LNA: agc global=%i", agc_global);
2755 if (agc_global < 25000) {
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03002756 state->dib7000p_ops.set_gpio(fe, 5, 0, 0);
2757 state->dib7000p_ops.set_agc1_min(fe, 0);
Olivier Grenie59501bb2012-12-31 09:51:17 -03002758 } else {
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03002759 state->dib7000p_ops.set_gpio(fe, 5, 0, 1);
2760 state->dib7000p_ops.set_agc1_min(fe, 32768);
Olivier Grenie59501bb2012-12-31 09:51:17 -03002761 }
2762
2763 return 0;
2764}
2765
Olivier Greniebe9bae12011-01-04 05:42:19 -03002766static struct dib7000p_config tfe7090pvr_dib7000p_config[2] = {
2767 {
2768 .output_mpeg2_in_188_bytes = 1,
2769 .hostbus_diversity = 1,
2770 .tuner_is_baseband = 1,
Olivier Grenie59501bb2012-12-31 09:51:17 -03002771 .update_lna = tfe7090p_pvr_update_lna,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002772
2773 .agc_config_count = 2,
2774 .agc = dib7090_agc_config,
2775
2776 .bw = &dib7090_clock_config_12_mhz,
2777
2778 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
2779 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
2780 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
2781
2782 .pwm_freq_div = 0,
2783
2784 .agc_control = dib7090_agc_restart,
2785
2786 .spur_protect = 0,
2787 .disable_sample_and_hold = 0,
2788 .enable_current_mirror = 0,
2789 .diversity_delay = 0,
2790
2791 .output_mode = OUTMODE_MPEG2_PAR_GATED_CLK,
2792 .default_i2c_addr = 0x90,
2793 .enMpegOutput = 1,
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002794 }, {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002795 .output_mpeg2_in_188_bytes = 1,
2796 .hostbus_diversity = 1,
2797 .tuner_is_baseband = 1,
Olivier Grenie59501bb2012-12-31 09:51:17 -03002798 .update_lna = tfe7090p_pvr_update_lna,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002799
2800 .agc_config_count = 2,
2801 .agc = dib7090_agc_config,
2802
2803 .bw = &dib7090_clock_config_12_mhz,
2804
2805 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
2806 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
2807 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
2808
2809 .pwm_freq_div = 0,
2810
2811 .agc_control = dib7090_agc_restart,
2812
2813 .spur_protect = 0,
2814 .disable_sample_and_hold = 0,
2815 .enable_current_mirror = 0,
2816 .diversity_delay = 0,
2817
2818 .output_mode = OUTMODE_MPEG2_PAR_GATED_CLK,
2819 .default_i2c_addr = 0x92,
2820 .enMpegOutput = 0,
2821 }
2822};
2823
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03002824static struct dib0090_config nim7090_dib0090_config = {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002825 .io.clock_khz = 12000,
2826 .io.pll_bypass = 0,
2827 .io.pll_range = 0,
2828 .io.pll_prediv = 3,
2829 .io.pll_loopdiv = 6,
2830 .io.adc_clock_ratio = 0,
2831 .io.pll_int_loop_filt = 0,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002832
2833 .freq_offset_khz_uhf = 0,
2834 .freq_offset_khz_vhf = 0,
2835
Olivier Greniebe9bae12011-01-04 05:42:19 -03002836 .clkouttobamse = 1,
2837 .analog_output = 0,
2838
2839 .wbd_vhf_offset = 0,
2840 .wbd_cband_offset = 0,
2841 .use_pwm_agc = 1,
2842 .clkoutdrive = 0,
2843
2844 .fref_clock_ratio = 0,
2845
2846 .wbd = dib7090_wbd_table,
2847
2848 .ls_cfg_pad_drv = 0,
2849 .data_tx_drv = 0,
2850 .low_if = NULL,
2851 .in_soc = 1,
2852};
2853
Olivier Grenief45f5132012-12-31 09:47:10 -03002854static struct dib7000p_config tfe7790p_dib7000p_config = {
Olivier Grenieb293f302011-08-09 04:48:25 -03002855 .output_mpeg2_in_188_bytes = 1,
2856 .hostbus_diversity = 1,
2857 .tuner_is_baseband = 1,
Olivier Grenief45f5132012-12-31 09:47:10 -03002858 .update_lna = tfe7790p_update_lna,
Olivier Grenieb293f302011-08-09 04:48:25 -03002859
2860 .agc_config_count = 2,
2861 .agc = dib7090_agc_config,
2862
2863 .bw = &dib7090_clock_config_12_mhz,
2864
2865 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
2866 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
2867 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
2868
2869 .pwm_freq_div = 0,
2870
2871 .agc_control = dib7090_agc_restart,
2872
2873 .spur_protect = 0,
2874 .disable_sample_and_hold = 0,
2875 .enable_current_mirror = 0,
2876 .diversity_delay = 0,
2877
2878 .output_mode = OUTMODE_MPEG2_PAR_GATED_CLK,
2879 .enMpegOutput = 1,
2880};
2881
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03002882static struct dib0090_config tfe7790p_dib0090_config = {
Olivier Grenieb293f302011-08-09 04:48:25 -03002883 .io.clock_khz = 12000,
2884 .io.pll_bypass = 0,
2885 .io.pll_range = 0,
2886 .io.pll_prediv = 3,
2887 .io.pll_loopdiv = 6,
2888 .io.adc_clock_ratio = 0,
2889 .io.pll_int_loop_filt = 0,
Olivier Grenieb293f302011-08-09 04:48:25 -03002890
2891 .freq_offset_khz_uhf = 0,
2892 .freq_offset_khz_vhf = 0,
2893
Olivier Grenieb293f302011-08-09 04:48:25 -03002894 .clkouttobamse = 1,
2895 .analog_output = 0,
2896
2897 .wbd_vhf_offset = 0,
2898 .wbd_cband_offset = 0,
2899 .use_pwm_agc = 1,
2900 .clkoutdrive = 0,
2901
2902 .fref_clock_ratio = 0,
2903
Olivier Grenief45f5132012-12-31 09:47:10 -03002904 .wbd = dib7090_wbd_table,
Olivier Grenieb293f302011-08-09 04:48:25 -03002905
2906 .ls_cfg_pad_drv = 0,
2907 .data_tx_drv = 0,
2908 .low_if = NULL,
2909 .in_soc = 1,
Olivier Grenief45f5132012-12-31 09:47:10 -03002910 .force_cband_input = 0,
2911 .is_dib7090e = 0,
Olivier Grenieb293f302011-08-09 04:48:25 -03002912 .force_crystal_mode = 1,
2913};
2914
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03002915static struct dib0090_config tfe7090pvr_dib0090_config[2] = {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002916 {
2917 .io.clock_khz = 12000,
2918 .io.pll_bypass = 0,
2919 .io.pll_range = 0,
2920 .io.pll_prediv = 3,
2921 .io.pll_loopdiv = 6,
2922 .io.adc_clock_ratio = 0,
2923 .io.pll_int_loop_filt = 0,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002924
2925 .freq_offset_khz_uhf = 50,
2926 .freq_offset_khz_vhf = 70,
2927
Olivier Greniebe9bae12011-01-04 05:42:19 -03002928 .clkouttobamse = 1,
2929 .analog_output = 0,
2930
2931 .wbd_vhf_offset = 0,
2932 .wbd_cband_offset = 0,
2933 .use_pwm_agc = 1,
2934 .clkoutdrive = 0,
2935
2936 .fref_clock_ratio = 0,
2937
2938 .wbd = dib7090_wbd_table,
2939
2940 .ls_cfg_pad_drv = 0,
2941 .data_tx_drv = 0,
2942 .low_if = NULL,
2943 .in_soc = 1,
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002944 }, {
Olivier Greniebe9bae12011-01-04 05:42:19 -03002945 .io.clock_khz = 12000,
2946 .io.pll_bypass = 0,
2947 .io.pll_range = 0,
2948 .io.pll_prediv = 3,
2949 .io.pll_loopdiv = 6,
2950 .io.adc_clock_ratio = 0,
2951 .io.pll_int_loop_filt = 0,
Olivier Greniebe9bae12011-01-04 05:42:19 -03002952
2953 .freq_offset_khz_uhf = -50,
2954 .freq_offset_khz_vhf = -70,
2955
Olivier Greniebe9bae12011-01-04 05:42:19 -03002956 .clkouttobamse = 1,
2957 .analog_output = 0,
2958
2959 .wbd_vhf_offset = 0,
2960 .wbd_cband_offset = 0,
2961 .use_pwm_agc = 1,
2962 .clkoutdrive = 0,
2963
2964 .fref_clock_ratio = 0,
2965
2966 .wbd = dib7090_wbd_table,
2967
2968 .ls_cfg_pad_drv = 0,
2969 .data_tx_drv = 0,
2970 .low_if = NULL,
2971 .in_soc = 1,
2972 }
2973};
2974
2975static int nim7090_frontend_attach(struct dvb_usb_adapter *adap)
2976{
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03002977 struct dib0700_adapter_state *state = adap->priv;
2978
2979 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
2980 return -ENODEV;
2981
Olivier Greniebe9bae12011-01-04 05:42:19 -03002982 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002983 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002984 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
2985 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
2986 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
2987 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
2988
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002989 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002990 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03002991 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002992 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
2993
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03002994 if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 0x10, &nim7090_dib7000p_config) != 0) {
2995 err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n", __func__);
2996 dvb_detach(&state->dib7000p_ops);
Olivier Greniebe9bae12011-01-04 05:42:19 -03002997 return -ENODEV;
2998 }
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03002999 adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap, 0x80, &nim7090_dib7000p_config);
Olivier Greniebe9bae12011-01-04 05:42:19 -03003000
Michael Krufky77eed212011-09-06 09:31:57 -03003001 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Olivier Greniebe9bae12011-01-04 05:42:19 -03003002}
3003
3004static int nim7090_tuner_attach(struct dvb_usb_adapter *adap)
3005{
3006 struct dib0700_adapter_state *st = adap->priv;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003007 struct i2c_adapter *tun_i2c = st->dib7000p_ops.get_i2c_tuner(adap->fe_adap[0].fe);
3008
3009 nim7090_dib0090_config.reset = st->dib7000p_ops.tuner_sleep,
3010 nim7090_dib0090_config.sleep = st->dib7000p_ops.tuner_sleep,
3011 nim7090_dib0090_config.get_adc_power = st->dib7000p_ops.get_adc_power;
Olivier Greniebe9bae12011-01-04 05:42:19 -03003012
Michael Krufky77eed212011-09-06 09:31:57 -03003013 if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c, &nim7090_dib0090_config) == NULL)
Olivier Greniebe9bae12011-01-04 05:42:19 -03003014 return -ENODEV;
3015
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003016 st->dib7000p_ops.set_gpio(adap->fe_adap[0].fe, 8, 0, 1);
Olivier Greniebe9bae12011-01-04 05:42:19 -03003017
Michael Krufky77eed212011-09-06 09:31:57 -03003018 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
3019 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib7090_agc_startup;
Olivier Greniebe9bae12011-01-04 05:42:19 -03003020 return 0;
3021}
3022
3023static int tfe7090pvr_frontend0_attach(struct dvb_usb_adapter *adap)
3024{
3025 struct dib0700_state *st = adap->dev->priv;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003026 struct dib0700_adapter_state *state = adap->priv;
3027
3028 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
3029 return -ENODEV;
Olivier Greniebe9bae12011-01-04 05:42:19 -03003030
3031 /* The TFE7090 requires the dib0700 to not be in master mode */
3032 st->disable_streaming_master_mode = 1;
3033
3034 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03003035 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03003036 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
3037 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
3038 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
3039 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
3040
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03003041 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03003042 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
Olivier Grenieb4d6046e2011-01-04 13:08:14 -03003043 msleep(20);
Olivier Greniebe9bae12011-01-04 05:42:19 -03003044 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
3045
3046 /* initialize IC 0 */
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003047 if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 0x20, &tfe7090pvr_dib7000p_config[0]) != 0) {
3048 err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n", __func__);
3049 dvb_detach(&state->dib7000p_ops);
Olivier Greniebe9bae12011-01-04 05:42:19 -03003050 return -ENODEV;
3051 }
3052
3053 dib0700_set_i2c_speed(adap->dev, 340);
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003054 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 -03003055 if (adap->fe_adap[0].fe == NULL)
Olivier Greniebe9bae12011-01-04 05:42:19 -03003056 return -ENODEV;
3057
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003058 state->dib7000p_ops.slave_reset(adap->fe_adap[0].fe);
Patrick Boettcher71682522011-04-03 12:44:25 -03003059
Olivier Greniebe9bae12011-01-04 05:42:19 -03003060 return 0;
3061}
3062
3063static int tfe7090pvr_frontend1_attach(struct dvb_usb_adapter *adap)
3064{
3065 struct i2c_adapter *i2c;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003066 struct dib0700_adapter_state *state = adap->priv;
Olivier Greniebe9bae12011-01-04 05:42:19 -03003067
Michael Krufky77eed212011-09-06 09:31:57 -03003068 if (adap->dev->adapter[0].fe_adap[0].fe == NULL) {
Olivier Greniebe9bae12011-01-04 05:42:19 -03003069 err("the master dib7090 has to be initialized first");
3070 return -ENODEV; /* the master device has not been initialized */
3071 }
3072
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003073 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
3074 return -ENODEV;
3075
3076 i2c = state->dib7000p_ops.get_i2c_master(adap->dev->adapter[0].fe_adap[0].fe, DIBX000_I2C_INTERFACE_GPIO_6_7, 1);
3077 if (state->dib7000p_ops.i2c_enumeration(i2c, 1, 0x10, &tfe7090pvr_dib7000p_config[1]) != 0) {
3078 err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n", __func__);
3079 dvb_detach(&state->dib7000p_ops);
Olivier Greniebe9bae12011-01-04 05:42:19 -03003080 return -ENODEV;
3081 }
3082
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003083 adap->fe_adap[0].fe = state->dib7000p_ops.init(i2c, 0x92, &tfe7090pvr_dib7000p_config[1]);
Olivier Greniebe9bae12011-01-04 05:42:19 -03003084 dib0700_set_i2c_speed(adap->dev, 200);
3085
Michael Krufky77eed212011-09-06 09:31:57 -03003086 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Olivier Greniebe9bae12011-01-04 05:42:19 -03003087}
3088
3089static int tfe7090pvr_tuner0_attach(struct dvb_usb_adapter *adap)
3090{
3091 struct dib0700_adapter_state *st = adap->priv;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003092 struct i2c_adapter *tun_i2c = st->dib7000p_ops.get_i2c_tuner(adap->fe_adap[0].fe);
3093
3094 tfe7090pvr_dib0090_config[0].reset = st->dib7000p_ops.tuner_sleep;
3095 tfe7090pvr_dib0090_config[0].sleep = st->dib7000p_ops.tuner_sleep;
3096 tfe7090pvr_dib0090_config[0].get_adc_power = st->dib7000p_ops.get_adc_power;
Olivier Greniebe9bae12011-01-04 05:42:19 -03003097
Michael Krufky77eed212011-09-06 09:31:57 -03003098 if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c, &tfe7090pvr_dib0090_config[0]) == NULL)
Olivier Greniebe9bae12011-01-04 05:42:19 -03003099 return -ENODEV;
3100
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003101 st->dib7000p_ops.set_gpio(adap->fe_adap[0].fe, 8, 0, 1);
Olivier Greniebe9bae12011-01-04 05:42:19 -03003102
Michael Krufky77eed212011-09-06 09:31:57 -03003103 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
3104 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib7090_agc_startup;
Olivier Greniebe9bae12011-01-04 05:42:19 -03003105 return 0;
3106}
3107
3108static int tfe7090pvr_tuner1_attach(struct dvb_usb_adapter *adap)
3109{
3110 struct dib0700_adapter_state *st = adap->priv;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003111 struct i2c_adapter *tun_i2c = st->dib7000p_ops.get_i2c_tuner(adap->fe_adap[0].fe);
3112
3113 tfe7090pvr_dib0090_config[1].reset = st->dib7000p_ops.tuner_sleep;
3114 tfe7090pvr_dib0090_config[1].sleep = st->dib7000p_ops.tuner_sleep;
3115 tfe7090pvr_dib0090_config[1].get_adc_power = st->dib7000p_ops.get_adc_power;
Olivier Greniebe9bae12011-01-04 05:42:19 -03003116
Michael Krufky77eed212011-09-06 09:31:57 -03003117 if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c, &tfe7090pvr_dib0090_config[1]) == NULL)
Olivier Greniebe9bae12011-01-04 05:42:19 -03003118 return -ENODEV;
3119
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003120 st->dib7000p_ops.set_gpio(adap->fe_adap[0].fe, 8, 0, 1);
Olivier Greniebe9bae12011-01-04 05:42:19 -03003121
Michael Krufky77eed212011-09-06 09:31:57 -03003122 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
3123 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib7090_agc_startup;
Olivier Greniebe9bae12011-01-04 05:42:19 -03003124 return 0;
3125}
3126
Olivier Grenief45f5132012-12-31 09:47:10 -03003127static int tfe7790p_frontend_attach(struct dvb_usb_adapter *adap)
Olivier Grenieb293f302011-08-09 04:48:25 -03003128{
3129 struct dib0700_state *st = adap->dev->priv;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003130 struct dib0700_adapter_state *state = adap->priv;
3131
3132 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
3133 return -ENODEV;
Olivier Grenieb293f302011-08-09 04:48:25 -03003134
Olivier Grenief45f5132012-12-31 09:47:10 -03003135 /* The TFE7790P requires the dib0700 to not be in master mode */
Olivier Grenieb293f302011-08-09 04:48:25 -03003136 st->disable_streaming_master_mode = 1;
3137
3138 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
3139 msleep(20);
3140 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
3141 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
3142 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
3143 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
3144 msleep(20);
3145 dib0700_ctrl_clock(adap->dev, 72, 1);
3146 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
3147 msleep(20);
3148 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
3149
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003150 if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap,
Olivier Grenief45f5132012-12-31 09:47:10 -03003151 1, 0x10, &tfe7790p_dib7000p_config) != 0) {
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003152 err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n",
Olivier Grenieb293f302011-08-09 04:48:25 -03003153 __func__);
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003154 dvb_detach(&state->dib7000p_ops);
Olivier Grenieb293f302011-08-09 04:48:25 -03003155 return -ENODEV;
3156 }
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003157 adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap,
Olivier Grenief45f5132012-12-31 09:47:10 -03003158 0x80, &tfe7790p_dib7000p_config);
Olivier Grenieb293f302011-08-09 04:48:25 -03003159
3160 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
3161}
3162
Olivier Grenief45f5132012-12-31 09:47:10 -03003163static int tfe7790p_tuner_attach(struct dvb_usb_adapter *adap)
Olivier Grenieb293f302011-08-09 04:48:25 -03003164{
3165 struct dib0700_adapter_state *st = adap->priv;
3166 struct i2c_adapter *tun_i2c =
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003167 st->dib7000p_ops.get_i2c_tuner(adap->fe_adap[0].fe);
3168
3169
3170 tfe7790p_dib0090_config.reset = st->dib7000p_ops.tuner_sleep;
3171 tfe7790p_dib0090_config.sleep = st->dib7000p_ops.tuner_sleep;
3172 tfe7790p_dib0090_config.get_adc_power = st->dib7000p_ops.get_adc_power;
Olivier Grenieb293f302011-08-09 04:48:25 -03003173
3174 if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c,
Olivier Grenief45f5132012-12-31 09:47:10 -03003175 &tfe7790p_dib0090_config) == NULL)
Olivier Grenie6724a2f2011-08-05 13:49:33 -03003176 return -ENODEV;
3177
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003178 st->dib7000p_ops.set_gpio(adap->fe_adap[0].fe, 8, 0, 1);
Olivier Grenie6724a2f2011-08-05 13:49:33 -03003179
3180 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
3181 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib7090_agc_startup;
3182 return 0;
3183}
3184
Patrick Boettcher01373a52007-07-30 12:49:04 -03003185/* STK7070PD */
3186static struct dib7000p_config stk7070pd_dib7000p_config[2] = {
3187 {
3188 .output_mpeg2_in_188_bytes = 1,
3189
3190 .agc_config_count = 1,
3191 .agc = &dib7070_agc_config,
3192 .bw = &dib7070_bw_config_12_mhz,
Patrick Boettcher3cb2c392008-01-25 07:25:20 -03003193 .tuner_is_baseband = 1,
3194 .spur_protect = 1,
Patrick Boettcher01373a52007-07-30 12:49:04 -03003195
3196 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
3197 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
3198 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
3199
3200 .hostbus_diversity = 1,
3201 }, {
3202 .output_mpeg2_in_188_bytes = 1,
3203
3204 .agc_config_count = 1,
3205 .agc = &dib7070_agc_config,
3206 .bw = &dib7070_bw_config_12_mhz,
Patrick Boettcher3cb2c392008-01-25 07:25:20 -03003207 .tuner_is_baseband = 1,
3208 .spur_protect = 1,
Patrick Boettcher01373a52007-07-30 12:49:04 -03003209
3210 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
3211 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
3212 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
3213
3214 .hostbus_diversity = 1,
3215 }
3216};
3217
Jiri Slaby52fd5b22012-01-10 14:11:23 -03003218static void stk7070pd_init(struct dvb_usb_device *dev)
3219{
3220 dib0700_set_gpio(dev, GPIO6, GPIO_OUT, 1);
3221 msleep(10);
3222 dib0700_set_gpio(dev, GPIO9, GPIO_OUT, 1);
3223 dib0700_set_gpio(dev, GPIO4, GPIO_OUT, 1);
3224 dib0700_set_gpio(dev, GPIO7, GPIO_OUT, 1);
3225 dib0700_set_gpio(dev, GPIO10, GPIO_OUT, 0);
3226
3227 dib0700_ctrl_clock(dev, 72, 1);
3228
3229 msleep(10);
3230 dib0700_set_gpio(dev, GPIO10, GPIO_OUT, 1);
3231}
3232
Patrick Boettcher01373a52007-07-30 12:49:04 -03003233static int stk7070pd_frontend_attach0(struct dvb_usb_adapter *adap)
3234{
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003235 struct dib0700_adapter_state *state = adap->priv;
3236
3237 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
3238 return -ENODEV;
3239
Jiri Slaby52fd5b22012-01-10 14:11:23 -03003240 stk7070pd_init(adap->dev);
Patrick Boettcher01373a52007-07-30 12:49:04 -03003241
Patrick Boettcher01373a52007-07-30 12:49:04 -03003242 msleep(10);
3243 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
3244
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003245 if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap, 2, 18,
Devin Heitmueller83c4fdf2009-01-21 01:55:45 -03003246 stk7070pd_dib7000p_config) != 0) {
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003247 err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n",
Devin Heitmueller83c4fdf2009-01-21 01:55:45 -03003248 __func__);
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003249 dvb_detach(&state->dib7000p_ops);
Devin Heitmueller83c4fdf2009-01-21 01:55:45 -03003250 return -ENODEV;
3251 }
Patrick Boettcher01373a52007-07-30 12:49:04 -03003252
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003253 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 -03003254 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Patrick Boettcher01373a52007-07-30 12:49:04 -03003255}
3256
3257static int stk7070pd_frontend_attach1(struct dvb_usb_adapter *adap)
3258{
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003259 struct dib0700_adapter_state *state = adap->priv;
3260
3261 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
3262 return -ENODEV;
3263
3264 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 -03003265 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Patrick Boettcher01373a52007-07-30 12:49:04 -03003266}
3267
Jiri Slabyd43272a2012-01-10 14:11:25 -03003268static int novatd_read_status_override(struct dvb_frontend *fe,
3269 fe_status_t *stat)
3270{
3271 struct dvb_usb_adapter *adap = fe->dvb->priv;
3272 struct dvb_usb_device *dev = adap->dev;
3273 struct dib0700_state *state = dev->priv;
3274 int ret;
3275
3276 ret = state->read_status(fe, stat);
3277
3278 if (!ret)
3279 dib0700_set_gpio(dev, adap->id == 0 ? GPIO1 : GPIO0, GPIO_OUT,
3280 !!(*stat & FE_HAS_LOCK));
3281
3282 return ret;
3283}
3284
3285static int novatd_sleep_override(struct dvb_frontend* fe)
3286{
3287 struct dvb_usb_adapter *adap = fe->dvb->priv;
3288 struct dvb_usb_device *dev = adap->dev;
3289 struct dib0700_state *state = dev->priv;
3290
3291 /* turn off LED */
3292 dib0700_set_gpio(dev, adap->id == 0 ? GPIO1 : GPIO0, GPIO_OUT, 0);
3293
3294 return state->sleep(fe);
3295}
3296
Jiri Slaby2b05b882012-01-10 14:11:24 -03003297/**
3298 * novatd_frontend_attach - Nova-TD specific attach
3299 *
3300 * Nova-TD has GPIO0, 1 and 2 for LEDs. So do not fiddle with them except for
3301 * information purposes.
3302 */
3303static int novatd_frontend_attach(struct dvb_usb_adapter *adap)
3304{
3305 struct dvb_usb_device *dev = adap->dev;
Jiri Slabyd43272a2012-01-10 14:11:25 -03003306 struct dib0700_state *st = dev->priv;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003307 struct dib0700_adapter_state *state = adap->priv;
3308
3309 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
3310 return -ENODEV;
Jiri Slaby2b05b882012-01-10 14:11:24 -03003311
3312 if (adap->id == 0) {
3313 stk7070pd_init(dev);
3314
3315 /* turn the power LED on, the other two off (just in case) */
3316 dib0700_set_gpio(dev, GPIO0, GPIO_OUT, 0);
3317 dib0700_set_gpio(dev, GPIO1, GPIO_OUT, 0);
3318 dib0700_set_gpio(dev, GPIO2, GPIO_OUT, 1);
3319
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003320 if (state->dib7000p_ops.i2c_enumeration(&dev->i2c_adap, 2, 18,
Jiri Slaby2b05b882012-01-10 14:11:24 -03003321 stk7070pd_dib7000p_config) != 0) {
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003322 err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n",
Jiri Slaby2b05b882012-01-10 14:11:24 -03003323 __func__);
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003324 dvb_detach(&state->dib7000p_ops);
Jiri Slaby2b05b882012-01-10 14:11:24 -03003325 return -ENODEV;
3326 }
3327 }
3328
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003329 adap->fe_adap[0].fe = state->dib7000p_ops.init(&dev->i2c_adap,
Jiri Slaby2b05b882012-01-10 14:11:24 -03003330 adap->id == 0 ? 0x80 : 0x82,
3331 &stk7070pd_dib7000p_config[adap->id]);
Jiri Slabyd43272a2012-01-10 14:11:25 -03003332
3333 if (adap->fe_adap[0].fe == NULL)
3334 return -ENODEV;
3335
3336 st->read_status = adap->fe_adap[0].fe->ops.read_status;
3337 adap->fe_adap[0].fe->ops.read_status = novatd_read_status_override;
3338 st->sleep = adap->fe_adap[0].fe->ops.sleep;
3339 adap->fe_adap[0].fe->ops.sleep = novatd_sleep_override;
3340
3341 return 0;
Jiri Slaby2b05b882012-01-10 14:11:24 -03003342}
3343
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03003344/* S5H1411 */
3345static struct s5h1411_config pinnacle_801e_config = {
3346 .output_mode = S5H1411_PARALLEL_OUTPUT,
3347 .gpio = S5H1411_GPIO_OFF,
3348 .mpeg_timing = S5H1411_MPEGTIMING_NONCONTINOUS_NONINVERTING_CLOCK,
3349 .qam_if = S5H1411_IF_44000,
3350 .vsb_if = S5H1411_IF_44000,
3351 .inversion = S5H1411_INVERSION_OFF,
3352 .status_mode = S5H1411_DEMODLOCKING
3353};
3354
3355/* Pinnacle PCTV HD Pro 801e GPIOs map:
3356 GPIO0 - currently unknown
3357 GPIO1 - xc5000 tuner reset
3358 GPIO2 - CX25843 sleep
3359 GPIO3 - currently unknown
3360 GPIO4 - currently unknown
3361 GPIO6 - currently unknown
3362 GPIO7 - currently unknown
3363 GPIO9 - currently unknown
3364 GPIO10 - CX25843 reset
3365 */
3366static int s5h1411_frontend_attach(struct dvb_usb_adapter *adap)
3367{
3368 struct dib0700_state *st = adap->dev->priv;
3369
3370 /* Make use of the new i2c functions from FW 1.20 */
3371 st->fw_use_new_i2c_api = 1;
3372
3373 /* The s5h1411 requires the dib0700 to not be in master mode */
3374 st->disable_streaming_master_mode = 1;
3375
3376 /* All msleep values taken from Windows USB trace */
3377 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 0);
3378 dib0700_set_gpio(adap->dev, GPIO3, GPIO_OUT, 0);
3379 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
3380 msleep(400);
3381 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
3382 msleep(60);
3383 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
3384 msleep(30);
3385 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
3386 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
3387 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
3388 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
3389 dib0700_set_gpio(adap->dev, GPIO2, GPIO_OUT, 0);
3390 msleep(30);
3391
3392 /* Put the CX25843 to sleep for now since we're in digital mode */
3393 dib0700_set_gpio(adap->dev, GPIO2, GPIO_OUT, 1);
3394
3395 /* GPIOs are initialized, do the attach */
Michael Krufky77eed212011-09-06 09:31:57 -03003396 adap->fe_adap[0].fe = dvb_attach(s5h1411_attach, &pinnacle_801e_config,
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03003397 &adap->dev->i2c_adap);
Michael Krufky77eed212011-09-06 09:31:57 -03003398 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03003399}
3400
Michael Krufky767f3b32008-09-25 09:47:07 -03003401static int dib0700_xc5000_tuner_callback(void *priv, int component,
3402 int command, int arg)
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03003403{
3404 struct dvb_usb_adapter *adap = priv;
3405
Devin Heitmueller79025a92008-10-06 12:07:48 -03003406 if (command == XC5000_TUNER_RESET) {
3407 /* Reset the tuner */
3408 dib0700_set_gpio(adap->dev, GPIO1, GPIO_OUT, 0);
Devin Heitmuellerf0f46332009-05-04 21:57:41 -03003409 msleep(10);
Devin Heitmueller79025a92008-10-06 12:07:48 -03003410 dib0700_set_gpio(adap->dev, GPIO1, GPIO_OUT, 1);
Devin Heitmuellerf0f46332009-05-04 21:57:41 -03003411 msleep(10);
Devin Heitmueller79025a92008-10-06 12:07:48 -03003412 } else {
3413 err("xc5000: unknown tuner callback command: %d\n", command);
3414 return -EINVAL;
3415 }
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03003416
3417 return 0;
3418}
3419
3420static struct xc5000_config s5h1411_xc5000_tunerconfig = {
3421 .i2c_address = 0x64,
3422 .if_khz = 5380,
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03003423};
3424
3425static int xc5000_tuner_attach(struct dvb_usb_adapter *adap)
3426{
Devin Heitmueller79025a92008-10-06 12:07:48 -03003427 /* FIXME: generalize & move to common area */
Michael Krufky77eed212011-09-06 09:31:57 -03003428 adap->fe_adap[0].fe->callback = dib0700_xc5000_tuner_callback;
Devin Heitmueller79025a92008-10-06 12:07:48 -03003429
Michael Krufky77eed212011-09-06 09:31:57 -03003430 return dvb_attach(xc5000_attach, adap->fe_adap[0].fe, &adap->dev->i2c_adap,
Michael Krufky767f3b32008-09-25 09:47:07 -03003431 &s5h1411_xc5000_tunerconfig)
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03003432 == NULL ? -ENODEV : 0;
3433}
3434
Davide Ferri8d009a02009-06-23 22:34:06 -03003435static int dib0700_xc4000_tuner_callback(void *priv, int component,
3436 int command, int arg)
3437{
3438 struct dvb_usb_adapter *adap = priv;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003439 struct dib0700_adapter_state *state = adap->priv;
Davide Ferri8d009a02009-06-23 22:34:06 -03003440
3441 if (command == XC4000_TUNER_RESET) {
3442 /* Reset the tuner */
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003443 state->dib7000p_ops.set_gpio(adap->fe_adap[0].fe, 8, 0, 0);
Davide Ferri8d009a02009-06-23 22:34:06 -03003444 msleep(10);
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003445 state->dib7000p_ops.set_gpio(adap->fe_adap[0].fe, 8, 0, 1);
Davide Ferri8d009a02009-06-23 22:34:06 -03003446 } else {
3447 err("xc4000: unknown tuner callback command: %d\n", command);
3448 return -EINVAL;
3449 }
3450
3451 return 0;
3452}
3453
Devin Heitmueller8583fc82009-07-28 01:16:05 -03003454static struct dibx000_agc_config stk7700p_7000p_xc4000_agc_config = {
3455 .band_caps = BAND_UHF | BAND_VHF,
3456 .setup = 0x64,
3457 .inv_gain = 0x02c8,
3458 .time_stabiliz = 0x15,
3459 .alpha_level = 0x00,
3460 .thlock = 0x76,
3461 .wbd_inv = 0x01,
3462 .wbd_ref = 0x0b33,
3463 .wbd_sel = 0x00,
3464 .wbd_alpha = 0x02,
3465 .agc1_max = 0x00,
3466 .agc1_min = 0x00,
3467 .agc2_max = 0x9b26,
3468 .agc2_min = 0x26ca,
3469 .agc1_pt1 = 0x00,
3470 .agc1_pt2 = 0x00,
3471 .agc1_pt3 = 0x00,
3472 .agc1_slope1 = 0x00,
3473 .agc1_slope2 = 0x00,
3474 .agc2_pt1 = 0x00,
3475 .agc2_pt2 = 0x80,
3476 .agc2_slope1 = 0x1d,
3477 .agc2_slope2 = 0x1d,
Devin Heitmueller2df12512009-12-27 17:44:31 -03003478 .alpha_mant = 0x11,
Devin Heitmueller8583fc82009-07-28 01:16:05 -03003479 .alpha_exp = 0x1b,
3480 .beta_mant = 0x17,
3481 .beta_exp = 0x33,
3482 .perform_agc_softsplit = 0x00,
3483};
3484
Devin Heitmuellerf1c78d32009-10-05 00:34:04 -03003485static struct dibx000_bandwidth_config stk7700p_xc4000_pll_config = {
istvan_v@mailbox.hu341747b2011-06-06 12:54:54 -03003486 60000, 30000, /* internal, sampling */
3487 1, 8, 3, 1, 0, /* pll_cfg: prediv, ratio, range, reset, bypass */
3488 0, 0, 1, 1, 0, /* misc: refdiv, bypclk_div, IO_CLK_en_core, */
3489 /* ADClkSrc, modulo */
3490 (3 << 14) | (1 << 12) | 524, /* sad_cfg: refsel, sel, freq_15k */
3491 39370534, /* ifreq */
3492 20452225, /* timf */
3493 30000000 /* xtal */
Devin Heitmuellerf1c78d32009-10-05 00:34:04 -03003494};
3495
Devin Heitmueller01f16262009-06-24 00:07:01 -03003496/* FIXME: none of these inputs are validated yet */
3497static struct dib7000p_config pctv_340e_config = {
Devin Heitmueller62956ce2009-12-27 18:58:11 -03003498 .output_mpeg2_in_188_bytes = 1,
Devin Heitmueller01f16262009-06-24 00:07:01 -03003499
3500 .agc_config_count = 1,
Devin Heitmueller8583fc82009-07-28 01:16:05 -03003501 .agc = &stk7700p_7000p_xc4000_agc_config,
Devin Heitmuellerf1c78d32009-10-05 00:34:04 -03003502 .bw = &stk7700p_xc4000_pll_config,
Devin Heitmueller01f16262009-06-24 00:07:01 -03003503
Devin Heitmueller01f16262009-06-24 00:07:01 -03003504 .gpio_dir = DIB7000M_GPIO_DEFAULT_DIRECTIONS,
3505 .gpio_val = DIB7000M_GPIO_DEFAULT_VALUES,
3506 .gpio_pwm_pos = DIB7000M_GPIO_DEFAULT_PWM_POS,
3507};
3508
3509/* PCTV 340e GPIOs map:
3510 dib0700:
3511 GPIO2 - CX25843 sleep
3512 GPIO3 - CS5340 reset
3513 GPIO5 - IRD
3514 GPIO6 - Power Supply
3515 GPIO8 - LNA (1=off 0=on)
3516 GPIO10 - CX25843 reset
3517 dib7000:
3518 GPIO8 - xc4000 reset
3519 */
3520static int pctv340e_frontend_attach(struct dvb_usb_adapter *adap)
3521{
3522 struct dib0700_state *st = adap->dev->priv;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003523 struct dib0700_adapter_state *state = adap->priv;
3524
3525 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
3526 return -ENODEV;
Devin Heitmueller01f16262009-06-24 00:07:01 -03003527
3528 /* Power Supply on */
3529 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
3530 msleep(50);
3531 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
3532 msleep(100); /* Allow power supply to settle before probing */
3533
3534 /* cx25843 reset */
3535 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
3536 msleep(1); /* cx25843 datasheet say 350us required */
3537 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
3538
3539 /* LNA off for now */
3540 dib0700_set_gpio(adap->dev, GPIO8, GPIO_OUT, 1);
3541
3542 /* Put the CX25843 to sleep for now since we're in digital mode */
3543 dib0700_set_gpio(adap->dev, GPIO2, GPIO_OUT, 1);
3544
3545 /* FIXME: not verified yet */
3546 dib0700_ctrl_clock(adap->dev, 72, 1);
3547
Devin Heitmueller2750d9c2009-07-20 00:42:33 -03003548 msleep(500);
3549
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003550 if (state->dib7000p_ops.dib7000pc_detection(&adap->dev->i2c_adap) == 0) {
Devin Heitmueller01f16262009-06-24 00:07:01 -03003551 /* Demodulator not found for some reason? */
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003552 dvb_detach(&state->dib7000p_ops);
Devin Heitmueller01f16262009-06-24 00:07:01 -03003553 return -ENODEV;
3554 }
3555
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003556 adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap, 0x12,
Devin Heitmueller01f16262009-06-24 00:07:01 -03003557 &pctv_340e_config);
3558 st->is_dib7000pc = 1;
3559
Michael Krufky77eed212011-09-06 09:31:57 -03003560 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Devin Heitmueller01f16262009-06-24 00:07:01 -03003561}
3562
Devin Heitmueller8583fc82009-07-28 01:16:05 -03003563static struct xc4000_config dib7000p_xc4000_tunerconfig = {
istvan_v@mailbox.hu8edeb6e2011-06-06 13:03:44 -03003564 .i2c_address = 0x61,
3565 .default_pm = 1,
3566 .dvb_amplitude = 0,
3567 .set_smoothedcvbs = 0,
3568 .if_khz = 5400
Davide Ferri8d009a02009-06-23 22:34:06 -03003569};
3570
3571static int xc4000_tuner_attach(struct dvb_usb_adapter *adap)
3572{
Devin Heitmueller59d0c372009-06-29 21:11:02 -03003573 struct i2c_adapter *tun_i2c;
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003574 struct dib0700_adapter_state *state = adap->priv;
Devin Heitmueller59d0c372009-06-29 21:11:02 -03003575
3576 /* The xc4000 is not on the main i2c bus */
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03003577 tun_i2c = state->dib7000p_ops.get_i2c_master(adap->fe_adap[0].fe,
Devin Heitmueller59d0c372009-06-29 21:11:02 -03003578 DIBX000_I2C_INTERFACE_TUNER, 1);
3579 if (tun_i2c == NULL) {
Mauro Carvalho Chehab941830c2011-06-06 16:51:11 -03003580 printk(KERN_ERR "Could not reach tuner i2c bus\n");
Devin Heitmueller59d0c372009-06-29 21:11:02 -03003581 return 0;
3582 }
3583
3584 /* Setup the reset callback */
Michael Krufky77eed212011-09-06 09:31:57 -03003585 adap->fe_adap[0].fe->callback = dib0700_xc4000_tuner_callback;
Davide Ferri8d009a02009-06-23 22:34:06 -03003586
Michael Krufky77eed212011-09-06 09:31:57 -03003587 return dvb_attach(xc4000_attach, adap->fe_adap[0].fe, tun_i2c,
Devin Heitmueller8583fc82009-07-28 01:16:05 -03003588 &dib7000p_xc4000_tunerconfig)
Davide Ferri8d009a02009-06-23 22:34:06 -03003589 == NULL ? -ENODEV : 0;
3590}
3591
Michael Krufkyce904bc2009-01-19 01:12:55 -03003592static struct lgdt3305_config hcw_lgdt3305_config = {
3593 .i2c_addr = 0x0e,
3594 .mpeg_mode = LGDT3305_MPEG_PARALLEL,
3595 .tpclk_edge = LGDT3305_TPCLK_FALLING_EDGE,
3596 .tpvalid_polarity = LGDT3305_TP_VALID_LOW,
3597 .deny_i2c_rptr = 0,
3598 .spectral_inversion = 1,
3599 .qam_if_khz = 6000,
3600 .vsb_if_khz = 6000,
3601 .usref_8vsb = 0x0500,
3602};
3603
3604static struct mxl5007t_config hcw_mxl5007t_config = {
3605 .xtal_freq_hz = MxL_XTAL_25_MHZ,
3606 .if_freq_hz = MxL_IF_6_MHZ,
3607 .invert_if = 1,
3608};
3609
3610/* TIGER-ATSC map:
3611 GPIO0 - LNA_CTR (H: LNA power enabled, L: LNA power disabled)
3612 GPIO1 - ANT_SEL (H: VPA, L: MCX)
3613 GPIO4 - SCL2
3614 GPIO6 - EN_TUNER
3615 GPIO7 - SDA2
3616 GPIO10 - DEM_RST
3617
3618 MXL is behind LG's i2c repeater. LG is on SCL2/SDA2 gpios on the DIB
3619 */
3620static int lgdt3305_frontend_attach(struct dvb_usb_adapter *adap)
3621{
3622 struct dib0700_state *st = adap->dev->priv;
3623
3624 /* Make use of the new i2c functions from FW 1.20 */
3625 st->fw_use_new_i2c_api = 1;
3626
3627 st->disable_streaming_master_mode = 1;
3628
3629 /* fe power enable */
3630 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
3631 msleep(30);
3632 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
3633 msleep(30);
3634
3635 /* demod reset */
3636 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
3637 msleep(30);
3638 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
3639 msleep(30);
3640 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
3641 msleep(30);
3642
Michael Krufky77eed212011-09-06 09:31:57 -03003643 adap->fe_adap[0].fe = dvb_attach(lgdt3305_attach,
Michael Krufkyce904bc2009-01-19 01:12:55 -03003644 &hcw_lgdt3305_config,
3645 &adap->dev->i2c_adap);
3646
Michael Krufky77eed212011-09-06 09:31:57 -03003647 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
Michael Krufkyce904bc2009-01-19 01:12:55 -03003648}
3649
3650static int mxl5007t_tuner_attach(struct dvb_usb_adapter *adap)
3651{
Michael Krufky77eed212011-09-06 09:31:57 -03003652 return dvb_attach(mxl5007t_attach, adap->fe_adap[0].fe,
Michael Krufkyce904bc2009-01-19 01:12:55 -03003653 &adap->dev->i2c_adap, 0x60,
3654 &hcw_mxl5007t_config) == NULL ? -ENODEV : 0;
3655}
3656
3657
Patrick Boettcher01373a52007-07-30 12:49:04 -03003658/* DVB-USB and USB stuff follows */
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003659struct usb_device_id dib0700_usb_id_table[] = {
Patrick Boettcher01373a52007-07-30 12:49:04 -03003660/* 0 */ { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7700P) },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03003661 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7700P_PC) },
3662 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_500) },
3663 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_500_2) },
3664 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_STICK) },
Patrick Boettcher01373a52007-07-30 12:49:04 -03003665/* 5 */ { USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR) },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03003666 { USB_DEVICE(USB_VID_COMPRO, USB_PID_COMPRO_VIDEOMATE_U500) },
3667 { USB_DEVICE(USB_VID_UNIWILL, USB_PID_UNIWILL_STK7700P) },
3668 { USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV_DONGLE_STK7700P) },
3669 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_STICK_2) },
Patrick Boettcher01373a52007-07-30 12:49:04 -03003670/* 10 */{ USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR_2) },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03003671 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV2000E) },
3672 { USB_DEVICE(USB_VID_TERRATEC,
3673 USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY) },
3674 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_TD_STICK) },
3675 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7700D) },
Patrick Boettcher01373a52007-07-30 12:49:04 -03003676/* 15 */{ USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7070P) },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03003677 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV_DVB_T_FLASH) },
3678 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7070PD) },
3679 { USB_DEVICE(USB_VID_PINNACLE,
3680 USB_PID_PINNACLE_PCTV_DUAL_DIVERSITY_DVB_T) },
3681 { USB_DEVICE(USB_VID_COMPRO, USB_PID_COMPRO_VIDEOMATE_U500_PC) },
Joachim Steigerfa3b8772007-10-08 20:08:46 -03003682/* 20 */{ USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_EXPRESS) },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03003683 { USB_DEVICE(USB_VID_GIGABYTE, USB_PID_GIGABYTE_U7000) },
3684 { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC, USB_PID_ARTEC_T14BR) },
3685 { USB_DEVICE(USB_VID_ASUS, USB_PID_ASUS_U3000) },
3686 { USB_DEVICE(USB_VID_ASUS, USB_PID_ASUS_U3100) },
3687/* 25 */{ USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_STICK_3) },
3688 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_MYTV_T) },
3689 { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_HT_USB_XE) },
3690 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_EXPRESSCARD_320CX) },
3691 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV72E) },
3692/* 30 */{ USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV73E) },
3693 { USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_EC372S) },
3694 { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_HT_EXPRESS) },
Alexander Simondc888072008-03-29 21:37:54 -03003695 { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_XXS) },
Darryl Green5da4e2c2008-03-29 21:47:43 -03003696 { USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV_DONGLE_STK7700P_2) },
Michael Krufkyaf2a8872008-09-03 17:12:24 -03003697/* 35 */{ USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_TD_STICK_52009) },
Michael Krufky9a0c04a2008-09-03 17:12:24 -03003698 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_500_3) },
Finn Thain17a370b2008-09-06 13:42:47 -03003699 { USB_DEVICE(USB_VID_GIGABYTE, USB_PID_GIGABYTE_U8000) },
Daniel Oliveira Nascimento8751aaa2008-09-07 12:39:44 -03003700 { USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_STK7700PH) },
Albert Comerma57697432008-09-07 12:43:33 -03003701 { USB_DEVICE(USB_VID_ASUS, USB_PID_ASUS_U3000H) },
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03003702/* 40 */{ USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV801E) },
Devin Heitmuellerd2fc3bf2008-09-25 06:22:23 -03003703 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV801E_SE) },
Yusuf Altinbb1b0822009-01-08 07:58:45 -03003704 { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_EXPRESS) },
Nicolas Fournierdb4b2d12009-01-13 07:15:25 -03003705 { USB_DEVICE(USB_VID_TERRATEC,
3706 USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY_2) },
sebastian.blanes@gmail.com0a6e1ed2009-02-24 14:51:43 -03003707 { USB_DEVICE(USB_VID_SONY, USB_PID_SONY_PLAYTV) },
Pascal Terjan9abb6e62009-02-26 10:31:41 -03003708/* 45 */{ USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_PD378S) },
Michael Krufkyce904bc2009-01-19 01:12:55 -03003709 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_TIGER_ATSC) },
3710 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_TIGER_ATSC_B210) },
Xoan Loureiro16ba1ee2009-03-29 08:43:36 -03003711 { USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_MC770) },
Klaus Flittner919a5482009-03-29 09:12:06 -03003712 { USB_DEVICE(USB_VID_ELGATO, USB_PID_ELGATO_EYETV_DTT) },
Armin Schenker513846e2009-04-20 11:57:49 -03003713/* 50 */{ USB_DEVICE(USB_VID_ELGATO, USB_PID_ELGATO_EYETV_DTT_Dlx) },
tomas petrf0f4ae72009-05-20 05:28:05 -03003714 { USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV_DONGLE_H) },
Patrick Boettchera9b8fe32009-05-20 05:35:02 -03003715 { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_T3) },
3716 { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_T5) },
Pete Hildebrandtc53d83c2009-08-05 11:46:38 -03003717 { USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_STK7700D) },
Olivier Grenie74b76f22009-09-02 08:19:19 -03003718/* 55 */{ USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_STK7700D_2) },
3719 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV73A) },
Patrick Boettchere4147532009-11-30 13:52:57 -03003720 { USB_DEVICE(USB_VID_PCTV, USB_PID_PINNACLE_PCTV73ESE) },
3721 { USB_DEVICE(USB_VID_PCTV, USB_PID_PINNACLE_PCTV282E) },
Olivier Grenied300bd62009-09-15 06:55:35 -03003722 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7770P) },
Patrick Boettcherdb481382009-09-15 07:16:51 -03003723/* 60 */{ USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_XXS_2) },
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03003724 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK807XPVR) },
3725 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK807XP) },
Mauro Carvalho Chehab3bfb3172010-09-03 10:50:24 -03003726 { USB_DEVICE_VER(USB_VID_PIXELVIEW, USB_PID_PIXELVIEW_SBTVD, 0x000, 0x3f00) },
S?rgio Fortier8a378e82009-09-28 04:19:21 -03003727 { USB_DEVICE(USB_VID_EVOLUTEPC, USB_PID_TVWAY_PLUS) },
Patrick Boettcher20232c42009-12-01 12:08:56 -03003728/* 65 */{ USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV73ESE) },
Patrick Boettchere4147532009-11-30 13:52:57 -03003729 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV282E) },
Olivier Grenie03245a52009-12-04 13:27:57 -03003730 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK8096GP) },
Michael Müller84e2f032010-04-26 22:18:57 -03003731 { USB_DEVICE(USB_VID_ELGATO, USB_PID_ELGATO_EYETV_DIVERSITY) },
Olivier Greniebe9bae12011-01-04 05:42:19 -03003732 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_NIM9090M) },
3733/* 70 */{ USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_NIM8096MD) },
3734 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_NIM9090MD) },
3735 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_NIM7090) },
3736 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_TFE7090PVR) },
Lukas Max Fisch498e6772011-02-08 16:51:45 -03003737 { USB_DEVICE(USB_VID_TECHNISAT, USB_PID_TECHNISAT_AIRSTAR_TELESTICK_2) },
Stéphane Elmalehd1402302011-05-21 07:33:38 -03003738/* 75 */{ USB_DEVICE(USB_VID_MEDION, USB_PID_CREATIX_CTX1921) },
Davide Ferri8d009a02009-06-23 22:34:06 -03003739 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV340E) },
Devin Heitmueller33fb1682009-06-23 22:48:02 -03003740 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV340E_SE) },
Olivier Grenief45f5132012-12-31 09:47:10 -03003741 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_TFE7790P) },
3742 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_TFE8096P) },
3743/* 80 */{ USB_DEVICE(USB_VID_ELGATO, USB_PID_ELGATO_EYETV_DTT_2) },
Michael Krufkyc859e6e2013-06-30 12:43:58 -03003744 { USB_DEVICE(USB_VID_PCTV, USB_PID_PCTV_2002E) },
3745 { USB_DEVICE(USB_VID_PCTV, USB_PID_PCTV_2002E_SE) },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03003746 { 0 } /* Terminating entry */
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003747};
3748MODULE_DEVICE_TABLE(usb, dib0700_usb_id_table);
3749
3750#define DIB0700_DEFAULT_DEVICE_PROPERTIES \
3751 .caps = DVB_USB_IS_AN_I2C_ADAPTER, \
3752 .usb_ctrl = DEVICE_SPECIFIC, \
Devin Heitmuellerbdc203e2008-09-06 13:45:27 -03003753 .firmware = "dvb-usb-dib0700-1.20.fw", \
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003754 .download_firmware = dib0700_download_firmware, \
Patrick Boettcher6958eff2006-09-19 12:51:40 -03003755 .no_reconnect = 1, \
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003756 .size_of_priv = sizeof(struct dib0700_state), \
Patrick Boettcher6958eff2006-09-19 12:51:40 -03003757 .i2c_algo = &dib0700_i2c_algo, \
3758 .identify_state = dib0700_identify_state
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003759
3760#define DIB0700_DEFAULT_STREAMING_CONFIG(ep) \
3761 .streaming_ctrl = dib0700_streaming_ctrl, \
3762 .stream = { \
3763 .type = USB_BULK, \
3764 .count = 4, \
3765 .endpoint = ep, \
3766 .u = { \
3767 .bulk = { \
3768 .buffersize = 39480, \
3769 } \
3770 } \
3771 }
3772
3773struct dvb_usb_device_properties dib0700_devices[] = {
3774 {
3775 DIB0700_DEFAULT_DEVICE_PROPERTIES,
3776
3777 .num_adapters = 1,
3778 .adapter = {
3779 {
Michael Krufky77eed212011-09-06 09:31:57 -03003780 .num_frontends = 1,
3781 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03003782 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
3783 .pid_filter_count = 32,
Olivier Greniee192a7c2011-01-14 13:58:59 -03003784 .pid_filter = stk7700p_pid_filter,
3785 .pid_filter_ctrl = stk7700p_pid_filter_ctrl,
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003786 .frontend_attach = stk7700p_frontend_attach,
3787 .tuner_attach = stk7700p_tuner_attach,
3788
3789 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03003790 }},
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003791 },
3792 },
3793
dominik67053a42007-11-10 19:23:31 -03003794 .num_device_descs = 8,
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003795 .devices = {
3796 { "DiBcom STK7700P reference design",
Tomi Koivulahti49a13762006-10-19 07:27:19 -03003797 { &dib0700_usb_id_table[0], &dib0700_usb_id_table[1] },
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003798 { NULL },
3799 },
3800 { "Hauppauge Nova-T Stick",
Stefan Trabyf9aeba42006-11-12 13:02:51 -03003801 { &dib0700_usb_id_table[4], &dib0700_usb_id_table[9], NULL },
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003802 { NULL },
3803 },
Tomi Koivulahti49a13762006-10-19 07:27:19 -03003804 { "AVerMedia AVerTV DVB-T Volar",
Jose Carlos Garcia Sogoced8fec2006-11-14 05:01:47 -03003805 { &dib0700_usb_id_table[5], &dib0700_usb_id_table[10] },
Tomi Koivulahti49a13762006-10-19 07:27:19 -03003806 { NULL },
3807 },
3808 { "Compro Videomate U500",
Patrick Boettcher1f8ca4b2007-07-30 14:24:37 -03003809 { &dib0700_usb_id_table[6], &dib0700_usb_id_table[19] },
Tomi Koivulahti49a13762006-10-19 07:27:19 -03003810 { NULL },
Henning Schroeer0ce215e2006-10-19 07:58:22 -03003811 },
3812 { "Uniwill STK7700P based (Hama and others)",
3813 { &dib0700_usb_id_table[7], NULL },
3814 { NULL },
Michael Krufky8637a872006-11-08 16:47:32 -03003815 },
3816 { "Leadtek Winfast DTV Dongle (STK7700P based)",
Patrick Boettcher1e13c8f2009-09-19 05:24:40 -03003817 { &dib0700_usb_id_table[8], &dib0700_usb_id_table[34] },
Michael Krufky8637a872006-11-08 16:47:32 -03003818 { NULL },
Joachim Steigerfa3b8772007-10-08 20:08:46 -03003819 },
3820 { "AVerMedia AVerTV DVB-T Express",
3821 { &dib0700_usb_id_table[20] },
3822 { NULL },
dominik67053a42007-11-10 19:23:31 -03003823 },
dominik67053a42007-11-10 19:23:31 -03003824 { "Gigabyte U7000",
3825 { &dib0700_usb_id_table[21], NULL },
3826 { NULL },
Tomi Koivulahti49a13762006-10-19 07:27:19 -03003827 }
Darren Saltb1139e32007-08-18 18:05:31 -03003828 },
3829
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03003830 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03003831 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03003832 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03003833 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03003834 .allowed_protos = RC_BIT_RC5 |
3835 RC_BIT_RC6_MCE |
3836 RC_BIT_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03003837 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03003838 },
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003839 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
3840
3841 .num_adapters = 2,
3842 .adapter = {
3843 {
Michael Krufky77eed212011-09-06 09:31:57 -03003844 .num_frontends = 1,
3845 .fe = {{
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003846 .frontend_attach = bristol_frontend_attach,
3847 .tuner_attach = bristol_tuner_attach,
3848
3849 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03003850 }},
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003851 }, {
Michael Krufky77eed212011-09-06 09:31:57 -03003852 .num_frontends = 1,
3853 .fe = {{
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003854 .frontend_attach = bristol_frontend_attach,
3855 .tuner_attach = bristol_tuner_attach,
3856
3857 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
Michael Krufky77eed212011-09-06 09:31:57 -03003858 }},
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003859 }
3860 },
3861
3862 .num_device_descs = 1,
3863 .devices = {
3864 { "Hauppauge Nova-T 500 Dual DVB-T",
Tomi Koivulahti49a13762006-10-19 07:27:19 -03003865 { &dib0700_usb_id_table[2], &dib0700_usb_id_table[3], NULL },
Patrick Boettcherb7f54912006-09-19 12:51:37 -03003866 { NULL },
3867 },
Janne Grunau82f3d552007-07-30 13:50:28 -03003868 },
3869
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03003870 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03003871 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03003872 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03003873 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03003874 .allowed_protos = RC_BIT_RC5 |
3875 RC_BIT_RC6_MCE |
3876 RC_BIT_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03003877 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03003878 },
Olivier DANET54d75eb2007-07-25 14:42:54 -03003879 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
3880
3881 .num_adapters = 2,
3882 .adapter = {
3883 {
Michael Krufky77eed212011-09-06 09:31:57 -03003884 .num_frontends = 1,
3885 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03003886 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
3887 .pid_filter_count = 32,
3888 .pid_filter = stk70x0p_pid_filter,
3889 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
Olivier DANET54d75eb2007-07-25 14:42:54 -03003890 .frontend_attach = stk7700d_frontend_attach,
3891 .tuner_attach = stk7700d_tuner_attach,
3892
3893 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03003894 }},
Olivier DANET54d75eb2007-07-25 14:42:54 -03003895 }, {
Michael Krufky77eed212011-09-06 09:31:57 -03003896 .num_frontends = 1,
3897 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03003898 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
3899 .pid_filter_count = 32,
3900 .pid_filter = stk70x0p_pid_filter,
3901 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
Olivier DANET54d75eb2007-07-25 14:42:54 -03003902 .frontend_attach = stk7700d_frontend_attach,
3903 .tuner_attach = stk7700d_tuner_attach,
3904
3905 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
Michael Krufky77eed212011-09-06 09:31:57 -03003906 }},
Olivier DANET54d75eb2007-07-25 14:42:54 -03003907 }
3908 },
3909
James A Webb200e8612009-08-04 02:38:05 -03003910 .num_device_descs = 5,
Olivier DANET54d75eb2007-07-25 14:42:54 -03003911 .devices = {
3912 { "Pinnacle PCTV 2000e",
3913 { &dib0700_usb_id_table[11], NULL },
3914 { NULL },
3915 },
3916 { "Terratec Cinergy DT XS Diversity",
3917 { &dib0700_usb_id_table[12], NULL },
3918 { NULL },
3919 },
Darren Saltfaebb912007-08-18 18:04:00 -03003920 { "Hauppauge Nova-TD Stick/Elgato Eye-TV Diversity",
Olivier DANET54d75eb2007-07-25 14:42:54 -03003921 { &dib0700_usb_id_table[13], NULL },
3922 { NULL },
3923 },
Patrick Boettcher01373a52007-07-30 12:49:04 -03003924 { "DiBcom STK7700D reference design",
Patrick Boettcherb6884a12007-07-27 10:08:51 -03003925 { &dib0700_usb_id_table[14], NULL },
3926 { NULL },
Yusuf Altinbb1b0822009-01-08 07:58:45 -03003927 },
James A Webb200e8612009-08-04 02:38:05 -03003928 { "YUAN High-Tech DiBcom STK7700D",
3929 { &dib0700_usb_id_table[55], NULL },
3930 { NULL },
3931 },
Yusuf Altinbb1b0822009-01-08 07:58:45 -03003932
Olivier DANET54d75eb2007-07-25 14:42:54 -03003933 },
Janne Grunau82f3d552007-07-30 13:50:28 -03003934
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03003935 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03003936 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03003937 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03003938 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03003939 .allowed_protos = RC_BIT_RC5 |
3940 RC_BIT_RC6_MCE |
3941 RC_BIT_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03003942 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03003943 },
Patrick Boettcher01373a52007-07-30 12:49:04 -03003944 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
3945
3946 .num_adapters = 1,
3947 .adapter = {
3948 {
Michael Krufky77eed212011-09-06 09:31:57 -03003949 .num_frontends = 1,
3950 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03003951 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
3952 .pid_filter_count = 32,
3953 .pid_filter = stk70x0p_pid_filter,
3954 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
Daniel Gimpelevich132c3182008-01-25 06:02:42 -03003955 .frontend_attach = stk7700P2_frontend_attach,
3956 .tuner_attach = stk7700d_tuner_attach,
3957
3958 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03003959 }},
Daniel Gimpelevich132c3182008-01-25 06:02:42 -03003960 },
3961 },
3962
Yusuf Altinbb1b0822009-01-08 07:58:45 -03003963 .num_device_descs = 3,
Daniel Gimpelevich132c3182008-01-25 06:02:42 -03003964 .devices = {
3965 { "ASUS My Cinema U3000 Mini DVBT Tuner",
3966 { &dib0700_usb_id_table[23], NULL },
3967 { NULL },
3968 },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03003969 { "Yuan EC372S",
3970 { &dib0700_usb_id_table[31], NULL },
3971 { NULL },
Yusuf Altinbb1b0822009-01-08 07:58:45 -03003972 },
3973 { "Terratec Cinergy T Express",
3974 { &dib0700_usb_id_table[42], NULL },
3975 { NULL },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03003976 }
Chris Rankin48aa7392008-09-25 06:52:24 -03003977 },
3978
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03003979 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03003980 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03003981 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03003982 .module_name = "dib0700",
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03003983 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03003984 .allowed_protos = RC_BIT_RC5 |
3985 RC_BIT_RC6_MCE |
3986 RC_BIT_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03003987 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03003988 },
Daniel Gimpelevich132c3182008-01-25 06:02:42 -03003989 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
3990
3991 .num_adapters = 1,
3992 .adapter = {
3993 {
Michael Krufky77eed212011-09-06 09:31:57 -03003994 .num_frontends = 1,
3995 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03003996 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
3997 .pid_filter_count = 32,
3998 .pid_filter = stk70x0p_pid_filter,
3999 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
Patrick Boettcher01373a52007-07-30 12:49:04 -03004000 .frontend_attach = stk7070p_frontend_attach,
4001 .tuner_attach = dib7070p_tuner_attach,
4002
4003 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004004 }},
Patrick Boettcher01373a52007-07-30 12:49:04 -03004005 .size_of_priv = sizeof(struct dib0700_adapter_state),
4006 },
4007 },
4008
Gianluca Gennari0bc9d392012-04-14 09:14:07 -03004009 .num_device_descs = 12,
Patrick Boettcher01373a52007-07-30 12:49:04 -03004010 .devices = {
4011 { "DiBcom STK7070P reference design",
4012 { &dib0700_usb_id_table[15], NULL },
4013 { NULL },
4014 },
4015 { "Pinnacle PCTV DVB-T Flash Stick",
4016 { &dib0700_usb_id_table[16], NULL },
4017 { NULL },
4018 },
Yousef Lamlum7999a812008-01-25 05:51:48 -03004019 { "Artec T14BR DVB-T",
4020 { &dib0700_usb_id_table[22], NULL },
4021 { NULL },
Daniel Gimpelevich132c3182008-01-25 06:02:42 -03004022 },
4023 { "ASUS My Cinema U3100 Mini DVBT Tuner",
4024 { &dib0700_usb_id_table[24], NULL },
4025 { NULL },
4026 },
Tim Taubertc7637b12008-01-25 06:16:36 -03004027 { "Hauppauge Nova-T Stick",
4028 { &dib0700_usb_id_table[25], NULL },
4029 { NULL },
4030 },
Darren Salt13b83b52008-01-25 06:20:02 -03004031 { "Hauppauge Nova-T MyTV.t",
4032 { &dib0700_usb_id_table[26], NULL },
4033 { NULL },
4034 },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03004035 { "Pinnacle PCTV 72e",
4036 { &dib0700_usb_id_table[29], NULL },
4037 { NULL },
4038 },
4039 { "Pinnacle PCTV 73e",
4040 { &dib0700_usb_id_table[30], NULL },
4041 { NULL },
4042 },
Klaus Flittner919a5482009-03-29 09:12:06 -03004043 { "Elgato EyeTV DTT",
4044 { &dib0700_usb_id_table[49], NULL },
4045 { NULL },
4046 },
Pascal Terjan9abb6e62009-02-26 10:31:41 -03004047 { "Yuan PD378S",
4048 { &dib0700_usb_id_table[45], NULL },
4049 { NULL },
4050 },
Armin Schenker513846e2009-04-20 11:57:49 -03004051 { "Elgato EyeTV Dtt Dlx PD378S",
4052 { &dib0700_usb_id_table[50], NULL },
4053 { NULL },
4054 },
Gianluca Gennari0bc9d392012-04-14 09:14:07 -03004055 { "Elgato EyeTV DTT rev. 2",
Olivier Grenief45f5132012-12-31 09:47:10 -03004056 { &dib0700_usb_id_table[80], NULL },
Gianluca Gennari0bc9d392012-04-14 09:14:07 -03004057 { NULL },
4058 },
Tim Taubertc7637b12008-01-25 06:16:36 -03004059 },
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 },
Patrick Boettcher01373a52007-07-30 12:49:04 -03004071 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4072
Olivier Grenie74b76f22009-09-02 08:19:19 -03004073 .num_adapters = 1,
4074 .adapter = {
4075 {
Michael Krufky77eed212011-09-06 09:31:57 -03004076 .num_frontends = 1,
4077 .fe = {{
Mauro Carvalho Chehab648732f2009-11-04 12:11:43 -02004078 .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,
Olivier Grenie74b76f22009-09-02 08:19:19 -03004082 .frontend_attach = stk7070p_frontend_attach,
4083 .tuner_attach = dib7070p_tuner_attach,
4084
4085 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004086 }},
Olivier Grenie74b76f22009-09-02 08:19:19 -03004087 .size_of_priv = sizeof(struct dib0700_adapter_state),
4088 },
4089 },
4090
Patrick Boettcher20232c42009-12-01 12:08:56 -03004091 .num_device_descs = 3,
Olivier Grenie74b76f22009-09-02 08:19:19 -03004092 .devices = {
4093 { "Pinnacle PCTV 73A",
4094 { &dib0700_usb_id_table[56], NULL },
4095 { NULL },
4096 },
4097 { "Pinnacle PCTV 73e SE",
Patrick Boettcher20232c42009-12-01 12:08:56 -03004098 { &dib0700_usb_id_table[57], &dib0700_usb_id_table[65], NULL },
Olivier Grenie74b76f22009-09-02 08:19:19 -03004099 { NULL },
4100 },
4101 { "Pinnacle PCTV 282e",
Patrick Boettcher20232c42009-12-01 12:08:56 -03004102 { &dib0700_usb_id_table[58], &dib0700_usb_id_table[66], NULL },
Olivier Grenie74b76f22009-09-02 08:19:19 -03004103 { NULL },
4104 },
4105 },
4106
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004107 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004108 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004109 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004110 .module_name = "dib0700",
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03004111 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004112 .allowed_protos = RC_BIT_RC5 |
4113 RC_BIT_RC6_MCE |
4114 RC_BIT_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03004115 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004116 },
Olivier Grenie74b76f22009-09-02 08:19:19 -03004117 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4118
Patrick Boettcher01373a52007-07-30 12:49:04 -03004119 .num_adapters = 2,
4120 .adapter = {
4121 {
Michael Krufky77eed212011-09-06 09:31:57 -03004122 .num_frontends = 1,
4123 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03004124 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4125 .pid_filter_count = 32,
4126 .pid_filter = stk70x0p_pid_filter,
4127 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
Jiri Slaby2b05b882012-01-10 14:11:24 -03004128 .frontend_attach = novatd_frontend_attach,
Patrick Boettcher01373a52007-07-30 12:49:04 -03004129 .tuner_attach = dib7070p_tuner_attach,
4130
4131 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004132 }},
Patrick Boettcher01373a52007-07-30 12:49:04 -03004133 .size_of_priv = sizeof(struct dib0700_adapter_state),
4134 }, {
Michael Krufky77eed212011-09-06 09:31:57 -03004135 .num_frontends = 1,
4136 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03004137 .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,
Jiri Slaby2b05b882012-01-10 14:11:24 -03004141 .frontend_attach = novatd_frontend_attach,
Patrick Boettcher01373a52007-07-30 12:49:04 -03004142 .tuner_attach = dib7070p_tuner_attach,
4143
4144 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
Michael Krufky77eed212011-09-06 09:31:57 -03004145 }},
Patrick Boettcher01373a52007-07-30 12:49:04 -03004146 .size_of_priv = sizeof(struct dib0700_adapter_state),
4147 }
4148 },
4149
Michael Krufkyc859e6e2013-06-30 12:43:58 -03004150 .num_device_descs = 3,
Jiri Slaby9b6ba572012-01-10 14:11:22 -03004151 .devices = {
4152 { "Hauppauge Nova-TD Stick (52009)",
4153 { &dib0700_usb_id_table[35], NULL },
4154 { NULL },
4155 },
Michael Krufkyc859e6e2013-06-30 12:43:58 -03004156 { "PCTV 2002e",
4157 { &dib0700_usb_id_table[81], NULL },
4158 { NULL },
4159 },
4160 { "PCTV 2002e SE",
4161 { &dib0700_usb_id_table[82], NULL },
4162 { NULL },
4163 },
Jiri Slaby9b6ba572012-01-10 14:11:22 -03004164 },
4165
4166 .rc.core = {
4167 .rc_interval = DEFAULT_RC_INTERVAL,
4168 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4169 .module_name = "dib0700",
4170 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004171 .allowed_protos = RC_BIT_RC5 |
4172 RC_BIT_RC6_MCE |
4173 RC_BIT_NEC,
Jiri Slaby9b6ba572012-01-10 14:11:22 -03004174 .change_protocol = dib0700_change_protocol,
4175 },
4176 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4177
4178 .num_adapters = 2,
4179 .adapter = {
4180 {
4181 .num_frontends = 1,
4182 .fe = {{
4183 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4184 .pid_filter_count = 32,
4185 .pid_filter = stk70x0p_pid_filter,
4186 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
4187 .frontend_attach = stk7070pd_frontend_attach0,
4188 .tuner_attach = dib7070p_tuner_attach,
4189
4190 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
4191 }},
4192 .size_of_priv = sizeof(struct dib0700_adapter_state),
4193 }, {
4194 .num_frontends = 1,
4195 .fe = {{
4196 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4197 .pid_filter_count = 32,
4198 .pid_filter = stk70x0p_pid_filter,
4199 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
4200 .frontend_attach = stk7070pd_frontend_attach1,
4201 .tuner_attach = dib7070p_tuner_attach,
4202
4203 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
4204 }},
4205 .size_of_priv = sizeof(struct dib0700_adapter_state),
4206 }
4207 },
4208
4209 .num_device_descs = 5,
Patrick Boettcher01373a52007-07-30 12:49:04 -03004210 .devices = {
4211 { "DiBcom STK7070PD reference design",
4212 { &dib0700_usb_id_table[17], NULL },
4213 { NULL },
4214 },
4215 { "Pinnacle PCTV Dual DVB-T Diversity Stick",
4216 { &dib0700_usb_id_table[18], NULL },
4217 { NULL },
Michael Krufkyd01eb2d2008-07-03 23:43:36 -03004218 },
Michael Krufky9a0c04a2008-09-03 17:12:24 -03004219 { "Hauppauge Nova-TD-500 (84xxx)",
4220 { &dib0700_usb_id_table[36], NULL },
4221 { NULL },
Nicolas Fournierdb4b2d12009-01-13 07:15:25 -03004222 },
Patrick Boettchera9b8fe32009-05-20 05:35:02 -03004223 { "Terratec Cinergy DT USB XS Diversity/ T5",
4224 { &dib0700_usb_id_table[43],
4225 &dib0700_usb_id_table[53], NULL},
Nicolas Fournierdb4b2d12009-01-13 07:15:25 -03004226 { NULL },
sebastian.blanes@gmail.com0a6e1ed2009-02-24 14:51:43 -03004227 },
4228 { "Sony PlayTV",
4229 { &dib0700_usb_id_table[44], NULL },
4230 { NULL },
Michael Müller84e2f032010-04-26 22:18:57 -03004231 },
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004232 },
4233
4234 .rc.core = {
4235 .rc_interval = DEFAULT_RC_INTERVAL,
4236 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4237 .module_name = "dib0700",
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03004238 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004239 .allowed_protos = RC_BIT_RC5 |
4240 RC_BIT_RC6_MCE |
4241 RC_BIT_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03004242 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004243 },
4244 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4245
4246 .num_adapters = 2,
4247 .adapter = {
4248 {
Michael Krufky77eed212011-09-06 09:31:57 -03004249 .num_frontends = 1,
4250 .fe = {{
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004251 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4252 .pid_filter_count = 32,
4253 .pid_filter = stk70x0p_pid_filter,
4254 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
4255 .frontend_attach = stk7070pd_frontend_attach0,
4256 .tuner_attach = dib7070p_tuner_attach,
4257
4258 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004259 }},
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004260 .size_of_priv = sizeof(struct dib0700_adapter_state),
4261 }, {
Michael Krufky77eed212011-09-06 09:31:57 -03004262 .num_frontends = 1,
4263 .fe = {{
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004264 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4265 .pid_filter_count = 32,
4266 .pid_filter = stk70x0p_pid_filter,
4267 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
4268 .frontend_attach = stk7070pd_frontend_attach1,
4269 .tuner_attach = dib7070p_tuner_attach,
4270
4271 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
Michael Krufky77eed212011-09-06 09:31:57 -03004272 }},
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004273 .size_of_priv = sizeof(struct dib0700_adapter_state),
4274 }
4275 },
4276
4277 .num_device_descs = 1,
4278 .devices = {
Michael Müller84e2f032010-04-26 22:18:57 -03004279 { "Elgato EyeTV Diversity",
4280 { &dib0700_usb_id_table[68], NULL },
4281 { NULL },
4282 },
Arne Luehrsc985a8d2009-01-21 01:37:20 -03004283 },
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004284
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004285 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004286 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004287 .rc_codes = RC_MAP_DIB0700_NEC_TABLE,
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004288 .module_name = "dib0700",
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03004289 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004290 .allowed_protos = RC_BIT_RC5 |
4291 RC_BIT_RC6_MCE |
4292 RC_BIT_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03004293 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004294 },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03004295 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4296
4297 .num_adapters = 1,
4298 .adapter = {
4299 {
Michael Krufky77eed212011-09-06 09:31:57 -03004300 .num_frontends = 1,
4301 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03004302 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4303 .pid_filter_count = 32,
4304 .pid_filter = stk70x0p_pid_filter,
4305 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03004306 .frontend_attach = stk7700ph_frontend_attach,
4307 .tuner_attach = stk7700ph_tuner_attach,
4308
4309 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004310 }},
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03004311 .size_of_priv = sizeof(struct
4312 dib0700_adapter_state),
4313 },
4314 },
4315
Pete Hildebrandtc53d83c2009-08-05 11:46:38 -03004316 .num_device_descs = 9,
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03004317 .devices = {
4318 { "Terratec Cinergy HT USB XE",
4319 { &dib0700_usb_id_table[27], NULL },
4320 { NULL },
4321 },
4322 { "Pinnacle Expresscard 320cx",
4323 { &dib0700_usb_id_table[28], NULL },
4324 { NULL },
4325 },
4326 { "Terratec Cinergy HT Express",
4327 { &dib0700_usb_id_table[32], NULL },
4328 { NULL },
4329 },
Finn Thain17a370b2008-09-06 13:42:47 -03004330 { "Gigabyte U8000-RH",
4331 { &dib0700_usb_id_table[37], NULL },
4332 { NULL },
4333 },
Daniel Oliveira Nascimento8751aaa2008-09-07 12:39:44 -03004334 { "YUAN High-Tech STK7700PH",
4335 { &dib0700_usb_id_table[38], NULL },
4336 { NULL },
4337 },
Albert Comerma57697432008-09-07 12:43:33 -03004338 { "Asus My Cinema-U3000Hybrid",
4339 { &dib0700_usb_id_table[39], NULL },
4340 { NULL },
4341 },
Xoan Loureiro16ba1ee2009-03-29 08:43:36 -03004342 { "YUAN High-Tech MC770",
4343 { &dib0700_usb_id_table[48], NULL },
4344 { NULL },
4345 },
tomas petrf0f4ae72009-05-20 05:28:05 -03004346 { "Leadtek WinFast DTV Dongle H",
4347 { &dib0700_usb_id_table[51], NULL },
4348 { NULL },
4349 },
Pete Hildebrandtc53d83c2009-08-05 11:46:38 -03004350 { "YUAN High-Tech STK7700D",
4351 { &dib0700_usb_id_table[54], NULL },
4352 { NULL },
4353 },
Albert Comerma6ca8f0b2008-03-29 21:35:57 -03004354 },
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004355
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004356 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004357 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004358 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004359 .module_name = "dib0700",
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03004360 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004361 .allowed_protos = RC_BIT_RC5 |
4362 RC_BIT_RC6_MCE |
4363 RC_BIT_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03004364 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004365 },
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03004366 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4367 .num_adapters = 1,
4368 .adapter = {
4369 {
Michael Krufky77eed212011-09-06 09:31:57 -03004370 .num_frontends = 1,
4371 .fe = {{
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03004372 .frontend_attach = s5h1411_frontend_attach,
4373 .tuner_attach = xc5000_tuner_attach,
4374
4375 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004376 }},
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03004377 .size_of_priv = sizeof(struct
4378 dib0700_adapter_state),
4379 },
4380 },
4381
Devin Heitmuellerd2fc3bf2008-09-25 06:22:23 -03004382 .num_device_descs = 2,
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03004383 .devices = {
4384 { "Pinnacle PCTV HD Pro USB Stick",
4385 { &dib0700_usb_id_table[40], NULL },
4386 { NULL },
4387 },
Devin Heitmuellerd2fc3bf2008-09-25 06:22:23 -03004388 { "Pinnacle PCTV HD USB Stick",
4389 { &dib0700_usb_id_table[41], NULL },
4390 { NULL },
4391 },
Devin Heitmuellercb22cb52008-09-08 05:42:42 -03004392 },
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004393
4394 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004395 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004396 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004397 .module_name = "dib0700",
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03004398 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004399 .allowed_protos = RC_BIT_RC5 |
4400 RC_BIT_RC6_MCE |
4401 RC_BIT_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03004402 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004403 },
Michael Krufkyce904bc2009-01-19 01:12:55 -03004404 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4405 .num_adapters = 1,
4406 .adapter = {
4407 {
Michael Krufky77eed212011-09-06 09:31:57 -03004408 .num_frontends = 1,
4409 .fe = {{
Michael Krufkyce904bc2009-01-19 01:12:55 -03004410 .frontend_attach = lgdt3305_frontend_attach,
4411 .tuner_attach = mxl5007t_tuner_attach,
4412
4413 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004414 }},
Michael Krufkyce904bc2009-01-19 01:12:55 -03004415 .size_of_priv = sizeof(struct
4416 dib0700_adapter_state),
4417 },
4418 },
4419
4420 .num_device_descs = 2,
4421 .devices = {
4422 { "Hauppauge ATSC MiniCard (B200)",
4423 { &dib0700_usb_id_table[46], NULL },
4424 { NULL },
4425 },
4426 { "Hauppauge ATSC MiniCard (B210)",
4427 { &dib0700_usb_id_table[47], NULL },
4428 { NULL },
4429 },
4430 },
Olivier Grenied300bd62009-09-15 06:55:35 -03004431 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4432
4433 .num_adapters = 1,
4434 .adapter = {
4435 {
Michael Krufky77eed212011-09-06 09:31:57 -03004436 .num_frontends = 1,
4437 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03004438 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4439 .pid_filter_count = 32,
4440 .pid_filter = stk70x0p_pid_filter,
4441 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
Olivier Grenie90e12ce2010-09-07 12:50:45 -03004442 .frontend_attach = stk7770p_frontend_attach,
Olivier Grenied300bd62009-09-15 06:55:35 -03004443 .tuner_attach = dib7770p_tuner_attach,
4444
4445 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004446 }},
Olivier Grenied300bd62009-09-15 06:55:35 -03004447 .size_of_priv =
Patrick Boettcherdb481382009-09-15 07:16:51 -03004448 sizeof(struct dib0700_adapter_state),
Olivier Grenied300bd62009-09-15 06:55:35 -03004449 },
4450 },
4451
Stéphane Elmalehd1402302011-05-21 07:33:38 -03004452 .num_device_descs = 4,
Olivier Grenied300bd62009-09-15 06:55:35 -03004453 .devices = {
4454 { "DiBcom STK7770P reference design",
4455 { &dib0700_usb_id_table[59], NULL },
4456 { NULL },
4457 },
Patrick Boettcher1e13c8f2009-09-19 05:24:40 -03004458 { "Terratec Cinergy T USB XXS (HD)/ T3",
4459 { &dib0700_usb_id_table[33],
4460 &dib0700_usb_id_table[52],
4461 &dib0700_usb_id_table[60], NULL},
Patrick Boettcherdb481382009-09-15 07:16:51 -03004462 { NULL },
4463 },
Lukas Max Fisch498e6772011-02-08 16:51:45 -03004464 { "TechniSat AirStar TeleStick 2",
4465 { &dib0700_usb_id_table[74], NULL },
4466 { NULL },
4467 },
Stéphane Elmalehd1402302011-05-21 07:33:38 -03004468 { "Medion CTX1921 DVB-T USB",
4469 { &dib0700_usb_id_table[75], NULL },
4470 { NULL },
4471 },
Olivier Grenied300bd62009-09-15 06:55:35 -03004472 },
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004473
4474 .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_RC5_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 = 1,
4486 .adapter = {
4487 {
Michael Krufky77eed212011-09-06 09:31:57 -03004488 .num_frontends = 1,
4489 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03004490 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4491 .pid_filter_count = 32,
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 = stk807x_frontend_attach,
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 },
4503
S?rgio Fortier8a378e82009-09-28 04:19:21 -03004504 .num_device_descs = 3,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03004505 .devices = {
4506 { "DiBcom STK807xP reference design",
4507 { &dib0700_usb_id_table[62], NULL },
4508 { NULL },
4509 },
Mauro Carvalho Chehabaaeab302009-09-16 09:18:26 -03004510 { "Prolink Pixelview SBTVD",
4511 { &dib0700_usb_id_table[63], NULL },
4512 { NULL },
4513 },
S?rgio Fortier8a378e82009-09-28 04:19:21 -03004514 { "EvolutePC TVWay+",
4515 { &dib0700_usb_id_table[64], NULL },
4516 { NULL },
4517 },
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03004518 },
4519
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004520 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004521 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004522 .rc_codes = RC_MAP_DIB0700_NEC_TABLE,
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004523 .module_name = "dib0700",
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03004524 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004525 .allowed_protos = RC_BIT_RC5 |
4526 RC_BIT_RC6_MCE |
4527 RC_BIT_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03004528 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004529 },
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03004530 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4531 .num_adapters = 2,
4532 .adapter = {
4533 {
Michael Krufky77eed212011-09-06 09:31:57 -03004534 .num_frontends = 1,
4535 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03004536 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4537 .pid_filter_count = 32,
Olivier Grenie03245a52009-12-04 13:27:57 -03004538 .pid_filter = stk80xx_pid_filter,
4539 .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03004540 .frontend_attach = stk807xpvr_frontend_attach0,
4541 .tuner_attach = dib807x_tuner_attach,
4542
4543 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004544 }},
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03004545 .size_of_priv =
4546 sizeof(struct dib0700_adapter_state),
4547 },
4548 {
Michael Krufky77eed212011-09-06 09:31:57 -03004549 .num_frontends = 1,
4550 .fe = {{
Olivier Grenief8731f42009-09-18 04:08:43 -03004551 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4552 .pid_filter_count = 32,
Olivier Grenie03245a52009-12-04 13:27:57 -03004553 .pid_filter = stk80xx_pid_filter,
4554 .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03004555 .frontend_attach = stk807xpvr_frontend_attach1,
4556 .tuner_attach = dib807x_tuner_attach,
4557
4558 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
Michael Krufky77eed212011-09-06 09:31:57 -03004559 }},
Patrick Boettcherba3fe3a2009-09-16 09:51:30 -03004560 .size_of_priv =
4561 sizeof(struct dib0700_adapter_state),
4562 },
4563 },
4564
4565 .num_device_descs = 1,
4566 .devices = {
4567 { "DiBcom STK807xPVR reference design",
4568 { &dib0700_usb_id_table[61], NULL },
4569 { NULL },
4570 },
4571 },
4572
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004573 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004574 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004575 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004576 .module_name = "dib0700",
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03004577 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004578 .allowed_protos = RC_BIT_RC5 |
4579 RC_BIT_RC6_MCE |
4580 RC_BIT_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03004581 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004582 },
Olivier Grenie03245a52009-12-04 13:27:57 -03004583 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4584 .num_adapters = 1,
4585 .adapter = {
4586 {
Michael Krufky77eed212011-09-06 09:31:57 -03004587 .num_frontends = 1,
4588 .fe = {{
Olivier Grenie03245a52009-12-04 13:27:57 -03004589 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
4590 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4591 .pid_filter_count = 32,
4592 .pid_filter = stk80xx_pid_filter,
4593 .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
4594 .frontend_attach = stk809x_frontend_attach,
4595 .tuner_attach = dib809x_tuner_attach,
4596
4597 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004598 }},
Olivier Grenie03245a52009-12-04 13:27:57 -03004599 .size_of_priv =
4600 sizeof(struct dib0700_adapter_state),
4601 },
4602 },
4603
4604 .num_device_descs = 1,
4605 .devices = {
4606 { "DiBcom STK8096GP reference design",
4607 { &dib0700_usb_id_table[67], NULL },
4608 { NULL },
4609 },
4610 },
4611
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004612 .rc.core = {
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004613 .rc_interval = DEFAULT_RC_INTERVAL,
Mauro Carvalho Chehab5af935c2010-08-01 08:02:35 -03004614 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
Mauro Carvalho Chehab72b39312010-07-31 22:56:00 -03004615 .module_name = "dib0700",
Mauro Carvalho Chehab0ffd1ab2010-08-01 09:37:23 -03004616 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004617 .allowed_protos = RC_BIT_RC5 |
4618 RC_BIT_RC6_MCE |
4619 RC_BIT_NEC,
David Härdemand8b4b582010-10-29 16:08:23 -03004620 .change_protocol = dib0700_change_protocol,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03004621 },
Olivier Greniebe9bae12011-01-04 05:42:19 -03004622 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4623 .num_adapters = 1,
4624 .adapter = {
4625 {
Michael Krufky77eed212011-09-06 09:31:57 -03004626 .num_frontends = 1,
4627 .fe = {{
Olivier Greniebe9bae12011-01-04 05:42:19 -03004628 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
4629 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4630 .pid_filter_count = 32,
4631 .pid_filter = dib90x0_pid_filter,
4632 .pid_filter_ctrl = dib90x0_pid_filter_ctrl,
4633 .frontend_attach = stk9090m_frontend_attach,
4634 .tuner_attach = dib9090_tuner_attach,
4635
4636 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004637 }},
Olivier Greniebe9bae12011-01-04 05:42:19 -03004638 .size_of_priv =
4639 sizeof(struct dib0700_adapter_state),
4640 },
4641 },
4642
4643 .num_device_descs = 1,
4644 .devices = {
4645 { "DiBcom STK9090M reference design",
4646 { &dib0700_usb_id_table[69], NULL },
4647 { NULL },
4648 },
4649 },
4650
4651 .rc.core = {
4652 .rc_interval = DEFAULT_RC_INTERVAL,
4653 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4654 .module_name = "dib0700",
4655 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004656 .allowed_protos = RC_BIT_RC5 |
4657 RC_BIT_RC6_MCE |
4658 RC_BIT_NEC,
Olivier Greniebe9bae12011-01-04 05:42:19 -03004659 .change_protocol = dib0700_change_protocol,
4660 },
4661 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4662 .num_adapters = 1,
4663 .adapter = {
4664 {
Michael Krufky77eed212011-09-06 09:31:57 -03004665 .num_frontends = 1,
4666 .fe = {{
Olivier Greniebe9bae12011-01-04 05:42:19 -03004667 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
4668 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4669 .pid_filter_count = 32,
4670 .pid_filter = stk80xx_pid_filter,
4671 .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
4672 .frontend_attach = nim8096md_frontend_attach,
4673 .tuner_attach = nim8096md_tuner_attach,
4674
4675 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004676 }},
Olivier Greniebe9bae12011-01-04 05:42:19 -03004677 .size_of_priv =
4678 sizeof(struct dib0700_adapter_state),
4679 },
4680 },
4681
4682 .num_device_descs = 1,
4683 .devices = {
4684 { "DiBcom NIM8096MD reference design",
4685 { &dib0700_usb_id_table[70], NULL },
4686 { NULL },
4687 },
4688 },
4689
4690 .rc.core = {
4691 .rc_interval = DEFAULT_RC_INTERVAL,
4692 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4693 .module_name = "dib0700",
4694 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004695 .allowed_protos = RC_BIT_RC5 |
4696 RC_BIT_RC6_MCE |
4697 RC_BIT_NEC,
Olivier Greniebe9bae12011-01-04 05:42:19 -03004698 .change_protocol = dib0700_change_protocol,
4699 },
4700 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4701 .num_adapters = 1,
4702 .adapter = {
4703 {
Michael Krufky77eed212011-09-06 09:31:57 -03004704 .num_frontends = 1,
4705 .fe = {{
Olivier Greniebe9bae12011-01-04 05:42:19 -03004706 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
4707 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4708 .pid_filter_count = 32,
4709 .pid_filter = dib90x0_pid_filter,
4710 .pid_filter_ctrl = dib90x0_pid_filter_ctrl,
4711 .frontend_attach = nim9090md_frontend_attach,
4712 .tuner_attach = nim9090md_tuner_attach,
4713
4714 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004715 }},
Olivier Greniebe9bae12011-01-04 05:42:19 -03004716 .size_of_priv =
4717 sizeof(struct dib0700_adapter_state),
4718 },
4719 },
4720
4721 .num_device_descs = 1,
4722 .devices = {
4723 { "DiBcom NIM9090MD reference design",
4724 { &dib0700_usb_id_table[71], NULL },
4725 { NULL },
4726 },
4727 },
4728
4729 .rc.core = {
4730 .rc_interval = DEFAULT_RC_INTERVAL,
4731 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4732 .module_name = "dib0700",
4733 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004734 .allowed_protos = RC_BIT_RC5 |
4735 RC_BIT_RC6_MCE |
4736 RC_BIT_NEC,
Olivier Greniebe9bae12011-01-04 05:42:19 -03004737 .change_protocol = dib0700_change_protocol,
4738 },
4739 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4740 .num_adapters = 1,
4741 .adapter = {
4742 {
Michael Krufky77eed212011-09-06 09:31:57 -03004743 .num_frontends = 1,
4744 .fe = {{
Olivier Greniebe9bae12011-01-04 05:42:19 -03004745 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
4746 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4747 .pid_filter_count = 32,
4748 .pid_filter = stk70x0p_pid_filter,
4749 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
4750 .frontend_attach = nim7090_frontend_attach,
4751 .tuner_attach = nim7090_tuner_attach,
4752
4753 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004754 }},
Olivier Greniebe9bae12011-01-04 05:42:19 -03004755 .size_of_priv =
4756 sizeof(struct dib0700_adapter_state),
4757 },
4758 },
4759
4760 .num_device_descs = 1,
4761 .devices = {
4762 { "DiBcom NIM7090 reference design",
4763 { &dib0700_usb_id_table[72], NULL },
4764 { NULL },
4765 },
4766 },
4767
4768 .rc.core = {
4769 .rc_interval = DEFAULT_RC_INTERVAL,
4770 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4771 .module_name = "dib0700",
4772 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004773 .allowed_protos = RC_BIT_RC5 |
4774 RC_BIT_RC6_MCE |
4775 RC_BIT_NEC,
Olivier Greniebe9bae12011-01-04 05:42:19 -03004776 .change_protocol = dib0700_change_protocol,
4777 },
4778 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4779 .num_adapters = 2,
4780 .adapter = {
4781 {
Michael Krufky77eed212011-09-06 09:31:57 -03004782 .num_frontends = 1,
4783 .fe = {{
Olivier Greniebe9bae12011-01-04 05:42:19 -03004784 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
4785 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4786 .pid_filter_count = 32,
4787 .pid_filter = stk70x0p_pid_filter,
4788 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
4789 .frontend_attach = tfe7090pvr_frontend0_attach,
4790 .tuner_attach = tfe7090pvr_tuner0_attach,
4791
4792 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
Michael Krufky77eed212011-09-06 09:31:57 -03004793 }},
Olivier Greniebe9bae12011-01-04 05:42:19 -03004794 .size_of_priv =
4795 sizeof(struct dib0700_adapter_state),
4796 },
4797 {
Michael Krufky77eed212011-09-06 09:31:57 -03004798 .num_frontends = 1,
4799 .fe = {{
Olivier Greniebe9bae12011-01-04 05:42:19 -03004800 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
4801 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4802 .pid_filter_count = 32,
4803 .pid_filter = stk70x0p_pid_filter,
4804 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
4805 .frontend_attach = tfe7090pvr_frontend1_attach,
4806 .tuner_attach = tfe7090pvr_tuner1_attach,
4807
4808 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004809 }},
Olivier Greniebe9bae12011-01-04 05:42:19 -03004810 .size_of_priv =
4811 sizeof(struct dib0700_adapter_state),
4812 },
4813 },
4814
4815 .num_device_descs = 1,
4816 .devices = {
4817 { "DiBcom TFE7090PVR reference design",
4818 { &dib0700_usb_id_table[73], NULL },
4819 { NULL },
4820 },
4821 },
4822
4823 .rc.core = {
4824 .rc_interval = DEFAULT_RC_INTERVAL,
4825 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4826 .module_name = "dib0700",
4827 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004828 .allowed_protos = RC_BIT_RC5 |
4829 RC_BIT_RC6_MCE |
4830 RC_BIT_NEC,
Olivier Greniebe9bae12011-01-04 05:42:19 -03004831 .change_protocol = dib0700_change_protocol,
4832 },
Davide Ferri8d009a02009-06-23 22:34:06 -03004833 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4834 .num_adapters = 1,
4835 .adapter = {
4836 {
Michael Krufky77eed212011-09-06 09:31:57 -03004837 .num_frontends = 1,
4838 .fe = {{
Devin Heitmueller01f16262009-06-24 00:07:01 -03004839 .frontend_attach = pctv340e_frontend_attach,
Davide Ferri8d009a02009-06-23 22:34:06 -03004840 .tuner_attach = xc4000_tuner_attach,
4841
4842 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
Michael Krufky77eed212011-09-06 09:31:57 -03004843 }},
Davide Ferri8d009a02009-06-23 22:34:06 -03004844 .size_of_priv = sizeof(struct
4845 dib0700_adapter_state),
4846 },
4847 },
4848
Devin Heitmueller33fb1682009-06-23 22:48:02 -03004849 .num_device_descs = 2,
Davide Ferri8d009a02009-06-23 22:34:06 -03004850 .devices = {
4851 { "Pinnacle PCTV 340e HD Pro USB Stick",
4852 { &dib0700_usb_id_table[76], NULL },
4853 { NULL },
4854 },
Devin Heitmueller33fb1682009-06-23 22:48:02 -03004855 { "Pinnacle PCTV Hybrid Stick Solo",
4856 { &dib0700_usb_id_table[77], NULL },
4857 { NULL },
4858 },
Davide Ferri8d009a02009-06-23 22:34:06 -03004859 },
4860 .rc.core = {
4861 .rc_interval = DEFAULT_RC_INTERVAL,
4862 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4863 .module_name = "dib0700",
4864 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004865 .allowed_protos = RC_BIT_RC5 |
4866 RC_BIT_RC6_MCE |
4867 RC_BIT_NEC,
Davide Ferri8d009a02009-06-23 22:34:06 -03004868 .change_protocol = dib0700_change_protocol,
4869 },
Olivier Grenie6724a2f2011-08-05 13:49:33 -03004870 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4871 .num_adapters = 1,
4872 .adapter = {
4873 {
4874 .num_frontends = 1,
4875 .fe = {{
4876 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
4877 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4878 .pid_filter_count = 32,
4879 .pid_filter = stk70x0p_pid_filter,
4880 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
Olivier Grenief45f5132012-12-31 09:47:10 -03004881 .frontend_attach = tfe7790p_frontend_attach,
4882 .tuner_attach = tfe7790p_tuner_attach,
Olivier Grenieb293f302011-08-09 04:48:25 -03004883
4884 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
4885 } },
4886
4887 .size_of_priv =
4888 sizeof(struct dib0700_adapter_state),
4889 },
4890 },
4891
4892 .num_device_descs = 1,
4893 .devices = {
Olivier Grenief45f5132012-12-31 09:47:10 -03004894 { "DiBcom TFE7790P reference design",
4895 { &dib0700_usb_id_table[78], NULL },
Olivier Grenieb293f302011-08-09 04:48:25 -03004896 { NULL },
4897 },
4898 },
4899
4900 .rc.core = {
4901 .rc_interval = DEFAULT_RC_INTERVAL,
4902 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4903 .module_name = "dib0700",
4904 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004905 .allowed_protos = RC_BIT_RC5 |
4906 RC_BIT_RC6_MCE |
4907 RC_BIT_NEC,
Olivier Grenieb293f302011-08-09 04:48:25 -03004908 .change_protocol = dib0700_change_protocol,
4909 },
Olivier Grenie88f3a352011-08-10 05:28:38 -03004910 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
4911 .num_adapters = 1,
4912 .adapter = {
4913 {
4914 .num_frontends = 1,
4915 .fe = {{
4916 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
4917 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
4918 .pid_filter_count = 32,
4919 .pid_filter = stk80xx_pid_filter,
4920 .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
4921 .frontend_attach = tfe8096p_frontend_attach,
4922 .tuner_attach = tfe8096p_tuner_attach,
4923
4924 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
4925
4926 } },
4927
4928 .size_of_priv =
4929 sizeof(struct dib0700_adapter_state),
4930 },
4931 },
4932
4933 .num_device_descs = 1,
4934 .devices = {
4935 { "DiBcom TFE8096P reference design",
Olivier Grenief45f5132012-12-31 09:47:10 -03004936 { &dib0700_usb_id_table[79], NULL },
Olivier Grenie88f3a352011-08-10 05:28:38 -03004937 { NULL },
4938 },
4939 },
4940
4941 .rc.core = {
4942 .rc_interval = DEFAULT_RC_INTERVAL,
4943 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4944 .module_name = "dib0700",
4945 .rc_query = dib0700_rc_query_old_firmware,
David Härdemanc003ab12012-10-11 19:11:54 -03004946 .allowed_protos = RC_BIT_RC5 |
4947 RC_BIT_RC6_MCE |
4948 RC_BIT_NEC,
Olivier Grenie88f3a352011-08-10 05:28:38 -03004949 .change_protocol = dib0700_change_protocol,
4950 },
Patrick Boettcher01373a52007-07-30 12:49:04 -03004951 },
Patrick Boettcherb7f54912006-09-19 12:51:37 -03004952};
4953
4954int dib0700_device_count = ARRAY_SIZE(dib0700_devices);