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