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