xref: /openbmc/linux/drivers/media/usb/em28xx/em28xx-cards.c (revision 5ef12cb4a3a78ffb331c03a795a15eea4ae35155)
1 // SPDX-License-Identifier: GPL-2.0+
2 //
3 // em28xx-cards.c - driver for Empia EM2800/EM2820/2840 USB
4 //		    video capture devices
5 //
6 // Copyright (C) 2005 Ludovico Cavedon <cavedon@sssup.it>
7 //		      Markus Rechberger <mrechberger@gmail.com>
8 //		      Mauro Carvalho Chehab <mchehab@kernel.org>
9 //		      Sascha Sommer <saschasommer@freenet.de>
10 // Copyright (C) 2012 Frank Schäfer <fschaefer.oss@googlemail.com>
11 //
12 // This program is free software; you can redistribute it and/or modify
13 // it under the terms of the GNU General Public License as published by
14 // the Free Software Foundation; either version 2 of the License, or
15 // (at your option) any later version.
16 //
17 // This program is distributed in the hope that it will be useful,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20 // GNU General Public License for more details.
21 
22 #include "em28xx.h"
23 
24 #include <linux/init.h>
25 #include <linux/module.h>
26 #include <linux/slab.h>
27 #include <linux/delay.h>
28 #include <linux/i2c.h>
29 #include <linux/usb.h>
30 #include <media/tuner.h>
31 #include <media/drv-intf/msp3400.h>
32 #include <media/i2c/saa7115.h>
33 #include <dt-bindings/media/tvp5150.h>
34 #include <media/i2c/tvaudio.h>
35 #include <media/tveeprom.h>
36 #include <media/v4l2-common.h>
37 #include <sound/ac97_codec.h>
38 
39 #define DRIVER_NAME         "em28xx"
40 
41 static int tuner = -1;
42 module_param(tuner, int, 0444);
43 MODULE_PARM_DESC(tuner, "tuner type");
44 
45 static unsigned int disable_ir;
46 module_param(disable_ir, int, 0444);
47 MODULE_PARM_DESC(disable_ir, "disable infrared remote support");
48 
49 static unsigned int disable_usb_speed_check;
50 module_param(disable_usb_speed_check, int, 0444);
51 MODULE_PARM_DESC(disable_usb_speed_check,
52 		 "override min bandwidth requirement of 480M bps");
53 
54 static unsigned int card[]     = {[0 ... (EM28XX_MAXBOARDS - 1)] = -1U };
55 module_param_array(card,  int, NULL, 0444);
56 MODULE_PARM_DESC(card,     "card type");
57 
58 static int usb_xfer_mode = -1;
59 module_param(usb_xfer_mode, int, 0444);
60 MODULE_PARM_DESC(usb_xfer_mode,
61 		 "USB transfer mode for frame data (-1 = auto, 0 = prefer isoc, 1 = prefer bulk)");
62 
63 /* Bitmask marking allocated devices from 0 to EM28XX_MAXBOARDS - 1 */
64 static DECLARE_BITMAP(em28xx_devused, EM28XX_MAXBOARDS);
65 
66 struct em28xx_hash_table {
67 	unsigned long hash;
68 	unsigned int  model;
69 	unsigned int  tuner;
70 };
71 
72 static void em28xx_pre_card_setup(struct em28xx *dev);
73 
74 /*
75  *  Reset sequences for analog/digital modes
76  */
77 
78 /* Reset for the most [analog] boards */
79 static const struct em28xx_reg_seq default_analog[] = {
80 	{EM2820_R08_GPIO_CTRL,	0x6d,   ~EM_GPIO_4,	10},
81 	{	-1,		-1,	-1,		-1},
82 };
83 
84 /* Reset for the most [digital] boards */
85 static const struct em28xx_reg_seq default_digital[] = {
86 	{EM2820_R08_GPIO_CTRL,	0x6e,	~EM_GPIO_4,	10},
87 	{	-1,		-1,	-1,		-1},
88 };
89 
90 /* Board Hauppauge WinTV HVR 900 analog */
91 static const struct em28xx_reg_seq hauppauge_wintv_hvr_900_analog[] = {
92 	{EM2820_R08_GPIO_CTRL,	0x2d,	~EM_GPIO_4,	10},
93 	{	0x05,		0xff,	0x10,		10},
94 	{	-1,		-1,	-1,		-1},
95 };
96 
97 /* Board Hauppauge WinTV HVR 900 digital */
98 static const struct em28xx_reg_seq hauppauge_wintv_hvr_900_digital[] = {
99 	{EM2820_R08_GPIO_CTRL,	0x2e,	~EM_GPIO_4,	10},
100 	{EM2880_R04_GPO,	0x04,	0x0f,		10},
101 	{EM2880_R04_GPO,	0x0c,	0x0f,		10},
102 	{	-1,		-1,	-1,		-1},
103 };
104 
105 /* Board Hauppauge WinTV HVR 900 (R2) digital */
106 static const struct em28xx_reg_seq hauppauge_wintv_hvr_900R2_digital[] = {
107 	{EM2820_R08_GPIO_CTRL,	0x2e,	~EM_GPIO_4,	10},
108 	{EM2880_R04_GPO,	0x0c,	0x0f,		10},
109 	{	-1,		-1,	-1,		-1},
110 };
111 
112 /* Boards - EM2880 MSI DIGIVOX AD and EM2880_BOARD_MSI_DIGIVOX_AD_II */
113 static const struct em28xx_reg_seq em2880_msi_digivox_ad_analog[] = {
114 	{EM2820_R08_GPIO_CTRL,	0x69,   ~EM_GPIO_4,	10},
115 	{	-1,		-1,	-1,		-1},
116 };
117 
118 /* Board - EM2882 Kworld 315U digital */
119 static const struct em28xx_reg_seq em2882_kworld_315u_digital[] = {
120 	{EM2820_R08_GPIO_CTRL,	0xff,	0xff,		10},
121 	{EM2820_R08_GPIO_CTRL,	0xfe,	0xff,		10},
122 	{EM2880_R04_GPO,	0x04,	0xff,		10},
123 	{EM2880_R04_GPO,	0x0c,	0xff,		10},
124 	{EM2820_R08_GPIO_CTRL,	0x7e,	0xff,		10},
125 	{	-1,		-1,	-1,		-1},
126 };
127 
128 static const struct em28xx_reg_seq em2882_kworld_315u_tuner_gpio[] = {
129 	{EM2880_R04_GPO,	0x08,	0xff,		10},
130 	{EM2880_R04_GPO,	0x0c,	0xff,		10},
131 	{EM2880_R04_GPO,	0x08,	0xff,		10},
132 	{EM2880_R04_GPO,	0x0c,	0xff,		10},
133 	{	-1,		-1,	-1,		-1},
134 };
135 
136 static const struct em28xx_reg_seq kworld_330u_analog[] = {
137 	{EM2820_R08_GPIO_CTRL,	0x6d,	~EM_GPIO_4,	10},
138 	{EM2880_R04_GPO,	0x00,	0xff,		10},
139 	{	-1,		-1,	-1,		-1},
140 };
141 
142 static const struct em28xx_reg_seq kworld_330u_digital[] = {
143 	{EM2820_R08_GPIO_CTRL,	0x6e,	~EM_GPIO_4,	10},
144 	{EM2880_R04_GPO,	0x08,	0xff,		10},
145 	{	-1,		-1,	-1,		-1},
146 };
147 
148 /*
149  * Evga inDtube
150  * GPIO0 - Enable digital power (s5h1409) - low to enable
151  * GPIO1 - Enable analog power (tvp5150/emp202) - low to enable
152  * GPIO4 - xc3028 reset
153  * GOP3  - s5h1409 reset
154  */
155 static const struct em28xx_reg_seq evga_indtube_analog[] = {
156 	{EM2820_R08_GPIO_CTRL,	0x79,   0xff,		60},
157 	{	-1,		-1,	-1,		-1},
158 };
159 
160 static const struct em28xx_reg_seq evga_indtube_digital[] = {
161 	{EM2820_R08_GPIO_CTRL,	0x7a,	0xff,		 1},
162 	{EM2880_R04_GPO,	0x04,	0xff,		10},
163 	{EM2880_R04_GPO,	0x0c,	0xff,		 1},
164 	{	-1,		-1,	-1,		-1},
165 };
166 
167 /*
168  * KWorld PlusTV 340U, UB435-Q and UB435-Q V2 (ATSC) GPIOs map:
169  * EM_GPIO_0 - currently unknown
170  * EM_GPIO_1 - LED disable/enable (1 = off, 0 = on)
171  * EM_GPIO_2 - currently unknown
172  * EM_GPIO_3 - currently unknown
173  * EM_GPIO_4 - TDA18271HD/C1 tuner (1 = active, 0 = in reset)
174  * EM_GPIO_5 - LGDT3304 ATSC/QAM demod (1 = active, 0 = in reset)
175  * EM_GPIO_6 - currently unknown
176  * EM_GPIO_7 - currently unknown
177  */
178 static const struct em28xx_reg_seq kworld_a340_digital[] = {
179 	{EM2820_R08_GPIO_CTRL,	0x6d,	~EM_GPIO_4,	10},
180 	{	-1,		-1,	-1,		-1},
181 };
182 
183 static const struct em28xx_reg_seq kworld_ub435q_v3_digital[] = {
184 	{EM2874_R80_GPIO_P0_CTRL,	0xff,	0xff,	100},
185 	{EM2874_R80_GPIO_P0_CTRL,	0xfe,	0xff,	100},
186 	{EM2874_R80_GPIO_P0_CTRL,	0xbe,	0xff,	100},
187 	{EM2874_R80_GPIO_P0_CTRL,	0xfe,	0xff,	100},
188 	{	-1,			-1,	-1,	-1},
189 };
190 
191 /* Pinnacle Hybrid Pro eb1a:2881 */
192 static const struct em28xx_reg_seq pinnacle_hybrid_pro_analog[] = {
193 	{EM2820_R08_GPIO_CTRL,	0xfd,   ~EM_GPIO_4,	10},
194 	{	-1,		-1,	-1,		-1},
195 };
196 
197 static const struct em28xx_reg_seq pinnacle_hybrid_pro_digital[] = {
198 	{EM2820_R08_GPIO_CTRL,	0x6e,	~EM_GPIO_4,	10},
199 	{EM2880_R04_GPO,	0x04,	0xff,	       100},/* zl10353 reset */
200 	{EM2880_R04_GPO,	0x0c,	0xff,		 1},
201 	{	-1,		-1,	-1,		-1},
202 };
203 
204 static const struct em28xx_reg_seq terratec_cinergy_USB_XS_FR_analog[] = {
205 	{EM2820_R08_GPIO_CTRL,	0x6d,	~EM_GPIO_4,	10},
206 	{EM2880_R04_GPO,	0x00,	0xff,		10},
207 	{	-1,		-1,	-1,		-1},
208 };
209 
210 static const struct em28xx_reg_seq terratec_cinergy_USB_XS_FR_digital[] = {
211 	{EM2820_R08_GPIO_CTRL,	0x6e,	~EM_GPIO_4,	10},
212 	{EM2880_R04_GPO,	0x08,	0xff,		10},
213 	{	-1,		-1,	-1,		-1},
214 };
215 
216 /*
217  * PCTV HD Mini (80e) GPIOs
218  * 0-5: not used
219  * 6:   demod reset, active low
220  * 7:   LED on, active high
221  */
222 static const struct em28xx_reg_seq em2874_pctv_80e_digital[] = {
223 	{EM28XX_R06_I2C_CLK,    0x45,   0xff,		  10}, /*400 KHz*/
224 	{EM2874_R80_GPIO_P0_CTRL, 0x00,   0xff,		  100},/*Demod reset*/
225 	{EM2874_R80_GPIO_P0_CTRL, 0x40,   0xff,		  10},
226 	{  -1,			-1,	-1,		  -1},
227 };
228 
229 /*
230  * eb1a:2868 Reddo DVB-C USB TV Box
231  * GPIO4 - CU1216L NIM
232  * Other GPIOs seems to be don't care.
233  */
234 static const struct em28xx_reg_seq reddo_dvb_c_usb_box[] = {
235 	{EM2820_R08_GPIO_CTRL,	0xfe,	0xff,		10},
236 	{EM2820_R08_GPIO_CTRL,	0xde,	0xff,		10},
237 	{EM2820_R08_GPIO_CTRL,	0xfe,	0xff,		10},
238 	{EM2820_R08_GPIO_CTRL,	0xff,	0xff,		10},
239 	{EM2820_R08_GPIO_CTRL,	0x7f,	0xff,		10},
240 	{EM2820_R08_GPIO_CTRL,	0x6f,	0xff,		10},
241 	{EM2820_R08_GPIO_CTRL,	0xff,	0xff,		10},
242 	{	-1,		-1,	-1,		-1},
243 };
244 
245 /* Callback for the most boards */
246 static const struct em28xx_reg_seq default_tuner_gpio[] = {
247 	{EM2820_R08_GPIO_CTRL,	EM_GPIO_4,	EM_GPIO_4,	10},
248 	{EM2820_R08_GPIO_CTRL,	0,		EM_GPIO_4,	10},
249 	{EM2820_R08_GPIO_CTRL,	EM_GPIO_4,	EM_GPIO_4,	10},
250 	{	-1,		-1,		-1,		-1},
251 };
252 
253 /* Mute/unmute */
254 static const struct em28xx_reg_seq compro_unmute_tv_gpio[] = {
255 	{EM2820_R08_GPIO_CTRL,	5,	7,	10},
256 	{	-1,		-1,	-1,	-1},
257 };
258 
259 static const struct em28xx_reg_seq compro_unmute_svid_gpio[] = {
260 	{EM2820_R08_GPIO_CTRL,	4,	7,	10},
261 	{	-1,		-1,	-1,	-1},
262 };
263 
264 static const struct em28xx_reg_seq compro_mute_gpio[] = {
265 	{EM2820_R08_GPIO_CTRL,	6,	7,	10},
266 	{	-1,		-1,	-1,	-1},
267 };
268 
269 /* Terratec AV350 */
270 static const struct em28xx_reg_seq terratec_av350_mute_gpio[] = {
271 	{EM2820_R08_GPIO_CTRL,	0xff,	0x7f,		10},
272 	{	-1,		-1,	-1,		-1},
273 };
274 
275 static const struct em28xx_reg_seq terratec_av350_unmute_gpio[] = {
276 	{EM2820_R08_GPIO_CTRL,	0xff,	0xff,		10},
277 	{	-1,		-1,	-1,		-1},
278 };
279 
280 static const struct em28xx_reg_seq silvercrest_reg_seq[] = {
281 	{EM2820_R08_GPIO_CTRL,	0xff,	0xff,		10},
282 	{EM2820_R08_GPIO_CTRL,	0x01,	0xf7,		10},
283 	{	-1,		-1,	-1,		-1},
284 };
285 
286 static const struct em28xx_reg_seq vc211a_enable[] = {
287 	{EM2820_R08_GPIO_CTRL,	0xff,	0x07,		10},
288 	{EM2820_R08_GPIO_CTRL,	0xff,	0x0f,		10},
289 	{EM2820_R08_GPIO_CTRL,	0xff,	0x0b,		10},
290 	{	-1,		-1,	-1,		-1},
291 };
292 
293 static const struct em28xx_reg_seq dikom_dk300_digital[] = {
294 	{EM2820_R08_GPIO_CTRL,	0x6e,	~EM_GPIO_4,	10},
295 	{EM2880_R04_GPO,	0x08,	0xff,		10},
296 	{	-1,		-1,	-1,		-1},
297 };
298 
299 /* Reset for the most [digital] boards */
300 static const struct em28xx_reg_seq leadership_digital[] = {
301 	{EM2874_R80_GPIO_P0_CTRL,	0x70,	0xff,	10},
302 	{	-1,			-1,	-1,	-1},
303 };
304 
305 static const struct em28xx_reg_seq leadership_reset[] = {
306 	{EM2874_R80_GPIO_P0_CTRL,	0xf0,	0xff,	10},
307 	{EM2874_R80_GPIO_P0_CTRL,	0xb0,	0xff,	10},
308 	{EM2874_R80_GPIO_P0_CTRL,	0xf0,	0xff,	10},
309 	{	-1,			-1,	-1,	-1},
310 };
311 
312 /*
313  * 2013:024f PCTV nanoStick T2 290e
314  * GPIO_6 - demod reset
315  * GPIO_7 - LED
316  */
317 static const struct em28xx_reg_seq pctv_290e[] = {
318 	{EM2874_R80_GPIO_P0_CTRL,	0x00,	0xff,	80},
319 	{EM2874_R80_GPIO_P0_CTRL,	0x40,	0xff,	80}, /* GPIO_6 = 1 */
320 	{EM2874_R80_GPIO_P0_CTRL,	0xc0,	0xff,	80}, /* GPIO_7 = 1 */
321 	{	-1,			-1,	-1,	-1},
322 };
323 
324 #if 0
325 static const struct em28xx_reg_seq terratec_h5_gpio[] = {
326 	{EM2820_R08_GPIO_CTRL,		0xff,	0xff,	10},
327 	{EM2874_R80_GPIO_P0_CTRL,	0xf6,	0xff,	100},
328 	{EM2874_R80_GPIO_P0_CTRL,	0xf2,	0xff,	50},
329 	{EM2874_R80_GPIO_P0_CTRL,	0xf6,	0xff,	50},
330 	{	-1,			-1,	-1,	-1},
331 };
332 
333 static const struct em28xx_reg_seq terratec_h5_digital[] = {
334 	{EM2874_R80_GPIO_P0_CTRL,	0xf6,	0xff,	10},
335 	{EM2874_R80_GPIO_P0_CTRL,	0xe6,	0xff,	100},
336 	{EM2874_R80_GPIO_P0_CTRL,	0xa6,	0xff,	10},
337 	{	-1,			-1,	-1,	-1},
338 };
339 #endif
340 
341 /*
342  * 2013:024f PCTV DVB-S2 Stick 460e
343  * GPIO_0 - POWER_ON
344  * GPIO_1 - BOOST
345  * GPIO_2 - VUV_LNB (red LED)
346  * GPIO_3 - EXT_12V
347  * GPIO_4 - INT_DEM (DEMOD GPIO_0)
348  * GPIO_5 - INT_LNB
349  * GPIO_6 - RESET_DEM
350  * GPIO_7 - LED (green LED)
351  */
352 static const struct em28xx_reg_seq pctv_460e[] = {
353 	{EM2874_R80_GPIO_P0_CTRL,	0x01,	0xff,	50},
354 	{	0x0d,			0xff,	0xff,	50},
355 	{EM2874_R80_GPIO_P0_CTRL,	0x41,	0xff,	50}, /* GPIO_6=1 */
356 	{	0x0d,			0x42,	0xff,	50},
357 	{EM2874_R80_GPIO_P0_CTRL,	0x61,	0xff,	50}, /* GPIO_5=1 */
358 	{	-1,			-1,	-1,	-1},
359 };
360 
361 static const struct em28xx_reg_seq c3tech_digital_duo_digital[] = {
362 	{EM2874_R80_GPIO_P0_CTRL,	0xff,	0xff,	10},
363 	{EM2874_R80_GPIO_P0_CTRL,	0xfd,	0xff,	10}, /* xc5000 reset */
364 	{EM2874_R80_GPIO_P0_CTRL,	0xf9,	0xff,	35},
365 	{EM2874_R80_GPIO_P0_CTRL,	0xfd,	0xff,	10},
366 	{EM2874_R80_GPIO_P0_CTRL,	0xff,	0xff,	10},
367 	{EM2874_R80_GPIO_P0_CTRL,	0xfe,	0xff,	10},
368 	{EM2874_R80_GPIO_P0_CTRL,	0xbe,	0xff,	10},
369 	{EM2874_R80_GPIO_P0_CTRL,	0xfe,	0xff,	20},
370 	{	-1,			-1,	-1,	-1},
371 };
372 
373 /*
374  * 2013:0258 PCTV DVB-S2 Stick (461e)
375  * GPIO 0 = POWER_ON
376  * GPIO 1 = BOOST
377  * GPIO 2 = VUV_LNB (red LED)
378  * GPIO 3 = #EXT_12V
379  * GPIO 4 = INT_DEM
380  * GPIO 5 = INT_LNB
381  * GPIO 6 = #RESET_DEM
382  * GPIO 7 = P07_LED (green LED)
383  */
384 static const struct em28xx_reg_seq pctv_461e[] = {
385 	{EM2874_R80_GPIO_P0_CTRL,      0x7f, 0xff,    0},
386 	{0x0d,                 0xff, 0xff,    0},
387 	{EM2874_R80_GPIO_P0_CTRL,      0x3f, 0xff,  100}, /* reset demod */
388 	{EM2874_R80_GPIO_P0_CTRL,      0x7f, 0xff,  200}, /* reset demod */
389 	{0x0d,                 0x42, 0xff,    0},
390 	{EM2874_R80_GPIO_P0_CTRL,      0xeb, 0xff,    0},
391 	{EM2874_R5F_TS_ENABLE, 0x84, 0x84,    0}, /* parallel? | null discard */
392 	{                  -1,   -1,   -1,   -1},
393 };
394 
395 #if 0
396 static const struct em28xx_reg_seq hauppauge_930c_gpio[] = {
397 	{EM2874_R80_GPIO_P0_CTRL,	0x6f,	0xff,	10},
398 	{EM2874_R80_GPIO_P0_CTRL,	0x4f,	0xff,	10}, /* xc5000 reset */
399 	{EM2874_R80_GPIO_P0_CTRL,	0x6f,	0xff,	10},
400 	{EM2874_R80_GPIO_P0_CTRL,	0x4f,	0xff,	10},
401 	{	-1,			-1,	-1,	-1},
402 };
403 
404 static const struct em28xx_reg_seq hauppauge_930c_digital[] = {
405 	{EM2874_R80_GPIO_P0_CTRL,	0xf6,	0xff,	10},
406 	{EM2874_R80_GPIO_P0_CTRL,	0xe6,	0xff,	100},
407 	{EM2874_R80_GPIO_P0_CTRL,	0xa6,	0xff,	10},
408 	{	-1,			-1,	-1,	-1},
409 };
410 #endif
411 
412 /*
413  * 1b80:e425 MaxMedia UB425-TC
414  * 1b80:e1cc Delock 61959
415  * GPIO_6 - demod reset, 0=active
416  * GPIO_7 - LED, 0=active
417  */
418 static const struct em28xx_reg_seq maxmedia_ub425_tc[] = {
419 	{EM2874_R80_GPIO_P0_CTRL,	0x83,	0xff,	100},
420 	{EM2874_R80_GPIO_P0_CTRL,	0xc3,	0xff,	100}, /* GPIO_6 = 1 */
421 	{EM2874_R80_GPIO_P0_CTRL,	0x43,	0xff,	000}, /* GPIO_7 = 0 */
422 	{	-1,			-1,	-1,	-1},
423 };
424 
425 /*
426  * 2304:0242 PCTV QuatroStick (510e)
427  * GPIO_2: decoder reset, 0=active
428  * GPIO_4: decoder suspend, 0=active
429  * GPIO_6: demod reset, 0=active
430  * GPIO_7: LED, 1=active
431  */
432 static const struct em28xx_reg_seq pctv_510e[] = {
433 	{EM2874_R80_GPIO_P0_CTRL,	0x10,	0xff,	100},
434 	{EM2874_R80_GPIO_P0_CTRL,	0x14,	0xff,	100}, /* GPIO_2 = 1 */
435 	{EM2874_R80_GPIO_P0_CTRL,	0x54,	0xff,	050}, /* GPIO_6 = 1 */
436 	{	-1,			-1,	-1,	-1},
437 };
438 
439 /*
440  * 2013:0251 PCTV QuatroStick nano (520e)
441  * GPIO_2: decoder reset, 0=active
442  * GPIO_4: decoder suspend, 0=active
443  * GPIO_6: demod reset, 0=active
444  * GPIO_7: LED, 1=active
445  */
446 static const struct em28xx_reg_seq pctv_520e[] = {
447 	{EM2874_R80_GPIO_P0_CTRL,	0x10,	0xff,	100},
448 	{EM2874_R80_GPIO_P0_CTRL,	0x14,	0xff,	100}, /* GPIO_2 = 1 */
449 	{EM2874_R80_GPIO_P0_CTRL,	0x54,	0xff,	050}, /* GPIO_6 = 1 */
450 	{EM2874_R80_GPIO_P0_CTRL,	0xd4,	0xff,	000}, /* GPIO_7 = 1 */
451 	{	-1,			-1,	-1,	-1},
452 };
453 
454 /*
455  * 1ae7:9003/9004 SpeedLink Vicious And Devine Laplace webcam
456  * reg 0x80/0x84:
457  * GPIO_0: capturing LED, 0=on, 1=off
458  * GPIO_2: AV mute button, 0=pressed, 1=unpressed
459  * GPIO 3: illumination button, 0=pressed, 1=unpressed
460  * GPIO_6: illumination/flash LED, 0=on, 1=off
461  * reg 0x81/0x85:
462  * GPIO_7: snapshot button, 0=pressed, 1=unpressed
463  */
464 static const struct em28xx_reg_seq speedlink_vad_laplace_reg_seq[] = {
465 	{EM2820_R08_GPIO_CTRL,		0xf7,	0xff,	10},
466 	{EM2874_R80_GPIO_P0_CTRL,	0xff,	0xb2,	10},
467 	{	-1,			-1,	-1,	-1},
468 };
469 
470 static const struct em28xx_reg_seq pctv_292e[] = {
471 	{EM2874_R80_GPIO_P0_CTRL,      0xff, 0xff,      0},
472 	{0x0d,                         0xff, 0xff,    950},
473 	{EM2874_R80_GPIO_P0_CTRL,      0xbd, 0xff,    100},
474 	{EM2874_R80_GPIO_P0_CTRL,      0xfd, 0xff,    410},
475 	{EM2874_R80_GPIO_P0_CTRL,      0x7d, 0xff,    300},
476 	{EM2874_R80_GPIO_P0_CTRL,      0x7c, 0xff,     60},
477 	{0x0d,                         0x42, 0xff,     50},
478 	{EM2874_R5F_TS_ENABLE,         0x85, 0xff,      0},
479 	{-1,                             -1,   -1,     -1},
480 };
481 
482 static const struct em28xx_reg_seq terratec_t2_stick_hd[] = {
483 	{EM2874_R80_GPIO_P0_CTRL,	0xff,	0xff,	0},
484 	{0x0d,				0xff,	0xff,	600},
485 	{EM2874_R80_GPIO_P0_CTRL,	0xfc,	0xff,	10},
486 	{EM2874_R80_GPIO_P0_CTRL,	0xbc,	0xff,	100},
487 	{EM2874_R80_GPIO_P0_CTRL,	0xfc,	0xff,	100},
488 	{EM2874_R80_GPIO_P0_CTRL,	0x00,	0xff,	300},
489 	{EM2874_R80_GPIO_P0_CTRL,	0xf8,	0xff,	100},
490 	{EM2874_R80_GPIO_P0_CTRL,	0xfc,	0xff,	300},
491 	{0x0d,				0x42,	0xff,	1000},
492 	{EM2874_R5F_TS_ENABLE,		0x85,	0xff,	0},
493 	{-1,                             -1,   -1,     -1},
494 };
495 
496 static const struct em28xx_reg_seq plex_px_bcud[] = {
497 	{EM2874_R80_GPIO_P0_CTRL,	0xff,	0xff,	0},
498 	{0x0d,				0xff,	0xff,	0},
499 	{EM2874_R50_IR_CONFIG,		0x01,	0xff,	0},
500 	{EM28XX_R06_I2C_CLK,		0x40,	0xff,	0},
501 	{EM2874_R80_GPIO_P0_CTRL,	0xfd,	0xff,	100},
502 	{EM28XX_R12_VINENABLE,		0x20,	0x20,	0},
503 	{0x0d,				0x42,	0xff,	1000},
504 	{EM2874_R80_GPIO_P0_CTRL,	0xfc,	0xff,	10},
505 	{EM2874_R80_GPIO_P0_CTRL,	0xfd,	0xff,	10},
506 	{0x73,				0xfd,	0xff,	100},
507 	{-1,				-1,	-1,	-1},
508 };
509 
510 /*
511  * 2040:0265 Hauppauge WinTV-dualHD DVB Isoc
512  * 2040:8265 Hauppauge WinTV-dualHD DVB Bulk
513  * 2040:026d Hauppauge WinTV-dualHD ATSC/QAM Isoc
514  * 2040:826d Hauppauge WinTV-dualHD ATSC/QAM Bulk
515  * reg 0x80/0x84:
516  * GPIO_0: Yellow LED tuner 1, 0=on, 1=off
517  * GPIO_1: Green LED tuner 1, 0=on, 1=off
518  * GPIO_2: Yellow LED tuner 2, 0=on, 1=off
519  * GPIO_3: Green LED tuner 2, 0=on, 1=off
520  * GPIO_5: Reset #2, 0=active
521  * GPIO_6: Reset #1, 0=active
522  */
523 static const struct em28xx_reg_seq hauppauge_dualhd_dvb[] = {
524 	{EM2874_R80_GPIO_P0_CTRL,      0xff, 0xff,      0},
525 	{0x0d,                         0xff, 0xff,    200},
526 	{0x50,                         0x04, 0xff,    300},
527 	{EM2874_R80_GPIO_P0_CTRL,      0xbf, 0xff,    100}, /* demod 1 reset */
528 	{EM2874_R80_GPIO_P0_CTRL,      0xff, 0xff,    100},
529 	{EM2874_R80_GPIO_P0_CTRL,      0xdf, 0xff,    100}, /* demod 2 reset */
530 	{EM2874_R80_GPIO_P0_CTRL,      0xff, 0xff,    100},
531 	{EM2874_R5F_TS_ENABLE,         0x44, 0xff,     50},
532 	{EM2874_R5D_TS1_PKT_SIZE,      0x05, 0xff,     50},
533 	{EM2874_R5E_TS2_PKT_SIZE,      0x05, 0xff,     50},
534 	{-1,                             -1,   -1,     -1},
535 };
536 
537 /*
538  *  Button definitions
539  */
540 static const struct em28xx_button std_snapshot_button[] = {
541 	{
542 		.role         = EM28XX_BUTTON_SNAPSHOT,
543 		.reg_r        = EM28XX_R0C_USBSUSP,
544 		.reg_clearing = EM28XX_R0C_USBSUSP,
545 		.mask         = EM28XX_R0C_USBSUSP_SNAPSHOT,
546 		.inverted     = 0,
547 	},
548 	{-1, 0, 0, 0, 0},
549 };
550 
551 static const struct em28xx_button speedlink_vad_laplace_buttons[] = {
552 	{
553 		.role     = EM28XX_BUTTON_SNAPSHOT,
554 		.reg_r    = EM2874_R85_GPIO_P1_STATE,
555 		.mask     = 0x80,
556 		.inverted = 1,
557 	},
558 	{
559 		.role     = EM28XX_BUTTON_ILLUMINATION,
560 		.reg_r    = EM2874_R84_GPIO_P0_STATE,
561 		.mask     = 0x08,
562 		.inverted = 1,
563 	},
564 	{-1, 0, 0, 0, 0},
565 };
566 
567 /*
568  *  LED definitions
569  */
570 static struct em28xx_led speedlink_vad_laplace_leds[] = {
571 	{
572 		.role      = EM28XX_LED_ANALOG_CAPTURING,
573 		.gpio_reg  = EM2874_R80_GPIO_P0_CTRL,
574 		.gpio_mask = 0x01,
575 		.inverted  = 1,
576 	},
577 	{
578 		.role      = EM28XX_LED_ILLUMINATION,
579 		.gpio_reg  = EM2874_R80_GPIO_P0_CTRL,
580 		.gpio_mask = 0x40,
581 		.inverted  = 1,
582 	},
583 	{-1, 0, 0, 0},
584 };
585 
586 static struct em28xx_led kworld_ub435q_v3_leds[] = {
587 	{
588 		.role      = EM28XX_LED_DIGITAL_CAPTURING,
589 		.gpio_reg  = EM2874_R80_GPIO_P0_CTRL,
590 		.gpio_mask = 0x80,
591 		.inverted  = 1,
592 	},
593 	{-1, 0, 0, 0},
594 };
595 
596 static struct em28xx_led pctv_80e_leds[] = {
597 	{
598 		.role      = EM28XX_LED_DIGITAL_CAPTURING,
599 		.gpio_reg  = EM2874_R80_GPIO_P0_CTRL,
600 		.gpio_mask = 0x80,
601 		.inverted  = 0,
602 	},
603 	{-1, 0, 0, 0},
604 };
605 
606 static struct em28xx_led terratec_grabby_leds[] = {
607 	{
608 		.role      = EM28XX_LED_ANALOG_CAPTURING,
609 		.gpio_reg  = EM2820_R08_GPIO_CTRL,
610 		.gpio_mask = EM_GPIO_3,
611 		.inverted  = 1,
612 	},
613 	{-1, 0, 0, 0},
614 };
615 
616 static struct em28xx_led hauppauge_dualhd_leds[] = {
617 	{
618 		.role      = EM28XX_LED_DIGITAL_CAPTURING,
619 		.gpio_reg  = EM2874_R80_GPIO_P0_CTRL,
620 		.gpio_mask = EM_GPIO_1,
621 		.inverted  = 1,
622 	},
623 	{
624 		.role      = EM28XX_LED_DIGITAL_CAPTURING_TS2,
625 		.gpio_reg  = EM2874_R80_GPIO_P0_CTRL,
626 		.gpio_mask = EM_GPIO_3,
627 		.inverted  = 1,
628 	},
629 	{-1, 0, 0, 0},
630 };
631 
632 /*
633  *  Board definitions
634  */
635 const struct em28xx_board em28xx_boards[] = {
636 	[EM2750_BOARD_UNKNOWN] = {
637 		.name          = "EM2710/EM2750/EM2751 webcam grabber",
638 		.xclk          = EM28XX_XCLK_FREQUENCY_20MHZ,
639 		.tuner_type    = TUNER_ABSENT,
640 		.is_webcam     = 1,
641 		.input         = { {
642 			.type     = EM28XX_VMUX_COMPOSITE,
643 			.vmux     = 0,
644 			.amux     = EM28XX_AMUX_VIDEO,
645 			.gpio     = silvercrest_reg_seq,
646 		} },
647 	},
648 	[EM2800_BOARD_UNKNOWN] = {
649 		.name         = "Unknown EM2800 video grabber",
650 		.is_em2800    = 1,
651 		.tda9887_conf = TDA9887_PRESENT,
652 		.decoder      = EM28XX_SAA711X,
653 		.tuner_type   = TUNER_ABSENT,
654 		.input        = { {
655 			.type     = EM28XX_VMUX_COMPOSITE,
656 			.vmux     = SAA7115_COMPOSITE0,
657 			.amux     = EM28XX_AMUX_LINE_IN,
658 		}, {
659 			.type     = EM28XX_VMUX_SVIDEO,
660 			.vmux     = SAA7115_SVIDEO3,
661 			.amux     = EM28XX_AMUX_LINE_IN,
662 		} },
663 	},
664 	[EM2820_BOARD_UNKNOWN] = {
665 		.name          = "Unknown EM2750/28xx video grabber",
666 		.tuner_type    = TUNER_ABSENT,
667 		.is_webcam     = 1,	/* To enable sensor probe */
668 	},
669 	[EM2750_BOARD_DLCW_130] = {
670 		/* Beijing Huaqi Information Digital Technology Co., Ltd */
671 		.name          = "Huaqi DLCW-130",
672 		.valid         = EM28XX_BOARD_NOT_VALIDATED,
673 		.xclk          = EM28XX_XCLK_FREQUENCY_48MHZ,
674 		.tuner_type    = TUNER_ABSENT,
675 		.is_webcam     = 1,
676 		.input         = { {
677 			.type     = EM28XX_VMUX_COMPOSITE,
678 			.vmux     = 0,
679 			.amux     = EM28XX_AMUX_VIDEO,
680 		} },
681 	},
682 	[EM2820_BOARD_KWORLD_PVRTV2800RF] = {
683 		.name         = "Kworld PVR TV 2800 RF",
684 		.tuner_type   = TUNER_TEMIC_PAL,
685 		.tda9887_conf = TDA9887_PRESENT,
686 		.decoder      = EM28XX_SAA711X,
687 		.input        = { {
688 			.type     = EM28XX_VMUX_COMPOSITE,
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 	[EM2820_BOARD_GADMEI_TVR200] = {
698 		.name         = "Gadmei TVR200",
699 		.tuner_type   = TUNER_LG_PAL_NEW_TAPC,
700 		.tda9887_conf = TDA9887_PRESENT,
701 		.decoder      = EM28XX_SAA711X,
702 		.input        = { {
703 			.type     = EM28XX_VMUX_TELEVISION,
704 			.vmux     = SAA7115_COMPOSITE2,
705 			.amux     = EM28XX_AMUX_LINE_IN,
706 		}, {
707 			.type     = EM28XX_VMUX_COMPOSITE,
708 			.vmux     = SAA7115_COMPOSITE0,
709 			.amux     = EM28XX_AMUX_LINE_IN,
710 		}, {
711 			.type     = EM28XX_VMUX_SVIDEO,
712 			.vmux     = SAA7115_SVIDEO3,
713 			.amux     = EM28XX_AMUX_LINE_IN,
714 		} },
715 	},
716 	[EM2820_BOARD_TERRATEC_CINERGY_250] = {
717 		.name         = "Terratec Cinergy 250 USB",
718 		.tuner_type   = TUNER_LG_PAL_NEW_TAPC,
719 		.has_ir_i2c   = 1,
720 		.tda9887_conf = TDA9887_PRESENT,
721 		.decoder      = EM28XX_SAA711X,
722 		.input        = { {
723 			.type     = EM28XX_VMUX_TELEVISION,
724 			.vmux     = SAA7115_COMPOSITE2,
725 			.amux     = EM28XX_AMUX_VIDEO,
726 		}, {
727 			.type     = EM28XX_VMUX_COMPOSITE,
728 			.vmux     = SAA7115_COMPOSITE0,
729 			.amux     = EM28XX_AMUX_LINE_IN,
730 		}, {
731 			.type     = EM28XX_VMUX_SVIDEO,
732 			.vmux     = SAA7115_SVIDEO3,
733 			.amux     = EM28XX_AMUX_LINE_IN,
734 		} },
735 	},
736 	[EM2820_BOARD_PINNACLE_USB_2] = {
737 		.name         = "Pinnacle PCTV USB 2",
738 		.tuner_type   = TUNER_LG_PAL_NEW_TAPC,
739 		.has_ir_i2c   = 1,
740 		.tda9887_conf = TDA9887_PRESENT,
741 		.decoder      = EM28XX_SAA711X,
742 		.input        = { {
743 			.type     = EM28XX_VMUX_TELEVISION,
744 			.vmux     = SAA7115_COMPOSITE2,
745 			.amux     = EM28XX_AMUX_VIDEO,
746 		}, {
747 			.type     = EM28XX_VMUX_COMPOSITE,
748 			.vmux     = SAA7115_COMPOSITE0,
749 			.amux     = EM28XX_AMUX_LINE_IN,
750 		}, {
751 			.type     = EM28XX_VMUX_SVIDEO,
752 			.vmux     = SAA7115_SVIDEO3,
753 			.amux     = EM28XX_AMUX_LINE_IN,
754 		} },
755 	},
756 	[EM2820_BOARD_HAUPPAUGE_WINTV_USB_2] = {
757 		.name         = "Hauppauge WinTV USB 2",
758 		.tuner_type   = TUNER_PHILIPS_FM1236_MK3,
759 		.tda9887_conf = TDA9887_PRESENT |
760 				TDA9887_PORT1_ACTIVE |
761 				TDA9887_PORT2_ACTIVE,
762 		.decoder      = EM28XX_TVP5150,
763 		.has_msp34xx  = 1,
764 		.has_ir_i2c   = 1,
765 		.input        = { {
766 			.type     = EM28XX_VMUX_TELEVISION,
767 			.vmux     = TVP5150_COMPOSITE0,
768 			.amux     = MSP_INPUT_DEFAULT,
769 		}, {
770 			.type     = EM28XX_VMUX_SVIDEO,
771 			.vmux     = TVP5150_SVIDEO,
772 			.amux     = MSP_INPUT(MSP_IN_SCART1, MSP_IN_TUNER1,
773 					MSP_DSP_IN_SCART, MSP_DSP_IN_SCART),
774 		} },
775 	},
776 	[EM2820_BOARD_DLINK_USB_TV] = {
777 		.name         = "D-Link DUB-T210 TV Tuner",
778 		.valid        = EM28XX_BOARD_NOT_VALIDATED,
779 		.tuner_type   = TUNER_LG_PAL_NEW_TAPC,
780 		.tda9887_conf = TDA9887_PRESENT,
781 		.decoder      = EM28XX_SAA711X,
782 		.input        = { {
783 			.type     = EM28XX_VMUX_TELEVISION,
784 			.vmux     = SAA7115_COMPOSITE2,
785 			.amux     = EM28XX_AMUX_LINE_IN,
786 		}, {
787 			.type     = EM28XX_VMUX_COMPOSITE,
788 			.vmux     = SAA7115_COMPOSITE0,
789 			.amux     = EM28XX_AMUX_LINE_IN,
790 		}, {
791 			.type     = EM28XX_VMUX_SVIDEO,
792 			.vmux     = SAA7115_SVIDEO3,
793 			.amux     = EM28XX_AMUX_LINE_IN,
794 		} },
795 	},
796 	[EM2820_BOARD_HERCULES_SMART_TV_USB2] = {
797 		.name         = "Hercules Smart TV USB 2.0",
798 		.valid        = EM28XX_BOARD_NOT_VALIDATED,
799 		.tuner_type   = TUNER_LG_PAL_NEW_TAPC,
800 		.tda9887_conf = TDA9887_PRESENT,
801 		.decoder      = EM28XX_SAA711X,
802 		.input        = { {
803 			.type     = EM28XX_VMUX_TELEVISION,
804 			.vmux     = SAA7115_COMPOSITE2,
805 			.amux     = EM28XX_AMUX_LINE_IN,
806 		}, {
807 			.type     = EM28XX_VMUX_COMPOSITE,
808 			.vmux     = SAA7115_COMPOSITE0,
809 			.amux     = EM28XX_AMUX_LINE_IN,
810 		}, {
811 			.type     = EM28XX_VMUX_SVIDEO,
812 			.vmux     = SAA7115_SVIDEO3,
813 			.amux     = EM28XX_AMUX_LINE_IN,
814 		} },
815 	},
816 	[EM2820_BOARD_PINNACLE_USB_2_FM1216ME] = {
817 		.name         = "Pinnacle PCTV USB 2 (Philips FM1216ME)",
818 		.valid        = EM28XX_BOARD_NOT_VALIDATED,
819 		.tuner_type   = TUNER_PHILIPS_FM1216ME_MK3,
820 		.tda9887_conf = TDA9887_PRESENT,
821 		.decoder      = EM28XX_SAA711X,
822 		.input        = { {
823 			.type     = EM28XX_VMUX_TELEVISION,
824 			.vmux     = SAA7115_COMPOSITE2,
825 			.amux     = EM28XX_AMUX_VIDEO,
826 		}, {
827 			.type     = EM28XX_VMUX_COMPOSITE,
828 			.vmux     = SAA7115_COMPOSITE0,
829 			.amux     = EM28XX_AMUX_LINE_IN,
830 		}, {
831 			.type     = EM28XX_VMUX_SVIDEO,
832 			.vmux     = SAA7115_SVIDEO3,
833 			.amux     = EM28XX_AMUX_LINE_IN,
834 		} },
835 	},
836 	[EM2820_BOARD_GADMEI_UTV310] = {
837 		.name         = "Gadmei UTV310",
838 		.valid        = EM28XX_BOARD_NOT_VALIDATED,
839 		.tuner_type   = TUNER_TNF_5335MF,
840 		.tda9887_conf = TDA9887_PRESENT,
841 		.decoder      = EM28XX_SAA711X,
842 		.input        = { {
843 			.type     = EM28XX_VMUX_TELEVISION,
844 			.vmux     = SAA7115_COMPOSITE1,
845 			.amux     = EM28XX_AMUX_LINE_IN,
846 		}, {
847 			.type     = EM28XX_VMUX_COMPOSITE,
848 			.vmux     = SAA7115_COMPOSITE0,
849 			.amux     = EM28XX_AMUX_LINE_IN,
850 		}, {
851 			.type     = EM28XX_VMUX_SVIDEO,
852 			.vmux     = SAA7115_SVIDEO3,
853 			.amux     = EM28XX_AMUX_LINE_IN,
854 		} },
855 	},
856 	[EM2820_BOARD_LEADTEK_WINFAST_USBII_DELUXE] = {
857 		.name         = "Leadtek Winfast USB II Deluxe",
858 		.valid        = EM28XX_BOARD_NOT_VALIDATED,
859 		.tuner_type   = TUNER_PHILIPS_FM1216ME_MK3,
860 		.has_ir_i2c   = 1,
861 		.tvaudio_addr = 0x58,
862 		.tda9887_conf = TDA9887_PRESENT |
863 				TDA9887_PORT2_ACTIVE |
864 				TDA9887_QSS,
865 		.decoder      = EM28XX_SAA711X,
866 		.adecoder     = EM28XX_TVAUDIO,
867 		.input        = { {
868 			.type     = EM28XX_VMUX_TELEVISION,
869 			.vmux     = SAA7115_COMPOSITE4,
870 			.amux     = EM28XX_AMUX_AUX,
871 		}, {
872 			.type     = EM28XX_VMUX_COMPOSITE,
873 			.vmux     = SAA7115_COMPOSITE5,
874 			.amux     = EM28XX_AMUX_LINE_IN,
875 		}, {
876 			.type     = EM28XX_VMUX_SVIDEO,
877 			.vmux     = SAA7115_SVIDEO3,
878 			.amux     = EM28XX_AMUX_LINE_IN,
879 		} },
880 			.radio	  = {
881 			.type     = EM28XX_RADIO,
882 			.amux     = EM28XX_AMUX_AUX,
883 			}
884 	},
885 	[EM2820_BOARD_VIDEOLOGY_20K14XUSB] = {
886 		.name         = "Videology 20K14XUSB USB2.0",
887 		.valid        = EM28XX_BOARD_NOT_VALIDATED,
888 		.tuner_type   = TUNER_ABSENT,
889 		.is_webcam    = 1,
890 		.input        = { {
891 			.type     = EM28XX_VMUX_COMPOSITE,
892 			.vmux     = 0,
893 			.amux     = EM28XX_AMUX_VIDEO,
894 		} },
895 	},
896 	[EM2820_BOARD_SILVERCREST_WEBCAM] = {
897 		.name         = "Silvercrest Webcam 1.3mpix",
898 		.tuner_type   = TUNER_ABSENT,
899 		.is_webcam    = 1,
900 		.input        = { {
901 			.type     = EM28XX_VMUX_COMPOSITE,
902 			.vmux     = 0,
903 			.amux     = EM28XX_AMUX_VIDEO,
904 			.gpio     = silvercrest_reg_seq,
905 		} },
906 	},
907 	[EM2821_BOARD_SUPERCOMP_USB_2] = {
908 		.name         = "Supercomp USB 2.0 TV",
909 		.valid        = EM28XX_BOARD_NOT_VALIDATED,
910 		.tuner_type   = TUNER_PHILIPS_FM1236_MK3,
911 		.tda9887_conf = TDA9887_PRESENT |
912 				TDA9887_PORT1_ACTIVE |
913 				TDA9887_PORT2_ACTIVE,
914 		.decoder      = EM28XX_SAA711X,
915 		.input        = { {
916 			.type     = EM28XX_VMUX_TELEVISION,
917 			.vmux     = SAA7115_COMPOSITE2,
918 			.amux     = EM28XX_AMUX_LINE_IN,
919 		}, {
920 			.type     = EM28XX_VMUX_COMPOSITE,
921 			.vmux     = SAA7115_COMPOSITE0,
922 			.amux     = EM28XX_AMUX_VIDEO,
923 		}, {
924 			.type     = EM28XX_VMUX_SVIDEO,
925 			.vmux     = SAA7115_SVIDEO3,
926 			.amux     = EM28XX_AMUX_LINE_IN,
927 		} },
928 	},
929 	[EM2821_BOARD_USBGEAR_VD204] = {
930 		.name         = "Usbgear VD204v9",
931 		.valid        = EM28XX_BOARD_NOT_VALIDATED,
932 		.tuner_type   = TUNER_ABSENT,	/* Capture only device */
933 		.decoder      = EM28XX_SAA711X,
934 		.input        = { {
935 			.type  = EM28XX_VMUX_COMPOSITE,
936 			.vmux  = SAA7115_COMPOSITE0,
937 			.amux  = EM28XX_AMUX_LINE_IN,
938 		}, {
939 			.type  = EM28XX_VMUX_SVIDEO,
940 			.vmux  = SAA7115_SVIDEO3,
941 			.amux  = EM28XX_AMUX_LINE_IN,
942 		} },
943 	},
944 	[EM2860_BOARD_NETGMBH_CAM] = {
945 		/* Beijing Huaqi Information Digital Technology Co., Ltd */
946 		.name         = "NetGMBH Cam",
947 		.valid        = EM28XX_BOARD_NOT_VALIDATED,
948 		.tuner_type   = TUNER_ABSENT,
949 		.is_webcam    = 1,
950 		.input        = { {
951 			.type     = EM28XX_VMUX_COMPOSITE,
952 			.vmux     = 0,
953 			.amux     = EM28XX_AMUX_VIDEO,
954 		} },
955 	},
956 	[EM2860_BOARD_TYPHOON_DVD_MAKER] = {
957 		.name         = "Typhoon DVD Maker",
958 		.decoder      = EM28XX_SAA711X,
959 		.tuner_type   = TUNER_ABSENT,	/* Capture only device */
960 		.input        = { {
961 			.type  = EM28XX_VMUX_COMPOSITE,
962 			.vmux  = SAA7115_COMPOSITE0,
963 			.amux  = EM28XX_AMUX_LINE_IN,
964 		}, {
965 			.type  = EM28XX_VMUX_SVIDEO,
966 			.vmux  = SAA7115_SVIDEO3,
967 			.amux  = EM28XX_AMUX_LINE_IN,
968 		} },
969 	},
970 	[EM2860_BOARD_GADMEI_UTV330] = {
971 		.name         = "Gadmei UTV330",
972 		.valid        = EM28XX_BOARD_NOT_VALIDATED,
973 		.tuner_type   = TUNER_TNF_5335MF,
974 		.tda9887_conf = TDA9887_PRESENT,
975 		.decoder      = EM28XX_SAA711X,
976 		.input        = { {
977 			.type     = EM28XX_VMUX_TELEVISION,
978 			.vmux     = SAA7115_COMPOSITE2,
979 			.amux     = EM28XX_AMUX_VIDEO,
980 		}, {
981 			.type     = EM28XX_VMUX_COMPOSITE,
982 			.vmux     = SAA7115_COMPOSITE0,
983 			.amux     = EM28XX_AMUX_LINE_IN,
984 		}, {
985 			.type     = EM28XX_VMUX_SVIDEO,
986 			.vmux     = SAA7115_SVIDEO3,
987 			.amux     = EM28XX_AMUX_LINE_IN,
988 		} },
989 	},
990 	[EM2861_BOARD_GADMEI_UTV330PLUS] = {
991 		.name         = "Gadmei UTV330+",
992 		.tuner_type   = TUNER_TNF_5335MF,
993 		.tda9887_conf = TDA9887_PRESENT,
994 		.ir_codes     = RC_MAP_GADMEI_RM008Z,
995 		.decoder      = EM28XX_SAA711X,
996 		.xclk         = EM28XX_XCLK_FREQUENCY_12MHZ,
997 		.input        = { {
998 			.type     = EM28XX_VMUX_TELEVISION,
999 			.vmux     = SAA7115_COMPOSITE2,
1000 			.amux     = EM28XX_AMUX_VIDEO,
1001 		}, {
1002 			.type     = EM28XX_VMUX_COMPOSITE,
1003 			.vmux     = SAA7115_COMPOSITE0,
1004 			.amux     = EM28XX_AMUX_LINE_IN,
1005 		}, {
1006 			.type     = EM28XX_VMUX_SVIDEO,
1007 			.vmux     = SAA7115_SVIDEO3,
1008 			.amux     = EM28XX_AMUX_LINE_IN,
1009 		} },
1010 	},
1011 	[EM2860_BOARD_TERRATEC_HYBRID_XS] = {
1012 		.name         = "Terratec Cinergy A Hybrid XS",
1013 		.valid        = EM28XX_BOARD_NOT_VALIDATED,
1014 		.tuner_type   = TUNER_XC2028,
1015 		.tuner_gpio   = default_tuner_gpio,
1016 		.decoder      = EM28XX_TVP5150,
1017 
1018 		.input        = { {
1019 			.type     = EM28XX_VMUX_TELEVISION,
1020 			.vmux     = TVP5150_COMPOSITE0,
1021 			.amux     = EM28XX_AMUX_VIDEO,
1022 			.gpio     = hauppauge_wintv_hvr_900_analog,
1023 		}, {
1024 			.type     = EM28XX_VMUX_COMPOSITE,
1025 			.vmux     = TVP5150_COMPOSITE1,
1026 			.amux     = EM28XX_AMUX_LINE_IN,
1027 			.gpio     = hauppauge_wintv_hvr_900_analog,
1028 		}, {
1029 			.type     = EM28XX_VMUX_SVIDEO,
1030 			.vmux     = TVP5150_SVIDEO,
1031 			.amux     = EM28XX_AMUX_LINE_IN,
1032 			.gpio     = hauppauge_wintv_hvr_900_analog,
1033 		} },
1034 	},
1035 	[EM2861_BOARD_KWORLD_PVRTV_300U] = {
1036 		.name	      = "KWorld PVRTV 300U",
1037 		.valid        = EM28XX_BOARD_NOT_VALIDATED,
1038 		.tuner_type   = TUNER_XC2028,
1039 		.tuner_gpio   = default_tuner_gpio,
1040 		.decoder      = EM28XX_TVP5150,
1041 		.input        = { {
1042 			.type     = EM28XX_VMUX_TELEVISION,
1043 			.vmux     = TVP5150_COMPOSITE0,
1044 			.amux     = EM28XX_AMUX_VIDEO,
1045 		}, {
1046 			.type     = EM28XX_VMUX_COMPOSITE,
1047 			.vmux     = TVP5150_COMPOSITE1,
1048 			.amux     = EM28XX_AMUX_LINE_IN,
1049 		}, {
1050 			.type     = EM28XX_VMUX_SVIDEO,
1051 			.vmux     = TVP5150_SVIDEO,
1052 			.amux     = EM28XX_AMUX_LINE_IN,
1053 		} },
1054 	},
1055 	[EM2861_BOARD_YAKUMO_MOVIE_MIXER] = {
1056 		.name          = "Yakumo MovieMixer",
1057 		.tuner_type    = TUNER_ABSENT,	/* Capture only device */
1058 		.decoder       = EM28XX_TVP5150,
1059 		.input         = { {
1060 			.type     = EM28XX_VMUX_TELEVISION,
1061 			.vmux     = TVP5150_COMPOSITE0,
1062 			.amux     = EM28XX_AMUX_VIDEO,
1063 		}, {
1064 			.type     = EM28XX_VMUX_COMPOSITE,
1065 			.vmux     = TVP5150_COMPOSITE1,
1066 			.amux     = EM28XX_AMUX_LINE_IN,
1067 		}, {
1068 			.type     = EM28XX_VMUX_SVIDEO,
1069 			.vmux     = TVP5150_SVIDEO,
1070 			.amux     = EM28XX_AMUX_LINE_IN,
1071 		} },
1072 	},
1073 	[EM2860_BOARD_TVP5150_REFERENCE_DESIGN] = {
1074 		.name          = "EM2860/TVP5150 Reference Design",
1075 		.tuner_type    = TUNER_ABSENT,	/* Capture only device */
1076 		.decoder       = EM28XX_TVP5150,
1077 		.input         = { {
1078 			.type     = EM28XX_VMUX_COMPOSITE,
1079 			.vmux     = TVP5150_COMPOSITE1,
1080 			.amux     = EM28XX_AMUX_LINE_IN,
1081 		}, {
1082 			.type     = EM28XX_VMUX_SVIDEO,
1083 			.vmux     = TVP5150_SVIDEO,
1084 			.amux     = EM28XX_AMUX_LINE_IN,
1085 		} },
1086 	},
1087 	[EM2861_BOARD_PLEXTOR_PX_TV100U] = {
1088 		.name         = "Plextor ConvertX PX-TV100U",
1089 		.tuner_type   = TUNER_TNF_5335MF,
1090 		.xclk         = EM28XX_XCLK_I2S_MSB_TIMING |
1091 				EM28XX_XCLK_FREQUENCY_12MHZ,
1092 		.tda9887_conf = TDA9887_PRESENT,
1093 		.decoder      = EM28XX_TVP5150,
1094 		.has_msp34xx  = 1,
1095 		.input        = { {
1096 			.type     = EM28XX_VMUX_TELEVISION,
1097 			.vmux     = TVP5150_COMPOSITE0,
1098 			.amux     = EM28XX_AMUX_LINE_IN,
1099 			.gpio     = pinnacle_hybrid_pro_analog,
1100 		}, {
1101 			.type     = EM28XX_VMUX_COMPOSITE,
1102 			.vmux     = TVP5150_COMPOSITE1,
1103 			.amux     = EM28XX_AMUX_LINE_IN,
1104 			.gpio     = pinnacle_hybrid_pro_analog,
1105 		}, {
1106 			.type     = EM28XX_VMUX_SVIDEO,
1107 			.vmux     = TVP5150_SVIDEO,
1108 			.amux     = EM28XX_AMUX_LINE_IN,
1109 			.gpio     = pinnacle_hybrid_pro_analog,
1110 		} },
1111 	},
1112 
1113 	/* Those boards with em2870 are DVB Only*/
1114 
1115 	[EM2870_BOARD_TERRATEC_XS] = {
1116 		.name         = "Terratec Cinergy T XS",
1117 		.valid        = EM28XX_BOARD_NOT_VALIDATED,
1118 		.tuner_type   = TUNER_XC2028,
1119 		.tuner_gpio   = default_tuner_gpio,
1120 	},
1121 	[EM2870_BOARD_TERRATEC_XS_MT2060] = {
1122 		.name         = "Terratec Cinergy T XS (MT2060)",
1123 		.xclk         = EM28XX_XCLK_IR_RC5_MODE |
1124 				EM28XX_XCLK_FREQUENCY_12MHZ,
1125 		.i2c_speed    = EM28XX_I2C_CLK_WAIT_ENABLE,
1126 		.tuner_type   = TUNER_ABSENT, /* MT2060 */
1127 		.has_dvb      = 1,
1128 		.tuner_gpio   = default_tuner_gpio,
1129 	},
1130 	[EM2870_BOARD_KWORLD_350U] = {
1131 		.name         = "Kworld 350 U DVB-T",
1132 		.valid        = EM28XX_BOARD_NOT_VALIDATED,
1133 		.tuner_type   = TUNER_XC2028,
1134 		.tuner_gpio   = default_tuner_gpio,
1135 	},
1136 	[EM2870_BOARD_KWORLD_355U] = {
1137 		.name         = "Kworld 355 U DVB-T",
1138 		.valid        = EM28XX_BOARD_NOT_VALIDATED,
1139 		.tuner_type   = TUNER_ABSENT,
1140 		.tuner_gpio   = default_tuner_gpio,
1141 		.has_dvb      = 1,
1142 		.dvb_gpio     = default_digital,
1143 	},
1144 	[EM2870_BOARD_PINNACLE_PCTV_DVB] = {
1145 		.name         = "Pinnacle PCTV DVB-T",
1146 		.valid        = EM28XX_BOARD_NOT_VALIDATED,
1147 		.tuner_type   = TUNER_ABSENT, /* MT2060 */
1148 		/* djh - I have serious doubts this is right... */
1149 		.xclk         = EM28XX_XCLK_IR_RC5_MODE |
1150 				EM28XX_XCLK_FREQUENCY_10MHZ,
1151 	},
1152 	[EM2870_BOARD_COMPRO_VIDEOMATE] = {
1153 		.name         = "Compro, VideoMate U3",
1154 		.valid        = EM28XX_BOARD_NOT_VALIDATED,
1155 		.tuner_type   = TUNER_ABSENT, /* MT2060 */
1156 	},
1157 
1158 	[EM2880_BOARD_TERRATEC_HYBRID_XS_FR] = {
1159 		.name         = "Terratec Hybrid XS Secam",
1160 		.has_msp34xx  = 1,
1161 		.tuner_type   = TUNER_XC2028,
1162 		.tuner_gpio   = default_tuner_gpio,
1163 		.decoder      = EM28XX_TVP5150,
1164 		.has_dvb      = 1,
1165 		.dvb_gpio     = terratec_cinergy_USB_XS_FR_digital,
1166 		.input        = { {
1167 			.type     = EM28XX_VMUX_TELEVISION,
1168 			.vmux     = TVP5150_COMPOSITE0,
1169 			.amux     = EM28XX_AMUX_VIDEO,
1170 			.gpio     = terratec_cinergy_USB_XS_FR_analog,
1171 		}, {
1172 			.type     = EM28XX_VMUX_COMPOSITE,
1173 			.vmux     = TVP5150_COMPOSITE1,
1174 			.amux     = EM28XX_AMUX_LINE_IN,
1175 			.gpio     = terratec_cinergy_USB_XS_FR_analog,
1176 		}, {
1177 			.type     = EM28XX_VMUX_SVIDEO,
1178 			.vmux     = TVP5150_SVIDEO,
1179 			.amux     = EM28XX_AMUX_LINE_IN,
1180 			.gpio     = terratec_cinergy_USB_XS_FR_analog,
1181 		} },
1182 	},
1183 	[EM2884_BOARD_TERRATEC_H5] = {
1184 		.name         = "Terratec Cinergy H5",
1185 		.has_dvb      = 1,
1186 #if 0
1187 		.tuner_type   = TUNER_PHILIPS_TDA8290,
1188 		.tuner_addr   = 0x41,
1189 		.dvb_gpio     = terratec_h5_digital, /* FIXME: probably wrong */
1190 		.tuner_gpio   = terratec_h5_gpio,
1191 #else
1192 		.tuner_type   = TUNER_ABSENT,
1193 #endif
1194 		.def_i2c_bus  = 1,
1195 		.i2c_speed    = EM28XX_I2C_CLK_WAIT_ENABLE |
1196 				EM28XX_I2C_FREQ_400_KHZ,
1197 	},
1198 	[EM2884_BOARD_TERRATEC_H6] = {
1199 		.name         = "Terratec Cinergy H6 rev. 2",
1200 		.has_dvb      = 1,
1201 		.ir_codes     = RC_MAP_NEC_TERRATEC_CINERGY_XS,
1202 #if 0
1203 		.tuner_type   = TUNER_PHILIPS_TDA8290,
1204 		.tuner_addr   = 0x41,
1205 		.dvb_gpio     = terratec_h5_digital, /* FIXME: probably wrong */
1206 		.tuner_gpio   = terratec_h5_gpio,
1207 #else
1208 		.tuner_type   = TUNER_ABSENT,
1209 #endif
1210 		.def_i2c_bus  = 1,
1211 		.i2c_speed    = EM28XX_I2C_CLK_WAIT_ENABLE |
1212 				EM28XX_I2C_FREQ_400_KHZ,
1213 	},
1214 	[EM2884_BOARD_HAUPPAUGE_WINTV_HVR_930C] = {
1215 		.name         = "Hauppauge WinTV HVR 930C",
1216 		.has_dvb      = 1,
1217 #if 0 /* FIXME: Add analog support */
1218 		.tuner_type   = TUNER_XC5000,
1219 		.tuner_addr   = 0x41,
1220 		.dvb_gpio     = hauppauge_930c_digital,
1221 		.tuner_gpio   = hauppauge_930c_gpio,
1222 #else
1223 		.tuner_type   = TUNER_ABSENT,
1224 #endif
1225 		.ir_codes     = RC_MAP_HAUPPAUGE,
1226 		.def_i2c_bus  = 1,
1227 		.i2c_speed    = EM28XX_I2C_CLK_WAIT_ENABLE |
1228 				EM28XX_I2C_FREQ_400_KHZ,
1229 	},
1230 	[EM2884_BOARD_C3TECH_DIGITAL_DUO] = {
1231 		.name         = "C3 Tech Digital Duo HDTV/SDTV USB",
1232 		.has_dvb      = 1,
1233 		/* FIXME: Add analog support - need a saa7136 driver */
1234 		.tuner_type = TUNER_ABSENT,	/* Digital-only TDA18271HD */
1235 		.ir_codes     = RC_MAP_EMPTY,
1236 		.def_i2c_bus  = 1,
1237 		.i2c_speed    = EM28XX_I2C_CLK_WAIT_ENABLE,
1238 		.dvb_gpio     = c3tech_digital_duo_digital,
1239 	},
1240 	[EM2884_BOARD_CINERGY_HTC_STICK] = {
1241 		.name         = "Terratec Cinergy HTC Stick",
1242 		.has_dvb      = 1,
1243 		.ir_codes     = RC_MAP_NEC_TERRATEC_CINERGY_XS,
1244 		.tuner_type   = TUNER_ABSENT,
1245 		.def_i2c_bus  = 1,
1246 		.i2c_speed    = EM28XX_I2C_CLK_WAIT_ENABLE |
1247 				EM28XX_I2C_FREQ_400_KHZ,
1248 	},
1249 	[EM2884_BOARD_ELGATO_EYETV_HYBRID_2008] = {
1250 		.name         = "Elgato EyeTV Hybrid 2008 INT",
1251 		.has_dvb      = 1,
1252 		.ir_codes     = RC_MAP_NEC_TERRATEC_CINERGY_XS,
1253 		.tuner_type   = TUNER_ABSENT,
1254 		.def_i2c_bus  = 1,
1255 		.i2c_speed    = EM28XX_I2C_CLK_WAIT_ENABLE |
1256 				EM28XX_I2C_FREQ_400_KHZ,
1257 	},
1258 	[EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900] = {
1259 		.name         = "Hauppauge WinTV HVR 900",
1260 		.tda9887_conf = TDA9887_PRESENT,
1261 		.tuner_type   = TUNER_XC2028,
1262 		.tuner_gpio   = default_tuner_gpio,
1263 		.mts_firmware = 1,
1264 		.has_dvb      = 1,
1265 		.dvb_gpio     = hauppauge_wintv_hvr_900_digital,
1266 		.ir_codes     = RC_MAP_HAUPPAUGE,
1267 		.decoder      = EM28XX_TVP5150,
1268 		.input        = { {
1269 			.type     = EM28XX_VMUX_TELEVISION,
1270 			.vmux     = TVP5150_COMPOSITE0,
1271 			.amux     = EM28XX_AMUX_VIDEO,
1272 			.gpio     = hauppauge_wintv_hvr_900_analog,
1273 		}, {
1274 			.type     = EM28XX_VMUX_COMPOSITE,
1275 			.vmux     = TVP5150_COMPOSITE1,
1276 			.amux     = EM28XX_AMUX_LINE_IN,
1277 			.gpio     = hauppauge_wintv_hvr_900_analog,
1278 		}, {
1279 			.type     = EM28XX_VMUX_SVIDEO,
1280 			.vmux     = TVP5150_SVIDEO,
1281 			.amux     = EM28XX_AMUX_LINE_IN,
1282 			.gpio     = hauppauge_wintv_hvr_900_analog,
1283 		} },
1284 	},
1285 	[EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900_R2] = {
1286 		.name         = "Hauppauge WinTV HVR 900 (R2)",
1287 		.tda9887_conf = TDA9887_PRESENT,
1288 		.tuner_type   = TUNER_XC2028,
1289 		.tuner_gpio   = default_tuner_gpio,
1290 		.mts_firmware = 1,
1291 		.has_dvb      = 1,
1292 		.dvb_gpio     = hauppauge_wintv_hvr_900R2_digital,
1293 		.ir_codes     = RC_MAP_HAUPPAUGE,
1294 		.decoder      = EM28XX_TVP5150,
1295 		.input        = { {
1296 			.type     = EM28XX_VMUX_TELEVISION,
1297 			.vmux     = TVP5150_COMPOSITE0,
1298 			.amux     = EM28XX_AMUX_VIDEO,
1299 			.gpio     = hauppauge_wintv_hvr_900_analog,
1300 		}, {
1301 			.type     = EM28XX_VMUX_COMPOSITE,
1302 			.vmux     = TVP5150_COMPOSITE1,
1303 			.amux     = EM28XX_AMUX_LINE_IN,
1304 			.gpio     = hauppauge_wintv_hvr_900_analog,
1305 		}, {
1306 			.type     = EM28XX_VMUX_SVIDEO,
1307 			.vmux     = TVP5150_SVIDEO,
1308 			.amux     = EM28XX_AMUX_LINE_IN,
1309 			.gpio     = hauppauge_wintv_hvr_900_analog,
1310 		} },
1311 	},
1312 	[EM2883_BOARD_HAUPPAUGE_WINTV_HVR_850] = {
1313 		.name           = "Hauppauge WinTV HVR 850",
1314 		.tuner_type     = TUNER_XC2028,
1315 		.tuner_gpio     = default_tuner_gpio,
1316 		.mts_firmware   = 1,
1317 		.has_dvb        = 1,
1318 		.dvb_gpio       = hauppauge_wintv_hvr_900_digital,
1319 		.ir_codes       = RC_MAP_HAUPPAUGE,
1320 		.decoder        = EM28XX_TVP5150,
1321 		.input          = { {
1322 			.type     = EM28XX_VMUX_TELEVISION,
1323 			.vmux     = TVP5150_COMPOSITE0,
1324 			.amux     = EM28XX_AMUX_VIDEO,
1325 			.gpio     = hauppauge_wintv_hvr_900_analog,
1326 		}, {
1327 			.type     = EM28XX_VMUX_COMPOSITE,
1328 			.vmux     = TVP5150_COMPOSITE1,
1329 			.amux     = EM28XX_AMUX_LINE_IN,
1330 			.gpio     = hauppauge_wintv_hvr_900_analog,
1331 		}, {
1332 			.type     = EM28XX_VMUX_SVIDEO,
1333 			.vmux     = TVP5150_SVIDEO,
1334 			.amux     = EM28XX_AMUX_LINE_IN,
1335 			.gpio     = hauppauge_wintv_hvr_900_analog,
1336 		} },
1337 	},
1338 	[EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950] = {
1339 		.name           = "Hauppauge WinTV HVR 950",
1340 		.tuner_type     = TUNER_XC2028,
1341 		.tuner_gpio     = default_tuner_gpio,
1342 		.mts_firmware   = 1,
1343 		.has_dvb        = 1,
1344 		.dvb_gpio       = hauppauge_wintv_hvr_900_digital,
1345 		.ir_codes       = RC_MAP_HAUPPAUGE,
1346 		.decoder        = EM28XX_TVP5150,
1347 		.input          = { {
1348 			.type     = EM28XX_VMUX_TELEVISION,
1349 			.vmux     = TVP5150_COMPOSITE0,
1350 			.amux     = EM28XX_AMUX_VIDEO,
1351 			.gpio     = hauppauge_wintv_hvr_900_analog,
1352 		}, {
1353 			.type     = EM28XX_VMUX_COMPOSITE,
1354 			.vmux     = TVP5150_COMPOSITE1,
1355 			.amux     = EM28XX_AMUX_LINE_IN,
1356 			.gpio     = hauppauge_wintv_hvr_900_analog,
1357 		}, {
1358 			.type     = EM28XX_VMUX_SVIDEO,
1359 			.vmux     = TVP5150_SVIDEO,
1360 			.amux     = EM28XX_AMUX_LINE_IN,
1361 			.gpio     = hauppauge_wintv_hvr_900_analog,
1362 		} },
1363 	},
1364 	[EM2880_BOARD_PINNACLE_PCTV_HD_PRO] = {
1365 		.name           = "Pinnacle PCTV HD Pro Stick",
1366 		.tuner_type     = TUNER_XC2028,
1367 		.tuner_gpio   = default_tuner_gpio,
1368 		.mts_firmware   = 1,
1369 		.has_dvb        = 1,
1370 		.dvb_gpio       = hauppauge_wintv_hvr_900_digital,
1371 		.ir_codes       = RC_MAP_PINNACLE_PCTV_HD,
1372 		.decoder        = EM28XX_TVP5150,
1373 		.input          = { {
1374 			.type     = EM28XX_VMUX_TELEVISION,
1375 			.vmux     = TVP5150_COMPOSITE0,
1376 			.amux     = EM28XX_AMUX_VIDEO,
1377 			.gpio     = hauppauge_wintv_hvr_900_analog,
1378 		}, {
1379 			.type     = EM28XX_VMUX_COMPOSITE,
1380 			.vmux     = TVP5150_COMPOSITE1,
1381 			.amux     = EM28XX_AMUX_LINE_IN,
1382 			.gpio     = hauppauge_wintv_hvr_900_analog,
1383 		}, {
1384 			.type     = EM28XX_VMUX_SVIDEO,
1385 			.vmux     = TVP5150_SVIDEO,
1386 			.amux     = EM28XX_AMUX_LINE_IN,
1387 			.gpio     = hauppauge_wintv_hvr_900_analog,
1388 		} },
1389 	},
1390 	[EM2880_BOARD_AMD_ATI_TV_WONDER_HD_600] = {
1391 		.name           = "AMD ATI TV Wonder HD 600",
1392 		.tuner_type     = TUNER_XC2028,
1393 		.tuner_gpio     = default_tuner_gpio,
1394 		.mts_firmware   = 1,
1395 		.has_dvb        = 1,
1396 		.dvb_gpio       = hauppauge_wintv_hvr_900_digital,
1397 		.ir_codes       = RC_MAP_ATI_TV_WONDER_HD_600,
1398 		.decoder        = EM28XX_TVP5150,
1399 		.input          = { {
1400 			.type     = EM28XX_VMUX_TELEVISION,
1401 			.vmux     = TVP5150_COMPOSITE0,
1402 			.amux     = EM28XX_AMUX_VIDEO,
1403 			.gpio     = hauppauge_wintv_hvr_900_analog,
1404 		}, {
1405 			.type     = EM28XX_VMUX_COMPOSITE,
1406 			.vmux     = TVP5150_COMPOSITE1,
1407 			.amux     = EM28XX_AMUX_LINE_IN,
1408 			.gpio     = hauppauge_wintv_hvr_900_analog,
1409 		}, {
1410 			.type     = EM28XX_VMUX_SVIDEO,
1411 			.vmux     = TVP5150_SVIDEO,
1412 			.amux     = EM28XX_AMUX_LINE_IN,
1413 			.gpio     = hauppauge_wintv_hvr_900_analog,
1414 		} },
1415 	},
1416 	[EM2880_BOARD_TERRATEC_HYBRID_XS] = {
1417 		.name           = "Terratec Hybrid XS",
1418 		.tuner_type     = TUNER_XC2028,
1419 		.tuner_gpio     = default_tuner_gpio,
1420 		.decoder        = EM28XX_TVP5150,
1421 		.has_dvb        = 1,
1422 		.dvb_gpio       = default_digital,
1423 		.ir_codes       = RC_MAP_TERRATEC_CINERGY_XS,
1424 		.xclk           = EM28XX_XCLK_FREQUENCY_12MHZ, /* NEC IR */
1425 		.input          = { {
1426 			.type     = EM28XX_VMUX_TELEVISION,
1427 			.vmux     = TVP5150_COMPOSITE0,
1428 			.amux     = EM28XX_AMUX_VIDEO,
1429 			.gpio     = default_analog,
1430 		}, {
1431 			.type     = EM28XX_VMUX_COMPOSITE,
1432 			.vmux     = TVP5150_COMPOSITE1,
1433 			.amux     = EM28XX_AMUX_LINE_IN,
1434 			.gpio     = default_analog,
1435 		}, {
1436 			.type     = EM28XX_VMUX_SVIDEO,
1437 			.vmux     = TVP5150_SVIDEO,
1438 			.amux     = EM28XX_AMUX_LINE_IN,
1439 			.gpio     = default_analog,
1440 		} },
1441 	},
1442 	/*
1443 	 * maybe there's a reason behind it why Terratec sells the Hybrid XS
1444 	 * as Prodigy XS with a different PID, let's keep it separated for now
1445 	 * maybe we'll need it later on
1446 	 */
1447 	[EM2880_BOARD_TERRATEC_PRODIGY_XS] = {
1448 		.name         = "Terratec Prodigy XS",
1449 		.tuner_type   = TUNER_XC2028,
1450 		.tuner_gpio   = default_tuner_gpio,
1451 		.decoder      = EM28XX_TVP5150,
1452 		.input        = { {
1453 			.type     = EM28XX_VMUX_TELEVISION,
1454 			.vmux     = TVP5150_COMPOSITE0,
1455 			.amux     = EM28XX_AMUX_VIDEO,
1456 			.gpio     = hauppauge_wintv_hvr_900_analog,
1457 		}, {
1458 			.type     = EM28XX_VMUX_COMPOSITE,
1459 			.vmux     = TVP5150_COMPOSITE1,
1460 			.amux     = EM28XX_AMUX_LINE_IN,
1461 			.gpio     = hauppauge_wintv_hvr_900_analog,
1462 		}, {
1463 			.type     = EM28XX_VMUX_SVIDEO,
1464 			.vmux     = TVP5150_SVIDEO,
1465 			.amux     = EM28XX_AMUX_LINE_IN,
1466 			.gpio     = hauppauge_wintv_hvr_900_analog,
1467 		} },
1468 	},
1469 	[EM2820_BOARD_MSI_VOX_USB_2] = {
1470 		.name		   = "MSI VOX USB 2.0",
1471 		.tuner_type	   = TUNER_LG_PAL_NEW_TAPC,
1472 		.tda9887_conf	   = TDA9887_PRESENT      |
1473 				     TDA9887_PORT1_ACTIVE |
1474 				     TDA9887_PORT2_ACTIVE,
1475 		.max_range_640_480 = 1,
1476 		.decoder           = EM28XX_SAA711X,
1477 		.input             = { {
1478 			.type      = EM28XX_VMUX_TELEVISION,
1479 			.vmux      = SAA7115_COMPOSITE4,
1480 			.amux      = EM28XX_AMUX_VIDEO,
1481 		}, {
1482 			.type      = EM28XX_VMUX_COMPOSITE,
1483 			.vmux      = SAA7115_COMPOSITE0,
1484 			.amux      = EM28XX_AMUX_LINE_IN,
1485 		}, {
1486 			.type      = EM28XX_VMUX_SVIDEO,
1487 			.vmux      = SAA7115_SVIDEO3,
1488 			.amux      = EM28XX_AMUX_LINE_IN,
1489 		} },
1490 	},
1491 	[EM2800_BOARD_TERRATEC_CINERGY_200] = {
1492 		.name         = "Terratec Cinergy 200 USB",
1493 		.is_em2800    = 1,
1494 		.has_ir_i2c   = 1,
1495 		.tuner_type   = TUNER_LG_TALN,
1496 		.tda9887_conf = TDA9887_PRESENT,
1497 		.decoder      = EM28XX_SAA711X,
1498 		.input        = { {
1499 			.type     = EM28XX_VMUX_TELEVISION,
1500 			.vmux     = SAA7115_COMPOSITE2,
1501 			.amux     = EM28XX_AMUX_VIDEO,
1502 		}, {
1503 			.type     = EM28XX_VMUX_COMPOSITE,
1504 			.vmux     = SAA7115_COMPOSITE0,
1505 			.amux     = EM28XX_AMUX_LINE_IN,
1506 		}, {
1507 			.type     = EM28XX_VMUX_SVIDEO,
1508 			.vmux     = SAA7115_SVIDEO3,
1509 			.amux     = EM28XX_AMUX_LINE_IN,
1510 		} },
1511 	},
1512 	[EM2800_BOARD_GRABBEEX_USB2800] = {
1513 		.name       = "eMPIA Technology, Inc. GrabBeeX+ Video Encoder",
1514 		.is_em2800  = 1,
1515 		.decoder    = EM28XX_SAA711X,
1516 		.tuner_type = TUNER_ABSENT, /* capture only board */
1517 		.input      = { {
1518 			.type     = EM28XX_VMUX_COMPOSITE,
1519 			.vmux     = SAA7115_COMPOSITE0,
1520 			.amux     = EM28XX_AMUX_LINE_IN,
1521 		}, {
1522 			.type     = EM28XX_VMUX_SVIDEO,
1523 			.vmux     = SAA7115_SVIDEO3,
1524 			.amux     = EM28XX_AMUX_LINE_IN,
1525 		} },
1526 	},
1527 	[EM2800_BOARD_VC211A] = {
1528 		.name         = "Actionmaster/LinXcel/Digitus VC211A",
1529 		.is_em2800    = 1,
1530 		.tuner_type   = TUNER_ABSENT,	/* Capture-only board */
1531 		.decoder      = EM28XX_SAA711X,
1532 		.input        = { {
1533 			.type     = EM28XX_VMUX_COMPOSITE,
1534 			.vmux     = SAA7115_COMPOSITE0,
1535 			.amux     = EM28XX_AMUX_LINE_IN,
1536 			.gpio     = vc211a_enable,
1537 		}, {
1538 			.type     = EM28XX_VMUX_SVIDEO,
1539 			.vmux     = SAA7115_SVIDEO3,
1540 			.amux     = EM28XX_AMUX_LINE_IN,
1541 			.gpio     = vc211a_enable,
1542 		} },
1543 	},
1544 	[EM2800_BOARD_LEADTEK_WINFAST_USBII] = {
1545 		.name         = "Leadtek Winfast USB II",
1546 		.is_em2800    = 1,
1547 		.tuner_type   = TUNER_LG_PAL_NEW_TAPC,
1548 		.tda9887_conf = TDA9887_PRESENT,
1549 		.decoder      = EM28XX_SAA711X,
1550 		.input        = { {
1551 			.type     = EM28XX_VMUX_TELEVISION,
1552 			.vmux     = SAA7115_COMPOSITE2,
1553 			.amux     = EM28XX_AMUX_VIDEO,
1554 		}, {
1555 			.type     = EM28XX_VMUX_COMPOSITE,
1556 			.vmux     = SAA7115_COMPOSITE0,
1557 			.amux     = EM28XX_AMUX_LINE_IN,
1558 		}, {
1559 			.type     = EM28XX_VMUX_SVIDEO,
1560 			.vmux     = SAA7115_SVIDEO3,
1561 			.amux     = EM28XX_AMUX_LINE_IN,
1562 		} },
1563 	},
1564 	[EM2800_BOARD_KWORLD_USB2800] = {
1565 		.name         = "Kworld USB2800",
1566 		.is_em2800    = 1,
1567 		.tuner_type   = TUNER_PHILIPS_FCV1236D,
1568 		.tda9887_conf = TDA9887_PRESENT,
1569 		.decoder      = EM28XX_SAA711X,
1570 		.input        = { {
1571 			.type     = EM28XX_VMUX_TELEVISION,
1572 			.vmux     = SAA7115_COMPOSITE2,
1573 			.amux     = EM28XX_AMUX_VIDEO,
1574 		}, {
1575 			.type     = EM28XX_VMUX_COMPOSITE,
1576 			.vmux     = SAA7115_COMPOSITE0,
1577 			.amux     = EM28XX_AMUX_LINE_IN,
1578 		}, {
1579 			.type     = EM28XX_VMUX_SVIDEO,
1580 			.vmux     = SAA7115_SVIDEO3,
1581 			.amux     = EM28XX_AMUX_LINE_IN,
1582 		} },
1583 	},
1584 	[EM2820_BOARD_PINNACLE_DVC_90] = {
1585 		.name	      = "Pinnacle Dazzle DVC 90/100/101/107 / Kaiser Baas Video to DVD maker / Kworld DVD Maker 2 / Plextor ConvertX PX-AV100U",
1586 		.tuner_type   = TUNER_ABSENT, /* capture only board */
1587 		.decoder      = EM28XX_SAA711X,
1588 		.input        = { {
1589 			.type     = EM28XX_VMUX_COMPOSITE,
1590 			.vmux     = SAA7115_COMPOSITE0,
1591 			.amux     = EM28XX_AMUX_LINE_IN,
1592 		}, {
1593 			.type     = EM28XX_VMUX_SVIDEO,
1594 			.vmux     = SAA7115_SVIDEO3,
1595 			.amux     = EM28XX_AMUX_LINE_IN,
1596 		} },
1597 	},
1598 	[EM2800_BOARD_VGEAR_POCKETTV] = {
1599 		.name         = "V-Gear PocketTV",
1600 		.is_em2800    = 1,
1601 		.tuner_type   = TUNER_LG_PAL_NEW_TAPC,
1602 		.tda9887_conf = TDA9887_PRESENT,
1603 		.decoder      = EM28XX_SAA711X,
1604 		.input        = { {
1605 			.type     = EM28XX_VMUX_TELEVISION,
1606 			.vmux     = SAA7115_COMPOSITE2,
1607 			.amux     = EM28XX_AMUX_VIDEO,
1608 		}, {
1609 			.type     = EM28XX_VMUX_COMPOSITE,
1610 			.vmux     = SAA7115_COMPOSITE0,
1611 			.amux     = EM28XX_AMUX_LINE_IN,
1612 		}, {
1613 			.type     = EM28XX_VMUX_SVIDEO,
1614 			.vmux     = SAA7115_SVIDEO3,
1615 			.amux     = EM28XX_AMUX_LINE_IN,
1616 		} },
1617 	},
1618 	[EM2820_BOARD_PROLINK_PLAYTV_BOX4_USB2] = {
1619 		.name         = "Pixelview PlayTV Box 4 USB 2.0",
1620 		.tda9887_conf = TDA9887_PRESENT,
1621 		.tuner_type   = TUNER_YMEC_TVF_5533MF,
1622 		.decoder      = EM28XX_SAA711X,
1623 		.input        = { {
1624 			.type     = EM28XX_VMUX_TELEVISION,
1625 			.vmux     = SAA7115_COMPOSITE2,
1626 			.amux     = EM28XX_AMUX_VIDEO,
1627 			.aout     = EM28XX_AOUT_MONO |	/* I2S */
1628 				    EM28XX_AOUT_MASTER,	/* Line out pin */
1629 		}, {
1630 			.type     = EM28XX_VMUX_COMPOSITE,
1631 			.vmux     = SAA7115_COMPOSITE0,
1632 			.amux     = EM28XX_AMUX_LINE_IN,
1633 		}, {
1634 			.type     = EM28XX_VMUX_SVIDEO,
1635 			.vmux     = SAA7115_SVIDEO3,
1636 			.amux     = EM28XX_AMUX_LINE_IN,
1637 		} },
1638 	},
1639 	[EM2820_BOARD_PROLINK_PLAYTV_USB2] = {
1640 		.name         = "SIIG AVTuner-PVR / Pixelview Prolink PlayTV USB 2.0",
1641 		.buttons = std_snapshot_button,
1642 		.tda9887_conf = TDA9887_PRESENT,
1643 		.tuner_type   = TUNER_YMEC_TVF_5533MF,
1644 		.tuner_addr   = 0x60,
1645 		.decoder      = EM28XX_SAA711X,
1646 		.input        = { {
1647 			.type     = EM28XX_VMUX_TELEVISION,
1648 			.vmux     = SAA7115_COMPOSITE2,
1649 			.amux     = EM28XX_AMUX_VIDEO,
1650 			.aout     = EM28XX_AOUT_MONO |	/* I2S */
1651 				    EM28XX_AOUT_MASTER,	/* Line out pin */
1652 		}, {
1653 			.type     = EM28XX_VMUX_COMPOSITE,
1654 			.vmux     = SAA7115_COMPOSITE0,
1655 			.amux     = EM28XX_AMUX_LINE_IN,
1656 		}, {
1657 			.type     = EM28XX_VMUX_SVIDEO,
1658 			.vmux     = SAA7115_SVIDEO3,
1659 			.amux     = EM28XX_AMUX_LINE_IN,
1660 		} },
1661 	},
1662 	[EM2860_BOARD_SAA711X_REFERENCE_DESIGN] = {
1663 		.name                = "EM2860/SAA711X Reference Design",
1664 		.buttons = std_snapshot_button,
1665 		.tuner_type          = TUNER_ABSENT,
1666 		.decoder             = EM28XX_SAA711X,
1667 		.input               = { {
1668 			.type     = EM28XX_VMUX_SVIDEO,
1669 			.vmux     = SAA7115_SVIDEO3,
1670 		}, {
1671 			.type     = EM28XX_VMUX_COMPOSITE,
1672 			.vmux     = SAA7115_COMPOSITE0,
1673 		} },
1674 	},
1675 
1676 	[EM2874_BOARD_LEADERSHIP_ISDBT] = {
1677 		.def_i2c_bus	= 1,
1678 		.i2c_speed      = EM28XX_I2C_CLK_WAIT_ENABLE |
1679 				  EM28XX_I2C_FREQ_100_KHZ,
1680 		.xclk		= EM28XX_XCLK_FREQUENCY_10MHZ,
1681 		.name		= "EM2874 Leadership ISDBT",
1682 		.tuner_type	= TUNER_ABSENT,
1683 		.tuner_gpio     = leadership_reset,
1684 		.dvb_gpio       = leadership_digital,
1685 		.has_dvb	= 1,
1686 	},
1687 
1688 	[EM2880_BOARD_MSI_DIGIVOX_AD] = {
1689 		.name         = "MSI DigiVox A/D",
1690 		.valid        = EM28XX_BOARD_NOT_VALIDATED,
1691 		.tuner_type   = TUNER_XC2028,
1692 		.tuner_gpio   = default_tuner_gpio,
1693 		.decoder      = EM28XX_TVP5150,
1694 		.input        = { {
1695 			.type     = EM28XX_VMUX_TELEVISION,
1696 			.vmux     = TVP5150_COMPOSITE0,
1697 			.amux     = EM28XX_AMUX_VIDEO,
1698 			.gpio     = em2880_msi_digivox_ad_analog,
1699 		}, {
1700 			.type     = EM28XX_VMUX_COMPOSITE,
1701 			.vmux     = TVP5150_COMPOSITE1,
1702 			.amux     = EM28XX_AMUX_LINE_IN,
1703 			.gpio     = em2880_msi_digivox_ad_analog,
1704 		}, {
1705 			.type     = EM28XX_VMUX_SVIDEO,
1706 			.vmux     = TVP5150_SVIDEO,
1707 			.amux     = EM28XX_AMUX_LINE_IN,
1708 			.gpio     = em2880_msi_digivox_ad_analog,
1709 		} },
1710 	},
1711 	[EM2880_BOARD_MSI_DIGIVOX_AD_II] = {
1712 		.name         = "MSI DigiVox A/D II",
1713 		.valid        = EM28XX_BOARD_NOT_VALIDATED,
1714 		.tuner_type   = TUNER_XC2028,
1715 		.tuner_gpio   = default_tuner_gpio,
1716 		.decoder      = EM28XX_TVP5150,
1717 		.input        = { {
1718 			.type     = EM28XX_VMUX_TELEVISION,
1719 			.vmux     = TVP5150_COMPOSITE0,
1720 			.amux     = EM28XX_AMUX_VIDEO,
1721 			.gpio     = em2880_msi_digivox_ad_analog,
1722 		}, {
1723 			.type     = EM28XX_VMUX_COMPOSITE,
1724 			.vmux     = TVP5150_COMPOSITE1,
1725 			.amux     = EM28XX_AMUX_LINE_IN,
1726 			.gpio     = em2880_msi_digivox_ad_analog,
1727 		}, {
1728 			.type     = EM28XX_VMUX_SVIDEO,
1729 			.vmux     = TVP5150_SVIDEO,
1730 			.amux     = EM28XX_AMUX_LINE_IN,
1731 			.gpio     = em2880_msi_digivox_ad_analog,
1732 		} },
1733 	},
1734 	[EM2880_BOARD_KWORLD_DVB_305U] = {
1735 		.name	      = "KWorld DVB-T 305U",
1736 		.tuner_type   = TUNER_XC2028,
1737 		.tuner_gpio   = default_tuner_gpio,
1738 		.decoder      = EM28XX_TVP5150,
1739 		.input        = { {
1740 			.type     = EM28XX_VMUX_TELEVISION,
1741 			.vmux     = TVP5150_COMPOSITE0,
1742 			.amux     = EM28XX_AMUX_VIDEO,
1743 		}, {
1744 			.type     = EM28XX_VMUX_COMPOSITE,
1745 			.vmux     = TVP5150_COMPOSITE1,
1746 			.amux     = EM28XX_AMUX_LINE_IN,
1747 		}, {
1748 			.type     = EM28XX_VMUX_SVIDEO,
1749 			.vmux     = TVP5150_SVIDEO,
1750 			.amux     = EM28XX_AMUX_LINE_IN,
1751 		} },
1752 	},
1753 	[EM2880_BOARD_KWORLD_DVB_310U] = {
1754 		.name	      = "KWorld DVB-T 310U",
1755 		.tuner_type   = TUNER_XC2028,
1756 		.tuner_gpio   = default_tuner_gpio,
1757 		.has_dvb      = 1,
1758 		.dvb_gpio     = default_digital,
1759 		.mts_firmware = 1,
1760 		.decoder      = EM28XX_TVP5150,
1761 		.input        = { {
1762 			.type     = EM28XX_VMUX_TELEVISION,
1763 			.vmux     = TVP5150_COMPOSITE0,
1764 			.amux     = EM28XX_AMUX_VIDEO,
1765 			.gpio     = default_analog,
1766 		}, {
1767 			.type     = EM28XX_VMUX_COMPOSITE,
1768 			.vmux     = TVP5150_COMPOSITE1,
1769 			.amux     = EM28XX_AMUX_LINE_IN,
1770 			.gpio     = default_analog,
1771 		}, {	/* S-video has not been tested yet */
1772 			.type     = EM28XX_VMUX_SVIDEO,
1773 			.vmux     = TVP5150_SVIDEO,
1774 			.amux     = EM28XX_AMUX_LINE_IN,
1775 			.gpio     = default_analog,
1776 		} },
1777 	},
1778 	[EM2882_BOARD_KWORLD_ATSC_315U] = {
1779 		.name		= "KWorld ATSC 315U HDTV TV Box",
1780 		.valid		= EM28XX_BOARD_NOT_VALIDATED,
1781 		.tuner_type	= TUNER_THOMSON_DTT761X,
1782 		.tuner_gpio	= em2882_kworld_315u_tuner_gpio,
1783 		.tda9887_conf	= TDA9887_PRESENT,
1784 		.decoder	= EM28XX_SAA711X,
1785 		.has_dvb	= 1,
1786 		.dvb_gpio	= em2882_kworld_315u_digital,
1787 		.ir_codes	= RC_MAP_KWORLD_315U,
1788 		.xclk		= EM28XX_XCLK_FREQUENCY_12MHZ,
1789 		.i2c_speed	= EM28XX_I2C_CLK_WAIT_ENABLE,
1790 #if 0
1791 		/* FIXME: Analog mode - still not ready */
1792 		.input        = { {
1793 			.type = EM28XX_VMUX_TELEVISION,
1794 			.vmux = SAA7115_COMPOSITE2,
1795 			.amux = EM28XX_AMUX_VIDEO,
1796 			.gpio = em2882_kworld_315u_analog,
1797 			.aout = EM28XX_AOUT_PCM_IN | EM28XX_AOUT_PCM_STEREO,
1798 		}, {
1799 			.type = EM28XX_VMUX_COMPOSITE,
1800 			.vmux = SAA7115_COMPOSITE0,
1801 			.amux = EM28XX_AMUX_LINE_IN,
1802 			.gpio = em2882_kworld_315u_analog1,
1803 			.aout = EM28XX_AOUT_PCM_IN | EM28XX_AOUT_PCM_STEREO,
1804 		}, {
1805 			.type = EM28XX_VMUX_SVIDEO,
1806 			.vmux = SAA7115_SVIDEO3,
1807 			.amux = EM28XX_AMUX_LINE_IN,
1808 			.gpio = em2882_kworld_315u_analog1,
1809 			.aout = EM28XX_AOUT_PCM_IN | EM28XX_AOUT_PCM_STEREO,
1810 		} },
1811 #endif
1812 	},
1813 	[EM2880_BOARD_EMPIRE_DUAL_TV] = {
1814 		.name = "Empire dual TV",
1815 		.tuner_type = TUNER_XC2028,
1816 		.tuner_gpio = default_tuner_gpio,
1817 		.has_dvb = 1,
1818 		.dvb_gpio = default_digital,
1819 		.mts_firmware = 1,
1820 		.decoder = EM28XX_TVP5150,
1821 		.input = { {
1822 			.type = EM28XX_VMUX_TELEVISION,
1823 			.vmux = TVP5150_COMPOSITE0,
1824 			.amux = EM28XX_AMUX_VIDEO,
1825 			.gpio = default_analog,
1826 		}, {
1827 			.type = EM28XX_VMUX_COMPOSITE,
1828 			.vmux = TVP5150_COMPOSITE1,
1829 			.amux = EM28XX_AMUX_LINE_IN,
1830 			.gpio = default_analog,
1831 		}, {
1832 			.type = EM28XX_VMUX_SVIDEO,
1833 			.vmux = TVP5150_SVIDEO,
1834 			.amux = EM28XX_AMUX_LINE_IN,
1835 			.gpio = default_analog,
1836 		} },
1837 	},
1838 	[EM2881_BOARD_DNT_DA2_HYBRID] = {
1839 		.name         = "DNT DA2 Hybrid",
1840 		.valid        = EM28XX_BOARD_NOT_VALIDATED,
1841 		.tuner_type   = TUNER_XC2028,
1842 		.tuner_gpio   = default_tuner_gpio,
1843 		.decoder      = EM28XX_TVP5150,
1844 		.input        = { {
1845 			.type     = EM28XX_VMUX_TELEVISION,
1846 			.vmux     = TVP5150_COMPOSITE0,
1847 			.amux     = EM28XX_AMUX_VIDEO,
1848 			.gpio     = default_analog,
1849 		}, {
1850 			.type     = EM28XX_VMUX_COMPOSITE,
1851 			.vmux     = TVP5150_COMPOSITE1,
1852 			.amux     = EM28XX_AMUX_LINE_IN,
1853 			.gpio     = default_analog,
1854 		}, {
1855 			.type     = EM28XX_VMUX_SVIDEO,
1856 			.vmux     = TVP5150_SVIDEO,
1857 			.amux     = EM28XX_AMUX_LINE_IN,
1858 			.gpio     = default_analog,
1859 		} },
1860 	},
1861 	[EM2881_BOARD_PINNACLE_HYBRID_PRO] = {
1862 		.name         = "Pinnacle Hybrid Pro",
1863 		.tuner_type   = TUNER_XC2028,
1864 		.tuner_gpio   = default_tuner_gpio,
1865 		.decoder      = EM28XX_TVP5150,
1866 		.has_dvb      = 1,
1867 		.dvb_gpio     = pinnacle_hybrid_pro_digital,
1868 		.input        = { {
1869 			.type     = EM28XX_VMUX_TELEVISION,
1870 			.vmux     = TVP5150_COMPOSITE0,
1871 			.amux     = EM28XX_AMUX_VIDEO,
1872 			.gpio     = pinnacle_hybrid_pro_analog,
1873 		}, {
1874 			.type     = EM28XX_VMUX_COMPOSITE,
1875 			.vmux     = TVP5150_COMPOSITE1,
1876 			.amux     = EM28XX_AMUX_LINE_IN,
1877 			.gpio     = pinnacle_hybrid_pro_analog,
1878 		}, {
1879 			.type     = EM28XX_VMUX_SVIDEO,
1880 			.vmux     = TVP5150_SVIDEO,
1881 			.amux     = EM28XX_AMUX_LINE_IN,
1882 			.gpio     = pinnacle_hybrid_pro_analog,
1883 		} },
1884 	},
1885 	[EM2882_BOARD_PINNACLE_HYBRID_PRO_330E] = {
1886 		.name         = "Pinnacle Hybrid Pro (330e)",
1887 		.tuner_type   = TUNER_XC2028,
1888 		.tuner_gpio   = default_tuner_gpio,
1889 		.mts_firmware = 1,
1890 		.has_dvb      = 1,
1891 		.dvb_gpio     = hauppauge_wintv_hvr_900R2_digital,
1892 		.ir_codes     = RC_MAP_PINNACLE_PCTV_HD,
1893 		.decoder      = EM28XX_TVP5150,
1894 		.input        = { {
1895 			.type     = EM28XX_VMUX_TELEVISION,
1896 			.vmux     = TVP5150_COMPOSITE0,
1897 			.amux     = EM28XX_AMUX_VIDEO,
1898 			.gpio     = hauppauge_wintv_hvr_900_analog,
1899 		}, {
1900 			.type     = EM28XX_VMUX_COMPOSITE,
1901 			.vmux     = TVP5150_COMPOSITE1,
1902 			.amux     = EM28XX_AMUX_LINE_IN,
1903 			.gpio     = hauppauge_wintv_hvr_900_analog,
1904 		}, {
1905 			.type     = EM28XX_VMUX_SVIDEO,
1906 			.vmux     = TVP5150_SVIDEO,
1907 			.amux     = EM28XX_AMUX_LINE_IN,
1908 			.gpio     = hauppauge_wintv_hvr_900_analog,
1909 		} },
1910 	},
1911 	[EM2882_BOARD_KWORLD_VS_DVBT] = {
1912 		.name         = "Kworld VS-DVB-T 323UR",
1913 		.tuner_type   = TUNER_XC2028,
1914 		.tuner_gpio   = default_tuner_gpio,
1915 		.decoder      = EM28XX_TVP5150,
1916 		.mts_firmware = 1,
1917 		.has_dvb      = 1,
1918 		.dvb_gpio     = kworld_330u_digital,
1919 		.xclk         = EM28XX_XCLK_FREQUENCY_12MHZ, /* NEC IR */
1920 		.ir_codes     = RC_MAP_KWORLD_315U,
1921 		.input        = { {
1922 			.type     = EM28XX_VMUX_TELEVISION,
1923 			.vmux     = TVP5150_COMPOSITE0,
1924 			.amux     = EM28XX_AMUX_VIDEO,
1925 		}, {
1926 			.type     = EM28XX_VMUX_COMPOSITE,
1927 			.vmux     = TVP5150_COMPOSITE1,
1928 			.amux     = EM28XX_AMUX_LINE_IN,
1929 		}, {
1930 			.type     = EM28XX_VMUX_SVIDEO,
1931 			.vmux     = TVP5150_SVIDEO,
1932 			.amux     = EM28XX_AMUX_LINE_IN,
1933 		} },
1934 	},
1935 	[EM2882_BOARD_TERRATEC_HYBRID_XS] = {
1936 		.name         = "Terratec Cinnergy Hybrid T USB XS (em2882)",
1937 		.tuner_type   = TUNER_XC2028,
1938 		.tuner_gpio   = default_tuner_gpio,
1939 		.mts_firmware = 1,
1940 		.decoder      = EM28XX_TVP5150,
1941 		.has_dvb      = 1,
1942 		.dvb_gpio     = hauppauge_wintv_hvr_900_digital,
1943 		.ir_codes     = RC_MAP_TERRATEC_CINERGY_XS,
1944 		.xclk         = EM28XX_XCLK_FREQUENCY_12MHZ,
1945 		.input        = { {
1946 			.type     = EM28XX_VMUX_TELEVISION,
1947 			.vmux     = TVP5150_COMPOSITE0,
1948 			.amux     = EM28XX_AMUX_VIDEO,
1949 			.gpio     = hauppauge_wintv_hvr_900_analog,
1950 		}, {
1951 			.type     = EM28XX_VMUX_COMPOSITE,
1952 			.vmux     = TVP5150_COMPOSITE1,
1953 			.amux     = EM28XX_AMUX_LINE_IN,
1954 			.gpio     = hauppauge_wintv_hvr_900_analog,
1955 		}, {
1956 			.type     = EM28XX_VMUX_SVIDEO,
1957 			.vmux     = TVP5150_SVIDEO,
1958 			.amux     = EM28XX_AMUX_LINE_IN,
1959 			.gpio     = hauppauge_wintv_hvr_900_analog,
1960 		} },
1961 	},
1962 	[EM2882_BOARD_DIKOM_DK300] = {
1963 		.name         = "Dikom DK300",
1964 		.tuner_type   = TUNER_XC2028,
1965 		.tuner_gpio   = default_tuner_gpio,
1966 		.decoder      = EM28XX_TVP5150,
1967 		.mts_firmware = 1,
1968 		.has_dvb      = 1,
1969 		.dvb_gpio     = dikom_dk300_digital,
1970 		.input        = { {
1971 			.type     = EM28XX_VMUX_TELEVISION,
1972 			.vmux     = TVP5150_COMPOSITE0,
1973 			.amux     = EM28XX_AMUX_VIDEO,
1974 			.gpio     = default_analog,
1975 		} },
1976 	},
1977 	[EM2883_BOARD_KWORLD_HYBRID_330U] = {
1978 		.name         = "Kworld PlusTV HD Hybrid 330",
1979 		.tuner_type   = TUNER_XC2028,
1980 		.tuner_gpio   = default_tuner_gpio,
1981 		.decoder      = EM28XX_TVP5150,
1982 		.mts_firmware = 1,
1983 		.has_dvb      = 1,
1984 		.dvb_gpio     = kworld_330u_digital,
1985 		.xclk             = EM28XX_XCLK_FREQUENCY_12MHZ,
1986 		.i2c_speed        = EM28XX_I2C_CLK_WAIT_ENABLE |
1987 				    EM28XX_I2C_EEPROM_ON_BOARD |
1988 				    EM28XX_I2C_EEPROM_KEY_VALID,
1989 		.input        = { {
1990 			.type     = EM28XX_VMUX_TELEVISION,
1991 			.vmux     = TVP5150_COMPOSITE0,
1992 			.amux     = EM28XX_AMUX_VIDEO,
1993 			.gpio     = kworld_330u_analog,
1994 			.aout     = EM28XX_AOUT_PCM_IN | EM28XX_AOUT_PCM_STEREO,
1995 		}, {
1996 			.type     = EM28XX_VMUX_COMPOSITE,
1997 			.vmux     = TVP5150_COMPOSITE1,
1998 			.amux     = EM28XX_AMUX_LINE_IN,
1999 			.gpio     = kworld_330u_analog,
2000 			.aout     = EM28XX_AOUT_PCM_IN | EM28XX_AOUT_PCM_STEREO,
2001 		}, {
2002 			.type     = EM28XX_VMUX_SVIDEO,
2003 			.vmux     = TVP5150_SVIDEO,
2004 			.amux     = EM28XX_AMUX_LINE_IN,
2005 			.gpio     = kworld_330u_analog,
2006 		} },
2007 	},
2008 	[EM2820_BOARD_COMPRO_VIDEOMATE_FORYOU] = {
2009 		.name         = "Compro VideoMate ForYou/Stereo",
2010 		.tuner_type   = TUNER_LG_PAL_NEW_TAPC,
2011 		.tvaudio_addr = 0xb0,
2012 		.tda9887_conf = TDA9887_PRESENT,
2013 		.decoder      = EM28XX_TVP5150,
2014 		.adecoder     = EM28XX_TVAUDIO,
2015 		.mute_gpio    = compro_mute_gpio,
2016 		.input        = { {
2017 			.type     = EM28XX_VMUX_TELEVISION,
2018 			.vmux     = TVP5150_COMPOSITE0,
2019 			.amux     = EM28XX_AMUX_VIDEO,
2020 			.gpio     = compro_unmute_tv_gpio,
2021 		}, {
2022 			.type     = EM28XX_VMUX_SVIDEO,
2023 			.vmux     = TVP5150_SVIDEO,
2024 			.amux     = EM28XX_AMUX_LINE_IN,
2025 			.gpio     = compro_unmute_svid_gpio,
2026 		} },
2027 	},
2028 	[EM2860_BOARD_KAIOMY_TVNPC_U2] = {
2029 		.name	      = "Kaiomy TVnPC U2",
2030 		.vchannels    = 3,
2031 		.tuner_type   = TUNER_XC2028,
2032 		.tuner_addr   = 0x61,
2033 		.mts_firmware = 1,
2034 		.decoder      = EM28XX_TVP5150,
2035 		.tuner_gpio   = default_tuner_gpio,
2036 		.ir_codes     = RC_MAP_KAIOMY,
2037 		.input          = { {
2038 			.type     = EM28XX_VMUX_TELEVISION,
2039 			.vmux     = TVP5150_COMPOSITE0,
2040 			.amux     = EM28XX_AMUX_VIDEO,
2041 
2042 		}, {
2043 			.type     = EM28XX_VMUX_COMPOSITE,
2044 			.vmux     = TVP5150_COMPOSITE1,
2045 			.amux     = EM28XX_AMUX_LINE_IN,
2046 		}, {
2047 			.type     = EM28XX_VMUX_SVIDEO,
2048 			.vmux     = TVP5150_SVIDEO,
2049 			.amux     = EM28XX_AMUX_LINE_IN,
2050 		} },
2051 		.radio		= {
2052 			.type     = EM28XX_RADIO,
2053 			.amux     = EM28XX_AMUX_LINE_IN,
2054 		}
2055 	},
2056 	[EM2860_BOARD_EASYCAP] = {
2057 		.name         = "Easy Cap Capture DC-60",
2058 		.vchannels    = 2,
2059 		.tuner_type   = TUNER_ABSENT,
2060 		.decoder      = EM28XX_SAA711X,
2061 		.input           = { {
2062 			.type     = EM28XX_VMUX_COMPOSITE,
2063 			.vmux     = SAA7115_COMPOSITE0,
2064 			.amux     = EM28XX_AMUX_LINE_IN,
2065 		}, {
2066 			.type     = EM28XX_VMUX_SVIDEO,
2067 			.vmux     = SAA7115_SVIDEO3,
2068 			.amux     = EM28XX_AMUX_LINE_IN,
2069 		} },
2070 	},
2071 	[EM2820_BOARD_IODATA_GVMVP_SZ] = {
2072 		.name       = "IO-DATA GV-MVP/SZ",
2073 		.tuner_type   = TUNER_PHILIPS_FM1236_MK3,
2074 		.tuner_gpio   = default_tuner_gpio,
2075 		.tda9887_conf = TDA9887_PRESENT,
2076 		.decoder      = EM28XX_TVP5150,
2077 		.input        = { {
2078 			.type     = EM28XX_VMUX_TELEVISION,
2079 			.vmux     = TVP5150_COMPOSITE0,
2080 			.amux     = EM28XX_AMUX_VIDEO,
2081 		}, { /* Composite has not been tested yet */
2082 			.type     = EM28XX_VMUX_COMPOSITE,
2083 			.vmux     = TVP5150_COMPOSITE1,
2084 			.amux     = EM28XX_AMUX_VIDEO,
2085 		}, { /* S-video has not been tested yet */
2086 			.type     = EM28XX_VMUX_SVIDEO,
2087 			.vmux     = TVP5150_SVIDEO,
2088 			.amux     = EM28XX_AMUX_VIDEO,
2089 		} },
2090 	},
2091 	[EM2860_BOARD_TERRATEC_GRABBY] = {
2092 		.name            = "Terratec Grabby",
2093 		.vchannels       = 2,
2094 		.tuner_type      = TUNER_ABSENT,
2095 		.decoder         = EM28XX_SAA711X,
2096 		.xclk            = EM28XX_XCLK_FREQUENCY_12MHZ,
2097 		.input           = { {
2098 			.type     = EM28XX_VMUX_COMPOSITE,
2099 			.vmux     = SAA7115_COMPOSITE0,
2100 			.amux     = EM28XX_AMUX_LINE_IN,
2101 		}, {
2102 			.type     = EM28XX_VMUX_SVIDEO,
2103 			.vmux     = SAA7115_SVIDEO3,
2104 			.amux     = EM28XX_AMUX_LINE_IN,
2105 		} },
2106 		.buttons         = std_snapshot_button,
2107 		.leds            = terratec_grabby_leds,
2108 	},
2109 	[EM2860_BOARD_TERRATEC_AV350] = {
2110 		.name            = "Terratec AV350",
2111 		.vchannels       = 2,
2112 		.tuner_type      = TUNER_ABSENT,
2113 		.decoder         = EM28XX_TVP5150,
2114 		.xclk            = EM28XX_XCLK_FREQUENCY_12MHZ,
2115 		.mute_gpio       = terratec_av350_mute_gpio,
2116 		.input           = { {
2117 			.type     = EM28XX_VMUX_COMPOSITE,
2118 			.vmux     = TVP5150_COMPOSITE1,
2119 			.amux     = EM28XX_AUDIO_SRC_LINE,
2120 			.gpio     = terratec_av350_unmute_gpio,
2121 
2122 		}, {
2123 			.type     = EM28XX_VMUX_SVIDEO,
2124 			.vmux     = TVP5150_SVIDEO,
2125 			.amux     = EM28XX_AUDIO_SRC_LINE,
2126 			.gpio     = terratec_av350_unmute_gpio,
2127 		} },
2128 	},
2129 
2130 	[EM2860_BOARD_ELGATO_VIDEO_CAPTURE] = {
2131 		.name         = "Elgato Video Capture",
2132 		.decoder      = EM28XX_SAA711X,
2133 		.tuner_type   = TUNER_ABSENT,   /* Capture only device */
2134 		.input        = { {
2135 			.type  = EM28XX_VMUX_COMPOSITE,
2136 			.vmux  = SAA7115_COMPOSITE0,
2137 			.amux  = EM28XX_AMUX_LINE_IN,
2138 		}, {
2139 			.type  = EM28XX_VMUX_SVIDEO,
2140 			.vmux  = SAA7115_SVIDEO3,
2141 			.amux  = EM28XX_AMUX_LINE_IN,
2142 		} },
2143 	},
2144 
2145 	[EM2882_BOARD_EVGA_INDTUBE] = {
2146 		.name         = "Evga inDtube",
2147 		.tuner_type   = TUNER_XC2028,
2148 		.tuner_gpio   = default_tuner_gpio,
2149 		.decoder      = EM28XX_TVP5150,
2150 		.xclk         = EM28XX_XCLK_FREQUENCY_12MHZ, /* NEC IR */
2151 		.mts_firmware = 1,
2152 		.has_dvb      = 1,
2153 		.dvb_gpio     = evga_indtube_digital,
2154 		.ir_codes     = RC_MAP_EVGA_INDTUBE,
2155 		.input        = { {
2156 			.type     = EM28XX_VMUX_TELEVISION,
2157 			.vmux     = TVP5150_COMPOSITE0,
2158 			.amux     = EM28XX_AMUX_VIDEO,
2159 			.gpio     = evga_indtube_analog,
2160 		}, {
2161 			.type     = EM28XX_VMUX_COMPOSITE,
2162 			.vmux     = TVP5150_COMPOSITE1,
2163 			.amux     = EM28XX_AMUX_LINE_IN,
2164 			.gpio     = evga_indtube_analog,
2165 		}, {
2166 			.type     = EM28XX_VMUX_SVIDEO,
2167 			.vmux     = TVP5150_SVIDEO,
2168 			.amux     = EM28XX_AMUX_LINE_IN,
2169 			.gpio     = evga_indtube_analog,
2170 		} },
2171 	},
2172 	/*
2173 	 * eb1a:2868 Empia EM2870 + Philips CU1216L NIM
2174 	 * (Philips TDA10023 + Infineon TUA6034)
2175 	 */
2176 	[EM2870_BOARD_REDDO_DVB_C_USB_BOX] = {
2177 		.name          = "Reddo DVB-C USB TV Box",
2178 		.tuner_type    = TUNER_ABSENT,
2179 		.tuner_gpio    = reddo_dvb_c_usb_box,
2180 		.has_dvb       = 1,
2181 	},
2182 	/*
2183 	 * 1b80:a340 - Empia EM2870, NXP TDA18271HD and LG DT3304, sold
2184 	 * initially as the KWorld PlusTV 340U, then as the UB435-Q.
2185 	 * Early variants have a TDA18271HD/C1, later ones a TDA18271HD/C2
2186 	 */
2187 	[EM2870_BOARD_KWORLD_A340] = {
2188 		.name       = "KWorld PlusTV 340U or UB435-Q (ATSC)",
2189 		.tuner_type = TUNER_ABSENT,	/* Digital-only TDA18271HD */
2190 		.has_dvb    = 1,
2191 		.dvb_gpio   = kworld_a340_digital,
2192 		.tuner_gpio = default_tuner_gpio,
2193 	},
2194 	/*
2195 	 * 2013:024f PCTV nanoStick T2 290e.
2196 	 * Empia EM28174, Sony CXD2820R and NXP TDA18271HD/C2
2197 	 */
2198 	[EM28174_BOARD_PCTV_290E] = {
2199 		.name          = "PCTV nanoStick T2 290e",
2200 		.def_i2c_bus   = 1,
2201 		.i2c_speed     = EM28XX_I2C_CLK_WAIT_ENABLE |
2202 				 EM28XX_I2C_FREQ_100_KHZ,
2203 		.tuner_type    = TUNER_ABSENT,
2204 		.tuner_gpio    = pctv_290e,
2205 		.has_dvb       = 1,
2206 		.ir_codes      = RC_MAP_PINNACLE_PCTV_HD,
2207 	},
2208 	/*
2209 	 * 2013:024f PCTV DVB-S2 Stick 460e
2210 	 * Empia EM28174, NXP TDA10071, Conexant CX24118A and Allegro A8293
2211 	 */
2212 	[EM28174_BOARD_PCTV_460E] = {
2213 		.def_i2c_bus   = 1,
2214 		.i2c_speed     = EM28XX_I2C_CLK_WAIT_ENABLE |
2215 				 EM28XX_I2C_FREQ_400_KHZ,
2216 		.name          = "PCTV DVB-S2 Stick (460e)",
2217 		.tuner_type    = TUNER_ABSENT,
2218 		.tuner_gpio    = pctv_460e,
2219 		.has_dvb       = 1,
2220 		.ir_codes      = RC_MAP_PINNACLE_PCTV_HD,
2221 	},
2222 	/*
2223 	 * eb1a:5006 Honestech VIDBOX NW03
2224 	 * Empia EM2860, Philips SAA7113, Empia EMP202, No Tuner
2225 	 */
2226 	[EM2860_BOARD_HT_VIDBOX_NW03] = {
2227 		.name                = "Honestech Vidbox NW03",
2228 		.tuner_type          = TUNER_ABSENT,
2229 		.decoder             = EM28XX_SAA711X,
2230 		.input               = { {
2231 			.type     = EM28XX_VMUX_COMPOSITE,
2232 			.vmux     = SAA7115_COMPOSITE0,
2233 			.amux     = EM28XX_AMUX_LINE_IN,
2234 		}, {
2235 			.type     = EM28XX_VMUX_SVIDEO,
2236 			.vmux     = SAA7115_SVIDEO3,  /* S-VIDEO needs check */
2237 			.amux     = EM28XX_AMUX_LINE_IN,
2238 		} },
2239 	},
2240 	/*
2241 	 * 1b80:e425 MaxMedia UB425-TC
2242 	 * Empia EM2874B + Micronas DRX 3913KA2 + NXP TDA18271HDC2
2243 	 */
2244 	[EM2874_BOARD_MAXMEDIA_UB425_TC] = {
2245 		.name          = "MaxMedia UB425-TC",
2246 		.tuner_type    = TUNER_ABSENT,
2247 		.tuner_gpio    = maxmedia_ub425_tc,
2248 		.has_dvb       = 1,
2249 		.ir_codes      = RC_MAP_REDDO,
2250 		.def_i2c_bus   = 1,
2251 		.i2c_speed     = EM28XX_I2C_CLK_WAIT_ENABLE |
2252 				EM28XX_I2C_FREQ_400_KHZ,
2253 	},
2254 	/*
2255 	 * 2304:0242 PCTV QuatroStick (510e)
2256 	 * Empia EM2884 + Micronas DRX 3926K + NXP TDA18271HDC2
2257 	 */
2258 	[EM2884_BOARD_PCTV_510E] = {
2259 		.name          = "PCTV QuatroStick (510e)",
2260 		.tuner_type    = TUNER_ABSENT,
2261 		.tuner_gpio    = pctv_510e,
2262 		.has_dvb       = 1,
2263 		.ir_codes      = RC_MAP_PINNACLE_PCTV_HD,
2264 		.def_i2c_bus   = 1,
2265 		.i2c_speed     = EM28XX_I2C_CLK_WAIT_ENABLE |
2266 				EM28XX_I2C_FREQ_400_KHZ,
2267 	},
2268 	/*
2269 	 * 2013:0251 PCTV QuatroStick nano (520e)
2270 	 * Empia EM2884 + Micronas DRX 3926K + NXP TDA18271HDC2
2271 	 */
2272 	[EM2884_BOARD_PCTV_520E] = {
2273 		.name          = "PCTV QuatroStick nano (520e)",
2274 		.tuner_type    = TUNER_ABSENT,
2275 		.tuner_gpio    = pctv_520e,
2276 		.has_dvb       = 1,
2277 		.ir_codes      = RC_MAP_PINNACLE_PCTV_HD,
2278 		.def_i2c_bus   = 1,
2279 		.i2c_speed     = EM28XX_I2C_CLK_WAIT_ENABLE |
2280 				EM28XX_I2C_FREQ_400_KHZ,
2281 	},
2282 	[EM2884_BOARD_TERRATEC_HTC_USB_XS] = {
2283 		.name         = "Terratec Cinergy HTC USB XS",
2284 		.has_dvb      = 1,
2285 		.ir_codes     = RC_MAP_NEC_TERRATEC_CINERGY_XS,
2286 		.tuner_type   = TUNER_ABSENT,
2287 		.def_i2c_bus  = 1,
2288 		.i2c_speed    = EM28XX_I2C_CLK_WAIT_ENABLE |
2289 				EM28XX_I2C_FREQ_400_KHZ,
2290 	},
2291 	/*
2292 	 * 1b80:e1cc Delock 61959
2293 	 * Empia EM2874B + Micronas DRX 3913KA2 + NXP TDA18271HDC2
2294 	 * mostly the same as MaxMedia UB-425-TC but different remote
2295 	 */
2296 	[EM2874_BOARD_DELOCK_61959] = {
2297 		.name          = "Delock 61959",
2298 		.tuner_type    = TUNER_ABSENT,
2299 		.tuner_gpio    = maxmedia_ub425_tc,
2300 		.has_dvb       = 1,
2301 		.ir_codes      = RC_MAP_DELOCK_61959,
2302 		.def_i2c_bus   = 1,
2303 		.i2c_speed     = EM28XX_I2C_CLK_WAIT_ENABLE |
2304 				EM28XX_I2C_FREQ_400_KHZ,
2305 	},
2306 	/*
2307 	 * 1b80:e346 KWorld USB ATSC TV Stick UB435-Q V2
2308 	 * Empia EM2874B + LG DT3305 + NXP TDA18271HDC2
2309 	 */
2310 	[EM2874_BOARD_KWORLD_UB435Q_V2] = {
2311 		.name		= "KWorld USB ATSC TV Stick UB435-Q V2",
2312 		.tuner_type	= TUNER_ABSENT,
2313 		.has_dvb	= 1,
2314 		.dvb_gpio	= kworld_a340_digital,
2315 		.tuner_gpio	= default_tuner_gpio,
2316 		.def_i2c_bus	= 1,
2317 	},
2318 	/*
2319 	 * 1b80:e34c KWorld USB ATSC TV Stick UB435-Q V3
2320 	 * Empia EM2874B + LG DT3305 + NXP TDA18271HDC2
2321 	 */
2322 	[EM2874_BOARD_KWORLD_UB435Q_V3] = {
2323 		.name		= "KWorld USB ATSC TV Stick UB435-Q V3",
2324 		.tuner_type	= TUNER_ABSENT,
2325 		.has_dvb	= 1,
2326 		.tuner_gpio	= kworld_ub435q_v3_digital,
2327 		.def_i2c_bus	= 1,
2328 		.i2c_speed      = EM28XX_I2C_CLK_WAIT_ENABLE |
2329 				  EM28XX_I2C_FREQ_100_KHZ,
2330 		.leds = kworld_ub435q_v3_leds,
2331 	},
2332 	[EM2874_BOARD_PCTV_HD_MINI_80E] = {
2333 		.name         = "Pinnacle PCTV HD Mini",
2334 		.tuner_type   = TUNER_ABSENT,
2335 		.has_dvb      = 1,
2336 		.dvb_gpio     = em2874_pctv_80e_digital,
2337 		.decoder      = EM28XX_NODECODER,
2338 		.ir_codes     = RC_MAP_PINNACLE_PCTV_HD,
2339 		.leds         = pctv_80e_leds,
2340 	},
2341 	/*
2342 	 * 1ae7:9003/9004 SpeedLink Vicious And Devine Laplace webcam
2343 	 * Empia EM2765 + OmniVision OV2640
2344 	 */
2345 	[EM2765_BOARD_SPEEDLINK_VAD_LAPLACE] = {
2346 		.name         = "SpeedLink Vicious And Devine Laplace webcam",
2347 		.xclk         = EM28XX_XCLK_FREQUENCY_24MHZ,
2348 		.i2c_speed    = EM28XX_I2C_CLK_WAIT_ENABLE |
2349 				EM28XX_I2C_FREQ_100_KHZ,
2350 		.def_i2c_bus  = 1,
2351 		.tuner_type   = TUNER_ABSENT,
2352 		.is_webcam    = 1,
2353 		.input        = { {
2354 			.type     = EM28XX_VMUX_COMPOSITE,
2355 			.amux     = EM28XX_AMUX_VIDEO,
2356 			.gpio     = speedlink_vad_laplace_reg_seq,
2357 		} },
2358 		.buttons = speedlink_vad_laplace_buttons,
2359 		.leds = speedlink_vad_laplace_leds,
2360 	},
2361 	/*
2362 	 * 2013:0258 PCTV DVB-S2 Stick (461e)
2363 	 * Empia EM28178, Montage M88DS3103, Montage M88TS2022, Allegro A8293
2364 	 */
2365 	[EM28178_BOARD_PCTV_461E] = {
2366 		.def_i2c_bus   = 1,
2367 		.i2c_speed     = EM28XX_I2C_CLK_WAIT_ENABLE |
2368 				 EM28XX_I2C_FREQ_400_KHZ,
2369 		.name          = "PCTV DVB-S2 Stick (461e)",
2370 		.tuner_type    = TUNER_ABSENT,
2371 		.tuner_gpio    = pctv_461e,
2372 		.has_dvb       = 1,
2373 		.ir_codes      = RC_MAP_PINNACLE_PCTV_HD,
2374 	},
2375 	/*
2376 	 * 2013:025f PCTV tripleStick (292e).
2377 	 * Empia EM28178, Silicon Labs Si2168, Silicon Labs Si2157
2378 	 */
2379 	[EM28178_BOARD_PCTV_292E] = {
2380 		.name          = "PCTV tripleStick (292e)",
2381 		.def_i2c_bus   = 1,
2382 		.i2c_speed     = EM28XX_I2C_CLK_WAIT_ENABLE |
2383 				 EM28XX_I2C_FREQ_400_KHZ,
2384 		.tuner_type    = TUNER_ABSENT,
2385 		.tuner_gpio    = pctv_292e,
2386 		.has_dvb       = 1,
2387 		.ir_codes      = RC_MAP_PINNACLE_PCTV_HD,
2388 	},
2389 	[EM2861_BOARD_LEADTEK_VC100] = {
2390 		.name          = "Leadtek VC100",
2391 		.tuner_type    = TUNER_ABSENT,	/* Capture only device */
2392 		.decoder       = EM28XX_TVP5150,
2393 		.input         = { {
2394 			.type     = EM28XX_VMUX_COMPOSITE,
2395 			.vmux     = TVP5150_COMPOSITE1,
2396 			.amux     = EM28XX_AMUX_LINE_IN,
2397 		}, {
2398 			.type     = EM28XX_VMUX_SVIDEO,
2399 			.vmux     = TVP5150_SVIDEO,
2400 			.amux     = EM28XX_AMUX_LINE_IN,
2401 		} },
2402 	},
2403 	/*
2404 	 * eb1a:8179 Terratec Cinergy T2 Stick HD.
2405 	 * Empia EM28178, Silicon Labs Si2168, Silicon Labs Si2146
2406 	 */
2407 	[EM28178_BOARD_TERRATEC_T2_STICK_HD] = {
2408 		.name          = "Terratec Cinergy T2 Stick HD",
2409 		.def_i2c_bus   = 1,
2410 		.i2c_speed     = EM28XX_I2C_CLK_WAIT_ENABLE |
2411 				 EM28XX_I2C_FREQ_400_KHZ,
2412 		.tuner_type    = TUNER_ABSENT,
2413 		.tuner_gpio    = terratec_t2_stick_hd,
2414 		.has_dvb       = 1,
2415 		.ir_codes      = RC_MAP_TERRATEC_SLIM_2,
2416 	},
2417 
2418 	/*
2419 	 * 3275:0085 PLEX PX-BCUD.
2420 	 * Empia EM28178, TOSHIBA TC90532XBG, Sharp QM1D1C0042
2421 	 */
2422 	[EM28178_BOARD_PLEX_PX_BCUD] = {
2423 		.name          = "PLEX PX-BCUD",
2424 		.xclk          = EM28XX_XCLK_FREQUENCY_4_3MHZ,
2425 		.def_i2c_bus   = 1,
2426 		.i2c_speed     = EM28XX_I2C_CLK_WAIT_ENABLE,
2427 		.tuner_type    = TUNER_ABSENT,
2428 		.tuner_gpio    = plex_px_bcud,
2429 		.has_dvb       = 1,
2430 	},
2431 	/*
2432 	 * 2040:0265 Hauppauge WinTV-dualHD (DVB version) Isoc.
2433 	 * 2040:8265 Hauppauge WinTV-dualHD (DVB version) Bulk.
2434 	 * Empia EM28274, 2x Silicon Labs Si2168, 2x Silicon Labs Si2157
2435 	 */
2436 	[EM28174_BOARD_HAUPPAUGE_WINTV_DUALHD_DVB] = {
2437 		.name          = "Hauppauge WinTV-dualHD DVB",
2438 		.def_i2c_bus   = 1,
2439 		.i2c_speed     = EM28XX_I2C_CLK_WAIT_ENABLE |
2440 				 EM28XX_I2C_FREQ_400_KHZ,
2441 		.tuner_type    = TUNER_ABSENT,
2442 		.tuner_gpio    = hauppauge_dualhd_dvb,
2443 		.has_dvb       = 1,
2444 		.has_dual_ts   = 1,
2445 		.ir_codes      = RC_MAP_HAUPPAUGE,
2446 		.leds          = hauppauge_dualhd_leds,
2447 	},
2448 	/*
2449 	 * 2040:026d Hauppauge WinTV-dualHD (model 01595 - ATSC/QAM) Isoc.
2450 	 * 2040:826d Hauppauge WinTV-dualHD (model 01595 - ATSC/QAM) Bulk.
2451 	 * Empia EM28274, 2x LG LGDT3306A, 2x Silicon Labs Si2157
2452 	 */
2453 	[EM28174_BOARD_HAUPPAUGE_WINTV_DUALHD_01595] = {
2454 		.name          = "Hauppauge WinTV-dualHD 01595 ATSC/QAM",
2455 		.def_i2c_bus   = 1,
2456 		.i2c_speed     = EM28XX_I2C_CLK_WAIT_ENABLE |
2457 				 EM28XX_I2C_FREQ_400_KHZ,
2458 		.tuner_type    = TUNER_ABSENT,
2459 		.tuner_gpio    = hauppauge_dualhd_dvb,
2460 		.has_dvb       = 1,
2461 		.has_dual_ts   = 1,
2462 		.ir_codes      = RC_MAP_HAUPPAUGE,
2463 		.leds          = hauppauge_dualhd_leds,
2464 	},
2465 };
2466 EXPORT_SYMBOL_GPL(em28xx_boards);
2467 
2468 static const unsigned int em28xx_bcount = ARRAY_SIZE(em28xx_boards);
2469 
2470 /* table of devices that work with this driver */
2471 struct usb_device_id em28xx_id_table[] = {
2472 	{ USB_DEVICE(0xeb1a, 0x2750),
2473 			.driver_info = EM2750_BOARD_UNKNOWN },
2474 	{ USB_DEVICE(0xeb1a, 0x2751),
2475 			.driver_info = EM2750_BOARD_UNKNOWN },
2476 	{ USB_DEVICE(0xeb1a, 0x2800),
2477 			.driver_info = EM2800_BOARD_UNKNOWN },
2478 	{ USB_DEVICE(0xeb1a, 0x2710),
2479 			.driver_info = EM2820_BOARD_UNKNOWN },
2480 	{ USB_DEVICE(0xeb1a, 0x2820),
2481 			.driver_info = EM2820_BOARD_UNKNOWN },
2482 	{ USB_DEVICE(0xeb1a, 0x2821),
2483 			.driver_info = EM2820_BOARD_UNKNOWN },
2484 	{ USB_DEVICE(0xeb1a, 0x2860),
2485 			.driver_info = EM2820_BOARD_UNKNOWN },
2486 	{ USB_DEVICE(0xeb1a, 0x2861),
2487 			.driver_info = EM2820_BOARD_UNKNOWN },
2488 	{ USB_DEVICE(0xeb1a, 0x2862),
2489 			.driver_info = EM2820_BOARD_UNKNOWN },
2490 	{ USB_DEVICE(0xeb1a, 0x2863),
2491 			.driver_info = EM2820_BOARD_UNKNOWN },
2492 	{ USB_DEVICE(0xeb1a, 0x2870),
2493 			.driver_info = EM2820_BOARD_UNKNOWN },
2494 	{ USB_DEVICE(0xeb1a, 0x2881),
2495 			.driver_info = EM2820_BOARD_UNKNOWN },
2496 	{ USB_DEVICE(0xeb1a, 0x2883),
2497 			.driver_info = EM2820_BOARD_UNKNOWN },
2498 	{ USB_DEVICE(0xeb1a, 0x2868),
2499 			.driver_info = EM2820_BOARD_UNKNOWN },
2500 	{ USB_DEVICE(0xeb1a, 0x2875),
2501 			.driver_info = EM2820_BOARD_UNKNOWN },
2502 	{ USB_DEVICE(0xeb1a, 0x2885), /* MSI Digivox Trio */
2503 			.driver_info = EM2884_BOARD_TERRATEC_H5 },
2504 	{ USB_DEVICE(0xeb1a, 0xe300),
2505 			.driver_info = EM2861_BOARD_KWORLD_PVRTV_300U },
2506 	{ USB_DEVICE(0xeb1a, 0xe303),
2507 			.driver_info = EM2860_BOARD_KAIOMY_TVNPC_U2 },
2508 	{ USB_DEVICE(0xeb1a, 0xe305),
2509 			.driver_info = EM2880_BOARD_KWORLD_DVB_305U },
2510 	{ USB_DEVICE(0xeb1a, 0xe310),
2511 			.driver_info = EM2880_BOARD_MSI_DIGIVOX_AD },
2512 	{ USB_DEVICE(0xeb1a, 0xa313),
2513 		.driver_info = EM2882_BOARD_KWORLD_ATSC_315U },
2514 	{ USB_DEVICE(0xeb1a, 0xa316),
2515 			.driver_info = EM2883_BOARD_KWORLD_HYBRID_330U },
2516 	{ USB_DEVICE(0xeb1a, 0xe320),
2517 			.driver_info = EM2880_BOARD_MSI_DIGIVOX_AD_II },
2518 	{ USB_DEVICE(0xeb1a, 0xe323),
2519 			.driver_info = EM2882_BOARD_KWORLD_VS_DVBT },
2520 	{ USB_DEVICE(0xeb1a, 0xe350),
2521 			.driver_info = EM2870_BOARD_KWORLD_350U },
2522 	{ USB_DEVICE(0xeb1a, 0xe355),
2523 			.driver_info = EM2870_BOARD_KWORLD_355U },
2524 	{ USB_DEVICE(0xeb1a, 0x2801),
2525 			.driver_info = EM2800_BOARD_GRABBEEX_USB2800 },
2526 	{ USB_DEVICE(0xeb1a, 0xe357),
2527 			.driver_info = EM2870_BOARD_KWORLD_355U },
2528 	{ USB_DEVICE(0xeb1a, 0xe359),
2529 			.driver_info = EM2870_BOARD_KWORLD_355U },
2530 	{ USB_DEVICE(0x1b80, 0xe302), /* Kaiser Baas Video to DVD maker */
2531 			.driver_info = EM2820_BOARD_PINNACLE_DVC_90 },
2532 	{ USB_DEVICE(0x1b80, 0xe304), /* Kworld DVD Maker 2 */
2533 			.driver_info = EM2820_BOARD_PINNACLE_DVC_90 },
2534 	{ USB_DEVICE(0x0ccd, 0x0036),
2535 			.driver_info = EM2820_BOARD_TERRATEC_CINERGY_250 },
2536 	{ USB_DEVICE(0x0ccd, 0x004c),
2537 			.driver_info = EM2880_BOARD_TERRATEC_HYBRID_XS_FR },
2538 	{ USB_DEVICE(0x0ccd, 0x004f),
2539 			.driver_info = EM2860_BOARD_TERRATEC_HYBRID_XS },
2540 	{ USB_DEVICE(0x0ccd, 0x005e),
2541 			.driver_info = EM2882_BOARD_TERRATEC_HYBRID_XS },
2542 	{ USB_DEVICE(0x0ccd, 0x0042),
2543 			.driver_info = EM2882_BOARD_TERRATEC_HYBRID_XS },
2544 	{ USB_DEVICE(0x0ccd, 0x0043),
2545 			.driver_info = EM2870_BOARD_TERRATEC_XS_MT2060 },
2546 	{ USB_DEVICE(0x0ccd, 0x008e),	/* Cinergy HTC USB XS Rev. 1 */
2547 			.driver_info = EM2884_BOARD_TERRATEC_HTC_USB_XS },
2548 	{ USB_DEVICE(0x0ccd, 0x00ac),	/* Cinergy HTC USB XS Rev. 2 */
2549 			.driver_info = EM2884_BOARD_TERRATEC_HTC_USB_XS },
2550 	{ USB_DEVICE(0x0ccd, 0x10a2),	/* H5 Rev. 1 */
2551 			.driver_info = EM2884_BOARD_TERRATEC_H5 },
2552 	{ USB_DEVICE(0x0ccd, 0x10ad),	/* H5 Rev. 2 */
2553 			.driver_info = EM2884_BOARD_TERRATEC_H5 },
2554 	{ USB_DEVICE(0x0ccd, 0x10b6),	/* H5 Rev. 3 */
2555 			.driver_info = EM2884_BOARD_TERRATEC_H5 },
2556 	{ USB_DEVICE(0x0ccd, 0x10b2),	/* H6 */
2557 			.driver_info = EM2884_BOARD_TERRATEC_H6 },
2558 	{ USB_DEVICE(0x0ccd, 0x0084),
2559 			.driver_info = EM2860_BOARD_TERRATEC_AV350 },
2560 	{ USB_DEVICE(0x0ccd, 0x0096),
2561 			.driver_info = EM2860_BOARD_TERRATEC_GRABBY },
2562 	{ USB_DEVICE(0x0ccd, 0x10AF),
2563 			.driver_info = EM2860_BOARD_TERRATEC_GRABBY },
2564 	{ USB_DEVICE(0x0ccd, 0x00b2),
2565 			.driver_info = EM2884_BOARD_CINERGY_HTC_STICK },
2566 	{ USB_DEVICE(0x0fd9, 0x0018),
2567 			.driver_info = EM2884_BOARD_ELGATO_EYETV_HYBRID_2008 },
2568 	{ USB_DEVICE(0x0fd9, 0x0033),
2569 			.driver_info = EM2860_BOARD_ELGATO_VIDEO_CAPTURE },
2570 	{ USB_DEVICE(0x185b, 0x2870),
2571 			.driver_info = EM2870_BOARD_COMPRO_VIDEOMATE },
2572 	{ USB_DEVICE(0x185b, 0x2041),
2573 			.driver_info = EM2820_BOARD_COMPRO_VIDEOMATE_FORYOU },
2574 	{ USB_DEVICE(0x2040, 0x4200),
2575 			.driver_info = EM2820_BOARD_HAUPPAUGE_WINTV_USB_2 },
2576 	{ USB_DEVICE(0x2040, 0x4201),
2577 			.driver_info = EM2820_BOARD_HAUPPAUGE_WINTV_USB_2 },
2578 	{ USB_DEVICE(0x2040, 0x6500),
2579 			.driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900 },
2580 	{ USB_DEVICE(0x2040, 0x6502),
2581 			.driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900_R2 },
2582 	{ USB_DEVICE(0x2040, 0x6513), /* HCW HVR-980 */
2583 			.driver_info = EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950 },
2584 	{ USB_DEVICE(0x2040, 0x6517), /* HP  HVR-950 */
2585 			.driver_info = EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950 },
2586 	{ USB_DEVICE(0x2040, 0x651b), /* RP  HVR-950 */
2587 			.driver_info = EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950 },
2588 	{ USB_DEVICE(0x2040, 0x651f),
2589 			.driver_info = EM2883_BOARD_HAUPPAUGE_WINTV_HVR_850 },
2590 	{ USB_DEVICE(0x2040, 0x0265),
2591 			.driver_info = EM28174_BOARD_HAUPPAUGE_WINTV_DUALHD_DVB },
2592 	{ USB_DEVICE(0x2040, 0x8265),
2593 			.driver_info = EM28174_BOARD_HAUPPAUGE_WINTV_DUALHD_DVB },
2594 	{ USB_DEVICE(0x2040, 0x026d),
2595 			.driver_info = EM28174_BOARD_HAUPPAUGE_WINTV_DUALHD_01595 },
2596 	{ USB_DEVICE(0x2040, 0x826d),
2597 			.driver_info = EM28174_BOARD_HAUPPAUGE_WINTV_DUALHD_01595 },
2598 	{ USB_DEVICE(0x0438, 0xb002),
2599 			.driver_info = EM2880_BOARD_AMD_ATI_TV_WONDER_HD_600 },
2600 	{ USB_DEVICE(0x2001, 0xf112),
2601 			.driver_info = EM2820_BOARD_DLINK_USB_TV },
2602 	{ USB_DEVICE(0x2304, 0x0207),
2603 			.driver_info = EM2820_BOARD_PINNACLE_DVC_90 },
2604 	{ USB_DEVICE(0x2304, 0x0208),
2605 			.driver_info = EM2820_BOARD_PINNACLE_USB_2 },
2606 	{ USB_DEVICE(0x2304, 0x021a),
2607 			.driver_info = EM2820_BOARD_PINNACLE_DVC_90 },
2608 	{ USB_DEVICE(0x2304, 0x0226),
2609 			.driver_info = EM2882_BOARD_PINNACLE_HYBRID_PRO_330E },
2610 	{ USB_DEVICE(0x2304, 0x0227),
2611 			.driver_info = EM2880_BOARD_PINNACLE_PCTV_HD_PRO },
2612 	{ USB_DEVICE(0x2304, 0x023f),
2613 			.driver_info = EM2874_BOARD_PCTV_HD_MINI_80E },
2614 	{ USB_DEVICE(0x0413, 0x6023),
2615 			.driver_info = EM2800_BOARD_LEADTEK_WINFAST_USBII },
2616 	{ USB_DEVICE(0x093b, 0xa003),
2617 		       .driver_info = EM2820_BOARD_PINNACLE_DVC_90 },
2618 	{ USB_DEVICE(0x093b, 0xa005),
2619 			.driver_info = EM2861_BOARD_PLEXTOR_PX_TV100U },
2620 	{ USB_DEVICE(0x04bb, 0x0515),
2621 			.driver_info = EM2820_BOARD_IODATA_GVMVP_SZ },
2622 	{ USB_DEVICE(0xeb1a, 0x50a6),
2623 			.driver_info = EM2860_BOARD_GADMEI_UTV330 },
2624 	{ USB_DEVICE(0x1b80, 0xa340),
2625 			.driver_info = EM2870_BOARD_KWORLD_A340 },
2626 	{ USB_DEVICE(0x1b80, 0xe346),
2627 			.driver_info = EM2874_BOARD_KWORLD_UB435Q_V2 },
2628 	{ USB_DEVICE(0x1b80, 0xe34c),
2629 			.driver_info = EM2874_BOARD_KWORLD_UB435Q_V3 },
2630 	{ USB_DEVICE(0x2013, 0x024f),
2631 			.driver_info = EM28174_BOARD_PCTV_290E },
2632 	{ USB_DEVICE(0x2013, 0x024c),
2633 			.driver_info = EM28174_BOARD_PCTV_460E },
2634 	{ USB_DEVICE(0x2040, 0x1605),
2635 			.driver_info = EM2884_BOARD_HAUPPAUGE_WINTV_HVR_930C },
2636 	{ USB_DEVICE(0x1b80, 0xe755),
2637 			.driver_info = EM2884_BOARD_C3TECH_DIGITAL_DUO },
2638 	{ USB_DEVICE(0xeb1a, 0x5006),
2639 			.driver_info = EM2860_BOARD_HT_VIDBOX_NW03 },
2640 	{ USB_DEVICE(0x1b80, 0xe309), /* Sveon STV40 */
2641 			.driver_info = EM2860_BOARD_EASYCAP },
2642 	{ USB_DEVICE(0x1b80, 0xe425),
2643 			.driver_info = EM2874_BOARD_MAXMEDIA_UB425_TC },
2644 	{ USB_DEVICE(0x2304, 0x0242),
2645 			.driver_info = EM2884_BOARD_PCTV_510E },
2646 	{ USB_DEVICE(0x2013, 0x0251),
2647 			.driver_info = EM2884_BOARD_PCTV_520E },
2648 	{ USB_DEVICE(0x1b80, 0xe1cc),
2649 			.driver_info = EM2874_BOARD_DELOCK_61959 },
2650 	{ USB_DEVICE(0x1ae7, 0x9003),
2651 			.driver_info = EM2765_BOARD_SPEEDLINK_VAD_LAPLACE },
2652 	{ USB_DEVICE(0x1ae7, 0x9004),
2653 			.driver_info = EM2765_BOARD_SPEEDLINK_VAD_LAPLACE },
2654 	{ USB_DEVICE(0x2013, 0x0258),
2655 			.driver_info = EM28178_BOARD_PCTV_461E },
2656 	{ USB_DEVICE(0x2013, 0x025f),
2657 			.driver_info = EM28178_BOARD_PCTV_292E },
2658 	{ USB_DEVICE(0x2013, 0x0264), /* Hauppauge WinTV-soloHD 292e SE */
2659 			.driver_info = EM28178_BOARD_PCTV_292E },
2660 	{ USB_DEVICE(0x2040, 0x0264), /* Hauppauge WinTV-soloHD Isoc */
2661 			.driver_info = EM28178_BOARD_PCTV_292E },
2662 	{ USB_DEVICE(0x2040, 0x8264), /* Hauppauge OEM Generic WinTV-soloHD Bulk */
2663 			.driver_info = EM28178_BOARD_PCTV_292E },
2664 	{ USB_DEVICE(0x2040, 0x8268), /* Hauppauge Retail WinTV-soloHD Bulk */
2665 			.driver_info = EM28178_BOARD_PCTV_292E },
2666 	{ USB_DEVICE(0x0413, 0x6f07),
2667 			.driver_info = EM2861_BOARD_LEADTEK_VC100 },
2668 	{ USB_DEVICE(0xeb1a, 0x8179),
2669 			.driver_info = EM28178_BOARD_TERRATEC_T2_STICK_HD },
2670 	{ USB_DEVICE(0x3275, 0x0085),
2671 			.driver_info = EM28178_BOARD_PLEX_PX_BCUD },
2672 	{ USB_DEVICE(0xeb1a, 0x5051), /* Ion Video 2 PC MKII / Startech svid2usb23 / Raygo R12-41373 */
2673 			.driver_info = EM2860_BOARD_TVP5150_REFERENCE_DESIGN },
2674 	{ },
2675 };
2676 MODULE_DEVICE_TABLE(usb, em28xx_id_table);
2677 
2678 /*
2679  * EEPROM hash table for devices with generic USB IDs
2680  */
2681 static const struct em28xx_hash_table em28xx_eeprom_hash[] = {
2682 	/* P/N: SA 60002070465 Tuner: TVF7533-MF */
2683 	{0x6ce05a8f, EM2820_BOARD_PROLINK_PLAYTV_USB2, TUNER_YMEC_TVF_5533MF},
2684 	{0x72cc5a8b, EM2820_BOARD_PROLINK_PLAYTV_BOX4_USB2, TUNER_YMEC_TVF_5533MF},
2685 	{0x966a0441, EM2880_BOARD_KWORLD_DVB_310U, TUNER_XC2028},
2686 	{0x166a0441, EM2880_BOARD_EMPIRE_DUAL_TV, TUNER_XC2028},
2687 	{0xcee44a99, EM2882_BOARD_EVGA_INDTUBE, TUNER_XC2028},
2688 	{0xb8846b20, EM2881_BOARD_PINNACLE_HYBRID_PRO, TUNER_XC2028},
2689 	{0x63f653bd, EM2870_BOARD_REDDO_DVB_C_USB_BOX, TUNER_ABSENT},
2690 	{0x4e913442, EM2882_BOARD_DIKOM_DK300, TUNER_XC2028},
2691 };
2692 
2693 /* I2C devicelist hash table for devices with generic USB IDs */
2694 static const struct em28xx_hash_table em28xx_i2c_hash[] = {
2695 	{0xb06a32c3, EM2800_BOARD_TERRATEC_CINERGY_200, TUNER_LG_PAL_NEW_TAPC},
2696 	{0xf51200e3, EM2800_BOARD_VGEAR_POCKETTV, TUNER_LG_PAL_NEW_TAPC},
2697 	{0x1ba50080, EM2860_BOARD_SAA711X_REFERENCE_DESIGN, TUNER_ABSENT},
2698 	{0x77800080, EM2860_BOARD_TVP5150_REFERENCE_DESIGN, TUNER_ABSENT},
2699 	{0xc51200e3, EM2820_BOARD_GADMEI_TVR200, TUNER_LG_PAL_NEW_TAPC},
2700 	{0x4ba50080, EM2861_BOARD_GADMEI_UTV330PLUS, TUNER_TNF_5335MF},
2701 	{0x6b800080, EM2874_BOARD_LEADERSHIP_ISDBT, TUNER_ABSENT},
2702 };
2703 
2704 /* NOTE: introduce a separate hash table for devices with 16 bit eeproms */
2705 
2706 int em28xx_tuner_callback(void *ptr, int component, int command, int arg)
2707 {
2708 	struct em28xx_i2c_bus *i2c_bus = ptr;
2709 	struct em28xx *dev = i2c_bus->dev;
2710 	int rc = 0;
2711 
2712 	if (dev->tuner_type != TUNER_XC2028 && dev->tuner_type != TUNER_XC5000)
2713 		return 0;
2714 
2715 	if (command != XC2028_TUNER_RESET && command != XC5000_TUNER_RESET)
2716 		return 0;
2717 
2718 	rc = em28xx_gpio_set(dev, dev->board.tuner_gpio);
2719 
2720 	return rc;
2721 }
2722 EXPORT_SYMBOL_GPL(em28xx_tuner_callback);
2723 
2724 static inline void em28xx_set_xclk_i2c_speed(struct em28xx *dev)
2725 {
2726 	const struct em28xx_board *board = &em28xx_boards[dev->model];
2727 	u8 xclk = board->xclk, i2c_speed = board->i2c_speed;
2728 
2729 	/*
2730 	 * Those are the default values for the majority of boards
2731 	 * Use those values if not specified otherwise at boards entry
2732 	 */
2733 	if (!xclk)
2734 		xclk = EM28XX_XCLK_IR_RC5_MODE |
2735 		       EM28XX_XCLK_FREQUENCY_12MHZ;
2736 
2737 	em28xx_write_reg(dev, EM28XX_R0F_XCLK, xclk);
2738 
2739 	if (!i2c_speed)
2740 		i2c_speed = EM28XX_I2C_CLK_WAIT_ENABLE |
2741 			    EM28XX_I2C_FREQ_100_KHZ;
2742 
2743 	dev->i2c_speed = i2c_speed & 0x03;
2744 
2745 	if (!dev->board.is_em2800)
2746 		em28xx_write_reg(dev, EM28XX_R06_I2C_CLK, i2c_speed);
2747 	msleep(50);
2748 }
2749 
2750 static inline void em28xx_set_model(struct em28xx *dev)
2751 {
2752 	dev->board = em28xx_boards[dev->model];
2753 	dev->has_msp34xx = dev->board.has_msp34xx;
2754 	dev->is_webcam = dev->board.is_webcam;
2755 
2756 	em28xx_set_xclk_i2c_speed(dev);
2757 
2758 	/* Should be initialized early, for I2C to work */
2759 	dev->def_i2c_bus = dev->board.def_i2c_bus;
2760 }
2761 
2762 /*
2763  * Wait until AC97_RESET reports the expected value reliably before proceeding.
2764  * We also check that two unrelated registers accesses don't return the same
2765  * value to avoid premature return.
2766  * This procedure helps ensuring AC97 register accesses are reliable.
2767  */
2768 static int em28xx_wait_until_ac97_features_equals(struct em28xx *dev,
2769 						  int expected_feat)
2770 {
2771 	unsigned long timeout = jiffies + msecs_to_jiffies(2000);
2772 	int feat, powerdown;
2773 
2774 	while (time_is_after_jiffies(timeout)) {
2775 		feat = em28xx_read_ac97(dev, AC97_RESET);
2776 		if (feat < 0)
2777 			return feat;
2778 
2779 		powerdown = em28xx_read_ac97(dev, AC97_POWERDOWN);
2780 		if (powerdown < 0)
2781 			return powerdown;
2782 
2783 		if (feat == expected_feat && feat != powerdown)
2784 			return 0;
2785 
2786 		msleep(50);
2787 	}
2788 
2789 	dev_warn(&dev->intf->dev, "AC97 registers access is not reliable !\n");
2790 	return -ETIMEDOUT;
2791 }
2792 
2793 /*
2794  * Since em28xx_pre_card_setup() requires a proper dev->model,
2795  * this won't work for boards with generic PCI IDs
2796  */
2797 static void em28xx_pre_card_setup(struct em28xx *dev)
2798 {
2799 	/*
2800 	 * Set the initial XCLK and I2C clock values based on the board
2801 	 * definition
2802 	 */
2803 	em28xx_set_xclk_i2c_speed(dev);
2804 
2805 	/* request some modules */
2806 	switch (dev->model) {
2807 	case EM2861_BOARD_PLEXTOR_PX_TV100U:
2808 		/* Sets the msp34xx I2S speed */
2809 		dev->i2s_speed = 2048000;
2810 		break;
2811 	case EM2861_BOARD_KWORLD_PVRTV_300U:
2812 	case EM2880_BOARD_KWORLD_DVB_305U:
2813 		em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0x6d);
2814 		usleep_range(10000, 11000);
2815 		em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0x7d);
2816 		usleep_range(10000, 11000);
2817 		break;
2818 	case EM2870_BOARD_COMPRO_VIDEOMATE:
2819 		/*
2820 		 * TODO: someone can do some cleanup here...
2821 		 *	 not everything's needed
2822 		 */
2823 		em28xx_write_reg(dev, EM2880_R04_GPO, 0x00);
2824 		usleep_range(10000, 11000);
2825 		em28xx_write_reg(dev, EM2880_R04_GPO, 0x01);
2826 		usleep_range(10000, 11000);
2827 		em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xfd);
2828 		mdelay(70);
2829 		em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xfc);
2830 		mdelay(70);
2831 		em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xdc);
2832 		mdelay(70);
2833 		em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xfc);
2834 		mdelay(70);
2835 		break;
2836 	case EM2870_BOARD_TERRATEC_XS_MT2060:
2837 		/*
2838 		 * this device needs some gpio writes to get the DVB-T
2839 		 * demod work
2840 		 */
2841 		em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xfe);
2842 		mdelay(70);
2843 		em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xde);
2844 		mdelay(70);
2845 		em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xfe);
2846 		mdelay(70);
2847 		break;
2848 	case EM2870_BOARD_PINNACLE_PCTV_DVB:
2849 		/*
2850 		 * this device needs some gpio writes to get the
2851 		 * DVB-T demod work
2852 		 */
2853 		em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xfe);
2854 		mdelay(70);
2855 		em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xde);
2856 		mdelay(70);
2857 		em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xfe);
2858 		mdelay(70);
2859 		break;
2860 	case EM2820_BOARD_GADMEI_UTV310:
2861 	case EM2820_BOARD_MSI_VOX_USB_2:
2862 		/* enables audio for that devices */
2863 		em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xfd);
2864 		break;
2865 
2866 	case EM2882_BOARD_KWORLD_ATSC_315U:
2867 		em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xff);
2868 		usleep_range(10000, 11000);
2869 		em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xfe);
2870 		usleep_range(10000, 11000);
2871 		em28xx_write_reg(dev, EM2880_R04_GPO, 0x00);
2872 		usleep_range(10000, 11000);
2873 		em28xx_write_reg(dev, EM2880_R04_GPO, 0x08);
2874 		usleep_range(10000, 11000);
2875 		break;
2876 
2877 	case EM2860_BOARD_KAIOMY_TVNPC_U2:
2878 		em28xx_write_regs(dev, EM28XX_R0F_XCLK, "\x07", 1);
2879 		em28xx_write_regs(dev, EM28XX_R06_I2C_CLK, "\x40", 1);
2880 		em28xx_write_regs(dev, 0x0d, "\x42", 1);
2881 		em28xx_write_regs(dev, 0x08, "\xfd", 1);
2882 		usleep_range(10000, 11000);
2883 		em28xx_write_regs(dev, 0x08, "\xff", 1);
2884 		usleep_range(10000, 11000);
2885 		em28xx_write_regs(dev, 0x08, "\x7f", 1);
2886 		usleep_range(10000, 11000);
2887 		em28xx_write_regs(dev, 0x08, "\x6b", 1);
2888 
2889 		break;
2890 	case EM2860_BOARD_EASYCAP:
2891 		em28xx_write_regs(dev, 0x08, "\xf8", 1);
2892 		break;
2893 
2894 	case EM2820_BOARD_IODATA_GVMVP_SZ:
2895 		em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xff);
2896 		msleep(70);
2897 		em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xf7);
2898 		usleep_range(10000, 11000);
2899 		em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xfe);
2900 		msleep(70);
2901 		em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xfd);
2902 		msleep(70);
2903 		break;
2904 
2905 	case EM2860_BOARD_TERRATEC_GRABBY:
2906 		/*
2907 		 * HACK?: Ensure AC97 register reading is reliable before
2908 		 * proceeding. In practice, this will wait about 1.6 seconds.
2909 		 */
2910 		em28xx_wait_until_ac97_features_equals(dev, 0x6a90);
2911 		break;
2912 	}
2913 
2914 	em28xx_gpio_set(dev, dev->board.tuner_gpio);
2915 	em28xx_set_mode(dev, EM28XX_ANALOG_MODE);
2916 
2917 	/* Unlock device */
2918 	em28xx_set_mode(dev, EM28XX_SUSPEND);
2919 }
2920 
2921 static int em28xx_hint_board(struct em28xx *dev)
2922 {
2923 	int i;
2924 
2925 	if (dev->is_webcam) {
2926 		if (dev->em28xx_sensor == EM28XX_MT9V011) {
2927 			dev->model = EM2820_BOARD_SILVERCREST_WEBCAM;
2928 		} else if (dev->em28xx_sensor == EM28XX_MT9M001 ||
2929 			   dev->em28xx_sensor == EM28XX_MT9M111) {
2930 			dev->model = EM2750_BOARD_UNKNOWN;
2931 		}
2932 		/* FIXME: IMPROVE ! */
2933 
2934 		return 0;
2935 	}
2936 
2937 	/*
2938 	 * HINT method: EEPROM
2939 	 *
2940 	 * This method works only for boards with eeprom.
2941 	 * Uses a hash of all eeprom bytes. The hash should be
2942 	 * unique for a vendor/tuner pair.
2943 	 * There are a high chance that tuners for different
2944 	 * video standards produce different hashes.
2945 	 */
2946 	for (i = 0; i < ARRAY_SIZE(em28xx_eeprom_hash); i++) {
2947 		if (dev->hash == em28xx_eeprom_hash[i].hash) {
2948 			dev->model = em28xx_eeprom_hash[i].model;
2949 			dev->tuner_type = em28xx_eeprom_hash[i].tuner;
2950 
2951 			dev_err(&dev->intf->dev,
2952 				"Your board has no unique USB ID.\n"
2953 				"A hint were successfully done, based on eeprom hash.\n"
2954 				"This method is not 100%% failproof.\n"
2955 				"If the board were misdetected, please email this log to:\n"
2956 				"\tV4L Mailing List  <linux-media@vger.kernel.org>\n"
2957 				"Board detected as %s\n",
2958 			       em28xx_boards[dev->model].name);
2959 
2960 			return 0;
2961 		}
2962 	}
2963 
2964 	/*
2965 	 * HINT method: I2C attached devices
2966 	 *
2967 	 * This method works for all boards.
2968 	 * Uses a hash of i2c scanned devices.
2969 	 * Devices with the same i2c attached chips will
2970 	 * be considered equal.
2971 	 * This method is less precise than the eeprom one.
2972 	 */
2973 
2974 	/* user did not request i2c scanning => do it now */
2975 	if (!dev->i2c_hash)
2976 		em28xx_do_i2c_scan(dev, dev->def_i2c_bus);
2977 
2978 	for (i = 0; i < ARRAY_SIZE(em28xx_i2c_hash); i++) {
2979 		if (dev->i2c_hash == em28xx_i2c_hash[i].hash) {
2980 			dev->model = em28xx_i2c_hash[i].model;
2981 			dev->tuner_type = em28xx_i2c_hash[i].tuner;
2982 			dev_err(&dev->intf->dev,
2983 				"Your board has no unique USB ID.\n"
2984 				"A hint were successfully done, based on i2c devicelist hash.\n"
2985 				"This method is not 100%% failproof.\n"
2986 				"If the board were misdetected, please email this log to:\n"
2987 				"\tV4L Mailing List  <linux-media@vger.kernel.org>\n"
2988 				"Board detected as %s\n",
2989 				em28xx_boards[dev->model].name);
2990 
2991 			return 0;
2992 		}
2993 	}
2994 
2995 	dev_err(&dev->intf->dev,
2996 		"Your board has no unique USB ID and thus need a hint to be detected.\n"
2997 		"You may try to use card=<n> insmod option to workaround that.\n"
2998 		"Please send an email with this log to:\n"
2999 		"\tV4L Mailing List <linux-media@vger.kernel.org>\n"
3000 		"Board eeprom hash is 0x%08lx\n"
3001 		"Board i2c devicelist hash is 0x%08lx\n",
3002 		dev->hash, dev->i2c_hash);
3003 
3004 	dev_err(&dev->intf->dev,
3005 		"Here is a list of valid choices for the card=<n> insmod option:\n");
3006 	for (i = 0; i < em28xx_bcount; i++) {
3007 		dev_err(&dev->intf->dev,
3008 			"    card=%d -> %s\n", i, em28xx_boards[i].name);
3009 	}
3010 	return -1;
3011 }
3012 
3013 static void em28xx_card_setup(struct em28xx *dev)
3014 {
3015 	/*
3016 	 * If the device can be a webcam, seek for a sensor.
3017 	 * If sensor is not found, then it isn't a webcam.
3018 	 */
3019 	if (dev->is_webcam) {
3020 		em28xx_detect_sensor(dev);
3021 		if (dev->em28xx_sensor == EM28XX_NOSENSOR)
3022 			/* NOTE: error/unknown sensor/no sensor */
3023 			dev->is_webcam = 0;
3024 	}
3025 
3026 	switch (dev->model) {
3027 	case EM2750_BOARD_UNKNOWN:
3028 	case EM2820_BOARD_UNKNOWN:
3029 	case EM2800_BOARD_UNKNOWN:
3030 		/*
3031 		 * The K-WORLD DVB-T 310U is detected as an MSI Digivox AD.
3032 		 *
3033 		 * This occurs because they share identical USB vendor and
3034 		 * product IDs.
3035 		 *
3036 		 * What we do here is look up the EEPROM hash of the K-WORLD
3037 		 * and if it is found then we decide that we do not have
3038 		 * a DIGIVOX and reset the device to the K-WORLD instead.
3039 		 *
3040 		 * This solution is only valid if they do not share eeprom
3041 		 * hash identities which has not been determined as yet.
3042 		 */
3043 		if (em28xx_hint_board(dev) < 0) {
3044 			dev_err(&dev->intf->dev, "Board not discovered\n");
3045 		} else {
3046 			em28xx_set_model(dev);
3047 			em28xx_pre_card_setup(dev);
3048 		}
3049 		break;
3050 	default:
3051 		em28xx_set_model(dev);
3052 	}
3053 
3054 	dev_info(&dev->intf->dev, "Identified as %s (card=%d)\n",
3055 		 dev->board.name, dev->model);
3056 
3057 	dev->tuner_type = em28xx_boards[dev->model].tuner_type;
3058 
3059 	/* request some modules */
3060 	switch (dev->model) {
3061 	case EM2820_BOARD_HAUPPAUGE_WINTV_USB_2:
3062 	case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900:
3063 	case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900_R2:
3064 	case EM2883_BOARD_HAUPPAUGE_WINTV_HVR_850:
3065 	case EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950:
3066 	case EM2884_BOARD_HAUPPAUGE_WINTV_HVR_930C:
3067 	case EM28174_BOARD_HAUPPAUGE_WINTV_DUALHD_DVB:
3068 	case EM28174_BOARD_HAUPPAUGE_WINTV_DUALHD_01595:
3069 	{
3070 		struct tveeprom tv;
3071 
3072 		if (!dev->eedata)
3073 			break;
3074 #if defined(CONFIG_MODULES) && defined(MODULE)
3075 		request_module("tveeprom");
3076 #endif
3077 		/* Call first TVeeprom */
3078 
3079 		tveeprom_hauppauge_analog(&tv, dev->eedata);
3080 
3081 		dev->tuner_type = tv.tuner_type;
3082 
3083 		if (tv.audio_processor == TVEEPROM_AUDPROC_MSP) {
3084 			dev->i2s_speed = 2048000;
3085 			dev->has_msp34xx = 1;
3086 		}
3087 		break;
3088 	}
3089 	case EM2882_BOARD_KWORLD_ATSC_315U:
3090 		em28xx_write_reg(dev, 0x0d, 0x42);
3091 		usleep_range(10000, 11000);
3092 		em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xfd);
3093 		usleep_range(10000, 11000);
3094 		break;
3095 	case EM2820_BOARD_KWORLD_PVRTV2800RF:
3096 		/* GPIO enables sound on KWORLD PVR TV 2800RF */
3097 		em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xf9);
3098 		break;
3099 	case EM2820_BOARD_UNKNOWN:
3100 	case EM2800_BOARD_UNKNOWN:
3101 		/*
3102 		 * The K-WORLD DVB-T 310U is detected as an MSI Digivox AD.
3103 		 *
3104 		 * This occurs because they share identical USB vendor and
3105 		 * product IDs.
3106 		 *
3107 		 * What we do here is look up the EEPROM hash of the K-WORLD
3108 		 * and if it is found then we decide that we do not have
3109 		 * a DIGIVOX and reset the device to the K-WORLD instead.
3110 		 *
3111 		 * This solution is only valid if they do not share eeprom
3112 		 * hash identities which has not been determined as yet.
3113 		 */
3114 	case EM2880_BOARD_MSI_DIGIVOX_AD:
3115 		if (!em28xx_hint_board(dev))
3116 			em28xx_set_model(dev);
3117 
3118 		/*
3119 		 * In cases where we had to use a board hint, the call to
3120 		 * em28xx_set_mode() in em28xx_pre_card_setup() was a no-op,
3121 		 * so make the call now so the analog GPIOs are set properly
3122 		 * before probing the i2c bus.
3123 		 */
3124 		em28xx_gpio_set(dev, dev->board.tuner_gpio);
3125 		em28xx_set_mode(dev, EM28XX_ANALOG_MODE);
3126 		break;
3127 
3128 		/*
3129 		 * The Dikom DK300 is detected as an Kworld VS-DVB-T 323UR.
3130 		 *
3131 		 * This occurs because they share identical USB vendor and
3132 		 * product IDs.
3133 		 *
3134 		 * What we do here is look up the EEPROM hash of the Dikom
3135 		 * and if it is found then we decide that we do not have
3136 		 * a Kworld and reset the device to the Dikom instead.
3137 		 *
3138 		 * This solution is only valid if they do not share eeprom
3139 		 * hash identities which has not been determined as yet.
3140 		 */
3141 	case EM2882_BOARD_KWORLD_VS_DVBT:
3142 		if (!em28xx_hint_board(dev))
3143 			em28xx_set_model(dev);
3144 
3145 		/*
3146 		 * In cases where we had to use a board hint, the call to
3147 		 * em28xx_set_mode() in em28xx_pre_card_setup() was a no-op,
3148 		 * so make the call now so the analog GPIOs are set properly
3149 		 * before probing the i2c bus.
3150 		 */
3151 		em28xx_gpio_set(dev, dev->board.tuner_gpio);
3152 		em28xx_set_mode(dev, EM28XX_ANALOG_MODE);
3153 		break;
3154 	}
3155 
3156 	if (dev->board.valid == EM28XX_BOARD_NOT_VALIDATED) {
3157 		dev_err(&dev->intf->dev,
3158 			"\n\n"
3159 			"The support for this board weren't valid yet.\n"
3160 			"Please send a report of having this working\n"
3161 			"not to V4L mailing list (and/or to other addresses)\n\n");
3162 	}
3163 
3164 	/* Free eeprom data memory */
3165 	kfree(dev->eedata);
3166 	dev->eedata = NULL;
3167 
3168 	/* Allow override tuner type by a module parameter */
3169 	if (tuner >= 0)
3170 		dev->tuner_type = tuner;
3171 }
3172 
3173 void em28xx_setup_xc3028(struct em28xx *dev, struct xc2028_ctrl *ctl)
3174 {
3175 	memset(ctl, 0, sizeof(*ctl));
3176 
3177 	ctl->fname   = XC2028_DEFAULT_FIRMWARE;
3178 	ctl->max_len = 64;
3179 	ctl->mts = em28xx_boards[dev->model].mts_firmware;
3180 
3181 	switch (dev->model) {
3182 	case EM2880_BOARD_EMPIRE_DUAL_TV:
3183 	case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900:
3184 	case EM2882_BOARD_TERRATEC_HYBRID_XS:
3185 		ctl->demod = XC3028_FE_ZARLINK456;
3186 		break;
3187 	case EM2880_BOARD_TERRATEC_HYBRID_XS:
3188 	case EM2880_BOARD_TERRATEC_HYBRID_XS_FR:
3189 	case EM2881_BOARD_PINNACLE_HYBRID_PRO:
3190 		ctl->demod = XC3028_FE_ZARLINK456;
3191 		break;
3192 	case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900_R2:
3193 	case EM2882_BOARD_PINNACLE_HYBRID_PRO_330E:
3194 		ctl->demod = XC3028_FE_DEFAULT;
3195 		break;
3196 	case EM2880_BOARD_AMD_ATI_TV_WONDER_HD_600:
3197 		ctl->demod = XC3028_FE_DEFAULT;
3198 		ctl->fname = XC3028L_DEFAULT_FIRMWARE;
3199 		break;
3200 	case EM2883_BOARD_HAUPPAUGE_WINTV_HVR_850:
3201 	case EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950:
3202 	case EM2880_BOARD_PINNACLE_PCTV_HD_PRO:
3203 		/* FIXME: Better to specify the needed IF */
3204 		ctl->demod = XC3028_FE_DEFAULT;
3205 		break;
3206 	case EM2883_BOARD_KWORLD_HYBRID_330U:
3207 	case EM2882_BOARD_DIKOM_DK300:
3208 	case EM2882_BOARD_KWORLD_VS_DVBT:
3209 		ctl->demod = XC3028_FE_CHINA;
3210 		ctl->fname = XC2028_DEFAULT_FIRMWARE;
3211 		break;
3212 	case EM2882_BOARD_EVGA_INDTUBE:
3213 		ctl->demod = XC3028_FE_CHINA;
3214 		ctl->fname = XC3028L_DEFAULT_FIRMWARE;
3215 		break;
3216 	default:
3217 		ctl->demod = XC3028_FE_OREN538;
3218 	}
3219 }
3220 EXPORT_SYMBOL_GPL(em28xx_setup_xc3028);
3221 
3222 static void request_module_async(struct work_struct *work)
3223 {
3224 	struct em28xx *dev = container_of(work,
3225 			     struct em28xx, request_module_wk);
3226 
3227 	/*
3228 	 * The em28xx extensions can be modules or builtin. If the
3229 	 * modules are already loaded or are built in, those extensions
3230 	 * can be initialised right now. Otherwise, the module init
3231 	 * code will do it.
3232 	 */
3233 
3234 	/*
3235 	 * Devices with an audio-only intf also have a V4L/DVB/RC
3236 	 * intf. Don't register extensions twice on those devices.
3237 	 */
3238 	if (dev->is_audio_only) {
3239 #if defined(CONFIG_MODULES) && defined(MODULE)
3240 		request_module("em28xx-alsa");
3241 #endif
3242 		return;
3243 	}
3244 
3245 	em28xx_init_extension(dev);
3246 
3247 #if defined(CONFIG_MODULES) && defined(MODULE)
3248 	if (dev->has_video)
3249 		request_module("em28xx-v4l");
3250 	if (dev->usb_audio_type == EM28XX_USB_AUDIO_CLASS)
3251 		request_module("snd-usb-audio");
3252 	else if (dev->usb_audio_type == EM28XX_USB_AUDIO_VENDOR)
3253 		request_module("em28xx-alsa");
3254 	if (dev->board.has_dvb)
3255 		request_module("em28xx-dvb");
3256 	if (dev->board.buttons ||
3257 	    ((dev->board.ir_codes || dev->board.has_ir_i2c) && !disable_ir))
3258 		request_module("em28xx-rc");
3259 #endif /* CONFIG_MODULES */
3260 }
3261 
3262 static void request_modules(struct em28xx *dev)
3263 {
3264 	INIT_WORK(&dev->request_module_wk, request_module_async);
3265 	schedule_work(&dev->request_module_wk);
3266 }
3267 
3268 static void flush_request_modules(struct em28xx *dev)
3269 {
3270 	flush_work(&dev->request_module_wk);
3271 }
3272 
3273 static int em28xx_media_device_init(struct em28xx *dev,
3274 				    struct usb_device *udev)
3275 {
3276 #ifdef CONFIG_MEDIA_CONTROLLER
3277 	struct media_device *mdev;
3278 
3279 	mdev = kzalloc(sizeof(*mdev), GFP_KERNEL);
3280 	if (!mdev)
3281 		return -ENOMEM;
3282 
3283 	if (udev->product)
3284 		media_device_usb_init(mdev, udev, udev->product);
3285 	else if (udev->manufacturer)
3286 		media_device_usb_init(mdev, udev, udev->manufacturer);
3287 	else
3288 		media_device_usb_init(mdev, udev, dev_name(&dev->intf->dev));
3289 
3290 	dev->media_dev = mdev;
3291 #endif
3292 	return 0;
3293 }
3294 
3295 static void em28xx_unregister_media_device(struct em28xx *dev)
3296 {
3297 #ifdef CONFIG_MEDIA_CONTROLLER
3298 	if (dev->media_dev) {
3299 		media_device_unregister(dev->media_dev);
3300 		media_device_cleanup(dev->media_dev);
3301 		kfree(dev->media_dev);
3302 		dev->media_dev = NULL;
3303 	}
3304 #endif
3305 }
3306 
3307 /*
3308  * em28xx_release_resources()
3309  * unregisters the v4l2,i2c and usb devices
3310  * called when the device gets disconnected or at module unload
3311  */
3312 static void em28xx_release_resources(struct em28xx *dev)
3313 {
3314 	struct usb_device *udev = interface_to_usbdev(dev->intf);
3315 
3316 	/*FIXME: I2C IR should be disconnected */
3317 
3318 	mutex_lock(&dev->lock);
3319 
3320 	em28xx_unregister_media_device(dev);
3321 
3322 	if (dev->def_i2c_bus)
3323 		em28xx_i2c_unregister(dev, 1);
3324 	em28xx_i2c_unregister(dev, 0);
3325 
3326 	if (dev->ts == PRIMARY_TS)
3327 		usb_put_dev(udev);
3328 
3329 	/* Mark device as unused */
3330 	clear_bit(dev->devno, em28xx_devused);
3331 
3332 	mutex_unlock(&dev->lock);
3333 };
3334 
3335 /**
3336  * em28xx_free_device() - Free em28xx device
3337  *
3338  * @ref: struct kref for em28xx device
3339  *
3340  * This is called when all extensions and em28xx core unregisters a device
3341  */
3342 void em28xx_free_device(struct kref *ref)
3343 {
3344 	struct em28xx *dev = kref_to_dev(ref);
3345 
3346 	dev_info(&dev->intf->dev, "Freeing device\n");
3347 
3348 	if (!dev->disconnected)
3349 		em28xx_release_resources(dev);
3350 
3351 	kfree(dev->alt_max_pkt_size_isoc);
3352 	kfree(dev);
3353 }
3354 EXPORT_SYMBOL_GPL(em28xx_free_device);
3355 
3356 /*
3357  * em28xx_init_dev()
3358  * allocates and inits the device structs, registers i2c bus and v4l device
3359  */
3360 static int em28xx_init_dev(struct em28xx *dev, struct usb_device *udev,
3361 			   struct usb_interface *intf,
3362 			   int minor)
3363 {
3364 	int retval;
3365 	const char *chip_name = NULL;
3366 
3367 	dev->intf = intf;
3368 	mutex_init(&dev->ctrl_urb_lock);
3369 	spin_lock_init(&dev->slock);
3370 
3371 	dev->em28xx_write_regs = em28xx_write_regs;
3372 	dev->em28xx_read_reg = em28xx_read_reg;
3373 	dev->em28xx_read_reg_req_len = em28xx_read_reg_req_len;
3374 	dev->em28xx_write_regs_req = em28xx_write_regs_req;
3375 	dev->em28xx_read_reg_req = em28xx_read_reg_req;
3376 	dev->board.is_em2800 = em28xx_boards[dev->model].is_em2800;
3377 
3378 	em28xx_set_model(dev);
3379 
3380 	dev->wait_after_write = 5;
3381 
3382 	/* Based on the Chip ID, set the device configuration */
3383 	retval = em28xx_read_reg(dev, EM28XX_R0A_CHIPID);
3384 	if (retval > 0) {
3385 		dev->chip_id = retval;
3386 
3387 		switch (dev->chip_id) {
3388 		case CHIP_ID_EM2800:
3389 			chip_name = "em2800";
3390 			break;
3391 		case CHIP_ID_EM2710:
3392 			chip_name = "em2710";
3393 			break;
3394 		case CHIP_ID_EM2750:
3395 			chip_name = "em2750";
3396 			break;
3397 		case CHIP_ID_EM2765:
3398 			chip_name = "em2765";
3399 			dev->wait_after_write = 0;
3400 			dev->is_em25xx = 1;
3401 			dev->eeprom_addrwidth_16bit = 1;
3402 			break;
3403 		case CHIP_ID_EM2820:
3404 			chip_name = "em2710/2820";
3405 			if (le16_to_cpu(udev->descriptor.idVendor) == 0xeb1a) {
3406 				__le16 idProd = udev->descriptor.idProduct;
3407 
3408 				if (le16_to_cpu(idProd) == 0x2710)
3409 					chip_name = "em2710";
3410 				else if (le16_to_cpu(idProd) == 0x2820)
3411 					chip_name = "em2820";
3412 			}
3413 			/* NOTE: the em2820 is used in webcams, too ! */
3414 			break;
3415 		case CHIP_ID_EM2840:
3416 			chip_name = "em2840";
3417 			break;
3418 		case CHIP_ID_EM2860:
3419 			chip_name = "em2860";
3420 			break;
3421 		case CHIP_ID_EM2870:
3422 			chip_name = "em2870";
3423 			dev->wait_after_write = 0;
3424 			break;
3425 		case CHIP_ID_EM2874:
3426 			chip_name = "em2874";
3427 			dev->wait_after_write = 0;
3428 			dev->eeprom_addrwidth_16bit = 1;
3429 			break;
3430 		case CHIP_ID_EM28174:
3431 			chip_name = "em28174";
3432 			dev->wait_after_write = 0;
3433 			dev->eeprom_addrwidth_16bit = 1;
3434 			break;
3435 		case CHIP_ID_EM28178:
3436 			chip_name = "em28178";
3437 			dev->wait_after_write = 0;
3438 			dev->eeprom_addrwidth_16bit = 1;
3439 			break;
3440 		case CHIP_ID_EM2883:
3441 			chip_name = "em2882/3";
3442 			dev->wait_after_write = 0;
3443 			break;
3444 		case CHIP_ID_EM2884:
3445 			chip_name = "em2884";
3446 			dev->wait_after_write = 0;
3447 			dev->eeprom_addrwidth_16bit = 1;
3448 			break;
3449 		}
3450 	}
3451 	if (!chip_name)
3452 		dev_info(&dev->intf->dev,
3453 			 "unknown em28xx chip ID (%d)\n", dev->chip_id);
3454 	else
3455 		dev_info(&dev->intf->dev, "chip ID is %s\n", chip_name);
3456 
3457 	em28xx_media_device_init(dev, udev);
3458 
3459 	if (dev->is_audio_only) {
3460 		retval = em28xx_audio_setup(dev);
3461 		if (retval)
3462 			return -ENODEV;
3463 		em28xx_init_extension(dev);
3464 
3465 		return 0;
3466 	}
3467 
3468 	em28xx_pre_card_setup(dev);
3469 
3470 	rt_mutex_init(&dev->i2c_bus_lock);
3471 
3472 	/* register i2c bus 0 */
3473 	if (dev->board.is_em2800)
3474 		retval = em28xx_i2c_register(dev, 0, EM28XX_I2C_ALGO_EM2800);
3475 	else
3476 		retval = em28xx_i2c_register(dev, 0, EM28XX_I2C_ALGO_EM28XX);
3477 	if (retval < 0) {
3478 		dev_err(&dev->intf->dev,
3479 			"%s: em28xx_i2c_register bus 0 - error [%d]!\n",
3480 		       __func__, retval);
3481 		return retval;
3482 	}
3483 
3484 	/* register i2c bus 1 */
3485 	if (dev->def_i2c_bus) {
3486 		if (dev->is_em25xx)
3487 			retval = em28xx_i2c_register(dev, 1,
3488 						     EM28XX_I2C_ALGO_EM25XX_BUS_B);
3489 		else
3490 			retval = em28xx_i2c_register(dev, 1,
3491 						     EM28XX_I2C_ALGO_EM28XX);
3492 		if (retval < 0) {
3493 			dev_err(&dev->intf->dev,
3494 				"%s: em28xx_i2c_register bus 1 - error [%d]!\n",
3495 				__func__, retval);
3496 
3497 			em28xx_i2c_unregister(dev, 0);
3498 
3499 			return retval;
3500 		}
3501 	}
3502 
3503 	/* Do board specific init and eeprom reading */
3504 	em28xx_card_setup(dev);
3505 
3506 	return 0;
3507 }
3508 
3509 static int em28xx_duplicate_dev(struct em28xx *dev)
3510 {
3511 	int nr;
3512 	struct em28xx *sec_dev = kzalloc(sizeof(*sec_dev), GFP_KERNEL);
3513 
3514 	if (!sec_dev) {
3515 		dev->dev_next = NULL;
3516 		return -ENOMEM;
3517 	}
3518 	memcpy(sec_dev, dev, sizeof(*sec_dev));
3519 	/* Check to see next free device and mark as used */
3520 	do {
3521 		nr = find_first_zero_bit(em28xx_devused, EM28XX_MAXBOARDS);
3522 		if (nr >= EM28XX_MAXBOARDS) {
3523 			/* No free device slots */
3524 			dev_warn(&dev->intf->dev, ": Supports only %i em28xx boards.\n",
3525 				 EM28XX_MAXBOARDS);
3526 			kfree(sec_dev);
3527 			dev->dev_next = NULL;
3528 			return -ENOMEM;
3529 		}
3530 	} while (test_and_set_bit(nr, em28xx_devused));
3531 	sec_dev->devno = nr;
3532 	snprintf(sec_dev->name, 28, "em28xx #%d", nr);
3533 	sec_dev->dev_next = NULL;
3534 	dev->dev_next = sec_dev;
3535 	return 0;
3536 }
3537 
3538 /* high bandwidth multiplier, as encoded in highspeed endpoint descriptors */
3539 #define hb_mult(wMaxPacketSize) (1 + (((wMaxPacketSize) >> 11) & 0x03))
3540 
3541 static void em28xx_check_usb_descriptor(struct em28xx *dev,
3542 					struct usb_device *udev,
3543 					struct usb_interface *intf,
3544 					int alt, int ep,
3545 					bool *has_vendor_audio,
3546 					bool *has_video,
3547 					bool *has_dvb)
3548 {
3549 	const struct usb_endpoint_descriptor *e;
3550 	int sizedescr, size;
3551 
3552 	/*
3553 	 * NOTE:
3554 	 *
3555 	 * Old logic with support for isoc transfers only was:
3556 	 *  0x82	isoc		=> analog
3557 	 *  0x83	isoc		=> audio
3558 	 *  0x84	isoc		=> digital
3559 	 *
3560 	 * New logic with support for bulk transfers
3561 	 *  0x82	isoc		=> analog
3562 	 *  0x82	bulk		=> analog
3563 	 *  0x83	isoc*		=> audio
3564 	 *  0x84	isoc		=> digital
3565 	 *  0x84	bulk		=> analog or digital**
3566 	 *  0x85	isoc		=> digital TS2
3567 	 *  0x85	bulk		=> digital TS2
3568 	 * (*: audio should always be isoc)
3569 	 * (**: analog, if ep 0x82 is isoc, otherwise digital)
3570 	 *
3571 	 * The new logic preserves backwards compatibility and
3572 	 * reflects the endpoint configurations we have seen
3573 	 * so far. But there might be devices for which this
3574 	 * logic is not sufficient...
3575 	 */
3576 
3577 	e = &intf->altsetting[alt].endpoint[ep].desc;
3578 
3579 	if (!usb_endpoint_dir_in(e))
3580 		return;
3581 
3582 	sizedescr = le16_to_cpu(e->wMaxPacketSize);
3583 	size = sizedescr & 0x7ff;
3584 
3585 	if (udev->speed == USB_SPEED_HIGH)
3586 		size = size * hb_mult(sizedescr);
3587 
3588 	/* Only inspect input endpoints */
3589 
3590 	switch (e->bEndpointAddress) {
3591 	case 0x82:
3592 		*has_video = true;
3593 		if (usb_endpoint_xfer_isoc(e)) {
3594 			dev->analog_ep_isoc = e->bEndpointAddress;
3595 			dev->alt_max_pkt_size_isoc[alt] = size;
3596 		} else if (usb_endpoint_xfer_bulk(e)) {
3597 			dev->analog_ep_bulk = e->bEndpointAddress;
3598 		}
3599 		return;
3600 	case 0x83:
3601 		if (usb_endpoint_xfer_isoc(e))
3602 			*has_vendor_audio = true;
3603 		else
3604 			dev_err(&intf->dev,
3605 				"error: skipping audio endpoint 0x83, because it uses bulk transfers !\n");
3606 		return;
3607 	case 0x84:
3608 		if (*has_video && (usb_endpoint_xfer_bulk(e))) {
3609 			dev->analog_ep_bulk = e->bEndpointAddress;
3610 		} else {
3611 			if (usb_endpoint_xfer_isoc(e)) {
3612 				if (size > dev->dvb_max_pkt_size_isoc) {
3613 					/*
3614 					 * 2) some manufacturers (e.g. Terratec)
3615 					 * disable endpoints by setting
3616 					 * wMaxPacketSize to 0 bytes for all
3617 					 * alt settings. So far, we've seen
3618 					 * this for DVB isoc endpoints only.
3619 					 */
3620 					*has_dvb = true;
3621 					dev->dvb_ep_isoc = e->bEndpointAddress;
3622 					dev->dvb_max_pkt_size_isoc = size;
3623 					dev->dvb_alt_isoc = alt;
3624 				}
3625 			} else {
3626 				*has_dvb = true;
3627 				dev->dvb_ep_bulk = e->bEndpointAddress;
3628 			}
3629 		}
3630 		return;
3631 	case 0x85:
3632 		if (usb_endpoint_xfer_isoc(e)) {
3633 			if (size > dev->dvb_max_pkt_size_isoc_ts2) {
3634 				dev->dvb_ep_isoc_ts2 = e->bEndpointAddress;
3635 				dev->dvb_max_pkt_size_isoc_ts2 = size;
3636 				dev->dvb_alt_isoc = alt;
3637 			}
3638 		} else {
3639 			dev->dvb_ep_bulk_ts2 = e->bEndpointAddress;
3640 		}
3641 		return;
3642 	}
3643 }
3644 
3645 /*
3646  * em28xx_usb_probe()
3647  * checks for supported devices
3648  */
3649 static int em28xx_usb_probe(struct usb_interface *intf,
3650 			    const struct usb_device_id *id)
3651 {
3652 	struct usb_device *udev;
3653 	struct em28xx *dev = NULL;
3654 	int retval;
3655 	bool has_vendor_audio = false, has_video = false, has_dvb = false;
3656 	int i, nr, try_bulk;
3657 	const int ifnum = intf->altsetting[0].desc.bInterfaceNumber;
3658 	char *speed;
3659 
3660 	udev = usb_get_dev(interface_to_usbdev(intf));
3661 
3662 	/* Check to see next free device and mark as used */
3663 	do {
3664 		nr = find_first_zero_bit(em28xx_devused, EM28XX_MAXBOARDS);
3665 		if (nr >= EM28XX_MAXBOARDS) {
3666 			/* No free device slots */
3667 			dev_err(&intf->dev,
3668 				"Driver supports up to %i em28xx boards.\n",
3669 			       EM28XX_MAXBOARDS);
3670 			retval = -ENOMEM;
3671 			goto err_no_slot;
3672 		}
3673 	} while (test_and_set_bit(nr, em28xx_devused));
3674 
3675 	/* Don't register audio interfaces */
3676 	if (intf->altsetting[0].desc.bInterfaceClass == USB_CLASS_AUDIO) {
3677 		dev_err(&intf->dev,
3678 			"audio device (%04x:%04x): interface %i, class %i\n",
3679 			le16_to_cpu(udev->descriptor.idVendor),
3680 			le16_to_cpu(udev->descriptor.idProduct),
3681 			ifnum,
3682 			intf->altsetting[0].desc.bInterfaceClass);
3683 
3684 		retval = -ENODEV;
3685 		goto err;
3686 	}
3687 
3688 	/* allocate memory for our device state and initialize it */
3689 	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
3690 	if (!dev) {
3691 		retval = -ENOMEM;
3692 		goto err;
3693 	}
3694 
3695 	/* compute alternate max packet sizes */
3696 	dev->alt_max_pkt_size_isoc = kcalloc(intf->num_altsetting,
3697 					     sizeof(dev->alt_max_pkt_size_isoc[0]),
3698 					     GFP_KERNEL);
3699 	if (!dev->alt_max_pkt_size_isoc) {
3700 		kfree(dev);
3701 		retval = -ENOMEM;
3702 		goto err;
3703 	}
3704 
3705 	/* Get endpoints */
3706 	for (i = 0; i < intf->num_altsetting; i++) {
3707 		int ep;
3708 
3709 		for (ep = 0;
3710 		     ep < intf->altsetting[i].desc.bNumEndpoints;
3711 		     ep++)
3712 			em28xx_check_usb_descriptor(dev, udev, intf,
3713 						    i, ep,
3714 						    &has_vendor_audio,
3715 						    &has_video,
3716 						    &has_dvb);
3717 	}
3718 
3719 	if (!(has_vendor_audio || has_video || has_dvb)) {
3720 		retval = -ENODEV;
3721 		goto err_free;
3722 	}
3723 
3724 	switch (udev->speed) {
3725 	case USB_SPEED_LOW:
3726 		speed = "1.5";
3727 		break;
3728 	case USB_SPEED_UNKNOWN:
3729 	case USB_SPEED_FULL:
3730 		speed = "12";
3731 		break;
3732 	case USB_SPEED_HIGH:
3733 		speed = "480";
3734 		break;
3735 	default:
3736 		speed = "unknown";
3737 	}
3738 
3739 	dev_err(&intf->dev,
3740 		"New device %s %s @ %s Mbps (%04x:%04x, interface %d, class %d)\n",
3741 		udev->manufacturer ? udev->manufacturer : "",
3742 		udev->product ? udev->product : "",
3743 		speed,
3744 		le16_to_cpu(udev->descriptor.idVendor),
3745 		le16_to_cpu(udev->descriptor.idProduct),
3746 		ifnum,
3747 		intf->altsetting->desc.bInterfaceNumber);
3748 
3749 	/*
3750 	 * Make sure we have 480 Mbps of bandwidth, otherwise things like
3751 	 * video stream wouldn't likely work, since 12 Mbps is generally
3752 	 * not enough even for most Digital TV streams.
3753 	 */
3754 	if (udev->speed != USB_SPEED_HIGH && disable_usb_speed_check == 0) {
3755 		dev_err(&intf->dev, "Device initialization failed.\n");
3756 		dev_err(&intf->dev,
3757 			"Device must be connected to a high-speed USB 2.0 port.\n");
3758 		retval = -ENODEV;
3759 		goto err_free;
3760 	}
3761 
3762 	dev->devno = nr;
3763 	dev->model = id->driver_info;
3764 	dev->alt   = -1;
3765 	dev->is_audio_only = has_vendor_audio && !(has_video || has_dvb);
3766 	dev->has_video = has_video;
3767 	dev->ifnum = ifnum;
3768 
3769 	dev->ts = PRIMARY_TS;
3770 	snprintf(dev->name, 28, "em28xx");
3771 	dev->dev_next = NULL;
3772 
3773 	if (has_vendor_audio) {
3774 		dev_err(&intf->dev,
3775 			"Audio interface %i found (Vendor Class)\n", ifnum);
3776 		dev->usb_audio_type = EM28XX_USB_AUDIO_VENDOR;
3777 	}
3778 	/* Checks if audio is provided by a USB Audio Class intf */
3779 	for (i = 0; i < udev->config->desc.bNumInterfaces; i++) {
3780 		struct usb_interface *uif = udev->config->interface[i];
3781 
3782 		if (uif->altsetting[0].desc.bInterfaceClass == USB_CLASS_AUDIO) {
3783 			if (has_vendor_audio)
3784 				dev_err(&intf->dev,
3785 					"em28xx: device seems to have vendor AND usb audio class interfaces !\n"
3786 					"\t\tThe vendor interface will be ignored. Please contact the developers <linux-media@vger.kernel.org>\n");
3787 			dev->usb_audio_type = EM28XX_USB_AUDIO_CLASS;
3788 			break;
3789 		}
3790 	}
3791 
3792 	if (has_video)
3793 		dev_err(&intf->dev, "Video interface %i found:%s%s\n",
3794 			ifnum,
3795 			dev->analog_ep_bulk ? " bulk" : "",
3796 			dev->analog_ep_isoc ? " isoc" : "");
3797 	if (has_dvb)
3798 		dev_err(&intf->dev, "DVB interface %i found:%s%s\n",
3799 			ifnum,
3800 			dev->dvb_ep_bulk ? " bulk" : "",
3801 			dev->dvb_ep_isoc ? " isoc" : "");
3802 
3803 	dev->num_alt = intf->num_altsetting;
3804 
3805 	if ((unsigned int)card[nr] < em28xx_bcount)
3806 		dev->model = card[nr];
3807 
3808 	/* save our data pointer in this intf device */
3809 	usb_set_intfdata(intf, dev);
3810 
3811 	/* allocate device struct and check if the device is a webcam */
3812 	mutex_init(&dev->lock);
3813 	retval = em28xx_init_dev(dev, udev, intf, nr);
3814 	if (retval)
3815 		goto err_free;
3816 
3817 	if (usb_xfer_mode < 0) {
3818 		if (dev->is_webcam)
3819 			try_bulk = 1;
3820 		else
3821 			try_bulk = 0;
3822 	} else {
3823 		try_bulk = usb_xfer_mode > 0;
3824 	}
3825 
3826 	/* Disable V4L2 if the device doesn't have a decoder or image sensor */
3827 	if (has_video &&
3828 	    dev->board.decoder == EM28XX_NODECODER &&
3829 	    dev->em28xx_sensor == EM28XX_NOSENSOR) {
3830 		dev_err(&intf->dev,
3831 			"Currently, V4L2 is not supported on this model\n");
3832 		has_video = false;
3833 		dev->has_video = false;
3834 	}
3835 
3836 	/* Select USB transfer types to use */
3837 	if (has_video) {
3838 		if (!dev->analog_ep_isoc || (try_bulk && dev->analog_ep_bulk))
3839 			dev->analog_xfer_bulk = 1;
3840 		dev_err(&intf->dev, "analog set to %s mode.\n",
3841 			dev->analog_xfer_bulk ? "bulk" : "isoc");
3842 	}
3843 	if (has_dvb) {
3844 		if (!dev->dvb_ep_isoc || (try_bulk && dev->dvb_ep_bulk))
3845 			dev->dvb_xfer_bulk = 1;
3846 		dev_err(&intf->dev, "dvb set to %s mode.\n",
3847 			dev->dvb_xfer_bulk ? "bulk" : "isoc");
3848 	}
3849 
3850 	if (dev->board.has_dual_ts && em28xx_duplicate_dev(dev) == 0) {
3851 		dev->dev_next->ts = SECONDARY_TS;
3852 		dev->dev_next->alt   = -1;
3853 		dev->dev_next->is_audio_only = has_vendor_audio &&
3854 						!(has_video || has_dvb);
3855 		dev->dev_next->has_video = false;
3856 		dev->dev_next->ifnum = ifnum;
3857 		dev->dev_next->model = id->driver_info;
3858 
3859 		mutex_init(&dev->dev_next->lock);
3860 		retval = em28xx_init_dev(dev->dev_next, udev, intf,
3861 					 dev->dev_next->devno);
3862 		if (retval)
3863 			goto err_free;
3864 
3865 		dev->dev_next->board.ir_codes = NULL; /* No IR for 2nd tuner */
3866 		dev->dev_next->board.has_ir_i2c = 0; /* No IR for 2nd tuner */
3867 
3868 		if (usb_xfer_mode < 0) {
3869 			if (dev->dev_next->is_webcam)
3870 				try_bulk = 1;
3871 			else
3872 				try_bulk = 0;
3873 		} else {
3874 			try_bulk = usb_xfer_mode > 0;
3875 		}
3876 
3877 		/* Select USB transfer types to use */
3878 		if (has_dvb) {
3879 			if (!dev->dvb_ep_isoc_ts2 ||
3880 			    (try_bulk && dev->dvb_ep_bulk_ts2))
3881 				dev->dev_next->dvb_xfer_bulk = 1;
3882 			dev_info(&dev->intf->dev, "dvb ts2 set to %s mode.\n",
3883 				 dev->dev_next->dvb_xfer_bulk ? "bulk" : "isoc");
3884 		}
3885 
3886 		dev->dev_next->dvb_ep_isoc = dev->dvb_ep_isoc_ts2;
3887 		dev->dev_next->dvb_ep_bulk = dev->dvb_ep_bulk_ts2;
3888 		dev->dev_next->dvb_max_pkt_size_isoc = dev->dvb_max_pkt_size_isoc_ts2;
3889 		dev->dev_next->dvb_alt_isoc = dev->dvb_alt_isoc;
3890 
3891 		/* Configuare hardware to support TS2*/
3892 		if (dev->dvb_xfer_bulk) {
3893 			/* The ep4 and ep5 are configuared for BULK */
3894 			em28xx_write_reg(dev, 0x0b, 0x96);
3895 			mdelay(100);
3896 			em28xx_write_reg(dev, 0x0b, 0x80);
3897 			mdelay(100);
3898 		} else {
3899 			/* The ep4 and ep5 are configuared for ISO */
3900 			em28xx_write_reg(dev, 0x0b, 0x96);
3901 			mdelay(100);
3902 			em28xx_write_reg(dev, 0x0b, 0x82);
3903 			mdelay(100);
3904 		}
3905 
3906 		kref_init(&dev->dev_next->ref);
3907 	}
3908 
3909 	kref_init(&dev->ref);
3910 
3911 	request_modules(dev);
3912 
3913 	/*
3914 	 * Do it at the end, to reduce dynamic configuration changes during
3915 	 * the device init. Yet, as request_modules() can be async, the
3916 	 * topology will likely change after the load of the em28xx subdrivers.
3917 	 */
3918 #ifdef CONFIG_MEDIA_CONTROLLER
3919 	retval = media_device_register(dev->media_dev);
3920 #endif
3921 
3922 	return 0;
3923 
3924 err_free:
3925 	kfree(dev->alt_max_pkt_size_isoc);
3926 	kfree(dev);
3927 
3928 err:
3929 	clear_bit(nr, em28xx_devused);
3930 
3931 err_no_slot:
3932 	usb_put_dev(udev);
3933 	return retval;
3934 }
3935 
3936 /*
3937  * em28xx_usb_disconnect()
3938  * called when the device gets disconnected
3939  * video device will be unregistered on v4l2_close in case it is still open
3940  */
3941 static void em28xx_usb_disconnect(struct usb_interface *intf)
3942 {
3943 	struct em28xx *dev;
3944 
3945 	dev = usb_get_intfdata(intf);
3946 	usb_set_intfdata(intf, NULL);
3947 
3948 	if (!dev)
3949 		return;
3950 
3951 	if (dev->dev_next) {
3952 		dev->dev_next->disconnected = 1;
3953 		dev_info(&dev->intf->dev, "Disconnecting %s\n",
3954 			 dev->dev_next->name);
3955 		flush_request_modules(dev->dev_next);
3956 	}
3957 
3958 	dev->disconnected = 1;
3959 
3960 	dev_err(&dev->intf->dev, "Disconnecting %s\n", dev->name);
3961 
3962 	flush_request_modules(dev);
3963 
3964 	em28xx_close_extension(dev);
3965 
3966 	if (dev->dev_next)
3967 		em28xx_release_resources(dev->dev_next);
3968 	em28xx_release_resources(dev);
3969 
3970 	if (dev->dev_next) {
3971 		kref_put(&dev->dev_next->ref, em28xx_free_device);
3972 		dev->dev_next = NULL;
3973 	}
3974 	kref_put(&dev->ref, em28xx_free_device);
3975 }
3976 
3977 static int em28xx_usb_suspend(struct usb_interface *intf,
3978 			      pm_message_t message)
3979 {
3980 	struct em28xx *dev;
3981 
3982 	dev = usb_get_intfdata(intf);
3983 	if (!dev)
3984 		return 0;
3985 	em28xx_suspend_extension(dev);
3986 	return 0;
3987 }
3988 
3989 static int em28xx_usb_resume(struct usb_interface *intf)
3990 {
3991 	struct em28xx *dev;
3992 
3993 	dev = usb_get_intfdata(intf);
3994 	if (!dev)
3995 		return 0;
3996 	em28xx_resume_extension(dev);
3997 	return 0;
3998 }
3999 
4000 static struct usb_driver em28xx_usb_driver = {
4001 	.name = "em28xx",
4002 	.probe = em28xx_usb_probe,
4003 	.disconnect = em28xx_usb_disconnect,
4004 	.suspend = em28xx_usb_suspend,
4005 	.resume = em28xx_usb_resume,
4006 	.reset_resume = em28xx_usb_resume,
4007 	.id_table = em28xx_id_table,
4008 };
4009 
4010 module_usb_driver(em28xx_usb_driver);
4011