atmel-mci: Initialize BLKR before sending data transfer command
[linux-2.6.git] / drivers / media / video / em28xx / em28xx-cards.c
1 /*
2    em28xx-cards.c - driver for Empia EM2800/EM2820/2840 USB
3                     video capture devices
4
5    Copyright (C) 2005 Ludovico Cavedon <cavedon@sssup.it>
6                       Markus Rechberger <mrechberger@gmail.com>
7                       Mauro Carvalho Chehab <mchehab@infradead.org>
8                       Sascha Sommer <saschasommer@freenet.de>
9
10    This program is free software; you can redistribute it and/or modify
11    it under the terms of the GNU General Public License as published by
12    the Free Software Foundation; either version 2 of the License, or
13    (at your option) any later version.
14
15    This program is distributed in the hope that it will be useful,
16    but WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18    GNU General Public License for more details.
19
20    You should have received a copy of the GNU General Public License
21    along with this program; if not, write to the Free Software
22    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23  */
24
25 #include <linux/init.h>
26 #include <linux/module.h>
27 #include <linux/delay.h>
28 #include <linux/i2c.h>
29 #include <linux/usb.h>
30 #include <media/tuner.h>
31 #include <media/msp3400.h>
32 #include <media/saa7115.h>
33 #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 static int tuner = -1;
41 module_param(tuner, int, 0444);
42 MODULE_PARM_DESC(tuner, "tuner type");
43
44 static unsigned int disable_ir;
45 module_param(disable_ir, int, 0444);
46 MODULE_PARM_DESC(disable_ir, "disable infrared remote support");
47
48 struct em28xx_hash_table {
49         unsigned long hash;
50         unsigned int  model;
51         unsigned int  tuner;
52 };
53
54 struct em28xx_board em28xx_boards[] = {
55         [EM2750_BOARD_UNKNOWN] = {
56                 .name          = "Unknown EM2750/EM2751 webcam grabber",
57                 .vchannels     = 1,
58                 .input         = { {
59                         .type     = EM28XX_VMUX_COMPOSITE1,
60                         .vmux     = 0,
61                         .amux     = 0,
62                 } },
63         },
64         [EM2800_BOARD_UNKNOWN] = {
65                 .name         = "Unknown EM2800 video grabber",
66                 .is_em2800    = 1,
67                 .vchannels    = 2,
68                 .tda9887_conf = TDA9887_PRESENT,
69                 .decoder      = EM28XX_SAA7113,
70                 .input           = { {
71                         .type     = EM28XX_VMUX_COMPOSITE1,
72                         .vmux     = SAA7115_COMPOSITE0,
73                         .amux     = 1,
74                 }, {
75                         .type     = EM28XX_VMUX_SVIDEO,
76                         .vmux     = SAA7115_SVIDEO3,
77                         .amux     = 1,
78                 } },
79         },
80         [EM2820_BOARD_UNKNOWN] = {
81                 .name         = "Unknown EM2750/28xx video grabber",
82                 .is_em2800    = 0,
83                 .tuner_type   = TUNER_ABSENT,
84         },
85         [EM2750_BOARD_DLCW_130] = {
86                 /* Beijing Huaqi Information Digital Technology Co., Ltd */
87                 .name          = "Huaqi DLCW-130",
88                 .valid         = EM28XX_BOARD_NOT_VALIDATED,
89                 .vchannels     = 1,
90                 .input         = { {
91                         .type     = EM28XX_VMUX_COMPOSITE1,
92                         .vmux     = 0,
93                         .amux     = 0,
94                 } },
95         },
96         [EM2800_BOARD_KWORLD_USB2800] = {
97                 .name         = "Kworld USB2800",
98                 .valid        = EM28XX_BOARD_NOT_VALIDATED,
99                 .is_em2800    = 1,
100                 .vchannels    = 3,
101                 .tuner_type   = TUNER_PHILIPS_FCV1236D,
102                 .tda9887_conf = TDA9887_PRESENT,
103                 .decoder      = EM28XX_SAA7113,
104                 .input          = { {
105                         .type     = EM28XX_VMUX_TELEVISION,
106                         .vmux     = SAA7115_COMPOSITE2,
107                         .amux     = 0,
108                 }, {
109                         .type     = EM28XX_VMUX_COMPOSITE1,
110                         .vmux     = SAA7115_COMPOSITE0,
111                         .amux     = 1,
112                 }, {
113                         .type     = EM28XX_VMUX_SVIDEO,
114                         .vmux     = SAA7115_SVIDEO3,
115                         .amux     = 1,
116                 } },
117         },
118         [EM2820_BOARD_KWORLD_PVRTV2800RF] = {
119                 .name         = "Kworld PVR TV 2800 RF",
120                 .is_em2800    = 0,
121                 .vchannels    = 2,
122                 .tuner_type   = TUNER_TEMIC_PAL,
123                 .tda9887_conf = TDA9887_PRESENT,
124                 .decoder      = EM28XX_SAA7113,
125                 .input           = { {
126                         .type     = EM28XX_VMUX_COMPOSITE1,
127                         .vmux     = SAA7115_COMPOSITE0,
128                         .amux     = 1,
129                 }, {
130                         .type     = EM28XX_VMUX_SVIDEO,
131                         .vmux     = SAA7115_SVIDEO3,
132                         .amux     = 1,
133                 } },
134         },
135         [EM2820_BOARD_TERRATEC_CINERGY_250] = {
136                 .name         = "Terratec Cinergy 250 USB",
137                 .vchannels    = 3,
138                 .tuner_type   = TUNER_LG_PAL_NEW_TAPC,
139                 .tda9887_conf = TDA9887_PRESENT,
140                 .decoder      = EM28XX_SAA7113,
141                 .input          = { {
142                         .type     = EM28XX_VMUX_TELEVISION,
143                         .vmux     = SAA7115_COMPOSITE2,
144                         .amux     = 1,
145                 }, {
146                         .type     = EM28XX_VMUX_COMPOSITE1,
147                         .vmux     = SAA7115_COMPOSITE0,
148                         .amux     = 1,
149                 }, {
150                         .type     = EM28XX_VMUX_SVIDEO,
151                         .vmux     = SAA7115_SVIDEO3,
152                         .amux     = 1,
153                 } },
154         },
155         [EM2820_BOARD_PINNACLE_USB_2] = {
156                 .name         = "Pinnacle PCTV USB 2",
157                 .vchannels    = 3,
158                 .tuner_type   = TUNER_LG_PAL_NEW_TAPC,
159                 .tda9887_conf = TDA9887_PRESENT,
160                 .decoder      = EM28XX_SAA7113,
161                 .input          = { {
162                         .type     = EM28XX_VMUX_TELEVISION,
163                         .vmux     = SAA7115_COMPOSITE2,
164                         .amux     = 0,
165                 }, {
166                         .type     = EM28XX_VMUX_COMPOSITE1,
167                         .vmux     = SAA7115_COMPOSITE0,
168                         .amux     = 1,
169                 }, {
170                         .type     = EM28XX_VMUX_SVIDEO,
171                         .vmux     = SAA7115_SVIDEO3,
172                         .amux     = 1,
173                 } },
174         },
175         [EM2820_BOARD_HAUPPAUGE_WINTV_USB_2] = {
176                 .name         = "Hauppauge WinTV USB 2",
177                 .vchannels    = 3,
178                 .tuner_type   = TUNER_PHILIPS_FM1236_MK3,
179                 .tda9887_conf = TDA9887_PRESENT |
180                                 TDA9887_PORT1_ACTIVE|
181                                 TDA9887_PORT2_ACTIVE,
182                 .decoder      = EM28XX_TVP5150,
183                 .has_msp34xx  = 1,
184                 /*FIXME: S-Video not tested */
185                 .input          = { {
186                         .type     = EM28XX_VMUX_TELEVISION,
187                         .vmux     = TVP5150_COMPOSITE0,
188                         .amux     = MSP_INPUT_DEFAULT,
189                 }, {
190                         .type     = EM28XX_VMUX_SVIDEO,
191                         .vmux     = TVP5150_SVIDEO,
192                         .amux     = MSP_INPUT(MSP_IN_SCART1, MSP_IN_TUNER1,
193                                         MSP_DSP_IN_SCART, MSP_DSP_IN_SCART),
194                 } },
195         },
196         [EM2820_BOARD_DLINK_USB_TV] = {
197                 .name         = "D-Link DUB-T210 TV Tuner",
198                 .valid        = EM28XX_BOARD_NOT_VALIDATED,
199                 .vchannels    = 3,
200                 .is_em2800    = 0,
201                 .tuner_type   = TUNER_LG_PAL_NEW_TAPC,
202                 .tda9887_conf = TDA9887_PRESENT,
203                 .decoder      = EM28XX_SAA7113,
204                 .input          = { {
205                         .type     = EM28XX_VMUX_TELEVISION,
206                         .vmux     = SAA7115_COMPOSITE2,
207                         .amux     = 1,
208                 }, {
209                         .type     = EM28XX_VMUX_COMPOSITE1,
210                         .vmux     = SAA7115_COMPOSITE0,
211                         .amux     = 1,
212                 }, {
213                         .type     = EM28XX_VMUX_SVIDEO,
214                         .vmux     = SAA7115_SVIDEO3,
215                         .amux     = 1,
216                 } },
217         },
218         [EM2820_BOARD_HERCULES_SMART_TV_USB2] = {
219                 .name         = "Hercules Smart TV USB 2.0",
220                 .valid        = EM28XX_BOARD_NOT_VALIDATED,
221                 .vchannels    = 3,
222                 .tuner_type   = TUNER_LG_PAL_NEW_TAPC,
223                 .tda9887_conf = TDA9887_PRESENT,
224                 .decoder      = EM28XX_SAA7113,
225                 .input        = { {
226                         .type     = EM28XX_VMUX_TELEVISION,
227                         .vmux     = SAA7115_COMPOSITE2,
228                         .amux     = 1,
229                 }, {
230                         .type     = EM28XX_VMUX_COMPOSITE1,
231                         .vmux     = SAA7115_COMPOSITE0,
232                         .amux     = 1,
233                 }, {
234                         .type     = EM28XX_VMUX_SVIDEO,
235                         .vmux     = SAA7115_SVIDEO3,
236                         .amux     = 1,
237                 } },
238         },
239         [EM2820_BOARD_PINNACLE_USB_2_FM1216ME] = {
240                 .name         = "Pinnacle PCTV USB 2 (Philips FM1216ME)",
241                 .valid        = EM28XX_BOARD_NOT_VALIDATED,
242                 .vchannels    = 3,
243                 .is_em2800    = 0,
244                 .tuner_type   = TUNER_PHILIPS_FM1216ME_MK3,
245                 .tda9887_conf = TDA9887_PRESENT,
246                 .decoder      = EM28XX_SAA7113,
247                 .input          = { {
248                         .type     = EM28XX_VMUX_TELEVISION,
249                         .vmux     = SAA7115_COMPOSITE2,
250                         .amux     = 0,
251                 }, {
252                         .type     = EM28XX_VMUX_COMPOSITE1,
253                         .vmux     = SAA7115_COMPOSITE0,
254                         .amux     = 1,
255                 }, {
256                         .type     = EM28XX_VMUX_SVIDEO,
257                         .vmux     = SAA7115_SVIDEO3,
258                         .amux     = 1,
259                 } },
260         },
261         [EM2820_BOARD_GADMEI_UTV310] = {
262                 .name         = "Gadmei UTV310",
263                 .valid        = EM28XX_BOARD_NOT_VALIDATED,
264                 .vchannels    = 3,
265                 .tuner_type   = TUNER_TNF_5335MF,
266                 .tda9887_conf = TDA9887_PRESENT,
267                 .decoder      = EM28XX_SAA7113,
268                 .input          = { {
269                         .type     = EM28XX_VMUX_TELEVISION,
270                         .vmux     = SAA7115_COMPOSITE1,
271                         .amux     = 1,
272                 }, {
273                         .type     = EM28XX_VMUX_COMPOSITE1,
274                         .vmux     = SAA7115_COMPOSITE0,
275                         .amux     = 1,
276                 }, {
277                         .type     = EM28XX_VMUX_SVIDEO,
278                         .vmux     = SAA7115_SVIDEO3,
279                         .amux     = 1,
280                 } },
281         },
282         [EM2820_BOARD_LEADTEK_WINFAST_USBII_DELUXE] = {
283                 .name         = "Leadtek Winfast USB II Deluxe",
284                 .valid        = EM28XX_BOARD_NOT_VALIDATED,
285                 .vchannels    = 3,
286                 .tuner_type   = TUNER_PHILIPS_FM1216ME_MK3,
287                 .tda9887_conf = TDA9887_PRESENT,
288                 .decoder      = EM28XX_SAA7114,
289                 .input          = { {
290                         .type     = EM28XX_VMUX_TELEVISION,
291                         .vmux     = 2,
292                         .amux     = 0,
293                 }, {
294                         .type     = EM28XX_VMUX_COMPOSITE1,
295                         .vmux     = 0,
296                         .amux     = 1,
297                 }, {
298                         .type     = EM28XX_VMUX_SVIDEO,
299                         .vmux     = 9,
300                         .amux     = 1,
301                 } },
302         },
303         [EM2820_BOARD_PINNACLE_DVC_100] = {
304                 .name         = "Pinnacle Dazzle DVC 100",
305                 .valid        = EM28XX_BOARD_NOT_VALIDATED,
306                 .vchannels    = 3,
307                 .decoder      = EM28XX_SAA7113,
308                 .input          = { {
309                         .type     = EM28XX_VMUX_COMPOSITE1,
310                         .vmux     = SAA7115_COMPOSITE0,
311                         .amux     = 1,
312                 }, {
313                         .type     = EM28XX_VMUX_SVIDEO,
314                         .vmux     = SAA7115_SVIDEO3,
315                         .amux     = 1,
316                 } },
317         },
318         [EM2820_BOARD_VIDEOLOGY_20K14XUSB] = {
319                 .name          = "Videology 20K14XUSB USB2.0",
320                 .valid        = EM28XX_BOARD_NOT_VALIDATED,
321                 .vchannels     = 1,
322                 .input         = { {
323                         .type     = EM28XX_VMUX_COMPOSITE1,
324                         .vmux     = 0,
325                         .amux     = 0,
326                 } },
327         },
328         [EM2821_BOARD_PROLINK_PLAYTV_USB2] = {
329                 .name         = "SIIG AVTuner-PVR/Prolink PlayTV USB 2.0",
330                 .valid        = EM28XX_BOARD_NOT_VALIDATED,
331                 .vchannels    = 3,
332                 .is_em2800    = 0,
333                 .tuner_type   = TUNER_LG_PAL_NEW_TAPC,  /* unknown? */
334                 .tda9887_conf = TDA9887_PRESENT,        /* unknown? */
335                 .decoder      = EM28XX_SAA7113,
336                 .input          = { {
337                         .type     = EM28XX_VMUX_TELEVISION,
338                         .vmux     = SAA7115_COMPOSITE2,
339                         .amux     = 1,
340                 }, {
341                         .type     = EM28XX_VMUX_COMPOSITE1,
342                         .vmux     = SAA7115_COMPOSITE0,
343                         .amux     = 1,
344                 }, {
345                         .type     = EM28XX_VMUX_SVIDEO,
346                         .vmux     = SAA7115_SVIDEO3,
347                         .amux     = 1,
348                 } },
349         },
350         [EM2821_BOARD_SUPERCOMP_USB_2] = {
351                 .name         = "Supercomp USB 2.0 TV",
352                 .valid        = EM28XX_BOARD_NOT_VALIDATED,
353                 .vchannels    = 3,
354                 .is_em2800    = 0,
355                 .tuner_type   = TUNER_PHILIPS_FM1236_MK3,
356                 .tda9887_conf = TDA9887_PRESENT |
357                                 TDA9887_PORT1_ACTIVE |
358                                 TDA9887_PORT2_ACTIVE,
359                 .decoder      = EM28XX_SAA7113,
360                 .input          = { {
361                         .type     = EM28XX_VMUX_TELEVISION,
362                         .vmux     = SAA7115_COMPOSITE2,
363                         .amux     = 1,
364                 }, {
365                         .type     = EM28XX_VMUX_COMPOSITE1,
366                         .vmux     = SAA7115_COMPOSITE0,
367                         .amux     = 0,
368                 }, {
369                         .type     = EM28XX_VMUX_SVIDEO,
370                         .vmux     = SAA7115_SVIDEO3,
371                         .amux     = 1,
372                 } },
373         },
374         [EM2821_BOARD_USBGEAR_VD204] = {
375                 .name          = "Usbgear VD204v9",
376                 .valid        = EM28XX_BOARD_NOT_VALIDATED,
377                 .vchannels     = 2,
378                 .decoder       = EM28XX_SAA7113,
379                 .input          = { {
380                         .type  = EM28XX_VMUX_COMPOSITE1,
381                         .vmux  = SAA7115_COMPOSITE0,
382                         .amux  = 1,
383                 }, {
384                         .type  = EM28XX_VMUX_SVIDEO,
385                         .vmux  = SAA7115_SVIDEO3,
386                         .amux  = 1,
387                 } },
388         },
389         [EM2860_BOARD_NETGMBH_CAM] = {
390                 /* Beijing Huaqi Information Digital Technology Co., Ltd */
391                 .name          = "NetGMBH Cam",
392                 .valid       = EM28XX_BOARD_NOT_VALIDATED,
393                 .vchannels     = 1,
394                 .input         = { {
395                         .type     = EM28XX_VMUX_COMPOSITE1,
396                         .vmux     = 0,
397                         .amux     = 0,
398                 } },
399         },
400         [EM2860_BOARD_TYPHOON_DVD_MAKER] = {
401                 .name          = "Typhoon DVD Maker",
402                 .valid        = EM28XX_BOARD_NOT_VALIDATED,
403                 .vchannels     = 2,
404                 .decoder       = EM28XX_SAA7113,
405                 .input          = { {
406                         .type  = EM28XX_VMUX_COMPOSITE1,
407                         .vmux  = SAA7115_COMPOSITE0,
408                         .amux  = 1,
409                 }, {
410                         .type  = EM28XX_VMUX_SVIDEO,
411                         .vmux  = SAA7115_SVIDEO3,
412                         .amux  = 1,
413                 } },
414         },
415         [EM2860_BOARD_GADMEI_UTV330] = {
416                 .name         = "Gadmei UTV330",
417                 .valid        = EM28XX_BOARD_NOT_VALIDATED,
418                 .vchannels    = 3,
419                 .tuner_type   = TUNER_TNF_5335MF,
420                 .tda9887_conf = TDA9887_PRESENT,
421                 .decoder      = EM28XX_SAA7113,
422                 .input          = { {
423                         .type     = EM28XX_VMUX_TELEVISION,
424                         .vmux     = SAA7115_COMPOSITE2,
425                         .amux     = 0,
426                 }, {
427                         .type     = EM28XX_VMUX_COMPOSITE1,
428                         .vmux     = SAA7115_COMPOSITE0,
429                         .amux     = 1,
430                 }, {
431                         .type     = EM28XX_VMUX_SVIDEO,
432                         .vmux     = SAA7115_SVIDEO3,
433                         .amux     = 1,
434                 } },
435         },
436         [EM2860_BOARD_TERRATEC_HYBRID_XS] = {
437                 .name         = "Terratec Cinergy A Hybrid XS",
438                 .valid        = EM28XX_BOARD_NOT_VALIDATED,
439                 .vchannels    = 3,
440                 .tuner_type   = TUNER_XC2028,
441                 .decoder      = EM28XX_TVP5150,
442                 .input          = { {
443                         .type     = EM28XX_VMUX_TELEVISION,
444                         .vmux     = TVP5150_COMPOSITE0,
445                         .amux     = 0,
446                 }, {
447                         .type     = EM28XX_VMUX_COMPOSITE1,
448                         .vmux     = TVP5150_COMPOSITE1,
449                         .amux     = 1,
450                 }, {
451                         .type     = EM28XX_VMUX_SVIDEO,
452                         .vmux     = TVP5150_SVIDEO,
453                         .amux     = 1,
454                 } },
455         },
456         [EM2861_BOARD_KWORLD_PVRTV_300U] = {
457                 .name         = "KWorld PVRTV 300U",
458                 .valid        = EM28XX_BOARD_NOT_VALIDATED,
459                 .vchannels    = 3,
460                 .tuner_type   = TUNER_XC2028,
461                 .decoder      = EM28XX_TVP5150,
462                 .input          = { {
463                         .type     = EM28XX_VMUX_TELEVISION,
464                         .vmux     = TVP5150_COMPOSITE0,
465                         .amux     = 0,
466                 }, {
467                         .type     = EM28XX_VMUX_COMPOSITE1,
468                         .vmux     = TVP5150_COMPOSITE1,
469                         .amux     = 1,
470                 }, {
471                         .type     = EM28XX_VMUX_SVIDEO,
472                         .vmux     = TVP5150_SVIDEO,
473                         .amux     = 1,
474                 } },
475         },
476         [EM2861_BOARD_YAKUMO_MOVIE_MIXER] = {
477                 .name          = "Yakumo MovieMixer",
478                 .valid       = EM28XX_BOARD_NOT_VALIDATED,
479                 .vchannels     = 1,
480                 .decoder       = EM28XX_TVP5150,
481                 .input         = { {
482                         .type     = EM28XX_VMUX_TELEVISION,
483                         .vmux     = TVP5150_COMPOSITE0,
484                         .amux     = 0,
485                 }, {
486                         .type     = EM28XX_VMUX_COMPOSITE1,
487                         .vmux     = TVP5150_COMPOSITE1,
488                         .amux     = 1,
489                 }, {
490                         .type     = EM28XX_VMUX_SVIDEO,
491                         .vmux     = TVP5150_SVIDEO,
492                         .amux     = 1,
493                 } },
494         },
495         [EM2861_BOARD_PLEXTOR_PX_TV100U] = {
496                 .name         = "Plextor ConvertX PX-TV100U",
497                 .valid        = EM28XX_BOARD_NOT_VALIDATED,
498                 .vchannels    = 3,
499                 .tuner_type   = TUNER_TNF_5335MF,
500                 .tda9887_conf = TDA9887_PRESENT,
501                 .decoder      = EM28XX_TVP5150,
502                 .input          = { {
503                         .type     = EM28XX_VMUX_TELEVISION,
504                         .vmux     = TVP5150_COMPOSITE0,
505                         .amux     = 1,
506                 }, {
507                         .type     = EM28XX_VMUX_COMPOSITE1,
508                         .vmux     = TVP5150_COMPOSITE1,
509                         .amux     = 1,
510                 }, {
511                         .type     = EM28XX_VMUX_SVIDEO,
512                         .vmux     = TVP5150_SVIDEO,
513                         .amux     = 1,
514                 } },
515         },
516         [EM2870_BOARD_TERRATEC_XS] = {
517                 .name         = "Terratec Cinergy T XS",
518                 .valid        = EM28XX_BOARD_NOT_VALIDATED,
519                 .tuner_type   = TUNER_XC2028,
520         },
521         [EM2870_BOARD_TERRATEC_XS_MT2060] = {
522                 .name         = "Terratec Cinergy T XS (MT2060)",
523                 .valid        = EM28XX_BOARD_NOT_VALIDATED,
524                 .tuner_type   = TUNER_ABSENT, /* MT2060 */
525         },
526         [EM2870_BOARD_KWORLD_350U] = {
527                 .name         = "Kworld 350 U DVB-T",
528                 .valid        = EM28XX_BOARD_NOT_VALIDATED,
529                 .tuner_type   = TUNER_XC2028,
530         },
531         [EM2870_BOARD_KWORLD_355U] = {
532                 .name         = "Kworld 355 U DVB-T",
533                 .valid        = EM28XX_BOARD_NOT_VALIDATED,
534         },
535         [EM2870_BOARD_PINNACLE_PCTV_DVB] = {
536                 .name         = "Pinnacle PCTV DVB-T",
537                 .valid        = EM28XX_BOARD_NOT_VALIDATED,
538                 .tuner_type   = TUNER_ABSENT, /* MT2060 */
539         },
540         [EM2870_BOARD_COMPRO_VIDEOMATE] = {
541                 .name         = "Compro, VideoMate U3",
542                 .valid        = EM28XX_BOARD_NOT_VALIDATED,
543                 .tuner_type   = TUNER_ABSENT, /* MT2060 */
544         },
545         [EM2880_BOARD_TERRATEC_HYBRID_XS_FR] = {
546                 .name         = "Terratec Hybrid XS Secam",
547                 .valid        = EM28XX_BOARD_NOT_VALIDATED,
548                 .vchannels    = 3,
549                 .has_msp34xx  = 1,
550                 .tuner_type   = TUNER_XC2028,
551                 .decoder      = EM28XX_TVP5150,
552                 .input          = { {
553                         .type     = EM28XX_VMUX_TELEVISION,
554                         .vmux     = TVP5150_COMPOSITE0,
555                         .amux     = 0,
556                 }, {
557                         .type     = EM28XX_VMUX_COMPOSITE1,
558                         .vmux     = TVP5150_COMPOSITE1,
559                         .amux     = 1,
560                 }, {
561                         .type     = EM28XX_VMUX_SVIDEO,
562                         .vmux     = TVP5150_SVIDEO,
563                         .amux     = 1,
564                 } },
565         },
566         [EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900] = {
567                 .name         = "Hauppauge WinTV HVR 900",
568                 .vchannels    = 3,
569                 .tda9887_conf = TDA9887_PRESENT,
570                 .tuner_type   = TUNER_XC2028,
571                 .mts_firmware = 1,
572                 .has_dvb        = 1,
573                 .decoder      = EM28XX_TVP5150,
574                 .input          = { {
575                         .type     = EM28XX_VMUX_TELEVISION,
576                         .vmux     = TVP5150_COMPOSITE0,
577                         .amux     = 0,
578                 }, {
579                         .type     = EM28XX_VMUX_COMPOSITE1,
580                         .vmux     = TVP5150_COMPOSITE1,
581                         .amux     = 1,
582                 }, {
583                         .type     = EM28XX_VMUX_SVIDEO,
584                         .vmux     = TVP5150_SVIDEO,
585                         .amux     = 1,
586                 } },
587         },
588         [EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900_R2] = {
589                 .name         = "Hauppauge WinTV HVR 900 (R2)",
590                 .vchannels    = 3,
591                 .tda9887_conf = TDA9887_PRESENT,
592                 .tuner_type   = TUNER_XC2028,
593                 .mts_firmware = 1,
594                 .decoder      = EM28XX_TVP5150,
595                 .input          = { {
596                         .type     = EM28XX_VMUX_TELEVISION,
597                         .vmux     = TVP5150_COMPOSITE0,
598                         .amux     = 0,
599                 }, {
600                         .type     = EM28XX_VMUX_COMPOSITE1,
601                         .vmux     = TVP5150_COMPOSITE1,
602                         .amux     = 1,
603                 }, {
604                         .type     = EM28XX_VMUX_SVIDEO,
605                         .vmux     = TVP5150_SVIDEO,
606                         .amux     = 1,
607                 } },
608         },
609         [EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950] = {
610                 .name           = "Hauppauge WinTV HVR 950",
611                 .vchannels      = 3,
612                 .tda9887_conf   = TDA9887_PRESENT,
613                 .tuner_type     = TUNER_XC2028,
614                 .mts_firmware   = 1,
615                 .has_12mhz_i2s  = 1,
616                 .has_dvb        = 1,
617                 .decoder        = EM28XX_TVP5150,
618                 .input          = { {
619                         .type     = EM28XX_VMUX_TELEVISION,
620                         .vmux     = TVP5150_COMPOSITE0,
621                         .amux     = 0,
622                 }, {
623                         .type     = EM28XX_VMUX_COMPOSITE1,
624                         .vmux     = TVP5150_COMPOSITE1,
625                         .amux     = 1,
626                 }, {
627                         .type     = EM28XX_VMUX_SVIDEO,
628                         .vmux     = TVP5150_SVIDEO,
629                         .amux     = 1,
630                 } },
631         },
632         [EM2880_BOARD_PINNACLE_PCTV_HD_PRO] = {
633                 .name           = "Pinnacle PCTV HD Pro Stick",
634                 .vchannels      = 3,
635                 .tda9887_conf   = TDA9887_PRESENT,
636                 .tuner_type     = TUNER_XC2028,
637                 .mts_firmware   = 1,
638                 .has_12mhz_i2s  = 1,
639                 .has_dvb        = 1,
640                 .decoder        = EM28XX_TVP5150,
641                 .input          = { {
642                         .type     = EM28XX_VMUX_TELEVISION,
643                         .vmux     = TVP5150_COMPOSITE0,
644                         .amux     = 0,
645                 }, {
646                         .type     = EM28XX_VMUX_COMPOSITE1,
647                         .vmux     = TVP5150_COMPOSITE1,
648                         .amux     = 1,
649                 }, {
650                         .type     = EM28XX_VMUX_SVIDEO,
651                         .vmux     = TVP5150_SVIDEO,
652                         .amux     = 1,
653                 } },
654         },
655         [EM2880_BOARD_AMD_ATI_TV_WONDER_HD_600] = {
656                 .name           = "AMD ATI TV Wonder HD 600",
657                 .vchannels      = 3,
658                 .tda9887_conf   = TDA9887_PRESENT,
659                 .tuner_type     = TUNER_XC2028,
660                 .mts_firmware   = 1,
661                 .has_12mhz_i2s  = 1,
662                 .has_dvb        = 1,
663                 .decoder        = EM28XX_TVP5150,
664                 .input          = { {
665                         .type     = EM28XX_VMUX_TELEVISION,
666                         .vmux     = TVP5150_COMPOSITE0,
667                         .amux     = 0,
668                 }, {
669                         .type     = EM28XX_VMUX_COMPOSITE1,
670                         .vmux     = TVP5150_COMPOSITE1,
671                         .amux     = 1,
672                 }, {
673                         .type     = EM28XX_VMUX_SVIDEO,
674                         .vmux     = TVP5150_SVIDEO,
675                         .amux     = 1,
676                 } },
677         },
678         [EM2880_BOARD_TERRATEC_HYBRID_XS] = {
679                 .name         = "Terratec Hybrid XS",
680                 .vchannels    = 3,
681                 .tda9887_conf = TDA9887_PRESENT,
682                 .tuner_type   = TUNER_XC2028,
683                 .decoder      = EM28XX_TVP5150,
684                 .has_dvb        = 1,
685                 .input          = { {
686                         .type     = EM28XX_VMUX_TELEVISION,
687                         .vmux     = TVP5150_COMPOSITE0,
688                         .amux     = 0,
689                 }, {
690                         .type     = EM28XX_VMUX_COMPOSITE1,
691                         .vmux     = TVP5150_COMPOSITE1,
692                         .amux     = 1,
693                 }, {
694                         .type     = EM28XX_VMUX_SVIDEO,
695                         .vmux     = TVP5150_SVIDEO,
696                         .amux     = 1,
697                 } },
698         },
699         /* maybe there's a reason behind it why Terratec sells the Hybrid XS
700            as Prodigy XS with a different PID, let's keep it separated for now
701            maybe we'll need it lateron */
702         [EM2880_BOARD_TERRATEC_PRODIGY_XS] = {
703                 .name         = "Terratec Prodigy XS",
704                 .vchannels    = 3,
705                 .tda9887_conf = TDA9887_PRESENT,
706                 .tuner_type   = TUNER_XC2028,
707                 .decoder      = EM28XX_TVP5150,
708                 .input          = { {
709                         .type     = EM28XX_VMUX_TELEVISION,
710                         .vmux     = TVP5150_COMPOSITE0,
711                         .amux     = 0,
712                 }, {
713                         .type     = EM28XX_VMUX_COMPOSITE1,
714                         .vmux     = TVP5150_COMPOSITE1,
715                         .amux     = 1,
716                 }, {
717                         .type     = EM28XX_VMUX_SVIDEO,
718                         .vmux     = TVP5150_SVIDEO,
719                         .amux     = 1,
720                 } },
721         },
722         [EM2820_BOARD_MSI_VOX_USB_2] = {
723                 .name              = "MSI VOX USB 2.0",
724                 .vchannels         = 3,
725                 .tuner_type        = TUNER_LG_PAL_NEW_TAPC,
726                 .tda9887_conf      = TDA9887_PRESENT      |
727                                      TDA9887_PORT1_ACTIVE |
728                                      TDA9887_PORT2_ACTIVE,
729                 .max_range_640_480 = 1,
730
731                 .decoder           = EM28XX_SAA7114,
732                 .input             = { {
733                         .type      = EM28XX_VMUX_TELEVISION,
734                         .vmux      = SAA7115_COMPOSITE4,
735                         .amux      = 0,
736                 }, {
737                         .type      = EM28XX_VMUX_COMPOSITE1,
738                         .vmux      = SAA7115_COMPOSITE0,
739                         .amux      = 1,
740                 }, {
741                         .type      = EM28XX_VMUX_SVIDEO,
742                         .vmux      = SAA7115_SVIDEO3,
743                         .amux      = 1,
744                 } },
745         },
746         [EM2800_BOARD_TERRATEC_CINERGY_200] = {
747                 .name         = "Terratec Cinergy 200 USB",
748                 .is_em2800    = 1,
749                 .vchannels    = 3,
750                 .tuner_type   = TUNER_LG_PAL_NEW_TAPC,
751                 .tda9887_conf = TDA9887_PRESENT,
752                 .decoder      = EM28XX_SAA7113,
753                 .input          = { {
754                         .type     = EM28XX_VMUX_TELEVISION,
755                         .vmux     = SAA7115_COMPOSITE2,
756                         .amux     = 0,
757                 }, {
758                         .type     = EM28XX_VMUX_COMPOSITE1,
759                         .vmux     = SAA7115_COMPOSITE0,
760                         .amux     = 1,
761                 }, {
762                         .type     = EM28XX_VMUX_SVIDEO,
763                         .vmux     = SAA7115_SVIDEO3,
764                         .amux     = 1,
765                 } },
766         },
767         [EM2800_BOARD_GRABBEEX_USB2800] = {
768                 .name         = "eMPIA Technology, Inc. GrabBeeX+ Video Encoder",
769                 .is_em2800    = 1,
770                 .vchannels    = 2,
771                 .decoder      = EM28XX_SAA7113,
772                 .input          = { {
773                         .type     = EM28XX_VMUX_COMPOSITE1,
774                         .vmux     = SAA7115_COMPOSITE0,
775                         .amux     = 1,
776                 }, {
777                         .type     = EM28XX_VMUX_SVIDEO,
778                         .vmux     = SAA7115_SVIDEO3,
779                         .amux     = 1,
780                 } },
781         },
782         [EM2800_BOARD_LEADTEK_WINFAST_USBII] = {
783                 .name         = "Leadtek Winfast USB II",
784                 .is_em2800    = 1,
785                 .vchannels    = 3,
786                 .tuner_type   = TUNER_LG_PAL_NEW_TAPC,
787                 .tda9887_conf = TDA9887_PRESENT,
788                 .decoder      = EM28XX_SAA7113,
789                 .input          = { {
790                         .type     = EM28XX_VMUX_TELEVISION,
791                         .vmux     = SAA7115_COMPOSITE2,
792                         .amux     = 0,
793                 }, {
794                         .type     = EM28XX_VMUX_COMPOSITE1,
795                         .vmux     = SAA7115_COMPOSITE0,
796                         .amux     = 1,
797                 }, {
798                         .type     = EM28XX_VMUX_SVIDEO,
799                         .vmux     = SAA7115_SVIDEO3,
800                         .amux     = 1,
801                 } },
802         },
803         [EM2800_BOARD_KWORLD_USB2800] = {
804                 .name         = "Kworld USB2800",
805                 .is_em2800    = 1,
806                 .vchannels    = 3,
807                 .tuner_type   = TUNER_PHILIPS_FCV1236D,
808                 .tda9887_conf = TDA9887_PRESENT,
809                 .decoder      = EM28XX_SAA7113,
810                 .input          = { {
811                         .type     = EM28XX_VMUX_TELEVISION,
812                         .vmux     = SAA7115_COMPOSITE2,
813                         .amux     = 0,
814                 }, {
815                         .type     = EM28XX_VMUX_COMPOSITE1,
816                         .vmux     = SAA7115_COMPOSITE0,
817                         .amux     = 1,
818                 }, {
819                         .type     = EM28XX_VMUX_SVIDEO,
820                         .vmux     = SAA7115_SVIDEO3,
821                         .amux     = 1,
822                 } },
823         },
824         [EM2820_BOARD_PINNACLE_DVC_90] = {
825                 .name         = "Pinnacle Dazzle DVC 90/DVC 100",
826                 .vchannels    = 3,
827                 .tuner_type   = TUNER_ABSENT,
828                 .decoder      = EM28XX_SAA7113,
829                 .input          = { {
830                         .type     = EM28XX_VMUX_COMPOSITE1,
831                         .vmux     = SAA7115_COMPOSITE0,
832                         .amux     = 1,
833                 }, {
834                         .type     = EM28XX_VMUX_SVIDEO,
835                         .vmux     = SAA7115_SVIDEO3,
836                         .amux     = 1,
837                 } },
838         },
839         [EM2800_BOARD_VGEAR_POCKETTV] = {
840                 .name         = "V-Gear PocketTV",
841                 .is_em2800    = 1,
842                 .vchannels    = 3,
843                 .tuner_type   = TUNER_LG_PAL_NEW_TAPC,
844                 .tda9887_conf = TDA9887_PRESENT,
845                 .decoder      = EM28XX_SAA7113,
846                 .input          = { {
847                         .type     = EM28XX_VMUX_TELEVISION,
848                         .vmux     = SAA7115_COMPOSITE2,
849                         .amux     = 0,
850                 }, {
851                         .type     = EM28XX_VMUX_COMPOSITE1,
852                         .vmux     = SAA7115_COMPOSITE0,
853                         .amux     = 1,
854                 }, {
855                         .type     = EM28XX_VMUX_SVIDEO,
856                         .vmux     = SAA7115_SVIDEO3,
857                         .amux     = 1,
858                 } },
859         },
860         [EM2820_BOARD_PROLINK_PLAYTV_USB2] = {
861                 .name         = "Pixelview Prolink PlayTV USB 2.0",
862                 .vchannels    = 3,
863                 .tda9887_conf = TDA9887_PRESENT,
864                 .tuner_type   = TUNER_YMEC_TVF_5533MF,
865                 .decoder      = EM28XX_SAA7113,
866                 .input          = { {
867                         .type     = EM28XX_VMUX_TELEVISION,
868                         .vmux     = SAA7115_COMPOSITE2,
869                         .amux     = EM28XX_AMUX_LINE_IN,
870                 }, {
871                         .type     = EM28XX_VMUX_COMPOSITE1,
872                         .vmux     = SAA7115_COMPOSITE0,
873                         .amux     = EM28XX_AMUX_LINE_IN,
874                 }, {
875                         .type     = EM28XX_VMUX_SVIDEO,
876                         .vmux     = SAA7115_SVIDEO3,
877                         .amux     = EM28XX_AMUX_LINE_IN,
878                 } },
879         },
880         [EM2860_BOARD_POINTNIX_INTRAORAL_CAMERA] = {
881                 .name         = "PointNix Intra-Oral Camera",
882                 .has_snapshot_button = 1,
883                 .vchannels    = 1,
884                 .tda9887_conf = TDA9887_PRESENT,
885                 .tuner_type   = TUNER_ABSENT,
886                 .decoder      = EM28XX_SAA7113,
887                 .input          = { {
888                         .type     = EM28XX_VMUX_SVIDEO,
889                         .vmux     = SAA7115_SVIDEO3,
890                         .amux     = 0,
891                 } },
892         },
893         [EM2880_BOARD_MSI_DIGIVOX_AD] = {
894                 .name         = "MSI DigiVox A/D",
895                 .valid        = EM28XX_BOARD_NOT_VALIDATED,
896                 .vchannels    = 3,
897                 .tuner_type   = TUNER_XC2028,
898                 .decoder      = EM28XX_TVP5150,
899                 .input          = { {
900                         .type     = EM28XX_VMUX_TELEVISION,
901                         .vmux     = TVP5150_COMPOSITE0,
902                         .amux     = 0,
903                 }, {
904                         .type     = EM28XX_VMUX_COMPOSITE1,
905                         .vmux     = TVP5150_COMPOSITE1,
906                         .amux     = 1,
907                 }, {
908                         .type     = EM28XX_VMUX_SVIDEO,
909                         .vmux     = TVP5150_SVIDEO,
910                         .amux     = 1,
911                 } },
912         },
913         [EM2880_BOARD_MSI_DIGIVOX_AD_II] = {
914                 .name         = "MSI DigiVox A/D II",
915                 .valid        = EM28XX_BOARD_NOT_VALIDATED,
916                 .vchannels    = 3,
917                 .tuner_type   = TUNER_XC2028,
918                 .decoder      = EM28XX_TVP5150,
919                 .input          = { {
920                         .type     = EM28XX_VMUX_TELEVISION,
921                         .vmux     = TVP5150_COMPOSITE0,
922                         .amux     = 0,
923                 }, {
924                         .type     = EM28XX_VMUX_COMPOSITE1,
925                         .vmux     = TVP5150_COMPOSITE1,
926                         .amux     = 1,
927                 }, {
928                         .type     = EM28XX_VMUX_SVIDEO,
929                         .vmux     = TVP5150_SVIDEO,
930                         .amux     = 1,
931                 } },
932         },
933         [EM2880_BOARD_KWORLD_DVB_305U] = {
934                 .name         = "KWorld DVB-T 305U",
935                 .valid        = EM28XX_BOARD_NOT_VALIDATED,
936                 .vchannels    = 3,
937                 .tuner_type   = TUNER_XC2028,
938                 .decoder      = EM28XX_TVP5150,
939                 .input          = { {
940                         .type     = EM28XX_VMUX_TELEVISION,
941                         .vmux     = TVP5150_COMPOSITE0,
942                         .amux     = 0,
943                 }, {
944                         .type     = EM28XX_VMUX_COMPOSITE1,
945                         .vmux     = TVP5150_COMPOSITE1,
946                         .amux     = 1,
947                 }, {
948                         .type     = EM28XX_VMUX_SVIDEO,
949                         .vmux     = TVP5150_SVIDEO,
950                         .amux     = 1,
951                 } },
952         },
953         [EM2880_BOARD_KWORLD_DVB_310U] = {
954                 .name         = "KWorld DVB-T 310U",
955                 .valid        = EM28XX_BOARD_NOT_VALIDATED,
956                 .vchannels    = 3,
957                 .tuner_type   = TUNER_XC2028,
958                 .decoder      = EM28XX_TVP5150,
959                 .input          = { {
960                         .type     = EM28XX_VMUX_TELEVISION,
961                         .vmux     = TVP5150_COMPOSITE0,
962                         .amux     = 0,
963                 }, {
964                         .type     = EM28XX_VMUX_COMPOSITE1,
965                         .vmux     = TVP5150_COMPOSITE1,
966                         .amux     = 1,
967                 }, {
968                         .type     = EM28XX_VMUX_SVIDEO,
969                         .vmux     = TVP5150_SVIDEO,
970                         .amux     = 1,
971                 } },
972         },
973         [EM2881_BOARD_DNT_DA2_HYBRID] = {
974                 .name         = "DNT DA2 Hybrid",
975                 .valid        = EM28XX_BOARD_NOT_VALIDATED,
976                 .vchannels    = 3,
977                 .tuner_type   = TUNER_XC2028,
978                 .decoder      = EM28XX_TVP5150,
979                 .input          = { {
980                         .type     = EM28XX_VMUX_TELEVISION,
981                         .vmux     = TVP5150_COMPOSITE0,
982                         .amux     = 0,
983                 }, {
984                         .type     = EM28XX_VMUX_COMPOSITE1,
985                         .vmux     = TVP5150_COMPOSITE1,
986                         .amux     = 1,
987                 }, {
988                         .type     = EM28XX_VMUX_SVIDEO,
989                         .vmux     = TVP5150_SVIDEO,
990                         .amux     = 1,
991                 } },
992         },
993         [EM2881_BOARD_PINNACLE_HYBRID_PRO] = {
994                 .name         = "Pinnacle Hybrid Pro",
995                 .valid        = EM28XX_BOARD_NOT_VALIDATED,
996                 .vchannels    = 3,
997                 .tuner_type   = TUNER_XC2028,
998                 .decoder      = EM28XX_TVP5150,
999                 .input          = { {
1000                         .type     = EM28XX_VMUX_TELEVISION,
1001                         .vmux     = TVP5150_COMPOSITE0,
1002                         .amux     = 0,
1003                 }, {
1004                         .type     = EM28XX_VMUX_COMPOSITE1,
1005                         .vmux     = TVP5150_COMPOSITE1,
1006                         .amux     = 1,
1007                 }, {
1008                         .type     = EM28XX_VMUX_SVIDEO,
1009                         .vmux     = TVP5150_SVIDEO,
1010                         .amux     = 1,
1011                 } },
1012         },
1013         [EM2882_BOARD_PINNACLE_HYBRID_PRO] = {
1014                 .name         = "Pinnacle Hybrid Pro (2)",
1015                 .valid        = EM28XX_BOARD_NOT_VALIDATED,
1016                 .vchannels    = 3,
1017                 .tuner_type   = TUNER_XC2028,
1018                 .mts_firmware = 1,
1019                 .decoder      = EM28XX_TVP5150,
1020                 .input          = { {
1021                         .type     = EM28XX_VMUX_TELEVISION,
1022                         .vmux     = TVP5150_COMPOSITE0,
1023                         .amux     = 0,
1024                 }, {
1025                         .type     = EM28XX_VMUX_COMPOSITE1,
1026                         .vmux     = TVP5150_COMPOSITE1,
1027                         .amux     = 1,
1028                 }, {
1029                         .type     = EM28XX_VMUX_SVIDEO,
1030                         .vmux     = TVP5150_SVIDEO,
1031                         .amux     = 1,
1032                 } },
1033         },
1034         [EM2882_BOARD_KWORLD_VS_DVBT] = {
1035                 .name         = "Kworld VS-DVB-T 323UR",
1036                 .valid        = EM28XX_BOARD_NOT_VALIDATED,
1037                 .vchannels    = 3,
1038                 .tuner_type   = TUNER_XC2028,
1039                 .decoder      = EM28XX_TVP5150,
1040                 .input          = { {
1041                         .type     = EM28XX_VMUX_TELEVISION,
1042                         .vmux     = TVP5150_COMPOSITE0,
1043                         .amux     = 0,
1044                 }, {
1045                         .type     = EM28XX_VMUX_COMPOSITE1,
1046                         .vmux     = TVP5150_COMPOSITE1,
1047                         .amux     = 1,
1048                 }, {
1049                         .type     = EM28XX_VMUX_SVIDEO,
1050                         .vmux     = TVP5150_SVIDEO,
1051                         .amux     = 1,
1052                 } },
1053         },
1054         [EM2882_BOARD_TERRATEC_HYBRID_XS] = {
1055                 .name         = "Terratec Hybrid XS (em2882)",
1056                 .valid        = EM28XX_BOARD_NOT_VALIDATED,
1057                 .vchannels    = 3,
1058                 .tuner_type   = TUNER_XC2028,
1059                 .decoder      = EM28XX_TVP5150,
1060                 .input          = { {
1061                         .type     = EM28XX_VMUX_TELEVISION,
1062                         .vmux     = TVP5150_COMPOSITE0,
1063                         .amux     = 0,
1064                 }, {
1065                         .type     = EM28XX_VMUX_COMPOSITE1,
1066                         .vmux     = TVP5150_COMPOSITE1,
1067                         .amux     = 1,
1068                 }, {
1069                         .type     = EM28XX_VMUX_SVIDEO,
1070                         .vmux     = TVP5150_SVIDEO,
1071                         .amux     = 1,
1072                 } },
1073         },
1074         [EM2883_BOARD_KWORLD_HYBRID_A316] = {
1075                 .name         = "Kworld PlusTV HD Hybrid 330",
1076                 .valid        = EM28XX_BOARD_NOT_VALIDATED,
1077                 .vchannels    = 3,
1078                 .is_em2800    = 0,
1079                 .tuner_type   = TUNER_XC2028,
1080                 .decoder      = EM28XX_TVP5150,
1081                 .input          = { {
1082                         .type     = EM28XX_VMUX_TELEVISION,
1083                         .vmux     = TVP5150_COMPOSITE0,
1084                         .amux     = 0,
1085                 }, {
1086                         .type     = EM28XX_VMUX_COMPOSITE1,
1087                         .vmux     = TVP5150_COMPOSITE1,
1088                         .amux     = 1,
1089                 }, {
1090                         .type     = EM28XX_VMUX_SVIDEO,
1091                         .vmux     = TVP5150_SVIDEO,
1092                         .amux     = 1,
1093                 } },
1094         },
1095         [EM2820_BOARD_COMPRO_VIDEOMATE_FORYOU] = {
1096                 .name         = "Compro VideoMate ForYou/Stereo",
1097                 .vchannels    = 2,
1098                 .tuner_type   = TUNER_LG_PAL_NEW_TAPC,
1099                 .tda9887_conf = TDA9887_PRESENT,
1100                 .decoder      = EM28XX_TVP5150,
1101                 .input          = { {
1102                         .type     = EM28XX_VMUX_TELEVISION,
1103                         .vmux     = TVP5150_COMPOSITE0,
1104                         .amux     = EM28XX_AMUX_LINE_IN,
1105                 }, {
1106                         .type     = EM28XX_VMUX_SVIDEO,
1107                         .vmux     = TVP5150_SVIDEO,
1108                         .amux     = EM28XX_AMUX_LINE_IN,
1109                 } },
1110         },
1111 };
1112 const unsigned int em28xx_bcount = ARRAY_SIZE(em28xx_boards);
1113
1114 /* table of devices that work with this driver */
1115 struct usb_device_id em28xx_id_table [] = {
1116         { USB_DEVICE(0xeb1a, 0x2750),
1117                         .driver_info = EM2750_BOARD_UNKNOWN },
1118         { USB_DEVICE(0xeb1a, 0x2751),
1119                         .driver_info = EM2750_BOARD_UNKNOWN },
1120         { USB_DEVICE(0xeb1a, 0x2800),
1121                         .driver_info = EM2800_BOARD_UNKNOWN },
1122         { USB_DEVICE(0xeb1a, 0x2820),
1123                         .driver_info = EM2820_BOARD_UNKNOWN },
1124         { USB_DEVICE(0xeb1a, 0x2821),
1125                         .driver_info = EM2820_BOARD_UNKNOWN },
1126         { USB_DEVICE(0xeb1a, 0x2860),
1127                         .driver_info = EM2820_BOARD_UNKNOWN },
1128         { USB_DEVICE(0xeb1a, 0x2861),
1129                         .driver_info = EM2820_BOARD_UNKNOWN },
1130         { USB_DEVICE(0xeb1a, 0x2870),
1131                         .driver_info = EM2820_BOARD_UNKNOWN },
1132         { USB_DEVICE(0xeb1a, 0x2881),
1133                         .driver_info = EM2820_BOARD_UNKNOWN },
1134         { USB_DEVICE(0xeb1a, 0x2883),
1135                         .driver_info = EM2820_BOARD_UNKNOWN },
1136         { USB_DEVICE(0xeb1a, 0xe300),
1137                         .driver_info = EM2861_BOARD_KWORLD_PVRTV_300U },
1138         { USB_DEVICE(0xeb1a, 0xe305),
1139                         .driver_info = EM2880_BOARD_KWORLD_DVB_305U },
1140         { USB_DEVICE(0xeb1a, 0xe310),
1141                         .driver_info = EM2880_BOARD_MSI_DIGIVOX_AD },
1142         { USB_DEVICE(0xeb1a, 0xa316),
1143                         .driver_info = EM2883_BOARD_KWORLD_HYBRID_A316 },
1144         { USB_DEVICE(0xeb1a, 0xe320),
1145                         .driver_info = EM2880_BOARD_MSI_DIGIVOX_AD_II },
1146         { USB_DEVICE(0xeb1a, 0xe323),
1147                         .driver_info = EM2882_BOARD_KWORLD_VS_DVBT },
1148         { USB_DEVICE(0xeb1a, 0xe350),
1149                         .driver_info = EM2870_BOARD_KWORLD_350U },
1150         { USB_DEVICE(0xeb1a, 0xe355),
1151                         .driver_info = EM2870_BOARD_KWORLD_355U },
1152         { USB_DEVICE(0xeb1a, 0x2801),
1153                         .driver_info = EM2800_BOARD_GRABBEEX_USB2800 },
1154         { USB_DEVICE(0xeb1a, 0xe357),
1155                         .driver_info = EM2870_BOARD_KWORLD_355U },
1156         { USB_DEVICE(0x0ccd, 0x0036),
1157                         .driver_info = EM2820_BOARD_TERRATEC_CINERGY_250 },
1158         { USB_DEVICE(0x0ccd, 0x004c),
1159                         .driver_info = EM2880_BOARD_TERRATEC_HYBRID_XS_FR },
1160         { USB_DEVICE(0x0ccd, 0x004f),
1161                         .driver_info = EM2860_BOARD_TERRATEC_HYBRID_XS },
1162         { USB_DEVICE(0x0ccd, 0x005e),
1163                         .driver_info = EM2882_BOARD_TERRATEC_HYBRID_XS },
1164         { USB_DEVICE(0x0ccd, 0x0042),
1165                         .driver_info = EM2880_BOARD_TERRATEC_HYBRID_XS },
1166         { USB_DEVICE(0x0ccd, 0x0043),
1167                         .driver_info = EM2870_BOARD_TERRATEC_XS },
1168         { USB_DEVICE(0x0ccd, 0x0047),
1169                         .driver_info = EM2880_BOARD_TERRATEC_PRODIGY_XS },
1170         { USB_DEVICE(0x185b, 0x2870),
1171                         .driver_info = EM2870_BOARD_COMPRO_VIDEOMATE },
1172         { USB_DEVICE(0x185b, 0x2041),
1173                         .driver_info = EM2820_BOARD_COMPRO_VIDEOMATE_FORYOU },
1174         { USB_DEVICE(0x2040, 0x4200),
1175                         .driver_info = EM2820_BOARD_HAUPPAUGE_WINTV_USB_2 },
1176         { USB_DEVICE(0x2040, 0x4201),
1177                         .driver_info = EM2820_BOARD_HAUPPAUGE_WINTV_USB_2 },
1178         { USB_DEVICE(0x2040, 0x6500),
1179                         .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900 },
1180         { USB_DEVICE(0x2040, 0x6502),
1181                         .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900_R2 },
1182         { USB_DEVICE(0x2040, 0x6513), /* HCW HVR-980 */
1183                         .driver_info = EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950 },
1184         { USB_DEVICE(0x2040, 0x6517), /* HP  HVR-950 */
1185                         .driver_info = EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950 },
1186         { USB_DEVICE(0x2040, 0x651b), /* RP  HVR-950 */
1187                         .driver_info = EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950 },
1188         { USB_DEVICE(0x2040, 0x651f), /* HCW HVR-850 */
1189                         .driver_info = EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950 },
1190         { USB_DEVICE(0x0438, 0xb002),
1191                         .driver_info = EM2880_BOARD_AMD_ATI_TV_WONDER_HD_600 },
1192         { USB_DEVICE(0x2001, 0xf112),
1193                         .driver_info = EM2820_BOARD_DLINK_USB_TV },
1194         { USB_DEVICE(0x2304, 0x0207),
1195                         .driver_info = EM2820_BOARD_PINNACLE_DVC_90 },
1196         { USB_DEVICE(0x2304, 0x0208),
1197                         .driver_info = EM2820_BOARD_PINNACLE_USB_2 },
1198         { USB_DEVICE(0x2304, 0x021a),
1199                         .driver_info = EM2820_BOARD_PINNACLE_DVC_90 },
1200         { USB_DEVICE(0x2304, 0x0226),
1201                         .driver_info = EM2882_BOARD_PINNACLE_HYBRID_PRO },
1202         { USB_DEVICE(0x2304, 0x0227),
1203                         .driver_info = EM2880_BOARD_PINNACLE_PCTV_HD_PRO },
1204         { USB_DEVICE(0x0413, 0x6023),
1205                         .driver_info = EM2800_BOARD_LEADTEK_WINFAST_USBII },
1206         { USB_DEVICE(0x093b, 0xa005),
1207                         .driver_info = EM2861_BOARD_PLEXTOR_PX_TV100U },
1208         { },
1209 };
1210 MODULE_DEVICE_TABLE(usb, em28xx_id_table);
1211
1212 /*
1213  *  Reset sequences for analog/digital modes
1214  */
1215
1216 /* Reset for the most [analog] boards */
1217 static struct em28xx_reg_seq default_analog[] = {
1218         {EM28XX_R08_GPIO,       0x6d,   ~EM_GPIO_4,     10},
1219         {       -1,             -1,     -1,             -1},
1220 };
1221
1222 /* Reset for the most [digital] boards */
1223 static struct em28xx_reg_seq default_digital[] = {
1224         {EM28XX_R08_GPIO,       0x6e,   ~EM_GPIO_4,     10},
1225         {       -1,             -1,     -1,             -1},
1226 };
1227
1228 /* Board Hauppauge WinTV HVR 900 analog */
1229 static struct em28xx_reg_seq hauppauge_wintv_hvr_900_analog[] = {
1230         {EM28XX_R08_GPIO,       0x2d,   ~EM_GPIO_4,     10},
1231         {0x05,                  0xff,   0x10,           10},
1232         {  -1,                  -1,     -1,             -1},
1233 };
1234
1235 /* Board Hauppauge WinTV HVR 900 digital */
1236 static struct em28xx_reg_seq hauppauge_wintv_hvr_900_digital[] = {
1237         {EM28XX_R08_GPIO,       0x2e,   ~EM_GPIO_4,     10},
1238         {EM2880_R04_GPO,        0x04,   0x0f,           10},
1239         {EM2880_R04_GPO,        0x0c,   0x0f,           10},
1240         { -1,                   -1,     -1,             -1},
1241 };
1242
1243 /* Boards - EM2880 MSI DIGIVOX AD and EM2880_BOARD_MSI_DIGIVOX_AD_II */
1244 static struct em28xx_reg_seq em2880_msi_digivox_ad_analog[] = {
1245         {EM28XX_R08_GPIO,       0x69,   ~EM_GPIO_4,      10},
1246         {       -1,             -1,     -1,              -1},
1247 };
1248
1249 /* Boards - EM2880 MSI DIGIVOX AD and EM2880_BOARD_MSI_DIGIVOX_AD_II */
1250 static struct em28xx_reg_seq em2880_msi_digivox_ad_digital[] = {
1251         {EM28XX_R08_GPIO,       0x6a,   ~EM_GPIO_4,     10},
1252         {       -1,             -1,     -1,             -1},
1253 };
1254
1255 /* Board  - EM2870 Kworld 355u
1256    Analog - No input analog */
1257 static struct em28xx_reg_seq em2870_kworld_355u_digital[] = {
1258         {EM2880_R04_GPO,        0x01,   0xff,           10},
1259         {  -1,                  -1,     -1,             -1},
1260 };
1261
1262 /* Callback for the most boards */
1263 static struct em28xx_reg_seq default_callback[] = {
1264         {EM28XX_R08_GPIO,       EM_GPIO_4,      EM_GPIO_4,      10},
1265         {EM28XX_R08_GPIO,       0,              EM_GPIO_4,      10},
1266         {EM28XX_R08_GPIO,       EM_GPIO_4,      EM_GPIO_4,      10},
1267         {  -1,                  -1,             -1,             -1},
1268 };
1269
1270 /* Callback for EM2882 TERRATEC HYBRID XS */
1271 static struct em28xx_reg_seq em2882_terratec_hybrid_xs_digital[] = {
1272         {EM28XX_R08_GPIO,       0x2e,   0xff,              6},
1273         {EM28XX_R08_GPIO,       0x3e,   ~EM_GPIO_4,        6},
1274         {EM2880_R04_GPO,        0x04,   0xff,             10},
1275         {EM2880_R04_GPO,        0x0c,   0xff,             10},
1276         {  -1,                  -1,     -1,               -1},
1277 };
1278
1279 /*
1280  * EEPROM hash table for devices with generic USB IDs
1281  */
1282 static struct em28xx_hash_table em28xx_eeprom_hash [] = {
1283         /* P/N: SA 60002070465 Tuner: TVF7533-MF */
1284         {0x6ce05a8f, EM2820_BOARD_PROLINK_PLAYTV_USB2, TUNER_YMEC_TVF_5533MF},
1285 };
1286
1287 /* I2C devicelist hash table for devices with generic USB IDs */
1288 static struct em28xx_hash_table em28xx_i2c_hash[] = {
1289         {0xb06a32c3, EM2800_BOARD_TERRATEC_CINERGY_200, TUNER_LG_PAL_NEW_TAPC},
1290         {0xf51200e3, EM2800_BOARD_VGEAR_POCKETTV, TUNER_LG_PAL_NEW_TAPC},
1291         {0x1ba50080, EM2860_BOARD_POINTNIX_INTRAORAL_CAMERA, TUNER_ABSENT},
1292 };
1293
1294 int em28xx_tuner_callback(void *ptr, int command, int arg)
1295 {
1296         int rc = 0;
1297         struct em28xx *dev = ptr;
1298
1299         if (dev->tuner_type != TUNER_XC2028)
1300                 return 0;
1301
1302         if (command != XC2028_TUNER_RESET)
1303                 return 0;
1304
1305         if (dev->mode == EM28XX_ANALOG_MODE)
1306                 rc = em28xx_gpio_set(dev, dev->tun_analog_gpio);
1307         else
1308                 rc = em28xx_gpio_set(dev, dev->tun_digital_gpio);
1309
1310         return rc;
1311 }
1312 EXPORT_SYMBOL_GPL(em28xx_tuner_callback);
1313
1314 static void em28xx_set_model(struct em28xx *dev)
1315 {
1316         dev->is_em2800 = em28xx_boards[dev->model].is_em2800;
1317         dev->has_msp34xx = em28xx_boards[dev->model].has_msp34xx;
1318         dev->tda9887_conf = em28xx_boards[dev->model].tda9887_conf;
1319         dev->decoder = em28xx_boards[dev->model].decoder;
1320         dev->video_inputs = em28xx_boards[dev->model].vchannels;
1321         dev->has_12mhz_i2s = em28xx_boards[dev->model].has_12mhz_i2s;
1322         dev->max_range_640_480 = em28xx_boards[dev->model].max_range_640_480;
1323         dev->has_dvb = em28xx_boards[dev->model].has_dvb;
1324         dev->has_snapshot_button = em28xx_boards[dev->model].has_snapshot_button;
1325         dev->valid = em28xx_boards[dev->model].valid;
1326 }
1327
1328 /* Since em28xx_pre_card_setup() requires a proper dev->model,
1329  * this won't work for boards with generic PCI IDs
1330  */
1331 void em28xx_pre_card_setup(struct em28xx *dev)
1332 {
1333         int rc;
1334
1335         rc = em28xx_read_reg(dev, EM2880_R04_GPO);
1336         if (rc >= 0)
1337                 dev->reg_gpo = rc;
1338
1339         dev->wait_after_write = 5;
1340         rc = em28xx_read_reg(dev, EM28XX_R0A_CHIPID);
1341         if (rc > 0) {
1342                 switch (rc) {
1343                 case CHIP_ID_EM2860:
1344                         em28xx_info("chip ID is em2860\n");
1345                         break;
1346                 case CHIP_ID_EM2883:
1347                         em28xx_info("chip ID is em2882/em2883\n");
1348                         dev->wait_after_write = 0;
1349                         break;
1350                 default:
1351                         em28xx_info("em28xx chip ID = %d\n", rc);
1352                 }
1353         }
1354         em28xx_set_model(dev);
1355
1356         /* request some modules */
1357         switch (dev->model) {
1358         case EM2880_BOARD_TERRATEC_PRODIGY_XS:
1359         case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900:
1360         case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900_R2:
1361         case EM2860_BOARD_TERRATEC_HYBRID_XS:
1362         case EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950:
1363         case EM2880_BOARD_PINNACLE_PCTV_HD_PRO:
1364         case EM2882_BOARD_PINNACLE_HYBRID_PRO:
1365         case EM2883_BOARD_KWORLD_HYBRID_A316:
1366         case EM2880_BOARD_AMD_ATI_TV_WONDER_HD_600:
1367                 em28xx_write_regs(dev, EM28XX_R0F_XCLK,    "\x27", 1);
1368                 em28xx_write_regs(dev, EM28XX_R06_I2C_CLK, "\x40", 1);
1369                 msleep(50);
1370
1371                 /* Sets GPO/GPIO sequences for this device */
1372                 dev->analog_gpio      = hauppauge_wintv_hvr_900_analog;
1373                 dev->digital_gpio     = hauppauge_wintv_hvr_900_digital;
1374                 dev->tun_analog_gpio  = default_callback;
1375                 dev->tun_digital_gpio = default_callback;
1376                 break;
1377
1378         case EM2882_BOARD_TERRATEC_HYBRID_XS:
1379                 em28xx_write_regs(dev, EM28XX_R0F_XCLK,    "\x27", 1);
1380                 em28xx_write_regs(dev, EM28XX_R06_I2C_CLK, "\x40", 1);
1381                 msleep(50);
1382
1383                 /* should be added ir_codes here */
1384
1385                 /* Sets GPO/GPIO sequences for this device */
1386                 dev->analog_gpio      = hauppauge_wintv_hvr_900_analog;
1387                 dev->digital_gpio     = hauppauge_wintv_hvr_900_digital;
1388                 dev->tun_analog_gpio  = default_callback;
1389                 dev->tun_digital_gpio = em2882_terratec_hybrid_xs_digital;
1390                 break;
1391
1392         case EM2880_BOARD_TERRATEC_HYBRID_XS_FR:
1393         case EM2880_BOARD_TERRATEC_HYBRID_XS:
1394         case EM2870_BOARD_TERRATEC_XS:
1395         case EM2881_BOARD_PINNACLE_HYBRID_PRO:
1396         case EM2880_BOARD_KWORLD_DVB_310U:
1397         case EM2870_BOARD_KWORLD_350U:
1398         case EM2881_BOARD_DNT_DA2_HYBRID:
1399                 em28xx_write_regs(dev, EM28XX_R0F_XCLK,    "\x27", 1);
1400                 em28xx_write_regs(dev, EM28XX_R06_I2C_CLK, "\x40", 1);
1401                 msleep(50);
1402
1403                 /* NOTE: EM2881_DNT_DA2_HYBRID spend 140 msleep for digital
1404                          and analog commands. If this commands doesn't work,
1405                          add this timer. */
1406
1407                 /* Sets GPO/GPIO sequences for this device */
1408                 dev->analog_gpio      = default_analog;
1409                 dev->digital_gpio     = default_digital;
1410                 dev->tun_analog_gpio  = default_callback;
1411                 dev->tun_digital_gpio = default_callback;
1412                 break;
1413
1414         case EM2880_BOARD_MSI_DIGIVOX_AD:
1415         case EM2880_BOARD_MSI_DIGIVOX_AD_II:
1416                 em28xx_write_regs(dev, EM28XX_R0F_XCLK,    "\x27", 1);
1417                 em28xx_write_regs(dev, EM28XX_R06_I2C_CLK, "\x40", 1);
1418                 msleep(50);
1419
1420                 /* Sets GPO/GPIO sequences for this device */
1421                 dev->analog_gpio      = em2880_msi_digivox_ad_analog;
1422                 dev->digital_gpio     = em2880_msi_digivox_ad_digital;
1423                 dev->tun_analog_gpio  = default_callback;
1424                 dev->tun_digital_gpio = default_callback;
1425                 break;
1426
1427         case EM2750_BOARD_UNKNOWN:
1428         case EM2750_BOARD_DLCW_130:
1429                 em28xx_write_regs(dev, EM28XX_R0F_XCLK, "\x0a", 1);
1430                 break;
1431
1432         case EM2861_BOARD_PLEXTOR_PX_TV100U:
1433                 em28xx_write_regs(dev, EM28XX_R0F_XCLK, "\x27", 1);
1434                 em28xx_write_regs(dev, EM28XX_R06_I2C_CLK, "\x40", 1);
1435                 /* FIXME guess */
1436                 /* Turn on analog audio output */
1437                 em28xx_write_regs_req(dev, 0x00, 0x08, "\xfd", 1);
1438                 break;
1439
1440         case EM2861_BOARD_KWORLD_PVRTV_300U:
1441         case EM2880_BOARD_KWORLD_DVB_305U:
1442                 em28xx_write_regs(dev, EM28XX_R0F_XCLK, "\x27", 1);
1443                 em28xx_write_regs(dev, EM28XX_R06_I2C_CLK, "\x4c", 1);
1444                 msleep(10);
1445                 em28xx_write_regs(dev, 0x08, "\x6d", 1);
1446                 msleep(10);
1447                 em28xx_write_regs(dev, 0x08, "\x7d", 1);
1448                 msleep(10);
1449                 break;
1450
1451         case EM2870_BOARD_KWORLD_355U:
1452                 em28xx_write_regs(dev, EM28XX_R0F_XCLK, "\x27", 1);
1453                 em28xx_write_regs(dev, EM28XX_R06_I2C_CLK, "\x40", 1);
1454                 msleep(50);
1455
1456                 /* Sets GPO/GPIO sequences for this device */
1457                 dev->digital_gpio     = em2870_kworld_355u_digital;
1458                 break;
1459
1460         case EM2870_BOARD_COMPRO_VIDEOMATE:
1461                 em28xx_write_regs(dev, EM28XX_R0F_XCLK, "\x27", 1);
1462                 em28xx_write_regs(dev, EM28XX_R06_I2C_CLK, "\x40", 1);
1463                 /* TODO: someone can do some cleanup here...
1464                          not everything's needed */
1465                 em28xx_write_regs(dev, 0x04, "\x00", 1);
1466                 msleep(10);
1467                 em28xx_write_regs(dev, 0x04, "\x01", 1);
1468                 msleep(10);
1469                 em28xx_write_regs(dev, 0x08, "\xfd", 1);
1470                 mdelay(70);
1471                 em28xx_write_regs(dev, 0x08, "\xfc", 1);
1472                 mdelay(70);
1473                 em28xx_write_regs(dev, 0x08, "\xdc", 1);
1474                 mdelay(70);
1475                 em28xx_write_regs(dev, 0x08, "\xfc", 1);
1476                 mdelay(70);
1477                 break;
1478
1479         case EM2870_BOARD_TERRATEC_XS_MT2060:
1480                 em28xx_write_regs(dev, EM28XX_R0F_XCLK, "\x27", 1);
1481                 em28xx_write_regs(dev, EM28XX_R06_I2C_CLK, "\x40", 1);
1482                 /* this device needs some gpio writes to get the DVB-T
1483                    demod work */
1484                 em28xx_write_regs(dev, 0x08, "\xfe", 1);
1485                 mdelay(70);
1486                 em28xx_write_regs(dev, 0x08, "\xde", 1);
1487                 mdelay(70);
1488                 dev->em28xx_write_regs(dev, 0x08, "\xfe", 1);
1489                 mdelay(70);
1490                 break;
1491
1492         case EM2870_BOARD_PINNACLE_PCTV_DVB:
1493                 em28xx_write_regs(dev, EM28XX_R06_I2C_CLK, "\x40", 1);
1494                 /* this device needs some gpio writes to get the
1495                    DVB-T demod work */
1496                 em28xx_write_regs(dev, 0x08, "\xfe", 1);
1497                 mdelay(70);
1498                 em28xx_write_regs(dev, 0x08, "\xde", 1);
1499                 mdelay(70);
1500                 em28xx_write_regs(dev, 0x08, "\xfe", 1);
1501                 mdelay(70);
1502                 /* switch em2880 rc protocol */
1503                 em28xx_write_regs(dev, EM28XX_R0F_XCLK, "\x22", 1);
1504                 /* should be added ir_codes here */
1505                 break;
1506
1507         case EM2820_BOARD_GADMEI_UTV310:
1508                 em28xx_write_regs(dev, EM28XX_R0F_XCLK, "\x27", 1);
1509                 em28xx_write_regs(dev, EM28XX_R06_I2C_CLK, "\x40", 1);
1510                 /* Turn on analog audio output */
1511                 em28xx_write_regs_req(dev, 0x00, 0x08, "\xfd", 1);
1512                 break;
1513
1514         case EM2860_BOARD_GADMEI_UTV330:
1515                 /* Turn on IR */
1516                 em28xx_write_regs(dev, EM28XX_R0F_XCLK, "\x07", 1);
1517                 em28xx_write_regs(dev, EM28XX_R06_I2C_CLK, "\x40", 1);
1518                 /* should be added ir_codes here */
1519                 break;
1520
1521         case EM2820_BOARD_MSI_VOX_USB_2:
1522                 em28xx_write_regs(dev, EM28XX_R0F_XCLK, "\x27", 1);
1523                 em28xx_write_regs(dev, EM28XX_R06_I2C_CLK, "\x40", 1);
1524                 /* enables audio for that device */
1525                 em28xx_write_regs_req(dev, 0x00, 0x08, "\xfd", 1);
1526                 break;
1527         }
1528
1529         em28xx_gpio_set(dev, dev->tun_analog_gpio);
1530         em28xx_set_mode(dev, EM28XX_ANALOG_MODE);
1531
1532         /* Unlock device */
1533         em28xx_set_mode(dev, EM28XX_MODE_UNDEFINED);
1534 }
1535
1536 static void em28xx_setup_xc3028(struct em28xx *dev, struct xc2028_ctrl *ctl)
1537 {
1538         memset(ctl, 0, sizeof(*ctl));
1539
1540         ctl->fname   = XC2028_DEFAULT_FIRMWARE;
1541         ctl->max_len = 64;
1542         ctl->mts = em28xx_boards[dev->model].mts_firmware;
1543
1544         switch (dev->model) {
1545         case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900:
1546                 ctl->demod = XC3028_FE_ZARLINK456;
1547                 break;
1548         case EM2880_BOARD_TERRATEC_HYBRID_XS:
1549                 ctl->demod = XC3028_FE_ZARLINK456;
1550                 break;
1551         case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900_R2:
1552                 /* djh - Not sure which demod we need here */
1553                 ctl->demod = XC3028_FE_DEFAULT;
1554                 break;
1555         case EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950:
1556         case EM2880_BOARD_PINNACLE_PCTV_HD_PRO:
1557         case EM2880_BOARD_AMD_ATI_TV_WONDER_HD_600:
1558                 /* FIXME: Better to specify the needed IF */
1559                 ctl->demod = XC3028_FE_DEFAULT;
1560                 break;
1561         default:
1562                 ctl->demod = XC3028_FE_OREN538;
1563         }
1564 }
1565
1566 static void em28xx_config_tuner(struct em28xx *dev)
1567 {
1568         struct v4l2_priv_tun_config  xc2028_cfg;
1569         struct tuner_setup           tun_setup;
1570         struct v4l2_frequency        f;
1571
1572         if (dev->tuner_type == TUNER_ABSENT)
1573                 return;
1574
1575         tun_setup.mode_mask = T_ANALOG_TV | T_RADIO;
1576         tun_setup.type = dev->tuner_type;
1577         tun_setup.addr = dev->tuner_addr;
1578         tun_setup.tuner_callback = em28xx_tuner_callback;
1579
1580         em28xx_i2c_call_clients(dev, TUNER_SET_TYPE_ADDR, &tun_setup);
1581
1582         if (dev->tuner_type == TUNER_XC2028) {
1583                 struct xc2028_ctrl           ctl;
1584
1585                 em28xx_setup_xc3028(dev, &ctl);
1586
1587                 xc2028_cfg.tuner = TUNER_XC2028;
1588                 xc2028_cfg.priv  = &ctl;
1589
1590                 em28xx_i2c_call_clients(dev, TUNER_SET_CONFIG, &xc2028_cfg);
1591         }
1592
1593         /* configure tuner */
1594         f.tuner = 0;
1595         f.type = V4L2_TUNER_ANALOG_TV;
1596         f.frequency = 9076;     /* just a magic number */
1597         dev->ctl_freq = f.frequency;
1598         em28xx_i2c_call_clients(dev, VIDIOC_S_FREQUENCY, &f);
1599 }
1600
1601 static int em28xx_hint_board(struct em28xx *dev)
1602 {
1603         int i;
1604
1605         /* HINT method: EEPROM
1606          *
1607          * This method works only for boards with eeprom.
1608          * Uses a hash of all eeprom bytes. The hash should be
1609          * unique for a vendor/tuner pair.
1610          * There are a high chance that tuners for different
1611          * video standards produce different hashes.
1612          */
1613         for (i = 0; i < ARRAY_SIZE(em28xx_eeprom_hash); i++) {
1614                 if (dev->hash == em28xx_eeprom_hash[i].hash) {
1615                         dev->model = em28xx_eeprom_hash[i].model;
1616                         dev->tuner_type = em28xx_eeprom_hash[i].tuner;
1617
1618                         em28xx_errdev("Your board has no unique USB ID.\n");
1619                         em28xx_errdev("A hint were successfully done, "
1620                                       "based on eeprom hash.\n");
1621                         em28xx_errdev("This method is not 100%% failproof.\n");
1622                         em28xx_errdev("If the board were missdetected, "
1623                                       "please email this log to:\n");
1624                         em28xx_errdev("\tV4L Mailing List "
1625                                       " <video4linux-list@redhat.com>\n");
1626                         em28xx_errdev("Board detected as %s\n",
1627                                       em28xx_boards[dev->model].name);
1628
1629                         return 0;
1630                 }
1631         }
1632
1633         /* HINT method: I2C attached devices
1634          *
1635          * This method works for all boards.
1636          * Uses a hash of i2c scanned devices.
1637          * Devices with the same i2c attached chips will
1638          * be considered equal.
1639          * This method is less precise than the eeprom one.
1640          */
1641
1642         /* user did not request i2c scanning => do it now */
1643         if (!dev->i2c_hash)
1644                 em28xx_do_i2c_scan(dev);
1645
1646         for (i = 0; i < ARRAY_SIZE(em28xx_i2c_hash); i++) {
1647                 if (dev->i2c_hash == em28xx_i2c_hash[i].hash) {
1648                         dev->model = em28xx_i2c_hash[i].model;
1649                         dev->tuner_type = em28xx_i2c_hash[i].tuner;
1650                         em28xx_errdev("Your board has no unique USB ID.\n");
1651                         em28xx_errdev("A hint were successfully done, "
1652                                       "based on i2c devicelist hash.\n");
1653                         em28xx_errdev("This method is not 100%% failproof.\n");
1654                         em28xx_errdev("If the board were missdetected, "
1655                                       "please email this log to:\n");
1656                         em28xx_errdev("\tV4L Mailing List "
1657                                       " <video4linux-list@redhat.com>\n");
1658                         em28xx_errdev("Board detected as %s\n",
1659                                       em28xx_boards[dev->model].name);
1660
1661                         return 0;
1662                 }
1663         }
1664
1665         em28xx_errdev("Your board has no unique USB ID and thus need a "
1666                       "hint to be detected.\n");
1667         em28xx_errdev("You may try to use card=<n> insmod option to "
1668                       "workaround that.\n");
1669         em28xx_errdev("Please send an email with this log to:\n");
1670         em28xx_errdev("\tV4L Mailing List <video4linux-list@redhat.com>\n");
1671         em28xx_errdev("Board eeprom hash is 0x%08lx\n", dev->hash);
1672         em28xx_errdev("Board i2c devicelist hash is 0x%08lx\n", dev->i2c_hash);
1673
1674         em28xx_errdev("Here is a list of valid choices for the card=<n>"
1675                       " insmod option:\n");
1676         for (i = 0; i < em28xx_bcount; i++) {
1677                 em28xx_errdev("    card=%d -> %s\n",
1678                                 i, em28xx_boards[i].name);
1679         }
1680         return -1;
1681 }
1682
1683 /* ----------------------------------------------------------------------- */
1684 void em28xx_set_ir(struct em28xx *dev, struct IR_i2c *ir)
1685 {
1686         if (disable_ir) {
1687                 ir->get_key = NULL;
1688                 return ;
1689         }
1690
1691         /* detect & configure */
1692         switch (dev->model) {
1693         case (EM2800_BOARD_UNKNOWN):
1694                 break;
1695         case (EM2820_BOARD_UNKNOWN):
1696                 break;
1697         case (EM2800_BOARD_TERRATEC_CINERGY_200):
1698         case (EM2820_BOARD_TERRATEC_CINERGY_250):
1699                 ir->ir_codes = ir_codes_em_terratec;
1700                 ir->get_key = em28xx_get_key_terratec;
1701                 snprintf(ir->c.name, sizeof(ir->c.name),
1702                          "i2c IR (EM28XX Terratec)");
1703                 break;
1704         case (EM2820_BOARD_PINNACLE_USB_2):
1705                 ir->ir_codes = ir_codes_pinnacle_grey;
1706                 ir->get_key = em28xx_get_key_pinnacle_usb_grey;
1707                 snprintf(ir->c.name, sizeof(ir->c.name),
1708                          "i2c IR (EM28XX Pinnacle PCTV)");
1709                 break;
1710         case (EM2820_BOARD_HAUPPAUGE_WINTV_USB_2):
1711                 ir->ir_codes = ir_codes_hauppauge_new;
1712                 ir->get_key = em28xx_get_key_em_haup;
1713                 snprintf(ir->c.name, sizeof(ir->c.name),
1714                          "i2c IR (EM2840 Hauppauge)");
1715                 break;
1716         case (EM2820_BOARD_MSI_VOX_USB_2):
1717                 break;
1718         case (EM2800_BOARD_LEADTEK_WINFAST_USBII):
1719                 break;
1720         case (EM2800_BOARD_KWORLD_USB2800):
1721                 break;
1722         case (EM2800_BOARD_GRABBEEX_USB2800):
1723                 break;
1724         }
1725 }
1726
1727 void em28xx_card_setup(struct em28xx *dev)
1728 {
1729         em28xx_set_model(dev);
1730
1731         dev->tuner_type = em28xx_boards[dev->model].tuner_type;
1732
1733         /* request some modules */
1734         switch (dev->model) {
1735         case EM2820_BOARD_HAUPPAUGE_WINTV_USB_2:
1736         case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900:
1737         case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900_R2:
1738         case EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950:
1739         {
1740                 struct tveeprom tv;
1741 #ifdef CONFIG_MODULES
1742                 request_module("tveeprom");
1743 #endif
1744                 /* Call first TVeeprom */
1745
1746                 dev->i2c_client.addr = 0xa0 >> 1;
1747                 tveeprom_hauppauge_analog(&dev->i2c_client, &tv, dev->eedata);
1748
1749                 dev->tuner_type = tv.tuner_type;
1750
1751                 if (tv.audio_processor == V4L2_IDENT_MSPX4XX) {
1752                         dev->i2s_speed = 2048000;
1753                         dev->has_msp34xx = 1;
1754                 }
1755 #ifdef CONFIG_MODULES
1756                 if (tv.has_ir)
1757                         request_module("ir-kbd-i2c");
1758 #endif
1759                 break;
1760         }
1761         case EM2820_BOARD_KWORLD_PVRTV2800RF:
1762                 /* GPIO enables sound on KWORLD PVR TV 2800RF */
1763                 em28xx_write_regs_req(dev, 0x00, 0x08, "\xf9", 1);
1764                 break;
1765         case EM2820_BOARD_UNKNOWN:
1766         case EM2800_BOARD_UNKNOWN:
1767                 if (!em28xx_hint_board(dev))
1768                         em28xx_set_model(dev);
1769                 break;
1770         }
1771
1772         if (dev->has_snapshot_button)
1773                 em28xx_register_snapshot_button(dev);
1774
1775         if (dev->valid == EM28XX_BOARD_NOT_VALIDATED) {
1776                 em28xx_errdev("\n\n");
1777                 em28xx_errdev("The support for this board weren't "
1778                               "valid yet.\n");
1779                 em28xx_errdev("Please send a report of having this working\n");
1780                 em28xx_errdev("not to V4L mailing list (and/or to other "
1781                                 "addresses)\n\n");
1782         }
1783
1784         /* Allow override tuner type by a module parameter */
1785         if (tuner >= 0)
1786                 dev->tuner_type = tuner;
1787
1788 #ifdef CONFIG_MODULES
1789         /* request some modules */
1790         if (dev->has_msp34xx)
1791                 request_module("msp3400");
1792         if (dev->decoder == EM28XX_SAA7113 || dev->decoder == EM28XX_SAA7114)
1793                 request_module("saa7115");
1794         if (dev->decoder == EM28XX_TVP5150)
1795                 request_module("tvp5150");
1796         if (dev->tuner_type != TUNER_ABSENT)
1797                 request_module("tuner");
1798 #endif
1799
1800         em28xx_config_tuner(dev);
1801 }