📄 saa7114.c
字号:
/* extdrv/peripheral/vad/saa7114.c
*
* Copyright (c) 2006 ShenZhen Streaming Co., Ltd.
*
* 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;
*
* History:
* 10-5-2006 create this file
*/
#include <linux/module.h>
#include <linux/version.h>
#include <linux/types.h>
#include <linux/sched.h>
#include <linux/fcntl.h>
#include <linux/errno.h>
#include <linux/ioport.h>
#include <linux/config.h>
#include <asm/io.h>
#include <linux/miscdevice.h>
#include <linux/proc_fs.h>
#include <linux/fs.h>
#include <linux/slab.h>
#include <asm/uaccess.h>
#include <linux/string.h>
#include <linux/init.h>
#include <linux/delay.h>
#include <linux/proc_fs.h>
#include <linux/workqueue.h>
#include "hi_i2c.h"
#include "saa7114.h"
#define I2C_SAA7114 (0x88)
#define I2C_TW9910 (0x88)
//#define SAA_7114_PAL_HSYNC_START (-17)
//#define SAA_7114_PAL_HSYNC_STOP (-32)
static int init_flag = 0;
unsigned char TW9910B_CCIR_PAL_DataSet[] = {
0x88, 17,
0x06, 0x00,
0x1a, 0x4f,
0x03, 0xa2,
0x05, 0x01,
0x08, 0x19,
0x09, 0x1f,
0x19, 0x57,
0x1a, 0x0f,
0x1b, 0xc0, //0x1b, 0x00,
0x29, 0x03, // vertical sync start(line unit)
0x55, 0x00,
0x6b, 0x26,
0x6c, 0x36,
0x6d, 0xf0, //0x9f,
0x6e, 0x28, //0x6e, 0x41,
0x1a, 0x0f,
0x06, 0x80, //software reset
0xff, 0xff
};
unsigned char TW9910B_PAL[] = {
0x88, 2,
0x08, 0x19,
0x09, 0x1f,
// 0x0a, 0x0c,
0xff, 0xff
};
#if 0
static unsigned char init_pal[] = {
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_PAL_HSYNC_START, /* 06 - HSB: hsync start,yyb
* depends on the video standard */
0x07, SAA_7114_PAL_HSYNC_STOP, /* 07 - HSS: hsync stop, depends yyb
*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, 0x81, /* 0e - CDTO, CSTD2 to 0, DCVF, FCTC,yyb
* 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,
0xbb, 0x00,
0xbc, 0x00,
0xbd, 0x00,
0xbe, 0x00,
0xbf, 0x00,
0xc0, 0x00, // Task B definition,yyb
0xc1, 0x08,
0xc2, 0x00,
0xc3, 0x40,
0xc4, 0x00, // window settings
0xc5, 0x00,
0xc6, 0x00,
0xc7, 0x00,
0xc8, 0x00,
0xc9, 0x00,
0xca, 0x00,
0xcb, 0x00,
0xcc, 0x00,
0xcd, 0x00,
0xce, 0x00,
0xcf, 0x00,
0xd0, 0x01, // horizontal integer prescaling ratio
0xd1, 0x00, // horizontal prescaler accumulation sequence length
0xd2, 0x00, // UV FIR filter, Y FIR filter, prescaler DC gain
0xd3, 0x00,
0xd4, 0x80, // luminance brightness
0xd5, 0x40, // luminance gain
0xd6, 0x40, // chrominance saturation
0xd7, 0x00,
0xd8, 0x00, // horizontal luminance scaling increment
0xd9, 0x04,
0xda, 0x00, // horizontal luminance phase offset
0xdb, 0x00,
0xdc, 0x00, // horizontal chrominance scaling increment
0xdd, 0x02,
0xde, 0x00, // horizontal chrominance phase offset
0xdf, 0x00,
0xe0, 0x00, // vertical luminance scaling increment
0xe1, 0x04,
0xe2, 0x00, // vertical chrominance scaling increment
0xe3, 0x04,
0xe4, 0x00,
0xe5, 0x00,
0xe6, 0x00,
0xe7, 0x00,
0xe8, 0x00,
0xe9, 0x00,
0xea, 0x00,
0xeb, 0x00,
0xec, 0x00,
0xed, 0x00,
0xee, 0x00,
0xef, 0x00
};
unsigned char m_auc_vi_regtab2[0x20]=
{
/* DEC SAA7114 */
0x00,0x08,0xC0,0x33,0x00,0x00,0xEB,0xE0,
0xB8,0x60,0x80,0x42,0x43,0x00,0x01,0x25,
0xF8,0x09,0x5f,0x10,0x20,0x00,0x34,0x46,
0x40,0x80,0x00,0x00,0x00,0x00,0x00,0x00
};
unsigned char m_auc_vi_regtab3[0x30]=
{
0x00,0x72,0x03,0x00,0xCD,0xCC,0x3A,0x00,
0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x00,0x47,0x03,0x03,0x00,0x80,0x00,0x00
};
unsigned char m_auc_vi_regtab4[0x40]=
{
0x50,0x00,0x00,0x00,0x01,0x00,0xC0,0x01,
0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x08,0x10,0x80,0x08,0x00,0xD0,0x02,
0x04,0x00,0x33,0x01,0xD0,0x02,0x30,0x01,
0x01,0x00,0x00,0x00,0x80,0x40,0x40,0x00,
0x00,0x04,0x00,0x00,0x00,0x02,0x00,0x00,
0x00,0x04,0x00,0x04,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
static int set_vbi_slicer(void)
{
unsigned char data_tbl[32] = {
0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0x40, 0x47, 0x06, 0x83, 0x00, 0x3e, 0x00, 0x00
};
unsigned char addr_base = 0x40;
unsigned char i = 0;
for (i=0; i<32; i++)
{
if(hi_i2c_write(I2C_SAA7114,addr_base+i, data_tbl[i])!= 0 )
{
return -1;
}
}
return 0;
}
static int set_scaler_window(void)
{
unsigned char data_tbl_p[16] = {
0x00, 0x08, 0x00, 0x80, 0x10, 0x00, 0xd0, 0x02,
0x00, 0x00, 0x06, 0x01, 0xd0, 0x02, 0x06, 0x01
};
unsigned char addr_base = 0x90;
unsigned char i = 0;
for (i=0; i<16; i++)
{
if(hi_i2c_write(I2C_SAA7114,addr_base+i, data_tbl_p[i])!= 0 )
{
return -1;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -