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