tmbsl7113.c
来自「PNX1500上视频采集芯片7113的设置源代码」· C语言 代码 · 共 2,254 行 · 第 1/5 页
C
2,254 行
} pVD = &(gDecInstance[aviUnit]); SetReg(pVD, VGateStart, 0); // VBI off SetReg(pVD, VGateStop, 0); SetReg(pVD, VGateMSB, 0); if(!GetReg(pVD, LuminanceControl, &ucVal)) // Check only first access return lastI2cError; // Clear VBLB bit SetReg(pVD, LuminanceControl, (UInt8)(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; } } tmbsl7113SetDataServices ( aviUnit, // I: AVI Unit number oddTable, // I: table to assign service evenTable, // I: table to assign service 24 // I: size of table in bytes ); return TM_OK;}//-----------------------------------------------------------------------------//// FUNCTION: tmbsl7113SetVBIMode://// DESCRIPTION: sets VBI mode //// RETURN: tmErrorCode_t for success or error//// NOTES: NONE////-----------------------------------------------------------------------------tmErrorCode_t tmbsl7113SetVBIMode ( tmUnitSelect_t aviUnit, // I: AVI Unit number tmVideoVBIMode_t mode // I: VBI mode ){ // Only baseband YUV allowed if (mode == vvmBasebandYuv) return TM_OK; else return TMBSL_ERR_AVI_VAL_OUT_OF_RANGE;}//-----------------------------------------------------------------------------//// FUNCTION: tmbsl7113SetSlicerMode://// DESCRIPTION: sets VBI slicer mode //// RETURN: tmErrorCode_t for success or error//// NOTES: NONE////-----------------------------------------------------------------------------tmErrorCode_t tmbsl7113SetSlicerMode ( tmUnitSelect_t aviUnit, // I: AVI Unit number tmVideoSlicerMode_t mode // I: Slicer mode ){ // Only baseband YUV allowed if (mode == vvmBasebandYuv) return TM_OK; else return TMBSL_ERR_AVI_VAL_OUT_OF_RANGE;}//-----------------------------------------------------------------------------//// FUNCTION: tmbsl7113CloseVBI://// DESCRIPTION: frees all allocated VBI feature ressources //// RETURN: tmErrorCode_t for success or error//// NOTES: NONE////-----------------------------------------------------------------------------tmErrorCode_t tmbsl7113CloseVBI ( tmUnitSelect_t aviUnit // I: AVI Unit number ){ // Nothing to do here return TM_OK;}//-----------------------------------------------------------------------------//// FUNCTION: tmbsl7113GetVSyncFallingEdge://// DESCRIPTION: returns line number where falling edge of vertical sync happens// this is important to determine the active video area //// RETURN: tmErrorCode_t for success or error//// NOTES: NONE////-----------------------------------------------------------------------------tmErrorCode_t tmbsl7113GetVSyncFallingEdge ( tmUnitSelect_t aviUnit, // I: AVI Unit number UInt32 *pLineNumberOddField, // O: line number odd field UInt32 *pLineNumberEvenField // O: line number even fiels ){ decoderStruct_t* pVD = Null; if( aviUnit >= SAA7113_MAX_UNITS ) { return TMBSL_ERR_AVI_BAD_UNIT_NUMBER; } if( gDecInstance[aviUnit].init != True ) { return TMBSL_ERR_AVI_NOT_INITIALIZED; } pVD = &(gDecInstance[aviUnit]); switch (pVD->curVideoStandard) { // Offset between 7113 VSync and VIP line 1 case vasNTSC: *pLineNumberOddField = 0; *pLineNumberEvenField = 0; break; case vasPAL: case vasSECAM: *pLineNumberOddField = 2; *pLineNumberEvenField = 3; break; default: return TMBSL_ERR_AVI_CLR_STD_NOT_DETECTED; } return TM_OK;}//-----------------------------------------------------------------------------//// FUNCTION: tmbsl7113GetStatus://// DESCRIPTION: retrieves status information of the decoder chip//// RETURN: tmErrorCode_t for success or error//// NOTES: NONE////-----------------------------------------------------------------------------tmErrorCode_t tmbsl7113GetStatus ( tmUnitSelect_t aviUnit, // I: AVI Unit number tmVideoStatusType_t type, // I: status type to be received UInt32 *pState // O: receives status value ){ /* Equivalent to Video DecHAL VideoDecGetStatus */ UInt8 ucStatus; UInt8 ucValue; decoderStruct_t* pVD = Null; if( aviUnit >= SAA7113_MAX_UNITS ) { return TMBSL_ERR_AVI_BAD_UNIT_NUMBER; } if( gDecInstance[aviUnit].init != True ) { return TMBSL_ERR_AVI_NOT_INITIALIZED; } pVD = &(gDecInstance[aviUnit]); lastI2cError = TM_OK; switch (type) { case vstLocked: /* HIGH unlocked, LOW locked */ if(!GetReg(pVD, OutputControl3, &ucValue)) /* Set OLDSB=1 */ return lastI2cError; SetReg(pVD, OutputControl3, (UInt8)(ucValue & ~0x10 | 0x10)); GetReg(pVD, StatusByte, &ucStatus); *pState = (ucStatus & 0x40) ? False : True; break; case vstReady: /* HIGH locked, LOW unlocked */ if(!GetReg(pVD, OutputControl3, &ucValue)) /* Set OLDSB=0 */ return lastI2cError; SetReg(pVD, OutputControl3, (UInt8)(ucValue & ~0x10 | 0x00)); GetReg(pVD, StatusByte, &ucStatus); *pState = (ucStatus & 0x01) ? True : False; break; case vstSyncLock: /* HIGH unlocked, LOW locked */ if(!GetReg(pVD, OutputControl3, &ucValue)) /* Set OLDSB=0 */ return lastI2cError; SetReg(pVD, OutputControl3, (UInt8)(ucValue & ~0x10 | 0x00)); GetReg(pVD, StatusByte, &ucStatus); *pState = (ucStatus & 0x40) ? False : True; break; case vstCopy: /* HIGH copy protected, */ /* LOW not copy protected */ if(!GetReg(pVD, OutputControl3, &ucValue)) /* Set OLDSB=0 */ return lastI2cError; SetReg(pVD, OutputControl3, (UInt8)(ucValue & ~0x10 | 0x00)); GetReg(pVD, StatusByte, &ucStatus); *pState = (ucStatus & 0x02) ? True : False; break; case vstColorSignal: /* HIGH color, LOW no color */ if(!GetReg(pVD, OutputControl3, &ucValue)) /* Set OLDSB=1 */ return lastI2cError; SetReg(pVD, OutputControl3, (UInt8)(ucValue & ~0x10 | 0x10)); GetReg(pVD, StatusByte, &ucStatus); *pState = (ucStatus & 0x01) ? True : False; break; case vstFrequency: /* HIGH 60Hz, LOW 50Hz */ if(!GetReg(pVD, OutputControl3, &ucValue)) /* Set OLDSB=1 */ return lastI2cError; SetReg(pVD, OutputControl3, (UInt8)(ucValue & ~0x10 | 0x10)); GetReg(pVD, StatusByte, &ucStatus); *pState = (ucStatus & 0x20) ? 60 : 50; break; case vstPowerUp: GetReg(pVD, DR, &ucStatus); *pState = 0; /* Clear all */ if (ucStatus & 0x04) /* Closed caption found */ *pState |= (vdsEuroClosedCaption | vdsUSClosedCaption); if (ucStatus & 0x08) /* Widescreen signal found */ *pState |= vdsWSS; if (ucStatus & 0x10) /* VPS found */ *pState |= vdsVPS; if (ucStatus & 0x60) /* others found */ *pState |= (vdsEuroTeleText | vdsUSTeleText | vdsTeleText | vdsVITC_EBU | vdsVITC_SMPTE | vdsUSNABTS | vdsMoji | vdsJapFormatSwitch); break; case vstFidText: GetReg(pVD, LN1, &ucStatus); *pState = (ucStatus & 0x20) ? 1 : 2; break; default: return TMBSL_ERR_AVI_VAL_OUT_OF_RANGE; } return TM_OK;}//-----------------------------------------------------------------------------//// FUNCTION: tmbsl7113GetSupportedDataServices://// DESCRIPTION: retrieves supported HW slicing for each VBI line //// RETURN: tmErrorCode_t for success or error//// NOTES: NONE////-----------------------------------------------------------------------------tmErrorCode_t tmbsl7113GetSupportedDataServices ( tmUnitSelect_t aviUnit, // I: AVI Unit number tmVideoDataService_t fieldOne[], tmVideoDataService_t fieldTwo[], UInt8 tblSize ){ int i; /* Write supported data services into arrays */ for (i = 0; i < tblSize; i++) { if (i < 2) { /* No data slicing allowed in first two lines */ fieldOne [i] = fieldTwo [i] = vdsNone; } else { /* Allow all kind of data services */ fieldOne [i] = fieldTwo [i] = (tmVideoDataService_t) (vdsEuroTeleText | vdsEuroClosedCaption | vdsVPS | vdsWSS | vdsUSTeleText | vdsUSClosedCaption | vdsTeleText | vdsVITC_EBU | vdsVITC_SMPTE | vdsUSNABTS | vdsMoji | vdsJapFormatSwitch); } } return TM_OK;}//-----------------------------------------------------------------------------//// FUNCTION: tmbsl7113SetDataServices://// DESCRIPTION: sets HW slicing for each line //// RETURN: tmErrorCode_t for success or error//// NOTES: NONE////-----------------------------------------------------------------------------tmErrorCode_t tmbsl7113SetDataServices ( tmUnitSelect_t aviUnit, // I: AVI Unit number tmVideoDataService_t fieldOne[], // I: table to assign service tmVideoDataService_t fieldTwo[], // I: table to assign service UInt8 tblSize // I: size of table in bytes ){ tmErrorCode_t nReturn = TM_OK; int nCount; // Counter int nLoop; // Counter UInt8 ucReg; // Value to program int nProgrammableTextDataType; // Programmable text data type int nAllowedDataTypes; decoderStruct_t* pVD = Null; if( aviUnit >= SAA7113_MAX_UNITS ) { return TMBSL_ERR_AVI_BAD_UNIT_NUMBER; } if( gDecInstance[aviUnit].init != True ) { return TMBSL_ERR_AVI_NOT_INITIALIZED; } pVD = &(gDecInstance[aviUnit]); if (tblSize > 25) // Check upper bound { tblSize = 25; } nProgrammableTextDataType = 0; nAllowedDataTypes = vdsEuroTeleText | vdsEuroClosedCaption | vdsVPS | vdsWSS | vdsUSTeleText | vdsUSClosedCaption | vdsTeleText | vdsVITC_EBU | vdsVITC_SMPTE | vdsUSNABTS | vdsMoji | vdsJapFormatSwitch; // Collect all teletext standards to be used for (nCount = 0; nCount < tblSize; nCount++) nProgrammableTextDataType |= (fieldOne[nCount] | fieldTwo[nCount]); if (nProgrammableTextDataType & ~nAllowedDataTypes) { return (TMBSL_ERR_AVI_VAL_OUT_OF_RANGE); // Illegal standard requested } for (nCount = 2; nCount < tblSize; nCount++) { ucReg = 0xff; // Standard value. // Do not acquire. for(nLoop = 0; // Search for programm value. (nLoop < MAX_TT) && // Search odd table (Convert7113TT[nLoop].nBitMask != fieldOne[nCount]); nLoop++); if (nLoop < MAX_TT) // Found ! ucReg = ucReg & ~0xf0 | (Convert7113TT[nLoop].nNibble << 4); for(nLoop = 0; // Search for programm value. (nLoop < MAX_TT) && // Search even table (Convert7113TT[nLoop].nBitMask != fieldTwo[nCount]); nLoop++); if (nLoop < MAX_TT) // Found ! ucReg = ucReg & ~0x0f | Convert7113TT[nLoop].nNibble; if (!SetReg(pVD, (UInt8)(LCR2 + nCount - 2), ucReg)) // Check device access return lastI2cError; } SetReg(pVD, FC, 0); // Set framing code return nReturn;}//-----------------------------------------------------------------------------//// FUNCTION: tmbsl7113EnableSlicing://// DESCRIPTION: enables hardware slicer //// RETURN: tmErrorCode_t for success or error//// NOTES: NONE////-----------------------------------------------------------------------------tmErrorCode_t tmbsl7113EnableSlicing ( tmUnitSelect_t aviUnit, // I: AVI Unit number Bool enable // I: set True to enable ){ UInt32 sStatus; // There's no way to turn on/off the 7113 slicer specificly // Just ignore this command // Check if copy protected source connected. If so -> switch source type tmbsl7113GetStatus(aviUnit, vstCopy, &sStatus); if (sStatus) tmbsl7113SetSourceType(aviUnit, vsoTV); else
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?