em28xx-cards.c 8.5 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 32
#include <media/audiochip.h>
#include <media/tveeprom.h>
33
#include <media/v4l2-common.h>
34

35
#include "em28xx.h"
36

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

/* table of devices that work with this driver */
267
struct usb_device_id em28xx_id_table [] = {
268
	{ USB_DEVICE(0xeb1a, 0x2800), .driver_info = EM2800_BOARD_UNKNOWN },
269
	{ USB_DEVICE(0xeb1a, 0x2820), .driver_info = EM2820_BOARD_MSI_VOX_USB_2 },
270 271 272
	{ 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 },
273
	{ USB_DEVICE(0x2304, 0x0207), .driver_info = EM2820_BOARD_PINNACLE_DVC_90 },
274 275 276
	{ },
};

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

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

305 306
				dev->i2c_client.addr = 0xa0 >> 1;
				tveeprom_hauppauge_analog(&dev->i2c_client, &tv, dev->eedata);
307

308 309 310 311 312 313 314 315
				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;
			}
316 317 318 319 320 321
		case EM2820_BOARD_KWORLD_PVRTV2800RF:
			{
				em28xx_write_regs_req(dev,0x00,0x08, "\xf9", 1); // GPIO enables sound on KWORLD PVR TV 2800RF
				break;
			}

322 323 324
	}
}

325 326 327
EXPORT_SYMBOL(em28xx_boards);
EXPORT_SYMBOL(em28xx_bcount);
EXPORT_SYMBOL(em28xx_id_table);
328

329
MODULE_DEVICE_TABLE (usb, em28xx_id_table);