#if !defined(__IMX385_CMOS_H_)
#define __IMX385_CMOS_H_
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include "hi_comm_sns.h"
#include "hi_comm_video.h"
#include "hi_sns_ctrl.h"
#include "mpi_isp.h"
#include "mpi_ae.h"
#include "mpi_awb.h"
#include "mpi_af.h"
#ifdef __cplusplus
#if __cplusplus
extern "C"{
#endif
#endif /* End of #ifdef __cplusplus */
#define IMX385_ID 385
/****************************************************************************
* global variables *
****************************************************************************/
ISP_SNS_STATE_S g_astimx385[ISP_MAX_DEV_NUM] = {{0}};
static ISP_SNS_STATE_S *g_apstSnsState[ISP_MAX_DEV_NUM] = {&g_astimx385[0], &g_astimx385[1]};
ISP_SNS_COMMBUS_U g_aunImx385BusInfo[ISP_MAX_DEV_NUM] = {
[0] = { .s8I2cDev = 0},
[1] = { .s8I2cDev = 1}
};
static HI_U32 g_au32InitExposure[ISP_MAX_DEV_NUM] = {0};
static HI_U32 g_au32LinesPer500ms[ISP_MAX_DEV_NUM] = {0};
static HI_U16 g_au16InitWBGain[ISP_MAX_DEV_NUM][3] = {{0}};
static HI_U16 g_au16SampleRgain[ISP_MAX_DEV_NUM] = {0};
static HI_U16 g_au16SampleBgain[ISP_MAX_DEV_NUM] = {0};
static ISP_FSWDR_MODE_E genFSWDRMode[ISP_MAX_DEV_NUM] = {ISP_FSWDR_NORMAL_MODE,ISP_FSWDR_NORMAL_MODE};
static HI_U32 gu32MaxTimeGetCnt[ISP_MAX_DEV_NUM] = {0,0};
extern const unsigned int imx385_i2c_addr;
extern unsigned int imx385_addr_byte;
extern unsigned int imx385_data_byte;
typedef struct hiIMX385_STATE_S
{
HI_U8 u8Hcg;
HI_U32 u32BRL;
HI_U32 u32RHS1_MAX;
HI_U32 u32RHS2_MAX;
} IMX385_STATE_S;
IMX385_STATE_S g_astimx385State[ISP_MAX_DEV_NUM] = {{0}};
extern void imx385_init(ISP_DEV IspDev);
extern void imx385_exit(ISP_DEV IspDev);
extern void imx385_standby(ISP_DEV IspDev);
extern void imx385_restart(ISP_DEV IspDev);
extern int imx385_write_register(ISP_DEV IspDev, int addr, int data);
extern int imx385_read_register(ISP_DEV IspDev, int addr);
#define IMX385_FULL_LINES_MAX (0xFFFF)
#define IMX385_FULL_LINES_MAX_2TO1_WDR (0x8AA) // considering the YOUT_SIZE and bad frame
#define IMX385_FULL_LINES_MAX_3TO1_WDR (0x7FC)
/*****Imx385 Register Address*****/
#define IMX385_SHS1_ADDR (0x3020)
#define IMX385_SHS2_ADDR (0x3024)
#define IMX385_SHS3_ADDR (0x3028)
#define IMX385_GAIN_ADDR (0x3014)
#define IMX385_HCG_ADDR (0x3009)
#define IMX385_VMAX_ADDR (0x3018)
#define IMX385_HMAX_ADDR (0x301c)
#define IMX385_RHS1_ADDR (0x3030)
#define IMX385_RHS2_ADDR (0x3034)
#define IMX385_Y_OUT_SIZE_ADDR (0x3418)
#define IMX385_INCREASE_LINES (1) /* make real fps less than stand fps because NVR require*/
#define IMX385_VMAX_1080P30_LINEAR (1125+IMX385_INCREASE_LINES)
#define IMX385_VMAX_1080P60TO30_WDR (1220+IMX385_INCREASE_LINES)
#define IMX385_VMAX_1080P120TO30_WDR (1125+IMX385_INCREASE_LINES)
#define IMX385_VMAX_1080P60_LINEAR (1125+IMX385_INCREASE_LINES)
//sensor fps mode
#define IMX385_SENSOR_1080P_30FPS_LINEAR_MODE (1)
#define IMX385_SENSOR_1080P_30FPS_3t1_WDR_MODE (2)
#define IMX385_SENSOR_1080P_30FPS_2t1_WDR_MODE (3)
#define IMX385_SENSOR_1080P_60FPS_LINEAR_MODE (4)
static HI_S32 cmos_get_ae_default(ISP_DEV IspDev,AE_SENSOR_DEFAULT_S *pstAeSnsDft)
{
if (HI_NULL == pstAeSnsDft)
{
printf("null pointer when get ae default value!\n");
return - 1;
}
memset(&pstAeSnsDft->stAERouteAttr, 0, sizeof(ISP_AE_ROUTE_S));
// pstAeSnsDft->u32LinesPer500ms = g_apstSnsState[IspDev]->u32FLStd*30/2;
pstAeSnsDft->u32FullLinesStd = g_apstSnsState[IspDev]->u32FLStd;
pstAeSnsDft->u32FlickerFreq = 0;
pstAeSnsDft->u32FullLinesMax = IMX385_FULL_LINES_MAX;
pstAeSnsDft->stIntTimeAccu.enAccuType = AE_ACCURACY_LINEAR;
pstAeSnsDft->stIntTimeAccu.f32Accuracy = 1;
pstAeSnsDft->stIntTimeAccu.f32Offset = 0;//0.1083; //3.85us
pstAeSnsDft->stAgainAccu.enAccuType = AE_ACCURACY_TABLE;
pstAeSnsDft->stAgainAccu.f32Accuracy = 0.1;
pstAeSnsDft->stDgainAccu.enAccuType = AE_ACCURACY_TABLE;
pstAeSnsDft->stDgainAccu.f32Accuracy = 0.1;
pstAeSnsDft->u32ISPDgainShift = 8;
pstAeSnsDft->u32MinISPDgainTarget = 1 << pstAeSnsDft->u32ISPDgainShift;
// pstAeSnsDft->u32MaxISPDgainTarget = 2 << pstAeSnsDft->u32ISPDgainShift;
pstAeSnsDft->u32MaxISPDgainTarget = 8 << pstAeSnsDft->u32ISPDgainShift; //lzw
if(g_au32LinesPer500ms[IspDev] == 0)
{
pstAeSnsDft->u32LinesPer500ms = g_apstSnsState[IspDev]->u32FLStd*30/2;
}
else
{
pstAeSnsDft->u32LinesPer500ms = g_au32LinesPer500ms[IspDev];
}
pstAeSnsDft->u32InitExposure = 921600;
pstAeSnsDft->enMaxIrisFNO = ISP_IRIS_F_NO_1_0;
pstAeSnsDft->enMinIrisFNO = ISP_IRIS_F_NO_32_0;
pstAeSnsDft->bAERouteExValid = HI_FALSE;
pstAeSnsDft->stAERouteAttr.u32TotalNum = 0;
pstAeSnsDft->stAERouteAttrEx.u32TotalNum = 0;
switch(g_apstSnsState[IspDev]->enWDRMode)
{
default:
case WDR_MODE_NONE: /*linear mode*/
pstAeSnsDft->au8HistThresh[0] = 0xd;
pstAeSnsDft->au8HistThresh[1] = 0x28;
pstAeSnsDft->au8HistThresh[2] = 0x60;
pstAeSnsDft->au8HistThresh[3] = 0x80;
pstAeSnsDft->u32MaxAgain = 31*1024;
pstAeSnsDft->u32MinAgain = 1024;
pstAeSnsDft->u32MaxAgainTarget = pstAeSnsDft->u32MaxAgain;
pstAeSnsDft->u32MinAgainTarget = pstAeSnsDft->u32MinAgain;
pstAeSnsDft->u32MaxDgain = 125*1024;
pstAeSnsDft->u32MinDgain = 1024;
pstAeSnsDft->u32MaxDgainTarget = 125*1024;
pstAeSnsDft->u32MinDgainTarget = pstAeSnsDft->u32MinDgain;
pstAeSnsDft->u8AeCompensation = 0x38;
pstAeSnsDft->enAeExpMode = AE_EXP_HIGHLIGHT_PRIOR;
pstAeSnsDft->u32InitExposure = g_au32InitExposure[IspDev] ? g_au32InitExposure[IspDev] : 148859;
pstAeSnsDft->u32MaxIntTime = g_apstSnsState[IspDev]->u32FLStd - 2;
pstAeSnsDft->u32MinIntTime = 1;
pstAeSnsDft->u32MaxIntTimeTarget = 65535;
pstAeSnsDft->u32MinIntTimeTarget = 1;
break;
case WDR_MODE_2To1_LINE:
pstAeSnsDft->au8HistThresh[0] = 0xC;
pstAeSnsDft->au8HistThresh[1] = 0x18;
pstAeSnsDft->au8HistThresh[2] = 0x60;
pstAeSnsDft->au8HistThresh[3] = 0x80;
pstAeSnsDft->u32MaxIntTime = g_apstSnsState[IspDev]->u32FLStd - 2;
pstAeSnsDft->u32MinIntTime = 2;
pstAeSnsDft->u32MaxIntTimeTarget = 65535;
pstAeSnsDft->u32MinIntTimeTarget = pstAeSnsDft->u32MinIntTime;
pstAeSnsDft->u32MaxAgain = 62564;
pstAeSnsDft->u32MinAgain = 1024;
pstAeSnsDft->u32MaxAgainTarget = 62564;
pstAeSnsDft->u32MinAgainTarget = pstAeSnsDft->u32MinAgain;
pstAeSnsDft->u32MaxDgain = 38577;
pstAeSnsDft->u32MinDgain = 1024;
pstAeSnsDft->u32MaxDgainTarget = 20013;
pstAeSnsDft->u32MinDgainTarget = pstAeSnsDft->u32MinDgain;
pstAeSnsDft->u32InitExposure = g_a
评论3
最新资源