tmbsl7113.c

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

C
2,254
字号
        return TMBSL_ERR_AVI_INVALID_ADAPTER;    if (!GetReg(pVD, AnalogInputControl1, &ucVal))        return  lastI2cError;       // Switch input mode (line)         SetReg(pVD, AnalogInputControl1, (UInt8)(ucVal & ~0x0f | (inputMode & 0x0f)));    return TM_OK;}//-----------------------------------------------------------------------------//// FUNCTION:    tmbsl7113GetAnalogInput://// DESCRIPTION: Get currently used input port //// RETURN:      tmErrorCode_t for success or error//// NOTES:       NONE////-----------------------------------------------------------------------------tmErrorCode_t   tmbsl7113GetAnalogInput (    tmUnitSelect_t         aviUnit,     //  I: AVI Unit number                    tmVideoAnalogAdapter_t *pAdapter,   //  O: receives type    UInt32           *pAdapterIndex     //  O: receives index    ){     /* Similar to Video DecHAL VideoDecGetVideoSource */    UInt8 ucVal;    UInt8 mode;    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]);    // 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:    tmbsl7113SetSourceType://// DESCRIPTION: Set source type: TV, video, camera //// RETURN:      tmErrorCode_t for success or error//// NOTES:       NONE////-----------------------------------------------------------------------------tmErrorCode_t   tmbsl7113SetSourceType (    tmUnitSelect_t      aviUnit,        //  I: AVI Unit number                    tmVideoSourceType_t type            //  I: new source(TV,video,camera)    ){    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]);                                                // Check only forst access     if (GetReg(pVD, SyncControl, &ucVal))       // Read old value     {        if (type == vsoVCR)            SetReg(pVD, SyncControl, (UInt8)(ucVal & ~0x18 | 0x18));// Set bit, if VCR         else            SetReg(pVD, SyncControl, (UInt8)(ucVal & ~0x18 | 0x00));// else, clear bit     }    else        return lastI2cError;    return TM_OK;}//-----------------------------------------------------------------------------//// FUNCTION:    tmbsl7113GetSourceType://// DESCRIPTION: Get current source type settings //// RETURN:      tmErrorCode_t for success or error//// NOTES:       NONE////-----------------------------------------------------------------------------tmErrorCode_t   tmbsl7113GetSourceType (    tmUnitSelect_t      aviUnit,        //  I: AVI Unit number                    tmVideoSourceType_t *pType          //  O: receives current source    ){    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]);                                                // Check only forst access     if (GetReg(pVD, SyncControl, &ucVal))       // Read old value     {        if (ucVal & 0x18 == 0x18)            *pType = vsoVCR;        else                 *pType = vsoTV;    }    else        return lastI2cError;    return TM_OK;}//-----------------------------------------------------------------------------//// FUNCTION:    tmbsl7113GetAdapterVideoStandard://// DESCRIPTION: //// RETURN:      tmErrorCode_t for success or error//// NOTES:       NONE////-----------------------------------------------------------------------------tmErrorCode_t   tmbsl7113GetAdapterVideoStandard (    tmUnitSelect_t         aviUnit,     //  I: AVI Unit number                    tmVideoAnalogAdapter_t adapter,     //  I: selected adapter type     UInt32                adapterIndex, //  I: selected adapter index    tmVideoAnalogStandard_t *pStandard  //  O: current standard    ){    // Set input of video accordingly     tmbsl7113SetAnalogInput (aviUnit, adapter, adapterIndex);    return tmbsl7113GetStandard (aviUnit, pStandard);}//-----------------------------------------------------------------------------//// FUNCTION:    tmbsl7113GetGPIOCount://// DESCRIPTION: Get number of GPIO pins in use//// RETURN:      tmErrorCode_t for success or error//// NOTES:       NONE////-----------------------------------------------------------------------------tmErrorCode_t  tmbsl7113GetGPIOCount (    tmUnitSelect_t   aviUnit,           //  I: AVI Unit number                    UInt32           *pNum              //  O: nr of GPIO pins in use    ){    *pNum = 3;       // 3 GPIO pins available     return TM_OK;}//-----------------------------------------------------------------------------//// FUNCTION:    tmbsl7113SetGPIOState://// DESCRIPTION: Set GPIO pin state //// RETURN:      tmErrorCode_t for success or error//// NOTES:       NONE////-----------------------------------------------------------------------------tmErrorCode_t   tmbsl7113SetGPIOState (    tmUnitSelect_t   aviUnit,          //  I: AVI Unit number                    UInt32           pin,              //  I: pin number to set         Bool             state             //  I: state value (0,1)    ){    /* Equivalent to Video DecHAL VideoDecSetGPIOState */    UInt32  ucNum;    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]);    tmbsl7113GetGPIOCount(aviUnit, &ucNum);    // Get number of GPIOs     if (pin >= ucNum)        return TMBSL_ERR_AVI_VAL_OUT_OF_RANGE;    switch (pin)    {        case 0:                                 // RTS0                                                 // Check only first access             if (!GetReg(pVD, OutputControl2, &ucValue))                return lastI2cError;            SetReg(pVD, OutputControl2, (UInt8)(ucValue & ~0x0f | (state ? 0x03 :0x02)));            break;        case 1:                                 // RTS1                                                 // Check only first access             if (!GetReg(pVD, OutputControl2, &ucValue))                return lastI2cError;            SetReg(pVD, OutputControl2, (UInt8)(ucValue & ~0xf0 | (state ? 0x30 :0x20)));            break;        case 2:                                 // GPSW                                                 // Check only first access             if (!GetReg(pVD, OutputControl1, &ucValue))                return lastI2cError;            SetReg(pVD, OutputControl1, (UInt8)(ucValue & ~0x80 | (state ? 0x80 :0x00)));            break;        default:            return TMBSL_ERR_AVI_VAL_OUT_OF_RANGE;    }    return TM_OK;}//-----------------------------------------------------------------------------//// FUNCTION:    tmbsl7113GetGPIOState://// DESCRIPTION: Get current GPIO pin state //// RETURN:      tmErrorCode_t for success or error//// NOTES:       NONE////-----------------------------------------------------------------------------tmErrorCode_t   tmbsl7113GetGPIOState (    tmUnitSelect_t   aviUnit,          //  I: AVI Unit number                    UInt32           pin,              //  I: pin nr to get state from    Bool             *pState         //  O: receives state value    ){     /* Equivalent to Video DecHAL VideoDecGetGPIOState */    UInt32  ucNum;    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]);    tmbsl7113GetGPIOCount(aviUnit, &ucNum);                /* Get number of GPIO's */    if (pin >= ucNum)        return TMBSL_ERR_AVI_VAL_OUT_OF_RANGE;    /* Assume pin is not set */    *pState = False;    switch (pin)    {        case 0:                                 /* RTS0 */                                                /* Check only first access */            if (!GetReg(pVD, OutputControl2, &ucValue))                return lastI2cError;            if ((ucValue & 0x0f) ==  0x03)                *pState = True;                   /* Overwrite False */            break;        case 1:                                 /* RTS1 */                                                /* Check only first access */            if (!GetReg(pVD, OutputControl2, &ucValue))                return lastI2cError;            if ((ucValue & 0xf0) ==  0x30)                *pState = True;                   /* Overwrite False */            break;        case 2:                                 /* GPSW */                                                /* Check only first access */            if (!GetReg(pVD, OutputControl1, &ucValue))                return lastI2cError;            if (ucValue & 0x80)                *pState = True;                   /* Overwrite False */            break;        default:            return TMBSL_ERR_AVI_VAL_OUT_OF_RANGE;    }    return TM_OK;}//-----------------------------------------------------------------------------// VBI slicer related functions://-----------------------------------------------------------------------------//-----------------------------------------------------------------------------//// FUNCTION:    tmbsl7113OpenVBI://// DESCRIPTION: initializes VBI support of decoder//// RETURN:      tmErrorCode_t for success or error//// NOTES:       NONE////-----------------------------------------------------------------------------tmErrorCode_t   tmbsl7113OpenVBI (    tmUnitSelect_t     aviUnit,        //  I: AVI Unit number                    UInt32             sampleFreq,     //  I: sample frequency    UInt32             startLine,      //  I: first VBI line    UInt32             numLines        //  I: nr of VBI lines    ){    /* Equivalent to Video DecHAL VideoDecOpenVBI */    tmVideoAnalogStandard_t videoStd;        if( aviUnit >= SAA7113_MAX_UNITS )    {        return TMBSL_ERR_AVI_BAD_UNIT_NUMBER;    }    if( gDecInstance[aviUnit].init != True )    {        return TMBSL_ERR_AVI_NOT_INITIALIZED;    }    // Only 13.5 MHz sample frequency allowed     if (sampleFreq != 0)        if (sampleFreq != 13500000)          return TMBSL_ERR_AVI_VAL_OUT_OF_RANGE;    /* Not valid call */    if (startLine || numLines)                  /* if not 0 */    {                                                /* Check for underflow */        if ((startLine + numLines) < 2) return TMBSL_ERR_AVI_VAL_OUT_OF_RANGE;        /* Get current video standard */        tmbsl7113GetStandard (aviUnit, &videoStd);        switch (videoStd)        {            case vasPAL:                        /* 50 Hz standards */            case vasSECAM:                if ((startLine + numLines) > 312)                     return TMBSL_ERR_AVI_VAL_OUT_OF_RANGE;                break;            case vasNTSC:                       /* 60 Hz standards */                if ((startLine + numLines) > 262)                     return TMBSL_ERR_AVI_VAL_OUT_OF_RANGE;                break;            default:                return TMBSL_ERR_AVI_VAL_OUT_OF_RANGE;         }    }    m_nStartVBILine = startLine;    m_nNumVBILines = numLines;    return TM_OK;}//-----------------------------------------------------------------------------//// FUNCTION:    tmbsl7113EnableVBI://// DESCRIPTION: enables VBI feature of decoder//// RETURN:      tmErrorCode_t for success or error//// NOTES:       NONE////-----------------------------------------------------------------------------tmErrorCode_t   tmbsl7113EnableVBI (    tmUnitSelect_t     aviUnit,        //  I: AVI Unit number                    Bool               enable          //  I: set True to enable VBI    ){     UInt8 ucVal;    int nCount, i;    tmVideoDataService_t  ucTTMode;    tmVideoDataService_t  oddTable[24];    tmVideoDataService_t  evenTable[24];    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;

⌨️ 快捷键说明

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