dib0700_devices.c 127.6 KB
Newer Older
1 2 3 4 5 6
/* Linux driver for devices based on the DiBcom DiB0700 USB bridge
 *
 *	This program is free software; you can redistribute it and/or modify it
 *	under the terms of the GNU General Public License as published by the Free
 *	Software Foundation, version 2.
 *
7
 *  Copyright (C) 2005-9 DiBcom, SA et al
8 9 10 11
 */
#include "dib0700.h"

#include "dib3000mc.h"
12
#include "dib7000m.h"
13
#include "dib7000p.h"
14
#include "dib8000.h"
15
#include "dib9000.h"
16
#include "mt2060.h"
17
#include "mt2266.h"
18
#include "tuner-xc2028.h"
19
#include "xc5000.h"
20
#include "xc4000.h"
21
#include "s5h1411.h"
22
#include "dib0070.h"
23
#include "dib0090.h"
24 25
#include "lgdt3305.h"
#include "mxl5007t.h"
26

27 28 29 30 31
static int force_lna_activation;
module_param(force_lna_activation, int, 0644);
MODULE_PARM_DESC(force_lna_activation, "force the activation of Low-Noise-Amplifyer(s) (LNA), "
		"if applicable for the device (default: 0=automatic/off).");

32
struct dib0700_adapter_state {
33
	int (*set_param_save) (struct dvb_frontend *);
34
	const struct firmware *frontend_firmware;
35 36 37
};

/* Hauppauge Nova-T 500 (aka Bristol)
38 39 40 41
 *  has a LNA on GPIO0 which is enabled by setting 1 */
static struct mt2060_config bristol_mt2060_config[2] = {
	{
		.i2c_address = 0x60,
42
		.clock_out   = 3,
43 44 45 46 47
	}, {
		.i2c_address = 0x61,
	}
};

48

49 50
static struct dibx000_agc_config bristol_dib3000p_mt2060_agc_config = {
	.band_caps = BAND_VHF | BAND_UHF,
51
	.setup     = (1 << 8) | (5 << 5) | (0 << 4) | (0 << 3) | (0 << 2) | (2 << 0),
52

53 54 55 56
	.agc1_max = 42598,
	.agc1_min = 17694,
	.agc2_max = 45875,
	.agc2_min = 0,
57

58 59
	.agc1_pt1 = 0,
	.agc1_pt2 = 59,
60

61 62
	.agc1_slope1 = 0,
	.agc1_slope2 = 69,
63 64

	.agc2_pt1 = 0,
65
	.agc2_pt2 = 59,
66

67 68
	.agc2_slope1 = 111,
	.agc2_slope2 = 28,
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
};

static struct dib3000mc_config bristol_dib3000mc_config[2] = {
	{	.agc          = &bristol_dib3000p_mt2060_agc_config,
		.max_time     = 0x196,
		.ln_adc_level = 0x1cc7,
		.output_mpeg2_in_188_bytes = 1,
	},
	{	.agc          = &bristol_dib3000p_mt2060_agc_config,
		.max_time     = 0x196,
		.ln_adc_level = 0x1cc7,
		.output_mpeg2_in_188_bytes = 1,
	}
};

static int bristol_frontend_attach(struct dvb_usb_adapter *adap)
{
86
	struct dib0700_state *st = adap->dev->priv;
87 88 89 90 91 92
	if (adap->id == 0) {
		dib0700_set_gpio(adap->dev, GPIO6,  GPIO_OUT, 0); msleep(10);
		dib0700_set_gpio(adap->dev, GPIO6,  GPIO_OUT, 1); msleep(10);
		dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0); msleep(10);
		dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1); msleep(10);

93 94 95 96
		if (force_lna_activation)
			dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
		else
			dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 0);
97

98 99 100 101 102
		if (dib3000mc_i2c_enumeration(&adap->dev->i2c_adap, 2, DEFAULT_DIB3000P_I2C_ADDRESS, bristol_dib3000mc_config) != 0) {
			dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0); msleep(10);
			return -ENODEV;
		}
	}
103
	st->mt2060_if1[adap->id] = 1220;
104
	return (adap->fe_adap[0].fe = dvb_attach(dib3000mc_attach, &adap->dev->i2c_adap,
105
		(10 + adap->id) << 1, &bristol_dib3000mc_config[adap->id])) == NULL ? -ENODEV : 0;
106 107
}

108
static int eeprom_read(struct i2c_adapter *adap,u8 adrs,u8 *pval)
109 110 111 112 113 114 115 116 117
{
	struct i2c_msg msg[2] = {
		{ .addr = 0x50, .flags = 0,        .buf = &adrs, .len = 1 },
		{ .addr = 0x50, .flags = I2C_M_RD, .buf = pval,  .len = 1 },
	};
	if (i2c_transfer(adap, msg, 2) != 2) return -EREMOTEIO;
	return 0;
}

118 119
static int bristol_tuner_attach(struct dvb_usb_adapter *adap)
{
120
	struct i2c_adapter *prim_i2c = &adap->dev->i2c_adap;
121
	struct i2c_adapter *tun_i2c = dib3000mc_get_tuner_i2c_master(adap->fe_adap[0].fe, 1);
122 123
	s8 a;
	int if1=1220;
124 125
	if (adap->dev->udev->descriptor.idVendor  == cpu_to_le16(USB_VID_HAUPPAUGE) &&
		adap->dev->udev->descriptor.idProduct == cpu_to_le16(USB_PID_HAUPPAUGE_NOVA_T_500_2)) {
126 127
		if (!eeprom_read(prim_i2c,0x59 + adap->id,&a)) if1=1220+a;
	}
128 129 130
	return dvb_attach(mt2060_attach, adap->fe_adap[0].fe, tun_i2c,
			  &bristol_mt2060_config[adap->id], if1) == NULL ?
			  -ENODEV : 0;
131 132
}

133
/* STK7700D: Pinnacle/Terratec/Hauppauge Dual DVB-T Diversity */
134

135 136 137
/* MT226x */
static struct dibx000_agc_config stk7700d_7000p_mt2266_agc_config[2] = {
	{
138
		BAND_UHF,
139 140 141

		/* 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,
		* 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 */
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176
		(0 << 15) | (0 << 14) | (1 << 11) | (1 << 10) | (1 << 9) | (0 << 8)
	    | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),

		1130,
		21,

		0,
		118,

		0,
		3530,
		1,
		0,

		65535,
		33770,
		65535,
		23592,

		0,
		62,
		255,
		64,
		64,
		132,
		192,
		80,
		80,

		17,
		27,
		23,
		51,

		1,
177
	}, {
178
		BAND_VHF | BAND_LBAND,
179 180 181

		/* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=1, P_agc_inv_pwm1=1, P_agc_inv_pwm2=1,
		* 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 */
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216
		(0 << 15) | (0 << 14) | (1 << 11) | (1 << 10) | (1 << 9) | (0 << 8)
	    | (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0),

		2372,
		21,

		0,
		118,

		0,
		3530,
		1,
		0,

		65535,
		0,
		65535,
		23592,

		0,
		128,
		128,
		128,
		0,
		128,
		253,
		81,
		0,

		17,
		27,
		23,
		51,

		1,
217
	}
218 219 220
};

static struct dibx000_bandwidth_config stk7700d_mt2266_pll_config = {
221 222 223 224 225 226
	60000, 30000,
	1, 8, 3, 1, 0,
	0, 0, 1, 1, 2,
	(3 << 14) | (1 << 12) | (524 << 0),
	0,
	20452225,
227 228 229 230 231 232 233
};

static struct dib7000p_config stk7700d_dib7000p_mt2266_config[] = {
	{	.output_mpeg2_in_188_bytes = 1,
		.hostbus_diversity = 1,
		.tuner_is_baseband = 1,

234 235
		.agc_config_count = 2,
		.agc = stk7700d_7000p_mt2266_agc_config,
236 237
		.bw  = &stk7700d_mt2266_pll_config,

238 239 240
		.gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
		.gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
		.gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
241 242 243 244 245
	},
	{	.output_mpeg2_in_188_bytes = 1,
		.hostbus_diversity = 1,
		.tuner_is_baseband = 1,

246 247
		.agc_config_count = 2,
		.agc = stk7700d_7000p_mt2266_agc_config,
248 249
		.bw  = &stk7700d_mt2266_pll_config,

250 251 252
		.gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
		.gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
		.gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
253 254 255 256 257 258 259 260 261 262
	}
};

static struct mt2266_config stk7700d_mt2266_config[2] = {
	{	.i2c_address = 0x60
	},
	{	.i2c_address = 0x60
	}
};

263 264 265 266 267 268 269 270 271 272 273 274
static int stk7700P2_frontend_attach(struct dvb_usb_adapter *adap)
{
	if (adap->id == 0) {
		dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
		msleep(10);
		dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
		dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
		dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
		dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
		msleep(10);
		dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
		msleep(10);
275 276 277 278 279 280
		if (dib7000p_i2c_enumeration(&adap->dev->i2c_adap, 1, 18,
					     stk7700d_dib7000p_mt2266_config)
		    != 0) {
			err("%s: dib7000p_i2c_enumeration failed.  Cannot continue\n", __func__);
			return -ENODEV;
		}
281 282
	}

283 284 285 286
	adap->fe_adap[0].fe =
		dvb_attach(dib7000p_attach, &adap->dev->i2c_adap,
			   0x80 + (adap->id << 1),
			   &stk7700d_dib7000p_mt2266_config[adap->id]);
287

288
	return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
289 290
}

291 292 293 294 295 296 297 298 299 300 301 302 303
static int stk7700d_frontend_attach(struct dvb_usb_adapter *adap)
{
	if (adap->id == 0) {
		dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
		msleep(10);
		dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
		dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
		dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
		dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
		msleep(10);
		dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
		msleep(10);
		dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
304 305 306 307 308 309
		if (dib7000p_i2c_enumeration(&adap->dev->i2c_adap, 2, 18,
					     stk7700d_dib7000p_mt2266_config)
		    != 0) {
			err("%s: dib7000p_i2c_enumeration failed.  Cannot continue\n", __func__);
			return -ENODEV;
		}
310 311
	}

312 313 314 315
	adap->fe_adap[0].fe =
		dvb_attach(dib7000p_attach, &adap->dev->i2c_adap,
			   0x80 + (adap->id << 1),
			   &stk7700d_dib7000p_mt2266_config[adap->id]);
316

317
	return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
318 319 320 321 322
}

static int stk7700d_tuner_attach(struct dvb_usb_adapter *adap)
{
	struct i2c_adapter *tun_i2c;
323 324
	tun_i2c = dib7000p_get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_TUNER, 1);
	return dvb_attach(mt2266_attach, adap->fe_adap[0].fe, tun_i2c,
325
		&stk7700d_mt2266_config[adap->id]) == NULL ? -ENODEV : 0;
326 327
}

328
/* STK7700-PH: Digital/Analog Hybrid Tuner, e.h. Cinergy HT USB HE */
329
static struct dibx000_agc_config xc3028_agc_config = {
330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371
	BAND_VHF | BAND_UHF,       /* band_caps */

	/* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=0,
	 * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, 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 */
	(0 << 15) | (0 << 14) | (0 << 11) | (0 << 10) | (0 << 9) | (0 << 8) |
	(3 << 5) | (0 << 4) | (2 << 1) | (0 << 0), /* setup */

	712,	/* inv_gain */
	21,	/* time_stabiliz */

	0,	/* alpha_level */
	118,	/* thlock */

	0,	/* wbd_inv */
	2867,	/* wbd_ref */
	0,	/* wbd_sel */
	2,	/* wbd_alpha */

	0,	/* agc1_max */
	0,	/* agc1_min */
	39718,	/* agc2_max */
	9930,	/* agc2_min */
	0,	/* agc1_pt1 */
	0,	/* agc1_pt2 */
	0,	/* agc1_pt3 */
	0,	/* agc1_slope1 */
	0,	/* agc1_slope2 */
	0,	/* agc2_pt1 */
	128,	/* agc2_pt2 */
	29,	/* agc2_slope1 */
	29,	/* agc2_slope2 */

	17,	/* alpha_mant */
	27,	/* alpha_exp */
	23,	/* beta_mant */
	51,	/* beta_exp */

	1,	/* perform_agc_softsplit */
};

/* PLL Configuration for COFDM BW_MHz = 8.00 with external clock = 30.00 */
372
static struct dibx000_bandwidth_config xc3028_bw_config = {
373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395
	60000, 30000, /* internal, sampling */
	1, 8, 3, 1, 0, /* pll_cfg: prediv, ratio, range, reset, bypass */
	0, 0, 1, 1, 0, /* misc: refdiv, bypclk_div, IO_CLK_en_core, ADClkSrc,
			  modulo */
	(3 << 14) | (1 << 12) | (524 << 0), /* sad_cfg: refsel, sel, freq_15k */
	(1 << 25) | 5816102, /* ifreq = 5.200000 MHz */
	20452225, /* timf */
	30000000, /* xtal_hz */
};

static struct dib7000p_config stk7700ph_dib7700_xc3028_config = {
	.output_mpeg2_in_188_bytes = 1,
	.tuner_is_baseband = 1,

	.agc_config_count = 1,
	.agc = &xc3028_agc_config,
	.bw  = &xc3028_bw_config,

	.gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
	.gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
	.gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
};

396 397
static int stk7700ph_xc3028_callback(void *ptr, int component,
				     int command, int arg)
398 399 400 401 402 403
{
	struct dvb_usb_adapter *adap = ptr;

	switch (command) {
	case XC2028_TUNER_RESET:
		/* Send the tuner in then out of reset */
404 405
		dib7000p_set_gpio(adap->fe_adap[0].fe, 8, 0, 0); msleep(10);
		dib7000p_set_gpio(adap->fe_adap[0].fe, 8, 0, 1);
406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431
		break;
	case XC2028_RESET_CLK:
		break;
	default:
		err("%s: unknown command %d, arg %d\n", __func__,
			command, arg);
		return -EINVAL;
	}
	return 0;
}

static struct xc2028_ctrl stk7700ph_xc3028_ctrl = {
	.fname = XC2028_DEFAULT_FIRMWARE,
	.max_len = 64,
	.demod = XC3028_FE_DIBCOM52,
};

static struct xc2028_config stk7700ph_xc3028_config = {
	.i2c_addr = 0x61,
	.ctrl = &stk7700ph_xc3028_ctrl,
};

static int stk7700ph_frontend_attach(struct dvb_usb_adapter *adap)
{
	struct usb_device_descriptor *desc = &adap->dev->udev->descriptor;

432 433
	if (desc->idVendor  == cpu_to_le16(USB_VID_PINNACLE) &&
	    desc->idProduct == cpu_to_le16(USB_PID_PINNACLE_EXPRESSCARD_320CX))
434 435 436 437 438 439 440 441 442 443 444 445 446 447
	dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
	else
	dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
	msleep(20);
	dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
	dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
	dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
	dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
	msleep(10);
	dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
	msleep(20);
	dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
	msleep(10);

448 449 450 451 452 453
	if (dib7000p_i2c_enumeration(&adap->dev->i2c_adap, 1, 18,
				     &stk7700ph_dib7700_xc3028_config) != 0) {
		err("%s: dib7000p_i2c_enumeration failed.  Cannot continue\n",
		    __func__);
		return -ENODEV;
	}
454

455
	adap->fe_adap[0].fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 0x80,
456 457
		&stk7700ph_dib7700_xc3028_config);

458
	return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
459 460 461 462 463 464
}

static int stk7700ph_tuner_attach(struct dvb_usb_adapter *adap)
{
	struct i2c_adapter *tun_i2c;

465
	tun_i2c = dib7000p_get_i2c_master(adap->fe_adap[0].fe,
466 467 468
		DIBX000_I2C_INTERFACE_TUNER, 1);

	stk7700ph_xc3028_config.i2c_adap = tun_i2c;
469 470

	/* FIXME: generalize & move to common area */
471
	adap->fe_adap[0].fe->callback = stk7700ph_xc3028_callback;
472

473
	return dvb_attach(xc2028_attach, adap->fe_adap[0].fe, &stk7700ph_xc3028_config)
474 475 476
		== NULL ? -ENODEV : 0;
}

477
#define DEFAULT_RC_INTERVAL 50
478 479 480

static u8 rc_request[] = { REQUEST_POLL_RC, 0 };

481
/* Number of keypresses to ignore before start repeating */
482
#define RC_REPEAT_DELAY 6
483

484 485 486 487 488 489
/*
 * This function is used only when firmware is < 1.20 version. Newer
 * firmwares use bulk mode, with functions implemented at dib0700_core,
 * at dib0700_rc_urb_completion()
 */
static int dib0700_rc_query_old_firmware(struct dvb_usb_device *d)
490 491
{
	u8 key[4];
492 493
	u32 keycode;
	u8 toggle;
494 495
	int i;
	struct dib0700_state *st = d->priv;
496 497 498 499 500 501 502 503 504

	if (st->fw_version >= 0x10200) {
		/* For 1.20 firmware , We need to keep the RC polling
		   callback so we can reuse the input device setup in
		   dvb-usb-remote.c.  However, the actual work is being done
		   in the bulk URB completion handler. */
		return 0;
	}

505 506
	i = dib0700_ctrl_rd(d, rc_request, 2, key, 4);
	if (i <= 0) {
507
		err("RC Query Failed");
508
		return -1;
509
	}
510 511

	/* losing half of KEY_0 events from Philipps rc5 remotes.. */
512 513
	if (key[0] == 0 && key[1] == 0 && key[2] == 0 && key[3] == 0)
		return 0;
514 515 516 517 518

	/* 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]);  */

	dib0700_rc_setup(d); /* reset ir sensor data to prevent false events */

519
	d->last_event = 0;
520
	switch (d->props.rc.core.protocol) {
521
	case RC_BIT_NEC:
522 523
		/* NEC protocol sends repeat code as 0 0 0 FF */
		if ((key[3-2] == 0x00) && (key[3-3] == 0x00) &&
524 525 526 527 528
		    (key[3] == 0xff))
			keycode = d->last_event;
		else {
			keycode = key[3-2] << 8 | key[3-3];
			d->last_event = keycode;
529
		}
530

531
		rc_keydown(d->rc_dev, keycode, 0);
532
		break;
533
	default:
534
		/* RC-5 protocol changes toggle bit on new keypress */
535 536
		keycode = key[3-2] << 8 | key[3-3];
		toggle = key[3-1];
537
		rc_keydown(d->rc_dev, keycode, toggle);
538

539 540
		break;
	}
541 542 543
	return 0;
}

544
/* STK7700P: Hauppauge Nova-T Stick, AVerMedia Volar */
545
static struct dibx000_agc_config stk7700p_7000m_mt2060_agc_config = {
546
	BAND_UHF | BAND_VHF,
547 548 549

	/* 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,
	 * 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 */
550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587
	(0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8)
	| (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0),

	712,
	41,

	0,
	118,

	0,
	4095,
	0,
	0,

	42598,
	17694,
	45875,
	2621,
	0,
	76,
	139,
	52,
	59,
	107,
	172,
	57,
	70,

	21,
	25,
	28,
	48,

	1,
	{  0,
	   107,
	   51800,
	   24700
588 589 590
	},
};

591 592 593 594 595
static struct dibx000_agc_config stk7700p_7000p_mt2060_agc_config = {
	BAND_UHF | BAND_VHF,

	/* 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,
	 * 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 */
596 597
	(0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8)
	| (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0),
598

599 600
	712,
	41,
601

602 603
	0,
	118,
604

605 606 607 608
	0,
	4095,
	0,
	0,
609

610 611 612 613
	42598,
	16384,
	42598,
	    0,
614

615 616 617
	  0,
	137,
	255,
618

619 620
	  0,
	255,
621

622 623
	0,
	0,
624

625 626
	 0,
	41,
627

628 629
	15,
	25,
630

631 632
	28,
	48,
633

634
	0,
635 636 637
};

static struct dibx000_bandwidth_config stk7700p_pll_config = {
638 639 640 641 642 643 644
	60000, 30000,
	1, 8, 3, 1, 0,
	0, 0, 1, 1, 0,
	(3 << 14) | (1 << 12) | (524 << 0),
	60258167,
	20452225,
	30000000,
645 646 647 648 649 650 651 652
};

static struct dib7000m_config stk7700p_dib7000m_config = {
	.dvbt_mode = 1,
	.output_mpeg2_in_188_bytes = 1,
	.quartz_direct = 1,

	.agc_config_count = 1,
653 654 655 656 657 658 659 660 661 662 663
	.agc = &stk7700p_7000m_mt2060_agc_config,
	.bw  = &stk7700p_pll_config,

	.gpio_dir = DIB7000M_GPIO_DEFAULT_DIRECTIONS,
	.gpio_val = DIB7000M_GPIO_DEFAULT_VALUES,
	.gpio_pwm_pos = DIB7000M_GPIO_DEFAULT_PWM_POS,
};

static struct dib7000p_config stk7700p_dib7000p_config = {
	.output_mpeg2_in_188_bytes = 1,

664
	.agc_config_count = 1,
665 666
	.agc = &stk7700p_7000p_mt2060_agc_config,
	.bw  = &stk7700p_pll_config,
667 668 669 670

	.gpio_dir = DIB7000M_GPIO_DEFAULT_DIRECTIONS,
	.gpio_val = DIB7000M_GPIO_DEFAULT_VALUES,
	.gpio_pwm_pos = DIB7000M_GPIO_DEFAULT_PWM_POS,
671 672 673 674
};

static int stk7700p_frontend_attach(struct dvb_usb_adapter *adap)
{
675
	struct dib0700_state *st = adap->dev->priv;
676
	/* unless there is no real power management in DVB - we leave the device on GPIO6 */
677 678 679 680

	dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
	dib0700_set_gpio(adap->dev, GPIO6,  GPIO_OUT, 0); msleep(50);

681
	dib0700_set_gpio(adap->dev, GPIO6,  GPIO_OUT, 1); msleep(10);
682 683
	dib0700_set_gpio(adap->dev, GPIO9,  GPIO_OUT, 1);

684
	dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0); msleep(10);
685 686 687 688
	dib0700_ctrl_clock(adap->dev, 72, 1);
	dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1); msleep(100);

	dib0700_set_gpio(adap->dev,  GPIO0, GPIO_OUT, 1);
689

690
	st->mt2060_if1[0] = 1220;
691 692

	if (dib7000pc_detection(&adap->dev->i2c_adap)) {
693
		adap->fe_adap[0].fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 18, &stk7700p_dib7000p_config);
694 695
		st->is_dib7000pc = 1;
	} else
696
		adap->fe_adap[0].fe = dvb_attach(dib7000m_attach, &adap->dev->i2c_adap, 18, &stk7700p_dib7000m_config);
697

698
	return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
699 700
}

701 702 703 704
static struct mt2060_config stk7700p_mt2060_config = {
	0x60
};

705 706
static int stk7700p_tuner_attach(struct dvb_usb_adapter *adap)
{
707
	struct i2c_adapter *prim_i2c = &adap->dev->i2c_adap;
708
	struct dib0700_state *st = adap->dev->priv;
709
	struct i2c_adapter *tun_i2c;
710 711
	s8 a;
	int if1=1220;
712 713
	if (adap->dev->udev->descriptor.idVendor  == cpu_to_le16(USB_VID_HAUPPAUGE) &&
		adap->dev->udev->descriptor.idProduct == cpu_to_le16(USB_PID_HAUPPAUGE_NOVA_T_STICK)) {
714 715
		if (!eeprom_read(prim_i2c,0x58,&a)) if1=1220+a;
	}
716
	if (st->is_dib7000pc)
717
		tun_i2c = dib7000p_get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_TUNER, 1);
718
	else
719
		tun_i2c = dib7000m_get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_TUNER, 1);
720

721
	return dvb_attach(mt2060_attach, adap->fe_adap[0].fe, tun_i2c, &stk7700p_mt2060_config,
722
		if1) == NULL ? -ENODEV : 0;
723 724
}

725 726 727 728 729
/* DIB7070 generic */
static struct dibx000_agc_config dib7070_agc_config = {
	BAND_UHF | BAND_VHF | BAND_LBAND | BAND_SBAND,
	/* 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,
	 * 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 */
730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765
	(0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8)
	| (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),

	600,
	10,

	0,
	118,

	0,
	3530,
	1,
	5,

	65535,
		0,

	65535,
	0,

	0,
	40,
	183,
	206,
	255,
	72,
	152,
	88,
	90,

	17,
	27,
	23,
	51,

	0,
766 767 768 769
};

static int dib7070_tuner_reset(struct dvb_frontend *fe, int onoff)
{
770
	deb_info("reset: %d", onoff);
771 772 773 774 775
	return dib7000p_set_gpio(fe, 8, 0, !onoff);
}

static int dib7070_tuner_sleep(struct dvb_frontend *fe, int onoff)
{
776
	deb_info("sleep: %d", onoff);
777 778 779 780 781 782 783 784 785
	return dib7000p_set_gpio(fe, 9, 0, onoff);
}

static struct dib0070_config dib7070p_dib0070_config[2] = {
	{
		.i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
		.reset = dib7070_tuner_reset,
		.sleep = dib7070_tuner_sleep,
		.clock_khz = 12000,
786 787
		.clock_pad_drive = 4,
		.charge_pump = 2,
788 789 790 791 792
	}, {
		.i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
		.reset = dib7070_tuner_reset,
		.sleep = dib7070_tuner_sleep,
		.clock_khz = 12000,
793
		.charge_pump = 2,
794 795 796
	}
};

797 798 799 800 801 802 803
static struct dib0070_config dib7770p_dib0070_config = {
	 .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
	 .reset = dib7070_tuner_reset,
	 .sleep = dib7070_tuner_sleep,
	 .clock_khz = 12000,
	 .clock_pad_drive = 0,
	 .flip_chip = 1,
804
	 .charge_pump = 2,
805 806
};

807
static int dib7070_set_param_override(struct dvb_frontend *fe)
808
{
809
	struct dtv_frontend_properties *p = &fe->dtv_property_cache;
810 811 812 813
	struct dvb_usb_adapter *adap = fe->dvb->priv;
	struct dib0700_adapter_state *state = adap->priv;

	u16 offset;
814
	u8 band = BAND_OF_FREQUENCY(p->frequency/1000);
815 816 817 818 819 820 821
	switch (band) {
		case BAND_VHF: offset = 950; break;
		case BAND_UHF:
		default: offset = 550; break;
	}
	deb_info("WBD for DiB7000P: %d\n", offset + dib0070_wbd_offset(fe));
	dib7000p_set_wbd_ref(fe, offset + dib0070_wbd_offset(fe));
822
	return state->set_param_save(fe);
823 824
}

825
static int dib7770_set_param_override(struct dvb_frontend *fe)
826
{
827 828 829
	struct dtv_frontend_properties *p = &fe->dtv_property_cache;
	struct dvb_usb_adapter *adap = fe->dvb->priv;
	struct dib0700_adapter_state *state = adap->priv;
830 831

	 u16 offset;
832
	 u8 band = BAND_OF_FREQUENCY(p->frequency/1000);
833 834 835 836 837 838 839 840 841 842 843 844 845
	 switch (band) {
	 case BAND_VHF:
		  dib7000p_set_gpio(fe, 0, 0, 1);
		  offset = 850;
		  break;
	 case BAND_UHF:
	 default:
		  dib7000p_set_gpio(fe, 0, 0, 0);
		  offset = 250;
		  break;
	 }
	 deb_info("WBD for DiB7000P: %d\n", offset + dib0070_wbd_offset(fe));
	 dib7000p_set_wbd_ref(fe, offset + dib0070_wbd_offset(fe));
846
	 return state->set_param_save(fe);
847 848 849 850 851
}

static int dib7770p_tuner_attach(struct dvb_usb_adapter *adap)
{
	 struct dib0700_adapter_state *st = adap->priv;
852
	 struct i2c_adapter *tun_i2c = dib7000p_get_i2c_master(adap->fe_adap[0].fe,
853 854
			 DIBX000_I2C_INTERFACE_TUNER, 1);

855
	 if (dvb_attach(dib0070_attach, adap->fe_adap[0].fe, tun_i2c,
856
			&dib7770p_dib0070_config) == NULL)
857 858
		 return -ENODEV;

859 860
	 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
	 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib7770_set_param_override;
861 862 863
	 return 0;
}

864 865 866
static int dib7070p_tuner_attach(struct dvb_usb_adapter *adap)
{
	struct dib0700_adapter_state *st = adap->priv;
867
	struct i2c_adapter *tun_i2c = dib7000p_get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_TUNER, 1);
868 869

	if (adap->id == 0) {
870
		if (dvb_attach(dib0070_attach, adap->fe_adap[0].fe, tun_i2c, &dib7070p_dib0070_config[0]) == NULL)
871 872
			return -ENODEV;
	} else {
873
		if (dvb_attach(dib0070_attach, adap->fe_adap[0].fe, tun_i2c, &dib7070p_dib0070_config[1]) == NULL)
874 875 876
			return -ENODEV;
	}

877 878
	st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
	adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib7070_set_param_override;
879 880 881
	return 0;
}

882 883 884 885 886
static int stk7700p_pid_filter(struct dvb_usb_adapter *adapter, int index,
		u16 pid, int onoff)
{
	struct dib0700_state *st = adapter->dev->priv;
	if (st->is_dib7000pc)
887 888
		return dib7000p_pid_filter(adapter->fe_adap[0].fe, index, pid, onoff);
	return dib7000m_pid_filter(adapter->fe_adap[0].fe, index, pid, onoff);
889 890 891 892 893 894
}

static int stk7700p_pid_filter_ctrl(struct dvb_usb_adapter *adapter, int onoff)
{
	struct dib0700_state *st = adapter->dev->priv;
	if (st->is_dib7000pc)
895 896
		return dib7000p_pid_filter_ctrl(adapter->fe_adap[0].fe, onoff);
	return dib7000m_pid_filter_ctrl(adapter->fe_adap[0].fe, onoff);
897 898
}

899 900
static int stk70x0p_pid_filter(struct dvb_usb_adapter *adapter, int index, u16 pid, int onoff)
{
901
	return dib7000p_pid_filter(adapter->fe_adap[0].fe, index, pid, onoff);
902 903 904 905
}

static int stk70x0p_pid_filter_ctrl(struct dvb_usb_adapter *adapter, int onoff)
{
906
	return dib7000p_pid_filter_ctrl(adapter->fe_adap[0].fe, onoff);
907 908
}

909
static struct dibx000_bandwidth_config dib7070_bw_config_12_mhz = {
910 911 912 913 914 915 916
	60000, 15000,
	1, 20, 3, 1, 0,
	0, 0, 1, 1, 2,
	(3 << 14) | (1 << 12) | (524 << 0),
	(0 << 25) | 0,
	20452225,
	12000000,
917 918 919 920 921 922 923 924
};

static struct dib7000p_config dib7070p_dib7000p_config = {
	.output_mpeg2_in_188_bytes = 1,

	.agc_config_count = 1,
	.agc = &dib7070_agc_config,
	.bw  = &dib7070_bw_config_12_mhz,
925 926
	.tuner_is_baseband = 1,
	.spur_protect = 1,
927 928 929 930 931 932 933 934 935 936 937

	.gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
	.gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
	.gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,

	.hostbus_diversity = 1,
};

/* STK7070P */
static int stk7070p_frontend_attach(struct dvb_usb_adapter *adap)
{
938 939 940 941
	struct usb_device_descriptor *p = &adap->dev->udev->descriptor;
	if (p->idVendor  == cpu_to_le16(USB_VID_PINNACLE) &&
	    p->idProduct == cpu_to_le16(USB_PID_PINNACLE_PCTV72E))
		dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
942
	else
943
		dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
944 945 946 947 948 949 950 951 952 953 954 955 956
	msleep(10);
	dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
	dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
	dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
	dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);

	dib0700_ctrl_clock(adap->dev, 72, 1);

	msleep(10);
	dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
	msleep(10);
	dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);

957 958 959 960 961 962
	if (dib7000p_i2c_enumeration(&adap->dev->i2c_adap, 1, 18,
				     &dib7070p_dib7000p_config) != 0) {
		err("%s: dib7000p_i2c_enumeration failed.  Cannot continue\n",
		    __func__);
		return -ENODEV;
	}
963

964
	adap->fe_adap[0].fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 0x80,
965
		&dib7070p_dib7000p_config);
966
	return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
967 968
}

969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984
/* STK7770P */
static struct dib7000p_config dib7770p_dib7000p_config = {
	.output_mpeg2_in_188_bytes = 1,

	.agc_config_count = 1,
	.agc = &dib7070_agc_config,
	.bw  = &dib7070_bw_config_12_mhz,
	.tuner_is_baseband = 1,
	.spur_protect = 1,

	.gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
	.gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
	.gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,

	.hostbus_diversity = 1,
	.enable_current_mirror = 1,
985
	.disable_sample_and_hold = 0,
986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015
};

static int stk7770p_frontend_attach(struct dvb_usb_adapter *adap)
{
	struct usb_device_descriptor *p = &adap->dev->udev->descriptor;
	if (p->idVendor  == cpu_to_le16(USB_VID_PINNACLE) &&
	    p->idProduct == cpu_to_le16(USB_PID_PINNACLE_PCTV72E))
		dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
	else
		dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
	msleep(10);
	dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
	dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
	dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
	dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);

	dib0700_ctrl_clock(adap->dev, 72, 1);

	msleep(10);
	dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
	msleep(10);
	dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);

	if (dib7000p_i2c_enumeration(&adap->dev->i2c_adap, 1, 18,
				     &dib7770p_dib7000p_config) != 0) {
		err("%s: dib7000p_i2c_enumeration failed.  Cannot continue\n",
		    __func__);
		return -ENODEV;
	}

1016
	adap->fe_adap[0].fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 0x80,
1017
		&dib7770p_dib7000p_config);
1018
	return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
1019 1020
}

1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161
/* DIB807x generic */
static struct dibx000_agc_config dib807x_agc_config[2] = {
	{
		BAND_VHF,
		/* 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,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 */
		(0 << 15) | (0 << 14) | (7 << 11) | (0 << 10) | (0 << 9) |
			(0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) |
			(0 << 0), /* setup*/

		600, /* inv_gain*/
		10,  /* time_stabiliz*/

		0,  /* alpha_level*/
		118,  /* thlock*/

		0,     /* wbd_inv*/
		3530,  /* wbd_ref*/
		1,     /* wbd_sel*/
		5,     /* wbd_alpha*/

		65535,  /* agc1_max*/
		0,  /* agc1_min*/

		65535,  /* agc2_max*/
		0,      /* agc2_min*/

		0,      /* agc1_pt1*/
		40,     /* agc1_pt2*/
		183,    /* agc1_pt3*/
		206,    /* agc1_slope1*/
		255,    /* agc1_slope2*/
		72,     /* agc2_pt1*/
		152,    /* agc2_pt2*/
		88,     /* agc2_slope1*/
		90,     /* agc2_slope2*/

		17,  /* alpha_mant*/
		27,  /* alpha_exp*/
		23,  /* beta_mant*/
		51,  /* beta_exp*/

		0,  /* perform_agc_softsplit*/
	}, {
		BAND_UHF,
		/* 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, 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 */
		(0 << 15) | (0 << 14) | (1 << 11) | (0 << 10) | (0 << 9) |
			(0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) |
			(0 << 0), /* setup */

		600, /* inv_gain*/
		10,  /* time_stabiliz*/

		0,  /* alpha_level*/
		118,  /* thlock*/

		0,     /* wbd_inv*/
		3530,  /* wbd_ref*/
		1,     /* wbd_sel*/
		5,     /* wbd_alpha*/

		65535,  /* agc1_max*/
		0,  /* agc1_min*/

		65535,  /* agc2_max*/
		0,      /* agc2_min*/

		0,      /* agc1_pt1*/
		40,     /* agc1_pt2*/
		183,    /* agc1_pt3*/
		206,    /* agc1_slope1*/
		255,    /* agc1_slope2*/
		72,     /* agc2_pt1*/
		152,    /* agc2_pt2*/
		88,     /* agc2_slope1*/
		90,     /* agc2_slope2*/

		17,  /* alpha_mant*/
		27,  /* alpha_exp*/
		23,  /* beta_mant*/
		51,  /* beta_exp*/

		0,  /* perform_agc_softsplit*/
	}
};

static struct dibx000_bandwidth_config dib807x_bw_config_12_mhz = {
	60000, 15000, /* internal, sampling*/
	1, 20, 3, 1, 0, /* pll_cfg: prediv, ratio, range, reset, bypass*/
	0, 0, 1, 1, 2, /* misc: refdiv, bypclk_div, IO_CLK_en_core,
			  ADClkSrc, modulo */
	(3 << 14) | (1 << 12) | (599 << 0), /* sad_cfg: refsel, sel, freq_15k*/
	(0 << 25) | 0, /* ifreq = 0.000000 MHz*/
	18179755, /* timf*/
	12000000, /* xtal_hz*/
};

static struct dib8000_config dib807x_dib8000_config[2] = {
	{
		.output_mpeg2_in_188_bytes = 1,

		.agc_config_count = 2,
		.agc = dib807x_agc_config,
		.pll = &dib807x_bw_config_12_mhz,
		.tuner_is_baseband = 1,

		.gpio_dir = DIB8000_GPIO_DEFAULT_DIRECTIONS,
		.gpio_val = DIB8000_GPIO_DEFAULT_VALUES,
		.gpio_pwm_pos = DIB8000_GPIO_DEFAULT_PWM_POS,

		.hostbus_diversity = 1,
		.div_cfg = 1,
		.agc_control = &dib0070_ctrl_agc_filter,
		.output_mode = OUTMODE_MPEG2_FIFO,
		.drives = 0x2d98,
	}, {
		.output_mpeg2_in_188_bytes = 1,

		.agc_config_count = 2,
		.agc = dib807x_agc_config,
		.pll = &dib807x_bw_config_12_mhz,
		.tuner_is_baseband = 1,

		.gpio_dir = DIB8000_GPIO_DEFAULT_DIRECTIONS,
		.gpio_val = DIB8000_GPIO_DEFAULT_VALUES,
		.gpio_pwm_pos = DIB8000_GPIO_DEFAULT_PWM_POS,

		.hostbus_diversity = 1,
		.agc_control = &dib0070_ctrl_agc_filter,
		.output_mode = OUTMODE_MPEG2_FIFO,
		.drives = 0x2d98,
	}
};

1162
static int dib80xx_tuner_reset(struct dvb_frontend *fe, int onoff)
1163 1164 1165 1166
{
	return dib8000_set_gpio(fe, 5, 0, !onoff);
}

1167
static int dib80xx_tuner_sleep(struct dvb_frontend *fe, int onoff)
1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179
{
	return dib8000_set_gpio(fe, 0, 0, onoff);
}

static const struct dib0070_wbd_gain_cfg dib8070_wbd_gain_cfg[] = {
    { 240,      7},
    { 0xffff,   6},
};

static struct dib0070_config dib807x_dib0070_config[2] = {
	{
		.i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
1180 1181
		.reset = dib80xx_tuner_reset,
		.sleep = dib80xx_tuner_sleep,
1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193
		.clock_khz = 12000,
		.clock_pad_drive = 4,
		.vga_filter = 1,
		.force_crystal_mode = 1,
		.enable_third_order_filter = 1,
		.charge_pump = 0,
		.wbd_gain = dib8070_wbd_gain_cfg,
		.osc_buffer_state = 0,
		.freq_offset_khz_uhf = -100,
		.freq_offset_khz_vhf = -100,
	}, {
		.i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
1194 1195
		.reset = dib80xx_tuner_reset,
		.sleep = dib80xx_tuner_sleep,
1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208
		.clock_khz = 12000,
		.clock_pad_drive = 2,
		.vga_filter = 1,
		.force_crystal_mode = 1,
		.enable_third_order_filter = 1,
		.charge_pump = 0,
		.wbd_gain = dib8070_wbd_gain_cfg,
		.osc_buffer_state = 0,
		.freq_offset_khz_uhf = -25,
		.freq_offset_khz_vhf = -25,
	}
};

1209
static int dib807x_set_param_override(struct dvb_frontend *fe)
1210
{
1211
	struct dtv_frontend_properties *p = &fe->dtv_property_cache;
1212 1213 1214 1215
	struct dvb_usb_adapter *adap = fe->dvb->priv;
	struct dib0700_adapter_state *state = adap->priv;

	u16 offset = dib0070_wbd_offset(fe);
1216
	u8 band = BAND_OF_FREQUENCY(p->frequency/1000);
1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227
	switch (band) {
	case BAND_VHF:
		offset += 750;
		break;
	case BAND_UHF:  /* fall-thru wanted */
	default:
		offset += 250; break;
	}
	deb_info("WBD for DiB8000: %d\n", offset);
	dib8000_set_wbd_ref(fe, offset);

1228
	return state->set_param_save(fe);
1229 1230 1231 1232 1233
}

static int dib807x_tuner_attach(struct dvb_usb_adapter *adap)
{
	struct dib0700_adapter_state *st = adap->priv;
1234
	struct i2c_adapter *tun_i2c = dib8000_get_i2c_master(adap->fe_adap[0].fe,
1235 1236 1237
			DIBX000_I2C_INTERFACE_TUNER, 1);

	if (adap->id == 0) {
1238
		if (dvb_attach(dib0070_attach, adap->fe_adap[0].fe, tun_i2c,
1239 1240 1241
				&dib807x_dib0070_config[0]) == NULL)
			return -ENODEV;
	} else {
1242
		if (dvb_attach(dib0070_attach, adap->fe_adap[0].fe, tun_i2c,
1243 1244 1245 1246
				&dib807x_dib0070_config[1]) == NULL)
			return -ENODEV;
	}

1247 1248
	st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
	adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib807x_set_param_override;
1249 1250 1251
	return 0;
}

1252 1253
static int stk80xx_pid_filter(struct dvb_usb_adapter *adapter, int index,
	u16 pid, int onoff)
1254
{
1255
	return dib8000_pid_filter(adapter->fe_adap[0].fe, index, pid, onoff);
1256 1257
}

1258
static int stk80xx_pid_filter_ctrl(struct dvb_usb_adapter *adapter,
1259
		int onoff)
1260
{
1261
	return dib8000_pid_filter_ctrl(adapter->fe_adap[0].fe, onoff);
1262
}
1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282

/* STK807x */
static int stk807x_frontend_attach(struct dvb_usb_adapter *adap)
{
	dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
	msleep(10);
	dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
	dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
	dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);

	dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);

	dib0700_ctrl_clock(adap->dev, 72, 1);

	msleep(10);
	dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
	msleep(10);
	dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);

	dib8000_i2c_enumeration(&adap->dev->i2c_adap, 1, 18,
1283
				0x80, 0);
1284

1285
	adap->fe_adap[0].fe = dvb_attach(dib8000_attach, &adap->dev->i2c_adap, 0x80,
1286 1287
			      &dib807x_dib8000_config[0]);

1288
	return adap->fe_adap[0].fe == NULL ?  -ENODEV : 0;
1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311
}

/* STK807xPVR */
static int stk807xpvr_frontend_attach0(struct dvb_usb_adapter *adap)
{
	dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
	msleep(30);
	dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
	msleep(500);
	dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
	dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
	dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);

	dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);

	dib0700_ctrl_clock(adap->dev, 72, 1);

	msleep(10);
	dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
	msleep(10);
	dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);

	/* initialize IC 0 */
1312
	dib8000_i2c_enumeration(&adap->dev->i2c_adap, 1, 0x22, 0x80, 0);
1313

1314
	adap->fe_adap[0].fe = dvb_attach(dib8000_attach, &adap->dev->i2c_adap, 0x80,
1315 1316
			      &dib807x_dib8000_config[0]);

1317
	return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
1318 1319 1320 1321 1322
}

static int stk807xpvr_frontend_attach1(struct dvb_usb_adapter *adap)
{
	/* initialize IC 1 */
1323
	dib8000_i2c_enumeration(&adap->dev->i2c_adap, 1, 0x12, 0x82, 0);
1324

1325
	adap->fe_adap[0].fe = dvb_attach(dib8000_attach, &adap->dev->i2c_adap, 0x82,
1326 1327
			      &dib807x_dib8000_config[1]);

1328
	return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
1329 1330
}

1331
/* STK8096GP */
O
Olivier Grenie 已提交
1332
static struct dibx000_agc_config dib8090_agc_config[2] = {
1333
	{
1334
	BAND_UHF | BAND_VHF | BAND_LBAND | BAND_SBAND,
1335
	/* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=1,
1336 1337
	 * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, 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 */
1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373
	(0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8)
	| (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),

	787,
	10,

	0,
	118,

	0,
	3530,
	1,
	5,

	65535,
	0,

	65535,
	0,

	0,
	32,
	114,
	143,
	144,
	114,
	227,
	116,
	117,

	28,
	26,
	31,
	51,

	0,
1374 1375
	},
	{
1376
	BAND_CBAND,
1377
	/* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=1,
1378 1379
	 * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, 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 */
1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415
	(0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8)
	| (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),

	787,
	10,

	0,
	118,

	0,
	3530,
	1,
	5,

	0,
	0,

	65535,
	0,

	0,
	32,
	114,
	143,
	144,
	114,
	227,
	116,
	117,

	28,
	26,
	31,
	51,

	0,
1416
	}
1417 1418 1419
};

static struct dibx000_bandwidth_config dib8090_pll_config_12mhz = {
1420 1421 1422 1423 1424 1425 1426
	54000, 13500,
	1, 18, 3, 1, 0,
	0, 0, 1, 1, 2,
	(3 << 14) | (1 << 12) | (599 << 0),
	(0 << 25) | 0,
	20199727,
	12000000,
1427 1428 1429 1430
};

static int dib8090_get_adc_power(struct dvb_frontend *fe)
{
1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453
	return dib8000_get_adc_power(fe, 1);
}

static struct dib8000_config dib809x_dib8000_config[2] = {
	{
	.output_mpeg2_in_188_bytes = 1,

	.agc_config_count = 2,
	.agc = dib8090_agc_config,
	.agc_control = dib0090_dcc_freq,
	.pll = &dib8090_pll_config_12mhz,
	.tuner_is_baseband = 1,

	.gpio_dir = DIB8000_GPIO_DEFAULT_DIRECTIONS,
	.gpio_val = DIB8000_GPIO_DEFAULT_VALUES,
	.gpio_pwm_pos = DIB8000_GPIO_DEFAULT_PWM_POS,

	.hostbus_diversity = 1,
	.div_cfg = 0x31,
	.output_mode = OUTMODE_MPEG2_FIFO,
	.drives = 0x2d98,
	.diversity_delay = 48,
	.refclksel = 3,
1454
	}, {
1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506
	.output_mpeg2_in_188_bytes = 1,

	.agc_config_count = 2,
	.agc = dib8090_agc_config,
	.agc_control = dib0090_dcc_freq,
	.pll = &dib8090_pll_config_12mhz,
	.tuner_is_baseband = 1,

	.gpio_dir = DIB8000_GPIO_DEFAULT_DIRECTIONS,
	.gpio_val = DIB8000_GPIO_DEFAULT_VALUES,
	.gpio_pwm_pos = DIB8000_GPIO_DEFAULT_PWM_POS,

	.hostbus_diversity = 1,
	.div_cfg = 0x31,
	.output_mode = OUTMODE_DIVERSITY,
	.drives = 0x2d08,
	.diversity_delay = 1,
	.refclksel = 3,
	}
};

static struct dib0090_wbd_slope dib8090_wbd_table[] = {
	/* max freq ; cold slope ; cold offset ; warm slope ; warm offset ; wbd gain */
	{ 120,     0, 500,  0,   500, 4 }, /* CBAND */
	{ 170,     0, 450,  0,   450, 4 }, /* CBAND */
	{ 380,    48, 373, 28,   259, 6 }, /* VHF */
	{ 860,    34, 700, 36,   616, 6 }, /* high UHF */
	{ 0xFFFF, 34, 700, 36,   616, 6 }, /* default */
};

static struct dib0090_config dib809x_dib0090_config = {
	.io.pll_bypass = 1,
	.io.pll_range = 1,
	.io.pll_prediv = 1,
	.io.pll_loopdiv = 20,
	.io.adc_clock_ratio = 8,
	.io.pll_int_loop_filt = 0,
	.io.clock_khz = 12000,
	.reset = dib80xx_tuner_reset,
	.sleep = dib80xx_tuner_sleep,
	.clkouttobamse = 1,
	.analog_output = 1,
	.i2c_address = DEFAULT_DIB0090_I2C_ADDRESS,
	.use_pwm_agc = 1,
	.clkoutdrive = 1,
	.get_adc_power = dib8090_get_adc_power,
	.freq_offset_khz_uhf = -63,
	.freq_offset_khz_vhf = -143,
	.wbd = dib8090_wbd_table,
	.fref_clock_ratio = 6,
};

1507
static int dib8096_set_param_override(struct dvb_frontend *fe)
1508
{
1509
	struct dtv_frontend_properties *p = &fe->dtv_property_cache;
1510 1511
	struct dvb_usb_adapter *adap = fe->dvb->priv;
	struct dib0700_adapter_state *state = adap->priv;
1512
	u8 band = BAND_OF_FREQUENCY(p->frequency/1000);
1513 1514 1515 1516 1517
	u16 target;
	int ret = 0;
	enum frontend_tune_state tune_state = CT_SHUTDOWN;
	u16 ltgain, rf_gain_limit;

1518
	ret = state->set_param_save(fe);
1519 1520 1521
	if (ret < 0)
		return ret;

1522
	target = (dib0090_get_wbd_target(fe) * 8 * 18 / 33 + 1) / 2;
1523 1524 1525 1526
	dib8000_set_wbd_ref(fe, target);


	if (band == BAND_CBAND) {
1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543
		deb_info("tuning in CBAND - soft-AGC startup\n");
		dib0090_set_tune_state(fe, CT_AGC_START);
		do {
			ret = dib0090_gain_control(fe);
			msleep(ret);
			tune_state = dib0090_get_tune_state(fe);
			if (tune_state == CT_AGC_STEP_0)
				dib8000_set_gpio(fe, 6, 0, 1);
			else if (tune_state == CT_AGC_STEP_1) {
				dib0090_get_current_gain(fe, NULL, NULL, &rf_gain_limit, &ltgain);
				if (rf_gain_limit == 0)
					dib8000_set_gpio(fe, 6, 0, 0);
			}
		} while (tune_state < CT_AGC_STOP);
		dib0090_pwm_gain_reset(fe);
		dib8000_pwm_agc_reset(fe);
		dib8000_set_tune_state(fe, CT_DEMOD_START);
1544
	} else {
1545 1546
		deb_info("not tuning in CBAND - standard AGC startup\n");
		dib0090_pwm_gain_reset(fe);
1547 1548 1549 1550 1551 1552 1553 1554
	}

	return 0;
}

static int dib809x_tuner_attach(struct dvb_usb_adapter *adap)
{
	struct dib0700_adapter_state *st = adap->priv;
1555
	struct i2c_adapter *tun_i2c = dib8000_get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_TUNER, 1);
1556

1557
	if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c, &dib809x_dib0090_config) == NULL)
1558 1559
		return -ENODEV;

1560 1561
	st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
	adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib8096_set_param_override;
1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581
	return 0;
}

static int stk809x_frontend_attach(struct dvb_usb_adapter *adap)
{
	dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
	msleep(10);
	dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
	dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
	dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);

	dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);

	dib0700_ctrl_clock(adap->dev, 72, 1);

	msleep(10);
	dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
	msleep(10);
	dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);

1582
	dib8000_i2c_enumeration(&adap->dev->i2c_adap, 1, 18, 0x80, 0);
1583

1584
	adap->fe_adap[0].fe = dvb_attach(dib8000_attach, &adap->dev->i2c_adap, 0x80, &dib809x_dib8000_config[0]);
1585

1586
	return adap->fe_adap[0].fe == NULL ?  -ENODEV : 0;
1587 1588 1589 1590 1591 1592
}

static int nim8096md_tuner_attach(struct dvb_usb_adapter *adap)
{
	struct dib0700_adapter_state *st = adap->priv;
	struct i2c_adapter *tun_i2c;
1593
	struct dvb_frontend *fe_slave  = dib8000_get_slave_frontend(adap->fe_adap[0].fe, 1);
1594 1595 1596 1597 1598

	if (fe_slave) {
		tun_i2c = dib8000_get_i2c_master(fe_slave, DIBX000_I2C_INTERFACE_TUNER, 1);
		if (dvb_attach(dib0090_register, fe_slave, tun_i2c, &dib809x_dib0090_config) == NULL)
			return -ENODEV;
1599
		fe_slave->dvb = adap->fe_adap[0].fe->dvb;
1600 1601
		fe_slave->ops.tuner_ops.set_params = dib8096_set_param_override;
	}
1602 1603
	tun_i2c = dib8000_get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_TUNER, 1);
	if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c, &dib809x_dib0090_config) == NULL)
1604 1605
		return -ENODEV;

1606 1607
	st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
	adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib8096_set_param_override;
1608 1609 1610 1611 1612 1613 1614 1615 1616

	return 0;
}

static int nim8096md_frontend_attach(struct dvb_usb_adapter *adap)
{
	struct dvb_frontend *fe_slave;

	dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
1617
	msleep(20);
1618 1619 1620 1621 1622 1623 1624 1625 1626 1627
	dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
	msleep(1000);
	dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
	dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
	dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);

	dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);

	dib0700_ctrl_clock(adap->dev, 72, 1);

1628
	msleep(20);
1629
	dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
1630
	msleep(20);
1631 1632
	dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);

1633
	dib8000_i2c_enumeration(&adap->dev->i2c_adap, 2, 18, 0x80, 0);
1634

1635 1636
	adap->fe_adap[0].fe = dvb_attach(dib8000_attach, &adap->dev->i2c_adap, 0x80, &dib809x_dib8000_config[0]);
	if (adap->fe_adap[0].fe == NULL)
1637 1638 1639
		return -ENODEV;

	fe_slave = dvb_attach(dib8000_attach, &adap->dev->i2c_adap, 0x82, &dib809x_dib8000_config[1]);
1640
	dib8000_set_slave_frontend(adap->fe_adap[0].fe, fe_slave);
1641 1642 1643 1644

	return fe_slave == NULL ?  -ENODEV : 0;
}

1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822
/* TFE8096P */
static struct dibx000_agc_config dib8096p_agc_config[2] = {
	{
		.band_caps		= BAND_UHF,
		/* 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, 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 */
		.setup			= (0 << 15) | (0 << 14) | (5 << 11)
			| (0 << 10) | (0 << 9) | (0 << 8) | (3 << 5)
			| (0 << 4) | (5 << 1) | (0 << 0),

		.inv_gain		= 684,
		.time_stabiliz	= 10,

		.alpha_level	= 0,
		.thlock			= 118,

		.wbd_inv		= 0,
		.wbd_ref		= 1200,
		.wbd_sel		= 3,
		.wbd_alpha		= 5,

		.agc1_max		= 65535,
		.agc1_min		= 0,

		.agc2_max		= 32767,
		.agc2_min		= 0,

		.agc1_pt1		= 0,
		.agc1_pt2		= 0,
		.agc1_pt3		= 105,
		.agc1_slope1	= 0,
		.agc1_slope2	= 156,
		.agc2_pt1		= 105,
		.agc2_pt2		= 255,
		.agc2_slope1	= 54,
		.agc2_slope2	= 0,

		.alpha_mant		= 28,
		.alpha_exp		= 26,
		.beta_mant		= 31,
		.beta_exp		= 51,

		.perform_agc_softsplit = 0,
	} , {
		.band_caps		= BAND_FM | BAND_VHF | BAND_CBAND,
		/* 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, 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 */
		.setup			= (0 << 15) | (0 << 14) | (5 << 11)
			| (0 << 10) | (0 << 9) | (0 << 8) | (3 << 5)
			| (0 << 4) | (5 << 1) | (0 << 0),

		.inv_gain		= 732,
		.time_stabiliz  = 10,

		.alpha_level	= 0,
		.thlock			= 118,

		.wbd_inv		= 0,
		.wbd_ref		= 1200,
		.wbd_sel		= 3,
		.wbd_alpha		= 5,

		.agc1_max		= 65535,
		.agc1_min		= 0,

		.agc2_max		= 32767,
		.agc2_min		= 0,

		.agc1_pt1		= 0,
		.agc1_pt2		= 0,
		.agc1_pt3		= 98,
		.agc1_slope1	= 0,
		.agc1_slope2	= 167,
		.agc2_pt1		= 98,
		.agc2_pt2		= 255,
		.agc2_slope1	= 52,
		.agc2_slope2	= 0,

		.alpha_mant		= 28,
		.alpha_exp		= 26,
		.beta_mant		= 31,
		.beta_exp		= 51,

		.perform_agc_softsplit = 0,
	}
};

static struct dibx000_bandwidth_config dib8096p_clock_config_12_mhz = {
	108000, 13500,
	1, 9, 1, 0, 0,
	0, 0, 0, 0, 2,
	(3 << 14) | (1 << 12) | (524 << 0),
	(0 << 25) | 0,
	20199729,
	12000000,
};

static struct dib8000_config tfe8096p_dib8000_config = {
	.output_mpeg2_in_188_bytes	= 1,
	.hostbus_diversity			= 1,
	.update_lna					= NULL,

	.agc_config_count			= 2,
	.agc						= dib8096p_agc_config,
	.pll						= &dib8096p_clock_config_12_mhz,

	.gpio_dir					= DIB8000_GPIO_DEFAULT_DIRECTIONS,
	.gpio_val					= DIB8000_GPIO_DEFAULT_VALUES,
	.gpio_pwm_pos				= DIB8000_GPIO_DEFAULT_PWM_POS,

	.agc_control				= NULL,
	.diversity_delay			= 48,
	.output_mode				= OUTMODE_MPEG2_FIFO,
	.enMpegOutput				= 1,
};

static struct dib0090_wbd_slope dib8096p_wbd_table[] = {
	{ 380, 81, 850, 64, 540, 4},
	{ 860, 51, 866, 21, 375, 4},
	{1700, 0, 250, 0, 100, 6},
	{2600, 0, 250, 0, 100, 6},
	{ 0xFFFF, 0, 0, 0, 0, 0},
};

static const struct dib0090_config tfe8096p_dib0090_config = {
	.io.clock_khz			= 12000,
	.io.pll_bypass			= 0,
	.io.pll_range			= 0,
	.io.pll_prediv			= 3,
	.io.pll_loopdiv			= 6,
	.io.adc_clock_ratio		= 0,
	.io.pll_int_loop_filt	= 0,
	.reset					= dib8096p_tuner_sleep,
	.sleep					= dib8096p_tuner_sleep,

	.freq_offset_khz_uhf	= -143,
	.freq_offset_khz_vhf	= -143,

	.get_adc_power			= dib8090_get_adc_power,

	.clkouttobamse			= 1,
	.analog_output			= 0,

	.wbd_vhf_offset			= 0,
	.wbd_cband_offset		= 0,
	.use_pwm_agc			= 1,
	.clkoutdrive			= 0,

	.fref_clock_ratio		= 1,

	.wbd					= dib8096p_wbd_table,

	.ls_cfg_pad_drv			= 0,
	.data_tx_drv			= 0,
	.low_if					= NULL,
	.in_soc					= 1,
	.force_cband_input		= 0,
};

struct dibx090p_adc {
	u32 freq;			/* RF freq MHz */
	u32 timf;			/* New Timf */
	u32 pll_loopdiv;	/* New prediv */
	u32 pll_prediv;		/* New loopdiv */
};

struct dibx090p_adc dib8090p_adc_tab[] = {
	{ 50000, 17043521, 16, 3}, /* 64 MHz */
	{878000, 20199729, 9, 1}, /* 60 MHz */
	{0xffffffff, 0, 0, 0}, /* 60 MHz */
};

1823
static int dib8096p_agc_startup(struct dvb_frontend *fe)
1824
{
1825
	struct dtv_frontend_properties *p = &fe->dtv_property_cache;
1826 1827 1828 1829 1830 1831 1832
	struct dvb_usb_adapter *adap = fe->dvb->priv;
	struct dib0700_adapter_state *state = adap->priv;
	struct dibx000_bandwidth_config pll;
	u16 target;
	int better_sampling_freq = 0, ret;
	struct dibx090p_adc *adc_table = &dib8090p_adc_tab[0];

1833
	ret = state->set_param_save(fe);
1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844
	if (ret < 0)
		return ret;
	memset(&pll, 0, sizeof(struct dibx000_bandwidth_config));

	dib0090_pwm_gain_reset(fe);
	/* dib0090_get_wbd_target is returning any possible
	   temperature compensated wbd-target */
	target = (dib0090_get_wbd_target(fe) * 8  + 1) / 2;
	dib8000_set_wbd_ref(fe, target);


1845
	while (p->frequency / 1000 > adc_table->freq) {
1846 1847 1848 1849 1850 1851 1852
		better_sampling_freq = 1;
		adc_table++;
	}

	if ((adc_table->freq != 0xffffffff) && better_sampling_freq) {
		pll.pll_ratio  = adc_table->pll_loopdiv;
		pll.pll_prediv = adc_table->pll_prediv;
P
Patrick Boettcher 已提交
1853
		dib8000_update_pll(fe, &pll, fe->dtv_property_cache.bandwidth_hz / 1000, 0);
1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899
		dib8000_ctrl_timf(fe, DEMOD_TIMF_SET, adc_table->timf);
	}
	return 0;
}

static int tfe8096p_frontend_attach(struct dvb_usb_adapter *adap)
{
	dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
	msleep(20);
	dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
	dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
	dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);

	dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);

	dib0700_ctrl_clock(adap->dev, 72, 1);

	msleep(20);
	dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
	msleep(20);
	dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);

	dib8000_i2c_enumeration(&adap->dev->i2c_adap, 1, 0x10, 0x80, 1);

	adap->fe_adap[0].fe = dvb_attach(dib8000_attach,
			&adap->dev->i2c_adap, 0x80, &tfe8096p_dib8000_config);

	return adap->fe_adap[0].fe == NULL ?  -ENODEV : 0;
}

static int tfe8096p_tuner_attach(struct dvb_usb_adapter *adap)
{
	struct dib0700_adapter_state *st = adap->priv;
	struct i2c_adapter *tun_i2c = dib8096p_get_i2c_tuner(adap->fe_adap[0].fe);

	if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c,
				&tfe8096p_dib0090_config) == NULL)
		return -ENODEV;

	dib8000_set_gpio(adap->fe_adap[0].fe, 8, 0, 1);

	st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
	adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib8096p_agc_startup;
	return 0;
}

1900 1901 1902
/* STK9090M */
static int dib90x0_pid_filter(struct dvb_usb_adapter *adapter, int index, u16 pid, int onoff)
{
1903
	return dib9000_fw_pid_filter(adapter->fe_adap[0].fe, index, pid, onoff);
1904 1905 1906 1907
}

static int dib90x0_pid_filter_ctrl(struct dvb_usb_adapter *adapter, int onoff)
{
1908
	return dib9000_fw_pid_filter_ctrl(adapter->fe_adap[0].fe, onoff);
1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925
}

static int dib90x0_tuner_reset(struct dvb_frontend *fe, int onoff)
{
	return dib9000_set_gpio(fe, 5, 0, !onoff);
}

static int dib90x0_tuner_sleep(struct dvb_frontend *fe, int onoff)
{
	return dib9000_set_gpio(fe, 0, 0, onoff);
}

static int dib01x0_pmu_update(struct i2c_adapter *i2c, u16 *data, u8 len)
{
	u8 wb[4] = { 0xc >> 8, 0xc & 0xff, 0, 0 };
	u8 rb[2];
	struct i2c_msg msg[2] = {
1926 1927
		{.addr = 0x1e >> 1, .flags = 0, .buf = wb, .len = 2},
		{.addr = 0x1e >> 1, .flags = I2C_M_RD, .buf = rb, .len = 2},
1928 1929 1930 1931 1932 1933 1934 1935 1936
	};
	u8 index_data;

	dibx000_i2c_set_speed(i2c, 250);

	if (i2c_transfer(i2c, msg, 2) != 2)
		return -EIO;

	switch (rb[0] << 8 | rb[1]) {
1937
	case 0:
1938 1939
			deb_info("Found DiB0170 rev1: This version of DiB0170 is not supported any longer.\n");
			return -EIO;
1940
	case 1:
1941 1942
			deb_info("Found DiB0170 rev2");
			break;
1943
	case 2:
1944 1945
			deb_info("Found DiB0190 rev2");
			break;
1946
	default:
1947 1948
			deb_info("DiB01x0 not found");
			return -EIO;
1949
	}
1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964

	for (index_data = 0; index_data < len; index_data += 2) {
		wb[2] = (data[index_data + 1] >> 8) & 0xff;
		wb[3] = (data[index_data + 1]) & 0xff;

		if (data[index_data] == 0) {
			wb[0] = (data[index_data] >> 8) & 0xff;
			wb[1] = (data[index_data]) & 0xff;
			msg[0].len = 2;
			if (i2c_transfer(i2c, msg, 2) != 2)
				return -EIO;
			wb[2] |= rb[0];
			wb[3] |= rb[1] & ~(3 << 4);
		}

1965 1966
		wb[0] = (data[index_data] >> 8)&0xff;
		wb[1] = (data[index_data])&0xff;
1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062
		msg[0].len = 4;
		if (i2c_transfer(i2c, &msg[0], 1) != 1)
			return -EIO;
	}
	return 0;
}

static struct dib9000_config stk9090m_config = {
	.output_mpeg2_in_188_bytes = 1,
	.output_mode = OUTMODE_MPEG2_FIFO,
	.vcxo_timer = 279620,
	.timing_frequency = 20452225,
	.demod_clock_khz = 60000,
	.xtal_clock_khz = 30000,
	.if_drives = (0 << 15) | (1 << 13) | (0 << 12) | (3 << 10) | (0 << 9) | (1 << 7) | (0 << 6) | (0 << 4) | (1 << 3) | (1 << 1) | (0),
	.subband = {
		2,
		{
			{ 240, { BOARD_GPIO_COMPONENT_DEMOD, BOARD_GPIO_FUNCTION_SUBBAND_GPIO, 0x0008, 0x0000, 0x0008 } }, /* GPIO 3 to 1 for VHF */
			{ 890, { BOARD_GPIO_COMPONENT_DEMOD, BOARD_GPIO_FUNCTION_SUBBAND_GPIO, 0x0008, 0x0000, 0x0000 } }, /* GPIO 3 to 0 for UHF */
			{ 0 },
		},
	},
	.gpio_function = {
		{ .component = BOARD_GPIO_COMPONENT_DEMOD, .function = BOARD_GPIO_FUNCTION_COMPONENT_ON, .mask = 0x10 | 0x21, .direction = 0 & ~0x21, .value = (0x10 & ~0x1) | 0x20 },
		{ .component = BOARD_GPIO_COMPONENT_DEMOD, .function = BOARD_GPIO_FUNCTION_COMPONENT_OFF, .mask = 0x10 | 0x21, .direction = 0 & ~0x21, .value = 0 | 0x21 },
	},
};

static struct dib9000_config nim9090md_config[2] = {
	{
		.output_mpeg2_in_188_bytes = 1,
		.output_mode = OUTMODE_MPEG2_FIFO,
		.vcxo_timer = 279620,
		.timing_frequency = 20452225,
		.demod_clock_khz = 60000,
		.xtal_clock_khz = 30000,
		.if_drives = (0 << 15) | (1 << 13) | (0 << 12) | (3 << 10) | (0 << 9) | (1 << 7) | (0 << 6) | (0 << 4) | (1 << 3) | (1 << 1) | (0),
	}, {
		.output_mpeg2_in_188_bytes = 1,
		.output_mode = OUTMODE_DIVERSITY,
		.vcxo_timer = 279620,
		.timing_frequency = 20452225,
		.demod_clock_khz = 60000,
		.xtal_clock_khz = 30000,
		.if_drives = (0 << 15) | (1 << 13) | (0 << 12) | (3 << 10) | (0 << 9) | (1 << 7) | (0 << 6) | (0 << 4) | (1 << 3) | (1 << 1) | (0),
		.subband = {
			2,
			{
				{ 240, { BOARD_GPIO_COMPONENT_DEMOD, BOARD_GPIO_FUNCTION_SUBBAND_GPIO, 0x0006, 0x0000, 0x0006 } }, /* GPIO 1 and 2 to 1 for VHF */
				{ 890, { BOARD_GPIO_COMPONENT_DEMOD, BOARD_GPIO_FUNCTION_SUBBAND_GPIO, 0x0006, 0x0000, 0x0000 } }, /* GPIO 1 and 2 to 0 for UHF */
				{ 0 },
			},
		},
		.gpio_function = {
			{ .component = BOARD_GPIO_COMPONENT_DEMOD, .function = BOARD_GPIO_FUNCTION_COMPONENT_ON, .mask = 0x10 | 0x21, .direction = 0 & ~0x21, .value = (0x10 & ~0x1) | 0x20 },
			{ .component = BOARD_GPIO_COMPONENT_DEMOD, .function = BOARD_GPIO_FUNCTION_COMPONENT_OFF, .mask = 0x10 | 0x21, .direction = 0 & ~0x21, .value = 0 | 0x21 },
		},
	}
};

static struct dib0090_config dib9090_dib0090_config = {
	.io.pll_bypass = 0,
	.io.pll_range = 1,
	.io.pll_prediv = 1,
	.io.pll_loopdiv = 8,
	.io.adc_clock_ratio = 8,
	.io.pll_int_loop_filt = 0,
	.io.clock_khz = 30000,
	.reset = dib90x0_tuner_reset,
	.sleep = dib90x0_tuner_sleep,
	.clkouttobamse = 0,
	.analog_output = 0,
	.use_pwm_agc = 0,
	.clkoutdrive = 0,
	.freq_offset_khz_uhf = 0,
	.freq_offset_khz_vhf = 0,
};

static struct dib0090_config nim9090md_dib0090_config[2] = {
	{
		.io.pll_bypass = 0,
		.io.pll_range = 1,
		.io.pll_prediv = 1,
		.io.pll_loopdiv = 8,
		.io.adc_clock_ratio = 8,
		.io.pll_int_loop_filt = 0,
		.io.clock_khz = 30000,
		.reset = dib90x0_tuner_reset,
		.sleep = dib90x0_tuner_sleep,
		.clkouttobamse = 1,
		.analog_output = 0,
		.use_pwm_agc = 0,
		.clkoutdrive = 0,
		.freq_offset_khz_uhf = 0,
		.freq_offset_khz_vhf = 0,
2063
	}, {
2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095
		.io.pll_bypass = 0,
		.io.pll_range = 1,
		.io.pll_prediv = 1,
		.io.pll_loopdiv = 8,
		.io.adc_clock_ratio = 8,
		.io.pll_int_loop_filt = 0,
		.io.clock_khz = 30000,
		.reset = dib90x0_tuner_reset,
		.sleep = dib90x0_tuner_sleep,
		.clkouttobamse = 0,
		.analog_output = 0,
		.use_pwm_agc = 0,
		.clkoutdrive = 0,
		.freq_offset_khz_uhf = 0,
		.freq_offset_khz_vhf = 0,
	}
};


static int stk9090m_frontend_attach(struct dvb_usb_adapter *adap)
{
	struct dib0700_adapter_state *state = adap->priv;
	struct dib0700_state *st = adap->dev->priv;
	u32 fw_version;

	/* Make use of the new i2c functions from FW 1.20 */
	dib0700_get_version(adap->dev, NULL, NULL, &fw_version, NULL);
	if (fw_version >= 0x10200)
		st->fw_use_new_i2c_api = 1;
	dib0700_set_i2c_speed(adap->dev, 340);

	dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
2096
	msleep(20);
2097 2098 2099 2100 2101 2102 2103
	dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
	dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
	dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
	dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);

	dib0700_ctrl_clock(adap->dev, 72, 1);

2104
	msleep(20);
2105
	dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
2106
	msleep(20);
2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119
	dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);

	dib9000_i2c_enumeration(&adap->dev->i2c_adap, 1, 0x10, 0x80);

	if (request_firmware(&state->frontend_firmware, "dib9090.fw", &adap->dev->udev->dev)) {
		deb_info("%s: Upload failed. (file not found?)\n", __func__);
		return -ENODEV;
	} else {
		deb_info("%s: firmware read %Zu bytes.\n", __func__, state->frontend_firmware->size);
	}
	stk9090m_config.microcode_B_fe_size = state->frontend_firmware->size;
	stk9090m_config.microcode_B_fe_buffer = state->frontend_firmware->data;

2120
	adap->fe_adap[0].fe = dvb_attach(dib9000_attach, &adap->dev->i2c_adap, 0x80, &stk9090m_config);
2121

2122
	return adap->fe_adap[0].fe == NULL ?  -ENODEV : 0;
2123 2124 2125 2126 2127
}

static int dib9090_tuner_attach(struct dvb_usb_adapter *adap)
{
	struct dib0700_adapter_state *state = adap->priv;
2128
	struct i2c_adapter *i2c = dib9000_get_tuner_interface(adap->fe_adap[0].fe);
2129 2130 2131 2132 2133 2134 2135 2136
	u16 data_dib190[10] = {
		1, 0x1374,
		2, 0x01a2,
		7, 0x0020,
		0, 0x00ef,
		8, 0x0486,
	};

2137
	if (dvb_attach(dib0090_fw_register, adap->fe_adap[0].fe, i2c, &dib9090_dib0090_config) == NULL)
2138
		return -ENODEV;
2139
	i2c = dib9000_get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_GPIO_1_2, 0);
2140 2141
	if (dib01x0_pmu_update(i2c, data_dib190, 10) != 0)
		return -ENODEV;
2142
	dib0700_set_i2c_speed(adap->dev, 1500);
2143
	if (dib9000_firmware_post_pll_init(adap->fe_adap[0].fe) < 0)
2144
		return -ENODEV;
2145
	release_firmware(state->frontend_firmware);
2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163
	return 0;
}

static int nim9090md_frontend_attach(struct dvb_usb_adapter *adap)
{
	struct dib0700_adapter_state *state = adap->priv;
	struct dib0700_state *st = adap->dev->priv;
	struct i2c_adapter *i2c;
	struct dvb_frontend *fe_slave;
	u32 fw_version;

	/* Make use of the new i2c functions from FW 1.20 */
	dib0700_get_version(adap->dev, NULL, NULL, &fw_version, NULL);
	if (fw_version >= 0x10200)
		st->fw_use_new_i2c_api = 1;
	dib0700_set_i2c_speed(adap->dev, 340);

	dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
2164
	msleep(20);
2165 2166 2167 2168 2169 2170 2171
	dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
	dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
	dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
	dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);

	dib0700_ctrl_clock(adap->dev, 72, 1);

2172
	msleep(20);
2173
	dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
2174
	msleep(20);
2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188
	dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);

	if (request_firmware(&state->frontend_firmware, "dib9090.fw", &adap->dev->udev->dev)) {
		deb_info("%s: Upload failed. (file not found?)\n", __func__);
		return -EIO;
	} else {
		deb_info("%s: firmware read %Zu bytes.\n", __func__, state->frontend_firmware->size);
	}
	nim9090md_config[0].microcode_B_fe_size = state->frontend_firmware->size;
	nim9090md_config[0].microcode_B_fe_buffer = state->frontend_firmware->data;
	nim9090md_config[1].microcode_B_fe_size = state->frontend_firmware->size;
	nim9090md_config[1].microcode_B_fe_buffer = state->frontend_firmware->data;

	dib9000_i2c_enumeration(&adap->dev->i2c_adap, 1, 0x20, 0x80);
2189
	adap->fe_adap[0].fe = dvb_attach(dib9000_attach, &adap->dev->i2c_adap, 0x80, &nim9090md_config[0]);
2190

2191
	if (adap->fe_adap[0].fe == NULL)
2192 2193
		return -ENODEV;

2194
	i2c = dib9000_get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_GPIO_3_4, 0);
2195 2196 2197
	dib9000_i2c_enumeration(i2c, 1, 0x12, 0x82);

	fe_slave = dvb_attach(dib9000_attach, i2c, 0x82, &nim9090md_config[1]);
2198
	dib9000_set_slave_frontend(adap->fe_adap[0].fe, fe_slave);
2199 2200

	return fe_slave == NULL ?  -ENODEV : 0;
2201 2202
}

2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214
static int nim9090md_tuner_attach(struct dvb_usb_adapter *adap)
{
	struct dib0700_adapter_state *state = adap->priv;
	struct i2c_adapter *i2c;
	struct dvb_frontend *fe_slave;
	u16 data_dib190[10] = {
		1, 0x5374,
		2, 0x01ae,
		7, 0x0020,
		0, 0x00ef,
		8, 0x0406,
	};
2215 2216
	i2c = dib9000_get_tuner_interface(adap->fe_adap[0].fe);
	if (dvb_attach(dib0090_fw_register, adap->fe_adap[0].fe, i2c, &nim9090md_dib0090_config[0]) == NULL)
2217
		return -ENODEV;
2218
	i2c = dib9000_get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_GPIO_1_2, 0);
2219 2220
	if (dib01x0_pmu_update(i2c, data_dib190, 10) < 0)
		return -ENODEV;
2221 2222

	dib0700_set_i2c_speed(adap->dev, 1500);
2223
	if (dib9000_firmware_post_pll_init(adap->fe_adap[0].fe) < 0)
2224 2225
		return -ENODEV;

2226
	fe_slave = dib9000_get_slave_frontend(adap->fe_adap[0].fe, 1);
2227
	if (fe_slave != NULL) {
2228
		i2c = dib9000_get_component_bus_interface(adap->fe_adap[0].fe);
2229 2230 2231 2232 2233
		dib9000_set_i2c_adapter(fe_slave, i2c);

		i2c = dib9000_get_tuner_interface(fe_slave);
		if (dvb_attach(dib0090_fw_register, fe_slave, i2c, &nim9090md_dib0090_config[1]) == NULL)
			return -ENODEV;
2234
		fe_slave->dvb = adap->fe_adap[0].fe->dvb;
2235
		dib9000_fw_set_component_bus_speed(adap->fe_adap[0].fe, 1500);
2236 2237 2238
		if (dib9000_firmware_post_pll_init(fe_slave) < 0)
			return -ENODEV;
	}
2239
	release_firmware(state->frontend_firmware);
2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269

	return 0;
}

/* NIM7090 */
struct dib7090p_best_adc {
	u32 timf;
	u32 pll_loopdiv;
	u32 pll_prediv;
};

static int dib7090p_get_best_sampling(struct dvb_frontend *fe , struct dib7090p_best_adc *adc)
{
	u8 spur = 0, prediv = 0, loopdiv = 0, min_prediv = 1, max_prediv = 1;

	u16 xtal = 12000;
	u32 fcp_min = 1900;  /* PLL Minimum Frequency comparator KHz */
	u32 fcp_max = 20000; /* PLL Maximum Frequency comparator KHz */
	u32 fdem_max = 76000;
	u32 fdem_min = 69500;
	u32 fcp = 0, fs = 0, fdem = 0;
	u32 harmonic_id = 0;

	adc->pll_loopdiv = loopdiv;
	adc->pll_prediv = prediv;
	adc->timf = 0;

	deb_info("bandwidth = %d fdem_min =%d", fe->dtv_property_cache.bandwidth_hz, fdem_min);

	/* Find Min and Max prediv */
2270
	while ((xtal/max_prediv) >= fcp_min)
2271 2272 2273 2274
		max_prediv++;

	max_prediv--;
	min_prediv = max_prediv;
2275
	while ((xtal/min_prediv) <= fcp_max) {
2276
		min_prediv--;
2277
		if (min_prediv == 1)
2278 2279 2280 2281 2282 2283
			break;
	}
	deb_info("MIN prediv = %d : MAX prediv = %d", min_prediv, max_prediv);

	min_prediv = 2;

2284
	for (prediv = min_prediv ; prediv < max_prediv; prediv++) {
2285
		fcp = xtal / prediv;
2286 2287
		if (fcp > fcp_min && fcp < fcp_max) {
			for (loopdiv = 1 ; loopdiv < 64 ; loopdiv++) {
2288 2289 2290 2291
				fdem = ((xtal/prediv) * loopdiv);
				fs   = fdem / 4;
				/* test min/max system restrictions */

2292
				if ((fdem >= fdem_min) && (fdem <= fdem_max) && (fs >= fe->dtv_property_cache.bandwidth_hz/1000)) {
2293 2294
					spur = 0;
					/* test fs harmonics positions */
2295 2296
					for (harmonic_id = (fe->dtv_property_cache.frequency / (1000*fs)) ;  harmonic_id <= ((fe->dtv_property_cache.frequency / (1000*fs))+1) ; harmonic_id++) {
						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)))) {
2297 2298 2299 2300 2301
							spur = 1;
							break;
						}
					}

2302
					if (!spur) {
2303 2304
						adc->pll_loopdiv = loopdiv;
						adc->pll_prediv = prediv;
2305 2306
						adc->timf = 2396745143UL/fdem*(1 << 9);
						adc->timf += ((2396745143UL%fdem) << 9)/fdem;
2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317
						deb_info("loopdiv=%i prediv=%i timf=%i", loopdiv, prediv, adc->timf);
						break;
					}
				}
			}
		}
		if (!spur)
			break;
	}


2318
	if (adc->pll_loopdiv == 0 && adc->pll_prediv == 0)
2319
		return -EINVAL;
2320
	else
2321 2322 2323
		return 0;
}

2324
static int dib7090_agc_startup(struct dvb_frontend *fe)
2325 2326 2327 2328 2329 2330 2331 2332
{
	struct dvb_usb_adapter *adap = fe->dvb->priv;
	struct dib0700_adapter_state *state = adap->priv;
	struct dibx000_bandwidth_config pll;
	u16 target;
	struct dib7090p_best_adc adc;
	int ret;

2333
	ret = state->set_param_save(fe);
2334 2335 2336 2337 2338
	if (ret < 0)
		return ret;

	memset(&pll, 0, sizeof(struct dibx000_bandwidth_config));
	dib0090_pwm_gain_reset(fe);
2339
	target = (dib0090_get_wbd_target(fe) * 8 + 1) / 2;
2340 2341
	dib7000p_set_wbd_ref(fe, target);

2342
	if (dib7090p_get_best_sampling(fe, &adc) == 0) {
2343 2344 2345 2346 2347 2348 2349 2350 2351
		pll.pll_ratio  = adc.pll_loopdiv;
		pll.pll_prediv = adc.pll_prediv;

		dib7000p_update_pll(fe, &pll);
		dib7000p_ctrl_timf(fe, DEMOD_TIMF_SET, adc.timf);
	}
	return 0;
}

2352 2353 2354 2355 2356 2357 2358 2359
static int dib7090_agc_restart(struct dvb_frontend *fe, u8 restart)
{
	deb_info("AGC restart callback: %d", restart);
	if (restart == 0) /* before AGC startup */
		dib0090_set_dc_servo(fe, 1);
	return 0;
}

2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394
static int dib7090e_update_lna(struct dvb_frontend *fe, u16 agc_global)
{
	u16 agc1 = 0, agc2, wbd = 0, wbd_target, wbd_offset, threshold_agc1;
	s16 wbd_delta;

	if ((fe->dtv_property_cache.frequency) < 400000000)
		threshold_agc1 = 25000;
	else
		threshold_agc1 = 30000;

	wbd_target = (dib0090_get_wbd_target(fe)*8+1)/2;
	wbd_offset = dib0090_get_wbd_offset(fe);
	dib7000p_get_agc_values(fe, NULL, &agc1, &agc2, &wbd);
	wbd_delta = (s16)wbd - (((s16)wbd_offset+10)*4) ;

	deb_info("update lna, agc_global=%d agc1=%d agc2=%d",
			agc_global, agc1, agc2);
	deb_info("update lna, wbd=%d wbd target=%d wbd offset=%d wbd delta=%d",
			wbd, wbd_target, wbd_offset, wbd_delta);

	if ((agc1 < threshold_agc1) && (wbd_delta > 0)) {
		dib0090_set_switch(fe, 1, 1, 1);
		dib0090_set_vga(fe, 0);
		dib0090_update_rframp_7090(fe, 0);
		dib0090_update_tuning_table_7090(fe, 0);
	} else {
		dib0090_set_vga(fe, 1);
		dib0090_update_rframp_7090(fe, 1);
		dib0090_update_tuning_table_7090(fe, 1);
		dib0090_set_switch(fe, 0, 0, 0);
	}

	return 0;
}

2395
static struct dib0090_wbd_slope dib7090_wbd_table[] = {
2396 2397 2398 2399 2400
	{ 380,   81, 850, 64, 540,  4},
	{ 860,   51, 866, 21,  375, 4},
	{1700,    0, 250, 0,   100, 6},
	{2600,    0, 250, 0,   100, 6},
	{ 0xFFFF, 0,   0, 0,   0,   0},
2401 2402
};

2403 2404 2405 2406 2407 2408 2409 2410 2411
static struct dib0090_wbd_slope dib7090e_wbd_table[] = {
	{ 380,   81, 850, 64, 540,	4},
	{ 700,   51, 866, 21,  320,	4},
	{ 860,   48, 666, 18,  330,	6},
	{1700,    0, 250, 0,   100, 6},
	{2600,    0, 250, 0,   100, 6},
	{ 0xFFFF, 0,   0, 0,   0,	0},
};

O
Olivier Grenie 已提交
2412
static struct dibx000_agc_config dib7090_agc_config[2] = {
2413 2414 2415 2416
	{
		.band_caps      = BAND_UHF,
		/* 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,
		* 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 */
2417
		.setup          = (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),
2418

2419 2420
		.inv_gain       = 687,
		.time_stabiliz  = 10,
2421

2422 2423
		.alpha_level    = 0,
		.thlock         = 118,
2424

2425 2426 2427 2428
		.wbd_inv        = 0,
		.wbd_ref        = 1200,
		.wbd_sel        = 3,
		.wbd_alpha      = 5,
2429

2430 2431
		.agc1_max       = 65535,
		.agc1_min       = 0,
2432

2433 2434
		.agc2_max       = 65535,
		.agc2_min       = 0,
2435

2436 2437 2438 2439 2440 2441 2442 2443 2444
		.agc1_pt1       = 0,
		.agc1_pt2       = 32,
		.agc1_pt3       = 114,
		.agc1_slope1    = 143,
		.agc1_slope2    = 144,
		.agc2_pt1       = 114,
		.agc2_pt2       = 227,
		.agc2_slope1    = 116,
		.agc2_slope2    = 117,
2445

2446 2447 2448 2449
		.alpha_mant     = 18,
		.alpha_exp      = 0,
		.beta_mant      = 20,
		.beta_exp       = 59,
2450

2451
		.perform_agc_softsplit = 0,
2452 2453 2454 2455
	} , {
		.band_caps      = BAND_FM | BAND_VHF | BAND_CBAND,
		/* 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,
		* 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 */
2456
		.setup          = (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),
2457

2458 2459
		.inv_gain       = 732,
		.time_stabiliz  = 10,
2460

2461 2462
		.alpha_level    = 0,
		.thlock         = 118,
2463

2464 2465 2466 2467
		.wbd_inv        = 0,
		.wbd_ref        = 1200,
		.wbd_sel        = 3,
		.wbd_alpha      = 5,
2468

2469 2470
		.agc1_max       = 65535,
		.agc1_min       = 0,
2471

2472 2473
		.agc2_max       = 65535,
		.agc2_min       = 0,
2474

2475 2476 2477 2478 2479
		.agc1_pt1       = 0,
		.agc1_pt2       = 0,
		.agc1_pt3       = 98,
		.agc1_slope1    = 0,
		.agc1_slope2    = 167,
2480
		.agc2_pt1       = 98,
2481 2482 2483
		.agc2_pt2       = 255,
		.agc2_slope1    = 104,
		.agc2_slope2    = 0,
2484

2485 2486 2487 2488
		.alpha_mant     = 18,
		.alpha_exp      = 0,
		.beta_mant      = 20,
		.beta_exp       = 59,
2489

2490
		.perform_agc_softsplit = 0,
2491 2492 2493 2494
	}
};

static struct dibx000_bandwidth_config dib7090_clock_config_12_mhz = {
2495 2496 2497 2498 2499 2500 2501
	60000, 15000,
	1, 5, 0, 0, 0,
	0, 0, 1, 1, 2,
	(3 << 14) | (1 << 12) | (524 << 0),
	(0 << 25) | 0,
	20452225,
	15000000,
2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559
};

static struct dib7000p_config nim7090_dib7000p_config = {
	.output_mpeg2_in_188_bytes  = 1,
	.hostbus_diversity			= 1,
	.tuner_is_baseband			= 1,
	.update_lna					= NULL,

	.agc_config_count			= 2,
	.agc						= dib7090_agc_config,

	.bw							= &dib7090_clock_config_12_mhz,

	.gpio_dir					= DIB7000P_GPIO_DEFAULT_DIRECTIONS,
	.gpio_val					= DIB7000P_GPIO_DEFAULT_VALUES,
	.gpio_pwm_pos				= DIB7000P_GPIO_DEFAULT_PWM_POS,

	.pwm_freq_div				= 0,

	.agc_control				= dib7090_agc_restart,

	.spur_protect				= 0,
	.disable_sample_and_hold	= 0,
	.enable_current_mirror		= 0,
	.diversity_delay			= 0,

	.output_mode				= OUTMODE_MPEG2_FIFO,
	.enMpegOutput				= 1,
};

static struct dib7000p_config tfe7090pvr_dib7000p_config[2] = {
	{
		.output_mpeg2_in_188_bytes  = 1,
		.hostbus_diversity			= 1,
		.tuner_is_baseband			= 1,
		.update_lna					= NULL,

		.agc_config_count			= 2,
		.agc						= dib7090_agc_config,

		.bw							= &dib7090_clock_config_12_mhz,

		.gpio_dir					= DIB7000P_GPIO_DEFAULT_DIRECTIONS,
		.gpio_val					= DIB7000P_GPIO_DEFAULT_VALUES,
		.gpio_pwm_pos				= DIB7000P_GPIO_DEFAULT_PWM_POS,

		.pwm_freq_div				= 0,

		.agc_control				= dib7090_agc_restart,

		.spur_protect				= 0,
		.disable_sample_and_hold	= 0,
		.enable_current_mirror		= 0,
		.diversity_delay			= 0,

		.output_mode				= OUTMODE_MPEG2_PAR_GATED_CLK,
		.default_i2c_addr			= 0x90,
		.enMpegOutput				= 1,
2560
	}, {
2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589
		.output_mpeg2_in_188_bytes  = 1,
		.hostbus_diversity			= 1,
		.tuner_is_baseband			= 1,
		.update_lna					= NULL,

		.agc_config_count			= 2,
		.agc						= dib7090_agc_config,

		.bw							= &dib7090_clock_config_12_mhz,

		.gpio_dir					= DIB7000P_GPIO_DEFAULT_DIRECTIONS,
		.gpio_val					= DIB7000P_GPIO_DEFAULT_VALUES,
		.gpio_pwm_pos				= DIB7000P_GPIO_DEFAULT_PWM_POS,

		.pwm_freq_div				= 0,

		.agc_control				= dib7090_agc_restart,

		.spur_protect				= 0,
		.disable_sample_and_hold	= 0,
		.enable_current_mirror		= 0,
		.diversity_delay			= 0,

		.output_mode				= OUTMODE_MPEG2_PAR_GATED_CLK,
		.default_i2c_addr			= 0x92,
		.enMpegOutput				= 0,
	}
};

2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617
static struct dib7000p_config tfe7090e_dib7000p_config = {
	.output_mpeg2_in_188_bytes  = 1,
	.hostbus_diversity			= 1,
	.tuner_is_baseband			= 1,
	.update_lna					= dib7090e_update_lna,

	.agc_config_count			= 2,
	.agc						= dib7090_agc_config,

	.bw							= &dib7090_clock_config_12_mhz,

	.gpio_dir					= DIB7000P_GPIO_DEFAULT_DIRECTIONS,
	.gpio_val					= DIB7000P_GPIO_DEFAULT_VALUES,
	.gpio_pwm_pos				= DIB7000P_GPIO_DEFAULT_PWM_POS,

	.pwm_freq_div				= 0,

	.agc_control				= dib7090_agc_restart,

	.spur_protect				= 0,
	.disable_sample_and_hold	= 0,
	.enable_current_mirror		= 0,
	.diversity_delay			= 0,

	.output_mode				= OUTMODE_MPEG2_FIFO,
	.enMpegOutput				= 1,
};

2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651
static const struct dib0090_config nim7090_dib0090_config = {
	.io.clock_khz = 12000,
	.io.pll_bypass = 0,
	.io.pll_range = 0,
	.io.pll_prediv = 3,
	.io.pll_loopdiv = 6,
	.io.adc_clock_ratio = 0,
	.io.pll_int_loop_filt = 0,
	.reset = dib7090_tuner_sleep,
	.sleep = dib7090_tuner_sleep,

	.freq_offset_khz_uhf = 0,
	.freq_offset_khz_vhf = 0,

	.get_adc_power = dib7090_get_adc_power,

	.clkouttobamse = 1,
	.analog_output = 0,

	.wbd_vhf_offset = 0,
	.wbd_cband_offset = 0,
	.use_pwm_agc = 1,
	.clkoutdrive = 0,

	.fref_clock_ratio = 0,

	.wbd = dib7090_wbd_table,

	.ls_cfg_pad_drv = 0,
	.data_tx_drv = 0,
	.low_if = NULL,
	.in_soc = 1,
};

2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687
static const struct dib0090_config tfe7090e_dib0090_config = {
	.io.clock_khz = 12000,
	.io.pll_bypass = 0,
	.io.pll_range = 0,
	.io.pll_prediv = 3,
	.io.pll_loopdiv = 6,
	.io.adc_clock_ratio = 0,
	.io.pll_int_loop_filt = 0,
	.reset = dib7090_tuner_sleep,
	.sleep = dib7090_tuner_sleep,

	.freq_offset_khz_uhf = 0,
	.freq_offset_khz_vhf = 0,

	.get_adc_power = dib7090_get_adc_power,

	.clkouttobamse = 1,
	.analog_output = 0,

	.wbd_vhf_offset = 0,
	.wbd_cband_offset = 0,
	.use_pwm_agc = 1,
	.clkoutdrive = 0,

	.fref_clock_ratio = 0,

	.wbd = dib7090e_wbd_table,

	.ls_cfg_pad_drv = 0,
	.data_tx_drv = 0,
	.low_if = NULL,
	.in_soc = 1,
	.force_cband_input = 1,
	.is_dib7090e = 1,
};

2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752
static struct dib7000p_config tfe7790e_dib7000p_config = {
	.output_mpeg2_in_188_bytes  = 1,
	.hostbus_diversity			= 1,
	.tuner_is_baseband			= 1,
	.update_lna					= dib7090e_update_lna,

	.agc_config_count			= 2,
	.agc						= dib7090_agc_config,

	.bw							= &dib7090_clock_config_12_mhz,

	.gpio_dir					= DIB7000P_GPIO_DEFAULT_DIRECTIONS,
	.gpio_val					= DIB7000P_GPIO_DEFAULT_VALUES,
	.gpio_pwm_pos				= DIB7000P_GPIO_DEFAULT_PWM_POS,

	.pwm_freq_div				= 0,

	.agc_control				= dib7090_agc_restart,

	.spur_protect				= 0,
	.disable_sample_and_hold	= 0,
	.enable_current_mirror		= 0,
	.diversity_delay			= 0,

	.output_mode				= OUTMODE_MPEG2_PAR_GATED_CLK,
	.enMpegOutput				= 1,
};

static const struct dib0090_config tfe7790e_dib0090_config = {
	.io.clock_khz = 12000,
	.io.pll_bypass = 0,
	.io.pll_range = 0,
	.io.pll_prediv = 3,
	.io.pll_loopdiv = 6,
	.io.adc_clock_ratio = 0,
	.io.pll_int_loop_filt = 0,
	.reset = dib7090_tuner_sleep,
	.sleep = dib7090_tuner_sleep,

	.freq_offset_khz_uhf = 0,
	.freq_offset_khz_vhf = 0,

	.get_adc_power = dib7090_get_adc_power,

	.clkouttobamse = 1,
	.analog_output = 0,

	.wbd_vhf_offset = 0,
	.wbd_cband_offset = 0,
	.use_pwm_agc = 1,
	.clkoutdrive = 0,

	.fref_clock_ratio = 0,

	.wbd = dib7090e_wbd_table,

	.ls_cfg_pad_drv = 0,
	.data_tx_drv = 0,
	.low_if = NULL,
	.in_soc = 1,
	.force_cband_input = 1,
	.is_dib7090e = 1,
	.force_crystal_mode = 1,
};

2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785
static const struct dib0090_config tfe7090pvr_dib0090_config[2] = {
	{
		.io.clock_khz = 12000,
		.io.pll_bypass = 0,
		.io.pll_range = 0,
		.io.pll_prediv = 3,
		.io.pll_loopdiv = 6,
		.io.adc_clock_ratio = 0,
		.io.pll_int_loop_filt = 0,
		.reset = dib7090_tuner_sleep,
		.sleep = dib7090_tuner_sleep,

		.freq_offset_khz_uhf = 50,
		.freq_offset_khz_vhf = 70,

		.get_adc_power = dib7090_get_adc_power,

		.clkouttobamse = 1,
		.analog_output = 0,

		.wbd_vhf_offset = 0,
		.wbd_cband_offset = 0,
		.use_pwm_agc = 1,
		.clkoutdrive = 0,

		.fref_clock_ratio = 0,

		.wbd = dib7090_wbd_table,

		.ls_cfg_pad_drv = 0,
		.data_tx_drv = 0,
		.low_if = NULL,
		.in_soc = 1,
2786
	}, {
2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823
		.io.clock_khz = 12000,
		.io.pll_bypass = 0,
		.io.pll_range = 0,
		.io.pll_prediv = 3,
		.io.pll_loopdiv = 6,
		.io.adc_clock_ratio = 0,
		.io.pll_int_loop_filt = 0,
		.reset = dib7090_tuner_sleep,
		.sleep = dib7090_tuner_sleep,

		.freq_offset_khz_uhf = -50,
		.freq_offset_khz_vhf = -70,

		.get_adc_power = dib7090_get_adc_power,

		.clkouttobamse = 1,
		.analog_output = 0,

		.wbd_vhf_offset = 0,
		.wbd_cband_offset = 0,
		.use_pwm_agc = 1,
		.clkoutdrive = 0,

		.fref_clock_ratio = 0,

		.wbd = dib7090_wbd_table,

		.ls_cfg_pad_drv = 0,
		.data_tx_drv = 0,
		.low_if = NULL,
		.in_soc = 1,
	}
};

static int nim7090_frontend_attach(struct dvb_usb_adapter *adap)
{
	dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
2824
	msleep(20);
2825 2826 2827 2828 2829
	dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
	dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
	dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
	dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);

2830
	msleep(20);
2831
	dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
2832
	msleep(20);
2833
	dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
2834

2835 2836 2837 2838
	if (dib7000p_i2c_enumeration(&adap->dev->i2c_adap, 1, 0x10, &nim7090_dib7000p_config) != 0) {
		err("%s: dib7000p_i2c_enumeration failed.  Cannot continue\n", __func__);
		return -ENODEV;
	}
2839
	adap->fe_adap[0].fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 0x80, &nim7090_dib7000p_config);
2840

2841
	return adap->fe_adap[0].fe == NULL ?  -ENODEV : 0;
2842 2843
}

2844
static int nim7090_tuner_attach(struct dvb_usb_adapter *adap)
2845
{
2846
	struct dib0700_adapter_state *st = adap->priv;
2847
	struct i2c_adapter *tun_i2c = dib7090_get_i2c_tuner(adap->fe_adap[0].fe);
2848

2849
	if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c, &nim7090_dib0090_config) == NULL)
2850
		return -ENODEV;
2851

2852
	dib7000p_set_gpio(adap->fe_adap[0].fe, 8, 0, 1);
2853

2854 2855
	st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
	adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib7090_agc_startup;
2856
	return 0;
2857 2858
}

2859
static int tfe7090pvr_frontend0_attach(struct dvb_usb_adapter *adap)
2860
{
2861 2862 2863 2864 2865
	struct dib0700_state *st = adap->dev->priv;

	/* The TFE7090 requires the dib0700 to not be in master mode */
	st->disable_streaming_master_mode = 1;

2866
	dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
2867
	msleep(20);
2868 2869 2870 2871 2872
	dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
	dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
	dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
	dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);

2873
	msleep(20);
2874
	dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
2875
	msleep(20);
2876 2877
	dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);

2878 2879 2880 2881 2882
	/* initialize IC 0 */
	if (dib7000p_i2c_enumeration(&adap->dev->i2c_adap, 1, 0x20, &tfe7090pvr_dib7000p_config[0]) != 0) {
		err("%s: dib7000p_i2c_enumeration failed.  Cannot continue\n", __func__);
		return -ENODEV;
	}
2883

2884
	dib0700_set_i2c_speed(adap->dev, 340);
2885 2886
	adap->fe_adap[0].fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 0x90, &tfe7090pvr_dib7000p_config[0]);
	if (adap->fe_adap[0].fe == NULL)
2887 2888
		return -ENODEV;

2889
	dib7090_slave_reset(adap->fe_adap[0].fe);
2890

2891 2892 2893 2894 2895 2896 2897
	return 0;
}

static int tfe7090pvr_frontend1_attach(struct dvb_usb_adapter *adap)
{
	struct i2c_adapter *i2c;

2898
	if (adap->dev->adapter[0].fe_adap[0].fe == NULL) {
2899 2900 2901 2902
		err("the master dib7090 has to be initialized first");
		return -ENODEV; /* the master device has not been initialized */
	}

2903
	i2c = dib7000p_get_i2c_master(adap->dev->adapter[0].fe_adap[0].fe, DIBX000_I2C_INTERFACE_GPIO_6_7, 1);
2904 2905 2906 2907 2908
	if (dib7000p_i2c_enumeration(i2c, 1, 0x10, &tfe7090pvr_dib7000p_config[1]) != 0) {
		err("%s: dib7000p_i2c_enumeration failed.  Cannot continue\n", __func__);
		return -ENODEV;
	}

2909
	adap->fe_adap[0].fe = dvb_attach(dib7000p_attach, i2c, 0x92, &tfe7090pvr_dib7000p_config[1]);
2910 2911
	dib0700_set_i2c_speed(adap->dev, 200);

2912
	return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
2913 2914 2915 2916 2917
}

static int tfe7090pvr_tuner0_attach(struct dvb_usb_adapter *adap)
{
	struct dib0700_adapter_state *st = adap->priv;
2918
	struct i2c_adapter *tun_i2c = dib7090_get_i2c_tuner(adap->fe_adap[0].fe);
2919

2920
	if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c, &tfe7090pvr_dib0090_config[0]) == NULL)
2921 2922
		return -ENODEV;

2923
	dib7000p_set_gpio(adap->fe_adap[0].fe, 8, 0, 1);
2924

2925 2926
	st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
	adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib7090_agc_startup;
2927 2928 2929 2930 2931 2932
	return 0;
}

static int tfe7090pvr_tuner1_attach(struct dvb_usb_adapter *adap)
{
	struct dib0700_adapter_state *st = adap->priv;
2933
	struct i2c_adapter *tun_i2c = dib7090_get_i2c_tuner(adap->fe_adap[0].fe);
2934

2935
	if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c, &tfe7090pvr_dib0090_config[1]) == NULL)
2936 2937
		return -ENODEV;

2938
	dib7000p_set_gpio(adap->fe_adap[0].fe, 8, 0, 1);
2939

2940 2941
	st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
	adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib7090_agc_startup;
2942
	return 0;
2943
}
2944

2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970
static int tfe7090e_frontend_attach(struct dvb_usb_adapter *adap)
{
	dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
	msleep(20);
	dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
	dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
	dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
	dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);

	msleep(20);
	dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
	msleep(20);
	dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);

	if (dib7000p_i2c_enumeration(&adap->dev->i2c_adap,
				1, 0x10, &tfe7090e_dib7000p_config) != 0) {
		err("%s: dib7000p_i2c_enumeration failed.  Cannot continue\n",
				__func__);
		return -ENODEV;
	}
	adap->fe_adap[0].fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap,
			0x80, &tfe7090e_dib7000p_config);

	return adap->fe_adap[0].fe == NULL ?  -ENODEV : 0;
}

2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018
static int tfe7790e_frontend_attach(struct dvb_usb_adapter *adap)
{
	struct dib0700_state *st = adap->dev->priv;

	/* The TFE7790E requires the dib0700 to not be in master mode */
	st->disable_streaming_master_mode = 1;

	dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
	msleep(20);
	dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
	dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
	dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
	dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
	msleep(20);
	dib0700_ctrl_clock(adap->dev, 72, 1);
	dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
	msleep(20);
	dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);

	if (dib7000p_i2c_enumeration(&adap->dev->i2c_adap,
				1, 0x10, &tfe7790e_dib7000p_config) != 0) {
		err("%s: dib7000p_i2c_enumeration failed.  Cannot continue\n",
				__func__);
		return -ENODEV;
	}
	adap->fe_adap[0].fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap,
			0x80, &tfe7790e_dib7000p_config);

	return adap->fe_adap[0].fe == NULL ?  -ENODEV : 0;
}

static int tfe7790e_tuner_attach(struct dvb_usb_adapter *adap)
{
	struct dib0700_adapter_state *st = adap->priv;
	struct i2c_adapter *tun_i2c =
		dib7090_get_i2c_tuner(adap->fe_adap[0].fe);

	if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c,
				&tfe7790e_dib0090_config) == NULL)
		return -ENODEV;

	dib7000p_set_gpio(adap->fe_adap[0].fe, 8, 0, 1);

	st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
	adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib7090_agc_startup;
	return 0;
}

3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035
static int tfe7090e_tuner_attach(struct dvb_usb_adapter *adap)
{
	struct dib0700_adapter_state *st = adap->priv;
	struct i2c_adapter *tun_i2c =
		dib7090_get_i2c_tuner(adap->fe_adap[0].fe);

	if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c,
				&tfe7090e_dib0090_config) == NULL)
		return -ENODEV;

	dib7000p_set_gpio(adap->fe_adap[0].fe, 8, 0, 1);

	st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
	adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib7090_agc_startup;
	return 0;
}

3036 3037 3038 3039 3040 3041 3042 3043
/* STK7070PD */
static struct dib7000p_config stk7070pd_dib7000p_config[2] = {
	{
		.output_mpeg2_in_188_bytes = 1,

		.agc_config_count = 1,
		.agc = &dib7070_agc_config,
		.bw  = &dib7070_bw_config_12_mhz,
3044 3045
		.tuner_is_baseband = 1,
		.spur_protect = 1,
3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057

		.gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
		.gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
		.gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,

		.hostbus_diversity = 1,
	}, {
		.output_mpeg2_in_188_bytes = 1,

		.agc_config_count = 1,
		.agc = &dib7070_agc_config,
		.bw  = &dib7070_bw_config_12_mhz,
3058 3059
		.tuner_is_baseband = 1,
		.spur_protect = 1,
3060 3061 3062 3063 3064 3065 3066 3067 3068

		.gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
		.gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
		.gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,

		.hostbus_diversity = 1,
	}
};

3069
static void stk7070pd_init(struct dvb_usb_device *dev)
3070
{
3071
	dib0700_set_gpio(dev, GPIO6, GPIO_OUT, 1);
3072
	msleep(10);
3073 3074 3075 3076
	dib0700_set_gpio(dev, GPIO9, GPIO_OUT, 1);
	dib0700_set_gpio(dev, GPIO4, GPIO_OUT, 1);
	dib0700_set_gpio(dev, GPIO7, GPIO_OUT, 1);
	dib0700_set_gpio(dev, GPIO10, GPIO_OUT, 0);
3077

3078
	dib0700_ctrl_clock(dev, 72, 1);
3079 3080

	msleep(10);
3081 3082 3083 3084 3085 3086 3087
	dib0700_set_gpio(dev, GPIO10, GPIO_OUT, 1);
}

static int stk7070pd_frontend_attach0(struct dvb_usb_adapter *adap)
{
	stk7070pd_init(adap->dev);

3088 3089 3090
	msleep(10);
	dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);

3091 3092 3093 3094 3095 3096
	if (dib7000p_i2c_enumeration(&adap->dev->i2c_adap, 2, 18,
				     stk7070pd_dib7000p_config) != 0) {
		err("%s: dib7000p_i2c_enumeration failed.  Cannot continue\n",
		    __func__);
		return -ENODEV;
	}
3097

3098 3099
	adap->fe_adap[0].fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 0x80, &stk7070pd_dib7000p_config[0]);
	return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
3100 3101 3102 3103
}

static int stk7070pd_frontend_attach1(struct dvb_usb_adapter *adap)
{
3104 3105
	adap->fe_adap[0].fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 0x82, &stk7070pd_dib7000p_config[1]);
	return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
3106 3107
}

3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136
static int novatd_read_status_override(struct dvb_frontend *fe,
		fe_status_t *stat)
{
	struct dvb_usb_adapter *adap = fe->dvb->priv;
	struct dvb_usb_device *dev = adap->dev;
	struct dib0700_state *state = dev->priv;
	int ret;

	ret = state->read_status(fe, stat);

	if (!ret)
		dib0700_set_gpio(dev, adap->id == 0 ? GPIO1 : GPIO0, GPIO_OUT,
				!!(*stat & FE_HAS_LOCK));

	return ret;
}

static int novatd_sleep_override(struct dvb_frontend* fe)
{
	struct dvb_usb_adapter *adap = fe->dvb->priv;
	struct dvb_usb_device *dev = adap->dev;
	struct dib0700_state *state = dev->priv;

	/* turn off LED */
	dib0700_set_gpio(dev, adap->id == 0 ? GPIO1 : GPIO0, GPIO_OUT, 0);

	return state->sleep(fe);
}

3137 3138 3139 3140 3141 3142 3143 3144 3145
/**
 * novatd_frontend_attach - Nova-TD specific attach
 *
 * Nova-TD has GPIO0, 1 and 2 for LEDs. So do not fiddle with them except for
 * information purposes.
 */
static int novatd_frontend_attach(struct dvb_usb_adapter *adap)
{
	struct dvb_usb_device *dev = adap->dev;
3146
	struct dib0700_state *st = dev->priv;
3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166

	if (adap->id == 0) {
		stk7070pd_init(dev);

		/* turn the power LED on, the other two off (just in case) */
		dib0700_set_gpio(dev, GPIO0, GPIO_OUT, 0);
		dib0700_set_gpio(dev, GPIO1, GPIO_OUT, 0);
		dib0700_set_gpio(dev, GPIO2, GPIO_OUT, 1);

		if (dib7000p_i2c_enumeration(&dev->i2c_adap, 2, 18,
					     stk7070pd_dib7000p_config) != 0) {
			err("%s: dib7000p_i2c_enumeration failed.  Cannot continue\n",
			    __func__);
			return -ENODEV;
		}
	}

	adap->fe_adap[0].fe = dvb_attach(dib7000p_attach, &dev->i2c_adap,
			adap->id == 0 ? 0x80 : 0x82,
			&stk7070pd_dib7000p_config[adap->id]);
3167 3168 3169 3170 3171 3172 3173 3174 3175 3176

	if (adap->fe_adap[0].fe == NULL)
		return -ENODEV;

	st->read_status = adap->fe_adap[0].fe->ops.read_status;
	adap->fe_adap[0].fe->ops.read_status = novatd_read_status_override;
	st->sleep = adap->fe_adap[0].fe->ops.sleep;
	adap->fe_adap[0].fe->ops.sleep = novatd_sleep_override;

	return 0;
3177 3178
}

3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230
/* S5H1411 */
static struct s5h1411_config pinnacle_801e_config = {
	.output_mode   = S5H1411_PARALLEL_OUTPUT,
	.gpio          = S5H1411_GPIO_OFF,
	.mpeg_timing   = S5H1411_MPEGTIMING_NONCONTINOUS_NONINVERTING_CLOCK,
	.qam_if        = S5H1411_IF_44000,
	.vsb_if        = S5H1411_IF_44000,
	.inversion     = S5H1411_INVERSION_OFF,
	.status_mode   = S5H1411_DEMODLOCKING
};

/* Pinnacle PCTV HD Pro 801e GPIOs map:
   GPIO0  - currently unknown
   GPIO1  - xc5000 tuner reset
   GPIO2  - CX25843 sleep
   GPIO3  - currently unknown
   GPIO4  - currently unknown
   GPIO6  - currently unknown
   GPIO7  - currently unknown
   GPIO9  - currently unknown
   GPIO10 - CX25843 reset
 */
static int s5h1411_frontend_attach(struct dvb_usb_adapter *adap)
{
	struct dib0700_state *st = adap->dev->priv;

	/* Make use of the new i2c functions from FW 1.20 */
	st->fw_use_new_i2c_api = 1;

	/* The s5h1411 requires the dib0700 to not be in master mode */
	st->disable_streaming_master_mode = 1;

	/* All msleep values taken from Windows USB trace */
	dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 0);
	dib0700_set_gpio(adap->dev, GPIO3, GPIO_OUT, 0);
	dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
	msleep(400);
	dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
	msleep(60);
	dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
	msleep(30);
	dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
	dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
	dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
	dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
	dib0700_set_gpio(adap->dev, GPIO2, GPIO_OUT, 0);
	msleep(30);

	/* Put the CX25843 to sleep for now since we're in digital mode */
	dib0700_set_gpio(adap->dev, GPIO2, GPIO_OUT, 1);

	/* GPIOs are initialized, do the attach */
3231
	adap->fe_adap[0].fe = dvb_attach(s5h1411_attach, &pinnacle_801e_config,
3232
			      &adap->dev->i2c_adap);
3233
	return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
3234 3235
}

3236 3237
static int dib0700_xc5000_tuner_callback(void *priv, int component,
					 int command, int arg)
3238 3239 3240
{
	struct dvb_usb_adapter *adap = priv;

3241 3242 3243
	if (command == XC5000_TUNER_RESET) {
		/* Reset the tuner */
		dib0700_set_gpio(adap->dev, GPIO1, GPIO_OUT, 0);
3244
		msleep(10);
3245
		dib0700_set_gpio(adap->dev, GPIO1, GPIO_OUT, 1);
3246
		msleep(10);
3247 3248 3249 3250
	} else {
		err("xc5000: unknown tuner callback command: %d\n", command);
		return -EINVAL;
	}
3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261

	return 0;
}

static struct xc5000_config s5h1411_xc5000_tunerconfig = {
	.i2c_address      = 0x64,
	.if_khz           = 5380,
};

static int xc5000_tuner_attach(struct dvb_usb_adapter *adap)
{
3262
	/* FIXME: generalize & move to common area */
3263
	adap->fe_adap[0].fe->callback = dib0700_xc5000_tuner_callback;
3264

3265
	return dvb_attach(xc5000_attach, adap->fe_adap[0].fe, &adap->dev->i2c_adap,
3266
			  &s5h1411_xc5000_tunerconfig)
3267 3268 3269
		== NULL ? -ENODEV : 0;
}

3270 3271 3272 3273 3274 3275 3276
static int dib0700_xc4000_tuner_callback(void *priv, int component,
					 int command, int arg)
{
	struct dvb_usb_adapter *adap = priv;

	if (command == XC4000_TUNER_RESET) {
		/* Reset the tuner */
3277
		dib7000p_set_gpio(adap->fe_adap[0].fe, 8, 0, 0);
3278
		msleep(10);
3279
		dib7000p_set_gpio(adap->fe_adap[0].fe, 8, 0, 1);
3280 3281 3282 3283 3284 3285 3286 3287
	} else {
		err("xc4000: unknown tuner callback command: %d\n", command);
		return -EINVAL;
	}

	return 0;
}

3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311
static struct dibx000_agc_config stk7700p_7000p_xc4000_agc_config = {
	.band_caps = BAND_UHF | BAND_VHF,
	.setup = 0x64,
	.inv_gain = 0x02c8,
	.time_stabiliz = 0x15,
	.alpha_level = 0x00,
	.thlock = 0x76,
	.wbd_inv = 0x01,
	.wbd_ref = 0x0b33,
	.wbd_sel = 0x00,
	.wbd_alpha = 0x02,
	.agc1_max = 0x00,
	.agc1_min = 0x00,
	.agc2_max = 0x9b26,
	.agc2_min = 0x26ca,
	.agc1_pt1 = 0x00,
	.agc1_pt2 = 0x00,
	.agc1_pt3 = 0x00,
	.agc1_slope1 = 0x00,
	.agc1_slope2 = 0x00,
	.agc2_pt1 = 0x00,
	.agc2_pt2 = 0x80,
	.agc2_slope1 = 0x1d,
	.agc2_slope2 = 0x1d,
3312
	.alpha_mant = 0x11,
3313 3314 3315 3316 3317 3318
	.alpha_exp = 0x1b,
	.beta_mant = 0x17,
	.beta_exp = 0x33,
	.perform_agc_softsplit = 0x00,
};

3319
static struct dibx000_bandwidth_config stk7700p_xc4000_pll_config = {
3320 3321 3322 3323 3324 3325 3326 3327
	60000, 30000,	/* internal, sampling */
	1, 8, 3, 1, 0,	/* pll_cfg: prediv, ratio, range, reset, bypass */
	0, 0, 1, 1, 0,	/* misc: refdiv, bypclk_div, IO_CLK_en_core, */
			/* ADClkSrc, modulo */
	(3 << 14) | (1 << 12) | 524,	/* sad_cfg: refsel, sel, freq_15k */
	39370534,	/* ifreq */
	20452225,	/* timf */
	30000000	/* xtal */
3328 3329
};

3330 3331
/* FIXME: none of these inputs are validated yet */
static struct dib7000p_config pctv_340e_config = {
3332
	.output_mpeg2_in_188_bytes = 1,
3333 3334

	.agc_config_count = 1,
3335
	.agc = &stk7700p_7000p_xc4000_agc_config,
3336
	.bw  = &stk7700p_xc4000_pll_config,
3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377

	.gpio_dir = DIB7000M_GPIO_DEFAULT_DIRECTIONS,
	.gpio_val = DIB7000M_GPIO_DEFAULT_VALUES,
	.gpio_pwm_pos = DIB7000M_GPIO_DEFAULT_PWM_POS,
};

/* PCTV 340e GPIOs map:
   dib0700:
   GPIO2  - CX25843 sleep
   GPIO3  - CS5340 reset
   GPIO5  - IRD
   GPIO6  - Power Supply
   GPIO8  - LNA (1=off 0=on)
   GPIO10 - CX25843 reset
   dib7000:
   GPIO8  - xc4000 reset
 */
static int pctv340e_frontend_attach(struct dvb_usb_adapter *adap)
{
	struct dib0700_state *st = adap->dev->priv;

	/* Power Supply on */
	dib0700_set_gpio(adap->dev, GPIO6,  GPIO_OUT, 0);
	msleep(50);
	dib0700_set_gpio(adap->dev, GPIO6,  GPIO_OUT, 1);
	msleep(100); /* Allow power supply to settle before probing */

	/* cx25843 reset */
	dib0700_set_gpio(adap->dev, GPIO10,  GPIO_OUT, 0);
	msleep(1); /* cx25843 datasheet say 350us required */
	dib0700_set_gpio(adap->dev, GPIO10,  GPIO_OUT, 1);

	/* LNA off for now */
	dib0700_set_gpio(adap->dev, GPIO8,  GPIO_OUT, 1);

	/* Put the CX25843 to sleep for now since we're in digital mode */
	dib0700_set_gpio(adap->dev, GPIO2, GPIO_OUT, 1);

	/* FIXME: not verified yet */
	dib0700_ctrl_clock(adap->dev, 72, 1);

3378 3379
	msleep(500);

3380 3381 3382 3383 3384
	if (dib7000pc_detection(&adap->dev->i2c_adap) == 0) {
		/* Demodulator not found for some reason? */
		return -ENODEV;
	}

3385
	adap->fe_adap[0].fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 0x12,
3386 3387 3388
			      &pctv_340e_config);
	st->is_dib7000pc = 1;

3389
	return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
3390 3391
}

3392
static struct xc4000_config dib7000p_xc4000_tunerconfig = {
3393 3394 3395 3396 3397
	.i2c_address	  = 0x61,
	.default_pm	  = 1,
	.dvb_amplitude	  = 0,
	.set_smoothedcvbs = 0,
	.if_khz		  = 5400
3398 3399 3400 3401
};

static int xc4000_tuner_attach(struct dvb_usb_adapter *adap)
{
3402 3403 3404
	struct i2c_adapter *tun_i2c;

	/* The xc4000 is not on the main i2c bus */
3405
	tun_i2c = dib7000p_get_i2c_master(adap->fe_adap[0].fe,
3406 3407
					  DIBX000_I2C_INTERFACE_TUNER, 1);
	if (tun_i2c == NULL) {
3408
		printk(KERN_ERR "Could not reach tuner i2c bus\n");
3409 3410 3411 3412
		return 0;
	}

	/* Setup the reset callback */
3413
	adap->fe_adap[0].fe->callback = dib0700_xc4000_tuner_callback;
3414

3415
	return dvb_attach(xc4000_attach, adap->fe_adap[0].fe, tun_i2c,
3416
			  &dib7000p_xc4000_tunerconfig)
3417 3418 3419
		== NULL ? -ENODEV : 0;
}

3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470
static struct lgdt3305_config hcw_lgdt3305_config = {
	.i2c_addr           = 0x0e,
	.mpeg_mode          = LGDT3305_MPEG_PARALLEL,
	.tpclk_edge         = LGDT3305_TPCLK_FALLING_EDGE,
	.tpvalid_polarity   = LGDT3305_TP_VALID_LOW,
	.deny_i2c_rptr      = 0,
	.spectral_inversion = 1,
	.qam_if_khz         = 6000,
	.vsb_if_khz         = 6000,
	.usref_8vsb         = 0x0500,
};

static struct mxl5007t_config hcw_mxl5007t_config = {
	.xtal_freq_hz = MxL_XTAL_25_MHZ,
	.if_freq_hz = MxL_IF_6_MHZ,
	.invert_if = 1,
};

/* TIGER-ATSC map:
   GPIO0  - LNA_CTR  (H: LNA power enabled, L: LNA power disabled)
   GPIO1  - ANT_SEL  (H: VPA, L: MCX)
   GPIO4  - SCL2
   GPIO6  - EN_TUNER
   GPIO7  - SDA2
   GPIO10 - DEM_RST

   MXL is behind LG's i2c repeater.  LG is on SCL2/SDA2 gpios on the DIB
 */
static int lgdt3305_frontend_attach(struct dvb_usb_adapter *adap)
{
	struct dib0700_state *st = adap->dev->priv;

	/* Make use of the new i2c functions from FW 1.20 */
	st->fw_use_new_i2c_api = 1;

	st->disable_streaming_master_mode = 1;

	/* fe power enable */
	dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
	msleep(30);
	dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
	msleep(30);

	/* demod reset */
	dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
	msleep(30);
	dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
	msleep(30);
	dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
	msleep(30);

3471
	adap->fe_adap[0].fe = dvb_attach(lgdt3305_attach,
3472 3473 3474
			      &hcw_lgdt3305_config,
			      &adap->dev->i2c_adap);

3475
	return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
3476 3477 3478 3479
}

static int mxl5007t_tuner_attach(struct dvb_usb_adapter *adap)
{
3480
	return dvb_attach(mxl5007t_attach, adap->fe_adap[0].fe,
3481 3482 3483 3484 3485
			  &adap->dev->i2c_adap, 0x60,
			  &hcw_mxl5007t_config) == NULL ? -ENODEV : 0;
}


3486
/* DVB-USB and USB stuff follows */
3487
struct usb_device_id dib0700_usb_id_table[] = {
3488
/* 0 */	{ USB_DEVICE(USB_VID_DIBCOM,    USB_PID_DIBCOM_STK7700P) },
3489 3490 3491 3492
	{ USB_DEVICE(USB_VID_DIBCOM,    USB_PID_DIBCOM_STK7700P_PC) },
	{ USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_500) },
	{ USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_500_2) },
	{ USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_STICK) },
3493
/* 5 */	{ USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR) },
3494 3495 3496 3497
	{ USB_DEVICE(USB_VID_COMPRO,    USB_PID_COMPRO_VIDEOMATE_U500) },
	{ USB_DEVICE(USB_VID_UNIWILL,   USB_PID_UNIWILL_STK7700P) },
	{ USB_DEVICE(USB_VID_LEADTEK,   USB_PID_WINFAST_DTV_DONGLE_STK7700P) },
	{ USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_STICK_2) },
3498
/* 10 */{ USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR_2) },
3499 3500 3501 3502 3503
	{ USB_DEVICE(USB_VID_PINNACLE,  USB_PID_PINNACLE_PCTV2000E) },
	{ USB_DEVICE(USB_VID_TERRATEC,
			USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY) },
	{ USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_TD_STICK) },
	{ USB_DEVICE(USB_VID_DIBCOM,    USB_PID_DIBCOM_STK7700D) },
3504
/* 15 */{ USB_DEVICE(USB_VID_DIBCOM,    USB_PID_DIBCOM_STK7070P) },
3505 3506 3507 3508 3509
	{ USB_DEVICE(USB_VID_PINNACLE,  USB_PID_PINNACLE_PCTV_DVB_T_FLASH) },
	{ USB_DEVICE(USB_VID_DIBCOM,    USB_PID_DIBCOM_STK7070PD) },
	{ USB_DEVICE(USB_VID_PINNACLE,
			USB_PID_PINNACLE_PCTV_DUAL_DIVERSITY_DVB_T) },
	{ USB_DEVICE(USB_VID_COMPRO,    USB_PID_COMPRO_VIDEOMATE_U500_PC) },
3510
/* 20 */{ USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_EXPRESS) },
3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522
	{ USB_DEVICE(USB_VID_GIGABYTE,  USB_PID_GIGABYTE_U7000) },
	{ USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC, USB_PID_ARTEC_T14BR) },
	{ USB_DEVICE(USB_VID_ASUS,      USB_PID_ASUS_U3000) },
	{ USB_DEVICE(USB_VID_ASUS,      USB_PID_ASUS_U3100) },
/* 25 */{ USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_STICK_3) },
	{ USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_MYTV_T) },
	{ USB_DEVICE(USB_VID_TERRATEC,  USB_PID_TERRATEC_CINERGY_HT_USB_XE) },
	{ USB_DEVICE(USB_VID_PINNACLE,	USB_PID_PINNACLE_EXPRESSCARD_320CX) },
	{ USB_DEVICE(USB_VID_PINNACLE,	USB_PID_PINNACLE_PCTV72E) },
/* 30 */{ USB_DEVICE(USB_VID_PINNACLE,	USB_PID_PINNACLE_PCTV73E) },
	{ USB_DEVICE(USB_VID_YUAN,	USB_PID_YUAN_EC372S) },
	{ USB_DEVICE(USB_VID_TERRATEC,	USB_PID_TERRATEC_CINERGY_HT_EXPRESS) },
3523
	{ USB_DEVICE(USB_VID_TERRATEC,	USB_PID_TERRATEC_CINERGY_T_XXS) },
3524
	{ USB_DEVICE(USB_VID_LEADTEK,   USB_PID_WINFAST_DTV_DONGLE_STK7700P_2) },
3525
/* 35 */{ USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_TD_STICK_52009) },
3526
	{ USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_500_3) },
3527
	{ USB_DEVICE(USB_VID_GIGABYTE,  USB_PID_GIGABYTE_U8000) },
3528
	{ USB_DEVICE(USB_VID_YUAN,      USB_PID_YUAN_STK7700PH) },
3529
	{ USB_DEVICE(USB_VID_ASUS,	USB_PID_ASUS_U3000H) },
3530
/* 40 */{ USB_DEVICE(USB_VID_PINNACLE,  USB_PID_PINNACLE_PCTV801E) },
3531
	{ USB_DEVICE(USB_VID_PINNACLE,  USB_PID_PINNACLE_PCTV801E_SE) },
3532
	{ USB_DEVICE(USB_VID_TERRATEC,	USB_PID_TERRATEC_CINERGY_T_EXPRESS) },
3533 3534
	{ USB_DEVICE(USB_VID_TERRATEC,
			USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY_2) },
3535
	{ USB_DEVICE(USB_VID_SONY,	USB_PID_SONY_PLAYTV) },
3536
/* 45 */{ USB_DEVICE(USB_VID_YUAN,      USB_PID_YUAN_PD378S) },
3537 3538
	{ USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_TIGER_ATSC) },
	{ USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_TIGER_ATSC_B210) },
3539
	{ USB_DEVICE(USB_VID_YUAN,	USB_PID_YUAN_MC770) },
3540
	{ USB_DEVICE(USB_VID_ELGATO,	USB_PID_ELGATO_EYETV_DTT) },
3541
/* 50 */{ USB_DEVICE(USB_VID_ELGATO,	USB_PID_ELGATO_EYETV_DTT_Dlx) },
3542
	{ USB_DEVICE(USB_VID_LEADTEK,   USB_PID_WINFAST_DTV_DONGLE_H) },
3543 3544
	{ USB_DEVICE(USB_VID_TERRATEC,	USB_PID_TERRATEC_T3) },
	{ USB_DEVICE(USB_VID_TERRATEC,	USB_PID_TERRATEC_T5) },
3545
	{ USB_DEVICE(USB_VID_YUAN,      USB_PID_YUAN_STK7700D) },
3546 3547
/* 55 */{ USB_DEVICE(USB_VID_YUAN,	USB_PID_YUAN_STK7700D_2) },
	{ USB_DEVICE(USB_VID_PINNACLE,	USB_PID_PINNACLE_PCTV73A) },
3548 3549
	{ USB_DEVICE(USB_VID_PCTV,	USB_PID_PINNACLE_PCTV73ESE) },
	{ USB_DEVICE(USB_VID_PCTV,	USB_PID_PINNACLE_PCTV282E) },
3550
	{ USB_DEVICE(USB_VID_DIBCOM,	USB_PID_DIBCOM_STK7770P) },
3551
/* 60 */{ USB_DEVICE(USB_VID_TERRATEC,	USB_PID_TERRATEC_CINERGY_T_XXS_2) },
3552 3553
	{ USB_DEVICE(USB_VID_DIBCOM,    USB_PID_DIBCOM_STK807XPVR) },
	{ USB_DEVICE(USB_VID_DIBCOM,    USB_PID_DIBCOM_STK807XP) },
3554
	{ USB_DEVICE_VER(USB_VID_PIXELVIEW, USB_PID_PIXELVIEW_SBTVD, 0x000, 0x3f00) },
3555
	{ USB_DEVICE(USB_VID_EVOLUTEPC, USB_PID_TVWAY_PLUS) },
3556
/* 65 */{ USB_DEVICE(USB_VID_PINNACLE,	USB_PID_PINNACLE_PCTV73ESE) },
3557
	{ USB_DEVICE(USB_VID_PINNACLE,	USB_PID_PINNACLE_PCTV282E) },
3558
	{ USB_DEVICE(USB_VID_DIBCOM,    USB_PID_DIBCOM_STK8096GP) },
3559
	{ USB_DEVICE(USB_VID_ELGATO,    USB_PID_ELGATO_EYETV_DIVERSITY) },
3560 3561 3562 3563 3564
	{ USB_DEVICE(USB_VID_DIBCOM,    USB_PID_DIBCOM_NIM9090M) },
/* 70 */{ USB_DEVICE(USB_VID_DIBCOM,    USB_PID_DIBCOM_NIM8096MD) },
	{ USB_DEVICE(USB_VID_DIBCOM,    USB_PID_DIBCOM_NIM9090MD) },
	{ USB_DEVICE(USB_VID_DIBCOM,    USB_PID_DIBCOM_NIM7090) },
	{ USB_DEVICE(USB_VID_DIBCOM,    USB_PID_DIBCOM_TFE7090PVR) },
3565
	{ USB_DEVICE(USB_VID_TECHNISAT, USB_PID_TECHNISAT_AIRSTAR_TELESTICK_2) },
3566
/* 75 */{ USB_DEVICE(USB_VID_MEDION,    USB_PID_CREATIX_CTX1921) },
3567
	{ USB_DEVICE(USB_VID_PINNACLE,  USB_PID_PINNACLE_PCTV340E) },
3568
	{ USB_DEVICE(USB_VID_PINNACLE,  USB_PID_PINNACLE_PCTV340E_SE) },
3569
	{ USB_DEVICE(USB_VID_DIBCOM,    USB_PID_DIBCOM_TFE7090E) },
3570
	{ USB_DEVICE(USB_VID_DIBCOM,    USB_PID_DIBCOM_TFE7790E) },
3571
/* 80 */{ USB_DEVICE(USB_VID_DIBCOM,    USB_PID_DIBCOM_TFE8096P) },
3572
	{ USB_DEVICE(USB_VID_ELGATO,	USB_PID_ELGATO_EYETV_DTT_2) },
3573
	{ 0 }		/* Terminating entry */
3574 3575 3576 3577 3578 3579
};
MODULE_DEVICE_TABLE(usb, dib0700_usb_id_table);

#define DIB0700_DEFAULT_DEVICE_PROPERTIES \
	.caps              = DVB_USB_IS_AN_I2C_ADAPTER, \
	.usb_ctrl          = DEVICE_SPECIFIC, \
3580
	.firmware          = "dvb-usb-dib0700-1.20.fw", \
3581
	.download_firmware = dib0700_download_firmware, \
3582
	.no_reconnect      = 1, \
3583
	.size_of_priv      = sizeof(struct dib0700_state), \
3584 3585
	.i2c_algo          = &dib0700_i2c_algo, \
	.identify_state    = dib0700_identify_state
3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606

#define DIB0700_DEFAULT_STREAMING_CONFIG(ep) \
	.streaming_ctrl   = dib0700_streaming_ctrl, \
	.stream = { \
		.type = USB_BULK, \
		.count = 4, \
		.endpoint = ep, \
		.u = { \
			.bulk = { \
				.buffersize = 39480, \
			} \
		} \
	}

struct dvb_usb_device_properties dib0700_devices[] = {
	{
		DIB0700_DEFAULT_DEVICE_PROPERTIES,

		.num_adapters = 1,
		.adapter = {
			{
3607 3608
			.num_frontends = 1,
			.fe = {{
3609 3610
				.caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
				.pid_filter_count = 32,
3611 3612
				.pid_filter       = stk7700p_pid_filter,
				.pid_filter_ctrl  = stk7700p_pid_filter_ctrl,
3613 3614 3615 3616
				.frontend_attach  = stk7700p_frontend_attach,
				.tuner_attach     = stk7700p_tuner_attach,

				DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
3617
			}},
3618 3619 3620
			},
		},

3621
		.num_device_descs = 8,
3622 3623
		.devices = {
			{   "DiBcom STK7700P reference design",
3624
				{ &dib0700_usb_id_table[0], &dib0700_usb_id_table[1] },
3625 3626 3627
				{ NULL },
			},
			{   "Hauppauge Nova-T Stick",
3628
				{ &dib0700_usb_id_table[4], &dib0700_usb_id_table[9], NULL },
3629 3630 3631
				{ NULL },
			},
			{   "AVerMedia AVerTV DVB-T Volar",
3632
				{ &dib0700_usb_id_table[5], &dib0700_usb_id_table[10] },
3633 3634
				{ NULL },
			},
3635
			{   "Compro Videomate U500",
3636
				{ &dib0700_usb_id_table[6], &dib0700_usb_id_table[19] },
3637
				{ NULL },
3638 3639 3640 3641
			},
			{   "Uniwill STK7700P based (Hama and others)",
				{ &dib0700_usb_id_table[7], NULL },
				{ NULL },
3642 3643
			},
			{   "Leadtek Winfast DTV Dongle (STK7700P based)",
3644
				{ &dib0700_usb_id_table[8], &dib0700_usb_id_table[34] },
3645
				{ NULL },
3646 3647 3648 3649
			},
			{   "AVerMedia AVerTV DVB-T Express",
				{ &dib0700_usb_id_table[20] },
				{ NULL },
3650 3651 3652 3653
			},
			{   "Gigabyte U7000",
				{ &dib0700_usb_id_table[21], NULL },
				{ NULL },
3654
			}
3655 3656
		},

3657
		.rc.core = {
3658
			.rc_interval      = DEFAULT_RC_INTERVAL,
3659
			.rc_codes         = RC_MAP_DIB0700_RC5_TABLE,
3660
			.rc_query         = dib0700_rc_query_old_firmware,
3661 3662 3663
			.allowed_protos   = RC_BIT_RC5 |
					    RC_BIT_RC6_MCE |
					    RC_BIT_NEC,
3664
			.change_protocol  = dib0700_change_protocol,
3665
		},
3666 3667 3668 3669 3670
	}, { DIB0700_DEFAULT_DEVICE_PROPERTIES,

		.num_adapters = 2,
		.adapter = {
			{
3671 3672
			.num_frontends = 1,
			.fe = {{
3673 3674 3675 3676
				.frontend_attach  = bristol_frontend_attach,
				.tuner_attach     = bristol_tuner_attach,

				DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
3677
			}},
3678
			}, {
3679 3680
			.num_frontends = 1,
			.fe = {{
3681 3682 3683 3684
				.frontend_attach  = bristol_frontend_attach,
				.tuner_attach     = bristol_tuner_attach,

				DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
3685
			}},
3686 3687 3688 3689 3690 3691
			}
		},

		.num_device_descs = 1,
		.devices = {
			{   "Hauppauge Nova-T 500 Dual DVB-T",
3692
				{ &dib0700_usb_id_table[2], &dib0700_usb_id_table[3], NULL },
3693 3694
				{ NULL },
			},
3695 3696
		},

3697
		.rc.core = {
3698
			.rc_interval      = DEFAULT_RC_INTERVAL,
3699
			.rc_codes         = RC_MAP_DIB0700_RC5_TABLE,
3700
			.rc_query         = dib0700_rc_query_old_firmware,
3701 3702 3703
			.allowed_protos   = RC_BIT_RC5 |
					    RC_BIT_RC6_MCE |
					    RC_BIT_NEC,
3704
			.change_protocol = dib0700_change_protocol,
3705
		},
3706 3707 3708 3709 3710
	}, { DIB0700_DEFAULT_DEVICE_PROPERTIES,

		.num_adapters = 2,
		.adapter = {
			{
3711 3712
			.num_frontends = 1,
			.fe = {{
3713 3714 3715 3716
				.caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
				.pid_filter_count = 32,
				.pid_filter       = stk70x0p_pid_filter,
				.pid_filter_ctrl  = stk70x0p_pid_filter_ctrl,
3717 3718 3719 3720
				.frontend_attach  = stk7700d_frontend_attach,
				.tuner_attach     = stk7700d_tuner_attach,

				DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
3721
			}},
3722
			}, {
3723 3724
			.num_frontends = 1,
			.fe = {{
3725 3726 3727 3728
				.caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
				.pid_filter_count = 32,
				.pid_filter       = stk70x0p_pid_filter,
				.pid_filter_ctrl  = stk70x0p_pid_filter_ctrl,
3729 3730 3731 3732
				.frontend_attach  = stk7700d_frontend_attach,
				.tuner_attach     = stk7700d_tuner_attach,

				DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
3733
			}},
3734 3735 3736
			}
		},

3737
		.num_device_descs = 5,
3738 3739 3740 3741 3742 3743 3744 3745 3746
		.devices = {
			{   "Pinnacle PCTV 2000e",
				{ &dib0700_usb_id_table[11], NULL },
				{ NULL },
			},
			{   "Terratec Cinergy DT XS Diversity",
				{ &dib0700_usb_id_table[12], NULL },
				{ NULL },
			},
3747
			{   "Hauppauge Nova-TD Stick/Elgato Eye-TV Diversity",
3748 3749 3750
				{ &dib0700_usb_id_table[13], NULL },
				{ NULL },
			},
3751
			{   "DiBcom STK7700D reference design",
3752 3753
				{ &dib0700_usb_id_table[14], NULL },
				{ NULL },
3754
			},
3755 3756 3757 3758
			{   "YUAN High-Tech DiBcom STK7700D",
				{ &dib0700_usb_id_table[55], NULL },
				{ NULL },
			},
3759

3760
		},
3761

3762
		.rc.core = {
3763
			.rc_interval      = DEFAULT_RC_INTERVAL,
3764
			.rc_codes         = RC_MAP_DIB0700_RC5_TABLE,
3765
			.rc_query         = dib0700_rc_query_old_firmware,
3766 3767 3768
			.allowed_protos   = RC_BIT_RC5 |
					    RC_BIT_RC6_MCE |
					    RC_BIT_NEC,
3769
			.change_protocol = dib0700_change_protocol,
3770
		},
3771 3772 3773 3774 3775
	}, { DIB0700_DEFAULT_DEVICE_PROPERTIES,

		.num_adapters = 1,
		.adapter = {
			{
3776 3777
			.num_frontends = 1,
			.fe = {{
3778 3779 3780 3781
				.caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
				.pid_filter_count = 32,
				.pid_filter       = stk70x0p_pid_filter,
				.pid_filter_ctrl  = stk70x0p_pid_filter_ctrl,
3782 3783 3784 3785
				.frontend_attach  = stk7700P2_frontend_attach,
				.tuner_attach     = stk7700d_tuner_attach,

				DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
3786
			}},
3787 3788 3789
			},
		},

3790
		.num_device_descs = 3,
3791 3792 3793 3794 3795
		.devices = {
			{   "ASUS My Cinema U3000 Mini DVBT Tuner",
				{ &dib0700_usb_id_table[23], NULL },
				{ NULL },
			},
3796 3797 3798
			{   "Yuan EC372S",
				{ &dib0700_usb_id_table[31], NULL },
				{ NULL },
3799 3800 3801 3802
			},
			{   "Terratec Cinergy T Express",
				{ &dib0700_usb_id_table[42], NULL },
				{ NULL },
3803
			}
3804 3805
		},

3806
		.rc.core = {
3807
			.rc_interval      = DEFAULT_RC_INTERVAL,
3808
			.rc_codes         = RC_MAP_DIB0700_RC5_TABLE,
3809
			.module_name	  = "dib0700",
3810
			.rc_query         = dib0700_rc_query_old_firmware,
3811 3812 3813
			.allowed_protos   = RC_BIT_RC5 |
					    RC_BIT_RC6_MCE |
					    RC_BIT_NEC,
3814
			.change_protocol = dib0700_change_protocol,
3815
		},
3816 3817 3818 3819 3820
	}, { DIB0700_DEFAULT_DEVICE_PROPERTIES,

		.num_adapters = 1,
		.adapter = {
			{
3821 3822
			.num_frontends = 1,
			.fe = {{
3823 3824 3825 3826
				.caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
				.pid_filter_count = 32,
				.pid_filter       = stk70x0p_pid_filter,
				.pid_filter_ctrl  = stk70x0p_pid_filter_ctrl,
3827 3828 3829 3830
				.frontend_attach  = stk7070p_frontend_attach,
				.tuner_attach     = dib7070p_tuner_attach,

				DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
3831
			}},
3832 3833 3834 3835
				.size_of_priv     = sizeof(struct dib0700_adapter_state),
			},
		},

3836
		.num_device_descs = 12,
3837 3838 3839 3840 3841 3842 3843 3844 3845
		.devices = {
			{   "DiBcom STK7070P reference design",
				{ &dib0700_usb_id_table[15], NULL },
				{ NULL },
			},
			{   "Pinnacle PCTV DVB-T Flash Stick",
				{ &dib0700_usb_id_table[16], NULL },
				{ NULL },
			},
3846 3847 3848
			{   "Artec T14BR DVB-T",
				{ &dib0700_usb_id_table[22], NULL },
				{ NULL },
3849 3850 3851 3852 3853
			},
			{   "ASUS My Cinema U3100 Mini DVBT Tuner",
				{ &dib0700_usb_id_table[24], NULL },
				{ NULL },
			},
3854 3855 3856 3857
			{   "Hauppauge Nova-T Stick",
				{ &dib0700_usb_id_table[25], NULL },
				{ NULL },
			},
D
Darren Salt 已提交
3858 3859 3860 3861
			{   "Hauppauge Nova-T MyTV.t",
				{ &dib0700_usb_id_table[26], NULL },
				{ NULL },
			},
3862 3863 3864 3865 3866 3867 3868 3869
			{   "Pinnacle PCTV 72e",
				{ &dib0700_usb_id_table[29], NULL },
				{ NULL },
			},
			{   "Pinnacle PCTV 73e",
				{ &dib0700_usb_id_table[30], NULL },
				{ NULL },
			},
3870 3871 3872 3873
			{   "Elgato EyeTV DTT",
				{ &dib0700_usb_id_table[49], NULL },
				{ NULL },
			},
3874 3875 3876 3877
			{   "Yuan PD378S",
				{ &dib0700_usb_id_table[45], NULL },
				{ NULL },
			},
3878 3879 3880 3881
			{   "Elgato EyeTV Dtt Dlx PD378S",
				{ &dib0700_usb_id_table[50], NULL },
				{ NULL },
			},
3882 3883 3884 3885
			{   "Elgato EyeTV DTT rev. 2",
				{ &dib0700_usb_id_table[81], NULL },
				{ NULL },
			},
3886 3887
		},

3888
		.rc.core = {
3889
			.rc_interval      = DEFAULT_RC_INTERVAL,
3890
			.rc_codes         = RC_MAP_DIB0700_RC5_TABLE,
3891
			.module_name	  = "dib0700",
3892
			.rc_query         = dib0700_rc_query_old_firmware,
3893 3894 3895
			.allowed_protos   = RC_BIT_RC5 |
					    RC_BIT_RC6_MCE |
					    RC_BIT_NEC,
3896
			.change_protocol  = dib0700_change_protocol,
3897
		},
3898 3899 3900 3901 3902
	}, { DIB0700_DEFAULT_DEVICE_PROPERTIES,

		.num_adapters = 1,
		.adapter = {
			{
3903 3904
			.num_frontends = 1,
			.fe = {{
3905 3906 3907 3908
				.caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
				.pid_filter_count = 32,
				.pid_filter       = stk70x0p_pid_filter,
				.pid_filter_ctrl  = stk70x0p_pid_filter_ctrl,
3909 3910 3911 3912
				.frontend_attach  = stk7070p_frontend_attach,
				.tuner_attach     = dib7070p_tuner_attach,

				DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
3913
			}},
3914 3915 3916 3917
				.size_of_priv     = sizeof(struct dib0700_adapter_state),
			},
		},

3918
		.num_device_descs = 3,
3919 3920 3921 3922 3923 3924
		.devices = {
			{   "Pinnacle PCTV 73A",
				{ &dib0700_usb_id_table[56], NULL },
				{ NULL },
			},
			{   "Pinnacle PCTV 73e SE",
3925
				{ &dib0700_usb_id_table[57], &dib0700_usb_id_table[65], NULL },
3926 3927 3928
				{ NULL },
			},
			{   "Pinnacle PCTV 282e",
3929
				{ &dib0700_usb_id_table[58], &dib0700_usb_id_table[66], NULL },
3930 3931 3932 3933
				{ NULL },
			},
		},

3934
		.rc.core = {
3935
			.rc_interval      = DEFAULT_RC_INTERVAL,
3936
			.rc_codes         = RC_MAP_DIB0700_RC5_TABLE,
3937
			.module_name	  = "dib0700",
3938
			.rc_query         = dib0700_rc_query_old_firmware,
3939 3940 3941
			.allowed_protos   = RC_BIT_RC5 |
					    RC_BIT_RC6_MCE |
					    RC_BIT_NEC,
3942
			.change_protocol  = dib0700_change_protocol,
3943
		},
3944 3945 3946 3947 3948
	}, { DIB0700_DEFAULT_DEVICE_PROPERTIES,

		.num_adapters = 2,
		.adapter = {
			{
3949 3950
			.num_frontends = 1,
			.fe = {{
3951 3952 3953 3954
				.caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
				.pid_filter_count = 32,
				.pid_filter       = stk70x0p_pid_filter,
				.pid_filter_ctrl  = stk70x0p_pid_filter_ctrl,
3955
				.frontend_attach  = novatd_frontend_attach,
3956 3957 3958
				.tuner_attach     = dib7070p_tuner_attach,

				DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
3959
			}},
3960 3961
				.size_of_priv     = sizeof(struct dib0700_adapter_state),
			}, {
3962 3963
			.num_frontends = 1,
			.fe = {{
3964 3965 3966 3967
				.caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
				.pid_filter_count = 32,
				.pid_filter       = stk70x0p_pid_filter,
				.pid_filter_ctrl  = stk70x0p_pid_filter_ctrl,
3968
				.frontend_attach  = novatd_frontend_attach,
3969 3970 3971
				.tuner_attach     = dib7070p_tuner_attach,

				DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
3972
			}},
3973 3974 3975 3976
				.size_of_priv     = sizeof(struct dib0700_adapter_state),
			}
		},

3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989
		.num_device_descs = 1,
		.devices = {
			{   "Hauppauge Nova-TD Stick (52009)",
				{ &dib0700_usb_id_table[35], NULL },
				{ NULL },
			},
		},

		.rc.core = {
			.rc_interval      = DEFAULT_RC_INTERVAL,
			.rc_codes         = RC_MAP_DIB0700_RC5_TABLE,
			.module_name	  = "dib0700",
			.rc_query         = dib0700_rc_query_old_firmware,
3990 3991 3992
			.allowed_protos   = RC_BIT_RC5 |
					    RC_BIT_RC6_MCE |
					    RC_BIT_NEC,
3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028
			.change_protocol = dib0700_change_protocol,
		},
	}, { DIB0700_DEFAULT_DEVICE_PROPERTIES,

		.num_adapters = 2,
		.adapter = {
			{
			.num_frontends = 1,
			.fe = {{
				.caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
				.pid_filter_count = 32,
				.pid_filter       = stk70x0p_pid_filter,
				.pid_filter_ctrl  = stk70x0p_pid_filter_ctrl,
				.frontend_attach  = stk7070pd_frontend_attach0,
				.tuner_attach     = dib7070p_tuner_attach,

				DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
			}},
				.size_of_priv     = sizeof(struct dib0700_adapter_state),
			}, {
			.num_frontends = 1,
			.fe = {{
				.caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
				.pid_filter_count = 32,
				.pid_filter       = stk70x0p_pid_filter,
				.pid_filter_ctrl  = stk70x0p_pid_filter_ctrl,
				.frontend_attach  = stk7070pd_frontend_attach1,
				.tuner_attach     = dib7070p_tuner_attach,

				DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
			}},
				.size_of_priv     = sizeof(struct dib0700_adapter_state),
			}
		},

		.num_device_descs = 5,
4029 4030 4031 4032 4033 4034 4035 4036
		.devices = {
			{   "DiBcom STK7070PD reference design",
				{ &dib0700_usb_id_table[17], NULL },
				{ NULL },
			},
			{   "Pinnacle PCTV Dual DVB-T Diversity Stick",
				{ &dib0700_usb_id_table[18], NULL },
				{ NULL },
4037
			},
4038 4039 4040
			{   "Hauppauge Nova-TD-500 (84xxx)",
				{ &dib0700_usb_id_table[36], NULL },
				{ NULL },
4041
			},
4042 4043 4044
			{  "Terratec Cinergy DT USB XS Diversity/ T5",
				{ &dib0700_usb_id_table[43],
					&dib0700_usb_id_table[53], NULL},
4045
				{ NULL },
4046 4047 4048 4049
			},
			{  "Sony PlayTV",
				{ &dib0700_usb_id_table[44], NULL },
				{ NULL },
4050
			},
4051 4052 4053 4054 4055 4056
		},

		.rc.core = {
			.rc_interval      = DEFAULT_RC_INTERVAL,
			.rc_codes         = RC_MAP_DIB0700_RC5_TABLE,
			.module_name	  = "dib0700",
4057
			.rc_query         = dib0700_rc_query_old_firmware,
4058 4059 4060
			.allowed_protos   = RC_BIT_RC5 |
					    RC_BIT_RC6_MCE |
					    RC_BIT_NEC,
4061
			.change_protocol = dib0700_change_protocol,
4062 4063 4064 4065 4066 4067
		},
	}, { DIB0700_DEFAULT_DEVICE_PROPERTIES,

		.num_adapters = 2,
		.adapter = {
			{
4068 4069
			.num_frontends = 1,
			.fe = {{
4070 4071 4072 4073 4074 4075 4076 4077
				.caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
				.pid_filter_count = 32,
				.pid_filter       = stk70x0p_pid_filter,
				.pid_filter_ctrl  = stk70x0p_pid_filter_ctrl,
				.frontend_attach  = stk7070pd_frontend_attach0,
				.tuner_attach     = dib7070p_tuner_attach,

				DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
4078
			}},
4079 4080
				.size_of_priv     = sizeof(struct dib0700_adapter_state),
			}, {
4081 4082
			.num_frontends = 1,
			.fe = {{
4083 4084 4085 4086 4087 4088 4089 4090
				.caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
				.pid_filter_count = 32,
				.pid_filter       = stk70x0p_pid_filter,
				.pid_filter_ctrl  = stk70x0p_pid_filter_ctrl,
				.frontend_attach  = stk7070pd_frontend_attach1,
				.tuner_attach     = dib7070p_tuner_attach,

				DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
4091
			}},
4092 4093 4094 4095 4096 4097
				.size_of_priv     = sizeof(struct dib0700_adapter_state),
			}
		},

		.num_device_descs = 1,
		.devices = {
4098 4099 4100 4101
			{   "Elgato EyeTV Diversity",
				{ &dib0700_usb_id_table[68], NULL },
				{ NULL },
			},
4102
		},
4103

4104
		.rc.core = {
4105
			.rc_interval      = DEFAULT_RC_INTERVAL,
4106
			.rc_codes         = RC_MAP_DIB0700_NEC_TABLE,
4107
			.module_name	  = "dib0700",
4108
			.rc_query         = dib0700_rc_query_old_firmware,
4109 4110 4111
			.allowed_protos   = RC_BIT_RC5 |
					    RC_BIT_RC6_MCE |
					    RC_BIT_NEC,
4112
			.change_protocol  = dib0700_change_protocol,
4113
		},
4114 4115 4116 4117 4118
	}, { DIB0700_DEFAULT_DEVICE_PROPERTIES,

		.num_adapters = 1,
		.adapter = {
			{
4119 4120
			.num_frontends = 1,
			.fe = {{
4121 4122 4123 4124
				.caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
				.pid_filter_count = 32,
				.pid_filter       = stk70x0p_pid_filter,
				.pid_filter_ctrl  = stk70x0p_pid_filter_ctrl,
4125 4126 4127 4128
				.frontend_attach  = stk7700ph_frontend_attach,
				.tuner_attach     = stk7700ph_tuner_attach,

				DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
4129
			}},
4130 4131 4132 4133 4134
				.size_of_priv = sizeof(struct
						dib0700_adapter_state),
			},
		},

4135
		.num_device_descs = 9,
4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148
		.devices = {
			{   "Terratec Cinergy HT USB XE",
				{ &dib0700_usb_id_table[27], NULL },
				{ NULL },
			},
			{   "Pinnacle Expresscard 320cx",
				{ &dib0700_usb_id_table[28], NULL },
				{ NULL },
			},
			{   "Terratec Cinergy HT Express",
				{ &dib0700_usb_id_table[32], NULL },
				{ NULL },
			},
4149 4150 4151 4152
			{   "Gigabyte U8000-RH",
				{ &dib0700_usb_id_table[37], NULL },
				{ NULL },
			},
4153 4154 4155 4156
			{   "YUAN High-Tech STK7700PH",
				{ &dib0700_usb_id_table[38], NULL },
				{ NULL },
			},
4157 4158 4159 4160
			{   "Asus My Cinema-U3000Hybrid",
				{ &dib0700_usb_id_table[39], NULL },
				{ NULL },
			},
4161 4162 4163 4164
			{   "YUAN High-Tech MC770",
				{ &dib0700_usb_id_table[48], NULL },
				{ NULL },
			},
4165 4166 4167 4168
			{   "Leadtek WinFast DTV Dongle H",
				{ &dib0700_usb_id_table[51], NULL },
				{ NULL },
			},
4169 4170 4171 4172
			{   "YUAN High-Tech STK7700D",
				{ &dib0700_usb_id_table[54], NULL },
				{ NULL },
			},
4173
		},
4174

4175
		.rc.core = {
4176
			.rc_interval      = DEFAULT_RC_INTERVAL,
4177
			.rc_codes         = RC_MAP_DIB0700_RC5_TABLE,
4178
			.module_name	  = "dib0700",
4179
			.rc_query         = dib0700_rc_query_old_firmware,
4180 4181 4182
			.allowed_protos   = RC_BIT_RC5 |
					    RC_BIT_RC6_MCE |
					    RC_BIT_NEC,
4183
			.change_protocol  = dib0700_change_protocol,
4184
		},
4185 4186 4187 4188
	}, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
		.num_adapters = 1,
		.adapter = {
			{
4189 4190
			.num_frontends = 1,
			.fe = {{
4191 4192 4193 4194
				.frontend_attach  = s5h1411_frontend_attach,
				.tuner_attach     = xc5000_tuner_attach,

				DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
4195
			}},
4196 4197 4198 4199 4200
				.size_of_priv = sizeof(struct
						dib0700_adapter_state),
			},
		},

4201
		.num_device_descs = 2,
4202 4203 4204 4205 4206
		.devices = {
			{   "Pinnacle PCTV HD Pro USB Stick",
				{ &dib0700_usb_id_table[40], NULL },
				{ NULL },
			},
4207 4208 4209 4210
			{   "Pinnacle PCTV HD USB Stick",
				{ &dib0700_usb_id_table[41], NULL },
				{ NULL },
			},
4211
		},
4212 4213

		.rc.core = {
4214
			.rc_interval      = DEFAULT_RC_INTERVAL,
4215
			.rc_codes         = RC_MAP_DIB0700_RC5_TABLE,
4216
			.module_name	  = "dib0700",
4217
			.rc_query         = dib0700_rc_query_old_firmware,
4218 4219 4220
			.allowed_protos   = RC_BIT_RC5 |
					    RC_BIT_RC6_MCE |
					    RC_BIT_NEC,
4221
			.change_protocol  = dib0700_change_protocol,
4222
		},
4223 4224 4225 4226
	}, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
		.num_adapters = 1,
		.adapter = {
			{
4227 4228
			.num_frontends = 1,
			.fe = {{
4229 4230 4231 4232
				.frontend_attach  = lgdt3305_frontend_attach,
				.tuner_attach     = mxl5007t_tuner_attach,

				DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
4233
			}},
4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249
				.size_of_priv = sizeof(struct
						dib0700_adapter_state),
			},
		},

		.num_device_descs = 2,
		.devices = {
			{   "Hauppauge ATSC MiniCard (B200)",
				{ &dib0700_usb_id_table[46], NULL },
				{ NULL },
			},
			{   "Hauppauge ATSC MiniCard (B210)",
				{ &dib0700_usb_id_table[47], NULL },
				{ NULL },
			},
		},
4250 4251 4252 4253 4254
	}, { DIB0700_DEFAULT_DEVICE_PROPERTIES,

		.num_adapters = 1,
		.adapter = {
			{
4255 4256
			.num_frontends = 1,
			.fe = {{
4257 4258 4259 4260
				.caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
				.pid_filter_count = 32,
				.pid_filter       = stk70x0p_pid_filter,
				.pid_filter_ctrl  = stk70x0p_pid_filter_ctrl,
4261
				.frontend_attach  = stk7770p_frontend_attach,
4262 4263 4264
				.tuner_attach     = dib7770p_tuner_attach,

				DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
4265
			}},
4266
				.size_of_priv =
4267
					sizeof(struct dib0700_adapter_state),
4268 4269 4270
			},
		},

4271
		.num_device_descs = 4,
4272 4273 4274 4275 4276
		.devices = {
			{   "DiBcom STK7770P reference design",
				{ &dib0700_usb_id_table[59], NULL },
				{ NULL },
			},
4277 4278 4279 4280
			{   "Terratec Cinergy T USB XXS (HD)/ T3",
				{ &dib0700_usb_id_table[33],
					&dib0700_usb_id_table[52],
					&dib0700_usb_id_table[60], NULL},
4281 4282
				{ NULL },
			},
4283 4284 4285 4286
			{   "TechniSat AirStar TeleStick 2",
				{ &dib0700_usb_id_table[74], NULL },
				{ NULL },
			},
4287 4288 4289 4290
			{   "Medion CTX1921 DVB-T USB",
				{ &dib0700_usb_id_table[75], NULL },
				{ NULL },
			},
4291
		},
4292 4293

		.rc.core = {
4294
			.rc_interval      = DEFAULT_RC_INTERVAL,
4295
			.rc_codes         = RC_MAP_DIB0700_RC5_TABLE,
4296
			.module_name	  = "dib0700",
4297
			.rc_query         = dib0700_rc_query_old_firmware,
4298 4299 4300
			.allowed_protos   = RC_BIT_RC5 |
					    RC_BIT_RC6_MCE |
					    RC_BIT_NEC,
4301
			.change_protocol  = dib0700_change_protocol,
4302
		},
4303 4304 4305 4306
	}, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
		.num_adapters = 1,
		.adapter = {
			{
4307 4308
			.num_frontends = 1,
			.fe = {{
4309 4310
				.caps  = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
				.pid_filter_count = 32,
4311 4312
				.pid_filter = stk80xx_pid_filter,
				.pid_filter_ctrl = stk80xx_pid_filter_ctrl,
4313 4314 4315 4316
				.frontend_attach  = stk807x_frontend_attach,
				.tuner_attach     = dib807x_tuner_attach,

				DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
4317
			}},
4318 4319 4320 4321 4322
				.size_of_priv =
					sizeof(struct dib0700_adapter_state),
			},
		},

4323
		.num_device_descs = 3,
4324 4325 4326 4327 4328
		.devices = {
			{   "DiBcom STK807xP reference design",
				{ &dib0700_usb_id_table[62], NULL },
				{ NULL },
			},
4329 4330 4331 4332
			{   "Prolink Pixelview SBTVD",
				{ &dib0700_usb_id_table[63], NULL },
				{ NULL },
			},
4333 4334 4335 4336
			{   "EvolutePC TVWay+",
				{ &dib0700_usb_id_table[64], NULL },
				{ NULL },
			},
4337 4338
		},

4339
		.rc.core = {
4340
			.rc_interval      = DEFAULT_RC_INTERVAL,
4341
			.rc_codes         = RC_MAP_DIB0700_NEC_TABLE,
4342
			.module_name	  = "dib0700",
4343
			.rc_query         = dib0700_rc_query_old_firmware,
4344 4345 4346
			.allowed_protos   = RC_BIT_RC5 |
					    RC_BIT_RC6_MCE |
					    RC_BIT_NEC,
4347
			.change_protocol  = dib0700_change_protocol,
4348
		},
4349 4350 4351 4352
	}, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
		.num_adapters = 2,
		.adapter = {
			{
4353 4354
			.num_frontends = 1,
			.fe = {{
4355 4356
				.caps  = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
				.pid_filter_count = 32,
4357 4358
				.pid_filter = stk80xx_pid_filter,
				.pid_filter_ctrl = stk80xx_pid_filter_ctrl,
4359 4360 4361 4362
				.frontend_attach  = stk807xpvr_frontend_attach0,
				.tuner_attach     = dib807x_tuner_attach,

				DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
4363
			}},
4364 4365 4366 4367
				.size_of_priv =
					sizeof(struct dib0700_adapter_state),
			},
			{
4368 4369
			.num_frontends = 1,
			.fe = {{
4370 4371
				.caps  = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
				.pid_filter_count = 32,
4372 4373
				.pid_filter = stk80xx_pid_filter,
				.pid_filter_ctrl = stk80xx_pid_filter_ctrl,
4374 4375 4376 4377
				.frontend_attach  = stk807xpvr_frontend_attach1,
				.tuner_attach     = dib807x_tuner_attach,

				DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
4378
			}},
4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391
				.size_of_priv =
					sizeof(struct dib0700_adapter_state),
			},
		},

		.num_device_descs = 1,
		.devices = {
			{   "DiBcom STK807xPVR reference design",
				{ &dib0700_usb_id_table[61], NULL },
				{ NULL },
			},
		},

4392
		.rc.core = {
4393
			.rc_interval      = DEFAULT_RC_INTERVAL,
4394
			.rc_codes         = RC_MAP_DIB0700_RC5_TABLE,
4395
			.module_name	  = "dib0700",
4396
			.rc_query         = dib0700_rc_query_old_firmware,
4397 4398 4399
			.allowed_protos   = RC_BIT_RC5 |
					    RC_BIT_RC6_MCE |
					    RC_BIT_NEC,
4400
			.change_protocol  = dib0700_change_protocol,
4401
		},
4402 4403 4404 4405
	}, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
		.num_adapters = 1,
		.adapter = {
			{
4406 4407
			.num_frontends = 1,
			.fe = {{
4408 4409 4410 4411 4412 4413 4414 4415 4416
				.caps  = DVB_USB_ADAP_HAS_PID_FILTER |
					DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
				.pid_filter_count = 32,
				.pid_filter = stk80xx_pid_filter,
				.pid_filter_ctrl = stk80xx_pid_filter_ctrl,
				.frontend_attach  = stk809x_frontend_attach,
				.tuner_attach     = dib809x_tuner_attach,

				DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
4417
			}},
4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430
				.size_of_priv =
					sizeof(struct dib0700_adapter_state),
			},
		},

		.num_device_descs = 1,
		.devices = {
			{   "DiBcom STK8096GP reference design",
				{ &dib0700_usb_id_table[67], NULL },
				{ NULL },
			},
		},

4431 4432 4433 4434 4435
		.rc.core = {
			.rc_interval      = DEFAULT_RC_INTERVAL,
			.rc_codes         = RC_MAP_DIB0700_RC5_TABLE,
			.module_name	  = "dib0700",
			.rc_query         = dib0700_rc_query_old_firmware,
4436 4437 4438
			.allowed_protos   = RC_BIT_RC5 |
					    RC_BIT_RC6_MCE |
					    RC_BIT_NEC,
4439 4440 4441 4442 4443 4444
			.change_protocol  = dib0700_change_protocol,
		},
	}, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
		.num_adapters = 1,
		.adapter = {
			{
4445 4446
			.num_frontends = 1,
			.fe = {{
4447 4448 4449 4450 4451 4452 4453 4454 4455
				.caps  = DVB_USB_ADAP_HAS_PID_FILTER |
					DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
				.pid_filter_count = 32,
				.pid_filter = dib90x0_pid_filter,
				.pid_filter_ctrl = dib90x0_pid_filter_ctrl,
				.frontend_attach  = stk9090m_frontend_attach,
				.tuner_attach     = dib9090_tuner_attach,

				DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
4456
			}},
4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474
				.size_of_priv =
					sizeof(struct dib0700_adapter_state),
			},
		},

		.num_device_descs = 1,
		.devices = {
			{   "DiBcom STK9090M reference design",
				{ &dib0700_usb_id_table[69], NULL },
				{ NULL },
			},
		},

		.rc.core = {
			.rc_interval      = DEFAULT_RC_INTERVAL,
			.rc_codes         = RC_MAP_DIB0700_RC5_TABLE,
			.module_name	  = "dib0700",
			.rc_query         = dib0700_rc_query_old_firmware,
4475 4476 4477
			.allowed_protos   = RC_BIT_RC5 |
					    RC_BIT_RC6_MCE |
					    RC_BIT_NEC,
4478 4479 4480 4481 4482 4483
			.change_protocol  = dib0700_change_protocol,
		},
	}, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
		.num_adapters = 1,
		.adapter = {
			{
4484 4485
			.num_frontends = 1,
			.fe = {{
4486 4487 4488 4489 4490 4491 4492 4493 4494
				.caps  = DVB_USB_ADAP_HAS_PID_FILTER |
					DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
				.pid_filter_count = 32,
				.pid_filter = stk80xx_pid_filter,
				.pid_filter_ctrl = stk80xx_pid_filter_ctrl,
				.frontend_attach  = nim8096md_frontend_attach,
				.tuner_attach     = nim8096md_tuner_attach,

				DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
4495
			}},
4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513
				.size_of_priv =
					sizeof(struct dib0700_adapter_state),
			},
		},

		.num_device_descs = 1,
		.devices = {
			{   "DiBcom NIM8096MD reference design",
				{ &dib0700_usb_id_table[70], NULL },
				{ NULL },
			},
		},

		.rc.core = {
			.rc_interval      = DEFAULT_RC_INTERVAL,
			.rc_codes         = RC_MAP_DIB0700_RC5_TABLE,
			.module_name	  = "dib0700",
			.rc_query         = dib0700_rc_query_old_firmware,
4514 4515 4516
			.allowed_protos   = RC_BIT_RC5 |
					    RC_BIT_RC6_MCE |
					    RC_BIT_NEC,
4517 4518 4519 4520 4521 4522
			.change_protocol  = dib0700_change_protocol,
		},
	}, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
		.num_adapters = 1,
		.adapter = {
			{
4523 4524
			.num_frontends = 1,
			.fe = {{
4525 4526 4527 4528 4529 4530 4531 4532 4533
				.caps  = DVB_USB_ADAP_HAS_PID_FILTER |
					DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
				.pid_filter_count = 32,
				.pid_filter = dib90x0_pid_filter,
				.pid_filter_ctrl = dib90x0_pid_filter_ctrl,
				.frontend_attach  = nim9090md_frontend_attach,
				.tuner_attach     = nim9090md_tuner_attach,

				DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
4534
			}},
4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552
				.size_of_priv =
					sizeof(struct dib0700_adapter_state),
			},
		},

		.num_device_descs = 1,
		.devices = {
			{   "DiBcom NIM9090MD reference design",
				{ &dib0700_usb_id_table[71], NULL },
				{ NULL },
			},
		},

		.rc.core = {
			.rc_interval      = DEFAULT_RC_INTERVAL,
			.rc_codes         = RC_MAP_DIB0700_RC5_TABLE,
			.module_name	  = "dib0700",
			.rc_query         = dib0700_rc_query_old_firmware,
4553 4554 4555
			.allowed_protos   = RC_BIT_RC5 |
					    RC_BIT_RC6_MCE |
					    RC_BIT_NEC,
4556 4557 4558 4559 4560 4561
			.change_protocol  = dib0700_change_protocol,
		},
	}, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
		.num_adapters = 1,
		.adapter = {
			{
4562 4563
			.num_frontends = 1,
			.fe = {{
4564 4565 4566 4567 4568 4569 4570 4571 4572
				.caps  = DVB_USB_ADAP_HAS_PID_FILTER |
					DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
				.pid_filter_count = 32,
				.pid_filter = stk70x0p_pid_filter,
				.pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
				.frontend_attach  = nim7090_frontend_attach,
				.tuner_attach     = nim7090_tuner_attach,

				DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
4573
			}},
4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591
				.size_of_priv =
					sizeof(struct dib0700_adapter_state),
			},
		},

		.num_device_descs = 1,
		.devices = {
			{   "DiBcom NIM7090 reference design",
				{ &dib0700_usb_id_table[72], NULL },
				{ NULL },
			},
		},

		.rc.core = {
			.rc_interval      = DEFAULT_RC_INTERVAL,
			.rc_codes         = RC_MAP_DIB0700_RC5_TABLE,
			.module_name	  = "dib0700",
			.rc_query         = dib0700_rc_query_old_firmware,
4592 4593 4594
			.allowed_protos   = RC_BIT_RC5 |
					    RC_BIT_RC6_MCE |
					    RC_BIT_NEC,
4595 4596 4597 4598 4599 4600
			.change_protocol  = dib0700_change_protocol,
		},
	}, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
		.num_adapters = 2,
		.adapter = {
			{
4601 4602
			.num_frontends = 1,
			.fe = {{
4603 4604 4605 4606 4607 4608 4609 4610 4611
				.caps  = DVB_USB_ADAP_HAS_PID_FILTER |
					DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
				.pid_filter_count = 32,
				.pid_filter = stk70x0p_pid_filter,
				.pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
				.frontend_attach  = tfe7090pvr_frontend0_attach,
				.tuner_attach     = tfe7090pvr_tuner0_attach,

				DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
4612
			}},
4613 4614 4615 4616
				.size_of_priv =
					sizeof(struct dib0700_adapter_state),
			},
			{
4617 4618
			.num_frontends = 1,
			.fe = {{
4619 4620 4621 4622 4623 4624 4625 4626 4627
				.caps  = DVB_USB_ADAP_HAS_PID_FILTER |
					DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
				.pid_filter_count = 32,
				.pid_filter = stk70x0p_pid_filter,
				.pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
				.frontend_attach  = tfe7090pvr_frontend1_attach,
				.tuner_attach     = tfe7090pvr_tuner1_attach,

				DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
4628
			}},
4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641
				.size_of_priv =
					sizeof(struct dib0700_adapter_state),
			},
		},

		.num_device_descs = 1,
		.devices = {
			{   "DiBcom TFE7090PVR reference design",
				{ &dib0700_usb_id_table[73], NULL },
				{ NULL },
			},
		},

4642 4643 4644 4645 4646
		.rc.core = {
			.rc_interval      = DEFAULT_RC_INTERVAL,
			.rc_codes         = RC_MAP_DIB0700_RC5_TABLE,
			.module_name	  = "dib0700",
			.rc_query         = dib0700_rc_query_old_firmware,
4647 4648 4649
			.allowed_protos   = RC_BIT_RC5 |
					    RC_BIT_RC6_MCE |
					    RC_BIT_NEC,
4650 4651 4652 4653 4654 4655
			.change_protocol  = dib0700_change_protocol,
		},
	}, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
		.num_adapters = 1,
		.adapter = {
			{
4656 4657
			.num_frontends = 1,
			.fe = {{
4658
				.frontend_attach  = pctv340e_frontend_attach,
4659 4660 4661
				.tuner_attach     = xc4000_tuner_attach,

				DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
4662
			}},
4663 4664 4665 4666 4667
				.size_of_priv = sizeof(struct
						dib0700_adapter_state),
			},
		},

4668
		.num_device_descs = 2,
4669 4670 4671 4672 4673
		.devices = {
			{   "Pinnacle PCTV 340e HD Pro USB Stick",
				{ &dib0700_usb_id_table[76], NULL },
				{ NULL },
			},
4674 4675 4676 4677
			{   "Pinnacle PCTV Hybrid Stick Solo",
				{ &dib0700_usb_id_table[77], NULL },
				{ NULL },
			},
4678
		},
4679 4680 4681 4682 4683
		.rc.core = {
			.rc_interval      = DEFAULT_RC_INTERVAL,
			.rc_codes         = RC_MAP_DIB0700_RC5_TABLE,
			.module_name	  = "dib0700",
			.rc_query         = dib0700_rc_query_old_firmware,
4684 4685 4686
			.allowed_protos   = RC_BIT_RC5 |
					    RC_BIT_RC6_MCE |
					    RC_BIT_NEC,
4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718
			.change_protocol  = dib0700_change_protocol,
		},
	}, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
		.num_adapters = 1,
		.adapter = {
			{
				.num_frontends = 1,
				.fe = {{
					.caps  = DVB_USB_ADAP_HAS_PID_FILTER |
						DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
					.pid_filter_count = 32,
					.pid_filter = stk70x0p_pid_filter,
					.pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
					.frontend_attach  = tfe7090e_frontend_attach,
					.tuner_attach     = tfe7090e_tuner_attach,

					DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
				} },

				.size_of_priv =
					sizeof(struct dib0700_adapter_state),
			},
		},

		.num_device_descs = 1,
		.devices = {
			{   "DiBcom TFE7090E reference design",
				{ &dib0700_usb_id_table[78], NULL },
				{ NULL },
			},
		},

4719 4720 4721 4722 4723
		.rc.core = {
			.rc_interval      = DEFAULT_RC_INTERVAL,
			.rc_codes         = RC_MAP_DIB0700_RC5_TABLE,
			.module_name	  = "dib0700",
			.rc_query         = dib0700_rc_query_old_firmware,
4724 4725 4726
			.allowed_protos   = RC_BIT_RC5 |
					    RC_BIT_RC6_MCE |
					    RC_BIT_NEC,
4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758
			.change_protocol  = dib0700_change_protocol,
		},
	}, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
		.num_adapters = 1,
		.adapter = {
			{
				.num_frontends = 1,
				.fe = {{
					.caps  = DVB_USB_ADAP_HAS_PID_FILTER |
						DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
					.pid_filter_count = 32,
					.pid_filter = stk70x0p_pid_filter,
					.pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
					.frontend_attach  = tfe7790e_frontend_attach,
					.tuner_attach     = tfe7790e_tuner_attach,

					DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
				} },

				.size_of_priv =
					sizeof(struct dib0700_adapter_state),
			},
		},

		.num_device_descs = 1,
		.devices = {
			{   "DiBcom TFE7790E reference design",
				{ &dib0700_usb_id_table[79], NULL },
				{ NULL },
			},
		},

4759 4760 4761 4762 4763
		.rc.core = {
			.rc_interval      = DEFAULT_RC_INTERVAL,
			.rc_codes         = RC_MAP_DIB0700_RC5_TABLE,
			.module_name	  = "dib0700",
			.rc_query         = dib0700_rc_query_old_firmware,
4764 4765 4766
			.allowed_protos   = RC_BIT_RC5 |
					    RC_BIT_RC6_MCE |
					    RC_BIT_NEC,
4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799
			.change_protocol  = dib0700_change_protocol,
		},
	}, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
		.num_adapters = 1,
		.adapter = {
			{
				.num_frontends = 1,
				.fe = {{
					.caps  = DVB_USB_ADAP_HAS_PID_FILTER |
						DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
					.pid_filter_count = 32,
					.pid_filter = stk80xx_pid_filter,
					.pid_filter_ctrl = stk80xx_pid_filter_ctrl,
					.frontend_attach  = tfe8096p_frontend_attach,
					.tuner_attach     = tfe8096p_tuner_attach,

					DIB0700_DEFAULT_STREAMING_CONFIG(0x02),

				} },

				.size_of_priv =
					sizeof(struct dib0700_adapter_state),
			},
		},

		.num_device_descs = 1,
		.devices = {
			{   "DiBcom TFE8096P reference design",
				{ &dib0700_usb_id_table[80], NULL },
				{ NULL },
			},
		},

4800
		.rc.core = {
4801
			.rc_interval      = DEFAULT_RC_INTERVAL,
4802
			.rc_codes         = RC_MAP_DIB0700_RC5_TABLE,
4803
			.module_name	  = "dib0700",
4804
			.rc_query         = dib0700_rc_query_old_firmware,
4805 4806 4807
			.allowed_protos   = RC_BIT_RC5 |
					    RC_BIT_RC6_MCE |
					    RC_BIT_NEC,
4808
			.change_protocol  = dib0700_change_protocol,
4809
		},
4810
	},
4811 4812 4813
};

int dib0700_device_count = ARRAY_SIZE(dib0700_devices);