📄 saa7125.c
字号:
/*
* Copyright (c) 1995-1999 by Philips Semiconductors.
*
* +------------------------------------------------------------------+
* | 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 |
* | Philips Semiconductors. |
* | |
* | 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 : saa7125.c 1.19
*
* Last update : 11:06:59 - 99/02/15
*
*
* Description :
*
* Initialize and control routines for saa7125 DENC.
*
* Revision :
* Built for the TCS 2.0 release
*
*/
#include <stdio.h>
#include <tm1/tmIIC.h>
#include <tm1/tmAvFormats.h>
#include <tm1/tmVO.h>
#include <tm1/tmProcessor.h>
#include <tmlib/tmtypes.h>
#include <unistd.h>
#include "saa7125.h"
#define NO_SUPPORT_7121 1
#define SAA7125_NREGS 0x7E /* number of 7125 registers */
#define SAA7125_STARADR 0x38 /* Start for sub-addresses for 7125 */
#define SAA7125_ADDR 0x8c /* SAA7125 IIC address */
#define SAA7125_GAIN_U_REG 0x5B
#define SAA7125_GAIN_V_REG 0x5C
#define SAA7125_BLACKLEVEL_REG 0x5D /* bits 0-5 */
#define SAA7125_CONSTRAST_REG 0x5E
/* Initialization values; starts at SAA7125_STARADR */
/* SAA 7125 in master mode */
static unsigned char saa7125_init[SAA7125_NREGS - SAA7125_STARADR] = {
/* 0x38 */ 0x00, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00,
/* 0x40 */ 0x00, 0x00, 0x6B, 0x00, 0x00, 0x22, 0xAC, 0x0E,
/* 0x48 */ 0x03, 0x1D, 0xAC, 0xF0, 0xC8, 0xB9, 0xD4, 0x38,
/* 0x50 */ 0x47, 0xC1, 0xE3, 0x54, 0xA3, 0x54, 0xF2, 0x90,
/* 0x58 */ 0x00, 0x00, 0x68, 0x82, 0xB6, 0x2D, 0x3F, 0x00,
/* 0x60 */ 0x38, 0x56, 0x4E, 0xCB, 0x8A, 0x09, 0x2A, 0x00,
/* 0x68 */ 0x00, 0x00, 0x00, 0x11, 0x7A, 0x04, 0xAC, 0x06,
/* 0x70 */ 0x0C, 0x77, 0xF7, 0x33, 0x00, 0x00, 0x00, 0x00,
/* 0x78 */ 0x03, 0x00, 0x70, 0x12, 0x35, 0x22
};
typedef struct subaddInfo_t {
UInt8 subAddr; /* subaddress of IIC register */
UInt8 value; /* data for IIC register */
} subaddInfo_t;
static subaddInfo_t saa7125_pal[] = {
{0x61, 0xC6}, /* Standard Control */
{0x3A, 0x3B}, /* Input port control */
{0x5A, 0x68}, /* Chroma Phase */
{0x5B, 0x7D}, /* Gain-U */
{0x5C, 0xAF}, /* Gain-V */
{0x5D, 0x2D}, //0x5d,0x2D /* Gain-U MSB, Black Level */
{0x5E, 0x3F}, //3f /* Gain-V MSB, Blanking Level */
{0x5F, 0x3F}, //3f /* Gain-V MSB, Blanking Level in Vertical */
{0x62, 0x4B}, /* Burst Amplitude */
{0x63, 0xCB}, /* Subcarrier Frequency, Byte 0 */
{0x64, 0x8A}, /* Subcarrier Frequency, Byte 1 */
{0x65, 0x09}, /* Subcarrier Frequency, Byte 2 */
{0x66, 0x2A}, /* Subcarrier Frequency, Byte 3 */
{0x67, 0xAA}, /* */
{0x68, 0x00}, /* */
{0x69, 0x00}, /* */
{0x6A, 0x00}, /* */
{0x6B, 0x45}, /* FS on RCV1 falling, Htrig on RCV2 falling */
{0x6C, 0x1D}, /* Horizontal Trigger (LSB's) */
{0x6D, 0x24}, /* Horizontal Trigger (MSB's) + Vtrig */
{0x6E, 0x80}, /* Reset when changing Subcarrier frequency */
{0x6F, 0xD1}, /* CC */
{0x70, 0x00}, /* Begin RCV2 output */
{0x71, 0x00}, /* End RCV2 output */
{0x72, 0x00}, /* MSBs RCV2 output */
{0x7A, 0x16}, /* First Active Line don't care if 0x6E is 0x80 */
{0x7B, 0x36}, /* Last Active Line don't care if 0x6E is 0x80 */
{0x7C, 0x40}, /* (MSB's), don't care if 0x6E is 0x80 */
};
/*
For the NTSC case you can change the value written to 0x6E address by 0x80.
This way the denc will use the SAV/EAV codes generated by VO and not its
internal counters.
*/
static subaddInfo_t saa7125_ntsc[] = {
{0x61, 0xD5}, /* Standard Control */
{0x3A, 0x3B}, /* Input port control */
{0x42, 0x6B}, /* OSD Lut */
{0x45, 0x52}, /* OSD Lut */
{0x46, 0x90}, /* OSD Lut */
{0x47, 0x12}, /* OSD Lut */
{0x48, 0x2A}, /* OSD Lut */
{0x49, 0x26}, /* OSD Lut */
{0x4A, 0x90}, /* OSD Lut */
{0x4B, 0x11}, /* OSD Lut */
{0x4C, 0xB6}, /* OSD Lut */
{0x4D, 0xA2}, /* OSD Lut */
{0x4E, 0xEA}, /* OSD Lut */
{0x4F, 0x4A}, /* OSD Lut */
{0x50, 0x5E}, /* OSD Lut */
{0x51, 0xD1}, /* OSD Lut */
{0x52, 0xDA}, /* OSD Lut */
{0x53, 0x70}, /* OSD Lut */
{0x54, 0xA9}, /* OSD Lut */
{0x55, 0x70}, /* OSD Lut */
{0x56, 0xEE}, /* OSD Lut */
{0x57, 0x90}, /* OSD Lut */
{0x5A, 0x33}, /* Chroma Phase */
{0x5B, 0x79}, /* Gain-U */
{0x5C, 0xAD}, /* Gain-V */
{0x5D, 0x3C}, /* Gain-U MSB, Black Level */
{0x5E, 0x3A}, /* Gain-V MSB, Blanking Level */
{0x5F, 0x3A}, /* Gain-V MSB, Blanking Level in Vertical */
{0x61, 0xD5}, /* Standard Control */
{0x62, 0x69}, /* Burst Amplitude */
{0x63, 0x1F}, /* Subcarrier Frequency, Byte 0 */
{0x64, 0x7C}, /* Subcarrier Frequency, Byte 1 */
{0x65, 0xF0}, /* Subcarrier Frequency, Byte 2 */
{0x66, 0x21}, /* Subcarrier Frequency, Byte 3 */
{0x67, 0xAA}, /* */
{0x68, 0x00}, /* */
{0x69, 0x00}, /* */
{0x6A, 0x00}, /* */
{0x6B, 0x45}, /* Input Port & Closed Caption-Select Line Number */
{0x6C, 0xF1}, /* Horizontal Trigger (LSB's) */
{0x6D, 0x00}, /* Vertical and Horizontal Trigger (MSB's) */
{0x6E, 0x80}, /* Horizontal Trigger (MSB's) */
{0x6F, 0xD1}, /* Reset when changing Subcarrier frequency */
{0x70, 0x00}, /* Begin MP request */
{0x71, 0x00}, /* End MP request */
{0x72, 0x00}, /* MSBs MP request */
{0x7A, 0x12}, /* First Active Line */
{0x7B, 0x03}, /* Last Active Line */
{0x7C, 0x40} /* Field Control (MSB's) */
};
/** ** Public Config function ****/
static
tmLibdevErr_t
saa7125Config(unsigned long address, subaddInfo_t * tobeupdated, unsigned long last_address)
{
int i;
unsigned char subaddr, data;
int retval = 0;
#if NO_SUPPORT_7121
return TMLIBDEV_OK;
#endif
/* Update the device */
for (i = 0; i < last_address; i++) {
subaddr = tobeupdated[i].subAddr;
data = tobeupdated[i].value;
retval |= iicWriteReg(address, subaddr, data);
} /* end of for() */
return ((tmLibdevErr_t) retval);
} /* end of saa7125Config() */
/**** Public Init function ****/
tmLibdevErr_t
saa7125Init(pboardVOParam_t param)
{
return ((tmLibdevErr_t) retval);
}
/** Public Config function ****/
tmLibdevErr_t
saa7125Configure(unsigned long subaddr, unsigned long value)
{
int err;
tmLibdevErr_t retval = TMLIBDEV_OK;
#if NO_SUPPORT_7121
return TMLIBDEV_OK;
#endif
err = iicWriteReg(SAA7125_ADDR, subaddr, value);
if (err)
retval |= err;
return (retval);
}
/************************** Turn Denc DAC on *****************************/
tmLibdevErr_t
saa7125Start(tmVideoAnalogStandard_t standard)
{
#if NO_SUPPORT_7121
return TMLIBDEV_OK;
#endif
if (standard == vasNTSC)
return (iicWriteReg(SAA7125_ADDR, 0x61, 0x15));
else
return (iicWriteReg(SAA7125_ADDR, 0x61, 0x16));
}
/************************** Turn Denc DAC off *****************************/
tmLibdevErr_t
saa7125Stop(tmVideoAnalogStandard_t standard)
{
#if NO_SUPPORT_7121
return TMLIBDEV_OK;
#endif
if (standard == vasNTSC)
return (iicWriteReg(SAA7125_ADDR, 0x61, 0xD5));
else
return (iicWriteReg(SAA7125_ADDR, 0x61, 0xD6));
}
/************************** Set Brightness (or Balck Level) *****************/
tmLibdevErr_t
saa7125SetBrightness(unsigned int val)
{
#if NO_SUPPORT_7121
return TMLIBDEV_OK;
#endif
if (val > 63)
return BOARD_ERR_VAL_OUT_OF_RANGE;
return iicWriteReg(SAA7125_ADDR, SAA7125_BLACKLEVEL_REG, val);
}
tmLibdevErr_t
saa7125SetContrast(unsigned int val)
{
#if NO_SUPPORT_7121
return TMLIBDEV_OK;
#endif
if (val > 63)
return BOARD_ERR_VAL_OUT_OF_RANGE;
return iicWriteReg(SAA7125_ADDR, SAA7125_CONSTRAST_REG, val);
}
tmLibdevErr_t
saa7125SetSaturation(unsigned int val)
{
#if NO_SUPPORT_7121
return TMLIBDEV_OK;
#endif
if (val > 255)
return BOARD_ERR_VAL_OUT_OF_RANGE;
return iicWriteReg(SAA7125_ADDR, SAA7125_GAIN_V_REG, val);
}
tmLibdevErr_t
saa7125SetHue(unsigned int val)
{
#if NO_SUPPORT_7121
return TMLIBDEV_OK;
#endif
if (val > 255)
return BOARD_ERR_VAL_OUT_OF_RANGE;
return iicWriteReg(SAA7125_ADDR, SAA7125_GAIN_U_REG, val);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -