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, 0x8258), /* Bulk transport 461e */
2782 			.driver_info = EM28178_BOARD_PCTV_461E },
2783 	{ USB_DEVICE(0x2013, 0x0461),
2784 			.driver_info = EM28178_BOARD_PCTV_461E_V2 },
2785 	{ USB_DEVICE(0x2013, 0x8461), /* Bulk transport 461e v2 */
2786 			.driver_info = EM28178_BOARD_PCTV_461E_V2 },
2787 	{ USB_DEVICE(0x2013, 0x0259),
2788 			.driver_info = EM28178_BOARD_PCTV_461E_V2 },
2789 	{ USB_DEVICE(0x2013, 0x025f),
2790 			.driver_info = EM28178_BOARD_PCTV_292E },
2791 	{ USB_DEVICE(0x2013, 0x0264), /* Hauppauge WinTV-soloHD 292e SE */
2792 			.driver_info = EM28178_BOARD_PCTV_292E },
2793 	{ USB_DEVICE(0x2040, 0x0264), /* Hauppauge WinTV-soloHD Isoc */
2794 			.driver_info = EM28178_BOARD_PCTV_292E },
2795 	{ USB_DEVICE(0x2040, 0x8264), /* Hauppauge OEM Generic WinTV-soloHD Bulk */
2796 			.driver_info = EM28178_BOARD_PCTV_292E },
2797 	{ USB_DEVICE(0x2040, 0x8268), /* Hauppauge Retail WinTV-soloHD Bulk */
2798 			.driver_info = EM28178_BOARD_PCTV_292E },
2799 	{ USB_DEVICE(0x0413, 0x6f07),
2800 			.driver_info = EM2861_BOARD_LEADTEK_VC100 },
2801 	{ USB_DEVICE(0xeb1a, 0x8179),
2802 			.driver_info = EM28178_BOARD_TERRATEC_T2_STICK_HD },
2803 	{ USB_DEVICE(0x3275, 0x0085),
2804 			.driver_info = EM28178_BOARD_PLEX_PX_BCUD },
2805 	{ USB_DEVICE(0xeb1a, 0x5051), /* Ion Video 2 PC MKII / Startech svid2usb23 / Raygo R12-41373 */
2806 			.driver_info = EM2860_BOARD_TVP5150_REFERENCE_DESIGN },
2807 	{ USB_DEVICE(0x1b80, 0xe349), /* Magix USB Videowandler-2 */
2808 		.driver_info = EM2861_BOARD_MAGIX_VIDEOWANDLER2 },
2809 	{ },
2810 };
2811 MODULE_DEVICE_TABLE(usb, em28xx_id_table);
2812 
2813 /*
2814  * EEPROM hash table for devices with generic USB IDs
2815  */
2816 static const struct em28xx_hash_table em28xx_eeprom_hash[] = {
2817 	/* P/N: SA 60002070465 Tuner: TVF7533-MF */
2818 	{0x6ce05a8f, EM2820_BOARD_PROLINK_PLAYTV_USB2, TUNER_YMEC_TVF_5533MF},
2819 	{0x72cc5a8b, EM2820_BOARD_PROLINK_PLAYTV_BOX4_USB2, TUNER_YMEC_TVF_5533MF},
2820 	{0x966a0441, EM2880_BOARD_KWORLD_DVB_310U, TUNER_XC2028},
2821 	{0x166a0441, EM2880_BOARD_EMPIRE_DUAL_TV, TUNER_XC2028},
2822 	{0xcee44a99, EM2882_BOARD_EVGA_INDTUBE, TUNER_XC2028},
2823 	{0xb8846b20, EM2881_BOARD_PINNACLE_HYBRID_PRO, TUNER_XC2028},
2824 	{0x63f653bd, EM2870_BOARD_REDDO_DVB_C_USB_BOX, TUNER_ABSENT},
2825 	{0x4e913442, EM2882_BOARD_DIKOM_DK300, TUNER_XC2028},
2826 	{0x85dd871e, EM2882_BOARD_ZOLID_HYBRID_TV_STICK, TUNER_XC2028},
2827 };
2828 
2829 /* I2C devicelist hash table for devices with generic USB IDs */
2830 static const struct em28xx_hash_table em28xx_i2c_hash[] = {
2831 	{0xb06a32c3, EM2800_BOARD_TERRATEC_CINERGY_200, TUNER_LG_PAL_NEW_TAPC},
2832 	{0xf51200e3, EM2800_BOARD_VGEAR_POCKETTV, TUNER_LG_PAL_NEW_TAPC},
2833 	{0x1ba50080, EM2860_BOARD_SAA711X_REFERENCE_DESIGN, TUNER_ABSENT},
2834 	{0x77800080, EM2860_BOARD_TVP5150_REFERENCE_DESIGN, TUNER_ABSENT},
2835 	{0xc51200e3, EM2820_BOARD_GADMEI_TVR200, TUNER_LG_PAL_NEW_TAPC},
2836 	{0x4ba50080, EM2861_BOARD_GADMEI_UTV330PLUS, TUNER_TNF_5335MF},
2837 	{0x6b800080, EM2874_BOARD_LEADERSHIP_ISDBT, TUNER_ABSENT},
2838 	{0x27e10080, EM2882_BOARD_ZOLID_HYBRID_TV_STICK, TUNER_XC2028},
2839 };
2840 
2841 /* NOTE: introduce a separate hash table for devices with 16 bit eeproms */
2842 
2843 int em28xx_tuner_callback(void *ptr, int component, int command, int arg)
2844 {
2845 	struct em28xx_i2c_bus *i2c_bus = ptr;
2846 	struct em28xx *dev = i2c_bus->dev;
2847 	int rc = 0;
2848 
2849 	if (dev->tuner_type != TUNER_XC2028 && dev->tuner_type != TUNER_XC5000)
2850 		return 0;
2851 
2852 	if (command != XC2028_TUNER_RESET && command != XC5000_TUNER_RESET)
2853 		return 0;
2854 
2855 	rc = em28xx_gpio_set(dev, dev->board.tuner_gpio);
2856 
2857 	return rc;
2858 }
2859 EXPORT_SYMBOL_GPL(em28xx_tuner_callback);
2860 
2861 static inline void em28xx_set_xclk_i2c_speed(struct em28xx *dev)
2862 {
2863 	const struct em28xx_board *board = &em28xx_boards[dev->model];
2864 	u8 xclk = board->xclk, i2c_speed = board->i2c_speed;
2865 
2866 	/*
2867 	 * Those are the default values for the majority of boards
2868 	 * Use those values if not specified otherwise at boards entry
2869 	 */
2870 	if (!xclk)
2871 		xclk = EM28XX_XCLK_IR_RC5_MODE |
2872 		       EM28XX_XCLK_FREQUENCY_12MHZ;
2873 
2874 	em28xx_write_reg(dev, EM28XX_R0F_XCLK, xclk);
2875 
2876 	if (!i2c_speed)
2877 		i2c_speed = EM28XX_I2C_CLK_WAIT_ENABLE |
2878 			    EM28XX_I2C_FREQ_100_KHZ;
2879 
2880 	dev->i2c_speed = i2c_speed & 0x03;
2881 
2882 	if (!dev->board.is_em2800)
2883 		em28xx_write_reg(dev, EM28XX_R06_I2C_CLK, i2c_speed);
2884 	msleep(50);
2885 }
2886 
2887 static inline void em28xx_set_model(struct em28xx *dev)
2888 {
2889 	dev->board = em28xx_boards[dev->model];
2890 	dev->has_msp34xx = dev->board.has_msp34xx;
2891 	dev->is_webcam = dev->board.is_webcam;
2892 
2893 	em28xx_set_xclk_i2c_speed(dev);
2894 
2895 	/* Should be initialized early, for I2C to work */
2896 	dev->def_i2c_bus = dev->board.def_i2c_bus;
2897 }
2898 
2899 /*
2900  * Wait until AC97_RESET reports the expected value reliably before proceeding.
2901  * We also check that two unrelated registers accesses don't return the same
2902  * value to avoid premature return.
2903  * This procedure helps ensuring AC97 register accesses are reliable.
2904  */
2905 static int em28xx_wait_until_ac97_features_equals(struct em28xx *dev,
2906 						  int expected_feat)
2907 {
2908 	unsigned long timeout = jiffies + msecs_to_jiffies(2000);
2909 	int feat, powerdown;
2910 
2911 	while (time_is_after_jiffies(timeout)) {
2912 		feat = em28xx_read_ac97(dev, AC97_RESET);
2913 		if (feat < 0)
2914 			return feat;
2915 
2916 		powerdown = em28xx_read_ac97(dev, AC97_POWERDOWN);
2917 		if (powerdown < 0)
2918 			return powerdown;
2919 
2920 		if (feat == expected_feat && feat != powerdown)
2921 			return 0;
2922 
2923 		msleep(50);
2924 	}
2925 
2926 	dev_warn(&dev->intf->dev, "AC97 registers access is not reliable !\n");
2927 	return -ETIMEDOUT;
2928 }
2929 
2930 /*
2931  * Since em28xx_pre_card_setup() requires a proper dev->model,
2932  * this won't work for boards with generic PCI IDs
2933  */
2934 static void em28xx_pre_card_setup(struct em28xx *dev)
2935 {
2936 	/*
2937 	 * Set the initial XCLK and I2C clock values based on the board
2938 	 * definition
2939 	 */
2940 	em28xx_set_xclk_i2c_speed(dev);
2941 
2942 	/* request some modules */
2943 	switch (dev->model) {
2944 	case EM2861_BOARD_PLEXTOR_PX_TV100U:
2945 		/* Sets the msp34xx I2S speed */
2946 		dev->i2s_speed = 2048000;
2947 		break;
2948 	case EM2861_BOARD_KWORLD_PVRTV_300U:
2949 	case EM2880_BOARD_KWORLD_DVB_305U:
2950 		em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0x6d);
2951 		usleep_range(10000, 11000);
2952 		em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0x7d);
2953 		usleep_range(10000, 11000);
2954 		break;
2955 	case EM2870_BOARD_COMPRO_VIDEOMATE:
2956 		/*
2957 		 * TODO: someone can do some cleanup here...
2958 		 *	 not everything's needed
2959 		 */
2960 		em28xx_write_reg(dev, EM2880_R04_GPO, 0x00);
2961 		usleep_range(10000, 11000);
2962 		em28xx_write_reg(dev, EM2880_R04_GPO, 0x01);
2963 		usleep_range(10000, 11000);
2964 		em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xfd);
2965 		msleep(70);
2966 		em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xfc);
2967 		msleep(70);
2968 		em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xdc);
2969 		msleep(70);
2970 		em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xfc);
2971 		msleep(70);
2972 		break;
2973 	case EM2870_BOARD_TERRATEC_XS_MT2060:
2974 		/*
2975 		 * this device needs some gpio writes to get the DVB-T
2976 		 * demod work
2977 		 */
2978 		em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xfe);
2979 		msleep(70);
2980 		em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xde);
2981 		msleep(70);
2982 		em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xfe);
2983 		msleep(70);
2984 		break;
2985 	case EM2870_BOARD_PINNACLE_PCTV_DVB:
2986 		/*
2987 		 * this device needs some gpio writes to get the
2988 		 * DVB-T demod work
2989 		 */
2990 		em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xfe);
2991 		msleep(70);
2992 		em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xde);
2993 		msleep(70);
2994 		em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xfe);
2995 		msleep(70);
2996 		break;
2997 	case EM2820_BOARD_GADMEI_UTV310:
2998 	case EM2820_BOARD_MSI_VOX_USB_2:
2999 		/* enables audio for that devices */
3000 		em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xfd);
3001 		break;
3002 
3003 	case EM2882_BOARD_KWORLD_ATSC_315U:
3004 		em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xff);
3005 		usleep_range(10000, 11000);
3006 		em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xfe);
3007 		usleep_range(10000, 11000);
3008 		em28xx_write_reg(dev, EM2880_R04_GPO, 0x00);
3009 		usleep_range(10000, 11000);
3010 		em28xx_write_reg(dev, EM2880_R04_GPO, 0x08);
3011 		usleep_range(10000, 11000);
3012 		break;
3013 
3014 	case EM2860_BOARD_KAIOMY_TVNPC_U2:
3015 		em28xx_write_regs(dev, EM28XX_R0F_XCLK, "\x07", 1);
3016 		em28xx_write_regs(dev, EM28XX_R06_I2C_CLK, "\x40", 1);
3017 		em28xx_write_regs(dev, 0x0d, "\x42", 1);
3018 		em28xx_write_regs(dev, 0x08, "\xfd", 1);
3019 		usleep_range(10000, 11000);
3020 		em28xx_write_regs(dev, 0x08, "\xff", 1);
3021 		usleep_range(10000, 11000);
3022 		em28xx_write_regs(dev, 0x08, "\x7f", 1);
3023 		usleep_range(10000, 11000);
3024 		em28xx_write_regs(dev, 0x08, "\x6b", 1);
3025 
3026 		break;
3027 	case EM2860_BOARD_EASYCAP:
3028 		em28xx_write_regs(dev, 0x08, "\xf8", 1);
3029 		break;
3030 
3031 	case EM2820_BOARD_IODATA_GVMVP_SZ:
3032 		em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xff);
3033 		msleep(70);
3034 		em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xf7);
3035 		usleep_range(10000, 11000);
3036 		em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xfe);
3037 		msleep(70);
3038 		em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xfd);
3039 		msleep(70);
3040 		break;
3041 
3042 	case EM2860_BOARD_TERRATEC_GRABBY:
3043 		/*
3044 		 * HACK?: Ensure AC97 register reading is reliable before
3045 		 * proceeding. In practice, this will wait about 1.6 seconds.
3046 		 */
3047 		em28xx_wait_until_ac97_features_equals(dev, 0x6a90);
3048 		break;
3049 	}
3050 
3051 	em28xx_gpio_set(dev, dev->board.tuner_gpio);
3052 	em28xx_set_mode(dev, EM28XX_ANALOG_MODE);
3053 
3054 	/* Unlock device */
3055 	em28xx_set_mode(dev, EM28XX_SUSPEND);
3056 }
3057 
3058 static int em28xx_hint_board(struct em28xx *dev)
3059 {
3060 	int i;
3061 
3062 	if (dev->is_webcam) {
3063 		if (dev->em28xx_sensor == EM28XX_MT9V011) {
3064 			dev->model = EM2820_BOARD_SILVERCREST_WEBCAM;
3065 		} else if (dev->em28xx_sensor == EM28XX_MT9M001 ||
3066 			   dev->em28xx_sensor == EM28XX_MT9M111) {
3067 			dev->model = EM2750_BOARD_UNKNOWN;
3068 		}
3069 		/* FIXME: IMPROVE ! */
3070 
3071 		return 0;
3072 	}
3073 
3074 	/*
3075 	 * HINT method: EEPROM
3076 	 *
3077 	 * This method works only for boards with eeprom.
3078 	 * Uses a hash of all eeprom bytes. The hash should be
3079 	 * unique for a vendor/tuner pair.
3080 	 * There are a high chance that tuners for different
3081 	 * video standards produce different hashes.
3082 	 */
3083 	for (i = 0; i < ARRAY_SIZE(em28xx_eeprom_hash); i++) {
3084 		if (dev->hash == em28xx_eeprom_hash[i].hash) {
3085 			dev->model = em28xx_eeprom_hash[i].model;
3086 			dev->tuner_type = em28xx_eeprom_hash[i].tuner;
3087 
3088 			dev_err(&dev->intf->dev,
3089 				"Your board has no unique USB ID.\n"
3090 				"A hint were successfully done, based on eeprom hash.\n"
3091 				"This method is not 100%% failproof.\n"
3092 				"If the board were misdetected, please email this log to:\n"
3093 				"\tV4L Mailing List  <linux-media@vger.kernel.org>\n"
3094 				"Board detected as %s\n",
3095 			       em28xx_boards[dev->model].name);
3096 
3097 			return 0;
3098 		}
3099 	}
3100 
3101 	/*
3102 	 * HINT method: I2C attached devices
3103 	 *
3104 	 * This method works for all boards.
3105 	 * Uses a hash of i2c scanned devices.
3106 	 * Devices with the same i2c attached chips will
3107 	 * be considered equal.
3108 	 * This method is less precise than the eeprom one.
3109 	 */
3110 
3111 	/* user did not request i2c scanning => do it now */
3112 	if (!dev->i2c_hash)
3113 		em28xx_do_i2c_scan(dev, dev->def_i2c_bus);
3114 
3115 	for (i = 0; i < ARRAY_SIZE(em28xx_i2c_hash); i++) {
3116 		if (dev->i2c_hash == em28xx_i2c_hash[i].hash) {
3117 			dev->model = em28xx_i2c_hash[i].model;
3118 			dev->tuner_type = em28xx_i2c_hash[i].tuner;
3119 			dev_err(&dev->intf->dev,
3120 				"Your board has no unique USB ID.\n"
3121 				"A hint were successfully done, based on i2c devicelist hash.\n"
3122 				"This method is not 100%% failproof.\n"
3123 				"If the board were misdetected, please email this log to:\n"
3124 				"\tV4L Mailing List  <linux-media@vger.kernel.org>\n"
3125 				"Board detected as %s\n",
3126 				em28xx_boards[dev->model].name);
3127 
3128 			return 0;
3129 		}
3130 	}
3131 
3132 	dev_err(&dev->intf->dev,
3133 		"Your board has no unique USB ID and thus need a hint to be detected.\n"
3134 		"You may try to use card=<n> insmod option to workaround that.\n"
3135 		"Please send an email with this log to:\n"
3136 		"\tV4L Mailing List <linux-media@vger.kernel.org>\n"
3137 		"Board eeprom hash is 0x%08lx\n"
3138 		"Board i2c devicelist hash is 0x%08lx\n",
3139 		dev->hash, dev->i2c_hash);
3140 
3141 	dev_err(&dev->intf->dev,
3142 		"Here is a list of valid choices for the card=<n> insmod option:\n");
3143 	for (i = 0; i < em28xx_bcount; i++) {
3144 		dev_err(&dev->intf->dev,
3145 			"    card=%d -> %s\n", i, em28xx_boards[i].name);
3146 	}
3147 	return -1;
3148 }
3149 
3150 static void em28xx_card_setup(struct em28xx *dev)
3151 {
3152 	int i, j, idx;
3153 	bool duplicate_entry;
3154 
3155 	/*
3156 	 * If the device can be a webcam, seek for a sensor.
3157 	 * If sensor is not found, then it isn't a webcam.
3158 	 */
3159 	if (dev->is_webcam) {
3160 		em28xx_detect_sensor(dev);
3161 		if (dev->em28xx_sensor == EM28XX_NOSENSOR)
3162 			/* NOTE: error/unknown sensor/no sensor */
3163 			dev->is_webcam = 0;
3164 	}
3165 
3166 	switch (dev->model) {
3167 	case EM2750_BOARD_UNKNOWN:
3168 	case EM2820_BOARD_UNKNOWN:
3169 	case EM2800_BOARD_UNKNOWN:
3170 		/*
3171 		 * The K-WORLD DVB-T 310U is detected as an MSI Digivox AD.
3172 		 *
3173 		 * This occurs because they share identical USB vendor and
3174 		 * product IDs.
3175 		 *
3176 		 * What we do here is look up the EEPROM hash of the K-WORLD
3177 		 * and if it is found then we decide that we do not have
3178 		 * a DIGIVOX and reset the device to the K-WORLD instead.
3179 		 *
3180 		 * This solution is only valid if they do not share eeprom
3181 		 * hash identities which has not been determined as yet.
3182 		 */
3183 		if (em28xx_hint_board(dev) < 0) {
3184 			dev_err(&dev->intf->dev, "Board not discovered\n");
3185 		} else {
3186 			em28xx_set_model(dev);
3187 			em28xx_pre_card_setup(dev);
3188 		}
3189 		break;
3190 	default:
3191 		em28xx_set_model(dev);
3192 	}
3193 
3194 	dev_info(&dev->intf->dev, "Identified as %s (card=%d)\n",
3195 		 dev->board.name, dev->model);
3196 
3197 	dev->tuner_type = em28xx_boards[dev->model].tuner_type;
3198 
3199 	/* request some modules */
3200 	switch (dev->model) {
3201 	case EM2820_BOARD_HAUPPAUGE_WINTV_USB_2:
3202 	case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900:
3203 	case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900_R2:
3204 	case EM2883_BOARD_HAUPPAUGE_WINTV_HVR_850:
3205 	case EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950:
3206 	case EM2884_BOARD_HAUPPAUGE_WINTV_HVR_930C:
3207 	case EM28174_BOARD_HAUPPAUGE_WINTV_DUALHD_DVB:
3208 	case EM28174_BOARD_HAUPPAUGE_WINTV_DUALHD_01595:
3209 	{
3210 		struct tveeprom tv;
3211 
3212 		if (!dev->eedata)
3213 			break;
3214 #if defined(CONFIG_MODULES) && defined(MODULE)
3215 		request_module("tveeprom");
3216 #endif
3217 		/* Call first TVeeprom */
3218 
3219 		tveeprom_hauppauge_analog(&tv, dev->eedata);
3220 
3221 		dev->tuner_type = tv.tuner_type;
3222 
3223 		if (tv.audio_processor == TVEEPROM_AUDPROC_MSP) {
3224 			dev->i2s_speed = 2048000;
3225 			dev->has_msp34xx = 1;
3226 		}
3227 		break;
3228 	}
3229 	case EM2882_BOARD_KWORLD_ATSC_315U:
3230 		em28xx_write_reg(dev, 0x0d, 0x42);
3231 		usleep_range(10000, 11000);
3232 		em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xfd);
3233 		usleep_range(10000, 11000);
3234 		break;
3235 	case EM2820_BOARD_KWORLD_PVRTV2800RF:
3236 		/* GPIO enables sound on KWORLD PVR TV 2800RF */
3237 		em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xf9);
3238 		break;
3239 	case EM2820_BOARD_UNKNOWN:
3240 	case EM2800_BOARD_UNKNOWN:
3241 		/*
3242 		 * The K-WORLD DVB-T 310U is detected as an MSI Digivox AD.
3243 		 *
3244 		 * This occurs because they share identical USB vendor and
3245 		 * product IDs.
3246 		 *
3247 		 * What we do here is look up the EEPROM hash of the K-WORLD
3248 		 * and if it is found then we decide that we do not have
3249 		 * a DIGIVOX and reset the device to the K-WORLD instead.
3250 		 *
3251 		 * This solution is only valid if they do not share eeprom
3252 		 * hash identities which has not been determined as yet.
3253 		 */
3254 	case EM2880_BOARD_MSI_DIGIVOX_AD:
3255 		if (!em28xx_hint_board(dev))
3256 			em28xx_set_model(dev);
3257 
3258 		/*
3259 		 * In cases where we had to use a board hint, the call to
3260 		 * em28xx_set_mode() in em28xx_pre_card_setup() was a no-op,
3261 		 * so make the call now so the analog GPIOs are set properly
3262 		 * before probing the i2c bus.
3263 		 */
3264 		em28xx_gpio_set(dev, dev->board.tuner_gpio);
3265 		em28xx_set_mode(dev, EM28XX_ANALOG_MODE);
3266 		break;
3267 
3268 		/*
3269 		 * The Dikom DK300 is detected as an Kworld VS-DVB-T 323UR.
3270 		 *
3271 		 * This occurs because they share identical USB vendor and
3272 		 * product IDs.
3273 		 *
3274 		 * What we do here is look up the EEPROM hash of the Dikom
3275 		 * and if it is found then we decide that we do not have
3276 		 * a Kworld and reset the device to the Dikom instead.
3277 		 *
3278 		 * This solution is only valid if they do not share eeprom
3279 		 * hash identities which has not been determined as yet.
3280 		 */
3281 	case EM2882_BOARD_KWORLD_VS_DVBT:
3282 		if (!em28xx_hint_board(dev))
3283 			em28xx_set_model(dev);
3284 
3285 		/*
3286 		 * In cases where we had to use a board hint, the call to
3287 		 * em28xx_set_mode() in em28xx_pre_card_setup() was a no-op,
3288 		 * so make the call now so the analog GPIOs are set properly
3289 		 * before probing the i2c bus.
3290 		 */
3291 		em28xx_gpio_set(dev, dev->board.tuner_gpio);
3292 		em28xx_set_mode(dev, EM28XX_ANALOG_MODE);
3293 		break;
3294 	}
3295 
3296 	if (dev->board.valid == EM28XX_BOARD_NOT_VALIDATED) {
3297 		dev_err(&dev->intf->dev,
3298 			"\n\n"
3299 			"The support for this board weren't valid yet.\n"
3300 			"Please send a report of having this working\n"
3301 			"not to V4L mailing list (and/or to other addresses)\n\n");
3302 	}
3303 
3304 	/* Free eeprom data memory */
3305 	kfree(dev->eedata);
3306 	dev->eedata = NULL;
3307 
3308 	/* Allow override tuner type by a module parameter */
3309 	if (tuner >= 0)
3310 		dev->tuner_type = tuner;
3311 
3312 	/*
3313 	 * Dynamically generate a list of valid audio inputs for this
3314 	 * specific board, mapping them via enum em28xx_amux.
3315 	 */
3316 
3317 	idx = 0;
3318 	for (i = 0; i < MAX_EM28XX_INPUT; i++) {
3319 		if (!INPUT(i)->type)
3320 			continue;
3321 
3322 		/* Skip already mapped audio inputs */
3323 		duplicate_entry = false;
3324 		for (j = 0; j < idx; j++) {
3325 			if (INPUT(i)->amux == dev->amux_map[j]) {
3326 				duplicate_entry = true;
3327 				break;
3328 			}
3329 		}
3330 		if (duplicate_entry)
3331 			continue;
3332 
3333 		dev->amux_map[idx++] = INPUT(i)->amux;
3334 	}
3335 	for (; idx < MAX_EM28XX_INPUT; idx++)
3336 		dev->amux_map[idx] = EM28XX_AMUX_UNUSED;
3337 }
3338 
3339 void em28xx_setup_xc3028(struct em28xx *dev, struct xc2028_ctrl *ctl)
3340 {
3341 	memset(ctl, 0, sizeof(*ctl));
3342 
3343 	ctl->fname   = XC2028_DEFAULT_FIRMWARE;
3344 	ctl->max_len = 64;
3345 	ctl->mts = em28xx_boards[dev->model].mts_firmware;
3346 
3347 	switch (dev->model) {
3348 	case EM2880_BOARD_EMPIRE_DUAL_TV:
3349 	case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900:
3350 	case EM2882_BOARD_TERRATEC_HYBRID_XS:
3351 	case EM2880_BOARD_TERRATEC_HYBRID_XS:
3352 	case EM2880_BOARD_TERRATEC_HYBRID_XS_FR:
3353 	case EM2881_BOARD_PINNACLE_HYBRID_PRO:
3354 	case EM2882_BOARD_ZOLID_HYBRID_TV_STICK:
3355 		ctl->demod = XC3028_FE_ZARLINK456;
3356 		break;
3357 	case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900_R2:
3358 	case EM2882_BOARD_PINNACLE_HYBRID_PRO_330E:
3359 		ctl->demod = XC3028_FE_DEFAULT;
3360 		break;
3361 	case EM2880_BOARD_AMD_ATI_TV_WONDER_HD_600:
3362 		ctl->demod = XC3028_FE_DEFAULT;
3363 		ctl->fname = XC3028L_DEFAULT_FIRMWARE;
3364 		break;
3365 	case EM2883_BOARD_HAUPPAUGE_WINTV_HVR_850:
3366 	case EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950:
3367 	case EM2880_BOARD_PINNACLE_PCTV_HD_PRO:
3368 		/* FIXME: Better to specify the needed IF */
3369 		ctl->demod = XC3028_FE_DEFAULT;
3370 		break;
3371 	case EM2883_BOARD_KWORLD_HYBRID_330U:
3372 	case EM2882_BOARD_DIKOM_DK300:
3373 	case EM2882_BOARD_KWORLD_VS_DVBT:
3374 		ctl->demod = XC3028_FE_CHINA;
3375 		ctl->fname = XC2028_DEFAULT_FIRMWARE;
3376 		break;
3377 	case EM2882_BOARD_EVGA_INDTUBE:
3378 		ctl->demod = XC3028_FE_CHINA;
3379 		ctl->fname = XC3028L_DEFAULT_FIRMWARE;
3380 		break;
3381 	default:
3382 		ctl->demod = XC3028_FE_OREN538;
3383 	}
3384 }
3385 EXPORT_SYMBOL_GPL(em28xx_setup_xc3028);
3386 
3387 static void request_module_async(struct work_struct *work)
3388 {
3389 	struct em28xx *dev = container_of(work,
3390 			     struct em28xx, request_module_wk);
3391 
3392 	/*
3393 	 * The em28xx extensions can be modules or builtin. If the
3394 	 * modules are already loaded or are built in, those extensions
3395 	 * can be initialised right now. Otherwise, the module init
3396 	 * code will do it.
3397 	 */
3398 
3399 	/*
3400 	 * Devices with an audio-only intf also have a V4L/DVB/RC
3401 	 * intf. Don't register extensions twice on those devices.
3402 	 */
3403 	if (dev->is_audio_only) {
3404 #if defined(CONFIG_MODULES) && defined(MODULE)
3405 		request_module("em28xx-alsa");
3406 #endif
3407 		return;
3408 	}
3409 
3410 	em28xx_init_extension(dev);
3411 
3412 #if defined(CONFIG_MODULES) && defined(MODULE)
3413 	if (dev->has_video)
3414 		request_module("em28xx-v4l");
3415 	if (dev->usb_audio_type == EM28XX_USB_AUDIO_CLASS)
3416 		request_module("snd-usb-audio");
3417 	else if (dev->usb_audio_type == EM28XX_USB_AUDIO_VENDOR)
3418 		request_module("em28xx-alsa");
3419 	if (dev->board.has_dvb)
3420 		request_module("em28xx-dvb");
3421 	if (dev->board.buttons ||
3422 	    ((dev->board.ir_codes || dev->board.has_ir_i2c) && !disable_ir))
3423 		request_module("em28xx-rc");
3424 #endif /* CONFIG_MODULES */
3425 }
3426 
3427 static void request_modules(struct em28xx *dev)
3428 {
3429 	INIT_WORK(&dev->request_module_wk, request_module_async);
3430 	schedule_work(&dev->request_module_wk);
3431 }
3432 
3433 static void flush_request_modules(struct em28xx *dev)
3434 {
3435 	flush_work(&dev->request_module_wk);
3436 }
3437 
3438 static int em28xx_media_device_init(struct em28xx *dev,
3439 				    struct usb_device *udev)
3440 {
3441 #ifdef CONFIG_MEDIA_CONTROLLER
3442 	struct media_device *mdev;
3443 
3444 	mdev = kzalloc(sizeof(*mdev), GFP_KERNEL);
3445 	if (!mdev)
3446 		return -ENOMEM;
3447 
3448 	if (udev->product)
3449 		media_device_usb_init(mdev, udev, udev->product);
3450 	else if (udev->manufacturer)
3451 		media_device_usb_init(mdev, udev, udev->manufacturer);
3452 	else
3453 		media_device_usb_init(mdev, udev, dev_name(&dev->intf->dev));
3454 
3455 	dev->media_dev = mdev;
3456 #endif
3457 	return 0;
3458 }
3459 
3460 static void em28xx_unregister_media_device(struct em28xx *dev)
3461 {
3462 #ifdef CONFIG_MEDIA_CONTROLLER
3463 	if (dev->media_dev) {
3464 		media_device_unregister(dev->media_dev);
3465 		media_device_cleanup(dev->media_dev);
3466 		kfree(dev->media_dev);
3467 		dev->media_dev = NULL;
3468 	}
3469 #endif
3470 }
3471 
3472 /*
3473  * em28xx_release_resources()
3474  * unregisters the v4l2,i2c and usb devices
3475  * called when the device gets disconnected or at module unload
3476  */
3477 static void em28xx_release_resources(struct em28xx *dev)
3478 {
3479 	struct usb_device *udev = interface_to_usbdev(dev->intf);
3480 
3481 	/*FIXME: I2C IR should be disconnected */
3482 
3483 	mutex_lock(&dev->lock);
3484 
3485 	em28xx_unregister_media_device(dev);
3486 
3487 	if (dev->def_i2c_bus)
3488 		em28xx_i2c_unregister(dev, 1);
3489 	em28xx_i2c_unregister(dev, 0);
3490 
3491 	if (dev->ts == PRIMARY_TS)
3492 		usb_put_dev(udev);
3493 
3494 	/* Mark device as unused */
3495 	clear_bit(dev->devno, em28xx_devused);
3496 
3497 	mutex_unlock(&dev->lock);
3498 };
3499 
3500 /**
3501  * em28xx_free_device() - Free em28xx device
3502  *
3503  * @ref: struct kref for em28xx device
3504  *
3505  * This is called when all extensions and em28xx core unregisters a device
3506  */
3507 void em28xx_free_device(struct kref *ref)
3508 {
3509 	struct em28xx *dev = kref_to_dev(ref);
3510 
3511 	dev_info(&dev->intf->dev, "Freeing device\n");
3512 
3513 	if (!dev->disconnected)
3514 		em28xx_release_resources(dev);
3515 
3516 	if (dev->ts == PRIMARY_TS)
3517 		kfree(dev->alt_max_pkt_size_isoc);
3518 
3519 	kfree(dev);
3520 }
3521 EXPORT_SYMBOL_GPL(em28xx_free_device);
3522 
3523 /*
3524  * em28xx_init_dev()
3525  * allocates and inits the device structs, registers i2c bus and v4l device
3526  */
3527 static int em28xx_init_dev(struct em28xx *dev, struct usb_device *udev,
3528 			   struct usb_interface *intf,
3529 			   int minor)
3530 {
3531 	int retval;
3532 	const char *chip_name = NULL;
3533 
3534 	dev->intf = intf;
3535 	mutex_init(&dev->ctrl_urb_lock);
3536 	spin_lock_init(&dev->slock);
3537 
3538 	dev->em28xx_write_regs = em28xx_write_regs;
3539 	dev->em28xx_read_reg = em28xx_read_reg;
3540 	dev->em28xx_read_reg_req_len = em28xx_read_reg_req_len;
3541 	dev->em28xx_write_regs_req = em28xx_write_regs_req;
3542 	dev->em28xx_read_reg_req = em28xx_read_reg_req;
3543 	dev->board.is_em2800 = em28xx_boards[dev->model].is_em2800;
3544 
3545 	em28xx_set_model(dev);
3546 
3547 	dev->wait_after_write = 5;
3548 
3549 	/* Based on the Chip ID, set the device configuration */
3550 	retval = em28xx_read_reg(dev, EM28XX_R0A_CHIPID);
3551 	if (retval > 0) {
3552 		dev->chip_id = retval;
3553 
3554 		switch (dev->chip_id) {
3555 		case CHIP_ID_EM2800:
3556 			chip_name = "em2800";
3557 			break;
3558 		case CHIP_ID_EM2710:
3559 			chip_name = "em2710";
3560 			break;
3561 		case CHIP_ID_EM2750:
3562 			chip_name = "em2750";
3563 			break;
3564 		case CHIP_ID_EM2765:
3565 			chip_name = "em2765";
3566 			dev->wait_after_write = 0;
3567 			dev->is_em25xx = 1;
3568 			dev->eeprom_addrwidth_16bit = 1;
3569 			break;
3570 		case CHIP_ID_EM2820:
3571 			chip_name = "em2710/2820";
3572 			if (le16_to_cpu(udev->descriptor.idVendor) == 0xeb1a) {
3573 				__le16 idProd = udev->descriptor.idProduct;
3574 
3575 				if (le16_to_cpu(idProd) == 0x2710)
3576 					chip_name = "em2710";
3577 				else if (le16_to_cpu(idProd) == 0x2820)
3578 					chip_name = "em2820";
3579 			}
3580 			/* NOTE: the em2820 is used in webcams, too ! */
3581 			break;
3582 		case CHIP_ID_EM2840:
3583 			chip_name = "em2840";
3584 			break;
3585 		case CHIP_ID_EM2860:
3586 			chip_name = "em2860";
3587 			break;
3588 		case CHIP_ID_EM2870:
3589 			chip_name = "em2870";
3590 			dev->wait_after_write = 0;
3591 			break;
3592 		case CHIP_ID_EM2874:
3593 			chip_name = "em2874";
3594 			dev->wait_after_write = 0;
3595 			dev->eeprom_addrwidth_16bit = 1;
3596 			break;
3597 		case CHIP_ID_EM28174:
3598 			chip_name = "em28174";
3599 			dev->wait_after_write = 0;
3600 			dev->eeprom_addrwidth_16bit = 1;
3601 			break;
3602 		case CHIP_ID_EM28178:
3603 			chip_name = "em28178";
3604 			dev->wait_after_write = 0;
3605 			dev->eeprom_addrwidth_16bit = 1;
3606 			break;
3607 		case CHIP_ID_EM2883:
3608 			chip_name = "em2882/3";
3609 			dev->wait_after_write = 0;
3610 			break;
3611 		case CHIP_ID_EM2884:
3612 			chip_name = "em2884";
3613 			dev->wait_after_write = 0;
3614 			dev->eeprom_addrwidth_16bit = 1;
3615 			break;
3616 		}
3617 	}
3618 	if (!chip_name)
3619 		dev_info(&dev->intf->dev,
3620 			 "unknown em28xx chip ID (%d)\n", dev->chip_id);
3621 	else
3622 		dev_info(&dev->intf->dev, "chip ID is %s\n", chip_name);
3623 
3624 	em28xx_media_device_init(dev, udev);
3625 
3626 	if (dev->is_audio_only) {
3627 		retval = em28xx_audio_setup(dev);
3628 		if (retval)
3629 			return -ENODEV;
3630 		em28xx_init_extension(dev);
3631 
3632 		return 0;
3633 	}
3634 
3635 	em28xx_pre_card_setup(dev);
3636 
3637 	rt_mutex_init(&dev->i2c_bus_lock);
3638 
3639 	/* register i2c bus 0 */
3640 	if (dev->board.is_em2800)
3641 		retval = em28xx_i2c_register(dev, 0, EM28XX_I2C_ALGO_EM2800);
3642 	else
3643 		retval = em28xx_i2c_register(dev, 0, EM28XX_I2C_ALGO_EM28XX);
3644 	if (retval < 0) {
3645 		dev_err(&dev->intf->dev,
3646 			"%s: em28xx_i2c_register bus 0 - error [%d]!\n",
3647 		       __func__, retval);
3648 		return retval;
3649 	}
3650 
3651 	/* register i2c bus 1 */
3652 	if (dev->def_i2c_bus) {
3653 		if (dev->is_em25xx)
3654 			retval = em28xx_i2c_register(dev, 1,
3655 						     EM28XX_I2C_ALGO_EM25XX_BUS_B);
3656 		else
3657 			retval = em28xx_i2c_register(dev, 1,
3658 						     EM28XX_I2C_ALGO_EM28XX);
3659 		if (retval < 0) {
3660 			dev_err(&dev->intf->dev,
3661 				"%s: em28xx_i2c_register bus 1 - error [%d]!\n",
3662 				__func__, retval);
3663 
3664 			em28xx_i2c_unregister(dev, 0);
3665 
3666 			return retval;
3667 		}
3668 	}
3669 
3670 	/* Do board specific init and eeprom reading */
3671 	em28xx_card_setup(dev);
3672 
3673 	return 0;
3674 }
3675 
3676 static int em28xx_duplicate_dev(struct em28xx *dev)
3677 {
3678 	int nr;
3679 	struct em28xx *sec_dev = kmemdup(dev, sizeof(*sec_dev), GFP_KERNEL);
3680 
3681 	if (!sec_dev) {
3682 		dev->dev_next = NULL;
3683 		return -ENOMEM;
3684 	}
3685 	/* Check to see next free device and mark as used */
3686 	do {
3687 		nr = find_first_zero_bit(em28xx_devused, EM28XX_MAXBOARDS);
3688 		if (nr >= EM28XX_MAXBOARDS) {
3689 			/* No free device slots */
3690 			dev_warn(&dev->intf->dev, ": Supports only %i em28xx boards.\n",
3691 				 EM28XX_MAXBOARDS);
3692 			kfree(sec_dev);
3693 			dev->dev_next = NULL;
3694 			return -ENOMEM;
3695 		}
3696 	} while (test_and_set_bit(nr, em28xx_devused));
3697 	sec_dev->devno = nr;
3698 	snprintf(sec_dev->name, 28, "em28xx #%d", nr);
3699 	sec_dev->dev_next = NULL;
3700 	dev->dev_next = sec_dev;
3701 	return 0;
3702 }
3703 
3704 /* high bandwidth multiplier, as encoded in highspeed endpoint descriptors */
3705 #define hb_mult(wMaxPacketSize) (1 + (((wMaxPacketSize) >> 11) & 0x03))
3706 
3707 static void em28xx_check_usb_descriptor(struct em28xx *dev,
3708 					struct usb_device *udev,
3709 					struct usb_interface *intf,
3710 					int alt, int ep,
3711 					bool *has_vendor_audio,
3712 					bool *has_video,
3713 					bool *has_dvb)
3714 {
3715 	const struct usb_endpoint_descriptor *e;
3716 	int sizedescr, size;
3717 
3718 	/*
3719 	 * NOTE:
3720 	 *
3721 	 * Old logic with support for isoc transfers only was:
3722 	 *  0x82	isoc		=> analog
3723 	 *  0x83	isoc		=> audio
3724 	 *  0x84	isoc		=> digital
3725 	 *
3726 	 * New logic with support for bulk transfers
3727 	 *  0x82	isoc		=> analog
3728 	 *  0x82	bulk		=> analog
3729 	 *  0x83	isoc*		=> audio
3730 	 *  0x84	isoc		=> digital
3731 	 *  0x84	bulk		=> analog or digital**
3732 	 *  0x85	isoc		=> digital TS2
3733 	 *  0x85	bulk		=> digital TS2
3734 	 * (*: audio should always be isoc)
3735 	 * (**: analog, if ep 0x82 is isoc, otherwise digital)
3736 	 *
3737 	 * The new logic preserves backwards compatibility and
3738 	 * reflects the endpoint configurations we have seen
3739 	 * so far. But there might be devices for which this
3740 	 * logic is not sufficient...
3741 	 */
3742 
3743 	e = &intf->altsetting[alt].endpoint[ep].desc;
3744 
3745 	if (!usb_endpoint_dir_in(e))
3746 		return;
3747 
3748 	sizedescr = le16_to_cpu(e->wMaxPacketSize);
3749 	size = sizedescr & 0x7ff;
3750 
3751 	if (udev->speed == USB_SPEED_HIGH)
3752 		size = size * hb_mult(sizedescr);
3753 
3754 	/* Only inspect input endpoints */
3755 
3756 	switch (e->bEndpointAddress) {
3757 	case 0x82:
3758 		*has_video = true;
3759 		if (usb_endpoint_xfer_isoc(e)) {
3760 			dev->analog_ep_isoc = e->bEndpointAddress;
3761 			dev->alt_max_pkt_size_isoc[alt] = size;
3762 		} else if (usb_endpoint_xfer_bulk(e)) {
3763 			dev->analog_ep_bulk = e->bEndpointAddress;
3764 		}
3765 		return;
3766 	case 0x83:
3767 		if (usb_endpoint_xfer_isoc(e))
3768 			*has_vendor_audio = true;
3769 		else
3770 			dev_err(&intf->dev,
3771 				"error: skipping audio endpoint 0x83, because it uses bulk transfers !\n");
3772 		return;
3773 	case 0x84:
3774 		if (*has_video && (usb_endpoint_xfer_bulk(e))) {
3775 			dev->analog_ep_bulk = e->bEndpointAddress;
3776 		} else {
3777 			if (usb_endpoint_xfer_isoc(e)) {
3778 				if (size > dev->dvb_max_pkt_size_isoc) {
3779 					/*
3780 					 * 2) some manufacturers (e.g. Terratec)
3781 					 * disable endpoints by setting
3782 					 * wMaxPacketSize to 0 bytes for all
3783 					 * alt settings. So far, we've seen
3784 					 * this for DVB isoc endpoints only.
3785 					 */
3786 					*has_dvb = true;
3787 					dev->dvb_ep_isoc = e->bEndpointAddress;
3788 					dev->dvb_max_pkt_size_isoc = size;
3789 					dev->dvb_alt_isoc = alt;
3790 				}
3791 			} else {
3792 				*has_dvb = true;
3793 				dev->dvb_ep_bulk = e->bEndpointAddress;
3794 			}
3795 		}
3796 		return;
3797 	case 0x85:
3798 		if (usb_endpoint_xfer_isoc(e)) {
3799 			if (size > dev->dvb_max_pkt_size_isoc_ts2) {
3800 				dev->dvb_ep_isoc_ts2 = e->bEndpointAddress;
3801 				dev->dvb_max_pkt_size_isoc_ts2 = size;
3802 				dev->dvb_alt_isoc = alt;
3803 			}
3804 		} else {
3805 			dev->dvb_ep_bulk_ts2 = e->bEndpointAddress;
3806 		}
3807 		return;
3808 	}
3809 }
3810 
3811 /*
3812  * em28xx_usb_probe()
3813  * checks for supported devices
3814  */
3815 static int em28xx_usb_probe(struct usb_interface *intf,
3816 			    const struct usb_device_id *id)
3817 {
3818 	struct usb_device *udev;
3819 	struct em28xx *dev = NULL;
3820 	int retval;
3821 	bool has_vendor_audio = false, has_video = false, has_dvb = false;
3822 	int i, nr, try_bulk;
3823 	const int ifnum = intf->altsetting[0].desc.bInterfaceNumber;
3824 	char *speed;
3825 
3826 	udev = usb_get_dev(interface_to_usbdev(intf));
3827 
3828 	/* Check to see next free device and mark as used */
3829 	do {
3830 		nr = find_first_zero_bit(em28xx_devused, EM28XX_MAXBOARDS);
3831 		if (nr >= EM28XX_MAXBOARDS) {
3832 			/* No free device slots */
3833 			dev_err(&intf->dev,
3834 				"Driver supports up to %i em28xx boards.\n",
3835 			       EM28XX_MAXBOARDS);
3836 			retval = -ENOMEM;
3837 			goto err_no_slot;
3838 		}
3839 	} while (test_and_set_bit(nr, em28xx_devused));
3840 
3841 	/* Don't register audio interfaces */
3842 	if (intf->altsetting[0].desc.bInterfaceClass == USB_CLASS_AUDIO) {
3843 		dev_info(&intf->dev,
3844 			"audio device (%04x:%04x): interface %i, class %i\n",
3845 			le16_to_cpu(udev->descriptor.idVendor),
3846 			le16_to_cpu(udev->descriptor.idProduct),
3847 			ifnum,
3848 			intf->altsetting[0].desc.bInterfaceClass);
3849 
3850 		retval = -ENODEV;
3851 		goto err;
3852 	}
3853 
3854 	/* allocate memory for our device state and initialize it */
3855 	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
3856 	if (!dev) {
3857 		retval = -ENOMEM;
3858 		goto err;
3859 	}
3860 
3861 	/* compute alternate max packet sizes */
3862 	dev->alt_max_pkt_size_isoc = kcalloc(intf->num_altsetting,
3863 					     sizeof(dev->alt_max_pkt_size_isoc[0]),
3864 					     GFP_KERNEL);
3865 	if (!dev->alt_max_pkt_size_isoc) {
3866 		kfree(dev);
3867 		retval = -ENOMEM;
3868 		goto err;
3869 	}
3870 
3871 	/* Get endpoints */
3872 	for (i = 0; i < intf->num_altsetting; i++) {
3873 		int ep;
3874 
3875 		for (ep = 0;
3876 		     ep < intf->altsetting[i].desc.bNumEndpoints;
3877 		     ep++)
3878 			em28xx_check_usb_descriptor(dev, udev, intf,
3879 						    i, ep,
3880 						    &has_vendor_audio,
3881 						    &has_video,
3882 						    &has_dvb);
3883 	}
3884 
3885 	if (!(has_vendor_audio || has_video || has_dvb)) {
3886 		retval = -ENODEV;
3887 		goto err_free;
3888 	}
3889 
3890 	switch (udev->speed) {
3891 	case USB_SPEED_LOW:
3892 		speed = "1.5";
3893 		break;
3894 	case USB_SPEED_UNKNOWN:
3895 	case USB_SPEED_FULL:
3896 		speed = "12";
3897 		break;
3898 	case USB_SPEED_HIGH:
3899 		speed = "480";
3900 		break;
3901 	default:
3902 		speed = "unknown";
3903 	}
3904 
3905 	dev_info(&intf->dev,
3906 		"New device %s %s @ %s Mbps (%04x:%04x, interface %d, class %d)\n",
3907 		udev->manufacturer ? udev->manufacturer : "",
3908 		udev->product ? udev->product : "",
3909 		speed,
3910 		le16_to_cpu(udev->descriptor.idVendor),
3911 		le16_to_cpu(udev->descriptor.idProduct),
3912 		ifnum,
3913 		intf->altsetting->desc.bInterfaceNumber);
3914 
3915 	/*
3916 	 * Make sure we have 480 Mbps of bandwidth, otherwise things like
3917 	 * video stream wouldn't likely work, since 12 Mbps is generally
3918 	 * not enough even for most Digital TV streams.
3919 	 */
3920 	if (udev->speed != USB_SPEED_HIGH && disable_usb_speed_check == 0) {
3921 		dev_err(&intf->dev, "Device initialization failed.\n");
3922 		dev_err(&intf->dev,
3923 			"Device must be connected to a high-speed USB 2.0 port.\n");
3924 		retval = -ENODEV;
3925 		goto err_free;
3926 	}
3927 
3928 	dev->devno = nr;
3929 	dev->model = id->driver_info;
3930 	dev->alt   = -1;
3931 	dev->is_audio_only = has_vendor_audio && !(has_video || has_dvb);
3932 	dev->has_video = has_video;
3933 	dev->ifnum = ifnum;
3934 
3935 	dev->ts = PRIMARY_TS;
3936 	snprintf(dev->name, 28, "em28xx");
3937 	dev->dev_next = NULL;
3938 
3939 	if (has_vendor_audio) {
3940 		dev_info(&intf->dev,
3941 			"Audio interface %i found (Vendor Class)\n", ifnum);
3942 		dev->usb_audio_type = EM28XX_USB_AUDIO_VENDOR;
3943 	}
3944 	/* Checks if audio is provided by a USB Audio Class intf */
3945 	for (i = 0; i < udev->config->desc.bNumInterfaces; i++) {
3946 		struct usb_interface *uif = udev->config->interface[i];
3947 
3948 		if (uif->altsetting[0].desc.bInterfaceClass == USB_CLASS_AUDIO) {
3949 			if (has_vendor_audio)
3950 				dev_err(&intf->dev,
3951 					"em28xx: device seems to have vendor AND usb audio class interfaces !\n"
3952 					"\t\tThe vendor interface will be ignored. Please contact the developers <linux-media@vger.kernel.org>\n");
3953 			dev->usb_audio_type = EM28XX_USB_AUDIO_CLASS;
3954 			break;
3955 		}
3956 	}
3957 
3958 	if (has_video)
3959 		dev_info(&intf->dev, "Video interface %i found:%s%s\n",
3960 			ifnum,
3961 			dev->analog_ep_bulk ? " bulk" : "",
3962 			dev->analog_ep_isoc ? " isoc" : "");
3963 	if (has_dvb)
3964 		dev_info(&intf->dev, "DVB interface %i found:%s%s\n",
3965 			ifnum,
3966 			dev->dvb_ep_bulk ? " bulk" : "",
3967 			dev->dvb_ep_isoc ? " isoc" : "");
3968 
3969 	dev->num_alt = intf->num_altsetting;
3970 
3971 	if ((unsigned int)card[nr] < em28xx_bcount)
3972 		dev->model = card[nr];
3973 
3974 	/* save our data pointer in this intf device */
3975 	usb_set_intfdata(intf, dev);
3976 
3977 	/* allocate device struct and check if the device is a webcam */
3978 	mutex_init(&dev->lock);
3979 	retval = em28xx_init_dev(dev, udev, intf, nr);
3980 	if (retval)
3981 		goto err_free;
3982 
3983 	if (usb_xfer_mode < 0) {
3984 		if (dev->is_webcam)
3985 			try_bulk = 1;
3986 		else
3987 			try_bulk = 0;
3988 	} else {
3989 		try_bulk = usb_xfer_mode > 0;
3990 	}
3991 
3992 	/* Disable V4L2 if the device doesn't have a decoder or image sensor */
3993 	if (has_video &&
3994 	    dev->board.decoder == EM28XX_NODECODER &&
3995 	    dev->em28xx_sensor == EM28XX_NOSENSOR) {
3996 		dev_err(&intf->dev,
3997 			"Currently, V4L2 is not supported on this model\n");
3998 		has_video = false;
3999 		dev->has_video = false;
4000 	}
4001 
4002 	if (dev->board.has_dual_ts &&
4003 	    (dev->tuner_type != TUNER_ABSENT || INPUT(0)->type)) {
4004 		/*
4005 		 * The logic with sets alternate is not ready for dual-tuners
4006 		 * which analog modes.
4007 		 */
4008 		dev_err(&intf->dev,
4009 			"We currently don't support analog TV or stream capture on dual tuners.\n");
4010 		has_video = false;
4011 	}
4012 
4013 	/* Select USB transfer types to use */
4014 	if (has_video) {
4015 		if (!dev->analog_ep_isoc || (try_bulk && dev->analog_ep_bulk))
4016 			dev->analog_xfer_bulk = 1;
4017 		dev_info(&intf->dev, "analog set to %s mode.\n",
4018 			dev->analog_xfer_bulk ? "bulk" : "isoc");
4019 	}
4020 	if (has_dvb) {
4021 		if (!dev->dvb_ep_isoc || (try_bulk && dev->dvb_ep_bulk))
4022 			dev->dvb_xfer_bulk = 1;
4023 		dev_info(&intf->dev, "dvb set to %s mode.\n",
4024 			dev->dvb_xfer_bulk ? "bulk" : "isoc");
4025 	}
4026 
4027 	if (dev->board.has_dual_ts && em28xx_duplicate_dev(dev) == 0) {
4028 		dev->dev_next->ts = SECONDARY_TS;
4029 		dev->dev_next->alt   = -1;
4030 		dev->dev_next->is_audio_only = has_vendor_audio &&
4031 						!(has_video || has_dvb);
4032 		dev->dev_next->has_video = false;
4033 		dev->dev_next->ifnum = ifnum;
4034 		dev->dev_next->model = id->driver_info;
4035 
4036 		mutex_init(&dev->dev_next->lock);
4037 		retval = em28xx_init_dev(dev->dev_next, udev, intf,
4038 					 dev->dev_next->devno);
4039 		if (retval)
4040 			goto err_free;
4041 
4042 		dev->dev_next->board.ir_codes = NULL; /* No IR for 2nd tuner */
4043 		dev->dev_next->board.has_ir_i2c = 0; /* No IR for 2nd tuner */
4044 
4045 		if (usb_xfer_mode < 0) {
4046 			if (dev->dev_next->is_webcam)
4047 				try_bulk = 1;
4048 			else
4049 				try_bulk = 0;
4050 		} else {
4051 			try_bulk = usb_xfer_mode > 0;
4052 		}
4053 
4054 		/* Select USB transfer types to use */
4055 		if (has_dvb) {
4056 			if (!dev->dvb_ep_isoc_ts2 ||
4057 			    (try_bulk && dev->dvb_ep_bulk_ts2))
4058 				dev->dev_next->dvb_xfer_bulk = 1;
4059 			dev_info(&dev->intf->dev, "dvb ts2 set to %s mode.\n",
4060 				 dev->dev_next->dvb_xfer_bulk ? "bulk" : "isoc");
4061 		}
4062 
4063 		dev->dev_next->dvb_ep_isoc = dev->dvb_ep_isoc_ts2;
4064 		dev->dev_next->dvb_ep_bulk = dev->dvb_ep_bulk_ts2;
4065 		dev->dev_next->dvb_max_pkt_size_isoc = dev->dvb_max_pkt_size_isoc_ts2;
4066 		dev->dev_next->dvb_alt_isoc = dev->dvb_alt_isoc;
4067 
4068 		/* Configure hardware to support TS2*/
4069 		if (dev->dvb_xfer_bulk) {
4070 			/* The ep4 and ep5 are configured for BULK */
4071 			em28xx_write_reg(dev, 0x0b, 0x96);
4072 			mdelay(100);
4073 			em28xx_write_reg(dev, 0x0b, 0x80);
4074 			mdelay(100);
4075 		} else {
4076 			/* The ep4 and ep5 are configured for ISO */
4077 			em28xx_write_reg(dev, 0x0b, 0x96);
4078 			mdelay(100);
4079 			em28xx_write_reg(dev, 0x0b, 0x82);
4080 			mdelay(100);
4081 		}
4082 
4083 		kref_init(&dev->dev_next->ref);
4084 	}
4085 
4086 	kref_init(&dev->ref);
4087 
4088 	request_modules(dev);
4089 
4090 	/*
4091 	 * Do it at the end, to reduce dynamic configuration changes during
4092 	 * the device init. Yet, as request_modules() can be async, the
4093 	 * topology will likely change after the load of the em28xx subdrivers.
4094 	 */
4095 #ifdef CONFIG_MEDIA_CONTROLLER
4096 	retval = media_device_register(dev->media_dev);
4097 #endif
4098 
4099 	return 0;
4100 
4101 err_free:
4102 	kfree(dev->alt_max_pkt_size_isoc);
4103 	kfree(dev);
4104 
4105 err:
4106 	clear_bit(nr, em28xx_devused);
4107 
4108 err_no_slot:
4109 	usb_put_dev(udev);
4110 	return retval;
4111 }
4112 
4113 /*
4114  * em28xx_usb_disconnect()
4115  * called when the device gets disconnected
4116  * video device will be unregistered on v4l2_close in case it is still open
4117  */
4118 static void em28xx_usb_disconnect(struct usb_interface *intf)
4119 {
4120 	struct em28xx *dev;
4121 
4122 	dev = usb_get_intfdata(intf);
4123 	usb_set_intfdata(intf, NULL);
4124 
4125 	if (!dev)
4126 		return;
4127 
4128 	if (dev->dev_next) {
4129 		dev->dev_next->disconnected = 1;
4130 		dev_info(&dev->intf->dev, "Disconnecting %s\n",
4131 			 dev->dev_next->name);
4132 	}
4133 
4134 	dev->disconnected = 1;
4135 
4136 	dev_info(&dev->intf->dev, "Disconnecting %s\n", dev->name);
4137 
4138 	flush_request_modules(dev);
4139 
4140 	em28xx_close_extension(dev);
4141 
4142 	if (dev->dev_next)
4143 		em28xx_release_resources(dev->dev_next);
4144 	em28xx_release_resources(dev);
4145 
4146 	if (dev->dev_next) {
4147 		kref_put(&dev->dev_next->ref, em28xx_free_device);
4148 		dev->dev_next = NULL;
4149 	}
4150 	kref_put(&dev->ref, em28xx_free_device);
4151 }
4152 
4153 static int em28xx_usb_suspend(struct usb_interface *intf,
4154 			      pm_message_t message)
4155 {
4156 	struct em28xx *dev;
4157 
4158 	dev = usb_get_intfdata(intf);
4159 	if (!dev)
4160 		return 0;
4161 	em28xx_suspend_extension(dev);
4162 	return 0;
4163 }
4164 
4165 static int em28xx_usb_resume(struct usb_interface *intf)
4166 {
4167 	struct em28xx *dev;
4168 
4169 	dev = usb_get_intfdata(intf);
4170 	if (!dev)
4171 		return 0;
4172 	em28xx_resume_extension(dev);
4173 	return 0;
4174 }
4175 
4176 static struct usb_driver em28xx_usb_driver = {
4177 	.name = "em28xx",
4178 	.probe = em28xx_usb_probe,
4179 	.disconnect = em28xx_usb_disconnect,
4180 	.suspend = em28xx_usb_suspend,
4181 	.resume = em28xx_usb_resume,
4182 	.reset_resume = em28xx_usb_resume,
4183 	.id_table = em28xx_id_table,
4184 };
4185 
4186 module_usb_driver(em28xx_usb_driver);
4187