saa7121.c
上传用户:dahaojd
上传日期:2008-01-29
资源大小:14357k
文件大小:3k
- /*
- * Copyright 2003 by Texas Instruments Incorporated.
- * All rights reserved. Property of Texas Instruments Incorporated.
- * Restricted rights to use, duplicate or disclose this code are
- * granted through contract.
- *
- */
- /* "@(#) DDK 1.10.00.23 07-02-03 (ddk-b12)" */
- /********************************************************************************/
- /* saa7105edc.c file */
- /********************************************************************************/
- #include <std.h>
- #include <csl_stdinc.h>
- #include <csl_i2c.h>
- #include <edc.h>
- #include <saa7121.h>
- #include "_iic.h"
- #include "_saa7121.h"
-
- /* local functions declaration */
- static EDC_Handle SAA7121_open(String devName, Arg optArg);
- static Int SAA7121_close(EDC_Handle handle);
- static Int SAA7121_ctrl(EDC_Handle handle, SAA7121_Cmd cmd, Arg param);
- static void configSAA7121(Int devId, SAA7121_Mode videoInMode);
- static void resetSAA7121(Int devId);
- static void powerdownSAA7121(Int devId);
- static void powerupSAA7121(Int devId);
- static void setI2CRegs(Int devId, _SAA7121_I2CReg I2CRegs[]);
- EDC_Fxns SAA7121_Fxns = {
- SAA7121_open,
- SAA7121_close,
- SAA7121_ctrl
- };
- /* local variables and arrays */
- static I2C_Handle hI2C;
- static Uint8 addrI2C[2]={_SAA7121_IICADDR0, _SAA7121_IICADDR1}; //for 642c
- /*
- * ======== SAA7121_open ========
- */
- static EDC_Handle SAA7121_open(String devName, Arg optArg)
- {
- Int devId;
- /* Check if the addresse is correct */
- if(devName[0]!='/'||devName[1]<'0'||devName[1]>'1') {
- devId = -1;
- } else
- {
- devId = devName[1]-'0';
- }
- return (EDC_Handle)devId;
- }
- /*
- * ======== SAA7121_open ========
- */
- static Int SAA7121_close(EDC_Handle handle)
- {
- Int devId = (int)handle;
- powerdownSAA7121(devId);
- return EDC_SUCCESS;
- }
- /*
- * ======== SAA7121_ctrl ========
- */
- static Int SAA7121_ctrl(EDC_Handle handle, SAA7121_Cmd cmd, Arg arg)
- {
- Int devId = (int)handle;
- SAA7121_ConfParams *SAA7121Params;
- /*First Check if the Handle is correct */
- if(devId <0 || devId >1) {
- return EDC_FAILED;
- }
-
- switch(cmd) {
- case EDC_CONFIG:
- SAA7121Params = (SAA7121_ConfParams *)arg;
- hI2C = SAA7121Params->hI2C;
- configSAA7121(devId, SAA7121Params->mode);
- break;
- case EDC_RESET:
- resetSAA7121(devId);
- break;
- case SAA7121_POWERDOWN:
- powerdownSAA7121(devId);
- break;
- case SAA7121_POWERUP:
- powerupSAA7121(devId);
- break;
- default:
- break;
- }
- return EDC_SUCCESS;
- }
- /*
- * ======== configSAA7105 ========
- */
- static void configSAA7121(Int devId, SAA7121_Mode videoInMode)//, Bool enableBT656Sync)
- {
- _SAA7121_I2CReg* pI2CRegs;
- if(videoInMode==SAA7121_MODE_PAL)pI2CRegs=SAA7121_PalRegParam;
- else if(videoInMode==SAA7121_MODE_NTSC)pI2CRegs=SAA7121_NtscRegParam;
- setI2CRegs(devId, pI2CRegs);
- }
- static void setI2CRegs(Int devId, _SAA7121_I2CReg I2CRegs[])
- {
- Int i;
- for(i=0;i<256;i++)
- {
- if(I2CRegs[i].subaddr==0xFF)break;
- _IIC_write(hI2C, addrI2C[devId], I2CRegs[i].subaddr, &I2CRegs[i].content,1);
- }
- }
- static void resetSAA7121(Int devId)
- {
- setI2CRegs(devId, SAA7121_ResetRegParam);
- }
- static void powerdownSAA7121(Int devId)
- {
- }
- static void powerupSAA7121(Int devId)
- {
- }