diff --git a/libraries/sensor/hi3516ev200/imagedesign_mis2008/Makefile b/libraries/sensor/hi3516ev200/imagedesign_mis2008/Makefile new file mode 100644 index 0000000..c15bd94 --- /dev/null +++ b/libraries/sensor/hi3516ev200/imagedesign_mis2008/Makefile @@ -0,0 +1,17 @@ +LIB_NAME := libsns_mis2008 + +override CFLAGS += -DSDK_CODE=$(SDK_CODE) -fPIC -I$(CURDIR)/../../../../include + +SRCS := $(wildcard *.c) +OBJS := $(SRCS:%.c=%.o) $(ASM_SRCS:%.S=%.o) + +all: $(LIB_NAME).so $(LIB_NAME).a + +$(LIB_NAME).so: $(OBJS) + $(CC) -shared -o $@ $(OBJS) + +$(LIB_NAME).a: $(OBJS) + $(AR) -rcs $(LIB_NAME).a $(OBJS) + +clean: + -rm $(OBJS) $(LIB_NAME).so diff --git a/libraries/sensor/hi3516ev200/imagedesign_mis2008/mis2008_cmos.c b/libraries/sensor/hi3516ev200/imagedesign_mis2008/mis2008_cmos.c new file mode 100644 index 0000000..1213b7a --- /dev/null +++ b/libraries/sensor/hi3516ev200/imagedesign_mis2008/mis2008_cmos.c @@ -0,0 +1,1075 @@ +/* + * (c) OpenIPC.org (c) +*/ + +#include +#include +#include +#include "comm_sns.h" +#include "comm_video.h" +#include "sns_ctrl.h" +#include "gk_api_isp.h" +#include "gk_api_ae.h" +#include "gk_api_awb.h" +#include "mis2008_cmos_ex.h" +#include "hicompat.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif +#endif /* End of #ifdef __cplusplus */ + +#define MIS2008_ID 0x2008 +#define HIGH_8BITS(x) (((x)&0xFF00) >> 8) +#define LOW_8BITS(x) ((x)&0x00FF) +#define LOWER_4BITS(x) (((x)&0x000F) << 4) +#define HIGHER_4BITS(x) (((x)&0xF000) >> 12) +#define HIGHER_8BITS(x) (((x)&0x0FF0) >> 4) + +#ifndef MAX +#define MAX(a, b) (((a) < (b)) ? (b) : (a)) +#endif + +#ifndef MIN +#define MIN(a, b) (((a) > (b)) ? (b) : (a)) +#endif + +ISP_SNS_STATE_S *g_pastMis2008[ISP_MAX_PIPE_NUM] = { GK_NULL }; + +#define MIS2008_SENSOR_GET_CTX(dev, pstCtx) (pstCtx = g_pastMis2008[dev]) +#define MIS2008_SENSOR_SET_CTX(dev, pstCtx) (g_pastMis2008[dev] = pstCtx) +#define MIS2008_SENSOR_RESET_CTX(dev) (g_pastMis2008[dev] = GK_NULL) + +ISP_SNS_COMMBUS_U g_aunMis2008BusInfo[ISP_MAX_PIPE_NUM] = { [0] = { .s8I2cDev = 0 }, + [1 ... ISP_MAX_PIPE_NUM - 1] = { .s8I2cDev = -1 } }; + +static GK_U32 gu32MaxTimeGetCnt[ISP_MAX_PIPE_NUM] = { 0 }; +static GK_U32 g_au32InitExposure[ISP_MAX_PIPE_NUM] = { 0 }; +static GK_U32 g_au32LinesPer500ms[ISP_MAX_PIPE_NUM] = { 0 }; +static GK_U16 g_au16InitWBGain[ISP_MAX_PIPE_NUM][3] = { { 0 } }; +static GK_U16 g_au16SampleRgain[ISP_MAX_PIPE_NUM] = { 0 }; +static GK_U16 g_au16SampleBgain[ISP_MAX_PIPE_NUM] = { 0 }; +static GK_U32 au32WDRIntTime[4] = { 0 }; + +/**************************************************************************** + * extern * + ****************************************************************************/ +extern const unsigned int mis2008_i2c_addr; +extern unsigned int mis2008_addr_byte; +extern unsigned int mis2008_data_byte; + +extern void mis2008_init(VI_PIPE ViPipe); +extern void mis2008_exit(VI_PIPE ViPipe); +extern void mis2008_standby(VI_PIPE ViPipe); +extern void mis2008_restart(VI_PIPE ViPipe); +extern int mis2008_write_register(VI_PIPE ViPipe, int addr, int data); +extern int mis2008_read_register(VI_PIPE ViPipe, int addr); + +/**************************************************************************** + * local variables * + ****************************************************************************/ +#define MIS2008_FULL_LINES_MAX_LINEAR (0xFFFF) + +/******** MIS2008 Register Address ********/ +#define MIS2008_EXP_ADDR (0x3100) +#define MIS2008_AGAIN_ADDR (0x3102) +#define MIS2008_DGAIN_ADDR (0x3700) +#define MIS2008_VMAX_ADDR (0x3200) +#define MIS2008_FLIP_MIRROR_ADDR 0x3007 + +#define MIS2008_INCREASE_LINES (1) /* make real fps less than stand fps because NVR require*/ + +#define MIS2008_VMAX_1080P30_LINEAR (1125 + MIS2008_INCREASE_LINES) +#define MIS2008_FRAME_RATE_MIN (0x34BC) +#define EXP_OFFSET_LINEAR (8) + +//sensor fps mode +#define MIS2008_SENSOR_1080P_30FPS_LINEAR_MODE (1) + +#define MIS2008_RES_IS_1080P(w, h) ((w) <= 1920 && (h) <= 1080) + +#define MIS2008_ERR_MODE_PRINT(pstSensorImageMode, pstSnsState) \ + do { \ + ISP_TRACE(MODULE_DBG_ERR, "Not support! Width:%d, Height:%d, Fps:%f, WDRMode:%d\n", \ + pstSensorImageMode->u16Width, pstSensorImageMode->u16Height, pstSensorImageMode->f32Fps, \ + pstSnsState->enWDRMode); \ + } while (0) + +GK_U16 Dgain_mapping_realgain_to_sensorgain(GK_FLOAT gain_real); + +GK_U16 Dgain_mapping_realgain_to_sensorgain(GK_FLOAT gain_real) +{ + GK_U16 u16sensorgain; + GK_U32 u32Dgain = gain_real * 128; + GK_U8 dCoarseGain = 0; + GK_U8 dFineGain = 0; + GK_U8 u8Reg0x3e06 = 0; + for (dCoarseGain = 1; dCoarseGain <= 16; dCoarseGain = dCoarseGain * 2) //1,2,4,8,16 + { + if (u32Dgain < (128 * 2 * dCoarseGain)) { + break; + } + } + dFineGain = u32Dgain / dCoarseGain; + + for (; dCoarseGain >= 2; dCoarseGain = dCoarseGain / 2) { + u8Reg0x3e06 = (u8Reg0x3e06 << 1) | 0x01; + } + u16sensorgain = ((GK_U16)u8Reg0x3e06) << 8; + u16sensorgain += dFineGain; + + return u16sensorgain; +} + +static GK_S32 cmos_get_ae_default(VI_PIPE ViPipe, AE_SENSOR_DEFAULT_S *pstAeSnsDft) +{ + ISP_SNS_STATE_S *pstSnsState = GK_NULL; + + CMOS_CHECK_POINTER(pstAeSnsDft); + MIS2008_SENSOR_GET_CTX(ViPipe, pstSnsState); + CMOS_CHECK_POINTER(pstSnsState); + + memset(&pstAeSnsDft->stAERouteAttr, 0, sizeof(ISP_AE_ROUTE_S)); + + pstAeSnsDft->stIntTimeAccu.enAccuType = AE_ACCURACY_LINEAR; + pstAeSnsDft->stIntTimeAccu.f32Accuracy = 1; + pstAeSnsDft->stIntTimeAccu.f32Offset = 0; + + pstSnsState->u32FLStd = MIS2008_VMAX_1080P30_LINEAR ; + pstAeSnsDft->u32FullLinesStd = pstSnsState->u32FLStd; + pstAeSnsDft->u32FlickerFreq = 50 * 256; + pstAeSnsDft->u32FullLinesMax = MIS2008_FULL_LINES_MAX_LINEAR; + pstAeSnsDft->u32HmaxTimes = (1000000) / (pstSnsState->u32FLStd * 30); + + pstAeSnsDft->stAgainAccu.enAccuType = AE_ACCURACY_TABLE; + pstAeSnsDft->stAgainAccu.f32Accuracy = 1; //1/128 0.0078125 + + pstAeSnsDft->stDgainAccu.enAccuType = AE_ACCURACY_TABLE; + pstAeSnsDft->stDgainAccu.f32Accuracy = 1; //1/128 + + pstAeSnsDft->u32ISPDgainShift = 8; + pstAeSnsDft->u32MinISPDgainTarget = 1 << pstAeSnsDft->u32ISPDgainShift; + pstAeSnsDft->u32MaxISPDgainTarget = 2 << pstAeSnsDft->u32ISPDgainShift; + + pstAeSnsDft->enMaxIrisFNO = ISP_IRIS_F_NO_1_4; + pstAeSnsDft->enMinIrisFNO = ISP_IRIS_F_NO_5_6; + + pstAeSnsDft->bAERouteExValid = GK_FALSE; + pstAeSnsDft->stAERouteAttr.u32TotalNum = 0; + pstAeSnsDft->stAERouteAttrEx.u32TotalNum = 0; + + if (g_au32LinesPer500ms[ViPipe] == 0) { + pstAeSnsDft->u32LinesPer500ms = pstSnsState->u32FLStd * 30 / 2; + } else { + pstAeSnsDft->u32LinesPer500ms = g_au32LinesPer500ms[ViPipe]; + } + + pstAeSnsDft->au8HistThresh[0] = 0x0D; + pstAeSnsDft->au8HistThresh[1] = 0x28; + pstAeSnsDft->au8HistThresh[2] = 0x60; + pstAeSnsDft->au8HistThresh[3] = 0x80; + + pstAeSnsDft->u32MaxAgain = 16128; // 1.81*128*32 + pstAeSnsDft->u32MinAgain = 1024; + pstAeSnsDft->u32MaxAgainTarget = pstAeSnsDft->u32MaxAgain; + pstAeSnsDft->u32MinAgainTarget = pstAeSnsDft->u32MinAgain; + + pstAeSnsDft->u32MaxDgain = 16320; //4*128 + pstAeSnsDft->u32MinDgain = 1024; + pstAeSnsDft->u32MaxDgainTarget = pstAeSnsDft->u32MaxDgain; + pstAeSnsDft->u32MinDgainTarget = pstAeSnsDft->u32MinDgain; + + pstAeSnsDft->u8AeCompensation = 40; + pstAeSnsDft->u32InitAESpeed = 64; + pstAeSnsDft->u32InitAETolerance = 5; + + pstAeSnsDft->enAeExpMode = AE_EXP_HIGHLIGHT_PRIOR; + + pstAeSnsDft->u32InitExposure = g_au32InitExposure[ViPipe] ? g_au32InitExposure[ViPipe] : 76151; //148859 + + pstAeSnsDft->u32MaxIntTime = pstSnsState->u32FLStd - 1; + pstAeSnsDft->u32MinIntTime = 1; + pstAeSnsDft->u32MaxIntTimeTarget = 65535; + pstAeSnsDft->u32MinIntTimeTarget = 1; + + return GK_SUCCESS; +} + +/* the function of sensor set fps */ +static GK_VOID cmos_fps_set(VI_PIPE ViPipe, GK_FLOAT f32Fps, AE_SENSOR_DEFAULT_S *pstAeSnsDft) +{ + ISP_SNS_STATE_S *pstSnsState = GK_NULL; + GK_FLOAT f32maxFps; + GK_U32 u32FullLines; + + CMOS_CHECK_POINTER_VOID(pstAeSnsDft); + MIS2008_SENSOR_GET_CTX(ViPipe, pstSnsState); + CMOS_CHECK_POINTER_VOID(pstSnsState); + + switch (pstSnsState->u8ImgMode) { + case MIS2008_SENSOR_1080P_30FPS_LINEAR_MODE: + f32maxFps = 30; + if ((f32Fps <= 30) && (f32Fps >= 2.5)) { /* Minimum 2.5fps */ + u32FullLines = MIS2008_VMAX_1080P30_LINEAR * f32maxFps / DIV_0_TO_1_FLOAT(f32Fps); + } else { + ISP_TRACE(MODULE_DBG_ERR, "Not support Fps: %f\n", f32Fps); + return; + } + u32FullLines = (u32FullLines > MIS2008_FULL_LINES_MAX_LINEAR) ? MIS2008_FULL_LINES_MAX_LINEAR : + u32FullLines; + break; + + default: + printf("Not support this Mode\n"); + return; + break; + } + + pstSnsState->u32FLStd = u32FullLines; + + pstSnsState->astRegsInfo[0].astI2cData[6].u32Data = HIGH_8BITS(u32FullLines); + pstSnsState->astRegsInfo[0].astI2cData[7].u32Data = LOW_8BITS(u32FullLines); + + pstAeSnsDft->f32Fps = f32Fps; + pstAeSnsDft->u32FullLinesStd = pstSnsState->u32FLStd; + pstSnsState->au32FL[0] = pstSnsState->u32FLStd; + pstAeSnsDft->u32FullLines = pstSnsState->au32FL[0]; + + pstAeSnsDft->u32MaxIntTime = (pstSnsState->u32FLStd << 1) - EXP_OFFSET_LINEAR; + // pstAeSnsDft->u32HmaxTimes = (1000000) / (pstSnsState->u32FLStd * DIV_0_TO_1_FLOAT(f32Fps)); + + return; +} + +static GK_VOID cmos_slow_framerate_set(VI_PIPE ViPipe, GK_U32 u32FullLines, AE_SENSOR_DEFAULT_S *pstAeSnsDft) +{ + ISP_SNS_STATE_S *pstSnsState = GK_NULL; + + CMOS_CHECK_POINTER_VOID(pstAeSnsDft); + MIS2008_SENSOR_GET_CTX(ViPipe, pstSnsState); + CMOS_CHECK_POINTER_VOID(pstSnsState); + + u32FullLines = (u32FullLines + EXP_OFFSET_LINEAR) >> 1; + u32FullLines = (u32FullLines > MIS2008_FRAME_RATE_MIN) ? MIS2008_FRAME_RATE_MIN : u32FullLines; + pstSnsState->au32FL[0] = u32FullLines; + pstSnsState->astRegsInfo[0].astI2cData[6].u32Data = HIGH_8BITS(u32FullLines); + pstSnsState->astRegsInfo[0].astI2cData[7].u32Data = LOW_8BITS(u32FullLines); + + pstAeSnsDft->u32FullLines = pstSnsState->au32FL[0]; + + pstAeSnsDft->u32MaxIntTime = pstSnsState->au32FL[0] - EXP_OFFSET_LINEAR; + + return; +} + +/* while isp notify ae to update sensor regs, ae call these funcs. */ +static GK_VOID cmos_inttime_update(VI_PIPE ViPipe, GK_U32 u32IntTime) +{ + ISP_SNS_STATE_S *pstSnsState = GK_NULL; + static GK_BOOL bFirst = GK_TRUE; + static GK_U32 u32ShortIntTime = 0; + static GK_U32 u32LongIntTime = 0; + MIS2008_SENSOR_GET_CTX(ViPipe, pstSnsState); + CMOS_CHECK_POINTER_VOID(pstSnsState); + + // Somehow values after this leads to picture loss + // XM limits this to 0x10000, but actually never sets higher also + if (u32IntTime > 0x545){ + u32IntTime = 0x545; + } + + pstSnsState->astRegsInfo[0].astI2cData[0].u32Data = HIGH_8BITS(u32IntTime); + pstSnsState->astRegsInfo[0].astI2cData[1].u32Data = LOW_8BITS(u32IntTime); + + return; +} + +static const GK_U16 u16AgainTab[64] = { 1024, 1088, 1152, 1216, 1280, 1344, 1408, 1472, 1536, 1600, 1664, + 1728, 1792, 1856, 1920, 1984, 2048, 2176, 2304, 2432, 2560, 2688, + 2816, 2944, 3072, 3200, 3328, 3456, 3584, 3712, 3840, 3968, 4096, + 4352, 4608, 4864, 5120, 5376, 5632, 5888, 6144, 6400, 6656, 6912, + 7168, 7424, 7680, 7936, 8192, 8704, 9216, 9728, 10240, 10752, 11264, + 11776, 12288, 12800, 13312, 13824, 14336, 14848, 15360, 15872 }; + +static GK_U32 Dgain_table[] = { + 1024, 1088, 1152, 1216, 1280, 1344, 1408, 1472, 1536, 1600, 1664, 1728, 1792, 1856, 1920, 1984, + 2048, 2112, 2176, 2240, 2304, 2368, 2432, 2496, 2560, 2624, 2688, 2752, 2816, 2880, 2944, 3008, + 3072, 3136, 3200, 3264, 3328, 3392, 3456, 3520, 3584, 3648, 3712, 3776, 3840, 3904, 3968, 4032, + 4096, 4160, 4224, 4288, 4352, 4416, 4480, 4544, 4608, 4672, 4736, 4800, 4864, 4928, 4992, 5056, + 5120, 5184, 5248, 5312, 5376, 5440, 5504, 5568, 5632, 5696, 5760, 5824, 5888, 5952, 6016, 6080, + 6144, 6208, 6272, 6336, 6400, 6464, 6528, 6592, 6656, 6720, 6784, 6848, 6912, 6976, 7040, 7104, + 7168, 7232, 7296, 7360, 7424, 7488, 7552, 7616, 7680, 7744, 7808, 7872, 7936, 8000, 8064, 8128, + 8192, 8256, 8320, 8384, 8448, 8512, 8576, 8640, 8704, 8768, 8832, 8896, 8960, 9024, 9088, 9152, + 9216, 9280, 9344, 9408, 9472, 9536, 9600, 9664, 9728, 9792, 9856, 9920, 9984, 10048, 10112, 10176, + 10240, 10304, 10368, 10432, 10496, 10560, 10624, 10688, 10752, 10816, 10880, 10944, 11008, 11072, 11136, 11200, + 11264, 11328, 11392, 11456, 11520, 11584, 11648, 11712, 11776, 11840, 11904, 11968, 12032, 12096, 12160, 12224, + 12288, 12352, 12416, 12480, 12544, 12608, 12672, 12736, 12800, 12864, 12928, 12992, 13056, 13120, 13184, 13248, + 13312, 13376, 13440, 13504, 13568, 13632, 13696, 13760, 13824, 13888, 13952, 14016, 14080, 14144, 14208, 14272, + 14336, 14400, 14464, 14528, 14592, 14656, 14720, 14784, 14848, 14912, 14976, 15040, 15104, 15168, 15232, 15296, + 15360, 15424, 15488, 15552, 15616, 15680, 15744, 15808, 15872, 15936, 16000, 16064, 16128, 16192, 16256, 16320 +}; + +struct gain_tbl_info_s { + GK_U16 gainMax; + GK_U16 idxBase; + GK_U8 regGain; + GK_U8 regGainFineBase; + GK_U8 regGainFineStep; +}; + +static struct gain_tbl_info_s DgainInfo[] = { + { + .gainMax = 1984, + .idxBase = 0, + .regGain = 0x01, + .regGainFineBase = 0x10, + .regGainFineStep = 1, + }, + { + .gainMax = 3008, + .idxBase = 16, + .regGain = 0x02, + .regGainFineBase = 0x10, + .regGainFineStep = 1, + }, + { + .gainMax = 4032, + .idxBase = 32, + .regGain = 0x03, + .regGainFineBase = 0x10, + .regGainFineStep = 1, + }, + { + .gainMax = 5056, + .idxBase = 48, + .regGain = 0x04, + .regGainFineBase = 0x10, + .regGainFineStep = 1, + }, + { + .gainMax = 6080, + .idxBase = 64, + .regGain = 0x05, + .regGainFineBase = 0x10, + .regGainFineStep = 1, + }, + { + .gainMax = 7104, + .idxBase = 80, + .regGain = 0x06, + .regGainFineBase = 0x10, + .regGainFineStep = 1, + }, + { + .gainMax = 8128, + .idxBase = 96, + .regGain = 0x07, + .regGainFineBase = 0x10, + .regGainFineStep = 1, + }, + { + .gainMax = 9152, + .idxBase = 112, + .regGain = 0x08, + .regGainFineBase = 0x10, + .regGainFineStep = 1, + }, + { + .gainMax = 10176, + .idxBase = 128, + .regGain = 0x09, + .regGainFineBase = 0x10, + .regGainFineStep = 1, + }, + { + .gainMax = 11200, + .idxBase = 144, + .regGain = 0x0a, + .regGainFineBase = 0x10, + .regGainFineStep = 1, + }, + { + .gainMax = 12224, + .idxBase = 160, + .regGain = 0x0b, + .regGainFineBase = 0x10, + .regGainFineStep = 1, + }, + { + .gainMax = 13248, + .idxBase = 176, + .regGain = 0x0c, + .regGainFineBase = 0x10, + .regGainFineStep = 1, + }, + { + .gainMax = 14272, + .idxBase = 192, + .regGain = 0x0d, + .regGainFineBase = 0x10, + .regGainFineStep = 1, + }, + { + .gainMax = 15296, + .idxBase = 208, + .regGain = 0x0e, + .regGainFineBase = 0x10, + .regGainFineStep = 1, + }, + { + .gainMax = 16320, + .idxBase = 224, + .regGain = 0x0f, + .regGainFineBase = 0x10, + .regGainFineStep = 1, + }, +}; + + +static GK_VOID cmos_again_calc_table(VI_PIPE ViPipe, GK_U32 *pu32AgainLin, GK_U32 *pu32AgainDb) +{ + GK_U32 i; + static GK_U8 again_table_size = 63; + + CMOS_CHECK_POINTER_VOID(pu32AgainLin); + CMOS_CHECK_POINTER_VOID(pu32AgainDb); + + if (*pu32AgainLin >= u16AgainTab[again_table_size - 1]) { + *pu32AgainLin = u16AgainTab[again_table_size - 1]; + *pu32AgainDb = again_table_size - 1; + return; + } + + for (i = 1; i < again_table_size; i++) { + if (*pu32AgainLin < u16AgainTab[i]) { + *pu32AgainLin = u16AgainTab[i - 1]; + *pu32AgainDb = i - 1; + break; + } + } + return; +} + +static GK_VOID cmos_dgain_calc_table(VI_PIPE ViPipe, GK_U32 *pu32DgainLin, GK_U32 *pu32DgainDb) +{ + GK_U32 i; + static GK_U8 dgain_table_size = 255; + + CMOS_CHECK_POINTER_VOID(pu32DgainLin); + CMOS_CHECK_POINTER_VOID(pu32DgainDb); + + if (*pu32DgainLin >= Dgain_table[dgain_table_size - 1]) { + *pu32DgainLin = Dgain_table[dgain_table_size - 1]; + *pu32DgainDb = dgain_table_size - 1; + return; + } + + for (i = 1; i < dgain_table_size; i++) { + if (*pu32DgainLin < Dgain_table[i]) { + *pu32DgainLin = Dgain_table[i - 1]; + *pu32DgainDb = i - 1; + break; + } + } + return; +} + +static GK_VOID cmos_gains_update(VI_PIPE ViPipe, GK_U32 u32Again, GK_U32 u32Dgain) +{ + ISP_SNS_STATE_S *pstSnsState = GK_NULL; + struct gain_tbl_info_s *info; + int i, tbl_num; + + MIS2008_SENSOR_GET_CTX(ViPipe, pstSnsState); + CMOS_CHECK_POINTER_VOID(pstSnsState); + + pstSnsState->astRegsInfo[0].astI2cData[3].u32Data = (u32Again & 0x7F); + + /* find Dgain register setting. */ + tbl_num = sizeof(DgainInfo) / sizeof(struct gain_tbl_info_s); + for (i = tbl_num - 1; i >= 0; i--) { + info = &DgainInfo[i]; + + if (u32Dgain >= info->idxBase) + break; + } + + pstSnsState->astRegsInfo[0].astI2cData[4].u32Data = ((info->regGain & 0x0e) >> 1); + u32Dgain = info->regGainFineBase + (u32Dgain - info->idxBase) * info->regGainFineStep; + pstSnsState->astRegsInfo[0].astI2cData[5].u32Data = ((info->regGain & 0x01) << 7) | ((u32Dgain & 0x0F) << 3); + + return; +} + +static GK_VOID cmos_get_inttime_max(VI_PIPE ViPipe, GK_U16 u16ManRatioEnable, GK_U32 *au32Ratio, GK_U32 *au32IntTimeMax, + GK_U32 *au32IntTimeMin, GK_U32 *pu32LFMaxIntTime) +{ + GK_U32 u32ShortTimeMinLimit = 0; + GK_U32 u32ShortTimeMaxlimit = 0; + + ISP_SNS_STATE_S *pstSnsState = GK_NULL; + + CMOS_CHECK_POINTER_VOID(au32Ratio); + CMOS_CHECK_POINTER_VOID(au32IntTimeMax); + CMOS_CHECK_POINTER_VOID(au32IntTimeMin); + CMOS_CHECK_POINTER_VOID(pu32LFMaxIntTime); + MIS2008_SENSOR_GET_CTX(ViPipe, pstSnsState); + CMOS_CHECK_POINTER_VOID(pstSnsState); + u32ShortTimeMinLimit = 1; + + return; +} + +static GK_S32 cmos_init_ae_exp_function(AE_SENSOR_EXP_FUNC_S *pstExpFuncs) +{ + CMOS_CHECK_POINTER(pstExpFuncs); + + memset(pstExpFuncs, 0, sizeof(AE_SENSOR_EXP_FUNC_S)); + + pstExpFuncs->pfn_cmos_get_ae_default = cmos_get_ae_default; + pstExpFuncs->pfn_cmos_fps_set = cmos_fps_set; + // pstExpFuncs->pfn_cmos_slow_framerate_set = cmos_slow_framerate_set; + pstExpFuncs->pfn_cmos_inttime_update = cmos_inttime_update; + pstExpFuncs->pfn_cmos_gains_update = cmos_gains_update; + pstExpFuncs->pfn_cmos_again_calc_table = cmos_again_calc_table; + pstExpFuncs->pfn_cmos_dgain_calc_table = cmos_dgain_calc_table; + pstExpFuncs->pfn_cmos_get_inttime_max = cmos_get_inttime_max; + // pstExpFuncs->pfn_cmos_ae_fswdr_attr_set = cmos_ae_fswdr_attr_set; + + return GK_SUCCESS; +} + +/* Rgain and Bgain of the golden sample */ +#define GOLDEN_RGAIN 0 +#define GOLDEN_BGAIN 0 +static GK_S32 cmos_get_awb_default(VI_PIPE ViPipe, AWB_SENSOR_DEFAULT_S *pstAwbSnsDft) +{ + ISP_SNS_STATE_S *pstSnsState = GK_NULL; + + CMOS_CHECK_POINTER(pstAwbSnsDft); + MIS2008_SENSOR_GET_CTX(ViPipe, pstSnsState); + memset(pstAwbSnsDft, 0, sizeof(AWB_SENSOR_DEFAULT_S)); + + pstAwbSnsDft->u16InitGgain = 1024; + pstAwbSnsDft->u8AWBRunInterval = 1; + CMOS_CHECK_POINTER(pstSnsState); + + memset(pstAwbSnsDft, 0, sizeof(AWB_SENSOR_DEFAULT_S)); + pstAwbSnsDft->u16WbRefTemp = 5082; + + pstAwbSnsDft->au16GainOffset[0] = 404; + pstAwbSnsDft->au16GainOffset[1] = 256; + pstAwbSnsDft->au16GainOffset[2] = 256; + pstAwbSnsDft->au16GainOffset[3] = 509; + + pstAwbSnsDft->as32WbPara[0] = 12; + pstAwbSnsDft->as32WbPara[1] = 213; + pstAwbSnsDft->as32WbPara[2] = -30; + pstAwbSnsDft->as32WbPara[3] = 186383; + pstAwbSnsDft->as32WbPara[4] = 128; + pstAwbSnsDft->as32WbPara[5] = -131654; + pstAwbSnsDft->u16GoldenRgain = GOLDEN_RGAIN; + pstAwbSnsDft->u16GoldenBgain = GOLDEN_BGAIN; + + memcpy(&pstAwbSnsDft->stCcm, &g_stAwbCcm, sizeof(AWB_CCM_S)); + memcpy(&pstAwbSnsDft->stAgcTbl, &g_stAwbAgcTable, sizeof(AWB_AGC_TABLE_S)); + + pstAwbSnsDft->u16InitRgain = g_au16InitWBGain[ViPipe][0]; + pstAwbSnsDft->u16InitGgain = g_au16InitWBGain[ViPipe][1]; + pstAwbSnsDft->u16InitBgain = g_au16InitWBGain[ViPipe][2]; + pstAwbSnsDft->u16SampleRgain = g_au16SampleRgain[ViPipe]; + pstAwbSnsDft->u16SampleBgain = g_au16SampleBgain[ViPipe]; + + return GK_SUCCESS; +} + +static GK_S32 cmos_init_awb_exp_function(AWB_SENSOR_EXP_FUNC_S *pstExpFuncs) +{ + CMOS_CHECK_POINTER(pstExpFuncs); + + memset(pstExpFuncs, 0, sizeof(AWB_SENSOR_EXP_FUNC_S)); + pstExpFuncs->pfn_cmos_get_awb_default = cmos_get_awb_default; + + return GK_SUCCESS; +} + +static ISP_CMOS_DNG_COLORPARAM_S g_stDngColorParam = { { 378, 256, 430 }, { 439, 256, 439 } }; + +static GK_S32 cmos_get_isp_default(VI_PIPE ViPipe, ISP_CMOS_DEFAULT_S *pstDef) +{ + ISP_SNS_STATE_S *pstSnsState = GK_NULL; + + CMOS_CHECK_POINTER(pstDef); + MIS2008_SENSOR_GET_CTX(ViPipe, pstSnsState); + CMOS_CHECK_POINTER(pstSnsState); + + memset(pstDef, 0, sizeof(ISP_CMOS_DEFAULT_S)); + + pstDef->unKey.bit1Ca = 1; + pstDef->pstCa = &g_stIspCA; + pstDef->unKey.bit1Dpc = 1; + pstDef->pstDpc = &g_stCmosDpc; + pstDef->unKey.bit1Wdr = 0; + pstDef->pstWdr = &g_stIspWDR; + pstDef->unKey.bit1Lsc = 0; + pstDef->pstLsc = &g_stCmosLsc; + switch (pstSnsState->enWDRMode) { + default: + case WDR_MODE_NONE: + pstDef->unKey.bit1Demosaic = 1; + pstDef->pstDemosaic = &g_stIspDemosaic; + pstDef->unKey.bit1Sharpen = 1; + pstDef->pstSharpen = &g_stIspYuvSharpen; + pstDef->unKey.bit1Drc = 1; + pstDef->pstDrc = &g_stIspDRC; + pstDef->unKey.bit1BayerNr = 1; + pstDef->pstBayerNr = &g_stIspBayerNr; + pstDef->unKey.bit1Gamma = 1; + pstDef->pstGamma = &g_stIspGamma; +#ifdef CONFIG_ISP_CR_SUPPORT + pstDef->unKey.bit1Ge = 1; + pstDef->pstGe = &g_stIspGe; +#endif + pstDef->unKey.bit1AntiFalseColor = 1; + pstDef->pstAntiFalseColor = &g_stIspAntiFalseColor; + pstDef->unKey.bit1Ldci = 1; + pstDef->pstLdci = &g_stIspLdci; + pstDef->unKey.bit1Dehaze = 1; + pstDef->pstDehaze = &g_stIspDehaze; + pstDef->unKey.bit1Lcac = 1; + pstDef->pstLcac = &g_stIspLCac; + memcpy(&pstDef->stNoiseCalibration, &g_stIspNoiseCalibration, sizeof(ISP_CMOS_NOISE_CALIBRATION_S)); + break; + } + + pstDef->stSensorMode.u32SensorID = MIS2008_ID; + pstDef->stSensorMode.u8SensorMode = pstSnsState->u8ImgMode; + + memcpy(&pstDef->stDngColorParam, &g_stDngColorParam, sizeof(ISP_CMOS_DNG_COLORPARAM_S)); + + switch (pstSnsState->u8ImgMode) { + default: + case MIS2008_SENSOR_1080P_30FPS_LINEAR_MODE: + pstDef->stSensorMode.stDngRawFormat.u8BitsPerSample = 10; + pstDef->stSensorMode.stDngRawFormat.u32WhiteLevel = 1023; + break; + } + + pstDef->stSensorMode.stDngRawFormat.stDefaultScale.stDefaultScaleH.u32Denominator = 1; + pstDef->stSensorMode.stDngRawFormat.stDefaultScale.stDefaultScaleH.u32Numerator = 1; + pstDef->stSensorMode.stDngRawFormat.stDefaultScale.stDefaultScaleV.u32Denominator = 1; + pstDef->stSensorMode.stDngRawFormat.stDefaultScale.stDefaultScaleV.u32Numerator = 1; + pstDef->stSensorMode.stDngRawFormat.stCfaRepeatPatternDim.u16RepeatPatternDimRows = 2; + pstDef->stSensorMode.stDngRawFormat.stCfaRepeatPatternDim.u16RepeatPatternDimCols = 2; + pstDef->stSensorMode.stDngRawFormat.stBlcRepeatDim.u16BlcRepeatRows = 2; + pstDef->stSensorMode.stDngRawFormat.stBlcRepeatDim.u16BlcRepeatCols = 2; + pstDef->stSensorMode.stDngRawFormat.enCfaLayout = CFALAYOUT_TYPE_RECTANGULAR; + pstDef->stSensorMode.stDngRawFormat.au8CfaPlaneColor[0] = 0; + pstDef->stSensorMode.stDngRawFormat.au8CfaPlaneColor[1] = 1; + pstDef->stSensorMode.stDngRawFormat.au8CfaPlaneColor[2] = 2; + pstDef->stSensorMode.stDngRawFormat.au8CfaPattern[0] = 0; + pstDef->stSensorMode.stDngRawFormat.au8CfaPattern[1] = 1; + pstDef->stSensorMode.stDngRawFormat.au8CfaPattern[2] = 1; + pstDef->stSensorMode.stDngRawFormat.au8CfaPattern[3] = 2; + pstDef->stSensorMode.bValidDngRawFormat = GK_TRUE; + + return GK_SUCCESS; +} + +static GK_S32 cmos_get_isp_black_level(VI_PIPE ViPipe, ISP_CMOS_BLACK_LEVEL_S *pstBlackLevel) +{ + ISP_SNS_STATE_S *pstSnsState = GK_NULL; + + CMOS_CHECK_POINTER(pstBlackLevel); + MIS2008_SENSOR_GET_CTX(ViPipe, pstSnsState); + CMOS_CHECK_POINTER(pstSnsState); + + /* Don't need to update black level when iso change */ + pstBlackLevel->bUpdate = GK_FALSE; + + /* black level of linear mode */ + pstBlackLevel->au16BlackLevel[0] = 64; + pstBlackLevel->au16BlackLevel[1] = 64; + pstBlackLevel->au16BlackLevel[2] = 64; + pstBlackLevel->au16BlackLevel[3] = 64; + + return GK_SUCCESS; +} + +static GK_VOID cmos_set_pixel_detect(VI_PIPE ViPipe, GK_BOOL bEnable) +{ + GK_U32 u32FullLines_5Fps, u32MaxIntTime_5Fps; + ISP_SNS_STATE_S *pstSnsState = GK_NULL; + + MIS2008_SENSOR_GET_CTX(ViPipe, pstSnsState); + CMOS_CHECK_POINTER_VOID(pstSnsState); + + if (MIS2008_SENSOR_1080P_30FPS_LINEAR_MODE == pstSnsState->u8ImgMode) { + u32FullLines_5Fps = MIS2008_VMAX_1080P30_LINEAR * 30 / 5; + } else { + return; + } + + u32MaxIntTime_5Fps = u32FullLines_5Fps * 2 - EXP_OFFSET_LINEAR; + + if (bEnable) { /* setup for ISP pixel calibration mode */ + mis2008_write_register(ViPipe, MIS2008_VMAX_ADDR, HIGH_8BITS(u32FullLines_5Fps)); /* 5fps */ + mis2008_write_register(ViPipe, MIS2008_VMAX_ADDR + 1, LOW_8BITS(u32FullLines_5Fps)); /* 5fps */ + mis2008_write_register(ViPipe, MIS2008_EXP_ADDR, + HIGHER_4BITS(u32MaxIntTime_5Fps)); /* max exposure lines */ + mis2008_write_register(ViPipe, MIS2008_EXP_ADDR + 1, + HIGHER_8BITS(u32MaxIntTime_5Fps)); /* max exposure lines */ + // mis2008_write_register(ViPipe, MIS2008_EXP_ADDR + 2, + // LOWER_4BITS(u32MaxIntTime_5Fps)); /* max exposure lines */ + + mis2008_write_register(ViPipe, MIS2008_DGAIN_ADDR, 0x00); + mis2008_write_register(ViPipe, MIS2008_DGAIN_ADDR + 1, 0x80); + mis2008_write_register(ViPipe, MIS2008_AGAIN_ADDR, 0x00); + // mis2008_write_register(ViPipe, MIS2008_AGAIN_ADDR+1, 0x40); + } else { /* setup for ISP 'normal mode' */ + pstSnsState->u32FLStd = (pstSnsState->u32FLStd > MIS2008_FULL_LINES_MAX_LINEAR * 2) ? + (MIS2008_FULL_LINES_MAX_LINEAR * 2) : + pstSnsState->u32FLStd; + pstSnsState->au32FL[0] = pstSnsState->u32FLStd; + mis2008_write_register(ViPipe, MIS2008_VMAX_ADDR, HIGH_8BITS(pstSnsState->u32FLStd >> 1)); + mis2008_write_register(ViPipe, MIS2008_VMAX_ADDR + 1, LOW_8BITS(pstSnsState->u32FLStd >> 1)); + pstSnsState->bSyncInit = GK_FALSE; + } + + return; +} + +static GK_S32 cmos_get_sns_regs_info(VI_PIPE ViPipe, ISP_SNS_REGS_INFO_S *pstSnsRegsInfo) +{ + GK_S32 i; + ISP_SNS_STATE_S *pstSnsState = GK_NULL; + + CMOS_CHECK_POINTER(pstSnsRegsInfo); + MIS2008_SENSOR_GET_CTX(ViPipe, pstSnsState); + CMOS_CHECK_POINTER(pstSnsState); + + if ((pstSnsState->bSyncInit == GK_FALSE) || (pstSnsRegsInfo->bConfig == GK_FALSE)) { + pstSnsState->astRegsInfo[0].enSnsType = ISP_SNS_I2C_TYPE; + pstSnsState->astRegsInfo[0].unComBus.s8I2cDev = g_aunMis2008BusInfo[ViPipe].s8I2cDev; + pstSnsState->astRegsInfo[0].u8Cfg2ValidDelayMax = 2; + pstSnsState->astRegsInfo[0].u32RegNum = 8; + + for (i = 0; i < pstSnsState->astRegsInfo[0].u32RegNum; i++) { + pstSnsState->astRegsInfo[0].astI2cData[i].bUpdate = GK_TRUE; + pstSnsState->astRegsInfo[0].astI2cData[i].u8DevAddr = mis2008_i2c_addr; + pstSnsState->astRegsInfo[0].astI2cData[i].u32AddrByteNum = mis2008_addr_byte; + pstSnsState->astRegsInfo[0].astI2cData[i].u32DataByteNum = mis2008_data_byte; + } + + //Linear Mode Regs + pstSnsState->astRegsInfo[0].astI2cData[0].u8DelayFrmNum = 0; + pstSnsState->astRegsInfo[0].astI2cData[0].u32RegAddr = MIS2008_EXP_ADDR; + pstSnsState->astRegsInfo[0].astI2cData[1].u8DelayFrmNum = 0; + pstSnsState->astRegsInfo[0].astI2cData[1].u32RegAddr = MIS2008_EXP_ADDR + 1; + // pstSnsState->astRegsInfo[0].astI2cData[2].u8DelayFrmNum = 0; + // pstSnsState->astRegsInfo[0].astI2cData[2].u32RegAddr = MIS2008_EXP_ADDR + 2; + + pstSnsState->astRegsInfo[0].astI2cData[3].u8DelayFrmNum = 0; + pstSnsState->astRegsInfo[0].astI2cData[3].u32RegAddr = MIS2008_AGAIN_ADDR; + pstSnsState->astRegsInfo[0].astI2cData[4].u8DelayFrmNum = 0; + pstSnsState->astRegsInfo[0].astI2cData[4].u32RegAddr = MIS2008_DGAIN_ADDR; + pstSnsState->astRegsInfo[0].astI2cData[5].u8DelayFrmNum = 0; + pstSnsState->astRegsInfo[0].astI2cData[5].u32RegAddr = MIS2008_DGAIN_ADDR + 1; + + pstSnsState->astRegsInfo[0].astI2cData[6].u8DelayFrmNum = 0; + pstSnsState->astRegsInfo[0].astI2cData[6].u32RegAddr = MIS2008_VMAX_ADDR; + pstSnsState->astRegsInfo[0].astI2cData[7].u8DelayFrmNum = 0; + pstSnsState->astRegsInfo[0].astI2cData[7].u32RegAddr = MIS2008_VMAX_ADDR + 1; + pstSnsState->astRegsInfo[0].astI2cData[8].u8DelayFrmNum = 0; + pstSnsState->astRegsInfo[0].astI2cData[8].u32RegAddr = MIS2008_FLIP_MIRROR_ADDR; + pstSnsState->bSyncInit = GK_TRUE; + } else { + for (i = 0; i < pstSnsState->astRegsInfo[0].u32RegNum; i++) { + if (pstSnsState->astRegsInfo[0].astI2cData[i].u32Data == pstSnsState->astRegsInfo[1].astI2cData[i].u32Data) { + pstSnsState->astRegsInfo[0].astI2cData[i].bUpdate = GK_FALSE; + } else { + pstSnsState->astRegsInfo[0].astI2cData[i].bUpdate = GK_TRUE; + } + } + } + + pstSnsRegsInfo->bConfig = GK_FALSE; + memcpy(pstSnsRegsInfo, &pstSnsState->astRegsInfo[0], sizeof(ISP_SNS_REGS_INFO_S)); + memcpy(&pstSnsState->astRegsInfo[1], &pstSnsState->astRegsInfo[0], sizeof(ISP_SNS_REGS_INFO_S)); + + pstSnsState->au32FL[1] = pstSnsState->au32FL[0]; + + return GK_SUCCESS; +} + +static GK_S32 cmos_set_image_mode(VI_PIPE ViPipe, ISP_CMOS_SENSOR_IMAGE_MODE_S *pstSensorImageMode) +{ + GK_U8 u8SensorImageMode = 0; + ISP_SNS_STATE_S *pstSnsState = GK_NULL; + + CMOS_CHECK_POINTER(pstSensorImageMode); + MIS2008_SENSOR_GET_CTX(ViPipe, pstSnsState); + CMOS_CHECK_POINTER(pstSnsState); + + u8SensorImageMode = pstSnsState->u8ImgMode; + pstSnsState->bSyncInit = GK_FALSE; + + if (pstSensorImageMode->f32Fps <= 30) { + if (pstSnsState->enWDRMode == WDR_MODE_NONE) { + if (MIS2008_RES_IS_1080P(pstSensorImageMode->u16Width, pstSensorImageMode->u16Height)) { + u8SensorImageMode = MIS2008_SENSOR_1080P_30FPS_LINEAR_MODE; + // pstSnsState->u32FLStd = MIS2008_VMAX_1080P30_LINEAR * 2; + } else { + MIS2008_ERR_MODE_PRINT(pstSensorImageMode, pstSnsState); + return GK_FAILURE; + } + } else { + MIS2008_ERR_MODE_PRINT(pstSensorImageMode, pstSnsState); + return GK_FAILURE; + } + } else { + } + + if ((pstSnsState->bInit == GK_TRUE) && (u8SensorImageMode == pstSnsState->u8ImgMode)) { + /* Don't need to switch SensorImageMode */ + return ISP_DO_NOT_NEED_SWITCH_IMAGEMODE; + } + + pstSnsState->u8ImgMode = u8SensorImageMode; + + return GK_SUCCESS; +} + +static GK_VOID sensor_mirror_flip(VI_PIPE ViPipe, ISP_SNS_MIRRORFLIP_TYPE_E eSnsMirrorFlip) +{ + ISP_SNS_STATE_S *pstSnsState = GK_NULL; + MIS2008_SENSOR_GET_CTX(ViPipe, pstSnsState); + CMOS_CHECK_POINTER_VOID(pstSnsState); + GK_U8 FRAME_H_ST, FRAME_H_END; + GK_U8 FRAME_W_ST, FRAME_W_END; + GK_U8 value = 0; + switch (eSnsMirrorFlip) { + case ISP_SNS_NORMAL: + value |= 0; + FRAME_H_ST = 4; + FRAME_H_END = 0x3f; + FRAME_W_ST = 8; + FRAME_W_END = 0x88; + break; + case ISP_SNS_MIRROR: + value |= 0x01; + FRAME_H_ST = 4; + FRAME_H_END = 0x3f; + FRAME_W_ST = 0xa; + FRAME_W_END = 0x89; + break; + case ISP_SNS_FLIP: + value |= 0x02; + FRAME_H_ST = 5; + FRAME_H_END = 0x40; + FRAME_W_ST = 8; + FRAME_W_END = 0x88; + break; + case ISP_SNS_MIRROR_FLIP: + value |= 0x03; + FRAME_H_ST = 5; + FRAME_H_END = 0x40; + FRAME_W_ST = 0xa; + FRAME_W_END = 0x89; + break; + default: + return; + } + + mis2008_write_register(ViPipe, 0x3205, FRAME_H_ST); + mis2008_write_register(ViPipe, 0x3207, FRAME_H_END); + mis2008_write_register(ViPipe, 0x3209, FRAME_W_ST); + mis2008_write_register(ViPipe, 0x320b, FRAME_W_END); + mis2008_write_register(ViPipe, MIS2008_FLIP_MIRROR_ADDR, value); +} + +static GK_VOID sensor_global_init(VI_PIPE ViPipe) +{ + ISP_SNS_STATE_S *pstSnsState = GK_NULL; + + MIS2008_SENSOR_GET_CTX(ViPipe, pstSnsState); + CMOS_CHECK_POINTER_VOID(pstSnsState); + + pstSnsState->bInit = GK_FALSE; + pstSnsState->bSyncInit = GK_FALSE; + pstSnsState->u8ImgMode = MIS2008_SENSOR_1080P_30FPS_LINEAR_MODE; + pstSnsState->enWDRMode = WDR_MODE_NONE; + pstSnsState->u32FLStd = MIS2008_VMAX_1080P30_LINEAR; + pstSnsState->au32FL[0] = MIS2008_VMAX_1080P30_LINEAR; + pstSnsState->au32FL[1] = MIS2008_VMAX_1080P30_LINEAR; + + memset(&pstSnsState->astRegsInfo[0], 0, sizeof(ISP_SNS_REGS_INFO_S)); + memset(&pstSnsState->astRegsInfo[1], 0, sizeof(ISP_SNS_REGS_INFO_S)); + + pstSnsState->astRegsInfo[0].astI2cData[0].u32Data = 0x05; + pstSnsState->astRegsInfo[0].astI2cData[1].u32Data = 0x45; + +} + +static GK_S32 cmos_init_sensor_exp_function(ISP_SENSOR_EXP_FUNC_S *pstSensorExpFunc) +{ + CMOS_CHECK_POINTER(pstSensorExpFunc); + + memset(pstSensorExpFunc, 0, sizeof(ISP_SENSOR_EXP_FUNC_S)); + + pstSensorExpFunc->pfn_cmos_sensor_init = mis2008_init; + pstSensorExpFunc->pfn_cmos_sensor_exit = mis2008_exit; + pstSensorExpFunc->pfn_cmos_sensor_global_init = sensor_global_init; + pstSensorExpFunc->pfn_cmos_set_image_mode = cmos_set_image_mode; + // pstSensorExpFunc->pfn_cmos_set_wdr_mode = cmos_set_wdr_mode; + + pstSensorExpFunc->pfn_cmos_get_isp_default = cmos_get_isp_default; + pstSensorExpFunc->pfn_cmos_get_isp_black_level = cmos_get_isp_black_level; + pstSensorExpFunc->pfn_cmos_set_pixel_detect = cmos_set_pixel_detect; + pstSensorExpFunc->pfn_cmos_get_sns_reg_info = cmos_get_sns_regs_info; + + return GK_SUCCESS; +} + +static GK_S32 sensor_set_bus_info(VI_PIPE ViPipe, ISP_SNS_COMMBUS_U unSNSBusInfo) +{ + g_aunMis2008BusInfo[ViPipe].s8I2cDev = unSNSBusInfo.s8I2cDev; + + return GK_SUCCESS; +} + +static GK_S32 sensor_ctx_init(VI_PIPE ViPipe) +{ + ISP_SNS_STATE_S *pastSnsStateCtx = GK_NULL; + + MIS2008_SENSOR_GET_CTX(ViPipe, pastSnsStateCtx); + + if (pastSnsStateCtx == GK_NULL) { + pastSnsStateCtx = (ISP_SNS_STATE_S *)malloc(sizeof(ISP_SNS_STATE_S)); + if (pastSnsStateCtx == GK_NULL) { + ISP_TRACE(MODULE_DBG_ERR, "Isp[%d] SnsCtx malloc memory failed!\n", ViPipe); + return ERR_CODE_ISP_NOMEM; + } + } + + memset(pastSnsStateCtx, 0, sizeof(ISP_SNS_STATE_S)); + + MIS2008_SENSOR_SET_CTX(ViPipe, pastSnsStateCtx); + + return GK_SUCCESS; +} + +static GK_VOID sensor_ctx_exit(VI_PIPE ViPipe) +{ + ISP_SNS_STATE_S *pastSnsStateCtx = GK_NULL; + + MIS2008_SENSOR_GET_CTX(ViPipe, pastSnsStateCtx); + SENSOR_FREE(pastSnsStateCtx); + MIS2008_SENSOR_RESET_CTX(ViPipe); + return; +} + +static GK_S32 sensor_register_callback(VI_PIPE ViPipe, ALG_LIB_S *pstAeLib, ALG_LIB_S *pstAwbLib) +{ + GK_S32 s32Ret; + + ISP_SENSOR_REGISTER_S stIspRegister; + AE_SENSOR_REGISTER_S stAeRegister; + AWB_SENSOR_REGISTER_S stAwbRegister; + ISP_SNS_ATTR_INFO_S stSnsAttrInfo; + + CMOS_CHECK_POINTER(pstAeLib); + CMOS_CHECK_POINTER(pstAwbLib); + + s32Ret = sensor_ctx_init(ViPipe); + if (s32Ret != GK_SUCCESS) { + return GK_FAILURE; + } + + stSnsAttrInfo.eSensorId = MIS2008_ID; + s32Ret = cmos_init_sensor_exp_function(&stIspRegister.stSnsExp); + s32Ret |= GK_API_ISP_SensorRegCallBack(ViPipe, &stSnsAttrInfo, &stIspRegister); + if (s32Ret != GK_SUCCESS) { + ISP_TRACE(MODULE_DBG_ERR, "sensor register callback function failed!\n"); + return s32Ret; + } + + s32Ret = cmos_init_ae_exp_function(&stAeRegister.stSnsExp); + s32Ret |= GK_API_AE_SensorRegCallBack(ViPipe, pstAeLib, &stSnsAttrInfo, &stAeRegister); + if (s32Ret != GK_SUCCESS) { + ISP_TRACE(MODULE_DBG_ERR, "sensor register callback function to ae lib failed!\n"); + return s32Ret; + } + + s32Ret = cmos_init_awb_exp_function(&stAwbRegister.stSnsExp); + s32Ret |= GK_API_AWB_SensorRegCallBack(ViPipe, pstAwbLib, &stSnsAttrInfo, &stAwbRegister); + if (s32Ret != GK_SUCCESS) { + ISP_TRACE(MODULE_DBG_ERR, "sensor register callback function to awb lib failed!\n"); + return s32Ret; + } + + return GK_SUCCESS; +} + +static GK_S32 sensor_unregister_callback(VI_PIPE ViPipe, ALG_LIB_S *pstAeLib, ALG_LIB_S *pstAwbLib) +{ + GK_S32 s32Ret; + + CMOS_CHECK_POINTER(pstAeLib); + CMOS_CHECK_POINTER(pstAwbLib); + + s32Ret = GK_API_ISP_SensorUnRegCallBack(ViPipe, MIS2008_ID); + if (s32Ret != GK_SUCCESS) { + ISP_TRACE(MODULE_DBG_ERR, "sensor unregister callback function failed!\n"); + return s32Ret; + } + + s32Ret = GK_API_AE_SensorUnRegCallBack(ViPipe, pstAeLib, MIS2008_ID); + if (s32Ret != GK_SUCCESS) { + ISP_TRACE(MODULE_DBG_ERR, "sensor unregister callback function to ae lib failed!\n"); + return s32Ret; + } + + s32Ret = GK_API_AWB_SensorUnRegCallBack(ViPipe, pstAwbLib, MIS2008_ID); + if (s32Ret != GK_SUCCESS) { + ISP_TRACE(MODULE_DBG_ERR, "sensor unregister callback function to awb lib failed!\n"); + return s32Ret; + } + + sensor_ctx_exit(ViPipe); + + return GK_SUCCESS; +} + +static GK_S32 sensor_set_init(VI_PIPE ViPipe, ISP_INIT_ATTR_S *pstInitAttr) +{ + CMOS_CHECK_POINTER(pstInitAttr); + + g_au32InitExposure[ViPipe] = pstInitAttr->u32Exposure; + g_au32LinesPer500ms[ViPipe] = pstInitAttr->u32LinesPer500ms; + g_au16InitWBGain[ViPipe][0] = pstInitAttr->u16WBRgain; + g_au16InitWBGain[ViPipe][1] = pstInitAttr->u16WBGgain; + g_au16InitWBGain[ViPipe][2] = pstInitAttr->u16WBBgain; + g_au16SampleRgain[ViPipe] = pstInitAttr->u16SampleRgain; + g_au16SampleBgain[ViPipe] = pstInitAttr->u16SampleBgain; + + return GK_SUCCESS; +} + +ISP_SNS_OBJ_S stSnsMis2008Obj = { .pfnRegisterCallback = sensor_register_callback, + .pfnUnRegisterCallback = sensor_unregister_callback, + .pfnStandby = mis2008_standby, + .pfnRestart = mis2008_restart, + .pfnMirrorFlip = sensor_mirror_flip, + .pfnWriteReg = mis2008_write_register, + .pfnReadReg = mis2008_read_register, + .pfnSetBusInfo = sensor_set_bus_info, + .pfnSetInit = sensor_set_init }; + +#ifdef __cplusplus +#if __cplusplus +} +#endif + +#endif /* End of #ifdef __cplusplus */ diff --git a/libraries/sensor/hi3516ev200/imagedesign_mis2008/mis2008_cmos_ex.h b/libraries/sensor/hi3516ev200/imagedesign_mis2008/mis2008_cmos_ex.h new file mode 100644 index 0000000..17c0716 --- /dev/null +++ b/libraries/sensor/hi3516ev200/imagedesign_mis2008/mis2008_cmos_ex.h @@ -0,0 +1,910 @@ +/* + * (c) OpenIPC.org (c) +*/ + +#ifndef __MIS2008_CMOS_EX_H_ +#define __MIS2008_CMOS_EX_H_ + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif +#endif + +static const ISP_CMOS_LCAC_S g_stIspLCac = { + + /*bEnable*/ + 1, + /*u16PurpleDetRange*/ + 30, + /*VarThr*/ + 0, + /*au16RLumaThd*/ + { 1500, 1500, 0 }, + /*au16GLumaThd*/ + { 1500, 1500, 0 }, + /*au16BLumaThd*/ + { 4095, 1500, 0 }, + /*au16YLumaThd*/ + { 3200, 1500, 0 }, + /*as16CbCrRatio*/ + { -50, -50, -50 }, + /*enOpMode*/ + 0, + /*stManual*/ + { //u8DePurpleCrStr + 0, + //u8DePurpleCbStr + 3 }, + /*stAuto*/ + { //u8DePurpleCrStr + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + //u8DePurpleCbStr + { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 } } +}; + +static const ISP_CMOS_DPC_S g_stCmosDpc = { + /* ISO */ + /* 100, 200, 400, 800, 1600, 3200, 6400, 12800, 25600, 51200, 102400, 204800, 409600, 819200, 1638400, 3276800 */ + { 130, 150, 150, 200, 230, 240, 240, 240, 240, 240, 152, 152, 152, 152, 152, 152 }, /* au16Strength[16] */ + { 24, 24, 32, 32, 32, 32, 36, 36, 36, 40, 50, 50, 50, 50, 50, 50 }, /* au16BlendRatio[16] */ + 0, /* 0 for after drc, 1 for before wdr */ +}; + +static const ISP_CMOS_GE_S g_stIspGe = { + /* For GE */ + 1, /* bEnable */ + 13, /* u8Slope */ + 13, /* u8SensiSlope */ + 4800, /* u16SensiThr */ + /* ISO */ + /* 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768 */ + { 4800, 4800, 4800, 4800, 4960, 4960, 4960, 4960, 5120, 5120, 5120, 5120, 5280, 5280, 5280, + 5280 }, /* au16Threshold[ISP_AUTO_ISO_STRENGTH_NUM] */ + { 128, 128, 128, 128, 129, 129, 129, 129, 130, 130, 130, 130, 131, 131, 131, + 131 }, /* au16Strength[ISP_AUTO_ISO_STRENGTH_NUM] */ + { 16384, 16384, 16384, 16384, 16384, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, + 32768 } /* au16NpOffset[ISP_AUTO_ISO_STRENGTH_NUM] */ +}; + +static const ISP_CMOS_DEMOSAIC_S g_stIspDemosaic = { + 1, // bEnable + /* au8NonDirStr */ + /* 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768 */ + { 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 }, + /* au8NonDirLFDetailEhc */ + { 110, 100, 40, 28, 28, 28, 24, 22, 20, 18, 18, 18, 18, 18, 18, 18 }, + /* au8NonDirHFDetailEhc */ + { 3, 3, 3, 5, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 }, + /* au8DetailSmoothRange */ + { 1, 2, 2, 3, 3, 3, 4, 4, 5, 5, 7, 7, 7, 7, 7, 7 }, +}; + +static const ISP_CMOS_ANTIFALSECOLOR_S g_stIspAntiFalseColor = { + 1, /* bEnable */ + /* 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768 */ + { 10, 10, 8, 8, 7, 7, 7, 6, 6, 6, 5, 4, 3, 2, 1, 0 }, /*au8AntiFalseColorThreshold*/ + { 8, 8, 8, 8, 7, 7, 7, 6, 6, 6, 5, 4, 3, 2, 1, 0 }, /*au8AntiFalseColorStrength*/ +}; + +/***BAYER NR**/ +static ISP_CMOS_NOISE_CALIBRATION_S g_stIspNoiseCalibration = { + 5, //Calibration Lut Num + /*************Calibration LUT Table*************/ + { { 100.000000f, 0.060231f, 0.233816f }, + { 200.000000f, 0.113017f, 0.449750f }, + { 400.000000f, 0.212748f, 0.937471f }, + { 800.000000f, 0.354252f, 2.216004f }, + { 1600.000000f, 0.657290f, 4.290183f } } + /*********************************************/ +}; + +static const ISP_CMOS_BAYERNR_S g_stIspBayerNr = { + 1, // bEnable + 0, // bBnrMonoSensorEn + 0, // bNrLscEnable + 96, // u8BnrLscMaxGain + 256, // u16BnrLscCmpStrength + { 86, 80, 80, 70, 70, 65, 65, 60, 50, 50, 50, 50, 50, 50, 40, 40 }, //FineStr + { + { 1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3 }, // ChromaStrR + { 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2 }, // ChromaStrGr + { 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2 }, // ChromaStrGb + { 1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3 } // ChromaStrB + }, + { 0, 0, 0, 0 }, // WDRFrameStr + { 0, 0, 0, 0 }, // FusionFrameStr + { + { 80, 100, 110, 110, 110, 120, 130, 150, 160, 170, 170, 170, 170, 170, 170, 170 }, //CoarseStrR + { 80, 100, 110, 110, 110, 120, 130, 150, 160, 170, 170, 170, 170, 170, 170, 170 }, //CoarseStrGR + { 80, 100, 110, 110, 110, 120, 130, 150, 160, 170, 170, 170, 170, 170, 170, 170 }, //CoarseStrGB + { 80, 100, 110, 110, 110, 120, 130, 150, 160, 170, 170, 170, 170, 170, 170, 170 } //CoarseStrB + }, + { 50, 50, 60, 65, 70, 75, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60 }, //lutCoringWeight + { 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 91, + 92, 93, 94, 95, 96, 97, 98, 99, 100, 100, 100, 100, 100, 100, 100, 100 }, // CoringRatio +}; + +static const ISP_CMOS_LDCI_S g_stIspLdci = { + /* bEnable */ + 1, + /* u8GaussLPFSigma */ + 36, + + /* 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768 */ + /* au8HePosWgt */ + { 50, 50, 50, 56, 64, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + + /* au8HePosSigma */ + { 80, 72, 64, 56, 48, 32, 24, 20, 12, 8, 6, 2, 1, 1, 1, 1 }, + + /* au8HePosMean */ + { 0, 0, 40, 40, 40, 50, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60 }, + + /* au8HeNegWgt */ + { 50, 45, 45, 45, 45, 40, 40, 30, 20, 10, 0, 0, 0, 0, 0, 0 }, + + /* au8HeNegSigma */ + { 80, 80, 80, 80, 80, 72, 64, 54, 36, 8, 6, 2, 1, 1, 1, 1 }, + + /* au8HeNegMean */ + { 128, 128, 50, 60, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70 }, + + /* au16BlcCtrl */ + { 20, 20, 20, 20, 20, 20, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30 } +}; + +static const ISP_CMOS_GAMMA_S g_stIspGamma = { + /* au16Gamma[GAMMA_EXT_NODE_NUMBER] */ + { 0, 19, 38, 58, 77, 97, 117, 137, 156, 176, 195, 215, 234, 253, 272, 290, 308, 326, + 344, 364, 383, 401, 419, 436, 453, 470, 487, 504, 521, 539, 557, 576, 596, 617, 627, 637, + 648, 658, 669, 679, 690, 701, 712, 723, 734, 745, 757, 768, 779, 791, 803, 815, 827, 839, + 851, 863, 876, 888, 901, 914, 927, 940, 953, 967, 981, 987, 994, 1001, 1008, 1015, 1022, 1029, + 1036, 1043, 1051, 1058, 1066, 1073, 1081, 1088, 1096, 1104, 1111, 1119, 1127, 1135, 1143, 1150, 1158, 1166, + 1174, 1182, 1190, 1198, 1206, 1214, 1222, 1230, 1238, 1246, 1254, 1262, 1270, 1278, 1286, 1294, 1302, 1310, + 1318, 1326, 1334, 1341, 1349, 1357, 1365, 1372, 1380, 1387, 1395, 1402, 1409, 1417, 1424, 1431, 1438, 1445, + 1452, 1459, 1466, 1472, 1479, 1485, 1492, 1499, 1505, 1511, 1518, 1524, 1531, 1537, 1543, 1549, 1556, 1562, + 1568, 1574, 1580, 1586, 1592, 1598, 1604, 1610, 1616, 1622, 1628, 1634, 1639, 1645, 1651, 1657, 1663, 1668, + 1674, 1680, 1685, 1691, 1697, 1702, 1708, 1713, 1719, 1724, 1730, 1736, 1741, 1747, 1752, 1758, 1763, 1769, + 1774, 1780, 1785, 1790, 1796, 1801, 1807, 1812, 1818, 1823, 1829, 1834, 1840, 1845, 1850, 1856, 1861, 1867, + 1872, 1877, 1883, 1888, 1893, 1899, 1904, 1909, 1915, 1920, 1925, 1930, 1936, 1941, 1946, 1951, 1957, 1962, + 1967, 1972, 1977, 1982, 1988, 1993, 1998, 2003, 2008, 2013, 2018, 2023, 2028, 2033, 2038, 2043, 2048, 2053, + 2058, 2063, 2068, 2073, 2078, 2082, 2087, 2092, 2097, 2102, 2107, 2111, 2116, 2121, 2126, 2131, 2135, 2140, + 2145, 2149, 2154, 2159, 2164, 2168, 2173, 2177, 2182, 2187, 2191, 2196, 2200, 2205, 2210, 2214, 2219, 2223, + 2228, 2232, 2237, 2241, 2246, 2250, 2254, 2259, 2263, 2268, 2272, 2276, 2281, 2285, 2289, 2294, 2298, 2302, + 2307, 2311, 2315, 2319, 2324, 2328, 2332, 2336, 2340, 2344, 2349, 2353, 2357, 2361, 2365, 2369, 2373, 2377, + 2381, 2385, 2389, 2393, 2397, 2401, 2405, 2409, 2413, 2416, 2420, 2424, 2428, 2432, 2436, 2439, 2443, 2447, + 2450, 2454, 2458, 2461, 2465, 2468, 2472, 2475, 2479, 2482, 2486, 2489, 2493, 2496, 2500, 2503, 2506, 2510, + 2513, 2516, 2520, 2523, 2526, 2529, 2533, 2536, 2539, 2542, 2546, 2549, 2552, 2555, 2558, 2561, 2565, 2568, + 2571, 2574, 2577, 2580, 2583, 2586, 2590, 2593, 2596, 2599, 2602, 2605, 2608, 2611, 2614, 2617, 2621, 2624, + 2627, 2630, 2633, 2636, 2639, 2642, 2646, 2649, 2652, 2656, 2659, 2662, 2665, 2668, 2671, 2674, 2677, 2680, + 2683, 2686, 2690, 2693, 2696, 2699, 2702, 2705, 2708, 2711, 2714, 2717, 2720, 2723, 2726, 2729, 2732, 2735, + 2738, 2741, 2744, 2747, 2750, 2753, 2756, 2759, 2762, 2764, 2767, 2770, 2773, 2776, 2779, 2782, 2785, 2788, + 2791, 2794, 2796, 2799, 2802, 2805, 2808, 2811, 2814, 2817, 2820, 2822, 2825, 2828, 2831, 2834, 2837, 2840, + 2843, 2845, 2848, 2851, 2853, 2856, 2859, 2862, 2865, 2868, 2871, 2874, 2877, 2879, 2882, 2885, 2887, 2890, + 2893, 2896, 2899, 2901, 2904, 2907, 2909, 2912, 2915, 2918, 2920, 2923, 2926, 2929, 2932, 2934, 2937, 2940, + 2942, 2945, 2948, 2951, 2954, 2956, 2959, 2962, 2964, 2966, 2969, 2972, 2974, 2977, 2980, 2983, 2986, 2988, + 2991, 2994, 2996, 2998, 3001, 3004, 3006, 3009, 3012, 3015, 3018, 3020, 3023, 3026, 3028, 3031, 3033, 3035, + 3038, 3040, 3043, 3046, 3048, 3051, 3054, 3057, 3059, 3062, 3064, 3066, 3069, 3071, 3074, 3077, 3080, 3082, + 3085, 3088, 3090, 3093, 3095, 3097, 3100, 3102, 3105, 3108, 3110, 3113, 3115, 3117, 3120, 3122, 3125, 3128, + 3130, 3133, 3135, 3138, 3140, 3143, 3145, 3147, 3150, 3152, 3155, 3158, 3160, 3163, 3165, 3167, 3170, 3172, + 3175, 3178, 3180, 3183, 3185, 3187, 3189, 3192, 3194, 3196, 3199, 3201, 3204, 3207, 3209, 3211, 3214, 3217, + 3219, 3222, 3224, 3226, 3228, 3231, 3233, 3235, 3238, 3241, 3243, 3245, 3247, 3250, 3252, 3254, 3257, 3260, + 3262, 3264, 3267, 3269, 3271, 3273, 3276, 3279, 3281, 3283, 3286, 3288, 3290, 3292, 3295, 3298, 3300, 3302, + 3305, 3307, 3309, 3311, 3313, 3316, 3318, 3320, 3322, 3325, 3327, 3329, 3332, 3335, 3337, 3339, 3342, 3344, + 3346, 3348, 3350, 3353, 3355, 3357, 3360, 3362, 3364, 3366, 3368, 3371, 3373, 3375, 3378, 3380, 3382, 3384, + 3386, 3389, 3391, 3393, 3396, 3398, 3400, 3402, 3405, 3407, 3409, 3411, 3413, 3416, 3418, 3420, 3423, 3425, + 3427, 3429, 3431, 3434, 3436, 3438, 3441, 3443, 3445, 3447, 3449, 3452, 3454, 3456, 3459, 3461, 3463, 3465, + 3467, 3469, 3471, 3473, 3475, 3478, 3480, 3482, 3484, 3487, 3489, 3491, 3494, 3496, 3498, 3500, 3502, 3504, + 3506, 3508, 3511, 3513, 3515, 3517, 3519, 3521, 3523, 3525, 3528, 3530, 3532, 3534, 3536, 3538, 3540, 3542, + 3545, 3547, 3549, 3551, 3553, 3555, 3557, 3559, 3561, 3564, 3566, 3568, 3570, 3572, 3574, 3576, 3578, 3581, + 3583, 3585, 3587, 3589, 3591, 3593, 3595, 3598, 3600, 3602, 3604, 3606, 3608, 3610, 3612, 3614, 3616, 3618, + 3620, 3622, 3624, 3626, 3628, 3631, 3633, 3635, 3637, 3639, 3641, 3643, 3645, 3647, 3649, 3651, 3653, 3655, + 3657, 3659, 3661, 3663, 3665, 3667, 3670, 3672, 3674, 3676, 3678, 3680, 3682, 3684, 3686, 3688, 3690, 3692, + 3694, 3696, 3698, 3700, 3702, 3704, 3706, 3708, 3710, 3712, 3714, 3716, 3718, 3720, 3722, 3724, 3726, 3728, + 3730, 3732, 3734, 3736, 3738, 3740, 3742, 3744, 3746, 3748, 3750, 3752, 3754, 3756, 3758, 3760, 3762, 3764, + 3766, 3767, 3769, 3771, 3773, 3775, 3777, 3779, 3781, 3783, 3785, 3787, 3789, 3791, 3793, 3795, 3797, 3799, + 3801, 3803, 3804, 3806, 3808, 3810, 3812, 3814, 3816, 3818, 3820, 3822, 3824, 3826, 3828, 3830, 3832, 3834, + 3836, 3837, 3839, 3841, 3843, 3845, 3847, 3849, 3851, 3853, 3855, 3857, 3858, 3860, 3862, 3864, 3866, 3868, + 3870, 3872, 3873, 3875, 3877, 3879, 3881, 3883, 3885, 3887, 3888, 3890, 3892, 3894, 3896, 3898, 3900, 3902, + 3904, 3905, 3907, 3909, 3911, 3913, 3915, 3917, 3919, 3920, 3922, 3924, 3926, 3928, 3930, 3932, 3934, 3935, + 3937, 3939, 3941, 3943, 3945, 3947, 3949, 3950, 3952, 3954, 3955, 3957, 3959, 3961, 3963, 3965, 3967, 3969, + 3971, 3972, 3974, 3976, 3977, 3979, 3981, 3983, 3985, 3987, 3989, 3991, 3993, 3994, 3996, 3998, 4000, 4001, + 4003, 4005, 4006, 4008, 4010, 4012, 4014, 4016, 4018, 4020, 4022, 4023, 4025, 4027, 4028, 4030, 4032, 4034, + 4036, 4037, 4039, 4041, 4042, 4044, 4046, 4048, 4050, 4052, 4054, 4056, 4058, 4059, 4061, 4063, 4064, 4066, + 4068, 4070, 4072, 4073, 4075, 4077, 4078, 4080, 4082, 4084, 4086, 4087, 4089, 4091, 4092, 4094, 4095 } +}; + +static const ISP_CMOS_PREGAMMA_S g_stPreGamma = { + 0, + { 3821, 7131, 9741, 11691, 13307, 14713, 15971, 17118, 18179, 20099, 21818, 23385, 24833, + 26185, 27456, 28659, 29804, 30897, 31945, 32952, 33923, 35770, 37506, 39150, 40713, 42207, + 43638, 45014, 46340, 47622, 48863, 50066, 51235, 52373, 53481, 54561, 55616, 57656, 59611, + 61491, 63303, 65054, 66749, 68393, 69990, 71543, 73057, 74533, 75974, 77383, 78761, 80110, + 81432, 83999, 86475, 88866, 91182, 93428, 95609, 97731, 99799, 101815, 103784, 105708, 107590, + 109433, 111239, 113010, 114747, 118128, 121395, 124558, 127626, 130606, 133505, 136330, 139084, 141773, + 144402, 146973, 149491, 151957, 154376, 156749, 159079, 161368, 163618, 165831, 168008, 170152, 172263, + 174342, 176392, 178413, 180407, 182374, 184315, 186232, 188125, 189995, 191842, 193668, 197259, 200771, + 204210, 207580, 210884, 214126, 217308, 220435, 223509, 226532, 229506, 232434, 235318, 238159, 240959, + 243720, 246443, 249130, 251782, 254400, 256986, 259540, 262064, 264559, 267025, 269464, 271876, 274262, + 276623, 278960, 281273, 283562, 288076, 292504, 296852, 301124, 305323, 309452, 313515, 317515, 321454, + 325335, 329160, 332931, 336651, 340322, 343945, 347521, 351054, 354543, 357991, 361399, 364767, 368099, + 371394, 374653, 377878, 381070, 384230, 387358, 390456, 393523, 396562, 399573, 405512, 411348, 417083, + 422724, 428274, 433738, 439119, 444420, 449646, 454798, 459880, 464894, 469842, 474728, 479554, 484320, + 489030, 493685, 498287, 502838, 507339, 511791, 516197, 520557, 524874, 529147, 533378, 537569, 541720, + 545833, 549908, 553946, 557949, 561917, 565852, 569753, 577458, 585040, 592504, 599854, 607096, 614234, + 621272, 628214, 635064, 641824, 648498, 655090, 661601, 668035, 674394, 680681, 686897, 693045, 699128, + 705146, 711103, 716999, 722836, 728616, 734341, 740012, 745630, 751197, 756713, 762181, 767602, 778305, + 788831, 799189, 809384, 819425, 829318, 839069, 848683, 858166, 867523, 876757, 885875, 894879, 903774, + 912563, 921249, 938329, 955037, 971395, 987423, 1003139, 1018560, 1033701, 1048575 } +}; + +static const ISP_CMOS_SHARPEN_S g_stIspYuvSharpen = { + /* u8SkinUmin */ + 110, + /* u8SkinVmin */ + 128, + /* u8SkinUmax */ + 128, + /* u8SkinVmax */ + 149, + + /* Manual Para */ + { /* au8LumaWgt */ + { 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, + 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31 }, + /* u16TextureStr */ + { 250, 420, 390, 390, 390, 390, 390, 370, 350, 330, 310, 290, 270, 270, 270, 270, + 270, 270, 266, 260, 244, 230, 230, 230, 230, 230, 230, 210, 190, 190, 170, 150 }, + /* u16EdgeStr */ + { 120, 123, 125, 128, 130, 135, 140, 148, 160, 168, 180, 190, 200, 210, 210, 210, + 210, 210, 200, 190, 185, 175, 165, 160, 146, 136, 130, 128, 125, 123, 120, 120 }, + /* u16TextureFreq; */ + 160, + /* u16EdgeFreq; */ + 100, + /* u8OverShoot; */ + 55, + /* u8UnderShoot; */ + 70, + /* u8shootSupStr; */ + 10, + /* u8shootSupAdj; */ + 9, + /* u8DetailCtrl; */ + 128, + /* u8DetailCtrlThr; */ + 180, + /* u8EdgeFiltStr; */ + 60, + /*u8EdgeFiltMaxCap; */ + 18, + /* u8RGain; */ + 28, + /* u8GGain; */ + 32, + /* u8BGain; */ + 31, + /* u8SkinGain; */ + 23, + /* u8MaxSharpGain; */ + 67, + /* u8WeakDetailGain */ + 6 + + }, + /* Auto Para */ + { /* au16LumaWgt */ + /* ISO */ + /* 100, 200, 400, 800, 1600, 3200, 6400, 12800, 25600, 51200, 102400, 204800, 409600, 819200,1638400,3276800 */ + { { 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 1, 1, 1 }, + { 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 2, 2, 2 }, + { 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 4, 4, 4 }, + { 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 5, 5, 5 }, + { 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 7, 7, 7 }, + { 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 8, 8, 8 }, + { 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 9, 9, 9 }, + { 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 10, 10, 10 }, + { 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 12, 12, 12 }, + { 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 13, 13, 13 }, + { 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 14, 14, 14 }, + { 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 15, 15, 15 }, + { 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 17, 17, 17 }, + { 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 18, 18, 18 }, + { 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 19, 19, 19 }, + { 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 20, 20, 20 }, + { 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 22, 22, 22 }, + { 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 23, 23, 23 }, + { 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 24, 24, 24 }, + { 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 26, 26, 26 }, + { 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 26, 26, 26 }, + { 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 26, 26, 26 }, + { 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 26, 26, 26 }, + { 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 27, 27, 27 }, + { 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 27, 27, 27 }, + { 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 27, 27, 27 }, + { 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 27, 27, 27 }, + { 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 28, 28, 28 }, + { 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 28, 28, 28 }, + { 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 28, 28, 28 }, + { 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 28, 28, 28 }, + { 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 28, 28, 28 } }, + /* au16TextureStr */ + /* ISO */ + /* 100, 200, 400, 800, 1600, 3200, 6400, 12800, 25600, 51200, 102400, 204800, 409600, 819200,1638400,3276800 */ + { { 164, 135, 148, 146, 138, 145, 140, 140, 140, 113, 87, 87, 76, 28, 28, 28 }, + { 196, 169, 177, 171, 164, 164, 163, 159, 159, 135, 101, 101, 130, 43, 43, 43 }, + { 228, 203, 207, 195, 191, 191, 185, 178, 178, 157, 116, 116, 185, 59, 59, 59 }, + { 256, 233, 232, 216, 212, 213, 204, 196, 196, 177, 132, 132, 238, 75, 75, 75 }, + { 273, 252, 247, 228, 223, 223, 214, 208, 208, 191, 147, 147, 288, 91, 91, 91 }, + { 288, 269, 261, 238, 232, 231, 222, 219, 219, 203, 162, 162, 332, 106, 106, 106 }, + { 300, 282, 272, 246, 237, 237, 228, 229, 229, 214, 176, 176, 372, 121, 121, 121 }, + { 308, 293, 280, 252, 241, 241, 232, 237, 237, 223, 188, 188, 410, 136, 136, 136 }, + { 312, 300, 285, 255, 242, 243, 234, 243, 243, 229, 199, 199, 444, 152, 152, 152 }, + { 313, 303, 288, 255, 240, 244, 233, 246, 246, 232, 207, 207, 475, 167, 167, 167 }, + { 311, 305, 289, 254, 237, 243, 231, 248, 248, 234, 214, 214, 503, 183, 183, 183 }, + { 308, 305, 288, 252, 233, 241, 228, 249, 249, 235, 220, 220, 527, 199, 199, 199 }, + { 303, 304, 285, 249, 229, 238, 225, 249, 249, 234, 225, 225, 546, 214, 214, 214 }, + { 295, 302, 281, 244, 224, 233, 220, 248, 248, 232, 229, 229, 559, 228, 228, 228 }, + { 286, 299, 275, 239, 218, 227, 216, 246, 246, 229, 232, 232, 568, 241, 241, 241 }, + { 277, 296, 268, 233, 213, 221, 211, 243, 243, 225, 233, 233, 572, 254, 254, 254 }, + { 269, 292, 260, 227, 208, 215, 207, 240, 240, 221, 235, 235, 573, 267, 267, 267 }, + { 261, 288, 251, 221, 202, 208, 203, 236, 236, 215, 235, 235, 568, 283, 283, 283 }, + { 252, 284, 241, 215, 197, 201, 198, 232, 232, 209, 234, 234, 556, 298, 298, 298 }, + { 243, 279, 232, 208, 192, 193, 193, 227, 227, 204, 232, 232, 535, 313, 313, 313 }, + { 233, 273, 223, 201, 187, 186, 187, 222, 222, 199, 228, 228, 511, 325, 325, 325 }, + { 222, 267, 214, 195, 183, 177, 181, 216, 216, 194, 223, 223, 482, 338, 338, 338 }, + { 212, 261, 206, 188, 178, 169, 174, 209, 209, 189, 217, 217, 450, 348, 348, 348 }, + { 201, 255, 197, 181, 173, 161, 168, 201, 201, 183, 210, 210, 417, 353, 353, 353 }, + { 191, 248, 190, 174, 168, 153, 162, 192, 192, 175, 201, 201, 383, 350, 350, 350 }, + { 180, 242, 182, 167, 162, 145, 156, 181, 181, 166, 191, 191, 347, 343, 343, 343 }, + { 170, 235, 175, 160, 157, 137, 150, 170, 170, 157, 180, 180, 309, 330, 330, 330 }, + { 161, 228, 167, 153, 151, 129, 144, 159, 159, 147, 168, 168, 269, 313, 313, 313 }, + { 152, 221, 158, 147, 145, 120, 138, 148, 148, 137, 155, 155, 224, 287, 287, 287 }, + { 144, 213, 149, 140, 140, 111, 132, 136, 136, 126, 142, 142, 117, 254, 254, 254 }, + { 136, 205, 140, 134, 134, 102, 125, 125, 125, 116, 129, 129, 128, 219, 219, 219 }, + { 128, 197, 131, 128, 128, 93, 119, 113, 113, 105, 118, 118, 80, 186, 186, 186 } }, + /* au16EdgeStr */ + /* ISO */ + /* 100, 200, 400, 800, 1600, 3200, 6400, 12800, 25600, 51200, 102400, 204800, 409600, 819200,1638400, 3276800 */ + { { 219, 219, 193, 193, 172, 165, 131, 120, 432, 252, 214, 214, 224, 224, 224, 224 }, + { 224, 224, 199, 199, 177, 169, 139, 126, 448, 262, 223, 223, 244, 244, 244, 244 }, + { 228, 228, 205, 205, 181, 173, 147, 132, 463, 274, 233, 233, 265, 265, 265, 265 }, + { 233, 233, 212, 212, 186, 177, 155, 139, 480, 284, 244, 244, 285, 285, 285, 285 }, + { 237, 237, 218, 218, 190, 181, 161, 145, 494, 294, 254, 254, 303, 303, 303, 303 }, + { 242, 242, 224, 224, 195, 185, 168, 151, 509, 301, 264, 264, 319, 319, 319, 319 }, + { 246, 246, 230, 230, 199, 189, 174, 157, 524, 308, 273, 273, 333, 333, 333, 333 }, + { 251, 251, 235, 235, 204, 193, 180, 163, 539, 314, 281, 281, 346, 346, 346, 346 }, + { 255, 255, 239, 239, 208, 197, 185, 168, 554, 319, 288, 288, 357, 357, 357, 357 }, + { 260, 260, 243, 243, 213, 201, 190, 173, 569, 322, 293, 293, 364, 364, 364, 364 }, + { 265, 265, 247, 247, 217, 205, 195, 179, 583, 324, 297, 297, 370, 370, 370, 370 }, + { 270, 270, 251, 251, 222, 209, 200, 184, 595, 326, 300, 300, 374, 374, 374, 374 }, + { 274, 274, 254, 254, 226, 214, 204, 189, 605, 328, 302, 302, 379, 379, 379, 379 }, + { 278, 278, 257, 257, 230, 217, 209, 195, 613, 329, 304, 304, 384, 384, 384, 384 }, + { 282, 282, 260, 260, 234, 221, 213, 200, 619, 329, 305, 305, 390, 390, 390, 390 }, + { 284, 284, 263, 263, 237, 224, 217, 205, 624, 329, 306, 306, 394, 394, 394, 394 }, + { 286, 286, 265, 265, 241, 227, 222, 210, 627, 330, 307, 307, 398, 398, 398, 398 }, + { 287, 287, 268, 268, 245, 231, 227, 215, 627, 330, 307, 307, 398, 398, 398, 398 }, + { 288, 288, 272, 272, 249, 234, 232, 219, 627, 330, 307, 307, 398, 398, 398, 398 }, + { 289, 289, 274, 274, 252, 237, 235, 223, 627, 330, 306, 306, 398, 398, 398, 398 }, + { 288, 288, 276, 276, 255, 239, 237, 226, 628, 329, 305, 305, 398, 398, 398, 398 }, + { 287, 287, 276, 276, 256, 240, 239, 229, 628, 329, 303, 303, 398, 398, 398, 398 }, + { 284, 284, 275, 275, 255, 240, 239, 231, 628, 328, 300, 300, 399, 399, 399, 399 }, + { 279, 279, 271, 271, 251, 237, 237, 229, 627, 328, 296, 296, 402, 402, 402, 402 }, + { 272, 272, 264, 264, 244, 232, 232, 223, 627, 326, 291, 291, 405, 405, 405, 405 }, + { 264, 264, 255, 255, 235, 225, 225, 214, 627, 325, 285, 285, 408, 408, 408, 408 }, + { 254, 254, 244, 244, 223, 216, 216, 203, 623, 323, 279, 279, 411, 411, 411, 411 }, + { 242, 242, 231, 231, 210, 205, 207, 193, 613, 320, 272, 272, 413, 413, 413, 413 }, + { 231, 231, 218, 218, 196, 195, 197, 183, 593, 314, 264, 264, 411, 411, 411, 411 }, + { 219, 219, 204, 204, 182, 184, 187, 173, 566, 307, 257, 257, 408, 408, 408, 408 }, + { 208, 208, 191, 191, 169, 173, 177, 163, 536, 299, 249, 249, 405, 405, 405, 405 }, + { 235, 197, 179, 179, 156, 163, 169, 153, 507, 292, 243, 243, 402, 402, 402, 402 } }, + /* au16TextureFreq */ + /* ISO */ + /* 100, 200, 400, 800, 1600, 3200, 6400, 12800, 25600, 51200, 102400, 204800, 409600, 819200, 1638400, 3276800 */ + { 200, 200, 180, 180, 160, 160, 155, 170, 170, 170, 170, 170, 170, 170, 170, 170 }, + + /* au16EdgeFreq */ + { 130, 115, 100, 100, 100, 100, 100, 100, 100, 100, 96, 96, 96, 96, 96, 96 }, + + /* au8OverShoot */ + { 55, 60, 70, 70, 65, 55, 55, 55, 50, 45, 40, 40, 10, 10, 10, 10 }, + + /* au8UnderShoot */ + { 65, 75, 80, 80, 80, 70, 60, 55, 45, 45, 50, 50, 15, 15, 15, 15 }, + + /* au16shootSupStr */ + { 6, 6, 5, 5, 4, 4, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0 }, + + /* au8ShootSupAdj */ + { 8, 8, 6, 6, 4, 4, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0 }, + + /* au8DetailCtrl */ + { 135, 135, 128, 128, 128, 128, 128, 128, 128, 128, 120, 120, 120, 120, 120, 120 }, + + /* au8DetailCtrlThr */ + { 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160 }, + + /* au8EdgeFiltStr */ + { 50, 50, 50, 55, 57, 60, 61, 62, 62, 62, 62, 62, 62, 62, 62, 62 }, + + /* au8RGain */ + { 28, 25, 20, 20, 20, 20, 20, 31, 31, 31, 31, 31, 31, 31, 31, 31 }, + /*au8EdgeFiltMaxCap*/ + { 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18 }, + /* au8GGain */ + { 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32 }, + + /* au8BGain */ + { 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31 }, + + /* au8SkinGain */ + { 27, 27, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31 }, + + /* u8MaxSharpGain */ + { 67, 70, 72, 74, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80 }, + /* au8WeakDetailGain */ + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }, +}; + +static const ISP_CMOS_WDR_S g_stIspWDR = { + /* bFusionMode */ + 0, + + /* bMotionComp */ + 1, + + /* u16ShortThr */ + 4032, + + /* u16LongThr */ + 3008, + + /* bForceLong */ + 1, + + /* u16ForceLongLowThr */ + 500, + + /* u16ForceLongHigThr */ + 700, + + /* bShortExpoChk */ + 0, + + /* u16ShortCheckThd */ + 0x8, + + /* au8MdThrLowGain[16] */ + /* 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768 */ + { 64, 64, 64, 64, 128, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }, + + /* au8MdThrHigGain[16] */ + { 128, 128, 128, 128, 128, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }, + + /* au16FusionThr[2] */ + { 3855, 3000 }, + + /* u8MdtStillThd */ + 0x14, + + /* u8MdtLongBlend */ + 0x0 +}; + +static AWB_CCM_S g_stAwbCcm = { + 4, + { + { + 6500, + { 0x01C7, 0x80B9, 0x800E, 0x8022, 0x0141, 0x801F, 0x001C, 0x8095, 0x0179 }, + }, + + { + 5000, + { 0x01C0, 0x8095, 0x802B, 0x8048, 0x015E, 0x8016, 0x001A, 0x80AA, 0x0190 }, + }, + + { + 3800, + { 0x0208, 0x810B, 0x0003, 0x803B, 0x0142, 0x8007, 0x0018, 0x80D4, 0x01BC }, + }, + { + 2800, + { 0x01DF, 0x80CB, 0x8014, 0x8048, 0x014A, 0x8002, 0x003B, 0x811E, 0x01E3 }, + }, + { + 1600, + { 0x0100, 0x0000, 0x0000, 0x0000, 0x0100, 0x0000, 0x0000, 0x0000, 0x0100 }, + }, + { + 1400, + { 0x0100, 0x0000, 0x0000, 0x0000, 0x0100, 0x0000, 0x0000, 0x0000, 0x0100 }, + }, + { + 1000, + { 0x0100, 0x0000, 0x0000, 0x0000, 0x0100, 0x0000, 0x0000, 0x0000, 0x0100 }, + }, + }, +}; + +static AWB_AGC_TABLE_S g_stAwbAgcTable = { + /* bvalid */ + 1, + + /* saturation */ + /* 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768 */ + { 0x80, 0x78, 0x73, 0x6E, 0x69, 0x5F, 0x58, 0x50, 0x48, 0x40, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38 } +}; + +static const ISP_CMOS_DEHAZE_S g_stIspDehaze = { + /* bEnable */ + 0, + /* bUserLutEnable */ + 0, + /* enOpType */ + 0, + /* u8AutoStrength */ + 128, + /* u8ManualStrength */ + 128 +}; + +static const ISP_CMOS_DRC_S g_stIspDRC = { + /* bEnable */ + 0, + /* enOpType */ + 0, + /* u16ManualStrength */ + 512, + /* u16AutoStrength */ + 512, + /* u8SpatialFltCoef */ + 1, + /* u8RangeFltCoef */ + 2, + /* u8ContrastControl */ + 8, + /* s8DetailAdjustFactor */ + 0, + /* u8RangeAdaMax */ + 8, + /* u8FltScaleFine */ + 6, + /* u8FltScaleCoarse */ + 6, + /* u8GradRevMax */ + 64, + /* u8GradRevThr */ + 50, + /* u8BrightGainLmt */ + 12, + /* u8BrightGainLmtStep */ + 8, + /* u8DarkGainLmtY */ + 0, + /* u8DarkGainLmtC */ + 0, + /* u8PDStrength */ + 35, + /* u8LocalMixingBrightMax */ + 64, + /* u8LocalMixingBrightMin */ + 32, + /* u8LocalMixingBrightThr */ + 96, + /* s8LocalMixingBrightSlo */ + -3, + /* u8LocalMixingDarkMax */ + 64, + /* u8LocalMixingDarkMin */ + 32, + /* u8LocalMixingDarkThr */ + 200, + /* s8LocalMixingDarkSlo */ + 5, + /* ColorCorrectionLut[33] */ + { 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, + 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024 }, + /*ToneMappingValue[200]*/ + { 8, 8, 16, 24, 31, 39, 48, 56, 65, 75, 85, 95, 106, 118, 130, + 143, 156, 170, 185, 201, 218, 235, 254, 274, 294, 316, 339, 364, 390, 417, + 446, 477, 509, 543, 579, 617, 658, 701, 746, 794, 844, 898, 955, 1015, 1078, + 1145, 1216, 1291, 1370, 1454, 1543, 1637, 1736, 1841, 1952, 2069, 2194, 2325, 2465, 2612, + 2767, 2932, 3106, 3290, 3485, 3691, 3909, 4140, 4384, 4641, 4914, 5202, 5507, 5830, 6171, + 6531, 6913, 7316, 7742, 8193, 8669, 9173, 9705, 10268, 10863, 11492, 12145, 12808, 13483, 14171, + 14872, 15587, 16319, 17069, 17840, 18635, 19458, 19881, 20313, 20754, 21204, 21661, 22122, 22586, 23053, + 23525, 24000, 24480, 24965, 25455, 25950, 26451, 26959, 27473, 27995, 28524, 29062, 29609, 30165, 30732, + 31309, 31899, 32501, 33116, 33746, 34391, 35043, 35706, 36381, 37066, 37763, 38472, 39192, 39925, 40671, + 41429, 42201, 42591, 42986, 43383, 43784, 44189, 44597, 45008, 45424, 45842, 46265, 46691, 47121, 47555, + 47993, 48434, 48880, 49329, 49783, 50241, 50703, 51169, 51639, 52113, 52592, 53075, 53564, 54056, 54552, + 55054, 55560, 56071, 56586, 56846, 57107, 57369, 57632, 57896, 58162, 58429, 58697, 58967, 59238, 59510, + 59783, 60057, 60333, 60611, 60889, 61169, 61451, 61733, 62017, 62303, 62589, 62877, 63167, 63458, 63750, + 64044, 64340, 64636, 64934, 65234 }, + /* u8Asymmetry */ + 2, + /* u8SecondPole */ + 180, + /* u8Stretch */ + 54, + /* u8Compress */ + 180, + /* u8CurveSel */ + 0, + /* au16Xpoint */ + { 0, 200, 400, 600, 1000 }, + /* au16Ypoint */ + { 0, 200, 400, 600, 1000 }, + /* au16Slope */ + { 1000, 1000, 1000, 1000, 1000 } +}; + +static const ISP_CMOS_CA_S g_stIspCA = { + /* CA */ + 1, + /* Y */ + { 516, 525, 534, 544, 554, 563, 573, 583, 594, 604, 614, 624, 634, 644, 654, 664, + 674, 684, 694, 704, 713, 723, 732, 741, 750, 758, 766, 775, 782, 790, 797, 804, + 811, 817, 823, 828, 834, 839, 844, 848, 853, 857, 861, 865, 868, 872, 875, 878, + 881, 884, 887, 890, 892, 895, 898, 900, 903, 905, 908, 910, 913, 915, 918, 921, + 924, 926, 929, 932, 935, 937, 940, 943, 945, 948, 950, 952, 955, 957, 959, 961, + 964, 966, 968, 970, 972, 974, 976, 978, 979, 981, 983, 985, 987, 988, 990, 992, + 993, 994, 995, 996, 997, 998, 998, 999, 1000, 1001, 1002, 1002, 1003, 1004, 1005, 1006, + 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1018, 1019, 1020, 1022, 1024 }, + /* ISO */ + /* 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768 */ + { 1300, 1300, 1250, 1200, 1150, 1100, 1050, 1000, 950, 900, 900, 800, 800, 800, 800, 800 } +}; + +static const ISP_CMOS_LSC_S g_stCmosLsc = { + /* MeshStrength */ + 256, + /* MeshScale */ + 4, + /* ISP_LSC_CABLI_TABLE_S */ + { + { + // Rgain: + { + 0x26b, 0x1de, 0x179, 0x12a, 0xee, 0xc4, 0xa2, 0x94, 0x94, 0x97, 0xad, 0xc8, + 0x10d, 0x133, 0x184, 0x1fd, 0x284, 0x235, 0x1ba, 0x158, 0x10d, 0xd3, 0xad, 0x8c, + 0x7b, 0x74, 0x7b, 0x90, 0xaf, 0xd8, 0x114, 0x164, 0x1d1, 0x253, 0x210, 0x194, + 0x136, 0xec, 0xbc, 0x91, 0x6f, 0x5d, 0x59, 0x5f, 0x75, 0x94, 0xbf, 0xf7, + 0x149, 0x1ac, 0x229, 0x1e1, 0x177, 0x11a, 0xd7, 0xa6, 0x7c, 0x5b, 0x44, 0x3e, + 0x4a, 0x5c, 0x7d, 0xab, 0xe2, 0x127, 0x18f, 0x200, 0x1c8, 0x15f, 0x10d, 0xc9, + 0x98, 0x69, 0x4a, 0x32, 0x2a, 0x33, 0x4a, 0x6b, 0x9e, 0xd0, 0x113, 0x175, + 0x1e5, 0x1b6, 0x14f, 0xf9, 0xbf, 0x84, 0x57, 0x34, 0x21, 0x18, 0x21, 0x3a, + 0x5e, 0x8e, 0xc2, 0x105, 0x162, 0x1d8, 0x1a9, 0x140, 0xef, 0xb4, 0x7d, 0x50, + 0x2d, 0x11, 0xa, 0x15, 0x2f, 0x57, 0x83, 0xb9, 0xfb, 0x156, 0x1c3, 0x1a5, + 0x134, 0xe9, 0xae, 0x7a, 0x4b, 0x26, 0x8, 0x4, 0xc, 0x28, 0x4f, 0x7f, + 0xb8, 0xf7, 0x151, 0x1bf, 0x19d, 0x134, 0xe8, 0xac, 0x75, 0x48, 0x34, 0x4, + 0x0, 0xa, 0x25, 0x50, 0x7e, 0xb5, 0xf8, 0x150, 0x1bd, 0x199, 0x134, 0xea, + 0xae, 0x73, 0x4b, 0x32, 0x5, 0x2, 0xd, 0x2a, 0x4e, 0x83, 0xbc, 0xf9, + 0x151, 0x1c0, 0x1a5, 0x139, 0xee, 0xb1, 0x7e, 0x51, 0x2f, 0x14, 0xd, 0x16, + 0x31, 0x56, 0x86, 0xbb, 0x100, 0x158, 0x1c3, 0x1b2, 0x147, 0xfe, 0xbd, 0x87, + 0x5f, 0x3b, 0x24, 0x1b, 0x24, 0x43, 0x64, 0x90, 0xc8, 0x107, 0x164, 0x1d2, + 0x1c1, 0x159, 0x107, 0xca, 0x94, 0x6e, 0x4d, 0x36, 0x30, 0x36, 0x4e, 0x74, + 0x9b, 0xd1, 0x11a, 0x173, 0x1e2, 0x1de, 0x16f, 0x119, 0xda, 0xa7, 0x7f, 0x64, + 0x4e, 0x45, 0x4f, 0x62, 0x86, 0xb1, 0xe6, 0x128, 0x188, 0x1fd, 0x1f9, 0x18a, + 0x131, 0xf2, 0xbf, 0x99, 0x79, 0x65, 0x60, 0x6a, 0x7b, 0x9e, 0xc9, 0xfb, + 0x13d, 0x19f, 0x21e, 0x21c, 0x1a9, 0x14b, 0x109, 0xd6, 0xb4, 0x96, 0x83, 0x7f, + 0x83, 0x94, 0xb7, 0xe0, 0x115, 0x15d, 0x1c1, 0x23f, 0x244, 0x1c8, 0x167, 0x127, + 0xf5, 0xcc, 0xb1, 0x9f, 0x99, 0x98, 0xb3, 0xce, 0xf7, 0x12e, 0x17a, 0x1e9, + 0x262, + }, + + // Grgain: + { + 0x27c, 0x1fd, 0x18b, 0x138, 0xfb, 0xd2, 0xb1, 0xa3, 0x9d, 0xa0, 0xb7, 0xd8, + 0x11d, 0x141, 0x1a4, 0x21c, 0x2ab, 0x24a, 0x1d0, 0x164, 0x113, 0xde, 0xb4, 0x96, + 0x83, 0x7e, 0x84, 0x9a, 0xbb, 0xe8, 0x128, 0x17a, 0x1ec, 0x274, 0x21c, 0x1a8, + 0x140, 0xf8, 0xc5, 0x9b, 0x77, 0x64, 0x5d, 0x67, 0x80, 0x9f, 0xca, 0x105, + 0x15a, 0x1c1, 0x24e, 0x1f6, 0x18b, 0x127, 0xe6, 0xaf, 0x82, 0x62, 0x4b, 0x46, + 0x4e, 0x64, 0x85, 0xb6, 0xee, 0x13c, 0x1a6, 0x22d, 0x1de, 0x170, 0x118, 0xd3, + 0x9d, 0x6f, 0x4c, 0x35, 0x2a, 0x37, 0x4f, 0x76, 0xa3, 0xdb, 0x123, 0x187, + 0x20b, 0x1ca, 0x15c, 0x107, 0xc6, 0x8e, 0x5d, 0x3c, 0x21, 0x19, 0x27, 0x41, + 0x68, 0x94, 0xce, 0x116, 0x17a, 0x1fa, 0x1b4, 0x151, 0xfc, 0xbd, 0x85, 0x54, + 0x31, 0x12, 0x9, 0x16, 0x34, 0x5c, 0x89, 0xc6, 0x10a, 0x16b, 0x1e5, 0x1ae, + 0x147, 0xf7, 0xb7, 0x80, 0x53, 0x29, 0xa, 0x4, 0x12, 0x2c, 0x56, 0x86, + 0xc1, 0x103, 0x166, 0x1dc, 0x1ac, 0x144, 0xf5, 0xb5, 0x7d, 0x4c, 0x37, 0x7, + 0x1, 0xc, 0x2a, 0x55, 0x83, 0xbe, 0x101, 0x166, 0x1d7, 0x1aa, 0x145, 0xf9, + 0xb6, 0x82, 0x52, 0x3a, 0xb, 0x5, 0xd, 0x2d, 0x57, 0x88, 0xc0, 0x102, + 0x162, 0x1dc, 0x1b4, 0x14d, 0xfe, 0xbc, 0x87, 0x5c, 0x36, 0x16, 0xf, 0x19, + 0x36, 0x5f, 0x8f, 0xca, 0x10d, 0x16b, 0x1e2, 0x1be, 0x15a, 0x10b, 0xca, 0x90, + 0x63, 0x3e, 0x26, 0x1f, 0x2b, 0x44, 0x69, 0x9c, 0xd2, 0x119, 0x175, 0x1f3, + 0x1c9, 0x16a, 0x114, 0xd5, 0x9e, 0x77, 0x54, 0x3a, 0x33, 0x3a, 0x54, 0x79, + 0xa8, 0xe1, 0x127, 0x184, 0x203, 0x1ed, 0x186, 0x12a, 0xe7, 0xb1, 0x87, 0x6a, + 0x55, 0x4c, 0x54, 0x6d, 0x8f, 0xbb, 0xf4, 0x137, 0x1a0, 0x21a, 0x20d, 0x1a0, + 0x140, 0xfc, 0xc7, 0xa3, 0x81, 0x6d, 0x66, 0x71, 0x85, 0xa5, 0xd3, 0x108, + 0x152, 0x1b9, 0x23c, 0x231, 0x1bf, 0x160, 0x119, 0xe6, 0xbd, 0x9e, 0x8a, 0x84, + 0x8c, 0xa2, 0xc5, 0xf0, 0x123, 0x16d, 0x1da, 0x260, 0x25c, 0x1e1, 0x17f, 0x136, + 0xfd, 0xda, 0xbe, 0xaa, 0x9f, 0xa9, 0xbb, 0xda, 0x104, 0x13e, 0x18e, 0x1ff, + 0x285, + }, + + // Gbgain: + { + 0x28b, 0x1fd, 0x18e, 0x139, 0xfd, 0xd7, 0xb6, 0xa3, 0xa4, 0xa9, 0xbc, 0xde, + 0x126, 0x14d, 0x1a5, 0x21f, 0x2b1, 0x256, 0x1d6, 0x16a, 0x11d, 0xe4, 0xb9, 0x9b, + 0x87, 0x83, 0x8b, 0xa0, 0xc1, 0xec, 0x12e, 0x183, 0x1f5, 0x284, 0x229, 0x1ad, + 0x142, 0xfb, 0xc9, 0x9f, 0x7c, 0x6a, 0x62, 0x6c, 0x84, 0xa4, 0xd2, 0x10f, + 0x15f, 0x1ce, 0x252, 0x201, 0x18a, 0x129, 0xe8, 0xb1, 0x86, 0x67, 0x4d, 0x4b, + 0x51, 0x6a, 0x8b, 0xbc, 0xf9, 0x140, 0x1ac, 0x229, 0x1ea, 0x176, 0x116, 0xd2, + 0x9e, 0x73, 0x4e, 0x38, 0x2f, 0x3c, 0x54, 0x7a, 0xaa, 0xe0, 0x127, 0x18f, + 0x211, 0x1ce, 0x160, 0x107, 0xc8, 0x94, 0x5f, 0x3d, 0x22, 0x1e, 0x28, 0x43, + 0x6b, 0x9a, 0xd1, 0x11c, 0x17d, 0x1fa, 0x1bf, 0x153, 0x101, 0xbe, 0x86, 0x54, + 0x2f, 0x14, 0xc, 0x1b, 0x36, 0x60, 0x91, 0xc9, 0x110, 0x16f, 0x1eb, 0x1bf, + 0x14a, 0xfa, 0xb8, 0x81, 0x4f, 0x28, 0xb, 0x3, 0x11, 0x2e, 0x56, 0x8a, + 0xc6, 0x10a, 0x16a, 0x1e2, 0x1b1, 0x149, 0xfa, 0xb8, 0x7f, 0x50, 0x37, 0x8, + 0x0, 0xf, 0x2e, 0x57, 0x89, 0xc2, 0x107, 0x16a, 0x1df, 0x1b9, 0x148, 0xf9, + 0xba, 0x82, 0x54, 0x36, 0xd, 0x5, 0x10, 0x2f, 0x5a, 0x8b, 0xc5, 0x10a, + 0x167, 0x1dd, 0x1c0, 0x150, 0x100, 0xbf, 0x86, 0x5a, 0x34, 0x16, 0x10, 0x18, + 0x39, 0x61, 0x91, 0xcb, 0x115, 0x171, 0x1e9, 0x1d0, 0x15d, 0x10b, 0xc9, 0x93, + 0x66, 0x43, 0x26, 0x1f, 0x29, 0x46, 0x6d, 0x9f, 0xd4, 0x11a, 0x17d, 0x1f3, + 0x1e1, 0x16e, 0x11a, 0xd6, 0x9d, 0x76, 0x54, 0x3c, 0x35, 0x40, 0x59, 0x7b, + 0xad, 0xe4, 0x128, 0x187, 0x20a, 0x200, 0x184, 0x12c, 0xe8, 0xb3, 0x87, 0x66, + 0x51, 0x4d, 0x55, 0x6d, 0x93, 0xbd, 0xf9, 0x13f, 0x1a2, 0x21d, 0x214, 0x1a4, + 0x145, 0xfd, 0xc7, 0x9f, 0x82, 0x6d, 0x66, 0x6d, 0x86, 0xa8, 0xd7, 0x10c, + 0x155, 0x1bd, 0x246, 0x242, 0x1c2, 0x161, 0x119, 0xe4, 0xb9, 0x9d, 0x8f, 0x83, + 0x8d, 0xa3, 0xc4, 0xf1, 0x12a, 0x174, 0x1e1, 0x26b, 0x261, 0x1de, 0x17f, 0x131, + 0xfd, 0xd8, 0xbc, 0xac, 0x9d, 0xa9, 0xbe, 0xe0, 0x109, 0x142, 0x193, 0x208, + 0x28f, + }, + + // Bgain: + { + 0x28e, 0x202, 0x186, 0x12f, 0xfb, 0xcc, 0xb4, 0xa4, 0xa4, 0xa9, 0xba, 0xe2, + 0x120, 0x14b, 0x1a5, 0x220, 0x2b6, 0x251, 0x1d8, 0x16e, 0x114, 0xde, 0xb3, 0x92, + 0x83, 0x81, 0x88, 0xa1, 0xbe, 0xec, 0x128, 0x17d, 0x1f1, 0x274, 0x228, 0x1ac, + 0x144, 0xfc, 0xc2, 0x97, 0x7c, 0x67, 0x61, 0x67, 0x7e, 0x9e, 0xcf, 0x107, + 0x155, 0x1c9, 0x252, 0x1fa, 0x183, 0x12a, 0xe4, 0xb0, 0x83, 0x61, 0x4d, 0x48, + 0x50, 0x67, 0x86, 0xb4, 0xec, 0x133, 0x1a4, 0x22c, 0x1da, 0x16d, 0x113, 0xcd, + 0x9f, 0x70, 0x4e, 0x3a, 0x2f, 0x3c, 0x51, 0x75, 0xa0, 0xdb, 0x11e, 0x185, + 0x201, 0x1c5, 0x15d, 0x101, 0xc5, 0x8b, 0x5b, 0x41, 0x24, 0x1e, 0x27, 0x3d, + 0x65, 0x93, 0xce, 0x114, 0x179, 0x1fc, 0x1bc, 0x150, 0xfb, 0xbe, 0x87, 0x57, + 0x30, 0x17, 0xd, 0x18, 0x37, 0x5f, 0x8b, 0xbf, 0x105, 0x16b, 0x1e9, 0x1ac, + 0x147, 0xf1, 0xb8, 0x80, 0x4f, 0x29, 0xf, 0x5, 0x10, 0x32, 0x5c, 0x88, + 0xc2, 0x107, 0x160, 0x1d4, 0x1af, 0x143, 0xf7, 0xb4, 0x7d, 0x4f, 0x3a, 0x7, + 0x1, 0xc, 0x2f, 0x57, 0x8b, 0xc0, 0x102, 0x15f, 0x1d8, 0x1a8, 0x147, 0xf5, + 0xb6, 0x80, 0x51, 0x37, 0xc, 0x5, 0x10, 0x2f, 0x5a, 0x8b, 0xc8, 0x108, + 0x163, 0x1da, 0x1bc, 0x151, 0xfb, 0xba, 0x8a, 0x59, 0x36, 0x15, 0xf, 0x1b, + 0x38, 0x62, 0x92, 0xc9, 0x10e, 0x171, 0x1ec, 0x1cd, 0x156, 0x105, 0xc6, 0x8c, + 0x66, 0x45, 0x27, 0x23, 0x27, 0x47, 0x6f, 0x9a, 0xd8, 0x115, 0x17e, 0x1ee, + 0x1da, 0x16c, 0x110, 0xd2, 0x9e, 0x78, 0x54, 0x3d, 0x38, 0x3e, 0x58, 0x78, + 0xad, 0xe3, 0x126, 0x186, 0x20d, 0x201, 0x18e, 0x12b, 0xe2, 0xb1, 0x87, 0x67, + 0x54, 0x51, 0x58, 0x6c, 0x93, 0xb8, 0xf4, 0x13b, 0x1a3, 0x229, 0x217, 0x1aa, + 0x147, 0x100, 0xc8, 0xa0, 0x82, 0x6c, 0x66, 0x6c, 0x86, 0xa9, 0xd0, 0x107, + 0x156, 0x1bb, 0x23b, 0x232, 0x1c2, 0x165, 0x117, 0xe4, 0xbf, 0xa2, 0x8c, 0x85, + 0x8a, 0x9f, 0xc1, 0xeb, 0x126, 0x16b, 0x1dd, 0x26c, 0x262, 0x1ea, 0x17c, 0x132, + 0xf7, 0xd2, 0xc0, 0xa9, 0x9f, 0xa5, 0xb9, 0xd3, 0x102, 0x137, 0x184, 0x206, + 0x289, + }, + }, + + { + // Rgain: + { + 0x399, 0x2df, 0x23e, 0x1cd, 0x170, 0x135, 0xfc, 0xdb, 0xda, 0xe4, 0xfd, 0x12f, + 0x16e, 0x1d4, 0x24e, 0x2ee, 0x3e2, 0x372, 0x2b0, 0x20f, 0x19a, 0x140, 0x109, 0xdc, + 0xb7, 0xaf, 0xbe, 0xd5, 0x105, 0x14c, 0x1a4, 0x225, 0x2b8, 0x384, 0x32a, 0x276, + 0x1e3, 0x174, 0x11c, 0xda, 0xaf, 0x92, 0x88, 0x97, 0xac, 0xec, 0x125, 0x180, + 0x200, 0x289, 0x34f, 0x2f6, 0x24f, 0x1bd, 0x14b, 0xfd, 0xba, 0x89, 0x6c, 0x61, + 0x71, 0x89, 0xc6, 0x107, 0x15a, 0x1c7, 0x262, 0x319, 0x2c9, 0x229, 0x1a5, 0x135, + 0xdb, 0x9b, 0x6a, 0x4a, 0x3f, 0x4e, 0x6c, 0xa5, 0xeb, 0x13e, 0x1b1, 0x23d, + 0x2e3, 0x2b9, 0x211, 0x187, 0x11b, 0xc9, 0x81, 0x4d, 0x2b, 0x21, 0x2f, 0x58, + 0x8f, 0xda, 0x12a, 0x196, 0x229, 0x2c8, 0x29c, 0x1fb, 0x16e, 0x10d, 0xb5, 0x6e, + 0x37, 0x11, 0x7, 0x1a, 0x46, 0x7b, 0xc3, 0x118, 0x187, 0x210, 0x2b7, 0x2bc, + 0x1f5, 0x16b, 0x106, 0xb1, 0x61, 0x2e, 0x4, 0x0, 0xe, 0x3a, 0x71, 0xba, + 0x113, 0x17f, 0x206, 0x2a4, 0x33a, 0x1f3, 0x165, 0xfd, 0xab, 0x62, 0x2d, 0x2, + 0x3, 0x8, 0x35, 0x6e, 0xb6, 0x10f, 0x179, 0x202, 0x29f, 0x2f0, 0x1e6, 0x165, + 0x103, 0xac, 0x63, 0x30, 0x7, 0x1, 0xb, 0x36, 0x70, 0xb8, 0x112, 0x176, + 0x208, 0x2a4, 0x2d2, 0x1f4, 0x171, 0x106, 0xb6, 0x70, 0x38, 0x15, 0xa, 0x18, + 0x40, 0x78, 0xbf, 0x11c, 0x181, 0x20c, 0x2ac, 0x2d0, 0x202, 0x17e, 0x118, 0xc0, + 0x7c, 0x4a, 0x2e, 0x1d, 0x2e, 0x4f, 0x87, 0xcd, 0x122, 0x190, 0x21a, 0x2bb, + 0x2be, 0x216, 0x194, 0x12d, 0xd9, 0x99, 0x64, 0x49, 0x3d, 0x48, 0x68, 0x9d, + 0xdd, 0x13f, 0x1a3, 0x229, 0x2cf, 0x2e4, 0x236, 0x1bb, 0x144, 0xf0, 0xb5, 0x81, + 0x63, 0x62, 0x66, 0x86, 0xb7, 0xfb, 0x14e, 0x1be, 0x249, 0x2ed, 0x30c, 0x26c, + 0x1ce, 0x164, 0x110, 0xd4, 0xa4, 0x86, 0x7f, 0x86, 0xa6, 0xd7, 0x115, 0x171, + 0x1da, 0x270, 0x31c, 0x339, 0x28d, 0x1fb, 0x18d, 0x133, 0xf6, 0xc5, 0xaa, 0xa1, + 0xae, 0xca, 0xf8, 0x138, 0x195, 0x210, 0x2a1, 0x355, 0x37f, 0x2be, 0x229, 0x1b1, + 0x159, 0x118, 0xeb, 0xd3, 0xc6, 0xd4, 0xed, 0x11f, 0x15d, 0x1cd, 0x23d, 0x2cc, + 0x388, + }, + + // Grgain: + { + 0x324, 0x279, 0x1f5, 0x191, 0x148, 0x113, 0xe4, 0xcd, 0xc9, 0xd4, 0xf2, 0x11f, + 0x164, 0x1b6, 0x22c, 0x2ba, 0x392, 0x2f1, 0x250, 0x1cb, 0x16c, 0x11f, 0xe9, 0xc2, + 0xa8, 0xa5, 0xb1, 0xcf, 0xfa, 0x13d, 0x193, 0x208, 0x28d, 0x349, 0x2b8, 0x225, + 0x1a9, 0x148, 0xfa, 0xc5, 0x9c, 0x80, 0x7e, 0x8e, 0xa5, 0xe3, 0x11b, 0x16e, + 0x1e6, 0x266, 0x316, 0x28b, 0x201, 0x18e, 0x12a, 0xe4, 0xa5, 0x79, 0x60, 0x59, + 0x6a, 0x85, 0xbf, 0xfe, 0x151, 0x1b7, 0x243, 0x2e3, 0x26b, 0x1e5, 0x174, 0x111, + 0xc4, 0x88, 0x5d, 0x40, 0x39, 0x4a, 0x69, 0xa2, 0xea, 0x137, 0x19e, 0x223, + 0x2b8, 0x253, 0x1cd, 0x159, 0xfc, 0xb2, 0x73, 0x43, 0x26, 0x1e, 0x30, 0x57, + 0x90, 0xd8, 0x124, 0x188, 0x211, 0x2a4, 0x247, 0x1bd, 0x14c, 0xf2, 0xa4, 0x65, + 0x31, 0x10, 0x6, 0x1a, 0x49, 0x7c, 0xc3, 0x116, 0x17a, 0x201, 0x292, 0x263, + 0x1b6, 0x141, 0xec, 0xa1, 0x5a, 0x26, 0x3, 0x1, 0xf, 0x3f, 0x74, 0xb9, + 0x111, 0x172, 0x1f3, 0x285, 0x2dc, 0x1b4, 0x13e, 0xe6, 0x98, 0x56, 0x25, 0x1, + 0x5, 0xb, 0x38, 0x71, 0xb8, 0x10e, 0x16f, 0x1ed, 0x281, 0x291, 0x1af, 0x142, + 0xe5, 0x9d, 0x5a, 0x2b, 0x7, 0x2, 0xe, 0x3c, 0x74, 0xbb, 0x10f, 0x170, + 0x1f0, 0x27f, 0x28d, 0x1b7, 0x14b, 0xee, 0xa5, 0x64, 0x35, 0x13, 0xa, 0x1c, + 0x42, 0x7d, 0xbe, 0x116, 0x17b, 0x1f8, 0x28c, 0x27e, 0x1c3, 0x156, 0xfc, 0xb1, + 0x76, 0x46, 0x2e, 0x1f, 0x2f, 0x55, 0x8c, 0xd1, 0x127, 0x185, 0x207, 0x2a5, + 0x265, 0x1d8, 0x169, 0x111, 0xc5, 0x8a, 0x5c, 0x49, 0x3f, 0x4c, 0x6e, 0xa0, + 0xe2, 0x13b, 0x199, 0x215, 0x2ac, 0x282, 0x1f2, 0x188, 0x125, 0xde, 0xa5, 0x79, + 0x5e, 0x63, 0x67, 0x89, 0xb8, 0xf8, 0x14c, 0x1ae, 0x231, 0x2cb, 0x2a6, 0x221, + 0x19c, 0x141, 0xfb, 0xc2, 0x9a, 0x82, 0x7d, 0x88, 0xa6, 0xd6, 0x114, 0x168, + 0x1cd, 0x257, 0x2f4, 0x2cd, 0x240, 0x1c2, 0x166, 0x11e, 0xe7, 0xbc, 0xa8, 0xa0, + 0xac, 0xca, 0xf7, 0x138, 0x18a, 0x1f8, 0x27d, 0x31d, 0x317, 0x268, 0x1ef, 0x189, + 0x13b, 0x106, 0xde, 0xc9, 0xc3, 0xd3, 0xed, 0x119, 0x15a, 0x1c1, 0x221, 0x2a9, + 0x357, + }, + + // Gbgain: + { + 0x32b, 0x277, 0x1f2, 0x18f, 0x148, 0x116, 0xe3, 0xc9, 0xc9, 0xd5, 0xf1, 0x11c, + 0x15a, 0x1b4, 0x22d, 0x2bd, 0x38d, 0x2f4, 0x24d, 0x1ca, 0x16d, 0x11b, 0xea, 0xc4, + 0xa8, 0xa3, 0xb3, 0xc9, 0xfb, 0x13d, 0x190, 0x204, 0x28e, 0x348, 0x2b8, 0x221, + 0x1a8, 0x149, 0xfe, 0xc5, 0x9b, 0x80, 0x7a, 0x8e, 0xa6, 0xe2, 0x119, 0x16f, + 0x1e4, 0x269, 0x315, 0x28e, 0x201, 0x18a, 0x12d, 0xe3, 0xa2, 0x78, 0x60, 0x58, + 0x6c, 0x86, 0xc0, 0xfc, 0x14e, 0x1b9, 0x242, 0x2e7, 0x270, 0x1e1, 0x178, 0x115, + 0xc5, 0x8a, 0x5e, 0x41, 0x3a, 0x4b, 0x6a, 0xa2, 0xe7, 0x136, 0x19e, 0x225, + 0x2bd, 0x258, 0x1ce, 0x15c, 0xff, 0xb1, 0x75, 0x44, 0x26, 0x1e, 0x30, 0x57, + 0x8d, 0xd7, 0x125, 0x18c, 0x212, 0x2a7, 0x241, 0x1bd, 0x14f, 0xf2, 0xa5, 0x65, + 0x30, 0x11, 0x7, 0x1b, 0x48, 0x7d, 0xc3, 0x118, 0x17b, 0x1ff, 0x297, 0x26b, + 0x1ba, 0x147, 0xef, 0xa1, 0x5b, 0x28, 0x4, 0x1, 0x10, 0x3e, 0x75, 0xba, + 0x112, 0x171, 0x1f4, 0x28b, 0x2de, 0x1b6, 0x140, 0xe5, 0x98, 0x5a, 0x27, 0x1, + 0x5, 0xb, 0x37, 0x71, 0xb8, 0x10f, 0x171, 0x1f2, 0x27f, 0x293, 0x1b0, 0x144, + 0xe6, 0x9c, 0x5a, 0x2c, 0x7, 0x4, 0xe, 0x39, 0x74, 0xbc, 0x10f, 0x16e, + 0x1f4, 0x282, 0x285, 0x1ba, 0x14b, 0xef, 0xa5, 0x66, 0x36, 0x15, 0xb, 0x1d, + 0x46, 0x7c, 0xc1, 0x117, 0x17c, 0x1f8, 0x293, 0x27c, 0x1c5, 0x159, 0xfd, 0xb1, + 0x79, 0x47, 0x2e, 0x1f, 0x33, 0x56, 0x8e, 0xce, 0x129, 0x187, 0x206, 0x295, + 0x266, 0x1db, 0x16d, 0x111, 0xc6, 0x8d, 0x5f, 0x49, 0x3f, 0x4a, 0x6f, 0xa3, + 0xe1, 0x13a, 0x19c, 0x219, 0x2ac, 0x280, 0x1f4, 0x18a, 0x126, 0xde, 0xa5, 0x7e, + 0x61, 0x61, 0x67, 0x87, 0xbd, 0xf6, 0x14e, 0x1ae, 0x232, 0x2cb, 0x2ae, 0x21f, + 0x1a0, 0x141, 0xf8, 0xc4, 0x99, 0x84, 0x7f, 0x89, 0xa6, 0xd4, 0x115, 0x169, + 0x1d1, 0x255, 0x2f2, 0x2d4, 0x243, 0x1c6, 0x165, 0x11a, 0xe6, 0xc0, 0xa8, 0xa0, + 0xaa, 0xca, 0xfc, 0x137, 0x18a, 0x1f9, 0x282, 0x324, 0x310, 0x26a, 0x1f0, 0x18a, + 0x13d, 0x108, 0xde, 0xca, 0xc3, 0xcf, 0xf0, 0x11d, 0x15b, 0x1c1, 0x227, 0x2aa, + 0x360, + }, + + // Bgain: + { + 0x2f0, 0x24a, 0x1d2, 0x175, 0x137, 0x105, 0xd7, 0xbd, 0xc0, 0xca, 0xec, 0x10f, + 0x14b, 0x1a7, 0x21b, 0x29c, 0x35e, 0x2b8, 0x228, 0x1ad, 0x155, 0x114, 0xe1, 0xbe, + 0xa0, 0x9d, 0xad, 0xc1, 0xf3, 0x138, 0x183, 0x1f5, 0x278, 0x325, 0x28f, 0x1fe, + 0x18b, 0x138, 0xf1, 0xbc, 0x96, 0x7e, 0x78, 0x8a, 0xa2, 0xda, 0x114, 0x162, + 0x1d6, 0x253, 0x2f5, 0x25e, 0x1df, 0x171, 0x11b, 0xd7, 0x9f, 0x76, 0x5d, 0x5b, + 0x69, 0x84, 0xbd, 0xf9, 0x14a, 0x1ae, 0x232, 0x2c8, 0x249, 0x1c4, 0x15d, 0x105, + 0xba, 0x83, 0x5a, 0x3c, 0x37, 0x4c, 0x67, 0x9f, 0xe7, 0x12f, 0x195, 0x214, + 0x2a1, 0x234, 0x1af, 0x141, 0xf0, 0xa8, 0x71, 0x3e, 0x23, 0x1d, 0x30, 0x58, + 0x91, 0xd3, 0x122, 0x180, 0x202, 0x287, 0x21e, 0x19d, 0x138, 0xe3, 0x9d, 0x61, + 0x2e, 0xf, 0x6, 0x1a, 0x47, 0x7c, 0xbf, 0x119, 0x171, 0x1f5, 0x279, 0x244, + 0x19f, 0x133, 0xdd, 0x97, 0x56, 0x28, 0x4, 0x1, 0x11, 0x3d, 0x77, 0xbc, + 0x10f, 0x16f, 0x1e9, 0x276, 0x2a9, 0x19e, 0x12e, 0xda, 0x92, 0x54, 0x24, 0x4, + 0x7, 0xd, 0x3c, 0x75, 0xb4, 0x10b, 0x168, 0x1e9, 0x271, 0x267, 0x192, 0x128, + 0xd9, 0x96, 0x56, 0x2a, 0x6, 0x7, 0x10, 0x3d, 0x74, 0xb6, 0x10c, 0x168, + 0x1e4, 0x271, 0x263, 0x19a, 0x134, 0xdd, 0x9d, 0x65, 0x37, 0x16, 0xe, 0x1f, + 0x46, 0x79, 0xbd, 0x112, 0x170, 0x1ef, 0x286, 0x254, 0x1a5, 0x143, 0xf0, 0xa7, + 0x70, 0x46, 0x2e, 0x21, 0x33, 0x55, 0x90, 0xcb, 0x11d, 0x17d, 0x1f9, 0x287, + 0x236, 0x1bd, 0x153, 0x100, 0xba, 0x84, 0x57, 0x45, 0x42, 0x50, 0x6d, 0xa2, + 0xde, 0x137, 0x194, 0x20a, 0x297, 0x25b, 0x1db, 0x175, 0x115, 0xd2, 0x9b, 0x76, + 0x5b, 0x5f, 0x69, 0x8a, 0xba, 0xf4, 0x149, 0x1a4, 0x226, 0x2bb, 0x27d, 0x1fb, + 0x186, 0x132, 0xef, 0xbc, 0x97, 0x81, 0x7d, 0x86, 0xa4, 0xd5, 0x112, 0x15e, + 0x1bc, 0x242, 0x2da, 0x2a9, 0x21f, 0x1aa, 0x151, 0x10e, 0xdc, 0xb7, 0xa3, 0x99, + 0xaa, 0xc6, 0xee, 0x130, 0x183, 0x1f3, 0x264, 0x304, 0x2d0, 0x245, 0x1da, 0x175, + 0x12c, 0xf9, 0xdb, 0xc3, 0xbb, 0xc8, 0xe7, 0x114, 0x14d, 0x1b2, 0x218, 0x29b, + 0x338, + }, + }, + }, +}; + +#ifdef __cplusplus +#if __cplusplus +} +#endif +#endif /* End of #ifdef __cplusplus */ + +#endif /* __MIS2008_MIPI_CMOS_EX_H_ */ diff --git a/libraries/sensor/hi3516ev200/imagedesign_mis2008/mis2008_sensor_ctl.c b/libraries/sensor/hi3516ev200/imagedesign_mis2008/mis2008_sensor_ctl.c new file mode 100644 index 0000000..d6dc889 --- /dev/null +++ b/libraries/sensor/hi3516ev200/imagedesign_mis2008/mis2008_sensor_ctl.c @@ -0,0 +1,614 @@ +/* + * (c) OpenIPC.org (c) +*/ + +#include +#include +#include +#include +#include +#include +#include "comm_video.h" +#include "sns_ctrl.h" + +#ifdef GPIO_I2C +#include "gpioi2c_ex.h" +#else + +#ifdef __LITEOS__ +#include "i2c.h" +#else +#include "i2c.h" +#endif +#endif + +#define LOSCFG_HOST_TYPE_VENDOR +#ifdef LOSCFG_HOST_TYPE_VENDOR +#include +#endif + +const unsigned char mis2008_i2c_addr = 0x60; /* I2C Address of MIS2008 */ +const unsigned int mis2008_addr_byte = 2; +const unsigned int mis2008_data_byte = 1; +static int g_fd[ISP_MAX_PIPE_NUM] = { [0 ...(ISP_MAX_PIPE_NUM - 1)] = -1 }; + +extern ISP_SNS_STATE_S *g_pastMis2008[ISP_MAX_PIPE_NUM]; +extern ISP_SNS_COMMBUS_U g_aunMis2008BusInfo[]; + +int mis2008_i2c_init(VI_PIPE ViPipe) +{ + char acDevFile[16] = { 0 }; + GK_U8 u8DevNum; + + if (g_fd[ViPipe] >= 0) { + return GK_SUCCESS; + } +#ifdef GPIO_I2C + int ret; + + g_fd[ViPipe] = open("/dev/gpioi2c_ex", O_RDONLY, S_IRUSR); + if (g_fd[ViPipe] < 0) { + ISP_TRACE(MODULE_DBG_ERR, "Open gpioi2c_ex error!\n"); + return GK_FAILURE; + } +#else + int ret; + + u8DevNum = g_aunMis2008BusInfo[ViPipe].s8I2cDev; + snprintf(acDevFile, sizeof(acDevFile), "/dev/i2c-%u", u8DevNum); + g_fd[ViPipe] = open(acDevFile, O_RDWR, S_IRUSR | S_IWUSR); + if (g_fd[ViPipe] < 0) { + ISP_TRACE(MODULE_DBG_ERR, "Open /dev/i2c_drv-%u error!\n", u8DevNum); + return GK_FAILURE; + } + + ret = ioctl(g_fd[ViPipe], I2C_SLAVE_FORCE, (mis2008_i2c_addr >> 1)); + if (ret < 0) { + ISP_TRACE(MODULE_DBG_ERR, "I2C_SLAVE_FORCE error!\n"); + close(g_fd[ViPipe]); + g_fd[ViPipe] = -1; + return ret; + } +#endif + + return GK_SUCCESS; +} + +int mis2008_i2c_exit(VI_PIPE ViPipe) +{ + if (g_fd[ViPipe] >= 0) { + close(g_fd[ViPipe]); + g_fd[ViPipe] = -1; + return GK_SUCCESS; + } + return GK_FAILURE; +} + +struct i2c_rdwr_ioctl_data { + struct i2c_msg *msgs; + unsigned int nmsgs; +}; + +int mis2008_read_register(VI_PIPE ViPipe, GK_U32 addr) +{ + GK_S32 s32RegVal = 0; + + if (g_fd[ViPipe] < 0) { + ISP_TRACE(MODULE_DBG_ERR, "mis2008_read_register fd not opened!\n"); + return GK_FAILURE; + } + + GK_S32 s32Ret = 0; + GK_U32 u32RegWidth = mis2008_addr_byte; + GK_U32 u32DataWidth = mis2008_data_byte; + GK_U8 aRecvbuf[4]; + +#ifdef LOSCFG_HOST_TYPE_VENDOR + GK_U32 u32SnsI2cAddr = (mis2008_i2c_addr >> 1); + struct i2c_rdwr_ioctl_data stRdwr; + struct i2c_msg astMsg[2]; + memset(&stRdwr, 0x0, sizeof(stRdwr)); + memset(astMsg, 0x0, sizeof(astMsg)); +#endif + + memset(aRecvbuf, 0x0, sizeof(aRecvbuf)); + +#ifdef LOSCFG_HOST_TYPE_VENDOR + astMsg[0].addr = u32SnsI2cAddr; + astMsg[0].flags = 0; + astMsg[0].len = u32RegWidth; + astMsg[0].buf = aRecvbuf; + + astMsg[1].addr = u32SnsI2cAddr; + astMsg[1].flags = 0; + astMsg[1].flags |= I2C_M_RD; + astMsg[1].len = u32DataWidth; + astMsg[1].buf = aRecvbuf; + stRdwr.msgs = &astMsg[0]; + stRdwr.nmsgs = 2; +#endif + +#ifdef LOSCFG_HOST_TYPE_VENDOR + if (u32RegWidth == 2) { + aRecvbuf[0] = (addr >> 8) & 0xff; + aRecvbuf[1] = addr & 0xff; + } else { + aRecvbuf[0] = addr & 0xff; + } + s32Ret = ioctl(g_fd[ViPipe], I2C_RDWR, &stRdwr); +#else + if (u32RegWidth == 2) { + aRecvbuf[0] = addr & 0xff; + aRecvbuf[1] = (addr >> 8) & 0xff; + } else { + aRecvbuf[0] = addr & 0xff; + } + s32Ret = read(g_fd[ViPipe], aRecvbuf, u32RegWidth + u32DataWidth); +#endif + + if (s32Ret < 0) { + return GK_FAILURE; + } + + if (u32DataWidth == 2) { + s32RegVal = aRecvbuf[0] | (aRecvbuf[1] << 8); + } else { + s32RegVal = aRecvbuf[0]; + } + + return s32RegVal; +} + +int mis2008_write_register(VI_PIPE ViPipe, GK_U32 addr, GK_U32 data) +{ + if (g_fd[ViPipe] < 0) { + return GK_SUCCESS; + } + +#ifdef GPIO_I2C + i2c_data.dev_addr = mis2008_i2c_addr; + i2c_data.reg_addr = addr; + i2c_data.addr_byte_num = mis2008_addr_byte; + i2c_data.data = data; + i2c_data.data_byte_num = mis2008_data_byte; + + ret = ioctl(g_fd[ViPipe], GPIO_I2C_WRITE, &i2c_data); + if (ret) { + ISP_TRACE(MODULE_DBG_ERR, "GPIO-I2C write faild!\n"); + return ret; + } +#else + int idx = 0; + int ret; + char buf[8]; + + if (mis2008_addr_byte == 2) { + buf[idx] = (addr >> 8) & 0xff; + idx++; + buf[idx] = addr & 0xff; + idx++; + } else { + } + + if (mis2008_data_byte == 2) { + } else { + buf[idx] = data & 0xff; + idx++; + } + + ret = write(g_fd[ViPipe], buf, mis2008_addr_byte + mis2008_data_byte); + if (ret < 0) { + ISP_TRACE(MODULE_DBG_ERR, "I2C_WRITE error!\n"); + return GK_FAILURE; + } + +#endif + return GK_SUCCESS; +} + +void mis2008_standby(VI_PIPE ViPipe) +{ + mis2008_write_register(ViPipe, 0x3006, 0x02); + return; +} + +void mis2008_restart(VI_PIPE ViPipe) +{ + mis2008_write_register(ViPipe, 0x3006, 0x01); + return; +} + +static void delay_ms(int ms) +{ + usleep(ms * 1000); +} + +#define MIS2008_SENSOR_1080P_30FPS_LINEAR_MODE (1) +#define MIS2008_SENSOR_1080P_30FPS_2t1_WDR_MODE (2) + +void mis2008_linear_1080p30_init(VI_PIPE ViPipe); +void mis2008_linear_1080p30_10b_init(VI_PIPE ViPipe); +void mis2008_default_reg_init(VI_PIPE ViPipe) +{ + GK_U32 i; + for (i = 0; i < g_pastMis2008[ViPipe]->astRegsInfo[0].u32RegNum; i++) { + mis2008_write_register(ViPipe, g_pastMis2008[ViPipe]->astRegsInfo[0].astI2cData[i].u32RegAddr, + g_pastMis2008[ViPipe]->astRegsInfo[0].astI2cData[i].u32Data); + } +} +void mis2008_init(VI_PIPE ViPipe) +{ + GK_U8 u8ImgMode; + + u8ImgMode = g_pastMis2008[ViPipe]->u8ImgMode; + mis2008_i2c_init(ViPipe); + switch (u8ImgMode) { + case MIS2008_SENSOR_1080P_30FPS_2t1_WDR_MODE: + break; + case MIS2008_SENSOR_1080P_30FPS_LINEAR_MODE: + // mis2008_linear_1080p30_init(ViPipe); + mis2008_linear_1080p30_10b_init(ViPipe); + break; + default: + ISP_TRACE(MODULE_DBG_ERR, "Not Support Image Mode %d\n", u8ImgMode); + break; + } + + delay_ms(10); + mis2008_default_reg_init(ViPipe); + g_pastMis2008[ViPipe]->bInit = GK_TRUE; + return; +} + +void mis2008_exit(VI_PIPE ViPipe) +{ + mis2008_i2c_exit(ViPipe); + + return; +} + +void mis2008_linear_1080p30_init(VI_PIPE ViPipe) +{ + /* [ParaList] */ + mis2008_write_register(ViPipe, 0x300a, 0x01); + mis2008_write_register(ViPipe, 0x3006, 0x02); + mis2008_write_register(ViPipe, 0x3201, 0x46); + mis2008_write_register(ViPipe, 0x3200, 0x05); + mis2008_write_register(ViPipe, 0x3203, 0xc0); + mis2008_write_register(ViPipe, 0x3202, 0x08); + + mis2008_write_register(ViPipe, 0x3205, 0x05); + mis2008_write_register(ViPipe, 0x3204, 0x00); + mis2008_write_register(ViPipe, 0x3207, 0x40); + mis2008_write_register(ViPipe, 0x3206, 0x04); + + mis2008_write_register(ViPipe, 0x3209, 0x0a); + mis2008_write_register(ViPipe, 0x3208, 0x00); + mis2008_write_register(ViPipe, 0x320b, 0x89); + mis2008_write_register(ViPipe, 0x320a, 0x07); + + //mis2008_write_register(ViPipe, 0x3007 ,0x00); + mis2008_write_register(ViPipe, 0x3007, 0x00); + mis2008_write_register(ViPipe, 0x3300, 0x1c); // PLL_FBDIV + mis2008_write_register(ViPipe, 0x3301, 0x00); + mis2008_write_register(ViPipe, 0x3302, 0x02); + mis2008_write_register(ViPipe, 0x3303, 0x05); + mis2008_write_register(ViPipe, 0x330d, 0x00); // 12 bit + mis2008_write_register(ViPipe, 0x3011, 0x2c); // 12 bit + // mis2008_write_register(ViPipe, 0x330d ,0x01); // 10 bit + // mis2008_write_register(ViPipe, 0x3011 ,0x2b); // 10 bit + mis2008_write_register(ViPipe, 0x330b, 0x01); + mis2008_write_register(ViPipe, 0x330f, 0x0f); + mis2008_write_register(ViPipe, 0x3013, 0x00); + mis2008_write_register(ViPipe, 0x3637, 0x1e); + mis2008_write_register(ViPipe, 0x3900, 0x07); + mis2008_write_register(ViPipe, 0x2107, 0x00); + mis2008_write_register(ViPipe, 0x330e, 0x00); + + mis2008_write_register(ViPipe, 0x3900, 0x07); + mis2008_write_register(ViPipe, 0x2108, 0x01); + mis2008_write_register(ViPipe, 0x3c40, 0x8c); + mis2008_write_register(ViPipe, 0x3b01, 0x3f); + mis2008_write_register(ViPipe, 0x3b03, 0x3f); + mis2008_write_register(ViPipe, 0x3902, 0x01); + mis2008_write_register(ViPipe, 0x3904, 0x00); + mis2008_write_register(ViPipe, 0x3903, 0x00); + mis2008_write_register(ViPipe, 0x3906, 0x1e); + mis2008_write_register(ViPipe, 0x3905, 0x00); + mis2008_write_register(ViPipe, 0x3908, 0x71); + mis2008_write_register(ViPipe, 0x3907, 0x10); + mis2008_write_register(ViPipe, 0x390a, 0xff); + mis2008_write_register(ViPipe, 0x3909, 0x1f); + mis2008_write_register(ViPipe, 0x390c, 0x67); + mis2008_write_register(ViPipe, 0x390b, 0x03); + mis2008_write_register(ViPipe, 0x390e, 0x77); + mis2008_write_register(ViPipe, 0x390d, 0x00); + mis2008_write_register(ViPipe, 0x3910, 0x71); + mis2008_write_register(ViPipe, 0x390f, 0x10); + mis2008_write_register(ViPipe, 0x3912, 0xff); + mis2008_write_register(ViPipe, 0x3911, 0x1f); + mis2008_write_register(ViPipe, 0x3919, 0x00); + mis2008_write_register(ViPipe, 0x3918, 0x00); + mis2008_write_register(ViPipe, 0x391b, 0x91); + mis2008_write_register(ViPipe, 0x391a, 0x01); + mis2008_write_register(ViPipe, 0x3983, 0x5a); + mis2008_write_register(ViPipe, 0x3982, 0x00); + mis2008_write_register(ViPipe, 0x3985, 0x0f); + mis2008_write_register(ViPipe, 0x3984, 0x00); + mis2008_write_register(ViPipe, 0x391d, 0x00); + mis2008_write_register(ViPipe, 0x391c, 0x00); + mis2008_write_register(ViPipe, 0x391f, 0x65); + mis2008_write_register(ViPipe, 0x391e, 0x10); + mis2008_write_register(ViPipe, 0x3921, 0xff); + mis2008_write_register(ViPipe, 0x3920, 0x1f); + mis2008_write_register(ViPipe, 0x3923, 0xff); + mis2008_write_register(ViPipe, 0x3922, 0x1f); + mis2008_write_register(ViPipe, 0x3932, 0x00); + mis2008_write_register(ViPipe, 0x3931, 0x00); + mis2008_write_register(ViPipe, 0x3934, 0x65); + mis2008_write_register(ViPipe, 0x3933, 0x01); + mis2008_write_register(ViPipe, 0x393f, 0x6c); + mis2008_write_register(ViPipe, 0x393e, 0x00); + mis2008_write_register(ViPipe, 0x3941, 0x67); + mis2008_write_register(ViPipe, 0x3940, 0x00); + mis2008_write_register(ViPipe, 0x3943, 0x55); + mis2008_write_register(ViPipe, 0x3942, 0x01); + mis2008_write_register(ViPipe, 0x3945, 0xc2); + mis2008_write_register(ViPipe, 0x3944, 0x02); + mis2008_write_register(ViPipe, 0x3925, 0x95); + mis2008_write_register(ViPipe, 0x3924, 0x00); + mis2008_write_register(ViPipe, 0x3927, 0xe1); + mis2008_write_register(ViPipe, 0x3926, 0x02); + mis2008_write_register(ViPipe, 0x3947, 0x74); + mis2008_write_register(ViPipe, 0x3946, 0x01); + mis2008_write_register(ViPipe, 0x3949, 0xda); + mis2008_write_register(ViPipe, 0x3948, 0x0e); + mis2008_write_register(ViPipe, 0x394b, 0x42); + mis2008_write_register(ViPipe, 0x394a, 0x03); + mis2008_write_register(ViPipe, 0x394d, 0xf2); + mis2008_write_register(ViPipe, 0x394c, 0x01); + mis2008_write_register(ViPipe, 0x3913, 0x01); + mis2008_write_register(ViPipe, 0x3915, 0x0f); + mis2008_write_register(ViPipe, 0x3914, 0x00); + mis2008_write_register(ViPipe, 0x3917, 0x67); + mis2008_write_register(ViPipe, 0x3916, 0x03); + mis2008_write_register(ViPipe, 0x392a, 0x1e); + mis2008_write_register(ViPipe, 0x3929, 0x00); + mis2008_write_register(ViPipe, 0x392c, 0x0f); + mis2008_write_register(ViPipe, 0x392b, 0x00); + mis2008_write_register(ViPipe, 0x392e, 0x0f); + mis2008_write_register(ViPipe, 0x392d, 0x00); + mis2008_write_register(ViPipe, 0x3930, 0x6e); + mis2008_write_register(ViPipe, 0x392f, 0x03); + mis2008_write_register(ViPipe, 0x397f, 0x00); + mis2008_write_register(ViPipe, 0x397e, 0x00); + mis2008_write_register(ViPipe, 0x3981, 0x77); + mis2008_write_register(ViPipe, 0x3980, 0x00); + mis2008_write_register(ViPipe, 0x395d, 0x80); + mis2008_write_register(ViPipe, 0x395c, 0x10); + mis2008_write_register(ViPipe, 0x3962, 0x9e); + mis2008_write_register(ViPipe, 0x3961, 0x10); + mis2008_write_register(ViPipe, 0x3977, 0x22); + mis2008_write_register(ViPipe, 0x3976, 0x00); + mis2008_write_register(ViPipe, 0x3978, 0x00); + mis2008_write_register(ViPipe, 0x3979, 0x04); + mis2008_write_register(ViPipe, 0x396d, 0xc2); + mis2008_write_register(ViPipe, 0x396c, 0x02); + mis2008_write_register(ViPipe, 0x396f, 0xc2); + mis2008_write_register(ViPipe, 0x396e, 0x02); + mis2008_write_register(ViPipe, 0x3971, 0xc2); + mis2008_write_register(ViPipe, 0x3970, 0x02); + mis2008_write_register(ViPipe, 0x3973, 0xc2); + mis2008_write_register(ViPipe, 0x3972, 0x02); + + mis2008_write_register(ViPipe, 0x3900, 0x01); + mis2008_write_register(ViPipe, 0x3600, 0x00); + mis2008_write_register(ViPipe, 0x3707, 0x00); + mis2008_write_register(ViPipe, 0x3708, 0x80); + mis2008_write_register(ViPipe, 0x3709, 0x00); + mis2008_write_register(ViPipe, 0x370a, 0x80); + mis2008_write_register(ViPipe, 0x370b, 0x00); + mis2008_write_register(ViPipe, 0x370c, 0x80); + mis2008_write_register(ViPipe, 0x370d, 0x00); + mis2008_write_register(ViPipe, 0x370e, 0x80); + mis2008_write_register(ViPipe, 0x3006, 0x00); + + mis2008_write_register(ViPipe, 0x3012, 0x01); + mis2008_write_register(ViPipe, 0x3600, 0x13); + mis2008_write_register(ViPipe, 0x3601, 0x02); + mis2008_write_register(ViPipe, 0x360e, 0x00); + mis2008_write_register(ViPipe, 0x360f, 0x00); + mis2008_write_register(ViPipe, 0x3610, 0x02); + mis2008_write_register(ViPipe, 0x3707, 0x00); + mis2008_write_register(ViPipe, 0x3708, 0x40); + mis2008_write_register(ViPipe, 0x3709, 0x00); + mis2008_write_register(ViPipe, 0x370a, 0x40); + mis2008_write_register(ViPipe, 0x370b, 0x00); + mis2008_write_register(ViPipe, 0x370c, 0x40); + mis2008_write_register(ViPipe, 0x370d, 0x00); + mis2008_write_register(ViPipe, 0x370e, 0x40); + mis2008_write_register(ViPipe, 0x3800, 0x00); // Tsensor + mis2008_write_register(ViPipe, 0x3a03, 0x03); + mis2008_write_register(ViPipe, 0x3a02, 0x0b); + mis2008_write_register(ViPipe, 0x3a08, 0x34); + mis2008_write_register(ViPipe, 0x3a1b, 0x54); + mis2008_write_register(ViPipe, 0x3a1e, 0x80); + mis2008_write_register(ViPipe, 0x3100, 0x04); + mis2008_write_register(ViPipe, 0x3101, 0x64); + mis2008_write_register(ViPipe, 0x3a1c, 0x10); + mis2008_write_register(ViPipe, 0x3a0C, 0x04); + mis2008_write_register(ViPipe, 0x3a0D, 0x12); + mis2008_write_register(ViPipe, 0x3a0E, 0x15); + mis2008_write_register(ViPipe, 0x3a0F, 0x18); + mis2008_write_register(ViPipe, 0x3a10, 0x20); + mis2008_write_register(ViPipe, 0x3a11, 0x3c); + + delay_ms(100); + + printf("===MIS2008 1080P 30fps 12bit LINE Init OK!===\n"); +} + +void mis2008_linear_1080p30_10b_init(VI_PIPE ViPipe) +{ + mis2008_write_register(ViPipe, 0x300a, 0x01); + mis2008_write_register(ViPipe, 0x3006, 0x02); + mis2008_write_register(ViPipe, 0x3201, 0x65); + mis2008_write_register(ViPipe, 0x3200, 0x04); + mis2008_write_register(ViPipe, 0x3203, 0xc0); + mis2008_write_register(ViPipe, 0x3202, 0x08); + mis2008_write_register(ViPipe, 0x3205, 0x00); + mis2008_write_register(ViPipe, 0x3204, 0x00); + mis2008_write_register(ViPipe, 0x3207, 0x37); + mis2008_write_register(ViPipe, 0x3206, 0x04); + mis2008_write_register(ViPipe, 0x3209, 0x00); + mis2008_write_register(ViPipe, 0x3208, 0x00); + mis2008_write_register(ViPipe, 0x320b, 0x7f); + mis2008_write_register(ViPipe, 0x320a, 0x07); + mis2008_write_register(ViPipe, 0x3007, 0x00); + mis2008_write_register(ViPipe, 0x3300, 0x1c); + mis2008_write_register(ViPipe, 0x3301, 0x00); + mis2008_write_register(ViPipe, 0x3302, 0x02); + mis2008_write_register(ViPipe, 0x3303, 0x05); + mis2008_write_register(ViPipe, 0x330d, 0x01); + mis2008_write_register(ViPipe, 0x330b, 0x01); + mis2008_write_register(ViPipe, 0x330f, 0x0f); + mis2008_write_register(ViPipe, 0x3013, 0x00); + mis2008_write_register(ViPipe, 0x3011, 0x2b); + mis2008_write_register(ViPipe, 0x3c20, 0x2b); + mis2008_write_register(ViPipe, 0x3c21, 0x6b); + mis2008_write_register(ViPipe, 0x3c22, 0xab); + mis2008_write_register(ViPipe, 0x3c23, 0xeb); + mis2008_write_register(ViPipe, 0x3900, 0x07); + mis2008_write_register(ViPipe, 0x2107, 0x00); + mis2008_write_register(ViPipe, 0x2108, 0x01); + mis2008_write_register(ViPipe, 0x3c16, 0x02); + mis2008_write_register(ViPipe, 0x3c17, 0xdc); + mis2008_write_register(ViPipe, 0x3c18, 0x6c); + mis2008_write_register(ViPipe, 0x3c40, 0x8d); + mis2008_write_register(ViPipe, 0x3b01, 0x3f); + mis2008_write_register(ViPipe, 0x3b03, 0x3f); + mis2008_write_register(ViPipe, 0x3902, 0x01); + mis2008_write_register(ViPipe, 0x3904, 0x00); + mis2008_write_register(ViPipe, 0x3903, 0x00); + mis2008_write_register(ViPipe, 0x3906, 0x1e); + mis2008_write_register(ViPipe, 0x3905, 0x00); + mis2008_write_register(ViPipe, 0x3908, 0x71); + mis2008_write_register(ViPipe, 0x3907, 0x10); + mis2008_write_register(ViPipe, 0x390a, 0xff); + mis2008_write_register(ViPipe, 0x3909, 0x1f); + mis2008_write_register(ViPipe, 0x390c, 0x67); + mis2008_write_register(ViPipe, 0x390b, 0x03); + mis2008_write_register(ViPipe, 0x390e, 0x40); + mis2008_write_register(ViPipe, 0x390d, 0x00); + mis2008_write_register(ViPipe, 0x3910, 0x71); + mis2008_write_register(ViPipe, 0x390f, 0x10); + mis2008_write_register(ViPipe, 0x3912, 0xff); + mis2008_write_register(ViPipe, 0x3911, 0x1f); + mis2008_write_register(ViPipe, 0x3919, 0x00); + mis2008_write_register(ViPipe, 0x3918, 0x00); + mis2008_write_register(ViPipe, 0x391b, 0x91); + mis2008_write_register(ViPipe, 0x391a, 0x01); + mis2008_write_register(ViPipe, 0x3983, 0x5a); + mis2008_write_register(ViPipe, 0x3982, 0x00); + mis2008_write_register(ViPipe, 0x3985, 0x0f); + mis2008_write_register(ViPipe, 0x3984, 0x00); + mis2008_write_register(ViPipe, 0x391d, 0x00); + mis2008_write_register(ViPipe, 0x391c, 0x00); + mis2008_write_register(ViPipe, 0x391f, 0x65); + mis2008_write_register(ViPipe, 0x391e, 0x10); + mis2008_write_register(ViPipe, 0x3921, 0xff); + mis2008_write_register(ViPipe, 0x3920, 0x1f); + mis2008_write_register(ViPipe, 0x3923, 0xff); + mis2008_write_register(ViPipe, 0x3922, 0x1f); + mis2008_write_register(ViPipe, 0x3932, 0x00); + mis2008_write_register(ViPipe, 0x3931, 0x00); + mis2008_write_register(ViPipe, 0x3934, 0x65); + mis2008_write_register(ViPipe, 0x3933, 0x01); + mis2008_write_register(ViPipe, 0x393f, 0x6c); + mis2008_write_register(ViPipe, 0x393e, 0x00); + mis2008_write_register(ViPipe, 0x3941, 0x67); + mis2008_write_register(ViPipe, 0x3940, 0x00); + mis2008_write_register(ViPipe, 0x3943, 0x50); + mis2008_write_register(ViPipe, 0x3942, 0x01); + mis2008_write_register(ViPipe, 0x3945, 0xc2); + mis2008_write_register(ViPipe, 0x3944, 0x02); + mis2008_write_register(ViPipe, 0x3925, 0x95); + mis2008_write_register(ViPipe, 0x3924, 0x00); + mis2008_write_register(ViPipe, 0x3927, 0xe1); + mis2008_write_register(ViPipe, 0x3926, 0x02); + mis2008_write_register(ViPipe, 0x3947, 0x74); + mis2008_write_register(ViPipe, 0x3946, 0x01); + mis2008_write_register(ViPipe, 0x3949, 0xda); + mis2008_write_register(ViPipe, 0x3948, 0x0e); + mis2008_write_register(ViPipe, 0x394b, 0x42); + mis2008_write_register(ViPipe, 0x394a, 0x03); + mis2008_write_register(ViPipe, 0x394d, 0xf2); + mis2008_write_register(ViPipe, 0x394c, 0x01); + mis2008_write_register(ViPipe, 0x3913, 0x01); + mis2008_write_register(ViPipe, 0x3915, 0x0f); + mis2008_write_register(ViPipe, 0x3914, 0x00); + mis2008_write_register(ViPipe, 0x3917, 0x67); + mis2008_write_register(ViPipe, 0x3916, 0x03); + mis2008_write_register(ViPipe, 0x392a, 0x1e); + mis2008_write_register(ViPipe, 0x3929, 0x00); + mis2008_write_register(ViPipe, 0x392c, 0x0f); + mis2008_write_register(ViPipe, 0x392b, 0x00); + mis2008_write_register(ViPipe, 0x392e, 0x0f); + mis2008_write_register(ViPipe, 0x392d, 0x00); + mis2008_write_register(ViPipe, 0x3930, 0x6e); + mis2008_write_register(ViPipe, 0x392f, 0x03); + mis2008_write_register(ViPipe, 0x397f, 0x00); + mis2008_write_register(ViPipe, 0x397e, 0x00); + mis2008_write_register(ViPipe, 0x3981, 0x40); + mis2008_write_register(ViPipe, 0x3980, 0x00); + mis2008_write_register(ViPipe, 0x395d, 0x80); + mis2008_write_register(ViPipe, 0x395c, 0x10); + mis2008_write_register(ViPipe, 0x3962, 0x9e); + mis2008_write_register(ViPipe, 0x3961, 0x10); + mis2008_write_register(ViPipe, 0x3967, 0x50); + mis2008_write_register(ViPipe, 0x3977, 0x22); + mis2008_write_register(ViPipe, 0x3976, 0x00); + mis2008_write_register(ViPipe, 0x3978, 0x00); + mis2008_write_register(ViPipe, 0x3979, 0x04); + mis2008_write_register(ViPipe, 0x396d, 0xc2); + mis2008_write_register(ViPipe, 0x396c, 0x02); + mis2008_write_register(ViPipe, 0x396f, 0xc2); + mis2008_write_register(ViPipe, 0x396e, 0x02); + mis2008_write_register(ViPipe, 0x3971, 0xc2); + mis2008_write_register(ViPipe, 0x3970, 0x02); + mis2008_write_register(ViPipe, 0x3973, 0xc2); + mis2008_write_register(ViPipe, 0x3972, 0x02); + mis2008_write_register(ViPipe, 0x3900, 0x00); + mis2008_write_register(ViPipe, 0x3012, 0x01); + mis2008_write_register(ViPipe, 0x3600, 0x13); + mis2008_write_register(ViPipe, 0x3601, 0x02); + mis2008_write_register(ViPipe, 0x360e, 0x00); + mis2008_write_register(ViPipe, 0x360f, 0x00); + mis2008_write_register(ViPipe, 0x3610, 0x02); + mis2008_write_register(ViPipe, 0x3637, 0x1e); + mis2008_write_register(ViPipe, 0x3701, 0xa0); + mis2008_write_register(ViPipe, 0x3707, 0x00); + mis2008_write_register(ViPipe, 0x3708, 0x40); + mis2008_write_register(ViPipe, 0x3709, 0x00); + mis2008_write_register(ViPipe, 0x370a, 0x40); + mis2008_write_register(ViPipe, 0x370b, 0x00); + mis2008_write_register(ViPipe, 0x370c, 0x40); + mis2008_write_register(ViPipe, 0x370d, 0x00); + mis2008_write_register(ViPipe, 0x370e, 0x40); + mis2008_write_register(ViPipe, 0x3800, 0x00); + mis2008_write_register(ViPipe, 0x3a03, 0x09); + mis2008_write_register(ViPipe, 0x3a02, 0x0b); + mis2008_write_register(ViPipe, 0x3a08, 0x34); + mis2008_write_register(ViPipe, 0x3a1b, 0x50); + mis2008_write_register(ViPipe, 0x3a16, 0x4d); + mis2008_write_register(ViPipe, 0x3a1e, 0x01); + mis2008_write_register(ViPipe, 0x3a1c, 0x1f); + mis2008_write_register(ViPipe, 0x3a0c, 0x04); + mis2008_write_register(ViPipe, 0x3a0d, 0x12); + mis2008_write_register(ViPipe, 0x3a0e, 0x15); + mis2008_write_register(ViPipe, 0x3a0f, 0x18); + mis2008_write_register(ViPipe, 0x3a10, 0x20); + mis2008_write_register(ViPipe, 0x3a11, 0x3c); + mis2008_write_register(ViPipe, 0x3006, 0x00); + printf("===MIS2008 1080P 30fps 10bit LINE Init OK!===\n"); +} \ No newline at end of file