em28xx-cards.c 51.3 KB
Newer Older
1
/*
2 3
   em28xx-cards.c - driver for Empia EM2800/EM2820/2840 USB
		    video capture devices
4

5 6
   Copyright (C) 2005 Ludovico Cavedon <cavedon@sssup.it>
		      Markus Rechberger <mrechberger@gmail.com>
7
		      Mauro Carvalho Chehab <mchehab@infradead.org>
8
		      Sascha Sommer <saschasommer@freenet.de>
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30

   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; either version 2 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include <linux/init.h>
#include <linux/module.h>
#include <linux/delay.h>
#include <linux/i2c.h>
#include <linux/usb.h>
#include <media/tuner.h>
31
#include <media/msp3400.h>
32 33
#include <media/saa7115.h>
#include <media/tvp5150.h>
34
#include <media/tveeprom.h>
35
#include <media/v4l2-common.h>
36
#include <media/v4l2-chip-ident.h>
37

38
#include "em28xx.h"
39

40 41 42 43
static int tuner = -1;
module_param(tuner, int, 0444);
MODULE_PARM_DESC(tuner, "tuner type");

44 45 46 47
static unsigned int disable_ir;
module_param(disable_ir, int, 0444);
MODULE_PARM_DESC(disable_ir, "disable infrared remote support");

48 49 50 51 52 53
struct em28xx_hash_table {
	unsigned long hash;
	unsigned int  model;
	unsigned int  tuner;
};

54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 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 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
/*
 *  Reset sequences for analog/digital modes
 */

/* Reset for the most [analog] boards */
static struct em28xx_reg_seq default_analog[] = {
	{EM28XX_R08_GPIO,	0x6d,   ~EM_GPIO_4,	10},
	{	-1,		-1,	-1,		-1},
};

/* Reset for the most [digital] boards */
static struct em28xx_reg_seq default_digital[] = {
	{EM28XX_R08_GPIO,	0x6e,	~EM_GPIO_4,	10},
	{	-1,		-1,	-1,		-1},
};

/* Board Hauppauge WinTV HVR 900 analog */
static struct em28xx_reg_seq hauppauge_wintv_hvr_900_analog[] = {
	{EM28XX_R08_GPIO,	0x2d,	~EM_GPIO_4,	10},
	{0x05,			0xff,	0x10,		10},
	{  -1,			-1,	-1,		-1},
};

/* Board Hauppauge WinTV HVR 900 digital */
static struct em28xx_reg_seq hauppauge_wintv_hvr_900_digital[] = {
	{EM28XX_R08_GPIO,	0x2e,	~EM_GPIO_4,	10},
	{EM2880_R04_GPO,	0x04,	0x0f,		10},
	{EM2880_R04_GPO,	0x0c,	0x0f,		10},
	{ -1,			-1,	-1,		-1},
};

/* Boards - EM2880 MSI DIGIVOX AD and EM2880_BOARD_MSI_DIGIVOX_AD_II */
static struct em28xx_reg_seq em2880_msi_digivox_ad_analog[] = {
	{EM28XX_R08_GPIO,       0x69,   ~EM_GPIO_4,	 10},
	{	-1,		-1,	-1,		 -1},
};

/* Boards - EM2880 MSI DIGIVOX AD and EM2880_BOARD_MSI_DIGIVOX_AD_II */
static struct em28xx_reg_seq em2880_msi_digivox_ad_digital[] = {
	{EM28XX_R08_GPIO,	0x6a,	~EM_GPIO_4,	10},
	{	-1,		-1,	-1,		-1},
};

/* Board  - EM2870 Kworld 355u
   Analog - No input analog */
static struct em28xx_reg_seq em2870_kworld_355u_digital[] = {
	{EM2880_R04_GPO,	0x01,	0xff,		10},
	{  -1,			-1,	-1,		-1},
};

/* Callback for the most boards */
static struct em28xx_reg_seq default_callback[] = {
	{EM28XX_R08_GPIO,	EM_GPIO_4,	EM_GPIO_4,	10},
	{EM28XX_R08_GPIO,	0,		EM_GPIO_4,	10},
	{EM28XX_R08_GPIO,	EM_GPIO_4,	EM_GPIO_4,	10},
	{  -1,			-1,		-1,		-1},
};

/* Pinnacle PCTV HD Mini (80e) GPIOs
   0-5: not used
   6:   demod reset, active low
   7:   LED on, active high */
static struct em28xx_reg_seq em2874_pinnacle_80e_digital[] = {
	{EM28XX_R06_I2C_CLK,    0x45,   0xff,		  10}, /*400 KHz*/
	{EM2874_R80_GPIO,       0x80,   0xff,		  100},/*Demod reset*/
	{EM2874_R80_GPIO,       0xc0,   0xff,		  10},
	{  -1,			-1,	-1,		  -1},
};

/*
 *  Board definitions
 */
126
struct em28xx_board em28xx_boards[] = {
127 128
	[EM2750_BOARD_UNKNOWN] = {
		.name          = "Unknown EM2750/EM2751 webcam grabber",
129
		.xclk          = EM28XX_XCLK_FREQUENCY_48MHZ,
130 131 132
		.input         = { {
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = 0,
133
			.amux     = EM28XX_AMUX_VIDEO,
134 135
		} },
	},
136 137 138 139
	[EM2800_BOARD_UNKNOWN] = {
		.name         = "Unknown EM2800 video grabber",
		.is_em2800    = 1,
		.tda9887_conf = TDA9887_PRESENT,
140
		.decoder      = EM28XX_SAA711X,
141
		.input        = { {
142
			.type     = EM28XX_VMUX_COMPOSITE1,
143
			.vmux     = SAA7115_COMPOSITE0,
144
			.amux     = EM28XX_AMUX_LINE_IN,
145
		}, {
146
			.type     = EM28XX_VMUX_SVIDEO,
147
			.vmux     = SAA7115_SVIDEO3,
148
			.amux     = EM28XX_AMUX_LINE_IN,
149
		} },
150 151
	},
	[EM2820_BOARD_UNKNOWN] = {
152 153
		.name          = "Unknown EM2750/28xx video grabber",
		.tuner_type    = TUNER_ABSENT,
154
	},
155 156 157 158
	[EM2750_BOARD_DLCW_130] = {
		/* Beijing Huaqi Information Digital Technology Co., Ltd */
		.name          = "Huaqi DLCW-130",
		.valid         = EM28XX_BOARD_NOT_VALIDATED,
159
		.xclk          = EM28XX_XCLK_FREQUENCY_48MHZ,
160 161 162
		.input         = { {
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = 0,
163
			.amux     = EM28XX_AMUX_VIDEO,
164 165
		} },
	},
166
	[EM2820_BOARD_KWORLD_PVRTV2800RF] = {
167
		.name         = "Kworld PVR TV 2800 RF",
168
		.tuner_type   = TUNER_TEMIC_PAL,
169
		.tda9887_conf = TDA9887_PRESENT,
170
		.decoder      = EM28XX_SAA711X,
171
		.input        = { {
172
			.type     = EM28XX_VMUX_COMPOSITE1,
173
			.vmux     = SAA7115_COMPOSITE0,
174
			.amux     = EM28XX_AMUX_LINE_IN,
175
		}, {
176
			.type     = EM28XX_VMUX_SVIDEO,
177
			.vmux     = SAA7115_SVIDEO3,
178
			.amux     = EM28XX_AMUX_LINE_IN,
179
		} },
180
	},
181 182 183 184
	[EM2820_BOARD_TERRATEC_CINERGY_250] = {
		.name         = "Terratec Cinergy 250 USB",
		.tuner_type   = TUNER_LG_PAL_NEW_TAPC,
		.tda9887_conf = TDA9887_PRESENT,
185
		.decoder      = EM28XX_SAA711X,
186
		.input        = { {
187
			.type     = EM28XX_VMUX_TELEVISION,
188
			.vmux     = SAA7115_COMPOSITE2,
189
			.amux     = EM28XX_AMUX_LINE_IN,
190
		}, {
191
			.type     = EM28XX_VMUX_COMPOSITE1,
192
			.vmux     = SAA7115_COMPOSITE0,
193
			.amux     = EM28XX_AMUX_LINE_IN,
194
		}, {
195
			.type     = EM28XX_VMUX_SVIDEO,
196
			.vmux     = SAA7115_SVIDEO3,
197
			.amux     = EM28XX_AMUX_LINE_IN,
198
		} },
199 200 201 202 203
	},
	[EM2820_BOARD_PINNACLE_USB_2] = {
		.name         = "Pinnacle PCTV USB 2",
		.tuner_type   = TUNER_LG_PAL_NEW_TAPC,
		.tda9887_conf = TDA9887_PRESENT,
204
		.decoder      = EM28XX_SAA711X,
205
		.input        = { {
206
			.type     = EM28XX_VMUX_TELEVISION,
207
			.vmux     = SAA7115_COMPOSITE2,
208
			.amux     = EM28XX_AMUX_VIDEO,
209
		}, {
210
			.type     = EM28XX_VMUX_COMPOSITE1,
211
			.vmux     = SAA7115_COMPOSITE0,
212
			.amux     = EM28XX_AMUX_LINE_IN,
213
		}, {
214
			.type     = EM28XX_VMUX_SVIDEO,
215
			.vmux     = SAA7115_SVIDEO3,
216
			.amux     = EM28XX_AMUX_LINE_IN,
217
		} },
218 219 220 221
	},
	[EM2820_BOARD_HAUPPAUGE_WINTV_USB_2] = {
		.name         = "Hauppauge WinTV USB 2",
		.tuner_type   = TUNER_PHILIPS_FM1236_MK3,
222 223 224
		.tda9887_conf = TDA9887_PRESENT |
				TDA9887_PORT1_ACTIVE|
				TDA9887_PORT2_ACTIVE,
225
		.decoder      = EM28XX_TVP5150,
226
		.has_msp34xx  = 1,
227
		.input        = { {
228
			.type     = EM28XX_VMUX_TELEVISION,
229
			.vmux     = TVP5150_COMPOSITE0,
230
			.amux     = MSP_INPUT_DEFAULT,
231
		}, {
232
			.type     = EM28XX_VMUX_SVIDEO,
233
			.vmux     = TVP5150_SVIDEO,
234 235
			.amux     = MSP_INPUT(MSP_IN_SCART1, MSP_IN_TUNER1,
					MSP_DSP_IN_SCART, MSP_DSP_IN_SCART),
236
		} },
237
	},
238 239 240 241 242
	[EM2820_BOARD_DLINK_USB_TV] = {
		.name         = "D-Link DUB-T210 TV Tuner",
		.valid        = EM28XX_BOARD_NOT_VALIDATED,
		.tuner_type   = TUNER_LG_PAL_NEW_TAPC,
		.tda9887_conf = TDA9887_PRESENT,
243
		.decoder      = EM28XX_SAA711X,
244
		.input        = { {
245 246
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = SAA7115_COMPOSITE2,
247
			.amux     = EM28XX_AMUX_LINE_IN,
248 249 250
		}, {
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = SAA7115_COMPOSITE0,
251
			.amux     = EM28XX_AMUX_LINE_IN,
252 253 254
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = SAA7115_SVIDEO3,
255
			.amux     = EM28XX_AMUX_LINE_IN,
256 257 258 259 260 261 262
		} },
	},
	[EM2820_BOARD_HERCULES_SMART_TV_USB2] = {
		.name         = "Hercules Smart TV USB 2.0",
		.valid        = EM28XX_BOARD_NOT_VALIDATED,
		.tuner_type   = TUNER_LG_PAL_NEW_TAPC,
		.tda9887_conf = TDA9887_PRESENT,
263
		.decoder      = EM28XX_SAA711X,
264 265 266
		.input        = { {
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = SAA7115_COMPOSITE2,
267
			.amux     = EM28XX_AMUX_LINE_IN,
268 269 270
		}, {
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = SAA7115_COMPOSITE0,
271
			.amux     = EM28XX_AMUX_LINE_IN,
272 273 274
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = SAA7115_SVIDEO3,
275
			.amux     = EM28XX_AMUX_LINE_IN,
276 277 278 279 280 281 282
		} },
	},
	[EM2820_BOARD_PINNACLE_USB_2_FM1216ME] = {
		.name         = "Pinnacle PCTV USB 2 (Philips FM1216ME)",
		.valid        = EM28XX_BOARD_NOT_VALIDATED,
		.tuner_type   = TUNER_PHILIPS_FM1216ME_MK3,
		.tda9887_conf = TDA9887_PRESENT,
283
		.decoder      = EM28XX_SAA711X,
284
		.input        = { {
285 286
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = SAA7115_COMPOSITE2,
287
			.amux     = EM28XX_AMUX_VIDEO,
288 289 290
		}, {
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = SAA7115_COMPOSITE0,
291
			.amux     = EM28XX_AMUX_LINE_IN,
292 293 294
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = SAA7115_SVIDEO3,
295
			.amux     = EM28XX_AMUX_LINE_IN,
296 297 298 299 300 301 302
		} },
	},
	[EM2820_BOARD_GADMEI_UTV310] = {
		.name         = "Gadmei UTV310",
		.valid        = EM28XX_BOARD_NOT_VALIDATED,
		.tuner_type   = TUNER_TNF_5335MF,
		.tda9887_conf = TDA9887_PRESENT,
303
		.decoder      = EM28XX_SAA711X,
304
		.input        = { {
305 306
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = SAA7115_COMPOSITE1,
307
			.amux     = EM28XX_AMUX_LINE_IN,
308 309 310
		}, {
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = SAA7115_COMPOSITE0,
311
			.amux     = EM28XX_AMUX_LINE_IN,
312 313 314
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = SAA7115_SVIDEO3,
315
			.amux     = EM28XX_AMUX_LINE_IN,
316 317 318 319 320 321 322
		} },
	},
	[EM2820_BOARD_LEADTEK_WINFAST_USBII_DELUXE] = {
		.name         = "Leadtek Winfast USB II Deluxe",
		.valid        = EM28XX_BOARD_NOT_VALIDATED,
		.tuner_type   = TUNER_PHILIPS_FM1216ME_MK3,
		.tda9887_conf = TDA9887_PRESENT,
323
		.decoder      = EM28XX_SAA711X,
324
		.input        = { {
325 326
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = 2,
327
			.amux     = EM28XX_AMUX_VIDEO,
328 329 330
		}, {
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = 0,
331
			.amux     = EM28XX_AMUX_LINE_IN,
332 333 334
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = 9,
335
			.amux     = EM28XX_AMUX_LINE_IN,
336 337 338 339 340
		} },
	},
	[EM2820_BOARD_PINNACLE_DVC_100] = {
		.name         = "Pinnacle Dazzle DVC 100",
		.valid        = EM28XX_BOARD_NOT_VALIDATED,
341
		.decoder      = EM28XX_SAA711X,
342
		.input        = { {
343 344
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = SAA7115_COMPOSITE0,
345
			.amux     = EM28XX_AMUX_LINE_IN,
346 347 348
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = SAA7115_SVIDEO3,
349
			.amux     = EM28XX_AMUX_LINE_IN,
350 351 352
		} },
	},
	[EM2820_BOARD_VIDEOLOGY_20K14XUSB] = {
353
		.name         = "Videology 20K14XUSB USB2.0",
354
		.valid        = EM28XX_BOARD_NOT_VALIDATED,
355
		.input        = { {
356 357
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = 0,
358
			.amux     = EM28XX_AMUX_VIDEO,
359 360 361 362 363 364 365
		} },
	},
	[EM2821_BOARD_PROLINK_PLAYTV_USB2] = {
		.name         = "SIIG AVTuner-PVR/Prolink PlayTV USB 2.0",
		.valid        = EM28XX_BOARD_NOT_VALIDATED,
		.tuner_type   = TUNER_LG_PAL_NEW_TAPC,	/* unknown? */
		.tda9887_conf = TDA9887_PRESENT,	/* unknown? */
366
		.decoder      = EM28XX_SAA711X,
367
		.input        = { {
368 369
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = SAA7115_COMPOSITE2,
370
			.amux     = EM28XX_AMUX_LINE_IN,
371 372 373
		}, {
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = SAA7115_COMPOSITE0,
374
			.amux     = EM28XX_AMUX_LINE_IN,
375 376 377
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = SAA7115_SVIDEO3,
378
			.amux     = EM28XX_AMUX_LINE_IN,
379 380 381 382 383 384 385 386 387
		} },
	},
	[EM2821_BOARD_SUPERCOMP_USB_2] = {
		.name         = "Supercomp USB 2.0 TV",
		.valid        = EM28XX_BOARD_NOT_VALIDATED,
		.tuner_type   = TUNER_PHILIPS_FM1236_MK3,
		.tda9887_conf = TDA9887_PRESENT |
				TDA9887_PORT1_ACTIVE |
				TDA9887_PORT2_ACTIVE,
388
		.decoder      = EM28XX_SAA711X,
389
		.input        = { {
390 391
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = SAA7115_COMPOSITE2,
392
			.amux     = EM28XX_AMUX_LINE_IN,
393 394 395
		}, {
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = SAA7115_COMPOSITE0,
396
			.amux     = EM28XX_AMUX_VIDEO,
397 398 399
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = SAA7115_SVIDEO3,
400
			.amux     = EM28XX_AMUX_LINE_IN,
401 402 403
		} },
	},
	[EM2821_BOARD_USBGEAR_VD204] = {
404
		.name         = "Usbgear VD204v9",
405
		.valid        = EM28XX_BOARD_NOT_VALIDATED,
406
		.decoder      = EM28XX_SAA711X,
407
		.input        = { {
408 409
			.type  = EM28XX_VMUX_COMPOSITE1,
			.vmux  = SAA7115_COMPOSITE0,
410
			.amux  = EM28XX_AMUX_LINE_IN,
411 412 413
		}, {
			.type  = EM28XX_VMUX_SVIDEO,
			.vmux  = SAA7115_SVIDEO3,
414
			.amux  = EM28XX_AMUX_LINE_IN,
415 416 417 418
		} },
	},
	[EM2860_BOARD_NETGMBH_CAM] = {
		/* Beijing Huaqi Information Digital Technology Co., Ltd */
419 420 421
		.name         = "NetGMBH Cam",
		.valid        = EM28XX_BOARD_NOT_VALIDATED,
		.input        = { {
422 423
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = 0,
424
			.amux     = EM28XX_AMUX_VIDEO,
425 426 427
		} },
	},
	[EM2860_BOARD_TYPHOON_DVD_MAKER] = {
428
		.name         = "Typhoon DVD Maker",
429
		.valid        = EM28XX_BOARD_NOT_VALIDATED,
430
		.decoder      = EM28XX_SAA711X,
431
		.input        = { {
432 433
			.type  = EM28XX_VMUX_COMPOSITE1,
			.vmux  = SAA7115_COMPOSITE0,
434
			.amux  = EM28XX_AMUX_LINE_IN,
435 436 437
		}, {
			.type  = EM28XX_VMUX_SVIDEO,
			.vmux  = SAA7115_SVIDEO3,
438
			.amux  = EM28XX_AMUX_LINE_IN,
439 440 441 442 443 444
		} },
	},
	[EM2860_BOARD_GADMEI_UTV330] = {
		.name         = "Gadmei UTV330",
		.valid        = EM28XX_BOARD_NOT_VALIDATED,
		.tuner_type   = TUNER_TNF_5335MF,
445
		.tda9887_conf = TDA9887_PRESENT,
446
		.decoder      = EM28XX_SAA711X,
447
		.input        = { {
448 449
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = SAA7115_COMPOSITE2,
450
			.amux     = EM28XX_AMUX_VIDEO,
451 452 453
		}, {
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = SAA7115_COMPOSITE0,
454
			.amux     = EM28XX_AMUX_LINE_IN,
455 456 457
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = SAA7115_SVIDEO3,
458
			.amux     = EM28XX_AMUX_LINE_IN,
459 460 461 462 463
		} },
	},
	[EM2860_BOARD_TERRATEC_HYBRID_XS] = {
		.name         = "Terratec Cinergy A Hybrid XS",
		.valid        = EM28XX_BOARD_NOT_VALIDATED,
464 465
		.tuner_type   = TUNER_XC2028,
		.decoder      = EM28XX_TVP5150,
466
		.input        = { {
467 468
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = TVP5150_COMPOSITE0,
469
			.amux     = EM28XX_AMUX_VIDEO,
470
		}, {
471 472
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = TVP5150_COMPOSITE1,
473
			.amux     = EM28XX_AMUX_LINE_IN,
474
		}, {
475 476
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = TVP5150_SVIDEO,
477
			.amux     = EM28XX_AMUX_LINE_IN,
478
		} },
479
	},
480 481 482
	[EM2861_BOARD_KWORLD_PVRTV_300U] = {
		.name	      = "KWorld PVRTV 300U",
		.valid        = EM28XX_BOARD_NOT_VALIDATED,
483 484
		.tuner_type   = TUNER_XC2028,
		.decoder      = EM28XX_TVP5150,
485
		.input        = { {
486 487
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = TVP5150_COMPOSITE0,
488
			.amux     = EM28XX_AMUX_VIDEO,
489 490 491
		}, {
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = TVP5150_COMPOSITE1,
492
			.amux     = EM28XX_AMUX_LINE_IN,
493 494 495
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = TVP5150_SVIDEO,
496
			.amux     = EM28XX_AMUX_LINE_IN,
497 498
		} },
	},
499 500
	[EM2861_BOARD_YAKUMO_MOVIE_MIXER] = {
		.name          = "Yakumo MovieMixer",
501
		.valid         = EM28XX_BOARD_NOT_VALIDATED,
502 503
		.decoder       = EM28XX_TVP5150,
		.input         = { {
504 505
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = TVP5150_COMPOSITE0,
506
			.amux     = EM28XX_AMUX_VIDEO,
507
		}, {
508 509
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = TVP5150_COMPOSITE1,
510
			.amux     = EM28XX_AMUX_LINE_IN,
511
		}, {
512 513
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = TVP5150_SVIDEO,
514
			.amux     = EM28XX_AMUX_LINE_IN,
515
		} },
516
	},
517 518 519 520 521 522
	[EM2861_BOARD_PLEXTOR_PX_TV100U] = {
		.name         = "Plextor ConvertX PX-TV100U",
		.valid        = EM28XX_BOARD_NOT_VALIDATED,
		.tuner_type   = TUNER_TNF_5335MF,
		.tda9887_conf = TDA9887_PRESENT,
		.decoder      = EM28XX_TVP5150,
523
		.input        = { {
524 525
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = TVP5150_COMPOSITE0,
526
			.amux     = EM28XX_AMUX_LINE_IN,
527 528 529
		}, {
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = TVP5150_COMPOSITE1,
530
			.amux     = EM28XX_AMUX_LINE_IN,
531 532 533
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = TVP5150_SVIDEO,
534
			.amux     = EM28XX_AMUX_LINE_IN,
535 536
		} },
	},
537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559
	[EM2870_BOARD_TERRATEC_XS] = {
		.name         = "Terratec Cinergy T XS",
		.valid        = EM28XX_BOARD_NOT_VALIDATED,
		.tuner_type   = TUNER_XC2028,
	},
	[EM2870_BOARD_TERRATEC_XS_MT2060] = {
		.name         = "Terratec Cinergy T XS (MT2060)",
		.valid        = EM28XX_BOARD_NOT_VALIDATED,
		.tuner_type   = TUNER_ABSENT, /* MT2060 */
	},
	[EM2870_BOARD_KWORLD_350U] = {
		.name         = "Kworld 350 U DVB-T",
		.valid        = EM28XX_BOARD_NOT_VALIDATED,
		.tuner_type   = TUNER_XC2028,
	},
	[EM2870_BOARD_KWORLD_355U] = {
		.name         = "Kworld 355 U DVB-T",
		.valid        = EM28XX_BOARD_NOT_VALIDATED,
	},
	[EM2870_BOARD_PINNACLE_PCTV_DVB] = {
		.name         = "Pinnacle PCTV DVB-T",
		.valid        = EM28XX_BOARD_NOT_VALIDATED,
		.tuner_type   = TUNER_ABSENT, /* MT2060 */
560 561 562
		/* djh - I have serious doubts this is right... */
		.xclk         = EM28XX_XCLK_IR_RC5_MODE |
				EM28XX_XCLK_FREQUENCY_10MHZ,
563 564 565 566 567 568 569 570 571 572 573 574
	},
	[EM2870_BOARD_COMPRO_VIDEOMATE] = {
		.name         = "Compro, VideoMate U3",
		.valid        = EM28XX_BOARD_NOT_VALIDATED,
		.tuner_type   = TUNER_ABSENT, /* MT2060 */
	},
	[EM2880_BOARD_TERRATEC_HYBRID_XS_FR] = {
		.name         = "Terratec Hybrid XS Secam",
		.valid        = EM28XX_BOARD_NOT_VALIDATED,
		.has_msp34xx  = 1,
		.tuner_type   = TUNER_XC2028,
		.decoder      = EM28XX_TVP5150,
575
		.input        = { {
576 577
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = TVP5150_COMPOSITE0,
578
			.amux     = EM28XX_AMUX_VIDEO,
579 580 581
		}, {
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = TVP5150_COMPOSITE1,
582
			.amux     = EM28XX_AMUX_LINE_IN,
583 584 585
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = TVP5150_SVIDEO,
586
			.amux     = EM28XX_AMUX_LINE_IN,
587 588
		} },
	},
589 590 591 592 593
	[EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900] = {
		.name         = "Hauppauge WinTV HVR 900",
		.tda9887_conf = TDA9887_PRESENT,
		.tuner_type   = TUNER_XC2028,
		.mts_firmware = 1,
594
		.has_dvb      = 1,
595
		.decoder      = EM28XX_TVP5150,
596
		.input        = { {
597 598
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = TVP5150_COMPOSITE0,
599
			.amux     = EM28XX_AMUX_VIDEO,
600 601 602
		}, {
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = TVP5150_COMPOSITE1,
603
			.amux     = EM28XX_AMUX_LINE_IN,
604 605 606
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = TVP5150_SVIDEO,
607
			.amux     = EM28XX_AMUX_LINE_IN,
608 609 610 611 612 613 614 615
		} },
	},
	[EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900_R2] = {
		.name         = "Hauppauge WinTV HVR 900 (R2)",
		.tda9887_conf = TDA9887_PRESENT,
		.tuner_type   = TUNER_XC2028,
		.mts_firmware = 1,
		.decoder      = EM28XX_TVP5150,
616
		.input        = { {
617 618
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = TVP5150_COMPOSITE0,
619
			.amux     = EM28XX_AMUX_VIDEO,
620 621 622
		}, {
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = TVP5150_COMPOSITE1,
623
			.amux     = 3,
624 625 626
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = TVP5150_SVIDEO,
627
			.amux     = EM28XX_AMUX_LINE_IN,
628 629
		} },
	},
630
	[EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950] = {
631 632 633 634
		.name           = "Hauppauge WinTV HVR 950",
		.tuner_type     = TUNER_XC2028,
		.mts_firmware   = 1,
		.has_dvb        = 1,
635
		.ir_codes       = ir_codes_hauppauge_new,
636 637 638 639
		.decoder        = EM28XX_TVP5150,
		.input          = { {
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = TVP5150_COMPOSITE0,
640
			.amux     = EM28XX_AMUX_VIDEO,
641 642 643
		}, {
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = TVP5150_COMPOSITE1,
644
			.amux     = EM28XX_AMUX_LINE_IN,
645 646 647
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = TVP5150_SVIDEO,
648
			.amux     = EM28XX_AMUX_LINE_IN,
649 650 651 652 653 654 655
		} },
	},
	[EM2880_BOARD_PINNACLE_PCTV_HD_PRO] = {
		.name           = "Pinnacle PCTV HD Pro Stick",
		.tuner_type     = TUNER_XC2028,
		.mts_firmware   = 1,
		.has_dvb        = 1,
656
		.ir_codes       = ir_codes_pinnacle_pctv_hd,
657 658 659 660
		.decoder        = EM28XX_TVP5150,
		.input          = { {
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = TVP5150_COMPOSITE0,
661
			.amux     = EM28XX_AMUX_VIDEO,
662 663 664
		}, {
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = TVP5150_COMPOSITE1,
665
			.amux     = EM28XX_AMUX_LINE_IN,
666 667 668
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = TVP5150_SVIDEO,
669
			.amux     = EM28XX_AMUX_LINE_IN,
670 671 672 673 674 675 676
		} },
	},
	[EM2880_BOARD_AMD_ATI_TV_WONDER_HD_600] = {
		.name           = "AMD ATI TV Wonder HD 600",
		.tuner_type     = TUNER_XC2028,
		.mts_firmware   = 1,
		.has_dvb        = 1,
677
		.ir_codes       = ir_codes_ati_tv_wonder_hd_600,
678 679 680 681
		.decoder        = EM28XX_TVP5150,
		.input          = { {
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = TVP5150_COMPOSITE0,
682
			.amux     = EM28XX_AMUX_VIDEO,
683 684 685
		}, {
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = TVP5150_COMPOSITE1,
686
			.amux     = EM28XX_AMUX_LINE_IN,
687 688 689
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = TVP5150_SVIDEO,
690
			.amux     = EM28XX_AMUX_LINE_IN,
691 692 693
		} },
	},
	[EM2880_BOARD_TERRATEC_HYBRID_XS] = {
694 695 696
		.name           = "Terratec Hybrid XS",
		.tuner_type     = TUNER_XC2028,
		.decoder        = EM28XX_TVP5150,
697 698 699 700
		.has_dvb        = 1,
		.input          = { {
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = TVP5150_COMPOSITE0,
701
			.amux     = EM28XX_AMUX_VIDEO,
702 703 704
		}, {
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = TVP5150_COMPOSITE1,
705
			.amux     = EM28XX_AMUX_LINE_IN,
706 707 708
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = TVP5150_SVIDEO,
709
			.amux     = EM28XX_AMUX_LINE_IN,
710 711 712 713 714 715 716 717 718
		} },
	},
	/* maybe there's a reason behind it why Terratec sells the Hybrid XS
	   as Prodigy XS with a different PID, let's keep it separated for now
	   maybe we'll need it lateron */
	[EM2880_BOARD_TERRATEC_PRODIGY_XS] = {
		.name         = "Terratec Prodigy XS",
		.tuner_type   = TUNER_XC2028,
		.decoder      = EM28XX_TVP5150,
719
		.input        = { {
720 721
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = TVP5150_COMPOSITE0,
722
			.amux     = EM28XX_AMUX_VIDEO,
723 724 725
		}, {
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = TVP5150_COMPOSITE1,
726
			.amux     = EM28XX_AMUX_LINE_IN,
727 728 729
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = TVP5150_SVIDEO,
730
			.amux     = EM28XX_AMUX_LINE_IN,
731 732 733 734 735 736 737 738 739
		} },
	},
	[EM2820_BOARD_MSI_VOX_USB_2] = {
		.name		   = "MSI VOX USB 2.0",
		.tuner_type	   = TUNER_LG_PAL_NEW_TAPC,
		.tda9887_conf	   = TDA9887_PRESENT      |
				     TDA9887_PORT1_ACTIVE |
				     TDA9887_PORT2_ACTIVE,
		.max_range_640_480 = 1,
740
		.decoder           = EM28XX_SAA711X,
741 742 743
		.input             = { {
			.type      = EM28XX_VMUX_TELEVISION,
			.vmux      = SAA7115_COMPOSITE4,
744
			.amux      = EM28XX_AMUX_VIDEO,
745 746 747
		}, {
			.type      = EM28XX_VMUX_COMPOSITE1,
			.vmux      = SAA7115_COMPOSITE0,
748
			.amux      = EM28XX_AMUX_LINE_IN,
749 750 751
		}, {
			.type      = EM28XX_VMUX_SVIDEO,
			.vmux      = SAA7115_SVIDEO3,
752
			.amux      = EM28XX_AMUX_LINE_IN,
753 754 755 756 757 758 759
		} },
	},
	[EM2800_BOARD_TERRATEC_CINERGY_200] = {
		.name         = "Terratec Cinergy 200 USB",
		.is_em2800    = 1,
		.tuner_type   = TUNER_LG_PAL_NEW_TAPC,
		.tda9887_conf = TDA9887_PRESENT,
760
		.decoder      = EM28XX_SAA711X,
761
		.input        = { {
762 763
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = SAA7115_COMPOSITE2,
764
			.amux     = EM28XX_AMUX_VIDEO,
765 766 767
		}, {
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = SAA7115_COMPOSITE0,
768
			.amux     = EM28XX_AMUX_LINE_IN,
769 770 771
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = SAA7115_SVIDEO3,
772
			.amux     = EM28XX_AMUX_LINE_IN,
773 774 775 776 777
		} },
	},
	[EM2800_BOARD_GRABBEEX_USB2800] = {
		.name         = "eMPIA Technology, Inc. GrabBeeX+ Video Encoder",
		.is_em2800    = 1,
778
		.decoder      = EM28XX_SAA711X,
779
		.input        = { {
780 781
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = SAA7115_COMPOSITE0,
782
			.amux     = EM28XX_AMUX_LINE_IN,
783 784 785
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = SAA7115_SVIDEO3,
786
			.amux     = EM28XX_AMUX_LINE_IN,
787 788 789 790 791 792 793
		} },
	},
	[EM2800_BOARD_LEADTEK_WINFAST_USBII] = {
		.name         = "Leadtek Winfast USB II",
		.is_em2800    = 1,
		.tuner_type   = TUNER_LG_PAL_NEW_TAPC,
		.tda9887_conf = TDA9887_PRESENT,
794
		.decoder      = EM28XX_SAA711X,
795
		.input        = { {
796 797
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = SAA7115_COMPOSITE2,
798
			.amux     = EM28XX_AMUX_VIDEO,
799 800 801
		}, {
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = SAA7115_COMPOSITE0,
802
			.amux     = EM28XX_AMUX_LINE_IN,
803 804 805
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = SAA7115_SVIDEO3,
806
			.amux     = EM28XX_AMUX_LINE_IN,
807 808 809 810 811 812 813
		} },
	},
	[EM2800_BOARD_KWORLD_USB2800] = {
		.name         = "Kworld USB2800",
		.is_em2800    = 1,
		.tuner_type   = TUNER_PHILIPS_FCV1236D,
		.tda9887_conf = TDA9887_PRESENT,
814
		.decoder      = EM28XX_SAA711X,
815
		.input        = { {
816 817
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = SAA7115_COMPOSITE2,
818
			.amux     = EM28XX_AMUX_VIDEO,
819 820 821
		}, {
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = SAA7115_COMPOSITE0,
822
			.amux     = EM28XX_AMUX_LINE_IN,
823 824 825
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = SAA7115_SVIDEO3,
826
			.amux     = EM28XX_AMUX_LINE_IN,
827 828 829 830 831
		} },
	},
	[EM2820_BOARD_PINNACLE_DVC_90] = {
		.name         = "Pinnacle Dazzle DVC 90/DVC 100",
		.tuner_type   = TUNER_ABSENT,
832
		.decoder      = EM28XX_SAA711X,
833
		.input        = { {
834 835
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = SAA7115_COMPOSITE0,
836
			.amux     = EM28XX_AMUX_LINE_IN,
837 838 839
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = SAA7115_SVIDEO3,
840
			.amux     = EM28XX_AMUX_LINE_IN,
841 842 843 844 845 846 847
		} },
	},
	[EM2800_BOARD_VGEAR_POCKETTV] = {
		.name         = "V-Gear PocketTV",
		.is_em2800    = 1,
		.tuner_type   = TUNER_LG_PAL_NEW_TAPC,
		.tda9887_conf = TDA9887_PRESENT,
848
		.decoder      = EM28XX_SAA711X,
849
		.input        = { {
850 851
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = SAA7115_COMPOSITE2,
852
			.amux     = EM28XX_AMUX_VIDEO,
853 854 855
		}, {
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = SAA7115_COMPOSITE0,
856
			.amux     = EM28XX_AMUX_LINE_IN,
857 858 859
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = SAA7115_SVIDEO3,
860
			.amux     = EM28XX_AMUX_LINE_IN,
861 862 863 864 865 866
		} },
	},
	[EM2820_BOARD_PROLINK_PLAYTV_USB2] = {
		.name         = "Pixelview Prolink PlayTV USB 2.0",
		.tda9887_conf = TDA9887_PRESENT,
		.tuner_type   = TUNER_YMEC_TVF_5533MF,
867
		.decoder      = EM28XX_SAA711X,
868
		.input        = { {
869 870
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = SAA7115_COMPOSITE2,
871 872 873
			.amux     = EM28XX_AMUX_VIDEO,
			.aout     = EM28XX_AOUT_MONO | 	/* I2S */
				    EM28XX_AOUT_MASTER,	/* Line out pin */
874 875 876 877 878 879 880 881 882 883 884
		}, {
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = SAA7115_COMPOSITE0,
			.amux     = EM28XX_AMUX_LINE_IN,
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = SAA7115_SVIDEO3,
			.amux     = EM28XX_AMUX_LINE_IN,
		} },
	},
	[EM2860_BOARD_POINTNIX_INTRAORAL_CAMERA] = {
885
		.name                = "PointNix Intra-Oral Camera",
886
		.has_snapshot_button = 1,
887 888
		.tda9887_conf        = TDA9887_PRESENT,
		.tuner_type          = TUNER_ABSENT,
889
		.decoder             = EM28XX_SAA711X,
890
		.input               = { {
891 892
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = SAA7115_SVIDEO3,
893
			.amux     = EM28XX_AMUX_VIDEO,
894 895 896 897 898 899 900
		} },
	},
	[EM2880_BOARD_MSI_DIGIVOX_AD] = {
		.name         = "MSI DigiVox A/D",
		.valid        = EM28XX_BOARD_NOT_VALIDATED,
		.tuner_type   = TUNER_XC2028,
		.decoder      = EM28XX_TVP5150,
901
		.input        = { {
902 903
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = TVP5150_COMPOSITE0,
904
			.amux     = EM28XX_AMUX_VIDEO,
905 906 907
		}, {
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = TVP5150_COMPOSITE1,
908
			.amux     = EM28XX_AMUX_LINE_IN,
909 910 911
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = TVP5150_SVIDEO,
912
			.amux     = EM28XX_AMUX_LINE_IN,
913 914 915 916 917 918 919
		} },
	},
	[EM2880_BOARD_MSI_DIGIVOX_AD_II] = {
		.name         = "MSI DigiVox A/D II",
		.valid        = EM28XX_BOARD_NOT_VALIDATED,
		.tuner_type   = TUNER_XC2028,
		.decoder      = EM28XX_TVP5150,
920
		.input        = { {
921 922
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = TVP5150_COMPOSITE0,
923
			.amux     = EM28XX_AMUX_VIDEO,
924 925 926
		}, {
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = TVP5150_COMPOSITE1,
927
			.amux     = EM28XX_AMUX_LINE_IN,
928 929 930
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = TVP5150_SVIDEO,
931
			.amux     = EM28XX_AMUX_LINE_IN,
932 933
		} },
	},
934 935 936
	[EM2880_BOARD_KWORLD_DVB_305U] = {
		.name	      = "KWorld DVB-T 305U",
		.valid        = EM28XX_BOARD_NOT_VALIDATED,
937 938
		.tuner_type   = TUNER_XC2028,
		.decoder      = EM28XX_TVP5150,
939
		.input        = { {
940 941
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = TVP5150_COMPOSITE0,
942
			.amux     = EM28XX_AMUX_VIDEO,
943
		}, {
944 945
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = TVP5150_COMPOSITE1,
946
			.amux     = EM28XX_AMUX_LINE_IN,
947
		}, {
948 949
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = TVP5150_SVIDEO,
950
			.amux     = EM28XX_AMUX_LINE_IN,
951
		} },
952
	},
953 954
	[EM2880_BOARD_KWORLD_DVB_310U] = {
		.name	      = "KWorld DVB-T 310U",
955
		.tuner_type   = TUNER_XC2028,
956 957
		.has_dvb      = 1,
		.mts_firmware = 1,
958
		.decoder      = EM28XX_TVP5150,
959
		.input        = { {
960 961
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = TVP5150_COMPOSITE0,
962
			.amux     = EM28XX_AMUX_VIDEO,
963
		}, {
964 965
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = TVP5150_COMPOSITE1,
966
			.amux     = EM28XX_AMUX_LINE_IN,
967
		}, {	/* S-video has not been tested yet */
968 969
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = TVP5150_SVIDEO,
970
			.amux     = EM28XX_AMUX_LINE_IN,
971
		} },
972
	},
973 974 975 976 977
	[EM2881_BOARD_DNT_DA2_HYBRID] = {
		.name         = "DNT DA2 Hybrid",
		.valid        = EM28XX_BOARD_NOT_VALIDATED,
		.tuner_type   = TUNER_XC2028,
		.decoder      = EM28XX_TVP5150,
978
		.input        = { {
979
			.type     = EM28XX_VMUX_TELEVISION,
980
			.vmux     = TVP5150_COMPOSITE0,
981
			.amux     = EM28XX_AMUX_VIDEO,
982
		}, {
983
			.type     = EM28XX_VMUX_COMPOSITE1,
984
			.vmux     = TVP5150_COMPOSITE1,
985
			.amux     = EM28XX_AMUX_LINE_IN,
986
		}, {
987
			.type     = EM28XX_VMUX_SVIDEO,
988
			.vmux     = TVP5150_SVIDEO,
989
			.amux     = EM28XX_AMUX_LINE_IN,
990
		} },
991
	},
992 993 994 995 996
	[EM2881_BOARD_PINNACLE_HYBRID_PRO] = {
		.name         = "Pinnacle Hybrid Pro",
		.valid        = EM28XX_BOARD_NOT_VALIDATED,
		.tuner_type   = TUNER_XC2028,
		.decoder      = EM28XX_TVP5150,
997
		.input        = { {
998 999
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = TVP5150_COMPOSITE0,
1000
			.amux     = EM28XX_AMUX_VIDEO,
1001
		}, {
1002
			.type     = EM28XX_VMUX_COMPOSITE1,
1003
			.vmux     = TVP5150_COMPOSITE1,
1004
			.amux     = EM28XX_AMUX_LINE_IN,
1005 1006
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
1007
			.vmux     = TVP5150_SVIDEO,
1008
			.amux     = EM28XX_AMUX_LINE_IN,
1009 1010
		} },
	},
1011 1012 1013 1014
	[EM2882_BOARD_PINNACLE_HYBRID_PRO] = {
		.name         = "Pinnacle Hybrid Pro (2)",
		.valid        = EM28XX_BOARD_NOT_VALIDATED,
		.tuner_type   = TUNER_XC2028,
1015
		.mts_firmware = 1,
1016
		.decoder      = EM28XX_TVP5150,
1017
		.input        = { {
1018
			.type     = EM28XX_VMUX_TELEVISION,
1019
			.vmux     = TVP5150_COMPOSITE0,
1020
			.amux     = EM28XX_AMUX_VIDEO,
1021
		}, {
1022
			.type     = EM28XX_VMUX_COMPOSITE1,
1023
			.vmux     = TVP5150_COMPOSITE1,
1024
			.amux     = EM28XX_AMUX_LINE_IN,
1025
		}, {
1026
			.type     = EM28XX_VMUX_SVIDEO,
1027
			.vmux     = TVP5150_SVIDEO,
1028
			.amux     = EM28XX_AMUX_LINE_IN,
1029
		} },
1030
	},
1031 1032 1033 1034 1035
	[EM2882_BOARD_KWORLD_VS_DVBT] = {
		.name         = "Kworld VS-DVB-T 323UR",
		.valid        = EM28XX_BOARD_NOT_VALIDATED,
		.tuner_type   = TUNER_XC2028,
		.decoder      = EM28XX_TVP5150,
1036
		.input        = { {
1037
			.type     = EM28XX_VMUX_TELEVISION,
1038
			.vmux     = TVP5150_COMPOSITE0,
1039
			.amux     = EM28XX_AMUX_VIDEO,
1040
		}, {
1041
			.type     = EM28XX_VMUX_COMPOSITE1,
1042
			.vmux     = TVP5150_COMPOSITE1,
1043
			.amux     = EM28XX_AMUX_LINE_IN,
1044
		}, {
1045
			.type     = EM28XX_VMUX_SVIDEO,
1046
			.vmux     = TVP5150_SVIDEO,
1047
			.amux     = EM28XX_AMUX_LINE_IN,
1048
		} },
1049
	},
1050 1051 1052 1053 1054
	[EM2882_BOARD_TERRATEC_HYBRID_XS] = {
		.name         = "Terratec Hybrid XS (em2882)",
		.valid        = EM28XX_BOARD_NOT_VALIDATED,
		.tuner_type   = TUNER_XC2028,
		.decoder      = EM28XX_TVP5150,
1055
		.input        = { {
1056 1057
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = TVP5150_COMPOSITE0,
1058
			.amux     = EM28XX_AMUX_VIDEO,
1059
		}, {
1060
			.type     = EM28XX_VMUX_COMPOSITE1,
1061
			.vmux     = TVP5150_COMPOSITE1,
1062
			.amux     = EM28XX_AMUX_LINE_IN,
1063
		}, {
1064
			.type     = EM28XX_VMUX_SVIDEO,
1065
			.vmux     = TVP5150_SVIDEO,
1066
			.amux     = EM28XX_AMUX_LINE_IN,
1067
		} },
1068
	},
1069 1070 1071 1072 1073
	[EM2883_BOARD_KWORLD_HYBRID_A316] = {
		.name         = "Kworld PlusTV HD Hybrid 330",
		.valid        = EM28XX_BOARD_NOT_VALIDATED,
		.tuner_type   = TUNER_XC2028,
		.decoder      = EM28XX_TVP5150,
1074
		.input        = { {
1075
			.type     = EM28XX_VMUX_TELEVISION,
1076
			.vmux     = TVP5150_COMPOSITE0,
1077
			.amux     = EM28XX_AMUX_VIDEO,
1078
		}, {
1079
			.type     = EM28XX_VMUX_COMPOSITE1,
1080
			.vmux     = TVP5150_COMPOSITE1,
1081
			.amux     = EM28XX_AMUX_LINE_IN,
1082
		}, {
1083
			.type     = EM28XX_VMUX_SVIDEO,
1084
			.vmux     = TVP5150_SVIDEO,
1085
			.amux     = EM28XX_AMUX_LINE_IN,
1086 1087
		} },
	},
1088
	[EM2820_BOARD_COMPRO_VIDEOMATE_FORYOU] = {
1089 1090 1091 1092
		.name         = "Compro VideoMate ForYou/Stereo",
		.tuner_type   = TUNER_LG_PAL_NEW_TAPC,
		.tda9887_conf = TDA9887_PRESENT,
		.decoder      = EM28XX_TVP5150,
1093
		.input        = { {
1094 1095 1096 1097 1098 1099 1100 1101 1102
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = TVP5150_COMPOSITE0,
			.amux     = EM28XX_AMUX_LINE_IN,
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = TVP5150_SVIDEO,
			.amux     = EM28XX_AMUX_LINE_IN,
		} },
	},
1103 1104 1105
	[EM2874_BOARD_PINNACLE_PCTV_80E] = {
		.name         = "Pinnacle PCTV HD Mini",
		.tuner_type   = TUNER_ABSENT,
1106 1107
		.has_dvb      = 1,
		.ir_codes     = ir_codes_pinnacle_pctv_hd,
1108
		.decoder      = EM28XX_NODECODER,
1109 1110 1111
		.i2c_speed    = EM28XX_I2C_CLK_WAIT_ENABLE |
				EM2874_I2C_SECONDARY_BUS_SELECT |
				EM28XX_I2C_FREQ_400_KHZ,
1112
#ifdef DJH_DEBUG
1113
		.input        = { {
1114 1115 1116 1117 1118 1119
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = TVP5150_COMPOSITE0,
			.amux     = EM28XX_AMUX_LINE_IN,
		} },
#endif
	},
1120
};
1121
const unsigned int em28xx_bcount = ARRAY_SIZE(em28xx_boards);
1122 1123

/* table of devices that work with this driver */
1124
struct usb_device_id em28xx_id_table [] = {
1125
	{ USB_DEVICE(0xeb1a, 0x2750),
1126 1127 1128
			.driver_info = EM2750_BOARD_UNKNOWN },
	{ USB_DEVICE(0xeb1a, 0x2751),
			.driver_info = EM2750_BOARD_UNKNOWN },
1129 1130 1131 1132 1133
	{ USB_DEVICE(0xeb1a, 0x2800),
			.driver_info = EM2800_BOARD_UNKNOWN },
	{ USB_DEVICE(0xeb1a, 0x2820),
			.driver_info = EM2820_BOARD_UNKNOWN },
	{ USB_DEVICE(0xeb1a, 0x2821),
1134
			.driver_info = EM2820_BOARD_PROLINK_PLAYTV_USB2 },
1135 1136 1137 1138 1139 1140 1141 1142 1143 1144
	{ USB_DEVICE(0xeb1a, 0x2860),
			.driver_info = EM2820_BOARD_UNKNOWN },
	{ USB_DEVICE(0xeb1a, 0x2861),
			.driver_info = EM2820_BOARD_UNKNOWN },
	{ USB_DEVICE(0xeb1a, 0x2870),
			.driver_info = EM2820_BOARD_UNKNOWN },
	{ USB_DEVICE(0xeb1a, 0x2881),
			.driver_info = EM2820_BOARD_UNKNOWN },
	{ USB_DEVICE(0xeb1a, 0x2883),
			.driver_info = EM2820_BOARD_UNKNOWN },
1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164
	{ USB_DEVICE(0xeb1a, 0xe300),
			.driver_info = EM2861_BOARD_KWORLD_PVRTV_300U },
	{ USB_DEVICE(0xeb1a, 0xe305),
			.driver_info = EM2880_BOARD_KWORLD_DVB_305U },
	{ USB_DEVICE(0xeb1a, 0xe310),
			.driver_info = EM2880_BOARD_MSI_DIGIVOX_AD },
	{ USB_DEVICE(0xeb1a, 0xa316),
			.driver_info = EM2883_BOARD_KWORLD_HYBRID_A316 },
	{ USB_DEVICE(0xeb1a, 0xe320),
			.driver_info = EM2880_BOARD_MSI_DIGIVOX_AD_II },
	{ USB_DEVICE(0xeb1a, 0xe323),
			.driver_info = EM2882_BOARD_KWORLD_VS_DVBT },
	{ USB_DEVICE(0xeb1a, 0xe350),
			.driver_info = EM2870_BOARD_KWORLD_350U },
	{ USB_DEVICE(0xeb1a, 0xe355),
			.driver_info = EM2870_BOARD_KWORLD_355U },
	{ USB_DEVICE(0xeb1a, 0x2801),
			.driver_info = EM2800_BOARD_GRABBEEX_USB2800 },
	{ USB_DEVICE(0xeb1a, 0xe357),
			.driver_info = EM2870_BOARD_KWORLD_355U },
1165 1166
	{ USB_DEVICE(0x0ccd, 0x0036),
			.driver_info = EM2820_BOARD_TERRATEC_CINERGY_250 },
1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180
	{ USB_DEVICE(0x0ccd, 0x004c),
			.driver_info = EM2880_BOARD_TERRATEC_HYBRID_XS_FR },
	{ USB_DEVICE(0x0ccd, 0x004f),
			.driver_info = EM2860_BOARD_TERRATEC_HYBRID_XS },
	{ USB_DEVICE(0x0ccd, 0x005e),
			.driver_info = EM2882_BOARD_TERRATEC_HYBRID_XS },
	{ USB_DEVICE(0x0ccd, 0x0042),
			.driver_info = EM2880_BOARD_TERRATEC_HYBRID_XS },
	{ USB_DEVICE(0x0ccd, 0x0043),
			.driver_info = EM2870_BOARD_TERRATEC_XS },
	{ USB_DEVICE(0x0ccd, 0x0047),
			.driver_info = EM2880_BOARD_TERRATEC_PRODIGY_XS },
	{ USB_DEVICE(0x185b, 0x2870),
			.driver_info = EM2870_BOARD_COMPRO_VIDEOMATE },
1181
	{ USB_DEVICE(0x185b, 0x2041),
1182
			.driver_info = EM2820_BOARD_COMPRO_VIDEOMATE_FORYOU },
1183 1184
	{ USB_DEVICE(0x2040, 0x4200),
			.driver_info = EM2820_BOARD_HAUPPAUGE_WINTV_USB_2 },
1185 1186
	{ USB_DEVICE(0x2040, 0x4201),
			.driver_info = EM2820_BOARD_HAUPPAUGE_WINTV_USB_2 },
1187 1188
	{ USB_DEVICE(0x2040, 0x6500),
			.driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900 },
1189
	{ USB_DEVICE(0x2040, 0x6502),
1190
			.driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900_R2 },
1191
	{ USB_DEVICE(0x2040, 0x6513), /* HCW HVR-980 */
1192
			.driver_info = EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950 },
1193
	{ USB_DEVICE(0x2040, 0x6517), /* HP  HVR-950 */
1194
			.driver_info = EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950 },
1195
	{ USB_DEVICE(0x2040, 0x651b), /* RP  HVR-950 */
1196
			.driver_info = EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950 },
1197
	{ USB_DEVICE(0x2040, 0x651f), /* HCW HVR-850 */
1198
			.driver_info = EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950 },
1199 1200
	{ USB_DEVICE(0x0438, 0xb002),
			.driver_info = EM2880_BOARD_AMD_ATI_TV_WONDER_HD_600 },
1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212
	{ USB_DEVICE(0x2001, 0xf112),
			.driver_info = EM2820_BOARD_DLINK_USB_TV },
	{ USB_DEVICE(0x2304, 0x0207),
			.driver_info = EM2820_BOARD_PINNACLE_DVC_90 },
	{ USB_DEVICE(0x2304, 0x0208),
			.driver_info = EM2820_BOARD_PINNACLE_USB_2 },
	{ USB_DEVICE(0x2304, 0x021a),
			.driver_info = EM2820_BOARD_PINNACLE_DVC_90 },
	{ USB_DEVICE(0x2304, 0x0226),
			.driver_info = EM2882_BOARD_PINNACLE_HYBRID_PRO },
	{ USB_DEVICE(0x2304, 0x0227),
			.driver_info = EM2880_BOARD_PINNACLE_PCTV_HD_PRO },
1213 1214
	{ USB_DEVICE(0x2304, 0x023f),
			.driver_info = EM2874_BOARD_PINNACLE_PCTV_80E },
1215 1216 1217 1218
	{ USB_DEVICE(0x0413, 0x6023),
			.driver_info = EM2800_BOARD_LEADTEK_WINFAST_USBII },
	{ USB_DEVICE(0x093b, 0xa005),
			.driver_info = EM2861_BOARD_PLEXTOR_PX_TV100U },
1219 1220
	{ },
};
1221
MODULE_DEVICE_TABLE(usb, em28xx_id_table);
1222

1223 1224 1225
/*
 * EEPROM hash table for devices with generic USB IDs
 */
1226
static struct em28xx_hash_table em28xx_eeprom_hash [] = {
1227
	/* P/N: SA 60002070465 Tuner: TVF7533-MF */
1228
	{0x6ce05a8f, EM2820_BOARD_PROLINK_PLAYTV_USB2, TUNER_YMEC_TVF_5533MF},
1229
	{0x966a0441, EM2880_BOARD_KWORLD_DVB_310U, TUNER_XC2028},
1230
};
1231

1232
/* I2C devicelist hash table for devices with generic USB IDs */
1233
static struct em28xx_hash_table em28xx_i2c_hash[] = {
1234 1235
	{0xb06a32c3, EM2800_BOARD_TERRATEC_CINERGY_200, TUNER_LG_PAL_NEW_TAPC},
	{0xf51200e3, EM2800_BOARD_VGEAR_POCKETTV, TUNER_LG_PAL_NEW_TAPC},
1236
	{0x1ba50080, EM2860_BOARD_POINTNIX_INTRAORAL_CAMERA, TUNER_ABSENT},
1237 1238
};

1239
int em28xx_tuner_callback(void *ptr, int component, int command, int arg)
1240
{
1241
	int rc = 0;
1242 1243 1244 1245 1246 1247 1248 1249
	struct em28xx *dev = ptr;

	if (dev->tuner_type != TUNER_XC2028)
		return 0;

	if (command != XC2028_TUNER_RESET)
		return 0;

1250
	rc = em28xx_gpio_set(dev, dev->tuner_gpio);
1251 1252 1253 1254 1255

	return rc;
}
EXPORT_SYMBOL_GPL(em28xx_tuner_callback);

1256
static void inline em28xx_set_model(struct em28xx *dev)
1257
{
1258
	memcpy(&dev->board, &em28xx_boards[dev->model], sizeof(dev->board));
1259 1260
}

1261 1262 1263
/* Since em28xx_pre_card_setup() requires a proper dev->model,
 * this won't work for boards with generic PCI IDs
 */
1264 1265
void em28xx_pre_card_setup(struct em28xx *dev)
{
1266 1267
	int rc;

1268 1269 1270 1271
	em28xx_set_model(dev);

	em28xx_info("Found %s\n", dev->board.name);

1272 1273 1274
	/* Set the default GPO/GPIO for legacy devices */
	dev->reg_gpo_num = EM2880_R04_GPO;
	dev->reg_gpio_num = EM28XX_R08_GPIO;
1275

1276
	dev->wait_after_write = 5;
1277 1278

	/* Based on the Chip ID, set the device configuration */
1279
	rc = em28xx_read_reg(dev, EM28XX_R0A_CHIPID);
1280
	if (rc > 0) {
1281
		dev->chip_id = rc;
1282 1283

		switch (dev->chip_id) {
1284 1285 1286
		case CHIP_ID_EM2750:
			em28xx_info("chip ID is em2750\n");
			break;
1287 1288 1289 1290 1291 1292
		case CHIP_ID_EM2820:
			em28xx_info("chip ID is em2820\n");
			break;
		case CHIP_ID_EM2840:
			em28xx_info("chip ID is em2840\n");
			break;
1293 1294 1295
		case CHIP_ID_EM2860:
			em28xx_info("chip ID is em2860\n");
			break;
1296 1297
		case CHIP_ID_EM2874:
			em28xx_info("chip ID is em2874\n");
1298
			dev->reg_gpio_num = EM2874_R80_GPIO;
1299 1300
			dev->wait_after_write = 0;
			break;
1301
		case CHIP_ID_EM2883:
1302 1303 1304 1305
			em28xx_info("chip ID is em2882/em2883\n");
			dev->wait_after_write = 0;
			break;
		default:
1306
			em28xx_info("em28xx chip ID = %d\n", dev->chip_id);
1307 1308
		}
	}
1309 1310 1311 1312 1313 1314

	/* Prepopulate cached GPO register content */
	rc = em28xx_read_reg(dev, dev->reg_gpo_num);
	if (rc >= 0)
		dev->reg_gpo = rc;

1315 1316 1317
	/* Those are the default values for the majority of boards
	   Use those values if not specified otherwise at boards entry
	 */
1318 1319 1320
	if (!dev->board.xclk)
		dev->board.xclk = EM28XX_XCLK_IR_RC5_MODE |
				  EM28XX_XCLK_FREQUENCY_12MHZ;
1321

1322 1323 1324
	if (!dev->board.i2c_speed)
		dev->board.i2c_speed = EM28XX_I2C_CLK_WAIT_ENABLE |
				       EM28XX_I2C_FREQ_100_KHZ;
1325

1326 1327
	em28xx_write_reg(dev, EM28XX_R0F_XCLK, dev->board.xclk & 0x7f);
	em28xx_write_reg(dev, EM28XX_R06_I2C_CLK, dev->board.i2c_speed);
1328 1329
	msleep(50);

1330
	/* request some modules */
1331
	switch (dev->model) {
1332 1333
	case EM2880_BOARD_TERRATEC_PRODIGY_XS:
	case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900:
1334
	case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900_R2:
1335
	case EM2860_BOARD_TERRATEC_HYBRID_XS:
1336
	case EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950:
1337
	case EM2880_BOARD_PINNACLE_PCTV_HD_PRO:
1338 1339
	case EM2882_BOARD_PINNACLE_HYBRID_PRO:
	case EM2883_BOARD_KWORLD_HYBRID_A316:
1340
	case EM2880_BOARD_AMD_ATI_TV_WONDER_HD_600:
1341 1342 1343
		/* Sets GPO/GPIO sequences for this device */
		dev->analog_gpio      = hauppauge_wintv_hvr_900_analog;
		dev->digital_gpio     = hauppauge_wintv_hvr_900_digital;
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
		break;

	case EM2882_BOARD_TERRATEC_HYBRID_XS:
		/* Sets GPO/GPIO sequences for this device */
		dev->analog_gpio      = hauppauge_wintv_hvr_900_analog;
		dev->digital_gpio     = hauppauge_wintv_hvr_900_digital;
		break;

	case EM2880_BOARD_TERRATEC_HYBRID_XS_FR:
	case EM2880_BOARD_TERRATEC_HYBRID_XS:
	case EM2870_BOARD_TERRATEC_XS:
	case EM2881_BOARD_PINNACLE_HYBRID_PRO:
	case EM2880_BOARD_KWORLD_DVB_310U:
	case EM2870_BOARD_KWORLD_350U:
	case EM2881_BOARD_DNT_DA2_HYBRID:
		/* NOTE: EM2881_DNT_DA2_HYBRID spend 140 msleep for digital
			 and analog commands. If this commands doesn't work,
			 add this timer. */

		/* Sets GPO/GPIO sequences for this device */
		dev->analog_gpio      = default_analog;
		dev->digital_gpio     = default_digital;
		break;

	case EM2880_BOARD_MSI_DIGIVOX_AD:
	case EM2880_BOARD_MSI_DIGIVOX_AD_II:
		/* Sets GPO/GPIO sequences for this device */
		dev->analog_gpio      = em2880_msi_digivox_ad_analog;
		dev->digital_gpio     = em2880_msi_digivox_ad_digital;
		break;
1374

1375 1376 1377
	case EM2861_BOARD_PLEXTOR_PX_TV100U:
		/* FIXME guess */
		/* Turn on analog audio output */
1378
		em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xfd);
1379 1380 1381 1382
		break;

	case EM2861_BOARD_KWORLD_PVRTV_300U:
	case EM2880_BOARD_KWORLD_DVB_305U:
1383
		em28xx_write_reg(dev, EM28XX_R08_GPIO, 0x6d);
1384
		msleep(10);
1385
		em28xx_write_reg(dev, EM28XX_R08_GPIO, 0x7d);
1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396
		msleep(10);
		break;

	case EM2870_BOARD_KWORLD_355U:
		/* Sets GPO/GPIO sequences for this device */
		dev->digital_gpio     = em2870_kworld_355u_digital;
		break;

	case EM2870_BOARD_COMPRO_VIDEOMATE:
		/* TODO: someone can do some cleanup here...
			 not everything's needed */
1397
		em28xx_write_reg(dev, EM2880_R04_GPO, 0x00);
1398
		msleep(10);
1399
		em28xx_write_reg(dev, EM2880_R04_GPO, 0x01);
1400
		msleep(10);
1401
		em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xfd);
1402
		mdelay(70);
1403
		em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xfc);
1404
		mdelay(70);
1405
		em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xdc);
1406
		mdelay(70);
1407
		em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xfc);
1408 1409 1410 1411 1412 1413
		mdelay(70);
		break;

	case EM2870_BOARD_TERRATEC_XS_MT2060:
		/* this device needs some gpio writes to get the DVB-T
		   demod work */
1414
		em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xfe);
1415
		mdelay(70);
1416
		em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xde);
1417
		mdelay(70);
1418
		em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xfe);
1419 1420 1421 1422 1423 1424
		mdelay(70);
		break;

	case EM2870_BOARD_PINNACLE_PCTV_DVB:
		/* this device needs some gpio writes to get the
		   DVB-T demod work */
1425
		em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xfe);
1426
		mdelay(70);
1427
		em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xde);
1428
		mdelay(70);
1429
		em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xfe);
1430 1431 1432 1433 1434
		mdelay(70);
		break;

	case EM2820_BOARD_GADMEI_UTV310:
	case EM2820_BOARD_MSI_VOX_USB_2:
1435
		/* enables audio for that devices */
1436
		em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xfd);
1437
		break;
1438 1439 1440 1441

	case EM2874_BOARD_PINNACLE_PCTV_80E:
		dev->digital_gpio = em2874_pinnacle_80e_digital;
		break;
1442
	}
1443

1444 1445 1446 1447 1448
	/* Sets the default callback. Used only for certain tuners */
	if (!dev->tuner_gpio)
		dev->tuner_gpio       = default_callback;

	em28xx_gpio_set(dev, dev->tuner_gpio);
1449 1450 1451 1452
	em28xx_set_mode(dev, EM28XX_ANALOG_MODE);

	/* Unlock device */
	em28xx_set_mode(dev, EM28XX_MODE_UNDEFINED);
1453 1454
}

1455
static void em28xx_setup_xc3028(struct em28xx *dev, struct xc2028_ctrl *ctl)
1456 1457 1458 1459 1460 1461 1462 1463
{
	memset(ctl, 0, sizeof(*ctl));

	ctl->fname   = XC2028_DEFAULT_FIRMWARE;
	ctl->max_len = 64;
	ctl->mts = em28xx_boards[dev->model].mts_firmware;

	switch (dev->model) {
1464 1465 1466
	case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900:
		ctl->demod = XC3028_FE_ZARLINK456;
		break;
1467 1468 1469
	case EM2880_BOARD_TERRATEC_HYBRID_XS:
		ctl->demod = XC3028_FE_ZARLINK456;
		break;
1470 1471 1472 1473
	case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900_R2:
		/* djh - Not sure which demod we need here */
		ctl->demod = XC3028_FE_DEFAULT;
		break;
1474 1475 1476 1477
	case EM2880_BOARD_AMD_ATI_TV_WONDER_HD_600:
		ctl->demod = XC3028_FE_DEFAULT;
		ctl->fname = XC3028L_DEFAULT_FIRMWARE;
		break;
1478
	case EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950:
1479
	case EM2880_BOARD_PINNACLE_PCTV_HD_PRO:
1480
		/* FIXME: Better to specify the needed IF */
1481 1482
		ctl->demod = XC3028_FE_DEFAULT;
		break;
1483 1484 1485 1486 1487
	default:
		ctl->demod = XC3028_FE_OREN538;
	}
}

1488
static void em28xx_config_tuner(struct em28xx *dev)
1489 1490
{
	struct v4l2_priv_tun_config  xc2028_cfg;
1491 1492 1493
	struct tuner_setup           tun_setup;
	struct v4l2_frequency        f;

1494
	if (dev->tuner_type == TUNER_ABSENT)
1495 1496 1497 1498 1499 1500 1501 1502 1503 1504
		return;

	tun_setup.mode_mask = T_ANALOG_TV | T_RADIO;
	tun_setup.type = dev->tuner_type;
	tun_setup.addr = dev->tuner_addr;
	tun_setup.tuner_callback = em28xx_tuner_callback;

	em28xx_i2c_call_clients(dev, TUNER_SET_TYPE_ADDR, &tun_setup);

	if (dev->tuner_type == TUNER_XC2028) {
1505
		struct xc2028_ctrl           ctl;
1506

1507
		em28xx_setup_xc3028(dev, &ctl);
1508 1509 1510

		xc2028_cfg.tuner = TUNER_XC2028;
		xc2028_cfg.priv  = &ctl;
1511

1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525
		em28xx_i2c_call_clients(dev, TUNER_SET_CONFIG, &xc2028_cfg);
	}

	/* configure tuner */
	f.tuner = 0;
	f.type = V4L2_TUNER_ANALOG_TV;
	f.frequency = 9076;     /* just a magic number */
	dev->ctl_freq = f.frequency;
	em28xx_i2c_call_clients(dev, VIDIOC_S_FREQUENCY, &f);
}

static int em28xx_hint_board(struct em28xx *dev)
{
	int i;
1526

1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538
	/* HINT method: EEPROM
	 *
	 * This method works only for boards with eeprom.
	 * Uses a hash of all eeprom bytes. The hash should be
	 * unique for a vendor/tuner pair.
	 * There are a high chance that tuners for different
	 * video standards produce different hashes.
	 */
	for (i = 0; i < ARRAY_SIZE(em28xx_eeprom_hash); i++) {
		if (dev->hash == em28xx_eeprom_hash[i].hash) {
			dev->model = em28xx_eeprom_hash[i].model;
			dev->tuner_type = em28xx_eeprom_hash[i].tuner;
1539

1540 1541 1542 1543 1544 1545 1546 1547 1548 1549
			em28xx_errdev("Your board has no unique USB ID.\n");
			em28xx_errdev("A hint were successfully done, "
				      "based on eeprom hash.\n");
			em28xx_errdev("This method is not 100%% failproof.\n");
			em28xx_errdev("If the board were missdetected, "
				      "please email this log to:\n");
			em28xx_errdev("\tV4L Mailing List "
				      " <video4linux-list@redhat.com>\n");
			em28xx_errdev("Board detected as %s\n",
				      em28xx_boards[dev->model].name);
1550

1551 1552 1553
			return 0;
		}
	}
1554

1555 1556 1557 1558 1559 1560 1561 1562 1563
	/* HINT method: I2C attached devices
	 *
	 * This method works for all boards.
	 * Uses a hash of i2c scanned devices.
	 * Devices with the same i2c attached chips will
	 * be considered equal.
	 * This method is less precise than the eeprom one.
	 */

1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586
	/* user did not request i2c scanning => do it now */
	if (!dev->i2c_hash)
		em28xx_do_i2c_scan(dev);

	for (i = 0; i < ARRAY_SIZE(em28xx_i2c_hash); i++) {
		if (dev->i2c_hash == em28xx_i2c_hash[i].hash) {
			dev->model = em28xx_i2c_hash[i].model;
			dev->tuner_type = em28xx_i2c_hash[i].tuner;
			em28xx_errdev("Your board has no unique USB ID.\n");
			em28xx_errdev("A hint were successfully done, "
				      "based on i2c devicelist hash.\n");
			em28xx_errdev("This method is not 100%% failproof.\n");
			em28xx_errdev("If the board were missdetected, "
				      "please email this log to:\n");
			em28xx_errdev("\tV4L Mailing List "
				      " <video4linux-list@redhat.com>\n");
			em28xx_errdev("Board detected as %s\n",
				      em28xx_boards[dev->model].name);

			return 0;
		}
	}

1587 1588 1589 1590 1591 1592 1593
	em28xx_errdev("Your board has no unique USB ID and thus need a "
		      "hint to be detected.\n");
	em28xx_errdev("You may try to use card=<n> insmod option to "
		      "workaround that.\n");
	em28xx_errdev("Please send an email with this log to:\n");
	em28xx_errdev("\tV4L Mailing List <video4linux-list@redhat.com>\n");
	em28xx_errdev("Board eeprom hash is 0x%08lx\n", dev->hash);
1594
	em28xx_errdev("Board i2c devicelist hash is 0x%08lx\n", dev->i2c_hash);
1595 1596 1597 1598 1599 1600 1601 1602

	em28xx_errdev("Here is a list of valid choices for the card=<n>"
		      " insmod option:\n");
	for (i = 0; i < em28xx_bcount; i++) {
		em28xx_errdev("    card=%d -> %s\n",
				i, em28xx_boards[i].name);
	}
	return -1;
1603 1604
}

1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643
/* ----------------------------------------------------------------------- */
void em28xx_set_ir(struct em28xx *dev, struct IR_i2c *ir)
{
	if (disable_ir) {
		ir->get_key = NULL;
		return ;
	}

	/* detect & configure */
	switch (dev->model) {
	case (EM2800_BOARD_UNKNOWN):
		break;
	case (EM2820_BOARD_UNKNOWN):
		break;
	case (EM2800_BOARD_TERRATEC_CINERGY_200):
	case (EM2820_BOARD_TERRATEC_CINERGY_250):
		ir->ir_codes = ir_codes_em_terratec;
		ir->get_key = em28xx_get_key_terratec;
		snprintf(ir->c.name, sizeof(ir->c.name),
			 "i2c IR (EM28XX Terratec)");
		break;
	case (EM2820_BOARD_PINNACLE_USB_2):
		ir->ir_codes = ir_codes_pinnacle_grey;
		ir->get_key = em28xx_get_key_pinnacle_usb_grey;
		snprintf(ir->c.name, sizeof(ir->c.name),
			 "i2c IR (EM28XX Pinnacle PCTV)");
		break;
	case (EM2820_BOARD_HAUPPAUGE_WINTV_USB_2):
		ir->ir_codes = ir_codes_hauppauge_new;
		ir->get_key = em28xx_get_key_em_haup;
		snprintf(ir->c.name, sizeof(ir->c.name),
			 "i2c IR (EM2840 Hauppauge)");
		break;
	case (EM2820_BOARD_MSI_VOX_USB_2):
		break;
	case (EM2800_BOARD_LEADTEK_WINFAST_USBII):
		break;
	case (EM2800_BOARD_KWORLD_USB2800):
		break;
1644 1645
	case (EM2800_BOARD_GRABBEEX_USB2800):
		break;
1646 1647 1648
	}
}

1649
void em28xx_card_setup(struct em28xx *dev)
1650
{
1651 1652 1653
	em28xx_set_model(dev);

	dev->tuner_type = em28xx_boards[dev->model].tuner_type;
1654 1655
	if (em28xx_boards[dev->model].tuner_addr)
		dev->tuner_addr = em28xx_boards[dev->model].tuner_addr;
1656

1657
	/* request some modules */
1658 1659
	switch (dev->model) {
	case EM2820_BOARD_HAUPPAUGE_WINTV_USB_2:
1660
	case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900:
1661
	case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900_R2:
1662
	case EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950:
1663 1664
	{
		struct tveeprom tv;
1665
#ifdef CONFIG_MODULES
1666
		request_module("tveeprom");
1667
#endif
1668 1669 1670 1671
		/* Call first TVeeprom */

		dev->i2c_client.addr = 0xa0 >> 1;
		tveeprom_hauppauge_analog(&dev->i2c_client, &tv, dev->eedata);
1672

1673
		dev->tuner_type = tv.tuner_type;
1674

1675
		if (tv.audio_processor == V4L2_IDENT_MSPX4XX) {
1676
			dev->i2s_speed = 2048000;
1677
			dev->board.has_msp34xx = 1;
1678
		}
1679 1680 1681 1682
#ifdef CONFIG_MODULES
		if (tv.has_ir)
			request_module("ir-kbd-i2c");
#endif
1683
		break;
1684
	}
1685 1686
	case EM2820_BOARD_KWORLD_PVRTV2800RF:
		/* GPIO enables sound on KWORLD PVR TV 2800RF */
1687
		em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xf9);
1688 1689 1690
		break;
	case EM2820_BOARD_UNKNOWN:
	case EM2800_BOARD_UNKNOWN:
1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704
		/*
		 * The K-WORLD DVB-T 310U is detected as an MSI Digivox AD.
		 *
		 * This occurs because they share identical USB vendor and
		 * product IDs.
		 *
		 * What we do here is look up the EEPROM hash of the K-WORLD
		 * and if it is found then we decide that we do not have
		 * a DIGIVOX and reset the device to the K-WORLD instead.
		 *
		 * This solution is only valid if they do not share eeprom
		 * hash identities which has not been determined as yet.
		 */
	case EM2880_BOARD_MSI_DIGIVOX_AD:
1705 1706
		if (!em28xx_hint_board(dev))
			em28xx_set_model(dev);
1707
		break;
1708 1709
	}

1710
	if (dev->board.has_snapshot_button)
1711 1712
		em28xx_register_snapshot_button(dev);

1713
	if (dev->board.valid == EM28XX_BOARD_NOT_VALIDATED) {
1714 1715 1716 1717 1718 1719 1720 1721
		em28xx_errdev("\n\n");
		em28xx_errdev("The support for this board weren't "
			      "valid yet.\n");
		em28xx_errdev("Please send a report of having this working\n");
		em28xx_errdev("not to V4L mailing list (and/or to other "
				"addresses)\n\n");
	}

1722
	/* Allow override tuner type by a module parameter */
1723 1724 1725 1726 1727
	if (tuner >= 0)
		dev->tuner_type = tuner;

#ifdef CONFIG_MODULES
	/* request some modules */
1728
	if (dev->board.has_msp34xx)
1729
		request_module("msp3400");
1730
	if (dev->board.decoder == EM28XX_SAA711X)
1731
		request_module("saa7115");
1732
	if (dev->board.decoder == EM28XX_TVP5150)
1733
		request_module("tvp5150");
1734
	if (dev->board.tuner_type != TUNER_ABSENT)
1735 1736 1737
		request_module("tuner");
#endif

1738
	em28xx_config_tuner(dev);
1739 1740

	em28xx_ir_init(dev);
1741
}
1742