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

/* table of devices that work with this driver */
1052
struct usb_device_id em28xx_id_table [] = {
1053
	{ USB_DEVICE(0xeb1a, 0x2750),
1054 1055 1056
			.driver_info = EM2750_BOARD_UNKNOWN },
	{ USB_DEVICE(0xeb1a, 0x2751),
			.driver_info = EM2750_BOARD_UNKNOWN },
1057 1058 1059 1060 1061
	{ USB_DEVICE(0xeb1a, 0x2800),
			.driver_info = EM2800_BOARD_UNKNOWN },
	{ USB_DEVICE(0xeb1a, 0x2820),
			.driver_info = EM2820_BOARD_UNKNOWN },
	{ USB_DEVICE(0xeb1a, 0x2821),
1062
			.driver_info = EM2820_BOARD_PROLINK_PLAYTV_USB2 },
1063 1064 1065 1066 1067 1068 1069 1070 1071 1072
	{ 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 },
1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092
	{ 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 },
1093 1094
	{ USB_DEVICE(0x0ccd, 0x0036),
			.driver_info = EM2820_BOARD_TERRATEC_CINERGY_250 },
1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108
	{ 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 },
1109
	{ USB_DEVICE(0x185b, 0x2041),
1110
			.driver_info = EM2820_BOARD_COMPRO_VIDEOMATE_FORYOU },
1111 1112
	{ USB_DEVICE(0x2040, 0x4200),
			.driver_info = EM2820_BOARD_HAUPPAUGE_WINTV_USB_2 },
1113 1114
	{ USB_DEVICE(0x2040, 0x4201),
			.driver_info = EM2820_BOARD_HAUPPAUGE_WINTV_USB_2 },
1115 1116
	{ USB_DEVICE(0x2040, 0x6500),
			.driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900 },
1117
	{ USB_DEVICE(0x2040, 0x6502),
1118
			.driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900_R2 },
1119
	{ USB_DEVICE(0x2040, 0x6513), /* HCW HVR-980 */
1120
			.driver_info = EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950 },
1121
	{ USB_DEVICE(0x2040, 0x6517), /* HP  HVR-950 */
1122
			.driver_info = EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950 },
1123
	{ USB_DEVICE(0x2040, 0x651b), /* RP  HVR-950 */
1124
			.driver_info = EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950 },
1125
	{ USB_DEVICE(0x2040, 0x651f), /* HCW HVR-850 */
1126
			.driver_info = EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950 },
1127 1128
	{ USB_DEVICE(0x0438, 0xb002),
			.driver_info = EM2880_BOARD_AMD_ATI_TV_WONDER_HD_600 },
1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140
	{ 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 },
1141 1142
	{ USB_DEVICE(0x2304, 0x023f),
			.driver_info = EM2874_BOARD_PINNACLE_PCTV_80E },
1143 1144 1145 1146
	{ USB_DEVICE(0x0413, 0x6023),
			.driver_info = EM2800_BOARD_LEADTEK_WINFAST_USBII },
	{ USB_DEVICE(0x093b, 0xa005),
			.driver_info = EM2861_BOARD_PLEXTOR_PX_TV100U },
1147 1148
	{ },
};
1149
MODULE_DEVICE_TABLE(usb, em28xx_id_table);
1150

1151 1152 1153 1154
/*
 *  Reset sequences for analog/digital modes
 */

1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166
/* 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},
};

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

1174
/* Board Hauppauge WinTV HVR 900 digital */
1175
static struct em28xx_reg_seq hauppauge_wintv_hvr_900_digital[] = {
1176 1177 1178 1179 1180 1181
	{EM28XX_R08_GPIO,	0x2e,	~EM_GPIO_4,	10},
	{EM2880_R04_GPO,	0x04,	0x0f,		10},
	{EM2880_R04_GPO,	0x0c,	0x0f,		10},
	{ -1,			-1,	-1,		-1},
};

1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202
/* Boards - EM2880 MSI DIGIVOX AD and EM2880_BOARD_MSI_DIGIVOX_AD_II */
static struct em28xx_reg_seq em2880_msi_digivox_ad_analog[] = {
	{EM28XX_R08_GPIO,       0x69,   ~EM_GPIO_4,	 10},
	{	-1,		-1,	-1,		 -1},
};

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

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

/* Callback for the most boards */
static struct em28xx_reg_seq default_callback[] = {
1203 1204 1205 1206
	{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},
1207 1208
};

1209 1210 1211 1212 1213 1214 1215 1216 1217
/* Callback for EM2882 TERRATEC HYBRID XS */
static struct em28xx_reg_seq em2882_terratec_hybrid_xs_digital[] = {
	{EM28XX_R08_GPIO,       0x2e,   0xff,		   6},
	{EM28XX_R08_GPIO,       0x3e,   ~EM_GPIO_4,	   6},
	{EM2880_R04_GPO,        0x04,   0xff,		  10},
	{EM2880_R04_GPO,        0x0c,   0xff,		  10},
	{  -1,			-1,	-1,		  -1},
};

1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228
/* 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},
};

1229 1230 1231
/*
 * EEPROM hash table for devices with generic USB IDs
 */
1232
static struct em28xx_hash_table em28xx_eeprom_hash [] = {
1233
	/* P/N: SA 60002070465 Tuner: TVF7533-MF */
1234
	{0x6ce05a8f, EM2820_BOARD_PROLINK_PLAYTV_USB2, TUNER_YMEC_TVF_5533MF},
1235
	{0x966a0441, EM2880_BOARD_KWORLD_DVB_310U, TUNER_XC2028},
1236
};
1237

1238
/* I2C devicelist hash table for devices with generic USB IDs */
1239
static struct em28xx_hash_table em28xx_i2c_hash[] = {
1240 1241
	{0xb06a32c3, EM2800_BOARD_TERRATEC_CINERGY_200, TUNER_LG_PAL_NEW_TAPC},
	{0xf51200e3, EM2800_BOARD_VGEAR_POCKETTV, TUNER_LG_PAL_NEW_TAPC},
1242
	{0x1ba50080, EM2860_BOARD_POINTNIX_INTRAORAL_CAMERA, TUNER_ABSENT},
1243 1244
};

1245
int em28xx_tuner_callback(void *ptr, int component, int command, int arg)
1246
{
1247
	int rc = 0;
1248 1249 1250 1251 1252 1253 1254 1255 1256
	struct em28xx *dev = ptr;

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

	if (command != XC2028_TUNER_RESET)
		return 0;

	if (dev->mode == EM28XX_ANALOG_MODE)
1257
		rc = em28xx_gpio_set(dev, dev->tun_analog_gpio);
1258
	else
1259
		rc = em28xx_gpio_set(dev, dev->tun_digital_gpio);
1260 1261 1262 1263 1264

	return rc;
}
EXPORT_SYMBOL_GPL(em28xx_tuner_callback);

1265
static void inline em28xx_set_model(struct em28xx *dev)
1266
{
1267
	memcpy(&dev->board, &em28xx_boards[dev->model], sizeof(dev->board));
1268 1269
}

1270 1271 1272
/* Since em28xx_pre_card_setup() requires a proper dev->model,
 * this won't work for boards with generic PCI IDs
 */
1273 1274
void em28xx_pre_card_setup(struct em28xx *dev)
{
1275 1276
	int rc;

1277 1278 1279 1280
	em28xx_set_model(dev);

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

1281 1282 1283
	/* Set the default GPO/GPIO for legacy devices */
	dev->reg_gpo_num = EM2880_R04_GPO;
	dev->reg_gpio_num = EM28XX_R08_GPIO;
1284

1285
	dev->wait_after_write = 5;
1286 1287

	/* Based on the Chip ID, set the device configuration */
1288
	rc = em28xx_read_reg(dev, EM28XX_R0A_CHIPID);
1289
	if (rc > 0) {
1290
		dev->chip_id = rc;
1291 1292

		switch (dev->chip_id) {
1293 1294 1295
		case CHIP_ID_EM2750:
			em28xx_info("chip ID is em2750\n");
			break;
1296 1297 1298 1299 1300 1301
		case CHIP_ID_EM2820:
			em28xx_info("chip ID is em2820\n");
			break;
		case CHIP_ID_EM2840:
			em28xx_info("chip ID is em2840\n");
			break;
1302 1303 1304
		case CHIP_ID_EM2860:
			em28xx_info("chip ID is em2860\n");
			break;
1305 1306
		case CHIP_ID_EM2874:
			em28xx_info("chip ID is em2874\n");
1307
			dev->reg_gpio_num = EM2874_R80_GPIO;
1308 1309
			dev->wait_after_write = 0;
			break;
1310
		case CHIP_ID_EM2883:
1311 1312 1313 1314
			em28xx_info("chip ID is em2882/em2883\n");
			dev->wait_after_write = 0;
			break;
		default:
1315
			em28xx_info("em28xx chip ID = %d\n", dev->chip_id);
1316 1317
		}
	}
1318 1319 1320 1321 1322 1323

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

1324 1325 1326
	/* Those are the default values for the majority of boards
	   Use those values if not specified otherwise at boards entry
	 */
1327 1328 1329
	if (!dev->board.xclk)
		dev->board.xclk = EM28XX_XCLK_IR_RC5_MODE |
				  EM28XX_XCLK_FREQUENCY_12MHZ;
1330

1331 1332 1333
	if (!dev->board.i2c_speed)
		dev->board.i2c_speed = EM28XX_I2C_CLK_WAIT_ENABLE |
				       EM28XX_I2C_FREQ_100_KHZ;
1334

1335 1336
	em28xx_write_reg(dev, EM28XX_R0F_XCLK, dev->board.xclk & 0x7f);
	em28xx_write_reg(dev, EM28XX_R06_I2C_CLK, dev->board.i2c_speed);
1337 1338
	msleep(50);

1339
	/* request some modules */
1340
	switch (dev->model) {
1341 1342
	case EM2880_BOARD_TERRATEC_PRODIGY_XS:
	case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900:
1343
	case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900_R2:
1344
	case EM2860_BOARD_TERRATEC_HYBRID_XS:
1345
	case EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950:
1346
	case EM2880_BOARD_PINNACLE_PCTV_HD_PRO:
1347 1348
	case EM2882_BOARD_PINNACLE_HYBRID_PRO:
	case EM2883_BOARD_KWORLD_HYBRID_A316:
1349
	case EM2880_BOARD_AMD_ATI_TV_WONDER_HD_600:
1350 1351 1352
		/* Sets GPO/GPIO sequences for this device */
		dev->analog_gpio      = hauppauge_wintv_hvr_900_analog;
		dev->digital_gpio     = hauppauge_wintv_hvr_900_digital;
1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390
		dev->tun_analog_gpio  = default_callback;
		dev->tun_digital_gpio = default_callback;
		break;

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

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

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

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

1392 1393 1394
	case EM2861_BOARD_PLEXTOR_PX_TV100U:
		/* FIXME guess */
		/* Turn on analog audio output */
1395
		em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xfd);
1396 1397 1398 1399
		break;

	case EM2861_BOARD_KWORLD_PVRTV_300U:
	case EM2880_BOARD_KWORLD_DVB_305U:
1400
		em28xx_write_reg(dev, EM28XX_R08_GPIO, 0x6d);
1401
		msleep(10);
1402
		em28xx_write_reg(dev, EM28XX_R08_GPIO, 0x7d);
1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413
		msleep(10);
		break;

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

	case EM2870_BOARD_COMPRO_VIDEOMATE:
		/* TODO: someone can do some cleanup here...
			 not everything's needed */
1414
		em28xx_write_reg(dev, EM2880_R04_GPO, 0x00);
1415
		msleep(10);
1416
		em28xx_write_reg(dev, EM2880_R04_GPO, 0x01);
1417
		msleep(10);
1418
		em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xfd);
1419
		mdelay(70);
1420
		em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xfc);
1421
		mdelay(70);
1422
		em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xdc);
1423
		mdelay(70);
1424
		em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xfc);
1425 1426 1427 1428 1429 1430
		mdelay(70);
		break;

	case EM2870_BOARD_TERRATEC_XS_MT2060:
		/* this device needs some gpio writes to get the DVB-T
		   demod work */
1431
		em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xfe);
1432
		mdelay(70);
1433
		em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xde);
1434
		mdelay(70);
1435
		em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xfe);
1436 1437 1438 1439 1440 1441
		mdelay(70);
		break;

	case EM2870_BOARD_PINNACLE_PCTV_DVB:
		/* this device needs some gpio writes to get the
		   DVB-T demod work */
1442
		em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xfe);
1443
		mdelay(70);
1444
		em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xde);
1445
		mdelay(70);
1446
		em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xfe);
1447 1448 1449 1450 1451
		mdelay(70);
		break;

	case EM2820_BOARD_GADMEI_UTV310:
	case EM2820_BOARD_MSI_VOX_USB_2:
1452
		/* enables audio for that devices */
1453
		em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xfd);
1454
		break;
1455 1456 1457 1458

	case EM2874_BOARD_PINNACLE_PCTV_80E:
		dev->digital_gpio = em2874_pinnacle_80e_digital;
		break;
1459
	}
1460 1461 1462 1463 1464 1465

	em28xx_gpio_set(dev, dev->tun_analog_gpio);
	em28xx_set_mode(dev, EM28XX_ANALOG_MODE);

	/* Unlock device */
	em28xx_set_mode(dev, EM28XX_MODE_UNDEFINED);
1466 1467
}

1468
static void em28xx_setup_xc3028(struct em28xx *dev, struct xc2028_ctrl *ctl)
1469 1470 1471 1472 1473 1474 1475 1476
{
	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) {
1477 1478 1479
	case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900:
		ctl->demod = XC3028_FE_ZARLINK456;
		break;
1480 1481 1482
	case EM2880_BOARD_TERRATEC_HYBRID_XS:
		ctl->demod = XC3028_FE_ZARLINK456;
		break;
1483 1484 1485 1486
	case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900_R2:
		/* djh - Not sure which demod we need here */
		ctl->demod = XC3028_FE_DEFAULT;
		break;
1487 1488 1489 1490
	case EM2880_BOARD_AMD_ATI_TV_WONDER_HD_600:
		ctl->demod = XC3028_FE_DEFAULT;
		ctl->fname = XC3028L_DEFAULT_FIRMWARE;
		break;
1491
	case EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950:
1492
	case EM2880_BOARD_PINNACLE_PCTV_HD_PRO:
1493
		/* FIXME: Better to specify the needed IF */
1494 1495
		ctl->demod = XC3028_FE_DEFAULT;
		break;
1496 1497 1498 1499 1500
	default:
		ctl->demod = XC3028_FE_OREN538;
	}
}

1501
static void em28xx_config_tuner(struct em28xx *dev)
1502 1503
{
	struct v4l2_priv_tun_config  xc2028_cfg;
1504 1505 1506
	struct tuner_setup           tun_setup;
	struct v4l2_frequency        f;

1507
	if (dev->tuner_type == TUNER_ABSENT)
1508 1509 1510 1511 1512 1513 1514 1515 1516 1517
		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) {
1518
		struct xc2028_ctrl           ctl;
1519

1520
		em28xx_setup_xc3028(dev, &ctl);
1521 1522 1523

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

1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538
		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;
1539

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

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

1564 1565 1566
			return 0;
		}
	}
1567

1568 1569 1570 1571 1572 1573 1574 1575 1576
	/* 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.
	 */

1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599
	/* 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;
		}
	}

1600 1601 1602 1603 1604 1605 1606
	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);
1607
	em28xx_errdev("Board i2c devicelist hash is 0x%08lx\n", dev->i2c_hash);
1608 1609 1610 1611 1612 1613 1614 1615

	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;
1616 1617
}

1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656
/* ----------------------------------------------------------------------- */
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;
1657 1658
	case (EM2800_BOARD_GRABBEEX_USB2800):
		break;
1659 1660 1661
	}
}

1662
void em28xx_card_setup(struct em28xx *dev)
1663
{
1664 1665 1666
	em28xx_set_model(dev);

	dev->tuner_type = em28xx_boards[dev->model].tuner_type;
1667 1668
	if (em28xx_boards[dev->model].tuner_addr)
		dev->tuner_addr = em28xx_boards[dev->model].tuner_addr;
1669

1670
	/* request some modules */
1671 1672
	switch (dev->model) {
	case EM2820_BOARD_HAUPPAUGE_WINTV_USB_2:
1673
	case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900:
1674
	case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900_R2:
1675
	case EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950:
1676 1677
	{
		struct tveeprom tv;
1678
#ifdef CONFIG_MODULES
1679
		request_module("tveeprom");
1680
#endif
1681 1682 1683 1684
		/* Call first TVeeprom */

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

1686
		dev->tuner_type = tv.tuner_type;
1687

1688
		if (tv.audio_processor == V4L2_IDENT_MSPX4XX) {
1689
			dev->i2s_speed = 2048000;
1690
			dev->board.has_msp34xx = 1;
1691
		}
1692 1693 1694 1695
#ifdef CONFIG_MODULES
		if (tv.has_ir)
			request_module("ir-kbd-i2c");
#endif
1696
		break;
1697
	}
1698 1699
	case EM2820_BOARD_KWORLD_PVRTV2800RF:
		/* GPIO enables sound on KWORLD PVR TV 2800RF */
1700
		em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xf9);
1701 1702 1703
		break;
	case EM2820_BOARD_UNKNOWN:
	case EM2800_BOARD_UNKNOWN:
1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717
		/*
		 * 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:
1718 1719
		if (!em28xx_hint_board(dev))
			em28xx_set_model(dev);
1720
		break;
1721 1722
	}

1723
	if (dev->board.has_snapshot_button)
1724 1725
		em28xx_register_snapshot_button(dev);

1726
	if (dev->board.valid == EM28XX_BOARD_NOT_VALIDATED) {
1727 1728 1729 1730 1731 1732 1733 1734
		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");
	}

1735
	/* Allow override tuner type by a module parameter */
1736 1737 1738 1739 1740
	if (tuner >= 0)
		dev->tuner_type = tuner;

#ifdef CONFIG_MODULES
	/* request some modules */
1741
	if (dev->board.has_msp34xx)
1742
		request_module("msp3400");
1743
	if (dev->board.decoder == EM28XX_SAA711X)
1744
		request_module("saa7115");
1745
	if (dev->board.decoder == EM28XX_TVP5150)
1746
		request_module("tvp5150");
1747
	if (dev->board.tuner_type != TUNER_ABSENT)
1748 1749 1750
		request_module("tuner");
#endif

1751
	em28xx_config_tuner(dev);
1752 1753

	em28xx_ir_init(dev);
1754
}