?? saa7113.c
字號:
return (tmLibdevErr_t) lastI2cError; /* Switch input mode (line) */
SetReg(pVD, AnalogInputControl1, ucVal & ~0x0f | (num & 0x0f));
return TMLIBDEV_OK;
}
extern tmLibdevErr_t
saa7113GetAnalogInput(pboardVIDec_t pVD, unsigned int *num)
{
/* Similar to Video DecHAL VideoDecGetVideoSource */
UInt8 ucVal;
/* Read video input source from decoder */
if (!GetReg(pVD, AnalogInputControl1, &ucVal))
return (tmLibdevErr_t) lastI2cError;
*num = ucVal & 0x0F;;
return TMLIBDEV_OK;
}
extern tmLibdevErr_t
saa7113SetStandard(pboardVIDec_t pVD, tmVideoAnalogStandard_t standard)
{
/* Equivalent to Video DecHAL SetVideoStandard */
UInt8 ucVal;
/* Only check first access */
if (GetReg(pVD, ChromaControl, &ucVal)) /* Read old value */
{
ucVal &= ~0x73; /* Delete video standard bits; */
switch (standard)
{
case vasNTSC:
case vasPAL:
SetReg(pVD, ChromaControl, ucVal | 0x01);
GetReg(pVD, LuminanceControl, &ucVal);
SetReg(pVD, LuminanceControl, (ucVal & ~0x03) | 0x01); /* Aperture factor */
break;
case vasSECAM:
SetReg(pVD, ChromaControl, ucVal | 0x50);
GetReg(pVD, LuminanceControl, &ucVal);
SetReg(pVD, LuminanceControl, (ucVal & ~0x03) | 0x00); /* Aperture factor */
GetReg(pVD, ChromaGainControl, &ucVal);
SetReg(pVD, ChromaGainControl, (ucVal & ~0x80) | 0x80); /* Set ACGC=1 */
break;
default:
return BOARD_ERR_VAL_OUT_OF_RANGE;
}
}
else
return (tmLibdevErr_t) lastI2cError;
return TMLIBDEV_OK;
}
extern tmLibdevErr_t
saa7113SetSourceType(pboardVIDec_t pVD, tmVideoSourceType_t type)
{
/* Equivalent to Video DecHAL VideoDecSetSourceType */
UInt8 ucVal;
/* Check only forst access */
if (GetReg(pVD, SyncControl, &ucVal)) /* Read old value */
{
if (type == vsoVCR)
SetReg(pVD, SyncControl, ucVal & ~0x18 | 0x18);/* Set bit, if VCR */
else
SetReg(pVD, SyncControl, ucVal & ~0x18 | 0x00);/* else, clear bit */
}
else
return (tmLibdevErr_t) lastI2cError;
return TMLIBDEV_OK;
}
extern tmLibdevErr_t
saa7113GetSourceType(pboardVIDec_t pVD, tmVideoSourceType_t *type)
{
/* Equivalent to Video DecHAL VideoDecGetSourceType */
UInt8 ucVal;
/* Check only forst access */
if (GetReg(pVD, SyncControl, &ucVal)) /* Read old value */
{
if (ucVal & 0x18 == 0x18)
*type = vsoVCR;
else
*type = vsoTV;
}
else
return (tmLibdevErr_t) lastI2cError;
return TMLIBDEV_OK;
}
extern tmLibdevErr_t
saa7113SetOutputFormat(pboardVIDec_t pVD, tmVideoRGBYUVFormat_t format)
{
/* Equivalent to Video DecHAL VideoDecSetVideoFormat */
UInt8 ucVal; /* Old value */
UInt8 ucFormat = 0; /* Format bits */
switch (format)
{
case vdfYUV422Sequence : /* VD_D1_CCIR656: */
ucFormat = 0x00;
break;
default:
return BOARD_ERR_VAL_OUT_OF_RANGE;
}
if (GetReg(pVD, FormatDelayControl, &ucVal))
SetReg(pVD, FormatDelayControl, ucVal & ~0x80 | ucFormat);
else
return (tmLibdevErr_t) lastI2cError;
return TMLIBDEV_OK;
}
extern tmLibdevErr_t
saa7113GetOutputFormat(pboardVIDec_t pVD, tmVideoRGBYUVFormat_t *format)
{
/* Equivalent to Video DecHAL VideoDecGetVideoFormat */
*format = vdfYUV422Sequence;
return TMLIBDEV_OK;
}
extern tmLibdevErr_t
saa7113SetAcquisitionWnd(pboardVIDec_t pVD, unsigned int beginX, unsigned int beginY, unsigned int endX, unsigned int endY)
{
/* Equivalent to Video DecHALSetAcquisitionWnd */
/* Scaling not supported by SAA7113 -> return error */
return BOARD_ERR_UNSUPPORTED_FUNCTION;
}
extern tmLibdevErr_t
saa7113GetAcquisitionWnd(pboardVIDec_t pVD, unsigned int *beginX, unsigned int *beginY, unsigned int *endX, unsigned int *endY)
{
/* Equivalent to Video DecHALGetAcquisitionWnd */
/* Scaling not supported by SAA7113 -> return error */
return BOARD_ERR_UNSUPPORTED_FUNCTION;
}
extern tmLibdevErr_t
saa7113GetDefaultAcquisitionWnd(pboardVIDec_t pVD, unsigned int *beginX, unsigned int *beginY, unsigned int *endX, unsigned int *endY)
{
/* Equivalent to Video DecHAL VideoDecGetDefaultAcquisitionWnd */
switch (pVD->curVideoStandard)
{
case vasNTSC:
/* Set default acquisition window for NTSC */
*beginX = 6;
*beginY = 2;
*endX = *beginX + 719;
*endY = *beginY + 239;
break;
case vasPAL:
/* Set default acquisition window for PAL */
*beginX = 6;
*beginY = 1;
*endX = *beginX + 719;
*endY = *beginY + 287;
break;
default:
return BOARD_ERR_COLOR_STANDARD_NOT_DETECTED;
}
return TMLIBDEV_OK;
}
extern tmLibdevErr_t
saa7113SetOutputSize(pboardVIDec_t pVD, unsigned int width, unsigned int height)
{
/* Equivalent to Video DecHAL VideoDecSetOutputVideoSize */
/* Scaling not supported by SAA7113 -> return error */
return BOARD_ERR_UNSUPPORTED_FUNCTION;
}
extern tmLibdevErr_t
saa7113SetInterlaceMode(pboardVIDec_t pVD, Bool interlace)
{
/* Equivalent to Video DecHAL VideoDecSetInterlacedMode */
/* Nothing to set for 7113 -> return error */
return BOARD_ERR_UNSUPPORTED_FUNCTION;
}
extern tmLibdevErr_t
saa7113DisableDecoder(pboardVIDec_t pVD, Bool disable)
{
/* Counterpart to Video DecHAL VideoDecEnableDecoder */
UInt8 ucValue;
if (!GetReg(pVD, OutputControl1, &ucValue)) /* Check only first access */
return (tmLibdevErr_t) lastI2cError;
SetReg(pVD, OutputControl1, (ucValue & ~0x0c) | (disable ? 0x00 : 0x0c));
return TMLIBDEV_OK;
}
extern tmLibdevErr_t
saa7113EnablePowerSaveMode(pboardVIDec_t pVD, Bool enable)
{
/* Equivalent to Video DecHAL VideoDecPowerSaveMode */
/* Nothing to set for 7113 -> return error */
return BOARD_ERR_UNSUPPORTED_FUNCTION;
}
extern tmLibdevErr_t
saa7113GetGPIOCount(pboardVIDec_t pVD, unsigned int *num)
{
/* Equivalent to Video DecHAL VideoDecGetGPIOCount */
*num = 3; /* 3 GPIO pins available */
return TMLIBDEV_OK;
}
extern tmLibdevErr_t
saa7113SetGPIOState(pboardVIDec_t pVD, unsigned int pin, Bool state)
{
/* Equivalent to Video DecHAL VideoDecSetGPIOState */
unsigned int ucNum;
UInt8 ucValue;
saa7113GetGPIOCount(pVD, &ucNum); /* Get number of GPIOs */
if (pin >= ucNum)
return BOARD_ERR_VAL_OUT_OF_RANGE;
switch (pin)
{
case 0: /* RTS0 */
/* Check only first access */
if (!GetReg(pVD, OutputControl2, &ucValue))
return (tmLibdevErr_t) lastI2cError;
SetReg(pVD, OutputControl2, ucValue & ~0x0f | (state ? 0x03 :0x02));
break;
case 1: /* RTS1 */
/* Check only first access */
if (!GetReg(pVD, OutputControl2, &ucValue))
return (tmLibdevErr_t) lastI2cError;
SetReg(pVD, OutputControl2, ucValue & ~0xf0 | (state ? 0x30 :0x20));
break;
case 2: /* GPSW */
/* Check only first access */
if (!GetReg(pVD, OutputControl1, &ucValue))
return (tmLibdevErr_t) lastI2cError;
SetReg(pVD, OutputControl1, ucValue & ~0x80 | (state ? 0x80 :0x00));
break;
default:
return BOARD_ERR_VAL_OUT_OF_RANGE;
}
return TMLIBDEV_OK;
}
extern tmLibdevErr_t
saa7113GetGPIOState(pboardVIDec_t pVD, unsigned int pin, Bool *state)
{
/* Equivalent to Video DecHAL VideoDecGetGPIOState */
unsigned int ucNum;
UInt8 ucValue;
saa7113GetGPIOCount(pVD, &ucNum); /* Get number of GPIO's */
if (pin >= ucNum)
return BOARD_ERR_VAL_OUT_OF_RANGE;
/* Assume pin is not set */
*state = 0;
switch (pin)
{
case 0: /* RTS0 */
/* Check only first access */
if (!GetReg(pVD, OutputControl2, &ucValue))
return (tmLibdevErr_t) lastI2cError;
if ((ucValue & 0x0f) == 0x03)
*state = 1; /* Overwrite 0 */
break;
case 1: /* RTS1 */
/* Check only first access */
if (!GetReg(pVD, OutputControl2, &ucValue))
return (tmLibdevErr_t) lastI2cError;
if ((ucValue & 0xf0) == 0x30)
*state = 1; /* Overwrite 0 */
break;
case 2: /* GPSW */
/* Check only first access */
if (!GetReg(pVD, OutputControl1, &ucValue))
return (tmLibdevErr_t) lastI2cError;
if (ucValue & 0x80)
*state = 1; /* Overwrite 0 */
break;
default:
return BOARD_ERR_VAL_OUT_OF_RANGE;
}
return TMLIBDEV_OK;
}
extern tmLibdevErr_t
saa7113OpenVBI(pboardVIDec_t pVD, unsigned int sampleFreq, unsigned int startLine, unsigned int numLines)
{
/* Equivalent to Video DecHAL VideoDecOpenVBI */
tmVideoAnalogStandard_t videoStd;
/* Only 13.5 MHz sample frequency allowed */
if (sampleFreq != 0)
if (sampleFreq != 13500000)
return BOARD_ERR_VAL_OUT_OF_RANGE; /* Not valid call */
if (startLine || numLines) /* if not 0 */
{
/* Check for underflow */
if ((startLine + numLines) < 2) return BOARD_ERR_VAL_OUT_OF_RANGE;
/* Get current video standard */
saa7113GetStandardM (pVD, &videoStd);
switch (videoStd)
{
case vasPAL: /* 50 Hz standards */
case vasSECAM:
if ((startLine + numLines) > 312)
return BOARD_ERR_VAL_OUT_OF_RANGE;
break;
case vasNTSC: /* 60 Hz standards */
if ((startLine + numLines) > 262)
return BOARD_ERR_VAL_OUT_OF_RANGE;
break;
default:
return BOARD_ERR_VAL_OUT_OF_RANGE;
}
}
m_nStartVBILine = startLine;
m_nNumVBILines = numLines;
return TMLIBDEV_OK;
}
extern tmLibdevErr_t
saa7113EnableVBI(pboardVIDec_t pVD, Bool enable)
{
/* Equivalent to Video DecHAL VideoDecEnableVBI */
UInt8 ucVal;
int nCount, i;
tmVideoDataService_t ucTTMode;
tmVideoDataService_t oddTable[24];
tmVideoDataService_t evenTable[24];
SetReg(pVD, VGateStart, 0); /* VBI off */
SetReg(pVD, VGateStop, 0);
SetReg(pVD, VGateMSB, 0);
if(!GetReg(pVD, LuminanceControl, &ucVal)) /* Check only first access */
return (tmLibdevErr_t) lastI2cError; /* Clear VBLB bit */
SetReg(pVD, LuminanceControl, ucVal & ~0x08 | 0x00);
ucTTMode = vdsNone;
for(i = 0; i < 24; i++)
{
oddTable[i] = vdsNone;
evenTable[i] = vdsNone;
}
if(ucTTMode != (UInt8)vdsNone)
{
for(nCount = m_nStartVBILine;
nCount<((int)m_nStartVBILine + (int)m_nNumVBILines);
nCount++)
{
oddTable[nCount] = ucTTMode;
evenTable[nCount] = ucTTMode;
}
}
saa7113SetDataServices (pVD, oddTable, evenTable, 24);
return TMLIBDEV_OK;
}
extern tmLibdevErr_t
saa7113SetVBIMode(pboardVIDec_t pVD, tmVideoVBIMode_t mode)
{
/* Equivalent to Video DecHAL VideoDecSetCurrentVBIMode */
if (mode == vvmBasebandYuv)
return TMLIBDEV_OK;
else
return BOARD_ERR_VAL_OUT_OF_RANGE;
}
extern tmLibdevErr_t
saa7113SetSlicerMode(pboardVIDec_t pVD, tmVideoSlicerMode_t mode)
{
/* Equivalent to Video DecHAL VideoDecSetTTMode */
/* Only baseband YUV allowed */
if (mode == vvmBasebandYuv)
return TMLIBDEV_OK;
else
return BOARD_ERR_VAL_OUT_OF_RANGE;
}
extern tmLibdevErr_t
saa7113CloseVBI(pboardVIDec_t pVD)
{
/* Equivalent to Video DecHAL VideoDecSetTTMode */
/* Nothing to do here */
return TMLIBDEV_OK;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -