📄 saa7114.c
字号:
/*
* Copyright (c) 1995 - 1999 by TriMedia Technologies.
*
* +------------------------------------------------------------------+
* | This software is furnished under a license and may only be used |
* | and copied in accordance with the terms and conditions of such |
* | a license and with the inclusion of this copyright notice. This |
* | software or any other copies of this software may not be provided|
* | or otherwise made available to any other person. The ownership |
* | and title of this software is not transferred. |
* | |
* | The information in this software is subject to change without |
* | any prior notice and should not be construed as a commitment by |
* | TriMedia Technologies. |
* | |
* | this code and information is provided "as is" without any |
* | warranty of any kind, either expressed or implied, including but |
* | not limited to the implied warranties of merchantability and/or |
* | fitness for any particular purpose. |
* +------------------------------------------------------------------+
*
*
* Module name : saa7114.c 1.9
*
* Last update : 11:58:38 - 99/06/23
*
* Description :
*
* Initialize and control routines for saa7114
*
*
* Revision :
* Built for the TCS 2.0 release
*
*
*/
#include <stdio.h>
#include <tm1/tmIIC.h>
#include <tm1/tmAvFormats.h>
#include <tm1/tmVImmio.h>
#include <tm1/tmVIboard.h>
#include <tmlib/dprintf.h>
#include <saa7114.h>
/* OLDSB = 0, so the masks are slightly different and not compatible with */
/* old versions */
#define A_HLCK 0x40 /* OLDSB = 1. Horizontal freq locked */
#define A_HLVLN 0x40 /* OLDSB = 0 Horizontal/Vertical freq locked */
#define A_FIDT 0x20 /* LOW = 50Hz, HIGH = 60 Hz */
#define A_RDCAP 0x01 /* OLDSB = 0. Ready for capture */
#define A_CODE 0x01 /* OLDSB = 1. Colour Signal in accordance w/ selected standard */
/******************************************************************************/
/* Default structures for video decoder configuration (supports 1 default instance) */
#define NUM_OF_DEF_ADAPTER 2
static boardVIAdapterEntry_t defAdapters[NUM_OF_DEF_ADAPTER] = {
{ vaaCVBS, 0, 1 },
{ vaaSvideo, 0, 9 }
};
static boardVIDec_t defaultVD [1] =
{
{ 0x40, /* I2C slave address of first decoder */
NUM_OF_DEF_ADAPTER, /* Number of adapters */
defAdapters } /* mapping of adapters to inputs */
};
/******************************************************************************/
/* Definitions and structures used by the video DecHAL implementation */
/******************************************************************************/
/* Definitions and structures used by the video DecHAL implementation */
typedef enum
{
ChipVersion= 0x00,
/* front-end part */
IncrementDelay= 0x01,
AnalogInputControl1= 0x02,
AnalogInputControl2= 0x03,
AnalogInputControl3= 0x04,
AnalogInputControl4= 0x05,
/* decoder part */
HorzSyncStart= 0x06,
HorzSyncStop= 0x07,
SyncControl= 0x08,
LuminanceControl= 0x09,
LuminanceBrightness= 0x0A,
LuminanceContrast= 0x0B,
ChromaSaturation= 0x0C,
ChromaHueControl= 0x0D,
ChromaControl1= 0x0E,
ChromaGainControl= 0x0F,
ChromaControl2= 0x10,
ModeDelayControl= 0x11,
RTSignalControl= 0x12,
RTOutputControl= 0x13,
CompatibilityControl= 0x14,
VGateStart= 0x15,
VGateStop= 0x16,
VGateMSB= 0x17,
RawDataGain= 0x18,
RawDataOffset= 0x19,
StatusByte= 0x1F,
/* Textslicer */
AC1= 0x40,
LCR2= 0x41,
LCR3= 0x42,
LCR4= 0x43,
LCR5= 0x44,
LCR6= 0x45,
LCR7= 0x46,
LCR8= 0x47,
LCR9= 0x48,
LCR10= 0x49,
LCR11= 0x4A,
LCR12= 0x4B,
LCR13= 0x4C,
LCR14= 0x4D,
LCR15= 0x4E,
LCR16= 0x4F,
LCR17= 0x50,
LCR18= 0x51,
LCR19= 0x52,
LCR20= 0x53,
LCR21= 0x54,
LCR22= 0x55,
LCR23= 0x56,
LCR24= 0x57,
FC= 0x58,
HOFF= 0x59,
VOFF= 0x5A,
HVOFF= 0x5B,
DID= 0x5D,
SDID= 0x5E,
DR= 0x60,
LN1= 0x61,
LN2= 0x62,
LineFlagsEven1= 0x63,
LineFlagsEven2= 0x64,
LineFlagsEven3= 0x65,
LineFlagsOdd1= 0x66,
LineFlagsOdd2= 0x67,
LineFlagsOdd3= 0x68,
/* X-Port, I-Port and scaler */
GlobalControl1= 0x80,
XPortIO= 0x83,
IPortSignalDef= 0x84,
IPortSignalPol= 0x85,
IPortFIFOFlag= 0x86,
IPortIODelay= 0x87,
PowerSaveControl= 0x88,
ScalerStatus= 0x8F,
/* task A */
ATaskHandlingControl= 0x90,
AXPortFormat= 0x91,
AXPortInputRef= 0x92,
AIPortFormat= 0x93,
AHorzInputStart= 0x94,
AHorzInputStartMSB= 0x95,
AHorzInputLength= 0x96,
AHorzInputLengthMSB= 0x97,
AVertInputStart= 0x98,
AVertInputStartMSB= 0x99,
AVertInputLength= 0x9A,
AVertInputLengthMSB= 0x9B,
AHorzOutputLength= 0x9C,
AHorzOutputLengthMSB= 0x9D,
AVertOutputLength= 0x9E,
AVertOutputLengthMSB= 0x9F,
AHorzPrescale= 0xA0,
AAcl= 0xA1,
ADCGain= 0xA2,
ALuminanceBrightness= 0xA4,
ALuminanceContrast= 0xA5,
AChromaSaturation= 0xA6,
AHorzScalingLuma= 0xA8,
AHorzScalingLumaMSB= 0xA9,
AHorzPhaseLuma= 0xAA,
AHorzScalingChroma= 0xAC,
AHorzScalingChromaMSB= 0xAD,
AHorzPhaseChroma= 0xAE,
AVertScalingLuma= 0xB0,
AVertScalingLumaMSB= 0xB1,
AVertScalingChroma= 0xB2,
AVertScalingChromaMSB= 0xB3,
AVertScalingMode= 0xB4,
AVertPhaseChroma00= 0xB8,
AVertPhaseChroma01= 0xB9,
AVertPhaseChroma10= 0xBA,
AVertPhaseChroma11= 0xBB,
AVertPhaseLuma00= 0xBC,
AVertPhaseLuma01= 0xBD,
AVertPhaseLuma10= 0xBE,
AVertPhaseLuma11= 0xBF,
/* task B */
BTaskHandlingControl= 0xC0,
BXPortFormat= 0xC1,
BXPortInputRef= 0xC2,
BIPortFormat= 0xC3,
BHorzInputStart= 0xC4,
BHorzInputStartMSB= 0xC5,
BHorzInputLength= 0xC6,
BHorzInputLengthMSB= 0xC7,
BVertInputStart= 0xC8,
BVertInputStartMSB= 0xC9,
BVertInputLength= 0xCA,
BVertInputLengthMSB= 0xCB,
BHorzOutputLength= 0xCC,
BHorzOutputLengthMSB= 0xCD,
BVertOutputLength= 0xCE,
BVertOutputLengthMSB= 0xCF,
BHorzPrescale= 0xD0,
BAcl= 0xD1,
BDCGain= 0xD2,
BLuminanceBrightness= 0xD4,
BLuminanceContrast= 0xD5,
BChromaSaturation= 0xD6,
BHorzScalingLuma= 0xD8,
BHorzScalingLumaMSB= 0xD9,
BHorzPhaseLuma= 0xDA,
BHorzScalingChroma= 0xDC,
BHorzScalingChromaMSB= 0xDD,
BHorzPhaseChroma= 0xDE,
BVertScalingLuma= 0xE0,
BVertScalingLumaMSB= 0xE1,
BVertScalingChroma= 0xE2,
BVertScalingChromaMSB= 0xE3,
BVertScalingMode= 0xE4,
BVertPhaseChroma00= 0xE8,
BVertPhaseChroma01= 0xE9,
BVertPhaseChroma10= 0xEA,
BVertPhaseChroma11= 0xEB,
BVertPhaseLuma00= 0xEC,
BVertPhaseLuma01= 0xED,
BVertPhaseLuma10= 0xEE,
BVertPhaseLuma11= 0xEF,
} decoderRegs_t;
typedef struct
{
Int nSubAddr;
Int nValue;
} viRegValue;
static viRegValue saa7114_defRegs[] = {
{IncrementDelay, 0x00},
{AnalogInputControl1, 0xC1},
{AnalogInputControl2, 0x23},
{AnalogInputControl3, 0x00},
{AnalogInputControl4, 0x00},
{HorzSyncStart, 0x00},
{HorzSyncStop, 0x00},
{SyncControl, 0x88},
{LuminanceControl, 0x10},
{LuminanceBrightness, 0x80},
{LuminanceContrast, 0x47},
{ChromaSaturation, 0x40},
{ChromaHueControl, 0x00},
{ChromaControl1, 0x01},
{ChromaGainControl, 0x00},
{ChromaControl2, 0xc8},
{ModeDelayControl, 0xf9},
{RTSignalControl, 0x11},
{RTOutputControl, 0x00},
{CompatibilityControl, 0x00},
{VGateStart, 0x00},
{VGateStop, 0x01},
{VGateMSB, 0x00},
{RawDataGain, 0x40},
{RawDataOffset, 0x80},
{StatusByte, 0x00},
{AC1, 0x02},
{LCR2, 0xFF},
{LCR3, 0xFF},
{LCR4, 0xFF},
{LCR5, 0xFF},
{LCR6, 0xFF},
{LCR7, 0xFF},
{LCR8, 0xFF},
{LCR9, 0xFF},
{LCR10, 0xFF},
{LCR11, 0xFF},
{LCR12, 0xFF},
{LCR13, 0xFF},
{LCR14, 0xFF},
{LCR15, 0xFF},
{LCR16, 0xFF},
{LCR17, 0xFF},
{LCR18, 0xFF},
{LCR19, 0xFF},
{LCR20, 0xFF},
{LCR21, 0xFF},
{LCR22, 0xFF},
{LCR23, 0xFF},
{LCR24, 0xFF},
{FC, 0x00},
{HOFF, 0x54},
{VOFF, 0x0A},
{HVOFF, 0x03},
{DID, 0x00},
{SDID, 0x13},
{DR, 0x00},
{LN1, 0x0c},
{LN2, 0x2F},
{LineFlagsEven1, 0x00},
{LineFlagsEven2, 0x00},
{LineFlagsEven3, 0x00},
{LineFlagsOdd1, 0x00},
{LineFlagsOdd2, 0x00},
{LineFlagsOdd3, 0x00},
/* X-Port}, I-Port and scaler */
{XPortIO, 0x01},
{IPortSignalDef, 0x40},
{IPortSignalPol, 0x08},
{IPortFIFOFlag, 0x40},
{IPortIODelay, 0x01},
{PowerSaveControl, 0xc0},
{ScalerStatus, 0x00},
/* task A */
{ATaskHandlingControl, 0x02},
{AXPortFormat, 0x08},
{AXPortInputRef, 0x00},
{AIPortFormat, 0x80},
{AHorzInputStart, 0x10},
{AHorzInputStartMSB, 0x00},
{AHorzInputLength, 0xd0},
{AHorzInputLengthMSB, 0x02},
{AVertInputStart, 0x0A},
{AVertInputStartMSB, 0x00},
{AVertInputLength, 0xF2},
{AVertInputLengthMSB, 0x00},
{AHorzOutputLength, 0xd0},
{AHorzOutputLengthMSB, 0x02},
{AVertOutputLength, 0xD0},
{AVertOutputLengthMSB, 0x00},
{AHorzPrescale, 0x02},
{AAcl, 0x01},
{ADCGain, 0x01},
/* Start scaling on task A */
{GlobalControl1, 0x90},
{ALuminanceBrightness, 0x80},
{ALuminanceContrast, 0x20},
{AChromaSaturation, 0x20},
{AHorzScalingLuma, 0x00},
{AHorzScalingLumaMSB, 0x04},
{AHorzPhaseLuma, 0x00},
{AHorzScalingChroma, 0x00},
{AHorzScalingChromaMSB, 0x02},
{AHorzPhaseChroma, 0x00},
{AVertScalingLuma, 0xf8},
{AVertScalingLumaMSB, 0x07},
{AVertScalingChroma, 0xf8},
{AVertScalingChromaMSB, 0x07},
{AVertScalingMode, 0x01},
{AVertPhaseChroma00, 0x00},
{AVertPhaseChroma01, 0x00},
{AVertPhaseChroma10, 0x00},
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -