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