tmbsl7113.c

来自「PNX1500上视频采集芯片7113的设置源代码」· C语言 代码 · 共 2,254 行 · 第 1/5 页

C
2,254
字号
        tmbsl7113SetSourceType(aviUnit, vsoVCR);    return TM_OK;}//-----------------------------------------------------------------------------//// FUNCTION:    tmbsl7113SetSlicerVideoStandard://// DESCRIPTION: sets analog standard for slicing  //// RETURN:      tmErrorCode_t for success or error//// NOTES:       NONE////-----------------------------------------------------------------------------tmErrorCode_t   tmbsl7113SetSlicerVideoStandard (    tmUnitSelect_t     aviUnit,        //  I: AVI Unit number                    tmVideoAnalogStandard_t standard)  //  I: new video standard{    UInt8 ucVal;    UInt8 ucValHOff;    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 (!GetReg(pVD, AC1, &ucVal))              // Read old value, check only     {        return  lastI2cError;    // first access     }    GetReg(pVD, HVOFF, &ucValHOff);             // Read old value     switch (standard)    {        case vasPAL:                            // 50 Hz standards         case vasSECAM:                SetReg(pVD, AC1, (UInt8)(ucVal & ~0x80 | 0x00));                SetReg(pVD, VOFF, 7);                SetReg(pVD, HOFF, 0x54);                       SetReg(pVD, HVOFF, (UInt8)(ucValHOff & ~0x07 | 0x03));            break;        case vasNTSC:                           // 60 Hz standards                 SetReg(pVD, AC1, (UInt8)(ucVal & ~0x80 | 0x80));                SetReg(pVD, VOFF, 10);                SetReg(pVD, HOFF, 0x54);                         SetReg(pVD, HVOFF, (UInt8)(ucValHOff & ~0x07 | 0x03));            break;        default:            return TMBSL_ERR_AVI_VAL_OUT_OF_RANGE;    }    return TM_OK;}//-----------------------------------------------------------------------------//// FUNCTION:    tmbsl7113GetSlicerVideoStandard://// DESCRIPTION: returns current analog standard used by the hardware slicer //// RETURN:      tmErrorCode_t for success or error//// NOTES:       NONE////-----------------------------------------------------------------------------tmErrorCode_t   tmbsl7113GetSlicerVideoStandard (    tmUnitSelect_t     aviUnit,         //  I: AVI Unit number                    tmVideoAnalogStandard_t *pStandard  //  O: current video standard    ){    UInt8 ucVal;    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 (!GetReg(pVD, AC1, &ucVal))                   // Read old value, check only     {        return  lastI2cError;         // first access     }    if (ucVal & 0x80)    {        // 60 Hz standards         *pStandard = vasNTSC;    }    else    {        // 50 Hz standards         *pStandard = vasPAL;    }    return TM_OK;}//-----------------------------------------------------------------------------//// FUNCTION:    tmbsl7113ToggleFieldID://// DESCRIPTION: toggles field ID to correct field assignment//// RETURN:      tmErrorCode_t for success or error//// NOTES:       NONE////-----------------------------------------------------------------------------tmErrorCode_t   tmbsl7113ToggleFieldID (    tmUnitSelect_t     aviUnit,        //  I: AVI Unit number                    Bool               toggle          //  I: set True to enable toggling      ){     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]);    if (!GetReg(pVD, HVOFF, &ucValue))               /* check only first access */        return  lastI2cError;    SetReg(pVD, HVOFF, (UInt8)(ucValue & ~0x80 | (toggle ? 0x80 : 0x00)));    return TM_OK;}//-----------------------------------------------------------------------------//// FUNCTION:    tmbsl7113SetSlicerInput://// DESCRIPTION: sets slice input //// RETURN:      tmErrorCode_t for success or error//// NOTES:       NONE////-----------------------------------------------------------------------------tmErrorCode_t   tmbsl7113SetSlicerInput (    tmUnitSelect_t     aviUnit,        //  I: AVI Unit number                    tmVideoAnalogAdapter_t adapter,    //  I: type (CVBS,SVideo,...)    UInt32 adapterIndex                //  I: index of this type    ){    UInt8  ucVal;    UInt8 inputMode;    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 (mapAdapterInput (pVD, adapter, adapterIndex, &inputMode) != TM_OK)        return TMBSL_ERR_AVI_INVALID_ADAPTER;        // Slicer input on 7113 cannot differ from basic video source     //  -> make sure they are identical     if (!GetReg(pVD, AnalogInputControl1, &ucVal))        return  lastI2cError;                   // Return error if the argument does not match current video source     if ((ucVal & 0x0f) != inputMode)        return TMBSL_ERR_AVI_VAL_OUT_OF_RANGE;    else        return TM_OK;}//-----------------------------------------------------------------------------//// FUNCTION:    tmbsl7113GetSlicerInput://// DESCRIPTION: returns current slice input//// RETURN:      tmErrorCode_t for success or error//// NOTES:       NONE////-----------------------------------------------------------------------------tmErrorCode_t   tmbsl7113GetSlicerInput (    tmUnitSelect_t         aviUnit,    //  I: AVI Unit number                    tmVideoAnalogAdapter_t *pAdapter,  //  O: receives type    UInt32           *pAdapterIndex    //  O: receives index    ){     UInt8 ucVal;    decoderStruct_t*    pVD         = Null;            UInt8 mode;        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]);    // Read video input source from decoder     if (!GetReg(pVD, AnalogInputControl1, &ucVal))        return  lastI2cError;                   mode = ucVal & 0x0F;    getAdapterInput (        pVD,         pAdapter,         pAdapterIndex,        mode        );        return TM_OK;}//-----------------------------------------------------------------------------//// FUNCTION:    tmbsl7113GetSlicerLineFlags://// DESCRIPTION: get status for each line (service found or not) //// RETURN:      tmErrorCode_t for success or error//// NOTES:       NONE////-----------------------------------------------------------------------------tmErrorCode_t   tmbsl7113GetSlicerLineFlags (    tmUnitSelect_t     aviUnit,        //  I: AVI Unit number                    Bool               fieldOne[],     Bool               fieldTwo[],     UInt8              tblSize    ){    // Line status is not supported by SAA7113 -> indicate error     return TMBSL_ERR_AVI_NOT_SUPPORTED;}//-----------------------------------------------------------------------------//// FUNCTION:    tmbsl7113GetDataLength://// DESCRIPTION: returns the data length for the specified data service//// RETURN:      tmErrorCode_t for success or error//// NOTES:       NONE////-----------------------------------------------------------------------------tmErrorCode_t   tmbsl7113GetDataLength (    tmUnitSelect_t       aviUnit,      //  I: AVI Unit number                    tmVideoDataService_t dataService,  //  I: data service    UInt32             *pDataLength    //  O: reveives data length    ){    switch (dataService)    {        case vdsEuroClosedCaption:        case vdsUSClosedCaption:            *pDataLength = OUT_DATA_LENGTH_L21;            break;        case vdsEuroTeleText:        case vdsTeleText:             *pDataLength = OUT_DATA_LENGTH_EU_TXT;            break;        case vdsWSS:             *pDataLength = OUT_DATA_LENGTH_WSS;            break;        case vdsVPS:             *pDataLength = OUT_DATA_LENGTH_VPS;            break;        case vdsUSNABTS:             *pDataLength = OUT_DATA_LENGTH_NABTS;            break;        default:            *pDataLength = 0;    }    if (*pDataLength == 0)        return !TM_OK; //TODO: Replace error!    else        return TM_OK;}//-----------------------------------------------------------------------------//// FUNCTION:    tmbsl7113GetSlicedData://// DESCRIPTION: returns sliced data according to requested service //// RETURN:      tmErrorCode_t for success or error//// NOTES:       NONE////-----------------------------------------------------------------------------tmErrorCode_t   tmbsl7113GetSlicedData (    tmUnitSelect_t       aviUnit,      //  I: AVI Unit number                    tmVideoDataService_t service,     UInt8               *pBufIn,     UInt32               sizeIn,     UInt8               *pData,     UInt32              *pDataSize    ){    UInt index = 0;    UInt bytesToFind;    UInt byteNr;    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]);     // - Search video buffer for sliced data     // - Extract and copy sliced data from planar buffers into output buffer     // - Code not optimized for performance     // Assume no data will be found      *pDataSize = 0;    // First implementation does support Closed Caption, only     switch (service)    {    case vdsUSClosedCaption:    case vdsEuroClosedCaption:        bytesToFind = 2;        break;        case vdsVPS:        case vdsJapFormatSwitch:        bytesToFind = 26;        break;        case vdsWSS:        bytesToFind = 14;        break;        case vdsTeleText:        case vdsEuroTeleText:        bytesToFind = 42;        break;        case vdsUSNABTS:        bytesToFind = 33;        break;        case vdsUSTeleText:        bytesToFind = 34;        break;        case vdsVITC_EBU:        case vdsVITC_SMPTE:        bytesToFind = 11;        break;        case vdsMoji:        bytesToFind = 35;        break;    default:            // Not supported, yet        return TMBSL_ERR_AVI_VAL_OUT_OF_RANGE;        }     /* Header 0x53 should always be in a fixed location in the     buffer memory     XX 53 XX XX XX DA TA DA TA ......    so just check if pBufIn[1] == 0x53, if not return    */    index=1;    if(pBufIn [index++] != 0x53)        return TM_OK;               /* Skip next three bytes */    index += 3;    /* Find up to maximum number of data bytes */    for (byteNr = 0; byteNr < bytesToFind; byteNr++)        {        UInt8 nibble1;        UInt8 nibble2;                        /* Skip zeroes in data stream */        while ((nibble1 = pBufIn [index++]) == 0)            if (index >= sizeIn)                return

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?