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