em28xx-cards.c 11.6 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@infradead.org>
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

   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/delay.h>
#include <linux/i2c.h>
#include <linux/usb.h>
#include <media/tuner.h>
30
#include <media/msp3400.h>
31 32
#include <media/saa7115.h>
#include <media/tvp5150.h>
33
#include <media/tveeprom.h>
34
#include <media/audiochip.h>
35
#include <media/v4l2-common.h>
36

37
#include "em28xx.h"
38
#include "tuner-xc2028.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 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227
	[EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900] = {
		.name         = "Hauppauge WinTV HVR 900",
		.vchannels    = 3,
		.norm         = VIDEO_MODE_PAL,
		.tda9887_conf = TDA9887_PRESENT,
		.tuner_type   = TUNER_XC2028,
		.has_tuner    = 1,
		.decoder      = EM28XX_TVP5150,
		.input          = {{
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = TVP5150_COMPOSITE1,
			.amux     = 1,
		},{
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = TVP5150_COMPOSITE0,
			.amux     = 0,
		},{
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = TVP5150_SVIDEO,
			.amux     = 1,
		}},
	},
	[EM2880_BOARD_TERRATEC_HYBRID_XS] = {
		.name         = "Terratec Hybrid XS",
		.vchannels    = 3,
		.norm         = VIDEO_MODE_PAL,
		.tda9887_conf = TDA9887_PRESENT,
		.has_tuner    = 1,
		.tuner_type   = TUNER_XC2028,
		.decoder      = EM28XX_TVP5150,
		.input          = {{
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = TVP5150_COMPOSITE0,
			.amux     = 0,
		},{
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = TVP5150_COMPOSITE1,
			.amux     = 1,
		},{
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = TVP5150_SVIDEO,
			.amux     = 1,
		}},
	},
	/* maybe there's a reason behind it why Terratec sells the Hybrid XS as Prodigy XS with a
	 * different PID, let's keep it separated for now maybe we'll need it lateron */
	[EM2880_BOARD_TERRATEC_PRODIGY_XS] = {
		.name         = "Terratec Prodigy XS",
		.vchannels    = 3,
		.norm         = VIDEO_MODE_PAL,
		.tda9887_conf = TDA9887_PRESENT,
		.has_tuner    = 1,
		.tuner_type   = TUNER_XC2028,
		.decoder      = EM28XX_TVP5150,
		.input          = {{
			.type     = EM28XX_VMUX_TELEVISION,
			.vmux     = TVP5150_COMPOSITE0,
			.amux     = 0,
		},{
			.type     = EM28XX_VMUX_COMPOSITE1,
			.vmux     = TVP5150_COMPOSITE1,
			.amux     = 1,
		},{
			.type     = EM28XX_VMUX_SVIDEO,
			.vmux     = TVP5150_SVIDEO,
			.amux     = 1,
		}},
	},
228 229 230 231
	[EM2820_BOARD_MSI_VOX_USB_2] = {
		.name		= "MSI VOX USB 2.0",
		.vchannels	= 3,
		.norm		= VIDEO_MODE_PAL,
232
		.tuner_type	= TUNER_LG_PAL_NEW_TAPC,
233 234
		.tda9887_conf	= TDA9887_PRESENT|TDA9887_PORT1_ACTIVE|TDA9887_PORT2_ACTIVE,
		.has_tuner	= 1,
235
		.decoder        = EM28XX_SAA7114,
236
		.input          = {{
237
			.type     = EM28XX_VMUX_TELEVISION,
238
			.vmux     = SAA7115_COMPOSITE4,
239 240
			.amux     = 0,
		},{
241
			.type     = EM28XX_VMUX_COMPOSITE1,
242
			.vmux     = SAA7115_COMPOSITE0,
243 244
			.amux     = 1,
		},{
245
			.type     = EM28XX_VMUX_SVIDEO,
246
			.vmux     = SAA7115_SVIDEO3,
247 248 249
			.amux     = 1,
		}},
	},
250 251 252 253 254 255 256 257
	[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,
258
		.decoder      = EM28XX_SAA7113,
259
		.input          = {{
260
			.type     = EM28XX_VMUX_TELEVISION,
261
			.vmux     = SAA7115_COMPOSITE2,
262 263
			.amux     = 0,
		},{
264
			.type     = EM28XX_VMUX_COMPOSITE1,
265
			.vmux     = SAA7115_COMPOSITE0,
266 267
			.amux     = 1,
		},{
268
			.type     = EM28XX_VMUX_SVIDEO,
269
			.vmux     = SAA7115_SVIDEO3,
270 271 272 273 274 275 276 277 278 279 280
			.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,
281
		.decoder      = EM28XX_SAA7113,
282
		.input          = {{
283
			.type     = EM28XX_VMUX_TELEVISION,
284
			.vmux     = SAA7115_COMPOSITE2,
285 286
			.amux     = 0,
		},{
287
			.type     = EM28XX_VMUX_COMPOSITE1,
288
			.vmux     = SAA7115_COMPOSITE0,
289 290
			.amux     = 1,
		},{
291
			.type     = EM28XX_VMUX_SVIDEO,
292
			.vmux     = SAA7115_SVIDEO3,
293 294 295 296 297 298 299 300 301 302 303
			.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,
304
		.decoder      = EM28XX_SAA7113,
305
		.input          = {{
306
			.type     = EM28XX_VMUX_TELEVISION,
307
			.vmux     = SAA7115_COMPOSITE2,
308 309
			.amux     = 0,
		},{
310
			.type     = EM28XX_VMUX_COMPOSITE1,
311
			.vmux     = SAA7115_COMPOSITE0,
312 313
			.amux     = 1,
		},{
314
			.type     = EM28XX_VMUX_SVIDEO,
315
			.vmux     = SAA7115_SVIDEO3,
316 317 318
			.amux     = 1,
		}},
	},
319 320 321 322 323
	[EM2820_BOARD_PINNACLE_DVC_90] = {
		.name         = "Pinnacle Dazzle DVC 90",
		.vchannels    = 3,
		.norm         = VIDEO_MODE_PAL,
		.has_tuner    = 0,
324
		.decoder      = EM28XX_SAA7113,
325
		.input          = {{
326
			.type     = EM28XX_VMUX_COMPOSITE1,
327
			.vmux     = SAA7115_COMPOSITE0,
328 329
			.amux     = 1,
		},{
330
			.type     = EM28XX_VMUX_SVIDEO,
331
			.vmux     = SAA7115_SVIDEO3,
332 333 334
			.amux     = 1,
		}},
	},
335
};
336
const unsigned int em28xx_bcount = ARRAY_SIZE(em28xx_boards);
337 338

/* table of devices that work with this driver */
339
struct usb_device_id em28xx_id_table [] = {
340
	{ USB_DEVICE(0xeb1a, 0x2800), .driver_info = EM2800_BOARD_UNKNOWN },
341
	{ USB_DEVICE(0xeb1a, 0x2820), .driver_info = EM2820_BOARD_MSI_VOX_USB_2 },
342 343 344
	{ 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 },
345
	{ USB_DEVICE(0x2304, 0x0207), .driver_info = EM2820_BOARD_PINNACLE_DVC_90 },
346
	{ USB_DEVICE(0x2040, 0x6500), .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900 },
347
	{ USB_DEVICE(0x2040, 0x6513), .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900 },
348 349
	{ USB_DEVICE(0x0ccd, 0x0042), .driver_info = EM2880_BOARD_TERRATEC_HYBRID_XS },
	{ USB_DEVICE(0x0ccd, 0x0047), .driver_info = EM2880_BOARD_TERRATEC_PRODIGY_XS },
350 351 352
	{ },
};

353 354 355 356
void em28xx_pre_card_setup(struct em28xx *dev)
{
	/* request some modules */
	switch(dev->model){
357
		case EM2880_BOARD_TERRATEC_PRODIGY_XS:
358 359
		case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900:
		case EM2880_BOARD_TERRATEC_HYBRID_XS:
360 361 362 363 364 365 366
			{
				em28xx_write_regs_req(dev, 0x00, 0x08, "\x7d", 1); // reset through GPIO?
				break;
			}
	}
}

367 368 369 370 371 372 373
static void em28xx_config_tuner (struct em28xx *dev)
{
	struct v4l2_priv_tun_config  xc2028_cfg;
	struct xc2028_ctrl           ctl;

	memset (&ctl,0,sizeof(ctl));

374 375
	ctl.fname   = XC2028_DEFAULT_FIRMWARE;
	ctl.max_len = 64;
376 377 378 379 380 381 382

	xc2028_cfg.tuner = TUNER_XC2028;
	xc2028_cfg.priv  = &ctl;

	em28xx_i2c_call_clients(dev, TUNER_SET_CONFIG, &xc2028_cfg);
}

383
void em28xx_card_setup(struct em28xx *dev)
384 385
{
	/* request some modules */
386 387 388 389
	switch(dev->model){
		case EM2820_BOARD_HAUPPAUGE_WINTV_USB_2:
			{
				struct tveeprom tv;
390
#ifdef CONFIG_MODULES
391 392 393
				request_module("tveeprom");
				request_module("ir-kbd-i2c");
				request_module("msp3400");
394
#endif
395
				/* Call first TVeeprom */
396

397 398
				dev->i2c_client.addr = 0xa0 >> 1;
				tveeprom_hauppauge_analog(&dev->i2c_client, &tv, dev->eedata);
399

400 401 402 403 404 405 406 407
				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;
			}
408 409 410 411 412 413
		case EM2820_BOARD_KWORLD_PVRTV2800RF:
			{
				em28xx_write_regs_req(dev,0x00,0x08, "\xf9", 1); // GPIO enables sound on KWORLD PVR TV 2800RF
				break;
			}

414
	}
415
	em28xx_config_tuner (dev);
416 417
}

418
MODULE_DEVICE_TABLE (usb, em28xx_id_table);