V4L/DVB (12720): em28xx-cards: Add vendor/product id for Kworld DVD Maker 2
[linux-3.10.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/tvaudio.h>
35 #include <media/i2c-addr.h>
36 #include <media/tveeprom.h>
37 #include <media/v4l2-common.h>
38 #include <media/v4l2-chip-ident.h>
39
40 #include "em28xx.h"
41
42 #define DRIVER_NAME         "em28xx"
43
44 static int tuner = -1;
45 module_param(tuner, int, 0444);
46 MODULE_PARM_DESC(tuner, "tuner type");
47
48 static unsigned int disable_ir;
49 module_param(disable_ir, int, 0444);
50 MODULE_PARM_DESC(disable_ir, "disable infrared remote support");
51
52 static unsigned int disable_usb_speed_check;
53 module_param(disable_usb_speed_check, int, 0444);
54 MODULE_PARM_DESC(disable_usb_speed_check,
55                  "override min bandwidth requirement of 480M bps");
56
57 static unsigned int card[]     = {[0 ... (EM28XX_MAXBOARDS - 1)] = UNSET };
58 module_param_array(card,  int, NULL, 0444);
59 MODULE_PARM_DESC(card,     "card type");
60
61 /* Bitmask marking allocated devices from 0 to EM28XX_MAXBOARDS */
62 static unsigned long em28xx_devused;
63
64 struct em28xx_hash_table {
65         unsigned long hash;
66         unsigned int  model;
67         unsigned int  tuner;
68 };
69
70 /*
71  *  Reset sequences for analog/digital modes
72  */
73
74 /* Reset for the most [analog] boards */
75 static struct em28xx_reg_seq default_analog[] = {
76         {EM28XX_R08_GPIO,       0x6d,   ~EM_GPIO_4,     10},
77         {       -1,             -1,     -1,             -1},
78 };
79
80 /* Reset for the most [digital] boards */
81 static struct em28xx_reg_seq default_digital[] = {
82         {EM28XX_R08_GPIO,       0x6e,   ~EM_GPIO_4,     10},
83         {       -1,             -1,     -1,             -1},
84 };
85
86 /* Board Hauppauge WinTV HVR 900 analog */
87 static struct em28xx_reg_seq hauppauge_wintv_hvr_900_analog[] = {
88         {EM28XX_R08_GPIO,       0x2d,   ~EM_GPIO_4,     10},
89         {0x05,                  0xff,   0x10,           10},
90         {  -1,                  -1,     -1,             -1},
91 };
92
93 /* Board Hauppauge WinTV HVR 900 digital */
94 static struct em28xx_reg_seq hauppauge_wintv_hvr_900_digital[] = {
95         {EM28XX_R08_GPIO,       0x2e,   ~EM_GPIO_4,     10},
96         {EM2880_R04_GPO,        0x04,   0x0f,           10},
97         {EM2880_R04_GPO,        0x0c,   0x0f,           10},
98         { -1,                   -1,     -1,             -1},
99 };
100
101 /* Boards - EM2880 MSI DIGIVOX AD and EM2880_BOARD_MSI_DIGIVOX_AD_II */
102 static struct em28xx_reg_seq em2880_msi_digivox_ad_analog[] = {
103         {EM28XX_R08_GPIO,       0x69,   ~EM_GPIO_4,      10},
104         {       -1,             -1,     -1,              -1},
105 };
106
107 /* Boards - EM2880 MSI DIGIVOX AD and EM2880_BOARD_MSI_DIGIVOX_AD_II */
108
109 /* Board  - EM2870 Kworld 355u
110    Analog - No input analog */
111
112 /* Board - EM2882 Kworld 315U digital */
113 static struct em28xx_reg_seq em2882_kworld_315u_digital[] = {
114         {EM28XX_R08_GPIO,       0xff,   0xff,           10},
115         {EM28XX_R08_GPIO,       0xfe,   0xff,           10},
116         {EM2880_R04_GPO,        0x04,   0xff,           10},
117         {EM2880_R04_GPO,        0x0c,   0xff,           10},
118         {EM28XX_R08_GPIO,       0x7e,   0xff,           10},
119         {  -1,                  -1,     -1,             -1},
120 };
121
122 static struct em28xx_reg_seq em2882_kworld_315u_tuner_gpio[] = {
123         {EM2880_R04_GPO,        0x08,   0xff,           10},
124         {EM2880_R04_GPO,        0x0c,   0xff,           10},
125         {EM2880_R04_GPO,        0x08,   0xff,           10},
126         {EM2880_R04_GPO,        0x0c,   0xff,           10},
127         {  -1,                  -1,     -1,             -1},
128 };
129
130 static struct em28xx_reg_seq kworld_330u_analog[] = {
131         {EM28XX_R08_GPIO,       0x6d,   ~EM_GPIO_4,     10},
132         {EM2880_R04_GPO,        0x00,   0xff,           10},
133         { -1,                   -1,     -1,             -1},
134 };
135
136 static struct em28xx_reg_seq kworld_330u_digital[] = {
137         {EM28XX_R08_GPIO,       0x6e,   ~EM_GPIO_4,     10},
138         {EM2880_R04_GPO,        0x08,   0xff,           10},
139         { -1,                   -1,     -1,             -1},
140 };
141
142 /* Evga inDtube
143    GPIO0 - Enable digital power (s5h1409) - low to enable
144    GPIO1 - Enable analog power (tvp5150/emp202) - low to enable
145    GPIO4 - xc3028 reset
146    GOP3  - s5h1409 reset
147  */
148 static struct em28xx_reg_seq evga_indtube_analog[] = {
149         {EM28XX_R08_GPIO,       0x79,   0xff,           60},
150         {       -1,             -1,     -1,             -1},
151 };
152
153 static struct em28xx_reg_seq evga_indtube_digital[] = {
154         {EM28XX_R08_GPIO,       0x7a,   0xff,            1},
155         {EM2880_R04_GPO,        0x04,   0xff,           10},
156         {EM2880_R04_GPO,        0x0c,   0xff,            1},
157         { -1,                   -1,     -1,             -1},
158 };
159
160 /* Pinnacle Hybrid Pro eb1a:2881 */
161 static struct em28xx_reg_seq pinnacle_hybrid_pro_analog[] = {
162         {EM28XX_R08_GPIO,       0xfd,   ~EM_GPIO_4,     10},
163         {       -1,             -1,     -1,             -1},
164 };
165
166 static struct em28xx_reg_seq pinnacle_hybrid_pro_digital[] = {
167         {EM28XX_R08_GPIO,       0x6e,   ~EM_GPIO_4,     10},
168         {EM2880_R04_GPO,        0x04,   0xff,          100},/* zl10353 reset */
169         {EM2880_R04_GPO,        0x0c,   0xff,            1},
170         {       -1,             -1,     -1,             -1},
171 };
172
173
174 /* Callback for the most boards */
175 static struct em28xx_reg_seq default_tuner_gpio[] = {
176         {EM28XX_R08_GPIO,       EM_GPIO_4,      EM_GPIO_4,      10},
177         {EM28XX_R08_GPIO,       0,              EM_GPIO_4,      10},
178         {EM28XX_R08_GPIO,       EM_GPIO_4,      EM_GPIO_4,      10},
179         {  -1,                  -1,             -1,             -1},
180 };
181
182 /* Mute/unmute */
183 static struct em28xx_reg_seq compro_unmute_tv_gpio[] = {
184         {EM28XX_R08_GPIO,       5,              7,              10},
185         {  -1,                  -1,             -1,             -1},
186 };
187
188 static struct em28xx_reg_seq compro_unmute_svid_gpio[] = {
189         {EM28XX_R08_GPIO,       4,              7,              10},
190         {  -1,                  -1,             -1,             -1},
191 };
192
193 static struct em28xx_reg_seq compro_mute_gpio[] = {
194         {EM28XX_R08_GPIO,       6,              7,              10},
195         {  -1,                  -1,             -1,             -1},
196 };
197
198 /* Terratec AV350 */
199 static struct em28xx_reg_seq terratec_av350_mute_gpio[] = {
200         {EM28XX_R08_GPIO,       0xff,   0x7f,           10},
201         {       -1,             -1,     -1,             -1},
202 };
203
204 static struct em28xx_reg_seq terratec_av350_unmute_gpio[] = {
205         {EM28XX_R08_GPIO,       0xff,   0xff,           10},
206         {       -1,             -1,     -1,             -1},
207 };
208
209 static struct em28xx_reg_seq silvercrest_reg_seq[] = {
210         {EM28XX_R08_GPIO,       0xff,   0xff,           10},
211         {EM28XX_R08_GPIO,       0x01,   0xf7,           10},
212         {       -1,             -1,     -1,             -1},
213 };
214
215 /*
216  *  Board definitions
217  */
218 struct em28xx_board em28xx_boards[] = {
219         [EM2750_BOARD_UNKNOWN] = {
220                 .name          = "EM2710/EM2750/EM2751 webcam grabber",
221                 .xclk          = EM28XX_XCLK_FREQUENCY_20MHZ,
222                 .tuner_type    = TUNER_ABSENT,
223                 .is_webcam     = 1,
224                 .input         = { {
225                         .type     = EM28XX_VMUX_COMPOSITE1,
226                         .vmux     = 0,
227                         .amux     = EM28XX_AMUX_VIDEO,
228                         .gpio     = silvercrest_reg_seq,
229                 } },
230         },
231         [EM2800_BOARD_UNKNOWN] = {
232                 .name         = "Unknown EM2800 video grabber",
233                 .is_em2800    = 1,
234                 .tda9887_conf = TDA9887_PRESENT,
235                 .decoder      = EM28XX_SAA711X,
236                 .tuner_type   = TUNER_ABSENT,
237                 .input        = { {
238                         .type     = EM28XX_VMUX_COMPOSITE1,
239                         .vmux     = SAA7115_COMPOSITE0,
240                         .amux     = EM28XX_AMUX_LINE_IN,
241                 }, {
242                         .type     = EM28XX_VMUX_SVIDEO,
243                         .vmux     = SAA7115_SVIDEO3,
244                         .amux     = EM28XX_AMUX_LINE_IN,
245                 } },
246         },
247         [EM2820_BOARD_UNKNOWN] = {
248                 .name          = "Unknown EM2750/28xx video grabber",
249                 .tuner_type    = TUNER_ABSENT,
250                 .is_webcam     = 1,     /* To enable sensor probe */
251         },
252         [EM2750_BOARD_DLCW_130] = {
253                 /* Beijing Huaqi Information Digital Technology Co., Ltd */
254                 .name          = "Huaqi DLCW-130",
255                 .valid         = EM28XX_BOARD_NOT_VALIDATED,
256                 .xclk          = EM28XX_XCLK_FREQUENCY_48MHZ,
257                 .tuner_type    = TUNER_ABSENT,
258                 .is_webcam     = 1,
259                 .input         = { {
260                         .type     = EM28XX_VMUX_COMPOSITE1,
261                         .vmux     = 0,
262                         .amux     = EM28XX_AMUX_VIDEO,
263                 } },
264         },
265         [EM2820_BOARD_KWORLD_PVRTV2800RF] = {
266                 .name         = "Kworld PVR TV 2800 RF",
267                 .tuner_type   = TUNER_TEMIC_PAL,
268                 .tda9887_conf = TDA9887_PRESENT,
269                 .decoder      = EM28XX_SAA711X,
270                 .input        = { {
271                         .type     = EM28XX_VMUX_COMPOSITE1,
272                         .vmux     = SAA7115_COMPOSITE0,
273                         .amux     = EM28XX_AMUX_LINE_IN,
274                 }, {
275                         .type     = EM28XX_VMUX_SVIDEO,
276                         .vmux     = SAA7115_SVIDEO3,
277                         .amux     = EM28XX_AMUX_LINE_IN,
278                 } },
279         },
280         [EM2820_BOARD_GADMEI_TVR200] = {
281                 .name         = "Gadmei TVR200",
282                 .tuner_type   = TUNER_LG_PAL_NEW_TAPC,
283                 .tda9887_conf = TDA9887_PRESENT,
284                 .decoder      = EM28XX_SAA711X,
285                 .input        = { {
286                         .type     = EM28XX_VMUX_TELEVISION,
287                         .vmux     = SAA7115_COMPOSITE2,
288                         .amux     = EM28XX_AMUX_LINE_IN,
289                 }, {
290                         .type     = EM28XX_VMUX_COMPOSITE1,
291                         .vmux     = SAA7115_COMPOSITE0,
292                         .amux     = EM28XX_AMUX_LINE_IN,
293                 }, {
294                         .type     = EM28XX_VMUX_SVIDEO,
295                         .vmux     = SAA7115_SVIDEO3,
296                         .amux     = EM28XX_AMUX_LINE_IN,
297                 } },
298         },
299         [EM2820_BOARD_TERRATEC_CINERGY_250] = {
300                 .name         = "Terratec Cinergy 250 USB",
301                 .tuner_type   = TUNER_LG_PAL_NEW_TAPC,
302                 .has_ir_i2c   = 1,
303                 .tda9887_conf = TDA9887_PRESENT,
304                 .decoder      = EM28XX_SAA711X,
305                 .input        = { {
306                         .type     = EM28XX_VMUX_TELEVISION,
307                         .vmux     = SAA7115_COMPOSITE2,
308                         .amux     = EM28XX_AMUX_LINE_IN,
309                 }, {
310                         .type     = EM28XX_VMUX_COMPOSITE1,
311                         .vmux     = SAA7115_COMPOSITE0,
312                         .amux     = EM28XX_AMUX_LINE_IN,
313                 }, {
314                         .type     = EM28XX_VMUX_SVIDEO,
315                         .vmux     = SAA7115_SVIDEO3,
316                         .amux     = EM28XX_AMUX_LINE_IN,
317                 } },
318         },
319         [EM2820_BOARD_PINNACLE_USB_2] = {
320                 .name         = "Pinnacle PCTV USB 2",
321                 .tuner_type   = TUNER_LG_PAL_NEW_TAPC,
322                 .has_ir_i2c   = 1,
323                 .tda9887_conf = TDA9887_PRESENT,
324                 .decoder      = EM28XX_SAA711X,
325                 .input        = { {
326                         .type     = EM28XX_VMUX_TELEVISION,
327                         .vmux     = SAA7115_COMPOSITE2,
328                         .amux     = EM28XX_AMUX_VIDEO,
329                 }, {
330                         .type     = EM28XX_VMUX_COMPOSITE1,
331                         .vmux     = SAA7115_COMPOSITE0,
332                         .amux     = EM28XX_AMUX_LINE_IN,
333                 }, {
334                         .type     = EM28XX_VMUX_SVIDEO,
335                         .vmux     = SAA7115_SVIDEO3,
336                         .amux     = EM28XX_AMUX_LINE_IN,
337                 } },
338         },
339         [EM2820_BOARD_HAUPPAUGE_WINTV_USB_2] = {
340                 .name         = "Hauppauge WinTV USB 2",
341                 .tuner_type   = TUNER_PHILIPS_FM1236_MK3,
342                 .tda9887_conf = TDA9887_PRESENT |
343                                 TDA9887_PORT1_ACTIVE |
344                                 TDA9887_PORT2_ACTIVE,
345                 .decoder      = EM28XX_TVP5150,
346                 .has_msp34xx  = 1,
347                 .has_ir_i2c   = 1,
348                 .input        = { {
349                         .type     = EM28XX_VMUX_TELEVISION,
350                         .vmux     = TVP5150_COMPOSITE0,
351                         .amux     = MSP_INPUT_DEFAULT,
352                 }, {
353                         .type     = EM28XX_VMUX_SVIDEO,
354                         .vmux     = TVP5150_SVIDEO,
355                         .amux     = MSP_INPUT(MSP_IN_SCART1, MSP_IN_TUNER1,
356                                         MSP_DSP_IN_SCART, MSP_DSP_IN_SCART),
357                 } },
358         },
359         [EM2820_BOARD_DLINK_USB_TV] = {
360                 .name         = "D-Link DUB-T210 TV Tuner",
361                 .valid        = EM28XX_BOARD_NOT_VALIDATED,
362                 .tuner_type   = TUNER_LG_PAL_NEW_TAPC,
363                 .tda9887_conf = TDA9887_PRESENT,
364                 .decoder      = EM28XX_SAA711X,
365                 .input        = { {
366                         .type     = EM28XX_VMUX_TELEVISION,
367                         .vmux     = SAA7115_COMPOSITE2,
368                         .amux     = EM28XX_AMUX_LINE_IN,
369                 }, {
370                         .type     = EM28XX_VMUX_COMPOSITE1,
371                         .vmux     = SAA7115_COMPOSITE0,
372                         .amux     = EM28XX_AMUX_LINE_IN,
373                 }, {
374                         .type     = EM28XX_VMUX_SVIDEO,
375                         .vmux     = SAA7115_SVIDEO3,
376                         .amux     = EM28XX_AMUX_LINE_IN,
377                 } },
378         },
379         [EM2820_BOARD_HERCULES_SMART_TV_USB2] = {
380                 .name         = "Hercules Smart TV USB 2.0",
381                 .valid        = EM28XX_BOARD_NOT_VALIDATED,
382                 .tuner_type   = TUNER_LG_PAL_NEW_TAPC,
383                 .tda9887_conf = TDA9887_PRESENT,
384                 .decoder      = EM28XX_SAA711X,
385                 .input        = { {
386                         .type     = EM28XX_VMUX_TELEVISION,
387                         .vmux     = SAA7115_COMPOSITE2,
388                         .amux     = EM28XX_AMUX_LINE_IN,
389                 }, {
390                         .type     = EM28XX_VMUX_COMPOSITE1,
391                         .vmux     = SAA7115_COMPOSITE0,
392                         .amux     = EM28XX_AMUX_LINE_IN,
393                 }, {
394                         .type     = EM28XX_VMUX_SVIDEO,
395                         .vmux     = SAA7115_SVIDEO3,
396                         .amux     = EM28XX_AMUX_LINE_IN,
397                 } },
398         },
399         [EM2820_BOARD_PINNACLE_USB_2_FM1216ME] = {
400                 .name         = "Pinnacle PCTV USB 2 (Philips FM1216ME)",
401                 .valid        = EM28XX_BOARD_NOT_VALIDATED,
402                 .tuner_type   = TUNER_PHILIPS_FM1216ME_MK3,
403                 .tda9887_conf = TDA9887_PRESENT,
404                 .decoder      = EM28XX_SAA711X,
405                 .input        = { {
406                         .type     = EM28XX_VMUX_TELEVISION,
407                         .vmux     = SAA7115_COMPOSITE2,
408                         .amux     = EM28XX_AMUX_VIDEO,
409                 }, {
410                         .type     = EM28XX_VMUX_COMPOSITE1,
411                         .vmux     = SAA7115_COMPOSITE0,
412                         .amux     = EM28XX_AMUX_LINE_IN,
413                 }, {
414                         .type     = EM28XX_VMUX_SVIDEO,
415                         .vmux     = SAA7115_SVIDEO3,
416                         .amux     = EM28XX_AMUX_LINE_IN,
417                 } },
418         },
419         [EM2820_BOARD_GADMEI_UTV310] = {
420                 .name         = "Gadmei UTV310",
421                 .valid        = EM28XX_BOARD_NOT_VALIDATED,
422                 .tuner_type   = TUNER_TNF_5335MF,
423                 .tda9887_conf = TDA9887_PRESENT,
424                 .decoder      = EM28XX_SAA711X,
425                 .input        = { {
426                         .type     = EM28XX_VMUX_TELEVISION,
427                         .vmux     = SAA7115_COMPOSITE1,
428                         .amux     = EM28XX_AMUX_LINE_IN,
429                 }, {
430                         .type     = EM28XX_VMUX_COMPOSITE1,
431                         .vmux     = SAA7115_COMPOSITE0,
432                         .amux     = EM28XX_AMUX_LINE_IN,
433                 }, {
434                         .type     = EM28XX_VMUX_SVIDEO,
435                         .vmux     = SAA7115_SVIDEO3,
436                         .amux     = EM28XX_AMUX_LINE_IN,
437                 } },
438         },
439         [EM2820_BOARD_LEADTEK_WINFAST_USBII_DELUXE] = {
440                 .name         = "Leadtek Winfast USB II Deluxe",
441                 .valid        = EM28XX_BOARD_NOT_VALIDATED,
442                 .tuner_type   = TUNER_PHILIPS_FM1216ME_MK3,
443                 .tda9887_conf = TDA9887_PRESENT,
444                 .decoder      = EM28XX_SAA711X,
445                 .input        = { {
446                         .type     = EM28XX_VMUX_TELEVISION,
447                         .vmux     = SAA7115_COMPOSITE2,
448                         .amux     = EM28XX_AMUX_VIDEO,
449                 }, {
450                         .type     = EM28XX_VMUX_COMPOSITE1,
451                         .vmux     = SAA7115_COMPOSITE0,
452                         .amux     = EM28XX_AMUX_LINE_IN,
453                 }, {
454                         .type     = EM28XX_VMUX_SVIDEO,
455                         .vmux     = SAA7115_COMPOSITE0,
456                         .amux     = EM28XX_AMUX_LINE_IN,
457                 } },
458         },
459         [EM2820_BOARD_VIDEOLOGY_20K14XUSB] = {
460                 .name         = "Videology 20K14XUSB USB2.0",
461                 .valid        = EM28XX_BOARD_NOT_VALIDATED,
462                 .tuner_type   = TUNER_ABSENT,
463                 .is_webcam    = 1,
464                 .input        = { {
465                         .type     = EM28XX_VMUX_COMPOSITE1,
466                         .vmux     = 0,
467                         .amux     = EM28XX_AMUX_VIDEO,
468                 } },
469         },
470         [EM2820_BOARD_SILVERCREST_WEBCAM] = {
471                 .name         = "Silvercrest Webcam 1.3mpix",
472                 .tuner_type   = TUNER_ABSENT,
473                 .is_webcam    = 1,
474                 .input        = { {
475                         .type     = EM28XX_VMUX_COMPOSITE1,
476                         .vmux     = 0,
477                         .amux     = EM28XX_AMUX_VIDEO,
478                         .gpio     = silvercrest_reg_seq,
479                 } },
480         },
481         [EM2821_BOARD_SUPERCOMP_USB_2] = {
482                 .name         = "Supercomp USB 2.0 TV",
483                 .valid        = EM28XX_BOARD_NOT_VALIDATED,
484                 .tuner_type   = TUNER_PHILIPS_FM1236_MK3,
485                 .tda9887_conf = TDA9887_PRESENT |
486                                 TDA9887_PORT1_ACTIVE |
487                                 TDA9887_PORT2_ACTIVE,
488                 .decoder      = EM28XX_SAA711X,
489                 .input        = { {
490                         .type     = EM28XX_VMUX_TELEVISION,
491                         .vmux     = SAA7115_COMPOSITE2,
492                         .amux     = EM28XX_AMUX_LINE_IN,
493                 }, {
494                         .type     = EM28XX_VMUX_COMPOSITE1,
495                         .vmux     = SAA7115_COMPOSITE0,
496                         .amux     = EM28XX_AMUX_VIDEO,
497                 }, {
498                         .type     = EM28XX_VMUX_SVIDEO,
499                         .vmux     = SAA7115_SVIDEO3,
500                         .amux     = EM28XX_AMUX_LINE_IN,
501                 } },
502         },
503         [EM2821_BOARD_USBGEAR_VD204] = {
504                 .name         = "Usbgear VD204v9",
505                 .valid        = EM28XX_BOARD_NOT_VALIDATED,
506                 .tuner_type   = TUNER_ABSENT,   /* Capture only device */
507                 .decoder      = EM28XX_SAA711X,
508                 .input        = { {
509                         .type  = EM28XX_VMUX_COMPOSITE1,
510                         .vmux  = SAA7115_COMPOSITE0,
511                         .amux  = EM28XX_AMUX_LINE_IN,
512                 }, {
513                         .type  = EM28XX_VMUX_SVIDEO,
514                         .vmux  = SAA7115_SVIDEO3,
515                         .amux  = EM28XX_AMUX_LINE_IN,
516                 } },
517         },
518         [EM2860_BOARD_NETGMBH_CAM] = {
519                 /* Beijing Huaqi Information Digital Technology Co., Ltd */
520                 .name         = "NetGMBH Cam",
521                 .valid        = EM28XX_BOARD_NOT_VALIDATED,
522                 .tuner_type   = TUNER_ABSENT,
523                 .is_webcam    = 1,
524                 .input        = { {
525                         .type     = EM28XX_VMUX_COMPOSITE1,
526                         .vmux     = 0,
527                         .amux     = EM28XX_AMUX_VIDEO,
528                 } },
529         },
530         [EM2860_BOARD_TYPHOON_DVD_MAKER] = {
531                 .name         = "Typhoon DVD Maker",
532                 .decoder      = EM28XX_SAA711X,
533                 .tuner_type   = TUNER_ABSENT,   /* Capture only device */
534                 .input        = { {
535                         .type  = EM28XX_VMUX_COMPOSITE1,
536                         .vmux  = SAA7115_COMPOSITE0,
537                         .amux  = EM28XX_AMUX_LINE_IN,
538                 }, {
539                         .type  = EM28XX_VMUX_SVIDEO,
540                         .vmux  = SAA7115_SVIDEO3,
541                         .amux  = EM28XX_AMUX_LINE_IN,
542                 } },
543         },
544         [EM2860_BOARD_GADMEI_UTV330] = {
545                 .name         = "Gadmei UTV330",
546                 .valid        = EM28XX_BOARD_NOT_VALIDATED,
547                 .tuner_type   = TUNER_TNF_5335MF,
548                 .tda9887_conf = TDA9887_PRESENT,
549                 .decoder      = EM28XX_SAA711X,
550                 .input        = { {
551                         .type     = EM28XX_VMUX_TELEVISION,
552                         .vmux     = SAA7115_COMPOSITE2,
553                         .amux     = EM28XX_AMUX_VIDEO,
554                 }, {
555                         .type     = EM28XX_VMUX_COMPOSITE1,
556                         .vmux     = SAA7115_COMPOSITE0,
557                         .amux     = EM28XX_AMUX_LINE_IN,
558                 }, {
559                         .type     = EM28XX_VMUX_SVIDEO,
560                         .vmux     = SAA7115_SVIDEO3,
561                         .amux     = EM28XX_AMUX_LINE_IN,
562                 } },
563         },
564         [EM2861_BOARD_GADMEI_UTV330PLUS] = {
565                 .name         = "Gadmei UTV330+",
566                 .tuner_type   = TUNER_TNF_5335MF,
567                 .tda9887_conf = TDA9887_PRESENT,
568                 .ir_codes     = &ir_codes_gadmei_rm008z_table,
569                 .decoder      = EM28XX_SAA711X,
570                 .xclk         = EM28XX_XCLK_FREQUENCY_12MHZ,
571                 .input        = { {
572                         .type     = EM28XX_VMUX_TELEVISION,
573                         .vmux     = SAA7115_COMPOSITE2,
574                         .amux     = EM28XX_AMUX_VIDEO,
575                 }, {
576                         .type     = EM28XX_VMUX_COMPOSITE1,
577                         .vmux     = SAA7115_COMPOSITE0,
578                         .amux     = EM28XX_AMUX_LINE_IN,
579                 }, {
580                         .type     = EM28XX_VMUX_SVIDEO,
581                         .vmux     = SAA7115_SVIDEO3,
582                         .amux     = EM28XX_AMUX_LINE_IN,
583                 } },
584         },
585         [EM2860_BOARD_TERRATEC_HYBRID_XS] = {
586                 .name         = "Terratec Cinergy A Hybrid XS",
587                 .valid        = EM28XX_BOARD_NOT_VALIDATED,
588                 .tuner_type   = TUNER_XC2028,
589                 .tuner_gpio   = default_tuner_gpio,
590                 .decoder      = EM28XX_TVP5150,
591
592                 .input        = { {
593                         .type     = EM28XX_VMUX_TELEVISION,
594                         .vmux     = TVP5150_COMPOSITE0,
595                         .amux     = EM28XX_AMUX_VIDEO,
596                         .gpio     = hauppauge_wintv_hvr_900_analog,
597                 }, {
598                         .type     = EM28XX_VMUX_COMPOSITE1,
599                         .vmux     = TVP5150_COMPOSITE1,
600                         .amux     = EM28XX_AMUX_LINE_IN,
601                         .gpio     = hauppauge_wintv_hvr_900_analog,
602                 }, {
603                         .type     = EM28XX_VMUX_SVIDEO,
604                         .vmux     = TVP5150_SVIDEO,
605                         .amux     = EM28XX_AMUX_LINE_IN,
606                         .gpio     = hauppauge_wintv_hvr_900_analog,
607                 } },
608         },
609         [EM2861_BOARD_KWORLD_PVRTV_300U] = {
610                 .name         = "KWorld PVRTV 300U",
611                 .valid        = EM28XX_BOARD_NOT_VALIDATED,
612                 .tuner_type   = TUNER_XC2028,
613                 .tuner_gpio   = default_tuner_gpio,
614                 .decoder      = EM28XX_TVP5150,
615                 .input        = { {
616                         .type     = EM28XX_VMUX_TELEVISION,
617                         .vmux     = TVP5150_COMPOSITE0,
618                         .amux     = EM28XX_AMUX_VIDEO,
619                 }, {
620                         .type     = EM28XX_VMUX_COMPOSITE1,
621                         .vmux     = TVP5150_COMPOSITE1,
622                         .amux     = EM28XX_AMUX_LINE_IN,
623                 }, {
624                         .type     = EM28XX_VMUX_SVIDEO,
625                         .vmux     = TVP5150_SVIDEO,
626                         .amux     = EM28XX_AMUX_LINE_IN,
627                 } },
628         },
629         [EM2861_BOARD_YAKUMO_MOVIE_MIXER] = {
630                 .name          = "Yakumo MovieMixer",
631                 .tuner_type    = TUNER_ABSENT,  /* Capture only device */
632                 .decoder       = EM28XX_TVP5150,
633                 .input         = { {
634                         .type     = EM28XX_VMUX_TELEVISION,
635                         .vmux     = TVP5150_COMPOSITE0,
636                         .amux     = EM28XX_AMUX_VIDEO,
637                 }, {
638                         .type     = EM28XX_VMUX_COMPOSITE1,
639                         .vmux     = TVP5150_COMPOSITE1,
640                         .amux     = EM28XX_AMUX_LINE_IN,
641                 }, {
642                         .type     = EM28XX_VMUX_SVIDEO,
643                         .vmux     = TVP5150_SVIDEO,
644                         .amux     = EM28XX_AMUX_LINE_IN,
645                 } },
646         },
647         [EM2861_BOARD_PLEXTOR_PX_TV100U] = {
648                 .name         = "Plextor ConvertX PX-TV100U",
649                 .tuner_type   = TUNER_TNF_5335MF,
650                 .xclk         = EM28XX_XCLK_I2S_MSB_TIMING |
651                                 EM28XX_XCLK_FREQUENCY_12MHZ,
652                 .tda9887_conf = TDA9887_PRESENT,
653                 .decoder      = EM28XX_TVP5150,
654                 .has_msp34xx  = 1,
655                 .input        = { {
656                         .type     = EM28XX_VMUX_TELEVISION,
657                         .vmux     = TVP5150_COMPOSITE0,
658                         .amux     = EM28XX_AMUX_LINE_IN,
659                         .gpio     = pinnacle_hybrid_pro_analog,
660                 }, {
661                         .type     = EM28XX_VMUX_COMPOSITE1,
662                         .vmux     = TVP5150_COMPOSITE1,
663                         .amux     = EM28XX_AMUX_LINE_IN,
664                         .gpio     = pinnacle_hybrid_pro_analog,
665                 }, {
666                         .type     = EM28XX_VMUX_SVIDEO,
667                         .vmux     = TVP5150_SVIDEO,
668                         .amux     = EM28XX_AMUX_LINE_IN,
669                         .gpio     = pinnacle_hybrid_pro_analog,
670                 } },
671         },
672
673         /* Those boards with em2870 are DVB Only*/
674
675         [EM2870_BOARD_TERRATEC_XS] = {
676                 .name         = "Terratec Cinergy T XS",
677                 .valid        = EM28XX_BOARD_NOT_VALIDATED,
678                 .tuner_type   = TUNER_XC2028,
679                 .tuner_gpio   = default_tuner_gpio,
680         },
681         [EM2870_BOARD_TERRATEC_XS_MT2060] = {
682                 .name         = "Terratec Cinergy T XS (MT2060)",
683                 .valid        = EM28XX_BOARD_NOT_VALIDATED,
684                 .tuner_type   = TUNER_ABSENT, /* MT2060 */
685         },
686         [EM2870_BOARD_KWORLD_350U] = {
687                 .name         = "Kworld 350 U DVB-T",
688                 .valid        = EM28XX_BOARD_NOT_VALIDATED,
689                 .tuner_type   = TUNER_XC2028,
690                 .tuner_gpio   = default_tuner_gpio,
691         },
692         [EM2870_BOARD_KWORLD_355U] = {
693                 .name         = "Kworld 355 U DVB-T",
694                 .valid        = EM28XX_BOARD_NOT_VALIDATED,
695         },
696         [EM2870_BOARD_PINNACLE_PCTV_DVB] = {
697                 .name         = "Pinnacle PCTV DVB-T",
698                 .valid        = EM28XX_BOARD_NOT_VALIDATED,
699                 .tuner_type   = TUNER_ABSENT, /* MT2060 */
700                 /* djh - I have serious doubts this is right... */
701                 .xclk         = EM28XX_XCLK_IR_RC5_MODE |
702                                 EM28XX_XCLK_FREQUENCY_10MHZ,
703         },
704         [EM2870_BOARD_COMPRO_VIDEOMATE] = {
705                 .name         = "Compro, VideoMate U3",
706                 .valid        = EM28XX_BOARD_NOT_VALIDATED,
707                 .tuner_type   = TUNER_ABSENT, /* MT2060 */
708         },
709
710         [EM2880_BOARD_TERRATEC_HYBRID_XS_FR] = {
711                 .name         = "Terratec Hybrid XS Secam",
712                 .valid        = EM28XX_BOARD_NOT_VALIDATED,
713                 .has_msp34xx  = 1,
714                 .tuner_type   = TUNER_XC2028,
715                 .tuner_gpio   = default_tuner_gpio,
716                 .decoder      = EM28XX_TVP5150,
717                 .input        = { {
718                         .type     = EM28XX_VMUX_TELEVISION,
719                         .vmux     = TVP5150_COMPOSITE0,
720                         .amux     = EM28XX_AMUX_VIDEO,
721                         .gpio     = default_analog,
722                 }, {
723                         .type     = EM28XX_VMUX_COMPOSITE1,
724                         .vmux     = TVP5150_COMPOSITE1,
725                         .amux     = EM28XX_AMUX_LINE_IN,
726                         .gpio     = default_analog,
727                 }, {
728                         .type     = EM28XX_VMUX_SVIDEO,
729                         .vmux     = TVP5150_SVIDEO,
730                         .amux     = EM28XX_AMUX_LINE_IN,
731                         .gpio     = default_analog,
732                 } },
733         },
734         [EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900] = {
735                 .name         = "Hauppauge WinTV HVR 900",
736                 .tda9887_conf = TDA9887_PRESENT,
737                 .tuner_type   = TUNER_XC2028,
738                 .tuner_gpio   = default_tuner_gpio,
739                 .mts_firmware = 1,
740                 .has_dvb      = 1,
741                 .dvb_gpio     = hauppauge_wintv_hvr_900_digital,
742                 .ir_codes     = &ir_codes_hauppauge_new_table,
743                 .decoder      = EM28XX_TVP5150,
744                 .input        = { {
745                         .type     = EM28XX_VMUX_TELEVISION,
746                         .vmux     = TVP5150_COMPOSITE0,
747                         .amux     = EM28XX_AMUX_VIDEO,
748                         .gpio     = hauppauge_wintv_hvr_900_analog,
749                 }, {
750                         .type     = EM28XX_VMUX_COMPOSITE1,
751                         .vmux     = TVP5150_COMPOSITE1,
752                         .amux     = EM28XX_AMUX_LINE_IN,
753                         .gpio     = hauppauge_wintv_hvr_900_analog,
754                 }, {
755                         .type     = EM28XX_VMUX_SVIDEO,
756                         .vmux     = TVP5150_SVIDEO,
757                         .amux     = EM28XX_AMUX_LINE_IN,
758                         .gpio     = hauppauge_wintv_hvr_900_analog,
759                 } },
760         },
761         [EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900_R2] = {
762                 .name         = "Hauppauge WinTV HVR 900 (R2)",
763                 .tda9887_conf = TDA9887_PRESENT,
764                 .tuner_type   = TUNER_XC2028,
765                 .tuner_gpio   = default_tuner_gpio,
766                 .mts_firmware = 1,
767                 .ir_codes     = &ir_codes_hauppauge_new_table,
768                 .decoder      = EM28XX_TVP5150,
769                 .input        = { {
770                         .type     = EM28XX_VMUX_TELEVISION,
771                         .vmux     = TVP5150_COMPOSITE0,
772                         .amux     = EM28XX_AMUX_VIDEO,
773                         .gpio     = hauppauge_wintv_hvr_900_analog,
774                 }, {
775                         .type     = EM28XX_VMUX_COMPOSITE1,
776                         .vmux     = TVP5150_COMPOSITE1,
777                         .amux     = EM28XX_AMUX_LINE_IN,
778                         .gpio     = hauppauge_wintv_hvr_900_analog,
779                 }, {
780                         .type     = EM28XX_VMUX_SVIDEO,
781                         .vmux     = TVP5150_SVIDEO,
782                         .amux     = EM28XX_AMUX_LINE_IN,
783                         .gpio     = hauppauge_wintv_hvr_900_analog,
784                 } },
785         },
786         [EM2883_BOARD_HAUPPAUGE_WINTV_HVR_850] = {
787                 .name           = "Hauppauge WinTV HVR 850",
788                 .tuner_type     = TUNER_XC2028,
789                 .tuner_gpio     = default_tuner_gpio,
790                 .mts_firmware   = 1,
791                 .has_dvb        = 1,
792                 .dvb_gpio       = hauppauge_wintv_hvr_900_digital,
793                 .ir_codes       = &ir_codes_hauppauge_new_table,
794                 .decoder        = EM28XX_TVP5150,
795                 .input          = { {
796                         .type     = EM28XX_VMUX_TELEVISION,
797                         .vmux     = TVP5150_COMPOSITE0,
798                         .amux     = EM28XX_AMUX_VIDEO,
799                         .gpio     = hauppauge_wintv_hvr_900_analog,
800                 }, {
801                         .type     = EM28XX_VMUX_COMPOSITE1,
802                         .vmux     = TVP5150_COMPOSITE1,
803                         .amux     = EM28XX_AMUX_LINE_IN,
804                         .gpio     = hauppauge_wintv_hvr_900_analog,
805                 }, {
806                         .type     = EM28XX_VMUX_SVIDEO,
807                         .vmux     = TVP5150_SVIDEO,
808                         .amux     = EM28XX_AMUX_LINE_IN,
809                         .gpio     = hauppauge_wintv_hvr_900_analog,
810                 } },
811         },
812         [EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950] = {
813                 .name           = "Hauppauge WinTV HVR 950",
814                 .tuner_type     = TUNER_XC2028,
815                 .tuner_gpio     = default_tuner_gpio,
816                 .mts_firmware   = 1,
817                 .has_dvb        = 1,
818                 .dvb_gpio       = hauppauge_wintv_hvr_900_digital,
819                 .ir_codes       = &ir_codes_hauppauge_new_table,
820                 .decoder        = EM28XX_TVP5150,
821                 .input          = { {
822                         .type     = EM28XX_VMUX_TELEVISION,
823                         .vmux     = TVP5150_COMPOSITE0,
824                         .amux     = EM28XX_AMUX_VIDEO,
825                         .gpio     = hauppauge_wintv_hvr_900_analog,
826                 }, {
827                         .type     = EM28XX_VMUX_COMPOSITE1,
828                         .vmux     = TVP5150_COMPOSITE1,
829                         .amux     = EM28XX_AMUX_LINE_IN,
830                         .gpio     = hauppauge_wintv_hvr_900_analog,
831                 }, {
832                         .type     = EM28XX_VMUX_SVIDEO,
833                         .vmux     = TVP5150_SVIDEO,
834                         .amux     = EM28XX_AMUX_LINE_IN,
835                         .gpio     = hauppauge_wintv_hvr_900_analog,
836                 } },
837         },
838         [EM2880_BOARD_PINNACLE_PCTV_HD_PRO] = {
839                 .name           = "Pinnacle PCTV HD Pro Stick",
840                 .tuner_type     = TUNER_XC2028,
841                 .tuner_gpio   = default_tuner_gpio,
842                 .mts_firmware   = 1,
843                 .has_dvb        = 1,
844                 .dvb_gpio       = hauppauge_wintv_hvr_900_digital,
845                 .ir_codes       = &ir_codes_pinnacle_pctv_hd_table,
846                 .decoder        = EM28XX_TVP5150,
847                 .input          = { {
848                         .type     = EM28XX_VMUX_TELEVISION,
849                         .vmux     = TVP5150_COMPOSITE0,
850                         .amux     = EM28XX_AMUX_VIDEO,
851                         .gpio     = hauppauge_wintv_hvr_900_analog,
852                 }, {
853                         .type     = EM28XX_VMUX_COMPOSITE1,
854                         .vmux     = TVP5150_COMPOSITE1,
855                         .amux     = EM28XX_AMUX_LINE_IN,
856                         .gpio     = hauppauge_wintv_hvr_900_analog,
857                 }, {
858                         .type     = EM28XX_VMUX_SVIDEO,
859                         .vmux     = TVP5150_SVIDEO,
860                         .amux     = EM28XX_AMUX_LINE_IN,
861                         .gpio     = hauppauge_wintv_hvr_900_analog,
862                 } },
863         },
864         [EM2880_BOARD_AMD_ATI_TV_WONDER_HD_600] = {
865                 .name           = "AMD ATI TV Wonder HD 600",
866                 .tuner_type     = TUNER_XC2028,
867                 .tuner_gpio     = default_tuner_gpio,
868                 .mts_firmware   = 1,
869                 .has_dvb        = 1,
870                 .dvb_gpio       = hauppauge_wintv_hvr_900_digital,
871                 .ir_codes       = &ir_codes_ati_tv_wonder_hd_600_table,
872                 .decoder        = EM28XX_TVP5150,
873                 .input          = { {
874                         .type     = EM28XX_VMUX_TELEVISION,
875                         .vmux     = TVP5150_COMPOSITE0,
876                         .amux     = EM28XX_AMUX_VIDEO,
877                         .gpio     = hauppauge_wintv_hvr_900_analog,
878                 }, {
879                         .type     = EM28XX_VMUX_COMPOSITE1,
880                         .vmux     = TVP5150_COMPOSITE1,
881                         .amux     = EM28XX_AMUX_LINE_IN,
882                         .gpio     = hauppauge_wintv_hvr_900_analog,
883                 }, {
884                         .type     = EM28XX_VMUX_SVIDEO,
885                         .vmux     = TVP5150_SVIDEO,
886                         .amux     = EM28XX_AMUX_LINE_IN,
887                         .gpio     = hauppauge_wintv_hvr_900_analog,
888                 } },
889         },
890         [EM2880_BOARD_TERRATEC_HYBRID_XS] = {
891                 .name           = "Terratec Hybrid XS",
892                 .tuner_type     = TUNER_XC2028,
893                 .tuner_gpio     = default_tuner_gpio,
894                 .decoder        = EM28XX_TVP5150,
895                 .has_dvb        = 1,
896                 .dvb_gpio       = default_digital,
897                 .ir_codes       = &ir_codes_terratec_cinergy_xs_table,
898                 .xclk           = EM28XX_XCLK_FREQUENCY_12MHZ, /* NEC IR */
899                 .input          = { {
900                         .type     = EM28XX_VMUX_TELEVISION,
901                         .vmux     = TVP5150_COMPOSITE0,
902                         .amux     = EM28XX_AMUX_VIDEO,
903                         .gpio     = default_analog,
904                 }, {
905                         .type     = EM28XX_VMUX_COMPOSITE1,
906                         .vmux     = TVP5150_COMPOSITE1,
907                         .amux     = EM28XX_AMUX_LINE_IN,
908                         .gpio     = default_analog,
909                 }, {
910                         .type     = EM28XX_VMUX_SVIDEO,
911                         .vmux     = TVP5150_SVIDEO,
912                         .amux     = EM28XX_AMUX_LINE_IN,
913                         .gpio     = default_analog,
914                 } },
915         },
916         /* maybe there's a reason behind it why Terratec sells the Hybrid XS
917            as Prodigy XS with a different PID, let's keep it separated for now
918            maybe we'll need it lateron */
919         [EM2880_BOARD_TERRATEC_PRODIGY_XS] = {
920                 .name         = "Terratec Prodigy XS",
921                 .tuner_type   = TUNER_XC2028,
922                 .tuner_gpio   = default_tuner_gpio,
923                 .decoder      = EM28XX_TVP5150,
924                 .input        = { {
925                         .type     = EM28XX_VMUX_TELEVISION,
926                         .vmux     = TVP5150_COMPOSITE0,
927                         .amux     = EM28XX_AMUX_VIDEO,
928                         .gpio     = hauppauge_wintv_hvr_900_analog,
929                 }, {
930                         .type     = EM28XX_VMUX_COMPOSITE1,
931                         .vmux     = TVP5150_COMPOSITE1,
932                         .amux     = EM28XX_AMUX_LINE_IN,
933                         .gpio     = hauppauge_wintv_hvr_900_analog,
934                 }, {
935                         .type     = EM28XX_VMUX_SVIDEO,
936                         .vmux     = TVP5150_SVIDEO,
937                         .amux     = EM28XX_AMUX_LINE_IN,
938                         .gpio     = hauppauge_wintv_hvr_900_analog,
939                 } },
940         },
941         [EM2820_BOARD_MSI_VOX_USB_2] = {
942                 .name              = "MSI VOX USB 2.0",
943                 .tuner_type        = TUNER_LG_PAL_NEW_TAPC,
944                 .tda9887_conf      = TDA9887_PRESENT      |
945                                      TDA9887_PORT1_ACTIVE |
946                                      TDA9887_PORT2_ACTIVE,
947                 .max_range_640_480 = 1,
948                 .decoder           = EM28XX_SAA711X,
949                 .input             = { {
950                         .type      = EM28XX_VMUX_TELEVISION,
951                         .vmux      = SAA7115_COMPOSITE4,
952                         .amux      = EM28XX_AMUX_VIDEO,
953                 }, {
954                         .type      = EM28XX_VMUX_COMPOSITE1,
955                         .vmux      = SAA7115_COMPOSITE0,
956                         .amux      = EM28XX_AMUX_LINE_IN,
957                 }, {
958                         .type      = EM28XX_VMUX_SVIDEO,
959                         .vmux      = SAA7115_SVIDEO3,
960                         .amux      = EM28XX_AMUX_LINE_IN,
961                 } },
962         },
963         [EM2800_BOARD_TERRATEC_CINERGY_200] = {
964                 .name         = "Terratec Cinergy 200 USB",
965                 .is_em2800    = 1,
966                 .has_ir_i2c   = 1,
967                 .tuner_type   = TUNER_LG_PAL_NEW_TAPC,
968                 .tda9887_conf = TDA9887_PRESENT,
969                 .decoder      = EM28XX_SAA711X,
970                 .input        = { {
971                         .type     = EM28XX_VMUX_TELEVISION,
972                         .vmux     = SAA7115_COMPOSITE2,
973                         .amux     = EM28XX_AMUX_VIDEO,
974                 }, {
975                         .type     = EM28XX_VMUX_COMPOSITE1,
976                         .vmux     = SAA7115_COMPOSITE0,
977                         .amux     = EM28XX_AMUX_LINE_IN,
978                 }, {
979                         .type     = EM28XX_VMUX_SVIDEO,
980                         .vmux     = SAA7115_SVIDEO3,
981                         .amux     = EM28XX_AMUX_LINE_IN,
982                 } },
983         },
984         [EM2800_BOARD_GRABBEEX_USB2800] = {
985                 .name       = "eMPIA Technology, Inc. GrabBeeX+ Video Encoder",
986                 .is_em2800  = 1,
987                 .decoder    = EM28XX_SAA711X,
988                 .tuner_type = TUNER_ABSENT, /* capture only board */
989                 .input      = { {
990                         .type     = EM28XX_VMUX_COMPOSITE1,
991                         .vmux     = SAA7115_COMPOSITE0,
992                         .amux     = EM28XX_AMUX_LINE_IN,
993                 }, {
994                         .type     = EM28XX_VMUX_SVIDEO,
995                         .vmux     = SAA7115_SVIDEO3,
996                         .amux     = EM28XX_AMUX_LINE_IN,
997                 } },
998         },
999         [EM2800_BOARD_LEADTEK_WINFAST_USBII] = {
1000                 .name         = "Leadtek Winfast USB II",
1001                 .is_em2800    = 1,
1002                 .tuner_type   = TUNER_LG_PAL_NEW_TAPC,
1003                 .tda9887_conf = TDA9887_PRESENT,
1004                 .decoder      = EM28XX_SAA711X,
1005                 .input        = { {
1006                         .type     = EM28XX_VMUX_TELEVISION,
1007                         .vmux     = SAA7115_COMPOSITE2,
1008                         .amux     = EM28XX_AMUX_VIDEO,
1009                 }, {
1010                         .type     = EM28XX_VMUX_COMPOSITE1,
1011                         .vmux     = SAA7115_COMPOSITE0,
1012                         .amux     = EM28XX_AMUX_LINE_IN,
1013                 }, {
1014                         .type     = EM28XX_VMUX_SVIDEO,
1015                         .vmux     = SAA7115_SVIDEO3,
1016                         .amux     = EM28XX_AMUX_LINE_IN,
1017                 } },
1018         },
1019         [EM2800_BOARD_KWORLD_USB2800] = {
1020                 .name         = "Kworld USB2800",
1021                 .is_em2800    = 1,
1022                 .tuner_type   = TUNER_PHILIPS_FCV1236D,
1023                 .tda9887_conf = TDA9887_PRESENT,
1024                 .decoder      = EM28XX_SAA711X,
1025                 .input        = { {
1026                         .type     = EM28XX_VMUX_TELEVISION,
1027                         .vmux     = SAA7115_COMPOSITE2,
1028                         .amux     = EM28XX_AMUX_VIDEO,
1029                 }, {
1030                         .type     = EM28XX_VMUX_COMPOSITE1,
1031                         .vmux     = SAA7115_COMPOSITE0,
1032                         .amux     = EM28XX_AMUX_LINE_IN,
1033                 }, {
1034                         .type     = EM28XX_VMUX_SVIDEO,
1035                         .vmux     = SAA7115_SVIDEO3,
1036                         .amux     = EM28XX_AMUX_LINE_IN,
1037                 } },
1038         },
1039         [EM2820_BOARD_PINNACLE_DVC_90] = {
1040                 .name         = "Pinnacle Dazzle DVC 90/100/101/107 / Kaiser Baas Video to DVD maker "
1041                                 "/ Kworld DVD Maker 2",
1042                 .tuner_type   = TUNER_ABSENT, /* capture only board */
1043                 .decoder      = EM28XX_SAA711X,
1044                 .input        = { {
1045                         .type     = EM28XX_VMUX_COMPOSITE1,
1046                         .vmux     = SAA7115_COMPOSITE0,
1047                         .amux     = EM28XX_AMUX_LINE_IN,
1048                 }, {
1049                         .type     = EM28XX_VMUX_SVIDEO,
1050                         .vmux     = SAA7115_SVIDEO3,
1051                         .amux     = EM28XX_AMUX_LINE_IN,
1052                 } },
1053         },
1054         [EM2800_BOARD_VGEAR_POCKETTV] = {
1055                 .name         = "V-Gear PocketTV",
1056                 .is_em2800    = 1,
1057                 .tuner_type   = TUNER_LG_PAL_NEW_TAPC,
1058                 .tda9887_conf = TDA9887_PRESENT,
1059                 .decoder      = EM28XX_SAA711X,
1060                 .input        = { {
1061                         .type     = EM28XX_VMUX_TELEVISION,
1062                         .vmux     = SAA7115_COMPOSITE2,
1063                         .amux     = EM28XX_AMUX_VIDEO,
1064                 }, {
1065                         .type     = EM28XX_VMUX_COMPOSITE1,
1066                         .vmux     = SAA7115_COMPOSITE0,
1067                         .amux     = EM28XX_AMUX_LINE_IN,
1068                 }, {
1069                         .type     = EM28XX_VMUX_SVIDEO,
1070                         .vmux     = SAA7115_SVIDEO3,
1071                         .amux     = EM28XX_AMUX_LINE_IN,
1072                 } },
1073         },
1074         [EM2820_BOARD_PROLINK_PLAYTV_BOX4_USB2] = {
1075                 .name         = "Pixelview PlayTV Box 4 USB 2.0",
1076                 .tda9887_conf = TDA9887_PRESENT,
1077                 .tuner_type   = TUNER_YMEC_TVF_5533MF,
1078                 .decoder      = EM28XX_SAA711X,
1079                 .input        = { {
1080                         .type     = EM28XX_VMUX_TELEVISION,
1081                         .vmux     = SAA7115_COMPOSITE2,
1082                         .amux     = EM28XX_AMUX_VIDEO,
1083                         .aout     = EM28XX_AOUT_MONO |  /* I2S */
1084                                     EM28XX_AOUT_MASTER, /* Line out pin */
1085                 }, {
1086                         .type     = EM28XX_VMUX_COMPOSITE1,
1087                         .vmux     = SAA7115_COMPOSITE0,
1088                         .amux     = EM28XX_AMUX_LINE_IN,
1089                 }, {
1090                         .type     = EM28XX_VMUX_SVIDEO,
1091                         .vmux     = SAA7115_SVIDEO3,
1092                         .amux     = EM28XX_AMUX_LINE_IN,
1093                 } },
1094         },
1095         [EM2820_BOARD_PROLINK_PLAYTV_USB2] = {
1096                 .name         = "SIIG AVTuner-PVR / Pixelview Prolink PlayTV USB 2.0",
1097                 .has_snapshot_button = 1,
1098                 .tda9887_conf = TDA9887_PRESENT,
1099                 .tuner_type   = TUNER_YMEC_TVF_5533MF,
1100                 .decoder      = EM28XX_SAA711X,
1101                 .input        = { {
1102                         .type     = EM28XX_VMUX_TELEVISION,
1103                         .vmux     = SAA7115_COMPOSITE2,
1104                         .amux     = EM28XX_AMUX_VIDEO,
1105                         .aout     = EM28XX_AOUT_MONO |  /* I2S */
1106                                     EM28XX_AOUT_MASTER, /* Line out pin */
1107                 }, {
1108                         .type     = EM28XX_VMUX_COMPOSITE1,
1109                         .vmux     = SAA7115_COMPOSITE0,
1110                         .amux     = EM28XX_AMUX_LINE_IN,
1111                 }, {
1112                         .type     = EM28XX_VMUX_SVIDEO,
1113                         .vmux     = SAA7115_SVIDEO3,
1114                         .amux     = EM28XX_AMUX_LINE_IN,
1115                 } },
1116         },
1117         [EM2860_BOARD_SAA711X_REFERENCE_DESIGN] = {
1118                 .name                = "EM2860/SAA711X Reference Design",
1119                 .has_snapshot_button = 1,
1120                 .tuner_type          = TUNER_ABSENT,
1121                 .decoder             = EM28XX_SAA711X,
1122                 .input               = { {
1123                         .type     = EM28XX_VMUX_SVIDEO,
1124                         .vmux     = SAA7115_SVIDEO3,
1125                 }, {
1126                         .type     = EM28XX_VMUX_COMPOSITE1,
1127                         .vmux     = SAA7115_COMPOSITE0,
1128                 } },
1129         },
1130         [EM2880_BOARD_MSI_DIGIVOX_AD] = {
1131                 .name         = "MSI DigiVox A/D",
1132                 .valid        = EM28XX_BOARD_NOT_VALIDATED,
1133                 .tuner_type   = TUNER_XC2028,
1134                 .tuner_gpio   = default_tuner_gpio,
1135                 .decoder      = EM28XX_TVP5150,
1136                 .input        = { {
1137                         .type     = EM28XX_VMUX_TELEVISION,
1138                         .vmux     = TVP5150_COMPOSITE0,
1139                         .amux     = EM28XX_AMUX_VIDEO,
1140                         .gpio     = em2880_msi_digivox_ad_analog,
1141                 }, {
1142                         .type     = EM28XX_VMUX_COMPOSITE1,
1143                         .vmux     = TVP5150_COMPOSITE1,
1144                         .amux     = EM28XX_AMUX_LINE_IN,
1145                         .gpio     = em2880_msi_digivox_ad_analog,
1146                 }, {
1147                         .type     = EM28XX_VMUX_SVIDEO,
1148                         .vmux     = TVP5150_SVIDEO,
1149                         .amux     = EM28XX_AMUX_LINE_IN,
1150                         .gpio     = em2880_msi_digivox_ad_analog,
1151                 } },
1152         },
1153         [EM2880_BOARD_MSI_DIGIVOX_AD_II] = {
1154                 .name         = "MSI DigiVox A/D II",
1155                 .valid        = EM28XX_BOARD_NOT_VALIDATED,
1156                 .tuner_type   = TUNER_XC2028,
1157                 .tuner_gpio   = default_tuner_gpio,
1158                 .decoder      = EM28XX_TVP5150,
1159                 .input        = { {
1160                         .type     = EM28XX_VMUX_TELEVISION,
1161                         .vmux     = TVP5150_COMPOSITE0,
1162                         .amux     = EM28XX_AMUX_VIDEO,
1163                         .gpio     = em2880_msi_digivox_ad_analog,
1164                 }, {
1165                         .type     = EM28XX_VMUX_COMPOSITE1,
1166                         .vmux     = TVP5150_COMPOSITE1,
1167                         .amux     = EM28XX_AMUX_LINE_IN,
1168                         .gpio     = em2880_msi_digivox_ad_analog,
1169                 }, {
1170                         .type     = EM28XX_VMUX_SVIDEO,
1171                         .vmux     = TVP5150_SVIDEO,
1172                         .amux     = EM28XX_AMUX_LINE_IN,
1173                         .gpio     = em2880_msi_digivox_ad_analog,
1174                 } },
1175         },
1176         [EM2880_BOARD_KWORLD_DVB_305U] = {
1177                 .name         = "KWorld DVB-T 305U",
1178                 .valid        = EM28XX_BOARD_NOT_VALIDATED,
1179                 .tuner_type   = TUNER_XC2028,
1180                 .tuner_gpio   = default_tuner_gpio,
1181                 .decoder      = EM28XX_TVP5150,
1182                 .input        = { {
1183                         .type     = EM28XX_VMUX_TELEVISION,
1184                         .vmux     = TVP5150_COMPOSITE0,
1185                         .amux     = EM28XX_AMUX_VIDEO,
1186                 }, {
1187                         .type     = EM28XX_VMUX_COMPOSITE1,
1188                         .vmux     = TVP5150_COMPOSITE1,
1189                         .amux     = EM28XX_AMUX_LINE_IN,
1190                 }, {
1191                         .type     = EM28XX_VMUX_SVIDEO,
1192                         .vmux     = TVP5150_SVIDEO,
1193                         .amux     = EM28XX_AMUX_LINE_IN,
1194                 } },
1195         },
1196         [EM2880_BOARD_KWORLD_DVB_310U] = {
1197                 .name         = "KWorld DVB-T 310U",
1198                 .tuner_type   = TUNER_XC2028,
1199                 .tuner_gpio   = default_tuner_gpio,
1200                 .has_dvb      = 1,
1201                 .dvb_gpio     = default_digital,
1202                 .mts_firmware = 1,
1203                 .decoder      = EM28XX_TVP5150,
1204                 .input        = { {
1205                         .type     = EM28XX_VMUX_TELEVISION,
1206                         .vmux     = TVP5150_COMPOSITE0,
1207                         .amux     = EM28XX_AMUX_VIDEO,
1208                         .gpio     = default_analog,
1209                 }, {
1210                         .type     = EM28XX_VMUX_COMPOSITE1,
1211                         .vmux     = TVP5150_COMPOSITE1,
1212                         .amux     = EM28XX_AMUX_LINE_IN,
1213                         .gpio     = default_analog,
1214                 }, {    /* S-video has not been tested yet */
1215                         .type     = EM28XX_VMUX_SVIDEO,
1216                         .vmux     = TVP5150_SVIDEO,
1217                         .amux     = EM28XX_AMUX_LINE_IN,
1218                         .gpio     = default_analog,
1219                 } },
1220         },
1221         [EM2882_BOARD_KWORLD_ATSC_315U] = {
1222                 .name           = "KWorld ATSC 315U HDTV TV Box",
1223                 .valid          = EM28XX_BOARD_NOT_VALIDATED,
1224                 .tuner_type     = TUNER_THOMSON_DTT761X,
1225                 .tuner_gpio     = em2882_kworld_315u_tuner_gpio,
1226                 .tda9887_conf   = TDA9887_PRESENT,
1227                 .decoder        = EM28XX_SAA711X,
1228                 .has_dvb        = 1,
1229                 .dvb_gpio       = em2882_kworld_315u_digital,
1230                 .xclk           = EM28XX_XCLK_FREQUENCY_12MHZ,
1231                 .i2c_speed      = EM28XX_I2C_CLK_WAIT_ENABLE,
1232                 /* Analog mode - still not ready */
1233                 /*.input        = { {
1234                         .type = EM28XX_VMUX_TELEVISION,
1235                         .vmux = SAA7115_COMPOSITE2,
1236                         .amux = EM28XX_AMUX_VIDEO,
1237                         .gpio = em2882_kworld_315u_analog,
1238                         .aout = EM28XX_AOUT_PCM_IN | EM28XX_AOUT_PCM_STEREO,
1239                 }, {
1240                         .type = EM28XX_VMUX_COMPOSITE1,
1241                         .vmux = SAA7115_COMPOSITE0,
1242                         .amux = EM28XX_AMUX_LINE_IN,
1243                         .gpio = em2882_kworld_315u_analog1,
1244                         .aout = EM28XX_AOUT_PCM_IN | EM28XX_AOUT_PCM_STEREO,
1245                 }, {
1246                         .type = EM28XX_VMUX_SVIDEO,
1247                         .vmux = SAA7115_SVIDEO3,
1248                         .amux = EM28XX_AMUX_LINE_IN,
1249                         .gpio = em2882_kworld_315u_analog1,
1250                         .aout = EM28XX_AOUT_PCM_IN | EM28XX_AOUT_PCM_STEREO,
1251                 } }, */
1252         },
1253         [EM2880_BOARD_EMPIRE_DUAL_TV] = {
1254                 .name = "Empire dual TV",
1255                 .tuner_type = TUNER_XC2028,
1256                 .tuner_gpio = default_tuner_gpio,
1257                 .has_dvb = 1,
1258                 .dvb_gpio = default_digital,
1259                 .mts_firmware = 1,
1260                 .decoder = EM28XX_TVP5150,
1261                 .input = { {
1262                         .type = EM28XX_VMUX_TELEVISION,
1263                         .vmux = TVP5150_COMPOSITE0,
1264                         .amux = EM28XX_AMUX_VIDEO,
1265                         .gpio = default_analog,
1266                 }, {
1267                         .type = EM28XX_VMUX_COMPOSITE1,
1268                         .vmux = TVP5150_COMPOSITE1,
1269                         .amux = EM28XX_AMUX_LINE_IN,
1270                         .gpio = default_analog,
1271                 }, {
1272                         .type = EM28XX_VMUX_SVIDEO,
1273                         .vmux = TVP5150_SVIDEO,
1274                         .amux = EM28XX_AMUX_LINE_IN,
1275                         .gpio = default_analog,
1276                 } },
1277         },
1278         [EM2881_BOARD_DNT_DA2_HYBRID] = {
1279                 .name         = "DNT DA2 Hybrid",
1280                 .valid        = EM28XX_BOARD_NOT_VALIDATED,
1281                 .tuner_type   = TUNER_XC2028,
1282                 .tuner_gpio   = default_tuner_gpio,
1283                 .decoder      = EM28XX_TVP5150,
1284                 .input        = { {
1285                         .type     = EM28XX_VMUX_TELEVISION,
1286                         .vmux     = TVP5150_COMPOSITE0,
1287                         .amux     = EM28XX_AMUX_VIDEO,
1288                         .gpio     = default_analog,
1289                 }, {
1290                         .type     = EM28XX_VMUX_COMPOSITE1,
1291                         .vmux     = TVP5150_COMPOSITE1,
1292                         .amux     = EM28XX_AMUX_LINE_IN,
1293                         .gpio     = default_analog,
1294                 }, {
1295                         .type     = EM28XX_VMUX_SVIDEO,
1296                         .vmux     = TVP5150_SVIDEO,
1297                         .amux     = EM28XX_AMUX_LINE_IN,
1298                         .gpio     = default_analog,
1299                 } },
1300         },
1301         [EM2881_BOARD_PINNACLE_HYBRID_PRO] = {
1302                 .name         = "Pinnacle Hybrid Pro",
1303                 .tuner_type   = TUNER_XC2028,
1304                 .tuner_gpio   = default_tuner_gpio,
1305                 .decoder      = EM28XX_TVP5150,
1306                 .has_dvb      = 1,
1307                 .dvb_gpio     = pinnacle_hybrid_pro_digital,
1308                 .input        = { {
1309                         .type     = EM28XX_VMUX_TELEVISION,
1310                         .vmux     = TVP5150_COMPOSITE0,
1311                         .amux     = EM28XX_AMUX_VIDEO,
1312                         .gpio     = pinnacle_hybrid_pro_analog,
1313                 }, {
1314                         .type     = EM28XX_VMUX_COMPOSITE1,
1315                         .vmux     = TVP5150_COMPOSITE1,
1316                         .amux     = EM28XX_AMUX_LINE_IN,
1317                         .gpio     = pinnacle_hybrid_pro_analog,
1318                 }, {
1319                         .type     = EM28XX_VMUX_SVIDEO,
1320                         .vmux     = TVP5150_SVIDEO,
1321                         .amux     = EM28XX_AMUX_LINE_IN,
1322                         .gpio     = pinnacle_hybrid_pro_analog,
1323                 } },
1324         },
1325         [EM2882_BOARD_PINNACLE_HYBRID_PRO] = {
1326                 .name         = "Pinnacle Hybrid Pro (2)",
1327                 .valid        = EM28XX_BOARD_NOT_VALIDATED,
1328                 .tuner_type   = TUNER_XC2028,
1329                 .tuner_gpio   = default_tuner_gpio,
1330                 .mts_firmware = 1,
1331                 .decoder      = EM28XX_TVP5150,
1332                 .input        = { {
1333                         .type     = EM28XX_VMUX_TELEVISION,
1334                         .vmux     = TVP5150_COMPOSITE0,
1335                         .amux     = EM28XX_AMUX_VIDEO,
1336                         .gpio     = hauppauge_wintv_hvr_900_analog,
1337                 }, {
1338                         .type     = EM28XX_VMUX_COMPOSITE1,
1339                         .vmux     = TVP5150_COMPOSITE1,
1340                         .amux     = EM28XX_AMUX_LINE_IN,
1341                         .gpio     = hauppauge_wintv_hvr_900_analog,
1342                 }, {
1343                         .type     = EM28XX_VMUX_SVIDEO,
1344                         .vmux     = TVP5150_SVIDEO,
1345                         .amux     = EM28XX_AMUX_LINE_IN,
1346                         .gpio     = hauppauge_wintv_hvr_900_analog,
1347                 } },
1348         },
1349         [EM2882_BOARD_KWORLD_VS_DVBT] = {
1350                 .name         = "Kworld VS-DVB-T 323UR",
1351                 .valid        = EM28XX_BOARD_NOT_VALIDATED,
1352                 .tuner_type   = TUNER_XC2028,
1353                 .tuner_gpio   = default_tuner_gpio,
1354                 .decoder      = EM28XX_TVP5150,
1355                 .input        = { {
1356                         .type     = EM28XX_VMUX_TELEVISION,
1357                         .vmux     = TVP5150_COMPOSITE0,
1358                         .amux     = EM28XX_AMUX_VIDEO,
1359                 }, {
1360                         .type     = EM28XX_VMUX_COMPOSITE1,
1361                         .vmux     = TVP5150_COMPOSITE1,
1362                         .amux     = EM28XX_AMUX_LINE_IN,
1363                 }, {
1364                         .type     = EM28XX_VMUX_SVIDEO,
1365                         .vmux     = TVP5150_SVIDEO,
1366                         .amux     = EM28XX_AMUX_LINE_IN,
1367                 } },
1368         },
1369         [EM2882_BOARD_TERRATEC_HYBRID_XS] = {
1370                 .name         = "Terratec Hybrid XS (em2882)",
1371                 .valid        = EM28XX_BOARD_NOT_VALIDATED,
1372                 .tuner_type   = TUNER_XC2028,
1373                 .tuner_gpio   = default_tuner_gpio,
1374                 .decoder      = EM28XX_TVP5150,
1375                 .input        = { {
1376                         .type     = EM28XX_VMUX_TELEVISION,
1377                         .vmux     = TVP5150_COMPOSITE0,
1378                         .amux     = EM28XX_AMUX_VIDEO,
1379                         .gpio     = hauppauge_wintv_hvr_900_analog,
1380                 }, {
1381                         .type     = EM28XX_VMUX_COMPOSITE1,
1382                         .vmux     = TVP5150_COMPOSITE1,
1383                         .amux     = EM28XX_AMUX_LINE_IN,
1384                         .gpio     = hauppauge_wintv_hvr_900_analog,
1385                 }, {
1386                         .type     = EM28XX_VMUX_SVIDEO,
1387                         .vmux     = TVP5150_SVIDEO,
1388                         .amux     = EM28XX_AMUX_LINE_IN,
1389                         .gpio     = hauppauge_wintv_hvr_900_analog,
1390                 } },
1391         },
1392         [EM2883_BOARD_KWORLD_HYBRID_330U] = {
1393                 .name         = "Kworld PlusTV HD Hybrid 330",
1394                 .tuner_type   = TUNER_XC2028,
1395                 .tuner_gpio   = default_tuner_gpio,
1396                 .decoder      = EM28XX_TVP5150,
1397                 .mts_firmware = 1,
1398                 .has_dvb      = 1,
1399                 .dvb_gpio     = kworld_330u_digital,
1400                 .xclk             = EM28XX_XCLK_FREQUENCY_12MHZ,
1401                 .i2c_speed        = EM28XX_I2C_CLK_WAIT_ENABLE |
1402                                     EM28XX_I2C_EEPROM_ON_BOARD |
1403                                     EM28XX_I2C_EEPROM_KEY_VALID,
1404                 .input        = { {
1405                         .type     = EM28XX_VMUX_TELEVISION,
1406                         .vmux     = TVP5150_COMPOSITE0,
1407                         .amux     = EM28XX_AMUX_VIDEO,
1408                         .gpio     = kworld_330u_analog,
1409                         .aout     = EM28XX_AOUT_PCM_IN | EM28XX_AOUT_PCM_STEREO,
1410                 }, {
1411                         .type     = EM28XX_VMUX_COMPOSITE1,
1412                         .vmux     = TVP5150_COMPOSITE1,
1413                         .amux     = EM28XX_AMUX_LINE_IN,
1414                         .gpio     = kworld_330u_analog,
1415                         .aout     = EM28XX_AOUT_PCM_IN | EM28XX_AOUT_PCM_STEREO,
1416                 }, {
1417                         .type     = EM28XX_VMUX_SVIDEO,
1418                         .vmux     = TVP5150_SVIDEO,
1419                         .amux     = EM28XX_AMUX_LINE_IN,
1420                         .gpio     = kworld_330u_analog,
1421                 } },
1422         },
1423         [EM2820_BOARD_COMPRO_VIDEOMATE_FORYOU] = {
1424                 .name         = "Compro VideoMate ForYou/Stereo",
1425                 .tuner_type   = TUNER_LG_PAL_NEW_TAPC,
1426                 .tvaudio_addr = 0xb0,
1427                 .tda9887_conf = TDA9887_PRESENT,
1428                 .decoder      = EM28XX_TVP5150,
1429                 .adecoder     = EM28XX_TVAUDIO,
1430                 .mute_gpio    = compro_mute_gpio,
1431                 .input        = { {
1432                         .type     = EM28XX_VMUX_TELEVISION,
1433                         .vmux     = TVP5150_COMPOSITE0,
1434                         .amux     = EM28XX_AMUX_VIDEO,
1435                         .gpio     = compro_unmute_tv_gpio,
1436                 }, {
1437                         .type     = EM28XX_VMUX_SVIDEO,
1438                         .vmux     = TVP5150_SVIDEO,
1439                         .amux     = EM28XX_AMUX_LINE_IN,
1440                         .gpio     = compro_unmute_svid_gpio,
1441                 } },
1442         },
1443         [EM2860_BOARD_KAIOMY_TVNPC_U2] = {
1444                 .name         = "Kaiomy TVnPC U2",
1445                 .vchannels    = 3,
1446                 .tuner_type   = TUNER_XC2028,
1447                 .tuner_addr   = 0x61,
1448                 .mts_firmware = 1,
1449                 .decoder      = EM28XX_TVP5150,
1450                 .tuner_gpio   = default_tuner_gpio,
1451                 .ir_codes     = &ir_codes_kaiomy_table,
1452                 .input          = { {
1453                         .type     = EM28XX_VMUX_TELEVISION,
1454                         .vmux     = TVP5150_COMPOSITE0,
1455                         .amux     = EM28XX_AMUX_VIDEO,
1456
1457                 }, {
1458                         .type     = EM28XX_VMUX_COMPOSITE1,
1459                         .vmux     = TVP5150_COMPOSITE1,
1460                         .amux     = EM28XX_AMUX_LINE_IN,
1461                 }, {
1462                         .type     = EM28XX_VMUX_SVIDEO,
1463                         .vmux     = TVP5150_SVIDEO,
1464                         .amux     = EM28XX_AMUX_LINE_IN,
1465                 } },
1466                 .radio          = {
1467                         .type     = EM28XX_RADIO,
1468                         .amux     = EM28XX_AMUX_LINE_IN,
1469                 }
1470         },
1471         [EM2860_BOARD_EASYCAP] = {
1472                 .name         = "Easy Cap Capture DC-60",
1473                 .vchannels    = 2,
1474                 .tuner_type   = TUNER_ABSENT,
1475                 .decoder      = EM28XX_SAA711X,
1476                 .input           = { {
1477                         .type     = EM28XX_VMUX_COMPOSITE1,
1478                         .vmux     = SAA7115_COMPOSITE0,
1479                         .amux     = EM28XX_AMUX_LINE_IN,
1480                 }, {
1481                         .type     = EM28XX_VMUX_SVIDEO,
1482                         .vmux     = SAA7115_SVIDEO3,
1483                         .amux     = EM28XX_AMUX_LINE_IN,
1484                 } },
1485         },
1486         [EM2820_BOARD_IODATA_GVMVP_SZ] = {
1487                 .name       = "IO-DATA GV-MVP/SZ",
1488                 .tuner_type   = TUNER_PHILIPS_FM1236_MK3,
1489                 .tuner_gpio   = default_tuner_gpio,
1490                 .tda9887_conf = TDA9887_PRESENT,
1491                 .decoder      = EM28XX_TVP5150,
1492                 .input        = { {
1493                         .type     = EM28XX_VMUX_TELEVISION,
1494                         .vmux     = TVP5150_COMPOSITE0,
1495                         .amux     = EM28XX_AMUX_VIDEO,
1496                 }, { /* Composite has not been tested yet */
1497                         .type     = EM28XX_VMUX_COMPOSITE1,
1498                         .vmux     = TVP5150_COMPOSITE1,
1499                         .amux     = EM28XX_AMUX_VIDEO,
1500                 }, { /* S-video has not been tested yet */
1501                         .type     = EM28XX_VMUX_SVIDEO,
1502                         .vmux     = TVP5150_SVIDEO,
1503                         .amux     = EM28XX_AMUX_VIDEO,
1504                 } },
1505         },
1506         [EM2860_BOARD_TERRATEC_GRABBY] = {
1507                 .name            = "Terratec Grabby",
1508                 .vchannels       = 2,
1509                 .tuner_type      = TUNER_ABSENT,
1510                 .decoder         = EM28XX_SAA711X,
1511                 .xclk            = EM28XX_XCLK_FREQUENCY_12MHZ,
1512                 .input           = { {
1513                         .type     = EM28XX_VMUX_COMPOSITE1,
1514                         .vmux     = SAA7115_COMPOSITE0,
1515                         .amux     = EM28XX_AMUX_VIDEO2,
1516                 }, {
1517                         .type     = EM28XX_VMUX_SVIDEO,
1518                         .vmux     = SAA7115_SVIDEO3,
1519                         .amux     = EM28XX_AMUX_VIDEO2,
1520                 } },
1521         },
1522         [EM2860_BOARD_TERRATEC_AV350] = {
1523                 .name            = "Terratec AV350",
1524                 .vchannels       = 2,
1525                 .tuner_type      = TUNER_ABSENT,
1526                 .decoder         = EM28XX_TVP5150,
1527                 .xclk            = EM28XX_XCLK_FREQUENCY_12MHZ,
1528                 .mute_gpio       = terratec_av350_mute_gpio,
1529                 .input           = { {
1530                         .type     = EM28XX_VMUX_COMPOSITE1,
1531                         .vmux     = TVP5150_COMPOSITE1,
1532                         .amux     = EM28XX_AUDIO_SRC_LINE,
1533                         .gpio     = terratec_av350_unmute_gpio,
1534
1535                 }, {
1536                         .type     = EM28XX_VMUX_SVIDEO,
1537                         .vmux     = TVP5150_SVIDEO,
1538                         .amux     = EM28XX_AUDIO_SRC_LINE,
1539                         .gpio     = terratec_av350_unmute_gpio,
1540                 } },
1541         },
1542         [EM2882_BOARD_EVGA_INDTUBE] = {
1543                 .name         = "Evga inDtube",
1544                 .tuner_type   = TUNER_XC2028,
1545                 .tuner_gpio   = default_tuner_gpio,
1546                 .decoder      = EM28XX_TVP5150,
1547                 .xclk         = EM28XX_XCLK_FREQUENCY_12MHZ, /* NEC IR */
1548                 .mts_firmware = 1,
1549                 .has_dvb      = 1,
1550                 .dvb_gpio     = evga_indtube_digital,
1551                 .ir_codes     = &ir_codes_evga_indtube_table,
1552                 .input        = { {
1553                         .type     = EM28XX_VMUX_TELEVISION,
1554                         .vmux     = TVP5150_COMPOSITE0,
1555                         .amux     = EM28XX_AMUX_VIDEO,
1556                         .gpio     = evga_indtube_analog,
1557                 }, {
1558                         .type     = EM28XX_VMUX_COMPOSITE1,
1559                         .vmux     = TVP5150_COMPOSITE1,
1560                         .amux     = EM28XX_AMUX_LINE_IN,
1561                         .gpio     = evga_indtube_analog,
1562                 }, {
1563                         .type     = EM28XX_VMUX_SVIDEO,
1564                         .vmux     = TVP5150_SVIDEO,
1565                         .amux     = EM28XX_AMUX_LINE_IN,
1566                         .gpio     = evga_indtube_analog,
1567                 } },
1568         },
1569 };
1570 const unsigned int em28xx_bcount = ARRAY_SIZE(em28xx_boards);
1571
1572 /* table of devices that work with this driver */
1573 struct usb_device_id em28xx_id_table[] = {
1574         { USB_DEVICE(0xeb1a, 0x2750),
1575                         .driver_info = EM2750_BOARD_UNKNOWN },
1576         { USB_DEVICE(0xeb1a, 0x2751),
1577                         .driver_info = EM2750_BOARD_UNKNOWN },
1578         { USB_DEVICE(0xeb1a, 0x2800),
1579                         .driver_info = EM2800_BOARD_UNKNOWN },
1580         { USB_DEVICE(0xeb1a, 0x2710),
1581                         .driver_info = EM2820_BOARD_UNKNOWN },
1582         { USB_DEVICE(0xeb1a, 0x2820),
1583                         .driver_info = EM2820_BOARD_UNKNOWN },
1584         { USB_DEVICE(0xeb1a, 0x2821),
1585                         .driver_info = EM2820_BOARD_UNKNOWN },
1586         { USB_DEVICE(0xeb1a, 0x2860),
1587                         .driver_info = EM2820_BOARD_UNKNOWN },
1588         { USB_DEVICE(0xeb1a, 0x2861),
1589                         .driver_info = EM2820_BOARD_UNKNOWN },
1590         { USB_DEVICE(0xeb1a, 0x2870),
1591                         .driver_info = EM2820_BOARD_UNKNOWN },
1592         { USB_DEVICE(0xeb1a, 0x2881),
1593                         .driver_info = EM2820_BOARD_UNKNOWN },
1594         { USB_DEVICE(0xeb1a, 0x2883),
1595                         .driver_info = EM2820_BOARD_UNKNOWN },
1596         { USB_DEVICE(0xeb1a, 0xe300),
1597                         .driver_info = EM2861_BOARD_KWORLD_PVRTV_300U },
1598         { USB_DEVICE(0xeb1a, 0xe303),
1599                         .driver_info = EM2860_BOARD_KAIOMY_TVNPC_U2 },
1600         { USB_DEVICE(0xeb1a, 0xe305),
1601                         .driver_info = EM2880_BOARD_KWORLD_DVB_305U },
1602         { USB_DEVICE(0xeb1a, 0xe310),
1603                         .driver_info = EM2880_BOARD_MSI_DIGIVOX_AD },
1604         { USB_DEVICE(0xeb1a, 0xa313),
1605                 .driver_info = EM2882_BOARD_KWORLD_ATSC_315U },
1606         { USB_DEVICE(0xeb1a, 0xa316),
1607                         .driver_info = EM2883_BOARD_KWORLD_HYBRID_330U },
1608         { USB_DEVICE(0xeb1a, 0xe320),
1609                         .driver_info = EM2880_BOARD_MSI_DIGIVOX_AD_II },
1610         { USB_DEVICE(0xeb1a, 0xe323),
1611                         .driver_info = EM2882_BOARD_KWORLD_VS_DVBT },
1612         { USB_DEVICE(0xeb1a, 0xe350),
1613                         .driver_info = EM2870_BOARD_KWORLD_350U },
1614         { USB_DEVICE(0xeb1a, 0xe355),
1615                         .driver_info = EM2870_BOARD_KWORLD_355U },
1616         { USB_DEVICE(0xeb1a, 0x2801),
1617                         .driver_info = EM2800_BOARD_GRABBEEX_USB2800 },
1618         { USB_DEVICE(0xeb1a, 0xe357),
1619                         .driver_info = EM2870_BOARD_KWORLD_355U },
1620         { USB_DEVICE(0x1b80, 0xe302),
1621                         .driver_info = EM2820_BOARD_PINNACLE_DVC_90 }, /* Kaiser Baas Video to DVD maker */
1622         { USB_DEVICE(0x1b80, 0xe304),
1623                         .driver_info = EM2820_BOARD_PINNACLE_DVC_90 }, /* Kworld DVD Maker 2 */
1624         { USB_DEVICE(0x0ccd, 0x0036),
1625                         .driver_info = EM2820_BOARD_TERRATEC_CINERGY_250 },
1626         { USB_DEVICE(0x0ccd, 0x004c),
1627                         .driver_info = EM2880_BOARD_TERRATEC_HYBRID_XS_FR },
1628         { USB_DEVICE(0x0ccd, 0x004f),
1629                         .driver_info = EM2860_BOARD_TERRATEC_HYBRID_XS },
1630         { USB_DEVICE(0x0ccd, 0x005e),
1631                         .driver_info = EM2882_BOARD_TERRATEC_HYBRID_XS },
1632         { USB_DEVICE(0x0ccd, 0x0042),
1633                         .driver_info = EM2880_BOARD_TERRATEC_HYBRID_XS },
1634         { USB_DEVICE(0x0ccd, 0x0043),
1635                         .driver_info = EM2870_BOARD_TERRATEC_XS },
1636         { USB_DEVICE(0x0ccd, 0x0047),
1637                         .driver_info = EM2880_BOARD_TERRATEC_PRODIGY_XS },
1638         { USB_DEVICE(0x0ccd, 0x0084),
1639                         .driver_info = EM2860_BOARD_TERRATEC_AV350 },
1640         { USB_DEVICE(0x0ccd, 0x0096),
1641                         .driver_info = EM2860_BOARD_TERRATEC_GRABBY },
1642         { USB_DEVICE(0x185b, 0x2870),
1643                         .driver_info = EM2870_BOARD_COMPRO_VIDEOMATE },
1644         { USB_DEVICE(0x185b, 0x2041),
1645                         .driver_info = EM2820_BOARD_COMPRO_VIDEOMATE_FORYOU },
1646         { USB_DEVICE(0x2040, 0x4200),
1647                         .driver_info = EM2820_BOARD_HAUPPAUGE_WINTV_USB_2 },
1648         { USB_DEVICE(0x2040, 0x4201),
1649                         .driver_info = EM2820_BOARD_HAUPPAUGE_WINTV_USB_2 },
1650         { USB_DEVICE(0x2040, 0x6500),
1651                         .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900 },
1652         { USB_DEVICE(0x2040, 0x6502),
1653                         .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900_R2 },
1654         { USB_DEVICE(0x2040, 0x6513), /* HCW HVR-980 */
1655                         .driver_info = EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950 },
1656         { USB_DEVICE(0x2040, 0x6517), /* HP  HVR-950 */
1657                         .driver_info = EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950 },
1658         { USB_DEVICE(0x2040, 0x651b), /* RP  HVR-950 */
1659                         .driver_info = EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950 },
1660         { USB_DEVICE(0x2040, 0x651f),
1661                         .driver_info = EM2883_BOARD_HAUPPAUGE_WINTV_HVR_850 },
1662         { USB_DEVICE(0x0438, 0xb002),
1663                         .driver_info = EM2880_BOARD_AMD_ATI_TV_WONDER_HD_600 },
1664         { USB_DEVICE(0x2001, 0xf112),
1665                         .driver_info = EM2820_BOARD_DLINK_USB_TV },
1666         { USB_DEVICE(0x2304, 0x0207),
1667                         .driver_info = EM2820_BOARD_PINNACLE_DVC_90 },
1668         { USB_DEVICE(0x2304, 0x0208),
1669                         .driver_info = EM2820_BOARD_PINNACLE_USB_2 },
1670         { USB_DEVICE(0x2304, 0x021a),
1671                         .driver_info = EM2820_BOARD_PINNACLE_DVC_90 },
1672         { USB_DEVICE(0x2304, 0x0226),
1673                         .driver_info = EM2882_BOARD_PINNACLE_HYBRID_PRO },
1674         { USB_DEVICE(0x2304, 0x0227),
1675                         .driver_info = EM2880_BOARD_PINNACLE_PCTV_HD_PRO },
1676         { USB_DEVICE(0x0413, 0x6023),
1677                         .driver_info = EM2800_BOARD_LEADTEK_WINFAST_USBII },
1678         { USB_DEVICE(0x093b, 0xa005),
1679                         .driver_info = EM2861_BOARD_PLEXTOR_PX_TV100U },
1680         { USB_DEVICE(0x04bb, 0x0515),
1681                         .driver_info = EM2820_BOARD_IODATA_GVMVP_SZ },
1682         { USB_DEVICE(0xeb1a, 0x50a6),
1683                         .driver_info = EM2860_BOARD_GADMEI_UTV330 },
1684         { },
1685 };
1686 MODULE_DEVICE_TABLE(usb, em28xx_id_table);
1687
1688 /*
1689  * EEPROM hash table for devices with generic USB IDs
1690  */
1691 static struct em28xx_hash_table em28xx_eeprom_hash[] = {
1692         /* P/N: SA 60002070465 Tuner: TVF7533-MF */
1693         {0x6ce05a8f, EM2820_BOARD_PROLINK_PLAYTV_USB2, TUNER_YMEC_TVF_5533MF},
1694         {0x72cc5a8b, EM2820_BOARD_PROLINK_PLAYTV_BOX4_USB2, TUNER_YMEC_TVF_5533MF},
1695         {0x966a0441, EM2880_BOARD_KWORLD_DVB_310U, TUNER_XC2028},
1696         {0x166a0441, EM2880_BOARD_EMPIRE_DUAL_TV, TUNER_XC2028},
1697         {0xcee44a99, EM2882_BOARD_EVGA_INDTUBE, TUNER_XC2028},
1698         {0xb8846b20, EM2881_BOARD_PINNACLE_HYBRID_PRO, TUNER_XC2028},
1699 };
1700
1701 /* I2C devicelist hash table for devices with generic USB IDs */
1702 static struct em28xx_hash_table em28xx_i2c_hash[] = {
1703         {0xb06a32c3, EM2800_BOARD_TERRATEC_CINERGY_200, TUNER_LG_PAL_NEW_TAPC},
1704         {0xf51200e3, EM2800_BOARD_VGEAR_POCKETTV, TUNER_LG_PAL_NEW_TAPC},
1705         {0x1ba50080, EM2860_BOARD_SAA711X_REFERENCE_DESIGN, TUNER_ABSENT},
1706         {0xc51200e3, EM2820_BOARD_GADMEI_TVR200, TUNER_LG_PAL_NEW_TAPC},
1707         {0x4ba50080, EM2861_BOARD_GADMEI_UTV330PLUS, TUNER_TNF_5335MF},
1708 };
1709
1710 /* I2C possible address to saa7115, tvp5150, msp3400, tvaudio */
1711 static unsigned short saa711x_addrs[] = {
1712         0x4a >> 1, 0x48 >> 1,   /* SAA7111, SAA7111A and SAA7113 */
1713         0x42 >> 1, 0x40 >> 1,   /* SAA7114, SAA7115 and SAA7118 */
1714         I2C_CLIENT_END };
1715
1716 static unsigned short tvp5150_addrs[] = {
1717         0xb8 >> 1,
1718         0xba >> 1,
1719         I2C_CLIENT_END
1720 };
1721
1722 static unsigned short mt9v011_addrs[] = {
1723         0xba >> 1,
1724         I2C_CLIENT_END
1725 };
1726
1727 static unsigned short msp3400_addrs[] = {
1728         0x80 >> 1,
1729         0x88 >> 1,
1730         I2C_CLIENT_END
1731 };
1732
1733 int em28xx_tuner_callback(void *ptr, int component, int command, int arg)
1734 {
1735         int rc = 0;
1736         struct em28xx *dev = ptr;
1737
1738         if (dev->tuner_type != TUNER_XC2028)
1739                 return 0;
1740
1741         if (command != XC2028_TUNER_RESET)
1742                 return 0;
1743
1744         rc = em28xx_gpio_set(dev, dev->board.tuner_gpio);
1745
1746         return rc;
1747 }
1748 EXPORT_SYMBOL_GPL(em28xx_tuner_callback);
1749
1750 static inline void em28xx_set_model(struct em28xx *dev)
1751 {
1752         memcpy(&dev->board, &em28xx_boards[dev->model], sizeof(dev->board));
1753
1754         /* Those are the default values for the majority of boards
1755            Use those values if not specified otherwise at boards entry
1756          */
1757         if (!dev->board.xclk)
1758                 dev->board.xclk = EM28XX_XCLK_IR_RC5_MODE |
1759                                   EM28XX_XCLK_FREQUENCY_12MHZ;
1760
1761         if (!dev->board.i2c_speed)
1762                 dev->board.i2c_speed = EM28XX_I2C_CLK_WAIT_ENABLE |
1763                                        EM28XX_I2C_FREQ_100_KHZ;
1764 }
1765
1766
1767 /* FIXME: Should be replaced by a proper mt9m111 driver */
1768 static int em28xx_initialize_mt9m111(struct em28xx *dev)
1769 {
1770         int i;
1771         unsigned char regs[][3] = {
1772                 { 0x0d, 0x00, 0x01, },  /* reset and use defaults */
1773                 { 0x0d, 0x00, 0x00, },
1774                 { 0x0a, 0x00, 0x21, },
1775                 { 0x21, 0x04, 0x00, },  /* full readout speed, no row/col skipping */
1776         };
1777
1778         for (i = 0; i < ARRAY_SIZE(regs); i++)
1779                 i2c_master_send(&dev->i2c_client, &regs[i][0], 3);
1780
1781         return 0;
1782 }
1783
1784
1785 /* FIXME: Should be replaced by a proper mt9m001 driver */
1786 static int em28xx_initialize_mt9m001(struct em28xx *dev)
1787 {
1788         int i;
1789         unsigned char regs[][3] = {
1790                 { 0x0d, 0x00, 0x01, },
1791                 { 0x0d, 0x00, 0x00, },
1792                 { 0x04, 0x05, 0x00, },  /* hres = 1280 */
1793                 { 0x03, 0x04, 0x00, },  /* vres = 1024 */
1794                 { 0x20, 0x11, 0x00, },
1795                 { 0x06, 0x00, 0x10, },
1796                 { 0x2b, 0x00, 0x24, },
1797                 { 0x2e, 0x00, 0x24, },
1798                 { 0x35, 0x00, 0x24, },
1799                 { 0x2d, 0x00, 0x20, },
1800                 { 0x2c, 0x00, 0x20, },
1801                 { 0x09, 0x0a, 0xd4, },
1802                 { 0x35, 0x00, 0x57, },
1803         };
1804
1805         for (i = 0; i < ARRAY_SIZE(regs); i++)
1806                 i2c_master_send(&dev->i2c_client, &regs[i][0], 3);
1807
1808         return 0;
1809 }
1810
1811 /* HINT method: webcam I2C chips
1812  *
1813  * This method works for webcams with Micron sensors
1814  */
1815 static int em28xx_hint_sensor(struct em28xx *dev)
1816 {
1817         int rc;
1818         char *sensor_name;
1819         unsigned char cmd;
1820         __be16 version_be;
1821         u16 version;
1822
1823         /* Micron sensor detection */
1824         dev->i2c_client.addr = 0xba >> 1;
1825         cmd = 0;
1826         i2c_master_send(&dev->i2c_client, &cmd, 1);
1827         rc = i2c_master_recv(&dev->i2c_client, (char *)&version_be, 2);
1828         if (rc != 2)
1829                 return -EINVAL;
1830
1831         version = be16_to_cpu(version_be);
1832         switch (version) {
1833         case 0x8232:            /* mt9v011 640x480 1.3 Mpix sensor */
1834         case 0x8243:            /* mt9v011 rev B 640x480 1.3 Mpix sensor */
1835                 dev->model = EM2820_BOARD_SILVERCREST_WEBCAM;
1836                 em28xx_set_model(dev);
1837
1838                 sensor_name = "mt9v011";
1839                 dev->em28xx_sensor = EM28XX_MT9V011;
1840                 dev->sensor_xres = 640;
1841                 dev->sensor_yres = 480;
1842                 /*
1843                  * FIXME: mt9v011 uses I2S speed as xtal clk - at least with
1844                  * the Silvercrest cam I have here for testing - for higher
1845                  * resolutions, a high clock cause horizontal artifacts, so we
1846                  * need to use a lower xclk frequency.
1847                  * Yet, it would be possible to adjust xclk depending on the
1848                  * desired resolution, since this affects directly the
1849                  * frame rate.
1850                  */
1851                 dev->board.xclk = EM28XX_XCLK_FREQUENCY_4_3MHZ;
1852                 dev->sensor_xtal = 4300000;
1853
1854                 /* probably means GRGB 16 bit bayer */
1855                 dev->vinmode = 0x0d;
1856                 dev->vinctl = 0x00;
1857
1858                 break;
1859
1860         case 0x143a:    /* MT9M111 as found in the ECS G200 */
1861                 dev->model = EM2750_BOARD_UNKNOWN;
1862                 em28xx_set_model(dev);
1863
1864                 sensor_name = "mt9m111";
1865                 dev->board.xclk = EM28XX_XCLK_FREQUENCY_48MHZ;
1866                 dev->em28xx_sensor = EM28XX_MT9M111;
1867                 em28xx_initialize_mt9m111(dev);
1868                 dev->sensor_xres = 640;
1869                 dev->sensor_yres = 512;
1870
1871                 dev->vinmode = 0x0a;
1872                 dev->vinctl = 0x00;
1873
1874                 break;
1875
1876         case 0x8431:
1877                 dev->model = EM2750_BOARD_UNKNOWN;
1878                 em28xx_set_model(dev);
1879
1880                 sensor_name = "mt9m001";
1881                 dev->em28xx_sensor = EM28XX_MT9M001;
1882                 em28xx_initialize_mt9m001(dev);
1883                 dev->sensor_xres = 1280;
1884                 dev->sensor_yres = 1024;
1885
1886                 /* probably means BGGR 16 bit bayer */
1887                 dev->vinmode = 0x0c;
1888                 dev->vinctl = 0x00;
1889
1890                 break;
1891         default:
1892                 printk("Unknown Micron Sensor 0x%04x\n", version);
1893                 return -EINVAL;
1894         }
1895
1896         /* Setup webcam defaults */
1897         em28xx_pre_card_setup(dev);
1898
1899         em28xx_errdev("Sensor is %s, using model %s entry.\n",
1900                       sensor_name, em28xx_boards[dev->model].name);
1901
1902         return 0;
1903 }
1904
1905 /* Since em28xx_pre_card_setup() requires a proper dev->model,
1906  * this won't work for boards with generic PCI IDs
1907  */
1908 void em28xx_pre_card_setup(struct em28xx *dev)
1909 {
1910         /* Set the initial XCLK and I2C clock values based on the board
1911            definition */
1912         em28xx_write_reg(dev, EM28XX_R0F_XCLK, dev->board.xclk & 0x7f);
1913         em28xx_write_reg(dev, EM28XX_R06_I2C_CLK, dev->board.i2c_speed);
1914         msleep(50);
1915
1916         /* request some modules */
1917         switch (dev->model) {
1918         case EM2861_BOARD_PLEXTOR_PX_TV100U:
1919                 /* Sets the msp34xx I2S speed */
1920                 dev->i2s_speed = 2048000;
1921                 break;
1922         case EM2861_BOARD_KWORLD_PVRTV_300U:
1923         case EM2880_BOARD_KWORLD_DVB_305U:
1924                 em28xx_write_reg(dev, EM28XX_R08_GPIO, 0x6d);
1925                 msleep(10);
1926                 em28xx_write_reg(dev, EM28XX_R08_GPIO, 0x7d);
1927                 msleep(10);
1928                 break;
1929         case EM2870_BOARD_COMPRO_VIDEOMATE:
1930                 /* TODO: someone can do some cleanup here...
1931                          not everything's needed */
1932                 em28xx_write_reg(dev, EM2880_R04_GPO, 0x00);
1933                 msleep(10);
1934                 em28xx_write_reg(dev, EM2880_R04_GPO, 0x01);
1935                 msleep(10);
1936                 em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xfd);
1937                 mdelay(70);
1938                 em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xfc);
1939                 mdelay(70);
1940                 em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xdc);
1941                 mdelay(70);
1942                 em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xfc);
1943                 mdelay(70);
1944                 break;
1945         case EM2870_BOARD_TERRATEC_XS_MT2060:
1946                 /* this device needs some gpio writes to get the DVB-T
1947                    demod work */
1948                 em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xfe);
1949                 mdelay(70);
1950                 em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xde);
1951                 mdelay(70);
1952                 em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xfe);
1953                 mdelay(70);
1954                 break;
1955         case EM2870_BOARD_PINNACLE_PCTV_DVB:
1956                 /* this device needs some gpio writes to get the
1957                    DVB-T demod work */
1958                 em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xfe);
1959                 mdelay(70);
1960                 em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xde);
1961                 mdelay(70);
1962                 em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xfe);
1963                 mdelay(70);
1964                 break;
1965         case EM2820_BOARD_GADMEI_UTV310:
1966         case EM2820_BOARD_MSI_VOX_USB_2:
1967                 /* enables audio for that devices */
1968                 em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xfd);
1969                 break;
1970
1971         case EM2882_BOARD_KWORLD_ATSC_315U:
1972                 em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xff);
1973                 msleep(10);
1974                 em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xfe);
1975                 msleep(10);
1976                 em28xx_write_reg(dev, EM2880_R04_GPO, 0x00);
1977                 msleep(10);
1978                 em28xx_write_reg(dev, EM2880_R04_GPO, 0x08);
1979                 msleep(10);
1980                 break;
1981
1982         case EM2860_BOARD_KAIOMY_TVNPC_U2:
1983                 em28xx_write_regs(dev, EM28XX_R0F_XCLK, "\x07", 1);
1984                 em28xx_write_regs(dev, EM28XX_R06_I2C_CLK, "\x40", 1);
1985                 em28xx_write_regs(dev, 0x0d, "\x42", 1);
1986                 em28xx_write_regs(dev, 0x08, "\xfd", 1);
1987                 msleep(10);
1988                 em28xx_write_regs(dev, 0x08, "\xff", 1);
1989                 msleep(10);
1990                 em28xx_write_regs(dev, 0x08, "\x7f", 1);
1991                 msleep(10);
1992                 em28xx_write_regs(dev, 0x08, "\x6b", 1);
1993
1994                 break;
1995         case EM2860_BOARD_EASYCAP:
1996                 em28xx_write_regs(dev, 0x08, "\xf8", 1);
1997                 break;
1998
1999         case EM2820_BOARD_IODATA_GVMVP_SZ:
2000                 em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xff);
2001                 msleep(70);
2002                 em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xf7);
2003                 msleep(10);
2004                 em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xfe);
2005                 msleep(70);
2006                 em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xfd);
2007                 msleep(70);
2008                 break;
2009         }
2010
2011         em28xx_gpio_set(dev, dev->board.tuner_gpio);
2012         em28xx_set_mode(dev, EM28XX_ANALOG_MODE);
2013
2014         /* Unlock device */
2015         em28xx_set_mode(dev, EM28XX_SUSPEND);
2016 }
2017
2018 static void em28xx_setup_xc3028(struct em28xx *dev, struct xc2028_ctrl *ctl)
2019 {
2020         memset(ctl, 0, sizeof(*ctl));
2021
2022         ctl->fname   = XC2028_DEFAULT_FIRMWARE;
2023         ctl->max_len = 64;
2024         ctl->mts = em28xx_boards[dev->model].mts_firmware;
2025
2026         switch (dev->model) {
2027         case EM2880_BOARD_EMPIRE_DUAL_TV:
2028         case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900:
2029                 ctl->demod = XC3028_FE_ZARLINK456;
2030                 break;
2031         case EM2880_BOARD_TERRATEC_HYBRID_XS:
2032         case EM2881_BOARD_PINNACLE_HYBRID_PRO:
2033                 ctl->demod = XC3028_FE_ZARLINK456;
2034                 break;
2035         case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900_R2:
2036                 /* djh - Not sure which demod we need here */
2037                 ctl->demod = XC3028_FE_DEFAULT;
2038                 break;
2039         case EM2880_BOARD_AMD_ATI_TV_WONDER_HD_600:
2040                 ctl->demod = XC3028_FE_DEFAULT;
2041                 ctl->fname = XC3028L_DEFAULT_FIRMWARE;
2042                 break;
2043         case EM2883_BOARD_HAUPPAUGE_WINTV_HVR_850:
2044         case EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950:
2045         case EM2880_BOARD_PINNACLE_PCTV_HD_PRO:
2046                 /* FIXME: Better to specify the needed IF */
2047                 ctl->demod = XC3028_FE_DEFAULT;
2048                 break;
2049         case EM2883_BOARD_KWORLD_HYBRID_330U:
2050                 ctl->demod = XC3028_FE_CHINA;
2051                 ctl->fname = XC2028_DEFAULT_FIRMWARE;
2052                 break;
2053         case EM2882_BOARD_EVGA_INDTUBE:
2054                 ctl->demod = XC3028_FE_CHINA;
2055                 ctl->fname = XC3028L_DEFAULT_FIRMWARE;
2056                 break;
2057         default:
2058                 ctl->demod = XC3028_FE_OREN538;
2059         }
2060 }
2061
2062 static void em28xx_tuner_setup(struct em28xx *dev)
2063 {
2064         struct tuner_setup           tun_setup;
2065         struct v4l2_frequency        f;
2066
2067         if (dev->tuner_type == TUNER_ABSENT)
2068                 return;
2069
2070         memset(&tun_setup, 0, sizeof(tun_setup));
2071
2072         tun_setup.mode_mask = T_ANALOG_TV | T_RADIO;
2073         tun_setup.tuner_callback = em28xx_tuner_callback;
2074
2075         if (dev->board.radio.type) {
2076                 tun_setup.type = dev->board.radio.type;
2077                 tun_setup.addr = dev->board.radio_addr;
2078
2079                 v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_type_addr, &tun_setup);
2080         }
2081
2082         if ((dev->tuner_type != TUNER_ABSENT) && (dev->tuner_type)) {
2083                 tun_setup.type   = dev->tuner_type;
2084                 tun_setup.addr   = dev->tuner_addr;
2085
2086                 v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_type_addr, &tun_setup);
2087         }
2088
2089         if (dev->tda9887_conf) {
2090                 struct v4l2_priv_tun_config tda9887_cfg;
2091
2092                 tda9887_cfg.tuner = TUNER_TDA9887;
2093                 tda9887_cfg.priv = &dev->tda9887_conf;
2094
2095                 v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_config, &tda9887_cfg);
2096         }
2097
2098         if (dev->tuner_type == TUNER_XC2028) {
2099                 struct v4l2_priv_tun_config  xc2028_cfg;
2100                 struct xc2028_ctrl           ctl;
2101
2102                 memset(&xc2028_cfg, 0, sizeof(xc2028_cfg));
2103                 memset(&ctl, 0, sizeof(ctl));
2104
2105                 em28xx_setup_xc3028(dev, &ctl);
2106
2107                 xc2028_cfg.tuner = TUNER_XC2028;
2108                 xc2028_cfg.priv  = &ctl;
2109
2110                 v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_config, &xc2028_cfg);
2111         }
2112
2113         /* configure tuner */
2114         f.tuner = 0;
2115         f.type = V4L2_TUNER_ANALOG_TV;
2116         f.frequency = 9076;     /* just a magic number */
2117         dev->ctl_freq = f.frequency;
2118         v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_frequency, &f);
2119 }
2120
2121 static int em28xx_hint_board(struct em28xx *dev)
2122 {
2123         int i;
2124
2125         /* HINT method: EEPROM
2126          *
2127          * This method works only for boards with eeprom.
2128          * Uses a hash of all eeprom bytes. The hash should be
2129          * unique for a vendor/tuner pair.
2130          * There are a high chance that tuners for different
2131          * video standards produce different hashes.
2132          */
2133         for (i = 0; i < ARRAY_SIZE(em28xx_eeprom_hash); i++) {
2134                 if (dev->hash == em28xx_eeprom_hash[i].hash) {
2135                         dev->model = em28xx_eeprom_hash[i].model;
2136                         dev->tuner_type = em28xx_eeprom_hash[i].tuner;
2137
2138                         em28xx_errdev("Your board has no unique USB ID.\n");
2139                         em28xx_errdev("A hint were successfully done, "
2140                                       "based on eeprom hash.\n");
2141                         em28xx_errdev("This method is not 100%% failproof.\n");
2142                         em28xx_errdev("If the board were missdetected, "
2143                                       "please email this log to:\n");
2144                         em28xx_errdev("\tV4L Mailing List "
2145                                       " <linux-media@vger.kernel.org>\n");
2146                         em28xx_errdev("Board detected as %s\n",
2147                                       em28xx_boards[dev->model].name);
2148
2149                         return 0;
2150                 }
2151         }
2152
2153         /* HINT method: I2C attached devices
2154          *
2155          * This method works for all boards.
2156          * Uses a hash of i2c scanned devices.
2157          * Devices with the same i2c attached chips will
2158          * be considered equal.
2159          * This method is less precise than the eeprom one.
2160          */
2161
2162         /* user did not request i2c scanning => do it now */
2163         if (!dev->i2c_hash)
2164                 em28xx_do_i2c_scan(dev);
2165
2166         for (i = 0; i < ARRAY_SIZE(em28xx_i2c_hash); i++) {
2167                 if (dev->i2c_hash == em28xx_i2c_hash[i].hash) {
2168                         dev->model = em28xx_i2c_hash[i].model;
2169                         dev->tuner_type = em28xx_i2c_hash[i].tuner;
2170                         em28xx_errdev("Your board has no unique USB ID.\n");
2171                         em28xx_errdev("A hint were successfully done, "
2172                                       "based on i2c devicelist hash.\n");
2173                         em28xx_errdev("This method is not 100%% failproof.\n");
2174                         em28xx_errdev("If the board were missdetected, "
2175                                       "please email this log to:\n");
2176                         em28xx_errdev("\tV4L Mailing List "
2177                                       " <linux-media@vger.kernel.org>\n");
2178                         em28xx_errdev("Board detected as %s\n",
2179                                       em28xx_boards[dev->model].name);
2180
2181                         return 0;
2182                 }
2183         }
2184
2185         em28xx_errdev("Your board has no unique USB ID and thus need a "
2186                       "hint to be detected.\n");
2187         em28xx_errdev("You may try to use card=<n> insmod option to "
2188                       "workaround that.\n");
2189         em28xx_errdev("Please send an email with this log to:\n");
2190         em28xx_errdev("\tV4L Mailing List <linux-media@vger.kernel.org>\n");
2191         em28xx_errdev("Board eeprom hash is 0x%08lx\n", dev->hash);
2192         em28xx_errdev("Board i2c devicelist hash is 0x%08lx\n", dev->i2c_hash);
2193
2194         em28xx_errdev("Here is a list of valid choices for the card=<n>"
2195                       " insmod option:\n");
2196         for (i = 0; i < em28xx_bcount; i++) {
2197                 em28xx_errdev("    card=%d -> %s\n",
2198                                 i, em28xx_boards[i].name);
2199         }
2200         return -1;
2201 }
2202
2203 /* ----------------------------------------------------------------------- */
2204 void em28xx_register_i2c_ir(struct em28xx *dev)
2205 {
2206         const unsigned short addr_list[] = {
2207                  0x30, 0x47, I2C_CLIENT_END
2208         };
2209
2210         if (disable_ir)
2211                 return;
2212
2213         memset(&dev->info, 0, sizeof(&dev->info));
2214         memset(&dev->init_data, 0, sizeof(dev->init_data));
2215         strlcpy(dev->info.type, "ir_video", I2C_NAME_SIZE);
2216
2217         /* detect & configure */
2218         switch (dev->model) {
2219         case EM2800_BOARD_TERRATEC_CINERGY_200:
2220         case EM2820_BOARD_TERRATEC_CINERGY_250:
2221                 dev->init_data.ir_codes = &ir_codes_em_terratec_table;
2222                 dev->init_data.get_key = em28xx_get_key_terratec;
2223                 dev->init_data.name = "i2c IR (EM28XX Terratec)";
2224                 break;
2225         case EM2820_BOARD_PINNACLE_USB_2:
2226                 dev->init_data.ir_codes = &ir_codes_pinnacle_grey_table;
2227                 dev->init_data.get_key = em28xx_get_key_pinnacle_usb_grey;
2228                 dev->init_data.name = "i2c IR (EM28XX Pinnacle PCTV)";
2229                 break;
2230         case EM2820_BOARD_HAUPPAUGE_WINTV_USB_2:
2231                 dev->init_data.ir_codes = &ir_codes_hauppauge_new_table;
2232                 dev->init_data.get_key = em28xx_get_key_em_haup;
2233                 dev->init_data.name = "i2c IR (EM2840 Hauppauge)";
2234                 break;
2235         }
2236
2237         if (dev->init_data.name)
2238                 dev->info.platform_data = &dev->init_data;
2239         i2c_new_probed_device(&dev->i2c_adap, &dev->info, addr_list);
2240 }
2241
2242 void em28xx_card_setup(struct em28xx *dev)
2243 {
2244         /*
2245          * If the device can be a webcam, seek for a sensor.
2246          * If sensor is not found, then it isn't a webcam.
2247          */
2248         if (dev->board.is_webcam) {
2249                 if (em28xx_hint_sensor(dev) < 0)
2250                         dev->board.is_webcam = 0;
2251                 else
2252                         dev->progressive = 1;
2253         } else
2254                 em28xx_set_model(dev);
2255
2256         em28xx_info("Identified as %s (card=%d)\n",
2257                     dev->board.name, dev->model);
2258
2259         dev->tuner_type = em28xx_boards[dev->model].tuner_type;
2260         if (em28xx_boards[dev->model].tuner_addr)
2261                 dev->tuner_addr = em28xx_boards[dev->model].tuner_addr;
2262
2263         if (em28xx_boards[dev->model].tda9887_conf)
2264                 dev->tda9887_conf = em28xx_boards[dev->model].tda9887_conf;
2265
2266         /* request some modules */
2267         switch (dev->model) {
2268         case EM2820_BOARD_HAUPPAUGE_WINTV_USB_2:
2269         case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900:
2270         case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900_R2:
2271         case EM2883_BOARD_HAUPPAUGE_WINTV_HVR_850:
2272         case EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950:
2273         {
2274                 struct tveeprom tv;
2275 #if defined(CONFIG_MODULES) && defined(MODULE)
2276                 request_module("tveeprom");
2277 #endif
2278                 /* Call first TVeeprom */
2279
2280                 dev->i2c_client.addr = 0xa0 >> 1;
2281                 tveeprom_hauppauge_analog(&dev->i2c_client, &tv, dev->eedata);
2282
2283                 dev->tuner_type = tv.tuner_type;
2284
2285                 if (tv.audio_processor == V4L2_IDENT_MSPX4XX) {
2286                         dev->i2s_speed = 2048000;
2287                         dev->board.has_msp34xx = 1;
2288                 }
2289                 break;
2290         }
2291         case EM2882_BOARD_KWORLD_ATSC_315U:
2292                 em28xx_write_reg(dev, 0x0d, 0x42);
2293                 msleep(10);
2294                 em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xfd);
2295                 msleep(10);
2296                 break;
2297         case EM2820_BOARD_KWORLD_PVRTV2800RF:
2298                 /* GPIO enables sound on KWORLD PVR TV 2800RF */
2299                 em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xf9);
2300                 break;
2301         case EM2820_BOARD_UNKNOWN:
2302         case EM2800_BOARD_UNKNOWN:
2303                 /*
2304                  * The K-WORLD DVB-T 310U is detected as an MSI Digivox AD.
2305                  *
2306                  * This occurs because they share identical USB vendor and
2307                  * product IDs.
2308                  *
2309                  * What we do here is look up the EEPROM hash of the K-WORLD
2310                  * and if it is found then we decide that we do not have
2311                  * a DIGIVOX and reset the device to the K-WORLD instead.
2312                  *
2313                  * This solution is only valid if they do not share eeprom
2314                  * hash identities which has not been determined as yet.
2315                  */
2316         case EM2880_BOARD_MSI_DIGIVOX_AD:
2317                 if (!em28xx_hint_board(dev))
2318                         em28xx_set_model(dev);
2319
2320                 /* In cases where we had to use a board hint, the call to
2321                    em28xx_set_mode() in em28xx_pre_card_setup() was a no-op,
2322                    so make the call now so the analog GPIOs are set properly
2323                    before probing the i2c bus. */
2324                 em28xx_gpio_set(dev, dev->board.tuner_gpio);
2325                 em28xx_set_mode(dev, EM28XX_ANALOG_MODE);
2326                 break;
2327         }
2328
2329 #if defined(CONFIG_MODULES) && defined(MODULE)
2330         if (dev->board.has_ir_i2c && !disable_ir)
2331                 request_module("ir-kbd-i2c");
2332 #endif
2333         if (dev->board.has_snapshot_button)
2334                 em28xx_register_snapshot_button(dev);
2335
2336         if (dev->board.valid == EM28XX_BOARD_NOT_VALIDATED) {
2337                 em28xx_errdev("\n\n");
2338                 em28xx_errdev("The support for this board weren't "
2339                               "valid yet.\n");
2340                 em28xx_errdev("Please send a report of having this working\n");
2341                 em28xx_errdev("not to V4L mailing list (and/or to other "
2342                                 "addresses)\n\n");
2343         }
2344
2345         /* Allow override tuner type by a module parameter */
2346         if (tuner >= 0)
2347                 dev->tuner_type = tuner;
2348
2349         /* request some modules */
2350         if (dev->board.has_msp34xx)
2351                 v4l2_i2c_new_probed_subdev(&dev->v4l2_dev, &dev->i2c_adap,
2352                         "msp3400", "msp3400", msp3400_addrs);
2353
2354         if (dev->board.decoder == EM28XX_SAA711X)
2355                 v4l2_i2c_new_probed_subdev(&dev->v4l2_dev, &dev->i2c_adap,
2356                         "saa7115", "saa7115_auto", saa711x_addrs);
2357
2358         if (dev->board.decoder == EM28XX_TVP5150)
2359                 v4l2_i2c_new_probed_subdev(&dev->v4l2_dev, &dev->i2c_adap,
2360                         "tvp5150", "tvp5150", tvp5150_addrs);
2361
2362         if (dev->em28xx_sensor == EM28XX_MT9V011) {
2363                 struct v4l2_subdev *sd;
2364
2365                 sd = v4l2_i2c_new_probed_subdev(&dev->v4l2_dev,
2366                          &dev->i2c_adap, "mt9v011", "mt9v011", mt9v011_addrs);
2367                 v4l2_subdev_call(sd, core, s_config, 0, &dev->sensor_xtal);
2368         }
2369
2370
2371         if (dev->board.adecoder == EM28XX_TVAUDIO)
2372                 v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap,
2373                         "tvaudio", "tvaudio", dev->board.tvaudio_addr);
2374
2375         if (dev->board.tuner_type != TUNER_ABSENT) {
2376                 int has_demod = (dev->tda9887_conf & TDA9887_PRESENT);
2377
2378                 if (dev->board.radio.type)
2379                         v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap,
2380                                 "tuner", "tuner", dev->board.radio_addr);
2381
2382                 if (has_demod)
2383                         v4l2_i2c_new_probed_subdev(&dev->v4l2_dev,
2384                                 &dev->i2c_adap, "tuner", "tuner",
2385                                 v4l2_i2c_tuner_addrs(ADDRS_DEMOD));
2386                 if (dev->tuner_addr == 0) {
2387                         enum v4l2_i2c_tuner_type type =
2388                                 has_demod ? ADDRS_TV_WITH_DEMOD : ADDRS_TV;
2389                         struct v4l2_subdev *sd;
2390
2391                         sd = v4l2_i2c_new_probed_subdev(&dev->v4l2_dev,
2392                                 &dev->i2c_adap, "tuner", "tuner",
2393                                 v4l2_i2c_tuner_addrs(type));
2394
2395                         if (sd)
2396                                 dev->tuner_addr = v4l2_i2c_subdev_addr(sd);
2397                 } else {
2398                         v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap,
2399                                 "tuner", "tuner", dev->tuner_addr);
2400                 }
2401         }
2402
2403         em28xx_tuner_setup(dev);
2404
2405         if(!disable_ir)
2406                 em28xx_ir_init(dev);
2407 }
2408
2409
2410 #if defined(CONFIG_MODULES) && defined(MODULE)
2411 static void request_module_async(struct work_struct *work)
2412 {
2413         struct em28xx *dev = container_of(work,
2414                              struct em28xx, request_module_wk);
2415
2416         if (dev->has_audio_class)
2417                 request_module("snd-usb-audio");
2418         else if (dev->has_alsa_audio)
2419                 request_module("em28xx-alsa");
2420
2421         if (dev->board.has_dvb)
2422                 request_module("em28xx-dvb");
2423 }
2424
2425 static void request_modules(struct em28xx *dev)
2426 {
2427         INIT_WORK(&dev->request_module_wk, request_module_async);
2428         schedule_work(&dev->request_module_wk);
2429 }
2430 #else
2431 #define request_modules(dev)
2432 #endif /* CONFIG_MODULES */
2433
2434 /*
2435  * em28xx_realease_resources()
2436  * unregisters the v4l2,i2c and usb devices
2437  * called when the device gets disconected or at module unload
2438 */
2439 void em28xx_release_resources(struct em28xx *dev)
2440 {
2441         if (dev->sbutton_input_dev)
2442                 em28xx_deregister_snapshot_button(dev);
2443
2444         if (dev->ir)
2445                 em28xx_ir_fini(dev);
2446
2447         /*FIXME: I2C IR should be disconnected */
2448
2449         em28xx_release_analog_resources(dev);
2450
2451         em28xx_remove_from_devlist(dev);
2452
2453         em28xx_i2c_unregister(dev);
2454
2455         v4l2_device_unregister(&dev->v4l2_dev);
2456
2457         usb_put_dev(dev->udev);
2458
2459         /* Mark device as unused */
2460         em28xx_devused &= ~(1 << dev->devno);
2461 };
2462
2463 /*
2464  * em28xx_init_dev()
2465  * allocates and inits the device structs, registers i2c bus and v4l device
2466  */
2467 static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev,
2468                            struct usb_interface *interface,
2469                            int minor)
2470 {
2471         struct em28xx *dev = *devhandle;
2472         int retval;
2473         int errCode;
2474
2475         dev->udev = udev;
2476         mutex_init(&dev->ctrl_urb_lock);
2477         spin_lock_init(&dev->slock);
2478         init_waitqueue_head(&dev->open);
2479         init_waitqueue_head(&dev->wait_frame);
2480         init_waitqueue_head(&dev->wait_stream);
2481
2482         dev->em28xx_write_regs = em28xx_write_regs;
2483         dev->em28xx_read_reg = em28xx_read_reg;
2484         dev->em28xx_read_reg_req_len = em28xx_read_reg_req_len;
2485         dev->em28xx_write_regs_req = em28xx_write_regs_req;
2486         dev->em28xx_read_reg_req = em28xx_read_reg_req;
2487         dev->board.is_em2800 = em28xx_boards[dev->model].is_em2800;
2488
2489         em28xx_set_model(dev);
2490
2491         /* Set the default GPO/GPIO for legacy devices */
2492         dev->reg_gpo_num = EM2880_R04_GPO;
2493         dev->reg_gpio_num = EM28XX_R08_GPIO;
2494
2495         dev->wait_after_write = 5;
2496
2497         /* Based on the Chip ID, set the device configuration */
2498         retval = em28xx_read_reg(dev, EM28XX_R0A_CHIPID);
2499         if (retval > 0) {
2500                 dev->chip_id = retval;
2501
2502                 switch (dev->chip_id) {
2503                 case CHIP_ID_EM2710:
2504                         em28xx_info("chip ID is em2710\n");
2505                         break;
2506                 case CHIP_ID_EM2750:
2507                         em28xx_info("chip ID is em2750\n");
2508                         break;
2509                 case CHIP_ID_EM2820:
2510                         em28xx_info("chip ID is em2820 (or em2710)\n");
2511                         break;
2512                 case CHIP_ID_EM2840:
2513                         em28xx_info("chip ID is em2840\n");
2514                         break;
2515                 case CHIP_ID_EM2860:
2516                         em28xx_info("chip ID is em2860\n");
2517                         break;
2518                 case CHIP_ID_EM2870:
2519                         em28xx_info("chip ID is em2870\n");
2520                         dev->wait_after_write = 0;
2521                         break;
2522                 case CHIP_ID_EM2874:
2523                         em28xx_info("chip ID is em2874\n");
2524                         dev->reg_gpio_num = EM2874_R80_GPIO;
2525                         dev->wait_after_write = 0;
2526                         break;
2527                 case CHIP_ID_EM2883:
2528                         em28xx_info("chip ID is em2882/em2883\n");
2529                         dev->wait_after_write = 0;
2530                         break;
2531                 default:
2532                         em28xx_info("em28xx chip ID = %d\n", dev->chip_id);
2533                 }
2534         }
2535
2536         /* Prepopulate cached GPO register content */
2537         retval = em28xx_read_reg(dev, dev->reg_gpo_num);
2538         if (retval >= 0)
2539                 dev->reg_gpo = retval;
2540
2541         em28xx_pre_card_setup(dev);
2542
2543         if (!dev->board.is_em2800) {
2544                 /* Sets I2C speed to 100 KHz */
2545                 retval = em28xx_write_reg(dev, EM28XX_R06_I2C_CLK, 0x40);
2546                 if (retval < 0) {
2547                         em28xx_errdev("%s: em28xx_write_regs_req failed!"
2548                                       " retval [%d]\n",
2549                                       __func__, retval);
2550                         return retval;
2551                 }
2552         }
2553
2554         retval = v4l2_device_register(&interface->dev, &dev->v4l2_dev);
2555         if (retval < 0) {
2556                 em28xx_errdev("Call to v4l2_device_register() failed!\n");
2557                 return retval;
2558         }
2559
2560         /* register i2c bus */
2561         errCode = em28xx_i2c_register(dev);
2562         if (errCode < 0) {
2563                 v4l2_device_unregister(&dev->v4l2_dev);
2564                 em28xx_errdev("%s: em28xx_i2c_register - errCode [%d]!\n",
2565                         __func__, errCode);
2566                 return errCode;
2567         }
2568
2569         /*
2570          * Default format, used for tvp5150 or saa711x output formats
2571          */
2572         dev->vinmode = 0x10;
2573         dev->vinctl  = 0x11;
2574
2575         /* Do board specific init and eeprom reading */
2576         em28xx_card_setup(dev);
2577
2578         /* Configure audio */
2579         errCode = em28xx_audio_setup(dev);
2580         if (errCode < 0) {
2581                 v4l2_device_unregister(&dev->v4l2_dev);
2582                 em28xx_errdev("%s: Error while setting audio - errCode [%d]!\n",
2583                         __func__, errCode);
2584         }
2585
2586         /* wake i2c devices */
2587         em28xx_wake_i2c(dev);
2588
2589         /* init video dma queues */
2590         INIT_LIST_HEAD(&dev->vidq.active);
2591         INIT_LIST_HEAD(&dev->vidq.queued);
2592
2593
2594         if (dev->board.has_msp34xx) {
2595                 /* Send a reset to other chips via gpio */
2596                 errCode = em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xf7);
2597                 if (errCode < 0) {
2598                         em28xx_errdev("%s: em28xx_write_regs_req - "
2599                                       "msp34xx(1) failed! errCode [%d]\n",
2600                                       __func__, errCode);
2601                         return errCode;
2602                 }
2603                 msleep(3);
2604
2605                 errCode = em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xff);
2606                 if (errCode < 0) {
2607                         em28xx_errdev("%s: em28xx_write_regs_req - "
2608                                       "msp34xx(2) failed! errCode [%d]\n",
2609                                       __func__, errCode);
2610                         return errCode;
2611                 }
2612                 msleep(3);
2613         }
2614
2615         em28xx_add_into_devlist(dev);
2616
2617         retval = em28xx_register_analog_devices(dev);
2618         if (retval < 0) {
2619                 em28xx_release_resources(dev);
2620                 goto fail_reg_devices;
2621         }
2622
2623         em28xx_init_extension(dev);
2624
2625         /* Save some power by putting tuner to sleep */
2626         v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_standby);
2627
2628         return 0;
2629
2630 fail_reg_devices:
2631         return retval;
2632 }
2633
2634 /*
2635  * em28xx_usb_probe()
2636  * checks for supported devices
2637  */
2638 static int em28xx_usb_probe(struct usb_interface *interface,
2639                             const struct usb_device_id *id)
2640 {
2641         const struct usb_endpoint_descriptor *endpoint;
2642         struct usb_device *udev;
2643         struct usb_interface *uif;
2644         struct em28xx *dev = NULL;
2645         int retval;
2646         int i, nr, ifnum, isoc_pipe;
2647         char *speed;
2648         char descr[255] = "";
2649
2650         udev = usb_get_dev(interface_to_usbdev(interface));
2651         ifnum = interface->altsetting[0].desc.bInterfaceNumber;
2652
2653         /* Check to see next free device and mark as used */
2654         nr = find_first_zero_bit(&em28xx_devused, EM28XX_MAXBOARDS);
2655         em28xx_devused |= 1<<nr;
2656
2657         /* Don't register audio interfaces */
2658         if (interface->altsetting[0].desc.bInterfaceClass == USB_CLASS_AUDIO) {
2659                 em28xx_err(DRIVER_NAME " audio device (%04x:%04x): "
2660                         "interface %i, class %i\n",
2661                         le16_to_cpu(udev->descriptor.idVendor),
2662                         le16_to_cpu(udev->descriptor.idProduct),
2663                         ifnum,
2664                         interface->altsetting[0].desc.bInterfaceClass);
2665
2666                 em28xx_devused &= ~(1<<nr);
2667                 retval = -ENODEV;
2668                 goto err;
2669         }
2670
2671         endpoint = &interface->cur_altsetting->endpoint[0].desc;
2672
2673         /* check if the device has the iso in endpoint at the correct place */
2674         if (usb_endpoint_xfer_isoc(endpoint)
2675             &&
2676             (interface->altsetting[1].endpoint[0].desc.wMaxPacketSize == 940)) {
2677                 /* It's a newer em2874/em2875 device */
2678                 isoc_pipe = 0;
2679         } else {
2680                 int check_interface = 1;
2681                 isoc_pipe = 1;
2682                 endpoint = &interface->cur_altsetting->endpoint[1].desc;
2683                 if (!usb_endpoint_xfer_isoc(endpoint))
2684                         check_interface = 0;
2685
2686                 if (usb_endpoint_dir_out(endpoint))
2687                         check_interface = 0;
2688
2689                 if (!check_interface) {
2690                         em28xx_err(DRIVER_NAME " video device (%04x:%04x): "
2691                                 "interface %i, class %i found.\n",
2692                                 le16_to_cpu(udev->descriptor.idVendor),
2693                                 le16_to_cpu(udev->descriptor.idProduct),
2694                                 ifnum,
2695                                 interface->altsetting[0].desc.bInterfaceClass);
2696
2697                         em28xx_err(DRIVER_NAME " This is an anciliary "
2698                                 "interface not used by the driver\n");
2699
2700                         em28xx_devused &= ~(1<<nr);
2701                         retval = -ENODEV;
2702                         goto err;
2703                 }
2704         }
2705
2706         switch (udev->speed) {
2707         case USB_SPEED_LOW:
2708                 speed = "1.5";
2709                 break;
2710         case USB_SPEED_UNKNOWN:
2711         case USB_SPEED_FULL:
2712                 speed = "12";
2713                 break;
2714         case USB_SPEED_HIGH:
2715                 speed = "480";
2716                 break;
2717         default:
2718                 speed = "unknown";
2719         }
2720
2721         if (udev->manufacturer)
2722                 strlcpy(descr, udev->manufacturer, sizeof(descr));
2723
2724         if (udev->product) {
2725                 if (*descr)
2726                         strlcat(descr, " ", sizeof(descr));
2727                 strlcat(descr, udev->product, sizeof(descr));
2728         }
2729         if (*descr)
2730                 strlcat(descr, " ", sizeof(descr));
2731
2732         printk(DRIVER_NAME ": New device %s@ %s Mbps "
2733                 "(%04x:%04x, interface %d, class %d)\n",
2734                 descr,
2735                 speed,
2736                 le16_to_cpu(udev->descriptor.idVendor),
2737                 le16_to_cpu(udev->descriptor.idProduct),
2738                 ifnum,
2739                 interface->altsetting->desc.bInterfaceNumber);
2740
2741         /*
2742          * Make sure we have 480 Mbps of bandwidth, otherwise things like
2743          * video stream wouldn't likely work, since 12 Mbps is generally
2744          * not enough even for most Digital TV streams.
2745          */
2746         if (udev->speed != USB_SPEED_HIGH && disable_usb_speed_check == 0) {
2747                 printk(DRIVER_NAME ": Device initialization failed.\n");
2748                 printk(DRIVER_NAME ": Device must be connected to a high-speed"
2749                        " USB 2.0 port.\n");
2750                 em28xx_devused &= ~(1<<nr);
2751                 retval = -ENODEV;
2752                 goto err;
2753         }
2754
2755         if (nr >= EM28XX_MAXBOARDS) {
2756                 printk(DRIVER_NAME ": Supports only %i em28xx boards.\n",
2757                                 EM28XX_MAXBOARDS);
2758                 em28xx_devused &= ~(1<<nr);
2759                 retval = -ENOMEM;
2760                 goto err;
2761         }
2762
2763         /* allocate memory for our device state and initialize it */
2764         dev = kzalloc(sizeof(*dev), GFP_KERNEL);
2765         if (dev == NULL) {
2766                 em28xx_err(DRIVER_NAME ": out of memory!\n");
2767                 em28xx_devused &= ~(1<<nr);
2768                 retval = -ENOMEM;
2769                 goto err;
2770         }
2771
2772         snprintf(dev->name, 29, "em28xx #%d", nr);
2773         dev->devno = nr;
2774         dev->model = id->driver_info;
2775         dev->alt   = -1;
2776
2777         /* Checks if audio is provided by some interface */
2778         for (i = 0; i < udev->config->desc.bNumInterfaces; i++) {
2779                 uif = udev->config->interface[i];
2780                 if (uif->altsetting[0].desc.bInterfaceClass == USB_CLASS_AUDIO) {
2781                         dev->has_audio_class = 1;
2782                         break;
2783                 }
2784         }
2785
2786         /* compute alternate max packet sizes */
2787         uif = udev->actconfig->interface[0];
2788
2789         dev->num_alt = uif->num_altsetting;
2790         dev->alt_max_pkt_size = kmalloc(32 * dev->num_alt, GFP_KERNEL);
2791
2792         if (dev->alt_max_pkt_size == NULL) {
2793                 em28xx_errdev("out of memory!\n");
2794                 em28xx_devused &= ~(1<<nr);
2795                 kfree(dev);
2796                 retval = -ENOMEM;
2797                 goto err;
2798         }
2799
2800         for (i = 0; i < dev->num_alt ; i++) {
2801                 u16 tmp = le16_to_cpu(uif->altsetting[i].endpoint[isoc_pipe].desc.wMaxPacketSize);
2802                 dev->alt_max_pkt_size[i] =
2803                     (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1);
2804         }
2805
2806         if ((card[nr] >= 0) && (card[nr] < em28xx_bcount))
2807                 dev->model = card[nr];
2808
2809         /* allocate device struct */
2810         mutex_init(&dev->lock);
2811         mutex_lock(&dev->lock);
2812         retval = em28xx_init_dev(&dev, udev, interface, nr);
2813         if (retval) {
2814                 em28xx_devused &= ~(1<<dev->devno);
2815                 mutex_unlock(&dev->lock);
2816                 kfree(dev);
2817                 goto err;
2818         }
2819
2820         /* save our data pointer in this interface device */
2821         usb_set_intfdata(interface, dev);
2822
2823         request_modules(dev);
2824
2825         /* Should be the last thing to do, to avoid newer udev's to
2826            open the device before fully initializing it
2827          */
2828         mutex_unlock(&dev->lock);
2829
2830         return 0;
2831
2832 err:
2833         return retval;
2834 }
2835
2836 /*
2837  * em28xx_usb_disconnect()
2838  * called when the device gets diconencted
2839  * video device will be unregistered on v4l2_close in case it is still open
2840  */
2841 static void em28xx_usb_disconnect(struct usb_interface *interface)
2842 {
2843         struct em28xx *dev;
2844
2845         dev = usb_get_intfdata(interface);
2846         usb_set_intfdata(interface, NULL);
2847
2848         if (!dev)
2849                 return;
2850
2851         em28xx_info("disconnecting %s\n", dev->vdev->name);
2852
2853         /* wait until all current v4l2 io is finished then deallocate
2854            resources */
2855         mutex_lock(&dev->lock);
2856
2857         wake_up_interruptible_all(&dev->open);
2858
2859         v4l2_device_disconnect(&dev->v4l2_dev);
2860
2861         if (dev->users) {
2862                 em28xx_warn
2863                     ("device /dev/video%d is open! Deregistration and memory "
2864                      "deallocation are deferred on close.\n",
2865                                 dev->vdev->num);
2866
2867                 dev->state |= DEV_MISCONFIGURED;
2868                 em28xx_uninit_isoc(dev);
2869                 dev->state |= DEV_DISCONNECTED;
2870                 wake_up_interruptible(&dev->wait_frame);
2871                 wake_up_interruptible(&dev->wait_stream);
2872         } else {
2873                 dev->state |= DEV_DISCONNECTED;
2874                 em28xx_release_resources(dev);
2875         }
2876
2877         em28xx_close_extension(dev);
2878
2879         mutex_unlock(&dev->lock);
2880
2881         if (!dev->users) {
2882                 kfree(dev->alt_max_pkt_size);
2883                 kfree(dev);
2884         }
2885 }
2886
2887 static struct usb_driver em28xx_usb_driver = {
2888         .name = "em28xx",
2889         .probe = em28xx_usb_probe,
2890         .disconnect = em28xx_usb_disconnect,
2891         .id_table = em28xx_id_table,
2892 };
2893
2894 static int __init em28xx_module_init(void)
2895 {
2896         int result;
2897
2898         /* register this driver with the USB subsystem */
2899         result = usb_register(&em28xx_usb_driver);
2900         if (result)
2901                 em28xx_err(DRIVER_NAME
2902                            " usb_register failed. Error number %d.\n", result);
2903
2904         printk(KERN_INFO DRIVER_NAME " driver loaded\n");
2905
2906         return result;
2907 }
2908
2909 static void __exit em28xx_module_exit(void)
2910 {
2911         /* deregister this driver with the USB subsystem */
2912         usb_deregister(&em28xx_usb_driver);
2913 }
2914
2915 module_init(em28xx_module_init);
2916 module_exit(em28xx_module_exit);