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