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