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