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