⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 zoran_card.c

📁 linux-2.6.15.6
💻 C
📖 第 1 页 / 共 3 页
字号:
/* * Zoran zr36057/zr36067 PCI controller driver, for the * Pinnacle/Miro DC10/DC10+/DC30/DC30+, Iomega Buz, Linux * Media Labs LML33/LML33R10. * * This part handles card-specific data and detection *  * Copyright (C) 2000 Serguei Miridonov <mirsev@cicese.mx> * * Currently maintained by: *   Ronald Bultje    <rbultje@ronald.bitfreak.net> *   Laurent Pinchart <laurent.pinchart@skynet.be> *   Mailinglist      <mjpeg-users@lists.sf.net> * * 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/config.h>#include <linux/types.h>#include <linux/kernel.h>#include <linux/module.h>#include <linux/init.h>#include <linux/vmalloc.h>#include <linux/proc_fs.h>#include <linux/i2c.h>#include <linux/i2c-algo-bit.h>#include <linux/videodev.h>#include <linux/spinlock.h>#include <linux/sem.h>#include <linux/kmod.h>#include <linux/wait.h>#include <linux/pci.h>#include <linux/interrupt.h>#include <linux/video_decoder.h>#include <linux/video_encoder.h>#include <asm/io.h>#include "videocodec.h"#include "zoran.h"#include "zoran_card.h"#include "zoran_device.h"#include "zoran_procfs.h"#define I2C_NAME(x) (x)->nameextern const struct zoran_format zoran_formats[];static int card[BUZ_MAX] = { -1, -1, -1, -1 };module_param_array(card, int, NULL, 0);MODULE_PARM_DESC(card, "The type of card");static int encoder[BUZ_MAX] = { -1, -1, -1, -1 };module_param_array(encoder, int, NULL, 0);MODULE_PARM_DESC(encoder, "i2c TV encoder");static int decoder[BUZ_MAX] = { -1, -1, -1, -1 };module_param_array(decoder, int, NULL, 0);MODULE_PARM_DESC(decoder, "i2c TV decoder");/*   The video mem address of the video card.   The driver has a little database for some videocards   to determine it from there. If your video card is not in there   you have either to give it to the driver as a parameter   or set in in a VIDIOCSFBUF ioctl */static unsigned long vidmem = 0;	/* Video memory base address */module_param(vidmem, ulong, 0);/*   Default input and video norm at startup of the driver.*/static int default_input = 0;	/* 0=Composite, 1=S-Video */module_param(default_input, int, 0);MODULE_PARM_DESC(default_input,		 "Default input (0=Composite, 1=S-Video, 2=Internal)");static int default_norm = 0;	/* 0=PAL, 1=NTSC 2=SECAM */module_param(default_norm, int, 0);MODULE_PARM_DESC(default_norm, "Default norm (0=PAL, 1=NTSC, 2=SECAM)");static int video_nr = -1;	/* /dev/videoN, -1 for autodetect */module_param(video_nr, int, 0);MODULE_PARM_DESC(video_nr, "video device number");/*   Number and size of grab buffers for Video 4 Linux   The vast majority of applications should not need more than 2,   the very popular BTTV driver actually does ONLY have 2.   Time sensitive applications might need more, the maximum   is VIDEO_MAX_FRAME (defined in <linux/videodev.h>).   The size is set so that the maximum possible request   can be satisfied. Decrease  it, if bigphys_area alloc'd   memory is low. If you don't have the bigphys_area patch,   set it to 128 KB. Will you allow only to grab small   images with V4L, but that's better than nothing.   v4l_bufsize has to be given in KB !*/int v4l_nbufs = 2;int v4l_bufsize = 128;		/* Everybody should be able to work with this setting */module_param(v4l_nbufs, int, 0);MODULE_PARM_DESC(v4l_nbufs, "Maximum number of V4L buffers to use");module_param(v4l_bufsize, int, 0);MODULE_PARM_DESC(v4l_bufsize, "Maximum size per V4L buffer (in kB)");int jpg_nbufs = 32;int jpg_bufsize = 512;		/* max size for 100% quality full-PAL frame */module_param(jpg_nbufs, int, 0);MODULE_PARM_DESC(jpg_nbufs, "Maximum number of JPG buffers to use");module_param(jpg_bufsize, int, 0);MODULE_PARM_DESC(jpg_bufsize, "Maximum size per JPG buffer (in kB)");int pass_through = 0;		/* 1=Pass through TV signal when device is not used */				/* 0=Show color bar when device is not used (LML33: only if lml33dpath=1) */module_param(pass_through, int, 0);MODULE_PARM_DESC(pass_through,		 "Pass TV signal through to TV-out when idling");static int debug = 1;int *zr_debug = &debug;module_param(debug, int, 0);MODULE_PARM_DESC(debug, "Debug level (0-4)");MODULE_DESCRIPTION("Zoran-36057/36067 JPEG codec driver");MODULE_AUTHOR("Serguei Miridonov");MODULE_LICENSE("GPL");static struct pci_device_id zr36067_pci_tbl[] = {	{PCI_VENDOR_ID_ZORAN, PCI_DEVICE_ID_ZORAN_36057,	 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},	{0}};MODULE_DEVICE_TABLE(pci, zr36067_pci_tbl);#define dprintk(num, format, args...) \	do { \		if (*zr_debug >= num) \			printk(format, ##args); \	} while (0)int zoran_num;			/* number of Buzs in use */struct zoran zoran[BUZ_MAX];/* videocodec bus functions ZR36060 */static u32zr36060_read (struct videocodec *codec,	      u16                reg){	struct zoran *zr = (struct zoran *) codec->master_data->data;	__u32 data;	if (post_office_wait(zr)	    || post_office_write(zr, 0, 1, reg >> 8)	    || post_office_write(zr, 0, 2, reg & 0xff)) {		return -1;	}	data = post_office_read(zr, 0, 3) & 0xff;	return data;}static voidzr36060_write (struct videocodec *codec,	       u16                reg,	       u32                val){	struct zoran *zr = (struct zoran *) codec->master_data->data;	if (post_office_wait(zr)	    || post_office_write(zr, 0, 1, reg >> 8)	    || post_office_write(zr, 0, 2, reg & 0xff)) {		return;	}	post_office_write(zr, 0, 3, val & 0xff);}/* videocodec bus functions ZR36050 */static u32zr36050_read (struct videocodec *codec,	      u16                reg){	struct zoran *zr = (struct zoran *) codec->master_data->data;	__u32 data;	if (post_office_wait(zr)	    || post_office_write(zr, 1, 0, reg >> 2)) {	// reg. HIGHBYTES		return -1;	}	data = post_office_read(zr, 0, reg & 0x03) & 0xff;	// reg. LOWBYTES + read	return data;}static voidzr36050_write (struct videocodec *codec,	       u16                reg,	       u32                val){	struct zoran *zr = (struct zoran *) codec->master_data->data;	if (post_office_wait(zr)	    || post_office_write(zr, 1, 0, reg >> 2)) {	// reg. HIGHBYTES		return;	}	post_office_write(zr, 0, reg & 0x03, val & 0xff);	// reg. LOWBYTES + wr. data}/* videocodec bus functions ZR36016 */static u32zr36016_read (struct videocodec *codec,	      u16                reg){	struct zoran *zr = (struct zoran *) codec->master_data->data;	__u32 data;	if (post_office_wait(zr)) {		return -1;	}	data = post_office_read(zr, 2, reg & 0x03) & 0xff;	// read	return data;}/* hack for in zoran_device.c */voidzr36016_write (struct videocodec *codec,	       u16                reg,	       u32                val){	struct zoran *zr = (struct zoran *) codec->master_data->data;	if (post_office_wait(zr)) {		return;	}	post_office_write(zr, 2, reg & 0x03, val & 0x0ff);	// wr. data}/* * Board specific information */static voiddc10_init (struct zoran *zr){	dprintk(3, KERN_DEBUG "%s: dc10_init()\n", ZR_DEVNAME(zr));	/* Pixel clock selection */	GPIO(zr, 4, 0);	GPIO(zr, 5, 1);	/* Enable the video bus sync signals */	GPIO(zr, 7, 0);}static voiddc10plus_init (struct zoran *zr){	dprintk(3, KERN_DEBUG "%s: dc10plus_init()\n", ZR_DEVNAME(zr));}static voidbuz_init (struct zoran *zr){	dprintk(3, KERN_DEBUG "%s: buz_init()\n", ZR_DEVNAME(zr));	/* some stuff from Iomega */	pci_write_config_dword(zr->pci_dev, 0xfc, 0x90680f15);	pci_write_config_dword(zr->pci_dev, 0x0c, 0x00012020);	pci_write_config_dword(zr->pci_dev, 0xe8, 0xc0200000);}static voidlml33_init (struct zoran *zr){	dprintk(3, KERN_DEBUG "%s: lml33_init()\n", ZR_DEVNAME(zr));	GPIO(zr, 2, 1);		// Set Composite input/output}static char *i2cid_to_modulename (u16 i2c_id){	char *name = NULL;	switch (i2c_id) {	case I2C_DRIVERID_SAA7110:		name = "saa7110";		break;	case I2C_DRIVERID_SAA7111A:		name = "saa7111";		break;	case I2C_DRIVERID_SAA7114:		name = "saa7114";		break;	case I2C_DRIVERID_SAA7185B:		name = "saa7185";		break;	case I2C_DRIVERID_ADV7170:		name = "adv7170";		break;	case I2C_DRIVERID_ADV7175:		name = "adv7175";		break;	case I2C_DRIVERID_BT819:		name = "bt819";		break;	case I2C_DRIVERID_BT856:		name = "bt856";		break;	case I2C_DRIVERID_VPX3220:		name = "vpx3220";		break;/*	case I2C_DRIVERID_VPX3224:		name = "vpx3224";		break;	case I2C_DRIVERID_MSE3000:		name = "mse3000";		break;*/	default:		break;	}	return name;}static char *codecid_to_modulename (u16 codecid){	char *name = NULL;	switch (codecid) {	case CODEC_TYPE_ZR36060:		name = "zr36060";		break;	case CODEC_TYPE_ZR36050:		name = "zr36050";		break;	case CODEC_TYPE_ZR36016:		name = "zr36016";		break;	default:		break;	}	return name;}// struct tvnorm {//      u16 Wt, Wa, HStart, HSyncStart, Ht, Ha, VStart;// };static struct tvnorm f50sqpixel = { 944, 768, 83, 880, 625, 576, 16 };static struct tvnorm f60sqpixel = { 780, 640, 51, 716, 525, 480, 12 };static struct tvnorm f50ccir601 = { 864, 720, 75, 804, 625, 576, 18 };static struct tvnorm f60ccir601 = { 858, 720, 57, 788, 525, 480, 16 };static struct tvnorm f50ccir601_lml33 = { 864, 720, 75+34, 804, 625, 576, 18 };static struct tvnorm f60ccir601_lml33 = { 858, 720, 57+34, 788, 525, 480, 16 };/* The DC10 (57/16/50) uses VActive as HSync, so HStart must be 0 */static struct tvnorm f50sqpixel_dc10 = { 944, 768, 0, 880, 625, 576, 0 };static struct tvnorm f60sqpixel_dc10 = { 780, 640, 0, 716, 525, 480, 12 };/* FIXME: I cannot swap U and V in saa7114, so i do one * pixel left shift in zoran (75 -> 74) * (Maxim Yevtyushkin <max@linuxmedialabs.com>) */static struct tvnorm f50ccir601_lm33r10 = { 864, 720, 74+54, 804, 625, 576, 18 };static struct tvnorm f60ccir601_lm33r10 = { 858, 720, 56+54, 788, 525, 480, 16 };static struct card_info zoran_cards[NUM_CARDS] __devinitdata = {	{		.type = DC10_old,		.name = "DC10(old)",		.i2c_decoder = I2C_DRIVERID_VPX3220,		/*.i2c_encoder = I2C_DRIVERID_MSE3000,*/		.video_codec = CODEC_TYPE_ZR36050,		.video_vfe = CODEC_TYPE_ZR36016,		.inputs = 3,		.input = {			{ 1, "Composite" },			{ 2, "S-Video" },			{ 0, "Internal/comp" }		},		.norms = 3,		.tvn = {			&f50sqpixel_dc10,			&f60sqpixel_dc10,			&f50sqpixel_dc10		},		.jpeg_int = 0,		.vsync_int = ZR36057_ISR_GIRQ1,		.gpio = { 2, 1, -1, 3, 7, 0, 4, 5 },		.gpio_pol = { 0, 0, 0, 1, 0, 0, 0, 0 },		.gpcs = { -1, 0 },		.vfe_pol = { 0, 0, 0, 0, 0, 0, 0, 0 },		.gws_not_connected = 0,		.init = &dc10_init,	}, {		.type = DC10_new,		.name = "DC10(new)",		.i2c_decoder = I2C_DRIVERID_SAA7110,		.i2c_encoder = I2C_DRIVERID_ADV7175,		.video_codec = CODEC_TYPE_ZR36060,		.inputs = 3,		.input = {				{ 0, "Composite" },				{ 7, "S-Video" },				{ 5, "Internal/comp" }			},		.norms = 3,		.tvn = {				&f50sqpixel,				&f60sqpixel,				&f50sqpixel},		.jpeg_int = ZR36057_ISR_GIRQ0,		.vsync_int = ZR36057_ISR_GIRQ1,		.gpio = { 3, 0, 6, 1, 2, -1, 4, 5 },		.gpio_pol = { 0, 0, 0, 0, 0, 0, 0, 0 },		.gpcs = { -1, 1},		.vfe_pol = { 1, 1, 1, 1, 0, 0, 0, 0 },		.gws_not_connected = 0,		.init = &dc10plus_init,	}, {		.type = DC10plus,		.name = "DC10plus",		.vendor_id = PCI_VENDOR_ID_MIRO,		.device_id = PCI_DEVICE_ID_MIRO_DC10PLUS,		.i2c_decoder = I2C_DRIVERID_SAA7110,		.i2c_encoder = I2C_DRIVERID_ADV7175,		.video_codec = CODEC_TYPE_ZR36060,		.inputs = 3,		.input = {			{ 0, "Composite" },			{ 7, "S-Video" },			{ 5, "Internal/comp" }		},		.norms = 3,		.tvn = {			&f50sqpixel,			&f60sqpixel,			&f50sqpixel		},		.jpeg_int = ZR36057_ISR_GIRQ0,		.vsync_int = ZR36057_ISR_GIRQ1,		.gpio = { 3, 0, 6, 1, 2, -1, 4, 5 },		.gpio_pol = { 0, 0, 0, 0, 0, 0, 0, 0 },		.gpcs = { -1, 1 },		.vfe_pol = { 1, 1, 1, 1, 0, 0, 0, 0 },		.gws_not_connected = 0,		.init = &dc10plus_init,	}, {		.type = DC30,		.name = "DC30",		.i2c_decoder = I2C_DRIVERID_VPX3220,		.i2c_encoder = I2C_DRIVERID_ADV7175,		.video_codec = CODEC_TYPE_ZR36050,		.video_vfe = CODEC_TYPE_ZR36016,		.inputs = 3,		.input = {			{ 1, "Composite" },			{ 2, "S-Video" },			{ 0, "Internal/comp" }		},		.norms = 3,		.tvn = {			&f50sqpixel_dc10,			&f60sqpixel_dc10,			&f50sqpixel_dc10		},		.jpeg_int = 0,		.vsync_int = ZR36057_ISR_GIRQ1,		.gpio = { 2, 1, -1, 3, 7, 0, 4, 5 },		.gpio_pol = { 0, 0, 0, 1, 0, 0, 0, 0 },		.gpcs = { -1, 0 },		.vfe_pol = { 0, 0, 0, 0, 0, 0, 0, 0 },		.gws_not_connected = 0,		.init = &dc10_init,	}, {		.type = DC30plus,		.name = "DC30plus",		.vendor_id = PCI_VENDOR_ID_MIRO,		.device_id = PCI_DEVICE_ID_MIRO_DC30PLUS,		.i2c_decoder = I2C_DRIVERID_VPX3220,		.i2c_encoder = I2C_DRIVERID_ADV7175,		.video_codec = CODEC_TYPE_ZR36050,		.video_vfe = CODEC_TYPE_ZR36016,		.inputs = 3,		.input = {			{ 1, "Composite" },			{ 2, "S-Video" },			{ 0, "Internal/comp" }		},		.norms = 3,		.tvn = {			&f50sqpixel_dc10,			&f60sqpixel_dc10,			&f50sqpixel_dc10		},		.jpeg_int = 0,		.vsync_int = ZR36057_ISR_GIRQ1,

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -