cxusb.c 21.2 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) 2005 Michael Krufky (mkrufky@m1k.net)
18
 * Copyright (C) 2006 Chris Pascoe (c.pascoe@itee.uq.edu.au)
19 20 21 22 23 24 25 26 27 28
 *
 *	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.
 *
 * see Documentation/dvb/README.dvb-usb for more information
 */
#include "cxusb.h"

#include "cx22702.h"
29
#include "lgdt330x.h"
30
#include "lg_h06xf.h"
31 32
#include "mt352.h"
#include "mt352_priv.h"
33
#include "zl10353.h"
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56

/* debug */
int dvb_usb_cxusb_debug;
module_param_named(debug,dvb_usb_cxusb_debug, int, 0644);
MODULE_PARM_DESC(debug, "set debugging level (1=rc (or-able))." DVB_USB_DEBUG_STATUS);

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

	sndbuf[0] = cmd;
	memcpy(&sndbuf[1],wbuf,wlen);
	if (wo)
		dvb_usb_generic_write(d,sndbuf,1+wlen);
	else
		dvb_usb_generic_rw(d,sndbuf,1+wlen,rbuf,rlen,0);

	return 0;
}

57 58
/* GPIO */
static void cxusb_gpio_tuner(struct dvb_usb_device *d, int onoff)
59 60 61 62
{
	struct cxusb_state *st = d->priv;
	u8 o[2],i;

63
	if (st->gpio_write_state[GPIO_TUNER] == onoff)
64 65
		return;

66 67 68
	o[0] = GPIO_TUNER;
	o[1] = onoff;
	cxusb_ctrl_msg(d,CMD_GPIO_WRITE,o,2,&i,1);
69 70

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

73
	st->gpio_write_state[GPIO_TUNER] = onoff;
74 75
}

76
/* I2C */
77 78 79 80 81
static int cxusb_i2c_xfer(struct i2c_adapter *adap,struct i2c_msg msg[],int num)
{
	struct dvb_usb_device *d = i2c_get_adapdata(adap);
	int i;

82
	if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
83 84 85
		return -EAGAIN;

	if (num > 2)
86
		warn("more than two i2c messages at a time is not handled yet. TODO.");
87 88 89

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

90 91 92 93 94 95 96 97 98
		if (d->udev->descriptor.idVendor == USB_VID_MEDION)
			switch (msg[i].addr) {
				case 0x63:
					cxusb_gpio_tuner(d,0);
					break;
				default:
					cxusb_gpio_tuner(d,1);
					break;
			}
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113

		/* read request */
		if (i+1 < num && (msg[i+1].flags & I2C_M_RD)) {
			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;
			memcpy(&obuf[3],msg[i].buf,msg[i].len);

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

			if (ibuf[0] != 0x08)
114
				deb_i2c("i2c read may have failed\n");
115 116 117 118 119 120 121 122 123 124 125 126 127

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

			i++;
		} else { /* write */
			u8 obuf[2+msg[i].len], ibuf;
			obuf[0] = msg[i].addr;
			obuf[1] = msg[i].len;
			memcpy(&obuf[2],msg[i].buf,msg[i].len);

			if (cxusb_ctrl_msg(d,CMD_I2C_WRITE, obuf, 2+msg[i].len, &ibuf,1) < 0)
				break;
			if (ibuf != 0x08)
128
				deb_i2c("i2c write may have failed\n");
129 130 131
		}
	}

132
	mutex_unlock(&d->i2c_mutex);
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
	return i;
}

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)
{
148 149 150 151 152
	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);
153 154
}

155 156 157 158 159 160 161 162 163
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;
}

164
static int cxusb_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
165
{
166 167
	u8 buf[2] = { 0x03, 0x00 };
	if (onoff)
168
		cxusb_ctrl_msg(adap->dev, CMD_STREAMING_ON, buf, 2, NULL, 0);
169
	else
170
		cxusb_ctrl_msg(adap->dev, CMD_STREAMING_OFF, NULL, 0, NULL, 0);
171

172 173 174
	return 0;
}

175 176 177
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;
178
	u8 ircode[4];
179 180
	int i;

181
	cxusb_ctrl_msg(d, CMD_GET_IR_CODE, NULL, 0, ircode, 4);
182 183 184 185 186

	*event = 0;
	*state = REMOTE_NO_KEY_PRESSED;

	for (i = 0; i < d->props.rc_key_map_size; i++) {
187 188
		if (keymap[i].custom == ircode[2] &&
		    keymap[i].data == ircode[3]) {
189 190 191 192 193 194 195 196 197 198
			*event = keymap[i].event;
			*state = REMOTE_KEY_PRESSED;

			return 0;
		}
	}

	return 0;
}

199
static struct dvb_usb_rc_key dvico_mce_rc_keys[] = {
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246
	{ 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 },
};

247 248 249 250 251 252 253 254 255 256 257 258 259
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 },
260
	{ 0xfc, 0x16, KEY_CAMERA },
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
	{ 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 */
};

286 287
static int cxusb_dee1601_demod_init(struct dvb_frontend* fe)
{
288
	static u8 clock_config []  = { CLOCK_CTL,  0x38, 0x28 };
289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306
	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 已提交
307 308
static int cxusb_mt352_demod_init(struct dvb_frontend* fe)
{	/* used in both lgz201 and th7579 */
309
	static u8 clock_config []  = { CLOCK_CTL,  0x38, 0x29 };
M
 
Michael Krufky 已提交
310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326
	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;
}

327 328
static int cxusb_lgh064f_tuner_set_params(struct dvb_frontend *fe,
					  struct dvb_frontend_parameters *fep)
329
{
330 331
	struct dvb_usb_adapter *adap = fe->dvb->priv;
	return lg_h06xf_pll_set(fe, &adap->dev->i2c_adap, fep);
332 333
}

334
static struct cx22702_config cxusb_cx22702_config = {
335 336
	.demod_address = 0x63,

337
	.output_mode = CX22702_PARALLEL_OUTPUT,
338 339
};

340
static struct lgdt330x_config cxusb_lgdt3303_config = {
341 342 343 344
	.demod_address = 0x0e,
	.demod_chip    = LGDT3303,
};

345
static struct mt352_config cxusb_dee1601_config = {
346 347 348 349
	.demod_address = 0x0f,
	.demod_init    = cxusb_dee1601_demod_init,
};

350 351
static struct zl10353_config cxusb_zl10353_dee1601_config = {
	.demod_address = 0x0f,
352
	.parallel_ts = 1,
353 354
};

355
static struct mt352_config cxusb_mt352_config = {
M
 
Michael Krufky 已提交
356 357 358 359 360
	/* used in both lgz201 and th7579 */
	.demod_address = 0x0f,
	.demod_init    = cxusb_mt352_demod_init,
};

361
/* Callbacks for DVB USB */
362
static int cxusb_fmd1216me_tuner_attach(struct dvb_usb_adapter *adap)
363 364
{
	u8 bpll[4] = { 0x0b, 0xdc, 0x9c, 0xa0 };
365 366 367
	adap->pll_addr = 0x61;
	memcpy(adap->pll_init, bpll, 4);
	adap->pll_desc = &dvb_pll_fmd1216me;
368

369 370
	adap->fe->ops.tuner_ops.init = dvb_usb_tuner_init_i2c;
	adap->fe->ops.tuner_ops.set_params = dvb_usb_tuner_set_params_i2c;
371

372 373 374
	return 0;
}

375
static int cxusb_dee1601_tuner_attach(struct dvb_usb_adapter *adap)
376
{
377 378 379
	adap->pll_addr = 0x61;
	adap->pll_desc = &dvb_pll_thomson_dtt7579;
	adap->fe->ops.tuner_ops.calc_regs = dvb_usb_tuner_calc_regs;
380 381 382
	return 0;
}

383
static int cxusb_lgz201_tuner_attach(struct dvb_usb_adapter *adap)
M
 
Michael Krufky 已提交
384
{
385 386 387
	adap->pll_addr = 0x61;
	adap->pll_desc = &dvb_pll_lg_z201;
	adap->fe->ops.tuner_ops.calc_regs = dvb_usb_tuner_calc_regs;
M
 
Michael Krufky 已提交
388 389 390
	return 0;
}

391
static int cxusb_dtt7579_tuner_attach(struct dvb_usb_adapter *adap)
M
 
Michael Krufky 已提交
392
{
393 394 395
	adap->pll_addr = 0x60;
	adap->pll_desc = &dvb_pll_thomson_dtt7579;
	adap->fe->ops.tuner_ops.calc_regs = dvb_usb_tuner_calc_regs;
396 397 398
	return 0;
}

399
static int cxusb_lgdt3303_tuner_attach(struct dvb_usb_adapter *adap)
400
{
401
	adap->fe->ops.tuner_ops.set_params = cxusb_lgh064f_tuner_set_params;
M
 
Michael Krufky 已提交
402 403 404
	return 0;
}

405
static int cxusb_cx22702_frontend_attach(struct dvb_usb_adapter *adap)
406
{
407
	u8 b;
408
	if (usb_set_interface(adap->dev->udev, 0, 6) < 0)
409
		err("set interface failed");
410

411
	cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, &b, 1);
412

413
	if ((adap->fe = dvb_attach(cx22702_attach, &cxusb_cx22702_config, &adap->dev->i2c_adap)) != NULL)
414 415 416 417 418
		return 0;

	return -EIO;
}

419
static int cxusb_lgdt3303_frontend_attach(struct dvb_usb_adapter *adap)
420
{
421
	if (usb_set_interface(adap->dev->udev, 0, 7) < 0)
422 423
		err("set interface failed");

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

426
	if ((adap->fe = dvb_attach(lgdt330x_attach, &cxusb_lgdt3303_config, &adap->dev->i2c_adap)) != NULL)
427 428 429 430 431
		return 0;

	return -EIO;
}

432 433 434 435
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 已提交
436 437
		err("set interface failed");

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

440
	if ((adap->fe = dvb_attach(mt352_attach, &cxusb_mt352_config, &adap->dev->i2c_adap)) != NULL)
M
 
Michael Krufky 已提交
441 442 443 444 445
		return 0;

	return -EIO;
}

446
static int cxusb_dee1601_frontend_attach(struct dvb_usb_adapter *adap)
447
{
448
	if (usb_set_interface(adap->dev->udev, 0, 0) < 0)
449 450
		err("set interface failed");

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

453 454
	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))
455 456 457 458 459
		return 0;

	return -EIO;
}

460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482
/*
 * DViCO bluebird firmware needs the "warm" product ID to be patched into the
 * firmware file before download.
 */

#define BLUEBIRD_01_ID_OFFSET 6638
static int bluebird_patch_dvico_firmware_download(struct usb_device *udev, const struct firmware *fw)
{
	if (fw->size < BLUEBIRD_01_ID_OFFSET + 4)
		return -EINVAL;

	if (fw->data[BLUEBIRD_01_ID_OFFSET] == (USB_VID_DVICO & 0xff) &&
	    fw->data[BLUEBIRD_01_ID_OFFSET + 1] == USB_VID_DVICO >> 8) {

		fw->data[BLUEBIRD_01_ID_OFFSET + 2] = udev->descriptor.idProduct + 1;
		fw->data[BLUEBIRD_01_ID_OFFSET + 3] = udev->descriptor.idProduct >> 8;

		return usb_cypress_load_firmware(udev,fw,CYPRESS_FX2);
	}

	return -EINVAL;
}

483
/* DVB USB Driver stuff */
484 485 486 487 488
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;
489 490 491 492

static int cxusb_probe(struct usb_interface *intf,
		const struct usb_device_id *id)
{
493
	if (dvb_usb_device_init(intf,&cxusb_medion_properties,THIS_MODULE,NULL) == 0 ||
494
		dvb_usb_device_init(intf,&cxusb_bluebird_lgh064f_properties,THIS_MODULE,NULL) == 0 ||
M
 
Michael Krufky 已提交
495 496 497
		dvb_usb_device_init(intf,&cxusb_bluebird_dee1601_properties,THIS_MODULE,NULL) == 0 ||
		dvb_usb_device_init(intf,&cxusb_bluebird_lgz201_properties,THIS_MODULE,NULL) == 0 ||
		dvb_usb_device_init(intf,&cxusb_bluebird_dtt7579_properties,THIS_MODULE,NULL) == 0) {
498 499 500 501
		return 0;
	}

	return -EINVAL;
502 503 504 505
}

static struct usb_device_id cxusb_table [] = {
		{ USB_DEVICE(USB_VID_MEDION, USB_PID_MEDION_MD95700) },
506 507
		{ USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LG064F_COLD) },
		{ USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LG064F_WARM) },
508 509
		{ USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DEE1601_COLD) },
		{ USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DEE1601_WARM) },
M
 
Michael Krufky 已提交
510 511 512 513
		{ 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) },
514 515
		{ USB_DEVICE(USB_VID_DVICO, USB_PID_DIGITALNOW_BLUEBIRD_DEE1601_COLD) },
		{ USB_DEVICE(USB_VID_DVICO, USB_PID_DIGITALNOW_BLUEBIRD_DEE1601_WARM) },
516 517 518 519
		{}		/* Terminating entry */
};
MODULE_DEVICE_TABLE (usb, cxusb_table);

520
static struct dvb_usb_device_properties cxusb_medion_properties = {
521 522 523 524 525 526
	.caps = DVB_USB_IS_AN_I2C_ADAPTER,

	.usb_ctrl = CYPRESS_FX2,

	.size_of_priv     = sizeof(struct cxusb_state),

527 528 529
	.num_adapters = 1,
	.adapter = {
		{
530
	.streaming_ctrl   = cxusb_streaming_ctrl,
531 532
	.frontend_attach  = cxusb_cx22702_frontend_attach,
	.tuner_attach     = cxusb_fmd1216me_tuner_attach,
533
	/* parameter for the MPEG2-data transfer */
534 535
			.stream = {
				.type = USB_BULK,
536 537 538
		.count = 5,
		.endpoint = 0x02,
		.u = {
539 540
			.bulk = {
				.buffersize = 8192,
541 542 543 544
			}
		}
	},

545 546 547 548 549 550 551 552
		},
	},
	.power_ctrl       = cxusb_power_ctrl,

	.i2c_algo         = &cxusb_i2c_algo,

	.generic_bulk_ctrl_endpoint = 0x01,

553 554 555 556 557 558 559 560 561
	.num_device_descs = 1,
	.devices = {
		{   "Medion MD95700 (MDUSBTV-HYBRID)",
			{ NULL },
			{ &cxusb_table[0], NULL },
		},
	}
};

562
static struct dvb_usb_device_properties cxusb_bluebird_lgh064f_properties = {
563 564
	.caps = DVB_USB_IS_AN_I2C_ADAPTER,

565 566 567
	.usb_ctrl          = DEVICE_SPECIFIC,
	.firmware          = "dvb-usb-bluebird-01.fw",
	.download_firmware = bluebird_patch_dvico_firmware_download,
568 569
	/* use usb alt setting 0 for EP4 transfer (dvb-t),
	   use usb alt setting 7 for EP2 transfer (atsc) */
570 571 572

	.size_of_priv     = sizeof(struct cxusb_state),

573 574 575
	.num_adapters = 1,
	.adapter = {
		{
576
	.streaming_ctrl   = cxusb_streaming_ctrl,
577
	.frontend_attach  = cxusb_lgdt3303_frontend_attach,
578
	.tuner_attach     = cxusb_lgdt3303_tuner_attach,
579 580

	/* parameter for the MPEG2-data transfer */
581 582
			.stream = {
				.type = USB_BULK,
583 584 585 586 587 588 589 590
		.count = 5,
		.endpoint = 0x02,
		.u = {
			.bulk = {
				.buffersize = 8192,
			}
		}
	},
591 592 593 594 595 596 597 598 599 600 601 602 603
		},
	},

	.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,
604 605 606 607 608 609 610 611 612 613

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

614
static struct dvb_usb_device_properties cxusb_bluebird_dee1601_properties = {
615 616
	.caps = DVB_USB_IS_AN_I2C_ADAPTER,

617 618 619
	.usb_ctrl          = DEVICE_SPECIFIC,
	.firmware          = "dvb-usb-bluebird-01.fw",
	.download_firmware = bluebird_patch_dvico_firmware_download,
620 621 622 623 624
	/* 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),

625 626 627
	.num_adapters = 1,
	.adapter = {
		{
628 629 630 631
	.streaming_ctrl   = cxusb_streaming_ctrl,
	.frontend_attach  = cxusb_dee1601_frontend_attach,
	.tuner_attach     = cxusb_dee1601_tuner_attach,
	/* parameter for the MPEG2-data transfer */
632 633
			.stream = {
				.type = USB_BULK,
634 635 636 637 638 639 640 641
		.count = 5,
		.endpoint = 0x04,
		.u = {
			.bulk = {
				.buffersize = 8192,
			}
		}
	},
642 643 644 645 646 647 648 649 650 651 652 653 654
		},
	},

	.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,
655

656
	.num_device_descs = 2,
657 658 659 660 661
	.devices = {
		{   "DViCO FusionHDTV DVB-T Dual USB",
			{ &cxusb_table[3], NULL },
			{ &cxusb_table[4], NULL },
		},
662 663 664 665
		{   "DigitalNow DVB-T Dual USB",
			{ &cxusb_table[9],  NULL },
			{ &cxusb_table[10], NULL },
		},
666 667 668
	}
};

669
static struct dvb_usb_device_properties cxusb_bluebird_lgz201_properties = {
M
 
Michael Krufky 已提交
670 671 672 673 674 675 676 677 678 679
	.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),

680 681 682
	.num_adapters = 2,
	.adapter = {
		{
M
 
Michael Krufky 已提交
683 684 685 686 687
	.streaming_ctrl   = cxusb_streaming_ctrl,
	.frontend_attach  = cxusb_mt352_frontend_attach,
	.tuner_attach     = cxusb_lgz201_tuner_attach,

	/* parameter for the MPEG2-data transfer */
688 689
			.stream = {
				.type = USB_BULK,
M
 
Michael Krufky 已提交
690 691 692 693 694 695 696 697
		.count = 5,
		.endpoint = 0x04,
		.u = {
			.bulk = {
				.buffersize = 8192,
			}
		}
	},
698 699 700 701 702
		},
	},
	.power_ctrl       = cxusb_bluebird_power_ctrl,

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

704 705 706 707 708 709
	.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 已提交
710 711 712 713 714 715 716 717 718
	.num_device_descs = 1,
	.devices = {
		{   "DViCO FusionHDTV DVB-T USB (LGZ201)",
			{ &cxusb_table[5], NULL },
			{ &cxusb_table[6], NULL },
		},
	}
};

719
static struct dvb_usb_device_properties cxusb_bluebird_dtt7579_properties = {
M
 
Michael Krufky 已提交
720 721 722 723 724 725 726 727 728 729
	.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),

730 731 732
	.num_adapters = 1,
	.adapter = {
		{
M
 
Michael Krufky 已提交
733 734 735 736 737
	.streaming_ctrl   = cxusb_streaming_ctrl,
	.frontend_attach  = cxusb_mt352_frontend_attach,
	.tuner_attach     = cxusb_dtt7579_tuner_attach,

	/* parameter for the MPEG2-data transfer */
738 739
			.stream = {
				.type = USB_BULK,
M
 
Michael Krufky 已提交
740 741 742 743 744 745 746 747
		.count = 5,
		.endpoint = 0x04,
		.u = {
			.bulk = {
				.buffersize = 8192,
			}
		}
	},
748 749 750 751 752 753 754 755 756 757 758 759
		},
	},
	.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 已提交
760 761 762 763 764 765 766 767 768 769

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

770
static struct usb_driver cxusb_driver = {
771
	.name		= "dvb_usb_cxusb",
772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798
	.probe		= cxusb_probe,
	.disconnect = dvb_usb_device_exit,
	.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>");
799 800
MODULE_AUTHOR("Michael Krufky <mkrufky@m1k.net>");
MODULE_AUTHOR("Chris Pascoe <c.pascoe@itee.uq.edu.au>");
801 802 803
MODULE_DESCRIPTION("Driver for Conexant USB2.0 hybrid reference design");
MODULE_VERSION("1.0-alpha");
MODULE_LICENSE("GPL");