em28xx-cards.c 9.1 KB
Newer Older
1
/*
2
   em28xx-cards.c - driver for Empia EM2800/EM2820/2840 USB video capture devices
3

4 5
   Copyright (C) 2005 Ludovico Cavedon <cavedon@sssup.it>
		      Markus Rechberger <mrechberger@gmail.com>
6
		      Mauro Carvalho Chehab <mchehab@brturbo.com.br>
7
		      Sascha Sommer <saschasommer@freenet.de>
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include <linux/init.h>
#include <linux/module.h>
#include <linux/pci.h>
#include <linux/delay.h>
#include <linux/i2c.h>
#include <linux/usb.h>
#include <media/tuner.h>
31
#include <media/msp3400.h>
32 33
#include <media/saa7115.h>
#include <media/tvp5150.h>
34
#include <media/tveeprom.h>
35
#include <media/audiochip.h>
36
#include <media/v4l2-common.h>
37

38
#include "em28xx.h"
39

40
struct em28xx_board em28xx_boards[] = {
41 42 43 44 45 46 47
	[EM2800_BOARD_UNKNOWN] = {
		.name         = "Unknown EM2800 video grabber",
		.is_em2800    = 1,
		.vchannels    = 2,
		.norm         = VIDEO_MODE_PAL,
		.tda9887_conf = TDA9887_PRESENT,
		.has_tuner    = 1,
48
		.decoder      = EM28XX_SAA7113,
49
		.input           = {{
50
			.type     = EM28XX_VMUX_COMPOSITE1,
51
			.vmux     = SAA7115_COMPOSITE0,
52 53
			.amux     = 1,
		},{
54
			.type     = EM28XX_VMUX_SVIDEO,
55
			.vmux     = SAA7115_SVIDEO3,
56 57 58 59 60 61 62 63 64 65
			.amux     = 1,
		}},
	},
	[EM2820_BOARD_UNKNOWN] = {
		.name         = "Unknown EM2820/2840 video grabber",
		.is_em2800    = 0,
		.vchannels    = 2,
		.norm         = VIDEO_MODE_PAL,
		.tda9887_conf = TDA9887_PRESENT,
		.has_tuner    = 1,
66
		.decoder      = EM28XX_SAA7113,
67
		.input           = {{
68
			.type     = EM28XX_VMUX_COMPOSITE1,
69
			.vmux     = SAA7115_COMPOSITE0,
70 71
			.amux     = 1,
		},{
72
			.type     = EM28XX_VMUX_SVIDEO,
73
			.vmux     = SAA7115_SVIDEO3,
74 75 76
			.amux     = 1,
		}},
	},
77
	[EM2820_BOARD_KWORLD_PVRTV2800RF] = {
78
		.name         = "Kworld PVR TV 2800 RF",
79 80 81 82 83 84 85 86
		.is_em2800    = 0,
		.vchannels    = 2,
		.norm         = VIDEO_MODE_PAL,
		.tda9887_conf = TDA9887_PRESENT,
		.has_tuner    = 1,
		.decoder      = EM28XX_SAA7113,
		.input           = {{
			.type     = EM28XX_VMUX_COMPOSITE1,
87
			.vmux     = SAA7115_COMPOSITE0,
88 89 90
			.amux     = 1,
		},{
			.type     = EM28XX_VMUX_SVIDEO,
91
			.vmux     = SAA7115_SVIDEO3,
92 93 94
			.amux     = 1,
		}},
	},
95 96 97 98 99 100 101
	[EM2820_BOARD_TERRATEC_CINERGY_250] = {
		.name         = "Terratec Cinergy 250 USB",
		.vchannels    = 3,
		.norm         = VIDEO_MODE_PAL,
		.tuner_type   = TUNER_LG_PAL_NEW_TAPC,
		.tda9887_conf = TDA9887_PRESENT,
		.has_tuner    = 1,
102
		.decoder      = EM28XX_SAA7113,
103
		.input          = {{
104
			.type     = EM28XX_VMUX_TELEVISION,
105
			.vmux     = SAA7115_COMPOSITE2,
106
			.amux     = 1,
107
		},{
108
			.type     = EM28XX_VMUX_COMPOSITE1,
109
			.vmux     = SAA7115_COMPOSITE0,
110 111
			.amux     = 1,
		},{
112
			.type     = EM28XX_VMUX_SVIDEO,
113
			.vmux     = SAA7115_SVIDEO3,
114 115 116 117 118 119 120 121 122 123
			.amux     = 1,
		}},
	},
	[EM2820_BOARD_PINNACLE_USB_2] = {
		.name         = "Pinnacle PCTV USB 2",
		.vchannels    = 3,
		.norm         = VIDEO_MODE_PAL,
		.tuner_type   = TUNER_LG_PAL_NEW_TAPC,
		.tda9887_conf = TDA9887_PRESENT,
		.has_tuner    = 1,
124
		.decoder      = EM28XX_SAA7113,
125
		.input          = {{
126
			.type     = EM28XX_VMUX_TELEVISION,
127
			.vmux     = SAA7115_COMPOSITE2,
128 129
			.amux     = 0,
		},{
130
			.type     = EM28XX_VMUX_COMPOSITE1,
131
			.vmux     = SAA7115_COMPOSITE0,
132 133
			.amux     = 1,
		},{
134
			.type     = EM28XX_VMUX_SVIDEO,
135
			.vmux     = SAA7115_SVIDEO3,
136 137 138 139 140 141 142 143 144 145
			.amux     = 1,
		}},
	},
	[EM2820_BOARD_HAUPPAUGE_WINTV_USB_2] = {
		.name         = "Hauppauge WinTV USB 2",
		.vchannels    = 3,
		.norm         = VIDEO_MODE_NTSC,
		.tuner_type   = TUNER_PHILIPS_FM1236_MK3,
		.tda9887_conf = TDA9887_PRESENT|TDA9887_PORT1_ACTIVE|TDA9887_PORT2_ACTIVE,
		.has_tuner    = 1,
146
		.decoder      = EM28XX_TVP5150,
147 148 149
		.has_msp34xx  = 1,
		/*FIXME: S-Video not tested */
		.input          = {{
150
			.type     = EM28XX_VMUX_TELEVISION,
151
			.vmux     = TVP5150_COMPOSITE0,
152
			.amux     = MSP_INPUT_DEFAULT,
153
		},{
154
			.type     = EM28XX_VMUX_SVIDEO,
155
			.vmux     = TVP5150_SVIDEO,
156 157
			.amux     = MSP_INPUT(MSP_IN_SCART1, MSP_IN_TUNER1,
					MSP_DSP_IN_SCART, MSP_DSP_IN_SCART),
158 159 160 161 162 163
		}},
	},
	[EM2820_BOARD_MSI_VOX_USB_2] = {
		.name		= "MSI VOX USB 2.0",
		.vchannels	= 3,
		.norm		= VIDEO_MODE_PAL,
164
		.tuner_type	= TUNER_LG_PAL_NEW_TAPC,
165 166
		.tda9887_conf	= TDA9887_PRESENT|TDA9887_PORT1_ACTIVE|TDA9887_PORT2_ACTIVE,
		.has_tuner	= 1,
167
		.decoder        = EM28XX_SAA7114,
168
		.input          = {{
169
			.type     = EM28XX_VMUX_TELEVISION,
170
			.vmux     = SAA7115_COMPOSITE4,
171 172
			.amux     = 0,
		},{
173
			.type     = EM28XX_VMUX_COMPOSITE1,
174
			.vmux     = SAA7115_COMPOSITE0,
175 176
			.amux     = 1,
		},{
177
			.type     = EM28XX_VMUX_SVIDEO,
178
			.vmux     = SAA7115_SVIDEO3,
179 180 181
			.amux     = 1,
		}},
	},
182 183 184 185 186 187 188 189
	[EM2800_BOARD_TERRATEC_CINERGY_200] = {
		.name         = "Terratec Cinergy 200 USB",
		.is_em2800    = 1,
		.vchannels    = 3,
		.norm         = VIDEO_MODE_PAL,
		.tuner_type   = TUNER_LG_PAL_NEW_TAPC,
		.tda9887_conf = TDA9887_PRESENT,
		.has_tuner    = 1,
190
		.decoder      = EM28XX_SAA7113,
191
		.input          = {{
192
			.type     = EM28XX_VMUX_TELEVISION,
193
			.vmux     = SAA7115_COMPOSITE2,
194 195
			.amux     = 0,
		},{
196
			.type     = EM28XX_VMUX_COMPOSITE1,
197
			.vmux     = SAA7115_COMPOSITE0,
198 199
			.amux     = 1,
		},{
200
			.type     = EM28XX_VMUX_SVIDEO,
201
			.vmux     = SAA7115_SVIDEO3,
202 203 204 205 206 207 208 209 210 211 212
			.amux     = 1,
		}},
	},
	[EM2800_BOARD_LEADTEK_WINFAST_USBII] = {
		.name         = "Leadtek Winfast USB II",
		.is_em2800    = 1,
		.vchannels    = 3,
		.norm         = VIDEO_MODE_PAL,
		.tuner_type   = TUNER_LG_PAL_NEW_TAPC,
		.tda9887_conf = TDA9887_PRESENT,
		.has_tuner    = 1,
213
		.decoder      = EM28XX_SAA7113,
214
		.input          = {{
215
			.type     = EM28XX_VMUX_TELEVISION,
216
			.vmux     = SAA7115_COMPOSITE2,
217 218
			.amux     = 0,
		},{
219
			.type     = EM28XX_VMUX_COMPOSITE1,
220
			.vmux     = SAA7115_COMPOSITE0,
221 222
			.amux     = 1,
		},{
223
			.type     = EM28XX_VMUX_SVIDEO,
224
			.vmux     = SAA7115_SVIDEO3,
225 226 227 228 229 230 231 232 233 234 235
			.amux     = 1,
		}},
	},
	[EM2800_BOARD_KWORLD_USB2800] = {
		.name         = "Kworld USB2800",
		.is_em2800    = 1,
		.vchannels    = 3,
		.norm         = VIDEO_MODE_PAL,
		.tuner_type   = TUNER_PHILIPS_ATSC,
		.tda9887_conf = TDA9887_PRESENT,
		.has_tuner    = 1,
236
		.decoder      = EM28XX_SAA7113,
237
		.input          = {{
238
			.type     = EM28XX_VMUX_TELEVISION,
239
			.vmux     = SAA7115_COMPOSITE2,
240 241
			.amux     = 0,
		},{
242
			.type     = EM28XX_VMUX_COMPOSITE1,
243
			.vmux     = SAA7115_COMPOSITE0,
244 245
			.amux     = 1,
		},{
246
			.type     = EM28XX_VMUX_SVIDEO,
247
			.vmux     = SAA7115_SVIDEO3,
248 249 250
			.amux     = 1,
		}},
	},
251 252 253 254 255
	[EM2820_BOARD_PINNACLE_DVC_90] = {
		.name         = "Pinnacle Dazzle DVC 90",
		.vchannels    = 3,
		.norm         = VIDEO_MODE_PAL,
		.has_tuner    = 0,
256
		.decoder      = EM28XX_SAA7113,
257
		.input          = {{
258
			.type     = EM28XX_VMUX_COMPOSITE1,
259
			.vmux     = SAA7115_COMPOSITE0,
260 261
			.amux     = 1,
		},{
262
			.type     = EM28XX_VMUX_SVIDEO,
263
			.vmux     = SAA7115_SVIDEO3,
264 265 266
			.amux     = 1,
		}},
	},
267
};
268
const unsigned int em28xx_bcount = ARRAY_SIZE(em28xx_boards);
269 270

/* table of devices that work with this driver */
271
struct usb_device_id em28xx_id_table [] = {
272
	{ USB_DEVICE(0xeb1a, 0x2800), .driver_info = EM2800_BOARD_UNKNOWN },
273
	{ USB_DEVICE(0xeb1a, 0x2820), .driver_info = EM2820_BOARD_MSI_VOX_USB_2 },
274 275 276
	{ USB_DEVICE(0x0ccd, 0x0036), .driver_info = EM2820_BOARD_TERRATEC_CINERGY_250 },
	{ USB_DEVICE(0x2304, 0x0208), .driver_info = EM2820_BOARD_PINNACLE_USB_2 },
	{ USB_DEVICE(0x2040, 0x4200), .driver_info = EM2820_BOARD_HAUPPAUGE_WINTV_USB_2 },
277
	{ USB_DEVICE(0x2304, 0x0207), .driver_info = EM2820_BOARD_PINNACLE_DVC_90 },
278 279 280
	{ },
};

281 282 283 284
void em28xx_pre_card_setup(struct em28xx *dev)
{
	/* request some modules */
	switch(dev->model){
285
		case EM2880_BOARD_TERRATEC_PRODIGY_XS:
286 287
		case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900:
		case EM2880_BOARD_TERRATEC_HYBRID_XS:
288 289 290 291 292 293 294
			{
				em28xx_write_regs_req(dev, 0x00, 0x08, "\x7d", 1); // reset through GPIO?
				break;
			}
	}
}

295
void em28xx_card_setup(struct em28xx *dev)
296 297
{
	/* request some modules */
298 299 300 301
	switch(dev->model){
		case EM2820_BOARD_HAUPPAUGE_WINTV_USB_2:
			{
				struct tveeprom tv;
302
#ifdef CONFIG_MODULES
303 304 305
				request_module("tveeprom");
				request_module("ir-kbd-i2c");
				request_module("msp3400");
306
#endif
307
				/* Call first TVeeprom */
308

309 310
				dev->i2c_client.addr = 0xa0 >> 1;
				tveeprom_hauppauge_analog(&dev->i2c_client, &tv, dev->eedata);
311

312 313 314 315 316 317 318 319
				dev->tuner_type= tv.tuner_type;
				if (tv.audio_processor == AUDIO_CHIP_MSP34XX) {
					dev->i2s_speed=2048000;
					dev->has_msp34xx=1;
				} else
					dev->has_msp34xx=0;
				break;
			}
320 321 322 323 324 325
		case EM2820_BOARD_KWORLD_PVRTV2800RF:
			{
				em28xx_write_regs_req(dev,0x00,0x08, "\xf9", 1); // GPIO enables sound on KWORLD PVR TV 2800RF
				break;
			}

326 327 328
	}
}

329 330 331
EXPORT_SYMBOL(em28xx_boards);
EXPORT_SYMBOL(em28xx_bcount);
EXPORT_SYMBOL(em28xx_id_table);
332

333
MODULE_DEVICE_TABLE (usb, em28xx_id_table);