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

36
#include "em28xx.h"
37

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

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

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

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

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

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

324 325 326
	}
}

327 328 329
EXPORT_SYMBOL(em28xx_boards);
EXPORT_SYMBOL(em28xx_bcount);
EXPORT_SYMBOL(em28xx_id_table);
330

331
MODULE_DEVICE_TABLE (usb, em28xx_id_table);