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

/* table of devices that work with this driver */
1174
struct usb_device_id em28xx_id_table [] = {
1175
	{ USB_DEVICE(0xeb1a, 0x2750),
1176 1177 1178
			.driver_info = EM2750_BOARD_UNKNOWN },
	{ USB_DEVICE(0xeb1a, 0x2751),
			.driver_info = EM2750_BOARD_UNKNOWN },
1179 1180 1181 1182 1183
	{ USB_DEVICE(0xeb1a, 0x2800),
			.driver_info = EM2800_BOARD_UNKNOWN },
	{ USB_DEVICE(0xeb1a, 0x2820),
			.driver_info = EM2820_BOARD_UNKNOWN },
	{ USB_DEVICE(0xeb1a, 0x2821),
1184
			.driver_info = EM2820_BOARD_PROLINK_PLAYTV_USB2 },
1185 1186 1187 1188 1189 1190 1191 1192 1193 1194
	{ 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 },
1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214
	{ 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 },
1215 1216
	{ USB_DEVICE(0x0ccd, 0x0036),
			.driver_info = EM2820_BOARD_TERRATEC_CINERGY_250 },
1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230
	{ 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 },
1231
	{ USB_DEVICE(0x185b, 0x2041),
1232
			.driver_info = EM2820_BOARD_COMPRO_VIDEOMATE_FORYOU },
1233 1234
	{ USB_DEVICE(0x2040, 0x4200),
			.driver_info = EM2820_BOARD_HAUPPAUGE_WINTV_USB_2 },
1235 1236
	{ USB_DEVICE(0x2040, 0x4201),
			.driver_info = EM2820_BOARD_HAUPPAUGE_WINTV_USB_2 },
1237 1238
	{ USB_DEVICE(0x2040, 0x6500),
			.driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900 },
1239
	{ USB_DEVICE(0x2040, 0x6502),
1240
			.driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900_R2 },
1241
	{ USB_DEVICE(0x2040, 0x6513), /* HCW HVR-980 */
1242
			.driver_info = EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950 },
1243
	{ USB_DEVICE(0x2040, 0x6517), /* HP  HVR-950 */
1244
			.driver_info = EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950 },
1245
	{ USB_DEVICE(0x2040, 0x651b), /* RP  HVR-950 */
1246
			.driver_info = EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950 },
1247
	{ USB_DEVICE(0x2040, 0x651f), /* HCW HVR-850 */
1248
			.driver_info = EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950 },
1249 1250
	{ USB_DEVICE(0x0438, 0xb002),
			.driver_info = EM2880_BOARD_AMD_ATI_TV_WONDER_HD_600 },
1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262
	{ 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 },
1263 1264
	{ USB_DEVICE(0x2304, 0x023f),
			.driver_info = EM2874_BOARD_PINNACLE_PCTV_80E },
1265 1266 1267 1268
	{ USB_DEVICE(0x0413, 0x6023),
			.driver_info = EM2800_BOARD_LEADTEK_WINFAST_USBII },
	{ USB_DEVICE(0x093b, 0xa005),
			.driver_info = EM2861_BOARD_PLEXTOR_PX_TV100U },
1269 1270
	{ },
};
1271
MODULE_DEVICE_TABLE(usb, em28xx_id_table);
1272

1273 1274 1275
/*
 * EEPROM hash table for devices with generic USB IDs
 */
1276
static struct em28xx_hash_table em28xx_eeprom_hash [] = {
1277
	/* P/N: SA 60002070465 Tuner: TVF7533-MF */
1278
	{0x6ce05a8f, EM2820_BOARD_PROLINK_PLAYTV_USB2, TUNER_YMEC_TVF_5533MF},
1279
	{0x966a0441, EM2880_BOARD_KWORLD_DVB_310U, TUNER_XC2028},
1280
};
1281

1282
/* I2C devicelist hash table for devices with generic USB IDs */
1283
static struct em28xx_hash_table em28xx_i2c_hash[] = {
1284 1285
	{0xb06a32c3, EM2800_BOARD_TERRATEC_CINERGY_200, TUNER_LG_PAL_NEW_TAPC},
	{0xf51200e3, EM2800_BOARD_VGEAR_POCKETTV, TUNER_LG_PAL_NEW_TAPC},
1286
	{0x1ba50080, EM2860_BOARD_POINTNIX_INTRAORAL_CAMERA, TUNER_ABSENT},
1287 1288
};

1289
int em28xx_tuner_callback(void *ptr, int component, int command, int arg)
1290
{
1291
	int rc = 0;
1292 1293 1294 1295 1296 1297 1298 1299
	struct em28xx *dev = ptr;

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

	if (command != XC2028_TUNER_RESET)
		return 0;

1300
	rc = em28xx_gpio_set(dev, dev->tuner_gpio);
1301 1302 1303 1304 1305

	return rc;
}
EXPORT_SYMBOL_GPL(em28xx_tuner_callback);

1306
static void inline em28xx_set_model(struct em28xx *dev)
1307
{
1308
	memcpy(&dev->board, &em28xx_boards[dev->model], sizeof(dev->board));
1309 1310
}

1311 1312 1313
/* Since em28xx_pre_card_setup() requires a proper dev->model,
 * this won't work for boards with generic PCI IDs
 */
1314 1315
void em28xx_pre_card_setup(struct em28xx *dev)
{
1316 1317
	int rc;

1318 1319 1320 1321
	em28xx_set_model(dev);

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

1322 1323 1324
	/* Set the default GPO/GPIO for legacy devices */
	dev->reg_gpo_num = EM2880_R04_GPO;
	dev->reg_gpio_num = EM28XX_R08_GPIO;
1325

1326
	dev->wait_after_write = 5;
1327 1328

	/* Based on the Chip ID, set the device configuration */
1329
	rc = em28xx_read_reg(dev, EM28XX_R0A_CHIPID);
1330
	if (rc > 0) {
1331
		dev->chip_id = rc;
1332 1333

		switch (dev->chip_id) {
1334 1335 1336
		case CHIP_ID_EM2750:
			em28xx_info("chip ID is em2750\n");
			break;
1337 1338 1339 1340 1341 1342
		case CHIP_ID_EM2820:
			em28xx_info("chip ID is em2820\n");
			break;
		case CHIP_ID_EM2840:
			em28xx_info("chip ID is em2840\n");
			break;
1343 1344 1345
		case CHIP_ID_EM2860:
			em28xx_info("chip ID is em2860\n");
			break;
1346 1347
		case CHIP_ID_EM2874:
			em28xx_info("chip ID is em2874\n");
1348
			dev->reg_gpio_num = EM2874_R80_GPIO;
1349 1350
			dev->wait_after_write = 0;
			break;
1351
		case CHIP_ID_EM2883:
1352 1353 1354 1355
			em28xx_info("chip ID is em2882/em2883\n");
			dev->wait_after_write = 0;
			break;
		default:
1356
			em28xx_info("em28xx chip ID = %d\n", dev->chip_id);
1357 1358
		}
	}
1359 1360 1361 1362 1363 1364

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

1365 1366 1367
	/* Those are the default values for the majority of boards
	   Use those values if not specified otherwise at boards entry
	 */
1368 1369 1370
	if (!dev->board.xclk)
		dev->board.xclk = EM28XX_XCLK_IR_RC5_MODE |
				  EM28XX_XCLK_FREQUENCY_12MHZ;
1371

1372 1373 1374
	if (!dev->board.i2c_speed)
		dev->board.i2c_speed = EM28XX_I2C_CLK_WAIT_ENABLE |
				       EM28XX_I2C_FREQ_100_KHZ;
1375

1376 1377
	em28xx_write_reg(dev, EM28XX_R0F_XCLK, dev->board.xclk & 0x7f);
	em28xx_write_reg(dev, EM28XX_R06_I2C_CLK, dev->board.i2c_speed);
1378 1379
	msleep(50);

1380
	/* request some modules */
1381
	switch (dev->model) {
1382 1383 1384
	case EM2861_BOARD_PLEXTOR_PX_TV100U:
		/* FIXME guess */
		/* Turn on analog audio output */
1385
		em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xfd);
1386 1387 1388
		break;
	case EM2861_BOARD_KWORLD_PVRTV_300U:
	case EM2880_BOARD_KWORLD_DVB_305U:
1389
		em28xx_write_reg(dev, EM28XX_R08_GPIO, 0x6d);
1390
		msleep(10);
1391
		em28xx_write_reg(dev, EM28XX_R08_GPIO, 0x7d);
1392 1393 1394 1395 1396
		msleep(10);
		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
		mdelay(70);
		break;
	case EM2870_BOARD_TERRATEC_XS_MT2060:
		/* this device needs some gpio writes to get the DVB-T
		   demod work */
1413
		em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xfe);
1414
		mdelay(70);
1415
		em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xde);
1416
		mdelay(70);
1417
		em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xfe);
1418 1419 1420 1421 1422
		mdelay(70);
		break;
	case EM2870_BOARD_PINNACLE_PCTV_DVB:
		/* this device needs some gpio writes to get the
		   DVB-T demod work */
1423
		em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xfe);
1424
		mdelay(70);
1425
		em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xde);
1426
		mdelay(70);
1427
		em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xfe);
1428 1429 1430 1431
		mdelay(70);
		break;
	case EM2820_BOARD_GADMEI_UTV310:
	case EM2820_BOARD_MSI_VOX_USB_2:
1432
		/* enables audio for that devices */
1433
		em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xfd);
1434 1435
		break;
	}
1436

1437 1438 1439 1440 1441
	/* 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);
1442 1443 1444 1445
	em28xx_set_mode(dev, EM28XX_ANALOG_MODE);

	/* Unlock device */
	em28xx_set_mode(dev, EM28XX_MODE_UNDEFINED);
1446 1447
}

1448
static void em28xx_setup_xc3028(struct em28xx *dev, struct xc2028_ctrl *ctl)
1449 1450 1451 1452 1453 1454 1455 1456
{
	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) {
1457 1458 1459
	case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900:
		ctl->demod = XC3028_FE_ZARLINK456;
		break;
1460 1461 1462
	case EM2880_BOARD_TERRATEC_HYBRID_XS:
		ctl->demod = XC3028_FE_ZARLINK456;
		break;
1463 1464 1465 1466
	case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900_R2:
		/* djh - Not sure which demod we need here */
		ctl->demod = XC3028_FE_DEFAULT;
		break;
1467 1468 1469 1470
	case EM2880_BOARD_AMD_ATI_TV_WONDER_HD_600:
		ctl->demod = XC3028_FE_DEFAULT;
		ctl->fname = XC3028L_DEFAULT_FIRMWARE;
		break;
1471
	case EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950:
1472
	case EM2880_BOARD_PINNACLE_PCTV_HD_PRO:
1473
		/* FIXME: Better to specify the needed IF */
1474 1475
		ctl->demod = XC3028_FE_DEFAULT;
		break;
1476 1477 1478 1479 1480
	default:
		ctl->demod = XC3028_FE_OREN538;
	}
}

1481
static void em28xx_config_tuner(struct em28xx *dev)
1482 1483
{
	struct v4l2_priv_tun_config  xc2028_cfg;
1484 1485 1486
	struct tuner_setup           tun_setup;
	struct v4l2_frequency        f;

1487
	if (dev->tuner_type == TUNER_ABSENT)
1488 1489 1490 1491 1492 1493 1494 1495 1496 1497
		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) {
1498
		struct xc2028_ctrl           ctl;
1499

1500
		em28xx_setup_xc3028(dev, &ctl);
1501 1502 1503

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

1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518
		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;
1519

1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531
	/* 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;
1532

1533 1534 1535 1536 1537 1538 1539 1540 1541 1542
			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);
1543

1544 1545 1546
			return 0;
		}
	}
1547

1548 1549 1550 1551 1552 1553 1554 1555 1556
	/* 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.
	 */

1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579
	/* 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;
		}
	}

1580 1581 1582 1583 1584 1585 1586
	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);
1587
	em28xx_errdev("Board i2c devicelist hash is 0x%08lx\n", dev->i2c_hash);
1588 1589 1590 1591 1592 1593 1594 1595

	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;
1596 1597
}

1598 1599 1600 1601 1602 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
/* ----------------------------------------------------------------------- */
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;
1637 1638
	case (EM2800_BOARD_GRABBEEX_USB2800):
		break;
1639 1640 1641
	}
}

1642
void em28xx_card_setup(struct em28xx *dev)
1643
{
1644 1645 1646
	em28xx_set_model(dev);

	dev->tuner_type = em28xx_boards[dev->model].tuner_type;
1647 1648
	if (em28xx_boards[dev->model].tuner_addr)
		dev->tuner_addr = em28xx_boards[dev->model].tuner_addr;
1649

1650
	/* request some modules */
1651 1652
	switch (dev->model) {
	case EM2820_BOARD_HAUPPAUGE_WINTV_USB_2:
1653
	case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900:
1654
	case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900_R2:
1655
	case EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950:
1656 1657
	{
		struct tveeprom tv;
1658
#ifdef CONFIG_MODULES
1659
		request_module("tveeprom");
1660
#endif
1661 1662 1663 1664
		/* Call first TVeeprom */

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

1666
		dev->tuner_type = tv.tuner_type;
1667

1668
		if (tv.audio_processor == V4L2_IDENT_MSPX4XX) {
1669
			dev->i2s_speed = 2048000;
1670
			dev->board.has_msp34xx = 1;
1671
		}
1672 1673 1674 1675
#ifdef CONFIG_MODULES
		if (tv.has_ir)
			request_module("ir-kbd-i2c");
#endif
1676
		break;
1677
	}
1678 1679
	case EM2820_BOARD_KWORLD_PVRTV2800RF:
		/* GPIO enables sound on KWORLD PVR TV 2800RF */
1680
		em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xf9);
1681 1682 1683
		break;
	case EM2820_BOARD_UNKNOWN:
	case EM2800_BOARD_UNKNOWN:
1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697
		/*
		 * 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:
1698 1699
		if (!em28xx_hint_board(dev))
			em28xx_set_model(dev);
1700
		break;
1701 1702
	}

1703
	if (dev->board.has_snapshot_button)
1704 1705
		em28xx_register_snapshot_button(dev);

1706
	if (dev->board.valid == EM28XX_BOARD_NOT_VALIDATED) {
1707 1708 1709 1710 1711 1712 1713 1714
		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");
	}

1715
	/* Allow override tuner type by a module parameter */
1716 1717 1718 1719 1720
	if (tuner >= 0)
		dev->tuner_type = tuner;

#ifdef CONFIG_MODULES
	/* request some modules */
1721
	if (dev->board.has_msp34xx)
1722
		request_module("msp3400");
1723
	if (dev->board.decoder == EM28XX_SAA711X)
1724
		request_module("saa7115");
1725
	if (dev->board.decoder == EM28XX_TVP5150)
1726
		request_module("tvp5150");
1727
	if (dev->board.tuner_type != TUNER_ABSENT)
1728 1729 1730
		request_module("tuner");
#endif

1731
	em28xx_config_tuner(dev);
1732 1733

	em28xx_ir_init(dev);
1734
}
1735