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