em28xx-cards.c 53.0 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
/*
 *  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 */

/* Board  - EM2870 Kworld 355u
   Analog - No input analog */

/* Callback for the most boards */
97
static struct em28xx_reg_seq default_tuner_gpio[] = {
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
	{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
 */
118
struct em28xx_board em28xx_boards[] = {
119 120
	[EM2750_BOARD_UNKNOWN] = {
		.name          = "Unknown EM2750/EM2751 webcam grabber",
121
		.xclk          = EM28XX_XCLK_FREQUENCY_48MHZ,
122
		.tuner_type    = TUNER_ABSENT,	/* This is a webcam */
123 124 125
		.input         = { {
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = 0,
126
			.amux     = EM28XX_AMUX_VIDEO,
127 128
		} },
	},
129 130 131 132
	[EM2800_BOARD_UNKNOWN] = {
		.name         = "Unknown EM2800 video grabber",
		.is_em2800    = 1,
		.tda9887_conf = TDA9887_PRESENT,
133
		.decoder      = EM28XX_SAA711X,
134
		.tuner_type   = TUNER_ABSENT,
135
		.input        = { {
136
			.type     = EM28XX_VMUX_COMPOSITE1,
137
			.vmux     = SAA7115_COMPOSITE0,
138
			.amux     = EM28XX_AMUX_LINE_IN,
139
		}, {
140
			.type     = EM28XX_VMUX_SVIDEO,
141
			.vmux     = SAA7115_SVIDEO3,
142
			.amux     = EM28XX_AMUX_LINE_IN,
143
		} },
144 145
	},
	[EM2820_BOARD_UNKNOWN] = {
146 147
		.name          = "Unknown EM2750/28xx video grabber",
		.tuner_type    = TUNER_ABSENT,
148
	},
149 150 151 152
	[EM2750_BOARD_DLCW_130] = {
		/* Beijing Huaqi Information Digital Technology Co., Ltd */
		.name          = "Huaqi DLCW-130",
		.valid         = EM28XX_BOARD_NOT_VALIDATED,
153
		.xclk          = EM28XX_XCLK_FREQUENCY_48MHZ,
154
		.tuner_type    = TUNER_ABSENT,	/* This is a webcam */
155 156 157
		.input         = { {
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = 0,
158
			.amux     = EM28XX_AMUX_VIDEO,
159 160
		} },
	},
161
	[EM2820_BOARD_KWORLD_PVRTV2800RF] = {
162
		.name         = "Kworld PVR TV 2800 RF",
163
		.tuner_type   = TUNER_TEMIC_PAL,
164
		.tda9887_conf = TDA9887_PRESENT,
165
		.decoder      = EM28XX_SAA711X,
166
		.input        = { {
167
			.type     = EM28XX_VMUX_COMPOSITE1,
168
			.vmux     = SAA7115_COMPOSITE0,
169
			.amux     = EM28XX_AMUX_LINE_IN,
170
		}, {
171
			.type     = EM28XX_VMUX_SVIDEO,
172
			.vmux     = SAA7115_SVIDEO3,
173
			.amux     = EM28XX_AMUX_LINE_IN,
174
		} },
175
	},
176 177 178 179
	[EM2820_BOARD_TERRATEC_CINERGY_250] = {
		.name         = "Terratec Cinergy 250 USB",
		.tuner_type   = TUNER_LG_PAL_NEW_TAPC,
		.tda9887_conf = TDA9887_PRESENT,
180
		.decoder      = EM28XX_SAA711X,
181
		.input        = { {
182
			.type     = EM28XX_VMUX_TELEVISION,
183
			.vmux     = SAA7115_COMPOSITE2,
184
			.amux     = EM28XX_AMUX_LINE_IN,
185
		}, {
186
			.type     = EM28XX_VMUX_COMPOSITE1,
187
			.vmux     = SAA7115_COMPOSITE0,
188
			.amux     = EM28XX_AMUX_LINE_IN,
189
		}, {
190
			.type     = EM28XX_VMUX_SVIDEO,
191
			.vmux     = SAA7115_SVIDEO3,
192
			.amux     = EM28XX_AMUX_LINE_IN,
193
		} },
194 195 196 197 198
	},
	[EM2820_BOARD_PINNACLE_USB_2] = {
		.name         = "Pinnacle PCTV USB 2",
		.tuner_type   = TUNER_LG_PAL_NEW_TAPC,
		.tda9887_conf = TDA9887_PRESENT,
199
		.decoder      = EM28XX_SAA711X,
200
		.input        = { {
201
			.type     = EM28XX_VMUX_TELEVISION,
202
			.vmux     = SAA7115_COMPOSITE2,
203
			.amux     = EM28XX_AMUX_VIDEO,
204
		}, {
205
			.type     = EM28XX_VMUX_COMPOSITE1,
206
			.vmux     = SAA7115_COMPOSITE0,
207
			.amux     = EM28XX_AMUX_LINE_IN,
208
		}, {
209
			.type     = EM28XX_VMUX_SVIDEO,
210
			.vmux     = SAA7115_SVIDEO3,
211
			.amux     = EM28XX_AMUX_LINE_IN,
212
		} },
213 214 215 216
	},
	[EM2820_BOARD_HAUPPAUGE_WINTV_USB_2] = {
		.name         = "Hauppauge WinTV USB 2",
		.tuner_type   = TUNER_PHILIPS_FM1236_MK3,
217 218 219
		.tda9887_conf = TDA9887_PRESENT |
				TDA9887_PORT1_ACTIVE|
				TDA9887_PORT2_ACTIVE,
220
		.decoder      = EM28XX_TVP5150,
221
		.has_msp34xx  = 1,
222
		.input        = { {
223
			.type     = EM28XX_VMUX_TELEVISION,
224
			.vmux     = TVP5150_COMPOSITE0,
225
			.amux     = MSP_INPUT_DEFAULT,
226
		}, {
227
			.type     = EM28XX_VMUX_SVIDEO,
228
			.vmux     = TVP5150_SVIDEO,
229 230
			.amux     = MSP_INPUT(MSP_IN_SCART1, MSP_IN_TUNER1,
					MSP_DSP_IN_SCART, MSP_DSP_IN_SCART),
231
		} },
232
	},
233 234 235 236 237
	[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,
238
		.decoder      = EM28XX_SAA711X,
239
		.input        = { {
240 241
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = SAA7115_COMPOSITE2,
242
			.amux     = EM28XX_AMUX_LINE_IN,
243 244 245
		}, {
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = SAA7115_COMPOSITE0,
246
			.amux     = EM28XX_AMUX_LINE_IN,
247 248 249
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = SAA7115_SVIDEO3,
250
			.amux     = EM28XX_AMUX_LINE_IN,
251 252 253 254 255 256 257
		} },
	},
	[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,
258
		.decoder      = EM28XX_SAA711X,
259 260 261
		.input        = { {
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = SAA7115_COMPOSITE2,
262
			.amux     = EM28XX_AMUX_LINE_IN,
263 264 265
		}, {
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = SAA7115_COMPOSITE0,
266
			.amux     = EM28XX_AMUX_LINE_IN,
267 268 269
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = SAA7115_SVIDEO3,
270
			.amux     = EM28XX_AMUX_LINE_IN,
271 272 273 274 275 276 277
		} },
	},
	[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,
278
		.decoder      = EM28XX_SAA711X,
279
		.input        = { {
280 281
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = SAA7115_COMPOSITE2,
282
			.amux     = EM28XX_AMUX_VIDEO,
283 284 285
		}, {
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = SAA7115_COMPOSITE0,
286
			.amux     = EM28XX_AMUX_LINE_IN,
287 288 289
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = SAA7115_SVIDEO3,
290
			.amux     = EM28XX_AMUX_LINE_IN,
291 292 293 294 295 296 297
		} },
	},
	[EM2820_BOARD_GADMEI_UTV310] = {
		.name         = "Gadmei UTV310",
		.valid        = EM28XX_BOARD_NOT_VALIDATED,
		.tuner_type   = TUNER_TNF_5335MF,
		.tda9887_conf = TDA9887_PRESENT,
298
		.decoder      = EM28XX_SAA711X,
299
		.input        = { {
300 301
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = SAA7115_COMPOSITE1,
302
			.amux     = EM28XX_AMUX_LINE_IN,
303 304 305
		}, {
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = SAA7115_COMPOSITE0,
306
			.amux     = EM28XX_AMUX_LINE_IN,
307 308 309
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = SAA7115_SVIDEO3,
310
			.amux     = EM28XX_AMUX_LINE_IN,
311 312 313 314 315 316 317
		} },
	},
	[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,
318
		.decoder      = EM28XX_SAA711X,
319
		.input        = { {
320
			.type     = EM28XX_VMUX_TELEVISION,
321
			.vmux     = SAA7115_COMPOSITE2,
322
			.amux     = EM28XX_AMUX_VIDEO,
323 324
		}, {
			.type     = EM28XX_VMUX_COMPOSITE1,
325
			.vmux     = SAA7115_COMPOSITE0,
326
			.amux     = EM28XX_AMUX_LINE_IN,
327 328
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
329
			.vmux     = SAA7115_COMPOSITE0,
330
			.amux     = EM28XX_AMUX_LINE_IN,
331 332 333 334
		} },
	},
	[EM2820_BOARD_PINNACLE_DVC_100] = {
		.name         = "Pinnacle Dazzle DVC 100",
335
		.decoder      = EM28XX_SAA711X,
336
		.tuner_type   = TUNER_ABSENT,	/* Capture only device */
337
		.input        = { {
338 339
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = SAA7115_COMPOSITE0,
340
			.amux     = EM28XX_AMUX_LINE_IN,
341 342 343
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = SAA7115_SVIDEO3,
344
			.amux     = EM28XX_AMUX_LINE_IN,
345 346 347
		} },
	},
	[EM2820_BOARD_VIDEOLOGY_20K14XUSB] = {
348
		.name         = "Videology 20K14XUSB USB2.0",
349
		.valid        = EM28XX_BOARD_NOT_VALIDATED,
350
		.tuner_type   = TUNER_ABSENT,	/* This is a webcam */
351
		.input        = { {
352 353
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = 0,
354
			.amux     = EM28XX_AMUX_VIDEO,
355 356 357 358 359 360 361
		} },
	},
	[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? */
362
		.decoder      = EM28XX_SAA711X,
363
		.input        = { {
364 365
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = SAA7115_COMPOSITE2,
366
			.amux     = EM28XX_AMUX_LINE_IN,
367 368 369
		}, {
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = SAA7115_COMPOSITE0,
370
			.amux     = EM28XX_AMUX_LINE_IN,
371 372 373
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = SAA7115_SVIDEO3,
374
			.amux     = EM28XX_AMUX_LINE_IN,
375 376 377 378 379 380 381 382 383
		} },
	},
	[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,
384
		.decoder      = EM28XX_SAA711X,
385
		.input        = { {
386 387
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = SAA7115_COMPOSITE2,
388
			.amux     = EM28XX_AMUX_LINE_IN,
389 390 391
		}, {
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = SAA7115_COMPOSITE0,
392
			.amux     = EM28XX_AMUX_VIDEO,
393 394 395
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = SAA7115_SVIDEO3,
396
			.amux     = EM28XX_AMUX_LINE_IN,
397 398 399
		} },
	},
	[EM2821_BOARD_USBGEAR_VD204] = {
400
		.name         = "Usbgear VD204v9",
401
		.valid        = EM28XX_BOARD_NOT_VALIDATED,
402
		.tuner_type   = TUNER_ABSENT,	/* Capture only device */
403
		.decoder      = EM28XX_SAA711X,
404
		.input        = { {
405 406
			.type  = EM28XX_VMUX_COMPOSITE1,
			.vmux  = SAA7115_COMPOSITE0,
407
			.amux  = EM28XX_AMUX_LINE_IN,
408 409 410
		}, {
			.type  = EM28XX_VMUX_SVIDEO,
			.vmux  = SAA7115_SVIDEO3,
411
			.amux  = EM28XX_AMUX_LINE_IN,
412 413 414 415
		} },
	},
	[EM2860_BOARD_NETGMBH_CAM] = {
		/* Beijing Huaqi Information Digital Technology Co., Ltd */
416 417
		.name         = "NetGMBH Cam",
		.valid        = EM28XX_BOARD_NOT_VALIDATED,
418
		.tuner_type   = TUNER_ABSENT,	/* This is a webcam */
419
		.input        = { {
420 421
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = 0,
422
			.amux     = EM28XX_AMUX_VIDEO,
423 424 425
		} },
	},
	[EM2860_BOARD_TYPHOON_DVD_MAKER] = {
426
		.name         = "Typhoon DVD Maker",
427
		.decoder      = EM28XX_SAA711X,
428
		.tuner_type   = TUNER_ABSENT,	/* Capture only device */
429
		.input        = { {
430 431
			.type  = EM28XX_VMUX_COMPOSITE1,
			.vmux  = SAA7115_COMPOSITE0,
432
			.amux  = EM28XX_AMUX_LINE_IN,
433 434 435
		}, {
			.type  = EM28XX_VMUX_SVIDEO,
			.vmux  = SAA7115_SVIDEO3,
436
			.amux  = EM28XX_AMUX_LINE_IN,
437 438 439 440 441 442
		} },
	},
	[EM2860_BOARD_GADMEI_UTV330] = {
		.name         = "Gadmei UTV330",
		.valid        = EM28XX_BOARD_NOT_VALIDATED,
		.tuner_type   = TUNER_TNF_5335MF,
443
		.tda9887_conf = TDA9887_PRESENT,
444
		.decoder      = EM28XX_SAA711X,
445
		.input        = { {
446 447
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = SAA7115_COMPOSITE2,
448
			.amux     = EM28XX_AMUX_VIDEO,
449 450 451
		}, {
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = SAA7115_COMPOSITE0,
452
			.amux     = EM28XX_AMUX_LINE_IN,
453 454 455
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = SAA7115_SVIDEO3,
456
			.amux     = EM28XX_AMUX_LINE_IN,
457 458 459 460 461
		} },
	},
	[EM2860_BOARD_TERRATEC_HYBRID_XS] = {
		.name         = "Terratec Cinergy A Hybrid XS",
		.valid        = EM28XX_BOARD_NOT_VALIDATED,
462
		.tuner_type   = TUNER_XC2028,
463
		.tuner_gpio   = default_tuner_gpio,
464
		.decoder      = EM28XX_TVP5150,
465

466
		.input        = { {
467 468
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = TVP5150_COMPOSITE0,
469
			.amux     = EM28XX_AMUX_VIDEO,
470
			.gpio     = hauppauge_wintv_hvr_900_analog,
471
		}, {
472 473
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = TVP5150_COMPOSITE1,
474
			.amux     = EM28XX_AMUX_LINE_IN,
475
			.gpio     = hauppauge_wintv_hvr_900_analog,
476
		}, {
477 478
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = TVP5150_SVIDEO,
479
			.amux     = EM28XX_AMUX_LINE_IN,
480
			.gpio     = hauppauge_wintv_hvr_900_analog,
481
		} },
482
	},
483 484 485
	[EM2861_BOARD_KWORLD_PVRTV_300U] = {
		.name	      = "KWorld PVRTV 300U",
		.valid        = EM28XX_BOARD_NOT_VALIDATED,
486
		.tuner_type   = TUNER_XC2028,
487
		.tuner_gpio   = default_tuner_gpio,
488
		.decoder      = EM28XX_TVP5150,
489
		.input        = { {
490 491
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = TVP5150_COMPOSITE0,
492
			.amux     = EM28XX_AMUX_VIDEO,
493 494 495
		}, {
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = TVP5150_COMPOSITE1,
496
			.amux     = EM28XX_AMUX_LINE_IN,
497 498 499
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = TVP5150_SVIDEO,
500
			.amux     = EM28XX_AMUX_LINE_IN,
501 502
		} },
	},
503 504
	[EM2861_BOARD_YAKUMO_MOVIE_MIXER] = {
		.name          = "Yakumo MovieMixer",
505
		.tuner_type   = TUNER_ABSENT,	/* Capture only device */
506 507
		.decoder       = EM28XX_TVP5150,
		.input         = { {
508 509
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = TVP5150_COMPOSITE0,
510
			.amux     = EM28XX_AMUX_VIDEO,
511
		}, {
512 513
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = TVP5150_COMPOSITE1,
514
			.amux     = EM28XX_AMUX_LINE_IN,
515
		}, {
516 517
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = TVP5150_SVIDEO,
518
			.amux     = EM28XX_AMUX_LINE_IN,
519
		} },
520
	},
521 522 523 524 525 526
	[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,
527
		.input        = { {
528 529
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = TVP5150_COMPOSITE0,
530
			.amux     = EM28XX_AMUX_LINE_IN,
531 532 533
		}, {
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = TVP5150_COMPOSITE1,
534
			.amux     = EM28XX_AMUX_LINE_IN,
535 536 537
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = TVP5150_SVIDEO,
538
			.amux     = EM28XX_AMUX_LINE_IN,
539 540
		} },
	},
541 542 543

	/* Those boards with em2870 are DVB Only*/

544 545 546 547
	[EM2870_BOARD_TERRATEC_XS] = {
		.name         = "Terratec Cinergy T XS",
		.valid        = EM28XX_BOARD_NOT_VALIDATED,
		.tuner_type   = TUNER_XC2028,
548
		.tuner_gpio   = default_tuner_gpio,
549 550 551 552 553 554 555 556 557 558
	},
	[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,
559
		.tuner_gpio   = default_tuner_gpio,
560 561 562 563 564 565 566 567 568
	},
	[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 */
569 570 571
		/* djh - I have serious doubts this is right... */
		.xclk         = EM28XX_XCLK_IR_RC5_MODE |
				EM28XX_XCLK_FREQUENCY_10MHZ,
572 573 574 575 576 577
	},
	[EM2870_BOARD_COMPRO_VIDEOMATE] = {
		.name         = "Compro, VideoMate U3",
		.valid        = EM28XX_BOARD_NOT_VALIDATED,
		.tuner_type   = TUNER_ABSENT, /* MT2060 */
	},
578

579 580 581 582 583
	[EM2880_BOARD_TERRATEC_HYBRID_XS_FR] = {
		.name         = "Terratec Hybrid XS Secam",
		.valid        = EM28XX_BOARD_NOT_VALIDATED,
		.has_msp34xx  = 1,
		.tuner_type   = TUNER_XC2028,
584
		.tuner_gpio   = default_tuner_gpio,
585
		.decoder      = EM28XX_TVP5150,
586
		.input        = { {
587 588
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = TVP5150_COMPOSITE0,
589
			.amux     = EM28XX_AMUX_VIDEO,
590
			.gpio     = default_analog,
591 592 593
		}, {
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = TVP5150_COMPOSITE1,
594
			.amux     = EM28XX_AMUX_LINE_IN,
595
			.gpio     = default_analog,
596 597 598
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = TVP5150_SVIDEO,
599
			.amux     = EM28XX_AMUX_LINE_IN,
600
			.gpio     = default_analog,
601 602
		} },
	},
603 604 605 606
	[EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900] = {
		.name         = "Hauppauge WinTV HVR 900",
		.tda9887_conf = TDA9887_PRESENT,
		.tuner_type   = TUNER_XC2028,
607
		.tuner_gpio   = default_tuner_gpio,
608
		.mts_firmware = 1,
609
		.has_dvb      = 1,
610
		.dvb_gpio     = hauppauge_wintv_hvr_900_digital,
611
		.decoder      = EM28XX_TVP5150,
612
		.input        = { {
613 614
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = TVP5150_COMPOSITE0,
615
			.amux     = EM28XX_AMUX_VIDEO,
616
			.gpio     = hauppauge_wintv_hvr_900_analog,
617 618 619
		}, {
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = TVP5150_COMPOSITE1,
620
			.amux     = EM28XX_AMUX_LINE_IN,
621
			.gpio     = hauppauge_wintv_hvr_900_analog,
622 623 624
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = TVP5150_SVIDEO,
625
			.amux     = EM28XX_AMUX_LINE_IN,
626
			.gpio     = hauppauge_wintv_hvr_900_analog,
627 628 629 630 631 632
		} },
	},
	[EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900_R2] = {
		.name         = "Hauppauge WinTV HVR 900 (R2)",
		.tda9887_conf = TDA9887_PRESENT,
		.tuner_type   = TUNER_XC2028,
633
		.tuner_gpio   = default_tuner_gpio,
634 635
		.mts_firmware = 1,
		.decoder      = EM28XX_TVP5150,
636
		.input        = { {
637 638
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = TVP5150_COMPOSITE0,
639
			.amux     = EM28XX_AMUX_VIDEO,
640
			.gpio     = hauppauge_wintv_hvr_900_analog,
641 642 643
		}, {
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = TVP5150_COMPOSITE1,
644
			.amux     = EM28XX_AMUX_LINE_IN,
645
			.gpio     = hauppauge_wintv_hvr_900_analog,
646 647 648
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = TVP5150_SVIDEO,
649
			.amux     = EM28XX_AMUX_LINE_IN,
650
			.gpio     = hauppauge_wintv_hvr_900_analog,
651 652
		} },
	},
653
	[EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950] = {
654 655
		.name           = "Hauppauge WinTV HVR 950",
		.tuner_type     = TUNER_XC2028,
656
		.tuner_gpio     = default_tuner_gpio,
657 658
		.mts_firmware   = 1,
		.has_dvb        = 1,
659
		.dvb_gpio       = hauppauge_wintv_hvr_900_digital,
660
		.ir_codes       = ir_codes_hauppauge_new,
661 662 663 664
		.decoder        = EM28XX_TVP5150,
		.input          = { {
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = TVP5150_COMPOSITE0,
665
			.amux     = EM28XX_AMUX_VIDEO,
666
			.gpio     = hauppauge_wintv_hvr_900_analog,
667 668 669
		}, {
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = TVP5150_COMPOSITE1,
670
			.amux     = EM28XX_AMUX_LINE_IN,
671
			.gpio     = hauppauge_wintv_hvr_900_analog,
672 673 674
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = TVP5150_SVIDEO,
675
			.amux     = EM28XX_AMUX_LINE_IN,
676
			.gpio     = hauppauge_wintv_hvr_900_analog,
677 678 679 680 681
		} },
	},
	[EM2880_BOARD_PINNACLE_PCTV_HD_PRO] = {
		.name           = "Pinnacle PCTV HD Pro Stick",
		.tuner_type     = TUNER_XC2028,
682
		.tuner_gpio   = default_tuner_gpio,
683 684
		.mts_firmware   = 1,
		.has_dvb        = 1,
685
		.dvb_gpio       = hauppauge_wintv_hvr_900_digital,
686
		.ir_codes       = ir_codes_pinnacle_pctv_hd,
687 688 689 690
		.decoder        = EM28XX_TVP5150,
		.input          = { {
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = TVP5150_COMPOSITE0,
691
			.amux     = EM28XX_AMUX_VIDEO,
692
			.gpio     = hauppauge_wintv_hvr_900_analog,
693 694 695
		}, {
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = TVP5150_COMPOSITE1,
696
			.amux     = EM28XX_AMUX_LINE_IN,
697
			.gpio     = hauppauge_wintv_hvr_900_analog,
698 699 700
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = TVP5150_SVIDEO,
701
			.amux     = EM28XX_AMUX_LINE_IN,
702
			.gpio     = hauppauge_wintv_hvr_900_analog,
703 704 705 706 707
		} },
	},
	[EM2880_BOARD_AMD_ATI_TV_WONDER_HD_600] = {
		.name           = "AMD ATI TV Wonder HD 600",
		.tuner_type     = TUNER_XC2028,
708
		.tuner_gpio     = default_tuner_gpio,
709 710
		.mts_firmware   = 1,
		.has_dvb        = 1,
711
		.dvb_gpio       = hauppauge_wintv_hvr_900_digital,
712
		.ir_codes       = ir_codes_ati_tv_wonder_hd_600,
713 714 715 716
		.decoder        = EM28XX_TVP5150,
		.input          = { {
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = TVP5150_COMPOSITE0,
717
			.amux     = EM28XX_AMUX_VIDEO,
718
			.gpio     = hauppauge_wintv_hvr_900_analog,
719 720 721
		}, {
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = TVP5150_COMPOSITE1,
722
			.amux     = EM28XX_AMUX_LINE_IN,
723
			.gpio     = hauppauge_wintv_hvr_900_analog,
724 725 726
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = TVP5150_SVIDEO,
727
			.amux     = EM28XX_AMUX_LINE_IN,
728
			.gpio     = hauppauge_wintv_hvr_900_analog,
729 730 731
		} },
	},
	[EM2880_BOARD_TERRATEC_HYBRID_XS] = {
732 733
		.name           = "Terratec Hybrid XS",
		.tuner_type     = TUNER_XC2028,
734
		.tuner_gpio     = default_tuner_gpio,
735
		.decoder        = EM28XX_TVP5150,
736
		.has_dvb        = 1,
737
		.dvb_gpio       = default_analog,
738 739 740
		.input          = { {
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = TVP5150_COMPOSITE0,
741
			.amux     = EM28XX_AMUX_VIDEO,
742
			.gpio     = default_analog,
743 744 745
		}, {
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = TVP5150_COMPOSITE1,
746
			.amux     = EM28XX_AMUX_LINE_IN,
747
			.gpio     = default_analog,
748 749 750
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = TVP5150_SVIDEO,
751
			.amux     = EM28XX_AMUX_LINE_IN,
752
			.gpio     = default_analog,
753 754 755 756 757 758 759 760
		} },
	},
	/* 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,
761
		.tuner_gpio   = default_tuner_gpio,
762
		.decoder      = EM28XX_TVP5150,
763
		.input        = { {
764 765
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = TVP5150_COMPOSITE0,
766
			.amux     = EM28XX_AMUX_VIDEO,
767
			.gpio     = hauppauge_wintv_hvr_900_analog,
768 769 770
		}, {
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = TVP5150_COMPOSITE1,
771
			.amux     = EM28XX_AMUX_LINE_IN,
772
			.gpio     = hauppauge_wintv_hvr_900_analog,
773 774 775
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = TVP5150_SVIDEO,
776
			.amux     = EM28XX_AMUX_LINE_IN,
777
			.gpio     = hauppauge_wintv_hvr_900_analog,
778 779 780 781 782 783 784 785 786
		} },
	},
	[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,
787
		.decoder           = EM28XX_SAA711X,
788 789 790
		.input             = { {
			.type      = EM28XX_VMUX_TELEVISION,
			.vmux      = SAA7115_COMPOSITE4,
791
			.amux      = EM28XX_AMUX_VIDEO,
792 793 794
		}, {
			.type      = EM28XX_VMUX_COMPOSITE1,
			.vmux      = SAA7115_COMPOSITE0,
795
			.amux      = EM28XX_AMUX_LINE_IN,
796 797 798
		}, {
			.type      = EM28XX_VMUX_SVIDEO,
			.vmux      = SAA7115_SVIDEO3,
799
			.amux      = EM28XX_AMUX_LINE_IN,
800 801 802 803 804 805 806
		} },
	},
	[EM2800_BOARD_TERRATEC_CINERGY_200] = {
		.name         = "Terratec Cinergy 200 USB",
		.is_em2800    = 1,
		.tuner_type   = TUNER_LG_PAL_NEW_TAPC,
		.tda9887_conf = TDA9887_PRESENT,
807
		.decoder      = EM28XX_SAA711X,
808
		.input        = { {
809 810
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = SAA7115_COMPOSITE2,
811
			.amux     = EM28XX_AMUX_VIDEO,
812 813 814
		}, {
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = SAA7115_COMPOSITE0,
815
			.amux     = EM28XX_AMUX_LINE_IN,
816 817 818
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = SAA7115_SVIDEO3,
819
			.amux     = EM28XX_AMUX_LINE_IN,
820 821 822 823 824
		} },
	},
	[EM2800_BOARD_GRABBEEX_USB2800] = {
		.name         = "eMPIA Technology, Inc. GrabBeeX+ Video Encoder",
		.is_em2800    = 1,
825
		.decoder      = EM28XX_SAA711X,
826
		.tuner_type   = TUNER_ABSENT, /* capture only board */
827
		.input        = { {
828 829
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = SAA7115_COMPOSITE0,
830
			.amux     = EM28XX_AMUX_LINE_IN,
831 832 833
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = SAA7115_SVIDEO3,
834
			.amux     = EM28XX_AMUX_LINE_IN,
835 836 837 838 839 840 841
		} },
	},
	[EM2800_BOARD_LEADTEK_WINFAST_USBII] = {
		.name         = "Leadtek Winfast USB II",
		.is_em2800    = 1,
		.tuner_type   = TUNER_LG_PAL_NEW_TAPC,
		.tda9887_conf = TDA9887_PRESENT,
842
		.decoder      = EM28XX_SAA711X,
843
		.input        = { {
844 845
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = SAA7115_COMPOSITE2,
846
			.amux     = EM28XX_AMUX_VIDEO,
847 848 849
		}, {
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = SAA7115_COMPOSITE0,
850
			.amux     = EM28XX_AMUX_LINE_IN,
851 852 853
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = SAA7115_SVIDEO3,
854
			.amux     = EM28XX_AMUX_LINE_IN,
855 856 857 858 859 860 861
		} },
	},
	[EM2800_BOARD_KWORLD_USB2800] = {
		.name         = "Kworld USB2800",
		.is_em2800    = 1,
		.tuner_type   = TUNER_PHILIPS_FCV1236D,
		.tda9887_conf = TDA9887_PRESENT,
862
		.decoder      = EM28XX_SAA711X,
863
		.input        = { {
864 865
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = SAA7115_COMPOSITE2,
866
			.amux     = EM28XX_AMUX_VIDEO,
867 868 869
		}, {
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = SAA7115_COMPOSITE0,
870
			.amux     = EM28XX_AMUX_LINE_IN,
871 872 873
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = SAA7115_SVIDEO3,
874
			.amux     = EM28XX_AMUX_LINE_IN,
875 876 877 878
		} },
	},
	[EM2820_BOARD_PINNACLE_DVC_90] = {
		.name         = "Pinnacle Dazzle DVC 90/DVC 100",
879
		.tuner_type   = TUNER_ABSENT, /* capture only board */
880
		.decoder      = EM28XX_SAA711X,
881
		.input        = { {
882 883
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = SAA7115_COMPOSITE0,
884
			.amux     = EM28XX_AMUX_LINE_IN,
885 886 887
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = SAA7115_SVIDEO3,
888
			.amux     = EM28XX_AMUX_LINE_IN,
889 890 891 892 893 894 895
		} },
	},
	[EM2800_BOARD_VGEAR_POCKETTV] = {
		.name         = "V-Gear PocketTV",
		.is_em2800    = 1,
		.tuner_type   = TUNER_LG_PAL_NEW_TAPC,
		.tda9887_conf = TDA9887_PRESENT,
896
		.decoder      = EM28XX_SAA711X,
897
		.input        = { {
898 899
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = SAA7115_COMPOSITE2,
900
			.amux     = EM28XX_AMUX_VIDEO,
901 902 903
		}, {
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = SAA7115_COMPOSITE0,
904
			.amux     = EM28XX_AMUX_LINE_IN,
905 906 907
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = SAA7115_SVIDEO3,
908
			.amux     = EM28XX_AMUX_LINE_IN,
909 910 911 912 913 914
		} },
	},
	[EM2820_BOARD_PROLINK_PLAYTV_USB2] = {
		.name         = "Pixelview Prolink PlayTV USB 2.0",
		.tda9887_conf = TDA9887_PRESENT,
		.tuner_type   = TUNER_YMEC_TVF_5533MF,
915
		.decoder      = EM28XX_SAA711X,
916
		.input        = { {
917 918
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = SAA7115_COMPOSITE2,
919 920 921
			.amux     = EM28XX_AMUX_VIDEO,
			.aout     = EM28XX_AOUT_MONO | 	/* I2S */
				    EM28XX_AOUT_MASTER,	/* Line out pin */
922 923 924 925 926 927 928 929 930 931 932
		}, {
			.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] = {
933
		.name                = "PointNix Intra-Oral Camera",
934
		.has_snapshot_button = 1,
935 936
		.tda9887_conf        = TDA9887_PRESENT,
		.tuner_type          = TUNER_ABSENT,
937
		.decoder             = EM28XX_SAA711X,
938
		.input               = { {
939 940
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = SAA7115_SVIDEO3,
941
			.amux     = EM28XX_AMUX_VIDEO,
942 943 944 945 946 947
		} },
	},
	[EM2880_BOARD_MSI_DIGIVOX_AD] = {
		.name         = "MSI DigiVox A/D",
		.valid        = EM28XX_BOARD_NOT_VALIDATED,
		.tuner_type   = TUNER_XC2028,
948
		.tuner_gpio   = default_tuner_gpio,
949
		.decoder      = EM28XX_TVP5150,
950
		.input        = { {
951 952
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = TVP5150_COMPOSITE0,
953
			.amux     = EM28XX_AMUX_VIDEO,
954
			.gpio     = em2880_msi_digivox_ad_analog,
955 956 957
		}, {
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = TVP5150_COMPOSITE1,
958
			.amux     = EM28XX_AMUX_LINE_IN,
959
			.gpio     = em2880_msi_digivox_ad_analog,
960 961 962
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = TVP5150_SVIDEO,
963
			.amux     = EM28XX_AMUX_LINE_IN,
964
			.gpio     = em2880_msi_digivox_ad_analog,
965 966 967 968 969 970
		} },
	},
	[EM2880_BOARD_MSI_DIGIVOX_AD_II] = {
		.name         = "MSI DigiVox A/D II",
		.valid        = EM28XX_BOARD_NOT_VALIDATED,
		.tuner_type   = TUNER_XC2028,
971
		.tuner_gpio   = default_tuner_gpio,
972
		.decoder      = EM28XX_TVP5150,
973
		.input        = { {
974 975
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = TVP5150_COMPOSITE0,
976
			.amux     = EM28XX_AMUX_VIDEO,
977
			.gpio     = em2880_msi_digivox_ad_analog,
978 979 980
		}, {
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = TVP5150_COMPOSITE1,
981
			.amux     = EM28XX_AMUX_LINE_IN,
982
			.gpio     = em2880_msi_digivox_ad_analog,
983 984 985
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = TVP5150_SVIDEO,
986
			.amux     = EM28XX_AMUX_LINE_IN,
987
			.gpio     = em2880_msi_digivox_ad_analog,
988 989
		} },
	},
990 991 992
	[EM2880_BOARD_KWORLD_DVB_305U] = {
		.name	      = "KWorld DVB-T 305U",
		.valid        = EM28XX_BOARD_NOT_VALIDATED,
993
		.tuner_type   = TUNER_XC2028,
994
		.tuner_gpio   = default_tuner_gpio,
995
		.decoder      = EM28XX_TVP5150,
996
		.input        = { {
997 998
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = TVP5150_COMPOSITE0,
999
			.amux     = EM28XX_AMUX_VIDEO,
1000
		}, {
1001 1002
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = TVP5150_COMPOSITE1,
1003
			.amux     = EM28XX_AMUX_LINE_IN,
1004
		}, {
1005 1006
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = TVP5150_SVIDEO,
1007
			.amux     = EM28XX_AMUX_LINE_IN,
1008
		} },
1009
	},
1010 1011
	[EM2880_BOARD_KWORLD_DVB_310U] = {
		.name	      = "KWorld DVB-T 310U",
1012
		.tuner_type   = TUNER_XC2028,
1013
		.tuner_gpio   = default_tuner_gpio,
1014
		.has_dvb      = 1,
1015
		.dvb_gpio     = default_digital,
1016
		.mts_firmware = 1,
1017
		.decoder      = EM28XX_TVP5150,
1018
		.input        = { {
1019 1020
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = TVP5150_COMPOSITE0,
1021
			.amux     = EM28XX_AMUX_VIDEO,
1022
			.gpio     = default_analog,
1023
		}, {
1024 1025
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = TVP5150_COMPOSITE1,
1026
			.amux     = EM28XX_AMUX_LINE_IN,
1027
			.gpio     = default_analog,
1028
		}, {	/* S-video has not been tested yet */
1029 1030
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = TVP5150_SVIDEO,
1031
			.amux     = EM28XX_AMUX_LINE_IN,
1032
			.gpio     = default_analog,
1033
		} },
1034
	},
1035 1036 1037 1038
	[EM2881_BOARD_DNT_DA2_HYBRID] = {
		.name         = "DNT DA2 Hybrid",
		.valid        = EM28XX_BOARD_NOT_VALIDATED,
		.tuner_type   = TUNER_XC2028,
1039
		.tuner_gpio   = default_tuner_gpio,
1040
		.decoder      = EM28XX_TVP5150,
1041
		.input        = { {
1042
			.type     = EM28XX_VMUX_TELEVISION,
1043
			.vmux     = TVP5150_COMPOSITE0,
1044
			.amux     = EM28XX_AMUX_VIDEO,
1045
			.gpio     = default_analog,
1046
		}, {
1047
			.type     = EM28XX_VMUX_COMPOSITE1,
1048
			.vmux     = TVP5150_COMPOSITE1,
1049
			.amux     = EM28XX_AMUX_LINE_IN,
1050
			.gpio     = default_analog,
1051
		}, {
1052
			.type     = EM28XX_VMUX_SVIDEO,
1053
			.vmux     = TVP5150_SVIDEO,
1054
			.amux     = EM28XX_AMUX_LINE_IN,
1055
			.gpio     = default_analog,
1056
		} },
1057
	},
1058 1059 1060 1061
	[EM2881_BOARD_PINNACLE_HYBRID_PRO] = {
		.name         = "Pinnacle Hybrid Pro",
		.valid        = EM28XX_BOARD_NOT_VALIDATED,
		.tuner_type   = TUNER_XC2028,
1062
		.tuner_gpio   = default_tuner_gpio,
1063
		.decoder      = EM28XX_TVP5150,
1064
		.input        = { {
1065 1066
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = TVP5150_COMPOSITE0,
1067
			.amux     = EM28XX_AMUX_VIDEO,
1068
			.gpio     = default_analog,
1069
		}, {
1070
			.type     = EM28XX_VMUX_COMPOSITE1,
1071
			.vmux     = TVP5150_COMPOSITE1,
1072
			.amux     = EM28XX_AMUX_LINE_IN,
1073
			.gpio     = default_analog,
1074 1075
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
1076
			.vmux     = TVP5150_SVIDEO,
1077
			.amux     = EM28XX_AMUX_LINE_IN,
1078
			.gpio     = default_analog,
1079 1080
		} },
	},
1081 1082 1083 1084
	[EM2882_BOARD_PINNACLE_HYBRID_PRO] = {
		.name         = "Pinnacle Hybrid Pro (2)",
		.valid        = EM28XX_BOARD_NOT_VALIDATED,
		.tuner_type   = TUNER_XC2028,
1085
		.tuner_gpio   = default_tuner_gpio,
1086
		.mts_firmware = 1,
1087
		.decoder      = EM28XX_TVP5150,
1088
		.input        = { {
1089
			.type     = EM28XX_VMUX_TELEVISION,
1090
			.vmux     = TVP5150_COMPOSITE0,
1091
			.amux     = EM28XX_AMUX_VIDEO,
1092
			.gpio     = hauppauge_wintv_hvr_900_analog,
1093
		}, {
1094
			.type     = EM28XX_VMUX_COMPOSITE1,
1095
			.vmux     = TVP5150_COMPOSITE1,
1096
			.amux     = EM28XX_AMUX_LINE_IN,
1097
			.gpio     = hauppauge_wintv_hvr_900_analog,
1098
		}, {
1099
			.type     = EM28XX_VMUX_SVIDEO,
1100
			.vmux     = TVP5150_SVIDEO,
1101
			.amux     = EM28XX_AMUX_LINE_IN,
1102
			.gpio     = hauppauge_wintv_hvr_900_analog,
1103
		} },
1104
	},
1105 1106 1107 1108
	[EM2882_BOARD_KWORLD_VS_DVBT] = {
		.name         = "Kworld VS-DVB-T 323UR",
		.valid        = EM28XX_BOARD_NOT_VALIDATED,
		.tuner_type   = TUNER_XC2028,
1109
		.tuner_gpio   = default_tuner_gpio,
1110
		.decoder      = EM28XX_TVP5150,
1111
		.input        = { {
1112
			.type     = EM28XX_VMUX_TELEVISION,
1113
			.vmux     = TVP5150_COMPOSITE0,
1114
			.amux     = EM28XX_AMUX_VIDEO,
1115
		}, {
1116
			.type     = EM28XX_VMUX_COMPOSITE1,
1117
			.vmux     = TVP5150_COMPOSITE1,
1118
			.amux     = EM28XX_AMUX_LINE_IN,
1119
		}, {
1120
			.type     = EM28XX_VMUX_SVIDEO,
1121
			.vmux     = TVP5150_SVIDEO,
1122
			.amux     = EM28XX_AMUX_LINE_IN,
1123
		} },
1124
	},
1125 1126 1127 1128
	[EM2882_BOARD_TERRATEC_HYBRID_XS] = {
		.name         = "Terratec Hybrid XS (em2882)",
		.valid        = EM28XX_BOARD_NOT_VALIDATED,
		.tuner_type   = TUNER_XC2028,
1129
		.tuner_gpio   = default_tuner_gpio,
1130
		.decoder      = EM28XX_TVP5150,
1131
		.input        = { {
1132 1133
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = TVP5150_COMPOSITE0,
1134
			.amux     = EM28XX_AMUX_VIDEO,
1135
			.gpio     = hauppauge_wintv_hvr_900_analog,
1136
		}, {
1137
			.type     = EM28XX_VMUX_COMPOSITE1,
1138
			.vmux     = TVP5150_COMPOSITE1,
1139
			.amux     = EM28XX_AMUX_LINE_IN,
1140
			.gpio     = hauppauge_wintv_hvr_900_analog,
1141
		}, {
1142
			.type     = EM28XX_VMUX_SVIDEO,
1143
			.vmux     = TVP5150_SVIDEO,
1144
			.amux     = EM28XX_AMUX_LINE_IN,
1145
			.gpio     = hauppauge_wintv_hvr_900_analog,
1146
		} },
1147
	},
1148 1149 1150 1151
	[EM2883_BOARD_KWORLD_HYBRID_A316] = {
		.name         = "Kworld PlusTV HD Hybrid 330",
		.valid        = EM28XX_BOARD_NOT_VALIDATED,
		.tuner_type   = TUNER_XC2028,
1152
		.tuner_gpio   = default_tuner_gpio,
1153
		.decoder      = EM28XX_TVP5150,
1154
		.input        = { {
1155
			.type     = EM28XX_VMUX_TELEVISION,
1156
			.vmux     = TVP5150_COMPOSITE0,
1157
			.amux     = EM28XX_AMUX_VIDEO,
1158
			.gpio     = hauppauge_wintv_hvr_900_analog,
1159
		}, {
1160
			.type     = EM28XX_VMUX_COMPOSITE1,
1161
			.vmux     = TVP5150_COMPOSITE1,
1162
			.amux     = EM28XX_AMUX_LINE_IN,
1163
			.gpio     = hauppauge_wintv_hvr_900_analog,
1164
		}, {
1165
			.type     = EM28XX_VMUX_SVIDEO,
1166
			.vmux     = TVP5150_SVIDEO,
1167
			.amux     = EM28XX_AMUX_LINE_IN,
1168
			.gpio     = hauppauge_wintv_hvr_900_analog,
1169 1170
		} },
	},
1171
	[EM2820_BOARD_COMPRO_VIDEOMATE_FORYOU] = {
1172 1173 1174 1175
		.name         = "Compro VideoMate ForYou/Stereo",
		.tuner_type   = TUNER_LG_PAL_NEW_TAPC,
		.tda9887_conf = TDA9887_PRESENT,
		.decoder      = EM28XX_TVP5150,
1176
		.input        = { {
1177 1178 1179 1180 1181 1182 1183 1184 1185
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = TVP5150_COMPOSITE0,
			.amux     = EM28XX_AMUX_LINE_IN,
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = TVP5150_SVIDEO,
			.amux     = EM28XX_AMUX_LINE_IN,
		} },
	},
1186 1187 1188

	/* em2874 tuners are DVB only */

1189 1190 1191
	[EM2874_BOARD_PINNACLE_PCTV_80E] = {
		.name         = "Pinnacle PCTV HD Mini",
		.tuner_type   = TUNER_ABSENT,
1192
		.has_dvb      = 1,
1193
		.dvb_gpio     = em2874_pinnacle_80e_digital,
1194
		.ir_codes     = ir_codes_pinnacle_pctv_hd,
1195
		.decoder      = EM28XX_NODECODER,
1196 1197 1198
		.i2c_speed    = EM28XX_I2C_CLK_WAIT_ENABLE |
				EM2874_I2C_SECONDARY_BUS_SELECT |
				EM28XX_I2C_FREQ_400_KHZ,
1199
#ifdef DJH_DEBUG
1200
		.input        = { {
1201 1202 1203 1204 1205 1206
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = TVP5150_COMPOSITE0,
			.amux     = EM28XX_AMUX_LINE_IN,
		} },
#endif
	},
1207
};
1208
const unsigned int em28xx_bcount = ARRAY_SIZE(em28xx_boards);
1209 1210

/* table of devices that work with this driver */
1211
struct usb_device_id em28xx_id_table [] = {
1212
	{ USB_DEVICE(0xeb1a, 0x2750),
1213 1214 1215
			.driver_info = EM2750_BOARD_UNKNOWN },
	{ USB_DEVICE(0xeb1a, 0x2751),
			.driver_info = EM2750_BOARD_UNKNOWN },
1216 1217 1218 1219 1220
	{ USB_DEVICE(0xeb1a, 0x2800),
			.driver_info = EM2800_BOARD_UNKNOWN },
	{ USB_DEVICE(0xeb1a, 0x2820),
			.driver_info = EM2820_BOARD_UNKNOWN },
	{ USB_DEVICE(0xeb1a, 0x2821),
1221
			.driver_info = EM2820_BOARD_PROLINK_PLAYTV_USB2 },
1222 1223 1224 1225 1226 1227 1228 1229 1230 1231
	{ 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 },
1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251
	{ 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 },
1252 1253
	{ USB_DEVICE(0x0ccd, 0x0036),
			.driver_info = EM2820_BOARD_TERRATEC_CINERGY_250 },
1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267
	{ 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 },
1268
	{ USB_DEVICE(0x185b, 0x2041),
1269
			.driver_info = EM2820_BOARD_COMPRO_VIDEOMATE_FORYOU },
1270 1271
	{ USB_DEVICE(0x2040, 0x4200),
			.driver_info = EM2820_BOARD_HAUPPAUGE_WINTV_USB_2 },
1272 1273
	{ USB_DEVICE(0x2040, 0x4201),
			.driver_info = EM2820_BOARD_HAUPPAUGE_WINTV_USB_2 },
1274 1275
	{ USB_DEVICE(0x2040, 0x6500),
			.driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900 },
1276
	{ USB_DEVICE(0x2040, 0x6502),
1277
			.driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900_R2 },
1278
	{ USB_DEVICE(0x2040, 0x6513), /* HCW HVR-980 */
1279
			.driver_info = EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950 },
1280
	{ USB_DEVICE(0x2040, 0x6517), /* HP  HVR-950 */
1281
			.driver_info = EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950 },
1282
	{ USB_DEVICE(0x2040, 0x651b), /* RP  HVR-950 */
1283
			.driver_info = EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950 },
1284
	{ USB_DEVICE(0x2040, 0x651f), /* HCW HVR-850 */
1285
			.driver_info = EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950 },
1286 1287
	{ USB_DEVICE(0x0438, 0xb002),
			.driver_info = EM2880_BOARD_AMD_ATI_TV_WONDER_HD_600 },
1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299
	{ 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 },
1300 1301
	{ USB_DEVICE(0x2304, 0x023f),
			.driver_info = EM2874_BOARD_PINNACLE_PCTV_80E },
1302 1303 1304 1305
	{ USB_DEVICE(0x0413, 0x6023),
			.driver_info = EM2800_BOARD_LEADTEK_WINFAST_USBII },
	{ USB_DEVICE(0x093b, 0xa005),
			.driver_info = EM2861_BOARD_PLEXTOR_PX_TV100U },
1306 1307
	{ },
};
1308
MODULE_DEVICE_TABLE(usb, em28xx_id_table);
1309

1310 1311 1312
/*
 * EEPROM hash table for devices with generic USB IDs
 */
1313
static struct em28xx_hash_table em28xx_eeprom_hash [] = {
1314
	/* P/N: SA 60002070465 Tuner: TVF7533-MF */
1315
	{0x6ce05a8f, EM2820_BOARD_PROLINK_PLAYTV_USB2, TUNER_YMEC_TVF_5533MF},
1316
	{0x966a0441, EM2880_BOARD_KWORLD_DVB_310U, TUNER_XC2028},
1317
};
1318

1319
/* I2C devicelist hash table for devices with generic USB IDs */
1320
static struct em28xx_hash_table em28xx_i2c_hash[] = {
1321 1322
	{0xb06a32c3, EM2800_BOARD_TERRATEC_CINERGY_200, TUNER_LG_PAL_NEW_TAPC},
	{0xf51200e3, EM2800_BOARD_VGEAR_POCKETTV, TUNER_LG_PAL_NEW_TAPC},
1323
	{0x1ba50080, EM2860_BOARD_POINTNIX_INTRAORAL_CAMERA, TUNER_ABSENT},
1324 1325
};

1326
int em28xx_tuner_callback(void *ptr, int component, int command, int arg)
1327
{
1328
	int rc = 0;
1329 1330 1331 1332 1333 1334 1335 1336
	struct em28xx *dev = ptr;

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

	if (command != XC2028_TUNER_RESET)
		return 0;

1337
	rc = em28xx_gpio_set(dev, dev->board.tuner_gpio);
1338 1339 1340 1341 1342

	return rc;
}
EXPORT_SYMBOL_GPL(em28xx_tuner_callback);

1343
static void inline em28xx_set_model(struct em28xx *dev)
1344
{
1345
	memcpy(&dev->board, &em28xx_boards[dev->model], sizeof(dev->board));
1346 1347
}

1348 1349 1350
/* Since em28xx_pre_card_setup() requires a proper dev->model,
 * this won't work for boards with generic PCI IDs
 */
1351 1352
void em28xx_pre_card_setup(struct em28xx *dev)
{
1353 1354
	int rc;

1355 1356 1357 1358
	em28xx_set_model(dev);

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

1359 1360 1361
	/* Set the default GPO/GPIO for legacy devices */
	dev->reg_gpo_num = EM2880_R04_GPO;
	dev->reg_gpio_num = EM28XX_R08_GPIO;
1362

1363
	dev->wait_after_write = 5;
1364 1365

	/* Based on the Chip ID, set the device configuration */
1366
	rc = em28xx_read_reg(dev, EM28XX_R0A_CHIPID);
1367
	if (rc > 0) {
1368
		dev->chip_id = rc;
1369 1370

		switch (dev->chip_id) {
1371 1372 1373
		case CHIP_ID_EM2750:
			em28xx_info("chip ID is em2750\n");
			break;
1374 1375 1376 1377 1378 1379
		case CHIP_ID_EM2820:
			em28xx_info("chip ID is em2820\n");
			break;
		case CHIP_ID_EM2840:
			em28xx_info("chip ID is em2840\n");
			break;
1380 1381 1382
		case CHIP_ID_EM2860:
			em28xx_info("chip ID is em2860\n");
			break;
1383 1384
		case CHIP_ID_EM2874:
			em28xx_info("chip ID is em2874\n");
1385
			dev->reg_gpio_num = EM2874_R80_GPIO;
1386 1387
			dev->wait_after_write = 0;
			break;
1388
		case CHIP_ID_EM2883:
1389 1390 1391 1392
			em28xx_info("chip ID is em2882/em2883\n");
			dev->wait_after_write = 0;
			break;
		default:
1393
			em28xx_info("em28xx chip ID = %d\n", dev->chip_id);
1394 1395
		}
	}
1396 1397 1398 1399 1400 1401

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

1402 1403 1404
	/* Those are the default values for the majority of boards
	   Use those values if not specified otherwise at boards entry
	 */
1405 1406 1407
	if (!dev->board.xclk)
		dev->board.xclk = EM28XX_XCLK_IR_RC5_MODE |
				  EM28XX_XCLK_FREQUENCY_12MHZ;
1408

1409 1410 1411
	if (!dev->board.i2c_speed)
		dev->board.i2c_speed = EM28XX_I2C_CLK_WAIT_ENABLE |
				       EM28XX_I2C_FREQ_100_KHZ;
1412

1413 1414
	em28xx_write_reg(dev, EM28XX_R0F_XCLK, dev->board.xclk & 0x7f);
	em28xx_write_reg(dev, EM28XX_R06_I2C_CLK, dev->board.i2c_speed);
1415 1416
	msleep(50);

1417
	/* request some modules */
1418
	switch (dev->model) {
1419 1420 1421
	case EM2861_BOARD_PLEXTOR_PX_TV100U:
		/* FIXME guess */
		/* Turn on analog audio output */
1422
		em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xfd);
1423 1424 1425
		break;
	case EM2861_BOARD_KWORLD_PVRTV_300U:
	case EM2880_BOARD_KWORLD_DVB_305U:
1426
		em28xx_write_reg(dev, EM28XX_R08_GPIO, 0x6d);
1427
		msleep(10);
1428
		em28xx_write_reg(dev, EM28XX_R08_GPIO, 0x7d);
1429 1430 1431 1432 1433
		msleep(10);
		break;
	case EM2870_BOARD_COMPRO_VIDEOMATE:
		/* TODO: someone can do some cleanup here...
			 not everything's needed */
1434
		em28xx_write_reg(dev, EM2880_R04_GPO, 0x00);
1435
		msleep(10);
1436
		em28xx_write_reg(dev, EM2880_R04_GPO, 0x01);
1437
		msleep(10);
1438
		em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xfd);
1439
		mdelay(70);
1440
		em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xfc);
1441
		mdelay(70);
1442
		em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xdc);
1443
		mdelay(70);
1444
		em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xfc);
1445 1446 1447 1448 1449
		mdelay(70);
		break;
	case EM2870_BOARD_TERRATEC_XS_MT2060:
		/* this device needs some gpio writes to get the DVB-T
		   demod work */
1450
		em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xfe);
1451
		mdelay(70);
1452
		em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xde);
1453
		mdelay(70);
1454
		em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xfe);
1455 1456 1457 1458 1459
		mdelay(70);
		break;
	case EM2870_BOARD_PINNACLE_PCTV_DVB:
		/* this device needs some gpio writes to get the
		   DVB-T demod work */
1460
		em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xfe);
1461
		mdelay(70);
1462
		em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xde);
1463
		mdelay(70);
1464
		em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xfe);
1465 1466 1467 1468
		mdelay(70);
		break;
	case EM2820_BOARD_GADMEI_UTV310:
	case EM2820_BOARD_MSI_VOX_USB_2:
1469
		/* enables audio for that devices */
1470
		em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xfd);
1471 1472
		break;
	}
1473

1474
	em28xx_gpio_set(dev, dev->board.tuner_gpio);
1475 1476 1477
	em28xx_set_mode(dev, EM28XX_ANALOG_MODE);

	/* Unlock device */
1478
	em28xx_set_mode(dev, EM28XX_SUSPEND);
1479 1480
}

1481
static void em28xx_setup_xc3028(struct em28xx *dev, struct xc2028_ctrl *ctl)
1482 1483 1484 1485 1486 1487 1488 1489
{
	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) {
1490 1491 1492
	case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900:
		ctl->demod = XC3028_FE_ZARLINK456;
		break;
1493 1494 1495
	case EM2880_BOARD_TERRATEC_HYBRID_XS:
		ctl->demod = XC3028_FE_ZARLINK456;
		break;
1496 1497 1498 1499
	case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900_R2:
		/* djh - Not sure which demod we need here */
		ctl->demod = XC3028_FE_DEFAULT;
		break;
1500 1501 1502 1503
	case EM2880_BOARD_AMD_ATI_TV_WONDER_HD_600:
		ctl->demod = XC3028_FE_DEFAULT;
		ctl->fname = XC3028L_DEFAULT_FIRMWARE;
		break;
1504
	case EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950:
1505
	case EM2880_BOARD_PINNACLE_PCTV_HD_PRO:
1506
		/* FIXME: Better to specify the needed IF */
1507 1508
		ctl->demod = XC3028_FE_DEFAULT;
		break;
1509 1510 1511 1512 1513
	default:
		ctl->demod = XC3028_FE_OREN538;
	}
}

1514
static void em28xx_config_tuner(struct em28xx *dev)
1515 1516
{
	struct v4l2_priv_tun_config  xc2028_cfg;
1517 1518 1519
	struct tuner_setup           tun_setup;
	struct v4l2_frequency        f;

1520
	if (dev->tuner_type == TUNER_ABSENT)
1521 1522 1523 1524 1525 1526 1527 1528 1529 1530
		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) {
1531
		struct xc2028_ctrl           ctl;
1532

1533
		em28xx_setup_xc3028(dev, &ctl);
1534 1535 1536

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

1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551
		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;
1552

1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564
	/* 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;
1565

1566 1567 1568 1569 1570 1571 1572 1573 1574 1575
			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);
1576

1577 1578 1579
			return 0;
		}
	}
1580

1581 1582 1583 1584 1585 1586 1587 1588 1589
	/* 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.
	 */

1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612
	/* 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;
		}
	}

1613 1614 1615 1616 1617 1618 1619
	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);
1620
	em28xx_errdev("Board i2c devicelist hash is 0x%08lx\n", dev->i2c_hash);
1621 1622 1623 1624 1625 1626 1627 1628

	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;
1629 1630
}

1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669
/* ----------------------------------------------------------------------- */
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;
1670 1671
	case (EM2800_BOARD_GRABBEEX_USB2800):
		break;
1672 1673 1674
	}
}

1675
void em28xx_card_setup(struct em28xx *dev)
1676
{
1677 1678 1679
	em28xx_set_model(dev);

	dev->tuner_type = em28xx_boards[dev->model].tuner_type;
1680 1681
	if (em28xx_boards[dev->model].tuner_addr)
		dev->tuner_addr = em28xx_boards[dev->model].tuner_addr;
1682

1683
	/* request some modules */
1684 1685
	switch (dev->model) {
	case EM2820_BOARD_HAUPPAUGE_WINTV_USB_2:
1686
	case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900:
1687
	case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900_R2:
1688
	case EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950:
1689 1690
	{
		struct tveeprom tv;
1691
#ifdef CONFIG_MODULES
1692
		request_module("tveeprom");
1693
#endif
1694 1695 1696 1697
		/* Call first TVeeprom */

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

1699
		dev->tuner_type = tv.tuner_type;
1700

1701
		if (tv.audio_processor == V4L2_IDENT_MSPX4XX) {
1702
			dev->i2s_speed = 2048000;
1703
			dev->board.has_msp34xx = 1;
1704
		}
1705 1706 1707 1708
#ifdef CONFIG_MODULES
		if (tv.has_ir)
			request_module("ir-kbd-i2c");
#endif
1709
		break;
1710
	}
1711 1712
	case EM2820_BOARD_KWORLD_PVRTV2800RF:
		/* GPIO enables sound on KWORLD PVR TV 2800RF */
1713
		em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xf9);
1714 1715 1716
		break;
	case EM2820_BOARD_UNKNOWN:
	case EM2800_BOARD_UNKNOWN:
1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730
		/*
		 * 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:
1731 1732
		if (!em28xx_hint_board(dev))
			em28xx_set_model(dev);
1733
		break;
1734 1735
	}

1736
	if (dev->board.has_snapshot_button)
1737 1738
		em28xx_register_snapshot_button(dev);

1739
	if (dev->board.valid == EM28XX_BOARD_NOT_VALIDATED) {
1740 1741 1742 1743 1744 1745 1746 1747
		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");
	}

1748
	/* Allow override tuner type by a module parameter */
1749 1750 1751 1752 1753
	if (tuner >= 0)
		dev->tuner_type = tuner;

#ifdef CONFIG_MODULES
	/* request some modules */
1754
	if (dev->board.has_msp34xx)
1755
		request_module("msp3400");
1756
	if (dev->board.decoder == EM28XX_SAA711X)
1757
		request_module("saa7115");
1758
	if (dev->board.decoder == EM28XX_TVP5150)
1759
		request_module("tvp5150");
1760
	if (dev->board.tuner_type != TUNER_ABSENT)
1761 1762 1763
		request_module("tuner");
#endif

1764
	em28xx_config_tuner(dev);
1765 1766

	em28xx_ir_init(dev);
1767
}
1768