From 2c7f0cd8220cbe5ee96436ee628c8b2fee630490 Mon Sep 17 00:00:00 2001 From: Viktor <35473052+viktorxda@users.noreply.github.com> Date: Mon, 7 Aug 2023 09:41:51 +0200 Subject: [PATCH] Packages: move sigmastar-osdrv-sensor to external repository --- .../sigmastar-osdrv-sensor.mk | 10 +- .../src/infinity6b0/Makefile | 9 - .../infinity6b0/include/drv_ms_cus_sensor.h | 1029 ---- .../src/infinity6b0/include/drv_sensor.h | 53 - .../infinity6b0/include/drv_sensor_common.h | 379 -- .../include/drv_sensor_init_table.h | 114 - .../src/infinity6b0/include/sensor_i2c_api.h | 168 - .../infinity6b0/sensor/sensor_gc2053_mipi.c | 1291 ---- .../infinity6b0/sensor/sensor_gc4653_mipi.c | 1108 ---- .../infinity6b0/sensor/sensor_imx307_mipi.c | 3208 ---------- .../infinity6b0/sensor/sensor_imx335_mipi.c | 3707 ------------ .../infinity6b0/sensor/sensor_sc2239_mipi.c | 1086 ---- .../infinity6b0/sensor/sensor_sc2335_mipi.c | 1107 ---- .../infinity6b0/sensor/sensor_sc3335_mipi.c | 1118 ---- .../src/infinity6e/Makefile | 9 - .../infinity6e/include/drv_ms_cus_sensor.h | 1045 ---- .../src/infinity6e/include/drv_sensor.h | 53 - .../infinity6e/include/drv_sensor_common.h | 379 -- .../include/drv_sensor_init_table.h | 114 - .../src/infinity6e/include/sensor_i2c_api.h | 168 - .../infinity6e/sensor/sensor_imx274_mipi.c | 4112 ------------- .../infinity6e/sensor/sensor_imx335_mipi.c | 3458 ----------- .../infinity6e/sensor/sensor_imx347_mipi.c | 2199 ------- .../infinity6e/sensor/sensor_imx415_mipi.c | 5391 ----------------- .../infinity6e/sensor/sensor_sc8235_mipi.c | 5134 ---------------- 25 files changed, 5 insertions(+), 36444 deletions(-) delete mode 100644 general/package/sigmastar-osdrv-sensor/src/infinity6b0/Makefile delete mode 100644 general/package/sigmastar-osdrv-sensor/src/infinity6b0/include/drv_ms_cus_sensor.h delete mode 100644 general/package/sigmastar-osdrv-sensor/src/infinity6b0/include/drv_sensor.h delete mode 100644 general/package/sigmastar-osdrv-sensor/src/infinity6b0/include/drv_sensor_common.h delete mode 100644 general/package/sigmastar-osdrv-sensor/src/infinity6b0/include/drv_sensor_init_table.h delete mode 100644 general/package/sigmastar-osdrv-sensor/src/infinity6b0/include/sensor_i2c_api.h delete mode 100644 general/package/sigmastar-osdrv-sensor/src/infinity6b0/sensor/sensor_gc2053_mipi.c delete mode 100644 general/package/sigmastar-osdrv-sensor/src/infinity6b0/sensor/sensor_gc4653_mipi.c delete mode 100644 general/package/sigmastar-osdrv-sensor/src/infinity6b0/sensor/sensor_imx307_mipi.c delete mode 100644 general/package/sigmastar-osdrv-sensor/src/infinity6b0/sensor/sensor_imx335_mipi.c delete mode 100644 general/package/sigmastar-osdrv-sensor/src/infinity6b0/sensor/sensor_sc2239_mipi.c delete mode 100644 general/package/sigmastar-osdrv-sensor/src/infinity6b0/sensor/sensor_sc2335_mipi.c delete mode 100644 general/package/sigmastar-osdrv-sensor/src/infinity6b0/sensor/sensor_sc3335_mipi.c delete mode 100644 general/package/sigmastar-osdrv-sensor/src/infinity6e/Makefile delete mode 100644 general/package/sigmastar-osdrv-sensor/src/infinity6e/include/drv_ms_cus_sensor.h delete mode 100644 general/package/sigmastar-osdrv-sensor/src/infinity6e/include/drv_sensor.h delete mode 100644 general/package/sigmastar-osdrv-sensor/src/infinity6e/include/drv_sensor_common.h delete mode 100644 general/package/sigmastar-osdrv-sensor/src/infinity6e/include/drv_sensor_init_table.h delete mode 100644 general/package/sigmastar-osdrv-sensor/src/infinity6e/include/sensor_i2c_api.h delete mode 100644 general/package/sigmastar-osdrv-sensor/src/infinity6e/sensor/sensor_imx274_mipi.c delete mode 100644 general/package/sigmastar-osdrv-sensor/src/infinity6e/sensor/sensor_imx335_mipi.c delete mode 100644 general/package/sigmastar-osdrv-sensor/src/infinity6e/sensor/sensor_imx347_mipi.c delete mode 100644 general/package/sigmastar-osdrv-sensor/src/infinity6e/sensor/sensor_imx415_mipi.c delete mode 100644 general/package/sigmastar-osdrv-sensor/src/infinity6e/sensor/sensor_sc8235_mipi.c diff --git a/general/package/sigmastar-osdrv-sensor/sigmastar-osdrv-sensor.mk b/general/package/sigmastar-osdrv-sensor/sigmastar-osdrv-sensor.mk index b222d579..d44bb854 100644 --- a/general/package/sigmastar-osdrv-sensor/sigmastar-osdrv-sensor.mk +++ b/general/package/sigmastar-osdrv-sensor/sigmastar-osdrv-sensor.mk @@ -4,15 +4,15 @@ # ################################################################################ +SIGMASTAR_OSDRV_SENSOR_SITE = https://github.com/openipc/sensors/archive +SIGMASTAR_OSDRV_SENSOR_SOURCE = master.tar.gz + SIGMASTAR_OSDRV_SENSOR_LICENSE = MIT SIGMASTAR_OSDRV_SENSOR_LICENSE_FILES = LICENSE -define SIGMASTAR_OSDRV_SENSOR_EXTRACT_CMDS - cp -r $(SIGMASTAR_OSDRV_SENSOR_PKGDIR)/src/* $(@D) -endef - -SIGMASTAR_OSDRV_SENSOR_MODULE_SUBDIRS = $(OPENIPC_SOC_FAMILY) +SIGMASTAR_OSDRV_SENSOR_MODULE_SUBDIRS = sigmastar/sources/$(OPENIPC_SOC_FAMILY) SIGMASTAR_OSDRV_SENSOR_MODULE_MAKE_OPTS = \ + SENSOR_VERSION=$(OPENIPC_SOC_MODEL)-$(OPENIPC_SOC_FAMILY) \ INSTALL_MOD_DIR=sigmastar \ KSRC=$(LINUX_DIR) diff --git a/general/package/sigmastar-osdrv-sensor/src/infinity6b0/Makefile b/general/package/sigmastar-osdrv-sensor/src/infinity6b0/Makefile deleted file mode 100644 index b18f8982..00000000 --- a/general/package/sigmastar-osdrv-sensor/src/infinity6b0/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -EXTRA_CFLAGS += -I $(PWD)/include -I $(KSRC)/drivers/sstar/include -EXTRA_CFLAGS += -D SENSOR_MODULE_VERSION=$(OPENIPC_SOC_MODEL)-$(OPENIPC_SOC_FAMILY) -obj-m := $(patsubst $(PWD)/%.c, %.o, $(wildcard $(PWD)/sensor/*.c)) - -modules: - $(MAKE) -C $(KSRC) M=$(PWD) modules - -clean: - $(MAKE) -C $(KSRC) M=$(PWD) clean diff --git a/general/package/sigmastar-osdrv-sensor/src/infinity6b0/include/drv_ms_cus_sensor.h b/general/package/sigmastar-osdrv-sensor/src/infinity6b0/include/drv_ms_cus_sensor.h deleted file mode 100644 index f8914e72..00000000 --- a/general/package/sigmastar-osdrv-sensor/src/infinity6b0/include/drv_ms_cus_sensor.h +++ /dev/null @@ -1,1029 +0,0 @@ -/* Copyright (c) 2018-2019 Sigmastar Technology Corp. - All rights reserved. - - Unless otherwise stipulated in writing, any and all information contained -herein regardless in any format shall remain the sole proprietary of -Sigmastar Technology Corp. and be kept in strict confidence -(Sigmastar Confidential Information) by the recipient. -Any unauthorized act including without limitation unauthorized disclosure, -copying, use, reproduction, sale, distribution, modification, disassembling, -reverse engineering and compiling of the contents of Sigmastar Confidential -Information is unlawful and strictly prohibited. Sigmastar hereby reserves the -rights to any and all damages, losses, costs and expenses resulting therefrom. -*/ - -/*! @file drv_ms_cus_sensor.h - @brief This file contains Infinity ISP sensor driver interface. -*/ - -/** @defgroup group1 ISP Sensor Driver Interface -* @{ -*/ - -#ifndef DRV_MS_CUS_SENSOR_H_ -#define DRV_MS_CUS_SENSOR_H_ -#ifdef __cplusplus -extern "C" -{ -#endif - -#include - -#define I2C_RETRYTIME (5) - -#ifndef SUCCESS -#define FAIL (-1) -#define SUCCESS 0 -#endif - -#ifdef __cplusplus -#define EXPORT_CUS extern "C" -#else -#define EXPORT_CUS -#endif - -#define CUS_CAMSENSOR_HANDLE_MAJ_VER 0x0002 -#define CUS_CAMSENSOR_HANDLE_MIN_VER 0x0002 - -#define CUS_CAMSENSORIF_MAJ_VER 0x0001 -#define CUS_CAMSENSORIF_MIN_VER 0x0002 - -#define CUS_CAMSENSOR_I2C_MAJ_VER 0x0001 -#define CUS_CAMSENSOR_I2C_MIN_VER 0x0001 - -#define CUS_MSTART_CAMSENSOR_CAP_VERSION 0x0001 - -//#define usleep(usec) CamOsMsSleep(usec*1000); -//#define usleep(usec) udelay(usec) -//#define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0])) - -#define SENSOR_DRIVER_MODE_NOT_SUUPORT (0xFFFF) - -struct __ms_cus_sensor; /**< Sensor driver handle */ -//struct __ISensorAPI; /**< Sensor to ISP control interface */ - -/*! @brief Resolution descriptor*/ -typedef struct _cus_camsensor_res{ - u32 width; /**< Image crop width */ - u32 height; /**< Image crop height */ - u32 max_fps; /**< Max fps in this resolution */ - u32 min_fps; /**< Min fps in this resolution*/ - u32 crop_start_x; - u32 crop_start_y; - u32 nOutputWidth; /**< Sensor actual output width */ - u32 nOutputHeight; /**< Sensor actual output height */ - char strResDesc[32]; -} __attribute__((packed, aligned(4))) cus_camsensor_res; - -/*! @brief Resolution list*/ -typedef struct _cus_camsensor_res_list -{ - u32 num_res; /**< number of sensor resolution in list */ - u32 ulcur_res; /**< current sensor resolution*/ - cus_camsensor_res res[12]; /**< resolution list */ -} __attribute__((packed, aligned(4))) cus_camsensor_res_list; - - -/*! @brief Select sensor type */ -typedef enum { - ISP_SOC, /**< Not support */ - ISP_EXT /**< sensor without built-in ISP */ -} CUS_CAMSENSOR_ISPTYPE; - -/*! @brief Sensor bayer raw pixel order */ -typedef enum { - CUS_BAYER_RG = 0, /**< bayer data start with R channel */ - CUS_BAYER_GR, /**< bayer data start with Gr channel */ - CUS_BAYER_BG, /**< bayer data start with B channel */ - CUS_BAYER_GB /**< bayer data start with Gb channel */ -} CUS_SEN_BAYER; - -typedef enum { - CUS_RGBIR_NONE = 0, /** modify RGBIR pixel order enumeration */ - CUS_RGBIR_R0 = 1, - CUS_RGBIR_G0 = 2, - CUS_RGBIR_B0 = 3, - CUS_RGBIR_G1 = 4, - CUS_RGBIR_G2 = 5, - CUS_RGBIR_I0 = 6, - CUS_RGBIR_G3 = 7, - CUS_RGBIR_I1 = 8 -} CUS_SEN_RGBIR; - -/*! @brief Set sensor image mirror and flip.*/ -typedef enum { - CUS_ORIT_M0F0, /**< mirror, flip unchanged */ - CUS_ORIT_M1F0, /**< mirror changed, flip unchanged */ - CUS_ORIT_M0F1, /**< mirror unchanged, flip changed */ - CUS_ORIT_M1F1, /**< mirror and flip changed */ -} CUS_CAMSENSOR_ORIT; - - -/*! @brief Get input source type.*/ -typedef enum { - CUS_SNR_ANADEC_SRC_NO_READY, /**< input no ready */ - CUS_SNR_ANADEC_SRC_DISCNT, /**< input disconnect */ - CUS_SNR_ANADEC_SRC_PAL, /**< input type is PAL */ - CUS_SNR_ANADEC_SRC_NTSC, /**< input type is NTSC */ - CUS_SNR_ANADEC_SRC_HD_25P, /**< input source type is HD */ - CUS_SNR_ANADEC_SRC_HD_30P, /**< input source type is HD */ - CUS_SNR_ANADEC_SRC_HD_50P, /**< input source type is HD */ - CUS_SNR_ANADEC_SRC_HD_60P, /**< input source type is HD */ - CUS_SNR_ANADEC_SRC_FHD_25P, /**< input source type is FHD */ - CUS_SNR_ANADEC_SRC_FHD_30P, /**< input source type is FHD */ -}CUS_SNR_ANADEC_SRC_TYPE; - - -/*! @brief ISP AE event notifycation*/ -typedef enum { - CUS_FRAME_INACTIVE = 0, /**< Frame end */ - CUS_FRAME_ACTIVE = 1,/**< Frame start */ -} CUS_CAMSENSOR_AE_STATUS_NOTIFY; - -/*! @brief Sensor bayer raw (8/10 bits) to 12bits mode control */ -typedef enum { - CUS_SEN_8TO12_7074, /**< Do not use*/ - CUS_SEN_8TO12_7000, /**< Sensor bayer raw is 8 bits*/ - CUS_SEN_8TO12_114118, /**< Do not use*/ - CUS_SEN_8TO12_11400, /**< Do not use*/ - CUS_SEN_10TO12_9098, /**< Do not use*/ - CUS_SEN_10TO12_9000, /**< Sensor bayer raw is 10 bits*/ - CUS_SEN_10TO12_1121110, /**< Do not use*/ - CUS_SEN_10TO12_11200 /**< Do not use*/ -} CUS_SEN_FMT_CONV_MODE; - -/*! @brief Sensor input raw data precision */ -typedef enum { - CUS_DATAPRECISION_8 = 0, /**< raw data precision is 8bits */ - CUS_DATAPRECISION_10 = 1, /**< raw data precision is 10bits */ - CUS_DATAPRECISION_16 = 2, /**< raw data precision is 16bits */ - CUS_DATAPRECISION_12 = 3, /**< raw data precision is 12bits */ - CUS_DATAPRECISION_14 = 4, /**< raw data precision is 14bits */ -} CUS_DATAPRECISION; - -/*! @brief Select sensor data intarface */ -typedef enum { - CUS_SENIF_BUS_PARL = 0, /**< sensor data bus is parallel bus */ - CUS_SENIF_BUS_MIPI = 1, /**< sensor data bus is mipi */ - CUS_SENIF_BUS_BT601 = 2, - CUS_SENIF_BUS_BT656 = 3, - CUS_SENIF_BUS_BT1120 = 4, -} CUS_SENIF_BUS; - -typedef enum { - CUS_SEN_INPUT_FORMAT_YUV422, - CUS_SEN_INPUT_FORMAT_RGB, -} CUS_SEN_INPUT_FORMAT; - -/*! @brief Select pin polarity */ -typedef enum { - CUS_CLK_POL_POS = 0, /**< High active */ - CUS_CLK_POL_NEG /**< Low active */ -} CUS_CLK_POL; - -typedef enum -{ - CUS_SENSOR_YUV_ORDER_CY = 0, - CUS_SENSOR_YUV_ORDER_YC = 1, -}CUS_SENSOR_YUV_ORDER; - -/*! @brief Sensor master clock select */ -typedef enum { - CUS_CMU_CLK_27MHZ, - CUS_CMU_CLK_21P6MHZ, - CUS_CMU_CLK_12MHZ, - CUS_CMU_CLK_5P4MHZ, - CUS_CMU_CLK_36MHZ, - CUS_CMU_CLK_54MHZ, - CUS_CMU_CLK_43P2MHZ, - CUS_CMU_CLK_61P7MHZ, - CUS_CMU_CLK_72MHZ, - CUS_CMU_CLK_48MHZ, - CUS_CMU_CLK_24MHZ, - CUS_CMU_CLK_37P125MHZ, - CUS_CMU_CLK_LPLL_DIV1, - CUS_CMU_CLK_LPLL_DIV2, - CUS_CMU_CLK_LPLL_DIV4, - CUS_CMU_CLK_LPLL_DIV8, -} CUS_MCLK_FREQ; //Depends on chip. - -//Depends on chip definition. -typedef enum { - CUS_SR0_PAR_DISABLE, - CUS_SR0_PAR_MODE_1, - CUS_SR0_PAR_MODE_2, -} CUS_SR0_PAR_MODE; - -//Depends on chip definition. -typedef enum { - CUS_SR0_BT656_DISABLE, - CUS_SR0_BT656_MODE_1, - CUS_SR0_BT656_MODE_2, - CUS_SR0_BT656_MODE_3, - CUS_SR0_BT656_MODE_4, -} CUS_SR0_BT656_MODE; - -//Depends on chip definition. -typedef enum { - CUS_SR1_BT656_DISABLE, - CUS_SR1_BT656_MODE_1, -} CUS_SR1_BT656_MODE; - -//Depends on chip definition. -typedef enum { - CUS_SR0_BT601_DISABLE, - CUS_SR0_BT601_MODE_1, - CUS_SR0_BT601_MODE_2, - CUS_SR0_BT601_MODE_3, - CUS_SR0_BT601_MODE_4, -} CUS_SR0_BT601_MODE; - -//Depends on chip definition. -typedef enum { - CUS_SR0_MIPI_DISABLE, - CUS_SR0_MIPI_MODE_1, - CUS_SR0_MIPI_MODE_2, -} CUS_SR0_MIPI_MODE; - -//Depends on chip definition. -typedef enum { - CUS_SR1_MIPI_DISABLE, - CUS_SR1_MIPI_MODE_1, - CUS_SR1_MIPI_MODE_2, - CUS_SR1_MIPI_MODE_3, - CUS_SR1_MIPI_MODE_4, -} CUS_SR1_MIPI_MODE; - -//Depends on chip definition. -typedef enum -{ - CUS_VIF_BT656_EAV_DETECT = 0, - CUS_VIF_BT656_SAV_DETECT = 1, -}CUS_VIF_BT656_CHANNEL_SELECT; - -//Depends on chip definition. -typedef enum -{ - CUS_VIF_BT656_VSYNC_DELAY_1LINE = 0, - CUS_VIF_BT656_VSYNC_DELAY_2LINE = 1, - CUS_VIF_BT656_VSYNC_DELAY_0LINE = 2, - CUS_VIF_BT656_VSYNC_DELAY_AUTO = 3, -}CUS_VIF_BT656_VSYNC_DELAY; - -typedef enum -{ - CUS_SENSOR_FUNC_DISABLE = 0, - CUS_SENSOR_FUNC_ENABLE = 1, -}CUS_SENSOR_FUNC; - -typedef enum -{ - CUS_SENSOR_PAD_GROUP_A = 0, - CUS_SENSOR_PAD_GROUP_B = 1, - CUS_SENSOR_PAD_GROUP_C = 2, - CUS_SENSOR_PAD_GROUP_D = 3, -}CUS_SENSOR_PAD_GROUP; - -typedef enum -{ - CUS_SENSOR_MASTER_MODE = 0, - CUS_SENSOR_SLAVE_MODE = 1, -}CUS_SENSOR_MODE; - -typedef enum -{ - CUS_SENSOR_CHANNEL_MODE_REALTIME_NORMAL = 0, - CUS_SENSOR_CHANNEL_MODE_REALTIME_HDR = 1, - CUS_SENSOR_CHANNEL_MODE_RAW_STORE = 2, - CUS_SENSOR_CHANNEL_MODE_RAW_STORE_HDR = 3, -}CUS_SENSOR_CHANNEL_MODE; - -typedef struct { - unsigned int gain; - unsigned int offset; -} CUS_GAIN_GAP_ARRAY; - -////////////////////////////////////// -// sensor functions -////////////////////////////////////// - -typedef struct { - u32 length; //header length - u32 version; //version -}CUS_CAMSENSOR_CAP; - -/////////////////// ISP for SENSOR API /////////////////// -typedef enum { - CUS_INT_TASK_AE = (1<<0), - CUS_INT_TASK_AWB = (1<<1), - CUS_INT_TASK_AF = (1<<2), - CUS_INT_TASK_VS = (1<<3), - CUS_INT_TASK_VDOS = (1<<4), -} CUS_INT_TASK_TYPE; - -#define MAX_RUN_ORDER 16 -typedef struct { - u8 RunLength; - u8 Orders[MAX_RUN_ORDER]; - u8 CurTaskType; -} CUS_INT_TASK_ORDER; - -/////////////////// Shutter Info /////////////////////// -/*! @brief Report shutter information */ -typedef struct { - u32 length; /**< struct size */ - u32 max; /**< maximun shutter in us*/ - u32 min; /**< minimum shutter in us*/ - u32 step; /**< shutter in step us*/ -} CUS_SHUTTER_INFO; - -////////////////// CSI CLOCK //////////////////////// -/*! @brief Select MIPI clock*/ -typedef enum { - CUS_CSI_CLK_DISABLE = -1, /**< Disable MIPI clock*/ - CUS_CSI_CLK_108M = 0, /**< MIPI pixel rate 864Mbps (1-lane)*/ - CUS_CSI_CLK_86M = 1, /**< MIPI pixel rate 344Mbps(1-lane)*/ - CUS_CSI_CLK_144M = 2, /**< MIPI pixel rate 1152Mbps(1-lane)*/ - CUS_CSI_CLK_172M = 3, - CUS_CSI_CLK_216M = 4, - CUS_CSI_CLK_288M = 5, - CUS_CSI_CLK_40M = 6, - CUS_CSI_CLK_24M = 7, - CUS_CSI_CLK_12M = 8, - CUS_CSI_CLK_123M = 9 -}CUS_CSI_CLK; - -///////////////// SENSOR PIN CONFIG///////////////// -/*! @brief Sensor pin assignment*/ -typedef enum { - CUS_SR_PAD_CFG_1 = 1, /**< Pin config for MIPI 1/2 lanes*/ - CUS_SR_PAD_CFG_MIPI = 1, /**< Pin config for MIPI 1/2 lanes*/ - CUS_SR_PAD_CFG_2 = 2, /**< Reserved */ - CUS_SR_PAD_CFG_3 = 3, /**< Reserved */ - CUS_SR_PAD_CFG_10BITS = 4, /**< Pin config for parallel interface 10 bits */ - CUS_SR_PAD_CFG_4 = 4, /**< Pin config for parallel interface 12 bits */ - CUS_SR_PAD_CFG_12BITS = 5, /**< Pin config for parallel interface 12 bits */ - CUS_SR_PAD_CFG_5 = 5, /**< Pin config for parallel interface 12 bits */ - CUS_SR_PAD_CFG_6 = 6 /**< Pin config for parallel interface 12 bits */ - }CUS_SR_PAD_CFG; - -/*! @brief virtual channel0 hsync. mode */ -typedef enum -{ - PACKET_HEADER_EDGE1 = 0, /**< packet header edge */ - PACKET_HEADER_EDGE2 = 1, /**< line end edge */ - PACKET_HEADER_EDGE3 = 2, /**< line start edge */ - PACKET_FOOTER_EDGE = 3, /**< packet footer edge */ -}CUS_CSI_VC_HS_MODE; - -typedef enum -{ - CUS_HDR_MODE_NONE = 0, - CUS_HDR_MODE_SONY_DOL = 1, - CUS_HDR_MODE_DCG = 2, - CUS_HDR_MODE_EMBEDDED_RAW8 = 3, - CUS_HDR_MODE_EMBEDDED_RAW10 = 4, - CUS_HDR_MODE_EMBEDDED_RAW12 = 5, - CUS_HDR_MODE_EMBEDDED_RAW16 = 6, //Only for OV2718? - CUS_HDR_MODE_LI = 7, - CUS_HDR_MODE_MULTI_VC = 8, -}CUS_HDR_MODE; - -typedef enum -{ - // Index 0 - SENSOR_DRIVER_MODE_VGA_30P_RESOLUTION, // 640*360 30P - SENSOR_DRIVER_MODE_VGA_50P_RESOLUTION, // 640*360 50P - SENSOR_DRIVER_MODE_VGA_60P_RESOLUTION, // 640*360 60P - SENSOR_DRIVER_MODE_VGA_100P_RESOLUTION, // 640*360 100P - SENSOR_DRIVER_MODE_VGA_120P_RESOLUTION, // 640*360 120P - - // Index 5 - SENSOR_DRIVER_MODE_HD_24P_RESOLUTION, // 1280*720 24P - SENSOR_DRIVER_MODE_HD_30P_RESOLUTION, // 1280*720 30P - SENSOR_DRIVER_MODE_HD_50P_RESOLUTION, // 1280*720 50P - SENSOR_DRIVER_MODE_HD_60P_RESOLUTION, // 1280*720 60P - SENSOR_DRIVER_MODE_HD_100P_RESOLUTION, // 1280*720 100P - - // Index 10 - SENSOR_DRIVER_MODE_HD_120P_RESOLUTION, // 1280*720 120P - SENSOR_DRIVER_MODE_1600x900_30P_RESOLUTION, // 1600*900 30P - SENSOR_DRIVER_MODE_FULL_HD_15P_RESOLUTION, // 1920*1080 15P - SENSOR_DRIVER_MODE_FULL_HD_24P_RESOLUTION, // 1920*1080 24P - SENSOR_DRIVER_MODE_FULL_HD_25P_RESOLUTION, // 1920*1080 25P - - // Index 15 - SENSOR_DRIVER_MODE_FULL_HD_30P_RESOLUTION, // 1920*1080 30P - SENSOR_DRIVER_MODE_FULL_HD_50P_RESOLUTION, // 1920*1080 50P - SENSOR_DRIVER_MODE_FULL_HD_60P_RESOLUTION, // 1920*1080 60P - SENSOR_DRIVER_MODE_SUPER_HD_30P_RESOLUTION, // 2304*1296 30P - SENSOR_DRIVER_MODE_SUPER_HD_25P_RESOLUTION, // 2304*1296 25P - - // Index 20 - SENSOR_DRIVER_MODE_SUPER_HD_24P_RESOLUTION, // 2304*1296 24P - SENSOR_DRIVER_MODE_1440_30P_RESOLUTION, // 2560*1440 30P - SENSOR_DRIVER_MODE_2D7K_15P_RESOLUTION, // 2704*1524 15P - SENSOR_DRIVER_MODE_2D7K_30P_RESOLUTION, // 2704*1524 30P - SENSOR_DRIVER_MODE_4K2K_15P_RESOLUTION, // 3840*2160 15P - - // Index 25 - SENSOR_DRIVER_MODE_4K2K_30P_RESOLUTION, // 3840*2160 30P - SENSOR_DRIVER_MODE_4TO3_VGA_30P_RESOLUTION, // 640*480 30P - SENSOR_DRIVER_MODE_4TO3_1D2M_30P_RESOLUTION, // 1280*960 30P - SENSOR_DRIVER_MODE_4TO3_1D5M_30P_RESOLUTION, // 1440*1080 30P - SENSOR_DRIVER_MODE_4TO3_3M_15P_RESOLUTION, // 2048*1536 15P - - // Index 30 - SENSOR_DRIVER_MODE_4TO3_3M_30P_RESOLUTION, // 2048*1536 30P - SENSOR_DRIVER_MODE_4TO3_5M_15P_RESOLUTION, // 2560*1920 15P - SENSOR_DRIVER_MODE_4TO3_5M_30P_RESOLUTION, // 2560*1920 30P - SENSOR_DRIVER_MODE_4TO3_8M_15P_RESOLUTION, // 3264*2448 15P - SENSOR_DRIVER_MODE_4TO3_8M_30P_RESOLUTION, // 3264*2448 30P - - // Index 35 - SENSOR_DRIVER_MODE_4TO3_10M_15P_RESOLUTION, // 3648*2736 15P - SENSOR_DRIVER_MODE_4TO3_10M_30P_RESOLUTION, // 3648*2736 30P - SENSOR_DRIVER_MODE_4TO3_12M_15P_RESOLUTION, // 4032*3024 15P - SENSOR_DRIVER_MODE_4TO3_12M_30P_RESOLUTION, // 4032*3024 30P - SENSOR_DRIVER_MODE_4TO3_14M_15P_RESOLUTION, // 4352*3264 15P - - // Index 40 - SENSOR_DRIVER_MODE_4TO3_14M_30P_RESOLUTION, // 4352*3264 30P - SENSOR_DRIVER_MODE_4K2K_24P_RESOLUTION, - SENSOR_DRIVER_MODE_PAL_25P_RESOLUTION, - SENSOR_DRIVER_MODE_NTSC_30P_RESOLUTION, - - // For Camera Preview - SENSOR_DRIVER_MODE_BEST_CAMERA_PREVIEW_RESOLUTION, - SENSOR_DRIVER_MODE_BEST_CAMERA_CAPTURE_16TO9_RESOLUTION, - SENSOR_DRIVER_MODE_BEST_CAMERA_CAPTURE_4TO3_RESOLUTION, - SENSOR_DRIVER_MODE_FULL_HD_30P_RESOLUTION_HDR, -} CUS_SNR_RESOLUTION; - - -#ifdef __cplusplus -extern "C" -#endif - -/**@brief ISP sensor interface control API */ -typedef struct __ISensorIfAPI //isp sensor interface API -{ - version_info version; - /**@brief Reserved */ - void* pdata; - - /** @brief Set sensor power down pin. - @param[in] idx Sensor pad ID. - @param[in] pol pin polarity. - @retval SUCCESS or FAIL if error occurs. - */ - int (*PowerOff)(u32 idx, CUS_CLK_POL pol); - - /** @brief Set sensor power reset pin. - @param[in] idx Sensor pad ID. - @param[in] pol pin polarity. - @retval SUCCESS or FAIL if error occurs. - */ - int (*Reset)(u32 idx, CUS_CLK_POL pol); - - /** @brief Configure sensor master clock. - @param[in] idx Sensor pad ID. - @param[in] bONOFF Clock ON/OFF control. - @param[in] mclk Clock frequency Hz. - @retval SUCCESS or FAIL if error occurs. - */ - int (*MCLK)(u32 idx, u8 bONOFF, CUS_MCLK_FREQ mclk); - - /** @brief Query sensor master clock. - @param[in] idx Sensor pad ID. - @param[in] mclk Query if clock frequency Hz is available. - @retval SUCCESS or FAIL if error occurs. - */ - int (*QueryMCLK)(u32 idx, CUS_MCLK_FREQ mclk); - - /** @brief Query MIPI lane number. - @param[in] idx Sensor pad ID. - @param[in] lane_num Query max lane number. - @retval SUCCESS or FAIL if error occurs. - */ - int (*QueryLaneNum)(u32 idx, u8 *max_lane); -#if 0 - /** @brief Select pixel clock source - @remarks Parallel interface only - @param[in] handle Handle to sensor driver. - @param[in] pclk_source Clock source. - @retval SUCCESS or FAIL if error occurs. - */ - int (*PCLK)(CUS_PCLK_SOURCE pclk_source); //senect sensor - - /** @brief Configure HSYNC pin polarity. - @remarks Parallel interface only - @param[in] handle Handle to sensor driver. - @param[in] pol pin polarity. - @retval SUCCESS or FAIL if error occurs. - */ - int (*HsyncPol)(CUS_CLK_POL pol); - - /** @brief [parallel interface only] Configure VSYNC pin polarity. - @param[in] handle Handle to sensor driver. - @param[in] pol pin polarity. - @retval SUCCESS or FAIL if error occurs. - */ - int (*VsyncPol)(CUS_CLK_POL pol); - - /** @brief Configure PCLK pin polarity. - @param[in] handle Handle to sensor driver. - @param[in] pol pin polarity. - @retval SUCCESS or FAIL if error occurs. - */ - int (*ClkPol)(CUS_CLK_POL pol); - - /** @brief Configure sensor bayer raw pixel order - @param[in] handle Handle to sensor driver. - @param[in] bayer_id Select pixel order - @retval SUCCESS or FAIL if error occurs. - */ - int (*BayerFmt)(CUS_SEN_BAYER bayer_id); - - /** @brief Configure sensor RGBIR (8 or 10bits) convert to 12bit bits isp input, This config will be ignore for 12/16 bits sensor bayer raw input. - @param[in] handle Handle to sensor driver. - @param[in] mode Mode select - @retval SUCCESS or FAIL if error occurs. - */ - int (*FmtConv)(CUS_SEN_FMT_CONV_MODE mode); - - /** @brief Select sensor image data interface - @param[in] handle Handle to sensor driver. - @param[in] bus Sensor interface - @retval SUCCESS or FAIL if error occurs. - */ - int (*DataBus)(CUS_SENIF_BUS bus); - - /** @brief Configure sensor bayer raw pixel bits - @param[in] handle Handle to sensor driver. - @param[in] prec Select pixel bits - @retval SUCCESS or FAIL if error occurs. - */ - int (*DataPrecision)(CUS_DATAPRECISION prec); - - /** @brief Wait isp frame start event - @param[in] handle Handle to sensor driver. - @param[in] ms Max timeout in ms - @retval SUCCESS or FAIL if error occurs. - */ - int (*WaitVStart)(int ms); - - /** @brief Wait isp frame end event - @param[in] handle Handle to sensor driver. - @param[in] ms Max timeout in ms - @retval SUCCESS or FAIL if error occurs. - */ - int (*WaitVEnd)(int ms); - - /** @brief Configure 3A task order table - @param[in] handle Handle to sensor driver. - @param[in] tasks Task order table - @retval SUCCESS or FAIL if error occurs. - */ - int (*Set3ATaskOrder)(CUS_INT_TASK_ORDER tasks); -#endif - /** @brief Select sensor IO pin assignment - @param[in] idx Sensor pad ID. - @param[in] ulSnrType Interface type. - @param[in] ulSnrPadCfg Pin config. - @retval SUCCESS or FAIL if error occurs. - */ - int (*SetIOPad)(u32 idx, CUS_SENIF_BUS ulSnrType, u32 ulSnrPadCfg); - - //FOR CSI - - /** @brief Set maximum mipi data rate (amount of all lans) - @remarks MIPI interface only. - @param[in] idx Sensor pad ID. - @param[in] clk Max data rate. - @retval SUCCESS or FAIL if error occurs. - */ - int (*SetCSI_Clk)(u32 idx, CUS_CSI_CLK clk); - - /** @brief Set number of MIPI lanes - @remarks MIPI interface only. - @param[in] idx Sensor pad ID. - @param[in] num_lan Number of lanes. - @param[in] bon_off Clock ON/OFF control. - @retval SUCCESS or FAIL if error occurs. - */ - int (*SetCSI_Lane)(u32 idx, u16 num_lan, u8 bon_off); - - /** @brief Enable long packet type - @remarks MIPI interface only - @param[in] idx Sensor pad ID. - @param[in] ctl_cfg0_15 Control flag bit[0:15] - @param[in] ctl_cfg16_31 Control flag bit[16:31] - @param[in] ctl_cfg32_47 Control flag bit[32:47] - @retval SUCCESS or FAIL if error occurs. - */ - int (*SetCSI_LongPacketType)(u32 idx, u16 ctl_cfg0_15, u16 ctl_cfg16_31, u16 ctl_cfg32_47); - - /** @brief Virtual channel0 hsync mode - @remarks MIPI interface only - @param[in] idx Sensor pad ID. - @param[in] mode HSYNC mode. - @retval SUCCESS or FAIL if error occurs. - */ - int (*SetCSI_VC0HSmode)(CUS_CSI_VC_HS_MODE mode); - - /** @brief Configure MIPI capture start timing - @remarks MIPI interface only - @param[in] idx Sensor pad ID. - @param[in] rx_clk_skip_ns - @param[in] rx_data_skip_ns - @retval SUCCESS or FAIL if error occurs. - */ - int (*SetCSI_clk_data_skip)(u32 idx, u8 rx_clk_skip_ns,u8 rx_data_skip_ns); - - /** @brief Configure MIPI hdr mode - @remarks MIPI interface only - @param[in] idx Sensor pad ID. - @param[in] hdr_mode HDR mode. - @param[in] bon_off Clock ON/OFF control. - @retval SUCCESS or FAIL if error occurs. - */ - int (*SetCSI_hdr_mode)(u32 idx, CUS_HDR_MODE hdr_mode, u8 bon_off); - -#if 0 - /** @brief Configure sensor RGBIR raw pixel order - @param[in] handle Handle to sensor driver. - @param[in] bayer_id Select pixel order - @retval SUCCESS or FAIL if error occurs. - */ - int (*RGBIRFmt)(CUS_SEN_RGBIR RGBIR_id); -#endif - - /** @brief Skip vif output frame - @remarks Skip Frame interface only - @param[in] idx Sensor pad ID. - @param[in] fps Sensor current fps. - @param[in] cnt Skip counter - @retval SUCCESS or FAIL if error occurs. - */ - int (*SetSkipFrame)(u32 idx, u32 fps, u32 cnt); -}ISensorIfAPI; - -typedef union { - //Parallel sensor - struct { - u32 parallel_reserved; //No additional attribute. - } attr_parallel; - - //MIPI sensor - struct { - u32 mipi_lane_num; - u32 mipi_data_format; //0: YUV 422 format. 1: RGB pattern. - u32 mipi_yuv_order; //YUYV or UYVY - u32 mipi_hsync_mode; - u32 mipi_sampling_delay; /** < MIPI start sampling delay */ /*bit 0~7: clk_skip_ns. bit 8~15: data_skip_ns*/ - CUS_HDR_MODE mipi_hdr_mode; - u32 mipi_hdr_virtual_channel_num; - } attr_mipi; - - //BT656 sensor - struct { - u32 bt656_total_ch; - u32 bt656_cur_ch; - u32 bt656_ch_det_en; - CUS_VIF_BT656_CHANNEL_SELECT bt656_ch_det_sel; - u32 bt656_bit_swap; - u32 bt656_8bit_mode; - CUS_VIF_BT656_VSYNC_DELAY bt656_vsync_delay; - u32 bt656_hsync_inv; - u32 bt656_vsync_inv; - u32 bt656_clamp_en; - } attr_bt656; -} InterfaceAttr_u; - -/////////////////////////////////////////////////////// - -/** @brief Sensor driver interface \n -The function here are implemented by sensor driver. -*/ -typedef struct __ms_cus_sensor{ - //short lib_idx; /**< Reserved , Do not use */ - version_info version; - char model_id[32]; /**< Please fill the sensor modle id string here then libcamera user can read model_id by using cameraGetSensorModelID() .*/ - void *sen_handle; /**< Reserved , Do not use */ - void *private_data; /**< sensor driver dependent variables should store in private_data and free when release */ - void *slave_mode_set; /**< Reserved , For sensor vsync/hsync control*/ - - // i2c - app_i2c_cfg i2c_cfg; /**< Sensor i2c setting */ - i2c_handle_t *i2c_bus; /**< Handle to sensor i2c API. */ - - // sensor if api - ISensorIfAPI *sensor_if_api; /**< sensor interface API */ - - // ae parameters - int ae_gain_delay; /**< How many frame delay from writing AE gain to take effect*/ - int ae_shutter_delay; /**< How many frame delay from writing AE shutter to take effect*/ - int ae_gain_ctrl_num; - int ae_shutter_ctrl_num; - - // polarity - CUS_CLK_POL reset_POLARITY; /** < Sensor REST pin polarity */ - CUS_CLK_POL pwdn_POLARITY; /** < Sensor Power Down pin polarity */ - CUS_CLK_POL VSYNC_POLARITY; /** < Sensor VSYNC polarity */ - CUS_CLK_POL HSYNC_POLARITY; /** < Sensor HSYNC pin polarity */ - CUS_CLK_POL PCLK_POLARITY; /** < Sensor Plxel Clock pin polarity */ - - // sensor data enum list*/ - CUS_CAMSENSOR_ISPTYPE isp_type; /** < Always use ISP_EXT */ - CUS_SEN_BAYER bayer_id; /** < Sensor bayer raw pixel order */ - CUS_SEN_RGBIR RGBIR_id; /** < Sensor bayer raw pixel order */ - CUS_SENIF_BUS sif_bus; /** < Select sensor interface */ - CUS_DATAPRECISION data_prec; /** < Raw data bits */ - CUS_SEN_FMT_CONV_MODE data_mode; /** < Data convert mode*/ - CUS_CAMSENSOR_ORIT orient; /** < Sensor mirror/flip */ - CUS_SENSOR_PAD_GROUP snr_pad_group; - CUS_SENSOR_MODE snr_pad_mode; /** < support master/slave mode sensor */ - - cus_camsensor_res_list video_res_supported; /** < Resolution list */ - InterfaceAttr_u interface_attr; - - //sensor calibration - u32 mclk; /** < Sensor master clock frequency */ - u32 sat_mingain; /**< Minimum AE gain */ - u32 ir_only_fmt; - - //////////////////////////////////////////////// - // system functions - //////////////////////////////////////////////// - - /** @brief Sensor power on sequence, I2C must be ready after calling this function - @param[in] handle Handle to sensor driver. - @remark Following configuration need to set up at this stage \n - @ref __ISensorIfAPI::Reset Reset sensor \n - @ref __ISensorIfAPI::PowerOff Sensor power down pin \n - @ref __ISensorIfAPI::MCLK Sensor master clock \n - @ref __ISensorIfAPI::SetIOPad ISP sensor IO \n - @ref __ISensorIfAPI::SetCSI_Clk [MIPI sensor only] MIPI clock\n - @ref __ISensorIfAPI::HsyncPol Hsync polarity\n - @ref __ISensorIfAPI::VsyncPol Vsync polarity\n - @ref __ISensorIfAPI::ClkPol [Parallel sensor only] Pixel clock polarity\n - @ref __ISensorIfAPI::BayerFmt Raw data format\n - @ref __ISensorIfAPI::DataPrecision Raw data pixel bits\n - @ref __ISensorIfAPI::FmtConv Raw data to ISP pixel convert\n - @retval SUCCESS or FAIL if error occurs. - */ - int (*pCus_sensor_poweron)(struct __ms_cus_sensor* handle, u32 idx); - - /** @brief Sensor power off - @param[in] handle Handle to sensor driver. - @retval SUCCESS or FAIL if error occurs. - */ - int (*pCus_sensor_poweroff)(struct __ms_cus_sensor* handle, u32 idx); - - /** @brief Sensor initialization - @param[in] handle Handle to sensor driver. - @retval SUCCESS or FAIL if error occurs. - @remark Fill sensor initial table here, Sensor beginning to output raw images after calling this function . - */ - int (*pCus_sensor_init)(struct __ms_cus_sensor* handle); - - /** @brief Sensor Post initialization - @param[in] handle Handle to sensor driver. - @retval SUCCESS or FAIL if error occurs. - @remark Fill sensor initial table here, Sensor beginning to output raw images after calling this function . - */ - int (*pCus_sensor_post_init)(struct __ms_cus_sensor* handle, u32 idx); - - /** @brief Release resources those allocated in cus_camsensor_init_handle() - @param[in] handle Handle to sensor driver. - @retval SUCCESS or FAIL if error occurs. - @remark Release resource allocated in \ref cus_camsensor_init_handle - */ - int (*pCus_sensor_release)(struct __ms_cus_sensor* handle); - - /** @brief Enter sensor suspend mode - @param[in] handle Handle to sensor driver. - @retval SUCCESS or FAIL if error occurs. - @remark ISP call this function before enter power saving mode - */ - int (*pCus_sensor_suspend)(struct __ms_cus_sensor* handle); - - /** @brief Sensor wakeup - @param[in] handle Handle to sensor driver. - @retval SUCCESS or FAIL if error occurs. - @remark ISP call this function after exit power saving mode - */ - int (*pCus_sensor_resume)(struct __ms_cus_sensor* handle); - - /** @brief Enable sensor pattern mode if sensor hardward supported - @param[in] handle Handle to sensor driver. - @param[in] mode Pattern select, if 0 disable pattern mode. - @retval SUCCESS or FAIL if error occurs. - @remark This function is optional - */ - int (*pCus_sensor_SetPatternMode)(struct __ms_cus_sensor* handle,u32 mode); - - // Normal - - /** @brief Check sensor ID and report to ISP sensor match or not - @param[in] handle Handle to sensor driver. - @param[out] id Receive 4 bytes customer defined sensor ID. - @retval Return SUCCESS if sensor matched or Retuen FAIL if sensor mismatch. - @remark Read sensor ID through I2C - */ - int (*pCus_sensor_GetSensorID)(struct __ms_cus_sensor* handle, u32 *id); - - /** @brief Get resolution list - @param[in] handle Handle to sensor driver. - @param[out] id Receive supported resolution list - @retval Return SUCCESS or FAIL if error occurs. - */ - int (*pCus_sensor_GetVideoRes)(struct __ms_cus_sensor* handle, u32 res_idx, cus_camsensor_res **res); - - /** @brief Get resolution list - @param[in] handle Handle to sensor driver. - @param[out] id Receive supported resolution list - @retval Return SUCCESS or FAIL if error occurs. - */ - int (*pCus_sensor_GetCurVideoRes)(struct __ms_cus_sensor* handle, u32 *cur_idx, cus_camsensor_res **res); - - /** @brief Select a sensor output resolution sensor list - @param[in] handle Handle to sensor driver. - @param[in] res_id Resolution id - @retval Return SUCCESS or FAIL if error occurs. - */ - int (*pCus_sensor_SetVideoRes)(struct __ms_cus_sensor* handle, u32 res_id); - - /** @brief Get sensor current mirror flip setting - @param[in] handle Handle to sensor driver. - @param[out] ori Receive Mirror/Flip setting. - @retval Return SUCCESS or FAIL if error occurs. - */ - int (*pCus_sensor_GetOrien)(struct __ms_cus_sensor* handle, CUS_CAMSENSOR_ORIT *ori); - - /** @brief Select a sensor mirror flip - @param[in] handle Handle to sensor driver. - @param[in] ori Mirror/Flip configuration. - @retval Return SUCCESS or FAIL if error occurs. - */ - int (*pCus_sensor_SetOrien)(struct __ms_cus_sensor* handle, CUS_CAMSENSOR_ORIT ori); - - /** @brief Get sensor capability - @param[in] handle Handle to sensor driver. - @param[out] cap Receive sensor capability - @retval Return SUCCESS or FAIL if error occurs. - */ - int (*pCus_sensor_GetSensorCap)(struct __ms_cus_sensor* handle, CUS_CAMSENSOR_CAP *cap); - - /////////////////////////////////////////////////////// - // AE - /////////////////////////////////////////////////////// - // unit: micro seconds - - /** @brief AE/Frame status change notification - @param[in] handle Handle to sensor driver. - @param[in] status Current status - @retval Return SUCCESS or FAIL if error occurs. - */ - int (*pCus_sensor_AEStatusNotify)(struct __ms_cus_sensor* handle, CUS_CAMSENSOR_AE_STATUS_NOTIFY status); - - /** @brief Get sensor shutter setting in us - @param[in] handle Handle to sensor driver. - @param[out] us Receive current shutter setting - @retval Return SUCCESS or FAIL if error occurs. - */ - int (*pCus_sensor_GetAEUSecs)(struct __ms_cus_sensor* handle, u32 *us); - - /** @brief Set sensor shutter in us - @param[in] handle Handle to sensor driver. - @param[in] us Shutter setting in us - @retval Return SUCCESS or FAIL if error occurs. - */ - int (*pCus_sensor_SetAEUSecs)(struct __ms_cus_sensor* handle, u32 us); - - // Gain: 1x = 1024 - /** @brief Get sensor current AE gain - @param[in] handle Handle to sensor driver. - @param[out] gain Receive current AE gain - @retval Return SUCCESS or FAIL if error occurs. - @remark gain: 1x = 1024 - */ - int (*pCus_sensor_GetAEGain)(struct __ms_cus_sensor* handle, u32* gain); - - /** @brief Set sensor AE gain - @param[in] handle Handle to sensor driver. - @param[in] gain AE gain - @retval Return SUCCESS or FAIL if error occurs. - @remark gain: 1x = 1024 - */ - int (*pCus_sensor_SetAEGain)(struct __ms_cus_sensor* handle, u32 gain); - - /** @brief Get supported shutter range - @param[in] handle Handle to sensor driver. - @param[out] min Receive minimum shutter which sensor can supported - @param[out] min Receive maxiimum shutter which sensor can supported - @retval Return SUCCESS or FAIL if error occurs. - @remark gain: 1x = 1024 - */ - int (*pCus_sensor_GetAEMinMaxUSecs)(struct __ms_cus_sensor* handle, u32 *min, u32 *max); - - /** @brief Get supported AE gain range - @param[in] handle Handle to sensor driver. - @param[out] min Receive minimum gain which sensor can supported - @param[out] min Receive maxiimum gain which sensor can supported - @retval Return SUCCESS or FAIL if error occurs. - @remark gain: 1x = 1024 - */ - int (*pCus_sensor_GetAEMinMaxGain)(struct __ms_cus_sensor* handle, u32 *min, u32 *max); - - // frame rate control - /** @brief Get current fps - @param[in] handle Handle to sensor driver. - @retval Return current frame rate per second - */ - int (*pCus_sensor_GetFPS)(struct __ms_cus_sensor* handle); - - /** @brief Set sensor output fps - @param[in] handle Handle to sensor driver. - @param[in] fps - @retval Return SUCCESS or FAIL if fps is out of range. - */ - int (*pCus_sensor_SetFPS)(struct __ms_cus_sensor* handle, u32 fps); - - //[OPTIONAL] sensor calibration - /** @brief Optional function */ - int (*pCus_sensor_SetAEGain_cal)(struct __ms_cus_sensor* handle, u32); - - /** @brief Optional function */ - int (*pCus_sensor_setCaliData_gain_linearity)(struct __ms_cus_sensor* handle, CUS_GAIN_GAP_ARRAY* pArray ,u32 num); - - //Get shutter information - /** @brief Get shutter information - @param[in] handle Handle to sensor driver. - @param[out] info return shutter information. - @retval Return current frame rate per second - */ - int (*pCus_sensor_GetShutterInfo)(struct __ms_cus_sensor* handle,CUS_SHUTTER_INFO *info); - - /** @brief Get resolution list number - @param[in] handle Handle to sensor driver. - @param[out] ulres_num resolution list number - @retval Return SUCCESS or FAIL if error occurs. - */ - int (*pCus_sensor_GetVideoResNum)(struct __ms_cus_sensor* handle, u32 *ulres_num); - - //Get shutter information - /** @brief Sensor vendor command - @param[in] handle Handle to sensor driver. - @param[in] reserved - @param[in] param Command input - @param[out] out Command output - @retval Return SUCCESS or FAIL if error occurs. - */ - int (*pCus_sensor_CustDefineFunction)(struct __ms_cus_sensor* handle,u32 cmd_id, void *param); - - //Get Source Type - /** @brief Get Source Type - @param[in] handle Handle to sensor driver. - @param[in] plane id. - @param[out] psrc_type info - @retval Return SUCCESS or FAIL if error occurs. - */ - int (*pCus_sensor_GetSrcType)(struct __ms_cus_sensor* handle, u32 plane_id, CUS_SNR_ANADEC_SRC_TYPE *psrc_type); - - // Gain: 1x = 1024 - /** @brief Try AE gain value - @param[in] handle Handle to sensor driver. - @param[in] Target AE gain value to try - @retval Return actual sensor gain will apply on the HW. - @remark gain: 1x = 1024 - */ - u32 (*pCus_sensor_TryAEGain)(struct __ms_cus_sensor* handle, u32 gain); - - // Return actual shutter - /** @brief Try AE shutter value - @param[in] handle Handle to sensor driver. - @param[in] Target AE shutter value to try , in us - @retval Return actual sensor gain will apply on the HW. - @remark gain: 1x = 1024 - */ - u32 (*pCus_sensor_TryAEShutter)(struct __ms_cus_sensor* handle, u32 us); -} ms_cus_sensor; - -/** @brief Sensor driver entry. ISP call this function before start using sensor driver. \n -ISP pass \ref ms_cus_sensor struct to obtain the driver information and function entries. \n -And all allocated resources here should be released at \ref __ms_cus_sensor::pCus_sensor_release. -Every sensor driver must implement this api. -@param[in] drv_handle A uninitialized \ref ms_cus_sensor struct from ISP, Sensor driver fill the driver information and function entries to drv_handle. -@retval SUCCESS or FAIL if error occurs. -*/ - -typedef int (*SensorInitHandle)(ms_cus_sensor* handle); - -#ifdef __cplusplus -} -#endif - -#endif /* DRV_MS_CUS_SENSOR_H_ */ -/** @} */ // end of ISP Sensor Driver Interface diff --git a/general/package/sigmastar-osdrv-sensor/src/infinity6b0/include/drv_sensor.h b/general/package/sigmastar-osdrv-sensor/src/infinity6b0/include/drv_sensor.h deleted file mode 100644 index 36452880..00000000 --- a/general/package/sigmastar-osdrv-sensor/src/infinity6b0/include/drv_sensor.h +++ /dev/null @@ -1,53 +0,0 @@ -/* Copyright (c) 2018-2019 Sigmastar Technology Corp. - All rights reserved. - - Unless otherwise stipulated in writing, any and all information contained -herein regardless in any format shall remain the sole proprietary of -Sigmastar Technology Corp. and be kept in strict confidence -(Sigmastar Confidential Information) by the recipient. -Any unauthorized act including without limitation unauthorized disclosure, -copying, use, reproduction, sale, distribution, modification, disassembling, -reverse engineering and compiling of the contents of Sigmastar Confidential -Information is unlawful and strictly prohibited. Sigmastar hereby reserves the -rights to any and all damages, losses, costs and expenses resulting therefrom. -*/ - -#ifndef DRV_SENSOR_H -#define DRV_SENSOR_H - -#include - -#define SENSOR_DMSG(args...) do{}while(0) -#define SENSOR_EMSG(args...) CamOsPrintf(args) -#define SENSOR_IMSG(args...) CamOsPrintf(args) -#if 0 -typedef enum { - I2C_FMT_A8D8, /**< 8 bits Address, 8 bits Data */ - I2C_FMT_A16D8,/**< 16 bits Address 8 bits Data */ - I2C_FMT_A8D16,/**< 8 bits Address 16 bits Data */ - I2C_FMT_A16D16,/**< 16 bits Address 16 bits Data */ - I2C_FMT_END/**< Reserved */ -} ISP_I2C_FMT; -#endif - -extern s32 WriteRegisterPair(int slaveAddr, short reg, unsigned short value, ISP_I2C_FMT fmt); -extern u64 intlog10(u32 value); -extern u64 intlog2(u32 value); -extern s32 DrvRegisterSensorDriver(u32 nCamID, SensorInitHandle pfnSensorInitHandle); -extern s32 DrvRegisterPlaneDriver(u32 nCamID, u32 nPlaneID, SensorInitHandle pfnSensorInitHandle); -extern s32 DrvRegisterSensorDriverEx(u32 nSNRPadID, SensorInitHandle pfnSensorInitHandle, void *pPrivateData); -extern s32 DrvRegisterPlaneDriverEx(u32 nSNRPadID, u32 nPlaneID, SensorInitHandle pfnSensorInitHandle, void *pPrivateData); -extern s32 DrvSensorRelease(u32 nSNRPadID); -extern s32 DrvSensorEarlyInitSync(u32 nSNRPadID); -extern s32 DrvRegisterSensorI2CSlaveID(u32 nCamID, u32 Slaveid); -extern s32 DrvRegisterPlaneI2CSlaveID(u32 nCamID, u32 nPlaneID, u32 Slaveid); -extern s32 DrvSensorHandleVer(u32 version_major, u32 version_minor); -extern s32 DrvSensorIFVer(u32 version_major, u32 version_minor); -extern s32 DrvSensorI2CVer(u32 version_major, u32 version_minor); -#define DrvUnregisterSensorDriverEx(nSNRPadID) DrvSensorRelease((nSNRPadID)) - -#define SENSOR_USLEEP(us) CamOsUsSleep(us) -#define SENSOR_MSLEEP(ms) CamOsMsSleep(ms) -#define SENSOR_UDELAY(us) CamOsUsDelay(us) -#define SENSOR_MDELAY(ms) CamOsMsDelay(ms) -#endif diff --git a/general/package/sigmastar-osdrv-sensor/src/infinity6b0/include/drv_sensor_common.h b/general/package/sigmastar-osdrv-sensor/src/infinity6b0/include/drv_sensor_common.h deleted file mode 100644 index 88b2b38c..00000000 --- a/general/package/sigmastar-osdrv-sensor/src/infinity6b0/include/drv_sensor_common.h +++ /dev/null @@ -1,379 +0,0 @@ -/* Copyright (c) 2018-2019 Sigmastar Technology Corp. - All rights reserved. - - Unless otherwise stipulated in writing, any and all information contained -herein regardless in any format shall remain the sole proprietary of -Sigmastar Technology Corp. and be kept in strict confidence -(Sigmastar Confidential Information) by the recipient. -Any unauthorized act including without limitation unauthorized disclosure, -copying, use, reproduction, sale, distribution, modification, disassembling, -reverse engineering and compiling of the contents of Sigmastar Confidential -Information is unlawful and strictly prohibited. Sigmastar hereby reserves the -rights to any and all damages, losses, costs and expenses resulting therefrom. -*/ - -#ifndef _SENSOR_OS_WRAPPER_H_ -#define _SENSOR_OS_WRAPPER_H_ - -#if defined(__KERNEL__) -#define CAM_OS_LINUX_KERNEL -#endif - -#include -#include -#include - -/******************************************************** RTK ***********************************************************/ -#if defined(CAM_OS_RTK) -typedef unsigned char bool; -#ifndef true -#define true 1 -#define false 0 -#endif - -#ifndef _SENSOR_SLAVE_ID_ -#define _SENSOR_SLAVE_ID_ 0 -#endif - -#define SENSOR_DRV_ENTRY_IMPL_BEGIN(NAME) - -#define SENSOR_DRV_ENTRY_IMPL_END(Name,LinearEntry,HdrSefEntry,HdrLefEntry)\ -int Name##_init_driver(unsigned char chmap)\ -{\ - int nCamID=0;\ - /*To avoid compile warning*/\ - void* p0 = LinearEntry;\ - void* p1 = HdrSefEntry;\ - void* p2 = HdrLefEntry;\ - for(nCamID=0;nCamID<4;++nCamID)\ - {\ - if((chmap>>nCamID)&0x1)\ - {\ - if(p0){ DrvRegisterSensorDriver(nCamID, LinearEntry);\ - DrvRegisterSensorI2CSlaveID(nCamID, (_SENSOR_SLAVE_ID_>>(nCamID*8))&0xFF);\ - SENSOR_DMSG("Connect %s linear to sensor pad %d\n",__FUNCTION__, nCamID);\ - }\ - if(p1){ DrvRegisterPlaneDriver(nCamID, 1, HdrSefEntry);\ - DrvRegisterPlaneI2CSlaveID(nCamID, 1, (_SENSOR_SLAVE_ID_>>(nCamID*8))&0xFF);\ - SENSOR_DMSG("Connect %s SEF to vif sensor pad %d\n",__FUNCTION__, nCamID);\ - }\ - if(p2){ DrvRegisterPlaneDriver(nCamID, 0, HdrLefEntry);\ - DrvRegisterPlaneI2CSlaveID(nCamID, 0, (_SENSOR_SLAVE_ID_>>(nCamID*8))&0xFF);\ - SENSOR_DMSG("Connect %s LEF to sensor pad %d\n",__FUNCTION__, nCamID);\ - }\ - }\ - }\ - return 0;\ -} - -static volatile int lane_num = 2; -static volatile int hdr_lane_num=2; - -#define SENSOR_DRV_PARAM_MCLK() "NONE" -#define SENSOR_USLEEP_(us) {CamOsUsDelay(us);} -#define SENSOR_MSLEEP_(ms) {CamOsMsDelay(ms);} - -/*Extension version*/ -#define SENSOR_DRV_ENTRY_IMPL_BEGIN_EX(NAME) SENSOR_DRV_ENTRY_IMPL_BEGIN(NAME) - -#define MAX_CAMID_LEN 4 -#define SENSOR_DRV_ENTRY_IMPL_END_EX(Name,LinearEntry,HdrSefEntry,HdrLefEntry,PrivateDataType)\ -static PrivateDataType* g_pData[2][MAX_CAMID_LEN] = {{0,0,0,0}, {0,0,0,0}};\ -static PrivateDataType g_PrivData[2][MAX_CAMID_LEN];\ -int Name##_init_driver(unsigned char chmap)\ -{\ - int nCamID=0;\ - /*To avoid compile warning*/\ - void* p0 = LinearEntry;\ - void* p1 = HdrSefEntry;\ - void* p2 = HdrLefEntry;\ - for(nCamID=0;nCamID>nCamID)&0x1)\ - {\ - if(p0){\ - /*void* pData = CamOsMemAlloc(sizeof(PrivateDataType));*/\ - void* pData = &g_PrivData[0][nCamID];/*Change private data to static var*/\ - memset(pData,0,sizeof(PrivateDataType));\ - DrvRegisterSensorDriverEx(nCamID, LinearEntry,pData);\ - DrvRegisterSensorI2CSlaveID(nCamID, (_SENSOR_SLAVE_ID_>>(nCamID*8))&0xFF);\ - SENSOR_DMSG("Connect %s linear to sensor pad %d\n",__FUNCTION__, nCamID);\ - g_pData[0][nCamID] = pData;\ - }\ - if(p1||p2){\ - /*void* pData = CamOsMemAlloc(sizeof(PrivateDataType));*/\ - void* pData = &g_PrivData[1][nCamID];/*Change private data to static var*/\ - memset(pData,0,sizeof(PrivateDataType));\ - if(p1){\ - DrvRegisterPlaneDriverEx(nCamID, 1, HdrSefEntry,pData);\ - DrvRegisterPlaneI2CSlaveID(nCamID, 1, (_SENSOR_SLAVE_ID_>>(nCamID*8))&0xFF);\ - SENSOR_DMSG("Connect %s SEF to vif sensor pad %d\n",__FUNCTION__, nCamID);\ - }\ - if(p2){\ - DrvRegisterPlaneDriverEx(nCamID, 0, HdrLefEntry,pData);\ - DrvRegisterPlaneI2CSlaveID(nCamID, 0, (_SENSOR_SLAVE_ID_>>(nCamID*8))&0xFF);\ - SENSOR_DMSG("Connect %s LEF to sensor pad %d\n",__FUNCTION__, nCamID);\ - }\ - g_pData[1][nCamID] = pData;\ - }\ - DrvSensorEarlyInitSync(nCamID);\ - }\ - }\ - return 0;\ -}\ -\ -int Name##_deinit_driver(unsigned char chmap)\ -{\ - int nCamID=0;\ - for(nCamID=0;nCamID>nCamID)&0x1)\ - {\ - if(g_pData[0][nCamID] || g_pData[1][nCamID])\ - {\ - DrvUnregisterSensorDriverEx(nCamID);\ - if(g_pData[0][nCamID]){\ - /*CamOsMemRelease((void*)g_pData[0][nCamID]);*/\ - g_pData[0][nCamID] = 0;\ - }\ - if(g_pData[1][nCamID]){\ - /*CamOsMemRelease((void*)g_pData[1][nCamID]);*/\ - g_pData[1][nCamID] = 0;\ - }\ - }\ - }\ - }\ - return 0;\ -} -/******************************************************** LINUX ***********************************************************/ -#elif defined(CAM_OS_LINUX_KERNEL) -#include -#include -#include -#include -#include -#define SENSOR_DRV_ENTRY_IMPL_BEGIN(Name) \ -int chmap = 0;\ -module_param(chmap, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);\ -MODULE_PARM_DESC(chmap, "VIF channel mapping");\ -char *mclk = "use default parameter";\ -module_param(mclk, charp, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);\ -MODULE_PARM_DESC(mclk, "Assign MCLK"); -int lane_num = 2;\ -module_param(lane_num, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);\ -MODULE_PARM_DESC(lane_num, "sensor output lane number"); -int hdr_lane_num = 4;\ -module_param(hdr_lane_num, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);\ -MODULE_PARM_DESC(hdr_lane_num, "sensor output lane number"); -int i2c_slave_id = 0;\ -module_param(i2c_slave_id, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);\ -MODULE_PARM_DESC(i2c_slave_id, "sensor i2c slave id"); - -#define SENSOR_DRV_ENTRY_IMPL_END(Name,LinearEntry,HdrSefEntry,HdrLefEntry) \ -static int __init Name##_init_driver(void)\ -{\ - int nCamID=0;\ - void* p0 = LinearEntry;\ - void* p1 = HdrSefEntry;\ - void* p2 = HdrLefEntry;\ - if(DrvSensorHandleVer(CUS_CAMSENSOR_HANDLE_MAJ_VER, CUS_CAMSENSOR_HANDLE_MIN_VER)==FAIL)\ - return FAIL;\ - if(DrvSensorIFVer(CUS_CAMSENSORIF_MAJ_VER, CUS_CAMSENSORIF_MIN_VER)==FAIL)\ - return FAIL;\ - if(DrvSensorI2CVer(CUS_CAMSENSOR_I2C_MAJ_VER, CUS_CAMSENSOR_I2C_MIN_VER)==FAIL)\ - return FAIL;\ - for(nCamID=0;nCamID<4;++nCamID)\ - {\ - if((chmap>>nCamID)&0x1)\ - {\ - if(p0){ DrvRegisterSensorDriver(nCamID, LinearEntry);\ - DrvRegisterSensorI2CSlaveID(nCamID, (i2c_slave_id>>(nCamID*8))&0xFF);\ - pr_info("Connect %s linear to sensor pad %d\n",__FUNCTION__, nCamID);\ - }\ - if(p1){ DrvRegisterPlaneDriver(nCamID, 1, HdrSefEntry);\ - DrvRegisterPlaneI2CSlaveID(nCamID, 1, (i2c_slave_id>>(nCamID*8))&0xFF);\ - pr_info("Connect %s SEF to vif sensor pad %d\n",__FUNCTION__, nCamID);\ - }\ - if(p2){ DrvRegisterPlaneDriver(nCamID, 0, HdrLefEntry);\ - DrvRegisterPlaneI2CSlaveID(nCamID, 0, (i2c_slave_id>>(nCamID*8))&0xFF);\ - pr_info("Connect %s LEF to sensor pad %d\n",__FUNCTION__, nCamID);\ - }\ - }\ - }\ - return 0;\ -}\ -static void __exit Name##_exit_driver(void)\ -{\ - pr_info("sensordrv exit");\ -}\ -subsys_initcall(Name##_init_driver);\ -module_exit(Name##_exit_driver);\ -MODULE_DESCRIPTION("Sensor_"#Name);\ -MODULE_AUTHOR("SigmaStar");\ -MODULE_LICENSE("Proprietary"); - -#define SENSOR_DRV_PARAM_MCLK() (mclk) -#define SENSOR_USLEEP_(us) CamOsUsSleep(us) -#define SENSOR_MSLEEP_(ms) CamOsMsSleep(ms) - -/*Extension version*/ -#define SENSOR_DRV_ENTRY_IMPL_BEGIN_EX(Name) SENSOR_DRV_ENTRY_IMPL_BEGIN(Name) - -#define MAX_CAMID_LEN 4 -#define SENSOR_DRV_ENTRY_IMPL_END_EX(Name,LinearEntry,HdrSefEntry,HdrLefEntry,PrivateDataType) \ -static PrivateDataType* g_pData[2][MAX_CAMID_LEN] = {{0,0,0,0}, {0,0,0,0}};\ -static int __init Name##_init_driver(void)\ -{\ - int nCamID=0;\ - void* p0 = LinearEntry;\ - void* p1 = HdrSefEntry;\ - void* p2 = HdrLefEntry;\ - if(DrvSensorHandleVer(CUS_CAMSENSOR_HANDLE_MAJ_VER, CUS_CAMSENSOR_HANDLE_MIN_VER)==FAIL)\ - return FAIL;\ - if(DrvSensorIFVer(CUS_CAMSENSORIF_MAJ_VER, CUS_CAMSENSORIF_MIN_VER)==FAIL)\ - return FAIL;\ - if(DrvSensorI2CVer(CUS_CAMSENSOR_I2C_MAJ_VER, CUS_CAMSENSOR_I2C_MIN_VER)==FAIL)\ - return FAIL;\ - for(nCamID=0;nCamID>nCamID)&0x1)\ - {\ - if(p0){\ - void* pData = CamOsMemAlloc(sizeof(PrivateDataType));\ - memset(pData,0,sizeof(PrivateDataType));\ - DrvRegisterSensorDriverEx(nCamID, LinearEntry,pData);\ - DrvRegisterSensorI2CSlaveID(nCamID, (i2c_slave_id>>(nCamID*8))&0xFF);\ - pr_info("Connect %s linear to sensor pad %d\n",__FUNCTION__, nCamID);\ - g_pData[0][nCamID] = pData;\ - }\ - if(p1||p2){\ - void* pData = CamOsMemAlloc(sizeof(PrivateDataType));\ - memset(pData,0,sizeof(PrivateDataType));\ - if(p1){\ - DrvRegisterPlaneDriverEx(nCamID, 1, HdrSefEntry,pData);\ - DrvRegisterPlaneI2CSlaveID(nCamID, 1, (i2c_slave_id>>(nCamID*8))&0xFF);\ - pr_info("Connect %s SEF to vif sensor pad %d\n",__FUNCTION__, nCamID);\ - }\ - if(p2){\ - DrvRegisterPlaneDriverEx(nCamID, 0, HdrLefEntry,pData);\ - DrvRegisterPlaneI2CSlaveID(nCamID, 0, (i2c_slave_id>>(nCamID*8))&0xFF);\ - pr_info("Connect %s LEF to sensor pad %d\n",__FUNCTION__, nCamID);\ - }\ - g_pData[1][nCamID] = pData;\ - }\ - }\ - }\ - return 0;\ -}\ -static void __exit Name##_exit_driver(void)\ -{\ - int nCamID=0;\ - for(nCamID=0;nCamID>nCamID)&0x1)\ - {\ - if(g_pData[0][nCamID] || g_pData[1][nCamID])\ - {\ - DrvUnregisterSensorDriverEx(nCamID);\ - if(g_pData[0][nCamID]){\ - CamOsMemRelease((void*)g_pData[0][nCamID]);\ - g_pData[0][nCamID] = 0;\ - }\ - if(g_pData[1][nCamID]){\ - CamOsMemRelease((void*)g_pData[1][nCamID]);\ - g_pData[1][nCamID] = 0;\ - }\ - }\ - }\ - }\ -}\ -subsys_initcall(Name##_init_driver);\ -module_exit(Name##_exit_driver);\ -MODULE_DESCRIPTION("Sensor_"#Name);\ -MODULE_AUTHOR("SigmaStar");\ -MODULE_LICENSE("Proprietary"); - -//define 3 ch AHD application impl -#define SENSOR_DRV_ENTRY_3CHAHD_IMPL_END_EX(Name,LinearEntry,AhdCh0Entry,AhdCh1Entry, AhdCh2Entry,PrivateDataType)\ -static PrivateDataType* g_pData[2][MAX_CAMID_LEN] = {{0,0,0,0}, {0,0,0,0}};\ -static int __init Name##_init_driver(void)\ -{\ - int nCamID=0;\ - void* p0 = LinearEntry;\ - void* p1 = AhdCh0Entry;\ - void* p2 = AhdCh1Entry;\ - void* p3 = AhdCh2Entry;\ - if(DrvSensorHandleVer(CUS_CAMSENSOR_HANDLE_MAJ_VER, CUS_CAMSENSOR_HANDLE_MIN_VER)==FAIL)\ - return FAIL;\ - if(DrvSensorIFVer(CUS_CAMSENSORIF_MAJ_VER, CUS_CAMSENSORIF_MIN_VER)==FAIL)\ - return FAIL;\ - if(DrvSensorI2CVer(CUS_CAMSENSOR_I2C_MAJ_VER, CUS_CAMSENSOR_I2C_MIN_VER)==FAIL)\ - return FAIL;\ - for(nCamID=0;nCamID>nCamID)&0x1)\ - {\ - if(p0){\ - void* pData = CamOsMemAlloc(sizeof(PrivateDataType));\ - memset(pData,0,sizeof(PrivateDataType));\ - DrvRegisterSensorDriverEx(nCamID, LinearEntry,pData);\ - DrvRegisterSensorI2CSlaveID(nCamID, (i2c_slave_id>>(nCamID*8))&0xFF);\ - pr_info("Connect %s linear to sensor pad %d\n",__FUNCTION__, nCamID);\ - g_pData[0][nCamID] = pData;\ - }\ - if(p1||p2||p3){\ - void* pData = CamOsMemAlloc(sizeof(PrivateDataType));\ - memset(pData,0,sizeof(PrivateDataType));\ - if(p1){\ - DrvRegisterPlaneDriverEx(nCamID, 0, AhdCh0Entry,pData);\ - DrvRegisterPlaneI2CSlaveID(nCamID, 0, (i2c_slave_id>>(nCamID*8))&0xFF);\ - pr_info("Connect %s AHD0 to vif sensor pad %d\n",__FUNCTION__, nCamID);\ - }\ - if(p2){\ - DrvRegisterPlaneDriverEx(nCamID, 1, AhdCh1Entry,pData);\ - DrvRegisterPlaneI2CSlaveID(nCamID, 1, (i2c_slave_id>>(nCamID*8))&0xFF);\ - pr_info("Connect %s AHD1 to sensor pad %d\n",__FUNCTION__, nCamID);\ - }\ - if(p3){\ - DrvRegisterPlaneDriverEx(nCamID, 2, AhdCh2Entry,pData);\ - DrvRegisterPlaneI2CSlaveID(nCamID, 2, (i2c_slave_id>>(nCamID*8))&0xFF);\ - pr_info("Connect %s AHD2 to sensor pad %d\n",__FUNCTION__, nCamID);\ - }\ - g_pData[1][nCamID] = pData;\ - }\ - }\ - }\ - return 0;\ -}\ -static void __exit Name##_exit_driver(void)\ -{\ - int nCamID=0;\ - for(nCamID=0;nCamID>nCamID)&0x1)\ - {\ - if(g_pData[0][nCamID] || g_pData[1][nCamID])\ - {\ - DrvUnregisterSensorDriverEx(nCamID);\ - if(g_pData[0][nCamID]){\ - CamOsMemRelease((void*)g_pData[0][nCamID]);\ - g_pData[0][nCamID] = 0;\ - }\ - if(g_pData[1][nCamID]){\ - CamOsMemRelease((void*)g_pData[1][nCamID]);\ - g_pData[1][nCamID] = 0;\ - }\ - }\ - }\ - }\ -}\ -subsys_initcall(Name##_init_driver);\ -module_exit(Name##_exit_driver);\ -MODULE_DESCRIPTION("Sensor_"#Name);\ -MODULE_AUTHOR("SigmaStar");\ -MODULE_LICENSE("Proprietary"); - -#endif //end of CAM_OS_LINUX_KERNEL - - -#endif //endif _SENSOR_OS_WRAPPER_H_ diff --git a/general/package/sigmastar-osdrv-sensor/src/infinity6b0/include/drv_sensor_init_table.h b/general/package/sigmastar-osdrv-sensor/src/infinity6b0/include/drv_sensor_init_table.h deleted file mode 100644 index 10368d9e..00000000 --- a/general/package/sigmastar-osdrv-sensor/src/infinity6b0/include/drv_sensor_init_table.h +++ /dev/null @@ -1,114 +0,0 @@ -/* Copyright (c) 2018-2019 Sigmastar Technology Corp. - All rights reserved. - - Unless otherwise stipulated in writing, any and all information contained -herein regardless in any format shall remain the sole proprietary of -Sigmastar Technology Corp. and be kept in strict confidence -(Sigmastar Confidential Information) by the recipient. -Any unauthorized act including without limitation unauthorized disclosure, -copying, use, reproduction, sale, distribution, modification, disassembling, -reverse engineering and compiling of the contents of Sigmastar Confidential -Information is unlawful and strictly prohibited. Sigmastar hereby reserves the -rights to any and all damages, losses, costs and expenses resulting therefrom. -*/ - -#ifndef _DRV_SENSOR_INIT_H_ -#define _DRV_SENSOR_INIT_H_ - -//#define SENSOR_INIT_CMDQ_MODE -#define SENSOR_INIT_DRV_MODE - -/* for sensor driver */ -#define I2C_1A1B_W(reg,val) {(reg),(val)} -#define CMDQ_DELAY_MS(ms) {(0xFFFF),(ms)} - -#define I2CM_1A1D_W(slave_addr,reg,val) \ - {(reg),(val)} - -#define I2CM_1A1D_W_BURST2(slave_addr,reg,d0,d1) \ - {(reg),(d0)},\ - {(reg)+1,(d1)} - -#define I2CM_1A1D_W_BURST3(slave_addr,reg,d0,d1,d2) \ - {(reg),(d0)},\ - {(reg)+1,(d1)},\ - {(reg)+2,(d2)} - -#define I2CM_1A1D_W_BURST4(slave_addr,reg,d0,d1,d2,d3) \ - {(reg),(d0)},\ - {(reg)+1,(d1)},\ - {(reg)+2,(d2)},\ - {(reg)+3,(d3)} - -#define I2CM_1A1D_W_BURST5(slave_addr,reg,d0,d1,d2,d3,d4) \ - {(reg),(d0)},\ - {(reg)+1,(d1)},\ - {(reg)+2,(d2)},\ - {(reg)+3,(d3)},\ - {(reg)+4,(d4)} - -#define I2CM_1A1D_W_BURST6(slave_addr,reg,d0,d1,d2,d3,d4,d5) \ - {(reg),(d0)},\ - {(reg)+1,(d1)},\ - {(reg)+2,(d2)},\ - {(reg)+3,(d3)},\ - {(reg)+4,(d4)},\ - {(reg)+5,(d5)} - -#define I2CM_1A1D_W_BURST7(slave_addr,reg,d0,d1,d2,d3,d4,d5,d6) \ - {(reg),(d0)},\ - {(reg)+1,(d1)},\ - {(reg)+2,(d2)},\ - {(reg)+3,(d3)},\ - {(reg)+4,(d4)},\ - {(reg)+5,(d5)},\ - {(reg)+6,(d6)} - -#define I2CM_2A1D_W(slave_addr,reg,val) \ - {(reg),(val)} - -#define I2CM_2A1D_W_BURST2(slave_addr,reg,d0,d1) \ - {(reg),(d0)},\ - {(reg)+1,(d1)} - -#define I2CM_2A1D_W_BURST3(slave_addr,reg,d0,d1,d2) \ - {(reg),(d0)},\ - {(reg)+1,(d1)},\ - {(reg)+2,(d2)} - -#define I2CM_2A1D_W_BURST4(slave_addr,reg,d0,d1,d2,d3) \ - {(reg),(d0)},\ - {(reg)+1,(d1)},\ - {(reg)+2,(d2)},\ - {(reg)+3,(d3)} - -#define I2CM_2A1D_W_BURST5(slave_addr,reg,d0,d1,d2,d3,d4) \ - {(reg),(d0)},\ - {(reg)+1,(d1)},\ - {(reg)+2,(d2)},\ - {(reg)+3,(d3)},\ - {(reg)+4,(d4)} - -#define I2CM_2A1D_W_BURST6(slave_addr,reg,d0,d1,d2,d3,d4,d5) \ - {(reg),(d0)},\ - {(reg)+1,(d1)},\ - {(reg)+2,(d2)},\ - {(reg)+3,(d3)},\ - {(reg)+4,(d4)},\ - {(reg)+5,(d5)} - -#define I2CM_2A2D_W(slave_addr,reg,val) \ - {(reg),(val)} - -#define I2CM_2A2D_W_BURST2(slave_addr,reg,d0,d1) \ - {(reg),(d0)},\ - {(reg)+1,(d1)} - -#define I2CM_2A2D_W_BURST3(slave_addr,reg,d0,d1,d2) \ - {(reg),(d0)},\ - {(reg)+1,(d1)},\ - {(reg)+2,(d2)} - -#define SENSOR_INIT_TABLE I2C_ARRAY - -#endif diff --git a/general/package/sigmastar-osdrv-sensor/src/infinity6b0/include/sensor_i2c_api.h b/general/package/sigmastar-osdrv-sensor/src/infinity6b0/include/sensor_i2c_api.h deleted file mode 100644 index 4de7027c..00000000 --- a/general/package/sigmastar-osdrv-sensor/src/infinity6b0/include/sensor_i2c_api.h +++ /dev/null @@ -1,168 +0,0 @@ -/* Copyright (c) 2018-2019 Sigmastar Technology Corp. - All rights reserved. - - Unless otherwise stipulated in writing, any and all information contained -herein regardless in any format shall remain the sole proprietary of -Sigmastar Technology Corp. and be kept in strict confidence -(Sigmastar Confidential Information) by the recipient. -Any unauthorized act including without limitation unauthorized disclosure, -copying, use, reproduction, sale, distribution, modification, disassembling, -reverse engineering and compiling of the contents of Sigmastar Confidential -Information is unlawful and strictly prohibited. Sigmastar hereby reserves the -rights to any and all damages, losses, costs and expenses resulting therefrom. -*/ - -/*! @file isp_i2c_api.h - @brief This file contains Infinity ISP I2C basic API. -*/ - -/** @defgroup group1 ISP I2C API -* @{ -*/ -#ifndef ISP_I2C_API_H -#define ISP_I2C_API_H - -#define SENSOR_I2C_SUCCESS (0) -#define SENSOR_I2C_FAIL (-1) -#define SENSOR_I2C_NOT_SUPPORT (-2) - -/**@brief handle version info */ -typedef struct _version_info{ - u16 major; - u16 minor; -}__attribute__((packed, aligned(1))) version_info; - -/*! @brief I2C API handle.*/ -struct __i2c_handle_t; - -/*! @brief I2C batch read/write data.*/ -typedef struct _I2C_ARRAY{ - u16 reg; /**< Register address.*/ - u16 data; /**< Data.*/ -} I2C_ARRAY; - -/*! @brief I2C burst read/write data.*/ -typedef struct _I2C_ARRAY_BURST{ - u16 reg; /**< Register address.*/ - u16 *data; /**< Data.*/ -} I2C_ARRAY_BURST; - -/*! @brief I2C data direction*/ -typedef enum { - I2C_RW_R, /**< Data direction read.*/ - I2C_RW_W,/**< Data direction write.*/ -} I2C_RW; - -/*! @brief Use for i2c_array_rw only */ -typedef struct _I2C_CPX_ARRAY{ - I2C_RW rw; /**< Data direction */ - u16 reg; /**< Device register address */ - u16 data; /**< Data write to device or read from device*/ -}__attribute__((packed, aligned(1))) I2C_CPX_ARRAY; - -/*! @brief Internal use for I2C API*/ -typedef enum { - I2C_FMT_A8D8, /**< 8 bits Address, 8 bits Data */ - I2C_FMT_A16D8,/**< 16 bits Address 8 bits Data */ - I2C_FMT_A8D16,/**< 8 bits Address 16 bits Data */ - I2C_FMT_A16D16,/**< 16 bits Address 16 bits Data */ - I2C_FMT_END/**< Reserved */ -} ISP_I2C_FMT; - -/*! @brief ISP_I2C_MODE Internal use for I2C API*/ -typedef enum { - I2C_LEGACY_MODE, /**< Do not use */ - I2C_NORMAL_MODE /**< Sensor driver can only use I2C_NORMAL_MODE */ -} ISP_I2C_MODE; - - -/*! @brief app_i2c_cfg I2C setting for sensor and bus.*/ -typedef struct _app_i2c_cfg{ - ISP_I2C_MODE mode; //!< I2C_NORMAL_MODE only - ISP_I2C_FMT fmt; //!< I2C data format - u32 speed; //!< I2C clock in Hz - u16 address; //!< Sensor slave address , bit[7~1] are available, bit[0] user don't care - u16 reserved; -}__attribute__((packed, aligned(1))) app_i2c_cfg; - -/*! @brief The interface of I2C APIs export to user*/ -typedef struct _i2c_handle_t { - //int version; - version_info version; - void *pdata; //i2c_private_data - - u32 nSensorID; - /** @brief Open isp i2c port. This function must be called before using isp I2C APIs. - Call i2c_close to close isp i2c port and allocated resource. - @param[in] handle Handle to isp i2c api. - @param[in] cfg I2C initial configuration. - @retval SENSOR_I2C_SUCCESS or SENSOR_I2C_FAIL if error occurs. - */ - int (*i2c_open)(struct _i2c_handle_t* handle, app_i2c_cfg *cfg); - - /** @brief Close isp I2C port. Call this functon to release resource which allocated form i2c_open. - @param[in] handle Handle to isp i2c api. - @param[in] cfg I2C configuration mode and spped are necessary in this stage. - @retval SENSOR_I2C_SUCCESS or SENSOR_I2C_FAIL if error occurs. - */ - int (*i2c_close)(struct _i2c_handle_t* handle ); - - /** @brief Write single data to device. - @param[in] handle Handle to isp i2c api. - @param[in] cfg I2C config, fmd and address are necessary in this stage. - @param[in] reg Device register address address width depend on cfg->fmt. - @param[in] data Data to write, data width depend on cfg->fmt. - @retval SENSOR_I2C_SUCCESS or SENSOR_I2C_FAIL if error occurs. - */ - int (*i2c_tx)(struct _i2c_handle_t* handle , app_i2c_cfg *cfg, u16 reg, u16 data); - - /** @brief Read single data from device. - @param[in] handle Handle to isp i2c api. - @param[in] cfg I2C config, fmd and address are necessary in this stage. - @param[in] reg Device register address address width depend on cfg->fmt. - @param[out] data Data buffer for read, data width depend on cfg->fmt. - @retval SENSOR_I2C_SUCCESS or SENSOR_I2C_FAIL if error occurs. - */ - int (*i2c_rx)(struct _i2c_handle_t* handle, app_i2c_cfg *cfg, u16 reg, volatile u16 *data); - - /** @brief Batch write to device. - @param[in] handle Handle to isp i2c api. - @param[in] cfg I2C config, fmd and address are necessary in this stage. - @param[in] pdata Data array. - @param[in] len Array size. - @retval SENSOR_I2C_SUCCESS or SENSOR_I2C_FAIL if error occurs. - */ - int (*i2c_array_tx)(struct _i2c_handle_t* handle, app_i2c_cfg *cfg, I2C_ARRAY *pdata, u32 len); - - /** @brief Burst write to device. - @param[in] handle Handle to isp i2c api. - @param[in] cfg I2C config, fmd and address are necessary in this stage. - @param[in] pdata Data array. - @param[in] len Array size. - @retval SENSOR_I2C_SUCCESS or SENSOR_I2C_FAIL if error occurs. - */ - int (*i2c_burst_tx)(struct _i2c_handle_t* handle, app_i2c_cfg *cfg, I2C_ARRAY_BURST *pdata, u32 len); - - int (*i2c_burst_rx)(struct _i2c_handle_t* handle, app_i2c_cfg *cfg, I2C_ARRAY_BURST *pdata, u32 len); - /** @brief Batch read from device. - @param[in] handle Handle to isp i2c api. - @param[in] cfg I2C config, fmd and address are necessary in this stage. - @param[out] pdata Data array. - @param[in] len Array size. - @retval SENSOR_I2C_SUCCESS or SENSOR_I2C_FAIL if error occurs. - */ - int (*i2c_array_rx)(struct _i2c_handle_t* handle, app_i2c_cfg *cfg, I2C_ARRAY *pdata, u32 len); - - /** @brief Composite batch read/write - @param[in] handle Handle to isp i2c api. - @param[in] cfg I2C config, fmd and address are necessary in this stage. - @param[in][out] pdata Data description array. - @param[in] len Array size. - @retval SENSOR_I2C_SUCCESS or SENSOR_I2C_FAIL if error occurs. - */ - int (*i2c_array_rw)(struct _i2c_handle_t* handle, app_i2c_cfg *cfg, I2C_CPX_ARRAY *pdata, u32 len); -} i2c_handle_t; - -/** @} */ // end of ISP I2C API - -#endif diff --git a/general/package/sigmastar-osdrv-sensor/src/infinity6b0/sensor/sensor_gc2053_mipi.c b/general/package/sigmastar-osdrv-sensor/src/infinity6b0/sensor/sensor_gc2053_mipi.c deleted file mode 100644 index 277d75df..00000000 --- a/general/package/sigmastar-osdrv-sensor/src/infinity6b0/sensor/sensor_gc2053_mipi.c +++ /dev/null @@ -1,1291 +0,0 @@ -/* Copyright (c) 2018-2019 Sigmastar Technology Corp. - All rights reserved. - - Unless otherwise stipulated in writing, any and all information contained -herein regardless in any format shall remain the sole proprietary of -Sigmastar Technology Corp. and be kept in strict confidence -(Sigmastar Confidential Information) by the recipient. -Any unauthorized act including without limitation unauthorized disclosure, -copying, use, reproduction, sale, distribution, modification, disassembling, -reverse engineering and compiling of the contents of Sigmastar Confidential -Information is unlawful and strictly prohibited. Sigmastar hereby reserves the -rights to any and all damages, losses, costs and expenses resulting therefrom. -*/ - -#ifdef __cplusplus -extern "C" -{ -#endif - -#include -#include -#include - -#ifdef __cplusplus -} -#endif - -SENSOR_DRV_ENTRY_IMPL_BEGIN(gc2053); - -#ifndef ARRAY_SIZE -#define ARRAY_SIZE CAM_OS_ARRAY_SIZE -#endif - -//#define _DEBUG_ -//c11 extern int usleep(u32 usec); -//int usleep(u32 usec); - -#define SENSOR_CHANNEL_NUM (0) -#define SENSOR_CHANNEL_MODE_LINEAR CUS_SENSOR_CHANNEL_MODE_REALTIME_NORMAL -#define SENSOR_CHANNEL_MODE_SONY_DOL CUS_SENSOR_CHANNEL_MODE_RAW_STORE_HDR - -//============================================ -//MIPI config begin. -#define SENSOR_MIPI_LANE_NUM (2) -//#define SENSOR_MIPI_HDR_MODE (1) //0: Non-HDR mode. 1:Sony DOL mode -//MIPI config end. -//============================================ - -#define R_GAIN_REG 1 -#define G_GAIN_REG 2 -#define B_GAIN_REG 3 - - -//#undef SENSOR_DBG -#define SENSOR_DBG 0 - -/////////////////////////////////////////////////////////////// -// @@@ // -// @ @@ == S t a r t * H e r e == // -// @@ == S t a r t * H e r e == // -// @@ == S t a r t * H e r e == // -// @@@@ // -// // -// Start Step 1 -- show preview on LCM // -// // -// Fill these #define value and table with correct settings // -// camera can work and show preview on LCM // -// // -/////////////////////////////////////////////////////////////// - -#define SENSOR_ISP_TYPE ISP_EXT //ISP_EXT, ISP_SOC -#define F_number 22 // CFG, demo module -//#define SENSOR_DATAFMT CUS_DATAFMT_BAYER //CUS_DATAFMT_YUV, CUS_DATAFMT_BAYER -#define SENSOR_IFBUS_TYPE CUS_SENIF_BUS_MIPI //CFG //CUS_SENIF_BUS_PARL, CUS_SENIF_BUS_MIPI -#define SENSOR_MIPI_HSYNC_MODE PACKET_HEADER_EDGE1 -#define SENSOR_DATAPREC CUS_DATAPRECISION_10 //CFG //CUS_DATAPRECISION_8, CUS_DATAPRECISION_10 -#define SENSOR_DATAMODE CUS_SEN_10TO12_9000 //CFG -#define SENSOR_BAYERID CUS_BAYER_RG //CFG //CUS_BAYER_GB, CUS_BAYER_GR, CUS_BAYER_BG, CUS_BAYER_RG -#define SENSOR_RGBIRID CUS_RGBIR_NONE -#define SENSOR_ORIT CUS_ORIT_M0F0 //CUS_ORIT_M0F0, CUS_ORIT_M1F0, CUS_ORIT_M0F1, CUS_ORIT_M1F1, -#define SENSOR_MAX_GAIN 128 // max sensor again, a-gain -//#define SENSOR_YCORDER CUS_SEN_YCODR_YC //CUS_SEN_YCODR_YC, CUS_SEN_YCODR_CY -#define lane_number 2 -#define vc0_hs_mode 3 //0: packet header edge 1: line end edge 2: line start edge 3: packet footer edge -#define long_packet_type_enable 0x00 //UD1~UD8 (user define) - -#define Preview_MCLK_SPEED CUS_CMU_CLK_27MHZ //CFG //CUS_CMU_CLK_12M, CUS_CMU_CLK_16M, CUS_CMU_CLK_24M, CUS_CMU_CLK_27M -//#define Preview_line_period 30000 ////HTS/PCLK=4455 pixels/148.5MHZ=30usec @MCLK=36MHz -//#define vts_30fps 1125//1346,1616 //for 29.1fps @ MCLK=36MHz -#define Preview_line_period 29630//30580 //(36M/37.125M)*30fps=29.091fps(34.375msec), hts=34.375/1125=30556, -//#define Line_per_second 32727 -#define vts_30fps 1125//1266//1150//1090 //for 29.091fps @ MCLK=36MHz -#define Prv_Max_line_number 2200 //maximum exposure line munber of sensor when preview -#define Preview_WIDTH 1920 //resolution Width when preview -#define Preview_HEIGHT 1080 //resolution Height when preview -#define Preview_MAX_FPS 30 //fastest preview FPS -#define Preview_MIN_FPS 5 //slowest preview FPS -#define Preview_CROP_START_X 0 //CROP_START_X -#define Preview_CROP_START_Y 0 //CROP_START_Y - -#define SENSOR_I2C_ADDR 0x6E //I2C slave address -#define SENSOR_I2C_SPEED 200000 //300000// 240000 //I2C speed, 60000~320000 - -#define SENSOR_I2C_LEGACY I2C_NORMAL_MODE //usally set CUS_I2C_NORMAL_MODE, if use old OVT I2C protocol=> set CUS_I2C_LEGACY_MODE -#define SENSOR_I2C_FMT I2C_FMT_A8D8 //CUS_I2C_FMT_A8D8, CUS_I2C_FMT_A8D16, CUS_I2C_FMT_A16D8, CUS_I2C_FMT_A16D16 - -#define SENSOR_PWDN_POL CUS_CLK_POL_POS // if PWDN pin High can makes sensor in power down, set CUS_CLK_POL_POS -#define SENSOR_RST_POL CUS_CLK_POL_NEG // if RESET pin High can makes sensor in reset state, set CUS_CLK_POL_NEG - -// VSYNC/HSYNC POL can be found in data sheet timing diagram, -// Notice: the initial setting may contain VSYNC/HSYNC POL inverse settings so that condition is different. - -#define SENSOR_VSYNC_POL CUS_CLK_POL_NEG // if VSYNC pin High and data bus have data, set CUS_CLK_POL_POS -#define SENSOR_HSYNC_POL CUS_CLK_POL_NEG // if HSYNC pin High and data bus have data, set CUS_CLK_POL_POS -#define SENSOR_PCLK_POL CUS_CLK_POL_POS // depend on sensor setting, sometimes need to try CUS_CLK_POL_POS or CUS_CLK_POL_NEG - -int blk_flag=1; -int times = 0; -//static int drv_Fnumber = 22; -static int pCus_SetAEGain(ms_cus_sensor *handle, u32 gain); -static int pCus_SetAEUSecs(ms_cus_sensor *handle, u32 us); -static int pCus_SetFPS(ms_cus_sensor *handle, u32 fps); -CUS_MCLK_FREQ UseParaMclk(void); - -CUS_CAMSENSOR_CAP sensor_cap = { - .length = sizeof(CUS_CAMSENSOR_CAP), - .version = 0x0001, -}; - -typedef struct { - struct { - u16 pre_div0; - u16 div124; - u16 div_cnt7b; - u16 sdiv0; - u16 mipi_div0; - u16 r_divp; - u16 sdiv1; - u16 r_seld5; - u16 r_sclk_dac; - u16 sys_sel; - u16 pdac_sel; - u16 adac_sel; - u16 pre_div_sp; - u16 r_div_sp; - u16 div_cnt5b; - u16 sdiv_sp; - u16 div12_sp; - u16 mipi_lane_sel; - u16 div_dac; - } clk_tree; - struct { - bool bVideoMode; - u16 res_idx; - // bool binning; - // bool scaling; - CUS_CAMSENSOR_ORIT orit; - } res; - struct { - u32 sclk; - u32 hts; - u32 vts; - u32 ho; - u32 xinc; - u32 line_freq; - u32 us_per_line; - u32 final_us; - u32 final_gain; - u32 back_pv_us; - u32 fps; - u32 preview_fps; - u32 line; - } expo; - - int sen_init; - int still_min_fps; - int video_min_fps; - bool dirty; - bool orient_dirty; -} gc2053_params; -// set sensor ID address and data, - -/* typedef struct { - unsigned int total_gain; - unsigned short reg_val; -} Gain_ARRAY; - */ -static I2C_ARRAY Sensor_id_table[] = -{ -{0xf0, 0x20}, // {address of ID, ID }, -{0xf1, 0x53}, -}; - -typedef struct { - - u32 gain; - unsigned short again_reg_val_0; - unsigned short again_reg_val_1; - unsigned short again_reg_val_2; - unsigned short again_reg_val_3; - -} Gain_ARRAY; - -static I2C_ARRAY Sensor_init_table[] = -{ - /****system****/ -{0xfe, 0x80}, -{0xfe, 0x80}, -{0xfe, 0x80}, -{0xfe, 0x00}, -{0xf2, 0x00},//[1]I2C_open_ena [0]pwd_dn -{0xf3, 0x00},//0f//00[3]Sdata_pad_io [2:0]Ssync_pad_io -{0xf4, 0x36},//[6:4]pll_ldo_set -{0xf5, 0xc0},//[7]soc_mclk_enable [6]pll_ldo_en [5:4]cp_clk_sel [3:0]cp_clk_div -{0xf6, 0x44},//[7:3]wpllclk_div [2:0]refmp_div -{0xf7, 0x01},//[7]refdiv2d5_en [6]refdiv1d5_en [5:4]scaler_mode [3]refmp_enb [1]div2en [0]pllmp_en -{0xf8, 0x2c},//[7:0]pllmp_div -{0xf9, 0x42},//[7:3]rpllclk_div [2:1]pllmp_prediv [0]analog_pwc -{0xfc, 0x8e}, /****CISCTL & ANALOG****/ -{0xfe, 0x00}, -{0x87, 0x18},//[6]aec_delay_mode -{0xee, 0x30},//[5:4]dwen_sramen -{0xd0, 0xb7},//ramp_en -{0x03, 0x04}, -{0x04, 0x60}, -{0x05, 0x04},//05 -{0x06, 0x4c},//60//[11:0]hb -{0x07, 0x00}, -{0x08, 0x19}, -{0x09, 0x00}, -{0x0a, 0x02}, //cisctl row start -{0x0b, 0x00}, -{0x0c, 0x02}, //cisctl col start -{0x0d, 0x04}, -{0x0e, 0x40}, -{0x12, 0xe2}, //vsync_ahead_mode -{0x13, 0x16}, -{0x19, 0x0a}, //ad_pipe_num -{0x21, 0x1c},//eqc1fc_eqc2fc_sw -{0x28, 0x0a},//16//eqc2_c2clpen_sw -{0x29, 0x24},//eq_post_width -{0x2b, 0x04},//c2clpen --eqc2 -{0x32, 0xf8}, //[5]txh_en ->avdd28 -{0x37, 0x03}, //[3:2]eqc2sel=0 -{0x39, 0x15},//17 //[3:0]rsgl -{0x43, 0x07},//vclamp -{0x44, 0x40}, //0e//post_tx_width -{0x46, 0x0b}, -{0x4b, 0x20}, //rst_tx_width -{0x4e, 0x08}, //12//ramp_t1_width -{0x55, 0x20}, //read_tx_width_pp -{0x66, 0x05}, //18//stspd_width_r1 -{0x67, 0x05}, //40//5//stspd_width_r -{0x77, 0x01}, //dacin offset x31 -{0x78, 0x00}, //dacin offset -{0x7c, 0x93}, //[1:0] co1comp -{0x8c, 0x12}, //12 ramp_t1_ref -{0x8d, 0x92},//90 -{0x90, 0x00}, -{0x9d, 0x10}, -{0xce, 0x7c},//70//78//[4:2]c1isel -{0xd2, 0x41},//[5:3]c2clamp -{0xd3, 0xdc},//ec//0x39[7]=0,0xd3[3]=1 rsgh=vref -{0xe6, 0x50},//ramps offset /*gain*/ -{0xb6, 0xc0}, -{0xb0, 0x70}, -{0xb1, 0x01}, -{0xb2, 0x00}, -{0xb3, 0x00}, -{0xb4, 0x00}, -{0xb8, 0x01}, -{0xb9, 0x00}, -/*blk*/ -{0x26, 0x30},//23 -{0xfe, 0x01}, -{0x40, 0x23}, -{0x55, 0x07}, -{0x58, 0x00},//random noise disable - -{0x60, 0x40}, //[7:0]WB_offset -{0xfe, 0x04}, -{0x14, 0x78}, //g1 ratio -{0x15, 0x78}, //r ratio -{0x16, 0x78}, //b ratio -{0x17, 0x78}, //g2 ratio -/*window*/ -{0xfe, 0x01}, -{0x92, 0x00}, //win y1 -{0x94, 0x03}, //win x1 -{0x95, 0x04}, -{0x96, 0x38}, //[10:0]out_height -{0x97, 0x07}, -{0x98, 0x80}, //[11:0]out_width -/*ISP*/ -{0xfe, 0x01}, -{0x58, 0x00}, -{0x01, 0x05},//03//[3]dpc blending mode [2]noise_mode [1:0]center_choose 2b'11:median 2b'10:avg 2'b00:near -{0x02, 0x89}, //[7:0]BFF_sram_mode -{0x04, 0x01}, //[0]DD_en -{0x07, 0xa6}, -{0x08, 0xa9}, -{0x09, 0xa8}, -{0x0a, 0xa7}, -{0x0b, 0xff}, -{0x0c, 0xff}, -{0x0f, 0x00}, -{0x50, 0x1c}, -{0x89, 0x03}, -{0xfe, 0x04}, -{0x28, 0x86},//84 -{0x29, 0x86},//84 -{0x2a, 0x86},//84 -{0x2b, 0x68},//84 -{0x2c, 0x68},//84 -{0x2d, 0x68},//84 -{0x2e, 0x68},//83 -{0x2f, 0x68},//82 -{0x30, 0x4f},//82 -{0x31, 0x68},//82 -{0x32, 0x67},//82 -{0x33, 0x66},//82 -{0x34, 0x66},//82 -{0x35, 0x66},//82 -{0x36, 0x66},//64 -{0x37, 0x66},//68 -{0x38, 0x62}, -{0x39, 0x62}, -{0x3a, 0x62}, -{0x3b, 0x62}, -{0x3c, 0x62}, -{0x3d, 0x62}, -{0x3e, 0x62}, -{0x3f, 0x62}, -/****DVP & MIPI****/ -{0xfe, 0x01}, -{0x9a, 0x06},//[5]OUT_gate_mode [4]hsync_delay_half_pclk [3]data_delay_half_pclk [2]vsync_polarity [1]hsync_polarity [0]pclk_out_polarity -{0xfe, 0x00}, -{0x7b, 0x2a},//[7:6]updn [5:4]drv_high_data [3:2]drv_low_data [1:0]drv_pclk -{0x23, 0x2d},//[3]rst_rc [2:1]drv_sync [0]pwd_rc -{0xfe, 0x03}, -{0x01, 0x27},//20//27[6:5]clkctr [2]phy-lane1_en [1]phy-lane0_en [0]phy_clk_en -{0x02, 0x56},//[7:6]data1ctr [5:4]data0ctr [3:0]mipi_diff -{0x03, 0xb6},//b2//b6[7]clklane_p2s_sel [6:5]data0hs_ph [4]data0_delay1s [3]clkdelay1s [2]mipi_en [1:0]clkhs_ph -{0x12, 0x80}, -{0x13, 0x07},//LWC -{0x15, 0x12},//[1:0]clk_lane_mode -{0xfe, 0x00}, -{0x3e, 0x91},//40//91[7]lane_ena [6]DVPBUF_ena [5]ULPEna [4]MIPI_ena [3]mipi_set_auto_disable [2]RAW8_mode [1]ine_sync_mode [0]double_lane_en - -}; - -I2C_ARRAY TriggerStartTbl[] = { -//{0x30f4,0x00},//Master mode start -}; - -I2C_ARRAY PatternTbl[] = { - //pattern mode -}; - -I2C_ARRAY Current_Mirror_Flip_Tbl[] = { - {0x17, 0x80}, // bit[1:0] -}; - -///////////////////////////////////////////////////////////////// -// @@@@@@ // -// @@ // -// @@@ // -// @ @@ // -// @@@@ // -// // -// Step 3 -- complete camera features // -// // -// // -// camera set EV, MWB, orientation, contrast, sharpness // -// , saturation, and Denoise can work correctly. // -// // -///////////////////////////////////////////////////////////////// - - -static I2C_ARRAY mirr_flip_table[] = -{ - #if 0 - {0x17, 0x83}, // bit[1:0] - - {0x17, 0x82}, // bit[1:0] - - {0x17, 0x81}, // bit[1:0] - - {0x17, 0x80}, // bit[1:0] - #endif - {0x17, 0x80}, // bit[1:0] - - {0x17, 0x81}, // bit[1:0] - - {0x17, 0x82}, // bit[1:0] - - {0x17, 0x83}, // bit[1:0] - -}; - -typedef struct { - short reg; - char startbit; - char stopbit; -} COLLECT_REG_SET; - - -static int g_sensor_ae_min_gain = 1024;//1280; - -static I2C_ARRAY gain_reg[] = { - {0xfe, 0x00}, - {0xb4, 0x00}, - {0xb3, 0x00}, - {0xb8, 0x00}, - {0xb9, 0x00}, - {0xb1, 0x00}, - {0xb2, 0x00}, -}; - - -static I2C_ARRAY expo_reg[] = { - {0x04, 0xd0}, - {0x03, 0x05}, -}; - - -static I2C_ARRAY vts_reg[] = { - {0x41, 0x05}, - {0x42, 0xdc}, - -}; - -I2C_ARRAY temperature_reg[] = { - {0x0c, 0x30}, - {0x0d, 0x30}, - {0x0e, 0x30}, - {0x0f, 0x30}, -}; - -static Gain_ARRAY gain_table[]={ - {1024 , 0x00, 0x00,0x01,0x00}, - {1230 , 0x00, 0x10,0x01,0x0c}, - {1440 , 0x00, 0x20,0x01,0x1b}, - {1730 , 0x00, 0x30,0x01,0x2c}, - {2032 , 0x00, 0x40,0x01,0x3f}, - {2380 , 0x00, 0x50,0x02,0x16}, - {2880 , 0x00, 0x60,0x02,0x35}, - {3460 , 0x00, 0x70,0x03,0x16}, - {4080 , 0x00, 0x80,0x04,0x02}, - {4800 , 0x00, 0x90,0x04,0x31}, - {5776 , 0x00, 0xa0,0x05,0x32}, - {6760 , 0x00, 0xb0,0x06,0x35}, - {8064 , 0x00, 0xc0,0x08,0x04}, - {9500 , 0x00, 0x5a,0x09,0x19}, - {11552, 0x00, 0x83,0x0b,0x0f}, - {13600, 0x00, 0x93,0x0d,0x12}, - {16132, 0x00, 0x84,0x10,0x00}, - {18912, 0x00, 0x94,0x12,0x3a}, - {22528, 0x01, 0x2c,0x1a,0x02}, - {27036, 0x01, 0x3c,0x1b,0x20}, - {32340, 0x00, 0x8c,0x20,0x0f}, - {38256, 0x00, 0x9c,0x26,0x07}, - {45600, 0x02, 0x64,0x36,0x21}, - {53912, 0x02, 0x74,0x37,0x3a}, - {63768, 0x00, 0xc6,0x3d,0x02}, - {76880, 0x00, 0xdc,0x3f,0x3f}, - {92300, 0x02, 0x85,0x3f,0x3f}, - {108904, 0x02, 0x95,0x3f,0x3f}, - {123568, 0x00, 0xce,0x3f,0x3f}, -}; - -#if 0 -static CUS_INT_TASK_ORDER def_order = { - .RunLength = 9, - .Orders = { - CUS_INT_TASK_AE|CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_AWB|CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_AE|CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_AWB|CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_AE|CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_AWB|CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - }, -}; -#endif - -/////////// function definition /////////////////// -#if SENSOR_DBG == 1 -//#define SENSOR_DMSG(args...) SENSOR_DMSG(args) -//#define SENSOR_DMSG(args...) LOGE(args) -#define SENSOR_DMSG(args...) SENSOR_DMSG(args) -#elif SENSOR_DBG == 0 -//#define SENSOR_DMSG(args...) -#endif -#undef SENSOR_NAME -#define SENSOR_NAME gc2053 - - -#define SensorReg_Read(_reg,_data) (handle->i2c_bus->i2c_rx(handle->i2c_bus, &(handle->i2c_cfg),_reg,_data)) -#define SensorReg_Write(_reg,_data) (handle->i2c_bus->i2c_tx(handle->i2c_bus, &(handle->i2c_cfg),_reg,_data)) -#define SensorRegArrayW(_reg,_len) (handle->i2c_bus->i2c_array_tx(handle->i2c_bus, &(handle->i2c_cfg),(_reg),(_len))) -#define SensorRegArrayR(_reg,_len) (handle->i2c_bus->i2c_array_rx(handle->i2c_bus, &(handle->i2c_cfg),(_reg),(_len))) - -static int cus_camsensor_release_handle(ms_cus_sensor *handle); - -/////////////////// sensor hardware dependent ////////////// -#if 0 -static int ISP_config_io(ms_cus_sensor *handle) { - ISensorIfAPI *sensor_if = handle->sensor_if_api; - - SENSOR_DMSG("[%s]", __FUNCTION__); - - sensor_if->HsyncPol(handle, handle->HSYNC_POLARITY); - sensor_if->VsyncPol(handle, handle->VSYNC_POLARITY); - sensor_if->ClkPol(handle, handle->PCLK_POLARITY); - sensor_if->BayerFmt(handle, handle->bayer_id); - sensor_if->DataBus(handle, handle->sif_bus); - - sensor_if->DataPrecision(handle, handle->data_prec); - sensor_if->FmtConv(handle, handle->data_mode); - return SUCCESS; -} -#endif - -//static u32 timeGetTimeU(void) -//{ -// CamOsTimespec_t tRes; -// CamOsGetMonotonicTime(&tRes); -// return (tRes.nSec * 1000000)+(tRes.nNanoSec/1000); -//} -//static u32 TStart = 0; - -static int pCus_poweron(ms_cus_sensor *handle, u32 idx) -{ - ISensorIfAPI *sensor_if = handle->sensor_if_api; - SENSOR_DMSG("[%s] ", __FUNCTION__); - - //TStart = timeGetTimeU(); - /*PAD and CSI*/ - sensor_if->SetIOPad(idx, handle->sif_bus, handle->interface_attr.attr_mipi.mipi_lane_num); - sensor_if->SetCSI_Clk(idx, CUS_CSI_CLK_216M); ///??? - sensor_if->SetCSI_Lane(idx, handle->interface_attr.attr_mipi.mipi_lane_num, 1); ///??? - sensor_if->SetCSI_LongPacketType(idx, 0, 0x1C00, 0); //========= ???? - - /*Power ON*/ - sensor_if->PowerOff(idx, !handle->pwdn_POLARITY); - SENSOR_USLEEP(1000); - - /*Reset PIN*/ - SENSOR_DMSG("[%s] reset low\n", __FUNCTION__); - sensor_if->Reset(idx, handle->reset_POLARITY); - SENSOR_USLEEP(1000); - sensor_if->PowerOff(idx, handle->pwdn_POLARITY); - SENSOR_USLEEP(1000); - SENSOR_DMSG("[%s] reset high\n", __FUNCTION__); - sensor_if->Reset(idx, !handle->reset_POLARITY); - SENSOR_USLEEP(1000); - - /*MCLK ON*/ - sensor_if->MCLK(idx, 1, handle->mclk); - SENSOR_USLEEP(5000); - //CamOsPrintf("pCus_poweron = %d us \n",timeGetTimeU()-TStart); - return SUCCESS; -} - -static int pCus_poweroff(ms_cus_sensor *handle, u32 idx) -{ - // power/reset low - ISensorIfAPI *sensor_if = handle->sensor_if_api; - SENSOR_DMSG("[%s] power low\n", __FUNCTION__); - sensor_if->PowerOff(idx, !handle->pwdn_POLARITY); - sensor_if->Reset(idx, handle->reset_POLARITY); - //handle->i2c_bus->i2c_close(handle->i2c_bus); - SENSOR_USLEEP(1000); - //Set_csi_if(0, 0); - sensor_if->SetCSI_Clk(idx, CUS_CSI_CLK_DISABLE); - sensor_if->MCLK(idx, 0, handle->mclk); - - return SUCCESS; -} - -/////////////////// image function ///////////////////////// -//Get and check sensor ID -//if i2c error or sensor id does not match then return FAIL -static int pCus_GetSensorID(ms_cus_sensor *handle, u32 *id) -{ - int i,n; - int table_length= ARRAY_SIZE(Sensor_id_table); - I2C_ARRAY id_from_sensor[ARRAY_SIZE(Sensor_id_table)]; - SensorReg_Write(0xfe,0x00); - - for(n=0;n8) table_length=8; - - SENSOR_DMSG("\n\n[%s]", __FUNCTION__); - - for(n=0;n<4;++n) //retry , until I2C success - { - if(n>2) return FAIL; - - if( SensorRegArrayR((I2C_ARRAY*)id_from_sensor,table_length) == SUCCESS) //read sensor ID from I2C - break; - else - continue; - } - - //convert sensor id to u32 format - for(i=0;i>= 8; - SENSOR_DMSG("[%s]gc2053 Read sensor id, get 0x%x Success\n", __FUNCTION__, (int)*id); - //SENSOR_DMSG("[%s]Read sensor id, get 0x%x Success\n", __FUNCTION__, (int)*id); - - return SUCCESS; -} - -static int gc2053_SetPatternMode(ms_cus_sensor *handle,u32 mode) -{ - - SENSOR_DMSG("\n\n[%s], mode=%d \n", __FUNCTION__, mode); - - return SUCCESS; -} -static int pCus_SetFPS(ms_cus_sensor *handle, u32 fps); -//static int pCus_SetAEGain_cal(ms_cus_sensor *handle, u32 gain); -static int pCus_AEStatusNotify(ms_cus_sensor *handle, CUS_CAMSENSOR_AE_STATUS_NOTIFY status); -static int pCus_init(ms_cus_sensor *handle) -{ - int i,cnt=0; - SENSOR_DMSG("\n\n[%s]", __FUNCTION__); - //ISensorIfAPI *sensor_if = &(handle->sensor_if_api); - //sensor_if->PCLK(NULL,CUS_PCLK_MIPI_TOP); - //TStart = timeGetTimeU(); - - for(i=0;i< ARRAY_SIZE(Sensor_init_table);i++) - { - if(Sensor_init_table[i].reg==0xffff) - { - msleep(Sensor_init_table[i].data); - } - else - { - cnt = 0; - while(SensorReg_Write(Sensor_init_table[i].reg,Sensor_init_table[i].data) != SUCCESS) - { - cnt++; - //SENSOR_DMSG("Sensor_init_table -> Retry %d...\n",cnt); - if(cnt>=10) - { - //SENSOR_DMSG("[%s:%d]Sensor init fail!!\n", __FUNCTION__, __LINE__); - return FAIL; - } - msleep(10); - } - } - } - -/* - for(i=0;i< ARRAY_SIZE(PatternTbl);i++) - { - if(SensorReg_Write(PatternTbl[i].reg,PatternTbl[i].data) != SUCCESS) - { - //MSG("[%s:%d]Sensor init fail!!\n", __FUNCTION__, __LINE__); - return FAIL; - } - } -*/ - - pCus_SetAEGain(handle,1024); //Set sensor gain = 1x - pCus_SetAEUSecs(handle, 30000); - pCus_AEStatusNotify(handle,CUS_FRAME_ACTIVE); - - //CamOsPrintf("pCus_init = %d us \n",timeGetTimeU()-TStart); - - return SUCCESS; -} -/* -int pCus_release(ms_cus_sensor *handle) -{ - ISensorIfAPI *sensor_if = handle->sensor_if_api; - sensor_if->PCLK(NULL,CUS_PCLK_OFF); - return SUCCESS; -} -*/ - -static int pCus_GetVideoResNum( ms_cus_sensor *handle, u32 *ulres_num) -{ - *ulres_num = handle->video_res_supported.num_res; - return SUCCESS; -} - -static int pCus_GetVideoRes(ms_cus_sensor *handle, u32 res_idx, cus_camsensor_res **res) -{ - u32 num_res = handle->video_res_supported.num_res; - - if (res_idx >= num_res) { - return FAIL; - } - - *res = &handle->video_res_supported.res[res_idx]; - - return SUCCESS; -} - -static int pCus_GetCurVideoRes(ms_cus_sensor *handle, u32 *cur_idx, cus_camsensor_res **res) -{ - u32 num_res = handle->video_res_supported.num_res; - - *cur_idx = handle->video_res_supported.ulcur_res; - - if (*cur_idx >= num_res) { - return FAIL; - } - - *res = &handle->video_res_supported.res[*cur_idx]; - - return SUCCESS; -} - -static int pCus_SetVideoRes(ms_cus_sensor *handle, u32 res_idx) -{ - u32 num_res = handle->video_res_supported.num_res; - if (res_idx >= num_res) { - return FAIL; - } - switch (res_idx) { - case 0: - handle->video_res_supported.ulcur_res = 0; - handle->pCus_sensor_init = pCus_init; - break; - - default: - break; - } - - return SUCCESS; -} - -static int pCus_GetOrien(ms_cus_sensor *handle, CUS_CAMSENSOR_ORIT *orit) { - short HFlip;//,VFlip; - - SensorReg_Write(0xfe,0x00);//page 0 - SensorReg_Read(0x17, &HFlip); - // SensorReg_Read(0x1d, &VFlip); - - if(((HFlip&0x03)==0x03)) //&&((VFlip&0x80)==0)) - *orit = CUS_ORIT_M0F0; - else if(((HFlip&0x03)==0x02)) //&&((VFlip&0x80)==0)) - *orit = CUS_ORIT_M1F0; - else if(((HFlip&0x03)==0x01)) //&&((VFlip&0x80)!=0)) - *orit = CUS_ORIT_M0F1; - else if(((HFlip&0x03)==0x00)) //&&((VFlip&0x80)!=0)) - *orit = CUS_ORIT_M1F1; - - //SENSOR_DMSG("mirror:%x\r\n", HFlip&0x80); - //SENSOR_DMSG("Flip:%x\r\n", VFlip&0x80); - - return SUCCESS; -} - -static int pCus_SetOrien(ms_cus_sensor *handle, CUS_CAMSENSOR_ORIT orit) { - //gc2053_params *params = (gc2053_params *)handle->private_data; - SENSOR_DMSG("\n\n[%s]", __FUNCTION__); - - switch(orit) - { - case CUS_ORIT_M0F0: - SensorReg_Write(0xfe,0x00);//page 0 - SensorReg_Write(mirr_flip_table[0].reg,mirr_flip_table[0].data); - Current_Mirror_Flip_Tbl[0].reg = mirr_flip_table[0].reg; - Current_Mirror_Flip_Tbl[0].data = mirr_flip_table[0].data; - // handle->bayer_id= CUS_BAYER_BG; - break; - case CUS_ORIT_M1F0: - SensorReg_Write(0xfe,0x00);//page 0 - SensorReg_Write(mirr_flip_table[1].reg,mirr_flip_table[1].data); - Current_Mirror_Flip_Tbl[0].reg = mirr_flip_table[1].reg; - Current_Mirror_Flip_Tbl[0].data = mirr_flip_table[1].data; - // handle->bayer_id= CUS_BAYER_BG; - break; - case CUS_ORIT_M0F1: - SensorReg_Write(0xfe,0x00);//page 0 - SensorReg_Write(mirr_flip_table[2].reg,mirr_flip_table[2].data); - Current_Mirror_Flip_Tbl[0].reg = mirr_flip_table[2].reg; - Current_Mirror_Flip_Tbl[0].data = mirr_flip_table[2].data; - // handle->bayer_id= CUS_BAYER_GR; - break; - case CUS_ORIT_M1F1: - SensorReg_Write(0xfe,0x00);//page 0 - SensorReg_Write(mirr_flip_table[3].reg,mirr_flip_table[3].data); - Current_Mirror_Flip_Tbl[0].reg = mirr_flip_table[3].reg; - Current_Mirror_Flip_Tbl[0].data = mirr_flip_table[3].data; - // handle->bayer_id= CUS_BAYER_GR; - break; - default : - SensorReg_Write(0xfe,0x00);//page 0 - SensorReg_Write(mirr_flip_table[0].reg,mirr_flip_table[0].data); - Current_Mirror_Flip_Tbl[0].reg = mirr_flip_table[0].reg; - Current_Mirror_Flip_Tbl[0].data = mirr_flip_table[0].data; - // handle->bayer_id= CUS_BAYER_BG; - break; - } - //SensorReg_Write(0xef,0x01); - // SensorReg_Write(0x09,1); - - // params->orient_dirty = true; - return SUCCESS; -} - -static int pCus_GetFPS(ms_cus_sensor *handle) -{ - gc2053_params *params = (gc2053_params *)handle->private_data; - u32 max_fps = handle->video_res_supported.res[handle->video_res_supported.ulcur_res].max_fps; - u32 tVts = vts_reg[0].data << 8 | vts_reg[1].data ; - - if (params->expo.fps >= 5000) - params->expo.preview_fps = (vts_30fps*max_fps*1000)/tVts; - else - params->expo.preview_fps = (vts_30fps*max_fps)/tVts; - - return params->expo.preview_fps; -} - -static int pCus_SetFPS(ms_cus_sensor *handle, u32 fps) -{ - int vts=0; - gc2053_params *params = (gc2053_params *)handle->private_data; - SENSOR_DMSG("\n\n[%s]", __FUNCTION__); - - //return SUCCESS; - - if(fps>=5 && fps <= 30){ - params->expo.fps = fps; - params->expo.vts= (vts_30fps*30)/fps; - }else if(fps>=5000 && fps <= 30000){ - params->expo.fps = fps; - params->expo.vts= (vts_30fps*30000)/fps; - }else{ - //params->expo.vts=vts_30fps; - //params->expo.fps=30; - //SENSOR_DMSG("[%s] FPS %d out of range.\n",__FUNCTION__,fps); - return FAIL; - } - - if ((params->expo.line) > (params->expo.vts)-4) { - vts = params->expo.line + 4; - }else - vts = params->expo.vts; - vts_reg[0].data = (vts >> 8) & 0x003f; - vts_reg[1].data = (vts >> 0) & 0x00ff; - - - params->dirty = true; - return SUCCESS; -} - -#if 0 -static int pCus_GetSensorCap(ms_cus_sensor *handle, CUS_CAMSENSOR_CAP *cap) { - if (cap) - memcpy(cap, &sensor_cap, sizeof(CUS_CAMSENSOR_CAP)); - else return FAIL; - return SUCCESS; -} -#endif - -/////////////////////////////////////////////////////////////////////// -// auto exposure -/////////////////////////////////////////////////////////////////////// -// unit: micro seconds -//AE status notification -static int pCus_AEStatusNotify(ms_cus_sensor *handle, CUS_CAMSENSOR_AE_STATUS_NOTIFY status){ - gc2053_params *params = (gc2053_params *)handle->private_data; - switch(status) - { - case CUS_FRAME_INACTIVE: - - break; - case CUS_FRAME_ACTIVE: - if(params->dirty) - { - SensorRegArrayW((I2C_ARRAY*)gain_reg, ARRAY_SIZE(gain_reg)); - SensorRegArrayW((I2C_ARRAY*)expo_reg, ARRAY_SIZE(expo_reg)); - SensorRegArrayW((I2C_ARRAY*)vts_reg, ARRAY_SIZE(vts_reg)); - params->dirty = false; - } - break; - default : - break; - } - - return SUCCESS; -} - -static int pCus_GetAEUSecs(ms_cus_sensor *handle, u32 *us) { -// gc2053_params *params = (gc2053_params *)handle->private_data; - u32 lines = 0; - - lines = (u32)(expo_reg[0].data&0xff); - lines |= (u32)(expo_reg[1].data&0x3f)<<8; - - *us = (lines*Preview_line_period)/1000; - - - SENSOR_DMSG("[%s] sensor expo lines/us %ld,%ld us\n", __FUNCTION__, lines, *us); - - return SUCCESS; -} - -static int pCus_SetAEUSecs(ms_cus_sensor *handle, u32 us) { - u32 lines = 0, vts = 0; - gc2053_params *params = (gc2053_params *)handle->private_data; - - lines=(1000*us)/Preview_line_period; - - if(lines<1) lines=1; - if (lines > params->expo.vts-4) { - vts = lines + 4; - }else - vts = params->expo.vts; - - params->expo.line = lines; - SENSOR_DMSG("[%s] us %ld, lines %ld, vts %ld\n", __FUNCTION__, - us, - lines, - params->expo.vts - ); - - expo_reg[0].data = (lines) & 0x00ff; - expo_reg[1].data = (lines>>8) & 0x003f; - vts_reg[0].data = (vts >> 8) & 0x003f; - vts_reg[1].data = (vts >> 0) & 0x00ff; - - - params->dirty = true; - return SUCCESS; -} - -// Gain: 1x = 1024 -static int pCus_GetAEGain(ms_cus_sensor *handle, u32* gain) { - // gc2053_params *params = (gc2053_params *)handle->private_data; - - u32 Again_0 = 1, Dgain_0 = 1; - u8 i; - u32 Fine_again = 1024; - - - for(i = 0;i < sizeof(gain_table)/sizeof(Gain_ARRAY);i++ ) - { - if(( gain_table[i].again_reg_val_0 ==gain_reg[1].data) && (gain_table[i].again_reg_val_1 ==gain_reg[2].data)) - { - Fine_again = gain_table[i].gain; - break; - } - } - - Dgain_0 = (gain_reg[5].data & 0xf) * 64 + (gain_reg[6].data >> 2); - Again_0 = Fine_again; - *gain =(u32)((Again_0 * Dgain_0)/64); - - - - return SUCCESS; -} - -static int pCus_SetAEGain(ms_cus_sensor *handle, u32 gain) { - - gc2053_params *params = (gc2053_params *)handle->private_data; - u32 dgain = 1; - u8 dgain_0 = 1, dgain_1 = 0; - u8 i = 0,tmp = 0; - int temperature_value = 0; - params->expo.final_gain = gain; - - if (gain < 1024) { - gain = 1024; - } else if (gain > SENSOR_MAX_GAIN * 1024) { - gain = SENSOR_MAX_GAIN * 1024; - } - - if(0 == times % 4) - { - SensorReg_Write(0xfe, 0x04); - SensorReg_Read(0x0c,&temperature_reg[0].data); - SensorReg_Read(0x0d,&temperature_reg[1].data); - SensorReg_Read(0x0e,&temperature_reg[2].data); - SensorReg_Read(0x0f,&temperature_reg[3].data); - SensorReg_Write(0xfe, 0x00); - if(times > 20) - { - times = 0; - } - } - temperature_value = (temperature_reg[0].data + temperature_reg[1].data + temperature_reg[2].data + temperature_reg[3].data) >> 2; - - if(temperature_value >= 0x64) - { - if(gain > gain_table[16].gain) - { - tmp = 16; - blk_flag=2; - } - else - { - for(i = 0;i < 16;i++ ) - { - if((gain >= gain_table[i].gain) && (gain < gain_table[i + 1].gain)) - { - tmp = i; - blk_flag=2; - break; - } - } - } - } - else if(temperature_value <= 0x18) - { - - for(i = 0;i < sizeof(gain_table)/sizeof(Gain_ARRAY) - 1;i++ ) - { - if((gain >= gain_table[i].gain) && (gain < gain_table[i + 1].gain)) - { - tmp = i; - blk_flag=1; - break; - } - else - { - blk_flag=1; - tmp = sizeof(gain_table)/sizeof(Gain_ARRAY) -1; - } - } - } - else - { - if(blk_flag==2) - { - if(gain >= gain_table[16].gain) - { - //gain = gain_table[16].gain; - tmp = 16; - } - else - { - for(i = 0;i < 16;i++ ) - { - if((gain >= gain_table[i].gain) && (gain < gain_table[i + 1].gain)) - { - tmp = i; - break; - } - } - } - } - if(blk_flag==1) - { - - for(i = 0;i < sizeof(gain_table)/sizeof(Gain_ARRAY) - 1;i++ ) - { - if((gain >= gain_table[i].gain) && (gain < gain_table[i + 1].gain)) - { - tmp = i; - break; - } - else - { - blk_flag=1; - tmp = sizeof(gain_table)/sizeof(Gain_ARRAY) - 1; - } - } - } - } - - - dgain =(gain*64)/(gain_table[tmp].gain); - dgain_0 = (dgain)>>6; - dgain_1 =(dgain & 0x3f)<<2; - gain_reg[1].data = gain_table[tmp].again_reg_val_0; - gain_reg[2].data = gain_table[tmp].again_reg_val_1; - gain_reg[3].data = gain_table[tmp].again_reg_val_2; - gain_reg[4].data = gain_table[tmp].again_reg_val_3; - - gain_reg[5].data = dgain_0; - gain_reg[6].data = dgain_1; - - - SENSOR_DMSG("[%s] set gain/regH/regL=%d/0x%x/0x%x\n", __FUNCTION__, gain,gain_reg[1].data,gain_reg[2].data); - - params->dirty = true; - return SUCCESS; -} - -static int pCus_GetAEMinMaxUSecs(ms_cus_sensor *handle, u32 *min, u32 *max) { - *min = 1;//30 - *max = 1000000/Preview_MIN_FPS; - return SUCCESS; -} - -static int pCus_GetAEMinMaxGain(ms_cus_sensor *handle, u32 *min, u32 *max) { - *min =handle->sat_mingain; - *max = SENSOR_MAX_GAIN*1024; - return SUCCESS; -} - -static int gc2053_GetShutterInfo(struct __ms_cus_sensor* handle,CUS_SHUTTER_INFO *info) -{ - info->max = 1000000000/Preview_MIN_FPS; - info->min = Preview_line_period*1;//2 - info->step = Preview_line_period*1;//2 - return SUCCESS; -} - -static int pCus_setCaliData_gain_linearity(ms_cus_sensor* handle, CUS_GAIN_GAP_ARRAY* pArray, u32 num) { - // u32 i, j; -/* - for(i=0,j=0;i< num ;i++,j+=2){ - gain_gap_compensate[i].gain=pArray[i].gain; - gain_gap_compensate[i].offset=pArray[i].offset; - } - //SENSOR_DMSG("[%s]%d, %d, %d, %d\n", __FUNCTION__, num, pArray[0].gain, pArray[1].gain, pArray[num-1].offset); -*/ - return SUCCESS; -} - -static int cus_camsensor_init_handle(ms_cus_sensor* drv_handle) { - ms_cus_sensor *handle = drv_handle; - gc2053_params *params; - if (!handle) { - SENSOR_DMSG("[%s] not enough memory!\n", __FUNCTION__); - return FAIL; - } - SENSOR_DMSG("[%s]", __FUNCTION__); - //private data allocation & init - handle->private_data = CamOsMemCalloc(1, sizeof(gc2053_params)); - params = (gc2053_params *)handle->private_data; - - //////////////////////////////////// - // sensor model ID // - //////////////////////////////////// - strcpy(handle->model_id,"gc2053_MIPI"); - - //////////////////////////////////// - // sensor interface info // - //////////////////////////////////// - //SENSOR_DMSG("[%s] entering function with id %d\n", __FUNCTION__, id); - handle->isp_type = SENSOR_ISP_TYPE; //ISP_SOC; - //handle->data_fmt = SENSOR_DATAFMT; //CUS_DATAFMT_YUV; - handle->sif_bus = SENSOR_IFBUS_TYPE;//CUS_SENIF_BUS_PARL; - handle->data_prec = SENSOR_DATAPREC; //CUS_DATAPRECISION_8; - handle->data_mode = SENSOR_DATAMODE; - handle->bayer_id = SENSOR_BAYERID; //CUS_BAYER_GB; - handle->RGBIR_id = SENSOR_RGBIRID; - handle->orient = SENSOR_ORIT; //CUS_ORIT_M1F1; - //handle->YC_ODER = SENSOR_YCORDER; //CUS_SEN_YCODR_CY; - handle->interface_attr.attr_mipi.mipi_lane_num = SENSOR_MIPI_LANE_NUM; - handle->interface_attr.attr_mipi.mipi_data_format = CUS_SEN_INPUT_FORMAT_RGB; // RGB pattern. - handle->interface_attr.attr_mipi.mipi_yuv_order = 0; //don't care in RGB pattern. - handle->interface_attr.attr_mipi.mipi_hsync_mode = SENSOR_MIPI_HSYNC_MODE; - handle->interface_attr.attr_mipi.mipi_hdr_mode = CUS_HDR_MODE_NONE; - handle->interface_attr.attr_mipi.mipi_hdr_virtual_channel_num = 0; //Short frame - - //////////////////////////////////// - // resolution capability // - //////////////////////////////////// - - handle->video_res_supported.num_res = 1; - handle->video_res_supported.ulcur_res = 0; - handle->video_res_supported.res[0].width = Preview_WIDTH; - handle->video_res_supported.res[0].height = Preview_HEIGHT; - handle->video_res_supported.res[0].max_fps= Preview_MAX_FPS; - handle->video_res_supported.res[0].min_fps= Preview_MIN_FPS; - handle->video_res_supported.res[0].crop_start_x= 0; - handle->video_res_supported.res[0].crop_start_y= 0; - handle->video_res_supported.res[0].nOutputWidth= 1920; - handle->video_res_supported.res[0].nOutputHeight= 1080; - SENSOR_DMSG(handle->video_res_supported.res[0].strResDesc, "1920x1080@30fps"); - - // i2c - - handle->i2c_cfg.mode = SENSOR_I2C_LEGACY; //(CUS_ISP_I2C_MODE) FALSE; - handle->i2c_cfg.fmt = SENSOR_I2C_FMT; //CUS_I2C_FMT_A16D16; - handle->i2c_cfg.address = SENSOR_I2C_ADDR; //0x5a; - handle->i2c_cfg.speed = SENSOR_I2C_SPEED; //320000; - - // mclk - handle->mclk = Preview_MCLK_SPEED; - - //polarity - ///////////////////////////////////////////////////// - handle->pwdn_POLARITY = SENSOR_PWDN_POL; //CUS_CLK_POL_NEG; - handle->reset_POLARITY = SENSOR_RST_POL; //CUS_CLK_POL_NEG; - handle->VSYNC_POLARITY = SENSOR_VSYNC_POL; //CUS_CLK_POL_POS; - handle->HSYNC_POLARITY = SENSOR_HSYNC_POL; //CUS_CLK_POL_POS; - handle->PCLK_POLARITY = SENSOR_PCLK_POL; //CUS_CLK_POL_POS); // use '!' to clear board latch error - ///////////////////////////////////////////////////// - - //////////////////////////////////////////////////// - // AE parameters - //////////////////////////////////////////////////// - handle->ae_gain_delay = 2; - handle->ae_shutter_delay = 2; - - handle->ae_gain_ctrl_num = 1; - handle->ae_shutter_ctrl_num = 1; - - ///calibration - handle->sat_mingain=g_sensor_ae_min_gain; - - - handle->pCus_sensor_release = cus_camsensor_release_handle; - handle->pCus_sensor_init = pCus_init ; - - handle->pCus_sensor_poweron = pCus_poweron ; - handle->pCus_sensor_poweroff = pCus_poweroff; - - // Normal - handle->pCus_sensor_GetSensorID = pCus_GetSensorID ; - - handle->pCus_sensor_GetVideoResNum = pCus_GetVideoResNum; - handle->pCus_sensor_GetVideoRes = pCus_GetVideoRes; - handle->pCus_sensor_GetCurVideoRes = pCus_GetCurVideoRes; - handle->pCus_sensor_SetVideoRes = pCus_SetVideoRes; - - handle->pCus_sensor_GetOrien = pCus_GetOrien ; - handle->pCus_sensor_SetOrien = pCus_SetOrien ; - handle->pCus_sensor_GetFPS = pCus_GetFPS ; - handle->pCus_sensor_SetFPS = pCus_SetFPS ; - //handle->pCus_sensor_GetSensorCap = pCus_GetSensorCap; - handle->pCus_sensor_SetPatternMode = gc2053_SetPatternMode; - /////////////////////////////////////////////////////// - // AE - /////////////////////////////////////////////////////// - // unit: micro seconds - //handle->pCus_sensor_GetAETrigger_mode = pCus_GetAETrigger_mode; - //handle->pCus_sensor_SetAETrigger_mode = pCus_SetAETrigger_mode; - handle->pCus_sensor_AEStatusNotify = pCus_AEStatusNotify; - handle->pCus_sensor_GetAEUSecs = pCus_GetAEUSecs; - handle->pCus_sensor_SetAEUSecs = pCus_SetAEUSecs; - handle->pCus_sensor_GetAEGain = pCus_GetAEGain; - - handle->pCus_sensor_SetAEGain = pCus_SetAEGain; - - handle->pCus_sensor_GetAEMinMaxGain = pCus_GetAEMinMaxGain; - handle->pCus_sensor_GetAEMinMaxUSecs= pCus_GetAEMinMaxUSecs; - - //sensor calibration -// handle->pCus_sensor_SetAEGain_cal = pCus_SetAEGain_cal; - handle->pCus_sensor_setCaliData_gain_linearity=pCus_setCaliData_gain_linearity; - handle->pCus_sensor_GetShutterInfo = gc2053_GetShutterInfo; - params->expo.vts=vts_30fps; - params->expo.fps = 30; - params->expo.line = 100; - params->dirty = false; - params->orient_dirty = false; - return SUCCESS; -} - -static int cus_camsensor_release_handle(ms_cus_sensor *handle) { - //ISensorIfAPI *sensor_if = handle->sensor_if_api; - //sensor_if->PCLK(NULL,CUS_PCLK_OFF); - //sensor_if->SetCSI_Clk(handle,CUS_CSI_CLK_DISABLE); - if (handle && handle->private_data) { - SENSOR_DMSG("[%s] release handle, handle %x, private data %x", - __FUNCTION__, - (int)handle, - (int)handle->private_data); - CamOsMemRelease(handle->private_data); - handle->private_data = NULL; - } - return SUCCESS; -} - -SENSOR_DRV_ENTRY_IMPL_END( gc2053, - cus_camsensor_init_handle, - NULL, - NULL - ); - diff --git a/general/package/sigmastar-osdrv-sensor/src/infinity6b0/sensor/sensor_gc4653_mipi.c b/general/package/sigmastar-osdrv-sensor/src/infinity6b0/sensor/sensor_gc4653_mipi.c deleted file mode 100644 index 4383e79a..00000000 --- a/general/package/sigmastar-osdrv-sensor/src/infinity6b0/sensor/sensor_gc4653_mipi.c +++ /dev/null @@ -1,1108 +0,0 @@ -/* Copyright (c) 2018-2019 Sigmastar Technology Corp. - All rights reserved. - - Unless otherwise stipulated in writing, any and all information contained -herein regardless in any format shall remain the sole proprietary of -Sigmastar Technology Corp. and be kept in strict confidence -(Sigmastar Confidential Information) by the recipient. -Any unauthorized act including without limitation unauthorized disclosure, -copying, use, reproduction, sale, distribution, modification, disassembling, -reverse engineering and compiling of the contents of Sigmastar Confidential -Information is unlawful and strictly prohibited. Sigmastar hereby reserves the -rights to any and all damages, losses, costs and expenses resulting therefrom. -*/ - -#ifdef __cplusplus -extern "C" -{ -#endif - -#include -#include -#include - -#ifdef __cplusplus -} -#endif - -SENSOR_DRV_ENTRY_IMPL_BEGIN_EX(gc4653); - -#ifndef ARRAY_SIZE -#define ARRAY_SIZE CAM_OS_ARRAY_SIZE -#endif - -#define SENSOR_CHANNEL_NUM (0) -#define SENSOR_CHANNEL_MODE_LINEAR CUS_SENSOR_CHANNEL_MODE_REALTIME_NORMAL -#define SENSOR_CHANNEL_MODE_SONY_DOL CUS_SENSOR_CHANNEL_MODE_RAW_STORE_HDR - -//============================================ -//MIPI config begin. -#define SENSOR_MIPI_LANE_NUM (2) -//#define SENSOR_MIPI_HDR_MODE (1) //0: Non-HDR mode. 1:Sony DOL mode -//MIPI config end. -//============================================ - -#define R_GAIN_REG 1 -#define G_GAIN_REG 2 -#define B_GAIN_REG 3 - - -//#undef SENSOR_DBG -#define SENSOR_DBG 0 - -#define SENSOR_ISP_TYPE ISP_EXT //ISP_EXT, ISP_SOC -#define SENSOR_IFBUS_TYPE CUS_SENIF_BUS_MIPI //CUS_SENIF_BUS_PARL, CUS_SENIF_BUS_MIPI -#define SENSOR_MIPI_HSYNC_MODE PACKET_HEADER_EDGE1 -#define SENSOR_DATAPREC CUS_DATAPRECISION_10 //CFG //CUS_DATAPRECISION_8, CUS_DATAPRECISION_10 -#define SENSOR_DATAMODE CUS_SEN_10TO12_9000 //CFG -#define SENSOR_BAYERID CUS_BAYER_GR //CFG //CUS_BAYER_GB, CUS_BAYER_GR, CUS_BAYER_BG, CUS_BAYER_RG -#define SENSOR_RGBIRID CUS_RGBIR_NONE -#define SENSOR_ORIT CUS_ORIT_M0F0 //CUS_ORIT_M0F0, CUS_ORIT_M1F0, CUS_ORIT_M0F1, CUS_ORIT_M1F1, -#define SENSOR_MAX_GAIN (77660)/100 // max sensor again, a-gain -//#define SENSOR_YCORDER CUS_SEN_YCODR_YC //CUS_SEN_YCODR_YC, CUS_SEN_YCODR_CY -#define lane_number 2 -#define vc0_hs_mode 3 //0: packet header edge 1: line end edge 2: line start edge 3: packet footer edge -#define long_packet_type_enable 0x00 //UD1~UD8 (user define) - -#define Preview_MCLK_SPEED CUS_CMU_CLK_27MHZ //CFG //CUS_CMU_CLK_12M, CUS_CMU_CLK_16M, CUS_CMU_CLK_24M, CUS_CMU_CLK_27M -#define Preview_line_period 22222//30580 //(36M/37.125M)*30fps=29.091fps(34.375msec), hts=34.375/1125=30556, -//#define Line_per_second 32727 -#define vts_30fps 1500//1266//1150//1090 //for 29.091fps @ MCLK=36MHz -//#define Prv_Max_line_number 2200 //maximum exposure line munber of sensor when preview -#define Preview_WIDTH 2560 //resolution Width when preview -#define Preview_HEIGHT 1440 //resolution Height when preview -#define Preview_MAX_FPS 30 //fastest preview FPS -#define Preview_MIN_FPS 5 //slowest preview FPS -#define Preview_CROP_START_X 0 //CROP_START_X -#define Preview_CROP_START_Y 0 //CROP_START_Y - -#define SENSOR_I2C_ADDR 0x52 //I2C slave address -#define SENSOR_I2C_SPEED 200000 //300000// 240000 //I2C speed, 60000~320000 - -#define SENSOR_I2C_LEGACY I2C_NORMAL_MODE //usally set CUS_I2C_NORMAL_MODE, if use old OVT I2C protocol=> set CUS_I2C_LEGACY_MODE -#define SENSOR_I2C_FMT I2C_FMT_A16D8 //CUS_I2C_FMT_A8D8, CUS_I2C_FMT_A8D16, CUS_I2C_FMT_A16D8, CUS_I2C_FMT_A16D16 - -#define SENSOR_PWDN_POL CUS_CLK_POL_POS // if PWDN pin High can makes sensor in power down, set CUS_CLK_POL_POS -#define SENSOR_RST_POL CUS_CLK_POL_NEG // if RESET pin High can makes sensor in reset state, set CUS_CLK_POL_NEG - -// VSYNC/HSYNC POL can be found in data sheet timing diagram, -// Notice: the initial setting may contain VSYNC/HSYNC POL inverse settings so that condition is different. - -#define SENSOR_VSYNC_POL CUS_CLK_POL_NEG // if VSYNC pin High and data bus have data, set CUS_CLK_POL_POS -#define SENSOR_HSYNC_POL CUS_CLK_POL_NEG // if HSYNC pin High and data bus have data, set CUS_CLK_POL_POS -#define SENSOR_PCLK_POL CUS_CLK_POL_POS // depend on sensor setting, sometimes need to try CUS_CLK_POL_POS or CUS_CLK_POL_NEG - - -#if defined (SENSOR_MODULE_VERSION) -#define TO_STR_NATIVE(e) #e -#define TO_STR_PROXY(m, e) m(e) -#define MACRO_TO_STRING(e) TO_STR_PROXY(TO_STR_NATIVE, e) -static char *sensor_module_version = MACRO_TO_STRING(SENSOR_MODULE_VERSION); -module_param(sensor_module_version, charp, S_IRUGO); -#endif - -static int pCus_SetAEGain(ms_cus_sensor *handle, u32 gain); -static int pCus_SetAEUSecs(ms_cus_sensor *handle, u32 us); -static int pCus_SetFPS(ms_cus_sensor *handle, u32 fps); -CUS_MCLK_FREQ UseParaMclk(void); - -typedef struct { - struct { - u16 pre_div0; - u16 div124; - u16 div_cnt7b; - u16 sdiv0; - u16 mipi_div0; - u16 r_divp; - u16 sdiv1; - u16 r_seld5; - u16 r_sclk_dac; - u16 sys_sel; - u16 pdac_sel; - u16 adac_sel; - u16 pre_div_sp; - u16 r_div_sp; - u16 div_cnt5b; - u16 sdiv_sp; - u16 div12_sp; - u16 mipi_lane_sel; - u16 div_dac; - } clk_tree; - struct { - bool bVideoMode; - u16 res_idx; - // bool binning; - // bool scaling; - CUS_CAMSENSOR_ORIT orit; - } res; - struct { - u32 sclk; - u32 hts; - u32 vts; - u32 ho; - u32 xinc; - u32 line_freq; - u32 us_per_line; - u32 final_us; - u32 final_gain; - u32 back_pv_us; - u32 fps; - u32 line; - } expo; - - int sen_init; - int still_min_fps; - int video_min_fps; - bool dirty; - bool orient_dirty; - I2C_ARRAY tVts_reg[2]; - I2C_ARRAY tGain_reg[7]; - I2C_ARRAY tExpo_reg[2]; - I2C_ARRAY tMirror_reg[1]; -} gc4653_params; -// set sensor ID address and data, - -/* typedef struct { - unsigned int total_gain; - unsigned short reg_val; -} Gain_ARRAY; - */ -const static I2C_ARRAY Sensor_id_table[] = -{ - {0x03f0, 0x46}, // {address of ID, ID }, - {0x03f1, 0x53}, -}; - -typedef struct { - u32 gain; - unsigned short again_reg_val_0; - unsigned short again_reg_val_1; - unsigned short again_reg_val_2; - unsigned short again_reg_val_3; - unsigned short again_reg_val_4; -} Gain_ARRAY; - -const static I2C_ARRAY Sensor_init_table[] = -{ -/****************************************/ -//version 6.3 -//mclk 27Mhz -//mipiclk 648Mhz -//framelength 1500 -//linelength 4800 -//pclk 216Mhz -//rowtime 22.2222us -//pattern grbg - -/****************************************/ - -/****************************************/ -/*SYSTEM*/ -/****************************************/ -{0x03fe, 0xf0}, -{0x03fe, 0x00}, -{0x0317, 0x00}, -{0x0320, 0x77}, -{0x0324, 0xc8}, -{0x0325, 0x06}, -{0x0326, 0x60}, -{0x0327, 0x03}, -{0x0334, 0x40}, -{0x0336, 0x60}, -{0x0337, 0x82}, -{0x0315, 0x25}, -{0x031c, 0xc6}, -/****************************************/ -/*frame structure*/ -/****************************************/ -{0x0287, 0x18}, -{0x0084, 0x00}, -{0x0087, 0x50}, -{0x029d, 0x08}, -{0x0290, 0x00}, -//AHD 30 other need change -{0x0340, 0x05}, -{0x0341, 0xdc}, -{0x0345, 0x06}, -{0x034b, 0xb0}, -{0x0352, 0x08}, -{0x0354, 0x08}, -/****************************************/ -/*ANALOG CIRCUIT*/ -/****************************************/ -{0x02d1, 0xb0}, -{0x023c, 0x05}, -{0x0223, 0xfb}, -{0x0232, 0xc4}, -{0x0279, 0x53}, -{0x02d3, 0x01}, -{0x0243, 0x06}, -{0x02ce, 0xbf}, -{0x02ee, 0x30}, -{0x026f, 0x70}, -{0x0257, 0x09}, -{0x0211, 0x02}, -{0x0219, 0x09}, -{0x023f, 0x2d}, -{0x0518, 0x00}, -{0x0519, 0x01}, -{0x0515, 0x08}, -{0x02d9, 0x3f}, -{0x02da, 0x02}, -{0x02db, 0xe8}, -{0x02e6, 0x20}, -{0x021b, 0x10}, -{0x0252, 0x22}, -{0x024e, 0x22}, -{0x02c4, 0x01}, -{0x021d, 0x07}, -{0x024a, 0x01}, -{0x02ca, 0x02}, -{0x0262, 0x10}, -{0x029a, 0x20}, -{0x021c, 0x0e}, -{0x0298, 0x03}, -{0x029c, 0x00}, -{0x027e, 0x14}, -{0x02c2, 0x10}, -{0x0540, 0x20}, -{0x0546, 0x01}, -{0x0548, 0x01}, -{0x0544, 0x01}, -{0x0242, 0x1b}, -{0x02c0, 0x1b}, -{0x02c3, 0x20}, -{0x02e4, 0x10}, -{0x022e, 0x00}, -{0x027b, 0x3f}, -{0x0269, 0x0f}, -{0x02d2, 0x40}, -{0x027c, 0x08}, -{0x023a, 0x2e}, -{0x0245, 0xce}, -{0x0530, 0x20}, -{0x0531, 0x02}, -{0x0228, 0x28}, -{0x02ab, 0x00}, -{0x0250, 0x00}, -{0x0221, 0x28}, -{0x02ac, 0x00}, -{0x02a5, 0x02}, -{0x0260, 0x0b}, -{0x0216, 0x04}, -{0x0299, 0x1C}, -{0x02bb, 0x0d}, -{0x02a3, 0x02}, -{0x02a4, 0x02}, -{0x021e, 0x02}, -{0x024f, 0x08}, -{0x028c, 0x08}, -{0x0532, 0x3f}, -{0x0533, 0x02}, -{0x0277, 0x38}, -{0x0276, 0x60}, -{0x0239, 0xc0}, -/*exp*/ -{0x0202, 0x05}, -{0x0203, 0xd0}, -/*gain*/ -{0x0205, 0xc0}, -{0x02b0, 0x60}, //0x90 -/*dpc*/ -{0x0002, 0xa9}, -{0x0004, 0x01}, -/****************************************/ -/*mipi*/ -/****************************************/ -//30fps -{0x0342, 0x06}, -{0x0343, 0x40}, -{0x03fe, 0x10}, -{0x03fe, 0x00}, -{0x0106, 0x78}, -{0x0108, 0x0c}, -{0x0114, 0x01}, -{0x0115, 0x12}, -{0x0180, 0x46}, -{0x0181, 0x30}, -{0x0182, 0x05}, -{0x0185, 0x01}, -{0x03fe, 0x10}, -{0x03fe, 0x00}, -{0x0100, 0x09}, -}; - -const I2C_ARRAY TriggerStartTbl[] = { -//{0x30f4,0x00},//Master mode start -}; - -const I2C_ARRAY PatternTbl[] = { - //pattern mode -}; - -///////////////////////////////////////////////////////////////// -// @@@@@@ // -// @@ // -// @@@ // -// @ @@ // -// @@@@ // -// // -// Step 3 -- complete camera features // -// // -// // -// camera set EV, MWB, orientation, contrast, sharpness // -// , saturation, and Denoise can work correctly. // -// // -///////////////////////////////////////////////////////////////// - -const I2C_ARRAY mirror_reg[] = { - {0x0101, 0x00}, -}; - -typedef struct { - short reg; - char startbit; - char stopbit; -} COLLECT_REG_SET; - -static int g_sensor_ae_min_gain = 1024;//1280; - -const static I2C_ARRAY gain_reg[] = { - {0x02b3, 0x00}, - {0x0519, 0x04}, - {0x02d9, 0x42}, - {0x02b8, 0x01}, - {0x02b9, 0x00}, - {0x020e, 0x01}, - {0x020f, 0x00}, -}; - -const static I2C_ARRAY expo_reg[] = { - {0x0203, 0xd0}, // expo[7:0] - {0x0202, 0x05}, // expo[15:8] -}; - -const static I2C_ARRAY vts_reg[] = { - {0x0340, 0x05}, - {0x0341, 0xdc}, -}; - - static Gain_ARRAY gain_table[]={ - //02b3, 0519, 02d9, 02b8, 02b9 - { 1024, 0x00, 0x04, 0x42, 0x01, 0x00}, - { 1213, 0x20, 0x05, 0x43, 0x01, 0x0B}, - { 1434, 0x01, 0x04, 0x42, 0x01, 0x19}, - { 1699, 0x21, 0x05, 0x43, 0x01, 0x2a}, - { 2048, 0x02, 0x04, 0x42, 0x02, 0x00}, - { 2427, 0x22, 0x05, 0x43, 0x02, 0x17}, - { 2867, 0x03, 0x05, 0x43, 0x02, 0x33}, - { 3398, 0x23, 0x06, 0x44, 0x03, 0x14}, - { 4096, 0x04, 0x06, 0x44, 0x04, 0x00}, - { 4854, 0x24, 0x08, 0x46, 0x04, 0x2f}, - { 5734, 0x05, 0x08, 0x46, 0x05, 0x26}, - { 6795, 0x25, 0x0a, 0x48, 0x06, 0x28}, - { 8192, 0x06, 0x0c, 0x4a, 0x08, 0x00}, - { 9708, 0x26, 0x0d, 0x4b, 0x09, 0x1E}, - {11469, 0x46, 0x0f, 0x4d, 0x0B, 0x0C}, - {13591, 0x66, 0x11, 0x4f, 0x0D, 0x11}, - {16384, 0x0e, 0x13, 0x51, 0x10, 0x00}, - {19415, 0x2e, 0x16, 0x54, 0x12, 0x3D}, - {22938, 0x4e, 0x19, 0x57, 0x16, 0x19}, - {27181, 0x6e, 0x1b, 0x59, 0x1A, 0x22}, - {32768, 0x1e, 0x1e, 0x5c, 0x20, 0x00}, - {38830, 0x3e, 0x21, 0x5f, 0x25, 0x3A}, - {45875, 0x5e, 0x25, 0x63, 0x2C, 0x33}, - {54362, 0x7e, 0x29, 0x67, 0x35, 0x05}, - {65536, 0x9e, 0x2d, 0x6b, 0x40, 0x00}, - {77660, 0xbe, 0x40, 0x78, 0x4B, 0x35}, -}; - -#if 0 -static CUS_INT_TASK_ORDER def_order = { - .RunLength = 9, - .Orders = { - CUS_INT_TASK_AE|CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_AWB|CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_AE|CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_AWB|CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_AE|CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_AWB|CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - }, -}; -#endif - -/////////// function definition /////////////////// -#if SENSOR_DBG == 1 -//#define SENSOR_DMSG(args...) SENSOR_DMSG(args) -//#define SENSOR_DMSG(args...) LOGE(args) -#define SENSOR_DMSG(args...) SENSOR_DMSG(args) -#elif SENSOR_DBG == 0 -//#define SENSOR_DMSG(args...) -#endif -#undef SENSOR_NAME -#define SENSOR_NAME gc4653 - - -#define SensorReg_Read(_reg,_data) (handle->i2c_bus->i2c_rx(handle->i2c_bus, &(handle->i2c_cfg),_reg,_data)) -#define SensorReg_Write(_reg,_data) (handle->i2c_bus->i2c_tx(handle->i2c_bus, &(handle->i2c_cfg),_reg,_data)) -#define SensorRegArrayW(_reg,_len) (handle->i2c_bus->i2c_array_tx(handle->i2c_bus, &(handle->i2c_cfg),(_reg),(_len))) -#define SensorRegArrayR(_reg,_len) (handle->i2c_bus->i2c_array_rx(handle->i2c_bus, &(handle->i2c_cfg),(_reg),(_len))) - -static int cus_camsensor_release_handle(ms_cus_sensor *handle); - -/////////////////// sensor hardware dependent ////////////// -#if 0 -static int ISP_config_io(ms_cus_sensor *handle) { - ISensorIfAPI *sensor_if = handle->sensor_if_api; - - SENSOR_DMSG("[%s]", __FUNCTION__); - - sensor_if->HsyncPol(handle, handle->HSYNC_POLARITY); - sensor_if->VsyncPol(handle, handle->VSYNC_POLARITY); - sensor_if->ClkPol(handle, handle->PCLK_POLARITY); - sensor_if->BayerFmt(handle, handle->bayer_id); - sensor_if->DataBus(handle, handle->sif_bus); - - sensor_if->DataPrecision(handle, handle->data_prec); - sensor_if->FmtConv(handle, handle->data_mode); - return SUCCESS; -} -#endif - -//static u32 timeGetTimeU(void) -//{ -// CamOsTimespec_t tRes; -// CamOsGetMonotonicTime(&tRes); -// return (tRes.nSec * 1000000)+(tRes.nNanoSec/1000); -//} -//static u32 TStart = 0; - -static int pCus_poweron(ms_cus_sensor *handle, u32 idx) -{ - ISensorIfAPI *sensor_if = handle->sensor_if_api; - SENSOR_DMSG("[%s] ", __FUNCTION__); - - //TStart = timeGetTimeU(); - /*PAD and CSI*/ - sensor_if->SetIOPad(idx, handle->sif_bus, handle->interface_attr.attr_mipi.mipi_lane_num); - sensor_if->SetCSI_Clk(idx, CUS_CSI_CLK_216M); ///??? - sensor_if->SetCSI_Lane(idx, handle->interface_attr.attr_mipi.mipi_lane_num, 1); ///??? - sensor_if->SetCSI_LongPacketType(idx, 0, 0x1C00, 0); //========= ???? - - /*Power ON*/ - sensor_if->PowerOff(idx, !handle->pwdn_POLARITY); - SENSOR_USLEEP(1000); - - /*Reset PIN*/ - SENSOR_DMSG("[%s] reset low\n", __FUNCTION__); - sensor_if->Reset(idx, handle->reset_POLARITY); - SENSOR_USLEEP(1000); - sensor_if->PowerOff(idx, handle->pwdn_POLARITY); - SENSOR_USLEEP(1000); - SENSOR_DMSG("[%s] reset high\n", __FUNCTION__); - sensor_if->Reset(idx, !handle->reset_POLARITY); - SENSOR_USLEEP(1000); - - /*MCLK ON*/ - sensor_if->MCLK(idx, 1, handle->mclk); - SENSOR_USLEEP(5000); - //CamOsPrintf("pCus_poweron = %d us \n",timeGetTimeU()-TStart); - return SUCCESS; -} - -static int pCus_poweroff(ms_cus_sensor *handle, u32 idx) -{ - // power/reset low - ISensorIfAPI *sensor_if = handle->sensor_if_api; - SENSOR_DMSG("[%s] power low\n", __FUNCTION__); - sensor_if->PowerOff(idx, !handle->pwdn_POLARITY); - sensor_if->Reset(idx, handle->reset_POLARITY); - //handle->i2c_bus->i2c_close(handle->i2c_bus); - SENSOR_USLEEP(1000); - //Set_csi_if(0, 0); - sensor_if->SetCSI_Clk(idx, CUS_CSI_CLK_DISABLE); - sensor_if->MCLK(idx, 0, handle->mclk); - - return SUCCESS; -} - -/////////////////// image function ///////////////////////// -//Get and check sensor ID -//if i2c error or sensor id does not match then return FAIL -static int pCus_GetSensorID(ms_cus_sensor *handle, u32 *id) -{ - int i,n; - int table_length= ARRAY_SIZE(Sensor_id_table); - I2C_ARRAY id_from_sensor[ARRAY_SIZE(Sensor_id_table)]; - - - for(n=0;n8) table_length=8; - - SENSOR_DMSG("\n\n[%s]", __FUNCTION__); - - for(n=0;n<4;++n) //retry , until I2C success - { - if(n>2) return FAIL; - - if( SensorRegArrayR((I2C_ARRAY*)id_from_sensor,table_length) == SUCCESS) //read sensor ID from I2C - break; - else - continue; - } - - //convert sensor id to u32 format - for(i=0;i>= 8; - SENSOR_DMSG("[%s]gc4653 Read sensor id, get 0x%x Success\n", __FUNCTION__, (int)*id); - //SENSOR_DMSG("[%s]Read sensor id, get 0x%x Success\n", __FUNCTION__, (int)*id); - - return SUCCESS; -} - -static int gc4653_SetPatternMode(ms_cus_sensor *handle,u32 mode) -{ - - SENSOR_DMSG("\n\n[%s], mode=%d \n", __FUNCTION__, mode); - - return SUCCESS; -} - -static int pCus_SetFPS(ms_cus_sensor *handle, u32 fps); -//static int pCus_SetAEGain_cal(ms_cus_sensor *handle, u32 gain); -static int pCus_AEStatusNotify(ms_cus_sensor *handle, CUS_CAMSENSOR_AE_STATUS_NOTIFY status); -static int pCus_init(ms_cus_sensor *handle) -{ - int i,cnt=0; - SENSOR_DMSG("\n\n[%s]", __FUNCTION__); - //ISensorIfAPI *sensor_if = handle->sensor_if_api; - //sensor_if->PCLK(NULL,CUS_PCLK_MIPI_TOP); - //TStart = timeGetTimeU(); - - for(i=0;i< ARRAY_SIZE(Sensor_init_table);i++) - { - if(Sensor_init_table[i].reg==0xffff) - { - msleep(Sensor_init_table[i].data); - } - else - { - cnt = 0; - while(SensorReg_Write(Sensor_init_table[i].reg,Sensor_init_table[i].data) != SUCCESS) - { - cnt++; - - if(cnt>=10) - { - - return FAIL; - } - msleep(10); - } - } - } -/* - for(i=0;i< ARRAY_SIZE(PatternTbl);i++) - { - if(SensorReg_Write(PatternTbl[i].reg,PatternTbl[i].data) != SUCCESS) - { - //MSG("[%s:%d]Sensor init fail!!\n", __FUNCTION__, __LINE__); - return FAIL; - } - } -*/ - pCus_SetAEGain(handle,1024); //Set sensor gain = 1x - pCus_SetAEUSecs(handle, 30000); - pCus_AEStatusNotify(handle,CUS_FRAME_ACTIVE); - return SUCCESS; -} -/* -int pCus_release(ms_cus_sensor *handle) -{ - ISensorIfAPI *sensor_if = handle->sensor_if_api; - sensor_if->PCLK(NULL,CUS_PCLK_OFF); - return SUCCESS; -} -*/ - -static int pCus_GetVideoResNum( ms_cus_sensor *handle, u32 *ulres_num) -{ - *ulres_num = handle->video_res_supported.num_res; - return SUCCESS; -} - -static int pCus_GetVideoRes(ms_cus_sensor *handle, u32 res_idx, cus_camsensor_res **res) -{ - u32 num_res = handle->video_res_supported.num_res; - - if (res_idx >= num_res) { - return FAIL; - } - - *res = &handle->video_res_supported.res[res_idx]; - - return SUCCESS; -} - -static int pCus_GetCurVideoRes(ms_cus_sensor *handle, u32 *cur_idx, cus_camsensor_res **res) -{ - u32 num_res = handle->video_res_supported.num_res; - - *cur_idx = handle->video_res_supported.ulcur_res; - - if (*cur_idx >= num_res) { - return FAIL; - } - - *res = &handle->video_res_supported.res[*cur_idx]; - - return SUCCESS; -} - -static int pCus_SetVideoRes(ms_cus_sensor *handle, u32 res_idx) -{ - u32 num_res = handle->video_res_supported.num_res; - if (res_idx >= num_res) { - return FAIL; - } - switch (res_idx) { - case 0: - handle->video_res_supported.ulcur_res = 0; - handle->pCus_sensor_init = pCus_init; - break; - - default: - break; - } - - return SUCCESS; -} - -static int pCus_GetOrien(ms_cus_sensor *handle, CUS_CAMSENSOR_ORIT *orit) { - char sen_data; - sen_data = mirror_reg[0].data; - SENSOR_DMSG("mirror:%x\r\n", sen_data); - switch(sen_data) { - case 0x03: - *orit = CUS_ORIT_M0F0; - break; - case 0x02: - *orit = CUS_ORIT_M1F0; - break; - case 0x01: - *orit = CUS_ORIT_M0F1; - break; - case 0x00: - *orit = CUS_ORIT_M1F1; - break; - } - - return SUCCESS; -} - -static int pCus_SetOrien(ms_cus_sensor *handle, CUS_CAMSENSOR_ORIT orit) { - gc4653_params *params = (gc4653_params *)handle->private_data; - switch(orit) { - case CUS_ORIT_M0F0: - params->tMirror_reg[0].data = 0x03; - params->orient_dirty = true; - //params->dirty = true; - break; - case CUS_ORIT_M1F0: - params->tMirror_reg[0].data = 0x2; - params->orient_dirty = true; - //params->dirty = true; - break; - case CUS_ORIT_M0F1: - params->tMirror_reg[0].data = 0x01; - params->orient_dirty = true; - //params->dirty = true; - break; - case CUS_ORIT_M1F1: - params->tMirror_reg[0].data = 0x00; - params->orient_dirty = true; - //params->dirty = true; - break; - } - - return SUCCESS; -} - -static int pCus_GetFPS(ms_cus_sensor *handle) -{ - gc4653_params *params = (gc4653_params *)handle->private_data; - return params->expo.fps; -} -static int pCus_SetFPS(ms_cus_sensor *handle, u32 fps) -{ - int vts=0; - gc4653_params *params = (gc4653_params *)handle->private_data; - SENSOR_DMSG("\n\n[%s]", __FUNCTION__); - - if(fps>=5 && fps <= 30){ - params->expo.fps = fps; - params->expo.vts= (vts_30fps*30)/fps; - }else if(fps>=5000 && fps <= 30000){ - params->expo.fps = fps; - params->expo.vts= (vts_30fps*30000)/fps; - }else{ - //params->expo.vts=vts_30fps; - //params->expo.fps=30; - //SENSOR_DMSG("[%s] FPS %d out of range.\n",__FUNCTION__,fps); - return FAIL; - } - - if ((params->expo.line) > (params->expo.vts)-4) { - vts = params->expo.line + 4; - }else - vts = params->expo.vts; - params->tVts_reg[0].data = (vts >> 8) & 0x003f; - params->tVts_reg[1].data = (vts >> 0) & 0x00ff; - //vts_reg[0].data = ((params->expo.vts - 12 ) >> 8) & 0x001f; - //vts_reg[1].data = ((params->expo.vts - 12) >> 0) & 0x00ff; - - params->dirty = true; - return SUCCESS; -} - -#if 0 -static int pCus_GetSensorCap(ms_cus_sensor *handle, CUS_CAMSENSOR_CAP *cap) { - if (cap) - memcpy(cap, &sensor_cap, sizeof(CUS_CAMSENSOR_CAP)); - else return FAIL; - return SUCCESS; -} -#endif - -/////////////////////////////////////////////////////////////////////// -// auto exposure -/////////////////////////////////////////////////////////////////////// -// unit: micro seconds -//AE status notification -static int pCus_AEStatusNotify(ms_cus_sensor *handle, CUS_CAMSENSOR_AE_STATUS_NOTIFY status){ - gc4653_params *params = (gc4653_params *)handle->private_data; - switch(status) - { - case CUS_FRAME_INACTIVE: - - break; - case CUS_FRAME_ACTIVE: - if(params->orient_dirty) - { - SensorRegArrayW((I2C_ARRAY*)params->tMirror_reg, ARRAY_SIZE(mirror_reg)); - params->orient_dirty = false; - } - if(params->dirty) - { - SensorRegArrayW((I2C_ARRAY*)params->tGain_reg, ARRAY_SIZE(gain_reg)); - SensorRegArrayW((I2C_ARRAY*)params->tExpo_reg, ARRAY_SIZE(expo_reg)); - SensorRegArrayW((I2C_ARRAY*)params->tVts_reg, ARRAY_SIZE(vts_reg)); - params->dirty = false; - } - break; - default : - break; - } - - return SUCCESS; -} - -static int pCus_GetAEUSecs(ms_cus_sensor *handle, u32 *us) { - gc4653_params *params = (gc4653_params *)handle->private_data; - u32 lines = 0; - - lines = (u32)(params->tExpo_reg[0].data&0xff); - lines |= (u32)(params->tExpo_reg[1].data&0x3f)<<8; - - *us = (lines*Preview_line_period)/1000; - - - SENSOR_DMSG("[%s] sensor expo lines/us %ld,%ld us\n", __FUNCTION__, lines, *us); - - return SUCCESS; -} - -static int pCus_SetAEUSecs(ms_cus_sensor *handle, u32 us) { - u32 lines = 0, vts = 0; - gc4653_params *params = (gc4653_params *)handle->private_data; - - lines=(1000*us)/Preview_line_period; - - if(lines<1) lines=1; - if (lines > params->expo.vts-4) { - vts = lines + 4; - }else - vts = params->expo.vts; - - params->expo.line = lines; - SENSOR_DMSG("[%s] us %ld, lines %ld, vts %ld\n", __FUNCTION__, - us, - lines, - params->expo.vts - ); - params->tExpo_reg[0].data = (lines) & 0x00ff; - params->tExpo_reg[1].data = (lines>>8) & 0x003f; - params->tVts_reg[0].data = (vts >> 8) & 0x003f; - params->tVts_reg[1].data = (vts >> 0) & 0x00ff; - - params->dirty = true; - return SUCCESS; -} - -// Gain: 1x = 1024 -static int pCus_GetAEGain(ms_cus_sensor *handle, u32* gain) { - gc4653_params *params = (gc4653_params *)handle->private_data; - u32 Again_0 = 1, Dgain_0 = 1; - u8 i; - u32 Fine_again = 1024; - - for(i = 0;i < sizeof(gain_table)/sizeof(Gain_ARRAY);i++ ) { - if(( gain_table[i].again_reg_val_0 == params->tGain_reg[1].data) && (gain_table[i].again_reg_val_1 == params->tGain_reg[2].data)) - { - Fine_again = gain_table[i].gain; - break; - } - } - - Dgain_0 = (params->tGain_reg[5].data & 0xf) * 64 + (params->tGain_reg[6].data >> 2); - Again_0 = Fine_again; - *gain =(u32)((Again_0 * Dgain_0)/64); - - return SUCCESS; -} - -static int pCus_SetAEGain(ms_cus_sensor *handle, u32 gain) { - gc4653_params *params = (gc4653_params *)handle->private_data; - u32 dgain = 1; -// u32 gain_64 = gain; - u8 dgain_0 = 1, dgain_1 = 0; - u8 i = 0,tmp = 0; -// int temperature_value; - params->expo.final_gain = gain; - - if (gain < 1024) { - gain = 1024; - } else if (gain > SENSOR_MAX_GAIN * 1024) { - gain = SENSOR_MAX_GAIN * 1024; - } - - for(i = 1;i < sizeof(gain_table)/sizeof(Gain_ARRAY);i++ ) - { - if((gain >= gain_table[i-1].gain) && (gain < gain_table[i].gain)) - { - tmp = i - 1; - break; - } - else - tmp = sizeof(gain_table)/sizeof(Gain_ARRAY) - 1; - } - - dgain =(gain*64)/(gain_table[tmp].gain); - dgain_0 = (dgain)>>6; - dgain_1 =(dgain & 0x3f)<<2; - params->tGain_reg[0].data = gain_table[tmp].again_reg_val_0; - params->tGain_reg[1].data = gain_table[tmp].again_reg_val_1; - params->tGain_reg[2].data = gain_table[tmp].again_reg_val_2; - params->tGain_reg[3].data = gain_table[tmp].again_reg_val_3; - params->tGain_reg[4].data = gain_table[tmp].again_reg_val_4; - - params->tGain_reg[5].data = dgain_0; - params->tGain_reg[6].data = dgain_1; - SENSOR_DMSG("[%s] set gain/regH/regL=%d/0x%x/0x%x\n", __FUNCTION__, gain,gain_reg[1].data,gain_reg[2].data); - - params->dirty = true; - return SUCCESS; -} - -static int pCus_GetAEMinMaxUSecs(ms_cus_sensor *handle, u32 *min, u32 *max) { - *min = 30; - *max = 1000000/Preview_MIN_FPS; - return SUCCESS; -} - -static int pCus_GetAEMinMaxGain(ms_cus_sensor *handle, u32 *min, u32 *max) { - *min =handle->sat_mingain; - *max = SENSOR_MAX_GAIN*1024; - return SUCCESS; -} - -static int gc4653_GetShutterInfo(struct __ms_cus_sensor* handle,CUS_SHUTTER_INFO *info) -{ - info->max = 1000000000/Preview_MIN_FPS; - info->min = Preview_line_period*1;//2 - info->step = Preview_line_period*1;//2 - return SUCCESS; -} - -static int pCus_setCaliData_gain_linearity(ms_cus_sensor* handle, CUS_GAIN_GAP_ARRAY* pArray, u32 num) { - - return SUCCESS; -} - -int cus_camsensor_init_handle(ms_cus_sensor* drv_handle) { - ms_cus_sensor *handle = drv_handle; - gc4653_params *params; - if (!handle) { - SENSOR_DMSG("[%s] not enough memory!\n", __FUNCTION__); - return FAIL; - } - SENSOR_DMSG("[%s]", __FUNCTION__); - //private data allocation & init - if (handle->private_data == NULL) { - SENSOR_EMSG("[%s] Private data is empty!\n", __FUNCTION__); - return FAIL; - } - params = (gc4653_params *)handle->private_data; - memcpy(params->tGain_reg, gain_reg, sizeof(gain_reg)); - memcpy(params->tExpo_reg, expo_reg, sizeof(expo_reg)); - memcpy(params->tVts_reg, vts_reg, sizeof(vts_reg)); - memcpy(params->tMirror_reg, mirror_reg, sizeof(mirror_reg)); - - //////////////////////////////////// - // sensor model ID // - //////////////////////////////////// - strcpy(handle->model_id,"gc4653_MIPI"); - - //////////////////////////////////// - // sensor interface info // - //////////////////////////////////// - //SENSOR_DMSG("[%s] entering function with id %d\n", __FUNCTION__, id); - handle->isp_type = SENSOR_ISP_TYPE; //ISP_SOC; - //handle->data_fmt = SENSOR_DATAFMT; //CUS_DATAFMT_YUV; - handle->sif_bus = SENSOR_IFBUS_TYPE;//CUS_SENIF_BUS_PARL; - handle->data_prec = SENSOR_DATAPREC; //CUS_DATAPRECISION_8; - handle->data_mode = SENSOR_DATAMODE; - handle->bayer_id = SENSOR_BAYERID; //CUS_BAYER_GB; - handle->RGBIR_id = SENSOR_RGBIRID; - handle->orient = SENSOR_ORIT; //CUS_ORIT_M1F1; - //handle->YC_ODER = SENSOR_YCORDER; //CUS_SEN_YCODR_CY; - handle->interface_attr.attr_mipi.mipi_lane_num = SENSOR_MIPI_LANE_NUM; - handle->interface_attr.attr_mipi.mipi_data_format = CUS_SEN_INPUT_FORMAT_RGB; // RGB pattern. - handle->interface_attr.attr_mipi.mipi_yuv_order = 0; //don't care in RGB pattern. - handle->interface_attr.attr_mipi.mipi_hsync_mode = SENSOR_MIPI_HSYNC_MODE; - handle->interface_attr.attr_mipi.mipi_hdr_mode = CUS_HDR_MODE_NONE; - handle->interface_attr.attr_mipi.mipi_hdr_virtual_channel_num = 0; //Short frame - - //////////////////////////////////// - // resolution capability // - //////////////////////////////////// - - handle->video_res_supported.num_res = 1; - handle->video_res_supported.ulcur_res = 0; - handle->video_res_supported.res[0].width = Preview_WIDTH; - handle->video_res_supported.res[0].height = Preview_HEIGHT; - handle->video_res_supported.res[0].max_fps= Preview_MAX_FPS; - handle->video_res_supported.res[0].min_fps= Preview_MIN_FPS; - handle->video_res_supported.res[0].crop_start_x= 0; - handle->video_res_supported.res[0].crop_start_y= 0; - handle->video_res_supported.res[0].nOutputWidth= 2560; - handle->video_res_supported.res[0].nOutputHeight= 1440; - SENSOR_DMSG(handle->video_res_supported.res[0].strResDesc, "2560x1440@30fps"); - - // i2c - - handle->i2c_cfg.mode = SENSOR_I2C_LEGACY; //(CUS_ISP_I2C_MODE) FALSE; - handle->i2c_cfg.fmt = SENSOR_I2C_FMT; //CUS_I2C_FMT_A16D16; - handle->i2c_cfg.address = SENSOR_I2C_ADDR; //0x5a; - handle->i2c_cfg.speed = SENSOR_I2C_SPEED; //320000; - - // mclk - handle->mclk = Preview_MCLK_SPEED; - - //polarity - ///////////////////////////////////////////////////// - handle->pwdn_POLARITY = SENSOR_PWDN_POL; //CUS_CLK_POL_NEG; - handle->reset_POLARITY = SENSOR_RST_POL; //CUS_CLK_POL_NEG; - handle->VSYNC_POLARITY = SENSOR_VSYNC_POL; //CUS_CLK_POL_POS; - handle->HSYNC_POLARITY = SENSOR_HSYNC_POL; //CUS_CLK_POL_POS; - handle->PCLK_POLARITY = SENSOR_PCLK_POL; //CUS_CLK_POL_POS); // use '!' to clear board latch error - ///////////////////////////////////////////////////// - - //////////////////////////////////////////////////// - // AE parameters - //////////////////////////////////////////////////// - handle->ae_gain_delay = 2; - handle->ae_shutter_delay = 2; - - handle->ae_gain_ctrl_num = 1; - handle->ae_shutter_ctrl_num = 1; - - ///calibration - handle->sat_mingain=g_sensor_ae_min_gain; - - - handle->pCus_sensor_release = cus_camsensor_release_handle; - handle->pCus_sensor_init = pCus_init ; - - handle->pCus_sensor_poweron = pCus_poweron ; - handle->pCus_sensor_poweroff = pCus_poweroff; - - // Normal - handle->pCus_sensor_GetSensorID = pCus_GetSensorID ; - - handle->pCus_sensor_GetVideoResNum = pCus_GetVideoResNum; - handle->pCus_sensor_GetVideoRes = pCus_GetVideoRes; - handle->pCus_sensor_GetCurVideoRes = pCus_GetCurVideoRes; - handle->pCus_sensor_SetVideoRes = pCus_SetVideoRes; - - handle->pCus_sensor_GetOrien = pCus_GetOrien ; - handle->pCus_sensor_SetOrien = pCus_SetOrien ; - handle->pCus_sensor_GetFPS = pCus_GetFPS ; - handle->pCus_sensor_SetFPS = pCus_SetFPS ; - //handle->pCus_sensor_GetSensorCap = pCus_GetSensorCap; - handle->pCus_sensor_SetPatternMode = gc4653_SetPatternMode; - /////////////////////////////////////////////////////// - // AE - /////////////////////////////////////////////////////// - // unit: micro seconds - //handle->pCus_sensor_GetAETrigger_mode = pCus_GetAETrigger_mode; - //handle->pCus_sensor_SetAETrigger_mode = pCus_SetAETrigger_mode; - handle->pCus_sensor_AEStatusNotify = pCus_AEStatusNotify; - handle->pCus_sensor_GetAEUSecs = pCus_GetAEUSecs; - handle->pCus_sensor_SetAEUSecs = pCus_SetAEUSecs; - handle->pCus_sensor_GetAEGain = pCus_GetAEGain; - - handle->pCus_sensor_SetAEGain = pCus_SetAEGain; - - handle->pCus_sensor_GetAEMinMaxGain = pCus_GetAEMinMaxGain; - handle->pCus_sensor_GetAEMinMaxUSecs= pCus_GetAEMinMaxUSecs; - - //sensor calibration -// handle->pCus_sensor_SetAEGain_cal = pCus_SetAEGain_cal; - handle->pCus_sensor_setCaliData_gain_linearity=pCus_setCaliData_gain_linearity; - handle->pCus_sensor_GetShutterInfo = gc4653_GetShutterInfo; - params->expo.vts=vts_30fps; - params->expo.fps = 30; - params->expo.line = 100; - params->dirty = false; - params->orient_dirty = false; - return SUCCESS; -} - -int cus_camsensor_release_handle(ms_cus_sensor *handle) { - - return SUCCESS; -} - -SENSOR_DRV_ENTRY_IMPL_END_EX( gc4653, - cus_camsensor_init_handle, - NULL, - NULL, - gc4653_params - ); diff --git a/general/package/sigmastar-osdrv-sensor/src/infinity6b0/sensor/sensor_imx307_mipi.c b/general/package/sigmastar-osdrv-sensor/src/infinity6b0/sensor/sensor_imx307_mipi.c deleted file mode 100644 index adeb0367..00000000 --- a/general/package/sigmastar-osdrv-sensor/src/infinity6b0/sensor/sensor_imx307_mipi.c +++ /dev/null @@ -1,3208 +0,0 @@ -/* Copyright (c) 2018-2019 Sigmastar Technology Corp. - All rights reserved. - - Unless otherwise stipulated in writing, any and all information contained -herein regardless in any format shall remain the sole proprietary of -Sigmastar Technology Corp. and be kept in strict confidence -(Sigmastar Confidential Information) by the recipient. -Any unauthorized act including without limitation unauthorized disclosure, -copying, use, reproduction, sale, distribution, modification, disassembling, -reverse engineering and compiling of the contents of Sigmastar Confidential -Information is unlawful and strictly prohibited. Sigmastar hereby reserves the -rights to any and all damages, losses, costs and expenses resulting therefrom. -*/ - -#ifdef __cplusplus -extern "C" -{ -#endif - -#include -#include -#include - -#ifdef __cplusplus -} -#endif - -SENSOR_DRV_ENTRY_IMPL_BEGIN_EX(IMX307_HDR); - -#ifndef ARRAY_SIZE -#define ARRAY_SIZE CAM_OS_ARRAY_SIZE -#endif - -#define SENSOR_PAD_GROUP_SET CUS_SENSOR_PAD_GROUP_A -#define SENSOR_CHANNEL_NUM (0) -#define SENSOR_CHANNEL_MODE CUS_SENSOR_CHANNEL_MODE_REALTIME_NORMAL -#define SENSOR_CHANNEL_MODE_SONY_DOL CUS_SENSOR_CHANNEL_MODE_RAW_STORE_HDR - -#define SENSOR_CHANNEL_imx307_ISP_CALIBRATION_ENABLE (1) - -//============================================ -//MIPI config begin. -#define SENSOR_MIPI_LANE_NUM (2) -#define SENSOR_MIPI_LANE_NUM_DOL (4) -//#define SENSOR_MIPI_HDR_MODE (0) //0: Non-HDR mode. 1:Sony DOL mode -//MIPI config end. -#define HDR_DOL_10bit (0) -#define HDR_DOL_12bit (1) -//============================================ - -//#define LOGD //(...) - -//c11 extern int usleep(u32 usec); -//int usleep(u32 usec); - -#define R_GAIN_REG 1 -#define G_GAIN_REG 2 -#define B_GAIN_REG 3 - -#undef SENSOR_DBG -#define SENSOR_DBG 0 - -/////////////////////////////////////////////////////////////// -// @@@ // -// @ @@ == S t a r t * H e r e == // -// @@ == S t a r t * H e r e == // -// @@ == S t a r t * H e r e == // -// @@@@ // -// // -// Start Step 1 -- show preview on LCM // -// ���?// -// Fill these #define value and table with correct settings // -// camera can work and show preview on LCM // -// // -/////////////////////////////////////////////////////////////// -#define SENSOR_ISP_TYPE ISP_EXT //ISP_EXT, ISP_SOC -//#define F_number 22 // CFG, demo module -//#define SENSOR_DATAFMT CUS_DATAFMT_BAYER //CUS_DATAFMT_YUV, CUS_DATAFMT_BAYER -#define SENSOR_IFBUS_TYPE CUS_SENIF_BUS_MIPI //CFG //CUS_SENIF_BUS_PARL, CUS_SENIF_BUS_MIPI -#define SENSOR_MIPI_HSYNC_MODE PACKET_HEADER_EDGE1 -#define SENSOR_MIPI_HSYNC_MODE_HDR_DOL PACKET_FOOTER_EDGE -#define SENSOR_DATAPREC CUS_DATAPRECISION_12 //CFG //CUS_DATAPRECISION_8, CUS_DATAPRECISION_10 -#if HDR_DOL_10bit -#define SENSOR_DATAPREC_DOL CUS_DATAPRECISION_10 -#endif -#if HDR_DOL_12bit -#define SENSOR_DATAPREC_DOL CUS_DATAPRECISION_12 -#endif -#define SENSOR_DATAMODE CUS_SEN_10TO12_9098 //CFG -#define SENSOR_BAYERID CUS_BAYER_RG //CUS_BAYER_GR //CFG //CUS_BAYER_GB, CUS_BAYER_GR, CUS_BAYER_BG, CUS_BAYER_RG -#define SENSOR_BAYERID_HDR_DOL CUS_BAYER_RG//CUS_BAYER_GR -#define SENSOR_RGBIRID CUS_RGBIR_NONE -#ifndef SENSOR_ORIT -#define SENSOR_ORIT CUS_ORIT_M0F0 //CUS_ORIT_M0F0, CUS_ORIT_M1F0, CUS_ORIT_M0F1, CUS_ORIT_M1F1, -#endif -//#define SENSOR_YCORDER CUS_SEN_YCODR_YC //CUS_SEN_YCODR_YC, CUS_SEN_YCODR_CY -//#define lane_number 2 -//#define vc0_hs_mode 3 //0: packet header edge 1: line end edge 2: line start edge 3: packet footer edge -//#define long_packet_type_enable 0x00 //UD1~UD8 (user define) -#define SENSOR_MAX_GAIN (2818 * 1024) // max sensor again, a-gain * conversion-gain*d-gain -#define SENSOR_MIN_GAIN (1 * 1024) - -#define SENSOR_GAIN_DELAY_FRAME_COUNT (1) -#define SENSOR_SHUTTER_DELAY_FRAME_COUNT (2) - -#define SENSOR_GAIN_DELAY_FRAME_COUNT_DOL (2) -#define SENSOR_SHUTTER_DELAY_FRAME_COUNT_DOL (2) - -#define Preview_MCLK_SPEED CUS_CMU_CLK_37P125MHZ //CUS_CMU_SCL_CLK_37P125M //CFG //CUS_CMU_CLK_12M, CUS_CMU_CLK_16M, CUS_CMU_CLK_24M, CUS_CMU_CLK_27M -//#define Preview_line_period 30000 ////HTS/PCLK=4455 pixels/148.5MHZ=30usec @MCLK=36MHz -//#define vts_30fps 1125//1346,1616 //for 29.1fps @ MCLK=36MHz -//For MCLK = 36Mhz -//#define Preview_line_period 30556//30580 //(36M/37.125M)*30fps=29.091fps(34.375msec), hts=34.375/1125=30556, -//For MCLK = 37.125Mhz -#define Preview_line_period 29629 // hts=33.333/1125=25629, -#if HDR_DOL_10bit -//For MCLK = 36Mhz -//#define Preview_line_period_HDR_DOL_4LANE 28176//14842//30535//30580 10^9 / (1158 * 2) / 29.091 //(36M/37.125M)*30.02fps=29.11fps(34.352msec), hts=34.375/1220=28176, -//For MCLK = 37.125Mhz -#define Preview_line_period_HDR_DOL_4LANE 27322 //hts=33.333/1220=27322 -#endif -#if HDR_DOL_12bit -//For MCLK = 36Mhz -//#define Preview_line_period_HDR_DOL_4LANE (29684 / 2) //29684//14842//30535//30580 10^9 / (1158 * 2) / 29.091 //(36M/37.125M)*30.02fps=29.11fps(34.352msec), hts=34.352/1158=30556, -//For MCLK = 37.125Mhz -#define Preview_line_period_HDR_DOL_4LANE (28784 / 2) //33.333/1158=28784, -//For MCLK = 36Mhz -//#define Preview_line_period_HDR_DOL_2LANE (29684/*30501*/ / 2) -//For MCLK = 37.125Mhz -#define Preview_line_period_HDR_DOL_2LANE (28784/*30501*/ / 2) -#endif -//#define Line_per_second 32727 -#define vts_30fps 1125//1090 //for 29.091fps @ MCLK=36MHz -#if HDR_DOL_10bit -#define vts_30fps_HDR_DOL_4lane 1220//1125//1090 //for 29.091fps @ MCLK=36MHz //VMAX -#endif -#if HDR_DOL_12bit -#define vts_30fps_HDR_DOL_4lane 1158//1125//1090 //for 29.091fps @ MCLK=36MHz //VMAX -#define vts_30fps_HDR_DOL_2lane 1158 -#endif -#define MAX_DOL_RHS1 ((1158 * 2) - (1097/*BRL HD1080p*/ * 2) - 21) //must 1158 -#define Prv_Max_line_number 1080 //maximum exposure line munber of sensor when preview -#define Preview_WIDTH 1920 //resolution Width when preview -#define Preview_HEIGHT 1080 //resolution Height when preview -#define Preview_HEIGHT_HDR_DOL 1080 //resolution Height when preview -#define Preview_MAX_FPS 30 //fastest preview FPS -#define Preview_MIN_FPS 3 //slowest preview FPS -#define Preview_CROP_START_X 0 //CROP_START_X -#define Preview_CROP_START_Y 0 //CROP_START_Y - -#define SENSOR_I2C_ADDR 0x34 //I2C slave address -#define SENSOR_I2C_SPEED 20000//200000 //300000// 240000 //I2C speed, 60000~320000 -#define SENSOR_I2C_CHANNEL 1 //I2C Channel -#define SENSOR_I2C_PAD_MODE 2 //Pad/Mode Number - -#define SENSOR_I2C_LEGACY I2C_NORMAL_MODE //usally set CUS_I2C_NORMAL_MODE, if use old OVT I2C protocol=> set CUS_I2C_LEGACY_MODE -#define SENSOR_I2C_FMT I2C_FMT_A16D8 //CUS_I2C_FMT_A8D8, CUS_I2C_FMT_A8D16, CUS_I2C_FMT_A16D8, CUS_I2C_FMT_A16D16 - -#define SENSOR_PWDN_POL CUS_CLK_POL_NEG // if PWDN pin High can makes sensor in power down, set CUS_CLK_POL_POS -#define SENSOR_RST_POL CUS_CLK_POL_NEG // if RESET pin High can makes sensor in reset state, set CUS_CLK_POL_NEG - -// VSYNC/HSYNC POL can be found in data sheet timing diagram, -// Notice: the initial setting may contain VSYNC/HSYNC POL inverse settings so that condition is different. - -#define SENSOR_VSYNC_POL CUS_CLK_POL_NEG // if VSYNC pin High and data bus have data, set CUS_CLK_POL_POS -#define SENSOR_HSYNC_POL CUS_CLK_POL_NEG // if HSYNC pin High and data bus have data, set CUS_CLK_POL_POS -#define SENSOR_PCLK_POL CUS_CLK_POL_NEG // depend on sensor setting, sometimes need to try CUS_CLK_POL_POS or CUS_CLK_POL_NEG -//static int drv_Fnumber = 22; - -#if SENSOR_DBG == 1 -//#define SENSOR_DMSG(args...) LOGD(args) -//#define SENSOR_DMSG(args...) LOGE(args) -//#define SENSOR_DMSG(args...) printf(args) -#elif SENSOR_DBG == 0 -//#define SENSOR_DMSG(args...) -#endif -#undef SENSOR_NAME -#define SENSOR_NAME IMX307 - -#if defined (SENSOR_MODULE_VERSION) -#define TO_STR_NATIVE(e) #e -#define TO_STR_PROXY(m, e) m(e) -#define MACRO_TO_STRING(e) TO_STR_PROXY(TO_STR_NATIVE, e) -static char *sensor_module_version = MACRO_TO_STRING(SENSOR_MODULE_VERSION); -module_param(sensor_module_version, charp, S_IRUGO); -#endif - -//#define SensorReg_Read(_reg,_data) (handle->i2c_bus->i2c_rx(handle->i2c_bus, &(handle->i2c_cfg),_reg,_data)) -//#define SensorReg_Write(_reg,_data) (handle->i2c_bus->i2c_tx(handle->i2c_bus, &(handle->i2c_cfg),_reg,_data)) -//#define SensorRegArrayW(_reg,_len) (handle->i2c_bus->i2c_array_tx(handle->i2c_bus, &(handle->i2c_cfg),(_reg),(_len))) -//#define SensorRegArrayR(_reg,_len) (handle->i2c_bus->i2c_array_rx(handle->i2c_bus, &(handle->i2c_cfg),(_reg),(_len))) - -static int cus_camsensor_release_handle(ms_cus_sensor *handle); -static int pCus_SetAEGain(ms_cus_sensor *handle, u32 gain); -static int pCus_SetAEUSecs(ms_cus_sensor *handle, u32 us); -static int pCus_SetFPS(ms_cus_sensor *handle, u32 fps); -static int pCus_SetOrien(ms_cus_sensor *handle, CUS_CAMSENSOR_ORIT orit); -static CUS_MCLK_FREQ UseParaMclk(const char *mclk); -static int pCus_SetAEUSecsHDR_DOL_SEF1(ms_cus_sensor *handle, u32 us); -static int pCus_SetAEUSecsHDR_DOL_LEF(ms_cus_sensor *handle, u32 us); - -typedef struct { - struct { - u16 pre_div0; - u16 div124; - u16 div_cnt7b; - u16 sdiv0; - u16 mipi_div0; - u16 r_divp; - u16 sdiv1; - u16 r_seld5; - u16 r_sclk_dac; - u16 sys_sel; - u16 pdac_sel; - u16 adac_sel; - u16 pre_div_sp; - u16 r_div_sp; - u16 div_cnt5b; - u16 sdiv_sp; - u16 div12_sp; - u16 mipi_lane_sel; - u16 div_dac; - } clk_tree; - struct { - bool bVideoMode; - u16 res_idx; - // bool binning; - // bool scaling; - CUS_CAMSENSOR_ORIT orit; - } res; - struct { - float sclk; - u32 hts; - u32 vts; - u32 ho; - u32 xinc; - u32 line_freq; - u32 us_per_line; - u32 final_us; - u32 final_gain; - u32 back_pv_us; - u32 fps; - u32 preview_fps; - u32 expo_lines; - u32 expo_lef_us; - u32 expo_sef_us; - } expo; - - int sen_init; - int still_min_fps; - int video_min_fps; - u32 max_rhs1; - u32 lef_shs2; - u32 skip_cnt; - bool dirty; - bool change; - I2C_ARRAY tVts_reg[3]; - I2C_ARRAY tGain_reg[3]; - I2C_ARRAY tExpo_reg[3]; - I2C_ARRAY tShs2_reg[3]; - I2C_ARRAY tRhs1_reg[3]; - I2C_ARRAY tGain_hdr_dol_lef_reg[1]; - I2C_ARRAY tGain_hdr_dol_sef_reg[1]; - bool orien_dirty; -} imx307_params; -// set sensor ID address and data, - -const static I2C_ARRAY Sensor_id_table[] = -{ - {0x3004, 0x10}, // {address of ID, ID }, - {0x3009, 0x01}, // {address of ID, ID }, -}; - -const static I2C_ARRAY Sensor_init_table_4lane[] = -{ - {0x3002, 0x01}, //Master mode stop - {0xffff, 0x14},//delay - {0x3000, 0x01}, // standby - {0xffff, 0x14},//delay - {0x3005, 0x01}, - {0x3007, 0x00},//mirror/flip - {0x3009, 0x02},//FRSEL - // {0x300A, 0xF0}, - // {0x300F, 0x00}, - // {0x3010, 0x21}, - {0x3011, 0x0A}, - {0x3012, 0x64}, - {0x3013, 0x00}, - //{0x3016, 0x08},//yc modify - {0x3018, 0x65},//VMAX - {0x3019, 0x04}, - {0x301a, 0x00}, - {0x301c, 0x30},//0x1167 HMAX,for 25fps - {0x301d, 0x11}, - - {0x3046, 0x01}, - //{0x304B, 0x0a},//arbitary value - {0x305C, 0x18},//INCK - {0x305D, 0x03}, - {0x305E, 0x20}, - {0x305F, 0x01}, - - //{0x3070, 0x02}, - // {0x3071, 0x11}, - // {0x309B, 0x10}, - // {0x309C, 0x22}, - {0x309E, 0x4A}, - {0x309F, 0x4A}, - // {0x30A0, 0x02},//new add - // {0x30A2, 0x02}, - // {0x30A6, 0x20}, - // {0x30A8, 0x20}, - // {0x30AA, 0x20}, - // {0x30AC, 0x20}, - // {0x30B0, 0x43}, - - // {0x3119, 0x9E}, - {0x311C, 0x0E}, - // {0x311E, 0x08}, - {0x3128, 0x04}, - {0x3129, 0x00}, - {0x313B, 0x41}, - // {0x313D, 0x83}, - // {0x3150, 0x02}, - {0x315E, 0x1A},//INCKSEL5 - {0x3164, 0x1A},//INCKSEL6 - {0x317C, 0x00},//ADBIT2 - {0x317E, 0x00}, - {0x31EC, 0x0E}, - - - {0x3405, 0x20}, - {0x3407, 0x03}, // 4 lane for phy - // {0x3414, 0x0A}, - {0x3418, 0x49},//Y-out - {0x3419, 0x04}, - // {0x342C, 0x47}, - // {0x342D, 0x00}, - // {0x3430, 0x0F}, - // {0x3431, 0x00}, - {0x3441, 0x0C}, - {0x3442, 0x0C}, - {0x3443, 0x03}, // 4 lane - {0x3444, 0x20}, - {0x3445, 0x25}, - {0x3446, 0x47}, - {0x3447, 0x00}, - {0x3448, 0x1F}, - {0x3449, 0x00}, - {0x344A, 0x17}, - {0x344B, 0x00}, - {0x344C, 0x0F}, - {0x344D, 0x00}, - {0x344E, 0x17}, - {0x344F, 0x00}, - {0x3450, 0x47}, - {0x3451, 0x00}, - {0x3452, 0x0F}, - {0x3453, 0x00}, - {0x3454, 0x0F}, - {0x3455, 0x00}, - {0x3472, 0x9c},//x-out size - {0x3473, 0x07}, - {0x3480, 0x49},//0x9c - - {0x3000, 0x00}, // operating - //{0xffff, 0x14}, - - {0x3002, 0x00}, //Master mode start -}; - -const static I2C_ARRAY Sensor_init_table_2lane[] = -{ - - {0x3002, 0x00}, //Master mode stop - {0xffff, 0x14},//delay - {0x3000, 0x01}, // standby - {0xffff, 0x14},//delay - {0x3005, 0x01}, - // {0x3007, 0x00},//mirror/flip - {0x3009, 0x02},//FRSEL - // {0x300A, 0xF0}, - // {0x300F, 0x00}, - // {0x3010, 0x21}, - {0x3011, 0x0A}, - // {0x3012, 0x64}, - // {0x3013, 0x00}, - {0x3016, 0x08},//yc modify - {0x3018, 0x65},//VMAX - {0x3019, 0x04}, - {0x301c, 0x30},//0x1167 HMAX,for 25fps - {0x301d, 0x11}, - - //{0x3046, 0x01}, - //{0x304B, 0x0a},//arbitary value - {0x305C, 0x18},//INCK - {0x305D, 0x03}, - {0x305E, 0x20}, - //{0x305F, 0x01}, - - //{0x3070, 0x02}, - // {0x3071, 0x11}, - // {0x309B, 0x10}, - // {0x309C, 0x22}, - {0x309E, 0x4A}, - {0x309F, 0x4A}, - // {0x30A0, 0x02},//new add - // {0x30A2, 0x02}, - // {0x30A6, 0x20}, - // {0x30A8, 0x20}, - // {0x30AA, 0x20}, - // {0x30AC, 0x20}, - // {0x30B0, 0x43}, - - // {0x3119, 0x9E}, - {0x311C, 0x0E}, - // {0x311E, 0x08}, - {0x3128, 0x04}, - {0x3129, 0x00}, - {0x313B, 0x41}, - // {0x313D, 0x83}, - // {0x3150, 0x02}, - {0x315E, 0x1A},//INCKSEL5 - {0x3164, 0x1A},//INCKSEL6 - {0x317C, 0x00},//ADBIT2 - {0x317E, 0x00}, - {0x31EC, 0x0E}, - - - {0x3405, 0x10}, - {0x3407, 0x01}, // 2 lane for phy - // {0x3414, 0x0A}, - {0x3418, 0x49},//Y-out - {0x3419, 0x04}, - // {0x342C, 0x47}, - // {0x342D, 0x00}, - // {0x3430, 0x0F}, - // {0x3431, 0x00}, - // {0x3441, 0x0C}, - // {0x3442, 0x0C}, - {0x3443, 0x01}, // 2 lane - {0x3444, 0x20}, - {0x3445, 0x25}, - {0x3446, 0x57}, - // {0x3447, 0x00}, - {0x3448, 0x37}, - // {0x3449, 0x00}, - {0x344A, 0x1F}, - // {0x344B, 0x00}, - {0x344C, 0x1F}, - // {0x344D, 0x00}, - {0x344E, 0x1f}, - // {0x344F, 0x00}, - {0x3450, 0x77}, - // {0x3451, 0x00}, - {0x3452, 0x1F}, - // {0x3453, 0x00}, - {0x3454, 0x17}, - // {0x3472, 0x9c},//x-out size - // {0x3473, 0x07}, - {0x3480, 0x49},//0x9c - - {0x3000, 0x00}, // operating - {0xffff, 0x14}, - - - // {0x3002, 0x00}, //Master mode start -}; - -const static I2C_ARRAY Sensor_init_table_HDR_DOL_4lane[] = -{ -#if HDR_DOL_10bit - //DOL 2frame 1080p 10bit - {0x3002, 0x01}, - {0xffff, 0x14}, - {0x3000, 0x01}, - {0xffff, 0x14}, - - {0x3005, 0x00}, - //{0x3007, 0x00}, //WINMODE - {0x3007, 0x40}, - - {0x3009, 0x01}, - {0x300A, 0x3C}, - {0x300C, 0x11}, - {0x3011, 0x0A}, - - - //{0x3018, 0x65}, //VMAX - //{0x3019, 0x04}, - {0x3018, 0xC4}, - {0x3019, 0x04}, - - //{0x301c, 0x98}, //HMAX - //{0x301d, 0x08}, - {0x301c, 0xEC}, - {0x301d, 0x07}, - - {0x3020, 0x02}, // SHS1 - {0x3021, 0x00}, // SHS1 - {0x3022, 0x00}, // SHS1 - - {0x3024, 0x53}, // SHS2 - {0x3025, 0x04}, // SHS2 - {0x3026, 0x00}, // SHS2 - - {0x3028, 0x00}, // SHS3 - {0x3029, 0x00}, // SHS3 - {0x302A, 0x00}, // SHS3 - - {0x3030, 0xe1},//RHS1 - {0x3031, 0x00}, - {0x3032, 0x00}, - - {0x3034, 0x00},//RHS2 - {0x3035, 0x00}, - {0x3036, 0x00}, - - {0x303A, 0x08}, // WIN - {0x303C, 0x04}, // WIN - {0x303E, 0x41}, // WIN - {0x303F, 0x04}, // WIN - - {0x3045, 0x05}, - {0x3046, 0x00}, - {0x304B, 0x0A}, - {0x305C, 0x18}, - {0x305D, 0x03}, - {0x305E, 0x20}, - {0x305F, 0x01}, - {0x309E, 0x4A}, - {0x309F, 0x4A}, - - {0x3106, 0x11}, - {0x311C, 0x0E}, - {0x3128, 0x04}, - {0x3129, 0x1D}, - {0x313B, 0x41}, - {0x315E, 0x1A}, - {0x3164, 0x1A}, - {0x317C, 0x12}, - {0x31EC, 0x37}, - - - {0x3405, 0x10}, - {0x3407, 0x03}, - - //{0x3414, 0x0A}, //opb_size_v - {0x3414, 0x00}, - - {0x3415, 0x00}, - - //{0x3418, 0x9C}, //y_out_size - //{0x3419, 0x08}, - {0x3418, 0x7A}, - {0x3419, 0x09}, - - - {0x3441, 0x0A}, - {0x3442, 0x0A}, - {0x3443, 0x03}, - {0x3444, 0x20}, - {0x3445, 0x25}, - {0x3446, 0x57}, - {0x3447, 0x00}, - {0x3448, 0x37}, - {0x3449, 0x00}, - {0x344A, 0x1F}, - {0x344B, 0x00}, - {0x344C, 0x1F}, - {0x344D, 0x00}, - {0x344E, 0x1F}, - {0x344F, 0x00}, - {0x3450, 0x77}, - {0x3451, 0x00}, - {0x3452, 0x1F}, - {0x3453, 0x00}, - {0x3454, 0x17}, - {0x3455, 0x00}, - {0x3472, 0xA0}, - {0x3473, 0x07}, - {0x347B, 0x23}, - {0x3480, 0x49}, - - {0x3000, 0x00}, // operating - //{0xffff, 0x14}, - - {0x3002, 0x00}, //Master mode start -#endif - -#if HDR_DOL_12bit - //DOL 2frame 1080p 12bit - {0x3002, 0x01}, - {0xffff, 0x14}, - {0x3000, 0x01}, - {0xffff, 0x14}, - - {0x3005, 0x01}, - //{0x3007, 0x00}, //WINMODE - {0x3007, 0x40}, - - {0x3009, 0x01}, - {0x300A, 0xF0}, - {0x300C, 0x11}, - {0x3011, 0x0A}, - - - //{0x3018, 0x65}, //VMAX - //{0x3019, 0x04}, - {0x3018, 0x86}, - {0x3019, 0x04}, - - //{0x301c, 0x98}, //HMAX - //{0x301d, 0x08}, - {0x301c, 0x58}, - {0x301d, 0x08}, - - {0x3020, 0x02}, // SHS1 - {0x3021, 0x00}, // SHS1 - {0x3022, 0x00}, // SHS1 - - {0x3024, 0x73}, // SHS2 - {0x3025, 0x04}, // SHS2 - {0x3026, 0x00}, // SHS2 - - {0x3028, 0x00}, // SHS3 - {0x3029, 0x00}, // SHS3 - {0x302A, 0x00}, // SHS3 - - {0x3030, 0x65},//RHS1 - {0x3031, 0x00}, - {0x3032, 0x00}, - - {0x3034, 0x00},//RHS2 - {0x3035, 0x00}, - {0x3036, 0x00}, - - {0x303A, 0x08}, // WIN - {0x303C, 0x04}, // WIN - {0x303E, 0x41}, // WIN - {0x303F, 0x04}, // WIN - - {0x3045, 0x05}, - {0x3046, 0x01}, - {0x304B, 0x0A}, - {0x305C, 0x18}, - {0x305D, 0x03}, - {0x305E, 0x20}, - {0x305F, 0x01}, - {0x309E, 0x4A}, - {0x309F, 0x4A}, - - {0x3106, 0x11}, - {0x311C, 0x0E}, - {0x3128, 0x04}, - {0x3129, 0x00}, - {0x313B, 0x41}, - {0x315E, 0x1A}, - {0x3164, 0x1A}, - {0x317C, 0x00}, - {0x31EC, 0x0E}, - - {0x3204, 0x4A}, - {0x320A, 0x22}, - - {0x3344, 0x38}, - - {0x3405, 0x10}, - {0x3407, 0x03}, - - //{0x3414, 0x0A}, //opb_size_v - {0x3414, 0x00}, - - {0x3415, 0x00}, - - //{0x3418, 0x9C}, //y_out_size - //{0x3419, 0x08}, - {0x3418, 0x7A}, - {0x3419, 0x09}, - - {0x3441, 0x0C}, - {0x3442, 0x0C}, - {0x3443, 0x03}, - {0x3444, 0x20}, - {0x3445, 0x25}, - {0x3446, 0x57}, - {0x3447, 0x00}, - {0x3448, 0x37}, - {0x3449, 0x00}, - {0x344A, 0x1F}, - {0x344B, 0x00}, - {0x344C, 0x1F}, - {0x344D, 0x00}, - {0x344E, 0x1F}, - {0x344F, 0x00}, - {0x3450, 0x77}, - {0x3451, 0x00}, - {0x3452, 0x1F}, - {0x3453, 0x00}, - {0x3454, 0x17}, - {0x3455, 0x00}, - {0x3472, 0xA0}, - {0x3473, 0x07}, - {0x347B, 0x23}, - {0x3480, 0x49}, - - {0x3000, 0x00}, // operating - //{0xffff, 0x14}, - - {0x3002, 0x00}, //Master mode start -#endif -}; - - -const static I2C_ARRAY Sensor_init_table_HDR_DOL_2lane[] = -{ - {0x3002,0x01}, - {0xffff, 0x14}, //test - {0x3000, 0x01}, //test - {0xffff, 0x14}, //test - {0x3005,0x01}, - - {0x3007,0x00}, - - {0x3009,0x01}, - {0x300A,0xF0}, - {0x300C,0x11}, - {0x3011,0x0A}, - - - {0x3018,0x86}, - - {0x3019,0x04}, - {0x301C,0x58}, - {0x301D,0x08}, - {0x3020,0x02}, // SHS1 - {0x3021,0x00}, // SHS1 - - {0x3024,0xC9}, // SHS2 - {0x3025,0x06}, // SHS2 - //{0x3026,0x06}, // SHS2 - {0x3030,0x0B}, - {0x3031,0x00}, - //{0x3032,0x00}, - {0x3045,0x05}, - {0x3046,0x01}, - //{0x3048,0x00}, - //{0x3049,0x00}, - {0x304B,0x0A}, - {0x305C,0x18}, - {0x305D,0x03}, - {0x305E,0x20}, - {0x305F,0x01}, - {0x309E,0x4A}, - {0x309F,0x4A}, - {0x3106,0x11}, - {0x311C,0x0E}, - {0x311D,0x08}, - - - {0x3128,0x04}, - {0x3129,0x00}, - - - {0x313B,0x41}, - {0x315E,0x1A}, - {0x3164,0x1A}, - {0x317C,0x00}, - {0x31EC,0x0E}, - {0x3405,0x00}, - {0x3407,0x01}, - {0x3414,0x0A}, - {0x3415,0x00}, - //{0x3418,0x9C}, - //{0x3419,0x08}, - {0x3418,0x7A}, - {0x3419,0x09}, - {0x3441,0x0C}, - {0x3442,0x0C}, - {0x3443,0x01}, - {0x3444,0x20}, - - {0x3445,0x25}, - - {0x3446,0x77}, - {0x3447,0x00}, - {0x3448,0x67}, - {0x3449,0x00}, - {0x344A,0x47}, - - {0x344B,0x00}, - {0x344C,0x37}, - {0x344D,0x00}, - {0x344E,0x3F}, - {0x344F,0x00}, - {0x3450,0xFF}, - {0x3451,0x00}, - {0x3452,0x3F}, - {0x3453,0x00}, - {0x3454,0x37}, - {0x3455,0x00}, - - - - - - {0x3472,0xA0}, - {0x3473,0x07}, - {0x347B,0x23}, - - {0x3480,0x49}, - - {0x3000, 0x00}, //test - - {0x3002,0x00}, - -}; - -const static I2C_ARRAY TriggerStartTbl[] = { - {0x3002,0x00},//Master mode start -}; - -static I2C_ARRAY PatternTbl[] = { - {0x308c,0x20}, //colorbar pattern , bit 0 to enable -}; - -const static I2C_ARRAY gain_HDR_DOL_LEF_reg[] = -{ - {0x3014, 0x00}, -}; - -const static I2C_ARRAY gain_HDR_DOL_SEF1_reg[] = -{ - {0x30F2, 0x00}, -}; - -const static I2C_ARRAY expo_SHS2_reg[] = -{ -#if 1 //decreasing exposure ratio version. - {0x3026, 0x00}, - {0x3025, 0x08}, - {0x3024, 0x49}, -#else - {0x3026, 0x00}, - {0x3025, 0x07}, - {0x3024, 0xc9}, -#endif -}; - -const I2C_ARRAY expo_RHS1_reg[] = -{ -#if 1 //decreasing exposure ratio version. - {0x3032, 0x00}, - {0x3031, 0x00}, - {0x3030, 0x65}, /*101*/ -#else - {0x3032, 0x00}, - {0x3031, 0x00}, - {0x3030, 0x0b}, -#endif -}; - -///////////////////////////////////////////////////////////////// -// @@@@@@ // -// @@ // -// @@@ // -// @ @@ // -// @@@@ // -// // -// Step 3 -- complete camera features // -// // -// // -// camera set EV, MWB, orientation, contrast, sharpness // -// , saturation, and Denoise can work correctly. // -// // -///////////////////////////////////////////////////////////////// - - -const static I2C_ARRAY mirr_flip_table[] = -{ - {0x3007, 0x00},//M0F0 - {0x3007, 0x02},//M1F0 - {0x3007, 0x01},//M0F1 - {0x3007, 0x03},//M1F1 - -}; - -typedef struct { - short reg; - char startbit; - char stopbit; -} COLLECT_REG_SET; - - - -const static I2C_ARRAY gain_reg[] = { - //{0x350A, 0x00},//bit0, high bit - {0x3014, 0x00},//low bit - {0x3009, 0x02},//hcg mode,bit 4 - {0x3016, 0x08},// - -}; -#if 0 -static I2C_ARRAY frame_drop_reg[] = { - //{0x350A, 0x00},//bit0, high bit - {0x4202, 0x01}, //frame mask - {0x3000, 0x23}, //timing reset - {0x3000, 0xa0}, //low bit - -}; -#endif -//static int g_sensor_ae_min_gain = 1024; -static CUS_GAIN_GAP_ARRAY gain_gap_compensate[16] = { //compensate gain gap - {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} -}; - -const static I2C_ARRAY expo_reg[] = { - - {0x3022, 0x00}, - {0x3021, 0x00}, - {0x3020, 0x00}, -}; - -const static I2C_ARRAY vts_reg[] = { - {0x301a, 0x00}, - {0x3019, 0x04}, - {0x3018, 0xC4}, - -}; - -#if 0 -static CUS_INT_TASK_ORDER def_order = { - .RunLength = 9, - .Orders = { - CUS_INT_TASK_AE|CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_AWB|CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_AE|CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_AWB|CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_AE|CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_AWB|CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - }, -}; -#endif - -/////////// function definition /////////////////// - -#define SensorReg_Read(_reg,_data) (handle->i2c_bus->i2c_rx(handle->i2c_bus, &(handle->i2c_cfg),_reg,_data)) -#define SensorReg_Write(_reg,_data) (handle->i2c_bus->i2c_tx(handle->i2c_bus, &(handle->i2c_cfg),_reg,_data)) -#define SensorRegArrayW(_reg,_len) (handle->i2c_bus->i2c_array_tx(handle->i2c_bus, &(handle->i2c_cfg),(_reg),(_len))) -#define SensorRegArrayR(_reg,_len) (handle->i2c_bus->i2c_array_rx(handle->i2c_bus, &(handle->i2c_cfg),(_reg),(_len))) - -/////////////////// sensor hardware dependent ////////////// -#if 0 -static int ISP_config_io(ms_cus_sensor *handle) { -#if 0 - ISensorIfAPI *sensor_if = handle->sensor_if_api; - - SENSOR_DMSG("[%s]", __FUNCTION__); - - sensor_if->HsyncPol(handle, handle->HSYNC_POLARITY); - sensor_if->VsyncPol(handle, handle->VSYNC_POLARITY); - sensor_if->ClkPol(handle, handle->PCLK_POLARITY); - sensor_if->BayerFmt(handle, handle->bayer_id); - sensor_if->DataBus(handle, handle->sif_bus); - - sensor_if->DataPrecision(handle, handle->data_prec); - sensor_if->FmtConv(handle, handle->data_mode); -#endif - return SUCCESS; -} -#endif - -static int pCus_poweron(ms_cus_sensor *handle, u32 idx) -{ - ISensorIfAPI *sensor_if = handle->sensor_if_api; - SENSOR_DMSG("[%s] ", __FUNCTION__); - - //Sensor power on sequence - sensor_if->PowerOff(idx, !handle->pwdn_POLARITY); - sensor_if->Reset(idx, !handle->reset_POLARITY); - sensor_if->SetIOPad(idx, handle->sif_bus, handle->interface_attr.attr_mipi.mipi_lane_num); - sensor_if->SetCSI_Clk(idx, CUS_CSI_CLK_216M); - sensor_if->SetCSI_Lane(idx, handle->interface_attr.attr_mipi.mipi_lane_num, 1); - sensor_if->SetCSI_LongPacketType(idx, 0, 0x1C00, 0); - - if (handle->interface_attr.attr_mipi.mipi_hdr_mode == CUS_HDR_MODE_SONY_DOL) { - sensor_if->SetCSI_hdr_mode(idx, handle->interface_attr.attr_mipi.mipi_hdr_mode, 1); - } - - sensor_if->Reset(idx, handle->reset_POLARITY ); - sensor_if->MCLK(idx, 1, handle->mclk); - SENSOR_UDELAY(20); //TLOW - - sensor_if->PowerOff(idx, handle->pwdn_POLARITY); - SENSOR_UDELAY(20); - sensor_if->PowerOff(idx, !handle->pwdn_POLARITY); - SENSOR_UDELAY(20); - - sensor_if->Reset(idx, !handle->reset_POLARITY ); - SENSOR_UDELAY(20); //TXCE - - return SUCCESS; -} - -static int pCus_poweroff(ms_cus_sensor *handle, u32 idx) -{ - // power/reset low - ISensorIfAPI *sensor_if = handle->sensor_if_api; - - SENSOR_DMSG("[%s] reset low\n", __FUNCTION__); - sensor_if->Reset(idx, handle->reset_POLARITY); - sensor_if->MCLK(idx, 0, handle->mclk); - - sensor_if->SetCSI_Clk(idx, CUS_CSI_CLK_DISABLE); - if (handle->interface_attr.attr_mipi.mipi_hdr_mode == CUS_HDR_MODE_SONY_DOL) { - sensor_if->SetCSI_hdr_mode(idx, handle->interface_attr.attr_mipi.mipi_hdr_mode, 0); - } - handle->orient = SENSOR_ORIT; -#if 0 -#if (SENSOR_MIPI_LANE_NUM == 2) - sensor_if->SetCSI_Lane(SENSOR_PAD_GROUP_SET, 2, 0); -#endif -#if (SENSOR_MIPI_LANE_NUM == 4) - sensor_if->SetCSI_Lane(SENSOR_PAD_GROUP_SET, 4, 0); -#endif -#endif - return SUCCESS; -} - -/////////////////// image function ///////////////////////// -static int pCus_CheckSonyProductID(ms_cus_sensor *handle) -{ - u16 sen_data; - - /* Read Product ID */ - if (SensorReg_Read(0x31DC, (void*)&sen_data)) { - return FAIL; - } - - if ((sen_data & 0x0006) != 0x4) { - SENSOR_EMSG("[***ERROR***]Check Product ID Fail: 0x%x\n", sen_data); - return FAIL; - } - - return SUCCESS; -} -//Get and check sensor ID -//if i2c error or sensor id does not match then return FAIL -static int pCus_GetSensorID(ms_cus_sensor *handle, u32 *id) -{ - int i,n; - int table_length= ARRAY_SIZE(Sensor_id_table); - I2C_ARRAY id_from_sensor[ARRAY_SIZE(Sensor_id_table)]; - - for(n=0;n8) table_length=8; - - SENSOR_DMSG("\n\n[%s]", __FUNCTION__); - - for(n=0;n<4;++n) //retry , until I2C success - { - if(n>2) return FAIL; - - if(/* SensorRegArrayR((I2C_ARRAY*)id_from_sensor,table_length) == */SUCCESS) //read sensor ID from I2C - break; - else - SENSOR_MSLEEP(1); - } - - //convert sensor id to u32 format - for(i=0;iprivate_data; - int i,cnt=0; - - if (pCus_CheckSonyProductID(handle)) { - return FAIL; - } - - //UartSendTrace("IMX307 Sensor_init_table_4lane\n"); - for(i=0;i< ARRAY_SIZE(Sensor_init_table_4lane);i++) - { - if(Sensor_init_table_4lane[i].reg==0xffff) - { - SENSOR_MSLEEP(Sensor_init_table_4lane[i].data); - } - else - { - cnt = 0; - while(SensorReg_Write(Sensor_init_table_4lane[i].reg,Sensor_init_table_4lane[i].data) != SUCCESS) - { - cnt++; - //printf("Sensor_init_table_4lane -> Retry %d...\n",cnt); - if(cnt>=10) - { - //printf("[%s:%d]Sensor init fail!!\n", __FUNCTION__, __LINE__); - return FAIL; - } - //usleep(10*1000); - } - //SensorReg_Read( Sensor_init_table_4lane[i].reg, &sen_data ); - //UartSendTrace("IMX307 reg: 0x%x, data: 0x%x, read: 0x%x.\n",Sensor_init_table_4lane[i].reg, Sensor_init_table_4lane[i].data, sen_data); - } - } - - params->tVts_reg[0].data = (params->expo.vts >> 16) & 0x0003; - params->tVts_reg[1].data = (params->expo.vts >> 8) & 0x00ff; - params->tVts_reg[2].data = (params->expo.vts >> 0) & 0x00ff; - pCus_SetOrien(handle, handle->orient); - return SUCCESS; -} -#endif -#if (SENSOR_MIPI_LANE_NUM_DOL == 4) -static int pCus_init_mipi4lane_HDR_DOL(ms_cus_sensor *handle) -{ - imx307_params *params = (imx307_params *)handle->private_data; - //SENSOR_DMSG("\n\n[%s]", __FUNCTION__); - int i,cnt=0; - //ISensorIfAPI *sensor_if = handle->sensor_if_api; - // short sen_data; - //sensor_if->PCLK( CUS_SNR_PCLK_MIPI_TOP );//sensor_if->PCLK(NULL,CUS_PCLK_MIPI_TOP); - - if (pCus_CheckSonyProductID(handle)) { - return FAIL; - } - - //UartSendTrace("IMX307 Sensor_init_table_HDR_DOL_4lane\n"); - for(i=0;i< ARRAY_SIZE(Sensor_init_table_HDR_DOL_4lane);i++) - { - if(Sensor_init_table_HDR_DOL_4lane[i].reg==0xffff) - { - SENSOR_MSLEEP(Sensor_init_table_HDR_DOL_4lane[i].data); - } - else - { - cnt = 0; - while(SensorReg_Write(Sensor_init_table_HDR_DOL_4lane[i].reg,Sensor_init_table_HDR_DOL_4lane[i].data) != SUCCESS) - { - cnt++; - //UartSendTrace("Sensor_init_table_HDR_DOL_4lane -> Retry %d...\n",cnt); - if(cnt>=10) - { - //UartSendTrace("[%s:%d]Sensor init fail!!\n", __FUNCTION__, __LINE__); - return FAIL; - } - //usleep(10*1000); - } - //SensorReg_Read( Sensor_init_table_HDR_DOL_4lane[i].reg, &sen_data ); - //UartSendTrace("IMX307 reg: 0x%x, data: 0x%x, read: 0x%x.\n",Sensor_init_table_HDR_DOL_4lane[i].reg, Sensor_init_table_HDR_DOL_4lane[i].data, sen_data); - } - } - - params->tVts_reg[0].data = (params->expo.vts >> 16) & 0x0003; - params->tVts_reg[1].data = (params->expo.vts >> 8) & 0x00ff; - params->tVts_reg[2].data = (params->expo.vts >> 0) & 0x00ff; - - //UartSendTrace("[%s:%d]Sensor init success!!\n", __FUNCTION__, __LINE__); - return SUCCESS; -} -#endif - -#if 1//(SENSOR_MIPI_LANE_NUM_DOL == 2) -static int pCus_init_mipi2lane_HDR_DOL(ms_cus_sensor *handle) -{ - imx307_params *params = (imx307_params *)handle->private_data; - //SENSOR_DMSG("\n\n[%s]", __FUNCTION__); - int i,cnt=0; - //ISensorIfAPI *sensor_if = handle->sensor_if_api; - // short sen_data; - //sensor_if->PCLK( CUS_SNR_PCLK_MIPI_TOP );//sensor_if->PCLK(NULL,CUS_PCLK_MIPI_TOP); - - if (pCus_CheckSonyProductID(handle)) { - return FAIL; - } - - //UartSendTrace("IMX307 Sensor_init_table_HDR_DOL_2lane\n"); - for(i=0;i< ARRAY_SIZE(Sensor_init_table_HDR_DOL_2lane);i++) - { - if(Sensor_init_table_HDR_DOL_2lane[i].reg==0xffff) - { - SENSOR_MSLEEP(Sensor_init_table_HDR_DOL_2lane[i].data); - } - else - { - cnt = 0; - while(SensorReg_Write(Sensor_init_table_HDR_DOL_2lane[i].reg,Sensor_init_table_HDR_DOL_2lane[i].data) != SUCCESS) - { - cnt++; - //UartSendTrace("Sensor_init_table_HDR_DOL_2lane -> Retry %d...\n",cnt); - if(cnt>=10) - { - //UartSendTrace("[%s:%d]Sensor init fail!!\n", __FUNCTION__, __LINE__); - return FAIL; - } - //usleep(10*1000); - } - //SensorReg_Read( Sensor_init_table_HDR_DOL_2lane[i].reg, &sen_data ); - //UartSendTrace("IMX307 reg: 0x%x, data: 0x%x, read: 0x%x.\n",Sensor_init_table_HDR_DOL_2lane[i].reg, Sensor_init_table_HDR_DOL_2lane[i].data, sen_data); - } - } - - params->tVts_reg[0].data = (params->expo.vts >> 16) & 0x0003; - params->tVts_reg[1].data = (params->expo.vts >> 8) & 0x00ff; - params->tVts_reg[2].data = (params->expo.vts >> 0) & 0x00ff; - - //UartSendTrace("[%s:%d]Sensor init success!!\n", __FUNCTION__, __LINE__); - return SUCCESS; -} -#endif - -#if 1//(SENSOR_MIPI_LANE_NUM == 2) -static int pCus_init_mipi2lane_linear(ms_cus_sensor *handle) -{ - int i,cnt=0; - SENSOR_DMSG("\n\n[%s]", __FUNCTION__); - - //ISensorIfAPI *sensor_if = handle->sensor_if_api; - //short sen_data; - //sensor_if->PCLK( CUS_SNR_PCLK_MIPI_TOP );//sensor_if->PCLK(NULL,CUS_PCLK_MIPI_TOP); - - if (pCus_CheckSonyProductID(handle)) { - return FAIL; - } - - //UartSendTrace("IMX307 Sensor_init_table_2lane\n"); - for(i=0;i< ARRAY_SIZE(Sensor_init_table_2lane);i++) - { - if(Sensor_init_table_2lane[i].reg==0xffff) - { - SENSOR_MSLEEP_(Sensor_init_table_2lane[i].data); - } - else - { - cnt = 0; - while(SensorReg_Write(Sensor_init_table_2lane[i].reg,Sensor_init_table_2lane[i].data) != SUCCESS) - { - cnt++; - //printf("Sensor_init_table_2lane -> Retry %d...\n",cnt); - if(cnt>=10) - { - //printf("[%s:%d]Sensor init fail!!\n", __FUNCTION__, __LINE__); - return FAIL; - } - //usleep(10*1000); - } - //SensorReg_Read( Sensor_init_table_2lane[i].reg, &sen_data ); - //UartSendTrace("IMX307 reg: 0x%x, data: 0x%x, read: 0x%x.\n",Sensor_init_table_2lane[i].reg, Sensor_init_table_2lane[i].data, sen_data); - } - } - - for(i=0;i< ARRAY_SIZE(PatternTbl);i++) - { - if(SensorReg_Write(PatternTbl[i].reg,PatternTbl[i].data) != SUCCESS) - { - //MSG("[%s:%d]Sensor init fail!!\n", __FUNCTION__, __LINE__); - return FAIL; - } - } - - for(i=0;i< ARRAY_SIZE(TriggerStartTbl);i++) - { - if(SensorReg_Write(TriggerStartTbl[i].reg,TriggerStartTbl[i].data) != SUCCESS) - { - //MSG("[%s:%d]Sensor init fail!!\n", __FUNCTION__, __LINE__); - return FAIL; - } - } - - pCus_SetOrien(handle, handle->orient); - - //pCus_SetAEGain(handle,2048); - //pCus_SetAEUSecs(handle, 25000); - //pCus_SetFPS(handle, 25000); - //MSG("[%s:%d]Sensor init success!!\n", __FUNCTION__, __LINE__); - return SUCCESS; -} -#endif -/* -int pCus_release(ms_cus_sensor *handle) -{ - ISensorIfAPI *sensor_if = handle->sensor_if_api; - sensor_if->PCLK(NULL,CUS_PCLK_OFF); - return SUCCESS; -} -*/ - -static int pCus_GetVideoResNum( ms_cus_sensor *handle, u32 *ulres_num) -{ - *ulres_num = handle->video_res_supported.num_res; - return SUCCESS; -} - -static int pCus_GetVideoRes(ms_cus_sensor *handle, u32 res_idx, cus_camsensor_res **res) -{ - u32 num_res = handle->video_res_supported.num_res; - - if (res_idx >= num_res) { - return FAIL; - } - - *res = &handle->video_res_supported.res[res_idx]; - - return SUCCESS; -} - -static int pCus_GetCurVideoRes(ms_cus_sensor *handle, u32 *cur_idx, cus_camsensor_res **res) -{ - u32 num_res = handle->video_res_supported.num_res; - - *cur_idx = handle->video_res_supported.ulcur_res; - - if (*cur_idx >= num_res) { - return FAIL; - } - - *res = &handle->video_res_supported.res[*cur_idx]; - - return SUCCESS; -} - -static int pCus_SetVideoRes(ms_cus_sensor *handle, u32 res_idx) -{ - imx307_params *params = (imx307_params *)handle->private_data; - u32 num_res = handle->video_res_supported.num_res; - - if (res_idx >= num_res) { - return FAIL; - } - switch (res_idx) { - case 0: - handle->video_res_supported.ulcur_res = 0; - - if(lane_num == 2) - handle->pCus_sensor_init = pCus_init_mipi2lane_linear; - else if (lane_num == 4) - handle->pCus_sensor_init = pCus_init_mipi4lane_linear; - else - handle->pCus_sensor_init = pCus_init_mipi2lane_linear; - - params->expo.vts=vts_30fps; - break; - - default: - break; - } - - return SUCCESS; -} - -static int pCus_SetVideoRes_HDR_DOL(ms_cus_sensor *handle, u32 res_idx) -{ - imx307_params *params = (imx307_params *)handle->private_data; - u32 num_res = handle->video_res_supported.num_res; - if (res_idx >= num_res) { - return FAIL; - } - switch (res_idx) { - case 0: - handle->video_res_supported.ulcur_res = 0; - if(hdr_lane_num == 2) { - handle->pCus_sensor_init = pCus_init_mipi2lane_HDR_DOL; - params->expo.vts = vts_30fps_HDR_DOL_2lane; - } else if(hdr_lane_num == 4) { - handle->pCus_sensor_init = pCus_init_mipi4lane_HDR_DOL; - params->expo.vts = vts_30fps_HDR_DOL_4lane; - } - - break; - - default: - break; - } - - return SUCCESS; -} - -static int pCus_GetOrien(ms_cus_sensor *handle, CUS_CAMSENSOR_ORIT *orit) -{ -#if 0 - imx307_params *params = (imx307_params *)handle->private_data; - short sen_data; - - SensorReg_Read(0x3007, &sen_data);//always success now - - //LOGD("mirror:%x\r\n", sen_data & 0x03); - switch(sen_data & 0x03) - { - case 0x00: - *orit = CUS_ORIT_M0F0; - break; - case 0x02: - *orit = CUS_ORIT_M1F0; - break; - case 0x01: - *orit = CUS_ORIT_M0F1; - break; - case 0x03: - *orit = CUS_ORIT_M1F1; - break; - } -#endif - *orit = handle->orient; - return SUCCESS; -} - -static int pCus_SetOrien(ms_cus_sensor *handle, CUS_CAMSENSOR_ORIT orit) -{ - imx307_params *params = (imx307_params *)handle->private_data; - SENSOR_DMSG("\n\n[%s]", __FUNCTION__); - handle->orient = orit; - params->orien_dirty = true; - - return SUCCESS; -} - -static int DoOrien(ms_cus_sensor *handle, CUS_CAMSENSOR_ORIT orit) -{ - int table_length = ARRAY_SIZE(mirr_flip_table); - int seg_length=table_length/4; - int i,j; - - SENSOR_DMSG("\n\n[%s]", __FUNCTION__); - - switch(orit) - { - case CUS_ORIT_M0F0: - for(i=0,j=0;iorient = CUS_ORIT_M0F0; - } - break; - - case CUS_ORIT_M1F0: - for(i=seg_length,j=0;iorient = CUS_ORIT_M1F0; - } - break; - - case CUS_ORIT_M0F1: - for(i=seg_length*2,j=0;iorient = CUS_ORIT_M0F1; - } - break; - - case CUS_ORIT_M1F1: - for(i=seg_length*3,j=0;iorient = CUS_ORIT_M1F1; - } - break; - - default : - for(i=0,j=0;iorient = CUS_ORIT_M0F0; - } - break; - } - - return SUCCESS; -} - -static int pCus_GetFPS(ms_cus_sensor *handle) -{ - imx307_params *params = (imx307_params *)handle->private_data; - u32 max_fps = handle->video_res_supported.res[handle->video_res_supported.ulcur_res].max_fps; - u32 tVts = (params->tVts_reg[0].data << 16) | (params->tVts_reg[1].data << 8) | (params->tVts_reg[2].data << 0); - - if (params->expo.fps >= 3000) - params->expo.preview_fps = (vts_30fps*max_fps*1000)/tVts; - else - params->expo.preview_fps = (vts_30fps*max_fps)/tVts; - - return params->expo.preview_fps; -} - -static int pCus_SetFPS(ms_cus_sensor *handle, u32 fps) -{ - u32 vts = 0; - imx307_params *params = (imx307_params *)handle->private_data; - SENSOR_DMSG("\n\n[%s]", __FUNCTION__); - - if(fps>=3 && fps <= 30){ - if (CUS_CMU_CLK_36MHZ == handle->mclk) - fps = fps>29?29:fps;//limit fps at 29 fps due to MCLK=36MHz - params->expo.fps = fps; - if (CUS_CMU_CLK_36MHZ == handle->mclk) - params->expo.vts= (vts_30fps*29091 + fps * 500)/(fps * 1000); - else - params->expo.vts= (vts_30fps*30000 + fps * 500)/(fps * 1000); - params->dirty = true; - }else if(fps>=3000 && fps <= 30000){ - if (CUS_CMU_CLK_36MHZ == handle->mclk) - fps = fps>29091?29091:fps;//limit fps at 29.091 fps due to MCLK=36MHz - params->expo.fps = fps; - if (CUS_CMU_CLK_36MHZ == handle->mclk) - params->expo.vts= (vts_30fps*29091 + (fps>>1))/fps; - else - params->expo.vts= (vts_30fps*30000 + (fps>>1))/fps; - params->dirty = true; - }else{ - //params->expo.vts=vts_30fps; - //params->expo.fps=30; - SENSOR_DMSG("[%s] FPS %d out of range.\n",__FUNCTION__,fps); - return FAIL; - } - if(params->expo.expo_lines > params->expo.vts -2){ - vts = params->expo.expo_lines + 8; - }else{ - vts = params->expo.vts; - } - - params->expo.vts = vts; - - pCus_SetAEUSecs(handle, params->expo.expo_lef_us); - - return SUCCESS; -} - -static int pCus_GetFPS_HDR_DOL_SEF1(ms_cus_sensor *handle) -{ - imx307_params *params = (imx307_params *)handle->private_data; - u32 cur_vts_30fps = vts_30fps_HDR_DOL_4lane; - u32 max_fps = handle->video_res_supported.res[handle->video_res_supported.ulcur_res].max_fps; - u32 tVts = (params->tVts_reg[0].data << 16) | (params->tVts_reg[1].data << 8) | (params->tVts_reg[2].data << 0); - - if(2 == handle->interface_attr.attr_mipi.mipi_lane_num) - { - cur_vts_30fps = vts_30fps_HDR_DOL_2lane; - } - else if(4 == handle->interface_attr.attr_mipi.mipi_lane_num) - { - cur_vts_30fps = vts_30fps_HDR_DOL_4lane; - } - - if (params->expo.fps >= 3000) - params->expo.preview_fps = (cur_vts_30fps*max_fps*1000)/tVts; - else - params->expo.preview_fps = (cur_vts_30fps*max_fps)/tVts; - - return params->expo.preview_fps; -} - -static int pCus_SetFPS_HDR_DOL_SEF1(ms_cus_sensor *handle, u32 fps) -{ - u32 vts = 0, cur_vts_30fps = vts_30fps_HDR_DOL_4lane; - imx307_params *params = (imx307_params *)handle->private_data; - - if(2 == handle->interface_attr.attr_mipi.mipi_lane_num) - { - cur_vts_30fps =vts_30fps_HDR_DOL_2lane; - } - else if(4 == handle->interface_attr.attr_mipi.mipi_lane_num) - { - cur_vts_30fps = vts_30fps_HDR_DOL_4lane; - } - - params->expo.fps = fps; - - if(fps>=3 && fps <= 30){ - if (CUS_CMU_CLK_36MHZ == handle->mclk) - fps = fps>29?29:fps;//limit fps at 29 fps due to MCLK=36MHz - params->expo.fps = fps; - if (CUS_CMU_CLK_36MHZ == handle->mclk) - params->expo.vts= (cur_vts_30fps*29091 + fps * 500 )/ (fps * 1000); - else - params->expo.vts= (cur_vts_30fps*30000 + fps * 500 )/ (fps * 1000); - params->dirty = true; - }else if(fps>=3000 && fps <= 30000){ - if (CUS_CMU_CLK_36MHZ == handle->mclk) - fps = fps>29091?29091:fps;//limit fps at 29.091 fps due to MCLK=36MHz - params->expo.fps = fps; - if (CUS_CMU_CLK_36MHZ == handle->mclk) - params->expo.vts= (cur_vts_30fps*29091 + (fps >> 1))/fps; - else - params->expo.vts= (cur_vts_30fps*30000 + (fps >> 1))/fps; - params->dirty = true; - }else{ - //params->expo.vts=vts_30fps; - //params->expo.fps=30; - SENSOR_DMSG("[%s] FPS %d out of range.\n",__FUNCTION__,fps); - return FAIL; - } - - if(params->expo.expo_lines > 2 * params->expo.vts - params->max_rhs1 -3){ - vts = (params->expo.expo_lines + params->max_rhs1 + 3 + 1) / 2; - }else{ - vts = params->expo.vts; - } - - params->expo.vts = vts; - pCus_SetAEUSecsHDR_DOL_SEF1(handle, params->expo.expo_sef_us); - params->skip_cnt = 1; - return SUCCESS; -} -#if 0 -static int pCus_GetSensorCap(ms_cus_sensor *handle, CUS_CAMSENSOR_CAP *cap) -{ - if (cap) - memcpy(cap, &sensor_cap, sizeof(CUS_CAMSENSOR_CAP)); - else return FAIL; - return SUCCESS; -} -#endif - -/////////////////////////////////////////////////////////////////////// -// auto exposure -/////////////////////////////////////////////////////////////////////// -// unit: micro seconds -//AE status notification -static int pCus_AEStatusNotify(ms_cus_sensor *handle, CUS_CAMSENSOR_AE_STATUS_NOTIFY status) -{ - imx307_params *params = (imx307_params *)handle->private_data; - ISensorIfAPI *sensor_if = handle->sensor_if_api; - - switch(status) - { - case CUS_FRAME_INACTIVE: - //SensorReg_Write(0x3001,0); - break; - case CUS_FRAME_ACTIVE: - if(params->dirty || params->orien_dirty) { - SensorReg_Write(0x3001,1); - - if(params->dirty) - { - SensorRegArrayW((I2C_ARRAY*)params->tExpo_reg, ARRAY_SIZE(expo_reg)); - SensorRegArrayW((I2C_ARRAY*)params->tGain_reg, ARRAY_SIZE(gain_reg)); - SensorRegArrayW((I2C_ARRAY*)params->tVts_reg, ARRAY_SIZE(vts_reg)); - params->dirty = false; - } - - if(params->orien_dirty) - { - DoOrien(handle, handle->orient); - params->orien_dirty = false; - } - - SensorReg_Write(0x3001,0); // printf("0x3009=0x%x,0x3014=0x%x,0x3016=0x%x,0x3020=0x%x,0x3021=0x%x\n", params->tGain_reg[1].data,params->tGain_reg[0].data,params->tGain_reg[2].data,params->tExpo_reg[2].data,params->tExpo_reg[1].data); - } - - if(params->skip_cnt){ - sensor_if->SetSkipFrame(handle->snr_pad_group, params->expo.fps, params->skip_cnt); - params->skip_cnt = 0; - } - break; - default : - break; - } - return SUCCESS; -} - -static int pCus_AEStatusNotifyHDR_DOL_SEF1(ms_cus_sensor *handle, CUS_CAMSENSOR_AE_STATUS_NOTIFY status) -{ - //imx307_params *params = (imx307_params *)handle->private_data; - switch(status) - { - case CUS_FRAME_INACTIVE: - //SensorReg_Write(0x3001,0); - break; - case CUS_FRAME_ACTIVE: - break; - default : - break; - } - return SUCCESS; -} - -static int pCus_GetAEUSecs(ms_cus_sensor *handle, u32 *us) -{ - //int rc; - u32 lines = 0; - imx307_params *params = (imx307_params *)handle->private_data; - //int rc = SensorRegArrayR((I2C_ARRAY*)params->tExpo_reg, ARRAY_SIZE(expo_reg)); - - lines |= (u32)(params->tExpo_reg[0].data&0xff)<<16; - lines |= (u32)(params->tExpo_reg[1].data&0xff)<<8; - lines |= (u32)(params->tExpo_reg[2].data&0xff)<<0; - // lines >>= 4; - // *us = (lines+dummy) * params->expo.us_per_line; - //*us = lines;//(lines*Preview_line_period); - *us = (lines*Preview_line_period)/1000; - SENSOR_DMSG("[%s] sensor expo lines/us %u,%u us\n", __FUNCTION__, lines, *us); - //return rc; - return SUCCESS; -} - -static int pCus_SetAEUSecs(ms_cus_sensor *handle, u32 us) -{ - u32 lines = 0, vts = 0; - imx307_params *params = (imx307_params *)handle->private_data; - - params->expo.expo_lef_us = us; - lines = (1000*us)/Preview_line_period; - - if (lines <1 ) lines = 1; - - params->expo.expo_lines = lines; - - if (lines >params->expo.vts-2) { - vts = lines +2; - } - else - vts=params->expo.vts; - - SENSOR_DMSG("[%s] us %u, lines %u, vts %u\n", __FUNCTION__, - us, - lines, - params->expo.vts - ); - lines=vts-lines-1; - params->tExpo_reg[0].data = (lines>>16) & 0x0003; - params->tExpo_reg[1].data = (lines>>8) & 0x00ff; - params->tExpo_reg[2].data = (lines>>0) & 0x00ff; - - params->tVts_reg[0].data = (vts >> 16) & 0x0003; - params->tVts_reg[1].data = (vts >> 8) & 0x00ff; - params->tVts_reg[2].data = (vts >> 0) & 0x00ff; - - params->dirty = true; - return SUCCESS; -} - -static int pCus_SetAEUSecsHDR_DOL_SEF1(ms_cus_sensor *handle, u32 us) -{ - u32 lines = 0, cur_line_period = Preview_line_period_HDR_DOL_4LANE, cur_vts_30fps = vts_30fps_HDR_DOL_4lane; - u32 rhs1 = 0, shs1 = 0, vts = 0; - imx307_params *params = (imx307_params *)handle->private_data; - - params->expo.expo_sef_us = us; - - if(2 == handle->interface_attr.attr_mipi.mipi_lane_num) - { - cur_line_period = Preview_line_period_HDR_DOL_2LANE; - } - else if(4 == handle->interface_attr.attr_mipi.mipi_lane_num) - { - cur_line_period = Preview_line_period_HDR_DOL_4LANE; - } - - if(2 == handle->interface_attr.attr_mipi.mipi_lane_num) - { - cur_vts_30fps =vts_30fps_HDR_DOL_2lane; - } - else if(4 == handle->interface_attr.attr_mipi.mipi_lane_num) - { - cur_vts_30fps = vts_30fps_HDR_DOL_4lane; - } - - lines = (1000 * us + (cur_line_period >> 1)) / cur_line_period; - - //check fps to set rhs1 - - if(params->expo.fps > 3000){ //3fps*1000 - if(params->expo.fps > 25000){ - if(lines > 98) { - params->max_rhs1 = 211; - params->expo.vts = cur_vts_30fps * 30000 / 25000; - } - else{ - params->expo.vts = cur_vts_30fps * 30000 / params->expo.fps; - params->max_rhs1 = 101; - } - } - else - params->max_rhs1 = 211; - } - else { - if(params->expo.fps > 25){ - if(lines > 98) { - params->max_rhs1 = 211; - params->expo.vts = cur_vts_30fps * 30 / 25; - } - else{ - params->expo.vts = cur_vts_30fps * 30 / params->expo.fps; - params->max_rhs1 = 101; - } - } - else - params->max_rhs1 = 211; - } - - if (params->expo.expo_lines > 2 * params->expo.vts - params->max_rhs1 - 3) { - vts = (params->expo.expo_lines + params->max_rhs1 + 3 + 1) / 2; - } - else{ - vts = params->expo.vts; - } - - rhs1 = params->max_rhs1; - //Check boundary - if(lines < 1) - lines = 1; - if(lines > rhs1- 3) - lines = rhs1 - 3; - - if((rhs1 - 1 - 2) <= lines){ - shs1 = 2; - } - else if((rhs1 <= params->max_rhs1) && (rhs1 <= params->lef_shs2 - 2)){ - shs1 = rhs1 - 1 - lines; - if((shs1 < 2) || (shs1 > (rhs1 - 2))){ //Check boundary - //shs1 = 0; - //UartSendTrace("[SEF1 NG1]"); - } - } - else{ - //UartSendTrace("[SEF1 NG2]"); - } - params->tVts_reg[0].data = (vts >> 16) & 0x0003; - params->tVts_reg[1].data = (vts >> 8) & 0x00ff; - params->tVts_reg[2].data = (vts >> 0) & 0x00ff; - - params->tExpo_reg[0].data = (shs1 >> 16) & 0x0003; - params->tExpo_reg[1].data = (shs1 >> 8) & 0x00ff; - params->tExpo_reg[2].data = (shs1 >> 0) & 0x00ff; - - params->tRhs1_reg[0].data = (params->max_rhs1 >> 16) & 0x0003; - params->tRhs1_reg[1].data = (params->max_rhs1 >> 8) & 0x00ff; - params->tRhs1_reg[2].data = (params->max_rhs1 >> 0) & 0x00ff; - - return SUCCESS; -} - -// Gain: 1x = 1024 -static int pCus_GetAEGain(ms_cus_sensor *handle, u32* gain) -{ - //int rc = SensorRegArrayR((I2C_ARRAY*)params->tGain_reg, ARRAY_SIZE(gain_reg)); - unsigned short temp_gain; - // *gain=params->expo.final_gain; - temp_gain=gain_reg[0].data; - - *gain=(u32)(10^((temp_gain*3)/200))*1024; - if (gain_reg[1].data & 0x10) - *gain = (*gain) * 2; - - SENSOR_DMSG("[%s] get gain/reg (1024=1X)= %u/0x%x\n", __FUNCTION__, *gain,gain_reg[0].data); - //return rc; - return SUCCESS; -} - -static int pCus_SetAEGain_cal(ms_cus_sensor *handle, u32 gain) -{ - imx307_params *params = (imx307_params *)handle->private_data; - //double gain_double; - u64 gain_double; - params->expo.final_gain = gain; - - if(gain<1024) - gain=1024; - else if(gain>=3980*1024) - gain=3980*1024; - - gain_double = 20*(intlog10(gain)-intlog10(1024)); - params->tGain_reg[0].data=(u16)(((gain_double*10)>> 24)/3); - - //gain_double = 20*log10((double)gain/1024); - //params->tGain_reg[0].data=(u16)((gain_double*10)/3); - - SENSOR_DMSG("[%s] set gain/reg=%u/0x%x\n", __FUNCTION__, gain,params->tGain_reg[0].data); - - //return CusHW_i2c_array_tx(handle, handle->i2c_cfg, params->tGain_reg, sizeof(gain_reg)/sizeof(CUS_I2C_ARRAY)); - //return SensorRegArrayW((I2C_ARRAY*)params->tGain_reg, sizeof(gain_reg)/sizeof(I2C_ARRAY)); - params->dirty = true; - return SUCCESS; -} - -static int pCus_SetAEGain(ms_cus_sensor *handle, u32 gain) -{ - //extern DBG_ITEM Dbg_Items[DBG_TAG_MAX]; - imx307_params *params = (imx307_params *)handle->private_data; - u32 i;//, gain_before=0; - CUS_GAIN_GAP_ARRAY* Sensor_Gain_Linearity; - //double gain_double; - u64 gain_double; - - //return SUCCESS; //TBD - - // u32 times = log2((double)gain/1024.0f)/log(2); - params->expo.final_gain = gain; - if(gain < SENSOR_MIN_GAIN) - gain = SENSOR_MIN_GAIN; - else if(gain >= SENSOR_MAX_GAIN) - gain = SENSOR_MAX_GAIN; - Sensor_Gain_Linearity = gain_gap_compensate; - - for(i = 0; i < sizeof(gain_gap_compensate)/sizeof(CUS_GAIN_GAP_ARRAY); i++){ - //LOGD("GAP:%x %x\r\n",Sensor_Gain_Linearity[i].gain, Sensor_Gain_Linearity[i].offset); - - if (Sensor_Gain_Linearity[i].gain == 0) - break; - if((gain>Sensor_Gain_Linearity[i].gain) && (gain < (Sensor_Gain_Linearity[i].gain + Sensor_Gain_Linearity[i].offset))){ - gain=Sensor_Gain_Linearity[i].gain; - break; - } - } - - if(gain>=22925)//if gain exceed 2x , enable high conversion gain, >27DB, enable HCG - { - - if(params->tGain_reg[1].data==0x02){ - // params->change = true; - // gain_reg[2].data=0x08; - } - else{ - // params->change = false; - // gain_reg[2].data=0x09; - } - //gain_before=gain; - params->tGain_reg[1].data |= 0x10; - // gain_reg[2].data=0x08; - gain /= 2; - - } - else{ - - if(params->tGain_reg[1].data==0x12){ - // params->change = true; - // gain_reg[2].data=0x08; - } - else{ - // params->change = false; - // gain_reg[2].data=0x09; - } - // printf("[%s] params->change=%d\n", __FUNCTION__, params->change); - - // gain_before=gain; - params->tGain_reg[1].data &= ~0x10; - //gain_reg[2].data=0x09; - - } - gain_double = 20*(intlog10(gain)-intlog10(1024)); - params->tGain_reg[0].data=(u16)(((gain_double*10)>> 24)/3); - //gain_double = 20*log10((double)gain/1024); - //params->tGain_reg[0].data=(u16)((gain_double*10)/3); - - //SensorRegArrayW((I2C_ARRAY*)params->tGain_reg, ARRAY_SIZE(gain_reg)); - - //LOGD("s:%x %x\r\n", params->tGain_reg[0].data, params->tGain_reg[1].data); - SENSOR_DMSG("[%s] set gain/reg=%u/0x%x\n", __FUNCTION__, gain,params->tGain_reg[0].data); - params->dirty = true; - return SUCCESS; - //return CusHW_i2c_array_tx(handle, handle->i2c_cfg, params->tGain_reg, sizeof(gain_reg)/sizeof(CUS_I2C_ARRAY)); - // return SensorRegArrayW((I2C_ARRAY*)params->tGain_reg, sizeof(gain_reg)/sizeof(I2C_ARRAY)); -} - -static void pCus_SetAEGainHDR_DOL_Calculate(u32 gain, u16 *gain_reg) -{ - //double gain_double; - u64 gain_double; - - if(gain < SENSOR_MIN_GAIN){ - gain = SENSOR_MIN_GAIN; - } - else if(gain >= SENSOR_MAX_GAIN){ - gain = SENSOR_MAX_GAIN; - } - gain_double = 20*(intlog10(gain)-intlog10(1024)); - *gain_reg=(u16)(((gain_double*10)>> 24)/3); - //gain_double = 20*log10((double)gain/1024); //gain to db - //*gain_reg = (u16)((gain_double*10)/3); //db to sensor reg -} - -static int pCus_SetAEGainHDR_DOL_SEF1(ms_cus_sensor *handle, u32 gain) -{ - imx307_params *params = (imx307_params *)handle->private_data; - u16 gain_reg = 0; - - - pCus_SetAEGainHDR_DOL_Calculate(gain, &gain_reg); - params->tGain_hdr_dol_sef_reg[0].data = gain_reg; - - SENSOR_DMSG("[%s] set gain/reg=%u/0x%x\n", __FUNCTION__, gain, params->tGain_hdr_dol_sef_reg[0].data); - - params->dirty = true; - return SUCCESS; -} - -static int pCus_GetAEMinMaxUSecs(ms_cus_sensor *handle, u32 *min, u32 *max) -{ - *min = 1; - *max = 1000000/Preview_MIN_FPS; - return SUCCESS; -} - -static int pCus_GetAEMinMaxGain(ms_cus_sensor *handle, u32 *min, u32 *max) -{ - *min = SENSOR_MIN_GAIN;//handle->sat_mingain; - *max = SENSOR_MAX_GAIN;//3980*1024; - return SUCCESS; -} -#if 0 -static int pCus_GetDGainRemainder(ms_cus_sensor *handle, u32 *dgain_remainder) -{ - *dgain_remainder = handle->dgain_remainder; - - return SUCCESS; -} -#endif -static int IMX307_GetShutterInfo(struct __ms_cus_sensor* handle,CUS_SHUTTER_INFO *info) -{ - info->max = 1000000000/Preview_MIN_FPS; - info->min = (Preview_line_period * 1); - info->step = Preview_line_period; - return SUCCESS; -} - -static int pCus_setCaliData_gain_linearity(ms_cus_sensor* handle, CUS_GAIN_GAP_ARRAY* pArray, u32 num) { - u32 i, j; - - for(i=0,j=0;i< num ;i++,j+=2){ - gain_gap_compensate[i].gain=pArray[i].gain; - gain_gap_compensate[i].offset=pArray[i].offset; - } - - //LOGD("[%s]%d, %d, %d, %d\n", __FUNCTION__, num, pArray[0].gain, pArray[1].gain, pArray[num-1].offset); - - return SUCCESS; -} - -int cus_camsensor_init_handle(ms_cus_sensor* drv_handle) -{ - ms_cus_sensor *handle = drv_handle; - imx307_params *params; - - if (!handle) { - SENSOR_DMSG("[%s] not enough memory!\n", __FUNCTION__); - return FAIL; - } - SENSOR_DMSG("[%s]", __FUNCTION__); - - //private data allocation & init - if (handle->private_data == NULL) { - SENSOR_EMSG("[%s] Private data is empty!\n", __FUNCTION__); - return FAIL; - } - params = (imx307_params *)handle->private_data; - memcpy(params->tGain_reg, gain_reg, sizeof(gain_reg)); - memcpy(params->tExpo_reg, expo_reg, sizeof(expo_reg)); - memcpy(params->tVts_reg, vts_reg, sizeof(vts_reg)); - memcpy(params->tRhs1_reg, expo_RHS1_reg, sizeof(expo_RHS1_reg)); - memcpy(params->tShs2_reg, expo_SHS2_reg, sizeof(expo_SHS2_reg)); - memcpy(params->tGain_hdr_dol_lef_reg, gain_HDR_DOL_LEF_reg, sizeof(gain_HDR_DOL_LEF_reg)); - memcpy(params->tGain_hdr_dol_sef_reg, gain_HDR_DOL_SEF1_reg, sizeof(gain_HDR_DOL_SEF1_reg)); - - //////////////////////////////////// - // sensor model ID // - //////////////////////////////////// - sprintf(handle->model_id,"IMX307_MIPI"); - - //////////////////////////////////// - // sensor interface info // - //////////////////////////////////// - //SENSOR_DMSG("[%s] entering function with id %d\n", __FUNCTION__, id); - handle->isp_type = SENSOR_ISP_TYPE; //ISP_SOC; - //handle->data_fmt = SENSOR_DATAFMT; //CUS_DATAFMT_YUV; - handle->sif_bus = SENSOR_IFBUS_TYPE;//CUS_SENIF_BUS_PARL; - handle->data_prec = SENSOR_DATAPREC; //CUS_DATAPRECISION_8; - handle->data_mode = SENSOR_DATAMODE; - handle->bayer_id = SENSOR_BAYERID; //CUS_BAYER_GB; - handle->RGBIR_id = SENSOR_RGBIRID; - handle->orient = SENSOR_ORIT; //CUS_ORIT_M1F1; - //handle->YC_ODER = SENSOR_YCORDER; //CUS_SEN_YCODR_CY; - handle->interface_attr.attr_mipi.mipi_lane_num = lane_num; - handle->interface_attr.attr_mipi.mipi_data_format = CUS_SEN_INPUT_FORMAT_RGB; // RGB pattern. - handle->interface_attr.attr_mipi.mipi_yuv_order = 0; //don't care in RGB pattern. - handle->interface_attr.attr_mipi.mipi_hsync_mode = SENSOR_MIPI_HSYNC_MODE; - handle->interface_attr.attr_mipi.mipi_hdr_mode = CUS_HDR_MODE_NONE; - handle->interface_attr.attr_mipi.mipi_hdr_virtual_channel_num = 0; //Short frame - - //////////////////////////////////// - // resolution capability // - //////////////////////////////////// - handle->video_res_supported.num_res = 1; - handle->video_res_supported.ulcur_res = 0; //default resolution index is 0. - handle->video_res_supported.res[0].width = Preview_WIDTH; - handle->video_res_supported.res[0].height = Preview_HEIGHT; - handle->video_res_supported.res[0].max_fps= Preview_MAX_FPS; - handle->video_res_supported.res[0].min_fps= Preview_MIN_FPS; - handle->video_res_supported.res[0].crop_start_x= Preview_CROP_START_X; - handle->video_res_supported.res[0].crop_start_y= Preview_CROP_START_Y; - handle->video_res_supported.res[0].nOutputWidth = 0x79C; - handle->video_res_supported.res[0].nOutputHeight = 0x449; - sprintf(handle->video_res_supported.res[0].strResDesc, "1920x1080@30fps"); - // i2c - handle->i2c_cfg.mode = SENSOR_I2C_LEGACY; //(CUS_ISP_I2C_MODE) FALSE; - handle->i2c_cfg.fmt = SENSOR_I2C_FMT; //CUS_I2C_FMT_A16D16; - handle->i2c_cfg.address = SENSOR_I2C_ADDR; //0x5a; - handle->i2c_cfg.speed = SENSOR_I2C_SPEED; //320000; - - // mclk - handle->mclk = UseParaMclk(SENSOR_DRV_PARAM_MCLK()); - - //polarity - ///////////////////////////////////////////////////// - handle->pwdn_POLARITY = SENSOR_PWDN_POL; //CUS_CLK_POL_NEG; - handle->reset_POLARITY = SENSOR_RST_POL; //CUS_CLK_POL_NEG; - //handle->VSYNC_POLARITY = SENSOR_VSYNC_POL; //CUS_CLK_POL_POS; - //handle->HSYNC_POLARITY = SENSOR_HSYNC_POL; //CUS_CLK_POL_POS; - handle->PCLK_POLARITY = SENSOR_PCLK_POL; //CUS_CLK_POL_POS); // use '!' to clear board latch error - ///////////////////////////////////////////////////// - - - - //////////////////////////////////////////////////// - // AE parameters - //////////////////////////////////////////////////// - handle->ae_gain_delay = SENSOR_GAIN_DELAY_FRAME_COUNT; - handle->ae_shutter_delay = SENSOR_SHUTTER_DELAY_FRAME_COUNT; - - handle->ae_gain_ctrl_num = 1; - handle->ae_shutter_ctrl_num = 2; - - ///calibration - handle->sat_mingain = SENSOR_MIN_GAIN;//g_sensor_ae_min_gain; - //handle->dgain_remainder = 0; - - //LOGD("[%s:%d]\n", __FUNCTION__, __LINE__); - handle->pCus_sensor_release = cus_camsensor_release_handle; - - if(lane_num == 2) - handle->pCus_sensor_init = pCus_init_mipi2lane_linear ; - else if(lane_num == 4) - handle->pCus_sensor_init = pCus_init_mipi4lane_linear ; - else - handle->pCus_sensor_init = pCus_init_mipi2lane_linear ; - - //handle->pCus_sensor_powerupseq = pCus_powerupseq ; - handle->pCus_sensor_poweron = pCus_poweron ; - handle->pCus_sensor_poweroff = pCus_poweroff; - - // Normal - handle->pCus_sensor_GetSensorID = pCus_GetSensorID ; - - handle->pCus_sensor_GetVideoResNum = pCus_GetVideoResNum; - handle->pCus_sensor_GetVideoRes = pCus_GetVideoRes; - handle->pCus_sensor_GetCurVideoRes = pCus_GetCurVideoRes; - handle->pCus_sensor_SetVideoRes = pCus_SetVideoRes; - - handle->pCus_sensor_GetOrien = pCus_GetOrien ; - handle->pCus_sensor_SetOrien = pCus_SetOrien ; - handle->pCus_sensor_GetFPS = pCus_GetFPS ; - handle->pCus_sensor_SetFPS = pCus_SetFPS ; - //handle->pCus_sensor_GetSensorCap = pCus_GetSensorCap; - handle->pCus_sensor_SetPatternMode = imx307_SetPatternMode; - /////////////////////////////////////////////////////// - // AE - /////////////////////////////////////////////////////// - // unit: micro seconds - //handle->pCus_sensor_GetAETrigger_mode = pCus_GetAETrigger_mode; - //handle->pCus_sensor_SetAETrigger_mode = pCus_SetAETrigger_mode; - handle->pCus_sensor_AEStatusNotify = pCus_AEStatusNotify; - handle->pCus_sensor_GetAEUSecs = pCus_GetAEUSecs; - handle->pCus_sensor_SetAEUSecs = pCus_SetAEUSecs; - handle->pCus_sensor_GetAEGain = pCus_GetAEGain; - //handle->pCus_sensor_SetAEGain = pCus_SetAEGain; - handle->pCus_sensor_SetAEGain = pCus_SetAEGain; - - handle->pCus_sensor_GetAEMinMaxGain = pCus_GetAEMinMaxGain; - handle->pCus_sensor_GetAEMinMaxUSecs= pCus_GetAEMinMaxUSecs; - //handle->pCus_sensor_GetDGainRemainder = pCus_GetDGainRemainder; - - //sensor calibration - handle->pCus_sensor_SetAEGain_cal = pCus_SetAEGain_cal; - handle->pCus_sensor_setCaliData_gain_linearity=pCus_setCaliData_gain_linearity; - handle->pCus_sensor_GetShutterInfo = IMX307_GetShutterInfo; - - params->expo.vts=vts_30fps; - params->expo.expo_lines = 673; - if (CUS_CMU_CLK_36MHZ == handle->mclk) - params->expo.fps = 29; - else - params->expo.fps = 30; - params->dirty = false; - - return SUCCESS; -} - -static int IMX307_GetShutterInfo_hdr_dol_sef1(struct __ms_cus_sensor* handle,CUS_SHUTTER_INFO *info) -{ - info->max = Preview_line_period_HDR_DOL_4LANE * 211; - info->min = (Preview_line_period_HDR_DOL_4LANE * 2); - info->step = Preview_line_period_HDR_DOL_4LANE; - return SUCCESS; -} - -int cus_camsensor_init_handle_hdr_dol_sef1(ms_cus_sensor* drv_handle) -{ - ms_cus_sensor *handle = drv_handle; - imx307_params *params = NULL; - - cus_camsensor_init_handle(drv_handle); - params = (imx307_params *)handle->private_data; - - sprintf(handle->model_id,"IMX307_MIPI_HDR_SEF"); - - handle->bayer_id = SENSOR_BAYERID_HDR_DOL; - handle->RGBIR_id = SENSOR_RGBIRID; - handle->data_prec = SENSOR_DATAPREC_DOL; - handle->interface_attr.attr_mipi.mipi_lane_num = hdr_lane_num; - handle->interface_attr.attr_mipi.mipi_hsync_mode = SENSOR_MIPI_HSYNC_MODE_HDR_DOL; - handle->interface_attr.attr_mipi.mipi_hdr_mode = CUS_HDR_MODE_SONY_DOL; - - handle->video_res_supported.num_res = 1; - handle->video_res_supported.ulcur_res = 0; //default resolution index is 0. - handle->video_res_supported.res[0].width = Preview_WIDTH; - handle->video_res_supported.res[0].height = Preview_HEIGHT_HDR_DOL; //TBD. Workaround for Sony DOL HDR mode - handle->video_res_supported.res[0].max_fps= Preview_MAX_FPS; - handle->video_res_supported.res[0].min_fps= Preview_MIN_FPS; - handle->video_res_supported.res[0].crop_start_x= Preview_CROP_START_X; - handle->video_res_supported.res[0].crop_start_y= Preview_CROP_START_Y; - handle->video_res_supported.res[0].nOutputWidth = 0x79C; - handle->video_res_supported.res[0].nOutputHeight = 0x449; - sprintf(handle->video_res_supported.res[0].strResDesc, "1920x1080@30fps_HDR"); - - handle->pCus_sensor_SetVideoRes = pCus_SetVideoRes_HDR_DOL; - - if(hdr_lane_num == 4) - handle->pCus_sensor_init = pCus_init_mipi4lane_HDR_DOL; - else if(hdr_lane_num == 2) - handle->pCus_sensor_init = pCus_init_mipi2lane_HDR_DOL; - else - handle->pCus_sensor_init = pCus_init_mipi4lane_HDR_DOL; - - handle->pCus_sensor_GetFPS = pCus_GetFPS_HDR_DOL_SEF1; - handle->pCus_sensor_SetFPS = pCus_SetFPS_HDR_DOL_SEF1; - handle->pCus_sensor_GetOrien = pCus_GetOrien; - handle->pCus_sensor_SetOrien = pCus_SetOrien; - handle->pCus_sensor_AEStatusNotify = pCus_AEStatusNotifyHDR_DOL_SEF1; - handle->pCus_sensor_GetAEUSecs = pCus_GetAEUSecs; - handle->pCus_sensor_SetAEUSecs = pCus_SetAEUSecsHDR_DOL_SEF1; - handle->pCus_sensor_GetAEGain = pCus_GetAEGain; - //handle->pCus_sensor_SetAEGain = pCus_SetAEGain; - handle->pCus_sensor_SetAEGain = pCus_SetAEGainHDR_DOL_SEF1; - handle->pCus_sensor_GetShutterInfo = IMX307_GetShutterInfo_hdr_dol_sef1; - - if(hdr_lane_num == 4) - params->expo.vts = vts_30fps_HDR_DOL_4lane; - else if(hdr_lane_num == 2) - params->expo.vts = vts_30fps_HDR_DOL_2lane; - else - params->expo.vts = vts_30fps_HDR_DOL_4lane; - - - params->expo.expo_lines = 673; - - handle->interface_attr.attr_mipi.mipi_hdr_virtual_channel_num = 1; //Short frame - - handle->ae_gain_delay = SENSOR_GAIN_DELAY_FRAME_COUNT_DOL; - handle->ae_shutter_delay = SENSOR_SHUTTER_DELAY_FRAME_COUNT_DOL; - - handle->ae_gain_ctrl_num = 2; - handle->ae_shutter_ctrl_num = 2; - - return SUCCESS; -} -#if 1//(SENSOR_MIPI_LANE_NUM == 4) -static int pCus_init_mipi4lane_linear_isp_calibration(ms_cus_sensor *handle) -{ - return SUCCESS; -} -#endif -#if 1//(SENSOR_MIPI_LANE_NUM == 2) -static int pCus_init_mipi2lane_linear_isp_calibration(ms_cus_sensor *handle) -{ - return SUCCESS; -} -#endif -static int pCus_poweron_isp_calibration( ms_cus_sensor *handle, u32 idx) -{ - //ISensorIfAPI *sensor_if = &handle->sensor_if_api; - //SENSOR_DMSG( "[%s] ", __FUNCTION__ ); - - return SUCCESS; -} - -static int pCus_poweroff_isp_calibration( ms_cus_sensor *handle, u32 idx) -{ - //ISensorIfAPI *sensor_if = &handle->sensor_if_api; - //SENSOR_DMSG( "[%s] power low\n", __FUNCTION__ ); - - return SUCCESS; -} - -static int pCus_GetSensorID_isp_calibration( ms_cus_sensor *handle, u32 *id ) -{ - *id = 0; - return SUCCESS; -} - -static int imx307_SetPatternMode_isp_calibration( ms_cus_sensor *handle, u32 mode ) -{ - return SUCCESS; -} -#if 0 -static int pCus_I2CWrite_isp_calibration(ms_cus_sensor *handle, unsigned short usreg, unsigned short usval) -{ - return SUCCESS; -} - -static int pCus_I2CRead_isp_calibration(ms_cus_sensor *handle, unsigned short usreg) -{ - return SUCCESS; -} - -static int pCus_init_isp_calibration( ms_cus_sensor *handle ) -{ - return SUCCESS; -} -#endif -static int pCus_GetVideoRes_isp_calibration( ms_cus_sensor *handle, u32 res_idx, cus_camsensor_res **res ) -{ - *res = &handle->video_res_supported.res[res_idx]; - return SUCCESS; -} - -static int pCus_SetVideoRes_isp_calibration( ms_cus_sensor *handle, u32 res ) -{ - handle->video_res_supported.ulcur_res = 0; //TBD - return SUCCESS; -} - -static int pCus_GetOrien_isp_calibration( ms_cus_sensor *handle, CUS_CAMSENSOR_ORIT *orit ) -{ - //imx307_params *params = ( imx307_params * ) handle->private_data; - //return params->mirror_flip.cur; - return SUCCESS; -} - -static int pCus_SetOrien_isp_calibration( ms_cus_sensor *handle, CUS_CAMSENSOR_ORIT orit ) -{ - return SUCCESS; -} - -static int pCus_GetFPS_isp_calibration( ms_cus_sensor *handle ) -{ - return SUCCESS; -} - -static int pCus_SetFPS_isp_calibration( ms_cus_sensor *handle, u32 fps ) -{ - return SUCCESS; -} -#if 0 -static int pCus_GetSensorCap_isp_calibration( ms_cus_sensor *handle, CUS_CAMSENSOR_CAP *cap ) -{ - if( cap ) - memcpy( cap, &sensor_cap, sizeof(CUS_CAMSENSOR_CAP) ); - else - return FAIL; - return SUCCESS; -} -#endif -static int pCus_AEStatusNotify_isp_calibration( ms_cus_sensor *handle, CUS_CAMSENSOR_AE_STATUS_NOTIFY status ) -{ - return SUCCESS; -} - -static int pCus_GetAEUSecs_isp_calibration( ms_cus_sensor *handle, u32 *us ) -{ - *us = 0; - return SUCCESS; -} - -static int pCus_SetAEUSecs_isp_calibration( ms_cus_sensor *handle, u32 us ) -{ - return SUCCESS; -} - -// Gain: 1x = 1024 -static int pCus_GetAEGain_isp_calibration( ms_cus_sensor *handle, u32* gain ) -{ - *gain = 0; - return SUCCESS; -} - -static int pCus_SetAEGain_cal_isp_calibration( ms_cus_sensor *handle, u32 gain ) -{ - return SUCCESS; -} -static int pCus_SetAEGain_isp_calibration( ms_cus_sensor *handle, u32 gain ) -{ - return SUCCESS; -} - -static int pCus_GetAEMinMaxUSecs_isp_calibration( ms_cus_sensor *handle, u32 *min, u32 *max ) -{ - *min = 1; - *max = 1000000 / 30; - - return SUCCESS; -} - -static int pCus_GetAEMinMaxGain_isp_calibration( ms_cus_sensor *handle, u32 *min, u32 *max ) -{ - *min = 1024; //1024*1.1*2 - *max = 1024*8; - - return SUCCESS; -} - -static int pCus_setCaliData_gain_linearity_isp_calibration( ms_cus_sensor* handle, CUS_GAIN_GAP_ARRAY* pArray, u32 num ) -{ - return SUCCESS; -} - -static int IMX307_GetShutterInfo_isp_calibration( struct __ms_cus_sensor* handle, CUS_SHUTTER_INFO *info ) -{ - info->max = 1000000000 / 12; - info->min = Preview_line_period; - info->step = Preview_line_period; - return SUCCESS; -} -#if 0 -static int pCus_GetDGainRemainder_isp_calibration(ms_cus_sensor *handle, u32 *dgain_remainder) -{ - return SUCCESS; -} -#endif -int cus_camsensor_init_handle_linear_isp_calibration(ms_cus_sensor* drv_handle) -{ - ms_cus_sensor *handle = drv_handle; - imx307_params *params; -#if defined(__RTK_OS__) - //CamOsRet_e eCamOsRet = CAM_OS_OK; - void* pvBufVirt = NULL; - //u64 u64BufPhy = 0; - //u64 u64BufMiu = 0; - char str[20]; -#endif - if (!handle) { - SENSOR_DMSG("[%s] not enough memory!\n", __FUNCTION__); - return FAIL; - } - SENSOR_DMSG("[%s]", __FUNCTION__); - //private data allocation & init -#if defined(__RTK_OS__) - sprintf(str, "IMX307linear"); - //eCamOsRet = CamOsDirectMemAlloc(str, sizeof(imx307_params), &pvBufVirt, &u64BufMiu, &u64BufPhy); - pvBufVirt = CamOsMemAlloc(sizeof(imx307_params)); - if (pvBufVirt == NULL) { - //UartSendTrace("[%s:%d] fail!\n", __FUNCTION__, __LINE__); - return FAIL; - } - handle->private_data = (imx307_params *)pvBufVirt; - memset(handle->private_data, 0, sizeof(imx307_params)); -#else - if (handle->private_data == NULL) { - SENSOR_EMSG("[%s] Private data is empty!\n", __FUNCTION__); - return FAIL; - } -#endif - params = (imx307_params *)handle->private_data; - memcpy(params->tGain_reg, gain_reg, sizeof(gain_reg)); - memcpy(params->tExpo_reg, expo_reg, sizeof(expo_reg)); - memcpy(params->tVts_reg, vts_reg, sizeof(vts_reg)); - memcpy(params->tRhs1_reg, expo_RHS1_reg, sizeof(expo_RHS1_reg)); - memcpy(params->tShs2_reg, expo_SHS2_reg, sizeof(expo_SHS2_reg)); - memcpy(params->tGain_hdr_dol_lef_reg, gain_HDR_DOL_LEF_reg, sizeof(gain_HDR_DOL_LEF_reg)); - memcpy(params->tGain_hdr_dol_sef_reg, gain_HDR_DOL_SEF1_reg, sizeof(gain_HDR_DOL_SEF1_reg)); - - //////////////////////////////////// - // sensor model ID // - //////////////////////////////////// - sprintf(handle->model_id,"IMX307_MIPI"); - - //////////////////////////////////// - // sensor interface info // - //////////////////////////////////// - //SENSOR_DMSG("[%s] entering function with id %d\n", __FUNCTION__, id); - handle->isp_type = SENSOR_ISP_TYPE; //ISP_SOC; - //handle->data_fmt = SENSOR_DATAFMT; //CUS_DATAFMT_YUV; - handle->sif_bus = SENSOR_IFBUS_TYPE;//CUS_SENIF_BUS_PARL; - handle->data_prec = SENSOR_DATAPREC; //CUS_DATAPRECISION_8; - handle->data_mode = SENSOR_DATAMODE; - handle->bayer_id = SENSOR_BAYERID; //CUS_BAYER_GB; - handle->RGBIR_id = SENSOR_RGBIRID; - handle->orient = SENSOR_ORIT; //CUS_ORIT_M1F1; - //handle->YC_ODER = SENSOR_YCORDER; //CUS_SEN_YCODR_CY; - handle->interface_attr.attr_mipi.mipi_lane_num = lane_num; - handle->interface_attr.attr_mipi.mipi_data_format = CUS_SEN_INPUT_FORMAT_RGB; // RGB pattern. - handle->interface_attr.attr_mipi.mipi_yuv_order = 0; //don't care in RGB pattern. - handle->interface_attr.attr_mipi.mipi_hsync_mode = SENSOR_MIPI_HSYNC_MODE; - handle->interface_attr.attr_mipi.mipi_hdr_mode = CUS_HDR_MODE_NONE; - handle->interface_attr.attr_mipi.mipi_hdr_virtual_channel_num = 1; //Short frame - sprintf(handle->video_res_supported.res[0].strResDesc, "1920x1080@30fps"); - - //////////////////////////////////// - // resolution capability // - //////////////////////////////////// - - handle->video_res_supported.num_res = 1; - handle->video_res_supported.ulcur_res = 0; //default resolution index is 0. - handle->video_res_supported.res[0].width = Preview_WIDTH; - handle->video_res_supported.res[0].height = Preview_HEIGHT; - handle->video_res_supported.res[0].max_fps= Preview_MAX_FPS; - handle->video_res_supported.res[0].min_fps= Preview_MIN_FPS; - handle->video_res_supported.res[0].crop_start_x= Preview_CROP_START_X; - handle->video_res_supported.res[0].crop_start_y= Preview_CROP_START_Y; - handle->video_res_supported.res[0].nOutputWidth = 0x79C; - handle->video_res_supported.res[0].nOutputHeight = 0x449; - - // i2c - handle->i2c_cfg.mode = SENSOR_I2C_LEGACY; //(CUS_ISP_I2C_MODE) FALSE; - handle->i2c_cfg.fmt = SENSOR_I2C_FMT; //CUS_I2C_FMT_A16D16; - handle->i2c_cfg.address = SENSOR_I2C_ADDR; //0x5a; - handle->i2c_cfg.speed = SENSOR_I2C_SPEED; //320000; - - // mclk - handle->mclk = UseParaMclk(SENSOR_DRV_PARAM_MCLK()); - - //polarity - ///////////////////////////////////////////////////// - handle->pwdn_POLARITY = SENSOR_PWDN_POL; //CUS_CLK_POL_NEG; - handle->reset_POLARITY = SENSOR_RST_POL; //CUS_CLK_POL_NEG; - //handle->VSYNC_POLARITY = SENSOR_VSYNC_POL; //CUS_CLK_POL_POS; - //handle->HSYNC_POLARITY = SENSOR_HSYNC_POL; //CUS_CLK_POL_POS; - handle->PCLK_POLARITY = SENSOR_PCLK_POL; //CUS_CLK_POL_POS); // use '!' to clear board latch error - ///////////////////////////////////////////////////// - - - - //////////////////////////////////////////////////// - // AE parameters - //////////////////////////////////////////////////// - handle->ae_gain_delay = SENSOR_GAIN_DELAY_FRAME_COUNT; - handle->ae_shutter_delay = SENSOR_SHUTTER_DELAY_FRAME_COUNT; - - handle->ae_gain_ctrl_num = 1; - handle->ae_shutter_ctrl_num = 2; - - ///calibration - handle->sat_mingain = SENSOR_MIN_GAIN;//g_sensor_ae_min_gain; - //handle->dgain_remainder = 0; - - //LOGD("[%s:%d]\n", __FUNCTION__, __LINE__); - handle->pCus_sensor_release = cus_camsensor_release_handle; - - if(lane_num == 2) - handle->pCus_sensor_init = pCus_init_mipi2lane_linear_isp_calibration ; - else if(lane_num == 4) - handle->pCus_sensor_init = pCus_init_mipi4lane_linear_isp_calibration ; - else - handle->pCus_sensor_init = pCus_init_mipi2lane_linear_isp_calibration ; - - //handle->pCus_sensor_powerupseq = pCus_powerupseq ; - handle->pCus_sensor_poweron = pCus_poweron_isp_calibration ; - handle->pCus_sensor_poweroff = pCus_poweroff_isp_calibration; - - // Normal - handle->pCus_sensor_GetSensorID = pCus_GetSensorID_isp_calibration ; - //handle->pCus_sensor_GetStillResCap = pCus_GetStillResCap; - //handle->pCus_sensor_GetStillRes = pCus_GetStillRes ; - //handle->pCus_sensor_SetStillRes = pCus_SetStillRes ; - //handle->pCus_sensor_GetVideoResCap = pCus_GetVideoResCap; - handle->pCus_sensor_GetVideoResNum = pCus_GetVideoResNum; - handle->pCus_sensor_GetVideoRes = pCus_GetVideoRes_isp_calibration ; - handle->pCus_sensor_SetVideoRes = pCus_SetVideoRes_isp_calibration ; - handle->pCus_sensor_GetOrien = pCus_GetOrien_isp_calibration ; - handle->pCus_sensor_SetOrien = pCus_SetOrien_isp_calibration ; - handle->pCus_sensor_GetFPS = pCus_GetFPS_isp_calibration ; - handle->pCus_sensor_SetFPS = pCus_SetFPS_isp_calibration ; - //handle->pCus_sensor_GetSensorCap = pCus_GetSensorCap_isp_calibration; - handle->pCus_sensor_SetPatternMode = imx307_SetPatternMode_isp_calibration; - /////////////////////////////////////////////////////// - // AE - /////////////////////////////////////////////////////// - // unit: micro seconds - //handle->pCus_sensor_GetAETrigger_mode = pCus_GetAETrigger_mode; - //handle->pCus_sensor_SetAETrigger_mode = pCus_SetAETrigger_mode; - handle->pCus_sensor_AEStatusNotify = pCus_AEStatusNotify_isp_calibration; - handle->pCus_sensor_GetAEUSecs = pCus_GetAEUSecs_isp_calibration; - handle->pCus_sensor_SetAEUSecs = pCus_SetAEUSecs_isp_calibration; - handle->pCus_sensor_GetAEGain = pCus_GetAEGain_isp_calibration; - //handle->pCus_sensor_SetAEGain = pCus_SetAEGain; - handle->pCus_sensor_SetAEGain = pCus_SetAEGain_isp_calibration; - - handle->pCus_sensor_GetAEMinMaxGain = pCus_GetAEMinMaxGain_isp_calibration; - handle->pCus_sensor_GetAEMinMaxUSecs= pCus_GetAEMinMaxUSecs_isp_calibration; - //handle->pCus_sensor_GetDGainRemainder = pCus_GetDGainRemainder_isp_calibration; - - //sensor calibration - handle->pCus_sensor_SetAEGain_cal = pCus_SetAEGain_cal_isp_calibration; - handle->pCus_sensor_setCaliData_gain_linearity=pCus_setCaliData_gain_linearity_isp_calibration; - handle->pCus_sensor_GetShutterInfo = IMX307_GetShutterInfo_isp_calibration; -#if 0//defined(__MV5_FPGA__) - handle->pCus_sensor_I2CWrite = pCus_I2CWrite_isp_calibration; //Andy Liu - handle->pCus_sensor_I2CRead = pCus_I2CRead_isp_calibration; //Andy Liu -#endif - params->expo.vts=vts_30fps; - params->expo.expo_lines = 673; - if (CUS_CMU_CLK_36MHZ == handle->mclk) - params->expo.fps = 29; - else - params->expo.fps = 30; - params->dirty = false; - - return SUCCESS; -} -//lef functions -static int pCus_init_hdr_dol_lef(ms_cus_sensor *handle) -{ - return SUCCESS; -} - -static int pCus_poweron_hdr_dol_lef(ms_cus_sensor *handle, u32 idx) -{ -#if 0 - ISensorIfAPI *sensor_if = handle->sensor_if_api; - SENSOR_DMSG( "[%s] ", __FUNCTION__ ); - - sensor_if->PowerOff(CUS_SENSOR_PAD_GROUP_B/*TBD?*/, !handle->pwdn_POLARITY ); - MsSleep(RTK_MS_TO_TICK(10));//usleep( 500 ); - - //sensor_if->Reset(CUS_SENSOR_PAD_GROUP_B, !handle->reset_POLARITY ); - //MsSleep(RTK_MS_TO_TICK(5));//usleep( 500 ); - - // pure power on - sensor_if->PowerOff(CUS_SENSOR_PAD_GROUP_B/*TBD?*/, !handle->pwdn_POLARITY ); -#endif - return SUCCESS; -} - -static int pCus_poweroff_hdr_dol_lef(ms_cus_sensor *handle, u32 idx) -{ -#if 0 - ISensorIfAPI *sensor_if = handle->sensor_if_api; - SENSOR_DMSG( "[%s] power low\n", __FUNCTION__ ); - - sensor_if->PowerOff(CUS_SENSOR_PAD_GROUP_B/*TBD?*/, handle->pwdn_POLARITY ); - MsSleep(RTK_MS_TO_TICK(5));//usleep( 1000 ); -#endif - return SUCCESS; -} - -static int pCus_GetSensorID_hdr_dol_lef(ms_cus_sensor *handle, u32 *id) -{ - *id = 0; - return SUCCESS; -} -#if 0 -static int pCus_GetOrien_hdr_dol_lef(ms_cus_sensor *handle, CUS_CAMSENSOR_ORIT *orit) -{ - *orit = CUS_ORIT_M0F0; - return SUCCESS; -} - -static int pCus_SetOrien_hdr_dol_lef(ms_cus_sensor *handle, CUS_CAMSENSOR_ORIT orit) -{ - return SUCCESS; -} -#endif - -static int pCus_GetFPS_hdr_dol_lef(ms_cus_sensor *handle) -{ - imx307_params *params = (imx307_params *)handle->private_data; - u32 cur_vts_30fps = vts_30fps_HDR_DOL_4lane; - u32 max_fps = handle->video_res_supported.res[handle->video_res_supported.ulcur_res].max_fps; - u32 tVts = (params->tVts_reg[0].data << 16) | (params->tVts_reg[1].data << 8) | (params->tVts_reg[2].data << 0); - - if(2 == handle->interface_attr.attr_mipi.mipi_lane_num) - { - cur_vts_30fps = vts_30fps_HDR_DOL_2lane; - } - else if(4 == handle->interface_attr.attr_mipi.mipi_lane_num) - { - cur_vts_30fps = vts_30fps_HDR_DOL_4lane; - } - - if (params->expo.fps >= 3000) - params->expo.preview_fps = (cur_vts_30fps*max_fps*1000)/tVts; - else - params->expo.preview_fps = (cur_vts_30fps*max_fps)/tVts; - - return params->expo.preview_fps; -} - -static int pCus_SetFPS_hdr_dol_lef(ms_cus_sensor *handle, u32 fps) -{ - u32 vts = 0, cur_vts_30fps = vts_30fps_HDR_DOL_4lane; - imx307_params *params = (imx307_params *)handle->private_data; - - if(2 == handle->interface_attr.attr_mipi.mipi_lane_num) - { - cur_vts_30fps = vts_30fps_HDR_DOL_2lane; - } - else if(4 == handle->interface_attr.attr_mipi.mipi_lane_num) - { - cur_vts_30fps = vts_30fps_HDR_DOL_4lane; - } - - if(fps>=3 && fps <= 30){ - if (CUS_CMU_CLK_36MHZ == handle->mclk) - fps = fps>29?29:fps;//limit fps at 29 fps due to MCLK=36MHz - params->expo.fps = fps; - if (CUS_CMU_CLK_36MHZ == handle->mclk) - params->expo.vts= (cur_vts_30fps*29091 + fps * 500 )/ (fps * 1000); - else - params->expo.vts= (cur_vts_30fps*30000 + fps * 500 )/ (fps * 1000); - params->dirty = true; - }else if(fps>=3000 && fps <= 30000){ - if (CUS_CMU_CLK_36MHZ == handle->mclk) - fps = fps>29091?29091:fps;//limit fps at 29.091 fps due to MCLK=36MHz - params->expo.fps = fps; - if (CUS_CMU_CLK_36MHZ == handle->mclk) - params->expo.vts= (cur_vts_30fps*29091 + (fps >> 1))/fps; - else - params->expo.vts= (cur_vts_30fps*30000 + (fps >> 1))/fps; - params->dirty = true; - }else{ - //params->expo.vts=vts_30fps; - //params->expo.fps=30; - SENSOR_DMSG("[%s] FPS %d out of range.\n",__FUNCTION__,fps); - return FAIL; - } - - if(params->expo.expo_lines > 2 * params->expo.vts - params->max_rhs1 -3){ - vts = (params->expo.expo_lines + params->max_rhs1 + 3 + 1) / 2; - }else{ - vts = params->expo.vts; - } - - params->expo.vts = vts; - params->skip_cnt = 1; - pCus_SetAEUSecsHDR_DOL_LEF(handle, params->expo.expo_lef_us); - - return SUCCESS; -} -#if 0 -static int pCus_GetSensorCap_hdr_dol_lef(ms_cus_sensor *handle, CUS_CAMSENSOR_CAP *cap) -{ - if (cap) - memcpy(cap, &sensor_cap, sizeof(CUS_CAMSENSOR_CAP)); - else return FAIL; - return SUCCESS; -} -#endif -static int imx307_SetPatternMode_hdr_dol_lef(ms_cus_sensor *handle,u32 mode) -{ - return SUCCESS; -} - -static int pCus_AEStatusNotifyHDR_DOL_LEF(ms_cus_sensor *handle, CUS_CAMSENSOR_AE_STATUS_NOTIFY status) -{ - imx307_params *params = (imx307_params *)handle->private_data; - ISensorIfAPI *sensor_if = handle->sensor_if_api; - - switch(status) - { - case CUS_FRAME_INACTIVE: - //SensorReg_Write(0x3001,0); - break; - case CUS_FRAME_ACTIVE: - if(params->dirty || params->orien_dirty) - { - SensorReg_Write(0x3001,1); - SensorRegArrayW((I2C_ARRAY*)params->tShs2_reg, ARRAY_SIZE(expo_SHS2_reg)); - SensorRegArrayW((I2C_ARRAY*)params->tVts_reg, ARRAY_SIZE(vts_reg)); - SensorRegArrayW((I2C_ARRAY*)params->tRhs1_reg, ARRAY_SIZE(expo_RHS1_reg)); - SensorRegArrayW((I2C_ARRAY*)params->tExpo_reg, ARRAY_SIZE(expo_reg)); - SensorRegArrayW((I2C_ARRAY*)params->tGain_hdr_dol_lef_reg, ARRAY_SIZE(gain_HDR_DOL_LEF_reg)); - SensorRegArrayW((I2C_ARRAY*)params->tGain_hdr_dol_sef_reg, ARRAY_SIZE(gain_HDR_DOL_SEF1_reg)); - params->dirty = false; - - if(params->orien_dirty) - { - DoOrien(handle, handle->orient); - params->orien_dirty = false; - } - SensorReg_Write(0x3001,0); - } - - if(params->skip_cnt){ - sensor_if->SetSkipFrame(handle->snr_pad_group, params->expo.fps, params->skip_cnt); - params->skip_cnt = 0; - } - break; - default : - break; - } - return SUCCESS; -} - -static int pCus_GetAEUSecs_hdr_dol_lef(ms_cus_sensor *handle, u32 *us) -{ - *us = 0; - return SUCCESS; -} - -static int pCus_SetAEUSecsHDR_DOL_LEF(ms_cus_sensor *handle, u32 us) -{ - u32 vts = 0, fsc = 0, cur_line_period = Preview_line_period_HDR_DOL_4LANE; - //u32 cur_vts_30fps = vts_30fps_HDR_DOL_4lane; - imx307_params *params = (imx307_params *)handle->private_data; - - params->expo.expo_lef_us = us; - - if(2 == handle->interface_attr.attr_mipi.mipi_lane_num) - { - cur_line_period = Preview_line_period_HDR_DOL_2LANE; - //cur_vts_30fps =vts_30fps_HDR_DOL_2lane; - } - else if(4 == handle->interface_attr.attr_mipi.mipi_lane_num) - { - cur_line_period = Preview_line_period_HDR_DOL_4LANE; - //cur_vts_30fps =vts_30fps_HDR_DOL_4lane; - } - - params->expo.expo_lines = (1000 * us + (cur_line_period >> 1)) / cur_line_period; - - if (params->expo.expo_lines > 2 * params->expo.vts - params->max_rhs1 - 3) { - vts = (params->expo.expo_lines + params->max_rhs1 + 3 + 1) / 2; - } - else{ - vts = params->expo.vts; - } - - // lines=us/Preview_line_period_HDR_DOL_4LANE; - SENSOR_DMSG("[%s] us %u, lines %u, vts %u\n", __FUNCTION__, - us, - params->expo.expo_lines, - params->expo.vts - ); - - fsc = vts * 2; - - if(params->expo.expo_lines <= 1) { - params->expo.expo_lines = 1; - } - - if(params->expo.expo_lines > fsc - 104) { - params->expo.expo_lines = fsc - 104; - } - - params->lef_shs2 = fsc - params->expo.expo_lines - 1; - - params->tShs2_reg[0].data = (params->lef_shs2 >> 16) & 0x0003; - params->tShs2_reg[1].data = (params->lef_shs2 >> 8) & 0x00ff; - params->tShs2_reg[2].data = (params->lef_shs2 >> 0) & 0x00ff; - - params->tVts_reg[0].data = (vts >> 16) & 0x0003; - params->tVts_reg[1].data = (vts >> 8) & 0x00ff; - params->tVts_reg[2].data = (vts >> 0) & 0x00ff; - - params->dirty = true; - return SUCCESS; -} - -static int pCus_GetAEGain_hdr_dol_lef(ms_cus_sensor *handle, u32* gain) -{ - *gain = 0; - return SUCCESS; -} - -static int pCus_SetAEGainHDR_DOL_LEF(ms_cus_sensor *handle, u32 gain) -{ - imx307_params *params = (imx307_params *)handle->private_data; - u16 gain_reg = 0; - - - pCus_SetAEGainHDR_DOL_Calculate(gain, &gain_reg); - params->tGain_hdr_dol_lef_reg[0].data = gain_reg; - - SENSOR_DMSG("[%s] set gain/reg=%u/0x%x\n", __FUNCTION__, gain, params->tGain_hdr_dol_lef_reg[0].data); - - params->dirty = true; - return SUCCESS; -} - -static int pCus_GetAEMinMaxGain_hdr_dol_lef(ms_cus_sensor *handle, u32 *min, u32 *max) -{ - *min = handle->sat_mingain; - *max = 3980*1024; - return SUCCESS; -} - -static int pCus_GetAEMinMaxUSecs_hdr_dol_lef(ms_cus_sensor *handle, u32 *min, u32 *max) -{ - *min = 1; - *max = 1000000/Preview_MIN_FPS; - return SUCCESS; -} - -//static int pCus_GetDGainRemainder(ms_cus_sensor *handle, u32 *dgain_remainder) -//{ -// *dgain_remainder = handle->dgain_remainder; - -// return SUCCESS; -//} - -static int pCus_SetAEGain_cal_hdr_dol_lef(ms_cus_sensor *handle, u32 gain) -{ - return SUCCESS; -} - -static int pCus_setCaliData_gain_linearity_hdr_dol_lef(ms_cus_sensor* handle, CUS_GAIN_GAP_ARRAY* pArray, u32 num) -{ - return SUCCESS; -} - -static int IMX307_GetShutterInfo_hdr_dol_lef(struct __ms_cus_sensor* handle,CUS_SHUTTER_INFO *info) -{ - info->max = 1000000000/Preview_MIN_FPS; - info->min = (Preview_line_period_HDR_DOL_4LANE * 5); - info->step = Preview_line_period_HDR_DOL_4LANE; - return SUCCESS; -} -#if 0 -static int pCus_I2CWrite_hdr_dol_lef(ms_cus_sensor *handle, unsigned short usreg, unsigned short usval) -{ - return SUCCESS; -} - -static int pCus_I2CRead_hdr_dol_lef(ms_cus_sensor *handle, unsigned short usreg) -{ - return SUCCESS; -} -#endif -// -static int cus_camsensor_init_handle_hdr_dol_lef(ms_cus_sensor* drv_handle) -{ - ms_cus_sensor *handle = drv_handle; - imx307_params *params; - - if (!handle) { - SENSOR_DMSG("[%s] not enough memory!\n", __FUNCTION__); - return FAIL; - } - SENSOR_DMSG("[%s]", __FUNCTION__); - //private data allocation & init - if (handle->private_data == NULL) { - SENSOR_EMSG("[%s] Private data is empty!\n", __FUNCTION__); - return FAIL; - } - params = (imx307_params *)handle->private_data; - memcpy(params->tGain_reg, gain_reg, sizeof(gain_reg)); - memcpy(params->tExpo_reg, expo_reg, sizeof(expo_reg)); - memcpy(params->tVts_reg, vts_reg, sizeof(vts_reg)); - memcpy(params->tRhs1_reg, expo_RHS1_reg, sizeof(expo_RHS1_reg)); - memcpy(params->tShs2_reg, expo_SHS2_reg, sizeof(expo_SHS2_reg)); - memcpy(params->tGain_hdr_dol_lef_reg, gain_HDR_DOL_LEF_reg, sizeof(gain_HDR_DOL_LEF_reg)); - memcpy(params->tGain_hdr_dol_sef_reg, gain_HDR_DOL_SEF1_reg, sizeof(gain_HDR_DOL_SEF1_reg)); - - //////////////////////////////////// - // sensor model ID // - //////////////////////////////////// - sprintf(handle->model_id,"IMX307_MIPI_HDR_LEF"); - - //////////////////////////////////// - // sensor interface info // - //////////////////////////////////// - //SENSOR_DMSG("[%s] entering function with id %d\n", __FUNCTION__, id); - handle->isp_type = SENSOR_ISP_TYPE; //ISP_SOC; - //handle->data_fmt = SENSOR_DATAFMT; //CUS_DATAFMT_YUV; - handle->sif_bus = SENSOR_IFBUS_TYPE;//CUS_SENIF_BUS_PARL; - handle->data_prec = SENSOR_DATAPREC_DOL; //CUS_DATAPRECISION_8; - handle->data_mode = SENSOR_DATAMODE; - handle->bayer_id = SENSOR_BAYERID_HDR_DOL; //CUS_BAYER_GB; - handle->RGBIR_id = SENSOR_RGBIRID; - handle->orient = SENSOR_ORIT; //CUS_ORIT_M1F1; - //handle->YC_ODER = SENSOR_YCORDER; //CUS_SEN_YCODR_CY; - handle->interface_attr.attr_mipi.mipi_lane_num = hdr_lane_num; - handle->interface_attr.attr_mipi.mipi_data_format = CUS_SEN_INPUT_FORMAT_RGB; // RGB pattern. - handle->interface_attr.attr_mipi.mipi_yuv_order = 0; //don't care in RGB pattern. - handle->interface_attr.attr_mipi.mipi_hsync_mode = SENSOR_MIPI_HSYNC_MODE_HDR_DOL; - handle->interface_attr.attr_mipi.mipi_hdr_mode = CUS_HDR_MODE_SONY_DOL; - handle->interface_attr.attr_mipi.mipi_hdr_virtual_channel_num = 0; //Long frame - - //////////////////////////////////// - // resolution capability // - //////////////////////////////////// - - handle->video_res_supported.num_res = 1; - handle->video_res_supported.ulcur_res = 0; //default resolution index is 0. - handle->video_res_supported.res[0].width = Preview_WIDTH; - handle->video_res_supported.res[0].height = Preview_HEIGHT_HDR_DOL; //TBD. Workaround for Sony DOL HDR mode - handle->video_res_supported.res[0].max_fps= Preview_MAX_FPS; - handle->video_res_supported.res[0].min_fps= Preview_MIN_FPS; - handle->video_res_supported.res[0].crop_start_x= Preview_CROP_START_X; - handle->video_res_supported.res[0].crop_start_y= Preview_CROP_START_Y; - handle->video_res_supported.res[0].nOutputWidth = 0x79C; - handle->video_res_supported.res[0].nOutputHeight = 0x449; - sprintf(handle->video_res_supported.res[0].strResDesc, "1920x1080@30fps_HDR"); - - // i2c - handle->i2c_cfg.mode = SENSOR_I2C_LEGACY; //(CUS_ISP_I2C_MODE) FALSE; - handle->i2c_cfg.fmt = SENSOR_I2C_FMT; //CUS_I2C_FMT_A16D16; - handle->i2c_cfg.address = SENSOR_I2C_ADDR; //0x5a; - handle->i2c_cfg.speed = SENSOR_I2C_SPEED; //320000; - - // mclk - handle->mclk = UseParaMclk(SENSOR_DRV_PARAM_MCLK()); - - //polarity - ///////////////////////////////////////////////////// - handle->pwdn_POLARITY = SENSOR_PWDN_POL; //CUS_CLK_POL_NEG; - handle->reset_POLARITY = SENSOR_RST_POL; //CUS_CLK_POL_NEG; - //handle->VSYNC_POLARITY = SENSOR_VSYNC_POL; //CUS_CLK_POL_POS; - //handle->HSYNC_POLARITY = SENSOR_HSYNC_POL; //CUS_CLK_POL_POS; - //handle->PCLK_POLARITY = SENSOR_PCLK_POL; //CUS_CLK_POL_POS); // use '!' to clear board latch error - ///////////////////////////////////////////////////// - - - - //////////////////////////////////////////////////// - // AE parameters - //////////////////////////////////////////////////// - handle->ae_gain_delay = SENSOR_GAIN_DELAY_FRAME_COUNT_DOL; - handle->ae_shutter_delay = SENSOR_SHUTTER_DELAY_FRAME_COUNT_DOL; - - handle->ae_gain_ctrl_num = 2; - handle->ae_shutter_ctrl_num = 2; - - ///calibration - handle->sat_mingain = SENSOR_MIN_GAIN;//g_sensor_ae_min_gain; - //handle->dgain_remainder = 0; - - //LOGD("[%s:%d]\n", __FUNCTION__, __LINE__); - handle->pCus_sensor_release = cus_camsensor_release_handle; - handle->pCus_sensor_init = pCus_init_hdr_dol_lef; - //handle->pCus_sensor_powerupseq = pCus_powerupseq ; - handle->pCus_sensor_poweron = pCus_poweron_hdr_dol_lef; - handle->pCus_sensor_poweroff = pCus_poweroff_hdr_dol_lef; - - // Normal - handle->pCus_sensor_GetSensorID = pCus_GetSensorID_hdr_dol_lef; - - handle->pCus_sensor_GetVideoResNum = NULL; - handle->pCus_sensor_GetVideoRes = NULL; - handle->pCus_sensor_GetCurVideoRes = NULL; - handle->pCus_sensor_SetVideoRes = NULL; - - handle->pCus_sensor_GetOrien = pCus_GetOrien; - handle->pCus_sensor_SetOrien = pCus_SetOrien; - handle->pCus_sensor_GetFPS = pCus_GetFPS_hdr_dol_lef; - handle->pCus_sensor_SetFPS = pCus_SetFPS_hdr_dol_lef; - //handle->pCus_sensor_GetSensorCap = pCus_GetSensorCap_hdr_dol_lef; - handle->pCus_sensor_SetPatternMode = imx307_SetPatternMode_hdr_dol_lef; - /////////////////////////////////////////////////////// - // AE - /////////////////////////////////////////////////////// - // unit: micro seconds - //handle->pCus_sensor_GetAETrigger_mode = pCus_GetAETrigger_mode; - //handle->pCus_sensor_SetAETrigger_mode = pCus_SetAETrigger_mode; - handle->pCus_sensor_AEStatusNotify = pCus_AEStatusNotifyHDR_DOL_LEF; - handle->pCus_sensor_GetAEUSecs = pCus_GetAEUSecs_hdr_dol_lef; - handle->pCus_sensor_SetAEUSecs = pCus_SetAEUSecsHDR_DOL_LEF; - handle->pCus_sensor_GetAEGain = pCus_GetAEGain_hdr_dol_lef; - //handle->pCus_sensor_SetAEGain = pCus_SetAEGain_hdr_dol_lef; - handle->pCus_sensor_SetAEGain = pCus_SetAEGainHDR_DOL_LEF; - - handle->pCus_sensor_GetAEMinMaxGain = pCus_GetAEMinMaxGain_hdr_dol_lef; - handle->pCus_sensor_GetAEMinMaxUSecs= pCus_GetAEMinMaxUSecs_hdr_dol_lef; - //handle->pCus_sensor_GetDGainRemainder = pCus_GetDGainRemainder; - - //sensor calibration - handle->pCus_sensor_SetAEGain_cal = pCus_SetAEGain_cal_hdr_dol_lef; - handle->pCus_sensor_setCaliData_gain_linearity=pCus_setCaliData_gain_linearity_hdr_dol_lef; - handle->pCus_sensor_GetShutterInfo = IMX307_GetShutterInfo_hdr_dol_lef; - - params->expo.vts = vts_30fps_HDR_DOL_4lane; - params->expo.expo_lines = 673; - if (CUS_CMU_CLK_36MHZ == handle->mclk) - params->expo.fps = 29; - else - params->expo.fps = 30; - - params->dirty = false; - - return SUCCESS; -} - -static int cus_camsensor_release_handle(ms_cus_sensor *handle) -{ - return SUCCESS; -} - -static CUS_MCLK_FREQ UseParaMclk(const char *mclk) -{ -/* - CUS_CMU_CLK_27MHZ, - CUS_CMU_CLK_21P6MHZ, - CUS_CMU_CLK_12MHZ, - CUS_CMU_CLK_5P4MHZ, - CUS_CMU_CLK_36MHZ, - CUS_CMU_CLK_54MHZ, - CUS_CMU_CLK_43P2MHZ, - CUS_CMU_CLK_61P7MHZ, - CUS_CMU_CLK_72MHZ, - CUS_CMU_CLK_48MHZ, - CUS_CMU_CLK_24MHZ, - CUS_CMU_CLK_37P125MHZ, -*/ - if (strcmp(mclk, "27M") == 0) { - return CUS_CMU_CLK_27MHZ; - } else if (strcmp(mclk, "12M") == 0) { - return CUS_CMU_CLK_12MHZ; - } else if (strcmp(mclk, "36M") == 0) { - return CUS_CMU_CLK_36MHZ; - } else if (strcmp(mclk, "48M") == 0) { - return CUS_CMU_CLK_48MHZ; - } else if (strcmp(mclk, "54M") == 0) { - return CUS_CMU_CLK_54MHZ; - } else if (strcmp(mclk, "24M") == 0) { - return CUS_CMU_CLK_24MHZ; - } else if (strcmp(mclk, "37.125M") == 0) { - return CUS_CMU_CLK_37P125MHZ; - } - - return Preview_MCLK_SPEED; -} - -SENSOR_DRV_ENTRY_IMPL_END_EX( IMX307_HDR, - cus_camsensor_init_handle, - cus_camsensor_init_handle_hdr_dol_sef1, - cus_camsensor_init_handle_hdr_dol_lef, - imx307_params - ); diff --git a/general/package/sigmastar-osdrv-sensor/src/infinity6b0/sensor/sensor_imx335_mipi.c b/general/package/sigmastar-osdrv-sensor/src/infinity6b0/sensor/sensor_imx335_mipi.c deleted file mode 100644 index ee11c3b4..00000000 --- a/general/package/sigmastar-osdrv-sensor/src/infinity6b0/sensor/sensor_imx335_mipi.c +++ /dev/null @@ -1,3707 +0,0 @@ -/* Copyright (c) 2018-2019 Sigmastar Technology Corp. - All rights reserved. - - Unless otherwise stipulated in writing, any and all information contained -herein regardless in any format shall remain the sole proprietary of -Sigmastar Technology Corp. and be kept in strict confidence -(Sigmastar Confidential Information) by the recipient. -Any unauthorized act including without limitation unauthorized disclosure, -copying, use, reproduction, sale, distribution, modification, disassembling, -reverse engineering and compiling of the contents of Sigmastar Confidential -Information is unlawful and strictly prohibited. Sigmastar hereby reserves the -rights to any and all damages, losses, costs and expenses resulting therefrom. -*/ - -#ifdef __cplusplus -extern "C" -{ -#endif - -#include -#include -#include - -#ifdef __cplusplus -} -#endif - -SENSOR_DRV_ENTRY_IMPL_BEGIN_EX(IMX335_HDR); - -#ifndef ARRAY_SIZE -#define ARRAY_SIZE CAM_OS_ARRAY_SIZE -#endif - -//#define SENSOR_PAD_GROUP_SET CUS_SENSOR_PAD_GROUP_A -//#define SENSOR_CHANNEL_NUM (0) -#define SENSOR_CHANNEL_MODE CUS_SENSOR_CHANNEL_MODE_REALTIME_NORMAL -#define SENSOR_CHANNEL_MODE_SONY_DOL CUS_SENSOR_CHANNEL_MODE_RAW_STORE_HDR - -//============================================ -#define ENABLE 1 -#define DISABLE 0 -#undef SENSOR_DBG -#define SENSOR_DBG 0 - -#define DEBUG_INFO 0 - -#if SENSOR_DBG == 1 -//#define SENSOR_DMSG(args...) LOGD(args) -//#define SENSOR_DMSG(args...) LOGE(args) -//#define SENSOR_DMSG(args...) printf(args) -#elif SENSOR_DBG == 0 -//#define SENSOR_DMSG(args...) -#endif -/////////////////////////////////////////////////////////////// -// @@@ // -// @ @@ == S t a r t * H e r e == // -// @@ == S t a r t * H e r e == // -// @@ == S t a r t * H e r e == // -// @@@@ // -// // -// Start Step 1 -- show preview on LCM // -// // -// Fill these #define value and table with correct settings // -// camera can work and show preview on LCM // -// // -/////////////////////////////////////////////////////////////// - -//////////////////////////////////// -// Sensor-If Info // -//////////////////////////////////// -//MIPI config begin. -#define SENSOR_MIPI_LANE_NUM (lane_num) //IMX335 Linear mode supports MIPI 2/4 Lane -#define SENSOR_MIPI_LANE_NUM_DOL (4) //(hdr_lane_num)//IMX335 DOL mode supports MIPI 4 Lane -//#define SENSOR_MIPI_HDR_MODE (0) //0: Non-HDR mode. 1:Sony DOL mode - -#define SENSOR_ISP_TYPE ISP_EXT //ISP_EXT, ISP_SOC (Non-used) -//#define SENSOR_DATAFMT CUS_DATAFMT_BAYER //CUS_DATAFMT_YUV, CUS_DATAFMT_BAYER -#define SENSOR_IFBUS_TYPE CUS_SENIF_BUS_MIPI //CFG //CUS_SENIF_BUS_PARL, CUS_SENIF_BUS_MIPI -#define SENSOR_MIPI_HSYNC_MODE PACKET_HEADER_EDGE1 -#define SENSOR_MIPI_HSYNC_MODE_HDR_DOL PACKET_FOOTER_EDGE -#define SENSOR_DATAPREC CUS_DATAPRECISION_10 -#define SENSOR_DATAPREC_DOL CUS_DATAPRECISION_10 -#define SENSOR_DATAMODE CUS_SEN_10TO12_9098 //CFG -#define SENSOR_BAYERID CUS_BAYER_RG //0h: CUS_BAYER_RG, 1h: CUS_BAYER_GR, 2h: CUS_BAYER_BG, 3h: CUS_BAYER_GB -#define SENSOR_BAYERID_HDR_DOL CUS_BAYER_RG -#define SENSOR_RGBIRID CUS_RGBIR_NONE -#define SENSOR_ORIT CUS_ORIT_M0F0 //CUS_ORIT_M0F0, CUS_ORIT_M1F0, CUS_ORIT_M0F1, CUS_ORIT_M1F1, -//#define SENSOR_YCORDER CUS_SEN_YCODR_YC //CUS_SEN_YCODR_YC, CUS_SEN_YCODR_CY -//#define long_packet_type_enable 0x00 //UD1~UD8 (user define) - -//////////////////////////////////// -// MCLK Info // -//////////////////////////////////// -#define Preview_MCLK_SPEED CUS_CMU_CLK_27MHZ //CUS_CMU_CLK_24MHZ //CUS_CMU_CLK_37P125MHZ//CUS_CMU_CLK_27MHZ -#define Preview_MCLK_SPEED_HDR_DOL CUS_CMU_CLK_27MHZ - -//////////////////////////////////// -// I2C Info // -//////////////////////////////////// -#define SENSOR_I2C_ADDR 0x34 //I2C slave address -#define SENSOR_I2C_SPEED 300000 //200000 //300000 //240000 //I2C speed, 60000~320000 -//#define SENSOR_I2C_CHANNEL 1 //I2C Channel -//#define SENSOR_I2C_PAD_MODE 2 //Pad/Mode Number -#define SENSOR_I2C_LEGACY I2C_NORMAL_MODE //usally set CUS_I2C_NORMAL_MODE, if use old OVT I2C protocol=> set CUS_I2C_LEGACY_MODE -#define SENSOR_I2C_FMT I2C_FMT_A16D8 //CUS_I2C_FMT_A8D8, CUS_I2C_FMT_A8D16, CUS_I2C_FMT_A16D8, CUS_I2C_FMT_A16D16 - -//////////////////////////////////// -// Sensor Signal // -//////////////////////////////////// -#define SENSOR_PWDN_POL CUS_CLK_POL_NEG // if PWDN pin High can makes sensor in power down, set CUS_CLK_POL_POS -#define SENSOR_RST_POL CUS_CLK_POL_NEG // if RESET pin High can makes sensor in reset state, set CUS_CLK_POL_NEG - // VSYNC/HSYNC POL can be found in data sheet timing diagram, - // Notice: the initial setting may contain VSYNC/HSYNC POL inverse settings so that condition is different. -#define SENSOR_VSYNC_POL CUS_CLK_POL_NEG // if VSYNC pin High and data bus have data, set CUS_CLK_POL_POS -#define SENSOR_HSYNC_POL CUS_CLK_POL_NEG // if HSYNC pin High and data bus have data, set CUS_CLK_POL_POS -#define SENSOR_PCLK_POL CUS_CLK_POL_NEG // depend on sensor setting, sometimes need to try CUS_CLK_POL_POS or CUS_CLK_POL_NEG - -//////////////////////////////////// -// Sensor ID // -//////////////////////////////////// -//define SENSOR_ID - -#undef SENSOR_NAME -#define SENSOR_NAME IMX335 - -//////////////////////////////////// -// Image Info // -//////////////////////////////////// -static struct { // LINEAR - // Modify it based on number of support resolution - enum {LINEAR_RES_1 = 0, LINEAR_RES_2, LINEAR_RES_END}mode; - // Sensor Output Image info - struct _senout{ - s32 width, height, min_fps, max_fps; - }senout; - // VIF Get Image Info - struct _sensif{ - s32 crop_start_X, crop_start_y, preview_w, preview_h; - }senif; - // Show resolution string - struct _senstr{ - const char* strResDesc; - }senstr; -}imx335_mipi_linear[] = { - {LINEAR_RES_1, {2592, 1944, 3, 25}, {0, 0, 2592, 1944}, {"2592x1944@25fps"}}, - {LINEAR_RES_2, {2592, 1944, 3, 30}, {0, 0, 2592, 1944}, {"2592x1944@30fps"}}, // Modify it -}; - -static struct { // HDR - // Modify it based on number of support resolution - enum {HDR_RES_1 = 0, HDR_RES_2, HDR_RES_3, HDR_RES_END}mode; - // Sensor Output Image info - struct _hsenout{ - s32 width, height, min_fps, max_fps; - }senout; - // VIF Get Image Info - struct _hsensif{ - s32 crop_start_X, crop_start_y, preview_w, preview_h; - }senif; - // Show resolution string - struct _hsenstr{ - const char* strResDesc; - }senstr; -}imx335_mipi_hdr[] = { - {HDR_RES_1, {2592, 1944, 3, 25}, {4, 0, 2592, 1944}, {"2592x1944@25fps_HDR"}}, // Modify it - {HDR_RES_2, {2592, 1944, 3, 20}, {4, 0, 2592, 1944}, {"2592x1944@20fps_HDR"}}, // Modify it - {HDR_RES_3, {2592, 1944, 3, 30}, {4, 0, 2592, 1944}, {"2592x1944@30fps_HDR"}}, // Modify it -}; - -#define IMX335_HDR_BRL 2228 - -u32 Preview_line_period; -u32 vts_30fps; -u32 Preview_MAX_FPS; -u32 Preview_line_period_HDR_DOL; -u32 vts_30fps_HDR_DOL; - -//#define SENSOR_YCORDER CUS_SEN_YCODR_YC //CUS_SEN_YCODR_YC, CUS_SEN_YCODR_CY -//#define vc0_hs_mode 3 //0: packet header edge 1: line end edge 2: line start edge 3: packet footer edge -//#define long_packet_type_enable 0x00 //UD1~UD8 (user define) -//////////////////////////////////// -// AE Info // -//////////////////////////////////// -#define SENSOR_MAX_GAIN (1412 * 1024) // max sensor again, a-gain * conversion-gain*d-gain -#define SENSOR_MIN_GAIN (1 * 1024) -#define SENSOR_GAIN_DELAY_FRAME_COUNT (2) -#define SENSOR_SHUTTER_DELAY_FRAME_COUNT (2) -#define SENSOR_GAIN_DELAY_FRAME_COUNT_HDR_DOL (1) -#define SENSOR_SHUTTER_DELAY_FRAME_COUNT_HDR_DOL (2) - -//////////////////////////////////// -// Mirror-Flip Info // -//////////////////////////////////// -#define REG_MIRROR 0x304E -#define REG_FLIP 0x304F -#define SENSOR_NOR 0x0 -#define MIRROR_EN 0x1 << (0) -#define FLIP_EN 0x1 << (0) - -#if defined (SENSOR_MODULE_VERSION) -#define TO_STR_NATIVE(e) #e -#define TO_STR_PROXY(m, e) m(e) -#define MACRO_TO_STRING(e) TO_STR_PROXY(TO_STR_NATIVE, e) -static char *sensor_module_version = MACRO_TO_STRING(SENSOR_MODULE_VERSION); -module_param(sensor_module_version, charp, S_IRUGO); -#endif - -//static int pCus_SetAEGain(ms_cus_sensor *handle, u32 gain); -static int pCus_SetAEUSecs(ms_cus_sensor *handle, u32 us); -//static int pCus_SetFPS(ms_cus_sensor *handle, u32 fps); -static int pCus_SetOrien(ms_cus_sensor *handle, CUS_CAMSENSOR_ORIT orit); -static int pCus_SetAEUSecsHDR_DOL_SEF1(ms_cus_sensor *handle, u32 us); -static int pCus_SetAEUSecsHDR_DOL_LEF(ms_cus_sensor *handle, u32 us); - -typedef struct { - struct { - u16 pre_div0; - u16 div124; - u16 div_cnt7b; - u16 sdiv0; - u16 mipi_div0; - u16 r_divp; - u16 sdiv1; - u16 r_seld5; - u16 r_sclk_dac; - u16 sys_sel; - u16 pdac_sel; - u16 adac_sel; - u16 pre_div_sp; - u16 r_div_sp; - u16 div_cnt5b; - u16 sdiv_sp; - u16 div12_sp; - u16 mipi_lane_sel; - u16 div_dac; - } clk_tree; - struct { - bool bVideoMode; - u16 res_idx; - // bool binning; - // bool scaling; - CUS_CAMSENSOR_ORIT orit; - } res; - struct { - float sclk; - u32 hts; - u32 vts; - u32 ho; - u32 xinc; - u32 line_freq; - u32 us_per_line; - u32 final_us; - u32 final_gain; - u32 back_pv_us; - u32 fps; - u32 preview_fps; - u32 expo_lines; - u32 expo_lef_us; - u32 expo_sef_us; - } expo; - u32 max_rhs1; - int sen_init; - int still_min_fps; - int video_min_fps; - bool dirty; - bool orien_dirty; - I2C_ARRAY tVts_reg[3]; - I2C_ARRAY tGain_reg[2]; - I2C_ARRAY tExpo_reg[3]; - I2C_ARRAY tExpo_shr_dol1_reg[3]; - I2C_ARRAY tExpo_rhs1_reg[3]; - I2C_ARRAY tGain_hdr_dol_lef_reg[2]; - I2C_ARRAY tGain_hdr_dol_sef_reg[2]; -} imx335_params; -// set sensor ID address and data, - -const static I2C_ARRAY Sensor_id_table[] = -{ - {0x3003, 0x00}, // {address of ID, ID }, - {0x3033, 0x00} -}; - -const static I2C_ARRAY Sensor_init_table_2lane_5m25fps[] = -{ - /*"IMX335LQN All-pixel scan CSI-2_2lane 1188Mbps AD:10bit Output:10bit 27MHz Master Mode 25fps"*/ - {0x3002,0x01}, //Master mode stop - {0xffff,0x14}, //delay - {0x3000,0x01}, //standby - {0xffff,0x14}, //delay - {0x300C,0x42}, //BCWAIT_TIME - {0x300D,0x2E}, //CPWAIT_TIME - {0x3030,0x56}, //VMAX //101Dh: 4125 //1518h: 5400 - {0x3031,0x13}, //VMAX - {0x3032,0x00}, //VMAX - {0x3034,0x58}, //HMAX //2D0h: 720 //226h: 550 - {0x3035,0x02}, //HMAX - {0x3050,0x00}, //ADBIT - {0x314C,0xB0}, //INCKSEL1 - {0x315A,0x02}, //INCKSEL2 - {0x3168,0x8F}, //INCKSEL3 - {0x316A,0x7E}, //INCKSEL4 - {0x319D,0x00}, //MDBIT 0:10Bit 1:12Bit - {0x31A0,0x2A}, //XH&VSOUTSEL - {0x31A1,0x00}, //XVS/XHS pin setting - {0x31A4,0x00}, //PULSE1_UP - {0x31A5,0x00}, //PULSE1_UP - {0x31A6,0x00}, //PULSE1_UP - {0x31A8,0x00}, //PULSE1EN/PULSE1_POL - {0x31AC,0x00}, //PULSE1_DN - {0x31AD,0x00}, //PULSE1_DN - {0x31AE,0x00}, //PULSE1_DN - {0x31D4,0x00}, //XVSLNG - {0x31D5,0x00}, //XHSLNG - {0x31D7,0x00}, - {0x31E4,0x01}, - {0x31F3,0x01}, - {0x3288,0x21}, - {0x328A,0x02}, - {0x3414,0x05}, - {0x3416,0x18}, - {0x341C,0xFF}, //ADBIT1 10Bit:0x01FF 12Bit:0x0047 - {0x341D,0x01}, //ADBIT1 10Bit:0x01FF 12Bit:0x0047 - {0x3648,0x01}, - {0x364A,0x04}, - {0x364C,0x04}, - {0x3678,0x01}, - {0x367C,0x31}, - {0x367E,0x31}, - {0x3706,0x10}, - {0x3708,0x03}, - {0x3714,0x02}, - {0x3715,0x02}, - {0x3716,0x01}, - {0x3717,0x03}, - {0x371C,0x3D}, - {0x371D,0x3F}, - {0x372C,0x00}, - {0x372D,0x00}, - {0x372E,0x46}, - {0x372F,0x00}, - {0x3730,0x89}, - {0x3731,0x00}, - {0x3732,0x08}, - {0x3733,0x01}, - {0x3734,0xFE}, - {0x3735,0x05}, - {0x3740,0x02}, - {0x375D,0x00}, - {0x375E,0x00}, - {0x375F,0x11}, - {0x3760,0x01}, - {0x3768,0x1B}, - {0x3769,0x1B}, - {0x376A,0x1B}, - {0x376B,0x1B}, - {0x376C,0x1A}, - {0x376D,0x17}, - {0x376E,0x0F}, - {0x3776,0x00}, - {0x3777,0x00}, - {0x3778,0x46}, - {0x3779,0x00}, - {0x377A,0x89}, - {0x377B,0x00}, - {0x377C,0x08}, - {0x377D,0x01}, - {0x377E,0x23}, - {0x377F,0x02}, - {0x3780,0xD9}, - {0x3781,0x03}, - {0x3782,0xF5}, - {0x3783,0x06}, - {0x3784,0xA5}, - {0x3788,0x0F}, - {0x378A,0xD9}, - {0x378B,0x03}, - {0x378C,0xEB}, - {0x378D,0x05}, - {0x378E,0x87}, - {0x378F,0x06}, - {0x3790,0xF5}, - {0x3792,0x43}, - {0x3794,0x7A}, - {0x3796,0xA1}, - {0x3A01,0x01}, //LANEMODE 0x03:4Lane 0x01:2Lane - {0x3000,0x00}, - {0x3002,0x00}, -}; - -const static I2C_ARRAY Sensor_init_table_2lane_5m30fps[] = -{ - /*"IMX335LQN All-pixel scan CSI-2_2lane 1188Mbps AD:10bit Output:10bit 27MHz Master Mode 30fps"*/ - {0x3002,0x01}, //Master mode stop - {0xffff,0x14}, //delay - {0x3000,0x01}, //standby - {0xffff,0x14}, //delay - {0x300C,0x42}, //BCWAIT_TIME - {0x300D,0x2E}, //CPWAIT_TIME - {0x3030,0x1D}, //VMAX //1194 :4500 //101D: 4125 - {0x3031,0x10}, //VMAX - {0x3032,0x00}, //VMAX - {0x3034,0x58}, //HMAX //2D0h: 720 //226h: 550 - {0x3035,0x02}, //HMAX - {0x3050,0x00}, //ADBIT - {0x314C,0xB0}, //INCKSEL1 - {0x315A,0x02}, //INCKSEL2 - {0x3168,0x8F}, //INCKSEL3 - {0x316A,0x7E}, //INCKSEL4 - {0x319D,0x00}, //MDBIT 0:10Bit 1:12Bit - {0x31A0,0x2A}, //XH&VSOUTSEL - {0x31A1,0x00}, //XVS/XHS pin setting - {0x31A4,0x00}, //PULSE1_UP - {0x31A5,0x00}, //PULSE1_UP - {0x31A6,0x00}, //PULSE1_UP - {0x31A8,0x00}, //PULSE1EN/PULSE1_POL - {0x31AC,0x00}, //PULSE1_DN - {0x31AD,0x00}, //PULSE1_DN - {0x31AE,0x00}, //PULSE1_DN - {0x31D4,0x00}, //XVSLNG - {0x31D5,0x00}, //XHSLNG - {0x31D7,0x00}, - {0x31E4,0x01}, - {0x31F3,0x01}, - {0x3288,0x21}, - {0x328A,0x02}, - {0x3414,0x05}, - {0x3416,0x18}, - {0x341C,0xFF}, //ADBIT1 10Bit:0x01FF 12Bit:0x0047 - {0x341D,0x01}, //ADBIT1 10Bit:0x01FF 12Bit:0x0047 - {0x3648,0x01}, - {0x364A,0x04}, - {0x364C,0x04}, - {0x3678,0x01}, - {0x367C,0x31}, - {0x367E,0x31}, - {0x3706,0x10}, - {0x3708,0x03}, - {0x3714,0x02}, - {0x3715,0x02}, - {0x3716,0x01}, - {0x3717,0x03}, - {0x371C,0x3D}, - {0x371D,0x3F}, - {0x372C,0x00}, - {0x372D,0x00}, - {0x372E,0x46}, - {0x372F,0x00}, - {0x3730,0x89}, - {0x3731,0x00}, - {0x3732,0x08}, - {0x3733,0x01}, - {0x3734,0xFE}, - {0x3735,0x05}, - {0x3740,0x02}, - {0x375D,0x00}, - {0x375E,0x00}, - {0x375F,0x11}, - {0x3760,0x01}, - {0x3768,0x1B}, - {0x3769,0x1B}, - {0x376A,0x1B}, - {0x376B,0x1B}, - {0x376C,0x1A}, - {0x376D,0x17}, - {0x376E,0x0F}, - {0x3776,0x00}, - {0x3777,0x00}, - {0x3778,0x46}, - {0x3779,0x00}, - {0x377A,0x89}, - {0x377B,0x00}, - {0x377C,0x08}, - {0x377D,0x01}, - {0x377E,0x23}, - {0x377F,0x02}, - {0x3780,0xD9}, - {0x3781,0x03}, - {0x3782,0xF5}, - {0x3783,0x06}, - {0x3784,0xA5}, - {0x3788,0x0F}, - {0x378A,0xD9}, - {0x378B,0x03}, - {0x378C,0xEB}, - {0x378D,0x05}, - {0x378E,0x87}, - {0x378F,0x06}, - {0x3790,0xF5}, - {0x3792,0x43}, - {0x3794,0x7A}, - {0x3796,0xA1}, - {0x3A01,0x01}, //LANEMODE 0x03:4Lane 0x01:2Lane - {0x3000,0x00}, - {0x3002,0x00}, -}; - -const static I2C_ARRAY Sensor_init_table_4lane_5m25fps[] = -{ -/* "IMX335LQN All-pixel scan CSI-2_4lane 1188Mbps AD:10bit Output:10bit 27MHz Master Mode 25fps" */ - {0x3002,0x01}, //Master mode stop - {0xffff,0x14}, //delay - {0x3000,0x01}, //standby - {0xffff,0x14}, //delay - {0x300C,0x42}, - {0x300D,0x2E}, - {0x3030,0x56}, //VMAX //101Dh: 4125 //1518h: 5400 - {0x3031,0x13}, //VMAX - {0x3032,0x00}, //VMAX - {0x3034,0x58}, //HMAX //2D0h: 720 //226h: 550 - {0x3035,0x02}, //HMAX - {0x314C,0xB0}, - {0x315A,0x02}, - {0x3168,0x8F}, - {0x316A,0x7E}, - {0x319D,0x00}, //MDBIT 0:10Bit 1:12Bit - {0x31A0,0x2A}, - {0x31A1,0x00}, - {0x31A4,0x00}, - {0x31A5,0x00}, - {0x31A6,0x00}, - {0x31A8,0x00}, - {0x31AC,0x00}, - {0x31AD,0x00}, - {0x31AE,0x00}, - {0x31D4,0x00}, - {0x31D5,0x00}, - {0x31D7,0x00}, - {0x31E4,0x01}, - {0x31F3,0x01}, - {0x3288,0x21}, - {0x328A,0x02}, - {0x3414,0x05}, - {0x3416,0x18}, - {0x341c,0xFF}, //0x47--12-bit 0xff--10bit - {0x341d,0x01}, //0x00--12-bit 0x01--10bit - {0x3648,0x01}, - {0x364A,0x04}, - {0x364C,0x04}, - {0x3678,0x01}, - {0x367C,0x31}, - {0x367E,0x31}, - {0x3706,0x10}, - {0x3708,0x03}, - {0x3714,0x02}, - {0x3715,0x02}, - {0x3716,0x01}, - {0x3717,0x03}, - {0x371C,0x3D}, - {0x371D,0x3F}, - {0x372C,0x00}, - {0x372D,0x00}, - {0x372E,0x46}, - {0x372F,0x00}, - {0x3730,0x89}, - {0x3731,0x00}, - {0x3732,0x08}, - {0x3733,0x01}, - {0x3734,0xFE}, - {0x3735,0x05}, - {0x3740,0x02}, - {0x375D,0x00}, - {0x375E,0x00}, - {0x375F,0x11}, - {0x3760,0x01}, - {0x3768,0x1B}, - {0x3769,0x1B}, - {0x376A,0x1B}, - {0x376B,0x1B}, - {0x376C,0x1A}, - {0x376D,0x17}, - {0x376E,0x0F}, - {0x3776,0x00}, - {0x3777,0x00}, - {0x3778,0x46}, - {0x3779,0x00}, - {0x377A,0x89}, - {0x377B,0x00}, - {0x377C,0x08}, - {0x377D,0x01}, - {0x377E,0x23}, - {0x377F,0x02}, - {0x3780,0xD9}, - {0x3781,0x03}, - {0x3782,0xF5}, - {0x3783,0x06}, - {0x3784,0xA5}, - {0x3788,0x0F}, - {0x378A,0xD9}, - {0x378B,0x03}, - {0x378C,0xEB}, - {0x378D,0x05}, - {0x378E,0x87}, - {0x378F,0x06}, - {0x3790,0xF5}, - {0x3792,0x43}, - {0x3794,0x7A}, - {0x3796,0xA1}, - //{0x3A18,0x7F}, //TCLKPOST - //{0x3A19,0x00}, //TCLKPOST - //{0x3A1A,0x37}, //TCLKPREPARE - //{0x3A1B,0x00}, //TCLKPREPARE - //{0x3A1C,0x37}, //TCLKTRAIL - //{0x3A1D,0x00}, //TCLKTRAIL - //{0x3A1E,0xF7}, //TCLKZERO - //{0x3A1F,0x00}, //TCLKZERO - //{0x3A20,0x3F}, //THSPREPARE - //{0x3A21,0x00}, //THSPREPARE - //{0x3A22,0x6F}, //THSZERO - //{0x3A23,0x00}, //THSZERO - //{0x3A24,0x3F}, //THSTRAIL - //{0x3A25,0x00}, //THSTRAIL - //{0x3A26,0x5F}, //THSEXIT - //{0x3A27,0x00}, //THSEXIT - //{0x3A28,0x2F}, //TLPX - //{0x3A29,0x00}, //TLPX - {0x3000,0x00}, - {0x3002,0x00}, -}; - -const static I2C_ARRAY Sensor_init_table_4lane_5m30fps[] = -{ -/* "IMX335LQN All-pixel scan CSI-2_4lane 1188Mbps AD:10bit Output:10bit 27MHz Master Mode 30fps" */ - {0x3002,0x01}, //Master mode stop - {0xffff,0x14}, //delay - {0x3000,0x01}, //standby - {0xffff,0x14}, //delay - {0x300C,0x42}, - {0x300D,0x2E}, - {0x3030,0x1D}, //VMAX //1194 :4500 //101D: 4125 - {0x3031,0x10}, //VMAX - {0x3032,0x00}, //VMAX - {0x3034,0x58}, //HMAX //2D0h: 720 //226h: 550 - {0x3035,0x02}, //HMAX - {0x314C,0xB0}, - {0x315A,0x02}, - {0x3168,0x8F}, - {0x316A,0x7E}, - {0x319D,0x00}, //MDBIT 0:10Bit 1:12Bit - {0x31A0,0x2A}, - {0x31A1,0x00}, - {0x31A4,0x00}, - {0x31A5,0x00}, - {0x31A6,0x00}, - {0x31A8,0x00}, - {0x31AC,0x00}, - {0x31AD,0x00}, - {0x31AE,0x00}, - {0x31D4,0x00}, - {0x31D5,0x00}, - {0x31D7,0x00}, - {0x31E4,0x01}, - {0x31F3,0x01}, - {0x3288,0x21}, - {0x328A,0x02}, - {0x3414,0x05}, - {0x3416,0x18}, - {0x341c,0xFF}, //0x47--12-bit 0xff--10bit - {0x341d,0x01}, //0x00--12-bit 0x01--10bit - {0x3648,0x01}, - {0x364A,0x04}, - {0x364C,0x04}, - {0x3678,0x01}, - {0x367C,0x31}, - {0x367E,0x31}, - {0x3706,0x10}, - {0x3708,0x03}, - {0x3714,0x02}, - {0x3715,0x02}, - {0x3716,0x01}, - {0x3717,0x03}, - {0x371C,0x3D}, - {0x371D,0x3F}, - {0x372C,0x00}, - {0x372D,0x00}, - {0x372E,0x46}, - {0x372F,0x00}, - {0x3730,0x89}, - {0x3731,0x00}, - {0x3732,0x08}, - {0x3733,0x01}, - {0x3734,0xFE}, - {0x3735,0x05}, - {0x3740,0x02}, - {0x375D,0x00}, - {0x375E,0x00}, - {0x375F,0x11}, - {0x3760,0x01}, - {0x3768,0x1B}, - {0x3769,0x1B}, - {0x376A,0x1B}, - {0x376B,0x1B}, - {0x376C,0x1A}, - {0x376D,0x17}, - {0x376E,0x0F}, - {0x3776,0x00}, - {0x3777,0x00}, - {0x3778,0x46}, - {0x3779,0x00}, - {0x377A,0x89}, - {0x377B,0x00}, - {0x377C,0x08}, - {0x377D,0x01}, - {0x377E,0x23}, - {0x377F,0x02}, - {0x3780,0xD9}, - {0x3781,0x03}, - {0x3782,0xF5}, - {0x3783,0x06}, - {0x3784,0xA5}, - {0x3788,0x0F}, - {0x378A,0xD9}, - {0x378B,0x03}, - {0x378C,0xEB}, - {0x378D,0x05}, - {0x378E,0x87}, - {0x378F,0x06}, - {0x3790,0xF5}, - {0x3792,0x43}, - {0x3794,0x7A}, - {0x3796,0xA1}, - //{0x3A18,0x7F}, //TCLKPOST - //{0x3A19,0x00}, //TCLKPOST - //{0x3A1A,0x37}, //TCLKPREPARE - //{0x3A1B,0x00}, //TCLKPREPARE - //{0x3A1C,0x37}, //TCLKTRAIL - //{0x3A1D,0x00}, //TCLKTRAIL - //{0x3A1E,0xF7}, //TCLKZERO - //{0x3A1F,0x00}, //TCLKZERO - //{0x3A20,0x3F}, //THSPREPARE - //{0x3A21,0x00}, //THSPREPARE - //{0x3A22,0x6F}, //THSZERO - //{0x3A23,0x00}, //THSZERO - //{0x3A24,0x3F}, //THSTRAIL - //{0x3A25,0x00}, //THSTRAIL - //{0x3A26,0x5F}, //THSEXIT - //{0x3A27,0x00}, //THSEXIT - //{0x3A28,0x2F}, //TLPX - //{0x3A29,0x00}, //TLPX - {0x3000,0x00}, - {0x3002,0x00}, -}; - -const static I2C_ARRAY Sensor_init_table_HDR_DOL_4lane5m25fps[] = -{ -#if 1 -/*"IMX335LQN All-pixel scan CSI-2_4lane 1188Mbps AD:10bit Output:10bit 27MHz Master Mode DOL HDR 2frameLI 25fps" */ - {0x3002,0x01}, //Master mode stop - {0xffff,0x14}, //delay - {0x3000,0x01}, //standby - {0xffff,0x14}, //delay - {0x300C,0x42}, - {0x300D,0x2E}, - {0x3030,0x9A}, //VMAX 1518: 5400 //4500 1194 //4250 109A - {0x3031,0x10}, - {0x3032,0x00}, - {0x3034,0x5D}, //HMAX 113: 275 14A //15Dh 349 - {0x3035,0x01}, - {0x3048,0x01}, - {0x3049,0x01}, - {0x304A,0x04}, - {0x304B,0x03}, - {0x304C,0x00}, - {0x3050,0x00}, - {0x3056,0x07}, //Y_OUT_SIZE[7:0] - {0x3057,0x08}, //Y_OUT_SIZE[12:8] - {0x3058,0x88}, - {0x3059,0x1D}, - {0x305A,0x00}, - {0x305C,0x12}, - {0x305D,0x00}, - {0x305E,0x00}, - {0x3068,0x22}, - {0x3069,0x01}, - {0x306A,0x00}, - {0x314C,0xB0}, - {0x315A,0x02}, - {0x3168,0x8F}, - {0x316A,0x7E}, - {0x319D,0x00}, - {0x319F,0x00}, //0x2 - {0x31A0,0x2A}, - {0x31A1,0x00}, - {0x31A4,0x00}, - {0x31A5,0x00}, - {0x31A6,0x00}, - {0x31A8,0x00}, - {0x31AC,0x00}, - {0x31AD,0x00}, - {0x31AE,0x00}, - {0x31D4,0x00}, - {0x31D5,0x00}, - {0x31D7,0x01}, - {0x31E4,0x01}, - {0x31F3,0x01}, - {0x3288,0x21}, - {0x328A,0x02}, - {0x3300,0x00}, - {0x3414,0x05}, - {0x3416,0x18}, - {0x341C,0xFF},//0x47--12-bit 0xff--10bit - {0x341D,0x01},// - {0x3648,0x01}, - {0x364A,0x04}, - {0x364C,0x04}, - {0x3678,0x01}, - {0x367C,0x31}, - {0x367E,0x31}, - {0x3706,0x10}, - {0x3708,0x03}, - {0x3714,0x02}, - {0x3715,0x02}, - {0x3716,0x01}, - {0x3717,0x03}, - {0x371C,0x3D}, - {0x371D,0x3F}, - {0x372C,0x00}, - {0x372D,0x00}, - {0x372E,0x46}, - {0x372F,0x00}, - {0x3730,0x89}, - {0x3731,0x00}, - {0x3732,0x08}, - {0x3733,0x01}, - {0x3734,0xFE}, - {0x3735,0x05}, - {0x3740,0x02}, - {0x375d,0x00}, - {0x375e,0x00}, - {0x375f,0x11}, - {0x3760,0x01}, - {0x3768,0x1B}, - {0x3769,0x1B}, - {0x376A,0x1B}, - {0x376B,0x1B}, - {0x376C,0x1A}, - {0x376D,0x17}, - {0x376E,0x0F}, - {0x3776,0x00}, - {0x3777,0x00}, - {0x3778,0x46}, - {0x3779,0x00}, - {0x377A,0x89}, - {0x377B,0x00}, - {0x377C,0x08}, - {0x377D,0x01}, - {0x377E,0x23}, - {0x377F,0x02}, - {0x3780,0xD9}, - {0x3781,0x03}, - {0x3782,0xF5}, - {0x3783,0x06}, - {0x3784,0xA5}, - {0x3788,0x0F}, - {0x378A,0xD9}, - {0x378B,0x03}, - {0x378C,0xEB}, - {0x378D,0x05}, - {0x378E,0x87}, - {0x378F,0x06}, - {0x3790,0xF5}, - {0x3792,0x43}, - {0x3794,0x7A}, - {0x3796,0xA1}, - //{0x37b0,0x36}, - //{0x3a01,0x03}, - //{0x3a04,0x90}, - //{0x3a05,0x12}, - //{0x3a18,0x8f}, - //{0x3a19,0x00}, - //{0x3a1a,0x4f}, - //{0x3a1b,0x00}, - //{0x3a1c,0x47}, - //{0x3a1d,0x00}, - //{0x3a1e,0x37}, - //{0x3a1f,0x01}, - //{0x3a20,0x4f}, - //{0x3a21,0x00}, - //{0x3a22,0x87}, - //{0x3a23,0x00}, - //{0x3a24,0x4f}, - //{0x3a25,0x00}, - //{0x3a26,0x7f}, - //{0x3a27,0x00}, - //{0x3a28,0x3f}, - //{0x3a29,0x00}, - {0x3000,0x00}, - {0x3002,0x00}, -#else //Ori_24Mhz - {0x3000,0x01}, - {0x3001,0x00}, - {0x3002,0x01}, - {0x3003,0x00}, - - {0x300c,0x3b}, - {0x300d,0x2a}, - {0x3018,0x00}, - {0x302c,0x30}, - {0x302d,0x00}, - {0x302e,0x38}, - {0x302f,0x0a}, - - {0x3030,0x9A}, //VMAX 1518: 5400 //4500 1194 //4250 109A - {0x3031,0x10}, - {0x3032,0x00}, - {0x3034,0x5D}, //HMAX 113: 275 14A //15Dh 349 - {0x3035,0x01}, - - {0x3048,0x01}, - {0x3049,0x01}, - {0x304a,0x04}, - {0x304b,0x03}, - {0x304c,0x00}, - {0x304e,0x00}, - {0x304f,0x00}, - {0x3050,0x00}, - {0x3056,0x07}, - {0x3057,0x08}, - {0x3058,0x88}, - {0x3059,0x1d}, - {0x305a,0x00}, - {0x305c,0x12}, - {0x305d,0x00}, - {0x305e,0x00}, - {0x3060,0xe8}, - {0x3061,0x00}, - {0x3062,0x00}, - {0x3064,0x09}, - {0x3065,0x00}, - {0x3066,0x00}, - {0x3068,0x22}, - {0x3069,0x01}, - {0x306a,0x00}, - {0x306c,0x68}, - {0x306d,0x06}, - {0x306e,0x00}, - {0x3072,0x28}, - {0x3073,0x00}, - {0x3074,0xb0}, - {0x3075,0x00}, - {0x3076,0x58}, - {0x3077,0x0f}, - - {0x3078,0x01}, - {0x3079,0x02}, - {0x307a,0xff}, - {0x307b,0x02}, - {0x307c,0x00}, - {0x307d,0x00}, - {0x307e,0x00}, - {0x307f,0x00}, - {0x3080,0x01}, - {0x3081,0x02}, - {0x3082,0xff}, - {0x3083,0x02}, - {0x3084,0x00}, - {0x3085,0x00}, - {0x3086,0x00}, - {0x3087,0x00}, - - {0x30a4,0x33}, - {0x30a8,0x10}, - {0x30a9,0x04}, - {0x30ac,0x00}, - {0x30ad,0x00}, - {0x30b0,0x10}, - {0x30b1,0x08}, - {0x30b4,0x00}, - {0x30b5,0x00}, - {0x30b6,0x00}, - {0x30b7,0x00}, - - {0x30c6,0x00}, - {0x30c7,0x00}, - {0x30ce,0x00}, - {0x30cf,0x00}, - {0x30d8,0x4c}, - {0x30d9,0x10}, - {0x30e8,0x00}, - {0x30e9,0x00}, - {0x30ea,0x00}, - {0x30eb,0x00}, - {0x30ec,0x00}, - {0x30ed,0x00}, - {0x30ee,0x00}, - {0x30ef,0x00}, - {0x3112,0x08}, - {0x3113,0x00}, - {0x3116,0x08}, - {0x3117,0x00}, - {0x314c,0xc6}, - {0x314d,0x00}, - {0x315a,0x02}, - {0x3167,0x01}, - {0x3168,0xa0}, - {0x316a,0x7e}, - {0x3199,0x00}, - {0x319d,0x00}, - {0x319e,0x01}, - {0x319f,0x00}, - {0x31a0,0x2a}, - {0x31a1,0x00}, - {0x31a4,0x00}, - {0x31a5,0x00}, - {0x31a6,0x00}, - {0x31a8,0x00}, - {0x31ac,0x00}, - {0x31ad,0x00}, - {0x31ae,0x00}, - {0x31d4,0x00}, - {0x31d5,0x00}, - {0x31d7,0x01}, - {0x31e4,0x01}, - {0x31e8,0x00}, - {0x31f3,0x01}, - {0x3200,0x01}, - {0x3288,0x21}, - {0x328a,0x02}, - {0x3300,0x00}, - {0x3302,0x32}, - {0x3303,0x00}, - {0x3414,0x05}, - {0x3416,0x18}, - {0x341c,0xff},//0x47--12-bit 0xff--10bit - {0x341d,0x01},// - {0x3648,0x01}, - {0x364a,0x04}, - {0x364c,0x04}, - {0x3678,0x01}, - {0x367c,0x31}, - {0x367e,0x31}, - {0x3706,0x10}, - {0x3708,0x03}, - {0x3714,0x02}, - {0x3715,0x02}, - {0x3716,0x01}, - {0x3717,0x03}, - {0x371c,0x3d}, - {0x371d,0x3f}, - {0x372c,0x00}, - {0x372d,0x00}, - {0x372e,0x46}, - {0x372f,0x00}, - {0x3730,0x89}, - {0x3731,0x00}, - {0x3732,0x08}, - {0x3733,0x01}, - {0x3734,0xfe}, - {0x3735,0x05}, - {0x3740,0x02}, - {0x375d,0x00}, - {0x375e,0x00}, - {0x375f,0x11}, - {0x3760,0x01}, - {0x3768,0x1b}, - {0x3769,0x1b}, - {0x376a,0x1b}, - {0x376b,0x1b}, - {0x376c,0x1a}, - {0x376d,0x17}, - {0x376e,0x0f}, - {0x3776,0x00}, - {0x3777,0x00}, - {0x3778,0x46}, - {0x3779,0x00}, - {0x377a,0x89}, - {0x377b,0x00}, - {0x377c,0x08}, - {0x377d,0x01}, - {0x377e,0x23}, - {0x377f,0x02}, - {0x3780,0xd9}, - {0x3781,0x03}, - {0x3782,0xf5}, - {0x3783,0x06}, - {0x3784,0xa5}, - {0x3788,0x0f}, - {0x378a,0xd9}, - {0x378b,0x03}, - {0x378c,0xeb}, - {0x378d,0x05}, - {0x378e,0x87}, - {0x378f,0x06}, - {0x3790,0xf5}, - {0x3792,0x43}, - {0x3794,0x7a}, - {0x3796,0xa1}, - {0x37b0,0x36}, - {0x3a01,0x03}, - {0x3a04,0x90}, - {0x3a05,0x12}, - {0x3a18,0x8f}, - {0x3a19,0x00}, - {0x3a1a,0x4f}, - {0x3a1b,0x00}, - {0x3a1c,0x47}, - {0x3a1d,0x00}, - {0x3a1e,0x37}, - {0x3a1f,0x01}, - {0x3a20,0x4f}, - {0x3a21,0x00}, - {0x3a22,0x87}, - {0x3a23,0x00}, - {0x3a24,0x4f}, - {0x3a25,0x00}, - {0x3a26,0x7f}, - {0x3a27,0x00}, - {0x3a28,0x3f}, - {0x3a29,0x00}, - - {0x3000,0x00}, - {0x3002,0x00}, -#endif -}; - -const static I2C_ARRAY Sensor_init_table_HDR_DOL_4lane5m20fps[] = -{ -#if 1 -/*"IMX335LQN All-pixel scan CSI-2_4lane 1188Mbps AD:10bit Output:10bit 27MHz Master Mode DOL HDR 2frameLI 25fps" */ - {0x3002,0x01}, //Master mode stop - {0xffff,0x14}, //delay - {0x3000,0x01}, //standby - {0xffff,0x14}, //delay - {0x300C,0x42}, - {0x300D,0x2E}, - {0x3030,0xC0}, //VMAX 1518: 5400 //4500 1194 //4250 109A - {0x3031,0x14}, - {0x3032,0x00}, - {0x3034,0x5D}, //HMAX 113: 275 14A //15Dh 349 - {0x3035,0x01}, - {0x3048,0x01}, - {0x3049,0x01}, - {0x304A,0x04}, - {0x304B,0x03}, - {0x304C,0x00}, - {0x3050,0x00}, - {0x3056,0x07}, //Y_OUT_SIZE[7:0] - {0x3057,0x08}, //Y_OUT_SIZE[12:8] - {0x3058,0x88}, - {0x3059,0x1D}, - {0x305A,0x00}, - {0x305C,0x12}, - {0x305D,0x00}, - {0x305E,0x00}, - {0x3068,0x22}, - {0x3069,0x01}, - {0x306A,0x00}, - {0x314C,0xB0}, - {0x315A,0x02}, - {0x3168,0x8F}, - {0x316A,0x7E}, - {0x319D,0x00}, - {0x319F,0x00}, //0x2 - {0x31A0,0x2A}, - {0x31A1,0x00}, - {0x31A4,0x00}, - {0x31A5,0x00}, - {0x31A6,0x00}, - {0x31A8,0x00}, - {0x31AC,0x00}, - {0x31AD,0x00}, - {0x31AE,0x00}, - {0x31D4,0x00}, - {0x31D5,0x00}, - {0x31D7,0x01}, - {0x31E4,0x01}, - {0x31F3,0x01}, - {0x3288,0x21}, - {0x328A,0x02}, - {0x3300,0x00}, - {0x3414,0x05}, - {0x3416,0x18}, - {0x341C,0xFF},//0x47--12-bit 0xff--10bit - {0x341D,0x01},// - {0x3648,0x01}, - {0x364A,0x04}, - {0x364C,0x04}, - {0x3678,0x01}, - {0x367C,0x31}, - {0x367E,0x31}, - {0x3706,0x10}, - {0x3708,0x03}, - {0x3714,0x02}, - {0x3715,0x02}, - {0x3716,0x01}, - {0x3717,0x03}, - {0x371C,0x3D}, - {0x371D,0x3F}, - {0x372C,0x00}, - {0x372D,0x00}, - {0x372E,0x46}, - {0x372F,0x00}, - {0x3730,0x89}, - {0x3731,0x00}, - {0x3732,0x08}, - {0x3733,0x01}, - {0x3734,0xFE}, - {0x3735,0x05}, - {0x3740,0x02}, - {0x375d,0x00}, - {0x375e,0x00}, - {0x375f,0x11}, - {0x3760,0x01}, - {0x3768,0x1B}, - {0x3769,0x1B}, - {0x376A,0x1B}, - {0x376B,0x1B}, - {0x376C,0x1A}, - {0x376D,0x17}, - {0x376E,0x0F}, - {0x3776,0x00}, - {0x3777,0x00}, - {0x3778,0x46}, - {0x3779,0x00}, - {0x377A,0x89}, - {0x377B,0x00}, - {0x377C,0x08}, - {0x377D,0x01}, - {0x377E,0x23}, - {0x377F,0x02}, - {0x3780,0xD9}, - {0x3781,0x03}, - {0x3782,0xF5}, - {0x3783,0x06}, - {0x3784,0xA5}, - {0x3788,0x0F}, - {0x378A,0xD9}, - {0x378B,0x03}, - {0x378C,0xEB}, - {0x378D,0x05}, - {0x378E,0x87}, - {0x378F,0x06}, - {0x3790,0xF5}, - {0x3792,0x43}, - {0x3794,0x7A}, - {0x3796,0xA1}, - //{0x37b0,0x36}, - //{0x3a01,0x03}, - //{0x3a04,0x90}, - //{0x3a05,0x12}, - //{0x3a18,0x8f}, - //{0x3a19,0x00}, - //{0x3a1a,0x4f}, - //{0x3a1b,0x00}, - //{0x3a1c,0x47}, - //{0x3a1d,0x00}, - //{0x3a1e,0x37}, - //{0x3a1f,0x01}, - //{0x3a20,0x4f}, - //{0x3a21,0x00}, - //{0x3a22,0x87}, - //{0x3a23,0x00}, - //{0x3a24,0x4f}, - //{0x3a25,0x00}, - //{0x3a26,0x7f}, - //{0x3a27,0x00}, - //{0x3a28,0x3f}, - //{0x3a29,0x00}, - {0x3000,0x00}, - {0x3002,0x00}, -#else //Ori_24Mhz - {0x3000,0x01}, - {0x3001,0x00}, - {0x3002,0x01}, - {0x3003,0x00}, - {0x300c,0x3b}, - {0x300d,0x2a}, - {0x3018,0x00}, - {0x302c,0x30}, - {0x302d,0x00}, - {0x302e,0x38}, - {0x302f,0x0a}, - {0x3030,0x5e}, //1A5Eh : 6750 // 16A8h : 5800 - {0x3031,0x1a}, - {0x3032,0x00}, - {0x3033,0x00}, - {0x3034,0x13}, //113h : 275 // 140h : 320 - {0x3035,0x01}, - {0x3048,0x01}, - {0x3049,0x01}, - {0x304a,0x04}, - {0x304b,0x03}, - {0x304c,0x00}, - {0x304e,0x00}, - {0x304f,0x00}, - {0x3050,0x00}, - {0x3056,0x07}, - {0x3057,0x08}, - {0x3058,0x14}, - {0x3059,0x28}, - {0x305a,0x00}, - {0x305c,0x12}, - {0x305d,0x00}, - {0x305e,0x00}, - {0x3060,0xe8}, - {0x3061,0x00}, - {0x3062,0x00}, - {0x3064,0x09}, - {0x3065,0x00}, - {0x3066,0x00}, - {0x3068,0x22}, - {0x3069,0x01}, - {0x306a,0x00}, - {0x306c,0x68}, - {0x306d,0x06}, - {0x306e,0x00}, - {0x3072,0x28}, - {0x3073,0x00}, - {0x3074,0xb0}, - {0x3075,0x00}, - {0x3076,0x58}, - {0x3077,0x0f}, - {0x3078,0x01}, - {0x3079,0x02}, - {0x307a,0xff}, - {0x307b,0x02}, - {0x307c,0x00}, - {0x307d,0x00}, - {0x307e,0x00}, - {0x307f,0x00}, - {0x3080,0x01}, - {0x3081,0x02}, - {0x3082,0xff}, - {0x3083,0x02}, - {0x3084,0x00}, - {0x3085,0x00}, - {0x3086,0x00}, - {0x3087,0x00}, - {0x30a4,0x33}, - {0x30a8,0x10}, - {0x30a9,0x04}, - {0x30ac,0x00}, - {0x30ad,0x00}, - {0x30b0,0x10}, - {0x30b1,0x08}, - {0x30b4,0x00}, - {0x30b5,0x00}, - {0x30b6,0x00}, - {0x30b7,0x00}, - - {0x30c6,0x00}, - {0x30c7,0x00}, - {0x30ce,0x00}, - {0x30cf,0x00}, - {0x30d8,0x4c}, - {0x30d9,0x10}, - {0x30e8,0x00}, - {0x30e9,0x00}, - {0x30ea,0x00}, - {0x30eb,0x00}, - {0x30ec,0x00}, - {0x30ed,0x00}, - {0x30ee,0x00}, - {0x30ef,0x00}, - {0x3112,0x08}, - {0x3113,0x00}, - {0x3116,0x08}, - {0x3117,0x00}, - {0x314c,0xc6}, - {0x314d,0x00}, - {0x315a,0x02}, - {0x3167,0x01}, - {0x3168,0xa0}, - {0x316a,0x7e}, - {0x3199,0x00}, - {0x319d,0x00}, - {0x319e,0x01}, - {0x319f,0x00}, - {0x31a0,0x2a}, - {0x31a1,0x00}, - {0x31a4,0x00}, - {0x31a5,0x00}, - {0x31a6,0x00}, - {0x31a8,0x00}, - {0x31ac,0x00}, - {0x31ad,0x00}, - {0x31ae,0x00}, - {0x31d4,0x00}, - {0x31d5,0x00}, - {0x31d7,0x01}, - {0x31e4,0x01}, - {0x31e8,0x00}, - {0x31f3,0x01}, - {0x3200,0x01}, - {0x3288,0x21}, - {0x328a,0x02}, - {0x3300,0x00}, - {0x3302,0x32}, - {0x3303,0x00}, - {0x3414,0x05}, - {0x3416,0x18}, - {0x341c,0xff},//0x47--12-bit 0xff--10bit - {0x341d,0x01},// - {0x3648,0x01}, - {0x364a,0x04}, - {0x364c,0x04}, - {0x3678,0x01}, - {0x367c,0x31}, - {0x367e,0x31}, - {0x3706,0x10}, - {0x3708,0x03}, - {0x3714,0x02}, - {0x3715,0x02}, - {0x3716,0x01}, - {0x3717,0x03}, - {0x371c,0x3d}, - {0x371d,0x3f}, - {0x372c,0x00}, - {0x372d,0x00}, - {0x372e,0x46}, - {0x372f,0x00}, - {0x3730,0x89}, - {0x3731,0x00}, - {0x3732,0x08}, - {0x3733,0x01}, - {0x3734,0xfe}, - {0x3735,0x05}, - {0x3740,0x02}, - {0x375d,0x00}, - {0x375e,0x00}, - {0x375f,0x11}, - {0x3760,0x01}, - {0x3768,0x1b}, - {0x3769,0x1b}, - {0x376a,0x1b}, - {0x376b,0x1b}, - {0x376c,0x1a}, - {0x376d,0x17}, - {0x376e,0x0f}, - {0x3776,0x00}, - {0x3777,0x00}, - {0x3778,0x46}, - {0x3779,0x00}, - {0x377a,0x89}, - {0x377b,0x00}, - {0x377c,0x08}, - {0x377d,0x01}, - {0x377e,0x23}, - {0x377f,0x02}, - {0x3780,0xd9}, - {0x3781,0x03}, - {0x3782,0xf5}, - {0x3783,0x06}, - {0x3784,0xa5}, - {0x3788,0x0f}, - {0x378a,0xd9}, - {0x378b,0x03}, - {0x378c,0xeb}, - {0x378d,0x05}, - {0x378e,0x87}, - {0x378f,0x06}, - {0x3790,0xf5}, - {0x3792,0x43}, - {0x3794,0x7a}, - {0x3796,0xa1}, - {0x37b0,0x36}, - {0x3a01,0x03}, - {0x3a04,0x90}, - {0x3a05,0x12}, - {0x3a18,0x8f}, - {0x3a19,0x00}, - {0x3a1a,0x4f}, - {0x3a1b,0x00}, - {0x3a1c,0x47}, - {0x3a1d,0x00}, - {0x3a1e,0x37}, - {0x3a1f,0x01}, - {0x3a20,0x4f}, - {0x3a21,0x00}, - {0x3a22,0x87}, - {0x3a23,0x00}, - {0x3a24,0x4f}, - {0x3a25,0x00}, - {0x3a26,0x7f}, - {0x3a27,0x00}, - {0x3a28,0x3f}, - {0x3a29,0x00}, - - {0x3000,0x00}, - {0x3002,0x00}, -#endif -}; - -const static I2C_ARRAY Sensor_init_table_HDR_DOL_4lane5m30fps[] = -{ -/*"IMX335LQN All-pixel scan CSI-2_4lane 1188Mbps AD:10bit Output:10bit 27MHz Master Mode DOL HDR 2frameLI 30fps"*/ -#if 1 - {0x3002,0x01}, //Master mode stop - {0xffff,0x14}, //delay - {0x3000,0x01}, //standby - {0xffff,0x14}, //delay - {0x300C,0x42}, - {0x300D,0x2E}, - {0x3030,0x00}, //4096 1000h - {0x3031,0x10}, - {0x3032,0x00}, - {0x3034,0x2C}, //HMAX 300 : 12Ch - {0x3035,0x01}, - {0x3048,0x01}, - {0x3049,0x01}, - {0x304A,0x04}, - {0x304B,0x03}, - {0x304C,0x00}, - {0x3050,0x00}, - {0x3056,0x07}, //Y_OUT_SIZE[7:0] - {0x3057,0x08}, //Y_OUT_SIZE[12:8] - {0x3058,0x1C}, - {0x3059,0x22}, - {0x305A,0x00}, - {0x305C,0x12}, - {0x305D,0x00}, - {0x305E,0x00}, - {0x3068,0x22}, - {0x3069,0x01}, - {0x306A,0x00}, - {0x314C,0xB0}, - {0x315A,0x02}, - {0x3168,0x8F}, - {0x316A,0x7E}, - {0x319D,0x00}, - {0x319F,0x00}, //0x2 - {0x31A0,0x2A}, - {0x31A1,0x00}, - {0x31A4,0x00}, - {0x31A5,0x00}, - {0x31A6,0x00}, - {0x31A8,0x00}, - {0x31AC,0x00}, - {0x31AD,0x00}, - {0x31AE,0x00}, - {0x31D4,0x00}, - {0x31D5,0x00}, - {0x31D7,0x01}, - {0x31E4,0x01}, - {0x31F3,0x01}, - {0x3288,0x21}, - {0x328A,0x02}, - {0x3300,0x00}, - {0x3414,0x05}, - {0x3416,0x18}, - {0x341C,0xFF},//0x47--12-bit 0xff--10bit - {0x341D,0x01},// - {0x3648,0x01}, - {0x364A,0x04}, - {0x364C,0x04}, - {0x3678,0x01}, - {0x367C,0x31}, - {0x367E,0x31}, - {0x3706,0x10}, - {0x3708,0x03}, - {0x3714,0x02}, - {0x3715,0x02}, - {0x3716,0x01}, - {0x3717,0x03}, - {0x371C,0x3D}, - {0x371D,0x3F}, - {0x372C,0x00}, - {0x372D,0x00}, - {0x372E,0x46}, - {0x372F,0x00}, - {0x3730,0x89}, - {0x3731,0x00}, - {0x3732,0x08}, - {0x3733,0x01}, - {0x3734,0xFE}, - {0x3735,0x05}, - {0x3740,0x02}, - {0x375d,0x00}, - {0x375e,0x00}, - {0x375f,0x11}, - {0x3760,0x01}, - {0x3768,0x1B}, - {0x3769,0x1B}, - {0x376A,0x1B}, - {0x376B,0x1B}, - {0x376C,0x1A}, - {0x376D,0x17}, - {0x376E,0x0F}, - {0x3776,0x00}, - {0x3777,0x00}, - {0x3778,0x46}, - {0x3779,0x00}, - {0x377A,0x89}, - {0x377B,0x00}, - {0x377C,0x08}, - {0x377D,0x01}, - {0x377E,0x23}, - {0x377F,0x02}, - {0x3780,0xD9}, - {0x3781,0x03}, - {0x3782,0xF5}, - {0x3783,0x06}, - {0x3784,0xA5}, - {0x3788,0x0F}, - {0x378A,0xD9}, - {0x378B,0x03}, - {0x378C,0xEB}, - {0x378D,0x05}, - {0x378E,0x87}, - {0x378F,0x06}, - {0x3790,0xF5}, - {0x3792,0x43}, - {0x3794,0x7A}, - {0x3796,0xA1}, - //{0x37b0,0x36}, - //{0x3a01,0x03}, - //{0x3a04,0x90}, - //{0x3a05,0x12}, - //{0x3a18,0x8f}, - //{0x3a19,0x00}, - //{0x3a1a,0x4f}, - //{0x3a1b,0x00}, - //{0x3a1c,0x47}, - //{0x3a1d,0x00}, - //{0x3a1e,0x37}, - //{0x3a1f,0x01}, - //{0x3a20,0x4f}, - //{0x3a21,0x00}, - //{0x3a22,0x87}, - //{0x3a23,0x00}, - //{0x3a24,0x4f}, - //{0x3a25,0x00}, - //{0x3a26,0x7f}, - //{0x3a27,0x00}, - //{0x3a28,0x3f}, - //{0x3a29,0x00}, - {0x3000,0x00}, - {0x3002,0x00}, -#else - {0x3000,0x01}, - {0x3001,0x00}, - {0x3002,0x01}, - {0x3003,0x00}, - - {0x300c,0x3b}, - {0x300d,0x2a}, - {0x3018,0x00}, - {0x302c,0x30}, - {0x302d,0x00}, - {0x302e,0x38}, - {0x302f,0x0a}, - - {0x3030,0x9A}, //VMAX - {0x3031,0x11}, - {0x3032,0x00}, - {0x3033,0x00}, - {0x3034,0x13}, //HMAX - {0x3035,0x01}, - {0x3048,0x01}, - {0x3049,0x01}, - {0x304a,0x04}, - {0x304b,0x03}, - {0x304c,0x00}, - {0x304e,0x00}, - {0x304f,0x00}, - {0x3050,0x00}, - {0x3056,0x07}, - {0x3057,0x08}, - {0x3058,0x9c}, - {0x3059,0x18}, - {0x305a,0x00}, - {0x305c,0x12}, - {0x305d,0x00}, - {0x305e,0x00}, - {0x3060,0xe8}, - {0x3061,0x00}, - {0x3062,0x00}, - {0x3064,0x09}, - {0x3065,0x00}, - {0x3066,0x00}, - {0x3068,0x22}, - {0x3069,0x01}, - {0x306a,0x00}, - {0x306c,0x68}, - {0x306d,0x06}, - {0x306e,0x00}, - {0x3072,0x28}, - {0x3073,0x00}, - {0x3074,0xb0}, - {0x3075,0x00}, - {0x3076,0x58}, - {0x3077,0x0f}, - - {0x3078,0x01}, - {0x3079,0x02}, - {0x307a,0xff}, - {0x307b,0x02}, - {0x307c,0x00}, - {0x307d,0x00}, - {0x307e,0x00}, - {0x307f,0x00}, - {0x3080,0x01}, - {0x3081,0x02}, - {0x3082,0xff}, - {0x3083,0x02}, - {0x3084,0x00}, - {0x3085,0x00}, - {0x3086,0x00}, - {0x3087,0x00}, - - {0x30a4,0x33}, - {0x30a8,0x10}, - {0x30a9,0x04}, - {0x30ac,0x00}, - {0x30ad,0x00}, - {0x30b0,0x10}, - {0x30b1,0x08}, - {0x30b4,0x00}, - {0x30b5,0x00}, - {0x30b6,0x00}, - {0x30b7,0x00}, - - {0x30c6,0x00}, - {0x30c7,0x00}, - {0x30ce,0x00}, - {0x30cf,0x00}, - {0x30d8,0x4c}, - {0x30d9,0x10}, - {0x30e8,0x00}, - {0x30e9,0x00}, - {0x30ea,0x00}, - {0x30eb,0x00}, - {0x30ec,0x00}, - {0x30ed,0x00}, - {0x30ee,0x00}, - {0x30ef,0x00}, - {0x3112,0x08}, - {0x3113,0x00}, - {0x3116,0x08}, - {0x3117,0x00}, - {0x314c,0xc6}, - {0x314d,0x00}, - {0x315a,0x02}, - {0x3167,0x01}, - {0x3168,0xa0}, - {0x316a,0x7e}, - {0x3199,0x00}, - {0x319d,0x00}, - {0x319e,0x01}, - {0x319f,0x02}, - {0x31a0,0x2a}, - {0x31a1,0x00}, - {0x31a4,0x00}, - {0x31a5,0x00}, - {0x31a6,0x00}, - {0x31a8,0x00}, - {0x31ac,0x00}, - {0x31ad,0x00}, - {0x31ae,0x00}, - {0x31d4,0x00}, - {0x31d5,0x00}, - {0x31d7,0x01}, - {0x31e4,0x01}, - {0x31e8,0x00}, - {0x31f3,0x01}, - {0x3200,0x01}, - {0x3288,0x21}, - {0x328a,0x02}, - {0x3300,0x00}, - {0x3302,0x32}, - {0x3303,0x00}, - {0x3414,0x05}, - {0x3416,0x18}, - {0x341c,0xff},//0x47--12-bit 0xff--10bit - {0x341d,0x01},// - {0x3648,0x01}, - {0x364a,0x04}, - {0x364c,0x04}, - {0x3678,0x01}, - {0x367c,0x31}, - {0x367e,0x31}, - {0x3706,0x10}, - {0x3708,0x03}, - {0x3714,0x02}, - {0x3715,0x02}, - {0x3716,0x01}, - {0x3717,0x03}, - {0x371c,0x3d}, - {0x371d,0x3f}, - {0x372c,0x00}, - {0x372d,0x00}, - {0x372e,0x46}, - {0x372f,0x00}, - {0x3730,0x89}, - {0x3731,0x00}, - {0x3732,0x08}, - {0x3733,0x01}, - {0x3734,0xfe}, - {0x3735,0x05}, - {0x3740,0x02}, - {0x375d,0x00}, - {0x375e,0x00}, - {0x375f,0x11}, - {0x3760,0x01}, - {0x3768,0x1b}, - {0x3769,0x1b}, - {0x376a,0x1b}, - {0x376b,0x1b}, - {0x376c,0x1a}, - {0x376d,0x17}, - {0x376e,0x0f}, - {0x3776,0x00}, - {0x3777,0x00}, - {0x3778,0x46}, - {0x3779,0x00}, - {0x377a,0x89}, - {0x377b,0x00}, - {0x377c,0x08}, - {0x377d,0x01}, - {0x377e,0x23}, - {0x377f,0x02}, - {0x3780,0xd9}, - {0x3781,0x03}, - {0x3782,0xf5}, - {0x3783,0x06}, - {0x3784,0xa5}, - {0x3788,0x0f}, - {0x378a,0xd9}, - {0x378b,0x03}, - {0x378c,0xeb}, - {0x378d,0x05}, - {0x378e,0x87}, - {0x378f,0x06}, - {0x3790,0xf5}, - {0x3792,0x43}, - {0x3794,0x7a}, - {0x3796,0xa1}, - {0x37b0,0x36}, - {0x3a01,0x03}, - {0x3a04,0x90}, - {0x3a05,0x12}, - {0x3a18,0x8f}, - {0x3a19,0x00}, - {0x3a1a,0x4f}, - {0x3a1b,0x00}, - {0x3a1c,0x47}, - {0x3a1d,0x00}, - {0x3a1e,0x37}, - {0x3a1f,0x01}, - {0x3a20,0x4f}, - {0x3a21,0x00}, - {0x3a22,0x87}, - {0x3a23,0x00}, - {0x3a24,0x4f}, - {0x3a25,0x00}, - {0x3a26,0x7f}, - {0x3a27,0x00}, - {0x3a28,0x3f}, - {0x3a29,0x00}, - - {0x3000,0x00}, - {0x3002,0x00}, -#endif -}; - -static I2C_ARRAY PatternTbl[] = { - {0x308c,0x20}, //colorbar pattern , bit 0 to enable -}; - -const static I2C_ARRAY gain_HDR_DOL_LEF_reg[] = -{ - {0x30E8, 0x00},// bit0-7 low - {0x30E9, 0x00},// bit0-2(8-10) -}; - -const static I2C_ARRAY gain_HDR_DOL_SEF1_reg[] = -{ - {0x30EA, 0x00},// bit0-7 low - {0x30EB, 0x00},// bit0-2(8-10) -}; - -const static I2C_ARRAY expo_shr_dol1_reg[] = -{ //SEL - {0x305e, 0x00}, // bit0-3(16-18) - {0x305d, 0x00}, // bit0-7(8-15) - {0x305c, 0x12}, // bit0-7 -}; - -const I2C_ARRAY expo_rhs1_reg[] = -{ //SEL - {0x306a, 0x00}, // bit0-3(16-18) - {0x3069, 0x00}, // bit0-7(8-15) - {0x3068, 0xCE}, // bit0-7 -}; - -const static I2C_ARRAY mirr_flip_table[] = -{ - {0x304e, 0x00}, //M0F0 - {0x304f, 0x00}, //M0F0 - {0x3081, 0x02}, - {0x3083, 0x02}, - {0x30b6, 0x00}, - {0x30b7, 0x00}, - {0x3016, 0x08}, - - {0x304e, 0x01}, //M1F0 - {0x304f, 0x00}, //M1F0 - {0x3081, 0x02}, - {0x3083, 0x02}, - {0x30b6, 0x00}, - {0x30b7, 0x00}, - {0x3016, 0x08}, - - {0x304e, 0x00}, //M0F1 - {0x304f, 0x01}, //M0F1 - {0x3081, 0xfe}, - {0x3083, 0xfe}, - {0x30b6, 0xfa}, - {0x30b7, 0x01}, - {0x3016, 0x02}, - - {0x304e, 0x01}, //M1F1 - {0x304f, 0x01}, //M1F1 - {0x3081, 0xfe}, - {0x3083, 0xfe}, - {0x30b6, 0xfa}, - {0x30b7, 0x01}, - {0x3016, 0x02}, -}; - -const static I2C_ARRAY gain_reg[] = { - {0x30E8, 0x00},// bit0-7 low - {0x30E9, 0x00},// bit0-2(8-10) -}; - -//static int g_sensor_ae_min_gain = 1024; -static CUS_GAIN_GAP_ARRAY gain_gap_compensate[16] = { //compensate gain gap - {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} -}; - -const static I2C_ARRAY expo_reg[] = { - {0x305a, 0x00}, // bit0-3(16-18) - {0x3059, 0x00}, // bit0-7(8-15) - {0x3058, 0x09}, // bit0-7 -}; - -const static I2C_ARRAY vts_reg[] = { - {0x3032, 0x00}, // bit0-3(16-18) - {0x3031, 0x11}, // bit0-7(8-15) - {0x3030, 0x94}, // bit0-7 -}; - -///////////////////////////////////////////////////////////////// -// @@@@@@@ // -// @@ // -// @@ // -// @@@ // -// @ @@ // -// @@@@ // -// // -// Step 3 -- complete camera features // -// // -// camera set EV, MWB, orientation, contrast, sharpness // -// , saturation, and Denoise can work correctly. // -// // -///////////////////////////////////////////////////////////////// -#if 0 -static CUS_INT_TASK_ORDER def_order = { - .RunLength = 9, - .Orders = { - CUS_INT_TASK_AE|CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_AWB|CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_AE|CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_AWB|CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_AE|CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_AWB|CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - }, -}; -#endif - -/////////// function definition /////////////////// -#define SensorReg_Read(_reg,_data) (handle->i2c_bus->i2c_rx(handle->i2c_bus, &(handle->i2c_cfg),_reg,_data)) -#define SensorReg_Write(_reg,_data) (handle->i2c_bus->i2c_tx(handle->i2c_bus, &(handle->i2c_cfg),_reg,_data)) -#define SensorRegArrayW(_reg,_len) (handle->i2c_bus->i2c_array_tx(handle->i2c_bus, &(handle->i2c_cfg),(_reg),(_len))) -#define SensorRegArrayR(_reg,_len) (handle->i2c_bus->i2c_array_rx(handle->i2c_bus, &(handle->i2c_cfg),(_reg),(_len))) - -/////////////////// sensor hardware dependent ////////////// -#if 0 -static int ISP_config_io(ms_cus_sensor *handle) { -#if 0 - ISensorIfAPI *sensor_if = handle->sensor_if_api; - - SENSOR_DMSG("[%s]", __FUNCTION__); - - sensor_if->HsyncPol(handle, handle->HSYNC_POLARITY); - sensor_if->VsyncPol(handle, handle->VSYNC_POLARITY); - sensor_if->ClkPol(handle, handle->PCLK_POLARITY); - sensor_if->BayerFmt(handle, handle->bayer_id); - sensor_if->DataBus(handle, handle->sif_bus); - - sensor_if->DataPrecision(handle, handle->data_prec); - sensor_if->FmtConv(handle, handle->data_mode); -#endif - return SUCCESS; -} -#endif - -static int cus_camsensor_release_handle(ms_cus_sensor *handle) -{ - return SUCCESS; -} - -/*******I5/I6 Support MCLK List******* - * CUS_CMU_CLK_27MHZ, - * CUS_CMU_CLK_21P6MHZ, - * CUS_CMU_CLK_12MHZ, - * CUS_CMU_CLK_5P4MHZ, - * CUS_CMU_CLK_36MHZ, - * CUS_CMU_CLK_54MHZ, - * CUS_CMU_CLK_43P2MHZ, - * CUS_CMU_CLK_61P7MHZ, - * CUS_CMU_CLK_72MHZ, - * CUS_CMU_CLK_48MHZ, - * CUS_CMU_CLK_24MHZ, - * CUS_CMU_CLK_37P125MHZ, - ******End of Support MCLK List*******/ - #if 0 -static CUS_MCLK_FREQ UseParaMclk(const char *mclk) -{ - if (strcmp(mclk, "27M") == 0) { - return CUS_CMU_CLK_27MHZ; - } else if (strcmp(mclk, "12M") == 0) { - return CUS_CMU_CLK_12MHZ; - } else if (strcmp(mclk, "36M") == 0) { - return CUS_CMU_CLK_36MHZ; - } else if (strcmp(mclk, "48M") == 0) { - return CUS_CMU_CLK_48MHZ; - } else if (strcmp(mclk, "54M") == 0) { - return CUS_CMU_CLK_54MHZ; - } else if (strcmp(mclk, "24M") == 0) { - return CUS_CMU_CLK_24MHZ; - } else if (strcmp(mclk, "37.125M") == 0) { - return CUS_CMU_CLK_37P125MHZ; - } - return Preview_MCLK_SPEED; -} -#endif - -static int pCus_poweron(ms_cus_sensor *handle, u32 idx) -{ - ISensorIfAPI *sensor_if = handle->sensor_if_api; - SENSOR_DMSG("[%s] ", __FUNCTION__); - - //Sensor power on sequence - sensor_if->PowerOff(idx, !handle->pwdn_POLARITY); - sensor_if->Reset(idx, !handle->reset_POLARITY); - sensor_if->SetIOPad(idx, handle->sif_bus, handle->interface_attr.attr_mipi.mipi_lane_num); - sensor_if->SetCSI_Clk(idx, CUS_CSI_CLK_216M); - sensor_if->SetCSI_Lane(idx, handle->interface_attr.attr_mipi.mipi_lane_num, 1); - sensor_if->SetCSI_LongPacketType(idx, 0, 0x1C00, 0); - - if (handle->interface_attr.attr_mipi.mipi_hdr_mode == CUS_HDR_MODE_SONY_DOL) { - sensor_if->SetCSI_hdr_mode(idx, handle->interface_attr.attr_mipi.mipi_hdr_mode, 1); - } - - sensor_if->PowerOff(idx, !handle->pwdn_POLARITY); - //Sensor board PWDN Enable, 1.8V & 2.9V need 30ms then Pull High - SENSOR_MSLEEP(31); - sensor_if->Reset(idx, !handle->reset_POLARITY); - SENSOR_UDELAY(1); - sensor_if->MCLK(idx, 1, handle->mclk); - SENSOR_DMSG("Sensor Power On finished\n"); - return SUCCESS; -} - -static int pCus_poweroff(ms_cus_sensor *handle, u32 idx) -{ - // power/reset low - ISensorIfAPI *sensor_if = handle->sensor_if_api; - - SENSOR_DMSG("[%s] reset low\n", __FUNCTION__); - sensor_if->Reset(idx, handle->reset_POLARITY); - sensor_if->MCLK(idx, 0, handle->mclk); - - sensor_if->SetCSI_Clk(idx, CUS_CSI_CLK_DISABLE); - if (handle->interface_attr.attr_mipi.mipi_hdr_mode == CUS_HDR_MODE_SONY_DOL) { - sensor_if->SetCSI_hdr_mode(idx, handle->interface_attr.attr_mipi.mipi_hdr_mode, 0); - } - handle->orient = SENSOR_ORIT; - - return SUCCESS; -} - -/////////////////// Check Sensor Product ID ///////////////////////// -#if 0 -static int pCus_CheckSensorProductID(ms_cus_sensor *handle) -{ - u16 sen_id_msb, sen_id_lsb, sen_data; - - /* Read Product ID */ - SensorReg_Read(0x3f12, &sen_id_lsb); - SensorReg_Read(0x3f13, &sen_id_msb);//CHIP_ID_r3F13 - sen_data = ((sen_id_lsb & 0x0F) << 8) | (sen_id_lsb & 0xF0) | (sen_id_msb & 0x0F); -#if 0 - if (sen_data != CHIP_ID) { - printk("[***ERROR***]Check Product ID Fail: 0x%x\n", sen_data); - return FAIL; - } -#endif - return SUCCESS; -} -#endif -//Get and check sensor ID -//if i2c error or sensor id does not match then return FAIL -static int pCus_GetSensorID(ms_cus_sensor *handle, u32 *id) -{ - int i,n; - int table_length= ARRAY_SIZE(Sensor_id_table); - I2C_ARRAY id_from_sensor[ARRAY_SIZE(Sensor_id_table)]; - - for(n=0;n8) table_length=8; - - SENSOR_DMSG("\n\n[%s]", __FUNCTION__); - - for(n=0;n<4;++n) //retry , until I2C success - { - if(n>2) return FAIL; - - if(/* SensorRegArrayR((I2C_ARRAY*)id_from_sensor,table_length) == */SUCCESS) //read sensor ID from I2C - break; - else - SENSOR_MSLEEP(1); - } - - //convert sensor id to u32 format - for(i=0;i=10) - { - return FAIL; - } - //usleep(10*1000); - } - //printk("\n reg 0x%x, 0x%x",Sensor_init_table_2lane_5m25fps[i].reg, Sensor_init_table_2lane_5m25fps[i].data); -#if 0 - SensorReg_Read(Sensor_init_table_2lane_5m25fps[i].reg, &sen_data ); - if(Sensor_init_table_2lane_5m25fps[i].data != sen_data) - printk("R/W Differ Reg: 0x%x\n",Sensor_init_table_2lane_5m25fps[i].reg); - //printk("IMX335 reg: 0x%x, data: 0x%x, read: 0x%x.\n",Sensor_init_table_2lane_5m25fps[i].reg, Sensor_init_table_2lane_5m25fps[i].data, sen_data); -#endif - } - } - return SUCCESS; -} - -static int pCus_init_mipi2lane_5m30fps_linear(ms_cus_sensor *handle) -{ - int i,cnt=0; - - SENSOR_DMSG("\n[%s]", __FUNCTION__); - - for(i=0;i< ARRAY_SIZE(Sensor_init_table_2lane_5m30fps);i++) - { - if(Sensor_init_table_2lane_5m30fps[i].reg==0xffff) - { - SENSOR_MSLEEP(Sensor_init_table_2lane_5m30fps[i].data); - } - else - { - cnt = 0; - while(SensorReg_Write(Sensor_init_table_2lane_5m30fps[i].reg,Sensor_init_table_2lane_5m30fps[i].data) != SUCCESS) - { - cnt++; - if(cnt>=10) - { - return FAIL; - } - //usleep(10*1000); - } - //printk("\n reg 0x%x, 0x%x",Sensor_init_table_2lane_5m30fps[i].reg, Sensor_init_table_2lane_5m30fps[i].data); -#if 0 - SensorReg_Read(Sensor_init_table_2lane_5m30fps[i].reg, &sen_data ); - if(Sensor_init_table_2lane_5m30fps[i].data != sen_data) - printk("R/W Differ Reg: 0x%x\n",Sensor_init_table_2lane_5m30fps[i].reg); - //printk("IMX335 reg: 0x%x, data: 0x%x, read: 0x%x.\n",Sensor_init_table_2lane_5m30fps[i].reg, Sensor_init_table_2lane_5m30fps[i].data, sen_data); -#endif - } - } - return SUCCESS; -} - -static int pCus_init_mipi4lane_5m30fps_linear(ms_cus_sensor *handle) -{ - int i,cnt=0; - - SENSOR_DMSG("\n[%s]", __FUNCTION__); - - for(i=0;i< ARRAY_SIZE(Sensor_init_table_4lane_5m30fps);i++) - { - if(Sensor_init_table_4lane_5m30fps[i].reg==0xffff) - { - SENSOR_MSLEEP(Sensor_init_table_4lane_5m30fps[i].data); - } - else - { - cnt = 0; - while(SensorReg_Write(Sensor_init_table_4lane_5m30fps[i].reg,Sensor_init_table_4lane_5m30fps[i].data) != SUCCESS) - { - cnt++; - if(cnt>=10) - { - return FAIL; - } - //usleep(10*1000); - } - //printk("\n reg 0x%x, 0x%x",Sensor_init_table_4lane_5m30fps[i].reg, Sensor_init_table_4lane_5m30fps[i].data); -#if 0 - SensorReg_Read(Sensor_init_table_4lane_5m30fps[i].reg, &sen_data ); - if(Sensor_init_table_4lane_5m30fps[i].data != sen_data) - printk("R/W Differ Reg: 0x%x\n",Sensor_init_table_4lane_5m30fps[i].reg); - //printk("IMX335 reg: 0x%x, data: 0x%x, read: 0x%x.\n",Sensor_init_table_4lane_5m30fps[i].reg, Sensor_init_table_4lane_5m30fps[i].data, sen_data); -#endif - } - } - return SUCCESS; -} - -static int pCus_init_mipi4lane_5m25fps_linear(ms_cus_sensor *handle) -{ - int i,cnt=0; - - SENSOR_DMSG("\n[%s]", __FUNCTION__); - - for(i=0;i< ARRAY_SIZE(Sensor_init_table_4lane_5m25fps);i++) - { - if(Sensor_init_table_4lane_5m25fps[i].reg==0xffff) - { - SENSOR_MSLEEP(Sensor_init_table_4lane_5m25fps[i].data); - } - else - { - cnt = 0; - while(SensorReg_Write(Sensor_init_table_4lane_5m25fps[i].reg,Sensor_init_table_4lane_5m25fps[i].data) != SUCCESS) - { - cnt++; - if(cnt>=10) - { - return FAIL; - } - //usleep(10*1000); - } - //printk("\n reg 0x%x, 0x%x",Sensor_init_table_4lane_5m25fps[i].reg, Sensor_init_table_4lane_5m25fps[i].data); -#if 0 - SensorReg_Read(Sensor_init_table_4lane_5m25fps[i].reg, &sen_data ); - if(Sensor_init_table_4lane_5m25fps[i].data != sen_data) - printk("R/W Differ Reg: 0x%x\n",Sensor_init_table_4lane_5m25fps[i].reg); - //printk("IMX335 reg: 0x%x, data: 0x%x, read: 0x%x.\n",Sensor_init_table_4lane_5m25fps[i].reg, Sensor_init_table_4lane_5m25fps[i].data, sen_data); -#endif - } - } - return SUCCESS; -} - -static int pCus_init_mipi4lane5m25fps_HDR_DOL(ms_cus_sensor *handle) -{ - int i,cnt=0; - - SENSOR_DMSG("\n[%s]", __FUNCTION__); - - for(i=0;i< ARRAY_SIZE(Sensor_init_table_HDR_DOL_4lane5m25fps);i++) - { - if(Sensor_init_table_HDR_DOL_4lane5m25fps[i].reg==0xffff) - { - SENSOR_MSLEEP(Sensor_init_table_HDR_DOL_4lane5m25fps[i].data); - } - else - { - cnt = 0; - while(SensorReg_Write(Sensor_init_table_HDR_DOL_4lane5m25fps[i].reg,Sensor_init_table_HDR_DOL_4lane5m25fps[i].data) != SUCCESS) - { - cnt++; - if(cnt>=10) - { - return FAIL; - } - //usleep(10*1000); - } - //printk("\n reg 0x%x, 0x%x",Sensor_init_table_HDR_DOL_4lane5m25fps[i].reg, Sensor_init_table_HDR_DOL_4lane5m25fps[i].data); -#if 0 - SensorReg_Read(Sensor_init_table_HDR_DOL_4lane5m25fps[i].reg, &sen_data ); - if(Sensor_init_table_HDR_DOL_4lane5m25fps[i].data != sen_data) - printk("R/W Differ Reg: 0x%x\n",Sensor_init_table_HDR_DOL_4lane5m25fps[i].reg); - //printk("IMX335 reg: 0x%x, data: 0x%x, read: 0x%x.\n",Sensor_init_table_HDR_DOL_4lane5m25fps[i].reg, Sensor_init_table_HDR_DOL_4lane5m25fps[i].data, sen_data); -#endif - } - } - return SUCCESS; -} - -static int pCus_init_mipi4lane5m20fps_HDR_DOL(ms_cus_sensor *handle) -{ - int i,cnt=0; - - SENSOR_DMSG("\n[%s]", __FUNCTION__); - - for(i=0;i< ARRAY_SIZE(Sensor_init_table_HDR_DOL_4lane5m20fps);i++) - { - if(Sensor_init_table_HDR_DOL_4lane5m20fps[i].reg==0xffff) - { - SENSOR_MSLEEP(Sensor_init_table_HDR_DOL_4lane5m20fps[i].data); - } - else - { - cnt = 0; - while(SensorReg_Write(Sensor_init_table_HDR_DOL_4lane5m20fps[i].reg,Sensor_init_table_HDR_DOL_4lane5m20fps[i].data) != SUCCESS) - { - cnt++; - if(cnt>=10) - { - return FAIL; - } - //usleep(10*1000); - } - //printk("\n reg 0x%x, 0x%x",Sensor_init_table_HDR_DOL_4lane5m20fps[i].reg, Sensor_init_table_HDR_DOL_4lane5m20fps[i].data); -#if 0 - SensorReg_Read(Sensor_init_table_HDR_DOL_4lane5m20fps[i].reg, &sen_data ); - if(Sensor_init_table_HDR_DOL_4lane5m20fps[i].data != sen_data) - printk("R/W Differ Reg: 0x%x\n",Sensor_init_table_HDR_DOL_4lane5m20fps[i].reg); - //printk("IMX335 reg: 0x%x, data: 0x%x, read: 0x%x.\n",Sensor_init_table_HDR_DOL_4lane5m20fps[i].reg, Sensor_init_table_HDR_DOL_4lane5m20fps[i].data, sen_data); -#endif - } - } - return SUCCESS; -} - -static int pCus_init_mipi4lane5m30fps_HDR_DOL(ms_cus_sensor *handle) -{ - int i,cnt=0; - - SENSOR_DMSG("\n[%s]", __FUNCTION__); - - for(i=0;i< ARRAY_SIZE(Sensor_init_table_HDR_DOL_4lane5m30fps);i++) - { - if(Sensor_init_table_HDR_DOL_4lane5m30fps[i].reg==0xffff) - { - SENSOR_MSLEEP(Sensor_init_table_HDR_DOL_4lane5m30fps[i].data); - } - else - { - cnt = 0; - while(SensorReg_Write(Sensor_init_table_HDR_DOL_4lane5m30fps[i].reg,Sensor_init_table_HDR_DOL_4lane5m30fps[i].data) != SUCCESS) - { - cnt++; - if(cnt>=10) - { - return FAIL; - } - //usleep(10*1000); - } - //printk("\n reg 0x%x, 0x%x",Sensor_init_table_HDR_DOL_4lane5m30fps[i].reg, Sensor_init_table_HDR_DOL_4lane5m30fps[i].data); -#if 0 - SensorReg_Read(Sensor_init_table_HDR_DOL_4lane5m30fps[i].reg, &sen_data ); - if(Sensor_init_table_HDR_DOL_4lane5m30fps[i].data != sen_data) - printk("R/W Differ Reg: 0x%x\n",Sensor_init_table_HDR_DOL_4lane5m30fps[i].reg); - //printk("IMX335 reg: 0x%x, data: 0x%x, read: 0x%x.\n",Sensor_init_table_HDR_DOL_4lane5m30fps[i].reg, Sensor_init_table_HDR_DOL_4lane5m30fps[i].data, sen_data); -#endif - } - } - return SUCCESS; -} - -static int pCus_GetVideoResNum( ms_cus_sensor *handle, u32 *ulres_num) -{ - *ulres_num = handle->video_res_supported.num_res; - return SUCCESS; -} - -static int pCus_GetVideoRes(ms_cus_sensor *handle, u32 res_idx, cus_camsensor_res **res) -{ - u32 num_res = handle->video_res_supported.num_res; - - if (res_idx >= num_res) { - return FAIL; - } - - *res = &handle->video_res_supported.res[res_idx]; - - return SUCCESS; -} - -static int pCus_GetCurVideoRes(ms_cus_sensor *handle, u32 *cur_idx, cus_camsensor_res **res) -{ - u32 num_res = handle->video_res_supported.num_res; - - *cur_idx = handle->video_res_supported.ulcur_res; - - if (*cur_idx >= num_res) { - return FAIL; - } - - *res = &handle->video_res_supported.res[*cur_idx]; - - return SUCCESS; -} - -static int pCus_SetVideoRes(ms_cus_sensor *handle, u32 res_idx) -{ - imx335_params *params = (imx335_params *)handle->private_data; - u32 num_res = handle->video_res_supported.num_res; - - if (res_idx >= num_res) { - return FAIL; - } - - switch (res_idx) { - case 0: - handle->video_res_supported.ulcur_res = 0; - if(lane_num == 2){ - handle->pCus_sensor_init = pCus_init_mipi2lane_5m25fps_linear; - } - else if (lane_num == 4){ - handle->pCus_sensor_init = pCus_init_mipi4lane_5m25fps_linear; - } - else{ - handle->pCus_sensor_init = pCus_init_mipi4lane_5m25fps_linear; - } - vts_30fps = 4950; - Preview_MAX_FPS = 25; - Preview_line_period = 8080; - break; - case 1: - handle->video_res_supported.ulcur_res = 1; - if(lane_num == 2){ - handle->pCus_sensor_init = pCus_init_mipi2lane_5m30fps_linear; - } - else if (lane_num == 4){ - handle->pCus_sensor_init = pCus_init_mipi4lane_5m30fps_linear; - } - else{ - handle->pCus_sensor_init = pCus_init_mipi4lane_5m30fps_linear; - } - - vts_30fps = 4125; - Preview_MAX_FPS = 30; - Preview_line_period = 8080; - break; - default: - break; - } - params->expo.vts = vts_30fps; - params->expo.fps = Preview_MAX_FPS; - - return SUCCESS; -} - -static int pCus_SetVideoRes_HDR_DOL(ms_cus_sensor *handle, u32 res_idx) -{ - imx335_params *params = (imx335_params *)handle->private_data; - //ISensorIfAPI *sensor_if = &handle->sensor_if_api; - u32 num_res = handle->video_res_supported.num_res; - if (res_idx >= num_res) { - return FAIL; - } - switch (res_idx) { - - case 0: - handle->video_res_supported.ulcur_res = 0; - handle->pCus_sensor_init = pCus_init_mipi4lane5m25fps_HDR_DOL; - vts_30fps_HDR_DOL = 4250; - params->expo.vts = vts_30fps_HDR_DOL; - Preview_MAX_FPS = 25; - params->expo.fps=Preview_MAX_FPS; - Preview_line_period_HDR_DOL = 9411; //8889 - params->max_rhs1 = 290; - break; - case 1: - handle->video_res_supported.ulcur_res = 1; - handle->pCus_sensor_init = pCus_init_mipi4lane5m20fps_HDR_DOL; - vts_30fps_HDR_DOL = 5312; - params->expo.vts = vts_30fps_HDR_DOL; - Preview_MAX_FPS = 20; - params->expo.fps=Preview_MAX_FPS; - Preview_line_period_HDR_DOL = 9411; - params->max_rhs1 = 290; - break; - case 2: - handle->video_res_supported.ulcur_res = 2; - handle->pCus_sensor_init = pCus_init_mipi4lane5m30fps_HDR_DOL; - vts_30fps_HDR_DOL = 4096; - params->expo.vts = vts_30fps_HDR_DOL; - Preview_MAX_FPS = 30; - params->expo.fps= Preview_MAX_FPS; - Preview_line_period_HDR_DOL = 8318; - params->max_rhs1 = 290; - break; - default: - break; - } - return SUCCESS; -} - -static int pCus_GetOrien(ms_cus_sensor *handle, CUS_CAMSENSOR_ORIT *orit) -{ - short Horiz_Inv = 0; - short Verti_Inv = 0; - short Orien_Mode = 0; - SensorReg_Read(0x304e, &Horiz_Inv); - SensorReg_Read(0x304f, &Verti_Inv); - Horiz_Inv &= 0x01; - Verti_Inv &= 0X01; - Orien_Mode = Horiz_Inv |(Verti_Inv << 2); - switch(Orien_Mode) - { - case 0x00: - *orit = CUS_ORIT_M0F0; - break; - case 0x01: - *orit = CUS_ORIT_M1F0; - break; - case 0x02: - *orit = CUS_ORIT_M0F1; - break; - case 0x03: - *orit = CUS_ORIT_M1F1; - break; - } - return SUCCESS; -} - -static int pCus_SetOrien(ms_cus_sensor *handle, CUS_CAMSENSOR_ORIT orit) -{ - imx335_params *params = (imx335_params *)handle->private_data; - - handle->orient = orit; - params->orien_dirty = true; - - return SUCCESS; -} - -static int DoOrien(ms_cus_sensor *handle, CUS_CAMSENSOR_ORIT orit) -{ - int table_length = ARRAY_SIZE(mirr_flip_table); - int seg_length = table_length/4; - int i,j; - - switch(orit) - { - case CUS_ORIT_M0F0: - handle->orient = CUS_ORIT_M0F0; - for(i = 0, j = 0; i < seg_length; i++, j++){ - SensorReg_Write(mirr_flip_table[i].reg,mirr_flip_table[i].data); - //SensorReg_Write(0x304e,0x00); - //SensorReg_Write(0x304f,0x00); - } - break; - case CUS_ORIT_M1F0: - for(i = seg_length, j = 0; i < seg_length*2; i++, j++){ - handle->orient = CUS_ORIT_M1F0; - SensorReg_Write(mirr_flip_table[i].reg,mirr_flip_table[i].data); - //SensorReg_Write(0x304e,0x01); - //SensorReg_Write(0x304f,0x00); - } - break; - case CUS_ORIT_M0F1: - for(i = seg_length * 2, j = 0; i < seg_length*3; i++, j++){ - handle->orient = CUS_ORIT_M0F1; - SensorReg_Write(mirr_flip_table[i].reg,mirr_flip_table[i].data); - //SensorReg_Write(0x304e,0x00); - //SensorReg_Write(0x304f,0x01); - } - break; - case CUS_ORIT_M1F1: - for(i = seg_length * 3, j = 0; i < seg_length*4; i++, j++){ - handle->orient = CUS_ORIT_M1F1; - SensorReg_Write(mirr_flip_table[i].reg,mirr_flip_table[i].data); - //SensorReg_Write(0x304e,0x01); - //SensorReg_Write(0x304e,0x01); - } - break; - default : - handle->orient = CUS_ORIT_M0F0; - break; - } - return SUCCESS; -} - -static int pCus_GetFPS(ms_cus_sensor *handle) -{ - imx335_params *params = (imx335_params *)handle->private_data; - u32 max_fps = handle->video_res_supported.res[handle->video_res_supported.ulcur_res].max_fps; - u32 tVts = (params->tVts_reg[0].data << 16) | (params->tVts_reg[1].data << 8) | (params->tVts_reg[2].data << 0); - - if (params->expo.fps >= 1000) - params->expo.preview_fps = (vts_30fps*max_fps*1000)/tVts; - else - params->expo.preview_fps = (vts_30fps*max_fps)/tVts; - - return params->expo.preview_fps; -} - -static int pCus_SetFPS(ms_cus_sensor *handle, u32 fps) -{ - u32 vts = 0; - imx335_params *params = (imx335_params *)handle->private_data; - u32 max_fps = handle->video_res_supported.res[handle->video_res_supported.ulcur_res].max_fps; - u32 min_fps = handle->video_res_supported.res[handle->video_res_supported.ulcur_res].min_fps; - - SENSOR_DMSG("\n\n[%s]", __FUNCTION__); - - if(fps>=min_fps && fps <= max_fps){ - params->expo.fps = fps; - params->expo.vts= (vts_30fps*(max_fps*1000) + fps * 500 )/ (fps * 1000); - }else if((fps>=(min_fps*1000)) && (fps <= (max_fps*1000))){ - params->expo.fps = fps; - params->expo.vts = (vts_30fps*(max_fps*1000) + (fps>>1))/fps; - }else{ - //params->expo.vts=vts_30fps; - //params->expo.fps=25; - SENSOR_DMSG("[%s] FPS %d out of range.\n",__FUNCTION__,fps); - return FAIL; - } - - if(params->expo.expo_lines > params->expo.vts -2){ - vts = params->expo.expo_lines + 8; - }else{ - vts = params->expo.vts; - } - params->expo.vts = vts; - pCus_SetAEUSecs(handle, params->expo.expo_lef_us); - - params->dirty = true; - return SUCCESS; -} - -static int pCus_GetFPS_HDR_DOL_SEF1(ms_cus_sensor *handle) -{ - imx335_params *params = (imx335_params *)handle->private_data; - u32 max_fps = handle->video_res_supported.res[handle->video_res_supported.ulcur_res].max_fps; - u32 tVts = (params->tVts_reg[0].data << 16) | (params->tVts_reg[1].data << 8) | (params->tVts_reg[2].data << 0); - - if (params->expo.fps >= 1000) - params->expo.preview_fps = (vts_30fps_HDR_DOL*max_fps*1000)/tVts; - else - params->expo.preview_fps = (vts_30fps_HDR_DOL*max_fps)/tVts; - - return params->expo.preview_fps; -} - -static int pCus_SetFPS_HDR_DOL_SEF1(ms_cus_sensor *handle, u32 fps) -{ - imx335_params *params = (imx335_params *)handle->private_data; - u32 max_fps = handle->video_res_supported.res[handle->video_res_supported.ulcur_res].max_fps; - u32 min_fps = handle->video_res_supported.res[handle->video_res_supported.ulcur_res].min_fps; - - if(fps>=min_fps && fps <= max_fps){ - params->expo.fps = fps; - params->expo.vts = (vts_30fps_HDR_DOL*(max_fps*1000) + fps * 500 )/ (fps * 1000); - }else if((fps >= (min_fps*1000)) && (fps <= (max_fps*1000))){ - params->expo.fps = fps; - params->expo.vts = (vts_30fps_HDR_DOL*(max_fps*1000) + (fps>>1))/fps; - }else{ - //params->expo.vts=vts_30fps; - //params->expo.fps=30; - SENSOR_DMSG("[%s] FPS %d out of range.\n",__FUNCTION__,fps); - return FAIL; - } - params->dirty = true; //reg need to update = true; - pCus_SetAEUSecsHDR_DOL_SEF1(handle, params->expo.expo_sef_us); - - return SUCCESS; -} -#if 0 -static int pCus_GetSensorCap(ms_cus_sensor *handle, CUS_CAMSENSOR_CAP *cap) -{ - if (cap) - memcpy(cap, &sensor_cap, sizeof(CUS_CAMSENSOR_CAP)); - else return FAIL; - return SUCCESS; -} -#endif - -/////////////////////////////////////////////////////////////////////// -// auto exposure -/////////////////////////////////////////////////////////////////////// -// unit: micro seconds -//AE status notification -static int pCus_AEStatusNotify(ms_cus_sensor *handle, CUS_CAMSENSOR_AE_STATUS_NOTIFY status) -{ - imx335_params *params = (imx335_params *)handle->private_data; - - switch(status) - { - case CUS_FRAME_INACTIVE: - //SensorReg_Write(0x3001,0); - break; - case CUS_FRAME_ACTIVE: - if(params->dirty || params->orien_dirty) { - SensorReg_Write(0x3001,1); - SensorRegArrayW((I2C_ARRAY*)params->tExpo_reg, ARRAY_SIZE(expo_reg)); - SensorRegArrayW((I2C_ARRAY*)params->tGain_reg, ARRAY_SIZE(gain_reg)); - SensorRegArrayW((I2C_ARRAY*)params->tVts_reg, ARRAY_SIZE(vts_reg)); - - if(params->orien_dirty) { - DoOrien(handle, handle->orient); - params->orien_dirty = false; - } - SensorReg_Write(0x3001,0); - params->dirty = false; - } - break; - default : - break; - } - return SUCCESS; -} - -static int pCus_AEStatusNotifyHDR_DOL_SEF1(ms_cus_sensor *handle, CUS_CAMSENSOR_AE_STATUS_NOTIFY status) -{ - //imx335_params *params = (imx335_params *)handle->private_data; - switch(status) - { - case CUS_FRAME_INACTIVE: - //SensorReg_Write(0x3001,0); - break; - case CUS_FRAME_ACTIVE: - break; - default : - break; - } - return SUCCESS; -} - -static int pCus_GetAEUSecs(ms_cus_sensor *handle, u32 *us) -{ - u32 lines = 0; - imx335_params *params = (imx335_params *)handle->private_data; - - lines |= (u32)(params->tExpo_reg[0].data&0xff)<<16; - lines |= (u32)(params->tExpo_reg[1].data&0xff)<<8; - lines |= (u32)(params->tExpo_reg[2].data&0xff)<<0; - - *us = (lines*Preview_line_period)/1000; - SENSOR_DMSG("[%s] sensor expo lines/us %u,%u us\n", __FUNCTION__, lines, *us); - - return SUCCESS; -} - -static int pCus_SetAEUSecs(ms_cus_sensor *handle, u32 us) -{ - u32 lines = 0, vts = 0,activeline = 0; - imx335_params *params = (imx335_params *)handle->private_data; - - params->expo.expo_lef_us = us; - - lines = (1000 * us) / Preview_line_period; - if(lines < 9) lines = 9; - params->expo.expo_lines = lines; - - if (lines >params->expo.vts-1) - vts = lines +1; - else - vts = params->expo.vts; - - SENSOR_DMSG("[%s] us %u, lines %u, vts %u\n", __FUNCTION__, - us, - lines, - params->expo.vts - ); - - activeline = vts - lines; - if(activeline < 9) activeline = 9; - - params->tExpo_reg[0].data = (activeline>>16) & 0x000f; - params->tExpo_reg[1].data = (activeline>>8) & 0x00ff; - params->tExpo_reg[2].data = (activeline>>0) & 0x00ff; - - params->tVts_reg[0].data = (vts >> 16) & 0x000f; - params->tVts_reg[1].data = (vts >> 8) & 0x00ff; - params->tVts_reg[2].data = (vts >> 0) & 0x00ff; - - params->dirty = true; - return SUCCESS; -} - -static int pCus_SetAEUSecsHDR_DOL_SEF1(ms_cus_sensor *handle, u32 us) -{ - u32 qua_lines = 0, lines = 0, long_lines = 0,vts = 0, fsc = 0; - u32 rhs1 = 0, shs1 = 0, shs0 = 0; - imx335_params *params = (imx335_params *)handle->private_data; - - params->expo.expo_sef_us = us; - qua_lines = (1000 * us) / Preview_line_period_HDR_DOL /4; - vts = params->expo.vts; - shs0 = (params->tExpo_reg[0].data << 16) | (params->tExpo_reg[1].data << 8) | (params->tExpo_reg[2].data << 0); - fsc = vts * 2; - long_lines = fsc - shs0; - params->expo.expo_lines = long_lines; - - //params->max_rhs1 = 290; - rhs1 = params->max_rhs1;//(params->tExpo_rhs1_reg[0].data << 16) | (params->tExpo_rhs1_reg[1].data << 8) | (params->tExpo_rhs1_reg[2].data << 0); - - if(qua_lines <= 1) - qua_lines = 1; - if((4*qua_lines) > (rhs1- 18)) - qua_lines = (rhs1 - 18)/4; - - lines = 4*qua_lines; - if((rhs1 - 18) <= lines){ - shs1 = 18; - } - else if((rhs1 <= params->max_rhs1) && (rhs1 <= shs0 - 18)){ - shs1 = rhs1 - lines; - if((shs1 < 18) || (shs1 > (rhs1 - 4))){ //Check boundary - //shs1 = 0; - //UartSendTrace("[SEF1 NG1]"); - } - } - else{ - //UartSendTrace("[SEF1 NG2]"); - } - - params->tExpo_shr_dol1_reg[0].data = (shs1 >> 16) & 0x000f; - params->tExpo_shr_dol1_reg[1].data = (shs1 >> 8) & 0x00ff; - params->tExpo_shr_dol1_reg[2].data = (shs1 >> 0) & 0x00ff; - params->tExpo_rhs1_reg[0].data = (rhs1 >> 16) & 0x000f; - params->tExpo_rhs1_reg[1].data = (rhs1 >> 8) & 0x00ff; - params->tExpo_rhs1_reg[2].data = (rhs1 >> 0) & 0x00ff; - - return SUCCESS; -} - -// Gain: 1x = 1024 -static int pCus_GetAEGain(ms_cus_sensor *handle, u32* gain) -{ - //int rc = SensorRegArrayR((I2C_ARRAY*)params->tGain_reg, ARRAY_SIZE(gain_reg)); - unsigned short temp_gain; - // *gain=params->expo.final_gain; - temp_gain=gain_reg[0].data; - - *gain=(u32)(10^((temp_gain*3)/200))*1024; - if (gain_reg[1].data & 0x10) - *gain = (*gain) * 2; - - SENSOR_DMSG("[%s] get gain/reg (1024=1X)= %u/0x%x\n", __FUNCTION__, *gain,gain_reg[0].data); - //return rc; - return SUCCESS; -} - -static int pCus_SetAEGain_cal(ms_cus_sensor *handle, u32 gain) -{ - imx335_params *params = (imx335_params *)handle->private_data; - //double gain_double; - u64 gain_double; - params->expo.final_gain = gain; - - if(gain<1024) - gain=1024; - else if(gain>=3980*1024) - gain=3980*1024; - - gain_double = 20*(intlog10(gain)-intlog10(1024)); - params->tGain_reg[0].data=(u16)(((gain_double*10)>> 24)/3); - - SENSOR_DMSG("[%s] set gain/reg=%u/0x%x\n", __FUNCTION__, gain,params->tGain_reg[0].data); - - params->dirty = true; - return SUCCESS; -} - -static int pCus_SetAEGain(ms_cus_sensor *handle, u32 gain) -{ - //extern DBG_ITEM Dbg_Items[DBG_TAG_MAX]; - imx335_params *params = (imx335_params *)handle->private_data; - u32 i=0; - CUS_GAIN_GAP_ARRAY* Sensor_Gain_Linearity; - u64 gain_double; - - params->expo.final_gain = gain; - if(gain < SENSOR_MIN_GAIN) - gain = SENSOR_MIN_GAIN; - else if(gain >= SENSOR_MAX_GAIN) - gain = SENSOR_MAX_GAIN; - Sensor_Gain_Linearity = gain_gap_compensate; - - for(i = 0; i < sizeof(gain_gap_compensate)/sizeof(CUS_GAIN_GAP_ARRAY); i++){ - - if (Sensor_Gain_Linearity[i].gain == 0) - break; - if((gain>Sensor_Gain_Linearity[i].gain) && (gain < (Sensor_Gain_Linearity[i].gain + Sensor_Gain_Linearity[i].offset))){ - gain=Sensor_Gain_Linearity[i].gain; - break; - } - } - - gain_double = 20*(intlog10(gain)-intlog10(1024)); - params->tGain_reg[0].data=(u16)(((gain_double*10)>> 24)/3) & 0x00ff; - params->tGain_reg[1].data=(u16)((((gain_double*10)>> 24)/3) >> 8) & 0x0007; - - SENSOR_DMSG("[%s] set gain/reg=%u/0x%x\n", __FUNCTION__, gain,params->tGain_reg[0].data); - params->dirty = true; - return SUCCESS; -} - -static void pCus_SetAEGainHDR_DOL_Calculate(u32 gain, u16 *gain_reg) -{ - //double gain_double; - u64 gain_double; - - if(gain < SENSOR_MIN_GAIN){ - gain = SENSOR_MIN_GAIN; - } - else if(gain >= SENSOR_MAX_GAIN){ - gain = SENSOR_MAX_GAIN; - } - gain_double = 20*(intlog10(gain)-intlog10(1024)); - *gain_reg=(u16)(((gain_double*10)>> 24)/3) & 0x07ff; -} - -static int pCus_SetAEGainHDR_DOL_SEF1(ms_cus_sensor *handle, u32 gain) -{ - imx335_params *params = (imx335_params *)handle->private_data; - u16 gain_reg = 0; - - pCus_SetAEGainHDR_DOL_Calculate(gain, &gain_reg); - params->tGain_hdr_dol_sef_reg[0].data = gain_reg & 0x00ff; - params->tGain_hdr_dol_sef_reg[1].data = (gain_reg>>8) & 0x0007; - - SENSOR_DMSG("[%s] set gain/reg=%u/0x%x\n", __FUNCTION__, gain, params->tGain_hdr_dol_sef_reg[0].data); - - params->dirty = true; - return SUCCESS; -} - -static int pCus_GetAEMinMaxUSecs(ms_cus_sensor *handle, u32 *min, u32 *max) -{ - *min = 1; - *max = 1000000/imx335_mipi_linear[0].senout.min_fps; - return SUCCESS; -} - -static int pCus_GetAEMinMaxGain(ms_cus_sensor *handle, u32 *min, u32 *max) -{ - *min = SENSOR_MIN_GAIN;//handle->sat_mingain; - *max = SENSOR_MAX_GAIN;//3980*1024; - return SUCCESS; -} - -static int IMX335_GetShutterInfo(struct __ms_cus_sensor* handle,CUS_SHUTTER_INFO *info) -{ - info->max = 1000000000/imx335_mipi_linear[0].senout.min_fps; - info->min = (Preview_line_period * 9); - info->step = Preview_line_period; - return SUCCESS; -} - -static int pCus_setCaliData_gain_linearity(ms_cus_sensor* handle, CUS_GAIN_GAP_ARRAY* pArray, u32 num) { - u32 i, j; - - for(i=0,j=0;i< num ;i++,j+=2){ - gain_gap_compensate[i].gain=pArray[i].gain; - gain_gap_compensate[i].offset=pArray[i].offset; - } - return SUCCESS; -} - -static int IMX335_GetShutterInfoHDR_DOL_SEF1(struct __ms_cus_sensor* handle,CUS_SHUTTER_INFO *info) -{ - imx335_params *params = (imx335_params *)handle->private_data; - info->max = Preview_line_period_HDR_DOL * params->max_rhs1; - info->min = (Preview_line_period_HDR_DOL * 4); - info->step = Preview_line_period_HDR_DOL; - return SUCCESS; -} - -int cus_camsensor_init_handle_linear(ms_cus_sensor* drv_handle) -{ - ms_cus_sensor *handle = drv_handle; - imx335_params *params; - int res; - - if (!handle) { - SENSOR_DMSG("[%s] not enough memory!\n", __FUNCTION__); - return FAIL; - } - SENSOR_DMSG("[%s]", __FUNCTION__); - //////////////////////////////////// - // private data allocation & init // - //////////////////////////////////// - if (handle->private_data == NULL) { - SENSOR_EMSG("[%s] Private data is empty!\n", __FUNCTION__); - return FAIL; - } - - params = (imx335_params *)handle->private_data; - memcpy(params->tGain_reg, gain_reg, sizeof(gain_reg)); - memcpy(params->tExpo_reg, expo_reg, sizeof(expo_reg)); - memcpy(params->tVts_reg, vts_reg, sizeof(vts_reg)); - //memcpy(params->tExpo_rhs1_reg, expo_rhs1_reg, sizeof(expo_rhs1_reg)); - //memcpy(params->tExpo_shr_dol1_reg, expo_shr_dol1_reg, sizeof(expo_shr_dol1_reg)); - //memcpy(params->tGain_hdr_dol_lef_reg, gain_HDR_DOL_LEF_reg, sizeof(gain_HDR_DOL_LEF_reg)); - //memcpy(params->tGain_hdr_dol_sef_reg, gain_HDR_DOL_SEF1_reg, sizeof(gain_HDR_DOL_SEF1_reg)); - - //////////////////////////////////// - // sensor model ID // - //////////////////////////////////// - sprintf(handle->model_id,"IMX335_MIPI"); - - //////////////////////////////////// - // i2c config // - //////////////////////////////////// - handle->i2c_cfg.mode = SENSOR_I2C_LEGACY; //(CUS_ISP_I2C_MODE) FALSE; - handle->i2c_cfg.fmt = SENSOR_I2C_FMT; //CUS_I2C_FMT_A16D8; - handle->i2c_cfg.address = SENSOR_I2C_ADDR; //0x34; - handle->i2c_cfg.speed = SENSOR_I2C_SPEED; //300000; - - //////////////////////////////////// - // mclk // - //////////////////////////////////// - handle->mclk = Preview_MCLK_SPEED;//UseParaMclk(SENSOR_DRV_PARAM_MCLK()); - - //////////////////////////////////// - // sensor interface info // - //////////////////////////////////// - handle->isp_type = SENSOR_ISP_TYPE; - //handle->data_fmt = SENSOR_DATAFMT; - handle->sif_bus = SENSOR_IFBUS_TYPE; - handle->data_prec = SENSOR_DATAPREC; - handle->data_mode = SENSOR_DATAMODE; - handle->bayer_id = SENSOR_BAYERID; - handle->RGBIR_id = SENSOR_RGBIRID; - handle->orient = SENSOR_ORIT; - //handle->YC_ODER = SENSOR_YCORDER; //CUS_SEN_YCODR_CY; - handle->interface_attr.attr_mipi.mipi_lane_num = SENSOR_MIPI_LANE_NUM; - handle->interface_attr.attr_mipi.mipi_data_format = CUS_SEN_INPUT_FORMAT_RGB; // RGB pattern. - handle->interface_attr.attr_mipi.mipi_yuv_order = 0; //don't care in RGB pattern. - handle->interface_attr.attr_mipi.mipi_hsync_mode = SENSOR_MIPI_HSYNC_MODE; - handle->interface_attr.attr_mipi.mipi_hdr_mode = CUS_HDR_MODE_NONE; - handle->interface_attr.attr_mipi.mipi_hdr_virtual_channel_num = 0; //Short frame - - //////////////////////////////////// - // resolution capability // - //////////////////////////////////// - handle->video_res_supported.ulcur_res = 0; //default resolution index is 0. - //handle->video_res_supported.num_res = LINEAR_RES_END; - for (res = 0; res < LINEAR_RES_END; res++) { - handle->video_res_supported.num_res = res+1; - handle->video_res_supported.res[res].width = imx335_mipi_linear[res].senif.preview_w; - handle->video_res_supported.res[res].height = imx335_mipi_linear[res].senif.preview_h; - handle->video_res_supported.res[res].max_fps = imx335_mipi_linear[res].senout.max_fps; - handle->video_res_supported.res[res].min_fps = imx335_mipi_linear[res].senout.min_fps; - handle->video_res_supported.res[res].crop_start_x = imx335_mipi_linear[res].senif.crop_start_X; - handle->video_res_supported.res[res].crop_start_y = imx335_mipi_linear[res].senif.crop_start_y; - handle->video_res_supported.res[res].nOutputWidth = imx335_mipi_linear[res].senout.width; - handle->video_res_supported.res[res].nOutputHeight = imx335_mipi_linear[res].senout.height; - sprintf(handle->video_res_supported.res[res].strResDesc, imx335_mipi_linear[res].senstr.strResDesc); - } - - //////////////////////////////////// - // Sensor polarity // - //////////////////////////////////// - handle->pwdn_POLARITY = SENSOR_PWDN_POL; //CUS_CLK_POL_NEG; - handle->reset_POLARITY = SENSOR_RST_POL; //CUS_CLK_POL_NEG; - //handle->VSYNC_POLARITY = SENSOR_VSYNC_POL; //CUS_CLK_POL_POS; - //handle->HSYNC_POLARITY = SENSOR_HSYNC_POL; //CUS_CLK_POL_POS; - handle->PCLK_POLARITY = SENSOR_PCLK_POL; //CUS_CLK_POL_POS); // use '!' to clear board latch error - - //////////////////////////////////////// - // Sensor Status Control and Get Info // - //////////////////////////////////////// - handle->pCus_sensor_release = cus_camsensor_release_handle; - handle->pCus_sensor_init = pCus_init_mipi4lane_5m30fps_linear; - //handle->pCus_sensor_powerupseq = pCus_powerupseq; - handle->pCus_sensor_poweron = pCus_poweron; - handle->pCus_sensor_poweroff = pCus_poweroff; - handle->pCus_sensor_GetSensorID = pCus_GetSensorID; - handle->pCus_sensor_GetVideoResNum = pCus_GetVideoResNum; - handle->pCus_sensor_GetVideoRes = pCus_GetVideoRes; - handle->pCus_sensor_GetCurVideoRes = pCus_GetCurVideoRes; - handle->pCus_sensor_SetVideoRes = pCus_SetVideoRes; - - handle->pCus_sensor_GetOrien = pCus_GetOrien; - handle->pCus_sensor_SetOrien = pCus_SetOrien; - handle->pCus_sensor_GetFPS = pCus_GetFPS; - handle->pCus_sensor_SetFPS = pCus_SetFPS; - //handle->pCus_sensor_GetSensorCap = pCus_GetSensorCap; - handle->pCus_sensor_SetPatternMode = imx335_SetPatternMode; - - //////////////////////////////////// - // AE parameters // - //////////////////////////////////// - handle->ae_gain_delay = SENSOR_GAIN_DELAY_FRAME_COUNT; - handle->ae_shutter_delay = SENSOR_SHUTTER_DELAY_FRAME_COUNT; - handle->ae_gain_ctrl_num = 1; - handle->ae_shutter_ctrl_num = 1; - handle->sat_mingain = SENSOR_MIN_GAIN; //calibration - //handle->dgain_remainder = 0; - - //////////////////////////////////// - // AE Control and Get Info // - //////////////////////////////////// - // unit: micro seconds - //handle->pCus_sensor_GetAETrigger_mode = pCus_GetAETrigger_mode; - //handle->pCus_sensor_SetAETrigger_mode = pCus_SetAETrigger_mode; - handle->pCus_sensor_AEStatusNotify = pCus_AEStatusNotify; - handle->pCus_sensor_GetAEUSecs = pCus_GetAEUSecs; - handle->pCus_sensor_SetAEUSecs = pCus_SetAEUSecs; - handle->pCus_sensor_GetAEGain = pCus_GetAEGain; - handle->pCus_sensor_SetAEGain = pCus_SetAEGain; - - handle->pCus_sensor_GetAEMinMaxGain = pCus_GetAEMinMaxGain; - handle->pCus_sensor_GetAEMinMaxUSecs= pCus_GetAEMinMaxUSecs; - //handle->pCus_sensor_GetDGainRemainder = pCus_GetDGainRemainder; - - //sensor calibration - handle->pCus_sensor_SetAEGain_cal = pCus_SetAEGain_cal; - handle->pCus_sensor_setCaliData_gain_linearity=pCus_setCaliData_gain_linearity; - handle->pCus_sensor_GetShutterInfo = IMX335_GetShutterInfo; - - params->expo.vts = vts_30fps; - params->expo.expo_lines = 5000; - params->dirty = false; - - return SUCCESS; -} - -int cus_camsensor_init_handle_hdr_dol_sef1(ms_cus_sensor* drv_handle) -{ - ms_cus_sensor *handle = drv_handle; - imx335_params *params = NULL; - int res; - - if (!handle) { - SENSOR_DMSG("[%s] not enough memory!\n", __FUNCTION__); - return FAIL; - } - SENSOR_DMSG("[%s]", __FUNCTION__); - //////////////////////////////////// - // private data allocation & init // - //////////////////////////////////// - if (handle->private_data == NULL) { - SENSOR_EMSG("[%s] Private data is empty!\n", __FUNCTION__); - return FAIL; - } - - params = (imx335_params *)handle->private_data; - memcpy(params->tExpo_rhs1_reg, expo_rhs1_reg, sizeof(expo_rhs1_reg)); - memcpy(params->tExpo_shr_dol1_reg, expo_shr_dol1_reg, sizeof(expo_shr_dol1_reg)); - memcpy(params->tGain_hdr_dol_sef_reg, gain_HDR_DOL_SEF1_reg, sizeof(gain_HDR_DOL_SEF1_reg)); - - //////////////////////////////////// - // sensor model ID // - //////////////////////////////////// - sprintf(handle->model_id,"IMX335_MIPI_HDR_SEF"); - - //////////////////////////////////// - // i2c config // - //////////////////////////////////// - handle->i2c_cfg.mode = SENSOR_I2C_LEGACY; //(CUS_ISP_I2C_MODE) FALSE; - handle->i2c_cfg.fmt = SENSOR_I2C_FMT; //CUS_I2C_FMT_A16D16; - handle->i2c_cfg.address = SENSOR_I2C_ADDR; //0x5a; - handle->i2c_cfg.speed = SENSOR_I2C_SPEED; //320000; - - //////////////////////////////////// - // mclk // - //////////////////////////////////// - handle->mclk = Preview_MCLK_SPEED_HDR_DOL;//UseParaMclk(SENSOR_DRV_PARAM_MCLK()); - - //////////////////////////////////// - // sensor interface info // - //////////////////////////////////// - //handle->isp_type = SENSOR_ISP_TYPE; - //handle->data_fmt = SENSOR_DATAFMT; - handle->sif_bus = SENSOR_IFBUS_TYPE; - handle->data_prec = SENSOR_DATAPREC_DOL; - handle->data_mode = SENSOR_DATAMODE; - handle->bayer_id = SENSOR_BAYERID_HDR_DOL; - handle->RGBIR_id = SENSOR_RGBIRID; - - handle->interface_attr.attr_mipi.mipi_lane_num = SENSOR_MIPI_LANE_NUM_DOL; - handle->interface_attr.attr_mipi.mipi_data_format = CUS_SEN_INPUT_FORMAT_RGB; - handle->interface_attr.attr_mipi.mipi_hsync_mode = SENSOR_MIPI_HSYNC_MODE_HDR_DOL; - handle->interface_attr.attr_mipi.mipi_hdr_mode = CUS_HDR_MODE_SONY_DOL; - handle->interface_attr.attr_mipi.mipi_hdr_virtual_channel_num = 1; //Short frame - - //////////////////////////////////// - // resolution capability // - //////////////////////////////////// - handle->video_res_supported.ulcur_res = 0; //default resolution index is 0. - for (res = 0; res < HDR_RES_END; res++) { - handle->video_res_supported.num_res = res+1; - handle->video_res_supported.res[res].width = imx335_mipi_hdr[res].senif.preview_w; - handle->video_res_supported.res[res].height = imx335_mipi_hdr[res].senif.preview_h; - handle->video_res_supported.res[res].max_fps = imx335_mipi_hdr[res].senout.max_fps; - handle->video_res_supported.res[res].min_fps = imx335_mipi_hdr[res].senout.min_fps; - handle->video_res_supported.res[res].crop_start_x = imx335_mipi_hdr[res].senif.crop_start_X; - handle->video_res_supported.res[res].crop_start_y = imx335_mipi_hdr[res].senif.crop_start_y; - handle->video_res_supported.res[res].nOutputWidth = imx335_mipi_hdr[res].senout.width; - handle->video_res_supported.res[res].nOutputHeight = imx335_mipi_hdr[res].senout.height; - sprintf(handle->video_res_supported.res[res].strResDesc, imx335_mipi_hdr[res].senstr.strResDesc); - } - - //////////////////////////////////// - // Sensor polarity // - //////////////////////////////////// - handle->pwdn_POLARITY = SENSOR_PWDN_POL; //CUS_CLK_POL_NEG; - handle->reset_POLARITY = SENSOR_RST_POL; //CUS_CLK_POL_NEG; - //handle->VSYNC_POLARITY = SENSOR_VSYNC_POL; //CUS_CLK_POL_POS; - //handle->HSYNC_POLARITY = SENSOR_HSYNC_POL; //CUS_CLK_POL_POS; - handle->PCLK_POLARITY = SENSOR_PCLK_POL; //CUS_CLK_POL_POS); // use '!' to clear board latch error - - //////////////////////////////////////// - // Sensor Status Control and Get Info // - //////////////////////////////////////// - handle->pCus_sensor_release = cus_camsensor_release_handle; - handle->pCus_sensor_init = pCus_init_mipi4lane5m25fps_HDR_DOL; - handle->pCus_sensor_poweron = pCus_poweron; // Need to check - handle->pCus_sensor_poweroff = pCus_poweroff; - handle->pCus_sensor_GetSensorID = pCus_GetSensorID; - handle->pCus_sensor_GetVideoResNum = pCus_GetVideoResNum; - handle->pCus_sensor_SetVideoRes = pCus_SetVideoRes_HDR_DOL; - handle->pCus_sensor_GetVideoRes = pCus_GetVideoRes; - handle->pCus_sensor_GetCurVideoRes = pCus_GetCurVideoRes; - - handle->pCus_sensor_GetOrien = pCus_GetOrien; // Need to check - handle->pCus_sensor_SetOrien = pCus_SetOrien; // Need to check - handle->pCus_sensor_GetFPS = pCus_GetFPS_HDR_DOL_SEF1; - handle->pCus_sensor_SetFPS = pCus_SetFPS_HDR_DOL_SEF1; - - //////////////////////////////////// - // AE parameters // - //////////////////////////////////// - handle->ae_gain_delay = SENSOR_GAIN_DELAY_FRAME_COUNT_HDR_DOL; - handle->ae_shutter_delay = SENSOR_SHUTTER_DELAY_FRAME_COUNT_HDR_DOL; - handle->ae_gain_ctrl_num = 2; - handle->ae_shutter_ctrl_num = 2; - handle->sat_mingain = SENSOR_MIN_GAIN; //g_sensor_ae_min_gain; - //handle->dgain_remainder = 0; - - //////////////////////////////////// - // AE Control and Get Info // - //////////////////////////////////// - handle->pCus_sensor_AEStatusNotify = pCus_AEStatusNotifyHDR_DOL_SEF1; - handle->pCus_sensor_GetAEUSecs = pCus_GetAEUSecs; - handle->pCus_sensor_SetAEUSecs = pCus_SetAEUSecsHDR_DOL_SEF1; - handle->pCus_sensor_GetAEGain = pCus_GetAEGain; - handle->pCus_sensor_SetAEGain = pCus_SetAEGainHDR_DOL_SEF1; - handle->pCus_sensor_GetAEMinMaxGain = pCus_GetAEMinMaxGain; - handle->pCus_sensor_GetAEMinMaxUSecs= pCus_GetAEMinMaxUSecs; - - handle->pCus_sensor_GetShutterInfo = IMX335_GetShutterInfoHDR_DOL_SEF1; - params->expo.vts = vts_30fps_HDR_DOL; - params->expo.expo_lines = 4250; - return SUCCESS; -} - -//lef functions -static int pCus_init_HDR_DOL_LEF(ms_cus_sensor *handle) -{ - return SUCCESS; -} - -static int pCus_poweron_HDR_DOL_LEF(ms_cus_sensor *handle, u32 idx) -{ - return SUCCESS; -} - -static int pCus_poweroff_HDR_DOL_LEF(ms_cus_sensor *handle, u32 idx) -{ - return SUCCESS; -} - -static int pCus_GetSensorID_HDR_DOL_LEF(ms_cus_sensor *handle, u32 *id) -{ - *id = 0; - return SUCCESS; -} - -static int pCus_GetOrien_HDR_DOL_LEF(ms_cus_sensor *handle, CUS_CAMSENSOR_ORIT *orit) -{ - *orit = CUS_ORIT_M0F0; - return SUCCESS; -} - -static int pCus_SetOrien_HDR_DOL_LEF(ms_cus_sensor *handle, CUS_CAMSENSOR_ORIT orit) -{ - return SUCCESS; -} - -static int pCus_GetFPS_HDR_DOL_LEF(ms_cus_sensor *handle) -{ - imx335_params *params = (imx335_params *)handle->private_data; - u32 max_fps = handle->video_res_supported.res[handle->video_res_supported.ulcur_res].max_fps; - u32 tVts = (params->tVts_reg[0].data << 16) | (params->tVts_reg[1].data << 8) | (params->tVts_reg[2].data << 0); - - if (params->expo.fps >= 1000) - params->expo.preview_fps = (vts_30fps_HDR_DOL*max_fps*1000)/tVts; - else - params->expo.preview_fps = (vts_30fps_HDR_DOL*max_fps)/tVts; - - return params->expo.preview_fps; -} - -static int pCus_SetFPS_HDR_DOL_LEF(ms_cus_sensor *handle, u32 fps) -{ - u32 vts = 0; - imx335_params *params = (imx335_params *)handle->private_data; - u32 max_fps = handle->video_res_supported.res[handle->video_res_supported.ulcur_res].max_fps; - u32 min_fps = handle->video_res_supported.res[handle->video_res_supported.ulcur_res].min_fps; - - if(fps>=min_fps && fps <= max_fps){ - params->expo.fps = fps; - params->expo.vts= (vts_30fps_HDR_DOL*max_fps)/fps; - }else if((fps >= (min_fps*1000)) && (fps <= (max_fps*1000))){ - params->expo.fps = fps; - params->expo.vts= (vts_30fps_HDR_DOL*(max_fps*1000))/fps; - }else{ - //params->expo.vts=vts_30fps; - //params->expo.fps=30; - SENSOR_DMSG("[%s] FPS %d out of range.\n",__FUNCTION__,fps); - return FAIL; - } - - if(params->expo.expo_lines > 2 * params->expo.vts - params->max_rhs1 -18){ - vts = (params->expo.expo_lines + params->max_rhs1 + 18) / 2; - }else{ - vts = params->expo.vts; - } - - pCus_SetAEUSecsHDR_DOL_LEF(handle, params->expo.expo_lef_us); - - return SUCCESS; -} -#if 0 -static int pCus_GetSensorCap_hdr_dol_lef(ms_cus_sensor *handle, CUS_CAMSENSOR_CAP *cap) -{ - if (cap) - memcpy(cap, &sensor_cap, sizeof(CUS_CAMSENSOR_CAP)); - else return FAIL; - return SUCCESS; -} -#endif -static int imx335_SetPatternMode_hdr_dol_lef(ms_cus_sensor *handle,u32 mode) -{ - return SUCCESS; -} - -static int pCus_AEStatusNotifyHDR_DOL_LEF(ms_cus_sensor *handle, CUS_CAMSENSOR_AE_STATUS_NOTIFY status) -{ - imx335_params *params = (imx335_params *)handle->private_data; - - switch(status) - { - case CUS_FRAME_INACTIVE: - break; - case CUS_FRAME_ACTIVE: - if(params->dirty || params->orien_dirty) - { - SensorReg_Write(0x3001,1); - SensorRegArrayW((I2C_ARRAY*)params->tExpo_shr_dol1_reg, ARRAY_SIZE(expo_shr_dol1_reg)); - SensorRegArrayW((I2C_ARRAY*)params->tVts_reg, ARRAY_SIZE(vts_reg)); - SensorRegArrayW((I2C_ARRAY*)params->tExpo_reg, ARRAY_SIZE(expo_reg)); - SensorRegArrayW((I2C_ARRAY*)params->tExpo_rhs1_reg, ARRAY_SIZE(expo_rhs1_reg)); - SensorRegArrayW((I2C_ARRAY*)params->tGain_hdr_dol_lef_reg, ARRAY_SIZE(gain_HDR_DOL_LEF_reg)); - SensorRegArrayW((I2C_ARRAY*)params->tGain_hdr_dol_sef_reg, ARRAY_SIZE(gain_HDR_DOL_SEF1_reg)); - - if(params->orien_dirty) { - DoOrien(handle, handle->orient); - params->orien_dirty = false; - } - SensorReg_Write(0x3001,0); - } - break; - default : - break; - } - return SUCCESS; -} - -static int pCus_GetAEUSecs_HDR_DOL_LEF(ms_cus_sensor *handle, u32 *us) -{ - *us = 0; - return SUCCESS; -} - -static int pCus_SetAEUSecsHDR_DOL_LEF(ms_cus_sensor *handle, u32 us) -{ - u32 qua_lines = 0,lines = 0, half_vts = 0, vts = 0, shr_dol0 = 0, fsc = 0; - imx335_params *params = (imx335_params *)handle->private_data; - - qua_lines = (1000 * us) / Preview_line_period_HDR_DOL / 4; - // lines=us/Preview_line_period_HDR_DOL; - params->expo.expo_lef_us = us; - - if (4 * qua_lines > 2 * params->expo.vts - params->max_rhs1 - 18) { // shs2 > max_rhs1 +2 - half_vts = (4 * qua_lines + params->max_rhs1 + 19) / 4; - } - else{ - half_vts = params->expo.vts / 2; - } - - SENSOR_DMSG("[%s] us %u, qua_lines %u, vts %u\n", __FUNCTION__, - us, - qua_lines, - params->expo.vts - ); - - //exposure limit lines = fsc - (shs2 + 1) = fsc - 1 - ( rhs1 + 2 ~ fsc - 2) = 1 ~ fsc - 104 (rhs1 fix to 101) - vts = half_vts * 2; - fsc = half_vts * 4; - if(qua_lines < 1) // shs2 < fsc - 2 - qua_lines = 1; - if(4 * qua_lines > fsc - params->max_rhs1 - 18) - qua_lines = (fsc - params->max_rhs1 - 18) / 4; - - lines = 4*qua_lines; - params->expo.expo_lines = lines; - - shr_dol0 = fsc - lines; -#if 0 - printk("[%s] us %u, qua_lines %u, vts %u shr_dol0 %u\n", __FUNCTION__, - us, - qua_lines, - params->expo.vts, - shr_dol0 - ); -#endif - params->tExpo_reg[0].data = (shr_dol0 >> 16) & 0x000f; - params->tExpo_reg[1].data = (shr_dol0 >> 8) & 0x00ff; - params->tExpo_reg[2].data = (shr_dol0 >> 0) & 0x00ff; - - params->tVts_reg[0].data = (vts >> 16) & 0x000f; - params->tVts_reg[1].data = (vts >> 8) & 0x00ff; - params->tVts_reg[2].data = (vts >> 0) & 0x00ff; - - params->dirty = true; - return SUCCESS; -} - -static int pCus_GetAEGain_HDR_DOL_LEF(ms_cus_sensor *handle, u32* gain) -{ - *gain = 0; - return SUCCESS; -} - -static int pCus_SetAEGainHDR_DOL_LEF(ms_cus_sensor *handle, u32 gain) -{ - imx335_params *params = (imx335_params *)handle->private_data; - u16 gain_reg = 0; - - pCus_SetAEGainHDR_DOL_Calculate(gain, &gain_reg); - params->tGain_hdr_dol_lef_reg[0].data = gain_reg & 0x00ff; - params->tGain_hdr_dol_lef_reg[1].data = (gain_reg>>8) & 0x0007; - - SENSOR_DMSG("[%s] set gain/reg=%u/0x%x\n", __FUNCTION__, gain, params->tGain_hdr_dol_lef_reg[0].data); - - params->dirty = true; - return SUCCESS; -} - -static int pCus_GetAEMinMaxGain_HDR_DOL_LEF(ms_cus_sensor *handle, u32 *min, u32 *max) -{ - *min = handle->sat_mingain; - *max = SENSOR_MAX_GAIN; - return SUCCESS; -} - -static int pCus_GetAEMinMaxUSecs_HDR_DOL_LEF(ms_cus_sensor *handle, u32 *min, u32 *max) -{ - *min = 1; - *max = 1000000/imx335_mipi_linear[0].senout.min_fps; - return SUCCESS; -} - -static int pCus_SetAEGain_cal_hdr_dol_lef(ms_cus_sensor *handle, u32 gain) -{ - return SUCCESS; -} - -static int pCus_setCaliData_gain_linearity_hdr_dol_lef(ms_cus_sensor* handle, CUS_GAIN_GAP_ARRAY* pArray, u32 num) -{ - return SUCCESS; -} - -static int IMX335_GetShutterInfo_hdr_dol_lef(struct __ms_cus_sensor* handle,CUS_SHUTTER_INFO *info) -{ - info->max = 1000000000/imx335_mipi_linear[0].senout.min_fps; - info->min = (Preview_line_period_HDR_DOL * 4); - info->step = Preview_line_period_HDR_DOL; - return SUCCESS; -} - -static int cus_camsensor_init_handle_hdr_dol_lef(ms_cus_sensor* drv_handle) -{ - ms_cus_sensor *handle = drv_handle; - imx335_params *params; - s32 res; - - if (!handle) { - SENSOR_DMSG("[%s] not enough memory!\n", __FUNCTION__); - return FAIL; - } - - //private data allocation & init - if (handle->private_data == NULL) { - SENSOR_EMSG("[%s] Private data is empty!\n", __FUNCTION__); - return FAIL; - } - params = (imx335_params *)handle->private_data; - memcpy(params->tVts_reg, vts_reg, sizeof(vts_reg)); - memcpy(params->tExpo_reg, expo_reg, sizeof(expo_reg)); - memcpy(params->tGain_hdr_dol_lef_reg, gain_HDR_DOL_LEF_reg, sizeof(gain_HDR_DOL_LEF_reg)); - - //////////////////////////////////// - // sensor model ID // - //////////////////////////////////// - sprintf(handle->model_id,"IMX335_MIPI_HDR_LEF"); - - //////////////////////////////////// - // i2c config // - //////////////////////////////////// - handle->i2c_cfg.mode = SENSOR_I2C_LEGACY; //(CUS_ISP_I2C_MODE) FALSE; - handle->i2c_cfg.fmt = SENSOR_I2C_FMT; //CUS_I2C_FMT_A16D16; - handle->i2c_cfg.address = SENSOR_I2C_ADDR; //0x5a; - handle->i2c_cfg.speed = SENSOR_I2C_SPEED; //320000; - - //////////////////////////////////// - // mclk // - //////////////////////////////////// - handle->mclk = Preview_MCLK_SPEED_HDR_DOL;//UseParaMclk(SENSOR_DRV_PARAM_MCLK()); - //sensor_if->MCLK(0,1,handle->mclk); - - //////////////////////////////////// - // sensor interface info // - //////////////////////////////////// - handle->isp_type = SENSOR_ISP_TYPE; //ISP_SOC; - //handle->data_fmt = SENSOR_DATAFMT; //CUS_DATAFMT_YUV; - handle->sif_bus = SENSOR_IFBUS_TYPE;//CUS_SENIF_BUS_PARL; - handle->data_prec = SENSOR_DATAPREC_DOL; //CUS_DATAPRECISION_8; - handle->data_mode = SENSOR_DATAMODE; - handle->bayer_id = SENSOR_BAYERID_HDR_DOL; //CUS_BAYER_GB; - handle->RGBIR_id = SENSOR_RGBIRID; - handle->orient = SENSOR_ORIT; //CUS_ORIT_M1F1; - //handle->YC_ODER = SENSOR_YCORDER; //CUS_SEN_YCODR_CY; - handle->interface_attr.attr_mipi.mipi_lane_num = SENSOR_MIPI_LANE_NUM_DOL; - handle->interface_attr.attr_mipi.mipi_data_format = CUS_SEN_INPUT_FORMAT_RGB; // RGB pattern. - handle->interface_attr.attr_mipi.mipi_yuv_order = 0; //don't care in RGB pattern. - handle->interface_attr.attr_mipi.mipi_hsync_mode = SENSOR_MIPI_HSYNC_MODE_HDR_DOL; - handle->interface_attr.attr_mipi.mipi_hdr_mode = CUS_HDR_MODE_SONY_DOL; - handle->interface_attr.attr_mipi.mipi_hdr_virtual_channel_num = 0; //Long frame - - //////////////////////////////////// - // resolution capability // - //////////////////////////////////// - handle->video_res_supported.ulcur_res = 0; //default resolution index is 0. - for (res = 0; res < HDR_RES_END; res++) { - handle->video_res_supported.num_res = res+1; - handle->video_res_supported.res[res].width = imx335_mipi_hdr[res].senif.preview_w; - handle->video_res_supported.res[res].height = imx335_mipi_hdr[res].senif.preview_h; - handle->video_res_supported.res[res].max_fps = imx335_mipi_hdr[res].senout.max_fps; - handle->video_res_supported.res[res].min_fps = imx335_mipi_hdr[res].senout.min_fps; - handle->video_res_supported.res[res].crop_start_x = imx335_mipi_hdr[res].senif.crop_start_X; - handle->video_res_supported.res[res].crop_start_y = imx335_mipi_hdr[res].senif.crop_start_y; - handle->video_res_supported.res[res].nOutputWidth = imx335_mipi_hdr[res].senout.width; - handle->video_res_supported.res[res].nOutputHeight = imx335_mipi_hdr[res].senout.height; - sprintf(handle->video_res_supported.res[res].strResDesc, imx335_mipi_hdr[res].senstr.strResDesc); - } - - //////////////////////////////////// - // Sensor polarity // - //////////////////////////////////// - handle->pwdn_POLARITY = SENSOR_PWDN_POL; //CUS_CLK_POL_NEG; - handle->reset_POLARITY = SENSOR_RST_POL; //CUS_CLK_POL_NEG; - //handle->VSYNC_POLARITY = SENSOR_VSYNC_POL; //CUS_CLK_POL_POS; - //handle->HSYNC_POLARITY = SENSOR_HSYNC_POL; //CUS_CLK_POL_POS; - handle->PCLK_POLARITY = SENSOR_PCLK_POL; //CUS_CLK_POL_POS); // use '!' to clear board latch error - - //////////////////////////////////////// - // Sensor Status Control and Get Info // - //////////////////////////////////////// - handle->pCus_sensor_release = cus_camsensor_release_handle; - handle->pCus_sensor_init = pCus_init_HDR_DOL_LEF; - //handle->pCus_sensor_powerupseq = pCus_powerupseq; - handle->pCus_sensor_poweron = pCus_poweron_HDR_DOL_LEF; - handle->pCus_sensor_poweroff = pCus_poweroff_HDR_DOL_LEF; - handle->pCus_sensor_GetSensorID = pCus_GetSensorID_HDR_DOL_LEF; - //handle->pCus_sensor_GetVideoResNum = NULL; - //handle->pCus_sensor_GetVideoRes = NULL; - //handle->pCus_sensor_GetCurVideoRes = NULL; - //handle->pCus_sensor_SetVideoRes = NULL; // Need to check - - handle->pCus_sensor_GetOrien = pCus_GetOrien_HDR_DOL_LEF; - handle->pCus_sensor_SetOrien = pCus_SetOrien_HDR_DOL_LEF; - handle->pCus_sensor_GetFPS = pCus_GetFPS_HDR_DOL_LEF; - handle->pCus_sensor_SetFPS = pCus_SetFPS_HDR_DOL_LEF; - - //handle->pCus_sensor_GetSensorCap = pCus_GetSensorCap_hdr_dol_lef; - handle->pCus_sensor_SetPatternMode = imx335_SetPatternMode_hdr_dol_lef; - - //////////////////////////////////// - // AE parameters // - //////////////////////////////////// - handle->ae_gain_delay = SENSOR_GAIN_DELAY_FRAME_COUNT_HDR_DOL; - handle->ae_shutter_delay = SENSOR_SHUTTER_DELAY_FRAME_COUNT_HDR_DOL; - handle->ae_gain_ctrl_num = 2; - handle->ae_shutter_ctrl_num = 2; - handle->sat_mingain = SENSOR_MIN_GAIN; - //handle->dgain_remainder = 0; - - //////////////////////////////////// - // AE Control and Get Info // - //////////////////////////////////// - handle->pCus_sensor_AEStatusNotify = pCus_AEStatusNotifyHDR_DOL_LEF; - handle->pCus_sensor_GetAEUSecs = pCus_GetAEUSecs_HDR_DOL_LEF; - handle->pCus_sensor_SetAEUSecs = pCus_SetAEUSecsHDR_DOL_LEF; - handle->pCus_sensor_GetAEGain = pCus_GetAEGain_HDR_DOL_LEF; - handle->pCus_sensor_SetAEGain = pCus_SetAEGainHDR_DOL_LEF; - handle->pCus_sensor_GetAEMinMaxGain = pCus_GetAEMinMaxGain_HDR_DOL_LEF; - handle->pCus_sensor_GetAEMinMaxUSecs= pCus_GetAEMinMaxUSecs_HDR_DOL_LEF; - //handle->pCus_sensor_GetDGainRemainder = pCus_GetDGainRemainder; - - //sensor calibration - handle->pCus_sensor_SetAEGain_cal = pCus_SetAEGain_cal_hdr_dol_lef; - handle->pCus_sensor_setCaliData_gain_linearity = pCus_setCaliData_gain_linearity_hdr_dol_lef; - handle->pCus_sensor_GetShutterInfo = IMX335_GetShutterInfo_hdr_dol_lef; - - params->expo.vts = vts_30fps_HDR_DOL; - params->expo.expo_lines = 673; - params->expo.fps = 25; - params->dirty = false; - - return SUCCESS; -} - -SENSOR_DRV_ENTRY_IMPL_END_EX(IMX335_HDR, - cus_camsensor_init_handle_linear, - cus_camsensor_init_handle_hdr_dol_sef1, - cus_camsensor_init_handle_hdr_dol_lef, - imx335_params - ); diff --git a/general/package/sigmastar-osdrv-sensor/src/infinity6b0/sensor/sensor_sc2239_mipi.c b/general/package/sigmastar-osdrv-sensor/src/infinity6b0/sensor/sensor_sc2239_mipi.c deleted file mode 100644 index e8c52057..00000000 --- a/general/package/sigmastar-osdrv-sensor/src/infinity6b0/sensor/sensor_sc2239_mipi.c +++ /dev/null @@ -1,1086 +0,0 @@ -/* SigmaStar trade secret */ -/* Copyright (c) [2019~2020] SigmaStar Technology. - All rights reserved. - - Unless otherwise stipulated in writing, any and all information contained - herein regardless in any format shall remain the sole proprietary of - SigmaStar and be kept in strict confidence - (SigmaStar Confidential Information) by the recipient. - Any unauthorized act including without limitation unauthorized disclosure, - copying, use, reproduction, sale, distribution, modification, disassembling, - reverse engineering and compiling of the contents of SigmaStar Confidential - Information is unlawful and strictly prohibited. SigmaStar hereby reserves the - rights to any and all damages, losses, costs and expenses resulting therefrom. - */ - -#ifdef __cplusplus -extern "C" -{ -#endif - -#include -#include -#include - -#ifdef __cplusplus -} -#endif - -SENSOR_DRV_ENTRY_IMPL_BEGIN_EX(SC2239); - -#ifndef ARRAY_SIZE -#define ARRAY_SIZE CAM_OS_ARRAY_SIZE -#endif - -#define SENSOR_PAD_GROUP_SET CUS_SENSOR_PAD_GROUP_A -#define SENSOR_CHANNEL_NUM (0) -#define SENSOR_CHANNEL_MODE_LINEAR CUS_SENSOR_CHANNEL_MODE_REALTIME_NORMAL -//#define SENSOR_CHANNEL_MODE_SONY_DOL CUS_SENSOR_CHANNEL_MODE_RAW_STORE_HDR - -//============================================ -//MIPI config begin. -#define SENSOR_MIPI_LANE_NUM (1) -//#define SENSOR_MIPI_HDR_MODE (1) //0: Non-HDR mode. 1:Sony DOL mode -//MIPI config end. -//============================================ - -#define R_GAIN_REG 1 -#define G_GAIN_REG 2 -#define B_GAIN_REG 3 - -//#undef SENSOR_DBG -#define SENSOR_DBG 0 - -#define SENSOR_ISP_TYPE ISP_EXT //ISP_EXT, ISP_SOC -#define SENSOR_IFBUS_TYPE CUS_SENIF_BUS_MIPI //CUS_SENIF_BUS_PARL, CUS_SENIF_BUS_MIPI -#define SENSOR_MIPI_HSYNC_MODE PACKET_HEADER_EDGE1 -#define SENSOR_DATAPREC CUS_DATAPRECISION_10 //CUS_DATAPRECISION_8, CUS_DATAPRECISION_10 -#define SENSOR_DATAMODE CUS_SEN_10TO12_9000 -#define SENSOR_BAYERID CUS_BAYER_BG //CUS_BAYER_GB, CUS_BAYER_GR, CUS_BAYER_BG, CUS_BAYER_RG -#define SENSOR_RGBIRID CUS_RGBIR_NONE -#define SENSOR_ORIT CUS_ORIT_M0F0 //CUS_ORIT_M0F0, CUS_ORIT_M1F0, CUS_ORIT_M0F1, CUS_ORIT_M1F1, -#define SENSOR_MAXGAIN (155*31)/10 // (15.5*31) max sensor gain, a-gain*conversion-gain*d-gain -//#define SENSOR_YCORDER CUS_SEN_YCODR_YC //CUS_SEN_YCODR_YC, CUS_SEN_YCODR_CY - -#define Preview_MCLK_SPEED CUS_CMU_CLK_27MHZ //CFG //CUS_CMU_CLK_12M, CUS_CMU_CLK_16M, CUS_CMU_CLK_24M, CUS_CMU_CLK_27M -#define Preview_line_period 29630 //1/30/1500 -#define vts_30fps 1125 //for 30 fps - -#define Preview_WIDTH 1920 //resolution Width when preview -#define Preview_HEIGHT 1080 //resolution Height when preview -#define Preview_MAX_FPS 30 //25 //fastest preview FPS -#define Preview_MIN_FPS 3 //slowest preview FPS -#define Preview_CROP_START_X 0 //CROP_START_X -#define Preview_CROP_START_Y 0 //CROP_START_Y - -#define SENSOR_I2C_ADDR 0x60 //I2C slave address -#define SENSOR_I2C_SPEED 240000 //I2C speed,60000~320000 -#define SENSOR_I2C_LEGACY I2C_NORMAL_MODE //usally set CUS_I2C_NORMAL_MODE, if use old OVT I2C protocol=> set CUS_I2C_LEGACY_MODE -#define SENSOR_I2C_FMT I2C_FMT_A16D8 //CUS_I2C_FMT_A8D8, CUS_I2C_FMT_A8D16, CUS_I2C_FMT_A16D8, CUS_I2C_FMT_A16D16 - -#define SENSOR_PWDN_POL CUS_CLK_POL_NEG // if PWDN pin High can makes sensor in power down, set CUS_CLK_POL_POS -#define SENSOR_RST_POL CUS_CLK_POL_NEG // if RESET pin High can makes sensor in reset state, set CUS_CLK_POL_NEG - -// VSYNC/HSYNC POL can be found in data sheet timing diagram, -// Notice: the initial setting may contain VSYNC/HSYNC POL inverse settings so that condition is different. -#define SENSOR_VSYNC_POL CUS_CLK_POL_NEG // if VSYNC pin High and data bus have data, set CUS_CLK_POL_POS -#define SENSOR_HSYNC_POL CUS_CLK_POL_POS // if HSYNC pin High and data bus have data, set CUS_CLK_POL_POS -#define SENSOR_PCLK_POL CUS_CLK_POL_POS // depend on sensor setting, sometimes need to try CUS_CLK_POL_POS or CUS_CLK_POL_NEG - - -#if defined (SENSOR_MODULE_VERSION) -#define TO_STR_NATIVE(e) #e -#define TO_STR_PROXY(m, e) m(e) -#define MACRO_TO_STRING(e) TO_STR_PROXY(TO_STR_NATIVE, e) -static char *sensor_module_version = MACRO_TO_STRING(SENSOR_MODULE_VERSION); -module_param(sensor_module_version, charp, S_IRUGO); -#endif -static int cus_camsensor_release_handle(ms_cus_sensor *handle); -static int pCus_SetAEGain(ms_cus_sensor *handle, u32 gain); -static int pCus_SetAEUSecs(ms_cus_sensor *handle, u32 us); -static int pCus_SetFPS(ms_cus_sensor *handle, u32 fps); -static int pCus_SetOrien(ms_cus_sensor *handle, CUS_CAMSENSOR_ORIT orit); -//#define ABS(a) ((a)>(0) ? (a) : (-(a))) -static int g_sensor_ae_min_gain = 1024; -#define ENABLE_NR 1 - -CUS_MCLK_FREQ UseParaMclk(void); - -typedef struct { - struct { - u16 pre_div0; - u16 div124; - u16 div_cnt7b; - u16 sdiv0; - u16 mipi_div0; - u16 r_divp; - u16 sdiv1; - u16 r_seld5; - u16 r_sclk_dac; - u16 sys_sel; - u16 pdac_sel; - u16 adac_sel; - u16 pre_div_sp; - u16 r_div_sp; - u16 div_cnt5b; - u16 sdiv_sp; - u16 div12_sp; - u16 mipi_lane_sel; - u16 div_dac; - } clk_tree; - struct { - float sclk; - u32 hts; - u32 vts; - u32 ho; - u32 xinc; - u32 line_freq; - u32 us_per_line; - u32 final_us; - u32 final_gain; - u32 back_pv_us; - u32 fps; - u32 preview_fps; - u32 line; - } expo; - struct { - bool bVideoMode; - u16 res_idx; - // bool binning; - // bool scaling; - CUS_CAMSENSOR_ORIT orit; - } res; - - int sen_init; - int still_min_fps; - int video_min_fps; - bool reg_mf; - bool reg_dirty; - bool nr_dirty; - CUS_CAMSENSOR_ORIT cur_orien; -} sc2239_params; -// set sensor ID address and data, - -typedef struct { - u64 gain; - u8 fine_gain_reg; -} FINE_GAIN; - -I2C_ARRAY Sensor_id_table[] = -{ - {0x3107, 0xCB}, - {0x3108, 0x10}, -}; - -I2C_ARRAY Sensor_init_table[] = -{ - //ipc_0x21_SC2239_MIPI_27Minput_1lane_10bit_742.5Mbps_1920x1080_30fps_non_continue - {0x0103,0x01}, //disable reset, just for 0x60&0x64 case - {0x0100,0x00}, - {0x36e9,0x80}, - {0x36f9,0x80}, - {0x301f,0x21}, - {0x3038,0x44}, - {0x3253,0x12}, - {0x3301,0x04}, - {0x3304,0xa8}, - {0x3306,0x44}, - {0x3308,0x10}, - {0x3309,0x48}, - {0x330a,0x01}, - {0x330b,0x40}, - {0x331e,0xa1}, - {0x331f,0x41}, - {0x3333,0x10}, - {0x3364,0x17}, - {0x3390,0x08}, - {0x3391,0x18}, - {0x3392,0x38}, - {0x3393,0x08}, - {0x3394,0x0d}, - {0x3395,0x70}, - {0x33af,0x20}, - {0x360f,0x01}, - {0x3630,0x00}, - {0x3634,0x64}, - {0x3637,0x10}, - {0x363c,0x05}, - {0x3670,0x0c}, - {0x3671,0xc2}, - {0x3672,0x02}, - {0x3673,0x02}, - {0x3677,0x84}, - {0x3678,0x84}, - {0x3679,0x8e}, - {0x367a,0x18}, - {0x367b,0x38}, - {0x367e,0x08}, - {0x367f,0x38}, - {0x3690,0x74}, - {0x3691,0x64}, - {0x3692,0x64}, - {0x369c,0x08}, - {0x369d,0x18}, - {0x3904,0x08}, - {0x3908,0x82}, - {0x3933,0x82}, - {0x3934,0x1b}, - {0x3940,0x77}, - {0x3941,0x18}, - {0x3942,0x02}, - {0x3943,0x1c}, - {0x3944,0x0b}, - {0x3945,0x80}, - {0x3e01,0x8c}, - {0x3e02,0x20}, - {0x4509,0x20}, - {0x4800,0x64}, - {0x4819,0x09}, - {0x481b,0x05}, - {0x481d,0x14}, - {0x4821,0x0a}, - {0x4823,0x05}, - {0x5000,0x06}, - {0x5780,0x7f}, - {0x5781,0x04}, - {0x5782,0x03}, - {0x5783,0x02}, - {0x5784,0x01}, - {0x5785,0x18}, - {0x5786,0x10}, - {0x5787,0x08}, - {0x5788,0x02}, - {0x5789,0x20}, - {0x578a,0x7f}, - {0x36e9,0x20}, - {0x36f9,0x27}, - {0x0100,0x01}, - {0xffff,0x10}, //mdelay(10), -}; - -I2C_ARRAY mirror_reg[] = { - {0x3221, 0x00}, // mirror[2:1], flip[6:5] -}; - -typedef struct { - short reg; - char startbit; - char stopbit; -} COLLECT_REG_SET; - -static I2C_ARRAY gain_reg[] = { - {0x3e06, 0x00}, - {0x3e07, 0x80},//[7:0] - {0x3e08, 0x00|0x03}, - {0x3e09, 0x20}, //low bit, 0x20 - 0x3f, step 1/32 -}; - -I2C_ARRAY expo_reg[] = { - {0x3e00, 0x00}, //expo [20:17] - {0x3e01, 0x02}, // expo[15:8] - {0x3e02, 0x00}, // expo[7:0], [3:0] fraction of line -}; - -I2C_ARRAY vts_reg[] = { - {0x320e, 0x04}, - {0x320f, 0x65}, -}; - -#if ENABLE_NR -I2C_ARRAY nr_reg[] = { - {0x3634,0x64}, - {0x3306,0x44}, - {0x3301,0x05}, -}; -#endif -I2C_ARRAY PatternTbl[] = { - {0x4501,0xc8}, //testpattern , bit 3 to enable -}; - -CUS_INT_TASK_ORDER def_order = { - .RunLength = 9, - .Orders = { - CUS_INT_TASK_AE|CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_AWB|CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_AE|CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_AWB|CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_AE|CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_AWB|CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - }, -}; -/* -/////////// function definition /////////////////// -#if SENSOR_DBG == 1 -//#define SENSOR_DMSG(args...) LOGD(args) -//#define SENSOR_DMSG(args...) LOGE(args) -#define SENSOR_DMSG(args...) printf(args) -#elif SENSOR_DBG == 0 -#define SENSOR_DMSG(args...) -#endif -#undef SENSOR_NAME -#define SENSOR_NAME sc2239 -*/ - -#define SensorReg_Read(_reg,_data) (handle->i2c_bus->i2c_rx(handle->i2c_bus, &(handle->i2c_cfg),_reg,_data)) -#define SensorReg_Write(_reg,_data) (handle->i2c_bus->i2c_tx(handle->i2c_bus, &(handle->i2c_cfg),_reg,_data)) -#define SensorRegArrayW(_reg,_len) (handle->i2c_bus->i2c_array_tx(handle->i2c_bus, &(handle->i2c_cfg),(_reg),(_len))) -#define SensorRegArrayR(_reg,_len) (handle->i2c_bus->i2c_array_rx(handle->i2c_bus, &(handle->i2c_cfg),(_reg),(_len))) - -//int cus_camsensor_release_handle(ms_cus_sensor *handle); - -/////////////////// sensor hardware dependent ////////////// -#if 0 -static int ISP_config_io(ms_cus_sensor *handle) { - ISensorIfAPI *sensor_if = handle->sensor_if_api; - - SENSOR_DMSG("[%s]", __FUNCTION__); - - sensor_if->HsyncPol(handle, handle->HSYNC_POLARITY); - sensor_if->VsyncPol(handle, handle->VSYNC_POLARITY); - sensor_if->ClkPol(handle, handle->PCLK_POLARITY); - sensor_if->BayerFmt(handle, handle->bayer_id); - sensor_if->DataBus(handle, handle->sif_bus); - - sensor_if->DataPrecision(handle, handle->data_prec); - sensor_if->FmtConv(handle, handle->data_mode); - return SUCCESS; -} -#endif -static int pCus_poweron(ms_cus_sensor *handle, u32 idx) -{ - ISensorIfAPI *sensor_if = handle->sensor_if_api; - SENSOR_DMSG("[%s] ", __FUNCTION__); - sensor_if->PowerOff(idx, handle->pwdn_POLARITY);////pwd low - sensor_if->Reset(idx, handle->reset_POLARITY); - CamOsMsSleep(1); - //Sensor power on sequence - sensor_if->MCLK(idx, 1, handle->mclk); - - sensor_if->SetIOPad(idx, handle->sif_bus, handle->interface_attr.attr_mipi.mipi_lane_num); - //sensor_if->SetCSI_Clk(idx, CUS_CSI_CLK_216M); - //sensor_if->SetCSI_Lane(idx, handle->interface_attr.attr_mipi.mipi_lane_num, 1); - //sensor_if->SetCSI_LongPacketType(idx, 0, 0x1C00, 0); - CamOsMsSleep(2); - sensor_if->Reset(idx, !handle->reset_POLARITY); - CamOsMsSleep(1); - - SENSOR_DMSG("[%s] pwd high\n", __FUNCTION__); - sensor_if->PowerOff(idx, !handle->reset_POLARITY); - CamOsMsSleep(5); - - //sensor_if->Set3ATaskOrder(handle, def_order); - // pure power on - //ISP_config_io(handle); - // sensor_if->PowerOff(idx, !handle->pwdn_POLARITY); - // CamOsMsSleep(5); - //handle->i2c_bus->i2c_open(handle->i2c_bus,&handle->i2c_cfg); - - return SUCCESS; -} - -static int pCus_poweroff(ms_cus_sensor *handle, u32 idx) -{ - // power/reset low - ISensorIfAPI *sensor_if = handle->sensor_if_api; - sc2239_params *params = (sc2239_params *)handle->private_data; - SENSOR_DMSG("[%s] power low\n", __FUNCTION__); - sensor_if->PowerOff(idx, handle->pwdn_POLARITY); - sensor_if->Reset(idx, handle->reset_POLARITY); - //handle->i2c_bus->i2c_close(handle->i2c_bus); - CamOsMsSleep(1); - //Set_csi_if(0, 0); - sensor_if->SetCSI_Clk(idx, CUS_CSI_CLK_DISABLE); - sensor_if->MCLK(idx, 0, handle->mclk); - - params->cur_orien = CUS_ORIT_M0F0; - - return SUCCESS; -} - -/////////////////// image function ///////////////////////// -//Get and check sensor ID -//if i2c error or sensor id does not match then return FAIL -static int pCus_GetSensorID(ms_cus_sensor *handle, u32 *id) -{ - int i,n; - int table_length= ARRAY_SIZE(Sensor_id_table); - I2C_ARRAY id_from_sensor[ARRAY_SIZE(Sensor_id_table)]; - - SENSOR_DMSG("\n\n[%s]", __FUNCTION__); - for(n=0;n8) table_length=8; - for(n=0; n<4; ++n) { //retry , until I2C success - if(n>2) return FAIL; - if(SensorRegArrayR((I2C_ARRAY*)id_from_sensor,table_length) == SUCCESS) //read sensor ID from I2C - break; - else - CamOsMsSleep(1); - } - - for(i=0; i>= 8; - SENSOR_DMSG("[%s]Read sensor id, get 0x%x Success\n", __FUNCTION__, (int)*id); - - return SUCCESS; -} - -static int sc2239_SetPatternMode(ms_cus_sensor *handle,u32 mode) -{ - int i; - SENSOR_DMSG("\n\n[%s], mode=%d \n", __FUNCTION__, mode); - - switch(mode) { - case 1: - PatternTbl[0].data = 0xc8; //enable - break; - case 0: - PatternTbl[0].data = 0xc0; //disable - break; - default: - PatternTbl[0].data = 0xc0; //disable - break; - } - for(i=0; i< ARRAY_SIZE(PatternTbl); i++) { - if(SensorReg_Write(PatternTbl[i].reg,PatternTbl[i].data) != SUCCESS) - return FAIL; - } - - return SUCCESS; -} -static int pCus_SetFPS(ms_cus_sensor *handle, u32 fps); -static int pCus_SetAEGain_cal(ms_cus_sensor *handle, u32 gain); -static int pCus_AEStatusNotify(ms_cus_sensor *handle, CUS_CAMSENSOR_AE_STATUS_NOTIFY status); -static int pCus_init(ms_cus_sensor *handle) -{ - sc2239_params *params = (sc2239_params *)handle->private_data; - //SENSOR_DMSG("\n\n[%s]", __FUNCTION__); - int i,cnt; - ISensorIfAPI *sensor_if = handle->sensor_if_api; - //sensor_if->PCLK(NULL,CUS_PCLK_MIPI_TOP); - - SensorReg_Write(0x3011,0x60); - SensorReg_Write(0x3004,0x60); - - for(i=0;i< ARRAY_SIZE(Sensor_init_table);i++) - { - if(Sensor_init_table[i].reg==0x0100 && 0x01 == Sensor_init_table[i].data) - { - sensor_if->SetCSI_Clk(0, CUS_CSI_CLK_216M); - sensor_if->SetCSI_Lane(0, handle->interface_attr.attr_mipi.mipi_lane_num, 1); - sensor_if->SetCSI_LongPacketType(0, 0, 0x1C00, 0); - SENSOR_MSLEEP(50); - } - - if(Sensor_init_table[i].reg==0xffff) - { - SENSOR_MSLEEP(Sensor_init_table[i].data); - } - else - { - cnt = 0; - while(SensorReg_Write(Sensor_init_table[i].reg, Sensor_init_table[i].data) != SUCCESS) - { - cnt++; - SENSOR_DMSG("Sensor_init_table -> Retry %d...\n",cnt); - if(cnt>=10) - { - SENSOR_DMSG("[%s:%d]Sensor init fail!!\n", __FUNCTION__, __LINE__); - return FAIL; - } - SENSOR_MSLEEP(10); - } - } - } - - pCus_SetOrien(handle, params->cur_orien); - // pr_info("cur_orien %s pCus_SetOrien %x\n",__FUNCTION__, params->cur_orien); - vts_reg[0].data = (params->expo.vts >> 8) & 0x00ff; - vts_reg[1].data = (params->expo.vts >> 0) & 0x00ff; - - return SUCCESS; -} - -/* -int pCus_release(ms_cus_sensor *handle) -{ - ISensorIfAPI *sensor_if = &handle->sensor_if_api; - sensor_if->PCLK(NULL,CUS_PCLK_OFF); - return SUCCESS; -} -*/ - -static int pCus_GetVideoResNum( ms_cus_sensor *handle, u32 *ulres_num) -{ - *ulres_num = handle->video_res_supported.num_res; - return SUCCESS; -} - -static int pCus_GetVideoRes(ms_cus_sensor *handle, u32 res_idx, cus_camsensor_res **res) -{ - u32 num_res = handle->video_res_supported.num_res; - - if (res_idx >= num_res) { - return FAIL; - } - - *res = &handle->video_res_supported.res[res_idx]; - - return SUCCESS; -} - -static int pCus_GetCurVideoRes(ms_cus_sensor *handle, u32 *cur_idx, cus_camsensor_res **res) -{ - u32 num_res = handle->video_res_supported.num_res; - - *cur_idx = handle->video_res_supported.ulcur_res; - - if (*cur_idx >= num_res) { - return FAIL; - } - - *res = &handle->video_res_supported.res[*cur_idx]; - - return SUCCESS; -} - -static int pCus_SetVideoRes(ms_cus_sensor *handle, u32 res_idx) -{ - u32 num_res = handle->video_res_supported.num_res; - if (res_idx >= num_res) { - return FAIL; - } - switch (res_idx) { - case 0: //"1920x1080@30fps" - handle->video_res_supported.ulcur_res = 0; - handle->pCus_sensor_init = pCus_init; - break; - - default: - break; - } - - return SUCCESS; -} - -static int pCus_GetOrien(ms_cus_sensor *handle, CUS_CAMSENSOR_ORIT *orit) { - char sen_data; - sen_data = mirror_reg[0].data; - SENSOR_DMSG("mirror:%x\r\n", sen_data); - switch(sen_data) - { - case 0x00: - *orit = CUS_ORIT_M0F0; - break; - case 0x06: - *orit = CUS_ORIT_M1F0; - break; - case 0x60: - *orit = CUS_ORIT_M0F1; - break; - case 0x66: - *orit = CUS_ORIT_M1F1; - break; - } - - return SUCCESS; -} - -static int pCus_SetOrien(ms_cus_sensor *handle, CUS_CAMSENSOR_ORIT orit) -{ - sc2239_params *params = (sc2239_params *)handle->private_data; - SENSOR_DMSG("\n\n[%s]", __FUNCTION__); - switch(orit) - { - case CUS_ORIT_M0F0: - mirror_reg[0].data = 0x00; - params->cur_orien = CUS_ORIT_M0F0; - params->reg_mf = true; - break; - case CUS_ORIT_M1F0: - mirror_reg[0].data = 0x06; - params->cur_orien = CUS_ORIT_M1F0; - params->reg_mf = true; - break; - case CUS_ORIT_M0F1: - mirror_reg[0].data = 0x60; - params->cur_orien = CUS_ORIT_M0F1; - params->reg_mf = true; - break; - case CUS_ORIT_M1F1: - mirror_reg[0].data = 0x66; - params->cur_orien = CUS_ORIT_M1F1; - params->reg_mf = true; - break; - default : - break; - } - return SUCCESS; -} - -static int pCus_GetFPS(ms_cus_sensor *handle) -{ - sc2239_params *params = (sc2239_params *)handle->private_data; - u32 max_fps = handle->video_res_supported.res[handle->video_res_supported.ulcur_res].max_fps; - u32 tVts = (vts_reg[0].data << 8) | (vts_reg[1].data << 0); - - if (params->expo.fps >= 1000) - params->expo.preview_fps = (vts_30fps*max_fps*1000)/tVts; - else - params->expo.preview_fps = (vts_30fps*max_fps)/tVts; - - return params->expo.preview_fps; -} -static int pCus_SetFPS(ms_cus_sensor *handle, u32 fps) -{ - u32 vts=0; - sc2239_params *params = (sc2239_params *)handle->private_data; - u32 max_fps = handle->video_res_supported.res[handle->video_res_supported.ulcur_res].max_fps; - u32 min_fps = handle->video_res_supported.res[handle->video_res_supported.ulcur_res].min_fps; - if(fps>=min_fps && fps <= max_fps){ - params->expo.fps = fps; - params->expo.vts= (vts_30fps*max_fps)/fps; - }else if((fps >= (min_fps*1000)) && (fps <= (max_fps*1000))){ - params->expo.fps = fps; - params->expo.vts= (vts_30fps*(max_fps*1000))/fps; - }else{ - SENSOR_DMSG("[%s] FPS %d out of range.\n",__FUNCTION__,fps); - return FAIL; - } - - if(params->expo.line > 2*(params->expo.vts) -8){ - vts = (params->expo.line + 9)/2; - }else{ - vts = params->expo.vts; - } - - vts_reg[0].data = (vts >> 8) & 0x00ff; - vts_reg[1].data = (vts >> 0) & 0x00ff; - params->reg_dirty = true; - return SUCCESS; -} - -#if 0 -static int pCus_GetSensorCap(ms_cus_sensor *handle, CUS_CAMSENSOR_CAP *cap) { - if (cap) - memcpy(cap, &sensor_cap, sizeof(CUS_CAMSENSOR_CAP)); - else return FAIL; - return SUCCESS; -} -#endif - -static int pCus_AEStatusNotify(ms_cus_sensor *handle, CUS_CAMSENSOR_AE_STATUS_NOTIFY status) -{ - sc2239_params *params = (sc2239_params *)handle->private_data; - switch(status) - { - case CUS_FRAME_INACTIVE: - - break; - case CUS_FRAME_ACTIVE: - if(params->reg_mf) - { - SensorRegArrayW((I2C_ARRAY*)mirror_reg, sizeof(mirror_reg)/sizeof(I2C_ARRAY)); - params->reg_mf = false; - } - if(params->reg_dirty) - { - SensorRegArrayW((I2C_ARRAY*)expo_reg, sizeof(expo_reg)/sizeof(I2C_ARRAY)); - SensorRegArrayW((I2C_ARRAY*)gain_reg, sizeof(gain_reg)/sizeof(I2C_ARRAY)); - SensorRegArrayW((I2C_ARRAY*)vts_reg, sizeof(vts_reg)/sizeof(I2C_ARRAY)); - params->reg_dirty = false; - } -#if ENABLE_NR - if(params->nr_dirty) - { - SensorReg_Write(0x3812,0x00); - SensorRegArrayW((I2C_ARRAY*)nr_reg, sizeof(nr_reg)/sizeof(I2C_ARRAY)); - params->nr_dirty = false; - SensorReg_Write(0x3812,0x30); - } -#endif - break; - default : - break; - } - return SUCCESS; -} - -static int pCus_GetAEUSecs(ms_cus_sensor *handle, u32 *us) { - int rc=0; - u32 lines = 0; - lines |= (u32)(expo_reg[0].data&0x000f)<<16; - lines |= (u32)(expo_reg[1].data&0x00ff)<<8; - lines |= (u32)(expo_reg[2].data&0x00f0)<<0; - lines >>= 4; - *us = (lines*Preview_line_period)/1000/2; //return us - - SENSOR_DMSG("[%s] sensor expo lines/us %d, %dus\n", __FUNCTION__, lines, *us); - return rc; -} - -static int pCus_SetAEUSecs(ms_cus_sensor *handle, u32 us) { - int i; - u32 half_lines = 0,vts = 0; - sc2239_params *params = (sc2239_params *)handle->private_data; - I2C_ARRAY expo_reg_temp[] = { // max expo line vts-4! - {0x3e00, 0x00},//expo [20:17] - {0x3e01, 0x00}, // expo[16:8] - {0x3e02, 0x10}, // expo[7:0], [3:0] fraction of line - }; - memcpy(expo_reg_temp, expo_reg, sizeof(expo_reg)); - - half_lines = (1000*us*2)/Preview_line_period; // Preview_line_period in ns - if(half_lines<2) half_lines=2; - if (half_lines > 2 * (params->expo.vts)-8) { - vts = (half_lines+9)/2; - } - else - vts=params->expo.vts; - params->expo.line = half_lines; - SENSOR_DMSG("[%s] us %ld, half_lines %ld, vts %ld\n", __FUNCTION__, us, half_lines, params->expo.vts); - - half_lines = half_lines<<4; -// printf("===================================================================\n"); -// printf("us = %d half_lines = %x params->expo.vts = %x\n",us, half_lines, params->expo.vts); -// printf("===================================================================\n"); - expo_reg[0].data = (half_lines>>16) & 0x0f; - expo_reg[1].data = (half_lines>>8) & 0xff; - expo_reg[2].data = (half_lines>>0) & 0xf0; - vts_reg[0].data = (vts >> 8) & 0x00ff; - vts_reg[1].data = (vts >> 0) & 0x00ff; - - for (i = 0; i < sizeof(expo_reg)/sizeof(I2C_ARRAY); i++) - { - if (expo_reg[i].data != expo_reg_temp[i].data) - { - params->reg_dirty = true; - break; - } - } - return SUCCESS; -} - -// Gain: 1x = 1024 -static int pCus_GetAEGain(ms_cus_sensor *handle, u32* gain) { - int rc = 0; - - return rc; -} - -static int pCus_SetAEGain_cal(ms_cus_sensor *handle, u32 gain) { - - return SUCCESS; -} - -static int pCus_SetAEGain(ms_cus_sensor *handle, u32 gain) { - sc2239_params *params = (sc2239_params *)handle->private_data; - int i = 0; - u8 Dgain_reg = 0, Cgain_reg = 0, Fine_again_reg= 0x20,Fine_dgain_reg= 0x80; - - I2C_ARRAY gain_reg_temp[] = { - {0x3e06, 0x00}, - {0x3e07, 0x80}, - {0x3e08, (0x00|0x03)}, - {0x3e09, 0x20}, - }; - I2C_ARRAY nr_reg_temp[] ={ - {0x3634, 0x64}, - {0x3306, 0x44}, - {0x3301, 0x05}, - }; - memcpy(gain_reg_temp, gain_reg, sizeof(gain_reg)); - memcpy(nr_reg_temp, nr_reg, sizeof(nr_reg)); - - if (gain<1024){ - gain=1024; - }else if (gain>=SENSOR_MAXGAIN*1024){ - gain=SENSOR_MAXGAIN*1024; - } - - if (gain < 2 * 1024) - { - Cgain_reg = 0x03; Fine_again_reg = gain>>5; - Dgain_reg = 0; Fine_dgain_reg = (gain<<2)/Fine_again_reg; - } - else if (gain < 4 * 1024) - { - Cgain_reg = 0x07; Fine_again_reg = gain>>6; - Dgain_reg = 0; Fine_dgain_reg = (gain<<1)/Fine_again_reg; - } - else if (gain < 8 * 1024) - { - Cgain_reg = 0x0f; Fine_again_reg = gain>>7; - Dgain_reg = 0; Fine_dgain_reg = gain/Fine_again_reg; - } - else if (gain <= 16128) - { - Cgain_reg = 0x1f; Fine_again_reg = gain>>8; - Dgain_reg = 0; Fine_dgain_reg = (gain>>1)/Fine_again_reg; - } - else if (gain < 32256) - { - Cgain_reg = 0x1f; Fine_again_reg = 0x3f; - Dgain_reg = 0; Fine_dgain_reg = gain/126; - } - else if (gain < 63 * 1024) - { - Cgain_reg = 0x1f; Fine_again_reg = 0x3f; - Dgain_reg = 1; Fine_dgain_reg = gain/252; - } - else if (gain < 126 * 1024) - { - Cgain_reg = 0x1f; Fine_again_reg = 0x3f; - Dgain_reg = 3; Fine_dgain_reg = gain/504; - } - else if (gain < 252 * 1024) - { - Cgain_reg = 0x1f; Fine_again_reg = 0x3f; - Dgain_reg = 7; Fine_dgain_reg = gain/1008; - }else if (gain <= SENSOR_MAXGAIN * 1024) - { - Cgain_reg = 0x1f; Fine_again_reg = 0x3f; - Dgain_reg = 0x0f; Fine_dgain_reg = gain/2016; - } - - gain_reg[3].data = Fine_again_reg; - gain_reg[2].data = Cgain_reg; - gain_reg[1].data = Fine_dgain_reg; - gain_reg[0].data = Dgain_reg & 0x0f; - -#if ENABLE_NR - if (gain_reg_temp[2].data == 0x03 && gain_reg_temp[3].data <= 0x28) - { - nr_reg[0].data = 0x64; //0x05; - nr_reg[1].data = 0x44; - nr_reg[2].data = 0x04; - } else if (gain_reg_temp[2].data < 0x07) - { - nr_reg[0].data = 0x64; //0x05; - nr_reg[1].data = 0x68; - nr_reg[2].data = 0x05; - } else if (gain_reg_temp[2].data < 0x0f) - { - nr_reg[0].data = 0x64; //0x05; - nr_reg[1].data = 0x68; - nr_reg[2].data = 0x05; - } else if (gain_reg_temp[2].data < 0x1f) - { - nr_reg[0].data = 0x44; //0x05; - nr_reg[1].data = 0x68; - nr_reg[2].data = 0x05; - } else if (gain_reg_temp[2].data == 0x1f) - { - nr_reg[0].data = 0x24; //0x14; - nr_reg[1].data = 0x68; - nr_reg[2].data = 0x05; - } - - #if 1 - /* Each frame refresh to avoid the red flash when linear and wide dynamic switching */ - for (i = 0; i < sizeof(nr_reg)/sizeof(I2C_ARRAY); i++) - { - if (nr_reg[i].data != nr_reg_temp[i].data) - { - params->nr_dirty = true; - break; - } - } - #endif -#endif - - for (i = 0; i < sizeof(gain_reg)/sizeof(I2C_ARRAY); i++) - { - if (gain_reg[i].data != gain_reg_temp[i].data) - { - params->reg_dirty = true; - break; - } - } - return SUCCESS; -} - -static int pCus_GetAEMinMaxUSecs(ms_cus_sensor *handle, u32 *min, u32 *max) { - *min = 1; - *max = 1000000000/Preview_MIN_FPS; - return SUCCESS; -} - -static int pCus_GetAEMinMaxGain(ms_cus_sensor *handle, u32 *min, u32 *max) { - *min = 1024; - *max = SENSOR_MAXGAIN*1024; - return SUCCESS; -} - -static int sc2239_GetShutterInfo(struct __ms_cus_sensor* handle,CUS_SHUTTER_INFO *info) -{ - info->max = 1000000000/Preview_MIN_FPS; - info->min = Preview_line_period; - info->step = Preview_line_period/2; - return SUCCESS; -} - -static int pCus_setCaliData_gain_linearity(ms_cus_sensor* handle, CUS_GAIN_GAP_ARRAY* pArray, u32 num) { - - return SUCCESS; -} - -int cus_camsensor_init_handle_linear(ms_cus_sensor* drv_handle) { - ms_cus_sensor *handle = drv_handle; - sc2239_params *params; - if (!handle) { - SENSOR_DMSG("[%s] not enough memory!\n", __FUNCTION__); - return FAIL; - } - SENSOR_DMSG("[%s]", __FUNCTION__); - //private data allocation & init - if (handle->private_data == NULL) { - SENSOR_EMSG("[%s] Private data is empty!\n", __FUNCTION__); - return FAIL; - } - params = (sc2239_params *)handle->private_data; - - //////////////////////////////////// - // sensor model ID // - //////////////////////////////////// - strcpy(handle->model_id,"sc2239_MIPI"); - - //////////////////////////////////// - // sensor interface info // - //////////////////////////////////// - //SENSOR_DMSG("[%s] entering function with id %d\n", __FUNCTION__, id); - handle->isp_type = SENSOR_ISP_TYPE; //ISP_SOC; - //handle->data_fmt = SENSOR_DATAFMT; //CUS_DATAFMT_YUV; - handle->sif_bus = SENSOR_IFBUS_TYPE;//CUS_SENIF_BUS_PARL; - handle->data_prec = SENSOR_DATAPREC; //CUS_DATAPRECISION_8; - handle->data_mode = SENSOR_DATAMODE; - handle->bayer_id = SENSOR_BAYERID; //CUS_BAYER_GB; - handle->RGBIR_id = SENSOR_RGBIRID; - handle->orient = SENSOR_ORIT; //CUS_ORIT_M1F1; - //handle->YC_ODER = SENSOR_YCORDER; //CUS_SEN_YCODR_CY; - handle->interface_attr.attr_mipi.mipi_lane_num = SENSOR_MIPI_LANE_NUM; - handle->interface_attr.attr_mipi.mipi_data_format = CUS_SEN_INPUT_FORMAT_RGB; // RGB pattern. - handle->interface_attr.attr_mipi.mipi_yuv_order = 0; //don't care in RGB pattern. - handle->interface_attr.attr_mipi.mipi_hsync_mode = SENSOR_MIPI_HSYNC_MODE; - handle->interface_attr.attr_mipi.mipi_hdr_mode = CUS_HDR_MODE_NONE; - handle->interface_attr.attr_mipi.mipi_hdr_virtual_channel_num = 0; //Short frame - - //////////////////////////////////// - // resolution capability // - //////////////////////////////////// - - handle->video_res_supported.num_res = 1; - handle->video_res_supported.ulcur_res = 0; //default resolution index is 0. - handle->video_res_supported.res[0].width = Preview_WIDTH; - handle->video_res_supported.res[0].height = Preview_HEIGHT; - handle->video_res_supported.res[0].max_fps= Preview_MAX_FPS; - handle->video_res_supported.res[0].min_fps= Preview_MIN_FPS; - handle->video_res_supported.res[0].crop_start_x= Preview_CROP_START_X; - handle->video_res_supported.res[0].crop_start_y= Preview_CROP_START_Y; - handle->video_res_supported.res[0].nOutputWidth= 1920; - handle->video_res_supported.res[0].nOutputHeight= 1080; - sprintf(handle->video_res_supported.res[0].strResDesc, "1920x1080@30fps"); - - // i2c - - handle->i2c_cfg.mode = SENSOR_I2C_LEGACY; //(CUS_ISP_I2C_MODE) FALSE; - handle->i2c_cfg.fmt = SENSOR_I2C_FMT; //CUS_I2C_FMT_A16D16; - handle->i2c_cfg.address = SENSOR_I2C_ADDR; //0x5a; - handle->i2c_cfg.speed = SENSOR_I2C_SPEED; //320000; - - // mclk - handle->mclk = Preview_MCLK_SPEED; - - //polarity - ///////////////////////////////////////////////////// - handle->pwdn_POLARITY = SENSOR_PWDN_POL; //CUS_CLK_POL_NEG; - handle->reset_POLARITY = SENSOR_RST_POL; //CUS_CLK_POL_NEG; - handle->VSYNC_POLARITY = SENSOR_VSYNC_POL; //CUS_CLK_POL_POS; - handle->HSYNC_POLARITY = SENSOR_HSYNC_POL; //CUS_CLK_POL_POS; - handle->PCLK_POLARITY = SENSOR_PCLK_POL; //CUS_CLK_POL_POS); // use '!' to clear board latch error - ///////////////////////////////////////////////////// - - //////////////////////////////////////////////////// - // AE parameters - //////////////////////////////////////////////////// - handle->ae_gain_delay = 2; - handle->ae_shutter_delay = 2; - - handle->ae_gain_ctrl_num = 1; - handle->ae_shutter_ctrl_num = 1; - - ///calibration - handle->sat_mingain=g_sensor_ae_min_gain; - - - handle->pCus_sensor_release = cus_camsensor_release_handle; - handle->pCus_sensor_init = pCus_init; - - handle->pCus_sensor_poweron = pCus_poweron ; - handle->pCus_sensor_poweroff = pCus_poweroff; - - // Normal - handle->pCus_sensor_GetSensorID = pCus_GetSensorID ; - - handle->pCus_sensor_GetVideoResNum = pCus_GetVideoResNum; - handle->pCus_sensor_GetVideoRes = pCus_GetVideoRes; - handle->pCus_sensor_GetCurVideoRes = pCus_GetCurVideoRes; - handle->pCus_sensor_SetVideoRes = pCus_SetVideoRes; - - handle->pCus_sensor_GetOrien = pCus_GetOrien ; - handle->pCus_sensor_SetOrien = pCus_SetOrien ; - handle->pCus_sensor_GetFPS = pCus_GetFPS ; - handle->pCus_sensor_SetFPS = pCus_SetFPS ; - //handle->pCus_sensor_GetSensorCap = pCus_GetSensorCap; - handle->pCus_sensor_SetPatternMode = sc2239_SetPatternMode; - /////////////////////////////////////////////////////// - // AE - /////////////////////////////////////////////////////// - // unit: micro seconds - //handle->pCus_sensor_GetAETrigger_mode = pCus_GetAETrigger_mode; - //handle->pCus_sensor_SetAETrigger_mode = pCus_SetAETrigger_mode; - handle->pCus_sensor_AEStatusNotify = pCus_AEStatusNotify; - handle->pCus_sensor_GetAEUSecs = pCus_GetAEUSecs; - handle->pCus_sensor_SetAEUSecs = pCus_SetAEUSecs; - handle->pCus_sensor_GetAEGain = pCus_GetAEGain; - - handle->pCus_sensor_SetAEGain = pCus_SetAEGain; - - handle->pCus_sensor_GetAEMinMaxGain = pCus_GetAEMinMaxGain; - handle->pCus_sensor_GetAEMinMaxUSecs= pCus_GetAEMinMaxUSecs; - - //sensor calibration - handle->pCus_sensor_SetAEGain_cal = pCus_SetAEGain_cal; - handle->pCus_sensor_setCaliData_gain_linearity=pCus_setCaliData_gain_linearity; - handle->pCus_sensor_GetShutterInfo = sc2239_GetShutterInfo; - params->expo.vts=vts_30fps; - params->expo.fps = 30; - params->expo.line= 1000; - params->reg_dirty = false; - params->reg_mf = false; - params->nr_dirty = false; - return SUCCESS; -} - -static int cus_camsensor_release_handle(ms_cus_sensor *handle) -{ - return SUCCESS; -} - -SENSOR_DRV_ENTRY_IMPL_END_EX( SC2239, - cus_camsensor_init_handle_linear, - NULL, - NULL, - sc2239_params - ); \ No newline at end of file diff --git a/general/package/sigmastar-osdrv-sensor/src/infinity6b0/sensor/sensor_sc2335_mipi.c b/general/package/sigmastar-osdrv-sensor/src/infinity6b0/sensor/sensor_sc2335_mipi.c deleted file mode 100644 index 8cff6d94..00000000 --- a/general/package/sigmastar-osdrv-sensor/src/infinity6b0/sensor/sensor_sc2335_mipi.c +++ /dev/null @@ -1,1107 +0,0 @@ -/* SigmaStar trade secret */ -/* Copyright (c) [2019~2020] SigmaStar Technology. - All rights reserved. - - Unless otherwise stipulated in writing, any and all information contained - herein regardless in any format shall remain the sole proprietary of - SigmaStar and be kept in strict confidence - (SigmaStar Confidential Information) by the recipient. - Any unauthorized act including without limitation unauthorized disclosure, - copying, use, reproduction, sale, distribution, modification, disassembling, - reverse engineering and compiling of the contents of SigmaStar Confidential - Information is unlawful and strictly prohibited. SigmaStar hereby reserves the - rights to any and all damages, losses, costs and expenses resulting therefrom. - */ - -#ifdef __cplusplus -extern "C" -{ -#endif - -#include -#include -#include - -#ifdef __cplusplus -} -#endif - -SENSOR_DRV_ENTRY_IMPL_BEGIN_EX(SC2335); - -#define SENSOR_CHANNEL_NUM (0) -#define SENSOR_CHANNEL_MODE_LINEAR CUS_SENSOR_CHANNEL_MODE_REALTIME_NORMAL -//#define SENSOR_CHANNEL_MODE_SONY_DOL CUS_SENSOR_CHANNEL_MODE_RAW_STORE_HDR - -//============================================ -//MIPI config begin. -#define SENSOR_MIPI_LANE_NUM (2) -//#define SENSOR_MIPI_HDR_MODE (1) //0: Non-HDR mode. 1:Sony DOL mode -//MIPI config end. -//============================================ - -#define R_GAIN_REG 1 -#define G_GAIN_REG 2 -#define B_GAIN_REG 3 - -//#undef SENSOR_DBG -#define SENSOR_DBG 0 - -#define SENSOR_ISP_TYPE ISP_EXT //ISP_EXT, ISP_SOC -#define SENSOR_IFBUS_TYPE CUS_SENIF_BUS_MIPI //CUS_SENIF_BUS_PARL, CUS_SENIF_BUS_MIPI -#define SENSOR_MIPI_HSYNC_MODE PACKET_HEADER_EDGE1 -#define SENSOR_DATAPREC CUS_DATAPRECISION_10 //CUS_DATAPRECISION_8, CUS_DATAPRECISION_10 -#define SENSOR_DATAMODE CUS_SEN_10TO12_9000 -#define SENSOR_BAYERID CUS_BAYER_BG //CUS_BAYER_GB, CUS_BAYER_GR, CUS_BAYER_BG, CUS_BAYER_RG -#define SENSOR_RGBIRID CUS_RGBIR_NONE -#define SENSOR_ORIT CUS_ORIT_M0F0 //CUS_ORIT_M0F0, CUS_ORIT_M1F0, CUS_ORIT_M0F1, CUS_ORIT_M1F1, -#define SENSOR_MAXGAIN (15875*31)/1000 // (15.5*31) max sensor gain, a-gain*conversion-gain*d-gain -//#define SENSOR_YCORDER CUS_SEN_YCODR_YC //CUS_SEN_YCODR_YC, CUS_SEN_YCODR_CY - -#define Preview_MCLK_SPEED CUS_CMU_CLK_27MHZ //CFG //CUS_CMU_CLK_12M, CUS_CMU_CLK_16M, CUS_CMU_CLK_24M, CUS_CMU_CLK_27M -//#define Preview_line_period 30000 ////HTS/PCLK=4455 pixels/148.5MHZ=30usec @MCLK=36MHz -//#define vts_30fps 1125//1346,1616 //for 29.1fps @ MCLK=36MHz -//#define Line_per_second 32727 -//#define vts_30fps -#define Preview_line_period 29630 //1/30/1500 -#define vts_30fps 1125 //for 30 fps - -#define Preview_WIDTH 1920 //resolution Width when preview -#define Preview_HEIGHT 1080 //resolution Height when preview -#define Preview_MAX_FPS 30 //25 //fastest preview FPS -#define Preview_MIN_FPS 3 //slowest preview FPS -#define Preview_CROP_START_X 0 //CROP_START_X -#define Preview_CROP_START_Y 0 //CROP_START_Y - -#define SENSOR_I2C_ADDR 0x60 //I2C slave address -#define SENSOR_I2C_SPEED 240000 //I2C speed,60000~320000 - -#define SENSOR_I2C_LEGACY I2C_NORMAL_MODE //usally set CUS_I2C_NORMAL_MODE, if use old OVT I2C protocol=> set CUS_I2C_LEGACY_MODE -#define SENSOR_I2C_FMT I2C_FMT_A16D8 //CUS_I2C_FMT_A8D8, CUS_I2C_FMT_A8D16, CUS_I2C_FMT_A16D8, CUS_I2C_FMT_A16D16 - -#define SENSOR_PWDN_POL CUS_CLK_POL_NEG // if PWDN pin High can makes sensor in power down, set CUS_CLK_POL_POS -#define SENSOR_RST_POL CUS_CLK_POL_NEG // if RESET pin High can makes sensor in reset state, set CUS_CLK_POL_NEG - -// VSYNC/HSYNC POL can be found in data sheet timing diagram, -// Notice: the initial setting may contain VSYNC/HSYNC POL inverse settings so that condition is different. - -#define SENSOR_VSYNC_POL CUS_CLK_POL_NEG // if VSYNC pin High and data bus have data, set CUS_CLK_POL_POS -#define SENSOR_HSYNC_POL CUS_CLK_POL_POS // if HSYNC pin High and data bus have data, set CUS_CLK_POL_POS -#define SENSOR_PCLK_POL CUS_CLK_POL_POS // depend on sensor setting, sometimes need to try CUS_CLK_POL_POS or CUS_CLK_POL_NEG -#define ENABLE_NR 1 - -#if defined (SENSOR_MODULE_VERSION) -#define TO_STR_NATIVE(e) #e -#define TO_STR_PROXY(m, e) m(e) -#define MACRO_TO_STRING(e) TO_STR_PROXY(TO_STR_NATIVE, e) -static char *sensor_module_version = MACRO_TO_STRING(SENSOR_MODULE_VERSION); -module_param(sensor_module_version, charp, S_IRUGO); -#endif - -static int pCus_SetAEGain(ms_cus_sensor *handle, u32 gain); -static int pCus_SetAEUSecs(ms_cus_sensor *handle, u32 us); -static int pCus_SetFPS(ms_cus_sensor *handle, u32 fps); -static int pCus_SetOrien(ms_cus_sensor *handle, CUS_CAMSENSOR_ORIT orit); -static int g_sensor_ae_min_gain = 1024; - -CUS_MCLK_FREQ UseParaMclk(void); - -typedef struct { - struct { - float sclk; - u32 hts; - u32 vts; - u32 ho; - u32 xinc; - u32 line_freq; - u32 us_per_line; - u32 final_us; - u32 final_gain; - u32 back_pv_us; - u32 half_lines; - u32 half_line; - u32 fps; - u32 preview_fps; - u32 line; - } expo; - struct { - bool bVideoMode; - u16 res_idx; - // bool binning; - // bool scaling; - CUS_CAMSENSOR_ORIT orit; - } res; - - int sen_init; - int still_min_fps; - int video_min_fps; - bool reg_mf; - bool reg_dirty; - bool nr_dirty; - bool temperature_reg_1_dirty; -// bool temperature_reg_2_dirty; - CUS_CAMSENSOR_ORIT cur_orien; -} sc2335_params; -// set sensor ID address and data, - -typedef struct { - u64 gain; - u8 fine_gain_reg; -} FINE_GAIN; - -I2C_ARRAY Sensor_id_table[] = { - {0x3107, 0xCB}, - {0x3108, 0x14}, // 0x07 -}; - -I2C_ARRAY Sensor_init_table_2M30fps[] = { - // printf("===SC2335_mipi_lane2_bit10_1080P_30fps_20200309\n"); - {0x0103,0x01}, - {0xffff,0x50}, - {0x0100,0x00}, - {0x36e9,0x80}, - {0x36f9,0x80}, - {0x301f,0x02}, - {0x3207,0x3f}, - {0x3249,0x0f}, - {0x3253,0x08}, - {0x3271,0x00}, - {0x3273,0x03}, - {0x3301,0x06}, - {0x3302,0x09}, - {0x3304,0x28}, - {0x3306,0x30}, - {0x330b,0x94}, - {0x330c,0x08}, - {0x330d,0x18}, - {0x330e,0x14}, - {0x330f,0x05}, - {0x3310,0x06}, - {0x3314,0x96}, - {0x3316,0x00}, - {0x331e,0x21}, - {0x332b,0x08}, - {0x3333,0x10}, - {0x3338,0x80}, - {0x333a,0x04}, - {0x334c,0x04}, - {0x335f,0x04}, - {0x3364,0x17}, - {0x3366,0x62}, - {0x337c,0x05}, - {0x337d,0x09}, - {0x337e,0x00}, - {0x3390,0x08}, - {0x3391,0x18}, - {0x3392,0x38}, - {0x3393,0x09}, - {0x3394,0x20}, - {0x3395,0x20}, - {0x33a2,0x07}, - {0x33ac,0x04}, - {0x33ae,0x14}, - {0x3614,0x00}, - {0x3622,0x16}, - {0x3630,0x68}, - {0x3631,0x84}, - {0x3637,0x20}, - {0x363a,0x1f}, - {0x363c,0x0e}, - {0x3670,0x0e}, - {0x3674,0xa1}, - {0x3675,0x9c}, - {0x3676,0x9e}, - {0x3677,0x84}, - {0x3678,0x85}, - {0x3679,0x87}, - {0x367c,0x18}, - {0x367d,0x38}, - {0x367e,0x08}, - {0x367f,0x18}, - {0x3690,0x32}, - {0x3691,0x32}, - {0x3692,0x44}, - {0x369c,0x08}, - {0x369d,0x38}, - {0x3908,0x82}, - {0x391f,0x18}, - {0x3e01,0x8c}, - {0x3e02,0x00}, - {0x3f00,0x0d}, - {0x3f04,0x02}, - {0x3f05,0x0e}, - {0x3f09,0x48}, - {0x4505,0x0a}, - {0x4509,0x20}, - {0x481d,0x0a}, - {0x4827,0x03}, - {0x5787,0x10}, - {0x5788,0x06}, - {0x578a,0x10}, - {0x578b,0x06}, - {0x5790,0x10}, - {0x5791,0x10}, - {0x5792,0x00}, - {0x5793,0x10}, - {0x5794,0x10}, - {0x5795,0x00}, - {0x5799,0x00}, - {0x57c7,0x10}, - {0x57c8,0x06}, - {0x57ca,0x10}, - {0x57cb,0x06}, - {0x57d1,0x10}, - {0x57d4,0x10}, - {0x57d9,0x00}, - {0x36e9,0x20},// pll - {0x36f9,0x27}, - {0x0100,0x01}, - {0xffff,0x50}, -}; - -I2C_ARRAY mirror_reg[] = { - {0x3221, 0x00}, // mirror[2:1], flip[6:5] -}; - -typedef struct { - short reg; - char startbit; - char stopbit; -} COLLECT_REG_SET; - -static I2C_ARRAY gain_reg[] = { - {0x3e06, 0x00}, - {0x3e07, 0x80}, // 128 - {0x3e08, 0x03}, - {0x3e09, 0x40}, // 64 -}; - -I2C_ARRAY expo_reg[] = { - {0x3e00, 0x00}, //expo [20:17] - {0x3e01, 0x02}, // expo[15:8] - {0x3e02, 0x00}, // expo[7:0], [3:0] fraction of line -}; - -I2C_ARRAY vts_reg[] = { - {0x320e, 0x04}, - {0x320f, 0x65}, -}; - -#if ENABLE_NR -I2C_ARRAY nr_reg[] = { - {0x363c, 0x0e}, -}; -#endif - -I2C_ARRAY temperature_reg_1[] = { - {0x5799, 0x07}, -}; - -I2C_ARRAY PatternTbl[] = { - {0x4501,0xb4}, //testpattern , bit 3 to enable -}; - -#if 0 -CUS_INT_TASK_ORDER def_order = { - .RunLength = 9, - .Orders = { - CUS_INT_TASK_AE|CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_AWB|CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_AE|CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_AWB|CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_AE|CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_AWB|CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - }, -}; -#endif - -/////////// function definition /////////////////// -#if SENSOR_DBG == 1 -//#define SENSOR_DMSG(args...) LOGD(args) -//#define SENSOR_DMSG(args...) LOGE(args) -#define SENSOR_DMSG(args...) printf(args) -#elif SENSOR_DBG == 0 -//#define SENSOR_DMSG(args...) -#endif -#undef SENSOR_NAME -#define SENSOR_NAME ov2710 - - -#define SensorReg_Read(_reg,_data) (handle->i2c_bus->i2c_rx(handle->i2c_bus,&(handle->i2c_cfg),_reg,_data)) -#define SensorReg_Write(_reg,_data) (handle->i2c_bus->i2c_tx(handle->i2c_bus,&(handle->i2c_cfg),_reg,_data)) -#define SensorRegArrayW(_reg,_len) (handle->i2c_bus->i2c_array_tx(handle->i2c_bus, &(handle->i2c_cfg),(_reg),(_len))) -#define SensorRegArrayR(_reg,_len) (handle->i2c_bus->i2c_array_rx(handle->i2c_bus, &(handle->i2c_cfg),(_reg),(_len))) - -int cus_camsensor_release_handle(ms_cus_sensor *handle); - -/////////////////// sensor hardware dependent ////////////// -#if 0 -static int ISP_config_io(ms_cus_sensor *handle) { - ISensorIfAPI *sensor_if = handle->sensor_if_api; - - SENSOR_DMSG("[%s]", __FUNCTION__); - - sensor_if->HsyncPol(handle, handle->HSYNC_POLARITY); - sensor_if->VsyncPol(handle, handle->VSYNC_POLARITY); - sensor_if->ClkPol(handle, handle->PCLK_POLARITY); - sensor_if->BayerFmt(handle, handle->bayer_id); - sensor_if->DataBus(handle, handle->sif_bus); - - sensor_if->DataPrecision(handle, handle->data_prec); - sensor_if->FmtConv(handle, handle->data_mode); - return SUCCESS; -} -#endif -static int pCus_poweron(ms_cus_sensor *handle, u32 idx) -{ - ISensorIfAPI *sensor_if = handle->sensor_if_api; - SENSOR_DMSG("[%s] ", __FUNCTION__); - sensor_if->PowerOff(idx, handle->pwdn_POLARITY);////pwd low - sensor_if->Reset(idx, handle->reset_POLARITY); - CamOsMsSleep(1); - //Sensor power on sequence - sensor_if->MCLK(idx, 1, handle->mclk); - - sensor_if->SetIOPad(idx, handle->sif_bus, handle->interface_attr.attr_mipi.mipi_lane_num); - //sensor_if->SetCSI_Clk(idx, CUS_CSI_CLK_216M); - //sensor_if->SetCSI_Lane(idx, handle->interface_attr.attr_mipi.mipi_lane_num, 1); - //sensor_if->SetCSI_LongPacketType(idx, 0, 0x1C00, 0); - CamOsMsSleep(2); - sensor_if->Reset(idx, !handle->reset_POLARITY); - CamOsMsSleep(1); - - SENSOR_DMSG("[%s] pwd high\n", __FUNCTION__); - sensor_if->PowerOff(idx, !handle->reset_POLARITY); - CamOsMsSleep(2); - - //sensor_if->Set3ATaskOrder(handle, def_order); - // pure power on - //ISP_config_io(handle); - // sensor_if->PowerOff(idx, !handle->pwdn_POLARITY); - // CamOsMsSleep(5); - //handle->i2c_bus->i2c_open(handle->i2c_bus,&handle->i2c_cfg); - - return SUCCESS; -} - -static int pCus_poweroff(ms_cus_sensor *handle, u32 idx) -{ - // power/reset low - ISensorIfAPI *sensor_if = handle->sensor_if_api; - sc2335_params *params = (sc2335_params *)handle->private_data; - SENSOR_DMSG("[%s] power low\n", __FUNCTION__); - sensor_if->PowerOff(idx, handle->pwdn_POLARITY); - sensor_if->Reset(idx, handle->reset_POLARITY); - //handle->i2c_bus->i2c_close(handle->i2c_bus); - CamOsMsSleep(1); - //Set_csi_if(0, 0); - sensor_if->SetCSI_Clk(idx, CUS_CSI_CLK_DISABLE); - sensor_if->MCLK(idx, 0, handle->mclk); - - params->cur_orien = CUS_ORIT_M0F0; - - return SUCCESS; -} - -/////////////////// image function ///////////////////////// -//Get and check sensor ID -//if i2c error or sensor id does not match then return FAIL -static int pCus_GetSensorID(ms_cus_sensor *handle, u32 *id) -{ - int i,n; - int table_length= ARRAY_SIZE(Sensor_id_table); - I2C_ARRAY id_from_sensor[ARRAY_SIZE(Sensor_id_table)]; - - SENSOR_DMSG("\n\n[%s]", __FUNCTION__); - //printk("[%s]Read sensor id, get 0x%x Success\n", __FUNCTION__, (int)*id); - for(n=0;n8) table_length=8; - for(n=0; n<4; ++n) { //retry , until I2C success - if(n>2) return FAIL; - if(SensorRegArrayR((I2C_ARRAY*)id_from_sensor,table_length) == SUCCESS) //read sensor ID from I2C - break; - else - CamOsMsSleep(1); - } - - for(i=0; i>= 8; - SENSOR_DMSG("[%s]Read sensor id, get 0x%x Success\n", __FUNCTION__, (int)*id); - //printk("[%s]Read sensor id, get 0x%x Success\n", __FUNCTION__, (int)*id); - - - return SUCCESS; -} - -static int sc2335_SetPatternMode(ms_cus_sensor *handle,u32 mode) -{ - int i; - SENSOR_DMSG("\n\n[%s], mode=%d \n", __FUNCTION__, mode); - - switch(mode) { - case 1: - PatternTbl[0].data = 0xbc; //enable - break; - case 0: - PatternTbl[0].data = 0xb4; //disable - break; - default: - PatternTbl[0].data = 0xb4; //disable - break; - } - for(i=0; i< ARRAY_SIZE(PatternTbl); i++) { - if(SensorReg_Write(PatternTbl[i].reg,PatternTbl[i].data) != SUCCESS) - return FAIL; - } - - return SUCCESS; -} -static int pCus_SetFPS(ms_cus_sensor *handle, u32 fps); -static int pCus_SetAEGain_cal(ms_cus_sensor *handle, u32 gain); -static int pCus_AEStatusNotify(ms_cus_sensor *handle, CUS_CAMSENSOR_AE_STATUS_NOTIFY status); - -static u16 reg3040; - -static int pCus_init(ms_cus_sensor *handle) -{ - ISensorIfAPI *sensor_if = handle->sensor_if_api; - sc2335_params *params = (sc2335_params *)handle->private_data; - //SENSOR_DMSG("\n\n[%s]", __FUNCTION__); - int i,cnt; - - //logic - SensorReg_Read(0x3040, ®3040); - - //sensor_if->PCLK(NULL,CUS_PCLK_MIPI_TOP); - - for(i=0;i< ARRAY_SIZE(Sensor_init_table_2M30fps);i++) - { - if(Sensor_init_table_2M30fps[i].reg==0x0100 && 0x01 == Sensor_init_table_2M30fps[i].data) - { - //platform dependent - SensorReg_Write(0x3802, 0x00); //sync - sensor_if->SetCSI_Clk(0, CUS_CSI_CLK_216M); - sensor_if->SetCSI_Lane(0, handle->interface_attr.attr_mipi.mipi_lane_num, 1); - sensor_if->SetCSI_LongPacketType(0, 0, 0x1C00, 0); - SENSOR_MSLEEP(50); - } - - if(Sensor_init_table_2M30fps[i].reg==0xffff) - { - SENSOR_MSLEEP(Sensor_init_table_2M30fps[i].data); - } - else - { - cnt = 0; - while(SensorReg_Write(Sensor_init_table_2M30fps[i].reg, Sensor_init_table_2M30fps[i].data) != SUCCESS) - { - cnt++; - SENSOR_DMSG("Sensor_init_table -> Retry %d...\n",cnt); - if(cnt>=10) - { - SENSOR_DMSG("[%s:%d]Sensor init fail!!\n", __FUNCTION__, __LINE__); - return FAIL; - } - SENSOR_MSLEEP(10); - } - } - } - - if(reg3040 == 0x40) { - SensorReg_Write(0x363c, 0x0e); - } else { - SensorReg_Write(0x363c, 0x0f); - } - - pCus_SetOrien(handle, params->cur_orien); - // pr_info("cur_orien %s pCus_SetOrien %x\n",__FUNCTION__, params->cur_orien); - vts_reg[0].data = (params->expo.vts >> 8) & 0x00ff; - vts_reg[1].data = (params->expo.vts >> 0) & 0x00ff; - // usleep(50*1000); - //pCus_SetAEGain(handle,1024); - //pCus_SetAEUSecs(handle, 40000); - //pCus_AEStatusNotify(handle,CUS_FRAME_ACTIVE); - return SUCCESS; -} - -/* -int pCus_release(ms_cus_sensor *handle) -{ - ISensorIfAPI *sensor_if = &handle->sensor_if_api; - sensor_if->PCLK(NULL,CUS_PCLK_OFF); - return SUCCESS; -} -*/ - -static int pCus_GetVideoResNum( ms_cus_sensor *handle, u32 *ulres_num) -{ - *ulres_num = handle->video_res_supported.num_res; - return SUCCESS; -} - -static int pCus_GetVideoRes(ms_cus_sensor *handle, u32 res_idx, cus_camsensor_res **res) -{ - u32 num_res = handle->video_res_supported.num_res; - - if (res_idx >= num_res) { - return FAIL; - } - - *res = &handle->video_res_supported.res[res_idx]; - - return SUCCESS; -} - -static int pCus_GetCurVideoRes(ms_cus_sensor *handle, u32 *cur_idx, cus_camsensor_res **res) -{ - u32 num_res = handle->video_res_supported.num_res; - - *cur_idx = handle->video_res_supported.ulcur_res; - - if (*cur_idx >= num_res) { - return FAIL; - } - - *res = &handle->video_res_supported.res[*cur_idx]; - - return SUCCESS; -} - -static int pCus_SetVideoRes(ms_cus_sensor *handle, u32 res_idx) -{ - u32 num_res = handle->video_res_supported.num_res; - if (res_idx >= num_res) { - return FAIL; - } - switch (res_idx) { - case 0: //"1920x1080@30fps" - handle->video_res_supported.ulcur_res = 0; - handle->pCus_sensor_init = pCus_init; - break; - - default: - break; - } - - return SUCCESS; -} - -static int pCus_GetOrien(ms_cus_sensor *handle, CUS_CAMSENSOR_ORIT *orit) { - char sen_data; - sen_data = mirror_reg[0].data; - SENSOR_DMSG("mirror:%x\r\n", sen_data); - switch(sen_data & 0x66) - { - case 0x00: - *orit = CUS_ORIT_M0F0; - break; - case 0x06: - *orit = CUS_ORIT_M1F0; - break; - case 0x60: - *orit = CUS_ORIT_M0F1; - break; - case 0x66: - *orit = CUS_ORIT_M1F1; - break; - } - - return SUCCESS; -} - -static int pCus_SetOrien(ms_cus_sensor *handle, CUS_CAMSENSOR_ORIT orit) -{ - sc2335_params *params = (sc2335_params *)handle->private_data; - // pr_info("Connect %s table_length %d\n",__FUNCTION__, table_length); - SENSOR_DMSG("\n\n[%s]", __FUNCTION__); - switch(orit) - { - case CUS_ORIT_M0F0: - mirror_reg[0].data = 0x00; - params->cur_orien = CUS_ORIT_M0F0; - params->reg_mf = true; - break; - case CUS_ORIT_M1F0: - mirror_reg[0].data = 0x06; - params->cur_orien = CUS_ORIT_M1F0; - params->reg_mf = true; - break; - case CUS_ORIT_M0F1: - mirror_reg[0].data = 0x60; - params->cur_orien = CUS_ORIT_M0F1; - params->reg_mf = true; - break; - case CUS_ORIT_M1F1: - mirror_reg[0].data = 0x66; - params->cur_orien = CUS_ORIT_M1F1; - params->reg_mf = true; - break; - default : - break; - } - return SUCCESS; -} - -static int pCus_GetFPS(ms_cus_sensor *handle) -{ - sc2335_params *params = (sc2335_params *)handle->private_data; - u32 max_fps = handle->video_res_supported.res[handle->video_res_supported.ulcur_res].max_fps; - u32 tVts = (vts_reg[0].data << 8) | (vts_reg[1].data << 0); - - if (params->expo.fps >= 1000) - params->expo.preview_fps = (vts_30fps*max_fps*1000)/tVts; - else - params->expo.preview_fps = (vts_30fps*max_fps)/tVts; - - return params->expo.preview_fps; -} -static int pCus_SetFPS(ms_cus_sensor *handle, u32 fps) -{ - u32 vts=0; - sc2335_params *params = (sc2335_params *)handle->private_data; - u32 max_fps = handle->video_res_supported.res[handle->video_res_supported.ulcur_res].max_fps; - u32 min_fps = handle->video_res_supported.res[handle->video_res_supported.ulcur_res].min_fps; - - if(fps>=min_fps && fps <= max_fps){ - params->expo.fps = fps; - params->expo.vts= (vts_30fps*max_fps)/fps; - }else if((fps >= (min_fps*1000)) && (fps <= (max_fps*1000))){ - params->expo.fps = fps; - params->expo.vts= (vts_30fps*(max_fps*1000))/fps; - }else{ - SENSOR_DMSG("[%s] FPS %d out of range.\n",__FUNCTION__,fps); - return FAIL; - } - - if(params->expo.line > 2* (params->expo.vts) -10){ - vts = (params->expo.line + 11)/2; - }else{ - vts = params->expo.vts; - } - - vts_reg[0].data = (vts >> 8) & 0x00ff; - vts_reg[1].data = (vts >> 0) & 0x00ff; - params->reg_dirty = true; - return SUCCESS; -} - -#if 0 -static int pCus_GetSensorCap(ms_cus_sensor *handle, CUS_CAMSENSOR_CAP *cap) { - if (cap) - memcpy(cap, &sensor_cap, sizeof(CUS_CAMSENSOR_CAP)); - else return FAIL; - return SUCCESS; -} -#endif - -static int pCus_AEStatusNotify(ms_cus_sensor *handle, CUS_CAMSENSOR_AE_STATUS_NOTIFY status) -{ - sc2335_params *params = (sc2335_params *)handle->private_data; - switch(status) - { - case CUS_FRAME_INACTIVE: - break; - case CUS_FRAME_ACTIVE: - if(params->reg_mf) { - SensorRegArrayW((I2C_ARRAY*)mirror_reg, sizeof(mirror_reg)/sizeof(I2C_ARRAY)); - params->reg_mf = false; - } - if(params->reg_dirty) { - SensorRegArrayW((I2C_ARRAY*)expo_reg, sizeof(expo_reg)/sizeof(I2C_ARRAY)); - SensorRegArrayW((I2C_ARRAY*)gain_reg, sizeof(gain_reg)/sizeof(I2C_ARRAY)); - SensorRegArrayW((I2C_ARRAY*)vts_reg, sizeof(vts_reg)/sizeof(I2C_ARRAY)); - params->reg_dirty = false; - } -#if ENABLE_NR - - if(params->nr_dirty || params->temperature_reg_1_dirty) { - SensorReg_Write(0x3812,0x00); - if(params->nr_dirty) { - SensorRegArrayW((I2C_ARRAY*)nr_reg, sizeof(nr_reg)/sizeof(I2C_ARRAY)); - params->nr_dirty = false; - } - if(params->temperature_reg_1_dirty) { - SensorRegArrayW((I2C_ARRAY*)temperature_reg_1, sizeof(temperature_reg_1)/sizeof(I2C_ARRAY)); - params->temperature_reg_1_dirty = false; - } - SensorReg_Write(0x3812,0x30); - } -#endif - - break; - default : - break; - } - return SUCCESS; -} - -static int pCus_GetAEUSecs(ms_cus_sensor *handle, u32 *us) { - int rc=0; - u32 lines = 0; - lines |= (u32)(expo_reg[0].data&0x000f)<<16; - lines |= (u32)(expo_reg[1].data&0x00ff)<<8; - lines |= (u32)(expo_reg[2].data&0x00f0)<<0; - lines >>= 4; - *us = (lines*Preview_line_period)/1000/2; //return us - - SENSOR_DMSG("[%s] sensor expo lines/us %d, %dus\n", __FUNCTION__, lines, *us); - return rc; -} - -static int pCus_SetAEUSecs(ms_cus_sensor *handle, u32 us) { - int i; - u32 half_lines = 0,vts = 0; - sc2335_params *params = (sc2335_params *)handle->private_data; - I2C_ARRAY expo_reg_temp[] = { // max expo line vts-4! - {0x3e00, 0x00},//expo [20:17] - {0x3e01, 0x00}, // expo[16:8] - {0x3e02, 0x10}, // expo[7:0], [3:0] fraction of line - }; - memcpy(expo_reg_temp, expo_reg, sizeof(expo_reg)); - - half_lines = (1000*us*2)/Preview_line_period; // Preview_line_period in ns - if(half_lines<2) - half_lines=2; - if (half_lines > 2 * (params->expo.vts) - 10) { - vts = (half_lines+11)/2; - } - else - vts= params->expo.vts; - - params->expo.line = half_lines; - SENSOR_DMSG("[%s] us %ld, half_lines %ld, vts %ld\n", __FUNCTION__, us, half_lines, params->expo.vts); - - half_lines = half_lines<<4; - // printk("us = %d half_lines = %x params->expo.vts = %x\n",us, half_lines, params->expo.vts); - expo_reg[0].data = (half_lines>>16) & 0x0f; - expo_reg[1].data = (half_lines>>8) & 0xff; - expo_reg[2].data = (half_lines>>0) & 0xf0; - vts_reg[0].data = (vts >> 8) & 0x00ff; - vts_reg[1].data = (vts >> 0) & 0x00ff; - - for (i = 0; i < sizeof(expo_reg)/sizeof(I2C_ARRAY); i++) { - if (expo_reg[i].data != expo_reg_temp[i].data) { - params->reg_dirty = true; - break; - } - } - return SUCCESS; -} - -// Gain: 1x = 1024 -static int pCus_GetAEGain(ms_cus_sensor *handle, u32* gain) { - int rc = 0; - - return rc; -} - -static int pCus_SetAEGain_cal(ms_cus_sensor *handle, u32 gain) { - - return SUCCESS; -} - -static int pCus_SetAEGain(ms_cus_sensor *handle, u32 gain) { - sc2335_params *params = (sc2335_params *)handle->private_data; - u8 i=0 ,Dgain = 1, Ana_gain = 1; - u64 Fine_againx64 = 64,Fine_dgainx128 = 128; - u8 Dgain_reg = 0, Ana_gain_reg = 0, Fine_again_reg= 0x40,Fine_dgain_reg= 0x80; - - I2C_ARRAY gain_reg_temp[] = { - {0x3e06, 0x00}, - {0x3e07, 0x80}, - {0x3e08, 0x03}, - {0x3e09, 0x40}, - }; - I2C_ARRAY nr_reg_temp[] ={ - {0x363c, 0x0e}, - }; - I2C_ARRAY temperature_reg_1_temp[] ={ - {0x5799, 0x07}, - }; - - memcpy(gain_reg_temp, gain_reg, sizeof(gain_reg)); - memcpy(nr_reg_temp, nr_reg, sizeof(nr_reg)); - memcpy(temperature_reg_1_temp, temperature_reg_1, sizeof(temperature_reg_1)); - - if (gain<1024){ - gain=1024; - }else if (gain>=SENSOR_MAXGAIN*1024){ - gain=SENSOR_MAXGAIN*1024; - } - - if (gain < 2 * 1024) { - Dgain = 1; Fine_dgainx128 = 128; Ana_gain = 1; - Dgain_reg = 0x00; Fine_dgain_reg = 0x80; Ana_gain_reg = 0x03; - } else if (gain < 4 * 1024) { - Dgain = 1; Fine_dgainx128 = 128; Ana_gain = 2; - Dgain_reg = 0x00; Fine_dgain_reg = 0x80; Ana_gain_reg = 0x07; - } else if (gain < 8 * 1024) { - Dgain = 1; Fine_dgainx128 = 128; Ana_gain = 4; - Dgain_reg = 0x00; Fine_dgain_reg = 0x80; Ana_gain_reg = 0x0f; - } else if (gain <= 16256) { - Dgain = 1; Fine_dgainx128 = 128; Ana_gain = 8; - Dgain_reg = 0x00; Fine_dgain_reg = 0x80; Ana_gain_reg = 0x1f; - } else if (gain < 32512) { - Dgain = 1; Fine_againx64 = 127; Ana_gain = 8; - Dgain_reg = 0x00; Fine_again_reg = 0x7f; Ana_gain_reg = 0x1f; - } else if (gain < 65024) { - Dgain = 2; Fine_againx64 = 127; Ana_gain = 8; - Dgain_reg = 0x01; Fine_again_reg = 0x7f; Ana_gain_reg = 0x1f; - } else if (gain < 127 * 1024) { - Dgain = 4; Fine_againx64 = 127; Ana_gain = 8; - Dgain_reg = 0x03; Fine_again_reg = 0x7f; Ana_gain_reg = 0x1f; - } else if (gain < 254 * 1024) { - Dgain = 8; Fine_againx64 = 127; Ana_gain = 8; - Dgain_reg = 0x07; Fine_again_reg = 0x7f; Ana_gain_reg = 0x1f; - } else if (gain <= SENSOR_MAXGAIN * 1024) { - Dgain = 16; Fine_againx64 = 127; Ana_gain = 8; - Dgain_reg = 0x0f; Fine_again_reg = 0x7f; Ana_gain_reg = 0x1f; - } - - if (gain <= 16256) { - Fine_againx64 = abs(8 * gain/ (Dgain * Ana_gain * Fine_dgainx128)); - //Fine_dgainx128 = abs(8 * gain/ (Dgain * Ana_gain * Fine_againx64)); - Fine_again_reg = Fine_againx64; - //Fine_dgain_reg = Fine_dgainx128; - } else { - Fine_dgainx128 = abs(8 * gain/ (Dgain * Ana_gain * Fine_againx64)); - Fine_dgain_reg = Fine_dgainx128; - } - - gain_reg[3].data = Fine_again_reg; - gain_reg[2].data = Ana_gain_reg; - gain_reg[1].data = Fine_dgain_reg; - gain_reg[0].data = Dgain_reg & 0x0f; - - for (i = 0; i < sizeof(gain_reg)/sizeof(I2C_ARRAY); i++) { - if (gain_reg[i].data != gain_reg_temp[i].data) { - params->reg_dirty = true; - break; - } - } - -#if ENABLE_NR - if(reg3040 == 0x40) { - if (gain_reg_temp[2].data < 0x07) { // delay 1 frame group, group & exp & gain active at the same time - nr_reg[0].data = 0x0e; - } else { - nr_reg[0].data = 0x07; - } - } else if(reg3040 == 0x41) { - if (gain_reg_temp[2].data < 0x07) { - nr_reg[0].data = 0x0f; - } else { - nr_reg[0].data = 0x07; - } - } else { - nr_reg[0].data = 0x07; - } - - /* Each frame refresh to avoid the red flash when linear and wide dynamic switching */ - for (i = 0; i < sizeof(nr_reg)/sizeof(I2C_ARRAY); i++) { - if (nr_reg[i].data != nr_reg_temp[i].data) { - params->nr_dirty = true; - break; - } - } -#endif - - if (gain >= 16256) - temperature_reg_1[0].data = 0x07; - else if (gain <= 10240) - temperature_reg_1[0].data = 0x00; - - for (i = 0; i < sizeof(temperature_reg_1)/sizeof(I2C_ARRAY); i++) { - if (temperature_reg_1[i].data != temperature_reg_1_temp[i].data) { - params->temperature_reg_1_dirty = true; - break; - } - } - - return SUCCESS; -} - -static int pCus_GetAEMinMaxUSecs(ms_cus_sensor *handle, u32 *min, u32 *max) { - *min = 1; - *max = 1000000000/Preview_MIN_FPS; - return SUCCESS; -} - -static int pCus_GetAEMinMaxGain(ms_cus_sensor *handle, u32 *min, u32 *max) { - *min = 1024; - *max = SENSOR_MAXGAIN*1024; - return SUCCESS; -} - -static int sc2335_GetShutterInfo(struct __ms_cus_sensor* handle,CUS_SHUTTER_INFO *info) -{ - info->max = 1000000000/Preview_MIN_FPS; - info->min = Preview_line_period;// * 3; - info->step = Preview_line_period/2; - return SUCCESS; -} - -static int pCus_setCaliData_gain_linearity(ms_cus_sensor* handle, CUS_GAIN_GAP_ARRAY* pArray, u32 num) { - - return SUCCESS; -} - -int cus_camsensor_init_handle_linear(ms_cus_sensor* drv_handle) { - ms_cus_sensor *handle = drv_handle; - sc2335_params *params; - if (!handle) { - SENSOR_DMSG("[%s] not enough memory!\n", __FUNCTION__); - return FAIL; - } - SENSOR_DMSG("[%s]", __FUNCTION__); - //private data allocation & init - if (handle->private_data == NULL) { - SENSOR_EMSG("[%s] Private data is empty!\n", __FUNCTION__); - return FAIL; - } - params = (sc2335_params *)handle->private_data; - - //////////////////////////////////// - // sensor model ID // - //////////////////////////////////// - strcpy(handle->model_id,"sc2335_MIPI"); - - //////////////////////////////////// - // sensor interface info // - //////////////////////////////////// - //SENSOR_DMSG("[%s] entering function with id %d\n", __FUNCTION__, id); - handle->isp_type = SENSOR_ISP_TYPE; //ISP_SOC; - //handle->data_fmt = SENSOR_DATAFMT; //CUS_DATAFMT_YUV; - handle->sif_bus = SENSOR_IFBUS_TYPE;//CUS_SENIF_BUS_PARL; - handle->data_prec = SENSOR_DATAPREC; //CUS_DATAPRECISION_8; - handle->data_mode = SENSOR_DATAMODE; - handle->bayer_id = SENSOR_BAYERID; //CUS_BAYER_GB; - handle->RGBIR_id = SENSOR_RGBIRID; - handle->orient = SENSOR_ORIT; //CUS_ORIT_M1F1; - //handle->YC_ODER = SENSOR_YCORDER; //CUS_SEN_YCODR_CY; - handle->interface_attr.attr_mipi.mipi_lane_num = SENSOR_MIPI_LANE_NUM; - handle->interface_attr.attr_mipi.mipi_data_format = CUS_SEN_INPUT_FORMAT_RGB; // RGB pattern. - handle->interface_attr.attr_mipi.mipi_yuv_order = 0; //don't care in RGB pattern. - handle->interface_attr.attr_mipi.mipi_hsync_mode = SENSOR_MIPI_HSYNC_MODE; - handle->interface_attr.attr_mipi.mipi_hdr_mode = CUS_HDR_MODE_NONE; - handle->interface_attr.attr_mipi.mipi_hdr_virtual_channel_num = 0; //Short frame - - //////////////////////////////////// - // resolution capability // - //////////////////////////////////// - - handle->video_res_supported.num_res = 1; - handle->video_res_supported.ulcur_res = 0; //default resolution index is 0. - handle->video_res_supported.res[0].width = Preview_WIDTH; - handle->video_res_supported.res[0].height = Preview_HEIGHT; - handle->video_res_supported.res[0].max_fps= Preview_MAX_FPS; - handle->video_res_supported.res[0].min_fps= Preview_MIN_FPS; - handle->video_res_supported.res[0].crop_start_x= Preview_CROP_START_X; - handle->video_res_supported.res[0].crop_start_y= Preview_CROP_START_Y; - handle->video_res_supported.res[0].nOutputWidth= 1920; - handle->video_res_supported.res[0].nOutputHeight= 1080; - sprintf(handle->video_res_supported.res[0].strResDesc, "1920x1080@30fps"); - - - // i2c - - handle->i2c_cfg.mode = SENSOR_I2C_LEGACY; //(CUS_ISP_I2C_MODE) FALSE; - handle->i2c_cfg.fmt = SENSOR_I2C_FMT; //CUS_I2C_FMT_A16D16; - handle->i2c_cfg.address = SENSOR_I2C_ADDR; //0x5a; - handle->i2c_cfg.speed = SENSOR_I2C_SPEED; //320000; - - // mclk - handle->mclk = Preview_MCLK_SPEED; - - //polarity - ///////////////////////////////////////////////////// - handle->pwdn_POLARITY = SENSOR_PWDN_POL; //CUS_CLK_POL_NEG; - handle->reset_POLARITY = SENSOR_RST_POL; //CUS_CLK_POL_NEG; - handle->VSYNC_POLARITY = SENSOR_VSYNC_POL; //CUS_CLK_POL_POS; - handle->HSYNC_POLARITY = SENSOR_HSYNC_POL; //CUS_CLK_POL_POS; - handle->PCLK_POLARITY = SENSOR_PCLK_POL; //CUS_CLK_POL_POS); // use '!' to clear board latch error - ///////////////////////////////////////////////////// - - //////////////////////////////////////////////////// - // AE parameters - //////////////////////////////////////////////////// - handle->ae_gain_delay = 2; - handle->ae_shutter_delay = 2; - - handle->ae_gain_ctrl_num = 1; - handle->ae_shutter_ctrl_num = 1; - - ///calibration - handle->sat_mingain=g_sensor_ae_min_gain; - - - handle->pCus_sensor_release = cus_camsensor_release_handle; - handle->pCus_sensor_init = pCus_init; - - handle->pCus_sensor_poweron = pCus_poweron ; - handle->pCus_sensor_poweroff = pCus_poweroff; - - // Normal - handle->pCus_sensor_GetSensorID = pCus_GetSensorID ; - - handle->pCus_sensor_GetVideoResNum = pCus_GetVideoResNum; - handle->pCus_sensor_GetVideoRes = pCus_GetVideoRes; - handle->pCus_sensor_GetCurVideoRes = pCus_GetCurVideoRes; - handle->pCus_sensor_SetVideoRes = pCus_SetVideoRes; - - handle->pCus_sensor_GetOrien = pCus_GetOrien ; - handle->pCus_sensor_SetOrien = pCus_SetOrien ; - handle->pCus_sensor_GetFPS = pCus_GetFPS ; - handle->pCus_sensor_SetFPS = pCus_SetFPS ; - //handle->pCus_sensor_GetSensorCap = pCus_GetSensorCap; - handle->pCus_sensor_SetPatternMode = sc2335_SetPatternMode; - /////////////////////////////////////////////////////// - // AE - /////////////////////////////////////////////////////// - // unit: micro seconds - //handle->pCus_sensor_GetAETrigger_mode = pCus_GetAETrigger_mode; - //handle->pCus_sensor_SetAETrigger_mode = pCus_SetAETrigger_mode; - handle->pCus_sensor_AEStatusNotify = pCus_AEStatusNotify; - handle->pCus_sensor_GetAEUSecs = pCus_GetAEUSecs; - handle->pCus_sensor_SetAEUSecs = pCus_SetAEUSecs; - handle->pCus_sensor_GetAEGain = pCus_GetAEGain; - - handle->pCus_sensor_SetAEGain = pCus_SetAEGain; - - handle->pCus_sensor_GetAEMinMaxGain = pCus_GetAEMinMaxGain; - handle->pCus_sensor_GetAEMinMaxUSecs= pCus_GetAEMinMaxUSecs; - - //sensor calibration - handle->pCus_sensor_SetAEGain_cal = pCus_SetAEGain_cal; - handle->pCus_sensor_setCaliData_gain_linearity=pCus_setCaliData_gain_linearity; - handle->pCus_sensor_GetShutterInfo = sc2335_GetShutterInfo; - params->expo.vts=vts_30fps; - params->expo.fps = 30; - params->expo.line= 1000; - params->reg_dirty = false; - params->reg_mf = false; - params->nr_dirty = false; - return SUCCESS; -} - -int cus_camsensor_release_handle(ms_cus_sensor *handle) { - return SUCCESS; -} - -SENSOR_DRV_ENTRY_IMPL_END_EX( SC2335, - cus_camsensor_init_handle_linear, - NULL, - NULL, - sc2335_params - ); diff --git a/general/package/sigmastar-osdrv-sensor/src/infinity6b0/sensor/sensor_sc3335_mipi.c b/general/package/sigmastar-osdrv-sensor/src/infinity6b0/sensor/sensor_sc3335_mipi.c deleted file mode 100644 index 71cc8cc2..00000000 --- a/general/package/sigmastar-osdrv-sensor/src/infinity6b0/sensor/sensor_sc3335_mipi.c +++ /dev/null @@ -1,1118 +0,0 @@ -/* SigmaStar trade secret */ -/* Copyright (c) [2019~2020] SigmaStar Technology. -All rights reserved. - -Unless otherwise stipulated in writing, any and all information contained -herein regardless in any format shall remain the sole proprietary of -SigmaStar and be kept in strict confidence -(SigmaStar Confidential Information) by the recipient. -Any unauthorized act including without limitation unauthorized disclosure, -copying, use, reproduction, sale, distribution, modification, disassembling, -reverse engineering and compiling of the contents of SigmaStar Confidential -Information is unlawful and strictly prohibited. SigmaStar hereby reserves the -rights to any and all damages, losses, costs and expenses resulting therefrom. -*/ - -#ifdef __cplusplus -extern "C" -{ -#endif - -#include -#include -#include - -#ifdef __cplusplus -} -#endif - -SENSOR_DRV_ENTRY_IMPL_BEGIN_EX(SC3335); - -#ifndef ARRAY_SIZE -#define ARRAY_SIZE CAM_OS_ARRAY_SIZE -#endif - -#define SENSOR_PAD_GROUP_SET CUS_SENSOR_PAD_GROUP_A -#define SENSOR_CHANNEL_NUM (0) -#define SENSOR_CHANNEL_MODE_LINEAR CUS_SENSOR_CHANNEL_MODE_REALTIME_NORMAL - -//============================================ -//MIPI config begin. -#define SENSOR_MIPI_LANE_NUM (2) -//#define SENSOR_MIPI_HDR_MODE (1) //0: Non-HDR mode. 1:Sony DOL mode -//MIPI config end. -//============================================ - -#define R_GAIN_REG 1 -#define G_GAIN_REG 2 -#define B_GAIN_REG 3 - - -//#undef SENSOR_DBG -#define SENSOR_DBG 0 - -#define SENSOR_ISP_TYPE ISP_EXT //ISP_EXT, ISP_SOC -#define SENSOR_IFBUS_TYPE CUS_SENIF_BUS_MIPI //CUS_SENIF_BUS_PARL, CUS_SENIF_BUS_MIPI -#define SENSOR_MIPI_HSYNC_MODE PACKET_HEADER_EDGE1 -#define SENSOR_DATAPREC CUS_DATAPRECISION_10 //CUS_DATAPRECISION_8, CUS_DATAPRECISION_10 -#define SENSOR_DATAMODE CUS_SEN_10TO12_9000 -#define SENSOR_BAYERID CUS_BAYER_BG //CUS_BAYER_GB, CUS_BAYER_GR, CUS_BAYER_BG, CUS_BAYER_RG -#define SENSOR_RGBIRID CUS_RGBIR_NONE -#define SENSOR_ORIT CUS_ORIT_M0F0 //CUS_ORIT_M0F0, CUS_ORIT_M1F0, CUS_ORIT_M0F1, CUS_ORIT_M1F1, -#define SENSOR_MAXGAIN (15875*31875)/1000000 //max sensor gain, a-gain*conversion-gain*d-gain -//#define SENSOR_YCORDER CUS_SEN_YCODR_YC //CUS_SEN_YCODR_YC, CUS_SEN_YCODR_CY -#define long_packet_type_enable 0x00 //UD1~UD8 (user define) - -#define Preview_MCLK_SPEED CUS_CMU_CLK_27MHZ //CFG //CUS_CMU_CLK_12M, CUS_CMU_CLK_16M, CUS_CMU_CLK_24M, CUS_CMU_CLK_27M -//#define Preview_line_period 30000 ////HTS/PCLK=4455 pixels/148.5MHZ=30usec @MCLK=36MHz -//#define vts_30fps 1125//1346,1616 //for 29.1fps @ MCLK=36MHz -//#define Line_per_second 32727 -//#define vts_30fps -u32 Preview_line_period; -u32 vts_30fps; -#define Preview_WIDTH 2304 //resolution Width when preview -#define Preview_HEIGHT 1296 //resolution Height when preview -#define Preview_MAX_FPS 30 //25 //fastest preview FPS -#define Preview_MIN_FPS 5 //slowest preview FPS -#define Preview_CROP_START_X 0 //CROP_START_X -#define Preview_CROP_START_Y 0 //CROP_START_Y - -#define SENSOR_I2C_ADDR 0x60 //I2C slave address -#define SENSOR_I2C_SPEED 240000 //I2C speed,60000~320000 - -#define SENSOR_I2C_LEGACY I2C_NORMAL_MODE //usally set CUS_I2C_NORMAL_MODE, if use old OVT I2C protocol=> set CUS_I2C_LEGACY_MODE -#define SENSOR_I2C_FMT I2C_FMT_A16D8 //CUS_I2C_FMT_A8D8, CUS_I2C_FMT_A8D16, CUS_I2C_FMT_A16D8, CUS_I2C_FMT_A16D16 - -#define SENSOR_PWDN_POL CUS_CLK_POL_NEG // if PWDN pin High can makes sensor in power down, set CUS_CLK_POL_POS -#define SENSOR_RST_POL CUS_CLK_POL_NEG // if RESET pin High can makes sensor in reset state, set CUS_CLK_POL_NEG - -// VSYNC/HSYNC POL can be found in data sheet timing diagram, -// Notice: the initial setting may contain VSYNC/HSYNC POL inverse settings so that condition is different. - -#define SENSOR_VSYNC_POL CUS_CLK_POL_NEG // if VSYNC pin High and data bus have data, set CUS_CLK_POL_POS -#define SENSOR_HSYNC_POL CUS_CLK_POL_POS // if HSYNC pin High and data bus have data, set CUS_CLK_POL_POS -#define SENSOR_PCLK_POL CUS_CLK_POL_POS // depend on sensor setting, sometimes need to try CUS_CLK_POL_POS or CUS_CLK_POL_NEG - - -#if defined (SENSOR_MODULE_VERSION) -#define TO_STR_NATIVE(e) #e -#define TO_STR_PROXY(m, e) m(e) -#define MACRO_TO_STRING(e) TO_STR_PROXY(TO_STR_NATIVE, e) -static char *sensor_module_version = MACRO_TO_STRING(SENSOR_MODULE_VERSION); -module_param(sensor_module_version, charp, S_IRUGO); -#endif -static int cus_camsensor_release_handle(ms_cus_sensor *handle); -static int pCus_SetAEGain(ms_cus_sensor *handle, u32 gain); -static int pCus_SetAEUSecs(ms_cus_sensor *handle, u32 us); -static int pCus_SetFPS(ms_cus_sensor *handle, u32 fps); -static int pCus_SetOrien(ms_cus_sensor *handle, CUS_CAMSENSOR_ORIT orit); -//#define ABS(a) ((a)>(0) ? (a) : (-(a))) -static int g_sensor_ae_min_gain = 1024; -#define ENABLE_NR 1 - -CUS_MCLK_FREQ UseParaMclk(void); - -typedef struct { - struct { - u16 pre_div0; - u16 div124; - u16 div_cnt7b; - u16 sdiv0; - u16 mipi_div0; - u16 r_divp; - u16 sdiv1; - u16 r_seld5; - u16 r_sclk_dac; - u16 sys_sel; - u16 pdac_sel; - u16 adac_sel; - u16 pre_div_sp; - u16 r_div_sp; - u16 div_cnt5b; - u16 sdiv_sp; - u16 div12_sp; - u16 mipi_lane_sel; - u16 div_dac; - } clk_tree; - struct { - u32 sclk; - u32 hts; - u32 vts; - u32 ho; - u32 xinc; - u32 line_freq; - u32 us_per_line; - u32 final_us; - u32 final_gain; - u32 back_pv_us; - u32 fps; - u32 preview_fps; - u32 line; - } expo; - struct { - bool bVideoMode; - u16 res_idx; - CUS_CAMSENSOR_ORIT orit; - } res; - I2C_ARRAY tVts_reg[2]; - I2C_ARRAY tGain_reg[4]; - I2C_ARRAY tExpo_reg[3]; - I2C_ARRAY tMirror_reg[1]; - I2C_ARRAY tNr_reg[3]; - int sen_init; - int still_min_fps; - int video_min_fps; - bool orient_dirty; - bool reg_dirty; - bool nr_dirty; - CUS_CAMSENSOR_ORIT cur_orien; -} sc3335_params; -// set sensor ID address and data, - -typedef struct { - u64 gain; - u8 fine_gain_reg; -} FINE_GAIN; - -const I2C_ARRAY Sensor_id_table[] = -{ - {0x3107, 0xcc}, - {0x3108, 0x1a}, -}; - -const I2C_ARRAY Sensor_init_table_3M30fps[] = -{ - {0x0103,0x01}, - {0x0100,0x00}, - {0x36e9,0x80}, - {0x36f9,0x80}, - {0x301f,0x01}, - {0x3253,0x04}, - {0x3301,0x04}, - {0x3302,0x10}, - {0x3304,0x40}, - {0x3306,0x40}, - {0x3309,0x50}, - {0x330b,0xb6}, - {0x330e,0x29}, - {0x3310,0x06}, - {0x3314,0x96}, - {0x331e,0x39}, - {0x331f,0x49}, - {0x3320,0x09}, - {0x3333,0x10}, - {0x334c,0x01}, - {0x3364,0x17}, - {0x3367,0x01}, - {0x3390,0x04}, - {0x3391,0x08}, - {0x3392,0x38}, - {0x3393,0x05}, - {0x3394,0x09}, - {0x3395,0x16}, - {0x33ac,0x0c}, - {0x33ae,0x1c}, - {0x3622,0x16}, - {0x3637,0x22}, - {0x363a,0x1f}, - {0x363c,0x05}, - {0x3670,0x0e}, - {0x3674,0xb0}, - {0x3675,0x88}, - {0x3676,0x68}, - {0x3677,0x84}, - {0x3678,0x85}, - {0x3679,0x86}, - {0x367c,0x18}, - {0x367d,0x38}, - {0x367e,0x08}, - {0x367f,0x18}, - {0x3690,0x43}, - {0x3691,0x43}, - {0x3692,0x44}, - {0x369c,0x18}, - {0x369d,0x38}, - {0x36ea,0x3b}, - {0x36eb,0x0d}, - {0x36ec,0x1c}, - {0x36ed,0x24}, - {0x36fa,0x3b}, - {0x36fb,0x00}, - {0x36fc,0x10}, - {0x36fd,0x24}, - {0x3908,0x82}, - {0x391f,0x18}, - {0x3e01,0xa8}, - {0x3e02,0x20}, - {0x3f09,0x48}, - {0x4505,0x08}, - {0x4509,0x20}, - {0x5799,0x00}, - {0x59e0,0x60}, - {0x59e1,0x08}, - {0x59e2,0x3f}, - {0x59e3,0x18}, - {0x59e4,0x18}, - {0x59e5,0x3f}, - {0x59e6,0x06}, - {0x59e7,0x02}, - {0x59e8,0x38}, - {0x59e9,0x10}, - {0x59ea,0x0c}, - {0x59eb,0x10}, - {0x59ec,0x04}, - {0x59ed,0x02}, - {0x36e9,0x23}, - {0x36f9,0x23}, - {0x0100,0x01}, - {0xffff,0x0a}, -}; - -I2C_ARRAY mirror_reg[] = { - {0x3221, 0x00}, // mirror[2:1], flip[6:5] -}; - - -typedef struct { - short reg; - char startbit; - char stopbit; -} COLLECT_REG_SET; - -static I2C_ARRAY gain_reg[] = { - {0x3e06, 0x00}, - {0x3e07, 0x80}, - {0x3e08, 0x00|0x03}, - {0x3e09, 0x40}, //low bit, 0x40 - 0x7f, step 1/64 -}; - -I2C_ARRAY expo_reg[] = { - {0x3e00, 0x00}, //expo [20:17] - {0x3e01, 0x30}, // expo[16:8] - {0x3e02, 0x00}, // expo[7:0], [3:0] fraction of line -}; - -I2C_ARRAY vts_reg[] = { - {0x320e, 0x05}, - {0x320f, 0x46}, -}; - -#if ENABLE_NR -I2C_ARRAY nr_reg[] = { -{0x363c,0x05}, -{0x330e,0x29}, -{0x5799,0x07}, -}; -#endif - -I2C_ARRAY PatternTbl[] = { - {0x4501,0xc8}, //testpattern , bit 3 to enable -}; - -CUS_INT_TASK_ORDER def_order = { - .RunLength = 9, - .Orders = { - CUS_INT_TASK_AE|CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_AWB|CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_AE|CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_AWB|CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_AE|CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_AWB|CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - }, -}; -/* -/////////// function definition /////////////////// -#if SENSOR_DBG == 1 -//#define SENSOR_DMSG(args...) LOGD(args) -//#define SENSOR_DMSG(args...) LOGE(args) -#define SENSOR_DMSG(args...) printf(args) -#elif SENSOR_DBG == 0 -#define SENSOR_DMSG(args...) -#endif -#undef SENSOR_NAME -#define SENSOR_NAME sc3335 -*/ -#define SensorReg_Read(_reg,_data) (handle->i2c_bus->i2c_rx(handle->i2c_bus, &(handle->i2c_cfg),_reg,_data)) -#define SensorReg_Write(_reg,_data) (handle->i2c_bus->i2c_tx(handle->i2c_bus, &(handle->i2c_cfg),_reg,_data)) -#define SensorRegArrayW(_reg,_len) (handle->i2c_bus->i2c_array_tx(handle->i2c_bus, &(handle->i2c_cfg),(_reg),(_len))) -#define SensorRegArrayR(_reg,_len) (handle->i2c_bus->i2c_array_rx(handle->i2c_bus, &(handle->i2c_cfg),(_reg),(_len))) - -//int cus_camsensor_release_handle(ms_cus_sensor *handle); - -/////////////////// sensor hardware dependent ////////////// -#if 0 -static int ISP_config_io(ms_cus_sensor *handle) { - ISensorIfAPI *sensor_if = handle->sensor_if_api; - - SENSOR_DMSG("[%s]", __FUNCTION__); - - sensor_if->HsyncPol(handle, handle->HSYNC_POLARITY); - sensor_if->VsyncPol(handle, handle->VSYNC_POLARITY); - sensor_if->ClkPol(handle, handle->PCLK_POLARITY); - sensor_if->BayerFmt(handle, handle->bayer_id); - sensor_if->DataBus(handle, handle->sif_bus); - - sensor_if->DataPrecision(handle, handle->data_prec); - sensor_if->FmtConv(handle, handle->data_mode); - return SUCCESS; -} -#endif -static int pCus_poweron(ms_cus_sensor *handle, u32 idx) -{ - ISensorIfAPI *sensor_if = handle->sensor_if_api; - SENSOR_DMSG("[%s] ", __FUNCTION__); - sensor_if->PowerOff(idx, handle->pwdn_POLARITY);////pwd low - sensor_if->Reset(idx, handle->reset_POLARITY); - SENSOR_USLEEP(1000); - //Sensor power on sequence - sensor_if->MCLK(idx, 1, handle->mclk); - - sensor_if->SetIOPad(idx, handle->sif_bus, handle->interface_attr.attr_mipi.mipi_lane_num); - //sensor_if->SetCSI_Clk(idx, CUS_CSI_CLK_216M); - //sensor_if->SetCSI_Lane(idx, handle->interface_attr.attr_mipi.mipi_lane_num, 1); - //sensor_if->SetCSI_LongPacketType(idx, 0, 0x1C00, 0); - SENSOR_USLEEP(2000); - sensor_if->Reset(idx, !handle->reset_POLARITY); - SENSOR_USLEEP(1000); - - SENSOR_DMSG("[%s] pwd high\n", __FUNCTION__); - sensor_if->PowerOff(idx, !handle->reset_POLARITY); - SENSOR_USLEEP(2000); - - return SUCCESS; -} - -static int pCus_poweroff(ms_cus_sensor *handle, u32 idx) -{ - // power/reset low - ISensorIfAPI *sensor_if = handle->sensor_if_api; - sc3335_params *params = (sc3335_params *)handle->private_data; - SENSOR_DMSG("[%s] power low\n", __FUNCTION__); - sensor_if->PowerOff(idx, handle->pwdn_POLARITY); - sensor_if->Reset(idx, handle->reset_POLARITY); - //handle->i2c_bus->i2c_close(handle->i2c_bus); - SENSOR_USLEEP(1000); - //Set_csi_if(0, 0); - sensor_if->SetCSI_Clk(idx, CUS_CSI_CLK_DISABLE); - sensor_if->MCLK(idx, 0, handle->mclk); - - params->cur_orien = CUS_ORIT_M0F0; - - return SUCCESS; -} - -/////////////////// image function ///////////////////////// -//Get and check sensor ID -//if i2c error or sensor id does not match then return FAIL -static int pCus_GetSensorID(ms_cus_sensor *handle, u32 *id) -{ - int i,n; - int table_length= ARRAY_SIZE(Sensor_id_table); - I2C_ARRAY id_from_sensor[ARRAY_SIZE(Sensor_id_table)]; - - SENSOR_DMSG("\n\n[%s]", __FUNCTION__); - for(n=0;n8) table_length=8; - for(n=0; n<4; ++n) { //retry , until I2C success - if(n>2) return FAIL; - if(SensorRegArrayR((I2C_ARRAY*)id_from_sensor,table_length) == SUCCESS) //read sensor ID from I2C - break; - else - SENSOR_USLEEP(1000); - } - - for(i=0; i>= 8; - SENSOR_DMSG("[%s]Read sensor id, get 0x%x Success\n", __FUNCTION__, (int)*id); - - return SUCCESS; -} - -static int sc3335_SetPatternMode(ms_cus_sensor *handle,u32 mode) -{ - int i; - SENSOR_DMSG("\n\n[%s], mode=%d \n", __FUNCTION__, mode); - - switch(mode) { - case 1: - PatternTbl[0].data = 0xc8; //enable - break; - case 0: - PatternTbl[0].data = 0xc0; //disable - break; - default: - PatternTbl[0].data = 0xc0; //disable - break; - } - for(i=0; i< ARRAY_SIZE(PatternTbl); i++) { - if(SensorReg_Write(PatternTbl[i].reg,PatternTbl[i].data) != SUCCESS) - return FAIL; - } - - return SUCCESS; -} -static int pCus_SetFPS(ms_cus_sensor *handle, u32 fps); -static int pCus_SetAEGain_cal(ms_cus_sensor *handle, u32 gain); -static int pCus_AEStatusNotify(ms_cus_sensor *handle, CUS_CAMSENSOR_AE_STATUS_NOTIFY status); -static int pCus_init_linear_3M30fps(ms_cus_sensor *handle) -{ - sc3335_params *params = (sc3335_params *)handle->private_data; - //SENSOR_DMSG("\n\n[%s]", __FUNCTION__); - int i,cnt; - ISensorIfAPI *sensor_if = handle->sensor_if_api; - //sensor_if->PCLK(NULL,CUS_PCLK_MIPI_TOP); - - for(i=0;i< ARRAY_SIZE(Sensor_init_table_3M30fps);i++) - { - if(Sensor_init_table_3M30fps[i].reg==0x0100 && 0x01 == Sensor_init_table_3M30fps[i].data) - { - sensor_if->SetCSI_Clk(0, CUS_CSI_CLK_216M); - sensor_if->SetCSI_Lane(0, handle->interface_attr.attr_mipi.mipi_lane_num, 1); - sensor_if->SetCSI_LongPacketType(0, 0, 0x1C00, 0); - SENSOR_MSLEEP(50); - } - - if(Sensor_init_table_3M30fps[i].reg==0xffff) - { - SENSOR_MSLEEP(Sensor_init_table_3M30fps[i].data); - } - else - { - cnt = 0; - while(SensorReg_Write(Sensor_init_table_3M30fps[i].reg, Sensor_init_table_3M30fps[i].data) != SUCCESS) - { - cnt++; - SENSOR_DMSG("Sensor_init_table -> Retry %d...\n",cnt); - if(cnt>=10) - { - SENSOR_DMSG("[%s:%d]Sensor init fail!!\n", __FUNCTION__, __LINE__); - return FAIL; - } - SENSOR_MSLEEP(10); - } - } - } - - pCus_SetOrien(handle, params->cur_orien); - // pr_info("cur_orien %s pCus_SetOrien %x\n",__FUNCTION__, params->cur_orien); - params->tVts_reg[0].data = (params->expo.vts >> 8) & 0x00ff; - params->tVts_reg[1].data = (params->expo.vts >> 0) & 0x00ff; - return SUCCESS; -} - -/* -int pCus_release(ms_cus_sensor *handle) -{ - ISensorIfAPI *sensor_if = handle->sensor_if_api; - sensor_if->PCLK(NULL,CUS_PCLK_OFF); - return SUCCESS; -} -*/ - -static int pCus_GetVideoResNum( ms_cus_sensor *handle, u32 *ulres_num) -{ - *ulres_num = handle->video_res_supported.num_res; - return SUCCESS; -} - -static int pCus_GetVideoRes(ms_cus_sensor *handle, u32 res_idx, cus_camsensor_res **res) -{ - u32 num_res = handle->video_res_supported.num_res; - - if (res_idx >= num_res) { - return FAIL; - } - - *res = &handle->video_res_supported.res[res_idx]; - - return SUCCESS; -} - -static int pCus_GetCurVideoRes(ms_cus_sensor *handle, u32 *cur_idx, cus_camsensor_res **res) -{ - u32 num_res = handle->video_res_supported.num_res; - - *cur_idx = handle->video_res_supported.ulcur_res; - - if (*cur_idx >= num_res) { - return FAIL; - } - - *res = &handle->video_res_supported.res[*cur_idx]; - - return SUCCESS; -} - -static int pCus_SetVideoRes(ms_cus_sensor *handle, u32 res_idx) -{ - u32 num_res = handle->video_res_supported.num_res; - sc3335_params *params = (sc3335_params *)handle->private_data; - if (res_idx >= num_res) { - return FAIL; - } - switch (res_idx) { - case 0: //"2304x1296@30fps" - handle->video_res_supported.ulcur_res = 0; - handle->pCus_sensor_init = pCus_init_linear_3M30fps; - vts_30fps=1350;//1500 - params->expo.vts = vts_30fps; - params->expo.fps = 30; - Preview_line_period = 24691; - break; - - default: - break; - } - - return SUCCESS; -} - -static int pCus_GetOrien(ms_cus_sensor *handle, CUS_CAMSENSOR_ORIT *orit) { - char sen_data; - sc3335_params *params = (sc3335_params *)handle->private_data; - sen_data = params->tMirror_reg[0].data; - SENSOR_DMSG("[%s] mirror:%x\r\n", __FUNCTION__, sen_data & 0x66); - switch(sen_data & 0x66) - { - case 0x00: - *orit = CUS_ORIT_M0F0; - break; - case 0x06: - *orit = CUS_ORIT_M1F0; - break; - case 0x60: - *orit = CUS_ORIT_M0F1; - break; - case 0x66: - *orit = CUS_ORIT_M1F1; - break; - } - - return SUCCESS; -} - -static int pCus_SetOrien(ms_cus_sensor *handle, CUS_CAMSENSOR_ORIT orit) -{ - - sc3335_params *params = (sc3335_params *)handle->private_data; - - switch(orit) { - case CUS_ORIT_M0F0: - { - params->tMirror_reg[0].data = 0; - //params->tMirror_reg[1].data = 8; - params->orient_dirty = true; - } - break; - case CUS_ORIT_M1F0: - { - params->tMirror_reg[0].data = 6; - //params->tMirror_reg[1].data = 8; - params->orient_dirty = true; - } - break; - case CUS_ORIT_M0F1: - { - params->tMirror_reg[0].data = 0x60; - //params->tMirror_reg[1].data = 8; - params->orient_dirty = true; - } - break; - case CUS_ORIT_M1F1: - { - params->tMirror_reg[0].data = 0x66; - //params->tMirror_reg[1].data = 8; - params->orient_dirty = true; - } - break; -} - - SENSOR_DMSG("pCus_SetOrien:%x\r\n", orit); - - return SUCCESS; -} - -static int pCus_GetFPS(ms_cus_sensor *handle) -{ - sc3335_params *params = (sc3335_params *)handle->private_data; - u32 max_fps = handle->video_res_supported.res[handle->video_res_supported.ulcur_res].max_fps; - u32 tVts = (params->tVts_reg[0].data << 8) | (params->tVts_reg[1].data << 0); - - if (params->expo.fps >= 1000) - params->expo.preview_fps = (vts_30fps*max_fps*1000)/tVts; - else - params->expo.preview_fps = (vts_30fps*max_fps)/tVts; - - return params->expo.preview_fps; -} - - -static int pCus_SetFPS(ms_cus_sensor *handle, u32 fps) -{ - u32 vts=0; - sc3335_params *params = (sc3335_params *)handle->private_data; - u32 max_fps = handle->video_res_supported.res[handle->video_res_supported.ulcur_res].max_fps; - u32 min_fps = handle->video_res_supported.res[handle->video_res_supported.ulcur_res].min_fps; - - if(fps>=min_fps && fps <= max_fps){ - params->expo.fps = fps; - params->expo.vts= (vts_30fps*max_fps)/fps; - }else if((fps >= (min_fps*1000)) && (fps <= (max_fps*1000))){ - params->expo.fps = fps; - params->expo.vts= (vts_30fps*(max_fps*1000))/fps; - }else{ - SENSOR_DMSG("[%s] FPS %d out of range.\n",__FUNCTION__,fps); - return FAIL; - } - - if(params->expo.line > 2 * (params->expo.vts) -8){ - vts = (params->expo.line + 9)/2; - }else{ - vts = params->expo.vts; - } - params->tVts_reg[0].data = (vts >> 8) & 0x00ff; - params->tVts_reg[1].data = (vts >> 0) & 0x00ff; - params->reg_dirty = true; - return SUCCESS; -} - -#if 0 -static int pCus_GetSensorCap(ms_cus_sensor *handle, CUS_CAMSENSOR_CAP *cap) { - if (cap) - memcpy(cap, &sensor_cap, sizeof(CUS_CAMSENSOR_CAP)); - else return FAIL; - return SUCCESS; -} -#endif - -static int pCus_AEStatusNotify(ms_cus_sensor *handle, CUS_CAMSENSOR_AE_STATUS_NOTIFY status) -{ - sc3335_params *params = (sc3335_params *)handle->private_data; - switch(status) - { - case CUS_FRAME_INACTIVE: - break; - case CUS_FRAME_ACTIVE: - if(params->orient_dirty) - { - SensorRegArrayW((I2C_ARRAY*)params->tMirror_reg, sizeof(mirror_reg)/sizeof(I2C_ARRAY)); - params->orient_dirty = false; - } - if(params->reg_dirty) - { - SensorRegArrayW((I2C_ARRAY*)params->tExpo_reg, sizeof(expo_reg)/sizeof(I2C_ARRAY)); - SensorRegArrayW((I2C_ARRAY*)params->tGain_reg, sizeof(gain_reg)/sizeof(I2C_ARRAY)); - SensorRegArrayW((I2C_ARRAY*)params->tVts_reg, sizeof(vts_reg)/sizeof(I2C_ARRAY)); - params->reg_dirty = false; - } -#if ENABLE_NR - if(params->nr_dirty) - { - SensorReg_Write(0x3812,0x00); - if(params->nr_dirty) - { - SensorRegArrayW((I2C_ARRAY*)params->tNr_reg, sizeof(nr_reg)/sizeof(I2C_ARRAY)); - params->nr_dirty = false; - //printk("nr_reg update --------------------- \n"); - } - SensorReg_Write(0x3812,0x30); - - } -#endif - break; - default : - break; - } - return SUCCESS; -} - -static int pCus_GetAEUSecs(ms_cus_sensor *handle, u32 *us) { - int rc=0; - u32 lines = 0; - sc3335_params *params = (sc3335_params *)handle->private_data; - lines |= (u32)(params->tExpo_reg[0].data&0x0f)<<16; - lines |= (u32)(params->tExpo_reg[1].data&0xff)<<8; - lines |= (u32)(params->tExpo_reg[2].data&0xf0)<<0; - lines >>= 4; - *us = (lines*Preview_line_period)/1000/2; //return us - - SENSOR_DMSG("[%s] sensor expo lines/us %d, %dus\n", __FUNCTION__, lines, *us); - return rc; -} - -static int pCus_SetAEUSecs(ms_cus_sensor *handle, u32 us) { - int i; - u32 half_lines = 0,vts = 0; - sc3335_params *params = (sc3335_params *)handle->private_data; - I2C_ARRAY expo_reg_temp[] = { // max expo line vts-4! - {0x3e00, 0x00},//expo [20:17] - {0x3e01, 0x00}, // expo[16:8] - {0x3e02, 0x10}, // expo[7:0], [3:0] fraction of line - }; - memcpy(expo_reg_temp, params->tExpo_reg, sizeof(expo_reg)); - - half_lines = (1000*us*2)/Preview_line_period; // Preview_line_period in ns - if(half_lines<3) half_lines=3; - if (half_lines > 2 * (params->expo.vts)-8) { - vts = (half_lines+9)/2; - } - else - vts=params->expo.vts; - params->expo.line = half_lines; - SENSOR_DMSG("[%s] us %ld, half_lines %ld, vts %ld\n", __FUNCTION__, us, half_lines, params->expo.vts); - - half_lines = half_lines<<4; - params->tExpo_reg[0].data = (half_lines>>16) & 0x0f; - params->tExpo_reg[1].data = (half_lines>>8) & 0xff; - params->tExpo_reg[2].data = (half_lines>>0) & 0xf0; - params->tVts_reg[0].data = (vts >> 8) & 0x00ff; - params->tVts_reg[1].data = (vts >> 0) & 0x00ff; - - for (i = 0; i < sizeof(expo_reg)/sizeof(I2C_ARRAY); i++) - { - if (params->tExpo_reg[i].data != expo_reg_temp[i].data) - { - params->reg_dirty = true; - break; - } - } - return SUCCESS; -} - -// Gain: 1x = 1024 -static int pCus_GetAEGain(ms_cus_sensor *handle, u32* gain) { - int rc = 0; - - return rc; -} - -static int pCus_SetAEGain_cal(ms_cus_sensor *handle, u32 gain) { - - return SUCCESS; -} - -static int pCus_SetAEGain(ms_cus_sensor *handle, u32 gain) { - sc3335_params *params = (sc3335_params *)handle->private_data; - - u8 i=0 ,Dgain = 1, Coarse_gain = 1; - u32 Fine_againx64 = 64,Fine_dgainx128 = 128; - u8 Dgain_reg = 0, Coarse_gain_reg = 0, Fine_again_reg= 0x10,Fine_dgain_reg= 0x80; - - I2C_ARRAY gain_reg_temp[] = { - {0x3e06, 0x00}, - {0x3e07, 0x80}, - {0x3e08, (0x00|0x03)}, - {0x3e09, 0x40}, - }; - I2C_ARRAY nr_reg_temp[] = { - {0x363c,0x05}, - {0x330e,0x29}, - {0x5799,0x07}, - }; - - memcpy(gain_reg_temp, params->tGain_reg, sizeof(gain_reg)); - memcpy(nr_reg_temp, params->tNr_reg, sizeof(nr_reg)); - - if (gain < 1024) { - gain = 1024; - } else if (gain > SENSOR_MAXGAIN*1024) { - gain = SENSOR_MAXGAIN*1024; - } - - if (gain < 2 * 1024) - { - Dgain = 1; Fine_dgainx128 = 128; Coarse_gain = 1; - Dgain_reg = 0; Fine_dgain_reg = 0x80; Coarse_gain_reg = 0x3; - } - else if (gain < 4 * 1024) - { - Dgain = 1; Fine_dgainx128 = 128; Coarse_gain = 2; - Dgain_reg = 0; Fine_dgain_reg = 0x80; Coarse_gain_reg = 0x7; - } - else if (gain < 8 * 1024) - { - Dgain = 1; Fine_dgainx128 = 128; Coarse_gain = 4; - Dgain_reg = 0; Fine_dgain_reg = 0x80; Coarse_gain_reg = 0xf; - } - else if (gain <= 16256) - { - Dgain = 1; Fine_dgainx128 = 128; Coarse_gain = 8; - Dgain_reg = 0; Fine_dgain_reg = 0x80; Coarse_gain_reg = 0x1f; - } - else if (gain < 32512) - { - Dgain = 1; Fine_againx64 = 127; Coarse_gain = 8; - Dgain_reg = 0; Fine_again_reg = 0x7f; Coarse_gain_reg = 0x1f; - } - else if (gain < 65024) - { - Dgain = 2; Fine_againx64 = 127; Coarse_gain = 8; - Dgain_reg = 1; Fine_again_reg = 0x7f; Coarse_gain_reg = 0x1f; - } - else if (gain < 127 * 1024) - { - Dgain = 4; Fine_againx64 = 127; Coarse_gain = 8; - Dgain_reg = 0x03; Fine_again_reg = 0x7f; Coarse_gain_reg = 0x1f; - } - else if (gain < 254 * 1024) - { - Dgain = 8; Fine_againx64 = 127; Coarse_gain = 8; - Dgain_reg = 0x07; Fine_again_reg = 0x7f; Coarse_gain_reg = 0x1f; - } - else if (gain <= SENSOR_MAXGAIN * 1024) - { - Dgain = 16; Fine_againx64 = 127; Coarse_gain = 8; - Dgain_reg = 0x0f; Fine_again_reg = 0x7f; Coarse_gain_reg = 0x1f; - } - - if (gain <= 16256){ - Fine_againx64 = abs(8 * gain / (Dgain * Coarse_gain * Fine_dgainx128)); - Fine_again_reg = Fine_againx64; - }else{ - Fine_dgain_reg = abs(8 * gain / (Dgain * Coarse_gain * Fine_againx64)); - } - - params->tGain_reg[3].data = Fine_again_reg; // 9 - params->tGain_reg[2].data = Coarse_gain_reg; // 8 - params->tGain_reg[1].data = Fine_dgain_reg; // 7 - params->tGain_reg[0].data = Dgain_reg; // 6 - - for (i = 0; i < sizeof(gain_reg)/sizeof(I2C_ARRAY); i++) - { - if (params->tGain_reg[i].data != gain_reg_temp[i].data) - { - params->reg_dirty = true; - break; - } - } - -#if ENABLE_NR - if (gain_reg_temp[2].data < 0x07) { // gain<2 - params->tNr_reg[0].data = 0x05; - params->tNr_reg[1].data = 0x29; - } else if (gain_reg_temp[2].data < 0x0F) { // 2<=gain<4 - params->tNr_reg[0].data = 0x07; - params->tNr_reg[1].data = 0x25; - } else if (gain_reg_temp[2].data < 0x1F) { // 4<=gain<8 - params->tNr_reg[0].data = 0x07; - params->tNr_reg[1].data = 0x25; - } else if (gain_reg_temp[2].data == 0x1F) { // gain >= 8 - params->tNr_reg[0].data = 0x07; - params->tNr_reg[1].data = 0x18; - } - // highTemp dpc - if (gain >= 16256) - { - params->tNr_reg[2].data = 0x07; - } - else if (gain <= 10240) - { - params->tNr_reg[2].data = 0x00; - } - for (i = 0; i < sizeof(nr_reg)/sizeof(I2C_ARRAY); i++) - { - if (params->tNr_reg[i].data != nr_reg_temp[i].data) - { - params->nr_dirty = true; - break; - } - } -#endif - - return SUCCESS; -} - -static int pCus_GetAEMinMaxUSecs(ms_cus_sensor *handle, u32 *min, u32 *max) { - *min = 1; - *max = 1000000/Preview_MIN_FPS; - return SUCCESS; -} - -static int pCus_GetAEMinMaxGain(ms_cus_sensor *handle, u32 *min, u32 *max) { - *min = 1024; - *max = SENSOR_MAXGAIN*1024; - return SUCCESS; -} - -static int sc3335_GetShutterInfo(struct __ms_cus_sensor* handle,CUS_SHUTTER_INFO *info) -{ - info->max = 1000000000/Preview_MIN_FPS; - info->min = (Preview_line_period * 3) / 2; - info->step = Preview_line_period/2; - return SUCCESS; -} - -static int pCus_setCaliData_gain_linearity(ms_cus_sensor* handle, CUS_GAIN_GAP_ARRAY* pArray, u32 num) { - - return SUCCESS; -} - -int cus_camsensor_init_handle(ms_cus_sensor* drv_handle) { - ms_cus_sensor *handle = drv_handle; - sc3335_params *params; - if (!handle) { - SENSOR_DMSG("[%s] not enough memory!\n", __FUNCTION__); - return FAIL; - } - SENSOR_DMSG("[%s]", __FUNCTION__); - //private data allocation & init - if (handle->private_data == NULL) { - SENSOR_EMSG("[%s] Private data is empty!\n", __FUNCTION__); - return FAIL; - } - params = (sc3335_params *)handle->private_data; - memcpy(params->tVts_reg, vts_reg, sizeof(vts_reg)); - memcpy(params->tGain_reg, gain_reg, sizeof(gain_reg)); - memcpy(params->tExpo_reg, expo_reg, sizeof(expo_reg)); - memcpy(params->tMirror_reg, mirror_reg, sizeof(mirror_reg)); - memcpy(params->tNr_reg, nr_reg, sizeof(nr_reg)); - //////////////////////////////////// - // sensor model ID // - //////////////////////////////////// - strcpy(handle->model_id,"sc3335_MIPI"); - - //////////////////////////////////// - // sensor interface info // - //////////////////////////////////// - //SENSOR_DMSG("[%s] entering function with id %d\n", __FUNCTION__, id); - handle->isp_type = SENSOR_ISP_TYPE; //ISP_SOC; - //handle->data_fmt = SENSOR_DATAFMT; //CUS_DATAFMT_YUV; - handle->sif_bus = SENSOR_IFBUS_TYPE;//CUS_SENIF_BUS_PARL; - handle->data_prec = SENSOR_DATAPREC; //CUS_DATAPRECISION_8; - handle->data_mode = SENSOR_DATAMODE; - handle->bayer_id = SENSOR_BAYERID; //CUS_BAYER_GB; - handle->RGBIR_id = SENSOR_RGBIRID; - handle->orient = SENSOR_ORIT; //CUS_ORIT_M1F1; - //handle->YC_ODER = SENSOR_YCORDER; //CUS_SEN_YCODR_CY; - handle->interface_attr.attr_mipi.mipi_lane_num = SENSOR_MIPI_LANE_NUM; - handle->interface_attr.attr_mipi.mipi_data_format = CUS_SEN_INPUT_FORMAT_RGB; // RGB pattern. - handle->interface_attr.attr_mipi.mipi_yuv_order = 0; //don't care in RGB pattern. - handle->interface_attr.attr_mipi.mipi_hsync_mode = SENSOR_MIPI_HSYNC_MODE; - handle->interface_attr.attr_mipi.mipi_hdr_mode = CUS_HDR_MODE_NONE; - handle->interface_attr.attr_mipi.mipi_hdr_virtual_channel_num = 0; //Short frame - - //////////////////////////////////// - // resolution capability // - //////////////////////////////////// - - handle->video_res_supported.num_res = 1; - handle->video_res_supported.ulcur_res = 0; //default resolution index is 0. - handle->video_res_supported.res[0].width = Preview_WIDTH; - handle->video_res_supported.res[0].height = Preview_HEIGHT; - handle->video_res_supported.res[0].max_fps= Preview_MAX_FPS; - handle->video_res_supported.res[0].min_fps= Preview_MIN_FPS; - handle->video_res_supported.res[0].crop_start_x= Preview_CROP_START_X; - handle->video_res_supported.res[0].crop_start_y= Preview_CROP_START_Y; - handle->video_res_supported.res[0].nOutputWidth= 2304; - handle->video_res_supported.res[0].nOutputHeight= 1296; - sprintf(handle->video_res_supported.res[0].strResDesc, "2304x1296@30fps"); - - - // i2c - - handle->i2c_cfg.mode = SENSOR_I2C_LEGACY; //(CUS_ISP_I2C_MODE) FALSE; - handle->i2c_cfg.fmt = SENSOR_I2C_FMT; //CUS_I2C_FMT_A16D16; - handle->i2c_cfg.address = SENSOR_I2C_ADDR; //0x5a; - handle->i2c_cfg.speed = SENSOR_I2C_SPEED; //320000; - - // mclk - handle->mclk = Preview_MCLK_SPEED; - - //polarity - ///////////////////////////////////////////////////// - handle->pwdn_POLARITY = SENSOR_PWDN_POL; //CUS_CLK_POL_NEG; - handle->reset_POLARITY = SENSOR_RST_POL; //CUS_CLK_POL_NEG; - handle->VSYNC_POLARITY = SENSOR_VSYNC_POL; //CUS_CLK_POL_POS; - handle->HSYNC_POLARITY = SENSOR_HSYNC_POL; //CUS_CLK_POL_POS; - handle->PCLK_POLARITY = SENSOR_PCLK_POL; //CUS_CLK_POL_POS); // use '!' to clear board latch error - ///////////////////////////////////////////////////// - - //////////////////////////////////////////////////// - // AE parameters - //////////////////////////////////////////////////// - handle->ae_gain_delay = 2; - handle->ae_shutter_delay = 2; - - handle->ae_gain_ctrl_num = 1; - handle->ae_shutter_ctrl_num = 1; - - ///calibration - handle->sat_mingain=g_sensor_ae_min_gain; - - - handle->pCus_sensor_release = cus_camsensor_release_handle; - handle->pCus_sensor_init = pCus_init_linear_3M30fps; - - handle->pCus_sensor_poweron = pCus_poweron ; - handle->pCus_sensor_poweroff = pCus_poweroff; - - // Normal - handle->pCus_sensor_GetSensorID = pCus_GetSensorID ; - - handle->pCus_sensor_GetVideoResNum = pCus_GetVideoResNum; - handle->pCus_sensor_GetVideoRes = pCus_GetVideoRes; - handle->pCus_sensor_GetCurVideoRes = pCus_GetCurVideoRes; - handle->pCus_sensor_SetVideoRes = pCus_SetVideoRes; - - handle->pCus_sensor_GetOrien = pCus_GetOrien ; - handle->pCus_sensor_SetOrien = pCus_SetOrien ; - handle->pCus_sensor_GetFPS = pCus_GetFPS ; - handle->pCus_sensor_SetFPS = pCus_SetFPS ; - //handle->pCus_sensor_GetSensorCap = pCus_GetSensorCap; - handle->pCus_sensor_SetPatternMode = sc3335_SetPatternMode; - /////////////////////////////////////////////////////// - // AE - /////////////////////////////////////////////////////// - // unit: micro seconds - //handle->pCus_sensor_GetAETrigger_mode = pCus_GetAETrigger_mode; - //handle->pCus_sensor_SetAETrigger_mode = pCus_SetAETrigger_mode; - handle->pCus_sensor_AEStatusNotify = pCus_AEStatusNotify; - handle->pCus_sensor_GetAEUSecs = pCus_GetAEUSecs; - handle->pCus_sensor_SetAEUSecs = pCus_SetAEUSecs; - handle->pCus_sensor_GetAEGain = pCus_GetAEGain; - - handle->pCus_sensor_SetAEGain = pCus_SetAEGain; - - handle->pCus_sensor_GetAEMinMaxGain = pCus_GetAEMinMaxGain; - handle->pCus_sensor_GetAEMinMaxUSecs= pCus_GetAEMinMaxUSecs; - - //sensor calibration - handle->pCus_sensor_SetAEGain_cal = pCus_SetAEGain_cal; - handle->pCus_sensor_setCaliData_gain_linearity=pCus_setCaliData_gain_linearity; - handle->pCus_sensor_GetShutterInfo = sc3335_GetShutterInfo; - params->expo.vts=vts_30fps; - params->expo.fps = 30; - params->expo.line= 1000; - params->reg_dirty = false; - params->nr_dirty = false; - - params->orient_dirty = false; - - //handle->snr_pad_group = SENSOR_PAD_GROUP_SET; - - return SUCCESS; -} - -static int cus_camsensor_release_handle(ms_cus_sensor *handle) -{ - return SUCCESS; -} -SENSOR_DRV_ENTRY_IMPL_END_EX( SC3335, - cus_camsensor_init_handle, - NULL, - NULL, - sc3335_params - ); - diff --git a/general/package/sigmastar-osdrv-sensor/src/infinity6e/Makefile b/general/package/sigmastar-osdrv-sensor/src/infinity6e/Makefile deleted file mode 100644 index b18f8982..00000000 --- a/general/package/sigmastar-osdrv-sensor/src/infinity6e/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -EXTRA_CFLAGS += -I $(PWD)/include -I $(KSRC)/drivers/sstar/include -EXTRA_CFLAGS += -D SENSOR_MODULE_VERSION=$(OPENIPC_SOC_MODEL)-$(OPENIPC_SOC_FAMILY) -obj-m := $(patsubst $(PWD)/%.c, %.o, $(wildcard $(PWD)/sensor/*.c)) - -modules: - $(MAKE) -C $(KSRC) M=$(PWD) modules - -clean: - $(MAKE) -C $(KSRC) M=$(PWD) clean diff --git a/general/package/sigmastar-osdrv-sensor/src/infinity6e/include/drv_ms_cus_sensor.h b/general/package/sigmastar-osdrv-sensor/src/infinity6e/include/drv_ms_cus_sensor.h deleted file mode 100644 index b4929f1b..00000000 --- a/general/package/sigmastar-osdrv-sensor/src/infinity6e/include/drv_ms_cus_sensor.h +++ /dev/null @@ -1,1045 +0,0 @@ -/* Copyright (c) 2018-2019 Sigmastar Technology Corp. - All rights reserved. - - Unless otherwise stipulated in writing, any and all information contained -herein regardless in any format shall remain the sole proprietary of -Sigmastar Technology Corp. and be kept in strict confidence -(Sigmastar Confidential Information) by the recipient. -Any unauthorized act including without limitation unauthorized disclosure, -copying, use, reproduction, sale, distribution, modification, disassembling, -reverse engineering and compiling of the contents of Sigmastar Confidential -Information is unlawful and strictly prohibited. Sigmastar hereby reserves the -rights to any and all damages, losses, costs and expenses resulting therefrom. -*/ - -/*! @file drv_ms_cus_sensor.h - @brief This file contains Infinity ISP sensor driver interface. -*/ - -/** @defgroup group1 ISP Sensor Driver Interface -* @{ -*/ - -#ifndef DRV_MS_CUS_SENSOR_H_ -#define DRV_MS_CUS_SENSOR_H_ -#ifdef __cplusplus -extern "C" -{ -#endif - -#include - -#define I2C_RETRYTIME (5) - -#ifndef SUCCESS -#define FAIL (-1) -#define SUCCESS 0 -#endif - -#ifdef __cplusplus -#define EXPORT_CUS extern "C" -#else -#define EXPORT_CUS -#endif - -#define CUS_CAMSENSOR_HANDLE_MAJ_VER 0x0002 -#define CUS_CAMSENSOR_HANDLE_MIN_VER 0x0002 - -#define CUS_CAMSENSORIF_MAJ_VER 0x0001 -#define CUS_CAMSENSORIF_MIN_VER 0x0002 - -#define CUS_CAMSENSOR_I2C_MAJ_VER 0x0001 -#define CUS_CAMSENSOR_I2C_MIN_VER 0x0001 - -#define CUS_MSTART_CAMSENSOR_CAP_VERSION 0x0001 - -//#define usleep(usec) CamOsMsSleep(usec*1000); -//#define usleep(usec) udelay(usec) -//#define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0])) - -#define SENSOR_DRIVER_MODE_NOT_SUUPORT (0xFFFF) - -struct __ms_cus_sensor; /**< Sensor driver handle */ -//struct __ISensorAPI; /**< Sensor to ISP control interface */ - -/*! @brief Resolution descriptor*/ -typedef struct _cus_camsensor_res{ - u32 width; /**< Image crop width */ - u32 height; /**< Image crop height */ - u32 max_fps; /**< Max fps in this resolution */ - u32 min_fps; /**< Min fps in this resolution*/ - u32 crop_start_x; - u32 crop_start_y; - u32 nOutputWidth; /**< Sensor actual output width */ - u32 nOutputHeight; /**< Sensor actual output height */ - char strResDesc[32]; - u32 nMinFrameLengthLine; // in Line - u32 nRowTime; -} __attribute__((packed, aligned(4))) cus_camsensor_res; - -/*! @brief Resolution list*/ -typedef struct _cus_camsensor_res_list -{ - u32 num_res; /**< number of sensor resolution in list */ - u32 ulcur_res; /**< current sensor resolution*/ - cus_camsensor_res res[12]; /**< resolution list */ -} __attribute__((packed, aligned(4))) cus_camsensor_res_list; - - -/*! @brief Select sensor type */ -typedef enum { - ISP_SOC, /**< Not support */ - ISP_EXT /**< sensor without built-in ISP */ -} CUS_CAMSENSOR_ISPTYPE; - -/*! @brief Sensor bayer raw pixel order */ -typedef enum { - CUS_BAYER_RG = 0, /**< bayer data start with R channel */ - CUS_BAYER_GR, /**< bayer data start with Gr channel */ - CUS_BAYER_BG, /**< bayer data start with B channel */ - CUS_BAYER_GB /**< bayer data start with Gb channel */ -} CUS_SEN_BAYER; - -typedef enum { - CUS_RGBIR_NONE = 0, /** modify RGBIR pixel order enumeration */ - CUS_RGBIR_R0 = 1, - CUS_RGBIR_G0 = 2, - CUS_RGBIR_B0 = 3, - CUS_RGBIR_G1 = 4, - CUS_RGBIR_G2 = 5, - CUS_RGBIR_I0 = 6, - CUS_RGBIR_G3 = 7, - CUS_RGBIR_I1 = 8 -} CUS_SEN_RGBIR; - -/*! @brief Set sensor image mirror and flip.*/ -typedef enum { - CUS_ORIT_M0F0, /**< mirror, flip unchanged */ - CUS_ORIT_M1F0, /**< mirror changed, flip unchanged */ - CUS_ORIT_M0F1, /**< mirror unchanged, flip changed */ - CUS_ORIT_M1F1, /**< mirror and flip changed */ -} CUS_CAMSENSOR_ORIT; - - -/*! @brief Get input source type.*/ -typedef enum { - CUS_SNR_ANADEC_SRC_NO_READY, /**< input no ready */ - CUS_SNR_ANADEC_SRC_DISCNT, /**< input disconnect */ - CUS_SNR_ANADEC_SRC_PAL, /**< input type is PAL */ - CUS_SNR_ANADEC_SRC_NTSC, /**< input type is NTSC */ - CUS_SNR_ANADEC_SRC_HD_25P, /**< input source type is HD */ - CUS_SNR_ANADEC_SRC_HD_30P, /**< input source type is HD */ - CUS_SNR_ANADEC_SRC_HD_50P, /**< input source type is HD */ - CUS_SNR_ANADEC_SRC_HD_60P, /**< input source type is HD */ - CUS_SNR_ANADEC_SRC_FHD_25P, /**< input source type is FHD */ - CUS_SNR_ANADEC_SRC_FHD_30P, /**< input source type is FHD */ -}CUS_SNR_ANADEC_SRC_TYPE; - - -/*! @brief ISP AE event notifycation*/ -typedef enum { - CUS_FRAME_INACTIVE = 0, /**< Frame end */ - CUS_FRAME_ACTIVE = 1,/**< Frame start */ -} CUS_CAMSENSOR_AE_STATUS_NOTIFY; - -/*! @brief Sensor bayer raw (8/10 bits) to 12bits mode control */ -typedef enum { - CUS_SEN_8TO12_7074, /**< Do not use*/ - CUS_SEN_8TO12_7000, /**< Sensor bayer raw is 8 bits*/ - CUS_SEN_8TO12_114118, /**< Do not use*/ - CUS_SEN_8TO12_11400, /**< Do not use*/ - CUS_SEN_10TO12_9098, /**< Do not use*/ - CUS_SEN_10TO12_9000, /**< Sensor bayer raw is 10 bits*/ - CUS_SEN_10TO12_1121110, /**< Do not use*/ - CUS_SEN_10TO12_11200 /**< Do not use*/ -} CUS_SEN_FMT_CONV_MODE; - -/*! @brief Sensor input raw data precision */ -typedef enum { - CUS_DATAPRECISION_8 = 0, /**< raw data precision is 8bits */ - CUS_DATAPRECISION_10 = 1, /**< raw data precision is 10bits */ - CUS_DATAPRECISION_16 = 2, /**< raw data precision is 16bits */ - CUS_DATAPRECISION_12 = 3, /**< raw data precision is 12bits */ - CUS_DATAPRECISION_14 = 4, /**< raw data precision is 14bits */ -} CUS_DATAPRECISION; - -/*! @brief Select sensor data intarface */ -typedef enum { - CUS_SENIF_BUS_PARL = 0, /**< sensor data bus is parallel bus */ - CUS_SENIF_BUS_MIPI = 1, /**< sensor data bus is mipi */ - CUS_SENIF_BUS_BT601 = 2, - CUS_SENIF_BUS_BT656 = 3, - CUS_SENIF_BUS_BT1120 = 4, -} CUS_SENIF_BUS; - -typedef enum { - CUS_SEN_INPUT_FORMAT_YUV422, - CUS_SEN_INPUT_FORMAT_RGB, -} CUS_SEN_INPUT_FORMAT; - -/*! @brief Select pin polarity */ -typedef enum { - CUS_CLK_POL_POS = 0, /**< High active */ - CUS_CLK_POL_NEG /**< Low active */ -} CUS_CLK_POL; - -typedef enum -{ - CUS_SENSOR_YUV_ORDER_CY = 0, - CUS_SENSOR_YUV_ORDER_YC = 1, -}CUS_SENSOR_YUV_ORDER; - -/*! @brief Sensor master clock select */ -typedef enum { - CUS_CMU_CLK_27MHZ, - CUS_CMU_CLK_21P6MHZ, - CUS_CMU_CLK_12MHZ, - CUS_CMU_CLK_5P4MHZ, - CUS_CMU_CLK_36MHZ, - CUS_CMU_CLK_54MHZ, - CUS_CMU_CLK_43P2MHZ, - CUS_CMU_CLK_61P7MHZ, - CUS_CMU_CLK_72MHZ, - CUS_CMU_CLK_48MHZ, - CUS_CMU_CLK_24MHZ, - CUS_CMU_CLK_37P125MHZ, - CUS_CMU_CLK_LPLL_DIV1, - CUS_CMU_CLK_LPLL_DIV2, - CUS_CMU_CLK_LPLL_DIV4, - CUS_CMU_CLK_LPLL_DIV8, -} CUS_MCLK_FREQ; //Depends on chip. - -//Depends on chip definition. -typedef enum { - CUS_SR0_PAR_DISABLE, - CUS_SR0_PAR_MODE_1, - CUS_SR0_PAR_MODE_2, -} CUS_SR0_PAR_MODE; - -//Depends on chip definition. -typedef enum { - CUS_SR0_BT656_DISABLE, - CUS_SR0_BT656_MODE_1, - CUS_SR0_BT656_MODE_2, - CUS_SR0_BT656_MODE_3, - CUS_SR0_BT656_MODE_4, -} CUS_SR0_BT656_MODE; - -//Depends on chip definition. -typedef enum { - CUS_SR1_BT656_DISABLE, - CUS_SR1_BT656_MODE_1, -} CUS_SR1_BT656_MODE; - -//Depends on chip definition. -typedef enum { - CUS_SR0_BT601_DISABLE, - CUS_SR0_BT601_MODE_1, - CUS_SR0_BT601_MODE_2, - CUS_SR0_BT601_MODE_3, - CUS_SR0_BT601_MODE_4, -} CUS_SR0_BT601_MODE; - -//Depends on chip definition. -typedef enum { - CUS_SR0_MIPI_DISABLE, - CUS_SR0_MIPI_MODE_1, - CUS_SR0_MIPI_MODE_2, -} CUS_SR0_MIPI_MODE; - -//Depends on chip definition. -typedef enum { - CUS_SR1_MIPI_DISABLE, - CUS_SR1_MIPI_MODE_1, - CUS_SR1_MIPI_MODE_2, - CUS_SR1_MIPI_MODE_3, - CUS_SR1_MIPI_MODE_4, -} CUS_SR1_MIPI_MODE; - -//Depends on chip definition. -typedef enum -{ - CUS_VIF_BT656_EAV_DETECT = 0, - CUS_VIF_BT656_SAV_DETECT = 1, -}CUS_VIF_BT656_CHANNEL_SELECT; - -//Depends on chip definition. -typedef enum -{ - CUS_VIF_BT656_VSYNC_DELAY_1LINE = 0, - CUS_VIF_BT656_VSYNC_DELAY_2LINE = 1, - CUS_VIF_BT656_VSYNC_DELAY_0LINE = 2, - CUS_VIF_BT656_VSYNC_DELAY_AUTO = 3, -}CUS_VIF_BT656_VSYNC_DELAY; - -typedef enum -{ - CUS_SENSOR_FUNC_DISABLE = 0, - CUS_SENSOR_FUNC_ENABLE = 1, -}CUS_SENSOR_FUNC; - -typedef enum -{ - CUS_SENSOR_PAD_GROUP_A = 0, - CUS_SENSOR_PAD_GROUP_B = 1, - CUS_SENSOR_PAD_GROUP_C = 2, - CUS_SENSOR_PAD_GROUP_D = 3, -}CUS_SENSOR_PAD_GROUP; - -typedef enum -{ - CUS_SENSOR_MASTER_MODE = 0, - CUS_SENSOR_SLAVE_MODE = 1, -}CUS_SENSOR_MODE; - -typedef enum -{ - CUS_SENSOR_CHANNEL_MODE_REALTIME_NORMAL = 0, - CUS_SENSOR_CHANNEL_MODE_REALTIME_HDR = 1, - CUS_SENSOR_CHANNEL_MODE_RAW_STORE = 2, - CUS_SENSOR_CHANNEL_MODE_RAW_STORE_HDR = 3, -}CUS_SENSOR_CHANNEL_MODE; - -typedef struct { - unsigned int gain; - unsigned int offset; -} CUS_GAIN_GAP_ARRAY; - -////////////////////////////////////// -// sensor functions -////////////////////////////////////// - -typedef struct { - u32 length; //header length - u32 version; //version -}CUS_CAMSENSOR_CAP; - -/////////////////// ISP for SENSOR API /////////////////// -typedef enum { - CUS_INT_TASK_AE = (1<<0), - CUS_INT_TASK_AWB = (1<<1), - CUS_INT_TASK_AF = (1<<2), - CUS_INT_TASK_VS = (1<<3), - CUS_INT_TASK_VDOS = (1<<4), -} CUS_INT_TASK_TYPE; - -#define MAX_RUN_ORDER 16 -typedef struct { - u8 RunLength; - u8 Orders[MAX_RUN_ORDER]; - u8 CurTaskType; -} CUS_INT_TASK_ORDER; - -/////////////////// Shutter Info /////////////////////// -/*! @brief Report shutter information */ -typedef struct { - u32 length; /**< struct size */ - u32 max; /**< maximun shutter in us*/ - u32 min; /**< minimum shutter in us*/ - u32 step; /**< shutter in step us*/ -} CUS_SHUTTER_INFO; - -////////////////// CSI CLOCK //////////////////////// -/*! @brief Select MIPI clock*/ -typedef enum { - CUS_CSI_CLK_DISABLE = -1, /**< Disable MIPI clock*/ - CUS_CSI_CLK_108M = 0, /**< MIPI pixel rate 864Mbps (1-lane)*/ - CUS_CSI_CLK_86M = 1, /**< MIPI pixel rate 344Mbps(1-lane)*/ - CUS_CSI_CLK_144M = 2, /**< MIPI pixel rate 1152Mbps(1-lane)*/ - CUS_CSI_CLK_172M = 3, - CUS_CSI_CLK_216M = 4, - CUS_CSI_CLK_288M = 5, - CUS_CSI_CLK_40M = 6, - CUS_CSI_CLK_24M = 7, - CUS_CSI_CLK_12M = 8, - CUS_CSI_CLK_123M = 9 -}CUS_CSI_CLK; - -///////////////// SENSOR PIN CONFIG///////////////// -/*! @brief Sensor pin assignment*/ -typedef enum { - CUS_SR_PAD_CFG_1 = 1, /**< Pin config for MIPI 1/2 lanes*/ - CUS_SR_PAD_CFG_MIPI = 1, /**< Pin config for MIPI 1/2 lanes*/ - CUS_SR_PAD_CFG_2 = 2, /**< Reserved */ - CUS_SR_PAD_CFG_3 = 3, /**< Reserved */ - CUS_SR_PAD_CFG_10BITS = 4, /**< Pin config for parallel interface 10 bits */ - CUS_SR_PAD_CFG_4 = 4, /**< Pin config for parallel interface 12 bits */ - CUS_SR_PAD_CFG_12BITS = 5, /**< Pin config for parallel interface 12 bits */ - CUS_SR_PAD_CFG_5 = 5, /**< Pin config for parallel interface 12 bits */ - CUS_SR_PAD_CFG_6 = 6 /**< Pin config for parallel interface 12 bits */ - }CUS_SR_PAD_CFG; - -/*! @brief virtual channel0 hsync. mode */ -typedef enum -{ - PACKET_HEADER_EDGE1 = 0, /**< packet header edge */ - PACKET_HEADER_EDGE2 = 1, /**< line end edge */ - PACKET_HEADER_EDGE3 = 2, /**< line start edge */ - PACKET_FOOTER_EDGE = 3, /**< packet footer edge */ -}CUS_CSI_VC_HS_MODE; - -typedef enum -{ - CUS_HDR_MODE_NONE = 0, - CUS_HDR_MODE_SONY_DOL = 1, - CUS_HDR_MODE_DCG = 2, - CUS_HDR_MODE_EMBEDDED_RAW8 = 3, - CUS_HDR_MODE_EMBEDDED_RAW10 = 4, - CUS_HDR_MODE_EMBEDDED_RAW12 = 5, - CUS_HDR_MODE_EMBEDDED_RAW16 = 6, //Only for OV2718? - CUS_HDR_MODE_LI = 7, - CUS_HDR_MODE_MULTI_VC = 8, -}CUS_HDR_MODE; - -typedef enum -{ - // Index 0 - SENSOR_DRIVER_MODE_VGA_30P_RESOLUTION, // 640*360 30P - SENSOR_DRIVER_MODE_VGA_50P_RESOLUTION, // 640*360 50P - SENSOR_DRIVER_MODE_VGA_60P_RESOLUTION, // 640*360 60P - SENSOR_DRIVER_MODE_VGA_100P_RESOLUTION, // 640*360 100P - SENSOR_DRIVER_MODE_VGA_120P_RESOLUTION, // 640*360 120P - - // Index 5 - SENSOR_DRIVER_MODE_HD_24P_RESOLUTION, // 1280*720 24P - SENSOR_DRIVER_MODE_HD_30P_RESOLUTION, // 1280*720 30P - SENSOR_DRIVER_MODE_HD_50P_RESOLUTION, // 1280*720 50P - SENSOR_DRIVER_MODE_HD_60P_RESOLUTION, // 1280*720 60P - SENSOR_DRIVER_MODE_HD_100P_RESOLUTION, // 1280*720 100P - - // Index 10 - SENSOR_DRIVER_MODE_HD_120P_RESOLUTION, // 1280*720 120P - SENSOR_DRIVER_MODE_1600x900_30P_RESOLUTION, // 1600*900 30P - SENSOR_DRIVER_MODE_FULL_HD_15P_RESOLUTION, // 1920*1080 15P - SENSOR_DRIVER_MODE_FULL_HD_24P_RESOLUTION, // 1920*1080 24P - SENSOR_DRIVER_MODE_FULL_HD_25P_RESOLUTION, // 1920*1080 25P - - // Index 15 - SENSOR_DRIVER_MODE_FULL_HD_30P_RESOLUTION, // 1920*1080 30P - SENSOR_DRIVER_MODE_FULL_HD_50P_RESOLUTION, // 1920*1080 50P - SENSOR_DRIVER_MODE_FULL_HD_60P_RESOLUTION, // 1920*1080 60P - SENSOR_DRIVER_MODE_SUPER_HD_30P_RESOLUTION, // 2304*1296 30P - SENSOR_DRIVER_MODE_SUPER_HD_25P_RESOLUTION, // 2304*1296 25P - - // Index 20 - SENSOR_DRIVER_MODE_SUPER_HD_24P_RESOLUTION, // 2304*1296 24P - SENSOR_DRIVER_MODE_1440_30P_RESOLUTION, // 2560*1440 30P - SENSOR_DRIVER_MODE_2D7K_15P_RESOLUTION, // 2704*1524 15P - SENSOR_DRIVER_MODE_2D7K_30P_RESOLUTION, // 2704*1524 30P - SENSOR_DRIVER_MODE_4K2K_15P_RESOLUTION, // 3840*2160 15P - - // Index 25 - SENSOR_DRIVER_MODE_4K2K_30P_RESOLUTION, // 3840*2160 30P - SENSOR_DRIVER_MODE_4TO3_VGA_30P_RESOLUTION, // 640*480 30P - SENSOR_DRIVER_MODE_4TO3_1D2M_30P_RESOLUTION, // 1280*960 30P - SENSOR_DRIVER_MODE_4TO3_1D5M_30P_RESOLUTION, // 1440*1080 30P - SENSOR_DRIVER_MODE_4TO3_3M_15P_RESOLUTION, // 2048*1536 15P - - // Index 30 - SENSOR_DRIVER_MODE_4TO3_3M_30P_RESOLUTION, // 2048*1536 30P - SENSOR_DRIVER_MODE_4TO3_5M_15P_RESOLUTION, // 2560*1920 15P - SENSOR_DRIVER_MODE_4TO3_5M_30P_RESOLUTION, // 2560*1920 30P - SENSOR_DRIVER_MODE_4TO3_8M_15P_RESOLUTION, // 3264*2448 15P - SENSOR_DRIVER_MODE_4TO3_8M_30P_RESOLUTION, // 3264*2448 30P - - // Index 35 - SENSOR_DRIVER_MODE_4TO3_10M_15P_RESOLUTION, // 3648*2736 15P - SENSOR_DRIVER_MODE_4TO3_10M_30P_RESOLUTION, // 3648*2736 30P - SENSOR_DRIVER_MODE_4TO3_12M_15P_RESOLUTION, // 4032*3024 15P - SENSOR_DRIVER_MODE_4TO3_12M_30P_RESOLUTION, // 4032*3024 30P - SENSOR_DRIVER_MODE_4TO3_14M_15P_RESOLUTION, // 4352*3264 15P - - // Index 40 - SENSOR_DRIVER_MODE_4TO3_14M_30P_RESOLUTION, // 4352*3264 30P - SENSOR_DRIVER_MODE_4K2K_24P_RESOLUTION, - SENSOR_DRIVER_MODE_PAL_25P_RESOLUTION, - SENSOR_DRIVER_MODE_NTSC_30P_RESOLUTION, - - // For Camera Preview - SENSOR_DRIVER_MODE_BEST_CAMERA_PREVIEW_RESOLUTION, - SENSOR_DRIVER_MODE_BEST_CAMERA_CAPTURE_16TO9_RESOLUTION, - SENSOR_DRIVER_MODE_BEST_CAMERA_CAPTURE_4TO3_RESOLUTION, - SENSOR_DRIVER_MODE_FULL_HD_30P_RESOLUTION_HDR, -} CUS_SNR_RESOLUTION; - - -#ifdef __cplusplus -extern "C" -#endif - -/**@brief ISP sensor interface control API */ -typedef struct __ISensorIfAPI //isp sensor interface API -{ - version_info version; - /**@brief Reserved */ - void* pdata; - - /** @brief Set sensor power down pin. - @param[in] idx Sensor pad ID. - @param[in] pol pin polarity. - @retval SUCCESS or FAIL if error occurs. - */ - int (*PowerOff)(u32 idx, CUS_CLK_POL pol); - - /** @brief Set sensor power reset pin. - @param[in] idx Sensor pad ID. - @param[in] pol pin polarity. - @retval SUCCESS or FAIL if error occurs. - */ - int (*Reset)(u32 idx, CUS_CLK_POL pol); - - /** @brief Configure sensor master clock. - @param[in] idx Sensor pad ID. - @param[in] bONOFF Clock ON/OFF control. - @param[in] mclk Clock frequency Hz. - @retval SUCCESS or FAIL if error occurs. - */ - int (*MCLK)(u32 idx, u8 bONOFF, CUS_MCLK_FREQ mclk); - - /** @brief Query sensor master clock. - @param[in] idx Sensor pad ID. - @param[in] mclk Query if clock frequency Hz is available. - @retval SUCCESS or FAIL if error occurs. - */ - int (*QueryMCLK)(u32 idx, CUS_MCLK_FREQ mclk); - - /** @brief Query MIPI lane number. - @param[in] idx Sensor pad ID. - @param[in] lane_num Query max lane number. - @retval SUCCESS or FAIL if error occurs. - */ - int (*QueryLaneNum)(u32 idx, u8 *max_lane); -#if 0 - /** @brief Select pixel clock source - @remarks Parallel interface only - @param[in] handle Handle to sensor driver. - @param[in] pclk_source Clock source. - @retval SUCCESS or FAIL if error occurs. - */ - int (*PCLK)(CUS_PCLK_SOURCE pclk_source); //senect sensor - - /** @brief Configure HSYNC pin polarity. - @remarks Parallel interface only - @param[in] handle Handle to sensor driver. - @param[in] pol pin polarity. - @retval SUCCESS or FAIL if error occurs. - */ - int (*HsyncPol)(CUS_CLK_POL pol); - - /** @brief [parallel interface only] Configure VSYNC pin polarity. - @param[in] handle Handle to sensor driver. - @param[in] pol pin polarity. - @retval SUCCESS or FAIL if error occurs. - */ - int (*VsyncPol)(CUS_CLK_POL pol); - - /** @brief Configure PCLK pin polarity. - @param[in] handle Handle to sensor driver. - @param[in] pol pin polarity. - @retval SUCCESS or FAIL if error occurs. - */ - int (*ClkPol)(CUS_CLK_POL pol); - - /** @brief Configure sensor bayer raw pixel order - @param[in] handle Handle to sensor driver. - @param[in] bayer_id Select pixel order - @retval SUCCESS or FAIL if error occurs. - */ - int (*BayerFmt)(CUS_SEN_BAYER bayer_id); - - /** @brief Configure sensor RGBIR (8 or 10bits) convert to 12bit bits isp input, This config will be ignore for 12/16 bits sensor bayer raw input. - @param[in] handle Handle to sensor driver. - @param[in] mode Mode select - @retval SUCCESS or FAIL if error occurs. - */ - int (*FmtConv)(CUS_SEN_FMT_CONV_MODE mode); - - /** @brief Select sensor image data interface - @param[in] handle Handle to sensor driver. - @param[in] bus Sensor interface - @retval SUCCESS or FAIL if error occurs. - */ - int (*DataBus)(CUS_SENIF_BUS bus); - - /** @brief Configure sensor bayer raw pixel bits - @param[in] handle Handle to sensor driver. - @param[in] prec Select pixel bits - @retval SUCCESS or FAIL if error occurs. - */ - int (*DataPrecision)(CUS_DATAPRECISION prec); - - /** @brief Wait isp frame start event - @param[in] handle Handle to sensor driver. - @param[in] ms Max timeout in ms - @retval SUCCESS or FAIL if error occurs. - */ - int (*WaitVStart)(int ms); - - /** @brief Wait isp frame end event - @param[in] handle Handle to sensor driver. - @param[in] ms Max timeout in ms - @retval SUCCESS or FAIL if error occurs. - */ - int (*WaitVEnd)(int ms); - - /** @brief Configure 3A task order table - @param[in] handle Handle to sensor driver. - @param[in] tasks Task order table - @retval SUCCESS or FAIL if error occurs. - */ - int (*Set3ATaskOrder)(CUS_INT_TASK_ORDER tasks); -#endif - /** @brief Select sensor IO pin assignment - @param[in] idx Sensor pad ID. - @param[in] ulSnrType Interface type. - @param[in] ulSnrPadCfg Pin config. - @retval SUCCESS or FAIL if error occurs. - */ - int (*SetIOPad)(u32 idx, CUS_SENIF_BUS ulSnrType, u32 ulSnrPadCfg); - - //FOR CSI - - /** @brief Set maximum mipi data rate (amount of all lans) - @remarks MIPI interface only. - @param[in] idx Sensor pad ID. - @param[in] clk Max data rate. - @retval SUCCESS or FAIL if error occurs. - */ - int (*SetCSI_Clk)(u32 idx, CUS_CSI_CLK clk); - - /** @brief Set number of MIPI lanes - @remarks MIPI interface only. - @param[in] idx Sensor pad ID. - @param[in] num_lan Number of lanes. - @param[in] bon_off Clock ON/OFF control. - @retval SUCCESS or FAIL if error occurs. - */ - int (*SetCSI_Lane)(u32 idx, u16 num_lan, u8 bon_off); - - /** @brief Enable long packet type - @remarks MIPI interface only - @param[in] idx Sensor pad ID. - @param[in] ctl_cfg0_15 Control flag bit[0:15] - @param[in] ctl_cfg16_31 Control flag bit[16:31] - @param[in] ctl_cfg32_47 Control flag bit[32:47] - @retval SUCCESS or FAIL if error occurs. - */ - int (*SetCSI_LongPacketType)(u32 idx, u16 ctl_cfg0_15, u16 ctl_cfg16_31, u16 ctl_cfg32_47); - - /** @brief Virtual channel0 hsync mode - @remarks MIPI interface only - @param[in] idx Sensor pad ID. - @param[in] mode HSYNC mode. - @retval SUCCESS or FAIL if error occurs. - */ - int (*SetCSI_VC0HSmode)(CUS_CSI_VC_HS_MODE mode); - - /** @brief Configure MIPI capture start timing - @remarks MIPI interface only - @param[in] idx Sensor pad ID. - @param[in] rx_clk_skip_ns - @param[in] rx_data_skip_ns - @retval SUCCESS or FAIL if error occurs. - */ - int (*SetCSI_clk_data_skip)(u32 idx, u8 rx_clk_skip_ns,u8 rx_data_skip_ns); - - /** @brief Configure MIPI hdr mode - @remarks MIPI interface only - @param[in] idx Sensor pad ID. - @param[in] hdr_mode HDR mode. - @param[in] bon_off Clock ON/OFF control. - @retval SUCCESS or FAIL if error occurs. - */ - int (*SetCSI_hdr_mode)(u32 idx, CUS_HDR_MODE hdr_mode, u8 bon_off); - -#if 0 - /** @brief Configure sensor RGBIR raw pixel order - @param[in] handle Handle to sensor driver. - @param[in] bayer_id Select pixel order - @retval SUCCESS or FAIL if error occurs. - */ - int (*RGBIRFmt)(CUS_SEN_RGBIR RGBIR_id); -#endif - - /** @brief Skip vif output frame - @remarks Skip Frame interface only - @param[in] idx Sensor pad ID. - @param[in] fps Sensor current fps. - @param[in] cnt Skip counter - @retval SUCCESS or FAIL if error occurs. - */ - int (*SetSkipFrame)(u32 idx, u32 fps, u32 cnt); - - /** @brief Switch Vif PadID - @remarks Switch Vif PadID mux - @param[in] id Vif Select Source. - @retval SUCCESS or FAIL if error occurs. - */ - int (*SetVIFSelectSource)(u32 id); ///2eff - -}ISensorIfAPI; - -typedef union { - //Parallel sensor - struct { - u32 parallel_reserved; //No additional attribute. - } attr_parallel; - - //MIPI sensor - struct { - u32 mipi_lane_num; - u32 mipi_data_format; //0: YUV 422 format. 1: RGB pattern. - u32 mipi_yuv_order; //YUYV or UYVY - u32 mipi_hsync_mode; - u32 mipi_sampling_delay; /** < MIPI start sampling delay */ /*bit 0~7: clk_skip_ns. bit 8~15: data_skip_ns*/ - CUS_HDR_MODE mipi_hdr_mode; - u32 mipi_hdr_virtual_channel_num; - } attr_mipi; - - //BT656 sensor - struct { - u32 bt656_total_ch; - u32 bt656_cur_ch; - u32 bt656_ch_det_en; - CUS_VIF_BT656_CHANNEL_SELECT bt656_ch_det_sel; - u32 bt656_bit_swap; - u32 bt656_8bit_mode; - CUS_VIF_BT656_VSYNC_DELAY bt656_vsync_delay; - u32 bt656_hsync_inv; - u32 bt656_vsync_inv; - u32 bt656_clamp_en; - u32 bt656_yuv_order; //YUYV or UYVY - } attr_bt656; -} InterfaceAttr_u; - -/////////////////////////////////////////////////////// - -/** @brief Sensor driver interface \n -The function here are implemented by sensor driver. -*/ -typedef struct __ms_cus_sensor{ - //short lib_idx; /**< Reserved , Do not use */ - version_info version; - char model_id[32]; /**< Please fill the sensor modle id string here then libcamera user can read model_id by using cameraGetSensorModelID() .*/ - void *sen_handle; /**< Reserved , Do not use */ - void *private_data; /**< sensor driver dependent variables should store in private_data and free when release */ - void *slave_mode_set; /**< Reserved , For sensor vsync/hsync control*/ - - // i2c - app_i2c_cfg i2c_cfg; /**< Sensor i2c setting */ - i2c_handle_t *i2c_bus; /**< Handle to sensor i2c API. */ - - // sensor if api - ISensorIfAPI *sensor_if_api; /**< sensor interface API */ - - // ae parameters - int ae_gain_delay; /**< How many frame delay from writing AE gain to take effect*/ - int ae_shutter_delay; /**< How many frame delay from writing AE shutter to take effect*/ - int ae_gain_ctrl_num; - int ae_shutter_ctrl_num; - - // polarity - CUS_CLK_POL reset_POLARITY; /** < Sensor REST pin polarity */ - CUS_CLK_POL pwdn_POLARITY; /** < Sensor Power Down pin polarity */ - CUS_CLK_POL VSYNC_POLARITY; /** < Sensor VSYNC polarity */ - CUS_CLK_POL HSYNC_POLARITY; /** < Sensor HSYNC pin polarity */ - CUS_CLK_POL PCLK_POLARITY; /** < Sensor Plxel Clock pin polarity */ - - // sensor data enum list*/ - CUS_CAMSENSOR_ISPTYPE isp_type; /** < Always use ISP_EXT */ - CUS_SEN_BAYER bayer_id; /** < Sensor bayer raw pixel order */ - CUS_SEN_RGBIR RGBIR_id; /** < Sensor bayer raw pixel order */ - CUS_SENIF_BUS sif_bus; /** < Select sensor interface */ - CUS_DATAPRECISION data_prec; /** < Raw data bits */ - CUS_SEN_FMT_CONV_MODE data_mode; /** < Data convert mode*/ - CUS_CAMSENSOR_ORIT orient; /** < Sensor mirror/flip */ - CUS_SENSOR_PAD_GROUP snr_pad_group; - CUS_SENSOR_MODE snr_pad_mode; /** < support master/slave mode sensor */ - - cus_camsensor_res_list video_res_supported; /** < Resolution list */ - InterfaceAttr_u interface_attr; - - //sensor calibration - u32 mclk; /** < Sensor master clock frequency */ - u32 sat_mingain; /**< Minimum AE gain */ - u32 ir_only_fmt; - u32 nPixelSize; //in nano meter - - //////////////////////////////////////////////// - // system functions - //////////////////////////////////////////////// - - /** @brief Sensor power on sequence, I2C must be ready after calling this function - @param[in] handle Handle to sensor driver. - @remark Following configuration need to set up at this stage \n - @ref __ISensorIfAPI::Reset Reset sensor \n - @ref __ISensorIfAPI::PowerOff Sensor power down pin \n - @ref __ISensorIfAPI::MCLK Sensor master clock \n - @ref __ISensorIfAPI::SetIOPad ISP sensor IO \n - @ref __ISensorIfAPI::SetCSI_Clk [MIPI sensor only] MIPI clock\n - @ref __ISensorIfAPI::HsyncPol Hsync polarity\n - @ref __ISensorIfAPI::VsyncPol Vsync polarity\n - @ref __ISensorIfAPI::ClkPol [Parallel sensor only] Pixel clock polarity\n - @ref __ISensorIfAPI::BayerFmt Raw data format\n - @ref __ISensorIfAPI::DataPrecision Raw data pixel bits\n - @ref __ISensorIfAPI::FmtConv Raw data to ISP pixel convert\n - @retval SUCCESS or FAIL if error occurs. - */ - int (*pCus_sensor_poweron)(struct __ms_cus_sensor* handle, u32 idx); - - /** @brief Sensor power off - @param[in] handle Handle to sensor driver. - @retval SUCCESS or FAIL if error occurs. - */ - int (*pCus_sensor_poweroff)(struct __ms_cus_sensor* handle, u32 idx); - - /** @brief Sensor initialization - @param[in] handle Handle to sensor driver. - @retval SUCCESS or FAIL if error occurs. - @remark Fill sensor initial table here, Sensor beginning to output raw images after calling this function . - */ - int (*pCus_sensor_init)(struct __ms_cus_sensor* handle); - - /** @brief Sensor Post initialization - @param[in] handle Handle to sensor driver. - @retval SUCCESS or FAIL if error occurs. - @remark Fill sensor initial table here, Sensor beginning to output raw images after calling this function . - */ - int (*pCus_sensor_post_init)(struct __ms_cus_sensor* handle, u32 idx); - - /** @brief Release resources those allocated in cus_camsensor_init_handle() - @param[in] handle Handle to sensor driver. - @retval SUCCESS or FAIL if error occurs. - @remark Release resource allocated in \ref cus_camsensor_init_handle - */ - int (*pCus_sensor_release)(struct __ms_cus_sensor* handle); - - /** @brief Enter sensor suspend mode - @param[in] handle Handle to sensor driver. - @retval SUCCESS or FAIL if error occurs. - @remark ISP call this function before enter power saving mode - */ - int (*pCus_sensor_suspend)(struct __ms_cus_sensor* handle); - - /** @brief Sensor wakeup - @param[in] handle Handle to sensor driver. - @retval SUCCESS or FAIL if error occurs. - @remark ISP call this function after exit power saving mode - */ - int (*pCus_sensor_resume)(struct __ms_cus_sensor* handle); - - /** @brief Enable sensor pattern mode if sensor hardward supported - @param[in] handle Handle to sensor driver. - @param[in] mode Pattern select, if 0 disable pattern mode. - @retval SUCCESS or FAIL if error occurs. - @remark This function is optional - */ - int (*pCus_sensor_SetPatternMode)(struct __ms_cus_sensor* handle,u32 mode); - - // Normal - - /** @brief Check sensor ID and report to ISP sensor match or not - @param[in] handle Handle to sensor driver. - @param[out] id Receive 4 bytes customer defined sensor ID. - @retval Return SUCCESS if sensor matched or Retuen FAIL if sensor mismatch. - @remark Read sensor ID through I2C - */ - int (*pCus_sensor_GetSensorID)(struct __ms_cus_sensor* handle, u32 *id); - - /** @brief Get resolution list - @param[in] handle Handle to sensor driver. - @param[out] id Receive supported resolution list - @retval Return SUCCESS or FAIL if error occurs. - */ - int (*pCus_sensor_GetVideoRes)(struct __ms_cus_sensor* handle, u32 res_idx, cus_camsensor_res **res); - - /** @brief Get resolution list - @param[in] handle Handle to sensor driver. - @param[out] id Receive supported resolution list - @retval Return SUCCESS or FAIL if error occurs. - */ - int (*pCus_sensor_GetCurVideoRes)(struct __ms_cus_sensor* handle, u32 *cur_idx, cus_camsensor_res **res); - - /** @brief Select a sensor output resolution sensor list - @param[in] handle Handle to sensor driver. - @param[in] res_id Resolution id - @retval Return SUCCESS or FAIL if error occurs. - */ - int (*pCus_sensor_SetVideoRes)(struct __ms_cus_sensor* handle, u32 res_id); - - /** @brief Get sensor current mirror flip setting - @param[in] handle Handle to sensor driver. - @param[out] ori Receive Mirror/Flip setting. - @retval Return SUCCESS or FAIL if error occurs. - */ - int (*pCus_sensor_GetOrien)(struct __ms_cus_sensor* handle, CUS_CAMSENSOR_ORIT *ori); - - /** @brief Select a sensor mirror flip - @param[in] handle Handle to sensor driver. - @param[in] ori Mirror/Flip configuration. - @retval Return SUCCESS or FAIL if error occurs. - */ - int (*pCus_sensor_SetOrien)(struct __ms_cus_sensor* handle, CUS_CAMSENSOR_ORIT ori); - - /** @brief Get sensor capability - @param[in] handle Handle to sensor driver. - @param[out] cap Receive sensor capability - @retval Return SUCCESS or FAIL if error occurs. - */ - int (*pCus_sensor_GetSensorCap)(struct __ms_cus_sensor* handle, CUS_CAMSENSOR_CAP *cap); - - /////////////////////////////////////////////////////// - // AE - /////////////////////////////////////////////////////// - // unit: micro seconds - - /** @brief AE/Frame status change notification - @param[in] handle Handle to sensor driver. - @param[in] status Current status - @retval Return SUCCESS or FAIL if error occurs. - */ - int (*pCus_sensor_AEStatusNotify)(struct __ms_cus_sensor* handle, CUS_CAMSENSOR_AE_STATUS_NOTIFY status); - - /** @brief Get sensor shutter setting in us - @param[in] handle Handle to sensor driver. - @param[out] us Receive current shutter setting - @retval Return SUCCESS or FAIL if error occurs. - */ - int (*pCus_sensor_GetAEUSecs)(struct __ms_cus_sensor* handle, u32 *us); - - /** @brief Set sensor shutter in us - @param[in] handle Handle to sensor driver. - @param[in] us Shutter setting in us - @retval Return SUCCESS or FAIL if error occurs. - */ - int (*pCus_sensor_SetAEUSecs)(struct __ms_cus_sensor* handle, u32 us); - - // Gain: 1x = 1024 - /** @brief Get sensor current AE gain - @param[in] handle Handle to sensor driver. - @param[out] gain Receive current AE gain - @retval Return SUCCESS or FAIL if error occurs. - @remark gain: 1x = 1024 - */ - int (*pCus_sensor_GetAEGain)(struct __ms_cus_sensor* handle, u32* gain); - - /** @brief Set sensor AE gain - @param[in] handle Handle to sensor driver. - @param[in] gain AE gain - @retval Return SUCCESS or FAIL if error occurs. - @remark gain: 1x = 1024 - */ - int (*pCus_sensor_SetAEGain)(struct __ms_cus_sensor* handle, u32 gain); - - /** @brief Get supported shutter range - @param[in] handle Handle to sensor driver. - @param[out] min Receive minimum shutter which sensor can supported - @param[out] min Receive maxiimum shutter which sensor can supported - @retval Return SUCCESS or FAIL if error occurs. - @remark gain: 1x = 1024 - */ - int (*pCus_sensor_GetAEMinMaxUSecs)(struct __ms_cus_sensor* handle, u32 *min, u32 *max); - - /** @brief Get supported AE gain range - @param[in] handle Handle to sensor driver. - @param[out] min Receive minimum gain which sensor can supported - @param[out] min Receive maxiimum gain which sensor can supported - @retval Return SUCCESS or FAIL if error occurs. - @remark gain: 1x = 1024 - */ - int (*pCus_sensor_GetAEMinMaxGain)(struct __ms_cus_sensor* handle, u32 *min, u32 *max); - - // frame rate control - /** @brief Get current fps - @param[in] handle Handle to sensor driver. - @retval Return current frame rate per second - */ - int (*pCus_sensor_GetFPS)(struct __ms_cus_sensor* handle); - - /** @brief Set sensor output fps - @param[in] handle Handle to sensor driver. - @param[in] fps - @retval Return SUCCESS or FAIL if fps is out of range. - */ - int (*pCus_sensor_SetFPS)(struct __ms_cus_sensor* handle, u32 fps); - - //[OPTIONAL] sensor calibration - /** @brief Optional function */ - int (*pCus_sensor_SetAEGain_cal)(struct __ms_cus_sensor* handle, u32); - - /** @brief Optional function */ - int (*pCus_sensor_setCaliData_gain_linearity)(struct __ms_cus_sensor* handle, CUS_GAIN_GAP_ARRAY* pArray ,u32 num); - - //Get shutter information - /** @brief Get shutter information - @param[in] handle Handle to sensor driver. - @param[out] info return shutter information. - @retval Return current frame rate per second - */ - int (*pCus_sensor_GetShutterInfo)(struct __ms_cus_sensor* handle,CUS_SHUTTER_INFO *info); - - /** @brief Get resolution list number - @param[in] handle Handle to sensor driver. - @param[out] ulres_num resolution list number - @retval Return SUCCESS or FAIL if error occurs. - */ - int (*pCus_sensor_GetVideoResNum)(struct __ms_cus_sensor* handle, u32 *ulres_num); - - //Get shutter information - /** @brief Sensor vendor command - @param[in] handle Handle to sensor driver. - @param[in] reserved - @param[in] param Command input - @param[out] out Command output - @retval Return SUCCESS or FAIL if error occurs. - */ - int (*pCus_sensor_CustDefineFunction)(struct __ms_cus_sensor* handle,u32 cmd_id, void *param); - - //Get Source Type - /** @brief Get Source Type - @param[in] handle Handle to sensor driver. - @param[in] plane id. - @param[out] psrc_type info - @retval Return SUCCESS or FAIL if error occurs. - */ - int (*pCus_sensor_GetSrcType)(struct __ms_cus_sensor* handle, u32 plane_id, CUS_SNR_ANADEC_SRC_TYPE *psrc_type); - - // Gain: 1x = 1024 - /** @brief Try AE gain value - @param[in] handle Handle to sensor driver. - @param[in] Target AE gain value to try - @retval Return actual sensor gain will apply on the HW. - @remark gain: 1x = 1024 - */ - u32 (*pCus_sensor_TryAEGain)(struct __ms_cus_sensor* handle, u32 gain); - - // Return actual shutter - /** @brief Try AE shutter value - @param[in] handle Handle to sensor driver. - @param[in] Target AE shutter value to try , in us - @retval Return actual sensor gain will apply on the HW. - @remark gain: 1x = 1024 - */ - u32 (*pCus_sensor_TryAEShutter)(struct __ms_cus_sensor* handle, u32 us); - - int (*pCus_sensor_SwitchgSensorId)(struct __ms_cus_sensor* handle,u32 sensorId); - - int (*pCus_sensor_GetCurSwtichSensorId)(struct __ms_cus_sensor* handle,u32 *pu32sensorId); -} ms_cus_sensor; - -/** @brief Sensor driver entry. ISP call this function before start using sensor driver. \n -ISP pass \ref ms_cus_sensor struct to obtain the driver information and function entries. \n -And all allocated resources here should be released at \ref __ms_cus_sensor::pCus_sensor_release. -Every sensor driver must implement this api. -@param[in] drv_handle A uninitialized \ref ms_cus_sensor struct from ISP, Sensor driver fill the driver information and function entries to drv_handle. -@retval SUCCESS or FAIL if error occurs. -*/ - -typedef int (*SensorInitHandle)(ms_cus_sensor* handle); - -#ifdef __cplusplus -} -#endif - -#endif /* DRV_MS_CUS_SENSOR_H_ */ -/** @} */ // end of ISP Sensor Driver Interface diff --git a/general/package/sigmastar-osdrv-sensor/src/infinity6e/include/drv_sensor.h b/general/package/sigmastar-osdrv-sensor/src/infinity6e/include/drv_sensor.h deleted file mode 100644 index 36452880..00000000 --- a/general/package/sigmastar-osdrv-sensor/src/infinity6e/include/drv_sensor.h +++ /dev/null @@ -1,53 +0,0 @@ -/* Copyright (c) 2018-2019 Sigmastar Technology Corp. - All rights reserved. - - Unless otherwise stipulated in writing, any and all information contained -herein regardless in any format shall remain the sole proprietary of -Sigmastar Technology Corp. and be kept in strict confidence -(Sigmastar Confidential Information) by the recipient. -Any unauthorized act including without limitation unauthorized disclosure, -copying, use, reproduction, sale, distribution, modification, disassembling, -reverse engineering and compiling of the contents of Sigmastar Confidential -Information is unlawful and strictly prohibited. Sigmastar hereby reserves the -rights to any and all damages, losses, costs and expenses resulting therefrom. -*/ - -#ifndef DRV_SENSOR_H -#define DRV_SENSOR_H - -#include - -#define SENSOR_DMSG(args...) do{}while(0) -#define SENSOR_EMSG(args...) CamOsPrintf(args) -#define SENSOR_IMSG(args...) CamOsPrintf(args) -#if 0 -typedef enum { - I2C_FMT_A8D8, /**< 8 bits Address, 8 bits Data */ - I2C_FMT_A16D8,/**< 16 bits Address 8 bits Data */ - I2C_FMT_A8D16,/**< 8 bits Address 16 bits Data */ - I2C_FMT_A16D16,/**< 16 bits Address 16 bits Data */ - I2C_FMT_END/**< Reserved */ -} ISP_I2C_FMT; -#endif - -extern s32 WriteRegisterPair(int slaveAddr, short reg, unsigned short value, ISP_I2C_FMT fmt); -extern u64 intlog10(u32 value); -extern u64 intlog2(u32 value); -extern s32 DrvRegisterSensorDriver(u32 nCamID, SensorInitHandle pfnSensorInitHandle); -extern s32 DrvRegisterPlaneDriver(u32 nCamID, u32 nPlaneID, SensorInitHandle pfnSensorInitHandle); -extern s32 DrvRegisterSensorDriverEx(u32 nSNRPadID, SensorInitHandle pfnSensorInitHandle, void *pPrivateData); -extern s32 DrvRegisterPlaneDriverEx(u32 nSNRPadID, u32 nPlaneID, SensorInitHandle pfnSensorInitHandle, void *pPrivateData); -extern s32 DrvSensorRelease(u32 nSNRPadID); -extern s32 DrvSensorEarlyInitSync(u32 nSNRPadID); -extern s32 DrvRegisterSensorI2CSlaveID(u32 nCamID, u32 Slaveid); -extern s32 DrvRegisterPlaneI2CSlaveID(u32 nCamID, u32 nPlaneID, u32 Slaveid); -extern s32 DrvSensorHandleVer(u32 version_major, u32 version_minor); -extern s32 DrvSensorIFVer(u32 version_major, u32 version_minor); -extern s32 DrvSensorI2CVer(u32 version_major, u32 version_minor); -#define DrvUnregisterSensorDriverEx(nSNRPadID) DrvSensorRelease((nSNRPadID)) - -#define SENSOR_USLEEP(us) CamOsUsSleep(us) -#define SENSOR_MSLEEP(ms) CamOsMsSleep(ms) -#define SENSOR_UDELAY(us) CamOsUsDelay(us) -#define SENSOR_MDELAY(ms) CamOsMsDelay(ms) -#endif diff --git a/general/package/sigmastar-osdrv-sensor/src/infinity6e/include/drv_sensor_common.h b/general/package/sigmastar-osdrv-sensor/src/infinity6e/include/drv_sensor_common.h deleted file mode 100644 index 88b2b38c..00000000 --- a/general/package/sigmastar-osdrv-sensor/src/infinity6e/include/drv_sensor_common.h +++ /dev/null @@ -1,379 +0,0 @@ -/* Copyright (c) 2018-2019 Sigmastar Technology Corp. - All rights reserved. - - Unless otherwise stipulated in writing, any and all information contained -herein regardless in any format shall remain the sole proprietary of -Sigmastar Technology Corp. and be kept in strict confidence -(Sigmastar Confidential Information) by the recipient. -Any unauthorized act including without limitation unauthorized disclosure, -copying, use, reproduction, sale, distribution, modification, disassembling, -reverse engineering and compiling of the contents of Sigmastar Confidential -Information is unlawful and strictly prohibited. Sigmastar hereby reserves the -rights to any and all damages, losses, costs and expenses resulting therefrom. -*/ - -#ifndef _SENSOR_OS_WRAPPER_H_ -#define _SENSOR_OS_WRAPPER_H_ - -#if defined(__KERNEL__) -#define CAM_OS_LINUX_KERNEL -#endif - -#include -#include -#include - -/******************************************************** RTK ***********************************************************/ -#if defined(CAM_OS_RTK) -typedef unsigned char bool; -#ifndef true -#define true 1 -#define false 0 -#endif - -#ifndef _SENSOR_SLAVE_ID_ -#define _SENSOR_SLAVE_ID_ 0 -#endif - -#define SENSOR_DRV_ENTRY_IMPL_BEGIN(NAME) - -#define SENSOR_DRV_ENTRY_IMPL_END(Name,LinearEntry,HdrSefEntry,HdrLefEntry)\ -int Name##_init_driver(unsigned char chmap)\ -{\ - int nCamID=0;\ - /*To avoid compile warning*/\ - void* p0 = LinearEntry;\ - void* p1 = HdrSefEntry;\ - void* p2 = HdrLefEntry;\ - for(nCamID=0;nCamID<4;++nCamID)\ - {\ - if((chmap>>nCamID)&0x1)\ - {\ - if(p0){ DrvRegisterSensorDriver(nCamID, LinearEntry);\ - DrvRegisterSensorI2CSlaveID(nCamID, (_SENSOR_SLAVE_ID_>>(nCamID*8))&0xFF);\ - SENSOR_DMSG("Connect %s linear to sensor pad %d\n",__FUNCTION__, nCamID);\ - }\ - if(p1){ DrvRegisterPlaneDriver(nCamID, 1, HdrSefEntry);\ - DrvRegisterPlaneI2CSlaveID(nCamID, 1, (_SENSOR_SLAVE_ID_>>(nCamID*8))&0xFF);\ - SENSOR_DMSG("Connect %s SEF to vif sensor pad %d\n",__FUNCTION__, nCamID);\ - }\ - if(p2){ DrvRegisterPlaneDriver(nCamID, 0, HdrLefEntry);\ - DrvRegisterPlaneI2CSlaveID(nCamID, 0, (_SENSOR_SLAVE_ID_>>(nCamID*8))&0xFF);\ - SENSOR_DMSG("Connect %s LEF to sensor pad %d\n",__FUNCTION__, nCamID);\ - }\ - }\ - }\ - return 0;\ -} - -static volatile int lane_num = 2; -static volatile int hdr_lane_num=2; - -#define SENSOR_DRV_PARAM_MCLK() "NONE" -#define SENSOR_USLEEP_(us) {CamOsUsDelay(us);} -#define SENSOR_MSLEEP_(ms) {CamOsMsDelay(ms);} - -/*Extension version*/ -#define SENSOR_DRV_ENTRY_IMPL_BEGIN_EX(NAME) SENSOR_DRV_ENTRY_IMPL_BEGIN(NAME) - -#define MAX_CAMID_LEN 4 -#define SENSOR_DRV_ENTRY_IMPL_END_EX(Name,LinearEntry,HdrSefEntry,HdrLefEntry,PrivateDataType)\ -static PrivateDataType* g_pData[2][MAX_CAMID_LEN] = {{0,0,0,0}, {0,0,0,0}};\ -static PrivateDataType g_PrivData[2][MAX_CAMID_LEN];\ -int Name##_init_driver(unsigned char chmap)\ -{\ - int nCamID=0;\ - /*To avoid compile warning*/\ - void* p0 = LinearEntry;\ - void* p1 = HdrSefEntry;\ - void* p2 = HdrLefEntry;\ - for(nCamID=0;nCamID>nCamID)&0x1)\ - {\ - if(p0){\ - /*void* pData = CamOsMemAlloc(sizeof(PrivateDataType));*/\ - void* pData = &g_PrivData[0][nCamID];/*Change private data to static var*/\ - memset(pData,0,sizeof(PrivateDataType));\ - DrvRegisterSensorDriverEx(nCamID, LinearEntry,pData);\ - DrvRegisterSensorI2CSlaveID(nCamID, (_SENSOR_SLAVE_ID_>>(nCamID*8))&0xFF);\ - SENSOR_DMSG("Connect %s linear to sensor pad %d\n",__FUNCTION__, nCamID);\ - g_pData[0][nCamID] = pData;\ - }\ - if(p1||p2){\ - /*void* pData = CamOsMemAlloc(sizeof(PrivateDataType));*/\ - void* pData = &g_PrivData[1][nCamID];/*Change private data to static var*/\ - memset(pData,0,sizeof(PrivateDataType));\ - if(p1){\ - DrvRegisterPlaneDriverEx(nCamID, 1, HdrSefEntry,pData);\ - DrvRegisterPlaneI2CSlaveID(nCamID, 1, (_SENSOR_SLAVE_ID_>>(nCamID*8))&0xFF);\ - SENSOR_DMSG("Connect %s SEF to vif sensor pad %d\n",__FUNCTION__, nCamID);\ - }\ - if(p2){\ - DrvRegisterPlaneDriverEx(nCamID, 0, HdrLefEntry,pData);\ - DrvRegisterPlaneI2CSlaveID(nCamID, 0, (_SENSOR_SLAVE_ID_>>(nCamID*8))&0xFF);\ - SENSOR_DMSG("Connect %s LEF to sensor pad %d\n",__FUNCTION__, nCamID);\ - }\ - g_pData[1][nCamID] = pData;\ - }\ - DrvSensorEarlyInitSync(nCamID);\ - }\ - }\ - return 0;\ -}\ -\ -int Name##_deinit_driver(unsigned char chmap)\ -{\ - int nCamID=0;\ - for(nCamID=0;nCamID>nCamID)&0x1)\ - {\ - if(g_pData[0][nCamID] || g_pData[1][nCamID])\ - {\ - DrvUnregisterSensorDriverEx(nCamID);\ - if(g_pData[0][nCamID]){\ - /*CamOsMemRelease((void*)g_pData[0][nCamID]);*/\ - g_pData[0][nCamID] = 0;\ - }\ - if(g_pData[1][nCamID]){\ - /*CamOsMemRelease((void*)g_pData[1][nCamID]);*/\ - g_pData[1][nCamID] = 0;\ - }\ - }\ - }\ - }\ - return 0;\ -} -/******************************************************** LINUX ***********************************************************/ -#elif defined(CAM_OS_LINUX_KERNEL) -#include -#include -#include -#include -#include -#define SENSOR_DRV_ENTRY_IMPL_BEGIN(Name) \ -int chmap = 0;\ -module_param(chmap, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);\ -MODULE_PARM_DESC(chmap, "VIF channel mapping");\ -char *mclk = "use default parameter";\ -module_param(mclk, charp, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);\ -MODULE_PARM_DESC(mclk, "Assign MCLK"); -int lane_num = 2;\ -module_param(lane_num, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);\ -MODULE_PARM_DESC(lane_num, "sensor output lane number"); -int hdr_lane_num = 4;\ -module_param(hdr_lane_num, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);\ -MODULE_PARM_DESC(hdr_lane_num, "sensor output lane number"); -int i2c_slave_id = 0;\ -module_param(i2c_slave_id, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);\ -MODULE_PARM_DESC(i2c_slave_id, "sensor i2c slave id"); - -#define SENSOR_DRV_ENTRY_IMPL_END(Name,LinearEntry,HdrSefEntry,HdrLefEntry) \ -static int __init Name##_init_driver(void)\ -{\ - int nCamID=0;\ - void* p0 = LinearEntry;\ - void* p1 = HdrSefEntry;\ - void* p2 = HdrLefEntry;\ - if(DrvSensorHandleVer(CUS_CAMSENSOR_HANDLE_MAJ_VER, CUS_CAMSENSOR_HANDLE_MIN_VER)==FAIL)\ - return FAIL;\ - if(DrvSensorIFVer(CUS_CAMSENSORIF_MAJ_VER, CUS_CAMSENSORIF_MIN_VER)==FAIL)\ - return FAIL;\ - if(DrvSensorI2CVer(CUS_CAMSENSOR_I2C_MAJ_VER, CUS_CAMSENSOR_I2C_MIN_VER)==FAIL)\ - return FAIL;\ - for(nCamID=0;nCamID<4;++nCamID)\ - {\ - if((chmap>>nCamID)&0x1)\ - {\ - if(p0){ DrvRegisterSensorDriver(nCamID, LinearEntry);\ - DrvRegisterSensorI2CSlaveID(nCamID, (i2c_slave_id>>(nCamID*8))&0xFF);\ - pr_info("Connect %s linear to sensor pad %d\n",__FUNCTION__, nCamID);\ - }\ - if(p1){ DrvRegisterPlaneDriver(nCamID, 1, HdrSefEntry);\ - DrvRegisterPlaneI2CSlaveID(nCamID, 1, (i2c_slave_id>>(nCamID*8))&0xFF);\ - pr_info("Connect %s SEF to vif sensor pad %d\n",__FUNCTION__, nCamID);\ - }\ - if(p2){ DrvRegisterPlaneDriver(nCamID, 0, HdrLefEntry);\ - DrvRegisterPlaneI2CSlaveID(nCamID, 0, (i2c_slave_id>>(nCamID*8))&0xFF);\ - pr_info("Connect %s LEF to sensor pad %d\n",__FUNCTION__, nCamID);\ - }\ - }\ - }\ - return 0;\ -}\ -static void __exit Name##_exit_driver(void)\ -{\ - pr_info("sensordrv exit");\ -}\ -subsys_initcall(Name##_init_driver);\ -module_exit(Name##_exit_driver);\ -MODULE_DESCRIPTION("Sensor_"#Name);\ -MODULE_AUTHOR("SigmaStar");\ -MODULE_LICENSE("Proprietary"); - -#define SENSOR_DRV_PARAM_MCLK() (mclk) -#define SENSOR_USLEEP_(us) CamOsUsSleep(us) -#define SENSOR_MSLEEP_(ms) CamOsMsSleep(ms) - -/*Extension version*/ -#define SENSOR_DRV_ENTRY_IMPL_BEGIN_EX(Name) SENSOR_DRV_ENTRY_IMPL_BEGIN(Name) - -#define MAX_CAMID_LEN 4 -#define SENSOR_DRV_ENTRY_IMPL_END_EX(Name,LinearEntry,HdrSefEntry,HdrLefEntry,PrivateDataType) \ -static PrivateDataType* g_pData[2][MAX_CAMID_LEN] = {{0,0,0,0}, {0,0,0,0}};\ -static int __init Name##_init_driver(void)\ -{\ - int nCamID=0;\ - void* p0 = LinearEntry;\ - void* p1 = HdrSefEntry;\ - void* p2 = HdrLefEntry;\ - if(DrvSensorHandleVer(CUS_CAMSENSOR_HANDLE_MAJ_VER, CUS_CAMSENSOR_HANDLE_MIN_VER)==FAIL)\ - return FAIL;\ - if(DrvSensorIFVer(CUS_CAMSENSORIF_MAJ_VER, CUS_CAMSENSORIF_MIN_VER)==FAIL)\ - return FAIL;\ - if(DrvSensorI2CVer(CUS_CAMSENSOR_I2C_MAJ_VER, CUS_CAMSENSOR_I2C_MIN_VER)==FAIL)\ - return FAIL;\ - for(nCamID=0;nCamID>nCamID)&0x1)\ - {\ - if(p0){\ - void* pData = CamOsMemAlloc(sizeof(PrivateDataType));\ - memset(pData,0,sizeof(PrivateDataType));\ - DrvRegisterSensorDriverEx(nCamID, LinearEntry,pData);\ - DrvRegisterSensorI2CSlaveID(nCamID, (i2c_slave_id>>(nCamID*8))&0xFF);\ - pr_info("Connect %s linear to sensor pad %d\n",__FUNCTION__, nCamID);\ - g_pData[0][nCamID] = pData;\ - }\ - if(p1||p2){\ - void* pData = CamOsMemAlloc(sizeof(PrivateDataType));\ - memset(pData,0,sizeof(PrivateDataType));\ - if(p1){\ - DrvRegisterPlaneDriverEx(nCamID, 1, HdrSefEntry,pData);\ - DrvRegisterPlaneI2CSlaveID(nCamID, 1, (i2c_slave_id>>(nCamID*8))&0xFF);\ - pr_info("Connect %s SEF to vif sensor pad %d\n",__FUNCTION__, nCamID);\ - }\ - if(p2){\ - DrvRegisterPlaneDriverEx(nCamID, 0, HdrLefEntry,pData);\ - DrvRegisterPlaneI2CSlaveID(nCamID, 0, (i2c_slave_id>>(nCamID*8))&0xFF);\ - pr_info("Connect %s LEF to sensor pad %d\n",__FUNCTION__, nCamID);\ - }\ - g_pData[1][nCamID] = pData;\ - }\ - }\ - }\ - return 0;\ -}\ -static void __exit Name##_exit_driver(void)\ -{\ - int nCamID=0;\ - for(nCamID=0;nCamID>nCamID)&0x1)\ - {\ - if(g_pData[0][nCamID] || g_pData[1][nCamID])\ - {\ - DrvUnregisterSensorDriverEx(nCamID);\ - if(g_pData[0][nCamID]){\ - CamOsMemRelease((void*)g_pData[0][nCamID]);\ - g_pData[0][nCamID] = 0;\ - }\ - if(g_pData[1][nCamID]){\ - CamOsMemRelease((void*)g_pData[1][nCamID]);\ - g_pData[1][nCamID] = 0;\ - }\ - }\ - }\ - }\ -}\ -subsys_initcall(Name##_init_driver);\ -module_exit(Name##_exit_driver);\ -MODULE_DESCRIPTION("Sensor_"#Name);\ -MODULE_AUTHOR("SigmaStar");\ -MODULE_LICENSE("Proprietary"); - -//define 3 ch AHD application impl -#define SENSOR_DRV_ENTRY_3CHAHD_IMPL_END_EX(Name,LinearEntry,AhdCh0Entry,AhdCh1Entry, AhdCh2Entry,PrivateDataType)\ -static PrivateDataType* g_pData[2][MAX_CAMID_LEN] = {{0,0,0,0}, {0,0,0,0}};\ -static int __init Name##_init_driver(void)\ -{\ - int nCamID=0;\ - void* p0 = LinearEntry;\ - void* p1 = AhdCh0Entry;\ - void* p2 = AhdCh1Entry;\ - void* p3 = AhdCh2Entry;\ - if(DrvSensorHandleVer(CUS_CAMSENSOR_HANDLE_MAJ_VER, CUS_CAMSENSOR_HANDLE_MIN_VER)==FAIL)\ - return FAIL;\ - if(DrvSensorIFVer(CUS_CAMSENSORIF_MAJ_VER, CUS_CAMSENSORIF_MIN_VER)==FAIL)\ - return FAIL;\ - if(DrvSensorI2CVer(CUS_CAMSENSOR_I2C_MAJ_VER, CUS_CAMSENSOR_I2C_MIN_VER)==FAIL)\ - return FAIL;\ - for(nCamID=0;nCamID>nCamID)&0x1)\ - {\ - if(p0){\ - void* pData = CamOsMemAlloc(sizeof(PrivateDataType));\ - memset(pData,0,sizeof(PrivateDataType));\ - DrvRegisterSensorDriverEx(nCamID, LinearEntry,pData);\ - DrvRegisterSensorI2CSlaveID(nCamID, (i2c_slave_id>>(nCamID*8))&0xFF);\ - pr_info("Connect %s linear to sensor pad %d\n",__FUNCTION__, nCamID);\ - g_pData[0][nCamID] = pData;\ - }\ - if(p1||p2||p3){\ - void* pData = CamOsMemAlloc(sizeof(PrivateDataType));\ - memset(pData,0,sizeof(PrivateDataType));\ - if(p1){\ - DrvRegisterPlaneDriverEx(nCamID, 0, AhdCh0Entry,pData);\ - DrvRegisterPlaneI2CSlaveID(nCamID, 0, (i2c_slave_id>>(nCamID*8))&0xFF);\ - pr_info("Connect %s AHD0 to vif sensor pad %d\n",__FUNCTION__, nCamID);\ - }\ - if(p2){\ - DrvRegisterPlaneDriverEx(nCamID, 1, AhdCh1Entry,pData);\ - DrvRegisterPlaneI2CSlaveID(nCamID, 1, (i2c_slave_id>>(nCamID*8))&0xFF);\ - pr_info("Connect %s AHD1 to sensor pad %d\n",__FUNCTION__, nCamID);\ - }\ - if(p3){\ - DrvRegisterPlaneDriverEx(nCamID, 2, AhdCh2Entry,pData);\ - DrvRegisterPlaneI2CSlaveID(nCamID, 2, (i2c_slave_id>>(nCamID*8))&0xFF);\ - pr_info("Connect %s AHD2 to sensor pad %d\n",__FUNCTION__, nCamID);\ - }\ - g_pData[1][nCamID] = pData;\ - }\ - }\ - }\ - return 0;\ -}\ -static void __exit Name##_exit_driver(void)\ -{\ - int nCamID=0;\ - for(nCamID=0;nCamID>nCamID)&0x1)\ - {\ - if(g_pData[0][nCamID] || g_pData[1][nCamID])\ - {\ - DrvUnregisterSensorDriverEx(nCamID);\ - if(g_pData[0][nCamID]){\ - CamOsMemRelease((void*)g_pData[0][nCamID]);\ - g_pData[0][nCamID] = 0;\ - }\ - if(g_pData[1][nCamID]){\ - CamOsMemRelease((void*)g_pData[1][nCamID]);\ - g_pData[1][nCamID] = 0;\ - }\ - }\ - }\ - }\ -}\ -subsys_initcall(Name##_init_driver);\ -module_exit(Name##_exit_driver);\ -MODULE_DESCRIPTION("Sensor_"#Name);\ -MODULE_AUTHOR("SigmaStar");\ -MODULE_LICENSE("Proprietary"); - -#endif //end of CAM_OS_LINUX_KERNEL - - -#endif //endif _SENSOR_OS_WRAPPER_H_ diff --git a/general/package/sigmastar-osdrv-sensor/src/infinity6e/include/drv_sensor_init_table.h b/general/package/sigmastar-osdrv-sensor/src/infinity6e/include/drv_sensor_init_table.h deleted file mode 100644 index 10368d9e..00000000 --- a/general/package/sigmastar-osdrv-sensor/src/infinity6e/include/drv_sensor_init_table.h +++ /dev/null @@ -1,114 +0,0 @@ -/* Copyright (c) 2018-2019 Sigmastar Technology Corp. - All rights reserved. - - Unless otherwise stipulated in writing, any and all information contained -herein regardless in any format shall remain the sole proprietary of -Sigmastar Technology Corp. and be kept in strict confidence -(Sigmastar Confidential Information) by the recipient. -Any unauthorized act including without limitation unauthorized disclosure, -copying, use, reproduction, sale, distribution, modification, disassembling, -reverse engineering and compiling of the contents of Sigmastar Confidential -Information is unlawful and strictly prohibited. Sigmastar hereby reserves the -rights to any and all damages, losses, costs and expenses resulting therefrom. -*/ - -#ifndef _DRV_SENSOR_INIT_H_ -#define _DRV_SENSOR_INIT_H_ - -//#define SENSOR_INIT_CMDQ_MODE -#define SENSOR_INIT_DRV_MODE - -/* for sensor driver */ -#define I2C_1A1B_W(reg,val) {(reg),(val)} -#define CMDQ_DELAY_MS(ms) {(0xFFFF),(ms)} - -#define I2CM_1A1D_W(slave_addr,reg,val) \ - {(reg),(val)} - -#define I2CM_1A1D_W_BURST2(slave_addr,reg,d0,d1) \ - {(reg),(d0)},\ - {(reg)+1,(d1)} - -#define I2CM_1A1D_W_BURST3(slave_addr,reg,d0,d1,d2) \ - {(reg),(d0)},\ - {(reg)+1,(d1)},\ - {(reg)+2,(d2)} - -#define I2CM_1A1D_W_BURST4(slave_addr,reg,d0,d1,d2,d3) \ - {(reg),(d0)},\ - {(reg)+1,(d1)},\ - {(reg)+2,(d2)},\ - {(reg)+3,(d3)} - -#define I2CM_1A1D_W_BURST5(slave_addr,reg,d0,d1,d2,d3,d4) \ - {(reg),(d0)},\ - {(reg)+1,(d1)},\ - {(reg)+2,(d2)},\ - {(reg)+3,(d3)},\ - {(reg)+4,(d4)} - -#define I2CM_1A1D_W_BURST6(slave_addr,reg,d0,d1,d2,d3,d4,d5) \ - {(reg),(d0)},\ - {(reg)+1,(d1)},\ - {(reg)+2,(d2)},\ - {(reg)+3,(d3)},\ - {(reg)+4,(d4)},\ - {(reg)+5,(d5)} - -#define I2CM_1A1D_W_BURST7(slave_addr,reg,d0,d1,d2,d3,d4,d5,d6) \ - {(reg),(d0)},\ - {(reg)+1,(d1)},\ - {(reg)+2,(d2)},\ - {(reg)+3,(d3)},\ - {(reg)+4,(d4)},\ - {(reg)+5,(d5)},\ - {(reg)+6,(d6)} - -#define I2CM_2A1D_W(slave_addr,reg,val) \ - {(reg),(val)} - -#define I2CM_2A1D_W_BURST2(slave_addr,reg,d0,d1) \ - {(reg),(d0)},\ - {(reg)+1,(d1)} - -#define I2CM_2A1D_W_BURST3(slave_addr,reg,d0,d1,d2) \ - {(reg),(d0)},\ - {(reg)+1,(d1)},\ - {(reg)+2,(d2)} - -#define I2CM_2A1D_W_BURST4(slave_addr,reg,d0,d1,d2,d3) \ - {(reg),(d0)},\ - {(reg)+1,(d1)},\ - {(reg)+2,(d2)},\ - {(reg)+3,(d3)} - -#define I2CM_2A1D_W_BURST5(slave_addr,reg,d0,d1,d2,d3,d4) \ - {(reg),(d0)},\ - {(reg)+1,(d1)},\ - {(reg)+2,(d2)},\ - {(reg)+3,(d3)},\ - {(reg)+4,(d4)} - -#define I2CM_2A1D_W_BURST6(slave_addr,reg,d0,d1,d2,d3,d4,d5) \ - {(reg),(d0)},\ - {(reg)+1,(d1)},\ - {(reg)+2,(d2)},\ - {(reg)+3,(d3)},\ - {(reg)+4,(d4)},\ - {(reg)+5,(d5)} - -#define I2CM_2A2D_W(slave_addr,reg,val) \ - {(reg),(val)} - -#define I2CM_2A2D_W_BURST2(slave_addr,reg,d0,d1) \ - {(reg),(d0)},\ - {(reg)+1,(d1)} - -#define I2CM_2A2D_W_BURST3(slave_addr,reg,d0,d1,d2) \ - {(reg),(d0)},\ - {(reg)+1,(d1)},\ - {(reg)+2,(d2)} - -#define SENSOR_INIT_TABLE I2C_ARRAY - -#endif diff --git a/general/package/sigmastar-osdrv-sensor/src/infinity6e/include/sensor_i2c_api.h b/general/package/sigmastar-osdrv-sensor/src/infinity6e/include/sensor_i2c_api.h deleted file mode 100644 index 4de7027c..00000000 --- a/general/package/sigmastar-osdrv-sensor/src/infinity6e/include/sensor_i2c_api.h +++ /dev/null @@ -1,168 +0,0 @@ -/* Copyright (c) 2018-2019 Sigmastar Technology Corp. - All rights reserved. - - Unless otherwise stipulated in writing, any and all information contained -herein regardless in any format shall remain the sole proprietary of -Sigmastar Technology Corp. and be kept in strict confidence -(Sigmastar Confidential Information) by the recipient. -Any unauthorized act including without limitation unauthorized disclosure, -copying, use, reproduction, sale, distribution, modification, disassembling, -reverse engineering and compiling of the contents of Sigmastar Confidential -Information is unlawful and strictly prohibited. Sigmastar hereby reserves the -rights to any and all damages, losses, costs and expenses resulting therefrom. -*/ - -/*! @file isp_i2c_api.h - @brief This file contains Infinity ISP I2C basic API. -*/ - -/** @defgroup group1 ISP I2C API -* @{ -*/ -#ifndef ISP_I2C_API_H -#define ISP_I2C_API_H - -#define SENSOR_I2C_SUCCESS (0) -#define SENSOR_I2C_FAIL (-1) -#define SENSOR_I2C_NOT_SUPPORT (-2) - -/**@brief handle version info */ -typedef struct _version_info{ - u16 major; - u16 minor; -}__attribute__((packed, aligned(1))) version_info; - -/*! @brief I2C API handle.*/ -struct __i2c_handle_t; - -/*! @brief I2C batch read/write data.*/ -typedef struct _I2C_ARRAY{ - u16 reg; /**< Register address.*/ - u16 data; /**< Data.*/ -} I2C_ARRAY; - -/*! @brief I2C burst read/write data.*/ -typedef struct _I2C_ARRAY_BURST{ - u16 reg; /**< Register address.*/ - u16 *data; /**< Data.*/ -} I2C_ARRAY_BURST; - -/*! @brief I2C data direction*/ -typedef enum { - I2C_RW_R, /**< Data direction read.*/ - I2C_RW_W,/**< Data direction write.*/ -} I2C_RW; - -/*! @brief Use for i2c_array_rw only */ -typedef struct _I2C_CPX_ARRAY{ - I2C_RW rw; /**< Data direction */ - u16 reg; /**< Device register address */ - u16 data; /**< Data write to device or read from device*/ -}__attribute__((packed, aligned(1))) I2C_CPX_ARRAY; - -/*! @brief Internal use for I2C API*/ -typedef enum { - I2C_FMT_A8D8, /**< 8 bits Address, 8 bits Data */ - I2C_FMT_A16D8,/**< 16 bits Address 8 bits Data */ - I2C_FMT_A8D16,/**< 8 bits Address 16 bits Data */ - I2C_FMT_A16D16,/**< 16 bits Address 16 bits Data */ - I2C_FMT_END/**< Reserved */ -} ISP_I2C_FMT; - -/*! @brief ISP_I2C_MODE Internal use for I2C API*/ -typedef enum { - I2C_LEGACY_MODE, /**< Do not use */ - I2C_NORMAL_MODE /**< Sensor driver can only use I2C_NORMAL_MODE */ -} ISP_I2C_MODE; - - -/*! @brief app_i2c_cfg I2C setting for sensor and bus.*/ -typedef struct _app_i2c_cfg{ - ISP_I2C_MODE mode; //!< I2C_NORMAL_MODE only - ISP_I2C_FMT fmt; //!< I2C data format - u32 speed; //!< I2C clock in Hz - u16 address; //!< Sensor slave address , bit[7~1] are available, bit[0] user don't care - u16 reserved; -}__attribute__((packed, aligned(1))) app_i2c_cfg; - -/*! @brief The interface of I2C APIs export to user*/ -typedef struct _i2c_handle_t { - //int version; - version_info version; - void *pdata; //i2c_private_data - - u32 nSensorID; - /** @brief Open isp i2c port. This function must be called before using isp I2C APIs. - Call i2c_close to close isp i2c port and allocated resource. - @param[in] handle Handle to isp i2c api. - @param[in] cfg I2C initial configuration. - @retval SENSOR_I2C_SUCCESS or SENSOR_I2C_FAIL if error occurs. - */ - int (*i2c_open)(struct _i2c_handle_t* handle, app_i2c_cfg *cfg); - - /** @brief Close isp I2C port. Call this functon to release resource which allocated form i2c_open. - @param[in] handle Handle to isp i2c api. - @param[in] cfg I2C configuration mode and spped are necessary in this stage. - @retval SENSOR_I2C_SUCCESS or SENSOR_I2C_FAIL if error occurs. - */ - int (*i2c_close)(struct _i2c_handle_t* handle ); - - /** @brief Write single data to device. - @param[in] handle Handle to isp i2c api. - @param[in] cfg I2C config, fmd and address are necessary in this stage. - @param[in] reg Device register address address width depend on cfg->fmt. - @param[in] data Data to write, data width depend on cfg->fmt. - @retval SENSOR_I2C_SUCCESS or SENSOR_I2C_FAIL if error occurs. - */ - int (*i2c_tx)(struct _i2c_handle_t* handle , app_i2c_cfg *cfg, u16 reg, u16 data); - - /** @brief Read single data from device. - @param[in] handle Handle to isp i2c api. - @param[in] cfg I2C config, fmd and address are necessary in this stage. - @param[in] reg Device register address address width depend on cfg->fmt. - @param[out] data Data buffer for read, data width depend on cfg->fmt. - @retval SENSOR_I2C_SUCCESS or SENSOR_I2C_FAIL if error occurs. - */ - int (*i2c_rx)(struct _i2c_handle_t* handle, app_i2c_cfg *cfg, u16 reg, volatile u16 *data); - - /** @brief Batch write to device. - @param[in] handle Handle to isp i2c api. - @param[in] cfg I2C config, fmd and address are necessary in this stage. - @param[in] pdata Data array. - @param[in] len Array size. - @retval SENSOR_I2C_SUCCESS or SENSOR_I2C_FAIL if error occurs. - */ - int (*i2c_array_tx)(struct _i2c_handle_t* handle, app_i2c_cfg *cfg, I2C_ARRAY *pdata, u32 len); - - /** @brief Burst write to device. - @param[in] handle Handle to isp i2c api. - @param[in] cfg I2C config, fmd and address are necessary in this stage. - @param[in] pdata Data array. - @param[in] len Array size. - @retval SENSOR_I2C_SUCCESS or SENSOR_I2C_FAIL if error occurs. - */ - int (*i2c_burst_tx)(struct _i2c_handle_t* handle, app_i2c_cfg *cfg, I2C_ARRAY_BURST *pdata, u32 len); - - int (*i2c_burst_rx)(struct _i2c_handle_t* handle, app_i2c_cfg *cfg, I2C_ARRAY_BURST *pdata, u32 len); - /** @brief Batch read from device. - @param[in] handle Handle to isp i2c api. - @param[in] cfg I2C config, fmd and address are necessary in this stage. - @param[out] pdata Data array. - @param[in] len Array size. - @retval SENSOR_I2C_SUCCESS or SENSOR_I2C_FAIL if error occurs. - */ - int (*i2c_array_rx)(struct _i2c_handle_t* handle, app_i2c_cfg *cfg, I2C_ARRAY *pdata, u32 len); - - /** @brief Composite batch read/write - @param[in] handle Handle to isp i2c api. - @param[in] cfg I2C config, fmd and address are necessary in this stage. - @param[in][out] pdata Data description array. - @param[in] len Array size. - @retval SENSOR_I2C_SUCCESS or SENSOR_I2C_FAIL if error occurs. - */ - int (*i2c_array_rw)(struct _i2c_handle_t* handle, app_i2c_cfg *cfg, I2C_CPX_ARRAY *pdata, u32 len); -} i2c_handle_t; - -/** @} */ // end of ISP I2C API - -#endif diff --git a/general/package/sigmastar-osdrv-sensor/src/infinity6e/sensor/sensor_imx274_mipi.c b/general/package/sigmastar-osdrv-sensor/src/infinity6e/sensor/sensor_imx274_mipi.c deleted file mode 100644 index ae86d60a..00000000 --- a/general/package/sigmastar-osdrv-sensor/src/infinity6e/sensor/sensor_imx274_mipi.c +++ /dev/null @@ -1,4112 +0,0 @@ -/* Copyright (c) 2018-2019 Sigmastar Technology Corp. - All rights reserved. - - Unless otherwise stipulated in writing, any and all information contained -herein regardless in any format shall remain the sole proprietary of -Sigmastar Technology Corp. and be kept in strict confidence -(Sigmastar Confidential Information) by the recipient. -Any unauthorized act including without limitation unauthorized disclosure, -copying, use, reproduction, sale, distribution, modification, disassembling, -reverse engineering and compiling of the contents of Sigmastar Confidential -Information is unlawful and strictly prohibited. Sigmastar hereby reserves the -rights to any and all damages, losses, costs and expenses resulting therefrom. -*/ - -#ifdef __cplusplus -extern "C" -{ -#endif - -#include -#include -#include - -#ifdef __cplusplus -} -#endif - -SENSOR_DRV_ENTRY_IMPL_BEGIN_EX(IMX274_HDR); - -#define SENSOR_CHANNEL_NUM (0) -#define SENSOR_CHANNEL_MODE_LINEAR CUS_SENSOR_CHANNEL_MODE_REALTIME_NORMAL -#define SENSOR_CHANNEL_MODE_SONY_DOL CUS_SENSOR_CHANNEL_MODE_RAW_STORE_HDR - -//============================================ -//MIPI config begin. -#define SENSOR_MIPI_LANE_NUM (4) -//#define SENSOR_MIPI_HDR_MODE (1) //0: Non-HDR mode. 1:Sony DOL mode -//MIPI config end. -//============================================ - -#define R_GAIN_REG 1 -#define G_GAIN_REG 2 -#define B_GAIN_REG 3 - -//#undef SENSOR_DBG -//#define SENSOR_DBG 0 - -/////////////////////////////////////////////////////////////// -// @@@ // -// @ @@ == S t a r t * H e r e == // -// @@ == S t a r t * H e r e == // -// @@ == S t a r t * H e r e == // -// @@@@ // -// // -// Start Step 1 -- show preview on LCM // -// �@// -// Fill these #define value and table with correct settings // -// camera can work and show preview on LCM // -// // -/////////////////////////////////////////////////////////////// - - -#define SENSOR_ISP_TYPE ISP_EXT //ISP_EXT, ISP_SOC -#define F_number 22 // CFG, demo module -//#define SENSOR_DATAFMT CUS_DATAFMT_BAYER //CUS_DATAFMT_YUV, CUS_DATAFMT_BAYER -#define SENSOR_IFBUS_TYPE CUS_SENIF_BUS_MIPI //CFG //CUS_SENIF_BUS_PARL, CUS_SENIF_BUS_MIPI -#define SENSOR_MIPI_HSYNC_MODE PACKET_HEADER_EDGE1 -#define SENSOR_MIPI_HSYNC_MODE_HDR_DOL PACKET_FOOTER_EDGE -#define SENSOR_DATAPREC CUS_DATAPRECISION_12 //CFG //CUS_DATAPRECISION_8, CUS_DATAPRECISION_10 -#define SENSOR_DATAPREC_HDR_DOL CUS_DATAPRECISION_10 -#define SENSOR_DATAMODE CUS_SEN_10TO12_9098 //CFG -#define SENSOR_BAYERID CUS_BAYER_RG //CFG //CUS_BAYER_GB, CUS_BAYER_GR, CUS_BAYER_BG, CUS_BAYER_RG -#define SENSOR_BAYERID_HDR_DOL CUS_BAYER_RG//CUS_BAYER_GR -#define SENSOR_RGBIRID CUS_RGBIR_NONE -#define SENSOR_ORIT CUS_ORIT_M0F0 //CUS_ORIT_M0F0, CUS_ORIT_M1F0, CUS_ORIT_M0F1, CUS_ORIT_M1F1, -//#define SENSOR_YCORDER CUS_SEN_YCODR_YC //CUS_SEN_YCODR_YC, CUS_SEN_YCODR_CY -//#define SENSOR_MAX_GAIN 350 // max sensor again, a-gain * conversion-gain*d-gain//51db -//#define SENSOR_MAX_GAIN 22.5 // max sensor again, a-gain * conversion-gain*d-gain*expand gain//63db -#define SENSOR_MAX_GAIN (1412 * 1024) -#define SENSOR_MIN_GAIN (1 * 1024) -#define lane_number 4 -#define vc0_hs_mode 3 //0: packet header edge 1: line end edge 2: line start edge 3: packet footer edge -#define long_packet_type_enable 0x00 //UD1~UD8 (user define) - -#define Preview_MCLK_SPEED CUS_CMU_CLK_24MHZ //CFG //CUS_CMU_CLK_12M, CUS_CMU_CLK_16M, CUS_CMU_CLK_24M, CUS_CMU_CLK_27M -#define Preview_MCLK_SPEED_HDR_DOL CUS_CMU_CLK_24MHZ - -u32 Preview_line_period; -u32 vts_30fps; - -u32 Preview_line_period_HDR_DOL; -u32 vts_30fps_HDR_DOL; - -#define Preview_WIDTH 3840 //resolution Width when preview -#define Preview_HEIGHT 2160 //resolution Height when preview -#define Preview_MAX_FPS 15 //fastest preview FPS -#define Preview_MIN_FPS 3 //slowest preview FPS - -#define SENSOR_I2C_ADDR 0x34 //I2C slave address -#define SENSOR_I2C_SPEED 200000 //300000// 240000 //I2C speed, 60000~320000 - -#define SENSOR_I2C_LEGACY I2C_NORMAL_MODE //usally set CUS_I2C_NORMAL_MODE, if use old OVT I2C protocol=> set CUS_I2C_LEGACY_MODE -#define SENSOR_I2C_FMT I2C_FMT_A16D8 //CUS_I2C_FMT_A8D8, CUS_I2C_FMT_A8D16, CUS_I2C_FMT_A16D8, CUS_I2C_FMT_A16D16 - -#define SENSOR_PWDN_POL CUS_CLK_POL_NEG // if PWDN pin High can makes sensor in power down, set CUS_CLK_POL_POS -#define SENSOR_RST_POL CUS_CLK_POL_NEG // if RESET pin High can makes sensor in reset state, set CUS_CLK_POL_NEG - -// VSYNC/HSYNC POL can be found in data sheet timing diagram, -// Notice: the initial setting may contain VSYNC/HSYNC POL inverse settings so that condition is different. - -#define SENSOR_VSYNC_POL CUS_CLK_POL_NEG // if VSYNC pin High and data bus have data, set CUS_CLK_POL_POS -#define SENSOR_HSYNC_POL CUS_CLK_POL_NEG // if HSYNC pin High and data bus have data, set CUS_CLK_POL_POS -#define SENSOR_PCLK_POL CUS_CLK_POL_NEG // depend on sensor setting, sometimes need to try CUS_CLK_POL_POS or CUS_CLK_POL_NEG -//static int drv_Fnumber = 22; - -#define Preview_CROP_START_X 0 //CROP_START_X -#define Preview_CROP_START_Y 0 //CROP_START_Y -#define Preview_CROP_START_Y_DOL 8 -static int pCus_SetAEGain(ms_cus_sensor *handle, u32 gain); -static int pCus_SetAEUSecs(ms_cus_sensor *handle, u32 us); -static int pCus_SetOrien(ms_cus_sensor *handle, CUS_CAMSENSOR_ORIT orit); -static int pCus_SetAEUSecsHDR_DOL_SEF(ms_cus_sensor *handle, u32 us); -static int pCus_SetAEUSecsHDR_DOL_SEF_Binning(ms_cus_sensor *handle, u32 us); - -CUS_CAMSENSOR_CAP sensor_cap = { - .length = sizeof(CUS_CAMSENSOR_CAP), - .version = 0x0001, -}; - -typedef struct { - struct { - u16 pre_div0; - u16 div124; - u16 div_cnt7b; - u16 sdiv0; - u16 mipi_div0; - u16 r_divp; - u16 sdiv1; - u16 r_seld5; - u16 r_sclk_dac; - u16 sys_sel; - u16 pdac_sel; - u16 adac_sel; - u16 pre_div_sp; - u16 r_div_sp; - u16 div_cnt5b; - u16 sdiv_sp; - u16 div12_sp; - u16 mipi_lane_sel; - u16 div_dac; - } clk_tree; - struct { - bool bVideoMode; - u16 res_idx; - // bool binning; - // bool scaling; - CUS_CAMSENSOR_ORIT orit; - } res; - struct { - float sclk; - u32 hts; - u32 vts; - u32 ho; - u32 xinc; - u32 line_freq; - u32 us_per_line; - u32 final_us; - u32 final_gain; - u32 back_pv_us; - u32 fps; - u32 preview_fps; - u32 expo_lef_us; - u32 expo_sef_us; - } expo; - - int sen_init; - int still_min_fps; - int video_min_fps; - bool dirty; - I2C_ARRAY vwinpos_nor[2]; //normal - I2C_ARRAY vwinpos_inv[2]; //inverted - I2C_ARRAY tVts_reg[3]; - I2C_ARRAY tGain_reg[3]; - I2C_ARRAY tExpo_reg[2]; - I2C_ARRAY tExpo_shr_dol1_reg[2]; - I2C_ARRAY tExpo_rhs1_reg[2]; - I2C_ARRAY tExpo_shr_dol2_reg[2]; - CUS_CAMSENSOR_ORIT cur_orien; - int vts_to_rhs1; -} imx274_params; -// set sensor ID address and data, - -const I2C_ARRAY Sensor_id_table[] = -{ - {0x3004, 0x03}, // {address of ID, ID }, - {0x3005, 0x31}, -}; - -const I2C_ARRAY Sensor_init_table_HDR_DOL_4lane_4k15fps[] = -{ -#if 1 //DOL mode, MIPI clock 720M, VMAX 2310 @15fps - {0x3000, 0x12}, //standby - {0x3120, 0xF0}, - {0x3121, 0x00}, - {0x3122, 0x02}, - {0x3123, 0x01},// - {0x3129, 0x9C}, - {0x312a, 0x02}, - {0x312d, 0x02}, - {0x3ac4, 0x01},// - {0x310b, 0x00}, - {0x304c, 0x00}, - {0x304d, 0x03}, - {0x331c, 0x1a}, - {0x331d, 0x00}, - {0x3502, 0x02}, - {0x3529, 0x0e}, - {0x352a, 0x0e}, - {0x352b, 0x0e}, - {0x3538, 0x0e}, - {0x3539, 0x0e}, - {0x3553, 0x00}, - {0x357d, 0x05}, - {0x357f, 0x05}, - {0x3581, 0x04}, - {0x3583, 0x76}, - {0x3587, 0x01}, - {0x35bb, 0x0e}, - {0x35bc, 0x0e}, - {0x35bd, 0x0e}, - {0x35be, 0x0e}, - {0x35bf, 0x0e}, - {0x366e, 0x00}, - {0x366f, 0x00}, - {0x3670, 0x00}, - {0x3671, 0x00}, - {0x30ee, 0x01}, - {0x3304, 0x32}, - {0x3305, 0x00}, - {0x3306, 0x32}, - {0x3307, 0x00}, - {0x3590, 0x32}, - {0x3591, 0x00}, - {0x3686, 0x32}, - {0x3687, 0x00}, - {0x3134, 0x77}, - {0x3135, 0x00}, - {0x3136, 0x67}, - {0x3137, 0x00}, - {0x3138, 0x37}, - {0x3139, 0x00}, - {0x313a, 0x37}, - {0x313b, 0x00}, - {0x313c, 0x37}, - {0x313d, 0x00}, - {0x313e, 0xdf}, - {0x313f, 0x00}, - {0x3140, 0x37}, - {0x3141, 0x00}, - {0x3142, 0x2f}, - {0x3143, 0x00}, - {0x3144, 0x0f}, - {0x3145, 0x00}, - {0x3a86, 0x47}, - {0x3a87, 0x00}, -//mode registers 15fps - {0x3004, 0x06},//shutter and gain - {0x3005, 0x01}, - {0x3006, 0x00}, - {0x3007, 0x02}, - - {0x300E, 0x00}, - {0x300F, 0x00}, - {0x3019, 0x31}, - {0x301A, 0x00}, - {0x3032, 0x40}, - {0x3033, 0x00}, - - {0x3037, 0x00}, - {0x3038, 0x00}, - {0x3039, 0x00},//?? - {0x303a, 0x00}, - {0x303b, 0x00}, - - {0x3041, 0x31}, - {0x3042, 0x08}, - {0x3043, 0x02}, - - {0x306b, 0x05}, - {0x30dd, 0x00}, - {0x30de, 0x00}, - {0x30df, 0x00}, - {0x30e0, 0x00}, - {0x30e1, 0x00}, - {0x30e2, 0x01}, - {0x30e9, 0x01}, - - {0x30ee, 0x01}, - {0x30f6, 0x20},//HMAX - {0x30f7, 0x08}, - {0x30f8, 0x06},//VMAX - {0x30f9, 0x09}, - {0x30fa, 0x00},// - {0x3130, 0x86}, - {0x3131, 0x08}, - {0x3132, 0x00}, - {0x3133, 0x00}, - - {0x3342, 0x0a}, - {0x3343, 0x00}, - {0x3344, 0x16}, - {0x3345, 0x00}, - - {0x33a6, 0x01}, - {0x3528, 0x0e}, - {0x3554, 0x1f}, - {0x3555, 0x01}, - {0x3556, 0x01}, - {0x3557, 0x01}, - {0x3558, 0x01}, - {0x3559, 0x00}, - {0x355a, 0x00}, - {0x35ba, 0x0e}, - {0x366a, 0x1b}, - {0x366b, 0x1a}, - {0x366c, 0x19}, - {0x366d, 0x17}, - {0x3a41, 0x08}, - // {0x3045, 0x28},//black level - {0xffff, 0x0a},//delay >=10ms - - //{0x300a, 0x80},//analog gain yc add - // {0x300b, 0x00},//yc add - //{0x3012, 0x05},//digital gain - - //{0x300d, 0xff},//MSB - //{0x300c, 0x02}, - - {0x300c, 0x08},//yc add - {0x300d, 0x01},//yc add - - - //setting 2 - {0x3000, 0x00}, - {0x303e, 0x02},//?? - {0xffff, 0x07},//delay >=7ms - - // {0x303c, 0x11},//test pattern - // {0x303d, 0x0a}, - - //setting3 - - {0x30f4, 0x00}, - {0x3018, 0xa2}, - //{0xffff, 0x60},//delay >=96ms - //{0x312e, 0x01}, - //{0x3aa2, 0x01}, - - // {0x3001, 0x06}, // ?��?MIPI 2lane Mode Change -#endif -}; - -const I2C_ARRAY Sensor_init_table_HDR_DOL_4lane_4k20fps[] = -{ -#if 1 //DOL mode, MIPI clock 1152M, VMAX 2500 @20fps - {0x3000, 0x12}, //standby - {0x3120, 0xC0}, - {0x3121, 0x00}, - {0x3122, 0x02}, - - {0x3129, 0x9C}, - {0x312a, 0x02}, - {0x312d, 0x02}, - - {0x310b, 0x00}, - {0x304c, 0x00}, - {0x304d, 0x03}, - {0x331c, 0x1a}, - {0x331d, 0x00}, - {0x3502, 0x02}, - {0x3529, 0x0e}, - {0x352a, 0x0e}, - {0x352b, 0x0e}, - {0x3538, 0x0e}, - {0x3539, 0x0e}, - {0x3553, 0x00}, - {0x357d, 0x05}, - {0x357f, 0x05}, - {0x3581, 0x04}, - {0x3583, 0x76}, - {0x3587, 0x01}, - {0x35bb, 0x0e}, - {0x35bc, 0x0e}, - {0x35bd, 0x0e}, - {0x35be, 0x0e}, - {0x35bf, 0x0e}, - {0x366e, 0x00}, - {0x366f, 0x00}, - {0x3670, 0x00}, - {0x3671, 0x00}, - {0x30ee, 0x01}, - {0x3304, 0x32}, - {0x3305, 0x00}, - {0x3306, 0x32}, - {0x3307, 0x00}, - {0x3590, 0x32}, - {0x3591, 0x00}, - {0x3686, 0x32}, - {0x3687, 0x00}, - - {0x3134, 0x8f}, - {0x3135, 0x00}, - {0x3136, 0x87}, - {0x3137, 0x00}, - {0x3138, 0x57}, - {0x3139, 0x00}, - {0x313a, 0x4f}, - {0x313b, 0x00}, - {0x313c, 0x4f}, - {0x313d, 0x00}, - {0x313e, 0x3f}, - {0x313f, 0x01}, - {0x3140, 0x57}, - {0x3141, 0x00}, - {0x3142, 0x47}, - {0x3143, 0x00}, - {0x3144, 0x0f}, - {0x3145, 0x00}, - {0x3a86, 0x47}, - {0x3a87, 0x00}, - - {0x3004, 0x06},//shutter and gain - {0x3005, 0x01}, - {0x3006, 0x00}, - {0x3007, 0x02}, - - {0x300C, 0xE0},//yc add - {0x300D, 0x05},//yc add - - {0x300E, 0x00}, - {0x300F, 0x00}, - {0x3019, 0x31}, - {0x301A, 0x00}, - {0x3032, 0x40}, - {0x3033, 0x00}, - - {0x3037, 0x00}, - {0x3038, 0x00}, - {0x3039, 0x00},//?? - {0x303a, 0x00}, - {0x303b, 0x00}, - - {0x3041, 0x31}, - {0x3042, 0x68}, - {0x3043, 0x01}, - - {0x306b, 0x05}, - {0x30dd, 0x00}, - {0x30de, 0x00}, - {0x30df, 0x00}, - {0x30e0, 0x00}, - {0x30e1, 0x00}, - {0x30e2, 0x01}, - {0x30e9, 0x01}, - - {0x30ee, 0x01}, - {0x30f6, 0xa0},//HMAX - {0x30f7, 0x05}, - {0x30f8, 0xc4},//VMAX - {0x30f9, 0x09}, - {0x30fa, 0x00},// - {0x3130, 0x86}, - {0x3131, 0x08}, - {0x3132, 0x00}, - {0x3133, 0x00}, - - {0x3342, 0x0a}, - {0x3343, 0x00}, - {0x3344, 0x16}, - {0x3345, 0x00}, - - {0x33a6, 0x01}, - {0x3528, 0x0e}, - {0x3554, 0x1f}, - {0x3555, 0x01}, - {0x3556, 0x01}, - {0x3557, 0x01}, - {0x3558, 0x01}, - {0x3559, 0x00}, - {0x355a, 0x00}, - {0x35ba, 0x0e}, - {0x366a, 0x1b}, - {0x366b, 0x1a}, - {0x366c, 0x19}, - {0x366d, 0x17}, - {0x3a41, 0x08}, - {0xffff, 0x0a},//delay >=10ms - - //setting 2 - {0x3000, 0x00}, - {0x303e, 0x03},//?? - {0xffff, 0x07},//delay >=7ms - - //setting3 - {0x30f4, 0x00}, - {0x3018, 0xa2}, - -#endif -}; - -const I2C_ARRAY Sensor_init_table_HDR_DOL_4lane_4k30fps[] = -{ -#if 1 //DOL mode, MIPI clock 1440M, VMAX 2275 @30fps - {0x3000, 0x12}, //standby - {0x3120, 0xF0}, - {0x3121, 0x00}, - {0x3122, 0x02}, - {0x3129, 0x9C}, - {0x312a, 0x02}, - {0x312d, 0x02}, - {0x310b, 0x00}, - {0x304c, 0x00}, - {0x304d, 0x03}, - {0x331c, 0x1a}, - {0x331d, 0x00}, - {0x3502, 0x02}, - {0x3529, 0x0e}, - {0x352a, 0x0e}, - {0x352b, 0x0e}, - {0x3538, 0x0e}, - {0x3539, 0x0e}, - {0x3553, 0x00}, - {0x357d, 0x05}, - {0x357f, 0x05}, - {0x3581, 0x04}, - {0x3583, 0x76}, - {0x3587, 0x01}, - {0x35bb, 0x0e}, - {0x35bc, 0x0e}, - {0x35bd, 0x0e}, - {0x35be, 0x0e}, - {0x35bf, 0x0e}, - {0x366e, 0x00}, - {0x366f, 0x00}, - {0x3670, 0x00}, - {0x3671, 0x00}, - {0x30ee, 0x01}, - {0x3304, 0x32}, - {0x3305, 0x00}, - {0x3306, 0x32}, - {0x3307, 0x00}, - {0x3590, 0x32}, - {0x3591, 0x00}, - {0x3686, 0x32}, - {0x3687, 0x00}, - - {0x3134, 0xa7}, - {0x3135, 0x00}, - {0x3136, 0x9f}, - {0x3137, 0x00}, - {0x3138, 0x6f}, - {0x3139, 0x00}, - {0x313a, 0x5f}, - {0x313b, 0x00}, - {0x313c, 0x5f}, - {0x313d, 0x00}, - {0x313e, 0x7f}, - {0x313f, 0x01}, - {0x3140, 0x6f}, - {0x3141, 0x00}, - {0x3142, 0x4f}, - {0x3143, 0x00}, - {0x3144, 0x0f}, - {0x3145, 0x00}, - {0x3a86, 0x47}, - {0x3a87, 0x00}, - - {0x3004, 0x05},//shutter and gain - {0x3005, 0x01}, - {0x3006, 0x00}, - {0x3007, 0x02}, - - {0x300C, 0xFF}, - {0x300D, 0x07}, - - {0x300E, 0x00}, - {0x300F, 0x00}, - {0x3019, 0x31}, - {0x301A, 0x00}, - {0x3032, 0x40}, - {0x3033, 0x00}, - - {0x3037, 0x00}, - {0x3038, 0x00}, - {0x3039, 0x00},//?? - {0x303a, 0x00}, - {0x303b, 0x00}, - - {0x3041, 0x31}, - {0x3042, 0x07}, - {0x3043, 0x01}, - - {0x306b, 0x05}, - {0x30dd, 0x00}, - {0x30de, 0x00}, - {0x30df, 0x00}, - {0x30e0, 0x00}, - {0x30e1, 0x00}, - {0x30e2, 0x01}, - {0x30e9, 0x01}, - - {0x30ee, 0x01}, - {0x30f6, 0x20},//HMAX - {0x30f7, 0x04}, - {0x30f8, 0xe3},//VMAX - {0x30f9, 0x08}, - {0x30fa, 0x00},// - {0x3130, 0x86}, - {0x3131, 0x08}, - {0x3132, 0x7E}, - {0x3133, 0x08}, - - {0x3342, 0x0a}, - {0x3343, 0x00}, - {0x3344, 0x16}, - {0x3345, 0x00}, - - {0x33a6, 0x01}, - {0x3528, 0x0e}, - {0x3554, 0x1f}, - {0x3555, 0x01}, - {0x3556, 0x01}, - {0x3557, 0x01}, - {0x3558, 0x01}, - {0x3559, 0x00}, - {0x355a, 0x00}, - {0x35ba, 0x0e}, - {0x366a, 0x1b}, - {0x366b, 0x1a}, - {0x366c, 0x19}, - {0x366d, 0x17}, - {0x3a41, 0x08}, - {0xffff, 0x0a},//delay >=10ms - - //setting 2 - {0x3000, 0x00}, - {0x303e, 0x02},//?? - {0xffff, 0x07},//delay >=7ms - - //setting3 - {0x30f4, 0x00}, - {0x3018, 0xa2}, - -#endif -}; - - - -const I2C_ARRAY Sensor_init_table_HDR_DOL_4lane_2M30fps[] = -{ -#if 1 //H/V 2/2 line-binning DOL mode, MIPI clock 1152M, VMAX 2310 @30fps - {0x3000, 0x12}, //standby - {0x3120, 0xC0}, - {0x3121, 0x00}, - {0x3122, 0x02}, - {0x3129, 0x9C}, - {0x312a, 0x02}, - {0x312d, 0x02}, - {0x310b, 0x00}, - {0x304c, 0x00}, - {0x304d, 0x03}, - {0x331c, 0x1a}, - {0x331d, 0x00}, - {0x3502, 0x02}, - {0x3529, 0x0e}, - {0x352a, 0x0e}, - {0x352b, 0x0e}, - {0x3538, 0x0e}, - {0x3539, 0x0e}, - {0x3553, 0x00}, - {0x357d, 0x05}, - {0x357f, 0x05}, - {0x3581, 0x04}, - {0x3583, 0x76}, - {0x3587, 0x01}, - {0x35bb, 0x0e}, - {0x35bc, 0x0e}, - {0x35bd, 0x0e}, - {0x35be, 0x0e}, - {0x35bf, 0x0e}, - {0x366e, 0x00}, - {0x366f, 0x00}, - {0x3670, 0x00}, - {0x3671, 0x00}, - {0x30ee, 0x01}, - {0x3304, 0x32}, - {0x3305, 0x00}, - {0x3306, 0x32}, - {0x3307, 0x00}, - {0x3590, 0x32}, - {0x3591, 0x00}, - {0x3686, 0x32}, - {0x3687, 0x00}, - {0x3134, 0x8f}, - {0x3135, 0x00}, - {0x3136, 0x87}, - {0x3137, 0x00}, - {0x3138, 0x57}, - {0x3139, 0x00}, - {0x313a, 0x4f}, - {0x313b, 0x00}, - {0x313c, 0x4f}, - {0x313d, 0x00}, - {0x313e, 0x3f}, - {0x313f, 0x00}, - {0x3140, 0x57}, - {0x3141, 0x00}, - {0x3142, 0x47}, - {0x3143, 0x00}, - {0x3144, 0x0f}, - {0x3145, 0x00}, - {0x3a86, 0x47}, - {0x3a87, 0x00}, - -//mode registers 30fps - {0x3004, 0x07},//shutter and gain - {0x3005, 0x21}, - {0x3006, 0x00}, - {0x3007, 0x11}, - - {0x300C, 0x1F}, - {0x300D, 0x08}, - - {0x300E, 0x00}, - {0x300F, 0x00}, - {0x3019, 0x31}, - {0x301A, 0x00}, - {0x3032, 0x40}, - {0x3033, 0x00}, - - {0x3037, 0x00}, - {0x3038, 0x00}, - {0x3039, 0x00},//?? - {0x303a, 0x00}, - {0x303b, 0x00}, - - {0x3041, 0x31}, - {0x3042, 0x04}, - {0x3043, 0x01}, - - {0x306b, 0x05}, - {0x30dd, 0x00}, - {0x30de, 0x00}, - {0x30df, 0x00}, - {0x30e0, 0x00}, - {0x30e1, 0x00}, - {0x30e2, 0x02}, - {0x30e9, 0x01}, - - {0x30ee, 0x01}, - {0x30f6, 0x10},//HMAX[7:0] - {0x30f7, 0x04},//HMAX[15:8] - {0x30f8, 0x06},//VMAX[7:0] - {0x30f9, 0x09},//VMAX[15:8] - {0x30fa, 0x00},//VMAX[19:16] - {0x3130, 0x4e}, - {0x3131, 0x04}, - {0x3132, 0x00}, - {0x3133, 0x00}, - - {0x3342, 0x0a}, - {0x3343, 0x00}, - {0x3344, 0x1a}, - {0x3345, 0x00}, - - {0x33a6, 0x01}, - {0x3528, 0x0e}, - {0x3554, 0x00}, - {0x3555, 0x01}, - {0x3556, 0x01}, - {0x3557, 0x01}, - {0x3558, 0x01}, - {0x3559, 0x00}, - {0x355a, 0x00}, - {0x35ba, 0x0e}, - {0x366a, 0x1b}, - {0x366b, 0x1a}, - {0x366c, 0x19}, - {0x366d, 0x17}, - {0x3a41, 0x08}, - // {0x3045, 0x28},//black level - {0xffff, 0x0a},//delay >=10ms - - //{0x300a, 0x80},//analog gain yc add - // {0x300b, 0x00},//yc add - //{0x3012, 0x05},//digital gain - - //{0x300d, 0xff},//MSB - //{0x300c, 0x02}, - - //{0x300c, 0x08},//yc add - //{0x300d, 0x01},//yc add - - - //setting 2 - {0x3000, 0x00}, - {0x303e, 0x03},//?? - {0xffff, 0x07},//delay >=7ms - - // {0x303c, 0x11},//test pattern - // {0x303d, 0x0a}, - - //setting3 - - {0x30f4, 0x00}, - {0x3018, 0xa2}, - //{0xffff, 0x60},//delay >=96ms - //{0x312e, 0x01}, - //{0x3aa2, 0x01}, - - {0x3001, 0x10}, //terry -#endif -}; - - -const I2C_ARRAY Sensor_init_table_4lane_4K15fps[] = -{ -//Linear mode, MIPI clock 720M, VMAX 8008 @15fps - {0x3000, 0x12}, //standby - {0x3120, 0xF0}, - {0x3121, 0x00}, - {0x3122, 0x02}, - {0x3123, 0x01},// - {0x3129, 0x9C}, - {0x312a, 0x02}, - {0x312d, 0x02}, - {0x3ac4, 0x01},// - {0x310b, 0x00}, - {0x304c, 0x00}, - {0x304d, 0x03}, - {0x331c, 0x1a}, - {0x331d, 0x00}, - {0x3502, 0x02}, - {0x3529, 0x0e}, - {0x352a, 0x0e}, - {0x352b, 0x0e}, - {0x3538, 0x0e}, - {0x3539, 0x0e}, - {0x3553, 0x00}, - {0x357d, 0x05}, - {0x357f, 0x05}, - {0x3581, 0x04}, - {0x3583, 0x76}, - {0x3587, 0x01}, - {0x35bb, 0x0e}, - {0x35bc, 0x0e}, - {0x35bd, 0x0e}, - {0x35be, 0x0e}, - {0x35bf, 0x0e}, - {0x366e, 0x00}, - {0x366f, 0x00}, - {0x3670, 0x00}, - {0x3671, 0x00}, - {0x30ee, 0x01}, - {0x3304, 0x32}, - {0x3305, 0x00}, - {0x3306, 0x32}, - {0x3307, 0x00}, - {0x3590, 0x32}, - {0x3591, 0x00}, - {0x3686, 0x32}, - {0x3687, 0x00}, - {0x3134, 0x77}, - {0x3135, 0x00}, - {0x3136, 0x67}, - {0x3137, 0x00}, - {0x3138, 0x37}, - {0x3139, 0x00}, - {0x313a, 0x37}, - {0x313b, 0x00}, - {0x313c, 0x37}, - {0x313d, 0x00}, - {0x313e, 0xdf}, - {0x313f, 0x00}, - {0x3140, 0x37}, - {0x3141, 0x00}, - {0x3142, 0x2f}, - {0x3143, 0x00}, - {0x3144, 0x0f}, - {0x3145, 0x00}, - {0x3a86, 0x47}, - {0x3a87, 0x00}, -//mode registers 15fps - {0x3004, 0x00},//shutter and gain - {0x3005, 0x07}, - {0x3006, 0x00}, - {0x3007, 0x02}, - - {0x300E, 0x00}, - {0x300F, 0x00}, - {0x3019, 0x10}, - {0x301A, 0x00}, - {0x3032, 0x08}, - {0x3033, 0x00}, - - {0x3037, 0x00}, - {0x3038, 0x00}, - {0x3039, 0x00},//?? - {0x303a, 0x00}, - {0x303b, 0x00}, - - {0x3041, 0x30}, - {0x3042, 0x08}, - {0x3043, 0x01}, - - {0x306b, 0x07}, - {0x30dd, 0x00}, - {0x30de, 0x00}, - {0x30df, 0x00}, - {0x30e0, 0x00}, - {0x30e1, 0x00}, - {0x30e2, 0x00}, - {0x30e9, 0x00}, - - {0x30ee, 0x01}, - {0x30f6, 0x2e},//HMAX - {0x30f7, 0x04}, - {0x30f8, 0x86},//VMAX - {0x30f9, 0x11}, - {0x30fa, 0x00},// - {0x3130, 0xaa}, - {0x3131, 0x08}, - {0x3132, 0x9a}, - {0x3133, 0x08}, - - {0x3342, 0xff}, - {0x3343, 0x01}, - {0x3344, 0xff}, - {0x3345, 0x01}, - - {0x33a6, 0x01}, - {0x3528, 0x0f}, - {0x3554, 0x00}, - {0x3555, 0x00}, - {0x3556, 0x00}, - {0x3557, 0x00}, - {0x3558, 0x00}, - {0x3559, 0x1f}, - {0x355a, 0x1f}, - {0x35ba, 0x0f}, - {0x366a, 0x00}, - {0x366b, 0x00}, - {0x366c, 0x00}, - {0x366d, 0x00}, - {0x3a41, 0x10}, - // {0x3045, 0x28},//black level - {0xffff, 0x0a},//delay >=10ms - - //{0x300a, 0x80},//analog gain yc add - // {0x300b, 0x00},//yc add - //{0x3012, 0x05},//digital gain - - //{0x300d, 0xff},//MSB - //{0x300c, 0x02}, - - {0x300c, 0x08},//yc add - {0x300d, 0x01},//yc add - - - //setting 2 - {0x3000, 0x00}, - {0x303e, 0x02},//?? - {0xffff, 0x07},//delay >=7ms - - // {0x303c, 0x11},//test pattern - // {0x303d, 0x0a}, - - //setting3 - - {0x30f4, 0x00}, - {0x3018, 0xa2}, - //{0xffff, 0x60},//delay >=96ms - //{0x312e, 0x01}, - //{0x3aa2, 0x01}, - - // {0x3001, 0x06}, // ?��?MIPI 2lane Mode Change -}; - -const I2C_ARRAY Sensor_init_table_4lane_4K20fps[] = -{ -//Linear mode, MIPI clock 576Mbps, VMAX 4500 @20fps - {0x3000, 0x12}, //standby - {0x3120, 0xC0}, - {0x3121, 0x00}, - {0x3122, 0x02}, - {0x3123, 0x01},// - {0x3129, 0x9C}, - {0x312a, 0x02}, - {0x312d, 0x02}, - {0x3ac4, 0x01},// - {0x310b, 0x00}, - {0x304c, 0x00}, - {0x304d, 0x03}, - {0x331c, 0x1a}, - {0x331d, 0x00}, - {0x3502, 0x02}, - {0x3529, 0x0e}, - {0x352a, 0x0e}, - {0x352b, 0x0e}, - {0x3538, 0x0e}, - {0x3539, 0x0e}, - {0x3553, 0x00}, - {0x357d, 0x05}, - {0x357f, 0x05}, - {0x3581, 0x04}, - {0x3583, 0x76}, - {0x3587, 0x01}, - {0x35bb, 0x0e}, - {0x35bc, 0x0e}, - {0x35bd, 0x0e}, - {0x35be, 0x0e}, - {0x35bf, 0x0e}, - {0x366e, 0x00}, - {0x366f, 0x00}, - {0x3670, 0x00}, - {0x3671, 0x00}, - {0x30ee, 0x01}, - {0x3304, 0x32}, - {0x3305, 0x00}, - {0x3306, 0x32}, - {0x3307, 0x00}, - {0x3590, 0x32}, - {0x3591, 0x00}, - {0x3686, 0x32}, - {0x3687, 0x00}, - {0x3134, 0x5f}, - {0x3135, 0x00}, - {0x3136, 0x47}, - {0x3137, 0x00}, - {0x3138, 0x27}, - {0x3139, 0x00}, - {0x313a, 0x27}, - {0x313b, 0x00}, - {0x313c, 0x27}, - {0x313d, 0x00}, - {0x313e, 0x97}, - {0x313f, 0x00}, - {0x3140, 0x27}, - {0x3141, 0x00}, - {0x3142, 0x1f}, - {0x3143, 0x00}, - {0x3144, 0x0f}, - {0x3145, 0x00}, - {0x3a86, 0x47}, - {0x3a87, 0x00}, -//mode registers 15fps - {0x3004, 0x00},//shutter and gain - {0x3005, 0x07}, - {0x3006, 0x00}, - {0x3007, 0x02}, - - {0x300E, 0x00}, - {0x300F, 0x00}, - {0x3019, 0x10}, - {0x301A, 0x00}, - {0x3032, 0x08}, - {0x3033, 0x00}, - - {0x3037, 0x00}, - {0x3038, 0x00}, - {0x3039, 0x00},//?? - {0x303a, 0x00}, - {0x303b, 0x00}, - - {0x3041, 0x30}, - {0x3042, 0x08}, - {0x3043, 0x01}, - - {0x306b, 0x07}, - {0x30dd, 0x00}, - {0x30de, 0x00}, - {0x30df, 0x00}, - {0x30e0, 0x00}, - {0x30e1, 0x00}, - {0x30e2, 0x00}, - {0x30e9, 0x00}, - - {0x30ee, 0x01}, - {0x30f6, 0x20},//HMAX - {0x30f7, 0x03}, - {0x30f8, 0x94},//VMAX - {0x30f9, 0x11}, - {0x30fa, 0x00},// - {0x3130, 0xaa}, - {0x3131, 0x08}, - {0x3132, 0x9a}, - {0x3133, 0x08}, - - {0x3342, 0xff}, - {0x3343, 0x01}, - {0x3344, 0xff}, - {0x3345, 0x01}, - - {0x33a6, 0x01}, - {0x3528, 0x0f}, - {0x3554, 0x00}, - {0x3555, 0x00}, - {0x3556, 0x00}, - {0x3557, 0x00}, - {0x3558, 0x00}, - {0x3559, 0x1f}, - {0x355a, 0x1f}, - {0x35ba, 0x0f}, - {0x366a, 0x00}, - {0x366b, 0x00}, - {0x366c, 0x00}, - {0x366d, 0x00}, - {0x3a41, 0x10}, - // {0x3045, 0x28},//black level - {0xffff, 0x0a},//delay >=10ms - - //{0x300a, 0x80},//analog gain yc add - // {0x300b, 0x00},//yc add - //{0x3012, 0x05},//digital gain - - {0x300d, 0xff},//MSB - {0x300c, 0x02}, - - //{0x300c, 0x08},//yc add - //{0x300d, 0x01},//yc add - - - //setting 2 - {0x3000, 0x00}, - {0x303e, 0x03},//?? - {0xffff, 0x07},//delay >=7ms - - // {0x303c, 0x11},//test pattern - // {0x303d, 0x0a}, - - //setting3 - - {0x30f4, 0x00}, - {0x3018, 0xa2}, - //{0xffff, 0x60},//delay >=96ms - //{0x312e, 0x01}, - //{0x3aa2, 0x01}, - - // {0x3001, 0x06}, // ?��?MIPI 2lane Mode Change -}; - -const I2C_ARRAY Sensor_init_table_4lane_5M30fps[] = -{ -//Linear mode, MIPI clock 576Mbps, VMAX 4620 @30fps - {0x3000, 0x12}, //standby - {0x3120, 0xC0}, - {0x3121, 0x00}, - {0x3122, 0x02}, - {0x3123, 0x01},// - {0x3129, 0x9C}, - {0x312a, 0x02}, - {0x312d, 0x02}, - {0x3ac4, 0x01},// - {0x310b, 0x00}, - {0x304c, 0x00}, - {0x304d, 0x03}, - {0x331c, 0x1a}, - {0x331d, 0x00}, - {0x3502, 0x02}, - {0x3529, 0x0e}, - {0x352a, 0x0e}, - {0x352b, 0x0e}, - {0x3538, 0x0e}, - {0x3539, 0x0e}, - {0x3553, 0x00}, - {0x357d, 0x05}, - {0x357f, 0x05}, - {0x3581, 0x04}, - {0x3583, 0x76}, - {0x3587, 0x01}, - {0x35bb, 0x0e}, - {0x35bc, 0x0e}, - {0x35bd, 0x0e}, - {0x35be, 0x0e}, - {0x35bf, 0x0e}, - {0x366e, 0x00}, - {0x366f, 0x00}, - {0x3670, 0x00}, - {0x3671, 0x00}, - {0x30ee, 0x01}, - {0x3304, 0x32}, - {0x3305, 0x00}, - {0x3306, 0x32}, - {0x3307, 0x00}, - {0x3590, 0x32}, - {0x3591, 0x00}, - {0x3686, 0x32}, - {0x3687, 0x00}, - {0x3134, 0x5f}, - {0x3135, 0x00}, - {0x3136, 0x47}, - {0x3137, 0x00}, - {0x3138, 0x27}, - {0x3139, 0x00}, - {0x313a, 0x27}, - {0x313b, 0x00}, - {0x313c, 0x27}, - {0x313d, 0x00}, - {0x313e, 0x97}, - {0x313f, 0x00}, - {0x3140, 0x27}, - {0x3141, 0x00}, - {0x3142, 0x1f}, - {0x3143, 0x00}, - {0x3144, 0x0f}, - {0x3145, 0x00}, - {0x3a86, 0x47}, - {0x3a87, 0x00}, -//mode registers 5M@30fps - {0x3004, 0x00},//shutter and gain - {0x3005, 0x07}, - {0x3006, 0x00}, - {0x3007, 0xa2}, - - {0x300E, 0x00}, - {0x300F, 0x00}, - {0x3019, 0x10}, - {0x301A, 0x00}, - {0x3032, 0x08}, - {0x3033, 0x00}, - - {0x3037, 0x01}, - {0x3038, 0x70}, - {0x3039, 0x02},//?? - {0x303a, 0xa8}, - {0x303b, 0x0c}, - - {0x3041, 0x30}, - {0x3042, 0x08}, - {0x3043, 0x01}, - - {0x306b, 0x07}, - {0x30dd, 0x01}, - {0x30de, 0x6c}, - {0x30df, 0x00}, - {0x30e0, 0x36},//inverted 0xca - {0x30e1, 0x00},//inverted 0x0f - {0x30e2, 0x00}, - {0x30e9, 0x00}, - - {0x30ee, 0x01}, - {0x30f6, 0x08},//HMAX - {0x30f7, 0x02}, - {0x30f8, 0x0c},//VMAX - {0x30f9, 0x12}, - {0x30fa, 0x00},// - {0x3130, 0xd2}, - {0x3131, 0x07}, - {0x3132, 0xc2}, - {0x3133, 0x07}, - - {0x3342, 0xff}, - {0x3343, 0x01}, - {0x3344, 0xff}, - {0x3345, 0x01}, - - {0x33a6, 0x01}, - {0x3528, 0x0f}, - {0x3554, 0x00}, - {0x3555, 0x00}, - {0x3556, 0x00}, - {0x3557, 0x00}, - {0x3558, 0x00}, - {0x3559, 0x1f}, - {0x355a, 0x1f}, - {0x35ba, 0x0f}, - {0x366a, 0x00}, - {0x366b, 0x00}, - {0x366c, 0x00}, - {0x366d, 0x00}, - {0x3a41, 0x10}, - // {0x3045, 0x28},//black level - {0xffff, 0x0a},//delay >=10ms - //expo - {0x300d, 0x10},//MSB - {0x300c, 0x39}, - //setting 2 - {0x3000, 0x00}, - {0x303e, 0x03},//?? - {0xffff, 0x07},//delay >=7ms - - //setting3 - {0x30f4, 0x00}, - {0x3018, 0xa2}, - //{0xffff, 0x60},//delay >=96ms - -}; - -const I2C_ARRAY Sensor_init_table_4lane_4P8M30fps[] = -{ -//Linear mode, MIPI clock 576Mbps, VMAX 4004 @30fps - {0x3000, 0x12}, //standby - {0x3120, 0xC0}, - {0x3121, 0x00}, - {0x3122, 0x02}, - {0x3123, 0x01},// - {0x3129, 0x9C}, - {0x312a, 0x02}, - {0x312d, 0x02}, - {0x3ac4, 0x01},// - {0x310b, 0x00}, - {0x304c, 0x00}, - {0x304d, 0x03}, - {0x331c, 0x1a}, - {0x331d, 0x00}, - {0x3502, 0x02}, - {0x3529, 0x0e}, - {0x352a, 0x0e}, - {0x352b, 0x0e}, - {0x3538, 0x0e}, - {0x3539, 0x0e}, - {0x3553, 0x00}, - {0x357d, 0x05}, - {0x357f, 0x05}, - {0x3581, 0x04}, - {0x3583, 0x76}, - {0x3587, 0x01}, - {0x35bb, 0x0e}, - {0x35bc, 0x0e}, - {0x35bd, 0x0e}, - {0x35be, 0x0e}, - {0x35bf, 0x0e}, - {0x366e, 0x00}, - {0x366f, 0x00}, - {0x3670, 0x00}, - {0x3671, 0x00}, - {0x30ee, 0x01}, - {0x3304, 0x32}, - {0x3305, 0x00}, - {0x3306, 0x32}, - {0x3307, 0x00}, - {0x3590, 0x32}, - {0x3591, 0x00}, - {0x3686, 0x32}, - {0x3687, 0x00}, - {0x3134, 0x5f}, - {0x3135, 0x00}, - {0x3136, 0x47}, - {0x3137, 0x00}, - {0x3138, 0x27}, - {0x3139, 0x00}, - {0x313a, 0x27}, - {0x313b, 0x00}, - {0x313c, 0x27}, - {0x313d, 0x00}, - {0x313e, 0x97}, - {0x313f, 0x00}, - {0x3140, 0x27}, - {0x3141, 0x00}, - {0x3142, 0x1f}, - {0x3143, 0x00}, - {0x3144, 0x0f}, - {0x3145, 0x00}, - {0x3a86, 0x47}, - {0x3a87, 0x00}, - -//mode registers 4P8M@30fps - {0x3004, 0x00},//shutter and gain - {0x3005, 0x07}, - {0x3006, 0x00}, - {0x3007, 0xa2}, - - {0x300E, 0x00}, - {0x300F, 0x00}, - {0x3019, 0x10}, - {0x301A, 0x00}, - {0x3032, 0x08}, - {0x3033, 0x00}, - - {0x3037, 0x01}, - {0x3038, 0xbc}, - {0x3039, 0x01},//?? - {0x303a, 0x5c}, - {0x303b, 0x0d}, - - {0x3041, 0x30}, - {0x3042, 0x08}, - {0x3043, 0x01}, - - {0x306b, 0x07}, - {0x30dd, 0x01}, - {0x30de, 0xfc}, - {0x30df, 0x00}, - {0x30e0, 0x7e},//inverted 0x82 - {0x30e1, 0x00},//inverted 0x0f - {0x30e2, 0x00}, - {0x30e9, 0x00}, - - {0x30ee, 0x01}, - {0x30f6, 0x58},//HMAX - {0x30f7, 0x02}, - {0x30f8, 0xa4},//VMAX - {0x30f9, 0x0f}, - {0x30fa, 0x00},// - {0x3130, 0xb2}, - {0x3131, 0x06}, - {0x3132, 0xa2}, - {0x3133, 0x06}, - - {0x3342, 0xff}, - {0x3343, 0x01}, - {0x3344, 0xff}, - {0x3345, 0x01}, - - {0x33a6, 0x01}, - {0x3528, 0x0f}, - {0x3554, 0x00}, - {0x3555, 0x00}, - {0x3556, 0x00}, - {0x3557, 0x00}, - {0x3558, 0x00}, - {0x3559, 0x1f}, - {0x355a, 0x1f}, - {0x35ba, 0x0f}, - {0x366a, 0x00}, - {0x366b, 0x00}, - {0x366c, 0x00}, - {0x366d, 0x00}, - {0x3a41, 0x10}, - // {0x3045, 0x28},//black level - {0xffff, 0x0a},//delay >=10ms - //expo - {0x300d, 0x0e},//MSB - {0x300c, 0x10}, - //setting 2 - {0x3000, 0x00}, - {0x303e, 0x03},//?? - {0xffff, 0x07},//delay >=7ms - - //setting3 - {0x30f4, 0x00}, - {0x3018, 0xa2}, - //{0xffff, 0x60},//delay >=96ms - -}; - -const I2C_ARRAY Sensor_init_table_4lane_3P6M30fps[] = -{ -//Linear mode, MIPI clock 576Mbps, VMAX 4620 @30fps - {0x3000, 0x12}, //standby - {0x3120, 0xC0}, - {0x3121, 0x00}, - {0x3122, 0x02}, - {0x3123, 0x01},// - {0x3129, 0x9C}, - {0x312a, 0x02}, - {0x312d, 0x02}, - {0x3ac4, 0x01},// - {0x310b, 0x00}, - {0x304c, 0x00}, - {0x304d, 0x03}, - {0x331c, 0x1a}, - {0x331d, 0x00}, - {0x3502, 0x02}, - {0x3529, 0x0e}, - {0x352a, 0x0e}, - {0x352b, 0x0e}, - {0x3538, 0x0e}, - {0x3539, 0x0e}, - {0x3553, 0x00}, - {0x357d, 0x05}, - {0x357f, 0x05}, - {0x3581, 0x04}, - {0x3583, 0x76}, - {0x3587, 0x01}, - {0x35bb, 0x0e}, - {0x35bc, 0x0e}, - {0x35bd, 0x0e}, - {0x35be, 0x0e}, - {0x35bf, 0x0e}, - {0x366e, 0x00}, - {0x366f, 0x00}, - {0x3670, 0x00}, - {0x3671, 0x00}, - {0x30ee, 0x01}, - {0x3304, 0x32}, - {0x3305, 0x00}, - {0x3306, 0x32}, - {0x3307, 0x00}, - {0x3590, 0x32}, - {0x3591, 0x00}, - {0x3686, 0x32}, - {0x3687, 0x00}, - {0x3134, 0x5f}, - {0x3135, 0x00}, - {0x3136, 0x47}, - {0x3137, 0x00}, - {0x3138, 0x27}, - {0x3139, 0x00}, - {0x313a, 0x27}, - {0x313b, 0x00}, - {0x313c, 0x27}, - {0x313d, 0x00}, - {0x313e, 0x97}, - {0x313f, 0x00}, - {0x3140, 0x27}, - {0x3141, 0x00}, - {0x3142, 0x1f}, - {0x3143, 0x00}, - {0x3144, 0x0f}, - {0x3145, 0x00}, - {0x3a86, 0x47}, - {0x3a87, 0x00}, - -//mode registers 3P6M@30fps - {0x3004, 0x00},//shutter and gain - {0x3005, 0x07}, - {0x3006, 0x00}, - {0x3007, 0xa2}, - - {0x300E, 0x00}, - {0x300F, 0x00}, - {0x3019, 0x10}, - {0x301A, 0x00}, - {0x3032, 0x08}, - {0x3033, 0x00}, - - {0x3037, 0x01}, - {0x3038, 0x7c}, - {0x3039, 0x02},//?? - {0x303a, 0x9c}, - {0x303b, 0x0c}, - - {0x3041, 0x30}, - {0x3042, 0x08}, - {0x3043, 0x01}, - - {0x306b, 0x07}, - {0x30dd, 0x01}, - {0x30de, 0x68}, - {0x30df, 0x01}, - {0x30e0, 0xb4},//inverted 0x4c - {0x30e1, 0x00},//inverted 0x0f - {0x30e2, 0x00}, - {0x30e9, 0x00}, - - {0x30ee, 0x01}, - {0x30f6, 0x08},//HMAX - {0x30f7, 0x02}, - {0x30f8, 0x0c},//VMAX - {0x30f9, 0x12}, - {0x30fa, 0x00},// - {0x3130, 0xda}, - {0x3131, 0x05}, - {0x3132, 0xca}, - {0x3133, 0x05}, - - {0x3342, 0xff}, - {0x3343, 0x01}, - {0x3344, 0xff}, - {0x3345, 0x01}, - - {0x33a6, 0x01}, - {0x3528, 0x0f}, - {0x3554, 0x00}, - {0x3555, 0x00}, - {0x3556, 0x00}, - {0x3557, 0x00}, - {0x3558, 0x00}, - {0x3559, 0x1f}, - {0x355a, 0x1f}, - {0x35ba, 0x0f}, - {0x366a, 0x00}, - {0x366b, 0x00}, - {0x366c, 0x00}, - {0x366d, 0x00}, - {0x3a41, 0x10}, - // {0x3045, 0x28},//black level - {0xffff, 0x0a},//delay >=10ms - //expo - {0x300d, 0x10},//MSB - {0x300c, 0x39}, - //setting 2 - {0x3000, 0x00}, - {0x303e, 0x03},//?? - {0xffff, 0x07},//delay >=7ms - - //setting3 - {0x30f4, 0x00}, - {0x3018, 0xa2}, - //{0xffff, 0x60},//delay >=96ms - -}; - -const I2C_ARRAY Sensor_init_table_4lane_2M60fps[] = -{ -//Linear mode, MIPI clock 576Mbps, VMAX 2310 @60fps - {0x3000, 0x12}, //standby - {0x3120, 0xC0}, - {0x3121, 0x00}, - {0x3122, 0x02}, - {0x3123, 0x01},// - {0x3129, 0x9C}, - {0x312a, 0x02}, - {0x312d, 0x02}, - {0x3ac4, 0x01},// - {0x310b, 0x00}, - {0x304c, 0x00}, - {0x304d, 0x03}, - {0x331c, 0x1a}, - {0x331d, 0x00}, - {0x3502, 0x02}, - {0x3529, 0x0e}, - {0x352a, 0x0e}, - {0x352b, 0x0e}, - {0x3538, 0x0e}, - {0x3539, 0x0e}, - {0x3553, 0x00}, - {0x357d, 0x05}, - {0x357f, 0x05}, - {0x3581, 0x04}, - {0x3583, 0x76}, - {0x3587, 0x01}, - {0x35bb, 0x0e}, - {0x35bc, 0x0e}, - {0x35bd, 0x0e}, - {0x35be, 0x0e}, - {0x35bf, 0x0e}, - {0x366e, 0x00}, - {0x366f, 0x00}, - {0x3670, 0x00}, - {0x3671, 0x00}, - {0x30ee, 0x01}, - {0x3304, 0x32}, - {0x3305, 0x00}, - {0x3306, 0x32}, - {0x3307, 0x00}, - {0x3590, 0x32}, - {0x3591, 0x00}, - {0x3686, 0x32}, - {0x3687, 0x00}, - {0x3134, 0x5f}, - {0x3135, 0x00}, - {0x3136, 0x47}, - {0x3137, 0x00}, - {0x3138, 0x27}, - {0x3139, 0x00}, - {0x313a, 0x27}, - {0x313b, 0x00}, - {0x313c, 0x27}, - {0x313d, 0x00}, - {0x313e, 0x97}, - {0x313f, 0x00}, - {0x3140, 0x27}, - {0x3141, 0x00}, - {0x3142, 0x1f}, - {0x3143, 0x00}, - {0x3144, 0x0f}, - {0x3145, 0x00}, - {0x3a86, 0x47}, - {0x3a87, 0x00}, - -//mode registers 2M@60fps - {0x3004, 0x02},//shutter and gain - {0x3005, 0x27}, - {0x3006, 0x00}, - {0x3007, 0x11}, - - {0x300E, 0x00}, - {0x300F, 0x00}, - {0x3019, 0x10}, - {0x301A, 0x00}, - {0x3032, 0x08}, - {0x3033, 0x00}, - - {0x3037, 0x00}, - {0x3038, 0x00}, - {0x3039, 0x02},//?? - {0x303a, 0x00}, - {0x303b, 0x00}, - - {0x3041, 0x30}, - {0x3042, 0x08}, - {0x3043, 0x01}, - - {0x306b, 0x07}, - {0x30dd, 0x00}, - {0x30de, 0x00}, - {0x30df, 0x00}, - {0x30e0, 0x00},// - {0x30e1, 0x00},// - {0x30e2, 0x02}, - {0x30e9, 0x00}, - - {0x30ee, 0x01}, - {0x30f6, 0x08},//HMAX - {0x30f7, 0x02}, - {0x30f8, 0x06},//VMAX - {0x30f9, 0x09}, - {0x30fa, 0x00},// - {0x3130, 0x4e}, - {0x3131, 0x04}, - {0x3132, 0x46}, - {0x3133, 0x04}, - - {0x3342, 0xff}, - {0x3343, 0x01}, - {0x3344, 0xff}, - {0x3345, 0x01}, - - {0x33a6, 0x01}, - {0x3528, 0x0f}, - {0x3554, 0x00}, - {0x3555, 0x00}, - {0x3556, 0x00}, - {0x3557, 0x00}, - {0x3558, 0x00}, - {0x3559, 0x1f}, - {0x355a, 0x1f}, - {0x35ba, 0x0f}, - {0x366a, 0x00}, - {0x366b, 0x00}, - {0x366c, 0x00}, - {0x366d, 0x00}, - {0x3a41, 0x08}, - // {0x3045, 0x28},//black level - {0xffff, 0x0a},//delay >=10ms - //expo - {0x300d, 0x10},//MSB - {0x300c, 0x39}, - //setting 2 - {0x3000, 0x00}, - {0x303e, 0x03},//?? - {0xffff, 0x07},//delay >=7ms - - //setting3 - {0x30f4, 0x00}, - {0x3018, 0xa2}, - //{0xffff, 0x60},//delay >=96ms - -}; - -const I2C_ARRAY Sensor_init_table_4lane_4K30fps[] = -{ -//Linear mode, MIPI clock 720Mbps, VMAX 4620 @20fps - {0x3000, 0x12}, //standby - {0x3120, 0xF0}, - {0x3121, 0x00}, - {0x3122, 0x02}, - {0x3123, 0x01},// - {0x3129, 0x9C}, - {0x312a, 0x02}, - {0x312d, 0x02}, - {0x3ac4, 0x01},// - {0x310b, 0x00}, - {0x304c, 0x00}, - {0x304d, 0x03}, - {0x331c, 0x1a}, - {0x331d, 0x00}, - {0x3502, 0x02}, - {0x3529, 0x0e}, - {0x352a, 0x0e}, - {0x352b, 0x0e}, - {0x3538, 0x0e}, - {0x3539, 0x0e}, - {0x3553, 0x00}, - {0x357d, 0x05}, - {0x357f, 0x05}, - {0x3581, 0x04}, - {0x3583, 0x76}, - {0x3587, 0x01}, - {0x35bb, 0x0e}, - {0x35bc, 0x0e}, - {0x35bd, 0x0e}, - {0x35be, 0x0e}, - {0x35bf, 0x0e}, - {0x366e, 0x00}, - {0x366f, 0x00}, - {0x3670, 0x00}, - {0x3671, 0x00}, - {0x30ee, 0x01}, - {0x3304, 0x32}, - {0x3305, 0x00}, - {0x3306, 0x32}, - {0x3307, 0x00}, - {0x3590, 0x32}, - {0x3591, 0x00}, - {0x3686, 0x32}, - {0x3687, 0x00}, - {0x3134, 0x77}, - {0x3135, 0x00}, - {0x3136, 0x67}, - {0x3137, 0x00}, - {0x3138, 0x37}, - {0x3139, 0x00}, - {0x313a, 0x37}, - {0x313b, 0x00}, - {0x313c, 0x37}, - {0x313d, 0x00}, - {0x313e, 0xDF}, - {0x313f, 0x00}, - {0x3140, 0x37}, - {0x3141, 0x00}, - {0x3142, 0x2f}, - {0x3143, 0x00}, - {0x3144, 0x0f}, - {0x3145, 0x00}, - {0x3a86, 0x47}, - {0x3a87, 0x00}, -//mode registers 15fps - {0x3004, 0x01},//shutter and gain - {0x3005, 0x01}, - {0x3006, 0x00}, - {0x3007, 0x02}, - - {0x300E, 0x00}, - {0x300F, 0x00}, - {0x3019, 0x10}, - {0x301A, 0x00}, - {0x3032, 0x08}, - {0x3033, 0x00}, - - {0x3037, 0x00}, - {0x3038, 0x00}, - {0x3039, 0x00},//?? - {0x303a, 0x00}, - {0x303b, 0x00}, - - {0x3041, 0x30}, - {0x3042, 0x08}, - {0x3043, 0x01}, - - {0x306b, 0x05}, - {0x30dd, 0x00}, - {0x30de, 0x00}, - {0x30df, 0x00}, - {0x30e0, 0x00}, - {0x30e1, 0x00}, - {0x30e2, 0x01}, - {0x30e9, 0x00}, - - {0x30ee, 0x01}, - {0x30f6, 0x08},//HMAX - {0x30f7, 0x02}, - {0x30f8, 0x0c},//VMAX - {0x30f9, 0x12}, - {0x30fa, 0x00},// - {0x3130, 0x86}, - {0x3131, 0x08}, - {0x3132, 0x7e}, - {0x3133, 0x08}, - - {0x3342, 0x0a}, - {0x3343, 0x00}, - {0x3344, 0x16}, - {0x3345, 0x00}, - - {0x33a6, 0x01}, - {0x3528, 0x0e}, - {0x3554, 0x1f}, - {0x3555, 0x01}, - {0x3556, 0x01}, - {0x3557, 0x01}, - {0x3558, 0x01}, - {0x3559, 0x00}, - {0x355a, 0x00}, - {0x35ba, 0x0e}, - {0x366a, 0x1b}, - {0x366b, 0x1a}, - {0x366c, 0x19}, - {0x366d, 0x17}, - {0x3a41, 0x08}, - // {0x3045, 0x28},//black level - {0xffff, 0x0a},//delay >=10ms - - //{0x300a, 0x80},//analog gain yc add - // {0x300b, 0x00},//yc add - //{0x3012, 0x05},//digital gain - - //{0x300d, 0xff},//MSB - //{0x300c, 0x02}, - - //{0x300c, 0x08},//yc add - //{0x300d, 0x01},//yc add - - //expo - {0x300d, 0x10},//MSB - {0x300c, 0x3e}, - //setting 2 - {0x3000, 0x00}, - {0x303e, 0x02},//?? - {0xffff, 0x07},//delay >=7ms - - // {0x303c, 0x11},//test pattern - // {0x303d, 0x0a}, - - //setting3 - - {0x30f4, 0x00}, - {0x3018, 0xa2}, - //{0xffff, 0x60},//delay >=96ms - //{0x312e, 0x01}, - //{0x3aa2, 0x01}, - - // {0x3001, 0x06}, // ?��?MIPI 2lane Mode Change -}; - - - -///////////////////////////////////////////////////////////////// -// @@@@@@ // -// @@ // -// @@@ // -// @ @@ // -// @@@@ // -// // -// Step 3 -- complete camera features // -// // -// // -// camera set EV, MWB, orientation, contrast, sharpness // -// , saturation, and Denoise can work correctly. // -// // -///////////////////////////////////////////////////////////////// - - -const I2C_ARRAY mirr_flip_table[] = -{ - {0x301a, 0x00},//M0F0 - {0x301a, 0x00},//M1F0 - {0x301a, 0x01},//M0F1 - {0x301a, 0x01},//M1F1 - -}; - -typedef struct { - short reg; - char startbit; - char stopbit; -} COLLECT_REG_SET; - -const I2C_ARRAY gain_reg[] = { - {0x300b, 0x00},//high 10~8bit, analog gain - {0x300a, 0x10},//low byte - {0x3012, 0x10},//low bit 0~2 -}; - -static CUS_GAIN_GAP_ARRAY gain_gap_compensate[16] = { //compensate gain gap - {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} -}; - -const I2C_ARRAY expo_reg[] = { - {0x300d, 0x00},//MSB - {0x300c, 0x00}, -}; - -const I2C_ARRAY expo_shr_dol1_reg[] = -{ //SEL - {0x302F, 0x00},//MSB - {0x302E, 0x04}, -}; -const I2C_ARRAY expo_rhs1_reg[] = -{ //SEL - {0x3033, 0x00},//MSB - {0x3032, 0x08}, -}; -const I2C_ARRAY expo_shr_dol2_reg[] = -{ //LEF - {0x3031, 0x05},//MSB - {0x3030, 0x43}, -}; - -const I2C_ARRAY vts_reg[] = { - {0x30fa, 0x00},//bit0-3-->MSB - {0x30f9, 0x09}, - {0x30f8, 0x06}, -}; - -I2C_ARRAY PatternTbl[] = { - //pattern mode - {0x303c, 0x11},//test pattern - {0x303d, 0x0a}, -}; - -CUS_INT_TASK_ORDER def_order = { - .RunLength = 9, - .Orders = { - CUS_INT_TASK_AE|CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_AWB|CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_AE|CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_AWB|CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_AE|CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_AWB|CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - }, -}; - -#define SensorReg_Read(_reg,_data) (handle->i2c_bus->i2c_rx(handle->i2c_bus, &(handle->i2c_cfg),_reg,_data)) -#define SensorReg_Write(_reg,_data) (handle->i2c_bus->i2c_tx(handle->i2c_bus, &(handle->i2c_cfg),_reg,_data)) -#define SensorRegArrayW(_reg,_len) (handle->i2c_bus->i2c_array_tx(handle->i2c_bus, &(handle->i2c_cfg),(_reg),(_len))) -#define SensorRegArrayR(_reg,_len) (handle->i2c_bus->i2c_array_rx(handle->i2c_bus, &(handle->i2c_cfg),(_reg),(_len))) - -int cus_camsensor_release_handle(ms_cus_sensor *handle); - -/////////////////// sensor hardware dependent ////////////// -#if 0 -static int ISP_config_io(ms_cus_sensor *handle) { - ISensorIfAPI *sensor_if = handle->sensor_if_api; - - SENSOR_DMSG("[%s]", __FUNCTION__); - - sensor_if->HsyncPol(handle, handle->HSYNC_POLARITY); - sensor_if->VsyncPol(handle, handle->VSYNC_POLARITY); - sensor_if->ClkPol(handle, handle->PCLK_POLARITY); - sensor_if->BayerFmt(handle, handle->bayer_id); - sensor_if->DataBus(handle, handle->sif_bus); - - sensor_if->DataPrecision(handle, handle->data_prec); - sensor_if->FmtConv(handle, handle->data_mode); - return SUCCESS; -} -#endif -static int pCus_poweron(ms_cus_sensor *handle, u32 idx) -{ - ISensorIfAPI *sensor_if = handle->sensor_if_api; - SENSOR_DMSG("[%s] ", __FUNCTION__); - - //Sensor power on sequence - sensor_if->PowerOff(idx, !handle->pwdn_POLARITY); - sensor_if->Reset(idx, !handle->reset_POLARITY); - sensor_if->SetIOPad(idx, handle->sif_bus, handle->interface_attr.attr_mipi.mipi_lane_num); - sensor_if->SetCSI_Clk(idx, CUS_CSI_CLK_216M); - sensor_if->SetCSI_Lane(idx, handle->interface_attr.attr_mipi.mipi_lane_num, 1); - //sensor_if->SetCSI_VC0HSmode(handle,PACKET_FOOTER_EDGE); - sensor_if->SetCSI_LongPacketType(idx, 0, 0x1C00, 0); - - if (handle->interface_attr.attr_mipi.mipi_hdr_mode == CUS_HDR_MODE_SONY_DOL) { - sensor_if->SetCSI_hdr_mode(idx, handle->interface_attr.attr_mipi.mipi_hdr_mode, 1); - } - - sensor_if->Reset(idx, handle->reset_POLARITY); - SENSOR_UDELAY(20); - - sensor_if->PowerOff(idx, handle->pwdn_POLARITY); - SENSOR_UDELAY(20); - sensor_if->PowerOff(idx, !handle->pwdn_POLARITY); - SENSOR_UDELAY(20); - - SENSOR_DMSG("[%s] reset high\n", __FUNCTION__); - sensor_if->Reset(idx, !handle->reset_POLARITY); - - sensor_if->MCLK(idx, 1, handle->mclk); - SENSOR_UDELAY(20); - - return SUCCESS; -} - -static int pCus_poweroff(ms_cus_sensor *handle, u32 idx) -{ - // power/reset low - ISensorIfAPI *sensor_if = handle->sensor_if_api; - imx274_params *params = (imx274_params *)handle->private_data; - - SENSOR_DMSG("[%s] reset low\n", __FUNCTION__); - sensor_if->Reset(idx, handle->reset_POLARITY); - sensor_if->MCLK(idx, 0, handle->mclk); - - sensor_if->SetCSI_Clk(idx, CUS_CSI_CLK_DISABLE); - if (handle->interface_attr.attr_mipi.mipi_hdr_mode == CUS_HDR_MODE_SONY_DOL) { - sensor_if->SetCSI_hdr_mode(idx, handle->interface_attr.attr_mipi.mipi_hdr_mode, 0); - } - - params->cur_orien = CUS_ORIT_M0F0; - - return SUCCESS; -} - -/////////////////// image function ///////////////////////// -//Get and check sensor ID -//if i2c error or sensor id does not match then return FAIL -static int pCus_GetSensorID(ms_cus_sensor *handle, u32 *id) -{ - int i,n; - int table_length= ARRAY_SIZE(Sensor_id_table); - I2C_ARRAY id_from_sensor[ARRAY_SIZE(Sensor_id_table)]; - - for(n=0;n8) table_length=8; - - SENSOR_DMSG("\n\n[%s]", __FUNCTION__); - - for(n=0;n<4;++n) //retry , until I2C success - { - if(n>2) return FAIL; - - if( SensorRegArrayR((I2C_ARRAY*)id_from_sensor,table_length) == SUCCESS) //read sensor ID from I2C - break; - else - continue; - - } - - //convert sensor id to u32 format - for(i=0;iprivate_data; - //SENSOR_DMSG("\n\n[%s]", __FUNCTION__); - int i,cnt; - //ISensorIfAPI *sensor_if = handle->sensor_if_api; - //sensor_if->PCLK(NULL,CUS_PCLK_MIPI_TOP); - - for(i=0;i< ARRAY_SIZE(Sensor_init_table_4lane_4K15fps);i++) - { - if(Sensor_init_table_4lane_4K15fps[i].reg==0xffff) - { - SENSOR_MSLEEP(Sensor_init_table_4lane_4K15fps[i].data); - } - else - { - cnt = 0; - while(SensorReg_Write(Sensor_init_table_4lane_4K15fps[i].reg, Sensor_init_table_4lane_4K15fps[i].data) != SUCCESS) - { - cnt++; - SENSOR_DMSG("Sensor_init_table -> Retry %d...\n",cnt); - if(cnt>=10) - { - SENSOR_DMSG("[%s:%d]Sensor init fail!!\n", __FUNCTION__, __LINE__); - return FAIL; - } - SENSOR_MSLEEP(10); - } - } - } - - pCus_SetOrien(handle, params->cur_orien); - - params->tVts_reg[0].data =(u16)((params->expo.vts >> 16) & 0x000f); - params->tVts_reg[1].data = (u16)((params->expo.vts >> 8) & 0x00ff); - params->tVts_reg[2].data = (u16)((params->expo.vts >> 0) & 0x00ff); - // usleep(50*1000); - //pCus_SetAEGain(handle,1024); - //pCus_SetAEUSecs(handle, 40000); - //pCus_AEStatusNotify(handle,CUS_FRAME_ACTIVE); - return SUCCESS; -} - -static int pCus_init_mipi4lane_linear_4K20fps(ms_cus_sensor *handle) -{ - imx274_params *params = (imx274_params *)handle->private_data; - //SENSOR_DMSG("\n\n[%s]", __FUNCTION__); - int i,cnt; - //ISensorIfAPI *sensor_if = handle->sensor_if_api; - //sensor_if->PCLK(NULL,CUS_PCLK_MIPI_TOP); - - for(i=0;i< ARRAY_SIZE(Sensor_init_table_4lane_4K20fps);i++) - { - if(Sensor_init_table_4lane_4K20fps[i].reg==0xffff) - { - SENSOR_MSLEEP(Sensor_init_table_4lane_4K20fps[i].data); - } - else - { - cnt = 0; - while(SensorReg_Write(Sensor_init_table_4lane_4K20fps[i].reg, Sensor_init_table_4lane_4K20fps[i].data) != SUCCESS) - { - cnt++; - SENSOR_DMSG("Sensor_init_table -> Retry %d...\n",cnt); - if(cnt>=10) - { - SENSOR_DMSG("[%s:%d]Sensor init fail!!\n", __FUNCTION__, __LINE__); - return FAIL; - } - SENSOR_MSLEEP(10); - } - } - } - - pCus_SetOrien(handle, params->cur_orien); - - params->tVts_reg[0].data =(u16)((params->expo.vts >> 16) & 0x000f); - params->tVts_reg[1].data = (u16)((params->expo.vts >> 8) & 0x00ff); - params->tVts_reg[2].data = (u16)((params->expo.vts >> 0) & 0x00ff); - // usleep(50*1000); - //pCus_SetAEGain(handle,1024); - //pCus_SetAEUSecs(handle, 40000); - //pCus_AEStatusNotify(handle,CUS_FRAME_ACTIVE); - return SUCCESS; -} - -static int pCus_init_mipi4lane_linear_5M30fps(ms_cus_sensor *handle) -{ - imx274_params *params = (imx274_params *)handle->private_data; - //SENSOR_DMSG("\n\n[%s]", __FUNCTION__); - int i,cnt; - //ISensorIfAPI *sensor_if = handle->sensor_if_api; - //sensor_if->PCLK(NULL,CUS_PCLK_MIPI_TOP); - - for(i=0;i< ARRAY_SIZE(Sensor_init_table_4lane_5M30fps);i++) - { - if(Sensor_init_table_4lane_5M30fps[i].reg==0xffff) - { - SENSOR_MSLEEP(Sensor_init_table_4lane_5M30fps[i].data); - } - else - { - cnt = 0; - while(SensorReg_Write(Sensor_init_table_4lane_5M30fps[i].reg, Sensor_init_table_4lane_5M30fps[i].data) != SUCCESS) - { - cnt++; - SENSOR_DMSG("Sensor_init_table -> Retry %d...\n",cnt); - if(cnt>=10) - { - SENSOR_DMSG("[%s:%d]Sensor init fail!!\n", __FUNCTION__, __LINE__); - return FAIL; - } - SENSOR_MSLEEP(10); - } - } - } - - pCus_SetOrien(handle, params->cur_orien); - - params->tVts_reg[0].data =(u16)((params->expo.vts >> 16) & 0x000f); - params->tVts_reg[1].data = (u16)((params->expo.vts >> 8) & 0x00ff); - params->tVts_reg[2].data = (u16)((params->expo.vts >> 0) & 0x00ff); - // usleep(50*1000); - //pCus_SetAEGain(handle,1024); - //pCus_SetAEUSecs(handle, 40000); - //pCus_AEStatusNotify(handle,CUS_FRAME_ACTIVE); - return SUCCESS; -} - -static int pCus_init_mipi4lane_linear_4P8M30fps(ms_cus_sensor *handle) -{ - imx274_params *params = (imx274_params *)handle->private_data; - //SENSOR_DMSG("\n\n[%s]", __FUNCTION__); - int i,cnt; - //ISensorIfAPI *sensor_if = handle->sensor_if_api; - //sensor_if->PCLK(NULL,CUS_PCLK_MIPI_TOP); - - for(i=0;i< ARRAY_SIZE(Sensor_init_table_4lane_4P8M30fps);i++) - { - if(Sensor_init_table_4lane_4P8M30fps[i].reg==0xffff) - { - SENSOR_MSLEEP(Sensor_init_table_4lane_4P8M30fps[i].data); - } - else - { - cnt = 0; - while(SensorReg_Write(Sensor_init_table_4lane_4P8M30fps[i].reg, Sensor_init_table_4lane_4P8M30fps[i].data) != SUCCESS) - { - cnt++; - SENSOR_DMSG("Sensor_init_table -> Retry %d...\n",cnt); - if(cnt>=10) - { - SENSOR_DMSG("[%s:%d]Sensor init fail!!\n", __FUNCTION__, __LINE__); - return FAIL; - } - SENSOR_MSLEEP(10); - } - } - } - - pCus_SetOrien(handle, params->cur_orien); - - params->tVts_reg[0].data =(u16)((params->expo.vts >> 16) & 0x000f); - params->tVts_reg[1].data = (u16)((params->expo.vts >> 8) & 0x00ff); - params->tVts_reg[2].data = (u16)((params->expo.vts >> 0) & 0x00ff); - // usleep(50*1000); - //pCus_SetAEGain(handle,1024); - //pCus_SetAEUSecs(handle, 40000); - //pCus_AEStatusNotify(handle,CUS_FRAME_ACTIVE); - return SUCCESS; -} - -static int pCus_init_mipi4lane_linear_3P6M30fps(ms_cus_sensor *handle) -{ - imx274_params *params = (imx274_params *)handle->private_data; - //SENSOR_DMSG("\n\n[%s]", __FUNCTION__); - int i,cnt; - //ISensorIfAPI *sensor_if = handle->sensor_if_api; - //sensor_if->PCLK(NULL,CUS_PCLK_MIPI_TOP); - - for(i=0;i< ARRAY_SIZE(Sensor_init_table_4lane_3P6M30fps);i++) - { - if(Sensor_init_table_4lane_3P6M30fps[i].reg==0xffff) - { - SENSOR_MSLEEP(Sensor_init_table_4lane_3P6M30fps[i].data); - } - else - { - cnt = 0; - while(SensorReg_Write(Sensor_init_table_4lane_3P6M30fps[i].reg, Sensor_init_table_4lane_3P6M30fps[i].data) != SUCCESS) - { - cnt++; - SENSOR_DMSG("Sensor_init_table -> Retry %d...\n",cnt); - if(cnt>=10) - { - SENSOR_DMSG("[%s:%d]Sensor init fail!!\n", __FUNCTION__, __LINE__); - return FAIL; - } - SENSOR_MSLEEP(10); - } - } - } - - pCus_SetOrien(handle, params->cur_orien); - - params->tVts_reg[0].data =(u16)((params->expo.vts >> 16) & 0x000f); - params->tVts_reg[1].data = (u16)((params->expo.vts >> 8) & 0x00ff); - params->tVts_reg[2].data = (u16)((params->expo.vts >> 0) & 0x00ff); - // usleep(50*1000); - //pCus_SetAEGain(handle,1024); - //pCus_SetAEUSecs(handle, 40000); - //pCus_AEStatusNotify(handle,CUS_FRAME_ACTIVE); - return SUCCESS; -} - -static int pCus_init_mipi4lane_linear_2M60fps(ms_cus_sensor *handle) -{ - imx274_params *params = (imx274_params *)handle->private_data; - //SENSOR_DMSG("\n\n[%s]", __FUNCTION__); - int i,cnt; - //ISensorIfAPI *sensor_if = handle->sensor_if_api; - //sensor_if->PCLK(NULL,CUS_PCLK_MIPI_TOP); - - for(i=0;i< ARRAY_SIZE(Sensor_init_table_4lane_2M60fps);i++) - { - if(Sensor_init_table_4lane_2M60fps[i].reg==0xffff) - { - SENSOR_MSLEEP(Sensor_init_table_4lane_2M60fps[i].data); - } - else - { - cnt = 0; - while(SensorReg_Write(Sensor_init_table_4lane_2M60fps[i].reg, Sensor_init_table_4lane_2M60fps[i].data) != SUCCESS) - { - cnt++; - SENSOR_DMSG("Sensor_init_table -> Retry %d...\n",cnt); - if(cnt>=10) - { - SENSOR_DMSG("[%s:%d]Sensor init fail!!\n", __FUNCTION__, __LINE__); - return FAIL; - } - SENSOR_MSLEEP(10); - } - } - } - - pCus_SetOrien(handle, params->cur_orien); - - params->tVts_reg[0].data =(u16)((params->expo.vts >> 16) & 0x000f); - params->tVts_reg[1].data = (u16)((params->expo.vts >> 8) & 0x00ff); - params->tVts_reg[2].data = (u16)((params->expo.vts >> 0) & 0x00ff); - // usleep(50*1000); - //pCus_SetAEGain(handle,1024); - //pCus_SetAEUSecs(handle, 40000); - //pCus_AEStatusNotify(handle,CUS_FRAME_ACTIVE); - return SUCCESS; -} - - -static int pCus_init_mipi4lane_linear_4K30fps(ms_cus_sensor *handle) -{ - imx274_params *params = (imx274_params *)handle->private_data; - //SENSOR_DMSG("\n\n[%s]", __FUNCTION__); - int i,cnt; - //ISensorIfAPI *sensor_if = handle->sensor_if_api; - //sensor_if->PCLK(NULL,CUS_PCLK_MIPI_TOP); - - for(i=0;i< ARRAY_SIZE(Sensor_init_table_4lane_4K30fps);i++) - { - if(Sensor_init_table_4lane_4K30fps[i].reg==0xffff) - { - SENSOR_MSLEEP(Sensor_init_table_4lane_4K30fps[i].data); - } - else - { - cnt = 0; - while(SensorReg_Write(Sensor_init_table_4lane_4K30fps[i].reg, Sensor_init_table_4lane_4K30fps[i].data) != SUCCESS) - { - cnt++; - SENSOR_DMSG("Sensor_init_table -> Retry %d...\n",cnt); - if(cnt>=10) - { - SENSOR_DMSG("[%s:%d]Sensor init fail!!\n", __FUNCTION__, __LINE__); - return FAIL; - } - SENSOR_MSLEEP(10); - } - } - } - - pCus_SetOrien(handle, params->cur_orien); - - params->tVts_reg[0].data =(u16)((params->expo.vts >> 16) & 0x000f); - params->tVts_reg[1].data = (u16)((params->expo.vts >> 8) & 0x00ff); - params->tVts_reg[2].data = (u16)((params->expo.vts >> 0) & 0x00ff); - // usleep(50*1000); - //pCus_SetAEGain(handle,1024); - //pCus_SetAEUSecs(handle, 40000); - //pCus_AEStatusNotify(handle,CUS_FRAME_ACTIVE); - return SUCCESS; -} - - -static int pCus_init_mipi4lane_HDR_DOL_4k15fps(ms_cus_sensor *handle) -{ - imx274_params *params = (imx274_params *)handle->private_data; - int i,cnt=0; - - //SENSOR_DMSG("\n\n[%s]", __FUNCTION__); - for(i=0;i< ARRAY_SIZE(Sensor_init_table_HDR_DOL_4lane_4k15fps);i++) - { - if(Sensor_init_table_HDR_DOL_4lane_4k15fps[i].reg==0xffff) - { - //MsSleep(RTK_MS_TO_TICK(1));//usleep(1000*Sensor_init_table_HDR_DOL_4lane_4k15fps[i].data); - SENSOR_MSLEEP(Sensor_init_table_HDR_DOL_4lane_4k15fps[i].data); - } - else - { - cnt = 0; - SENSOR_DMSG("reg = %x, data = %x\n", Sensor_init_table_HDR_DOL_4lane_4k15fps[i].reg, Sensor_init_table_HDR_DOL_4lane_4k15fps[i].data); - while(SensorReg_Write(Sensor_init_table_HDR_DOL_4lane_4k15fps[i].reg,Sensor_init_table_HDR_DOL_4lane_4k15fps[i].data) != SUCCESS) - { - cnt++; - SENSOR_DMSG("Sensor_init_table_HDR_DOL_4lane_4k15fps -> Retry %d...\n",cnt); - if(cnt>=10) - { - //printf("[%s:%d]Sensor init fail!!\n", __FUNCTION__, __LINE__); - return FAIL; - } - SENSOR_MSLEEP(10); - } - //SensorReg_Read( Sensor_init_table_HDR_DOL_4lane_4k15fps[i].reg, &sen_data ); - //UartSendTrace("IMX274 reg: 0x%x, data: 0x%x, read: 0x%x.\n",Sensor_init_table_HDR_DOL_4lane_4k15fps[i].reg, Sensor_init_table_HDR_DOL_4lane_4k15fps[i].data, sen_data); - } - } - - params->tVts_reg[0].data =(u16)((params->expo.vts >> 16) & 0x000f); - params->tVts_reg[1].data = (u16)((params->expo.vts >> 8) & 0x00ff); - params->tVts_reg[2].data = (u16)((params->expo.vts >> 0) & 0x00ff); - - //MSG("[%s:%d]Sensor init success!!\n", __FUNCTION__, __LINE__); - return SUCCESS; -} - - -static int pCus_init_mipi4lane_HDR_DOL_4k20fps(ms_cus_sensor *handle) -{ - imx274_params *params = (imx274_params *)handle->private_data; - int i,cnt=0; - - //SENSOR_DMSG("\n\n[%s]", __FUNCTION__); - for(i=0;i< ARRAY_SIZE(Sensor_init_table_HDR_DOL_4lane_4k20fps);i++) - { - if(Sensor_init_table_HDR_DOL_4lane_4k20fps[i].reg==0xffff) - { - //MsSleep(RTK_MS_TO_TICK(1));//usleep(1000*Sensor_init_table_HDR_DOL_4lane_4k15fps[i].data); - SENSOR_MSLEEP(Sensor_init_table_HDR_DOL_4lane_4k20fps[i].data); - } - else - { - cnt = 0; - SENSOR_DMSG("reg = %x, data = %x\n", Sensor_init_table_HDR_DOL_4lane_4k20fps[i].reg, Sensor_init_table_HDR_DOL_4lane_4k20fps[i].data); - while(SensorReg_Write(Sensor_init_table_HDR_DOL_4lane_4k20fps[i].reg,Sensor_init_table_HDR_DOL_4lane_4k20fps[i].data) != SUCCESS) - { - cnt++; - SENSOR_DMSG("Sensor_init_table_HDR_DOL_4lane_4k20fps -> Retry %d...\n",cnt); - if(cnt>=10) - { - //printf("[%s:%d]Sensor init fail!!\n", __FUNCTION__, __LINE__); - return FAIL; - } - SENSOR_MSLEEP(10); - } - //SensorReg_Read( Sensor_init_table_HDR_DOL_4lane_4k15fps[i].reg, &sen_data ); - //UartSendTrace("IMX274 reg: 0x%x, data: 0x%x, read: 0x%x.\n",Sensor_init_table_HDR_DOL_4lane_4k15fps[i].reg, Sensor_init_table_HDR_DOL_4lane_4k15fps[i].data, sen_data); - } - } - - params->tVts_reg[0].data =(u16)((params->expo.vts >> 16) & 0x000f); - params->tVts_reg[1].data = (u16)((params->expo.vts >> 8) & 0x00ff); - params->tVts_reg[2].data = (u16)((params->expo.vts >> 0) & 0x00ff); - - //MSG("[%s:%d]Sensor init success!!\n", __FUNCTION__, __LINE__); - return SUCCESS; -} - -static int pCus_init_mipi4lane_HDR_DOL_4k30fps(ms_cus_sensor *handle) -{ - imx274_params *params = (imx274_params *)handle->private_data; - int i,cnt=0; - - //SENSOR_DMSG("\n\n[%s]", __FUNCTION__); - for(i=0;i< ARRAY_SIZE(Sensor_init_table_HDR_DOL_4lane_4k30fps);i++) - { - if(Sensor_init_table_HDR_DOL_4lane_4k30fps[i].reg==0xffff) - { - //MsSleep(RTK_MS_TO_TICK(1));//usleep(1000*Sensor_init_table_HDR_DOL_4lane_4k15fps[i].data); - SENSOR_MSLEEP(Sensor_init_table_HDR_DOL_4lane_4k30fps[i].data); - } - else - { - cnt = 0; - SENSOR_DMSG("reg = %x, data = %x\n", Sensor_init_table_HDR_DOL_4lane_4k30fps[i].reg, Sensor_init_table_HDR_DOL_4lane_4k30fps[i].data); - while(SensorReg_Write(Sensor_init_table_HDR_DOL_4lane_4k30fps[i].reg,Sensor_init_table_HDR_DOL_4lane_4k30fps[i].data) != SUCCESS) - { - cnt++; - SENSOR_DMSG("Sensor_init_table_HDR_DOL_4lane_4k25fps -> Retry %d...\n",cnt); - if(cnt>=10) - { - //printf("[%s:%d]Sensor init fail!!\n", __FUNCTION__, __LINE__); - return FAIL; - } - SENSOR_MSLEEP(10); - } - //SensorReg_Read( Sensor_init_table_HDR_DOL_4lane_4k15fps[i].reg, &sen_data ); - //UartSendTrace("IMX274 reg: 0x%x, data: 0x%x, read: 0x%x.\n",Sensor_init_table_HDR_DOL_4lane_4k15fps[i].reg, Sensor_init_table_HDR_DOL_4lane_4k15fps[i].data, sen_data); - } - } - - params->tVts_reg[0].data =(u16)((params->expo.vts >> 16) & 0x000f); - params->tVts_reg[1].data = (u16)((params->expo.vts >> 8) & 0x00ff); - params->tVts_reg[2].data = (u16)((params->expo.vts >> 0) & 0x00ff); - - //MSG("[%s:%d]Sensor init success!!\n", __FUNCTION__, __LINE__); - return SUCCESS; -} - - -static int pCus_init_mipi4lane_HDR_DOL_2M30fps(ms_cus_sensor *handle) -{ - imx274_params *params = (imx274_params *)handle->private_data; - int i,cnt=0; - - //SENSOR_DMSG("\n\n[%s]", __FUNCTION__); - for(i=0;i< ARRAY_SIZE(Sensor_init_table_HDR_DOL_4lane_2M30fps);i++) - { - if(Sensor_init_table_HDR_DOL_4lane_2M30fps[i].reg==0xffff) - { - //MsSleep(RTK_MS_TO_TICK(1));//usleep(1000*Sensor_init_table_HDR_DOL_4lane_4k15fps[i].data); - SENSOR_MSLEEP(Sensor_init_table_HDR_DOL_4lane_2M30fps[i].data); - } - else - { - cnt = 0; - //SENSOR_IMSG("reg = %x, data = %x\n", Sensor_init_table_HDR_DOL_4lane_2M30fps[i].reg, Sensor_init_table_HDR_DOL_4lane_2M30fps[i].data); - while(SensorReg_Write(Sensor_init_table_HDR_DOL_4lane_2M30fps[i].reg,Sensor_init_table_HDR_DOL_4lane_2M30fps[i].data) != SUCCESS) - { - cnt++; - SENSOR_DMSG("Sensor_init_table_HDR_DOL_4lane_2M30fps -> Retry %d...\n",cnt); - if(cnt>=10) - { - //printf("[%s:%d]Sensor init fail!!\n", __FUNCTION__, __LINE__); - return FAIL; - } - SENSOR_MSLEEP(10); - } - //SensorReg_Read( Sensor_init_table_HDR_DOL_4lane_2M30fps[i].reg, &sen_data ); - //UartSendTrace("IMX274 reg: 0x%x, data: 0x%x, read: 0x%x.\n",Sensor_init_table_HDR_DOL_4lane_2M30fps[i].reg, Sensor_init_table_HDR_DOL_4lane_2M30fps[i].data, sen_data); - } - } - - params->tVts_reg[0].data =(u16)((params->expo.vts >> 16) & 0x000f); - params->tVts_reg[1].data = (u16)((params->expo.vts >> 8) & 0x00ff); - params->tVts_reg[2].data = (u16)((params->expo.vts >> 0) & 0x00ff); - - //MSG("[%s:%d]Sensor init success!!\n", __FUNCTION__, __LINE__); - return SUCCESS; -} - - -/* -int pCus_release(ms_cus_sensor *handle) -{ - ISensorIfAPI *sensor_if = handle->sensor_if_api; - sensor_if->PCLK(NULL,CUS_PCLK_OFF); - return SUCCESS; -} -*/ -static int pCus_GetVideoResNum( ms_cus_sensor *handle, u32 *ulres_num) -{ - *ulres_num = handle->video_res_supported.num_res; - return SUCCESS; -} -static int pCus_GetVideoRes(ms_cus_sensor *handle, u32 res_idx, cus_camsensor_res **res) -{ - u32 num_res = handle->video_res_supported.num_res; - - if (res_idx >= num_res) { - return FAIL; - } - - *res = &handle->video_res_supported.res[res_idx]; - - return SUCCESS; -} - -static int pCus_GetCurVideoRes(ms_cus_sensor *handle, u32 *cur_idx, cus_camsensor_res **res) -{ - u32 num_res = handle->video_res_supported.num_res; - - *cur_idx = handle->video_res_supported.ulcur_res; - - if (*cur_idx >= num_res) { - return FAIL; - } - - *res = &handle->video_res_supported.res[*cur_idx]; - - return SUCCESS; -} - -static int pCus_SetVideoRes(ms_cus_sensor *handle, u32 res_idx) -{ - u32 num_res = handle->video_res_supported.num_res; - imx274_params *params = (imx274_params *)handle->private_data; - - if (res_idx >= num_res) { - return FAIL; - } - handle->data_prec = SENSOR_DATAPREC; - switch (res_idx) { - case 0: //"3840x2160@15fps" - handle->video_res_supported.ulcur_res = 0; - handle->pCus_sensor_init = pCus_init_mipi4lane_linear_4K15fps; - vts_30fps = 4486; - params->expo.vts = vts_30fps; - params->expo.fps = 15; - Preview_line_period = 14861; - params->vwinpos_nor[0].reg = 0x30E1; - params->vwinpos_nor[0].data = 0; - params->vwinpos_nor[1].reg = 0x30E0; - params->vwinpos_nor[1].data = 0; - params->vwinpos_inv[0].reg = 0x30E1; - params->vwinpos_inv[0].data = 0; - params->vwinpos_inv[1].reg = 0x30E0; - params->vwinpos_inv[1].data = 0; - break; - case 1: //"3840x2160@20fps" - handle->video_res_supported.ulcur_res = 1; - handle->pCus_sensor_init = pCus_init_mipi4lane_linear_4K20fps; - vts_30fps = 4500; - params->expo.vts = vts_30fps; - params->expo.fps = 20; - Preview_line_period = 11111; - params->vwinpos_nor[0].reg = 0x30E1; - params->vwinpos_nor[0].data = 0; - params->vwinpos_nor[1].reg = 0x30E0; - params->vwinpos_nor[1].data = 0; - params->vwinpos_inv[0].reg = 0x30E1; - params->vwinpos_inv[0].data = 0; - params->vwinpos_inv[1].reg = 0x30E0; - params->vwinpos_inv[1].data = 0; - break; - case 2: //"2592x1944@30fps" - handle->video_res_supported.ulcur_res = 2; - handle->pCus_sensor_init = pCus_init_mipi4lane_linear_5M30fps; - vts_30fps = 4620; - params->expo.vts = vts_30fps; - params->expo.fps = 30; - Preview_line_period = 7222; - params->vwinpos_nor[0].reg = 0x30E1; - params->vwinpos_nor[0].data = 0; - params->vwinpos_nor[1].reg = 0x30E0; - params->vwinpos_nor[1].data = 0x36; - params->vwinpos_inv[0].reg = 0x30E1; - params->vwinpos_inv[0].data = 0xF; - params->vwinpos_inv[1].reg = 0x30E0; - params->vwinpos_inv[1].data = 0xCA; - break; - case 3: //"2944x1656@30fps" - handle->video_res_supported.ulcur_res = 3; - handle->pCus_sensor_init = pCus_init_mipi4lane_linear_4P8M30fps; - vts_30fps = 4004; - params->expo.vts = vts_30fps; - params->expo.fps = 30; - Preview_line_period = 8333; - params->vwinpos_nor[0].reg = 0x30E1; - params->vwinpos_nor[0].data = 0; - params->vwinpos_nor[1].reg = 0x30E0; - params->vwinpos_nor[1].data = 0x7E; - params->vwinpos_inv[0].reg = 0x30E1; - params->vwinpos_inv[0].data = 0xF; - params->vwinpos_inv[1].reg = 0x30E0; - params->vwinpos_inv[1].data = 0x82; - break; - case 4: //"2560x1440@30fps" - handle->video_res_supported.ulcur_res = 4; - handle->pCus_sensor_init = pCus_init_mipi4lane_linear_3P6M30fps; - vts_30fps = 4620; - params->expo.vts = vts_30fps; - params->expo.fps = 30; - Preview_line_period = 7222; - params->vwinpos_nor[0].reg = 0x30E1; - params->vwinpos_nor[0].data = 0; - params->vwinpos_nor[1].reg = 0x30E0; - params->vwinpos_nor[1].data = 0xB4; - params->vwinpos_inv[0].reg = 0x30E1; - params->vwinpos_inv[0].data = 0xF; - params->vwinpos_inv[1].reg = 0x30E0; - params->vwinpos_inv[1].data = 0x4C; - break; - case 5: //"1920x1080@60fps" - handle->video_res_supported.ulcur_res = 5; - handle->pCus_sensor_init = pCus_init_mipi4lane_linear_2M60fps; - vts_30fps = 2310; - params->expo.vts = vts_30fps; - params->expo.fps = 60; - Preview_line_period = 7222; - params->vwinpos_nor[0].reg = 0x30E1; - params->vwinpos_nor[0].data = 0; - params->vwinpos_nor[1].reg = 0x30E0; - params->vwinpos_nor[1].data = 0; - params->vwinpos_inv[0].reg = 0x30E1; - params->vwinpos_inv[0].data = 0; - params->vwinpos_inv[1].reg = 0x30E0; - params->vwinpos_inv[1].data = 0; - break; - case 6: //"3840x2160@30fps" - handle->video_res_supported.ulcur_res = 6; - handle->pCus_sensor_init = pCus_init_mipi4lane_linear_4K30fps; - handle->data_prec = CUS_DATAPRECISION_10; - vts_30fps = 4620; - params->expo.vts = vts_30fps; - params->expo.fps = 30; - Preview_line_period = 7215; - params->vwinpos_nor[0].reg = 0x30E1; - params->vwinpos_nor[0].data = 0; - params->vwinpos_nor[1].reg = 0x30E0; - params->vwinpos_nor[1].data = 0; - params->vwinpos_inv[0].reg = 0x30E1; - params->vwinpos_inv[0].data = 0; - params->vwinpos_inv[1].reg = 0x30E0; - params->vwinpos_inv[1].data = 0; - break; - default: - break; - } - - return SUCCESS; -} - -static int pCus_SetVideoRes_HDR_DOL(ms_cus_sensor *handle, u32 res_idx) -{ - u32 num_res = handle->video_res_supported.num_res; - imx274_params *params = (imx274_params *)handle->private_data; - - if (res_idx >= num_res) { - return FAIL; - } - switch (res_idx) { - case 0: - handle->video_res_supported.ulcur_res = 0; - if (handle->interface_attr.attr_mipi.mipi_hdr_virtual_channel_num == 1) { - handle->pCus_sensor_init = pCus_init_mipi4lane_HDR_DOL_4k15fps; - handle->pCus_sensor_SetAEUSecs = pCus_SetAEUSecsHDR_DOL_SEF; - } - vts_30fps_HDR_DOL = (2310+Preview_CROP_START_Y_DOL); - params->expo.vts = vts_30fps_HDR_DOL; - params->expo.fps = 15; - Preview_line_period_HDR_DOL = 28879; - params->vwinpos_nor[0].reg = 0x30E1; - params->vwinpos_nor[0].data = 0; - params->vwinpos_nor[1].reg = 0x30E0; - params->vwinpos_nor[1].data = 0; - params->vwinpos_inv[0].reg = 0x30E1; - params->vwinpos_inv[0].data = 0; - params->vwinpos_inv[1].reg = 0x30E0; - params->vwinpos_inv[1].data = 0; - params->vts_to_rhs1 = 2310; - break; - case 1: - handle->video_res_supported.ulcur_res = 1; - if (handle->interface_attr.attr_mipi.mipi_hdr_virtual_channel_num == 1) { - handle->pCus_sensor_init = pCus_init_mipi4lane_HDR_DOL_2M30fps; - handle->pCus_sensor_SetAEUSecs = pCus_SetAEUSecsHDR_DOL_SEF_Binning; - } - vts_30fps_HDR_DOL = 2310; - params->expo.vts = vts_30fps_HDR_DOL; - params->expo.fps = 30; - Preview_line_period_HDR_DOL = 14430; - params->vwinpos_nor[0].reg = 0x30E1; - params->vwinpos_nor[0].data = 0; - params->vwinpos_nor[1].reg = 0x30E0; - params->vwinpos_nor[1].data = 0; - params->vwinpos_inv[0].reg = 0x30E1; - params->vwinpos_inv[0].data = 0; - params->vwinpos_inv[1].reg = 0x30E0; - params->vwinpos_inv[1].data = 0; - params->vts_to_rhs1 = 2310; - break; - case 2: - handle->video_res_supported.ulcur_res = 2; - if (handle->interface_attr.attr_mipi.mipi_hdr_virtual_channel_num == 1) { - handle->pCus_sensor_init = pCus_init_mipi4lane_HDR_DOL_4k20fps; - handle->pCus_sensor_SetAEUSecs = pCus_SetAEUSecsHDR_DOL_SEF; - } - vts_30fps_HDR_DOL = (2500+Preview_CROP_START_Y_DOL); - params->expo.vts = vts_30fps_HDR_DOL; - params->expo.fps = 20; - Preview_line_period_HDR_DOL = 19936; - params->vwinpos_nor[0].reg = 0x30E1; - params->vwinpos_nor[0].data = 0; - params->vwinpos_nor[1].reg = 0x30E0; - params->vwinpos_nor[1].data = 0; - params->vwinpos_inv[0].reg = 0x30E1; - params->vwinpos_inv[0].data = 0; - params->vwinpos_inv[1].reg = 0x30E0; - params->vwinpos_inv[1].data = 0; - params->vts_to_rhs1 = 2360; //fix rhs1, align to res 0 - break; - case 3: - handle->video_res_supported.ulcur_res = 3; - if (handle->interface_attr.attr_mipi.mipi_hdr_virtual_channel_num == 1) { - handle->pCus_sensor_init = pCus_init_mipi4lane_HDR_DOL_4k30fps; - handle->pCus_sensor_SetAEUSecs = pCus_SetAEUSecsHDR_DOL_SEF; - } - vts_30fps_HDR_DOL = (2275+Preview_CROP_START_Y_DOL); - params->expo.vts = vts_30fps_HDR_DOL; - params->expo.fps = 30; - Preview_line_period_HDR_DOL = 14652; - params->vwinpos_nor[0].reg = 0x30E1; - params->vwinpos_nor[0].data = 0; - params->vwinpos_nor[1].reg = 0x30E0; - params->vwinpos_nor[1].data = 0; - params->vwinpos_inv[0].reg = 0x30E1; - params->vwinpos_inv[0].data = 0; - params->vwinpos_inv[1].reg = 0x30E0; - params->vwinpos_inv[1].data = 0; - params->vts_to_rhs1 = 2275; - break; - default: - break; - } - - return SUCCESS; -} - -static int pCus_GetOrien(ms_cus_sensor *handle, CUS_CAMSENSOR_ORIT *orit) -{ - short sen_data = 0; - - SensorReg_Read(0x301a, &sen_data);//always success now - - SENSOR_DMSG("mirror:%x\r\n", sen_data & 0x01); - switch(sen_data & 0x01) - { - case 0x00: - *orit = CUS_ORIT_M0F0; - break; - case 0x01: - *orit = CUS_ORIT_M0F1; - break; - default: - *orit = CUS_ORIT_M0F0; - break; - } - return SUCCESS; -} - -static int pCus_SetOrien(ms_cus_sensor *handle, CUS_CAMSENSOR_ORIT orit) -{ - imx274_params *params = (imx274_params *)handle->private_data; - int table_length = ARRAY_SIZE(mirr_flip_table); - int seg_length=table_length/4; - int i,j; - - SENSOR_DMSG("\n\n[%s]", __FUNCTION__); - - switch(orit) - { - case CUS_ORIT_M0F0: - for(i=0,j=0;icur_orien = CUS_ORIT_M0F0; - } - SensorRegArrayW((I2C_ARRAY*)params->vwinpos_nor, ARRAY_SIZE(params->vwinpos_nor)); - break; - - case CUS_ORIT_M1F0: - for(i=seg_length,j=0;icur_orien = CUS_ORIT_M1F0; - } - SensorRegArrayW((I2C_ARRAY*)params->vwinpos_nor, ARRAY_SIZE(params->vwinpos_nor)); - break; - - case CUS_ORIT_M0F1: - for(i=seg_length*2,j=0;icur_orien = CUS_ORIT_M0F1; - } - SensorRegArrayW((I2C_ARRAY*)params->vwinpos_inv, ARRAY_SIZE(params->vwinpos_inv)); - break; - - case CUS_ORIT_M1F1: - for(i=seg_length*3,j=0;icur_orien = CUS_ORIT_M1F1; - } - SensorRegArrayW((I2C_ARRAY*)params->vwinpos_inv, ARRAY_SIZE(params->vwinpos_inv)); - break; - - default : - for(i=0,j=0;icur_orien = CUS_ORIT_M0F0; - } - SensorRegArrayW((I2C_ARRAY*)params->vwinpos_nor, ARRAY_SIZE(params->vwinpos_nor)); - break; - } - return SUCCESS; -} - -static int pCus_GetFPS(ms_cus_sensor *handle) -{ - imx274_params *params = (imx274_params *)handle->private_data; - u32 max_fps = handle->video_res_supported.res[handle->video_res_supported.ulcur_res].max_fps; - u32 tVts = (params->tVts_reg[0].data << 16) | (params->tVts_reg[1].data << 8) | (params->tVts_reg[2].data << 0); - - if (params->expo.fps >= 1000) - params->expo.preview_fps = (vts_30fps*max_fps*1000)/tVts; - else - params->expo.preview_fps = (vts_30fps*max_fps)/tVts; - - return params->expo.preview_fps; -} - -static int pCus_SetFPS(ms_cus_sensor *handle, u32 fps) -{ - imx274_params *params = (imx274_params *)handle->private_data; - u32 max_fps = handle->video_res_supported.res[handle->video_res_supported.ulcur_res].max_fps; - u32 min_fps = handle->video_res_supported.res[handle->video_res_supported.ulcur_res].min_fps; - - if(fps>=min_fps && fps <= max_fps){ - params->expo.fps = fps; - params->expo.vts= (vts_30fps*max_fps)/fps; - }else if((fps >= (min_fps*1000)) && (fps <= (max_fps*1000))){ - params->expo.fps = fps; - params->expo.vts= (vts_30fps*(max_fps*1000))/fps; - - }else{ - //params->expo.vts=vts_30fps; - //params->expo.fps=30; - SENSOR_DMSG("[%s] FPS %d out of range.\n",__FUNCTION__,fps); - return FAIL; - } - - pCus_SetAEUSecs(handle, params->expo.expo_lef_us); - params->dirty = true; //reg need to update = true; - return SUCCESS; -} - -static int pCus_GetFPS_HDR_DOL_SEF(ms_cus_sensor *handle) -{ - imx274_params *params = (imx274_params *)handle->private_data; - u32 max_fps = handle->video_res_supported.res[handle->video_res_supported.ulcur_res].max_fps; - u32 tVts = (params->tVts_reg[0].data << 16) | (params->tVts_reg[1].data << 8) | (params->tVts_reg[2].data << 0); - - if (params->expo.fps >= 1000) - params->expo.preview_fps = (vts_30fps_HDR_DOL*max_fps*1000)/tVts; - else - params->expo.preview_fps = (vts_30fps_HDR_DOL*max_fps)/tVts; - - return params->expo.preview_fps; -} - -static int pCus_SetFPS_HDR_DOL_SEF(ms_cus_sensor *handle, u32 fps) -{ - imx274_params *params = (imx274_params *)handle->private_data; - u32 max_fps = handle->video_res_supported.res[handle->video_res_supported.ulcur_res].max_fps; - u32 min_fps = handle->video_res_supported.res[handle->video_res_supported.ulcur_res].min_fps; - - if(fps>=min_fps && fps <= max_fps){ - params->expo.fps = fps; - params->expo.vts= (vts_30fps_HDR_DOL*max_fps)/fps; - }else if((fps >= (min_fps*1000)) && (fps <= (max_fps*1000))){ - params->expo.fps = fps; - params->expo.vts= (vts_30fps_HDR_DOL*(max_fps*1000))/fps; - }else{ - //params->expo.vts=vts_30fps; - //params->expo.fps=30; - SENSOR_DMSG("[%s] FPS %d out of range.\n",__FUNCTION__,fps); - return FAIL; - } - - pCus_SetAEUSecsHDR_DOL_SEF(handle, params->expo.expo_sef_us); - params->dirty = true; //reg need to update = true; - return SUCCESS; -} - - -#if 0 -static int pCus_GetSensorCap(ms_cus_sensor *handle, CUS_CAMSENSOR_CAP *cap) { - if (cap) - memcpy(cap, &sensor_cap, sizeof(CUS_CAMSENSOR_CAP)); - else return FAIL; - return SUCCESS; -} -#endif - -/////////////////////////////////////////////////////////////////////// -// auto exposure -/////////////////////////////////////////////////////////////////////// -// unit: micro seconds -//AE status notification -static int pCus_AEStatusNotify(ms_cus_sensor *handle, CUS_CAMSENSOR_AE_STATUS_NOTIFY status) -{ - imx274_params *params = (imx274_params *)handle->private_data; - - switch(status) - { - case CUS_FRAME_INACTIVE: - //SensorReg_Write(0x3001,0); - break; - case CUS_FRAME_ACTIVE: - if(params->dirty) - { - SensorReg_Write(0x302d,1); - SensorRegArrayW((I2C_ARRAY*)params->tExpo_reg, ARRAY_SIZE(expo_reg)); - SensorRegArrayW((I2C_ARRAY*)params->tGain_reg, ARRAY_SIZE(gain_reg)); - SensorRegArrayW((I2C_ARRAY*)params->tVts_reg, ARRAY_SIZE(vts_reg)); - SensorReg_Write(0x302d,0); - params->dirty = false; - } - break; - default : - break; - } - return SUCCESS; -} - -static int pCus_AEStatusNotifyHDR_DOL_LEF(ms_cus_sensor *handle, CUS_CAMSENSOR_AE_STATUS_NOTIFY status) -{ - imx274_params *params = (imx274_params *)handle->private_data; - //ISensorIfAPI2 *sensor_if1 = handle->sensor_if_api2; - - switch(status) - { - case CUS_FRAME_INACTIVE: - //SensorReg_Write(0x3001,0); - break; - case CUS_FRAME_ACTIVE: - if(params->dirty) - { - SensorReg_Write(0x302d, 1); - SensorRegArrayW((I2C_ARRAY*)params->tExpo_shr_dol2_reg, ARRAY_SIZE(expo_shr_dol2_reg)); - SensorRegArrayW((I2C_ARRAY*)params->tVts_reg, ARRAY_SIZE(vts_reg)); - SensorRegArrayW((I2C_ARRAY*)params->tExpo_shr_dol1_reg, ARRAY_SIZE(expo_shr_dol1_reg)); - SensorRegArrayW((I2C_ARRAY*)params->tExpo_rhs1_reg, ARRAY_SIZE(expo_rhs1_reg)); - SensorRegArrayW((I2C_ARRAY*)params->tGain_reg, ARRAY_SIZE(gain_reg)); - SensorReg_Write(0x302d, 0); - params->dirty = false; - } - break; - default : - break; - } - - return SUCCESS; -} - -static int pCus_GetAEUSecs_hdr_dol_lef(ms_cus_sensor *handle, u32 *us) -{ - *us = 0; - return SUCCESS; -} - -static int pCus_AEStatusNotifyHDR_DOL_SEF(ms_cus_sensor *handle, CUS_CAMSENSOR_AE_STATUS_NOTIFY status) -{ - // imx274_params *params = (imx274_params *)handle->private_data; - - switch(status) - { - case CUS_FRAME_INACTIVE: - //SensorReg_Write(0x3001,0); - break; - case CUS_FRAME_ACTIVE: - break; - default : - break; - } - return SUCCESS; -} - -static int pCus_SetAEUSecsHDR_DOL_LEF(ms_cus_sensor *handle, u32 us) -{ - u32 lines = 0, vts = 0, shr_dol2 = 0; - imx274_params *params = (imx274_params *)handle->private_data; - - // us = 1000000/30; - //lines = us/Preview_line_period_HDR_DOL; - lines = (1000 * us) / Preview_line_period_HDR_DOL; - if (lines > params->expo.vts - 4) { - vts = lines + 4; - } - else{ - vts = params->expo.vts; - } - - // lines=us/Preview_line_period_HDR_DOL; - SENSOR_DMSG("[%s] us %ld, lines %ld, vts %ld\n", __FUNCTION__, - us, - lines, - params->expo.vts - ); - - shr_dol2 = vts - lines; - - params->tExpo_shr_dol2_reg[0].data = (shr_dol2 >> 8) & 0x00ff; - params->tExpo_shr_dol2_reg[1].data = (shr_dol2 >> 0) & 0x00ff; - - params->tVts_reg[0].data = (vts >> 16) & 0x000f; - params->tVts_reg[1].data = (vts >> 8) & 0x00ff; - params->tVts_reg[2].data = (vts >> 0) & 0x00ff; - - //SensorReg_Write(0x3001,1); - //SensorRegArrayW((I2C_ARRAY*)expo_SHS2_reg, ARRAY_SIZE(expo_SHS2_reg)); - //SensorRegArrayW((I2C_ARRAY*)params->tGain_reg, ARRAY_SIZE(gain_reg)); - //SensorRegArrayW((I2C_ARRAY*)params->tVts_reg, ARRAY_SIZE(vts_reg)); - //SENSOR_EMSG("[LEF, us:%d, lines:%d, ", us, lines); - //SENSOR_EMSG("vts:%d, shr_dol2:%d]\n", vts, shr_dol2); - - params->dirty = true; - return SUCCESS; -} - -static int pCus_GetAEGain_hdr_dol_lef(ms_cus_sensor *handle, u32* gain) -{ - *gain = 0; - return SUCCESS; -} - -static int pCus_SetAEUSecsHDR_DOL_SEF(ms_cus_sensor *handle, u32 us) -{ - u32 lines = 0, vts = 0; - u32 rhs1 = 0, shr_dol1 = 0, shr_dol2 = 0; - u32 max_rhs1 = 0; - imx274_params *params = (imx274_params *)handle->private_data; - - params->expo.expo_sef_us = us; - - // us = 1000000/30; - //lines = us/Preview_line_period_HDR_DOL; - lines = (1000 * us) / Preview_line_period_HDR_DOL; - vts = (params->tVts_reg[0].data << 16) | (params->tVts_reg[1].data << 8) | (params->tVts_reg[2].data << 0); - - shr_dol2 = ((params->tExpo_shr_dol2_reg[0].data << 8) | (params->tExpo_shr_dol2_reg[1].data << 0)); - - max_rhs1 = params->vts_to_rhs1 - 2198 - Preview_CROP_START_Y_DOL; - - //rhs1 = ((params->tExpo_rhs1_reg[0].data << 8) | (params->tExpo_rhs1_reg[1].data << 0)); - rhs1 = max_rhs1; - - if((rhs1 - 6) < lines){ - shr_dol1 = 6; - } - else if((rhs1 <= max_rhs1) && (rhs1 <= shr_dol2 - 6)){ - shr_dol1 = rhs1 - lines; - if((shr_dol1 < 6) || (shr_dol1 > (rhs1 - 2))){ //Check boundary - //shs1 = 0; - //UartSendTrace("\n\n[SEF NG1]\n"); - } - } - else{ - //UartSendTrace("\n\n[SEF NG2]\n"); - } - - //SENSOR_EMSG("[SEF, us:%d, lines:%d, ", us, lines); - //SENSOR_EMSG("vts:%d, shr_dol2:%d, ", vts, shr_dol2); - //SENSOR_EMSG("rhs1:%d, shr_dol1:%d]\n", rhs1, shr_dol1); - - params->tExpo_shr_dol1_reg[0].data = (shr_dol1 >> 8) & 0x00ff; - params->tExpo_shr_dol1_reg[1].data = (shr_dol1 >> 0) & 0x00ff; - - params->tExpo_rhs1_reg[0].data = (rhs1 >> 8) & 0x00ff; - params->tExpo_rhs1_reg[1].data = (rhs1 >> 0) & 0x00ff; - - return SUCCESS; -} - -static int pCus_SetAEUSecsHDR_DOL_SEF_Binning(ms_cus_sensor *handle, u32 us) -{ - u32 lines = 0, vts = 0; - u32 rhs1 = 0, shr_dol1 = 0, shr_dol2 = 0; - u32 max_rhs1 = 0; - imx274_params *params = (imx274_params *)handle->private_data; - - // us = 1000000/30; - //lines = us/Preview_line_period_HDR_DOL; - lines = (1000 * us) / Preview_line_period_HDR_DOL; - vts = (params->tVts_reg[0].data << 16) | (params->tVts_reg[1].data << 8) | (params->tVts_reg[2].data << 0); - - shr_dol2 = ((params->tExpo_shr_dol2_reg[0].data << 8) | (params->tExpo_shr_dol2_reg[1].data << 0)); - - max_rhs1 = params->vts_to_rhs1 - 2198 - Preview_CROP_START_Y_DOL; - - //rhs1 = ((params->tExpo_rhs1_reg[0].data << 8) | (params->tExpo_rhs1_reg[1].data << 0)); - rhs1 = max_rhs1; - - if((rhs1 - 4) < lines){ - shr_dol1 = 4; - } - else if((rhs1 <= max_rhs1) && (rhs1 <= shr_dol2 - 4)){ - shr_dol1 = rhs1 - lines; - if((shr_dol1 < 4) || (shr_dol1 > (rhs1 - 2))){ //Check boundary - //shs1 = 0; - //UartSendTrace("\n\n[SEF NG1]\n"); - } - } - else{ - //UartSendTrace("\n\n[SEF NG2]\n"); - } - - //SENSOR_EMSG("[SEF, us:%d, lines:%d, ", us, lines); - //SENSOR_EMSG("vts:%d, shr_dol2:%d, ", vts, shr_dol2); - //SENSOR_EMSG("rhs1:%d, shr_dol1:%d]\n", rhs1, shr_dol1); - - params->tExpo_shr_dol1_reg[0].data = (shr_dol1 >> 8) & 0x00ff; - params->tExpo_shr_dol1_reg[1].data = (shr_dol1 >> 0) & 0x00ff; - - params->tExpo_rhs1_reg[0].data = (rhs1 >> 8) & 0x00ff; - params->tExpo_rhs1_reg[1].data = (rhs1 >> 0) & 0x00ff; - - return SUCCESS; -} - - -static int pCus_GetAEUSecs(ms_cus_sensor *handle, u32 *us) -{ - imx274_params *params = (imx274_params *)handle->private_data; - u32 lines = 0; - //int rc = SensorRegArrayR((I2C_ARRAY*)params->tExpo_reg, ARRAY_SIZE(expo_reg)); - lines |= (u32)(params->tExpo_reg[0].data&0xff)<<8; - lines |= (u32)(params->tExpo_reg[1].data&0xff)<<0; - // lines >>= 4; - // *us = (lines+dummy) * params->expo.us_per_line; - //*us = lines;//(lines*Preview_line_period); - *us = lines*Preview_line_period/1000; - SENSOR_DMSG("[%s] sensor expo lines/us %ld,%ld us\n", __FUNCTION__, lines, *us); - //return rc; - return SUCCESS; -} - -static int pCus_SetAEUSecs(ms_cus_sensor *handle, u32 us) -{ - u32 lines = 0, vts = 0; - imx274_params *params = (imx274_params *)handle->private_data; - - params->expo.expo_lef_us = us; - lines=(1000*us)/Preview_line_period; - - if (lines >params->expo.vts-12) { - vts = lines +12; - } - else - vts=params->expo.vts; - -#if 0 - // lines=us/Preview_line_period; - SENSOR_DMSG("[%s] us %ld, lines %ld, vts %ld\n", __FUNCTION__, - us, - lines, - params->expo.vts - ); -#endif - lines=vts-lines; - - params->tExpo_reg[0].data =(u16)((lines>>8) & 0x00ff); - params->tExpo_reg[1].data =(u16)((lines>>0) & 0x00ff); - - params->tVts_reg[0].data =(u16)((vts >> 16) & 0x000f); - params->tVts_reg[1].data = (u16)((vts >> 8) & 0x00ff); - params->tVts_reg[2].data = (u16)((vts >> 0) & 0x00ff); - - //SensorReg_Write(0x302d,1); - //SensorRegArrayW((I2C_ARRAY*)params->tExpo_reg, ARRAY_SIZE(expo_reg)); - //SensorRegArrayW((I2C_ARRAY*)params->tGain_reg, ARRAY_SIZE(gain_reg)); - //SensorRegArrayW((I2C_ARRAY*)params->tVts_reg, ARRAY_SIZE(vts_reg)); - params->dirty = true; - return SUCCESS; -} - -// Gain: 1x = 1024 -static int pCus_GetAEGain(ms_cus_sensor *handle, u32* gain) -{ - imx274_params *params = (imx274_params *)handle->private_data; - //u16 temp_gain; - //double temp_gain_double; - - *gain=params->expo.final_gain; - SENSOR_DMSG("[%s] get gain/regL/regH (1024=1X)= %d/0x%x/0x%x\n", __FUNCTION__, *gain, params->tGain_reg[0].data, params->tGain_reg[1].data); - - return SUCCESS; -} - -static int pCus_SetAEGain_cal(ms_cus_sensor *handle, u32 gain) -{ - imx274_params *params = (imx274_params *)handle->private_data; - u16 gain16; - //double gain_double; - - params->expo.final_gain = gain; - if(gain=SENSOR_MAX_GAIN) - gain=SENSOR_MAX_GAIN; - - gain16=(u16)(2048-((2048*1024)/gain)); - //gain16=(u16)(gain_double*10); - - params->tGain_reg[0].data=(gain16>>8)&0x07;//MSB - params->tGain_reg[1].data=gain16&0xff;//LSB - - SENSOR_DMSG("[%s] set gain/reg0/reg1=%d/0x%x/0x%x\n", __FUNCTION__, gain, params->tGain_reg[0].data, params->tGain_reg[1].data); - return SUCCESS; - -} - -static int pCus_SetAEGain(ms_cus_sensor *handle, u32 gain) -{ - //extern DBG_ITEM Dbg_Items[DBG_TAG_MAX]; - imx274_params *params = (imx274_params *)handle->private_data; - u32 i; - //double gain_double; - CUS_GAIN_GAP_ARRAY* Sensor_Gain_Linearity; - u16 gain16; - - params->expo.final_gain = gain; - if(gain=SENSOR_MAX_GAIN) - gain=SENSOR_MAX_GAIN; - - //gain_double=(double)gain; - Sensor_Gain_Linearity = gain_gap_compensate; - - for(i = 0; i < sizeof(gain_gap_compensate)/sizeof(CUS_GAIN_GAP_ARRAY); i++){ - //LOGD("GAP:%x %x\r\n",Sensor_Gain_Linearity[i].gain, Sensor_Gain_Linearity[i].offset); - - if (Sensor_Gain_Linearity[i].gain == 0) - break; - if((gain>Sensor_Gain_Linearity[i].gain) && (gain < (Sensor_Gain_Linearity[i].gain + Sensor_Gain_Linearity[i].offset))){ - gain=Sensor_Gain_Linearity[i].gain; - break; - } - } -#if 0 - gain16=(u16)(2048-((2048*1024)/gain)); - //gain16=(u16)(gain_double*10); - params->tGain_reg[0].data=(gain16>>8)&0x07;//MSB - params->tGain_reg[1].data=gain16&0xff;//LSB -#else - - if(gain<=23040){ - gain16=(u16)(2048-((2048*1024)/gain)); - params->tGain_reg[0].data=(gain16>>8)&0x07;//MSB - params->tGain_reg[1].data=gain16&0xff;//LSB - params->tGain_reg[2].data=0x00; - } else if((gain>23040)&&(gain<=46080)){ - gain=gain>>1; - gain16=(u16)(2048-((2048*1024)/gain)); - params->tGain_reg[0].data=(gain16>>8)&0x07;//MSB - params->tGain_reg[1].data=gain16&0xff;//LSB - params->tGain_reg[2].data=0x01; - } else if((gain>46080)&&(gain<=92160)){ - gain=gain>>2; - gain16=(u16)(2048-((2048*1024)/gain)); - params->tGain_reg[0].data=(gain16>>8)&0x07;//MSB - params->tGain_reg[1].data=gain16&0xff;//LSB - params->tGain_reg[2].data=0x02; - } else if ((gain>92160)&&(gain<=184320)){//if((gain>22.5*1024*4)&&(gain<=22.5*1024*8)){ - gain=gain>>3; - gain16=(u16)(2048-((2048*1024)/gain)); - params->tGain_reg[0].data=(gain16>>8)&0x07;//MSB - params->tGain_reg[1].data=gain16&0xff;//LSB - params->tGain_reg[2].data=0x03; - } else if ((gain>184320)&&(gain<=368640)){//if((gain>22.5*1024*8)&&(gain<=22.5*1024*16)){ - gain=gain>>4; - gain16=(u16)(2048-((2048*1024)/gain)); - params->tGain_reg[0].data=(gain16>>8)&0x07;//MSB - params->tGain_reg[1].data=gain16&0xff;//LSB - params->tGain_reg[2].data=0x04; - } else if ((gain>368640)&&(gain<=737280)){//if((gain>22.5*1024*16)&&(gain<=22.5*1024*32)){ - gain=gain>>5; - gain16=(u16)(2048-((2048*1024)/gain)); - params->tGain_reg[0].data=(gain16>>8)&0x07;//MSB - params->tGain_reg[1].data=gain16&0xff;//LSB - params->tGain_reg[2].data=0x05; - } else {//if((gain>22.5*1024*32)&&(gain<=22.5*1024*64)){ - gain=gain>>6; - gain16=(u16)(2048-((2048*1024)/gain)); - params->tGain_reg[0].data=(gain16>>8)&0x07;//MSB - params->tGain_reg[1].data=gain16&0xff;//LSB - params->tGain_reg[2].data=0x06; - } - params->dirty = true; -#endif - - SENSOR_DMSG("[%s] set gain/reg0/reg1=%d/0x%x/0x%x\n", __FUNCTION__, gain, params->tGain_reg[0].data, params->tGain_reg[1].data); - return SUCCESS; -} - -static int pCus_GetAEMinMaxUSecs(ms_cus_sensor *handle, u32 *min, u32 *max) -{ - *min = 1; - *max = 1000000/30; - return SUCCESS; -} - -static int pCus_GetAEMinMaxGain(ms_cus_sensor *handle, u32 *min, u32 *max) -{ - *min =handle->sat_mingain; - *max = SENSOR_MAX_GAIN; - return SUCCESS; -} - -static int pCus_GetShutterInfo(struct __ms_cus_sensor* handle,CUS_SHUTTER_INFO *info) -{ - info->max = 1000000000/Preview_MIN_FPS; - info->min = Preview_line_period*4; - info->step = Preview_line_period; - return SUCCESS; -} - -static int pCus_poweron_hdr_dol_lef(ms_cus_sensor *handle, u32 idx) -{ - return SUCCESS; -} - -static int pCus_poweroff_hdr_dol_lef(ms_cus_sensor *handle, u32 idx) -{ - return SUCCESS; -} -static int pCus_GetSensorID_hdr_dol_lef(ms_cus_sensor *handle, u32 *id) -{ - *id = 0; - return SUCCESS; -} -static int pCus_init_hdr_dol_lef(ms_cus_sensor *handle) -{ - return SUCCESS; -} -#if 0 -static int pCus_GetVideoRes_hdr_dol_lef( ms_cus_sensor *handle, u32 res_idx, cus_camsensor_res **res ) -{ - *res = &handle->video_res_supported.res[res_idx]; - return SUCCESS; -} - -static int pCus_SetVideoRes_hdr_dol_lef( ms_cus_sensor *handle, u32 res ) -{ - handle->video_res_supported.ulcur_res = 0; //TBD - return SUCCESS; -} -#endif -static int pCus_GetOrien_hdr_dol_lef(ms_cus_sensor *handle, CUS_CAMSENSOR_ORIT *orit) -{ - *orit = CUS_ORIT_M0F0; - return SUCCESS; -} - -static int pCus_SetOrien_hdr_dol_lef(ms_cus_sensor *handle, CUS_CAMSENSOR_ORIT orit) -{ - return SUCCESS; -} - -static int pCus_GetFPS_hdr_dol_lef(ms_cus_sensor *handle) -{ - imx274_params *params = (imx274_params *)handle->private_data; - u32 max_fps = handle->video_res_supported.res[handle->video_res_supported.ulcur_res].max_fps; - u32 tVts = (params->tVts_reg[0].data << 16) | (params->tVts_reg[1].data << 8) | (params->tVts_reg[2].data << 0); - - if (params->expo.fps >= 1000) - params->expo.preview_fps = (vts_30fps_HDR_DOL*max_fps*1000)/tVts; - else - params->expo.preview_fps = (vts_30fps_HDR_DOL*max_fps)/tVts; - - return params->expo.preview_fps; -} - -static int pCus_SetFPS_hdr_dol_lef(ms_cus_sensor *handle, u32 fps) -{ - imx274_params *params = (imx274_params *)handle->private_data; - u32 max_fps = handle->video_res_supported.res[handle->video_res_supported.ulcur_res].max_fps; - u32 min_fps = handle->video_res_supported.res[handle->video_res_supported.ulcur_res].min_fps; - - if(fps>=min_fps && fps <= max_fps){ - params->expo.fps = fps; - params->expo.vts= (vts_30fps_HDR_DOL*max_fps)/fps; - }else if((fps >= (min_fps*1000)) && (fps <= (max_fps*1000))){ - params->expo.fps = fps; - params->expo.vts= (vts_30fps_HDR_DOL*(max_fps*1000))/fps; - }else{ - //params->expo.vts=vts_30fps; - //params->expo.fps=30; - SENSOR_DMSG("[%s] FPS %d out of range.\n",__FUNCTION__,fps); - return FAIL; - } - - pCus_SetAEUSecsHDR_DOL_LEF(handle, params->expo.expo_lef_us); - params->dirty = true; //reg need to update = true; - return SUCCESS; -} -static int pCus_GetShutterInfo_hdr_dol_lef(struct __ms_cus_sensor* handle,CUS_SHUTTER_INFO *info) -{ - info->max = 1000000000/Preview_MIN_FPS; - info->min = (Preview_line_period_HDR_DOL * 4); - info->step = Preview_line_period_HDR_DOL; - return SUCCESS; -} -static int pCus_GetShutterInfo_hdr_dol_sef(struct __ms_cus_sensor* handle,CUS_SHUTTER_INFO *info) -{ - imx274_params *params = (imx274_params *)handle->private_data; - u32 max_rhs1 = params->vts_to_rhs1 - 2198 - Preview_CROP_START_Y_DOL; - - info->max = Preview_line_period_HDR_DOL * max_rhs1; - info->min = (Preview_line_period_HDR_DOL * 2); - info->step = Preview_line_period_HDR_DOL; - return SUCCESS; -} -static int pCus_setCaliData_gain_linearity_hdr_dol_lef(ms_cus_sensor* handle, CUS_GAIN_GAP_ARRAY* pArray, u32 num) -{ - return SUCCESS; -} -static int pCus_SetAEGain_cal_hdr_dol_lef(ms_cus_sensor *handle, u32 gain) -{ - return SUCCESS; -} -static int pCus_setCaliData_gain_linearity(ms_cus_sensor* handle, CUS_GAIN_GAP_ARRAY* pArray, u32 num) { - u32 i, j; - - for(i=0,j=0;i< num ;i++,j+=2){ - gain_gap_compensate[i].gain=pArray[i].gain; - gain_gap_compensate[i].offset=pArray[i].offset; - } - - SENSOR_DMSG("[%s]%d, %d, %d, %d\n", __FUNCTION__, num, pArray[0].gain, pArray[1].gain, pArray[num-1].offset); - - return SUCCESS; -} - -int cus_camsensor_init_handle_linear(ms_cus_sensor* drv_handle) -{ - ms_cus_sensor *handle = drv_handle; - imx274_params *params; - - if (!handle) { - SENSOR_DMSG("[%s] not enough memory!\n", __FUNCTION__); - return FAIL; - } - SENSOR_DMSG("[%s]", __FUNCTION__); - //private data allocation & init - if (handle->private_data == NULL) { - SENSOR_EMSG("[%s] Private data is empty!\n", __FUNCTION__); - return FAIL; - } - params = (imx274_params *)handle->private_data; - memcpy(params->tVts_reg, vts_reg, sizeof(vts_reg)); - memcpy(params->tGain_reg, gain_reg, sizeof(gain_reg)); - memcpy(params->tExpo_reg, expo_reg, sizeof(expo_reg)); - memcpy(params->tExpo_shr_dol1_reg, expo_shr_dol1_reg, sizeof(expo_shr_dol1_reg)); - memcpy(params->tExpo_rhs1_reg, expo_rhs1_reg, sizeof(expo_rhs1_reg)); - memcpy(params->tExpo_shr_dol2_reg, expo_shr_dol2_reg, sizeof(expo_shr_dol2_reg)); - - //////////////////////////////////// - // sensor model ID // - //////////////////////////////////// - sprintf(handle->model_id,"IMX274_MIPI"); - - //////////////////////////////////// - // sensor interface info // - //////////////////////////////////// - //SENSOR_DMSG("[%s] entering function with id %d\n", __FUNCTION__, id); - //handle->isp_type = SENSOR_ISP_TYPE; //ISP_SOC; - //handle->data_fmt = SENSOR_DATAFMT; //CUS_DATAFMT_YUV; - handle->sif_bus = SENSOR_IFBUS_TYPE;//CUS_SENIF_BUS_PARL; - handle->data_prec = SENSOR_DATAPREC; //CUS_DATAPRECISION_8; - handle->data_mode = SENSOR_DATAMODE; - handle->bayer_id = SENSOR_BAYERID; //CUS_BAYER_GB; - handle->RGBIR_id = SENSOR_RGBIRID; - handle->orient = SENSOR_ORIT; //CUS_ORIT_M1F1; - //handle->YC_ODER = SENSOR_YCORDER; //CUS_SEN_YCODR_CY; - handle->interface_attr.attr_mipi.mipi_lane_num = SENSOR_MIPI_LANE_NUM; - handle->interface_attr.attr_mipi.mipi_data_format = CUS_SEN_INPUT_FORMAT_RGB; // RGB pattern. - handle->interface_attr.attr_mipi.mipi_yuv_order = 0; //don't care in RGB pattern. - handle->interface_attr.attr_mipi.mipi_hsync_mode = SENSOR_MIPI_HSYNC_MODE; - handle->interface_attr.attr_mipi.mipi_hdr_mode = CUS_HDR_MODE_NONE; - handle->interface_attr.attr_mipi.mipi_hdr_virtual_channel_num = 0; //Short frame - - //////////////////////////////////// - // resolution capability // - //////////////////////////////////// - handle->video_res_supported.num_res = 1; - handle->video_res_supported.ulcur_res = 0; //default resolution index is 0. - handle->video_res_supported.res[0].width = Preview_WIDTH; - handle->video_res_supported.res[0].height = Preview_HEIGHT; - handle->video_res_supported.res[0].max_fps= Preview_MAX_FPS; - handle->video_res_supported.res[0].min_fps= Preview_MIN_FPS; - handle->video_res_supported.res[0].crop_start_x= Preview_CROP_START_X; - handle->video_res_supported.res[0].crop_start_y= Preview_CROP_START_Y; - handle->video_res_supported.res[0].nOutputWidth= 3864; - handle->video_res_supported.res[0].nOutputHeight= 2202; - sprintf(handle->video_res_supported.res[0].strResDesc, "3840x2160@15fps"); - - handle->video_res_supported.num_res = 2; - handle->video_res_supported.ulcur_res = 0; //default resolution index is 0. - handle->video_res_supported.res[1].width = Preview_WIDTH; - handle->video_res_supported.res[1].height = Preview_HEIGHT; - handle->video_res_supported.res[1].max_fps= 20; - handle->video_res_supported.res[1].min_fps= Preview_MIN_FPS; - handle->video_res_supported.res[1].crop_start_x= Preview_CROP_START_X; - handle->video_res_supported.res[1].crop_start_y= Preview_CROP_START_Y; - handle->video_res_supported.res[1].nOutputWidth= 3864; - handle->video_res_supported.res[1].nOutputHeight= 2202; - sprintf(handle->video_res_supported.res[1].strResDesc, "3840x2160@20fps"); - - handle->video_res_supported.num_res = 3; - handle->video_res_supported.ulcur_res = 0; //default resolution index is 0. - handle->video_res_supported.res[2].width = 2592; - handle->video_res_supported.res[2].height = 1944; - handle->video_res_supported.res[2].max_fps= 30; - handle->video_res_supported.res[2].min_fps= Preview_MIN_FPS; - handle->video_res_supported.res[2].crop_start_x= Preview_CROP_START_X; - handle->video_res_supported.res[2].crop_start_y= Preview_CROP_START_Y; - handle->video_res_supported.res[2].nOutputWidth= 2592; - handle->video_res_supported.res[2].nOutputHeight= 1944; - sprintf(handle->video_res_supported.res[2].strResDesc, "2592x1944@30fps"); - - handle->video_res_supported.num_res = 4; - handle->video_res_supported.ulcur_res = 0; //default resolution index is 0. - handle->video_res_supported.res[3].width = 2944; - handle->video_res_supported.res[3].height = 1656; - handle->video_res_supported.res[3].max_fps= 30; - handle->video_res_supported.res[3].min_fps= Preview_MIN_FPS; - handle->video_res_supported.res[3].crop_start_x= Preview_CROP_START_X; - handle->video_res_supported.res[3].crop_start_y= Preview_CROP_START_Y; - handle->video_res_supported.res[3].nOutputWidth= 2944; - handle->video_res_supported.res[3].nOutputHeight= 1656; - sprintf(handle->video_res_supported.res[3].strResDesc, "2944x1656@30fps"); - - handle->video_res_supported.num_res = 5; - handle->video_res_supported.ulcur_res = 0; //default resolution index is 0. - handle->video_res_supported.res[4].width = 2560; - handle->video_res_supported.res[4].height = 1440; - handle->video_res_supported.res[4].max_fps= 30; - handle->video_res_supported.res[4].min_fps= Preview_MIN_FPS; - handle->video_res_supported.res[4].crop_start_x= Preview_CROP_START_X; - handle->video_res_supported.res[4].crop_start_y= Preview_CROP_START_Y; - handle->video_res_supported.res[4].nOutputWidth= 2560; - handle->video_res_supported.res[4].nOutputHeight= 1440; - sprintf(handle->video_res_supported.res[4].strResDesc, "2560x1440@30fps"); - - handle->video_res_supported.num_res = 6; - handle->video_res_supported.ulcur_res = 0; //default resolution index is 0. - handle->video_res_supported.res[5].width = 1920; - handle->video_res_supported.res[5].height = 1080; - handle->video_res_supported.res[5].max_fps= 60; - handle->video_res_supported.res[5].min_fps= Preview_MIN_FPS; - handle->video_res_supported.res[5].crop_start_x= Preview_CROP_START_X; - handle->video_res_supported.res[5].crop_start_y= Preview_CROP_START_Y; - handle->video_res_supported.res[5].nOutputWidth= 1920; - handle->video_res_supported.res[5].nOutputHeight= 1080; - sprintf(handle->video_res_supported.res[5].strResDesc, "1920x1080@60fps"); - - handle->video_res_supported.num_res = 7; - handle->video_res_supported.ulcur_res = 0; //default resolution index is 0. - handle->video_res_supported.res[6].width = Preview_WIDTH; - handle->video_res_supported.res[6].height = Preview_HEIGHT; - handle->video_res_supported.res[6].max_fps= 30; - handle->video_res_supported.res[6].min_fps= Preview_MIN_FPS; - handle->video_res_supported.res[6].crop_start_x= Preview_CROP_START_X; - handle->video_res_supported.res[6].crop_start_y= Preview_CROP_START_Y; - handle->video_res_supported.res[6].nOutputWidth= 3864; - handle->video_res_supported.res[6].nOutputHeight= 2202; - sprintf(handle->video_res_supported.res[6].strResDesc, "3840x2160@30fps"); - - // i2c - handle->i2c_cfg.mode = SENSOR_I2C_LEGACY; //(CUS_ISP_I2C_MODE) FALSE; - handle->i2c_cfg.fmt = SENSOR_I2C_FMT; //CUS_I2C_FMT_A16D16; - handle->i2c_cfg.address = SENSOR_I2C_ADDR; //0x5a; - handle->i2c_cfg.speed = SENSOR_I2C_SPEED; //320000; - - // mclk - handle->mclk = Preview_MCLK_SPEED; - - //polarity - ///////////////////////////////////////////////////// - handle->pwdn_POLARITY = SENSOR_PWDN_POL; //CUS_CLK_POL_NEG; - handle->reset_POLARITY = SENSOR_RST_POL; //CUS_CLK_POL_NEG; - handle->VSYNC_POLARITY = SENSOR_VSYNC_POL; //CUS_CLK_POL_POS; - handle->HSYNC_POLARITY = SENSOR_HSYNC_POL; //CUS_CLK_POL_POS; - handle->PCLK_POLARITY = SENSOR_PCLK_POL; //CUS_CLK_POL_POS); // use '!' to clear board latch error - ///////////////////////////////////////////////////// - - //////////////////////////////////////////////////// - // AE parameters - //////////////////////////////////////////////////// - handle->ae_gain_delay = 1;//0;//1; - handle->ae_shutter_delay = 2;//1;//2; - - handle->ae_gain_ctrl_num = 1; - handle->ae_shutter_ctrl_num = 1; - - ///calibration - handle->sat_mingain = SENSOR_MIN_GAIN; - - //LOGD("[%s:%d]\n", __FUNCTION__, __LINE__); - handle->pCus_sensor_release = cus_camsensor_release_handle; - handle->pCus_sensor_init = pCus_init_mipi4lane_linear_4K15fps; - //handle->pCus_sensor_powerupseq = pCus_powerupseq ; - handle->pCus_sensor_poweron = pCus_poweron; - handle->pCus_sensor_poweroff = pCus_poweroff; - - // Normal - handle->pCus_sensor_GetSensorID = pCus_GetSensorID ; - - handle->pCus_sensor_GetVideoResNum = pCus_GetVideoResNum; - handle->pCus_sensor_GetVideoRes = pCus_GetVideoRes; - handle->pCus_sensor_GetCurVideoRes = pCus_GetCurVideoRes; - handle->pCus_sensor_SetVideoRes = pCus_SetVideoRes; - - handle->pCus_sensor_GetOrien = pCus_GetOrien ; - handle->pCus_sensor_SetOrien = pCus_SetOrien ; - handle->pCus_sensor_GetFPS = pCus_GetFPS ; - handle->pCus_sensor_SetFPS = pCus_SetFPS ; - //handle->pCus_sensor_GetSensorCap = pCus_GetSensorCap; - handle->pCus_sensor_SetPatternMode = imx274_SetPatternMode; - /////////////////////////////////////////////////////// - // AE - /////////////////////////////////////////////////////// - // unit: micro seconds - //handle->pCus_sensor_GetAETrigger_mode = pCus_GetAETrigger_mode; - //handle->pCus_sensor_SetAETrigger_mode = pCus_SetAETrigger_mode; - handle->pCus_sensor_AEStatusNotify = pCus_AEStatusNotify; - handle->pCus_sensor_GetAEUSecs = pCus_GetAEUSecs; - handle->pCus_sensor_SetAEUSecs = pCus_SetAEUSecs; - handle->pCus_sensor_GetAEGain = pCus_GetAEGain; - handle->pCus_sensor_SetAEGain = pCus_SetAEGain; - handle->pCus_sensor_SetAEGain_cal = pCus_SetAEGain_cal; - - handle->pCus_sensor_GetAEMinMaxGain = pCus_GetAEMinMaxGain; - handle->pCus_sensor_GetAEMinMaxUSecs= pCus_GetAEMinMaxUSecs; - - //sensor calibration - // handle->pCus_sensor_SetAEGain_cal = pCus_SetAEGain_cal; - handle->pCus_sensor_setCaliData_gain_linearity=pCus_setCaliData_gain_linearity; - handle->pCus_sensor_GetShutterInfo = pCus_GetShutterInfo; - - params->dirty = false; - - return SUCCESS; -} - -int cus_camsensor_init_handle_hdr_dol_sef(ms_cus_sensor* drv_handle) -{ - ms_cus_sensor *handle = drv_handle; - imx274_params *params = NULL; - - cus_camsensor_init_handle_linear(drv_handle); - params = (imx274_params *)handle->private_data; - - sprintf(handle->model_id,"IMX274_MIPI_HDR_SEF"); - - handle->bayer_id = SENSOR_BAYERID_HDR_DOL; - handle->RGBIR_id = SENSOR_RGBIRID; - - handle->interface_attr.attr_mipi.mipi_hsync_mode = SENSOR_MIPI_HSYNC_MODE_HDR_DOL; - handle->interface_attr.attr_mipi.mipi_hdr_mode = CUS_HDR_MODE_SONY_DOL; - - //////////////////////////////////// - // resolution capability // - //////////////////////////////////// - handle->video_res_supported.num_res = 1; - handle->video_res_supported.ulcur_res = 0; //default resolution index is 0. - handle->video_res_supported.res[0].width = Preview_WIDTH; - handle->video_res_supported.res[0].height = Preview_HEIGHT; - handle->video_res_supported.res[0].max_fps= Preview_MAX_FPS; - handle->video_res_supported.res[0].min_fps= Preview_MIN_FPS; - handle->video_res_supported.res[0].crop_start_x= Preview_CROP_START_X; - handle->video_res_supported.res[0].crop_start_y= Preview_CROP_START_Y_DOL; - handle->video_res_supported.res[0].nOutputWidth= 0xF18; - handle->video_res_supported.res[0].nOutputHeight= 0x886; - sprintf(handle->video_res_supported.res[0].strResDesc, "3840x2160@15fps_HDR"); - - handle->video_res_supported.num_res = 2; - handle->video_res_supported.ulcur_res = 0; //default resolution index is 0. - handle->video_res_supported.res[1].width = 1920; - handle->video_res_supported.res[1].height = 1080; - handle->video_res_supported.res[1].max_fps= 30; - handle->video_res_supported.res[1].min_fps= 3; - handle->video_res_supported.res[1].crop_start_x= 0; - handle->video_res_supported.res[1].crop_start_y= Preview_CROP_START_Y_DOL; - handle->video_res_supported.res[1].nOutputWidth= 0x78C; - handle->video_res_supported.res[1].nOutputHeight= 0x44E; - sprintf(handle->video_res_supported.res[1].strResDesc, "1920x1080@30fps_HDR"); - - handle->video_res_supported.num_res = 3; - handle->video_res_supported.ulcur_res = 0; //default resolution index is 0. - handle->video_res_supported.res[2].width = Preview_WIDTH; - handle->video_res_supported.res[2].height = Preview_HEIGHT; - handle->video_res_supported.res[2].max_fps= 20; - handle->video_res_supported.res[2].min_fps= Preview_MIN_FPS; - handle->video_res_supported.res[2].crop_start_x= Preview_CROP_START_X; - handle->video_res_supported.res[2].crop_start_y= Preview_CROP_START_Y_DOL; - handle->video_res_supported.res[2].nOutputWidth= 0xF18; - handle->video_res_supported.res[2].nOutputHeight= 0x886; - sprintf(handle->video_res_supported.res[2].strResDesc, "3840x2160@20fps_HDR"); - - handle->video_res_supported.num_res = 4; - handle->video_res_supported.ulcur_res = 0; //default resolution index is 0. - handle->video_res_supported.res[3].width = Preview_WIDTH; - handle->video_res_supported.res[3].height = Preview_HEIGHT; - handle->video_res_supported.res[3].max_fps= 30; - handle->video_res_supported.res[3].min_fps= Preview_MIN_FPS; - handle->video_res_supported.res[3].crop_start_x= Preview_CROP_START_X; - handle->video_res_supported.res[3].crop_start_y= Preview_CROP_START_Y_DOL; - handle->video_res_supported.res[3].nOutputWidth= 0xF18; - handle->video_res_supported.res[3].nOutputHeight= 0x886; - sprintf(handle->video_res_supported.res[3].strResDesc, "3840x2160@30fps_HDR"); - - handle->pCus_sensor_SetVideoRes = pCus_SetVideoRes_HDR_DOL; - handle->mclk = Preview_MCLK_SPEED_HDR_DOL; - -#if (SENSOR_MIPI_LANE_NUM == 2) -#endif -#if (SENSOR_MIPI_LANE_NUM == 4) - handle->pCus_sensor_init = pCus_init_mipi4lane_HDR_DOL_4k15fps; -#endif - handle->pCus_sensor_GetFPS = pCus_GetFPS_HDR_DOL_SEF; //TBD - handle->pCus_sensor_SetFPS = pCus_SetFPS_HDR_DOL_SEF; //TBD - - handle->pCus_sensor_AEStatusNotify = pCus_AEStatusNotifyHDR_DOL_SEF; - handle->pCus_sensor_GetAEUSecs = pCus_GetAEUSecs; - handle->pCus_sensor_SetAEUSecs = pCus_SetAEUSecsHDR_DOL_SEF; - handle->pCus_sensor_GetAEGain = pCus_GetAEGain; - //handle->pCus_sensor_SetAEGain = pCus_SetAEGain; - handle->pCus_sensor_SetAEGain = pCus_SetAEGain; - handle->pCus_sensor_GetShutterInfo = pCus_GetShutterInfo_hdr_dol_sef; - params->expo.vts = vts_30fps_HDR_DOL; - params->expo.fps = 15; - - handle->data_prec = SENSOR_DATAPREC_HDR_DOL; - handle->interface_attr.attr_mipi.mipi_hdr_virtual_channel_num = 1; //Short frame - - handle->ae_gain_ctrl_num = 1; - handle->ae_shutter_ctrl_num = 2; - - return SUCCESS; -} - -int cus_camsensor_init_handle_hdr_dol_lef(ms_cus_sensor* drv_handle) -{ - ms_cus_sensor *handle = drv_handle; - imx274_params *params; - if (!handle) { - SENSOR_DMSG("[%s] not enough memory!\n", __FUNCTION__); - return FAIL; - } - SENSOR_DMSG("[%s]", __FUNCTION__); - //private data allocation & init - if (handle->private_data == NULL) { - SENSOR_EMSG("[%s] Private data is empty!\n", __FUNCTION__); - return FAIL; - } - params = (imx274_params *)handle->private_data; - memcpy(params->tVts_reg, vts_reg, sizeof(vts_reg)); - memcpy(params->tGain_reg, gain_reg, sizeof(gain_reg)); - memcpy(params->tExpo_reg, expo_reg, sizeof(expo_reg)); - memcpy(params->tExpo_shr_dol1_reg, expo_shr_dol1_reg, sizeof(expo_shr_dol1_reg)); - memcpy(params->tExpo_rhs1_reg, expo_rhs1_reg, sizeof(expo_rhs1_reg)); - memcpy(params->tExpo_shr_dol2_reg, expo_shr_dol2_reg, sizeof(expo_shr_dol2_reg)); - - //////////////////////////////////// - // sensor model ID // - //////////////////////////////////// - sprintf(handle->model_id,"IMX274_MIPI_HDR_LEF"); - - //////////////////////////////////// - // sensor interface info // - //////////////////////////////////// - //SENSOR_DMSG("[%s] entering function with id %d\n", __FUNCTION__, id); - handle->isp_type = SENSOR_ISP_TYPE; //ISP_SOC; - //handle->data_fmt = SENSOR_DATAFMT; //CUS_DATAFMT_YUV; - handle->sif_bus = SENSOR_IFBUS_TYPE;//CUS_SENIF_BUS_PARL; - handle->data_prec = SENSOR_DATAPREC_HDR_DOL; //CUS_DATAPRECISION_8; - handle->data_mode = SENSOR_DATAMODE; - handle->bayer_id = SENSOR_BAYERID_HDR_DOL; //CUS_BAYER_GB; - handle->RGBIR_id = SENSOR_RGBIRID; - handle->orient = SENSOR_ORIT; //CUS_ORIT_M1F1; - //handle->YC_ODER = SENSOR_YCORDER; //CUS_SEN_YCODR_CY; - handle->interface_attr.attr_mipi.mipi_lane_num = SENSOR_MIPI_LANE_NUM; - handle->interface_attr.attr_mipi.mipi_data_format = CUS_SEN_INPUT_FORMAT_RGB; // RGB pattern. - handle->interface_attr.attr_mipi.mipi_yuv_order = 0; //don't care in RGB pattern. - handle->interface_attr.attr_mipi.mipi_hsync_mode = SENSOR_MIPI_HSYNC_MODE_HDR_DOL; - handle->interface_attr.attr_mipi.mipi_hdr_mode = CUS_HDR_MODE_SONY_DOL; - handle->interface_attr.attr_mipi.mipi_hdr_virtual_channel_num = 0; //Long frame - - //////////////////////////////////// - // resolution capability // - //////////////////////////////////// - handle->video_res_supported.num_res = 1; - handle->video_res_supported.ulcur_res = 0; //default resolution index is 0. - handle->video_res_supported.res[0].width = Preview_WIDTH; - handle->video_res_supported.res[0].height = Preview_HEIGHT; - handle->video_res_supported.res[0].max_fps= Preview_MAX_FPS; - handle->video_res_supported.res[0].min_fps= Preview_MIN_FPS; - handle->video_res_supported.res[0].crop_start_x= Preview_CROP_START_X; - handle->video_res_supported.res[0].crop_start_y= Preview_CROP_START_Y_DOL; - handle->video_res_supported.res[0].nOutputWidth= 0xF18; - handle->video_res_supported.res[0].nOutputHeight= 0x886; - sprintf(handle->video_res_supported.res[0].strResDesc, "3840x2160@15fps_HDR"); - - handle->video_res_supported.num_res = 2; - handle->video_res_supported.ulcur_res = 0; //default resolution index is 0. - handle->video_res_supported.res[1].width = 1920; - handle->video_res_supported.res[1].height = 1080; - handle->video_res_supported.res[1].max_fps= 30; - handle->video_res_supported.res[1].min_fps= 3; - handle->video_res_supported.res[1].crop_start_x= 0; - handle->video_res_supported.res[1].crop_start_y= Preview_CROP_START_Y_DOL; - handle->video_res_supported.res[1].nOutputWidth= 0x78C; - handle->video_res_supported.res[1].nOutputHeight= 0x44E; - sprintf(handle->video_res_supported.res[1].strResDesc, "1920x1080@30fps_HDR"); - - handle->video_res_supported.num_res = 3; - handle->video_res_supported.ulcur_res = 0; //default resolution index is 0. - handle->video_res_supported.res[2].width = Preview_WIDTH; - handle->video_res_supported.res[2].height = Preview_HEIGHT; - handle->video_res_supported.res[2].max_fps= 20; - handle->video_res_supported.res[2].min_fps= Preview_MIN_FPS; - handle->video_res_supported.res[2].crop_start_x= Preview_CROP_START_X; - handle->video_res_supported.res[2].crop_start_y= Preview_CROP_START_Y_DOL; - handle->video_res_supported.res[2].nOutputWidth= 0xF18; - handle->video_res_supported.res[2].nOutputHeight= 0x886; - sprintf(handle->video_res_supported.res[2].strResDesc, "3840x2160@20fps_HDR"); - - handle->video_res_supported.num_res = 4; - handle->video_res_supported.ulcur_res = 0; //default resolution index is 0. - handle->video_res_supported.res[3].width = Preview_WIDTH; - handle->video_res_supported.res[3].height = Preview_HEIGHT; - handle->video_res_supported.res[3].max_fps= 30; - handle->video_res_supported.res[3].min_fps= Preview_MIN_FPS; - handle->video_res_supported.res[3].crop_start_x= Preview_CROP_START_X; - handle->video_res_supported.res[3].crop_start_y= Preview_CROP_START_Y_DOL; - handle->video_res_supported.res[3].nOutputWidth= 0xF18; - handle->video_res_supported.res[3].nOutputHeight= 0x886; - sprintf(handle->video_res_supported.res[3].strResDesc, "3840x2160@30fps_HDR"); - - // i2c - handle->i2c_cfg.mode = SENSOR_I2C_LEGACY; //(CUS_ISP_I2C_MODE) FALSE; - handle->i2c_cfg.fmt = SENSOR_I2C_FMT; //CUS_I2C_FMT_A16D16; - handle->i2c_cfg.address = SENSOR_I2C_ADDR; //0x5a; - handle->i2c_cfg.speed = SENSOR_I2C_SPEED; //320000; - - // mclk - handle->mclk = Preview_MCLK_SPEED_HDR_DOL; - - //polarity - ///////////////////////////////////////////////////// - handle->pwdn_POLARITY = SENSOR_PWDN_POL; //CUS_CLK_POL_NEG; - handle->reset_POLARITY = SENSOR_RST_POL; //CUS_CLK_POL_NEG; - handle->VSYNC_POLARITY = SENSOR_VSYNC_POL; //CUS_CLK_POL_POS; - handle->HSYNC_POLARITY = SENSOR_HSYNC_POL; //CUS_CLK_POL_POS; - handle->PCLK_POLARITY = SENSOR_PCLK_POL; //CUS_CLK_POL_POS); // use '!' to clear board latch error - ///////////////////////////////////////////////////// - - - - //////////////////////////////////////////////////// - // AE parameters - //////////////////////////////////////////////////// - handle->ae_gain_delay = 1;//0;//1; - handle->ae_shutter_delay = 2;//1;//2; - - handle->ae_gain_ctrl_num = 1; - handle->ae_shutter_ctrl_num = 2; - - ///calibration - handle->sat_mingain = SENSOR_MIN_GAIN; - - //LOGD("[%s:%d]\n", __FUNCTION__, __LINE__); - handle->pCus_sensor_release = cus_camsensor_release_handle; - handle->pCus_sensor_init = pCus_init_hdr_dol_lef; - //handle->pCus_sensor_powerupseq = pCus_powerupseq ; - handle->pCus_sensor_poweron = pCus_poweron_hdr_dol_lef; - handle->pCus_sensor_poweroff = pCus_poweroff_hdr_dol_lef; - - // Normal - handle->pCus_sensor_GetSensorID = pCus_GetSensorID_hdr_dol_lef; - handle->pCus_sensor_GetVideoResNum = pCus_GetVideoResNum; - handle->pCus_sensor_GetVideoRes = pCus_GetVideoRes; - handle->pCus_sensor_GetCurVideoRes = pCus_GetCurVideoRes; - handle->pCus_sensor_SetVideoRes = pCus_SetVideoRes_HDR_DOL; - handle->pCus_sensor_GetOrien = pCus_GetOrien_hdr_dol_lef; - handle->pCus_sensor_SetOrien = pCus_SetOrien_hdr_dol_lef; - handle->pCus_sensor_GetFPS = pCus_GetFPS_hdr_dol_lef; - handle->pCus_sensor_SetFPS = pCus_SetFPS_hdr_dol_lef; - //handle->pCus_sensor_GetSensorCap = pCus_GetSensorCap_hdr_dol_lef; - //handle->pCus_sensor_SetPatternMode = pCus_SetPatternMode_hdr_dol_lef; - /////////////////////////////////////////////////////// - // AE - /////////////////////////////////////////////////////// - // unit: micro seconds - //handle->pCus_sensor_GetAETrigger_mode = pCus_GetAETrigger_mode; - //handle->pCus_sensor_SetAETrigger_mode = pCus_SetAETrigger_mode; - handle->pCus_sensor_AEStatusNotify = pCus_AEStatusNotifyHDR_DOL_LEF; - handle->pCus_sensor_GetAEUSecs = pCus_GetAEUSecs_hdr_dol_lef; - handle->pCus_sensor_SetAEUSecs = pCus_SetAEUSecsHDR_DOL_LEF; - handle->pCus_sensor_GetAEGain = pCus_GetAEGain_hdr_dol_lef; - //handle->pCus_sensor_SetAEGain = pCus_SetAEGain_hdr_dol_lef; - handle->pCus_sensor_SetAEGain = pCus_SetAEGain; - - handle->pCus_sensor_GetAEMinMaxGain = pCus_GetAEMinMaxGain; - //handle->pCus_sensor_GetAEMinMaxUSecs= pCus_GetAEMinMaxUSecs_hdr_dol_lef; - - //sensor calibration - handle->pCus_sensor_SetAEGain_cal = pCus_SetAEGain_cal_hdr_dol_lef; - handle->pCus_sensor_setCaliData_gain_linearity= pCus_setCaliData_gain_linearity_hdr_dol_lef; - handle->pCus_sensor_GetShutterInfo = pCus_GetShutterInfo_hdr_dol_lef; -#if 0//defined(__MV5_FPGA__) - handle->pCus_sensor_I2CWrite = pCus_I2CWrite_hdr_dol_lef; //Andy Liu - handle->pCus_sensor_I2CRead = pCus_I2CRead_hdr_dol_lef; //Andy Liu -#endif - params->expo.vts = vts_30fps_HDR_DOL; - params->expo.fps = 15; - params->dirty = false; - - return SUCCESS; -} - -int cus_camsensor_release_handle(ms_cus_sensor *handle) -{ - return SUCCESS; -} - -SENSOR_DRV_ENTRY_IMPL_END_EX( IMX274_HDR, - cus_camsensor_init_handle_linear, - cus_camsensor_init_handle_hdr_dol_sef, - cus_camsensor_init_handle_hdr_dol_lef, - imx274_params - ); - - diff --git a/general/package/sigmastar-osdrv-sensor/src/infinity6e/sensor/sensor_imx335_mipi.c b/general/package/sigmastar-osdrv-sensor/src/infinity6e/sensor/sensor_imx335_mipi.c deleted file mode 100644 index 5e5b5847..00000000 --- a/general/package/sigmastar-osdrv-sensor/src/infinity6e/sensor/sensor_imx335_mipi.c +++ /dev/null @@ -1,3458 +0,0 @@ -/* SigmaStar trade secret */ -/* Copyright (c) [2019~2020] SigmaStar Technology. -All rights reserved. - -Unless otherwise stipulated in writing, any and all information contained -herein regardless in any format shall remain the sole proprietary of -SigmaStar and be kept in strict confidence -(SigmaStar Confidential Information) by the recipient. -Any unauthorized act including without limitation unauthorized disclosure, -copying, use, reproduction, sale, distribution, modification, disassembling, -reverse engineering and compiling of the contents of SigmaStar Confidential -Information is unlawful and strictly prohibited. SigmaStar hereby reserves the -rights to any and all damages, losses, costs and expenses resulting therefrom. -*/ - -#ifdef __cplusplus -extern "C" -{ -#endif - -#include -#include -#include - -#ifdef __cplusplus -} -#endif - -SENSOR_DRV_ENTRY_IMPL_BEGIN_EX(IMX335_HDR); - -#ifndef ARRAY_SIZE -#define ARRAY_SIZE CAM_OS_ARRAY_SIZE -#endif - -//#define SENSOR_PAD_GROUP_SET CUS_SENSOR_PAD_GROUP_A -//#define SENSOR_CHANNEL_NUM (0) -#define SENSOR_CHANNEL_MODE CUS_SENSOR_CHANNEL_MODE_REALTIME_NORMAL -#define SENSOR_CHANNEL_MODE_SONY_DOL CUS_SENSOR_CHANNEL_MODE_RAW_STORE_HDR - -//============================================ -#define ENABLE 1 -#define DISABLE 0 -#undef SENSOR_DBG -#define SENSOR_DBG 0 - -#define DEBUG_INFO 0 - -#if SENSOR_DBG == 1 -//#define SENSOR_DMSG(args...) LOGD(args) -//#define SENSOR_DMSG(args...) LOGE(args) -//#define SENSOR_DMSG(args...) printf(args) -#elif SENSOR_DBG == 0 -//#define SENSOR_DMSG(args...) -#endif -/////////////////////////////////////////////////////////////// -// @@@ // -// @ @@ == S t a r t * H e r e == // -// @@ == S t a r t * H e r e == // -// @@ == S t a r t * H e r e == // -// @@@@ // -// // -// Start Step 1 -- show preview on LCM // -// // -// Fill these #define value and table with correct settings // -// camera can work and show preview on LCM // -// // -/////////////////////////////////////////////////////////////// - -//////////////////////////////////// -// Sensor-If Info // -//////////////////////////////////// -//MIPI config begin. -#define SENSOR_MIPI_LANE_NUM (lane_num) //IMX335 Linear mode supports MIPI 2/4 Lane -#define SENSOR_MIPI_LANE_NUM_DOL (4) //(hdr_lane_num)//IMX335 DOL mode supports MIPI 4 Lane -//#define SENSOR_MIPI_HDR_MODE (0) //0: Non-HDR mode. 1:Sony DOL mode - -#define SENSOR_ISP_TYPE ISP_EXT //ISP_EXT, ISP_SOC (Non-used) -#define SENSOR_IFBUS_TYPE CUS_SENIF_BUS_MIPI //CFG //CUS_SENIF_BUS_PARL, CUS_SENIF_BUS_MIPI -#define SENSOR_MIPI_HSYNC_MODE PACKET_HEADER_EDGE1 -#define SENSOR_MIPI_HSYNC_MODE_HDR_DOL PACKET_FOOTER_EDGE -#define SENSOR_DATAPREC CUS_DATAPRECISION_10 -#define SENSOR_DATAPREC_DOL CUS_DATAPRECISION_10 -#define SENSOR_DATAMODE CUS_SEN_10TO12_9098 //CFG -#define SENSOR_BAYERID CUS_BAYER_RG //0h: CUS_BAYER_RG, 1h: CUS_BAYER_GR, 2h: CUS_BAYER_BG, 3h: CUS_BAYER_GB -#define SENSOR_BAYERID_HDR_DOL CUS_BAYER_RG -#define SENSOR_RGBIRID CUS_RGBIR_NONE -#define SENSOR_ORIT CUS_ORIT_M0F0 //CUS_ORIT_M0F0, CUS_ORIT_M1F0, CUS_ORIT_M0F1, CUS_ORIT_M1F1, - -//////////////////////////////////// -// MCLK Info // -//////////////////////////////////// -#define Preview_MCLK_SPEED CUS_CMU_CLK_27MHZ //CUS_CMU_CLK_24MHZ //CUS_CMU_CLK_37P125MHZ//CUS_CMU_CLK_27MHZ -#define Preview_MCLK_SPEED_HDR_DOL CUS_CMU_CLK_27MHZ - -//////////////////////////////////// -// I2C Info // -//////////////////////////////////// -#define SENSOR_I2C_ADDR 0x34 //I2C slave address -#define SENSOR_I2C_SPEED 300000 //200000 //300000 //240000 //I2C speed, 60000~320000 -#define SENSOR_I2C_LEGACY I2C_NORMAL_MODE //usally set CUS_I2C_NORMAL_MODE, if use old OVT I2C protocol=> set CUS_I2C_LEGACY_MODE -#define SENSOR_I2C_FMT I2C_FMT_A16D8 //CUS_I2C_FMT_A8D8, CUS_I2C_FMT_A8D16, CUS_I2C_FMT_A16D8, CUS_I2C_FMT_A16D16 - -//////////////////////////////////// -// Sensor Signal // -//////////////////////////////////// -#define SENSOR_PWDN_POL CUS_CLK_POL_NEG // if PWDN pin High can makes sensor in power down, set CUS_CLK_POL_POS -#define SENSOR_RST_POL CUS_CLK_POL_NEG // if RESET pin High can makes sensor in reset state, set CUS_CLK_POL_NEG - // VSYNC/HSYNC POL can be found in data sheet timing diagram, - // Notice: the initial setting may contain VSYNC/HSYNC POL inverse settings so that condition is different. -#define SENSOR_VSYNC_POL CUS_CLK_POL_NEG // if VSYNC pin High and data bus have data, set CUS_CLK_POL_POS -#define SENSOR_HSYNC_POL CUS_CLK_POL_NEG // if HSYNC pin High and data bus have data, set CUS_CLK_POL_POS -#define SENSOR_PCLK_POL CUS_CLK_POL_NEG // depend on sensor setting, sometimes need to try CUS_CLK_POL_POS or CUS_CLK_POL_NEG - -//////////////////////////////////// -// Sensor ID // -//////////////////////////////////// -//define SENSOR_ID - -#undef SENSOR_NAME -#define SENSOR_NAME IMX335 - -//////////////////////////////////// -// Image Info // -//////////////////////////////////// -static struct { // LINEAR - // Modify it based on number of support resolution - enum {LINEAR_RES_1 = 0, LINEAR_RES_2, LINEAR_RES_END}mode; - // Sensor Output Image info - struct _senout{ - s32 width, height, min_fps, max_fps; - }senout; - // VIF Get Image Info - struct _sensif{ - s32 crop_start_X, crop_start_y, preview_w, preview_h; - }senif; - // Show resolution string - struct _senstr{ - const char* strResDesc; - }senstr; -}imx335_mipi_linear[] = { - {LINEAR_RES_1, {2592, 1944, 3, 25}, {0, 0, 2592, 1944}, {"2592x1944@25fps"}}, - {LINEAR_RES_2, {2592, 1944, 3, 30}, {0, 0, 2592, 1944}, {"2592x1944@30fps"}}, // Modify it -}; - -static struct { // HDR - // Modify it based on number of support resolution - enum {HDR_RES_1 = 0, HDR_RES_2, HDR_RES_3, HDR_RES_END}mode; - // Sensor Output Image info - struct _hsenout{ - s32 width, height, min_fps, max_fps; - }senout; - // VIF Get Image Info - struct _hsensif{ - s32 crop_start_X, crop_start_y, preview_w, preview_h; - }senif; - // Show resolution string - struct _hsenstr{ - const char* strResDesc; - }senstr; -}imx335_mipi_hdr[] = { - {HDR_RES_1, {2592, 1944, 3, 25}, {4, 0, 2592, 1944}, {"2592x1944@25fps_HDR"}}, // Modify it - {HDR_RES_2, {2592, 1944, 3, 20}, {4, 0, 2592, 1944}, {"2592x1944@20fps_HDR"}}, // Modify it - {HDR_RES_3, {2592, 1944, 3, 30}, {4, 0, 2592, 1944}, {"2592x1944@30fps_HDR"}}, // Modify it -}; - -#define IMX335_HDR_BRL 2228 - -u32 Preview_line_period; -u32 vts_30fps; -u32 Preview_MAX_FPS; -u32 Preview_line_period_HDR_DOL; -u32 vts_30fps_HDR_DOL; - -//////////////////////////////////// -// AE Info // -//////////////////////////////////// -#define SENSOR_MAX_GAIN (1412 * 1024) // max sensor again, a-gain * conversion-gain*d-gain -#define SENSOR_MIN_GAIN (1 * 1024) -#define SENSOR_GAIN_DELAY_FRAME_COUNT (2) -#define SENSOR_SHUTTER_DELAY_FRAME_COUNT (2) -#define SENSOR_GAIN_DELAY_FRAME_COUNT_HDR_DOL (1) -#define SENSOR_SHUTTER_DELAY_FRAME_COUNT_HDR_DOL (2) - -//////////////////////////////////// -// Mirror-Flip Info // -//////////////////////////////////// -#define REG_MIRROR 0x304E -#define REG_FLIP 0x304F -#define SENSOR_NOR 0x0 -#define MIRROR_EN 0x1 << (0) -#define FLIP_EN 0x1 << (0) - -#if defined (SENSOR_MODULE_VERSION) -#define TO_STR_NATIVE(e) #e -#define TO_STR_PROXY(m, e) m(e) -#define MACRO_TO_STRING(e) TO_STR_PROXY(TO_STR_NATIVE, e) -static char *sensor_module_version = MACRO_TO_STRING(SENSOR_MODULE_VERSION); -module_param(sensor_module_version, charp, S_IRUGO); -#endif - -//static int pCus_SetAEGain(ms_cus_sensor *handle, u32 gain); -static int pCus_SetAEUSecs(ms_cus_sensor *handle, u32 us); -static int pCus_SetOrien(ms_cus_sensor *handle, CUS_CAMSENSOR_ORIT orit); -static int pCus_SetAEUSecsHDR_DOL_SEF1(ms_cus_sensor *handle, u32 us); -static int pCus_SetAEUSecsHDR_DOL_LEF(ms_cus_sensor *handle, u32 us); - -typedef struct { - struct { - u16 pre_div0; - u16 div124; - u16 div_cnt7b; - u16 sdiv0; - u16 mipi_div0; - u16 r_divp; - u16 sdiv1; - u16 r_seld5; - u16 r_sclk_dac; - u16 sys_sel; - u16 pdac_sel; - u16 adac_sel; - u16 pre_div_sp; - u16 r_div_sp; - u16 div_cnt5b; - u16 sdiv_sp; - u16 div12_sp; - u16 mipi_lane_sel; - u16 div_dac; - } clk_tree; - struct { - bool bVideoMode; - u16 res_idx; - CUS_CAMSENSOR_ORIT orit; - } res; - struct { - float sclk; - u32 hts; - u32 vts; - u32 ho; - u32 xinc; - u32 line_freq; - u32 us_per_line; - u32 final_us; - u32 final_gain; - u32 back_pv_us; - u32 fps; - u32 preview_fps; - u32 expo_lines; - u32 expo_lef_us; - u32 expo_sef_us; - } expo; - u32 max_rhs1; - int sen_init; - int still_min_fps; - int video_min_fps; - bool dirty; - bool orien_dirty; - I2C_ARRAY tVts_reg[3]; - I2C_ARRAY tGain_reg[2]; - I2C_ARRAY tExpo_reg[3]; - I2C_ARRAY tExpo_shr_dol1_reg[3]; - I2C_ARRAY tExpo_rhs1_reg[3]; - I2C_ARRAY tGain_hdr_dol_lef_reg[2]; - I2C_ARRAY tGain_hdr_dol_sef_reg[2]; -} imx335_params; - -// set sensor ID address and data, -const static I2C_ARRAY Sensor_id_table[] = -{ - {0x3003, 0x00}, // {address of ID, ID }, - {0x3033, 0x00} -}; - -const static I2C_ARRAY Sensor_init_table_2lane_5m25fps[] = -{ - /*"IMX335LQN All-pixel scan CSI-2_2lane 1188Mbps AD:10bit Output:10bit 27MHz Master Mode 25fps"*/ - {0x3002,0x01}, //Master mode stop - {0xffff,0x14}, //delay - {0x3000,0x01}, //standby - {0xffff,0x14}, //delay - {0x300C,0x42}, //BCWAIT_TIME - {0x300D,0x2E}, //CPWAIT_TIME - {0x3030,0x56}, //VMAX //101Dh: 4125 //1518h: 5400 - {0x3031,0x13}, //VMAX - {0x3032,0x00}, //VMAX - {0x3034,0x58}, //HMAX //2D0h: 720 //226h: 550 - {0x3035,0x02}, //HMAX - {0x3050,0x00}, //ADBIT - - {0x305a,0x00}, // bit0-3(16-18) - {0x3059,0x0E}, // bit0-7(8-15) - {0x3058,0x80}, // bit0-7 - - {0x314C,0xB0}, //INCKSEL1 - {0x315A,0x02}, //INCKSEL2 - {0x3168,0x8F}, //INCKSEL3 - {0x316A,0x7E}, //INCKSEL4 - {0x319D,0x00}, //MDBIT 0:10Bit 1:12Bit - {0x31A0,0x2A}, //XH&VSOUTSEL - {0x31A1,0x00}, //XVS/XHS pin setting - {0x31A4,0x00}, //PULSE1_UP - {0x31A5,0x00}, //PULSE1_UP - {0x31A6,0x00}, //PULSE1_UP - {0x31A8,0x00}, //PULSE1EN/PULSE1_POL - {0x31AC,0x00}, //PULSE1_DN - {0x31AD,0x00}, //PULSE1_DN - {0x31AE,0x00}, //PULSE1_DN - {0x31D4,0x00}, //XVSLNG - {0x31D5,0x00}, //XHSLNG - {0x31D7,0x00}, - {0x31E4,0x01}, - {0x31F3,0x01}, - {0x3288,0x21}, - {0x328A,0x02}, - {0x3414,0x05}, - {0x3416,0x18}, - {0x341C,0xFF}, //ADBIT1 10Bit:0x01FF 12Bit:0x0047 - {0x341D,0x01}, //ADBIT1 10Bit:0x01FF 12Bit:0x0047 - {0x3648,0x01}, - {0x364A,0x04}, - {0x364C,0x04}, - {0x3678,0x01}, - {0x367C,0x31}, - {0x367E,0x31}, - {0x3706,0x10}, - {0x3708,0x03}, - {0x3714,0x02}, - {0x3715,0x02}, - {0x3716,0x01}, - {0x3717,0x03}, - {0x371C,0x3D}, - {0x371D,0x3F}, - {0x372C,0x00}, - {0x372D,0x00}, - {0x372E,0x46}, - {0x372F,0x00}, - {0x3730,0x89}, - {0x3731,0x00}, - {0x3732,0x08}, - {0x3733,0x01}, - {0x3734,0xFE}, - {0x3735,0x05}, - {0x3740,0x02}, - {0x375D,0x00}, - {0x375E,0x00}, - {0x375F,0x11}, - {0x3760,0x01}, - {0x3768,0x1B}, - {0x3769,0x1B}, - {0x376A,0x1B}, - {0x376B,0x1B}, - {0x376C,0x1A}, - {0x376D,0x17}, - {0x376E,0x0F}, - {0x3776,0x00}, - {0x3777,0x00}, - {0x3778,0x46}, - {0x3779,0x00}, - {0x377A,0x89}, - {0x377B,0x00}, - {0x377C,0x08}, - {0x377D,0x01}, - {0x377E,0x23}, - {0x377F,0x02}, - {0x3780,0xD9}, - {0x3781,0x03}, - {0x3782,0xF5}, - {0x3783,0x06}, - {0x3784,0xA5}, - {0x3788,0x0F}, - {0x378A,0xD9}, - {0x378B,0x03}, - {0x378C,0xEB}, - {0x378D,0x05}, - {0x378E,0x87}, - {0x378F,0x06}, - {0x3790,0xF5}, - {0x3792,0x43}, - {0x3794,0x7A}, - {0x3796,0xA1}, - {0x3A01,0x01}, //LANEMODE 0x03:4Lane 0x01:2Lane - {0x3000,0x00}, - {0x3002,0x00}, -}; - -const static I2C_ARRAY Sensor_init_table_2lane_5m30fps[] = -{ - /*"IMX335LQN All-pixel scan CSI-2_2lane 1188Mbps AD:10bit Output:10bit 27MHz Master Mode 30fps"*/ - {0x3002,0x01}, //Master mode stop - {0xffff,0x14}, //delay - {0x3000,0x01}, //standby - {0xffff,0x14}, //delay - {0x300C,0x42}, //BCWAIT_TIME - {0x300D,0x2E}, //CPWAIT_TIME - {0x3030,0x1D}, //VMAX //1194 :4500 //101D: 4125 - {0x3031,0x10}, //VMAX - {0x3032,0x00}, //VMAX - {0x3034,0x58}, //HMAX //2D0h: 720 //226h: 550 - {0x3035,0x02}, //HMAX - {0x3050,0x00}, //ADBIT - - {0x305a,0x00}, // bit0-3(16-18) - {0x3059,0x0E}, // bit0-7(8-15) - {0x3058,0x80}, // bit0-7 - - {0x314C,0xB0}, //INCKSEL1 - {0x315A,0x02}, //INCKSEL2 - {0x3168,0x8F}, //INCKSEL3 - {0x316A,0x7E}, //INCKSEL4 - {0x319D,0x00}, //MDBIT 0:10Bit 1:12Bit - {0x31A0,0x2A}, //XH&VSOUTSEL - {0x31A1,0x00}, //XVS/XHS pin setting - {0x31A4,0x00}, //PULSE1_UP - {0x31A5,0x00}, //PULSE1_UP - {0x31A6,0x00}, //PULSE1_UP - {0x31A8,0x00}, //PULSE1EN/PULSE1_POL - {0x31AC,0x00}, //PULSE1_DN - {0x31AD,0x00}, //PULSE1_DN - {0x31AE,0x00}, //PULSE1_DN - {0x31D4,0x00}, //XVSLNG - {0x31D5,0x00}, //XHSLNG - {0x31D7,0x00}, - {0x31E4,0x01}, - {0x31F3,0x01}, - {0x3288,0x21}, - {0x328A,0x02}, - {0x3414,0x05}, - {0x3416,0x18}, - {0x341C,0xFF}, //ADBIT1 10Bit:0x01FF 12Bit:0x0047 - {0x341D,0x01}, //ADBIT1 10Bit:0x01FF 12Bit:0x0047 - {0x3648,0x01}, - {0x364A,0x04}, - {0x364C,0x04}, - {0x3678,0x01}, - {0x367C,0x31}, - {0x367E,0x31}, - {0x3706,0x10}, - {0x3708,0x03}, - {0x3714,0x02}, - {0x3715,0x02}, - {0x3716,0x01}, - {0x3717,0x03}, - {0x371C,0x3D}, - {0x371D,0x3F}, - {0x372C,0x00}, - {0x372D,0x00}, - {0x372E,0x46}, - {0x372F,0x00}, - {0x3730,0x89}, - {0x3731,0x00}, - {0x3732,0x08}, - {0x3733,0x01}, - {0x3734,0xFE}, - {0x3735,0x05}, - {0x3740,0x02}, - {0x375D,0x00}, - {0x375E,0x00}, - {0x375F,0x11}, - {0x3760,0x01}, - {0x3768,0x1B}, - {0x3769,0x1B}, - {0x376A,0x1B}, - {0x376B,0x1B}, - {0x376C,0x1A}, - {0x376D,0x17}, - {0x376E,0x0F}, - {0x3776,0x00}, - {0x3777,0x00}, - {0x3778,0x46}, - {0x3779,0x00}, - {0x377A,0x89}, - {0x377B,0x00}, - {0x377C,0x08}, - {0x377D,0x01}, - {0x377E,0x23}, - {0x377F,0x02}, - {0x3780,0xD9}, - {0x3781,0x03}, - {0x3782,0xF5}, - {0x3783,0x06}, - {0x3784,0xA5}, - {0x3788,0x0F}, - {0x378A,0xD9}, - {0x378B,0x03}, - {0x378C,0xEB}, - {0x378D,0x05}, - {0x378E,0x87}, - {0x378F,0x06}, - {0x3790,0xF5}, - {0x3792,0x43}, - {0x3794,0x7A}, - {0x3796,0xA1}, - {0x3A01,0x01}, //LANEMODE 0x03:4Lane 0x01:2Lane - {0x3000,0x00}, - {0x3002,0x00}, -}; - -const static I2C_ARRAY Sensor_init_table_4lane_5m25fps[] = -{ -/* "IMX335LQN All-pixel scan CSI-2_4lane 1188Mbps AD:10bit Output:10bit 27MHz Master Mode 25fps" */ - {0x3002,0x01}, //Master mode stop - {0xffff,0x14}, //delay - {0x3000,0x01}, //standby - {0xffff,0x14}, //delay - {0x300C,0x42}, - {0x300D,0x2E}, - {0x3030,0x56}, //VMAX //101Dh: 4125 //1518h: 5400 - {0x3031,0x13}, //VMAX - {0x3032,0x00}, //VMAX - {0x3034,0x58}, //HMAX //2D0h: 720 //226h: 550 - {0x3035,0x02}, //HMAX - - {0x305a,0x00}, // bit0-3(16-18) - {0x3059,0x0E}, // bit0-7(8-15) - {0x3058,0x80}, // bit0-7 - - {0x314C,0xB0}, - {0x315A,0x02}, - {0x3168,0x8F}, - {0x316A,0x7E}, - {0x319D,0x00}, //MDBIT 0:10Bit 1:12Bit - {0x31A0,0x2A}, - {0x31A1,0x00}, - {0x31A4,0x00}, - {0x31A5,0x00}, - {0x31A6,0x00}, - {0x31A8,0x00}, - {0x31AC,0x00}, - {0x31AD,0x00}, - {0x31AE,0x00}, - {0x31D4,0x00}, - {0x31D5,0x00}, - {0x31D7,0x00}, - {0x31E4,0x01}, - {0x31F3,0x01}, - {0x3288,0x21}, - {0x328A,0x02}, - {0x3414,0x05}, - {0x3416,0x18}, - {0x341c,0xFF}, //0x47--12-bit 0xff--10bit - {0x341d,0x01}, //0x00--12-bit 0x01--10bit - {0x3648,0x01}, - {0x364A,0x04}, - {0x364C,0x04}, - {0x3678,0x01}, - {0x367C,0x31}, - {0x367E,0x31}, - {0x3706,0x10}, - {0x3708,0x03}, - {0x3714,0x02}, - {0x3715,0x02}, - {0x3716,0x01}, - {0x3717,0x03}, - {0x371C,0x3D}, - {0x371D,0x3F}, - {0x372C,0x00}, - {0x372D,0x00}, - {0x372E,0x46}, - {0x372F,0x00}, - {0x3730,0x89}, - {0x3731,0x00}, - {0x3732,0x08}, - {0x3733,0x01}, - {0x3734,0xFE}, - {0x3735,0x05}, - {0x3740,0x02}, - {0x375D,0x00}, - {0x375E,0x00}, - {0x375F,0x11}, - {0x3760,0x01}, - {0x3768,0x1B}, - {0x3769,0x1B}, - {0x376A,0x1B}, - {0x376B,0x1B}, - {0x376C,0x1A}, - {0x376D,0x17}, - {0x376E,0x0F}, - {0x3776,0x00}, - {0x3777,0x00}, - {0x3778,0x46}, - {0x3779,0x00}, - {0x377A,0x89}, - {0x377B,0x00}, - {0x377C,0x08}, - {0x377D,0x01}, - {0x377E,0x23}, - {0x377F,0x02}, - {0x3780,0xD9}, - {0x3781,0x03}, - {0x3782,0xF5}, - {0x3783,0x06}, - {0x3784,0xA5}, - {0x3788,0x0F}, - {0x378A,0xD9}, - {0x378B,0x03}, - {0x378C,0xEB}, - {0x378D,0x05}, - {0x378E,0x87}, - {0x378F,0x06}, - {0x3790,0xF5}, - {0x3792,0x43}, - {0x3794,0x7A}, - {0x3796,0xA1}, - {0x3000,0x00}, - {0x3002,0x00}, -}; - -const static I2C_ARRAY Sensor_init_table_4lane_5m30fps[] = -{ -/* "IMX335LQN All-pixel scan CSI-2_4lane 1188Mbps AD:10bit Output:10bit 27MHz Master Mode 30fps" */ - {0x3002,0x01}, //Master mode stop - {0xffff,0x14}, //delay - {0x3000,0x01}, //standby - {0xffff,0x14}, //delay - {0x300C,0x42}, - {0x300D,0x2E}, - {0x3030,0x1D}, //VMAX //1194 :4500 //101D: 4125 - {0x3031,0x10}, //VMAX - {0x3032,0x00}, //VMAX - {0x3034,0x58}, //HMAX //2D0h: 720 //226h: 550 - {0x3035,0x02}, //HMAX - - {0x305a,0x00}, // bit0-3(16-18) - {0x3059,0x0E}, // bit0-7(8-15) - {0x3058,0x80}, // bit0-7 - - {0x314C,0xB0}, - {0x315A,0x02}, - {0x3168,0x8F}, - {0x316A,0x7E}, - {0x319D,0x00}, //MDBIT 0:10Bit 1:12Bit - {0x31A0,0x2A}, - {0x31A1,0x00}, - {0x31A4,0x00}, - {0x31A5,0x00}, - {0x31A6,0x00}, - {0x31A8,0x00}, - {0x31AC,0x00}, - {0x31AD,0x00}, - {0x31AE,0x00}, - {0x31D4,0x00}, - {0x31D5,0x00}, - {0x31D7,0x00}, - {0x31E4,0x01}, - {0x31F3,0x01}, - {0x3288,0x21}, - {0x328A,0x02}, - {0x3414,0x05}, - {0x3416,0x18}, - {0x341c,0xFF}, //0x47--12-bit 0xff--10bit - {0x341d,0x01}, //0x00--12-bit 0x01--10bit - {0x3648,0x01}, - {0x364A,0x04}, - {0x364C,0x04}, - {0x3678,0x01}, - {0x367C,0x31}, - {0x367E,0x31}, - {0x3706,0x10}, - {0x3708,0x03}, - {0x3714,0x02}, - {0x3715,0x02}, - {0x3716,0x01}, - {0x3717,0x03}, - {0x371C,0x3D}, - {0x371D,0x3F}, - {0x372C,0x00}, - {0x372D,0x00}, - {0x372E,0x46}, - {0x372F,0x00}, - {0x3730,0x89}, - {0x3731,0x00}, - {0x3732,0x08}, - {0x3733,0x01}, - {0x3734,0xFE}, - {0x3735,0x05}, - {0x3740,0x02}, - {0x375D,0x00}, - {0x375E,0x00}, - {0x375F,0x11}, - {0x3760,0x01}, - {0x3768,0x1B}, - {0x3769,0x1B}, - {0x376A,0x1B}, - {0x376B,0x1B}, - {0x376C,0x1A}, - {0x376D,0x17}, - {0x376E,0x0F}, - {0x3776,0x00}, - {0x3777,0x00}, - {0x3778,0x46}, - {0x3779,0x00}, - {0x377A,0x89}, - {0x377B,0x00}, - {0x377C,0x08}, - {0x377D,0x01}, - {0x377E,0x23}, - {0x377F,0x02}, - {0x3780,0xD9}, - {0x3781,0x03}, - {0x3782,0xF5}, - {0x3783,0x06}, - {0x3784,0xA5}, - {0x3788,0x0F}, - {0x378A,0xD9}, - {0x378B,0x03}, - {0x378C,0xEB}, - {0x378D,0x05}, - {0x378E,0x87}, - {0x378F,0x06}, - {0x3790,0xF5}, - {0x3792,0x43}, - {0x3794,0x7A}, - {0x3796,0xA1}, - {0x3000,0x00}, - {0x3002,0x00}, -}; - -const static I2C_ARRAY Sensor_init_table_HDR_DOL_4lane5m25fps[] = -{ -#if 1 -/*"IMX335LQN All-pixel scan CSI-2_4lane 1188Mbps AD:10bit Output:10bit 27MHz Master Mode DOL HDR 2frameLI 25fps" */ - {0x3002,0x01}, //Master mode stop - {0xffff,0x14}, //delay - {0x3000,0x01}, //standby - {0xffff,0x14}, //delay - {0x300C,0x42}, - {0x300D,0x2E}, - {0x3030,0x9A}, //VMAX 1518: 5400 //4500 1194 //4250 109A - {0x3031,0x10}, - {0x3032,0x00}, - {0x3034,0x5D}, //HMAX 113: 275 14A //15Dh 349 - {0x3035,0x01}, - {0x3048,0x01}, - {0x3049,0x01}, - {0x304A,0x04}, - {0x304B,0x03}, - {0x304C,0x00}, - {0x3050,0x00}, - {0x3056,0x07}, //Y_OUT_SIZE[7:0] - {0x3057,0x08}, //Y_OUT_SIZE[12:8] - {0x3058,0x88}, - {0x3059,0x1D}, - {0x305A,0x00}, - {0x305C,0x12}, - {0x305D,0x00}, - {0x305E,0x00}, - {0x3068,0x22}, - {0x3069,0x01}, - {0x306A,0x00}, - {0x314C,0xB0}, - {0x315A,0x02}, - {0x3168,0x8F}, - {0x316A,0x7E}, - {0x319D,0x00}, - {0x319F,0x00}, //0x2 - {0x31A0,0x2A}, - {0x31A1,0x00}, - {0x31A4,0x00}, - {0x31A5,0x00}, - {0x31A6,0x00}, - {0x31A8,0x00}, - {0x31AC,0x00}, - {0x31AD,0x00}, - {0x31AE,0x00}, - {0x31D4,0x00}, - {0x31D5,0x00}, - {0x31D7,0x01}, - {0x31E4,0x01}, - {0x31F3,0x01}, - {0x3288,0x21}, - {0x328A,0x02}, - {0x3300,0x00}, - {0x3414,0x05}, - {0x3416,0x18}, - {0x341C,0xFF},//0x47--12-bit 0xff--10bit - {0x341D,0x01},// - {0x3648,0x01}, - {0x364A,0x04}, - {0x364C,0x04}, - {0x3678,0x01}, - {0x367C,0x31}, - {0x367E,0x31}, - {0x3706,0x10}, - {0x3708,0x03}, - {0x3714,0x02}, - {0x3715,0x02}, - {0x3716,0x01}, - {0x3717,0x03}, - {0x371C,0x3D}, - {0x371D,0x3F}, - {0x372C,0x00}, - {0x372D,0x00}, - {0x372E,0x46}, - {0x372F,0x00}, - {0x3730,0x89}, - {0x3731,0x00}, - {0x3732,0x08}, - {0x3733,0x01}, - {0x3734,0xFE}, - {0x3735,0x05}, - {0x3740,0x02}, - {0x375d,0x00}, - {0x375e,0x00}, - {0x375f,0x11}, - {0x3760,0x01}, - {0x3768,0x1B}, - {0x3769,0x1B}, - {0x376A,0x1B}, - {0x376B,0x1B}, - {0x376C,0x1A}, - {0x376D,0x17}, - {0x376E,0x0F}, - {0x3776,0x00}, - {0x3777,0x00}, - {0x3778,0x46}, - {0x3779,0x00}, - {0x377A,0x89}, - {0x377B,0x00}, - {0x377C,0x08}, - {0x377D,0x01}, - {0x377E,0x23}, - {0x377F,0x02}, - {0x3780,0xD9}, - {0x3781,0x03}, - {0x3782,0xF5}, - {0x3783,0x06}, - {0x3784,0xA5}, - {0x3788,0x0F}, - {0x378A,0xD9}, - {0x378B,0x03}, - {0x378C,0xEB}, - {0x378D,0x05}, - {0x378E,0x87}, - {0x378F,0x06}, - {0x3790,0xF5}, - {0x3792,0x43}, - {0x3794,0x7A}, - {0x3796,0xA1}, - {0x3000,0x00}, - {0x3002,0x00}, -#else //Ori_24Mhz - {0x3000,0x01}, - {0x3001,0x00}, - {0x3002,0x01}, - {0x3003,0x00}, - - {0x300c,0x3b}, - {0x300d,0x2a}, - {0x3018,0x00}, - {0x302c,0x30}, - {0x302d,0x00}, - {0x302e,0x38}, - {0x302f,0x0a}, - - {0x3030,0x9A}, //VMAX 1518: 5400 //4500 1194 //4250 109A - {0x3031,0x10}, - {0x3032,0x00}, - {0x3034,0x5D}, //HMAX 113: 275 14A //15Dh 349 - {0x3035,0x01}, - - {0x3048,0x01}, - {0x3049,0x01}, - {0x304a,0x04}, - {0x304b,0x03}, - {0x304c,0x00}, - {0x304e,0x00}, - {0x304f,0x00}, - {0x3050,0x00}, - {0x3056,0x07}, - {0x3057,0x08}, - {0x3058,0x88}, - {0x3059,0x1d}, - {0x305a,0x00}, - {0x305c,0x12}, - {0x305d,0x00}, - {0x305e,0x00}, - {0x3060,0xe8}, - {0x3061,0x00}, - {0x3062,0x00}, - {0x3064,0x09}, - {0x3065,0x00}, - {0x3066,0x00}, - {0x3068,0x22}, - {0x3069,0x01}, - {0x306a,0x00}, - {0x306c,0x68}, - {0x306d,0x06}, - {0x306e,0x00}, - {0x3072,0x28}, - {0x3073,0x00}, - {0x3074,0xb0}, - {0x3075,0x00}, - {0x3076,0x58}, - {0x3077,0x0f}, - - {0x3078,0x01}, - {0x3079,0x02}, - {0x307a,0xff}, - {0x307b,0x02}, - {0x307c,0x00}, - {0x307d,0x00}, - {0x307e,0x00}, - {0x307f,0x00}, - {0x3080,0x01}, - {0x3081,0x02}, - {0x3082,0xff}, - {0x3083,0x02}, - {0x3084,0x00}, - {0x3085,0x00}, - {0x3086,0x00}, - {0x3087,0x00}, - - {0x30a4,0x33}, - {0x30a8,0x10}, - {0x30a9,0x04}, - {0x30ac,0x00}, - {0x30ad,0x00}, - {0x30b0,0x10}, - {0x30b1,0x08}, - {0x30b4,0x00}, - {0x30b5,0x00}, - {0x30b6,0x00}, - {0x30b7,0x00}, - - {0x30c6,0x00}, - {0x30c7,0x00}, - {0x30ce,0x00}, - {0x30cf,0x00}, - {0x30d8,0x4c}, - {0x30d9,0x10}, - {0x30e8,0x00}, - {0x30e9,0x00}, - {0x30ea,0x00}, - {0x30eb,0x00}, - {0x30ec,0x00}, - {0x30ed,0x00}, - {0x30ee,0x00}, - {0x30ef,0x00}, - {0x3112,0x08}, - {0x3113,0x00}, - {0x3116,0x08}, - {0x3117,0x00}, - {0x314c,0xc6}, - {0x314d,0x00}, - {0x315a,0x02}, - {0x3167,0x01}, - {0x3168,0xa0}, - {0x316a,0x7e}, - {0x3199,0x00}, - {0x319d,0x00}, - {0x319e,0x01}, - {0x319f,0x00}, - {0x31a0,0x2a}, - {0x31a1,0x00}, - {0x31a4,0x00}, - {0x31a5,0x00}, - {0x31a6,0x00}, - {0x31a8,0x00}, - {0x31ac,0x00}, - {0x31ad,0x00}, - {0x31ae,0x00}, - {0x31d4,0x00}, - {0x31d5,0x00}, - {0x31d7,0x01}, - {0x31e4,0x01}, - {0x31e8,0x00}, - {0x31f3,0x01}, - {0x3200,0x01}, - {0x3288,0x21}, - {0x328a,0x02}, - {0x3300,0x00}, - {0x3302,0x32}, - {0x3303,0x00}, - {0x3414,0x05}, - {0x3416,0x18}, - {0x341c,0xff},//0x47--12-bit 0xff--10bit - {0x341d,0x01},// - {0x3648,0x01}, - {0x364a,0x04}, - {0x364c,0x04}, - {0x3678,0x01}, - {0x367c,0x31}, - {0x367e,0x31}, - {0x3706,0x10}, - {0x3708,0x03}, - {0x3714,0x02}, - {0x3715,0x02}, - {0x3716,0x01}, - {0x3717,0x03}, - {0x371c,0x3d}, - {0x371d,0x3f}, - {0x372c,0x00}, - {0x372d,0x00}, - {0x372e,0x46}, - {0x372f,0x00}, - {0x3730,0x89}, - {0x3731,0x00}, - {0x3732,0x08}, - {0x3733,0x01}, - {0x3734,0xfe}, - {0x3735,0x05}, - {0x3740,0x02}, - {0x375d,0x00}, - {0x375e,0x00}, - {0x375f,0x11}, - {0x3760,0x01}, - {0x3768,0x1b}, - {0x3769,0x1b}, - {0x376a,0x1b}, - {0x376b,0x1b}, - {0x376c,0x1a}, - {0x376d,0x17}, - {0x376e,0x0f}, - {0x3776,0x00}, - {0x3777,0x00}, - {0x3778,0x46}, - {0x3779,0x00}, - {0x377a,0x89}, - {0x377b,0x00}, - {0x377c,0x08}, - {0x377d,0x01}, - {0x377e,0x23}, - {0x377f,0x02}, - {0x3780,0xd9}, - {0x3781,0x03}, - {0x3782,0xf5}, - {0x3783,0x06}, - {0x3784,0xa5}, - {0x3788,0x0f}, - {0x378a,0xd9}, - {0x378b,0x03}, - {0x378c,0xeb}, - {0x378d,0x05}, - {0x378e,0x87}, - {0x378f,0x06}, - {0x3790,0xf5}, - {0x3792,0x43}, - {0x3794,0x7a}, - {0x3796,0xa1}, - {0x37b0,0x36}, - {0x3a01,0x03}, - {0x3a04,0x90}, - {0x3a05,0x12}, - {0x3a18,0x8f}, - {0x3a19,0x00}, - {0x3a1a,0x4f}, - {0x3a1b,0x00}, - {0x3a1c,0x47}, - {0x3a1d,0x00}, - {0x3a1e,0x37}, - {0x3a1f,0x01}, - {0x3a20,0x4f}, - {0x3a21,0x00}, - {0x3a22,0x87}, - {0x3a23,0x00}, - {0x3a24,0x4f}, - {0x3a25,0x00}, - {0x3a26,0x7f}, - {0x3a27,0x00}, - {0x3a28,0x3f}, - {0x3a29,0x00}, - - {0x3000,0x00}, - {0x3002,0x00}, -#endif -}; - -const static I2C_ARRAY Sensor_init_table_HDR_DOL_4lane5m20fps[] = -{ -#if 1 -/*"IMX335LQN All-pixel scan CSI-2_4lane 1188Mbps AD:10bit Output:10bit 27MHz Master Mode DOL HDR 2frameLI 25fps" */ - {0x3002,0x01}, //Master mode stop - {0xffff,0x14}, //delay - {0x3000,0x01}, //standby - {0xffff,0x14}, //delay - {0x300C,0x42}, - {0x300D,0x2E}, - {0x3030,0xC0}, //VMAX 1518: 5400 //4500 1194 //4250 109A - {0x3031,0x14}, - {0x3032,0x00}, - {0x3034,0x5D}, //HMAX 113: 275 14A //15Dh 349 - {0x3035,0x01}, - {0x3048,0x01}, - {0x3049,0x01}, - {0x304A,0x04}, - {0x304B,0x03}, - {0x304C,0x00}, - {0x3050,0x00}, - {0x3056,0x07}, //Y_OUT_SIZE[7:0] - {0x3057,0x08}, //Y_OUT_SIZE[12:8] - {0x3058,0x88}, - {0x3059,0x1D}, - {0x305A,0x00}, - {0x305C,0x12}, - {0x305D,0x00}, - {0x305E,0x00}, - {0x3068,0x22}, - {0x3069,0x01}, - {0x306A,0x00}, - {0x314C,0xB0}, - {0x315A,0x02}, - {0x3168,0x8F}, - {0x316A,0x7E}, - {0x319D,0x00}, - {0x319F,0x00}, //0x2 - {0x31A0,0x2A}, - {0x31A1,0x00}, - {0x31A4,0x00}, - {0x31A5,0x00}, - {0x31A6,0x00}, - {0x31A8,0x00}, - {0x31AC,0x00}, - {0x31AD,0x00}, - {0x31AE,0x00}, - {0x31D4,0x00}, - {0x31D5,0x00}, - {0x31D7,0x01}, - {0x31E4,0x01}, - {0x31F3,0x01}, - {0x3288,0x21}, - {0x328A,0x02}, - {0x3300,0x00}, - {0x3414,0x05}, - {0x3416,0x18}, - {0x341C,0xFF},//0x47--12-bit 0xff--10bit - {0x341D,0x01},// - {0x3648,0x01}, - {0x364A,0x04}, - {0x364C,0x04}, - {0x3678,0x01}, - {0x367C,0x31}, - {0x367E,0x31}, - {0x3706,0x10}, - {0x3708,0x03}, - {0x3714,0x02}, - {0x3715,0x02}, - {0x3716,0x01}, - {0x3717,0x03}, - {0x371C,0x3D}, - {0x371D,0x3F}, - {0x372C,0x00}, - {0x372D,0x00}, - {0x372E,0x46}, - {0x372F,0x00}, - {0x3730,0x89}, - {0x3731,0x00}, - {0x3732,0x08}, - {0x3733,0x01}, - {0x3734,0xFE}, - {0x3735,0x05}, - {0x3740,0x02}, - {0x375d,0x00}, - {0x375e,0x00}, - {0x375f,0x11}, - {0x3760,0x01}, - {0x3768,0x1B}, - {0x3769,0x1B}, - {0x376A,0x1B}, - {0x376B,0x1B}, - {0x376C,0x1A}, - {0x376D,0x17}, - {0x376E,0x0F}, - {0x3776,0x00}, - {0x3777,0x00}, - {0x3778,0x46}, - {0x3779,0x00}, - {0x377A,0x89}, - {0x377B,0x00}, - {0x377C,0x08}, - {0x377D,0x01}, - {0x377E,0x23}, - {0x377F,0x02}, - {0x3780,0xD9}, - {0x3781,0x03}, - {0x3782,0xF5}, - {0x3783,0x06}, - {0x3784,0xA5}, - {0x3788,0x0F}, - {0x378A,0xD9}, - {0x378B,0x03}, - {0x378C,0xEB}, - {0x378D,0x05}, - {0x378E,0x87}, - {0x378F,0x06}, - {0x3790,0xF5}, - {0x3792,0x43}, - {0x3794,0x7A}, - {0x3796,0xA1}, - {0x3000,0x00}, - {0x3002,0x00}, -#else //Ori_24Mhz - {0x3000,0x01}, - {0x3001,0x00}, - {0x3002,0x01}, - {0x3003,0x00}, - {0x300c,0x3b}, - {0x300d,0x2a}, - {0x3018,0x00}, - {0x302c,0x30}, - {0x302d,0x00}, - {0x302e,0x38}, - {0x302f,0x0a}, - {0x3030,0xc0}, //14c0:5312 1A5Eh : 6750 // 16A8h : 5800 - {0x3031,0x14}, - {0x3032,0x00}, - {0x3033,0x00}, - {0x3034,0x5d}, //15d:349 113h : 275 // 140h : 320 - {0x3035,0x01}, - {0x3048,0x01}, - {0x3049,0x01}, - {0x304a,0x04}, - {0x304b,0x03}, - {0x304c,0x00}, - {0x304e,0x00}, - {0x304f,0x00}, - {0x3050,0x00}, - {0x3056,0x07}, - {0x3057,0x08}, - {0x3058,0x14}, - {0x3059,0x28}, - {0x305a,0x00}, - {0x305c,0x12}, - {0x305d,0x00}, - {0x305e,0x00}, - {0x3060,0xe8}, - {0x3061,0x00}, - {0x3062,0x00}, - {0x3064,0x09}, - {0x3065,0x00}, - {0x3066,0x00}, - {0x3068,0x22}, - {0x3069,0x01}, - {0x306a,0x00}, - {0x306c,0x68}, - {0x306d,0x06}, - {0x306e,0x00}, - {0x3072,0x28}, - {0x3073,0x00}, - {0x3074,0xb0}, - {0x3075,0x00}, - {0x3076,0x58}, - {0x3077,0x0f}, - {0x3078,0x01}, - {0x3079,0x02}, - {0x307a,0xff}, - {0x307b,0x02}, - {0x307c,0x00}, - {0x307d,0x00}, - {0x307e,0x00}, - {0x307f,0x00}, - {0x3080,0x01}, - {0x3081,0x02}, - {0x3082,0xff}, - {0x3083,0x02}, - {0x3084,0x00}, - {0x3085,0x00}, - {0x3086,0x00}, - {0x3087,0x00}, - {0x30a4,0x33}, - {0x30a8,0x10}, - {0x30a9,0x04}, - {0x30ac,0x00}, - {0x30ad,0x00}, - {0x30b0,0x10}, - {0x30b1,0x08}, - {0x30b4,0x00}, - {0x30b5,0x00}, - {0x30b6,0x00}, - {0x30b7,0x00}, - - {0x30c6,0x00}, - {0x30c7,0x00}, - {0x30ce,0x00}, - {0x30cf,0x00}, - {0x30d8,0x4c}, - {0x30d9,0x10}, - {0x30e8,0x00}, - {0x30e9,0x00}, - {0x30ea,0x00}, - {0x30eb,0x00}, - {0x30ec,0x00}, - {0x30ed,0x00}, - {0x30ee,0x00}, - {0x30ef,0x00}, - {0x3112,0x08}, - {0x3113,0x00}, - {0x3116,0x08}, - {0x3117,0x00}, - {0x314c,0xc6}, - {0x314d,0x00}, - {0x315a,0x02}, - {0x3167,0x01}, - {0x3168,0xa0}, - {0x316a,0x7e}, - {0x3199,0x00}, - {0x319d,0x00}, - {0x319e,0x01}, - {0x319f,0x00}, - {0x31a0,0x2a}, - {0x31a1,0x00}, - {0x31a4,0x00}, - {0x31a5,0x00}, - {0x31a6,0x00}, - {0x31a8,0x00}, - {0x31ac,0x00}, - {0x31ad,0x00}, - {0x31ae,0x00}, - {0x31d4,0x00}, - {0x31d5,0x00}, - {0x31d7,0x01}, - {0x31e4,0x01}, - {0x31e8,0x00}, - {0x31f3,0x01}, - {0x3200,0x01}, - {0x3288,0x21}, - {0x328a,0x02}, - {0x3300,0x00}, - {0x3302,0x32}, - {0x3303,0x00}, - {0x3414,0x05}, - {0x3416,0x18}, - {0x341c,0xff},//0x47--12-bit 0xff--10bit - {0x341d,0x01},// - {0x3648,0x01}, - {0x364a,0x04}, - {0x364c,0x04}, - {0x3678,0x01}, - {0x367c,0x31}, - {0x367e,0x31}, - {0x3706,0x10}, - {0x3708,0x03}, - {0x3714,0x02}, - {0x3715,0x02}, - {0x3716,0x01}, - {0x3717,0x03}, - {0x371c,0x3d}, - {0x371d,0x3f}, - {0x372c,0x00}, - {0x372d,0x00}, - {0x372e,0x46}, - {0x372f,0x00}, - {0x3730,0x89}, - {0x3731,0x00}, - {0x3732,0x08}, - {0x3733,0x01}, - {0x3734,0xfe}, - {0x3735,0x05}, - {0x3740,0x02}, - {0x375d,0x00}, - {0x375e,0x00}, - {0x375f,0x11}, - {0x3760,0x01}, - {0x3768,0x1b}, - {0x3769,0x1b}, - {0x376a,0x1b}, - {0x376b,0x1b}, - {0x376c,0x1a}, - {0x376d,0x17}, - {0x376e,0x0f}, - {0x3776,0x00}, - {0x3777,0x00}, - {0x3778,0x46}, - {0x3779,0x00}, - {0x377a,0x89}, - {0x377b,0x00}, - {0x377c,0x08}, - {0x377d,0x01}, - {0x377e,0x23}, - {0x377f,0x02}, - {0x3780,0xd9}, - {0x3781,0x03}, - {0x3782,0xf5}, - {0x3783,0x06}, - {0x3784,0xa5}, - {0x3788,0x0f}, - {0x378a,0xd9}, - {0x378b,0x03}, - {0x378c,0xeb}, - {0x378d,0x05}, - {0x378e,0x87}, - {0x378f,0x06}, - {0x3790,0xf5}, - {0x3792,0x43}, - {0x3794,0x7a}, - {0x3796,0xa1}, - {0x37b0,0x36}, - {0x3a01,0x03}, - {0x3a04,0x90}, - {0x3a05,0x12}, - {0x3a18,0x8f}, - {0x3a19,0x00}, - {0x3a1a,0x4f}, - {0x3a1b,0x00}, - {0x3a1c,0x47}, - {0x3a1d,0x00}, - {0x3a1e,0x37}, - {0x3a1f,0x01}, - {0x3a20,0x4f}, - {0x3a21,0x00}, - {0x3a22,0x87}, - {0x3a23,0x00}, - {0x3a24,0x4f}, - {0x3a25,0x00}, - {0x3a26,0x7f}, - {0x3a27,0x00}, - {0x3a28,0x3f}, - {0x3a29,0x00}, - - {0x3000,0x00}, - {0x3002,0x00}, -#endif -}; - -const static I2C_ARRAY Sensor_init_table_HDR_DOL_4lane5m30fps[] = -{ -/*"IMX335LQN All-pixel scan CSI-2_4lane 1188Mbps AD:10bit Output:10bit 27MHz Master Mode DOL HDR 2frameLI 30fps"*/ -#if 1 - {0x3002,0x01}, //Master mode stop - {0xffff,0x14}, //delay - {0x3000,0x01}, //standby - {0xffff,0x14}, //delay - {0x300C,0x42}, - {0x300D,0x2E}, - {0x3030,0x9a}, //4250 109a//4096 1000h - {0x3031,0x10}, - {0x3032,0x00}, - {0x3034,0x21}, //HMAX 121: 121h 300 : 12Ch - {0x3035,0x01}, - {0x3048,0x01}, - {0x3049,0x01}, - {0x304A,0x04}, - {0x304B,0x03}, - {0x304C,0x00}, - {0x3050,0x00}, - {0x3056,0x07}, //Y_OUT_SIZE[7:0] - {0x3057,0x08}, //Y_OUT_SIZE[12:8] - {0x3058,0x1C}, - {0x3059,0x22}, - {0x305A,0x00}, - {0x305C,0x12}, - {0x305D,0x00}, - {0x305E,0x00}, - {0x3068,0x22}, - {0x3069,0x01}, - {0x306A,0x00}, - {0x314C,0xB0}, - {0x315A,0x02}, - {0x3168,0x8F}, - {0x316A,0x7E}, - {0x319D,0x00}, - {0x319F,0x00}, //0x2 - {0x31A0,0x2A}, - {0x31A1,0x00}, - {0x31A4,0x00}, - {0x31A5,0x00}, - {0x31A6,0x00}, - {0x31A8,0x00}, - {0x31AC,0x00}, - {0x31AD,0x00}, - {0x31AE,0x00}, - {0x31D4,0x00}, - {0x31D5,0x00}, - {0x31D7,0x01}, - {0x31E4,0x01}, - {0x31F3,0x01}, - {0x3288,0x21}, - {0x328A,0x02}, - {0x3300,0x00}, - {0x3414,0x05}, - {0x3416,0x18}, - {0x341C,0xFF},//0x47--12-bit 0xff--10bit - {0x341D,0x01},// - {0x3648,0x01}, - {0x364A,0x04}, - {0x364C,0x04}, - {0x3678,0x01}, - {0x367C,0x31}, - {0x367E,0x31}, - {0x3706,0x10}, - {0x3708,0x03}, - {0x3714,0x02}, - {0x3715,0x02}, - {0x3716,0x01}, - {0x3717,0x03}, - {0x371C,0x3D}, - {0x371D,0x3F}, - {0x372C,0x00}, - {0x372D,0x00}, - {0x372E,0x46}, - {0x372F,0x00}, - {0x3730,0x89}, - {0x3731,0x00}, - {0x3732,0x08}, - {0x3733,0x01}, - {0x3734,0xFE}, - {0x3735,0x05}, - {0x3740,0x02}, - {0x375d,0x00}, - {0x375e,0x00}, - {0x375f,0x11}, - {0x3760,0x01}, - {0x3768,0x1B}, - {0x3769,0x1B}, - {0x376A,0x1B}, - {0x376B,0x1B}, - {0x376C,0x1A}, - {0x376D,0x17}, - {0x376E,0x0F}, - {0x3776,0x00}, - {0x3777,0x00}, - {0x3778,0x46}, - {0x3779,0x00}, - {0x377A,0x89}, - {0x377B,0x00}, - {0x377C,0x08}, - {0x377D,0x01}, - {0x377E,0x23}, - {0x377F,0x02}, - {0x3780,0xD9}, - {0x3781,0x03}, - {0x3782,0xF5}, - {0x3783,0x06}, - {0x3784,0xA5}, - {0x3788,0x0F}, - {0x378A,0xD9}, - {0x378B,0x03}, - {0x378C,0xEB}, - {0x378D,0x05}, - {0x378E,0x87}, - {0x378F,0x06}, - {0x3790,0xF5}, - {0x3792,0x43}, - {0x3794,0x7A}, - {0x3796,0xA1}, - {0x3000,0x00}, - {0x3002,0x00}, -#else - {0x3000,0x01}, - {0x3001,0x00}, - {0x3002,0x01}, - {0x3003,0x00}, - - {0x300c,0x3b}, - {0x300d,0x2a}, - {0x3018,0x00}, - {0x302c,0x30}, - {0x302d,0x00}, - {0x302e,0x38}, - {0x302f,0x0a}, - - {0x3030,0x9a}, //VMAX 119a:4506, 109ah:4250 - {0x3031,0x10}, - {0x3032,0x00}, - {0x3033,0x00}, - {0x3034,0x23}, //HMAX 113h:275, 123:291 - {0x3035,0x01}, - {0x3048,0x01}, - {0x3049,0x01}, - {0x304a,0x04}, - {0x304b,0x03}, - {0x304c,0x00}, - {0x304e,0x00}, - {0x304f,0x00}, - {0x3050,0x00}, - {0x3056,0x07}, - {0x3057,0x08}, - {0x3058,0x9c}, - {0x3059,0x18}, - {0x305a,0x00}, - {0x305c,0x12}, - {0x305d,0x00}, - {0x305e,0x00}, - {0x3060,0xe8}, - {0x3061,0x00}, - {0x3062,0x00}, - {0x3064,0x09}, - {0x3065,0x00}, - {0x3066,0x00}, - {0x3068,0x22}, - {0x3069,0x01}, - {0x306a,0x00}, - {0x306c,0x68}, - {0x306d,0x06}, - {0x306e,0x00}, - {0x3072,0x28}, - {0x3073,0x00}, - {0x3074,0xb0}, - {0x3075,0x00}, - {0x3076,0x58}, - {0x3077,0x0f}, - - {0x3078,0x01}, - {0x3079,0x02}, - {0x307a,0xff}, - {0x307b,0x02}, - {0x307c,0x00}, - {0x307d,0x00}, - {0x307e,0x00}, - {0x307f,0x00}, - {0x3080,0x01}, - {0x3081,0x02}, - {0x3082,0xff}, - {0x3083,0x02}, - {0x3084,0x00}, - {0x3085,0x00}, - {0x3086,0x00}, - {0x3087,0x00}, - - {0x30a4,0x33}, - {0x30a8,0x10}, - {0x30a9,0x04}, - {0x30ac,0x00}, - {0x30ad,0x00}, - {0x30b0,0x10}, - {0x30b1,0x08}, - {0x30b4,0x00}, - {0x30b5,0x00}, - {0x30b6,0x00}, - {0x30b7,0x00}, - - {0x30c6,0x00}, - {0x30c7,0x00}, - {0x30ce,0x00}, - {0x30cf,0x00}, - {0x30d8,0x4c}, - {0x30d9,0x10}, - {0x30e8,0x00}, - {0x30e9,0x00}, - {0x30ea,0x00}, - {0x30eb,0x00}, - {0x30ec,0x00}, - {0x30ed,0x00}, - {0x30ee,0x00}, - {0x30ef,0x00}, - {0x3112,0x08}, - {0x3113,0x00}, - {0x3116,0x08}, - {0x3117,0x00}, - {0x314c,0xc6}, - {0x314d,0x00}, - {0x315a,0x02}, - {0x3167,0x01}, - {0x3168,0xa0}, - {0x316a,0x7e}, - {0x3199,0x00}, - {0x319d,0x00}, - {0x319e,0x01}, - {0x319f,0x02}, - {0x31a0,0x2a}, - {0x31a1,0x00}, - {0x31a4,0x00}, - {0x31a5,0x00}, - {0x31a6,0x00}, - {0x31a8,0x00}, - {0x31ac,0x00}, - {0x31ad,0x00}, - {0x31ae,0x00}, - {0x31d4,0x00}, - {0x31d5,0x00}, - {0x31d7,0x01}, - {0x31e4,0x01}, - {0x31e8,0x00}, - {0x31f3,0x01}, - {0x3200,0x01}, - {0x3288,0x21}, - {0x328a,0x02}, - {0x3300,0x00}, - {0x3302,0x32}, - {0x3303,0x00}, - {0x3414,0x05}, - {0x3416,0x18}, - {0x341c,0xff},//0x47--12-bit 0xff--10bit - {0x341d,0x01},// - {0x3648,0x01}, - {0x364a,0x04}, - {0x364c,0x04}, - {0x3678,0x01}, - {0x367c,0x31}, - {0x367e,0x31}, - {0x3706,0x10}, - {0x3708,0x03}, - {0x3714,0x02}, - {0x3715,0x02}, - {0x3716,0x01}, - {0x3717,0x03}, - {0x371c,0x3d}, - {0x371d,0x3f}, - {0x372c,0x00}, - {0x372d,0x00}, - {0x372e,0x46}, - {0x372f,0x00}, - {0x3730,0x89}, - {0x3731,0x00}, - {0x3732,0x08}, - {0x3733,0x01}, - {0x3734,0xfe}, - {0x3735,0x05}, - {0x3740,0x02}, - {0x375d,0x00}, - {0x375e,0x00}, - {0x375f,0x11}, - {0x3760,0x01}, - {0x3768,0x1b}, - {0x3769,0x1b}, - {0x376a,0x1b}, - {0x376b,0x1b}, - {0x376c,0x1a}, - {0x376d,0x17}, - {0x376e,0x0f}, - {0x3776,0x00}, - {0x3777,0x00}, - {0x3778,0x46}, - {0x3779,0x00}, - {0x377a,0x89}, - {0x377b,0x00}, - {0x377c,0x08}, - {0x377d,0x01}, - {0x377e,0x23}, - {0x377f,0x02}, - {0x3780,0xd9}, - {0x3781,0x03}, - {0x3782,0xf5}, - {0x3783,0x06}, - {0x3784,0xa5}, - {0x3788,0x0f}, - {0x378a,0xd9}, - {0x378b,0x03}, - {0x378c,0xeb}, - {0x378d,0x05}, - {0x378e,0x87}, - {0x378f,0x06}, - {0x3790,0xf5}, - {0x3792,0x43}, - {0x3794,0x7a}, - {0x3796,0xa1}, - {0x37b0,0x36}, - {0x3a01,0x03}, - {0x3a04,0x90}, - {0x3a05,0x12}, - {0x3a18,0x8f}, - {0x3a19,0x00}, - {0x3a1a,0x4f}, - {0x3a1b,0x00}, - {0x3a1c,0x47}, - {0x3a1d,0x00}, - {0x3a1e,0x37}, - {0x3a1f,0x01}, - {0x3a20,0x4f}, - {0x3a21,0x00}, - {0x3a22,0x87}, - {0x3a23,0x00}, - {0x3a24,0x4f}, - {0x3a25,0x00}, - {0x3a26,0x7f}, - {0x3a27,0x00}, - {0x3a28,0x3f}, - {0x3a29,0x00}, - - {0x3000,0x00}, - {0x3002,0x00}, -#endif -}; - -static I2C_ARRAY PatternTbl[] = { - {0x308c,0x20}, //colorbar pattern , bit 0 to enable -}; - -const static I2C_ARRAY gain_HDR_DOL_LEF_reg[] = -{ - {0x30E8, 0x00},// bit0-7 low - {0x30E9, 0x00},// bit0-2(8-10) -}; - -const static I2C_ARRAY gain_HDR_DOL_SEF1_reg[] = -{ - {0x30EA, 0x00},// bit0-7 low - {0x30EB, 0x00},// bit0-2(8-10) -}; - -const static I2C_ARRAY expo_shr_dol1_reg[] = -{ //SEL - {0x305e, 0x00}, // bit0-3(16-18) - {0x305d, 0x00}, // bit0-7(8-15) - {0x305c, 0x12}, // bit0-7 -}; - -const I2C_ARRAY expo_rhs1_reg[] = -{ //SEL - {0x306a, 0x00}, // bit0-3(16-18) - {0x3069, 0x00}, // bit0-7(8-15) - {0x3068, 0xCE}, // bit0-7 -}; - -const static I2C_ARRAY mirr_flip_table[] = -{ - {0x304e, 0x00}, //M0F0 - {0x304f, 0x00}, //M0F0 - {0x3081, 0x02}, - {0x3083, 0x02}, - {0x30b6, 0x00}, - {0x30b7, 0x00}, - {0x3016, 0x08}, - - {0x304e, 0x01}, //M1F0 - {0x304f, 0x00}, //M1F0 - {0x3081, 0x02}, - {0x3083, 0x02}, - {0x30b6, 0x00}, - {0x30b7, 0x00}, - {0x3016, 0x08}, - - {0x304e, 0x00}, //M0F1 - {0x304f, 0x01}, //M0F1 - {0x3081, 0xfe}, - {0x3083, 0xfe}, - {0x30b6, 0xfa}, - {0x30b7, 0x01}, - {0x3016, 0x02}, - - {0x304e, 0x01}, //M1F1 - {0x304f, 0x01}, //M1F1 - {0x3081, 0xfe}, - {0x3083, 0xfe}, - {0x30b6, 0xfa}, - {0x30b7, 0x01}, - {0x3016, 0x02}, -}; - -const static I2C_ARRAY gain_reg[] = { - {0x30E8, 0x00},// bit0-7 low - {0x30E9, 0x00},// bit0-2(8-10) -}; - -const static I2C_ARRAY expo_reg[] = { - {0x305a, 0x00}, // bit0-3(16-18) - {0x3059, 0x00}, // bit0-7(8-15) - {0x3058, 0x09}, // bit0-7 -}; - -const static I2C_ARRAY vts_reg[] = { - {0x3032, 0x00}, // bit0-3(16-18) - {0x3031, 0x11}, // bit0-7(8-15) - {0x3030, 0x94}, // bit0-7 -}; - -///////////////////////////////////////////////////////////////// -// @@@@@@@ // -// @@ // -// @@ // -// @@@ // -// @ @@ // -// @@@@ // -// // -// Step 3 -- complete camera features // -// // -// camera set EV, MWB, orientation, contrast, sharpness // -// , saturation, and Denoise can work correctly. // -// // -///////////////////////////////////////////////////////////////// - -/////////// function definition /////////////////// -#define SensorReg_Read(_reg,_data) (handle->i2c_bus->i2c_rx(handle->i2c_bus, &(handle->i2c_cfg),_reg,_data)) -#define SensorReg_Write(_reg,_data) (handle->i2c_bus->i2c_tx(handle->i2c_bus, &(handle->i2c_cfg),_reg,_data)) -#define SensorRegArrayW(_reg,_len) (handle->i2c_bus->i2c_array_tx(handle->i2c_bus, &(handle->i2c_cfg),(_reg),(_len))) -#define SensorRegArrayR(_reg,_len) (handle->i2c_bus->i2c_array_rx(handle->i2c_bus, &(handle->i2c_cfg),(_reg),(_len))) - -/////////////////// sensor hardware dependent ////////////// -static int cus_camsensor_release_handle(ms_cus_sensor *handle) -{ - return SUCCESS; -} - -/*******I5/I6 Support MCLK List******* - * CUS_CMU_CLK_27MHZ, - * CUS_CMU_CLK_21P6MHZ, - * CUS_CMU_CLK_12MHZ, - * CUS_CMU_CLK_5P4MHZ, - * CUS_CMU_CLK_36MHZ, - * CUS_CMU_CLK_54MHZ, - * CUS_CMU_CLK_43P2MHZ, - * CUS_CMU_CLK_61P7MHZ, - * CUS_CMU_CLK_72MHZ, - * CUS_CMU_CLK_48MHZ, - * CUS_CMU_CLK_24MHZ, - * CUS_CMU_CLK_37P125MHZ, - ******End of Support MCLK List*******/ - #if 0 -static CUS_MCLK_FREQ UseParaMclk(const char *mclk) -{ - if (strcmp(mclk, "27M") == 0) { - return CUS_CMU_CLK_27MHZ; - } else if (strcmp(mclk, "12M") == 0) { - return CUS_CMU_CLK_12MHZ; - } else if (strcmp(mclk, "36M") == 0) { - return CUS_CMU_CLK_36MHZ; - } else if (strcmp(mclk, "48M") == 0) { - return CUS_CMU_CLK_48MHZ; - } else if (strcmp(mclk, "54M") == 0) { - return CUS_CMU_CLK_54MHZ; - } else if (strcmp(mclk, "24M") == 0) { - return CUS_CMU_CLK_24MHZ; - } else if (strcmp(mclk, "37.125M") == 0) { - return CUS_CMU_CLK_37P125MHZ; - } - return Preview_MCLK_SPEED; -} -#endif - -static int pCus_poweron(ms_cus_sensor *handle, u32 idx) -{ - ISensorIfAPI *sensor_if = handle->sensor_if_api; - SENSOR_DMSG("[%s] ", __FUNCTION__); - - //Sensor power on sequence - sensor_if->PowerOff(idx, !handle->pwdn_POLARITY); - sensor_if->Reset(idx, handle->reset_POLARITY); - sensor_if->SetIOPad(idx, handle->sif_bus, handle->interface_attr.attr_mipi.mipi_lane_num); - sensor_if->SetCSI_Clk(idx, CUS_CSI_CLK_216M); - sensor_if->SetCSI_Lane(idx, handle->interface_attr.attr_mipi.mipi_lane_num, 1); - sensor_if->SetCSI_LongPacketType(idx, 0, 0x1C00, 0); - - if (handle->interface_attr.attr_mipi.mipi_hdr_mode == CUS_HDR_MODE_SONY_DOL) { - sensor_if->SetCSI_hdr_mode(idx, handle->interface_attr.attr_mipi.mipi_hdr_mode, 1); - } - - sensor_if->PowerOff(idx, !handle->pwdn_POLARITY); - //Sensor board PWDN Enable, 1.8V & 2.9V need 30ms then Pull High - SENSOR_MSLEEP(31); - sensor_if->Reset(idx, !handle->reset_POLARITY); - SENSOR_UDELAY(1); - sensor_if->MCLK(idx, 1, handle->mclk); - SENSOR_UDELAY(30); //modify: clear_OFF->commucation_start>=20us - SENSOR_DMSG("Sensor Power On finished\n"); - return SUCCESS; -} - -static int pCus_poweroff(ms_cus_sensor *handle, u32 idx) -{ - // power/reset low - ISensorIfAPI *sensor_if = handle->sensor_if_api; - - SENSOR_DMSG("[%s] reset low\n", __FUNCTION__); - sensor_if->Reset(idx, handle->reset_POLARITY); - sensor_if->MCLK(idx, 0, handle->mclk); - - sensor_if->SetCSI_Clk(idx, CUS_CSI_CLK_DISABLE); - if (handle->interface_attr.attr_mipi.mipi_hdr_mode == CUS_HDR_MODE_SONY_DOL) { - sensor_if->SetCSI_hdr_mode(idx, handle->interface_attr.attr_mipi.mipi_hdr_mode, 0); - } - handle->orient = SENSOR_ORIT; - - return SUCCESS; -} - -/////////////////// Check Sensor Product ID ///////////////////////// -#if 0 -static int pCus_CheckSensorProductID(ms_cus_sensor *handle) -{ - u16 sen_id_msb, sen_id_lsb, sen_data; - - /* Read Product ID */ - SensorReg_Read(0x3f12, &sen_id_lsb); - SensorReg_Read(0x3f13, &sen_id_msb);//CHIP_ID_r3F13 - sen_data = ((sen_id_lsb & 0x0F) << 8) | (sen_id_lsb & 0xF0) | (sen_id_msb & 0x0F); -#if 0 - if (sen_data != CHIP_ID) { - printk("[***ERROR***]Check Product ID Fail: 0x%x\n", sen_data); - return FAIL; - } -#endif - return SUCCESS; -} -#endif -//Get and check sensor ID -//if i2c error or sensor id does not match then return FAIL -static int pCus_GetSensorID(ms_cus_sensor *handle, u32 *id) -{ - int i,n; - int table_length= ARRAY_SIZE(Sensor_id_table); - I2C_ARRAY id_from_sensor[ARRAY_SIZE(Sensor_id_table)]; - - for(n=0;n8) table_length=8; - - SENSOR_DMSG("\n\n[%s]", __FUNCTION__); - - for(n=0;n<4;++n) //retry , until I2C success - { - if(n>2) return FAIL; - - if(/* SensorRegArrayR((I2C_ARRAY*)id_from_sensor,table_length) == */SUCCESS) //read sensor ID from I2C - break; - else - SENSOR_MSLEEP(1); - } - - //convert sensor id to u32 format - for(i=0;i=10) - { - return FAIL; - } - //usleep(10*1000); - } - } - } - return SUCCESS; -} - -static int pCus_init_mipi2lane_5m30fps_linear(ms_cus_sensor *handle) -{ - int i,cnt=0; - - SENSOR_DMSG("\n[%s]", __FUNCTION__); - - for(i=0;i< ARRAY_SIZE(Sensor_init_table_2lane_5m30fps);i++) - { - if(Sensor_init_table_2lane_5m30fps[i].reg==0xffff) - { - SENSOR_MSLEEP(Sensor_init_table_2lane_5m30fps[i].data); - } - else - { - cnt = 0; - while(SensorReg_Write(Sensor_init_table_2lane_5m30fps[i].reg,Sensor_init_table_2lane_5m30fps[i].data) != SUCCESS) - { - cnt++; - if(cnt>=10) - { - return FAIL; - } - //usleep(10*1000); - } - } - } - return SUCCESS; -} - -static int pCus_init_mipi4lane_5m30fps_linear(ms_cus_sensor *handle) -{ - int i,cnt=0; - - SENSOR_DMSG("\n[%s]", __FUNCTION__); - - for(i=0;i< ARRAY_SIZE(Sensor_init_table_4lane_5m30fps);i++) - { - if(Sensor_init_table_4lane_5m30fps[i].reg==0xffff) - { - SENSOR_MSLEEP(Sensor_init_table_4lane_5m30fps[i].data); - } - else - { - cnt = 0; - while(SensorReg_Write(Sensor_init_table_4lane_5m30fps[i].reg,Sensor_init_table_4lane_5m30fps[i].data) != SUCCESS) - { - cnt++; - if(cnt>=10) - { - return FAIL; - } - //usleep(10*1000); - } - } - } - return SUCCESS; -} - -static int pCus_init_mipi4lane_5m25fps_linear(ms_cus_sensor *handle) -{ - int i,cnt=0; - - SENSOR_DMSG("\n[%s]", __FUNCTION__); - - for(i=0;i< ARRAY_SIZE(Sensor_init_table_4lane_5m25fps);i++) - { - if(Sensor_init_table_4lane_5m25fps[i].reg==0xffff) - { - SENSOR_MSLEEP(Sensor_init_table_4lane_5m25fps[i].data); - } - else - { - cnt = 0; - while(SensorReg_Write(Sensor_init_table_4lane_5m25fps[i].reg,Sensor_init_table_4lane_5m25fps[i].data) != SUCCESS) - { - cnt++; - if(cnt>=10) - { - return FAIL; - } - //usleep(10*1000); - } - } - } - return SUCCESS; -} - -static int pCus_init_mipi4lane5m25fps_HDR_DOL(ms_cus_sensor *handle) -{ - int i,cnt=0; - - SENSOR_DMSG("\n[%s]", __FUNCTION__); - - for(i=0;i< ARRAY_SIZE(Sensor_init_table_HDR_DOL_4lane5m25fps);i++) - { - if(Sensor_init_table_HDR_DOL_4lane5m25fps[i].reg==0xffff) - { - SENSOR_MSLEEP(Sensor_init_table_HDR_DOL_4lane5m25fps[i].data); - } - else - { - cnt = 0; - while(SensorReg_Write(Sensor_init_table_HDR_DOL_4lane5m25fps[i].reg,Sensor_init_table_HDR_DOL_4lane5m25fps[i].data) != SUCCESS) - { - cnt++; - if(cnt>=10) - { - return FAIL; - } - //usleep(10*1000); - } - } - } - return SUCCESS; -} - -static int pCus_init_mipi4lane5m20fps_HDR_DOL(ms_cus_sensor *handle) -{ - int i,cnt=0; - - SENSOR_DMSG("\n[%s]", __FUNCTION__); - - for(i=0;i< ARRAY_SIZE(Sensor_init_table_HDR_DOL_4lane5m20fps);i++) - { - if(Sensor_init_table_HDR_DOL_4lane5m20fps[i].reg==0xffff) - { - SENSOR_MSLEEP(Sensor_init_table_HDR_DOL_4lane5m20fps[i].data); - } - else - { - cnt = 0; - while(SensorReg_Write(Sensor_init_table_HDR_DOL_4lane5m20fps[i].reg,Sensor_init_table_HDR_DOL_4lane5m20fps[i].data) != SUCCESS) - { - cnt++; - if(cnt>=10) - { - return FAIL; - } - //usleep(10*1000); - } - } - } - return SUCCESS; -} - -static int pCus_init_mipi4lane5m30fps_HDR_DOL(ms_cus_sensor *handle) -{ - int i,cnt=0; - - SENSOR_DMSG("\n[%s]", __FUNCTION__); - - for(i=0;i< ARRAY_SIZE(Sensor_init_table_HDR_DOL_4lane5m30fps);i++) - { - if(Sensor_init_table_HDR_DOL_4lane5m30fps[i].reg==0xffff) - { - SENSOR_MSLEEP(Sensor_init_table_HDR_DOL_4lane5m30fps[i].data); - } - else - { - cnt = 0; - while(SensorReg_Write(Sensor_init_table_HDR_DOL_4lane5m30fps[i].reg,Sensor_init_table_HDR_DOL_4lane5m30fps[i].data) != SUCCESS) - { - cnt++; - if(cnt>=10) - { - return FAIL; - } - //usleep(10*1000); - } - } - } - return SUCCESS; -} - -static int pCus_GetVideoResNum( ms_cus_sensor *handle, u32 *ulres_num) -{ - *ulres_num = handle->video_res_supported.num_res; - return SUCCESS; -} - -static int pCus_GetVideoRes(ms_cus_sensor *handle, u32 res_idx, cus_camsensor_res **res) -{ - u32 num_res = handle->video_res_supported.num_res; - - if (res_idx >= num_res) { - return FAIL; - } - - *res = &handle->video_res_supported.res[res_idx]; - - return SUCCESS; -} - -static int pCus_GetCurVideoRes(ms_cus_sensor *handle, u32 *cur_idx, cus_camsensor_res **res) -{ - u32 num_res = handle->video_res_supported.num_res; - - *cur_idx = handle->video_res_supported.ulcur_res; - - if (*cur_idx >= num_res) { - return FAIL; - } - - *res = &handle->video_res_supported.res[*cur_idx]; - - return SUCCESS; -} - -static int pCus_SetVideoRes(ms_cus_sensor *handle, u32 res_idx) -{ - imx335_params *params = (imx335_params *)handle->private_data; - u32 num_res = handle->video_res_supported.num_res; - - if (res_idx >= num_res) { - return FAIL; - } - - switch (res_idx) { - case 0: - handle->video_res_supported.ulcur_res = 0; - if(lane_num == 2){ - handle->pCus_sensor_init = pCus_init_mipi2lane_5m25fps_linear; - } - else if (lane_num == 4){ - handle->pCus_sensor_init = pCus_init_mipi4lane_5m25fps_linear; - } - else{ - handle->pCus_sensor_init = pCus_init_mipi4lane_5m25fps_linear; - } - vts_30fps = 4950; - Preview_MAX_FPS = 25; - Preview_line_period = 8080; - break; - case 1: - handle->video_res_supported.ulcur_res = 1; - if(lane_num == 2){ - handle->pCus_sensor_init = pCus_init_mipi2lane_5m30fps_linear; - } - else if (lane_num == 4){ - handle->pCus_sensor_init = pCus_init_mipi4lane_5m30fps_linear; - } - else{ - handle->pCus_sensor_init = pCus_init_mipi4lane_5m30fps_linear; - } - vts_30fps = 4125; - Preview_MAX_FPS = 30; - Preview_line_period = 8080; - break; - default: - break; - } - params->expo.vts = vts_30fps; - params->expo.fps = Preview_MAX_FPS; - - return SUCCESS; -} - -static int pCus_SetVideoRes_HDR_DOL_LEF(ms_cus_sensor *handle, u32 res_idx) -{ - u32 num_res = handle->video_res_supported.num_res; - if (res_idx >= num_res) { - SENSOR_EMSG("[%s] Please check the number of resolutions supported by the sensor!\n", __FUNCTION__); - return FAIL; - } - handle->video_res_supported.ulcur_res = res_idx; - - return SUCCESS; -} - -static int pCus_SetVideoRes_HDR_DOL(ms_cus_sensor *handle, u32 res_idx) -{ - imx335_params *params = (imx335_params *)handle->private_data; - //ISensorIfAPI *sensor_if = &handle->sensor_if_api; - u32 num_res = handle->video_res_supported.num_res; - if (res_idx >= num_res) { - return FAIL; - } - switch (res_idx) { - - case 0: - handle->video_res_supported.ulcur_res = 0; - handle->pCus_sensor_init = pCus_init_mipi4lane5m25fps_HDR_DOL; - vts_30fps_HDR_DOL = 4250; - params->expo.vts = vts_30fps_HDR_DOL; - Preview_MAX_FPS = 25; - params->expo.fps=Preview_MAX_FPS; - Preview_line_period_HDR_DOL = 9411; //8889 - params->max_rhs1 = 290; - break; - case 1: - handle->video_res_supported.ulcur_res = 1; - handle->pCus_sensor_init = pCus_init_mipi4lane5m20fps_HDR_DOL; - vts_30fps_HDR_DOL = 5312; - params->expo.vts = vts_30fps_HDR_DOL; - Preview_MAX_FPS = 20; - params->expo.fps=Preview_MAX_FPS; - Preview_line_period_HDR_DOL = 9411; - params->max_rhs1 = 290; - break; - case 2: - handle->video_res_supported.ulcur_res = 2; - handle->pCus_sensor_init = pCus_init_mipi4lane5m30fps_HDR_DOL; - vts_30fps_HDR_DOL = 4250; - params->expo.vts = vts_30fps_HDR_DOL; - Preview_MAX_FPS = 30; - params->expo.fps= Preview_MAX_FPS; - Preview_line_period_HDR_DOL = 7843; - params->max_rhs1 = 290; - break; - default: - break; - } - return SUCCESS; -} - -static int pCus_GetOrien(ms_cus_sensor *handle, CUS_CAMSENSOR_ORIT *orit) -{ - short Horiz_Inv = 0; - short Verti_Inv = 0; - short Orien_Mode = 0; - SensorReg_Read(0x304e, &Horiz_Inv); - SensorReg_Read(0x304f, &Verti_Inv); - Horiz_Inv &= 0x01; - Verti_Inv &= 0X01; - Orien_Mode = Horiz_Inv |(Verti_Inv << 2); - switch(Orien_Mode) - { - case 0x00: - *orit = CUS_ORIT_M0F0; - break; - case 0x01: - *orit = CUS_ORIT_M1F0; - break; - case 0x02: - *orit = CUS_ORIT_M0F1; - break; - case 0x03: - *orit = CUS_ORIT_M1F1; - break; - } - return SUCCESS; -} - -static int pCus_SetOrien(ms_cus_sensor *handle, CUS_CAMSENSOR_ORIT orit) -{ - imx335_params *params = (imx335_params *)handle->private_data; - - handle->orient = orit; - params->orien_dirty = true; - - return SUCCESS; -} - -static int DoOrien(ms_cus_sensor *handle, CUS_CAMSENSOR_ORIT orit) -{ - int table_length = ARRAY_SIZE(mirr_flip_table); - int seg_length = table_length/4; - int i,j; - - switch(orit) - { - case CUS_ORIT_M0F0: - handle->orient = CUS_ORIT_M0F0; - for(i = 0, j = 0; i < seg_length; i++, j++){ - SensorReg_Write(mirr_flip_table[i].reg,mirr_flip_table[i].data); - } - break; - case CUS_ORIT_M1F0: - for(i = seg_length, j = 0; i < seg_length*2; i++, j++){ - handle->orient = CUS_ORIT_M1F0; - SensorReg_Write(mirr_flip_table[i].reg,mirr_flip_table[i].data); - } - break; - case CUS_ORIT_M0F1: - for(i = seg_length * 2, j = 0; i < seg_length*3; i++, j++){ - handle->orient = CUS_ORIT_M0F1; - SensorReg_Write(mirr_flip_table[i].reg,mirr_flip_table[i].data); - } - break; - case CUS_ORIT_M1F1: - for(i = seg_length * 3, j = 0; i < seg_length*4; i++, j++){ - handle->orient = CUS_ORIT_M1F1; - SensorReg_Write(mirr_flip_table[i].reg,mirr_flip_table[i].data); - } - break; - default : - handle->orient = CUS_ORIT_M0F0; - break; - } - return SUCCESS; -} - -static int pCus_GetFPS(ms_cus_sensor *handle) -{ - imx335_params *params = (imx335_params *)handle->private_data; - u32 max_fps = handle->video_res_supported.res[handle->video_res_supported.ulcur_res].max_fps; - u32 tVts = (params->tVts_reg[0].data << 16) | (params->tVts_reg[1].data << 8) | (params->tVts_reg[2].data << 0); - - if (params->expo.fps >= 1000) - params->expo.preview_fps = (vts_30fps*max_fps*1000)/tVts; - else - params->expo.preview_fps = (vts_30fps*max_fps)/tVts; - - return params->expo.preview_fps; -} - -static int pCus_SetFPS(ms_cus_sensor *handle, u32 fps) -{ - u32 vts = 0; - imx335_params *params = (imx335_params *)handle->private_data; - u32 max_fps = handle->video_res_supported.res[handle->video_res_supported.ulcur_res].max_fps; - u32 min_fps = handle->video_res_supported.res[handle->video_res_supported.ulcur_res].min_fps; - - SENSOR_DMSG("\n\n[%s]", __FUNCTION__); - - if(fps>=min_fps && fps <= max_fps){ - params->expo.fps = fps; - params->expo.vts= (vts_30fps*(max_fps*1000) + fps * 500 )/ (fps * 1000); - }else if((fps>=(min_fps*1000)) && (fps <= (max_fps*1000))){ - params->expo.fps = fps; - params->expo.vts = (vts_30fps*(max_fps*1000) + (fps>>1))/fps; - }else{ - //params->expo.vts=vts_30fps; - //params->expo.fps=25; - SENSOR_DMSG("[%s] FPS %d out of range.\n",__FUNCTION__,fps); - return FAIL; - } - - if(params->expo.expo_lines > params->expo.vts -2){ - vts = params->expo.expo_lines + 8; - }else{ - vts = params->expo.vts; - } - pCus_SetAEUSecs(handle, params->expo.expo_lef_us); - - params->dirty = true; - return SUCCESS; -} - -static int pCus_GetFPS_HDR_DOL_SEF1(ms_cus_sensor *handle) -{ - imx335_params *params = (imx335_params *)handle->private_data; - u32 max_fps = handle->video_res_supported.res[handle->video_res_supported.ulcur_res].max_fps; - u32 tVts = (params->tVts_reg[0].data << 16) | (params->tVts_reg[1].data << 8) | (params->tVts_reg[2].data << 0); - - if (params->expo.fps >= 1000) - params->expo.preview_fps = (vts_30fps_HDR_DOL*max_fps*1000)/tVts; - else - params->expo.preview_fps = (vts_30fps_HDR_DOL*max_fps)/tVts; - - return params->expo.preview_fps; -} - -static int pCus_SetFPS_HDR_DOL_SEF1(ms_cus_sensor *handle, u32 fps) -{ - imx335_params *params = (imx335_params *)handle->private_data; - u32 max_fps = handle->video_res_supported.res[handle->video_res_supported.ulcur_res].max_fps; - u32 min_fps = handle->video_res_supported.res[handle->video_res_supported.ulcur_res].min_fps; - - if(fps>=min_fps && fps <= max_fps){ - params->expo.fps = fps; - params->expo.vts = (vts_30fps_HDR_DOL*(max_fps*1000) + fps * 500 )/ (fps * 1000); - }else if((fps >= (min_fps*1000)) && (fps <= (max_fps*1000))){ - params->expo.fps = fps; - params->expo.vts = (vts_30fps_HDR_DOL*(max_fps*1000) + (fps>>1))/fps; - }else{ - //params->expo.vts=vts_30fps; - //params->expo.fps=30; - SENSOR_DMSG("[%s] FPS %d out of range.\n",__FUNCTION__,fps); - return FAIL; - } - params->dirty = true; //reg need to update = true; - pCus_SetAEUSecsHDR_DOL_SEF1(handle, params->expo.expo_sef_us); - - return SUCCESS; -} - -/////////////////////////////////////////////////////////////////////// -// auto exposure -/////////////////////////////////////////////////////////////////////// -// unit: micro seconds -//AE status notification -static int pCus_AEStatusNotify(ms_cus_sensor *handle, CUS_CAMSENSOR_AE_STATUS_NOTIFY status) -{ - imx335_params *params = (imx335_params *)handle->private_data; - - switch(status) - { - case CUS_FRAME_INACTIVE: - //SensorReg_Write(0x3001,0); - break; - case CUS_FRAME_ACTIVE: - if(params->dirty || params->orien_dirty) { - SensorReg_Write(0x3001,1); - SensorRegArrayW((I2C_ARRAY*)params->tExpo_reg, ARRAY_SIZE(expo_reg)); - SensorRegArrayW((I2C_ARRAY*)params->tGain_reg, ARRAY_SIZE(gain_reg)); - SensorRegArrayW((I2C_ARRAY*)params->tVts_reg, ARRAY_SIZE(vts_reg)); - - if(params->orien_dirty) { - DoOrien(handle, handle->orient); - params->orien_dirty = false; - } - SensorReg_Write(0x3001,0); - params->dirty = false; - } - break; - default : - break; - } - return SUCCESS; -} - -static int pCus_AEStatusNotifyHDR_DOL_SEF1(ms_cus_sensor *handle, CUS_CAMSENSOR_AE_STATUS_NOTIFY status) -{ - //imx335_params *params = (imx335_params *)handle->private_data; - switch(status) - { - case CUS_FRAME_INACTIVE: - break; - case CUS_FRAME_ACTIVE: - break; - default : - break; - } - return SUCCESS; -} - -static int pCus_GetAEUSecs(ms_cus_sensor *handle, u32 *us) -{ - u32 lines = 0; - imx335_params *params = (imx335_params *)handle->private_data; - - lines |= (u32)(params->tExpo_reg[0].data&0xff)<<16; - lines |= (u32)(params->tExpo_reg[1].data&0xff)<<8; - lines |= (u32)(params->tExpo_reg[2].data&0xff)<<0; - - *us = (lines*Preview_line_period)/1000; - SENSOR_DMSG("[%s] sensor expo lines/us %u,%u us\n", __FUNCTION__, lines, *us); - - return SUCCESS; -} - -static int pCus_SetAEUSecs(ms_cus_sensor *handle, u32 us) -{ - u32 lines = 0, vts = 0,activeline = 0; - imx335_params *params = (imx335_params *)handle->private_data; - - params->expo.expo_lef_us = us; - - lines = (1000 * us) / Preview_line_period; - if(lines < 9) lines = 9; - params->expo.expo_lines = lines; - - if (lines >params->expo.vts-1) - vts = lines +1; - else - vts = params->expo.vts; - - SENSOR_DMSG("[%s] us %u, lines %u, vts %u\n", __FUNCTION__, - us, - lines, - params->expo.vts - ); - - activeline = vts - lines; - if(activeline < 9) activeline = 9; - - params->tExpo_reg[0].data = (activeline>>16) & 0x000f; - params->tExpo_reg[1].data = (activeline>>8) & 0x00ff; - params->tExpo_reg[2].data = (activeline>>0) & 0x00ff; - - params->tVts_reg[0].data = (vts >> 16) & 0x000f; - params->tVts_reg[1].data = (vts >> 8) & 0x00ff; - params->tVts_reg[2].data = (vts >> 0) & 0x00ff; - - params->dirty = true; - return SUCCESS; -} - -static int pCus_SetAEUSecsHDR_DOL_SEF1(ms_cus_sensor *handle, u32 us) -{ - u32 qua_lines = 0, lines = 0, long_lines = 0,vts = 0, fsc = 0; - u32 rhs1 = 0, shs1 = 0, shs0 = 0; - imx335_params *params = (imx335_params *)handle->private_data; - - params->expo.expo_sef_us = us; - qua_lines = (1000 * us) / Preview_line_period_HDR_DOL /4; - vts = params->expo.vts; - shs0 = (params->tExpo_reg[0].data << 16) | (params->tExpo_reg[1].data << 8) | (params->tExpo_reg[2].data << 0); - fsc = vts * 2; - long_lines = fsc - shs0; - params->expo.expo_lines = long_lines; - - //params->max_rhs1 = 290; - rhs1 = params->max_rhs1;//(params->tExpo_rhs1_reg[0].data << 16) | (params->tExpo_rhs1_reg[1].data << 8) | (params->tExpo_rhs1_reg[2].data << 0); - - if(qua_lines <= 1) - qua_lines = 1; - if((4*qua_lines) > (rhs1- 18)) - qua_lines = (rhs1 - 18)/4; - - lines = 4*qua_lines; - if((rhs1 - 18) <= lines){ - shs1 = 18; - } - else if((rhs1 <= params->max_rhs1) && (rhs1 <= shs0 - 18)){ - shs1 = rhs1 - lines; - if((shs1 < 18) || (shs1 > (rhs1 - 4))){ //Check boundary - //shs1 = 0; - //UartSendTrace("[SEF1 NG1]"); - } - } - else{ - //UartSendTrace("[SEF1 NG2]"); - } - - params->tExpo_shr_dol1_reg[0].data = (shs1 >> 16) & 0x000f; - params->tExpo_shr_dol1_reg[1].data = (shs1 >> 8) & 0x00ff; - params->tExpo_shr_dol1_reg[2].data = (shs1 >> 0) & 0x00ff; - params->tExpo_rhs1_reg[0].data = (rhs1 >> 16) & 0x000f; - params->tExpo_rhs1_reg[1].data = (rhs1 >> 8) & 0x00ff; - params->tExpo_rhs1_reg[2].data = (rhs1 >> 0) & 0x00ff; - - return SUCCESS; -} - -// Gain: 1x = 1024 -static int pCus_GetAEGain(ms_cus_sensor *handle, u32* gain) -{ - unsigned short temp_gain; - // *gain=params->expo.final_gain; - temp_gain=gain_reg[0].data; - - *gain=(u32)(10^((temp_gain*3)/200))*1024; - if (gain_reg[1].data & 0x10) - *gain = (*gain) * 2; - - SENSOR_DMSG("[%s] get gain/reg (1024=1X)= %u/0x%x\n", __FUNCTION__, *gain,gain_reg[0].data); - return SUCCESS; -} - -static int pCus_SetAEGain_cal(ms_cus_sensor *handle, u32 gain) -{ - imx335_params *params = (imx335_params *)handle->private_data; - //double gain_double; - u64 gain_double; - params->expo.final_gain = gain; - - if(gain<1024) - gain=1024; - else if(gain>=3980*1024) - gain=3980*1024; - - gain_double = 20*(intlog10(gain)-intlog10(1024)); - params->tGain_reg[0].data=(u16)(((gain_double*10)>> 24)/3); - - SENSOR_DMSG("[%s] set gain/reg=%u/0x%x\n", __FUNCTION__, gain,params->tGain_reg[0].data); - - params->dirty = true; - return SUCCESS; -} - -static int pCus_SetAEGain(ms_cus_sensor *handle, u32 gain) -{ - imx335_params *params = (imx335_params *)handle->private_data; - u64 gain_double; - - params->expo.final_gain = gain; - if(gain < SENSOR_MIN_GAIN) - gain = SENSOR_MIN_GAIN; - else if(gain >= SENSOR_MAX_GAIN) - gain = SENSOR_MAX_GAIN; - - gain_double = 20*(intlog10(gain)-intlog10(1024)); - params->tGain_reg[0].data=(u16)(((gain_double*10)>> 24)/3) & 0x00ff; - params->tGain_reg[1].data=(u16)((((gain_double*10)>> 24)/3) >> 8) & 0x0007; - - SENSOR_DMSG("[%s] set gain/reg=%u/0x%x\n", __FUNCTION__, gain,params->tGain_reg[0].data); - params->dirty = true; - return SUCCESS; -} - -static void pCus_SetAEGainHDR_DOL_Calculate(u32 gain, u16 *gain_reg) -{ - //double gain_double; - u64 gain_double; - - if(gain < SENSOR_MIN_GAIN){ - gain = SENSOR_MIN_GAIN; - } - else if(gain >= SENSOR_MAX_GAIN){ - gain = SENSOR_MAX_GAIN; - } - gain_double = 20*(intlog10(gain)-intlog10(1024)); - *gain_reg=(u16)(((gain_double*10)>> 24)/3) & 0x07ff; -} - -static int pCus_SetAEGainHDR_DOL_SEF1(ms_cus_sensor *handle, u32 gain) -{ - imx335_params *params = (imx335_params *)handle->private_data; - u16 gain_reg = 0; - - pCus_SetAEGainHDR_DOL_Calculate(gain, &gain_reg); - params->tGain_hdr_dol_sef_reg[0].data = gain_reg & 0x00ff; - params->tGain_hdr_dol_sef_reg[1].data = (gain_reg>>8) & 0x0007; - - SENSOR_DMSG("[%s] set gain/reg=%u/0x%x\n", __FUNCTION__, gain, params->tGain_hdr_dol_sef_reg[0].data); - - params->dirty = true; - return SUCCESS; -} - -static int pCus_GetAEMinMaxUSecs(ms_cus_sensor *handle, u32 *min, u32 *max) -{ - *min = 1; - *max = 1000000/imx335_mipi_linear[0].senout.min_fps; - return SUCCESS; -} - -static int pCus_GetAEMinMaxGain(ms_cus_sensor *handle, u32 *min, u32 *max) -{ - *min = SENSOR_MIN_GAIN;//handle->sat_mingain; - *max = SENSOR_MAX_GAIN;//3980*1024; - return SUCCESS; -} - -static int IMX335_GetShutterInfo(struct __ms_cus_sensor* handle,CUS_SHUTTER_INFO *info) -{ - info->max = 1000000000/imx335_mipi_linear[0].senout.min_fps; - info->min = (Preview_line_period * 9); - info->step = Preview_line_period; - return SUCCESS; -} - -static int pCus_setCaliData_gain_linearity(ms_cus_sensor* handle, CUS_GAIN_GAP_ARRAY* pArray, u32 num) { - - return SUCCESS; -} - -static int IMX335_GetShutterInfoHDR_DOL_SEF1(struct __ms_cus_sensor* handle,CUS_SHUTTER_INFO *info) -{ - imx335_params *params = (imx335_params *)handle->private_data; - info->max = Preview_line_period_HDR_DOL * params->max_rhs1; - info->min = (Preview_line_period_HDR_DOL * 4); - info->step = Preview_line_period_HDR_DOL * 4; - return SUCCESS; -} - -int cus_camsensor_init_handle_linear(ms_cus_sensor* drv_handle) -{ - ms_cus_sensor *handle = drv_handle; - imx335_params *params; - int res; - - if (!handle) { - SENSOR_DMSG("[%s] not enough memory!\n", __FUNCTION__); - return FAIL; - } - SENSOR_DMSG("[%s]", __FUNCTION__); - //////////////////////////////////// - // private data allocation & init // - //////////////////////////////////// - if (handle->private_data == NULL) { - SENSOR_EMSG("[%s] Private data is empty!\n", __FUNCTION__); - return FAIL; - } - - params = (imx335_params *)handle->private_data; - memcpy(params->tGain_reg, gain_reg, sizeof(gain_reg)); - memcpy(params->tExpo_reg, expo_reg, sizeof(expo_reg)); - memcpy(params->tVts_reg, vts_reg, sizeof(vts_reg)); - //memcpy(params->tExpo_rhs1_reg, expo_rhs1_reg, sizeof(expo_rhs1_reg)); - //memcpy(params->tExpo_shr_dol1_reg, expo_shr_dol1_reg, sizeof(expo_shr_dol1_reg)); - //memcpy(params->tGain_hdr_dol_lef_reg, gain_HDR_DOL_LEF_reg, sizeof(gain_HDR_DOL_LEF_reg)); - //memcpy(params->tGain_hdr_dol_sef_reg, gain_HDR_DOL_SEF1_reg, sizeof(gain_HDR_DOL_SEF1_reg)); - - //////////////////////////////////// - // sensor model ID // - //////////////////////////////////// - sprintf(handle->model_id,"IMX335_MIPI"); - - //////////////////////////////////// - // i2c config // - //////////////////////////////////// - handle->i2c_cfg.mode = SENSOR_I2C_LEGACY; //(CUS_ISP_I2C_MODE) FALSE; - handle->i2c_cfg.fmt = SENSOR_I2C_FMT; //CUS_I2C_FMT_A16D8; - handle->i2c_cfg.address = SENSOR_I2C_ADDR; //0x34; - handle->i2c_cfg.speed = SENSOR_I2C_SPEED; //300000; - - //////////////////////////////////// - // mclk // - //////////////////////////////////// - handle->mclk = Preview_MCLK_SPEED;//UseParaMclk(SENSOR_DRV_PARAM_MCLK()); - - //////////////////////////////////// - // sensor interface info // - //////////////////////////////////// - handle->isp_type = SENSOR_ISP_TYPE; - //handle->data_fmt = SENSOR_DATAFMT; - handle->sif_bus = SENSOR_IFBUS_TYPE; - handle->data_prec = SENSOR_DATAPREC; - handle->data_mode = SENSOR_DATAMODE; - handle->bayer_id = SENSOR_BAYERID; - handle->RGBIR_id = SENSOR_RGBIRID; - handle->orient = SENSOR_ORIT; - handle->interface_attr.attr_mipi.mipi_lane_num = SENSOR_MIPI_LANE_NUM; - handle->interface_attr.attr_mipi.mipi_data_format = CUS_SEN_INPUT_FORMAT_RGB; // RGB pattern. - handle->interface_attr.attr_mipi.mipi_yuv_order = 0; //don't care in RGB pattern. - handle->interface_attr.attr_mipi.mipi_hsync_mode = SENSOR_MIPI_HSYNC_MODE; - handle->interface_attr.attr_mipi.mipi_hdr_mode = CUS_HDR_MODE_NONE; - handle->interface_attr.attr_mipi.mipi_hdr_virtual_channel_num = 0; //Short frame - - //////////////////////////////////// - // resolution capability // - //////////////////////////////////// - handle->video_res_supported.ulcur_res = 0; //default resolution index is 0. - //handle->video_res_supported.num_res = LINEAR_RES_END; - for (res = 0; res < LINEAR_RES_END; res++) { - handle->video_res_supported.num_res = res+1; - handle->video_res_supported.res[res].width = imx335_mipi_linear[res].senif.preview_w; - handle->video_res_supported.res[res].height = imx335_mipi_linear[res].senif.preview_h; - handle->video_res_supported.res[res].max_fps = imx335_mipi_linear[res].senout.max_fps; - handle->video_res_supported.res[res].min_fps = imx335_mipi_linear[res].senout.min_fps; - handle->video_res_supported.res[res].crop_start_x = imx335_mipi_linear[res].senif.crop_start_X; - handle->video_res_supported.res[res].crop_start_y = imx335_mipi_linear[res].senif.crop_start_y; - handle->video_res_supported.res[res].nOutputWidth = imx335_mipi_linear[res].senout.width; - handle->video_res_supported.res[res].nOutputHeight = imx335_mipi_linear[res].senout.height; - sprintf(handle->video_res_supported.res[res].strResDesc, imx335_mipi_linear[res].senstr.strResDesc); - } - - //////////////////////////////////// - // Sensor polarity // - //////////////////////////////////// - handle->pwdn_POLARITY = SENSOR_PWDN_POL; //CUS_CLK_POL_NEG; - handle->reset_POLARITY = SENSOR_RST_POL; //CUS_CLK_POL_NEG; - //handle->VSYNC_POLARITY = SENSOR_VSYNC_POL; //CUS_CLK_POL_POS; - //handle->HSYNC_POLARITY = SENSOR_HSYNC_POL; //CUS_CLK_POL_POS; - handle->PCLK_POLARITY = SENSOR_PCLK_POL; //CUS_CLK_POL_POS); // use '!' to clear board latch error - - //////////////////////////////////////// - // Sensor Status Control and Get Info // - //////////////////////////////////////// - handle->pCus_sensor_release = cus_camsensor_release_handle; - handle->pCus_sensor_init = pCus_init_mipi4lane_5m30fps_linear; - handle->pCus_sensor_poweron = pCus_poweron; - handle->pCus_sensor_poweroff = pCus_poweroff; - handle->pCus_sensor_GetSensorID = pCus_GetSensorID; - handle->pCus_sensor_GetVideoResNum = pCus_GetVideoResNum; - handle->pCus_sensor_GetVideoRes = pCus_GetVideoRes; - handle->pCus_sensor_GetCurVideoRes = pCus_GetCurVideoRes; - handle->pCus_sensor_SetVideoRes = pCus_SetVideoRes; - - handle->pCus_sensor_GetOrien = pCus_GetOrien; - handle->pCus_sensor_SetOrien = pCus_SetOrien; - handle->pCus_sensor_GetFPS = pCus_GetFPS; - handle->pCus_sensor_SetFPS = pCus_SetFPS; - handle->pCus_sensor_SetPatternMode = imx335_SetPatternMode; - - //////////////////////////////////// - // AE parameters // - //////////////////////////////////// - handle->ae_gain_delay = SENSOR_GAIN_DELAY_FRAME_COUNT; - handle->ae_shutter_delay = SENSOR_SHUTTER_DELAY_FRAME_COUNT; - handle->ae_gain_ctrl_num = 1; - handle->ae_shutter_ctrl_num = 1; - handle->sat_mingain = SENSOR_MIN_GAIN; //calibration - //handle->dgain_remainder = 0; - - //////////////////////////////////// - // AE Control and Get Info // - //////////////////////////////////// - // unit: micro seconds - //handle->pCus_sensor_GetAETrigger_mode = pCus_GetAETrigger_mode; - //handle->pCus_sensor_SetAETrigger_mode = pCus_SetAETrigger_mode; - handle->pCus_sensor_AEStatusNotify = pCus_AEStatusNotify; - handle->pCus_sensor_GetAEUSecs = pCus_GetAEUSecs; - handle->pCus_sensor_SetAEUSecs = pCus_SetAEUSecs; - handle->pCus_sensor_GetAEGain = pCus_GetAEGain; - handle->pCus_sensor_SetAEGain = pCus_SetAEGain; - - handle->pCus_sensor_GetAEMinMaxGain = pCus_GetAEMinMaxGain; - handle->pCus_sensor_GetAEMinMaxUSecs= pCus_GetAEMinMaxUSecs; - //handle->pCus_sensor_GetDGainRemainder = pCus_GetDGainRemainder; - - //sensor calibration - handle->pCus_sensor_SetAEGain_cal = pCus_SetAEGain_cal; - handle->pCus_sensor_setCaliData_gain_linearity=pCus_setCaliData_gain_linearity; - handle->pCus_sensor_GetShutterInfo = IMX335_GetShutterInfo; - - params->expo.vts = vts_30fps; - params->expo.expo_lines = 5000; - params->dirty = false; - - return SUCCESS; -} - -int cus_camsensor_init_handle_hdr_dol_sef1(ms_cus_sensor* drv_handle) -{ - ms_cus_sensor *handle = drv_handle; - imx335_params *params = NULL; - int res; - - if (!handle) { - SENSOR_DMSG("[%s] not enough memory!\n", __FUNCTION__); - return FAIL; - } - SENSOR_DMSG("[%s]", __FUNCTION__); - //////////////////////////////////// - // private data allocation & init // - //////////////////////////////////// - if (handle->private_data == NULL) { - SENSOR_EMSG("[%s] Private data is empty!\n", __FUNCTION__); - return FAIL; - } - - params = (imx335_params *)handle->private_data; - memcpy(params->tExpo_rhs1_reg, expo_rhs1_reg, sizeof(expo_rhs1_reg)); - memcpy(params->tExpo_shr_dol1_reg, expo_shr_dol1_reg, sizeof(expo_shr_dol1_reg)); - memcpy(params->tGain_hdr_dol_sef_reg, gain_HDR_DOL_SEF1_reg, sizeof(gain_HDR_DOL_SEF1_reg)); - - //////////////////////////////////// - // sensor model ID // - //////////////////////////////////// - sprintf(handle->model_id,"IMX335_MIPI_HDR_SEF"); - - //////////////////////////////////// - // i2c config // - //////////////////////////////////// - handle->i2c_cfg.mode = SENSOR_I2C_LEGACY; //(CUS_ISP_I2C_MODE) FALSE; - handle->i2c_cfg.fmt = SENSOR_I2C_FMT; //CUS_I2C_FMT_A16D16; - handle->i2c_cfg.address = SENSOR_I2C_ADDR; //0x5a; - handle->i2c_cfg.speed = SENSOR_I2C_SPEED; //320000; - - //////////////////////////////////// - // mclk // - //////////////////////////////////// - handle->mclk = Preview_MCLK_SPEED_HDR_DOL;//UseParaMclk(SENSOR_DRV_PARAM_MCLK()); - - //////////////////////////////////// - // sensor interface info // - //////////////////////////////////// - //handle->isp_type = SENSOR_ISP_TYPE; - //handle->data_fmt = SENSOR_DATAFMT; - handle->sif_bus = SENSOR_IFBUS_TYPE; - handle->data_prec = SENSOR_DATAPREC_DOL; - handle->data_mode = SENSOR_DATAMODE; - handle->bayer_id = SENSOR_BAYERID_HDR_DOL; - handle->RGBIR_id = SENSOR_RGBIRID; - - handle->interface_attr.attr_mipi.mipi_lane_num = SENSOR_MIPI_LANE_NUM_DOL; - handle->interface_attr.attr_mipi.mipi_data_format = CUS_SEN_INPUT_FORMAT_RGB; - handle->interface_attr.attr_mipi.mipi_hsync_mode = SENSOR_MIPI_HSYNC_MODE_HDR_DOL; - handle->interface_attr.attr_mipi.mipi_hdr_mode = CUS_HDR_MODE_SONY_DOL; - handle->interface_attr.attr_mipi.mipi_hdr_virtual_channel_num = 1; //Short frame - - //////////////////////////////////// - // resolution capability // - //////////////////////////////////// - handle->video_res_supported.ulcur_res = 0; //default resolution index is 0. - for (res = 0; res < HDR_RES_END; res++) { - handle->video_res_supported.num_res = res+1; - handle->video_res_supported.res[res].width = imx335_mipi_hdr[res].senif.preview_w; - handle->video_res_supported.res[res].height = imx335_mipi_hdr[res].senif.preview_h; - handle->video_res_supported.res[res].max_fps = imx335_mipi_hdr[res].senout.max_fps; - handle->video_res_supported.res[res].min_fps = imx335_mipi_hdr[res].senout.min_fps; - handle->video_res_supported.res[res].crop_start_x = imx335_mipi_hdr[res].senif.crop_start_X; - handle->video_res_supported.res[res].crop_start_y = imx335_mipi_hdr[res].senif.crop_start_y; - handle->video_res_supported.res[res].nOutputWidth = imx335_mipi_hdr[res].senout.width; - handle->video_res_supported.res[res].nOutputHeight = imx335_mipi_hdr[res].senout.height; - sprintf(handle->video_res_supported.res[res].strResDesc, imx335_mipi_hdr[res].senstr.strResDesc); - } - - //////////////////////////////////// - // Sensor polarity // - //////////////////////////////////// - handle->pwdn_POLARITY = SENSOR_PWDN_POL; //CUS_CLK_POL_NEG; - handle->reset_POLARITY = SENSOR_RST_POL; //CUS_CLK_POL_NEG; - //handle->VSYNC_POLARITY = SENSOR_VSYNC_POL; //CUS_CLK_POL_POS; - //handle->HSYNC_POLARITY = SENSOR_HSYNC_POL; //CUS_CLK_POL_POS; - handle->PCLK_POLARITY = SENSOR_PCLK_POL; //CUS_CLK_POL_POS); // use '!' to clear board latch error - - //////////////////////////////////////// - // Sensor Status Control and Get Info // - //////////////////////////////////////// - handle->pCus_sensor_release = cus_camsensor_release_handle; - handle->pCus_sensor_init = pCus_init_mipi4lane5m25fps_HDR_DOL; - handle->pCus_sensor_poweron = pCus_poweron; // Need to check - handle->pCus_sensor_poweroff = pCus_poweroff; - handle->pCus_sensor_GetSensorID = pCus_GetSensorID; - handle->pCus_sensor_GetVideoResNum = pCus_GetVideoResNum; - handle->pCus_sensor_SetVideoRes = pCus_SetVideoRes_HDR_DOL; - handle->pCus_sensor_GetVideoRes = pCus_GetVideoRes; - handle->pCus_sensor_GetCurVideoRes = pCus_GetCurVideoRes; - - handle->pCus_sensor_GetOrien = pCus_GetOrien; // Need to check - handle->pCus_sensor_SetOrien = pCus_SetOrien; // Need to check - handle->pCus_sensor_GetFPS = pCus_GetFPS_HDR_DOL_SEF1; - handle->pCus_sensor_SetFPS = pCus_SetFPS_HDR_DOL_SEF1; - - //////////////////////////////////// - // AE parameters // - //////////////////////////////////// - handle->ae_gain_delay = SENSOR_GAIN_DELAY_FRAME_COUNT_HDR_DOL; - handle->ae_shutter_delay = SENSOR_SHUTTER_DELAY_FRAME_COUNT_HDR_DOL; - handle->ae_gain_ctrl_num = 2; - handle->ae_shutter_ctrl_num = 2; - handle->sat_mingain = SENSOR_MIN_GAIN; //g_sensor_ae_min_gain; - //handle->dgain_remainder = 0; - - //////////////////////////////////// - // AE Control and Get Info // - //////////////////////////////////// - handle->pCus_sensor_AEStatusNotify = pCus_AEStatusNotifyHDR_DOL_SEF1; - handle->pCus_sensor_GetAEUSecs = pCus_GetAEUSecs; - handle->pCus_sensor_SetAEUSecs = pCus_SetAEUSecsHDR_DOL_SEF1; - handle->pCus_sensor_GetAEGain = pCus_GetAEGain; - handle->pCus_sensor_SetAEGain = pCus_SetAEGainHDR_DOL_SEF1; - handle->pCus_sensor_GetAEMinMaxGain = pCus_GetAEMinMaxGain; - handle->pCus_sensor_GetAEMinMaxUSecs= pCus_GetAEMinMaxUSecs; - - handle->pCus_sensor_GetShutterInfo = IMX335_GetShutterInfoHDR_DOL_SEF1; - params->expo.vts = vts_30fps_HDR_DOL; - params->expo.expo_lines = 4250; - return SUCCESS; -} - -//lef functions -static int pCus_init_HDR_DOL_LEF(ms_cus_sensor *handle) -{ - return SUCCESS; -} - -static int pCus_poweron_HDR_DOL_LEF(ms_cus_sensor *handle, u32 idx) -{ - return SUCCESS; -} - -static int pCus_poweroff_HDR_DOL_LEF(ms_cus_sensor *handle, u32 idx) -{ - return SUCCESS; -} - -static int pCus_GetSensorID_HDR_DOL_LEF(ms_cus_sensor *handle, u32 *id) -{ - *id = 0; - return SUCCESS; -} - -static int pCus_GetFPS_HDR_DOL_LEF(ms_cus_sensor *handle) -{ - imx335_params *params = (imx335_params *)handle->private_data; - u32 max_fps = handle->video_res_supported.res[handle->video_res_supported.ulcur_res].max_fps; - u32 tVts = (params->tVts_reg[0].data << 16) | (params->tVts_reg[1].data << 8) | (params->tVts_reg[2].data << 0); - - if (params->expo.fps >= 1000) - params->expo.preview_fps = (vts_30fps_HDR_DOL*max_fps*1000)/tVts; - else - params->expo.preview_fps = (vts_30fps_HDR_DOL*max_fps)/tVts; - - return params->expo.preview_fps; -} - -static int pCus_SetFPS_HDR_DOL_LEF(ms_cus_sensor *handle, u32 fps) -{ - u32 vts = 0; - imx335_params *params = (imx335_params *)handle->private_data; - u32 max_fps = handle->video_res_supported.res[handle->video_res_supported.ulcur_res].max_fps; - u32 min_fps = handle->video_res_supported.res[handle->video_res_supported.ulcur_res].min_fps; - - if(fps>=min_fps && fps <= max_fps){ - params->expo.fps = fps; - params->expo.vts= (vts_30fps_HDR_DOL*max_fps)/fps; - }else if((fps >= (min_fps*1000)) && (fps <= (max_fps*1000))){ - params->expo.fps = fps; - params->expo.vts= (vts_30fps_HDR_DOL*(max_fps*1000))/fps; - }else{ - //params->expo.vts=vts_30fps; - //params->expo.fps=30; - SENSOR_DMSG("[%s] FPS %d out of range.\n",__FUNCTION__,fps); - return FAIL; - } - - if(params->expo.expo_lines > 2 * params->expo.vts - params->max_rhs1 -18){ - vts = (params->expo.expo_lines + params->max_rhs1 + 18) / 2; - }else{ - vts = params->expo.vts; - } - - pCus_SetAEUSecsHDR_DOL_LEF(handle, params->expo.expo_lef_us); - - return SUCCESS; -} - -static int imx335_SetPatternMode_hdr_dol_lef(ms_cus_sensor *handle,u32 mode) -{ - return SUCCESS; -} - -static int pCus_AEStatusNotifyHDR_DOL_LEF(ms_cus_sensor *handle, CUS_CAMSENSOR_AE_STATUS_NOTIFY status) -{ - imx335_params *params = (imx335_params *)handle->private_data; - - switch(status) - { - case CUS_FRAME_INACTIVE: - break; - case CUS_FRAME_ACTIVE: - if(params->dirty || params->orien_dirty) - { - SensorReg_Write(0x3001,1); - SensorRegArrayW((I2C_ARRAY*)params->tExpo_shr_dol1_reg, ARRAY_SIZE(expo_shr_dol1_reg)); - SensorRegArrayW((I2C_ARRAY*)params->tVts_reg, ARRAY_SIZE(vts_reg)); - SensorRegArrayW((I2C_ARRAY*)params->tExpo_reg, ARRAY_SIZE(expo_reg)); - SensorRegArrayW((I2C_ARRAY*)params->tExpo_rhs1_reg, ARRAY_SIZE(expo_rhs1_reg)); - SensorRegArrayW((I2C_ARRAY*)params->tGain_hdr_dol_lef_reg, ARRAY_SIZE(gain_HDR_DOL_LEF_reg)); - SensorRegArrayW((I2C_ARRAY*)params->tGain_hdr_dol_sef_reg, ARRAY_SIZE(gain_HDR_DOL_SEF1_reg)); - - if(params->orien_dirty) { - DoOrien(handle, handle->orient); - params->orien_dirty = false; - } - SensorReg_Write(0x3001,0); - } - break; - default : - break; - } - return SUCCESS; -} - -static int pCus_GetAEUSecs_HDR_DOL_LEF(ms_cus_sensor *handle, u32 *us) -{ - *us = 0; - return SUCCESS; -} - -static int pCus_SetAEUSecsHDR_DOL_LEF(ms_cus_sensor *handle, u32 us) -{ - u32 qua_lines = 0,lines = 0, half_vts = 0, vts = 0, shr_dol0 = 0, fsc = 0; - imx335_params *params = (imx335_params *)handle->private_data; - - qua_lines = (1000 * us) / Preview_line_period_HDR_DOL / 4; - // lines=us/Preview_line_period_HDR_DOL; - params->expo.expo_lef_us = us; - - if (4 * qua_lines > 2 * params->expo.vts - params->max_rhs1 - 18) { // shs2 > max_rhs1 +2 - half_vts = (4 * qua_lines + params->max_rhs1 + 19) / 4; - } - else{ - half_vts = params->expo.vts / 2; - } - - SENSOR_DMSG("[%s] us %u, qua_lines %u, vts %u\n", __FUNCTION__, - us, - qua_lines, - params->expo.vts - ); - - //exposure limit lines = fsc - (shs2 + 1) = fsc - 1 - ( rhs1 + 2 ~ fsc - 2) = 1 ~ fsc - 104 (rhs1 fix to 101) - vts = half_vts * 2; - fsc = half_vts * 4; - if(qua_lines < 1) // shs2 < fsc - 2 - qua_lines = 1; - if(4 * qua_lines > fsc - params->max_rhs1 - 18) - qua_lines = (fsc - params->max_rhs1 - 18) / 4; - - lines = 4*qua_lines; - params->expo.expo_lines = lines; - - shr_dol0 = fsc - lines; -#if 0 - printk("[%s] us %u, qua_lines %u, vts %u shr_dol0 %u\n", __FUNCTION__, - us, - qua_lines, - params->expo.vts, - shr_dol0 - ); -#endif - params->tExpo_reg[0].data = (shr_dol0 >> 16) & 0x000f; - params->tExpo_reg[1].data = (shr_dol0 >> 8) & 0x00ff; - params->tExpo_reg[2].data = (shr_dol0 >> 0) & 0x00ff; - - params->tVts_reg[0].data = (vts >> 16) & 0x000f; - params->tVts_reg[1].data = (vts >> 8) & 0x00ff; - params->tVts_reg[2].data = (vts >> 0) & 0x00ff; - - params->dirty = true; - return SUCCESS; -} - -static int pCus_GetAEGain_HDR_DOL_LEF(ms_cus_sensor *handle, u32* gain) -{ - *gain = 0; - return SUCCESS; -} - -static int pCus_SetAEGainHDR_DOL_LEF(ms_cus_sensor *handle, u32 gain) -{ - imx335_params *params = (imx335_params *)handle->private_data; - u16 gain_reg = 0; - - pCus_SetAEGainHDR_DOL_Calculate(gain, &gain_reg); - params->tGain_hdr_dol_lef_reg[0].data = gain_reg & 0x00ff; - params->tGain_hdr_dol_lef_reg[1].data = (gain_reg>>8) & 0x0007; - - SENSOR_DMSG("[%s] set gain/reg=%u/0x%x\n", __FUNCTION__, gain, params->tGain_hdr_dol_lef_reg[0].data); - - params->dirty = true; - return SUCCESS; -} - -static int pCus_GetAEMinMaxGain_HDR_DOL_LEF(ms_cus_sensor *handle, u32 *min, u32 *max) -{ - *min = handle->sat_mingain; - *max = SENSOR_MAX_GAIN; - return SUCCESS; -} - -static int pCus_GetAEMinMaxUSecs_HDR_DOL_LEF(ms_cus_sensor *handle, u32 *min, u32 *max) -{ - *min = 1; - *max = 1000000/imx335_mipi_linear[0].senout.min_fps; - return SUCCESS; -} - -static int pCus_SetAEGain_cal_hdr_dol_lef(ms_cus_sensor *handle, u32 gain) -{ - return SUCCESS; -} - -static int pCus_setCaliData_gain_linearity_hdr_dol_lef(ms_cus_sensor* handle, CUS_GAIN_GAP_ARRAY* pArray, u32 num) -{ - return SUCCESS; -} - -static int IMX335_GetShutterInfo_hdr_dol_lef(struct __ms_cus_sensor* handle,CUS_SHUTTER_INFO *info) -{ - info->max = 1000000000/imx335_mipi_linear[0].senout.min_fps; - info->min = (Preview_line_period_HDR_DOL * 4); - info->step = Preview_line_period_HDR_DOL * 4; - return SUCCESS; -} - -static int cus_camsensor_init_handle_hdr_dol_lef(ms_cus_sensor* drv_handle) -{ - ms_cus_sensor *handle = drv_handle; - imx335_params *params; - s32 res; - - if (!handle) { - SENSOR_DMSG("[%s] not enough memory!\n", __FUNCTION__); - return FAIL; - } - - //private data allocation & init - if (handle->private_data == NULL) { - SENSOR_EMSG("[%s] Private data is empty!\n", __FUNCTION__); - return FAIL; - } - params = (imx335_params *)handle->private_data; - memcpy(params->tVts_reg, vts_reg, sizeof(vts_reg)); - memcpy(params->tExpo_reg, expo_reg, sizeof(expo_reg)); - memcpy(params->tGain_hdr_dol_lef_reg, gain_HDR_DOL_LEF_reg, sizeof(gain_HDR_DOL_LEF_reg)); - - //////////////////////////////////// - // sensor model ID // - //////////////////////////////////// - sprintf(handle->model_id,"IMX335_MIPI_HDR_LEF"); - - //////////////////////////////////// - // i2c config // - //////////////////////////////////// - handle->i2c_cfg.mode = SENSOR_I2C_LEGACY; //(CUS_ISP_I2C_MODE) FALSE; - handle->i2c_cfg.fmt = SENSOR_I2C_FMT; //CUS_I2C_FMT_A16D16; - handle->i2c_cfg.address = SENSOR_I2C_ADDR; //0x5a; - handle->i2c_cfg.speed = SENSOR_I2C_SPEED; //320000; - - //////////////////////////////////// - // mclk // - //////////////////////////////////// - handle->mclk = Preview_MCLK_SPEED_HDR_DOL;//UseParaMclk(SENSOR_DRV_PARAM_MCLK()); - //sensor_if->MCLK(0,1,handle->mclk); - - //////////////////////////////////// - // sensor interface info // - //////////////////////////////////// - handle->isp_type = SENSOR_ISP_TYPE; //ISP_SOC; - //handle->data_fmt = SENSOR_DATAFMT; //CUS_DATAFMT_YUV; - handle->sif_bus = SENSOR_IFBUS_TYPE;//CUS_SENIF_BUS_PARL; - handle->data_prec = SENSOR_DATAPREC_DOL; //CUS_DATAPRECISION_8; - handle->data_mode = SENSOR_DATAMODE; - handle->bayer_id = SENSOR_BAYERID_HDR_DOL; //CUS_BAYER_GB; - handle->RGBIR_id = SENSOR_RGBIRID; - handle->orient = SENSOR_ORIT; //CUS_ORIT_M1F1; - //handle->YC_ODER = SENSOR_YCORDER; //CUS_SEN_YCODR_CY; - handle->interface_attr.attr_mipi.mipi_lane_num = SENSOR_MIPI_LANE_NUM_DOL; - handle->interface_attr.attr_mipi.mipi_data_format = CUS_SEN_INPUT_FORMAT_RGB; // RGB pattern. - handle->interface_attr.attr_mipi.mipi_yuv_order = 0; //don't care in RGB pattern. - handle->interface_attr.attr_mipi.mipi_hsync_mode = SENSOR_MIPI_HSYNC_MODE_HDR_DOL; - handle->interface_attr.attr_mipi.mipi_hdr_mode = CUS_HDR_MODE_SONY_DOL; - handle->interface_attr.attr_mipi.mipi_hdr_virtual_channel_num = 0; //Long frame - - //////////////////////////////////// - // resolution capability // - //////////////////////////////////// - handle->video_res_supported.ulcur_res = 0; //default resolution index is 0. - for (res = 0; res < HDR_RES_END; res++) { - handle->video_res_supported.num_res = res+1; - handle->video_res_supported.res[res].width = imx335_mipi_hdr[res].senif.preview_w; - handle->video_res_supported.res[res].height = imx335_mipi_hdr[res].senif.preview_h; - handle->video_res_supported.res[res].max_fps = imx335_mipi_hdr[res].senout.max_fps; - handle->video_res_supported.res[res].min_fps = imx335_mipi_hdr[res].senout.min_fps; - handle->video_res_supported.res[res].crop_start_x = imx335_mipi_hdr[res].senif.crop_start_X; - handle->video_res_supported.res[res].crop_start_y = imx335_mipi_hdr[res].senif.crop_start_y; - handle->video_res_supported.res[res].nOutputWidth = imx335_mipi_hdr[res].senout.width; - handle->video_res_supported.res[res].nOutputHeight = imx335_mipi_hdr[res].senout.height; - sprintf(handle->video_res_supported.res[res].strResDesc, imx335_mipi_hdr[res].senstr.strResDesc); - } - - //////////////////////////////////// - // Sensor polarity // - //////////////////////////////////// - handle->pwdn_POLARITY = SENSOR_PWDN_POL; //CUS_CLK_POL_NEG; - handle->reset_POLARITY = SENSOR_RST_POL; //CUS_CLK_POL_NEG; - //handle->VSYNC_POLARITY = SENSOR_VSYNC_POL; //CUS_CLK_POL_POS; - //handle->HSYNC_POLARITY = SENSOR_HSYNC_POL; //CUS_CLK_POL_POS; - handle->PCLK_POLARITY = SENSOR_PCLK_POL; //CUS_CLK_POL_POS); // use '!' to clear board latch error - - //////////////////////////////////////// - // Sensor Status Control and Get Info // - //////////////////////////////////////// - handle->pCus_sensor_release = cus_camsensor_release_handle; - handle->pCus_sensor_init = pCus_init_HDR_DOL_LEF; - handle->pCus_sensor_poweron = pCus_poweron_HDR_DOL_LEF; - handle->pCus_sensor_poweroff = pCus_poweroff_HDR_DOL_LEF; - handle->pCus_sensor_GetSensorID = pCus_GetSensorID_HDR_DOL_LEF; - handle->pCus_sensor_GetVideoResNum = pCus_GetVideoResNum; - handle->pCus_sensor_SetVideoRes = pCus_SetVideoRes_HDR_DOL_LEF; - handle->pCus_sensor_GetVideoRes = pCus_GetVideoRes; - handle->pCus_sensor_GetCurVideoRes = pCus_GetCurVideoRes; - - handle->pCus_sensor_GetOrien = pCus_GetOrien; //pCus_GetOrien_HDR_DOL_LEF - handle->pCus_sensor_SetOrien = pCus_SetOrien; //pCus_SetOrien_HDR_DOL_LEF - handle->pCus_sensor_GetFPS = pCus_GetFPS_HDR_DOL_LEF; - handle->pCus_sensor_SetFPS = pCus_SetFPS_HDR_DOL_LEF; - - handle->pCus_sensor_SetPatternMode = imx335_SetPatternMode_hdr_dol_lef; - - //////////////////////////////////// - // AE parameters // - //////////////////////////////////// - handle->ae_gain_delay = SENSOR_GAIN_DELAY_FRAME_COUNT_HDR_DOL; - handle->ae_shutter_delay = SENSOR_SHUTTER_DELAY_FRAME_COUNT_HDR_DOL; - handle->ae_gain_ctrl_num = 2; - handle->ae_shutter_ctrl_num = 2; - handle->sat_mingain = SENSOR_MIN_GAIN; - //handle->dgain_remainder = 0; - - //////////////////////////////////// - // AE Control and Get Info // - //////////////////////////////////// - handle->pCus_sensor_AEStatusNotify = pCus_AEStatusNotifyHDR_DOL_LEF; - handle->pCus_sensor_GetAEUSecs = pCus_GetAEUSecs_HDR_DOL_LEF; - handle->pCus_sensor_SetAEUSecs = pCus_SetAEUSecsHDR_DOL_LEF; - handle->pCus_sensor_GetAEGain = pCus_GetAEGain_HDR_DOL_LEF; - handle->pCus_sensor_SetAEGain = pCus_SetAEGainHDR_DOL_LEF; - handle->pCus_sensor_GetAEMinMaxGain = pCus_GetAEMinMaxGain_HDR_DOL_LEF; - handle->pCus_sensor_GetAEMinMaxUSecs= pCus_GetAEMinMaxUSecs_HDR_DOL_LEF; - //handle->pCus_sensor_GetDGainRemainder = pCus_GetDGainRemainder; - - //sensor calibration - handle->pCus_sensor_SetAEGain_cal = pCus_SetAEGain_cal_hdr_dol_lef; - handle->pCus_sensor_setCaliData_gain_linearity = pCus_setCaliData_gain_linearity_hdr_dol_lef; - handle->pCus_sensor_GetShutterInfo = IMX335_GetShutterInfo_hdr_dol_lef; - - params->expo.vts = vts_30fps_HDR_DOL; - params->expo.expo_lines = 673; - params->expo.fps = 25; - params->dirty = false; - - return SUCCESS; -} - -SENSOR_DRV_ENTRY_IMPL_END_EX(IMX335_HDR, - cus_camsensor_init_handle_linear, - cus_camsensor_init_handle_hdr_dol_sef1, - cus_camsensor_init_handle_hdr_dol_lef, - imx335_params - ); diff --git a/general/package/sigmastar-osdrv-sensor/src/infinity6e/sensor/sensor_imx347_mipi.c b/general/package/sigmastar-osdrv-sensor/src/infinity6e/sensor/sensor_imx347_mipi.c deleted file mode 100644 index 25eb1639..00000000 --- a/general/package/sigmastar-osdrv-sensor/src/infinity6e/sensor/sensor_imx347_mipi.c +++ /dev/null @@ -1,2199 +0,0 @@ -/* Copyright (c) 2018-2019 Sigmastar Technology Corp. - All rights reserved. - - Unless otherwise stipulated in writing, any and all information contained -herein regardless in any format shall remain the sole proprietary of -Sigmastar Technology Corp. and be kept in strict confidence -(Sigmastar Confidential Information) by the recipient. -Any unauthorized act including without limitation unauthorized disclosure, -copying, use, reproduction, sale, distribution, modification, disassembling, -reverse engineering and compiling of the contents of Sigmastar Confidential -Information is unlawful and strictly prohibited. Sigmastar hereby reserves the -rights to any and all damages, losses, costs and expenses resulting therefrom. -*/ - -#ifdef __cplusplus -extern "C" -{ -#endif - -#include -#include -#include -#include //TODO: move this header to drv_sensor_common.h -#ifdef __cplusplus -} -#endif - -SENSOR_DRV_ENTRY_IMPL_BEGIN_EX(IMX347_HDR); - -#ifndef ARRAY_SIZE -#define ARRAY_SIZE CAM_OS_ARRAY_SIZE -#endif - -//#define SENSOR_PAD_GROUP_SET CUS_SENSOR_PAD_GROUP_A -//#define SENSOR_CHANNEL_NUM (0) -#define SENSOR_CHANNEL_MODE CUS_SENSOR_CHANNEL_MODE_REALTIME_NORMAL -#define SENSOR_CHANNEL_MODE_SONY_DOL CUS_SENSOR_CHANNEL_MODE_RAW_STORE_HDR - -//============================================ -#define ENABLE 1 -#define DISABLE 0 -#undef SENSOR_DBG -#define SENSOR_DBG 1 - -#define DEBUG_INFO 0 - -#if SENSOR_DBG == 1 -//#define SENSOR_DMSG(args...) LOGD(args) -//#define SENSOR_DMSG(args...) LOGE(args) -//#define SENSOR_DMSG(args...) printf(args) -#elif SENSOR_DBG == 0 -//#define SENSOR_DMSG(args...) -#endif -/////////////////////////////////////////////////////////////// -// @@@ // -// @ @@ == S t a r t * H e r e == // -// @@ == S t a r t * H e r e == // -// @@ == S t a r t * H e r e == // -// @@@@ // -// // -// Start Step 1 -- show preview on LCM // -// // -// Fill these #define value and table with correct settings // -// camera can work and show preview on LCM // -// // -/////////////////////////////////////////////////////////////// - -//////////////////////////////////// -// Sensor-If Info // -//////////////////////////////////// -//MIPI config begin. -#define SENSOR_MIPI_LANE_NUM (4) -#define SENSOR_MIPI_LANE_NUM_DOL (4) -//#define SENSOR_MIPI_HDR_MODE (0) //0: Non-HDR mode. 1:Sony DOL mode - -#define SENSOR_ISP_TYPE ISP_EXT //ISP_EXT, ISP_SOC (Non-used) -//#define SENSOR_DATAFMT CUS_DATAFMT_BAYER //CUS_DATAFMT_YUV, CUS_DATAFMT_BAYER -#define SENSOR_IFBUS_TYPE CUS_SENIF_BUS_MIPI //CFG //CUS_SENIF_BUS_PARL, CUS_SENIF_BUS_MIPI -#define SENSOR_MIPI_HSYNC_MODE PACKET_HEADER_EDGE1 -#define SENSOR_MIPI_HSYNC_MODE_HDR_DOL PACKET_FOOTER_EDGE -#define SENSOR_DATAPREC CUS_DATAPRECISION_12 -#define SENSOR_DATAPREC_DOL CUS_DATAPRECISION_12 -#define SENSOR_DATAMODE CUS_SEN_10TO12_9098 //CFG -#define SENSOR_BAYERID CUS_BAYER_RG //0h: CUS_BAYER_RG, 1h: CUS_BAYER_GR, 2h: CUS_BAYER_BG, 3h: CUS_BAYER_GB -#define SENSOR_BAYERID_HDR_DOL CUS_BAYER_RG -#define SENSOR_RGBIRID CUS_RGBIR_NONE -#define SENSOR_ORIT CUS_ORIT_M0F0 //CUS_ORIT_M0F0, CUS_ORIT_M1F0, CUS_ORIT_M0F1, CUS_ORIT_M1F1, - -//////////////////////////////////// -// MCLK Info // -//////////////////////////////////// -#define Preview_MCLK_SPEED CUS_CMU_CLK_24MHZ //CUS_CMU_CLK_24MHZ //CUS_CMU_CLK_37P125MHZ//CUS_CMU_CLK_27MHZ -#define Preview_MCLK_SPEED_HDR_DOL CUS_CMU_CLK_27MHZ - -//////////////////////////////////// -// I2C Info // -//////////////////////////////////// -#define SENSOR_I2C_ADDR 0x6e //0x34 //I2C slave address -#define SENSOR_I2C_SPEED 300000 //200000 //300000 //240000 //I2C speed, 60000~320000 -//#define SENSOR_I2C_CHANNEL 1 //I2C Channel -//#define SENSOR_I2C_PAD_MODE 2 //Pad/Mode Number -#define SENSOR_I2C_LEGACY I2C_NORMAL_MODE //usally set CUS_I2C_NORMAL_MODE, if use old OVT I2C protocol=> set CUS_I2C_LEGACY_MODE -#define SENSOR_I2C_FMT I2C_FMT_A16D8 //CUS_I2C_FMT_A8D8, CUS_I2C_FMT_A8D16, CUS_I2C_FMT_A16D8, CUS_I2C_FMT_A16D16 - -//////////////////////////////////// -// Sensor Signal // -//////////////////////////////////// -#define SENSOR_PWDN_POL CUS_CLK_POL_NEG // if PWDN pin High can makes sensor in power down, set CUS_CLK_POL_POS -#define SENSOR_RST_POL CUS_CLK_POL_NEG // if RESET pin High can makes sensor in reset state, set CUS_CLK_POL_NEG - // VSYNC/HSYNC POL can be found in data sheet timing diagram, - // Notice: the initial setting may contain VSYNC/HSYNC POL inverse settings so that condition is different. -#define SENSOR_VSYNC_POL CUS_CLK_POL_NEG // if VSYNC pin High and data bus have data, set CUS_CLK_POL_POS -#define SENSOR_HSYNC_POL CUS_CLK_POL_NEG // if HSYNC pin High and data bus have data, set CUS_CLK_POL_POS -#define SENSOR_PCLK_POL CUS_CLK_POL_NEG // depend on sensor setting, sometimes need to try CUS_CLK_POL_POS or CUS_CLK_POL_NEG - -//////////////////////////////////// -// Sensor ID // -//////////////////////////////////// -//define SENSOR_ID - -#undef SENSOR_NAME -#define SENSOR_NAME IMX347 - -#define CHIP_ID_r3F12 0x3F12 -#define CHIP_ID_r3F13 0x3F13 -#define CHIP_ID 0x0415 -int HDR_Ratio = 16; - -//////////////////////////////////// -// Image Info // -//////////////////////////////////// -static struct { // LINEAR - // Modify it based on number of support resolution - enum {LINEAR_RES_1 = 0, LINEAR_RES_2, LINEAR_RES_3, LINEAR_RES_END}mode; - // Sensor Output Image info - struct _senout{ - s32 width, height, min_fps, max_fps; - }senout; - // VIF Get Image Info - struct _sensif{ - s32 crop_start_X, crop_start_y, preview_w, preview_h; - }senif; - // Show resolution string - struct _senstr{ - const char* strResDesc; - }senstr; -}imx347_mipi_linear[] = { - {LINEAR_RES_1, {2712, 1536, 3, 30}, {12, 8, 2688, 1520}, {"2688x1520@30fps"}}, - {LINEAR_RES_2, {2712, 1536, 3, 30}, {152, 48, 2560, 1440}, {"2560x1440@30fps"}}, // Modify it - {LINEAR_RES_3, {2712, 1536, 3, 30}, {396, 228, 1920, 1080}, {"1920x1080@30fps"}}, // Modify it -}; - -static struct { // HDR - // Modify it based on number of support resolution - enum {HDR_RES_1 = 0, HDR_RES_2, HDR_RES_3, HDR_RES_END}mode; - // Sensor Output Image info - struct _hsenout{ - s32 width, height, min_fps, max_fps; - }senout; - // VIF Get Image Info - struct _hsensif{ - s32 crop_start_X, crop_start_y, preview_w, preview_h; - }senif; - // Show resolution string - struct _hsenstr{ - const char* strResDesc; - }senstr; -}imx347_mipi_hdr[] = { - {HDR_RES_1, {2712, 1536, 3, 30}, {12, 8, 2688, 1520}, {"2688x1520@30fps_HDR"}}, // Modify it - {HDR_RES_2, {2712, 1536, 3, 30}, {152, 48, 2560, 1440}, {"2560x1440@30fps_HDR"}}, // Modify it - {HDR_RES_3, {2712, 1536, 3, 30}, {396, 228, 1920, 1080}, {"1920x1080@30fps_HDR"}}, // Modify it -}; - -#define IMX347_HDR_BRL 1650 - -u32 vts_30fps = 2666; -u32 vts_30fps_HDR_DOL_4lane = 1650; -u32 Preview_line_period = 12503; -u32 Preview_line_period_HDR_DOL_4LANE = 20202; - -//////////////////////////////////// -// AE Info // -//////////////////////////////////// -#define SENSOR_MAX_GAIN (3981 * 1024) // max sensor again, a-gain * conversion-gain*d-gain -#define SENSOR_MIN_GAIN (1 * 1024) -#define SENSOR_GAIN_DELAY_FRAME_COUNT (2) -#define SENSOR_SHUTTER_DELAY_FRAME_COUNT (2) -#define SENSOR_SHUTTER_DELAY_FRAME_COUNT_HDR_DOL (2) - -#if defined (SENSOR_MODULE_VERSION) -#define TO_STR_NATIVE(e) #e -#define TO_STR_PROXY(m, e) m(e) -#define MACRO_TO_STRING(e) TO_STR_PROXY(TO_STR_NATIVE, e) -static char *sensor_module_version = MACRO_TO_STRING(SENSOR_MODULE_VERSION); -module_param(sensor_module_version, charp, S_IRUGO); -#endif - -typedef struct { - struct { - u16 pre_div0; - u16 div124; - u16 div_cnt7b; - u16 sdiv0; - u16 mipi_div0; - u16 r_divp; - u16 sdiv1; - u16 r_seld5; - u16 r_sclk_dac; - u16 sys_sel; - u16 pdac_sel; - u16 adac_sel; - u16 pre_div_sp; - u16 r_div_sp; - u16 div_cnt5b; - u16 sdiv_sp; - u16 div12_sp; - u16 mipi_lane_sel; - u16 div_dac; - } clk_tree; - struct { - bool bVideoMode; - u16 res_idx; - CUS_CAMSENSOR_ORIT orit; - } res; - struct { - float sclk; - u32 hts; - u32 vts; - u32 ho; - u32 xinc; - u32 line_freq; - u32 us_per_line; - u32 final_us; - u32 final_gain; - u32 back_pv_us; - u32 fps; - u32 preview_fps; - u32 expo_lines; - u32 expo_lef_us; - u32 expo_sef_us; - } expo; - u32 min_shr1; - u32 min_rhs1; - u32 min_shr0; - u32 max_shr0; - u32 fsc; - I2C_ARRAY tVts_reg[3]; - I2C_ARRAY tVts_reg_hdr[3]; - I2C_ARRAY tExpo_reg[3]; - I2C_ARRAY tSHR0_reg[3]; - I2C_ARRAY tSHR1_reg[3]; - I2C_ARRAY tRHS1_reg[3]; - I2C_ARRAY tGain_reg[2]; - I2C_ARRAY tGain_hdr_dol_lef_reg[2]; - I2C_ARRAY tGain_hdr_dol_sef_reg[2]; - bool dirty; - bool orien_dirty; -} imx347_params; - -static int pCus_SetAEUSecs(ms_cus_sensor *handle, u32 us); -static int pCus_SetAEUSecsHDR_DOL_SEF(ms_cus_sensor *handle, u32 us); -static int pCus_SetAEUSecsHDR_DOL_LEF(ms_cus_sensor *handle, u32 us); -/////////////////////////////////////////////////////////////// -// @@@ // -// @ @@ // -// @@ // -// @@ // -// @@@@@ // -// // -// Start Step 2 -- set Sensor initial and // -// adjust parameter // -// Fill these register table with resolution settings // -// camera can work and show preview on LCM // -// // -/////////////////////////////////////////////////////////////// -const static I2C_ARRAY Sensor_init_table_4lane_linear[] = -{ -/* -IMX347LQR All-pixel scan AD:12bit Output:12bit CSI-2_4lane 720Mbps INCK_24MHz Master Mode LCG Mode 50fps Integration Time 10ms Gain:6dB -Tool ver : Ver2.0 -*/ - {0x3000, 0x01},//Standby - {0x3002, 0x01},//Master mode stopx - {0x300C, 0x3B},// BCWAIT_TIME[7:0] - {0x300D, 0x2A},// CPWAIT_TIME[7:0] - {0x3030, 0x40},// VMAX[19:0] - - {0x3056, 0x00},//y_out_size lsb 0x02 - {0x3057, 0x06},//y_out_size msb 0x06 - - {0x3058, 0x20},// SHR0[19:0] - {0x3059, 0x03},// - {0x30BE, 0x5E},// - - {0x30C6, 0x00},// BLACK_OFSET_ADR[12:0] - {0x30CE, 0x00},// UNRD_LINE_MAX[12:0] - {0x30D8, 0x4F},// UNREAD_ED_ADR[12:0] - {0x30D9, 0x64},// - {0x30E8, 0x14},// GAIN[10:0] - {0x3110, 0x02},// - - {0x314C, 0xF0},// INCKSEL1[8:0] - {0x315A, 0x06},// INCKSEL2[1:0] - {0x3168, 0x82},// INCKSEL3[7:0] - {0x316A, 0x7E},// INCKSEL4[1:0] - {0x319E, 0x02},// SYS_MODE[1:0] - {0x31A1, 0x00},// XVS_DRV[1:0] - {0x3202, 0x02},// - - {0x3288, 0x22},// - - {0x328A, 0x02},// - - {0x328C, 0xA2},// - - {0x328E, 0x22},// - - {0x3415, 0x27},// - - {0x3418, 0x27},// - - {0x3428, 0xFE},// - - {0x349E, 0x6A},// - - {0x34A2, 0x9A},// - - {0x34A4, 0x8A},// - - {0x34A6, 0x8E},// - - {0x34AA, 0xD8},// - - {0x3648, 0x01},// - - {0x3678, 0x01},// - - {0x367C, 0x69},// - - {0x367E, 0x69},// - - {0x3680, 0x69},// - - {0x3682, 0x69},// - - {0x371D, 0x05},// - - {0x375D, 0x11},// - - {0x375E, 0x43},// - - {0x375F, 0x76},// - - {0x3760, 0x07},// - - {0x3768, 0x1B},// - - {0x3769, 0x1B},// - - {0x376A, 0x1A},// - - {0x376B, 0x19},// - - {0x376C, 0x17},// - - {0x376D, 0x0F},// - - {0x376E, 0x0B},// - - {0x376F, 0x0B},// - - {0x3770, 0x0B},// - - {0x3776, 0x89},// - - {0x3777, 0x00},// - - {0x3778, 0xCA},// - - {0x3779, 0x00},// - - {0x377A, 0x45},// - - {0x377B, 0x01},// - - {0x377C, 0x56},// - - {0x377D, 0x02},// - - {0x377E, 0xFE},// - - {0x377F, 0x03},// - - {0x3780, 0xFE},// - - {0x3781, 0x05},// - - {0x3782, 0xFE},// - - {0x3783, 0x06},// - - {0x3784, 0x7F},// - - {0x3788, 0x1F},// - - {0x378A, 0xCA},// - - {0x378B, 0x00},// - - {0x378C, 0x45},// - - {0x378D, 0x01},// - - {0x378E, 0x56},// - - {0x378F, 0x02},// - - {0x3790, 0xFE},// - - {0x3791, 0x03},// - - {0x3792, 0xFE},// - - {0x3793, 0x05},// - - {0x3794, 0xFE},// - - {0x3795, 0x06},// - - {0x3796, 0x7F},// - - {0x3798, 0xBF},// - - {0x3A18, 0x6F},// TCLKPOST[9:0] - {0x3A1A, 0x2F},// TCLKPREPARE[9:0] - {0x3A1C, 0x2F},// TCLKTRAIL[9:0] - {0x3A1E, 0xBF},// TCLKZERO[9:0] - {0x3A1F, 0x00},// - {0x3A20, 0x2F},// THSPREPARE[9:0] - {0x3A22, 0x57},// THSZERO[9:0] - {0x3A24, 0x2F},// THSTRAIL[9:0] - {0x3A26, 0x4F},// THSEXIT[9:0] - {0x3A28, 0x27},// TLPX[9:0] - {0x3000, 0x00},// STANDBY Release - {0x3002, 0x00},// MASTER MODE Start -}; - -const static I2C_ARRAY Sensor_init_table_4lane_HDR_DOL[] = -{ - /* - IMX347LQR All-pixel scan - CSI-2_4lane - 27MHz - AD:12bit Output:12bit - 1188Mbps - Master Mode LCG Mode DOL HDR 2frame VC - 30fps - Integration Time LEF:32ms SEF:0.202ms - Tool ver : Ver2.0 - */ - {0x3000, 0x01},//Standby - {0x3002, 0x01},//Master mode stopx - {0x300C, 0x42},// BCWAIT_TIME[7:0] - {0x300D, 0x2E},// CPWAIT_TIME[7:0] - {0x3048, 0x01},// WDMODE[0] - {0x3049, 0x01},// WDSEL[1:0] - {0x304A, 0x04},// WD_SET1[2:0] - {0x304B, 0x04},// WD_SET2[3:0] - {0x304C, 0x13},// OPB_SIZE_V[5:0] - - {0x3056, 0x00},//y_out_size lsb 0x02 - {0x3057, 0x06},//y_out_size msb 0x06 - - {0x3058, 0x84},// SHR0[19:0] - {0x3068, 0x1D},// RHS1[19:0] - {0x30BE, 0x5E}, - {0x3110, 0x02}, - {0x314C, 0xB0},// INCKSEL1[8:0] - {0x315A, 0x02},// INCKSEL2[1:0] - {0x3168, 0x8F},// INCKSEL3[7:0] - {0x316A, 0x7E},// INCKSEL4[1:0] - {0x31A1, 0x00},// XVS_DRV[1:0] - {0x31D7, 0x01},// XVSMSKCNT_INT[1:0] - {0x3202, 0x02}, - {0x3288, 0x22}, - {0x328A, 0x02}, - {0x328C, 0xA2}, - {0x328E, 0x22}, - {0x3415, 0x27}, - {0x3418, 0x27}, - {0x3428, 0xFE}, - {0x349E, 0x6A}, - {0x34A2, 0x9A}, - {0x34A4, 0x8A}, - {0x34A6, 0x8E}, - {0x34AA, 0xD8}, - {0x3648, 0x01}, - {0x3678, 0x01}, - {0x367C, 0x69}, - {0x367E, 0x69}, - {0x3680, 0x69}, - {0x3682, 0x69}, - {0x371D, 0x05}, - {0x375D, 0x11}, - {0x375E, 0x43}, - {0x375F, 0x76}, - {0x3760, 0x07}, - {0x3768, 0x1B}, - {0x3769, 0x1B}, - {0x376A, 0x1A}, - {0x376B, 0x19}, - {0x376C, 0x17}, - {0x376D, 0x0F}, - {0x376E, 0x0B}, - {0x376F, 0x0B}, - {0x3770, 0x0B}, - {0x3776, 0x89}, - {0x3777, 0x00}, - {0x3778, 0xCA}, - {0x3779, 0x00}, - {0x377A, 0x45}, - {0x377B, 0x01}, - {0x377C, 0x56}, - {0x377D, 0x02}, - {0x377E, 0xFE}, - {0x377F, 0x03}, - {0x3780, 0xFE}, - {0x3781, 0x05}, - {0x3782, 0xFE}, - {0x3783, 0x06}, - {0x3784, 0x7F}, - {0x3788, 0x1F}, - {0x378A, 0xCA}, - {0x378B, 0x00}, - {0x378C, 0x45}, - {0x378D, 0x01}, - {0x378E, 0x56}, - {0x378F, 0x02}, - {0x3790, 0xFE}, - {0x3791, 0x03}, - {0x3792, 0xFE}, - {0x3793, 0x05}, - {0x3794, 0xFE}, - {0x3795, 0x06}, - {0x3796, 0x7F}, - {0x3798, 0xBF}, - {0xffff, 0x10}, - {0x3000, 0x00}, //Operating - {0xffff, 0x10}, - {0x3002, 0x00}, //Master mode start - {0x3260, 0x00}, //Gain_Pgc_Fidmd -}; - -const static I2C_ARRAY Sensor_id_table[] = { - {0x3F12, 0x14}, // {address of ID, ID }, - {0x3F13, 0x75}, // {address of ID, ID }, -}; - -static I2C_ARRAY PatternTbl[] = { - {0x0000,0x00}, // colorbar pattern , bit 0 to enable -}; - -const static I2C_ARRAY expo_reg[] = { // SHS0 (For Linear) - {0x305a, 0x00}, - {0x3059, 0x00}, - {0x3058, 0x08}, -}; - -const static I2C_ARRAY expo_SHR0_reg[] = { // SHS0 (For LEF) - {0x305a, 0x00}, - {0x3059, 0x00}, - {0x3058, 0x84}, -}; - -const static I2C_ARRAY expo_SHR1_reg[] = { // SHS1 (For SEF) - //decreasing exposure ratio version. - {0x305e, 0x00}, - {0x305d, 0x00}, - {0x305c, 0x09}, -}; - -const static I2C_ARRAY vts_reg[] = { //VMAX - {0x3032, 0x00}, //bit0-3-->MSB - {0x3031, 0x06}, - {0x3030, 0x72}, -}; - -const static I2C_ARRAY vts_reg_hdr[] = { - {0x3032, 0x00}, //bit0-3-->MSB - {0x3031, 0x06}, - {0x3030, 0x72}, -}; - -const I2C_ARRAY expo_RHS1_reg[] = { - //decreasing exposure ratio version. - {0x306a, 0x00}, - {0x3069, 0x00}, - {0x3068, 0x1d}, -}; - -const static I2C_ARRAY gain_reg[] = { - {0x30e8, 0x2A},//low bit - {0x30e9, 0x00},//hcg mode,bit 4 -}; - -const static I2C_ARRAY gain_HDR_DOL_LEF_reg[] = { - {0x30e8, 0x2A}, - {0x30e9, 0x00}, -}; - -const static I2C_ARRAY gain_HDR_DOL_SEF_reg[] = { - {0x30ea, 0x20}, - {0x30eb, 0x00}, -}; - -const static I2C_ARRAY mirr_flip_table[] = -{ - {0x304e, 0x00},//M0F0 - {0x304f, 0x00}, - {0x304e, 0x01},//M1F0 - {0x304f, 0x00}, - {0x304e, 0x00},//M0F1 - {0x304f, 0x01}, - {0x304e, 0x01},//M1F1 - {0x304f, 0x01}, -}; - -//static int g_sensor_ae_min_gain = 1024; -static CUS_GAIN_GAP_ARRAY gain_gap_compensate[16] = { //compensate gain gap - {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} -}; - -///////////////////////////////////////////////////////////////// -// @@@@@@@ // -// @@ // -// @@ // -// @@@ // -// @ @@ // -// @@@@ // -// // -// Step 3 -- complete camera features // -// // -// camera set EV, MWB, orientation, contrast, sharpness // -// , saturation, and Denoise can work correctly. // -// // -///////////////////////////////////////////////////////////////// - -#if 0 -static CUS_INT_TASK_ORDER def_order = { - .RunLength = 9, - .Orders = { - CUS_INT_TASK_AE|CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_AWB|CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_AE|CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_AWB|CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_AE|CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_AWB|CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - }, -}; -#endif - -/////////////////// I2C function definition /////////////////// -#define SensorReg_Read(_reg,_data) (handle->i2c_bus->i2c_rx(handle->i2c_bus, &(handle->i2c_cfg),_reg,_data)) -#define SensorReg_Write(_reg,_data) (handle->i2c_bus->i2c_tx(handle->i2c_bus, &(handle->i2c_cfg),_reg,_data)) -#define SensorRegArrayW(_reg,_len) (handle->i2c_bus->i2c_array_tx(handle->i2c_bus, &(handle->i2c_cfg),(_reg),(_len))) -#define SensorRegArrayR(_reg,_len) (handle->i2c_bus->i2c_array_rx(handle->i2c_bus, &(handle->i2c_cfg),(_reg),(_len))) - -/////////////////// sensor hardware dependent /////////////////// -#if 0 -static int ISP_config_io(ms_cus_sensor *handle) { - ISensorIfAPI *sensor_if = handle->sensor_if_api; - - SENSOR_DMSG("[%s]", __FUNCTION__); - - sensor_if->HsyncPol(handle, handle->HSYNC_POLARITY); - sensor_if->VsyncPol(handle, handle->VSYNC_POLARITY); - sensor_if->ClkPol(handle, handle->PCLK_POLARITY); - sensor_if->BayerFmt(handle, handle->bayer_id); - sensor_if->DataBus(handle, handle->sif_bus); - - sensor_if->DataPrecision(handle, handle->data_prec); - sensor_if->FmtConv(handle, handle->data_mode); - return SUCCESS; -} -#endif - -static int cus_camsensor_release_handle(ms_cus_sensor *handle) -{ - return SUCCESS; -} - -/*******I5/I6 Support MCLK List******* - * CUS_CMU_CLK_27MHZ, - * CUS_CMU_CLK_21P6MHZ, - * CUS_CMU_CLK_12MHZ, - * CUS_CMU_CLK_5P4MHZ, - * CUS_CMU_CLK_36MHZ, - * CUS_CMU_CLK_54MHZ, - * CUS_CMU_CLK_43P2MHZ, - * CUS_CMU_CLK_61P7MHZ, - * CUS_CMU_CLK_72MHZ, - * CUS_CMU_CLK_48MHZ, - * CUS_CMU_CLK_24MHZ, - * CUS_CMU_CLK_37P125MHZ, - ******End of Support MCLK List*******/ - #if 0 -static CUS_MCLK_FREQ UseParaMclk(const char *mclk) -{ - if (strcmp(mclk, "27M") == 0) { - return CUS_CMU_CLK_27MHZ; - } else if (strcmp(mclk, "12M") == 0) { - return CUS_CMU_CLK_12MHZ; - } else if (strcmp(mclk, "36M") == 0) { - return CUS_CMU_CLK_36MHZ; - } else if (strcmp(mclk, "48M") == 0) { - return CUS_CMU_CLK_48MHZ; - } else if (strcmp(mclk, "54M") == 0) { - return CUS_CMU_CLK_54MHZ; - } else if (strcmp(mclk, "24M") == 0) { - return CUS_CMU_CLK_24MHZ; - } else if (strcmp(mclk, "37.125M") == 0) { - return CUS_CMU_CLK_37P125MHZ; - } - return Preview_MCLK_SPEED; -} -#endif - -static int pCus_poweron(ms_cus_sensor *handle, u32 idx) -{ - ISensorIfAPI *sensor_if = handle->sensor_if_api; - - //Sensor power on sequence - sensor_if->PowerOff(idx, handle->pwdn_POLARITY); // Powerdn Pull Low - sensor_if->Reset(idx, handle->reset_POLARITY); // Rst Pull Low - sensor_if->SetIOPad(idx, handle->sif_bus, handle->interface_attr.attr_mipi.mipi_lane_num); - sensor_if->SetCSI_Clk(idx, CUS_CSI_CLK_216M); - sensor_if->SetCSI_Lane(idx, handle->interface_attr.attr_mipi.mipi_lane_num, ENABLE); - sensor_if->SetCSI_LongPacketType(idx, 0, 0x1C00, 0); - - if (handle->interface_attr.attr_mipi.mipi_hdr_mode == CUS_HDR_MODE_SONY_DOL) { - sensor_if->SetCSI_hdr_mode(idx, handle->interface_attr.attr_mipi.mipi_hdr_mode, 1); - } - - sensor_if->PowerOff(idx, !handle->pwdn_POLARITY); - //Sensor board PWDN Enable, 1.8V & 2.9V need 30ms then Pull High - SENSOR_MSLEEP(31); - sensor_if->Reset(idx, !handle->reset_POLARITY); - SENSOR_MSLEEP(2); - sensor_if->MCLK(idx, 1, handle->mclk); - SENSOR_MSLEEP(2); - SENSOR_DMSG("Sensor Power On finished\n"); - return SUCCESS; -} - -static int pCus_poweroff(ms_cus_sensor *handle, u32 idx) -{ - // power/reset low - ISensorIfAPI *sensor_if = handle->sensor_if_api; - - SENSOR_DMSG("[%s] reset low\n", __FUNCTION__); - sensor_if->PowerOff(idx, handle->pwdn_POLARITY); // Powerdn Pull Low - sensor_if->Reset(idx, handle->reset_POLARITY); // Rst Pull Low - sensor_if->MCLK(idx, 0, handle->mclk); - - sensor_if->SetCSI_Clk(idx, CUS_CSI_CLK_DISABLE); - if (handle->interface_attr.attr_mipi.mipi_hdr_mode == CUS_HDR_MODE_SONY_DOL) { - sensor_if->SetCSI_hdr_mode(idx, handle->interface_attr.attr_mipi.mipi_hdr_mode, 0); - } - - handle->orient = SENSOR_ORIT; - - return SUCCESS; -} - -/////////////////// Check Sensor Product ID ///////////////////////// -/* static int pCus_CheckSensorProductID(ms_cus_sensor *handle) -{ - u16 sen_id_msb, sen_id_lsb; - - //Read Product ID - SensorReg_Read(0x3f12, (void*)&sen_id_lsb); - SensorReg_Read(0x3f13, (void*)&sen_id_msb);//CHIP_ID_r3F13 -#if 0 - if (sen_data != CHIP_ID) { - printk("[***ERROR***]Check Product ID Fail: 0x%x\n", sen_data); - return FAIL; - } -#endif - return SUCCESS; -} */ -//Get and check sensor ID -//if i2c error or sensor id does not match then return FAIL -static int pCus_GetSensorID(ms_cus_sensor *handle, u32 *id) -{ - int i,n; - int table_length= ARRAY_SIZE(Sensor_id_table); - I2C_ARRAY id_from_sensor[ARRAY_SIZE(Sensor_id_table)]; - - for(n=0;n8) - table_length=8; - - SENSOR_DMSG("\n\n[%s]", __FUNCTION__); - - for(n=0;n<4;++n) //retry , until I2C success - { - if(n>3) - return FAIL; - - if(SensorRegArrayR((I2C_ARRAY*)id_from_sensor,table_length) == SUCCESS) //read sensor ID from I2C - break; - else - SENSOR_MSLEEP(1); - } - - //convert sensor id to u32 format - for(i=0;iprivate_data; - int i,cnt=0; - //s16 sen_data; - -/* if (pCus_CheckSensorProductID(handle) == FAIL) { - return FAIL; - } */ - - for(i=0;i< ARRAY_SIZE(Sensor_init_table_4lane_linear);i++) - { - if(Sensor_init_table_4lane_linear[i].reg==0xffff) - { - SENSOR_MSLEEP(Sensor_init_table_4lane_linear[i].data); - } - else - { - cnt = 0; - while(SensorReg_Write(Sensor_init_table_4lane_linear[i].reg, Sensor_init_table_4lane_linear[i].data) != SUCCESS) - { - cnt++; - if(cnt>=10) - { - SENSOR_EMSG("[%s:%d]Sensor init fail!!\n", __FUNCTION__, __LINE__); - return FAIL; - } - //SENSOR_UDELAY(1); - } - //printk("\n reg 0x%x, 0x%x",Sensor_init_table_4lane_linear[i].reg, Sensor_init_table_4lane_linear[i].data); -#if 0 - SensorReg_Read(Sensor_init_table_4lane_linear[i].reg, &sen_data ); - if(Sensor_init_table_4lane_linear[i].data != sen_data) - printk("R/W Differ Reg: 0x%x\n",Sensor_init_table_4lane_linear[i].reg); - //printk("IMX347 reg: 0x%x, data: 0x%x, read: 0x%x.\n",Sensor_init_table_4lane_linear[i].reg, Sensor_init_table_4lane_linear[i].data, sen_data); -#endif - } - } - - return SUCCESS; -} - -static int pCus_init_mipi4lane_HDR_DOL(ms_cus_sensor *handle) -{ - //imx347_params *params = (imx347_params *)handle->private_data; - int i,cnt=0; - //s16 sen_data; - -/* if (pCus_CheckSensorProductID(handle)) { - return FAIL; - } */ - - for(i=0;i< ARRAY_SIZE(Sensor_init_table_4lane_HDR_DOL);i++) - { - if(Sensor_init_table_4lane_HDR_DOL[i].reg==0xffff) - { - SENSOR_MSLEEP(Sensor_init_table_4lane_HDR_DOL[i].data); - } - else - { - cnt = 0; - while(SensorReg_Write(Sensor_init_table_4lane_HDR_DOL[i].reg,Sensor_init_table_4lane_HDR_DOL[i].data) != SUCCESS) - { - cnt++; - if(cnt>=10) - { - SENSOR_EMSG("[%s:%d]Sensor init fail!!\n", __FUNCTION__, __LINE__); - return FAIL; - } - //SENSOR_UDELAY(1); - } - //printk("\n reg 0x%x, 0x%x",Sensor_init_table_4lane_HDR_DOL[i].reg, Sensor_init_table_4lane_HDR_DOL[i].data); -#if 0 - SensorReg_Read(Sensor_init_table_4lane_HDR_DOL[i].reg, &sen_data ); - if(Sensor_init_table_4lane_linear[i].data != sen_data) - printk("HDR R/W Differ Reg: 0x%x\n",Sensor_init_table_4lane_HDR_DOL[i].reg); - //printk("IMX347 reg: 0x%x, data: 0x%x, read: 0x%x.\n",Sensor_init_table_4lane_HDR_DOL[i].reg, Sensor_init_table_4lane_HDR_DOL[i].data, sen_data); -#endif - } - } - - SENSOR_DMSG("Sensor IMX347 HDR MODE Initial Finished\n"); - return SUCCESS; -} - -static int pCus_GetVideoResNum( ms_cus_sensor *handle, u32 *ulres_num) -{ - *ulres_num = handle->video_res_supported.num_res; - - return SUCCESS; -} - -static int pCus_GetVideoRes(ms_cus_sensor *handle, u32 res_idx, cus_camsensor_res **res) -{ - u32 num_res = handle->video_res_supported.num_res; - - if (res_idx >= num_res) { - SENSOR_EMSG("[%s] Please check the number of resolutions supported by the sensor!\n", __FUNCTION__); - return FAIL; - } - - *res = &handle->video_res_supported.res[res_idx]; - - return SUCCESS; -} - -static int pCus_GetCurVideoRes(ms_cus_sensor *handle, u32 *cur_idx, cus_camsensor_res **res) -{ - u32 num_res = handle->video_res_supported.num_res; - - *cur_idx = handle->video_res_supported.ulcur_res; - - if (*cur_idx >= num_res) { - SENSOR_EMSG("[%s] Please check the number of resolutions supported by the sensor!\n", __FUNCTION__); - return FAIL; - } - - *res = &handle->video_res_supported.res[*cur_idx]; - - return SUCCESS; -} - -static int pCus_SetVideoRes(ms_cus_sensor *handle, u32 res_idx) -{ - imx347_params *params = (imx347_params *)handle->private_data; - u32 num_res = handle->video_res_supported.num_res; - - if (res_idx >= num_res) { - SENSOR_EMSG("[%s] Please check the number of resolutions supported by the sensor!\n", __FUNCTION__); - return FAIL; - } - - handle->video_res_supported.ulcur_res = res_idx; - - switch (res_idx) { - case 0: - handle->video_res_supported.ulcur_res = 0; - handle->pCus_sensor_init = pCus_init_mipi4lane_linear; - vts_30fps = 2666; - params->expo.vts = vts_30fps; - params->expo.fps = 30; - Preview_line_period = 12503; - break; - case 1: - handle->video_res_supported.ulcur_res = 1; - handle->pCus_sensor_init = pCus_init_mipi4lane_linear; - vts_30fps = 2666; - params->expo.vts = vts_30fps; - params->expo.fps = 30; - Preview_line_period = 12503; - break; - case 2: - handle->video_res_supported.ulcur_res = 2; - handle->pCus_sensor_init = pCus_init_mipi4lane_linear; - vts_30fps = 2666; - params->expo.vts = vts_30fps; - params->expo.fps = 30; - Preview_line_period = 12503; - break; - default: - handle->video_res_supported.ulcur_res = 0; - handle->pCus_sensor_init = pCus_init_mipi4lane_linear; - vts_30fps = 2666; - params->expo.vts = vts_30fps; - params->expo.fps = 30; - Preview_line_period = 12503; - break; - } - return SUCCESS; -} - -static int pCus_SetVideoRes_HDR_DOL_LEF(ms_cus_sensor *handle, u32 res_idx) -{ - u32 num_res = handle->video_res_supported.num_res; - - if (res_idx >= num_res) { - SENSOR_EMSG("[%s] Please check the number of resolutions supported by the sensor!\n", __FUNCTION__); - return FAIL; - } - - handle->video_res_supported.ulcur_res = res_idx; - - switch (res_idx) { - case HDR_RES_1: - case HDR_RES_2: - case HDR_RES_3: - handle->data_prec = CUS_DATAPRECISION_12; - break; - default: - break; - } - return SUCCESS; -} - -static int pCus_SetVideoRes_HDR_DOL_SEF(ms_cus_sensor *handle, u32 res_idx) -{ - imx347_params *params = (imx347_params *)handle->private_data; - u32 num_res = handle->video_res_supported.num_res; - - if (res_idx >= num_res) { - SENSOR_EMSG("[%s] Please check the number of resolutions supported by the sensor!\n", __FUNCTION__); - return FAIL; - } - - handle->video_res_supported.ulcur_res = res_idx; - - switch (res_idx) { - case HDR_RES_1: - handle->pCus_sensor_init = pCus_init_mipi4lane_HDR_DOL; - vts_30fps_HDR_DOL_4lane = 1650; - params->expo.vts = vts_30fps_HDR_DOL_4lane; - params->expo.fps = 30; - Preview_line_period_HDR_DOL_4LANE = 20202; - handle->data_prec = CUS_DATAPRECISION_12; - params->min_rhs1 = 101; - break; - case HDR_RES_2: - handle->pCus_sensor_init = pCus_init_mipi4lane_HDR_DOL; - vts_30fps_HDR_DOL_4lane = 1650; - params->expo.vts = vts_30fps_HDR_DOL_4lane; - params->expo.fps = 30; - Preview_line_period_HDR_DOL_4LANE = 20202; - handle->data_prec = CUS_DATAPRECISION_12; - params->min_rhs1 = 101; - break; - case HDR_RES_3: - handle->pCus_sensor_init = pCus_init_mipi4lane_HDR_DOL; - vts_30fps_HDR_DOL_4lane = 1650; - params->expo.vts = vts_30fps_HDR_DOL_4lane; - params->expo.fps = 30; - Preview_line_period_HDR_DOL_4LANE = 20202; - handle->data_prec = CUS_DATAPRECISION_12; - params->min_rhs1 = 101; - break; - default: - handle->pCus_sensor_init = pCus_init_mipi4lane_HDR_DOL; - vts_30fps_HDR_DOL_4lane = 1650; - params->expo.vts = vts_30fps_HDR_DOL_4lane; - params->expo.fps = 30; - Preview_line_period_HDR_DOL_4LANE = 20202; - handle->data_prec = CUS_DATAPRECISION_12; - params->min_rhs1 = 101; - break; - } - - return SUCCESS; -} - -static int pCus_GetOrien(ms_cus_sensor *handle, CUS_CAMSENSOR_ORIT *orit) -{ - - *orit = handle->orient; - return SUCCESS; -} - -static int pCus_SetOrien(ms_cus_sensor *handle, CUS_CAMSENSOR_ORIT orit) -{ - imx347_params *params = (imx347_params *)handle->private_data; - - handle->orient = orit; - params->orien_dirty = true; - - return SUCCESS; -} - -static int DoOrien(ms_cus_sensor *handle, CUS_CAMSENSOR_ORIT orit) -{ - int table_length = ARRAY_SIZE(mirr_flip_table); - int seg_length=table_length/4; - int i,j; - - SENSOR_DMSG("\n\n[%s]", __FUNCTION__); - switch(orit) - { - case CUS_ORIT_M0F0: - for(i=0,j=0;iorient = CUS_ORIT_M0F0; - } - break; - case CUS_ORIT_M1F0: - for(i=seg_length,j=0;iorient = CUS_ORIT_M1F0; - } - break; - case CUS_ORIT_M0F1: - for(i=seg_length*2,j=0;iorient = CUS_ORIT_M0F1; - } - break; - case CUS_ORIT_M1F1: - for(i=seg_length*3,j=0;iorient = CUS_ORIT_M1F1; - } - break; - default : - for(i=0,j=0;iorient = CUS_ORIT_M0F0; - } - break; - } - - return SUCCESS; -} - -static int pCus_GetFPS(ms_cus_sensor *handle) -{ - imx347_params *params = (imx347_params *)handle->private_data; - u32 max_fps = handle->video_res_supported.res[handle->video_res_supported.ulcur_res].max_fps; - u32 tVts = (params->tVts_reg[0].data << 16) | (params->tVts_reg[1].data << 8) | (params->tVts_reg[2].data << 0); - - if (params->expo.fps >= 1000) - params->expo.preview_fps = (vts_30fps*max_fps*1000)/tVts; - else - params->expo.preview_fps = (vts_30fps*max_fps)/tVts; - - return params->expo.preview_fps; -} - -static int pCus_SetFPS(ms_cus_sensor *handle, u32 fps) -{ - //u32 vts = 0, cur_vts_30fps = 0; - imx347_params *params = (imx347_params *)handle->private_data; - u32 max_fps = handle->video_res_supported.res[handle->video_res_supported.ulcur_res].max_fps; - u32 min_fps = handle->video_res_supported.res[handle->video_res_supported.ulcur_res].min_fps; - - if(fps>=min_fps && fps <= max_fps) - { - params->expo.vts= (vts_30fps*(max_fps*1000) + fps * 500)/(fps * 1000); - }else if(fps>=(min_fps*1000) && fps <= (max_fps*1000)) - { - params->expo.vts= (vts_30fps*(max_fps*1000) + (fps>>1))/fps; - }else - { - SENSOR_DMSG("[%s] FPS %d out of range.\n",__FUNCTION__,fps); - return FAIL; - } - - //pr_info("[%s] leslie_vts : %u\n\n", __FUNCTION__,params->expo.vts); - if(params->expo.expo_lines > params->expo.vts - 4){ - //vts = params->expo.expo_lines + 4; -#if 0 //Update FPS Status - if(fps>=3 && fps <= 30) - fps = (vts_30fps*30000)/(params->expo.vts * 1000 - 500); - else if(fps>=3000 && fps <= 30000) - fps = (vts_30fps*30000)/(params->expo.vts - (500 / 1000)); -#endif - }else{ - //vts = params->expo.vts; - } - - params->expo.fps = fps; - params->dirty = true; - - pCus_SetAEUSecs(handle, params->expo.expo_lef_us); - return SUCCESS; -} - -static int pCus_GetFPS_HDR_DOL_SEF(ms_cus_sensor *handle) -{ - imx347_params *params = (imx347_params *)handle->private_data; - u32 cur_vts_30fps = vts_30fps_HDR_DOL_4lane; - u32 max_fps = handle->video_res_supported.res[handle->video_res_supported.ulcur_res].max_fps; - u32 tVts = (params->tVts_reg[0].data << 16) | (params->tVts_reg[1].data << 8) | (params->tVts_reg[2].data << 0); - - if (params->expo.fps >= 1000) - params->expo.preview_fps = (cur_vts_30fps*max_fps*1000)/tVts; - else - params->expo.preview_fps = (cur_vts_30fps*max_fps)/tVts; - - return params->expo.preview_fps; -} - -static int pCus_SetFPS_HDR_DOL_SEF(ms_cus_sensor *handle, u32 fps) -{ - u32 cur_vts_30fps = 0; - imx347_params *params = (imx347_params *)handle->private_data; - u32 max_fps = handle->video_res_supported.res[handle->video_res_supported.ulcur_res].max_fps; - u32 min_fps = handle->video_res_supported.res[handle->video_res_supported.ulcur_res].min_fps; - - cur_vts_30fps=vts_30fps_HDR_DOL_4lane; - if(fps>=min_fps && fps <= max_fps) - { - params->expo.vts= (cur_vts_30fps*(max_fps*1000) + fps * 500 )/ (fps * 1000); - }else if(fps>=(min_fps*1000) && fps <= (max_fps*1000)) - { - params->expo.vts= (cur_vts_30fps*(max_fps*1000) + (fps >> 1))/fps; - }else - { - SENSOR_DMSG("[%s] FPS %d out of range.\n",__FUNCTION__,fps); - return FAIL; - } - - if(params->expo.expo_lines > params->expo.vts - 4){ - //vts = params->expo.expo_lines + 4; -#if 0 //Update FPS Status - if(fps>=3 && fps <= 30) - fps = (vts_30fps*30000)/(params->expo.vts * 1000 - 500); - else if(fps>=3000 && fps <= 30000) - fps = (vts_30fps*30000)/(params->expo.vts - (500 / 1000)); -#endif - }else{ - //vts = params->expo.vts; - } - - params->expo.fps = fps; - //params->expo.vts = vts; - params->dirty = true; - - pCus_SetAEUSecsHDR_DOL_SEF(handle, params->expo.expo_sef_us); - return SUCCESS; -} - -/////////////////////////////////////////////////////////////////////// -// auto exposure -/////////////////////////////////////////////////////////////////////// -// unit: micro seconds -//AE status notification -static int pCus_AEStatusNotify(ms_cus_sensor *handle, CUS_CAMSENSOR_AE_STATUS_NOTIFY status) -{ - imx347_params *params = (imx347_params *)handle->private_data; - - switch(status) - { - case CUS_FRAME_INACTIVE: - break; - case CUS_FRAME_ACTIVE: - if(params->dirty || params->orien_dirty) { - SensorReg_Write(0x3001,1); // Global hold on - if(params->dirty) { - SensorRegArrayW((I2C_ARRAY*)params->tExpo_reg, ARRAY_SIZE(expo_reg)); - SensorRegArrayW((I2C_ARRAY*)params->tGain_reg, ARRAY_SIZE(gain_reg)); - SensorRegArrayW((I2C_ARRAY*)params->tVts_reg, ARRAY_SIZE(vts_reg)); - params->dirty = false; - } - - if(params->orien_dirty) { - DoOrien(handle, handle->orient); - params->orien_dirty = false; - } - SensorReg_Write(0x3001,0); // Global hold off - } - break; - default : - break; - } - return SUCCESS; -} - -static int pCus_AEStatusNotifyHDR_DOL_SEF(ms_cus_sensor *handle, CUS_CAMSENSOR_AE_STATUS_NOTIFY status) -{ - //imx347_params *params = (imx347_params *)handle->private_data; - - switch(status) - { - case CUS_FRAME_INACTIVE: - break; - case CUS_FRAME_ACTIVE: -#if 0 - if(params->dirty || params->orien_dirty) { - SensorReg_Write(0x3001,1); - - if(params->dirty) { - //SensorRegArrayW((I2C_ARRAY*)params->tExpo_reg, ARRAY_SIZE(expo_reg)); - //SensorRegArrayW((I2C_ARRAY*)params->tGain_reg, ARRAY_SIZE(gain_reg)); - //SensorRegArrayW((I2C_ARRAY*)params->tVts_reg, ARRAY_SIZE(vts_reg)); - params->dirty = false; - } - if(params->orien_dirty) { - DoOrien(handle, handle->orient); - params->orien_dirty = false; - } - SensorReg_Write(0x3001,0); - } -#endif - break; - default : - break; - } - return SUCCESS; -} - -static int pCus_GetAEUSecs(ms_cus_sensor *handle, u32 *us) -{ - u32 lines = 0; - imx347_params *params = (imx347_params *)handle->private_data; - - lines |= (u32)(params->tExpo_reg[0].data & 0x03) << 16; - lines |= (u32)(params->tExpo_reg[1].data & 0xff) << 8; - lines |= (u32)(params->tExpo_reg[2].data & 0xff) << 0; - - *us = (lines * Preview_line_period) / 1000; - - SENSOR_DMSG("[%s] sensor expo lines/us %u,%u us\n", __FUNCTION__, lines, *us); - - return SUCCESS; -} - -static int pCus_SetAEUSecs(ms_cus_sensor *handle, u32 us) -{ - u32 expo_lines = 0, vts = 0, SHR0 = 0; - imx347_params *params = (imx347_params *)handle->private_data; - - params->expo.expo_lef_us = us; - expo_lines = (1000*us)/Preview_line_period; - - if (expo_lines > params->expo.vts) { - vts = expo_lines + 8; - } - else - vts = params->expo.vts; - SHR0 = vts - expo_lines; - - if (SHR0 <= 12 ) // 8+4 - SHR0 = 8; - else - SHR0 -= 4; - - params->expo.expo_lines = expo_lines; - //params->expo.vts = vts; - - SENSOR_DMSG("[%s] us %u, SHR0 %u, vts %u\n", __FUNCTION__, - us, \ - SHR0, \ - vts - ); - //pr_info("[%s] leslie_shutter,expo_lines,params_expo_lines : %d,%d,%d\n\n", __FUNCTION__,us,expo_lines,params->expo.expo_lines); - //pr_info("[%s] leslie_shutter_vts : %u,%u\n\n", __FUNCTION__,params->expo.vts,vts); - params->tExpo_reg[0].data = (SHR0>>16) & 0x0003; - params->tExpo_reg[1].data = (SHR0>>8) & 0x00ff; - params->tExpo_reg[2].data = (SHR0>>0) & 0x00ff; - - params->tVts_reg[0].data = (vts >> 16) & 0x0003; - params->tVts_reg[1].data = (vts >> 8) & 0x00ff; - params->tVts_reg[2].data = (vts >> 0) & 0x00ff; - - params->dirty = true; - return SUCCESS; -} - -static int pCus_SetAEUSecsHDR_DOL_SEF(ms_cus_sensor *handle, u32 us) -{ - u32 expo_line_sef = 0; - u32 cur_line_period = Preview_line_period_HDR_DOL_4LANE; - imx347_params *params = (imx347_params *)handle->private_data; - - cur_line_period = Preview_line_period_HDR_DOL_4LANE; - expo_line_sef = (1000 * us + (cur_line_period >> 1)) / cur_line_period; - params->expo.expo_sef_us = us; - //params->min_rhs1 = 437; // 4n+1 fix to 269, 337 //5ms: 429 - - params->min_shr1 = params->min_rhs1 - expo_line_sef; - if((expo_line_sef > params->min_rhs1) || ((params->min_shr1) < 9)) - params->min_shr1 = 9; - params->min_shr1 = ((params->min_shr1 >> 1) << 1) + 1; - - SENSOR_DMSG("[%s] us %u, expo_line_sef %u rhs %u shr1 %u\n", __FUNCTION__, - us, \ - expo_line_sef, \ - params->min_rhs1, \ - params->min_shr1 - ); - - params->tRHS1_reg[0].data = (params->min_rhs1 >>16) & 0x03; - params->tRHS1_reg[1].data = (params->min_rhs1 >>8) & 0xff; - params->tRHS1_reg[2].data = (params->min_rhs1 >>0) & 0xff; - - params->tSHR1_reg[0].data = (params->min_shr1 >> 16) & 0x0003; - params->tSHR1_reg[1].data = (params->min_shr1 >> 8) & 0x00ff; - params->tSHR1_reg[2].data = (params->min_shr1 >> 0) & 0x00ff; - - params->dirty = true; - return SUCCESS; -} - -// Gain: 1x = 1024 -static int pCus_GetAEGain(ms_cus_sensor *handle, u32* gain) -{ - imx347_params *params = (imx347_params *)handle->private_data; -#if 0 - u16 temp_gain; - - temp_gain=gain_reg[0].data; - *gain=(u32)(10^((temp_gain*3)/200))*1024; - if (gain_reg[1].data & 0x10) - *gain = (*gain) * 2; -#endif - *gain = params->expo.final_gain; - SENSOR_DMSG("[%s] get gain %u\n", __FUNCTION__, *gain); - - return SUCCESS; -} - -static int pCus_SetAEGain(ms_cus_sensor *handle, u32 gain) -{ - imx347_params *params = (imx347_params *)handle->private_data; - u32 i; - CUS_GAIN_GAP_ARRAY* Sensor_Gain_Linearity; - u64 gain_double; - - params->expo.final_gain = gain; - if(gain < SENSOR_MIN_GAIN) - gain = SENSOR_MIN_GAIN; - else if(gain >= SENSOR_MAX_GAIN) - gain = SENSOR_MAX_GAIN; - - Sensor_Gain_Linearity = gain_gap_compensate; - - for(i = 0; i < sizeof(gain_gap_compensate)/sizeof(CUS_GAIN_GAP_ARRAY); i++){ - if (Sensor_Gain_Linearity[i].gain == 0) - break; - if((gain>Sensor_Gain_Linearity[i].gain) && (gain < (Sensor_Gain_Linearity[i].gain + Sensor_Gain_Linearity[i].offset))){ - gain=Sensor_Gain_Linearity[i].gain; - break; - } - } - gain_double = 20 * (intlog10(gain) - intlog10(1024)); - gain_double = (u16)((gain_double * 10) >> 24) / 3; - - params->tGain_reg[0].data = gain_double & 0xff; - params->tGain_reg[1].data = (gain_double >> 8) & 0xff; - -#if DEBUG_INFO - SENSOR_DMSG("[%s]gain %u gain_double %llu\n",__FUNCTION__, gain, gain_double); -#endif - - SENSOR_DMSG("[%s] set gain/reg=%u/0x%x 0x%x\n", __FUNCTION__, gain,params->tGain_reg[0].data, gain,params->tGain_reg[1].dat); - params->dirty = true; - return SUCCESS; -} - -static void pCus_SetAEGainHDR_DOL_Calculate(u32 gain, u16 *gain_reg) -{ - //double gain_double; - u64 gain_double; - - if(gain < SENSOR_MIN_GAIN){ - gain = SENSOR_MIN_GAIN; - } - else if(gain >= SENSOR_MAX_GAIN){ - gain = SENSOR_MAX_GAIN; - } - gain_double = 20 * (intlog10(gain) - intlog10(1024)); - *gain_reg =(u16)((gain_double * 10) >> 24) / 3; -} - -static int pCus_SetAEGainHDR_DOL_SEF1(ms_cus_sensor *handle, u32 gain) -{ - imx347_params *params = (imx347_params *)handle->private_data; - u16 gain_reg = 0; - - pCus_SetAEGainHDR_DOL_Calculate(gain, &gain_reg); - params->tGain_hdr_dol_sef_reg[0].data = gain_reg & 0xff; - params->tGain_hdr_dol_sef_reg[1].data = (gain_reg >> 8) & 0xff; - - SENSOR_DMSG("[%s] set gain/reg=%u/0x%x 0x%x\n", __FUNCTION__, gain, params->tGain_hdr_dol_sef_reg[0].data, params->tGain_hdr_dol_sef_reg[1].data); - - params->dirty = true; - return SUCCESS; -} - -static int pCus_GetAEMinMaxUSecs(ms_cus_sensor *handle, u32 *min, u32 *max) -{ - *min = 1; - *max = 1000000/imx347_mipi_linear[0].senout.min_fps; - return SUCCESS; -} - -static int pCus_GetAEMinMaxGain(ms_cus_sensor *handle, u32 *min, u32 *max) -{ - *min = SENSOR_MIN_GAIN;//handle->sat_mingain; - *max = SENSOR_MAX_GAIN;//10^(72db/20)*1024; - return SUCCESS; -} - -static int IMX347_GetShutterInfo(struct __ms_cus_sensor* handle,CUS_SHUTTER_INFO *info) -{ - info->max = 1000000000/imx347_mipi_linear[0].senout.min_fps;// - info->min = (Preview_line_period * 1); - info->step = Preview_line_period; - return SUCCESS; -} - -static int IMX347_GetShutterInfo_HDR_DOL_SEF(struct __ms_cus_sensor* handle,CUS_SHUTTER_INFO *info) -{ - imx347_params *params = (imx347_params *)handle->private_data; - info->max = Preview_line_period_HDR_DOL_4LANE * params->min_rhs1; - info->min = (Preview_line_period_HDR_DOL_4LANE * 2); - info->step = Preview_line_period_HDR_DOL_4LANE; - return SUCCESS; -} - -int cus_camsensor_init_handle_linear(ms_cus_sensor* drv_handle) -{ - ms_cus_sensor *handle = drv_handle; - imx347_params *params; - int res; - - if (!handle) { - SENSOR_DMSG("[%s] not enough memory!\n", __FUNCTION__); - return FAIL; - } - SENSOR_DMSG("[%s]", __FUNCTION__); - //////////////////////////////////// - // private data allocation & init // - //////////////////////////////////// - if (handle->private_data == NULL) { - SENSOR_EMSG("[%s] Private data is empty!\n", __FUNCTION__); - return FAIL; - } - - params = (imx347_params *)handle->private_data; - memcpy(params->tVts_reg, vts_reg, sizeof(vts_reg)); - memcpy(params->tGain_reg, gain_reg, sizeof(gain_reg)); - memcpy(params->tExpo_reg, expo_reg, sizeof(expo_reg)); - - //////////////////////////////////// - // sensor model ID // - //////////////////////////////////// - sprintf(handle->model_id,"IMX347_MIPI"); - - //////////////////////////////////// - // i2c config // - //////////////////////////////////// - handle->i2c_cfg.mode = SENSOR_I2C_LEGACY; //(CUS_ISP_I2C_MODE) FALSE; - handle->i2c_cfg.fmt = SENSOR_I2C_FMT; //CUS_I2C_FMT_A16D8; - handle->i2c_cfg.address = SENSOR_I2C_ADDR; //0x34; - handle->i2c_cfg.speed = SENSOR_I2C_SPEED; //300000; - - //////////////////////////////////// - // mclk // - //////////////////////////////////// - handle->mclk =Preview_MCLK_SPEED; - - //////////////////////////////////// - // sensor interface info // - //////////////////////////////////// - handle->isp_type = SENSOR_ISP_TYPE; - //handle->data_fmt = SENSOR_DATAFMT; - handle->sif_bus = SENSOR_IFBUS_TYPE; - handle->data_prec = SENSOR_DATAPREC; - handle->data_mode = SENSOR_DATAMODE; - handle->bayer_id = SENSOR_BAYERID; - handle->RGBIR_id = SENSOR_RGBIRID; - handle->orient = SENSOR_ORIT; - //handle->YC_ODER = SENSOR_YCORDER; //CUS_SEN_YCODR_CY; - handle->interface_attr.attr_mipi.mipi_lane_num = SENSOR_MIPI_LANE_NUM; - handle->interface_attr.attr_mipi.mipi_data_format = CUS_SEN_INPUT_FORMAT_RGB; // RGB pattern. - handle->interface_attr.attr_mipi.mipi_yuv_order = 0; //don't care in RGB pattern. - handle->interface_attr.attr_mipi.mipi_hsync_mode = SENSOR_MIPI_HSYNC_MODE; - handle->interface_attr.attr_mipi.mipi_hdr_mode = CUS_HDR_MODE_NONE; - handle->interface_attr.attr_mipi.mipi_hdr_virtual_channel_num = 0; //Short frame - - //////////////////////////////////// - // resolution capability // - //////////////////////////////////// - handle->video_res_supported.ulcur_res = 0; //default resolution index is 0. - //handle->video_res_supported.num_res = LINEAR_RES_END; - for (res = 0; res < LINEAR_RES_END; res++) { - handle->video_res_supported.num_res = res+1; - handle->video_res_supported.res[res].width = imx347_mipi_linear[res].senif.preview_w; - handle->video_res_supported.res[res].height = imx347_mipi_linear[res].senif.preview_h; - handle->video_res_supported.res[res].max_fps = imx347_mipi_linear[res].senout.max_fps; - handle->video_res_supported.res[res].min_fps = imx347_mipi_linear[res].senout.min_fps; - handle->video_res_supported.res[res].crop_start_x = imx347_mipi_linear[res].senif.crop_start_X; - handle->video_res_supported.res[res].crop_start_y = imx347_mipi_linear[res].senif.crop_start_y; - handle->video_res_supported.res[res].nOutputWidth = imx347_mipi_linear[res].senout.width; - handle->video_res_supported.res[res].nOutputHeight = imx347_mipi_linear[res].senout.height; - sprintf(handle->video_res_supported.res[res].strResDesc, imx347_mipi_linear[res].senstr.strResDesc); - } - - //////////////////////////////////// - // Sensor polarity // - //////////////////////////////////// - handle->pwdn_POLARITY = SENSOR_PWDN_POL; //CUS_CLK_POL_NEG; - handle->reset_POLARITY = SENSOR_RST_POL; //CUS_CLK_POL_NEG; - //handle->VSYNC_POLARITY = SENSOR_VSYNC_POL; //CUS_CLK_POL_POS; - //handle->HSYNC_POLARITY = SENSOR_HSYNC_POL; //CUS_CLK_POL_POS; - //handle->PCLK_POLARITY = SENSOR_PCLK_POL; //CUS_CLK_POL_POS); // use '!' to clear board latch error - - //////////////////////////////////////// - // Sensor Status Control and Get Info // - //////////////////////////////////////// - handle->pCus_sensor_release = cus_camsensor_release_handle; - handle->pCus_sensor_init = pCus_init_mipi4lane_linear; - //handle->pCus_sensor_powerupseq = pCus_powerupseq; - handle->pCus_sensor_poweron = pCus_poweron; - handle->pCus_sensor_poweroff = pCus_poweroff; - handle->pCus_sensor_GetSensorID = pCus_GetSensorID; - handle->pCus_sensor_GetVideoResNum = pCus_GetVideoResNum; - handle->pCus_sensor_GetVideoRes = pCus_GetVideoRes; - handle->pCus_sensor_GetCurVideoRes = pCus_GetCurVideoRes; - handle->pCus_sensor_SetVideoRes = pCus_SetVideoRes; - - handle->pCus_sensor_GetOrien = pCus_GetOrien; - handle->pCus_sensor_SetOrien = pCus_SetOrien; - handle->pCus_sensor_GetFPS = pCus_GetFPS; - handle->pCus_sensor_SetFPS = pCus_SetFPS; - //handle->pCus_sensor_GetSensorCap = pCus_GetSensorCap; - handle->pCus_sensor_SetPatternMode = imx347_SetPatternMode; //NONE - - //////////////////////////////////// - // AE parameters // - //////////////////////////////////// - handle->ae_gain_delay = SENSOR_GAIN_DELAY_FRAME_COUNT; - handle->ae_shutter_delay = SENSOR_SHUTTER_DELAY_FRAME_COUNT; - handle->ae_gain_ctrl_num = 1; - handle->ae_shutter_ctrl_num = 1; - handle->sat_mingain = SENSOR_MIN_GAIN;//g_sensor_ae_min_gain; - //handle->dgain_remainder = 0; - - //////////////////////////////////// - // AE Control and Get Info // - //////////////////////////////////// - // unit: micro seconds - //handle->pCus_sensor_GetAETrigger_mode = pCus_GetAETrigger_mode; - //handle->pCus_sensor_SetAETrigger_mode = pCus_SetAETrigger_mode; - handle->pCus_sensor_AEStatusNotify = pCus_AEStatusNotify; - handle->pCus_sensor_GetAEUSecs = pCus_GetAEUSecs; - handle->pCus_sensor_SetAEUSecs = pCus_SetAEUSecs; - handle->pCus_sensor_GetAEGain = pCus_GetAEGain; - handle->pCus_sensor_SetAEGain = pCus_SetAEGain; - - handle->pCus_sensor_GetAEMinMaxGain = pCus_GetAEMinMaxGain; - handle->pCus_sensor_GetAEMinMaxUSecs= pCus_GetAEMinMaxUSecs; - //handle->pCus_sensor_GetDGainRemainder = pCus_GetDGainRemainder; - - //sensor calibration - //handle->pCus_sensor_SetAEGain_cal = pCus_SetAEGain_cal; - //handle->pCus_sensor_setCaliData_gain_linearity=pCus_setCaliData_gain_linearity; - handle->pCus_sensor_GetShutterInfo = IMX347_GetShutterInfo; - - params->expo.vts = vts_30fps; - - return SUCCESS; -} - -int cus_camsensor_init_handle_hdr_dol_sef(ms_cus_sensor* drv_handle) -{ - ms_cus_sensor *handle = drv_handle; - imx347_params *params = NULL; - int res; - - if (!handle) { - SENSOR_DMSG("[%s] not enough memory!\n", __FUNCTION__); - return FAIL; - } - SENSOR_DMSG("[%s]", __FUNCTION__); - //////////////////////////////////// - // private data allocation & init // - //////////////////////////////////// - if (handle->private_data == NULL) { - SENSOR_EMSG("[%s] Private data is empty!\n", __FUNCTION__); - return FAIL; - } - - params = (imx347_params *)handle->private_data; - memcpy(params->tVts_reg, vts_reg_hdr, sizeof(vts_reg_hdr)); - memcpy(params->tRHS1_reg, expo_RHS1_reg, sizeof(expo_RHS1_reg)); - memcpy(params->tSHR1_reg, expo_SHR1_reg, sizeof(expo_SHR1_reg)); - memcpy(params->tGain_hdr_dol_sef_reg, gain_HDR_DOL_SEF_reg, sizeof(gain_HDR_DOL_SEF_reg)); - - //////////////////////////////////// - // sensor model ID // - //////////////////////////////////// - sprintf(handle->model_id,"IMX347_MIPI_HDR_SEF"); - - //////////////////////////////////// - // i2c config // - //////////////////////////////////// - handle->i2c_cfg.mode = SENSOR_I2C_LEGACY; //(CUS_ISP_I2C_MODE) FALSE; - handle->i2c_cfg.fmt = SENSOR_I2C_FMT; //CUS_I2C_FMT_A16D16; - handle->i2c_cfg.address = SENSOR_I2C_ADDR; //0x5a; - handle->i2c_cfg.speed = SENSOR_I2C_SPEED; //320000; - - //////////////////////////////////// - // mclk // - //////////////////////////////////// - handle->mclk = Preview_MCLK_SPEED_HDR_DOL; - - //////////////////////////////////// - // sensor interface info // - //////////////////////////////////// - //handle->isp_type = SENSOR_ISP_TYPE; - //handle->data_fmt = SENSOR_DATAFMT; - handle->sif_bus = SENSOR_IFBUS_TYPE; - handle->data_prec = SENSOR_DATAPREC_DOL; - handle->data_mode = SENSOR_DATAMODE; - handle->bayer_id = SENSOR_BAYERID_HDR_DOL; - handle->RGBIR_id = SENSOR_RGBIRID; - - handle->interface_attr.attr_mipi.mipi_lane_num = 4; // hdr_lane_num; - handle->interface_attr.attr_mipi.mipi_data_format = CUS_SEN_INPUT_FORMAT_RGB; - handle->interface_attr.attr_mipi.mipi_hsync_mode = SENSOR_MIPI_HSYNC_MODE_HDR_DOL; - handle->interface_attr.attr_mipi.mipi_hdr_mode = CUS_HDR_MODE_DCG; // SONY IMX347 as VC mode - handle->interface_attr.attr_mipi.mipi_hdr_virtual_channel_num = 1; //Short frame - - //////////////////////////////////// - // resolution capability // - //////////////////////////////////// - handle->video_res_supported.ulcur_res = 0; //default resolution index is 0. - //handle->video_res_supported.num_res = HDR_RES_END; - for (res = 0; res < HDR_RES_END; res++) { - handle->video_res_supported.num_res = res+1; - handle->video_res_supported.res[res].width = imx347_mipi_hdr[res].senif.preview_w; - handle->video_res_supported.res[res].height = imx347_mipi_hdr[res].senif.preview_h; - handle->video_res_supported.res[res].max_fps = imx347_mipi_hdr[res].senout.max_fps; - handle->video_res_supported.res[res].min_fps = imx347_mipi_hdr[res].senout.min_fps; - handle->video_res_supported.res[res].crop_start_x = imx347_mipi_hdr[res].senif.crop_start_X; - handle->video_res_supported.res[res].crop_start_y = imx347_mipi_hdr[res].senif.crop_start_y; - handle->video_res_supported.res[res].nOutputWidth = imx347_mipi_hdr[res].senout.width; - handle->video_res_supported.res[res].nOutputHeight = imx347_mipi_hdr[res].senout.height; - sprintf(handle->video_res_supported.res[res].strResDesc, imx347_mipi_hdr[res].senstr.strResDesc); - } - - //////////////////////////////////// - // Sensor polarity // - //////////////////////////////////// - handle->pwdn_POLARITY = SENSOR_PWDN_POL; //CUS_CLK_POL_NEG; - handle->reset_POLARITY = SENSOR_RST_POL; //CUS_CLK_POL_NEG; - //handle->VSYNC_POLARITY = SENSOR_VSYNC_POL; //CUS_CLK_POL_POS; - //handle->HSYNC_POLARITY = SENSOR_HSYNC_POL; //CUS_CLK_POL_POS; - handle->PCLK_POLARITY = SENSOR_PCLK_POL; //CUS_CLK_POL_POS); // use '!' to clear board latch error - - //////////////////////////////////////// - // Sensor Status Control and Get Info // - //////////////////////////////////////// - handle->pCus_sensor_release = cus_camsensor_release_handle; - handle->pCus_sensor_init = pCus_init_mipi4lane_HDR_DOL; - handle->pCus_sensor_poweron = pCus_poweron; // Need to check - handle->pCus_sensor_poweroff = pCus_poweroff; // Need to check - handle->pCus_sensor_GetSensorID = pCus_GetSensorID; // Need to check - handle->pCus_sensor_GetVideoResNum = pCus_GetVideoResNum; - handle->pCus_sensor_SetVideoRes = pCus_SetVideoRes_HDR_DOL_SEF; // Need to check - handle->pCus_sensor_GetVideoRes = pCus_GetVideoRes; - handle->pCus_sensor_GetCurVideoRes = pCus_GetCurVideoRes; - - handle->pCus_sensor_GetOrien = pCus_GetOrien; // Need to check - handle->pCus_sensor_SetOrien = pCus_SetOrien; // Need to check - handle->pCus_sensor_GetFPS = pCus_GetFPS_HDR_DOL_SEF; // Need to check - handle->pCus_sensor_SetFPS = pCus_SetFPS_HDR_DOL_SEF; // Need to check - - //////////////////////////////////// - // AE parameters // - //////////////////////////////////// - handle->ae_gain_delay = SENSOR_GAIN_DELAY_FRAME_COUNT; - handle->ae_shutter_delay = SENSOR_SHUTTER_DELAY_FRAME_COUNT_HDR_DOL; - handle->ae_gain_ctrl_num = 2; - handle->ae_shutter_ctrl_num = 2; - handle->sat_mingain = SENSOR_MIN_GAIN; //g_sensor_ae_min_gain; - //handle->dgain_remainder = 0; - - //////////////////////////////////// - // AE Control and Get Info // - //////////////////////////////////// - handle->pCus_sensor_AEStatusNotify = pCus_AEStatusNotifyHDR_DOL_SEF; // Need to check - handle->pCus_sensor_GetAEUSecs = pCus_GetAEUSecs; - handle->pCus_sensor_SetAEUSecs = pCus_SetAEUSecsHDR_DOL_SEF; // Need to check - handle->pCus_sensor_GetAEGain = pCus_GetAEGain; - handle->pCus_sensor_SetAEGain = pCus_SetAEGainHDR_DOL_SEF1; // Need to check - handle->pCus_sensor_GetAEMinMaxGain = pCus_GetAEMinMaxGain; - handle->pCus_sensor_GetAEMinMaxUSecs= pCus_GetAEMinMaxUSecs; - //handle->pCus_sensor_GetDGainRemainder = pCus_GetDGainRemainder; - - handle->pCus_sensor_GetShutterInfo = IMX347_GetShutterInfo_HDR_DOL_SEF; - params->expo.vts = vts_30fps_HDR_DOL_4lane; - - return SUCCESS; -} - -//lef functions -static int pCus_init_HDR_DOL_LEF(ms_cus_sensor *handle) -{ - return SUCCESS; -} - -static int pCus_poweron_HDR_DOL_LEF(ms_cus_sensor *handle, u32 idx) -{ - return SUCCESS; -} - -static int pCus_poweroff_HDR_DOL_LEF(ms_cus_sensor *handle, u32 idx) -{ - return SUCCESS; -} - -static int pCus_GetSensorID_HDR_DOL_LEF(ms_cus_sensor *handle, u32 *id) -{ - return SUCCESS; -} - -static int pCus_GetOrien_HDR_DOL_LEF(ms_cus_sensor *handle, CUS_CAMSENSOR_ORIT *orit) -{ - return SUCCESS; -} - -static int pCus_SetOrien_HDR_DOL_LEF(ms_cus_sensor *handle, CUS_CAMSENSOR_ORIT orit) -{ - imx347_params *params = (imx347_params *)handle->private_data; - - handle->orient = orit; - params->orien_dirty = true; - - return SUCCESS; -} - -static int pCus_GetFPS_HDR_DOL_LEF(ms_cus_sensor *handle) -{ - imx347_params *params = (imx347_params *)handle->private_data; - u32 cur_vts_30fps = vts_30fps_HDR_DOL_4lane; - u32 max_fps = handle->video_res_supported.res[handle->video_res_supported.ulcur_res].max_fps; - u32 tVts = (params->tVts_reg[0].data << 16) | (params->tVts_reg[1].data << 8) | (params->tVts_reg[2].data << 0); - - if (params->expo.fps >= 1000) - params->expo.preview_fps = (cur_vts_30fps*max_fps*1000)/tVts; - else - params->expo.preview_fps = (cur_vts_30fps*max_fps)/tVts; - - return params->expo.preview_fps; -} - -static int pCus_SetFPS_HDR_DOL_LEF(ms_cus_sensor *handle, u32 fps) -{ - u32 cur_vts_30fps = 0;//vts = 0, - imx347_params *params = (imx347_params *)handle->private_data; - u32 max_fps = handle->video_res_supported.res[handle->video_res_supported.ulcur_res].max_fps; - u32 min_fps = handle->video_res_supported.res[handle->video_res_supported.ulcur_res].min_fps; - // cur_vts_30fps = imx347_mipi_hdr[0].senout.height; - cur_vts_30fps=vts_30fps_HDR_DOL_4lane; - if(fps>=min_fps && fps <= max_fps) - { - params->expo.vts= (cur_vts_30fps*(max_fps*1000) + fps * 500 )/ (fps * 1000); - }else if(fps>=(min_fps*1000) && fps <= (max_fps*1000)) - { - params->expo.vts= (cur_vts_30fps*(max_fps*1000) + (fps >> 1))/fps; - }else { - SENSOR_DMSG("[%s] FPS %d out of range.\n",__FUNCTION__,fps); - return FAIL; - } - - if(params->expo.expo_lines > params->expo.vts - 4) { - //vts = params->expo.expo_lines + 4; - }else { - //vts = params->expo.vts; - } - - params->dirty = true; - params->expo.fps = fps; - pCus_SetAEUSecsHDR_DOL_LEF(handle, params->expo.expo_sef_us); - return SUCCESS; -} - -static int pCus_AEStatusNotifyHDR_DOL_LEF(ms_cus_sensor *handle, CUS_CAMSENSOR_AE_STATUS_NOTIFY status) -{ - imx347_params *params = (imx347_params *)handle->private_data; - - switch(status) - { - case CUS_FRAME_INACTIVE: - - break; - case CUS_FRAME_ACTIVE: - - if(params->dirty || params->orien_dirty) { - SensorReg_Write(0x3001,1); - if(params->dirty) { - SensorRegArrayW((I2C_ARRAY*)params->tVts_reg, ARRAY_SIZE(vts_reg_hdr)); - SensorRegArrayW((I2C_ARRAY*)params->tSHR0_reg, ARRAY_SIZE(expo_SHR0_reg)); - SensorRegArrayW((I2C_ARRAY*)params->tSHR1_reg, ARRAY_SIZE(expo_SHR1_reg)); - SensorRegArrayW((I2C_ARRAY*)params->tRHS1_reg, ARRAY_SIZE(expo_RHS1_reg)); - SensorRegArrayW((I2C_ARRAY*)params->tGain_hdr_dol_lef_reg, ARRAY_SIZE(gain_HDR_DOL_LEF_reg)); - SensorRegArrayW((I2C_ARRAY*)params->tGain_hdr_dol_sef_reg, ARRAY_SIZE(gain_HDR_DOL_SEF_reg)); - params->dirty = false; - } - if(params->orien_dirty) { - DoOrien(handle, handle->orient); - params->orien_dirty = false; - } - SensorReg_Write(0x3001,0); - } - break; - default : - break; - } - return SUCCESS; -} - -static int pCus_GetAEUSecs_HDR_DOL_LEF(ms_cus_sensor *handle, u32 *us) -{ - *us = 0; - return SUCCESS; -} - -static int pCus_SetAEUSecsHDR_DOL_LEF(ms_cus_sensor *handle, u32 us) -{ - u32 expo_lines_lef = 0, vts = 0, fsc = 0; - u32 cur_line_period = Preview_line_period_HDR_DOL_4LANE; - imx347_params *params = (imx347_params *)handle->private_data; - cur_line_period = Preview_line_period_HDR_DOL_4LANE; - expo_lines_lef = (1000 * us + (cur_line_period >> 1)) / cur_line_period; - - params->expo.expo_lef_us = us; - fsc = params->expo.vts * 2; - params->fsc = ((fsc >> 2) << 2)+ 4; // 4n - - //params->max_shr0 = fsc - expo_lines_lef - 8; - params->max_shr0 = (fsc - 8) - expo_lines_lef; - if(params->max_shr0 < (params->min_rhs1+9)) - params->max_shr0 = params->min_rhs1+9; - params->max_shr0 = ((params->max_shr0 >> 1) << 1) + 2; //2n - - if (expo_lines_lef > (fsc - params->min_rhs1 - 9)) { - vts = (expo_lines_lef + params->min_rhs1 + 9) / 2; - } - else{ - vts = params->expo.vts; - } - params->expo.expo_lines = expo_lines_lef; - //params->expo.vts = vts; - - SENSOR_DMSG("[%s] us %u, expo_lines_lef %u, vts %u, SHR0 %u \n", __FUNCTION__, - us, \ - expo_lines_lef, \ - vts, \ - params->max_shr0 - ); - params->tSHR0_reg[0].data = (params->max_shr0 >> 16) & 0x0003; - params->tSHR0_reg[1].data = (params->max_shr0 >> 8) & 0x00ff; - params->tSHR0_reg[2].data = (params->max_shr0 >> 0) & 0x00ff; - - params->tVts_reg[0].data = (vts >> 16) & 0x0003; - params->tVts_reg[1].data = (vts >> 8) & 0x00ff; - params->tVts_reg[2].data = (vts >> 0) & 0x00ff; - - params->dirty = true; - return SUCCESS; -} - -static int pCus_GetAEGain_HDR_DOL_LEF(ms_cus_sensor *handle, u32* gain) -{ - *gain = 0; - return SUCCESS; -} - -static int pCus_SetAEGainHDR_DOL_LEF(ms_cus_sensor *handle, u32 gain) -{ - imx347_params *params = (imx347_params *)handle->private_data; - u16 gain_reg = 0; - - pCus_SetAEGainHDR_DOL_Calculate(gain, &gain_reg); - params->tGain_hdr_dol_lef_reg[0].data = gain_reg & 0xff; - params->tGain_hdr_dol_lef_reg[1].data = (gain_reg >> 8) & 0xff; - - SENSOR_DMSG("[%s] set gain/reg=%u/0x%x\n", __FUNCTION__, gain, params->tGain_hdr_dol_lef_reg[0].data, params->tGain_hdr_dol_lef_reg[1].data); - - params->dirty = true; - return SUCCESS; -} - -static int pCus_GetAEMinMaxGain_HDR_DOL_LEF(ms_cus_sensor *handle, u32 *min, u32 *max) -{ - *min = handle->sat_mingain; - *max = SENSOR_MAX_GAIN; - return SUCCESS; -} - -static int pCus_GetAEMinMaxUSecs_HDR_DOL_LEF(ms_cus_sensor *handle, u32 *min, u32 *max) -{ - *min = 1; - *max = 1000000/imx347_mipi_hdr[0].senout.min_fps; - return SUCCESS; -} - -#if 0 -//static int pCus_GetDGainRemainder(ms_cus_sensor *handle, u32 *dgain_remainder) -//{ -// *dgain_remainder = handle->dgain_remainder; - -// return SUCCESS; -//} - -static int pCus_SetAEGain_cal_hdr_dol_lef(ms_cus_sensor *handle, u32 gain) -{ - return SUCCESS; -} - -static int pCus_setCaliData_gain_linearity_hdr_dol_lef(ms_cus_sensor* handle, CUS_GAIN_GAP_ARRAY* pArray, u32 num) -{ - return SUCCESS; -} -#endif - -static int IMX347_GetShutterInfo_HDR_DOL_LEF(struct __ms_cus_sensor* handle,CUS_SHUTTER_INFO *info) -{ - info->max = 1000000000/imx347_mipi_hdr[0].senout.min_fps; - info->min = (Preview_line_period_HDR_DOL_4LANE * 2); - info->step = Preview_line_period_HDR_DOL_4LANE; - return SUCCESS; -} - -static int cus_camsensor_init_handle_hdr_dol_lef(ms_cus_sensor* drv_handle) -{ - ms_cus_sensor *handle = drv_handle; - imx347_params *params; - s32 res; - if (!handle) { - SENSOR_DMSG("[%s] not enough memory!\n", __FUNCTION__); - return FAIL; - } - - //private data allocation & init - if (handle->private_data == NULL) { - SENSOR_EMSG("[%s] Private data is empty!\n", __FUNCTION__); - return FAIL; - } - params = (imx347_params *)handle->private_data; - memcpy(params->tVts_reg, vts_reg_hdr, sizeof(vts_reg_hdr)); - memcpy(params->tSHR0_reg, expo_SHR0_reg, sizeof(expo_SHR0_reg)); - memcpy(params->tGain_hdr_dol_lef_reg, gain_HDR_DOL_LEF_reg, sizeof(gain_HDR_DOL_LEF_reg)); - - //////////////////////////////////// - // sensor model ID // - //////////////////////////////////// - sprintf(handle->model_id,"IMX347_MIPI_HDR_LEF"); - - //////////////////////////////////// - // i2c config // - //////////////////////////////////// - handle->i2c_cfg.mode = SENSOR_I2C_LEGACY; //(CUS_ISP_I2C_MODE) FALSE; - handle->i2c_cfg.fmt = SENSOR_I2C_FMT; //CUS_I2C_FMT_A16D16; - handle->i2c_cfg.address = SENSOR_I2C_ADDR; //0x5a; - handle->i2c_cfg.speed = SENSOR_I2C_SPEED; //320000; - - //////////////////////////////////// - // mclk // - //////////////////////////////////// - handle->mclk =Preview_MCLK_SPEED_HDR_DOL; - //////////////////////////////////// - // sensor interface info // - //////////////////////////////////// - //handle->isp_type = SENSOR_ISP_TYPE; //ISP_SOC; - //handle->data_fmt = SENSOR_DATAFMT; //CUS_DATAFMT_YUV; - handle->sif_bus = SENSOR_IFBUS_TYPE; //CUS_SENIF_BUS_PARL; - handle->data_prec = SENSOR_DATAPREC_DOL; //CUS_DATAPRECISION_8; - handle->data_mode = SENSOR_DATAMODE; - handle->bayer_id = SENSOR_BAYERID_HDR_DOL; //CUS_BAYER_GB; - handle->RGBIR_id = SENSOR_RGBIRID; - handle->orient = SENSOR_ORIT; //CUS_ORIT_M1F1; - //handle->YC_ODER = SENSOR_YCORDER; //CUS_SEN_YCODR_CY; - handle->interface_attr.attr_mipi.mipi_lane_num = 4;//hdr_lane_num; - handle->interface_attr.attr_mipi.mipi_data_format = CUS_SEN_INPUT_FORMAT_RGB; // RGB pattern. - handle->interface_attr.attr_mipi.mipi_yuv_order = 0; //don't care in RGB pattern. - handle->interface_attr.attr_mipi.mipi_hsync_mode = SENSOR_MIPI_HSYNC_MODE_HDR_DOL; - handle->interface_attr.attr_mipi.mipi_hdr_mode = CUS_HDR_MODE_DCG; - handle->interface_attr.attr_mipi.mipi_hdr_virtual_channel_num = 0; //Long frame - - //////////////////////////////////// - // resolution capability // - //////////////////////////////////// - - handle->video_res_supported.ulcur_res = 0; //default resolution index is 0. - //handle->video_res_supported.num_res = HDR_RES_END; - for (res = 0; res < HDR_RES_END; res++) { - handle->video_res_supported.num_res = res+1; - handle->video_res_supported.res[res].width = imx347_mipi_hdr[res].senif.preview_w; - handle->video_res_supported.res[res].height = imx347_mipi_hdr[res].senif.preview_h; - handle->video_res_supported.res[res].max_fps = imx347_mipi_hdr[res].senout.max_fps; - handle->video_res_supported.res[res].min_fps = imx347_mipi_hdr[res].senout.min_fps; - handle->video_res_supported.res[res].crop_start_x = imx347_mipi_hdr[res].senif.crop_start_X; - handle->video_res_supported.res[res].crop_start_y = imx347_mipi_hdr[res].senif.crop_start_y; - handle->video_res_supported.res[res].nOutputWidth = imx347_mipi_hdr[res].senout.width; - handle->video_res_supported.res[res].nOutputHeight = imx347_mipi_hdr[res].senout.height; - sprintf(handle->video_res_supported.res[res].strResDesc, imx347_mipi_hdr[res].senstr.strResDesc); - } - - //////////////////////////////////// - // Sensor polarity // - //////////////////////////////////// - handle->pwdn_POLARITY = SENSOR_PWDN_POL; //CUS_CLK_POL_NEG; - handle->reset_POLARITY = SENSOR_RST_POL; //CUS_CLK_POL_NEG; - //handle->VSYNC_POLARITY = SENSOR_VSYNC_POL; //CUS_CLK_POL_POS; - //handle->HSYNC_POLARITY = SENSOR_HSYNC_POL; //CUS_CLK_POL_POS; - //handle->PCLK_POLARITY = SENSOR_PCLK_POL; //CUS_CLK_POL_POS); // use '!' to clear board latch error - ///////////////////////////////////////////////////// - - //////////////////////////////////////// - // Sensor Status Control and Get Info // - //////////////////////////////////////// - //LOGD("[%s:%d]\n", __FUNCTION__, __LINE__); - handle->pCus_sensor_release = cus_camsensor_release_handle; - handle->pCus_sensor_init = pCus_init_HDR_DOL_LEF; - //handle->pCus_sensor_powerupseq = pCus_powerupseq ; - handle->pCus_sensor_poweron = pCus_poweron_HDR_DOL_LEF; - handle->pCus_sensor_poweroff = pCus_poweroff_HDR_DOL_LEF; - handle->pCus_sensor_GetSensorID = pCus_GetSensorID_HDR_DOL_LEF; - //handle->pCus_sensor_GetVideoResNum = NULL; - //handle->pCus_sensor_GetVideoRes = NULL; - //handle->pCus_sensor_GetCurVideoRes = NULL; - handle->pCus_sensor_SetVideoRes = pCus_SetVideoRes_HDR_DOL_LEF; // Need to check - - - handle->pCus_sensor_GetOrien = pCus_GetOrien_HDR_DOL_LEF; - handle->pCus_sensor_SetOrien = pCus_SetOrien_HDR_DOL_LEF; - handle->pCus_sensor_GetFPS = pCus_GetFPS_HDR_DOL_LEF; - handle->pCus_sensor_SetFPS = pCus_SetFPS_HDR_DOL_LEF; - //handle->pCus_sensor_GetSensorCap = pCus_GetSensorCap_hdr_dol_lef; - //handle->pCus_sensor_SetPatternMode = imx347_SetPatternMode_hdr_dol_lef; - - //////////////////////////////////// - // AE parameters // - //////////////////////////////////// - handle->ae_gain_delay = SENSOR_GAIN_DELAY_FRAME_COUNT; - handle->ae_shutter_delay = SENSOR_SHUTTER_DELAY_FRAME_COUNT_HDR_DOL; - handle->ae_gain_ctrl_num = 2; - handle->ae_shutter_ctrl_num = 2; - handle->sat_mingain = SENSOR_MIN_GAIN; - //handle->dgain_remainder = 0; - - //////////////////////////////////// - // AE Control and Get Info // - //////////////////////////////////// - handle->pCus_sensor_AEStatusNotify = pCus_AEStatusNotifyHDR_DOL_LEF; - handle->pCus_sensor_GetAEUSecs = pCus_GetAEUSecs_HDR_DOL_LEF; - handle->pCus_sensor_SetAEUSecs = pCus_SetAEUSecsHDR_DOL_LEF; - handle->pCus_sensor_GetAEGain = pCus_GetAEGain_HDR_DOL_LEF; - handle->pCus_sensor_SetAEGain = pCus_SetAEGainHDR_DOL_LEF; - - handle->pCus_sensor_GetAEMinMaxGain = pCus_GetAEMinMaxGain_HDR_DOL_LEF; - handle->pCus_sensor_GetAEMinMaxUSecs= pCus_GetAEMinMaxUSecs_HDR_DOL_LEF; - //handle->pCus_sensor_GetDGainRemainder = pCus_GetDGainRemainder; - - handle->pCus_sensor_GetShutterInfo = IMX347_GetShutterInfo_HDR_DOL_LEF; - - params->expo.vts = vts_30fps_HDR_DOL_4lane; - - params->dirty = false; - - return SUCCESS; -} - -SENSOR_DRV_ENTRY_IMPL_END_EX(IMX347_HDR, - cus_camsensor_init_handle_linear, - cus_camsensor_init_handle_hdr_dol_sef, - cus_camsensor_init_handle_hdr_dol_lef, - imx347_params - ); diff --git a/general/package/sigmastar-osdrv-sensor/src/infinity6e/sensor/sensor_imx415_mipi.c b/general/package/sigmastar-osdrv-sensor/src/infinity6e/sensor/sensor_imx415_mipi.c deleted file mode 100644 index e4e46c0b..00000000 --- a/general/package/sigmastar-osdrv-sensor/src/infinity6e/sensor/sensor_imx415_mipi.c +++ /dev/null @@ -1,5391 +0,0 @@ -/* Copyright (c) 2018-2019 Sigmastar Technology Corp. - All rights reserved. - - Unless otherwise stipulated in writing, any and all information contained -herein regardless in any format shall remain the sole proprietary of -Sigmastar Technology Corp. and be kept in strict confidence -(Sigmastar Confidential Information) by the recipient. -Any unauthorized act including without limitation unauthorized disclosure, -copying, use, reproduction, sale, distribution, modification, disassembling, -reverse engineering and compiling of the contents of Sigmastar Confidential -Information is unlawful and strictly prohibited. Sigmastar hereby reserves the -rights to any and all damages, losses, costs and expenses resulting therefrom. -*/ - -#ifdef __cplusplus -extern "C" -{ -#endif - -#include -#include -#include -#include //TODO: move this header to drv_sensor_common.h -#ifdef __cplusplus -} -#endif - -SENSOR_DRV_ENTRY_IMPL_BEGIN_EX(IMX415_HDR); - -#ifndef ARRAY_SIZE -#define ARRAY_SIZE CAM_OS_ARRAY_SIZE -#endif - -//#define SENSOR_PAD_GROUP_SET CUS_SENSOR_PAD_GROUP_A -//#define SENSOR_CHANNEL_NUM (0) -#define SENSOR_CHANNEL_MODE CUS_SENSOR_CHANNEL_MODE_REALTIME_NORMAL -#define SENSOR_CHANNEL_MODE_SONY_DOL CUS_SENSOR_CHANNEL_MODE_RAW_STORE_HDR - -//============================================ -#define ENABLE 1 -#define DISABLE 0 -#undef SENSOR_DBG -#define SENSOR_DBG 0 - -#define DEBUG_INFO 0 - -#if SENSOR_DBG == 1 -//#define SENSOR_DMSG(args...) LOGD(args) -//#define SENSOR_DMSG(args...) LOGE(args) -//#define SENSOR_DMSG(args...) printf(args) -#elif SENSOR_DBG == 0 -//#define SENSOR_DMSG(args...) -#endif -/////////////////////////////////////////////////////////////// -// @@@ // -// @ @@ == S t a r t * H e r e == // -// @@ == S t a r t * H e r e == // -// @@ == S t a r t * H e r e == // -// @@@@ // -// // -// Start Step 1 -- show preview on LCM // -// // -// Fill these #define value and table with correct settings // -// camera can work and show preview on LCM // -// // -/////////////////////////////////////////////////////////////// - -//////////////////////////////////// -// Sensor-If Info // -//////////////////////////////////// -//MIPI config begin. -#define SENSOR_MIPI_LANE_NUM (4) -#define SENSOR_MIPI_LANE_NUM_DOL (4) -//#define SENSOR_MIPI_HDR_MODE (0) //0: Non-HDR mode. 1:Sony DOL mode - -#define SENSOR_ISP_TYPE ISP_EXT //ISP_EXT, ISP_SOC (Non-used) -//#define SENSOR_DATAFMT CUS_DATAFMT_BAYER //CUS_DATAFMT_YUV, CUS_DATAFMT_BAYER -#define SENSOR_IFBUS_TYPE CUS_SENIF_BUS_MIPI //CFG //CUS_SENIF_BUS_PARL, CUS_SENIF_BUS_MIPI -#define SENSOR_MIPI_HSYNC_MODE PACKET_HEADER_EDGE1 -#define SENSOR_MIPI_HSYNC_MODE_HDR_DOL PACKET_FOOTER_EDGE -#define SENSOR_DATAPREC CUS_DATAPRECISION_10 -#define SENSOR_DATAPREC_DOL CUS_DATAPRECISION_12 -#define SENSOR_DATAMODE CUS_SEN_10TO12_9098 //CFG -#define SENSOR_BAYERID CUS_BAYER_GB //0h: CUS_BAYER_RG, 1h: CUS_BAYER_GR, 2h: CUS_BAYER_BG, 3h: CUS_BAYER_GB -#define SENSOR_BAYERID_HDR_DOL CUS_BAYER_GB -#define SENSOR_RGBIRID CUS_RGBIR_NONE -#define SENSOR_ORIT CUS_ORIT_M0F0 //CUS_ORIT_M0F0, CUS_ORIT_M1F0, CUS_ORIT_M0F1, CUS_ORIT_M1F1, -//#define SENSOR_YCORDER CUS_SEN_YCODR_YC //CUS_SEN_YCODR_YC, CUS_SEN_YCODR_CY -//#define long_packet_type_enable 0x00 //UD1~UD8 (user define) - -//////////////////////////////////// -// MCLK Info // -//////////////////////////////////// -#define Preview_MCLK_SPEED CUS_CMU_CLK_27MHZ //CUS_CMU_CLK_24MHZ //CUS_CMU_CLK_37P125MHZ//CUS_CMU_CLK_27MHZ -#define Preview_MCLK_SPEED_HDR_DOL CUS_CMU_CLK_27MHZ - -//////////////////////////////////// -// I2C Info // -//////////////////////////////////// -#define SENSOR_I2C_ADDR 0x34 //I2C slave address -#define SENSOR_I2C_SPEED 300000 //200000 //300000 //240000 //I2C speed, 60000~320000 -//#define SENSOR_I2C_CHANNEL 1 //I2C Channel -//#define SENSOR_I2C_PAD_MODE 2 //Pad/Mode Number -#define SENSOR_I2C_LEGACY I2C_NORMAL_MODE //usally set CUS_I2C_NORMAL_MODE, if use old OVT I2C protocol=> set CUS_I2C_LEGACY_MODE -#define SENSOR_I2C_FMT I2C_FMT_A16D8 //CUS_I2C_FMT_A8D8, CUS_I2C_FMT_A8D16, CUS_I2C_FMT_A16D8, CUS_I2C_FMT_A16D16 - -//////////////////////////////////// -// Sensor Signal // -//////////////////////////////////// -#define SENSOR_PWDN_POL CUS_CLK_POL_NEG // if PWDN pin High can makes sensor in power down, set CUS_CLK_POL_POS -#define SENSOR_RST_POL CUS_CLK_POL_NEG // if RESET pin High can makes sensor in reset state, set CUS_CLK_POL_NEG - // VSYNC/HSYNC POL can be found in data sheet timing diagram, - // Notice: the initial setting may contain VSYNC/HSYNC POL inverse settings so that condition is different. -#define SENSOR_VSYNC_POL CUS_CLK_POL_NEG // if VSYNC pin High and data bus have data, set CUS_CLK_POL_POS -#define SENSOR_HSYNC_POL CUS_CLK_POL_NEG // if HSYNC pin High and data bus have data, set CUS_CLK_POL_POS -#define SENSOR_PCLK_POL CUS_CLK_POL_NEG // depend on sensor setting, sometimes need to try CUS_CLK_POL_POS or CUS_CLK_POL_NEG - -//////////////////////////////////// -// Sensor ID // -//////////////////////////////////// -//define SENSOR_ID - -#undef SENSOR_NAME -#define SENSOR_NAME IMX415 - -#define CHIP_ID_r3F12 0x3F12 -#define CHIP_ID_r3F13 0x3F13 -#define CHIP_ID 0x0415 - -//////////////////////////////////// -// Image Info // -//////////////////////////////////// -static struct { // LINEAR - // Modify it based on number of support resolution - enum {LINEAR_RES_1 = 0, LINEAR_RES_2, LINEAR_RES_3, LINEAR_RES_4, LINEAR_RES_5, LINEAR_RES_6, LINEAR_RES_7, LINEAR_RES_8, LINEAR_RES_END}mode; - // Sensor Output Image info - struct _senout{ - s32 width, height, min_fps, max_fps; - }senout; - // VIF Get Image Info - struct _sensif{ - s32 crop_start_X, crop_start_y, preview_w, preview_h; - }senif; - // Show resolution string - struct _senstr{ - const char* strResDesc; - }senstr; -}imx415_mipi_linear[] = { - {LINEAR_RES_1, {3860, 2250, 3, 20}, {12, 16, 3840, 2160}, {"3840x2160@20fps"}}, - {LINEAR_RES_2, {3096, 2190, 3, 30}, {0, 0, 3072, 2048}, {"3072x2048@30fps"}}, // Modify it - {LINEAR_RES_3, {3096, 1758, 3, 30}, {0, 0, 3072, 1728}, {"3072x1728@30fps"}}, // Modify it - {LINEAR_RES_4, {2616, 1974, 3, 30}, {0, 0, 2592, 1944}, {"2592x1944@30fps"}}, // Modify it - {LINEAR_RES_5, {2976, 1686, 3, 30}, {0, 0, 2944, 1656}, {"2944x1656@30fps"}}, // Modify it - {LINEAR_RES_6, {2592, 1470, 3, 30}, {0, 0, 2560, 1440}, {"2560x1440@30fps"}}, // Modify it - {LINEAR_RES_7, {1920, 1080, 3, 60}, {0, 0, 1920, 1080}, {"1920x1080@60fps"}}, // Modify it - {LINEAR_RES_8, {1280, 720, 3, 120}, {0, 0, 1280, 720}, {"1280x720@120fps"}}, // Modify it -}; - -static struct { // HDR - // Modify it based on number of support resolution - enum {HDR_RES_1 = 0, HDR_RES_2, HDR_RES_3, HDR_RES_4, HDR_RES_5, HDR_RES_6, HDR_RES_7, HDR_RES_END}mode; - // Sensor Output Image info - struct _hsenout{ - s32 width, height, min_fps, max_fps; - }senout; - // VIF Get Image Info - struct _hsensif{ - s32 crop_start_X, crop_start_y, preview_w, preview_h; - }senif; - // Show resolution string - struct _hsenstr{ - const char* strResDesc; - }senstr; -}imx415_mipi_hdr[] = { - {HDR_RES_1, {3864, 2192, 3, 15}, {0, 0, 3840, 2160}, {"3840x2160@15fps_HDR"}}, // Modify it - {HDR_RES_2, {3864, 2192, 3, 20}, {0, 0, 3840, 2160}, {"3840x2160@20fps_HDR"}}, // Modify it - {HDR_RES_3, {3864, 2192, 3, 30}, {0, 0, 3840, 2160}, {"3840x2160@30fps_HDR"}}, // Modify it - {HDR_RES_4, {2592, 1944, 3, 30}, {0, 0, 2592, 1944}, {"2592x1944@30fps_HDR"}}, // Modify it - {HDR_RES_5, {2976, 1688, 3, 30}, {0, 0, 2944, 1656}, {"2944x1656@30fps_HDR"}}, // Modify it - {HDR_RES_6, {2688, 1520, 3, 30}, {0, 0, 2688, 1520}, {"2688x1520@30fps_HDR"}}, // Modify it - {HDR_RES_7, {1920, 1080, 3, 30}, {0, 0, 1920, 1080}, {"1920x1080@30fps_HDR"}}, // Modify it -}; - -#define IMX415_HDR_BRL 2228 - -u32 vts_30fps = 2250; -u32 vts_30fps_HDR_DOL_4lane = 2250; -u32 Preview_line_period = 17778; -u32 Preview_line_period_HDR_DOL_4LANE = 29630; - -//////////////////////////////////// -// AE Info // -//////////////////////////////////// -#define SENSOR_MAX_GAIN (3981 * 1024) // max sensor again, a-gain * conversion-gain*d-gain -#define SENSOR_MIN_GAIN (1 * 1024) -#define SENSOR_GAIN_DELAY_FRAME_COUNT (2) -#define SENSOR_SHUTTER_DELAY_FRAME_COUNT (2) -#define SENSOR_SHUTTER_DELAY_FRAME_COUNT_HDR_DOL (2) - -//////////////////////////////////// -// Mirror-Flip Info // -//////////////////////////////////// -#define MIRROR_FLIP 0x3030 -#define SENSOR_NOR 0x0 -#define SENSOR_MIRROR_EN 0x1 << (0) -#define SENSOR_FLIP_EN 0x1 << (1) -#define SENSOR_MIRROR_FLIP_EN 0x3 - -#if defined (SENSOR_MODULE_VERSION) -#define TO_STR_NATIVE(e) #e -#define TO_STR_PROXY(m, e) m(e) -#define MACRO_TO_STRING(e) TO_STR_PROXY(TO_STR_NATIVE, e) -static char *sensor_module_version = MACRO_TO_STRING(SENSOR_MODULE_VERSION); -module_param(sensor_module_version, charp, S_IRUGO); -#endif - -typedef struct { - struct { - u16 pre_div0; - u16 div124; - u16 div_cnt7b; - u16 sdiv0; - u16 mipi_div0; - u16 r_divp; - u16 sdiv1; - u16 r_seld5; - u16 r_sclk_dac; - u16 sys_sel; - u16 pdac_sel; - u16 adac_sel; - u16 pre_div_sp; - u16 r_div_sp; - u16 div_cnt5b; - u16 sdiv_sp; - u16 div12_sp; - u16 mipi_lane_sel; - u16 div_dac; - } clk_tree; - struct { - bool bVideoMode; - u16 res_idx; - CUS_CAMSENSOR_ORIT orit; - } res; - struct { - float sclk; - u32 hts; - u32 vts; - u32 ho; - u32 xinc; - u32 line_freq; - u32 us_per_line; - u32 final_us; - u32 final_gain; - u32 back_pv_us; - u32 fps; - u32 preview_fps; - u32 expo_lines; - u32 expo_lef_us; - u32 expo_sef_us; - } expo; - - u32 min_shr1; - u32 min_rhs1; - u32 min_shr0; - u32 max_shr0; - u32 fsc; - I2C_ARRAY tVts_reg[3]; - I2C_ARRAY tVts_reg_hdr[3]; - I2C_ARRAY tExpo_reg[3]; - I2C_ARRAY tSHR0_reg[3]; - I2C_ARRAY tSHR1_reg[3]; - I2C_ARRAY tRHS1_reg[3]; - I2C_ARRAY tGain_reg[2]; - I2C_ARRAY tGain_hdr_dol_lef_reg[2]; - I2C_ARRAY tGain_hdr_dol_sef_reg[2]; - bool dirty; - bool orien_dirty; -} imx415_params; - -static int pCus_SetAEUSecs(ms_cus_sensor *handle, u32 us); -static int pCus_SetAEUSecsHDR_DOL_SEF(ms_cus_sensor *handle, u32 us); -static int pCus_SetAEUSecsHDR_DOL_LEF(ms_cus_sensor *handle, u32 us); -/////////////////////////////////////////////////////////////// -// @@@ // -// @ @@ // -// @@ // -// @@ // -// @@@@@ // -// // -// Start Step 2 -- set Sensor initial and // -// adjust parameter // -// Fill these register table with resolution settings // -// camera can work and show preview on LCM // -// // -/////////////////////////////////////////////////////////////// -const static I2C_ARRAY Sensor_init_table_4lane_linear[] = -{ - {0x3000, 0x01}, //Standby - //{0xffff, 0x24}, //delay (ms) - {0x3002, 0x01}, //Master mode stop - //{0xffff, 0x10}, //delay (ms) - {0x3008, 0x7F}, //BCwait time - {0x3009, 0x00}, - {0x300A, 0x5B}, - {0x300B, 0xA0}, - //{0x3023, 0x0}, - {0x3024, 0xCA}, //VMAX LSB - {0x3025, 0x08}, //VMAX MSB 8CAh: 2250 - {0x3026, 0x00}, //VMAX MSB [0:3] - {0x3028, 0x4C}, //HMAX LSB - {0x3029, 0x04}, //HMAX MSB 44Ch: 1100 - {0x3031, 0x00}, //ADBIT 0h: AD 10bit; 1h: AD 12bit - {0x3032, 0x00}, //MDBIT 0h: 10bit; 1h: 12bit - {0x3033, 0x05}, //SYS MODE 05h: 891Mbps - {0x3050, 0x08}, //SHR0 Shutter Setting - {0x3051, 0x00}, - {0x3052, 0x00}, - {0x30C0, 0x2A}, //XVSOUTSEL - {0x30C1, 0x00}, - {0x30CC, 0x00}, - {0x30CD, 0x00}, - {0x30CF, 0x00}, //DOL setting - {0x3116, 0x24}, //INCKSEL2 - {0x311E, 0x24}, //INCKSEL5 - {0x32D4, 0x21}, - {0x32EC, 0xA1}, - {0x3452, 0x7F}, - {0x3453, 0x03}, - {0x358A, 0x04}, - {0x35A1, 0x02}, - {0x36BC, 0x0C}, - {0x36CC, 0x53}, - {0x36CD, 0x00}, - {0x36CE, 0x3C}, - {0x36D0, 0x8C}, - {0x36D1, 0x00}, - {0x36D2, 0x71}, - {0x36D4, 0x3C}, - {0x36D6, 0x53}, - {0x36D7, 0x00}, - {0x36D8, 0x71}, - {0x36DA, 0x8C}, - {0x36DB, 0x00}, - {0x37D1, 0x00}, //ADBIT1 - {0x3724, 0x02}, - {0x3726, 0x02}, - {0x3732, 0x02}, - {0x3734, 0x03}, - {0x3736, 0x03}, - {0x3742, 0x03}, - {0x3862, 0xE0}, - {0x38CC, 0x30}, - {0x38CD, 0x2F}, - {0x395C, 0x0C}, - {0x3A42, 0xD1}, - {0x3A4C, 0x77}, - {0x3AE0, 0x02}, - {0x3AEC, 0x0C}, - {0x3B00, 0x2E}, - {0x3B06, 0x29}, - {0x3B98, 0x25}, - {0x3B99, 0x21}, - {0x3B9B, 0x13}, - {0x3B9C, 0x13}, - {0x3B9D, 0x13}, - {0x3B9E, 0x13}, - {0x3BA1, 0x00}, - {0x3BA2, 0x06}, - {0x3BA3, 0x0B}, - {0x3BA4, 0x10}, - {0x3BA5, 0x14}, - {0x3BA6, 0x18}, - {0x3BA7, 0x1A}, - {0x3BA8, 0x1A}, - {0x3BA9, 0x1A}, - {0x3BAC, 0xED}, - {0x3BAD, 0x01}, - {0x3BAE, 0xF6}, - {0x3BAF, 0x02}, - {0x3BB0, 0xA2}, - {0x3BB1, 0x03}, - {0x3BB2, 0xE0}, - {0x3BB3, 0x03}, - {0x3BB4, 0xE0}, - {0x3BB5, 0x03}, - {0x3BB6, 0xE0}, - {0x3BB7, 0x03}, - {0x3BB8, 0xE0}, - {0x3BBA, 0xE0}, - {0x3BBC, 0xDA}, - {0x3BBE, 0x88}, - {0x3BC0, 0x44}, - {0x3BC2, 0x7B}, - {0x3BC4, 0xA2}, - {0x3BC8, 0xBD}, - {0x3BCA, 0xBD}, - {0x4004, 0x48}, //TXCLKSEC_FREQ LSB - {0x4005, 0x09}, //TXCLKSEC_FREQ MSB - {0x400C, 0x00}, - {0x4018, 0x7F}, //TCLKPOST MIPI global setting - {0x401A, 0x37}, //TCLKPREPARE MIPI global setting - {0x401C, 0x37}, //TCLKTRAIL MIPI global setting - {0x401E, 0xF7}, //TCLKZERO MIPI global setting - {0x401F, 0x00}, //TCLKZERO - {0x4020, 0x3F}, //THSPREPARE - {0x4022, 0x6F}, //THSZERO - {0x4024, 0x3F}, //THSTRAIL - {0x4026, 0x5F}, //THSEXT - {0x4028, 0x2F}, //TLPX - {0x4074, 0x01}, - {0xffff, 0x24}, - {0x3002, 0x00}, //Master mode start - {0xffff, 0x10}, - {0x3000, 0x00}, //Operating -}; -//8M20 594Mbps, 10bits, Mclk 27M -const static I2C_ARRAY Sensor_8m_20fps_init_table_4lane_linear[] = -{ - /* - IMX415-AAQR All-pixel scan CSI-2_4lane 27MHz AD:10bit Output:10bit 594Mbps Master Mode 19.996fps Integration Time 49.86ms - Tool ver : Ver6.0 hts:1320 vts:2813 - */ - {0x3000, 0x01}, //Standby - //{0xffff, 0x24}, //delay (ms) - {0x3002, 0x01}, //Master mode stop - //{0xffff, 0x10}, //delay (ms) - {0x3008,0x5D}, // BCWAIT_TIME[9:0] - {0x300A,0x42}, // CPWAIT_TIME[9:0] - {0x3024,0xFD}, // VMAX[19:0] - {0x3025,0x0A}, // - {0x3028,0x28}, // HMAX[15:0] - {0x3029,0x05}, // - {0x3031,0x00}, // ADBIT[1:0] - {0x3032,0x00}, // MDBIT - {0x3033,0x07}, // SYS_MODE[3:0] - {0x3050,0x08}, // SHR0[19:0] - {0x30C1,0x00}, // XVS_DRV[1:0] - {0x3116,0x23}, // INCKSEL2[7:0] - {0x3118,0x84}, // INCKSEL3[10:0] - {0x311A,0xE7}, // INCKSEL4[10:0] - {0x311E,0x23}, // INCKSEL5[7:0] - {0x32D4,0x21}, // - - {0x32EC,0xA1}, // - - {0x3452,0x7F}, // - - {0x3453,0x03}, // - - {0x358A,0x04}, // - - {0x35A1,0x02}, // - - {0x36BC,0x0C}, // - - {0x36CC,0x53}, // - - {0x36CD,0x00}, // - - {0x36CE,0x3C}, // - - {0x36D0,0x8C}, // - - {0x36D1,0x00}, // - - {0x36D2,0x71}, // - - {0x36D4,0x3C}, // - - {0x36D6,0x53}, // - - {0x36D7,0x00}, // - - {0x36D8,0x71}, // - - {0x36DA,0x8C}, // - - {0x36DB,0x00}, // - - {0x3701,0x00}, // ADBIT1[7:0] - {0x3724,0x02}, // - - {0x3726,0x02}, // - - {0x3732,0x02}, // - - {0x3734,0x03}, // - - {0x3736,0x03}, // - - {0x3742,0x03}, // - - {0x3862,0xE0}, // - - {0x38CC,0x30}, // - - {0x38CD,0x2F}, // - - {0x395C,0x0C}, // - - {0x3A42,0xD1}, // - - {0x3A4C,0x77}, // - - {0x3AE0,0x02}, // - - {0x3AEC,0x0C}, // - - {0x3B00,0x2E}, // - - {0x3B06,0x29}, // - - {0x3B98,0x25}, // - - {0x3B99,0x21}, // - - {0x3B9B,0x13}, // - - {0x3B9C,0x13}, // - - {0x3B9D,0x13}, // - - {0x3B9E,0x13}, // - - {0x3BA1,0x00}, // - - {0x3BA2,0x06}, // - - {0x3BA3,0x0B}, // - - {0x3BA4,0x10}, // - - {0x3BA5,0x14}, // - - {0x3BA6,0x18}, // - - {0x3BA7,0x1A}, // - - {0x3BA8,0x1A}, // - - {0x3BA9,0x1A}, // - - {0x3BAC,0xED}, // - - {0x3BAD,0x01}, // - - {0x3BAE,0xF6}, // - - {0x3BAF,0x02}, // - - {0x3BB0,0xA2}, // - - {0x3BB1,0x03}, // - - {0x3BB2,0xE0}, // - - {0x3BB3,0x03}, // - - {0x3BB4,0xE0}, // - - {0x3BB5,0x03}, // - - {0x3BB6,0xE0}, // - - {0x3BB7,0x03}, // - - {0x3BB8,0xE0}, // - - {0x3BBA,0xE0}, // - - {0x3BBC,0xDA}, // - - {0x3BBE,0x88}, // - - {0x3BC0,0x44}, // - - {0x3BC2,0x7B}, // - - {0x3BC4,0xA2}, // - - {0x3BC8,0xBD}, // - - {0x3BCA,0xBD}, // - - {0x4004,0xC0}, // TXCLKESC_FREQ[15:0] - {0x4005,0x06}, // - {0x400C,0x00}, // INCKSEL6 - {0x4018,0x67}, // TCLKPOST[15:0] - {0x401A,0x27}, // TCLKPREPARE[15:0] - {0x401C,0x27}, // TCLKTRAIL[15:0] - {0x401E,0xB7}, // TCLKZERO[15:0] - {0x401F,0x00}, // - {0x4020,0x2F}, // THSPREPARE[15:0] - {0x4022,0x4F}, // THSZERO[15:0] - {0x4024,0x2F}, // THSTRAIL[15:0] - {0x4026,0x47}, // THSEXIT[15:0] - {0x4028,0x27}, // TLPX[15:0] - {0x4074,0x01}, // INCKSEL7 [2:0] - {0xffff, 0x24}, - {0x3002, 0x00}, //Master mode start - {0xffff, 0x10}, - {0x3000, 0x00}, //Operating -}; -//3096x2190 891Mbps, 10bits, Mclk 27M -const static I2C_ARRAY Sensor_6m_30fps_init_table_4lane_linear[] = -{ - /* - IMX415-AAQR Window cropping 3096x2190 CSI-2_4lane 27MHz AD:10bit Output:10bit 891Mbps Master Mode 30fps Integration Time 33.217ms - Tool ver : Ver6.0 vts:2250 hts:1100 - */ - {0x3000, 0x01}, //Standby - //{0xffff, 0x24}, //delay (ms) - {0x3002, 0x01}, //Master mode stop - //{0xffff, 0x10}, //delay (ms) - {0x3008, 0x5D}, // BCWAIT_TIME[9:0] - {0x300A, 0x42}, // CPWAIT_TIME[9:0] - {0x301C, 0x04}, // WINMODE[3:0] - {0x3028, 0x4C}, // HMAX[15:0] - {0x3029, 0x04}, // - {0x3031, 0x00}, // ADBIT[1:0] - {0x3032, 0x00}, // MDBIT - {0x3033, 0x05}, // SYS_MODE[3:0] - {0x3040, 0x80}, // PIX_HST[12:0] - {0x3041, 0x01}, // - {0x3043, 0x0C}, // - {0x3044, 0x00}, // PIX_VST[12:0]//02 - {0x3045, 0x00}, // - {0x3046, 0x1C}, // PIX_VWIDTH[12:0] - {0x3050, 0x08}, // SHR0[19:0] - {0x30C1, 0x00}, // XVS_DRV[1:0] - {0x3116, 0x23}, // INCKSEL2[7:0] - {0x3118, 0xC6}, // INCKSEL3[10:0] - {0x311A, 0xE7}, // INCKSEL4[10:0] - {0x311E, 0x23}, // INCKSEL5[7:0] - {0x32D4, 0x21}, // - - {0x32EC, 0xA1}, // - - {0x3452, 0x7F}, // - - {0x3453, 0x03}, // - - {0x358A, 0x04}, // - - {0x35A1, 0x02}, // - - {0x36BC, 0x0C}, // - - {0x36CC, 0x53}, // - - {0x36CD, 0x00}, // - - {0x36CE, 0x3C}, // - - {0x36D0, 0x8C}, // - - {0x36D1, 0x00}, // - - {0x36D2, 0x71}, // - - {0x36D4, 0x3C}, // - - {0x36D6, 0x53}, // - - {0x36D7, 0x00}, // - - {0x36D8, 0x71}, // - - {0x36DA, 0x8C}, // - - {0x36DB, 0x00}, // - - {0x3701, 0x00}, // ADBIT1[7:0] - {0x3724, 0x02}, // - - {0x3726, 0x02}, // - - {0x3732, 0x02}, // - - {0x3734, 0x03}, // - - {0x3736, 0x03}, // - - {0x3742, 0x03}, // - - {0x3862, 0xE0}, // - - {0x38CC, 0x30}, // - - {0x38CD, 0x2F}, // - - {0x395C, 0x0C}, // - - {0x3A42, 0xD1}, // - - {0x3A4C, 0x77}, // - - {0x3AE0, 0x02}, // - - {0x3AEC, 0x0C}, // - - {0x3B00, 0x2E}, // - - {0x3B06, 0x29}, // - - {0x3B98, 0x25}, // - - {0x3B99, 0x21}, // - - {0x3B9B, 0x13}, // - - {0x3B9C, 0x13}, // - - {0x3B9D, 0x13}, // - - {0x3B9E, 0x13}, // - - {0x3BA1, 0x00}, // - - {0x3BA2, 0x06}, // - - {0x3BA3, 0x0B}, // - - {0x3BA4, 0x10}, // - - {0x3BA5, 0x14}, // - - {0x3BA6, 0x18}, // - - {0x3BA7, 0x1A}, // - - {0x3BA8, 0x1A}, // - - {0x3BA9, 0x1A}, // - - {0x3BAC, 0xED}, // - - {0x3BAD, 0x01}, // - - {0x3BAE, 0xF6}, // - - {0x3BAF, 0x02}, // - - {0x3BB0, 0xA2}, // - - {0x3BB1, 0x03}, // - - {0x3BB2, 0xE0}, // - - {0x3BB3, 0x03}, // - - {0x3BB4, 0xE0}, // - - {0x3BB5, 0x03}, // - - {0x3BB6, 0xE0}, // - - {0x3BB7, 0x03}, // - - {0x3BB8, 0xE0}, // - - {0x3BBA, 0xE0}, // - - {0x3BBC, 0xDA}, // - - {0x3BBE, 0x88}, // - - {0x3BC0, 0x44}, // - - {0x3BC2, 0x7B}, // - - {0x3BC4, 0xA2}, // - - {0x3BC8, 0xBD}, // - - {0x3BCA, 0xBD}, // - - {0x4004, 0xC0}, // TXCLKESC_FREQ[15:0] - {0x4005, 0x06}, // - {0x400C, 0x00}, // INCKSEL6 - {0x4018, 0x7F}, // TCLKPOST[15:0] - {0x401A, 0x37}, // TCLKPREPARE[15:0] - {0x401C, 0x37}, // TCLKTRAIL[15:0] - {0x401E, 0xF7}, // TCLKZERO[15:0] - {0x401F, 0x00}, // - {0x4020, 0x3F}, // THSPREPARE[15:0] - {0x4022, 0x6F}, // THSZERO[15:0] - {0x4024, 0x3F}, // THSTRAIL[15:0] - {0x4026, 0x5F}, // THSEXIT[15:0] - {0x4028, 0x2F}, // TLPX[15:0] - {0x4074, 0x01}, // INCKSEL7 [2:0] - {0xffff, 0x24}, - {0x3002, 0x00}, //Master mode start - {0xffff, 0x10}, - {0x3000, 0x00}, //Operating -}; -//3096x1758@30fps -const static I2C_ARRAY Sensor_5p3m_30fps_init_table_4lane_linear[] = -{ - /* - IMX415-AAQR Window cropping 3096x1758 CSI-2_4lane 27MHz AD:10bit Output:10bit 891Mbps Master Mode 30fps Integration Time 33.217ms - Tool ver : Ver6.0 - */ - {0x3000, 0x01}, //Standby - //{0xffff, 0x24}, //delay (ms) - {0x3002, 0x01}, //Master mode stop - //{0xffff, 0x10}, //delay (ms) - {0x3008, 0x5D}, // BCWAIT_TIME[9:0] - {0x300A, 0x42}, // CPWAIT_TIME[9:0] - {0x301C, 0x04}, // WINMODE[3:0] - {0x3028, 0x4C}, // HMAX[15:0] - {0x3029, 0x04}, // - {0x3031, 0x00}, // ADBIT[1:0] - {0x3032, 0x00}, // MDBIT - {0x3033, 0x05}, // SYS_MODE[3:0] - {0x3040, 0x80}, // PIX_HST[12:0] - {0x3041, 0x01}, // - {0x3043, 0x0C}, // - {0x3044, 0xB0}, // PIX_VST[12:0] //01b2 - {0x3045, 0x01}, // - {0x3046, 0xBC}, // PIX_VWIDTH[12:0] - {0x3047, 0x0D}, // - {0x3050, 0x08}, // SHR0[19:0] - {0x30C1, 0x00}, // XVS_DRV[1:0] - {0x3116, 0x23}, // INCKSEL2[7:0] - {0x3118, 0xC6}, // INCKSEL3[10:0] - {0x311A, 0xE7}, // INCKSEL4[10:0] - {0x311E, 0x23}, // INCKSEL5[7:0] - {0x32D4, 0x21}, // - - {0x32EC, 0xA1}, // - - {0x3452, 0x7F}, // - - {0x3453, 0x03}, // - - {0x358A, 0x04}, // - - {0x35A1, 0x02}, // - - {0x36BC, 0x0C}, // - - {0x36CC, 0x53}, // - - {0x36CD, 0x00}, // - - {0x36CE, 0x3C}, // - - {0x36D0, 0x8C}, // - - {0x36D1, 0x00}, // - - {0x36D2, 0x71}, // - - {0x36D4, 0x3C}, // - - {0x36D6, 0x53}, // - - {0x36D7, 0x00}, // - - {0x36D8, 0x71}, // - - {0x36DA, 0x8C}, // - - {0x36DB, 0x00}, // - - {0x3701, 0x00}, // ADBIT1[7:0] - {0x3724, 0x02}, // - - {0x3726, 0x02}, // - - {0x3732, 0x02}, // - - {0x3734, 0x03}, // - - {0x3736, 0x03}, // - - {0x3742, 0x03}, // - - {0x3862, 0xE0}, // - - {0x38CC, 0x30}, // - - {0x38CD, 0x2F}, // - - {0x395C, 0x0C}, // - - {0x3A42, 0xD1}, // - - {0x3A4C, 0x77}, // - - {0x3AE0, 0x02}, // - - {0x3AEC, 0x0C}, // - - {0x3B00, 0x2E}, // - - {0x3B06, 0x29}, // - - {0x3B98, 0x25}, // - - {0x3B99, 0x21}, // - - {0x3B9B, 0x13}, // - - {0x3B9C, 0x13}, // - - {0x3B9D, 0x13}, // - - {0x3B9E, 0x13}, // - - {0x3BA1, 0x00}, // - - {0x3BA2, 0x06}, // - - {0x3BA3, 0x0B}, // - - {0x3BA4, 0x10}, // - - {0x3BA5, 0x14}, // - - {0x3BA6, 0x18}, // - - {0x3BA7, 0x1A}, // - - {0x3BA8, 0x1A}, // - - {0x3BA9, 0x1A}, // - - {0x3BAC, 0xED}, // - - {0x3BAD, 0x01}, // - - {0x3BAE, 0xF6}, // - - {0x3BAF, 0x02}, // - - {0x3BB0, 0xA2}, // - - {0x3BB1, 0x03}, // - - {0x3BB2, 0xE0}, // - - {0x3BB3, 0x03}, // - - {0x3BB4, 0xE0}, // - - {0x3BB5, 0x03}, // - - {0x3BB6, 0xE0}, // - - {0x3BB7, 0x03}, // - - {0x3BB8, 0xE0}, // - - {0x3BBA, 0xE0}, // - - {0x3BBC, 0xDA}, // - - {0x3BBE, 0x88}, // - - {0x3BC0, 0x44}, // - - {0x3BC2, 0x7B}, // - - {0x3BC4, 0xA2}, // - - {0x3BC8, 0xBD}, // - - {0x3BCA, 0xBD}, // - - {0x4004, 0xC0}, // TXCLKESC_FREQ[15:0] - {0x4005, 0x06}, // - {0x400C, 0x00}, // INCKSEL6 - {0x4018, 0x7F}, // TCLKPOST[15:0] - {0x401A, 0x37}, // TCLKPREPARE[15:0] - {0x401C, 0x37}, // TCLKTRAIL[15:0] - {0x401E, 0xF7}, // TCLKZERO[15:0] - {0x401F, 0x00}, // - {0x4020, 0x3F}, // THSPREPARE[15:0] - {0x4022, 0x6F}, // THSZERO[15:0] - {0x4024, 0x3F}, // THSTRAIL[15:0] - {0x4026, 0x5F}, // THSEXIT[15:0] - {0x4028, 0x2F}, // TLPX[15:0] - {0x4074, 0x01}, // INCKSEL7 [2:0] - {0xffff, 0x24}, - {0x3002, 0x00}, //Master mode start - {0xffff, 0x10}, - {0x3000, 0x00}, //Operating -}; - -#if 0 -//5M25 594Mbps, 10bits, Mclk 27M -const static I2C_ARRAY Sensor_5m_25fps_init_table_4lane_linear[] = -{ - /* - IMX415-AAQR Window cropping 2592x1944 CSI-2_4lane 27MHz AD:10bit Output:10bit 594Mbps Master Mode 25fps Integration Time 39.86ms - Tool ver : Ver6.0 - */ - {0x3000, 0x01}, //Standby - //{0xffff, 0x24}, //delay (ms) - {0x3002, 0x01}, //Master mode stop - //{0xffff, 0x10}, //delay (ms) - {0x3008, 0x5D}, // BCWAIT_TIME[9:0] - {0x300A, 0x42}, // CPWAIT_TIME[9:0] - {0x301C, 0x04}, // WINMODE[3:0] - {0x3028, 0x28}, // HMAX[15:0] - {0x3029, 0x05}, // - {0x3031, 0x00}, // ADBIT[1:0] - {0x3032, 0x00}, // MDBIT - {0x3033, 0x07}, // SYS_MODE[3:0] - {0x3040, 0x7C}, // PIX_HST[12:0] - {0x3041, 0x02}, // - {0x3042, 0x20}, // PIX_HWIDTH[12:0] - {0x3043, 0x0A}, // - {0x3044, 0xF8}, // PIX_VST[12:0] //DA - {0x3045, 0x00}, // - {0x3046, 0x30}, // PIX_VWIDTH[12:0] - {0x3047, 0x0F}, // - {0x3050, 0x08}, // SHR0[19:0] - {0x30C0, 0x2A}, // XVSOUTSEL[1:0] XHSOUTSEL[3:2] - {0x30C1, 0x00}, // XVS_DRV[1:0] - {0x30CC, 0x00}, - {0x30CD, 0x00}, - {0x30CF, 0x00}, - {0x3116, 0x23}, // INCKSEL2[7:0] - {0x3118, 0x84}, // INCKSEL3[10:0] - {0x311A, 0xE7}, // INCKSEL4[10:0] - {0x311E, 0x23}, // INCKSEL5[7:0] - {0x32D4, 0x21}, // - - {0x32EC, 0xA1}, // - - {0x3452, 0x7F}, // - - {0x3453, 0x03}, // - - {0x358A, 0x04}, // - - {0x35A1, 0x02}, // - - {0x36BC, 0x0C}, // - - {0x36CC, 0x53}, // - - {0x36CD, 0x00}, // - - {0x36CE, 0x3C}, // - - {0x36D0, 0x8C}, // - - {0x36D1, 0x00}, // - - {0x36D2, 0x71}, // - - {0x36D4, 0x3C}, // - - {0x36D6, 0x53}, // - - {0x36D7, 0x00}, // - - {0x36D8, 0x71}, // - - {0x36DA, 0x8C}, // - - {0x36DB, 0x00}, // - - {0x3701, 0x00}, // ADBIT1[7:0] - {0x3724, 0x02}, // - - {0x3726, 0x02}, // - - {0x3732, 0x02}, // - - {0x3734, 0x03}, // - - {0x3736, 0x03}, // - - {0x3742, 0x03}, // - - {0x3862, 0xE0}, // - - {0x38CC, 0x30}, // - - {0x38CD, 0x2F}, // - - {0x395C, 0x0C}, // - - {0x3A42, 0xD1}, // - - {0x3A4C, 0x77}, // - - {0x3AE0, 0x02}, // - - {0x3AEC, 0x0C}, // - - {0x3B00, 0x2E}, // - - {0x3B06, 0x29}, // - - {0x3B98, 0x25}, // - - {0x3B99, 0x21}, // - - {0x3B9B, 0x13}, // - - {0x3B9C, 0x13}, // - - {0x3B9D, 0x13}, // - - {0x3B9E, 0x13}, // - - {0x3BA1, 0x00}, // - - {0x3BA2, 0x06}, // - - {0x3BA3, 0x0B}, // - - {0x3BA4, 0x10}, // - - {0x3BA5, 0x14}, // - - {0x3BA6, 0x18}, // - - {0x3BA7, 0x1A}, // - - {0x3BA8, 0x1A}, // - - {0x3BA9, 0x1A}, // - - {0x3BAC, 0xED}, // - - {0x3BAD, 0x01}, // - - {0x3BAE, 0xF6}, // - - {0x3BAF, 0x02}, // - - {0x3BB0, 0xA2}, // - - {0x3BB1, 0x03}, // - - {0x3BB2, 0xE0}, // - - {0x3BB3, 0x03}, // - - {0x3BB4, 0xE0}, // - - {0x3BB5, 0x03}, // - - {0x3BB6, 0xE0}, // - - {0x3BB7, 0x03}, // - - {0x3BB8, 0xE0}, // - - {0x3BBA, 0xE0}, // - - {0x3BBC, 0xDA}, // - - {0x3BBE, 0x88}, // - - {0x3BC0, 0x44}, // - - {0x3BC2, 0x7B}, // - - {0x3BC4, 0xA2}, // - - {0x3BC8, 0xBD}, // - - {0x3BCA, 0xBD}, // - - {0x4004, 0xC0}, // TXCLKESC_FREQ[15:0] - {0x4005, 0x06}, // - {0x400C, 0x00}, // INCKSEL6 - {0x4018, 0x67}, // TCLKPOST[15:0] - {0x401A, 0x27}, // TCLKPREPARE[15:0] - {0x401C, 0x27}, // TCLKTRAIL[15:0] - {0x401E, 0xB7}, // TCLKZERO[15:0] - {0x401F, 0x00}, // - {0x4020, 0x2F}, // THSPREPARE[15:0] - {0x4022, 0x4F}, // THSZERO[15:0] - {0x4024, 0x2F}, // THSTRAIL[15:0] - {0x4026, 0x47}, // THSEXIT[15:0] - {0x4028, 0x27}, // TLPX[15:0] - {0x4074, 0x01}, // INCKSEL7 [2:0] - {0xffff, 0x24}, - {0x3002, 0x00}, //Master mode start - {0xffff, 0x10}, - {0x3000, 0x00}, //Operating -}; -#endif -//5M30 891Mbps, 10bits, Mclk 27M -const static I2C_ARRAY Sensor_5m_30fps_init_table_4lane_linear[] = -{ - /* - IMX415-AAQR Window cropping 2616x1974 CSI-2_4lane 27MHz AD:10bit Output:10bit 891Mbps Master Mode 30fps Integration Time 33.217ms - Tool ver : Ver6.0 - */ - {0x3000, 0x01}, //Standby - //{0xffff, 0x24}, //delay (ms) - {0x3002, 0x01}, //Master mode stop - //{0xffff, 0x10}, //delay (ms) - {0x3008, 0x5D}, // BCWAIT_TIME[9:0] - {0x300A, 0x42}, // CPWAIT_TIME[9:0] - {0x301C, 0x04}, // WINMODE[3:0] - {0x3024, 0x60}, //VMAX LSB - {0x3025, 0x08}, //VMAX MSB 8CAh: 2250 - {0x3026, 0x00}, //VMAX MSB [0:3] - {0x3028, 0x82}, // HMAX[15:0] - {0x3029, 0x04}, // - {0x3031, 0x00}, // ADBIT[1:0] - {0x3032, 0x00}, // MDBIT - {0x3033, 0x05}, // SYS_MODE[3:0] - {0x3040, 0x70}, // PIX_HST[12:0] - {0x3041, 0x02}, // - {0x3042, 0x38}, // PIX_HWIDTH[12:0] - {0x3043, 0x0A}, // - {0x3044, 0xD8}, // PIX_VST[12:0] //DA - {0x3045, 0x00}, // - {0x3046, 0x6C}, // PIX_VWIDTH[12:0] - {0x3047, 0x0F}, // - {0x3050, 0x08}, // SHR0[19:0] - {0x30C1, 0x00}, // XVS_DRV[1:0] - {0x3116, 0x23}, // INCKSEL2[7:0] - {0x3118, 0xC6}, // INCKSEL3[10:0] - {0x311A, 0xE7}, // INCKSEL4[10:0] - {0x311E, 0x23}, // INCKSEL5[7:0] - {0x32D4, 0x21}, // - - {0x32EC, 0xA1}, // - - {0x3452, 0x7F}, // - - {0x3453, 0x03}, // - - {0x358A, 0x04}, // - - {0x35A1, 0x02}, // - - {0x36BC, 0x0C}, // - - {0x36CC, 0x53}, // - - {0x36CD, 0x00}, // - - {0x36CE, 0x3C}, // - - {0x36D0, 0x8C}, // - - {0x36D1, 0x00}, // - - {0x36D2, 0x71}, // - - {0x36D4, 0x3C}, // - - {0x36D6, 0x53}, // - - {0x36D7, 0x00}, // - - {0x36D8, 0x71}, // - - {0x36DA, 0x8C}, // - - {0x36DB, 0x00}, // - - {0x3701, 0x00}, // ADBIT1[7:0] - {0x3724, 0x02}, // - - {0x3726, 0x02}, // - - {0x3732, 0x02}, // - - {0x3734, 0x03}, // - - {0x3736, 0x03}, // - - {0x3742, 0x03}, // - - {0x3862, 0xE0}, // - - {0x38CC, 0x30}, // - - {0x38CD, 0x2F}, // - - {0x395C, 0x0C}, // - - {0x3A42, 0xD1}, // - - {0x3A4C, 0x77}, // - - {0x3AE0, 0x02}, // - - {0x3AEC, 0x0C}, // - - {0x3B00, 0x2E}, // - - {0x3B06, 0x29}, // - - {0x3B98, 0x25}, // - - {0x3B99, 0x21}, // - - {0x3B9B, 0x13}, // - - {0x3B9C, 0x13}, // - - {0x3B9D, 0x13}, // - - {0x3B9E, 0x13}, // - - {0x3BA1, 0x00}, // - - {0x3BA2, 0x06}, // - - {0x3BA3, 0x0B}, // - - {0x3BA4, 0x10}, // - - {0x3BA5, 0x14}, // - - {0x3BA6, 0x18}, // - - {0x3BA7, 0x1A}, // - - {0x3BA8, 0x1A}, // - - {0x3BA9, 0x1A}, // - - {0x3BAC, 0xED}, // - - {0x3BAD, 0x01}, // - - {0x3BAE, 0xF6}, // - - {0x3BAF, 0x02}, // - - {0x3BB0, 0xA2}, // - - {0x3BB1, 0x03}, // - - {0x3BB2, 0xE0}, // - - {0x3BB3, 0x03}, // - - {0x3BB4, 0xE0}, // - - {0x3BB5, 0x03}, // - - {0x3BB6, 0xE0}, // - - {0x3BB7, 0x03}, // - - {0x3BB8, 0xE0}, // - - {0x3BBA, 0xE0}, // - - {0x3BBC, 0xDA}, // - - {0x3BBE, 0x88}, // - - {0x3BC0, 0x44}, // - - {0x3BC2, 0x7B}, // - - {0x3BC4, 0xA2}, // - - {0x3BC8, 0xBD}, // - - {0x3BCA, 0xBD}, // - - {0x4004, 0xC0}, // TXCLKESC_FREQ[15:0] - {0x4005, 0x06}, // - {0x400C, 0x00}, // INCKSEL6 - {0x4018, 0x7F}, // TCLKPOST[15:0] - {0x401A, 0x37}, // TCLKPREPARE[15:0] - {0x401C, 0x37}, // TCLKTRAIL[15:0] - {0x401E, 0xF7}, // TCLKZERO[15:0] - {0x401F, 0x00}, // - {0x4020, 0x3F}, // THSPREPARE[15:0] - {0x4022, 0x6F}, // THSZERO[15:0] - {0x4024, 0x3F}, // THSTRAIL[15:0] - {0x4026, 0x5F}, // THSEXIT[15:0] - {0x4028, 0x2F}, // TLPX[15:0] - {0x4074, 0x01}, // INCKSEL7 [2:0] - {0xffff, 0x24}, - {0x3002, 0x00}, //Master mode start - {0xffff, 0x10}, - {0x3000, 0x00}, //Operating -}; -//4p8M30 891Mbps, 10bits, Mclk 27M -const static I2C_ARRAY Sensor_4p8m_30fps_init_table_4lane_linear[] = -{ - /* - IMX415-AAQR Window cropping 2976x1686 CSI-2_4lane 27MHz AD:10bit Output:10bit 891Mbps Master Mode 30fps Integration Time 33.217ms - Tool ver : Ver6.0 - */ - {0x3000, 0x01}, //Standby - //{0xffff, 0x24}, //delay (ms) - {0x3002, 0x01}, //Master mode stop - //{0xffff, 0x10}, //delay (ms) - {0x3008, 0x5D}, // BCWAIT_TIME[9:0] - {0x300A, 0x42}, // CPWAIT_TIME[9:0] - {0x301C, 0x04}, // WINMODE[3:0] - {0x3028, 0x4C}, // HMAX[15:0] - {0x3029, 0x04}, // - {0x3031, 0x00}, // ADBIT[1:0] - {0x3032, 0x00}, // MDBIT - {0x3033, 0x05}, // SYS_MODE[3:0] - {0x3040, 0xBC}, // PIX_HST[12:0] - {0x3041, 0x01}, // - {0x3042, 0xA0}, // PIX_HWIDTH[12:0] - {0x3043, 0x0B}, // - {0x3044, 0xF8}, // PIX_VST[12:0] //FA - {0x3045, 0x01}, // - {0x3046, 0x2C}, // PIX_VWIDTH[12:0] - {0x3047, 0x0D}, // - {0x3050, 0x08}, // SHR0[19:0] - {0x30C1, 0x00}, // XVS_DRV[1:0] - {0x3116, 0x23}, // INCKSEL2[7:0] - {0x3118, 0xC6}, // INCKSEL3[10:0] - {0x311A, 0xE7}, // INCKSEL4[10:0] - {0x311E, 0x23}, // INCKSEL5[7:0] - {0x32D4, 0x21}, // - - {0x32EC, 0xA1}, // - - {0x3452, 0x7F}, // - - {0x3453, 0x03}, // - - {0x358A, 0x04}, // - - {0x35A1, 0x02}, // - - {0x36BC, 0x0C}, // - - {0x36CC, 0x53}, // - - {0x36CD, 0x00}, // - - {0x36CE, 0x3C}, // - - {0x36D0, 0x8C}, // - - {0x36D1, 0x00}, // - - {0x36D2, 0x71}, // - - {0x36D4, 0x3C}, // - - {0x36D6, 0x53}, // - - {0x36D7, 0x00}, // - - {0x36D8, 0x71}, // - - {0x36DA, 0x8C}, // - - {0x36DB, 0x00}, // - - {0x3701, 0x00}, // ADBIT1[7:0] - {0x3724, 0x02}, // - - {0x3726, 0x02}, // - - {0x3732, 0x02}, // - - {0x3734, 0x03}, // - - {0x3736, 0x03}, // - - {0x3742, 0x03}, // - - {0x3862, 0xE0}, // - - {0x38CC, 0x30}, // - - {0x38CD, 0x2F}, // - - {0x395C, 0x0C}, // - - {0x3A42, 0xD1}, // - - {0x3A4C, 0x77}, // - - {0x3AE0, 0x02}, // - - {0x3AEC, 0x0C}, // - - {0x3B00, 0x2E}, // - - {0x3B06, 0x29}, // - - {0x3B98, 0x25}, // - - {0x3B99, 0x21}, // - - {0x3B9B, 0x13}, // - - {0x3B9C, 0x13}, // - - {0x3B9D, 0x13}, // - - {0x3B9E, 0x13}, // - - {0x3BA1, 0x00}, // - - {0x3BA2, 0x06}, // - - {0x3BA3, 0x0B}, // - - {0x3BA4, 0x10}, // - - {0x3BA5, 0x14}, // - - {0x3BA6, 0x18}, // - - {0x3BA7, 0x1A}, // - - {0x3BA8, 0x1A}, // - - {0x3BA9, 0x1A}, // - - {0x3BAC, 0xED}, // - - {0x3BAD, 0x01}, // - - {0x3BAE, 0xF6}, // - - {0x3BAF, 0x02}, // - - {0x3BB0, 0xA2}, // - - {0x3BB1, 0x03}, // - - {0x3BB2, 0xE0}, // - - {0x3BB3, 0x03}, // - - {0x3BB4, 0xE0}, // - - {0x3BB5, 0x03}, // - - {0x3BB6, 0xE0}, // - - {0x3BB7, 0x03}, // - - {0x3BB8, 0xE0}, // - - {0x3BBA, 0xE0}, // - - {0x3BBC, 0xDA}, // - - {0x3BBE, 0x88}, // - - {0x3BC0, 0x44}, // - - {0x3BC2, 0x7B}, // - - {0x3BC4, 0xA2}, // - - {0x3BC8, 0xBD}, // - - {0x3BCA, 0xBD}, // - - {0x4004, 0xC0}, // TXCLKESC_FREQ[15:0] - {0x4005, 0x06}, // - {0x400C, 0x00}, // INCKSEL6 - {0x4018, 0x7F}, // TCLKPOST[15:0] - {0x401A, 0x37}, // TCLKPREPARE[15:0] - {0x401C, 0x37}, // TCLKTRAIL[15:0] - {0x401E, 0xF7}, // TCLKZERO[15:0] - {0x401F, 0x00}, // - {0x4020, 0x3F}, // THSPREPARE[15:0] - {0x4022, 0x6F}, // THSZERO[15:0] - {0x4024, 0x3F}, // THSTRAIL[15:0] - {0x4026, 0x5F}, // THSEXIT[15:0] - {0x4028, 0x2F}, // TLPX[15:0] - {0x4074, 0x01}, // INCKSEL7 [2:0] - {0xffff, 0x24}, - {0x3002, 0x00}, //Master mode start - {0xffff, 0x10}, - {0x3000, 0x00}, //Operating -}; -//2592x1470@30fps -const static I2C_ARRAY Sensor_3p6m_30fps_init_table_4lane_linear[] = -{ - /* - IMX415-AAQR Window cropping 2592x1470 CSI-2_4lane 27MHz AD:10bit Output:10bit 891Mbps Master Mode 30fps Integration Time 33.217ms - Tool ver : Ver6.0 - */ - {0x3000, 0x01}, //Standby - //{0xffff, 0x24}, //delay (ms) - {0x3002, 0x01}, //Master mode stop - //{0xffff, 0x10}, //delay (ms) - {0x3008, 0x5D}, // BCWAIT_TIME[9:0] - {0x300A, 0x42}, // CPWAIT_TIME[9:0] - {0x301C, 0x04}, // WINMODE[3:0] - {0x3028, 0x4C}, // HMAX[15:0] - {0x3029, 0x04}, // - {0x3031, 0x00}, // ADBIT[1:0] - {0x3032, 0x00}, // MDBIT - {0x3033, 0x05}, // SYS_MODE[3:0] - {0x3040, 0x7C}, // PIX_HST[12:0] - {0x3041, 0x02}, // - {0x3042, 0x20}, // PIX_HWIDTH[12:0] - {0x3043, 0x0A}, // - {0x3044, 0xD0}, // PIX_VST[12:0] //D2 - {0x3045, 0x02}, // - {0x3046, 0x7C}, // PIX_VWIDTH[12:0] - {0x3047, 0x0B}, // - {0x3050, 0x08}, // SHR0[19:0] - {0x30C1, 0x00}, // XVS_DRV[1:0] - {0x3116, 0x23}, // INCKSEL2[7:0] - {0x3118, 0xC6}, // INCKSEL3[10:0] - {0x311A, 0xE7}, // INCKSEL4[10:0] - {0x311E, 0x23}, // INCKSEL5[7:0] - {0x32D4, 0x21}, // - - {0x32EC, 0xA1}, // - - {0x3452, 0x7F}, // - - {0x3453, 0x03}, // - - {0x358A, 0x04}, // - - {0x35A1, 0x02}, // - - {0x36BC, 0x0C}, // - - {0x36CC, 0x53}, // - - {0x36CD, 0x00}, // - - {0x36CE, 0x3C}, // - - {0x36D0, 0x8C}, // - - {0x36D1, 0x00}, // - - {0x36D2, 0x71}, // - - {0x36D4, 0x3C}, // - - {0x36D6, 0x53}, // - - {0x36D7, 0x00}, // - - {0x36D8, 0x71}, // - - {0x36DA, 0x8C}, // - - {0x36DB, 0x00}, // - - {0x3701, 0x00}, // ADBIT1[7:0] - {0x3724, 0x02}, // - - {0x3726, 0x02}, // - - {0x3732, 0x02}, // - - {0x3734, 0x03}, // - - {0x3736, 0x03}, // - - {0x3742, 0x03}, // - - {0x3862, 0xE0}, // - - {0x38CC, 0x30}, // - - {0x38CD, 0x2F}, // - - {0x395C, 0x0C}, // - - {0x3A42, 0xD1}, // - - {0x3A4C, 0x77}, // - - {0x3AE0, 0x02}, // - - {0x3AEC, 0x0C}, // - - {0x3B00, 0x2E}, // - - {0x3B06, 0x29}, // - - {0x3B98, 0x25}, // - - {0x3B99, 0x21}, // - - {0x3B9B, 0x13}, // - - {0x3B9C, 0x13}, // - - {0x3B9D, 0x13}, // - - {0x3B9E, 0x13}, // - - {0x3BA1, 0x00}, // - - {0x3BA2, 0x06}, // - - {0x3BA3, 0x0B}, // - - {0x3BA4, 0x10}, // - - {0x3BA5, 0x14}, // - - {0x3BA6, 0x18}, // - - {0x3BA7, 0x1A}, // - - {0x3BA8, 0x1A}, // - - {0x3BA9, 0x1A}, // - - {0x3BAC, 0xED}, // - - {0x3BAD, 0x01}, // - - {0x3BAE, 0xF6}, // - - {0x3BAF, 0x02}, // - - {0x3BB0, 0xA2}, // - - {0x3BB1, 0x03}, // - - {0x3BB2, 0xE0}, // - - {0x3BB3, 0x03}, // - - {0x3BB4, 0xE0}, // - - {0x3BB5, 0x03}, // - - {0x3BB6, 0xE0}, // - - {0x3BB7, 0x03}, // - - {0x3BB8, 0xE0}, // - - {0x3BBA, 0xE0}, // - - {0x3BBC, 0xDA}, // - - {0x3BBE, 0x88}, // - - {0x3BC0, 0x44}, // - - {0x3BC2, 0x7B}, // - - {0x3BC4, 0xA2}, // - - {0x3BC8, 0xBD}, // - - {0x3BCA, 0xBD}, // - - {0x4004, 0xC0}, // TXCLKESC_FREQ[15:0] - {0x4005, 0x06}, // - {0x400C, 0x00}, // INCKSEL6 - {0x4018, 0x7F}, // TCLKPOST[15:0] - {0x401A, 0x37}, // TCLKPREPARE[15:0] - {0x401C, 0x37}, // TCLKTRAIL[15:0] - {0x401E, 0xF7}, // TCLKZERO[15:0] - {0x401F, 0x00}, // - {0x4020, 0x3F}, // THSPREPARE[15:0] - {0x4022, 0x6F}, // THSZERO[15:0] - {0x4024, 0x3F}, // THSTRAIL[15:0] - {0x4026, 0x5F}, // THSEXIT[15:0] - {0x4028, 0x2F}, // TLPX[15:0] - {0x4074, 0x01}, // INCKSEL7 [2:0] - {0xffff, 0x24}, - {0x3002, 0x00}, //Master mode start - {0xffff, 0x10}, - {0x3000, 0x00}, //Operating -}; -//8M30 891Mbps, 10bits, Mclk 27M -const static I2C_ARRAY Sensor_8m_30fps_init_table_4lane_linear[] = -{ - /* - IMX415-AAQRAll-pixel scan - CSI-2_4lane - 27MHz - AD:10bit - Output:10bit - 891Mbps - Master Mode 30fps - Integration Time33.217ms - */ - - {0x3000, 0x01}, //Standby - //{0xffff, 0x24}, //delay (ms) - {0x3002, 0x01}, //Master mode stop - //{0xffff, 0x10}, //delay (ms) - {0x3008,0x5D}, // BCWAIT_TIME[9:0] - {0x300A,0x42}, // CPWAIT_TIME[9:0] - {0x3024,0xCA}, // VMAX[19:0] - {0x3025,0x08}, // - {0x3028,0x4C}, // HMAX[15:0] - {0x3029,0x04}, // - {0x3031,0x00}, // ADBIT[1:0] - {0x3032,0x00}, // MDBIT - {0x3033,0x05}, // SYS_MODE[3:0] - {0x3050,0x08}, // SHR0[19:0] - {0x30C1,0x00}, // XVS_DRV[1:0] - {0x3116,0x23}, // INCKSEL2[7:0] - {0x3118,0xC6}, // INCKSEL3[10:0] - {0x311A,0xE7}, // INCKSEL4[10:0] - {0x311E,0x23}, // INCKSEL5[7:0] - {0x32D4,0x21}, // - - {0x32EC,0xA1}, // - - {0x3452,0x7F}, // - - {0x3453,0x03}, // - - {0x358A,0x04}, // - - {0x35A1,0x02}, // - - {0x36BC,0x0C}, // - - {0x36CC,0x53}, // - - {0x36CD,0x00}, // - - {0x36CE,0x3C}, // - - {0x36D0,0x8C}, // - - {0x36D1,0x00}, // - - {0x36D2,0x71}, // - - {0x36D4,0x3C}, // - - {0x36D6,0x53}, // - - {0x36D7,0x00}, // - - {0x36D8,0x71}, // - - {0x36DA,0x8C}, // - - {0x36DB,0x00}, // - - {0x3701,0x00}, // ADBIT1[7:0] - {0x3724,0x02}, // - - {0x3726,0x02}, // - - {0x3732,0x02}, // - - {0x3734,0x03}, // - - {0x3736,0x03}, // - - {0x3742,0x03}, // - - {0x3862,0xE0}, // - - {0x38CC,0x30}, // - - {0x38CD,0x2F}, // - - {0x395C,0x0C}, // - - - {0x3A42,0xD1}, // - - {0x3A4C,0x77}, // - - {0x3AE0,0x02}, // - - {0x3AEC,0x0C}, // - - {0x3B00,0x2E}, // - - {0x3B06,0x29}, // - - {0x3B98,0x25}, // - - {0x3B99,0x21}, // - - {0x3B9B,0x13}, // - - {0x3B9C,0x13}, // - - {0x3B9D,0x13}, // - - {0x3B9E,0x13}, // - - {0x3BA1,0x00}, // - - {0x3BA2,0x06}, // - - {0x3BA3,0x0B}, // - - {0x3BA4,0x10}, // - - {0x3BA5,0x14}, // - - {0x3BA6,0x18}, // - - {0x3BA7,0x1A}, // - - {0x3BA8,0x1A}, // - - {0x3BA9,0x1A}, // - - {0x3BAC,0xED}, // - - {0x3BAD,0x01}, // - - {0x3BAE,0xF6}, // - - {0x3BAF,0x02}, // - - {0x3BB0,0xA2}, // - - {0x3BB1,0x03}, // - - {0x3BB2,0xE0}, // - - {0x3BB3,0x03}, // - - {0x3BB4,0xE0}, // - - {0x3BB5,0x03}, // - - {0x3BB6,0xE0}, // - - {0x3BB7,0x03}, // - - {0x3BB8,0xE0}, // - - {0x3BBA,0xE0}, // - - {0x3BBC,0xDA}, // - - {0x3BBE,0x88}, // - - {0x3BC0,0x44}, // - - {0x3BC2,0x7B}, // - - {0x3BC4,0xA2}, // - - {0x3BC8,0xBD}, // - - {0x3BCA,0xBD}, // - - {0x4004,0xC0}, // TXCLKESC_FREQ[15:0] - {0x4005,0x06}, // - {0x400C,0x00}, // INCKSEL6 - {0x4018,0x7F}, // TCLKPOST[15:0] - {0x401A,0x37}, // TCLKPREPARE[15:0] - {0x401C,0x37}, // TCLKTRAIL[15:0] - {0x401E,0xF7}, // TCLKZERO[15:0] - {0x401F,0x00}, // - {0x4020,0x3F}, // THSPREPARE[15:0] - {0x4022,0x6F}, // THSZERO[15:0] - {0x4024,0x3F}, // THSTRAIL[15:0] - {0x4026,0x5F}, // THSEXIT[15:0] - {0x4028,0x2F}, // TLPX[15:0] - {0x4074,0x01}, // INCKSEL7 [2:0] - {0xffff, 0x24}, - {0x3002, 0x00}, //Master mode start - {0xffff, 0x10}, - {0x3000, 0x00}, //Operating -}; - -//1920x1080@60fps -const static I2C_ARRAY Sensor_2m_60fps_init_table_4lane_linear[] = -{ -/* -IMX415-AAQR 2/2-line binning CSI-2_4lane 27MHz AD:10bit Output:12bit 891Mbps Master Mode 59.998fps Integration Time 16.61ms -Tool ver : Ver6.0 -*/ - {0x3000, 0x01}, //Standby - //{0xffff, 0x24}, //delay (ms) - {0x3002, 0x01}, //Master mode stop - //{0xffff, 0x10}, //delay (ms) - {0x3008, 0x5D}, // BCWAIT_TIME[9:0] - {0x300A, 0x42}, // CPWAIT_TIME[9:0] - {0x3020, 0x01}, // HADD - {0x3021, 0x01}, // VADD - {0x3022, 0x01}, // ADDMODE[1:0] - {0x3024, 0xF8}, // VMAX[19:0] - {0x3028, 0x1B}, // HMAX[15:0] - {0x3031, 0x00}, // ADBIT[1:0] - {0x3033, 0x05}, // SYS_MODE[3:0] - {0x3050, 0x08}, // SHR0[19:0] - {0x30C1, 0x00}, // XVS_DRV[1:0] - {0x30D9, 0x02}, // DIG_CLP_VSTART[4:0] - {0x30DA, 0x01}, // DIG_CLP_VNUM[1:0] - {0x3116, 0x23}, // INCKSEL2[7:0] - {0x3118, 0xC6}, // INCKSEL3[10:0] - {0x311A, 0xE7}, // INCKSEL4[10:0] - {0x311E, 0x23}, // INCKSEL5[7:0] - {0x32D4, 0x21}, // - - {0x32EC, 0xA1}, // - - {0x3452, 0x7F}, // - - {0x3453, 0x03}, // - - {0x358A, 0x04}, // - - {0x35A1, 0x02}, // - - {0x36BC, 0x0C}, // - - {0x36CC, 0x53}, // - - {0x36CD, 0x00}, // - - {0x36CE, 0x3C}, // - - {0x36D0, 0x8C}, // - - {0x36D1, 0x00}, // - - {0x36D2, 0x71}, // - - {0x36D4, 0x3C}, // - - {0x36D6, 0x53}, // - - {0x36D7, 0x00}, // - - {0x36D8, 0x71}, // - - {0x36DA, 0x8C}, // - - {0x36DB, 0x00}, // - - {0x3701, 0x00}, // ADBIT1[7:0] - {0x3724, 0x02}, // - - {0x3726, 0x02}, // - - {0x3732, 0x02}, // - - {0x3734, 0x03}, // - - {0x3736, 0x03}, // - - {0x3742, 0x03}, // - - {0x3862, 0xE0}, // - - {0x38CC, 0x30}, // - - {0x38CD, 0x2F}, // - - {0x395C, 0x0C}, // - - {0x3A42, 0xD1}, // - - {0x3A4C, 0x77}, // - - {0x3AE0, 0x02}, // - - {0x3AEC, 0x0C}, // - - {0x3B00, 0x2E}, // - - {0x3B06, 0x29}, // - - {0x3B98, 0x25}, // - - {0x3B99, 0x21}, // - - {0x3B9B, 0x13}, // - - {0x3B9C, 0x13}, // - - {0x3B9D, 0x13}, // - - {0x3B9E, 0x13}, // - - {0x3BA1, 0x00}, // - - {0x3BA2, 0x06}, // - - {0x3BA3, 0x0B}, // - - {0x3BA4, 0x10}, // - - {0x3BA5, 0x14}, // - - {0x3BA6, 0x18}, // - - {0x3BA7, 0x1A}, // - - {0x3BA8, 0x1A}, // - - {0x3BA9, 0x1A}, // - - {0x3BAC, 0xED}, // - - {0x3BAD, 0x01}, // - - {0x3BAE, 0xF6}, // - - {0x3BAF, 0x02}, // - - {0x3BB0, 0xA2}, // - - {0x3BB1, 0x03}, // - - {0x3BB2, 0xE0}, // - - {0x3BB3, 0x03}, // - - {0x3BB4, 0xE0}, // - - {0x3BB5, 0x03}, // - - {0x3BB6, 0xE0}, // - - {0x3BB7, 0x03}, // - - {0x3BB8, 0xE0}, // - - {0x3BBA, 0xE0}, // - - {0x3BBC, 0xDA}, // - - {0x3BBE, 0x88}, // - - {0x3BC0, 0x44}, // - - {0x3BC2, 0x7B}, // - - {0x3BC4, 0xA2}, // - - {0x3BC8, 0xBD}, // - - {0x3BCA, 0xBD}, // - - {0x4004, 0xC0}, // TXCLKESC_FREQ[15:0] - {0x4005, 0x06}, // - {0x400C, 0x00}, // INCKSEL6 - {0x4018, 0x7F}, // TCLKPOST[15:0] - {0x401A, 0x37}, // TCLKPREPARE[15:0] - {0x401C, 0x37}, // TCLKTRAIL[15:0] - {0x401E, 0xF7}, // TCLKZERO[15:0] - {0x401F, 0x00}, // - {0x4020, 0x3F}, // THSPREPARE[15:0] - {0x4022, 0x6F}, // THSZERO[15:0] - {0x4024, 0x3F}, // THSTRAIL[15:0] - {0x4026, 0x5F}, // THSEXIT[15:0] - {0x4028, 0x2F}, // TLPX[15:0] - {0x4074, 0x01}, // INCKSEL7 [2:0] - {0xffff, 0x24}, - {0x3002, 0x00}, //Master mode start - {0xffff, 0x10}, - {0x3000, 0x00}, //Operating -}; - -// 1280x720@120fps -const static I2C_ARRAY Sensor_1m_120fps_init_table_4lane_linear[] = -{ -/* -IMX415-AAQR 2/2-line binning & Window cropping 2568x1440 CSI-2_4lane 24MHz AD:10bit Output:12bit 1440Mbps Master Mode 119.988fps Integration Time 8ms Gain:6dB -Ver8.0 -*/ - {0x3000, 0x01}, // Standby - {0x3002, 0x01}, // Master mode stop - {0x3008, 0x54}, // BCWAIT_TIME[9:0] - {0x300A, 0x3B}, // CPWAIT_TIME[9:0] - {0x301C, 0x04}, // WINMODE[3:0] - {0x3020, 0x01}, // HADD - {0x3021, 0x01}, // VADD - {0x3022, 0x01}, // ADDMODE[1:0] - {0x3024, 0x6C}, // VMAX[19:0] - {0x3025, 0x06}, // - {0x3028, 0x6D}, // HMAX[15:0] - {0x3029, 0x01}, // - {0x3031, 0x00}, // ADBIT[1:0] - {0x3033, 0x08}, // SYS_MODE[3:0] - {0x3040, 0x88}, // PIX_HST[12:0] - {0x3041, 0x02}, // - {0x3042, 0x08}, // PIX_HWIDTH[12:0] - {0x3043, 0x0A}, // - {0x3044, 0xF0}, // PIX_VST[12:0] - {0x3045, 0x02}, // - {0x3046, 0x40}, // PIX_VWIDTH[12:0] - {0x3047, 0x0B}, // - {0x3050, 0x42}, // SHR0[19:0] - {0x3090, 0x14}, // GAIN_PCG_0[8:0] - {0x30C1, 0x00}, // XVS_DRV[1:0] - {0x30D9, 0x02}, // DIG_CLP_VSTART[4:0] - {0x30DA, 0x01}, // DIG_CLP_VNUM[1:0] - {0x3116, 0x23}, // INCKSEL2[7:0] - {0x3118, 0xB4}, // INCKSEL3[10:0] - {0x311A, 0xFC}, // INCKSEL4[10:0] - {0x311E, 0x23}, // INCKSEL5[7:0] - {0x32D4, 0x21}, // - - {0x32EC, 0xA1}, // - - {0x344C, 0x2B}, // - - {0x344D, 0x01}, // - - {0x344E, 0xED}, // - - {0x344F, 0x01}, // - - {0x3450, 0xF6}, // - - {0x3451, 0x02}, // - - {0x3452, 0x7F}, // - - {0x3453, 0x03}, // - - {0x358A, 0x04}, // - - {0x35A1, 0x02}, // - - {0x35EC, 0x27}, // - - {0x35EE, 0x8D}, // - - {0x35F0, 0x8D}, // - - {0x35F2, 0x29}, // - - {0x36BC, 0x0C}, // - - {0x36CC, 0x53}, // - - {0x36CD, 0x00}, // - - {0x36CE, 0x3C}, // - - {0x36D0, 0x8C}, // - - {0x36D1, 0x00}, // - - {0x36D2, 0x71}, // - - {0x36D4, 0x3C}, // - - {0x36D6, 0x53}, // - - {0x36D7, 0x00}, // - - {0x36D8, 0x71}, // - - {0x36DA, 0x8C}, // - - {0x36DB, 0x00}, // - - {0x3701, 0x00}, // ADBIT1[7:0] - {0x3720, 0x00}, // - - {0x3724, 0x02}, // - - {0x3726, 0x02}, // - - {0x3732, 0x02}, // - - {0x3734, 0x03}, // - - {0x3736, 0x03}, // - - {0x3742, 0x03}, // - - {0x3862, 0xE0}, // - - {0x38CC, 0x30}, // - - {0x38CD, 0x2F}, // - - {0x395C, 0x0C}, // - - {0x39A4, 0x07}, // - - {0x39A8, 0x32}, // - - {0x39AA, 0x32}, // - - {0x39AC, 0x32}, // - - {0x39AE, 0x32}, // - - {0x39B0, 0x32}, // - - {0x39B2, 0x2F}, // - - {0x39B4, 0x2D}, // - - {0x39B6, 0x28}, // - - {0x39B8, 0x30}, // - - {0x39BA, 0x30}, // - - {0x39BC, 0x30}, // - - {0x39BE, 0x30}, // - - {0x39C0, 0x30}, // - - {0x39C2, 0x2E}, // - - {0x39C4, 0x2B}, // - - {0x39C6, 0x25}, // - - {0x3A42, 0xD1}, // - - {0x3A4C, 0x77}, // - - {0x3AE0, 0x02}, // - - {0x3AEC, 0x0C}, // - - {0x3B00, 0x2E}, // - - {0x3B06, 0x29}, // - - {0x3B98, 0x25}, // - - {0x3B99, 0x21}, // - - {0x3B9B, 0x13}, // - - {0x3B9C, 0x13}, // - - {0x3B9D, 0x13}, // - - {0x3B9E, 0x13}, // - - {0x3BA1, 0x00}, // - - {0x3BA2, 0x06}, // - - {0x3BA3, 0x0B}, // - - {0x3BA4, 0x10}, // - - {0x3BA5, 0x14}, // - - {0x3BA6, 0x18}, // - - {0x3BA7, 0x1A}, // - - {0x3BA8, 0x1A}, // - - {0x3BA9, 0x1A}, // - - {0x3BAC, 0xED}, // - - {0x3BAD, 0x01}, // - - {0x3BAE, 0xF6}, // - - {0x3BAF, 0x02}, // - - {0x3BB0, 0xA2}, // - - {0x3BB1, 0x03}, // - - {0x3BB2, 0xE0}, // - - {0x3BB3, 0x03}, // - - {0x3BB4, 0xE0}, // - - {0x3BB5, 0x03}, // - - {0x3BB6, 0xE0}, // - - {0x3BB7, 0x03}, // - - {0x3BB8, 0xE0}, // - - {0x3BBA, 0xE0}, // - - {0x3BBC, 0xDA}, // - - {0x3BBE, 0x88}, // - - {0x3BC0, 0x44}, // - - {0x3BC2, 0x7B}, // - - {0x3BC4, 0xA2}, // - - {0x3BC8, 0xBD}, // - - {0x3BCA, 0xBD}, // - - {0x4004, 0x00}, // TXCLKESC_FREQ[15:0] - {0x4005, 0x06}, // - {0x4018, 0x9F}, // TCLKPOST[15:0] - {0x401A, 0x57}, // TCLKPREPARE[15:0] - {0x401C, 0x57}, // TCLKTRAIL[15:0] - {0x401E, 0x87}, // TCLKZERO[15:0] - {0x4020, 0x5F}, // THSPREPARE[15:0] - {0x4022, 0xA7}, // THSZERO[15:0] - {0x4024, 0x5F}, // THSTRAIL[15:0] - {0x4026, 0x97}, // THSEXIT[15:0] - {0x4028, 0x4F}, // TLPX[15:0] - {0xffff, 0x10}, - {0x3000, 0x00}, // Operating - {0xffff, 0x10}, - {0x3002, 0x00}, // Master mode start - {0x3260, 0x00}, // Gain_Pgc_Fidmd -}; - -#if 0 -// 1280x720@135fps -const static I2C_ARRAY Sensor_1m_135fps_init_table_4lane_linear[] = -{ -/* -IMX415-AAQR 2/2-line binning & Window cropping 2568x1440 CSI-2_4lane 37.125Mhz AD:10bit Output:12bit 1485Mbps Master Mode 134.987fps Integration Time 0.999ms Gain:6dB -Ver8.0 -*/ - {0x3000, 0x01}, // Standby - {0x3002, 0x01}, // Master mode stop - {0x3008, 0x7F}, // BCWAIT_TIME[9:0] - {0x300A, 0x5B}, // CPWAIT_TIME[9:0] - {0x301C, 0x04}, // WINMODE[3:0] - {0x3020, 0x01}, // HADD - {0x3021, 0x01}, // VADD - {0x3022, 0x01}, // ADDMODE[1:0] - {0x3024, 0xE3}, // VMAX[19:0] - {0x3025, 0x05}, // - {0x3028, 0x6D}, // HMAX[15:0] - {0x3029, 0x01}, // - {0x3031, 0x00}, // ADBIT[1:0] - {0x3033, 0x08}, // SYS_MODE[3:0] - {0x3040, 0x88}, // PIX_HST[12:0] - {0x3041, 0x02}, // - {0x3042, 0x08}, // PIX_HWIDTH[12:0] - {0x3043, 0x0A}, // - {0x3044, 0xF0}, // PIX_VST[12:0] - {0x3045, 0x02}, // - {0x3046, 0x40}, // PIX_VWIDTH[12:0] - {0x3047, 0x0B}, // - {0x3050, 0x18}, // SHR0[19:0] - {0x3051, 0x05}, // - {0x3090, 0x14}, // GAIN_PCG_0[8:0] - {0x30C1, 0x00}, // XVS_DRV[1:0] - {0x30D9, 0x02}, // DIG_CLP_VSTART[4:0] - {0x30DA, 0x01}, // DIG_CLP_VNUM[1:0] - {0x3116, 0x24}, // INCKSEL2[7:0] - {0x3118, 0xA0}, // INCKSEL3[10:0] - {0x311E, 0x24}, // INCKSEL5[7:0] - {0x32D4, 0x21}, // - - {0x32EC, 0xA1}, // - - {0x344C, 0x2B}, // - - {0x344D, 0x01}, // - - {0x344E, 0xED}, // - - {0x344F, 0x01}, // - - {0x3450, 0xF6}, // - - {0x3451, 0x02}, // - - {0x3452, 0x7F}, // - - {0x3453, 0x03}, // - - {0x358A, 0x04}, // - - {0x35A1, 0x02}, // - - {0x35EC, 0x27}, // - - {0x35EE, 0x8D}, // - - {0x35F0, 0x8D}, // - - {0x35F2, 0x29}, // - - {0x36BC, 0x0C}, // - - {0x36CC, 0x53}, // - - {0x36CD, 0x00}, // - - {0x36CE, 0x3C}, // - - {0x36D0, 0x8C}, // - - {0x36D1, 0x00}, // - - {0x36D2, 0x71}, // - - {0x36D4, 0x3C}, // - - {0x36D6, 0x53}, // - - {0x36D7, 0x00}, // - - {0x36D8, 0x71}, // - - {0x36DA, 0x8C}, // - - {0x36DB, 0x00}, // - - {0x3701, 0x00}, // ADBIT1[7:0] - {0x3720, 0x00}, // - - {0x3724, 0x02}, // - - {0x3726, 0x02}, // - - {0x3732, 0x02}, // - - {0x3734, 0x03}, // - - {0x3736, 0x03}, // - - {0x3742, 0x03}, // - - {0x3862, 0xE0}, // - - {0x38CC, 0x30}, // - - {0x38CD, 0x2F}, // - - {0x395C, 0x0C}, // - - {0x39A4, 0x07}, // - - {0x39A8, 0x32}, // - - {0x39AA, 0x32}, // - - {0x39AC, 0x32}, // - - {0x39AE, 0x32}, // - - {0x39B0, 0x32}, // - - {0x39B2, 0x2F}, // - - {0x39B4, 0x2D}, // - - {0x39B6, 0x28}, // - - {0x39B8, 0x30}, // - - {0x39BA, 0x30}, // - - {0x39BC, 0x30}, // - - {0x39BE, 0x30}, // - - {0x39C0, 0x30}, // - - {0x39C2, 0x2E}, // - - {0x39C4, 0x2B}, // - - {0x39C6, 0x25}, // - - {0x3A42, 0xD1}, // - - {0x3A4C, 0x77}, // - - {0x3AE0, 0x02}, // - - {0x3AEC, 0x0C}, // - - {0x3B00, 0x2E}, // - - {0x3B06, 0x29}, // - - {0x3B98, 0x25}, // - - {0x3B99, 0x21}, // - - {0x3B9B, 0x13}, // - - {0x3B9C, 0x13}, // - - {0x3B9D, 0x13}, // - - {0x3B9E, 0x13}, // - - {0x3BA1, 0x00}, // - - {0x3BA2, 0x06}, // - - {0x3BA3, 0x0B}, // - - {0x3BA4, 0x10}, // - - {0x3BA5, 0x14}, // - - {0x3BA6, 0x18}, // - - {0x3BA7, 0x1A}, // - - {0x3BA8, 0x1A}, // - - {0x3BA9, 0x1A}, // - - {0x3BAC, 0xED}, // - - {0x3BAD, 0x01}, // - - {0x3BAE, 0xF6}, // - - {0x3BAF, 0x02}, // - - {0x3BB0, 0xA2}, // - - {0x3BB1, 0x03}, // - - {0x3BB2, 0xE0}, // - - {0x3BB3, 0x03}, // - - {0x3BB4, 0xE0}, // - - {0x3BB5, 0x03}, // - - {0x3BB6, 0xE0}, // - - {0x3BB7, 0x03}, // - - {0x3BB8, 0xE0}, // - - {0x3BBA, 0xE0}, // - - {0x3BBC, 0xDA}, // - - {0x3BBE, 0x88}, // - - {0x3BC0, 0x44}, // - - {0x3BC2, 0x7B}, // - - {0x3BC4, 0xA2}, // - - {0x3BC8, 0xBD}, // - - {0x3BCA, 0xBD}, // - - {0x4004, 0x48}, // TXCLKESC_FREQ[15:0] - {0x4005, 0x09}, // - {0x4018, 0xA7}, // TCLKPOST[15:0] - {0x401A, 0x57}, // TCLKPREPARE[15:0] - {0x401C, 0x5F}, // TCLKTRAIL[15:0] - {0x401E, 0x97}, // TCLKZERO[15:0] - {0x4020, 0x5F}, // THSPREPARE[15:0] - {0x4022, 0xAF}, // THSZERO[15:0] - {0x4024, 0x5F}, // THSTRAIL[15:0] - {0x4026, 0x9F}, // THSEXIT[15:0] - {0x4028, 0x4F}, // TLPX[15:0] - {0xffff, 0x10}, - {0x3000, 0x00}, // Operating - {0xffff, 0x10}, - {0x3002, 0x00}, // Master mode start - {0x3260, 0x00}, // Gain_Pgc_Fidmd -}; -#endif - -const static I2C_ARRAY Sensor_init_table_4lane_HDR_DOL[] = -{ - /* - IMX415-AAQR All-pixel scan CSI-2_4lane 27MHz AD:12bit Output:12bit 891Mbps Master Mode DOL HDR 2frame VC 15fps Integration Time LEF:9.988ms SEF:0.121ms - Tool ver : Ver6.0 vts:2250 hts:1100 - */ - {0x3000, 0x01}, //Standby - {0x3002, 0x01}, //Master mode stop - {0x3008, 0x5D}, // BCWAIT_TIME[9:0] - {0x300A, 0x42}, // CPWAIT_TIME[9:0] - {0x3028, 0x4C}, // HMAX[15:0] - {0x3029, 0x04}, // - {0x302C, 0x01}, // WDMODE[1:0] - {0x302D, 0x01}, // WDSEL[1:0] - {0x3033, 0x05}, // SYS_MODE[3:0] - {0x3050, 0xF2}, // SHR0[19:0] - {0x3051, 0x0E}, // - {0x3054, 0x09}, // SHR1[19:0] - {0x3060, 0x11}, // RHS1[19:0] - {0x30C1, 0x00}, // XVS_DRV[1:0] - {0x30CF, 0x01}, // XVSMSKCNT_INT[1:0] - {0x3116, 0x23}, // INCKSEL2[7:0] - {0x3118, 0xC6}, // INCKSEL3[10:0] - {0x311A, 0xE7}, // INCKSEL4[10:0] - {0x311E, 0x23}, // INCKSEL5[7:0] - {0x32D4, 0x21}, // - - {0x32EC, 0xA1}, // - - {0x3452, 0x7F}, // - - {0x3453, 0x03}, // - - {0x358A, 0x04}, // - - {0x35A1, 0x02}, // - - {0x36BC, 0x0C}, // - - {0x36CC, 0x53}, // - - {0x36CD, 0x00}, // - - {0x36CE, 0x3C}, // - - {0x36D0, 0x8C}, // - - {0x36D1, 0x00}, // - - {0x36D2, 0x71}, // - - {0x36D4, 0x3C}, // - - {0x36D6, 0x53}, // - - {0x36D7, 0x00}, // - - {0x36D8, 0x71}, // - - {0x36DA, 0x8C}, // - - {0x36DB, 0x00}, // - - {0x3724, 0x02}, // - - {0x3726, 0x02}, // - - {0x3732, 0x02}, // - - {0x3734, 0x03}, // - - {0x3736, 0x03}, // - - {0x3742, 0x03}, // - - {0x3862, 0xE0}, // - - {0x38CC, 0x30}, // - - {0x38CD, 0x2F}, // - - {0x395C, 0x0C}, // - - {0x3A42, 0xD1}, // - - {0x3A4C, 0x77}, // - - {0x3AE0, 0x02}, // - - {0x3AEC, 0x0C}, // - - {0x3B00, 0x2E}, // - - {0x3B06, 0x29}, // - - {0x3B98, 0x25}, // - - {0x3B99, 0x21}, // - - {0x3B9B, 0x13}, // - - {0x3B9C, 0x13}, // - - {0x3B9D, 0x13}, // - - {0x3B9E, 0x13}, // - - {0x3BA1, 0x00}, // - - {0x3BA2, 0x06}, // - - {0x3BA3, 0x0B}, // - - {0x3BA4, 0x10}, // - - {0x3BA5, 0x14}, // - - {0x3BA6, 0x18}, // - - {0x3BA7, 0x1A}, // - - {0x3BA8, 0x1A}, // - - {0x3BA9, 0x1A}, // - - {0x3BAC, 0xED}, // - - {0x3BAD, 0x01}, // - - {0x3BAE, 0xF6}, // - - {0x3BAF, 0x02}, // - - {0x3BB0, 0xA2}, // - - {0x3BB1, 0x03}, // - - {0x3BB2, 0xE0}, // - - {0x3BB3, 0x03}, // - - {0x3BB4, 0xE0}, // - - {0x3BB5, 0x03}, // - - {0x3BB6, 0xE0}, // - - {0x3BB7, 0x03}, // - - {0x3BB8, 0xE0}, // - - {0x3BBA, 0xE0}, // - - {0x3BBC, 0xDA}, // - - {0x3BBE, 0x88}, // - - {0x3BC0, 0x44}, // - - {0x3BC2, 0x7B}, // - - {0x3BC4, 0xA2}, // - - {0x3BC8, 0xBD}, // - - {0x3BCA, 0xBD}, // - - {0x4004, 0xC0}, // TXCLKESC_FREQ[15:0] - {0x4005, 0x06}, // - {0x400C, 0x00}, // INCKSEL6 - {0x4018, 0x7F}, // TCLKPOST[15:0] - {0x401A, 0x37}, // TCLKPREPARE[15:0] - {0x401C, 0x37}, // TCLKTRAIL[15:0] - {0x401E, 0xF7}, // TCLKZERO[15:0] - {0x401F, 0x00}, // - {0x4020, 0x3F}, // THSPREPARE[15:0] - {0x4022, 0x6F}, // THSZERO[15:0] - {0x4024, 0x3F}, // THSTRAIL[15:0] - {0x4026, 0x5F}, // THSEXIT[15:0] - {0x4028, 0x2F}, // TLPX[15:0] - {0x4074, 0x01}, // INCKSEL7 [2:0] - {0xffff, 0x10}, - {0x3000, 0x00}, //Operating - {0xffff, 0x10}, - {0x3002, 0x00}, //Master mode start - {0x3260, 0x00}, //Gain_Pgc_Fidmd -}; - -const static I2C_ARRAY Sensor_8m_20fps_init_table_4lane_HDR_DOL[] = -{ - /* - IMX415-AAQRAll-pixel scan - CSI-2_4lane - 27MHz - AD:10bit Output:10bit - 1485Mbps - Master Mode DOL HDR 2frame VC - 20.002fps - Integration Time LEF:1.002ms SEF:0.118ms - */ - {0x3000, 0x01}, //Standby - {0x3002, 0x01}, //Master mode stop - {0x3008, 0x5D}, // BCWAIT_TIME[9:0] - {0x300A, 0x42}, // CPWAIT_TIME[9:0] - {0x3024, 0x7A}, // VMAX[15:0] - {0x3025, 0x0D}, // - {0x3028, 0x1A}, // HMAX[15:0] - {0x3029, 0x02}, // - {0x302C, 0x01}, // WDMODE[1:0] - {0x302D, 0x01}, // WDSEL[1:0] - {0x3031, 0x00}, // - {0x3032, 0x00}, // - {0x3033, 0x08}, // SYS_MODE[3:0] - {0x3050, 0x6A}, // SHR0[19:0] - {0x3051, 0x1A}, // - {0x3054, 0x09}, // SHR1[19:0] - {0x3060, 0x19}, // RHS1[19:0] - {0x30C1, 0x00}, // XVS_DRV[1:0] - {0x30CF, 0x01}, // XVSMSKCNT_INT[1:0] - {0x3116, 0x23}, // INCKSEL2[7:0] - {0x3118, 0xA5}, // INCKSEL3[10:0] - {0x311A, 0xE7}, // INCKSEL4[10:0] - {0x311E, 0x23}, // INCKSEL5[7:0] - {0x32D4, 0x21}, // - - {0x32EC, 0xA1}, // - - {0x3452, 0x7F}, // - - {0x3453, 0x03}, // - - {0x358A, 0x04}, // - - {0x35A1, 0x02}, // - - {0x36BC, 0x0C}, // - - {0x36CC, 0x53}, // - - {0x36CD, 0x00}, // - - {0x36CE, 0x3C}, // - - {0x36D0, 0x8C}, // - - {0x36D1, 0x00}, // - - {0x36D2, 0x71}, // - - {0x36D4, 0x3C}, // - - {0x36D6, 0x53}, // - - {0x36D7, 0x00}, // - - {0x36D8, 0x71}, // - - {0x36DA, 0x8C}, // - - {0x36DB, 0x00}, // - - {0x3701, 0x00}, // - - {0x3724, 0x02}, // - - {0x3726, 0x02}, // - - {0x3732, 0x02}, // - - {0x3734, 0x03}, // - - {0x3736, 0x03}, // - - {0x3742, 0x03}, // - - {0x3862, 0xE0}, // - - {0x38CC, 0x30}, // - - {0x38CD, 0x2F}, // - - {0x395C, 0x0C}, // - - {0x3A42, 0xD1}, // - - {0x3A4C, 0x77}, // - - {0x3AE0, 0x02}, // - - {0x3AEC, 0x0C}, // - - {0x3B00, 0x2E}, // - - {0x3B06, 0x29}, // - - {0x3B98, 0x25}, // - - {0x3B99, 0x21}, // - - {0x3B9B, 0x13}, // - - {0x3B9C, 0x13}, // - - {0x3B9D, 0x13}, // - - {0x3B9E, 0x13}, // - - {0x3BA1, 0x00}, // - - {0x3BA2, 0x06}, // - - {0x3BA3, 0x0B}, // - - {0x3BA4, 0x10}, // - - {0x3BA5, 0x14}, // - - {0x3BA6, 0x18}, // - - {0x3BA7, 0x1A}, // - - {0x3BA8, 0x1A}, // - - {0x3BA9, 0x1A}, // - - {0x3BAC, 0xED}, // - - {0x3BAD, 0x01}, // - - {0x3BAE, 0xF6}, // - - {0x3BAF, 0x02}, // - - {0x3BB0, 0xA2}, // - - {0x3BB1, 0x03}, // - - {0x3BB2, 0xE0}, // - - {0x3BB3, 0x03}, // - - {0x3BB4, 0xE0}, // - - {0x3BB5, 0x03}, // - - {0x3BB6, 0xE0}, // - - {0x3BB7, 0x03}, // - - {0x3BB8, 0xE0}, // - - {0x3BBA, 0xE0}, // - - {0x3BBC, 0xDA}, // - - {0x3BBE, 0x88}, // - - {0x3BC0, 0x44}, // - - {0x3BC2, 0x7B}, // - - {0x3BC4, 0xA2}, // - - {0x3BC8, 0xBD}, // - - {0x3BCA, 0xBD}, // - - {0x4004, 0xC0}, // TXCLKESC_FREQ[15:0] - {0x4005, 0x06}, // - {0x4018, 0xA7}, // TCLKPOST[15:0] - {0x401A, 0x57}, // TCLKPREPARE[15:0] - {0x401C, 0x5F}, // TCLKTRAIL[15:0] - {0x401E, 0x97}, // TCLKZERO[15:0] - {0x4020, 0x5F}, // THSPREPARE[15:0] - {0x4022, 0xAF}, // THSZERO[15:0] - {0x4024, 0x5F}, // THSTRAIL[15:0] - {0x4026, 0x9F}, // THSEXIT[15:0] - {0x4028, 0x4F}, // TLPX[15:0] - {0xffff, 0x10}, - {0x3000, 0x00}, //Operating - {0xffff, 0x10}, - {0x3002, 0x00}, //Master mode start - {0x3260, 0x00}, //Gain_Pgc_Fidmd -}; - -const static I2C_ARRAY Sensor_8m_30fps_init_table_4lane_HDR_DOL[] = -{ - /* - IMX415-AAQRAll-pixel scan - CSI-2_4lane - 27MHz - AD:10bit Output:10bit - 1485Mbps - Master Mode DOL HDR 2frame VC - 30.002fps - Integration Time LEF:1.002ms SEF:0.118ms - */ - {0x3000, 0x01}, //Standby - {0x3002, 0x01}, //Master mode stop - {0x3008, 0x5D}, // BCWAIT_TIME[9:0] - {0x300A, 0x42}, // CPWAIT_TIME[9:0] - {0x3024, 0xFC}, // VMAX[15:0] - {0x3025, 0x08}, // - {0x3028, 0x1A}, // HMAX[15:0] - {0x3029, 0x02}, // - {0x302C, 0x01}, // WDMODE[1:0] - {0x302D, 0x01}, // WDSEL[1:0] - {0x3031, 0x00}, // - {0x3032, 0x00}, // - {0x3033, 0x08}, // SYS_MODE[3:0] - {0x3050, 0x6E}, // SHR0[19:0] - {0x3051, 0x11}, // - {0x3054, 0x09}, // SHR1[19:0] - {0x3060, 0x19}, // RHS1[19:0] - {0x30C1, 0x00}, // XVS_DRV[1:0] - {0x30CF, 0x01}, // XVSMSKCNT_INT[1:0] - {0x3116, 0x23}, // INCKSEL2[7:0] - {0x3118, 0xA5}, // INCKSEL3[10:0] - {0x311A, 0xE7}, // INCKSEL4[10:0] - {0x311E, 0x23}, // INCKSEL5[7:0] - {0x32D4, 0x21}, // - - {0x32EC, 0xA1}, // - - {0x3452, 0x7F}, // - - {0x3453, 0x03}, // - - {0x358A, 0x04}, // - - {0x35A1, 0x02}, // - - {0x36BC, 0x0C}, // - - {0x36CC, 0x53}, // - - {0x36CD, 0x00}, // - - {0x36CE, 0x3C}, // - - {0x36D0, 0x8C}, // - - {0x36D1, 0x00}, // - - {0x36D2, 0x71}, // - - {0x36D4, 0x3C}, // - - {0x36D6, 0x53}, // - - {0x36D7, 0x00}, // - - {0x36D8, 0x71}, // - - {0x36DA, 0x8C}, // - - {0x36DB, 0x00}, // - - {0x3701, 0x00}, // - - {0x3724, 0x02}, // - - {0x3726, 0x02}, // - - {0x3732, 0x02}, // - - {0x3734, 0x03}, // - - {0x3736, 0x03}, // - - {0x3742, 0x03}, // - - {0x3862, 0xE0}, // - - {0x38CC, 0x30}, // - - {0x38CD, 0x2F}, // - - {0x395C, 0x0C}, // - - {0x3A42, 0xD1}, // - - {0x3A4C, 0x77}, // - - {0x3AE0, 0x02}, // - - {0x3AEC, 0x0C}, // - - {0x3B00, 0x2E}, // - - {0x3B06, 0x29}, // - - {0x3B98, 0x25}, // - - {0x3B99, 0x21}, // - - {0x3B9B, 0x13}, // - - {0x3B9C, 0x13}, // - - {0x3B9D, 0x13}, // - - {0x3B9E, 0x13}, // - - {0x3BA1, 0x00}, // - - {0x3BA2, 0x06}, // - - {0x3BA3, 0x0B}, // - - {0x3BA4, 0x10}, // - - {0x3BA5, 0x14}, // - - {0x3BA6, 0x18}, // - - {0x3BA7, 0x1A}, // - - {0x3BA8, 0x1A}, // - - {0x3BA9, 0x1A}, // - - {0x3BAC, 0xED}, // - - {0x3BAD, 0x01}, // - - {0x3BAE, 0xF6}, // - - {0x3BAF, 0x02}, // - - {0x3BB0, 0xA2}, // - - {0x3BB1, 0x03}, // - - {0x3BB2, 0xE0}, // - - {0x3BB3, 0x03}, // - - {0x3BB4, 0xE0}, // - - {0x3BB5, 0x03}, // - - {0x3BB6, 0xE0}, // - - {0x3BB7, 0x03}, // - - {0x3BB8, 0xE0}, // - - {0x3BBA, 0xE0}, // - - {0x3BBC, 0xDA}, // - - {0x3BBE, 0x88}, // - - {0x3BC0, 0x44}, // - - {0x3BC2, 0x7B}, // - - {0x3BC4, 0xA2}, // - - {0x3BC8, 0xBD}, // - - {0x3BCA, 0xBD}, // - - {0x4004, 0xC0}, // TXCLKESC_FREQ[15:0] - {0x4005, 0x06}, // - {0x4018, 0xA7}, // TCLKPOST[15:0] - {0x401A, 0x57}, // TCLKPREPARE[15:0] - {0x401C, 0x5F}, // TCLKTRAIL[15:0] - {0x401E, 0x97}, // TCLKZERO[15:0] - {0x4020, 0x5F}, // THSPREPARE[15:0] - {0x4022, 0xAF}, // THSZERO[15:0] - {0x4024, 0x5F}, // THSTRAIL[15:0] - {0x4026, 0x9F}, // THSEXIT[15:0] - {0x4028, 0x4F}, // TLPX[15:0] - {0xffff, 0x10}, - {0x3000, 0x00}, //Operating - {0xffff, 0x10}, - {0x3002, 0x00}, //Master mode start - {0x3260, 0x00}, //Gain_Pgc_Fidmd -}; - -const static I2C_ARRAY Sensor_5m_30fps_init_table_4lane_HDR_DOL[] = -{ - /* - IMX415-AAQR - Window cropping2592x1944 - CSI-2_4lane27MHz - AD:10bit Output:10bit - 1485Mbps - Master Mode DOL HDR 2frame VC - 30.002fps - Integration Time LEF:1.002ms SEF:0.118ms - - */ - {0x3000, 0x01}, //Standby - {0x3002, 0x01}, //Master mode stop - {0x3008, 0x5D}, // BCWAIT_TIME[9:0] - {0x300A, 0x42}, // CPWAIT_TIME[9:0] - {0x301C, 0x04}, // - {0x3024, 0xFC}, // VMAX[15:0] - {0x3025, 0x08}, // - {0x3028, 0x1A}, // HMAX[15:0] - {0x3029, 0x02}, // - {0x302C, 0x01}, // WDMODE[1:0] - {0x302D, 0x01}, // WDSEL[1:0] - {0x3031, 0x00}, // - {0x3032, 0x00}, // - {0x3033, 0x08}, // SYS_MODE[3:0] - {0x3040, 0x7C}, // - {0x3041, 0x02}, // - {0x3042, 0x20}, // - {0x3043, 0x0A}, // - {0x3044, 0xF8}, // - {0x3045, 0x00}, // - {0x3046, 0x30}, // - {0x3047, 0x0F}, // - {0x3050, 0x6E}, // SHR0[19:0] - {0x3051, 0x11}, // - {0x3054, 0x09}, // SHR1[19:0] - {0x3060, 0x19}, // RHS1[19:0] - {0x30C1, 0x00}, // XVS_DRV[1:0] - {0x30CF, 0x01}, // XVSMSKCNT_INT[1:0] - {0x3116, 0x23}, // INCKSEL2[7:0] - {0x3118, 0xA5}, // INCKSEL3[10:0] - {0x311A, 0xE7}, // INCKSEL4[10:0] - {0x311E, 0x23}, // INCKSEL5[7:0] - {0x32D4, 0x21}, // - - {0x32EC, 0xA1}, // - - {0x3452, 0x7F}, // - - {0x3453, 0x03}, // - - {0x358A, 0x04}, // - - {0x35A1, 0x02}, // - - {0x36BC, 0x0C}, // - - {0x36CC, 0x53}, // - - {0x36CD, 0x00}, // - - {0x36CE, 0x3C}, // - - {0x36D0, 0x8C}, // - - {0x36D1, 0x00}, // - - {0x36D2, 0x71}, // - - {0x36D4, 0x3C}, // - - {0x36D6, 0x53}, // - - {0x36D7, 0x00}, // - - {0x36D8, 0x71}, // - - {0x36DA, 0x8C}, // - - {0x36DB, 0x00}, // - - {0x3701, 0x00}, // - - {0x3724, 0x02}, // - - {0x3726, 0x02}, // - - {0x3732, 0x02}, // - - {0x3734, 0x03}, // - - {0x3736, 0x03}, // - - {0x3742, 0x03}, // - - {0x3862, 0xE0}, // - - {0x38CC, 0x30}, // - - {0x38CD, 0x2F}, // - - {0x395C, 0x0C}, // - - {0x3A42, 0xD1}, // - - {0x3A4C, 0x77}, // - - {0x3AE0, 0x02}, // - - {0x3AEC, 0x0C}, // - - {0x3B00, 0x2E}, // - - {0x3B06, 0x29}, // - - {0x3B98, 0x25}, // - - {0x3B99, 0x21}, // - - {0x3B9B, 0x13}, // - - {0x3B9C, 0x13}, // - - {0x3B9D, 0x13}, // - - {0x3B9E, 0x13}, // - - {0x3BA1, 0x00}, // - - {0x3BA2, 0x06}, // - - {0x3BA3, 0x0B}, // - - {0x3BA4, 0x10}, // - - {0x3BA5, 0x14}, // - - {0x3BA6, 0x18}, // - - {0x3BA7, 0x1A}, // - - {0x3BA8, 0x1A}, // - - {0x3BA9, 0x1A}, // - - {0x3BAC, 0xED}, // - - {0x3BAD, 0x01}, // - - {0x3BAE, 0xF6}, // - - {0x3BAF, 0x02}, // - - {0x3BB0, 0xA2}, // - - {0x3BB1, 0x03}, // - - {0x3BB2, 0xE0}, // - - {0x3BB3, 0x03}, // - - {0x3BB4, 0xE0}, // - - {0x3BB5, 0x03}, // - - {0x3BB6, 0xE0}, // - - {0x3BB7, 0x03}, // - - {0x3BB8, 0xE0}, // - - {0x3BBA, 0xE0}, // - - {0x3BBC, 0xDA}, // - - {0x3BBE, 0x88}, // - - {0x3BC0, 0x44}, // - - {0x3BC2, 0x7B}, // - - {0x3BC4, 0xA2}, // - - {0x3BC8, 0xBD}, // - - {0x3BCA, 0xBD}, // - - {0x4004, 0xC0}, // TXCLKESC_FREQ[15:0] - {0x4005, 0x06}, // - {0x4018, 0xA7}, // TCLKPOST[15:0] - {0x401A, 0x57}, // TCLKPREPARE[15:0] - {0x401C, 0x5F}, // TCLKTRAIL[15:0] - {0x401E, 0x97}, // TCLKZERO[15:0] - {0x4020, 0x5F}, // THSPREPARE[15:0] - {0x4022, 0xAF}, // THSZERO[15:0] - {0x4024, 0x5F}, // THSTRAIL[15:0] - {0x4026, 0x9F}, // THSEXIT[15:0] - {0x4028, 0x4F}, // TLPX[15:0] - {0xffff, 0x10}, - {0x3000, 0x00}, //Operating - {0xffff, 0x10}, - {0x3002, 0x00}, //Master mode start - {0x3260, 0x00}, //Gain_Pgc_Fidmd -}; - -#if 0 -const static I2C_ARRAY Sensor_5m_15fps_init_table_4lane_HDR_DOL[] = -{ - /* - IMX415-AAQR window cropping2616x1974 scan CSI-2_4lane 27MHz AD:12bit Output:12bit 891Mbps Master Mode DOL HDR 2frame VC 15fps Integration Time LEF:9.988ms SEF:0.121ms - Tool ver : Ver6.0 - */ - {0x3000, 0x01}, //Standby - {0x3002, 0x01}, //Master mode stop - {0x3008, 0x5D}, // BCWAIT_TIME[9:0] - {0x300A, 0x42}, // CPWAIT_TIME[9:0] - {0x301C, 0x04}, // WINMODE[3:0] - {0x3028, 0x4C}, // HMAX[15:0] - {0x3029, 0x04}, // - {0x302C, 0x01}, // WDMODE[1:0] - {0x302D, 0x01}, // WDSEL[1:0] - {0x3033, 0x05}, // SYS_MODE[3:0] - {0x3040, 0x70}, // PIX_HST[12:0] - {0x3041, 0x02}, // - {0x3042, 0x38}, // PIX_HWIDTH[12:0] - {0x3043, 0x0A}, // - {0x3044, 0xDA}, // PIX_VST[12:0] - {0x3045, 0x00}, // - {0x3046, 0x6C}, // PIX_VWIDTH[12:0] - {0x3047, 0x0F}, // - {0x3050, 0xF2}, // SHR0[19:0] - {0x3051, 0x0E}, // - {0x3054, 0x09}, // SHR1[19:0] - {0x3060, 0x11}, // RHS1[19:0] - {0x30C1, 0x00}, // XVS_DRV[1:0] - {0x30CF, 0x01}, // XVSMSKCNT_INT[1:0] - {0x3116, 0x23}, // INCKSEL2[7:0] - {0x3118, 0xC6}, // INCKSEL3[10:0] - {0x311A, 0xE7}, // INCKSEL4[10:0] - {0x311E, 0x23}, // INCKSEL5[7:0] - {0x32D4, 0x21}, // - - {0x32EC, 0xA1}, // - - {0x3452, 0x7F}, // - - {0x3453, 0x03}, // - - {0x358A, 0x04}, // - - {0x35A1, 0x02}, // - - {0x36BC, 0x0C}, // - - {0x36CC, 0x53}, // - - {0x36CD, 0x00}, // - - {0x36CE, 0x3C}, // - - {0x36D0, 0x8C}, // - - {0x36D1, 0x00}, // - - {0x36D2, 0x71}, // - - {0x36D4, 0x3C}, // - - {0x36D6, 0x53}, // - - {0x36D7, 0x00}, // - - {0x36D8, 0x71}, // - - {0x36DA, 0x8C}, // - - {0x36DB, 0x00}, // - - {0x3724, 0x02}, // - - {0x3726, 0x02}, // - - {0x3732, 0x02}, // - - {0x3734, 0x03}, // - - {0x3736, 0x03}, // - - {0x3742, 0x03}, // - - {0x3862, 0xE0}, // - - {0x38CC, 0x30}, // - - {0x38CD, 0x2F}, // - - {0x395C, 0x0C}, // - - {0x3A42, 0xD1}, // - - {0x3A4C, 0x77}, // - - {0x3AE0, 0x02}, // - - {0x3AEC, 0x0C}, // - - {0x3B00, 0x2E}, // - - {0x3B06, 0x29}, // - - {0x3B98, 0x25}, // - - {0x3B99, 0x21}, // - - {0x3B9B, 0x13}, // - - {0x3B9C, 0x13}, // - - {0x3B9D, 0x13}, // - - {0x3B9E, 0x13}, // - - {0x3BA1, 0x00}, // - - {0x3BA2, 0x06}, // - - {0x3BA3, 0x0B}, // - - {0x3BA4, 0x10}, // - - {0x3BA5, 0x14}, // - - {0x3BA6, 0x18}, // - - {0x3BA7, 0x1A}, // - - {0x3BA8, 0x1A}, // - - {0x3BA9, 0x1A}, // - - {0x3BAC, 0xED}, // - - {0x3BAD, 0x01}, // - - {0x3BAE, 0xF6}, // - - {0x3BAF, 0x02}, // - - {0x3BB0, 0xA2}, // - - {0x3BB1, 0x03}, // - - {0x3BB2, 0xE0}, // - - {0x3BB3, 0x03}, // - - {0x3BB4, 0xE0}, // - - {0x3BB5, 0x03}, // - - {0x3BB6, 0xE0}, // - - {0x3BB7, 0x03}, // - - {0x3BB8, 0xE0}, // - - {0x3BBA, 0xE0}, // - - {0x3BBC, 0xDA}, // - - {0x3BBE, 0x88}, // - - {0x3BC0, 0x44}, // - - {0x3BC2, 0x7B}, // - - {0x3BC4, 0xA2}, // - - {0x3BC8, 0xBD}, // - - {0x3BCA, 0xBD}, // - - {0x4004, 0xC0}, // TXCLKESC_FREQ[15:0] - {0x4005, 0x06}, // - {0x400C, 0x00}, // INCKSEL6 - {0x4018, 0x7F}, // TCLKPOST[15:0] - {0x401A, 0x37}, // TCLKPREPARE[15:0] - {0x401C, 0x37}, // TCLKTRAIL[15:0] - {0x401E, 0xF7}, // TCLKZERO[15:0] - {0x401F, 0x00}, // - {0x4020, 0x3F}, // THSPREPARE[15:0] - {0x4022, 0x6F}, // THSZERO[15:0] - {0x4024, 0x3F}, // THSTRAIL[15:0] - {0x4026, 0x5F}, // THSEXIT[15:0] - {0x4028, 0x2F}, // TLPX[15:0] - {0x4074, 0x01}, // INCKSEL7 [2:0] - {0xffff, 0x10}, - {0x3000, 0x00}, //Operating - {0xffff, 0x10}, - {0x3002, 0x00}, //Master mode start - {0x3260, 0x00}, //Gain_Pgc_Fidmd -}; -#endif - -const static I2C_ARRAY Sensor_4p8m_30fps_init_table_4lane_HDR_DOL[] = -{ - /* - "IMX415-AAQR Window cropping 2976x1686 CSI-2_4lane 27MHz - AD:10bit Output:10bit 1485Mbps - Master Mode DOL HDR 2frame VC 30.002fps - Integration Time LEF:1.002ms SEF:0.118ms" - */ - {0x3000, 0x01}, //Standby - {0x3002, 0x01}, //Master mode stop - {0x3008, 0x5D}, // BCWAIT_TIME[9:0] - {0x300A, 0x42}, // CPWAIT_TIME[9:0] - {0x301C, 0x04}, // - {0x3024, 0xFC}, // VMAX[15:0] FC - {0x3025, 0x08}, // - {0x3028, 0x1A}, // HMAX[15:0] 1A - {0x3029, 0x02}, // - {0x302C, 0x01}, // WDMODE[1:0] - {0x302D, 0x01}, // WDSEL[1:0] - {0x3031, 0x00}, // - {0x3032, 0x00}, // - {0x3033, 0x08}, // SYS_MODE[3:0] - {0x3040, 0xBC}, // - {0x3041, 0x01}, // 01 - {0x3042, 0xA0}, // - {0x3043, 0x0B}, // - {0x3044, 0xF8}, // - {0x3045, 0x01}, // 01 - {0x3046, 0x30}, // - {0x3047, 0x0D}, // - {0x3050, 0x6E}, // SHR0[19:0] - {0x3051, 0x11}, // - {0x3054, 0x09}, // SHR1[19:0] - {0x3060, 0x19}, // RHS1[19:0] - {0x30C0, 0x2A}, - {0x30C1, 0x00}, // XVS_DRV[1:0] - {0x30CC, 0x00}, - {0x30CD, 0x00}, - {0x30CF, 0x01}, // XVSMSKCNT_INT[1:0] - {0x3116, 0x23}, // INCKSEL2[7:0] - {0x3118, 0xA5}, // INCKSEL3[10:0] - {0x311A, 0xE7}, // INCKSEL4[10:0] - {0x311E, 0x23}, // INCKSEL5[7:0] - {0x32D4, 0x21}, // - - {0x32EC, 0xA1}, // - - {0x3452, 0x7F}, // - - {0x3453, 0x03}, // - - {0x358A, 0x04}, // - - {0x35A1, 0x02}, // - - {0x36BC, 0x0C}, // - - {0x36CC, 0x53}, // - - {0x36CD, 0x00}, // - - {0x36CE, 0x3C}, // - - {0x36D0, 0x8C}, // - - {0x36D1, 0x00}, // - - {0x36D2, 0x71}, // - - {0x36D4, 0x3C}, // - - {0x36D6, 0x53}, // - - {0x36D7, 0x00}, // - - {0x36D8, 0x71}, // - - {0x36DA, 0x8C}, // - - {0x36DB, 0x00}, // - - {0x3701, 0x00}, // - - {0x3724, 0x02}, // - - {0x3726, 0x02}, // - - {0x3732, 0x02}, // - - {0x3734, 0x03}, // - - {0x3736, 0x03}, // - - {0x3742, 0x03}, // - - {0x3862, 0xE0}, // - - {0x38CC, 0x30}, // - - {0x38CD, 0x2F}, // - - {0x395C, 0x0C}, // - - {0x3A42, 0xD1}, // - - {0x3A4C, 0x77}, // - - {0x3AE0, 0x02}, // - - {0x3AEC, 0x0C}, // - - {0x3B00, 0x2E}, // - - {0x3B06, 0x29}, // - - {0x3B98, 0x25}, // - - {0x3B99, 0x21}, // - - {0x3B9B, 0x13}, // - - {0x3B9C, 0x13}, // - - {0x3B9D, 0x13}, // - - {0x3B9E, 0x13}, // - - {0x3BA1, 0x00}, // - - {0x3BA2, 0x06}, // - - {0x3BA3, 0x0B}, // - - {0x3BA4, 0x10}, // - - {0x3BA5, 0x14}, // - - {0x3BA6, 0x18}, // - - {0x3BA7, 0x1A}, // - - {0x3BA8, 0x1A}, // - - {0x3BA9, 0x1A}, // - - {0x3BAC, 0xED}, // - - {0x3BAD, 0x01}, // - - {0x3BAE, 0xF6}, // - - {0x3BAF, 0x02}, // - - {0x3BB0, 0xA2}, // - - {0x3BB1, 0x03}, // - - {0x3BB2, 0xE0}, // - - {0x3BB3, 0x03}, // - - {0x3BB4, 0xE0}, // - - {0x3BB5, 0x03}, // - - {0x3BB6, 0xE0}, // - - {0x3BB7, 0x03}, // - - {0x3BB8, 0xE0}, // - - {0x3BBA, 0xE0}, // - - {0x3BBC, 0xDA}, // - - {0x3BBE, 0x88}, // - - {0x3BC0, 0x44}, // - - {0x3BC2, 0x7B}, // - - {0x3BC4, 0xA2}, // - - {0x3BC8, 0xBD}, // - - {0x3BCA, 0xBD}, // - - {0x4004, 0xC0}, // TXCLKESC_FREQ[15:0] - {0x4005, 0x06}, // - {0x4018, 0xA7}, // TCLKPOST[15:0] - {0x401A, 0x57}, // TCLKPREPARE[15:0] - {0x401C, 0x5F}, // TCLKTRAIL[15:0] - {0x401E, 0x97}, // TCLKZERO[15:0] - {0x4020, 0x5F}, // THSPREPARE[15:0] - {0x4022, 0xAF}, // THSZERO[15:0] - {0x4024, 0x5F}, // THSTRAIL[15:0] - {0x4026, 0x9F}, // THSEXIT[15:0] - {0x4028, 0x4F}, // TLPX[15:0] - {0xffff, 0x10}, - {0x3000, 0x00}, //Operating - {0xffff, 0x10}, - {0x3002, 0x00}, //Master mode start - {0x3260, 0x00}, //Gain_Pgc_Fidmd -}; - -const static I2C_ARRAY Sensor_4m_30fps_init_table_4lane_HDR_DOL[] = -{ - /* - "IMX415-AAQR Window cropping 2688x1520 - CSI-2_4lane 27MHz AD:10bit Output:10bit 1485Mbps - Master Mode DOL HDR 2frame VC - 30.002fps Integration Time LEF:1.002ms SEF:0.118ms" - */ - {0x3000, 0x01}, //Standby - {0x3002, 0x01}, //Master mode stop - {0x3008, 0x5D}, // BCWAIT_TIME[9:0] - {0x300A, 0x42}, // CPWAIT_TIME[9:0] - {0x301C, 0x04}, // - {0x3024, 0xFC}, // VMAX[15:0] - {0x3025, 0x08}, // - {0x3028, 0x1A}, // HMAX[15:0] - {0x3029, 0x02}, // - {0x302C, 0x01}, // WDMODE[1:0] - {0x302D, 0x01}, // WDSEL[1:0] - {0x3031, 0x00}, // - {0x3032, 0x00}, // - {0x3033, 0x08}, // SYS_MODE[3:0] - {0x3040, 0x4C}, // - {0x3041, 0x01}, // - {0x3042, 0x80}, // - {0x3043, 0x0A}, // - {0x3044, 0xA0}, // - {0x3045, 0x01}, // - {0x3046, 0xE0}, // - {0x3047, 0x0B}, // - {0x3050, 0x6E}, // SHR0[19:0] - {0x3051, 0x11}, // - {0x3054, 0x09}, // SHR1[19:0] - {0x3060, 0x19}, // RHS1[19:0] - {0x30C0, 0x2A}, - {0x30C1, 0x00}, // XVS_DRV[1:0] - {0x30CC, 0x00}, - {0x30CD, 0x00}, - {0x30CF, 0x01}, // XVSMSKCNT_INT[1:0] - {0x3116, 0x23}, // INCKSEL2[7:0] - {0x3118, 0xA5}, // INCKSEL3[10:0] - {0x311A, 0xE7}, // INCKSEL4[10:0] - {0x311E, 0x23}, // INCKSEL5[7:0] - {0x32D4, 0x21}, // - - {0x32EC, 0xA1}, // - - {0x3452, 0x7F}, // - - {0x3453, 0x03}, // - - {0x358A, 0x04}, // - - {0x35A1, 0x02}, // - - {0x36BC, 0x0C}, // - - {0x36CC, 0x53}, // - - {0x36CD, 0x00}, // - - {0x36CE, 0x3C}, // - - {0x36D0, 0x8C}, // - - {0x36D1, 0x00}, // - - {0x36D2, 0x71}, // - - {0x36D4, 0x3C}, // - - {0x36D6, 0x53}, // - - {0x36D7, 0x00}, // - - {0x36D8, 0x71}, // - - {0x36DA, 0x8C}, // - - {0x36DB, 0x00}, // - - {0x3701, 0x00}, // - - {0x3724, 0x02}, // - - {0x3726, 0x02}, // - - {0x3732, 0x02}, // - - {0x3734, 0x03}, // - - {0x3736, 0x03}, // - - {0x3742, 0x03}, // - - {0x3862, 0xE0}, // - - {0x38CC, 0x30}, // - - {0x38CD, 0x2F}, // - - {0x395C, 0x0C}, // - - {0x3A42, 0xD1}, // - - {0x3A4C, 0x77}, // - - {0x3AE0, 0x02}, // - - {0x3AEC, 0x0C}, // - - {0x3B00, 0x2E}, // - - {0x3B06, 0x29}, // - - {0x3B98, 0x25}, // - - {0x3B99, 0x21}, // - - {0x3B9B, 0x13}, // - - {0x3B9C, 0x13}, // - - {0x3B9D, 0x13}, // - - {0x3B9E, 0x13}, // - - {0x3BA1, 0x00}, // - - {0x3BA2, 0x06}, // - - {0x3BA3, 0x0B}, // - - {0x3BA4, 0x10}, // - - {0x3BA5, 0x14}, // - - {0x3BA6, 0x18}, // - - {0x3BA7, 0x1A}, // - - {0x3BA8, 0x1A}, // - - {0x3BA9, 0x1A}, // - - {0x3BAC, 0xED}, // - - {0x3BAD, 0x01}, // - - {0x3BAE, 0xF6}, // - - {0x3BAF, 0x02}, // - - {0x3BB0, 0xA2}, // - - {0x3BB1, 0x03}, // - - {0x3BB2, 0xE0}, // - - {0x3BB3, 0x03}, // - - {0x3BB4, 0xE0}, // - - {0x3BB5, 0x03}, // - - {0x3BB6, 0xE0}, // - - {0x3BB7, 0x03}, // - - {0x3BB8, 0xE0}, // - - {0x3BBA, 0xE0}, // - - {0x3BBC, 0xDA}, // - - {0x3BBE, 0x88}, // - - {0x3BC0, 0x44}, // - - {0x3BC2, 0x7B}, // - - {0x3BC4, 0xA2}, // - - {0x3BC8, 0xBD}, // - - {0x3BCA, 0xBD}, // - - {0x4004, 0xC0}, // TXCLKESC_FREQ[15:0] - {0x4005, 0x06}, // - {0x4018, 0xA7}, // TCLKPOST[15:0] - {0x401A, 0x57}, // TCLKPREPARE[15:0] - {0x401C, 0x5F}, // TCLKTRAIL[15:0] - {0x401E, 0x97}, // TCLKZERO[15:0] - {0x4020, 0x5F}, // THSPREPARE[15:0] - {0x4022, 0xAF}, // THSZERO[15:0] - {0x4024, 0x5F}, // THSTRAIL[15:0] - {0x4026, 0x9F}, // THSEXIT[15:0] - {0x4028, 0x4F}, // TLPX[15:0] - {0xffff, 0x10}, - {0x3000, 0x00}, //Operating - {0xffff, 0x10}, - {0x3002, 0x00}, //Master mode start - {0x3260, 0x00}, //Gain_Pgc_Fidmd -}; - -const static I2C_ARRAY Sensor_2m_30fps_init_table_4lane_HDR_DOL[] = -{ - /* - "IMX415-AAQR 2/2-line binning CSI-2_4lane 27MHz - AD:10bit Output:12bit 891Mbps - Master Mode DOL HDR 2frame VC - 29.999fps Integration Time LEF:1.004ms SEF:0.118ms" - */ - {0x3000, 0x01}, //Standby - {0x3002, 0x01}, //Master mode stop - {0x3008, 0x5D}, // BCWAIT_TIME[9:0] - {0x300A, 0x42}, // CPWAIT_TIME[9:0] - - {0x3020, 0x01}, // 01h: Horizontal 2 binning - {0x3021, 0x01}, // 01h: Vertical 2 binning - {0x3022, 0x01}, // 01h: Horizontal/Vertical 2x2-line binning(RGB only) - {0x3024, 0xF8}, // MAX[15:0] - {0x3025, 0x08}, // - {0x3028, 0x1B}, // HMAX[15:0] - {0x3029, 0x02}, // - {0x302C, 0x01}, // WDMODE[1:0] - {0x302D, 0x01}, // WDSEL[1:0] - {0x3031, 0x00}, // - {0x3033, 0x05}, // SYS_MODE[3:0] - {0x3050, 0x66}, // SHR0[19:0] - {0x3051, 0x11}, // - {0x3054, 0x09}, // SHR1[19:0] - {0x3060, 0x19}, // RHS1[19:0] - {0x30C0, 0x2A}, - {0x30C1, 0x00}, // XVS_DRV[1:0] - {0x30CC, 0x00}, - {0x30CD, 0x00}, - {0x30CF, 0x01}, // XVSMSKCNT_INT[1:0] - {0x30D9, 0x02}, - {0x30DA, 0x01}, - {0x3116, 0x23}, // INCKSEL2[7:0] - {0x3118, 0xC6}, // INCKSEL3[10:0] - {0x311A, 0xE7}, // INCKSEL4[10:0] - {0x311E, 0x23}, // INCKSEL5[7:0] - {0x32D4, 0x21}, // -- - {0x32EC, 0xA1}, // -- - {0x3452, 0x7F}, // -- - {0x3453, 0x03}, // -- - {0x358A, 0x04}, // -- - {0x35A1, 0x02}, // -- - {0x36BC, 0x0C}, // -- - {0x36CC, 0x53}, // -- - {0x36CD, 0x00}, // -- - {0x36CE, 0x3C}, // -- - {0x36D0, 0x8C}, // -- - {0x36D1, 0x00}, // -- - {0x36D2, 0x71}, // -- - {0x36D4, 0x3C}, // -- - {0x36D6, 0x53}, // -- - {0x36D7, 0x00}, // -- - {0x36D8, 0x71}, // -- - {0x36DA, 0x8C}, // -- - {0x36DB, 0x00}, // -- - {0x3701, 0x00}, // -- - {0x3724, 0x02}, // -- - {0x3726, 0x02}, // -- - {0x3732, 0x02}, // -- - {0x3734, 0x03}, // -- - {0x3736, 0x03}, // -- - {0x3742, 0x03}, // -- - {0x3862, 0xE0}, // -- - {0x38CC, 0x30}, // -- - {0x38CD, 0x2F}, // -- - {0x395C, 0x0C}, // -- - {0x3A42, 0xD1}, // -- - {0x3A4C, 0x77}, // -- - {0x3AE0, 0x02}, // -- - {0x3AEC, 0x0C}, // -- - {0x3B00, 0x2E}, // -- - {0x3B06, 0x29}, // -- - {0x3B98, 0x25}, // -- - {0x3B99, 0x21}, // -- - {0x3B9B, 0x13}, // -- - {0x3B9C, 0x13}, // -- - {0x3B9D, 0x13}, // -- - {0x3B9E, 0x13}, // -- - {0x3BA1, 0x00}, // -- - {0x3BA2, 0x06}, // -- - {0x3BA3, 0x0B}, // -- - {0x3BA4, 0x10}, // -- - {0x3BA5, 0x14}, // -- - {0x3BA6, 0x18}, // -- - {0x3BA7, 0x1A}, // -- - {0x3BA8, 0x1A}, // -- - {0x3BA9, 0x1A}, // -- - {0x3BAC, 0xED}, // -- - {0x3BAD, 0x01}, // -- - {0x3BAE, 0xF6}, // -- - {0x3BAF, 0x02}, // -- - {0x3BB0, 0xA2}, // -- - {0x3BB1, 0x03}, // -- - {0x3BB2, 0xE0}, // -- - {0x3BB3, 0x03}, // -- - {0x3BB4, 0xE0}, // -- - {0x3BB5, 0x03}, // -- - {0x3BB6, 0xE0}, // -- - {0x3BB7, 0x03}, // -- - {0x3BB8, 0xE0}, // -- - {0x3BBA, 0xE0}, // -- - {0x3BBC, 0xDA}, // -- - {0x3BBE, 0x88}, // -- - {0x3BC0, 0x44}, // -- - {0x3BC2, 0x7B}, // -- - {0x3BC4, 0xA2}, // -- - {0x3BC8, 0xBD}, // -- - {0x3BCA, 0xBD}, // -- - {0x4004, 0xC0}, // TXCLKESC_FREQ[15:0] - {0x4005, 0x06}, // - {0x400C, 0x00}, - {0x4018, 0x7F}, // TCLKPOST[15:0] - {0x401A, 0x37}, // TCLKPREPARE[15:0] - {0x401C, 0x37}, // TCLKTRAIL[15:0] - {0x401E, 0xF7}, // TCLKZERO[15:0] - {0x401F, 0x00}, - {0x4020, 0x3F}, // THSPREPARE[15:0] - {0x4022, 0x6F}, // THSZERO[15:0] - {0x4024, 0x3F}, // THSTRAIL[15:0] - {0x4026, 0x5F}, // THSEXIT[15:0] - {0x4028, 0x2F}, // TLPX[15:0] - {0x4074, 0x01}, // TLPX[15:0] - {0xffff, 0x10}, - {0x3000, 0x00}, //Operating - {0xffff, 0x10}, - {0x3002, 0x00}, //Master mode start - {0x3260, 0x00}, //Gain_Pgc_Fidmd -}; - -const static I2C_ARRAY Sensor_id_table[] = { - {0x3F12, 0x14}, // {address of ID, ID }, - {0x3F13, 0x75}, // {address of ID, ID }, -}; - -static I2C_ARRAY PatternTbl[] = { - {0x0000,0x00}, // colorbar pattern , bit 0 to enable -}; - -const static I2C_ARRAY expo_reg[] = { // SHS0 (For Linear) - {0x3052, 0x00}, - {0x3051, 0x00}, - {0x3050, 0x08}, -}; - -const static I2C_ARRAY expo_SHR0_reg[] = { // SHS0 (For LEF) - {0x3052, 0x00}, - {0x3051, 0x16}, - {0x3050, 0x22}, -}; - -const static I2C_ARRAY expo_SHR1_reg[] = { // SHS1 (For SEF) - //decreasing exposure ratio version. - {0x3056, 0x00}, - {0x3055, 0x00}, - {0x3054, 0x09}, -}; - -const static I2C_ARRAY vts_reg[] = { //VMAX - {0x3026, 0x00}, //bit0-3-->MSB - {0x3025, 0x08}, - {0x3024, 0xCA}, -}; - -const static I2C_ARRAY vts_reg_hdr[] = { - {0x3026, 0x00}, //bit0-3-->MSB - {0x3025, 0x0B}, - {0x3024, 0x3B}, -}; - -const I2C_ARRAY expo_RHS1_reg[] = { - //decreasing exposure ratio version. - {0x3062, 0x00}, - {0x3061, 0x00}, - {0x3060, 0x11}, -}; - -const static I2C_ARRAY gain_reg[] = { - {0x3090, 0x2A},//low bit - {0x3091, 0x00},//hcg mode,bit 4 -}; - -const static I2C_ARRAY gain_HDR_DOL_LEF_reg[] = { - {0x3090, 0x2A}, - {0x3091, 0x00}, -}; - -const static I2C_ARRAY gain_HDR_DOL_SEF_reg[] = { - {0x3092, 0x20}, - {0x3093, 0x00}, -}; - -//static int g_sensor_ae_min_gain = 1024; -static CUS_GAIN_GAP_ARRAY gain_gap_compensate[16] = { //compensate gain gap - {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} -}; - -///////////////////////////////////////////////////////////////// -// @@@@@@@ // -// @@ // -// @@ // -// @@@ // -// @ @@ // -// @@@@ // -// // -// Step 3 -- complete camera features // -// // -// camera set EV, MWB, orientation, contrast, sharpness // -// , saturation, and Denoise can work correctly. // -// // -///////////////////////////////////////////////////////////////// - -#if 0 -static CUS_INT_TASK_ORDER def_order = { - .RunLength = 9, - .Orders = { - CUS_INT_TASK_AE|CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_AWB|CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_AE|CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_AWB|CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_AE|CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_AWB|CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - }, -}; -#endif - -/////////////////// I2C function definition /////////////////// -#define SensorReg_Read(_reg,_data) (handle->i2c_bus->i2c_rx(handle->i2c_bus, &(handle->i2c_cfg),_reg,_data)) -#define SensorReg_Write(_reg,_data) (handle->i2c_bus->i2c_tx(handle->i2c_bus, &(handle->i2c_cfg),_reg,_data)) -#define SensorRegArrayW(_reg,_len) (handle->i2c_bus->i2c_array_tx(handle->i2c_bus, &(handle->i2c_cfg),(_reg),(_len))) -#define SensorRegArrayR(_reg,_len) (handle->i2c_bus->i2c_array_rx(handle->i2c_bus, &(handle->i2c_cfg),(_reg),(_len))) - -/////////////////// sensor hardware dependent /////////////////// -#if 0 -static int ISP_config_io(ms_cus_sensor *handle) { - ISensorIfAPI *sensor_if = handle->sensor_if_api; - - SENSOR_DMSG("[%s]", __FUNCTION__); - - sensor_if->HsyncPol(handle, handle->HSYNC_POLARITY); - sensor_if->VsyncPol(handle, handle->VSYNC_POLARITY); - sensor_if->ClkPol(handle, handle->PCLK_POLARITY); - sensor_if->BayerFmt(handle, handle->bayer_id); - sensor_if->DataBus(handle, handle->sif_bus); - - sensor_if->DataPrecision(handle, handle->data_prec); - sensor_if->FmtConv(handle, handle->data_mode); - return SUCCESS; -} -#endif - -static int cus_camsensor_release_handle(ms_cus_sensor *handle) -{ - return SUCCESS; -} - -/*******I5/I6 Support MCLK List******* - * CUS_CMU_CLK_27MHZ, - * CUS_CMU_CLK_21P6MHZ, - * CUS_CMU_CLK_12MHZ, - * CUS_CMU_CLK_5P4MHZ, - * CUS_CMU_CLK_36MHZ, - * CUS_CMU_CLK_54MHZ, - * CUS_CMU_CLK_43P2MHZ, - * CUS_CMU_CLK_61P7MHZ, - * CUS_CMU_CLK_72MHZ, - * CUS_CMU_CLK_48MHZ, - * CUS_CMU_CLK_24MHZ, - * CUS_CMU_CLK_37P125MHZ, - ******End of Support MCLK List*******/ -#if 0 -static CUS_MCLK_FREQ UseParaMclk(const char *mclk) -{ - if (strcmp(mclk, "27M") == 0) { - return CUS_CMU_CLK_27MHZ; - } else if (strcmp(mclk, "12M") == 0) { - return CUS_CMU_CLK_12MHZ; - } else if (strcmp(mclk, "36M") == 0) { - return CUS_CMU_CLK_36MHZ; - } else if (strcmp(mclk, "48M") == 0) { - return CUS_CMU_CLK_48MHZ; - } else if (strcmp(mclk, "54M") == 0) { - return CUS_CMU_CLK_54MHZ; - } else if (strcmp(mclk, "24M") == 0) { - return CUS_CMU_CLK_24MHZ; - } else if (strcmp(mclk, "37.125M") == 0) { - return CUS_CMU_CLK_37P125MHZ; - } - return Preview_MCLK_SPEED; -} -#endif - -static int pCus_poweron(ms_cus_sensor *handle, u32 idx) -{ - ISensorIfAPI *sensor_if = handle->sensor_if_api; - - //Sensor power on sequence - sensor_if->PowerOff(idx, handle->pwdn_POLARITY); // Powerdn Pull Low - sensor_if->Reset(idx, handle->reset_POLARITY); // Rst Pull Low - sensor_if->SetIOPad(idx, handle->sif_bus, handle->interface_attr.attr_mipi.mipi_lane_num); - sensor_if->SetCSI_Clk(idx, CUS_CSI_CLK_216M); - sensor_if->SetCSI_Lane(idx, handle->interface_attr.attr_mipi.mipi_lane_num, ENABLE); - sensor_if->SetCSI_LongPacketType(idx, 0, 0x1C00, 0); - - if (handle->interface_attr.attr_mipi.mipi_hdr_mode == CUS_HDR_MODE_SONY_DOL) { - sensor_if->SetCSI_hdr_mode(idx, handle->interface_attr.attr_mipi.mipi_hdr_mode, 1); - } - - sensor_if->PowerOff(idx, !handle->pwdn_POLARITY); - //Sensor board PWDN Enable, 1.8V & 2.9V need 30ms then Pull High - SENSOR_MSLEEP(31); - sensor_if->Reset(idx, !handle->reset_POLARITY); - SENSOR_UDELAY(1); - sensor_if->MCLK(idx, 1, handle->mclk); - SENSOR_DMSG("Sensor Power On finished\n"); - return SUCCESS; -} - -static int pCus_poweroff(ms_cus_sensor *handle, u32 idx) -{ - // power/reset low - ISensorIfAPI *sensor_if = handle->sensor_if_api; - - SENSOR_DMSG("[%s] reset low\n", __FUNCTION__); - sensor_if->PowerOff(idx, handle->pwdn_POLARITY); // Powerdn Pull Low - sensor_if->Reset(idx, handle->reset_POLARITY); // Rst Pull Low - sensor_if->MCLK(idx, 0, handle->mclk); - - sensor_if->SetCSI_Clk(idx, CUS_CSI_CLK_DISABLE); - if (handle->interface_attr.attr_mipi.mipi_hdr_mode == CUS_HDR_MODE_SONY_DOL) { - sensor_if->SetCSI_hdr_mode(idx, handle->interface_attr.attr_mipi.mipi_hdr_mode, 0); - } - - handle->orient = SENSOR_ORIT; - - return SUCCESS; -} - -/////////////////// Check Sensor Product ID ///////////////////////// -static int pCus_CheckSensorProductID(ms_cus_sensor *handle) -{ - u16 sen_id_msb, sen_id_lsb; - - /* Read Product ID */ - SensorReg_Read(0x3f12, (void*)&sen_id_lsb); - SensorReg_Read(0x3f13, (void*)&sen_id_msb);//CHIP_ID_r3F13 -#if 0 - if (sen_data != CHIP_ID) { - printk("[***ERROR***]Check Product ID Fail: 0x%x\n", sen_data); - return FAIL; - } -#endif - return SUCCESS; -} -//Get and check sensor ID -//if i2c error or sensor id does not match then return FAIL -static int pCus_GetSensorID(ms_cus_sensor *handle, u32 *id) -{ - int i,n; - int table_length= ARRAY_SIZE(Sensor_id_table); - I2C_ARRAY id_from_sensor[ARRAY_SIZE(Sensor_id_table)]; - - for(n=0;n8) - table_length=8; - - SENSOR_DMSG("\n\n[%s]", __FUNCTION__); - - for(n=0;n<4;++n) //retry , until I2C success - { - if(n>3) - return FAIL; - - if(SensorRegArrayR((I2C_ARRAY*)id_from_sensor,table_length) == SUCCESS) //read sensor ID from I2C - break; - else - SENSOR_MSLEEP(1); - } - - //convert sensor id to u32 format - for(i=0;iprivate_data; - int i,cnt=0; - //s16 sen_data; - - if (pCus_CheckSensorProductID(handle) == FAIL) { - return FAIL; - } - - for(i=0;i< ARRAY_SIZE(Sensor_init_table_4lane_linear);i++) - { - if(Sensor_init_table_4lane_linear[i].reg==0xffff) - { - SENSOR_MSLEEP(Sensor_init_table_4lane_linear[i].data); - } - else - { - cnt = 0; - while(SensorReg_Write(Sensor_init_table_4lane_linear[i].reg, Sensor_init_table_4lane_linear[i].data) != SUCCESS) - { - cnt++; - if(cnt>=10) - { - SENSOR_EMSG("[%s:%d]Sensor init fail!!\n", __FUNCTION__, __LINE__); - return FAIL; - } - //SENSOR_UDELAY(1); - } - //printk("\n reg 0x%x, 0x%x",Sensor_init_table_4lane_linear[i].reg, Sensor_init_table_4lane_linear[i].data); -#if 0 - SensorReg_Read(Sensor_init_table_4lane_linear[i].reg, &sen_data ); - if(Sensor_init_table_4lane_linear[i].data != sen_data) - printk("R/W Differ Reg: 0x%x\n",Sensor_init_table_4lane_linear[i].reg); - //printk("IMX415 reg: 0x%x, data: 0x%x, read: 0x%x.\n",Sensor_init_table_4lane_linear[i].reg, Sensor_init_table_4lane_linear[i].data, sen_data); -#endif - } - } - - return SUCCESS; -} - -static int pCus_init_8m_20fps_mipi4lane_linear(ms_cus_sensor *handle) -{ - //imx415_params *params = (imx415_params *)handle->private_data; - int i,cnt=0; - //s16 sen_data; - - if (pCus_CheckSensorProductID(handle) == FAIL) { - return FAIL; - } - - for(i=0;i< ARRAY_SIZE(Sensor_8m_20fps_init_table_4lane_linear);i++) - { - if(Sensor_8m_20fps_init_table_4lane_linear[i].reg==0xffff) - { - SENSOR_MSLEEP(Sensor_8m_20fps_init_table_4lane_linear[i].data); - } - else - { - cnt = 0; - while(SensorReg_Write(Sensor_8m_20fps_init_table_4lane_linear[i].reg, Sensor_8m_20fps_init_table_4lane_linear[i].data) != SUCCESS) - { - cnt++; - if(cnt>=10) - { - SENSOR_EMSG("[%s:%d]Sensor init fail!!\n", __FUNCTION__, __LINE__); - return FAIL; - } - //SENSOR_UDELAY(1); - } - //printk("\n reg 0x%x, 0x%x",Sensor_8m_20fps_init_table_4lane_linear[i].reg, Sensor_8m_20fps_init_table_4lane_linear[i].data); -#if 0 - SensorReg_Read(Sensor_8m_20fps_init_table_4lane_linear[i].reg, &sen_data ); - if(Sensor_8m_20fps_init_table_4lane_linear[i].data != sen_data) - printk("R/W Differ Reg: 0x%x\n",Sensor_8m_20fps_init_table_4lane_linear[i].reg); - //printk("IMX415 reg: 0x%x, data: 0x%x, read: 0x%x.\n",Sensor_8m_20fps_init_table_4lane_linear[i].reg, Sensor_8m_20fps_init_table_4lane_linear[i].data, sen_data); -#endif - } - } - - return SUCCESS; -} -static int pCus_init_6m_30fps_mipi4lane_linear(ms_cus_sensor *handle) -{ - //imx415_params *params = (imx415_params *)handle->private_data; - int i,cnt=0; - //s16 sen_data; - - if (pCus_CheckSensorProductID(handle) == FAIL) { - return FAIL; - } - - for(i=0;i< ARRAY_SIZE(Sensor_6m_30fps_init_table_4lane_linear);i++) - { - if(Sensor_6m_30fps_init_table_4lane_linear[i].reg==0xffff) - { - SENSOR_MSLEEP(Sensor_6m_30fps_init_table_4lane_linear[i].data); - } - else - { - cnt = 0; - while(SensorReg_Write(Sensor_6m_30fps_init_table_4lane_linear[i].reg, Sensor_6m_30fps_init_table_4lane_linear[i].data) != SUCCESS) - { - cnt++; - if(cnt>=10) - { - SENSOR_EMSG("[%s:%d]Sensor init fail!!\n", __FUNCTION__, __LINE__); - return FAIL; - } - //SENSOR_UDELAY(1); - } - //printk("\n reg 0x%x, 0x%x",Sensor_6m_30fps_init_table_4lane_linear[i].reg, Sensor_6m_30fps_init_table_4lane_linear[i].data); -#if 0 - SensorReg_Read(Sensor_6m_30fps_init_table_4lane_linear[i].reg, &sen_data ); - if(Sensor_6m_30fps_init_table_4lane_linear[i].data != sen_data) - printk("R/W Differ Reg: 0x%x\n",Sensor_6m_30fps_init_table_4lane_linear[i].reg); - //printk("IMX415 reg: 0x%x, data: 0x%x, read: 0x%x.\n",Sensor_6m_30fps_init_table_4lane_linear[i].reg, Sensor_6m_30fps_init_table_4lane_linear[i].data, sen_data); -#endif - } - } - - return SUCCESS; -} - -static int pCus_init_5p3m_30fps_mipi4lane_linear(ms_cus_sensor *handle) -{ - //imx415_params *params = (imx415_params *)handle->private_data; - int i,cnt=0; - //s16 sen_data; - - if (pCus_CheckSensorProductID(handle) == FAIL) { - return FAIL; - } - - for(i=0;i< ARRAY_SIZE(Sensor_5p3m_30fps_init_table_4lane_linear);i++) - { - if(Sensor_5p3m_30fps_init_table_4lane_linear[i].reg==0xffff) - { - SENSOR_MSLEEP(Sensor_5p3m_30fps_init_table_4lane_linear[i].data); - } - else - { - cnt = 0; - while(SensorReg_Write(Sensor_5p3m_30fps_init_table_4lane_linear[i].reg, Sensor_5p3m_30fps_init_table_4lane_linear[i].data) != SUCCESS) - { - cnt++; - if(cnt>=10) - { - SENSOR_EMSG("[%s:%d]Sensor init fail!!\n", __FUNCTION__, __LINE__); - return FAIL; - } - //SENSOR_UDELAY(1); - } - //printk("\n reg 0x%x, 0x%x",Sensor_5p3m_30fps_init_table_4lane_linear[i].reg, Sensor_5p3m_30fps_init_table_4lane_linear[i].data); -#if 0 - SensorReg_Read(Sensor_5p3m_30fps_init_table_4lane_linear[i].reg, &sen_data ); - if(Sensor_8m20_init_table_4lane_linear[i].data != sen_data) - printk("R/W Differ Reg: 0x%x\n",Sensor_5p3m_30fps_init_table_4lane_linear[i].reg); - //printk("IMX415 reg: 0x%x, data: 0x%x, read: 0x%x.\n",Sensor_5p3m_30fps_init_table_4lane_linear[i].reg, Sensor_5p3m_30fps_init_table_4lane_linear[i].data, sen_data); -#endif - } - } - - return SUCCESS; -} - -#if 0 -static int pCus_init_5m_25fps_mipi4lane_linear(ms_cus_sensor *handle) -{ - //imx415_params *params = (imx415_params *)handle->private_data; - int i,cnt=0; - //s16 sen_data; - - if (pCus_CheckSensorProductID(handle) == FAIL) { - return FAIL; - } - - for(i=0;i< ARRAY_SIZE(Sensor_5m_25fps_init_table_4lane_linear);i++) - { - if(Sensor_5m_25fps_init_table_4lane_linear[i].reg==0xffff) - { - SENSOR_MSLEEP(Sensor_5m_25fps_init_table_4lane_linear[i].data); - } - else - { - cnt = 0; - while(SensorReg_Write(Sensor_5m_25fps_init_table_4lane_linear[i].reg, Sensor_5m_25fps_init_table_4lane_linear[i].data) != SUCCESS) - { - cnt++; - if(cnt>=10) - { - SENSOR_EMSG("[%s:%d]Sensor init fail!!\n", __FUNCTION__, __LINE__); - return FAIL; - } - //SENSOR_UDELAY(1); - } - //printk("\n reg 0x%x, 0x%x",Sensor_5m_25fps_init_table_4lane_linear[i].reg, Sensor_5m_25fps_init_table_4lane_linear[i].data); -#if 0 - SensorReg_Read(Sensor_5m_25fps_init_table_4lane_linear[i].reg, &sen_data ); - if(Sensor_5m_25fps_init_table_4lane_linear[i].data != sen_data) - printk("R/W Differ Reg: 0x%x\n",Sensor_5m_25fps_init_table_4lane_linear[i].reg); - //printk("IMX415 reg: 0x%x, data: 0x%x, read: 0x%x.\n",Sensor_5m_25fps_init_table_4lane_linear[i].reg, Sensor_5m_25fps_init_table_4lane_linear[i].data, sen_data); -#endif - } - } - - return SUCCESS; -} -#endif - -static int pCus_init_5m_30fps_mipi4lane_linear(ms_cus_sensor *handle) -{ - //imx415_params *params = (imx415_params *)handle->private_data; - int i,cnt=0; - //s16 sen_data; - - if (pCus_CheckSensorProductID(handle) == FAIL) { - return FAIL; - } - - for(i=0;i< ARRAY_SIZE(Sensor_5m_30fps_init_table_4lane_linear);i++) - { - if(Sensor_5m_30fps_init_table_4lane_linear[i].reg==0xffff) - { - SENSOR_MSLEEP(Sensor_5m_30fps_init_table_4lane_linear[i].data); - } - else - { - cnt = 0; - while(SensorReg_Write(Sensor_5m_30fps_init_table_4lane_linear[i].reg, Sensor_5m_30fps_init_table_4lane_linear[i].data) != SUCCESS) - { - cnt++; - if(cnt>=10) - { - SENSOR_EMSG("[%s:%d]Sensor init fail!!\n", __FUNCTION__, __LINE__); - return FAIL; - } - //SENSOR_UDELAY(1); - } - //printk("\n reg 0x%x, 0x%x",Sensor_5m_30fps_init_table_4lane_linear[i].reg, Sensor_5m_30fps_init_table_4lane_linear[i].data); -#if 0 - SensorReg_Read(Sensor_5m_30fps_init_table_4lane_linear[i].reg, &sen_data ); - if(Sensor_5m_30fps_init_table_4lane_linear[i].data != sen_data) - printk("R/W Differ Reg: 0x%x\n",Sensor_5m_30fps_init_table_4lane_linear[i].reg); - //printk("IMX415 reg: 0x%x, data: 0x%x, read: 0x%x.\n",Sensor_5m_30fps_init_table_4lane_linear[i].reg, Sensor_5m_30fps_init_table_4lane_linear[i].data, sen_data); -#endif - } - } - - return SUCCESS; -} - - -static int pCus_init_4p8m_30fps_mipi4lane_linear(ms_cus_sensor *handle) -{ - //imx415_params *params = (imx415_params *)handle->private_data; - int i,cnt=0; - //s16 sen_data; - - if (pCus_CheckSensorProductID(handle) == FAIL) { - return FAIL; - } - - for(i=0;i< ARRAY_SIZE(Sensor_4p8m_30fps_init_table_4lane_linear);i++) - { - if(Sensor_4p8m_30fps_init_table_4lane_linear[i].reg==0xffff) - { - SENSOR_MSLEEP(Sensor_4p8m_30fps_init_table_4lane_linear[i].data); - } - else - { - cnt = 0; - while(SensorReg_Write(Sensor_4p8m_30fps_init_table_4lane_linear[i].reg, Sensor_4p8m_30fps_init_table_4lane_linear[i].data) != SUCCESS) - { - cnt++; - if(cnt>=10) - { - SENSOR_EMSG("[%s:%d]Sensor init fail!!\n", __FUNCTION__, __LINE__); - return FAIL; - } - //SENSOR_UDELAY(1); - } - //printk("\n reg 0x%x, 0x%x",Sensor_4p8m_30fps_init_table_4lane_linear[i].reg, Sensor_4p8m_30fps_init_table_4lane_linear[i].data); -#if 0 - SensorReg_Read(Sensor_4p8m_30fps_init_table_4lane_linear[i].reg, &sen_data ); - if(Sensor_4p8m_30fps_init_table_4lane_linear[i].data != sen_data) - printk("R/W Differ Reg: 0x%x\n",Sensor_4p8m_30fps_init_table_4lane_linear[i].reg); - //printk("IMX415 reg: 0x%x, data: 0x%x, read: 0x%x.\n",Sensor_4p8m_30fps_init_table_4lane_linear[i].reg, Sensor_4p8m_30fps_init_table_4lane_linear[i].data, sen_data); -#endif - } - } - - return SUCCESS; -} - -static int pCus_init_3p6m_30fps_mipi4lane_linear(ms_cus_sensor *handle) -{ - //imx415_params *params = (imx415_params *)handle->private_data; - int i,cnt=0; - //s16 sen_data; - - if (pCus_CheckSensorProductID(handle) == FAIL) { - return FAIL; - } - - for(i=0;i< ARRAY_SIZE(Sensor_3p6m_30fps_init_table_4lane_linear);i++) - { - if(Sensor_3p6m_30fps_init_table_4lane_linear[i].reg==0xffff) - { - SENSOR_MSLEEP(Sensor_3p6m_30fps_init_table_4lane_linear[i].data); - } - else - { - cnt = 0; - while(SensorReg_Write(Sensor_3p6m_30fps_init_table_4lane_linear[i].reg, Sensor_3p6m_30fps_init_table_4lane_linear[i].data) != SUCCESS) - { - cnt++; - if(cnt>=10) - { - SENSOR_EMSG("[%s:%d]Sensor init fail!!\n", __FUNCTION__, __LINE__); - return FAIL; - } - //SENSOR_UDELAY(1); - } - //printk("\n reg 0x%x, 0x%x",Sensor_3p6m_30fps_init_table_4lane_linear[i].reg, Sensor_3p6m_30fps_init_table_4lane_linear[i].data); -#if 0 - SensorReg_Read(Sensor_3p6m_30fps_init_table_4lane_linear[i].reg, &sen_data ); - if(Sensor_3p6m_30fps_init_table_4lane_linear[i].data != sen_data) - printk("R/W Differ Reg: 0x%x\n",Sensor_3p6m_30fps_init_table_4lane_linear[i].reg); - //printk("IMX415 reg: 0x%x, data: 0x%x, read: 0x%x.\n",Sensor_3p6m_30fps_init_table_4lane_linear[i].reg, Sensor_3p6m_30fps_init_table_4lane_linear[i].data, sen_data); -#endif - } - } - - return SUCCESS; -} - -static int pCus_init_2m_60fps_mipi4lane_linear(ms_cus_sensor *handle) -{ - //imx415_params *params = (imx415_params *)handle->private_data; - int i,cnt=0; - //s16 sen_data; - - if (pCus_CheckSensorProductID(handle) == FAIL) { - return FAIL; - } - - for(i=0;i< ARRAY_SIZE(Sensor_2m_60fps_init_table_4lane_linear);i++) - { - if(Sensor_2m_60fps_init_table_4lane_linear[i].reg==0xffff) - { - SENSOR_MSLEEP(Sensor_2m_60fps_init_table_4lane_linear[i].data); - } - else - { - cnt = 0; - while(SensorReg_Write(Sensor_2m_60fps_init_table_4lane_linear[i].reg, Sensor_2m_60fps_init_table_4lane_linear[i].data) != SUCCESS) - { - cnt++; - if(cnt>=10) - { - SENSOR_EMSG("[%s:%d]Sensor init fail!!\n", __FUNCTION__, __LINE__); - return FAIL; - } - //SENSOR_UDELAY(1); - } - } - } - - return SUCCESS; -} - -static int pCus_init_1m_120fps_mipi4lane_linear(ms_cus_sensor *handle) -{ - int i,cnt=0; - - if (pCus_CheckSensorProductID(handle) == FAIL) { - return FAIL; - } - - for(i=0;i< ARRAY_SIZE(Sensor_1m_120fps_init_table_4lane_linear);i++) - { - if(Sensor_1m_120fps_init_table_4lane_linear[i].reg==0xffff) - { - SENSOR_MSLEEP(Sensor_1m_120fps_init_table_4lane_linear[i].data); - } - else - { - cnt = 0; - while(SensorReg_Write(Sensor_1m_120fps_init_table_4lane_linear[i].reg, Sensor_1m_120fps_init_table_4lane_linear[i].data) != SUCCESS) - { - cnt++; - if(cnt>=10) - { - SENSOR_EMSG("[%s:%d]Sensor init fail!!\n", __FUNCTION__, __LINE__); - return FAIL; - } - //SENSOR_UDELAY(1); - } - } - } - - return SUCCESS; -} - -#if 0 -static int pCus_init_1m_135fps_mipi4lane_linear(ms_cus_sensor *handle) -{ - int i,cnt=0; - - if (pCus_CheckSensorProductID(handle) == FAIL) { - return FAIL; - } - - for(i=0;i< ARRAY_SIZE(Sensor_1m_135fps_init_table_4lane_linear);i++) - { - if(Sensor_1m_135fps_init_table_4lane_linear[i].reg==0xffff) - { - SENSOR_MSLEEP(Sensor_1m_135fps_init_table_4lane_linear[i].data); - } - else - { - cnt = 0; - while(SensorReg_Write(Sensor_1m_135fps_init_table_4lane_linear[i].reg, Sensor_1m_135fps_init_table_4lane_linear[i].data) != SUCCESS) - { - cnt++; - if(cnt>=10) - { - SENSOR_EMSG("[%s:%d]Sensor init fail!!\n", __FUNCTION__, __LINE__); - return FAIL; - } - //SENSOR_UDELAY(1); - } - } - } - - return SUCCESS; -} -#endif - -#if 0 -static int pCus_init_8m_30fps_mipi4lane_linear(ms_cus_sensor *handle) -{ - //imx415_params *params = (imx415_params *)handle->private_data; - int i,cnt=0; - //s16 sen_data; - - if (pCus_CheckSensorProductID(handle) == FAIL) { - return FAIL; - } - - for(i=0;i< ARRAY_SIZE(Sensor_8m_30fps_init_table_4lane_linear);i++) - { - if(Sensor_8m_30fps_init_table_4lane_linear[i].reg==0xffff) - { - SENSOR_MSLEEP(Sensor_8m_30fps_init_table_4lane_linear[i].data); - } - else - { - cnt = 0; - while(SensorReg_Write(Sensor_8m_30fps_init_table_4lane_linear[i].reg, Sensor_8m_30fps_init_table_4lane_linear[i].data) != SUCCESS) - { - cnt++; - if(cnt>=10) - { - SENSOR_EMSG("[%s:%d]Sensor init fail!!\n", __FUNCTION__, __LINE__); - return FAIL; - } - //SENSOR_UDELAY(1); - } - //printk("\n reg 0x%x, 0x%x",Sensor_8m_30fps_init_table_4lane_linear[i].reg, Sensor_8m_30fps_init_table_4lane_linear[i].data); -#if 0 - SensorReg_Read(Sensor_8m_30fps_init_table_4lane_linear[i].reg, &sen_data ); - if(Sensor_8m_30fps_init_table_4lane_linear[i].data != sen_data) - printk("R/W Differ Reg: 0x%x\n",Sensor_8m_30fps_init_table_4lane_linear[i].reg); - //printk("IMX415 reg: 0x%x, data: 0x%x, read: 0x%x.\n",Sensor_8m_30fps_init_table_4lane_linear[i].reg, Sensor_8m_30fps_init_table_4lane_linear[i].data, sen_data); -#endif - } - } - - return SUCCESS; -} -#endif - -static int pCus_init_mipi4lane_HDR_DOL(ms_cus_sensor *handle) -{ - //imx415_params *params = (imx415_params *)handle->private_data; - int i,cnt=0; - //s16 sen_data; - - if (pCus_CheckSensorProductID(handle)) { - return FAIL; - } - - for(i=0;i< ARRAY_SIZE(Sensor_init_table_4lane_HDR_DOL);i++) - { - if(Sensor_init_table_4lane_HDR_DOL[i].reg==0xffff) - { - SENSOR_MSLEEP(Sensor_init_table_4lane_HDR_DOL[i].data); - } - else - { - cnt = 0; - while(SensorReg_Write(Sensor_init_table_4lane_HDR_DOL[i].reg,Sensor_init_table_4lane_HDR_DOL[i].data) != SUCCESS) - { - cnt++; - if(cnt>=10) - { - SENSOR_EMSG("[%s:%d]Sensor init fail!!\n", __FUNCTION__, __LINE__); - return FAIL; - } - //SENSOR_UDELAY(1); - } - //printk("\n reg 0x%x, 0x%x",Sensor_init_table_4lane_HDR_DOL[i].reg, Sensor_init_table_4lane_HDR_DOL[i].data); -#if 0 - SensorReg_Read(Sensor_init_table_4lane_HDR_DOL[i].reg, &sen_data ); - if(Sensor_init_table_4lane_linear[i].data != sen_data) - printk("HDR R/W Differ Reg: 0x%x\n",Sensor_init_table_4lane_HDR_DOL[i].reg); - //printk("IMX415 reg: 0x%x, data: 0x%x, read: 0x%x.\n",Sensor_init_table_4lane_HDR_DOL[i].reg, Sensor_init_table_4lane_HDR_DOL[i].data, sen_data); -#endif - } - } - - SENSOR_DMSG("Sensor IMX415 HDR MODE Initial Finished\n"); - return SUCCESS; -} - -static int pCus_init_8m_20fps_mipi4lane_HDR_DOL(ms_cus_sensor *handle) -{ - int i,cnt=0; - - if (pCus_CheckSensorProductID(handle)) { - return FAIL; - } - - for(i=0;i< ARRAY_SIZE(Sensor_8m_20fps_init_table_4lane_HDR_DOL);i++) - { - if(Sensor_8m_20fps_init_table_4lane_HDR_DOL[i].reg==0xffff) - { - SENSOR_MSLEEP(Sensor_8m_20fps_init_table_4lane_HDR_DOL[i].data); - } - else - { - cnt = 0; - while(SensorReg_Write(Sensor_8m_20fps_init_table_4lane_HDR_DOL[i].reg,Sensor_8m_20fps_init_table_4lane_HDR_DOL[i].data) != SUCCESS) - { - cnt++; - if(cnt>=10) - { - SENSOR_EMSG("[%s:%d]Sensor init fail!!\n", __FUNCTION__, __LINE__); - return FAIL; - } - //SENSOR_UDELAY(1); - } - //printk("\n reg 0x%x, 0x%x",Sensor_8m_20fps_init_table_4lane_HDR_DOL[i].reg, Sensor_8m_20fps_init_table_4lane_HDR_DOL[i].data); -#if 0 - SensorReg_Read(Sensor_8m_20fps_init_table_4lane_HDR_DOL[i].reg, &sen_data ); - if(Sensor_8m_20fps_init_table_4lane_HDR_DOL[i].data != sen_data) - printk("HDR R/W Differ Reg: 0x%x\n",Sensor_8m_20fps_init_table_4lane_HDR_DOL[i].reg); - //printk("IMX415 reg: 0x%x, data: 0x%x, read: 0x%x.\n",Sensor_8m_20fps_init_table_4lane_HDR_DOL[i].reg, Sensor_8m_20fps_init_table_4lane_HDR_DOL[i].data, sen_data); -#endif - } - } - - return SUCCESS; -} - -static int pCus_init_8m_30fps_mipi4lane_HDR_DOL(ms_cus_sensor *handle) -{ - int i,cnt=0; - - if (pCus_CheckSensorProductID(handle)) { - return FAIL; - } - - for(i=0;i< ARRAY_SIZE(Sensor_8m_30fps_init_table_4lane_HDR_DOL);i++) - { - if(Sensor_8m_30fps_init_table_4lane_HDR_DOL[i].reg==0xffff) - { - SENSOR_MSLEEP(Sensor_8m_30fps_init_table_4lane_HDR_DOL[i].data); - } - else - { - cnt = 0; - while(SensorReg_Write(Sensor_8m_30fps_init_table_4lane_HDR_DOL[i].reg,Sensor_8m_30fps_init_table_4lane_HDR_DOL[i].data) != SUCCESS) - { - cnt++; - if(cnt>=10) - { - SENSOR_EMSG("[%s:%d]Sensor init fail!!\n", __FUNCTION__, __LINE__); - return FAIL; - } - //SENSOR_UDELAY(1); - } - //printk("\n reg 0x%x, 0x%x",Sensor_8m_30fps_init_table_4lane_HDR_DOL[i].reg, Sensor_8m_30fps_init_table_4lane_HDR_DOL[i].data); -#if 0 - SensorReg_Read(Sensor_8m_30fps_init_table_4lane_HDR_DOL[i].reg, &sen_data ); - if(Sensor_8m_30fps_init_table_4lane_HDR_DOL[i].data != sen_data) - printk("HDR R/W Differ Reg: 0x%x\n",Sensor_8m_30fps_init_table_4lane_HDR_DOL[i].reg); - //printk("IMX415 reg: 0x%x, data: 0x%x, read: 0x%x.\n",Sensor_8m_30fps_init_table_4lane_HDR_DOL[i].reg, Sensor_8m_30fps_init_table_4lane_HDR_DOL[i].data, sen_data); -#endif - } - } - - return SUCCESS; -} - -static int pCus_init_5m_30fps_mipi4lane_HDR_DOL(ms_cus_sensor *handle) -{ - int i,cnt=0; - - if (pCus_CheckSensorProductID(handle)) { - return FAIL; - } - - for(i=0;i< ARRAY_SIZE(Sensor_5m_30fps_init_table_4lane_HDR_DOL);i++) - { - if(Sensor_5m_30fps_init_table_4lane_HDR_DOL[i].reg==0xffff) - { - SENSOR_MSLEEP(Sensor_5m_30fps_init_table_4lane_HDR_DOL[i].data); - } - else - { - cnt = 0; - while(SensorReg_Write(Sensor_5m_30fps_init_table_4lane_HDR_DOL[i].reg,Sensor_5m_30fps_init_table_4lane_HDR_DOL[i].data) != SUCCESS) - { - cnt++; - if(cnt>=10) - { - SENSOR_EMSG("[%s:%d]Sensor init fail!!\n", __FUNCTION__, __LINE__); - return FAIL; - } - //SENSOR_UDELAY(1); - } - //printk("\n reg 0x%x, 0x%x",Sensor_init_table_4lane_linear[i].reg, Sensor_init_table_4lane_linear[i].data); -#if 0 - SensorReg_Read(Sensor_init_table_4lane_linear[i].reg, &sen_data ); - if(Sensor_init_table_4lane_linear[i].data != sen_data) - printk("HDR R/W Differ Reg: 0x%x\n",Sensor_init_table_4lane_linear[i].reg); - //printk("IMX415 reg: 0x%x, data: 0x%x, read: 0x%x.\n",Sensor_init_table_4lane_linear[i].reg, Sensor_init_table_4lane_linear[i].data, sen_data); -#endif - } - } - - return SUCCESS; -} - -#if 0 -static int pCus_init_5m_15fps_mipi4lane_HDR_DOL(ms_cus_sensor *handle) -{ - //imx415_params *params = (imx415_params *)handle->private_data; - int i,cnt=0; - //s16 sen_data; - - if (pCus_CheckSensorProductID(handle)) { - return FAIL; - } - - for(i=0;i< ARRAY_SIZE(Sensor_5m_15fps_init_table_4lane_HDR_DOL);i++) - { - if(Sensor_5m_15fps_init_table_4lane_HDR_DOL[i].reg==0xffff) - { - SENSOR_MSLEEP(Sensor_5m_15fps_init_table_4lane_HDR_DOL[i].data); - } - else - { - cnt = 0; - while(SensorReg_Write(Sensor_5m_15fps_init_table_4lane_HDR_DOL[i].reg,Sensor_5m_15fps_init_table_4lane_HDR_DOL[i].data) != SUCCESS) - { - cnt++; - if(cnt>=10) - { - SENSOR_EMSG("[%s:%d]Sensor init fail!!\n", __FUNCTION__, __LINE__); - return FAIL; - } - //SENSOR_UDELAY(1); - } - //printk("\n reg 0x%x, 0x%x",Sensor_init_table_4lane_linear[i].reg, Sensor_init_table_4lane_linear[i].data); - } - } - - printk("Sensor IMX415 HDR MODE Initial Finished\n"); - return SUCCESS; -} -#endif - -static int pCus_init_4p8m_30fps_mipi4lane_HDR_DOL(ms_cus_sensor *handle) -{ - int i,cnt=0; - - if (pCus_CheckSensorProductID(handle)) { - return FAIL; - } - for(i=0;i< ARRAY_SIZE(Sensor_4p8m_30fps_init_table_4lane_HDR_DOL);i++) - { - if(Sensor_4p8m_30fps_init_table_4lane_HDR_DOL[i].reg==0xffff) - { - SENSOR_MSLEEP(Sensor_4p8m_30fps_init_table_4lane_HDR_DOL[i].data); - } - else - { - cnt = 0; - while(SensorReg_Write(Sensor_4p8m_30fps_init_table_4lane_HDR_DOL[i].reg,Sensor_4p8m_30fps_init_table_4lane_HDR_DOL[i].data) != SUCCESS) - { - cnt++; - if(cnt>=10) - { - SENSOR_EMSG("[%s:%d]Sensor init fail!!\n", __FUNCTION__, __LINE__); - return FAIL; - } - //SENSOR_UDELAY(1); - } - //printk("\n reg 0x%x, 0x%x",Sensor_4p8m_30fps_init_table_4lane_HDR_DOL[i].reg, Sensor_4p8m_30fps_init_table_4lane_HDR_DOL[i].data); -#if 0 - SensorReg_Read(Sensor_4p8m_30fps_init_table_4lane_HDR_DOL[i].reg, &sen_data ); - if(Sensor_4p8m_30fps_init_table_4lane_HDR_DOL[i].data != sen_data) - printk("HDR R/W Differ Reg: 0x%x\n",Sensor_4p8m_30fps_init_table_4lane_HDR_DOL[i].reg); - //printk("IMX415 reg: 0x%x, data: 0x%x, read: 0x%x.\n",Sensor_4p8m_30fps_init_table_4lane_HDR_DOL[i].reg, Sensor_4p8m_30fps_init_table_4lane_HDR_DOL[i].data, sen_data); -#endif - } - } - return SUCCESS; -} - -static int pCus_init_4m_30fps_mipi4lane_HDR_DOL(ms_cus_sensor *handle) -{ - int i,cnt=0; - - if (pCus_CheckSensorProductID(handle)) { - return FAIL; - } - for(i=0;i< ARRAY_SIZE(Sensor_4m_30fps_init_table_4lane_HDR_DOL);i++) - { - if(Sensor_4m_30fps_init_table_4lane_HDR_DOL[i].reg==0xffff) - { - SENSOR_MSLEEP(Sensor_4m_30fps_init_table_4lane_HDR_DOL[i].data); - } - else - { - cnt = 0; - while(SensorReg_Write(Sensor_4m_30fps_init_table_4lane_HDR_DOL[i].reg,Sensor_4m_30fps_init_table_4lane_HDR_DOL[i].data) != SUCCESS) - { - cnt++; - if(cnt>=10) - { - SENSOR_EMSG("[%s:%d]Sensor init fail!!\n", __FUNCTION__, __LINE__); - return FAIL; - } - //SENSOR_UDELAY(1); - } - //printk("\n reg 0x%x, 0x%x",Sensor_4m_30fps_init_table_4lane_HDR_DOL[i].reg, Sensor_4m_30fps_init_table_4lane_HDR_DOL[i].data); -#if 0 - SensorReg_Read(Sensor_4m_30fps_init_table_4lane_HDR_DOL[i].reg, &sen_data ); - if(Sensor_4m_30fps_init_table_4lane_HDR_DOL[i].data != sen_data) - printk("HDR R/W Differ Reg: 0x%x\n",Sensor_4m_30fps_init_table_4lane_HDR_DOL[i].reg); - //printk("IMX415 reg: 0x%x, data: 0x%x, read: 0x%x.\n",Sensor_4m_30fps_init_table_4lane_HDR_DOL[i].reg, Sensor_4m_30fps_init_table_4lane_HDR_DOL[i].data, sen_data); -#endif - } - } - return SUCCESS; -} - -static int pCus_init_2m_30fps_mipi4lane_HDR_DOL(ms_cus_sensor *handle) -{ - int i,cnt=0; - - if (pCus_CheckSensorProductID(handle)) { - return FAIL; - } - for(i=0;i< ARRAY_SIZE(Sensor_2m_30fps_init_table_4lane_HDR_DOL);i++) - { - if(Sensor_2m_30fps_init_table_4lane_HDR_DOL[i].reg==0xffff) - { - SENSOR_MSLEEP(Sensor_2m_30fps_init_table_4lane_HDR_DOL[i].data); - } - else - { - cnt = 0; - while(SensorReg_Write(Sensor_2m_30fps_init_table_4lane_HDR_DOL[i].reg,Sensor_2m_30fps_init_table_4lane_HDR_DOL[i].data) != SUCCESS) - { - cnt++; - if(cnt>=10) - { - SENSOR_EMSG("[%s:%d]Sensor init fail!!\n", __FUNCTION__, __LINE__); - return FAIL; - } - //SENSOR_UDELAY(1); - } - //printk("\n reg 0x%x, 0x%x",Sensor_init_table_4lane_linear[i].reg, Sensor_2m_30fps_init_table_4lane_HDR_DOL[i].data); -#if 0 - SensorReg_Read(Sensor_2m_30fps_init_table_4lane_HDR_DOL[i].reg, &sen_data ); - if(Sensor_2m_30fps_init_table_4lane_HDR_DOL[i].data != sen_data) - printk("HDR R/W Differ Reg: 0x%x\n",Sensor_2m_30fps_init_table_4lane_HDR_DOL[i].reg); - //printk("IMX415 reg: 0x%x, data: 0x%x, read: 0x%x.\n",Sensor_2m_30fps_init_table_4lane_HDR_DOL[i].reg, Sensor_2m_30fps_init_table_4lane_HDR_DOL[i].data, sen_data); -#endif - } - } - return SUCCESS; -} - -static int pCus_GetVideoResNum( ms_cus_sensor *handle, u32 *ulres_num) -{ - *ulres_num = handle->video_res_supported.num_res; - - return SUCCESS; -} - -static int pCus_GetVideoRes(ms_cus_sensor *handle, u32 res_idx, cus_camsensor_res **res) -{ - u32 num_res = handle->video_res_supported.num_res; - - if (res_idx >= num_res) { - SENSOR_EMSG("[%s] Please check the number of resolutions supported by the sensor!\n", __FUNCTION__); - return FAIL; - } - - *res = &handle->video_res_supported.res[res_idx]; - - return SUCCESS; -} - -static int pCus_GetCurVideoRes(ms_cus_sensor *handle, u32 *cur_idx, cus_camsensor_res **res) -{ - u32 num_res = handle->video_res_supported.num_res; - - *cur_idx = handle->video_res_supported.ulcur_res; - - if (*cur_idx >= num_res) { - SENSOR_EMSG("[%s] Please check the number of resolutions supported by the sensor!\n", __FUNCTION__); - return FAIL; - } - - *res = &handle->video_res_supported.res[*cur_idx]; - - return SUCCESS; -} - -static int pCus_SetVideoRes(ms_cus_sensor *handle, u32 res_idx) -{ - imx415_params *params = (imx415_params *)handle->private_data; - u32 num_res = handle->video_res_supported.num_res; - - if (res_idx >= num_res) { - SENSOR_EMSG("[%s] Please check the number of resolutions supported by the sensor!\n", __FUNCTION__); - return FAIL; - } - - handle->video_res_supported.ulcur_res = res_idx; - - switch (res_idx) { - case 0: - handle->video_res_supported.ulcur_res = 0; - handle->pCus_sensor_init = pCus_init_8m_20fps_mipi4lane_linear; - vts_30fps = 2813; - params->expo.vts = vts_30fps; - params->expo.fps = 20; - Preview_line_period = 17778; // 49.86ms/2813 = 17725ns - handle->data_prec = CUS_DATAPRECISION_10; - break; - case 1: - handle->video_res_supported.ulcur_res = 1; - handle->pCus_sensor_init = pCus_init_6m_30fps_mipi4lane_linear; - vts_30fps = 2250; - params->expo.vts = vts_30fps; - params->expo.fps = 30; - Preview_line_period = 14815; - handle->data_prec = CUS_DATAPRECISION_10; - break; - case 2: - handle->video_res_supported.ulcur_res = 2; - handle->pCus_sensor_init = pCus_init_5p3m_30fps_mipi4lane_linear; - vts_30fps = 2250; - params->expo.vts = vts_30fps; - params->expo.fps = 30; - Preview_line_period = 14815; - handle->data_prec = CUS_DATAPRECISION_10; - break; - case 3: - handle->video_res_supported.ulcur_res = 3; - handle->pCus_sensor_init = pCus_init_5m_30fps_mipi4lane_linear; - vts_30fps = 2144; - params->expo.vts = vts_30fps; - params->expo.fps = 25; - Preview_line_period = 15547; - handle->data_prec = CUS_DATAPRECISION_10; - break; - case 4: - handle->video_res_supported.ulcur_res = 4; - handle->pCus_sensor_init = pCus_init_4p8m_30fps_mipi4lane_linear; - vts_30fps = 2250; - params->expo.vts = vts_30fps; - params->expo.fps = 25; - Preview_line_period = 14815; - handle->data_prec = CUS_DATAPRECISION_10; - break; - case 5: - handle->video_res_supported.ulcur_res = 5; - handle->pCus_sensor_init = pCus_init_3p6m_30fps_mipi4lane_linear; - vts_30fps = 2250; - params->expo.vts = vts_30fps; - params->expo.fps = 30; - Preview_line_period = 14815; - handle->data_prec = CUS_DATAPRECISION_10; - break; - case 6: - handle->video_res_supported.ulcur_res = 6; - handle->pCus_sensor_init = pCus_init_2m_60fps_mipi4lane_linear; - vts_30fps = 2296; - params->expo.vts = vts_30fps; - params->expo.fps = 60; - Preview_line_period = 7259; - handle->data_prec = CUS_DATAPRECISION_12; - break; - case 7: - handle->video_res_supported.ulcur_res = 7; - handle->pCus_sensor_init = pCus_init_1m_120fps_mipi4lane_linear; - vts_30fps = 1644; - params->expo.vts = vts_30fps; - params->expo.fps = 120; - Preview_line_period = 4866; // 8ms/1644 = 4866ns; - handle->data_prec = CUS_DATAPRECISION_12; - break; -#if 0 - case 8: - handle->video_res_supported.ulcur_res = 8; - handle->pCus_sensor_init = pCus_init_1m_135fps_mipi4lane_linear; - vts_30fps = 1507; - params->expo.vts = vts_30fps; - params->expo.fps = 120; - Preview_line_period = 4645; // 7ms/1507 = 4645ns; - handle->data_prec = CUS_DATAPRECISION_12; - break; -#endif - default: - handle->video_res_supported.ulcur_res = 0; - handle->pCus_sensor_init = pCus_init_8m_20fps_mipi4lane_linear; - vts_30fps = 2813; - params->expo.vts = vts_30fps; - params->expo.fps = 20; - Preview_line_period = 17725; // 49.86ms/2813 = 17725ns - handle->data_prec = CUS_DATAPRECISION_10; - break; - } - return SUCCESS; -} - -static int pCus_SetVideoRes_HDR_DOL_LEF(ms_cus_sensor *handle, u32 res_idx) -{ - u32 num_res = handle->video_res_supported.num_res; - - if (res_idx >= num_res) { - SENSOR_EMSG("[%s] Please check the number of resolutions supported by the sensor!\n", __FUNCTION__); - return FAIL; - } - - handle->video_res_supported.ulcur_res = res_idx; - - switch (res_idx) { - case HDR_RES_1: - case HDR_RES_7: - handle->data_prec = CUS_DATAPRECISION_12; - break; - case HDR_RES_2: - case HDR_RES_3: - case HDR_RES_4: - case HDR_RES_5: - case HDR_RES_6: - handle->data_prec = CUS_DATAPRECISION_10; - break; - default: - break; - } - return SUCCESS; -} - -static int pCus_SetVideoRes_HDR_DOL_SEF(ms_cus_sensor *handle, u32 res_idx) -{ - imx415_params *params = (imx415_params *)handle->private_data; - u32 num_res = handle->video_res_supported.num_res; - - if (res_idx >= num_res) { - SENSOR_EMSG("[%s] Please check the number of resolutions supported by the sensor!\n", __FUNCTION__); - return FAIL; - } - - handle->video_res_supported.ulcur_res = res_idx; - - switch (res_idx) { - case HDR_RES_1: - handle->pCus_sensor_init = pCus_init_mipi4lane_HDR_DOL; - vts_30fps_HDR_DOL_4lane = 2250; - params->expo.vts = vts_30fps_HDR_DOL_4lane; - params->expo.fps = 15; - Preview_line_period_HDR_DOL_4LANE = 29630; - handle->data_prec = CUS_DATAPRECISION_12; - params->min_rhs1 = 437; // 4n+1 fix to 269, 337 //5ms: 429 - break; - case HDR_RES_2: - handle->pCus_sensor_init = pCus_init_8m_20fps_mipi4lane_HDR_DOL; - vts_30fps_HDR_DOL_4lane = 3450; - params->expo.vts = vts_30fps_HDR_DOL_4lane; - params->expo.fps = 20; - Preview_line_period_HDR_DOL_4LANE = 14493; - handle->data_prec = CUS_DATAPRECISION_10; - params->min_rhs1 = 437; // 4n+1 fix to 269, 337 //5ms: 429 - break; - case HDR_RES_3: - handle->pCus_sensor_init = pCus_init_8m_30fps_mipi4lane_HDR_DOL; - vts_30fps_HDR_DOL_4lane = 2300; - params->expo.vts = vts_30fps_HDR_DOL_4lane; - params->expo.fps = 30; - Preview_line_period_HDR_DOL_4LANE = 14493; - handle->data_prec = CUS_DATAPRECISION_10; - params->min_rhs1 = 437; // 4n+1 fix to 269, 337 //5ms: 429 - break; - case HDR_RES_4: - handle->pCus_sensor_init = pCus_init_5m_30fps_mipi4lane_HDR_DOL; - vts_30fps_HDR_DOL_4lane = 2300; - params->expo.vts = vts_30fps_HDR_DOL_4lane; - params->expo.fps = 30; - Preview_line_period_HDR_DOL_4LANE = 14493; - handle->data_prec = CUS_DATAPRECISION_10; - params->min_rhs1 = 437; // 4n+1 fix to 269, 337 //5ms: 429 - break; - case HDR_RES_5: - handle->pCus_sensor_init = pCus_init_4p8m_30fps_mipi4lane_HDR_DOL; - vts_30fps_HDR_DOL_4lane = 2300; - params->expo.vts = vts_30fps_HDR_DOL_4lane; - params->expo.fps = 30; - Preview_line_period_HDR_DOL_4LANE = 14493; - handle->data_prec = CUS_DATAPRECISION_10; - params->min_rhs1 = 365; // 4n+1 fix to 269, 337 //5ms: 429 - break; - case HDR_RES_6: - handle->pCus_sensor_init = pCus_init_4m_30fps_mipi4lane_HDR_DOL; - vts_30fps_HDR_DOL_4lane = 2300; - params->expo.vts = vts_30fps_HDR_DOL_4lane; - params->expo.fps = 30; - Preview_line_period_HDR_DOL_4LANE = 14493; - handle->data_prec = CUS_DATAPRECISION_10; - params->min_rhs1 = 365; // 4ms: 343 //5ms: 429 - break; - case HDR_RES_7: - handle->pCus_sensor_init = pCus_init_2m_30fps_mipi4lane_HDR_DOL; - vts_30fps_HDR_DOL_4lane = 2296; - params->expo.vts = vts_30fps_HDR_DOL_4lane; - params->expo.fps = 30; - Preview_line_period_HDR_DOL_4LANE = 14518; - handle->data_prec = CUS_DATAPRECISION_12; - params->min_rhs1 = 437; // 4n+1 fix to 269, 337 //5ms: 429 - break; - default: - break; - } - - return SUCCESS; -} - -static int pCus_GetOrien(ms_cus_sensor *handle, CUS_CAMSENSOR_ORIT *orit) -{ - s16 sen_data; - - //Read SENSOR MIRROR-FLIP STATUS - SensorReg_Read(MIRROR_FLIP, (void*)&sen_data); - - switch(sen_data & SENSOR_MIRROR_FLIP_EN) - { - case SENSOR_NOR: - *orit = CUS_ORIT_M0F0; - break; - case SENSOR_FLIP_EN: - *orit = CUS_ORIT_M0F1; - break; - case SENSOR_MIRROR_EN: - *orit = CUS_ORIT_M1F0; - break; - case SENSOR_MIRROR_FLIP_EN: - *orit = CUS_ORIT_M1F1; - break; - } - return SUCCESS; -} - -static int pCus_SetOrien(ms_cus_sensor *handle, CUS_CAMSENSOR_ORIT orit) -{ - imx415_params *params = (imx415_params *)handle->private_data; - - handle->orient = orit; - params->orien_dirty = true; - - return SUCCESS; -} - -static int DoOrien(ms_cus_sensor *handle, CUS_CAMSENSOR_ORIT orit) -{ - s16 sen_data; - //Read SENSOR MIRROR-FLIP STATUS - SensorReg_Read(MIRROR_FLIP, (void*)&sen_data); - sen_data &= ~(SENSOR_MIRROR_FLIP_EN); - - switch(orit) - { - case CUS_ORIT_M0F0: - //sen_data |= SENSOR_NOR; - handle->orient = CUS_ORIT_M0F0; - break; - case CUS_ORIT_M1F0: - sen_data |= SENSOR_MIRROR_EN; - handle->orient = CUS_ORIT_M1F0; - break; - case CUS_ORIT_M0F1: - sen_data |= SENSOR_FLIP_EN; - handle->orient = CUS_ORIT_M0F1; - break; - case CUS_ORIT_M1F1: - sen_data |= SENSOR_MIRROR_FLIP_EN; - handle->orient = CUS_ORIT_M1F1; - break; - default : - handle->orient = CUS_ORIT_M0F0; - break; - } - //Write SENSOR MIRROR-FLIP STATUS - SensorReg_Write(MIRROR_FLIP, sen_data); - - return SUCCESS; -} - -static int pCus_GetFPS(ms_cus_sensor *handle) -{ - imx415_params *params = (imx415_params *)handle->private_data; - u32 max_fps = handle->video_res_supported.res[handle->video_res_supported.ulcur_res].max_fps; - u32 tVts = (params->tVts_reg[0].data << 16) | (params->tVts_reg[1].data << 8) | (params->tVts_reg[2].data << 0); - - if (params->expo.fps >= 1000) - params->expo.preview_fps = (vts_30fps*max_fps*1000)/tVts; - else - params->expo.preview_fps = (vts_30fps*max_fps)/tVts; - - return params->expo.preview_fps; -} - -static int pCus_SetFPS(ms_cus_sensor *handle, u32 fps) -{ - //u32 vts = 0, cur_vts_30fps = 0; - imx415_params *params = (imx415_params *)handle->private_data; - u32 max_fps = handle->video_res_supported.res[handle->video_res_supported.ulcur_res].max_fps; - u32 min_fps = handle->video_res_supported.res[handle->video_res_supported.ulcur_res].min_fps; - //pr_info("[%s] leslie_fps,maxfps,minfps : %d,%d,%d\n\n", __FUNCTION__,fps,max_fps,min_fps); - //cur_vts_30fps = vts_30fps; - //pr_info("[%s] leslie_vts_30fps : %u\n\n", __FUNCTION__,vts_30fps); - if(fps>=min_fps && fps <= max_fps){ - if (CUS_CMU_CLK_36MHZ == handle->mclk) { - fps = fps>29?29:fps; //limit fps at 29 fps due to MCLK=36MHz - params->expo.vts= (vts_30fps*29091 + fps * 500)/(fps * 1000); - } - else - params->expo.vts= (vts_30fps*(max_fps*1000) + fps * 500)/(fps * 1000); - }else if(fps>=(min_fps*1000) && fps <= (max_fps*1000)){ - if (CUS_CMU_CLK_36MHZ == handle->mclk) { - fps = fps>29091?29091:fps; //limit fps at 29.091 fps due to MCLK=36MHz - params->expo.vts= (vts_30fps*29091 + (fps>>1))/fps; - } - else - params->expo.vts= (vts_30fps*(max_fps*1000) + (fps>>1))/fps; - }else{ - SENSOR_DMSG("[%s] FPS %d out of range.\n",__FUNCTION__,fps); - return FAIL; - } - //pr_info("[%s] leslie_vts : %u\n\n", __FUNCTION__,params->expo.vts); - if(params->expo.expo_lines > params->expo.vts - 4){ - //vts = params->expo.expo_lines + 4; -#if 0 //Update FPS Status - if(fps>=3 && fps <= 30) - fps = (vts_30fps*30000)/(params->expo.vts * 1000 - 500); - else if(fps>=3000 && fps <= 30000) - fps = (vts_30fps*30000)/(params->expo.vts - (500 / 1000)); -#endif - }else{ - //vts = params->expo.vts; - } - - params->expo.fps = fps; - params->dirty = true; - - pCus_SetAEUSecs(handle, params->expo.expo_lef_us); - - return SUCCESS; -} - -static int pCus_GetFPS_HDR_DOL_SEF(ms_cus_sensor *handle) -{ - imx415_params *params = (imx415_params *)handle->private_data; - u32 cur_vts_30fps = vts_30fps_HDR_DOL_4lane; - u32 max_fps = handle->video_res_supported.res[handle->video_res_supported.ulcur_res].max_fps; - u32 tVts = (params->tVts_reg[0].data << 16) | (params->tVts_reg[1].data << 8) | (params->tVts_reg[2].data << 0); - - if (params->expo.fps >= 1000) - params->expo.preview_fps = (cur_vts_30fps*max_fps*1000)/tVts; - else - params->expo.preview_fps = (cur_vts_30fps*max_fps)/tVts; - - return params->expo.preview_fps; -} - -static int pCus_SetFPS_HDR_DOL_SEF(ms_cus_sensor *handle, u32 fps) -{ - u32 cur_vts_30fps = 0; - imx415_params *params = (imx415_params *)handle->private_data; - u32 max_fps = handle->video_res_supported.res[handle->video_res_supported.ulcur_res].max_fps; - u32 min_fps = handle->video_res_supported.res[handle->video_res_supported.ulcur_res].min_fps; - //cur_vts_30fps = imx415_mipi_hdr[0].senout.height; - cur_vts_30fps=vts_30fps_HDR_DOL_4lane; - if(fps>=min_fps && fps <= max_fps){ - if (CUS_CMU_CLK_36MHZ == handle->mclk) { - fps = fps > 14 ? 14 : fps;//limit fps at 29 fps due to MCLK=36MHz - params->expo.vts= (cur_vts_30fps*14545 + fps * 500 )/ (fps * 1000); - } - else - params->expo.vts= (cur_vts_30fps*(max_fps*1000) + fps * 500 )/ (fps * 1000); - - }else if(fps>=(min_fps*1000) && fps <= (max_fps*1000)){ - if (CUS_CMU_CLK_36MHZ == handle->mclk) { - fps = fps > 14545 ? 14545 : fps;//limit fps at 29.091 fps due to MCLK=36MHz - params->expo.vts= (cur_vts_30fps*14545 + (fps >> 1))/fps; - } - else - params->expo.vts= (cur_vts_30fps*(max_fps*1000) + (fps >> 1))/fps; - }else{ - SENSOR_DMSG("[%s] FPS %d out of range.\n",__FUNCTION__,fps); - return FAIL; - } - - if(params->expo.expo_lines > params->expo.vts - 4){ - //vts = params->expo.expo_lines + 4; -#if 0 //Update FPS Status - if(fps>=3 && fps <= 30) - fps = (vts_30fps*30000)/(params->expo.vts * 1000 - 500); - else if(fps>=3000 && fps <= 30000) - fps = (vts_30fps*30000)/(params->expo.vts - (500 / 1000)); -#endif - }else{ - //vts = params->expo.vts; - } - - params->expo.fps = fps; - //params->expo.vts = vts; - params->dirty = true; - - pCus_SetAEUSecsHDR_DOL_SEF(handle, params->expo.expo_sef_us); - - return SUCCESS; -} - -/////////////////////////////////////////////////////////////////////// -// auto exposure -/////////////////////////////////////////////////////////////////////// -// unit: micro seconds -//AE status notification -static int pCus_AEStatusNotify(ms_cus_sensor *handle, CUS_CAMSENSOR_AE_STATUS_NOTIFY status) -{ - imx415_params *params = (imx415_params *)handle->private_data; - //ISensorIfAPI2 *sensor_if1 = handle->sensor_if_api2; - - switch(status) - { - case CUS_FRAME_INACTIVE: - break; - case CUS_FRAME_ACTIVE: - if(params->dirty || params->orien_dirty) { - SensorReg_Write(0x3001,1); // Global hold on - if(params->dirty) { - SensorRegArrayW((I2C_ARRAY*)params->tExpo_reg, ARRAY_SIZE(expo_reg)); - SensorRegArrayW((I2C_ARRAY*)params->tGain_reg, ARRAY_SIZE(gain_reg)); - SensorRegArrayW((I2C_ARRAY*)params->tVts_reg, ARRAY_SIZE(vts_reg)); - params->dirty = false; - } - - if(params->orien_dirty) { - DoOrien(handle, handle->orient); - params->orien_dirty = false; - } - SensorReg_Write(0x3001,0); // Global hold off - } - break; - default : - break; - } - return SUCCESS; -} - -static int pCus_AEStatusNotifyHDR_DOL_SEF(ms_cus_sensor *handle, CUS_CAMSENSOR_AE_STATUS_NOTIFY status) -{ - //imx415_params *params = (imx415_params *)handle->private_data; - - switch(status) - { - case CUS_FRAME_INACTIVE: - break; - case CUS_FRAME_ACTIVE: -#if 0 - if(params->dirty || params->orien_dirty) { - SensorReg_Write(0x3001,1); - - if(params->dirty) { - //SensorRegArrayW((I2C_ARRAY*)params->tExpo_reg, ARRAY_SIZE(expo_reg)); - //SensorRegArrayW((I2C_ARRAY*)params->tGain_reg, ARRAY_SIZE(gain_reg)); - //SensorRegArrayW((I2C_ARRAY*)params->tVts_reg, ARRAY_SIZE(vts_reg)); - params->dirty = false; - } - if(params->orien_dirty) { - DoOrien(handle, handle->orient); - params->orien_dirty = false; - } - SensorReg_Write(0x3001,0); - } -#endif - break; - default : - break; - } - return SUCCESS; -} - -static int pCus_GetAEUSecs(ms_cus_sensor *handle, u32 *us) -{ - u32 lines = 0; - imx415_params *params = (imx415_params *)handle->private_data; - - lines |= (u32)(params->tExpo_reg[0].data & 0x03) << 16; - lines |= (u32)(params->tExpo_reg[1].data & 0xff) << 8; - lines |= (u32)(params->tExpo_reg[2].data & 0xff) << 0; - - *us = (lines * Preview_line_period) / 1000; - - SENSOR_DMSG("[%s] sensor expo lines/us %u,%u us\n", __FUNCTION__, lines, *us); - - return SUCCESS; -} - -static int pCus_SetAEUSecs(ms_cus_sensor *handle, u32 us) -{ - u32 expo_lines = 0, vts = 0, SHR0 = 0; - imx415_params *params = (imx415_params *)handle->private_data; - - params->expo.expo_lef_us = us; - expo_lines = (1000*us)/Preview_line_period; - - if (expo_lines > params->expo.vts) { - vts = expo_lines + 8; - } - else - vts = params->expo.vts; - SHR0 = vts - expo_lines; - - if (SHR0 <= 12 ) // 8+4 - SHR0 = 8; - else - SHR0 -= 4; - - params->expo.expo_lines = expo_lines; - //params->expo.vts = vts; - - SENSOR_DMSG("[%s] us %u, SHR0 %u, vts %u\n", __FUNCTION__, - us, \ - SHR0, \ - vts - ); - //pr_info("[%s] leslie_shutter,expo_lines,params_expo_lines : %d,%d,%d\n\n", __FUNCTION__,us,expo_lines,params->expo.expo_lines); - //pr_info("[%s] leslie_shutter_vts : %u,%u\n\n", __FUNCTION__,params->expo.vts,vts); - params->tExpo_reg[0].data = (SHR0>>16) & 0x0003; - params->tExpo_reg[1].data = (SHR0>>8) & 0x00ff; - params->tExpo_reg[2].data = (SHR0>>0) & 0x00ff; - - params->tVts_reg[0].data = (vts >> 16) & 0x0003; - params->tVts_reg[1].data = (vts >> 8) & 0x00ff; - params->tVts_reg[2].data = (vts >> 0) & 0x00ff; - - params->dirty = true; - return SUCCESS; -} - -static int pCus_SetAEUSecsHDR_DOL_SEF(ms_cus_sensor *handle, u32 us) -{ - u32 expo_line_sef = 0; - u32 cur_line_period = Preview_line_period_HDR_DOL_4LANE; - //u32 cur_vts_30fps = vts_30fps_HDR_DOL_4lane; - imx415_params *params = (imx415_params *)handle->private_data; - - cur_line_period = Preview_line_period_HDR_DOL_4LANE; - //cur_vts_30fps =vts_30fps_HDR_DOL_4lane; - expo_line_sef = (1000 * us + (cur_line_period >> 1)) / cur_line_period; - params->expo.expo_sef_us = us; - //params->min_rhs1 = 437; // 4n+1 fix to 269, 337 //5ms: 429 - - params->min_shr1 = params->min_rhs1 - expo_line_sef; - if((expo_line_sef > params->min_rhs1) || ((params->min_shr1) < 9)) - params->min_shr1 = 9; - params->min_shr1 = ((params->min_shr1 >> 1) << 1) + 1; - - SENSOR_DMSG("[%s] us %u, expo_line_sef %u rhs %u shr1 %u\n", __FUNCTION__, - us, \ - expo_line_sef, \ - params->min_rhs1, \ - params->min_shr1 - ); - - params->tRHS1_reg[0].data = (params->min_rhs1 >>16) & 0x03; - params->tRHS1_reg[1].data = (params->min_rhs1 >>8) & 0xff; - params->tRHS1_reg[2].data = (params->min_rhs1 >>0) & 0xff; - - params->tSHR1_reg[0].data = (params->min_shr1 >> 16) & 0x0003; - params->tSHR1_reg[1].data = (params->min_shr1 >> 8) & 0x00ff; - params->tSHR1_reg[2].data = (params->min_shr1 >> 0) & 0x00ff; - - params->dirty = true; - return SUCCESS; -} - -// Gain: 1x = 1024 -static int pCus_GetAEGain(ms_cus_sensor *handle, u32* gain) -{ - imx415_params *params = (imx415_params *)handle->private_data; -#if 0 - u16 temp_gain; - - temp_gain=gain_reg[0].data; - *gain=(u32)(10^((temp_gain*3)/200))*1024; - if (gain_reg[1].data & 0x10) - *gain = (*gain) * 2; -#endif - *gain = params->expo.final_gain; - SENSOR_DMSG("[%s] get gain %u\n", __FUNCTION__, *gain); - - return SUCCESS; -} - -static int pCus_SetAEGain(ms_cus_sensor *handle, u32 gain) -{ - imx415_params *params = (imx415_params *)handle->private_data; - u32 i; - CUS_GAIN_GAP_ARRAY* Sensor_Gain_Linearity; - u64 gain_double; - - params->expo.final_gain = gain; - if(gain < SENSOR_MIN_GAIN) - gain = SENSOR_MIN_GAIN; - else if(gain >= SENSOR_MAX_GAIN) - gain = SENSOR_MAX_GAIN; - - Sensor_Gain_Linearity = gain_gap_compensate; - - for(i = 0; i < sizeof(gain_gap_compensate)/sizeof(CUS_GAIN_GAP_ARRAY); i++){ - if (Sensor_Gain_Linearity[i].gain == 0) - break; - if((gain>Sensor_Gain_Linearity[i].gain) && (gain < (Sensor_Gain_Linearity[i].gain + Sensor_Gain_Linearity[i].offset))){ - gain=Sensor_Gain_Linearity[i].gain; - break; - } - } - gain_double = 20 * (intlog10(gain) - intlog10(1024)); - gain_double = (u16)((gain_double * 10) >> 24) / 3; - - params->tGain_reg[0].data = gain_double & 0xff; - params->tGain_reg[1].data = (gain_double >> 8) & 0xff; - -#if DEBUG_INFO - SENSOR_DMSG("[%s]gain %u gain_double %llu\n",__FUNCTION__, gain, gain_double); -#endif - - SENSOR_DMSG("[%s] set gain/reg=%u/0x%x 0x%x\n", __FUNCTION__, gain,params->tGain_reg[0].data, gain,params->tGain_reg[1].dat); - params->dirty = true; - return SUCCESS; -} - -static void pCus_SetAEGainHDR_DOL_Calculate(u32 gain, u16 *gain_reg) -{ - //double gain_double; - u64 gain_double; - - if(gain < SENSOR_MIN_GAIN){ - gain = SENSOR_MIN_GAIN; - } - else if(gain >= SENSOR_MAX_GAIN){ - gain = SENSOR_MAX_GAIN; - } - gain_double = 20 * (intlog10(gain) - intlog10(1024)); - *gain_reg =(u16)((gain_double * 10) >> 24) / 3; -} - -static int pCus_SetAEGainHDR_DOL_SEF1(ms_cus_sensor *handle, u32 gain) -{ - imx415_params *params = (imx415_params *)handle->private_data; - u16 gain_reg = 0; - - pCus_SetAEGainHDR_DOL_Calculate(gain, &gain_reg); - params->tGain_hdr_dol_sef_reg[0].data = gain_reg & 0xff; - params->tGain_hdr_dol_sef_reg[1].data = (gain_reg >> 8) & 0xff; - - SENSOR_DMSG("[%s] set gain/reg=%u/0x%x 0x%x\n", __FUNCTION__, gain, params->tGain_hdr_dol_sef_reg[0].data, params->tGain_hdr_dol_sef_reg[1].data); - - params->dirty = true; - return SUCCESS; -} - -static int pCus_GetAEMinMaxUSecs(ms_cus_sensor *handle, u32 *min, u32 *max) -{ - *min = 1; - *max = 1000000/imx415_mipi_linear[0].senout.min_fps; - return SUCCESS; -} - -static int pCus_GetAEMinMaxGain(ms_cus_sensor *handle, u32 *min, u32 *max) -{ - *min = SENSOR_MIN_GAIN;//handle->sat_mingain; - *max = SENSOR_MAX_GAIN;//10^(72db/20)*1024; - return SUCCESS; -} - -static int IMX415_GetShutterInfo(struct __ms_cus_sensor* handle,CUS_SHUTTER_INFO *info) -{ - info->max = 1000000000/imx415_mipi_linear[0].senout.min_fps;// - info->min = (Preview_line_period * 1); - info->step = Preview_line_period; - return SUCCESS; -} - -static int IMX415_GetShutterInfo_HDR_DOL_SEF(struct __ms_cus_sensor* handle,CUS_SHUTTER_INFO *info) -{ - imx415_params *params = (imx415_params *)handle->private_data; - info->max = Preview_line_period_HDR_DOL_4LANE * params->min_rhs1; - info->min = (Preview_line_period_HDR_DOL_4LANE * 5); - info->step = Preview_line_period_HDR_DOL_4LANE; - return SUCCESS; -} - -int cus_camsensor_init_handle_linear(ms_cus_sensor* drv_handle) -{ - ms_cus_sensor *handle = drv_handle; - imx415_params *params; - int res; - - if (!handle) { - SENSOR_DMSG("[%s] not enough memory!\n", __FUNCTION__); - return FAIL; - } - SENSOR_DMSG("[%s]", __FUNCTION__); - //////////////////////////////////// - // private data allocation & init // - //////////////////////////////////// - if (handle->private_data == NULL) { - SENSOR_EMSG("[%s] Private data is empty!\n", __FUNCTION__); - return FAIL; - } - - params = (imx415_params *)handle->private_data; - memcpy(params->tVts_reg, vts_reg, sizeof(vts_reg)); - memcpy(params->tGain_reg, gain_reg, sizeof(gain_reg)); - memcpy(params->tExpo_reg, expo_reg, sizeof(expo_reg)); - - //////////////////////////////////// - // sensor model ID // - //////////////////////////////////// - sprintf(handle->model_id,"IMX415_MIPI"); - - //////////////////////////////////// - // i2c config // - //////////////////////////////////// - handle->i2c_cfg.mode = SENSOR_I2C_LEGACY; //(CUS_ISP_I2C_MODE) FALSE; - handle->i2c_cfg.fmt = SENSOR_I2C_FMT; //CUS_I2C_FMT_A16D8; - handle->i2c_cfg.address = SENSOR_I2C_ADDR; //0x34; - handle->i2c_cfg.speed = SENSOR_I2C_SPEED; //300000; - - //////////////////////////////////// - // mclk // - //////////////////////////////////// - //handle->mclk = UseParaMclk(SENSOR_DRV_PARAM_MCLK()); - handle->mclk = Preview_MCLK_SPEED; - - //////////////////////////////////// - // sensor interface info // - //////////////////////////////////// - handle->isp_type = SENSOR_ISP_TYPE; - //handle->data_fmt = SENSOR_DATAFMT; - handle->sif_bus = SENSOR_IFBUS_TYPE; - handle->data_prec = SENSOR_DATAPREC; - handle->data_mode = SENSOR_DATAMODE; - handle->bayer_id = SENSOR_BAYERID; - handle->RGBIR_id = SENSOR_RGBIRID; - handle->orient = SENSOR_ORIT; - //handle->YC_ODER = SENSOR_YCORDER; //CUS_SEN_YCODR_CY; - handle->interface_attr.attr_mipi.mipi_lane_num = SENSOR_MIPI_LANE_NUM; - handle->interface_attr.attr_mipi.mipi_data_format = CUS_SEN_INPUT_FORMAT_RGB; // RGB pattern. - handle->interface_attr.attr_mipi.mipi_yuv_order = 0; //don't care in RGB pattern. - handle->interface_attr.attr_mipi.mipi_hsync_mode = SENSOR_MIPI_HSYNC_MODE; - handle->interface_attr.attr_mipi.mipi_hdr_mode = CUS_HDR_MODE_NONE; - handle->interface_attr.attr_mipi.mipi_hdr_virtual_channel_num = 0; //Short frame - - //////////////////////////////////// - // resolution capability // - //////////////////////////////////// - handle->video_res_supported.ulcur_res = 0; //default resolution index is 0. - //handle->video_res_supported.num_res = LINEAR_RES_END; - for (res = 0; res < LINEAR_RES_END; res++) { - handle->video_res_supported.num_res = res+1; - handle->video_res_supported.res[res].width = imx415_mipi_linear[res].senif.preview_w; - handle->video_res_supported.res[res].height = imx415_mipi_linear[res].senif.preview_h; - handle->video_res_supported.res[res].max_fps = imx415_mipi_linear[res].senout.max_fps; - handle->video_res_supported.res[res].min_fps = imx415_mipi_linear[res].senout.min_fps; - handle->video_res_supported.res[res].crop_start_x = imx415_mipi_linear[res].senif.crop_start_X; - handle->video_res_supported.res[res].crop_start_y = imx415_mipi_linear[res].senif.crop_start_y; - handle->video_res_supported.res[res].nOutputWidth = imx415_mipi_linear[res].senout.width; - handle->video_res_supported.res[res].nOutputHeight = imx415_mipi_linear[res].senout.height; - sprintf(handle->video_res_supported.res[res].strResDesc, imx415_mipi_linear[res].senstr.strResDesc); - } - - //////////////////////////////////// - // Sensor polarity // - //////////////////////////////////// - handle->pwdn_POLARITY = SENSOR_PWDN_POL; //CUS_CLK_POL_NEG; - handle->reset_POLARITY = SENSOR_RST_POL; //CUS_CLK_POL_NEG; - //handle->VSYNC_POLARITY = SENSOR_VSYNC_POL; //CUS_CLK_POL_POS; - //handle->HSYNC_POLARITY = SENSOR_HSYNC_POL; //CUS_CLK_POL_POS; - //handle->PCLK_POLARITY = SENSOR_PCLK_POL; //CUS_CLK_POL_POS); // use '!' to clear board latch error - - //////////////////////////////////////// - // Sensor Status Control and Get Info // - //////////////////////////////////////// - handle->pCus_sensor_release = cus_camsensor_release_handle; - handle->pCus_sensor_init = pCus_init_mipi4lane_linear; - //handle->pCus_sensor_powerupseq = pCus_powerupseq; - handle->pCus_sensor_poweron = pCus_poweron; - handle->pCus_sensor_poweroff = pCus_poweroff; - handle->pCus_sensor_GetSensorID = pCus_GetSensorID; - handle->pCus_sensor_GetVideoResNum = pCus_GetVideoResNum; - handle->pCus_sensor_GetVideoRes = pCus_GetVideoRes; - handle->pCus_sensor_GetCurVideoRes = pCus_GetCurVideoRes; - handle->pCus_sensor_SetVideoRes = pCus_SetVideoRes; - - handle->pCus_sensor_GetOrien = pCus_GetOrien; - handle->pCus_sensor_SetOrien = pCus_SetOrien; - handle->pCus_sensor_GetFPS = pCus_GetFPS; - handle->pCus_sensor_SetFPS = pCus_SetFPS; - //handle->pCus_sensor_GetSensorCap = pCus_GetSensorCap; - handle->pCus_sensor_SetPatternMode = imx415_SetPatternMode; //NONE - - //////////////////////////////////// - // AE parameters // - //////////////////////////////////// - handle->ae_gain_delay = SENSOR_GAIN_DELAY_FRAME_COUNT; - handle->ae_shutter_delay = SENSOR_SHUTTER_DELAY_FRAME_COUNT; - handle->ae_gain_ctrl_num = 1; - handle->ae_shutter_ctrl_num = 1; - handle->sat_mingain = SENSOR_MIN_GAIN;//g_sensor_ae_min_gain; - //handle->dgain_remainder = 0; - - //////////////////////////////////// - // AE Control and Get Info // - //////////////////////////////////// - // unit: micro seconds - //handle->pCus_sensor_GetAETrigger_mode = pCus_GetAETrigger_mode; - //handle->pCus_sensor_SetAETrigger_mode = pCus_SetAETrigger_mode; - handle->pCus_sensor_AEStatusNotify = pCus_AEStatusNotify; - handle->pCus_sensor_GetAEUSecs = pCus_GetAEUSecs; - handle->pCus_sensor_SetAEUSecs = pCus_SetAEUSecs; - handle->pCus_sensor_GetAEGain = pCus_GetAEGain; - handle->pCus_sensor_SetAEGain = pCus_SetAEGain; - - handle->pCus_sensor_GetAEMinMaxGain = pCus_GetAEMinMaxGain; - handle->pCus_sensor_GetAEMinMaxUSecs= pCus_GetAEMinMaxUSecs; - //handle->pCus_sensor_GetDGainRemainder = pCus_GetDGainRemainder; - - //sensor calibration - //handle->pCus_sensor_SetAEGain_cal = pCus_SetAEGain_cal; - //handle->pCus_sensor_setCaliData_gain_linearity=pCus_setCaliData_gain_linearity; - handle->pCus_sensor_GetShutterInfo = IMX415_GetShutterInfo; - - params->expo.vts = vts_30fps; - - return SUCCESS; -} - -int cus_camsensor_init_handle_hdr_dol_sef(ms_cus_sensor* drv_handle) -{ - ms_cus_sensor *handle = drv_handle; - imx415_params *params = NULL; - int res; - - if (!handle) { - SENSOR_DMSG("[%s] not enough memory!\n", __FUNCTION__); - return FAIL; - } - SENSOR_DMSG("[%s]", __FUNCTION__); - //////////////////////////////////// - // private data allocation & init // - //////////////////////////////////// - if (handle->private_data == NULL) { - SENSOR_EMSG("[%s] Private data is empty!\n", __FUNCTION__); - return FAIL; - } - - params = (imx415_params *)handle->private_data; - memcpy(params->tVts_reg, vts_reg_hdr, sizeof(vts_reg_hdr)); - memcpy(params->tRHS1_reg, expo_RHS1_reg, sizeof(expo_RHS1_reg)); - memcpy(params->tSHR1_reg, expo_SHR1_reg, sizeof(expo_SHR1_reg)); - memcpy(params->tGain_hdr_dol_sef_reg, gain_HDR_DOL_SEF_reg, sizeof(gain_HDR_DOL_SEF_reg)); - - //////////////////////////////////// - // sensor model ID // - //////////////////////////////////// - sprintf(handle->model_id,"IMX415_MIPI_HDR_SEF"); - - //////////////////////////////////// - // i2c config // - //////////////////////////////////// - handle->i2c_cfg.mode = SENSOR_I2C_LEGACY; //(CUS_ISP_I2C_MODE) FALSE; - handle->i2c_cfg.fmt = SENSOR_I2C_FMT; //CUS_I2C_FMT_A16D16; - handle->i2c_cfg.address = SENSOR_I2C_ADDR; //0x5a; - handle->i2c_cfg.speed = SENSOR_I2C_SPEED; //320000; - - //////////////////////////////////// - // mclk // - //////////////////////////////////// - handle->mclk = Preview_MCLK_SPEED_HDR_DOL; - - //////////////////////////////////// - // sensor interface info // - //////////////////////////////////// - //handle->isp_type = SENSOR_ISP_TYPE; - //handle->data_fmt = SENSOR_DATAFMT; - handle->sif_bus = SENSOR_IFBUS_TYPE; - handle->data_prec = SENSOR_DATAPREC_DOL; - handle->data_mode = SENSOR_DATAMODE; - handle->bayer_id = SENSOR_BAYERID_HDR_DOL; - handle->RGBIR_id = SENSOR_RGBIRID; - - handle->interface_attr.attr_mipi.mipi_lane_num = 4; // hdr_lane_num; - handle->interface_attr.attr_mipi.mipi_data_format = CUS_SEN_INPUT_FORMAT_RGB; - handle->interface_attr.attr_mipi.mipi_hsync_mode = SENSOR_MIPI_HSYNC_MODE_HDR_DOL; - handle->interface_attr.attr_mipi.mipi_hdr_mode = CUS_HDR_MODE_DCG; // SONY IMX415 as VC mode - handle->interface_attr.attr_mipi.mipi_hdr_virtual_channel_num = 1; //Short frame - - //////////////////////////////////// - // resolution capability // - //////////////////////////////////// - handle->video_res_supported.ulcur_res = 0; //default resolution index is 0. - //handle->video_res_supported.num_res = HDR_RES_END; - for (res = 0; res < HDR_RES_END; res++) { - handle->video_res_supported.num_res = res+1; - handle->video_res_supported.res[res].width = imx415_mipi_hdr[res].senif.preview_w; - handle->video_res_supported.res[res].height = imx415_mipi_hdr[res].senif.preview_h; - handle->video_res_supported.res[res].max_fps = imx415_mipi_hdr[res].senout.max_fps; - handle->video_res_supported.res[res].min_fps = imx415_mipi_hdr[res].senout.min_fps; - handle->video_res_supported.res[res].crop_start_x = imx415_mipi_hdr[res].senif.crop_start_X; - handle->video_res_supported.res[res].crop_start_y = imx415_mipi_hdr[res].senif.crop_start_y; - handle->video_res_supported.res[res].nOutputWidth = imx415_mipi_hdr[res].senout.width; - handle->video_res_supported.res[res].nOutputHeight = imx415_mipi_hdr[res].senout.height; - sprintf(handle->video_res_supported.res[res].strResDesc, imx415_mipi_hdr[res].senstr.strResDesc); - } - - //////////////////////////////////// - // Sensor polarity // - //////////////////////////////////// - handle->pwdn_POLARITY = SENSOR_PWDN_POL; //CUS_CLK_POL_NEG; - handle->reset_POLARITY = SENSOR_RST_POL; //CUS_CLK_POL_NEG; - //handle->VSYNC_POLARITY = SENSOR_VSYNC_POL; //CUS_CLK_POL_POS; - //handle->HSYNC_POLARITY = SENSOR_HSYNC_POL; //CUS_CLK_POL_POS; - handle->PCLK_POLARITY = SENSOR_PCLK_POL; //CUS_CLK_POL_POS); // use '!' to clear board latch error - - //////////////////////////////////////// - // Sensor Status Control and Get Info // - //////////////////////////////////////// - handle->pCus_sensor_release = cus_camsensor_release_handle; - handle->pCus_sensor_init = pCus_init_mipi4lane_HDR_DOL; - handle->pCus_sensor_poweron = pCus_poweron; // Need to check - handle->pCus_sensor_poweroff = pCus_poweroff; // Need to check - handle->pCus_sensor_GetSensorID = pCus_GetSensorID; // Need to check - handle->pCus_sensor_GetVideoResNum = pCus_GetVideoResNum; - handle->pCus_sensor_SetVideoRes = pCus_SetVideoRes_HDR_DOL_SEF; // Need to check - handle->pCus_sensor_GetVideoRes = pCus_GetVideoRes; - handle->pCus_sensor_GetCurVideoRes = pCus_GetCurVideoRes; - - handle->pCus_sensor_GetOrien = pCus_GetOrien; // Need to check - handle->pCus_sensor_SetOrien = pCus_SetOrien; // Need to check - handle->pCus_sensor_GetFPS = pCus_GetFPS_HDR_DOL_SEF; // Need to check - handle->pCus_sensor_SetFPS = pCus_SetFPS_HDR_DOL_SEF; // Need to check - - //////////////////////////////////// - // AE parameters // - //////////////////////////////////// - handle->ae_gain_delay = SENSOR_GAIN_DELAY_FRAME_COUNT; - handle->ae_shutter_delay = SENSOR_SHUTTER_DELAY_FRAME_COUNT_HDR_DOL; - handle->ae_gain_ctrl_num = 2; - handle->ae_shutter_ctrl_num = 2; - handle->sat_mingain = SENSOR_MIN_GAIN; //g_sensor_ae_min_gain; - //handle->dgain_remainder = 0; - - //////////////////////////////////// - // AE Control and Get Info // - //////////////////////////////////// - handle->pCus_sensor_AEStatusNotify = pCus_AEStatusNotifyHDR_DOL_SEF; // Need to check - handle->pCus_sensor_GetAEUSecs = pCus_GetAEUSecs; - handle->pCus_sensor_SetAEUSecs = pCus_SetAEUSecsHDR_DOL_SEF; // Need to check - handle->pCus_sensor_GetAEGain = pCus_GetAEGain; - handle->pCus_sensor_SetAEGain = pCus_SetAEGainHDR_DOL_SEF1; // Need to check - handle->pCus_sensor_GetAEMinMaxGain = pCus_GetAEMinMaxGain; - handle->pCus_sensor_GetAEMinMaxUSecs= pCus_GetAEMinMaxUSecs; - //handle->pCus_sensor_GetDGainRemainder = pCus_GetDGainRemainder; - - handle->pCus_sensor_GetShutterInfo = IMX415_GetShutterInfo_HDR_DOL_SEF; - params->expo.vts = vts_30fps_HDR_DOL_4lane; - - return SUCCESS; -} - -//lef functions -static int pCus_init_HDR_DOL_LEF(ms_cus_sensor *handle) -{ - return SUCCESS; -} - -static int pCus_poweron_HDR_DOL_LEF(ms_cus_sensor *handle, u32 idx) -{ - return SUCCESS; -} - -static int pCus_poweroff_HDR_DOL_LEF(ms_cus_sensor *handle, u32 idx) -{ - return SUCCESS; -} - -static int pCus_GetSensorID_HDR_DOL_LEF(ms_cus_sensor *handle, u32 *id) -{ - return SUCCESS; -} - -static int pCus_GetOrien_HDR_DOL_LEF(ms_cus_sensor *handle, CUS_CAMSENSOR_ORIT *orit) -{ - return SUCCESS; -} - -static int pCus_SetOrien_HDR_DOL_LEF(ms_cus_sensor *handle, CUS_CAMSENSOR_ORIT orit) -{ - imx415_params *params = (imx415_params *)handle->private_data; - - handle->orient = orit; - params->orien_dirty = true; - - return SUCCESS; -} - -static int pCus_GetFPS_HDR_DOL_LEF(ms_cus_sensor *handle) -{ - imx415_params *params = (imx415_params *)handle->private_data; - u32 cur_vts_30fps = vts_30fps_HDR_DOL_4lane; - u32 max_fps = handle->video_res_supported.res[handle->video_res_supported.ulcur_res].max_fps; - u32 tVts = (params->tVts_reg[0].data << 16) | (params->tVts_reg[1].data << 8) | (params->tVts_reg[2].data << 0); - - if (params->expo.fps >= 1000) - params->expo.preview_fps = (cur_vts_30fps*max_fps*1000)/tVts; - else - params->expo.preview_fps = (cur_vts_30fps*max_fps)/tVts; - - return params->expo.preview_fps; -} - -static int pCus_SetFPS_HDR_DOL_LEF(ms_cus_sensor *handle, u32 fps) -{ - u32 cur_vts_30fps = 0;//vts = 0, - imx415_params *params = (imx415_params *)handle->private_data; - u32 max_fps = handle->video_res_supported.res[handle->video_res_supported.ulcur_res].max_fps; - u32 min_fps = handle->video_res_supported.res[handle->video_res_supported.ulcur_res].min_fps; - // cur_vts_30fps = imx415_mipi_hdr[0].senout.height; - cur_vts_30fps=vts_30fps_HDR_DOL_4lane; - if(fps>=min_fps && fps <= max_fps){ - if (CUS_CMU_CLK_36MHZ == handle->mclk) { - fps = fps>14?14:fps;//limit fps at 29 fps due to MCLK=36MHz - params->expo.vts= (cur_vts_30fps*14545 + fps * 500 )/ (fps * 1000); - } - else - params->expo.vts= (cur_vts_30fps*(max_fps*1000) + fps * 500 )/ (fps * 1000); - - }else if(fps>=(min_fps*1000) && fps <= (max_fps*1000)){ - if (CUS_CMU_CLK_36MHZ == handle->mclk) { - fps = fps>14?14:fps;//limit fps at 29.091 fps due to MCLK=36MHz - params->expo.vts= (cur_vts_30fps*14545 + (fps >> 1))/fps; - } - else - params->expo.vts= (cur_vts_30fps*(max_fps*1000) + (fps >> 1))/fps; - - }else { - SENSOR_DMSG("[%s] FPS %d out of range.\n",__FUNCTION__,fps); - return FAIL; - } - - if(params->expo.expo_lines > params->expo.vts - 4) { - //vts = params->expo.expo_lines + 4; - }else { - //vts = params->expo.vts; - } - - params->dirty = true; - params->expo.fps = fps; - pCus_SetAEUSecsHDR_DOL_LEF(handle, params->expo.expo_sef_us); - - return SUCCESS; -} - -static int pCus_AEStatusNotifyHDR_DOL_LEF(ms_cus_sensor *handle, CUS_CAMSENSOR_AE_STATUS_NOTIFY status) -{ - imx415_params *params = (imx415_params *)handle->private_data; - //ISensorIfAPI2 *sensor_if1 = handle->sensor_if_api2; - - switch(status) - { - case CUS_FRAME_INACTIVE: - - break; - case CUS_FRAME_ACTIVE: - - if(params->dirty || params->orien_dirty) { - SensorReg_Write(0x3001,1); - if(params->dirty) { - SensorRegArrayW((I2C_ARRAY*)params->tVts_reg, ARRAY_SIZE(vts_reg_hdr)); - SensorRegArrayW((I2C_ARRAY*)params->tSHR0_reg, ARRAY_SIZE(expo_SHR0_reg)); - SensorRegArrayW((I2C_ARRAY*)params->tSHR1_reg, ARRAY_SIZE(expo_SHR1_reg)); - SensorRegArrayW((I2C_ARRAY*)params->tRHS1_reg, ARRAY_SIZE(expo_RHS1_reg)); - SensorRegArrayW((I2C_ARRAY*)params->tGain_hdr_dol_lef_reg, ARRAY_SIZE(gain_HDR_DOL_LEF_reg)); - SensorRegArrayW((I2C_ARRAY*)params->tGain_hdr_dol_sef_reg, ARRAY_SIZE(gain_HDR_DOL_SEF_reg)); - params->dirty = false; - } - if(params->orien_dirty) { - DoOrien(handle, handle->orient); - params->orien_dirty = false; - } - SensorReg_Write(0x3001,0); - } - break; - default : - break; - } - return SUCCESS; -} - -static int pCus_GetAEUSecs_HDR_DOL_LEF(ms_cus_sensor *handle, u32 *us) -{ - *us = 0; - return SUCCESS; -} - -static int pCus_SetAEUSecsHDR_DOL_LEF(ms_cus_sensor *handle, u32 us) -{ - u32 expo_lines_lef = 0, vts = 0, fsc = 0; - u32 cur_line_period = Preview_line_period_HDR_DOL_4LANE; - //u32 cur_vts_30fps = vts_30fps_HDR_DOL_4lane; - imx415_params *params = (imx415_params *)handle->private_data; - cur_line_period = Preview_line_period_HDR_DOL_4LANE; - //cur_vts_30fps =vts_30fps_HDR_DOL_4lane; - expo_lines_lef = (1000 * us + (cur_line_period >> 1)) / cur_line_period; - - params->expo.expo_lef_us = us; - fsc = params->expo.vts * 2; - params->fsc = ((fsc >> 2) << 2)+ 4; // 4n - - //params->max_shr0 = fsc - expo_lines_lef - 8; - params->max_shr0 = (fsc - 8) - expo_lines_lef; - if(params->max_shr0 < (params->min_rhs1+9)) - params->max_shr0 = params->min_rhs1+9; - params->max_shr0 = ((params->max_shr0 >> 1) << 1) + 2; - - if (expo_lines_lef > (fsc - params->min_rhs1 - 9)) { - vts = (expo_lines_lef + params->min_rhs1 + 9) / 2; - } - else{ - vts = params->expo.vts; - } - params->expo.expo_lines = expo_lines_lef; - //params->expo.vts = vts; - - SENSOR_DMSG("[%s] us %u, expo_lines_lef %u, vts %u, SHR0 %u \n", __FUNCTION__, - us, \ - expo_lines_lef, \ - vts, \ - params->max_shr0 - ); - params->tSHR0_reg[0].data = (params->max_shr0 >> 16) & 0x0003; - params->tSHR0_reg[1].data = (params->max_shr0 >> 8) & 0x00ff; - params->tSHR0_reg[2].data = (params->max_shr0 >> 0) & 0x00ff; - - params->tVts_reg[0].data = (vts >> 16) & 0x0003; - params->tVts_reg[1].data = (vts >> 8) & 0x00ff; - params->tVts_reg[2].data = (vts >> 0) & 0x00ff; - - params->dirty = true; - return SUCCESS; -} - -static int pCus_GetAEGain_HDR_DOL_LEF(ms_cus_sensor *handle, u32* gain) -{ - *gain = 0; - return SUCCESS; -} - -static int pCus_SetAEGainHDR_DOL_LEF(ms_cus_sensor *handle, u32 gain) -{ - imx415_params *params = (imx415_params *)handle->private_data; - u16 gain_reg = 0; - - pCus_SetAEGainHDR_DOL_Calculate(gain, &gain_reg); - params->tGain_hdr_dol_lef_reg[0].data = gain_reg & 0xff; - params->tGain_hdr_dol_lef_reg[1].data = (gain_reg >> 8) & 0xff; - - SENSOR_DMSG("[%s] set gain/reg=%u/0x%x\n", __FUNCTION__, gain, params->tGain_hdr_dol_lef_reg[0].data, params->tGain_hdr_dol_lef_reg[1].data); - - params->dirty = true; - return SUCCESS; -} - -static int pCus_GetAEMinMaxGain_HDR_DOL_LEF(ms_cus_sensor *handle, u32 *min, u32 *max) -{ - *min = handle->sat_mingain; - *max = SENSOR_MAX_GAIN; - return SUCCESS; -} - -static int pCus_GetAEMinMaxUSecs_HDR_DOL_LEF(ms_cus_sensor *handle, u32 *min, u32 *max) -{ - *min = 1; - *max = 1000000/imx415_mipi_hdr[0].senout.min_fps; - return SUCCESS; -} - -#if 0 -//static int pCus_GetDGainRemainder(ms_cus_sensor *handle, u32 *dgain_remainder) -//{ -// *dgain_remainder = handle->dgain_remainder; - -// return SUCCESS; -//} - -static int pCus_SetAEGain_cal_hdr_dol_lef(ms_cus_sensor *handle, u32 gain) -{ - return SUCCESS; -} - -static int pCus_setCaliData_gain_linearity_hdr_dol_lef(ms_cus_sensor* handle, CUS_GAIN_GAP_ARRAY* pArray, u32 num) -{ - return SUCCESS; -} -#endif - -static int IMX415_GetShutterInfo_HDR_DOL_LEF(struct __ms_cus_sensor* handle,CUS_SHUTTER_INFO *info) -{ - info->max = 1000000000/imx415_mipi_hdr[0].senout.min_fps; - info->min = (Preview_line_period_HDR_DOL_4LANE * 5); - info->step = Preview_line_period_HDR_DOL_4LANE; - return SUCCESS; -} - -static int cus_camsensor_init_handle_hdr_dol_lef(ms_cus_sensor* drv_handle) -{ - ms_cus_sensor *handle = drv_handle; - imx415_params *params; - s32 res; - if (!handle) { - SENSOR_DMSG("[%s] not enough memory!\n", __FUNCTION__); - return FAIL; - } - - //private data allocation & init - if (handle->private_data == NULL) { - SENSOR_EMSG("[%s] Private data is empty!\n", __FUNCTION__); - return FAIL; - } - params = (imx415_params *)handle->private_data; - memcpy(params->tVts_reg, vts_reg_hdr, sizeof(vts_reg_hdr)); - memcpy(params->tSHR0_reg, expo_SHR0_reg, sizeof(expo_SHR0_reg)); - memcpy(params->tGain_hdr_dol_lef_reg, gain_HDR_DOL_LEF_reg, sizeof(gain_HDR_DOL_LEF_reg)); - - //////////////////////////////////// - // sensor model ID // - //////////////////////////////////// - sprintf(handle->model_id,"IMX415_MIPI_HDR_LEF"); - - //////////////////////////////////// - // i2c config // - //////////////////////////////////// - handle->i2c_cfg.mode = SENSOR_I2C_LEGACY; //(CUS_ISP_I2C_MODE) FALSE; - handle->i2c_cfg.fmt = SENSOR_I2C_FMT; //CUS_I2C_FMT_A16D16; - handle->i2c_cfg.address = SENSOR_I2C_ADDR; //0x5a; - handle->i2c_cfg.speed = SENSOR_I2C_SPEED; //320000; - - //////////////////////////////////// - // mclk // - //////////////////////////////////// - //handle->mclk = UseParaMclk(SENSOR_DRV_PARAM_MCLK()); - handle->mclk = Preview_MCLK_SPEED_HDR_DOL; - //////////////////////////////////// - // sensor interface info // - //////////////////////////////////// - //handle->isp_type = SENSOR_ISP_TYPE; //ISP_SOC; - //handle->data_fmt = SENSOR_DATAFMT; //CUS_DATAFMT_YUV; - handle->sif_bus = SENSOR_IFBUS_TYPE; //CUS_SENIF_BUS_PARL; - handle->data_prec = SENSOR_DATAPREC_DOL; //CUS_DATAPRECISION_8; - handle->data_mode = SENSOR_DATAMODE; - handle->bayer_id = SENSOR_BAYERID_HDR_DOL; //CUS_BAYER_GB; - handle->RGBIR_id = SENSOR_RGBIRID; - handle->orient = SENSOR_ORIT; //CUS_ORIT_M1F1; - //handle->YC_ODER = SENSOR_YCORDER; //CUS_SEN_YCODR_CY; - handle->interface_attr.attr_mipi.mipi_lane_num = 4;//hdr_lane_num; - handle->interface_attr.attr_mipi.mipi_data_format = CUS_SEN_INPUT_FORMAT_RGB; // RGB pattern. - handle->interface_attr.attr_mipi.mipi_yuv_order = 0; //don't care in RGB pattern. - handle->interface_attr.attr_mipi.mipi_hsync_mode = SENSOR_MIPI_HSYNC_MODE_HDR_DOL; - handle->interface_attr.attr_mipi.mipi_hdr_mode = CUS_HDR_MODE_DCG; - handle->interface_attr.attr_mipi.mipi_hdr_virtual_channel_num = 0; //Long frame - - //////////////////////////////////// - // resolution capability // - //////////////////////////////////// - - handle->video_res_supported.ulcur_res = 0; //default resolution index is 0. - //handle->video_res_supported.num_res = HDR_RES_END; - for (res = 0; res < HDR_RES_END; res++) { - handle->video_res_supported.num_res = res+1; - handle->video_res_supported.res[res].width = imx415_mipi_hdr[res].senif.preview_w; - handle->video_res_supported.res[res].height = imx415_mipi_hdr[res].senif.preview_h; - handle->video_res_supported.res[res].max_fps = imx415_mipi_hdr[res].senout.max_fps; - handle->video_res_supported.res[res].min_fps = imx415_mipi_hdr[res].senout.min_fps; - handle->video_res_supported.res[res].crop_start_x = imx415_mipi_hdr[res].senif.crop_start_X; - handle->video_res_supported.res[res].crop_start_y = imx415_mipi_hdr[res].senif.crop_start_y; - handle->video_res_supported.res[res].nOutputWidth = imx415_mipi_hdr[res].senout.width; - handle->video_res_supported.res[res].nOutputHeight = imx415_mipi_hdr[res].senout.height; - sprintf(handle->video_res_supported.res[res].strResDesc, imx415_mipi_hdr[res].senstr.strResDesc); - } - - //////////////////////////////////// - // Sensor polarity // - //////////////////////////////////// - handle->pwdn_POLARITY = SENSOR_PWDN_POL; //CUS_CLK_POL_NEG; - handle->reset_POLARITY = SENSOR_RST_POL; //CUS_CLK_POL_NEG; - //handle->VSYNC_POLARITY = SENSOR_VSYNC_POL; //CUS_CLK_POL_POS; - //handle->HSYNC_POLARITY = SENSOR_HSYNC_POL; //CUS_CLK_POL_POS; - //handle->PCLK_POLARITY = SENSOR_PCLK_POL; //CUS_CLK_POL_POS); // use '!' to clear board latch error - ///////////////////////////////////////////////////// - - //////////////////////////////////////// - // Sensor Status Control and Get Info // - //////////////////////////////////////// - //LOGD("[%s:%d]\n", __FUNCTION__, __LINE__); - handle->pCus_sensor_release = cus_camsensor_release_handle; - handle->pCus_sensor_init = pCus_init_HDR_DOL_LEF; - //handle->pCus_sensor_powerupseq = pCus_powerupseq ; - handle->pCus_sensor_poweron = pCus_poweron_HDR_DOL_LEF; - handle->pCus_sensor_poweroff = pCus_poweroff_HDR_DOL_LEF; - handle->pCus_sensor_GetSensorID = pCus_GetSensorID_HDR_DOL_LEF; - //handle->pCus_sensor_GetVideoResNum = NULL; - //handle->pCus_sensor_GetVideoRes = NULL; - //handle->pCus_sensor_GetCurVideoRes = NULL; - handle->pCus_sensor_SetVideoRes = pCus_SetVideoRes_HDR_DOL_LEF; // Need to check - - - handle->pCus_sensor_GetOrien = pCus_GetOrien_HDR_DOL_LEF; - handle->pCus_sensor_SetOrien = pCus_SetOrien_HDR_DOL_LEF; - handle->pCus_sensor_GetFPS = pCus_GetFPS_HDR_DOL_LEF; - handle->pCus_sensor_SetFPS = pCus_SetFPS_HDR_DOL_LEF; - //handle->pCus_sensor_GetSensorCap = pCus_GetSensorCap_hdr_dol_lef; - //handle->pCus_sensor_SetPatternMode = imx415_SetPatternMode_hdr_dol_lef; - - //////////////////////////////////// - // AE parameters // - //////////////////////////////////// - handle->ae_gain_delay = SENSOR_GAIN_DELAY_FRAME_COUNT; - handle->ae_shutter_delay = SENSOR_SHUTTER_DELAY_FRAME_COUNT_HDR_DOL; - handle->ae_gain_ctrl_num = 2; - handle->ae_shutter_ctrl_num = 2; - handle->sat_mingain = SENSOR_MIN_GAIN; - //handle->dgain_remainder = 0; - - //////////////////////////////////// - // AE Control and Get Info // - //////////////////////////////////// - handle->pCus_sensor_AEStatusNotify = pCus_AEStatusNotifyHDR_DOL_LEF; - handle->pCus_sensor_GetAEUSecs = pCus_GetAEUSecs_HDR_DOL_LEF; - handle->pCus_sensor_SetAEUSecs = pCus_SetAEUSecsHDR_DOL_LEF; - handle->pCus_sensor_GetAEGain = pCus_GetAEGain_HDR_DOL_LEF; - handle->pCus_sensor_SetAEGain = pCus_SetAEGainHDR_DOL_LEF; - - handle->pCus_sensor_GetAEMinMaxGain = pCus_GetAEMinMaxGain_HDR_DOL_LEF; - handle->pCus_sensor_GetAEMinMaxUSecs= pCus_GetAEMinMaxUSecs_HDR_DOL_LEF; - //handle->pCus_sensor_GetDGainRemainder = pCus_GetDGainRemainder; - - handle->pCus_sensor_GetShutterInfo = IMX415_GetShutterInfo_HDR_DOL_LEF; - - params->expo.vts = vts_30fps_HDR_DOL_4lane; - - params->dirty = false; - - return SUCCESS; -} - -SENSOR_DRV_ENTRY_IMPL_END_EX(IMX415_HDR, - cus_camsensor_init_handle_linear, - cus_camsensor_init_handle_hdr_dol_sef, - cus_camsensor_init_handle_hdr_dol_lef, - imx415_params - ); diff --git a/general/package/sigmastar-osdrv-sensor/src/infinity6e/sensor/sensor_sc8235_mipi.c b/general/package/sigmastar-osdrv-sensor/src/infinity6e/sensor/sensor_sc8235_mipi.c deleted file mode 100644 index 21905cb1..00000000 --- a/general/package/sigmastar-osdrv-sensor/src/infinity6e/sensor/sensor_sc8235_mipi.c +++ /dev/null @@ -1,5134 +0,0 @@ -/* SigmaStar trade secret */ -/* Copyright (c) [2019~2020] SigmaStar Technology. - All rights reserved. - - Unless otherwise stipulated in writing, any and all information contained - herein regardless in any format shall remain the sole proprietary of - SigmaStar and be kept in strict confidence - (SigmaStar Confidential Information) by the recipient. - Any unauthorized act including without limitation unauthorized disclosure, - copying, use, reproduction, sale, distribution, modification, disassembling, - reverse engineering and compiling of the contents of SigmaStar Confidential - Information is unlawful and strictly prohibited. SigmaStar hereby reserves the - rights to any and all damages, losses, costs and expenses resulting therefrom. - */ - -#ifdef __cplusplus -extern "C" -{ -#endif - -#include -#include -#include - -#ifdef __cplusplus -} -#endif - -SENSOR_DRV_ENTRY_IMPL_BEGIN_EX(SC8238_HDR); - -#ifndef ARRAY_SIZE -#define ARRAY_SIZE CAM_OS_ARRAY_SIZE -#endif - -#define SENSOR_PAD_GROUP_SET CUS_SENSOR_PAD_GROUP_A -#define SENSOR_CHANNEL_NUM (0) -#define SENSOR_CHANNEL_MODE_LINEAR CUS_SENSOR_CHANNEL_MODE_REALTIME_NORMAL -#define SENSOR_CHANNEL_MODE_SONY_DOL CUS_SENSOR_CHANNEL_MODE_RAW_STORE_HDR - -//============================================ -//MIPI config begin. -#define SENSOR_MIPI_LANE_NUM (4) -//#define SENSOR_MIPI_HDR_MODE (2) //0: Non-HDR mode. 1:Sony DOL mode. 2:CUS_HDR_MODE_DCG -//MIPI config end. -//============================================ - -#define R_GAIN_REG 1 -#define G_GAIN_REG 2 -#define B_GAIN_REG 3 - - -//#undef SENSOR_DBG -#define SENSOR_DBG 0 - -/////////////////////////////////////////////////////////////// -// @@@ // -// @ @@ == S t a r t * H e r e == // -// @@ == S t a r t * H e r e == // -// @@ == S t a r t * H e r e == // -// @@@@ // -// // -// Start Step 1 -- show preview on LCM // -// �@// -// Fill these #define value and table with correct settings // -// camera can work and show preview on LCM // -// // -/////////////////////////////////////////////////////////////// - -#define SENSOR_ISP_TYPE ISP_EXT //ISP_EXT, ISP_SOC -#define F_number 22 // CFG, demo module -//#define SENSOR_DATAFMT CUS_DATAFMT_BAYER //CUS_DATAFMT_YUV, CUS_DATAFMT_BAYER -#define SENSOR_IFBUS_TYPE CUS_SENIF_BUS_MIPI //CFG //CUS_SENIF_BUS_PARL, CUS_SENIF_BUS_MIPI -#define SENSOR_MIPI_HSYNC_MODE PACKET_HEADER_EDGE1 -#define SENSOR_MIPI_HSYNC_MODE_HDR_DOL PACKET_FOOTER_EDGE -#define SENSOR_DATAPREC CUS_DATAPRECISION_10 //CFG //CUS_DATAPRECISION_8, CUS_DATAPRECISION_10 -#define SENSOR_DATAPREC_HDR_DOL CUS_DATAPRECISION_10 -#define SENSOR_DATAMODE CUS_SEN_10TO12_9000 //CFG -//#define SENSOR_MAXGAIN (15875*315)/10000 /////sensor again 15.875 dgain=31.5 -#define SENSOR_MAXGAIN 500 /////sensor again 15.875 dgain=31.5 -#define SENSOR_BAYERID CUS_BAYER_BG //CFG //CUS_BAYER_GB, CUS_BAYER_GR, CUS_BAYER_BG, CUS_BAYER_RG -#define SENSOR_BAYERID_HDR_DOL CUS_BAYER_BG//CUS_BAYER_GR -#define SENSOR_RGBIRID CUS_RGBIR_NONE -#define SENSOR_ORIT CUS_ORIT_M0F0 //CUS_ORIT_M0F0, CUS_ORIT_M1F0, CUS_ORIT_M0F1, CUS_ORIT_M1F1, -#define SENSOR_MAX_GAIN 80 // max sensor again, a-gain -//#define SENSOR_YCORDER CUS_SEN_YCODR_YC //CUS_SEN_YCODR_YC, CUS_SEN_YCODR_CY -#define lane_number 4 -#define vc0_hs_mode 3 //0: packet header edge 1: line end edge 2: line start edge 3: packet footer edge -#define long_packet_type_enable 0x00 //UD1~UD8 (user define) - -#define Preview_MCLK_SPEED CUS_CMU_CLK_27MHZ //CFG //CUS_CMU_CLK_12M, CUS_CMU_CLK_16M, CUS_CMU_CLK_24M, CUS_CMU_CLK_27M -#define Preview_MCLK_SPEED_HDR_DOL CUS_CMU_CLK_27MHZ - -//#define Preview_line_period 30000 ////HTS/PCLK=4455 pixels/148.5MHZ=30usec @MCLK=36MHz -//#define vts_30fps 1125//1346,1616 //for 29.1fps @ MCLK=36MHz -//#define Preview_line_period //(36M/37.125M)*30fps=29.091fps(34.375msec), hts=34.375/1125=30556, -//#define Line_per_second 32727 -//#define vts_30fps -u32 Preview_line_period; -u32 vts_30fps; -u32 Preview_line_period_HDR_DOL = 14815; -u32 vts_30fps_HDR_DOL; -#define Preview_WIDTH 3840 //resolution Width when preview -#define Preview_HEIGHT 2160 //resolution Height when preview -#define Preview_MAX_FPS 15 //fastest preview FPS -#define Preview_MIN_FPS 3 //slowest preview FPS -#define Preview_CROP_START_X 0 //CROP_START_X -#define Preview_CROP_START_Y 0 //CROP_START_Y - -#define SENSOR_I2C_ADDR 0x60 //I2C slave address -#define SENSOR_I2C_SPEED 200000 //300000// 240000 //I2C speed, 60000~320000 - -#define SENSOR_I2C_LEGACY I2C_NORMAL_MODE //usally set CUS_I2C_NORMAL_MODE, if use old OVT I2C protocol=> set CUS_I2C_LEGACY_MODE -#define SENSOR_I2C_FMT I2C_FMT_A16D8 //CUS_I2C_FMT_A8D8, CUS_I2C_FMT_A8D16, CUS_I2C_FMT_A16D8, CUS_I2C_FMT_A16D16 - -#define SENSOR_PWDN_POL CUS_CLK_POL_NEG // if PWDN pin High can makes sensor in power down, set CUS_CLK_POL_POS -#define SENSOR_RST_POL CUS_CLK_POL_NEG // if RESET pin High can makes sensor in reset state, set CUS_CLK_POL_NEG - -// VSYNC/HSYNC POL can be found in data sheet timing diagram, -// Notice: the initial setting may contain VSYNC/HSYNC POL inverse settings so that condition is different. - -#define SENSOR_VSYNC_POL CUS_CLK_POL_NEG // if VSYNC pin High and data bus have data, set CUS_CLK_POL_POS -#define SENSOR_HSYNC_POL CUS_CLK_POL_NEG // if HSYNC pin High and data bus have data, set CUS_CLK_POL_POS -#define SENSOR_PCLK_POL CUS_CLK_POL_POS // depend on sensor setting, sometimes need to try CUS_CLK_POL_POS or CUS_CLK_POL_NEG - -#if defined (SENSOR_MODULE_VERSION) -#define TO_STR_NATIVE(e) #e -#define TO_STR_PROXY(m, e) m(e) -#define MACRO_TO_STRING(e) TO_STR_PROXY(TO_STR_NATIVE, e) -static char *sensor_module_version = MACRO_TO_STRING(SENSOR_MODULE_VERSION); -module_param(sensor_module_version, charp, S_IRUGO); -#endif -static int cus_camsensor_release_handle(ms_cus_sensor *handle); -static int pCus_SetAEGain(ms_cus_sensor *handle, u32 gain); -static int pCus_SetAEUSecs(ms_cus_sensor *handle, u32 us); -static int pCus_SetFPS(ms_cus_sensor *handle, u32 fps); -static int pCus_SetOrien(ms_cus_sensor *handle, CUS_CAMSENSOR_ORIT orit); -static int pCus_SetOrien_HDR(ms_cus_sensor *handle, CUS_CAMSENSOR_ORIT orit); -//static int sc8238_GetShutterInfo(struct __ms_cus_sensor* handle,CUS_SHUTTER_INFO *info); -#define ABS(a) ((a)>(0) ? (a) : (-(a))) -static int g_sensor_ae_min_gain = 1024; - -CUS_MCLK_FREQ UseParaMclk(void); - -typedef struct { - struct { - u16 pre_div0; - u16 div124; - u16 div_cnt7b; - u16 sdiv0; - u16 mipi_div0; - u16 r_divp; - u16 sdiv1; - u16 r_seld5; - u16 r_sclk_dac; - u16 sys_sel; - u16 pdac_sel; - u16 adac_sel; - u16 pre_div_sp; - u16 r_div_sp; - u16 div_cnt5b; - u16 sdiv_sp; - u16 div12_sp; - u16 mipi_lane_sel; - u16 div_dac; - } clk_tree; - struct { - u32 sclk; - u32 hts; - u32 vts; - u32 ho; - u32 xinc; - u32 line_freq; - u32 us_per_line; - u32 final_us; - u32 final_gain; - u32 back_pv_us; - u32 half_lines; - u32 half_line; - u32 fps; - u32 preview_fps; - u32 max_short_exp; - u32 line; - } expo; - struct { - bool bVideoMode; - u16 res_idx; - // bool binning; - // bool scaling; - CUS_CAMSENSOR_ORIT orit; - } res; - - int sen_init; - int still_min_fps; - int video_min_fps; - bool reg_mf; - bool reg_dirty; - CUS_CAMSENSOR_ORIT cur_orien; -} sc8238_params; -// set sensor ID address and data, - -typedef struct { - u64 gain; - u8 fine_gain_reg; -} FINE_GAIN; - -I2C_ARRAY Sensor_id_table[] = -{ - {0x3107, 0x82}, - {0x3108, 0x35}, -}; - -I2C_ARRAY Sensor_init_table_4lane_4K30fps[] = -{ -//0x02_Apollo_30fps_10bit_4lane_708.75Mbps_3840x2160(HTS=4200,VTS=2250).ini -{0x0103,0x01}, -{0x0100,0x00}, -{0x336c,0xc2}, -{0x3624,0x45}, -{0x33e1,0x08}, -{0x33e2,0x18}, -{0x33e3,0x10}, -{0x33e4,0x0c}, -{0x33e5,0x10}, -{0x33e6,0x06}, -{0x33e7,0x02}, -{0x33e8,0x18}, -{0x33e9,0x10}, -{0x33ea,0x0c}, -{0x33eb,0x10}, -{0x33ec,0x04}, -{0x33ed,0x02}, -{0x33ee,0xa0}, -{0x33ef,0x08}, -{0x33f4,0x18}, -{0x33f5,0x10}, -{0x33f6,0x0c}, -{0x33f7,0x10}, -{0x33f8,0x06}, -{0x33f9,0x02}, -{0x33fa,0x18}, -{0x33fb,0x10}, -{0x33fc,0x0c}, -{0x33fd,0x10}, -{0x33fe,0x04}, -{0x33ff,0x02}, -{0x5799,0x06}, -{0x3e16,0x00}, -{0x3e17,0xac}, -{0x3e18,0x00}, -{0x3e19,0xac}, -{0x3e0e,0x09}, -{0x3e1e,0x76}, -{0x3e25,0x23}, -{0x57aa,0x2f}, -{0x57ab,0xff}, -{0x3018,0x72}, -{0x3019,0x00}, -{0x3031,0x0a}, -{0x3037,0x20}, -{0x4501,0xa4}, -{0x4509,0x10}, -{0x4837,0x1c}, -{0x3366,0x92}, -{0x3314,0x94}, -{0x334c,0x10}, -{0x3e09,0x40}, -{0x3e08,0x03}, -{0x3637,0x52}, -{0x3631,0x80}, -{0x3308,0x20}, -{0x335d,0x60}, -{0x337f,0x33}, -{0x3368,0x07}, -{0x3369,0x00}, -{0x336a,0x00}, -{0x336b,0x00}, -{0x3367,0x08}, -{0x330e,0x58}, -{0x33af,0x48}, -{0x3638,0x0a}, -{0x3306,0xa8}, -{0x3309,0x68}, -{0x331f,0x59}, -{0x330d,0x28}, -{0x339e,0x24}, -{0x33aa,0x24}, -{0x3332,0x24}, -{0x3350,0x24}, -{0x3358,0x24}, -{0x335c,0x24}, -{0x3628,0x83}, -{0x3633,0x53}, -{0x3630,0x80}, -{0x3622,0xf7}, -{0x363d,0x01}, -{0x363e,0x00}, -{0x363a,0x88}, -{0x3e26,0x40}, -{0x360f,0x01}, -{0x367a,0x48}, -{0x367b,0x78}, -{0x3671,0xf7}, -{0x3672,0xf7}, -{0x3673,0x17}, -{0x3670,0x4a}, -{0x367c,0x48}, -{0x367d,0x78}, -{0x3674,0x80}, -{0x3675,0x85}, -{0x3676,0xa5}, -{0x369c,0x48}, -{0x369d,0x78}, -{0x3690,0x53}, -{0x3691,0x63}, -{0x3692,0x54}, -{0x36a2,0x48}, -{0x36a3,0x78}, -{0x3699,0x88}, -{0x369a,0x9f}, -{0x369b,0x9f}, -{0x36bb,0x48}, -{0x36bc,0x78}, -{0x36c9,0x05}, -{0x36ca,0x05}, -{0x36cb,0x05}, -{0x36d0,0x30}, -{0x36d1,0x48}, -{0x36d2,0x78}, -{0x36cc,0x00}, -{0x36cd,0x10}, -{0x36ce,0x1a}, -{0x3364,0x16}, -{0x3301,0x1c}, -{0x3393,0x1c}, -{0x3394,0x28}, -{0x3395,0x60}, -{0x3390,0x08}, -{0x3391,0x18}, -{0x3392,0x38}, -{0x3399,0x1c}, -{0x339a,0x1c}, -{0x339b,0x28}, -{0x339c,0x60}, -{0x3396,0x08}, -{0x3397,0x18}, -{0x3398,0x38}, -{0x3241,0x00}, -{0x3243,0x03}, -{0x3271,0x1c}, -{0x3273,0x1f}, -{0x394c,0x0f}, -{0x394d,0x20}, -{0x394e,0x08}, -{0x394f,0x90}, -{0x3981,0x70}, -{0x3984,0x20}, -{0x39ec,0x08}, -{0x39ed,0x00}, -{0x3982,0x00}, -{0x3983,0x00}, -{0x3980,0x71}, -{0x39b4,0x0c}, -{0x39b5,0x1c}, -{0x39b6,0x38}, -{0x39b7,0x5b}, -{0x39b8,0x50}, -{0x39b9,0x38}, -{0x39ba,0x20}, -{0x39bb,0x10}, -{0x39bc,0x0c}, -{0x39bd,0x16}, -{0x39be,0x21}, -{0x39bf,0x36}, -{0x39c0,0x3b}, -{0x39c1,0x2a}, -{0x39c2,0x16}, -{0x39c3,0x0c}, -{0x39a2,0x03}, -{0x39a3,0xe3}, -{0x39a4,0x03}, -{0x39a5,0xf2}, -{0x39a6,0x03}, -{0x39a7,0xf6}, -{0x39a8,0x03}, -{0x39a9,0xfa}, -{0x39aa,0x03}, -{0x39ab,0xff}, -{0x39ac,0x00}, -{0x39ad,0x06}, -{0x39ae,0x00}, -{0x39af,0x09}, -{0x39b0,0x00}, -{0x39b1,0x12}, -{0x39b2,0x00}, -{0x39b3,0x22}, -{0x39c6,0x07}, -{0x39c7,0xf8}, -{0x39c9,0x07}, -{0x39ca,0xf8}, -{0x3990,0x03}, -{0x3991,0xfd}, -{0x3992,0x03}, -{0x3993,0xfc}, -{0x3994,0x00}, -{0x3995,0x00}, -{0x3996,0x00}, -{0x3997,0x05}, -{0x3998,0x00}, -{0x3999,0x09}, -{0x399a,0x00}, -{0x399b,0x12}, -{0x399c,0x00}, -{0x399d,0x12}, -{0x399e,0x00}, -{0x399f,0x18}, -{0x39a0,0x00}, -{0x39a1,0x14}, -{0x39cc,0x00}, -{0x39cd,0x1b}, -{0x39ce,0x00}, -{0x39cf,0x00}, -{0x39d0,0x1b}, -{0x39d1,0x00}, -{0x39e2,0x15}, -{0x39e3,0x87}, -{0x39e4,0x12}, -{0x39e5,0xb7}, -{0x39e6,0x00}, -{0x39e7,0x8c}, -{0x39e8,0x01}, -{0x39e9,0x31}, -{0x39ea,0x01}, -{0x39eb,0xd7}, -{0x39c5,0x30}, -{0x330b,0x48}, -{0x320c,0x08}, -{0x320d,0x34}, -{0x320e,0x08}, -{0x320f,0xca}, -{0x3635,0x02}, -{0x3902,0xc5}, -{0x3038,0x44}, -{0x3632,0x98}, -{0x3e14,0x31}, -{0x3e1b,0x3a}, -{0x3248,0x04}, -{0x3901,0x00}, -{0x3904,0x18}, -{0x3987,0x0b}, -{0x363b,0x06}, -{0x3905,0xd8}, -{0x301f,0x02}, -{0x3203,0x08}, -{0x3207,0x87}, -{0x3213,0x08}, -{0x3e00,0x01}, -{0x3e01,0x18}, -{0x3e02,0xa0}, -{0x3641,0x0c}, -{0x36f9,0x57}, -{0x36fa,0x39}, -{0x36fb,0x13}, -{0x36fc,0x10}, -{0x36fd,0x14}, -{0x36e9,0x53}, -{0x36ea,0x39}, -{0x36eb,0x06}, -{0x36ec,0x05}, -{0x36ed,0x24}, -{0x3641,0x00}, -{0x0100,0x01}, -}; - -I2C_ARRAY Sensor_init_table_4lane_4K20fps[] = -{ -//cleaned_0x32_SC8235_MIPI_27Minput_4lane_10bit_472.5Mbps_3840x2160_20fps.ini -{0x0103,0x01}, -{0x0100,0x00}, -{0x3018,0x72}, -{0x3019,0x00}, -{0x301f,0x32}, -{0x3031,0x0a}, -{0x3037,0x20}, -{0x3038,0x44}, -{0x320c,0x08}, -{0x320d,0x34}, -{0x3241,0x00}, -{0x3243,0x03}, -{0x3248,0x04}, -{0x3271,0x1c}, -{0x3273,0x1f}, -{0x3301,0x18}, -{0x3306,0x88}, -{0x3308,0x20}, -{0x3309,0x68}, -{0x330b,0x70}, -{0x330d,0x28}, -{0x330e,0x48}, -{0x3314,0x94}, -{0x331f,0x59}, -{0x3332,0x24}, -{0x334c,0x10}, -{0x3350,0x24}, -{0x3358,0x24}, -{0x335c,0x24}, -{0x335d,0x60}, -{0x3364,0x16}, -{0x3366,0x92}, -{0x3367,0x08}, -{0x3368,0x07}, -{0x3369,0x00}, -{0x336a,0x00}, -{0x336b,0x00}, -{0x336c,0xc2}, -{0x337f,0x33}, -{0x3390,0x08}, -{0x3391,0x18}, -{0x3392,0x38}, -{0x3393,0x1c}, -{0x3394,0x28}, -{0x3395,0x60}, -{0x3396,0x08}, -{0x3397,0x18}, -{0x3398,0x38}, -{0x3399,0x18}, -{0x339a,0x1c}, -{0x339b,0x28}, -{0x339c,0x60}, -{0x339e,0x24}, -{0x33aa,0x24}, -{0x33af,0x48}, -{0x33e1,0x08}, -{0x33e2,0x18}, -{0x33e3,0x10}, -{0x33e4,0x0c}, -{0x33e5,0x10}, -{0x33e6,0x06}, -{0x33e7,0x02}, -{0x33e8,0x18}, -{0x33e9,0x10}, -{0x33ea,0x0c}, -{0x33eb,0x10}, -{0x33ec,0x04}, -{0x33ed,0x02}, -{0x33ee,0xa0}, -{0x33ef,0x08}, -{0x33f4,0x18}, -{0x33f5,0x10}, -{0x33f6,0x0c}, -{0x33f7,0x10}, -{0x33f8,0x06}, -{0x33f9,0x02}, -{0x33fa,0x18}, -{0x33fb,0x10}, -{0x33fc,0x0c}, -{0x33fd,0x10}, -{0x33fe,0x04}, -{0x33ff,0x02}, -{0x360f,0x01}, -{0x3622,0xf7}, -{0x3624,0x45}, -{0x3628,0x83}, -{0x3630,0x80}, -{0x3631,0x80}, -{0x3632,0xa8}, -{0x3633,0x53}, -{0x3635,0x02}, -{0x3637,0x52}, -{0x3638,0x0a}, -{0x363a,0x88}, -{0x363b,0x06}, -{0x363d,0x01}, -{0x363e,0x00}, -{0x3670,0x4a}, -{0x3671,0xf7}, -{0x3672,0xf7}, -{0x3673,0x17}, -{0x3674,0x80}, -{0x3675,0x85}, -{0x3676,0xa5}, -{0x367a,0x48}, -{0x367b,0x78}, -{0x367c,0x48}, -{0x367d,0x78}, -{0x3690,0x53}, -{0x3691,0x63}, -{0x3692,0x54}, -{0x3699,0x9f}, -{0x369a,0x9f}, -{0x369b,0x9f}, -{0x369c,0x48}, -{0x369d,0x78}, -{0x36a2,0x48}, -{0x36a3,0x78}, -{0x36bb,0x48}, -{0x36bc,0x78}, -{0x36c9,0x05}, -{0x36ca,0x05}, -{0x36cb,0x05}, -{0x36cc,0x00}, -{0x36cd,0x10}, -{0x36ce,0x1a}, -{0x36d0,0x30}, -{0x36d1,0x48}, -{0x36d2,0x78}, -{0x3901,0x00}, -{0x3902,0xc5}, -{0x3904,0x18}, -{0x3905,0xd8}, -{0x394c,0x0f}, -{0x394d,0x20}, -{0x394e,0x08}, -{0x394f,0x90}, -{0x3980,0x71}, -{0x3981,0x70}, -{0x3982,0x00}, -{0x3983,0x00}, -{0x3984,0x20}, -{0x3987,0x0b}, -{0x3990,0x03}, -{0x3991,0xfd}, -{0x3992,0x03}, -{0x3993,0xfc}, -{0x3994,0x00}, -{0x3995,0x00}, -{0x3996,0x00}, -{0x3997,0x05}, -{0x3998,0x00}, -{0x3999,0x09}, -{0x399a,0x00}, -{0x399b,0x12}, -{0x399c,0x00}, -{0x399d,0x12}, -{0x399e,0x00}, -{0x399f,0x18}, -{0x39a0,0x00}, -{0x39a1,0x14}, -{0x39a2,0x03}, -{0x39a3,0xe3}, -{0x39a4,0x03}, -{0x39a5,0xf2}, -{0x39a6,0x03}, -{0x39a7,0xf6}, -{0x39a8,0x03}, -{0x39a9,0xfa}, -{0x39aa,0x03}, -{0x39ab,0xff}, -{0x39ac,0x00}, -{0x39ad,0x06}, -{0x39ae,0x00}, -{0x39af,0x09}, -{0x39b0,0x00}, -{0x39b1,0x12}, -{0x39b2,0x00}, -{0x39b3,0x22}, -{0x39b4,0x0c}, -{0x39b5,0x1c}, -{0x39b6,0x38}, -{0x39b7,0x5b}, -{0x39b8,0x50}, -{0x39b9,0x38}, -{0x39ba,0x20}, -{0x39bb,0x10}, -{0x39bc,0x0c}, -{0x39bd,0x16}, -{0x39be,0x21}, -{0x39bf,0x36}, -{0x39c0,0x3b}, -{0x39c1,0x2a}, -{0x39c2,0x16}, -{0x39c3,0x0c}, -{0x39c5,0x30}, -{0x39c6,0x07}, -{0x39c7,0xf8}, -{0x39c9,0x07}, -{0x39ca,0xf8}, -{0x39cc,0x00}, -{0x39cd,0x1b}, -{0x39ce,0x00}, -{0x39cf,0x00}, -{0x39d0,0x1b}, -{0x39d1,0x00}, -{0x39e2,0x15}, -{0x39e3,0x87}, -{0x39e4,0x12}, -{0x39e5,0xb7}, -{0x39e6,0x00}, -{0x39e7,0x8c}, -{0x39e8,0x01}, -{0x39e9,0x31}, -{0x39ea,0x01}, -{0x39eb,0xd7}, -{0x39ec,0x08}, -{0x39ed,0x00}, -{0x3e00,0x01}, -{0x3e01,0x18}, -{0x3e02,0xa0}, -{0x3e08,0x03}, -{0x3e09,0x40}, -{0x3e0e,0x09}, -{0x3e14,0x31}, -{0x3e16,0x00}, -{0x3e17,0xac}, -{0x3e18,0x00}, -{0x3e19,0xac}, -{0x3e1b,0x3a}, -{0x3e1e,0x76}, -{0x3e25,0x23}, -{0x3e26,0x40}, -{0x4501,0xa4}, -{0x4509,0x10}, -{0x4837,0x2a}, -{0x5799,0x06}, -{0x57aa,0x2f}, -{0x57ab,0xff}, -{0x3641,0x0c}, -{0x36e9,0x56}, -{0x36ea,0x39}, -{0x36eb,0x0e}, -{0x36ec,0x15}, -{0x36ed,0x14}, -{0x36f9,0x11}, -{0x36fa,0x39}, -{0x36fb,0x13}, -{0x36fc,0x10}, -{0x36fd,0x14}, -{0x3641,0x00}, -{0x0100,0x01}, -}; - -I2C_ARRAY Sensor_init_table_4lane_4K15fps[] = -{ -//0x20_Apollo_MIPI_27Minput_4lane_10bit_421.875Mbps_3840x2160_15fps_(hts=5000,vts=2250).ini -{0x0103,0x01}, -{0x0100,0x00}, -{0x3018,0x72}, -{0x3019,0x00}, -{0x301f,0x20}, -{0x3031,0x0a}, -{0x3037,0x20}, -{0x3038,0x44}, -{0x320c,0x09}, -{0x320d,0xc4}, -{0x320e,0x08}, -{0x320f,0xca}, -{0x3241,0x00}, -{0x3243,0x03}, -{0x3248,0x04}, -{0x3271,0x1c}, -{0x3273,0x1f}, -{0x3301,0x1c}, -{0x3306,0xc0}, -{0x3309,0x40}, -{0x330b,0xc0}, -{0x330e,0x60}, -{0x3314,0x94}, -{0x331f,0x31}, -{0x334c,0x10}, -{0x335d,0x60}, -{0x3364,0x16}, -{0x3366,0x92}, -{0x3367,0x08}, -{0x3368,0x09}, -{0x3369,0x00}, -{0x336a,0x00}, -{0x336b,0x00}, -{0x336c,0xc2}, -{0x337f,0x33}, -{0x3390,0x08}, -{0x3391,0x18}, -{0x3392,0x38}, -{0x3393,0x1c}, -{0x3394,0x28}, -{0x3395,0x60}, -{0x3396,0x08}, -{0x3397,0x18}, -{0x3398,0x38}, -{0x3399,0x1c}, -{0x339a,0x1c}, -{0x339b,0x28}, -{0x339c,0x60}, -{0x33af,0x24}, -{0x33e0,0xa0}, -{0x33e1,0x08}, -{0x33e2,0x18}, -{0x33e3,0x10}, -{0x33e4,0x0c}, -{0x33e5,0x10}, -{0x33e6,0x06}, -{0x33e7,0x02}, -{0x33e8,0x18}, -{0x33e9,0x10}, -{0x33ea,0x0c}, -{0x33eb,0x10}, -{0x33ec,0x04}, -{0x33ed,0x02}, -{0x33ee,0xa0}, -{0x33ef,0x08}, -{0x33f4,0x18}, -{0x33f5,0x10}, -{0x33f6,0x0c}, -{0x33f7,0x10}, -{0x33f8,0x06}, -{0x33f9,0x02}, -{0x33fa,0x18}, -{0x33fb,0x10}, -{0x33fc,0x0c}, -{0x33fd,0x10}, -{0x33fe,0x04}, -{0x33ff,0x02}, -{0x360f,0x01}, -{0x3622,0xf7}, -{0x3624,0x45}, -{0x3628,0x83}, -{0x3630,0x80}, -{0x3631,0x80}, -{0x3632,0xa8}, -{0x3633,0x22}, -{0x3635,0x02}, -{0x3637,0x29}, -{0x3638,0x08}, -{0x363a,0x88}, -{0x363b,0x06}, -{0x363d,0x01}, -{0x363e,0x00}, -{0x3670,0x4a}, -{0x3671,0xf7}, -{0x3672,0xf7}, -{0x3673,0x17}, -{0x3674,0x80}, -{0x3675,0x85}, -{0x3676,0xa5}, -{0x367a,0x48}, -{0x367b,0x78}, -{0x367c,0x48}, -{0x367d,0x78}, -{0x3690,0x53}, -{0x3691,0x63}, -{0x3692,0x54}, -{0x3699,0x9f}, -{0x369a,0x9f}, -{0x369b,0x9f}, -{0x369c,0x48}, -{0x369d,0x78}, -{0x36a2,0x48}, -{0x36a3,0x78}, -{0x36bb,0x48}, -{0x36bc,0x78}, -{0x36c9,0x05}, -{0x36ca,0x05}, -{0x36cb,0x05}, -{0x36cc,0x00}, -{0x36cd,0x10}, -{0x36ce,0x1a}, -{0x36d0,0x30}, -{0x36d1,0x48}, -{0x36d2,0x78}, -{0x3901,0x00}, -{0x3902,0xc5}, -{0x3904,0x18}, -{0x3905,0xd8}, -{0x394c,0x0f}, -{0x394d,0x20}, -{0x394e,0x08}, -{0x394f,0x90}, -{0x3980,0x71}, -{0x3981,0x70}, -{0x3982,0x00}, -{0x3983,0x00}, -{0x3984,0x20}, -{0x3987,0x0b}, -{0x3990,0x03}, -{0x3991,0xfd}, -{0x3992,0x03}, -{0x3993,0xfc}, -{0x3994,0x03}, -{0x3995,0xff}, -{0x3996,0x00}, -{0x3997,0x03}, -{0x3998,0x00}, -{0x3999,0x06}, -{0x399a,0x00}, -{0x399b,0x0e}, -{0x399c,0x00}, -{0x399d,0x10}, -{0x399e,0x00}, -{0x399f,0x18}, -{0x39a0,0x00}, -{0x39a1,0x14}, -{0x39a2,0x03}, -{0x39a3,0xe3}, -{0x39a4,0x03}, -{0x39a5,0xee}, -{0x39a6,0x03}, -{0x39a7,0xf4}, -{0x39a8,0x03}, -{0x39a9,0xf6}, -{0x39aa,0x03}, -{0x39ab,0xfd}, -{0x39ac,0x00}, -{0x39ad,0x04}, -{0x39ae,0x00}, -{0x39af,0x06}, -{0x39b0,0x00}, -{0x39b1,0x0e}, -{0x39b2,0x00}, -{0x39b3,0x1c}, -{0x39b4,0x0c}, -{0x39b5,0x1c}, -{0x39b6,0x38}, -{0x39b7,0x5b}, -{0x39b8,0x50}, -{0x39b9,0x38}, -{0x39ba,0x20}, -{0x39bb,0x10}, -{0x39bc,0x0c}, -{0x39bd,0x16}, -{0x39be,0x21}, -{0x39bf,0x36}, -{0x39c0,0x3b}, -{0x39c1,0x2a}, -{0x39c2,0x16}, -{0x39c3,0x0c}, -{0x39c5,0x30}, -{0x39c6,0x07}, -{0x39c7,0xf8}, -{0x39c9,0x07}, -{0x39ca,0xf8}, -{0x39cc,0x00}, -{0x39cd,0x1b}, -{0x39ce,0x00}, -{0x39cf,0x00}, -{0x39d0,0x1b}, -{0x39d1,0x00}, -{0x39e2,0x19}, -{0x39e3,0xe9}, -{0x39e4,0x0e}, -{0x39e5,0x14}, -{0x39e6,0x00}, -{0x39e7,0x23}, -{0x39e8,0x03}, -{0x39e9,0xba}, -{0x39ea,0x02}, -{0x39eb,0x6d}, -{0x39ec,0x08}, -{0x39ed,0x00}, -{0x3e00,0x01}, -{0x3e01,0x18}, -{0x3e02,0xa0}, -{0x3e08,0x03}, -{0x3e09,0x40}, -{0x3e0e,0x09}, -{0x3e14,0x31}, -{0x3e16,0x00}, -{0x3e17,0xac}, -{0x3e18,0x00}, -{0x3e19,0xac}, -{0x3e1b,0x3a}, -{0x3e1e,0x76}, -{0x3e25,0x23}, -{0x3e26,0x40}, -{0x3f00,0x4a}, -{0x4501,0xb4}, -{0x4509,0x20}, -{0x4837,0x2f}, -{0x5799,0x06}, -{0x57aa,0x2f}, -{0x57ab,0xff}, -{0x3641,0x0c}, -{0x36e9,0x52}, -{0x36ea,0xbb}, -{0x36eb,0x14}, -{0x36ec,0x05}, -{0x36ed,0x14}, -{0x36f9,0x52}, -{0x36fa,0xbb}, -{0x36fb,0x14}, -{0x36fc,0x10}, -{0x36fd,0x14}, -{0x3641,0x00}, -{0x0100,0x01}, -}; - -I2C_ARRAY Sensor_init_table_4lane_5M30fps[] = -{ -//cleaned_0x10_SC8235_MIPI_4lane_10bit_708.75Mbps_2592x1944_4200x2250_30fps.ini -{0x0103,0x01}, -{0x0100,0x00}, -{0x3018,0x72}, -{0x3019,0x00}, -{0x301f,0x10}, -{0x3031,0x0a}, -{0x3037,0x20}, -{0x3038,0x44}, -{0x3200,0x02}, -{0x3201,0x80}, -{0x3202,0x00}, -{0x3203,0x78}, -{0x3204,0x0c}, -{0x3205,0xa7}, -{0x3206,0x08}, -{0x3207,0x17}, -{0x3208,0x0a}, -{0x3209,0x20}, -{0x320a,0x07}, -{0x320b,0x98}, -{0x320c,0x08}, -{0x320d,0x34}, -{0x3210,0x00}, -{0x3211,0x04}, -{0x3212,0x00}, -{0x3213,0x04}, -{0x3241,0x00}, -{0x3243,0x03}, -{0x3248,0x04}, -{0x3271,0x1c}, -{0x3273,0x1f}, -{0x3301,0x1c}, -{0x3306,0xa8}, -{0x3308,0x20}, -{0x3309,0x68}, -{0x330b,0x48}, -{0x330d,0x28}, -{0x330e,0x58}, -{0x3314,0x94}, -{0x331f,0x59}, -{0x3332,0x24}, -{0x334c,0x10}, -{0x3350,0x24}, -{0x3358,0x24}, -{0x335c,0x24}, -{0x335d,0x60}, -{0x3364,0x16}, -{0x3366,0x92}, -{0x3367,0x08}, -{0x3368,0x07}, -{0x3369,0x00}, -{0x336a,0x00}, -{0x336b,0x00}, -{0x336c,0xc2}, -{0x337f,0x33}, -{0x3390,0x08}, -{0x3391,0x18}, -{0x3392,0x38}, -{0x3393,0x1c}, -{0x3394,0x28}, -{0x3395,0x60}, -{0x3396,0x08}, -{0x3397,0x18}, -{0x3398,0x38}, -{0x3399,0x1c}, -{0x339a,0x1c}, -{0x339b,0x28}, -{0x339c,0x60}, -{0x339e,0x24}, -{0x33aa,0x24}, -{0x33af,0x48}, -{0x33e1,0x08}, -{0x33e2,0x18}, -{0x33e3,0x10}, -{0x33e4,0x0c}, -{0x33e5,0x10}, -{0x33e6,0x06}, -{0x33e7,0x02}, -{0x33e8,0x18}, -{0x33e9,0x10}, -{0x33ea,0x0c}, -{0x33eb,0x10}, -{0x33ec,0x04}, -{0x33ed,0x02}, -{0x33ee,0xa0}, -{0x33ef,0x08}, -{0x33f4,0x18}, -{0x33f5,0x10}, -{0x33f6,0x0c}, -{0x33f7,0x10}, -{0x33f8,0x06}, -{0x33f9,0x02}, -{0x33fa,0x18}, -{0x33fb,0x10}, -{0x33fc,0x0c}, -{0x33fd,0x10}, -{0x33fe,0x04}, -{0x33ff,0x02}, -{0x360f,0x01}, -{0x3622,0xf7}, -{0x3624,0x45}, -{0x3628,0x83}, -{0x3630,0x80}, -{0x3631,0x80}, -{0x3632,0xa8}, -{0x3633,0x53}, -{0x3635,0x02}, -{0x3637,0x52}, -{0x3638,0x0a}, -{0x363a,0x88}, -{0x363b,0x06}, -{0x363d,0x01}, -{0x363e,0x00}, -{0x3670,0x4a}, -{0x3671,0xf7}, -{0x3672,0xf7}, -{0x3673,0x17}, -{0x3674,0x80}, -{0x3675,0x85}, -{0x3676,0xa5}, -{0x367a,0x48}, -{0x367b,0x78}, -{0x367c,0x48}, -{0x367d,0x78}, -{0x3690,0x53}, -{0x3691,0x63}, -{0x3692,0x54}, -{0x3699,0x9f}, -{0x369a,0x9f}, -{0x369b,0x9f}, -{0x369c,0x48}, -{0x369d,0x78}, -{0x36a2,0x48}, -{0x36a3,0x78}, -{0x36bb,0x48}, -{0x36bc,0x78}, -{0x36c9,0x05}, -{0x36ca,0x05}, -{0x36cb,0x05}, -{0x36cc,0x00}, -{0x36cd,0x10}, -{0x36ce,0x1a}, -{0x36d0,0x30}, -{0x36d1,0x48}, -{0x36d2,0x78}, -{0x3901,0x00}, -{0x3902,0xc5}, -{0x3904,0x18}, -{0x3905,0xd8}, -{0x394c,0x0f}, -{0x394d,0x20}, -{0x394e,0x08}, -{0x394f,0x90}, -{0x3980,0x71}, -{0x3981,0x70}, -{0x3982,0x00}, -{0x3983,0x00}, -{0x3984,0x20}, -{0x3987,0x0b}, -{0x3990,0x03}, -{0x3991,0xfd}, -{0x3992,0x03}, -{0x3993,0xfc}, -{0x3994,0x00}, -{0x3995,0x00}, -{0x3996,0x00}, -{0x3997,0x05}, -{0x3998,0x00}, -{0x3999,0x09}, -{0x399a,0x00}, -{0x399b,0x12}, -{0x399c,0x00}, -{0x399d,0x12}, -{0x399e,0x00}, -{0x399f,0x18}, -{0x39a0,0x00}, -{0x39a1,0x14}, -{0x39a2,0x03}, -{0x39a3,0xe3}, -{0x39a4,0x03}, -{0x39a5,0xf2}, -{0x39a6,0x03}, -{0x39a7,0xf6}, -{0x39a8,0x03}, -{0x39a9,0xfa}, -{0x39aa,0x03}, -{0x39ab,0xff}, -{0x39ac,0x00}, -{0x39ad,0x06}, -{0x39ae,0x00}, -{0x39af,0x09}, -{0x39b0,0x00}, -{0x39b1,0x12}, -{0x39b2,0x00}, -{0x39b3,0x22}, -{0x39b4,0x0c}, -{0x39b5,0x1c}, -{0x39b6,0x38}, -{0x39b7,0x5b}, -{0x39b8,0x50}, -{0x39b9,0x38}, -{0x39ba,0x20}, -{0x39bb,0x10}, -{0x39bc,0x0c}, -{0x39bd,0x16}, -{0x39be,0x21}, -{0x39bf,0x36}, -{0x39c0,0x3b}, -{0x39c1,0x2a}, -{0x39c2,0x16}, -{0x39c3,0x0c}, -{0x39c5,0x30}, -{0x39c6,0x07}, -{0x39c7,0xf8}, -{0x39c9,0x07}, -{0x39ca,0xf8}, -{0x39cc,0x00}, -{0x39cd,0x1b}, -{0x39ce,0x00}, -{0x39cf,0x00}, -{0x39d0,0x1b}, -{0x39d1,0x00}, -{0x39e2,0x15}, -{0x39e3,0x87}, -{0x39e4,0x12}, -{0x39e5,0xb7}, -{0x39e6,0x00}, -{0x39e7,0x8c}, -{0x39e8,0x01}, -{0x39e9,0x31}, -{0x39ea,0x01}, -{0x39eb,0xd7}, -{0x39ec,0x08}, -{0x39ed,0x00}, -{0x3e00,0x01}, -{0x3e01,0x18}, -{0x3e02,0xa0}, -{0x3e08,0x03}, -{0x3e09,0x40}, -{0x3e0e,0x09}, -{0x3e14,0x31}, -{0x3e16,0x00}, -{0x3e17,0xac}, -{0x3e18,0x00}, -{0x3e19,0xac}, -{0x3e1b,0x3a}, -{0x3e1e,0x76}, -{0x3e25,0x23}, -{0x3e26,0x40}, -{0x4501,0xa4}, -{0x4509,0x10}, -{0x4837,0x1c}, -{0x5799,0x06}, -{0x57aa,0x2f}, -{0x57ab,0xff}, -{0x3641,0x0c}, -{0x36e9,0x53}, -{0x36ea,0x39}, -{0x36eb,0x06}, -{0x36ec,0x05}, -{0x36ed,0x24}, -{0x36f9,0x57}, -{0x36fa,0x39}, -{0x36fb,0x13}, -{0x36fc,0x10}, -{0x36fd,0x14}, -{0x3641,0x00}, -{0x0100,0x01}, -}; - -I2C_ARRAY Sensor_init_table_4lane_5MP3_30fps[] = -{ -//new_special_0x02_FT_SC8235_MIPI_27Minput_4lane_10bit_708.75Mbps_3072x1728_30fps.ini -{0x0103,0x01}, -{0x0100,0x00}, -{0x36e9,0x80}, -{0x36f9,0x80}, -{0x336c,0xc2}, -{0x3624,0x45}, -{0x33e1,0x08}, -{0x33e2,0x18}, -{0x33e3,0x10}, -{0x33e4,0x0c}, -{0x33e5,0x10}, -{0x33e6,0x06}, -{0x33e7,0x02}, -{0x33e8,0x18}, -{0x33e9,0x10}, -{0x33ea,0x0c}, -{0x33eb,0x10}, -{0x33ec,0x04}, -{0x33ed,0x02}, -{0x33ee,0xa0}, -{0x33ef,0x08}, -{0x33f4,0x18}, -{0x33f5,0x10}, -{0x33f6,0x0c}, -{0x33f7,0x10}, -{0x33f8,0x06}, -{0x33f9,0x02}, -{0x33fa,0x18}, -{0x33fb,0x10}, -{0x33fc,0x0c}, -{0x33fd,0x10}, -{0x33fe,0x04}, -{0x33ff,0x02}, -{0x5799,0x06}, -{0x3e16,0x00}, -{0x3e17,0xac}, -{0x3e18,0x00}, -{0x3e19,0xac}, -{0x3e0e,0x09}, -{0x3e1e,0x76}, -{0x3e25,0x23}, -{0x57aa,0x2f}, -{0x57ab,0xff}, -{0x3018,0x72}, -{0x3019,0x00}, -{0x3031,0x0a}, -{0x3037,0x20}, -{0x4501,0xa4}, -{0x4509,0x10}, -{0x4837,0x1c}, -{0x3366,0x92}, -{0x3314,0x94}, -{0x334c,0x10}, -{0x3e09,0x40}, -{0x3e08,0x03}, -{0x3637,0x52}, -{0x3631,0x80}, -{0x3308,0x20}, -{0x320c,0x08}, -{0x320d,0x34}, -{0x335d,0x60}, -{0x337f,0x33}, -{0x3368,0x07}, -{0x3369,0x00}, -{0x336a,0x00}, -{0x336b,0x00}, -{0x3367,0x08}, -{0x330e,0x58}, -{0x33af,0x48}, -{0x3638,0x0a}, -{0x3306,0xa8}, -{0x3309,0x68}, -{0x331f,0x59}, -{0x330d,0x28}, -{0x339e,0x24}, -{0x33aa,0x24}, -{0x3332,0x24}, -{0x3350,0x24}, -{0x3358,0x24}, -{0x335c,0x24}, -{0x3628,0x83}, -{0x3633,0x53}, -{0x3630,0x80}, -{0x3622,0xf7}, -{0x363d,0x01}, -{0x363e,0x00}, -{0x363a,0x88}, -{0x3e26,0x40}, -{0x360f,0x01}, -{0x367a,0x48}, -{0x367b,0x78}, -{0x3671,0xf7}, -{0x3672,0xf7}, -{0x3673,0x17}, -{0x3670,0x4a}, -{0x367c,0x48}, -{0x367d,0x78}, -{0x3674,0x80}, -{0x3675,0x85}, -{0x3676,0xa5}, -{0x369c,0x48}, -{0x369d,0x78}, -{0x3690,0x53}, -{0x3691,0x63}, -{0x3692,0x54}, -{0x36a2,0x48}, -{0x36a3,0x78}, -{0x3699,0x88}, -{0x369a,0x9f}, -{0x369b,0x9f}, -{0x36bb,0x48}, -{0x36bc,0x78}, -{0x36c9,0x05}, -{0x36ca,0x05}, -{0x36cb,0x05}, -{0x36d0,0x30}, -{0x36d1,0x48}, -{0x36d2,0x78}, -{0x36cc,0x00}, -{0x36cd,0x10}, -{0x36ce,0x1a}, -{0x3364,0x16}, -{0x3301,0x1c}, -{0x3393,0x1c}, -{0x3394,0x28}, -{0x3395,0x60}, -{0x3390,0x08}, -{0x3391,0x18}, -{0x3392,0x38}, -{0x3399,0x1c}, -{0x339a,0x1c}, -{0x339b,0x28}, -{0x339c,0x60}, -{0x3396,0x08}, -{0x3397,0x18}, -{0x3398,0x38}, -{0x3241,0x00}, -{0x3243,0x03}, -{0x3271,0x1c}, -{0x3273,0x1f}, -{0x394c,0x0f}, -{0x394d,0x20}, -{0x394e,0x08}, -{0x394f,0x90}, -{0x3981,0x70}, -{0x3984,0x20}, -{0x39ec,0x08}, -{0x39ed,0x00}, -{0x3982,0x00}, -{0x3983,0x00}, -{0x3980,0x71}, -{0x39b4,0x0c}, -{0x39b5,0x1c}, -{0x39b6,0x38}, -{0x39b7,0x5b}, -{0x39b8,0x50}, -{0x39b9,0x38}, -{0x39ba,0x20}, -{0x39bb,0x10}, -{0x39bc,0x0c}, -{0x39bd,0x16}, -{0x39be,0x21}, -{0x39bf,0x36}, -{0x39c0,0x3b}, -{0x39c1,0x2a}, -{0x39c2,0x16}, -{0x39c3,0x0c}, -{0x39a2,0x03}, -{0x39a3,0xe3}, -{0x39a4,0x03}, -{0x39a5,0xf2}, -{0x39a6,0x03}, -{0x39a7,0xf6}, -{0x39a8,0x03}, -{0x39a9,0xfa}, -{0x39aa,0x03}, -{0x39ab,0xff}, -{0x39ac,0x00}, -{0x39ad,0x06}, -{0x39ae,0x00}, -{0x39af,0x09}, -{0x39b0,0x00}, -{0x39b1,0x12}, -{0x39b2,0x00}, -{0x39b3,0x22}, -{0x39c6,0x07}, -{0x39c7,0xf8}, -{0x39c9,0x07}, -{0x39ca,0xf8}, -{0x3990,0x03}, -{0x3991,0xfd}, -{0x3992,0x03}, -{0x3993,0xfc}, -{0x3994,0x00}, -{0x3995,0x00}, -{0x3996,0x00}, -{0x3997,0x05}, -{0x3998,0x00}, -{0x3999,0x09}, -{0x399a,0x00}, -{0x399b,0x12}, -{0x399c,0x00}, -{0x399d,0x12}, -{0x399e,0x00}, -{0x399f,0x18}, -{0x39a0,0x00}, -{0x39a1,0x14}, -{0x39cc,0x00}, -{0x39cd,0x1b}, -{0x39ce,0x00}, -{0x39cf,0x00}, -{0x39d0,0x1b}, -{0x39d1,0x00}, -{0x39e2,0x15}, -{0x39e3,0x87}, -{0x39e4,0x12}, -{0x39e5,0xb7}, -{0x39e6,0x00}, -{0x39e7,0x8c}, -{0x39e8,0x01}, -{0x39e9,0x31}, -{0x39ea,0x01}, -{0x39eb,0xd7}, -{0x39c5,0x30}, -{0x330b,0x48}, -{0x36f9,0x57}, -{0x36fa,0x39}, -{0x36fb,0x13}, -{0x36fc,0x10}, -{0x36fd,0x14}, -{0x36e9,0x53}, -{0x36ea,0x39}, -{0x36eb,0x06}, -{0x36ec,0x05}, -{0x36ed,0x24}, -{0x3635,0x02}, -{0x3902,0xc5}, -{0x3038,0x44}, -{0x3632,0x98}, -{0x3e14,0x31}, -{0x3e1b,0x3a}, -{0x3248,0x04}, -{0x3901,0x00}, -{0x3904,0x18}, -{0x3987,0x0b}, -{0x363b,0x06}, -{0x3905,0xd8}, -{0x301f,0x02}, -{0x3200,0x01}, -{0x3201,0x88}, -{0x3202,0x00}, -{0x3203,0xda}, -{0x3204,0x0d}, -{0x3205,0x97}, -{0x3206,0x07}, -{0x3207,0xa9}, -{0x3208,0x0c}, -{0x3209,0x00}, -{0x320a,0x06}, -{0x320b,0xc0}, -{0x3210,0x00}, -{0x3211,0x08}, -{0x3212,0x00}, -{0x3213,0x08}, -{0x3e00,0x01}, -{0x3e01,0x18}, -{0x3e02,0xa0}, -{0x0100,0x01}, -}; - - -I2C_ARRAY Sensor_init_table_4lane_4P8M30fps[] = -{ -//cleaned_0x11_SC8235_MIPI_4lane_10bit_708.75Mbps_2944x1656_4200x2250_30fps.ini -{0x0103,0x01}, -{0x0100,0x00}, -{0x3018,0x72}, -{0x3019,0x00}, -{0x301f,0x11}, -{0x3031,0x0a}, -{0x3037,0x20}, -{0x3038,0x44}, -{0x3200,0x01}, -{0x3201,0xd0}, -{0x3202,0x01}, -{0x3203,0x08}, -{0x3204,0x0d}, -{0x3205,0x57}, -{0x3206,0x07}, -{0x3207,0x87}, -{0x3208,0x0b}, -{0x3209,0x80}, -{0x320a,0x06}, -{0x320b,0x78}, -{0x320c,0x08}, -{0x320d,0x34}, -{0x3210,0x00}, -{0x3211,0x04}, -{0x3212,0x00}, -{0x3213,0x04}, -{0x3241,0x00}, -{0x3243,0x03}, -{0x3248,0x04}, -{0x3271,0x1c}, -{0x3273,0x1f}, -{0x3301,0x1c}, -{0x3306,0xa8}, -{0x3308,0x20}, -{0x3309,0x68}, -{0x330b,0x48}, -{0x330d,0x28}, -{0x330e,0x58}, -{0x3314,0x94}, -{0x331f,0x59}, -{0x3332,0x24}, -{0x334c,0x10}, -{0x3350,0x24}, -{0x3358,0x24}, -{0x335c,0x24}, -{0x335d,0x60}, -{0x3364,0x16}, -{0x3366,0x92}, -{0x3367,0x08}, -{0x3368,0x07}, -{0x3369,0x00}, -{0x336a,0x00}, -{0x336b,0x00}, -{0x336c,0xc2}, -{0x337f,0x33}, -{0x3390,0x08}, -{0x3391,0x18}, -{0x3392,0x38}, -{0x3393,0x1c}, -{0x3394,0x28}, -{0x3395,0x60}, -{0x3396,0x08}, -{0x3397,0x18}, -{0x3398,0x38}, -{0x3399,0x1c}, -{0x339a,0x1c}, -{0x339b,0x28}, -{0x339c,0x60}, -{0x339e,0x24}, -{0x33aa,0x24}, -{0x33af,0x48}, -{0x33e1,0x08}, -{0x33e2,0x18}, -{0x33e3,0x10}, -{0x33e4,0x0c}, -{0x33e5,0x10}, -{0x33e6,0x06}, -{0x33e7,0x02}, -{0x33e8,0x18}, -{0x33e9,0x10}, -{0x33ea,0x0c}, -{0x33eb,0x10}, -{0x33ec,0x04}, -{0x33ed,0x02}, -{0x33ee,0xa0}, -{0x33ef,0x08}, -{0x33f4,0x18}, -{0x33f5,0x10}, -{0x33f6,0x0c}, -{0x33f7,0x10}, -{0x33f8,0x06}, -{0x33f9,0x02}, -{0x33fa,0x18}, -{0x33fb,0x10}, -{0x33fc,0x0c}, -{0x33fd,0x10}, -{0x33fe,0x04}, -{0x33ff,0x02}, -{0x360f,0x01}, -{0x3622,0xf7}, -{0x3624,0x45}, -{0x3628,0x83}, -{0x3630,0x80}, -{0x3631,0x80}, -{0x3632,0xa8}, -{0x3633,0x53}, -{0x3635,0x02}, -{0x3637,0x52}, -{0x3638,0x0a}, -{0x363a,0x88}, -{0x363b,0x06}, -{0x363d,0x01}, -{0x363e,0x00}, -{0x3670,0x4a}, -{0x3671,0xf7}, -{0x3672,0xf7}, -{0x3673,0x17}, -{0x3674,0x80}, -{0x3675,0x85}, -{0x3676,0xa5}, -{0x367a,0x48}, -{0x367b,0x78}, -{0x367c,0x48}, -{0x367d,0x78}, -{0x3690,0x53}, -{0x3691,0x63}, -{0x3692,0x54}, -{0x3699,0x9f}, -{0x369a,0x9f}, -{0x369b,0x9f}, -{0x369c,0x48}, -{0x369d,0x78}, -{0x36a2,0x48}, -{0x36a3,0x78}, -{0x36bb,0x48}, -{0x36bc,0x78}, -{0x36c9,0x05}, -{0x36ca,0x05}, -{0x36cb,0x05}, -{0x36cc,0x00}, -{0x36cd,0x10}, -{0x36ce,0x1a}, -{0x36d0,0x30}, -{0x36d1,0x48}, -{0x36d2,0x78}, -{0x3901,0x00}, -{0x3902,0xc5}, -{0x3904,0x18}, -{0x3905,0xd8}, -{0x394c,0x0f}, -{0x394d,0x20}, -{0x394e,0x08}, -{0x394f,0x90}, -{0x3980,0x71}, -{0x3981,0x70}, -{0x3982,0x00}, -{0x3983,0x00}, -{0x3984,0x20}, -{0x3987,0x0b}, -{0x3990,0x03}, -{0x3991,0xfd}, -{0x3992,0x03}, -{0x3993,0xfc}, -{0x3994,0x00}, -{0x3995,0x00}, -{0x3996,0x00}, -{0x3997,0x05}, -{0x3998,0x00}, -{0x3999,0x09}, -{0x399a,0x00}, -{0x399b,0x12}, -{0x399c,0x00}, -{0x399d,0x12}, -{0x399e,0x00}, -{0x399f,0x18}, -{0x39a0,0x00}, -{0x39a1,0x14}, -{0x39a2,0x03}, -{0x39a3,0xe3}, -{0x39a4,0x03}, -{0x39a5,0xf2}, -{0x39a6,0x03}, -{0x39a7,0xf6}, -{0x39a8,0x03}, -{0x39a9,0xfa}, -{0x39aa,0x03}, -{0x39ab,0xff}, -{0x39ac,0x00}, -{0x39ad,0x06}, -{0x39ae,0x00}, -{0x39af,0x09}, -{0x39b0,0x00}, -{0x39b1,0x12}, -{0x39b2,0x00}, -{0x39b3,0x22}, -{0x39b4,0x0c}, -{0x39b5,0x1c}, -{0x39b6,0x38}, -{0x39b7,0x5b}, -{0x39b8,0x50}, -{0x39b9,0x38}, -{0x39ba,0x20}, -{0x39bb,0x10}, -{0x39bc,0x0c}, -{0x39bd,0x16}, -{0x39be,0x21}, -{0x39bf,0x36}, -{0x39c0,0x3b}, -{0x39c1,0x2a}, -{0x39c2,0x16}, -{0x39c3,0x0c}, -{0x39c5,0x30}, -{0x39c6,0x07}, -{0x39c7,0xf8}, -{0x39c9,0x07}, -{0x39ca,0xf8}, -{0x39cc,0x00}, -{0x39cd,0x1b}, -{0x39ce,0x00}, -{0x39cf,0x00}, -{0x39d0,0x1b}, -{0x39d1,0x00}, -{0x39e2,0x15}, -{0x39e3,0x87}, -{0x39e4,0x12}, -{0x39e5,0xb7}, -{0x39e6,0x00}, -{0x39e7,0x8c}, -{0x39e8,0x01}, -{0x39e9,0x31}, -{0x39ea,0x01}, -{0x39eb,0xd7}, -{0x39ec,0x08}, -{0x39ed,0x00}, -{0x3e00,0x01}, -{0x3e01,0x18}, -{0x3e02,0xa0}, -{0x3e08,0x03}, -{0x3e09,0x40}, -{0x3e0e,0x09}, -{0x3e14,0x31}, -{0x3e16,0x00}, -{0x3e17,0xac}, -{0x3e18,0x00}, -{0x3e19,0xac}, -{0x3e1b,0x3a}, -{0x3e1e,0x76}, -{0x3e25,0x23}, -{0x3e26,0x40}, -{0x4501,0xa4}, -{0x4509,0x10}, -{0x4837,0x1c}, -{0x5799,0x06}, -{0x57aa,0x2f}, -{0x57ab,0xff}, -{0x3641,0x0c}, -{0x36e9,0x53}, -{0x36ea,0x39}, -{0x36eb,0x06}, -{0x36ec,0x05}, -{0x36ed,0x24}, -{0x36f9,0x57}, -{0x36fa,0x39}, -{0x36fb,0x13}, -{0x36fc,0x10}, -{0x36fd,0x14}, -{0x3641,0x00}, -{0x0100,0x01}, - -}; - - -I2C_ARRAY Sensor_init_table_4lane_3P6M30fps[] = -{ -//cleaned_0x1e_SC8235_MIPI_27Minput_4lane_10bit_583.2Mbps_2560x1440_30fps_2592x1500.ini -{0x0103,0x01}, -{0x0100,0x00}, -{0x3018,0x72}, -{0x3019,0x00}, -{0x301f,0x1e}, -{0x3031,0x0a}, -{0x3037,0x20}, -{0x3038,0x44}, -{0x3200,0x02}, -{0x3201,0x88}, -{0x3202,0x02}, -{0x3203,0xd8}, -{0x3204,0x0c}, -{0x3205,0x8f}, -{0x3206,0x08}, -{0x3207,0x7f}, -{0x3208,0x0a}, -{0x3209,0x00}, -{0x320a,0x05}, -{0x320b,0xa0}, -{0x320c,0x0a}, -{0x320d,0x20}, -{0x320e,0x05}, -{0x320f,0xdc}, -{0x3210,0x00}, -{0x3211,0x04}, -{0x3212,0x00}, -{0x3213,0x04}, -{0x3241,0x00}, -{0x3243,0x03}, -{0x3248,0x04}, -{0x3271,0x1c}, -{0x3273,0x1f}, -{0x3301,0x1c}, -{0x3306,0xc8}, -{0x3309,0x40}, -{0x330b,0xc0}, -{0x330e,0x60}, -{0x3314,0x94}, -{0x331f,0x31}, -{0x334c,0x10}, -{0x335d,0x60}, -{0x3364,0x16}, -{0x3366,0x92}, -{0x3367,0x08}, -{0x3368,0x09}, -{0x3369,0x00}, -{0x336a,0x00}, -{0x336b,0x00}, -{0x336c,0xc2}, -{0x337f,0x33}, -{0x3390,0x08}, -{0x3391,0x18}, -{0x3392,0x38}, -{0x3393,0x1c}, -{0x3394,0x28}, -{0x3395,0x60}, -{0x3396,0x08}, -{0x3397,0x18}, -{0x3398,0x38}, -{0x3399,0x1c}, -{0x339a,0x1c}, -{0x339b,0x28}, -{0x339c,0x60}, -{0x33af,0x24}, -{0x33e0,0xa0}, -{0x33e1,0x08}, -{0x33e2,0x18}, -{0x33e3,0x10}, -{0x33e4,0x0c}, -{0x33e5,0x10}, -{0x33e6,0x06}, -{0x33e7,0x02}, -{0x33e8,0x18}, -{0x33e9,0x10}, -{0x33ea,0x0c}, -{0x33eb,0x10}, -{0x33ec,0x04}, -{0x33ed,0x02}, -{0x33ee,0xa0}, -{0x33ef,0x08}, -{0x33f4,0x18}, -{0x33f5,0x10}, -{0x33f6,0x0c}, -{0x33f7,0x10}, -{0x33f8,0x06}, -{0x33f9,0x02}, -{0x33fa,0x18}, -{0x33fb,0x10}, -{0x33fc,0x0c}, -{0x33fd,0x10}, -{0x33fe,0x04}, -{0x33ff,0x02}, -{0x360f,0x01}, -{0x3622,0xf7}, -{0x3624,0x45}, -{0x3628,0x83}, -{0x3630,0x80}, -{0x3631,0x80}, -{0x3632,0xa8}, -{0x3633,0x22}, -{0x3635,0x02}, -{0x3637,0x29}, -{0x3638,0x08}, -{0x363a,0x88}, -{0x363b,0x06}, -{0x363d,0x01}, -{0x363e,0x00}, -{0x3670,0x4a}, -{0x3671,0xf7}, -{0x3672,0xf7}, -{0x3673,0x17}, -{0x3674,0x80}, -{0x3675,0x85}, -{0x3676,0xa5}, -{0x367a,0x48}, -{0x367b,0x78}, -{0x367c,0x48}, -{0x367d,0x78}, -{0x3690,0x53}, -{0x3691,0x63}, -{0x3692,0x55}, -{0x3699,0x9f}, -{0x369a,0x9f}, -{0x369b,0x9f}, -{0x369c,0x48}, -{0x369d,0x78}, -{0x36a2,0x48}, -{0x36a3,0x78}, -{0x36bb,0x48}, -{0x36bc,0x78}, -{0x36c9,0x05}, -{0x36ca,0x05}, -{0x36cb,0x05}, -{0x36cc,0x00}, -{0x36cd,0x10}, -{0x36ce,0x1a}, -{0x36d0,0x30}, -{0x36d1,0x48}, -{0x36d2,0x78}, -{0x3901,0x00}, -{0x3902,0xc5}, -{0x3904,0x18}, -{0x3905,0xd8}, -{0x394c,0x0f}, -{0x394d,0x20}, -{0x394e,0x08}, -{0x394f,0x90}, -{0x3980,0x71}, -{0x3981,0x70}, -{0x3982,0x00}, -{0x3983,0x00}, -{0x3984,0x20}, -{0x3987,0x0b}, -{0x3990,0x03}, -{0x3991,0xfd}, -{0x3992,0x03}, -{0x3993,0xfc}, -{0x3994,0x03}, -{0x3995,0xff}, -{0x3996,0x00}, -{0x3997,0x03}, -{0x3998,0x00}, -{0x3999,0x06}, -{0x399a,0x00}, -{0x399b,0x0e}, -{0x399c,0x00}, -{0x399d,0x10}, -{0x399e,0x00}, -{0x399f,0x18}, -{0x39a0,0x00}, -{0x39a1,0x14}, -{0x39a2,0x03}, -{0x39a3,0xe3}, -{0x39a4,0x03}, -{0x39a5,0xee}, -{0x39a6,0x03}, -{0x39a7,0xf4}, -{0x39a8,0x03}, -{0x39a9,0xf6}, -{0x39aa,0x03}, -{0x39ab,0xfd}, -{0x39ac,0x00}, -{0x39ad,0x04}, -{0x39ae,0x00}, -{0x39af,0x06}, -{0x39b0,0x00}, -{0x39b1,0x0e}, -{0x39b2,0x00}, -{0x39b3,0x1c}, -{0x39b4,0x0c}, -{0x39b5,0x1c}, -{0x39b6,0x38}, -{0x39b7,0x5b}, -{0x39b8,0x50}, -{0x39b9,0x38}, -{0x39ba,0x20}, -{0x39bb,0x10}, -{0x39bc,0x0c}, -{0x39bd,0x16}, -{0x39be,0x21}, -{0x39bf,0x36}, -{0x39c0,0x3b}, -{0x39c1,0x2a}, -{0x39c2,0x16}, -{0x39c3,0x0c}, -{0x39c5,0x30}, -{0x39c6,0x07}, -{0x39c7,0xf8}, -{0x39c9,0x07}, -{0x39ca,0xf8}, -{0x39cc,0x00}, -{0x39cd,0x1b}, -{0x39ce,0x00}, -{0x39cf,0x00}, -{0x39d0,0x1b}, -{0x39d1,0x00}, -{0x39e2,0x19}, -{0x39e3,0xe9}, -{0x39e4,0x0e}, -{0x39e5,0x14}, -{0x39e6,0x00}, -{0x39e7,0x23}, -{0x39e8,0x03}, -{0x39e9,0xba}, -{0x39ea,0x02}, -{0x39eb,0x6d}, -{0x39ec,0x08}, -{0x39ed,0x00}, -{0x3e00,0x00}, -{0x3e01,0xba}, -{0x3e02,0xe0}, -{0x3e08,0x03}, -{0x3e09,0x40}, -{0x3e0e,0x09}, -{0x3e14,0x31}, -{0x3e16,0x00}, -{0x3e17,0xac}, -{0x3e18,0x00}, -{0x3e19,0xac}, -{0x3e1b,0x3a}, -{0x3e1e,0x76}, -{0x3e25,0x23}, -{0x3e26,0x40}, -{0x3f00,0x4e}, -{0x3f05,0x70}, -{0x4501,0xb4}, -{0x4509,0x20}, -{0x4837,0x22}, -{0x5799,0x06}, -{0x57aa,0x2f}, -{0x57ab,0xff}, -{0x3641,0x0c}, -{0x36e9,0x37}, -{0x36ea,0x7d}, -{0x36eb,0x14}, -{0x36ec,0x05}, -{0x36ed,0x14}, -{0x36f9,0x37}, -{0x36fa,0x7d}, -{0x36fb,0x14}, -{0x36fc,0x10}, -{0x36fd,0x14}, -{0x3641,0x00}, -{0x0100,0x01}, - -}; - - -I2C_ARRAY Sensor_init_table_4lane_2M60fps[] = -{ -//cleaned_0x29_SC8235_MIPI_27Minput_4lane_10bit_675Mbps_1920x1080_60fps_hbin_vbin_2000x1125.ini -{0x0103,0x01}, -{0x0100,0x00}, -{0x3018,0x72}, -{0x3019,0x00}, -{0x301f,0x29}, -{0x3031,0x0a}, -{0x3037,0x20}, -{0x3038,0x44}, -{0x3203,0x08}, -{0x3207,0x87}, -{0x3208,0x07}, -{0x3209,0x80}, -{0x320a,0x04}, -{0x320b,0x38}, -{0x320c,0x07}, -{0x320d,0xd0}, -{0x320e,0x04}, -{0x320f,0x65}, -{0x3211,0x08}, -{0x3213,0x04}, -{0x3214,0x31}, -{0x3215,0x31}, -{0x3220,0x1c}, -{0x3241,0x00}, -{0x3243,0x03}, -{0x3248,0x04}, -{0x3271,0x1c}, -{0x3273,0x1f}, -{0x3301,0x1c}, -{0x3306,0xa0}, -{0x3308,0x20}, -{0x3309,0x68}, -{0x330b,0x38}, -{0x330d,0x28}, -{0x330e,0x58}, -{0x3314,0x94}, -{0x331f,0x59}, -{0x3332,0x24}, -{0x334c,0x10}, -{0x3350,0x24}, -{0x3358,0x24}, -{0x335c,0x24}, -{0x335d,0x60}, -{0x3364,0x16}, -{0x3366,0x92}, -{0x3367,0x08}, -{0x3368,0x07}, -{0x3369,0x00}, -{0x336a,0x00}, -{0x336b,0x00}, -{0x336c,0xc2}, -{0x337f,0x33}, -{0x3390,0x08}, -{0x3391,0x18}, -{0x3392,0x38}, -{0x3393,0x1c}, -{0x3394,0x28}, -{0x3395,0x38}, -{0x3396,0x08}, -{0x3397,0x18}, -{0x3398,0x38}, -{0x3399,0x1c}, -{0x339a,0x1c}, -{0x339b,0x28}, -{0x339c,0x38}, -{0x339e,0x24}, -{0x33aa,0x24}, -{0x33af,0x48}, -{0x33e1,0x08}, -{0x33e2,0x18}, -{0x33e3,0x10}, -{0x33e4,0x0c}, -{0x33e5,0x10}, -{0x33e6,0x06}, -{0x33e7,0x02}, -{0x33e8,0x18}, -{0x33e9,0x10}, -{0x33ea,0x0c}, -{0x33eb,0x10}, -{0x33ec,0x04}, -{0x33ed,0x02}, -{0x33ee,0xa0}, -{0x33ef,0x08}, -{0x33f4,0x18}, -{0x33f5,0x10}, -{0x33f6,0x0c}, -{0x33f7,0x10}, -{0x33f8,0x06}, -{0x33f9,0x02}, -{0x33fa,0x18}, -{0x33fb,0x10}, -{0x33fc,0x0c}, -{0x33fd,0x10}, -{0x33fe,0x04}, -{0x33ff,0x02}, -{0x360f,0x01}, -{0x3620,0x48}, -{0x3622,0xf7}, -{0x3624,0x45}, -{0x3628,0x83}, -{0x3630,0x80}, -{0x3631,0x80}, -{0x3632,0xa8}, -{0x3633,0x23}, -{0x3635,0x02}, -{0x3637,0x52}, -{0x3638,0x0a}, -{0x363a,0x88}, -{0x363b,0x06}, -{0x363d,0x01}, -{0x363e,0x00}, -{0x3670,0x4a}, -{0x3671,0xf7}, -{0x3672,0xf7}, -{0x3673,0x17}, -{0x3674,0x80}, -{0x3675,0x85}, -{0x3676,0xa5}, -{0x367a,0x48}, -{0x367b,0x78}, -{0x367c,0x48}, -{0x367d,0x78}, -{0x3690,0x53}, -{0x3691,0x63}, -{0x3692,0x54}, -{0x3699,0x9f}, -{0x369a,0x9f}, -{0x369b,0x9f}, -{0x369c,0x48}, -{0x369d,0x78}, -{0x36a2,0x48}, -{0x36a3,0x78}, -{0x36bb,0x48}, -{0x36bc,0x78}, -{0x36c9,0x05}, -{0x36ca,0x05}, -{0x36cb,0x05}, -{0x36cc,0x00}, -{0x36cd,0x10}, -{0x36ce,0x1a}, -{0x36d0,0x30}, -{0x36d1,0x48}, -{0x36d2,0x78}, -{0x3901,0x00}, -{0x3902,0xc5}, -{0x3904,0x18}, -{0x3905,0xd8}, -{0x394c,0x0f}, -{0x394d,0x20}, -{0x394e,0x08}, -{0x394f,0x90}, -{0x3980,0x71}, -{0x3981,0x70}, -{0x3982,0x00}, -{0x3983,0x00}, -{0x3984,0x20}, -{0x3987,0x0b}, -{0x3990,0x03}, -{0x3991,0xfd}, -{0x3992,0x03}, -{0x3993,0xfc}, -{0x3994,0x00}, -{0x3995,0x00}, -{0x3996,0x00}, -{0x3997,0x05}, -{0x3998,0x00}, -{0x3999,0x09}, -{0x399a,0x00}, -{0x399b,0x12}, -{0x399c,0x00}, -{0x399d,0x12}, -{0x399e,0x00}, -{0x399f,0x18}, -{0x39a0,0x00}, -{0x39a1,0x14}, -{0x39a2,0x03}, -{0x39a3,0xe3}, -{0x39a4,0x03}, -{0x39a5,0xf2}, -{0x39a6,0x03}, -{0x39a7,0xf6}, -{0x39a8,0x03}, -{0x39a9,0xfa}, -{0x39aa,0x03}, -{0x39ab,0xff}, -{0x39ac,0x00}, -{0x39ad,0x06}, -{0x39ae,0x00}, -{0x39af,0x09}, -{0x39b0,0x00}, -{0x39b1,0x12}, -{0x39b2,0x00}, -{0x39b3,0x22}, -{0x39b4,0x0c}, -{0x39b5,0x1c}, -{0x39b6,0x38}, -{0x39b7,0x5b}, -{0x39b8,0x50}, -{0x39b9,0x38}, -{0x39ba,0x20}, -{0x39bb,0x10}, -{0x39bc,0x0c}, -{0x39bd,0x16}, -{0x39be,0x21}, -{0x39bf,0x36}, -{0x39c0,0x3b}, -{0x39c1,0x2a}, -{0x39c2,0x16}, -{0x39c3,0x0c}, -{0x39c5,0x30}, -{0x39c6,0x07}, -{0x39c7,0xf8}, -{0x39c9,0x07}, -{0x39ca,0xf8}, -{0x39cc,0x00}, -{0x39cd,0x1b}, -{0x39ce,0x00}, -{0x39cf,0x00}, -{0x39d0,0x1b}, -{0x39d1,0x00}, -{0x39e2,0x15}, -{0x39e3,0x87}, -{0x39e4,0x12}, -{0x39e5,0xb7}, -{0x39e6,0x00}, -{0x39e7,0x8c}, -{0x39e8,0x01}, -{0x39e9,0x31}, -{0x39ea,0x01}, -{0x39eb,0xd7}, -{0x39ec,0x08}, -{0x39ed,0x00}, -{0x3e00,0x00}, -{0x3e01,0x8c}, -{0x3e02,0x00}, -{0x3e08,0x03}, -{0x3e09,0x40}, -{0x3e0e,0x09}, -{0x3e14,0x31}, -{0x3e16,0x00}, -{0x3e17,0xac}, -{0x3e18,0x00}, -{0x3e19,0xac}, -{0x3e1b,0x3a}, -{0x3e1e,0x76}, -{0x3e25,0x23}, -{0x3e26,0x40}, -{0x4501,0xa4}, -{0x4509,0x10}, -{0x450d,0x08}, -{0x4837,0x1c}, -{0x5799,0x06}, -{0x57aa,0x2f}, -{0x57ab,0xff}, -{0x3641,0x0c}, -{0x36e9,0x40}, -{0x36ea,0x31}, -{0x36eb,0x06}, -{0x36ec,0x05}, -{0x36ed,0x24}, -{0x36f9,0x44}, -{0x36fa,0x31}, -{0x36fb,0x13}, -{0x36fc,0x10}, -{0x36fd,0x14}, -{0x3641,0x00}, -{0x0100,0x01}, - -}; - -I2C_ARRAY Sensor_init_table_HDR_DOL_4lane[] = -{ -//cleaned_0x23_SC8235_MIPI_27Minput_4lane_10bit_708.75Mbps_3840x2160_hdr(vc)_15fps_4200x4500.ini -{0x0103,0x01}, -{0x0100,0x00}, -{0x3018,0x72}, -{0x3019,0x00}, -{0x301f,0x23}, -{0x3031,0x0a}, -{0x3037,0x20}, -{0x3038,0x44}, -{0x320c,0x08}, -{0x320d,0x34}, -{0x320e,0x11}, -{0x320f,0x94}, -{0x3220,0x50}, -{0x3241,0x00}, -{0x3243,0x03}, -{0x3248,0x04}, -{0x3250,0x3f}, -{0x3271,0x1c}, -{0x3273,0x1f}, -{0x3301,0x1c}, -{0x3306,0xa8}, -{0x3308,0x20}, -{0x3309,0x68}, -{0x330b,0x48}, -{0x330d,0x28}, -{0x330e,0x58}, -{0x3314,0x98}, -{0x331f,0x59}, -{0x3332,0x24}, -{0x334a,0x18}, -{0x334c,0x10}, -{0x3350,0x24}, -{0x3358,0x24}, -{0x335c,0x24}, -{0x335d,0x60}, -{0x3360,0x40}, -{0x3362,0x72}, -{0x3364,0x16}, -{0x3366,0x92}, -{0x3367,0x08}, -{0x3368,0x10}, -{0x3369,0x00}, -{0x336a,0x00}, -{0x336b,0x00}, -{0x336c,0xc2}, -{0x336f,0x58}, -{0x337f,0x33}, -{0x3390,0x08}, -{0x3391,0x18}, -{0x3392,0x38}, -{0x3393,0x1c}, -{0x3394,0x28}, -{0x3395,0x60}, -{0x3396,0x08}, -{0x3397,0x18}, -{0x3398,0x38}, -{0x3399,0x1c}, -{0x339a,0x1c}, -{0x339b,0x28}, -{0x339c,0x60}, -{0x339e,0x24}, -{0x33aa,0x24}, -{0x33af,0x48}, -{0x33e1,0x08}, -{0x33e2,0x18}, -{0x33e3,0x10}, -{0x33e4,0x0c}, -{0x33e5,0x10}, -{0x33e6,0x06}, -{0x33e7,0x02}, -{0x33e8,0x18}, -{0x33e9,0x10}, -{0x33ea,0x0c}, -{0x33eb,0x10}, -{0x33ec,0x04}, -{0x33ed,0x02}, -{0x33ee,0xa0}, -{0x33ef,0x08}, -{0x33f4,0x18}, -{0x33f5,0x10}, -{0x33f6,0x0c}, -{0x33f7,0x10}, -{0x33f8,0x06}, -{0x33f9,0x02}, -{0x33fa,0x18}, -{0x33fb,0x10}, -{0x33fc,0x0c}, -{0x33fd,0x10}, -{0x33fe,0x04}, -{0x33ff,0x02}, -{0x360f,0x01}, -{0x3622,0xf7}, -{0x3624,0x45}, -{0x3628,0x83}, -{0x3630,0x80}, -{0x3631,0x80}, -{0x3632,0xa8}, -{0x3633,0x23}, -{0x3635,0x02}, -{0x3636,0x11}, -{0x3637,0x10}, -{0x3638,0x0a}, -{0x363a,0x88}, -{0x363b,0x06}, -{0x363d,0x01}, -{0x363e,0x00}, -{0x3670,0x4a}, -{0x3671,0xf7}, -{0x3672,0xf7}, -{0x3673,0x17}, -{0x3674,0x80}, -{0x3675,0x85}, -{0x3676,0xa5}, -{0x367a,0x48}, -{0x367b,0x78}, -{0x367c,0x48}, -{0x367d,0x78}, -{0x3690,0x53}, -{0x3691,0x63}, -{0x3692,0x54}, -{0x3699,0x88}, -{0x369a,0x88}, -{0x369b,0x88}, -{0x369c,0x48}, -{0x369d,0x78}, -{0x36a2,0x48}, -{0x36a3,0x78}, -{0x36bb,0x48}, -{0x36bc,0x78}, -{0x36c9,0x05}, -{0x36ca,0x05}, -{0x36cb,0x05}, -{0x36cc,0x00}, -{0x36cd,0x10}, -{0x36ce,0x1a}, -{0x36d0,0x30}, -{0x36d1,0x48}, -{0x36d2,0x78}, -{0x3901,0x00}, -{0x3902,0xc5}, -{0x3904,0x18}, -{0x3905,0xd8}, -{0x394c,0x0f}, -{0x394d,0x20}, -{0x394e,0x08}, -{0x394f,0x90}, -{0x3980,0x71}, -{0x3981,0x70}, -{0x3982,0x00}, -{0x3983,0x00}, -{0x3984,0x20}, -{0x3987,0x0b}, -{0x3990,0x03}, -{0x3991,0xfd}, -{0x3992,0x03}, -{0x3993,0xfc}, -{0x3994,0x00}, -{0x3995,0x00}, -{0x3996,0x00}, -{0x3997,0x05}, -{0x3998,0x00}, -{0x3999,0x09}, -{0x399a,0x00}, -{0x399b,0x12}, -{0x399c,0x00}, -{0x399d,0x12}, -{0x399e,0x00}, -{0x399f,0x18}, -{0x39a0,0x00}, -{0x39a1,0x14}, -{0x39a2,0x03}, -{0x39a3,0xe3}, -{0x39a4,0x03}, -{0x39a5,0xf2}, -{0x39a6,0x03}, -{0x39a7,0xf6}, -{0x39a8,0x03}, -{0x39a9,0xfa}, -{0x39aa,0x03}, -{0x39ab,0xff}, -{0x39ac,0x00}, -{0x39ad,0x06}, -{0x39ae,0x00}, -{0x39af,0x09}, -{0x39b0,0x00}, -{0x39b1,0x12}, -{0x39b2,0x00}, -{0x39b3,0x22}, -{0x39b4,0x0c}, -{0x39b5,0x1c}, -{0x39b6,0x38}, -{0x39b7,0x5b}, -{0x39b8,0x50}, -{0x39b9,0x38}, -{0x39ba,0x20}, -{0x39bb,0x10}, -{0x39bc,0x0c}, -{0x39bd,0x16}, -{0x39be,0x21}, -{0x39bf,0x36}, -{0x39c0,0x3b}, -{0x39c1,0x2a}, -{0x39c2,0x16}, -{0x39c3,0x0c}, -{0x39c5,0x30}, -{0x39c6,0x07}, -{0x39c7,0xf8}, -{0x39c9,0x07}, -{0x39ca,0xf8}, -{0x39cc,0x00}, -{0x39cd,0x1b}, -{0x39ce,0x00}, -{0x39cf,0x00}, -{0x39d0,0x1b}, -{0x39d1,0x00}, -{0x39e2,0x15}, -{0x39e3,0x87}, -{0x39e4,0x12}, -{0x39e5,0xb7}, -{0x39e6,0x00}, -{0x39e7,0x8c}, -{0x39e8,0x01}, -{0x39e9,0x31}, -{0x39ea,0x01}, -{0x39eb,0xd7}, -{0x39ec,0x08}, -{0x39ed,0x00}, -{0x3e00,0x02}, -{0x3e01,0x0f}, -{0x3e02,0xa0}, -{0x3e04,0x20}, -{0x3e05,0xc0}, -{0x3e06,0x00}, -{0x3e07,0x80}, -{0x3e08,0x03}, -{0x3e09,0x40}, -{0x3e0e,0x09}, -{0x3e10,0x00}, -{0x3e11,0x80}, -{0x3e12,0x03}, -{0x3e13,0x40}, -{0x3e14,0x31}, -{0x3e16,0x00}, -{0x3e17,0xac}, -{0x3e18,0x00}, -{0x3e19,0xac}, -{0x3e1b,0x3a}, -{0x3e1e,0x76}, -{0x3e23,0x01}, -{0x3e24,0x0e}, -{0x3e25,0x23}, -{0x3e26,0x40}, -{0x4501,0xa4}, -{0x4509,0x10}, -{0x4816,0x51}, -{0x4837,0x1c}, -{0x5799,0x06}, -{0x57aa,0x2f}, -{0x57ab,0xff}, -{0x3641,0x0c}, -{0x36e9,0x53}, -{0x36ea,0x39}, -{0x36eb,0x06}, -{0x36ec,0x05}, -{0x36ed,0x24}, -{0x36f9,0x57}, -{0x36fa,0x39}, -{0x36fb,0x13}, -{0x36fc,0x10}, -{0x36fd,0x14}, -{0x3641,0x00}, -{0x0100,0x01}, -}; - -I2C_ARRAY Sensor_init_table_HDR_DOL_4lane_2M[] = -{ -{0x0103,0x01}, -{0x0100,0x00}, -{0x336c,0xc2}, -{0x3624,0x45}, -{0x33e1,0x08}, -{0x33e2,0x18}, -{0x33e3,0x10}, -{0x33e4,0x0c}, -{0x33e5,0x10}, -{0x33e6,0x06}, -{0x33e7,0x02}, -{0x33e8,0x18}, -{0x33e9,0x10}, -{0x33ea,0x0c}, -{0x33eb,0x10}, -{0x33ec,0x04}, -{0x33ed,0x02}, -{0x33ee,0xa0}, -{0x33ef,0x08}, -{0x33f4,0x18}, -{0x33f5,0x10}, -{0x33f6,0x0c}, -{0x33f7,0x10}, -{0x33f8,0x06}, -{0x33f9,0x02}, -{0x33fa,0x18}, -{0x33fb,0x10}, -{0x33fc,0x0c}, -{0x33fd,0x10}, -{0x33fe,0x04}, -{0x33ff,0x02}, -{0x5799,0x06}, -{0x3e16,0x00}, -{0x3e17,0xac}, -{0x3e18,0x00}, -{0x3e19,0xac}, -{0x3e0e,0x09}, -{0x3e1e,0x76}, -{0x3e25,0x23}, -{0x57aa,0x2f}, -{0x57ab,0xff}, -{0x3018,0x72}, -{0x3019,0x00}, -{0x3031,0x0a}, -{0x3037,0x20}, -{0x4501,0xa4}, -{0x4509,0x10}, -{0x4837,0x1c}, -{0x3366,0x92}, -{0x334c,0x10}, -{0x3631,0x80}, -{0x3308,0x20}, -{0x335d,0x60}, -{0x337f,0x33}, -{0x3369,0x00}, -{0x336a,0x00}, -{0x336b,0x00}, -{0x3367,0x08}, -{0x330e,0x58}, -{0x33af,0x48}, -{0x3638,0x0a}, -{0x3309,0x68}, -{0x331f,0x59}, -{0x330d,0x28}, -{0x339e,0x24}, -{0x33aa,0x24}, -{0x3332,0x24}, -{0x3350,0x24}, -{0x3358,0x24}, -{0x335c,0x24}, -{0x3628,0x83}, -{0x3633,0x23}, -{0x3630,0x80}, -{0x3622,0xf7}, -{0x363d,0x01}, -{0x363e,0x00}, -{0x363a,0x88}, -{0x3e26,0x40}, -{0x360f,0x01}, -{0x367a,0x48}, -{0x367b,0x78}, -{0x3671,0xf7}, -{0x3672,0xf7}, -{0x3673,0x17}, -{0x3670,0x4a}, -{0x367c,0x48}, -{0x367d,0x78}, -{0x3674,0x80}, -{0x3675,0x85}, -{0x3676,0xa5}, -{0x369c,0x48}, -{0x369d,0x78}, -{0x3690,0x53}, -{0x3691,0x63}, -{0x3692,0x54}, -{0x36a2,0x48}, -{0x36a3,0x78}, -{0x3699,0x88}, -{0x36bb,0x48}, -{0x36bc,0x78}, -{0x36c9,0x05}, -{0x36ca,0x05}, -{0x36cb,0x05}, -{0x36d0,0x30}, -{0x36d1,0x48}, -{0x36d2,0x78}, -{0x36cc,0x00}, -{0x36cd,0x10}, -{0x36ce,0x1a}, -{0x3364,0x16}, -{0x3301,0x1c}, -{0x3393,0x1c}, -{0x3394,0x28}, -{0x3395,0x38}, -{0x3390,0x08}, -{0x3391,0x18}, -{0x3392,0x38}, -{0x3399,0x1c}, -{0x339a,0x1c}, -{0x339b,0x28}, -{0x339c,0x38}, -{0x3396,0x08}, -{0x3397,0x18}, -{0x3398,0x38}, -{0x3241,0x00}, -{0x3243,0x03}, -{0x3271,0x1c}, -{0x3273,0x1f}, -{0x394c,0x0f}, -{0x394d,0x20}, -{0x394e,0x08}, -{0x394f,0x90}, -{0x3981,0x70}, -{0x3984,0x20}, -{0x39ec,0x08}, -{0x39ed,0x00}, -{0x3982,0x00}, -{0x3983,0x00}, -{0x3980,0x71}, -{0x39b4,0x0c}, -{0x39b5,0x1c}, -{0x39b6,0x38}, -{0x39b7,0x5b}, -{0x39b8,0x50}, -{0x39b9,0x38}, -{0x39ba,0x20}, -{0x39bb,0x10}, -{0x39bc,0x0c}, -{0x39bd,0x16}, -{0x39be,0x21}, -{0x39bf,0x36}, -{0x39c0,0x3b}, -{0x39c1,0x2a}, -{0x39c2,0x16}, -{0x39c3,0x0c}, -{0x39a2,0x03}, -{0x39a3,0xe3}, -{0x39a4,0x03}, -{0x39a5,0xf2}, -{0x39a6,0x03}, -{0x39a7,0xf6}, -{0x39a8,0x03}, -{0x39a9,0xfa}, -{0x39aa,0x03}, -{0x39ab,0xff}, -{0x39ac,0x00}, -{0x39ad,0x06}, -{0x39ae,0x00}, -{0x39af,0x09}, -{0x39b0,0x00}, -{0x39b1,0x12}, -{0x39b2,0x00}, -{0x39b3,0x22}, -{0x39c6,0x07}, -{0x39c7,0xf8}, -{0x39c9,0x07}, -{0x39ca,0xf8}, -{0x3990,0x03}, -{0x3991,0xfd}, -{0x3992,0x03}, -{0x3993,0xfc}, -{0x3994,0x00}, -{0x3995,0x00}, -{0x3996,0x00}, -{0x3997,0x05}, -{0x3998,0x00}, -{0x3999,0x09}, -{0x399a,0x00}, -{0x399b,0x12}, -{0x399c,0x00}, -{0x399d,0x12}, -{0x399e,0x00}, -{0x399f,0x18}, -{0x39a0,0x00}, -{0x39a1,0x14}, -{0x39cc,0x00}, -{0x39cd,0x1b}, -{0x39ce,0x00}, -{0x39cf,0x00}, -{0x39d0,0x1b}, -{0x39d1,0x00}, -{0x39e2,0x15}, -{0x39e3,0x87}, -{0x39e4,0x12}, -{0x39e5,0xb7}, -{0x39e6,0x00}, -{0x39e7,0x8c}, -{0x39e8,0x01}, -{0x39e9,0x31}, -{0x39ea,0x01}, -{0x39eb,0xd7}, -{0x39c5,0x30}, -{0x3214,0x31}, -{0x3620,0x48}, -{0x3208,0x07}, -{0x3209,0x80}, -{0x3211,0x08}, -{0x450d,0x08}, -{0x3215,0x31}, -{0x320a,0x04}, -{0x320b,0x38}, -{0x3641,0x00}, -{0x3635,0x02}, -{0x3902,0xc5}, -{0x3038,0x44}, -{0x3e14,0x31}, -{0x3e1b,0x3a}, -{0x3248,0x04}, -{0x3901,0x00}, -{0x3904,0x18}, -{0x3987,0x0b}, -{0x363b,0x06}, -{0x3905,0xd8}, -{0x301f,0x29}, -{0x320c,0x07}, -{0x320d,0xd0}, -{0x3641,0x0c}, -{0x36f9,0x44}, -{0x36fa,0x31}, -{0x36fb,0x13}, -{0x36fc,0x10}, -{0x36fd,0x14}, -{0x36e9,0x40}, -{0x36ea,0x31}, -{0x36eb,0x06}, -{0x36ec,0x05}, -{0x36ed,0x24}, -{0x3641,0x00}, -{0x3306,0xa0}, -{0x330b,0x38}, -{0x3203,0x08}, -{0x3207,0x87}, -{0x3213,0x04}, -{0x3802,0x01}, -{0x3220,0x5c}, -{0x336f,0x58}, -{0x4816,0x51}, -{0x3250,0x3f}, -{0x320e,0x08}, -{0x320f,0xca}, -{0x3e23,0x00}, -{0x3e24,0x8c}, -{0x3314,0x98}, -{0x334a,0x18}, -{0x3636,0x11}, -{0x3637,0x10}, -{0x3e00,0x01}, -{0x3e01,0x06}, -{0x3e02,0xc0}, -{0x3e04,0x10}, -{0x3e05,0x60}, -{0x3e06,0x00}, -{0x3e07,0x80}, -{0x3e08,0x03}, -{0x3e09,0x40}, -{0x3e10,0x00}, -{0x3e11,0x80}, -{0x3e12,0x03}, -{0x3e13,0x40}, -{0x3362,0x72}, -{0x3360,0x40}, -{0x3368,0x0e}, -{0x369a,0x88}, -{0x369b,0x88}, -{0x3632,0xa8},//2020/06/11 -{0x0100,0x01}, -}; - - -I2C_ARRAY TriggerStartTbl[] = { -//{0x30f4,0x00},//Master mode start -}; - -I2C_ARRAY PatternTbl[] = { - //pattern mode -}; - -I2C_ARRAY mirror_reg[] = -{ - {0x3221, 0x00}, // mirror[2:1], flip[6:5] -}; - -I2C_ARRAY mirror_reg_HDR[] = -{ - {0x3221, 0x00}, // mirror[2:1], flip[6:5] - {0x3812, 0x00}, - {0x4505, 0x80}, - {0x3812, 0x30}, -}; - -typedef struct { - short reg; - char startbit; - char stopbit; -} COLLECT_REG_SET; - -static I2C_ARRAY gain_reg[] = { - {0x3e06, 0x00}, - {0x3e07, 0x00}, - {0x3e08, 0x00|0x03}, - {0x3e09, 0x40}, //low bit, 0x40 - 0x7f, step 1/64 - -}; -static I2C_ARRAY gain_reg_HDR_DOL_SEF[] = { - {0x3e10, 0x00}, - {0x3e11, 0x00}, - {0x3e12, 0x00|0x03}, - {0x3e13, 0x10}, //low bit, 0x40 - 0x7f, step 1/64 - }; - -I2C_ARRAY expo_reg[] = { - {0x3e00, 0x00}, //expo [3:0] - {0x3e01, 0x30}, // expo[7:0] - {0x3e02, 0x00}, // expo[7:4] -}; -I2C_ARRAY expo_reg_HDR_DOL_SEF[] = { - {0x3e04, 0x21}, // expo[7:0] - {0x3e05, 0x00}, // expo[7:4] -}; - -I2C_ARRAY vts_reg[] = { - {0x320e, 0x08}, - {0x320f, 0xca} -}; -I2C_ARRAY max_short_exp_reg[] = { - {0x3e23, 0x01}, - {0x3e24, 0x0e} -}; - -#if 0 -CUS_INT_TASK_ORDER def_order = { - .RunLength = 9, - .Orders = { - CUS_INT_TASK_AE|CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_AWB|CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_AE|CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_AWB|CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_AE|CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_AWB|CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - CUS_INT_TASK_VDOS|CUS_INT_TASK_AF, - }, -}; -#endif - -/////////// function definition /////////////////// -#if SENSOR_DBG == 1 -//#define SENSOR_DMSG(args...) SENSOR_DMSG(args) -//#define SENSOR_DMSG(args...) LOGE(args) -#define SENSOR_DMSG(args...) SENSOR_DMSG(args) -#elif SENSOR_DBG == 0 -//#define SENSOR_DMSG(args...) -#endif -#undef SENSOR_NAME -#define SENSOR_NAME sc8238 - -#define SensorReg_Read(_reg,_data) (handle->i2c_bus->i2c_rx(handle->i2c_bus, &(handle->i2c_cfg),_reg,_data)) -#define SensorReg_Write(_reg,_data) (handle->i2c_bus->i2c_tx(handle->i2c_bus, &(handle->i2c_cfg),_reg,_data)) -#define SensorRegArrayW(_reg,_len) (handle->i2c_bus->i2c_array_tx(handle->i2c_bus, &(handle->i2c_cfg),(_reg),(_len))) -#define SensorRegArrayR(_reg,_len) (handle->i2c_bus->i2c_array_rx(handle->i2c_bus, &(handle->i2c_cfg),(_reg),(_len))) - -/////////////////// sensor hardware dependent ////////////// -#if 0 -static int ISP_config_io(ms_cus_sensor *handle) { - ISensorIfAPI *sensor_if = handle->sensor_if_api; - - SENSOR_DMSG("[%s]", __FUNCTION__); - - sensor_if->HsyncPol(handle, handle->HSYNC_POLARITY); - sensor_if->VsyncPol(handle, handle->VSYNC_POLARITY); - sensor_if->ClkPol(handle, handle->PCLK_POLARITY); - sensor_if->BayerFmt(handle, handle->bayer_id); - sensor_if->DataBus(handle, handle->sif_bus); - - sensor_if->DataPrecision(handle, handle->data_prec); - sensor_if->FmtConv(handle, handle->data_mode); - return SUCCESS; -} -#endif -static int pCus_poweron(ms_cus_sensor *handle, u32 idx) -{ - ISensorIfAPI *sensor_if = handle->sensor_if_api; - SENSOR_DMSG("[%s] ", __FUNCTION__); - - //Sensor power on sequence - sensor_if->MCLK(idx, 1, handle->mclk); - - sensor_if->SetIOPad(idx, handle->sif_bus, handle->interface_attr.attr_mipi.mipi_lane_num); -/* sensor_if->SetCSI_Clk(idx, CUS_CSI_CLK_216M); - sensor_if->SetCSI_Lane(idx, handle->interface_attr.attr_mipi.mipi_lane_num, 1); - sensor_if->SetCSI_LongPacketType(idx, 0, 0x1C00, 0); - if (handle->interface_attr.attr_mipi.mipi_hdr_mode == CUS_HDR_MODE_DCG) { - sensor_if->SetCSI_hdr_mode(idx, handle->interface_attr.attr_mipi.mipi_hdr_mode, 2); - } */ - - SENSOR_DMSG("[%s] reset low\n", __FUNCTION__); - sensor_if->Reset(idx, handle->reset_POLARITY); - SENSOR_USLEEP(1000); - SENSOR_DMSG("[%s] power low\n", __FUNCTION__); - sensor_if->PowerOff(idx, handle->pwdn_POLARITY); - SENSOR_USLEEP(1000); - - // power -> high, reset -> high - SENSOR_DMSG("[%s] power high\n", __FUNCTION__); - sensor_if->PowerOff(idx, !handle->pwdn_POLARITY); - SENSOR_USLEEP(1000); - SENSOR_DMSG("[%s] reset high\n", __FUNCTION__); - sensor_if->Reset(idx, !handle->reset_POLARITY); - SENSOR_USLEEP(1000); - - //sensor_if->Set3ATaskOrder(handle, def_order); - // pure power on - //ISP_config_io(handle); - sensor_if->PowerOff(idx, !handle->pwdn_POLARITY); - SENSOR_USLEEP(5000); - //handle->i2c_bus->i2c_open(handle->i2c_bus,&handle->i2c_cfg); - - return SUCCESS; -} - -static int pCus_post_init(ms_cus_sensor *handle, u32 idx) -{ - ISensorIfAPI *sensor_if = handle->sensor_if_api; - SENSOR_DMSG("[%s] ", __FUNCTION__); - - sensor_if->SetCSI_Clk(idx, CUS_CSI_CLK_216M); - sensor_if->SetCSI_Lane(idx, handle->interface_attr.attr_mipi.mipi_lane_num, 1); - sensor_if->SetCSI_LongPacketType(idx, 0, 0x1C00, 0); - if (handle->interface_attr.attr_mipi.mipi_hdr_mode == CUS_HDR_MODE_DCG) { - sensor_if->SetCSI_hdr_mode(idx, handle->interface_attr.attr_mipi.mipi_hdr_mode, 2); - } - return SUCCESS; -} - -static int pCus_poweroff(ms_cus_sensor *handle, u32 idx) -{ - // power/reset low - ISensorIfAPI *sensor_if = handle->sensor_if_api; - sc8238_params *params = (sc8238_params *)handle->private_data; - SENSOR_DMSG("[%s] power low\n", __FUNCTION__); - sensor_if->PowerOff(idx, handle->pwdn_POLARITY); - //handle->i2c_bus->i2c_close(handle->i2c_bus); - SENSOR_USLEEP(1000); - //Set_csi_if(0, 0); - sensor_if->SetCSI_Clk(idx, CUS_CSI_CLK_DISABLE); - if (handle->interface_attr.attr_mipi.mipi_hdr_mode == CUS_HDR_MODE_DCG) { - sensor_if->SetCSI_hdr_mode(idx, handle->interface_attr.attr_mipi.mipi_hdr_mode, 0); - } - sensor_if->MCLK(idx, 0, handle->mclk); - - params->cur_orien = CUS_ORIT_M0F0; - - SENSOR_USLEEP(2000);//mantis:1690203 - return SUCCESS; -} - -/////////////////// image function ///////////////////////// -//Get and check sensor ID -//if i2c error or sensor id does not match then return FAIL -static int pCus_GetSensorID(ms_cus_sensor *handle, u32 *id) -{ - int i,n; - int table_length= ARRAY_SIZE(Sensor_id_table); - I2C_ARRAY id_from_sensor[ARRAY_SIZE(Sensor_id_table)]; - - SensorReg_Write(0xef,0x00); - - for(n=0;n8) table_length=8; - - SENSOR_DMSG("\n\n[%s]", __FUNCTION__); - - for(n=0;n<4;++n) //retry , until I2C success - { - if(n>2) return FAIL; - - if( SensorRegArrayR((I2C_ARRAY*)id_from_sensor,table_length) == SUCCESS) //read sensor ID from I2C - break; - else - continue; - } - - //convert sensor id to u32 format - for(i=0;i>= 8; - SENSOR_DMSG("[%s]sc8238 Read sensor id, get 0x%x Success\n", __FUNCTION__, (int)*id); - //SENSOR_DMSG("[%s]Read sensor id, get 0x%x Success\n", __FUNCTION__, (int)*id); - - return SUCCESS; -} - -static int sc8238_SetPatternMode(ms_cus_sensor *handle,u32 mode) -{ - - SENSOR_DMSG("\n\n[%s], mode=%d \n", __FUNCTION__, mode); - - return SUCCESS; -} -static int pCus_SetFPS(ms_cus_sensor *handle, u32 fps); -static int pCus_SetAEGain_cal(ms_cus_sensor *handle, u32 gain); -static int pCus_AEStatusNotify(ms_cus_sensor *handle, CUS_CAMSENSOR_AE_STATUS_NOTIFY status); - -static int pCus_init_mipi4lane_linear_4K30fps(ms_cus_sensor *handle) -{ - short ver=0; - sc8238_params *params = (sc8238_params *)handle->private_data; - //SENSOR_DMSG("\n\n[%s]", __FUNCTION__); - int i,cnt; - //ISensorIfAPI *sensor_if = &(handle->sensor_if_api); - //sensor_if->PCLK(NULL,CUS_PCLK_MIPI_TOP); - - for(i=0;i< ARRAY_SIZE(Sensor_init_table_4lane_4K30fps);i++) - { - if(Sensor_init_table_4lane_4K30fps[i].reg==0xffff) - { - SENSOR_MSLEEP(Sensor_init_table_4lane_4K30fps[i].data); - } - else - { - cnt = 0; - while(SensorReg_Write(Sensor_init_table_4lane_4K30fps[i].reg, Sensor_init_table_4lane_4K30fps[i].data) != SUCCESS) - { - cnt++; - SENSOR_DMSG("Sensor_init_table -> Retry %d...\n",cnt); - if(cnt>=10) - { - SENSOR_DMSG("[%s:%d]Sensor init fail!!\n", __FUNCTION__, __LINE__); - return FAIL; - } - SENSOR_MSLEEP(10); - } - } - } - - SensorReg_Read(0x3040,&ver); - if(ver == 0){ - SensorReg_Write(0x36c9,0x01); - SensorReg_Write(0x36ca,0x00); - SensorReg_Write(0x36cb,0x00); - }else if(ver == 1){ - SensorReg_Write(0x36c9,0x05); - SensorReg_Write(0x36ca,0x05); - SensorReg_Write(0x36cb,0x05); - } - - //DPC patch - SensorReg_Write(0x5780,0x57); - SensorReg_Write(0x5785,0x00); - SensorReg_Write(0x5786,0x00); - SensorReg_Write(0x5799,0x07); //20190710 - - pCus_SetOrien(handle, params->cur_orien); - // pr_info("cur_orien %s pCus_SetOrien %x\n",__FUNCTION__, params->cur_orien); - vts_reg[0].data = (params->expo.vts >> 8) & 0x00ff; - vts_reg[1].data = (params->expo.vts >> 0) & 0x00ff; - pr_info("[%s] vts_reg_sef : %x , %x\n\n", __FUNCTION__,vts_reg[0].data,vts_reg[1].data); - return SUCCESS; -} - -static int pCus_init_mipi4lane_linear_4K20fps(ms_cus_sensor *handle) -{ - short ver=0; - sc8238_params *params = (sc8238_params *)handle->private_data; - //SENSOR_DMSG("\n\n[%s]", __FUNCTION__); - int i,cnt; - //ISensorIfAPI *sensor_if = &(handle->sensor_if_api); - //sensor_if->PCLK(NULL,CUS_PCLK_MIPI_TOP); - - for(i=0;i< ARRAY_SIZE(Sensor_init_table_4lane_4K20fps);i++) - { - if(Sensor_init_table_4lane_4K20fps[i].reg==0xffff) - { - SENSOR_MSLEEP(Sensor_init_table_4lane_4K20fps[i].data); - } - else - { - cnt = 0; - while(SensorReg_Write(Sensor_init_table_4lane_4K20fps[i].reg, Sensor_init_table_4lane_4K20fps[i].data) != SUCCESS) - { - cnt++; - SENSOR_DMSG("Sensor_init_table -> Retry %d...\n",cnt); - if(cnt>=10) - { - SENSOR_DMSG("[%s:%d]Sensor init fail!!\n", __FUNCTION__, __LINE__); - return FAIL; - } - SENSOR_MSLEEP(10); - } - } - } - - SensorReg_Read(0x3040,&ver); - if(ver == 0){ - SensorReg_Write(0x36c9,0x01); - SensorReg_Write(0x36ca,0x00); - SensorReg_Write(0x36cb,0x00); - }else if(ver == 1){ - SensorReg_Write(0x36c9,0x05); - SensorReg_Write(0x36ca,0x05); - SensorReg_Write(0x36cb,0x05); - } - //BL control - //SensorReg_Write(0x3907,0x01); - //SensorReg_Write(0x3908,0x11); - - //DPC patch - SensorReg_Write(0x5780,0x57); - SensorReg_Write(0x5785,0x00); - SensorReg_Write(0x5786,0x00); - SensorReg_Write(0x5799,0x07); //20190710 - - pCus_SetOrien(handle, params->cur_orien); - // pr_info("cur_orien %s pCus_SetOrien %x\n",__FUNCTION__, params->cur_orien); - vts_reg[0].data = (params->expo.vts >> 8) & 0x00ff; - vts_reg[1].data = (params->expo.vts >> 0) & 0x00ff; - pr_info("[%s] vts_reg_sef : %x , %x\n\n", __FUNCTION__,vts_reg[0].data,vts_reg[1].data); - // usleep(50*1000); - //pCus_SetAEGain(handle,1024); - //pCus_SetAEUSecs(handle, 40000); - //pCus_AEStatusNotify(handle,CUS_FRAME_ACTIVE); - return SUCCESS; -} - -static int pCus_init_mipi4lane_linear_4K15fps(ms_cus_sensor *handle) -{ - // short ver=0; - sc8238_params *params = (sc8238_params *)handle->private_data; - //SENSOR_DMSG("\n\n[%s]", __FUNCTION__); - int i,cnt; - //ISensorIfAPI *sensor_if = &(handle->sensor_if_api); - //sensor_if->PCLK(NULL,CUS_PCLK_MIPI_TOP); - - for(i=0;i< ARRAY_SIZE(Sensor_init_table_4lane_4K15fps);i++) - { - if(Sensor_init_table_4lane_4K15fps[i].reg==0xffff) - { - SENSOR_MSLEEP(Sensor_init_table_4lane_4K15fps[i].data); - } - else - { - cnt = 0; - while(SensorReg_Write(Sensor_init_table_4lane_4K15fps[i].reg, Sensor_init_table_4lane_4K15fps[i].data) != SUCCESS) - { - cnt++; - SENSOR_DMSG("Sensor_init_table -> Retry %d...\n",cnt); - if(cnt>=10) - { - SENSOR_DMSG("[%s:%d]Sensor init fail!!\n", __FUNCTION__, __LINE__); - return FAIL; - } - SENSOR_MSLEEP(10); - } - } - } -#if 0 - SensorReg_Read(0x3040,&ver); - if(ver == 0){ - SensorReg_Write(0x36c9,0x01); - SensorReg_Write(0x36ca,0x00); - SensorReg_Write(0x36cb,0x00); - }else if(ver == 1){ - SensorReg_Write(0x36c9,0x05); - SensorReg_Write(0x36ca,0x05); - SensorReg_Write(0x36cb,0x05); - } -#endif - //BL control - // SensorReg_Write(0x3907,0x01); - // SensorReg_Write(0x3908,0x11); - - //DPC patch - SensorReg_Write(0x5780,0x57); - SensorReg_Write(0x5785,0x00); - SensorReg_Write(0x5786,0x00); - SensorReg_Write(0x5799,0x07); //20190710 - - pCus_SetOrien(handle, params->cur_orien); - // pr_info("cur_orien %s pCus_SetOrien %x\n",__FUNCTION__, params->cur_orien); - vts_reg[0].data = (params->expo.vts >> 8) & 0x00ff; - vts_reg[1].data = (params->expo.vts >> 0) & 0x00ff; - // usleep(50*1000); - //pCus_SetAEGain(handle,1024); - //pCus_SetAEUSecs(handle, 40000); - //pCus_AEStatusNotify(handle,CUS_FRAME_ACTIVE); - return SUCCESS; -} - -static int pCus_init_mipi4lane_linear_5M30fps(ms_cus_sensor *handle) -{ - // short ver=0; - sc8238_params *params = (sc8238_params *)handle->private_data; - //SENSOR_DMSG("\n\n[%s]", __FUNCTION__); - int i,cnt; - //ISensorIfAPI *sensor_if = &(handle->sensor_if_api); - //sensor_if->PCLK(NULL,CUS_PCLK_MIPI_TOP); - - for(i=0;i< ARRAY_SIZE(Sensor_init_table_4lane_5M30fps);i++) - { - if(Sensor_init_table_4lane_5M30fps[i].reg==0xffff) - { - SENSOR_MSLEEP(Sensor_init_table_4lane_5M30fps[i].data); - } - else - { - cnt = 0; - while(SensorReg_Write(Sensor_init_table_4lane_5M30fps[i].reg, Sensor_init_table_4lane_5M30fps[i].data) != SUCCESS) - { - cnt++; - SENSOR_DMSG("Sensor_init_table -> Retry %d...\n",cnt); - if(cnt>=10) - { - SENSOR_DMSG("[%s:%d]Sensor init fail!!\n", __FUNCTION__, __LINE__); - return FAIL; - } - SENSOR_MSLEEP(10); - } - } - } -#if 0 - SensorReg_Read(0x3040,&ver); - if(ver == 0){ - SensorReg_Write(0x36c9,0x01); - SensorReg_Write(0x36ca,0x00); - SensorReg_Write(0x36cb,0x00); - }else if(ver == 1){ - SensorReg_Write(0x36c9,0x05); - SensorReg_Write(0x36ca,0x05); - SensorReg_Write(0x36cb,0x05); - } -#endif - //BL control - // SensorReg_Write(0x3907,0x01); - // SensorReg_Write(0x3908,0x11); - - //DPC patch - SensorReg_Write(0x5780,0x57); - SensorReg_Write(0x5785,0x00); - SensorReg_Write(0x5786,0x00); - SensorReg_Write(0x5799,0x07); //20190710 - - pCus_SetOrien(handle, params->cur_orien); - // pr_info("cur_orien %s pCus_SetOrien %x\n",__FUNCTION__, params->cur_orien); - vts_reg[0].data = (params->expo.vts >> 8) & 0x00ff; - vts_reg[1].data = (params->expo.vts >> 0) & 0x00ff; - // usleep(50*1000); - //pCus_SetAEGain(handle,1024); - //pCus_SetAEUSecs(handle, 40000); - //pCus_AEStatusNotify(handle,CUS_FRAME_ACTIVE); - return SUCCESS; -} - -//////// -static int pCus_init_mipi4lane_linear_5MP3_30fps(ms_cus_sensor *handle) -{ - // short ver=0; - sc8238_params *params = (sc8238_params *)handle->private_data; - //SENSOR_DMSG("\n\n[%s]", __FUNCTION__); - int i,cnt; - //ISensorIfAPI *sensor_if = &(handle->sensor_if_api); - //sensor_if->PCLK(NULL,CUS_PCLK_MIPI_TOP); - - for(i=0;i< ARRAY_SIZE(Sensor_init_table_4lane_5MP3_30fps);i++) - { - if(Sensor_init_table_4lane_5MP3_30fps[i].reg==0xffff) - { - SENSOR_MSLEEP(Sensor_init_table_4lane_5MP3_30fps[i].data); - } - else - { - cnt = 0; - while(SensorReg_Write(Sensor_init_table_4lane_5MP3_30fps[i].reg, Sensor_init_table_4lane_5MP3_30fps[i].data) != SUCCESS) - { - cnt++; - SENSOR_DMSG("Sensor_init_table -> Retry %d...\n",cnt); - if(cnt>=10) - { - SENSOR_DMSG("[%s:%d]Sensor init fail!!\n", __FUNCTION__, __LINE__); - return FAIL; - } - SENSOR_MSLEEP(10); - } - } - } -#if 0 - SensorReg_Read(0x3040,&ver); - if(ver == 0){ - SensorReg_Write(0x36c9,0x01); - SensorReg_Write(0x36ca,0x00); - SensorReg_Write(0x36cb,0x00); - }else if(ver == 1){ - SensorReg_Write(0x36c9,0x05); - SensorReg_Write(0x36ca,0x05); - SensorReg_Write(0x36cb,0x05); - } -#endif - //BL control - // SensorReg_Write(0x3907,0x01); - // SensorReg_Write(0x3908,0x11); - - //DPC patch - SensorReg_Write(0x5780,0x57); - SensorReg_Write(0x5785,0x00); - SensorReg_Write(0x5786,0x00); - SensorReg_Write(0x5799,0x07); //20190710 - - pCus_SetOrien(handle, params->cur_orien); - // pr_info("cur_orien %s pCus_SetOrien %x\n",__FUNCTION__, params->cur_orien); - vts_reg[0].data = (params->expo.vts >> 8) & 0x00ff; - vts_reg[1].data = (params->expo.vts >> 0) & 0x00ff; - // usleep(50*1000); - //pCus_SetAEGain(handle,1024); - //pCus_SetAEUSecs(handle, 40000); - //pCus_AEStatusNotify(handle,CUS_FRAME_ACTIVE); - return SUCCESS; -} - - - - -static int pCus_init_mipi4lane_linear_4P8M30fps(ms_cus_sensor *handle) -{ - // short ver=0; - sc8238_params *params = (sc8238_params *)handle->private_data; - //SENSOR_DMSG("\n\n[%s]", __FUNCTION__); - int i,cnt; - //ISensorIfAPI *sensor_if = &(handle->sensor_if_api); - //sensor_if->PCLK(NULL,CUS_PCLK_MIPI_TOP); - - for(i=0;i< ARRAY_SIZE(Sensor_init_table_4lane_4P8M30fps);i++) - { - if(Sensor_init_table_4lane_4P8M30fps[i].reg==0xffff) - { - SENSOR_MSLEEP(Sensor_init_table_4lane_4P8M30fps[i].data); - } - else - { - cnt = 0; - while(SensorReg_Write(Sensor_init_table_4lane_4P8M30fps[i].reg, Sensor_init_table_4lane_4P8M30fps[i].data) != SUCCESS) - { - cnt++; - SENSOR_DMSG("Sensor_init_table -> Retry %d...\n",cnt); - if(cnt>=10) - { - SENSOR_DMSG("[%s:%d]Sensor init fail!!\n", __FUNCTION__, __LINE__); - return FAIL; - } - SENSOR_MSLEEP(10); - } - } - } -#if 0 - SensorReg_Read(0x3040,&ver); - if(ver == 0){ - SensorReg_Write(0x36c9,0x01); - SensorReg_Write(0x36ca,0x00); - SensorReg_Write(0x36cb,0x00); - }else if(ver == 1){ - SensorReg_Write(0x36c9,0x05); - SensorReg_Write(0x36ca,0x05); - SensorReg_Write(0x36cb,0x05); - } -#endif - //BL control - // SensorReg_Write(0x3907,0x01); - // SensorReg_Write(0x3908,0x11); - - //DPC patch - SensorReg_Write(0x5780,0x57); - SensorReg_Write(0x5785,0x00); - SensorReg_Write(0x5786,0x00); - SensorReg_Write(0x5799,0x07); //20190710 - - pCus_SetOrien(handle, params->cur_orien); - // pr_info("cur_orien %s pCus_SetOrien %x\n",__FUNCTION__, params->cur_orien); - vts_reg[0].data = (params->expo.vts >> 8) & 0x00ff; - vts_reg[1].data = (params->expo.vts >> 0) & 0x00ff; - // usleep(50*1000); - //pCus_SetAEGain(handle,1024); - //pCus_SetAEUSecs(handle, 40000); - //pCus_AEStatusNotify(handle,CUS_FRAME_ACTIVE); - return SUCCESS; -} - -static int pCus_init_mipi4lane_linear_3P6M30fps(ms_cus_sensor *handle) -{ - // short ver=0; - sc8238_params *params = (sc8238_params *)handle->private_data; - //SENSOR_DMSG("\n\n[%s]", __FUNCTION__); - int i,cnt; - //ISensorIfAPI *sensor_if = &(handle->sensor_if_api); - //sensor_if->PCLK(NULL,CUS_PCLK_MIPI_TOP); - - for(i=0;i< ARRAY_SIZE(Sensor_init_table_4lane_3P6M30fps);i++) - { - if(Sensor_init_table_4lane_3P6M30fps[i].reg==0xffff) - { - SENSOR_MSLEEP(Sensor_init_table_4lane_3P6M30fps[i].data); - } - else - { - cnt = 0; - while(SensorReg_Write(Sensor_init_table_4lane_3P6M30fps[i].reg, Sensor_init_table_4lane_3P6M30fps[i].data) != SUCCESS) - { - cnt++; - SENSOR_DMSG("Sensor_init_table -> Retry %d...\n",cnt); - if(cnt>=10) - { - SENSOR_DMSG("[%s:%d]Sensor init fail!!\n", __FUNCTION__, __LINE__); - return FAIL; - } - SENSOR_MSLEEP(10); - } - } - } -#if 0 - SensorReg_Read(0x3040,&ver); - if(ver == 0){ - SensorReg_Write(0x36c9,0x01); - SensorReg_Write(0x36ca,0x00); - SensorReg_Write(0x36cb,0x00); - }else if(ver == 1){ - SensorReg_Write(0x36c9,0x05); - SensorReg_Write(0x36ca,0x05); - SensorReg_Write(0x36cb,0x05); - } -#endif - //BL control - // SensorReg_Write(0x3907,0x01); - // SensorReg_Write(0x3908,0x11); - - //DPC patch - SensorReg_Write(0x5780,0x57); - SensorReg_Write(0x5785,0x00); - SensorReg_Write(0x5786,0x00); - SensorReg_Write(0x5799,0x07); //20190710 - - pCus_SetOrien(handle, params->cur_orien); - // pr_info("cur_orien %s pCus_SetOrien %x\n",__FUNCTION__, params->cur_orien); - vts_reg[0].data = (params->expo.vts >> 8) & 0x00ff; - vts_reg[1].data = (params->expo.vts >> 0) & 0x00ff; - // usleep(50*1000); - //pCus_SetAEGain(handle,1024); - //pCus_SetAEUSecs(handle, 40000); - //pCus_AEStatusNotify(handle,CUS_FRAME_ACTIVE); - return SUCCESS; -} -static int pCus_init_mipi4lane_linear_2M60fps(ms_cus_sensor *handle) -{ - // short ver=0; - sc8238_params *params = (sc8238_params *)handle->private_data; - //SENSOR_DMSG("\n\n[%s]", __FUNCTION__); - int i,cnt; - //ISensorIfAPI *sensor_if = &(handle->sensor_if_api); - //sensor_if->PCLK(NULL,CUS_PCLK_MIPI_TOP); - - for(i=0;i< ARRAY_SIZE(Sensor_init_table_4lane_2M60fps);i++) - { - if(Sensor_init_table_4lane_2M60fps[i].reg==0xffff) - { - SENSOR_MSLEEP(Sensor_init_table_4lane_2M60fps[i].data); - } - else - { - cnt = 0; - while(SensorReg_Write(Sensor_init_table_4lane_2M60fps[i].reg, Sensor_init_table_4lane_2M60fps[i].data) != SUCCESS) - { - cnt++; - SENSOR_DMSG("Sensor_init_table -> Retry %d...\n",cnt); - if(cnt>=10) - { - SENSOR_DMSG("[%s:%d]Sensor init fail!!\n", __FUNCTION__, __LINE__); - return FAIL; - } - SENSOR_MSLEEP(10); - } - } - } -#if 0 - SensorReg_Read(0x3040,&ver); - if(ver == 0){ - SensorReg_Write(0x36c9,0x01); - SensorReg_Write(0x36ca,0x00); - SensorReg_Write(0x36cb,0x00); - }else if(ver == 1){ - SensorReg_Write(0x36c9,0x05); - SensorReg_Write(0x36ca,0x05); - SensorReg_Write(0x36cb,0x05); - } -#endif - //BL control - // SensorReg_Write(0x3907,0x01); - // SensorReg_Write(0x3908,0x11); - - //DPC patch - SensorReg_Write(0x5780,0x57); - SensorReg_Write(0x5785,0x00); - SensorReg_Write(0x5786,0x00); - SensorReg_Write(0x5799,0x07); //20190710 - - pCus_SetOrien(handle, params->cur_orien); - // pr_info("cur_orien %s pCus_SetOrien %x\n",__FUNCTION__, params->cur_orien); - vts_reg[0].data = (params->expo.vts >> 8) & 0x00ff; - vts_reg[1].data = (params->expo.vts >> 0) & 0x00ff; - // usleep(50*1000); - //pCus_SetAEGain(handle,1024); - //pCus_SetAEUSecs(handle, 40000); - //pCus_AEStatusNotify(handle,CUS_FRAME_ACTIVE); - return SUCCESS; -} - - -static int pCus_init_mipi4lane_HDR_DOL(ms_cus_sensor *handle) -{ - // short ver=0; - sc8238_params *params = (sc8238_params *)handle->private_data; - int i,cnt=0; - for(i=0;i< ARRAY_SIZE(Sensor_init_table_HDR_DOL_4lane);i++) - { - if(Sensor_init_table_HDR_DOL_4lane[i].reg==0xffff) - { - //MsSleep(RTK_MS_TO_TICK(1));//usleep(1000*Sensor_init_table_HDR_DOL_4lane[i].data); - SENSOR_MSLEEP(Sensor_init_table_HDR_DOL_4lane[i].data); - } - else - { - cnt = 0; - SENSOR_DMSG("reg = %x, data = %x\n", Sensor_init_table_HDR_DOL_4lane[i].reg, Sensor_init_table_HDR_DOL_4lane[i].data); - while(SensorReg_Write(Sensor_init_table_HDR_DOL_4lane[i].reg,Sensor_init_table_HDR_DOL_4lane[i].data) != SUCCESS) - { - cnt++; - SENSOR_DMSG("Sensor_init_table_HDR_DOL_4lane -> Retry %d...\n",cnt); - if(cnt>=10) - { - //printf("[%s:%d]Sensor init fail!!\n", __FUNCTION__, __LINE__); - return FAIL; - } - //usleep(10*1000); - } - //SensorReg_Read( Sensor_init_table_HDR_DOL_4lane[i].reg, &sen_data ); - //UartSendTrace("sc8238 reg: 0x%x, data: 0x%x, read: 0x%x.\n",Sensor_init_table_HDR_DOL_4lane[i].reg, Sensor_init_table_HDR_DOL_4lane[i].data, sen_data); - } - } - - //DPC patch - SensorReg_Write(0x5780,0x57); - SensorReg_Write(0x5785,0x00); - SensorReg_Write(0x5786,0x00); - SensorReg_Write(0x5799,0x07); //20190710 - - pCus_SetOrien_HDR(handle, params->cur_orien); - // pr_info("cur_orien %s pCus_SetOrien %x\n",__FUNCTION__, params->cur_orien); - vts_reg[0].data = (params->expo.vts >> 8) & 0x00ff; - vts_reg[1].data = (params->expo.vts >> 0) & 0x00ff; - - return SUCCESS; -} - -static int pCus_init_mipi4lane_HDR_DOL_2M(ms_cus_sensor *handle) -{ - // short ver=0; - sc8238_params *params = (sc8238_params *)handle->private_data; - int i,cnt=0; - for(i=0;i< ARRAY_SIZE(Sensor_init_table_HDR_DOL_4lane_2M);i++) - { - if(Sensor_init_table_HDR_DOL_4lane_2M[i].reg==0xffff) - { - //MsSleep(RTK_MS_TO_TICK(1));//usleep(1000*Sensor_init_table_HDR_DOL_4lane_2M[i].data); - SENSOR_MSLEEP(Sensor_init_table_HDR_DOL_4lane_2M[i].data); - } - else - { - cnt = 0; - SENSOR_DMSG("reg = %x, data = %x\n", Sensor_init_table_HDR_DOL_4lane_2M[i].reg, Sensor_init_table_HDR_DOL_4lane_2M[i].data); - while(SensorReg_Write(Sensor_init_table_HDR_DOL_4lane_2M[i].reg,Sensor_init_table_HDR_DOL_4lane_2M[i].data) != SUCCESS) - { - cnt++; - SENSOR_DMSG("Sensor_init_table_HDR_DOL_4lane_2M -> Retry %d...\n",cnt); - if(cnt>=10) - { - //printf("[%s:%d]Sensor init fail!!\n", __FUNCTION__, __LINE__); - return FAIL; - } - //usleep(10*1000); - } - } - } - //DPC patch - SensorReg_Write(0x5780,0x57); - SensorReg_Write(0x5785,0x00); - SensorReg_Write(0x5786,0x00); - SensorReg_Write(0x5799,0x07); //20190710 - - pCus_SetOrien_HDR(handle, params->cur_orien); - vts_reg[0].data = (params->expo.vts >> 8) & 0x00ff; - vts_reg[1].data = (params->expo.vts >> 0) & 0x00ff; - - return SUCCESS; -} - - -/* -int pCus_release(ms_cus_sensor *handle) -{ - ISensorIfAPI *sensor_if = handle->sensor_if_api; - sensor_if->PCLK(NULL,CUS_PCLK_OFF); - return SUCCESS; -} -*/ - -static int pCus_GetVideoResNum( ms_cus_sensor *handle, u32 *ulres_num) -{ - *ulres_num = handle->video_res_supported.num_res; - return SUCCESS; -} - -static int pCus_GetVideoRes(ms_cus_sensor *handle, u32 res_idx, cus_camsensor_res **res) -{ - u32 num_res = handle->video_res_supported.num_res; - - if (res_idx >= num_res) { - return FAIL; - } - - *res = &handle->video_res_supported.res[res_idx]; - - return SUCCESS; -} - -static int pCus_GetCurVideoRes(ms_cus_sensor *handle, u32 *cur_idx, cus_camsensor_res **res) -{ - u32 num_res = handle->video_res_supported.num_res; - - *cur_idx = handle->video_res_supported.ulcur_res; - - if (*cur_idx >= num_res) { - return FAIL; - } - - *res = &handle->video_res_supported.res[*cur_idx]; - - return SUCCESS; -} - -static int pCus_SetVideoRes(ms_cus_sensor *handle, u32 res_idx) -{ - u32 num_res = handle->video_res_supported.num_res; - sc8238_params *params = (sc8238_params *)handle->private_data; - if (res_idx >= num_res) { - return FAIL; - } - switch (res_idx) { - - case 0: //"3840x2160@15fps" - handle->video_res_supported.ulcur_res = 0; - handle->pCus_sensor_init = pCus_init_mipi4lane_linear_4K15fps; - vts_30fps=2250; - params->expo.vts = vts_30fps; - params->expo.fps = 15; - Preview_line_period = 29630; - break; - case 1: //"3840x2160@20fps" - handle->video_res_supported.ulcur_res = 1; - handle->pCus_sensor_init = pCus_init_mipi4lane_linear_4K20fps; - vts_30fps=2250;//3375 - params->expo.vts = vts_30fps; - params->expo.fps = 20; - Preview_line_period = 22222;///14815 - break; - case 2: //"3072x1728@30fps" - handle->video_res_supported.ulcur_res = 2; - handle->pCus_sensor_init = pCus_init_mipi4lane_linear_5MP3_30fps; - vts_30fps=2250;//3375 - params->expo.vts = vts_30fps; - params->expo.fps = 30; - Preview_line_period = 14815;///14815 - break; - case 3: //"2592x1944@30fps" - handle->video_res_supported.ulcur_res = 3; - handle->pCus_sensor_init = pCus_init_mipi4lane_linear_5M30fps; - vts_30fps=2250;//3375 - params->expo.vts = vts_30fps; - params->expo.fps = 30; - Preview_line_period = 14815;///14815 - break; - case 4: //"2944x1656@30fps" - handle->video_res_supported.ulcur_res = 4; - handle->pCus_sensor_init = pCus_init_mipi4lane_linear_4P8M30fps; - vts_30fps=2250;//3375 - params->expo.vts = vts_30fps; - params->expo.fps = 30; - Preview_line_period = 14815;///14815 - break; - case 5: //"2560x1440@30fps" - handle->video_res_supported.ulcur_res = 5; - handle->pCus_sensor_init = pCus_init_mipi4lane_linear_3P6M30fps; - vts_30fps=1500; - params->expo.vts = vts_30fps; - params->expo.fps = 30; - Preview_line_period = 22222; - break; - case 6: //"1920x1080@60fps" - handle->video_res_supported.ulcur_res = 6; - handle->pCus_sensor_init = pCus_init_mipi4lane_linear_2M60fps; - vts_30fps=1125; - params->expo.vts = vts_30fps; - params->expo.fps = 60; - Preview_line_period = 14815; - break; - case 7: //"3840x2160@30fps" - handle->video_res_supported.ulcur_res = 7; - handle->pCus_sensor_init = pCus_init_mipi4lane_linear_4K30fps; - vts_30fps=2250;//3375 - params->expo.vts = vts_30fps; - params->expo.fps = 30; - Preview_line_period = 14815;///14815 - break; - default: - break; - } - - return SUCCESS; -} -static int pCus_SetVideoRes_HDR_DOL(ms_cus_sensor *handle, u32 res_idx) -{ - u32 num_res = handle->video_res_supported.num_res; - sc8238_params *params = (sc8238_params *)handle->private_data; - - if (res_idx >= num_res) { - return FAIL; - } - switch (res_idx) { - case 0: - handle->video_res_supported.ulcur_res = 0; - if (handle->interface_attr.attr_mipi.mipi_hdr_virtual_channel_num == 1) { - handle->pCus_sensor_init = pCus_init_mipi4lane_HDR_DOL; - } - vts_30fps_HDR_DOL = 4500;//3375 - Preview_line_period_HDR_DOL = 14815;///14815 - params->expo.vts = vts_30fps_HDR_DOL; - params->expo.fps = 15; - params->expo.max_short_exp=260; - break; - case 1: - handle->video_res_supported.ulcur_res = 1; - if (handle->interface_attr.attr_mipi.mipi_hdr_virtual_channel_num == 1) { - handle->pCus_sensor_init = pCus_init_mipi4lane_HDR_DOL_2M; - } - vts_30fps_HDR_DOL = 2250;//3375 - Preview_line_period_HDR_DOL = 14815;///14815 - params->expo.vts = vts_30fps_HDR_DOL; - params->expo.fps = 15; - params->expo.max_short_exp=130; - break; - default: - break; - } - - return SUCCESS; -} - -static int pCus_GetOrien(ms_cus_sensor *handle, CUS_CAMSENSOR_ORIT *orit) { - char sen_data; - sen_data = mirror_reg[0].data; - SENSOR_DMSG("mirror:%x\r\n", sen_data); - switch(sen_data) { - case 0x00: - *orit = CUS_ORIT_M0F0; - break; - case 0x06: - *orit = CUS_ORIT_M1F0; - break; - case 0x60: - *orit = CUS_ORIT_M0F1; - break; - case 0x66: - *orit = CUS_ORIT_M1F1; - break; - } - return SUCCESS; -} - -static int pCus_SetOrien(ms_cus_sensor *handle, CUS_CAMSENSOR_ORIT orit) -{ - sc8238_params *params = (sc8238_params *)handle->private_data; - SENSOR_DMSG("\n\n[%s]", __FUNCTION__); - switch(orit) - { - case CUS_ORIT_M0F0: - mirror_reg[0].data = 0x00; - params->cur_orien = CUS_ORIT_M0F0; - params->reg_mf = true; - break; - case CUS_ORIT_M1F0: - mirror_reg[0].data = 0x06; - params->cur_orien = CUS_ORIT_M1F0; - params->reg_mf = true; - break; - case CUS_ORIT_M0F1: - mirror_reg[0].data = 0x60; - params->cur_orien = CUS_ORIT_M0F1; - params->reg_mf = true; - break; - case CUS_ORIT_M1F1: - mirror_reg[0].data = 0x66; - params->cur_orien = CUS_ORIT_M1F1; - params->reg_mf = true; - break; - default : - break; - } - return SUCCESS; -} - -static int pCus_SetOrien_HDR(ms_cus_sensor *handle, CUS_CAMSENSOR_ORIT orit) -{ - sc8238_params *params = (sc8238_params *)handle->private_data; - SENSOR_DMSG("\n\n[%s]", __FUNCTION__); - switch(orit) - { - case CUS_ORIT_M0F0: - mirror_reg_HDR[0].data = 0x00; - mirror_reg_HDR[2].data = 0x80; - params->cur_orien = CUS_ORIT_M0F0; - params->reg_mf = true; - break; - case CUS_ORIT_M1F0: - mirror_reg_HDR[0].data = 0x06; - mirror_reg_HDR[2].data = 0x83; - params->cur_orien = CUS_ORIT_M1F0; - params->reg_mf = true; - break; - case CUS_ORIT_M0F1: - mirror_reg_HDR[0].data = 0x60; - mirror_reg_HDR[2].data = 0x80; - params->cur_orien = CUS_ORIT_M0F1; - params->reg_mf = true; - break; - case CUS_ORIT_M1F1: - mirror_reg_HDR[0].data = 0x66; - mirror_reg_HDR[2].data = 0x83; - params->cur_orien = CUS_ORIT_M1F1; - params->reg_mf = true; - break; - default : - break; - } - return SUCCESS; -} - -static int pCus_GetFPS(ms_cus_sensor *handle) -{ - sc8238_params *params = (sc8238_params *)handle->private_data; - u32 max_fps = handle->video_res_supported.res[handle->video_res_supported.ulcur_res].max_fps; - u32 tVts = (vts_reg[0].data << 8) | (vts_reg[1].data << 0); - - if (params->expo.fps >= 1000) - params->expo.preview_fps = (vts_30fps*max_fps*1000)/tVts; - else - params->expo.preview_fps = (vts_30fps*max_fps)/tVts; - - return params->expo.preview_fps; -} - -static int pCus_SetFPS(ms_cus_sensor *handle, u32 fps) -{ - u32 vts=0; - sc8238_params *params = (sc8238_params *)handle->private_data; - u32 max_fps = handle->video_res_supported.res[handle->video_res_supported.ulcur_res].max_fps; - u32 min_fps = handle->video_res_supported.res[handle->video_res_supported.ulcur_res].min_fps; - pr_info("[%s] max_min_fps : %d ,%d\n\n", __FUNCTION__,max_fps,min_fps); - if(fps>=min_fps && fps <= max_fps){ - params->expo.fps = fps; - params->expo.vts= (vts_30fps*max_fps)/fps; - }else if((fps >= (min_fps*1000)) && (fps <= (max_fps*1000))){ - params->expo.fps = fps; - params->expo.vts= (vts_30fps*(max_fps*1000))/fps; - }else{ - SENSOR_DMSG("[%s] FPS %d out of range.\n",__FUNCTION__,fps); - return FAIL; - } - - if(params->expo.line > 2* (params->expo.vts) -10){ - vts = (params->expo.line + 11)/2; - }else{ - vts = params->expo.vts; - } - vts_reg[0].data = (vts >> 8) & 0x00ff; - vts_reg[1].data = (vts >> 0) & 0x00ff; - params->reg_dirty = true; - return SUCCESS; - -} - -static int pCus_GetFPS_HDR_DOL_SEF(ms_cus_sensor *handle) -{ - sc8238_params *params = (sc8238_params *)handle->private_data; - u32 max_fps = handle->video_res_supported.res[handle->video_res_supported.ulcur_res].max_fps; - u32 tVts = (vts_reg[0].data << 8) | (vts_reg[1].data << 0); - - if (params->expo.fps >= 1000) - params->expo.preview_fps = (vts_30fps_HDR_DOL*max_fps*1000)/tVts; - else - params->expo.preview_fps = (vts_30fps_HDR_DOL*max_fps)/tVts; - - return params->expo.preview_fps; -} - -static int pCus_SetFPS_HDR_DOL_SEF(ms_cus_sensor *handle, u32 fps) -{ - sc8238_params *params = (sc8238_params *)handle->private_data; - u32 max_fps = handle->video_res_supported.res[handle->video_res_supported.ulcur_res].max_fps; - u32 min_fps = handle->video_res_supported.res[handle->video_res_supported.ulcur_res].min_fps; - //pr_info("[%s] max_min_fps : %d ,%d\n\n", __FUNCTION__,max_fps,min_fps); - - if(fps>=min_fps && fps <= max_fps){ - params->expo.fps = fps; - params->expo.vts= ((vts_30fps_HDR_DOL*max_fps)/fps >> 1) << 1; - vts_reg[0].data = (params->expo.vts >> 8) & 0x00ff; - vts_reg[1].data = (params->expo.vts >> 0) & 0x00ff; - params->reg_dirty = true; - pr_info("[%s] vts_reg_sef : %x , %x\n\n", __FUNCTION__,vts_reg[0].data,vts_reg[1].data); - return SUCCESS; - }else if((fps >= (min_fps*1000)) && (fps <= (max_fps*1000))){ - params->expo.fps = fps; - params->expo.vts= ((vts_30fps_HDR_DOL*(max_fps*1000))/fps >> 1) << 1; - vts_reg[0].data = (params->expo.vts >> 8) & 0x00ff; - vts_reg[1].data = (params->expo.vts >> 0) & 0x00ff; - params->reg_dirty = true; - pr_info("[%s] vts_reg_sef : %x , %x\n\n", __FUNCTION__,vts_reg[0].data,vts_reg[1].data); - return SUCCESS; - }else{ - pr_info("[%s] FPS %d out of range.\n",__FUNCTION__,fps); - return FAIL; - } - -} -static int pCus_SetFPS_hdr_dol_lef(ms_cus_sensor *handle, u32 fps) -{ - sc8238_params *params = (sc8238_params *)handle->private_data; - u32 max_fps = handle->video_res_supported.res[handle->video_res_supported.ulcur_res].max_fps; - u32 min_fps = handle->video_res_supported.res[handle->video_res_supported.ulcur_res].min_fps; -// pr_info("[%s] max_min_fps : %d ,%d\n\n", __FUNCTION__,max_fps,min_fps); - - if(fps>=min_fps && fps <= max_fps){ - params->expo.fps = fps; - params->expo.vts= ((vts_30fps_HDR_DOL*max_fps)/fps >> 1) << 1; - vts_reg[0].data = (params->expo.vts >> 8) & 0x00ff; - vts_reg[1].data = (params->expo.vts >> 0) & 0x00ff; - params->reg_dirty = true; - pr_info("[%s] vts_reg_lef : %x , %x\n\n", __FUNCTION__,vts_reg[0].data,vts_reg[1].data); - return SUCCESS; - }else if((fps >= (min_fps*1000)) && (fps <= (max_fps*1000))){ - params->expo.fps = fps; - params->expo.vts= ((vts_30fps_HDR_DOL*(max_fps*1000))/fps >> 1) << 1; - vts_reg[0].data = (params->expo.vts >> 8) & 0x00ff; - vts_reg[1].data = (params->expo.vts >> 0) & 0x00ff; - params->reg_dirty = true; - pr_info("[%s] vts_reg_lef : %x , %x\n\n", __FUNCTION__,vts_reg[0].data,vts_reg[1].data); - return SUCCESS; - }else{ - pr_info("[%s] FPS %d out of range.\n",__FUNCTION__,fps); - return FAIL; - } - -} - - -#if 0 -static int pCus_GetSensorCap(ms_cus_sensor *handle, CUS_CAMSENSOR_CAP *cap) { - if (cap) - memcpy(cap, &sensor_cap, sizeof(CUS_CAMSENSOR_CAP)); - else return FAIL; - return SUCCESS; -} -#endif - -/////////////////////////////////////////////////////////////////////// -// auto exposure -/////////////////////////////////////////////////////////////////////// -// unit: micro seconds -//AE status notification -static int pCus_AEStatusNotify(ms_cus_sensor *handle, CUS_CAMSENSOR_AE_STATUS_NOTIFY status){ - - sc8238_params *params = (sc8238_params *)handle->private_data; - - switch(status) - { - case CUS_FRAME_INACTIVE: - break; - case CUS_FRAME_ACTIVE: - if(params->reg_mf) - { - SensorRegArrayW((I2C_ARRAY*)mirror_reg, ARRAY_SIZE(mirror_reg)); - params->reg_mf = false; - } - if(params->reg_dirty) - { - SensorRegArrayW((I2C_ARRAY*)expo_reg, ARRAY_SIZE(expo_reg)); - SensorRegArrayW((I2C_ARRAY*)gain_reg, ARRAY_SIZE(gain_reg)); - SensorRegArrayW((I2C_ARRAY*)vts_reg, ARRAY_SIZE(vts_reg)); - params->reg_dirty = false; - } - break; - default : - break; - } - return SUCCESS; -} -static int pCus_AEStatusNotifyHDR_DOL_LEF(ms_cus_sensor *handle, CUS_CAMSENSOR_AE_STATUS_NOTIFY status) -{ - //sc8238_params *params = (sc8238_params *)handle->private_data; - - switch(status) - { - case CUS_FRAME_INACTIVE: - break; - case CUS_FRAME_ACTIVE: - break; - default : - break; - } - return SUCCESS; - -} - -static int pCus_AEStatusNotifyHDR_DOL_SEF(ms_cus_sensor *handle, CUS_CAMSENSOR_AE_STATUS_NOTIFY status) -{ - sc8238_params *params = (sc8238_params *)handle->private_data; - switch(status) - { - case CUS_FRAME_INACTIVE: - //SensorReg_Write(0x3001,0); - - break; - case CUS_FRAME_ACTIVE: - if(params->reg_mf) - { - SensorRegArrayW((I2C_ARRAY*)mirror_reg_HDR, ARRAY_SIZE(mirror_reg_HDR)); - params->reg_mf = false; - } - if(params->reg_dirty) - { - SensorRegArrayW((I2C_ARRAY*)expo_reg, ARRAY_SIZE(expo_reg)); - SensorRegArrayW((I2C_ARRAY*)gain_reg, ARRAY_SIZE(gain_reg)); - SensorRegArrayW((I2C_ARRAY*)expo_reg_HDR_DOL_SEF, ARRAY_SIZE(expo_reg_HDR_DOL_SEF)); - SensorRegArrayW((I2C_ARRAY*)gain_reg_HDR_DOL_SEF, ARRAY_SIZE(gain_reg_HDR_DOL_SEF)); - SensorRegArrayW((I2C_ARRAY*)vts_reg, ARRAY_SIZE(vts_reg)); - params->reg_dirty = false; - } - break; - default : - break; - } - return SUCCESS; -} -static int pCus_SetAEUSecsHDR_DOL_LEF(ms_cus_sensor *handle, u32 us) -{ - int i; - u32 half_lines = 0,dou_lines = 0,vts = 0; - sc8238_params *params = (sc8238_params *)handle->private_data; - I2C_ARRAY expo_reg_temp[] = { // max expo line vts-4! - {0x3e00, 0x00},//expo [20:17] - {0x3e01, 0x00}, // expo[16:8] - {0x3e02, 0x10}, // expo[7:0], [3:0] fraction of line - }; - memcpy(expo_reg_temp, expo_reg, sizeof(expo_reg)); - dou_lines = (1000*us)/(Preview_line_period_HDR_DOL*2); // Preview_line_period in ns - half_lines = 4*dou_lines; - if(half_lines<8) half_lines=8; - if (half_lines > 2 * (params->expo.vts-params->expo.max_short_exp-10)) { - half_lines = 2 * (params->expo.vts-params->expo.max_short_exp-10); - } - else - vts=params->expo.vts; -// SENSOR_DMSG("[%s] us %ld, half_lines %ld, vts %ld\n", __FUNCTION__, us, half_lines, params->expo.vts); - - half_lines = half_lines<<4; - - expo_reg[0].data = (half_lines>>16) & 0x0f; - expo_reg[1].data = (half_lines>>8) & 0xff; - expo_reg[2].data = (half_lines>>0) & 0xf0; - // pr_info("[%s] expo_reg : %x ,%x , %x\n\n", __FUNCTION__,expo_reg[0].data,expo_reg[1].data,expo_reg[2].data); - for (i = 0; i < ARRAY_SIZE(expo_reg); i++) - { - if (expo_reg[i].data != expo_reg_temp[i].data) - { - params->reg_dirty = true; - break; - } - } - return SUCCESS; - -} - -static int pCus_SetAEUSecsHDR_DOL_SEF(ms_cus_sensor *handle, u32 us) -{ - int i; - u32 half_lines = 0,dou_lines = 0,vts = 0; - sc8238_params *params = (sc8238_params *)handle->private_data; - I2C_ARRAY expo_reg_temp[] = { - {0x3e04, 0x21}, // expo[7:0] - {0x3e05, 0x00}, // expo[7:4] - }; - memcpy(expo_reg_temp, expo_reg_HDR_DOL_SEF, sizeof(expo_reg_HDR_DOL_SEF)); - - dou_lines = (1000*us)/(Preview_line_period_HDR_DOL*2); // Preview_line_period in ns - half_lines = 4*dou_lines; - if(half_lines<8) half_lines=8; - if (half_lines > 2 * (params->expo.max_short_exp-8)) { - half_lines = 2 * (params->expo.max_short_exp-8); - } - else - vts=params->expo.vts; -// SENSOR_DMSG("[%s] us %ld, half_lines %ld, vts %ld\n", __FUNCTION__, us, half_lines, params->expo.vts); - - half_lines = half_lines<<4; - - expo_reg_HDR_DOL_SEF[0].data = (half_lines>>8) & 0xff; - expo_reg_HDR_DOL_SEF[1].data = (half_lines>>0) & 0xf0; - // pr_info("[%s] expo_reg_HDR_DOL_SEF : %x , %x\n\n", __FUNCTION__,expo_reg_HDR_DOL_SEF[0].data,expo_reg_HDR_DOL_SEF[1].data); - for (i = 0; i < ARRAY_SIZE(expo_reg_HDR_DOL_SEF); i++) - { - if (expo_reg_HDR_DOL_SEF[i].data != expo_reg_temp[i].data) - { - params->reg_dirty = true; - break; - } - } - return SUCCESS; - -} - -static int pCus_GetAEUSecs(ms_cus_sensor *handle, u32 *us) { - - u32 lines = 0; - lines |= (u32)(expo_reg[0].data&0x0f)<<16; - lines |= (u32)(expo_reg[1].data&0xff)<<8; - lines |= (u32)(expo_reg[2].data&0xf0)<<0; - lines >>= 4; - *us = (lines*Preview_line_period)/1000/2; //return us - - SENSOR_DMSG("[%s] sensor expo lines/us %d, %dus\n", __FUNCTION__, lines, *us); - return SUCCESS; -} - -static int pCus_SetAEUSecs(ms_cus_sensor *handle, u32 us) { - int i; - u32 half_lines = 0,vts = 0; - sc8238_params *params = (sc8238_params *)handle->private_data; - I2C_ARRAY expo_reg_temp[] = { // max expo line vts-4! - {0x3e00, 0x00},//expo [20:17] - {0x3e01, 0x00}, // expo[16:8] - {0x3e02, 0x10}, // expo[7:0], [3:0] fraction of line - }; - memcpy(expo_reg_temp, expo_reg, sizeof(expo_reg)); - - half_lines = (1000*us*2)/Preview_line_period; // Preview_line_period in ns - if(half_lines<3) half_lines=3; - if (half_lines > 2 * (params->expo.vts)-10) { - vts = (half_lines+11)/2; - } - else - vts=params->expo.vts; - - params->expo.line = half_lines; - SENSOR_DMSG("[%s] us %ld, half_lines %ld, vts %ld\n", __FUNCTION__, us, half_lines, params->expo.vts); - - half_lines = half_lines<<4; - - expo_reg[0].data = (half_lines>>16) & 0x0f; - expo_reg[1].data = (half_lines>>8) & 0xff; - expo_reg[2].data = (half_lines>>0) & 0xf0; - vts_reg[0].data = (vts >> 8) & 0x00ff; - vts_reg[1].data = (vts >> 0) & 0x00ff; - - for (i = 0; i < ARRAY_SIZE(expo_reg); i++) - { - if (expo_reg[i].data != expo_reg_temp[i].data) - { - params->reg_dirty = true; - break; - } - } - return SUCCESS; -} - -// Gain: 1x = 1024 -static int pCus_GetAEGain(ms_cus_sensor *handle, u32* gain) { - int rc = 0; - u8 Dgain = 1, Coarse_gain = 1; - - Coarse_gain = ((gain_reg[2].data&0x1C)>>2) +1; - Dgain = ((gain_reg[0].data&0x0f) + 1); - - *gain = (Coarse_gain*Dgain*(gain_reg[1].data)*(gain_reg[3].data))/2; - - return rc; -} -static int pCus_GetAEGainHDR_DOL_SEF(ms_cus_sensor *handle, u32* gain) { - int rc = 0; - u8 Dgain = 1, Coarse_gain = 1; - - Coarse_gain = ((gain_reg_HDR_DOL_SEF[2].data&0x1C)>>2) +1; - Dgain = ((gain_reg_HDR_DOL_SEF[0].data&0x0f) + 1); - - *gain = (Coarse_gain*Dgain*(gain_reg_HDR_DOL_SEF[1].data)*(gain_reg_HDR_DOL_SEF[3].data))/2; - - - return rc; -} - -static int pCus_SetAEGain_cal(ms_cus_sensor *handle, u32 gain) { - - return SUCCESS; -} - -static int pCus_SetAEGain(ms_cus_sensor *handle, u32 gain) { - sc8238_params *params = (sc8238_params *)handle->private_data; - u8 i=0 ,Dgain = 1, Ana_gain = 1; - u64 Fine_againx64 = 64,Fine_dgainx128 = 128; - u8 Dgain_reg = 0, Ana_gain_reg = 0, Fine_again_reg= 0x40,Fine_dgain_reg= 0x80; - - I2C_ARRAY gain_reg_temp[] = { - {0x3e06, 0x00}, - {0x3e07, 0x80}, - {0x3e08, (0x00|0x03)}, - {0x3e09, 0x40}, - }; - memcpy(gain_reg_temp, gain_reg, sizeof(gain_reg)); - - if (gain < 1024) { - gain = 1024; - } else if (gain > SENSOR_MAXGAIN*1024) { - gain = SENSOR_MAXGAIN*1024; - } - - if (gain < 2 * 1024) - { - Dgain = 1; Fine_dgainx128 = 128; Ana_gain = 1; - Dgain_reg = 0x00; Fine_dgain_reg = 0x80; Ana_gain_reg = 0x03; - } - else if (gain < 4 * 1024) - { - Dgain = 1; Fine_dgainx128 = 128; Ana_gain = 2; - Dgain_reg = 0x00; Fine_dgain_reg = 0x80; Ana_gain_reg = 0x07; - } - else if (gain < 8 * 1024) - { - Dgain = 1; Fine_dgainx128 = 128; Ana_gain = 4; - Dgain_reg = 0x00; Fine_dgain_reg = 0x80; Ana_gain_reg = 0x0f; - } - else if (gain <= 16256) - { - Dgain = 1; Fine_dgainx128 = 128; Ana_gain = 8; - Dgain_reg = 0x00; Fine_dgain_reg = 0x80; Ana_gain_reg = 0x1f; - } - else if (gain < 32512) - { - Dgain = 1; Fine_againx64 = 127; Ana_gain = 8; - Dgain_reg = 0x00; Fine_again_reg = 0x7f; Ana_gain_reg = 0x1f; - } - else if (gain < 65024) - { - Dgain = 2; Fine_againx64 = 127; Ana_gain = 8; - Dgain_reg = 0x01; Fine_again_reg = 0x7f; Ana_gain_reg = 0x1f; - } - else if (gain < 127 * 1024) - { - Dgain = 4; Fine_againx64 = 127; Ana_gain = 8; - Dgain_reg = 0x03; Fine_again_reg = 0x7f; Ana_gain_reg = 0x1f; - } - else if (gain < 254 * 1024) - { - Dgain = 8; Fine_againx64 = 127; Ana_gain = 8; - Dgain_reg = 0x07; Fine_again_reg = 0x7f; Ana_gain_reg = 0x1f; - } - else if (gain <= SENSOR_MAXGAIN * 1024) - { - Dgain = 16; Fine_againx64 = 127; Ana_gain = 8; - Dgain_reg = 0x0f; Fine_again_reg = 0x7f; Ana_gain_reg = 0x1f; - } - - if (gain <= 16256) - { - Fine_againx64 = abs(8 * gain/ (Dgain * Ana_gain * Fine_dgainx128)); - //Fine_dgainx128 = abs(8 * gain/ (Dgain * Ana_gain * Fine_againx64)); - Fine_again_reg = Fine_againx64; - //Fine_dgain_reg = Fine_dgainx128; - } - else - { - Fine_dgainx128 = abs(8 * gain/ (Dgain * Ana_gain * Fine_againx64)); - Fine_dgain_reg = Fine_dgainx128; - } - // pr_info("[%s] gain : %d,%lld,%lld,%d, %d\n\n", __FUNCTION__,gain,Fine_again,Fine_dgainx128,Dgain,Ana_gain); - // pr_info("[%s] gain_reg : %x ,%x ,%x , %x\n\n", __FUNCTION__,Fine_again_reg,Ana_gain_reg,Fine_dgain_reg,Dgain_reg); - - gain_reg[3].data = Fine_again_reg; - gain_reg[2].data = Ana_gain_reg; - gain_reg[1].data = Fine_dgain_reg; - gain_reg[0].data = Dgain_reg & 0xF; - //pr_info("[%s] gain_reg : %x ,%x ,%x , %x\n\n", __FUNCTION__,gain_reg[3].data,gain_reg[2].data,gain_reg[1].data,gain_reg[0].data); - - for (i = 0; i < ARRAY_SIZE(gain_reg); i++) - { - if (gain_reg[i].data != gain_reg_temp[i].data) - { - params->reg_dirty = true; - break; - } - } - return SUCCESS; -} - -static int pCus_SetAEGainHDR_DOL_SEF(ms_cus_sensor *handle, u32 gain) { - sc8238_params *params = (sc8238_params *)handle->private_data; - u8 i=0 ,Dgain = 1, Ana_gain = 1; - u64 Fine_againx64 = 64,Fine_dgainx128 = 128; - u8 Dgain_reg = 0, Ana_gain_reg = 0, Fine_again_reg= 0x10,Fine_dgain_reg= 0x80; - - I2C_ARRAY gain_reg_temp[] = { - {0x3e10, 0x00}, - {0x3e11, 0x80}, - {0x3e12, (0x00|0x03)}, - {0x3e13, 0x40}, - }; - memcpy(gain_reg_temp, gain_reg_HDR_DOL_SEF, sizeof(gain_reg_HDR_DOL_SEF)); - - if (gain < 1024) { - gain = 1024; - } else if (gain > SENSOR_MAXGAIN*1024) { - gain = SENSOR_MAXGAIN*1024; - } - - if (gain < 2 * 1024) - { - Dgain = 1; Fine_dgainx128 = 128; Ana_gain = 1; - Dgain_reg = 0x00; Fine_dgain_reg = 0x80; Ana_gain_reg = 0x03; - } - else if (gain < 4 * 1024) - { - Dgain = 1; Fine_dgainx128 = 128; Ana_gain = 2; - Dgain_reg = 0x00; Fine_dgain_reg = 0x80; Ana_gain_reg = 0x07; - } - else if (gain < 8 * 1024) - { - Dgain = 1; Fine_dgainx128 = 128; Ana_gain = 4; - Dgain_reg = 0x00; Fine_dgain_reg = 0x80; Ana_gain_reg = 0x0f; - } - else if (gain <= 16256) - { - Dgain = 1; Fine_dgainx128 = 128; Ana_gain = 8; - Dgain_reg = 0x00; Fine_dgain_reg = 0x80; Ana_gain_reg = 0x1f; - } - else if (gain < 32512) - { - Dgain = 1; Fine_againx64 = 127; Ana_gain = 8; - Dgain_reg = 0x00; Fine_again_reg = 0x7f; Ana_gain_reg = 0x1f; - } - else if (gain < 65024) - { - Dgain = 2; Fine_againx64 = 127; Ana_gain = 8; - Dgain_reg = 0x01; Fine_again_reg = 0x7f; Ana_gain_reg = 0x1f; - } - else if (gain < 127 * 1024) - { - Dgain = 4; Fine_againx64 = 127; Ana_gain = 8; - Dgain_reg = 0x03; Fine_again_reg = 0x7f; Ana_gain_reg = 0x1f; - } - else if (gain < 254 * 1024) - { - Dgain = 8; Fine_againx64 = 127; Ana_gain = 8; - Dgain_reg = 0x07; Fine_again_reg = 0x7f; Ana_gain_reg = 0x1f; - } - else if (gain <= SENSOR_MAXGAIN * 1024) - { - Dgain = 16; Fine_againx64 = 127; Ana_gain = 8; - Dgain_reg = 0x0f; Fine_again_reg = 0x7f; Ana_gain_reg = 0x1f; - } - - if (gain <= 16256) - { - Fine_againx64 = abs(8 * gain/ (Dgain * Ana_gain * Fine_dgainx128)); - //Fine_dgainx128 = abs(8 * gain/ (Dgain * Ana_gain * Fine_againx64)); - Fine_again_reg = Fine_againx64; - //Fine_dgain_reg = Fine_dgainx128; - } - else - { - Fine_dgainx128 = abs(8 * gain/ (Dgain * Ana_gain * Fine_againx64)); - Fine_dgain_reg = Fine_dgainx128; - } - // pr_info("[%s] gain : %d,%lld,%lld,%d, %d\n\n", __FUNCTION__,gain,Fine_again,Fine_dgain,Dgain,Ana_gain); - // pr_info("[%s] gain_reg : %x ,%x ,%x , %x\n\n", __FUNCTION__,Fine_again_reg,Ana_gain_reg,Fine_dgain_reg,Dgain_reg); - - gain_reg_HDR_DOL_SEF[3].data = Fine_again_reg; - gain_reg_HDR_DOL_SEF[2].data = Ana_gain_reg; - gain_reg_HDR_DOL_SEF[1].data = Fine_dgain_reg; - gain_reg_HDR_DOL_SEF[0].data = Dgain_reg & 0xF; - //pr_info("[%s] gain_reg : %x ,%x ,%x , %x\n\n", __FUNCTION__,gain_reg_HDR_DOL_SEF[3].data,gain_reg_HDR_DOL_SEF[2].data,gain_reg_HDR_DOL_SEF[1].data,gain_reg_HDR_DOL_SEF[0].data); - - for (i = 0; i < ARRAY_SIZE(gain_reg_HDR_DOL_SEF); i++) - { - if (gain_reg_HDR_DOL_SEF[i].data != gain_reg_temp[i].data) - { - params->reg_dirty = true; - break; - } - } - return SUCCESS; -} - - -static int pCus_GetAEMinMaxUSecs(ms_cus_sensor *handle, u32 *min, u32 *max) { - *min = 30; - *max = 1000000/Preview_MIN_FPS; - return SUCCESS; -} - -static int pCus_GetAEMinMaxGain(ms_cus_sensor *handle, u32 *min, u32 *max) { - *min = 1024; - *max = SENSOR_MAXGAIN*1024; - return SUCCESS; -} - -static int sc8238_GetShutterInfo(struct __ms_cus_sensor* handle,CUS_SHUTTER_INFO *info) -{ - info->max = 1000000000/Preview_MIN_FPS; - info->min = Preview_line_period * 3; - info->step = Preview_line_period; - return SUCCESS; -} -static int pCus_GetShutterInfo_hdr_dol_lef(struct __ms_cus_sensor* handle,CUS_SHUTTER_INFO *info) -{ - info->max = 1000000000/Preview_MIN_FPS; - info->min = (Preview_line_period_HDR_DOL * 4); - info->step = Preview_line_period_HDR_DOL*2; - return SUCCESS; -} -static int pCus_GetShutterInfo_hdr_dol_sef(struct __ms_cus_sensor* handle,CUS_SHUTTER_INFO *info) -{ - sc8238_params *params = (sc8238_params *)handle->private_data; - info->max = Preview_line_period_HDR_DOL * params->expo.max_short_exp; - info->min = (Preview_line_period_HDR_DOL * 4); - info->step = Preview_line_period_HDR_DOL*2; - return SUCCESS; -} -static int pCus_poweron_hdr_dol_lef(ms_cus_sensor *handle, u32 idx) -{ - return SUCCESS; -} - -static int pCus_poweroff_hdr_dol_lef(ms_cus_sensor *handle, u32 idx) -{ - return SUCCESS; -} -static int pCus_GetSensorID_hdr_dol_lef(ms_cus_sensor *handle, u32 *id) -{ - *id = 0; - return SUCCESS; -} -static int pCus_init_hdr_dol_lef(ms_cus_sensor *handle) -{ - return SUCCESS; -} -#if 0 -static int pCus_GetVideoRes_hdr_dol_lef( ms_cus_sensor *handle, u32 res_idx, cus_camsensor_res **res ) -{ - *res = &handle->video_res_supported.res[res_idx]; - return SUCCESS; -} - -static int pCus_SetVideoRes_hdr_dol_lef( ms_cus_sensor *handle, u32 res ) -{ - handle->video_res_supported.ulcur_res = 0; //TBD - return SUCCESS; -} -#endif -/* static int pCus_GetOrien_hdr_dol_lef(ms_cus_sensor *handle, CUS_CAMSENSOR_ORIT *orit) -{ - *orit = CUS_ORIT_M0F0; - return SUCCESS; -} - -static int pCus_SetOrien_hdr_dol_lef(ms_cus_sensor *handle, CUS_CAMSENSOR_ORIT orit) -{ - return SUCCESS; -} */ - -static int pCus_GetFPS_hdr_dol_lef(ms_cus_sensor *handle) -{ - sc8238_params *params = (sc8238_params *)handle->private_data; - u32 max_fps = handle->video_res_supported.res[handle->video_res_supported.ulcur_res].max_fps; - u32 tVts = (vts_reg[0].data << 8) | (vts_reg[1].data << 0); - - if (params->expo.fps >= 1000) - params->expo.preview_fps = (vts_30fps_HDR_DOL*max_fps*1000)/tVts; - else - params->expo.preview_fps = (vts_30fps_HDR_DOL*max_fps)/tVts; - - return params->expo.preview_fps; -} - -static int pCus_setCaliData_gain_linearity_hdr_dol_lef(ms_cus_sensor* handle, CUS_GAIN_GAP_ARRAY* pArray, u32 num) -{ - return SUCCESS; -} -static int pCus_SetAEGain_cal_hdr_dol_lef(ms_cus_sensor *handle, u32 gain) -{ - return SUCCESS; -} -static int pCus_setCaliData_gain_linearity(ms_cus_sensor* handle, CUS_GAIN_GAP_ARRAY* pArray, u32 num) { - - return SUCCESS; -} - -int cus_camsensor_init_handle_linear(ms_cus_sensor* drv_handle) { - ms_cus_sensor *handle = drv_handle; - sc8238_params *params; - if (!handle) { - SENSOR_DMSG("[%s] not enough memory!\n", __FUNCTION__); - return FAIL; - } - SENSOR_DMSG("[%s]", __FUNCTION__); - //private data allocation & init - if (handle->private_data == NULL) { - SENSOR_EMSG("[%s] Private data is empty!\n", __FUNCTION__); - return FAIL; - } - params = (sc8238_params *)handle->private_data; - - //////////////////////////////////// - // sensor model ID // - //////////////////////////////////// - sprintf(handle->model_id,"sc8238_MIPI"); - - //////////////////////////////////// - // sensor interface info // - //////////////////////////////////// - //SENSOR_DMSG("[%s] entering function with id %d\n", __FUNCTION__, id); - handle->isp_type = SENSOR_ISP_TYPE; //ISP_SOC; - //handle->data_fmt = SENSOR_DATAFMT; //CUS_DATAFMT_YUV; - handle->sif_bus = SENSOR_IFBUS_TYPE;//CUS_SENIF_BUS_PARL; - handle->data_prec = SENSOR_DATAPREC; //CUS_DATAPRECISION_8; - handle->data_mode = SENSOR_DATAMODE; - handle->bayer_id = SENSOR_BAYERID; //CUS_BAYER_GB; - handle->RGBIR_id = SENSOR_RGBIRID; - handle->orient = SENSOR_ORIT; //CUS_ORIT_M1F1; - //handle->YC_ODER = SENSOR_YCORDER; //CUS_SEN_YCODR_CY; - handle->interface_attr.attr_mipi.mipi_lane_num = SENSOR_MIPI_LANE_NUM; - handle->interface_attr.attr_mipi.mipi_data_format = CUS_SEN_INPUT_FORMAT_RGB; // RGB pattern. - handle->interface_attr.attr_mipi.mipi_yuv_order = 0; //don't care in RGB pattern. - handle->interface_attr.attr_mipi.mipi_hsync_mode = SENSOR_MIPI_HSYNC_MODE; - handle->interface_attr.attr_mipi.mipi_hdr_mode = CUS_HDR_MODE_NONE; - handle->interface_attr.attr_mipi.mipi_hdr_virtual_channel_num = 0; //Short frame - - //////////////////////////////////// - // resolution capability // - //////////////////////////////////// - - handle->video_res_supported.num_res = 1; - handle->video_res_supported.ulcur_res = 0; //default resolution index is 0. - handle->video_res_supported.res[0].width = Preview_WIDTH; - handle->video_res_supported.res[0].height = Preview_HEIGHT; - handle->video_res_supported.res[0].max_fps= 15; - handle->video_res_supported.res[0].min_fps= Preview_MIN_FPS; - handle->video_res_supported.res[0].crop_start_x= Preview_CROP_START_X; - handle->video_res_supported.res[0].crop_start_y= Preview_CROP_START_Y; - handle->video_res_supported.res[0].nOutputWidth= 3840; - handle->video_res_supported.res[0].nOutputHeight= 2160; - sprintf(handle->video_res_supported.res[0].strResDesc, "3840x2160@15fps"); - - handle->video_res_supported.num_res = 2; - handle->video_res_supported.ulcur_res = 0; //default resolution index is 0. - handle->video_res_supported.res[1].width = Preview_WIDTH; - handle->video_res_supported.res[1].height = Preview_HEIGHT; - handle->video_res_supported.res[1].max_fps= 20; - handle->video_res_supported.res[1].min_fps= Preview_MIN_FPS; - handle->video_res_supported.res[1].crop_start_x= Preview_CROP_START_X; - handle->video_res_supported.res[1].crop_start_y= Preview_CROP_START_Y; - handle->video_res_supported.res[1].nOutputWidth= 3840; - handle->video_res_supported.res[1].nOutputHeight= 2160; - sprintf(handle->video_res_supported.res[1].strResDesc, "3840x2160@20fps"); - - - handle->video_res_supported.num_res = 3; - handle->video_res_supported.ulcur_res = 0; //default resolution index is 0. - handle->video_res_supported.res[2].width = 3072; - handle->video_res_supported.res[2].height = 1728; - handle->video_res_supported.res[2].max_fps= 30; - handle->video_res_supported.res[2].min_fps= Preview_MIN_FPS; - handle->video_res_supported.res[2].crop_start_x= Preview_CROP_START_X; - handle->video_res_supported.res[2].crop_start_y= Preview_CROP_START_Y; - handle->video_res_supported.res[2].nOutputWidth= 3072; - handle->video_res_supported.res[2].nOutputHeight= 1728; - sprintf(handle->video_res_supported.res[2].strResDesc, "3072x1728@30fps"); - - - handle->video_res_supported.num_res = 4; - handle->video_res_supported.ulcur_res = 0; //default resolution index is 0. - handle->video_res_supported.res[3].width = 2592; - handle->video_res_supported.res[3].height = 1944; - handle->video_res_supported.res[3].max_fps= 30; - handle->video_res_supported.res[3].min_fps= Preview_MIN_FPS; - handle->video_res_supported.res[3].crop_start_x= Preview_CROP_START_X; - handle->video_res_supported.res[3].crop_start_y= Preview_CROP_START_Y; - handle->video_res_supported.res[3].nOutputWidth= 2592; - handle->video_res_supported.res[3].nOutputHeight= 1944; - sprintf(handle->video_res_supported.res[3].strResDesc, "2592x1944@30fps"); - - handle->video_res_supported.num_res = 5; - handle->video_res_supported.ulcur_res = 0; //default resolution index is 0. - handle->video_res_supported.res[4].width = 2944; - handle->video_res_supported.res[4].height = 1656; - handle->video_res_supported.res[4].max_fps= 30; - handle->video_res_supported.res[4].min_fps= Preview_MIN_FPS; - handle->video_res_supported.res[4].crop_start_x= Preview_CROP_START_X; - handle->video_res_supported.res[4].crop_start_y= Preview_CROP_START_Y; - handle->video_res_supported.res[4].nOutputWidth= 2944; - handle->video_res_supported.res[4].nOutputHeight= 1656; - sprintf(handle->video_res_supported.res[4].strResDesc, "2944x1656@30fps"); - - handle->video_res_supported.num_res = 6; - handle->video_res_supported.ulcur_res = 0; //default resolution index is 0. - handle->video_res_supported.res[5].width = 2560; - handle->video_res_supported.res[5].height = 1440; - handle->video_res_supported.res[5].max_fps= 30; - handle->video_res_supported.res[5].min_fps= Preview_MIN_FPS; - handle->video_res_supported.res[5].crop_start_x= Preview_CROP_START_X; - handle->video_res_supported.res[5].crop_start_y= Preview_CROP_START_Y; - handle->video_res_supported.res[5].nOutputWidth= 2560; - handle->video_res_supported.res[5].nOutputHeight= 1440; - sprintf(handle->video_res_supported.res[5].strResDesc, "2560x1440@30fps"); - - handle->video_res_supported.num_res = 7; - handle->video_res_supported.ulcur_res = 0; //default resolution index is 0. - handle->video_res_supported.res[6].width = 1920; - handle->video_res_supported.res[6].height = 1080; - handle->video_res_supported.res[6].max_fps= 60; - handle->video_res_supported.res[6].min_fps= Preview_MIN_FPS; - handle->video_res_supported.res[6].crop_start_x= Preview_CROP_START_X; - handle->video_res_supported.res[6].crop_start_y= Preview_CROP_START_Y; - handle->video_res_supported.res[6].nOutputWidth= 1920; - handle->video_res_supported.res[6].nOutputHeight= 1080; - sprintf(handle->video_res_supported.res[6].strResDesc, "1920x1080@60fps"); - - handle->video_res_supported.num_res = 8; - handle->video_res_supported.ulcur_res = 0; //default resolution index is 0. - handle->video_res_supported.res[7].width = Preview_WIDTH; - handle->video_res_supported.res[7].height = Preview_HEIGHT; - handle->video_res_supported.res[7].max_fps= 30; - handle->video_res_supported.res[7].min_fps= Preview_MIN_FPS; - handle->video_res_supported.res[7].crop_start_x= Preview_CROP_START_X; - handle->video_res_supported.res[7].crop_start_y= Preview_CROP_START_Y; - handle->video_res_supported.res[7].nOutputWidth= 3840; - handle->video_res_supported.res[7].nOutputHeight= 2160; - sprintf(handle->video_res_supported.res[7].strResDesc, "3840x2160@30fps"); - - // i2c - - handle->i2c_cfg.mode = SENSOR_I2C_LEGACY; //(CUS_ISP_I2C_MODE) FALSE; - handle->i2c_cfg.fmt = SENSOR_I2C_FMT; //CUS_I2C_FMT_A16D16; - handle->i2c_cfg.address = SENSOR_I2C_ADDR; //0x5a; - handle->i2c_cfg.speed = SENSOR_I2C_SPEED; //320000; - - // mclk - handle->mclk = Preview_MCLK_SPEED; - - //polarity - ///////////////////////////////////////////////////// - handle->pwdn_POLARITY = SENSOR_PWDN_POL; //CUS_CLK_POL_NEG; - handle->reset_POLARITY = SENSOR_RST_POL; //CUS_CLK_POL_NEG; - handle->VSYNC_POLARITY = SENSOR_VSYNC_POL; //CUS_CLK_POL_POS; - handle->HSYNC_POLARITY = SENSOR_HSYNC_POL; //CUS_CLK_POL_POS; - handle->PCLK_POLARITY = SENSOR_PCLK_POL; //CUS_CLK_POL_POS); // use '!' to clear board latch error - ///////////////////////////////////////////////////// - - //////////////////////////////////////////////////// - // AE parameters - //////////////////////////////////////////////////// - handle->ae_gain_delay = 2; - handle->ae_shutter_delay = 2; - - handle->ae_gain_ctrl_num = 1; - handle->ae_shutter_ctrl_num = 1; - - ///calibration - handle->sat_mingain=g_sensor_ae_min_gain; - - - handle->pCus_sensor_release = cus_camsensor_release_handle; - handle->pCus_sensor_init = pCus_init_mipi4lane_linear_4K15fps; - - handle->pCus_sensor_poweron = pCus_poweron ; - handle->pCus_sensor_poweroff = pCus_poweroff; - handle->pCus_sensor_post_init = pCus_post_init; - - // Normal - handle->pCus_sensor_GetSensorID = pCus_GetSensorID ; - - handle->pCus_sensor_GetVideoResNum = pCus_GetVideoResNum; - handle->pCus_sensor_GetVideoRes = pCus_GetVideoRes; - handle->pCus_sensor_GetCurVideoRes = pCus_GetCurVideoRes; - handle->pCus_sensor_SetVideoRes = pCus_SetVideoRes; - - handle->pCus_sensor_GetOrien = pCus_GetOrien ; - handle->pCus_sensor_SetOrien = pCus_SetOrien ; - handle->pCus_sensor_GetFPS = pCus_GetFPS ; - handle->pCus_sensor_SetFPS = pCus_SetFPS ; - //handle->pCus_sensor_GetSensorCap = pCus_GetSensorCap; - handle->pCus_sensor_SetPatternMode = sc8238_SetPatternMode; - /////////////////////////////////////////////////////// - // AE - /////////////////////////////////////////////////////// - // unit: micro seconds - //handle->pCus_sensor_GetAETrigger_mode = pCus_GetAETrigger_mode; - //handle->pCus_sensor_SetAETrigger_mode = pCus_SetAETrigger_mode; - handle->pCus_sensor_AEStatusNotify = pCus_AEStatusNotify; - handle->pCus_sensor_GetAEUSecs = pCus_GetAEUSecs; - handle->pCus_sensor_SetAEUSecs = pCus_SetAEUSecs; - handle->pCus_sensor_GetAEGain = pCus_GetAEGain; - - handle->pCus_sensor_SetAEGain = pCus_SetAEGain; - - handle->pCus_sensor_GetAEMinMaxGain = pCus_GetAEMinMaxGain; - handle->pCus_sensor_GetAEMinMaxUSecs= pCus_GetAEMinMaxUSecs; - - //sensor calibration - handle->pCus_sensor_SetAEGain_cal = pCus_SetAEGain_cal; - handle->pCus_sensor_setCaliData_gain_linearity=pCus_setCaliData_gain_linearity; - handle->pCus_sensor_GetShutterInfo = sc8238_GetShutterInfo; - // params->expo.vts=vts_30fps; - // params->expo.fps = 30; - params->expo.line= 1000; - Preview_line_period = 25720; - params->expo.fps = 15; - params->reg_dirty = false; - params->reg_mf = false; - return SUCCESS; -} -int cus_camsensor_init_handle_hdr_dol_sef(ms_cus_sensor* drv_handle) -{ - ms_cus_sensor *handle = drv_handle; - sc8238_params *params = NULL; - - cus_camsensor_init_handle_linear(drv_handle); - params = (sc8238_params *)handle->private_data; - - sprintf(handle->model_id,"sc8238_MIPI_HDR_SEF"); - - handle->bayer_id = SENSOR_BAYERID_HDR_DOL; - handle->RGBIR_id = SENSOR_RGBIRID; - - handle->interface_attr.attr_mipi.mipi_lane_num = SENSOR_MIPI_LANE_NUM; - handle->interface_attr.attr_mipi.mipi_hsync_mode = SENSOR_MIPI_HSYNC_MODE_HDR_DOL; - handle->interface_attr.attr_mipi.mipi_hdr_mode = CUS_HDR_MODE_DCG; - - //////////////////////////////////// - // resolution capability // - //////////////////////////////////// - handle->video_res_supported.num_res = 1; - handle->video_res_supported.ulcur_res = 0; //default resolution index is 0. - handle->video_res_supported.res[0].width = Preview_WIDTH; - handle->video_res_supported.res[0].height = Preview_HEIGHT; - handle->video_res_supported.res[0].max_fps= Preview_MAX_FPS; - handle->video_res_supported.res[0].min_fps= Preview_MIN_FPS; - handle->video_res_supported.res[0].crop_start_x= Preview_CROP_START_X; - handle->video_res_supported.res[0].crop_start_y= Preview_CROP_START_Y; - handle->video_res_supported.res[0].nOutputWidth= 3840; - handle->video_res_supported.res[0].nOutputHeight= 2160; - sprintf(handle->video_res_supported.res[0].strResDesc, "3840x2160@15fps"); - - handle->video_res_supported.num_res = 2; - handle->video_res_supported.ulcur_res = 0; //default resolution index is 0. - handle->video_res_supported.res[1].width = 1920; - handle->video_res_supported.res[1].height = 1080; - handle->video_res_supported.res[1].max_fps= 30; - handle->video_res_supported.res[1].min_fps= Preview_MIN_FPS; - handle->video_res_supported.res[1].crop_start_x= Preview_CROP_START_X; - handle->video_res_supported.res[1].crop_start_y= Preview_CROP_START_Y; - handle->video_res_supported.res[1].nOutputWidth= 1920; - handle->video_res_supported.res[1].nOutputHeight= 1080; - sprintf(handle->video_res_supported.res[1].strResDesc, "1920x1080@30fps"); - - - handle->pCus_sensor_SetVideoRes = pCus_SetVideoRes_HDR_DOL; - handle->mclk = Preview_MCLK_SPEED_HDR_DOL; - - handle->pCus_sensor_init = pCus_init_mipi4lane_HDR_DOL; - handle->pCus_sensor_GetFPS = pCus_GetFPS_HDR_DOL_SEF; - handle->pCus_sensor_SetFPS = pCus_SetFPS_HDR_DOL_SEF; //TBD - - handle->pCus_sensor_AEStatusNotify = pCus_AEStatusNotifyHDR_DOL_SEF; - handle->pCus_sensor_GetAEUSecs = pCus_GetAEUSecs; - handle->pCus_sensor_SetAEUSecs = pCus_SetAEUSecsHDR_DOL_SEF; - handle->pCus_sensor_GetAEGain = pCus_GetAEGainHDR_DOL_SEF; - //handle->pCus_sensor_SetAEGain = pCus_SetAEGain; - handle->pCus_sensor_SetAEGain = pCus_SetAEGainHDR_DOL_SEF; - handle->pCus_sensor_GetShutterInfo = pCus_GetShutterInfo_hdr_dol_sef; - params->expo.vts = vts_30fps_HDR_DOL; - params->expo.fps = 15; - params->expo.max_short_exp = 130; - handle->data_prec = SENSOR_DATAPREC_HDR_DOL; - handle->interface_attr.attr_mipi.mipi_hdr_virtual_channel_num = 1; //Short frame - - handle->ae_gain_ctrl_num = 1; - handle->ae_shutter_ctrl_num = 2; - - return SUCCESS; -} - -int cus_camsensor_init_handle_hdr_dol_lef(ms_cus_sensor* drv_handle) -{ - ms_cus_sensor *handle = drv_handle; - sc8238_params *params; - if (!handle) { - SENSOR_DMSG("[%s] not enough memory!\n", __FUNCTION__); - return FAIL; - } - SENSOR_DMSG("[%s]", __FUNCTION__); - //private data allocation & init - if (handle->private_data == NULL) { - SENSOR_EMSG("[%s] Private data is empty!\n", __FUNCTION__); - return FAIL; - } - params = (sc8238_params *)handle->private_data; - - //////////////////////////////////// - // sensor model ID // - //////////////////////////////////// - sprintf(handle->model_id,"sc8238_MIPI_HDR_LEF"); - - //////////////////////////////////// - // sensor interface info // - //////////////////////////////////// - //SENSOR_DMSG("[%s] entering function with id %d\n", __FUNCTION__, id); - handle->isp_type = SENSOR_ISP_TYPE; //ISP_SOC; - //handle->data_fmt = SENSOR_DATAFMT; //CUS_DATAFMT_YUV; - handle->sif_bus = SENSOR_IFBUS_TYPE;//CUS_SENIF_BUS_PARL; - handle->data_prec = SENSOR_DATAPREC_HDR_DOL; //CUS_DATAPRECISION_8; - handle->data_mode = SENSOR_DATAMODE; - handle->bayer_id = SENSOR_BAYERID_HDR_DOL; //CUS_BAYER_GB; - handle->RGBIR_id = SENSOR_RGBIRID; - handle->orient = SENSOR_ORIT; //CUS_ORIT_M1F1; - //handle->YC_ODER = SENSOR_YCORDER; //CUS_SEN_YCODR_CY; - handle->interface_attr.attr_mipi.mipi_lane_num = SENSOR_MIPI_LANE_NUM; - handle->interface_attr.attr_mipi.mipi_data_format = CUS_SEN_INPUT_FORMAT_RGB; // RGB pattern. - handle->interface_attr.attr_mipi.mipi_yuv_order = 0; //don't care in RGB pattern. - handle->interface_attr.attr_mipi.mipi_hsync_mode = SENSOR_MIPI_HSYNC_MODE_HDR_DOL; - handle->interface_attr.attr_mipi.mipi_hdr_mode = CUS_HDR_MODE_DCG; - handle->interface_attr.attr_mipi.mipi_hdr_virtual_channel_num = 0; //Long frame - - //////////////////////////////////// - // resolution capability // - //////////////////////////////////// - handle->video_res_supported.num_res = 1; - handle->video_res_supported.ulcur_res = 0; //default resolution index is 0. - handle->video_res_supported.res[0].width = Preview_WIDTH; - handle->video_res_supported.res[0].height = Preview_HEIGHT; - handle->video_res_supported.res[0].max_fps= Preview_MAX_FPS; - handle->video_res_supported.res[0].min_fps= Preview_MIN_FPS; - handle->video_res_supported.res[0].crop_start_x= Preview_CROP_START_X; - handle->video_res_supported.res[0].crop_start_y= Preview_CROP_START_Y; - handle->video_res_supported.res[0].nOutputWidth= 3840; - handle->video_res_supported.res[0].nOutputHeight= 2160; - sprintf(handle->video_res_supported.res[0].strResDesc, "3840x2160@15fps"); - - handle->video_res_supported.num_res = 2; - handle->video_res_supported.ulcur_res = 0; //default resolution index is 0. - handle->video_res_supported.res[1].width = 1920; - handle->video_res_supported.res[1].height = 1080; - handle->video_res_supported.res[1].max_fps= 30; - handle->video_res_supported.res[1].min_fps= Preview_MIN_FPS; - handle->video_res_supported.res[1].crop_start_x= Preview_CROP_START_X; - handle->video_res_supported.res[1].crop_start_y= Preview_CROP_START_Y; - handle->video_res_supported.res[1].nOutputWidth= 1920; - handle->video_res_supported.res[1].nOutputHeight= 1080; - sprintf(handle->video_res_supported.res[1].strResDesc, "1920x1080@30fps"); - - - // i2c - handle->i2c_cfg.mode = SENSOR_I2C_LEGACY; //(CUS_ISP_I2C_MODE) FALSE; - handle->i2c_cfg.fmt = SENSOR_I2C_FMT; //CUS_I2C_FMT_A16D16; - handle->i2c_cfg.address = SENSOR_I2C_ADDR; //0x5a; - handle->i2c_cfg.speed = SENSOR_I2C_SPEED; //320000; - - // mclk - handle->mclk = Preview_MCLK_SPEED_HDR_DOL; - - //polarity - ///////////////////////////////////////////////////// - handle->pwdn_POLARITY = SENSOR_PWDN_POL; //CUS_CLK_POL_NEG; - handle->reset_POLARITY = SENSOR_RST_POL; //CUS_CLK_POL_NEG; - handle->VSYNC_POLARITY = SENSOR_VSYNC_POL; //CUS_CLK_POL_POS; - handle->HSYNC_POLARITY = SENSOR_HSYNC_POL; //CUS_CLK_POL_POS; - handle->PCLK_POLARITY = SENSOR_PCLK_POL; //CUS_CLK_POL_POS); // use '!' to clear board latch error - ///////////////////////////////////////////////////// - - - - //////////////////////////////////////////////////// - // AE parameters - //////////////////////////////////////////////////// - handle->ae_gain_delay = 2;//0;//1; - handle->ae_shutter_delay = 2;//1;//2; - - handle->ae_gain_ctrl_num = 1; - handle->ae_shutter_ctrl_num = 2; - - ///calibration - handle->sat_mingain=g_sensor_ae_min_gain; - - //LOGD("[%s:%d]\n", __FUNCTION__, __LINE__); - handle->pCus_sensor_release = cus_camsensor_release_handle; - handle->pCus_sensor_init = pCus_init_hdr_dol_lef; - //handle->pCus_sensor_powerupseq = pCus_powerupseq ; - handle->pCus_sensor_poweron = pCus_poweron_hdr_dol_lef; - handle->pCus_sensor_poweroff = pCus_poweroff_hdr_dol_lef; - handle->pCus_sensor_post_init = pCus_post_init; - - // Normal - handle->pCus_sensor_GetSensorID = pCus_GetSensorID_hdr_dol_lef; - handle->pCus_sensor_GetVideoResNum = pCus_GetVideoResNum; - handle->pCus_sensor_GetVideoRes = pCus_GetVideoRes; - handle->pCus_sensor_GetCurVideoRes = pCus_GetCurVideoRes; - handle->pCus_sensor_SetVideoRes = pCus_SetVideoRes_HDR_DOL; - handle->pCus_sensor_GetOrien = pCus_GetOrien; - handle->pCus_sensor_SetOrien = pCus_SetOrien_HDR; - handle->pCus_sensor_GetFPS = pCus_GetFPS_hdr_dol_lef; - handle->pCus_sensor_SetFPS = pCus_SetFPS_hdr_dol_lef; - //handle->pCus_sensor_GetSensorCap = pCus_GetSensorCap_hdr_dol_lef; - handle->pCus_sensor_SetPatternMode = sc8238_SetPatternMode; - /////////////////////////////////////////////////////// - // AE - /////////////////////////////////////////////////////// - // unit: micro seconds - handle->pCus_sensor_AEStatusNotify = pCus_AEStatusNotifyHDR_DOL_LEF; - handle->pCus_sensor_GetAEUSecs = pCus_GetAEUSecs; - handle->pCus_sensor_SetAEUSecs = pCus_SetAEUSecsHDR_DOL_LEF; - handle->pCus_sensor_GetAEGain = pCus_GetAEGain; - //handle->pCus_sensor_SetAEGain = pCus_SetAEGain_hdr_dol_lef; - handle->pCus_sensor_SetAEGain = pCus_SetAEGain; - - handle->pCus_sensor_GetAEMinMaxGain = pCus_GetAEMinMaxGain; - //handle->pCus_sensor_GetAEMinMaxUSecs= pCus_GetAEMinMaxUSecs_hdr_dol_lef; - - //sensor calibration - handle->pCus_sensor_SetAEGain_cal = pCus_SetAEGain_cal_hdr_dol_lef; - handle->pCus_sensor_setCaliData_gain_linearity= pCus_setCaliData_gain_linearity_hdr_dol_lef; - handle->pCus_sensor_GetShutterInfo = pCus_GetShutterInfo_hdr_dol_lef; - - params->expo.vts = vts_30fps_HDR_DOL; - params->expo.fps = 15; - params->reg_dirty = false; - - return SUCCESS; -} - -int cus_camsensor_release_handle(ms_cus_sensor *handle) -{ - return SUCCESS; -} - -SENSOR_DRV_ENTRY_IMPL_END_EX( SC8235_HDR, - cus_camsensor_init_handle_linear, - cus_camsensor_init_handle_hdr_dol_sef, - cus_camsensor_init_handle_hdr_dol_lef, - sc8238_params - ); - -