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