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