cxusb.c 31.4 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13
/* DVB USB compliant linux driver for Conexant USB reference design.
 *
 * The Conexant reference design I saw on their website was only for analogue
 * capturing (using the cx25842). The box I took to write this driver (reverse
 * engineered) is the one labeled Medion MD95700. In addition to the cx25842
 * for analogue capturing it also has a cx22702 DVB-T demodulator on the main
 * board. Besides it has a atiremote (X10) and a USB2.0 hub onboard.
 *
 * Maybe it is a little bit premature to call this driver cxusb, but I assume
 * the USB protocol is identical or at least inherited from the reference
 * design, so it can be reused for the "analogue-only" device (if it will
 * appear at all).
 *
14
 * TODO: Use the cx25840-driver for the analogue part
15 16
 *
 * Copyright (C) 2005 Patrick Boettcher (patrick.boettcher@desy.de)
17
 * Copyright (C) 2006 Michael Krufky (mkrufky@linuxtv.org)
18
 * Copyright (C) 2006, 2007 Chris Pascoe (c.pascoe@itee.uq.edu.au)
19
 *
20 21 22
 *   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.
23 24 25
 *
 * see Documentation/dvb/README.dvb-usb for more information
 */
26 27
#include <media/tuner.h>

28 29 30
#include "cxusb.h"

#include "cx22702.h"
31
#include "lgdt330x.h"
32 33
#include "mt352.h"
#include "mt352_priv.h"
34
#include "zl10353.h"
35 36
#include "tuner-xc2028.h"
#include "tuner-xc2028-types.h"
37
#include "tuner-simple.h"
38 39

/* debug */
40
static int dvb_usb_cxusb_debug;
41
module_param_named(debug, dvb_usb_cxusb_debug, int, 0644);
42
MODULE_PARM_DESC(debug, "set debugging level (1=rc (or-able))." DVB_USB_DEBUG_STATUS);
43 44 45

DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);

46 47 48
#define deb_info(args...)   dprintk(dvb_usb_cxusb_debug,0x01,args)
#define deb_i2c(args...)    if (d->udev->descriptor.idVendor == USB_VID_MEDION) \
				dprintk(dvb_usb_cxusb_debug,0x01,args)
49 50

static int cxusb_ctrl_msg(struct dvb_usb_device *d,
51
			  u8 cmd, u8 *wbuf, int wlen, u8 *rbuf, int rlen)
52 53 54
{
	int wo = (rbuf == NULL || rlen == 0); /* write-only */
	u8 sndbuf[1+wlen];
55
	memset(sndbuf, 0, 1+wlen);
56 57

	sndbuf[0] = cmd;
58
	memcpy(&sndbuf[1], wbuf, wlen);
59
	if (wo)
60
		return dvb_usb_generic_write(d, sndbuf, 1+wlen);
61
	else
62
		return dvb_usb_generic_rw(d, sndbuf, 1+wlen, rbuf, rlen, 0);
63 64
}

65 66
/* GPIO */
static void cxusb_gpio_tuner(struct dvb_usb_device *d, int onoff)
67 68
{
	struct cxusb_state *st = d->priv;
69
	u8 o[2], i;
70

71
	if (st->gpio_write_state[GPIO_TUNER] == onoff)
72 73
		return;

74 75
	o[0] = GPIO_TUNER;
	o[1] = onoff;
76
	cxusb_ctrl_msg(d, CMD_GPIO_WRITE, o, 2, &i, 1);
77 78

	if (i != 0x01)
79
		deb_info("gpio_write failed.\n");
80

81
	st->gpio_write_state[GPIO_TUNER] = onoff;
82 83
}

84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
static int cxusb_bluebird_gpio_rw(struct dvb_usb_device *d, u8 changemask,
				 u8 newval)
{
	u8 o[2], gpio_state;
	int rc;

	o[0] = 0xff & ~changemask;	/* mask of bits to keep */
	o[1] = newval & changemask;	/* new values for bits  */

	rc = cxusb_ctrl_msg(d, CMD_BLUEBIRD_GPIO_RW, o, 2, &gpio_state, 1);
	if (rc < 0 || (gpio_state & changemask) != (newval & changemask))
		deb_info("bluebird_gpio_write failed.\n");

	return rc < 0 ? rc : gpio_state;
}

static void cxusb_bluebird_gpio_pulse(struct dvb_usb_device *d, u8 pin, int low)
{
	cxusb_bluebird_gpio_rw(d, pin, low ? 0 : pin);
	msleep(5);
	cxusb_bluebird_gpio_rw(d, pin, low ? pin : 0);
}

107 108 109 110 111
static void cxusb_nano2_led(struct dvb_usb_device *d, int onoff)
{
	cxusb_bluebird_gpio_rw(d, 0x40, onoff ? 0 : 0x40);
}

112
/* I2C */
113 114
static int cxusb_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
			  int num)
115 116 117 118
{
	struct dvb_usb_device *d = i2c_get_adapdata(adap);
	int i;

119
	if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
120 121 122 123
		return -EAGAIN;

	for (i = 0; i < num; i++) {

124 125
		if (d->udev->descriptor.idVendor == USB_VID_MEDION)
			switch (msg[i].addr) {
126 127 128 129 130 131
			case 0x63:
				cxusb_gpio_tuner(d, 0);
				break;
			default:
				cxusb_gpio_tuner(d, 1);
				break;
132
			}
133

134 135 136 137 138 139 140 141 142 143 144 145 146
		if (msg[i].flags & I2C_M_RD) {
			/* read only */
			u8 obuf[3], ibuf[1+msg[i].len];
			obuf[0] = 0;
			obuf[1] = msg[i].len;
			obuf[2] = msg[i].addr;
			if (cxusb_ctrl_msg(d, CMD_I2C_READ,
					   obuf, 3,
					   ibuf, 1+msg[i].len) < 0) {
				warn("i2c read failed");
				break;
			}
			memcpy(msg[i].buf, &ibuf[1], msg[i].len);
147 148 149
		} else if (i+1 < num && (msg[i+1].flags & I2C_M_RD) &&
			   msg[i].addr == msg[i+1].addr) {
			/* write to then read from same address */
150 151 152 153
			u8 obuf[3+msg[i].len], ibuf[1+msg[i+1].len];
			obuf[0] = msg[i].len;
			obuf[1] = msg[i+1].len;
			obuf[2] = msg[i].addr;
154
			memcpy(&obuf[3], msg[i].buf, msg[i].len);
155 156

			if (cxusb_ctrl_msg(d, CMD_I2C_READ,
157 158
					   obuf, 3+msg[i].len,
					   ibuf, 1+msg[i+1].len) < 0)
159 160 161
				break;

			if (ibuf[0] != 0x08)
162
				deb_i2c("i2c read may have failed\n");
163

164
			memcpy(msg[i+1].buf, &ibuf[1], msg[i+1].len);
165 166

			i++;
167 168
		} else {
			/* write only */
169 170 171
			u8 obuf[2+msg[i].len], ibuf;
			obuf[0] = msg[i].addr;
			obuf[1] = msg[i].len;
172
			memcpy(&obuf[2], msg[i].buf, msg[i].len);
173

174 175
			if (cxusb_ctrl_msg(d, CMD_I2C_WRITE, obuf,
					   2+msg[i].len, &ibuf,1) < 0)
176 177
				break;
			if (ibuf != 0x08)
178
				deb_i2c("i2c write may have failed\n");
179 180 181
		}
	}

182
	mutex_unlock(&d->i2c_mutex);
183
	return i == num ? num : -EREMOTEIO;
184 185 186 187 188 189 190 191 192 193 194 195 196 197
}

static u32 cxusb_i2c_func(struct i2c_adapter *adapter)
{
	return I2C_FUNC_I2C;
}

static struct i2c_algorithm cxusb_i2c_algo = {
	.master_xfer   = cxusb_i2c_xfer,
	.functionality = cxusb_i2c_func,
};

static int cxusb_power_ctrl(struct dvb_usb_device *d, int onoff)
{
198 199 200 201 202
	u8 b = 0;
	if (onoff)
		return cxusb_ctrl_msg(d, CMD_POWER_ON, &b, 1, NULL, 0);
	else
		return cxusb_ctrl_msg(d, CMD_POWER_OFF, &b, 1, NULL, 0);
203 204
}

205 206 207 208 209 210 211 212 213
static int cxusb_bluebird_power_ctrl(struct dvb_usb_device *d, int onoff)
{
	u8 b = 0;
	if (onoff)
		return cxusb_ctrl_msg(d, CMD_POWER_ON, &b, 1, NULL, 0);
	else
		return 0;
}

214 215 216 217 218 219 220 221 222 223 224
static int cxusb_nano2_power_ctrl(struct dvb_usb_device *d, int onoff)
{
	int rc = 0;

	rc = cxusb_power_ctrl(d, onoff);
	if (!onoff)
		cxusb_nano2_led(d, 0);

	return rc;
}

225
static int cxusb_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
226
{
227 228
	u8 buf[2] = { 0x03, 0x00 };
	if (onoff)
229
		cxusb_ctrl_msg(adap->dev, CMD_STREAMING_ON, buf, 2, NULL, 0);
230
	else
231
		cxusb_ctrl_msg(adap->dev, CMD_STREAMING_OFF, NULL, 0, NULL, 0);
232

233 234 235
	return 0;
}

236 237 238
static int cxusb_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
{
	struct dvb_usb_rc_key *keymap = d->props.rc_key_map;
239
	u8 ircode[4];
240 241
	int i;

242
	cxusb_ctrl_msg(d, CMD_GET_IR_CODE, NULL, 0, ircode, 4);
243 244 245 246 247

	*event = 0;
	*state = REMOTE_NO_KEY_PRESSED;

	for (i = 0; i < d->props.rc_key_map_size; i++) {
248 249
		if (keymap[i].custom == ircode[2] &&
		    keymap[i].data == ircode[3]) {
250 251 252 253 254 255 256 257 258 259
			*event = keymap[i].event;
			*state = REMOTE_KEY_PRESSED;

			return 0;
		}
	}

	return 0;
}

260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287
static int cxusb_bluebird2_rc_query(struct dvb_usb_device *d, u32 *event,
				    int *state)
{
	struct dvb_usb_rc_key *keymap = d->props.rc_key_map;
	u8 ircode[4];
	int i;
	struct i2c_msg msg = { .addr = 0x6b, .flags = I2C_M_RD,
			       .buf = ircode, .len = 4 };

	*event = 0;
	*state = REMOTE_NO_KEY_PRESSED;

	if (cxusb_i2c_xfer(&d->i2c_adap, &msg, 1) != 1)
		return 0;

	for (i = 0; i < d->props.rc_key_map_size; i++) {
		if (keymap[i].custom == ircode[1] &&
		    keymap[i].data == ircode[2]) {
			*event = keymap[i].event;
			*state = REMOTE_KEY_PRESSED;

			return 0;
		}
	}

	return 0;
}

288
static struct dvb_usb_rc_key dvico_mce_rc_keys[] = {
289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335
	{ 0xfe, 0x02, KEY_TV },
	{ 0xfe, 0x0e, KEY_MP3 },
	{ 0xfe, 0x1a, KEY_DVD },
	{ 0xfe, 0x1e, KEY_FAVORITES },
	{ 0xfe, 0x16, KEY_SETUP },
	{ 0xfe, 0x46, KEY_POWER2 },
	{ 0xfe, 0x0a, KEY_EPG },
	{ 0xfe, 0x49, KEY_BACK },
	{ 0xfe, 0x4d, KEY_MENU },
	{ 0xfe, 0x51, KEY_UP },
	{ 0xfe, 0x5b, KEY_LEFT },
	{ 0xfe, 0x5f, KEY_RIGHT },
	{ 0xfe, 0x53, KEY_DOWN },
	{ 0xfe, 0x5e, KEY_OK },
	{ 0xfe, 0x59, KEY_INFO },
	{ 0xfe, 0x55, KEY_TAB },
	{ 0xfe, 0x0f, KEY_PREVIOUSSONG },/* Replay */
	{ 0xfe, 0x12, KEY_NEXTSONG },	/* Skip */
	{ 0xfe, 0x42, KEY_ENTER	 },	/* Windows/Start */
	{ 0xfe, 0x15, KEY_VOLUMEUP },
	{ 0xfe, 0x05, KEY_VOLUMEDOWN },
	{ 0xfe, 0x11, KEY_CHANNELUP },
	{ 0xfe, 0x09, KEY_CHANNELDOWN },
	{ 0xfe, 0x52, KEY_CAMERA },
	{ 0xfe, 0x5a, KEY_TUNER },	/* Live */
	{ 0xfe, 0x19, KEY_OPEN },
	{ 0xfe, 0x0b, KEY_1 },
	{ 0xfe, 0x17, KEY_2 },
	{ 0xfe, 0x1b, KEY_3 },
	{ 0xfe, 0x07, KEY_4 },
	{ 0xfe, 0x50, KEY_5 },
	{ 0xfe, 0x54, KEY_6 },
	{ 0xfe, 0x48, KEY_7 },
	{ 0xfe, 0x4c, KEY_8 },
	{ 0xfe, 0x58, KEY_9 },
	{ 0xfe, 0x13, KEY_ANGLE },	/* Aspect */
	{ 0xfe, 0x03, KEY_0 },
	{ 0xfe, 0x1f, KEY_ZOOM },
	{ 0xfe, 0x43, KEY_REWIND },
	{ 0xfe, 0x47, KEY_PLAYPAUSE },
	{ 0xfe, 0x4f, KEY_FASTFORWARD },
	{ 0xfe, 0x57, KEY_MUTE },
	{ 0xfe, 0x0d, KEY_STOP },
	{ 0xfe, 0x01, KEY_RECORD },
	{ 0xfe, 0x4e, KEY_POWER },
};

336 337 338 339 340 341 342 343 344 345 346 347 348
static struct dvb_usb_rc_key dvico_portable_rc_keys[] = {
	{ 0xfc, 0x02, KEY_SETUP },       /* Profile */
	{ 0xfc, 0x43, KEY_POWER2 },
	{ 0xfc, 0x06, KEY_EPG },
	{ 0xfc, 0x5a, KEY_BACK },
	{ 0xfc, 0x05, KEY_MENU },
	{ 0xfc, 0x47, KEY_INFO },
	{ 0xfc, 0x01, KEY_TAB },
	{ 0xfc, 0x42, KEY_PREVIOUSSONG },/* Replay */
	{ 0xfc, 0x49, KEY_VOLUMEUP },
	{ 0xfc, 0x09, KEY_VOLUMEDOWN },
	{ 0xfc, 0x54, KEY_CHANNELUP },
	{ 0xfc, 0x0b, KEY_CHANNELDOWN },
349
	{ 0xfc, 0x16, KEY_CAMERA },
350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374
	{ 0xfc, 0x40, KEY_TUNER },	/* ATV/DTV */
	{ 0xfc, 0x45, KEY_OPEN },
	{ 0xfc, 0x19, KEY_1 },
	{ 0xfc, 0x18, KEY_2 },
	{ 0xfc, 0x1b, KEY_3 },
	{ 0xfc, 0x1a, KEY_4 },
	{ 0xfc, 0x58, KEY_5 },
	{ 0xfc, 0x59, KEY_6 },
	{ 0xfc, 0x15, KEY_7 },
	{ 0xfc, 0x14, KEY_8 },
	{ 0xfc, 0x17, KEY_9 },
	{ 0xfc, 0x44, KEY_ANGLE },	/* Aspect */
	{ 0xfc, 0x55, KEY_0 },
	{ 0xfc, 0x07, KEY_ZOOM },
	{ 0xfc, 0x0a, KEY_REWIND },
	{ 0xfc, 0x08, KEY_PLAYPAUSE },
	{ 0xfc, 0x4b, KEY_FASTFORWARD },
	{ 0xfc, 0x5b, KEY_MUTE },
	{ 0xfc, 0x04, KEY_STOP },
	{ 0xfc, 0x56, KEY_RECORD },
	{ 0xfc, 0x57, KEY_POWER },
	{ 0xfc, 0x41, KEY_UNKNOWN },    /* INPUT */
	{ 0xfc, 0x00, KEY_UNKNOWN },    /* HD */
};

375 376
static int cxusb_dee1601_demod_init(struct dvb_frontend* fe)
{
377
	static u8 clock_config []  = { CLOCK_CTL,  0x38, 0x28 };
378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395
	static u8 reset []         = { RESET,      0x80 };
	static u8 adc_ctl_1_cfg [] = { ADC_CTL_1,  0x40 };
	static u8 agc_cfg []       = { AGC_TARGET, 0x28, 0x20 };
	static u8 gpp_ctl_cfg []   = { GPP_CTL,    0x33 };
	static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };

	mt352_write(fe, clock_config,   sizeof(clock_config));
	udelay(200);
	mt352_write(fe, reset,          sizeof(reset));
	mt352_write(fe, adc_ctl_1_cfg,  sizeof(adc_ctl_1_cfg));

	mt352_write(fe, agc_cfg,        sizeof(agc_cfg));
	mt352_write(fe, gpp_ctl_cfg,    sizeof(gpp_ctl_cfg));
	mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));

	return 0;
}

M
 
Michael Krufky 已提交
396 397
static int cxusb_mt352_demod_init(struct dvb_frontend* fe)
{	/* used in both lgz201 and th7579 */
398
	static u8 clock_config []  = { CLOCK_CTL,  0x38, 0x29 };
M
 
Michael Krufky 已提交
399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415
	static u8 reset []         = { RESET,      0x80 };
	static u8 adc_ctl_1_cfg [] = { ADC_CTL_1,  0x40 };
	static u8 agc_cfg []       = { AGC_TARGET, 0x24, 0x20 };
	static u8 gpp_ctl_cfg []   = { GPP_CTL,    0x33 };
	static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };

	mt352_write(fe, clock_config,   sizeof(clock_config));
	udelay(200);
	mt352_write(fe, reset,          sizeof(reset));
	mt352_write(fe, adc_ctl_1_cfg,  sizeof(adc_ctl_1_cfg));

	mt352_write(fe, agc_cfg,        sizeof(agc_cfg));
	mt352_write(fe, gpp_ctl_cfg,    sizeof(gpp_ctl_cfg));
	mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
	return 0;
}

416
static struct cx22702_config cxusb_cx22702_config = {
417
	.demod_address = 0x63,
418
	.output_mode = CX22702_PARALLEL_OUTPUT,
419 420
};

421
static struct lgdt330x_config cxusb_lgdt3303_config = {
422 423 424 425
	.demod_address = 0x0e,
	.demod_chip    = LGDT3303,
};

426
static struct mt352_config cxusb_dee1601_config = {
427 428 429 430
	.demod_address = 0x0f,
	.demod_init    = cxusb_dee1601_demod_init,
};

431 432
static struct zl10353_config cxusb_zl10353_dee1601_config = {
	.demod_address = 0x0f,
433
	.parallel_ts = 1,
434 435
};

436
static struct mt352_config cxusb_mt352_config = {
M
 
Michael Krufky 已提交
437 438 439 440 441
	/* used in both lgz201 and th7579 */
	.demod_address = 0x0f,
	.demod_init    = cxusb_mt352_demod_init,
};

442 443
static struct zl10353_config cxusb_zl10353_xc3028_config = {
	.demod_address = 0x0f,
444
	.if2 = 45600,
445 446 447 448
	.no_tuner = 1,
	.parallel_ts = 1,
};

449 450 451 452 453 454 455
static struct mt352_config cxusb_mt352_xc3028_config = {
	.demod_address = 0x0f,
	.if2 = 4560,
	.no_tuner = 1,
	.demod_init = cxusb_mt352_demod_init,
};

456
/* Callbacks for DVB USB */
457
static int cxusb_fmd1216me_tuner_attach(struct dvb_usb_adapter *adap)
458
{
459 460 461
	dvb_attach(simple_tuner_attach, adap->fe,
		   &adap->dev->i2c_adap, 0x61,
		   TUNER_PHILIPS_FMD1216ME_MK3);
462 463 464
	return 0;
}

465
static int cxusb_dee1601_tuner_attach(struct dvb_usb_adapter *adap)
466
{
467
	dvb_attach(dvb_pll_attach, adap->fe, 0x61,
468
		   NULL, DVB_PLL_THOMSON_DTT7579);
469 470 471
	return 0;
}

472
static int cxusb_lgz201_tuner_attach(struct dvb_usb_adapter *adap)
M
 
Michael Krufky 已提交
473
{
474
	dvb_attach(dvb_pll_attach, adap->fe, 0x61, NULL, DVB_PLL_LG_Z201);
M
 
Michael Krufky 已提交
475 476 477
	return 0;
}

478
static int cxusb_dtt7579_tuner_attach(struct dvb_usb_adapter *adap)
M
 
Michael Krufky 已提交
479
{
480
	dvb_attach(dvb_pll_attach, adap->fe, 0x60,
481
		   NULL, DVB_PLL_THOMSON_DTT7579);
482 483 484
	return 0;
}

485
static int cxusb_lgh064f_tuner_attach(struct dvb_usb_adapter *adap)
486
{
487 488
	dvb_attach(simple_tuner_attach, adap->fe,
		   &adap->dev->i2c_adap, 0x61, TUNER_LG_TDVS_H06XF);
M
 
Michael Krufky 已提交
489 490 491
	return 0;
}

492 493 494 495 496 497
static int dvico_bluebird_xc2028_callback(void *ptr, int command, int arg)
{
	struct dvb_usb_device *d = ptr;

	switch (command) {
	case XC2028_TUNER_RESET:
498
		deb_info("%s: XC2028_TUNER_RESET %d\n", __func__, arg);
499 500 501
		cxusb_bluebird_gpio_pulse(d, 0x01, 1);
		break;
	case XC2028_RESET_CLK:
502
		deb_info("%s: XC2028_RESET_CLK %d\n", __func__, arg);
503 504
		break;
	default:
505
		deb_info("%s: unknown command %d, arg %d\n", __func__,
506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535
			 command, arg);
		return -EINVAL;
	}

	return 0;
}

static int cxusb_dvico_xc3028_tuner_attach(struct dvb_usb_adapter *adap)
{
	struct dvb_frontend	 *fe;
	struct xc2028_config	  cfg = {
		.i2c_adap  = &adap->dev->i2c_adap,
		.i2c_addr  = 0x61,
		.callback  = dvico_bluebird_xc2028_callback,
	};
	static struct xc2028_ctrl ctl = {
		.fname       = "xc3028-dvico-au-01.fw",
		.max_len     = 64,
		.scode_table = ZARLINK456,
	};

	fe = dvb_attach(xc2028_attach, adap->fe, &cfg);
	if (fe == NULL || fe->ops.tuner_ops.set_config == NULL)
		return -EIO;

	fe->ops.tuner_ops.set_config(fe, &ctl);

	return 0;
}

536
static int cxusb_cx22702_frontend_attach(struct dvb_usb_adapter *adap)
537
{
538
	u8 b;
539
	if (usb_set_interface(adap->dev->udev, 0, 6) < 0)
540
		err("set interface failed");
541

542
	cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, &b, 1);
543

544 545
	if ((adap->fe = dvb_attach(cx22702_attach, &cxusb_cx22702_config,
				   &adap->dev->i2c_adap)) != NULL)
546 547 548 549 550
		return 0;

	return -EIO;
}

551
static int cxusb_lgdt3303_frontend_attach(struct dvb_usb_adapter *adap)
552
{
553
	if (usb_set_interface(adap->dev->udev, 0, 7) < 0)
554 555
		err("set interface failed");

556
	cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
557

558 559
	if ((adap->fe = dvb_attach(lgdt330x_attach, &cxusb_lgdt3303_config,
				   &adap->dev->i2c_adap)) != NULL)
560 561 562 563 564
		return 0;

	return -EIO;
}

565 566 567 568
static int cxusb_mt352_frontend_attach(struct dvb_usb_adapter *adap)
{
	/* used in both lgz201 and th7579 */
	if (usb_set_interface(adap->dev->udev, 0, 0) < 0)
M
 
Michael Krufky 已提交
569 570
		err("set interface failed");

571
	cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
M
 
Michael Krufky 已提交
572

573 574
	if ((adap->fe = dvb_attach(mt352_attach, &cxusb_mt352_config,
				   &adap->dev->i2c_adap)) != NULL)
M
 
Michael Krufky 已提交
575 576 577 578 579
		return 0;

	return -EIO;
}

580
static int cxusb_dee1601_frontend_attach(struct dvb_usb_adapter *adap)
581
{
582
	if (usb_set_interface(adap->dev->udev, 0, 0) < 0)
583 584
		err("set interface failed");

585
	cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
586

587 588 589 590 591
	if (((adap->fe = dvb_attach(mt352_attach, &cxusb_dee1601_config,
				    &adap->dev->i2c_adap)) != NULL) ||
		((adap->fe = dvb_attach(zl10353_attach,
					&cxusb_zl10353_dee1601_config,
					&adap->dev->i2c_adap)) != NULL))
592 593 594 595 596
		return 0;

	return -EIO;
}

597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636
static int cxusb_dualdig4_frontend_attach(struct dvb_usb_adapter *adap)
{
	u8 ircode[4];
	int i;
	struct i2c_msg msg = { .addr = 0x6b, .flags = I2C_M_RD,
			       .buf = ircode, .len = 4 };

	if (usb_set_interface(adap->dev->udev, 0, 1) < 0)
		err("set interface failed");

	cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);

	/* reset the tuner and demodulator */
	cxusb_bluebird_gpio_rw(adap->dev, 0x04, 0);
	cxusb_bluebird_gpio_pulse(adap->dev, 0x01, 1);
	cxusb_bluebird_gpio_pulse(adap->dev, 0x02, 1);

	if ((adap->fe = dvb_attach(zl10353_attach,
				   &cxusb_zl10353_xc3028_config,
				   &adap->dev->i2c_adap)) == NULL)
		return -EIO;

	/* try to determine if there is no IR decoder on the I2C bus */
	for (i = 0; adap->dev->props.rc_key_map != NULL && i < 5; i++) {
		msleep(20);
		if (cxusb_i2c_xfer(&adap->dev->i2c_adap, &msg, 1) != 1)
			goto no_IR;
		if (ircode[0] == 0 && ircode[1] == 0)
			continue;
		if (ircode[2] + ircode[3] != 0xff) {
no_IR:
			adap->dev->props.rc_key_map = NULL;
			info("No IR receiver detected on this device.");
			break;
		}
	}

	return 0;
}

637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653
static int cxusb_nano2_frontend_attach(struct dvb_usb_adapter *adap)
{
	if (usb_set_interface(adap->dev->udev, 0, 1) < 0)
		err("set interface failed");

	cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);

	/* reset the tuner and demodulator */
	cxusb_bluebird_gpio_rw(adap->dev, 0x04, 0);
	cxusb_bluebird_gpio_pulse(adap->dev, 0x01, 1);
	cxusb_bluebird_gpio_pulse(adap->dev, 0x02, 1);

	if ((adap->fe = dvb_attach(zl10353_attach,
				   &cxusb_zl10353_xc3028_config,
				   &adap->dev->i2c_adap)) != NULL)
		return 0;

654 655 656 657 658
	if ((adap->fe = dvb_attach(mt352_attach,
				   &cxusb_mt352_xc3028_config,
				   &adap->dev->i2c_adap)) != NULL)
		return 0;

659 660 661
	return -EIO;
}

662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684
/*
 * DViCO has shipped two devices with the same USB ID, but only one of them
 * needs a firmware download.  Check the device class details to see if they
 * have non-default values to decide whether the device is actually cold or
 * not, and forget a match if it turns out we selected the wrong device.
 */
static int bluebird_fx2_identify_state(struct usb_device *udev,
				       struct dvb_usb_device_properties *props,
				       struct dvb_usb_device_description **desc,
				       int *cold)
{
	int wascold = *cold;

	*cold = udev->descriptor.bDeviceClass == 0xff &&
		udev->descriptor.bDeviceSubClass == 0xff &&
		udev->descriptor.bDeviceProtocol == 0xff;

	if (*cold && !wascold)
		*desc = NULL;

	return 0;
}

685 686 687 688 689
/*
 * DViCO bluebird firmware needs the "warm" product ID to be patched into the
 * firmware file before download.
 */

690
static const int dvico_firmware_id_offsets[] = { 6638, 3204 };
691 692
static int bluebird_patch_dvico_firmware_download(struct usb_device *udev,
						  const struct firmware *fw)
693
{
694 695 696 697
	int pos;

	for (pos = 0; pos < ARRAY_SIZE(dvico_firmware_id_offsets); pos++) {
		int idoff = dvico_firmware_id_offsets[pos];
698

699 700
		if (fw->size < idoff + 4)
			continue;
701

702 703 704 705 706 707
		if (fw->data[idoff] == (USB_VID_DVICO & 0xff) &&
		    fw->data[idoff + 1] == USB_VID_DVICO >> 8) {
			fw->data[idoff + 2] =
				le16_to_cpu(udev->descriptor.idProduct) + 1;
			fw->data[idoff + 3] =
				le16_to_cpu(udev->descriptor.idProduct) >> 8;
708

709 710
			return usb_cypress_load_firmware(udev, fw, CYPRESS_FX2);
		}
711 712 713 714 715
	}

	return -EINVAL;
}

716
/* DVB USB Driver stuff */
717 718 719 720 721
static struct dvb_usb_device_properties cxusb_medion_properties;
static struct dvb_usb_device_properties cxusb_bluebird_lgh064f_properties;
static struct dvb_usb_device_properties cxusb_bluebird_dee1601_properties;
static struct dvb_usb_device_properties cxusb_bluebird_lgz201_properties;
static struct dvb_usb_device_properties cxusb_bluebird_dtt7579_properties;
722
static struct dvb_usb_device_properties cxusb_bluebird_dualdig4_properties;
723
static struct dvb_usb_device_properties cxusb_bluebird_nano2_properties;
724
static struct dvb_usb_device_properties cxusb_bluebird_nano2_needsfirmware_properties;
725 726

static int cxusb_probe(struct usb_interface *intf,
727
		       const struct usb_device_id *id)
728
{
729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745
	if (0 == dvb_usb_device_init(intf, &cxusb_medion_properties,
				     THIS_MODULE, NULL, adapter_nr) ||
	    0 == dvb_usb_device_init(intf, &cxusb_bluebird_lgh064f_properties,
				     THIS_MODULE, NULL, adapter_nr) ||
	    0 == dvb_usb_device_init(intf, &cxusb_bluebird_dee1601_properties,
				     THIS_MODULE, NULL, adapter_nr) ||
	    0 == dvb_usb_device_init(intf, &cxusb_bluebird_lgz201_properties,
				     THIS_MODULE, NULL, adapter_nr) ||
	    0 == dvb_usb_device_init(intf, &cxusb_bluebird_dtt7579_properties,
				     THIS_MODULE, NULL, adapter_nr) ||
	    0 == dvb_usb_device_init(intf, &cxusb_bluebird_dualdig4_properties,
				     THIS_MODULE, NULL, adapter_nr) ||
	    0 == dvb_usb_device_init(intf, &cxusb_bluebird_nano2_properties,
				     THIS_MODULE, NULL, adapter_nr) ||
	    0 == dvb_usb_device_init(intf,
				&cxusb_bluebird_nano2_needsfirmware_properties,
				     THIS_MODULE, NULL, adapter_nr))
746 747 748
		return 0;

	return -EINVAL;
749 750 751
}

static struct usb_device_id cxusb_table [] = {
752 753 754 755 756 757 758 759 760 761 762 763 764
	{ USB_DEVICE(USB_VID_MEDION, USB_PID_MEDION_MD95700) },
	{ USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LG064F_COLD) },
	{ USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LG064F_WARM) },
	{ USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_1_COLD) },
	{ USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_1_WARM) },
	{ USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LGZ201_COLD) },
	{ USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LGZ201_WARM) },
	{ USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_TH7579_COLD) },
	{ USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_TH7579_WARM) },
	{ USB_DEVICE(USB_VID_DVICO, USB_PID_DIGITALNOW_BLUEBIRD_DUAL_1_COLD) },
	{ USB_DEVICE(USB_VID_DVICO, USB_PID_DIGITALNOW_BLUEBIRD_DUAL_1_WARM) },
	{ USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_2_COLD) },
	{ USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_2_WARM) },
765
	{ USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_4) },
766
	{ USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DVB_T_NANO_2) },
767
	{ USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DVB_T_NANO_2_NFW_WARM) },
768
	{}		/* Terminating entry */
769 770 771
};
MODULE_DEVICE_TABLE (usb, cxusb_table);

772
static struct dvb_usb_device_properties cxusb_medion_properties = {
773 774 775 776 777 778
	.caps = DVB_USB_IS_AN_I2C_ADAPTER,

	.usb_ctrl = CYPRESS_FX2,

	.size_of_priv     = sizeof(struct cxusb_state),

779 780 781
	.num_adapters = 1,
	.adapter = {
		{
782 783 784 785 786 787 788 789 790 791 792 793 794 795
			.streaming_ctrl   = cxusb_streaming_ctrl,
			.frontend_attach  = cxusb_cx22702_frontend_attach,
			.tuner_attach     = cxusb_fmd1216me_tuner_attach,
			/* parameter for the MPEG2-data transfer */
					.stream = {
						.type = USB_BULK,
				.count = 5,
				.endpoint = 0x02,
				.u = {
					.bulk = {
						.buffersize = 8192,
					}
				}
			},
796

797 798 799 800 801 802 803 804
		},
	},
	.power_ctrl       = cxusb_power_ctrl,

	.i2c_algo         = &cxusb_i2c_algo,

	.generic_bulk_ctrl_endpoint = 0x01,

805 806 807 808 809 810 811 812 813
	.num_device_descs = 1,
	.devices = {
		{   "Medion MD95700 (MDUSBTV-HYBRID)",
			{ NULL },
			{ &cxusb_table[0], NULL },
		},
	}
};

814
static struct dvb_usb_device_properties cxusb_bluebird_lgh064f_properties = {
815 816
	.caps = DVB_USB_IS_AN_I2C_ADAPTER,

817 818 819
	.usb_ctrl          = DEVICE_SPECIFIC,
	.firmware          = "dvb-usb-bluebird-01.fw",
	.download_firmware = bluebird_patch_dvico_firmware_download,
820 821
	/* use usb alt setting 0 for EP4 transfer (dvb-t),
	   use usb alt setting 7 for EP2 transfer (atsc) */
822 823 824

	.size_of_priv     = sizeof(struct cxusb_state),

825 826 827
	.num_adapters = 1,
	.adapter = {
		{
828 829
			.streaming_ctrl   = cxusb_streaming_ctrl,
			.frontend_attach  = cxusb_lgdt3303_frontend_attach,
830
			.tuner_attach     = cxusb_lgh064f_tuner_attach,
831 832 833 834 835 836 837 838 839 840 841 842

			/* parameter for the MPEG2-data transfer */
					.stream = {
						.type = USB_BULK,
				.count = 5,
				.endpoint = 0x02,
				.u = {
					.bulk = {
						.buffersize = 8192,
					}
				}
			},
843 844 845 846 847 848 849 850 851 852 853 854 855
		},
	},

	.power_ctrl       = cxusb_bluebird_power_ctrl,

	.i2c_algo         = &cxusb_i2c_algo,

	.rc_interval      = 100,
	.rc_key_map       = dvico_portable_rc_keys,
	.rc_key_map_size  = ARRAY_SIZE(dvico_portable_rc_keys),
	.rc_query         = cxusb_rc_query,

	.generic_bulk_ctrl_endpoint = 0x01,
856 857 858 859 860 861 862 863 864 865

	.num_device_descs = 1,
	.devices = {
		{   "DViCO FusionHDTV5 USB Gold",
			{ &cxusb_table[1], NULL },
			{ &cxusb_table[2], NULL },
		},
	}
};

866
static struct dvb_usb_device_properties cxusb_bluebird_dee1601_properties = {
867 868
	.caps = DVB_USB_IS_AN_I2C_ADAPTER,

869 870 871
	.usb_ctrl          = DEVICE_SPECIFIC,
	.firmware          = "dvb-usb-bluebird-01.fw",
	.download_firmware = bluebird_patch_dvico_firmware_download,
872 873 874 875 876
	/* use usb alt setting 0 for EP4 transfer (dvb-t),
	   use usb alt setting 7 for EP2 transfer (atsc) */

	.size_of_priv     = sizeof(struct cxusb_state),

877 878 879
	.num_adapters = 1,
	.adapter = {
		{
880 881 882 883
			.streaming_ctrl   = cxusb_streaming_ctrl,
			.frontend_attach  = cxusb_dee1601_frontend_attach,
			.tuner_attach     = cxusb_dee1601_tuner_attach,
			/* parameter for the MPEG2-data transfer */
884 885
			.stream = {
				.type = USB_BULK,
886 887 888 889 890 891 892 893
				.count = 5,
				.endpoint = 0x04,
				.u = {
					.bulk = {
						.buffersize = 8192,
					}
				}
			},
894 895 896 897 898 899 900 901 902 903 904 905 906
		},
	},

	.power_ctrl       = cxusb_bluebird_power_ctrl,

	.i2c_algo         = &cxusb_i2c_algo,

	.rc_interval      = 150,
	.rc_key_map       = dvico_mce_rc_keys,
	.rc_key_map_size  = ARRAY_SIZE(dvico_mce_rc_keys),
	.rc_query         = cxusb_rc_query,

	.generic_bulk_ctrl_endpoint = 0x01,
907

908
	.num_device_descs = 3,
909 910 911 912 913
	.devices = {
		{   "DViCO FusionHDTV DVB-T Dual USB",
			{ &cxusb_table[3], NULL },
			{ &cxusb_table[4], NULL },
		},
914 915 916 917
		{   "DigitalNow DVB-T Dual USB",
			{ &cxusb_table[9],  NULL },
			{ &cxusb_table[10], NULL },
		},
918 919 920 921
		{   "DViCO FusionHDTV DVB-T Dual Digital 2",
			{ &cxusb_table[11], NULL },
			{ &cxusb_table[12], NULL },
		},
922 923 924
	}
};

925
static struct dvb_usb_device_properties cxusb_bluebird_lgz201_properties = {
M
 
Michael Krufky 已提交
926 927 928 929 930 931 932 933 934 935
	.caps = DVB_USB_IS_AN_I2C_ADAPTER,

	.usb_ctrl          = DEVICE_SPECIFIC,
	.firmware          = "dvb-usb-bluebird-01.fw",
	.download_firmware = bluebird_patch_dvico_firmware_download,
	/* use usb alt setting 0 for EP4 transfer (dvb-t),
	   use usb alt setting 7 for EP2 transfer (atsc) */

	.size_of_priv     = sizeof(struct cxusb_state),

936 937 938
	.num_adapters = 2,
	.adapter = {
		{
939 940 941
			.streaming_ctrl   = cxusb_streaming_ctrl,
			.frontend_attach  = cxusb_mt352_frontend_attach,
			.tuner_attach     = cxusb_lgz201_tuner_attach,
M
 
Michael Krufky 已提交
942

943
			/* parameter for the MPEG2-data transfer */
944 945
			.stream = {
				.type = USB_BULK,
946 947 948 949 950 951 952 953
				.count = 5,
				.endpoint = 0x04,
				.u = {
					.bulk = {
						.buffersize = 8192,
					}
				}
			},
954 955 956 957 958
		},
	},
	.power_ctrl       = cxusb_bluebird_power_ctrl,

	.i2c_algo         = &cxusb_i2c_algo,
M
 
Michael Krufky 已提交
959

960 961 962 963 964 965
	.rc_interval      = 100,
	.rc_key_map       = dvico_portable_rc_keys,
	.rc_key_map_size  = ARRAY_SIZE(dvico_portable_rc_keys),
	.rc_query         = cxusb_rc_query,

	.generic_bulk_ctrl_endpoint = 0x01,
M
 
Michael Krufky 已提交
966 967 968 969 970 971 972 973 974
	.num_device_descs = 1,
	.devices = {
		{   "DViCO FusionHDTV DVB-T USB (LGZ201)",
			{ &cxusb_table[5], NULL },
			{ &cxusb_table[6], NULL },
		},
	}
};

975
static struct dvb_usb_device_properties cxusb_bluebird_dtt7579_properties = {
M
 
Michael Krufky 已提交
976 977 978 979 980 981 982 983 984 985
	.caps = DVB_USB_IS_AN_I2C_ADAPTER,

	.usb_ctrl          = DEVICE_SPECIFIC,
	.firmware          = "dvb-usb-bluebird-01.fw",
	.download_firmware = bluebird_patch_dvico_firmware_download,
	/* use usb alt setting 0 for EP4 transfer (dvb-t),
	   use usb alt setting 7 for EP2 transfer (atsc) */

	.size_of_priv     = sizeof(struct cxusb_state),

986 987 988
	.num_adapters = 1,
	.adapter = {
		{
989 990 991
			.streaming_ctrl   = cxusb_streaming_ctrl,
			.frontend_attach  = cxusb_mt352_frontend_attach,
			.tuner_attach     = cxusb_dtt7579_tuner_attach,
M
 
Michael Krufky 已提交
992

993
			/* parameter for the MPEG2-data transfer */
994 995
			.stream = {
				.type = USB_BULK,
996 997 998 999 1000 1001 1002 1003
				.count = 5,
				.endpoint = 0x04,
				.u = {
					.bulk = {
						.buffersize = 8192,
					}
				}
			},
1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015
		},
	},
	.power_ctrl       = cxusb_bluebird_power_ctrl,

	.i2c_algo         = &cxusb_i2c_algo,

	.rc_interval      = 100,
	.rc_key_map       = dvico_portable_rc_keys,
	.rc_key_map_size  = ARRAY_SIZE(dvico_portable_rc_keys),
	.rc_query         = cxusb_rc_query,

	.generic_bulk_ctrl_endpoint = 0x01,
M
 
Michael Krufky 已提交
1016 1017 1018 1019 1020 1021 1022 1023 1024 1025

	.num_device_descs = 1,
	.devices = {
		{   "DViCO FusionHDTV DVB-T USB (TH7579)",
			{ &cxusb_table[7], NULL },
			{ &cxusb_table[8], NULL },
		},
	}
};

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
static struct dvb_usb_device_properties cxusb_bluebird_dualdig4_properties = {
	.caps = DVB_USB_IS_AN_I2C_ADAPTER,

	.usb_ctrl         = CYPRESS_FX2,

	.size_of_priv     = sizeof(struct cxusb_state),

	.num_adapters = 1,
	.adapter = {
		{
			.streaming_ctrl   = cxusb_streaming_ctrl,
			.frontend_attach  = cxusb_dualdig4_frontend_attach,
			.tuner_attach     = cxusb_dvico_xc3028_tuner_attach,
			/* parameter for the MPEG2-data transfer */
			.stream = {
				.type = USB_BULK,
				.count = 5,
				.endpoint = 0x02,
				.u = {
					.bulk = {
						.buffersize = 8192,
					}
				}
			},
		},
	},

	.power_ctrl       = cxusb_power_ctrl,

	.i2c_algo         = &cxusb_i2c_algo,

	.generic_bulk_ctrl_endpoint = 0x01,

	.rc_interval      = 100,
	.rc_key_map       = dvico_mce_rc_keys,
	.rc_key_map_size  = ARRAY_SIZE(dvico_mce_rc_keys),
	.rc_query         = cxusb_bluebird2_rc_query,

	.num_device_descs = 1,
	.devices = {
		{   "DViCO FusionHDTV DVB-T Dual Digital 4",
			{ NULL },
			{ &cxusb_table[13], NULL },
		},
	}
};

1073 1074 1075 1076
static struct dvb_usb_device_properties cxusb_bluebird_nano2_properties = {
	.caps = DVB_USB_IS_AN_I2C_ADAPTER,

	.usb_ctrl         = CYPRESS_FX2,
1077
	.identify_state   = bluebird_fx2_identify_state,
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

	.size_of_priv     = sizeof(struct cxusb_state),

	.num_adapters = 1,
	.adapter = {
		{
			.streaming_ctrl   = cxusb_streaming_ctrl,
			.frontend_attach  = cxusb_nano2_frontend_attach,
			.tuner_attach     = cxusb_dvico_xc3028_tuner_attach,
			/* parameter for the MPEG2-data transfer */
			.stream = {
				.type = USB_BULK,
				.count = 5,
				.endpoint = 0x02,
				.u = {
					.bulk = {
						.buffersize = 8192,
					}
				}
			},
		},
	},

	.power_ctrl       = cxusb_nano2_power_ctrl,

	.i2c_algo         = &cxusb_i2c_algo,

	.generic_bulk_ctrl_endpoint = 0x01,

	.rc_interval      = 100,
	.rc_key_map       = dvico_portable_rc_keys,
	.rc_key_map_size  = ARRAY_SIZE(dvico_portable_rc_keys),
	.rc_query         = cxusb_bluebird2_rc_query,

	.num_device_descs = 1,
	.devices = {
		{   "DViCO FusionHDTV DVB-T NANO2",
			{ NULL },
			{ &cxusb_table[14], NULL },
		},
	}
};

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 1162 1163 1164 1165 1166 1167 1168 1169 1170
static struct dvb_usb_device_properties cxusb_bluebird_nano2_needsfirmware_properties = {
	.caps = DVB_USB_IS_AN_I2C_ADAPTER,

	.usb_ctrl          = DEVICE_SPECIFIC,
	.firmware          = "dvb-usb-bluebird-02.fw",
	.download_firmware = bluebird_patch_dvico_firmware_download,
	.identify_state    = bluebird_fx2_identify_state,

	.size_of_priv      = sizeof(struct cxusb_state),

	.num_adapters = 1,
	.adapter = {
		{
			.streaming_ctrl   = cxusb_streaming_ctrl,
			.frontend_attach  = cxusb_nano2_frontend_attach,
			.tuner_attach     = cxusb_dvico_xc3028_tuner_attach,
			/* parameter for the MPEG2-data transfer */
			.stream = {
				.type = USB_BULK,
				.count = 5,
				.endpoint = 0x02,
				.u = {
					.bulk = {
						.buffersize = 8192,
					}
				}
			},
		},
	},

	.power_ctrl       = cxusb_nano2_power_ctrl,

	.i2c_algo         = &cxusb_i2c_algo,

	.generic_bulk_ctrl_endpoint = 0x01,

	.rc_interval      = 100,
	.rc_key_map       = dvico_portable_rc_keys,
	.rc_key_map_size  = ARRAY_SIZE(dvico_portable_rc_keys),
	.rc_query         = cxusb_rc_query,

	.num_device_descs = 1,
	.devices = {
		{   "DViCO FusionHDTV DVB-T NANO2 w/o firmware",
			{ &cxusb_table[14], NULL },
			{ &cxusb_table[15], NULL },
		},
	}
};

1171
static struct usb_driver cxusb_driver = {
1172
	.name		= "dvb_usb_cxusb",
1173
	.probe		= cxusb_probe,
1174
	.disconnect     = dvb_usb_device_exit,
1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199
	.id_table	= cxusb_table,
};

/* module stuff */
static int __init cxusb_module_init(void)
{
	int result;
	if ((result = usb_register(&cxusb_driver))) {
		err("usb_register failed. Error number %d",result);
		return result;
	}

	return 0;
}

static void __exit cxusb_module_exit(void)
{
	/* deregister this driver from the USB subsystem */
	usb_deregister(&cxusb_driver);
}

module_init (cxusb_module_init);
module_exit (cxusb_module_exit);

MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>");
1200
MODULE_AUTHOR("Michael Krufky <mkrufky@linuxtv.org>");
1201
MODULE_AUTHOR("Chris Pascoe <c.pascoe@itee.uq.edu.au>");
1202 1203 1204
MODULE_DESCRIPTION("Driver for Conexant USB2.0 hybrid reference design");
MODULE_VERSION("1.0-alpha");
MODULE_LICENSE("GPL");