mirror of
https://github.com/sipeed/LicheeRV-Nano-Build.git
synced 2026-09-10 20:59:59 -05:00
* support ov2685
This commit is contained in:
@@ -78,6 +78,7 @@ sensor-$(CONFIG_SENSOR_NEXTCHIP_N6) += nextchip_n6
|
||||
sensor-$(CONFIG_SENSOR_OV_OS04A10) += ov_os04a10
|
||||
sensor-$(CONFIG_SENSOR_OV_OS04C10) += ov_os04c10
|
||||
sensor-$(CONFIG_SENSOR_OV_OS08A20) += ov_os08a20
|
||||
sensor-$(CONFIG_SENSOR_OV_OV2685) += ov_ov2685
|
||||
sensor-$(CONFIG_SENSOR_OV_OV4689) += ov_ov4689
|
||||
sensor-$(CONFIG_SENSOR_OV_OV5647) += ov_ov5647
|
||||
sensor-$(CONFIG_SENSOR_OV_OV6211) += ov_ov6211
|
||||
|
||||
@@ -101,6 +101,9 @@ ov_os04c10:
|
||||
ov_os08a20:
|
||||
$(call MAKE_SENSOR, ${@})
|
||||
|
||||
ov_ov2685:
|
||||
$(call MAKE_SENSOR, ${@})
|
||||
|
||||
ov_ov4689:
|
||||
$(call MAKE_SENSOR, ${@})
|
||||
|
||||
|
||||
36
middleware/v2/component/isp/sensor/cv182x/ov_ov2685/Makefile
Normal file
36
middleware/v2/component/isp/sensor/cv182x/ov_ov2685/Makefile
Normal file
@@ -0,0 +1,36 @@
|
||||
SHELL = /bin/bash
|
||||
ifeq ($(PARAM_FILE), )
|
||||
PARAM_FILE=../../../../../../$(shell echo $(MW_VER))/Makefile.param
|
||||
include $(PARAM_FILE)
|
||||
endif
|
||||
|
||||
SDIR = $(PWD)
|
||||
SRCS = $(wildcard $(SDIR)/*.c)
|
||||
INCS = -I$(MW_INC) -I$(ISP_INC) -I$(KERNEL_INC) -I./include
|
||||
OBJS = $(SRCS:.c=.o)
|
||||
DEPS = $(SRCS:.c=.d)
|
||||
TARGET_A = $(MW_LIB)/libov_ov2685.a
|
||||
TARGET_SO = $(MW_LIB)/libov_ov2685.so
|
||||
|
||||
EXTRA_CFLAGS = $(INCS)
|
||||
EXTRA_LDFLAGS =
|
||||
|
||||
.PHONY : clean all
|
||||
all : $(TARGET_A) $(TARGET_SO)
|
||||
|
||||
$(SDIR)/%.o: $(SDIR)/%.c
|
||||
@$(CC) $(DEPFLAGS) $(CFLAGS) $(EXTRA_CFLAGS) -c $< -o $@
|
||||
@echo [$(notdir $(CC))] $(notdir $@)
|
||||
|
||||
$(TARGET_A): $(OBJS)
|
||||
@$(AR) $(ARFLAGS) $@ $(OBJS)
|
||||
@echo -e $(YELLOW)[LINK]$(END)[$(notdir $(AR))] $(notdir $(TARGET_A))
|
||||
|
||||
$(TARGET_SO): $(OBJS)
|
||||
@$(LD) $(LDFLAGS) $(EXTRA_LDFLAGS) -o $@ --start-group $(OBJS) --end-group
|
||||
@echo -e $(GREEN)[LINK]$(END)[$(notdir $(LD))] $(notdir $(TARGET_SO))
|
||||
|
||||
clean:
|
||||
@rm -f $(OBJS) $(DEPS) $(TARGET_A) $(TARGET_SO)
|
||||
|
||||
-include $(DEPS)
|
||||
@@ -0,0 +1,972 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <syslog.h>
|
||||
#include <errno.h>
|
||||
#ifdef ARCH_CV182X
|
||||
#include "cvi_type.h"
|
||||
#include "cvi_comm_video.h"
|
||||
#include <linux/cvi_vip_snsr.h>
|
||||
#else
|
||||
#include <linux/cvi_type.h>
|
||||
#include <linux/cvi_comm_video.h>
|
||||
#include <linux/vi_snsr.h>
|
||||
#endif
|
||||
#include "cvi_debug.h"
|
||||
#include "cvi_comm_sns.h"
|
||||
#include "cvi_sns_ctrl.h"
|
||||
#include "cvi_ae_comm.h"
|
||||
#include "cvi_awb_comm.h"
|
||||
#include "cvi_ae.h"
|
||||
#include "cvi_awb.h"
|
||||
#include "cvi_isp.h"
|
||||
|
||||
#include "ov2685_cmos_ex.h"
|
||||
#include "ov2685_cmos_param.h"
|
||||
|
||||
#define DIV_0_TO_1(a) ((0 == (a)) ? 1 : (a))
|
||||
#define DIV_0_TO_1_FLOAT(a) ((((a) < 1E-10) && ((a) > -1E-10)) ? 1 : (a))
|
||||
#define OV2685_ID 2685
|
||||
#define OV2685_I2C_ADDR_1 0x10
|
||||
#define OV2685_I2C_ADDR_2 0x3c
|
||||
#define OV2685_I2C_ADDR_IS_VALID(addr) ((addr) == OV2685_I2C_ADDR_1 || (addr) == OV2685_I2C_ADDR_2)
|
||||
|
||||
/****************************************************************************
|
||||
* global variables *
|
||||
***************************************************************************/
|
||||
|
||||
ISP_SNS_STATE_S *g_pastOv2685[VI_MAX_PIPE_NUM] = {CVI_NULL};
|
||||
|
||||
#define OV2685_SENSOR_GET_CTX(dev, pstCtx) (pstCtx = g_pastOv2685[dev])
|
||||
#define OV2685_SENSOR_SET_CTX(dev, pstCtx) (g_pastOv2685[dev] = pstCtx)
|
||||
#define OV2685_SENSOR_RESET_CTX(dev) (g_pastOv2685[dev] = CVI_NULL)
|
||||
|
||||
ISP_SNS_COMMBUS_U g_aunOv2685_BusInfo[VI_MAX_PIPE_NUM] = {
|
||||
// for licheervnano
|
||||
[0] = { .s8I2cDev = 4},
|
||||
[1 ... VI_MAX_PIPE_NUM - 1] = { .s8I2cDev = -1}
|
||||
};
|
||||
|
||||
ISP_SNS_MIRRORFLIP_TYPE_E g_aeOv2685_MirrorFip[VI_MAX_PIPE_NUM] = {0};
|
||||
|
||||
CVI_U16 g_au16Ov2685_GainMode[VI_MAX_PIPE_NUM] = {0};
|
||||
|
||||
/****************************************************************************
|
||||
* local variables and functions *
|
||||
***************************************************************************/
|
||||
static ISP_FSWDR_MODE_E genFSWDRMode[VI_MAX_PIPE_NUM] = {
|
||||
[0 ... VI_MAX_PIPE_NUM - 1] = ISP_FSWDR_NORMAL_MODE
|
||||
};
|
||||
|
||||
static CVI_U32 gu32MaxTimeGetCnt[VI_MAX_PIPE_NUM] = {0};
|
||||
static CVI_U32 g_au32InitExposure[VI_MAX_PIPE_NUM] = {0};
|
||||
static CVI_U32 g_au32LinesPer500ms[VI_MAX_PIPE_NUM] = {0};
|
||||
static CVI_U16 g_au16InitWBGain[VI_MAX_PIPE_NUM][3] = {{0} };
|
||||
static CVI_U16 g_au16SampleRgain[VI_MAX_PIPE_NUM] = {0};
|
||||
static CVI_U16 g_au16SampleBgain[VI_MAX_PIPE_NUM] = {0};
|
||||
static CVI_S32 cmos_get_wdr_size(VI_PIPE ViPipe, ISP_SNS_ISP_INFO_S *pstIspCfg);
|
||||
/*****Ov2685 Lines Range*****/
|
||||
#define OV2685_FULL_LINES_MAX (0x3fff)
|
||||
|
||||
/*****Ov2685 Register Address*****/
|
||||
#define OV2685_EXP_H_ADDR 0x0202 //bit[13:8]
|
||||
#define OV2685_EXP_L_ADDR 0x0203
|
||||
|
||||
#define OV2685_AGAIN_H_ADDR 0x02b4 //bit[10:8]
|
||||
#define OV2685_AGAIN_L_ADDR 0x02b3
|
||||
#define OV2685_COL_AGAIN_H_ADDR 0x02b8 //bit[13:8]
|
||||
#define OV2685_COL_AGAIN_L_ADDR 0x02b9
|
||||
#define OV2685_DGAIN_H_ADDR 0x020e //bit[9:6]
|
||||
#define OV2685_DGAIN_L_ADDR 0x020f //bit[5:0]
|
||||
#define OV2685_AGAIN_MAG1_ADDR 0x0515
|
||||
#define OV2685_AGAIN_MAG2_ADDR 0x0519
|
||||
#define OV2685_AGAIN_MAG3_ADDR 0x02d9
|
||||
|
||||
#define OV2685_VTS_H_ADDR 0x0340 //bit[13:8]
|
||||
#define OV2685_VTS_L_ADDR 0x0341
|
||||
|
||||
#define OV2685_FLIP_MIRROR_ADDR 0x0101
|
||||
#define OV2685_FRAME_BUF_ADDR 0x031D
|
||||
|
||||
#define OV2685_RES_IS_1600X1200(w, h) ((w) == 1600 && (h) == 1200)
|
||||
|
||||
static CVI_S32 cmos_get_ae_default(VI_PIPE ViPipe, AE_SENSOR_DEFAULT_S *pstAeSnsDft)
|
||||
{
|
||||
ISP_SNS_STATE_S *pstSnsState = CVI_NULL;
|
||||
|
||||
CMOS_CHECK_POINTER(pstAeSnsDft);
|
||||
OV2685_SENSOR_GET_CTX(ViPipe, pstSnsState);
|
||||
CMOS_CHECK_POINTER(pstSnsState);
|
||||
|
||||
pstAeSnsDft->u32FullLinesStd = pstSnsState->u32FLStd;
|
||||
pstAeSnsDft->u32FlickerFreq = 50 * 256;
|
||||
pstAeSnsDft->u32FullLinesMax = OV2685_FULL_LINES_MAX;
|
||||
pstAeSnsDft->u32HmaxTimes = (1000000) / (pstSnsState->u32FLStd * 30);
|
||||
|
||||
pstAeSnsDft->stIntTimeAccu.enAccuType = AE_ACCURACY_LINEAR;
|
||||
pstAeSnsDft->stIntTimeAccu.f32Accuracy = 1;
|
||||
pstAeSnsDft->stIntTimeAccu.f32Offset = 0;
|
||||
pstAeSnsDft->stAgainAccu.enAccuType = AE_ACCURACY_TABLE;
|
||||
pstAeSnsDft->stAgainAccu.f32Accuracy = 1;
|
||||
pstAeSnsDft->stDgainAccu.enAccuType = AE_ACCURACY_TABLE;
|
||||
pstAeSnsDft->stDgainAccu.f32Accuracy = 1;
|
||||
|
||||
pstAeSnsDft->u32ISPDgainShift = 8;
|
||||
pstAeSnsDft->u32MinISPDgainTarget = 1 << pstAeSnsDft->u32ISPDgainShift;
|
||||
pstAeSnsDft->u32MaxISPDgainTarget = 2 << pstAeSnsDft->u32ISPDgainShift;
|
||||
|
||||
if (g_au32LinesPer500ms[ViPipe] == 0)
|
||||
pstAeSnsDft->u32LinesPer500ms = pstSnsState->u32FLStd * 30 / 2;
|
||||
else
|
||||
pstAeSnsDft->u32LinesPer500ms = g_au32LinesPer500ms[ViPipe];
|
||||
#if 0
|
||||
pstAeSnsDft->enMaxIrisFNO = ISP_IRIS_F_NO_1_0;
|
||||
pstAeSnsDft->enMinIrisFNO = ISP_IRIS_F_NO_32_0;
|
||||
|
||||
pstAeSnsDft->bAERouteExValid = CVI_FALSE;
|
||||
pstAeSnsDft->stAERouteAttr.u32TotalNum = 0;
|
||||
pstAeSnsDft->stAERouteAttrEx.u32TotalNum = 0;
|
||||
#endif
|
||||
switch (pstSnsState->enWDRMode) {
|
||||
default:
|
||||
case WDR_MODE_NONE: /*linear mode*/
|
||||
pstAeSnsDft->f32Fps = g_astOv2685_mode[OV2685_MODE_1600X1200P30].f32MaxFps;
|
||||
pstAeSnsDft->f32MinFps = g_astOv2685_mode[OV2685_MODE_1600X1200P30].f32MinFps;
|
||||
pstAeSnsDft->au8HistThresh[0] = 0xd;
|
||||
pstAeSnsDft->au8HistThresh[1] = 0x28;
|
||||
pstAeSnsDft->au8HistThresh[2] = 0x60;
|
||||
pstAeSnsDft->au8HistThresh[3] = 0x80;
|
||||
|
||||
pstAeSnsDft->u32MaxAgain = 77648;
|
||||
pstAeSnsDft->u32MinAgain = 1024;
|
||||
pstAeSnsDft->u32MaxAgainTarget = pstAeSnsDft->u32MaxAgain;
|
||||
pstAeSnsDft->u32MinAgainTarget = pstAeSnsDft->u32MinAgain;
|
||||
|
||||
pstAeSnsDft->u32MaxDgain = 10240;
|
||||
pstAeSnsDft->u32MinDgain = 1024;
|
||||
pstAeSnsDft->u32MaxDgainTarget = pstAeSnsDft->u32MaxDgain;
|
||||
pstAeSnsDft->u32MinDgainTarget = pstAeSnsDft->u32MinDgain;
|
||||
|
||||
pstAeSnsDft->u8AeCompensation = 40;
|
||||
pstAeSnsDft->u32InitAESpeed = 64;
|
||||
pstAeSnsDft->u32InitAETolerance = 2;
|
||||
pstAeSnsDft->u32AEResponseFrame = 4;
|
||||
pstAeSnsDft->enAeExpMode = AE_EXP_HIGHLIGHT_PRIOR;
|
||||
pstAeSnsDft->u32InitExposure = g_au32InitExposure[ViPipe] ?
|
||||
g_au32InitExposure[ViPipe] : g_astOv2685_mode[OV2685_MODE_1600X1200P30].stExp[0].u16Def;
|
||||
|
||||
pstAeSnsDft->u32MaxIntTime = pstSnsState->u32FLStd - 8;
|
||||
pstAeSnsDft->u32MinIntTime = g_astOv2685_mode[OV2685_MODE_1600X1200P30].stExp[0].u16Min;
|
||||
pstAeSnsDft->u32MaxIntTimeTarget = 65535;
|
||||
pstAeSnsDft->u32MinIntTimeTarget = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
return CVI_SUCCESS;
|
||||
}
|
||||
|
||||
/* the function of sensor set fps */
|
||||
static CVI_S32 cmos_fps_set(VI_PIPE ViPipe, CVI_FLOAT f32Fps, AE_SENSOR_DEFAULT_S *pstAeSnsDft)
|
||||
{
|
||||
ISP_SNS_STATE_S *pstSnsState = CVI_NULL;
|
||||
CVI_U32 u32VMAX;
|
||||
CVI_FLOAT f32MaxFps = 0;
|
||||
CVI_FLOAT f32MinFps = 0;
|
||||
CVI_U32 u32Vts = 0;
|
||||
ISP_SNS_REGS_INFO_S *pstSnsRegsInfo = CVI_NULL;
|
||||
|
||||
CMOS_CHECK_POINTER(pstAeSnsDft);
|
||||
OV2685_SENSOR_GET_CTX(ViPipe, pstSnsState);
|
||||
CMOS_CHECK_POINTER(pstSnsState);
|
||||
|
||||
u32Vts = g_astOv2685_mode[pstSnsState->u8ImgMode].u32VtsDef;
|
||||
pstSnsRegsInfo = &pstSnsState->astSyncInfo[0].snsCfg;
|
||||
f32MaxFps = g_astOv2685_mode[pstSnsState->u8ImgMode].f32MaxFps;
|
||||
f32MinFps = g_astOv2685_mode[pstSnsState->u8ImgMode].f32MinFps;
|
||||
|
||||
if ((f32Fps <= f32MaxFps) && (f32Fps >= f32MinFps)) {
|
||||
u32VMAX = u32Vts * f32MaxFps / DIV_0_TO_1_FLOAT(f32Fps);
|
||||
} else {
|
||||
CVI_TRACE_SNS(CVI_DBG_ERR, "Unsupport Fps: %f\n", f32Fps);
|
||||
return CVI_FAILURE;
|
||||
}
|
||||
|
||||
u32VMAX = (u32VMAX > OV2685_FULL_LINES_MAX) ? OV2685_FULL_LINES_MAX : u32VMAX;
|
||||
|
||||
if (pstSnsState->enWDRMode == WDR_MODE_NONE) {
|
||||
pstSnsRegsInfo->astI2cData[LINEAR_VTS_H].u32Data = ((u32VMAX & 0xFF00) >> 8);
|
||||
pstSnsRegsInfo->astI2cData[LINEAR_VTS_L].u32Data = (u32VMAX & 0xFF);
|
||||
} else {
|
||||
CVI_TRACE_SNS(CVI_DBG_ERR, "Unsupport WDRMode: %d\n", pstSnsState->enWDRMode);
|
||||
return CVI_FAILURE;
|
||||
}
|
||||
|
||||
pstSnsState->u32FLStd = u32VMAX;
|
||||
|
||||
pstAeSnsDft->f32Fps = f32Fps;
|
||||
pstAeSnsDft->u32LinesPer500ms = pstSnsState->u32FLStd * f32Fps / 2;
|
||||
pstAeSnsDft->u32FullLinesStd = pstSnsState->u32FLStd;
|
||||
pstAeSnsDft->u32MaxIntTime = pstSnsState->u32FLStd - 8;
|
||||
pstSnsState->au32FL[0] = pstSnsState->u32FLStd;
|
||||
pstAeSnsDft->u32FullLines = pstSnsState->au32FL[0];
|
||||
pstAeSnsDft->u32HmaxTimes = (1000000) / (pstSnsState->u32FLStd * DIV_0_TO_1_FLOAT(f32Fps));
|
||||
|
||||
return CVI_SUCCESS;
|
||||
}
|
||||
|
||||
/* while isp notify ae to update sensor regs, ae call these funcs. */
|
||||
static CVI_S32 cmos_inttime_update(VI_PIPE ViPipe, CVI_U32 *u32IntTime)
|
||||
{
|
||||
ISP_SNS_STATE_S *pstSnsState = CVI_NULL;
|
||||
ISP_SNS_REGS_INFO_S *pstSnsRegsInfo = CVI_NULL;
|
||||
|
||||
OV2685_SENSOR_GET_CTX(ViPipe, pstSnsState);
|
||||
CMOS_CHECK_POINTER(pstSnsState);
|
||||
CMOS_CHECK_POINTER(u32IntTime);
|
||||
pstSnsRegsInfo = &pstSnsState->astSyncInfo[0].snsCfg;
|
||||
pstSnsRegsInfo->astI2cData[LINEAR_EXP_H].u32Data = ((u32IntTime[0] >> 8) & 0x3F);
|
||||
pstSnsRegsInfo->astI2cData[LINEAR_EXP_L].u32Data = (u32IntTime[0] & 0xFF);
|
||||
|
||||
return CVI_SUCCESS;
|
||||
}
|
||||
|
||||
static CVI_U32 regValTable[26][7] = {
|
||||
/* [reg] 0x2b3, 0x2b4, 0x2b8, 0x2b9, 0x515, 0x519, 0x2d9
|
||||
* [name] AGAIN_L AGAIN_H COLGA_H COLGA_L MAG1 MAG2 MAG3
|
||||
*/
|
||||
{0x00, 0x00, 0x01, 0x00, 0x30, 0x1e, 0x5C},
|
||||
{0x20, 0x00, 0x01, 0x0B, 0x30, 0x1e, 0x5C},
|
||||
{0x01, 0x00, 0x01, 0x19, 0x30, 0x1d, 0x5B},
|
||||
{0x21, 0x00, 0x01, 0x2A, 0x30, 0x1e, 0x5C},
|
||||
{0x02, 0x00, 0x02, 0x00, 0x30, 0x1e, 0x5C},
|
||||
{0x22, 0x00, 0x02, 0x17, 0x30, 0x1d, 0x5B},
|
||||
{0x03, 0x00, 0x02, 0x33, 0x20, 0x16, 0x54},
|
||||
{0x23, 0x00, 0x03, 0x14, 0x20, 0x17, 0x55},
|
||||
{0x04, 0x00, 0x04, 0x00, 0x20, 0x17, 0x55},
|
||||
{0x24, 0x00, 0x04, 0x2F, 0x20, 0x19, 0x57},
|
||||
{0x05, 0x00, 0x05, 0x26, 0x20, 0x19, 0x57},
|
||||
{0x25, 0x00, 0x06, 0x28, 0x20, 0x1b, 0x59},
|
||||
{0x0c, 0x00, 0x08, 0x00, 0x20, 0x1d, 0x5B},
|
||||
{0x2C, 0x00, 0x09, 0x1E, 0x20, 0x1f, 0x5D},
|
||||
{0x0D, 0x00, 0x0B, 0x0C, 0x20, 0x21, 0x5F},
|
||||
{0x2D, 0x00, 0x0D, 0x11, 0x20, 0x24, 0x62},
|
||||
{0x1C, 0x00, 0x10, 0x00, 0x20, 0x26, 0x64},
|
||||
{0x3C, 0x00, 0x12, 0x3D, 0x18, 0x2a, 0x68},
|
||||
{0x5C, 0x00, 0x16, 0x19, 0x18, 0x2c, 0x6A},
|
||||
{0x7C, 0x00, 0x1A, 0x22, 0x18, 0x2e, 0x6C},
|
||||
{0x9C, 0x00, 0x20, 0x00, 0x18, 0x32, 0x70},
|
||||
{0xBC, 0x00, 0x25, 0x3A, 0x18, 0x35, 0x73},
|
||||
{0xDC, 0x00, 0x2C, 0x33, 0x10, 0x36, 0x74},
|
||||
{0xFC, 0x00, 0x35, 0x05, 0x10, 0x38, 0x76},
|
||||
{0x1C, 0x01, 0x40, 0x00, 0x10, 0x3c, 0x7A},
|
||||
{0x3C, 0x01, 0x4B, 0x35, 0x10, 0x42, 0x80},
|
||||
};
|
||||
|
||||
static CVI_U32 gain_table[26] = {
|
||||
1024, 1200, 1424, 1696, 2048, 2416, 2864, 3392, 4096, 4848, 5728,
|
||||
6784, 8192, 9696, 11456, 13584, 16384, 19408, 22928, 27168, 32768,
|
||||
38816, 45872, 54352, 65536, 77648
|
||||
};
|
||||
|
||||
static CVI_S32 cmos_again_calc_table(VI_PIPE ViPipe, CVI_U32 *pu32AgainLin, CVI_U32 *pu32AgainDb)
|
||||
{
|
||||
int i, total;
|
||||
CVI_U32 pregain;
|
||||
|
||||
CMOS_CHECK_POINTER(pu32AgainLin);
|
||||
CMOS_CHECK_POINTER(pu32AgainDb);
|
||||
UNUSED(ViPipe);
|
||||
total = sizeof(gain_table) / sizeof(CVI_U32);
|
||||
|
||||
if (*pu32AgainLin >= gain_table[total - 1]) {
|
||||
*pu32AgainLin = *pu32AgainDb = gain_table[total - 1];
|
||||
return CVI_SUCCESS;
|
||||
}
|
||||
|
||||
for (i = 1; i < total; i++) {
|
||||
if (*pu32AgainLin < gain_table[i])
|
||||
break;
|
||||
}
|
||||
i--;
|
||||
// find the pregain
|
||||
pregain = *pu32AgainLin * 64 / gain_table[i];
|
||||
// set the Db as the AE algo gain, we need this to do gain update
|
||||
*pu32AgainDb = *pu32AgainLin;
|
||||
// set the Lin as the closest sensor gain for AE algo reference
|
||||
*pu32AgainLin = pregain * gain_table[i] / 64;
|
||||
|
||||
return CVI_SUCCESS;
|
||||
}
|
||||
|
||||
static CVI_S32 cmos_dgain_calc_table(VI_PIPE ViPipe, CVI_U32 *pu32DgainLin, CVI_U32 *pu32DgainDb)
|
||||
{
|
||||
CVI_U32 pregain;
|
||||
|
||||
CMOS_CHECK_POINTER(pu32DgainLin);
|
||||
CMOS_CHECK_POINTER(pu32DgainDb);
|
||||
UNUSED(ViPipe);
|
||||
// find the pregain
|
||||
pregain = *pu32DgainLin * 64 / 1024;
|
||||
// set the Db as the AE algo gain, we need this to do gain update
|
||||
*pu32DgainDb = *pu32DgainLin;
|
||||
// set the Lin as the closest sensor gain for AE algo reference
|
||||
*pu32DgainLin = pregain * 16;
|
||||
|
||||
return CVI_SUCCESS;
|
||||
}
|
||||
|
||||
static CVI_S32 cmos_gains_update(VI_PIPE ViPipe, CVI_U32 *pu32Again, CVI_U32 *pu32Dgain)
|
||||
{
|
||||
ISP_SNS_STATE_S *pstSnsState = CVI_NULL;
|
||||
ISP_SNS_REGS_INFO_S *pstSnsRegsInfo = CVI_NULL;
|
||||
CVI_U32 u32Again;
|
||||
CVI_U32 u32Dgain;
|
||||
int i, total;
|
||||
|
||||
total = sizeof(gain_table) / sizeof(CVI_U32);
|
||||
|
||||
OV2685_SENSOR_GET_CTX(ViPipe, pstSnsState);
|
||||
CMOS_CHECK_POINTER(pstSnsState);
|
||||
CMOS_CHECK_POINTER(pu32Again);
|
||||
CMOS_CHECK_POINTER(pu32Dgain);
|
||||
pstSnsRegsInfo = &pstSnsState->astSyncInfo[0].snsCfg;
|
||||
|
||||
/* only surpport linear mode */
|
||||
u32Again = pu32Again[0];
|
||||
/* To kepp the linearity. we assume AE algo adjusts the dgain only when the again reachs the maximum value */
|
||||
if (u32Again < (77648)) {
|
||||
for (i = 1; i < total; i++) {
|
||||
if (*pu32Again < gain_table[i])
|
||||
break;
|
||||
}
|
||||
i--;
|
||||
// find the pregain
|
||||
u32Dgain = u32Again * 64 / gain_table[i];
|
||||
u32Again = i;
|
||||
} else {
|
||||
u32Again = total - 1;
|
||||
// find the pregain
|
||||
u32Dgain = pu32Dgain[0] * 64 / 1024;
|
||||
}
|
||||
|
||||
if (pstSnsState->enWDRMode == WDR_MODE_NONE) {
|
||||
pstSnsRegsInfo->astI2cData[LINEAR_AGAIN_L].u32Data = regValTable[u32Again][0];
|
||||
pstSnsRegsInfo->astI2cData[LINEAR_AGAIN_H].u32Data = regValTable[u32Again][1];
|
||||
pstSnsRegsInfo->astI2cData[LINEAR_COL_AGAIN_H].u32Data = regValTable[u32Again][2];
|
||||
pstSnsRegsInfo->astI2cData[LINEAR_COL_AGAIN_L].u32Data = regValTable[u32Again][3];
|
||||
pstSnsRegsInfo->astI2cData[LINEAR_AGAIN_MAG1].u32Data = regValTable[u32Again][4];
|
||||
pstSnsRegsInfo->astI2cData[LINEAR_AGAIN_MAG2].u32Data = regValTable[u32Again][5];
|
||||
pstSnsRegsInfo->astI2cData[LINEAR_AGAIN_MAG3].u32Data = regValTable[u32Again][6];
|
||||
|
||||
pstSnsRegsInfo->astI2cData[LINEAR_DGAIN_H].u32Data = (u32Dgain >> 6);
|
||||
pstSnsRegsInfo->astI2cData[LINEAR_DGAIN_L].u32Data = (u32Dgain & 0x3F) << 2;
|
||||
} else {
|
||||
CVI_TRACE_SNS(CVI_DBG_ERR, "Unsupport WDRMode: %d\n", pstSnsState->enWDRMode);
|
||||
return CVI_FAILURE;
|
||||
}
|
||||
return CVI_SUCCESS;
|
||||
}
|
||||
|
||||
static CVI_S32 cmos_get_inttime_max(VI_PIPE ViPipe, CVI_U16 u16ManRatioEnable, CVI_U32 *au32Ratio,
|
||||
CVI_U32 *au32IntTimeMax, CVI_U32 *au32IntTimeMin, CVI_U32 *pu32LFMaxIntTime)
|
||||
{
|
||||
UNUSED(ViPipe);
|
||||
UNUSED(u16ManRatioEnable);
|
||||
UNUSED(au32Ratio);
|
||||
UNUSED(au32IntTimeMax);
|
||||
UNUSED(au32IntTimeMin);
|
||||
UNUSED(pu32LFMaxIntTime);
|
||||
|
||||
CVI_TRACE_SNS(CVI_DBG_ERR, "Unsupport WDRMode\n");
|
||||
return CVI_SUCCESS;
|
||||
}
|
||||
|
||||
/* Only used in LINE_WDR mode */
|
||||
static CVI_S32 cmos_ae_fswdr_attr_set(VI_PIPE ViPipe, AE_FSWDR_ATTR_S *pstAeFSWDRAttr)
|
||||
{
|
||||
CMOS_CHECK_POINTER(pstAeFSWDRAttr);
|
||||
|
||||
genFSWDRMode[ViPipe] = pstAeFSWDRAttr->enFSWDRMode;
|
||||
gu32MaxTimeGetCnt[ViPipe] = 0;
|
||||
|
||||
return CVI_SUCCESS;
|
||||
}
|
||||
|
||||
static CVI_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_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 CVI_SUCCESS;
|
||||
}
|
||||
|
||||
static CVI_S32 cmos_get_awb_default(VI_PIPE ViPipe, AWB_SENSOR_DEFAULT_S *pstAwbSnsDft)
|
||||
{
|
||||
CMOS_CHECK_POINTER(pstAwbSnsDft);
|
||||
UNUSED(ViPipe);
|
||||
memset(pstAwbSnsDft, 0, sizeof(AWB_SENSOR_DEFAULT_S));
|
||||
|
||||
pstAwbSnsDft->u16InitGgain = 1024;
|
||||
pstAwbSnsDft->u8AWBRunInterval = 1;
|
||||
|
||||
return CVI_SUCCESS;
|
||||
}
|
||||
|
||||
static CVI_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 CVI_SUCCESS;
|
||||
}
|
||||
|
||||
static CVI_S32 cmos_get_isp_default(VI_PIPE ViPipe, ISP_CMOS_DEFAULT_S *pstDef)
|
||||
{
|
||||
UNUSED(ViPipe);
|
||||
memset(pstDef, 0, sizeof(ISP_CMOS_DEFAULT_S));
|
||||
|
||||
memcpy(pstDef->stNoiseCalibration.CalibrationCoef,
|
||||
&g_stIspNoiseCalibratio, sizeof(ISP_CMOS_NOISE_CALIBRATION_S));
|
||||
|
||||
return CVI_SUCCESS;
|
||||
}
|
||||
|
||||
static CVI_S32 cmos_get_blc_default(VI_PIPE ViPipe, ISP_CMOS_BLACK_LEVEL_S *pstBlc)
|
||||
{
|
||||
CMOS_CHECK_POINTER(pstBlc);
|
||||
UNUSED(ViPipe);
|
||||
memset(pstBlc, 0, sizeof(ISP_CMOS_BLACK_LEVEL_S));
|
||||
|
||||
memcpy(pstBlc,
|
||||
&g_stIspBlcCalibratio, sizeof(ISP_CMOS_BLACK_LEVEL_S));
|
||||
return CVI_SUCCESS;
|
||||
}
|
||||
|
||||
static CVI_S32 cmos_get_wdr_size(VI_PIPE ViPipe, ISP_SNS_ISP_INFO_S *pstIspCfg)
|
||||
{
|
||||
const OV2685_MODE_S *pstMode = CVI_NULL;
|
||||
ISP_SNS_STATE_S *pstSnsState = CVI_NULL;
|
||||
|
||||
OV2685_SENSOR_GET_CTX(ViPipe, pstSnsState);
|
||||
CMOS_CHECK_POINTER(pstSnsState);
|
||||
pstMode = &g_astOv2685_mode[pstSnsState->u8ImgMode];
|
||||
|
||||
if (pstSnsState->enWDRMode != WDR_MODE_NONE) {
|
||||
CVI_TRACE_SNS(CVI_DBG_ERR, "Unsupport WDRMode: %d\n", pstSnsState->enWDRMode);
|
||||
} else {
|
||||
pstIspCfg->frm_num = 1;
|
||||
memcpy(&pstIspCfg->img_size[0], &pstMode->astImg[0], sizeof(ISP_WDR_SIZE_S));
|
||||
}
|
||||
|
||||
return CVI_SUCCESS;
|
||||
}
|
||||
|
||||
static CVI_S32 cmos_set_wdr_mode(VI_PIPE ViPipe, CVI_U8 u8Mode)
|
||||
{
|
||||
//UNUSED(ViPipe);
|
||||
//UNUSED(u8Mode);
|
||||
|
||||
ISP_SNS_STATE_S *pstSnsState = CVI_NULL;
|
||||
|
||||
OV2685_SENSOR_GET_CTX(ViPipe, pstSnsState);
|
||||
CMOS_CHECK_POINTER(pstSnsState);
|
||||
|
||||
pstSnsState->bSyncInit = CVI_FALSE;
|
||||
switch (u8Mode) {
|
||||
case WDR_MODE_NONE:
|
||||
// pstSnsState->u8ImgMode = OV2685_MODE_1600X1200P30;
|
||||
pstSnsState->enWDRMode = WDR_MODE_NONE;
|
||||
pstSnsState->u32FLStd = g_astOv2685_mode[pstSnsState->u8ImgMode].u32VtsDef;
|
||||
syslog(LOG_INFO, "WDR_MODE_NONE\n");
|
||||
break;
|
||||
case WDR_MODE_2To1_LINE:
|
||||
default:
|
||||
CVI_TRACE_SNS(CVI_DBG_ERR, "Unsupport sensor mode!\n");
|
||||
return CVI_FAILURE;
|
||||
}
|
||||
|
||||
pstSnsState->au32FL[0] = pstSnsState->u32FLStd;
|
||||
pstSnsState->au32FL[1] = pstSnsState->au32FL[0];
|
||||
memset(pstSnsState->au32WDRIntTime, 0, sizeof(pstSnsState->au32WDRIntTime));
|
||||
|
||||
//CVI_TRACE_SNS(CVI_DBG_ERR, "Unsupport sensor mode!\n");
|
||||
return CVI_SUCCESS;
|
||||
}
|
||||
|
||||
static CVI_U32 sensor_cmp_wdr_size(ISP_SNS_ISP_INFO_S *pstWdr1, ISP_SNS_ISP_INFO_S *pstWdr2)
|
||||
{
|
||||
CVI_U32 i;
|
||||
|
||||
if (pstWdr1->frm_num != pstWdr2->frm_num)
|
||||
goto _mismatch;
|
||||
for (i = 0; i < 2; i++) {
|
||||
if (pstWdr1->img_size[i].stSnsSize.u32Width != pstWdr2->img_size[i].stSnsSize.u32Width)
|
||||
goto _mismatch;
|
||||
if (pstWdr1->img_size[i].stSnsSize.u32Height != pstWdr2->img_size[i].stSnsSize.u32Height)
|
||||
goto _mismatch;
|
||||
if (pstWdr1->img_size[i].stWndRect.s32X != pstWdr2->img_size[i].stWndRect.s32X)
|
||||
goto _mismatch;
|
||||
if (pstWdr1->img_size[i].stWndRect.s32Y != pstWdr2->img_size[i].stWndRect.s32Y)
|
||||
goto _mismatch;
|
||||
if (pstWdr1->img_size[i].stWndRect.u32Width != pstWdr2->img_size[i].stWndRect.u32Width)
|
||||
goto _mismatch;
|
||||
if (pstWdr1->img_size[i].stWndRect.u32Height != pstWdr2->img_size[i].stWndRect.u32Height)
|
||||
goto _mismatch;
|
||||
}
|
||||
|
||||
return 0;
|
||||
_mismatch:
|
||||
return 1;
|
||||
}
|
||||
|
||||
static CVI_S32 cmos_get_sns_regs_info(VI_PIPE ViPipe, ISP_SNS_SYNC_INFO_S *pstSnsSyncInfo)
|
||||
{
|
||||
CVI_U32 i;
|
||||
ISP_SNS_STATE_S *pstSnsState = CVI_NULL;
|
||||
ISP_SNS_REGS_INFO_S *pstSnsRegsInfo = CVI_NULL;
|
||||
ISP_SNS_SYNC_INFO_S *pstCfg0 = CVI_NULL;
|
||||
ISP_SNS_SYNC_INFO_S *pstCfg1 = CVI_NULL;
|
||||
ISP_I2C_DATA_S *pstI2c_data = CVI_NULL;
|
||||
|
||||
CMOS_CHECK_POINTER(pstSnsSyncInfo);
|
||||
OV2685_SENSOR_GET_CTX(ViPipe, pstSnsState);
|
||||
CMOS_CHECK_POINTER(pstSnsState);
|
||||
pstSnsRegsInfo = &pstSnsSyncInfo->snsCfg;
|
||||
pstCfg0 = &pstSnsState->astSyncInfo[0];
|
||||
pstCfg1 = &pstSnsState->astSyncInfo[1];
|
||||
pstI2c_data = pstCfg0->snsCfg.astI2cData;
|
||||
|
||||
if ((pstSnsState->bSyncInit == CVI_FALSE) || (pstSnsRegsInfo->bConfig == CVI_FALSE)) {
|
||||
pstCfg0->snsCfg.enSnsType = SNS_I2C_TYPE;
|
||||
pstCfg0->snsCfg.unComBus.s8I2cDev = g_aunOv2685_BusInfo[ViPipe].s8I2cDev;
|
||||
pstCfg0->snsCfg.u8Cfg2ValidDelayMax = 0;
|
||||
pstCfg0->snsCfg.use_snsr_sram = CVI_TRUE;
|
||||
pstCfg0->snsCfg.u32RegNum = LINEAR_REGS_NUM;
|
||||
|
||||
for (i = 0; i < pstCfg0->snsCfg.u32RegNum; i++) {
|
||||
pstI2c_data[i].bUpdate = CVI_TRUE;
|
||||
pstI2c_data[i].u8DevAddr = ov2685_i2c_addr;
|
||||
pstI2c_data[i].u32AddrByteNum = ov2685_addr_byte;
|
||||
pstI2c_data[i].u32DataByteNum = ov2685_data_byte;
|
||||
}
|
||||
|
||||
pstI2c_data[LINEAR_EXP_H].u32RegAddr = OV2685_EXP_H_ADDR;
|
||||
pstI2c_data[LINEAR_EXP_L].u32RegAddr = OV2685_EXP_L_ADDR;
|
||||
pstI2c_data[LINEAR_AGAIN_H].u32RegAddr = OV2685_AGAIN_H_ADDR;
|
||||
pstI2c_data[LINEAR_AGAIN_L].u32RegAddr = OV2685_AGAIN_L_ADDR;
|
||||
pstI2c_data[LINEAR_COL_AGAIN_H].u32RegAddr = OV2685_COL_AGAIN_H_ADDR;
|
||||
pstI2c_data[LINEAR_COL_AGAIN_L].u32RegAddr = OV2685_COL_AGAIN_L_ADDR;
|
||||
pstI2c_data[LINEAR_AGAIN_MAG1].u32RegAddr = OV2685_AGAIN_MAG1_ADDR;
|
||||
pstI2c_data[LINEAR_AGAIN_MAG2].u32RegAddr = OV2685_AGAIN_MAG2_ADDR;
|
||||
pstI2c_data[LINEAR_AGAIN_MAG3].u32RegAddr = OV2685_AGAIN_MAG3_ADDR;
|
||||
pstI2c_data[LINEAR_DGAIN_H].u32RegAddr = OV2685_DGAIN_H_ADDR;
|
||||
pstI2c_data[LINEAR_DGAIN_L].u32RegAddr = OV2685_DGAIN_L_ADDR;
|
||||
pstI2c_data[LINEAR_VTS_H].u32RegAddr = OV2685_VTS_H_ADDR;
|
||||
pstI2c_data[LINEAR_VTS_L].u32RegAddr = OV2685_VTS_L_ADDR;
|
||||
pstI2c_data[LINEAR_FLIP_MIRROR].u32RegAddr = OV2685_FLIP_MIRROR_ADDR;
|
||||
pstI2c_data[LINEAR_FRAME_BUF_ON].u32RegAddr = OV2685_FRAME_BUF_ADDR;
|
||||
pstI2c_data[LINEAR_FRAME_BUF_ON].u32Data = 0x2D;
|
||||
pstI2c_data[LINEAR_FRAME_BUF_OFF].u32RegAddr = OV2685_FRAME_BUF_ADDR;
|
||||
pstI2c_data[LINEAR_FRAME_BUF_OFF].u32Data = 0x28;
|
||||
|
||||
pstSnsState->bSyncInit = CVI_TRUE;
|
||||
pstCfg0->snsCfg.need_update = CVI_TRUE;
|
||||
/* recalcualte WDR size */
|
||||
cmos_get_wdr_size(ViPipe, &pstCfg0->ispCfg);
|
||||
pstCfg0->ispCfg.need_update = CVI_TRUE;
|
||||
} else {
|
||||
|
||||
CVI_U32 gainsUpdate = 0, shutterUpdate = 0, vtsUpdate = 0;
|
||||
|
||||
pstCfg0->snsCfg.need_update = CVI_FALSE;
|
||||
for (i = 0; i < pstCfg0->snsCfg.u32RegNum; i++) {
|
||||
if (pstCfg0->snsCfg.astI2cData[i].u32Data == pstCfg1->snsCfg.astI2cData[i].u32Data) {
|
||||
pstCfg0->snsCfg.astI2cData[i].bUpdate = CVI_FALSE;
|
||||
} else {
|
||||
|
||||
if ((i >= LINEAR_AGAIN_H) && (i <= LINEAR_DGAIN_L))
|
||||
gainsUpdate = 1;
|
||||
|
||||
if (i <= LINEAR_EXP_L)
|
||||
shutterUpdate = 1;
|
||||
|
||||
if ((i >= LINEAR_VTS_H) && (i <= LINEAR_VTS_L))
|
||||
vtsUpdate = 1;
|
||||
|
||||
pstCfg0->snsCfg.astI2cData[i].bUpdate = CVI_TRUE;
|
||||
pstCfg0->snsCfg.need_update = CVI_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (gainsUpdate) {
|
||||
pstCfg0->snsCfg.astI2cData[LINEAR_AGAIN_H].bUpdate = CVI_TRUE;
|
||||
pstCfg0->snsCfg.astI2cData[LINEAR_AGAIN_L].bUpdate = CVI_TRUE;
|
||||
pstCfg0->snsCfg.astI2cData[LINEAR_COL_AGAIN_H].bUpdate = CVI_TRUE;
|
||||
pstCfg0->snsCfg.astI2cData[LINEAR_COL_AGAIN_L].bUpdate = CVI_TRUE;
|
||||
pstCfg0->snsCfg.astI2cData[LINEAR_AGAIN_MAG1].bUpdate = CVI_TRUE;
|
||||
pstCfg0->snsCfg.astI2cData[LINEAR_AGAIN_MAG2].bUpdate = CVI_TRUE;
|
||||
pstCfg0->snsCfg.astI2cData[LINEAR_AGAIN_MAG3].bUpdate = CVI_TRUE;
|
||||
pstCfg0->snsCfg.astI2cData[LINEAR_DGAIN_H].bUpdate = CVI_TRUE;
|
||||
pstCfg0->snsCfg.astI2cData[LINEAR_DGAIN_L].bUpdate = CVI_TRUE;
|
||||
}
|
||||
if (shutterUpdate) {
|
||||
pstCfg0->snsCfg.astI2cData[LINEAR_EXP_H].bUpdate = CVI_TRUE;
|
||||
pstCfg0->snsCfg.astI2cData[LINEAR_EXP_L].bUpdate = CVI_TRUE;
|
||||
}
|
||||
if (vtsUpdate) {
|
||||
pstCfg0->snsCfg.astI2cData[LINEAR_VTS_H].bUpdate = CVI_TRUE;
|
||||
pstCfg0->snsCfg.astI2cData[LINEAR_VTS_L].bUpdate = CVI_TRUE;
|
||||
}
|
||||
if (pstCfg0->snsCfg.astI2cData[LINEAR_FLIP_MIRROR].bUpdate) {
|
||||
pstCfg0->snsCfg.astI2cData[LINEAR_FRAME_BUF_ON].bUpdate = CVI_TRUE;
|
||||
pstCfg0->snsCfg.astI2cData[LINEAR_FRAME_BUF_OFF].bUpdate = CVI_TRUE;
|
||||
}
|
||||
|
||||
/* check update isp crop or not */
|
||||
pstCfg0->ispCfg.need_update = (sensor_cmp_wdr_size(&pstCfg0->ispCfg, &pstCfg1->ispCfg) ?
|
||||
CVI_TRUE : CVI_FALSE);
|
||||
}
|
||||
|
||||
pstSnsRegsInfo->bConfig = CVI_FALSE;
|
||||
memcpy(pstSnsSyncInfo, &pstSnsState->astSyncInfo[0], sizeof(ISP_SNS_SYNC_INFO_S));
|
||||
memcpy(&pstSnsState->astSyncInfo[1], &pstSnsState->astSyncInfo[0], sizeof(ISP_SNS_SYNC_INFO_S));
|
||||
pstSnsState->au32FL[1] = pstSnsState->au32FL[0];
|
||||
pstCfg0->snsCfg.astI2cData[LINEAR_FLIP_MIRROR].bDropFrm = CVI_FALSE;
|
||||
|
||||
return CVI_SUCCESS;
|
||||
}
|
||||
|
||||
static CVI_S32 cmos_set_image_mode(VI_PIPE ViPipe, ISP_CMOS_SENSOR_IMAGE_MODE_S *pstSensorImageMode)
|
||||
{
|
||||
CVI_U8 u8SensorImageMode = 0;
|
||||
ISP_SNS_STATE_S *pstSnsState = CVI_NULL;
|
||||
|
||||
CMOS_CHECK_POINTER(pstSensorImageMode);
|
||||
OV2685_SENSOR_GET_CTX(ViPipe, pstSnsState);
|
||||
CMOS_CHECK_POINTER(pstSnsState);
|
||||
|
||||
u8SensorImageMode = pstSnsState->u8ImgMode;
|
||||
pstSnsState->bSyncInit = CVI_FALSE;
|
||||
|
||||
u8SensorImageMode = OV2685_MODE_1600X1200P30;
|
||||
if (pstSnsState->enWDRMode != WDR_MODE_NONE) {
|
||||
CVI_TRACE_SNS(CVI_DBG_ERR, "Not support! Width:%d, Height:%d, Fps:%f, WDRMode:%d\n",
|
||||
pstSensorImageMode->u16Width,
|
||||
pstSensorImageMode->u16Height,
|
||||
pstSensorImageMode->f32Fps,
|
||||
pstSnsState->enWDRMode);
|
||||
}
|
||||
|
||||
if ((pstSnsState->bInit == CVI_TRUE) && (u8SensorImageMode == pstSnsState->u8ImgMode)) {
|
||||
/* Don't need to switch SensorImageMode */
|
||||
return CVI_FAILURE;
|
||||
}
|
||||
|
||||
pstSnsState->u8ImgMode = u8SensorImageMode;
|
||||
|
||||
return CVI_SUCCESS;
|
||||
}
|
||||
|
||||
static CVI_VOID sensor_mirror_flip(VI_PIPE ViPipe, ISP_SNS_MIRRORFLIP_TYPE_E eSnsMirrorFlip)
|
||||
{
|
||||
ISP_SNS_STATE_S *pstSnsState = CVI_NULL;
|
||||
ISP_SNS_REGS_INFO_S *pstSnsRegsInfo = CVI_NULL;
|
||||
CVI_U8 value;
|
||||
|
||||
OV2685_SENSOR_GET_CTX(ViPipe, pstSnsState);
|
||||
CMOS_CHECK_POINTER_VOID(pstSnsState);
|
||||
|
||||
pstSnsRegsInfo = &pstSnsState->astSyncInfo[0].snsCfg;
|
||||
|
||||
/* Apply the setting on the fly */
|
||||
if (pstSnsState->bInit == CVI_TRUE && g_aeOv2685_MirrorFip[ViPipe] != eSnsMirrorFlip) {
|
||||
switch (eSnsMirrorFlip) {
|
||||
case ISP_SNS_NORMAL:
|
||||
value = 0;
|
||||
break;
|
||||
case ISP_SNS_MIRROR:
|
||||
value = 1;
|
||||
break;
|
||||
case ISP_SNS_FLIP:
|
||||
value = 2;
|
||||
break;
|
||||
case ISP_SNS_MIRROR_FLIP:
|
||||
value = 3;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
pstSnsRegsInfo->astI2cData[LINEAR_FLIP_MIRROR].u32Data = value;
|
||||
pstSnsRegsInfo->astI2cData[LINEAR_FLIP_MIRROR].bDropFrm = 1;
|
||||
pstSnsRegsInfo->astI2cData[LINEAR_FLIP_MIRROR].u8DropFrmNum = 2;
|
||||
g_aeOv2685_MirrorFip[ViPipe] = eSnsMirrorFlip;
|
||||
}
|
||||
}
|
||||
|
||||
static CVI_VOID sensor_global_init(VI_PIPE ViPipe)
|
||||
{
|
||||
ISP_SNS_STATE_S *pstSnsState = CVI_NULL;
|
||||
|
||||
OV2685_SENSOR_GET_CTX(ViPipe, pstSnsState);
|
||||
CMOS_CHECK_POINTER_VOID(pstSnsState);
|
||||
|
||||
pstSnsState->bInit = CVI_FALSE;
|
||||
pstSnsState->bSyncInit = CVI_FALSE;
|
||||
pstSnsState->u8ImgMode = OV2685_MODE_1600X1200P30;
|
||||
pstSnsState->enWDRMode = WDR_MODE_NONE;
|
||||
pstSnsState->u32FLStd = g_astOv2685_mode[pstSnsState->u8ImgMode].u32VtsDef;
|
||||
pstSnsState->au32FL[0] = g_astOv2685_mode[pstSnsState->u8ImgMode].u32VtsDef;
|
||||
pstSnsState->au32FL[1] = g_astOv2685_mode[pstSnsState->u8ImgMode].u32VtsDef;
|
||||
|
||||
memset(&pstSnsState->astSyncInfo[0], 0, sizeof(ISP_SNS_SYNC_INFO_S));
|
||||
memset(&pstSnsState->astSyncInfo[1], 0, sizeof(ISP_SNS_SYNC_INFO_S));
|
||||
}
|
||||
|
||||
static CVI_S32 sensor_rx_attr(VI_PIPE ViPipe, SNS_COMBO_DEV_ATTR_S *pstRxAttr)
|
||||
{
|
||||
ISP_SNS_STATE_S *pstSnsState = CVI_NULL;
|
||||
|
||||
OV2685_SENSOR_GET_CTX(ViPipe, pstSnsState);
|
||||
CMOS_CHECK_POINTER(pstSnsState);
|
||||
CMOS_CHECK_POINTER(pstRxAttr);
|
||||
|
||||
CVI_U8 u8SensorImageMode = 0;
|
||||
|
||||
memcpy(pstRxAttr, &ov2685_rx_attr, sizeof(*pstRxAttr));
|
||||
pstRxAttr->img_size.width = g_astOv2685_mode[pstSnsState->u8ImgMode].astImg[0].stSnsSize.u32Width;
|
||||
pstRxAttr->img_size.height = g_astOv2685_mode[pstSnsState->u8ImgMode].astImg[0].stSnsSize.u32Height;
|
||||
if (pstSnsState->enWDRMode == WDR_MODE_NONE)
|
||||
pstRxAttr->mipi_attr.wdr_mode = CVI_MIPI_WDR_MODE_NONE;
|
||||
|
||||
return CVI_SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
static CVI_S32 sensor_patch_rx_attr(RX_INIT_ATTR_S *pstRxInitAttr)
|
||||
{
|
||||
SNS_COMBO_DEV_ATTR_S *pstRxAttr = &ov2685_rx_attr;
|
||||
int i;
|
||||
|
||||
CMOS_CHECK_POINTER(pstRxInitAttr);
|
||||
|
||||
if (pstRxInitAttr->stMclkAttr.bMclkEn)
|
||||
pstRxAttr->mclk.cam = pstRxInitAttr->stMclkAttr.u8Mclk;
|
||||
|
||||
if (pstRxInitAttr->MipiDev >= VI_MAX_DEV_NUM)
|
||||
return CVI_SUCCESS;
|
||||
|
||||
pstRxAttr->devno = pstRxInitAttr->MipiDev;
|
||||
|
||||
if (pstRxAttr->input_mode == INPUT_MODE_MIPI) {
|
||||
struct mipi_dev_attr_s *attr = &pstRxAttr->mipi_attr;
|
||||
|
||||
for (i = 0; i < MIPI_LANE_NUM + 1; i++) {
|
||||
attr->lane_id[i] = pstRxInitAttr->as16LaneId[i];
|
||||
attr->pn_swap[i] = pstRxInitAttr->as8PNSwap[i];
|
||||
}
|
||||
} else {
|
||||
struct lvds_dev_attr_s *attr = &pstRxAttr->lvds_attr;
|
||||
|
||||
for (i = 0; i < MIPI_LANE_NUM + 1; i++) {
|
||||
attr->lane_id[i] = pstRxInitAttr->as16LaneId[i];
|
||||
attr->pn_swap[i] = pstRxInitAttr->as8PNSwap[i];
|
||||
}
|
||||
}
|
||||
|
||||
return CVI_SUCCESS;
|
||||
}
|
||||
|
||||
static CVI_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 = ov2685_init;
|
||||
pstSensorExpFunc->pfn_cmos_sensor_exit = ov2685_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_blc_default;
|
||||
pstSensorExpFunc->pfn_cmos_get_sns_reg_info = cmos_get_sns_regs_info;
|
||||
|
||||
return CVI_SUCCESS;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* callback structure *
|
||||
****************************************************************************/
|
||||
static CVI_VOID sensor_patch_i2c_addr(CVI_S32 s32I2cAddr)
|
||||
{
|
||||
if (OV2685_I2C_ADDR_IS_VALID(s32I2cAddr))
|
||||
ov2685_i2c_addr = s32I2cAddr;
|
||||
else
|
||||
ov2685_i2c_addr = OV2685_I2C_ADDR_2;
|
||||
}
|
||||
|
||||
static CVI_S32 ov2685_set_bus_info(VI_PIPE ViPipe, ISP_SNS_COMMBUS_U unSNSBusInfo)
|
||||
{
|
||||
g_aunOv2685_BusInfo[ViPipe].s8I2cDev = unSNSBusInfo.s8I2cDev;
|
||||
|
||||
return CVI_SUCCESS;
|
||||
}
|
||||
|
||||
static CVI_S32 sensor_ctx_init(VI_PIPE ViPipe)
|
||||
{
|
||||
ISP_SNS_STATE_S *pastSnsStateCtx = CVI_NULL;
|
||||
|
||||
OV2685_SENSOR_GET_CTX(ViPipe, pastSnsStateCtx);
|
||||
|
||||
if (pastSnsStateCtx == CVI_NULL) {
|
||||
pastSnsStateCtx = (ISP_SNS_STATE_S *)malloc(sizeof(ISP_SNS_STATE_S));
|
||||
if (pastSnsStateCtx == CVI_NULL) {
|
||||
CVI_TRACE_SNS(CVI_DBG_ERR, "Isp[%d] SnsCtx malloc memory failed!\n", ViPipe);
|
||||
return -ENOMEM;
|
||||
}
|
||||
}
|
||||
|
||||
memset(pastSnsStateCtx, 0, sizeof(ISP_SNS_STATE_S));
|
||||
|
||||
OV2685_SENSOR_SET_CTX(ViPipe, pastSnsStateCtx);
|
||||
|
||||
return CVI_SUCCESS;
|
||||
}
|
||||
|
||||
static CVI_VOID sensor_ctx_exit(VI_PIPE ViPipe)
|
||||
{
|
||||
ISP_SNS_STATE_S *pastSnsStateCtx = CVI_NULL;
|
||||
|
||||
OV2685_SENSOR_GET_CTX(ViPipe, pastSnsStateCtx);
|
||||
SENSOR_FREE(pastSnsStateCtx);
|
||||
OV2685_SENSOR_RESET_CTX(ViPipe);
|
||||
}
|
||||
|
||||
static CVI_S32 sensor_register_callback(VI_PIPE ViPipe, ALG_LIB_S *pstAeLib, ALG_LIB_S *pstAwbLib)
|
||||
{
|
||||
CVI_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 != CVI_SUCCESS)
|
||||
return CVI_FAILURE;
|
||||
|
||||
stSnsAttrInfo.eSensorId = OV2685_ID;
|
||||
|
||||
s32Ret = cmos_init_sensor_exp_function(&stIspRegister.stSnsExp);
|
||||
s32Ret |= CVI_ISP_SensorRegCallBack(ViPipe, &stSnsAttrInfo, &stIspRegister);
|
||||
|
||||
if (s32Ret != CVI_SUCCESS) {
|
||||
CVI_TRACE_SNS(CVI_DBG_ERR, "sensor register callback function failed!\n");
|
||||
return s32Ret;
|
||||
}
|
||||
|
||||
s32Ret = cmos_init_ae_exp_function(&stAeRegister.stAeExp);
|
||||
s32Ret |= CVI_AE_SensorRegCallBack(ViPipe, pstAeLib, &stSnsAttrInfo, &stAeRegister);
|
||||
|
||||
if (s32Ret != CVI_SUCCESS) {
|
||||
CVI_TRACE_SNS(CVI_DBG_ERR, "sensor register callback function to ae lib failed!\n");
|
||||
return s32Ret;
|
||||
}
|
||||
|
||||
s32Ret = cmos_init_awb_exp_function(&stAwbRegister.stAwbExp);
|
||||
s32Ret |= CVI_AWB_SensorRegCallBack(ViPipe, pstAwbLib, &stSnsAttrInfo, &stAwbRegister);
|
||||
|
||||
if (s32Ret != CVI_SUCCESS) {
|
||||
CVI_TRACE_SNS(CVI_DBG_ERR, "sensor register callback function to awb lib failed!\n");
|
||||
return s32Ret;
|
||||
}
|
||||
|
||||
return CVI_SUCCESS;
|
||||
}
|
||||
|
||||
static CVI_S32 sensor_unregister_callback(VI_PIPE ViPipe, ALG_LIB_S *pstAeLib, ALG_LIB_S *pstAwbLib)
|
||||
{
|
||||
CVI_S32 s32Ret;
|
||||
|
||||
CMOS_CHECK_POINTER(pstAeLib);
|
||||
CMOS_CHECK_POINTER(pstAwbLib);
|
||||
|
||||
s32Ret = CVI_ISP_SensorUnRegCallBack(ViPipe, OV2685_ID);
|
||||
if (s32Ret != CVI_SUCCESS) {
|
||||
CVI_TRACE_SNS(CVI_DBG_ERR, "sensor unregister callback function failed!\n");
|
||||
return s32Ret;
|
||||
}
|
||||
|
||||
s32Ret = CVI_AE_SensorUnRegCallBack(ViPipe, pstAeLib, OV2685_ID);
|
||||
if (s32Ret != CVI_SUCCESS) {
|
||||
CVI_TRACE_SNS(CVI_DBG_ERR, "sensor unregister callback function to ae lib failed!\n");
|
||||
return s32Ret;
|
||||
}
|
||||
|
||||
s32Ret = CVI_AWB_SensorUnRegCallBack(ViPipe, pstAwbLib, OV2685_ID);
|
||||
if (s32Ret != CVI_SUCCESS) {
|
||||
CVI_TRACE_SNS(CVI_DBG_ERR, "sensor unregister callback function to awb lib failed!\n");
|
||||
return s32Ret;
|
||||
}
|
||||
|
||||
sensor_ctx_exit(ViPipe);
|
||||
|
||||
return CVI_SUCCESS;
|
||||
}
|
||||
|
||||
static CVI_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;
|
||||
g_au16Ov2685_GainMode[ViPipe] = pstInitAttr->enGainMode;
|
||||
|
||||
return CVI_SUCCESS;
|
||||
}
|
||||
|
||||
static CVI_S32 sensor_probe(VI_PIPE ViPipe)
|
||||
{
|
||||
return ov2685_probe(ViPipe);
|
||||
}
|
||||
|
||||
ISP_SNS_OBJ_S stSnsOv2685_Obj = {
|
||||
.pfnRegisterCallback = sensor_register_callback,
|
||||
.pfnUnRegisterCallback = sensor_unregister_callback,
|
||||
.pfnStandby = ov2685_standby,
|
||||
.pfnRestart = ov2685_restart,
|
||||
.pfnWriteReg = ov2685_write_register,
|
||||
.pfnReadReg = ov2685_read_register,
|
||||
.pfnSetBusInfo = ov2685_set_bus_info,
|
||||
.pfnSetInit = sensor_set_init,
|
||||
.pfnMirrorFlip = sensor_mirror_flip,
|
||||
.pfnPatchRxAttr = sensor_patch_rx_attr,
|
||||
.pfnPatchI2cAddr = sensor_patch_i2c_addr,
|
||||
.pfnGetRxAttr = sensor_rx_attr,
|
||||
.pfnExpSensorCb = cmos_init_sensor_exp_function,
|
||||
.pfnExpAeCb = cmos_init_ae_exp_function,
|
||||
.pfnSnsProbe = sensor_probe,
|
||||
};
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
#ifndef __OV2685_CMOS_EX_H_
|
||||
#define __OV2685_CMOS_EX_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef ARCH_CV182X
|
||||
#include <linux/cvi_vip_cif.h>
|
||||
#include <linux/cvi_vip_snsr.h>
|
||||
#include "cvi_type.h"
|
||||
#else
|
||||
#include <linux/cif_uapi.h>
|
||||
#include <linux/vi_snsr.h>
|
||||
#include <linux/cvi_type.h>
|
||||
#endif
|
||||
#include "cvi_sns_ctrl.h"
|
||||
|
||||
#ifndef UNUSED
|
||||
#define UNUSED(x) ((void)(x))
|
||||
#endif
|
||||
|
||||
enum ov2685_linear_regs_e {
|
||||
LINEAR_EXP_H, //0x0202 bit[13:8]
|
||||
LINEAR_EXP_L, //0x0203
|
||||
LINEAR_AGAIN_L, //0x02b3
|
||||
LINEAR_AGAIN_H, //0x02b4 bit[10:8]
|
||||
LINEAR_COL_AGAIN_H, //0x02b8 bit[13:8]
|
||||
LINEAR_COL_AGAIN_L, //0x02b9
|
||||
LINEAR_AGAIN_MAG1, //0x0515
|
||||
LINEAR_AGAIN_MAG2, //0x0519
|
||||
LINEAR_AGAIN_MAG3, //0x02d9
|
||||
LINEAR_DGAIN_H, //0x020e bit[9:6]
|
||||
LINEAR_DGAIN_L, //0x020f bit[5:0]
|
||||
LINEAR_VTS_H, //0x0341 bit[13:8]
|
||||
LINEAR_VTS_L, //0x0342
|
||||
LINEAR_FRAME_BUF_ON,//0x031D
|
||||
LINEAR_FLIP_MIRROR,
|
||||
LINEAR_FRAME_BUF_OFF,//0x031D
|
||||
LINEAR_REGS_NUM
|
||||
};
|
||||
|
||||
typedef enum _OV2685_MODE_E {
|
||||
OV2685_MODE_1600X1200P30 = 0,
|
||||
OV2685_MODE_LINEAR_NUM,
|
||||
OV2685_MODE_NUM
|
||||
} OV2685_MODE_E;
|
||||
|
||||
typedef struct _OV2685_STATE_S {
|
||||
CVI_U32 u32Sexp_MAX;
|
||||
} OV2685_STATE_S;
|
||||
|
||||
typedef struct _OV2685_MODE_S {
|
||||
ISP_WDR_SIZE_S astImg[2];
|
||||
CVI_FLOAT f32MaxFps;
|
||||
CVI_FLOAT f32MinFps;
|
||||
CVI_U32 u32HtsDef;
|
||||
CVI_U32 u32VtsDef;
|
||||
SNS_ATTR_S stExp[2];
|
||||
SNS_ATTR_LARGE_S stAgain[2];
|
||||
SNS_ATTR_LARGE_S stDgain[2];
|
||||
char name[64];
|
||||
} OV2685_MODE_S;
|
||||
|
||||
/****************************************************************************
|
||||
* external variables and functions *
|
||||
****************************************************************************/
|
||||
|
||||
extern ISP_SNS_STATE_S *g_pastOv2685[VI_MAX_PIPE_NUM];
|
||||
extern ISP_SNS_COMMBUS_U g_aunOv2685_BusInfo[];
|
||||
extern ISP_SNS_MIRRORFLIP_TYPE_E g_aeOv2685_MirrorFip[VI_MAX_PIPE_NUM];
|
||||
extern CVI_U8 ov2685_i2c_addr;
|
||||
extern const CVI_U32 ov2685_addr_byte;
|
||||
extern const CVI_U32 ov2685_data_byte;
|
||||
extern void ov2685_init(VI_PIPE ViPipe);
|
||||
extern void ov2685_exit(VI_PIPE ViPipe);
|
||||
extern void ov2685_standby(VI_PIPE ViPipe);
|
||||
extern void ov2685_restart(VI_PIPE ViPipe);
|
||||
extern int ov2685_write_register(VI_PIPE ViPipe, int addr, int data);
|
||||
extern int ov2685_read_register(VI_PIPE ViPipe, int addr);
|
||||
extern int ov2685_probe(VI_PIPE ViPipe);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* End of #ifdef __cplusplus */
|
||||
|
||||
|
||||
#endif /* __OV2685_CMOS_EX_H_ */
|
||||
|
||||
@@ -0,0 +1,227 @@
|
||||
#ifndef __OV2685_CMOS_PARAM_H_
|
||||
#define __OV2685_CMOS_PARAM_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef ARCH_CV182X
|
||||
#include <linux/cvi_vip_cif.h>
|
||||
#include <linux/cvi_vip_snsr.h>
|
||||
#include "cvi_type.h"
|
||||
#else
|
||||
#include <linux/cif_uapi.h>
|
||||
#include <linux/vi_snsr.h>
|
||||
#include <linux/cvi_type.h>
|
||||
#endif
|
||||
#include "cvi_sns_ctrl.h"
|
||||
#include "ov2685_cmos_ex.h"
|
||||
|
||||
static const OV2685_MODE_S g_astOv2685_mode[OV2685_MODE_NUM] = {
|
||||
[OV2685_MODE_1600X1200P30] = {
|
||||
.name = "1600X1200P30",
|
||||
.astImg[0] = {
|
||||
.stSnsSize = {
|
||||
.u32Width = 1600,
|
||||
.u32Height = 1200,
|
||||
},
|
||||
.stWndRect = {
|
||||
.s32X = 0,
|
||||
.s32Y = 0,
|
||||
.u32Width = 1600,
|
||||
.u32Height = 1200,
|
||||
},
|
||||
.stMaxSize = {
|
||||
.u32Width = 1600,
|
||||
.u32Height = 1200,
|
||||
},
|
||||
},
|
||||
.f32MaxFps = 30,
|
||||
.f32MinFps = 2.75, /* 1500 * 30 / 16383 */
|
||||
.u32HtsDef = 1500,
|
||||
.u32VtsDef = 750,//650
|
||||
.stExp[0] = {
|
||||
.u16Min = 1,
|
||||
.u16Max = 0x3fff,
|
||||
.u16Def = 0x2000,
|
||||
.u16Step = 1,
|
||||
},
|
||||
.stAgain[0] = {
|
||||
.u32Min = 1024,
|
||||
.u32Max = 77648,
|
||||
.u32Def = 1024,
|
||||
.u32Step = 1,
|
||||
},
|
||||
.stDgain[0] = {
|
||||
.u32Min = 1024,
|
||||
.u32Max = 16368,
|
||||
.u32Def = 1024,
|
||||
.u32Step = 64,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
static ISP_CMOS_NOISE_CALIBRATION_S g_stIspNoiseCalibratio = {.CalibrationCoef = {
|
||||
{ //iso 100
|
||||
{0.04006369039416313171, 5.73531675338745117188}, //B: slope, intercept
|
||||
{0.03064448758959770203, 8.56994438171386718750}, //Gb: slope, intercept
|
||||
{0.03068985790014266968, 8.82220363616943359375}, //Gr: slope, intercept
|
||||
{0.03361049667000770569, 7.20687675476074218750}, //R: slope, intercept
|
||||
},
|
||||
{ //iso 200
|
||||
{0.05054308474063873291, 7.91628408432006835938}, //B: slope, intercept
|
||||
{0.03632996603846549988, 13.05291843414306640625}, //Gb: slope, intercept
|
||||
{0.03697143867611885071, 12.49540805816650390625}, //Gr: slope, intercept
|
||||
{0.04156460240483283997, 10.44298553466796875000}, //R: slope, intercept
|
||||
},
|
||||
{ //iso 400
|
||||
{0.06805337965488433838, 11.55693244934082031250}, //B: slope, intercept
|
||||
{0.04390667378902435303, 18.59673881530761718750}, //Gb: slope, intercept
|
||||
{0.04630871489644050598, 17.90183258056640625000}, //Gr: slope, intercept
|
||||
{0.05292420834302902222, 15.17318439483642578125}, //R: slope, intercept
|
||||
},
|
||||
{ //iso 800
|
||||
{0.08635756373405456543, 17.79124641418457031250}, //B: slope, intercept
|
||||
{0.05776864662766456604, 26.76541900634765625000}, //Gb: slope, intercept
|
||||
{0.05839699879288673401, 26.44194030761718750000}, //Gr: slope, intercept
|
||||
{0.06750740110874176025, 22.42554473876953125000}, //R: slope, intercept
|
||||
},
|
||||
{ //iso 1600
|
||||
{0.12254384160041809082, 26.20610046386718750000}, //B: slope, intercept
|
||||
{0.07916855812072753906, 39.39273834228515625000}, //Gb: slope, intercept
|
||||
{0.07857896387577056885, 39.03499984741210937500}, //Gr: slope, intercept
|
||||
{0.09273355454206466675, 33.09597778320312500000}, //R: slope, intercept
|
||||
},
|
||||
{ //iso 3200
|
||||
{0.18002016842365264893, 34.86975860595703125000}, //B: slope, intercept
|
||||
{0.10951708257198333740, 54.58878326416015625000}, //Gb: slope, intercept
|
||||
{0.10485322028398513794, 57.16654205322265625000}, //Gr: slope, intercept
|
||||
{0.13257601857185363770, 46.27093505859375000000}, //R: slope, intercept
|
||||
},
|
||||
{ //iso 6400
|
||||
{0.24713687598705291748, 48.62341690063476562500}, //B: slope, intercept
|
||||
{0.14974890649318695068, 77.06428527832031250000}, //Gb: slope, intercept
|
||||
{0.14544390141963958740, 76.57913970947265625000}, //Gr: slope, intercept
|
||||
{0.19056233763694763184, 62.13500213623046875000}, //R: slope, intercept
|
||||
},
|
||||
{ //iso 12800
|
||||
{0.37728109955787658691, 58.15543365478515625000}, //B: slope, intercept
|
||||
{0.20440576970577239990, 100.45700073242187500000}, //Gb: slope, intercept
|
||||
{0.20059910416603088379, 102.35488891601562500000}, //Gr: slope, intercept
|
||||
{0.27388775348663330078, 79.65499877929687500000}, //R: slope, intercept
|
||||
},
|
||||
{ //iso 25600
|
||||
{0.36612421274185180664, 115.28938293457031250000}, //B: slope, intercept
|
||||
{0.22633622586727142334, 164.58416748046875000000}, //Gb: slope, intercept
|
||||
{0.21590474247932434082, 168.92042541503906250000}, //Gr: slope, intercept
|
||||
{0.33193346858024597168, 127.92090606689453125000}, //R: slope, intercept
|
||||
},
|
||||
{ //iso 51200
|
||||
{0.48242908716201782227, 147.39015197753906250000}, //B: slope, intercept
|
||||
{0.28994381427764892578, 223.02711486816406250000}, //Gb: slope, intercept
|
||||
{0.29200506210327148438, 220.64030456542968750000}, //Gr: slope, intercept
|
||||
{0.42304891347885131836, 173.74638366699218750000}, //R: slope, intercept
|
||||
},
|
||||
{ //iso 102400
|
||||
{0.62099909782409667969, 130.97862243652343750000}, //B: slope, intercept
|
||||
{0.39534106850624084473, 219.74490356445312500000}, //Gb: slope, intercept
|
||||
{0.39458695054054260254, 213.37374877929687500000}, //Gr: slope, intercept
|
||||
{0.55690109729766845703, 158.37773132324218750000}, //R: slope, intercept
|
||||
},
|
||||
{ //iso 204800
|
||||
{0.75350415706634521484, 77.81707000732421875000}, //B: slope, intercept
|
||||
{0.52716732025146484375, 148.77879333496093750000}, //Gb: slope, intercept
|
||||
{0.51073729991912841797, 153.86495971679687500000}, //Gr: slope, intercept
|
||||
{0.68910604715347290039, 102.12422180175781250000}, //R: slope, intercept
|
||||
},
|
||||
{ //iso 409600
|
||||
{0.90276730060577392578, 43.78258514404296875000}, //B: slope, intercept
|
||||
{0.62851423025131225586, 119.41429138183593750000}, //Gb: slope, intercept
|
||||
{0.64918899536132812500, 110.74241638183593750000}, //Gr: slope, intercept
|
||||
{0.80880594253540039063, 68.89983367919921875000}, //R: slope, intercept
|
||||
},
|
||||
{ //iso 819200
|
||||
{0.90276730060577392578, 43.78258514404296875000}, //B: slope, intercept
|
||||
{0.62851423025131225586, 119.41429138183593750000}, //Gb: slope, intercept
|
||||
{0.64918899536132812500, 110.74241638183593750000}, //Gr: slope, intercept
|
||||
{0.80880594253540039063, 68.89983367919921875000}, //R: slope, intercept
|
||||
},
|
||||
{ //iso 1638400
|
||||
{0.90276730060577392578, 43.78258514404296875000}, //B: slope, intercept
|
||||
{0.62851423025131225586, 119.41429138183593750000}, //Gb: slope, intercept
|
||||
{0.64918899536132812500, 110.74241638183593750000}, //Gr: slope, intercept
|
||||
{0.80880594253540039063, 68.89983367919921875000}, //R: slope, intercept
|
||||
},
|
||||
{ //iso 3276800
|
||||
{0.90276730060577392578, 43.78258514404296875000}, //B: slope, intercept
|
||||
{0.62851423025131225586, 119.41429138183593750000}, //Gb: slope, intercept
|
||||
{0.64918899536132812500, 110.74241638183593750000}, //Gr: slope, intercept
|
||||
{0.80880594253540039063, 68.89983367919921875000}, //R: slope, intercept
|
||||
},
|
||||
} };
|
||||
|
||||
|
||||
static ISP_CMOS_BLACK_LEVEL_S g_stIspBlcCalibratio = {
|
||||
.bUpdate = CVI_TRUE,
|
||||
.blcAttr = {
|
||||
.Enable = 1,
|
||||
.enOpType = OP_TYPE_MANUAL,
|
||||
.stManual = {60, 60, 60, 60, 0, 0, 0, 0
|
||||
#ifdef ARCH_CV182X
|
||||
, 1039, 1039, 1039, 1039
|
||||
#endif
|
||||
},
|
||||
.stAuto = {
|
||||
{60, 60, 60, 60, 60, 60, 60, 60, /*8*/60, 60, 60, 60, 60, 60, 60, 60},
|
||||
{60, 60, 60, 60, 60, 60, 60, 60, /*8*/60, 60, 60, 60, 60, 60, 60, 60},
|
||||
{60, 60, 60, 60, 60, 60, 60, 60, /*8*/60, 60, 60, 60, 60, 60, 60, 60},
|
||||
{60, 60, 60, 60, 60, 60, 60, 60, /*8*/60, 60, 60, 60, 60, 60, 60, 60},
|
||||
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
#ifdef ARCH_CV182X
|
||||
{1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039,
|
||||
/*8*/1039, 1039, 1039, 1039, 1204, 1039, 1039, 1039},
|
||||
{1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039,
|
||||
/*8*/1039, 1039, 1039, 1039, 1204, 1039, 1039, 1039},
|
||||
{1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039,
|
||||
/*8*/1039, 1039, 1039, 1039, 1204, 1039, 1039, 1039},
|
||||
{1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039,
|
||||
/*8*/1039, 1039, 1039, 1039, 1204, 1039, 1039, 1039},
|
||||
#endif
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
struct combo_dev_attr_s ov2685_rx_attr = {
|
||||
.input_mode = INPUT_MODE_MIPI,
|
||||
.mac_clk = RX_MAC_CLK_600M,
|
||||
.mipi_attr = {
|
||||
.raw_data_type = RAW_DATA_10BIT,
|
||||
.lane_id = {4, 3, 2, -1, -1},
|
||||
.pn_swap = {1, 1, 1, 0, 0},
|
||||
.wdr_mode = CVI_MIPI_WDR_MODE_NONE,
|
||||
.dphy = {
|
||||
.enable = 1,
|
||||
.hs_settle = 8,
|
||||
},
|
||||
},
|
||||
.mclk = {
|
||||
.cam = 0,
|
||||
.freq = CAMPLL_FREQ_24M,
|
||||
},
|
||||
.devno = 0,
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* End of #ifdef __cplusplus */
|
||||
|
||||
|
||||
#endif /* __OV2685_CMOS_PARAM_H_ */
|
||||
|
||||
@@ -0,0 +1,425 @@
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <syslog.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/i2c-dev.h>
|
||||
#ifdef ARCH_CV182X
|
||||
#include <linux/cvi_vip_snsr.h>
|
||||
#include "cvi_comm_video.h"
|
||||
#else
|
||||
// #include <linux/vi_snsr.h>
|
||||
// #include <linux/cvi_comm_video.h>
|
||||
#endif
|
||||
#include "cvi_sns_ctrl.h"
|
||||
#include "ov2685_cmos_ex.h"
|
||||
|
||||
#define OV2685_CHIP_ID_ADDR_H 0x300A
|
||||
#define OV2685_CHIP_ID_ADDR_L 0x300B
|
||||
#define OV2685_CHIP_ID 0x2685
|
||||
|
||||
static void ov2685_linear_720p30_init(VI_PIPE ViPipe);
|
||||
static void ov2685_linear_1600x1200_30_init(VI_PIPE ViPipe);
|
||||
|
||||
CVI_U8 ov2685_i2c_addr = 0x29;
|
||||
const CVI_U32 ov2685_addr_byte = 2;
|
||||
const CVI_U32 ov2685_data_byte = 1;
|
||||
static int g_fd[VI_MAX_PIPE_NUM] = {[0 ... (VI_MAX_PIPE_NUM - 1)] = -1};
|
||||
|
||||
int ov2685_i2c_init(VI_PIPE ViPipe)
|
||||
{
|
||||
char acDevFile[16] = {0};
|
||||
CVI_U8 u8DevNum;
|
||||
|
||||
if (g_fd[ViPipe] >= 0)
|
||||
return CVI_SUCCESS;
|
||||
int ret;
|
||||
|
||||
u8DevNum = g_aunOv2685_BusInfo[ViPipe].s8I2cDev;
|
||||
snprintf(acDevFile, sizeof(acDevFile), "/dev/i2c-%u", u8DevNum);
|
||||
|
||||
g_fd[ViPipe] = open(acDevFile, O_RDWR, 0600);
|
||||
|
||||
if (g_fd[ViPipe] < 0) {
|
||||
CVI_TRACE_SNS(CVI_DBG_ERR, "Open /dev/i2c-%u error!\n", u8DevNum);
|
||||
return CVI_FAILURE;
|
||||
}
|
||||
|
||||
ret = ioctl(g_fd[ViPipe], I2C_SLAVE_FORCE, ov2685_i2c_addr);
|
||||
if (ret < 0) {
|
||||
CVI_TRACE_SNS(CVI_DBG_ERR, "I2C_SLAVE_FORCE error!\n");
|
||||
close(g_fd[ViPipe]);
|
||||
g_fd[ViPipe] = -1;
|
||||
return ret;
|
||||
}
|
||||
|
||||
return CVI_SUCCESS;
|
||||
}
|
||||
|
||||
int ov2685_i2c_exit(VI_PIPE ViPipe)
|
||||
{
|
||||
if (g_fd[ViPipe] >= 0) {
|
||||
close(g_fd[ViPipe]);
|
||||
g_fd[ViPipe] = -1;
|
||||
return CVI_SUCCESS;
|
||||
}
|
||||
return CVI_FAILURE;
|
||||
}
|
||||
|
||||
int ov2685_read_register(VI_PIPE ViPipe, int addr)
|
||||
{
|
||||
int ret, data;
|
||||
CVI_U8 buf[8];
|
||||
CVI_U8 idx = 0;
|
||||
|
||||
if (g_fd[ViPipe] < 0)
|
||||
return CVI_FAILURE;
|
||||
|
||||
if (ov2685_addr_byte == 2)
|
||||
buf[idx++] = (addr >> 8) & 0xff;
|
||||
|
||||
// add address byte 0
|
||||
buf[idx++] = addr & 0xff;
|
||||
|
||||
ret = write(g_fd[ViPipe], buf, ov2685_addr_byte);
|
||||
if (ret < 0) {
|
||||
CVI_TRACE_SNS(CVI_DBG_ERR, "I2C_WRITE error!\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
buf[0] = 0;
|
||||
buf[1] = 0;
|
||||
ret = read(g_fd[ViPipe], buf, ov2685_data_byte);
|
||||
if (ret < 0) {
|
||||
CVI_TRACE_SNS(CVI_DBG_ERR, "I2C_READ error!\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
// pack read back data
|
||||
data = 0;
|
||||
if (ov2685_data_byte == 2) {
|
||||
data = buf[0] << 8;
|
||||
data += buf[1];
|
||||
} else {
|
||||
data = buf[0];
|
||||
}
|
||||
|
||||
syslog(LOG_DEBUG, "i2c r 0x%x = 0x%x\n", addr, data);
|
||||
return data;
|
||||
}
|
||||
|
||||
int ov2685_write_register(VI_PIPE ViPipe, int addr, int data)
|
||||
{
|
||||
CVI_U8 idx = 0;
|
||||
int ret;
|
||||
CVI_U8 buf[8];
|
||||
|
||||
if (g_fd[ViPipe] < 0)
|
||||
return CVI_SUCCESS;
|
||||
|
||||
if (ov2685_addr_byte == 2) {
|
||||
buf[idx] = (addr >> 8) & 0xff;
|
||||
idx++;
|
||||
buf[idx] = addr & 0xff;
|
||||
idx++;
|
||||
}
|
||||
if (ov2685_data_byte == 1) {
|
||||
buf[idx] = data & 0xff;
|
||||
idx++;
|
||||
}
|
||||
|
||||
ret = write(g_fd[ViPipe], buf, ov2685_addr_byte + ov2685_data_byte);
|
||||
if (ret < 0) {
|
||||
CVI_TRACE_SNS(CVI_DBG_ERR, "I2C_WRITE error!\n");
|
||||
return CVI_FAILURE;
|
||||
}
|
||||
ret = read(g_fd[ViPipe], buf, ov2685_addr_byte + ov2685_data_byte);
|
||||
syslog(LOG_DEBUG, "i2c w 0x%x 0x%x\n", addr, data);
|
||||
return CVI_SUCCESS;
|
||||
}
|
||||
|
||||
static void delay_ms(int ms)
|
||||
{
|
||||
usleep(ms * 1000);
|
||||
}
|
||||
|
||||
void ov2685_standby(VI_PIPE ViPipe)
|
||||
{
|
||||
ov2685_write_register(ViPipe, 0x0100, 0x00);
|
||||
ov2685_write_register(ViPipe, 0x031c, 0xc7);
|
||||
ov2685_write_register(ViPipe, 0x0317, 0x01);
|
||||
|
||||
printf("ov2685_standby\n");
|
||||
}
|
||||
|
||||
void ov2685_restart(VI_PIPE ViPipe)
|
||||
{
|
||||
ov2685_write_register(ViPipe, 0x0317, 0x00);
|
||||
ov2685_write_register(ViPipe, 0x031c, 0xc6);
|
||||
ov2685_write_register(ViPipe, 0x0100, 0x09);
|
||||
|
||||
printf("ov2685_restart\n");
|
||||
}
|
||||
|
||||
void ov2685_default_reg_init(VI_PIPE ViPipe)
|
||||
{
|
||||
CVI_U32 i;
|
||||
|
||||
for (i = 0; i < g_pastOv2685[ViPipe]->astSyncInfo[0].snsCfg.u32RegNum; i++) {
|
||||
ov2685_write_register(ViPipe,
|
||||
g_pastOv2685[ViPipe]->astSyncInfo[0].snsCfg.astI2cData[i].u32RegAddr,
|
||||
g_pastOv2685[ViPipe]->astSyncInfo[0].snsCfg.astI2cData[i].u32Data);
|
||||
}
|
||||
}
|
||||
|
||||
int ov2685_probe(VI_PIPE ViPipe)
|
||||
{
|
||||
int nVal;
|
||||
int nVal2;
|
||||
|
||||
usleep(50);
|
||||
if (ov2685_i2c_init(ViPipe) != CVI_SUCCESS)
|
||||
return CVI_FAILURE;
|
||||
|
||||
nVal = ov2685_read_register(ViPipe, OV2685_CHIP_ID_ADDR_H);
|
||||
nVal2 = ov2685_read_register(ViPipe, OV2685_CHIP_ID_ADDR_L);
|
||||
if (nVal < 0 || nVal2 < 0) {
|
||||
CVI_TRACE_SNS(CVI_DBG_ERR, "read sensor id error.\n");
|
||||
return nVal;
|
||||
}
|
||||
|
||||
if ((((nVal & 0xFF) << 8) | (nVal2 & 0xFF)) != OV2685_CHIP_ID) {
|
||||
CVI_TRACE_SNS(CVI_DBG_ERR, "Sensor ID Mismatch! Use the wrong sensor??\n");
|
||||
return CVI_FAILURE;
|
||||
}
|
||||
|
||||
return CVI_SUCCESS;
|
||||
}
|
||||
|
||||
void ov2685_init(VI_PIPE ViPipe)
|
||||
{
|
||||
CVI_U8 u8ImgMode;
|
||||
|
||||
ov2685_i2c_init(ViPipe);
|
||||
|
||||
u8ImgMode = g_pastOv2685[ViPipe]->u8ImgMode;
|
||||
|
||||
ov2685_linear_1600x1200_30_init(ViPipe);
|
||||
|
||||
g_pastOv2685[ViPipe]->bInit = CVI_TRUE;
|
||||
}
|
||||
|
||||
void ov2685_exit(VI_PIPE ViPipe)
|
||||
{
|
||||
ov2685_i2c_exit(ViPipe);
|
||||
}
|
||||
|
||||
static void ov2685_linear_1600x1200_30_init(VI_PIPE ViPipe)
|
||||
{
|
||||
ov2685_write_register(ViPipe, 0x0103, 0x0001);
|
||||
ov2685_write_register(ViPipe, 0x3002, 0x0000);
|
||||
ov2685_write_register(ViPipe, 0x3016, 0x001c);
|
||||
ov2685_write_register(ViPipe, 0x3018, 0x0084);
|
||||
ov2685_write_register(ViPipe, 0x301d, 0x00f0);
|
||||
ov2685_write_register(ViPipe, 0x3020, 0x0000);
|
||||
ov2685_write_register(ViPipe, 0x3082, 0x0037);
|
||||
ov2685_write_register(ViPipe, 0x3083, 0x0003);
|
||||
ov2685_write_register(ViPipe, 0x3084, 0x0009);
|
||||
ov2685_write_register(ViPipe, 0x3085, 0x0004);
|
||||
ov2685_write_register(ViPipe, 0x3086, 0x0000);
|
||||
ov2685_write_register(ViPipe, 0x3087, 0x0001);
|
||||
ov2685_write_register(ViPipe, 0x3501, 0x004e);
|
||||
ov2685_write_register(ViPipe, 0x3502, 0x00e0);
|
||||
ov2685_write_register(ViPipe, 0x3503, 0x0000);
|
||||
ov2685_write_register(ViPipe, 0x350b, 0x0036);
|
||||
ov2685_write_register(ViPipe, 0x3600, 0x00b4);
|
||||
ov2685_write_register(ViPipe, 0x3603, 0x0035);
|
||||
ov2685_write_register(ViPipe, 0x3604, 0x0024);
|
||||
ov2685_write_register(ViPipe, 0x3605, 0x0000);
|
||||
ov2685_write_register(ViPipe, 0x3620, 0x0024);
|
||||
ov2685_write_register(ViPipe, 0x3621, 0x0034);
|
||||
ov2685_write_register(ViPipe, 0x3622, 0x0003);
|
||||
ov2685_write_register(ViPipe, 0x3628, 0x0010);
|
||||
ov2685_write_register(ViPipe, 0x3705, 0x003c);
|
||||
ov2685_write_register(ViPipe, 0x370a, 0x0021);
|
||||
ov2685_write_register(ViPipe, 0x370c, 0x0050);
|
||||
ov2685_write_register(ViPipe, 0x370d, 0x00c0);
|
||||
ov2685_write_register(ViPipe, 0x3717, 0x0058);
|
||||
ov2685_write_register(ViPipe, 0x3718, 0x0080);
|
||||
ov2685_write_register(ViPipe, 0x3720, 0x0000);
|
||||
ov2685_write_register(ViPipe, 0x3721, 0x0009);
|
||||
ov2685_write_register(ViPipe, 0x3722, 0x0006);
|
||||
ov2685_write_register(ViPipe, 0x3723, 0x0059);
|
||||
ov2685_write_register(ViPipe, 0x3738, 0x0099);
|
||||
ov2685_write_register(ViPipe, 0x3781, 0x0080);
|
||||
ov2685_write_register(ViPipe, 0x3784, 0x000c);
|
||||
ov2685_write_register(ViPipe, 0x3789, 0x0060);
|
||||
ov2685_write_register(ViPipe, 0x3800, 0x0000);
|
||||
ov2685_write_register(ViPipe, 0x3801, 0x0000);
|
||||
ov2685_write_register(ViPipe, 0x3802, 0x0000);
|
||||
ov2685_write_register(ViPipe, 0x3803, 0x0000);
|
||||
ov2685_write_register(ViPipe, 0x3804, 0x0006);
|
||||
ov2685_write_register(ViPipe, 0x3805, 0x004e);
|
||||
ov2685_write_register(ViPipe, 0x3806, 0x0004);
|
||||
ov2685_write_register(ViPipe, 0x3807, 0x00be);
|
||||
ov2685_write_register(ViPipe, 0x3808, 0x0006);
|
||||
ov2685_write_register(ViPipe, 0x3809, 0x0040);
|
||||
ov2685_write_register(ViPipe, 0x380a, 0x0004);
|
||||
ov2685_write_register(ViPipe, 0x380b, 0x00b0);
|
||||
ov2685_write_register(ViPipe, 0x380c, 0x0006);
|
||||
ov2685_write_register(ViPipe, 0x380d, 0x00a4);
|
||||
ov2685_write_register(ViPipe, 0x380e, 0x0005);
|
||||
ov2685_write_register(ViPipe, 0x380f, 0x000e);
|
||||
ov2685_write_register(ViPipe, 0x3810, 0x0000);
|
||||
ov2685_write_register(ViPipe, 0x3811, 0x0008);
|
||||
ov2685_write_register(ViPipe, 0x3812, 0x0000);
|
||||
ov2685_write_register(ViPipe, 0x3813, 0x0008);
|
||||
ov2685_write_register(ViPipe, 0x3814, 0x0011);
|
||||
ov2685_write_register(ViPipe, 0x3815, 0x0011);
|
||||
ov2685_write_register(ViPipe, 0x3819, 0x0004);
|
||||
ov2685_write_register(ViPipe, 0x3820, 0x00c0);
|
||||
ov2685_write_register(ViPipe, 0x3821, 0x0000);
|
||||
ov2685_write_register(ViPipe, 0x3a06, 0x0001);
|
||||
ov2685_write_register(ViPipe, 0x3a07, 0x0084);
|
||||
ov2685_write_register(ViPipe, 0x3a08, 0x0001);
|
||||
ov2685_write_register(ViPipe, 0x3a09, 0x0043);
|
||||
ov2685_write_register(ViPipe, 0x3a0a, 0x0024);
|
||||
ov2685_write_register(ViPipe, 0x3a0b, 0x0060);
|
||||
ov2685_write_register(ViPipe, 0x3a0c, 0x0028);
|
||||
ov2685_write_register(ViPipe, 0x3a0d, 0x0060);
|
||||
ov2685_write_register(ViPipe, 0x3a0e, 0x0004);
|
||||
ov2685_write_register(ViPipe, 0x3a0f, 0x008c);
|
||||
ov2685_write_register(ViPipe, 0x3a10, 0x0005);
|
||||
ov2685_write_register(ViPipe, 0x3a11, 0x000c);
|
||||
ov2685_write_register(ViPipe, 0x4000, 0x0081);
|
||||
ov2685_write_register(ViPipe, 0x4001, 0x0040);
|
||||
ov2685_write_register(ViPipe, 0x4008, 0x0002);
|
||||
ov2685_write_register(ViPipe, 0x4009, 0x0009);
|
||||
ov2685_write_register(ViPipe, 0x4300, 0x0000);
|
||||
ov2685_write_register(ViPipe, 0x430e, 0x0000);
|
||||
ov2685_write_register(ViPipe, 0x4602, 0x0002);
|
||||
ov2685_write_register(ViPipe, 0x481b, 0x0040);
|
||||
ov2685_write_register(ViPipe, 0x481f, 0x0040);
|
||||
ov2685_write_register(ViPipe, 0x4837, 0x0030);
|
||||
ov2685_write_register(ViPipe, 0x5000, 0x001f);
|
||||
ov2685_write_register(ViPipe, 0x5001, 0x0005);
|
||||
ov2685_write_register(ViPipe, 0x5002, 0x0030);
|
||||
ov2685_write_register(ViPipe, 0x5003, 0x0004);
|
||||
ov2685_write_register(ViPipe, 0x5004, 0x0000);
|
||||
ov2685_write_register(ViPipe, 0x5005, 0x000c);
|
||||
ov2685_write_register(ViPipe, 0x0100, 0x0001);
|
||||
|
||||
ov2685_write_register(ViPipe, 0x0000, 0x00); // end flag
|
||||
|
||||
ov2685_default_reg_init(ViPipe);
|
||||
delay_ms(10);
|
||||
|
||||
printf("ViPipe:%d,===OV2685 1600X1200 30fps 10bit LINEAR Init OK!===\n", ViPipe);
|
||||
}
|
||||
|
||||
|
||||
static void ov2685_linear_720p30_init(VI_PIPE ViPipe)
|
||||
{
|
||||
ov2685_write_register(ViPipe, 0x0103, 0x0001);
|
||||
ov2685_write_register(ViPipe, 0x3002, 0x0000);
|
||||
ov2685_write_register(ViPipe, 0x3016, 0x001c);
|
||||
ov2685_write_register(ViPipe, 0x3018, 0x0084);
|
||||
ov2685_write_register(ViPipe, 0x301d, 0x00f0);
|
||||
ov2685_write_register(ViPipe, 0x3020, 0x0000);
|
||||
ov2685_write_register(ViPipe, 0x3082, 0x0037);
|
||||
ov2685_write_register(ViPipe, 0x3083, 0x0003);
|
||||
ov2685_write_register(ViPipe, 0x3084, 0x0009);
|
||||
ov2685_write_register(ViPipe, 0x3085, 0x0004);
|
||||
ov2685_write_register(ViPipe, 0x3086, 0x0000);
|
||||
ov2685_write_register(ViPipe, 0x3087, 0x0001);
|
||||
ov2685_write_register(ViPipe, 0x3501, 0x004e);
|
||||
ov2685_write_register(ViPipe, 0x3502, 0x00e0);
|
||||
ov2685_write_register(ViPipe, 0x3503, 0x0000);
|
||||
ov2685_write_register(ViPipe, 0x350b, 0x0036);
|
||||
ov2685_write_register(ViPipe, 0x3600, 0x00b4);
|
||||
ov2685_write_register(ViPipe, 0x3603, 0x0035);
|
||||
ov2685_write_register(ViPipe, 0x3604, 0x0024);
|
||||
ov2685_write_register(ViPipe, 0x3605, 0x0000);
|
||||
ov2685_write_register(ViPipe, 0x3620, 0x0024);
|
||||
ov2685_write_register(ViPipe, 0x3621, 0x0034);
|
||||
ov2685_write_register(ViPipe, 0x3622, 0x0003);
|
||||
ov2685_write_register(ViPipe, 0x3628, 0x0010);
|
||||
ov2685_write_register(ViPipe, 0x3705, 0x003c);
|
||||
ov2685_write_register(ViPipe, 0x370a, 0x0021);
|
||||
ov2685_write_register(ViPipe, 0x370c, 0x0050);
|
||||
ov2685_write_register(ViPipe, 0x370d, 0x00c0);
|
||||
ov2685_write_register(ViPipe, 0x3717, 0x0058);
|
||||
ov2685_write_register(ViPipe, 0x3718, 0x0080);
|
||||
ov2685_write_register(ViPipe, 0x3720, 0x0000);
|
||||
ov2685_write_register(ViPipe, 0x3721, 0x0009);
|
||||
ov2685_write_register(ViPipe, 0x3722, 0x0006);
|
||||
ov2685_write_register(ViPipe, 0x3723, 0x0059);
|
||||
ov2685_write_register(ViPipe, 0x3738, 0x0099);
|
||||
ov2685_write_register(ViPipe, 0x3781, 0x0080);
|
||||
ov2685_write_register(ViPipe, 0x3784, 0x000c);
|
||||
ov2685_write_register(ViPipe, 0x3789, 0x0060);
|
||||
ov2685_write_register(ViPipe, 0x3800, 0x0000);
|
||||
ov2685_write_register(ViPipe, 0x3801, 0x00a0);
|
||||
ov2685_write_register(ViPipe, 0x3802, 0x0000);
|
||||
ov2685_write_register(ViPipe, 0x3803, 0x00f0);
|
||||
ov2685_write_register(ViPipe, 0x3804, 0x0005);
|
||||
ov2685_write_register(ViPipe, 0x3805, 0x00b4);
|
||||
ov2685_write_register(ViPipe, 0x3806, 0x0003);
|
||||
ov2685_write_register(ViPipe, 0x3807, 0x00d4);
|
||||
ov2685_write_register(ViPipe, 0x3808, 0x0005);
|
||||
ov2685_write_register(ViPipe, 0x3809, 0x0000);
|
||||
ov2685_write_register(ViPipe, 0x380a, 0x0002);
|
||||
ov2685_write_register(ViPipe, 0x380b, 0x00d0);
|
||||
ov2685_write_register(ViPipe, 0x380c, 0x0006);
|
||||
ov2685_write_register(ViPipe, 0x380d, 0x00a4);
|
||||
ov2685_write_register(ViPipe, 0x380e, 0x0005);
|
||||
ov2685_write_register(ViPipe, 0x380f, 0x000e);
|
||||
ov2685_write_register(ViPipe, 0x3810, 0x0000);
|
||||
ov2685_write_register(ViPipe, 0x3811, 0x0008);
|
||||
ov2685_write_register(ViPipe, 0x3812, 0x0000);
|
||||
ov2685_write_register(ViPipe, 0x3813, 0x0008);
|
||||
ov2685_write_register(ViPipe, 0x3814, 0x0011);
|
||||
ov2685_write_register(ViPipe, 0x3815, 0x0011);
|
||||
ov2685_write_register(ViPipe, 0x3819, 0x0004);
|
||||
ov2685_write_register(ViPipe, 0x3820, 0x00c0);
|
||||
ov2685_write_register(ViPipe, 0x3821, 0x0000);
|
||||
ov2685_write_register(ViPipe, 0x3a06, 0x0001);
|
||||
ov2685_write_register(ViPipe, 0x3a07, 0x0084);
|
||||
ov2685_write_register(ViPipe, 0x3a08, 0x0001);
|
||||
ov2685_write_register(ViPipe, 0x3a09, 0x0043);
|
||||
ov2685_write_register(ViPipe, 0x3a0a, 0x0024);
|
||||
ov2685_write_register(ViPipe, 0x3a0b, 0x0060);
|
||||
ov2685_write_register(ViPipe, 0x3a0c, 0x0028);
|
||||
ov2685_write_register(ViPipe, 0x3a0d, 0x0060);
|
||||
ov2685_write_register(ViPipe, 0x3a0e, 0x0004);
|
||||
ov2685_write_register(ViPipe, 0x3a0f, 0x008c);
|
||||
ov2685_write_register(ViPipe, 0x3a10, 0x0005);
|
||||
ov2685_write_register(ViPipe, 0x3a11, 0x000c);
|
||||
ov2685_write_register(ViPipe, 0x4000, 0x0081);
|
||||
ov2685_write_register(ViPipe, 0x4001, 0x0040);
|
||||
ov2685_write_register(ViPipe, 0x4008, 0x0002);
|
||||
ov2685_write_register(ViPipe, 0x4009, 0x0009);
|
||||
ov2685_write_register(ViPipe, 0x4300, 0x0000);
|
||||
ov2685_write_register(ViPipe, 0x430e, 0x0000);
|
||||
ov2685_write_register(ViPipe, 0x4602, 0x0002);
|
||||
ov2685_write_register(ViPipe, 0x481b, 0x0040);
|
||||
ov2685_write_register(ViPipe, 0x481f, 0x0040);
|
||||
ov2685_write_register(ViPipe, 0x4837, 0x0030);
|
||||
ov2685_write_register(ViPipe, 0x5000, 0x001f);
|
||||
ov2685_write_register(ViPipe, 0x5001, 0x0005);
|
||||
ov2685_write_register(ViPipe, 0x5002, 0x0030);
|
||||
ov2685_write_register(ViPipe, 0x5003, 0x0004);
|
||||
ov2685_write_register(ViPipe, 0x5004, 0x0000);
|
||||
ov2685_write_register(ViPipe, 0x5005, 0x000c);
|
||||
ov2685_write_register(ViPipe, 0x0100, 0x0001);
|
||||
|
||||
ov2685_write_register(ViPipe, 0x0000, 0x00); // end flag
|
||||
|
||||
ov2685_default_reg_init(ViPipe);
|
||||
delay_ms(10);
|
||||
|
||||
printf("ViPipe:%d,===OV2685 1280x720 30fps 10bit LINEAR Init OK!===\n", ViPipe);
|
||||
}
|
||||
@@ -146,6 +146,7 @@ extern ISP_SNS_OBJ_S stSnsOs04c10_Obj;
|
||||
extern ISP_SNS_OBJ_S stSnsOs04c10_Slave_Obj;
|
||||
extern ISP_SNS_OBJ_S stSnsOs08a20_Obj;
|
||||
extern ISP_SNS_OBJ_S stSnsOs08a20_Slave_Obj;
|
||||
extern ISP_SNS_OBJ_S stSnsOv2685_Obj;
|
||||
extern ISP_SNS_OBJ_S stSnsOv4689_Obj;
|
||||
extern ISP_SNS_OBJ_S stSnsOv5647_Obj;
|
||||
extern ISP_SNS_OBJ_S stSnsOv6211_Obj;
|
||||
|
||||
@@ -121,6 +121,10 @@ ifeq ($(CONFIG_SENSOR_OV_OS08A20_SLAVE), y)
|
||||
KBUILD_DEFINES += -DSENSOR_OV_OS08A20_SLAVE
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_SENSOR_OV_OV2685), y)
|
||||
KBUILD_DEFINES += -DSENSOR_OV_OV2685
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_SENSOR_OV_OV4689), y)
|
||||
KBUILD_DEFINES += -DSENSOR_OV_OV4689
|
||||
endif
|
||||
|
||||
@@ -313,6 +313,8 @@ typedef enum _SAMPLE_SNS_TYPE_E {
|
||||
VIVO_MCS369Q_4M_30FPS_12BIT,
|
||||
VIVO_MM308M2_2M_25FPS_8BIT,
|
||||
LONTIUM_LT6911_2M_60FPS_8BIT,
|
||||
GCORE_GC4653_MIPI_720P_60FPS_10BIT,
|
||||
GCORE_OV2685_MIPI_1600x1200_30FPS_10BIT,
|
||||
/* ------ LINEAR END ------*/
|
||||
SAMPLE_SNS_TYPE_LINEAR_BUTT,
|
||||
|
||||
|
||||
@@ -219,6 +219,8 @@ static const char *snsr_type_name[SAMPLE_SNS_TYPE_BUTT] = {
|
||||
"VIVO_MCS369Q_4M_30FPS_12BIT",
|
||||
"VIVO_MM308M2_2M_25FPS_8BIT",
|
||||
"LONTIUM_LT6911_2M_60FPS_8BIT",
|
||||
"GCORE_GC4653_MIPI_720P_60FPS_10BIT",
|
||||
"GCORE_OV2685_MIPI_1600x1200_30FPS_10BIT",
|
||||
/* ------ LINEAR END ------*/
|
||||
|
||||
/* ------ WDR 2TO1 BEGIN ------*/
|
||||
@@ -531,6 +533,12 @@ CVI_S32 SAMPLE_COMM_SNS_GetSize(SAMPLE_SNS_TYPE_E enMode, PIC_SIZE_E *penSize)
|
||||
*penSize = PIC_1080P;
|
||||
break;
|
||||
#endif
|
||||
case GCORE_GC4653_MIPI_720P_60FPS_10BIT:
|
||||
*penSize = PIC_720P;
|
||||
break;
|
||||
case GCORE_OV2685_MIPI_1600x1200_30FPS_10BIT:
|
||||
*penSize = PIC_1600x1200;
|
||||
break;
|
||||
default:
|
||||
s32Ret = CVI_FAILURE;
|
||||
break;
|
||||
@@ -886,16 +894,9 @@ CVI_S32 SAMPLE_COMM_SNS_GetDevAttr(SAMPLE_SNS_TYPE_E enSnsType, VI_DEV_ATTR_S *p
|
||||
case GCORE_GC1084_SLAVE_MIPI_1M_30FPS_10BIT:
|
||||
case GCORE_GC4653_MIPI_4M_30FPS_10BIT:
|
||||
case GCORE_GC4653_SLAVE_MIPI_4M_30FPS_10BIT:
|
||||
pstViDevAttr->enBayerFormat = BAYER_FORMAT_RG;
|
||||
// pstViDevAttr->enBayerFormat = BAYER_FORMAT_GB;
|
||||
break;
|
||||
// omnivision
|
||||
case OV_OS04A10_MIPI_4M_1440P_30FPS_12BIT:
|
||||
case OV_OS04A10_MIPI_4M_1440P_30FPS_10BIT_WDR2TO1:
|
||||
case TECHPOINT_TP2850_MIPI_2M_30FPS_8BIT:
|
||||
case TECHPOINT_TP2850_MIPI_4M_30FPS_8BIT:
|
||||
// pstViDevAttr->enBayerFormat = BAYER_FORMAT_RG;
|
||||
pstViDevAttr->enBayerFormat = BAYER_FORMAT_GB;
|
||||
pstViDevAttr->enBayerFormat = BAYER_FORMAT_GR;
|
||||
break;
|
||||
case SOI_K06_MIPI_4M_25FPS_10BIT:
|
||||
pstViDevAttr->enBayerFormat = BAYER_FORMAT_GB;
|
||||
@@ -906,6 +907,12 @@ CVI_S32 SAMPLE_COMM_SNS_GetDevAttr(SAMPLE_SNS_TYPE_E enSnsType, VI_DEV_ATTR_S *p
|
||||
pstViDevAttr->enIntfMode = VI_MODE_MIPI_YUV422;
|
||||
pstViDevAttr->enBayerFormat = BAYER_FORMAT_BG;
|
||||
break;
|
||||
case GCORE_GC4653_MIPI_720P_60FPS_10BIT:
|
||||
pstViDevAttr->enBayerFormat = BAYER_FORMAT_GR;
|
||||
break;
|
||||
case GCORE_OV2685_MIPI_1600x1200_30FPS_10BIT:
|
||||
pstViDevAttr->enBayerFormat = BAYER_FORMAT_BG;
|
||||
break;
|
||||
default:
|
||||
pstViDevAttr->enBayerFormat = BAYER_FORMAT_BG;
|
||||
break;
|
||||
@@ -1129,23 +1136,24 @@ CVI_S32 SAMPLE_COMM_SNS_GetIspAttrBySns(SAMPLE_SNS_TYPE_E enSnsType, ISP_PUB_ATT
|
||||
case GCORE_GC1084_SLAVE_MIPI_1M_30FPS_10BIT:
|
||||
case GCORE_GC4653_MIPI_4M_30FPS_10BIT:
|
||||
case GCORE_GC4653_SLAVE_MIPI_4M_30FPS_10BIT:
|
||||
pstPubAttr->enBayer = BAYER_RGGB;
|
||||
break;
|
||||
// omnivision
|
||||
case OV_OS04A10_MIPI_4M_1440P_30FPS_12BIT:
|
||||
case OV_OS04A10_MIPI_4M_1440P_30FPS_10BIT_WDR2TO1:
|
||||
case TECHPOINT_TP2850_MIPI_2M_30FPS_8BIT:
|
||||
case TECHPOINT_TP2850_MIPI_4M_30FPS_8BIT:
|
||||
// on licheervnano
|
||||
pstPubAttr->enBayer = BAYER_BGGR;
|
||||
// pstPubAttr->enBayer = BAYER_RGGB;
|
||||
//pstPubAttr->enBayer = BAYER_GRBG;
|
||||
pstPubAttr->enBayer = BAYER_RGGB;
|
||||
break;
|
||||
#ifdef ARCH_CV182X
|
||||
case SOI_F23_MIPI_2M_30FPS_10BIT:
|
||||
pstPubAttr->enBayer = BAYER_BGRGI;
|
||||
break;
|
||||
#endif
|
||||
case GCORE_GC4653_MIPI_720P_60FPS_10BIT:
|
||||
pstPubAttr->enBayer = BAYER_GRBG;
|
||||
pstPubAttr->f32FrameRate = 60;
|
||||
break;
|
||||
case GCORE_OV2685_MIPI_1600x1200_30FPS_10BIT:
|
||||
pstPubAttr->enBayer = BAYER_BGGR;
|
||||
pstPubAttr->f32FrameRate = 30;
|
||||
break;
|
||||
default:
|
||||
pstPubAttr->enBayer = BAYER_BGGR;
|
||||
break;
|
||||
@@ -1239,6 +1247,7 @@ CVI_VOID *SAMPLE_COMM_SNS_GetSnsObj(SAMPLE_SNS_TYPE_E enSnsType)
|
||||
return &stSnsGc4023_Obj;
|
||||
#endif
|
||||
#if defined(SENSOR_GCORE_GC4653)
|
||||
case GCORE_GC4653_MIPI_720P_60FPS_10BIT:
|
||||
case GCORE_GC4653_MIPI_4M_30FPS_10BIT:
|
||||
return &stSnsGc4653_Obj;
|
||||
#endif
|
||||
@@ -1317,6 +1326,11 @@ CVI_VOID *SAMPLE_COMM_SNS_GetSnsObj(SAMPLE_SNS_TYPE_E enSnsType)
|
||||
pSnsObj = &stSnsOs08a20_Slave_Obj;
|
||||
break;
|
||||
#endif
|
||||
#if defined(SENSOR_OV_OV2685)
|
||||
case GCORE_OV2685_MIPI_1600x1200_30FPS_10BIT:
|
||||
pSnsObj = &stSnsOv2685_Obj;
|
||||
break;
|
||||
#endif
|
||||
#if defined(SENSOR_OV_OV4689)
|
||||
case OV_OV4689_MIPI_4M_30FPS_10BIT:
|
||||
pSnsObj = &stSnsOv4689_Obj;
|
||||
|
||||
BIN
middleware/v2/sample/sensor_test/sample_0.yuv
Normal file
BIN
middleware/v2/sample/sensor_test/sample_0.yuv
Normal file
Binary file not shown.
Reference in New Issue
Block a user