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