SensorSupportList: weekly rls 2024.05.22
- ac9aa6, [feat](sensor):modify xs9922 sensor driver
This commit is contained in:
committed by
carbon
parent
93b1517102
commit
22d3a8abef
@ -53,6 +53,7 @@ sensor-$(CONFIG_SENSOR_VIVO_MCS369Q) += vivo_mcs369q
|
||||
sensor-$(CONFIG_SENSOR_VIVO_MM308M2) += vivo_mm308m2
|
||||
else ifeq ($(CHIP_ARCH), $(filter $(CHIP_ARCH), CV180X CV181X CV182X SG200X))
|
||||
sensor-$(CONFIG_SENSOR_BRIGATES_BG0808) += brigates_bg0808
|
||||
sensor-$(CONFIG_SENSOR_CHIPUP_XS9922B) += chipup_xs9922b
|
||||
sensor-$(CONFIG_SENSOR_CVSENS_CV2003) += cvsens_cv2003
|
||||
sensor-$(CONFIG_SENSOR_CVSENS_CV2003_1L_SLAVE) += cvsens_cv2003_1L_slave
|
||||
sensor-$(CONFIG_SENSOR_CVSENS_CV2003_1L_SLAVE1) += cvsens_cv2003_1L_slave1
|
||||
@ -143,6 +144,7 @@ sensor-$(CONFIG_SENSOR_SONY_IMX335) += sony_imx335
|
||||
sensor-$(CONFIG_SENSOR_TECHPOINT_TP2825) += techpoint_tp2825
|
||||
sensor-$(CONFIG_SENSOR_TECHPOINT_TP2863) += techpoint_tp2863
|
||||
sensor-$(CONFIG_SENSOR_LONTIUM_LT6911) += lontium_lt6911
|
||||
sensor-$(CONFIG_SENSOR_LONTIUM_LT7911) += lontium_lt7911
|
||||
else
|
||||
$(error not supported chip arch cv180x/cv181x/cv182x/cv183x)
|
||||
endif
|
||||
|
||||
@ -29,6 +29,9 @@ brigates_bg0808:
|
||||
byd_bf2253l:
|
||||
$(call MAKE_SENSOR, ${@})
|
||||
|
||||
chipup_xs9922b:
|
||||
$(call MAKE_SENSOR, ${@})
|
||||
|
||||
cvsens_cv2003:
|
||||
$(call MAKE_SENSOR, ${@})
|
||||
|
||||
@ -296,6 +299,9 @@ techpoint_tp2863:
|
||||
lontium_lt6911:
|
||||
$(call MAKE_SENSOR, ${@})
|
||||
|
||||
lontium_lt7911:
|
||||
$(call MAKE_SENSOR, ${@})
|
||||
|
||||
all_sensor:
|
||||
@$(MAKE) -f Makefile_full || exit 1;
|
||||
|
||||
|
||||
@ -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)/libsns_xs9922b.a
|
||||
TARGET_SO = $(MW_LIB)/libsns_xs9922b.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,315 @@
|
||||
#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_isp.h"
|
||||
|
||||
#include "xs9922b_cmos_ex.h"
|
||||
#include "xs9922b_cmos_param.h"
|
||||
|
||||
/****************************************************************************
|
||||
* global variables *
|
||||
****************************************************************************/
|
||||
ISP_SNS_COMMBUS_U g_aunXS9922b_BusInfo[VI_MAX_PIPE_NUM] = {
|
||||
[0] = { .s8I2cDev = 0},
|
||||
[1 ... VI_MAX_PIPE_NUM - 1] = { .s8I2cDev = -1}
|
||||
};
|
||||
|
||||
ISP_SNS_STATE_S *g_pastXS9922b[VI_MAX_PIPE_NUM] = {CVI_NULL};
|
||||
|
||||
#define XS9922B_SENSOR_GET_CTX(dev, pstCtx) (pstCtx = g_pastXS9922b[dev])
|
||||
#define XS9922B_SENSOR_SET_CTX(dev, pstCtx) (g_pastXS9922b[dev] = pstCtx)
|
||||
#define XS9922B_SENSOR_RESET_CTX(dev) (g_pastXS9922b[dev] = CVI_NULL)
|
||||
|
||||
#define XS9922B_RES_IS(w, h) ((w) <= 1280 && (h) <= 720)
|
||||
|
||||
#define XS9922B_ID0 0x22 // id1 0x40F0: 0x99 id0 0x40F1: 0x22
|
||||
#define XS9922B_ID1 0x99 // id1 0x40F0: 0x99 id0 0x40F1: 0x22
|
||||
#define XS9922B_ID 0x9922 // id1 0x40F0: 0x99 id0 0x40F1: 0x22
|
||||
|
||||
CVI_U16 g_au16XS9922b_BdgMuxMode[VI_MAX_PIPE_NUM] = {0};
|
||||
|
||||
/****************************************************************************
|
||||
* local variables and functions *
|
||||
****************************************************************************/
|
||||
static CVI_S32 cmos_get_wdr_size(VI_PIPE ViPipe, ISP_SNS_ISP_INFO_S *pstIspCfg)
|
||||
{
|
||||
const XS9922B_MODE_S *pstMode = CVI_NULL;
|
||||
ISP_SNS_STATE_S *pstSnsState = CVI_NULL;
|
||||
|
||||
XS9922B_SENSOR_GET_CTX(ViPipe, pstSnsState);
|
||||
CMOS_CHECK_POINTER(pstSnsState);
|
||||
|
||||
pstMode = &g_astXS9922b_mode[pstSnsState->u8ImgMode];
|
||||
pstIspCfg->frm_num = 1;
|
||||
memcpy(&pstIspCfg->img_size[0], &pstMode->astImg[0], sizeof(ISP_WDR_SIZE_S));
|
||||
|
||||
return CVI_SUCCESS;
|
||||
}
|
||||
|
||||
static CVI_S32 cmos_get_sns_regs_info(VI_PIPE ViPipe, ISP_SNS_SYNC_INFO_S *pstSnsSyncInfo)
|
||||
{
|
||||
ISP_SNS_STATE_S *pstSnsState = CVI_NULL;
|
||||
ISP_SNS_SYNC_INFO_S *pstCfg0 = CVI_NULL;
|
||||
|
||||
CMOS_CHECK_POINTER(pstSnsSyncInfo);
|
||||
XS9922B_SENSOR_GET_CTX(ViPipe, pstSnsState);
|
||||
CMOS_CHECK_POINTER(pstSnsState);
|
||||
|
||||
pstCfg0 = &pstSnsState->astSyncInfo[0];
|
||||
cmos_get_wdr_size(ViPipe, &pstCfg0->ispCfg);
|
||||
memcpy(pstSnsSyncInfo, &pstSnsState->astSyncInfo[0], sizeof(ISP_SNS_SYNC_INFO_S));
|
||||
|
||||
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);
|
||||
XS9922B_SENSOR_GET_CTX(ViPipe, pstSnsState);
|
||||
CMOS_CHECK_POINTER(pstSnsState);
|
||||
|
||||
u8SensorImageMode = pstSnsState->u8ImgMode;
|
||||
|
||||
if (pstSensorImageMode->f32Fps <= 30) {
|
||||
if (XS9922B_RES_IS(pstSensorImageMode->u16Width, pstSensorImageMode->u16Height)) {
|
||||
switch (g_au16XS9922b_BdgMuxMode[ViPipe]) {
|
||||
case SNS_BDG_MUX_NONE:
|
||||
u8SensorImageMode = XS9922B_MODE_720P_1CH;
|
||||
break;
|
||||
case SNS_BDG_MUX_2:
|
||||
u8SensorImageMode = XS9922B_MODE_720P_2CH;
|
||||
break;
|
||||
case SNS_BDG_MUX_3:
|
||||
u8SensorImageMode = XS9922B_MODE_720P_3CH;
|
||||
break;
|
||||
case SNS_BDG_MUX_4:
|
||||
u8SensorImageMode = XS9922B_MODE_720P_4CH;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
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);
|
||||
return CVI_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
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_global_init(VI_PIPE ViPipe)
|
||||
{
|
||||
ISP_SNS_STATE_S *pstSnsState = CVI_NULL;
|
||||
|
||||
XS9922B_SENSOR_GET_CTX(ViPipe, pstSnsState);
|
||||
CMOS_CHECK_POINTER_VOID(pstSnsState);
|
||||
|
||||
pstSnsState->bInit = CVI_FALSE;
|
||||
pstSnsState->u8ImgMode = XS9922B_MODE_720P_3CH;
|
||||
pstSnsState->enWDRMode = WDR_MODE_NONE;
|
||||
}
|
||||
|
||||
static CVI_S32 sensor_rx_attr(VI_PIPE ViPipe, SNS_COMBO_DEV_ATTR_S *pstRxAttr)
|
||||
{
|
||||
ISP_SNS_STATE_S *pstSnsState = CVI_NULL;
|
||||
|
||||
XS9922B_SENSOR_GET_CTX(ViPipe, pstSnsState);
|
||||
CMOS_CHECK_POINTER(pstSnsState);
|
||||
CMOS_CHECK_POINTER(pstRxAttr);
|
||||
|
||||
memcpy(pstRxAttr, &xs9922b_multi_rx_attr, sizeof(*pstRxAttr));
|
||||
pstRxAttr->img_size.width =
|
||||
g_astXS9922b_mode[pstSnsState->u8ImgMode].astImg[0].stSnsSize.u32Width;
|
||||
pstRxAttr->img_size.height =
|
||||
g_astXS9922b_mode[pstSnsState->u8ImgMode].astImg[0].stSnsSize.u32Height;
|
||||
|
||||
return CVI_SUCCESS;
|
||||
}
|
||||
|
||||
static CVI_S32 sensor_patch_rx_attr(RX_INIT_ATTR_S *pstRxInitAttr)
|
||||
{
|
||||
SNS_COMBO_DEV_ATTR_S *pstRxAttr = &xs9922b_multi_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 = xs9922b_init;
|
||||
pstSensorExpFunc->pfn_cmos_sensor_exit = xs9922b_exit;
|
||||
pstSensorExpFunc->pfn_cmos_sensor_global_init = sensor_global_init;
|
||||
pstSensorExpFunc->pfn_cmos_set_image_mode = cmos_set_image_mode;
|
||||
pstSensorExpFunc->pfn_cmos_get_sns_reg_info = cmos_get_sns_regs_info;
|
||||
|
||||
return CVI_SUCCESS;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* callback structure *
|
||||
****************************************************************************/
|
||||
|
||||
static CVI_S32 xs9922b_set_bus_info(VI_PIPE ViPipe, ISP_SNS_COMMBUS_U unSNSBusInfo)
|
||||
{
|
||||
g_aunXS9922b_BusInfo[ViPipe].s8I2cDev = unSNSBusInfo.s8I2cDev;
|
||||
|
||||
return CVI_SUCCESS;
|
||||
}
|
||||
|
||||
static CVI_S32 sensor_ctx_init(VI_PIPE ViPipe)
|
||||
{
|
||||
ISP_SNS_STATE_S *pastSnsStateCtx = CVI_NULL;
|
||||
|
||||
XS9922B_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));
|
||||
XS9922B_SENSOR_SET_CTX(ViPipe, pastSnsStateCtx);
|
||||
|
||||
return CVI_SUCCESS;
|
||||
}
|
||||
|
||||
static CVI_VOID sensor_ctx_exit(VI_PIPE ViPipe)
|
||||
{
|
||||
ISP_SNS_STATE_S *pastSnsStateCtx = CVI_NULL;
|
||||
|
||||
XS9922B_SENSOR_GET_CTX(ViPipe, pastSnsStateCtx);
|
||||
SENSOR_FREE(pastSnsStateCtx);
|
||||
XS9922B_SENSOR_RESET_CTX(ViPipe);
|
||||
}
|
||||
|
||||
static CVI_S32 sensor_register_callback(VI_PIPE ViPipe, ALG_LIB_S *pstAeLib, ALG_LIB_S *pstAwbLib)
|
||||
{
|
||||
(void) pstAeLib;
|
||||
(void) pstAwbLib;
|
||||
|
||||
CVI_S32 s32Ret;
|
||||
ISP_SENSOR_REGISTER_S stIspRegister;
|
||||
ISP_SNS_ATTR_INFO_S stSnsAttrInfo;
|
||||
|
||||
s32Ret = sensor_ctx_init(ViPipe);
|
||||
|
||||
if (s32Ret != CVI_SUCCESS)
|
||||
return CVI_FAILURE;
|
||||
|
||||
stSnsAttrInfo.eSensorId = XS9922B_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;
|
||||
}
|
||||
|
||||
return CVI_SUCCESS;
|
||||
}
|
||||
|
||||
static CVI_S32 sensor_unregister_callback(VI_PIPE ViPipe, ALG_LIB_S *pstAeLib, ALG_LIB_S *pstAwbLib)
|
||||
{
|
||||
(void) pstAeLib;
|
||||
(void) pstAwbLib;
|
||||
|
||||
CVI_S32 s32Ret;
|
||||
|
||||
s32Ret = CVI_ISP_SensorUnRegCallBack(ViPipe, XS9922B_ID);
|
||||
if (s32Ret != CVI_SUCCESS) {
|
||||
CVI_TRACE_SNS(CVI_DBG_ERR, "sensor unregister callback function 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)
|
||||
{
|
||||
g_au16XS9922b_BdgMuxMode[ViPipe] = pstInitAttr->enSnsBdgMuxMode;
|
||||
|
||||
return CVI_SUCCESS;
|
||||
}
|
||||
|
||||
ISP_SNS_OBJ_S stSnsXS9922B_Obj = {
|
||||
.pfnRegisterCallback = sensor_register_callback,
|
||||
.pfnUnRegisterCallback = sensor_unregister_callback,
|
||||
.pfnStandby = CVI_NULL,
|
||||
.pfnRestart = CVI_NULL,
|
||||
.pfnMirrorFlip = CVI_NULL,
|
||||
.pfnWriteReg = xs9922b_write_register,
|
||||
.pfnReadReg = xs9922b_read_register,
|
||||
.pfnSetBusInfo = xs9922b_set_bus_info,
|
||||
.pfnSetInit = sensor_set_init,
|
||||
.pfnPatchRxAttr = sensor_patch_rx_attr,
|
||||
.pfnPatchI2cAddr = CVI_NULL,
|
||||
.pfnGetRxAttr = sensor_rx_attr,
|
||||
.pfnExpSensorCb = cmos_init_sensor_exp_function,
|
||||
.pfnExpAeCb = CVI_NULL,
|
||||
.pfnSnsProbe = CVI_NULL,
|
||||
};
|
||||
|
||||
@ -0,0 +1,741 @@
|
||||
#ifndef __XS9922B_CMOS_EX_H_
|
||||
#define __XS9922B_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"
|
||||
|
||||
typedef enum _XS9922B_MODE_E {
|
||||
XS9922B_MODE_NONE,
|
||||
XS9922B_MODE_720P_1CH,
|
||||
XS9922B_MODE_720P_2CH,
|
||||
XS9922B_MODE_720P_3CH,
|
||||
XS9922B_MODE_720P_4CH,
|
||||
XS9922B_MODE_NUM
|
||||
} XS9922B_MODE_E;
|
||||
|
||||
typedef struct _XS9922B_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_S stAgain[2];
|
||||
SNS_ATTR_S stDgain[2];
|
||||
CVI_U8 u8DgainReg;
|
||||
char name[64];
|
||||
} XS9922B_MODE_S;
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* The config of xs9922b *
|
||||
****************************************************************************/
|
||||
typedef struct regval {
|
||||
unsigned short addr;
|
||||
unsigned char val;
|
||||
unsigned char nDelay; // ms
|
||||
}REG_VAL;
|
||||
|
||||
|
||||
#define REG_NULL 0xFFFF
|
||||
#define REG_DELAY 0xFFFE
|
||||
/*
|
||||
* 0x100 ~ 0x1E2
|
||||
*/
|
||||
#define USE_HD_CAM 1
|
||||
|
||||
/*
|
||||
* 0x300 ~ 0x349
|
||||
*/
|
||||
#define USE_SD_CAM 0
|
||||
|
||||
/*
|
||||
* Coaxial communication
|
||||
* 0x600 ~ 659
|
||||
*/
|
||||
#define USE_COAXIAL 0
|
||||
|
||||
/*
|
||||
* 0x700 ~ 0x714
|
||||
* 0x400c ~ 0x4012
|
||||
* 0x4350~0x4362
|
||||
* 0x4407 ~ 0x4429
|
||||
*/
|
||||
#define USE_AUDIO 0
|
||||
|
||||
|
||||
//去斜纹的配置,从配置分辨率部分挪到了初始化部分
|
||||
#define RM_STRIPES 1
|
||||
|
||||
//#define MIPILANESWAP 1
|
||||
|
||||
#define USE_YUVGAIN 1
|
||||
#define Y_GAIN 0x80
|
||||
#define U_GAIN 0x80
|
||||
#define V_GAIN 0x80
|
||||
|
||||
#define XS9922B_FREERUN_COLOR_VAL 0x8 //0x6 is blue
|
||||
|
||||
#define XS9922B_CH0_EN_REG 0x0e08
|
||||
#define XS9922B_CH1_EN_REG 0x1e08
|
||||
#define XS9922B_CH2_EN_REG 0x2e08
|
||||
#define XS9922B_CH3_EN_REG 0x3e08
|
||||
|
||||
|
||||
static const REG_VAL xs9922_init_cfg[] = {
|
||||
{0x4200, 0x3f, 0x00},
|
||||
{0x4210, 0x3f, 0x00},
|
||||
{0x4220, 0x3f, 0x00},
|
||||
{0x4230, 0x3f, 0x00},
|
||||
{0x0e08, 0x00, 0x00},
|
||||
{0x1e08, 0x00, 0x00},
|
||||
{0x2e08, 0x00, 0x00},
|
||||
{0x3e08, 0x00, 0x00},
|
||||
//{0x4500, 0x02},
|
||||
{0x4f00, 0x01, 0x00},
|
||||
{0x4030, 0x3f, 0x00},
|
||||
{0x0e02, 0x00, 0x00},
|
||||
{0x1e02, 0x00, 0x00},
|
||||
{0x2e02, 0x00, 0x00},
|
||||
{0x3e02, 0x00, 0x00},
|
||||
{0x0803, 0x00, 0x00},
|
||||
{0x1803, 0x00, 0x00},
|
||||
{0x2803, 0x00, 0x00},
|
||||
{0x3803, 0x00, 0x00},
|
||||
{0x4020, 0x00, 0x00},
|
||||
{0x080e, 0x00, 0x00},
|
||||
{0x080e, 0x20, 0x00},
|
||||
{0x080e, 0x28, 0x00},
|
||||
{0x180e, 0x00, 0x00},
|
||||
{0x180e, 0x20, 0x00},
|
||||
{0x180e, 0x28, 0x00},
|
||||
{0x280e, 0x00, 0x00},
|
||||
{0x280e, 0x20, 0x00},
|
||||
{0x280e, 0x28, 0x00},
|
||||
{0x380e, 0x00, 0x00},
|
||||
{0x380e, 0x20, 0x00},
|
||||
{0x380e, 0x28, 0x00},
|
||||
{0x4020, 0x03, 0x00},
|
||||
{0x0803, 0x0f, 0x00},
|
||||
{0x1803, 0x0f, 0x00},
|
||||
{0x2803, 0x0f, 0x00},
|
||||
{0x3803, 0x0f, 0x00},
|
||||
#if RM_STRIPES
|
||||
{0x0800, 0x16, 0x00},
|
||||
{0x1800, 0x16, 0x00},
|
||||
{0x2800, 0x16, 0x00},
|
||||
{0x3800, 0x16, 0x00},
|
||||
{0x4205, 0x36, 0x00},
|
||||
{0x4215, 0x36, 0x00},
|
||||
{0x4225, 0x36, 0x00},
|
||||
{0x4235, 0x36, 0x00},//wait(0.05)
|
||||
{0x4205, 0x26, 0x00},
|
||||
{0x4215, 0x26, 0x00},
|
||||
{0x4225, 0x26, 0x00},
|
||||
{0x4235, 0x26, 0x00},
|
||||
{0x0800, 0x17, 0x00},
|
||||
{0x1800, 0x17, 0x00},
|
||||
{0x2800, 0x17, 0x00},
|
||||
{0x3800, 0x17, 0x00},
|
||||
#endif
|
||||
{0x4340, 0x65, 0x00},
|
||||
{0x4204, 0x02, 0x00},
|
||||
{0x4214, 0x02, 0x00},
|
||||
{0x4224, 0x02, 0x00},
|
||||
{0x4234, 0x02, 0x00},
|
||||
{0x4080, 0x07, 0x00},
|
||||
{0x4119, 0x01, 0x00},
|
||||
{0x0501, 0x84, 0x00},
|
||||
#if USE_YUVGAIN
|
||||
{0x010e, Y_GAIN, 0x00},
|
||||
{0x010f, U_GAIN, 0x00},
|
||||
{0x0110, V_GAIN, 0x00},
|
||||
#endif
|
||||
{0x0111, 0x40, 0x00},
|
||||
{0x1501, 0x81, 0x00},
|
||||
#if USE_YUVGAIN
|
||||
{0x110e, Y_GAIN, 0x00},
|
||||
{0x110f, U_GAIN, 0x00},
|
||||
{0x1110, V_GAIN, 0x00},
|
||||
#endif
|
||||
{0x1111, 0x40, 0x00},
|
||||
{0x2501, 0x8e, 0x00},
|
||||
#if USE_YUVGAIN
|
||||
{0x210e, Y_GAIN, 0x00},
|
||||
{0x210f, U_GAIN, 0x00},
|
||||
{0x2110, V_GAIN, 0x00},
|
||||
#endif
|
||||
{0x2111, 0x40, 0x00},
|
||||
{0x3501, 0x8b, 0x00},
|
||||
#if USE_YUVGAIN
|
||||
{0x310e, Y_GAIN, 0x00},
|
||||
{0x310f, U_GAIN, 0x00},
|
||||
{0x3110, V_GAIN, 0x00},
|
||||
#endif
|
||||
{0x3111, 0x40, 0x00},
|
||||
{0x4141, 0x22, 0x00},
|
||||
{0x4140, 0x22, 0x00},
|
||||
{0x413f, 0x22, 0x00},
|
||||
{0x413e, 0x22, 0x00},
|
||||
{0x030c, 0x03, 0x00},
|
||||
{0x0300, 0x3f, 0x00},
|
||||
{0x0333, 0x09, 0x00},
|
||||
{0x0305, 0xe0, 0x00},
|
||||
{0x011c, 0x32, 0x00},
|
||||
{0x0105, 0xe1, 0x00},
|
||||
//{0x0106, 0x80}, // contrast
|
||||
//{0x0107, 0x00}, // brightness
|
||||
//{0x0108, 0x80}, // staturation
|
||||
//{0x0109, 0x00}, // hue
|
||||
{0x01bf, 0x4e, 0x00},
|
||||
{0x0b7c, 0x02, 0x00},
|
||||
{0x0b55, 0x80, 0x00},
|
||||
{0x0b56, 0x00, 0x00},
|
||||
{0x0b59, 0x04, 0x00},
|
||||
{0x0b5a, 0x01, 0x00},
|
||||
{0x0b5c, 0x07, 0x00},
|
||||
{0x0b5e, 0x05, 0x00},
|
||||
{0x0b31, 0x18, 0x00},
|
||||
{0x0b36, 0x40, 0x00},
|
||||
{0x0b37, 0x1f, 0x00},
|
||||
{0x0b4b, 0x10, 0x00},
|
||||
{0x0b4e, 0x05, 0x00},
|
||||
{0x0b51, 0x21, 0x00},
|
||||
{0x0b15, 0x03, 0x00},
|
||||
{0x0b16, 0x03, 0x00},
|
||||
{0x0b17, 0x03, 0x00},
|
||||
{0x0b07, 0x03, 0x00},
|
||||
{0x0b08, 0x05, 0x00},
|
||||
{0x0b1a, 0x10, 0x00},
|
||||
{0x0b1e, 0xb8, 0x00},
|
||||
{0x0b1f, 0x08, 0x00},
|
||||
{0x0b5f, 0x64, 0x00},
|
||||
{0x130c, 0x03, 0x00},
|
||||
{0x1300, 0x3f, 0x00},
|
||||
{0x1333, 0x09, 0x00},
|
||||
{0x111c, 0x32, 0x00},
|
||||
{0x11bf, 0x4e, 0x00},
|
||||
{0x1b7c, 0x02, 0x00},
|
||||
{0x1b55, 0x80, 0x00},
|
||||
{0x1b56, 0x00, 0x00},
|
||||
{0x1b59, 0x04, 0x00},
|
||||
{0x1b5a, 0x01, 0x00},
|
||||
{0x1b5c, 0x07, 0x00},
|
||||
{0x1b5e, 0x05, 0x00},
|
||||
{0x1b31, 0x18, 0x00},
|
||||
{0x1b36, 0x40, 0x00},
|
||||
{0x1b37, 0x1f, 0x00},
|
||||
{0x1b4b, 0x10, 0x00},
|
||||
{0x1b4e, 0x05, 0x00},
|
||||
{0x1b51, 0x21, 0x00},
|
||||
{0x1b15, 0x03, 0x00},
|
||||
{0x1b16, 0x03, 0x00},
|
||||
{0x1b17, 0x03, 0x00},
|
||||
{0x1b07, 0x03, 0x00},
|
||||
{0x1b08, 0x05, 0x00},
|
||||
{0x1b1a, 0x10, 0x00},
|
||||
{0x1b1e, 0xb8, 0x00},
|
||||
{0x1b1f, 0x08, 0x00},
|
||||
{0x1b5f, 0x64, 0x00},
|
||||
{0x1105, 0xe1, 0x00},
|
||||
//{0x1106, 0x80},
|
||||
//{0x1107, 0x00},
|
||||
//{0x1108, 0x80},
|
||||
//{0x1109, 0x00},
|
||||
{0x230c, 0x03, 0x00},
|
||||
{0x2300, 0x3f, 0x00},
|
||||
{0x2333, 0x09, 0x00},
|
||||
{0x211c, 0x32, 0x00},
|
||||
{0x21bf, 0x4e, 0x00},
|
||||
{0x2b7c, 0x02, 0x00},
|
||||
{0x2b55, 0x80, 0x00},
|
||||
{0x2b56, 0x00, 0x00},
|
||||
{0x2b59, 0x04, 0x00},
|
||||
{0x2b5a, 0x01, 0x00},
|
||||
{0x2b5c, 0x07, 0x00},
|
||||
{0x2b5e, 0x05, 0x00},
|
||||
{0x2b31, 0x18, 0x00},
|
||||
{0x2b36, 0x40, 0x00},
|
||||
{0x2b37, 0x1f, 0x00},
|
||||
{0x2b4b, 0x10, 0x00},
|
||||
{0x2b4e, 0x05, 0x00},
|
||||
{0x2b51, 0x21, 0x00},
|
||||
{0x2b15, 0x03, 0x00},
|
||||
{0x2b16, 0x03, 0x00},
|
||||
{0x2b17, 0x03, 0x00},
|
||||
{0x2b07, 0x03, 0x00},
|
||||
{0x2b08, 0x05, 0x00},
|
||||
{0x2b1a, 0x10, 0x00},
|
||||
{0x2b1e, 0xb8, 0x00},
|
||||
{0x2b1f, 0x08, 0x00},
|
||||
{0x2b5f, 0x64, 0x00},
|
||||
{0x2105, 0xe1, 0x00},
|
||||
//{0x2106, 0x80},
|
||||
//{0x2107, 0x00},
|
||||
//{0x2108, 0x80},
|
||||
//{0x2109, 0x00},
|
||||
{0x330c, 0x03, 0x00},
|
||||
{0x3300, 0x3f, 0x00},
|
||||
{0x3333, 0x09, 0x00},
|
||||
{0x311c, 0x32, 0x00},
|
||||
{0x31bf, 0x4e, 0x00},
|
||||
{0x3b7c, 0x02, 0x00},
|
||||
{0x3b55, 0x80, 0x00},
|
||||
{0x3b56, 0x00, 0x00},
|
||||
{0x3b59, 0x04, 0x00},
|
||||
{0x3b5a, 0x01, 0x00},
|
||||
{0x3b5c, 0x07, 0x00},
|
||||
{0x3b5e, 0x05, 0x00},
|
||||
{0x3b31, 0x18, 0x00},
|
||||
{0x3b36, 0x40, 0x00},
|
||||
{0x3b37, 0x1f, 0x00},
|
||||
{0x3b4b, 0x10, 0x00},
|
||||
{0x3b4e, 0x05, 0x00},
|
||||
{0x3b51, 0x21, 0x00},
|
||||
{0x3b15, 0x03, 0x00},
|
||||
{0x3b16, 0x03, 0x00},
|
||||
{0x3b17, 0x03, 0x00},
|
||||
{0x3b07, 0x03, 0x00},
|
||||
{0x3b08, 0x05, 0x00},
|
||||
{0x3b1a, 0x10, 0x00},
|
||||
{0x3b1e, 0xb8, 0x00},
|
||||
{0x3b1f, 0x08, 0x00},
|
||||
{0x3b5f, 0x64, 0x00},
|
||||
{0x3105, 0xe1, 0x00},
|
||||
//{0x3106, 0x80},
|
||||
//{0x3107, 0x00},
|
||||
//{0x3108, 0x80},
|
||||
//{0x3109, 0x00},
|
||||
{0x4800, 0x81, 0x00},
|
||||
{0x4802, 0x01, 0x00},
|
||||
{0x4030, 0x15, 0x00},
|
||||
{0x50fc, 0x00, 0x00},
|
||||
{0x50fd, 0x00, 0x00},
|
||||
{0x50fe, 0x0d, 0x00},
|
||||
{0x50ff, 0x59, 0x00},
|
||||
{0x50e4, 0x00, 0x00},//32位寄存器,0x50e4高字节,0x50e7低8位字节
|
||||
{0x50e5, 0x00, 0x00},
|
||||
{0x50e6, 0x2f, 0x00},
|
||||
{0x50e7, 0x03, 0x00},//0=1lane,1=2lane,2=3lane,3=4lane
|
||||
{0x50f0, 0x00, 0x00},
|
||||
{0x50f1, 0x00, 0x00},
|
||||
{0x50f2, 0x00, 0x00},
|
||||
{0x50f3, 0x32, 0x00},
|
||||
{0x50e0, 0x00, 0x00},
|
||||
{0x50e1, 0x00, 0x00},
|
||||
{0x50e2, 0x00, 0x00},
|
||||
{0x50e3, 0x00, 0x00},
|
||||
{0x5114, 0x00, 0x00},
|
||||
{0x5115, 0x00, 0x00},
|
||||
{0x5116, 0x00, 0x00},
|
||||
{0x5117, 0x03, 0x00},
|
||||
{0x5114, 0x00, 0x00},
|
||||
{0x5115, 0x00, 0x00},
|
||||
{0x5116, 0x00, 0x00},
|
||||
{0x5117, 0x02, 0x00},
|
||||
{0x5118, 0x00, 0x00},
|
||||
{0x5119, 0x01, 0x00},
|
||||
{0x511a, 0x00, 0x00},
|
||||
{0x511b, 0x44, 0x00},
|
||||
{0x5114, 0x00, 0x00},
|
||||
{0x5115, 0x00, 0x00},
|
||||
{0x5116, 0x00, 0x00},
|
||||
{0x5117, 0x00, 0x00},
|
||||
{0x5118, 0x00, 0x00},
|
||||
{0x5119, 0x00, 0x00},
|
||||
{0x511a, 0x00, 0x00},
|
||||
{0x511b, 0x78, 0x00},//0x78=1.5G,0x36=1.2G,0x34=1G,0x32=800M,0x30=700M,0x2E=600M
|
||||
{0x5114, 0x00, 0x00},
|
||||
{0x5115, 0x00, 0x00},
|
||||
{0x5116, 0x00, 0x00},
|
||||
{0x5117, 0x02, 0x00},
|
||||
{0x5118, 0x00, 0x00},
|
||||
{0x5119, 0x01, 0x00},
|
||||
{0x511a, 0x00, 0x00},
|
||||
{0x511b, 0x30, 0x00},
|
||||
{0x5114, 0x00, 0x00},
|
||||
{0x5115, 0x00, 0x00},
|
||||
{0x5116, 0x00, 0x00},
|
||||
{0x5117, 0x00, 0x00},
|
||||
{0x5118, 0x00, 0x00},
|
||||
{0x5119, 0x00, 0x00},
|
||||
{0x511a, 0x00, 0x00},
|
||||
{0x511b, 0x03, 0x00},
|
||||
{0x5114, 0x00, 0x00},
|
||||
{0x5115, 0x00, 0x00},
|
||||
{0x5116, 0x00, 0x00},
|
||||
{0x5117, 0x02, 0x00},
|
||||
{0x5118, 0x00, 0x00},
|
||||
{0x5119, 0x01, 0x00},
|
||||
{0x511a, 0x00, 0x00},
|
||||
{0x511b, 0x40, 0x00},
|
||||
{0x5114, 0x00, 0x00},
|
||||
{0x5115, 0x00, 0x00},
|
||||
{0x5116, 0x00, 0x00},
|
||||
{0x5117, 0x00, 0x00},
|
||||
{0x5118, 0x00, 0x00},
|
||||
{0x5119, 0x00, 0x00},
|
||||
{0x511a, 0x00, 0x00},
|
||||
{0x511b, 0x03, 0x00},
|
||||
{0x5114, 0x00, 0x00},
|
||||
{0x5115, 0x00, 0x00},
|
||||
{0x5116, 0x00, 0x00},
|
||||
{0x5117, 0x02, 0x00},
|
||||
{0x5118, 0x00, 0x00},
|
||||
{0x5119, 0x01, 0x00},
|
||||
{0x511a, 0x00, 0x00},
|
||||
{0x511b, 0x50, 0x00},
|
||||
{0x5114, 0x00, 0x00},
|
||||
{0x5115, 0x00, 0x00},
|
||||
{0x5116, 0x00, 0x00},
|
||||
{0x5117, 0x00, 0x00},
|
||||
{0x5118, 0x00, 0x00},
|
||||
{0x5119, 0x00, 0x00},
|
||||
{0x511a, 0x00, 0x00},
|
||||
{0x511b, 0x03, 0x00},
|
||||
{0x5114, 0x00, 0x00},
|
||||
{0x5115, 0x00, 0x00},
|
||||
{0x5116, 0x00, 0x00},
|
||||
{0x5117, 0x02, 0x00},
|
||||
{0x5118, 0x00, 0x00},
|
||||
{0x5119, 0x01, 0x00},
|
||||
{0x511a, 0x00, 0x00},
|
||||
{0x511b, 0x80, 0x00},
|
||||
{0x5114, 0x00, 0x00},
|
||||
{0x5115, 0x00, 0x00},
|
||||
{0x5116, 0x00, 0x00},
|
||||
{0x5117, 0x00, 0x00},
|
||||
{0x5118, 0x00, 0x00},
|
||||
{0x5119, 0x00, 0x00},
|
||||
{0x511a, 0x00, 0x00},
|
||||
{0x511b, 0x03, 0x00},
|
||||
{0x5114, 0x00, 0x00},
|
||||
{0x5115, 0x00, 0x00},
|
||||
{0x5116, 0x00, 0x00},
|
||||
{0x5117, 0x02, 0x00},
|
||||
{0x5118, 0x00, 0x00},
|
||||
{0x5119, 0x01, 0x00},
|
||||
{0x511a, 0x00, 0x00},
|
||||
{0x511b, 0x90, 0x00},
|
||||
{0x5114, 0x00, 0x00},
|
||||
{0x5115, 0x00, 0x00},
|
||||
{0x5116, 0x00, 0x00},
|
||||
{0x5117, 0x00, 0x00},
|
||||
{0x5118, 0x00, 0x00},
|
||||
{0x5119, 0x00, 0x00},
|
||||
{0x511a, 0x00, 0x00},
|
||||
{0x511b, 0x03, 0x00},
|
||||
{0x5114, 0x00, 0x00},
|
||||
{0x5115, 0x00, 0x00},
|
||||
{0x5116, 0x00, 0x00},
|
||||
{0x5117, 0x02, 0x00},
|
||||
{0x5118, 0x00, 0x00},
|
||||
{0x5119, 0x01, 0x00},
|
||||
{0x511a, 0x00, 0x00},
|
||||
{0x511b, 0x20, 0x00},
|
||||
{0x5114, 0x00, 0x00},
|
||||
{0x5115, 0x00, 0x00},
|
||||
{0x5116, 0x00, 0x00},
|
||||
{0x5117, 0x00, 0x00},
|
||||
{0x5118, 0x00, 0x00},
|
||||
{0x5119, 0x00, 0x00},
|
||||
{0x511a, 0x00, 0x00},
|
||||
{0x511b, 0x45, 0x00},
|
||||
{0x5114, 0x00, 0x00},
|
||||
{0x5115, 0x00, 0x00},
|
||||
{0x5116, 0x00, 0x00},
|
||||
{0x5117, 0x02, 0x00},
|
||||
#if MIPILANESWAP
|
||||
{0x5114, 0x00, 0x00},
|
||||
{0x5115, 0x00, 0x00},
|
||||
{0x5116, 0x00, 0x00},
|
||||
{0x5117, 0x02, 0x00},
|
||||
{0x5118, 0x00, 0x00},
|
||||
{0x5119, 0x01, 0x00},
|
||||
{0x511a, 0x00, 0x00},
|
||||
{0x511b, 0x55, 0x00},
|
||||
{0x5114, 0x00, 0x00},
|
||||
{0x5115, 0x00, 0x00},
|
||||
{0x5116, 0x00, 0x00},
|
||||
{0x5117, 0x00, 0x00},
|
||||
{0x5118, 0x00, 0x00},
|
||||
{0x5119, 0x00, 0x00},
|
||||
{0x511a, 0x00, 0x00},
|
||||
{0x511b, 0x01, 0x00},
|
||||
{0x5114, 0x00, 0x00},
|
||||
{0x5115, 0x00, 0x00},
|
||||
{0x5116, 0x00, 0x00},
|
||||
{0x5117, 0x02, 0x00},
|
||||
|
||||
{0x5114, 0x00, 0x00},
|
||||
{0x5115, 0x00, 0x00},
|
||||
{0x5116, 0x00, 0x00},
|
||||
{0x5117, 0x02, 0x00},
|
||||
{0x5118, 0x00, 0x00},
|
||||
{0x5119, 0x01, 0x00},
|
||||
{0x511a, 0x00, 0x00},
|
||||
{0x511b, 0x85, 0x00},
|
||||
{0x5114, 0x00, 0x00},
|
||||
{0x5115, 0x00, 0x00},
|
||||
{0x5116, 0x00, 0x00},
|
||||
{0x5117, 0x00, 0x00},
|
||||
{0x5118, 0x00, 0x00},
|
||||
{0x5119, 0x00, 0x00},
|
||||
{0x511a, 0x00, 0x00},
|
||||
{0x511b, 0x01, 0x00},
|
||||
{0x5114, 0x00, 0x00},
|
||||
{0x5115, 0x00, 0x00},
|
||||
{0x5116, 0x00, 0x00},
|
||||
{0x5117, 0x02, 0x00},
|
||||
#endif
|
||||
{0x50e0, 0x00, 0x00},
|
||||
{0x50e1, 0x00, 0x00},
|
||||
{0x50e2, 0x00, 0x00},
|
||||
{0x50e3, 0x04, 0x00},
|
||||
{0x50e0, 0x00, 0x00},
|
||||
{0x50e1, 0x00, 0x00},
|
||||
{0x50e2, 0x00, 0x00},
|
||||
{0x50e3, 0x05, 0x00},
|
||||
{0x50e0, 0x00, 0x00},
|
||||
{0x50e1, 0x00, 0x00},
|
||||
{0x50e2, 0x00, 0x00},
|
||||
{0x50e3, 0x07, 0x00},
|
||||
{0x50e8, 0x00, 0x00},
|
||||
{0x50e9, 0x00, 0x00},
|
||||
{0x50ea, 0x00, 0x00},
|
||||
{0x50eb, 0x01, 0x00}, //1:连续模式
|
||||
{0x4801, 0x81, 0x00},
|
||||
{0x4031, 0x01, 0x00},
|
||||
{0x4138, 0x1e, 0x00},
|
||||
{0x413b, 0x1e, 0x00},
|
||||
{0x4135, 0x1e, 0x00},
|
||||
{0x412f, 0x1e, 0x00},
|
||||
{0x412c, 0x1e, 0x00},
|
||||
{0x4126, 0x1e, 0x00},
|
||||
{0x4129, 0x1e, 0x00},
|
||||
{0x4123, 0x1e, 0x00},
|
||||
{0x4f00, 0x01, 0x00},
|
||||
{REG_NULL, 0x0, 0x00},
|
||||
};
|
||||
|
||||
|
||||
static const struct regval xs9922_720p_4lanes_25fps_1500M[] = {
|
||||
{0x0803, 0x03, 0x00}, // cam0
|
||||
{0x080e, 0x0f, 0x00},
|
||||
{0x0803, 0x0f, 0x00},
|
||||
{0x080e, 0x3f, 0x00},
|
||||
{0x080e, 0x3f, 0x00},
|
||||
{0x012d, 0x3f, 0x00},
|
||||
{0x012f, 0xcc, 0x00},
|
||||
{0x01e2, 0x03, 0x00},
|
||||
{0x0158, 0x01, 0x00},
|
||||
{0x0130, 0x10, 0x00},
|
||||
{0x010c, 0x01, 0x00},
|
||||
{0x010d, 0x40, 0x00}, // timing
|
||||
{0x0805, 0x05, 0x00},
|
||||
{0x0e11, XS9922B_FREERUN_COLOR_VAL, 0x00},
|
||||
{0x0e12, 0x01, 0x00},
|
||||
{0x060b, 0x00, 0x00},
|
||||
{0x0627, 0x14, 0x00},
|
||||
{0x061c, 0x00, 0x00},
|
||||
{0x061d, 0x5a, 0x00},
|
||||
{0x061e, 0xa5, 0x00},
|
||||
{0x0640, 0x04, 0x00},
|
||||
{0x0616, 0x24, 0x00},
|
||||
{0x0617, 0x00, 0x00},
|
||||
{0x0618, 0x04, 0x00},
|
||||
{0x060a, 0x07, 0x00},
|
||||
{0x010a, 0x05, 0x00},
|
||||
{0x0100, 0x30, 0x00},
|
||||
{0x0104, 0x48, 0x00}, //1500M
|
||||
{0x0802, 0x21, 0x00},
|
||||
{0x0502, 0x0c, 0x00},
|
||||
{0x050e, 0x1c, 0x00},
|
||||
{0x1803, 0x03, 0x00}, // cam1
|
||||
{0x180e, 0x0f, 0x00},
|
||||
{0x1803, 0x0f, 0x00},
|
||||
{0x180e, 0x3f, 0x00},
|
||||
{0x180e, 0x3f, 0x00},
|
||||
{0x112d, 0x3f, 0x00},
|
||||
{0x112f, 0xcc, 0x00},
|
||||
{0x11e2, 0x03, 0x00},
|
||||
{0x1158, 0x01, 0x00},
|
||||
{0x1130, 0x10, 0x00},
|
||||
{0x110c, 0x01, 0x00},
|
||||
{0x110d, 0x40, 0x00}, // timing
|
||||
{0x1805, 0x05, 0x00},
|
||||
{0x1e11, 0x06, 0x00},
|
||||
{0x1e12, 0x01, 0x00},
|
||||
{0x160b, 0x00, 0x00},
|
||||
{0x1627, 0x14, 0x00},
|
||||
{0x161c, 0x00, 0x00},
|
||||
{0x161d, 0x5a, 0x00},
|
||||
{0x161e, 0xa5, 0x00},
|
||||
{0x1640, 0x04, 0x00},
|
||||
{0x1616, 0x24, 0x00},
|
||||
{0x1617, 0x00, 0x00},
|
||||
{0x1618, 0x04, 0x00},
|
||||
{0x160a, 0x07, 0x00},
|
||||
{0x110a, 0x05, 0x00},
|
||||
{0x1100, 0x30, 0x00},
|
||||
{0x1104, 0x48, 0x00},
|
||||
{0x1802, 0x21, 0x00},
|
||||
{0x1502, 0x0d, 0x00},
|
||||
{0x150e, 0x1d, 0x00},
|
||||
{0x2803, 0x03, 0x00}, // cam2
|
||||
{0x280e, 0x0f, 0x00},
|
||||
{0x2803, 0x0f, 0x00},
|
||||
{0x280e, 0x3f, 0x00},
|
||||
{0x280e, 0x3f, 0x00},
|
||||
{0x212d, 0x3f, 0x00},
|
||||
{0x212f, 0xcc, 0x00},
|
||||
{0x21e2, 0x03, 0x00},
|
||||
{0x2158, 0x01, 0x00},
|
||||
{0x2130, 0x10, 0x00},
|
||||
{0x210c, 0x01, 0x00},
|
||||
{0x210d, 0x40, 0x00}, // timing
|
||||
{0x2805, 0x05, 0x00},
|
||||
{0x2e11, 0x06, 0x00},
|
||||
{0x2e12, 0x01, 0x00},
|
||||
{0x260b, 0x00, 0x00},
|
||||
{0x2627, 0x14, 0x00},
|
||||
{0x261c, 0x00, 0x00},
|
||||
{0x261d, 0x5a, 0x00},
|
||||
{0x261e, 0xa5, 0x00},
|
||||
{0x2640, 0x04, 0x00},
|
||||
{0x2616, 0x24, 0x00},
|
||||
{0x2617, 0x00, 0x00},
|
||||
{0x2618, 0x04, 0x00},
|
||||
{0x260a, 0x07, 0x00},
|
||||
{0x210a, 0x05, 0x00},
|
||||
{0x2100, 0x30, 0x00},
|
||||
{0x2104, 0x48, 0x00},
|
||||
{0x2802, 0x21, 0x00},
|
||||
{0x2502, 0x0e, 0x00},
|
||||
{0x250e, 0x1e, 0x00},
|
||||
{0x3803, 0x03, 0x00}, // cam3
|
||||
{0x380e, 0x0f, 0x00},
|
||||
{0x3803, 0x0f, 0x00},
|
||||
{0x380e, 0x3f, 0x00},
|
||||
{0x380e, 0x3f, 0x00},
|
||||
{0x312d, 0x3f, 0x00},
|
||||
{0x312f, 0xcc, 0x00},
|
||||
{0x31e2, 0x03, 0x00},
|
||||
{0x3158, 0x01, 0x00},
|
||||
{0x3130, 0x10, 0x00},
|
||||
{0x310c, 0x01, 0x00},
|
||||
{0x310d, 0x40, 0x00}, // timing
|
||||
{0x3805, 0x05, 0x00},
|
||||
{0x3e11, 0x06, 0x00},
|
||||
{0x3e12, 0x01, 0x00},
|
||||
{0x360b, 0x00, 0x00},
|
||||
{0x3627, 0x14, 0x00},
|
||||
{0x361c, 0x00, 0x00},
|
||||
{0x361d, 0x5a, 0x00},
|
||||
{0x361e, 0xa5, 0x00},
|
||||
{0x3640, 0x04, 0x00},
|
||||
{0x3616, 0x24, 0x00},
|
||||
{0x3617, 0x00, 0x00},
|
||||
{0x3618, 0x04, 0x00},
|
||||
{0x360a, 0x07, 0x00},
|
||||
{0x310a, 0x05, 0x00},
|
||||
{0x3100, 0x38, 0x00},
|
||||
{0x3104, 0x48, 0x00},
|
||||
{0x3802, 0x21, 0x00},
|
||||
{0x3502, 0x0f, 0x00},
|
||||
{0x350e, 0x1f, 0x00},
|
||||
{0x0e08, 0x01, 0x00},
|
||||
{0x1e08, 0x01, 0x00},
|
||||
{0x2e08, 0x01, 0x00},
|
||||
{0x3e08, 0x01, 0x00},
|
||||
{0x5004, 0x00, 0x00},
|
||||
{0x5005, 0x00, 0x00},
|
||||
{0x5006, 0x00, 0x00},
|
||||
{0x5007, 0x00, 0x00},
|
||||
{0x5004, 0x00, 0x00},
|
||||
{0x5005, 0x00, 0x00},
|
||||
{0x5006, 0x00, 0x00},
|
||||
{0x5007, 0x01, 0x00},
|
||||
{REG_NULL, 0x0, 0x00},
|
||||
};
|
||||
|
||||
static const struct regval xs9922_mipi_quick_streams[] = {
|
||||
{0x0e08, 0x01, 0x00}, //enable chn0
|
||||
{0x1e08, 0x01, 0x00},
|
||||
{0x2e08, 0x01, 0x00},
|
||||
{0x3e08, 0x01, 0x00},
|
||||
{0x5004, 0x00, 0x00},
|
||||
{0x5005, 0x00, 0x00},
|
||||
{0x5006, 0x00, 0x00},
|
||||
{0x5007, 0x00, 0x00},
|
||||
{0x5004, 0x00, 0x00},
|
||||
{0x5005, 0x00, 0x00},
|
||||
{0x5006, 0x00, 0x00},
|
||||
{0x5007, 0x01, 0x00},
|
||||
{REG_NULL, 0x0, 0x00},
|
||||
};
|
||||
|
||||
static const struct regval xs9922_mipi_dphy_set[] = {
|
||||
{0x5114, 0x0, 0x00},
|
||||
{0x5115, 0x0, 0x00},
|
||||
{0x5116, 0x0, 0x00},
|
||||
{0x5117, 0x2, 0x00},
|
||||
{0x5118, 0x0, 0x00},
|
||||
{0x5119, 0x1, 0x00},
|
||||
{0x511a, 0x0, 0x00},
|
||||
/* T-Trail time reg: 0x73 */
|
||||
{0x511b, 0x73, 0x00}, /* The val is means the reg add of d-phy */
|
||||
{0x5114, 0x0, 0x00},
|
||||
{0x5115, 0x0, 0x00},
|
||||
{0x5116, 0x0, 0x00},
|
||||
{0x5117, 0x0, 0x00},
|
||||
{0x5118, 0x0, 0x00},
|
||||
{0x5119, 0x0, 0x00},
|
||||
{0x511a, 0x0, 0x00},
|
||||
{0x511b, 0x9a, 0x00}, /* The val is means the reg val of d-phy */
|
||||
{0x5114, 0x0, 0x00},
|
||||
{0x5115, 0x0, 0x00},
|
||||
{0x5116, 0x0, 0x00},
|
||||
{0x5117, 0x2, 0x00},
|
||||
{REG_NULL, 0x0, 0x00},
|
||||
};
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* external variables and functions *
|
||||
****************************************************************************/
|
||||
|
||||
extern ISP_SNS_STATE_S *g_pastXS9922b[VI_MAX_PIPE_NUM];
|
||||
extern ISP_SNS_COMMBUS_U g_aunXS9922b_BusInfo[];
|
||||
extern const CVI_U8 xs9922b_i2c_addr;
|
||||
extern const CVI_U32 xs9922b_addr_byte;
|
||||
extern const CVI_U32 xs9922b_data_byte;
|
||||
extern void xs9922b_init(VI_PIPE ViPipe);
|
||||
extern void xs9922b_exit(VI_PIPE ViPipe);
|
||||
extern void xs9922b_standby(VI_PIPE ViPipe);
|
||||
extern void xs9922b_restart(VI_PIPE ViPipe);
|
||||
extern int xs9922b_write_register(VI_PIPE ViPipe, int addr, int data);
|
||||
extern int xs9922b_read_register(VI_PIPE ViPipe, int addr);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* End of #ifdef __cplusplus */
|
||||
|
||||
|
||||
#endif /* __XS9922B_CMOS_EX_H_ */
|
||||
@ -0,0 +1,136 @@
|
||||
#ifndef __XS9922B_CMOS_PARAM_H_
|
||||
#define __XS9922B_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 "xs9922b_cmos_ex.h"
|
||||
|
||||
static const XS9922B_MODE_S g_astXS9922b_mode[XS9922B_MODE_NUM] = {
|
||||
[XS9922B_MODE_720P_1CH] = {
|
||||
.name = "720p25_1ch",
|
||||
.astImg[0] = {
|
||||
.stSnsSize = {
|
||||
.u32Width = 1280,
|
||||
.u32Height = 720,
|
||||
},
|
||||
.stWndRect = {
|
||||
.s32X = 0,
|
||||
.s32Y = 0,
|
||||
.u32Width = 1280,
|
||||
.u32Height = 720,
|
||||
},
|
||||
.stMaxSize = {
|
||||
.u32Width = 1280,
|
||||
.u32Height = 720,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
[XS9922B_MODE_720P_2CH] = {
|
||||
.name = "720p25_2ch",
|
||||
.astImg[0] = {
|
||||
.stSnsSize = {
|
||||
.u32Width = 1280,
|
||||
.u32Height = 720,
|
||||
},
|
||||
.stWndRect = {
|
||||
.s32X = 0,
|
||||
.s32Y = 0,
|
||||
.u32Width = 1280,
|
||||
},
|
||||
.stMaxSize = {
|
||||
.u32Width = 1280,
|
||||
.u32Height = 720,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
[XS9922B_MODE_720P_3CH] = {
|
||||
.name = "720p25_3ch",
|
||||
.astImg[0] = {
|
||||
.stSnsSize = {
|
||||
.u32Width = 1280,
|
||||
.u32Height = 720,
|
||||
},
|
||||
.stWndRect = {
|
||||
.s32X = 0,
|
||||
.s32Y = 0,
|
||||
.u32Width = 1280,
|
||||
.u32Height = 720,
|
||||
},
|
||||
.stMaxSize = {
|
||||
.u32Width = 1280,
|
||||
.u32Height = 720,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
[XS9922B_MODE_720P_4CH] = {
|
||||
.name = "720p25_4ch",
|
||||
.astImg[0] = {
|
||||
.stSnsSize = {
|
||||
.u32Width = 1280,
|
||||
.u32Height = 720,
|
||||
},
|
||||
.stWndRect = {
|
||||
.s32X = 0,
|
||||
.s32Y = 0,
|
||||
.u32Width = 1280,
|
||||
.u32Height = 720,
|
||||
},
|
||||
.stMaxSize = {
|
||||
.u32Width = 1280,
|
||||
.u32Height = 720,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
struct combo_dev_attr_s xs9922b_multi_rx_attr = {
|
||||
.input_mode = INPUT_MODE_MIPI,
|
||||
.mac_clk = RX_MAC_CLK_600M,
|
||||
.mipi_attr = {
|
||||
.raw_data_type = YUV422_8BIT,
|
||||
.lane_id = {2, 0, 1, 3, 4},
|
||||
.pn_swap = {0, 0, 0, 0, 0},
|
||||
.wdr_mode = CVI_MIPI_WDR_MODE_VC,
|
||||
.demux = {
|
||||
.demux_en = 1,
|
||||
.vc_mapping = {0, 1, 2, 3},
|
||||
},
|
||||
.dphy = {
|
||||
.enable = 1,
|
||||
.hs_settle = 15,
|
||||
},
|
||||
},
|
||||
.mclk = {
|
||||
.cam = 0,
|
||||
.freq = CAMPLL_FREQ_27M,
|
||||
},
|
||||
.devno = 0,
|
||||
};
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* End of #ifdef __cplusplus */
|
||||
|
||||
|
||||
#endif /* __XS9922B_CMOS_PARAM_H_ */
|
||||
@ -0,0 +1,267 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.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 "xs9922b_cmos_ex.h"
|
||||
#include <pthread.h>
|
||||
#include <signal.h>
|
||||
|
||||
static void xs9922b_set_720p_25fps(VI_PIPE ViPipe);
|
||||
|
||||
const CVI_U8 xs9922b_master_i2c_addr = 0x30; /* I2C slave address of XS9922b master chip 0x5C*/
|
||||
const CVI_U8 xs9922b_slave_i2c_addr = 0x5F; /* I2C slave address of XS9922b slave chip*/
|
||||
const CVI_U32 xs9922b_addr_byte = 2;
|
||||
const CVI_U32 xs9922b_data_byte = 1;
|
||||
static int g_fd[VI_MAX_PIPE_NUM] = {[0 ... (VI_MAX_PIPE_NUM - 1)] = -1};
|
||||
|
||||
#define XS9922B_ID0_REG 0x40F1 // id1 0x40F0: 0x99 id0 0x40F1: 0x22
|
||||
#define XS9922B_ID1_REG 0x40F0 // id1 0x40F0: 0x99 id0 0x40F1: 0x22
|
||||
#define XS9922B_DEVICE_ID 0x9922 // id1 0x40F0: 0x99 id0 0x40F1: 0x22
|
||||
#define XS9922B_PATTERN_EN_REG 0x5080 // id1 0x40F0: 0x99 id0 0x40F1: 0x22
|
||||
|
||||
#define MAX_BUF 64
|
||||
|
||||
static void delay_ms(int ms)
|
||||
{
|
||||
usleep(ms * 1000);
|
||||
}
|
||||
|
||||
int xs9922b_i2c_init(VI_PIPE ViPipe, CVI_U8 i2c_addr)
|
||||
{
|
||||
int ret;
|
||||
char acDevFile[16] = {0};
|
||||
CVI_U8 u8DevNum;
|
||||
|
||||
if (g_fd[ViPipe] >= 0)
|
||||
return CVI_SUCCESS;
|
||||
|
||||
u8DevNum = g_aunXS9922b_BusInfo[ViPipe].s8I2cDev;
|
||||
snprintf(acDevFile, sizeof(acDevFile), "/dev/i2c-%u", u8DevNum);
|
||||
CVI_TRACE_SNS(CVI_DBG_INFO, "open %s\n", acDevFile);
|
||||
|
||||
g_fd[ViPipe] = open(acDevFile, O_RDWR, 0600);
|
||||
|
||||
if (g_fd[ViPipe] < 0) {
|
||||
CVI_TRACE_SNS(CVI_DBG_ERR, "Open /dev/cvi_i2c_drv-%u error!\n", u8DevNum);
|
||||
return CVI_FAILURE;
|
||||
}
|
||||
|
||||
ret = ioctl(g_fd[ViPipe], I2C_SLAVE_FORCE, 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 xs9922b_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 xs9922b_read_register(VI_PIPE ViPipe, int addr)
|
||||
{
|
||||
int ret, data;
|
||||
CVI_U8 buf[8];
|
||||
CVI_U8 idx = 0;
|
||||
|
||||
if (g_fd[ViPipe] < 0)
|
||||
return 0;
|
||||
|
||||
if (xs9922b_addr_byte == 2)
|
||||
buf[idx++] = (addr >> 8) & 0xff;
|
||||
|
||||
// add address byte 0
|
||||
buf[idx++] = addr & 0xff;
|
||||
|
||||
ret = write(g_fd[ViPipe], buf, xs9922b_addr_byte);
|
||||
if (ret < 0) {
|
||||
CVI_TRACE_SNS(CVI_DBG_ERR, "I2C_READ error!\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
buf[0] = 0;
|
||||
buf[1] = 0;
|
||||
ret = read(g_fd[ViPipe], buf, xs9922b_data_byte);
|
||||
if (ret < 0) {
|
||||
CVI_TRACE_SNS(CVI_DBG_ERR, "I2C_READ error!\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
// pack read back data
|
||||
data = 0;
|
||||
if (xs9922b_data_byte == 2) {
|
||||
data = buf[0] << 8;
|
||||
data += buf[1];
|
||||
} else {
|
||||
data = buf[0];
|
||||
}
|
||||
|
||||
CVI_TRACE_SNS(CVI_DBG_INFO, "i2c r 0x%x = 0x%x\n", addr, data);
|
||||
return data;
|
||||
}
|
||||
|
||||
int xs9922b_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 (xs9922b_addr_byte == 2)
|
||||
buf[idx++] = (addr >> 8) & 0xff;
|
||||
|
||||
// add address byte 0
|
||||
buf[idx++] = addr & 0xff;
|
||||
|
||||
if (xs9922b_data_byte == 2)
|
||||
buf[idx++] = (data >> 8) & 0xff;
|
||||
|
||||
// add data byte 0
|
||||
buf[idx++] = data & 0xff;
|
||||
|
||||
ret = write(g_fd[ViPipe], buf, xs9922b_addr_byte + xs9922b_data_byte);
|
||||
if (ret < 0) {
|
||||
CVI_TRACE_SNS(CVI_DBG_ERR, "I2C_WRITE error!\n");
|
||||
return CVI_FAILURE;
|
||||
}
|
||||
CVI_TRACE_SNS(CVI_DBG_INFO, "i2c w 0x%x 0x%x\n", addr, data);
|
||||
|
||||
#if 0 // read back checing
|
||||
ret = xs9922b_read_register(ViPipe, addr);
|
||||
if (ret != data)
|
||||
CVI_TRACE_SNS(CVI_DBG_INFO, "i2c readback-check fail, 0x%x != 0x%x\n", ret, data);
|
||||
#endif
|
||||
return CVI_SUCCESS;
|
||||
}
|
||||
|
||||
void xs9922b_init(VI_PIPE ViPipe)
|
||||
{
|
||||
if (ViPipe) // only init ch0
|
||||
return;
|
||||
|
||||
delay_ms(20);
|
||||
|
||||
if (xs9922b_i2c_init(ViPipe, xs9922b_master_i2c_addr) != CVI_SUCCESS) {
|
||||
CVI_TRACE_SNS(CVI_DBG_ERR, "XS9922b master i2c init fail\n");
|
||||
return;
|
||||
}
|
||||
|
||||
// check sensor chip id
|
||||
if (((xs9922b_read_register(ViPipe, XS9922B_ID1_REG) << 8) |
|
||||
(xs9922b_read_register(ViPipe, XS9922B_ID0_REG))) != XS9922B_DEVICE_ID) {
|
||||
CVI_TRACE_SNS(CVI_DBG_ERR,
|
||||
"XS9922b chip id(0x%04x) check fail, read is 0x%02x%02x\n",
|
||||
XS9922B_DEVICE_ID,
|
||||
xs9922b_read_register(ViPipe, XS9922B_ID1_REG),
|
||||
xs9922b_read_register(ViPipe, XS9922B_ID0_REG));
|
||||
return;
|
||||
}
|
||||
|
||||
CVI_TRACE_SNS(CVI_DBG_INFO, "Loading ChipUp XS9922b sensor\n");
|
||||
xs9922b_set_720p_25fps(ViPipe);
|
||||
// wait for signal to stabilize
|
||||
delay_ms(100);
|
||||
xs9922b_write_register(ViPipe, 0xff, 0x00);//page0
|
||||
}
|
||||
|
||||
void xs9922b_exit(VI_PIPE ViPipe)
|
||||
{
|
||||
CVI_TRACE_SNS(CVI_DBG_INFO, "Exit Pixelplus XS9922b Sensor\n");
|
||||
|
||||
xs9922b_i2c_exit(ViPipe);
|
||||
}
|
||||
|
||||
static void xs9922b_set_720p_25fps(VI_PIPE ViPipe)
|
||||
{
|
||||
CVI_U16 i;
|
||||
CVI_U16 addr;
|
||||
CVI_U8 val;
|
||||
CVI_U8 nDelay;
|
||||
|
||||
CVI_U8 u8ImgMode;
|
||||
u8ImgMode = g_pastXS9922b[ViPipe]->u8ImgMode;
|
||||
|
||||
i = 0;
|
||||
while (xs9922_init_cfg[i].addr != REG_NULL) {
|
||||
addr = xs9922_init_cfg[i].addr;
|
||||
val = xs9922_init_cfg[i].val;
|
||||
nDelay = xs9922_init_cfg[i].nDelay;
|
||||
xs9922b_write_register(ViPipe, addr, val);
|
||||
usleep(nDelay);
|
||||
i++;
|
||||
}
|
||||
|
||||
i = 0;
|
||||
while (xs9922_mipi_dphy_set[i].addr != REG_NULL) {
|
||||
addr = xs9922_mipi_dphy_set[i].addr;
|
||||
val = xs9922_mipi_dphy_set[i].val;
|
||||
nDelay = xs9922_mipi_dphy_set[i].nDelay;
|
||||
xs9922b_write_register(ViPipe, addr, val);
|
||||
usleep(nDelay);
|
||||
i++;
|
||||
}
|
||||
|
||||
i = 0;
|
||||
while (xs9922_720p_4lanes_25fps_1500M[i].addr != REG_NULL) {
|
||||
addr = xs9922_720p_4lanes_25fps_1500M[i].addr;
|
||||
val = xs9922_720p_4lanes_25fps_1500M[i].val;
|
||||
nDelay = xs9922_720p_4lanes_25fps_1500M[i].nDelay;
|
||||
xs9922b_write_register(ViPipe, addr, val);
|
||||
usleep(nDelay);
|
||||
i++;
|
||||
}
|
||||
|
||||
i = 0;
|
||||
while (xs9922_mipi_quick_streams[i].addr != REG_NULL) {
|
||||
addr = xs9922_mipi_quick_streams[i].addr;
|
||||
val = xs9922_mipi_quick_streams[i].val;
|
||||
nDelay = xs9922_mipi_quick_streams[i].nDelay;
|
||||
switch (u8ImgMode) {
|
||||
case XS9922B_MODE_720P_1CH:
|
||||
if ((XS9922B_CH1_EN_REG == addr) || (XS9922B_CH2_EN_REG == addr)
|
||||
|| (XS9922B_CH3_EN_REG == addr))/* Just run one ch */
|
||||
val = 0x00;
|
||||
break;
|
||||
case XS9922B_MODE_720P_2CH:
|
||||
if ((XS9922B_CH2_EN_REG == addr)
|
||||
|| (XS9922B_CH3_EN_REG == addr)) /* Just two chs */
|
||||
val = 0x00;
|
||||
break;
|
||||
case XS9922B_MODE_720P_3CH:
|
||||
if (XS9922B_CH3_EN_REG == addr) /* three chs */
|
||||
val = 0x00;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
xs9922b_write_register(ViPipe, addr, val);
|
||||
usleep(nDelay);
|
||||
i++;
|
||||
}
|
||||
delay_ms(100);
|
||||
}
|
||||
@ -158,7 +158,8 @@ static CVI_S32 cmos_get_ae_default(VI_PIPE ViPipe, AE_SENSOR_DEFAULT_S *pstAeSns
|
||||
pstAeSnsDft->u8AeCompensation = 40;
|
||||
pstAeSnsDft->u32InitAESpeed = 64;
|
||||
pstAeSnsDft->u32InitAETolerance = 2;
|
||||
pstAeSnsDft->u32AEResponseFrame = 5;
|
||||
pstAeSnsDft->u32AEResponseFrame = 3;
|
||||
pstAeSnsDft->u32SnsResponseFrame = 5;
|
||||
pstAeSnsDft->enAeExpMode = AE_EXP_HIGHLIGHT_PRIOR;
|
||||
pstAeSnsDft->u32InitExposure = g_au32InitExposure[ViPipe] ?
|
||||
g_au32InitExposure[ViPipe] : pstMode->stExp[0].u16Def;
|
||||
@ -242,32 +243,57 @@ static CVI_S32 cmos_inttime_update(VI_PIPE ViPipe, CVI_U32 *u32IntTime)
|
||||
return CVI_SUCCESS;
|
||||
}
|
||||
|
||||
static CVI_U32 gain_table[242] = {
|
||||
1024, 1024, 1024, 1024, 1040, 1040, 1040, 1040, 1056, 1056,
|
||||
1056, 1056, 1072, 1072, 1072, 1072, 1088, 1088, 1088, 1104,
|
||||
1104, 1104, 1120, 1120, 1120, 1120, 1136, 1136, 1136, 1152,
|
||||
1152, 1152, 1168, 1168, 1168, 1184, 1184, 1184, 1200, 1200,
|
||||
1200, 1216, 1216, 1216, 1232, 1232, 1248, 1248, 1248, 1264,
|
||||
1264, 1264, 1280, 1280, 1296, 1296, 1296, 1312, 1312, 1328,
|
||||
1328, 1344, 1344, 1344, 1360, 1360, 1376, 1376, 1392, 1392,
|
||||
1408, 1408, 1424, 1424, 1440, 1440, 1456, 1456, 1472, 1472,
|
||||
1488, 1488, 1504, 1504, 1520, 1520, 1536, 1536, 1552, 1568,
|
||||
1568, 1584, 1584, 1600, 1616, 1616, 1632, 1648, 1648, 1664,
|
||||
1680, 1680, 1696, 1712, 1712, 1728, 1744, 1744, 1760, 1776,
|
||||
1792, 1808, 1808, 1824, 1840, 1856, 1872, 1872, 1888, 1904,
|
||||
1920, 1936, 1952, 1968, 1984, 2000, 2016, 2016, 2048, 2064,
|
||||
2080, 2096, 2112, 2128, 2144, 2160, 2176, 2192, 2208, 2240,
|
||||
2256, 2272, 2288, 2304, 2336, 2352, 2368, 2400, 2416, 2448,
|
||||
2464, 2496, 2512, 2544, 2560, 2592, 2608, 2640, 2672, 2688,
|
||||
2720, 2752, 2784, 2816, 2848, 2880, 2912, 2944, 2976, 3008,
|
||||
3040, 3072, 3120, 3152, 3184, 3232, 3264, 3312, 3360, 3392,
|
||||
3440, 3488, 3536, 3584, 3632, 3680, 3744, 3792, 3840, 3904,
|
||||
3968, 4032, 4096, 4160, 4224, 4288, 4368, 4432, 4512, 4592,
|
||||
4672, 4752, 4848, 4944, 5040, 5136, 5232, 5344, 5456, 5568,
|
||||
5696, 5824, 5952, 6080, 6240, 6384, 6544, 6720, 6896, 7072,
|
||||
7280, 7488, 7696, 7936, 8192, 8448, 8736, 9024, 9360, 9696,
|
||||
10080, 10480, 10912, 11392, 11904, 12480, 13104, 13792, 14560, 15408,
|
||||
16384, 0x3FFFF,
|
||||
static CVI_U32 gain_table[250] = {
|
||||
1024, 1024, 1024, 1024, 1040,
|
||||
1040, 1040, 1040, 1056, 1056,
|
||||
1056, 1056, 1072, 1072, 1072,
|
||||
1072, 1088, 1088, 1088, 1104,
|
||||
1104, 1104, 1120, 1120, 1120,
|
||||
1120, 1136, 1136, 1136, 1152,
|
||||
1152, 1152, 1168, 1168, 1168,
|
||||
1184, 1184, 1184, 1200, 1200,
|
||||
1200, 1216, 1216, 1216, 1232,
|
||||
1232, 1248, 1248, 1248, 1264,
|
||||
1264, 1264, 1280, 1280, 1296,
|
||||
1296, 1296, 1312, 1312, 1328,
|
||||
1328, 1344, 1344, 1344, 1360,
|
||||
1360, 1376, 1376, 1392, 1392,
|
||||
1408, 1408, 1424, 1424, 1440,
|
||||
1440, 1456, 1456, 1472, 1472,
|
||||
1488, 1488, 1504, 1504, 1520,
|
||||
1520, 1536, 1536, 1552, 1568,
|
||||
1568, 1584, 1584, 1600, 1616,
|
||||
1616, 1632, 1648, 1648, 1664,
|
||||
1680, 1680, 1696, 1712, 1712,
|
||||
1728, 1744, 1744, 1760, 1776,
|
||||
1792, 1808, 1808, 1824, 1840,
|
||||
1856, 1872, 1872, 1904, 1904,
|
||||
1920, 1936, 1952, 1968, 1984,
|
||||
2000, 2016, 2016, 2048, 2064,
|
||||
2080, 2096, 2112, 2128, 2144,
|
||||
2160, 2176, 2192, 2208, 2240,
|
||||
2256, 2272, 2288, 2304, 2336,
|
||||
2352, 2368, 2400, 2416, 2448,
|
||||
2464, 2496, 2512, 2544, 2560,
|
||||
2576, 2608, 2640, 2672, 2688,
|
||||
2720, 2752, 2784, 2816, 2848,
|
||||
2880, 2912, 2944, 2976, 2008,
|
||||
3040, 3072, 3120, 3152, 3184,
|
||||
3232, 3264, 3312, 3360, 3392,
|
||||
3440, 3488, 3536, 3584, 3632,
|
||||
3680, 3744, 3792, 3840, 3904,
|
||||
3968, 4032, 4096, 4160, 4224,
|
||||
4288, 4368, 4432, 4512, 4592,
|
||||
4672, 4752, 4848, 4944, 5040,
|
||||
5136, 5232, 5344, 5456, 5568,
|
||||
5696, 5824, 5952, 6080, 6240,
|
||||
6384, 6384, 6720, 6896, 7072,
|
||||
7280, 7488, 7696, 7936, 8192,
|
||||
8448, 8736, 9024, 9360, 9696,
|
||||
10080, 10480, 10912, 11392, 11904,
|
||||
12480, 13104, 13792, 14560, 15408,
|
||||
16384, 17472, 18720, 20160, 21840,
|
||||
23824, 26208, 29120, 32768, 0xFFFF,
|
||||
};
|
||||
|
||||
static CVI_S32 cmos_again_calc_table(VI_PIPE ViPipe, CVI_U32 *pu32AgainLin, CVI_U32 *pu32AgainDb)
|
||||
@ -706,8 +732,8 @@ static CVI_S32 cmos_set_image_mode(VI_PIPE ViPipe, ISP_CMOS_SENSOR_IMAGE_MODE_S
|
||||
static CVI_VOID sensor_mirror_flip(VI_PIPE ViPipe, ISP_SNS_MIRRORFLIP_TYPE_E eSnsMirrorFlip)
|
||||
{
|
||||
CVI_U8 value = 0x0;
|
||||
CVI_U8 start_x = 4;
|
||||
CVI_U8 start_y = 4;
|
||||
CVI_U8 start_x = 0;
|
||||
CVI_U8 start_y = 0;
|
||||
|
||||
ISP_SNS_STATE_S *pstSnsState = CVI_NULL;
|
||||
ISP_SNS_REGS_INFO_S *pstSnsRegsInfo = CVI_NULL;
|
||||
@ -724,23 +750,23 @@ static CVI_VOID sensor_mirror_flip(VI_PIPE ViPipe, ISP_SNS_MIRRORFLIP_TYPE_E eSn
|
||||
switch (eSnsMirrorFlip) {
|
||||
case ISP_SNS_NORMAL:
|
||||
value = 0x0;
|
||||
start_x = 4;
|
||||
start_y = 4;
|
||||
start_x = 0;
|
||||
start_y = 0;
|
||||
break;
|
||||
case ISP_SNS_MIRROR:
|
||||
value = 0x1;
|
||||
start_x = 5;
|
||||
start_y = 4;
|
||||
start_x = 1;
|
||||
start_y = 0;
|
||||
break;
|
||||
case ISP_SNS_FLIP:
|
||||
value = 0x2;
|
||||
start_x = 4;
|
||||
start_y = 5;
|
||||
start_x = 0;
|
||||
start_y = 1;
|
||||
break;
|
||||
case ISP_SNS_MIRROR_FLIP:
|
||||
value = 0x3;
|
||||
start_x = 5;
|
||||
start_y = 5;
|
||||
start_x = 1;
|
||||
start_y = 1;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
|
||||
@ -24,8 +24,8 @@ static const CV2003_MODE_S g_astCV2003_mode[CV2003_MODE_NUM] = {
|
||||
.name = "1920X1080P30",
|
||||
.astImg[0] = {
|
||||
.stSnsSize = {
|
||||
.u32Width = 1920,
|
||||
.u32Height = 1080,
|
||||
.u32Width = 1928,
|
||||
.u32Height = 1088,
|
||||
},
|
||||
.stWndRect = {
|
||||
.s32X = 0,
|
||||
@ -34,8 +34,8 @@ static const CV2003_MODE_S g_astCV2003_mode[CV2003_MODE_NUM] = {
|
||||
.u32Height = 1080,
|
||||
},
|
||||
.stMaxSize = {
|
||||
.u32Width = 1920,
|
||||
.u32Height = 1080,
|
||||
.u32Width = 1928,
|
||||
.u32Height = 1088,
|
||||
},
|
||||
},
|
||||
.f32MaxFps = 30,
|
||||
|
||||
@ -265,13 +265,13 @@ static void cv2003_linear_1080P30_init(VI_PIPE ViPipe)
|
||||
cv2003_write_register(ViPipe, 0x3021, 0x08);
|
||||
cv2003_write_register(ViPipe, 0x3024, 0x80);
|
||||
cv2003_write_register(ViPipe, 0x3025, 0x02);
|
||||
cv2003_write_register(ViPipe, 0x3038, 0x04);
|
||||
cv2003_write_register(ViPipe, 0x3038, 0x00);
|
||||
cv2003_write_register(ViPipe, 0x3039, 0x00);
|
||||
cv2003_write_register(ViPipe, 0x303A, 0x80);
|
||||
cv2003_write_register(ViPipe, 0x303A, 0x88);
|
||||
cv2003_write_register(ViPipe, 0x303B, 0x07);
|
||||
cv2003_write_register(ViPipe, 0x3034, 0x04);
|
||||
cv2003_write_register(ViPipe, 0x3034, 0x00);
|
||||
cv2003_write_register(ViPipe, 0x3035, 0x00);
|
||||
cv2003_write_register(ViPipe, 0x3036, 0x38);
|
||||
cv2003_write_register(ViPipe, 0x3036, 0x40);
|
||||
cv2003_write_register(ViPipe, 0x3037, 0x04);
|
||||
cv2003_write_register(ViPipe, 0x3908, 0x48);
|
||||
cv2003_write_register(ViPipe, 0x390A, 0x02);
|
||||
|
||||
@ -158,7 +158,8 @@ static CVI_S32 cmos_get_ae_default(VI_PIPE ViPipe, AE_SENSOR_DEFAULT_S *pstAeSns
|
||||
pstAeSnsDft->u8AeCompensation = 40;
|
||||
pstAeSnsDft->u32InitAESpeed = 64;
|
||||
pstAeSnsDft->u32InitAETolerance = 2;
|
||||
pstAeSnsDft->u32AEResponseFrame = 5;
|
||||
pstAeSnsDft->u32AEResponseFrame = 2;
|
||||
pstAeSnsDft->u32SnsResponseFrame = 5;
|
||||
pstAeSnsDft->enAeExpMode = AE_EXP_HIGHLIGHT_PRIOR;
|
||||
pstAeSnsDft->u32InitExposure = g_au32InitExposure[ViPipe] ?
|
||||
g_au32InitExposure[ViPipe] : pstMode->stExp[0].u16Def;
|
||||
@ -242,32 +243,57 @@ static CVI_S32 cmos_inttime_update(VI_PIPE ViPipe, CVI_U32 *u32IntTime)
|
||||
return CVI_SUCCESS;
|
||||
}
|
||||
|
||||
static CVI_U32 gain_table[242] = {
|
||||
1024, 1024, 1024, 1024, 1040, 1040, 1040, 1040, 1056, 1056,
|
||||
1056, 1056, 1072, 1072, 1072, 1072, 1088, 1088, 1088, 1104,
|
||||
1104, 1104, 1120, 1120, 1120, 1120, 1136, 1136, 1136, 1152,
|
||||
1152, 1152, 1168, 1168, 1168, 1184, 1184, 1184, 1200, 1200,
|
||||
1200, 1216, 1216, 1216, 1232, 1232, 1248, 1248, 1248, 1264,
|
||||
1264, 1264, 1280, 1280, 1296, 1296, 1296, 1312, 1312, 1328,
|
||||
1328, 1344, 1344, 1344, 1360, 1360, 1376, 1376, 1392, 1392,
|
||||
1408, 1408, 1424, 1424, 1440, 1440, 1456, 1456, 1472, 1472,
|
||||
1488, 1488, 1504, 1504, 1520, 1520, 1536, 1536, 1552, 1568,
|
||||
1568, 1584, 1584, 1600, 1616, 1616, 1632, 1648, 1648, 1664,
|
||||
1680, 1680, 1696, 1712, 1712, 1728, 1744, 1744, 1760, 1776,
|
||||
1792, 1808, 1808, 1824, 1840, 1856, 1872, 1872, 1888, 1904,
|
||||
1920, 1936, 1952, 1968, 1984, 2000, 2016, 2016, 2048, 2064,
|
||||
2080, 2096, 2112, 2128, 2144, 2160, 2176, 2192, 2208, 2240,
|
||||
2256, 2272, 2288, 2304, 2336, 2352, 2368, 2400, 2416, 2448,
|
||||
2464, 2496, 2512, 2544, 2560, 2592, 2608, 2640, 2672, 2688,
|
||||
2720, 2752, 2784, 2816, 2848, 2880, 2912, 2944, 2976, 3008,
|
||||
3040, 3072, 3120, 3152, 3184, 3232, 3264, 3312, 3360, 3392,
|
||||
3440, 3488, 3536, 3584, 3632, 3680, 3744, 3792, 3840, 3904,
|
||||
3968, 4032, 4096, 4160, 4224, 4288, 4368, 4432, 4512, 4592,
|
||||
4672, 4752, 4848, 4944, 5040, 5136, 5232, 5344, 5456, 5568,
|
||||
5696, 5824, 5952, 6080, 6240, 6384, 6544, 6720, 6896, 7072,
|
||||
7280, 7488, 7696, 7936, 8192, 8448, 8736, 9024, 9360, 9696,
|
||||
10080, 10480, 10912, 11392, 11904, 12480, 13104, 13792, 14560, 15408,
|
||||
16384, 0x3FFFF,
|
||||
static CVI_U32 gain_table[250] = {
|
||||
1024, 1024, 1024, 1024, 1040,
|
||||
1040, 1040, 1040, 1056, 1056,
|
||||
1056, 1056, 1072, 1072, 1072,
|
||||
1072, 1088, 1088, 1088, 1104,
|
||||
1104, 1104, 1120, 1120, 1120,
|
||||
1120, 1136, 1136, 1136, 1152,
|
||||
1152, 1152, 1168, 1168, 1168,
|
||||
1184, 1184, 1184, 1200, 1200,
|
||||
1200, 1216, 1216, 1216, 1232,
|
||||
1232, 1248, 1248, 1248, 1264,
|
||||
1264, 1264, 1280, 1280, 1296,
|
||||
1296, 1296, 1312, 1312, 1328,
|
||||
1328, 1344, 1344, 1344, 1360,
|
||||
1360, 1376, 1376, 1392, 1392,
|
||||
1408, 1408, 1424, 1424, 1440,
|
||||
1440, 1456, 1456, 1472, 1472,
|
||||
1488, 1488, 1504, 1504, 1520,
|
||||
1520, 1536, 1536, 1552, 1568,
|
||||
1568, 1584, 1584, 1600, 1616,
|
||||
1616, 1632, 1648, 1648, 1664,
|
||||
1680, 1680, 1696, 1712, 1712,
|
||||
1728, 1744, 1744, 1760, 1776,
|
||||
1792, 1808, 1808, 1824, 1840,
|
||||
1856, 1872, 1872, 1904, 1904,
|
||||
1920, 1936, 1952, 1968, 1984,
|
||||
2000, 2016, 2016, 2048, 2064,
|
||||
2080, 2096, 2112, 2128, 2144,
|
||||
2160, 2176, 2192, 2208, 2240,
|
||||
2256, 2272, 2288, 2304, 2336,
|
||||
2352, 2368, 2400, 2416, 2448,
|
||||
2464, 2496, 2512, 2544, 2560,
|
||||
2576, 2608, 2640, 2672, 2688,
|
||||
2720, 2752, 2784, 2816, 2848,
|
||||
2880, 2912, 2944, 2976, 2008,
|
||||
3040, 3072, 3120, 3152, 3184,
|
||||
3232, 3264, 3312, 3360, 3392,
|
||||
3440, 3488, 3536, 3584, 3632,
|
||||
3680, 3744, 3792, 3840, 3904,
|
||||
3968, 4032, 4096, 4160, 4224,
|
||||
4288, 4368, 4432, 4512, 4592,
|
||||
4672, 4752, 4848, 4944, 5040,
|
||||
5136, 5232, 5344, 5456, 5568,
|
||||
5696, 5824, 5952, 6080, 6240,
|
||||
6384, 6384, 6720, 6896, 7072,
|
||||
7280, 7488, 7696, 7936, 8192,
|
||||
8448, 8736, 9024, 9360, 9696,
|
||||
10080, 10480, 10912, 11392, 11904,
|
||||
12480, 13104, 13792, 14560, 15408,
|
||||
16384, 17472, 18720, 20160, 21840,
|
||||
23824, 26208, 29120, 32768, 0xFFFF,
|
||||
};
|
||||
|
||||
static CVI_S32 cmos_again_calc_table(VI_PIPE ViPipe, CVI_U32 *pu32AgainLin, CVI_U32 *pu32AgainDb)
|
||||
@ -706,8 +732,8 @@ static CVI_S32 cmos_set_image_mode(VI_PIPE ViPipe, ISP_CMOS_SENSOR_IMAGE_MODE_S
|
||||
static CVI_VOID sensor_mirror_flip(VI_PIPE ViPipe, ISP_SNS_MIRRORFLIP_TYPE_E eSnsMirrorFlip)
|
||||
{
|
||||
CVI_U8 value = 0x0;
|
||||
CVI_U8 start_x = 4;
|
||||
CVI_U8 start_y = 4;
|
||||
CVI_U8 start_x = 0;
|
||||
CVI_U8 start_y = 0;
|
||||
|
||||
ISP_SNS_STATE_S *pstSnsState = CVI_NULL;
|
||||
ISP_SNS_REGS_INFO_S *pstSnsRegsInfo = CVI_NULL;
|
||||
@ -724,23 +750,23 @@ static CVI_VOID sensor_mirror_flip(VI_PIPE ViPipe, ISP_SNS_MIRRORFLIP_TYPE_E eSn
|
||||
switch (eSnsMirrorFlip) {
|
||||
case ISP_SNS_NORMAL:
|
||||
value = 0x0;
|
||||
start_x = 4;
|
||||
start_y = 4;
|
||||
start_x = 0;
|
||||
start_y = 0;
|
||||
break;
|
||||
case ISP_SNS_MIRROR:
|
||||
value = 0x1;
|
||||
start_x = 5;
|
||||
start_y = 4;
|
||||
start_x = 1;
|
||||
start_y = 0;
|
||||
break;
|
||||
case ISP_SNS_FLIP:
|
||||
value = 0x2;
|
||||
start_x = 4;
|
||||
start_y = 5;
|
||||
start_x = 0;
|
||||
start_y = 1;
|
||||
break;
|
||||
case ISP_SNS_MIRROR_FLIP:
|
||||
value = 0x3;
|
||||
start_x = 5;
|
||||
start_y = 5;
|
||||
start_x = 1;
|
||||
start_y = 1;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
|
||||
@ -24,8 +24,8 @@ static const CV2003_1L_SLAVE_MODE_S g_astCV2003_1L_SLAVE_mode[CV2003_1L_SLAVE_MO
|
||||
.name = "1920X1080P30",
|
||||
.astImg[0] = {
|
||||
.stSnsSize = {
|
||||
.u32Width = 1920,
|
||||
.u32Height = 1080,
|
||||
.u32Width = 1928,
|
||||
.u32Height = 1088,
|
||||
},
|
||||
.stWndRect = {
|
||||
.s32X = 0,
|
||||
@ -34,8 +34,8 @@ static const CV2003_1L_SLAVE_MODE_S g_astCV2003_1L_SLAVE_mode[CV2003_1L_SLAVE_MO
|
||||
.u32Height = 1080,
|
||||
},
|
||||
.stMaxSize = {
|
||||
.u32Width = 1920,
|
||||
.u32Height = 1080,
|
||||
.u32Width = 1928,
|
||||
.u32Height = 1088,
|
||||
},
|
||||
},
|
||||
.f32MaxFps = 30,
|
||||
|
||||
@ -221,10 +221,11 @@ static void cv2003_1l_slave_linear_1080P30_init(VI_PIPE ViPipe)
|
||||
{
|
||||
delay_ms(10);
|
||||
|
||||
//30fps
|
||||
//15fps
|
||||
cv2003_1l_slave_write_register(ViPipe, 0x3300, 0x03);
|
||||
cv2003_1l_slave_write_register(ViPipe, 0x3422, 0xBF);
|
||||
cv2003_1l_slave_write_register(ViPipe, 0x3401, 0x00);
|
||||
|
||||
cv2003_1l_slave_write_register(ViPipe, 0x3440, 0x01);
|
||||
cv2003_1l_slave_write_register(ViPipe, 0x3442, 0x00);
|
||||
// cv2003_1l_slave_write_register(ViPipe, 0x3460, 0x03);//drive capability
|
||||
@ -261,17 +262,17 @@ static void cv2003_1l_slave_linear_1080P30_init(VI_PIPE ViPipe)
|
||||
cv2003_1l_slave_write_register(ViPipe, 0x3144, 0x20);
|
||||
cv2003_1l_slave_write_register(ViPipe, 0x301c, 0x00);
|
||||
cv2003_1l_slave_write_register(ViPipe, 0x3030, 0x01);
|
||||
cv2003_1l_slave_write_register(ViPipe, 0x3020, 0xCA);
|
||||
cv2003_1l_slave_write_register(ViPipe, 0x3021, 0x08);
|
||||
cv2003_1l_slave_write_register(ViPipe, 0x3020, 0x94);
|
||||
cv2003_1l_slave_write_register(ViPipe, 0x3021, 0x11);
|
||||
cv2003_1l_slave_write_register(ViPipe, 0x3024, 0x80);
|
||||
cv2003_1l_slave_write_register(ViPipe, 0x3025, 0x02);
|
||||
cv2003_1l_slave_write_register(ViPipe, 0x3038, 0x04);
|
||||
cv2003_1l_slave_write_register(ViPipe, 0x3038, 0x00);
|
||||
cv2003_1l_slave_write_register(ViPipe, 0x3039, 0x00);
|
||||
cv2003_1l_slave_write_register(ViPipe, 0x303A, 0x80);
|
||||
cv2003_1l_slave_write_register(ViPipe, 0x303A, 0x88);
|
||||
cv2003_1l_slave_write_register(ViPipe, 0x303B, 0x07);
|
||||
cv2003_1l_slave_write_register(ViPipe, 0x3034, 0x04);
|
||||
cv2003_1l_slave_write_register(ViPipe, 0x3034, 0x00);
|
||||
cv2003_1l_slave_write_register(ViPipe, 0x3035, 0x00);
|
||||
cv2003_1l_slave_write_register(ViPipe, 0x3036, 0x38);
|
||||
cv2003_1l_slave_write_register(ViPipe, 0x3036, 0x40);
|
||||
cv2003_1l_slave_write_register(ViPipe, 0x3037, 0x04);
|
||||
cv2003_1l_slave_write_register(ViPipe, 0x3908, 0x48);
|
||||
cv2003_1l_slave_write_register(ViPipe, 0x390A, 0x02);
|
||||
@ -280,6 +281,8 @@ static void cv2003_1l_slave_linear_1080P30_init(VI_PIPE ViPipe)
|
||||
cv2003_1l_slave_write_register(ViPipe, 0x3001, 0x01);
|
||||
cv2003_1l_slave_write_register(ViPipe, 0x307A, 0x02);
|
||||
cv2003_1l_slave_write_register(ViPipe, 0x306D, 0x0F);
|
||||
//high
|
||||
cv2003_1l_slave_write_register(ViPipe, 0x3078, 0x00);
|
||||
|
||||
cv2003_1l_slave_default_reg_init(ViPipe);
|
||||
delay_ms(100);
|
||||
|
||||
@ -158,7 +158,8 @@ static CVI_S32 cmos_get_ae_default(VI_PIPE ViPipe, AE_SENSOR_DEFAULT_S *pstAeSns
|
||||
pstAeSnsDft->u8AeCompensation = 40;
|
||||
pstAeSnsDft->u32InitAESpeed = 64;
|
||||
pstAeSnsDft->u32InitAETolerance = 2;
|
||||
pstAeSnsDft->u32AEResponseFrame = 5;
|
||||
pstAeSnsDft->u32AEResponseFrame = 2;
|
||||
pstAeSnsDft->u32SnsResponseFrame = 5;
|
||||
pstAeSnsDft->enAeExpMode = AE_EXP_HIGHLIGHT_PRIOR;
|
||||
pstAeSnsDft->u32InitExposure = g_au32InitExposure[ViPipe] ?
|
||||
g_au32InitExposure[ViPipe] : pstMode->stExp[0].u16Def;
|
||||
@ -242,32 +243,57 @@ static CVI_S32 cmos_inttime_update(VI_PIPE ViPipe, CVI_U32 *u32IntTime)
|
||||
return CVI_SUCCESS;
|
||||
}
|
||||
|
||||
static CVI_U32 gain_table[242] = {
|
||||
1024, 1024, 1024, 1024, 1040, 1040, 1040, 1040, 1056, 1056,
|
||||
1056, 1056, 1072, 1072, 1072, 1072, 1088, 1088, 1088, 1104,
|
||||
1104, 1104, 1120, 1120, 1120, 1120, 1136, 1136, 1136, 1152,
|
||||
1152, 1152, 1168, 1168, 1168, 1184, 1184, 1184, 1200, 1200,
|
||||
1200, 1216, 1216, 1216, 1232, 1232, 1248, 1248, 1248, 1264,
|
||||
1264, 1264, 1280, 1280, 1296, 1296, 1296, 1312, 1312, 1328,
|
||||
1328, 1344, 1344, 1344, 1360, 1360, 1376, 1376, 1392, 1392,
|
||||
1408, 1408, 1424, 1424, 1440, 1440, 1456, 1456, 1472, 1472,
|
||||
1488, 1488, 1504, 1504, 1520, 1520, 1536, 1536, 1552, 1568,
|
||||
1568, 1584, 1584, 1600, 1616, 1616, 1632, 1648, 1648, 1664,
|
||||
1680, 1680, 1696, 1712, 1712, 1728, 1744, 1744, 1760, 1776,
|
||||
1792, 1808, 1808, 1824, 1840, 1856, 1872, 1872, 1888, 1904,
|
||||
1920, 1936, 1952, 1968, 1984, 2000, 2016, 2016, 2048, 2064,
|
||||
2080, 2096, 2112, 2128, 2144, 2160, 2176, 2192, 2208, 2240,
|
||||
2256, 2272, 2288, 2304, 2336, 2352, 2368, 2400, 2416, 2448,
|
||||
2464, 2496, 2512, 2544, 2560, 2592, 2608, 2640, 2672, 2688,
|
||||
2720, 2752, 2784, 2816, 2848, 2880, 2912, 2944, 2976, 3008,
|
||||
3040, 3072, 3120, 3152, 3184, 3232, 3264, 3312, 3360, 3392,
|
||||
3440, 3488, 3536, 3584, 3632, 3680, 3744, 3792, 3840, 3904,
|
||||
3968, 4032, 4096, 4160, 4224, 4288, 4368, 4432, 4512, 4592,
|
||||
4672, 4752, 4848, 4944, 5040, 5136, 5232, 5344, 5456, 5568,
|
||||
5696, 5824, 5952, 6080, 6240, 6384, 6544, 6720, 6896, 7072,
|
||||
7280, 7488, 7696, 7936, 8192, 8448, 8736, 9024, 9360, 9696,
|
||||
10080, 10480, 10912, 11392, 11904, 12480, 13104, 13792, 14560, 15408,
|
||||
16384, 0x3FFFF,
|
||||
static CVI_U32 gain_table[250] = {
|
||||
1024, 1024, 1024, 1024, 1040,
|
||||
1040, 1040, 1040, 1056, 1056,
|
||||
1056, 1056, 1072, 1072, 1072,
|
||||
1072, 1088, 1088, 1088, 1104,
|
||||
1104, 1104, 1120, 1120, 1120,
|
||||
1120, 1136, 1136, 1136, 1152,
|
||||
1152, 1152, 1168, 1168, 1168,
|
||||
1184, 1184, 1184, 1200, 1200,
|
||||
1200, 1216, 1216, 1216, 1232,
|
||||
1232, 1248, 1248, 1248, 1264,
|
||||
1264, 1264, 1280, 1280, 1296,
|
||||
1296, 1296, 1312, 1312, 1328,
|
||||
1328, 1344, 1344, 1344, 1360,
|
||||
1360, 1376, 1376, 1392, 1392,
|
||||
1408, 1408, 1424, 1424, 1440,
|
||||
1440, 1456, 1456, 1472, 1472,
|
||||
1488, 1488, 1504, 1504, 1520,
|
||||
1520, 1536, 1536, 1552, 1568,
|
||||
1568, 1584, 1584, 1600, 1616,
|
||||
1616, 1632, 1648, 1648, 1664,
|
||||
1680, 1680, 1696, 1712, 1712,
|
||||
1728, 1744, 1744, 1760, 1776,
|
||||
1792, 1808, 1808, 1824, 1840,
|
||||
1856, 1872, 1872, 1904, 1904,
|
||||
1920, 1936, 1952, 1968, 1984,
|
||||
2000, 2016, 2016, 2048, 2064,
|
||||
2080, 2096, 2112, 2128, 2144,
|
||||
2160, 2176, 2192, 2208, 2240,
|
||||
2256, 2272, 2288, 2304, 2336,
|
||||
2352, 2368, 2400, 2416, 2448,
|
||||
2464, 2496, 2512, 2544, 2560,
|
||||
2576, 2608, 2640, 2672, 2688,
|
||||
2720, 2752, 2784, 2816, 2848,
|
||||
2880, 2912, 2944, 2976, 2008,
|
||||
3040, 3072, 3120, 3152, 3184,
|
||||
3232, 3264, 3312, 3360, 3392,
|
||||
3440, 3488, 3536, 3584, 3632,
|
||||
3680, 3744, 3792, 3840, 3904,
|
||||
3968, 4032, 4096, 4160, 4224,
|
||||
4288, 4368, 4432, 4512, 4592,
|
||||
4672, 4752, 4848, 4944, 5040,
|
||||
5136, 5232, 5344, 5456, 5568,
|
||||
5696, 5824, 5952, 6080, 6240,
|
||||
6384, 6384, 6720, 6896, 7072,
|
||||
7280, 7488, 7696, 7936, 8192,
|
||||
8448, 8736, 9024, 9360, 9696,
|
||||
10080, 10480, 10912, 11392, 11904,
|
||||
12480, 13104, 13792, 14560, 15408,
|
||||
16384, 17472, 18720, 20160, 21840,
|
||||
23824, 26208, 29120, 32768, 0xFFFF,
|
||||
};
|
||||
|
||||
static CVI_S32 cmos_again_calc_table(VI_PIPE ViPipe, CVI_U32 *pu32AgainLin, CVI_U32 *pu32AgainDb)
|
||||
@ -706,8 +732,8 @@ static CVI_S32 cmos_set_image_mode(VI_PIPE ViPipe, ISP_CMOS_SENSOR_IMAGE_MODE_S
|
||||
static CVI_VOID sensor_mirror_flip(VI_PIPE ViPipe, ISP_SNS_MIRRORFLIP_TYPE_E eSnsMirrorFlip)
|
||||
{
|
||||
CVI_U8 value = 0x0;
|
||||
CVI_U8 start_x = 4;
|
||||
CVI_U8 start_y = 4;
|
||||
CVI_U8 start_x = 0;
|
||||
CVI_U8 start_y = 0;
|
||||
|
||||
ISP_SNS_STATE_S *pstSnsState = CVI_NULL;
|
||||
ISP_SNS_REGS_INFO_S *pstSnsRegsInfo = CVI_NULL;
|
||||
@ -724,23 +750,23 @@ static CVI_VOID sensor_mirror_flip(VI_PIPE ViPipe, ISP_SNS_MIRRORFLIP_TYPE_E eSn
|
||||
switch (eSnsMirrorFlip) {
|
||||
case ISP_SNS_NORMAL:
|
||||
value = 0x0;
|
||||
start_x = 4;
|
||||
start_y = 4;
|
||||
start_x = 0;
|
||||
start_y = 0;
|
||||
break;
|
||||
case ISP_SNS_MIRROR:
|
||||
value = 0x1;
|
||||
start_x = 5;
|
||||
start_y = 4;
|
||||
start_x = 1;
|
||||
start_y = 0;
|
||||
break;
|
||||
case ISP_SNS_FLIP:
|
||||
value = 0x2;
|
||||
start_x = 4;
|
||||
start_y = 5;
|
||||
start_x = 0;
|
||||
start_y = 1;
|
||||
break;
|
||||
case ISP_SNS_MIRROR_FLIP:
|
||||
value = 0x3;
|
||||
start_x = 5;
|
||||
start_y = 5;
|
||||
start_x = 1;
|
||||
start_y = 1;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
|
||||
@ -24,8 +24,8 @@ static const CV2003_1L_SLAVE1_MODE_S g_astCV2003_1L_SLAVE1_mode[CV2003_1L_SLAVE1
|
||||
.name = "1920X1080P30",
|
||||
.astImg[0] = {
|
||||
.stSnsSize = {
|
||||
.u32Width = 1920,
|
||||
.u32Height = 1080,
|
||||
.u32Width = 1928,
|
||||
.u32Height = 1088,
|
||||
},
|
||||
.stWndRect = {
|
||||
.s32X = 0,
|
||||
@ -34,8 +34,8 @@ static const CV2003_1L_SLAVE1_MODE_S g_astCV2003_1L_SLAVE1_mode[CV2003_1L_SLAVE1
|
||||
.u32Height = 1080,
|
||||
},
|
||||
.stMaxSize = {
|
||||
.u32Width = 1920,
|
||||
.u32Height = 1080,
|
||||
.u32Width = 1928,
|
||||
.u32Height = 1088,
|
||||
},
|
||||
},
|
||||
.f32MaxFps = 30,
|
||||
|
||||
@ -221,10 +221,16 @@ static void cv2003_1l_slave1_linear_1080P30_init(VI_PIPE ViPipe)
|
||||
{
|
||||
delay_ms(10);
|
||||
|
||||
//30fps
|
||||
//15fps
|
||||
cv2003_1l_slave1_write_register(ViPipe, 0x3300, 0x03);
|
||||
cv2003_1l_slave1_write_register(ViPipe, 0x3422, 0xBF);
|
||||
cv2003_1l_slave1_write_register(ViPipe, 0x3401, 0x00);
|
||||
//CHAGE MIPI DATA<==>MIPI CLK
|
||||
// cv2003_1l_slave1_write_register(ViPipe, 0x342E,0x00);
|
||||
// cv2003_1l_slave1_write_register(ViPipe, 0x342F,0x01);
|
||||
// cv2003_1l_slave1_write_register(ViPipe, 0x3430,0x02);
|
||||
// cv2003_1l_slave1_write_register(ViPipe, 0x3431,0x03);
|
||||
|
||||
cv2003_1l_slave1_write_register(ViPipe, 0x3440, 0x01);
|
||||
cv2003_1l_slave1_write_register(ViPipe, 0x3442, 0x00);
|
||||
// cv2003_1l_slave1_write_register(ViPipe, 0x3460, 0x03);//drive capability
|
||||
@ -261,17 +267,17 @@ static void cv2003_1l_slave1_linear_1080P30_init(VI_PIPE ViPipe)
|
||||
cv2003_1l_slave1_write_register(ViPipe, 0x3144, 0x20);
|
||||
cv2003_1l_slave1_write_register(ViPipe, 0x301c, 0x00);
|
||||
cv2003_1l_slave1_write_register(ViPipe, 0x3030, 0x01);
|
||||
cv2003_1l_slave1_write_register(ViPipe, 0x3020, 0xCA);
|
||||
cv2003_1l_slave1_write_register(ViPipe, 0x3021, 0x08);
|
||||
cv2003_1l_slave1_write_register(ViPipe, 0x3020, 0x94);
|
||||
cv2003_1l_slave1_write_register(ViPipe, 0x3021, 0x11);
|
||||
cv2003_1l_slave1_write_register(ViPipe, 0x3024, 0x80);
|
||||
cv2003_1l_slave1_write_register(ViPipe, 0x3025, 0x02);
|
||||
cv2003_1l_slave1_write_register(ViPipe, 0x3038, 0x04);
|
||||
cv2003_1l_slave1_write_register(ViPipe, 0x3038, 0x00);
|
||||
cv2003_1l_slave1_write_register(ViPipe, 0x3039, 0x00);
|
||||
cv2003_1l_slave1_write_register(ViPipe, 0x303A, 0x80);
|
||||
cv2003_1l_slave1_write_register(ViPipe, 0x303A, 0x88);
|
||||
cv2003_1l_slave1_write_register(ViPipe, 0x303B, 0x07);
|
||||
cv2003_1l_slave1_write_register(ViPipe, 0x3034, 0x04);
|
||||
cv2003_1l_slave1_write_register(ViPipe, 0x3034, 0x00);
|
||||
cv2003_1l_slave1_write_register(ViPipe, 0x3035, 0x00);
|
||||
cv2003_1l_slave1_write_register(ViPipe, 0x3036, 0x38);
|
||||
cv2003_1l_slave1_write_register(ViPipe, 0x3036, 0x40);
|
||||
cv2003_1l_slave1_write_register(ViPipe, 0x3037, 0x04);
|
||||
cv2003_1l_slave1_write_register(ViPipe, 0x3908, 0x48);
|
||||
cv2003_1l_slave1_write_register(ViPipe, 0x390A, 0x02);
|
||||
@ -280,6 +286,8 @@ static void cv2003_1l_slave1_linear_1080P30_init(VI_PIPE ViPipe)
|
||||
cv2003_1l_slave1_write_register(ViPipe, 0x3001, 0x01);
|
||||
cv2003_1l_slave1_write_register(ViPipe, 0x307A, 0x02);
|
||||
cv2003_1l_slave1_write_register(ViPipe, 0x306D, 0x0F);
|
||||
//low
|
||||
cv2003_1l_slave1_write_register(ViPipe, 0x3078, 0x04);
|
||||
|
||||
cv2003_1l_slave1_default_reg_init(ViPipe);
|
||||
delay_ms(100);
|
||||
|
||||
@ -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)/libsns_lt7911.a
|
||||
TARGET_SO = $(MW_LIB)/libsns_lt7911.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,423 @@
|
||||
#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 "lt7911_cmos_ex.h"
|
||||
#include "lt7911_cmos_param.h"
|
||||
|
||||
#define LT7911_ID 7911
|
||||
|
||||
#define INPUT_WIDTH (1920)
|
||||
#define INPUT_HEIGHT (1080)
|
||||
|
||||
/****************************************************************************
|
||||
* global variables *
|
||||
****************************************************************************/
|
||||
|
||||
ISP_SNS_STATE_S *g_pastLt7911[VI_MAX_PIPE_NUM] = {CVI_NULL};
|
||||
|
||||
#define LT7911_SENSOR_GET_CTX(dev, pstCtx) (pstCtx = g_pastLt7911[dev])
|
||||
#define LT7911_SENSOR_SET_CTX(dev, pstCtx) (g_pastLt7911[dev] = pstCtx)
|
||||
#define LT7911_SENSOR_RESET_CTX(dev) (g_pastLt7911[dev] = CVI_NULL)
|
||||
|
||||
ISP_SNS_COMMBUS_U g_aunLt7911_BusInfo[VI_MAX_PIPE_NUM] = {
|
||||
[0] = { .s8I2cDev = 0},
|
||||
[1 ... VI_MAX_PIPE_NUM - 1] = { .s8I2cDev = -1}
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* local variables and functions *
|
||||
****************************************************************************/
|
||||
|
||||
static CVI_S32 cmos_get_wdr_size(VI_PIPE ViPipe, ISP_SNS_ISP_INFO_S *pstIspCfg);
|
||||
/*****lt7911 Lines Range*****/
|
||||
|
||||
|
||||
static CVI_S32 cmos_get_ae_default(VI_PIPE ViPipe, AE_SENSOR_DEFAULT_S *pstAeSnsDft)
|
||||
{
|
||||
(void) ViPipe;
|
||||
(void) pstAeSnsDft;
|
||||
|
||||
return CVI_SUCCESS;
|
||||
}
|
||||
|
||||
static CVI_S32 cmos_again_calc_table(VI_PIPE ViPipe, CVI_U32 *pu32AgainLin, CVI_U32 *pu32AgainDb)
|
||||
{
|
||||
(void) ViPipe;
|
||||
(void) pu32AgainLin;
|
||||
(void) pu32AgainDb;
|
||||
|
||||
return CVI_SUCCESS;
|
||||
}
|
||||
|
||||
static CVI_S32 cmos_dgain_calc_table(VI_PIPE ViPipe, CVI_U32 *pu32DgainLin, CVI_U32 *pu32DgainDb)
|
||||
{
|
||||
(void) ViPipe;
|
||||
(void) pu32DgainLin;
|
||||
(void) pu32DgainDb;
|
||||
|
||||
return CVI_SUCCESS;
|
||||
}
|
||||
|
||||
static CVI_S32 cmos_gains_update(VI_PIPE ViPipe, CVI_U32 *pu32Again, CVI_U32 *pu32Dgain)
|
||||
{
|
||||
(void) ViPipe;
|
||||
(void) pu32Again;
|
||||
(void) pu32Dgain;
|
||||
|
||||
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_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;
|
||||
|
||||
return CVI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static CVI_S32 cmos_get_isp_default(VI_PIPE ViPipe, ISP_CMOS_DEFAULT_S *pstDef)
|
||||
{
|
||||
(void) ViPipe;
|
||||
|
||||
memset(pstDef, 0, sizeof(ISP_CMOS_DEFAULT_S));
|
||||
|
||||
return CVI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static CVI_S32 cmos_get_wdr_size(VI_PIPE ViPipe, ISP_SNS_ISP_INFO_S *pstIspCfg)
|
||||
{
|
||||
const LT7911_MODE_S *pstMode = CVI_NULL;
|
||||
ISP_SNS_STATE_S *pstSnsState = CVI_NULL;
|
||||
|
||||
LT7911_SENSOR_GET_CTX(ViPipe, pstSnsState);
|
||||
CMOS_CHECK_POINTER(pstSnsState);
|
||||
pstMode = &g_astLt7911_mode[pstSnsState->u8ImgMode];
|
||||
|
||||
if (pstSnsState->enWDRMode == WDR_MODE_NONE) {
|
||||
pstIspCfg->frm_num = 1;
|
||||
memcpy(&pstIspCfg->img_size[0], &pstMode->astImg[0], sizeof(ISP_WDR_SIZE_S));
|
||||
} else {
|
||||
CVI_TRACE_SNS(CVI_DBG_ERR, "not support wdr mode\n");
|
||||
}
|
||||
|
||||
return CVI_SUCCESS;
|
||||
}
|
||||
|
||||
static CVI_S32 cmos_get_sns_regs_info(VI_PIPE ViPipe, ISP_SNS_SYNC_INFO_S *pstSnsSyncInfo)
|
||||
{
|
||||
ISP_SNS_STATE_S *pstSnsState = CVI_NULL;
|
||||
ISP_SNS_REGS_INFO_S *pstSnsRegsInfo = CVI_NULL;
|
||||
ISP_SNS_SYNC_INFO_S *pstCfg0 = CVI_NULL;
|
||||
|
||||
CMOS_CHECK_POINTER(pstSnsSyncInfo);
|
||||
LT7911_SENSOR_GET_CTX(ViPipe, pstSnsState);
|
||||
CMOS_CHECK_POINTER(pstSnsState);
|
||||
pstSnsRegsInfo = &pstSnsSyncInfo->snsCfg;
|
||||
pstCfg0 = &pstSnsState->astSyncInfo[0];
|
||||
|
||||
//pstSnsState->bSyncInit, pstSnsRegsInfo->bConfig);
|
||||
if ((pstSnsState->bSyncInit == CVI_FALSE) || (pstSnsRegsInfo->bConfig == CVI_FALSE)) {
|
||||
pstCfg0->snsCfg.enSnsType = SNS_I2C_TYPE;
|
||||
pstCfg0->snsCfg.unComBus.s8I2cDev = g_aunLt7911_BusInfo[ViPipe].s8I2cDev;
|
||||
pstCfg0->snsCfg.u8Cfg2ValidDelayMax = 0;
|
||||
pstCfg0->snsCfg.use_snsr_sram = CVI_TRUE;
|
||||
pstCfg0->snsCfg.u32RegNum = LINEAR_REGS_NUM;
|
||||
pstSnsState->bSyncInit = CVI_TRUE;
|
||||
/* recalcualte WDR size */
|
||||
cmos_get_wdr_size(ViPipe, &pstCfg0->ispCfg);
|
||||
pstCfg0->ispCfg.need_update = CVI_TRUE;
|
||||
}
|
||||
|
||||
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];
|
||||
|
||||
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);
|
||||
LT7911_SENSOR_GET_CTX(ViPipe, pstSnsState);
|
||||
CMOS_CHECK_POINTER(pstSnsState);
|
||||
|
||||
u8SensorImageMode = LT7911_MODE_NORMAL;
|
||||
|
||||
pstSnsState->u8ImgMode = u8SensorImageMode;
|
||||
|
||||
return CVI_SUCCESS;
|
||||
}
|
||||
|
||||
static CVI_VOID sensor_global_init(VI_PIPE ViPipe)
|
||||
{
|
||||
(void) ViPipe;
|
||||
|
||||
ISP_SNS_STATE_S *pstSnsState = CVI_NULL;
|
||||
|
||||
LT7911_SENSOR_GET_CTX(ViPipe, pstSnsState);
|
||||
CMOS_CHECK_POINTER_VOID(pstSnsState);
|
||||
|
||||
pstSnsState->u8ImgMode = LT7911_MODE_NORMAL;
|
||||
}
|
||||
|
||||
static CVI_S32 sensor_rx_attr(VI_PIPE ViPipe, SNS_COMBO_DEV_ATTR_S *pstRxAttr)
|
||||
{
|
||||
ISP_SNS_STATE_S *pstSnsState = CVI_NULL;
|
||||
|
||||
LT7911_SENSOR_GET_CTX(ViPipe, pstSnsState);
|
||||
CMOS_CHECK_POINTER(pstSnsState);
|
||||
CMOS_CHECK_POINTER(pstRxAttr);
|
||||
|
||||
memcpy(pstRxAttr, <7911_rx_attr, sizeof(*pstRxAttr));
|
||||
|
||||
pstRxAttr->img_size.width = g_astLt7911_mode[0].astImg[pstSnsState->u8ImgMode].stSnsSize.u32Width;
|
||||
pstRxAttr->img_size.height = g_astLt7911_mode[0].astImg[pstSnsState->u8ImgMode].stSnsSize.u32Height;
|
||||
|
||||
return CVI_SUCCESS;
|
||||
}
|
||||
|
||||
static CVI_S32 cmos_set_wdr_mode(VI_PIPE ViPipe, CVI_U8 u8Mode)
|
||||
{
|
||||
(void) ViPipe;
|
||||
(void) u8Mode;
|
||||
|
||||
return CVI_SUCCESS;
|
||||
}
|
||||
|
||||
static CVI_S32 sensor_patch_rx_attr(RX_INIT_ATTR_S *pstRxInitAttr)
|
||||
{
|
||||
SNS_COMBO_DEV_ATTR_S *pstRxAttr = <7911_rx_attr;
|
||||
int i;
|
||||
|
||||
CMOS_CHECK_POINTER(pstRxInitAttr);
|
||||
|
||||
if (pstRxInitAttr->stMclkAttr.bMclkEn)
|
||||
pstRxAttr->mclk.cam = pstRxInitAttr->stMclkAttr.u8Mclk;
|
||||
|
||||
if (pstRxInitAttr->MipiDev >= 2)
|
||||
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 = lt7911_init;
|
||||
pstSensorExpFunc->pfn_cmos_sensor_exit = lt7911_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_sns_reg_info = cmos_get_sns_regs_info;
|
||||
|
||||
return CVI_SUCCESS;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* callback structure *
|
||||
****************************************************************************/
|
||||
|
||||
static CVI_S32 lt7911_set_bus_info(VI_PIPE ViPipe, ISP_SNS_COMMBUS_U unSNSBusInfo)
|
||||
{
|
||||
g_aunLt7911_BusInfo[ViPipe].s8I2cDev = unSNSBusInfo.s8I2cDev;
|
||||
|
||||
return CVI_SUCCESS;
|
||||
}
|
||||
|
||||
static CVI_VOID sensor_param_fix(CVI_VOID)
|
||||
{
|
||||
LT7911_MODE_S *pstMode = &g_astLt7911_mode[LT7911_MODE_NORMAL];
|
||||
|
||||
pstMode->astImg[0].stSnsSize.u32Width = INPUT_WIDTH;
|
||||
pstMode->astImg[0].stSnsSize.u32Height = INPUT_HEIGHT;
|
||||
pstMode->astImg[0].stWndRect.u32Width = INPUT_WIDTH;
|
||||
pstMode->astImg[0].stWndRect.u32Height = INPUT_HEIGHT;
|
||||
pstMode->astImg[0].stMaxSize.u32Width = INPUT_WIDTH;
|
||||
pstMode->astImg[0].stMaxSize.u32Height = INPUT_HEIGHT;
|
||||
}
|
||||
|
||||
static CVI_S32 sensor_ctx_init(VI_PIPE ViPipe)
|
||||
{
|
||||
ISP_SNS_STATE_S *pastSnsStateCtx = CVI_NULL;
|
||||
|
||||
LT7911_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));
|
||||
|
||||
LT7911_SENSOR_SET_CTX(ViPipe, pastSnsStateCtx);
|
||||
|
||||
return CVI_SUCCESS;
|
||||
}
|
||||
|
||||
static CVI_VOID sensor_ctx_exit(VI_PIPE ViPipe)
|
||||
{
|
||||
ISP_SNS_STATE_S *pastSnsStateCtx = CVI_NULL;
|
||||
|
||||
LT7911_SENSOR_GET_CTX(ViPipe, pastSnsStateCtx);
|
||||
SENSOR_FREE(pastSnsStateCtx);
|
||||
LT7911_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;
|
||||
ISP_SNS_ATTR_INFO_S stSnsAttrInfo;
|
||||
|
||||
CMOS_CHECK_POINTER(pstAeLib);
|
||||
CMOS_CHECK_POINTER(pstAwbLib);
|
||||
|
||||
sensor_param_fix();
|
||||
|
||||
s32Ret = sensor_ctx_init(ViPipe);
|
||||
|
||||
if (s32Ret != CVI_SUCCESS)
|
||||
return CVI_FAILURE;
|
||||
|
||||
stSnsAttrInfo.eSensorId = LT7911_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;
|
||||
}
|
||||
|
||||
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, LT7911_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, LT7911_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, LT7911_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)
|
||||
{
|
||||
(void) ViPipe;
|
||||
(void) pstInitAttr;
|
||||
|
||||
return CVI_SUCCESS;
|
||||
}
|
||||
|
||||
static CVI_S32 sensor_probe(VI_PIPE ViPipe)
|
||||
{
|
||||
return lt7911_probe(ViPipe);
|
||||
}
|
||||
|
||||
ISP_SNS_OBJ_S stSnsLT7911_Obj = {
|
||||
.pfnRegisterCallback = sensor_register_callback,
|
||||
.pfnUnRegisterCallback = sensor_unregister_callback,
|
||||
.pfnStandby = CVI_NULL,
|
||||
.pfnRestart = CVI_NULL,
|
||||
.pfnMirrorFlip = CVI_NULL,
|
||||
.pfnWriteReg = lt7911_write,
|
||||
.pfnReadReg = lt7911_read,
|
||||
.pfnSetBusInfo = lt7911_set_bus_info,
|
||||
.pfnSetInit = sensor_set_init,
|
||||
.pfnPatchRxAttr = sensor_patch_rx_attr,
|
||||
.pfnPatchI2cAddr = CVI_NULL,
|
||||
.pfnGetRxAttr = sensor_rx_attr,
|
||||
.pfnExpSensorCb = cmos_init_sensor_exp_function,
|
||||
.pfnExpAeCb = cmos_init_ae_exp_function,
|
||||
.pfnSnsProbe = sensor_probe,
|
||||
};
|
||||
@ -0,0 +1,63 @@
|
||||
#ifndef __LT7911_CMOS_EX_H_
|
||||
#define __LT7911_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 lt7911_linear_regs_e {
|
||||
LINEAR_REGS_NUM
|
||||
};
|
||||
|
||||
|
||||
typedef enum _LT7911_MODE_E {
|
||||
LT7911_MODE_NONE,
|
||||
LT7911_MODE_NORMAL,
|
||||
LT7911_MODE_NUM
|
||||
} LT7911_MODE_E;
|
||||
|
||||
|
||||
typedef struct _LT7911_MODE_S {
|
||||
ISP_WDR_SIZE_S astImg[2];
|
||||
char name[64];
|
||||
} LT7911_MODE_S;
|
||||
|
||||
|
||||
extern CVI_U8 lt7911_i2c_addr;
|
||||
extern const CVI_U32 lt7911_addr_byte;
|
||||
extern const CVI_U32 lt7911_data_byte;
|
||||
extern void lt7911_init(VI_PIPE ViPipe);
|
||||
extern void lt7911_exit(VI_PIPE ViPipe);
|
||||
extern void lt7911_standby(VI_PIPE ViPipe);
|
||||
extern void lt7911_restart(VI_PIPE ViPipe);
|
||||
extern int lt7911_write(VI_PIPE ViPipe, int addr, int data);
|
||||
extern int lt7911_read(VI_PIPE ViPipe, int addr);
|
||||
extern void lt7911_mirror_flip(VI_PIPE ViPipe, ISP_SNS_MIRRORFLIP_TYPE_E eSnsMirrorFlip);
|
||||
extern int lt7911_probe(VI_PIPE ViPipe);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* End of #ifdef __cplusplus */
|
||||
|
||||
|
||||
#endif /* __LT7911_CMOS_EX_H_ */
|
||||
@ -0,0 +1,75 @@
|
||||
#ifndef __LT7911_CMOS_PARAM_H_
|
||||
#define __LT7911_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 "lt7911_cmos_ex.h"
|
||||
|
||||
// not real time resolution
|
||||
#define WIDTH 3840//3840 1920
|
||||
#define HEIGHT 2160//2160 1080
|
||||
|
||||
static LT7911_MODE_S g_astLt7911_mode[LT7911_MODE_NUM] = {
|
||||
[LT7911_MODE_NORMAL] = {
|
||||
.name = "lt7911",
|
||||
.astImg[0] = {
|
||||
.stSnsSize = {
|
||||
.u32Width = WIDTH,
|
||||
.u32Height = HEIGHT,
|
||||
},
|
||||
.stWndRect = {
|
||||
.s32X = 0,
|
||||
.s32Y = 0,
|
||||
.u32Width = WIDTH,
|
||||
.u32Height = HEIGHT,
|
||||
},
|
||||
.stMaxSize = {
|
||||
.u32Width = WIDTH,
|
||||
.u32Height = HEIGHT,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
struct combo_dev_attr_s lt7911_rx_attr = {
|
||||
.input_mode = INPUT_MODE_MIPI,
|
||||
.mac_clk = RX_MAC_CLK_600M,
|
||||
.mipi_attr = {
|
||||
.raw_data_type = YUV422_8BIT,
|
||||
.lane_id = {2, 0, 1, 3, 4},
|
||||
.pn_swap = {0, 0, 0, 0, 0},
|
||||
.wdr_mode = CVI_MIPI_WDR_MODE_NONE,
|
||||
.dphy = {
|
||||
.enable = 1,
|
||||
.hs_settle = 8,
|
||||
},
|
||||
},
|
||||
.mclk = {
|
||||
.cam = 0,
|
||||
.freq = CAMPLL_FREQ_NONE,
|
||||
},
|
||||
.devno = 0,
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* End of #ifdef __cplusplus */
|
||||
|
||||
|
||||
#endif /* __LT7911_CMOS_PARAM_H_ */
|
||||
@ -0,0 +1,214 @@
|
||||
#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 "lt7911_cmos_ex.h"
|
||||
|
||||
#define LT7911_I2C_DEV 3
|
||||
#define LT7911_I2C_BANK_ADDR 0xff
|
||||
|
||||
CVI_U8 lt7911_i2c_addr = 0x2b;
|
||||
const CVI_U32 lt7911_addr_byte = 1;
|
||||
const CVI_U32 lt7911_data_byte = 1;
|
||||
static int g_fd[VI_MAX_PIPE_NUM] = {[0 ... (VI_MAX_PIPE_NUM - 1)] = -1};
|
||||
|
||||
int lt7911_i2c_init(VI_PIPE ViPipe)
|
||||
{
|
||||
char acDevFile[16] = {0};
|
||||
|
||||
if (g_fd[ViPipe] >= 0)
|
||||
return CVI_SUCCESS;
|
||||
int ret;
|
||||
|
||||
snprintf(acDevFile, sizeof(acDevFile), "/dev/i2c-%u", LT7911_I2C_DEV);
|
||||
|
||||
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", LT7911_I2C_DEV);
|
||||
return CVI_FAILURE;
|
||||
}
|
||||
|
||||
ret = ioctl(g_fd[ViPipe], I2C_SLAVE_FORCE, lt7911_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 lt7911_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 lt7911_read_register(VI_PIPE ViPipe, int addr)
|
||||
{
|
||||
int ret, data;
|
||||
char buf[8];
|
||||
int idx = 0;
|
||||
|
||||
if (g_fd[ViPipe] < 0)
|
||||
return CVI_FAILURE;
|
||||
|
||||
if (lt7911_addr_byte == 2)
|
||||
buf[idx++] = (addr >> 8) & 0xff;
|
||||
|
||||
// add address byte 0
|
||||
buf[idx++] = addr & 0xff;
|
||||
|
||||
ret = write(g_fd[ViPipe], buf, lt7911_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, lt7911_data_byte);
|
||||
if (ret < 0) {
|
||||
CVI_TRACE_SNS(CVI_DBG_ERR, "I2C_READ error!\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
// pack read back data
|
||||
data = 0;
|
||||
if (lt7911_data_byte == 2) {
|
||||
data = buf[0] << 8;
|
||||
data += buf[1];
|
||||
} else {
|
||||
data = buf[0];
|
||||
}
|
||||
|
||||
syslog(LOG_DEBUG, "vipipe:%d i2c r 0x%x = 0x%x\n", ViPipe, addr, data);
|
||||
return data;
|
||||
}
|
||||
|
||||
int lt7911_write_register(VI_PIPE ViPipe, int addr, int data)
|
||||
{
|
||||
int idx = 0;
|
||||
int ret;
|
||||
char buf[8];
|
||||
|
||||
if (g_fd[ViPipe] < 0)
|
||||
return CVI_SUCCESS;
|
||||
|
||||
if (lt7911_addr_byte == 2) {
|
||||
buf[idx] = (addr >> 8) & 0xff;
|
||||
idx++;
|
||||
}
|
||||
buf[idx] = addr & 0xff;
|
||||
idx++;
|
||||
|
||||
|
||||
if (lt7911_data_byte == 2) {
|
||||
buf[idx] = (data >> 8) & 0xff;
|
||||
idx++;
|
||||
}
|
||||
buf[idx] = data & 0xff;
|
||||
idx++;
|
||||
|
||||
ret = write(g_fd[ViPipe], buf, lt7911_addr_byte + lt7911_data_byte);
|
||||
if (ret < 0) {
|
||||
CVI_TRACE_SNS(CVI_DBG_ERR, "I2C_WRITE error!\n");
|
||||
return CVI_FAILURE;
|
||||
}
|
||||
syslog(LOG_DEBUG, "ViPipe:%d i2c w 0x%x 0x%x\n", ViPipe, addr, data);
|
||||
return CVI_SUCCESS;
|
||||
}
|
||||
|
||||
static int lt7911_i2c_read(VI_PIPE ViPipe, int RegAddr)
|
||||
{
|
||||
uint8_t bank = RegAddr >> 8;
|
||||
uint8_t addr = RegAddr & 0xff;
|
||||
|
||||
lt7911_write_register(ViPipe, LT7911_I2C_BANK_ADDR, bank);
|
||||
return lt7911_read_register(ViPipe, addr);
|
||||
}
|
||||
|
||||
static int lt7911_i2c_write(VI_PIPE ViPipe, int RegAddr, int data)
|
||||
{
|
||||
uint8_t bank = RegAddr >> 8;
|
||||
uint8_t addr = RegAddr & 0xff;
|
||||
|
||||
lt7911_write_register(ViPipe, LT7911_I2C_BANK_ADDR, bank);
|
||||
return lt7911_write_register(ViPipe, addr, data);
|
||||
}
|
||||
|
||||
int lt7911_read(VI_PIPE ViPipe, int addr)
|
||||
{
|
||||
int data = 0;
|
||||
|
||||
lt7911_i2c_write(ViPipe, 0x80ee, 0x01);
|
||||
data = lt7911_i2c_read(ViPipe, addr);
|
||||
lt7911_i2c_write(ViPipe, 0x80ee, 0x00);
|
||||
return data;
|
||||
}
|
||||
|
||||
int lt7911_write(VI_PIPE ViPipe, int addr, int data)
|
||||
{
|
||||
lt7911_i2c_write(ViPipe, 0x80ee, 0x01);
|
||||
lt7911_i2c_write(ViPipe, addr, data);
|
||||
lt7911_i2c_write(ViPipe, 0x80ee, 0x00);
|
||||
return CVI_SUCCESS;
|
||||
}
|
||||
|
||||
#define LT7911_CHIP_ID_ADDR_H 0xa000
|
||||
#define LT7911_CHIP_ID_ADDR_L 0xa001
|
||||
#define LT7911_CHIP_ID 0x1605
|
||||
|
||||
int lt7911_probe(VI_PIPE ViPipe)
|
||||
{
|
||||
int nVal;
|
||||
int nVal2;
|
||||
|
||||
usleep(50);
|
||||
if (lt7911_i2c_init(ViPipe) != CVI_SUCCESS)
|
||||
return CVI_FAILURE;
|
||||
|
||||
nVal = lt7911_read(ViPipe, LT7911_CHIP_ID_ADDR_H);
|
||||
nVal2 = lt7911_read(ViPipe, LT7911_CHIP_ID_ADDR_L);
|
||||
if (nVal < 0 || nVal2 < 0) {
|
||||
CVI_TRACE_SNS(CVI_DBG_ERR, "read sensor id error.\n");
|
||||
return nVal;
|
||||
}
|
||||
printf("data:%02x %02x\n", nVal, nVal2);
|
||||
if ((((nVal & 0xFF) << 8) | (nVal2 & 0xFF)) != LT7911_CHIP_ID) {
|
||||
CVI_TRACE_SNS(CVI_DBG_ERR, "Sensor ID Mismatch! Use the wrong sensor??\n");
|
||||
return CVI_FAILURE;
|
||||
}
|
||||
|
||||
return CVI_SUCCESS;
|
||||
}
|
||||
|
||||
void lt7911_init(VI_PIPE ViPipe)
|
||||
{
|
||||
lt7911_i2c_init(ViPipe);
|
||||
}
|
||||
|
||||
void lt7911_exit(VI_PIPE ViPipe)
|
||||
{
|
||||
lt7911_i2c_exit(ViPipe);
|
||||
}
|
||||
@ -37,7 +37,10 @@
|
||||
#define DIV_0_TO_1_FLOAT(a) ((((a) < 1E-10) && ((a) > -1E-10)) ? 1 : (a))
|
||||
#define SC132GS_ID 0x132
|
||||
|
||||
#define SC132GS_I2C_ADDR_IS_VALID(addr) ((addr) == SC132GS_I2C_ADDR_1)
|
||||
#define SC132GS_I2C_ADDR_1 0x30
|
||||
#define SC132GS_I2C_ADDR_2 0x31
|
||||
|
||||
#define SC132GS_I2C_ADDR_IS_VALID(addr) ((addr) == SC132GS_I2C_ADDR_1 || (addr) == SC132GS_I2C_ADDR_2)
|
||||
|
||||
/****************************************************************************
|
||||
* global variables *
|
||||
|
||||
@ -31,13 +31,13 @@
|
||||
#include <linux/cif_uapi.h>
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#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 SC132GS_SLAVE_ID 0x132
|
||||
#define SC132GS_SLAVE_I2C_ADDR_1 0x30
|
||||
#define SC132GS_SLAVE_I2C_ADDR_2 0x31
|
||||
|
||||
#define SC132GS_SLAVE_I2C_ADDR_IS_VALID(addr) ((addr) == SC132GS_SLAVE_I2C_ADDR_1)
|
||||
#define SC132GS_SLAVE_I2C_ADDR_IS_VALID(addr) ((addr) == SC132GS_SLAVE_I2C_ADDR_1 || (addr) == SC132GS_SLAVE_I2C_ADDR_2)
|
||||
|
||||
/****************************************************************************
|
||||
* global variables *
|
||||
|
||||
@ -94,7 +94,7 @@ int sc132gs_slave_read_register(VI_PIPE ViPipe, int addr)
|
||||
// add address byte 0
|
||||
buf[idx++] = addr & 0xff;
|
||||
|
||||
ret = write(g_fd[ViPipe], buf, sc132gs_slave_data_byte);
|
||||
ret = write(g_fd[ViPipe], buf, sc132gs_slave_addr_byte);
|
||||
if (ret < 0) {
|
||||
CVI_TRACE_SNS(CVI_DBG_ERR, "I2C_WRITE error!\n");
|
||||
return ret;
|
||||
|
||||
@ -178,6 +178,7 @@ static CVI_S32 cmos_fps_set(VI_PIPE ViPipe, CVI_FLOAT f32Fps, AE_SENSOR_DEFAULT_
|
||||
switch (pstSnsState->u8ImgMode) {
|
||||
case SC2331_1L_SLAVE_MODE_1920X1080P30:
|
||||
if ((f32Fps <= f32MaxFps) && (f32Fps >= f32MinFps)) {
|
||||
f32Fps = 30;//fixed fps--unchangable
|
||||
u32VMAX = u32Vts * f32MaxFps / DIV_0_TO_1_FLOAT(f32Fps);
|
||||
} else {
|
||||
CVI_TRACE_SNS(CVI_DBG_ERR, "Not support Fps: %f\n", f32Fps);
|
||||
@ -642,13 +643,18 @@ static CVI_S32 cmos_get_sns_regs_info(VI_PIPE ViPipe, ISP_SNS_SYNC_INFO_S *pstSn
|
||||
case WDR_MODE_NONE:
|
||||
//Linear Mode Regs
|
||||
pstI2c_data[LINEAR_EXP_H_ADDR].u32RegAddr = SC2331_1L_SLAVE_EXP_H_ADDR;
|
||||
//pstI2c_data[LINEAR_EXP_H_ADDR].u8DelayFrmNum = 1;
|
||||
pstI2c_data[LINEAR_EXP_M_ADDR].u32RegAddr = SC2331_1L_SLAVE_EXP_M_ADDR;
|
||||
//pstI2c_data[LINEAR_EXP_M_ADDR].u8DelayFrmNum = 1;
|
||||
pstI2c_data[LINEAR_EXP_L_ADDR].u32RegAddr = SC2331_1L_SLAVE_EXP_L_ADDR;
|
||||
//pstI2c_data[LINEAR_EXP_L_ADDR].u8DelayFrmNum = 1;
|
||||
pstI2c_data[LINEAR_AGAIN_H_ADDR].u32RegAddr = SC2331_1L_SLAVE_AGAIN_H_ADDR;
|
||||
//pstI2c_data[LINEAR_AGAIN_H_ADDR].u8DelayFrmNum = 1;
|
||||
pstI2c_data[LINEAR_AGAIN_L_ADDR].u32RegAddr = SC2331_1L_SLAVE_DGAIN_L_ADDR;
|
||||
//pstI2c_data[LINEAR_AGAIN_L_ADDR].u8DelayFrmNum = 1;
|
||||
pstI2c_data[LINEAR_DGAIN_H_ADDR].u32RegAddr = SC2331_1L_SLAVE_DGAIN_H_ADDR;
|
||||
pstI2c_data[LINEAR_DGAIN_L_ADDR].u32RegAddr = SC2331_1L_SLAVE_DGAIN_L_ADDR;
|
||||
printf("awei pingbi\n");
|
||||
//pstI2c_data[LINEAR_DGAIN_L_ADDR].u8DelayFrmNum = 1;
|
||||
//pstI2c_data[LINEAR_VMAX_H_ADDR].u32RegAddr = SC2331_1L_SLAVE_VMAX_H_ADDR;
|
||||
//pstI2c_data[LINEAR_VMAX_L_ADDR].u32RegAddr = SC2331_1L_SLAVE_VMAX_L_ADDR;
|
||||
break;
|
||||
|
||||
@ -43,7 +43,7 @@ static const SC2331_1L_SLAVE_MODE_S g_astSC2331_1L_Slave_mode[SC2331_1L_SLAVE_MO
|
||||
.u32HtsDef = 2200,
|
||||
.u32VtsDef = 1125,
|
||||
.stExp[0] = {
|
||||
.u16Min = 2,//3
|
||||
.u16Min = 7,//3
|
||||
.u16Max = 1125 - 13,
|
||||
.u16Def = 400,
|
||||
.u16Step = 1,
|
||||
|
||||
@ -178,6 +178,7 @@ static CVI_S32 cmos_fps_set(VI_PIPE ViPipe, CVI_FLOAT f32Fps, AE_SENSOR_DEFAULT_
|
||||
switch (pstSnsState->u8ImgMode) {
|
||||
case SC2331_1L_slave1_MODE_1920X1080P30:
|
||||
if ((f32Fps <= f32MaxFps) && (f32Fps >= f32MinFps)) {
|
||||
f32Fps = 30;//fixed fps--unchangable
|
||||
u32VMAX = u32Vts * f32MaxFps / DIV_0_TO_1_FLOAT(f32Fps);
|
||||
} else {
|
||||
CVI_TRACE_SNS(CVI_DBG_ERR, "Not support Fps: %f\n", f32Fps);
|
||||
@ -642,13 +643,18 @@ static CVI_S32 cmos_get_sns_regs_info(VI_PIPE ViPipe, ISP_SNS_SYNC_INFO_S *pstSn
|
||||
case WDR_MODE_NONE:
|
||||
//Linear Mode Regs
|
||||
pstI2c_data[LINEAR_EXP_H_ADDR].u32RegAddr = SC2331_1L_slave1_EXP_H_ADDR;
|
||||
//pstI2c_data[LINEAR_EXP_H_ADDR].u8DelayFrmNum = 1;
|
||||
pstI2c_data[LINEAR_EXP_M_ADDR].u32RegAddr = SC2331_1L_slave1_EXP_M_ADDR;
|
||||
//pstI2c_data[LINEAR_EXP_M_ADDR].u8DelayFrmNum = 1;
|
||||
pstI2c_data[LINEAR_EXP_L_ADDR].u32RegAddr = SC2331_1L_slave1_EXP_L_ADDR;
|
||||
//pstI2c_data[LINEAR_EXP_L_ADDR].u8DelayFrmNum = 1;
|
||||
pstI2c_data[LINEAR_AGAIN_H_ADDR].u32RegAddr = SC2331_1L_slave1_AGAIN_H_ADDR;
|
||||
//pstI2c_data[LINEAR_AGAIN_H_ADDR].u8DelayFrmNum = 1;
|
||||
pstI2c_data[LINEAR_AGAIN_L_ADDR].u32RegAddr = SC2331_1L_slave1_DGAIN_L_ADDR;
|
||||
//pstI2c_data[LINEAR_AGAIN_L_ADDR].u8DelayFrmNum = 1;
|
||||
pstI2c_data[LINEAR_DGAIN_H_ADDR].u32RegAddr = SC2331_1L_slave1_DGAIN_H_ADDR;
|
||||
pstI2c_data[LINEAR_DGAIN_L_ADDR].u32RegAddr = SC2331_1L_slave1_DGAIN_L_ADDR;
|
||||
printf("awei pingbi2\n");
|
||||
//pstI2c_data[LINEAR_DGAIN_L_ADDR].u8DelayFrmNum = 1;
|
||||
// pstI2c_data[LINEAR_VMAX_H_ADDR].u32RegAddr = SC2331_1L_slave1_VMAX_H_ADDR;
|
||||
// pstI2c_data[LINEAR_VMAX_L_ADDR].u32RegAddr = SC2331_1L_slave1_VMAX_L_ADDR;
|
||||
break;
|
||||
|
||||
@ -43,7 +43,7 @@ static const SC2331_1L_slave1_MODE_S g_astSC2331_1L_slave1_mode[SC2331_1L_slave1
|
||||
.u32HtsDef = 2200,
|
||||
.u32VtsDef = 1125,
|
||||
.stExp[0] = {
|
||||
.u16Min = 2,//3
|
||||
.u16Min = 7,//3
|
||||
.u16Max = 1125 - 13,
|
||||
.u16Def = 400,
|
||||
.u16Step = 1,
|
||||
|
||||
Reference in New Issue
Block a user