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