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

📄 image_sensor.c

📁 MTK6225摄像头驱动。芯片是SIV120A。
💻 C
📖 第 1 页 / 共 5 页
字号:
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/

    write_cmos_sensor(0x00, 0x03);  //bank 3
    switch (iPara)
    {
        case CAM_EFFECT_ENC_NORMAL:
            write_cmos_sensor(0x89, 0x00);
            break;

        case CAM_EFFECT_ENC_GRAYSCALE:
            write_cmos_sensor(0x89, 0x40);
            break;

        case CAM_EFFECT_ENC_SEPIA:
            write_cmos_sensor(0x8A, 0x00);
            write_cmos_sensor(0x8B, 0xA0);
            write_cmos_sensor(0x89, 0x80);			
            break;

        case CAM_EFFECT_ENC_SEPIAGREEN:
            write_cmos_sensor(0x8A, 0x50);
            write_cmos_sensor(0x8B, 0x50);
            write_cmos_sensor(0x89, 0x80);			
            break;

        case CAM_EFFECT_ENC_SEPIABLUE:
            write_cmos_sensor(0x8A, 0xC0);
            write_cmos_sensor(0x8B, 0x60);
            write_cmos_sensor(0x89, 0x80);			
            break;
        
        case CAM_EFFECT_ENC_COLORINV:
            write_cmos_sensor(0x89, 0x10);
            break;
            
        case CAM_EFFECT_ENC_GRAYINV:
            write_cmos_sensor(0x89, 0x20);
            break;

        case CAM_EFFECT_ENC_EMBOSSMENT:
            write_cmos_sensor(0x89, 0x08);
            break;
        
        case CAM_EFFECT_ENC_SKETCH:
             write_cmos_sensor(0x89, 0x04);
             break;
             
        case CAM_EFFECT_ENC_WHITEBOARD:
        case CAM_EFFECT_ENC_COPPERCARVING:        
        case CAM_EFFECT_ENC_BLUECARVING:
        case CAM_EFFECT_ENC_CONTRAST:
        case CAM_EFFECT_ENC_JEAN:       
        case CAM_EFFECT_ENC_OIL:
        default:
            return KAL_FALSE;
    }

    return KAL_TRUE;
}   /* SIV120A_Set_Para_Effect */

/*************************************************************************
* FUNCTION
*   SIV120A_Set_Para_AF_Key
*
* DESCRIPTION
*   SIV120A
*
* PARAMETERS
*   None
*
* RETURNS
*   None
*
* GLOBALS AFFECTED
*
*************************************************************************/
kal_uint32 SIV120A_Set_Para_AF_Key(kal_uint32 iPara)
{
    switch (iPara)
    {
    case CAM_AF_RELEASE:
    case CAM_AF_ONE_TIME:
    case CAM_AF_CONTINUE:
    default:
        return KAL_FALSE;
    }

    return KAL_FALSE;
}   /* SIV120A_Set_Para_AF_Key */

/*************************************************************************
* FUNCTION
*   SIV120A_Set_Para_Manual_Focus_Dir
*
* DESCRIPTION
*   SIV120A
*
* PARAMETERS
*   None
*
* RETURNS
*   None
*
* GLOBALS AFFECTED
*
*************************************************************************/
kal_uint32 SIV120A_Set_Para_Manual_Focus_Dir(kal_uint32 iPara)
{
    switch (iPara)
    {
    case CAM_FOCUS_STOP:
    case CAM_FOCUS_FORWARD:
    case CAM_FOCUS_BACKWARD:
    case CAM_FOCUS_FORWARD_CONTINUE:
    case CAM_FOCUS_BACKWARD_CONTINUE:
    default:
        return KAL_FALSE;
    }

    return KAL_FALSE;
}   /* SIV120A_Set_Para_Manual_Focus_Dir */

/*************************************************************************
* FUNCTION
*   SIV120A_Set_Para_AF_Mode
*
* DESCRIPTION
*   SIV120A
*
* PARAMETERS
*   None
*
* RETURNS
*   None
*
* GLOBALS AFFECTED
*
*************************************************************************/
kal_uint32 SIV120A_Set_Para_AF_Mode(kal_uint32 iPara)
{
    switch (iPara)
    {
    case CAM_AF_AUTO_MODE:
    case CAM_AF_MACRO_MODE:
    case CAM_AF_INFINITE_MODE:
    case CAM_AF_MANUAL_MODE:
    default:
        return KAL_FALSE;
    }

    return KAL_FALSE;
}   /* SIV120A_Set_Para_AF_Mode */

/*************************************************************************
* FUNCTION
*   SIV120A_Set_Para_AF_Meter
*
* DESCRIPTION
*   SIV120A
*
* PARAMETERS
*   None
*
* RETURNS
*   None
*
* GLOBALS AFFECTED
*
*************************************************************************/
kal_uint32 SIV120A_Set_Para_AF_Meter(kal_uint32 iPara)
{
    switch (iPara)
    {
    case CAM_AF_SINGLE_ZONE:
    case CAM_AF_MULTI3_ZONE:
    case CAM_AF_MULTI5_ZONE:
    default:
        return KAL_FALSE;
    }

    return KAL_FALSE;
}   /* SIV120A_Set_Para_AF_Meter */

/*************************************************************************
* FUNCTION
*   SIV120A_Set_Para_Flash
*
* DESCRIPTION
*   SIV120A
*
* PARAMETERS
*   None
*
* RETURNS
*   None
*
* GLOBALS AFFECTED
*
*************************************************************************/
kal_uint32 SIV120A_Set_Para_Flash(kal_uint32 iPara)
{
    switch (iPara)
    {
    case CAM_FLASH_OFF:
    case CAM_FLASH_ON:
    case CAM_FLASH_AUTO:
    case CAM_FLASH_REDEYE:
    default:
        return KAL_FALSE;
    }

    return KAL_FALSE;
}   /* SIV120A_Set_Para_Flash */

/*************************************************************************
* FUNCTION
*   SIV120A_YUV_SensorSetting
*
* DESCRIPTION
*   This function sends command and parameter to YUV-mode SIV120A to configure it
*
* PARAMETERS
*   None
*
* RETURNS
*   None
*
* GLOBALS AFFECTED
*
*************************************************************************/
kal_uint32 SIV120A_YUV_SensorSetting(kal_uint32 iCmd, kal_uint32 iPara)
{
    kal_uint32 iRet = KAL_FALSE;

    switch (iCmd)
    {
    case CAM_PARAM_ZOOM_FACTOR:
            iRet = SIV120A_Set_Para_Zoom(iPara);
        break;

    case CAM_PARAM_CONTRAST:
            iRet = SIV120A_Set_Para_Contrast(iPara);
        break;

    case CAM_PARAM_BRIGHTNESS:
            iRet = SIV120A_Set_Para_Brightness(iPara);
        break;

    case CAM_PARAM_HUE:
            iRet = SIV120A_Set_Para_Hue(iPara);
        break;

    case CAM_PARAM_GAMMA:
            iRet = SIV120A_Set_Para_Gamma(iPara);
        break;

    case CAM_PARAM_WB:
            iRet = SIV120A_Set_Para_WB(iPara);
        break;

    case CAM_PARAM_EXPOSURE:
            iRet = SIV120A_Set_Para_EV(iPara);
        break;

    case CAM_PARAM_EFFECT:
            iRet = SIV120A_Set_Para_Effect(iPara);
        break;

    case CAM_PARAM_BANDING:
            iRet = SIV120A_Set_Para_Banding(iPara);
        break;

    case CAM_PARAM_SATURATION:
            iRet = SIV120A_Set_Para_Saturation(iPara);
        break;

    case CAM_PARAM_NIGHT_MODE:
            iRet = SIV120A_Set_Para_NightMode(iPara);
        break;

    case CAM_PARAM_EV_VALUE:
            iRet = SIV120A_Set_Para_EV(iPara);
        break;

    case CAM_PARAM_FLASH:
            iRet = SIV120A_Set_Para_Flash(iPara);
        break;

    case CAM_PARAM_AE_METERING:
            iRet = SIV120A_Set_Para_AE_Meter(iPara);
        break;

    case CAM_PARAM_AF_KEY:
            iRet = SIV120A_Set_Para_AF_Key(iPara);
        break;

    case CAM_PARAM_AF_METERING:
            iRet = SIV120A_Set_Para_AF_Meter(iPara);
        break;

    case CAM_PARAM_AF_MODE:
            iRet = SIV120A_Set_Para_AF_Mode(iPara);
        break;

    case CAM_PARAM_MANUAL_FOCUS_DIR:
            iRet = SIV120A_Set_Para_Manual_Focus_Dir(iPara);
        break;

    case CAM_PARAM_SHUTTER_PRIORITY:
            iRet = SIV120A_Set_Para_Shutter_Priority(iPara);
        break;

    case CAM_PARAM_APERTURE_PRIORITY:
            iRet = SIV120A_Set_Para_Aperture_Priority(iPara);
        break;

    case CAM_PARAM_ISO:
            iRet = SIV120A_Set_Para_ISO(iPara);
        break;

    case CAM_PARAM_DSC_MODE:
            iRet = SIV120A_Set_Para_DSC_Mode(iPara);
        break;

    case CAM_PARAM_YUV_AF_STATUS:
            iRet = SIV120A_Get_Para_AF_Status(iPara);
        break;

    default:
        ASSERT(0);
    }

    return iRet;
}   /* SIV120A_YUV_SensorSetting */

kal_uint16 SIV120A_Get_Device_ID()
{
	return 0x0c10;
}
/*************************************************************************
* FUNCTION
*	image_sensor_func_OV76X0
*
* DESCRIPTION
*	OV76X0 Image Sensor functions struct.
*
* PARAMETERS
*	none
*
* RETURNS
*	None
*
* GLOBALS AFFECTED
*
*************************************************************************/
image_sensor_func_struct image_sensor_func_SIV120A = 
{
    0x0c10,
    SIV120A_Get_Device_ID,
    SIV120A_Init,
    SIV120A_Get_I2C_ID,
    SIV120A_GetSize,
    SIV120A_GetPeriod,
    SIV120A_Preview,
    SIV120A_Capture,
    SIV120A_WriteReg,
    SIV120A_ReadReg,
    SIV120A_SetShutter,
    SIV120A_NightMode,
    SIV120A_PowerOff,
    SIV120A_SetGain,
    SIV120A_SetFlash,
    SIV120A_YUV_SensorSetting
};  /* image_sensor_func_SIV120A */

/*************************************************************************
* FUNCTION
*   image_sensor_func_config
*
* DESCRIPTION
*   This function maps the external camera module function API structure.
*
* PARAMETERS
*
* RETURNS
*   None
*
* GLOBALS AFFECTED
*
*************************************************************************/
void image_sensor_func_config(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    image_sensor_func = &image_sensor_func_SIV120A;
}   /* image_sensor_func_config() */


/*****************************************************************************
 * FUNCTION
 *  camera_para_to_sensor
 * DESCRIPTION
 *  This function write initial setting sequence into sensor's registers
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
void camera_para_to_sensor(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    kal_uint16 iI;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    for (iI = 0; camera_para.SENSOR.reg[iI].addr != 0xFFFFFFFF; iI++)
    {
        write_cmos_sensor(camera_para.SENSOR.reg[iI].addr, camera_para.SENSOR.reg[iI].para);
    }

    for (iI = FACTORY_START_ADDR; camera_para.SENSOR.reg[iI].addr != 0xFFFFFFFF; iI++)
    {
        write_cmos_sensor(camera_para.SENSOR.reg[iI].addr, camera_para.SENSOR.reg[iI].para);
    }

    for (iI = 0; iI < CCT_END_ADDR; iI++)
    {
        write_cmos_sensor(camera_para.SENSOR.cct[iI].addr, camera_para.SENSOR.cct[iI].para);
    }
}   /* camera_para_to_sensor */


/*****************************************************************************
 * FUNCTION
 *  sensor_to_camera_para
 * DESCRIPTION
 *  This function read back sensor's register values to camera_para structure
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
void sensor_to_camera_para(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
}   /* sensor_to_camera_para */

/* ------------------------Engineer mode--------------------------------- */
/********************************************************
*   Engineer mode is unnecessary for YUV sensor driver  *
***************************************

⌨️ 快捷键说明

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