middleware: weekly update 2023-04-26 1. add new sensor driver: tp2863,gc0329,mis2008 2. add some panel driver and sample app 3. update vi/vo driver 4. add ko_shrink for cv180x

Change-Id: Iea07e7ff516682255616f8f066ae33131e243a31
This commit is contained in:
sam.xiang
2023-04-27 15:29:21 +08:00
committed by forum_service
parent a57169ae72
commit ce9f68c35f
116 changed files with 9008 additions and 71 deletions

View File

@ -6,6 +6,7 @@ sensor-$(CONFIG_SENSOR_GCORE_GC2093) += gcore_gc2093
sensor-$(CONFIG_SENSOR_GCORE_GC2093_SLAVE) += gcore_gc2093_slave sensor-$(CONFIG_SENSOR_GCORE_GC2093_SLAVE) += gcore_gc2093_slave
sensor-$(CONFIG_SENSOR_GCORE_GC4653) += gcore_gc4653 sensor-$(CONFIG_SENSOR_GCORE_GC4653) += gcore_gc4653
sensor-$(CONFIG_SENSOR_GCORE_GC4653_SLAVE) += gcore_gc4653_slave sensor-$(CONFIG_SENSOR_GCORE_GC4653_SLAVE) += gcore_gc4653_slave
sensor-$(CONFIG_SENSOR_IMGDS_MIS2008) += imgds_mis2008
sensor-$(CONFIG_SENSOR_NEXTCHIP_N5) += nextchip_n5 sensor-$(CONFIG_SENSOR_NEXTCHIP_N5) += nextchip_n5
sensor-$(CONFIG_SENSOR_OV_OS02D10) += ov_os02d10 sensor-$(CONFIG_SENSOR_OV_OS02D10) += ov_os02d10
sensor-$(CONFIG_SENSOR_OV_OS02D10_SLAVE) += ov_os02d10_slave sensor-$(CONFIG_SENSOR_OV_OS02D10_SLAVE) += ov_os02d10_slave
@ -45,6 +46,7 @@ sensor-$(CONFIG_SENSOR_SONY_IMX335) += sony_imx335
sensor-$(CONFIG_SENSOR_SONY_IMX347) += sony_imx347 sensor-$(CONFIG_SENSOR_SONY_IMX347) += sony_imx347
sensor-$(CONFIG_SENSOR_SONY_IMX385) += sony_imx385 sensor-$(CONFIG_SENSOR_SONY_IMX385) += sony_imx385
sensor-$(CONFIG_SENSOR_TECHPOINT_TP2850) += techpoint_tp2850 sensor-$(CONFIG_SENSOR_TECHPOINT_TP2850) += techpoint_tp2850
sensor-$(CONFIG_SENSOR_TECHPOINT_TP2863) += techpoint_tp2863
sensor-$(CONFIG_SENSOR_VIVO_MCS369) += vivo_mcs369 sensor-$(CONFIG_SENSOR_VIVO_MCS369) += vivo_mcs369
sensor-$(CONFIG_SENSOR_VIVO_MCS369Q) += vivo_mcs369q sensor-$(CONFIG_SENSOR_VIVO_MCS369Q) += vivo_mcs369q
sensor-$(CONFIG_SENSOR_VIVO_MM308M2) += vivo_mm308m2 sensor-$(CONFIG_SENSOR_VIVO_MM308M2) += vivo_mm308m2
@ -52,6 +54,7 @@ sensor-$(CONFIG_SENSOR_TECHPOINT_TP2825) += techpoint_tp2825
else ifeq ($(CHIP_ARCH), $(filter $(CHIP_ARCH), CV180X CV181X CV182X)) else ifeq ($(CHIP_ARCH), $(filter $(CHIP_ARCH), CV180X CV181X CV182X))
sensor-$(CONFIG_SENSOR_BRIGATES_BG0808) += brigates_bg0808 sensor-$(CONFIG_SENSOR_BRIGATES_BG0808) += brigates_bg0808
sensor-$(CONFIG_SENSOR_GCORE_GC02M1) += gcore_gc02m1 sensor-$(CONFIG_SENSOR_GCORE_GC02M1) += gcore_gc02m1
sensor-$(CONFIG_SENSOR_GCORE_GC0329) += gcore_gc0329
sensor-$(CONFIG_SENSOR_GCORE_GC1054) += gcore_gc1054 sensor-$(CONFIG_SENSOR_GCORE_GC1054) += gcore_gc1054
sensor-$(CONFIG_SENSOR_GCORE_GC2053) += gcore_gc2053 sensor-$(CONFIG_SENSOR_GCORE_GC2053) += gcore_gc2053
sensor-$(CONFIG_SENSOR_GCORE_GC2053_SLAVE) += gcore_gc2053_slave sensor-$(CONFIG_SENSOR_GCORE_GC2053_SLAVE) += gcore_gc2053_slave
@ -60,6 +63,7 @@ sensor-$(CONFIG_SENSOR_GCORE_GC2093) += gcore_gc2093
sensor-$(CONFIG_SENSOR_GCORE_GC2145) += gcore_gc2145 sensor-$(CONFIG_SENSOR_GCORE_GC2145) += gcore_gc2145
sensor-$(CONFIG_SENSOR_GCORE_GC4023) += gcore_gc4023 sensor-$(CONFIG_SENSOR_GCORE_GC4023) += gcore_gc4023
sensor-$(CONFIG_SENSOR_GCORE_GC4653) += gcore_gc4653 sensor-$(CONFIG_SENSOR_GCORE_GC4653) += gcore_gc4653
sensor-$(CONFIG_SENSOR_IMGDS_MIS2008) += imgds_mis2008
sensor-$(CONFIG_SENSOR_NEXTCHIP_N5) += nextchip_n5 sensor-$(CONFIG_SENSOR_NEXTCHIP_N5) += nextchip_n5
sensor-$(CONFIG_SENSOR_NEXTCHIP_N6) += nextchip_n6 sensor-$(CONFIG_SENSOR_NEXTCHIP_N6) += nextchip_n6
sensor-$(CONFIG_SENSOR_OV_OS04A10) += ov_os04a10 sensor-$(CONFIG_SENSOR_OV_OS04A10) += ov_os04a10
@ -103,6 +107,7 @@ sensor-$(CONFIG_SENSOR_SONY_IMX327_FPGA) += sony_imx327_fpga
sensor-$(CONFIG_SENSOR_SONY_IMX327_SUBLVDS) += sony_imx327_sublvds sensor-$(CONFIG_SENSOR_SONY_IMX327_SUBLVDS) += sony_imx327_sublvds
sensor-$(CONFIG_SENSOR_SONY_IMX335) += sony_imx335 sensor-$(CONFIG_SENSOR_SONY_IMX335) += sony_imx335
sensor-$(CONFIG_SENSOR_TECHPOINT_TP2825) += techpoint_tp2825 sensor-$(CONFIG_SENSOR_TECHPOINT_TP2825) += techpoint_tp2825
sensor-$(CONFIG_SENSOR_TECHPOINT_TP2863) += techpoint_tp2863
else else
$(error not supported chip arch cv180x/cv181x/cv182x/cv183x) $(error not supported chip arch cv180x/cv181x/cv182x/cv183x)
endif endif

View File

@ -29,6 +29,9 @@ brigates_bg0808:
gcore_gc02m1: gcore_gc02m1:
$(call MAKE_SENSOR, ${@}) $(call MAKE_SENSOR, ${@})
gcore_gc0329:
$(call MAKE_SENSOR, ${@})
gcore_gc1054: gcore_gc1054:
$(call MAKE_SENSOR, ${@}) $(call MAKE_SENSOR, ${@})
@ -53,6 +56,9 @@ gcore_gc4023:
gcore_gc4653: gcore_gc4653:
$(call MAKE_SENSOR, ${@}) $(call MAKE_SENSOR, ${@})
imgds_mis2008:
$(call MAKE_SENSOR, ${@})
nextchip_n5: nextchip_n5:
$(call MAKE_SENSOR, ${@}) $(call MAKE_SENSOR, ${@})
@ -181,6 +187,9 @@ sony_imx335:
techpoint_tp2825: techpoint_tp2825:
$(call MAKE_SENSOR, ${@}) $(call MAKE_SENSOR, ${@})
techpoint_tp2863:
$(call MAKE_SENSOR, ${@})
all_sensor: all_sensor:
@$(MAKE) -f Makefile_full || exit 1; @$(MAKE) -f Makefile_full || exit 1;

View File

@ -0,0 +1,36 @@
SHELL = /bin/bash
ifeq ($(PARAM_FILE), )
PARAM_FILE=../../../../../../$(shell echo $(MW_VER))/Makefile.param
include $(PARAM_FILE)
endif
SDIR = $(PWD)
SRCS = $(wildcard $(SDIR)/*.c)
INCS = -I$(MW_INC) -I$(ISP_INC) -I$(KERNEL_INC) -I./include
OBJS = $(SRCS:.c=.o)
DEPS = $(SRCS:.c=.d)
TARGET_A = $(MW_LIB)/libsns_gc0329.a
TARGET_SO = $(MW_LIB)/libsns_gc0329.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)

View File

@ -0,0 +1,303 @@
#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 "gc0329_cmos_ex.h"
#include "gc0329_cmos_param.h"
#define GC0329_ID 0xc0
#define GC0329_I2C_ADDR_1 0x31
#define GC0329_I2C_ADDR_IS_VALID(addr) ((addr) == GC0329_I2C_ADDR_1)
/****************************************************************************
* global variables *
****************************************************************************/
ISP_SNS_STATE_S *g_pastGc0329[VI_MAX_PIPE_NUM] = {CVI_NULL};
#define GC0329_SENSOR_GET_CTX(dev, pstCtx) (pstCtx = g_pastGc0329[dev])
#define GC0329_SENSOR_SET_CTX(dev, pstCtx) (g_pastGc0329[dev] = pstCtx)
#define GC0329_SENSOR_RESET_CTX(dev) (g_pastGc0329[dev] = CVI_NULL)
ISP_SNS_COMMBUS_U g_aunGc0329_BusInfo[VI_MAX_PIPE_NUM] = {
[0] = { .s8I2cDev = 0},
[1 ... VI_MAX_PIPE_NUM - 1] = { .s8I2cDev = -1}
};
/****************************************************************************
* local variables and functions *
****************************************************************************/
#define GC0329_RES_IS_480P(w, h) ((w) == 640 && (h) == 480)
static CVI_S32 cmos_get_wdr_size(VI_PIPE ViPipe, ISP_SNS_ISP_INFO_S *pstIspCfg)
{
const GC0329_MODE_S *pstMode = CVI_NULL;
ISP_SNS_STATE_S *pstSnsState = CVI_NULL;
GC0329_SENSOR_GET_CTX(ViPipe, pstSnsState);
CMOS_CHECK_POINTER(pstSnsState);
pstMode = &g_astGc0329_mode;
pstIspCfg->frm_num = 1;
memcpy(&pstIspCfg->img_size[0], &pstMode->stImg, 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);
GC0329_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);
GC0329_SENSOR_GET_CTX(ViPipe, pstSnsState);
CMOS_CHECK_POINTER(pstSnsState);
u8SensorImageMode = pstSnsState->u8ImgMode;
pstSnsState->bSyncInit = CVI_FALSE;
if (pstSensorImageMode->f32Fps <= 10) {
if (pstSnsState->enWDRMode == WDR_MODE_NONE) {
if (GC0329_RES_IS_480P(pstSensorImageMode->u16Width, pstSensorImageMode->u16Height))
u8SensorImageMode = GC0329_MODE_640X480P10;
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;
}
} 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;
}
} else {
CVI_TRACE_SNS(CVI_DBG_ERR, "Not support this Fps:%f\n", pstSensorImageMode->f32Fps);
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;
GC0329_SENSOR_GET_CTX(ViPipe, pstSnsState);
CMOS_CHECK_POINTER_VOID(pstSnsState);
pstSnsState->bInit = CVI_FALSE;
pstSnsState->bSyncInit = CVI_FALSE;
pstSnsState->u8ImgMode = GC0329_MODE_640X480P10;
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;
GC0329_SENSOR_GET_CTX(ViPipe, pstSnsState);
CMOS_CHECK_POINTER(pstSnsState);
CMOS_CHECK_POINTER(pstRxAttr);
memcpy(pstRxAttr, &gc0329_rx_attr, sizeof(*pstRxAttr));
pstRxAttr->img_size.width = g_astGc0329_mode.stImg.stSnsSize.u32Width;
pstRxAttr->img_size.height = g_astGc0329_mode.stImg.stSnsSize.u32Height;
return CVI_SUCCESS;
}
static CVI_S32 sensor_patch_rx_attr(RX_INIT_ATTR_S *pstRxInitAttr)
{
SNS_COMBO_DEV_ATTR_S *pstRxAttr = &gc0329_rx_attr;
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;
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 = gc0329_init;
pstSensorExpFunc->pfn_cmos_sensor_exit = gc0329_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_VOID sensor_patch_i2c_addr(CVI_S32 s32I2cAddr)
{
if (GC0329_I2C_ADDR_IS_VALID(s32I2cAddr))
gc0329_i2c_addr = s32I2cAddr;
}
static CVI_S32 gc0329_set_bus_info(VI_PIPE ViPipe, ISP_SNS_COMMBUS_U unSNSBusInfo)
{
g_aunGc0329_BusInfo[ViPipe].s8I2cDev = unSNSBusInfo.s8I2cDev;
return CVI_SUCCESS;
}
static CVI_S32 sensor_ctx_init(VI_PIPE ViPipe)
{
ISP_SNS_STATE_S *pastSnsStateCtx = CVI_NULL;
GC0329_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));
GC0329_SENSOR_SET_CTX(ViPipe, pastSnsStateCtx);
return CVI_SUCCESS;
}
static CVI_VOID sensor_ctx_exit(VI_PIPE ViPipe)
{
ISP_SNS_STATE_S *pastSnsStateCtx = CVI_NULL;
GC0329_SENSOR_GET_CTX(ViPipe, pastSnsStateCtx);
SENSOR_FREE(pastSnsStateCtx);
GC0329_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;
ISP_SNS_ATTR_INFO_S stSnsAttrInfo;
(void) pstAeLib;
(void) pstAwbLib;
s32Ret = sensor_ctx_init(ViPipe);
if (s32Ret != CVI_SUCCESS)
return CVI_FAILURE;
stSnsAttrInfo.eSensorId = GC0329_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)
{
CVI_S32 s32Ret;
(void) pstAeLib;
(void) pstAwbLib;
s32Ret = CVI_ISP_SensorUnRegCallBack(ViPipe, GC0329_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_probe(VI_PIPE ViPipe)
{
return gc0329_probe(ViPipe);
}
ISP_SNS_OBJ_S stSnsGc0329_Obj = {
.pfnRegisterCallback = sensor_register_callback,
.pfnUnRegisterCallback = sensor_unregister_callback,
.pfnStandby = CVI_NULL,
.pfnRestart = CVI_NULL,
.pfnWriteReg = gc0329_write_register,
.pfnReadReg = gc0329_read_register,
.pfnSetBusInfo = gc0329_set_bus_info,
.pfnSetInit = CVI_NULL,
.pfnMirrorFlip = CVI_NULL,
.pfnPatchRxAttr = sensor_patch_rx_attr,
.pfnPatchI2cAddr = sensor_patch_i2c_addr,
.pfnGetRxAttr = sensor_rx_attr,
.pfnExpSensorCb = cmos_init_sensor_exp_function,
.pfnExpAeCb = CVI_NULL,
.pfnSnsProbe = sensor_probe,
};

View File

@ -0,0 +1,64 @@
#ifndef __GC0329_CMOS_EX_H_
#define __GC0329_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 _GC0329_MODE_E {
GC0329_MODE_640X480P10 = 0,
GC0329_MODE_NUM
} GC0329_SLAVE_MODE_E;
typedef struct _GC0329_MODE_S {
ISP_WDR_SIZE_S stImg;
CVI_FLOAT f32MaxFps;
CVI_FLOAT f32MinFps;
CVI_U32 u32HtsDef;
CVI_U32 u32VtsDef;
SNS_ATTR_S stExp;
SNS_ATTR_LARGE_S stAgain;
SNS_ATTR_LARGE_S stDgain;
char name[64];
} GC0329_MODE_S;
/****************************************************************************
* external variables and functions *
****************************************************************************/
extern ISP_SNS_STATE_S *g_pastGc0329[VI_MAX_PIPE_NUM];
extern ISP_SNS_COMMBUS_U g_aunGc0329_BusInfo[];
extern CVI_U8 gc0329_i2c_addr;
extern const CVI_U32 gc0329_addr_byte;
extern const CVI_U32 gc0329_data_byte;
extern void gc0329_init(VI_PIPE ViPipe);
extern void gc0329_exit(VI_PIPE ViPipe);
extern void gc0329_standby(VI_PIPE ViPipe);
extern void gc0329_restart(VI_PIPE ViPipe);
extern int gc0329_write_register(VI_PIPE ViPipe, int addr, int data);
extern int gc0329_read_register(VI_PIPE ViPipe, int addr);
extern void gc0329_mirror_flip(VI_PIPE ViPipe, ISP_SNS_MIRRORFLIP_TYPE_E eSnsMirrorFlip);
extern int gc0329_probe(VI_PIPE ViPipe);
#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif /* End of #ifdef __cplusplus */
#endif /* __GC0329_CMOS_EX_H_ */

View File

@ -0,0 +1,71 @@
#ifndef __GC0329_CMOS_PARAM_H_
#define __GC0329_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 "gc0329_cmos_ex.h"
static const GC0329_MODE_S g_astGc0329_mode = {
.name = "640X480P10",
.stImg = {
.stSnsSize = {
.u32Width = 640,
.u32Height = 480,
},
.stWndRect = {
.s32X = 0,
.s32Y = 0,
.u32Width = 640,
.u32Height = 480,
},
.stMaxSize = {
.u32Width = 640,
.u32Height = 480,
},
},
};
struct combo_dev_attr_s gc0329_rx_attr = {
.input_mode = INPUT_MODE_BT601,
.mac_clk = RX_MAC_CLK_200M,
.ttl_attr = {
.vi = TTL_VI_SRC_VI0,
.ttl_fmt = TTL_VSDE_11B,
.raw_data_type = RAW_DATA_8BIT,
.func = {
8, -1, -1, 12,
0, 1, 2, 3,
4, 13, 14, 11,
-1, -1, -1, -1,
-1, -1, -1, -1,
},
},
.mclk = {
.cam = 0,
.freq = CAMPLL_FREQ_24M,
},
.devno = 0,
};
#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif /* End of #ifdef __cplusplus */
#endif /* __GC0329_CMOS_PARAM_H_ */

View File

@ -0,0 +1,464 @@
#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 "gc0329_cmos_ex.h"
static void gc0329_linear_480p10_init(VI_PIPE ViPipe);
CVI_U8 gc0329_i2c_addr = 0x31;//0x78
const CVI_U32 gc0329_addr_byte = 1;
const CVI_U32 gc0329_data_byte = 1;
static int g_fd[VI_MAX_PIPE_NUM] = {[0 ... (VI_MAX_PIPE_NUM - 1)] = -1};
int gc0329_i2c_init(VI_PIPE ViPipe)
{
char acDevFile[16] = {0};
CVI_U8 u8DevNum;
if (g_fd[ViPipe] >= 0)
return CVI_SUCCESS;
int ret;
u8DevNum = g_aunGc0329_BusInfo[ViPipe].s8I2cDev;
snprintf(acDevFile, sizeof(acDevFile), "/dev/i2c-%u", u8DevNum);
g_fd[ViPipe] = open(acDevFile, O_RDWR, 0600);
if (g_fd[ViPipe] < 0) {
CVI_TRACE_SNS(CVI_DBG_ERR, "Open /dev/i2c-%u error!\n", u8DevNum);
return CVI_FAILURE;
}
ret = ioctl(g_fd[ViPipe], I2C_SLAVE_FORCE, gc0329_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 gc0329_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 gc0329_read_register(VI_PIPE ViPipe, int addr)
{
int ret, data;
CVI_U8 buf[8];
CVI_U8 idx = 0;
if (g_fd[ViPipe] < 0)
return CVI_FAILURE;
if (gc0329_addr_byte == 2)
buf[idx++] = (addr >> 8) & 0xff;
// add address byte 0
buf[idx++] = addr & 0xff;
ret = write(g_fd[ViPipe], buf, gc0329_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, gc0329_data_byte);
if (ret < 0) {
CVI_TRACE_SNS(CVI_DBG_ERR, "I2C_READ error!\n");
return ret;
}
// pack read back data
data = 0;
if (gc0329_data_byte == 2) {
data = buf[0] << 8;
data += buf[1];
} else {
data = buf[0];
}
syslog(LOG_DEBUG, "i2c r 0x%x = 0x%x\n", addr, data);
return data;
}
int gc0329_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 (gc0329_addr_byte == 1) {
buf[idx] = addr & 0xff;
idx++;
}
if (gc0329_data_byte == 1) {
buf[idx] = data & 0xff;
idx++;
}
ret = write(g_fd[ViPipe], buf, gc0329_addr_byte + gc0329_data_byte);
if (ret < 0) {
CVI_TRACE_SNS(CVI_DBG_ERR, "I2C_WRITE error!\n");
return CVI_FAILURE;
}
// syslog(LOG_DEBUG, "i2c w 0x%x 0x%x\n", addr, data);
return CVI_SUCCESS;
}
static void delay_ms(int ms)
{
usleep(ms * 1000);
}
#define GC0329_CHIP_ID_ADDR 0x00
#define GC0329_CHIP_ID 0xc0
int gc0329_probe(VI_PIPE ViPipe)
{
int nVal;
usleep(50);
if (gc0329_i2c_init(ViPipe) != CVI_SUCCESS)
return CVI_FAILURE;
gc0329_write_register(ViPipe, 0xfc, 0x16);
nVal = gc0329_read_register(ViPipe, GC0329_CHIP_ID_ADDR);
if (nVal < 0) {
CVI_TRACE_SNS(CVI_DBG_ERR, "read sensor id error.\n");
return nVal;
}
if ((nVal & 0xFF) != GC0329_CHIP_ID) {
CVI_TRACE_SNS(CVI_DBG_ERR, "Sensor ID Mismatch! Use the wrong sensor??\n");
return CVI_FAILURE;
}
printf("%d\n", ViPipe);
return CVI_SUCCESS;
}
void gc0329_init(VI_PIPE ViPipe)
{
gc0329_i2c_init(ViPipe);
gc0329_linear_480p10_init(ViPipe);
g_pastGc0329[ViPipe]->bInit = CVI_TRUE;
}
void gc0329_exit(VI_PIPE ViPipe)
{
gc0329_i2c_exit(ViPipe);
}
static void gc0329_linear_480p10_init(VI_PIPE ViPipe)
{
gc0329_write_register(ViPipe, 0xfe, 0x80);
gc0329_write_register(ViPipe, 0xfc, 0x16);
gc0329_write_register(ViPipe, 0xfc, 0x16);
gc0329_write_register(ViPipe, 0xfe, 0x00);
gc0329_write_register(ViPipe, 0x70, 0x48);
gc0329_write_register(ViPipe, 0x73, 0x90);
gc0329_write_register(ViPipe, 0x74, 0x80);
gc0329_write_register(ViPipe, 0x75, 0x80);
gc0329_write_register(ViPipe, 0x76, 0x94);
gc0329_write_register(ViPipe, 0x77, 0x62);
gc0329_write_register(ViPipe, 0x78, 0x47);
gc0329_write_register(ViPipe, 0x79, 0x40);
gc0329_write_register(ViPipe, 0x03, 0x02);
gc0329_write_register(ViPipe, 0x04, 0x40);
gc0329_write_register(ViPipe, 0xfc, 0x16);
gc0329_write_register(ViPipe, 0x09, 0x00);
gc0329_write_register(ViPipe, 0x0a, 0x02);
gc0329_write_register(ViPipe, 0x0b, 0x00);
gc0329_write_register(ViPipe, 0x0c, 0x02);
gc0329_write_register(ViPipe, 0x17, 0x14);
gc0329_write_register(ViPipe, 0x19, 0x05);
gc0329_write_register(ViPipe, 0x1b, 0x24);
gc0329_write_register(ViPipe, 0x1c, 0x04);
gc0329_write_register(ViPipe, 0x1e, 0x08);
gc0329_write_register(ViPipe, 0x1f, 0x08);
gc0329_write_register(ViPipe, 0x20, 0x01);
gc0329_write_register(ViPipe, 0x21, 0x48);
gc0329_write_register(ViPipe, 0x22, 0xba);
gc0329_write_register(ViPipe, 0x23, 0x22);
gc0329_write_register(ViPipe, 0x24, 0x16);
gc0329_write_register(ViPipe, 0x26, 0xf7);
gc0329_write_register(ViPipe, 0x28, 0x7f);
gc0329_write_register(ViPipe, 0x29, 0x00);
gc0329_write_register(ViPipe, 0x32, 0x00);
gc0329_write_register(ViPipe, 0x33, 0x20);
gc0329_write_register(ViPipe, 0x34, 0x20);
gc0329_write_register(ViPipe, 0x35, 0x20);
gc0329_write_register(ViPipe, 0x36, 0x20);
gc0329_write_register(ViPipe, 0x3b, 0x04);
gc0329_write_register(ViPipe, 0x3c, 0x04);
gc0329_write_register(ViPipe, 0x3d, 0x04);
gc0329_write_register(ViPipe, 0x3e, 0x04);
gc0329_write_register(ViPipe, 0x40, 0xff);
gc0329_write_register(ViPipe, 0x41, 0x24);
gc0329_write_register(ViPipe, 0x42, 0xfa);
gc0329_write_register(ViPipe, 0x46, 0x02);
gc0329_write_register(ViPipe, 0x4b, 0xca);
gc0329_write_register(ViPipe, 0x4d, 0x01);
gc0329_write_register(ViPipe, 0x4f, 0x01);
gc0329_write_register(ViPipe, 0x70, 0x48);
gc0329_write_register(ViPipe, 0x80, 0x07);
gc0329_write_register(ViPipe, 0x81, 0xc2);
gc0329_write_register(ViPipe, 0x82, 0x90);
gc0329_write_register(ViPipe, 0x83, 0x05);
gc0329_write_register(ViPipe, 0x87, 0x40);
gc0329_write_register(ViPipe, 0x90, 0x8c);
gc0329_write_register(ViPipe, 0x92, 0x05);
gc0329_write_register(ViPipe, 0x94, 0x05);
gc0329_write_register(ViPipe, 0x95, 0x45);
gc0329_write_register(ViPipe, 0x96, 0x88);
gc0329_write_register(ViPipe, 0xfe, 0x01);
gc0329_write_register(ViPipe, 0x18, 0x22);
gc0329_write_register(ViPipe, 0xfe, 0x00);
gc0329_write_register(ViPipe, 0x9c, 0x0a);
gc0329_write_register(ViPipe, 0xa0, 0xaf);
gc0329_write_register(ViPipe, 0xa2, 0xff);
gc0329_write_register(ViPipe, 0xa4, 0x30);
gc0329_write_register(ViPipe, 0xa5, 0x31);
gc0329_write_register(ViPipe, 0xa7, 0x35);
gc0329_write_register(ViPipe, 0xfe, 0x00);
gc0329_write_register(ViPipe, 0xbf, 0x0b);
gc0329_write_register(ViPipe, 0xc0, 0x1d);
gc0329_write_register(ViPipe, 0xc1, 0x33);
gc0329_write_register(ViPipe, 0xc2, 0x49);
gc0329_write_register(ViPipe, 0xc3, 0x5d);
gc0329_write_register(ViPipe, 0xc4, 0x6e);
gc0329_write_register(ViPipe, 0xc5, 0x7c);
gc0329_write_register(ViPipe, 0xc6, 0x99);
gc0329_write_register(ViPipe, 0xc7, 0xaf);
gc0329_write_register(ViPipe, 0xc8, 0xc2);
gc0329_write_register(ViPipe, 0xc9, 0xd0);
gc0329_write_register(ViPipe, 0xca, 0xda);
gc0329_write_register(ViPipe, 0xcb, 0xe2);
gc0329_write_register(ViPipe, 0xcc, 0xe7);
gc0329_write_register(ViPipe, 0xcd, 0xf0);
gc0329_write_register(ViPipe, 0xce, 0xf7);
gc0329_write_register(ViPipe, 0xcf, 0xff);
gc0329_write_register(ViPipe, 0xfe, 0x00);
gc0329_write_register(ViPipe, 0x63, 0x00);
gc0329_write_register(ViPipe, 0x64, 0x06);
gc0329_write_register(ViPipe, 0x65, 0x0d);
gc0329_write_register(ViPipe, 0x66, 0x1b);
gc0329_write_register(ViPipe, 0x67, 0x2b);
gc0329_write_register(ViPipe, 0x68, 0x3d);
gc0329_write_register(ViPipe, 0x69, 0x50);
gc0329_write_register(ViPipe, 0x6a, 0x60);
gc0329_write_register(ViPipe, 0x6b, 0x80);
gc0329_write_register(ViPipe, 0x6c, 0xa0);
gc0329_write_register(ViPipe, 0x6d, 0xc0);
gc0329_write_register(ViPipe, 0x6e, 0xe0);
gc0329_write_register(ViPipe, 0x6f, 0xff);
gc0329_write_register(ViPipe, 0xfe, 0x00);
gc0329_write_register(ViPipe, 0xb3, 0x44);
gc0329_write_register(ViPipe, 0xb4, 0xfd);
gc0329_write_register(ViPipe, 0xb5, 0x02);
gc0329_write_register(ViPipe, 0xb6, 0xfa);
gc0329_write_register(ViPipe, 0xb7, 0x48);
gc0329_write_register(ViPipe, 0xb8, 0xf0);
gc0329_write_register(ViPipe, 0x50, 0x01);
gc0329_write_register(ViPipe, 0xfe, 0x00);
gc0329_write_register(ViPipe, 0xd0, 0x40);
gc0329_write_register(ViPipe, 0xd1, 0x28);
gc0329_write_register(ViPipe, 0xd2, 0x28);
gc0329_write_register(ViPipe, 0xd3, 0x40);
gc0329_write_register(ViPipe, 0xd5, 0x00);
gc0329_write_register(ViPipe, 0xdd, 0x14);
gc0329_write_register(ViPipe, 0xde, 0x34);
gc0329_write_register(ViPipe, 0xfe, 0x01);
gc0329_write_register(ViPipe, 0x10, 0x40);
gc0329_write_register(ViPipe, 0x11, 0x21);
gc0329_write_register(ViPipe, 0x12, 0x13);
gc0329_write_register(ViPipe, 0x13, 0x50);
gc0329_write_register(ViPipe, 0x17, 0xa8);
gc0329_write_register(ViPipe, 0x1a, 0x21);
gc0329_write_register(ViPipe, 0x20, 0x31);
gc0329_write_register(ViPipe, 0x21, 0xc0);
gc0329_write_register(ViPipe, 0x22, 0x60);
gc0329_write_register(ViPipe, 0x3c, 0x50);
gc0329_write_register(ViPipe, 0x3d, 0x40);
gc0329_write_register(ViPipe, 0x3e, 0x45);
gc0329_write_register(ViPipe, 0xfe, 0x01);
gc0329_write_register(ViPipe, 0x06, 0x12);
gc0329_write_register(ViPipe, 0x07, 0x06);
gc0329_write_register(ViPipe, 0x08, 0x9c);
gc0329_write_register(ViPipe, 0x09, 0xee);
gc0329_write_register(ViPipe, 0x50, 0xfc);
gc0329_write_register(ViPipe, 0x51, 0x28);
gc0329_write_register(ViPipe, 0x52, 0x10);
gc0329_write_register(ViPipe, 0x53, 0x20);
gc0329_write_register(ViPipe, 0x54, 0x12);
gc0329_write_register(ViPipe, 0x55, 0x16);
gc0329_write_register(ViPipe, 0x56, 0x30);
gc0329_write_register(ViPipe, 0x58, 0x60);
gc0329_write_register(ViPipe, 0x59, 0x08);
gc0329_write_register(ViPipe, 0x5a, 0x02);
gc0329_write_register(ViPipe, 0x5b, 0x63);
gc0329_write_register(ViPipe, 0x5c, 0x35);
gc0329_write_register(ViPipe, 0x5d, 0x72);
gc0329_write_register(ViPipe, 0x5e, 0x11);
gc0329_write_register(ViPipe, 0x5f, 0x40);
gc0329_write_register(ViPipe, 0x60, 0x40);
gc0329_write_register(ViPipe, 0x61, 0xc8);
gc0329_write_register(ViPipe, 0x62, 0xa0);
gc0329_write_register(ViPipe, 0x63, 0x40);
gc0329_write_register(ViPipe, 0x64, 0x50);
gc0329_write_register(ViPipe, 0x65, 0x98);
gc0329_write_register(ViPipe, 0x66, 0xfa);
gc0329_write_register(ViPipe, 0x67, 0x80);
gc0329_write_register(ViPipe, 0x68, 0x60);
gc0329_write_register(ViPipe, 0x69, 0x90);
gc0329_write_register(ViPipe, 0x6a, 0x40);
gc0329_write_register(ViPipe, 0x6b, 0x39);
gc0329_write_register(ViPipe, 0x6c, 0x30);
gc0329_write_register(ViPipe, 0x6d, 0x60);
gc0329_write_register(ViPipe, 0x6e, 0x41);
gc0329_write_register(ViPipe, 0x70, 0x10);
gc0329_write_register(ViPipe, 0x71, 0x00);
gc0329_write_register(ViPipe, 0x72, 0x10);
gc0329_write_register(ViPipe, 0x73, 0x40);
gc0329_write_register(ViPipe, 0x80, 0x60);
gc0329_write_register(ViPipe, 0x81, 0x50);
gc0329_write_register(ViPipe, 0x82, 0x42);
gc0329_write_register(ViPipe, 0x83, 0x40);
gc0329_write_register(ViPipe, 0x84, 0x40);
gc0329_write_register(ViPipe, 0x85, 0x40);
gc0329_write_register(ViPipe, 0x74, 0x40);
gc0329_write_register(ViPipe, 0x75, 0x58);
gc0329_write_register(ViPipe, 0x76, 0x24);
gc0329_write_register(ViPipe, 0x77, 0x40);
gc0329_write_register(ViPipe, 0x78, 0x20);
gc0329_write_register(ViPipe, 0x79, 0x60);
gc0329_write_register(ViPipe, 0x7a, 0x58);
gc0329_write_register(ViPipe, 0x7b, 0x20);
gc0329_write_register(ViPipe, 0x7c, 0x30);
gc0329_write_register(ViPipe, 0x7d, 0x35);
gc0329_write_register(ViPipe, 0x7e, 0x10);
gc0329_write_register(ViPipe, 0x7f, 0x08);
gc0329_write_register(ViPipe, 0x9c, 0x00);
gc0329_write_register(ViPipe, 0x9e, 0xc0);
gc0329_write_register(ViPipe, 0x9f, 0x40);
gc0329_write_register(ViPipe, 0xd0, 0x00);
gc0329_write_register(ViPipe, 0xd2, 0x2c);
gc0329_write_register(ViPipe, 0xd3, 0x80);
gc0329_write_register(ViPipe, 0xfe, 0x01);
gc0329_write_register(ViPipe, 0xc0, 0x0b);
gc0329_write_register(ViPipe, 0xc1, 0x07);
gc0329_write_register(ViPipe, 0xc2, 0x05);
gc0329_write_register(ViPipe, 0xc6, 0x0b);
gc0329_write_register(ViPipe, 0xc7, 0x07);
gc0329_write_register(ViPipe, 0xc8, 0x05);
gc0329_write_register(ViPipe, 0xba, 0x39);
gc0329_write_register(ViPipe, 0xbb, 0x24);
gc0329_write_register(ViPipe, 0xbc, 0x23);
gc0329_write_register(ViPipe, 0xb4, 0x39);
gc0329_write_register(ViPipe, 0xb5, 0x24);
gc0329_write_register(ViPipe, 0xb6, 0x23);
gc0329_write_register(ViPipe, 0xc3, 0x00);
gc0329_write_register(ViPipe, 0xc4, 0x00);
gc0329_write_register(ViPipe, 0xc5, 0x00);
gc0329_write_register(ViPipe, 0xc9, 0x00);
gc0329_write_register(ViPipe, 0xca, 0x00);
gc0329_write_register(ViPipe, 0xcb, 0x00);
gc0329_write_register(ViPipe, 0xbd, 0x2b);
gc0329_write_register(ViPipe, 0xbe, 0x00);
gc0329_write_register(ViPipe, 0xbf, 0x00);
gc0329_write_register(ViPipe, 0xb7, 0x09);
gc0329_write_register(ViPipe, 0xb8, 0x00);
gc0329_write_register(ViPipe, 0xb9, 0x00);
gc0329_write_register(ViPipe, 0xa8, 0x31);
gc0329_write_register(ViPipe, 0xa9, 0x23);
gc0329_write_register(ViPipe, 0xaa, 0x20);
gc0329_write_register(ViPipe, 0xab, 0x31);
gc0329_write_register(ViPipe, 0xac, 0x23);
gc0329_write_register(ViPipe, 0xad, 0x20);
gc0329_write_register(ViPipe, 0xae, 0x31);
gc0329_write_register(ViPipe, 0xaf, 0x23);
gc0329_write_register(ViPipe, 0xb0, 0x20);
gc0329_write_register(ViPipe, 0xb1, 0x31);
gc0329_write_register(ViPipe, 0xb2, 0x23);
gc0329_write_register(ViPipe, 0xb3, 0x20);
gc0329_write_register(ViPipe, 0xa4, 0x00);
gc0329_write_register(ViPipe, 0xa5, 0x00);
gc0329_write_register(ViPipe, 0xa6, 0x00);
gc0329_write_register(ViPipe, 0xa7, 0x00);
gc0329_write_register(ViPipe, 0xa1, 0x3c);
gc0329_write_register(ViPipe, 0xa2, 0x50);
gc0329_write_register(ViPipe, 0xfe, 0x00);
gc0329_write_register(ViPipe, 0x05, 0x02);
gc0329_write_register(ViPipe, 0x06, 0x2c);
gc0329_write_register(ViPipe, 0x07, 0x00);
gc0329_write_register(ViPipe, 0x08, 0xb8);
gc0329_write_register(ViPipe, 0xfe, 0x01);
gc0329_write_register(ViPipe, 0x29, 0x00);
gc0329_write_register(ViPipe, 0x2a, 0x60);
gc0329_write_register(ViPipe, 0x2b, 0x02);
gc0329_write_register(ViPipe, 0x2c, 0xa0);
gc0329_write_register(ViPipe, 0x2d, 0x03);
gc0329_write_register(ViPipe, 0x2e, 0x00);
gc0329_write_register(ViPipe, 0x2f, 0x03);
gc0329_write_register(ViPipe, 0x30, 0xc0);
gc0329_write_register(ViPipe, 0x31, 0x05);
gc0329_write_register(ViPipe, 0x32, 0x40);
gc0329_write_register(ViPipe, 0xfe, 0x00);
gc0329_write_register(ViPipe, 0x44, 0xa2);
gc0329_write_register(ViPipe, 0xf0, 0x07);
gc0329_write_register(ViPipe, 0xf1, 0x01);
delay_ms(50);
printf("ViPipe:%d,===GC0329 480P 10fps YUV Init OK!===\n", ViPipe);
}

View File

@ -28,6 +28,10 @@
#define DIV_0_TO_1(a) ((0 == (a)) ? 1 : (a)) #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 DIV_0_TO_1_FLOAT(a) ((((a) < 1E-10) && ((a) > -1E-10)) ? 1 : (a))
#define GC2093_ID 2093 #define GC2093_ID 2093
#define GC2093_I2C_ADDR_1 0x7e
#define GC2093_I2C_ADDR_2 0x37
#define GC2093_I2C_ADDR_IS_VALID(addr) ((addr) == GC2093_I2C_ADDR_1 || (addr) == GC2093_I2C_ADDR_2)
/**************************************************************************** /****************************************************************************
* global variables * * global variables *
***************************************************************************/ ***************************************************************************/
@ -1040,6 +1044,11 @@ static CVI_S32 cmos_init_sensor_exp_function(ISP_SENSOR_EXP_FUNC_S *pstSensorExp
/**************************************************************************** /****************************************************************************
* callback structure * * callback structure *
****************************************************************************/ ****************************************************************************/
static CVI_VOID sensor_patch_i2c_addr(CVI_S32 s32I2cAddr)
{
if (GC2093_I2C_ADDR_IS_VALID(s32I2cAddr))
gc2093_i2c_addr = s32I2cAddr;
}
static CVI_S32 gc2093_set_bus_info(VI_PIPE ViPipe, ISP_SNS_COMMBUS_U unSNSBusInfo) static CVI_S32 gc2093_set_bus_info(VI_PIPE ViPipe, ISP_SNS_COMMBUS_U unSNSBusInfo)
{ {
@ -1185,6 +1194,7 @@ ISP_SNS_OBJ_S stSnsGc2093_Obj = {
.pfnSetInit = sensor_set_init, .pfnSetInit = sensor_set_init,
.pfnMirrorFlip = sensor_mirror_flip, .pfnMirrorFlip = sensor_mirror_flip,
.pfnPatchRxAttr = sensor_patch_rx_attr, .pfnPatchRxAttr = sensor_patch_rx_attr,
.pfnPatchI2cAddr = sensor_patch_i2c_addr,
.pfnGetRxAttr = sensor_rx_attr, .pfnGetRxAttr = sensor_rx_attr,
.pfnExpSensorCb = cmos_init_sensor_exp_function, .pfnExpSensorCb = cmos_init_sensor_exp_function,
.pfnExpAeCb = cmos_init_ae_exp_function, .pfnExpAeCb = cmos_init_ae_exp_function,

View File

@ -93,7 +93,7 @@ typedef struct _GC2093_MODE_S {
extern ISP_SNS_STATE_S *g_pastGc2093[VI_MAX_PIPE_NUM]; extern ISP_SNS_STATE_S *g_pastGc2093[VI_MAX_PIPE_NUM];
extern ISP_SNS_COMMBUS_U g_aunGc2093_BusInfo[]; extern ISP_SNS_COMMBUS_U g_aunGc2093_BusInfo[];
extern ISP_SNS_MIRRORFLIP_TYPE_E g_aeGc2093_MirrorFip[VI_MAX_PIPE_NUM]; extern ISP_SNS_MIRRORFLIP_TYPE_E g_aeGc2093_MirrorFip[VI_MAX_PIPE_NUM];
extern const CVI_U8 gc2093_i2c_addr; extern CVI_U8 gc2093_i2c_addr;
extern const CVI_U32 gc2093_addr_byte; extern const CVI_U32 gc2093_addr_byte;
extern const CVI_U32 gc2093_data_byte; extern const CVI_U32 gc2093_data_byte;
extern void gc2093_init(VI_PIPE ViPipe); extern void gc2093_init(VI_PIPE ViPipe);

View File

@ -20,7 +20,7 @@
static void gc2093_linear_1080p30_init(VI_PIPE ViPipe); static void gc2093_linear_1080p30_init(VI_PIPE ViPipe);
static void gc2093_wdr_1080p30_init(VI_PIPE ViPipe); static void gc2093_wdr_1080p30_init(VI_PIPE ViPipe);
const CVI_U8 gc2093_i2c_addr = 0x37;//0x6e CVI_U8 gc2093_i2c_addr = 0x37;//0x6e
const CVI_U32 gc2093_addr_byte = 2; const CVI_U32 gc2093_addr_byte = 2;
const CVI_U32 gc2093_data_byte = 1; const CVI_U32 gc2093_data_byte = 1;
static int g_fd[VI_MAX_PIPE_NUM] = {[0 ... (VI_MAX_PIPE_NUM - 1)] = -1}; static int g_fd[VI_MAX_PIPE_NUM] = {[0 ... (VI_MAX_PIPE_NUM - 1)] = -1};

View File

@ -0,0 +1,36 @@
SHELL = /bin/bash
ifeq ($(PARAM_FILE), )
PARAM_FILE=../../../../../../$(shell echo $(MW_VER))/Makefile.param
include $(PARAM_FILE)
endif
SDIR = $(PWD)
SRCS = $(wildcard $(SDIR)/*.c)
INCS = -I$(MW_INC) -I$(ISP_INC) -I$(KERNEL_INC) -I./include
OBJS = $(SRCS:.c=.o)
DEPS = $(SRCS:.c=.d)
TARGET_A = $(MW_LIB)/libsns_mis2008.a
TARGET_SO = $(MW_LIB)/libsns_mis2008.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)

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,79 @@
#ifndef __MIS2008_CMOS_EX_H_
#define __MIS2008_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"
enum mis2008_linear_regs_e {
LINEAR_SHS1_0_ADDR,
LINEAR_SHS1_1_ADDR,
LINEAR_SHS1_2_ADDR,
LINEAR_AGAIN_ADDR,
LINEAR_DGAIN_ADDR,
LINEAR_D_FINEGAIN_ADDR,
LINEAR_VMAX_0_ADDR,
LINEAR_VMAX_1_ADDR,
LINEAR_FLIP_MIRROR_ADDR,
LINEAR_REGS_NUM
};
typedef enum _MIS2008_MODE_E {
MIS2008_MODE_1080P30 = 0,
MIS2008_MODE_NUM
} MIS2008_MODE_E;
typedef struct _MIS2008_MODE_S {
ISP_WDR_SIZE_S astImg[2];
CVI_FLOAT f32MaxFps;
CVI_FLOAT f32MinFps;
CVI_U32 u32HtsDef;
CVI_U32 u32VtsDef;
SNS_ATTR_LARGE_S stExp[2];
SNS_ATTR_LARGE_S stAgain[2];
SNS_ATTR_LARGE_S stDgain[2];
char name[64];
} MIS2008_MODE_S;
/****************************************************************************
* external variables and functions *
****************************************************************************/
extern ISP_SNS_STATE_S *g_pastMIS2008[VI_MAX_PIPE_NUM];
extern ISP_SNS_COMMBUS_U g_aunMIS2008_BusInfo[];
extern CVI_U16 g_au16MIS2008_GainMode[];
extern CVI_U16 g_au16MIS2008_L2SMode[];
extern CVI_U8 mis2008_i2c_addr;
extern const CVI_U32 mis2008_addr_byte;
extern const CVI_U32 mis2008_data_byte;
extern void mis2008_init(VI_PIPE ViPipe);
extern void mis2008_exit(VI_PIPE ViPipe);
extern void mis2008_standby(VI_PIPE ViPipe);
extern void mis2008_restart(VI_PIPE ViPipe);
extern int mis2008_write_register(VI_PIPE ViPipe, int addr, int data);
extern int mis2008_read_register(VI_PIPE ViPipe, int addr);
extern void mis2008_mirror_flip(VI_PIPE ViPipe, ISP_SNS_MIRRORFLIP_TYPE_E eSnsMirrorFlip);
extern int mis2008_probe(VI_PIPE ViPipe);
#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif /* End of #ifdef __cplusplus */
#endif /* __MIS2008_CMOS_EX_H_ */

View File

@ -0,0 +1,126 @@
#ifndef __MIS2008_CMOS_PARAM_H_
#define __MIS2008_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 "mis2008_cmos_ex.h"
static const MIS2008_MODE_S g_astMIS2008_mode[MIS2008_MODE_NUM] = {
[MIS2008_MODE_1080P30] = {
.name = "1080p30",
.astImg[0] = {
.stSnsSize = {
.u32Width = 1928,
.u32Height = 1088,
},
.stWndRect = {
.s32X = 8,
.s32Y = 8,
.u32Width = 1920,
.u32Height = 1080,
},
.stMaxSize = {
.u32Width = 1928,
.u32Height = 1088,
},
},
.f32MaxFps = 30,
.f32MinFps = 1, /* 1500 * 30 / 0x7FFF*/
.u32HtsDef = 2200,
.u32VtsDef = 1125,
.stExp[0] = {//exp_time
.u32Min = 1,
.u32Max = 1125 - 1, //exp_max
.u32Def = 128,
.u32Step = 1,
},
.stAgain[0] = {
.u32Min = 1024,
.u32Max = 16128,
.u32Def = 1024,
.u32Step = 1,
},
.stDgain[0] = {
.u32Min = 1024,
.u32Max = 16320,
.u32Def = 1024,
.u32Step = 1,
},
},
};
static ISP_CMOS_BLACK_LEVEL_S g_stIspBlcCalibratio = {
.bUpdate = CVI_TRUE,
.blcAttr = {
.Enable = 1,
.enOpType = OP_TYPE_AUTO,
.stManual = {64, 64, 64, 64, 0, 0, 0, 0
#ifdef ARCH_CV182X
, 1040, 1040, 1040, 1040
#endif
},
.stAuto = {
{64, 64, 64, 64, 64, 64, 64, 64, /*8*/64, 64, 64, 64, 64, 64, 64, 64},
{64, 64, 64, 64, 64, 64, 64, 64, /*8*/64, 64, 64, 64, 64, 64, 64, 64},
{64, 64, 64, 64, 64, 64, 64, 64, /*8*/64, 64, 64, 64, 64, 64, 64, 64},
{64, 64, 64, 64, 64, 64, 64, 64, /*8*/64, 64, 64, 64, 64, 64, 64, 64},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
#ifdef ARCH_CV182X
{1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040,
/*8*/1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040},
{1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040,
/*8*/1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040},
{1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040,
/*8*/1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040},
{1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040,
/*8*/1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040},
#endif
},
},
};
struct combo_dev_attr_s mis2008_rx_attr = {
.input_mode = INPUT_MODE_MIPI,
.mac_clk = RX_MAC_CLK_200M,
.mipi_attr = {
.raw_data_type = RAW_DATA_12BIT,
.lane_id = {2, 0, 1, -1, -1},
.pn_swap = {1, 1, 1, 0, 0},
.wdr_mode = CVI_MIPI_WDR_MODE_NONE,
.dphy = {
.enable = 1,
.hs_settle = 8,
},
},
.mclk = {
.cam = 1,
.freq = CAMPLL_FREQ_27M,
},
.devno = 0,
};
#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif /* End of #ifdef __cplusplus */
#endif /* __MIS2008_CMOS_PARAM_H_ */

View File

@ -0,0 +1,397 @@
#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 "mis2008_cmos_ex.h"
static void mis2008_linear_1080p30_init(VI_PIPE ViPipe);
CVI_U8 mis2008_i2c_addr = 0x30; /* I2C Address of MIS2008 */
const CVI_U32 mis2008_addr_byte = 2;
const CVI_U32 mis2008_data_byte = 1;
static int g_fd[VI_MAX_PIPE_NUM] = {[0 ... (VI_MAX_PIPE_NUM - 1)] = -1};
int mis2008_i2c_init(VI_PIPE ViPipe)
{
char acDevFile[16] = {0};
CVI_U8 u8DevNum;
if (g_fd[ViPipe] >= 0)
return CVI_SUCCESS;
int ret;
u8DevNum = g_aunMIS2008_BusInfo[ViPipe].s8I2cDev;
snprintf(acDevFile, sizeof(acDevFile), "/dev/i2c-%u", u8DevNum);
g_fd[ViPipe] = open(acDevFile, O_RDWR, 0600);
if (g_fd[ViPipe] < 0) {
CVI_TRACE_SNS(CVI_DBG_ERR, "Open /dev/cvi_i2c_drv-%u error!\n", u8DevNum);
return CVI_FAILURE;
}
ret = ioctl(g_fd[ViPipe], I2C_SLAVE_FORCE, mis2008_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 mis2008_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 mis2008_read_register(VI_PIPE ViPipe, int addr)
{
int ret, data;
CVI_U8 buf[8];
CVI_U8 idx = 0;
if (g_fd[ViPipe] < 0)
return CVI_FAILURE;
if (mis2008_addr_byte == 2)
buf[idx++] = (addr >> 8) & 0xff;
// add address byte 0
buf[idx++] = addr & 0xff;
ret = write(g_fd[ViPipe], buf, mis2008_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, mis2008_data_byte);
if (ret < 0) {
CVI_TRACE_SNS(CVI_DBG_ERR, "I2C_READ error!\n");
return ret;
}
// pack read back data
data = 0;
if (mis2008_data_byte == 2) {
data = buf[0] << 8;
data += buf[1];
} else {
data = buf[0];
}
syslog(LOG_DEBUG, "i2c r 0x%x = 0x%x\n", addr, data);
return data;
}
int mis2008_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 (mis2008_addr_byte == 2) {
buf[idx] = (addr >> 8) & 0xff;
idx++;
buf[idx] = addr & 0xff;
idx++;
}
if (mis2008_data_byte == 1) {
buf[idx] = data & 0xff;
idx++;
}
ret = write(g_fd[ViPipe], buf, mis2008_addr_byte + mis2008_data_byte);
if (ret < 0) {
CVI_TRACE_SNS(CVI_DBG_ERR, "I2C_WRITE error!\n");
return CVI_FAILURE;
}
syslog(LOG_DEBUG, "i2c w 0x%x 0x%x\n", addr, data);
return CVI_SUCCESS;
}
static void delay_ms(int ms)
{
usleep(ms * 1000);
}
void mis2008_standby(VI_PIPE ViPipe)
{
mis2008_write_register(ViPipe, 0x3006, 0x02);
}
void mis2008_restart(VI_PIPE ViPipe)
{
mis2008_write_register(ViPipe, 0x3006, 0x01);
}
void mis2008_default_reg_init(VI_PIPE ViPipe)
{
CVI_U32 i;
for (i = 0; i < g_pastMIS2008[ViPipe]->astSyncInfo[0].snsCfg.u32RegNum; i++) {
mis2008_write_register(ViPipe,
g_pastMIS2008[ViPipe]->astSyncInfo[0].snsCfg.astI2cData[i].u32RegAddr,
g_pastMIS2008[ViPipe]->astSyncInfo[0].snsCfg.astI2cData[i].u32Data);
}
}
#define MIS2008_CHIP_ID_HI_ADDR 0x3000
#define MIS2008_CHIP_ID_LO_ADDR 0x3001
#define MIS2008_CHIP_ID 0x2008
int mis2008_probe(VI_PIPE ViPipe)
{
int nVal;
CVI_U16 chip_id;
if (mis2008_i2c_init(ViPipe) != CVI_SUCCESS)
return CVI_FAILURE;
delay_ms(5);
nVal = mis2008_read_register(ViPipe, MIS2008_CHIP_ID_HI_ADDR);
if (nVal < 0) {
CVI_TRACE_SNS(CVI_DBG_ERR, "read sensor id error.\n");
return nVal;
}
chip_id = (nVal & 0xFF) << 8;
nVal = mis2008_read_register(ViPipe, MIS2008_CHIP_ID_LO_ADDR);
if (nVal < 0) {
CVI_TRACE_SNS(CVI_DBG_ERR, "read sensor id error.\n");
return nVal;
}
chip_id |= (nVal & 0xFF);
if (chip_id != MIS2008_CHIP_ID) {
CVI_TRACE_SNS(CVI_DBG_ERR, "Sensor ID Mismatch! Use the wrong sensor??\n");
return CVI_FAILURE;
}
return CVI_SUCCESS;
}
void mis2008_init(VI_PIPE ViPipe)
{
mis2008_i2c_init(ViPipe);
mis2008_linear_1080p30_init(ViPipe);
g_pastMIS2008[ViPipe]->bInit = CVI_TRUE;
}
void mis2008_exit(VI_PIPE ViPipe)
{
mis2008_i2c_exit(ViPipe);
}
/* 1080p30 */
static void mis2008_linear_1080p30_init(VI_PIPE ViPipe)
{
/* [ParaList] */
mis2008_write_register(ViPipe, 0x300a ,0x01);
mis2008_write_register(ViPipe, 0x3006 ,0x02);
mis2008_write_register(ViPipe, 0x3201 ,0x65);
mis2008_write_register(ViPipe, 0x3200 ,0x04);
mis2008_write_register(ViPipe, 0x3203 ,0x98);
mis2008_write_register(ViPipe, 0x3202 ,0x08);
mis2008_write_register(ViPipe, 0x3205 ,0x04);
mis2008_write_register(ViPipe, 0x3204 ,0x00);
mis2008_write_register(ViPipe, 0x3207 ,0x43);
mis2008_write_register(ViPipe, 0x3206 ,0x04);
mis2008_write_register(ViPipe, 0x3209 ,0x04);
mis2008_write_register(ViPipe, 0x3208 ,0x00);
mis2008_write_register(ViPipe, 0x320b ,0x8b);
mis2008_write_register(ViPipe, 0x320a ,0x07);
//mis2008_write_register(ViPipe, 0x3007 ,0x00);
mis2008_write_register(ViPipe, 0x3007 ,0x00);
mis2008_write_register(ViPipe, 0x3300 ,0x21);
mis2008_write_register(ViPipe, 0x3301 ,0x00);
mis2008_write_register(ViPipe, 0x3302 ,0x02);
mis2008_write_register(ViPipe, 0x3303 ,0x06);
mis2008_write_register(ViPipe, 0x330d ,0x00);
mis2008_write_register(ViPipe, 0x330b ,0x01);
mis2008_write_register(ViPipe, 0x330f ,0x0f);
mis2008_write_register(ViPipe, 0x3013 ,0x00);
mis2008_write_register(ViPipe, 0x3637 ,0x1e);
mis2008_write_register(ViPipe, 0x3900 ,0x07);
mis2008_write_register(ViPipe, 0x2107 ,0x00);
mis2008_write_register(ViPipe, 0x330e ,0x00);
mis2008_write_register(ViPipe, 0x3900 ,0x07);
mis2008_write_register(ViPipe, 0x2108 ,0x01);
mis2008_write_register(ViPipe, 0x3c40 ,0x8c);
mis2008_write_register(ViPipe, 0x3b01 ,0x3f);
mis2008_write_register(ViPipe, 0x3b03 ,0x3f);
mis2008_write_register(ViPipe, 0x3902 ,0x01);
mis2008_write_register(ViPipe, 0x3904 ,0x00);
mis2008_write_register(ViPipe, 0x3903 ,0x00);
mis2008_write_register(ViPipe, 0x3906 ,0x1e);
mis2008_write_register(ViPipe, 0x3905 ,0x00);
mis2008_write_register(ViPipe, 0x3908 ,0x71);
mis2008_write_register(ViPipe, 0x3907 ,0x10);
mis2008_write_register(ViPipe, 0x390a ,0xff);
mis2008_write_register(ViPipe, 0x3909 ,0x1f);
mis2008_write_register(ViPipe, 0x390c ,0x67);
mis2008_write_register(ViPipe, 0x390b ,0x03);
mis2008_write_register(ViPipe, 0x390e ,0x77);
mis2008_write_register(ViPipe, 0x390d ,0x00);
mis2008_write_register(ViPipe, 0x3910 ,0x71);
mis2008_write_register(ViPipe, 0x390f ,0x10);
mis2008_write_register(ViPipe, 0x3912 ,0xff);
mis2008_write_register(ViPipe, 0x3911 ,0x1f);
mis2008_write_register(ViPipe, 0x3919 ,0x00);
mis2008_write_register(ViPipe, 0x3918 ,0x00);
mis2008_write_register(ViPipe, 0x391b ,0x91);
mis2008_write_register(ViPipe, 0x391a ,0x01);
mis2008_write_register(ViPipe, 0x3983 ,0x5a);
mis2008_write_register(ViPipe, 0x3982 ,0x00);
mis2008_write_register(ViPipe, 0x3985 ,0x0f);
mis2008_write_register(ViPipe, 0x3984 ,0x00);
mis2008_write_register(ViPipe, 0x391d ,0x00);
mis2008_write_register(ViPipe, 0x391c ,0x00);
mis2008_write_register(ViPipe, 0x391f ,0x65);
mis2008_write_register(ViPipe, 0x391e ,0x10);
mis2008_write_register(ViPipe, 0x3921 ,0xff);
mis2008_write_register(ViPipe, 0x3920 ,0x1f);
mis2008_write_register(ViPipe, 0x3923 ,0xff);
mis2008_write_register(ViPipe, 0x3922 ,0x1f);
mis2008_write_register(ViPipe, 0x3932 ,0x00);
mis2008_write_register(ViPipe, 0x3931 ,0x00);
mis2008_write_register(ViPipe, 0x3934 ,0x65);
mis2008_write_register(ViPipe, 0x3933 ,0x01);
mis2008_write_register(ViPipe, 0x393f ,0x6c);
mis2008_write_register(ViPipe, 0x393e ,0x00);
mis2008_write_register(ViPipe, 0x3941 ,0x67);
mis2008_write_register(ViPipe, 0x3940 ,0x00);
mis2008_write_register(ViPipe, 0x3943 ,0x55);
mis2008_write_register(ViPipe, 0x3942 ,0x01);
mis2008_write_register(ViPipe, 0x3945 ,0xc2);
mis2008_write_register(ViPipe, 0x3944 ,0x02);
mis2008_write_register(ViPipe, 0x3925 ,0x95);
mis2008_write_register(ViPipe, 0x3924 ,0x00);
mis2008_write_register(ViPipe, 0x3927 ,0xe1);
mis2008_write_register(ViPipe, 0x3926 ,0x02);
mis2008_write_register(ViPipe, 0x3947 ,0x74);
mis2008_write_register(ViPipe, 0x3946 ,0x01);
mis2008_write_register(ViPipe, 0x3949 ,0xda);
mis2008_write_register(ViPipe, 0x3948 ,0x0e);
mis2008_write_register(ViPipe, 0x394b ,0x42);
mis2008_write_register(ViPipe, 0x394a ,0x03);
mis2008_write_register(ViPipe, 0x394d ,0xf2);
mis2008_write_register(ViPipe, 0x394c ,0x01);
mis2008_write_register(ViPipe, 0x3913 ,0x01);
mis2008_write_register(ViPipe, 0x3915 ,0x0f);
mis2008_write_register(ViPipe, 0x3914 ,0x00);
mis2008_write_register(ViPipe, 0x3917 ,0x67);
mis2008_write_register(ViPipe, 0x3916 ,0x03);
mis2008_write_register(ViPipe, 0x392a ,0x1e);
mis2008_write_register(ViPipe, 0x3929 ,0x00);
mis2008_write_register(ViPipe, 0x392c ,0x0f);
mis2008_write_register(ViPipe, 0x392b ,0x00);
mis2008_write_register(ViPipe, 0x392e ,0x0f);
mis2008_write_register(ViPipe, 0x392d ,0x00);
mis2008_write_register(ViPipe, 0x3930 ,0x6e);
mis2008_write_register(ViPipe, 0x392f ,0x03);
mis2008_write_register(ViPipe, 0x397f ,0x00);
mis2008_write_register(ViPipe, 0x397e ,0x00);
mis2008_write_register(ViPipe, 0x3981 ,0x77);
mis2008_write_register(ViPipe, 0x3980 ,0x00);
mis2008_write_register(ViPipe, 0x395d ,0x80);
mis2008_write_register(ViPipe, 0x395c ,0x10);
mis2008_write_register(ViPipe, 0x3962 ,0x9e);
mis2008_write_register(ViPipe, 0x3961 ,0x10);
mis2008_write_register(ViPipe, 0x3977 ,0x22);
mis2008_write_register(ViPipe, 0x3976 ,0x00);
mis2008_write_register(ViPipe, 0x3978 ,0x00);
mis2008_write_register(ViPipe, 0x3979 ,0x04);
mis2008_write_register(ViPipe, 0x396d ,0xc2);
mis2008_write_register(ViPipe, 0x396c ,0x02);
mis2008_write_register(ViPipe, 0x396f ,0xc2);
mis2008_write_register(ViPipe, 0x396e ,0x02);
mis2008_write_register(ViPipe, 0x3971 ,0xc2);
mis2008_write_register(ViPipe, 0x3970 ,0x02);
mis2008_write_register(ViPipe, 0x3973 ,0xc2);
mis2008_write_register(ViPipe, 0x3972 ,0x02);
mis2008_write_register(ViPipe, 0x3900 ,0x01);
mis2008_write_register(ViPipe, 0x3600 ,0x00);
mis2008_write_register(ViPipe, 0x3707 ,0x00);
mis2008_write_register(ViPipe, 0x3708 ,0x80);
mis2008_write_register(ViPipe, 0x3709 ,0x00);
mis2008_write_register(ViPipe, 0x370a ,0x80);
mis2008_write_register(ViPipe, 0x370b ,0x00);
mis2008_write_register(ViPipe, 0x370c ,0x80);
mis2008_write_register(ViPipe, 0x370d ,0x00);
mis2008_write_register(ViPipe, 0x370e ,0x80);
mis2008_write_register(ViPipe, 0x3006 ,0x00);
mis2008_write_register(ViPipe, 0x3012 ,0x01);
mis2008_write_register(ViPipe, 0x3600 ,0x13);
mis2008_write_register(ViPipe, 0x3601 ,0x02);
mis2008_write_register(ViPipe, 0x360e ,0x00);
mis2008_write_register(ViPipe, 0x360f ,0x00);
mis2008_write_register(ViPipe, 0x3610 ,0x02);
mis2008_write_register(ViPipe, 0x3707 ,0x00);
mis2008_write_register(ViPipe, 0x3708 ,0x40);
mis2008_write_register(ViPipe, 0x3709 ,0x00);
mis2008_write_register(ViPipe, 0x370a ,0x40);
mis2008_write_register(ViPipe, 0x370b ,0x00);
mis2008_write_register(ViPipe, 0x370c ,0x40);
mis2008_write_register(ViPipe, 0x370d ,0x00);
mis2008_write_register(ViPipe, 0x370e ,0x40);
mis2008_write_register(ViPipe, 0x3800 ,0x01);
mis2008_write_register(ViPipe, 0x3a03 ,0x03);
mis2008_write_register(ViPipe, 0x3a02 ,0x0b);
mis2008_write_register(ViPipe, 0x3a08 ,0x34);
mis2008_write_register(ViPipe, 0x3a1b ,0x54);
mis2008_write_register(ViPipe, 0x3a1e ,0x80);
mis2008_write_register(ViPipe, 0x3100 ,0x04);
mis2008_write_register(ViPipe, 0x3101 ,0x64);
mis2008_write_register(ViPipe, 0x3a1c ,0x10);
mis2008_write_register(ViPipe, 0x3a0C ,0x04);
mis2008_write_register(ViPipe, 0x3a0D ,0x12);
mis2008_write_register(ViPipe, 0x3a0E ,0x15);
mis2008_write_register(ViPipe, 0x3a0F ,0x18);
mis2008_write_register(ViPipe, 0x3a10 ,0x20);
mis2008_write_register(ViPipe, 0x3a11 ,0x3c);
mis2008_default_reg_init(ViPipe);
delay_ms(100);
printf("ViPipe:%d,===MIS2008 1080P 30fps 12bit LINE Init OK!===\n", ViPipe);
}

View File

@ -0,0 +1,36 @@
SHELL = /bin/bash
ifeq ($(PARAM_FILE), )
PARAM_FILE=../../../../../../$(shell echo $(MW_VER))/Makefile.param
include $(PARAM_FILE)
endif
SDIR = $(PWD)
SRCS = $(wildcard $(SDIR)/*.c)
INCS = -I$(MW_INC) -I$(ISP_INC) -I$(KERNEL_INC) -I./include
OBJS = $(SRCS:.c=.o)
DEPS = $(SRCS:.c=.d)
TARGET_A = $(MW_LIB)/libsns_tp2863.a
TARGET_SO = $(MW_LIB)/libsns_tp2863.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_SO): $(OBJS)
@$(LD) $(LDFLAGS) $(EXTRA_LDFLAGS) -o $@ --start-group $(OBJS) --end-group
@echo -e $(GREEN)[LINK]$(END)[$(notdir $(LD))] $(notdir $@)
clean:
@rm -f $(OBJS) $(DEPS) $(TARGET_A) $(TARGET_SO)
-include $(DEPS)

View File

@ -0,0 +1,336 @@
#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 "tp2863_cmos_ex.h"
#include "tp2863_cmos_param.h"
/****************************************************************************
* global variables *
****************************************************************************/
ISP_SNS_COMMBUS_U g_aunTP2863_BusInfo[VI_MAX_PIPE_NUM] = {
[0] = {.s8I2cDev = 0},
[1 ... VI_MAX_PIPE_NUM - 1] = {.s8I2cDev = -1}};
ISP_SNS_STATE_S *g_pastTP2863[VI_MAX_PIPE_NUM] = {CVI_NULL};
#define TP2863_SENSOR_GET_CTX(dev, pstCtx) (pstCtx = g_pastTP2863[dev])
#define TP2863_SENSOR_SET_CTX(dev, pstCtx) (g_pastTP2863[dev] = pstCtx)
#define TP2863_SENSOR_RESET_CTX(dev) (g_pastTP2863[dev] = CVI_NULL)
#define TP2863_RES_IS_720P_25(w, h, f) ((w) == 1280 && (h) == 720 && (f) == 25)
#define TP2863_RES_IS_720P_30(w, h, f) ((w) == 1280 && (h) == 720 && (f) == 30)
#define TP2863_RES_IS_1080P_25(w, h, f) ((w) == 1920 && (h) == 1080 && (f) == 25)
#define TP2863_RES_IS_1080P_30(w, h, f) ((w) == 1920 && (h) == 1080 && (f) == 30)
#define TP2863_ID 0x2863
/****************************************************************************
* local variables and functions *
****************************************************************************/
static CVI_S32 cmos_get_wdr_size(VI_PIPE ViPipe, ISP_SNS_ISP_INFO_S *pstIspCfg)
{
const TP2863_MODE_S *pstMode = CVI_NULL;
ISP_SNS_STATE_S *pstSnsState = CVI_NULL;
TP2863_SENSOR_GET_CTX(ViPipe, pstSnsState);
CMOS_CHECK_POINTER(pstSnsState);
pstMode = &g_astTP2863_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);
TP2863_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);
TP2863_SENSOR_GET_CTX(ViPipe, pstSnsState);
CMOS_CHECK_POINTER(pstSnsState);
u8SensorImageMode = pstSnsState->u8ImgMode;
if (pstSensorImageMode->f32Fps <= 30)
{
if (pstSnsState->enWDRMode == WDR_MODE_NONE) {
if (TP2863_RES_IS_720P_25(pstSensorImageMode->u16Width,
pstSensorImageMode->u16Height,
pstSensorImageMode->f32Fps)) {
u8SensorImageMode = TP2863_MODE_720P_25P;
} else if (TP2863_RES_IS_720P_30(pstSensorImageMode->u16Width,
pstSensorImageMode->u16Height,
pstSensorImageMode->f32Fps)) {
u8SensorImageMode = TP2863_MODE_720P_30P;
} else if (TP2863_RES_IS_1080P_25(pstSensorImageMode->u16Width,
pstSensorImageMode->u16Height,
pstSensorImageMode->f32Fps)) {
u8SensorImageMode = TP2863_MODE_1080P_25P;
} else if (TP2863_RES_IS_1080P_30(pstSensorImageMode->u16Width,
pstSensorImageMode->u16Height,
pstSensorImageMode->f32Fps)) {
u8SensorImageMode = TP2863_MODE_1080P_30P;
} 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;
}
}
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;
}
}
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;
TP2863_SENSOR_GET_CTX(ViPipe, pstSnsState);
CMOS_CHECK_POINTER_VOID(pstSnsState);
pstSnsState->bInit = CVI_FALSE;
pstSnsState->u8ImgMode = TP2863_MODE_1080P_25P;
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;
TP2863_SENSOR_GET_CTX(ViPipe, pstSnsState);
CMOS_CHECK_POINTER(pstSnsState);
CMOS_CHECK_POINTER(pstRxAttr);
memcpy(pstRxAttr, &tp2863_rx_attr, sizeof(*pstRxAttr));
// CVI_TRACE_SNS(CVI_DBG_INFO, "get tp2863_rx0_attr\n");
pstRxAttr->img_size.width = g_astTP2863_mode[pstSnsState->u8ImgMode].astImg[0].stSnsSize.u32Width;
pstRxAttr->img_size.height = g_astTP2863_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 = &tp2863_rx_attr;
int i;
CMOS_CHECK_POINTER(pstRxInitAttr);
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 = tp2863_init;
pstSensorExpFunc->pfn_cmos_sensor_exit = tp2863_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 tp2863_set_bus_info(VI_PIPE ViPipe, ISP_SNS_COMMBUS_U unSNSBusInfo)
{
g_aunTP2863_BusInfo[ViPipe].s8I2cDev = unSNSBusInfo.s8I2cDev;
return CVI_SUCCESS;
}
static CVI_S32 sensor_ctx_init(VI_PIPE ViPipe)
{
ISP_SNS_STATE_S *pastSnsStateCtx = CVI_NULL;
TP2863_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));
TP2863_SENSOR_SET_CTX(ViPipe, pastSnsStateCtx);
return CVI_SUCCESS;
}
static CVI_VOID sensor_ctx_exit(VI_PIPE ViPipe)
{
ISP_SNS_STATE_S *pastSnsStateCtx = CVI_NULL;
TP2863_SENSOR_GET_CTX(ViPipe, pastSnsStateCtx);
SENSOR_FREE(pastSnsStateCtx);
TP2863_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 = TP2863_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, TP2863_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;
}
ISP_SNS_OBJ_S stSnsTP2863_Obj = {
.pfnRegisterCallback = sensor_register_callback,
.pfnUnRegisterCallback = sensor_unregister_callback,
.pfnMirrorFlip = CVI_NULL,
.pfnStandby = CVI_NULL,
.pfnRestart = CVI_NULL,
.pfnWriteReg = tp2863_write_register,
.pfnReadReg = tp2863_read_register,
.pfnSetBusInfo = tp2863_set_bus_info,
.pfnSetInit = CVI_NULL,
.pfnPatchRxAttr = sensor_patch_rx_attr,
.pfnPatchI2cAddr = CVI_NULL,
.pfnGetRxAttr = sensor_rx_attr,
.pfnExpSensorCb = cmos_init_sensor_exp_function,
.pfnExpAeCb = CVI_NULL,
.pfnSnsProbe = CVI_NULL,
};

View File

@ -0,0 +1,63 @@
#ifndef __TP2863_CMOS_EX_H_
#define __TP2863_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 _TP2863_MODE_E
{
TP2863_MODE_1080P_30P,
TP2863_MODE_1080P_25P,
TP2863_MODE_720P_30P,
TP2863_MODE_720P_25P,
TP2863_MODE_NUM
} TP2863_MODE_E;
typedef struct _TP2863_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];
} TP2863_MODE_S;
/****************************************************************************
* external variables and functions *
****************************************************************************/
extern ISP_SNS_STATE_S *g_pastTP2863[VI_MAX_PIPE_NUM];
extern ISP_SNS_COMMBUS_U g_aunTP2863_BusInfo[];
extern const CVI_U8 tp2863_i2c_addr;
extern const CVI_U32 tp2863_addr_byte;
extern const CVI_U32 tp2863_data_byte;
extern void tp2863_init(VI_PIPE ViPipe);
extern void tp2863_exit(VI_PIPE ViPipe);
extern void tp2863_standby(VI_PIPE ViPipe);
extern void tp2863_restart(VI_PIPE ViPipe);
extern int tp2863_write_register(VI_PIPE ViPipe, int addr, int data);
extern int tp2863_read_register(VI_PIPE ViPipe, int addr);
#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif /* End of #ifdef __cplusplus */
#endif /* __TP2863_CMOS_EX_H_ */

View File

@ -0,0 +1,123 @@
#ifndef __TP2863_CMOS_PARAM_H_
#define __TP2863_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 "tp2863_cmos_ex.h"
static const TP2863_MODE_S g_astTP2863_mode[TP2863_MODE_NUM] = {
[TP2863_MODE_1080P_30P] = {
.name = "1080p30",
.astImg[0] = {
.stSnsSize = {
.u32Width = 1920,
.u32Height = 1080,
},
.stWndRect = {
.s32X = 0,
.s32Y = 0,
.u32Width = 1920,
.u32Height = 1080,
},
.stMaxSize = {
.u32Width = 1920,
.u32Height = 1080,
},
},
},
[TP2863_MODE_1080P_25P] = {
.name = "1080p25",
.astImg[0] = {
.stSnsSize = {
.u32Width = 1920,
.u32Height = 1080,
},
.stWndRect = {
.s32X = 0,
.s32Y = 0,
.u32Width = 1920,
.u32Height = 1080,
},
.stMaxSize = {
.u32Width = 1920,
.u32Height = 1080,
},
},
},
[TP2863_MODE_720P_30P] = {
.name = "720p30",
.astImg[0] = {
.stSnsSize = {
.u32Width = 1280,
.u32Height = 720,
},
.stWndRect = {
.s32X = 0,
.s32Y = 0,
.u32Width = 1280,
.u32Height = 720,
},
.stMaxSize = {
.u32Width = 1280,
.u32Height = 720,
},
},
},
[TP2863_MODE_720P_25P] = {
.name = "720p25",
.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 tp2863_rx_attr = {
.input_mode = INPUT_MODE_MIPI,
.mac_clk = RX_MAC_CLK_400M,
.mipi_attr = {
.raw_data_type = YUV422_8BIT,
.lane_id = {0, 2, 1, -1, -1},
.wdr_mode = CVI_MIPI_WDR_MODE_NONE,
},
.mclk = {
.cam = 0,
.freq = CAMPLL_FREQ_NONE,
},
.devno = 0,
};
#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif /* End of #ifdef __cplusplus */
#endif /* __TP2863_CMOS_PARAM_H_ */

View File

@ -0,0 +1,593 @@
#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 "tp2863_cmos_ex.h"
const CVI_U8 tp2863_i2c_addr = 0x44; /* I2C slave address of TP2863, SA0=0:0x44, SA0=1:0x45*/
const CVI_U32 tp2863_addr_byte = 1;
const CVI_U32 tp2863_data_byte = 1;
static int g_fd[VI_MAX_PIPE_NUM] = {[0 ...(VI_MAX_PIPE_NUM - 1)] = -1};
#define TP2863_BLUE_SCREEN 0
enum
{
CH_1 = 0,
CH_2 = 1,
CH_ALL = 4,
MIPI_PAGE = 8,
};
enum
{
STD_TVI, // TVI
STD_HDA, // AHD
};
enum
{
HD25,
HD30, // 1280x720
FHD25,
FHD30, // 1920x1080
};
enum
{
MIPI_1CH2LANE_297M,
MIPI_1CH2LANE_594M,
MIPI_2CH2LANE_594M,
MIPI_2CH2LANE_297M,
};
int tp2863_i2c_init(VI_PIPE ViPipe)
{
char acDevFile[16] = {0};
CVI_U8 u8DevNum;
int ret;
if (g_fd[ViPipe] >= 0)
return CVI_SUCCESS;
u8DevNum = g_aunTP2863_BusInfo[ViPipe].s8I2cDev;
snprintf(acDevFile, sizeof(acDevFile), "/dev/i2c-%u", u8DevNum);
syslog(LOG_DEBUG, "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, tp2863_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 tp2863_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 tp2863_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 (tp2863_addr_byte == 2)
buf[idx++] = (addr >> 8) & 0xff;
// add address byte 0
buf[idx++] = addr & 0xff;
ret = write(g_fd[ViPipe], buf, tp2863_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, tp2863_data_byte);
if (ret < 0)
{
CVI_TRACE_SNS(CVI_DBG_ERR, "I2C_READ error!\n");
return 0;
}
// pack read back data
data = 0;
if (tp2863_data_byte == 2)
{
data = buf[0] << 8;
data += buf[1];
}
else
{
data = buf[0];
}
syslog(LOG_DEBUG, "i2c r 0x%x = 0x%x\n", addr, data);
return data;
}
int tp2863_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 (tp2863_addr_byte == 2)
buf[idx++] = (addr >> 8) & 0xff;
// add address byte 0
buf[idx++] = addr & 0xff;
if (tp2863_data_byte == 2)
buf[idx++] = (data >> 8) & 0xff;
// add data byte 0
buf[idx++] = data & 0xff;
ret = write(g_fd[ViPipe], buf, tp2863_addr_byte + tp2863_data_byte);
if (ret < 0)
{
CVI_TRACE_SNS(CVI_DBG_ERR, "I2C_WRITE error!\n");
return CVI_FAILURE;
}
syslog(LOG_DEBUG, "i2c w 0x%x 0x%x\n", addr, data);
#if 0 // read back checing
ret = tp2863_read_register(ViPipe, addr);
if (ret != data)
syslog(LOG_DEBUG, "i2c readback-check fail, 0x%x != 0x%x\n", ret, data);
#endif
return CVI_SUCCESS;
}
void TP2863_decoder_init(VI_PIPE ViPipe, unsigned char ch, unsigned char fmt, unsigned char std)
{
unsigned char tmp;
const unsigned char REG42_43[] = {0x01, 0x02, 0x00, 0x00, 0x03};
const unsigned char MASK42_43[] = {0xfe, 0xfd, 0xff, 0xff, 0xfc};
tp2863_write_register(ViPipe, 0x40, ch);
tp2863_write_register(ViPipe, 0x06, 0x12); // default value
tp2863_write_register(ViPipe, 0x50, 0x00); // VIN1/3
tp2863_write_register(ViPipe, 0x51, 0x00);
tp2863_write_register(ViPipe, 0x54, 0x03);
if (HD25 == fmt)
{
tmp = tp2863_read_register(ViPipe, 0x42);
tmp |= REG42_43[ch];
tp2863_write_register(ViPipe, 0x42, tmp);
tmp = tp2863_read_register(ViPipe, 0x43);
tmp &= MASK42_43[ch];
tp2863_write_register(ViPipe, 0x43, tmp);
tp2863_write_register(ViPipe, 0x02, 0x42);
tp2863_write_register(ViPipe, 0x07, 0xc0);
tp2863_write_register(ViPipe, 0x0b, 0xc0);
tp2863_write_register(ViPipe, 0x0c, 0x13);
tp2863_write_register(ViPipe, 0x0d, 0x50);
tp2863_write_register(ViPipe, 0x15, 0x13);
tp2863_write_register(ViPipe, 0x16, 0x15);
tp2863_write_register(ViPipe, 0x17, 0x00);
tp2863_write_register(ViPipe, 0x18, 0x19);
tp2863_write_register(ViPipe, 0x19, 0xd0);
tp2863_write_register(ViPipe, 0x1a, 0x25);
tp2863_write_register(ViPipe, 0x1c, 0x07); // 1280*720, 25fps
tp2863_write_register(ViPipe, 0x1d, 0xbc); // 1280*720, 25fps
tp2863_write_register(ViPipe, 0x20, 0x30);
tp2863_write_register(ViPipe, 0x21, 0x84);
tp2863_write_register(ViPipe, 0x22, 0x36);
tp2863_write_register(ViPipe, 0x23, 0x3c);
tp2863_write_register(ViPipe, 0x2b, 0x60);
tp2863_write_register(ViPipe, 0x2c, 0x0a);
tp2863_write_register(ViPipe, 0x2d, 0x30);
tp2863_write_register(ViPipe, 0x2e, 0x70);
tp2863_write_register(ViPipe, 0x30, 0x48);
tp2863_write_register(ViPipe, 0x31, 0xbb);
tp2863_write_register(ViPipe, 0x32, 0x2e);
tp2863_write_register(ViPipe, 0x33, 0x90);
tp2863_write_register(ViPipe, 0x35, 0x25);
tp2863_write_register(ViPipe, 0x39, 0x08);
if (STD_HDA == std)
{
tp2863_write_register(ViPipe, 0x02, 0x46);
tp2863_write_register(ViPipe, 0x0d, 0x71);
tp2863_write_register(ViPipe, 0x20, 0x40);
tp2863_write_register(ViPipe, 0x21, 0x46);
tp2863_write_register(ViPipe, 0x25, 0xfe);
tp2863_write_register(ViPipe, 0x26, 0x01);
tp2863_write_register(ViPipe, 0x2c, 0x3a);
tp2863_write_register(ViPipe, 0x2d, 0x5a);
tp2863_write_register(ViPipe, 0x2e, 0x40);
tp2863_write_register(ViPipe, 0x30, 0x9e);
tp2863_write_register(ViPipe, 0x31, 0x20);
tp2863_write_register(ViPipe, 0x32, 0x10);
tp2863_write_register(ViPipe, 0x33, 0x90);
}
}
else if (HD30 == fmt)
{
tmp = tp2863_read_register(ViPipe, 0x42);
tmp |= REG42_43[ch];
tp2863_write_register(ViPipe, 0x42, tmp);
tmp = tp2863_read_register(ViPipe, 0x43);
tmp &= MASK42_43[ch];
tp2863_write_register(ViPipe, 0x43, tmp);
tp2863_write_register(ViPipe, 0x02, 0x42);
tp2863_write_register(ViPipe, 0x07, 0xc0);
tp2863_write_register(ViPipe, 0x0b, 0xc0);
tp2863_write_register(ViPipe, 0x0c, 0x13);
tp2863_write_register(ViPipe, 0x0d, 0x50);
tp2863_write_register(ViPipe, 0x15, 0x13);
tp2863_write_register(ViPipe, 0x16, 0x15);
tp2863_write_register(ViPipe, 0x17, 0x00);
tp2863_write_register(ViPipe, 0x18, 0x19);
tp2863_write_register(ViPipe, 0x19, 0xd0);
tp2863_write_register(ViPipe, 0x1a, 0x25);
tp2863_write_register(ViPipe, 0x1c, 0x06); // 1280*720, 30fps
tp2863_write_register(ViPipe, 0x1d, 0x72); // 1280*720, 30fps
tp2863_write_register(ViPipe, 0x20, 0x30);
tp2863_write_register(ViPipe, 0x21, 0x84);
tp2863_write_register(ViPipe, 0x22, 0x36);
tp2863_write_register(ViPipe, 0x23, 0x3c);
tp2863_write_register(ViPipe, 0x2b, 0x60);
tp2863_write_register(ViPipe, 0x2c, 0x0a);
tp2863_write_register(ViPipe, 0x2d, 0x30);
tp2863_write_register(ViPipe, 0x2e, 0x70);
tp2863_write_register(ViPipe, 0x30, 0x48);
tp2863_write_register(ViPipe, 0x31, 0xbb);
tp2863_write_register(ViPipe, 0x32, 0x2e);
tp2863_write_register(ViPipe, 0x33, 0x90);
tp2863_write_register(ViPipe, 0x35, 0x25);
tp2863_write_register(ViPipe, 0x39, 0x08);
if (STD_HDA == std)
{
tp2863_write_register(ViPipe, 0x02, 0x46);
tp2863_write_register(ViPipe, 0x0d, 0x70);
tp2863_write_register(ViPipe, 0x20, 0x40);
tp2863_write_register(ViPipe, 0x21, 0x46);
tp2863_write_register(ViPipe, 0x25, 0xfe);
tp2863_write_register(ViPipe, 0x26, 0x01);
tp2863_write_register(ViPipe, 0x2c, 0x3a);
tp2863_write_register(ViPipe, 0x2d, 0x5a);
tp2863_write_register(ViPipe, 0x2e, 0x40);
tp2863_write_register(ViPipe, 0x30, 0x9d);
tp2863_write_register(ViPipe, 0x31, 0xca);
tp2863_write_register(ViPipe, 0x32, 0x01);
tp2863_write_register(ViPipe, 0x33, 0xd0);
}
}
else if (FHD25 == fmt)
{
tmp = tp2863_read_register(ViPipe, 0x42);
tmp &= MASK42_43[ch];
tp2863_write_register(ViPipe, 0x42, tmp);
tmp = tp2863_read_register(ViPipe, 0x43);
tmp &= MASK42_43[ch];
tp2863_write_register(ViPipe, 0x43, tmp);
tp2863_write_register(ViPipe, 0x02, 0x40);
tp2863_write_register(ViPipe, 0x07, 0xc0);
tp2863_write_register(ViPipe, 0x0b, 0xc0);
tp2863_write_register(ViPipe, 0x0c, 0x03);
tp2863_write_register(ViPipe, 0x0d, 0x50);
tp2863_write_register(ViPipe, 0x15, 0x03);
tp2863_write_register(ViPipe, 0x16, 0xd2);
tp2863_write_register(ViPipe, 0x17, 0x80);
tp2863_write_register(ViPipe, 0x18, 0x29);
tp2863_write_register(ViPipe, 0x19, 0x38);
tp2863_write_register(ViPipe, 0x1a, 0x47);
tp2863_write_register(ViPipe, 0x1c, 0x0a); // 1920*1080, 25fps
tp2863_write_register(ViPipe, 0x1d, 0x50); //
tp2863_write_register(ViPipe, 0x20, 0x30);
tp2863_write_register(ViPipe, 0x21, 0x84);
tp2863_write_register(ViPipe, 0x22, 0x36);
tp2863_write_register(ViPipe, 0x23, 0x3c);
tp2863_write_register(ViPipe, 0x2b, 0x60);
tp2863_write_register(ViPipe, 0x2c, 0x0a);
tp2863_write_register(ViPipe, 0x2d, 0x30);
tp2863_write_register(ViPipe, 0x2e, 0x70);
tp2863_write_register(ViPipe, 0x30, 0x48);
tp2863_write_register(ViPipe, 0x31, 0xbb);
tp2863_write_register(ViPipe, 0x32, 0x2e);
tp2863_write_register(ViPipe, 0x33, 0x90);
tp2863_write_register(ViPipe, 0x35, 0x05);
tp2863_write_register(ViPipe, 0x39, 0x0C);
if (STD_HDA == std)
{
tp2863_write_register(ViPipe, 0x02, 0x44);
tp2863_write_register(ViPipe, 0x0d, 0x73);
tp2863_write_register(ViPipe, 0x15, 0x01);
tp2863_write_register(ViPipe, 0x16, 0xf0);
tp2863_write_register(ViPipe, 0x18, 0x2a);
tp2863_write_register(ViPipe, 0x20, 0x3c);
tp2863_write_register(ViPipe, 0x21, 0x46);
tp2863_write_register(ViPipe, 0x25, 0xfe);
tp2863_write_register(ViPipe, 0x26, 0x0d);
tp2863_write_register(ViPipe, 0x2c, 0x3a);
tp2863_write_register(ViPipe, 0x2d, 0x54);
tp2863_write_register(ViPipe, 0x2e, 0x40);
tp2863_write_register(ViPipe, 0x30, 0xa5);
tp2863_write_register(ViPipe, 0x31, 0x86);
tp2863_write_register(ViPipe, 0x32, 0xfb);
tp2863_write_register(ViPipe, 0x33, 0x60);
}
}
else if (FHD30 == fmt)
{
tmp = tp2863_read_register(ViPipe, 0x42);
tmp &= MASK42_43[ch];
tp2863_write_register(ViPipe, 0x42, tmp);
tmp = tp2863_read_register(ViPipe, 0x43);
tmp &= MASK42_43[ch];
tp2863_write_register(ViPipe, 0x43, tmp);
tp2863_write_register(ViPipe, 0x02, 0x40);
tp2863_write_register(ViPipe, 0x07, 0xc0);
tp2863_write_register(ViPipe, 0x0b, 0xc0);
tp2863_write_register(ViPipe, 0x0c, 0x03);
tp2863_write_register(ViPipe, 0x0d, 0x50);
tp2863_write_register(ViPipe, 0x15, 0x03);
tp2863_write_register(ViPipe, 0x16, 0xd2);
tp2863_write_register(ViPipe, 0x17, 0x80);
tp2863_write_register(ViPipe, 0x18, 0x29);
tp2863_write_register(ViPipe, 0x19, 0x38);
tp2863_write_register(ViPipe, 0x1a, 0x47);
tp2863_write_register(ViPipe, 0x1c, 0x08); // 1920*1080, 30fps
tp2863_write_register(ViPipe, 0x1d, 0x98); //
tp2863_write_register(ViPipe, 0x20, 0x30);
tp2863_write_register(ViPipe, 0x21, 0x84);
tp2863_write_register(ViPipe, 0x22, 0x36);
tp2863_write_register(ViPipe, 0x23, 0x3c);
tp2863_write_register(ViPipe, 0x2b, 0x60);
tp2863_write_register(ViPipe, 0x2c, 0x0a);
tp2863_write_register(ViPipe, 0x2d, 0x30);
tp2863_write_register(ViPipe, 0x2e, 0x70);
tp2863_write_register(ViPipe, 0x30, 0x48);
tp2863_write_register(ViPipe, 0x31, 0xbb);
tp2863_write_register(ViPipe, 0x32, 0x2e);
tp2863_write_register(ViPipe, 0x33, 0x90);
tp2863_write_register(ViPipe, 0x35, 0x05);
tp2863_write_register(ViPipe, 0x39, 0x0C);
if (STD_HDA == std)
{
tp2863_write_register(ViPipe, 0x02, 0x44);
tp2863_write_register(ViPipe, 0x0d, 0x72);
tp2863_write_register(ViPipe, 0x15, 0x01);
tp2863_write_register(ViPipe, 0x16, 0xf0);
tp2863_write_register(ViPipe, 0x18, 0x2a);
tp2863_write_register(ViPipe, 0x20, 0x38);
tp2863_write_register(ViPipe, 0x21, 0x46);
tp2863_write_register(ViPipe, 0x25, 0xfe);
tp2863_write_register(ViPipe, 0x26, 0x0d);
tp2863_write_register(ViPipe, 0x2c, 0x3a);
tp2863_write_register(ViPipe, 0x2d, 0x54);
tp2863_write_register(ViPipe, 0x2e, 0x40);
tp2863_write_register(ViPipe, 0x30, 0xa5);
tp2863_write_register(ViPipe, 0x31, 0x95);
tp2863_write_register(ViPipe, 0x32, 0xe0);
tp2863_write_register(ViPipe, 0x33, 0x60);
}
}
}
void TP2863_mipi_out(VI_PIPE ViPipe, unsigned char output)
{
// mipi setting
tp2863_write_register(ViPipe, 0x40, MIPI_PAGE); // MIPI page
tp2863_write_register(ViPipe, 0x02, 0x78);
tp2863_write_register(ViPipe, 0x03, 0x70);
tp2863_write_register(ViPipe, 0x04, 0x70);
tp2863_write_register(ViPipe, 0x05, 0x70);
tp2863_write_register(ViPipe, 0x06, 0x70);
tp2863_write_register(ViPipe, 0x13, 0xef);
tp2863_write_register(ViPipe, 0x20, 0x00);
tp2863_write_register(ViPipe, 0x21, 0x22);
tp2863_write_register(ViPipe, 0x22, 0x20);
tp2863_write_register(ViPipe, 0x23, 0x9e);
if (MIPI_1CH2LANE_297M == output)
{
tp2863_write_register(ViPipe, 0x21, 0x12);
tp2863_write_register(ViPipe, 0x14, 0x41);
tp2863_write_register(ViPipe, 0x15, 0x02);
tp2863_write_register(ViPipe, 0x2a, 0x04);
tp2863_write_register(ViPipe, 0x2b, 0x03);
tp2863_write_register(ViPipe, 0x2c, 0x09);
tp2863_write_register(ViPipe, 0x2e, 0x02);
tp2863_write_register(ViPipe, 0x10, 0xa0);
tp2863_write_register(ViPipe, 0x10, 0x20);
}
else if (MIPI_1CH2LANE_594M == output)
{
tp2863_write_register(ViPipe, 0x21, 0x12);
tp2863_write_register(ViPipe, 0x14, 0x00); // clk
tp2863_write_register(ViPipe, 0x15, 0x01); // clk
tp2863_write_register(ViPipe, 0x2a, 0x08); // LPX
tp2863_write_register(ViPipe, 0x2b, 0x08); // PREP
tp2863_write_register(ViPipe, 0x2c, 0x10); // TRAIL/HS ZERO
tp2863_write_register(ViPipe, 0x2e, 0x0a);
tp2863_write_register(ViPipe, 0x10, 0xa0);
tp2863_write_register(ViPipe, 0x10, 0x20);
}
else if (MIPI_2CH2LANE_297M == output)
{
tp2863_write_register(ViPipe, 0x21, 0x22);
tp2863_write_register(ViPipe, 0x14, 0x41);
tp2863_write_register(ViPipe, 0x15, 0x02);
tp2863_write_register(ViPipe, 0x2a, 0x04);
tp2863_write_register(ViPipe, 0x2b, 0x03);
tp2863_write_register(ViPipe, 0x2c, 0x09);
tp2863_write_register(ViPipe, 0x2e, 0x02);
tp2863_write_register(ViPipe, 0x10, 0xa0);
tp2863_write_register(ViPipe, 0x10, 0x20);
}
else if (MIPI_2CH2LANE_594M == output)
{
tp2863_write_register(ViPipe, 0x21, 0x22);
tp2863_write_register(ViPipe, 0x14, 0x00);
tp2863_write_register(ViPipe, 0x15, 0x01);
tp2863_write_register(ViPipe, 0x2a, 0x08);
tp2863_write_register(ViPipe, 0x2b, 0x08);
tp2863_write_register(ViPipe, 0x2c, 0x10);
tp2863_write_register(ViPipe, 0x2e, 0x0a);
tp2863_write_register(ViPipe, 0x10, 0xa0);
tp2863_write_register(ViPipe, 0x10, 0x20);
}
/* Enable MIPI CSI2 output */
tp2863_write_register(ViPipe, 0x28, 0x02);
tp2863_write_register(ViPipe, 0x28, 0x00);
}
void TP2863_reg_init(VI_PIPE ViPipe, CVI_U8 u8ImgMode)
{
if (u8ImgMode == TP2863_MODE_1080P_30P)
{
TP2863_decoder_init(ViPipe, CH_1, FHD30, STD_HDA);
TP2863_mipi_out(ViPipe, MIPI_1CH2LANE_297M);
printf("Techpoint TP2863 1080 FHD30\n");
}
else if (u8ImgMode == TP2863_MODE_1080P_25P)
{
TP2863_decoder_init(ViPipe, CH_1, FHD25, STD_HDA);
TP2863_mipi_out(ViPipe, MIPI_1CH2LANE_297M);
printf("Techpoint TP2863 720 FHD25\n");
}
else if (u8ImgMode == TP2863_MODE_720P_30P)
{
TP2863_decoder_init(ViPipe, CH_1, HD30, STD_HDA);
TP2863_mipi_out(ViPipe, MIPI_1CH2LANE_297M);
printf("Techpoint TP2863 720 HD30\n");
}
else if (u8ImgMode == TP2863_MODE_720P_25P)
{
TP2863_decoder_init(ViPipe, CH_1, HD25, STD_HDA);
TP2863_mipi_out(ViPipe, MIPI_1CH2LANE_297M);
printf("Techpoint TP2863 720 HD25\n");
}
}
void tp2863_init(VI_PIPE ViPipe)
{
tp2863_i2c_init(ViPipe);
syslog(LOG_DEBUG, "Loading Techpoint TP2863 sensor\n");
// check sensor chip id
tp2863_write_register(ViPipe, 0x40, 0x0);
if (tp2863_read_register(ViPipe, 0xfe) != 0x28 ||
tp2863_read_register(ViPipe, 0xff) != 0x63)
{
syslog(LOG_DEBUG, "read TP2863 chip id fail\n");
return;
}
TP2863_reg_init(ViPipe, g_pastTP2863[ViPipe]->u8ImgMode);
usleep(500 * 1000);
#if TP2863_BLUE_SCREEN
tp2863_write_register(ViPipe, 0x40, 0x00);
tp2863_write_register(ViPipe, 0x2A, 0x3C);
#endif
}
void tp2863_exit(VI_PIPE ViPipe)
{
tp2863_i2c_exit(ViPipe);
}

View File

@ -29,6 +29,9 @@ brigates_bg0808:
gcore_gc02m1: gcore_gc02m1:
$(call MAKE_SENSOR, ${@}) $(call MAKE_SENSOR, ${@})
gcore_gc0329:
$(call MAKE_SENSOR, ${@})
gcore_gc1054: gcore_gc1054:
$(call MAKE_SENSOR, ${@}) $(call MAKE_SENSOR, ${@})
@ -53,6 +56,9 @@ gcore_gc4023:
gcore_gc4653: gcore_gc4653:
$(call MAKE_SENSOR, ${@}) $(call MAKE_SENSOR, ${@})
imgds_mis2008:
$(call MAKE_SENSOR, ${@})
nextchip_n5: nextchip_n5:
$(call MAKE_SENSOR, ${@}) $(call MAKE_SENSOR, ${@})
@ -181,6 +187,9 @@ sony_imx335:
techpoint_tp2825: techpoint_tp2825:
$(call MAKE_SENSOR, ${@}) $(call MAKE_SENSOR, ${@})
techpoint_tp2863:
$(call MAKE_SENSOR, ${@})
all_sensor: all_sensor:
@$(MAKE) -f Makefile_full || exit 1; @$(MAKE) -f Makefile_full || exit 1;

View File

@ -0,0 +1,36 @@
SHELL = /bin/bash
ifeq ($(PARAM_FILE), )
PARAM_FILE=../../../../../../$(shell echo $(MW_VER))/Makefile.param
include $(PARAM_FILE)
endif
SDIR = $(PWD)
SRCS = $(wildcard $(SDIR)/*.c)
INCS = -I$(MW_INC) -I$(ISP_INC) -I$(KERNEL_INC) -I./include
OBJS = $(SRCS:.c=.o)
DEPS = $(SRCS:.c=.d)
TARGET_A = $(MW_LIB)/libsns_gc0329.a
TARGET_SO = $(MW_LIB)/libsns_gc0329.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)

View File

@ -0,0 +1,303 @@
#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 "gc0329_cmos_ex.h"
#include "gc0329_cmos_param.h"
#define GC0329_ID 0xc0
#define GC0329_I2C_ADDR_1 0x31
#define GC0329_I2C_ADDR_IS_VALID(addr) ((addr) == GC0329_I2C_ADDR_1)
/****************************************************************************
* global variables *
****************************************************************************/
ISP_SNS_STATE_S *g_pastGc0329[VI_MAX_PIPE_NUM] = {CVI_NULL};
#define GC0329_SENSOR_GET_CTX(dev, pstCtx) (pstCtx = g_pastGc0329[dev])
#define GC0329_SENSOR_SET_CTX(dev, pstCtx) (g_pastGc0329[dev] = pstCtx)
#define GC0329_SENSOR_RESET_CTX(dev) (g_pastGc0329[dev] = CVI_NULL)
ISP_SNS_COMMBUS_U g_aunGc0329_BusInfo[VI_MAX_PIPE_NUM] = {
[0] = { .s8I2cDev = 0},
[1 ... VI_MAX_PIPE_NUM - 1] = { .s8I2cDev = -1}
};
/****************************************************************************
* local variables and functions *
****************************************************************************/
#define GC0329_RES_IS_480P(w, h) ((w) == 640 && (h) == 480)
static CVI_S32 cmos_get_wdr_size(VI_PIPE ViPipe, ISP_SNS_ISP_INFO_S *pstIspCfg)
{
const GC0329_MODE_S *pstMode = CVI_NULL;
ISP_SNS_STATE_S *pstSnsState = CVI_NULL;
GC0329_SENSOR_GET_CTX(ViPipe, pstSnsState);
CMOS_CHECK_POINTER(pstSnsState);
pstMode = &g_astGc0329_mode;
pstIspCfg->frm_num = 1;
memcpy(&pstIspCfg->img_size[0], &pstMode->stImg, 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);
GC0329_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);
GC0329_SENSOR_GET_CTX(ViPipe, pstSnsState);
CMOS_CHECK_POINTER(pstSnsState);
u8SensorImageMode = pstSnsState->u8ImgMode;
pstSnsState->bSyncInit = CVI_FALSE;
if (pstSensorImageMode->f32Fps <= 10) {
if (pstSnsState->enWDRMode == WDR_MODE_NONE) {
if (GC0329_RES_IS_480P(pstSensorImageMode->u16Width, pstSensorImageMode->u16Height))
u8SensorImageMode = GC0329_MODE_640X480P10;
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;
}
} 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;
}
} else {
CVI_TRACE_SNS(CVI_DBG_ERR, "Not support this Fps:%f\n", pstSensorImageMode->f32Fps);
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;
GC0329_SENSOR_GET_CTX(ViPipe, pstSnsState);
CMOS_CHECK_POINTER_VOID(pstSnsState);
pstSnsState->bInit = CVI_FALSE;
pstSnsState->bSyncInit = CVI_FALSE;
pstSnsState->u8ImgMode = GC0329_MODE_640X480P10;
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;
GC0329_SENSOR_GET_CTX(ViPipe, pstSnsState);
CMOS_CHECK_POINTER(pstSnsState);
CMOS_CHECK_POINTER(pstRxAttr);
memcpy(pstRxAttr, &gc0329_rx_attr, sizeof(*pstRxAttr));
pstRxAttr->img_size.width = g_astGc0329_mode.stImg.stSnsSize.u32Width;
pstRxAttr->img_size.height = g_astGc0329_mode.stImg.stSnsSize.u32Height;
return CVI_SUCCESS;
}
static CVI_S32 sensor_patch_rx_attr(RX_INIT_ATTR_S *pstRxInitAttr)
{
SNS_COMBO_DEV_ATTR_S *pstRxAttr = &gc0329_rx_attr;
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;
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 = gc0329_init;
pstSensorExpFunc->pfn_cmos_sensor_exit = gc0329_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_VOID sensor_patch_i2c_addr(CVI_S32 s32I2cAddr)
{
if (GC0329_I2C_ADDR_IS_VALID(s32I2cAddr))
gc0329_i2c_addr = s32I2cAddr;
}
static CVI_S32 gc0329_set_bus_info(VI_PIPE ViPipe, ISP_SNS_COMMBUS_U unSNSBusInfo)
{
g_aunGc0329_BusInfo[ViPipe].s8I2cDev = unSNSBusInfo.s8I2cDev;
return CVI_SUCCESS;
}
static CVI_S32 sensor_ctx_init(VI_PIPE ViPipe)
{
ISP_SNS_STATE_S *pastSnsStateCtx = CVI_NULL;
GC0329_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));
GC0329_SENSOR_SET_CTX(ViPipe, pastSnsStateCtx);
return CVI_SUCCESS;
}
static CVI_VOID sensor_ctx_exit(VI_PIPE ViPipe)
{
ISP_SNS_STATE_S *pastSnsStateCtx = CVI_NULL;
GC0329_SENSOR_GET_CTX(ViPipe, pastSnsStateCtx);
SENSOR_FREE(pastSnsStateCtx);
GC0329_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;
ISP_SNS_ATTR_INFO_S stSnsAttrInfo;
(void) pstAeLib;
(void) pstAwbLib;
s32Ret = sensor_ctx_init(ViPipe);
if (s32Ret != CVI_SUCCESS)
return CVI_FAILURE;
stSnsAttrInfo.eSensorId = GC0329_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)
{
CVI_S32 s32Ret;
(void) pstAeLib;
(void) pstAwbLib;
s32Ret = CVI_ISP_SensorUnRegCallBack(ViPipe, GC0329_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_probe(VI_PIPE ViPipe)
{
return gc0329_probe(ViPipe);
}
ISP_SNS_OBJ_S stSnsGc0329_Obj = {
.pfnRegisterCallback = sensor_register_callback,
.pfnUnRegisterCallback = sensor_unregister_callback,
.pfnStandby = CVI_NULL,
.pfnRestart = CVI_NULL,
.pfnWriteReg = gc0329_write_register,
.pfnReadReg = gc0329_read_register,
.pfnSetBusInfo = gc0329_set_bus_info,
.pfnSetInit = CVI_NULL,
.pfnMirrorFlip = CVI_NULL,
.pfnPatchRxAttr = sensor_patch_rx_attr,
.pfnPatchI2cAddr = sensor_patch_i2c_addr,
.pfnGetRxAttr = sensor_rx_attr,
.pfnExpSensorCb = cmos_init_sensor_exp_function,
.pfnExpAeCb = CVI_NULL,
.pfnSnsProbe = sensor_probe,
};

View File

@ -0,0 +1,64 @@
#ifndef __GC0329_CMOS_EX_H_
#define __GC0329_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 _GC0329_MODE_E {
GC0329_MODE_640X480P10 = 0,
GC0329_MODE_NUM
} GC0329_SLAVE_MODE_E;
typedef struct _GC0329_MODE_S {
ISP_WDR_SIZE_S stImg;
CVI_FLOAT f32MaxFps;
CVI_FLOAT f32MinFps;
CVI_U32 u32HtsDef;
CVI_U32 u32VtsDef;
SNS_ATTR_S stExp;
SNS_ATTR_LARGE_S stAgain;
SNS_ATTR_LARGE_S stDgain;
char name[64];
} GC0329_MODE_S;
/****************************************************************************
* external variables and functions *
****************************************************************************/
extern ISP_SNS_STATE_S *g_pastGc0329[VI_MAX_PIPE_NUM];
extern ISP_SNS_COMMBUS_U g_aunGc0329_BusInfo[];
extern CVI_U8 gc0329_i2c_addr;
extern const CVI_U32 gc0329_addr_byte;
extern const CVI_U32 gc0329_data_byte;
extern void gc0329_init(VI_PIPE ViPipe);
extern void gc0329_exit(VI_PIPE ViPipe);
extern void gc0329_standby(VI_PIPE ViPipe);
extern void gc0329_restart(VI_PIPE ViPipe);
extern int gc0329_write_register(VI_PIPE ViPipe, int addr, int data);
extern int gc0329_read_register(VI_PIPE ViPipe, int addr);
extern void gc0329_mirror_flip(VI_PIPE ViPipe, ISP_SNS_MIRRORFLIP_TYPE_E eSnsMirrorFlip);
extern int gc0329_probe(VI_PIPE ViPipe);
#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif /* End of #ifdef __cplusplus */
#endif /* __GC0329_CMOS_EX_H_ */

View File

@ -0,0 +1,71 @@
#ifndef __GC0329_CMOS_PARAM_H_
#define __GC0329_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 "gc0329_cmos_ex.h"
static const GC0329_MODE_S g_astGc0329_mode = {
.name = "640X480P10",
.stImg = {
.stSnsSize = {
.u32Width = 640,
.u32Height = 480,
},
.stWndRect = {
.s32X = 0,
.s32Y = 0,
.u32Width = 640,
.u32Height = 480,
},
.stMaxSize = {
.u32Width = 640,
.u32Height = 480,
},
},
};
struct combo_dev_attr_s gc0329_rx_attr = {
.input_mode = INPUT_MODE_BT601,
.mac_clk = RX_MAC_CLK_200M,
.ttl_attr = {
.vi = TTL_VI_SRC_VI0,
.ttl_fmt = TTL_VSDE_11B,
.raw_data_type = RAW_DATA_8BIT,
.func = {
8, -1, -1, 12,
0, 1, 2, 3,
4, 13, 14, 11,
-1, -1, -1, -1,
-1, -1, -1, -1,
},
},
.mclk = {
.cam = 0,
.freq = CAMPLL_FREQ_24M,
},
.devno = 0,
};
#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif /* End of #ifdef __cplusplus */
#endif /* __GC0329_CMOS_PARAM_H_ */

View File

@ -0,0 +1,464 @@
#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 "gc0329_cmos_ex.h"
static void gc0329_linear_480p10_init(VI_PIPE ViPipe);
CVI_U8 gc0329_i2c_addr = 0x31;//0x78
const CVI_U32 gc0329_addr_byte = 1;
const CVI_U32 gc0329_data_byte = 1;
static int g_fd[VI_MAX_PIPE_NUM] = {[0 ... (VI_MAX_PIPE_NUM - 1)] = -1};
int gc0329_i2c_init(VI_PIPE ViPipe)
{
char acDevFile[16] = {0};
CVI_U8 u8DevNum;
if (g_fd[ViPipe] >= 0)
return CVI_SUCCESS;
int ret;
u8DevNum = g_aunGc0329_BusInfo[ViPipe].s8I2cDev;
snprintf(acDevFile, sizeof(acDevFile), "/dev/i2c-%u", u8DevNum);
g_fd[ViPipe] = open(acDevFile, O_RDWR, 0600);
if (g_fd[ViPipe] < 0) {
CVI_TRACE_SNS(CVI_DBG_ERR, "Open /dev/i2c-%u error!\n", u8DevNum);
return CVI_FAILURE;
}
ret = ioctl(g_fd[ViPipe], I2C_SLAVE_FORCE, gc0329_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 gc0329_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 gc0329_read_register(VI_PIPE ViPipe, int addr)
{
int ret, data;
CVI_U8 buf[8];
CVI_U8 idx = 0;
if (g_fd[ViPipe] < 0)
return CVI_FAILURE;
if (gc0329_addr_byte == 2)
buf[idx++] = (addr >> 8) & 0xff;
// add address byte 0
buf[idx++] = addr & 0xff;
ret = write(g_fd[ViPipe], buf, gc0329_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, gc0329_data_byte);
if (ret < 0) {
CVI_TRACE_SNS(CVI_DBG_ERR, "I2C_READ error!\n");
return ret;
}
// pack read back data
data = 0;
if (gc0329_data_byte == 2) {
data = buf[0] << 8;
data += buf[1];
} else {
data = buf[0];
}
syslog(LOG_DEBUG, "i2c r 0x%x = 0x%x\n", addr, data);
return data;
}
int gc0329_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 (gc0329_addr_byte == 1) {
buf[idx] = addr & 0xff;
idx++;
}
if (gc0329_data_byte == 1) {
buf[idx] = data & 0xff;
idx++;
}
ret = write(g_fd[ViPipe], buf, gc0329_addr_byte + gc0329_data_byte);
if (ret < 0) {
CVI_TRACE_SNS(CVI_DBG_ERR, "I2C_WRITE error!\n");
return CVI_FAILURE;
}
// syslog(LOG_DEBUG, "i2c w 0x%x 0x%x\n", addr, data);
return CVI_SUCCESS;
}
static void delay_ms(int ms)
{
usleep(ms * 1000);
}
#define GC0329_CHIP_ID_ADDR 0x00
#define GC0329_CHIP_ID 0xc0
int gc0329_probe(VI_PIPE ViPipe)
{
int nVal;
usleep(50);
if (gc0329_i2c_init(ViPipe) != CVI_SUCCESS)
return CVI_FAILURE;
gc0329_write_register(ViPipe, 0xfc, 0x16);
nVal = gc0329_read_register(ViPipe, GC0329_CHIP_ID_ADDR);
if (nVal < 0) {
CVI_TRACE_SNS(CVI_DBG_ERR, "read sensor id error.\n");
return nVal;
}
if ((nVal & 0xFF) != GC0329_CHIP_ID) {
CVI_TRACE_SNS(CVI_DBG_ERR, "Sensor ID Mismatch! Use the wrong sensor??\n");
return CVI_FAILURE;
}
printf("%d\n", ViPipe);
return CVI_SUCCESS;
}
void gc0329_init(VI_PIPE ViPipe)
{
gc0329_i2c_init(ViPipe);
gc0329_linear_480p10_init(ViPipe);
g_pastGc0329[ViPipe]->bInit = CVI_TRUE;
}
void gc0329_exit(VI_PIPE ViPipe)
{
gc0329_i2c_exit(ViPipe);
}
static void gc0329_linear_480p10_init(VI_PIPE ViPipe)
{
gc0329_write_register(ViPipe, 0xfe, 0x80);
gc0329_write_register(ViPipe, 0xfc, 0x16);
gc0329_write_register(ViPipe, 0xfc, 0x16);
gc0329_write_register(ViPipe, 0xfe, 0x00);
gc0329_write_register(ViPipe, 0x70, 0x48);
gc0329_write_register(ViPipe, 0x73, 0x90);
gc0329_write_register(ViPipe, 0x74, 0x80);
gc0329_write_register(ViPipe, 0x75, 0x80);
gc0329_write_register(ViPipe, 0x76, 0x94);
gc0329_write_register(ViPipe, 0x77, 0x62);
gc0329_write_register(ViPipe, 0x78, 0x47);
gc0329_write_register(ViPipe, 0x79, 0x40);
gc0329_write_register(ViPipe, 0x03, 0x02);
gc0329_write_register(ViPipe, 0x04, 0x40);
gc0329_write_register(ViPipe, 0xfc, 0x16);
gc0329_write_register(ViPipe, 0x09, 0x00);
gc0329_write_register(ViPipe, 0x0a, 0x02);
gc0329_write_register(ViPipe, 0x0b, 0x00);
gc0329_write_register(ViPipe, 0x0c, 0x02);
gc0329_write_register(ViPipe, 0x17, 0x14);
gc0329_write_register(ViPipe, 0x19, 0x05);
gc0329_write_register(ViPipe, 0x1b, 0x24);
gc0329_write_register(ViPipe, 0x1c, 0x04);
gc0329_write_register(ViPipe, 0x1e, 0x08);
gc0329_write_register(ViPipe, 0x1f, 0x08);
gc0329_write_register(ViPipe, 0x20, 0x01);
gc0329_write_register(ViPipe, 0x21, 0x48);
gc0329_write_register(ViPipe, 0x22, 0xba);
gc0329_write_register(ViPipe, 0x23, 0x22);
gc0329_write_register(ViPipe, 0x24, 0x16);
gc0329_write_register(ViPipe, 0x26, 0xf7);
gc0329_write_register(ViPipe, 0x28, 0x7f);
gc0329_write_register(ViPipe, 0x29, 0x00);
gc0329_write_register(ViPipe, 0x32, 0x00);
gc0329_write_register(ViPipe, 0x33, 0x20);
gc0329_write_register(ViPipe, 0x34, 0x20);
gc0329_write_register(ViPipe, 0x35, 0x20);
gc0329_write_register(ViPipe, 0x36, 0x20);
gc0329_write_register(ViPipe, 0x3b, 0x04);
gc0329_write_register(ViPipe, 0x3c, 0x04);
gc0329_write_register(ViPipe, 0x3d, 0x04);
gc0329_write_register(ViPipe, 0x3e, 0x04);
gc0329_write_register(ViPipe, 0x40, 0xff);
gc0329_write_register(ViPipe, 0x41, 0x24);
gc0329_write_register(ViPipe, 0x42, 0xfa);
gc0329_write_register(ViPipe, 0x46, 0x02);
gc0329_write_register(ViPipe, 0x4b, 0xca);
gc0329_write_register(ViPipe, 0x4d, 0x01);
gc0329_write_register(ViPipe, 0x4f, 0x01);
gc0329_write_register(ViPipe, 0x70, 0x48);
gc0329_write_register(ViPipe, 0x80, 0x07);
gc0329_write_register(ViPipe, 0x81, 0xc2);
gc0329_write_register(ViPipe, 0x82, 0x90);
gc0329_write_register(ViPipe, 0x83, 0x05);
gc0329_write_register(ViPipe, 0x87, 0x40);
gc0329_write_register(ViPipe, 0x90, 0x8c);
gc0329_write_register(ViPipe, 0x92, 0x05);
gc0329_write_register(ViPipe, 0x94, 0x05);
gc0329_write_register(ViPipe, 0x95, 0x45);
gc0329_write_register(ViPipe, 0x96, 0x88);
gc0329_write_register(ViPipe, 0xfe, 0x01);
gc0329_write_register(ViPipe, 0x18, 0x22);
gc0329_write_register(ViPipe, 0xfe, 0x00);
gc0329_write_register(ViPipe, 0x9c, 0x0a);
gc0329_write_register(ViPipe, 0xa0, 0xaf);
gc0329_write_register(ViPipe, 0xa2, 0xff);
gc0329_write_register(ViPipe, 0xa4, 0x30);
gc0329_write_register(ViPipe, 0xa5, 0x31);
gc0329_write_register(ViPipe, 0xa7, 0x35);
gc0329_write_register(ViPipe, 0xfe, 0x00);
gc0329_write_register(ViPipe, 0xbf, 0x0b);
gc0329_write_register(ViPipe, 0xc0, 0x1d);
gc0329_write_register(ViPipe, 0xc1, 0x33);
gc0329_write_register(ViPipe, 0xc2, 0x49);
gc0329_write_register(ViPipe, 0xc3, 0x5d);
gc0329_write_register(ViPipe, 0xc4, 0x6e);
gc0329_write_register(ViPipe, 0xc5, 0x7c);
gc0329_write_register(ViPipe, 0xc6, 0x99);
gc0329_write_register(ViPipe, 0xc7, 0xaf);
gc0329_write_register(ViPipe, 0xc8, 0xc2);
gc0329_write_register(ViPipe, 0xc9, 0xd0);
gc0329_write_register(ViPipe, 0xca, 0xda);
gc0329_write_register(ViPipe, 0xcb, 0xe2);
gc0329_write_register(ViPipe, 0xcc, 0xe7);
gc0329_write_register(ViPipe, 0xcd, 0xf0);
gc0329_write_register(ViPipe, 0xce, 0xf7);
gc0329_write_register(ViPipe, 0xcf, 0xff);
gc0329_write_register(ViPipe, 0xfe, 0x00);
gc0329_write_register(ViPipe, 0x63, 0x00);
gc0329_write_register(ViPipe, 0x64, 0x06);
gc0329_write_register(ViPipe, 0x65, 0x0d);
gc0329_write_register(ViPipe, 0x66, 0x1b);
gc0329_write_register(ViPipe, 0x67, 0x2b);
gc0329_write_register(ViPipe, 0x68, 0x3d);
gc0329_write_register(ViPipe, 0x69, 0x50);
gc0329_write_register(ViPipe, 0x6a, 0x60);
gc0329_write_register(ViPipe, 0x6b, 0x80);
gc0329_write_register(ViPipe, 0x6c, 0xa0);
gc0329_write_register(ViPipe, 0x6d, 0xc0);
gc0329_write_register(ViPipe, 0x6e, 0xe0);
gc0329_write_register(ViPipe, 0x6f, 0xff);
gc0329_write_register(ViPipe, 0xfe, 0x00);
gc0329_write_register(ViPipe, 0xb3, 0x44);
gc0329_write_register(ViPipe, 0xb4, 0xfd);
gc0329_write_register(ViPipe, 0xb5, 0x02);
gc0329_write_register(ViPipe, 0xb6, 0xfa);
gc0329_write_register(ViPipe, 0xb7, 0x48);
gc0329_write_register(ViPipe, 0xb8, 0xf0);
gc0329_write_register(ViPipe, 0x50, 0x01);
gc0329_write_register(ViPipe, 0xfe, 0x00);
gc0329_write_register(ViPipe, 0xd0, 0x40);
gc0329_write_register(ViPipe, 0xd1, 0x28);
gc0329_write_register(ViPipe, 0xd2, 0x28);
gc0329_write_register(ViPipe, 0xd3, 0x40);
gc0329_write_register(ViPipe, 0xd5, 0x00);
gc0329_write_register(ViPipe, 0xdd, 0x14);
gc0329_write_register(ViPipe, 0xde, 0x34);
gc0329_write_register(ViPipe, 0xfe, 0x01);
gc0329_write_register(ViPipe, 0x10, 0x40);
gc0329_write_register(ViPipe, 0x11, 0x21);
gc0329_write_register(ViPipe, 0x12, 0x13);
gc0329_write_register(ViPipe, 0x13, 0x50);
gc0329_write_register(ViPipe, 0x17, 0xa8);
gc0329_write_register(ViPipe, 0x1a, 0x21);
gc0329_write_register(ViPipe, 0x20, 0x31);
gc0329_write_register(ViPipe, 0x21, 0xc0);
gc0329_write_register(ViPipe, 0x22, 0x60);
gc0329_write_register(ViPipe, 0x3c, 0x50);
gc0329_write_register(ViPipe, 0x3d, 0x40);
gc0329_write_register(ViPipe, 0x3e, 0x45);
gc0329_write_register(ViPipe, 0xfe, 0x01);
gc0329_write_register(ViPipe, 0x06, 0x12);
gc0329_write_register(ViPipe, 0x07, 0x06);
gc0329_write_register(ViPipe, 0x08, 0x9c);
gc0329_write_register(ViPipe, 0x09, 0xee);
gc0329_write_register(ViPipe, 0x50, 0xfc);
gc0329_write_register(ViPipe, 0x51, 0x28);
gc0329_write_register(ViPipe, 0x52, 0x10);
gc0329_write_register(ViPipe, 0x53, 0x20);
gc0329_write_register(ViPipe, 0x54, 0x12);
gc0329_write_register(ViPipe, 0x55, 0x16);
gc0329_write_register(ViPipe, 0x56, 0x30);
gc0329_write_register(ViPipe, 0x58, 0x60);
gc0329_write_register(ViPipe, 0x59, 0x08);
gc0329_write_register(ViPipe, 0x5a, 0x02);
gc0329_write_register(ViPipe, 0x5b, 0x63);
gc0329_write_register(ViPipe, 0x5c, 0x35);
gc0329_write_register(ViPipe, 0x5d, 0x72);
gc0329_write_register(ViPipe, 0x5e, 0x11);
gc0329_write_register(ViPipe, 0x5f, 0x40);
gc0329_write_register(ViPipe, 0x60, 0x40);
gc0329_write_register(ViPipe, 0x61, 0xc8);
gc0329_write_register(ViPipe, 0x62, 0xa0);
gc0329_write_register(ViPipe, 0x63, 0x40);
gc0329_write_register(ViPipe, 0x64, 0x50);
gc0329_write_register(ViPipe, 0x65, 0x98);
gc0329_write_register(ViPipe, 0x66, 0xfa);
gc0329_write_register(ViPipe, 0x67, 0x80);
gc0329_write_register(ViPipe, 0x68, 0x60);
gc0329_write_register(ViPipe, 0x69, 0x90);
gc0329_write_register(ViPipe, 0x6a, 0x40);
gc0329_write_register(ViPipe, 0x6b, 0x39);
gc0329_write_register(ViPipe, 0x6c, 0x30);
gc0329_write_register(ViPipe, 0x6d, 0x60);
gc0329_write_register(ViPipe, 0x6e, 0x41);
gc0329_write_register(ViPipe, 0x70, 0x10);
gc0329_write_register(ViPipe, 0x71, 0x00);
gc0329_write_register(ViPipe, 0x72, 0x10);
gc0329_write_register(ViPipe, 0x73, 0x40);
gc0329_write_register(ViPipe, 0x80, 0x60);
gc0329_write_register(ViPipe, 0x81, 0x50);
gc0329_write_register(ViPipe, 0x82, 0x42);
gc0329_write_register(ViPipe, 0x83, 0x40);
gc0329_write_register(ViPipe, 0x84, 0x40);
gc0329_write_register(ViPipe, 0x85, 0x40);
gc0329_write_register(ViPipe, 0x74, 0x40);
gc0329_write_register(ViPipe, 0x75, 0x58);
gc0329_write_register(ViPipe, 0x76, 0x24);
gc0329_write_register(ViPipe, 0x77, 0x40);
gc0329_write_register(ViPipe, 0x78, 0x20);
gc0329_write_register(ViPipe, 0x79, 0x60);
gc0329_write_register(ViPipe, 0x7a, 0x58);
gc0329_write_register(ViPipe, 0x7b, 0x20);
gc0329_write_register(ViPipe, 0x7c, 0x30);
gc0329_write_register(ViPipe, 0x7d, 0x35);
gc0329_write_register(ViPipe, 0x7e, 0x10);
gc0329_write_register(ViPipe, 0x7f, 0x08);
gc0329_write_register(ViPipe, 0x9c, 0x00);
gc0329_write_register(ViPipe, 0x9e, 0xc0);
gc0329_write_register(ViPipe, 0x9f, 0x40);
gc0329_write_register(ViPipe, 0xd0, 0x00);
gc0329_write_register(ViPipe, 0xd2, 0x2c);
gc0329_write_register(ViPipe, 0xd3, 0x80);
gc0329_write_register(ViPipe, 0xfe, 0x01);
gc0329_write_register(ViPipe, 0xc0, 0x0b);
gc0329_write_register(ViPipe, 0xc1, 0x07);
gc0329_write_register(ViPipe, 0xc2, 0x05);
gc0329_write_register(ViPipe, 0xc6, 0x0b);
gc0329_write_register(ViPipe, 0xc7, 0x07);
gc0329_write_register(ViPipe, 0xc8, 0x05);
gc0329_write_register(ViPipe, 0xba, 0x39);
gc0329_write_register(ViPipe, 0xbb, 0x24);
gc0329_write_register(ViPipe, 0xbc, 0x23);
gc0329_write_register(ViPipe, 0xb4, 0x39);
gc0329_write_register(ViPipe, 0xb5, 0x24);
gc0329_write_register(ViPipe, 0xb6, 0x23);
gc0329_write_register(ViPipe, 0xc3, 0x00);
gc0329_write_register(ViPipe, 0xc4, 0x00);
gc0329_write_register(ViPipe, 0xc5, 0x00);
gc0329_write_register(ViPipe, 0xc9, 0x00);
gc0329_write_register(ViPipe, 0xca, 0x00);
gc0329_write_register(ViPipe, 0xcb, 0x00);
gc0329_write_register(ViPipe, 0xbd, 0x2b);
gc0329_write_register(ViPipe, 0xbe, 0x00);
gc0329_write_register(ViPipe, 0xbf, 0x00);
gc0329_write_register(ViPipe, 0xb7, 0x09);
gc0329_write_register(ViPipe, 0xb8, 0x00);
gc0329_write_register(ViPipe, 0xb9, 0x00);
gc0329_write_register(ViPipe, 0xa8, 0x31);
gc0329_write_register(ViPipe, 0xa9, 0x23);
gc0329_write_register(ViPipe, 0xaa, 0x20);
gc0329_write_register(ViPipe, 0xab, 0x31);
gc0329_write_register(ViPipe, 0xac, 0x23);
gc0329_write_register(ViPipe, 0xad, 0x20);
gc0329_write_register(ViPipe, 0xae, 0x31);
gc0329_write_register(ViPipe, 0xaf, 0x23);
gc0329_write_register(ViPipe, 0xb0, 0x20);
gc0329_write_register(ViPipe, 0xb1, 0x31);
gc0329_write_register(ViPipe, 0xb2, 0x23);
gc0329_write_register(ViPipe, 0xb3, 0x20);
gc0329_write_register(ViPipe, 0xa4, 0x00);
gc0329_write_register(ViPipe, 0xa5, 0x00);
gc0329_write_register(ViPipe, 0xa6, 0x00);
gc0329_write_register(ViPipe, 0xa7, 0x00);
gc0329_write_register(ViPipe, 0xa1, 0x3c);
gc0329_write_register(ViPipe, 0xa2, 0x50);
gc0329_write_register(ViPipe, 0xfe, 0x00);
gc0329_write_register(ViPipe, 0x05, 0x02);
gc0329_write_register(ViPipe, 0x06, 0x2c);
gc0329_write_register(ViPipe, 0x07, 0x00);
gc0329_write_register(ViPipe, 0x08, 0xb8);
gc0329_write_register(ViPipe, 0xfe, 0x01);
gc0329_write_register(ViPipe, 0x29, 0x00);
gc0329_write_register(ViPipe, 0x2a, 0x60);
gc0329_write_register(ViPipe, 0x2b, 0x02);
gc0329_write_register(ViPipe, 0x2c, 0xa0);
gc0329_write_register(ViPipe, 0x2d, 0x03);
gc0329_write_register(ViPipe, 0x2e, 0x00);
gc0329_write_register(ViPipe, 0x2f, 0x03);
gc0329_write_register(ViPipe, 0x30, 0xc0);
gc0329_write_register(ViPipe, 0x31, 0x05);
gc0329_write_register(ViPipe, 0x32, 0x40);
gc0329_write_register(ViPipe, 0xfe, 0x00);
gc0329_write_register(ViPipe, 0x44, 0xa2);
gc0329_write_register(ViPipe, 0xf0, 0x07);
gc0329_write_register(ViPipe, 0xf1, 0x01);
delay_ms(50);
printf("ViPipe:%d,===GC0329 480P 10fps YUV Init OK!===\n", ViPipe);
}

View File

@ -28,6 +28,10 @@
#define DIV_0_TO_1(a) ((0 == (a)) ? 1 : (a)) #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 DIV_0_TO_1_FLOAT(a) ((((a) < 1E-10) && ((a) > -1E-10)) ? 1 : (a))
#define GC2093_ID 2093 #define GC2093_ID 2093
#define GC2093_I2C_ADDR_1 0x7e
#define GC2093_I2C_ADDR_2 0x37
#define GC2093_I2C_ADDR_IS_VALID(addr) ((addr) == GC2093_I2C_ADDR_1 || (addr) == GC2093_I2C_ADDR_2)
/**************************************************************************** /****************************************************************************
* global variables * * global variables *
***************************************************************************/ ***************************************************************************/
@ -1040,6 +1044,11 @@ static CVI_S32 cmos_init_sensor_exp_function(ISP_SENSOR_EXP_FUNC_S *pstSensorExp
/**************************************************************************** /****************************************************************************
* callback structure * * callback structure *
****************************************************************************/ ****************************************************************************/
static CVI_VOID sensor_patch_i2c_addr(CVI_S32 s32I2cAddr)
{
if (GC2093_I2C_ADDR_IS_VALID(s32I2cAddr))
gc2093_i2c_addr = s32I2cAddr;
}
static CVI_S32 gc2093_set_bus_info(VI_PIPE ViPipe, ISP_SNS_COMMBUS_U unSNSBusInfo) static CVI_S32 gc2093_set_bus_info(VI_PIPE ViPipe, ISP_SNS_COMMBUS_U unSNSBusInfo)
{ {
@ -1185,6 +1194,7 @@ ISP_SNS_OBJ_S stSnsGc2093_Obj = {
.pfnSetInit = sensor_set_init, .pfnSetInit = sensor_set_init,
.pfnMirrorFlip = sensor_mirror_flip, .pfnMirrorFlip = sensor_mirror_flip,
.pfnPatchRxAttr = sensor_patch_rx_attr, .pfnPatchRxAttr = sensor_patch_rx_attr,
.pfnPatchI2cAddr = sensor_patch_i2c_addr,
.pfnGetRxAttr = sensor_rx_attr, .pfnGetRxAttr = sensor_rx_attr,
.pfnExpSensorCb = cmos_init_sensor_exp_function, .pfnExpSensorCb = cmos_init_sensor_exp_function,
.pfnExpAeCb = cmos_init_ae_exp_function, .pfnExpAeCb = cmos_init_ae_exp_function,

View File

@ -93,7 +93,7 @@ typedef struct _GC2093_MODE_S {
extern ISP_SNS_STATE_S *g_pastGc2093[VI_MAX_PIPE_NUM]; extern ISP_SNS_STATE_S *g_pastGc2093[VI_MAX_PIPE_NUM];
extern ISP_SNS_COMMBUS_U g_aunGc2093_BusInfo[]; extern ISP_SNS_COMMBUS_U g_aunGc2093_BusInfo[];
extern ISP_SNS_MIRRORFLIP_TYPE_E g_aeGc2093_MirrorFip[VI_MAX_PIPE_NUM]; extern ISP_SNS_MIRRORFLIP_TYPE_E g_aeGc2093_MirrorFip[VI_MAX_PIPE_NUM];
extern const CVI_U8 gc2093_i2c_addr; extern CVI_U8 gc2093_i2c_addr;
extern const CVI_U32 gc2093_addr_byte; extern const CVI_U32 gc2093_addr_byte;
extern const CVI_U32 gc2093_data_byte; extern const CVI_U32 gc2093_data_byte;
extern void gc2093_init(VI_PIPE ViPipe); extern void gc2093_init(VI_PIPE ViPipe);

View File

@ -20,7 +20,7 @@
static void gc2093_linear_1080p30_init(VI_PIPE ViPipe); static void gc2093_linear_1080p30_init(VI_PIPE ViPipe);
static void gc2093_wdr_1080p30_init(VI_PIPE ViPipe); static void gc2093_wdr_1080p30_init(VI_PIPE ViPipe);
const CVI_U8 gc2093_i2c_addr = 0x37;//0x6e CVI_U8 gc2093_i2c_addr = 0x37;//0x6e
const CVI_U32 gc2093_addr_byte = 2; const CVI_U32 gc2093_addr_byte = 2;
const CVI_U32 gc2093_data_byte = 1; const CVI_U32 gc2093_data_byte = 1;
static int g_fd[VI_MAX_PIPE_NUM] = {[0 ... (VI_MAX_PIPE_NUM - 1)] = -1}; static int g_fd[VI_MAX_PIPE_NUM] = {[0 ... (VI_MAX_PIPE_NUM - 1)] = -1};

View File

@ -0,0 +1,36 @@
SHELL = /bin/bash
ifeq ($(PARAM_FILE), )
PARAM_FILE=../../../../../../$(shell echo $(MW_VER))/Makefile.param
include $(PARAM_FILE)
endif
SDIR = $(PWD)
SRCS = $(wildcard $(SDIR)/*.c)
INCS = -I$(MW_INC) -I$(ISP_INC) -I$(KERNEL_INC) -I./include
OBJS = $(SRCS:.c=.o)
DEPS = $(SRCS:.c=.d)
TARGET_A = $(MW_LIB)/libsns_mis2008.a
TARGET_SO = $(MW_LIB)/libsns_mis2008.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)

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,79 @@
#ifndef __MIS2008_CMOS_EX_H_
#define __MIS2008_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"
enum mis2008_linear_regs_e {
LINEAR_SHS1_0_ADDR,
LINEAR_SHS1_1_ADDR,
LINEAR_SHS1_2_ADDR,
LINEAR_AGAIN_ADDR,
LINEAR_DGAIN_ADDR,
LINEAR_D_FINEGAIN_ADDR,
LINEAR_VMAX_0_ADDR,
LINEAR_VMAX_1_ADDR,
LINEAR_FLIP_MIRROR_ADDR,
LINEAR_REGS_NUM
};
typedef enum _MIS2008_MODE_E {
MIS2008_MODE_1080P30 = 0,
MIS2008_MODE_NUM
} MIS2008_MODE_E;
typedef struct _MIS2008_MODE_S {
ISP_WDR_SIZE_S astImg[2];
CVI_FLOAT f32MaxFps;
CVI_FLOAT f32MinFps;
CVI_U32 u32HtsDef;
CVI_U32 u32VtsDef;
SNS_ATTR_LARGE_S stExp[2];
SNS_ATTR_LARGE_S stAgain[2];
SNS_ATTR_LARGE_S stDgain[2];
char name[64];
} MIS2008_MODE_S;
/****************************************************************************
* external variables and functions *
****************************************************************************/
extern ISP_SNS_STATE_S *g_pastMIS2008[VI_MAX_PIPE_NUM];
extern ISP_SNS_COMMBUS_U g_aunMIS2008_BusInfo[];
extern CVI_U16 g_au16MIS2008_GainMode[];
extern CVI_U16 g_au16MIS2008_L2SMode[];
extern CVI_U8 mis2008_i2c_addr;
extern const CVI_U32 mis2008_addr_byte;
extern const CVI_U32 mis2008_data_byte;
extern void mis2008_init(VI_PIPE ViPipe);
extern void mis2008_exit(VI_PIPE ViPipe);
extern void mis2008_standby(VI_PIPE ViPipe);
extern void mis2008_restart(VI_PIPE ViPipe);
extern int mis2008_write_register(VI_PIPE ViPipe, int addr, int data);
extern int mis2008_read_register(VI_PIPE ViPipe, int addr);
extern void mis2008_mirror_flip(VI_PIPE ViPipe, ISP_SNS_MIRRORFLIP_TYPE_E eSnsMirrorFlip);
extern int mis2008_probe(VI_PIPE ViPipe);
#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif /* End of #ifdef __cplusplus */
#endif /* __MIS2008_CMOS_EX_H_ */

View File

@ -0,0 +1,126 @@
#ifndef __MIS2008_CMOS_PARAM_H_
#define __MIS2008_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 "mis2008_cmos_ex.h"
static const MIS2008_MODE_S g_astMIS2008_mode[MIS2008_MODE_NUM] = {
[MIS2008_MODE_1080P30] = {
.name = "1080p30",
.astImg[0] = {
.stSnsSize = {
.u32Width = 1928,
.u32Height = 1088,
},
.stWndRect = {
.s32X = 8,
.s32Y = 8,
.u32Width = 1920,
.u32Height = 1080,
},
.stMaxSize = {
.u32Width = 1928,
.u32Height = 1088,
},
},
.f32MaxFps = 30,
.f32MinFps = 1, /* 1500 * 30 / 0x7FFF*/
.u32HtsDef = 2200,
.u32VtsDef = 1125,
.stExp[0] = {//exp_time
.u32Min = 1,
.u32Max = 1125 - 1, //exp_max
.u32Def = 128,
.u32Step = 1,
},
.stAgain[0] = {
.u32Min = 1024,
.u32Max = 16128,
.u32Def = 1024,
.u32Step = 1,
},
.stDgain[0] = {
.u32Min = 1024,
.u32Max = 16320,
.u32Def = 1024,
.u32Step = 1,
},
},
};
static ISP_CMOS_BLACK_LEVEL_S g_stIspBlcCalibratio = {
.bUpdate = CVI_TRUE,
.blcAttr = {
.Enable = 1,
.enOpType = OP_TYPE_AUTO,
.stManual = {64, 64, 64, 64, 0, 0, 0, 0
#ifdef ARCH_CV182X
, 1040, 1040, 1040, 1040
#endif
},
.stAuto = {
{64, 64, 64, 64, 64, 64, 64, 64, /*8*/64, 64, 64, 64, 64, 64, 64, 64},
{64, 64, 64, 64, 64, 64, 64, 64, /*8*/64, 64, 64, 64, 64, 64, 64, 64},
{64, 64, 64, 64, 64, 64, 64, 64, /*8*/64, 64, 64, 64, 64, 64, 64, 64},
{64, 64, 64, 64, 64, 64, 64, 64, /*8*/64, 64, 64, 64, 64, 64, 64, 64},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
#ifdef ARCH_CV182X
{1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040,
/*8*/1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040},
{1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040,
/*8*/1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040},
{1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040,
/*8*/1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040},
{1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040,
/*8*/1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040},
#endif
},
},
};
struct combo_dev_attr_s mis2008_rx_attr = {
.input_mode = INPUT_MODE_MIPI,
.mac_clk = RX_MAC_CLK_200M,
.mipi_attr = {
.raw_data_type = RAW_DATA_12BIT,
.lane_id = {2, 0, 1, -1, -1},
.pn_swap = {1, 1, 1, 0, 0},
.wdr_mode = CVI_MIPI_WDR_MODE_NONE,
.dphy = {
.enable = 1,
.hs_settle = 8,
},
},
.mclk = {
.cam = 1,
.freq = CAMPLL_FREQ_27M,
},
.devno = 0,
};
#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif /* End of #ifdef __cplusplus */
#endif /* __MIS2008_CMOS_PARAM_H_ */

View File

@ -0,0 +1,397 @@
#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 "mis2008_cmos_ex.h"
static void mis2008_linear_1080p30_init(VI_PIPE ViPipe);
CVI_U8 mis2008_i2c_addr = 0x30; /* I2C Address of MIS2008 */
const CVI_U32 mis2008_addr_byte = 2;
const CVI_U32 mis2008_data_byte = 1;
static int g_fd[VI_MAX_PIPE_NUM] = {[0 ... (VI_MAX_PIPE_NUM - 1)] = -1};
int mis2008_i2c_init(VI_PIPE ViPipe)
{
char acDevFile[16] = {0};
CVI_U8 u8DevNum;
if (g_fd[ViPipe] >= 0)
return CVI_SUCCESS;
int ret;
u8DevNum = g_aunMIS2008_BusInfo[ViPipe].s8I2cDev;
snprintf(acDevFile, sizeof(acDevFile), "/dev/i2c-%u", u8DevNum);
g_fd[ViPipe] = open(acDevFile, O_RDWR, 0600);
if (g_fd[ViPipe] < 0) {
CVI_TRACE_SNS(CVI_DBG_ERR, "Open /dev/cvi_i2c_drv-%u error!\n", u8DevNum);
return CVI_FAILURE;
}
ret = ioctl(g_fd[ViPipe], I2C_SLAVE_FORCE, mis2008_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 mis2008_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 mis2008_read_register(VI_PIPE ViPipe, int addr)
{
int ret, data;
CVI_U8 buf[8];
CVI_U8 idx = 0;
if (g_fd[ViPipe] < 0)
return CVI_FAILURE;
if (mis2008_addr_byte == 2)
buf[idx++] = (addr >> 8) & 0xff;
// add address byte 0
buf[idx++] = addr & 0xff;
ret = write(g_fd[ViPipe], buf, mis2008_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, mis2008_data_byte);
if (ret < 0) {
CVI_TRACE_SNS(CVI_DBG_ERR, "I2C_READ error!\n");
return ret;
}
// pack read back data
data = 0;
if (mis2008_data_byte == 2) {
data = buf[0] << 8;
data += buf[1];
} else {
data = buf[0];
}
syslog(LOG_DEBUG, "i2c r 0x%x = 0x%x\n", addr, data);
return data;
}
int mis2008_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 (mis2008_addr_byte == 2) {
buf[idx] = (addr >> 8) & 0xff;
idx++;
buf[idx] = addr & 0xff;
idx++;
}
if (mis2008_data_byte == 1) {
buf[idx] = data & 0xff;
idx++;
}
ret = write(g_fd[ViPipe], buf, mis2008_addr_byte + mis2008_data_byte);
if (ret < 0) {
CVI_TRACE_SNS(CVI_DBG_ERR, "I2C_WRITE error!\n");
return CVI_FAILURE;
}
syslog(LOG_DEBUG, "i2c w 0x%x 0x%x\n", addr, data);
return CVI_SUCCESS;
}
static void delay_ms(int ms)
{
usleep(ms * 1000);
}
void mis2008_standby(VI_PIPE ViPipe)
{
mis2008_write_register(ViPipe, 0x3006, 0x02);
}
void mis2008_restart(VI_PIPE ViPipe)
{
mis2008_write_register(ViPipe, 0x3006, 0x01);
}
void mis2008_default_reg_init(VI_PIPE ViPipe)
{
CVI_U32 i;
for (i = 0; i < g_pastMIS2008[ViPipe]->astSyncInfo[0].snsCfg.u32RegNum; i++) {
mis2008_write_register(ViPipe,
g_pastMIS2008[ViPipe]->astSyncInfo[0].snsCfg.astI2cData[i].u32RegAddr,
g_pastMIS2008[ViPipe]->astSyncInfo[0].snsCfg.astI2cData[i].u32Data);
}
}
#define MIS2008_CHIP_ID_HI_ADDR 0x3000
#define MIS2008_CHIP_ID_LO_ADDR 0x3001
#define MIS2008_CHIP_ID 0x2008
int mis2008_probe(VI_PIPE ViPipe)
{
int nVal;
CVI_U16 chip_id;
if (mis2008_i2c_init(ViPipe) != CVI_SUCCESS)
return CVI_FAILURE;
delay_ms(5);
nVal = mis2008_read_register(ViPipe, MIS2008_CHIP_ID_HI_ADDR);
if (nVal < 0) {
CVI_TRACE_SNS(CVI_DBG_ERR, "read sensor id error.\n");
return nVal;
}
chip_id = (nVal & 0xFF) << 8;
nVal = mis2008_read_register(ViPipe, MIS2008_CHIP_ID_LO_ADDR);
if (nVal < 0) {
CVI_TRACE_SNS(CVI_DBG_ERR, "read sensor id error.\n");
return nVal;
}
chip_id |= (nVal & 0xFF);
if (chip_id != MIS2008_CHIP_ID) {
CVI_TRACE_SNS(CVI_DBG_ERR, "Sensor ID Mismatch! Use the wrong sensor??\n");
return CVI_FAILURE;
}
return CVI_SUCCESS;
}
void mis2008_init(VI_PIPE ViPipe)
{
mis2008_i2c_init(ViPipe);
mis2008_linear_1080p30_init(ViPipe);
g_pastMIS2008[ViPipe]->bInit = CVI_TRUE;
}
void mis2008_exit(VI_PIPE ViPipe)
{
mis2008_i2c_exit(ViPipe);
}
/* 1080p30 */
static void mis2008_linear_1080p30_init(VI_PIPE ViPipe)
{
/* [ParaList] */
mis2008_write_register(ViPipe, 0x300a ,0x01);
mis2008_write_register(ViPipe, 0x3006 ,0x02);
mis2008_write_register(ViPipe, 0x3201 ,0x65);
mis2008_write_register(ViPipe, 0x3200 ,0x04);
mis2008_write_register(ViPipe, 0x3203 ,0x98);
mis2008_write_register(ViPipe, 0x3202 ,0x08);
mis2008_write_register(ViPipe, 0x3205 ,0x04);
mis2008_write_register(ViPipe, 0x3204 ,0x00);
mis2008_write_register(ViPipe, 0x3207 ,0x43);
mis2008_write_register(ViPipe, 0x3206 ,0x04);
mis2008_write_register(ViPipe, 0x3209 ,0x04);
mis2008_write_register(ViPipe, 0x3208 ,0x00);
mis2008_write_register(ViPipe, 0x320b ,0x8b);
mis2008_write_register(ViPipe, 0x320a ,0x07);
//mis2008_write_register(ViPipe, 0x3007 ,0x00);
mis2008_write_register(ViPipe, 0x3007 ,0x00);
mis2008_write_register(ViPipe, 0x3300 ,0x21);
mis2008_write_register(ViPipe, 0x3301 ,0x00);
mis2008_write_register(ViPipe, 0x3302 ,0x02);
mis2008_write_register(ViPipe, 0x3303 ,0x06);
mis2008_write_register(ViPipe, 0x330d ,0x00);
mis2008_write_register(ViPipe, 0x330b ,0x01);
mis2008_write_register(ViPipe, 0x330f ,0x0f);
mis2008_write_register(ViPipe, 0x3013 ,0x00);
mis2008_write_register(ViPipe, 0x3637 ,0x1e);
mis2008_write_register(ViPipe, 0x3900 ,0x07);
mis2008_write_register(ViPipe, 0x2107 ,0x00);
mis2008_write_register(ViPipe, 0x330e ,0x00);
mis2008_write_register(ViPipe, 0x3900 ,0x07);
mis2008_write_register(ViPipe, 0x2108 ,0x01);
mis2008_write_register(ViPipe, 0x3c40 ,0x8c);
mis2008_write_register(ViPipe, 0x3b01 ,0x3f);
mis2008_write_register(ViPipe, 0x3b03 ,0x3f);
mis2008_write_register(ViPipe, 0x3902 ,0x01);
mis2008_write_register(ViPipe, 0x3904 ,0x00);
mis2008_write_register(ViPipe, 0x3903 ,0x00);
mis2008_write_register(ViPipe, 0x3906 ,0x1e);
mis2008_write_register(ViPipe, 0x3905 ,0x00);
mis2008_write_register(ViPipe, 0x3908 ,0x71);
mis2008_write_register(ViPipe, 0x3907 ,0x10);
mis2008_write_register(ViPipe, 0x390a ,0xff);
mis2008_write_register(ViPipe, 0x3909 ,0x1f);
mis2008_write_register(ViPipe, 0x390c ,0x67);
mis2008_write_register(ViPipe, 0x390b ,0x03);
mis2008_write_register(ViPipe, 0x390e ,0x77);
mis2008_write_register(ViPipe, 0x390d ,0x00);
mis2008_write_register(ViPipe, 0x3910 ,0x71);
mis2008_write_register(ViPipe, 0x390f ,0x10);
mis2008_write_register(ViPipe, 0x3912 ,0xff);
mis2008_write_register(ViPipe, 0x3911 ,0x1f);
mis2008_write_register(ViPipe, 0x3919 ,0x00);
mis2008_write_register(ViPipe, 0x3918 ,0x00);
mis2008_write_register(ViPipe, 0x391b ,0x91);
mis2008_write_register(ViPipe, 0x391a ,0x01);
mis2008_write_register(ViPipe, 0x3983 ,0x5a);
mis2008_write_register(ViPipe, 0x3982 ,0x00);
mis2008_write_register(ViPipe, 0x3985 ,0x0f);
mis2008_write_register(ViPipe, 0x3984 ,0x00);
mis2008_write_register(ViPipe, 0x391d ,0x00);
mis2008_write_register(ViPipe, 0x391c ,0x00);
mis2008_write_register(ViPipe, 0x391f ,0x65);
mis2008_write_register(ViPipe, 0x391e ,0x10);
mis2008_write_register(ViPipe, 0x3921 ,0xff);
mis2008_write_register(ViPipe, 0x3920 ,0x1f);
mis2008_write_register(ViPipe, 0x3923 ,0xff);
mis2008_write_register(ViPipe, 0x3922 ,0x1f);
mis2008_write_register(ViPipe, 0x3932 ,0x00);
mis2008_write_register(ViPipe, 0x3931 ,0x00);
mis2008_write_register(ViPipe, 0x3934 ,0x65);
mis2008_write_register(ViPipe, 0x3933 ,0x01);
mis2008_write_register(ViPipe, 0x393f ,0x6c);
mis2008_write_register(ViPipe, 0x393e ,0x00);
mis2008_write_register(ViPipe, 0x3941 ,0x67);
mis2008_write_register(ViPipe, 0x3940 ,0x00);
mis2008_write_register(ViPipe, 0x3943 ,0x55);
mis2008_write_register(ViPipe, 0x3942 ,0x01);
mis2008_write_register(ViPipe, 0x3945 ,0xc2);
mis2008_write_register(ViPipe, 0x3944 ,0x02);
mis2008_write_register(ViPipe, 0x3925 ,0x95);
mis2008_write_register(ViPipe, 0x3924 ,0x00);
mis2008_write_register(ViPipe, 0x3927 ,0xe1);
mis2008_write_register(ViPipe, 0x3926 ,0x02);
mis2008_write_register(ViPipe, 0x3947 ,0x74);
mis2008_write_register(ViPipe, 0x3946 ,0x01);
mis2008_write_register(ViPipe, 0x3949 ,0xda);
mis2008_write_register(ViPipe, 0x3948 ,0x0e);
mis2008_write_register(ViPipe, 0x394b ,0x42);
mis2008_write_register(ViPipe, 0x394a ,0x03);
mis2008_write_register(ViPipe, 0x394d ,0xf2);
mis2008_write_register(ViPipe, 0x394c ,0x01);
mis2008_write_register(ViPipe, 0x3913 ,0x01);
mis2008_write_register(ViPipe, 0x3915 ,0x0f);
mis2008_write_register(ViPipe, 0x3914 ,0x00);
mis2008_write_register(ViPipe, 0x3917 ,0x67);
mis2008_write_register(ViPipe, 0x3916 ,0x03);
mis2008_write_register(ViPipe, 0x392a ,0x1e);
mis2008_write_register(ViPipe, 0x3929 ,0x00);
mis2008_write_register(ViPipe, 0x392c ,0x0f);
mis2008_write_register(ViPipe, 0x392b ,0x00);
mis2008_write_register(ViPipe, 0x392e ,0x0f);
mis2008_write_register(ViPipe, 0x392d ,0x00);
mis2008_write_register(ViPipe, 0x3930 ,0x6e);
mis2008_write_register(ViPipe, 0x392f ,0x03);
mis2008_write_register(ViPipe, 0x397f ,0x00);
mis2008_write_register(ViPipe, 0x397e ,0x00);
mis2008_write_register(ViPipe, 0x3981 ,0x77);
mis2008_write_register(ViPipe, 0x3980 ,0x00);
mis2008_write_register(ViPipe, 0x395d ,0x80);
mis2008_write_register(ViPipe, 0x395c ,0x10);
mis2008_write_register(ViPipe, 0x3962 ,0x9e);
mis2008_write_register(ViPipe, 0x3961 ,0x10);
mis2008_write_register(ViPipe, 0x3977 ,0x22);
mis2008_write_register(ViPipe, 0x3976 ,0x00);
mis2008_write_register(ViPipe, 0x3978 ,0x00);
mis2008_write_register(ViPipe, 0x3979 ,0x04);
mis2008_write_register(ViPipe, 0x396d ,0xc2);
mis2008_write_register(ViPipe, 0x396c ,0x02);
mis2008_write_register(ViPipe, 0x396f ,0xc2);
mis2008_write_register(ViPipe, 0x396e ,0x02);
mis2008_write_register(ViPipe, 0x3971 ,0xc2);
mis2008_write_register(ViPipe, 0x3970 ,0x02);
mis2008_write_register(ViPipe, 0x3973 ,0xc2);
mis2008_write_register(ViPipe, 0x3972 ,0x02);
mis2008_write_register(ViPipe, 0x3900 ,0x01);
mis2008_write_register(ViPipe, 0x3600 ,0x00);
mis2008_write_register(ViPipe, 0x3707 ,0x00);
mis2008_write_register(ViPipe, 0x3708 ,0x80);
mis2008_write_register(ViPipe, 0x3709 ,0x00);
mis2008_write_register(ViPipe, 0x370a ,0x80);
mis2008_write_register(ViPipe, 0x370b ,0x00);
mis2008_write_register(ViPipe, 0x370c ,0x80);
mis2008_write_register(ViPipe, 0x370d ,0x00);
mis2008_write_register(ViPipe, 0x370e ,0x80);
mis2008_write_register(ViPipe, 0x3006 ,0x00);
mis2008_write_register(ViPipe, 0x3012 ,0x01);
mis2008_write_register(ViPipe, 0x3600 ,0x13);
mis2008_write_register(ViPipe, 0x3601 ,0x02);
mis2008_write_register(ViPipe, 0x360e ,0x00);
mis2008_write_register(ViPipe, 0x360f ,0x00);
mis2008_write_register(ViPipe, 0x3610 ,0x02);
mis2008_write_register(ViPipe, 0x3707 ,0x00);
mis2008_write_register(ViPipe, 0x3708 ,0x40);
mis2008_write_register(ViPipe, 0x3709 ,0x00);
mis2008_write_register(ViPipe, 0x370a ,0x40);
mis2008_write_register(ViPipe, 0x370b ,0x00);
mis2008_write_register(ViPipe, 0x370c ,0x40);
mis2008_write_register(ViPipe, 0x370d ,0x00);
mis2008_write_register(ViPipe, 0x370e ,0x40);
mis2008_write_register(ViPipe, 0x3800 ,0x01);
mis2008_write_register(ViPipe, 0x3a03 ,0x03);
mis2008_write_register(ViPipe, 0x3a02 ,0x0b);
mis2008_write_register(ViPipe, 0x3a08 ,0x34);
mis2008_write_register(ViPipe, 0x3a1b ,0x54);
mis2008_write_register(ViPipe, 0x3a1e ,0x80);
mis2008_write_register(ViPipe, 0x3100 ,0x04);
mis2008_write_register(ViPipe, 0x3101 ,0x64);
mis2008_write_register(ViPipe, 0x3a1c ,0x10);
mis2008_write_register(ViPipe, 0x3a0C ,0x04);
mis2008_write_register(ViPipe, 0x3a0D ,0x12);
mis2008_write_register(ViPipe, 0x3a0E ,0x15);
mis2008_write_register(ViPipe, 0x3a0F ,0x18);
mis2008_write_register(ViPipe, 0x3a10 ,0x20);
mis2008_write_register(ViPipe, 0x3a11 ,0x3c);
mis2008_default_reg_init(ViPipe);
delay_ms(100);
printf("ViPipe:%d,===MIS2008 1080P 30fps 12bit LINE Init OK!===\n", ViPipe);
}

View File

@ -0,0 +1,36 @@
SHELL = /bin/bash
ifeq ($(PARAM_FILE), )
PARAM_FILE=../../../../../../$(shell echo $(MW_VER))/Makefile.param
include $(PARAM_FILE)
endif
SDIR = $(PWD)
SRCS = $(wildcard $(SDIR)/*.c)
INCS = -I$(MW_INC) -I$(ISP_INC) -I$(KERNEL_INC) -I./include
OBJS = $(SRCS:.c=.o)
DEPS = $(SRCS:.c=.d)
TARGET_A = $(MW_LIB)/libsns_tp2863.a
TARGET_SO = $(MW_LIB)/libsns_tp2863.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_SO): $(OBJS)
@$(LD) $(LDFLAGS) $(EXTRA_LDFLAGS) -o $@ --start-group $(OBJS) --end-group
@echo -e $(GREEN)[LINK]$(END)[$(notdir $(LD))] $(notdir $@)
clean:
@rm -f $(OBJS) $(DEPS) $(TARGET_A) $(TARGET_SO)
-include $(DEPS)

View File

@ -0,0 +1,336 @@
#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 "tp2863_cmos_ex.h"
#include "tp2863_cmos_param.h"
/****************************************************************************
* global variables *
****************************************************************************/
ISP_SNS_COMMBUS_U g_aunTP2863_BusInfo[VI_MAX_PIPE_NUM] = {
[0] = {.s8I2cDev = 0},
[1 ... VI_MAX_PIPE_NUM - 1] = {.s8I2cDev = -1}};
ISP_SNS_STATE_S *g_pastTP2863[VI_MAX_PIPE_NUM] = {CVI_NULL};
#define TP2863_SENSOR_GET_CTX(dev, pstCtx) (pstCtx = g_pastTP2863[dev])
#define TP2863_SENSOR_SET_CTX(dev, pstCtx) (g_pastTP2863[dev] = pstCtx)
#define TP2863_SENSOR_RESET_CTX(dev) (g_pastTP2863[dev] = CVI_NULL)
#define TP2863_RES_IS_720P_25(w, h, f) ((w) == 1280 && (h) == 720 && (f) == 25)
#define TP2863_RES_IS_720P_30(w, h, f) ((w) == 1280 && (h) == 720 && (f) == 30)
#define TP2863_RES_IS_1080P_25(w, h, f) ((w) == 1920 && (h) == 1080 && (f) == 25)
#define TP2863_RES_IS_1080P_30(w, h, f) ((w) == 1920 && (h) == 1080 && (f) == 30)
#define TP2863_ID 0x2863
/****************************************************************************
* local variables and functions *
****************************************************************************/
static CVI_S32 cmos_get_wdr_size(VI_PIPE ViPipe, ISP_SNS_ISP_INFO_S *pstIspCfg)
{
const TP2863_MODE_S *pstMode = CVI_NULL;
ISP_SNS_STATE_S *pstSnsState = CVI_NULL;
TP2863_SENSOR_GET_CTX(ViPipe, pstSnsState);
CMOS_CHECK_POINTER(pstSnsState);
pstMode = &g_astTP2863_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);
TP2863_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);
TP2863_SENSOR_GET_CTX(ViPipe, pstSnsState);
CMOS_CHECK_POINTER(pstSnsState);
u8SensorImageMode = pstSnsState->u8ImgMode;
if (pstSensorImageMode->f32Fps <= 30)
{
if (pstSnsState->enWDRMode == WDR_MODE_NONE) {
if (TP2863_RES_IS_720P_25(pstSensorImageMode->u16Width,
pstSensorImageMode->u16Height,
pstSensorImageMode->f32Fps)) {
u8SensorImageMode = TP2863_MODE_720P_25P;
} else if (TP2863_RES_IS_720P_30(pstSensorImageMode->u16Width,
pstSensorImageMode->u16Height,
pstSensorImageMode->f32Fps)) {
u8SensorImageMode = TP2863_MODE_720P_30P;
} else if (TP2863_RES_IS_1080P_25(pstSensorImageMode->u16Width,
pstSensorImageMode->u16Height,
pstSensorImageMode->f32Fps)) {
u8SensorImageMode = TP2863_MODE_1080P_25P;
} else if (TP2863_RES_IS_1080P_30(pstSensorImageMode->u16Width,
pstSensorImageMode->u16Height,
pstSensorImageMode->f32Fps)) {
u8SensorImageMode = TP2863_MODE_1080P_30P;
} 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;
}
}
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;
}
}
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;
TP2863_SENSOR_GET_CTX(ViPipe, pstSnsState);
CMOS_CHECK_POINTER_VOID(pstSnsState);
pstSnsState->bInit = CVI_FALSE;
pstSnsState->u8ImgMode = TP2863_MODE_1080P_25P;
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;
TP2863_SENSOR_GET_CTX(ViPipe, pstSnsState);
CMOS_CHECK_POINTER(pstSnsState);
CMOS_CHECK_POINTER(pstRxAttr);
memcpy(pstRxAttr, &tp2863_rx_attr, sizeof(*pstRxAttr));
// CVI_TRACE_SNS(CVI_DBG_INFO, "get tp2863_rx0_attr\n");
pstRxAttr->img_size.width = g_astTP2863_mode[pstSnsState->u8ImgMode].astImg[0].stSnsSize.u32Width;
pstRxAttr->img_size.height = g_astTP2863_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 = &tp2863_rx_attr;
int i;
CMOS_CHECK_POINTER(pstRxInitAttr);
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 = tp2863_init;
pstSensorExpFunc->pfn_cmos_sensor_exit = tp2863_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 tp2863_set_bus_info(VI_PIPE ViPipe, ISP_SNS_COMMBUS_U unSNSBusInfo)
{
g_aunTP2863_BusInfo[ViPipe].s8I2cDev = unSNSBusInfo.s8I2cDev;
return CVI_SUCCESS;
}
static CVI_S32 sensor_ctx_init(VI_PIPE ViPipe)
{
ISP_SNS_STATE_S *pastSnsStateCtx = CVI_NULL;
TP2863_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));
TP2863_SENSOR_SET_CTX(ViPipe, pastSnsStateCtx);
return CVI_SUCCESS;
}
static CVI_VOID sensor_ctx_exit(VI_PIPE ViPipe)
{
ISP_SNS_STATE_S *pastSnsStateCtx = CVI_NULL;
TP2863_SENSOR_GET_CTX(ViPipe, pastSnsStateCtx);
SENSOR_FREE(pastSnsStateCtx);
TP2863_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 = TP2863_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, TP2863_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;
}
ISP_SNS_OBJ_S stSnsTP2863_Obj = {
.pfnRegisterCallback = sensor_register_callback,
.pfnUnRegisterCallback = sensor_unregister_callback,
.pfnMirrorFlip = CVI_NULL,
.pfnStandby = CVI_NULL,
.pfnRestart = CVI_NULL,
.pfnWriteReg = tp2863_write_register,
.pfnReadReg = tp2863_read_register,
.pfnSetBusInfo = tp2863_set_bus_info,
.pfnSetInit = CVI_NULL,
.pfnPatchRxAttr = sensor_patch_rx_attr,
.pfnPatchI2cAddr = CVI_NULL,
.pfnGetRxAttr = sensor_rx_attr,
.pfnExpSensorCb = cmos_init_sensor_exp_function,
.pfnExpAeCb = CVI_NULL,
.pfnSnsProbe = CVI_NULL,
};

View File

@ -0,0 +1,63 @@
#ifndef __TP2863_CMOS_EX_H_
#define __TP2863_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 _TP2863_MODE_E
{
TP2863_MODE_1080P_30P,
TP2863_MODE_1080P_25P,
TP2863_MODE_720P_30P,
TP2863_MODE_720P_25P,
TP2863_MODE_NUM
} TP2863_MODE_E;
typedef struct _TP2863_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];
} TP2863_MODE_S;
/****************************************************************************
* external variables and functions *
****************************************************************************/
extern ISP_SNS_STATE_S *g_pastTP2863[VI_MAX_PIPE_NUM];
extern ISP_SNS_COMMBUS_U g_aunTP2863_BusInfo[];
extern const CVI_U8 tp2863_i2c_addr;
extern const CVI_U32 tp2863_addr_byte;
extern const CVI_U32 tp2863_data_byte;
extern void tp2863_init(VI_PIPE ViPipe);
extern void tp2863_exit(VI_PIPE ViPipe);
extern void tp2863_standby(VI_PIPE ViPipe);
extern void tp2863_restart(VI_PIPE ViPipe);
extern int tp2863_write_register(VI_PIPE ViPipe, int addr, int data);
extern int tp2863_read_register(VI_PIPE ViPipe, int addr);
#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif /* End of #ifdef __cplusplus */
#endif /* __TP2863_CMOS_EX_H_ */

View File

@ -0,0 +1,123 @@
#ifndef __TP2863_CMOS_PARAM_H_
#define __TP2863_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 "tp2863_cmos_ex.h"
static const TP2863_MODE_S g_astTP2863_mode[TP2863_MODE_NUM] = {
[TP2863_MODE_1080P_30P] = {
.name = "1080p30",
.astImg[0] = {
.stSnsSize = {
.u32Width = 1920,
.u32Height = 1080,
},
.stWndRect = {
.s32X = 0,
.s32Y = 0,
.u32Width = 1920,
.u32Height = 1080,
},
.stMaxSize = {
.u32Width = 1920,
.u32Height = 1080,
},
},
},
[TP2863_MODE_1080P_25P] = {
.name = "1080p25",
.astImg[0] = {
.stSnsSize = {
.u32Width = 1920,
.u32Height = 1080,
},
.stWndRect = {
.s32X = 0,
.s32Y = 0,
.u32Width = 1920,
.u32Height = 1080,
},
.stMaxSize = {
.u32Width = 1920,
.u32Height = 1080,
},
},
},
[TP2863_MODE_720P_30P] = {
.name = "720p30",
.astImg[0] = {
.stSnsSize = {
.u32Width = 1280,
.u32Height = 720,
},
.stWndRect = {
.s32X = 0,
.s32Y = 0,
.u32Width = 1280,
.u32Height = 720,
},
.stMaxSize = {
.u32Width = 1280,
.u32Height = 720,
},
},
},
[TP2863_MODE_720P_25P] = {
.name = "720p25",
.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 tp2863_rx_attr = {
.input_mode = INPUT_MODE_MIPI,
.mac_clk = RX_MAC_CLK_400M,
.mipi_attr = {
.raw_data_type = YUV422_8BIT,
.lane_id = {0, 2, 1, -1, -1},
.wdr_mode = CVI_MIPI_WDR_MODE_NONE,
},
.mclk = {
.cam = 0,
.freq = CAMPLL_FREQ_NONE,
},
.devno = 0,
};
#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif /* End of #ifdef __cplusplus */
#endif /* __TP2863_CMOS_PARAM_H_ */

View File

@ -0,0 +1,593 @@
#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 "tp2863_cmos_ex.h"
const CVI_U8 tp2863_i2c_addr = 0x44; /* I2C slave address of TP2863, SA0=0:0x44, SA0=1:0x45*/
const CVI_U32 tp2863_addr_byte = 1;
const CVI_U32 tp2863_data_byte = 1;
static int g_fd[VI_MAX_PIPE_NUM] = {[0 ...(VI_MAX_PIPE_NUM - 1)] = -1};
#define TP2863_BLUE_SCREEN 0
enum
{
CH_1 = 0,
CH_2 = 1,
CH_ALL = 4,
MIPI_PAGE = 8,
};
enum
{
STD_TVI, // TVI
STD_HDA, // AHD
};
enum
{
HD25,
HD30, // 1280x720
FHD25,
FHD30, // 1920x1080
};
enum
{
MIPI_1CH2LANE_297M,
MIPI_1CH2LANE_594M,
MIPI_2CH2LANE_594M,
MIPI_2CH2LANE_297M,
};
int tp2863_i2c_init(VI_PIPE ViPipe)
{
char acDevFile[16] = {0};
CVI_U8 u8DevNum;
int ret;
if (g_fd[ViPipe] >= 0)
return CVI_SUCCESS;
u8DevNum = g_aunTP2863_BusInfo[ViPipe].s8I2cDev;
snprintf(acDevFile, sizeof(acDevFile), "/dev/i2c-%u", u8DevNum);
syslog(LOG_DEBUG, "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, tp2863_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 tp2863_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 tp2863_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 (tp2863_addr_byte == 2)
buf[idx++] = (addr >> 8) & 0xff;
// add address byte 0
buf[idx++] = addr & 0xff;
ret = write(g_fd[ViPipe], buf, tp2863_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, tp2863_data_byte);
if (ret < 0)
{
CVI_TRACE_SNS(CVI_DBG_ERR, "I2C_READ error!\n");
return 0;
}
// pack read back data
data = 0;
if (tp2863_data_byte == 2)
{
data = buf[0] << 8;
data += buf[1];
}
else
{
data = buf[0];
}
syslog(LOG_DEBUG, "i2c r 0x%x = 0x%x\n", addr, data);
return data;
}
int tp2863_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 (tp2863_addr_byte == 2)
buf[idx++] = (addr >> 8) & 0xff;
// add address byte 0
buf[idx++] = addr & 0xff;
if (tp2863_data_byte == 2)
buf[idx++] = (data >> 8) & 0xff;
// add data byte 0
buf[idx++] = data & 0xff;
ret = write(g_fd[ViPipe], buf, tp2863_addr_byte + tp2863_data_byte);
if (ret < 0)
{
CVI_TRACE_SNS(CVI_DBG_ERR, "I2C_WRITE error!\n");
return CVI_FAILURE;
}
syslog(LOG_DEBUG, "i2c w 0x%x 0x%x\n", addr, data);
#if 0 // read back checing
ret = tp2863_read_register(ViPipe, addr);
if (ret != data)
syslog(LOG_DEBUG, "i2c readback-check fail, 0x%x != 0x%x\n", ret, data);
#endif
return CVI_SUCCESS;
}
void TP2863_decoder_init(VI_PIPE ViPipe, unsigned char ch, unsigned char fmt, unsigned char std)
{
unsigned char tmp;
const unsigned char REG42_43[] = {0x01, 0x02, 0x00, 0x00, 0x03};
const unsigned char MASK42_43[] = {0xfe, 0xfd, 0xff, 0xff, 0xfc};
tp2863_write_register(ViPipe, 0x40, ch);
tp2863_write_register(ViPipe, 0x06, 0x12); // default value
tp2863_write_register(ViPipe, 0x50, 0x00); // VIN1/3
tp2863_write_register(ViPipe, 0x51, 0x00);
tp2863_write_register(ViPipe, 0x54, 0x03);
if (HD25 == fmt)
{
tmp = tp2863_read_register(ViPipe, 0x42);
tmp |= REG42_43[ch];
tp2863_write_register(ViPipe, 0x42, tmp);
tmp = tp2863_read_register(ViPipe, 0x43);
tmp &= MASK42_43[ch];
tp2863_write_register(ViPipe, 0x43, tmp);
tp2863_write_register(ViPipe, 0x02, 0x42);
tp2863_write_register(ViPipe, 0x07, 0xc0);
tp2863_write_register(ViPipe, 0x0b, 0xc0);
tp2863_write_register(ViPipe, 0x0c, 0x13);
tp2863_write_register(ViPipe, 0x0d, 0x50);
tp2863_write_register(ViPipe, 0x15, 0x13);
tp2863_write_register(ViPipe, 0x16, 0x15);
tp2863_write_register(ViPipe, 0x17, 0x00);
tp2863_write_register(ViPipe, 0x18, 0x19);
tp2863_write_register(ViPipe, 0x19, 0xd0);
tp2863_write_register(ViPipe, 0x1a, 0x25);
tp2863_write_register(ViPipe, 0x1c, 0x07); // 1280*720, 25fps
tp2863_write_register(ViPipe, 0x1d, 0xbc); // 1280*720, 25fps
tp2863_write_register(ViPipe, 0x20, 0x30);
tp2863_write_register(ViPipe, 0x21, 0x84);
tp2863_write_register(ViPipe, 0x22, 0x36);
tp2863_write_register(ViPipe, 0x23, 0x3c);
tp2863_write_register(ViPipe, 0x2b, 0x60);
tp2863_write_register(ViPipe, 0x2c, 0x0a);
tp2863_write_register(ViPipe, 0x2d, 0x30);
tp2863_write_register(ViPipe, 0x2e, 0x70);
tp2863_write_register(ViPipe, 0x30, 0x48);
tp2863_write_register(ViPipe, 0x31, 0xbb);
tp2863_write_register(ViPipe, 0x32, 0x2e);
tp2863_write_register(ViPipe, 0x33, 0x90);
tp2863_write_register(ViPipe, 0x35, 0x25);
tp2863_write_register(ViPipe, 0x39, 0x08);
if (STD_HDA == std)
{
tp2863_write_register(ViPipe, 0x02, 0x46);
tp2863_write_register(ViPipe, 0x0d, 0x71);
tp2863_write_register(ViPipe, 0x20, 0x40);
tp2863_write_register(ViPipe, 0x21, 0x46);
tp2863_write_register(ViPipe, 0x25, 0xfe);
tp2863_write_register(ViPipe, 0x26, 0x01);
tp2863_write_register(ViPipe, 0x2c, 0x3a);
tp2863_write_register(ViPipe, 0x2d, 0x5a);
tp2863_write_register(ViPipe, 0x2e, 0x40);
tp2863_write_register(ViPipe, 0x30, 0x9e);
tp2863_write_register(ViPipe, 0x31, 0x20);
tp2863_write_register(ViPipe, 0x32, 0x10);
tp2863_write_register(ViPipe, 0x33, 0x90);
}
}
else if (HD30 == fmt)
{
tmp = tp2863_read_register(ViPipe, 0x42);
tmp |= REG42_43[ch];
tp2863_write_register(ViPipe, 0x42, tmp);
tmp = tp2863_read_register(ViPipe, 0x43);
tmp &= MASK42_43[ch];
tp2863_write_register(ViPipe, 0x43, tmp);
tp2863_write_register(ViPipe, 0x02, 0x42);
tp2863_write_register(ViPipe, 0x07, 0xc0);
tp2863_write_register(ViPipe, 0x0b, 0xc0);
tp2863_write_register(ViPipe, 0x0c, 0x13);
tp2863_write_register(ViPipe, 0x0d, 0x50);
tp2863_write_register(ViPipe, 0x15, 0x13);
tp2863_write_register(ViPipe, 0x16, 0x15);
tp2863_write_register(ViPipe, 0x17, 0x00);
tp2863_write_register(ViPipe, 0x18, 0x19);
tp2863_write_register(ViPipe, 0x19, 0xd0);
tp2863_write_register(ViPipe, 0x1a, 0x25);
tp2863_write_register(ViPipe, 0x1c, 0x06); // 1280*720, 30fps
tp2863_write_register(ViPipe, 0x1d, 0x72); // 1280*720, 30fps
tp2863_write_register(ViPipe, 0x20, 0x30);
tp2863_write_register(ViPipe, 0x21, 0x84);
tp2863_write_register(ViPipe, 0x22, 0x36);
tp2863_write_register(ViPipe, 0x23, 0x3c);
tp2863_write_register(ViPipe, 0x2b, 0x60);
tp2863_write_register(ViPipe, 0x2c, 0x0a);
tp2863_write_register(ViPipe, 0x2d, 0x30);
tp2863_write_register(ViPipe, 0x2e, 0x70);
tp2863_write_register(ViPipe, 0x30, 0x48);
tp2863_write_register(ViPipe, 0x31, 0xbb);
tp2863_write_register(ViPipe, 0x32, 0x2e);
tp2863_write_register(ViPipe, 0x33, 0x90);
tp2863_write_register(ViPipe, 0x35, 0x25);
tp2863_write_register(ViPipe, 0x39, 0x08);
if (STD_HDA == std)
{
tp2863_write_register(ViPipe, 0x02, 0x46);
tp2863_write_register(ViPipe, 0x0d, 0x70);
tp2863_write_register(ViPipe, 0x20, 0x40);
tp2863_write_register(ViPipe, 0x21, 0x46);
tp2863_write_register(ViPipe, 0x25, 0xfe);
tp2863_write_register(ViPipe, 0x26, 0x01);
tp2863_write_register(ViPipe, 0x2c, 0x3a);
tp2863_write_register(ViPipe, 0x2d, 0x5a);
tp2863_write_register(ViPipe, 0x2e, 0x40);
tp2863_write_register(ViPipe, 0x30, 0x9d);
tp2863_write_register(ViPipe, 0x31, 0xca);
tp2863_write_register(ViPipe, 0x32, 0x01);
tp2863_write_register(ViPipe, 0x33, 0xd0);
}
}
else if (FHD25 == fmt)
{
tmp = tp2863_read_register(ViPipe, 0x42);
tmp &= MASK42_43[ch];
tp2863_write_register(ViPipe, 0x42, tmp);
tmp = tp2863_read_register(ViPipe, 0x43);
tmp &= MASK42_43[ch];
tp2863_write_register(ViPipe, 0x43, tmp);
tp2863_write_register(ViPipe, 0x02, 0x40);
tp2863_write_register(ViPipe, 0x07, 0xc0);
tp2863_write_register(ViPipe, 0x0b, 0xc0);
tp2863_write_register(ViPipe, 0x0c, 0x03);
tp2863_write_register(ViPipe, 0x0d, 0x50);
tp2863_write_register(ViPipe, 0x15, 0x03);
tp2863_write_register(ViPipe, 0x16, 0xd2);
tp2863_write_register(ViPipe, 0x17, 0x80);
tp2863_write_register(ViPipe, 0x18, 0x29);
tp2863_write_register(ViPipe, 0x19, 0x38);
tp2863_write_register(ViPipe, 0x1a, 0x47);
tp2863_write_register(ViPipe, 0x1c, 0x0a); // 1920*1080, 25fps
tp2863_write_register(ViPipe, 0x1d, 0x50); //
tp2863_write_register(ViPipe, 0x20, 0x30);
tp2863_write_register(ViPipe, 0x21, 0x84);
tp2863_write_register(ViPipe, 0x22, 0x36);
tp2863_write_register(ViPipe, 0x23, 0x3c);
tp2863_write_register(ViPipe, 0x2b, 0x60);
tp2863_write_register(ViPipe, 0x2c, 0x0a);
tp2863_write_register(ViPipe, 0x2d, 0x30);
tp2863_write_register(ViPipe, 0x2e, 0x70);
tp2863_write_register(ViPipe, 0x30, 0x48);
tp2863_write_register(ViPipe, 0x31, 0xbb);
tp2863_write_register(ViPipe, 0x32, 0x2e);
tp2863_write_register(ViPipe, 0x33, 0x90);
tp2863_write_register(ViPipe, 0x35, 0x05);
tp2863_write_register(ViPipe, 0x39, 0x0C);
if (STD_HDA == std)
{
tp2863_write_register(ViPipe, 0x02, 0x44);
tp2863_write_register(ViPipe, 0x0d, 0x73);
tp2863_write_register(ViPipe, 0x15, 0x01);
tp2863_write_register(ViPipe, 0x16, 0xf0);
tp2863_write_register(ViPipe, 0x18, 0x2a);
tp2863_write_register(ViPipe, 0x20, 0x3c);
tp2863_write_register(ViPipe, 0x21, 0x46);
tp2863_write_register(ViPipe, 0x25, 0xfe);
tp2863_write_register(ViPipe, 0x26, 0x0d);
tp2863_write_register(ViPipe, 0x2c, 0x3a);
tp2863_write_register(ViPipe, 0x2d, 0x54);
tp2863_write_register(ViPipe, 0x2e, 0x40);
tp2863_write_register(ViPipe, 0x30, 0xa5);
tp2863_write_register(ViPipe, 0x31, 0x86);
tp2863_write_register(ViPipe, 0x32, 0xfb);
tp2863_write_register(ViPipe, 0x33, 0x60);
}
}
else if (FHD30 == fmt)
{
tmp = tp2863_read_register(ViPipe, 0x42);
tmp &= MASK42_43[ch];
tp2863_write_register(ViPipe, 0x42, tmp);
tmp = tp2863_read_register(ViPipe, 0x43);
tmp &= MASK42_43[ch];
tp2863_write_register(ViPipe, 0x43, tmp);
tp2863_write_register(ViPipe, 0x02, 0x40);
tp2863_write_register(ViPipe, 0x07, 0xc0);
tp2863_write_register(ViPipe, 0x0b, 0xc0);
tp2863_write_register(ViPipe, 0x0c, 0x03);
tp2863_write_register(ViPipe, 0x0d, 0x50);
tp2863_write_register(ViPipe, 0x15, 0x03);
tp2863_write_register(ViPipe, 0x16, 0xd2);
tp2863_write_register(ViPipe, 0x17, 0x80);
tp2863_write_register(ViPipe, 0x18, 0x29);
tp2863_write_register(ViPipe, 0x19, 0x38);
tp2863_write_register(ViPipe, 0x1a, 0x47);
tp2863_write_register(ViPipe, 0x1c, 0x08); // 1920*1080, 30fps
tp2863_write_register(ViPipe, 0x1d, 0x98); //
tp2863_write_register(ViPipe, 0x20, 0x30);
tp2863_write_register(ViPipe, 0x21, 0x84);
tp2863_write_register(ViPipe, 0x22, 0x36);
tp2863_write_register(ViPipe, 0x23, 0x3c);
tp2863_write_register(ViPipe, 0x2b, 0x60);
tp2863_write_register(ViPipe, 0x2c, 0x0a);
tp2863_write_register(ViPipe, 0x2d, 0x30);
tp2863_write_register(ViPipe, 0x2e, 0x70);
tp2863_write_register(ViPipe, 0x30, 0x48);
tp2863_write_register(ViPipe, 0x31, 0xbb);
tp2863_write_register(ViPipe, 0x32, 0x2e);
tp2863_write_register(ViPipe, 0x33, 0x90);
tp2863_write_register(ViPipe, 0x35, 0x05);
tp2863_write_register(ViPipe, 0x39, 0x0C);
if (STD_HDA == std)
{
tp2863_write_register(ViPipe, 0x02, 0x44);
tp2863_write_register(ViPipe, 0x0d, 0x72);
tp2863_write_register(ViPipe, 0x15, 0x01);
tp2863_write_register(ViPipe, 0x16, 0xf0);
tp2863_write_register(ViPipe, 0x18, 0x2a);
tp2863_write_register(ViPipe, 0x20, 0x38);
tp2863_write_register(ViPipe, 0x21, 0x46);
tp2863_write_register(ViPipe, 0x25, 0xfe);
tp2863_write_register(ViPipe, 0x26, 0x0d);
tp2863_write_register(ViPipe, 0x2c, 0x3a);
tp2863_write_register(ViPipe, 0x2d, 0x54);
tp2863_write_register(ViPipe, 0x2e, 0x40);
tp2863_write_register(ViPipe, 0x30, 0xa5);
tp2863_write_register(ViPipe, 0x31, 0x95);
tp2863_write_register(ViPipe, 0x32, 0xe0);
tp2863_write_register(ViPipe, 0x33, 0x60);
}
}
}
void TP2863_mipi_out(VI_PIPE ViPipe, unsigned char output)
{
// mipi setting
tp2863_write_register(ViPipe, 0x40, MIPI_PAGE); // MIPI page
tp2863_write_register(ViPipe, 0x02, 0x78);
tp2863_write_register(ViPipe, 0x03, 0x70);
tp2863_write_register(ViPipe, 0x04, 0x70);
tp2863_write_register(ViPipe, 0x05, 0x70);
tp2863_write_register(ViPipe, 0x06, 0x70);
tp2863_write_register(ViPipe, 0x13, 0xef);
tp2863_write_register(ViPipe, 0x20, 0x00);
tp2863_write_register(ViPipe, 0x21, 0x22);
tp2863_write_register(ViPipe, 0x22, 0x20);
tp2863_write_register(ViPipe, 0x23, 0x9e);
if (MIPI_1CH2LANE_297M == output)
{
tp2863_write_register(ViPipe, 0x21, 0x12);
tp2863_write_register(ViPipe, 0x14, 0x41);
tp2863_write_register(ViPipe, 0x15, 0x02);
tp2863_write_register(ViPipe, 0x2a, 0x04);
tp2863_write_register(ViPipe, 0x2b, 0x03);
tp2863_write_register(ViPipe, 0x2c, 0x09);
tp2863_write_register(ViPipe, 0x2e, 0x02);
tp2863_write_register(ViPipe, 0x10, 0xa0);
tp2863_write_register(ViPipe, 0x10, 0x20);
}
else if (MIPI_1CH2LANE_594M == output)
{
tp2863_write_register(ViPipe, 0x21, 0x12);
tp2863_write_register(ViPipe, 0x14, 0x00); // clk
tp2863_write_register(ViPipe, 0x15, 0x01); // clk
tp2863_write_register(ViPipe, 0x2a, 0x08); // LPX
tp2863_write_register(ViPipe, 0x2b, 0x08); // PREP
tp2863_write_register(ViPipe, 0x2c, 0x10); // TRAIL/HS ZERO
tp2863_write_register(ViPipe, 0x2e, 0x0a);
tp2863_write_register(ViPipe, 0x10, 0xa0);
tp2863_write_register(ViPipe, 0x10, 0x20);
}
else if (MIPI_2CH2LANE_297M == output)
{
tp2863_write_register(ViPipe, 0x21, 0x22);
tp2863_write_register(ViPipe, 0x14, 0x41);
tp2863_write_register(ViPipe, 0x15, 0x02);
tp2863_write_register(ViPipe, 0x2a, 0x04);
tp2863_write_register(ViPipe, 0x2b, 0x03);
tp2863_write_register(ViPipe, 0x2c, 0x09);
tp2863_write_register(ViPipe, 0x2e, 0x02);
tp2863_write_register(ViPipe, 0x10, 0xa0);
tp2863_write_register(ViPipe, 0x10, 0x20);
}
else if (MIPI_2CH2LANE_594M == output)
{
tp2863_write_register(ViPipe, 0x21, 0x22);
tp2863_write_register(ViPipe, 0x14, 0x00);
tp2863_write_register(ViPipe, 0x15, 0x01);
tp2863_write_register(ViPipe, 0x2a, 0x08);
tp2863_write_register(ViPipe, 0x2b, 0x08);
tp2863_write_register(ViPipe, 0x2c, 0x10);
tp2863_write_register(ViPipe, 0x2e, 0x0a);
tp2863_write_register(ViPipe, 0x10, 0xa0);
tp2863_write_register(ViPipe, 0x10, 0x20);
}
/* Enable MIPI CSI2 output */
tp2863_write_register(ViPipe, 0x28, 0x02);
tp2863_write_register(ViPipe, 0x28, 0x00);
}
void TP2863_reg_init(VI_PIPE ViPipe, CVI_U8 u8ImgMode)
{
if (u8ImgMode == TP2863_MODE_1080P_30P)
{
TP2863_decoder_init(ViPipe, CH_1, FHD30, STD_HDA);
TP2863_mipi_out(ViPipe, MIPI_1CH2LANE_297M);
printf("Techpoint TP2863 1080 FHD30\n");
}
else if (u8ImgMode == TP2863_MODE_1080P_25P)
{
TP2863_decoder_init(ViPipe, CH_1, FHD25, STD_HDA);
TP2863_mipi_out(ViPipe, MIPI_1CH2LANE_297M);
printf("Techpoint TP2863 720 FHD25\n");
}
else if (u8ImgMode == TP2863_MODE_720P_30P)
{
TP2863_decoder_init(ViPipe, CH_1, HD30, STD_HDA);
TP2863_mipi_out(ViPipe, MIPI_1CH2LANE_297M);
printf("Techpoint TP2863 720 HD30\n");
}
else if (u8ImgMode == TP2863_MODE_720P_25P)
{
TP2863_decoder_init(ViPipe, CH_1, HD25, STD_HDA);
TP2863_mipi_out(ViPipe, MIPI_1CH2LANE_297M);
printf("Techpoint TP2863 720 HD25\n");
}
}
void tp2863_init(VI_PIPE ViPipe)
{
tp2863_i2c_init(ViPipe);
syslog(LOG_DEBUG, "Loading Techpoint TP2863 sensor\n");
// check sensor chip id
tp2863_write_register(ViPipe, 0x40, 0x0);
if (tp2863_read_register(ViPipe, 0xfe) != 0x28 ||
tp2863_read_register(ViPipe, 0xff) != 0x63)
{
syslog(LOG_DEBUG, "read TP2863 chip id fail\n");
return;
}
TP2863_reg_init(ViPipe, g_pastTP2863[ViPipe]->u8ImgMode);
usleep(500 * 1000);
#if TP2863_BLUE_SCREEN
tp2863_write_register(ViPipe, 0x40, 0x00);
tp2863_write_register(ViPipe, 0x2A, 0x3C);
#endif
}
void tp2863_exit(VI_PIPE ViPipe)
{
tp2863_i2c_exit(ViPipe);
}

View File

@ -0,0 +1,27 @@
#ifndef _BT656_TP2803_H_
#define _BT656_TP2803_H_
#include <linux/cvi_comm_vo.h>
const struct VO_BT_PINS tp2803_pins_cfg = {
.pin_num = 9,
.d_pins = {
{VO_VIVO_D0, VO_MUX_BT_DATA0},
{VO_VIVO_D1, VO_MUX_BT_DATA1},
{VO_VIVO_D2, VO_MUX_BT_DATA2},
{VO_VIVO_D3, VO_MUX_BT_DATA3},
{VO_VIVO_D4, VO_MUX_BT_DATA4},
{VO_VIVO_D5, VO_MUX_BT_DATA5},
{VO_VIVO_D6, VO_MUX_BT_DATA6},
{VO_VIVO_D7, VO_MUX_BT_DATA7},
{VO_VIVO_CLK, VO_MUX_BT_VS}
}
};
const VO_BT_ATTR_S stTP2803Cfg = {
.pins = tp2803_pins_cfg,
.mode = VO_BT_MODE_656,
.bt_clk = VO_BT_CLK_MODE_72M,
};
#endif // _I80_PARAM_ST7789V_H_

View File

@ -17,7 +17,7 @@
#define PIXEL_CLK(x) ((x##_VACT + x##_VSA + x##_VBP + x##_VFP) \ #define PIXEL_CLK(x) ((x##_VACT + x##_VSA + x##_VBP + x##_VFP) \
* (x##_HACT + x##_HSA + x##_HBP + x##_HFP) * 60 / 1000) * (x##_HACT + x##_HSA + x##_HBP + x##_HFP) * 60 / 1000)
const struct combo_dev_cfg_s dev_cfg_3AML069LP01G_600x1024 = { struct combo_dev_cfg_s dev_cfg_3AML069LP01G_600x1024 = {
.devno = 0, .devno = 0,
#ifdef MIPI_PANEL_2_LANES #ifdef MIPI_PANEL_2_LANES
.lane_id = {MIPI_TX_LANE_0, MIPI_TX_LANE_1, MIPI_TX_LANE_CLK, -1, -1}, .lane_id = {MIPI_TX_LANE_0, MIPI_TX_LANE_1, MIPI_TX_LANE_CLK, -1, -1},

View File

@ -4,7 +4,7 @@
#include <linux/vo_mipi_tx.h> #include <linux/vo_mipi_tx.h>
#include <linux/cvi_comm_mipi_tx.h> #include <linux/cvi_comm_mipi_tx.h>
const struct combo_dev_cfg_s dev_cfg_hx8394_720x1280 = { struct combo_dev_cfg_s dev_cfg_hx8394_720x1280 = {
.devno = 0, .devno = 0,
#ifdef MIPI_PANEL_2_LANES #ifdef MIPI_PANEL_2_LANES
.lane_id = {MIPI_TX_LANE_0, MIPI_TX_LANE_1, MIPI_TX_LANE_CLK, -1, -1}, .lane_id = {MIPI_TX_LANE_0, MIPI_TX_LANE_1, MIPI_TX_LANE_CLK, -1, -1},

View File

@ -17,7 +17,7 @@
#define PIXEL_CLK(x) ((x##_VACT + x##_VSA + x##_VBP + x##_VFP) \ #define PIXEL_CLK(x) ((x##_VACT + x##_VSA + x##_VBP + x##_VFP) \
* (x##_HACT + x##_HSA + x##_HBP + x##_HFP) * 60 / 1000) * (x##_HACT + x##_HSA + x##_HBP + x##_HFP) * 60 / 1000)
const struct combo_dev_cfg_s dev_cfg_hx8399_1080x1920 = { struct combo_dev_cfg_s dev_cfg_hx8399_1080x1920 = {
.devno = 0, .devno = 0,
#ifdef MIPI_PANEL_2_LANES #ifdef MIPI_PANEL_2_LANES
.lane_id = {MIPI_TX_LANE_0, MIPI_TX_LANE_1, MIPI_TX_LANE_CLK, -1, -1}, .lane_id = {MIPI_TX_LANE_0, MIPI_TX_LANE_1, MIPI_TX_LANE_CLK, -1, -1},

View File

@ -4,7 +4,7 @@
#include <linux/vo_mipi_tx.h> #include <linux/vo_mipi_tx.h>
#include <linux/cvi_comm_mipi_tx.h> #include <linux/cvi_comm_mipi_tx.h>
const struct combo_dev_cfg_s dev_cfg_icn9707_480x1920 = { struct combo_dev_cfg_s dev_cfg_icn9707_480x1920 = {
.devno = 0, .devno = 0,
.lane_id = {MIPI_TX_LANE_3, MIPI_TX_LANE_2, MIPI_TX_LANE_CLK, MIPI_TX_LANE_1, MIPI_TX_LANE_0}, .lane_id = {MIPI_TX_LANE_3, MIPI_TX_LANE_2, MIPI_TX_LANE_CLK, MIPI_TX_LANE_1, MIPI_TX_LANE_0},
.lane_pn_swap = {true, true, true, true, true}, .lane_pn_swap = {true, true, true, true, true},

View File

@ -4,7 +4,7 @@
#include <linux/vo_mipi_tx.h> #include <linux/vo_mipi_tx.h>
#include <linux/cvi_comm_mipi_tx.h> #include <linux/cvi_comm_mipi_tx.h>
const struct combo_dev_cfg_s dev_cfg_ili9881c_720x1280 = { struct combo_dev_cfg_s dev_cfg_ili9881c_720x1280 = {
.devno = 0, .devno = 0,
.lane_id = {MIPI_TX_LANE_0, MIPI_TX_LANE_1, MIPI_TX_LANE_CLK, MIPI_TX_LANE_2, MIPI_TX_LANE_3}, .lane_id = {MIPI_TX_LANE_0, MIPI_TX_LANE_1, MIPI_TX_LANE_CLK, MIPI_TX_LANE_2, MIPI_TX_LANE_3},
.lane_pn_swap = {false, false, false, false, false}, .lane_pn_swap = {false, false, false, false, false},

View File

@ -4,7 +4,7 @@
#include <linux/vo_mipi_tx.h> #include <linux/vo_mipi_tx.h>
#include <linux/cvi_comm_mipi_tx.h> #include <linux/cvi_comm_mipi_tx.h>
const struct combo_dev_cfg_s dev_cfg_ili9881d_720x1280 = { struct combo_dev_cfg_s dev_cfg_ili9881d_720x1280 = {
.devno = 0, .devno = 0,
.lane_id = {MIPI_TX_LANE_0, MIPI_TX_LANE_1, MIPI_TX_LANE_2, MIPI_TX_LANE_CLK, MIPI_TX_LANE_3}, .lane_id = {MIPI_TX_LANE_0, MIPI_TX_LANE_1, MIPI_TX_LANE_2, MIPI_TX_LANE_CLK, MIPI_TX_LANE_3},
.lane_pn_swap = {false, false, false, false, false}, .lane_pn_swap = {false, false, false, false, false},

View File

@ -4,7 +4,7 @@
#include <linux/vo_mipi_tx.h> #include <linux/vo_mipi_tx.h>
#include <linux/cvi_comm_mipi_tx.h> #include <linux/cvi_comm_mipi_tx.h>
const struct combo_dev_cfg_s dev_cfg_jd9366ab_800x1280 = { struct combo_dev_cfg_s dev_cfg_jd9366ab_800x1280 = {
.devno = 0, .devno = 0,
.lane_id = {MIPI_TX_LANE_0, MIPI_TX_LANE_1, MIPI_TX_LANE_CLK, MIPI_TX_LANE_3, MIPI_TX_LANE_2}, .lane_id = {MIPI_TX_LANE_0, MIPI_TX_LANE_1, MIPI_TX_LANE_CLK, MIPI_TX_LANE_3, MIPI_TX_LANE_2},
.lane_pn_swap = {true, true, true, true, true}, .lane_pn_swap = {true, true, true, true, true},

View File

@ -4,7 +4,7 @@
#include <linux/vo_mipi_tx.h> #include <linux/vo_mipi_tx.h>
#include <linux/cvi_comm_mipi_tx.h> #include <linux/cvi_comm_mipi_tx.h>
const struct combo_dev_cfg_s dev_cfg_nt35521_800x1280 = { struct combo_dev_cfg_s dev_cfg_nt35521_800x1280 = {
.devno = 0, .devno = 0,
.lane_id = {MIPI_TX_LANE_CLK, MIPI_TX_LANE_0, MIPI_TX_LANE_2, MIPI_TX_LANE_3, MIPI_TX_LANE_1}, .lane_id = {MIPI_TX_LANE_CLK, MIPI_TX_LANE_0, MIPI_TX_LANE_2, MIPI_TX_LANE_3, MIPI_TX_LANE_1},
.lane_pn_swap = {false, false, false, false, false}, .lane_pn_swap = {false, false, false, false, false},

View File

@ -5,7 +5,7 @@
#include <linux/cvi_comm_mipi_tx.h> #include <linux/cvi_comm_mipi_tx.h>
// Not support BTA // Not support BTA
const struct combo_dev_cfg_s dev_cfg_ota7290b_320x1280 = { struct combo_dev_cfg_s dev_cfg_ota7290b_320x1280 = {
.devno = 0, .devno = 0,
.lane_id = {MIPI_TX_LANE_0, MIPI_TX_LANE_1, MIPI_TX_LANE_CLK, MIPI_TX_LANE_2, MIPI_TX_LANE_3}, .lane_id = {MIPI_TX_LANE_0, MIPI_TX_LANE_1, MIPI_TX_LANE_CLK, MIPI_TX_LANE_2, MIPI_TX_LANE_3},
.lane_pn_swap = {false, false, false, false, false}, .lane_pn_swap = {false, false, false, false, false},

View File

@ -5,7 +5,7 @@
#include <linux/cvi_comm_mipi_tx.h> #include <linux/cvi_comm_mipi_tx.h>
// Not support BTA // Not support BTA
const struct combo_dev_cfg_s dev_cfg_ota7290b_440x1920 = { struct combo_dev_cfg_s dev_cfg_ota7290b_440x1920 = {
.devno = 0, .devno = 0,
.lane_id = {MIPI_TX_LANE_3, MIPI_TX_LANE_2, MIPI_TX_LANE_CLK, MIPI_TX_LANE_1, MIPI_TX_LANE_0}, .lane_id = {MIPI_TX_LANE_3, MIPI_TX_LANE_2, MIPI_TX_LANE_CLK, MIPI_TX_LANE_1, MIPI_TX_LANE_0},
.lane_pn_swap = {true, true, true, true, true}, .lane_pn_swap = {true, true, true, true, true},

View File

@ -19,7 +19,7 @@
#define PIXEL_CLK(x) ((x##_VACT + x##_VSA + x##_VBP + x##_VFP) \ #define PIXEL_CLK(x) ((x##_VACT + x##_VSA + x##_VBP + x##_VFP) \
* (x##_HACT + x##_HSA + x##_HBP + x##_HFP) * 60 / 1000) * (x##_HACT + x##_HSA + x##_HBP + x##_HFP) * 60 / 1000)
const struct combo_dev_cfg_s dev_cfg_st7701_480x800 = { struct combo_dev_cfg_s dev_cfg_st7701_480x800 = {
.devno = 0, .devno = 0,
.lane_id = {MIPI_TX_LANE_1, MIPI_TX_LANE_0, MIPI_TX_LANE_CLK, -1, -1}, .lane_id = {MIPI_TX_LANE_1, MIPI_TX_LANE_0, MIPI_TX_LANE_CLK, -1, -1},
.lane_pn_swap = {false, false, false, false, false}, .lane_pn_swap = {false, false, false, false, false},

View File

@ -0,0 +1,27 @@
#ifndef _BT656_TP2803_H_
#define _BT656_TP2803_H_
#include <linux/cvi_comm_vo.h>
const struct VO_BT_PINS tp2803_pins_cfg = {
.pin_num = 9,
.d_pins = {
{VO_VIVO_D0, VO_MUX_BT_DATA0},
{VO_VIVO_D1, VO_MUX_BT_DATA1},
{VO_VIVO_D2, VO_MUX_BT_DATA2},
{VO_VIVO_D3, VO_MUX_BT_DATA3},
{VO_VIVO_D4, VO_MUX_BT_DATA4},
{VO_VIVO_D5, VO_MUX_BT_DATA5},
{VO_VIVO_D6, VO_MUX_BT_DATA6},
{VO_VIVO_D7, VO_MUX_BT_DATA7},
{VO_VIVO_CLK, VO_MUX_BT_VS}
}
};
const VO_BT_ATTR_S stTP2803Cfg = {
.pins = tp2803_pins_cfg,
.mode = VO_BT_MODE_656,
.bt_clk = VO_BT_CLK_MODE_72M,
};
#endif // _I80_PARAM_ST7789V_H_

View File

@ -17,7 +17,7 @@
#define PIXEL_CLK(x) ((x##_VACT + x##_VSA + x##_VBP + x##_VFP) \ #define PIXEL_CLK(x) ((x##_VACT + x##_VSA + x##_VBP + x##_VFP) \
* (x##_HACT + x##_HSA + x##_HBP + x##_HFP) * 60 / 1000) * (x##_HACT + x##_HSA + x##_HBP + x##_HFP) * 60 / 1000)
const struct combo_dev_cfg_s dev_cfg_3AML069LP01G_600x1024 = { struct combo_dev_cfg_s dev_cfg_3AML069LP01G_600x1024 = {
.devno = 0, .devno = 0,
#ifdef MIPI_PANEL_2_LANES #ifdef MIPI_PANEL_2_LANES
.lane_id = {MIPI_TX_LANE_0, MIPI_TX_LANE_1, MIPI_TX_LANE_CLK, -1, -1}, .lane_id = {MIPI_TX_LANE_0, MIPI_TX_LANE_1, MIPI_TX_LANE_CLK, -1, -1},

View File

@ -4,7 +4,7 @@
#include <linux/vo_mipi_tx.h> #include <linux/vo_mipi_tx.h>
#include <linux/cvi_comm_mipi_tx.h> #include <linux/cvi_comm_mipi_tx.h>
const struct combo_dev_cfg_s dev_cfg_hx8394_720x1280 = { struct combo_dev_cfg_s dev_cfg_hx8394_720x1280 = {
.devno = 0, .devno = 0,
#ifdef MIPI_PANEL_2_LANES #ifdef MIPI_PANEL_2_LANES
.lane_id = {MIPI_TX_LANE_0, MIPI_TX_LANE_1, MIPI_TX_LANE_CLK, -1, -1}, .lane_id = {MIPI_TX_LANE_0, MIPI_TX_LANE_1, MIPI_TX_LANE_CLK, -1, -1},

View File

@ -17,7 +17,7 @@
#define PIXEL_CLK(x) ((x##_VACT + x##_VSA + x##_VBP + x##_VFP) \ #define PIXEL_CLK(x) ((x##_VACT + x##_VSA + x##_VBP + x##_VFP) \
* (x##_HACT + x##_HSA + x##_HBP + x##_HFP) * 60 / 1000) * (x##_HACT + x##_HSA + x##_HBP + x##_HFP) * 60 / 1000)
const struct combo_dev_cfg_s dev_cfg_hx8399_1080x1920 = { struct combo_dev_cfg_s dev_cfg_hx8399_1080x1920 = {
.devno = 0, .devno = 0,
#ifdef MIPI_PANEL_2_LANES #ifdef MIPI_PANEL_2_LANES
.lane_id = {MIPI_TX_LANE_0, MIPI_TX_LANE_1, MIPI_TX_LANE_CLK, -1, -1}, .lane_id = {MIPI_TX_LANE_0, MIPI_TX_LANE_1, MIPI_TX_LANE_CLK, -1, -1},

View File

@ -4,7 +4,7 @@
#include <linux/vo_mipi_tx.h> #include <linux/vo_mipi_tx.h>
#include <linux/cvi_comm_mipi_tx.h> #include <linux/cvi_comm_mipi_tx.h>
const struct combo_dev_cfg_s dev_cfg_icn9707_480x1920 = { struct combo_dev_cfg_s dev_cfg_icn9707_480x1920 = {
.devno = 0, .devno = 0,
.lane_id = {MIPI_TX_LANE_3, MIPI_TX_LANE_2, MIPI_TX_LANE_CLK, MIPI_TX_LANE_1, MIPI_TX_LANE_0}, .lane_id = {MIPI_TX_LANE_3, MIPI_TX_LANE_2, MIPI_TX_LANE_CLK, MIPI_TX_LANE_1, MIPI_TX_LANE_0},
.lane_pn_swap = {true, true, true, true, true}, .lane_pn_swap = {true, true, true, true, true},

View File

@ -4,7 +4,7 @@
#include <linux/vo_mipi_tx.h> #include <linux/vo_mipi_tx.h>
#include <linux/cvi_comm_mipi_tx.h> #include <linux/cvi_comm_mipi_tx.h>
const struct combo_dev_cfg_s dev_cfg_ili9881c_720x1280 = { struct combo_dev_cfg_s dev_cfg_ili9881c_720x1280 = {
.devno = 0, .devno = 0,
.lane_id = {MIPI_TX_LANE_0, MIPI_TX_LANE_1, MIPI_TX_LANE_CLK, MIPI_TX_LANE_2, MIPI_TX_LANE_3}, .lane_id = {MIPI_TX_LANE_0, MIPI_TX_LANE_1, MIPI_TX_LANE_CLK, MIPI_TX_LANE_2, MIPI_TX_LANE_3},
.lane_pn_swap = {false, false, false, false, false}, .lane_pn_swap = {false, false, false, false, false},

View File

@ -4,7 +4,7 @@
#include <linux/vo_mipi_tx.h> #include <linux/vo_mipi_tx.h>
#include <linux/cvi_comm_mipi_tx.h> #include <linux/cvi_comm_mipi_tx.h>
const struct combo_dev_cfg_s dev_cfg_ili9881d_720x1280 = { struct combo_dev_cfg_s dev_cfg_ili9881d_720x1280 = {
.devno = 0, .devno = 0,
.lane_id = {MIPI_TX_LANE_0, MIPI_TX_LANE_1, MIPI_TX_LANE_2, MIPI_TX_LANE_CLK, MIPI_TX_LANE_3}, .lane_id = {MIPI_TX_LANE_0, MIPI_TX_LANE_1, MIPI_TX_LANE_2, MIPI_TX_LANE_CLK, MIPI_TX_LANE_3},
.lane_pn_swap = {false, false, false, false, false}, .lane_pn_swap = {false, false, false, false, false},

View File

@ -4,7 +4,7 @@
#include <linux/vo_mipi_tx.h> #include <linux/vo_mipi_tx.h>
#include <linux/cvi_comm_mipi_tx.h> #include <linux/cvi_comm_mipi_tx.h>
const struct combo_dev_cfg_s dev_cfg_jd9366ab_800x1280 = { struct combo_dev_cfg_s dev_cfg_jd9366ab_800x1280 = {
.devno = 0, .devno = 0,
.lane_id = {MIPI_TX_LANE_0, MIPI_TX_LANE_1, MIPI_TX_LANE_CLK, MIPI_TX_LANE_3, MIPI_TX_LANE_2}, .lane_id = {MIPI_TX_LANE_0, MIPI_TX_LANE_1, MIPI_TX_LANE_CLK, MIPI_TX_LANE_3, MIPI_TX_LANE_2},
.lane_pn_swap = {true, true, true, true, true}, .lane_pn_swap = {true, true, true, true, true},

View File

@ -4,7 +4,7 @@
#include <linux/vo_mipi_tx.h> #include <linux/vo_mipi_tx.h>
#include <linux/cvi_comm_mipi_tx.h> #include <linux/cvi_comm_mipi_tx.h>
const struct combo_dev_cfg_s dev_cfg_nt35521_800x1280 = { struct combo_dev_cfg_s dev_cfg_nt35521_800x1280 = {
.devno = 0, .devno = 0,
.lane_id = {MIPI_TX_LANE_CLK, MIPI_TX_LANE_0, MIPI_TX_LANE_2, MIPI_TX_LANE_3, MIPI_TX_LANE_1}, .lane_id = {MIPI_TX_LANE_CLK, MIPI_TX_LANE_0, MIPI_TX_LANE_2, MIPI_TX_LANE_3, MIPI_TX_LANE_1},
.lane_pn_swap = {false, false, false, false, false}, .lane_pn_swap = {false, false, false, false, false},

View File

@ -5,7 +5,7 @@
#include <linux/cvi_comm_mipi_tx.h> #include <linux/cvi_comm_mipi_tx.h>
// Not support BTA // Not support BTA
const struct combo_dev_cfg_s dev_cfg_ota7290b_320x1280 = { struct combo_dev_cfg_s dev_cfg_ota7290b_320x1280 = {
.devno = 0, .devno = 0,
.lane_id = {MIPI_TX_LANE_0, MIPI_TX_LANE_1, MIPI_TX_LANE_CLK, MIPI_TX_LANE_2, MIPI_TX_LANE_3}, .lane_id = {MIPI_TX_LANE_0, MIPI_TX_LANE_1, MIPI_TX_LANE_CLK, MIPI_TX_LANE_2, MIPI_TX_LANE_3},
.lane_pn_swap = {false, false, false, false, false}, .lane_pn_swap = {false, false, false, false, false},

View File

@ -5,7 +5,7 @@
#include <linux/cvi_comm_mipi_tx.h> #include <linux/cvi_comm_mipi_tx.h>
// Not support BTA // Not support BTA
const struct combo_dev_cfg_s dev_cfg_ota7290b_440x1920 = { struct combo_dev_cfg_s dev_cfg_ota7290b_440x1920 = {
.devno = 0, .devno = 0,
.lane_id = {MIPI_TX_LANE_3, MIPI_TX_LANE_2, MIPI_TX_LANE_CLK, MIPI_TX_LANE_1, MIPI_TX_LANE_0}, .lane_id = {MIPI_TX_LANE_3, MIPI_TX_LANE_2, MIPI_TX_LANE_CLK, MIPI_TX_LANE_1, MIPI_TX_LANE_0},
.lane_pn_swap = {true, true, true, true, true}, .lane_pn_swap = {true, true, true, true, true},

View File

@ -19,7 +19,7 @@
#define PIXEL_CLK(x) ((x##_VACT + x##_VSA + x##_VBP + x##_VFP) \ #define PIXEL_CLK(x) ((x##_VACT + x##_VSA + x##_VBP + x##_VFP) \
* (x##_HACT + x##_HSA + x##_HBP + x##_HFP) * 60 / 1000) * (x##_HACT + x##_HSA + x##_HBP + x##_HFP) * 60 / 1000)
const struct combo_dev_cfg_s dev_cfg_st7701_480x800 = { struct combo_dev_cfg_s dev_cfg_st7701_480x800 = {
.devno = 0, .devno = 0,
.lane_id = {MIPI_TX_LANE_1, MIPI_TX_LANE_0, MIPI_TX_LANE_CLK, -1, -1}, .lane_id = {MIPI_TX_LANE_1, MIPI_TX_LANE_0, MIPI_TX_LANE_CLK, -1, -1},
.lane_pn_swap = {false, false, false, false, false}, .lane_pn_swap = {false, false, false, false, false},

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More