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

📄 saa7114.c

📁 linux-2.6.15.6
💻 C
📖 第 1 页 / 共 3 页
字号:
/*  * saa7114 - Philips SAA7114H video decoder driver version 0.0.1 * * Copyright (C) 2002 Maxim Yevtyushkin <max@linuxmedialabs.com> * * Based on saa7111 driver by Dave Perks * * Copyright (C) 1998 Dave Perks <dperks@ibm.net> * * Slight changes for video timing and attachment output by * Wolfgang Scherr <scherr@net4you.net> * * Changes by Ronald Bultje <rbultje@ronald.bitfreak.net> *    - moved over to linux>=2.4.x i2c protocol (1/1/2003) * * 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/module.h>#include <linux/init.h>#include <linux/delay.h>#include <linux/errno.h>#include <linux/fs.h>#include <linux/kernel.h>#include <linux/major.h>#include <linux/slab.h>#include <linux/mm.h>#include <linux/pci.h>#include <linux/signal.h>#include <asm/io.h>#include <asm/pgtable.h>#include <asm/page.h>#include <linux/sched.h>#include <linux/types.h>#include <linux/videodev.h>#include <asm/uaccess.h>MODULE_DESCRIPTION("Philips SAA7114H video decoder driver");MODULE_AUTHOR("Maxim Yevtyushkin");MODULE_LICENSE("GPL");#include <linux/i2c.h>#include <linux/i2c-dev.h>#define I2C_NAME(x) (x)->name#include <linux/video_decoder.h>static int debug = 0;module_param(debug, int, 0);MODULE_PARM_DESC(debug, "Debug level (0-1)");#define dprintk(num, format, args...) \	do { \		if (debug >= num) \			printk(format, ##args); \	} while (0)/* ----------------------------------------------------------------------- */struct saa7114 {	unsigned char reg[0xf0 * 2];	int norm;	int input;	int enable;	int bright;	int contrast;	int hue;	int sat;	int playback;};#define   I2C_SAA7114        0x42#define   I2C_SAA7114A       0x40#define   I2C_DELAY   10//#define SAA_7114_NTSC_HSYNC_START       (-3)//#define SAA_7114_NTSC_HSYNC_STOP        (-18)#define SAA_7114_NTSC_HSYNC_START  (-17)#define SAA_7114_NTSC_HSYNC_STOP   (-32)//#define SAA_7114_NTSC_HOFFSET           (5)#define SAA_7114_NTSC_HOFFSET		(6)#define SAA_7114_NTSC_VOFFSET           (10)#define SAA_7114_NTSC_WIDTH             (720)#define SAA_7114_NTSC_HEIGHT            (250)#define SAA_7114_SECAM_HSYNC_START      (-17)#define SAA_7114_SECAM_HSYNC_STOP       (-32)#define SAA_7114_SECAM_HOFFSET          (2)#define SAA_7114_SECAM_VOFFSET          (10)#define SAA_7114_SECAM_WIDTH            (720)#define SAA_7114_SECAM_HEIGHT           (300)#define SAA_7114_PAL_HSYNC_START        (-17)#define SAA_7114_PAL_HSYNC_STOP         (-32)#define SAA_7114_PAL_HOFFSET            (2)#define SAA_7114_PAL_VOFFSET            (10)#define SAA_7114_PAL_WIDTH              (720)#define SAA_7114_PAL_HEIGHT             (300)#define SAA_7114_VERTICAL_CHROMA_OFFSET         0	//0x50504040#define SAA_7114_VERTICAL_LUMA_OFFSET           0#define REG_ADDR(x) (((x) << 1) + 1)#define LOBYTE(x) ((unsigned char)((x) & 0xff))#define HIBYTE(x) ((unsigned char)(((x) >> 8) & 0xff))#define LOWORD(x) ((unsigned short int)((x) & 0xffff))#define HIWORD(x) ((unsigned short int)(((x) >> 16) & 0xffff))/* ----------------------------------------------------------------------- */static inline intsaa7114_write (struct i2c_client *client,	       u8                 reg,	       u8                 value){	/*struct saa7114 *decoder = i2c_get_clientdata(client);*/	/*decoder->reg[reg] = value;*/	return i2c_smbus_write_byte_data(client, reg, value);}static intsaa7114_write_block (struct i2c_client *client,		     const u8          *data,		     unsigned int       len){	int ret = -1;	u8 reg;	/* the saa7114 has an autoincrement function, use it if	 * the adapter understands raw I2C */	if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {		/* do raw I2C, not smbus compatible */		/*struct saa7114 *decoder = i2c_get_clientdata(client);*/		struct i2c_msg msg;		u8 block_data[32];		msg.addr = client->addr;		msg.flags = 0;		while (len >= 2) {			msg.buf = (char *) block_data;			msg.len = 0;			block_data[msg.len++] = reg = data[0];			do {				block_data[msg.len++] =				    /*decoder->reg[reg++] =*/ data[1];				len -= 2;				data += 2;			} while (len >= 2 && data[0] == reg &&				 msg.len < 32);			if ((ret = i2c_transfer(client->adapter,						&msg, 1)) < 0)				break;		}	} else {		/* do some slow I2C emulation kind of thing */		while (len >= 2) {			reg = *data++;			if ((ret = saa7114_write(client, reg,						 *data++)) < 0)				break;			len -= 2;		}	}	return ret;}static inline intsaa7114_read (struct i2c_client *client,	      u8                 reg){	return i2c_smbus_read_byte_data(client, reg);}/* ----------------------------------------------------------------------- */// initially set NTSC, compositestatic const unsigned char init[] = {	0x00, 0x00,		/* 00 - ID byte , chip version,				 * read only */	0x01, 0x08,		/* 01 - X,X,X,X, IDEL3 to IDEL0 -				 * horizontal increment delay,				 * recommended position */	0x02, 0x00,		/* 02 - FUSE=3, GUDL=2, MODE=0 ;				 * input control */	0x03, 0x10,		/* 03 - HLNRS=0, VBSL=1, WPOFF=0,				 * HOLDG=0, GAFIX=0, GAI1=256, GAI2=256 */	0x04, 0x90,		/* 04 - GAI1=256 */	0x05, 0x90,		/* 05 - GAI2=256 */	0x06, SAA_7114_NTSC_HSYNC_START,	/* 06 - HSB: hsync start,				 * depends on the video standard */	0x07, SAA_7114_NTSC_HSYNC_STOP,	/* 07 - HSS: hsync stop, depends				 *on the video standard */	0x08, 0xb8,		/* 08 - AUFD=1, FSEL=1, EXFIL=0, VTRC=1,				 * HPLL: free running in playback, locked				 * in capture, VNOI=0 */	0x09, 0x80,		/* 09 - BYPS=0, PREF=0, BPSS=0, VBLB=0,				 * UPTCV=0, APER=1; depends from input */	0x0a, 0x80,		/* 0a - BRIG=128 */	0x0b, 0x44,		/* 0b - CONT=1.109 */	0x0c, 0x40,		/* 0c - SATN=1.0 */	0x0d, 0x00,		/* 0d - HUE=0 */	0x0e, 0x84,		/* 0e - CDTO, CSTD2 to 0, DCVF, FCTC,				 * CCOMB; depends from video standard */	0x0f, 0x24,		/* 0f - ACGC,CGAIN6 to CGAIN0; depends				 * from video standard */	0x10, 0x03,		/* 10 - OFFU1 to 0, OFFV1 to 0, CHBW,				 * LCBW2 to 0 */	0x11, 0x59,		/* 11 - COLO, RTP1, HEDL1 to 0, RTP0,				 * YDEL2 to 0 */	0x12, 0xc9,		/* 12 - RT signal control RTSE13 to 10				 * and 03 to 00 */	0x13, 0x80,		/* 13 - RT/X port output control  */	0x14, 0x00,		/* 14 - analog, ADC, compatibility control */	0x15, 0x00,		/* 15 - VGATE start FID change  */	0x16, 0xfe,		/* 16 - VGATE stop */	0x17, 0x00,		/* 17 - Misc., VGATE MSBs */	0x18, 0x40,		/* RAWG */	0x19, 0x80,		/* RAWO */	0x1a, 0x00,	0x1b, 0x00,	0x1c, 0x00,	0x1d, 0x00,	0x1e, 0x00,	0x1f, 0x00,		/* status byte, read only */	0x20, 0x00,		/* video decoder reserved part */	0x21, 0x00,	0x22, 0x00,	0x23, 0x00,	0x24, 0x00,	0x25, 0x00,	0x26, 0x00,	0x27, 0x00,	0x28, 0x00,	0x29, 0x00,	0x2a, 0x00,	0x2b, 0x00,	0x2c, 0x00,	0x2d, 0x00,	0x2e, 0x00,	0x2f, 0x00,	0x30, 0xbc,		/* audio clock generator */	0x31, 0xdf,	0x32, 0x02,	0x33, 0x00,	0x34, 0xcd,	0x35, 0xcc,	0x36, 0x3a,	0x37, 0x00,	0x38, 0x03,	0x39, 0x10,	0x3a, 0x00,	0x3b, 0x00,	0x3c, 0x00,	0x3d, 0x00,	0x3e, 0x00,	0x3f, 0x00,	0x40, 0x00,		/* VBI data slicer */	0x41, 0xff,	0x42, 0xff,	0x43, 0xff,	0x44, 0xff,	0x45, 0xff,	0x46, 0xff,	0x47, 0xff,	0x48, 0xff,	0x49, 0xff,	0x4a, 0xff,	0x4b, 0xff,	0x4c, 0xff,	0x4d, 0xff,	0x4e, 0xff,	0x4f, 0xff,	0x50, 0xff,	0x51, 0xff,	0x52, 0xff,	0x53, 0xff,	0x54, 0xff,	0x55, 0xff,	0x56, 0xff,	0x57, 0xff,	0x58, 0x40,		// framing code 	0x59, 0x47,		// horizontal offset	0x5a, 0x06,		// vertical offset	0x5b, 0x83,		// field offset	0x5c, 0x00,		// reserved	0x5d, 0x3e,		// header and data	0x5e, 0x00,		// sliced data	0x5f, 0x00,		// reserved	0x60, 0x00,		/* video decoder reserved part */	0x61, 0x00,	0x62, 0x00,	0x63, 0x00,	0x64, 0x00,	0x65, 0x00,	0x66, 0x00,	0x67, 0x00,	0x68, 0x00,	0x69, 0x00,	0x6a, 0x00,	0x6b, 0x00,	0x6c, 0x00,	0x6d, 0x00,	0x6e, 0x00,	0x6f, 0x00,	0x70, 0x00,		/* video decoder reserved part */	0x71, 0x00,	0x72, 0x00,	0x73, 0x00,	0x74, 0x00,	0x75, 0x00,	0x76, 0x00,	0x77, 0x00,	0x78, 0x00,	0x79, 0x00,	0x7a, 0x00,	0x7b, 0x00,	0x7c, 0x00,	0x7d, 0x00,	0x7e, 0x00,	0x7f, 0x00,	0x80, 0x00,		/* X-port, I-port and scaler */	0x81, 0x00,	0x82, 0x00,	0x83, 0x00,	0x84, 0xc5,	0x85, 0x0d,		// hsync and vsync ? 	0x86, 0x40,	0x87, 0x01,	0x88, 0x00,	0x89, 0x00,	0x8a, 0x00,	0x8b, 0x00,	0x8c, 0x00,	0x8d, 0x00,	0x8e, 0x00,	0x8f, 0x00,	0x90, 0x03,		/* Task A definition           */	0x91, 0x08,	0x92, 0x00,	0x93, 0x40,	0x94, 0x00,		// window settings	0x95, 0x00,	0x96, 0x00,	0x97, 0x00,	0x98, 0x00,	0x99, 0x00,	0x9a, 0x00,	0x9b, 0x00,	0x9c, 0x00,	0x9d, 0x00,	0x9e, 0x00,	0x9f, 0x00,	0xa0, 0x01,		/* horizontal integer prescaling ratio */	0xa1, 0x00,		/* horizontal prescaler accumulation				 * sequence length */	0xa2, 0x00,		/* UV FIR filter, Y FIR filter, prescaler				 * DC gain */	0xa3, 0x00,	0xa4, 0x80,		// luminance brightness	0xa5, 0x40,		// luminance gain	0xa6, 0x40,		// chrominance saturation	0xa7, 0x00,	0xa8, 0x00,		// horizontal luminance scaling increment	0xa9, 0x04,	0xaa, 0x00,		// horizontal luminance phase offset	0xab, 0x00,	0xac, 0x00,		// horizontal chrominance scaling increment	0xad, 0x02,	0xae, 0x00,		// horizontal chrominance phase offset	0xaf, 0x00,	0xb0, 0x00,		// vertical luminance scaling increment	0xb1, 0x04,	0xb2, 0x00,		// vertical chrominance scaling increment	0xb3, 0x04,	0xb4, 0x00,	0xb5, 0x00,	0xb6, 0x00,	0xb7, 0x00,	0xb8, 0x00,	0xb9, 0x00,	0xba, 0x00,

⌨️ 快捷键说明

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