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 "em28xx.h"
27 
28 #include <linux/init.h>
29 #include <linux/module.h>
30 #include <linux/slab.h>
31 #include <linux/delay.h>
32 #include <linux/i2c.h>
33 #include <linux/usb.h>
34 #include <media/tuner.h>
35 #include <media/drv-intf/msp3400.h>
36 #include <media/i2c/saa7115.h>
37 #include <dt-bindings/media/tvp5150.h>
38 #include <media/i2c/tvaudio.h>
39 #include <media/i2c-addr.h>
40 #include <media/tveeprom.h>
41 #include <media/v4l2-common.h>
42 #include <sound/ac97_codec.h>
43 
44 
45 #define DRIVER_NAME         "em28xx"
46 
47 static int tuner = -1;
48 module_param(tuner, int, 0444);
49 MODULE_PARM_DESC(tuner, "tuner type");
50 
51 static unsigned int disable_ir;
52 module_param(disable_ir, int, 0444);
53 MODULE_PARM_DESC(disable_ir, "disable infrared remote support");
54 
55 static unsigned int disable_usb_speed_check;
56 module_param(disable_usb_speed_check, int, 0444);
57 MODULE_PARM_DESC(disable_usb_speed_check,
58 		 "override min bandwidth requirement of 480M bps");
59 
60 static unsigned int card[]     = {[0 ... (EM28XX_MAXBOARDS - 1)] = -1U };
61 module_param_array(card,  int, NULL, 0444);
62 MODULE_PARM_DESC(card,     "card type");
63 
64 static int usb_xfer_mode = -1;
65 module_param(usb_xfer_mode, int, 0444);
66 MODULE_PARM_DESC(usb_xfer_mode,
67 		 "USB transfer mode for frame data (-1 = auto, 0 = prefer isoc, 1 = prefer bulk)");
68 
69 /* Bitmask marking allocated devices from 0 to EM28XX_MAXBOARDS - 1 */
70 static DECLARE_BITMAP(em28xx_devused, EM28XX_MAXBOARDS);
71 
72 struct em28xx_hash_table {
73 	unsigned long hash;
74 	unsigned int  model;
75 	unsigned int  tuner;
76 };
77 
78 static void em28xx_pre_card_setup(struct em28xx *dev);
79 
80 /*
81  *  Reset sequences for analog/digital modes
82  */
83 
84 /* Reset for the most [analog] boards */
85 static struct em28xx_reg_seq default_analog[] = {
86 	{EM2820_R08_GPIO_CTRL,	0x6d,   ~EM_GPIO_4,	10},
87 	{	-1,		-1,	-1,		-1},
88 };
89 
90 /* Reset for the most [digital] boards */
91 static struct em28xx_reg_seq default_digital[] = {
92 	{EM2820_R08_GPIO_CTRL,	0x6e,	~EM_GPIO_4,	10},
93 	{	-1,		-1,	-1,		-1},
94 };
95 
96 /* Board Hauppauge WinTV HVR 900 analog */
97 static struct em28xx_reg_seq hauppauge_wintv_hvr_900_analog[] = {
98 	{EM2820_R08_GPIO_CTRL,	0x2d,	~EM_GPIO_4,	10},
99 	{	0x05,		0xff,	0x10,		10},
100 	{	-1,		-1,	-1,		-1},
101 };
102 
103 /* Board Hauppauge WinTV HVR 900 digital */
104 static struct em28xx_reg_seq hauppauge_wintv_hvr_900_digital[] = {
105 	{EM2820_R08_GPIO_CTRL,	0x2e,	~EM_GPIO_4,	10},
106 	{EM2880_R04_GPO,	0x04,	0x0f,		10},
107 	{EM2880_R04_GPO,	0x0c,	0x0f,		10},
108 	{	-1,		-1,	-1,		-1},
109 };
110 
111 /* Board Hauppauge WinTV HVR 900 (R2) digital */
112 static struct em28xx_reg_seq hauppauge_wintv_hvr_900R2_digital[] = {
113 	{EM2820_R08_GPIO_CTRL,	0x2e,	~EM_GPIO_4,	10},
114 	{EM2880_R04_GPO,	0x0c,	0x0f,		10},
115 	{	-1,		-1,	-1,		-1},
116 };
117 
118 /* Boards - EM2880 MSI DIGIVOX AD and EM2880_BOARD_MSI_DIGIVOX_AD_II */
119 static struct em28xx_reg_seq em2880_msi_digivox_ad_analog[] = {
120 	{EM2820_R08_GPIO_CTRL,	0x69,   ~EM_GPIO_4,	10},
121 	{	-1,		-1,	-1,		-1},
122 };
123 
124 /* Boards - EM2880 MSI DIGIVOX AD and EM2880_BOARD_MSI_DIGIVOX_AD_II */
125 
126 /* Board  - EM2870 Kworld 355u
127    Analog - No input analog */
128 
129 /* Board - EM2882 Kworld 315U digital */
130 static struct em28xx_reg_seq em2882_kworld_315u_digital[] = {
131 	{EM2820_R08_GPIO_CTRL,	0xff,	0xff,		10},
132 	{EM2820_R08_GPIO_CTRL,	0xfe,	0xff,		10},
133 	{EM2880_R04_GPO,	0x04,	0xff,		10},
134 	{EM2880_R04_GPO,	0x0c,	0xff,		10},
135 	{EM2820_R08_GPIO_CTRL,	0x7e,	0xff,		10},
136 	{	-1,		-1,	-1,		-1},
137 };
138 
139 static struct em28xx_reg_seq em2882_kworld_315u_tuner_gpio[] = {
140 	{EM2880_R04_GPO,	0x08,	0xff,		10},
141 	{EM2880_R04_GPO,	0x0c,	0xff,		10},
142 	{EM2880_R04_GPO,	0x08,	0xff,		10},
143 	{EM2880_R04_GPO,	0x0c,	0xff,		10},
144 	{	-1,		-1,	-1,		-1},
145 };
146 
147 static struct em28xx_reg_seq kworld_330u_analog[] = {
148 	{EM2820_R08_GPIO_CTRL,	0x6d,	~EM_GPIO_4,	10},
149 	{EM2880_R04_GPO,	0x00,	0xff,		10},
150 	{	-1,		-1,	-1,		-1},
151 };
152 
153 static struct em28xx_reg_seq kworld_330u_digital[] = {
154 	{EM2820_R08_GPIO_CTRL,	0x6e,	~EM_GPIO_4,	10},
155 	{EM2880_R04_GPO,	0x08,	0xff,		10},
156 	{	-1,		-1,	-1,		-1},
157 };
158 
159 /* Evga inDtube
160    GPIO0 - Enable digital power (s5h1409) - low to enable
161    GPIO1 - Enable analog power (tvp5150/emp202) - low to enable
162    GPIO4 - xc3028 reset
163    GOP3  - s5h1409 reset
164  */
165 static struct em28xx_reg_seq evga_indtube_analog[] = {
166 	{EM2820_R08_GPIO_CTRL,	0x79,   0xff,		60},
167 	{	-1,		-1,	-1,		-1},
168 };
169 
170 static struct em28xx_reg_seq evga_indtube_digital[] = {
171 	{EM2820_R08_GPIO_CTRL,	0x7a,	0xff,		 1},
172 	{EM2880_R04_GPO,	0x04,	0xff,		10},
173 	{EM2880_R04_GPO,	0x0c,	0xff,		 1},
174 	{	-1,		-1,	-1,		-1},
175 };
176 
177 /*
178  * KWorld PlusTV 340U, UB435-Q and UB435-Q V2 (ATSC) GPIOs map:
179  * EM_GPIO_0 - currently unknown
180  * EM_GPIO_1 - LED disable/enable (1 = off, 0 = on)
181  * EM_GPIO_2 - currently unknown
182  * EM_GPIO_3 - currently unknown
183  * EM_GPIO_4 - TDA18271HD/C1 tuner (1 = active, 0 = in reset)
184  * EM_GPIO_5 - LGDT3304 ATSC/QAM demod (1 = active, 0 = in reset)
185  * EM_GPIO_6 - currently unknown
186  * EM_GPIO_7 - currently unknown
187  */
188 static struct em28xx_reg_seq kworld_a340_digital[] = {
189 	{EM2820_R08_GPIO_CTRL,	0x6d,	~EM_GPIO_4,	10},
190 	{	-1,		-1,	-1,		-1},
191 };
192 
193 static struct em28xx_reg_seq kworld_ub435q_v3_digital[] = {
194 	{EM2874_R80_GPIO_P0_CTRL,	0xff,	0xff,	100},
195 	{EM2874_R80_GPIO_P0_CTRL,	0xfe,	0xff,	100},
196 	{EM2874_R80_GPIO_P0_CTRL,	0xbe,	0xff,	100},
197 	{EM2874_R80_GPIO_P0_CTRL,	0xfe,	0xff,	100},
198 	{	-1,			-1,	-1,	-1},
199 };
200 
201 /* Pinnacle Hybrid Pro eb1a:2881 */
202 static struct em28xx_reg_seq pinnacle_hybrid_pro_analog[] = {
203 	{EM2820_R08_GPIO_CTRL,	0xfd,   ~EM_GPIO_4,	10},
204 	{	-1,		-1,	-1,		-1},
205 };
206 
207 static struct em28xx_reg_seq pinnacle_hybrid_pro_digital[] = {
208 	{EM2820_R08_GPIO_CTRL,	0x6e,	~EM_GPIO_4,	10},
209 	{EM2880_R04_GPO,	0x04,	0xff,	       100},/* zl10353 reset */
210 	{EM2880_R04_GPO,	0x0c,	0xff,		 1},
211 	{	-1,		-1,	-1,		-1},
212 };
213 
214 static struct em28xx_reg_seq terratec_cinergy_USB_XS_FR_analog[] = {
215 	{EM2820_R08_GPIO_CTRL,	0x6d,	~EM_GPIO_4,	10},
216 	{EM2880_R04_GPO,	0x00,	0xff,		10},
217 	{	-1,		-1,	-1,		-1},
218 };
219 
220 static struct em28xx_reg_seq terratec_cinergy_USB_XS_FR_digital[] = {
221 	{EM2820_R08_GPIO_CTRL,	0x6e,	~EM_GPIO_4,	10},
222 	{EM2880_R04_GPO,	0x08,	0xff,		10},
223 	{	-1,		-1,	-1,		-1},
224 };
225 
226 /* PCTV HD Mini (80e) GPIOs
227    0-5: not used
228    6:   demod reset, active low
229    7:   LED on, active high */
230 static struct em28xx_reg_seq em2874_pctv_80e_digital[] = {
231 	{EM28XX_R06_I2C_CLK,    0x45,   0xff,		  10}, /*400 KHz*/
232 	{EM2874_R80_GPIO_P0_CTRL, 0x00,   0xff,		  100},/*Demod reset*/
233 	{EM2874_R80_GPIO_P0_CTRL, 0x40,   0xff,		  10},
234 	{  -1,			-1,	-1,		  -1},
235 };
236 
237 /* eb1a:2868 Reddo DVB-C USB TV Box
238    GPIO4 - CU1216L NIM
239    Other GPIOs seems to be don't care. */
240 static struct em28xx_reg_seq reddo_dvb_c_usb_box[] = {
241 	{EM2820_R08_GPIO_CTRL,	0xfe,	0xff,		10},
242 	{EM2820_R08_GPIO_CTRL,	0xde,	0xff,		10},
243 	{EM2820_R08_GPIO_CTRL,	0xfe,	0xff,		10},
244 	{EM2820_R08_GPIO_CTRL,	0xff,	0xff,		10},
245 	{EM2820_R08_GPIO_CTRL,	0x7f,	0xff,		10},
246 	{EM2820_R08_GPIO_CTRL,	0x6f,	0xff,		10},
247 	{EM2820_R08_GPIO_CTRL,	0xff,	0xff,		10},
248 	{	-1,		-1,	-1,		-1},
249 };
250 
251 /* Callback for the most boards */
252 static struct em28xx_reg_seq default_tuner_gpio[] = {
253 	{EM2820_R08_GPIO_CTRL,	EM_GPIO_4,	EM_GPIO_4,	10},
254 	{EM2820_R08_GPIO_CTRL,	0,		EM_GPIO_4,	10},
255 	{EM2820_R08_GPIO_CTRL,	EM_GPIO_4,	EM_GPIO_4,	10},
256 	{	-1,		-1,		-1,		-1},
257 };
258 
259 /* Mute/unmute */
260 static struct em28xx_reg_seq compro_unmute_tv_gpio[] = {
261 	{EM2820_R08_GPIO_CTRL,	5,	7,	10},
262 	{	-1,		-1,	-1,	-1},
263 };
264 
265 static struct em28xx_reg_seq compro_unmute_svid_gpio[] = {
266 	{EM2820_R08_GPIO_CTRL,	4,	7,	10},
267 	{	-1,		-1,	-1,	-1},
268 };
269 
270 static struct em28xx_reg_seq compro_mute_gpio[] = {
271 	{EM2820_R08_GPIO_CTRL,	6,	7,	10},
272 	{	-1,		-1,	-1,	-1},
273 };
274 
275 /* Terratec AV350 */
276 static struct em28xx_reg_seq terratec_av350_mute_gpio[] = {
277 	{EM2820_R08_GPIO_CTRL,	0xff,	0x7f,		10},
278 	{	-1,		-1,	-1,		-1},
279 };
280 
281 static struct em28xx_reg_seq terratec_av350_unmute_gpio[] = {
282 	{EM2820_R08_GPIO_CTRL,	0xff,	0xff,		10},
283 	{	-1,		-1,	-1,		-1},
284 };
285 
286 static struct em28xx_reg_seq silvercrest_reg_seq[] = {
287 	{EM2820_R08_GPIO_CTRL,	0xff,	0xff,		10},
288 	{EM2820_R08_GPIO_CTRL,	0x01,	0xf7,		10},
289 	{	-1,		-1,	-1,		-1},
290 };
291 
292 static struct em28xx_reg_seq vc211a_enable[] = {
293 	{EM2820_R08_GPIO_CTRL,	0xff,	0x07,		10},
294 	{EM2820_R08_GPIO_CTRL,	0xff,	0x0f,		10},
295 	{EM2820_R08_GPIO_CTRL,	0xff,	0x0b,		10},
296 	{	-1,		-1,	-1,		-1},
297 };
298 
299 static struct em28xx_reg_seq dikom_dk300_digital[] = {
300 	{EM2820_R08_GPIO_CTRL,	0x6e,	~EM_GPIO_4,	10},
301 	{EM2880_R04_GPO,	0x08,	0xff,		10},
302 	{	-1,		-1,	-1,		-1},
303 };
304 
305 /* Reset for the most [digital] boards */
306 static struct em28xx_reg_seq leadership_digital[] = {
307 	{EM2874_R80_GPIO_P0_CTRL,	0x70,	0xff,	10},
308 	{	-1,			-1,	-1,	-1},
309 };
310 
311 static struct em28xx_reg_seq leadership_reset[] = {
312 	{EM2874_R80_GPIO_P0_CTRL,	0xf0,	0xff,	10},
313 	{EM2874_R80_GPIO_P0_CTRL,	0xb0,	0xff,	10},
314 	{EM2874_R80_GPIO_P0_CTRL,	0xf0,	0xff,	10},
315 	{	-1,			-1,	-1,	-1},
316 };
317 
318 /* 2013:024f PCTV nanoStick T2 290e
319  * GPIO_6 - demod reset
320  * GPIO_7 - LED
321  */
322 static struct em28xx_reg_seq pctv_290e[] = {
323 	{EM2874_R80_GPIO_P0_CTRL,	0x00,	0xff,	80},
324 	{EM2874_R80_GPIO_P0_CTRL,	0x40,	0xff,	80}, /* GPIO_6 = 1 */
325 	{EM2874_R80_GPIO_P0_CTRL,	0xc0,	0xff,	80}, /* GPIO_7 = 1 */
326 	{	-1,			-1,	-1,	-1},
327 };
328 
329 #if 0
330 static struct em28xx_reg_seq terratec_h5_gpio[] = {
331 	{EM2820_R08_GPIO_CTRL,		0xff,	0xff,	10},
332 	{EM2874_R80_GPIO_P0_CTRL,	0xf6,	0xff,	100},
333 	{EM2874_R80_GPIO_P0_CTRL,	0xf2,	0xff,	50},
334 	{EM2874_R80_GPIO_P0_CTRL,	0xf6,	0xff,	50},
335 	{	-1,			-1,	-1,	-1},
336 };
337 
338 static struct em28xx_reg_seq terratec_h5_digital[] = {
339 	{EM2874_R80_GPIO_P0_CTRL,	0xf6,	0xff,	10},
340 	{EM2874_R80_GPIO_P0_CTRL,	0xe6,	0xff,	100},
341 	{EM2874_R80_GPIO_P0_CTRL,	0xa6,	0xff,	10},
342 	{	-1,			-1,	-1,	-1},
343 };
344 #endif
345 
346 /* 2013:024f PCTV DVB-S2 Stick 460e
347  * GPIO_0 - POWER_ON
348  * GPIO_1 - BOOST
349  * GPIO_2 - VUV_LNB (red LED)
350  * GPIO_3 - EXT_12V
351  * GPIO_4 - INT_DEM (DEMOD GPIO_0)
352  * GPIO_5 - INT_LNB
353  * GPIO_6 - RESET_DEM
354  * GPIO_7 - LED (green LED)
355  */
356 static struct em28xx_reg_seq pctv_460e[] = {
357 	{EM2874_R80_GPIO_P0_CTRL,	0x01,	0xff,	50},
358 	{	0x0d,			0xff,	0xff,	50},
359 	{EM2874_R80_GPIO_P0_CTRL,	0x41,	0xff,	50}, /* GPIO_6=1 */
360 	{	0x0d,			0x42,	0xff,	50},
361 	{EM2874_R80_GPIO_P0_CTRL,	0x61,	0xff,	50}, /* GPIO_5=1 */
362 	{	-1,			-1,	-1,	-1},
363 };
364 
365 static struct em28xx_reg_seq c3tech_digital_duo_digital[] = {
366 	{EM2874_R80_GPIO_P0_CTRL,	0xff,	0xff,	10},
367 	{EM2874_R80_GPIO_P0_CTRL,	0xfd,	0xff,	10}, /* xc5000 reset */
368 	{EM2874_R80_GPIO_P0_CTRL,	0xf9,	0xff,	35},
369 	{EM2874_R80_GPIO_P0_CTRL,	0xfd,	0xff,	10},
370 	{EM2874_R80_GPIO_P0_CTRL,	0xff,	0xff,	10},
371 	{EM2874_R80_GPIO_P0_CTRL,	0xfe,	0xff,	10},
372 	{EM2874_R80_GPIO_P0_CTRL,	0xbe,	0xff,	10},
373 	{EM2874_R80_GPIO_P0_CTRL,	0xfe,	0xff,	20},
374 	{	-1,			-1,	-1,	-1},
375 };
376 
377 /*
378  * 2013:0258 PCTV DVB-S2 Stick (461e)
379  * GPIO 0 = POWER_ON
380  * GPIO 1 = BOOST
381  * GPIO 2 = VUV_LNB (red LED)
382  * GPIO 3 = #EXT_12V
383  * GPIO 4 = INT_DEM
384  * GPIO 5 = INT_LNB
385  * GPIO 6 = #RESET_DEM
386  * GPIO 7 = P07_LED (green LED)
387  */
388 static struct em28xx_reg_seq pctv_461e[] = {
389 	{EM2874_R80_GPIO_P0_CTRL,      0x7f, 0xff,    0},
390 	{0x0d,                 0xff, 0xff,    0},
391 	{EM2874_R80_GPIO_P0_CTRL,      0x3f, 0xff,  100}, /* reset demod */
392 	{EM2874_R80_GPIO_P0_CTRL,      0x7f, 0xff,  200}, /* reset demod */
393 	{0x0d,                 0x42, 0xff,    0},
394 	{EM2874_R80_GPIO_P0_CTRL,      0xeb, 0xff,    0},
395 	{EM2874_R5F_TS_ENABLE, 0x84, 0x84,    0}, /* parallel? | null discard */
396 	{                  -1,   -1,   -1,   -1},
397 };
398 
399 #if 0
400 static struct em28xx_reg_seq hauppauge_930c_gpio[] = {
401 	{EM2874_R80_GPIO_P0_CTRL,	0x6f,	0xff,	10},
402 	{EM2874_R80_GPIO_P0_CTRL,	0x4f,	0xff,	10}, /* xc5000 reset */
403 	{EM2874_R80_GPIO_P0_CTRL,	0x6f,	0xff,	10},
404 	{EM2874_R80_GPIO_P0_CTRL,	0x4f,	0xff,	10},
405 	{	-1,			-1,	-1,	-1},
406 };
407 
408 static struct em28xx_reg_seq hauppauge_930c_digital[] = {
409 	{EM2874_R80_GPIO_P0_CTRL,	0xf6,	0xff,	10},
410 	{EM2874_R80_GPIO_P0_CTRL,	0xe6,	0xff,	100},
411 	{EM2874_R80_GPIO_P0_CTRL,	0xa6,	0xff,	10},
412 	{	-1,			-1,	-1,	-1},
413 };
414 #endif
415 
416 /* 1b80:e425 MaxMedia UB425-TC
417  * 1b80:e1cc Delock 61959
418  * GPIO_6 - demod reset, 0=active
419  * GPIO_7 - LED, 0=active
420  */
421 static struct em28xx_reg_seq maxmedia_ub425_tc[] = {
422 	{EM2874_R80_GPIO_P0_CTRL,	0x83,	0xff,	100},
423 	{EM2874_R80_GPIO_P0_CTRL,	0xc3,	0xff,	100}, /* GPIO_6 = 1 */
424 	{EM2874_R80_GPIO_P0_CTRL,	0x43,	0xff,	000}, /* GPIO_7 = 0 */
425 	{	-1,			-1,	-1,	-1},
426 };
427 
428 /* 2304:0242 PCTV QuatroStick (510e)
429  * GPIO_2: decoder reset, 0=active
430  * GPIO_4: decoder suspend, 0=active
431  * GPIO_6: demod reset, 0=active
432  * GPIO_7: LED, 1=active
433  */
434 static struct em28xx_reg_seq pctv_510e[] = {
435 	{EM2874_R80_GPIO_P0_CTRL,	0x10,	0xff,	100},
436 	{EM2874_R80_GPIO_P0_CTRL,	0x14,	0xff,	100}, /* GPIO_2 = 1 */
437 	{EM2874_R80_GPIO_P0_CTRL,	0x54,	0xff,	050}, /* GPIO_6 = 1 */
438 	{	-1,			-1,	-1,	-1},
439 };
440 
441 /* 2013:0251 PCTV QuatroStick nano (520e)
442  * GPIO_2: decoder reset, 0=active
443  * GPIO_4: decoder suspend, 0=active
444  * GPIO_6: demod reset, 0=active
445  * GPIO_7: LED, 1=active
446  */
447 static struct em28xx_reg_seq pctv_520e[] = {
448 	{EM2874_R80_GPIO_P0_CTRL,	0x10,	0xff,	100},
449 	{EM2874_R80_GPIO_P0_CTRL,	0x14,	0xff,	100}, /* GPIO_2 = 1 */
450 	{EM2874_R80_GPIO_P0_CTRL,	0x54,	0xff,	050}, /* GPIO_6 = 1 */
451 	{EM2874_R80_GPIO_P0_CTRL,	0xd4,	0xff,	000}, /* GPIO_7 = 1 */
452 	{	-1,			-1,	-1,	-1},
453 };
454 
455 /* 1ae7:9003/9004 SpeedLink Vicious And Devine Laplace webcam
456  * reg 0x80/0x84:
457  * GPIO_0: capturing LED, 0=on, 1=off
458  * GPIO_2: AV mute button, 0=pressed, 1=unpressed
459  * GPIO 3: illumination button, 0=pressed, 1=unpressed
460  * GPIO_6: illumination/flash LED, 0=on, 1=off
461  * reg 0x81/0x85:
462  * GPIO_7: snapshot button, 0=pressed, 1=unpressed
463  */
464 static struct em28xx_reg_seq speedlink_vad_laplace_reg_seq[] = {
465 	{EM2820_R08_GPIO_CTRL,		0xf7,	0xff,	10},
466 	{EM2874_R80_GPIO_P0_CTRL,	0xff,	0xb2,	10},
467 	{	-1,			-1,	-1,	-1},
468 };
469 
470 static struct em28xx_reg_seq pctv_292e[] = {
471 	{EM2874_R80_GPIO_P0_CTRL,      0xff, 0xff,      0},
472 	{0x0d,                         0xff, 0xff,    950},
473 	{EM2874_R80_GPIO_P0_CTRL,      0xbd, 0xff,    100},
474 	{EM2874_R80_GPIO_P0_CTRL,      0xfd, 0xff,    410},
475 	{EM2874_R80_GPIO_P0_CTRL,      0x7d, 0xff,    300},
476 	{EM2874_R80_GPIO_P0_CTRL,      0x7c, 0xff,     60},
477 	{0x0d,                         0x42, 0xff,     50},
478 	{EM2874_R5F_TS_ENABLE,         0x85, 0xff,      0},
479 	{-1,                             -1,   -1,     -1},
480 };
481 
482 static struct em28xx_reg_seq terratec_t2_stick_hd[] = {
483 	{EM2874_R80_GPIO_P0_CTRL,	0xff,	0xff,	0},
484 	{0x0d,				0xff,	0xff,	600},
485 	{EM2874_R80_GPIO_P0_CTRL,	0xfc,	0xff,	10},
486 	{EM2874_R80_GPIO_P0_CTRL,	0xbc,	0xff,	100},
487 	{EM2874_R80_GPIO_P0_CTRL,	0xfc,	0xff,	100},
488 	{EM2874_R80_GPIO_P0_CTRL,	0x00,	0xff,	300},
489 	{EM2874_R80_GPIO_P0_CTRL,	0xf8,	0xff,	100},
490 	{EM2874_R80_GPIO_P0_CTRL,	0xfc,	0xff,	300},
491 	{0x0d,				0x42,	0xff,	1000},
492 	{EM2874_R5F_TS_ENABLE,		0x85,	0xff,	0},
493 	{-1,                             -1,   -1,     -1},
494 };
495 
496 static struct em28xx_reg_seq plex_px_bcud[] = {
497 	{EM2874_R80_GPIO_P0_CTRL,	0xff,	0xff,	0},
498 	{0x0d,				0xff,	0xff,	0},
499 	{EM2874_R50_IR_CONFIG,		0x01,	0xff,	0},
500 	{EM28XX_R06_I2C_CLK,		0x40,	0xff,	0},
501 	{EM2874_R80_GPIO_P0_CTRL,	0xfd,	0xff,	100},
502 	{EM28XX_R12_VINENABLE,		0x20,	0x20,	0},
503 	{0x0d,				0x42,	0xff,	1000},
504 	{EM2874_R80_GPIO_P0_CTRL,	0xfc,	0xff,	10},
505 	{EM2874_R80_GPIO_P0_CTRL,	0xfd,	0xff,	10},
506 	{0x73,				0xfd,	0xff,	100},
507 	{-1,				-1,	-1,	-1},
508 };
509 
510 /*
511  * 2040:0265 Hauppauge WinTV-dualHD DVB
512  * reg 0x80/0x84:
513  * GPIO_0: Yellow LED tuner 1, 0=on, 1=off
514  * GPIO_1: Green LED tuner 1, 0=on, 1=off
515  * GPIO_2: Yellow LED tuner 2, 0=on, 1=off
516  * GPIO_3: Green LED tuner 2, 0=on, 1=off
517  * GPIO_5: Reset #2, 0=active
518  * GPIO_6: Reset #1, 0=active
519  */
520 static struct em28xx_reg_seq hauppauge_dualhd_dvb[] = {
521 	{EM2874_R80_GPIO_P0_CTRL,      0xff, 0xff,      0},
522 	{0x0d,                         0xff, 0xff,    200},
523 	{0x50,                         0x04, 0xff,    300},
524 	{EM2874_R80_GPIO_P0_CTRL,      0xbf, 0xff,    100}, /* demod 1 reset */
525 	{EM2874_R80_GPIO_P0_CTRL,      0xff, 0xff,    100},
526 	{EM2874_R80_GPIO_P0_CTRL,      0xdf, 0xff,    100}, /* demod 2 reset */
527 	{EM2874_R80_GPIO_P0_CTRL,      0xff, 0xff,    100},
528 	{EM2874_R5F_TS_ENABLE,         0x44, 0xff,     50},
529 	{EM2874_R5D_TS1_PKT_SIZE,      0x05, 0xff,     50},
530 	{EM2874_R5E_TS2_PKT_SIZE,      0x05, 0xff,     50},
531 	{-1,                             -1,   -1,     -1},
532 };
533 
534 /*
535  *  Button definitions
536  */
537 static struct em28xx_button std_snapshot_button[] = {
538 	{
539 		.role         = EM28XX_BUTTON_SNAPSHOT,
540 		.reg_r        = EM28XX_R0C_USBSUSP,
541 		.reg_clearing = EM28XX_R0C_USBSUSP,
542 		.mask         = EM28XX_R0C_USBSUSP_SNAPSHOT,
543 		.inverted     = 0,
544 	},
545 	{-1, 0, 0, 0, 0},
546 };
547 
548 static struct em28xx_button speedlink_vad_laplace_buttons[] = {
549 	{
550 		.role     = EM28XX_BUTTON_SNAPSHOT,
551 		.reg_r    = EM2874_R85_GPIO_P1_STATE,
552 		.mask     = 0x80,
553 		.inverted = 1,
554 	},
555 	{
556 		.role     = EM28XX_BUTTON_ILLUMINATION,
557 		.reg_r    = EM2874_R84_GPIO_P0_STATE,
558 		.mask     = 0x08,
559 		.inverted = 1,
560 	},
561 	{-1, 0, 0, 0, 0},
562 };
563 
564 /*
565  *  LED definitions
566  */
567 static struct em28xx_led speedlink_vad_laplace_leds[] = {
568 	{
569 		.role      = EM28XX_LED_ANALOG_CAPTURING,
570 		.gpio_reg  = EM2874_R80_GPIO_P0_CTRL,
571 		.gpio_mask = 0x01,
572 		.inverted  = 1,
573 	},
574 	{
575 		.role      = EM28XX_LED_ILLUMINATION,
576 		.gpio_reg  = EM2874_R80_GPIO_P0_CTRL,
577 		.gpio_mask = 0x40,
578 		.inverted  = 1,
579 	},
580 	{-1, 0, 0, 0},
581 };
582 
583 static struct em28xx_led kworld_ub435q_v3_leds[] = {
584 	{
585 		.role      = EM28XX_LED_DIGITAL_CAPTURING,
586 		.gpio_reg  = EM2874_R80_GPIO_P0_CTRL,
587 		.gpio_mask = 0x80,
588 		.inverted  = 1,
589 	},
590 	{-1, 0, 0, 0},
591 };
592 
593 static struct em28xx_led pctv_80e_leds[] = {
594 	{
595 		.role      = EM28XX_LED_DIGITAL_CAPTURING,
596 		.gpio_reg  = EM2874_R80_GPIO_P0_CTRL,
597 		.gpio_mask = 0x80,
598 		.inverted  = 0,
599 	},
600 	{-1, 0, 0, 0},
601 };
602 
603 static struct em28xx_led terratec_grabby_leds[] = {
604 	{
605 		.role      = EM28XX_LED_ANALOG_CAPTURING,
606 		.gpio_reg  = EM2820_R08_GPIO_CTRL,
607 		.gpio_mask = EM_GPIO_3,
608 		.inverted  = 1,
609 	},
610 	{-1, 0, 0, 0},
611 };
612 
613 static struct em28xx_led hauppauge_dualhd_leds[] = {
614 	{
615 		.role      = EM28XX_LED_DIGITAL_CAPTURING,
616 		.gpio_reg  = EM2874_R80_GPIO_P0_CTRL,
617 		.gpio_mask = EM_GPIO_1,
618 		.inverted  = 1,
619 	},
620 	{
621 		.role      = EM28XX_LED_DIGITAL_CAPTURING_TS2,
622 		.gpio_reg  = EM2874_R80_GPIO_P0_CTRL,
623 		.gpio_mask = EM_GPIO_3,
624 		.inverted  = 1,
625 	},
626 	{-1, 0, 0, 0},
627 };
628 
629 /*
630  *  Board definitions
631  */
632 struct em28xx_board em28xx_boards[] = {
633 	[EM2750_BOARD_UNKNOWN] = {
634 		.name          = "EM2710/EM2750/EM2751 webcam grabber",
635 		.xclk          = EM28XX_XCLK_FREQUENCY_20MHZ,
636 		.tuner_type    = TUNER_ABSENT,
637 		.is_webcam     = 1,
638 		.input         = { {
639 			.type     = EM28XX_VMUX_COMPOSITE,
640 			.vmux     = 0,
641 			.amux     = EM28XX_AMUX_VIDEO,
642 			.gpio     = silvercrest_reg_seq,
643 		} },
644 	},
645 	[EM2800_BOARD_UNKNOWN] = {
646 		.name         = "Unknown EM2800 video grabber",
647 		.is_em2800    = 1,
648 		.tda9887_conf = TDA9887_PRESENT,
649 		.decoder      = EM28XX_SAA711X,
650 		.tuner_type   = TUNER_ABSENT,
651 		.input        = { {
652 			.type     = EM28XX_VMUX_COMPOSITE,
653 			.vmux     = SAA7115_COMPOSITE0,
654 			.amux     = EM28XX_AMUX_LINE_IN,
655 		}, {
656 			.type     = EM28XX_VMUX_SVIDEO,
657 			.vmux     = SAA7115_SVIDEO3,
658 			.amux     = EM28XX_AMUX_LINE_IN,
659 		} },
660 	},
661 	[EM2820_BOARD_UNKNOWN] = {
662 		.name          = "Unknown EM2750/28xx video grabber",
663 		.tuner_type    = TUNER_ABSENT,
664 		.is_webcam     = 1,	/* To enable sensor probe */
665 	},
666 	[EM2750_BOARD_DLCW_130] = {
667 		/* Beijing Huaqi Information Digital Technology Co., Ltd */
668 		.name          = "Huaqi DLCW-130",
669 		.valid         = EM28XX_BOARD_NOT_VALIDATED,
670 		.xclk          = EM28XX_XCLK_FREQUENCY_48MHZ,
671 		.tuner_type    = TUNER_ABSENT,
672 		.is_webcam     = 1,
673 		.input         = { {
674 			.type     = EM28XX_VMUX_COMPOSITE,
675 			.vmux     = 0,
676 			.amux     = EM28XX_AMUX_VIDEO,
677 		} },
678 	},
679 	[EM2820_BOARD_KWORLD_PVRTV2800RF] = {
680 		.name         = "Kworld PVR TV 2800 RF",
681 		.tuner_type   = TUNER_TEMIC_PAL,
682 		.tda9887_conf = TDA9887_PRESENT,
683 		.decoder      = EM28XX_SAA711X,
684 		.input        = { {
685 			.type     = EM28XX_VMUX_COMPOSITE,
686 			.vmux     = SAA7115_COMPOSITE0,
687 			.amux     = EM28XX_AMUX_LINE_IN,
688 		}, {
689 			.type     = EM28XX_VMUX_SVIDEO,
690 			.vmux     = SAA7115_SVIDEO3,
691 			.amux     = EM28XX_AMUX_LINE_IN,
692 		} },
693 	},
694 	[EM2820_BOARD_GADMEI_TVR200] = {
695 		.name         = "Gadmei TVR200",
696 		.tuner_type   = TUNER_LG_PAL_NEW_TAPC,
697 		.tda9887_conf = TDA9887_PRESENT,
698 		.decoder      = EM28XX_SAA711X,
699 		.input        = { {
700 			.type     = EM28XX_VMUX_TELEVISION,
701 			.vmux     = SAA7115_COMPOSITE2,
702 			.amux     = EM28XX_AMUX_LINE_IN,
703 		}, {
704 			.type     = EM28XX_VMUX_COMPOSITE,
705 			.vmux     = SAA7115_COMPOSITE0,
706 			.amux     = EM28XX_AMUX_LINE_IN,
707 		}, {
708 			.type     = EM28XX_VMUX_SVIDEO,
709 			.vmux     = SAA7115_SVIDEO3,
710 			.amux     = EM28XX_AMUX_LINE_IN,
711 		} },
712 	},
713 	[EM2820_BOARD_TERRATEC_CINERGY_250] = {
714 		.name         = "Terratec Cinergy 250 USB",
715 		.tuner_type   = TUNER_LG_PAL_NEW_TAPC,
716 		.has_ir_i2c   = 1,
717 		.tda9887_conf = TDA9887_PRESENT,
718 		.decoder      = EM28XX_SAA711X,
719 		.input        = { {
720 			.type     = EM28XX_VMUX_TELEVISION,
721 			.vmux     = SAA7115_COMPOSITE2,
722 			.amux     = EM28XX_AMUX_VIDEO,
723 		}, {
724 			.type     = EM28XX_VMUX_COMPOSITE,
725 			.vmux     = SAA7115_COMPOSITE0,
726 			.amux     = EM28XX_AMUX_LINE_IN,
727 		}, {
728 			.type     = EM28XX_VMUX_SVIDEO,
729 			.vmux     = SAA7115_SVIDEO3,
730 			.amux     = EM28XX_AMUX_LINE_IN,
731 		} },
732 	},
733 	[EM2820_BOARD_PINNACLE_USB_2] = {
734 		.name         = "Pinnacle PCTV USB 2",
735 		.tuner_type   = TUNER_LG_PAL_NEW_TAPC,
736 		.has_ir_i2c   = 1,
737 		.tda9887_conf = TDA9887_PRESENT,
738 		.decoder      = EM28XX_SAA711X,
739 		.input        = { {
740 			.type     = EM28XX_VMUX_TELEVISION,
741 			.vmux     = SAA7115_COMPOSITE2,
742 			.amux     = EM28XX_AMUX_VIDEO,
743 		}, {
744 			.type     = EM28XX_VMUX_COMPOSITE,
745 			.vmux     = SAA7115_COMPOSITE0,
746 			.amux     = EM28XX_AMUX_LINE_IN,
747 		}, {
748 			.type     = EM28XX_VMUX_SVIDEO,
749 			.vmux     = SAA7115_SVIDEO3,
750 			.amux     = EM28XX_AMUX_LINE_IN,
751 		} },
752 	},
753 	[EM2820_BOARD_HAUPPAUGE_WINTV_USB_2] = {
754 		.name         = "Hauppauge WinTV USB 2",
755 		.tuner_type   = TUNER_PHILIPS_FM1236_MK3,
756 		.tda9887_conf = TDA9887_PRESENT |
757 				TDA9887_PORT1_ACTIVE |
758 				TDA9887_PORT2_ACTIVE,
759 		.decoder      = EM28XX_TVP5150,
760 		.has_msp34xx  = 1,
761 		.has_ir_i2c   = 1,
762 		.input        = { {
763 			.type     = EM28XX_VMUX_TELEVISION,
764 			.vmux     = TVP5150_COMPOSITE0,
765 			.amux     = MSP_INPUT_DEFAULT,
766 		}, {
767 			.type     = EM28XX_VMUX_SVIDEO,
768 			.vmux     = TVP5150_SVIDEO,
769 			.amux     = MSP_INPUT(MSP_IN_SCART1, MSP_IN_TUNER1,
770 					MSP_DSP_IN_SCART, MSP_DSP_IN_SCART),
771 		} },
772 	},
773 	[EM2820_BOARD_DLINK_USB_TV] = {
774 		.name         = "D-Link DUB-T210 TV Tuner",
775 		.valid        = EM28XX_BOARD_NOT_VALIDATED,
776 		.tuner_type   = TUNER_LG_PAL_NEW_TAPC,
777 		.tda9887_conf = TDA9887_PRESENT,
778 		.decoder      = EM28XX_SAA711X,
779 		.input        = { {
780 			.type     = EM28XX_VMUX_TELEVISION,
781 			.vmux     = SAA7115_COMPOSITE2,
782 			.amux     = EM28XX_AMUX_LINE_IN,
783 		}, {
784 			.type     = EM28XX_VMUX_COMPOSITE,
785 			.vmux     = SAA7115_COMPOSITE0,
786 			.amux     = EM28XX_AMUX_LINE_IN,
787 		}, {
788 			.type     = EM28XX_VMUX_SVIDEO,
789 			.vmux     = SAA7115_SVIDEO3,
790 			.amux     = EM28XX_AMUX_LINE_IN,
791 		} },
792 	},
793 	[EM2820_BOARD_HERCULES_SMART_TV_USB2] = {
794 		.name         = "Hercules Smart TV USB 2.0",
795 		.valid        = EM28XX_BOARD_NOT_VALIDATED,
796 		.tuner_type   = TUNER_LG_PAL_NEW_TAPC,
797 		.tda9887_conf = TDA9887_PRESENT,
798 		.decoder      = EM28XX_SAA711X,
799 		.input        = { {
800 			.type     = EM28XX_VMUX_TELEVISION,
801 			.vmux     = SAA7115_COMPOSITE2,
802 			.amux     = EM28XX_AMUX_LINE_IN,
803 		}, {
804 			.type     = EM28XX_VMUX_COMPOSITE,
805 			.vmux     = SAA7115_COMPOSITE0,
806 			.amux     = EM28XX_AMUX_LINE_IN,
807 		}, {
808 			.type     = EM28XX_VMUX_SVIDEO,
809 			.vmux     = SAA7115_SVIDEO3,
810 			.amux     = EM28XX_AMUX_LINE_IN,
811 		} },
812 	},
813 	[EM2820_BOARD_PINNACLE_USB_2_FM1216ME] = {
814 		.name         = "Pinnacle PCTV USB 2 (Philips FM1216ME)",
815 		.valid        = EM28XX_BOARD_NOT_VALIDATED,
816 		.tuner_type   = TUNER_PHILIPS_FM1216ME_MK3,
817 		.tda9887_conf = TDA9887_PRESENT,
818 		.decoder      = EM28XX_SAA711X,
819 		.input        = { {
820 			.type     = EM28XX_VMUX_TELEVISION,
821 			.vmux     = SAA7115_COMPOSITE2,
822 			.amux     = EM28XX_AMUX_VIDEO,
823 		}, {
824 			.type     = EM28XX_VMUX_COMPOSITE,
825 			.vmux     = SAA7115_COMPOSITE0,
826 			.amux     = EM28XX_AMUX_LINE_IN,
827 		}, {
828 			.type     = EM28XX_VMUX_SVIDEO,
829 			.vmux     = SAA7115_SVIDEO3,
830 			.amux     = EM28XX_AMUX_LINE_IN,
831 		} },
832 	},
833 	[EM2820_BOARD_GADMEI_UTV310] = {
834 		.name         = "Gadmei UTV310",
835 		.valid        = EM28XX_BOARD_NOT_VALIDATED,
836 		.tuner_type   = TUNER_TNF_5335MF,
837 		.tda9887_conf = TDA9887_PRESENT,
838 		.decoder      = EM28XX_SAA711X,
839 		.input        = { {
840 			.type     = EM28XX_VMUX_TELEVISION,
841 			.vmux     = SAA7115_COMPOSITE1,
842 			.amux     = EM28XX_AMUX_LINE_IN,
843 		}, {
844 			.type     = EM28XX_VMUX_COMPOSITE,
845 			.vmux     = SAA7115_COMPOSITE0,
846 			.amux     = EM28XX_AMUX_LINE_IN,
847 		}, {
848 			.type     = EM28XX_VMUX_SVIDEO,
849 			.vmux     = SAA7115_SVIDEO3,
850 			.amux     = EM28XX_AMUX_LINE_IN,
851 		} },
852 	},
853 	[EM2820_BOARD_LEADTEK_WINFAST_USBII_DELUXE] = {
854 		.name         = "Leadtek Winfast USB II Deluxe",
855 		.valid        = EM28XX_BOARD_NOT_VALIDATED,
856 		.tuner_type   = TUNER_PHILIPS_FM1216ME_MK3,
857 		.has_ir_i2c   = 1,
858 		.tvaudio_addr = 0x58,
859 		.tda9887_conf = TDA9887_PRESENT |
860 				TDA9887_PORT2_ACTIVE |
861 				TDA9887_QSS,
862 		.decoder      = EM28XX_SAA711X,
863 		.adecoder     = EM28XX_TVAUDIO,
864 		.input        = { {
865 			.type     = EM28XX_VMUX_TELEVISION,
866 			.vmux     = SAA7115_COMPOSITE4,
867 			.amux     = EM28XX_AMUX_AUX,
868 		}, {
869 			.type     = EM28XX_VMUX_COMPOSITE,
870 			.vmux     = SAA7115_COMPOSITE5,
871 			.amux     = EM28XX_AMUX_LINE_IN,
872 		}, {
873 			.type     = EM28XX_VMUX_SVIDEO,
874 			.vmux     = SAA7115_SVIDEO3,
875 			.amux     = EM28XX_AMUX_LINE_IN,
876 		} },
877 			.radio	  = {
878 			.type     = EM28XX_RADIO,
879 			.amux     = EM28XX_AMUX_AUX,
880 			}
881 	},
882 	[EM2820_BOARD_VIDEOLOGY_20K14XUSB] = {
883 		.name         = "Videology 20K14XUSB USB2.0",
884 		.valid        = EM28XX_BOARD_NOT_VALIDATED,
885 		.tuner_type   = TUNER_ABSENT,
886 		.is_webcam    = 1,
887 		.input        = { {
888 			.type     = EM28XX_VMUX_COMPOSITE,
889 			.vmux     = 0,
890 			.amux     = EM28XX_AMUX_VIDEO,
891 		} },
892 	},
893 	[EM2820_BOARD_SILVERCREST_WEBCAM] = {
894 		.name         = "Silvercrest Webcam 1.3mpix",
895 		.tuner_type   = TUNER_ABSENT,
896 		.is_webcam    = 1,
897 		.input        = { {
898 			.type     = EM28XX_VMUX_COMPOSITE,
899 			.vmux     = 0,
900 			.amux     = EM28XX_AMUX_VIDEO,
901 			.gpio     = silvercrest_reg_seq,
902 		} },
903 	},
904 	[EM2821_BOARD_SUPERCOMP_USB_2] = {
905 		.name         = "Supercomp USB 2.0 TV",
906 		.valid        = EM28XX_BOARD_NOT_VALIDATED,
907 		.tuner_type   = TUNER_PHILIPS_FM1236_MK3,
908 		.tda9887_conf = TDA9887_PRESENT |
909 				TDA9887_PORT1_ACTIVE |
910 				TDA9887_PORT2_ACTIVE,
911 		.decoder      = EM28XX_SAA711X,
912 		.input        = { {
913 			.type     = EM28XX_VMUX_TELEVISION,
914 			.vmux     = SAA7115_COMPOSITE2,
915 			.amux     = EM28XX_AMUX_LINE_IN,
916 		}, {
917 			.type     = EM28XX_VMUX_COMPOSITE,
918 			.vmux     = SAA7115_COMPOSITE0,
919 			.amux     = EM28XX_AMUX_VIDEO,
920 		}, {
921 			.type     = EM28XX_VMUX_SVIDEO,
922 			.vmux     = SAA7115_SVIDEO3,
923 			.amux     = EM28XX_AMUX_LINE_IN,
924 		} },
925 	},
926 	[EM2821_BOARD_USBGEAR_VD204] = {
927 		.name         = "Usbgear VD204v9",
928 		.valid        = EM28XX_BOARD_NOT_VALIDATED,
929 		.tuner_type   = TUNER_ABSENT,	/* Capture only device */
930 		.decoder      = EM28XX_SAA711X,
931 		.input        = { {
932 			.type  = EM28XX_VMUX_COMPOSITE,
933 			.vmux  = SAA7115_COMPOSITE0,
934 			.amux  = EM28XX_AMUX_LINE_IN,
935 		}, {
936 			.type  = EM28XX_VMUX_SVIDEO,
937 			.vmux  = SAA7115_SVIDEO3,
938 			.amux  = EM28XX_AMUX_LINE_IN,
939 		} },
940 	},
941 	[EM2860_BOARD_NETGMBH_CAM] = {
942 		/* Beijing Huaqi Information Digital Technology Co., Ltd */
943 		.name         = "NetGMBH Cam",
944 		.valid        = EM28XX_BOARD_NOT_VALIDATED,
945 		.tuner_type   = TUNER_ABSENT,
946 		.is_webcam    = 1,
947 		.input        = { {
948 			.type     = EM28XX_VMUX_COMPOSITE,
949 			.vmux     = 0,
950 			.amux     = EM28XX_AMUX_VIDEO,
951 		} },
952 	},
953 	[EM2860_BOARD_TYPHOON_DVD_MAKER] = {
954 		.name         = "Typhoon DVD Maker",
955 		.decoder      = EM28XX_SAA711X,
956 		.tuner_type   = TUNER_ABSENT,	/* Capture only device */
957 		.input        = { {
958 			.type  = EM28XX_VMUX_COMPOSITE,
959 			.vmux  = SAA7115_COMPOSITE0,
960 			.amux  = EM28XX_AMUX_LINE_IN,
961 		}, {
962 			.type  = EM28XX_VMUX_SVIDEO,
963 			.vmux  = SAA7115_SVIDEO3,
964 			.amux  = EM28XX_AMUX_LINE_IN,
965 		} },
966 	},
967 	[EM2860_BOARD_GADMEI_UTV330] = {
968 		.name         = "Gadmei UTV330",
969 		.valid        = EM28XX_BOARD_NOT_VALIDATED,
970 		.tuner_type   = TUNER_TNF_5335MF,
971 		.tda9887_conf = TDA9887_PRESENT,
972 		.decoder      = EM28XX_SAA711X,
973 		.input        = { {
974 			.type     = EM28XX_VMUX_TELEVISION,
975 			.vmux     = SAA7115_COMPOSITE2,
976 			.amux     = EM28XX_AMUX_VIDEO,
977 		}, {
978 			.type     = EM28XX_VMUX_COMPOSITE,
979 			.vmux     = SAA7115_COMPOSITE0,
980 			.amux     = EM28XX_AMUX_LINE_IN,
981 		}, {
982 			.type     = EM28XX_VMUX_SVIDEO,
983 			.vmux     = SAA7115_SVIDEO3,
984 			.amux     = EM28XX_AMUX_LINE_IN,
985 		} },
986 	},
987 	[EM2861_BOARD_GADMEI_UTV330PLUS] = {
988 		.name         = "Gadmei UTV330+",
989 		.tuner_type   = TUNER_TNF_5335MF,
990 		.tda9887_conf = TDA9887_PRESENT,
991 		.ir_codes     = RC_MAP_GADMEI_RM008Z,
992 		.decoder      = EM28XX_SAA711X,
993 		.xclk         = EM28XX_XCLK_FREQUENCY_12MHZ,
994 		.input        = { {
995 			.type     = EM28XX_VMUX_TELEVISION,
996 			.vmux     = SAA7115_COMPOSITE2,
997 			.amux     = EM28XX_AMUX_VIDEO,
998 		}, {
999 			.type     = EM28XX_VMUX_COMPOSITE,
1000 			.vmux     = SAA7115_COMPOSITE0,
1001 			.amux     = EM28XX_AMUX_LINE_IN,
1002 		}, {
1003 			.type     = EM28XX_VMUX_SVIDEO,
1004 			.vmux     = SAA7115_SVIDEO3,
1005 			.amux     = EM28XX_AMUX_LINE_IN,
1006 		} },
1007 	},
1008 	[EM2860_BOARD_TERRATEC_HYBRID_XS] = {
1009 		.name         = "Terratec Cinergy A Hybrid XS",
1010 		.valid        = EM28XX_BOARD_NOT_VALIDATED,
1011 		.tuner_type   = TUNER_XC2028,
1012 		.tuner_gpio   = default_tuner_gpio,
1013 		.decoder      = EM28XX_TVP5150,
1014 
1015 		.input        = { {
1016 			.type     = EM28XX_VMUX_TELEVISION,
1017 			.vmux     = TVP5150_COMPOSITE0,
1018 			.amux     = EM28XX_AMUX_VIDEO,
1019 			.gpio     = hauppauge_wintv_hvr_900_analog,
1020 		}, {
1021 			.type     = EM28XX_VMUX_COMPOSITE,
1022 			.vmux     = TVP5150_COMPOSITE1,
1023 			.amux     = EM28XX_AMUX_LINE_IN,
1024 			.gpio     = hauppauge_wintv_hvr_900_analog,
1025 		}, {
1026 			.type     = EM28XX_VMUX_SVIDEO,
1027 			.vmux     = TVP5150_SVIDEO,
1028 			.amux     = EM28XX_AMUX_LINE_IN,
1029 			.gpio     = hauppauge_wintv_hvr_900_analog,
1030 		} },
1031 	},
1032 	[EM2861_BOARD_KWORLD_PVRTV_300U] = {
1033 		.name	      = "KWorld PVRTV 300U",
1034 		.valid        = EM28XX_BOARD_NOT_VALIDATED,
1035 		.tuner_type   = TUNER_XC2028,
1036 		.tuner_gpio   = default_tuner_gpio,
1037 		.decoder      = EM28XX_TVP5150,
1038 		.input        = { {
1039 			.type     = EM28XX_VMUX_TELEVISION,
1040 			.vmux     = TVP5150_COMPOSITE0,
1041 			.amux     = EM28XX_AMUX_VIDEO,
1042 		}, {
1043 			.type     = EM28XX_VMUX_COMPOSITE,
1044 			.vmux     = TVP5150_COMPOSITE1,
1045 			.amux     = EM28XX_AMUX_LINE_IN,
1046 		}, {
1047 			.type     = EM28XX_VMUX_SVIDEO,
1048 			.vmux     = TVP5150_SVIDEO,
1049 			.amux     = EM28XX_AMUX_LINE_IN,
1050 		} },
1051 	},
1052 	[EM2861_BOARD_YAKUMO_MOVIE_MIXER] = {
1053 		.name          = "Yakumo MovieMixer",
1054 		.tuner_type    = TUNER_ABSENT,	/* Capture only device */
1055 		.decoder       = EM28XX_TVP5150,
1056 		.input         = { {
1057 			.type     = EM28XX_VMUX_TELEVISION,
1058 			.vmux     = TVP5150_COMPOSITE0,
1059 			.amux     = EM28XX_AMUX_VIDEO,
1060 		}, {
1061 			.type     = EM28XX_VMUX_COMPOSITE,
1062 			.vmux     = TVP5150_COMPOSITE1,
1063 			.amux     = EM28XX_AMUX_LINE_IN,
1064 		}, {
1065 			.type     = EM28XX_VMUX_SVIDEO,
1066 			.vmux     = TVP5150_SVIDEO,
1067 			.amux     = EM28XX_AMUX_LINE_IN,
1068 		} },
1069 	},
1070 	[EM2860_BOARD_TVP5150_REFERENCE_DESIGN] = {
1071 		.name          = "EM2860/TVP5150 Reference Design",
1072 		.tuner_type    = TUNER_ABSENT,	/* Capture only device */
1073 		.decoder       = EM28XX_TVP5150,
1074 		.input         = { {
1075 			.type     = EM28XX_VMUX_COMPOSITE,
1076 			.vmux     = TVP5150_COMPOSITE1,
1077 			.amux     = EM28XX_AMUX_LINE_IN,
1078 		}, {
1079 			.type     = EM28XX_VMUX_SVIDEO,
1080 			.vmux     = TVP5150_SVIDEO,
1081 			.amux     = EM28XX_AMUX_LINE_IN,
1082 		} },
1083 	},
1084 	[EM2861_BOARD_PLEXTOR_PX_TV100U] = {
1085 		.name         = "Plextor ConvertX PX-TV100U",
1086 		.tuner_type   = TUNER_TNF_5335MF,
1087 		.xclk         = EM28XX_XCLK_I2S_MSB_TIMING |
1088 				EM28XX_XCLK_FREQUENCY_12MHZ,
1089 		.tda9887_conf = TDA9887_PRESENT,
1090 		.decoder      = EM28XX_TVP5150,
1091 		.has_msp34xx  = 1,
1092 		.input        = { {
1093 			.type     = EM28XX_VMUX_TELEVISION,
1094 			.vmux     = TVP5150_COMPOSITE0,
1095 			.amux     = EM28XX_AMUX_LINE_IN,
1096 			.gpio     = pinnacle_hybrid_pro_analog,
1097 		}, {
1098 			.type     = EM28XX_VMUX_COMPOSITE,
1099 			.vmux     = TVP5150_COMPOSITE1,
1100 			.amux     = EM28XX_AMUX_LINE_IN,
1101 			.gpio     = pinnacle_hybrid_pro_analog,
1102 		}, {
1103 			.type     = EM28XX_VMUX_SVIDEO,
1104 			.vmux     = TVP5150_SVIDEO,
1105 			.amux     = EM28XX_AMUX_LINE_IN,
1106 			.gpio     = pinnacle_hybrid_pro_analog,
1107 		} },
1108 	},
1109 
1110 	/* Those boards with em2870 are DVB Only*/
1111 
1112 	[EM2870_BOARD_TERRATEC_XS] = {
1113 		.name         = "Terratec Cinergy T XS",
1114 		.valid        = EM28XX_BOARD_NOT_VALIDATED,
1115 		.tuner_type   = TUNER_XC2028,
1116 		.tuner_gpio   = default_tuner_gpio,
1117 	},
1118 	[EM2870_BOARD_TERRATEC_XS_MT2060] = {
1119 		.name         = "Terratec Cinergy T XS (MT2060)",
1120 		.xclk         = EM28XX_XCLK_IR_RC5_MODE |
1121 				EM28XX_XCLK_FREQUENCY_12MHZ,
1122 		.i2c_speed    = EM28XX_I2C_CLK_WAIT_ENABLE,
1123 		.tuner_type   = TUNER_ABSENT, /* MT2060 */
1124 		.has_dvb      = 1,
1125 		.tuner_gpio   = default_tuner_gpio,
1126 	},
1127 	[EM2870_BOARD_KWORLD_350U] = {
1128 		.name         = "Kworld 350 U DVB-T",
1129 		.valid        = EM28XX_BOARD_NOT_VALIDATED,
1130 		.tuner_type   = TUNER_XC2028,
1131 		.tuner_gpio   = default_tuner_gpio,
1132 	},
1133 	[EM2870_BOARD_KWORLD_355U] = {
1134 		.name         = "Kworld 355 U DVB-T",
1135 		.valid        = EM28XX_BOARD_NOT_VALIDATED,
1136 		.tuner_type   = TUNER_ABSENT,
1137 		.tuner_gpio   = default_tuner_gpio,
1138 		.has_dvb      = 1,
1139 		.dvb_gpio     = default_digital,
1140 	},
1141 	[EM2870_BOARD_PINNACLE_PCTV_DVB] = {
1142 		.name         = "Pinnacle PCTV DVB-T",
1143 		.valid        = EM28XX_BOARD_NOT_VALIDATED,
1144 		.tuner_type   = TUNER_ABSENT, /* MT2060 */
1145 		/* djh - I have serious doubts this is right... */
1146 		.xclk         = EM28XX_XCLK_IR_RC5_MODE |
1147 				EM28XX_XCLK_FREQUENCY_10MHZ,
1148 	},
1149 	[EM2870_BOARD_COMPRO_VIDEOMATE] = {
1150 		.name         = "Compro, VideoMate U3",
1151 		.valid        = EM28XX_BOARD_NOT_VALIDATED,
1152 		.tuner_type   = TUNER_ABSENT, /* MT2060 */
1153 	},
1154 
1155 	[EM2880_BOARD_TERRATEC_HYBRID_XS_FR] = {
1156 		.name         = "Terratec Hybrid XS Secam",
1157 		.has_msp34xx  = 1,
1158 		.tuner_type   = TUNER_XC2028,
1159 		.tuner_gpio   = default_tuner_gpio,
1160 		.decoder      = EM28XX_TVP5150,
1161 		.has_dvb      = 1,
1162 		.dvb_gpio     = terratec_cinergy_USB_XS_FR_digital,
1163 		.input        = { {
1164 			.type     = EM28XX_VMUX_TELEVISION,
1165 			.vmux     = TVP5150_COMPOSITE0,
1166 			.amux     = EM28XX_AMUX_VIDEO,
1167 			.gpio     = terratec_cinergy_USB_XS_FR_analog,
1168 		}, {
1169 			.type     = EM28XX_VMUX_COMPOSITE,
1170 			.vmux     = TVP5150_COMPOSITE1,
1171 			.amux     = EM28XX_AMUX_LINE_IN,
1172 			.gpio     = terratec_cinergy_USB_XS_FR_analog,
1173 		}, {
1174 			.type     = EM28XX_VMUX_SVIDEO,
1175 			.vmux     = TVP5150_SVIDEO,
1176 			.amux     = EM28XX_AMUX_LINE_IN,
1177 			.gpio     = terratec_cinergy_USB_XS_FR_analog,
1178 		} },
1179 	},
1180 	[EM2884_BOARD_TERRATEC_H5] = {
1181 		.name         = "Terratec Cinergy H5",
1182 		.has_dvb      = 1,
1183 #if 0
1184 		.tuner_type   = TUNER_PHILIPS_TDA8290,
1185 		.tuner_addr   = 0x41,
1186 		.dvb_gpio     = terratec_h5_digital, /* FIXME: probably wrong */
1187 		.tuner_gpio   = terratec_h5_gpio,
1188 #else
1189 		.tuner_type   = TUNER_ABSENT,
1190 #endif
1191 		.def_i2c_bus  = 1,
1192 		.i2c_speed    = EM28XX_I2C_CLK_WAIT_ENABLE |
1193 				EM28XX_I2C_FREQ_400_KHZ,
1194 	},
1195 	[EM2884_BOARD_HAUPPAUGE_WINTV_HVR_930C] = {
1196 		.name         = "Hauppauge WinTV HVR 930C",
1197 		.has_dvb      = 1,
1198 #if 0 /* FIXME: Add analog support */
1199 		.tuner_type   = TUNER_XC5000,
1200 		.tuner_addr   = 0x41,
1201 		.dvb_gpio     = hauppauge_930c_digital,
1202 		.tuner_gpio   = hauppauge_930c_gpio,
1203 #else
1204 		.tuner_type   = TUNER_ABSENT,
1205 #endif
1206 		.ir_codes     = RC_MAP_HAUPPAUGE,
1207 		.def_i2c_bus  = 1,
1208 		.i2c_speed    = EM28XX_I2C_CLK_WAIT_ENABLE |
1209 				EM28XX_I2C_FREQ_400_KHZ,
1210 	},
1211 	[EM2884_BOARD_C3TECH_DIGITAL_DUO] = {
1212 		.name         = "C3 Tech Digital Duo HDTV/SDTV USB",
1213 		.has_dvb      = 1,
1214 		/* FIXME: Add analog support - need a saa7136 driver */
1215 		.tuner_type = TUNER_ABSENT,	/* Digital-only TDA18271HD */
1216 		.ir_codes     = RC_MAP_EMPTY,
1217 		.def_i2c_bus  = 1,
1218 		.i2c_speed    = EM28XX_I2C_CLK_WAIT_ENABLE,
1219 		.dvb_gpio     = c3tech_digital_duo_digital,
1220 	},
1221 	[EM2884_BOARD_CINERGY_HTC_STICK] = {
1222 		.name         = "Terratec Cinergy HTC Stick",
1223 		.has_dvb      = 1,
1224 		.ir_codes     = RC_MAP_NEC_TERRATEC_CINERGY_XS,
1225 		.tuner_type   = TUNER_ABSENT,
1226 		.def_i2c_bus  = 1,
1227 		.i2c_speed    = EM28XX_I2C_CLK_WAIT_ENABLE |
1228 				EM28XX_I2C_FREQ_400_KHZ,
1229 	},
1230 	[EM2884_BOARD_ELGATO_EYETV_HYBRID_2008] = {
1231 		.name         = "Elgato EyeTV Hybrid 2008 INT",
1232 		.has_dvb      = 1,
1233 		.ir_codes     = RC_MAP_NEC_TERRATEC_CINERGY_XS,
1234 		.tuner_type   = TUNER_ABSENT,
1235 		.def_i2c_bus  = 1,
1236 		.i2c_speed    = EM28XX_I2C_CLK_WAIT_ENABLE |
1237 				EM28XX_I2C_FREQ_400_KHZ,
1238 	},
1239 	[EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900] = {
1240 		.name         = "Hauppauge WinTV HVR 900",
1241 		.tda9887_conf = TDA9887_PRESENT,
1242 		.tuner_type   = TUNER_XC2028,
1243 		.tuner_gpio   = default_tuner_gpio,
1244 		.mts_firmware = 1,
1245 		.has_dvb      = 1,
1246 		.dvb_gpio     = hauppauge_wintv_hvr_900_digital,
1247 		.ir_codes     = RC_MAP_HAUPPAUGE,
1248 		.decoder      = EM28XX_TVP5150,
1249 		.input        = { {
1250 			.type     = EM28XX_VMUX_TELEVISION,
1251 			.vmux     = TVP5150_COMPOSITE0,
1252 			.amux     = EM28XX_AMUX_VIDEO,
1253 			.gpio     = hauppauge_wintv_hvr_900_analog,
1254 		}, {
1255 			.type     = EM28XX_VMUX_COMPOSITE,
1256 			.vmux     = TVP5150_COMPOSITE1,
1257 			.amux     = EM28XX_AMUX_LINE_IN,
1258 			.gpio     = hauppauge_wintv_hvr_900_analog,
1259 		}, {
1260 			.type     = EM28XX_VMUX_SVIDEO,
1261 			.vmux     = TVP5150_SVIDEO,
1262 			.amux     = EM28XX_AMUX_LINE_IN,
1263 			.gpio     = hauppauge_wintv_hvr_900_analog,
1264 		} },
1265 	},
1266 	[EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900_R2] = {
1267 		.name         = "Hauppauge WinTV HVR 900 (R2)",
1268 		.tda9887_conf = TDA9887_PRESENT,
1269 		.tuner_type   = TUNER_XC2028,
1270 		.tuner_gpio   = default_tuner_gpio,
1271 		.mts_firmware = 1,
1272 		.has_dvb      = 1,
1273 		.dvb_gpio     = hauppauge_wintv_hvr_900R2_digital,
1274 		.ir_codes     = RC_MAP_HAUPPAUGE,
1275 		.decoder      = EM28XX_TVP5150,
1276 		.input        = { {
1277 			.type     = EM28XX_VMUX_TELEVISION,
1278 			.vmux     = TVP5150_COMPOSITE0,
1279 			.amux     = EM28XX_AMUX_VIDEO,
1280 			.gpio     = hauppauge_wintv_hvr_900_analog,
1281 		}, {
1282 			.type     = EM28XX_VMUX_COMPOSITE,
1283 			.vmux     = TVP5150_COMPOSITE1,
1284 			.amux     = EM28XX_AMUX_LINE_IN,
1285 			.gpio     = hauppauge_wintv_hvr_900_analog,
1286 		}, {
1287 			.type     = EM28XX_VMUX_SVIDEO,
1288 			.vmux     = TVP5150_SVIDEO,
1289 			.amux     = EM28XX_AMUX_LINE_IN,
1290 			.gpio     = hauppauge_wintv_hvr_900_analog,
1291 		} },
1292 	},
1293 	[EM2883_BOARD_HAUPPAUGE_WINTV_HVR_850] = {
1294 		.name           = "Hauppauge WinTV HVR 850",
1295 		.tuner_type     = TUNER_XC2028,
1296 		.tuner_gpio     = default_tuner_gpio,
1297 		.mts_firmware   = 1,
1298 		.has_dvb        = 1,
1299 		.dvb_gpio       = hauppauge_wintv_hvr_900_digital,
1300 		.ir_codes       = RC_MAP_HAUPPAUGE,
1301 		.decoder        = EM28XX_TVP5150,
1302 		.input          = { {
1303 			.type     = EM28XX_VMUX_TELEVISION,
1304 			.vmux     = TVP5150_COMPOSITE0,
1305 			.amux     = EM28XX_AMUX_VIDEO,
1306 			.gpio     = hauppauge_wintv_hvr_900_analog,
1307 		}, {
1308 			.type     = EM28XX_VMUX_COMPOSITE,
1309 			.vmux     = TVP5150_COMPOSITE1,
1310 			.amux     = EM28XX_AMUX_LINE_IN,
1311 			.gpio     = hauppauge_wintv_hvr_900_analog,
1312 		}, {
1313 			.type     = EM28XX_VMUX_SVIDEO,
1314 			.vmux     = TVP5150_SVIDEO,
1315 			.amux     = EM28XX_AMUX_LINE_IN,
1316 			.gpio     = hauppauge_wintv_hvr_900_analog,
1317 		} },
1318 	},
1319 	[EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950] = {
1320 		.name           = "Hauppauge WinTV HVR 950",
1321 		.tuner_type     = TUNER_XC2028,
1322 		.tuner_gpio     = default_tuner_gpio,
1323 		.mts_firmware   = 1,
1324 		.has_dvb        = 1,
1325 		.dvb_gpio       = hauppauge_wintv_hvr_900_digital,
1326 		.ir_codes       = RC_MAP_HAUPPAUGE,
1327 		.decoder        = EM28XX_TVP5150,
1328 		.input          = { {
1329 			.type     = EM28XX_VMUX_TELEVISION,
1330 			.vmux     = TVP5150_COMPOSITE0,
1331 			.amux     = EM28XX_AMUX_VIDEO,
1332 			.gpio     = hauppauge_wintv_hvr_900_analog,
1333 		}, {
1334 			.type     = EM28XX_VMUX_COMPOSITE,
1335 			.vmux     = TVP5150_COMPOSITE1,
1336 			.amux     = EM28XX_AMUX_LINE_IN,
1337 			.gpio     = hauppauge_wintv_hvr_900_analog,
1338 		}, {
1339 			.type     = EM28XX_VMUX_SVIDEO,
1340 			.vmux     = TVP5150_SVIDEO,
1341 			.amux     = EM28XX_AMUX_LINE_IN,
1342 			.gpio     = hauppauge_wintv_hvr_900_analog,
1343 		} },
1344 	},
1345 	[EM2880_BOARD_PINNACLE_PCTV_HD_PRO] = {
1346 		.name           = "Pinnacle PCTV HD Pro Stick",
1347 		.tuner_type     = TUNER_XC2028,
1348 		.tuner_gpio   = default_tuner_gpio,
1349 		.mts_firmware   = 1,
1350 		.has_dvb        = 1,
1351 		.dvb_gpio       = hauppauge_wintv_hvr_900_digital,
1352 		.ir_codes       = RC_MAP_PINNACLE_PCTV_HD,
1353 		.decoder        = EM28XX_TVP5150,
1354 		.input          = { {
1355 			.type     = EM28XX_VMUX_TELEVISION,
1356 			.vmux     = TVP5150_COMPOSITE0,
1357 			.amux     = EM28XX_AMUX_VIDEO,
1358 			.gpio     = hauppauge_wintv_hvr_900_analog,
1359 		}, {
1360 			.type     = EM28XX_VMUX_COMPOSITE,
1361 			.vmux     = TVP5150_COMPOSITE1,
1362 			.amux     = EM28XX_AMUX_LINE_IN,
1363 			.gpio     = hauppauge_wintv_hvr_900_analog,
1364 		}, {
1365 			.type     = EM28XX_VMUX_SVIDEO,
1366 			.vmux     = TVP5150_SVIDEO,
1367 			.amux     = EM28XX_AMUX_LINE_IN,
1368 			.gpio     = hauppauge_wintv_hvr_900_analog,
1369 		} },
1370 	},
1371 	[EM2880_BOARD_AMD_ATI_TV_WONDER_HD_600] = {
1372 		.name           = "AMD ATI TV Wonder HD 600",
1373 		.tuner_type     = TUNER_XC2028,
1374 		.tuner_gpio     = default_tuner_gpio,
1375 		.mts_firmware   = 1,
1376 		.has_dvb        = 1,
1377 		.dvb_gpio       = hauppauge_wintv_hvr_900_digital,
1378 		.ir_codes       = RC_MAP_ATI_TV_WONDER_HD_600,
1379 		.decoder        = EM28XX_TVP5150,
1380 		.input          = { {
1381 			.type     = EM28XX_VMUX_TELEVISION,
1382 			.vmux     = TVP5150_COMPOSITE0,
1383 			.amux     = EM28XX_AMUX_VIDEO,
1384 			.gpio     = hauppauge_wintv_hvr_900_analog,
1385 		}, {
1386 			.type     = EM28XX_VMUX_COMPOSITE,
1387 			.vmux     = TVP5150_COMPOSITE1,
1388 			.amux     = EM28XX_AMUX_LINE_IN,
1389 			.gpio     = hauppauge_wintv_hvr_900_analog,
1390 		}, {
1391 			.type     = EM28XX_VMUX_SVIDEO,
1392 			.vmux     = TVP5150_SVIDEO,
1393 			.amux     = EM28XX_AMUX_LINE_IN,
1394 			.gpio     = hauppauge_wintv_hvr_900_analog,
1395 		} },
1396 	},
1397 	[EM2880_BOARD_TERRATEC_HYBRID_XS] = {
1398 		.name           = "Terratec Hybrid XS",
1399 		.tuner_type     = TUNER_XC2028,
1400 		.tuner_gpio     = default_tuner_gpio,
1401 		.decoder        = EM28XX_TVP5150,
1402 		.has_dvb        = 1,
1403 		.dvb_gpio       = default_digital,
1404 		.ir_codes       = RC_MAP_TERRATEC_CINERGY_XS,
1405 		.xclk           = EM28XX_XCLK_FREQUENCY_12MHZ, /* NEC IR */
1406 		.input          = { {
1407 			.type     = EM28XX_VMUX_TELEVISION,
1408 			.vmux     = TVP5150_COMPOSITE0,
1409 			.amux     = EM28XX_AMUX_VIDEO,
1410 			.gpio     = default_analog,
1411 		}, {
1412 			.type     = EM28XX_VMUX_COMPOSITE,
1413 			.vmux     = TVP5150_COMPOSITE1,
1414 			.amux     = EM28XX_AMUX_LINE_IN,
1415 			.gpio     = default_analog,
1416 		}, {
1417 			.type     = EM28XX_VMUX_SVIDEO,
1418 			.vmux     = TVP5150_SVIDEO,
1419 			.amux     = EM28XX_AMUX_LINE_IN,
1420 			.gpio     = default_analog,
1421 		} },
1422 	},
1423 	/* maybe there's a reason behind it why Terratec sells the Hybrid XS
1424 	   as Prodigy XS with a different PID, let's keep it separated for now
1425 	   maybe we'll need it lateron */
1426 	[EM2880_BOARD_TERRATEC_PRODIGY_XS] = {
1427 		.name         = "Terratec Prodigy XS",
1428 		.tuner_type   = TUNER_XC2028,
1429 		.tuner_gpio   = default_tuner_gpio,
1430 		.decoder      = EM28XX_TVP5150,
1431 		.input        = { {
1432 			.type     = EM28XX_VMUX_TELEVISION,
1433 			.vmux     = TVP5150_COMPOSITE0,
1434 			.amux     = EM28XX_AMUX_VIDEO,
1435 			.gpio     = hauppauge_wintv_hvr_900_analog,
1436 		}, {
1437 			.type     = EM28XX_VMUX_COMPOSITE,
1438 			.vmux     = TVP5150_COMPOSITE1,
1439 			.amux     = EM28XX_AMUX_LINE_IN,
1440 			.gpio     = hauppauge_wintv_hvr_900_analog,
1441 		}, {
1442 			.type     = EM28XX_VMUX_SVIDEO,
1443 			.vmux     = TVP5150_SVIDEO,
1444 			.amux     = EM28XX_AMUX_LINE_IN,
1445 			.gpio     = hauppauge_wintv_hvr_900_analog,
1446 		} },
1447 	},
1448 	[EM2820_BOARD_MSI_VOX_USB_2] = {
1449 		.name		   = "MSI VOX USB 2.0",
1450 		.tuner_type	   = TUNER_LG_PAL_NEW_TAPC,
1451 		.tda9887_conf	   = TDA9887_PRESENT      |
1452 				     TDA9887_PORT1_ACTIVE |
1453 				     TDA9887_PORT2_ACTIVE,
1454 		.max_range_640_480 = 1,
1455 		.decoder           = EM28XX_SAA711X,
1456 		.input             = { {
1457 			.type      = EM28XX_VMUX_TELEVISION,
1458 			.vmux      = SAA7115_COMPOSITE4,
1459 			.amux      = EM28XX_AMUX_VIDEO,
1460 		}, {
1461 			.type      = EM28XX_VMUX_COMPOSITE,
1462 			.vmux      = SAA7115_COMPOSITE0,
1463 			.amux      = EM28XX_AMUX_LINE_IN,
1464 		}, {
1465 			.type      = EM28XX_VMUX_SVIDEO,
1466 			.vmux      = SAA7115_SVIDEO3,
1467 			.amux      = EM28XX_AMUX_LINE_IN,
1468 		} },
1469 	},
1470 	[EM2800_BOARD_TERRATEC_CINERGY_200] = {
1471 		.name         = "Terratec Cinergy 200 USB",
1472 		.is_em2800    = 1,
1473 		.has_ir_i2c   = 1,
1474 		.tuner_type   = TUNER_LG_TALN,
1475 		.tda9887_conf = TDA9887_PRESENT,
1476 		.decoder      = EM28XX_SAA711X,
1477 		.input        = { {
1478 			.type     = EM28XX_VMUX_TELEVISION,
1479 			.vmux     = SAA7115_COMPOSITE2,
1480 			.amux     = EM28XX_AMUX_VIDEO,
1481 		}, {
1482 			.type     = EM28XX_VMUX_COMPOSITE,
1483 			.vmux     = SAA7115_COMPOSITE0,
1484 			.amux     = EM28XX_AMUX_LINE_IN,
1485 		}, {
1486 			.type     = EM28XX_VMUX_SVIDEO,
1487 			.vmux     = SAA7115_SVIDEO3,
1488 			.amux     = EM28XX_AMUX_LINE_IN,
1489 		} },
1490 	},
1491 	[EM2800_BOARD_GRABBEEX_USB2800] = {
1492 		.name       = "eMPIA Technology, Inc. GrabBeeX+ Video Encoder",
1493 		.is_em2800  = 1,
1494 		.decoder    = EM28XX_SAA711X,
1495 		.tuner_type = TUNER_ABSENT, /* capture only board */
1496 		.input      = { {
1497 			.type     = EM28XX_VMUX_COMPOSITE,
1498 			.vmux     = SAA7115_COMPOSITE0,
1499 			.amux     = EM28XX_AMUX_LINE_IN,
1500 		}, {
1501 			.type     = EM28XX_VMUX_SVIDEO,
1502 			.vmux     = SAA7115_SVIDEO3,
1503 			.amux     = EM28XX_AMUX_LINE_IN,
1504 		} },
1505 	},
1506 	[EM2800_BOARD_VC211A] = {
1507 		.name         = "Actionmaster/LinXcel/Digitus VC211A",
1508 		.is_em2800    = 1,
1509 		.tuner_type   = TUNER_ABSENT,	/* Capture-only board */
1510 		.decoder      = EM28XX_SAA711X,
1511 		.input        = { {
1512 			.type     = EM28XX_VMUX_COMPOSITE,
1513 			.vmux     = SAA7115_COMPOSITE0,
1514 			.amux     = EM28XX_AMUX_LINE_IN,
1515 			.gpio     = vc211a_enable,
1516 		}, {
1517 			.type     = EM28XX_VMUX_SVIDEO,
1518 			.vmux     = SAA7115_SVIDEO3,
1519 			.amux     = EM28XX_AMUX_LINE_IN,
1520 			.gpio     = vc211a_enable,
1521 		} },
1522 	},
1523 	[EM2800_BOARD_LEADTEK_WINFAST_USBII] = {
1524 		.name         = "Leadtek Winfast USB II",
1525 		.is_em2800    = 1,
1526 		.tuner_type   = TUNER_LG_PAL_NEW_TAPC,
1527 		.tda9887_conf = TDA9887_PRESENT,
1528 		.decoder      = EM28XX_SAA711X,
1529 		.input        = { {
1530 			.type     = EM28XX_VMUX_TELEVISION,
1531 			.vmux     = SAA7115_COMPOSITE2,
1532 			.amux     = EM28XX_AMUX_VIDEO,
1533 		}, {
1534 			.type     = EM28XX_VMUX_COMPOSITE,
1535 			.vmux     = SAA7115_COMPOSITE0,
1536 			.amux     = EM28XX_AMUX_LINE_IN,
1537 		}, {
1538 			.type     = EM28XX_VMUX_SVIDEO,
1539 			.vmux     = SAA7115_SVIDEO3,
1540 			.amux     = EM28XX_AMUX_LINE_IN,
1541 		} },
1542 	},
1543 	[EM2800_BOARD_KWORLD_USB2800] = {
1544 		.name         = "Kworld USB2800",
1545 		.is_em2800    = 1,
1546 		.tuner_type   = TUNER_PHILIPS_FCV1236D,
1547 		.tda9887_conf = TDA9887_PRESENT,
1548 		.decoder      = EM28XX_SAA711X,
1549 		.input        = { {
1550 			.type     = EM28XX_VMUX_TELEVISION,
1551 			.vmux     = SAA7115_COMPOSITE2,
1552 			.amux     = EM28XX_AMUX_VIDEO,
1553 		}, {
1554 			.type     = EM28XX_VMUX_COMPOSITE,
1555 			.vmux     = SAA7115_COMPOSITE0,
1556 			.amux     = EM28XX_AMUX_LINE_IN,
1557 		}, {
1558 			.type     = EM28XX_VMUX_SVIDEO,
1559 			.vmux     = SAA7115_SVIDEO3,
1560 			.amux     = EM28XX_AMUX_LINE_IN,
1561 		} },
1562 	},
1563 	[EM2820_BOARD_PINNACLE_DVC_90] = {
1564 		.name	      = "Pinnacle Dazzle DVC 90/100/101/107 / Kaiser Baas Video to DVD maker / 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 	dev_warn(&dev->intf->dev, "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 			dev_err(&dev->intf->dev,
2835 				"Your board has no unique USB ID.\n"
2836 				"A hint were successfully done, based on eeprom hash.\n"
2837 				"This method is not 100%% failproof.\n"
2838 				"If the board were missdetected, please email this log to:\n"
2839 				"\tV4L Mailing List  <linux-media@vger.kernel.org>\n"
2840 				"Board detected as %s\n",
2841 			       em28xx_boards[dev->model].name);
2842 
2843 			return 0;
2844 		}
2845 	}
2846 
2847 	/* HINT method: I2C attached devices
2848 	 *
2849 	 * This method works for all boards.
2850 	 * Uses a hash of i2c scanned devices.
2851 	 * Devices with the same i2c attached chips will
2852 	 * be considered equal.
2853 	 * This method is less precise than the eeprom one.
2854 	 */
2855 
2856 	/* user did not request i2c scanning => do it now */
2857 	if (!dev->i2c_hash)
2858 		em28xx_do_i2c_scan(dev, dev->def_i2c_bus);
2859 
2860 	for (i = 0; i < ARRAY_SIZE(em28xx_i2c_hash); i++) {
2861 		if (dev->i2c_hash == em28xx_i2c_hash[i].hash) {
2862 			dev->model = em28xx_i2c_hash[i].model;
2863 			dev->tuner_type = em28xx_i2c_hash[i].tuner;
2864 			dev_err(&dev->intf->dev,
2865 				"Your board has no unique USB ID.\n"
2866 				"A hint were successfully done, based on i2c devicelist hash.\n"
2867 				"This method is not 100%% failproof.\n"
2868 				"If the board were missdetected, please email this log to:\n"
2869 				"\tV4L Mailing List  <linux-media@vger.kernel.org>\n"
2870 				"Board detected as %s\n",
2871 				em28xx_boards[dev->model].name);
2872 
2873 			return 0;
2874 		}
2875 	}
2876 
2877 	dev_err(&dev->intf->dev,
2878 		"Your board has no unique USB ID and thus need a hint to be detected.\n"
2879 		"You may try to use card=<n> insmod option to workaround that.\n"
2880 		"Please send an email with this log to:\n"
2881 		"\tV4L Mailing List <linux-media@vger.kernel.org>\n"
2882 		"Board eeprom hash is 0x%08lx\n"
2883 		"Board i2c devicelist hash is 0x%08lx\n",
2884 		dev->hash, dev->i2c_hash);
2885 
2886 	dev_err(&dev->intf->dev,
2887 		"Here is a list of valid choices for the card=<n> insmod option:\n");
2888 	for (i = 0; i < em28xx_bcount; i++) {
2889 		dev_err(&dev->intf->dev,
2890 			"    card=%d -> %s\n", i, em28xx_boards[i].name);
2891 	}
2892 	return -1;
2893 }
2894 
2895 static void em28xx_card_setup(struct em28xx *dev)
2896 {
2897 	/*
2898 	 * If the device can be a webcam, seek for a sensor.
2899 	 * If sensor is not found, then it isn't a webcam.
2900 	 */
2901 	if (dev->board.is_webcam) {
2902 		if (em28xx_detect_sensor(dev) < 0)
2903 			dev->board.is_webcam = 0;
2904 	}
2905 
2906 	switch (dev->model) {
2907 	case EM2750_BOARD_UNKNOWN:
2908 	case EM2820_BOARD_UNKNOWN:
2909 	case EM2800_BOARD_UNKNOWN:
2910 		/*
2911 		 * The K-WORLD DVB-T 310U is detected as an MSI Digivox AD.
2912 		 *
2913 		 * This occurs because they share identical USB vendor and
2914 		 * product IDs.
2915 		 *
2916 		 * What we do here is look up the EEPROM hash of the K-WORLD
2917 		 * and if it is found then we decide that we do not have
2918 		 * a DIGIVOX and reset the device to the K-WORLD instead.
2919 		 *
2920 		 * This solution is only valid if they do not share eeprom
2921 		 * hash identities which has not been determined as yet.
2922 		 */
2923 		if (em28xx_hint_board(dev) < 0)
2924 			dev_err(&dev->intf->dev, "Board not discovered\n");
2925 		else {
2926 			em28xx_set_model(dev);
2927 			em28xx_pre_card_setup(dev);
2928 		}
2929 		break;
2930 	default:
2931 		em28xx_set_model(dev);
2932 	}
2933 
2934 	dev_info(&dev->intf->dev, "Identified as %s (card=%d)\n",
2935 		dev->board.name, dev->model);
2936 
2937 	dev->tuner_type = em28xx_boards[dev->model].tuner_type;
2938 
2939 	/* request some modules */
2940 	switch (dev->model) {
2941 	case EM2820_BOARD_HAUPPAUGE_WINTV_USB_2:
2942 	case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900:
2943 	case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900_R2:
2944 	case EM2883_BOARD_HAUPPAUGE_WINTV_HVR_850:
2945 	case EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950:
2946 	case EM2884_BOARD_HAUPPAUGE_WINTV_HVR_930C:
2947 	case EM28174_BOARD_HAUPPAUGE_WINTV_DUALHD_DVB:
2948 	{
2949 		struct tveeprom tv;
2950 
2951 		if (dev->eedata == NULL)
2952 			break;
2953 #if defined(CONFIG_MODULES) && defined(MODULE)
2954 		request_module("tveeprom");
2955 #endif
2956 		/* Call first TVeeprom */
2957 
2958 		dev->i2c_client[dev->def_i2c_bus].addr = 0xa0 >> 1;
2959 		tveeprom_hauppauge_analog(&dev->i2c_client[dev->def_i2c_bus], &tv, dev->eedata);
2960 
2961 		dev->tuner_type = tv.tuner_type;
2962 
2963 		if (tv.audio_processor == TVEEPROM_AUDPROC_MSP) {
2964 			dev->i2s_speed = 2048000;
2965 			dev->board.has_msp34xx = 1;
2966 		}
2967 		break;
2968 	}
2969 	case EM2882_BOARD_KWORLD_ATSC_315U:
2970 		em28xx_write_reg(dev, 0x0d, 0x42);
2971 		msleep(10);
2972 		em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xfd);
2973 		msleep(10);
2974 		break;
2975 	case EM2820_BOARD_KWORLD_PVRTV2800RF:
2976 		/* GPIO enables sound on KWORLD PVR TV 2800RF */
2977 		em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xf9);
2978 		break;
2979 	case EM2820_BOARD_UNKNOWN:
2980 	case EM2800_BOARD_UNKNOWN:
2981 		/*
2982 		 * The K-WORLD DVB-T 310U is detected as an MSI Digivox AD.
2983 		 *
2984 		 * This occurs because they share identical USB vendor and
2985 		 * product IDs.
2986 		 *
2987 		 * What we do here is look up the EEPROM hash of the K-WORLD
2988 		 * and if it is found then we decide that we do not have
2989 		 * a DIGIVOX and reset the device to the K-WORLD instead.
2990 		 *
2991 		 * This solution is only valid if they do not share eeprom
2992 		 * hash identities which has not been determined as yet.
2993 		 */
2994 	case EM2880_BOARD_MSI_DIGIVOX_AD:
2995 		if (!em28xx_hint_board(dev))
2996 			em28xx_set_model(dev);
2997 
2998 		/* In cases where we had to use a board hint, the call to
2999 		   em28xx_set_mode() in em28xx_pre_card_setup() was a no-op,
3000 		   so make the call now so the analog GPIOs are set properly
3001 		   before probing the i2c bus. */
3002 		em28xx_gpio_set(dev, dev->board.tuner_gpio);
3003 		em28xx_set_mode(dev, EM28XX_ANALOG_MODE);
3004 		break;
3005 
3006 		/*
3007 		 * The Dikom DK300 is detected as an Kworld VS-DVB-T 323UR.
3008 		 *
3009 		 * This occurs because they share identical USB vendor and
3010 		 * product IDs.
3011 		 *
3012 		 * What we do here is look up the EEPROM hash of the Dikom
3013 		 * and if it is found then we decide that we do not have
3014 		 * a Kworld and reset the device to the Dikom instead.
3015 		 *
3016 		 * This solution is only valid if they do not share eeprom
3017 		 * hash identities which has not been determined as yet.
3018 		 */
3019 	case EM2882_BOARD_KWORLD_VS_DVBT:
3020 		if (!em28xx_hint_board(dev))
3021 			em28xx_set_model(dev);
3022 
3023 		/* In cases where we had to use a board hint, the call to
3024 		   em28xx_set_mode() in em28xx_pre_card_setup() was a no-op,
3025 		   so make the call now so the analog GPIOs are set properly
3026 		   before probing the i2c bus. */
3027 		em28xx_gpio_set(dev, dev->board.tuner_gpio);
3028 		em28xx_set_mode(dev, EM28XX_ANALOG_MODE);
3029 		break;
3030 	}
3031 
3032 	if (dev->board.valid == EM28XX_BOARD_NOT_VALIDATED) {
3033 		dev_err(&dev->intf->dev,
3034 			"\n\n"
3035 			"The support for this board weren't valid yet.\n"
3036 			"Please send a report of having this working\n"
3037 			"not to V4L mailing list (and/or to other addresses)\n\n");
3038 	}
3039 
3040 	/* Free eeprom data memory */
3041 	kfree(dev->eedata);
3042 	dev->eedata = NULL;
3043 
3044 	/* Allow override tuner type by a module parameter */
3045 	if (tuner >= 0)
3046 		dev->tuner_type = tuner;
3047 }
3048 
3049 void em28xx_setup_xc3028(struct em28xx *dev, struct xc2028_ctrl *ctl)
3050 {
3051 	memset(ctl, 0, sizeof(*ctl));
3052 
3053 	ctl->fname   = XC2028_DEFAULT_FIRMWARE;
3054 	ctl->max_len = 64;
3055 	ctl->mts = em28xx_boards[dev->model].mts_firmware;
3056 
3057 	switch (dev->model) {
3058 	case EM2880_BOARD_EMPIRE_DUAL_TV:
3059 	case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900:
3060 	case EM2882_BOARD_TERRATEC_HYBRID_XS:
3061 		ctl->demod = XC3028_FE_ZARLINK456;
3062 		break;
3063 	case EM2880_BOARD_TERRATEC_HYBRID_XS:
3064 	case EM2880_BOARD_TERRATEC_HYBRID_XS_FR:
3065 	case EM2881_BOARD_PINNACLE_HYBRID_PRO:
3066 		ctl->demod = XC3028_FE_ZARLINK456;
3067 		break;
3068 	case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900_R2:
3069 	case EM2882_BOARD_PINNACLE_HYBRID_PRO_330E:
3070 		ctl->demod = XC3028_FE_DEFAULT;
3071 		break;
3072 	case EM2880_BOARD_AMD_ATI_TV_WONDER_HD_600:
3073 		ctl->demod = XC3028_FE_DEFAULT;
3074 		ctl->fname = XC3028L_DEFAULT_FIRMWARE;
3075 		break;
3076 	case EM2883_BOARD_HAUPPAUGE_WINTV_HVR_850:
3077 	case EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950:
3078 	case EM2880_BOARD_PINNACLE_PCTV_HD_PRO:
3079 		/* FIXME: Better to specify the needed IF */
3080 		ctl->demod = XC3028_FE_DEFAULT;
3081 		break;
3082 	case EM2883_BOARD_KWORLD_HYBRID_330U:
3083 	case EM2882_BOARD_DIKOM_DK300:
3084 	case EM2882_BOARD_KWORLD_VS_DVBT:
3085 		ctl->demod = XC3028_FE_CHINA;
3086 		ctl->fname = XC2028_DEFAULT_FIRMWARE;
3087 		break;
3088 	case EM2882_BOARD_EVGA_INDTUBE:
3089 		ctl->demod = XC3028_FE_CHINA;
3090 		ctl->fname = XC3028L_DEFAULT_FIRMWARE;
3091 		break;
3092 	default:
3093 		ctl->demod = XC3028_FE_OREN538;
3094 	}
3095 }
3096 EXPORT_SYMBOL_GPL(em28xx_setup_xc3028);
3097 
3098 static void request_module_async(struct work_struct *work)
3099 {
3100 	struct em28xx *dev = container_of(work,
3101 			     struct em28xx, request_module_wk);
3102 
3103 	/*
3104 	 * The em28xx extensions can be modules or builtin. If the
3105 	 * modules are already loaded or are built in, those extensions
3106 	 * can be initialised right now. Otherwise, the module init
3107 	 * code will do it.
3108 	 */
3109 
3110 	/*
3111 	 * Devicdes with an audio-only interface also have a V4L/DVB/RC
3112 	 * interface. Don't register extensions twice on those devices.
3113 	 */
3114 	if (dev->is_audio_only) {
3115 #if defined(CONFIG_MODULES) && defined(MODULE)
3116 		request_module("em28xx-alsa");
3117 #endif
3118 		return;
3119 	}
3120 
3121 	em28xx_init_extension(dev);
3122 
3123 #if defined(CONFIG_MODULES) && defined(MODULE)
3124 	if (dev->has_video)
3125 		request_module("em28xx-v4l");
3126 	if (dev->usb_audio_type == EM28XX_USB_AUDIO_CLASS)
3127 		request_module("snd-usb-audio");
3128 	else if (dev->usb_audio_type == EM28XX_USB_AUDIO_VENDOR)
3129 		request_module("em28xx-alsa");
3130 	if (dev->board.has_dvb)
3131 		request_module("em28xx-dvb");
3132 	if (dev->board.buttons ||
3133 	    ((dev->board.ir_codes || dev->board.has_ir_i2c) && !disable_ir))
3134 		request_module("em28xx-rc");
3135 #endif /* CONFIG_MODULES */
3136 }
3137 
3138 static void request_modules(struct em28xx *dev)
3139 {
3140 	INIT_WORK(&dev->request_module_wk, request_module_async);
3141 	schedule_work(&dev->request_module_wk);
3142 }
3143 
3144 static void flush_request_modules(struct em28xx *dev)
3145 {
3146 	flush_work(&dev->request_module_wk);
3147 }
3148 
3149 static int em28xx_media_device_init(struct em28xx *dev,
3150 				    struct usb_device *udev)
3151 {
3152 #ifdef CONFIG_MEDIA_CONTROLLER
3153 	struct media_device *mdev;
3154 
3155 	mdev = kzalloc(sizeof(*mdev), GFP_KERNEL);
3156 	if (!mdev)
3157 		return -ENOMEM;
3158 
3159 	if (udev->product)
3160 		media_device_usb_init(mdev, udev, udev->product);
3161 	else if (udev->manufacturer)
3162 		media_device_usb_init(mdev, udev, udev->manufacturer);
3163 	else
3164 		media_device_usb_init(mdev, udev, dev_name(&dev->intf->dev));
3165 
3166 	dev->media_dev = mdev;
3167 #endif
3168 	return 0;
3169 }
3170 
3171 static void em28xx_unregister_media_device(struct em28xx *dev)
3172 {
3173 
3174 #ifdef CONFIG_MEDIA_CONTROLLER
3175 	if (dev->media_dev) {
3176 		media_device_unregister(dev->media_dev);
3177 		media_device_cleanup(dev->media_dev);
3178 		kfree(dev->media_dev);
3179 		dev->media_dev = NULL;
3180 	}
3181 #endif
3182 }
3183 
3184 /*
3185  * em28xx_release_resources()
3186  * unregisters the v4l2,i2c and usb devices
3187  * called when the device gets disconnected or at module unload
3188 */
3189 static void em28xx_release_resources(struct em28xx *dev)
3190 {
3191 	struct usb_device *udev = interface_to_usbdev(dev->intf);
3192 
3193 	/*FIXME: I2C IR should be disconnected */
3194 
3195 	mutex_lock(&dev->lock);
3196 
3197 	em28xx_unregister_media_device(dev);
3198 
3199 	if (dev->def_i2c_bus)
3200 		em28xx_i2c_unregister(dev, 1);
3201 	em28xx_i2c_unregister(dev, 0);
3202 
3203 	usb_put_dev(udev);
3204 
3205 	/* Mark device as unused */
3206 	clear_bit(dev->devno, em28xx_devused);
3207 
3208 	mutex_unlock(&dev->lock);
3209 };
3210 
3211 /**
3212  * em28xx_free_device() - Free em28xx device
3213  *
3214  * @ref: struct kref for em28xx device
3215  *
3216  * This is called when all extensions and em28xx core unregisters a device
3217  */
3218 void em28xx_free_device(struct kref *ref)
3219 {
3220 	struct em28xx *dev = kref_to_dev(ref);
3221 
3222 	dev_info(&dev->intf->dev, "Freeing device\n");
3223 
3224 	if (!dev->disconnected)
3225 		em28xx_release_resources(dev);
3226 
3227 	kfree(dev->alt_max_pkt_size_isoc);
3228 	kfree(dev);
3229 }
3230 EXPORT_SYMBOL_GPL(em28xx_free_device);
3231 
3232 /*
3233  * em28xx_init_dev()
3234  * allocates and inits the device structs, registers i2c bus and v4l device
3235  */
3236 static int em28xx_init_dev(struct em28xx *dev, struct usb_device *udev,
3237 			   struct usb_interface *interface,
3238 			   int minor)
3239 {
3240 	int retval;
3241 	const char *chip_name = NULL;
3242 
3243 	dev->intf = interface;
3244 	mutex_init(&dev->ctrl_urb_lock);
3245 	spin_lock_init(&dev->slock);
3246 
3247 	dev->em28xx_write_regs = em28xx_write_regs;
3248 	dev->em28xx_read_reg = em28xx_read_reg;
3249 	dev->em28xx_read_reg_req_len = em28xx_read_reg_req_len;
3250 	dev->em28xx_write_regs_req = em28xx_write_regs_req;
3251 	dev->em28xx_read_reg_req = em28xx_read_reg_req;
3252 	dev->board.is_em2800 = em28xx_boards[dev->model].is_em2800;
3253 
3254 	em28xx_set_model(dev);
3255 
3256 	dev->wait_after_write = 5;
3257 
3258 	/* Based on the Chip ID, set the device configuration */
3259 	retval = em28xx_read_reg(dev, EM28XX_R0A_CHIPID);
3260 	if (retval > 0) {
3261 		dev->chip_id = retval;
3262 
3263 		switch (dev->chip_id) {
3264 		case CHIP_ID_EM2800:
3265 			chip_name = "em2800";
3266 			break;
3267 		case CHIP_ID_EM2710:
3268 			chip_name = "em2710";
3269 			break;
3270 		case CHIP_ID_EM2750:
3271 			chip_name = "em2750";
3272 			break;
3273 		case CHIP_ID_EM2765:
3274 			chip_name = "em2765";
3275 			dev->wait_after_write = 0;
3276 			dev->is_em25xx = 1;
3277 			dev->eeprom_addrwidth_16bit = 1;
3278 			break;
3279 		case CHIP_ID_EM2820:
3280 			chip_name = "em2710/2820";
3281 			if (le16_to_cpu(udev->descriptor.idVendor) == 0xeb1a) {
3282 				__le16 idProd = udev->descriptor.idProduct;
3283 
3284 				if (le16_to_cpu(idProd) == 0x2710)
3285 					chip_name = "em2710";
3286 				else if (le16_to_cpu(idProd) == 0x2820)
3287 					chip_name = "em2820";
3288 			}
3289 			/* NOTE: the em2820 is used in webcams, too ! */
3290 			break;
3291 		case CHIP_ID_EM2840:
3292 			chip_name = "em2840";
3293 			break;
3294 		case CHIP_ID_EM2860:
3295 			chip_name = "em2860";
3296 			break;
3297 		case CHIP_ID_EM2870:
3298 			chip_name = "em2870";
3299 			dev->wait_after_write = 0;
3300 			break;
3301 		case CHIP_ID_EM2874:
3302 			chip_name = "em2874";
3303 			dev->wait_after_write = 0;
3304 			dev->eeprom_addrwidth_16bit = 1;
3305 			break;
3306 		case CHIP_ID_EM28174:
3307 			chip_name = "em28174";
3308 			dev->wait_after_write = 0;
3309 			dev->eeprom_addrwidth_16bit = 1;
3310 			break;
3311 		case CHIP_ID_EM28178:
3312 			chip_name = "em28178";
3313 			dev->wait_after_write = 0;
3314 			dev->eeprom_addrwidth_16bit = 1;
3315 			break;
3316 		case CHIP_ID_EM2883:
3317 			chip_name = "em2882/3";
3318 			dev->wait_after_write = 0;
3319 			break;
3320 		case CHIP_ID_EM2884:
3321 			chip_name = "em2884";
3322 			dev->wait_after_write = 0;
3323 			dev->eeprom_addrwidth_16bit = 1;
3324 			break;
3325 		}
3326 	}
3327 	if (!chip_name)
3328 		dev_info(&dev->intf->dev,
3329 			 "unknown em28xx chip ID (%d)\n", dev->chip_id);
3330 	else
3331 		dev_info(&dev->intf->dev, "chip ID is %s\n", chip_name);
3332 
3333 	em28xx_media_device_init(dev, udev);
3334 
3335 	if (dev->is_audio_only) {
3336 		retval = em28xx_audio_setup(dev);
3337 		if (retval)
3338 			return -ENODEV;
3339 		em28xx_init_extension(dev);
3340 
3341 		return 0;
3342 	}
3343 
3344 	em28xx_pre_card_setup(dev);
3345 
3346 	if (!dev->board.is_em2800) {
3347 		/* Resets I2C speed */
3348 		retval = em28xx_write_reg(dev, EM28XX_R06_I2C_CLK, dev->board.i2c_speed);
3349 		if (retval < 0) {
3350 			dev_err(&dev->intf->dev,
3351 			       "%s: em28xx_write_reg failed! retval [%d]\n",
3352 			       __func__, retval);
3353 			return retval;
3354 		}
3355 	}
3356 
3357 	rt_mutex_init(&dev->i2c_bus_lock);
3358 
3359 	/* register i2c bus 0 */
3360 	if (dev->board.is_em2800)
3361 		retval = em28xx_i2c_register(dev, 0, EM28XX_I2C_ALGO_EM2800);
3362 	else
3363 		retval = em28xx_i2c_register(dev, 0, EM28XX_I2C_ALGO_EM28XX);
3364 	if (retval < 0) {
3365 		dev_err(&dev->intf->dev,
3366 			"%s: em28xx_i2c_register bus 0 - error [%d]!\n",
3367 		       __func__, retval);
3368 		return retval;
3369 	}
3370 
3371 	/* register i2c bus 1 */
3372 	if (dev->def_i2c_bus) {
3373 		if (dev->is_em25xx)
3374 			retval = em28xx_i2c_register(dev, 1,
3375 						     EM28XX_I2C_ALGO_EM25XX_BUS_B);
3376 		else
3377 			retval = em28xx_i2c_register(dev, 1,
3378 						     EM28XX_I2C_ALGO_EM28XX);
3379 		if (retval < 0) {
3380 			dev_err(&dev->intf->dev,
3381 			       "%s: em28xx_i2c_register bus 1 - error [%d]!\n",
3382 			       __func__, retval);
3383 
3384 			em28xx_i2c_unregister(dev, 0);
3385 
3386 			return retval;
3387 		}
3388 	}
3389 
3390 	/* Do board specific init and eeprom reading */
3391 	em28xx_card_setup(dev);
3392 
3393 	return 0;
3394 }
3395 
3396 /* high bandwidth multiplier, as encoded in highspeed endpoint descriptors */
3397 #define hb_mult(wMaxPacketSize) (1 + (((wMaxPacketSize) >> 11) & 0x03))
3398 
3399 /*
3400  * em28xx_usb_probe()
3401  * checks for supported devices
3402  */
3403 static int em28xx_usb_probe(struct usb_interface *interface,
3404 			    const struct usb_device_id *id)
3405 {
3406 	struct usb_device *udev;
3407 	struct em28xx *dev = NULL;
3408 	int retval;
3409 	bool has_vendor_audio = false, has_video = false, has_dvb = false;
3410 	int i, nr, try_bulk;
3411 	const int ifnum = interface->altsetting[0].desc.bInterfaceNumber;
3412 	char *speed;
3413 
3414 	udev = usb_get_dev(interface_to_usbdev(interface));
3415 
3416 	/* Check to see next free device and mark as used */
3417 	do {
3418 		nr = find_first_zero_bit(em28xx_devused, EM28XX_MAXBOARDS);
3419 		if (nr >= EM28XX_MAXBOARDS) {
3420 			/* No free device slots */
3421 			dev_err(&interface->dev,
3422 				"Driver supports up to %i em28xx boards.\n",
3423 			       EM28XX_MAXBOARDS);
3424 			retval = -ENOMEM;
3425 			goto err_no_slot;
3426 		}
3427 	} while (test_and_set_bit(nr, em28xx_devused));
3428 
3429 	/* Don't register audio interfaces */
3430 	if (interface->altsetting[0].desc.bInterfaceClass == USB_CLASS_AUDIO) {
3431 		dev_err(&interface->dev,
3432 			"audio device (%04x:%04x): interface %i, class %i\n",
3433 			le16_to_cpu(udev->descriptor.idVendor),
3434 			le16_to_cpu(udev->descriptor.idProduct),
3435 			ifnum,
3436 			interface->altsetting[0].desc.bInterfaceClass);
3437 
3438 		retval = -ENODEV;
3439 		goto err;
3440 	}
3441 
3442 	/* allocate memory for our device state and initialize it */
3443 	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
3444 	if (dev == NULL) {
3445 		retval = -ENOMEM;
3446 		goto err;
3447 	}
3448 
3449 	/* compute alternate max packet sizes */
3450 	dev->alt_max_pkt_size_isoc =
3451 				kmalloc(sizeof(dev->alt_max_pkt_size_isoc[0]) *
3452 					interface->num_altsetting, GFP_KERNEL);
3453 	if (dev->alt_max_pkt_size_isoc == NULL) {
3454 		kfree(dev);
3455 		retval = -ENOMEM;
3456 		goto err;
3457 	}
3458 
3459 	/* Get endpoints */
3460 	for (i = 0; i < interface->num_altsetting; i++) {
3461 		int ep;
3462 
3463 		for (ep = 0; ep < interface->altsetting[i].desc.bNumEndpoints; ep++) {
3464 			const struct usb_endpoint_descriptor *e;
3465 			int sizedescr, size;
3466 
3467 			e = &interface->altsetting[i].endpoint[ep].desc;
3468 
3469 			sizedescr = le16_to_cpu(e->wMaxPacketSize);
3470 			size = sizedescr & 0x7ff;
3471 
3472 			if (udev->speed == USB_SPEED_HIGH)
3473 				size = size * hb_mult(sizedescr);
3474 
3475 			if (usb_endpoint_dir_in(e)) {
3476 				switch (e->bEndpointAddress) {
3477 				case 0x82:
3478 					has_video = true;
3479 					if (usb_endpoint_xfer_isoc(e)) {
3480 						dev->analog_ep_isoc =
3481 							    e->bEndpointAddress;
3482 						dev->alt_max_pkt_size_isoc[i] = size;
3483 					} else if (usb_endpoint_xfer_bulk(e)) {
3484 						dev->analog_ep_bulk =
3485 							    e->bEndpointAddress;
3486 					}
3487 					break;
3488 				case 0x83:
3489 					if (usb_endpoint_xfer_isoc(e)) {
3490 						has_vendor_audio = true;
3491 					} else {
3492 						dev_err(&interface->dev,
3493 							"error: skipping audio endpoint 0x83, because it uses bulk transfers !\n");
3494 					}
3495 					break;
3496 				case 0x84:
3497 					if (has_video &&
3498 					    (usb_endpoint_xfer_bulk(e))) {
3499 						dev->analog_ep_bulk =
3500 							    e->bEndpointAddress;
3501 					} else {
3502 						if (usb_endpoint_xfer_isoc(e)) {
3503 							if (size > dev->dvb_max_pkt_size_isoc) {
3504 								has_dvb = true; /* see NOTE (~) */
3505 								dev->dvb_ep_isoc = e->bEndpointAddress;
3506 								dev->dvb_max_pkt_size_isoc = size;
3507 								dev->dvb_alt_isoc = i;
3508 							}
3509 						} else {
3510 							has_dvb = true;
3511 							dev->dvb_ep_bulk = e->bEndpointAddress;
3512 						}
3513 					}
3514 					break;
3515 				}
3516 			}
3517 			/* NOTE:
3518 			 * Old logic with support for isoc transfers only was:
3519 			 *  0x82	isoc		=> analog
3520 			 *  0x83	isoc		=> audio
3521 			 *  0x84	isoc		=> digital
3522 			 *
3523 			 * New logic with support for bulk transfers
3524 			 *  0x82	isoc		=> analog
3525 			 *  0x82	bulk		=> analog
3526 			 *  0x83	isoc*		=> audio
3527 			 *  0x84	isoc		=> digital
3528 			 *  0x84	bulk		=> analog or digital**
3529 			 * (*: audio should always be isoc)
3530 			 * (**: analog, if ep 0x82 is isoc, otherwise digital)
3531 			 *
3532 			 * The new logic preserves backwards compatibility and
3533 			 * reflects the endpoint configurations we have seen
3534 			 * so far. But there might be devices for which this
3535 			 * logic is not sufficient...
3536 			 */
3537 			/*
3538 			 * NOTE (~): some manufacturers (e.g. Terratec) disable
3539 			 * endpoints by setting wMaxPacketSize to 0 bytes for
3540 			 * all alt settings. So far, we've seen this for
3541 			 * DVB isoc endpoints only.
3542 			 */
3543 		}
3544 	}
3545 
3546 	if (!(has_vendor_audio || has_video || has_dvb)) {
3547 		retval = -ENODEV;
3548 		goto err_free;
3549 	}
3550 
3551 	switch (udev->speed) {
3552 	case USB_SPEED_LOW:
3553 		speed = "1.5";
3554 		break;
3555 	case USB_SPEED_UNKNOWN:
3556 	case USB_SPEED_FULL:
3557 		speed = "12";
3558 		break;
3559 	case USB_SPEED_HIGH:
3560 		speed = "480";
3561 		break;
3562 	default:
3563 		speed = "unknown";
3564 	}
3565 
3566 	dev_err(&interface->dev,
3567 		"New device %s %s @ %s Mbps (%04x:%04x, interface %d, class %d)\n",
3568 		udev->manufacturer ? udev->manufacturer : "",
3569 		udev->product ? udev->product : "",
3570 		speed,
3571 		le16_to_cpu(udev->descriptor.idVendor),
3572 		le16_to_cpu(udev->descriptor.idProduct),
3573 		ifnum,
3574 		interface->altsetting->desc.bInterfaceNumber);
3575 
3576 	/*
3577 	 * Make sure we have 480 Mbps of bandwidth, otherwise things like
3578 	 * video stream wouldn't likely work, since 12 Mbps is generally
3579 	 * not enough even for most Digital TV streams.
3580 	 */
3581 	if (udev->speed != USB_SPEED_HIGH && disable_usb_speed_check == 0) {
3582 		dev_err(&interface->dev, "Device initialization failed.\n");
3583 		dev_err(&interface->dev,
3584 			"Device must be connected to a high-speed USB 2.0 port.\n");
3585 		retval = -ENODEV;
3586 		goto err_free;
3587 	}
3588 
3589 	dev->devno = nr;
3590 	dev->model = id->driver_info;
3591 	dev->alt   = -1;
3592 	dev->is_audio_only = has_vendor_audio && !(has_video || has_dvb);
3593 	dev->has_video = has_video;
3594 	dev->ifnum = ifnum;
3595 
3596 	if (has_vendor_audio) {
3597 		dev_err(&interface->dev,
3598 			"Audio interface %i found (Vendor Class)\n", ifnum);
3599 		dev->usb_audio_type = EM28XX_USB_AUDIO_VENDOR;
3600 	}
3601 	/* Checks if audio is provided by a USB Audio Class interface */
3602 	for (i = 0; i < udev->config->desc.bNumInterfaces; i++) {
3603 		struct usb_interface *uif = udev->config->interface[i];
3604 
3605 		if (uif->altsetting[0].desc.bInterfaceClass == USB_CLASS_AUDIO) {
3606 			if (has_vendor_audio)
3607 				dev_err(&interface->dev,
3608 					"em28xx: device seems to have vendor AND usb audio class interfaces !\n"
3609 				       "\t\tThe vendor interface will be ignored. Please contact the developers <linux-media@vger.kernel.org>\n");
3610 			dev->usb_audio_type = EM28XX_USB_AUDIO_CLASS;
3611 			break;
3612 		}
3613 	}
3614 
3615 	if (has_video)
3616 		dev_err(&interface->dev, "Video interface %i found:%s%s\n",
3617 			ifnum,
3618 			dev->analog_ep_bulk ? " bulk" : "",
3619 			dev->analog_ep_isoc ? " isoc" : "");
3620 	if (has_dvb)
3621 		dev_err(&interface->dev, "DVB interface %i found:%s%s\n",
3622 			ifnum,
3623 			dev->dvb_ep_bulk ? " bulk" : "",
3624 			dev->dvb_ep_isoc ? " isoc" : "");
3625 
3626 	dev->num_alt = interface->num_altsetting;
3627 
3628 	if ((unsigned)card[nr] < em28xx_bcount)
3629 		dev->model = card[nr];
3630 
3631 	/* save our data pointer in this interface device */
3632 	usb_set_intfdata(interface, dev);
3633 
3634 	/* allocate device struct and check if the device is a webcam */
3635 	mutex_init(&dev->lock);
3636 	retval = em28xx_init_dev(dev, udev, interface, nr);
3637 	if (retval) {
3638 		goto err_free;
3639 	}
3640 
3641 	if (usb_xfer_mode < 0) {
3642 		if (dev->board.is_webcam)
3643 			try_bulk = 1;
3644 		else
3645 			try_bulk = 0;
3646 	} else {
3647 		try_bulk = usb_xfer_mode > 0;
3648 	}
3649 
3650 	/* Disable V4L2 if the device doesn't have a decoder */
3651 	if (has_video &&
3652 	    dev->board.decoder == EM28XX_NODECODER && !dev->board.is_webcam) {
3653 		dev_err(&interface->dev,
3654 			"Currently, V4L2 is not supported on this model\n");
3655 		has_video = false;
3656 		dev->has_video = false;
3657 	}
3658 
3659 	/* Select USB transfer types to use */
3660 	if (has_video) {
3661 		if (!dev->analog_ep_isoc || (try_bulk && dev->analog_ep_bulk))
3662 			dev->analog_xfer_bulk = 1;
3663 		dev_err(&interface->dev, "analog set to %s mode.\n",
3664 			dev->analog_xfer_bulk ? "bulk" : "isoc");
3665 	}
3666 	if (has_dvb) {
3667 		if (!dev->dvb_ep_isoc || (try_bulk && dev->dvb_ep_bulk))
3668 			dev->dvb_xfer_bulk = 1;
3669 		dev_err(&interface->dev, "dvb set to %s mode.\n",
3670 			dev->dvb_xfer_bulk ? "bulk" : "isoc");
3671 	}
3672 
3673 	kref_init(&dev->ref);
3674 
3675 	request_modules(dev);
3676 
3677 	/*
3678 	 * Do it at the end, to reduce dynamic configuration changes during
3679 	 * the device init. Yet, as request_modules() can be async, the
3680 	 * topology will likely change after the load of the em28xx subdrivers.
3681 	 */
3682 #ifdef CONFIG_MEDIA_CONTROLLER
3683 	retval = media_device_register(dev->media_dev);
3684 #endif
3685 
3686 	return 0;
3687 
3688 err_free:
3689 	kfree(dev->alt_max_pkt_size_isoc);
3690 	kfree(dev);
3691 
3692 err:
3693 	clear_bit(nr, em28xx_devused);
3694 
3695 err_no_slot:
3696 	usb_put_dev(udev);
3697 	return retval;
3698 }
3699 
3700 /*
3701  * em28xx_usb_disconnect()
3702  * called when the device gets disconnected
3703  * video device will be unregistered on v4l2_close in case it is still open
3704  */
3705 static void em28xx_usb_disconnect(struct usb_interface *interface)
3706 {
3707 	struct em28xx *dev;
3708 
3709 	dev = usb_get_intfdata(interface);
3710 	usb_set_intfdata(interface, NULL);
3711 
3712 	if (!dev)
3713 		return;
3714 
3715 	dev->disconnected = 1;
3716 
3717 	dev_err(&dev->intf->dev, "Disconnecting\n");
3718 
3719 	flush_request_modules(dev);
3720 
3721 	em28xx_close_extension(dev);
3722 
3723 	em28xx_release_resources(dev);
3724 	kref_put(&dev->ref, em28xx_free_device);
3725 }
3726 
3727 static int em28xx_usb_suspend(struct usb_interface *interface,
3728 			      pm_message_t message)
3729 {
3730 	struct em28xx *dev;
3731 
3732 	dev = usb_get_intfdata(interface);
3733 	if (!dev)
3734 		return 0;
3735 	em28xx_suspend_extension(dev);
3736 	return 0;
3737 }
3738 
3739 static int em28xx_usb_resume(struct usb_interface *interface)
3740 {
3741 	struct em28xx *dev;
3742 
3743 	dev = usb_get_intfdata(interface);
3744 	if (!dev)
3745 		return 0;
3746 	em28xx_resume_extension(dev);
3747 	return 0;
3748 }
3749 
3750 static struct usb_driver em28xx_usb_driver = {
3751 	.name = "em28xx",
3752 	.probe = em28xx_usb_probe,
3753 	.disconnect = em28xx_usb_disconnect,
3754 	.suspend = em28xx_usb_suspend,
3755 	.resume = em28xx_usb_resume,
3756 	.reset_resume = em28xx_usb_resume,
3757 	.id_table = em28xx_id_table,
3758 };
3759 
3760 module_usb_driver(em28xx_usb_driver);
3761