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

📄 saa7111.c

📁 用于TM1300/PNX1300系列DSP(主要用于视频处理)的设备库的源码
💻 C
📖 第 1 页 / 共 3 页
字号:
    /* Just ignore this command */
    return TMLIBDEV_OK;
}

extern tmLibdevErr_t
saa7111SetSlicerInput(pboardVIDec_t pVD, UInt num)
{
    /* Equivalent to Video DecHAL VideoDecSetTTVideoSource */

    UInt8 ucVal;

    /* Slicer input on 7111 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 & 0x07) != num)
        return BOARD_ERR_VAL_OUT_OF_RANGE;
    else
        return TMLIBDEV_OK;
}

extern tmLibdevErr_t
saa7111GetSlicerInput(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 & 0x07;
    
    return TMLIBDEV_OK;
}

extern tmLibdevErr_t
saa7111SetVideoColor(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 > 3)
                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 | (val & 0x03)));
            }
            break;
        default:
            return BOARD_ERR_VAL_OUT_OF_RANGE;
    }

    return TMLIBDEV_OK;
}

extern tmLibdevErr_t
saa7111GetVideoColor(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  = 0x03;
            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
saa7111SetAnalogInput(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 & ~0x07 | (num & 0x07));

    return TMLIBDEV_OK;
}

extern tmLibdevErr_t
saa7111GetAnalogInput(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 & 0x07;
    
    return TMLIBDEV_OK;
}

extern tmLibdevErr_t
saa7111SetStandard(pboardVIDec_t pVD, tmVideoAnalogStandard_t standard)
{ 
    /* Equivalent to Video DecHAL SetVideoStandard */

    UInt8 ucVal;
                                                 /* Only check first access */
    if (GetReg(pVD, ChromaControl, &ucVal))      /* Read old value */
    {
        ucVal &= ~0x73;                          /* Delete video standard bits; */
        switch (standard)
        {
            case vasNTSC:
            case vasPAL:
                SetReg(pVD, ChromaControl, ucVal | 0x01);
                
                GetReg(pVD, LuminanceControl, &ucVal);
                SetReg(pVD, LuminanceControl, (ucVal & ~0x03) | 0x01);  /* Aperture factor */
                
                break;
            case vasSECAM:
                SetReg(pVD, ChromaControl, ucVal | 0x50);    
    
                GetReg(pVD, LuminanceControl, &ucVal);
                SetReg(pVD, LuminanceControl, (ucVal & ~0x03) | 0x00);  //Aperture factor 
                
                break;
            default:
                return BOARD_ERR_VAL_OUT_OF_RANGE;
        }
    }
    else
        return (tmLibdevErr_t) lastI2cError;

    return TMLIBDEV_OK;
}

extern tmLibdevErr_t
saa7111SetSourceType(pboardVIDec_t pVD, tmVideoSourceType_t type)
{
    // Equivalent to Video DecHAL VideoDecSetSourceType

    UInt8 ucVal;
                                                // Check only forst access
    if (GetReg(pVD, SyncControl, &ucVal))       // Read old value
    {
        if (type == vsoVCR)
            SetReg(pVD, SyncControl, ucVal & ~0x18 | 0x18);// Set bit, if VCR
        else
            SetReg(pVD, SyncControl, ucVal & ~0x18 | 0x00);// else, clear bit
    }
    else
        return (tmLibdevErr_t) lastI2cError;

    return TMLIBDEV_OK;
}

extern tmLibdevErr_t
saa7111GetSourceType(pboardVIDec_t pVD, tmVideoSourceType_t *type)
{
    // Equivalent to Video DecHAL VideoDecGetSourceType

    UInt8 ucVal;
                                                // Check only forst access
    if (GetReg(pVD, SyncControl, &ucVal))            // Read old value
    {
        if (ucVal & 0x18 == 0x18)
            *type = vsoVCR;
        else     
            *type = vsoTV; 
    }
    else
        return (tmLibdevErr_t) lastI2cError;

    return TMLIBDEV_OK;
}

extern tmLibdevErr_t
saa7111SetOutputFormat(pboardVIDec_t pVD, tmVideoRGBYUVFormat_t format)
{ 
    /* Equivalent to Video DecHAL VideoDecSetVideoFormat */

    switch (format)
    {
        case vdfYUV422Sequence : /* VD_D1_CCIR656: */
            break;
        default:
            return BOARD_ERR_VAL_OUT_OF_RANGE;
    }

    return TMLIBDEV_OK;
}

extern tmLibdevErr_t
saa7111GetOutputFormat(pboardVIDec_t pVD, tmVideoRGBYUVFormat_t *format)
{
    /* Equivalent to Video DecHAL VideoDecGetVideoFormat */

    *format = vdfYUV422Sequence; 
    return TMLIBDEV_OK;
}

extern tmLibdevErr_t
saa7111GetDefaultAcquisitionWnd(pboardVIDec_t pVD, UInt *beginX, UInt *beginY, UInt *endX, UInt *endY)
{ 
    /* Equivalent to Video DecHAL VideoDecGetDefaultAcquisitionWnd */

    switch (pVD->curVideoStandard)
    {
    case vasNTSC:
        /* Set default acquisition window for NTSC */
        *beginX = 6;
        *beginY = 12;
        *endX   = *beginX + 719;
        *endY   = *beginY + 239;
        break;
    case vasPAL:
        /* Set default acquisition window for PAL */
        *beginX = 6;
        *beginY = 1;
        *endX   = *beginX + 719;
        *endY   = *beginY + 287;
        break;
    default:
        return BOARD_ERR_COLOR_STANDARD_NOT_DETECTED;
    }

    return TMLIBDEV_OK;
}


extern tmLibdevErr_t
saa7111DisableDecoder(pboardVIDec_t pVD, Bool disable)
{
    /* Counterpart to Video DecHAL VideoDecEnableDecoder */

    UInt8 ucValue;

    if (!GetReg(pVD, OutputControl1, &ucValue))        /* Check only first access */
        return (tmLibdevErr_t) lastI2cError;

    SetReg(pVD, OutputControl1, (ucValue & ~0x0c) | (disable ? 0x00 : 0x0c));

    return TMLIBDEV_OK;
}

extern tmLibdevErr_t
saa7111EnablePowerSaveMode(pboardVIDec_t pVD, Bool enable)
{ 
    /* Equivalent to Video DecHAL VideoDecPowerSaveMode */

    /* Nothing to set for 7111 -> return error */
    return BOARD_ERR_UNSUPPORTED_FUNCTION;
}

extern tmLibdevErr_t
saa7111GetGPIOCount(pboardVIDec_t pVD, UInt *num)
{
    /* Equivalent to Video DecHAL VideoDecGetGPIOCount */

    *num = 0;       /* 0 GPIO pins available */

    return TMLIBDEV_OK;
}

extern tmLibdevErr_t
saa7111SetGPIOState(pboardVIDec_t pVD, UInt pin, Bool state)
{
    /* Equivalent to Video DecHAL VideoDecSetGPIOState */

    /* Nothing to set for 7111 -> return error */
    return BOARD_ERR_UNSUPPORTED_FUNCTION;
}

extern tmLibdevErr_t
saa7111GetGPIOState(pboardVIDec_t pVD, UInt pin, Bool *state)
{ 
    /* Equivalent to Video DecHAL VideoDecGetGPIOState */

    /* Nothing to get for 7111 -> return error */
    return BOARD_ERR_UNSUPPORTED_FUNCTION;

}

⌨️ 快捷键说明

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