⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tmvi.c

📁 用于TM1300/PNX1300系列DSP(主要用于视频处理)的设备库的源码
💻 C
📖 第 1 页 / 共 4 页
字号:
 *                    endX          (O) receives current horizontal end of window
 *                    endY          (O) receives current vertical end of window
 * Function Result  : resulting error condition
 */

extern tmLibdevErr_t
viGetAcquisitionWnd(Int instance, UInt *beginX, UInt *beginY, UInt *endX, UInt *endY)
{
    boardVIConfig_t *boardVIConfig = ((pviInstVars_t)instance)->boardVIConfig;

    IS_VALID(instance);
    tmAssert(boardVIConfig != Null, VI_ERR_UNINIT_DECODER);

    if (boardVIConfig->getAcquisitionWnd)
        return boardVIConfig->getAcquisitionWnd(&boardVIConfig->vDec, beginX, beginY, endX, endY);
    else
        return BOARD_ERR_NULL_FUNCTION;
}

/*
 * Function         : Get the decoder's default video acqusition window
 * Parameters       : instance      (I) instance
 *                    beginX        (O) receives default horizontal start of window
 *                    beginY        (O) receives default vertical start of window
 *                    endX          (O) receives default horizontal end of window
 *                    endY          (O) receives default vertical end of window
 * Function Result  : resulting error condition
 */

extern tmLibdevErr_t
viGetDefaultAcquisitionWnd(Int instance, UInt *beginX, UInt *beginY, UInt *endX, UInt *endY)
{ 
    boardVIConfig_t *boardVIConfig = ((pviInstVars_t)instance)->boardVIConfig;

    IS_VALID(instance);
    tmAssert(boardVIConfig != Null, VI_ERR_UNINIT_DECODER);

    if (boardVIConfig->getDefaultAcquisitionWnd)
        return boardVIConfig->getDefaultAcquisitionWnd(&boardVIConfig->vDec, beginX, beginY, endX, endY);
    else
        return BOARD_ERR_NULL_FUNCTION;
}

/*
 * Function         : Set the decoder's output window
 * Parameters       : instance      (I) instance
 *                    width         (I) specifies new width of the video output window
 *                    height        (I) specifies new height of the video output window
 * Function Result  : resulting error condition
 */

extern tmLibdevErr_t
viSetOutputSize(Int instance, UInt width, UInt height)
{
    boardVIConfig_t *boardVIConfig = ((pviInstVars_t)instance)->boardVIConfig;

    IS_VALID(instance);
    tmAssert(boardVIConfig != Null, VI_ERR_UNINIT_DECODER);

    if (boardVIConfig->setOutputSize)
        return boardVIConfig->setOutputSize(&boardVIConfig->vDec, width, height);
    else
        return BOARD_ERR_NULL_FUNCTION;
}

/*
 * Function         : Set the decoder's interlace mode
 * Parameters       : instance      (I) instance
 *                    interlace     (I) True: use decoder's interlace mode
 * Function Result  : resulting error condition
 */

extern tmLibdevErr_t
viSetInterlaceMode(Int instance, Bool interlace)
{
    boardVIConfig_t *boardVIConfig = ((pviInstVars_t)instance)->boardVIConfig;

    IS_VALID(instance);
    tmAssert(boardVIConfig != Null, VI_ERR_UNINIT_DECODER);

    if (boardVIConfig->setInterlaceMode)
        return boardVIConfig->setInterlaceMode(&boardVIConfig->vDec, interlace);
    else
        return BOARD_ERR_NULL_FUNCTION;
}

/*
 * Function         : Disable/tristate the decoder's output pins
 * Parameters       : instance      (I) instance
 *                    disable       (I) True: disable decoder
 * Function Result  : resulting error condition
 */

extern tmLibdevErr_t
viDisableDecoder(Int instance, Bool disable)
{
    boardVIConfig_t *boardVIConfig = ((pviInstVars_t)instance)->boardVIConfig;

    IS_VALID(instance);
    tmAssert(boardVIConfig != Null, VI_ERR_UNINIT_DECODER);

    if (boardVIConfig->disableDecoder)
        return boardVIConfig->disableDecoder(&boardVIConfig->vDec, disable);
    else
        return BOARD_ERR_NULL_FUNCTION;
}

/*
 * Function         : Enable/Disable the decoder's power save mode
 * Parameters       : instance      (I) instance
 *                    enable        (I) True: turn on power save mode
 * Function Result  : resulting error condition
 */

extern tmLibdevErr_t
viEnablePowerSaveMode(Int instance, Bool enable)
{ 
    boardVIConfig_t *boardVIConfig = ((pviInstVars_t)instance)->boardVIConfig;

    IS_VALID(instance);
    tmAssert(boardVIConfig != Null, VI_ERR_UNINIT_DECODER);

    if (boardVIConfig->enablePowerSaveMode)
        return boardVIConfig->enablePowerSaveMode(&boardVIConfig->vDec, enable);
    else
        return BOARD_ERR_NULL_FUNCTION;
}

/*
 * Function         : Get number of GPIO pins on decoder
 * Parameters       : instance      (I) instance
 *                    enable        (O) receives # of GPIOs 
 * Function Result  : resulting error condition
 */

extern tmLibdevErr_t
viGetGPIOCount(Int instance, UInt *num)
{
    boardVIConfig_t *boardVIConfig = ((pviInstVars_t)instance)->boardVIConfig;

    IS_VALID(instance);
    tmAssert(boardVIConfig != Null, VI_ERR_UNINIT_DECODER);

    if (boardVIConfig->getGPIOCount)
        return boardVIConfig->getGPIOCount(&boardVIConfig->vDec, num);
    else
        return BOARD_ERR_NULL_FUNCTION;
}

/*
 * Function         : Set the state of a decoder's GPIO  pin
 * Parameters       : instance      (I) instance
 *                    pin           (I) # of GPIO pin to set
 *                    state         (I) True: output high, otherwise low 
 * Function Result  : resulting error condition
 */

extern tmLibdevErr_t
viSetGPIOState(Int instance, UInt pin, Bool state)
{
    boardVIConfig_t *boardVIConfig = ((pviInstVars_t)instance)->boardVIConfig;

    IS_VALID(instance);
    tmAssert(boardVIConfig != Null, VI_ERR_UNINIT_DECODER);

    if (boardVIConfig->setGPIOState)
        return boardVIConfig->setGPIOState(&boardVIConfig->vDec, pin, state);
    else
        return BOARD_ERR_NULL_FUNCTION;
}

/*
 * Function         : Get the state of a decoder's GPIO  pin
 * Parameters       : instance      (I) instance
 *                    pin           (I) # of GPIO pin to set
 *                    state         (O) receives current state, True = high 
 * Function Result  : resulting error condition
 */

extern tmLibdevErr_t
viGetGPIOState(Int instance, UInt pin, Bool *state)
{ 
    boardVIConfig_t *boardVIConfig = ((pviInstVars_t)instance)->boardVIConfig;

    IS_VALID(instance);
    tmAssert(boardVIConfig != Null, VI_ERR_UNINIT_DECODER);

    if (boardVIConfig->getGPIOState)
        return boardVIConfig->getGPIOState(&boardVIConfig->vDec, pin, state);
    else
        return BOARD_ERR_NULL_FUNCTION;
}

/*
 * Function         : Open the decoder for raw VBI handling
 * Parameters       : instance      (I) instance
 *                    sampleFreq    (I) VBI sample freq in Hz
 *                    startLine     (I) first raw VBI line
 *                    numLines      (I) number of VBI lines
 * Function Result  : resulting error condition
 * Note             : Typical sample frequences are 13.5 and 27 MHz
 */

extern tmLibdevErr_t
viOpenVBI(Int instance, UInt sampleFreq, UInt startLine, UInt numLines)
{
    boardVIConfig_t *boardVIConfig = ((pviInstVars_t)instance)->boardVIConfig;

    IS_VALID(instance);
    tmAssert(boardVIConfig != Null, VI_ERR_UNINIT_DECODER);

    if (boardVIConfig->openVBI)
        return boardVIConfig->openVBI(&boardVIConfig->vDec, sampleFreq, startLine, numLines);
    else
        return BOARD_ERR_NULL_FUNCTION;
}

/*
 * Function         : Enable the decoder for raw VBI handling
 * Parameters       : instance      (I) instance
 *                    enable        (I) True: enable raw VBI handling
 * Function Result  : resulting error condition
 */

extern tmLibdevErr_t
viEnableVBI(Int instance, Bool enable)
{ 
    boardVIConfig_t *boardVIConfig = ((pviInstVars_t)instance)->boardVIConfig;

    IS_VALID(instance);
    tmAssert(boardVIConfig != Null, VI_ERR_UNINIT_DECODER);

    if (boardVIConfig->enableVBI)
        return boardVIConfig->enableVBI(&boardVIConfig->vDec, enable);
    else
        return BOARD_ERR_NULL_FUNCTION;
}

/*
 * Function         : Set the decoder's mode for raw VBI handling
 * Parameters       : instance      (I) instance
 *                    mode          (I) set mode to raw Y or baseband YUV
 * Function Result  : resulting error condition
 */

extern tmLibdevErr_t
viSetVBIMode(Int instance, tmVideoVBIMode_t mode)
{ 
    boardVIConfig_t *boardVIConfig = ((pviInstVars_t)instance)->boardVIConfig;

    IS_VALID(instance);
    tmAssert(boardVIConfig != Null, VI_ERR_UNINIT_DECODER);

    if (boardVIConfig->setVBIMode)
        return boardVIConfig->setVBIMode(&boardVIConfig->vDec, mode);
    else
        return BOARD_ERR_NULL_FUNCTION;
}

/*
 * Function         : Set the decoder's mode for sliced VBI data handling
 * Parameters       : instance      (I) instance
 *                    mode          (I) set mode to SAV/EAV or ANC header 
 * Function Result  : resulting error condition
 */

extern tmLibdevErr_t
viSetSlicerMode(Int instance, tmVideoSlicerMode_t mode)
{ 
    boardVIConfig_t *boardVIConfig = ((pviInstVars_t)instance)->boardVIConfig;

    IS_VALID(instance);
    tmAssert(boardVIConfig != Null, VI_ERR_UNINIT_DECODER);

    if (boardVIConfig->setSlicerMode)
        return boardVIConfig->setSlicerMode(&boardVIConfig->vDec, mode);
    else
        return BOARD_ERR_NULL_FUNCTION;
}

/*
 * Function         : Close the decoder's raw VBI data handling
 * Parameters       : instance      (I) instance
 * Function Result  : resulting error condition
 */

extern tmLibdevErr_t
viCloseVBI(Int instance)
{
    boardVIConfig_t *boardVIConfig = ((pviInstVars_t)instance)->boardVIConfig;

    IS_VALID(instance);
    tmAssert(boardVIConfig != Null, VI_ERR_UNINIT_DECODER);

    if (boardVIConfig->closeVBI)
        return boardVIConfig->closeVBI(&boardVIConfig->vDec);
    else
        return BOARD_ERR_NULL_FUNCTION;
}



/*
 * Function         : instance config the decoder.
 * Parameters       : instance      (I) instance
 *                    config        (I0) holds the config structure
 *                                       that will contain input and output.
 * Function Result  : resulting error condition
 */

extern tmLibdevErr_t
viInstanceConfig(Int instance, pviInstanceConfig_t config)
{
    tmLibdevErr_t    rval = TMLIBDEV_OK;
    
    switch (config->command) {
    case VI_CONFIG_SET_VIDEO_COLOR: 
        rval = viSetVideoColor(instance, config->u.videoColor.color, config->u.videoColor.level);
        break;
    case VI_CONFIG_GET_VIDEO_COLOR: 
        rval = viGetVideoColor(instance, config->u.videoColor.color, &config->u.videoColor.level);
        break;
    case VI_CONFIG_SET_SOURCE_TYPE:
        rval = viSetSourceType(instance, config->u.sourceType); 
        break;
    case VI_CONFIG_GET_SOURCE_TYPE:
        rval = viGetSourceType(instance, &config->u.sourceType); 
        break;

    /* These are possibly destructive for TSSA components, holding this instance */
    case VI_CONFIG_CONFIGURE_DECODER: 
       rval = viConfigureDecoder(instance, config->u.iicCommand.subaddr, config->u.iicCommand.value);
       break;
    case VI_CONFIG_GET_VIDEO_STANDARD: 
       rval = viGetVideoStandard(instance, &config->u.colorStandard);
       break;
    case VI_CONFIG_GET_VSYNC_FALLING_EDGE: 
       rval = viGetVSyncFallingEdge(instance, &config->u.line);
        break; 
    case VI_CONFIG_GET_STATUS:
        rval = viGetStatus(instance, config->u.status.type, &config->u.status.status);
        break;
    case VI_CONFIG_GET_SUPPORTED_DATA_SERVICES:
        rval = viGetSupportedDataServices(
                       instance, 
                       config->u.dataServices.fieldOne, 
                       config->u.dataServices.fieldTwo, 
                       config->u.dataServices.tblSize);
        break;
    case VI_CONFIG_SET_DATA_SERVICES:
        rval = viSetDataServices(
                       instance, 
                       config->u.dataServices.fieldOne, 
                       config->u.dataServices.fieldTwo, 
                       config->u.dataServices.tblSize);
        break;
    case VI_CONFIG_GET_SLICER_LINE_FLAGS:
        rval = viGetSlicerLineFlags(
                       instance, 
                       config->u.lineFlags.fieldOne, 
                       config->u.lineFlags.fieldTwo, 
                       config->u.lineFlags.tblSize);
        break;
    case VI_CONFIG_ENABLE_SLICING:
        rval = viEnableSlicing(instance, config->u.enableSlicing); 
        break;
    case VI_CONFIG_TOGGLE_FIELD_ID:
        rval = viToggleFieldID(instance, config->u.toggleFieldId); 
        break;
    case VI_CONFIG_SET_SLICER_INPUT:
        rval = viSetSlicerInput(instance,  config->u.input.adapter, config->u.input.adapterInstance);
        break;
    case VI_CONFIG_GET_SLICER_INPUT:
        rval = viGetSlicerInput(instance, &config->u.input.adapter, &config->u.input.adapterInstance);
        break;
    case VI_CONFIG_SET_ANALOGUE_INPUT:
        rval = viSetAnalogInput(instance, config->u.input.adapter, config->u.input.adapterInstance);
        break;
    case VI_CONFIG_GET_ANALOGUE_INPUT:
        rval = viGetAnalogInput(instance, &config->u.input.adapter, &config->u.input.adapterInstance);
        break;
    case VI_CONFIG_SET_STANDARD:
       rval = viSetStandard(instance, config->u.colorStandard);
        break;
    case VI_CONFIG_SET_OUTPUT_FORMAT:
        rval = viSetOutputFormat(instance, config->u.format);
        break;
    case VI_CONFIG_GET_OUTPUT_FORMAT:
        rval = viGetOutputFormat(instance, &config->u.format);
        break;
    case VI_CONFIG_SET_ACQUITSITION_WINDOW:
        rval = viSetAcquisitionWnd(
                   instance,
                   config->u.window.beginX,
                   config->u.window.beginY,
                   config->u.window.endX,
                   config->u.window.endY);
        break;
    case VI_CONFIG_GET_ACQUITSITION_WINDOW:
        rval = viGetAcquisitionWnd(
                   instance,
                   &config->u.window.beginX,
                   &config->u.window.beginY,
                   &config->u.window.endX,
                   &config->u.window.endY);
        break;
    case VI_CONFIG_GET_DEFAULT_ACQUITSITION_WINDOW:
        rval = viGetDefaultAcquisitionWnd(
                   instance,
                   &config->u.window.beginX,
                   &config->u.window.beginY,
                   &config->u.window.endX,
                   &config->u.window.endY);
        break;
    case VI_CONFIG_SET_INTERLACE_MODE:
        rval = viSetInterlaceMode(instance, config->u.interlaceMode);
        break;
    case VI_CONFIG_SET_OUTPUT_SIZE:
        rval = viSetOutputSize(instance, config->u.outputSize.width, config->u.outputSize.height);
        break;
    case VI_CONFIG_ENABLE_POWER_SAVE_MODE:
        rval = viEnablePowerSaveMode(instance, config->u.powerSave);
        break;
    case VI_CONFIG_GET_GPIO_COUNT:
        rval = viGetGPIOCount(instance, &config->u.num);
        break;
    case VI_CONFIG_SET_GPIO_STATE:
        rval = viSetGPIOState(instance, config->u.gpioState.pin, config->u.gpioState.state);
        break;
    case VI_CONFIG_GET_GPIO_STATE:
        rval = viGetGPIOState(instance, config->u.gpioState.pin, &config->u.gpioState.state);
        break;

    default: 
        rval = VI_ERR_INVALID_CONFIG_COMMAND;
        break;
    }
    return rval;
}

⌨️ 快捷键说明

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