📄 tmbslsaa7104.c
字号:
if (gSaa7104Inst[avoUnit].init != TM_TRUE )
return TMBSL_ERR_VENCANA_NOT_INITIALIZED;
*pPowerState = gSaa7104Inst[avoUnit].powerState;
return TM_OK;
}
/******************************************************************************/
tmErrorCode_t tmbsl7104VoSetPowerState(
tmUnitSelect_t avoUnit,
tmPowerState_t powerState
)
{
tmErrorCode_t tmRetVal = TM_OK;
UInt8 bMiscData;
if (avoUnit >= SAA7104_MAX_UNITS)
return TMBSL_ERR_VENCANA_BAD_UNIT_NUMBER;
if (gSaa7104Inst[avoUnit].init != TM_TRUE )
return TMBSL_ERR_VENCANA_NOT_INITIALIZED;
// Get power state
tmRetVal = saa7104GetReg (avoUnit, 0x61, &bMiscData);
if ( tmRetVal != TM_OK )
return tmRetVal;
// Set power state of video DACs
switch(powerState)
{
case tmPowerStandby:
{
// Enable Black only output
bMiscData &= 0x3f;
bMiscData |=0x40;
tmRetVal = saa7104SetReg (avoUnit, 0x61, bMiscData);
}
break;
case tmPowerSuspend:
case tmPowerOff:
{
// Ensure Power down bit is on - bit 0
bMiscData |=(0xc0);
// Set Power state of DACs
tmRetVal = saa7104SetReg (avoUnit, 0x61, bMiscData);
}
break;
case tmPowerOn:
default:
{
// Ensure Power down bit is off - bit 0
bMiscData &= 0x3f;
// Set Power state of DACs
tmRetVal = saa7104SetReg (avoUnit, 0x61, bMiscData);
}
break;
}
if( tmRetVal == TM_OK )
gSaa7104Inst[avoUnit].powerState = powerState;
return tmRetVal;
}
/******************************************************************************/
tmErrorCode_t tmbsl7104VoConfigFunc(
tmUnitSelect_t avoUnit,
UInt32 reg,
UInt32 val
)
{
tmErrorCode_t tmRetVal;
if (avoUnit >= SAA7104_MAX_UNITS)
return TMBSL_ERR_VENCANA_BAD_UNIT_NUMBER;
if (gSaa7104Inst[avoUnit].init != TM_TRUE )
return TMBSL_ERR_VENCANA_NOT_INITIALIZED;
// Set register
tmRetVal = saa7104SetReg(avoUnit, (UInt8) reg, (UInt8) val);
return tmRetVal;
}
/******************************************************************************/
tmErrorCode_t tmbsl7104VoConfigReadFunc(
tmUnitSelect_t avoUnit,
UInt8 reg,
UInt8* pval
)
{
tmErrorCode_t tmRetVal;
if (avoUnit >= SAA7104_MAX_UNITS)
return TMBSL_ERR_VENCANA_BAD_UNIT_NUMBER;
if (gSaa7104Inst[avoUnit].init != TM_TRUE )
return TMBSL_ERR_VENCANA_NOT_INITIALIZED;
// Set register
tmRetVal = saa7104GetReg(avoUnit, reg, pval);
return tmRetVal;
}
/******************************************************************************/
tmErrorCode_t tmbsl7104SetVideoColor(
tmUnitSelect_t avoUnit,
tmVideoColor_t color,
UInt32 val
)
{
tmErrorCode_t tmRetVal = TM_OK;
// Check if valid unit
if (avoUnit >= SAA7104_MAX_UNITS)
return TMBSL_ERR_VENCANA_BAD_UNIT_NUMBER;
if (gSaa7104Inst[avoUnit].init != TM_TRUE )
return TMBSL_ERR_VENCANA_NOT_INITIALIZED;
switch( color )
{
case vctBrightness: // TODO: set brightness
gSaa7104Inst[avoUnit].brightness = val;
break;
case vctContrast: // TODO: set contrast
gSaa7104Inst[avoUnit].contrast = val;
break;
case vctSaturation: // TODO: set saturation
gSaa7104Inst[avoUnit].saturation = val;
break;
case vctHue: // TODO: set hue
gSaa7104Inst[avoUnit].hue = val;
break;
case vctNone:
break;
case vctSharpness: // sharpness is not supported
tmRetVal = TMBSL_ERR_VENCANA_NOT_SUPPORTED;
break;
default:
tmRetVal = TMBSL_ERR_VENCANA_BAD_PARAMETER;
break;
}
return tmRetVal;
}
/******************************************************************************/
tmErrorCode_t tmbsl7104GetVideoColor(
tmUnitSelect_t avoUnit,
tmVideoColor_t color,
UInt32 *pVal
)
{
tmErrorCode_t tmRetVal = TM_OK;
DBG_ASSERT(pVal != Null);
if (avoUnit >= SAA7104_MAX_UNITS)
return TMBSL_ERR_VENCANA_BAD_UNIT_NUMBER;
if (gSaa7104Inst[avoUnit].init != TM_TRUE )
return TMBSL_ERR_VENCANA_NOT_INITIALIZED;
switch( color )
{
case vctBrightness:
*pVal = gSaa7104Inst[avoUnit].brightness;
break;
case vctContrast:
*pVal = gSaa7104Inst[avoUnit].contrast;
break;
case vctSaturation:
*pVal = gSaa7104Inst[avoUnit].saturation;
break;
case vctHue:
*pVal = gSaa7104Inst[avoUnit].hue;
break;
case vctSharpness:
*pVal = gSaa7104Inst[avoUnit].sharpness;
break;
case vctNone:
break;
default:
tmRetVal = TMBSL_ERR_VENCANA_BAD_PARAMETER;
break;
}
return tmRetVal;
}
/******************************************************************************
* STATIC FUNCTIONS *
*******************************************************************************/
/******************************************************************************/
/** Initialize 7104's video output mode according to setup structure.
@pre .
@retval TM_OK Operation done.
@retval TMBSL_ERR_VENCANA_BAD_UNIT_NUMBER .
@retval TMBSL_ERR_VENCANA_NOT_SUPPORTED .
@retval TMBSL_ERR_VENCANA_COMPATIBILITY .
@retval TMBSL_ERR_VENCANA_BAD_PARAMETER .
@note This function can be called several times without a call to
saa7104VoDeinit in between.
*/
static tmErrorCode_t saa7104VoInit(
tmUnitSelect_t avoUnit, /**< @b IN AVO Unit number. */
ptmbslVencAnaDesc_t pEnc, /**< @b IN Ptr to video encoder. */
psaa7104Param_t pSetup /**< @b IN Ptr to video setup. */
)
{
tmInstance_t iicInstance;
tmErrorCode_t tmRetVal = TM_OK;
UInt8 bData;
if (avoUnit >= SAA7104_MAX_UNITS)
{
return TMBSL_ERR_VENCANA_BAD_UNIT_NUMBER;
}
if (gSaa7104Inst[avoUnit].signature != SAA7104_SIGNATURE)
{
// first time through, initialize things
gSaa7104Inst[avoUnit].signature = SAA7104_SIGNATURE;
gSaa7104Inst[avoUnit].init = TM_FALSE;
gSaa7104Inst[avoUnit].iicInstance = 0;
gSaa7104Inst[avoUnit].dualInterfaceMode = TM_FALSE;
}
// Store parts of setup
gSaa7104Inst[avoUnit].slaveAddr = pEnc->slaveAddr;
gSaa7104Inst[avoUnit].videoType = pSetup->videoType;
gSaa7104Inst[avoUnit].videoSubtype = pSetup->videoSubtype;
strcpy(gSaa7104Inst[avoUnit].videoStandard, pSetup->videoStandard);
gSaa7104Inst[avoUnit].encodingType = pSetup->encodingType;
// Open I2C device for communication with saa7104, if not yet available
/***********************************************************************/
/* Note that tmdlIicSynchronousByPolling has been used instead of */
/* tmdlIicSynchronous that would seem more efficient. The difference */
/* between these two is that if the data transfer fails due to certain */
/* errors, tmdlIicSynchronousByPolling mode will keep on trying for */
/* successful data transfer(for mumRetries time or ??) until the data */
/* transfer is completed. If one choses to */
/* to use tmdlIicSynchronous instead, then the user i.e this function */
/* will have to do the error handling to ensure that data transfer has */
/* been done successfully since this mode does not make any attempt to */
/* retry. */
/* See PR DI#2285 */
/***********************************************************************/
if (gSaa7104Inst[avoUnit].iicInstance == 0)
{
// Setup I2C request
memset( &gSaa7104IicReq, 0, sizeof(tmdlIicRequest_t) );
gSaa7104IicReq.numRetries = SAA7104_IIC_RETRIES;
gSaa7104IicReq.waitBeforeRetry = 50;
gSaa7104IicReq.xferMode = tmdlIicSynchronousByPolling;
gSaa7104IicReq.addrType = tmdlIicSubAddress8Bits;
gSaa7104IicReq.done = TM_FALSE;
gSaa7104IicReq.errorCode = 0;
gSaa7104IicReq.userData = 0;
gSaa7104IicReq.direction = tmdlIicWrite;
tmRetVal = tmdlIicOpenM (&iicInstance, pEnc->i2cUnit);
if (tmRetVal == TM_OK)
{
tmdlIicInstanceSetup_t iicInstSetup;
// save I2C instance in local structure
gSaa7104Inst[avoUnit].iicInstance = iicInstance;
iicInstSetup.xferSpeedKHZ = SAA7104_IIC_SPEEDKHZ;
tmRetVal = tmdlIicInstanceSetup (iicInstance, &iicInstSetup);
if (tmRetVal == TM_OK)
{
// no call back function
tmdlIicRegisterCallback(iicInstance, Null, 0);
}
}
}
#if 0
if ((tmRetVal == TM_OK) & (gSaa7104Inst[avoUnit].init == TM_FALSE))
{
// Get saa7104 status register and check the revision level
tmRetVal = saa7104GetReg (avoUnit, 0/*chipStatus*/, &bData);
if (tmRetVal == TM_OK)
{
// Make sure SW supports this hardware
switch ((bData >> 5) & 7)
{
case 5:
gSaa7104Inst[avoUnit].chipRev = saa7104Rev5;
// init the cursor bitmap to fix HW's cold start problem
saa7104InitCursorBitmap( avoUnit );
break;
default: // Not a supported version of the chip...
tmRetVal = TMBSL_ERR_VENCANA_COMPATIBILITY;
break;
}
}
}
#endif
// Perform initialization of saa7104 chip
if (tmRetVal == TM_OK)
{
//It seems that need to initialize cursor, if standard is changed.
saa7104InitCursorBitmap(avoUnit);
//initialize saa7104 with preliminary values
tmRetVal = saa7104WriteArray (
avoUnit,
SAA7104_REG_VIDEO,
(UInt8*)saa7104_init,
sizeof (saa7104_init));
if (pSetup->videoSubtype == vof8bitYUV422 )
{
switch (pSetup->encodingType)
{
case tmbslVencAna_Cvbs:
case tmbslVencAna_Yc:
saa7104SetReg(avoUnit, 0x2D, 0xB0);
saa7104SetReg(avoUnit, 0x3A, 0x39); //output c_sync
saa7104SetReg(avoUnit, 0xFD, 0xD3);
break;
case tmbslVencAna_Scart:
saa7104SetReg(avoUnit, 0x2D, 0x00);
saa7104SetReg(avoUnit, 0x3A, 0x3D); //output c_sync
saa7104SetReg(avoUnit, 0xFD, 0xD3);
break;
case tmbslVencAna_Ext1:
saa7104SetReg(avoUnit, 0x2D, 0x80);
saa7104SetReg(avoUnit, 0x3A, 0x39);
saa7104SetReg(avoUnit, 0xFD, 0xD3);
break;
default:
tmRetVal = TMBSL_ERR_VENCANA_BAD_PARAMETER;
goto error;
}
if(!(strcmp(pSetup->videoStandard, "ntsc")))
{
tmRetVal = saa7104WriteArray( avoUnit, SAA7104_REG_VIDEO,
(UInt8*)saa7104_ntsc, sizeof(saa7104_ntsc) );
if (pSetup->colorSystem == tmbslVencAna_NtscJ) //NTSC_J
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -