em28xx-cards.c 8.4 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 "msp3400.h"

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

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

283 284 285 286 287 288 289 290 291 292 293 294
void em28xx_pre_card_setup(struct em28xx *dev)
{
	/* request some modules */
	switch(dev->model){
		case EM2880_BOARD_WINTV_HVR_900:
			{
				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
EXPORT_SYMBOL(em28xx_boards);
EXPORT_SYMBOL(em28xx_bcount);
EXPORT_SYMBOL(em28xx_id_table);
326

327
MODULE_DEVICE_TABLE (usb, em28xx_id_table);