em28xx-cards.c 56.5 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 57 58 59 60
	[EM2750_BOARD_UNKNOWN] = {
		.name          = "Unknown EM2750/EM2751 webcam grabber",
		.vchannels     = 1,
		.input         = { {
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = 0,
61
			.amux     = EM28XX_AMUX_VIDEO,
62 63
		} },
	},
64 65 66 67 68
	[EM2800_BOARD_UNKNOWN] = {
		.name         = "Unknown EM2800 video grabber",
		.is_em2800    = 1,
		.vchannels    = 2,
		.tda9887_conf = TDA9887_PRESENT,
69
		.decoder      = EM28XX_SAA7113,
70
		.input           = { {
71
			.type     = EM28XX_VMUX_COMPOSITE1,
72
			.vmux     = SAA7115_COMPOSITE0,
73
			.amux     = EM28XX_AMUX_LINE_IN,
74
		}, {
75
			.type     = EM28XX_VMUX_SVIDEO,
76
			.vmux     = SAA7115_SVIDEO3,
77
			.amux     = EM28XX_AMUX_LINE_IN,
78
		} },
79 80
	},
	[EM2820_BOARD_UNKNOWN] = {
81
		.name         = "Unknown EM2750/28xx video grabber",
82
		.is_em2800    = 0,
83
		.tuner_type   = TUNER_ABSENT,
84
	},
85 86 87 88 89 90 91 92
	[EM2750_BOARD_DLCW_130] = {
		/* Beijing Huaqi Information Digital Technology Co., Ltd */
		.name          = "Huaqi DLCW-130",
		.valid         = EM28XX_BOARD_NOT_VALIDATED,
		.vchannels     = 1,
		.input         = { {
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = 0,
93
			.amux     = EM28XX_AMUX_VIDEO,
94 95
		} },
	},
96
	[EM2820_BOARD_KWORLD_PVRTV2800RF] = {
97
		.name         = "Kworld PVR TV 2800 RF",
98 99
		.is_em2800    = 0,
		.vchannels    = 2,
100
		.tuner_type   = TUNER_TEMIC_PAL,
101 102
		.tda9887_conf = TDA9887_PRESENT,
		.decoder      = EM28XX_SAA7113,
103
		.input           = { {
104
			.type     = EM28XX_VMUX_COMPOSITE1,
105
			.vmux     = SAA7115_COMPOSITE0,
106
			.amux     = EM28XX_AMUX_LINE_IN,
107
		}, {
108
			.type     = EM28XX_VMUX_SVIDEO,
109
			.vmux     = SAA7115_SVIDEO3,
110
			.amux     = EM28XX_AMUX_LINE_IN,
111
		} },
112
	},
113 114 115 116 117
	[EM2820_BOARD_TERRATEC_CINERGY_250] = {
		.name         = "Terratec Cinergy 250 USB",
		.vchannels    = 3,
		.tuner_type   = TUNER_LG_PAL_NEW_TAPC,
		.tda9887_conf = TDA9887_PRESENT,
118
		.decoder      = EM28XX_SAA7113,
119
		.input          = { {
120
			.type     = EM28XX_VMUX_TELEVISION,
121
			.vmux     = SAA7115_COMPOSITE2,
122
			.amux     = EM28XX_AMUX_LINE_IN,
123
		}, {
124
			.type     = EM28XX_VMUX_COMPOSITE1,
125
			.vmux     = SAA7115_COMPOSITE0,
126
			.amux     = EM28XX_AMUX_LINE_IN,
127
		}, {
128
			.type     = EM28XX_VMUX_SVIDEO,
129
			.vmux     = SAA7115_SVIDEO3,
130
			.amux     = EM28XX_AMUX_LINE_IN,
131
		} },
132 133 134 135 136 137
	},
	[EM2820_BOARD_PINNACLE_USB_2] = {
		.name         = "Pinnacle PCTV USB 2",
		.vchannels    = 3,
		.tuner_type   = TUNER_LG_PAL_NEW_TAPC,
		.tda9887_conf = TDA9887_PRESENT,
138
		.decoder      = EM28XX_SAA7113,
139
		.input          = { {
140
			.type     = EM28XX_VMUX_TELEVISION,
141
			.vmux     = SAA7115_COMPOSITE2,
142
			.amux     = EM28XX_AMUX_VIDEO,
143
		}, {
144
			.type     = EM28XX_VMUX_COMPOSITE1,
145
			.vmux     = SAA7115_COMPOSITE0,
146
			.amux     = EM28XX_AMUX_LINE_IN,
147
		}, {
148
			.type     = EM28XX_VMUX_SVIDEO,
149
			.vmux     = SAA7115_SVIDEO3,
150
			.amux     = EM28XX_AMUX_LINE_IN,
151
		} },
152 153 154 155 156
	},
	[EM2820_BOARD_HAUPPAUGE_WINTV_USB_2] = {
		.name         = "Hauppauge WinTV USB 2",
		.vchannels    = 3,
		.tuner_type   = TUNER_PHILIPS_FM1236_MK3,
157 158 159
		.tda9887_conf = TDA9887_PRESENT |
				TDA9887_PORT1_ACTIVE|
				TDA9887_PORT2_ACTIVE,
160
		.decoder      = EM28XX_TVP5150,
161 162
		.has_msp34xx  = 1,
		/*FIXME: S-Video not tested */
163
		.input          = { {
164
			.type     = EM28XX_VMUX_TELEVISION,
165
			.vmux     = TVP5150_COMPOSITE0,
166
			.amux     = MSP_INPUT_DEFAULT,
167
		}, {
168
			.type     = EM28XX_VMUX_SVIDEO,
169
			.vmux     = TVP5150_SVIDEO,
170 171
			.amux     = MSP_INPUT(MSP_IN_SCART1, MSP_IN_TUNER1,
					MSP_DSP_IN_SCART, MSP_DSP_IN_SCART),
172
		} },
173
	},
174 175 176 177 178 179 180 181 182 183 184
	[EM2820_BOARD_DLINK_USB_TV] = {
		.name         = "D-Link DUB-T210 TV Tuner",
		.valid        = EM28XX_BOARD_NOT_VALIDATED,
		.vchannels    = 3,
		.is_em2800    = 0,
		.tuner_type   = TUNER_LG_PAL_NEW_TAPC,
		.tda9887_conf = TDA9887_PRESENT,
		.decoder      = EM28XX_SAA7113,
		.input          = { {
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = SAA7115_COMPOSITE2,
185
			.amux     = EM28XX_AMUX_LINE_IN,
186 187 188
		}, {
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = SAA7115_COMPOSITE0,
189
			.amux     = EM28XX_AMUX_LINE_IN,
190 191 192
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = SAA7115_SVIDEO3,
193
			.amux     = EM28XX_AMUX_LINE_IN,
194 195 196 197 198 199 200 201 202 203 204 205
		} },
	},
	[EM2820_BOARD_HERCULES_SMART_TV_USB2] = {
		.name         = "Hercules Smart TV USB 2.0",
		.valid        = EM28XX_BOARD_NOT_VALIDATED,
		.vchannels    = 3,
		.tuner_type   = TUNER_LG_PAL_NEW_TAPC,
		.tda9887_conf = TDA9887_PRESENT,
		.decoder      = EM28XX_SAA7113,
		.input        = { {
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = SAA7115_COMPOSITE2,
206
			.amux     = EM28XX_AMUX_LINE_IN,
207 208 209
		}, {
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = SAA7115_COMPOSITE0,
210
			.amux     = EM28XX_AMUX_LINE_IN,
211 212 213
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = SAA7115_SVIDEO3,
214
			.amux     = EM28XX_AMUX_LINE_IN,
215 216 217 218 219 220 221 222 223 224 225 226 227
		} },
	},
	[EM2820_BOARD_PINNACLE_USB_2_FM1216ME] = {
		.name         = "Pinnacle PCTV USB 2 (Philips FM1216ME)",
		.valid        = EM28XX_BOARD_NOT_VALIDATED,
		.vchannels    = 3,
		.is_em2800    = 0,
		.tuner_type   = TUNER_PHILIPS_FM1216ME_MK3,
		.tda9887_conf = TDA9887_PRESENT,
		.decoder      = EM28XX_SAA7113,
		.input          = { {
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = SAA7115_COMPOSITE2,
228
			.amux     = EM28XX_AMUX_VIDEO,
229 230 231
		}, {
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = SAA7115_COMPOSITE0,
232
			.amux     = EM28XX_AMUX_LINE_IN,
233 234 235
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = SAA7115_SVIDEO3,
236
			.amux     = EM28XX_AMUX_LINE_IN,
237 238 239 240 241 242 243 244 245 246 247 248
		} },
	},
	[EM2820_BOARD_GADMEI_UTV310] = {
		.name         = "Gadmei UTV310",
		.valid        = EM28XX_BOARD_NOT_VALIDATED,
		.vchannels    = 3,
		.tuner_type   = TUNER_TNF_5335MF,
		.tda9887_conf = TDA9887_PRESENT,
		.decoder      = EM28XX_SAA7113,
		.input          = { {
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = SAA7115_COMPOSITE1,
249
			.amux     = EM28XX_AMUX_LINE_IN,
250 251 252
		}, {
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = SAA7115_COMPOSITE0,
253
			.amux     = EM28XX_AMUX_LINE_IN,
254 255 256
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = SAA7115_SVIDEO3,
257
			.amux     = EM28XX_AMUX_LINE_IN,
258 259 260 261 262 263 264 265 266 267 268 269
		} },
	},
	[EM2820_BOARD_LEADTEK_WINFAST_USBII_DELUXE] = {
		.name         = "Leadtek Winfast USB II Deluxe",
		.valid        = EM28XX_BOARD_NOT_VALIDATED,
		.vchannels    = 3,
		.tuner_type   = TUNER_PHILIPS_FM1216ME_MK3,
		.tda9887_conf = TDA9887_PRESENT,
		.decoder      = EM28XX_SAA7114,
		.input          = { {
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = 2,
270
			.amux     = EM28XX_AMUX_VIDEO,
271 272 273
		}, {
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = 0,
274
			.amux     = EM28XX_AMUX_LINE_IN,
275 276 277
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = 9,
278
			.amux     = EM28XX_AMUX_LINE_IN,
279 280 281 282 283 284 285 286 287 288
		} },
	},
	[EM2820_BOARD_PINNACLE_DVC_100] = {
		.name         = "Pinnacle Dazzle DVC 100",
		.valid        = EM28XX_BOARD_NOT_VALIDATED,
		.vchannels    = 3,
		.decoder      = EM28XX_SAA7113,
		.input          = { {
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = SAA7115_COMPOSITE0,
289
			.amux     = EM28XX_AMUX_LINE_IN,
290 291 292
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = SAA7115_SVIDEO3,
293
			.amux     = EM28XX_AMUX_LINE_IN,
294 295 296 297 298 299 300 301 302
		} },
	},
	[EM2820_BOARD_VIDEOLOGY_20K14XUSB] = {
		.name          = "Videology 20K14XUSB USB2.0",
		.valid        = EM28XX_BOARD_NOT_VALIDATED,
		.vchannels     = 1,
		.input         = { {
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = 0,
303
			.amux     = EM28XX_AMUX_VIDEO,
304 305 306 307 308 309 310 311 312 313 314 315 316
		} },
	},
	[EM2821_BOARD_PROLINK_PLAYTV_USB2] = {
		.name         = "SIIG AVTuner-PVR/Prolink PlayTV USB 2.0",
		.valid        = EM28XX_BOARD_NOT_VALIDATED,
		.vchannels    = 3,
		.is_em2800    = 0,
		.tuner_type   = TUNER_LG_PAL_NEW_TAPC,	/* unknown? */
		.tda9887_conf = TDA9887_PRESENT,	/* unknown? */
		.decoder      = EM28XX_SAA7113,
		.input          = { {
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = SAA7115_COMPOSITE2,
317
			.amux     = EM28XX_AMUX_LINE_IN,
318 319 320
		}, {
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = SAA7115_COMPOSITE0,
321
			.amux     = EM28XX_AMUX_LINE_IN,
322 323 324
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = SAA7115_SVIDEO3,
325
			.amux     = EM28XX_AMUX_LINE_IN,
326 327 328 329 330 331 332 333 334 335 336 337 338 339 340
		} },
	},
	[EM2821_BOARD_SUPERCOMP_USB_2] = {
		.name         = "Supercomp USB 2.0 TV",
		.valid        = EM28XX_BOARD_NOT_VALIDATED,
		.vchannels    = 3,
		.is_em2800    = 0,
		.tuner_type   = TUNER_PHILIPS_FM1236_MK3,
		.tda9887_conf = TDA9887_PRESENT |
				TDA9887_PORT1_ACTIVE |
				TDA9887_PORT2_ACTIVE,
		.decoder      = EM28XX_SAA7113,
		.input          = { {
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = SAA7115_COMPOSITE2,
341
			.amux     = EM28XX_AMUX_LINE_IN,
342 343 344
		}, {
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = SAA7115_COMPOSITE0,
345
			.amux     = EM28XX_AMUX_VIDEO,
346 347 348
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = SAA7115_SVIDEO3,
349
			.amux     = EM28XX_AMUX_LINE_IN,
350 351 352 353 354 355 356 357 358 359
		} },
	},
	[EM2821_BOARD_USBGEAR_VD204] = {
		.name          = "Usbgear VD204v9",
		.valid        = EM28XX_BOARD_NOT_VALIDATED,
		.vchannels     = 2,
		.decoder       = EM28XX_SAA7113,
		.input          = { {
			.type  = EM28XX_VMUX_COMPOSITE1,
			.vmux  = SAA7115_COMPOSITE0,
360
			.amux  = EM28XX_AMUX_LINE_IN,
361 362 363
		}, {
			.type  = EM28XX_VMUX_SVIDEO,
			.vmux  = SAA7115_SVIDEO3,
364
			.amux  = EM28XX_AMUX_LINE_IN,
365 366 367 368 369 370 371 372 373 374
		} },
	},
	[EM2860_BOARD_NETGMBH_CAM] = {
		/* Beijing Huaqi Information Digital Technology Co., Ltd */
		.name          = "NetGMBH Cam",
		.valid       = EM28XX_BOARD_NOT_VALIDATED,
		.vchannels     = 1,
		.input         = { {
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = 0,
375
			.amux     = EM28XX_AMUX_VIDEO,
376 377 378 379 380 381 382 383 384 385
		} },
	},
	[EM2860_BOARD_TYPHOON_DVD_MAKER] = {
		.name          = "Typhoon DVD Maker",
		.valid        = EM28XX_BOARD_NOT_VALIDATED,
		.vchannels     = 2,
		.decoder       = EM28XX_SAA7113,
		.input          = { {
			.type  = EM28XX_VMUX_COMPOSITE1,
			.vmux  = SAA7115_COMPOSITE0,
386
			.amux  = EM28XX_AMUX_LINE_IN,
387 388 389
		}, {
			.type  = EM28XX_VMUX_SVIDEO,
			.vmux  = SAA7115_SVIDEO3,
390
			.amux  = EM28XX_AMUX_LINE_IN,
391 392 393 394 395
		} },
	},
	[EM2860_BOARD_GADMEI_UTV330] = {
		.name         = "Gadmei UTV330",
		.valid        = EM28XX_BOARD_NOT_VALIDATED,
396
		.vchannels    = 3,
397
		.tuner_type   = TUNER_TNF_5335MF,
398
		.tda9887_conf = TDA9887_PRESENT,
399 400 401 402
		.decoder      = EM28XX_SAA7113,
		.input          = { {
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = SAA7115_COMPOSITE2,
403
			.amux     = EM28XX_AMUX_VIDEO,
404 405 406
		}, {
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = SAA7115_COMPOSITE0,
407
			.amux     = EM28XX_AMUX_LINE_IN,
408 409 410
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = SAA7115_SVIDEO3,
411
			.amux     = EM28XX_AMUX_LINE_IN,
412 413 414 415 416 417
		} },
	},
	[EM2860_BOARD_TERRATEC_HYBRID_XS] = {
		.name         = "Terratec Cinergy A Hybrid XS",
		.valid        = EM28XX_BOARD_NOT_VALIDATED,
		.vchannels    = 3,
418 419
		.tuner_type   = TUNER_XC2028,
		.decoder      = EM28XX_TVP5150,
420
		.input          = { {
421 422
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = TVP5150_COMPOSITE0,
423
			.amux     = EM28XX_AMUX_VIDEO,
424
		}, {
425 426
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = TVP5150_COMPOSITE1,
427
			.amux     = EM28XX_AMUX_LINE_IN,
428
		}, {
429 430
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = TVP5150_SVIDEO,
431
			.amux     = EM28XX_AMUX_LINE_IN,
432
		} },
433
	},
434 435 436
	[EM2861_BOARD_KWORLD_PVRTV_300U] = {
		.name	      = "KWorld PVRTV 300U",
		.valid        = EM28XX_BOARD_NOT_VALIDATED,
437 438 439 440 441 442
		.vchannels    = 3,
		.tuner_type   = TUNER_XC2028,
		.decoder      = EM28XX_TVP5150,
		.input          = { {
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = TVP5150_COMPOSITE0,
443
			.amux     = EM28XX_AMUX_VIDEO,
444 445 446
		}, {
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = TVP5150_COMPOSITE1,
447
			.amux     = EM28XX_AMUX_LINE_IN,
448 449 450
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = TVP5150_SVIDEO,
451
			.amux     = EM28XX_AMUX_LINE_IN,
452 453
		} },
	},
454 455 456 457 458 459
	[EM2861_BOARD_YAKUMO_MOVIE_MIXER] = {
		.name          = "Yakumo MovieMixer",
		.valid       = EM28XX_BOARD_NOT_VALIDATED,
		.vchannels     = 1,
		.decoder       = EM28XX_TVP5150,
		.input         = { {
460 461
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = TVP5150_COMPOSITE0,
462
			.amux     = EM28XX_AMUX_VIDEO,
463
		}, {
464 465
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = TVP5150_COMPOSITE1,
466
			.amux     = EM28XX_AMUX_LINE_IN,
467
		}, {
468 469
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = TVP5150_SVIDEO,
470
			.amux     = EM28XX_AMUX_LINE_IN,
471
		} },
472
	},
473 474 475 476 477 478 479
	[EM2861_BOARD_PLEXTOR_PX_TV100U] = {
		.name         = "Plextor ConvertX PX-TV100U",
		.valid        = EM28XX_BOARD_NOT_VALIDATED,
		.vchannels    = 3,
		.tuner_type   = TUNER_TNF_5335MF,
		.tda9887_conf = TDA9887_PRESENT,
		.decoder      = EM28XX_TVP5150,
480 481 482
		.input          = { {
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = TVP5150_COMPOSITE0,
483
			.amux     = EM28XX_AMUX_LINE_IN,
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 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529
	[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 */
	},
	[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,
		.vchannels    = 3,
		.has_msp34xx  = 1,
		.tuner_type   = TUNER_XC2028,
		.decoder      = EM28XX_TVP5150,
530 531 532
		.input          = { {
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = TVP5150_COMPOSITE0,
533
			.amux     = EM28XX_AMUX_VIDEO,
534 535 536
		}, {
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = TVP5150_COMPOSITE1,
537
			.amux     = EM28XX_AMUX_LINE_IN,
538 539 540
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = TVP5150_SVIDEO,
541
			.amux     = EM28XX_AMUX_LINE_IN,
542 543
		} },
	},
544 545 546 547 548 549 550 551 552 553 554
	[EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900] = {
		.name         = "Hauppauge WinTV HVR 900",
		.vchannels    = 3,
		.tda9887_conf = TDA9887_PRESENT,
		.tuner_type   = TUNER_XC2028,
		.mts_firmware = 1,
		.has_dvb        = 1,
		.decoder      = EM28XX_TVP5150,
		.input          = { {
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = TVP5150_COMPOSITE0,
555
			.amux     = EM28XX_AMUX_VIDEO,
556 557 558
		}, {
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = TVP5150_COMPOSITE1,
559
			.amux     = EM28XX_AMUX_LINE_IN,
560 561 562
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = TVP5150_SVIDEO,
563
			.amux     = EM28XX_AMUX_LINE_IN,
564 565 566 567 568 569 570 571 572 573 574 575
		} },
	},
	[EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900_R2] = {
		.name         = "Hauppauge WinTV HVR 900 (R2)",
		.vchannels    = 3,
		.tda9887_conf = TDA9887_PRESENT,
		.tuner_type   = TUNER_XC2028,
		.mts_firmware = 1,
		.decoder      = EM28XX_TVP5150,
		.input          = { {
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = TVP5150_COMPOSITE0,
576
			.amux     = EM28XX_AMUX_VIDEO,
577 578 579
		}, {
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = TVP5150_COMPOSITE1,
580
			.amux     = 3,
581 582 583
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = TVP5150_SVIDEO,
584
			.amux     = EM28XX_AMUX_LINE_IN,
585 586
		} },
	},
587
	[EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950] = {
588 589 590 591 592 593
		.name           = "Hauppauge WinTV HVR 950",
		.vchannels      = 3,
		.tuner_type     = TUNER_XC2028,
		.mts_firmware   = 1,
		.has_12mhz_i2s  = 1,
		.has_dvb        = 1,
594
		.ir_codes       = ir_codes_hauppauge_new,
595 596 597 598
		.decoder        = EM28XX_TVP5150,
		.input          = { {
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = TVP5150_COMPOSITE0,
599
			.amux     = EM28XX_AMUX_VIDEO,
600 601 602
		}, {
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = TVP5150_COMPOSITE1,
603
			.amux     = EM28XX_AMUX_LINE_IN,
604 605 606
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = TVP5150_SVIDEO,
607
			.amux     = EM28XX_AMUX_LINE_IN,
608 609 610 611 612 613 614 615 616
		} },
	},
	[EM2880_BOARD_PINNACLE_PCTV_HD_PRO] = {
		.name           = "Pinnacle PCTV HD Pro Stick",
		.vchannels      = 3,
		.tuner_type     = TUNER_XC2028,
		.mts_firmware   = 1,
		.has_12mhz_i2s  = 1,
		.has_dvb        = 1,
617
		.ir_codes       = ir_codes_pinnacle_pctv_hd,
618 619 620 621
		.decoder        = EM28XX_TVP5150,
		.input          = { {
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = TVP5150_COMPOSITE0,
622
			.amux     = EM28XX_AMUX_VIDEO,
623 624 625
		}, {
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = TVP5150_COMPOSITE1,
626
			.amux     = EM28XX_AMUX_LINE_IN,
627 628 629
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = TVP5150_SVIDEO,
630
			.amux     = EM28XX_AMUX_LINE_IN,
631 632 633 634 635 636 637 638 639
		} },
	},
	[EM2880_BOARD_AMD_ATI_TV_WONDER_HD_600] = {
		.name           = "AMD ATI TV Wonder HD 600",
		.vchannels      = 3,
		.tuner_type     = TUNER_XC2028,
		.mts_firmware   = 1,
		.has_12mhz_i2s  = 1,
		.has_dvb        = 1,
640
		.ir_codes       = ir_codes_ati_tv_wonder_hd_600,
641 642 643 644
		.decoder        = EM28XX_TVP5150,
		.input          = { {
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = TVP5150_COMPOSITE0,
645
			.amux     = EM28XX_AMUX_VIDEO,
646 647 648
		}, {
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = TVP5150_COMPOSITE1,
649
			.amux     = EM28XX_AMUX_LINE_IN,
650 651 652
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = TVP5150_SVIDEO,
653
			.amux     = EM28XX_AMUX_LINE_IN,
654 655 656 657 658 659 660 661 662 663 664
		} },
	},
	[EM2880_BOARD_TERRATEC_HYBRID_XS] = {
		.name         = "Terratec Hybrid XS",
		.vchannels    = 3,
		.tuner_type   = TUNER_XC2028,
		.decoder      = EM28XX_TVP5150,
		.has_dvb        = 1,
		.input          = { {
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = TVP5150_COMPOSITE0,
665
			.amux     = EM28XX_AMUX_VIDEO,
666 667 668
		}, {
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = TVP5150_COMPOSITE1,
669
			.amux     = EM28XX_AMUX_LINE_IN,
670 671 672
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = TVP5150_SVIDEO,
673
			.amux     = EM28XX_AMUX_LINE_IN,
674 675 676 677 678 679 680 681 682 683 684 685 686
		} },
	},
	/* 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",
		.vchannels    = 3,
		.tuner_type   = TUNER_XC2028,
		.decoder      = EM28XX_TVP5150,
		.input          = { {
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = TVP5150_COMPOSITE0,
687
			.amux     = EM28XX_AMUX_VIDEO,
688 689 690
		}, {
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = TVP5150_COMPOSITE1,
691
			.amux     = EM28XX_AMUX_LINE_IN,
692 693 694
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = TVP5150_SVIDEO,
695
			.amux     = EM28XX_AMUX_LINE_IN,
696 697 698 699 700 701 702 703 704 705 706 707 708 709 710
		} },
	},
	[EM2820_BOARD_MSI_VOX_USB_2] = {
		.name		   = "MSI VOX USB 2.0",
		.vchannels	   = 3,
		.tuner_type	   = TUNER_LG_PAL_NEW_TAPC,
		.tda9887_conf	   = TDA9887_PRESENT      |
				     TDA9887_PORT1_ACTIVE |
				     TDA9887_PORT2_ACTIVE,
		.max_range_640_480 = 1,

		.decoder           = EM28XX_SAA7114,
		.input             = { {
			.type      = EM28XX_VMUX_TELEVISION,
			.vmux      = SAA7115_COMPOSITE4,
711
			.amux      = EM28XX_AMUX_VIDEO,
712 713 714
		}, {
			.type      = EM28XX_VMUX_COMPOSITE1,
			.vmux      = SAA7115_COMPOSITE0,
715
			.amux      = EM28XX_AMUX_LINE_IN,
716 717 718
		}, {
			.type      = EM28XX_VMUX_SVIDEO,
			.vmux      = SAA7115_SVIDEO3,
719
			.amux      = EM28XX_AMUX_LINE_IN,
720 721 722 723 724 725 726 727 728 729 730 731
		} },
	},
	[EM2800_BOARD_TERRATEC_CINERGY_200] = {
		.name         = "Terratec Cinergy 200 USB",
		.is_em2800    = 1,
		.vchannels    = 3,
		.tuner_type   = TUNER_LG_PAL_NEW_TAPC,
		.tda9887_conf = TDA9887_PRESENT,
		.decoder      = EM28XX_SAA7113,
		.input          = { {
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = SAA7115_COMPOSITE2,
732
			.amux     = EM28XX_AMUX_VIDEO,
733 734 735
		}, {
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = SAA7115_COMPOSITE0,
736
			.amux     = EM28XX_AMUX_LINE_IN,
737 738 739
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = SAA7115_SVIDEO3,
740
			.amux     = EM28XX_AMUX_LINE_IN,
741 742 743 744 745 746 747 748 749 750
		} },
	},
	[EM2800_BOARD_GRABBEEX_USB2800] = {
		.name         = "eMPIA Technology, Inc. GrabBeeX+ Video Encoder",
		.is_em2800    = 1,
		.vchannels    = 2,
		.decoder      = EM28XX_SAA7113,
		.input          = { {
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = SAA7115_COMPOSITE0,
751
			.amux     = EM28XX_AMUX_LINE_IN,
752 753 754
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = SAA7115_SVIDEO3,
755
			.amux     = EM28XX_AMUX_LINE_IN,
756 757 758 759 760 761 762 763 764 765 766 767
		} },
	},
	[EM2800_BOARD_LEADTEK_WINFAST_USBII] = {
		.name         = "Leadtek Winfast USB II",
		.is_em2800    = 1,
		.vchannels    = 3,
		.tuner_type   = TUNER_LG_PAL_NEW_TAPC,
		.tda9887_conf = TDA9887_PRESENT,
		.decoder      = EM28XX_SAA7113,
		.input          = { {
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = SAA7115_COMPOSITE2,
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 784 785 786 787 788
		} },
	},
	[EM2800_BOARD_KWORLD_USB2800] = {
		.name         = "Kworld USB2800",
		.is_em2800    = 1,
		.vchannels    = 3,
		.tuner_type   = TUNER_PHILIPS_FCV1236D,
		.tda9887_conf = TDA9887_PRESENT,
		.decoder      = EM28XX_SAA7113,
		.input          = { {
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = SAA7115_COMPOSITE2,
789
			.amux     = EM28XX_AMUX_VIDEO,
790 791 792
		}, {
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = SAA7115_COMPOSITE0,
793
			.amux     = EM28XX_AMUX_LINE_IN,
794 795 796
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = SAA7115_SVIDEO3,
797
			.amux     = EM28XX_AMUX_LINE_IN,
798 799 800 801 802 803 804 805 806 807
		} },
	},
	[EM2820_BOARD_PINNACLE_DVC_90] = {
		.name         = "Pinnacle Dazzle DVC 90/DVC 100",
		.vchannels    = 3,
		.tuner_type   = TUNER_ABSENT,
		.decoder      = EM28XX_SAA7113,
		.input          = { {
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = SAA7115_COMPOSITE0,
808
			.amux     = EM28XX_AMUX_LINE_IN,
809 810 811
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = SAA7115_SVIDEO3,
812
			.amux     = EM28XX_AMUX_LINE_IN,
813 814 815 816 817 818 819 820 821 822 823 824
		} },
	},
	[EM2800_BOARD_VGEAR_POCKETTV] = {
		.name         = "V-Gear PocketTV",
		.is_em2800    = 1,
		.vchannels    = 3,
		.tuner_type   = TUNER_LG_PAL_NEW_TAPC,
		.tda9887_conf = TDA9887_PRESENT,
		.decoder      = EM28XX_SAA7113,
		.input          = { {
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = SAA7115_COMPOSITE2,
825
			.amux     = EM28XX_AMUX_VIDEO,
826 827 828
		}, {
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = SAA7115_COMPOSITE0,
829
			.amux     = EM28XX_AMUX_LINE_IN,
830 831 832
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = SAA7115_SVIDEO3,
833
			.amux     = EM28XX_AMUX_LINE_IN,
834 835 836 837 838 839 840 841 842 843 844
		} },
	},
	[EM2820_BOARD_PROLINK_PLAYTV_USB2] = {
		.name         = "Pixelview Prolink PlayTV USB 2.0",
		.vchannels    = 3,
		.tda9887_conf = TDA9887_PRESENT,
		.tuner_type   = TUNER_YMEC_TVF_5533MF,
		.decoder      = EM28XX_SAA7113,
		.input          = { {
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = SAA7115_COMPOSITE2,
845 846 847
			.amux     = EM28XX_AMUX_VIDEO,
			.aout     = EM28XX_AOUT_MONO | 	/* I2S */
				    EM28XX_AOUT_MASTER,	/* Line out pin */
848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867
		}, {
			.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] = {
		.name         = "PointNix Intra-Oral Camera",
		.has_snapshot_button = 1,
		.vchannels    = 1,
		.tda9887_conf = TDA9887_PRESENT,
		.tuner_type   = TUNER_ABSENT,
		.decoder      = EM28XX_SAA7113,
		.input          = { {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = SAA7115_SVIDEO3,
868
			.amux     = EM28XX_AMUX_VIDEO,
869 870 871 872 873 874 875 876 877 878 879
		} },
	},
	[EM2880_BOARD_MSI_DIGIVOX_AD] = {
		.name         = "MSI DigiVox A/D",
		.valid        = EM28XX_BOARD_NOT_VALIDATED,
		.vchannels    = 3,
		.tuner_type   = TUNER_XC2028,
		.decoder      = EM28XX_TVP5150,
		.input          = { {
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = TVP5150_COMPOSITE0,
880
			.amux     = EM28XX_AMUX_VIDEO,
881 882 883
		}, {
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = TVP5150_COMPOSITE1,
884
			.amux     = EM28XX_AMUX_LINE_IN,
885 886 887
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = TVP5150_SVIDEO,
888
			.amux     = EM28XX_AMUX_LINE_IN,
889 890 891 892 893 894 895 896
		} },
	},
	[EM2880_BOARD_MSI_DIGIVOX_AD_II] = {
		.name         = "MSI DigiVox A/D II",
		.valid        = EM28XX_BOARD_NOT_VALIDATED,
		.vchannels    = 3,
		.tuner_type   = TUNER_XC2028,
		.decoder      = EM28XX_TVP5150,
897 898 899
		.input          = { {
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = TVP5150_COMPOSITE0,
900
			.amux     = EM28XX_AMUX_VIDEO,
901 902 903
		}, {
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = TVP5150_COMPOSITE1,
904
			.amux     = EM28XX_AMUX_LINE_IN,
905 906 907
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = TVP5150_SVIDEO,
908
			.amux     = EM28XX_AMUX_LINE_IN,
909 910
		} },
	},
911 912 913
	[EM2880_BOARD_KWORLD_DVB_305U] = {
		.name	      = "KWorld DVB-T 305U",
		.valid        = EM28XX_BOARD_NOT_VALIDATED,
914 915 916
		.vchannels    = 3,
		.tuner_type   = TUNER_XC2028,
		.decoder      = EM28XX_TVP5150,
917
		.input          = { {
918 919
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = TVP5150_COMPOSITE0,
920
			.amux     = EM28XX_AMUX_VIDEO,
921
		}, {
922 923
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = TVP5150_COMPOSITE1,
924
			.amux     = EM28XX_AMUX_LINE_IN,
925
		}, {
926 927
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = TVP5150_SVIDEO,
928
			.amux     = EM28XX_AMUX_LINE_IN,
929
		} },
930
	},
931 932
	[EM2880_BOARD_KWORLD_DVB_310U] = {
		.name	      = "KWorld DVB-T 310U",
933 934
		.vchannels    = 3,
		.tuner_type   = TUNER_XC2028,
935 936
		.has_dvb      = 1,
		.mts_firmware = 1,
937
		.decoder      = EM28XX_TVP5150,
938
		.input          = { {
939 940
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = TVP5150_COMPOSITE0,
941
			.amux     = EM28XX_AMUX_VIDEO,
942
		}, {
943 944
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = TVP5150_COMPOSITE1,
945
			.amux     = EM28XX_AMUX_LINE_IN,
946
		}, {	/* S-video has not been tested yet */
947 948
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = TVP5150_SVIDEO,
949
			.amux     = EM28XX_AMUX_LINE_IN,
950
		} },
951
	},
952 953 954
	[EM2881_BOARD_DNT_DA2_HYBRID] = {
		.name         = "DNT DA2 Hybrid",
		.valid        = EM28XX_BOARD_NOT_VALIDATED,
955
		.vchannels    = 3,
956 957
		.tuner_type   = TUNER_XC2028,
		.decoder      = EM28XX_TVP5150,
958
		.input          = { {
959
			.type     = EM28XX_VMUX_TELEVISION,
960
			.vmux     = TVP5150_COMPOSITE0,
961
			.amux     = EM28XX_AMUX_VIDEO,
962
		}, {
963
			.type     = EM28XX_VMUX_COMPOSITE1,
964
			.vmux     = TVP5150_COMPOSITE1,
965
			.amux     = EM28XX_AMUX_LINE_IN,
966
		}, {
967
			.type     = EM28XX_VMUX_SVIDEO,
968
			.vmux     = TVP5150_SVIDEO,
969
			.amux     = EM28XX_AMUX_LINE_IN,
970
		} },
971
	},
972 973 974 975 976 977
	[EM2881_BOARD_PINNACLE_HYBRID_PRO] = {
		.name         = "Pinnacle Hybrid Pro",
		.valid        = EM28XX_BOARD_NOT_VALIDATED,
		.vchannels    = 3,
		.tuner_type   = TUNER_XC2028,
		.decoder      = EM28XX_TVP5150,
978
		.input          = { {
979 980
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = TVP5150_COMPOSITE0,
981
			.amux     = EM28XX_AMUX_VIDEO,
982
		}, {
983
			.type     = EM28XX_VMUX_COMPOSITE1,
984
			.vmux     = TVP5150_COMPOSITE1,
985
			.amux     = EM28XX_AMUX_LINE_IN,
986 987
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
988
			.vmux     = TVP5150_SVIDEO,
989
			.amux     = EM28XX_AMUX_LINE_IN,
990 991
		} },
	},
992 993 994
	[EM2882_BOARD_PINNACLE_HYBRID_PRO] = {
		.name         = "Pinnacle Hybrid Pro (2)",
		.valid        = EM28XX_BOARD_NOT_VALIDATED,
995
		.vchannels    = 3,
996
		.tuner_type   = TUNER_XC2028,
997
		.mts_firmware = 1,
998
		.decoder      = EM28XX_TVP5150,
999
		.input          = { {
1000
			.type     = EM28XX_VMUX_TELEVISION,
1001
			.vmux     = TVP5150_COMPOSITE0,
1002
			.amux     = EM28XX_AMUX_VIDEO,
1003
		}, {
1004
			.type     = EM28XX_VMUX_COMPOSITE1,
1005
			.vmux     = TVP5150_COMPOSITE1,
1006
			.amux     = EM28XX_AMUX_LINE_IN,
1007
		}, {
1008
			.type     = EM28XX_VMUX_SVIDEO,
1009
			.vmux     = TVP5150_SVIDEO,
1010
			.amux     = EM28XX_AMUX_LINE_IN,
1011
		} },
1012
	},
1013 1014 1015
	[EM2882_BOARD_KWORLD_VS_DVBT] = {
		.name         = "Kworld VS-DVB-T 323UR",
		.valid        = EM28XX_BOARD_NOT_VALIDATED,
1016
		.vchannels    = 3,
1017 1018
		.tuner_type   = TUNER_XC2028,
		.decoder      = EM28XX_TVP5150,
1019
		.input          = { {
1020
			.type     = EM28XX_VMUX_TELEVISION,
1021
			.vmux     = TVP5150_COMPOSITE0,
1022
			.amux     = EM28XX_AMUX_VIDEO,
1023
		}, {
1024
			.type     = EM28XX_VMUX_COMPOSITE1,
1025
			.vmux     = TVP5150_COMPOSITE1,
1026
			.amux     = EM28XX_AMUX_LINE_IN,
1027
		}, {
1028
			.type     = EM28XX_VMUX_SVIDEO,
1029
			.vmux     = TVP5150_SVIDEO,
1030
			.amux     = EM28XX_AMUX_LINE_IN,
1031
		} },
1032
	},
1033 1034 1035
	[EM2882_BOARD_TERRATEC_HYBRID_XS] = {
		.name         = "Terratec Hybrid XS (em2882)",
		.valid        = EM28XX_BOARD_NOT_VALIDATED,
1036
		.vchannels    = 3,
1037 1038
		.tuner_type   = TUNER_XC2028,
		.decoder      = EM28XX_TVP5150,
1039
		.input          = { {
1040 1041
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = TVP5150_COMPOSITE0,
1042
			.amux     = EM28XX_AMUX_VIDEO,
1043
		}, {
1044
			.type     = EM28XX_VMUX_COMPOSITE1,
1045
			.vmux     = TVP5150_COMPOSITE1,
1046
			.amux     = EM28XX_AMUX_LINE_IN,
1047
		}, {
1048
			.type     = EM28XX_VMUX_SVIDEO,
1049
			.vmux     = TVP5150_SVIDEO,
1050
			.amux     = EM28XX_AMUX_LINE_IN,
1051
		} },
1052
	},
1053 1054 1055
	[EM2883_BOARD_KWORLD_HYBRID_A316] = {
		.name         = "Kworld PlusTV HD Hybrid 330",
		.valid        = EM28XX_BOARD_NOT_VALIDATED,
1056
		.vchannels    = 3,
1057 1058 1059
		.is_em2800    = 0,
		.tuner_type   = TUNER_XC2028,
		.decoder      = EM28XX_TVP5150,
1060
		.input          = { {
1061
			.type     = EM28XX_VMUX_TELEVISION,
1062
			.vmux     = TVP5150_COMPOSITE0,
1063
			.amux     = EM28XX_AMUX_VIDEO,
1064
		}, {
1065
			.type     = EM28XX_VMUX_COMPOSITE1,
1066
			.vmux     = TVP5150_COMPOSITE1,
1067
			.amux     = EM28XX_AMUX_LINE_IN,
1068
		}, {
1069
			.type     = EM28XX_VMUX_SVIDEO,
1070
			.vmux     = TVP5150_SVIDEO,
1071
			.amux     = EM28XX_AMUX_LINE_IN,
1072 1073
		} },
	},
1074
	[EM2820_BOARD_COMPRO_VIDEOMATE_FORYOU] = {
1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089
		.name         = "Compro VideoMate ForYou/Stereo",
		.vchannels    = 2,
		.tuner_type   = TUNER_LG_PAL_NEW_TAPC,
		.tda9887_conf = TDA9887_PRESENT,
		.decoder      = EM28XX_TVP5150,
		.input          = { {
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = TVP5150_COMPOSITE0,
			.amux     = EM28XX_AMUX_LINE_IN,
		}, {
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = TVP5150_SVIDEO,
			.amux     = EM28XX_AMUX_LINE_IN,
		} },
	},
1090 1091 1092 1093 1094
	[EM2874_BOARD_PINNACLE_PCTV_80E] = {
		.name         = "Pinnacle PCTV HD Mini",
		.vchannels    = 0,
		.tuner_type   = TUNER_ABSENT,
		.has_dvb        = 1,
1095
		.ir_codes       = ir_codes_pinnacle_pctv_hd,
1096 1097 1098 1099 1100 1101 1102 1103 1104
		.decoder      = EM28XX_NODECODER,
#ifdef DJH_DEBUG
		.input          = { {
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = TVP5150_COMPOSITE0,
			.amux     = EM28XX_AMUX_LINE_IN,
		} },
#endif
	},
1105
};
1106
const unsigned int em28xx_bcount = ARRAY_SIZE(em28xx_boards);
1107 1108

/* table of devices that work with this driver */
1109
struct usb_device_id em28xx_id_table [] = {
1110
	{ USB_DEVICE(0xeb1a, 0x2750),
1111 1112 1113
			.driver_info = EM2750_BOARD_UNKNOWN },
	{ USB_DEVICE(0xeb1a, 0x2751),
			.driver_info = EM2750_BOARD_UNKNOWN },
1114 1115 1116 1117 1118
	{ USB_DEVICE(0xeb1a, 0x2800),
			.driver_info = EM2800_BOARD_UNKNOWN },
	{ USB_DEVICE(0xeb1a, 0x2820),
			.driver_info = EM2820_BOARD_UNKNOWN },
	{ USB_DEVICE(0xeb1a, 0x2821),
1119
			.driver_info = EM2820_BOARD_PROLINK_PLAYTV_USB2 },
1120 1121 1122 1123 1124 1125 1126 1127 1128 1129
	{ 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 },
1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149
	{ 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 },
1150 1151
	{ USB_DEVICE(0x0ccd, 0x0036),
			.driver_info = EM2820_BOARD_TERRATEC_CINERGY_250 },
1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165
	{ 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 },
1166
	{ USB_DEVICE(0x185b, 0x2041),
1167
			.driver_info = EM2820_BOARD_COMPRO_VIDEOMATE_FORYOU },
1168 1169
	{ USB_DEVICE(0x2040, 0x4200),
			.driver_info = EM2820_BOARD_HAUPPAUGE_WINTV_USB_2 },
1170 1171
	{ USB_DEVICE(0x2040, 0x4201),
			.driver_info = EM2820_BOARD_HAUPPAUGE_WINTV_USB_2 },
1172 1173
	{ USB_DEVICE(0x2040, 0x6500),
			.driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900 },
1174
	{ USB_DEVICE(0x2040, 0x6502),
1175
			.driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900_R2 },
1176
	{ USB_DEVICE(0x2040, 0x6513), /* HCW HVR-980 */
1177
			.driver_info = EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950 },
1178
	{ USB_DEVICE(0x2040, 0x6517), /* HP  HVR-950 */
1179
			.driver_info = EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950 },
1180
	{ USB_DEVICE(0x2040, 0x651b), /* RP  HVR-950 */
1181
			.driver_info = EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950 },
1182
	{ USB_DEVICE(0x2040, 0x651f), /* HCW HVR-850 */
1183
			.driver_info = EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950 },
1184 1185
	{ USB_DEVICE(0x0438, 0xb002),
			.driver_info = EM2880_BOARD_AMD_ATI_TV_WONDER_HD_600 },
1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197
	{ 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 },
1198 1199
	{ USB_DEVICE(0x2304, 0x023f),
			.driver_info = EM2874_BOARD_PINNACLE_PCTV_80E },
1200 1201 1202 1203
	{ USB_DEVICE(0x0413, 0x6023),
			.driver_info = EM2800_BOARD_LEADTEK_WINFAST_USBII },
	{ USB_DEVICE(0x093b, 0xa005),
			.driver_info = EM2861_BOARD_PLEXTOR_PX_TV100U },
1204 1205
	{ },
};
1206
MODULE_DEVICE_TABLE(usb, em28xx_id_table);
1207

1208 1209 1210 1211
/*
 *  Reset sequences for analog/digital modes
 */

1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223
/* 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},
};

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

1231
/* Board Hauppauge WinTV HVR 900 digital */
1232
static struct em28xx_reg_seq hauppauge_wintv_hvr_900_digital[] = {
1233 1234 1235 1236 1237 1238
	{EM28XX_R08_GPIO,	0x2e,	~EM_GPIO_4,	10},
	{EM2880_R04_GPO,	0x04,	0x0f,		10},
	{EM2880_R04_GPO,	0x0c,	0x0f,		10},
	{ -1,			-1,	-1,		-1},
};

1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259
/* 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[] = {
1260 1261 1262 1263
	{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},
1264 1265
};

1266 1267 1268 1269 1270 1271 1272 1273 1274
/* 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},
};

1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285
/* 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},
};

1286 1287 1288
/*
 * EEPROM hash table for devices with generic USB IDs
 */
1289
static struct em28xx_hash_table em28xx_eeprom_hash [] = {
1290
	/* P/N: SA 60002070465 Tuner: TVF7533-MF */
1291
	{0x6ce05a8f, EM2820_BOARD_PROLINK_PLAYTV_USB2, TUNER_YMEC_TVF_5533MF},
1292
	{0x966a0441, EM2880_BOARD_KWORLD_DVB_310U, TUNER_XC2028},
1293
};
1294

1295
/* I2C devicelist hash table for devices with generic USB IDs */
1296
static struct em28xx_hash_table em28xx_i2c_hash[] = {
1297 1298
	{0xb06a32c3, EM2800_BOARD_TERRATEC_CINERGY_200, TUNER_LG_PAL_NEW_TAPC},
	{0xf51200e3, EM2800_BOARD_VGEAR_POCKETTV, TUNER_LG_PAL_NEW_TAPC},
1299
	{0x1ba50080, EM2860_BOARD_POINTNIX_INTRAORAL_CAMERA, TUNER_ABSENT},
1300 1301
};

1302
int em28xx_tuner_callback(void *ptr, int component, int command, int arg)
1303
{
1304
	int rc = 0;
1305 1306 1307 1308 1309 1310 1311 1312 1313
	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)
1314
		rc = em28xx_gpio_set(dev, dev->tun_analog_gpio);
1315
	else
1316
		rc = em28xx_gpio_set(dev, dev->tun_digital_gpio);
1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331

	return rc;
}
EXPORT_SYMBOL_GPL(em28xx_tuner_callback);

static void em28xx_set_model(struct em28xx *dev)
{
	dev->is_em2800 = em28xx_boards[dev->model].is_em2800;
	dev->has_msp34xx = em28xx_boards[dev->model].has_msp34xx;
	dev->tda9887_conf = em28xx_boards[dev->model].tda9887_conf;
	dev->decoder = em28xx_boards[dev->model].decoder;
	dev->video_inputs = em28xx_boards[dev->model].vchannels;
	dev->has_12mhz_i2s = em28xx_boards[dev->model].has_12mhz_i2s;
	dev->max_range_640_480 = em28xx_boards[dev->model].max_range_640_480;
	dev->has_dvb = em28xx_boards[dev->model].has_dvb;
1332
	dev->has_snapshot_button = em28xx_boards[dev->model].has_snapshot_button;
1333
	dev->ir_codes = em28xx_boards[dev->model].ir_codes;
1334
	dev->valid = em28xx_boards[dev->model].valid;
1335 1336
}

1337 1338 1339
/* Since em28xx_pre_card_setup() requires a proper dev->model,
 * this won't work for boards with generic PCI IDs
 */
1340 1341
void em28xx_pre_card_setup(struct em28xx *dev)
{
1342 1343
	int rc;

1344 1345 1346
	/* Set the default GPO/GPIO for legacy devices */
	dev->reg_gpo_num = EM2880_R04_GPO;
	dev->reg_gpio_num = EM28XX_R08_GPIO;
1347

1348
	dev->wait_after_write = 5;
1349 1350

	/* Based on the Chip ID, set the device configuration */
1351
	rc = em28xx_read_reg(dev, EM28XX_R0A_CHIPID);
1352
	if (rc > 0) {
1353
		dev->chip_id = rc;
1354
		switch (rc) {
1355 1356 1357
		case CHIP_ID_EM2750:
			em28xx_info("chip ID is em2750\n");
			break;
1358 1359 1360 1361 1362 1363
		case CHIP_ID_EM2820:
			em28xx_info("chip ID is em2820\n");
			break;
		case CHIP_ID_EM2840:
			em28xx_info("chip ID is em2840\n");
			break;
1364 1365 1366
		case CHIP_ID_EM2860:
			em28xx_info("chip ID is em2860\n");
			break;
1367 1368
		case CHIP_ID_EM2874:
			em28xx_info("chip ID is em2874\n");
1369
			dev->reg_gpio_num = EM2874_R80_GPIO;
1370 1371
			dev->wait_after_write = 0;
			break;
1372
		case CHIP_ID_EM2883:
1373 1374 1375 1376 1377 1378 1379
			em28xx_info("chip ID is em2882/em2883\n");
			dev->wait_after_write = 0;
			break;
		default:
			em28xx_info("em28xx chip ID = %d\n", rc);
		}
	}
1380 1381 1382 1383 1384 1385

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

1386 1387
	em28xx_set_model(dev);

1388
	/* request some modules */
1389
	switch (dev->model) {
1390 1391
	case EM2880_BOARD_TERRATEC_PRODIGY_XS:
	case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900:
1392
	case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900_R2:
1393
	case EM2860_BOARD_TERRATEC_HYBRID_XS:
1394
	case EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950:
1395
	case EM2880_BOARD_PINNACLE_PCTV_HD_PRO:
1396 1397
	case EM2882_BOARD_PINNACLE_HYBRID_PRO:
	case EM2883_BOARD_KWORLD_HYBRID_A316:
1398
	case EM2880_BOARD_AMD_ATI_TV_WONDER_HD_600:
1399 1400 1401
		em28xx_write_reg(dev, EM28XX_R0F_XCLK,
				 EM28XX_XCLK_IR_RC5_MODE |
				 EM28XX_XCLK_FREQUENCY_12MHZ);
1402 1403 1404
		em28xx_write_reg(dev, EM28XX_R06_I2C_CLK,
				 EM28XX_I2C_CLK_WAIT_ENABLE |
				 EM28XX_I2C_FREQ_100_KHZ);
1405 1406
		msleep(50);

1407 1408 1409
		/* Sets GPO/GPIO sequences for this device */
		dev->analog_gpio      = hauppauge_wintv_hvr_900_analog;
		dev->digital_gpio     = hauppauge_wintv_hvr_900_digital;
1410 1411 1412 1413 1414
		dev->tun_analog_gpio  = default_callback;
		dev->tun_digital_gpio = default_callback;
		break;

	case EM2882_BOARD_TERRATEC_HYBRID_XS:
1415 1416 1417
		em28xx_write_reg(dev, EM28XX_R0F_XCLK,
				 EM28XX_XCLK_IR_RC5_MODE |
				 EM28XX_XCLK_FREQUENCY_12MHZ);
1418 1419 1420
		em28xx_write_reg(dev, EM28XX_R06_I2C_CLK,
				 EM28XX_I2C_CLK_WAIT_ENABLE |
				 EM28XX_I2C_FREQ_100_KHZ);
1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438
		msleep(50);

		/* should be added ir_codes here */

		/* 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:
1439 1440 1441
		em28xx_write_reg(dev, EM28XX_R0F_XCLK,
				 EM28XX_XCLK_IR_RC5_MODE |
				 EM28XX_XCLK_FREQUENCY_12MHZ);
1442 1443 1444
		em28xx_write_reg(dev, EM28XX_R06_I2C_CLK,
				 EM28XX_I2C_CLK_WAIT_ENABLE |
				 EM28XX_I2C_FREQ_100_KHZ);
1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459
		msleep(50);

		/* 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:
1460 1461 1462
		em28xx_write_reg(dev, EM28XX_R0F_XCLK,
				 EM28XX_XCLK_IR_RC5_MODE |
				 EM28XX_XCLK_FREQUENCY_12MHZ);
1463 1464 1465
		em28xx_write_reg(dev, EM28XX_R06_I2C_CLK,
				 EM28XX_I2C_CLK_WAIT_ENABLE |
				 EM28XX_I2C_FREQ_100_KHZ);
1466 1467 1468 1469 1470 1471 1472 1473
		msleep(50);

		/* 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;
1474

1475 1476
	case EM2750_BOARD_UNKNOWN:
	case EM2750_BOARD_DLCW_130:
1477 1478
		em28xx_write_reg(dev, EM28XX_R0F_XCLK,
				 EM28XX_XCLK_FREQUENCY_48MHZ);
1479 1480 1481
		break;

	case EM2861_BOARD_PLEXTOR_PX_TV100U:
1482 1483 1484
		em28xx_write_reg(dev, EM28XX_R0F_XCLK,
				 EM28XX_XCLK_IR_RC5_MODE |
				 EM28XX_XCLK_FREQUENCY_12MHZ);
1485 1486 1487
		em28xx_write_reg(dev, EM28XX_R06_I2C_CLK,
				 EM28XX_I2C_CLK_WAIT_ENABLE |
				 EM28XX_I2C_FREQ_100_KHZ);
1488 1489 1490 1491 1492 1493 1494
		/* FIXME guess */
		/* Turn on analog audio output */
		em28xx_write_regs_req(dev, 0x00, 0x08, "\xfd", 1);
		break;

	case EM2861_BOARD_KWORLD_PVRTV_300U:
	case EM2880_BOARD_KWORLD_DVB_305U:
1495 1496 1497
		em28xx_write_reg(dev, EM28XX_R0F_XCLK,
				 EM28XX_XCLK_IR_RC5_MODE |
				 EM28XX_XCLK_FREQUENCY_12MHZ);
1498 1499 1500
		em28xx_write_reg(dev, EM28XX_R06_I2C_CLK,
				 EM28XX_I2C_CLK_WAIT_ENABLE |
				 EM28XX_I2C_FREQ_100_KHZ);
1501 1502 1503 1504 1505 1506 1507 1508
		msleep(10);
		em28xx_write_regs(dev, 0x08, "\x6d", 1);
		msleep(10);
		em28xx_write_regs(dev, 0x08, "\x7d", 1);
		msleep(10);
		break;

	case EM2870_BOARD_KWORLD_355U:
1509 1510 1511
		em28xx_write_reg(dev, EM28XX_R0F_XCLK,
				 EM28XX_XCLK_IR_RC5_MODE |
				 EM28XX_XCLK_FREQUENCY_12MHZ);
1512 1513 1514
		em28xx_write_reg(dev, EM28XX_R06_I2C_CLK,
				 EM28XX_I2C_CLK_WAIT_ENABLE |
				 EM28XX_I2C_FREQ_100_KHZ);
1515 1516 1517 1518 1519 1520 1521
		msleep(50);

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

	case EM2870_BOARD_COMPRO_VIDEOMATE:
1522 1523 1524
		em28xx_write_reg(dev, EM28XX_R0F_XCLK,
				 EM28XX_XCLK_IR_RC5_MODE |
				 EM28XX_XCLK_FREQUENCY_12MHZ);
1525 1526 1527
		em28xx_write_reg(dev, EM28XX_R06_I2C_CLK,
				 EM28XX_I2C_CLK_WAIT_ENABLE |
				 EM28XX_I2C_FREQ_100_KHZ);
1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544
		/* TODO: someone can do some cleanup here...
			 not everything's needed */
		em28xx_write_regs(dev, 0x04, "\x00", 1);
		msleep(10);
		em28xx_write_regs(dev, 0x04, "\x01", 1);
		msleep(10);
		em28xx_write_regs(dev, 0x08, "\xfd", 1);
		mdelay(70);
		em28xx_write_regs(dev, 0x08, "\xfc", 1);
		mdelay(70);
		em28xx_write_regs(dev, 0x08, "\xdc", 1);
		mdelay(70);
		em28xx_write_regs(dev, 0x08, "\xfc", 1);
		mdelay(70);
		break;

	case EM2870_BOARD_TERRATEC_XS_MT2060:
1545 1546 1547
		em28xx_write_reg(dev, EM28XX_R0F_XCLK,
				 EM28XX_XCLK_IR_RC5_MODE |
				 EM28XX_XCLK_FREQUENCY_12MHZ);
1548 1549 1550
		em28xx_write_reg(dev, EM28XX_R06_I2C_CLK,
				 EM28XX_I2C_CLK_WAIT_ENABLE |
				 EM28XX_I2C_FREQ_100_KHZ);
1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561
		/* this device needs some gpio writes to get the DVB-T
		   demod work */
		em28xx_write_regs(dev, 0x08, "\xfe", 1);
		mdelay(70);
		em28xx_write_regs(dev, 0x08, "\xde", 1);
		mdelay(70);
		dev->em28xx_write_regs(dev, 0x08, "\xfe", 1);
		mdelay(70);
		break;

	case EM2870_BOARD_PINNACLE_PCTV_DVB:
1562 1563 1564 1565
		em28xx_write_reg(dev, EM28XX_R06_I2C_CLK,
				 EM28XX_I2C_CLK_WAIT_ENABLE |
				 EM28XX_I2C_FREQ_100_KHZ);

1566 1567 1568 1569 1570 1571 1572 1573 1574
		/* this device needs some gpio writes to get the
		   DVB-T demod work */
		em28xx_write_regs(dev, 0x08, "\xfe", 1);
		mdelay(70);
		em28xx_write_regs(dev, 0x08, "\xde", 1);
		mdelay(70);
		em28xx_write_regs(dev, 0x08, "\xfe", 1);
		mdelay(70);
		/* switch em2880 rc protocol */
1575 1576 1577 1578
		/* djh - I have serious doubts this is right... */
		em28xx_write_reg(dev, EM28XX_R0F_XCLK,
				 EM28XX_XCLK_IR_RC5_MODE |
				 EM28XX_XCLK_FREQUENCY_10MHZ);
1579 1580 1581 1582
		/* should be added ir_codes here */
		break;

	case EM2820_BOARD_GADMEI_UTV310:
1583 1584 1585
		em28xx_write_reg(dev, EM28XX_R0F_XCLK,
				 EM28XX_XCLK_IR_RC5_MODE |
				 EM28XX_XCLK_FREQUENCY_12MHZ);
1586 1587 1588
		em28xx_write_reg(dev, EM28XX_R06_I2C_CLK,
				 EM28XX_I2C_CLK_WAIT_ENABLE |
				 EM28XX_I2C_FREQ_100_KHZ);
1589 1590 1591 1592 1593
		/* Turn on analog audio output */
		em28xx_write_regs_req(dev, 0x00, 0x08, "\xfd", 1);
		break;

	case EM2860_BOARD_GADMEI_UTV330:
1594 1595 1596
		em28xx_write_reg(dev, EM28XX_R0F_XCLK,
				 EM28XX_XCLK_IR_RC5_MODE |
				 EM28XX_XCLK_FREQUENCY_12MHZ);
1597 1598 1599
		em28xx_write_reg(dev, EM28XX_R06_I2C_CLK,
				 EM28XX_I2C_CLK_WAIT_ENABLE |
				 EM28XX_I2C_FREQ_100_KHZ);
1600 1601 1602 1603
		/* should be added ir_codes here */
		break;

	case EM2820_BOARD_MSI_VOX_USB_2:
1604 1605 1606
		em28xx_write_reg(dev, EM28XX_R0F_XCLK,
				 EM28XX_XCLK_IR_RC5_MODE |
				 EM28XX_XCLK_FREQUENCY_12MHZ);
1607 1608 1609
		em28xx_write_reg(dev, EM28XX_R06_I2C_CLK,
				 EM28XX_I2C_CLK_WAIT_ENABLE |
				 EM28XX_I2C_FREQ_100_KHZ);
1610 1611
		/* enables audio for that device */
		em28xx_write_regs_req(dev, 0x00, 0x08, "\xfd", 1);
1612
		break;
1613 1614

	case EM2874_BOARD_PINNACLE_PCTV_80E:
1615 1616 1617 1618 1619
		/* Set 400 KHz clock and select secondary i2c bus */
		em28xx_write_reg(dev, EM28XX_R06_I2C_CLK,
				 EM28XX_I2C_CLK_WAIT_ENABLE |
				 EM2874_I2C_SECONDARY_BUS_SELECT |
				 EM28XX_I2C_FREQ_400_KHZ);
1620 1621 1622

		dev->digital_gpio = em2874_pinnacle_80e_digital;
		break;
1623
	}
1624 1625 1626 1627 1628 1629

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

	/* Unlock device */
	em28xx_set_mode(dev, EM28XX_MODE_UNDEFINED);
1630 1631
}

1632
static void em28xx_setup_xc3028(struct em28xx *dev, struct xc2028_ctrl *ctl)
1633 1634 1635 1636 1637 1638 1639 1640
{
	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) {
1641 1642 1643
	case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900:
		ctl->demod = XC3028_FE_ZARLINK456;
		break;
1644 1645 1646
	case EM2880_BOARD_TERRATEC_HYBRID_XS:
		ctl->demod = XC3028_FE_ZARLINK456;
		break;
1647 1648 1649 1650
	case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900_R2:
		/* djh - Not sure which demod we need here */
		ctl->demod = XC3028_FE_DEFAULT;
		break;
1651 1652 1653 1654
	case EM2880_BOARD_AMD_ATI_TV_WONDER_HD_600:
		ctl->demod = XC3028_FE_DEFAULT;
		ctl->fname = XC3028L_DEFAULT_FIRMWARE;
		break;
1655
	case EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950:
1656
	case EM2880_BOARD_PINNACLE_PCTV_HD_PRO:
1657
		/* FIXME: Better to specify the needed IF */
1658 1659
		ctl->demod = XC3028_FE_DEFAULT;
		break;
1660 1661 1662 1663 1664
	default:
		ctl->demod = XC3028_FE_OREN538;
	}
}

1665
static void em28xx_config_tuner(struct em28xx *dev)
1666 1667
{
	struct v4l2_priv_tun_config  xc2028_cfg;
1668 1669 1670
	struct tuner_setup           tun_setup;
	struct v4l2_frequency        f;

1671
	if (dev->tuner_type == TUNER_ABSENT)
1672 1673 1674 1675 1676 1677 1678 1679 1680 1681
		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) {
1682
		struct xc2028_ctrl           ctl;
1683

1684
		em28xx_setup_xc3028(dev, &ctl);
1685 1686 1687

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

1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702
		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;
1703

1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715
	/* 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;
1716

1717 1718 1719 1720 1721 1722 1723 1724 1725 1726
			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);
1727

1728 1729 1730
			return 0;
		}
	}
1731

1732 1733 1734 1735 1736 1737 1738 1739 1740
	/* 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.
	 */

1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763
	/* 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;
		}
	}

1764 1765 1766 1767 1768 1769 1770
	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);
1771
	em28xx_errdev("Board i2c devicelist hash is 0x%08lx\n", dev->i2c_hash);
1772 1773 1774 1775 1776 1777 1778 1779

	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;
1780 1781
}

1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820
/* ----------------------------------------------------------------------- */
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;
1821 1822
	case (EM2800_BOARD_GRABBEEX_USB2800):
		break;
1823 1824 1825
	}
}

1826
void em28xx_card_setup(struct em28xx *dev)
1827
{
1828 1829 1830
	em28xx_set_model(dev);

	dev->tuner_type = em28xx_boards[dev->model].tuner_type;
1831 1832
	if (em28xx_boards[dev->model].tuner_addr)
		dev->tuner_addr = em28xx_boards[dev->model].tuner_addr;
1833

1834
	/* request some modules */
1835 1836
	switch (dev->model) {
	case EM2820_BOARD_HAUPPAUGE_WINTV_USB_2:
1837
	case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900:
1838
	case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900_R2:
1839
	case EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950:
1840 1841
	{
		struct tveeprom tv;
1842
#ifdef CONFIG_MODULES
1843
		request_module("tveeprom");
1844
#endif
1845 1846 1847 1848
		/* Call first TVeeprom */

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

1850
		dev->tuner_type = tv.tuner_type;
1851

1852
		if (tv.audio_processor == V4L2_IDENT_MSPX4XX) {
1853 1854 1855
			dev->i2s_speed = 2048000;
			dev->has_msp34xx = 1;
		}
1856 1857 1858 1859
#ifdef CONFIG_MODULES
		if (tv.has_ir)
			request_module("ir-kbd-i2c");
#endif
1860
		break;
1861
	}
1862 1863 1864 1865 1866 1867
	case EM2820_BOARD_KWORLD_PVRTV2800RF:
		/* GPIO enables sound on KWORLD PVR TV 2800RF */
		em28xx_write_regs_req(dev, 0x00, 0x08, "\xf9", 1);
		break;
	case EM2820_BOARD_UNKNOWN:
	case EM2800_BOARD_UNKNOWN:
1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881
		/*
		 * 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:
1882 1883
		if (!em28xx_hint_board(dev))
			em28xx_set_model(dev);
1884
		break;
1885 1886
	}

1887 1888 1889
	if (dev->has_snapshot_button)
		em28xx_register_snapshot_button(dev);

1890 1891 1892 1893 1894 1895 1896 1897 1898
	if (dev->valid == EM28XX_BOARD_NOT_VALIDATED) {
		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");
	}

1899
	/* Allow override tuner type by a module parameter */
1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910
	if (tuner >= 0)
		dev->tuner_type = tuner;

#ifdef CONFIG_MODULES
	/* request some modules */
	if (dev->has_msp34xx)
		request_module("msp3400");
	if (dev->decoder == EM28XX_SAA7113 || dev->decoder == EM28XX_SAA7114)
		request_module("saa7115");
	if (dev->decoder == EM28XX_TVP5150)
		request_module("tvp5150");
1911
	if (dev->tuner_type != TUNER_ABSENT)
1912 1913 1914
		request_module("tuner");
#endif

1915
	em28xx_config_tuner(dev);
1916 1917

	em28xx_ir_init(dev);
1918
}