📄 saa7114.c
字号:
return nReturn;
}
extern tmLibdevErr_t
saa7114GetSlicerLineFlags(pboardVIDec_t pVD, Bool fieldOne[], Bool fieldTwo[], UInt8 tblSize)
{
/* Equivalent to Video DecHAL VideoDecGetTTLineFlags */
int nCount = 0;
int nLoop = 0;
int nShift = 0;
Bool bTempOdd[24];
Bool bTempEven[24];
UInt8 ucEvenValue = 0x00;
UInt8 ucOddValue = 0x00;
/* read parallel Odd and Even Line Flag Byte */
for(nLoop = 0; nLoop < 3; nLoop++)
{
if (!GetReg(pVD, LineFlagsEven1 + nLoop, &ucEvenValue)) /* Check only first access */
return IIC_ERR_TIMEOUT;
GetReg(pVD, LineFlagsOdd1 + nLoop, &ucOddValue);
nShift = 0;
/* Check each bit for 0(=FALSE) or 1(=TRUE) */
for(nCount = 8*nLoop; nCount < (8*(nLoop + 1)); nCount++)
{
bTempEven[nCount] = (ucEvenValue >> nShift) & 0x01;
bTempOdd[nCount] = (ucOddValue >> nShift) & 0x01;
nShift++;
}
}
/* Because the firts bit of the first byte does not contain data type */
/* information, ignore this bit and reorder line flags */
for(nCount = 0; nCount < 23; nCount++)
{
fieldTwo[nCount] = bTempEven[nCount+1] ? True : False;
fieldOne[nCount] = bTempOdd[nCount+1] ? True : False;
}
return TMLIBDEV_OK;
}
extern tmLibdevErr_t
saa7114EnableSlicing(pboardVIDec_t pVD, Bool enable)
{
/* Equivalent to Video DecHAL VideoDecEnableTT */
UInt8 ucValue; /* Old value */
UInt8 ucValHOff;
UInt sStdFreq = 0; /* Standard frequency */
UInt sStatus = 0; /* boolean status */
if (!GetReg(pVD, IPortFIFOFlag, &ucValue)) /* Check only first access */
return IIC_ERR_TIMEOUT;
if (enable) /* Start text slicer */
SetReg(pVD, IPortFIFOFlag, ucValue & ~0xc0 | 0xc0);
else /* Stop text slicer */
SetReg(pVD, IPortFIFOFlag, ucValue & ~0xc0 | 0x40);
saa7114GetStatus(pVD, vstLocked, &sStatus);
if (sStatus)
/* Decoder locked: Return is ok */
saa7114GetStatus(pVD, vstFrequency, &sStdFreq);
else
{
if (pVD->curVideoStandard == vasNTSC)
sStdFreq = 60;
else
sStdFreq = 50;
}
GetReg(pVD, HVOFF, &ucValHOff);
switch (sStdFreq)
{
case 50: /* 50 Hz standards */
SetReg(pVD, VOFF, 3); /* 3 for 50 Hz */
SetReg(pVD, HOFF, 0x47); /* 839 for 50 Hz */
SetReg(pVD, HVOFF, ucValHOff & ~0x17 | 0x03);
break;
case 60: /* 60 Hz standards */
SetReg(pVD, VOFF, 6); /* 6 for 60 Hz */
SetReg(pVD, HOFF, 0x47); /* 839 for 60 Hz */
SetReg(pVD, HVOFF, ucValHOff & ~0x17 | 0x03);
break;
default:
return BOARD_ERR_VAL_OUT_OF_RANGE;
}
return TMLIBDEV_OK;
}
extern tmLibdevErr_t
saa7114SetSlicerVideoStandard(pboardVIDec_t pVD, tmVideoAnalogStandard_t standard)
{
/* Equivalent to Video DecHAL VideoDecSetTTVideoStandard */
UInt8 ucVal;
UInt8 ucValHOff;
if (!GetReg(pVD, AC1, &ucVal)) /* Read old value, check only */
return (tmLibdevErr_t) lastI2cError; /* first access */
GetReg(pVD, HVOFF, &ucValHOff); /* Read old value */
switch (standard)
{
case vasPAL: /* 50 Hz standards */
case vasSECAM:
SetReg(pVD, AC1, ucVal & ~0x80 | 0x00);
SetReg(pVD, VOFF, 7);
SetReg(pVD, HOFF, 0x54);
SetReg(pVD, HVOFF, ucValHOff & ~0x07 | 0x03);
break;
case vasNTSC: /* 60 Hz standards */
SetReg(pVD, AC1, ucVal & ~0x80 | 0x80);
SetReg(pVD, VOFF, 10);
SetReg(pVD, HOFF, 0x54);
SetReg(pVD, HVOFF, ucValHOff & ~0x07 | 0x03);
break;
default:
return BOARD_ERR_VAL_OUT_OF_RANGE;
}
return TMLIBDEV_OK;
}
extern tmLibdevErr_t
saa7114GetSlicerVideoStandard(pboardVIDec_t pVD, tmVideoAnalogStandard_t *standard)
{
/* Equivalent to Video DecHAL VideoDecGetTTVideoStandard */
UInt8 ucVal;
if (!GetReg(pVD, AC1, &ucVal)) /* Read old value, check only */
return (tmLibdevErr_t) lastI2cError; /* first access */
if (ucVal & 0x80)
{
/* 60 Hz standards */
*standard = vasNTSC;
}
else
{
/* 50 Hz standards */
*standard = vasPAL;
}
return TMLIBDEV_OK;
}
extern tmLibdevErr_t
saa7114ToggleFieldID(pboardVIDec_t pVD, Bool toggle)
{
/* Equivalent to Video DecHAL VideoDecHalToggleTTFieldID */
UInt8 ucValue;
if (!GetReg(pVD, HVOFF, &ucValue)) /* check only first access */
return (tmLibdevErr_t) lastI2cError;
SetReg(pVD, HVOFF, ucValue & ~0x80 | (toggle ? 0x80 : 0x00));
return TMLIBDEV_OK;
}
extern tmLibdevErr_t
saa7114SetSlicerInput(pboardVIDec_t pVD, UInt num)
{
/* Equivalent to Video DecHAL VideoDecSetTTVideoSource */
UInt8 ucVal;
/* Slicer input on 7114 cannot differ from basic video source */
/* -> make sure they are identical */
if (!GetReg(pVD, AnalogInputControl1, &ucVal))
return (tmLibdevErr_t) lastI2cError;
/* Return error if the argument does not match current video source */
if ((ucVal & 0x0f) != num)
return BOARD_ERR_VAL_OUT_OF_RANGE;
else
return TMLIBDEV_OK;
}
extern tmLibdevErr_t
saa7114GetSlicerInput(pboardVIDec_t pVD, UInt *num)
{
/* Equivalent to Video DecHAL VideoDecGetTTVideoSource */
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
saa7114SetVideoColor(pboardVIDec_t pVD, tmVideoColor_t color, UInt val)
{
/* Equivalent to Video DecHAL VideoDecSetVideoColor */
UInt8 ucVal;
switch (color)
{
case vctBrightness:
if (val > 255)
return BOARD_ERR_VAL_OUT_OF_RANGE;
else
{ /* Check only first access */
if (!SetReg(pVD, LuminanceBrightness, (UInt8)val))
return (tmLibdevErr_t) lastI2cError;
}
break;
case vctContrast:
if (val > 127)
return BOARD_ERR_VAL_OUT_OF_RANGE;
else
{ /* Check only first access */
if (!SetReg(pVD, LuminanceContrast, (UInt8)val))
return (tmLibdevErr_t) lastI2cError;
}
break;
case vctSaturation:
if (val > 127)
return BOARD_ERR_VAL_OUT_OF_RANGE;
else
{ /* Check only first access */
if (!SetReg(pVD, ChromaSaturation, (UInt8)val))
return (tmLibdevErr_t) lastI2cError;
}
break;
case vctHue:
if (val > 255)
return BOARD_ERR_VAL_OUT_OF_RANGE;
else
{ /* Check only first access */
if (!SetReg(pVD, ChromaHueControl, (UInt8)val))
return (tmLibdevErr_t) lastI2cError;
}
break;
case vctSharpness:
if (val > 15)
return BOARD_ERR_VAL_OUT_OF_RANGE;
else
{ /* Check only first access */
if (!GetReg(pVD, LuminanceControl, &ucVal))
return (tmLibdevErr_t) lastI2cError;
SetReg(pVD, LuminanceControl,
(UInt8)(ucVal & ~0x03 | LUFI[(val & 0x0f)]));
}
break;
default:
return BOARD_ERR_VAL_OUT_OF_RANGE;
}
return TMLIBDEV_OK;
}
extern tmLibdevErr_t
saa7114GetVideoColor(pboardVIDec_t pVD, tmVideoColor_t color, UInt *val)
{
/* No equivalent in Video DecHAL */
UInt8 ucVal;
UInt8 ucMask;
UInt8 subAddr;
switch (color)
{
case vctBrightness:
subAddr = LuminanceBrightness;
ucMask = 0xFF;
break;
case vctContrast:
subAddr = LuminanceContrast;
ucMask = 0x7F;
break;
case vctSaturation:
ucMask = 0x7F;
subAddr = ChromaSaturation;
break;
case vctHue:
subAddr = ChromaHueControl;
ucMask = 0xFF;
break;
case vctSharpness:
subAddr = LuminanceControl;
ucMask = 0x0F;
break;
default:
return BOARD_ERR_VAL_OUT_OF_RANGE;
}
if (!GetReg (pVD, subAddr, &ucVal))
return (tmLibdevErr_t) lastI2cError;
*val = ucVal & ucMask;
return TMLIBDEV_OK;
}
extern tmLibdevErr_t
saa7114SetAnalogInput(pboardVIDec_t pVD, UInt num)
{
/* Similar to Video DecHAL VideoDecSetVideoSource */
UInt8 ucVal;
/* Set Input mode ------------------------------------------------------------*/
/* Check only first access */
if (!GetReg(pVD, AnalogInputControl1, &ucVal))
return (tmLibdevErr_t) lastI2cError; /* Switch input mode (line) */
SetReg(pVD, AnalogInputControl1, ucVal & ~0x0f | (num & 0x0f));
/* For S-Video -> bypass filter */
GetReg(pVD, LuminanceControl, &ucVal);
if (num > 5)
SetReg(pVD, LuminanceControl, ucVal | 0x80);
else
SetReg(pVD, LuminanceControl, ucVal & 0x7F);
return TMLIBDEV_OK;
}
extern tmLibdevErr_t
saa7114GetAnalogInput(pboardVIDec_t pVD, UInt *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
saa7114SetStandard(pboardVIDec_t pVD, tmVideoAnalogStandard_t standard)
{
/* Equivalent to Video DecHAL SetVideoStandard */
UInt8 ucVal;
/* Only check first access */
if (GetReg(pVD, ChromaControl1, &ucVal)) /* Read old value */
{
ucVal &= ~0x73; /* Delete video standard bits; */
switch (standard)
{
case vasNTSC:
case vasPAL:
SetReg(pVD, ChromaControl1, ucVal | 0x01);
GetReg(pVD, LuminanceControl, &ucVal);
SetReg(pVD, LuminanceControl, (ucVal & ~0x03) | 0x01); /* Aperture factor */
break;
case vasSECAM:
SetReg(pVD, ChromaControl1, 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
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -