Initial commit: Linux kernel 4.19 for Unplugged OS

This commit is contained in:
ziv committed 2025-10-06 13:52:42 +00:00
commit d30235b04c
80519 files changed
+35800681

No files matched your search

+10
View File
@@ -0,0 +1,10 @@
config MTK_IMGSENSOR
bool CONFIG_MTK_IMGSENSOR
default n
help
Kernel space image sensor driver. Define project used all image
sensors .The value is combination of CUSTOM_KERNEL_MAIN_IMGSENSOR,
CUSTOM_KERNEL_MAIN_BACKUP_IMGSENSOR, CUSTOM_KERNEL_SUB_IMGSENSOR,
and CUSTOM_KERNEL_SUB_BACKUP_IMGSENSOR
source "drivers/misc/mediatek/imgsensor/src/Kconfig"
@@ -0,0 +1,60 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#ifndef _KD_CAMERA_FEATURE_H_
#define _KD_CAMERA_FEATURE_H_
#include "kd_camera_feature_id.h"
#include "kd_camera_feature_enum.h"
enum IMGSENSOR_SENSOR_IDX {
IMGSENSOR_SENSOR_IDX_MIN_NUM = 0,
IMGSENSOR_SENSOR_IDX_MAIN = IMGSENSOR_SENSOR_IDX_MIN_NUM,
IMGSENSOR_SENSOR_IDX_SUB,
IMGSENSOR_SENSOR_IDX_MAIN2,
IMGSENSOR_SENSOR_IDX_SUB2,
IMGSENSOR_SENSOR_IDX_MAIN3,
IMGSENSOR_SENSOR_IDX_SUB3,
IMGSENSOR_SENSOR_IDX_MAIN4,
IMGSENSOR_SENSOR_IDX_SUB4,
IMGSENSOR_SENSOR_IDX_MAIN5,
IMGSENSOR_SENSOR_IDX_SUB5,
IMGSENSOR_SENSOR_IDX_MAIN6,
IMGSENSOR_SENSOR_IDX_SUB6,
IMGSENSOR_SENSOR_IDX_MAX_NUM,
IMGSENSOR_SENSOR_IDX_NONE,
};
enum CAMERA_DUAL_CAMERA_SENSOR_ENUM {
DUAL_CAMERA_NONE_SENSOR = 0,
DUAL_CAMERA_MAIN_SENSOR = 1,
DUAL_CAMERA_SUB_SENSOR = 2,
DUAL_CAMERA_MAIN_2_SENSOR = 4,
DUAL_CAMERA_SUB_2_SENSOR = 8,
DUAL_CAMERA_MAIN_3_SENSOR = 16,
DUAL_CAMERA_SUB_3_SENSOR = 32,
DUAL_CAMERA_MAIN_4_SENSOR = 64,
DUAL_CAMERA_SUB_4_SENSOR = 128,
DUAL_CAMERA_MAIN_5_SENSOR = 256,
DUAL_CAMERA_SUB_5_SENSOR = 512,
DUAL_CAMERA_MAIN_6_SENSOR = 1024,
DUAL_CAMERA_SUB_6_SENSOR = 2048,
DUAL_CAMERA_SENSOR_MAX,
/* for backward compatible */
DUAL_CAMERA_MAIN_SECOND_SENSOR = DUAL_CAMERA_MAIN_2_SENSOR,
};
#define IMGSENSOR_SENSOR_DUAL2IDX(idx) ((ffs(idx) - 1))
#define IMGSENSOR_SENSOR_IDX2DUAL(idx) (1<<(idx))
#define IMGSENSOR_SENSOR_IDX_MAP(idx) \
(((idx) > DUAL_CAMERA_NONE_SENSOR && (idx) < DUAL_CAMERA_SENSOR_MAX) \
? (enum IMGSENSOR_SENSOR_IDX)IMGSENSOR_SENSOR_DUAL2IDX(idx) \
: IMGSENSOR_SENSOR_IDX_NONE)
#endif /* _KD_IMGSENSOR_DATA_H */
@@ -0,0 +1,411 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#ifndef _KD_CAMERA_FEATURE_ENUM_H_
#define _KD_CAMERA_FEATURE_ENUM_H_
enum SCENE_MODE_T {
SCENE_MODE_BEGIN = 0,
SCENE_MODE_OFF = SCENE_MODE_BEGIN,
SCENE_MODE_NORMAL,
SCENE_MODE_ACTION,
SCENE_MODE_PORTRAIT,
SCENE_MODE_LANDSCAPE,
SCENE_MODE_NIGHTSCENE,
SCENE_MODE_NIGHTPORTRAIT,
SCENE_MODE_THEATRE,
SCENE_MODE_BEACH,
SCENE_MODE_SNOW,
SCENE_MODE_SUNSET,
SCENE_MODE_STEADYPHOTO,
SCENE_MODE_FIREWORKS,
SCENE_MODE_SPORTS,
SCENE_MODE_PARTY,
SCENE_MODE_CANDLELIGHT,
SCENE_MODE_ISO_ANTI_SHAKE,
SCENE_MODE_BRACKET_AE,
SCENE_MODE_HDR,
SCENE_MODE_FACE_PRIORITY,
SCENE_MODE_BARCODE,
SCENE_MODE_NUM
};
enum MCOLOR_EFFECT {
MEFFECT_BEGIN = 0,
MEFFECT_OFF = MEFFECT_BEGIN,
MEFFECT_MONO,
MEFFECT_SEPIA,
MEFFECT_NEGATIVE,
MEFFECT_SOLARIZE,
MEFFECT_POSTERIZE,
MEFFECT_AQUA,
MEFFECT_BLACKBOARD,
MEFFFECT_BLACKBOARD = MEFFECT_BLACKBOARD,
MEFFECT_WHITEBOARD,
MEFFECT_SEPIAGREEN,
MEFFECT_SEPIABLUE,
MEFFECT_NASHVILLE,
MEFFECT_HEFE,
MEFFECT_VALENCIA,
MEFFECT_XPROII,
MEFFECT_LOFI,
MEFFECT_SIERRA,
MEFFECT_KELVIN,
MEFFECT_WALDEN,
MEFFECT_F1977,
MEFFECT_NUM
};
enum AWB_MODE_T {
AWB_MODE_BEGIN = 0,
AWB_MODE_OFF = AWB_MODE_BEGIN,
AWB_MODE_AUTO,
AWB_MODE_DAYLIGHT,
AWB_MODE_CLOUDY_DAYLIGHT,
AWB_MODE_SHADE,
AWB_MODE_TWILIGHT,
AWB_MODE_FLUORESCENT,
AWB_MODE_WARM_FLUORESCENT,
AWB_MODE_INCANDESCENT,
AWB_MODE_TUNGSTEN,
AWB_MODE_GRAYWORLD,
AWB_MODE_NUM
};
enum AE_FLICKER_MODE_T {
AE_FLICKER_MODE_BEGIN = 0,
AE_FLICKER_MODE_60HZ = AE_FLICKER_MODE_BEGIN,
AE_FLICKER_MODE_50HZ,
AE_FLICKER_MODE_AUTO,
AE_FLICKER_MODE_OFF,
AE_FLICKER_MODE_TOTAL_NUM
};
enum AE_EVCOMP_T {
AE_EV_COMP_BEGIN = 0,
AE_EV_COMP_00 = AE_EV_COMP_BEGIN,
AE_EV_COMP_03,
AE_EV_COMP_05,
AE_EV_COMP_07,
AE_EV_COMP_10,
AE_EV_COMP_13,
AE_EV_COMP_15,
AE_EV_COMP_17,
AE_EV_COMP_20,
AE_EV_COMP_23,
AE_EV_COMP_25,
AE_EV_COMP_27,
AE_EV_COMP_30,
AE_EV_COMP_n03,
AE_EV_COMP_n05,
AE_EV_COMP_n07,
AE_EV_COMP_n10,
AE_EV_COMP_n13,
AE_EV_COMP_n15,
AE_EV_COMP_n17,
AE_EV_COMP_n20,
AE_EV_COMP_n23,
AE_EV_COMP_n25,
AE_EV_COMP_n27,
AE_EV_COMP_n30,
AE_EV_COMP_TOTAL_NUM
};
enum AE_MODE_T {
AE_MODE_BEGIN = 0,
AE_MODE_OFF = AE_MODE_BEGIN,
AE_MODE_AUTO,
AE_MODE_PROGRAM,
AE_MODE_TV,
AE_MODE_AV,
AE_MODE_SV,
AE_MODE_VIDEO,
AE_MODE_NIGHT,
AE_MODE_ACTION,
AE_MODE_BEACH,
AE_MODE_CANDLELIGHT,
AE_MODE_FIREWORKS,
AE_MODE_LANDSCAPE,
AE_MODE_PORTRAIT,
AE_MODE_NIGHT_PORTRAIT,
AE_MODE_PARTY,
AE_MODE_SNOW,
AE_MODE_SPORTS,
AE_MODE_STEADYPHOTO,
AE_MODE_SUNSET,
AE_MODE_THEATRE,
AE_MODE_ISO_ANTI_SHAKE,
AE_MODE_BRACKET_AE,
AE_MODE_AUTO_PANORAMA,
AE_MODE_HDR,
AE_MODE_TOTAL_NUM
};
enum AE_METERING_T {
AE_METERING_BEGIN = 0,
AE_METERING_MODE_CENTER_WEIGHT = AE_METERING_BEGIN,
AE_METERING_MODE_SOPT,
AE_METERING_MODE_AVERAGE,
NUM_OF_AE_METER
};
enum AE_ISO_T {
AE_ISO_BEGIN = 0,
AE_ISO_AUTO = AE_ISO_BEGIN,
AE_ISO_100,
AE_ISO_200,
AE_ISO_400,
AE_ISO_800,
AE_ISO_1600,
NUM_OF_AE_ISO
};
enum AE_STROBE_T {
FLASHLIGHT_BEGIN = 0,
FLASHLIGHT_AUTO = FLASHLIGHT_BEGIN,
FLASHLIGHT_FORCE_ON,
FLASHLIGHT_FORCE_OFF,
FLASHLIGHT_REDEYE,
FLASHLIGHT_TORCH,
NUM_OF_FLASHLIGHT
};
enum AF_MODE_T {
AF_MODE_BEGIN = 0,
AF_MODE_AFS = AF_MODE_BEGIN,
AF_MODE_AFC,
AF_MODE_AFC_VIDEO,
AF_MODE_MACRO,
AF_MODE_INFINITY,
AF_MODE_MF,
AF_MODE_FULLSCAN,
NUM_OF_AF_MODE
};
enum _AF_METERING_T {
AF_METERING_BEGIN = 0,
AF_METER_SPOT = AF_METERING_BEGIN,
AF_METER_MATRIX,
AF_METER_MOVESPOT,
NUM_OF_AF_METER
};
enum ISP_EDGE_T {
ISP_EDGE_BEGIN = 0,
ISP_EDGE_LOW = ISP_EDGE_BEGIN,
ISP_EDGE_MIDDLE,
ISP_EDGE_HIGH,
NUM_OF_ISP_EDGE
};
enum ISP_HUE_T {
ISP_HUE_BEGIN = 0,
ISP_HUE_LOW = ISP_HUE_BEGIN,
ISP_HUE_MIDDLE,
ISP_HUE_HIGH,
NUM_OF_ISP_HUE
};
enum ISP_SAT_T {
ISP_SAT_BEGIN = 0,
ISP_SAT_LOW = ISP_SAT_BEGIN,
ISP_SAT_MIDDLE,
ISP_SAT_HIGH,
NUM_OF_ISP_SAT
};
enum ISP_BRIGHT_T {
ISP_BRIGHT_BEGIN = 0,
ISP_BRIGHT_LOW = ISP_BRIGHT_BEGIN,
ISP_BRIGHT_MIDDLE,
ISP_BRIGHT_HIGH,
NUM_OF_ISP_BRIGHT
};
enum ISP_CONTRAST_T {
ISP_CONTRAST_BEGIN = 0,
ISP_CONTRAST_LOW = ISP_CONTRAST_BEGIN,
ISP_CONTRAST_MIDDLE,
ISP_CONTRAST_HIGH,
NUM_OF_ISP_CONTRAST
};
enum CAPTURE_MODE_T {
CAPTURE_MODE_BEGIN = 0,
CAPTURE_MODE_NORMAL = CAPTURE_MODE_BEGIN,
CAPTURE_MODE_BURST_SHOT,
CAPTURE_MODE_SMILE_SHOT,
CAPTURE_MODE_PANORAMA,
CAPTURE_MODE_AUTORAMA,
CAPTURE_MODE_BEST_SHOT,
CAPTURE_MODE_EV_BRACKET,
CAPTURE_MODE_MAV,
CAPTURE_MODE_HDR,
CAPTURE_MODE_ASD,
CAPTURE_MODE_ZSD,
CAPTURE_MODE_PANO_3D,
CAPTURE_MODE_SINGLE_3D,
CAPTURE_MODE_FACE_BEAUTY,
CAPTURE_MODE_CONTINUOUS_SHOT,
CAPTURE_MODE_MULTI_MOTION,
NUM_OF_CAPTURE_MODE
};
enum CAPTURE_SIZE_T {
CAPTURE_SIZE_BEGIN = 0,
CAPTURE_SIZE_320_240 = CAPTURE_SIZE_BEGIN,
CAPTURE_SIZE_640_480,
CAPTURE_SIZE_1024_768,
CAPTURE_SIZE_1280_960,
CAPTURE_SIZE_1600_1200,
CAPTURE_SIZE_2048_1536,
CAPTURE_SIZE_2560_1920,
CAPTURE_SIZE_3264_2448,
CAPTURE_SIZE_4000_3000,
NUM_OF_CAPTURE_SIZE
};
enum PREVIEW_SIZE_T {
PREVIEW_SIZE_BEGIN = 0,
PREVIEW_SIZE_160_120 = PREVIEW_SIZE_BEGIN,
PREVIEW_SIZE_176_144,
PREVIEW_SIZE_320_240,
PREVIEW_SIZE_352_288,
PREVIEW_SIZE_480_320,
PREVIEW_SIZE_480_368,
PREVIEW_SIZE_640_480,
PREVIEW_SIZE_720_480,
PREVIEW_SIZE_800_480,
PREVIEW_SIZE_864_480,
PREVIEW_SIZE_800_600,
PREVIEW_SIZE_1280_720,
PREVIEW_SIZE_1920_1080,
NUM_OF_PREVIEW_SIZE
};
enum VIDEO_PREVIEW_SIZE_T {
VIDEO_PREVIEW_SIZE_BEGIN = 0,
VIDEO_PREVIEW_SIZE_640_480 = VIDEO_PREVIEW_SIZE_BEGIN,
VIDEO_PREVIEW_SIZE_800_600,
NUM_OF_VIDEO_PREVIEW_SIZE
};
enum FRAME_RATE_T {
FRAME_RATE_BEGIN = 0,
FRAME_RATE_000FPS = FRAME_RATE_BEGIN,
FRAME_RATE_010FPS,
FRAME_RATE_020FPS,
FRAME_RATE_030FPS,
FRAME_RATE_040FPS,
FRAME_RATE_050FPS,
FRAME_RATE_060FPS,
FRAME_RATE_070FPS,
FRAME_RATE_075FPS = FRAME_RATE_070FPS,
FRAME_RATE_080FPS,
FRAME_RATE_090FPS,
FRAME_RATE_100FPS,
FRAME_RATE_110FPS,
FRAME_RATE_120FPS,
FRAME_RATE_125FPS = FRAME_RATE_120FPS,
FRAME_RATE_130FPS,
FRAME_RATE_140FPS,
FRAME_RATE_150FPS,
FRAME_RATE_160FPS,
FRAME_RATE_170FPS,
FRAME_RATE_180FPS,
FRAME_RATE_190FPS,
FRAME_RATE_200FPS,
FRAME_RATE_210FPS,
FRAME_RATE_220FPS,
FRAME_RATE_230FPS,
FRAME_RATE_240FPS,
FRAME_RATE_250FPS,
FRAME_RATE_260FPS,
FRAME_RATE_270FPS,
FRAME_RATE_280FPS,
FRAME_RATE_290FPS,
FRAME_RATE_300FPS,
NUM_OF_FRAME_RATE
};
enum FRAME_RATE_RANGE_T {
FRAME_RATE_RANGE_BEGIN = 0,
FRAME_RATE_RANGE_5_30_FPS = FRAME_RATE_RANGE_BEGIN,
NUM_OF_FRAME_RATE_RANGE
};
enum FOCUS_DIST_NORMAL_T {
FOCUS_DIST_N_BEGIN = 0,
FOCUS_DIST_N_INFINITE = FOCUS_DIST_N_BEGIN,
FOCUS_DIST_N_10CM,
NUM_OF_FOCUS_DIST_N
};
enum FOCUS_DIST_MACRO_T {
FOCUS_DIST_M_BEGIN = 0,
FOCUS_DIST_M_INFINITE = FOCUS_DIST_M_BEGIN,
FOCUS_DIST_M_5CM,
FOCUS_DIST_M_10CM,
NUM_OF_FOCUS_DIST_M
};
enum FD_MODE_T {
FD_BEGIN = 0,
FD_OFF = FD_BEGIN,
FD_ON,
NUM_OF_FD
};
enum EIS_T {
EIS_BEGIN = 0,
EIS_OFF = EIS_BEGIN,
EIS_ON,
NUM_OF_EIS
};
enum ZSD_T {
ZSD_BEGIN = 0,
ZSD_OFF = ZSD_BEGIN,
ZSD_ON,
NUM_OF_ZSD
};
enum AF_LAMP_T {
AF_LAMP_BEGIN = 0,
AF_LAMP_OFF = AF_LAMP_BEGIN,
AF_LAMP_ON,
AF_LAMP_AUTO,
AF_LAMP_FLASH,
NUM_OF_AF_LAMP
};
enum STEREO_3D_CAPTURE_SIZE_T {
STEREO_3D_CAPTURE_SIZE_BEGIN = 0,
STEREO_3D_CAPTURE_SIZE_2560_720 = STEREO_3D_CAPTURE_SIZE_BEGIN,
STEREO_3D_CAPTURE_SIZE_3840_1080,
NUM_OF_STEREO_3D_CAPTURE_SIZE
};
enum STEREO_3D_PREVIEW_SIZE_T {
STEREO_3D_PREVIEW_SIZE_BEGIN = 0,
STEREO_3D_PREVIEW_SIZE_640_360 = STEREO_3D_PREVIEW_SIZE_BEGIN,
STEREO_3D_PREVIEW_SIZE_854_480,
STEREO_3D_PREVIEW_SIZE_960_540,
STEREO_3D_PREVIEW_SIZE_1280_720,
NUM_OF_STEREO_3D_PREVIEW_SIZE
};
enum STEREO_3D_TYPE_T {
STEREO_3D_TYPE_BEGIN = 0,
STEREO_3D_NOT_SUPPORT = STEREO_3D_TYPE_BEGIN,
STEREO_3D_FRAME_SEQ,
STEREO_3D_SIDE_BY_SIDE,
STEREO_3D_TOP_BOTTOM,
NUM_OF_STEREO_3D_TYPE
};
enum STEREO_3D_MODE_T {
STEREO_3D_MODE_BEGIN = 0,
STEREO_3D_OFF = STEREO_3D_MODE_BEGIN,
STEREO_3D_ON,
NUM_OF_STEREO_3D_MODE
};
enum STEREO_3D_IMAGE_FORMAT_T {
STEREO_3D_IMAGE_FORMAT_BEGIN = 0,
STEREO_3D_JPS = STEREO_3D_IMAGE_FORMAT_BEGIN,
STEREO_3D_MPO,
NUM_OF_STEREO_3D_IMAGE_FORMAT
};
enum YUV_AUTOTEST_T {
YUV_AUTOTEST_BEGIN = 0,
YUV_AUTOTEST_SET_SHADDING = YUV_AUTOTEST_BEGIN,
YUV_AUTOTEST_SET_GAMMA,
YUV_AUTOTEST_SET_AE,
YUV_AUTOTEST_SET_SHUTTER,
YUV_AUTOTEST_SET_GAIN,
YUV_AUTOTEST_GET_SHUTTER_RANGE,
YUV_AUTOTEST_GET_SHADDING,
YUV_AUTOTEST_GET_GAMMA,
YUV_AUTOTEST_GET_AE,
YUV_AUTOTEST_GET_SHUTTER,
YUV_AUTOTEST_GET_GAIN,
NUM_OF_YUV_AUTOTEST
};
enum SEAMLESS_SWITCH_FLAG {
IMAGE_SETTING_NONE = 0x0,
IMAGE_FULL_BIN,
IMAGE_FULL_SIZE,
IMAGE_ZOOM_IN_1_3X,
IMAGE_ZOOM_IN_2X,
};
#endif
@@ -0,0 +1,69 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#ifndef _KD_CAMERA_FEATURE_ID_H_
#define _KD_CAMERA_FEATURE_ID_H_
enum FEATURE_ID {
FID_PRE_BEGIN = 0,
FID_PRE_BEGIN_SI = FID_PRE_BEGIN,
FID_PRE_BEGIN_MISC_SI = FID_PRE_BEGIN_SI,
FID_ZOOM_FACTOR,
FID_AE_STROBE,
FID_EIS,
FID_ZSD,
FID_AWB2PASS,
FID_AF_LAMP,
FID_FAST_CONTINUOUS_SHOT,
FID_OVER_LAST_MISC_SI,
FID_PRE_BEGIN_RAW_ONLY_SI = FID_OVER_LAST_MISC_SI - 1,
FID_OVER_LAST_RAW_ONLY_SI,
FID_PRE_BEGIN_RAW_YUV_SI = FID_OVER_LAST_RAW_ONLY_SI - 1,
FID_SCENE_MODE,
FID_COLOR_EFFECT,
FID_CAPTURE_MODE,
FID_CAP_SIZE,
FID_PREVIEW_SIZE,
FID_VIDEO_PREVIEW_SIZE,
FID_FRAME_RATE,
FID_FRAME_RATE_RANGE,
FID_AE_FLICKER,
FID_FOCUS_DIST_NORMAL,
FID_FOCUS_DIST_MACRO,
FID_STEREO_3D_CAP_SIZE,
FID_STEREO_3D_PREVIEW_SIZE,
FID_STEREO_3D_TYPE,
FID_STEREO_3D_MODE,
FID_STEREO_3D_IMAGE_FORMAT,
FID_OVER_LAST_RAW_YUV_SI,
FID_PRE_BEGIN_YUV_ONLY_SI = FID_OVER_LAST_RAW_YUV_SI - 1,
FID_OVER_LAST_YUV_ONLY_SI,
FID_OVER_LAST_SI = FID_OVER_LAST_YUV_ONLY_SI,
FID_PRE_BEGIN_SD = FID_OVER_LAST_SI - 1,
FID_PRE_BEGIN_MISC_SD = FID_PRE_BEGIN_SD,
FID_FD_ON_OFF,
FID_OVER_LAST_MISC_SD,
FID_PRE_BEGIN_RAW_ONLY_SD = FID_OVER_LAST_MISC_SD - 1,
FID_OVER_LAST_RAW_ONLY_SD,
FID_PRE_BEGIN_RAW_YUV_SD = FID_OVER_LAST_RAW_ONLY_SD - 1,
FID_AE_SCENE_MODE,
FID_AE_METERING,
FID_AE_ISO,
FID_AE_EV,
FID_AF_MODE,
FID_AF_METERING,
FID_AWB_MODE,
FID_ISP_EDGE,
FID_ISP_HUE,
FID_ISP_SAT,
FID_ISP_BRIGHT,
FID_ISP_CONTRAST,
FID_OVER_LAST_RAW_YUV_SD,
FID_PRE_BEGIN_YUV_ONLY_SD = FID_OVER_LAST_RAW_YUV_SD - 1,
FID_YUV_AUTOTEST,
FID_OVER_LAST_YUV_ONLY_SD,
FID_OVER_LAST_SD = FID_OVER_LAST_YUV_ONLY_SD,
FID_OVER_LAST = FID_OVER_LAST_SD
};
#endif
@@ -0,0 +1,61 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#ifndef _CAMERA_TYPEDEFS_H
#define _CAMERA_TYPEDEFS_H
/* ------------------------*/
/* Basic Type Definitions */
/* -----------------------*/
#define kal_int8 signed char
#define kal_int16 signed short
#define kal_int32 signed int
#define kal_uint8 unsigned char
#define kal_uint16 unsigned short
#define kal_uint32 unsigned int
#define UINT8 unsigned char
#define UINT16 unsigned short
#define UINT32 unsigned int
#define INT8 signed char
#define INT32 signed int
#define BYTE unsigned char
/* -----------*/
/* Constants */
/* ----------*/
#ifndef FALSE
#define FALSE (0)
#endif
#ifndef TRUE
#define TRUE (1)
#endif
#ifndef NULL
#define NULL (0)
#endif
/* enum boolean {false, true}; */
enum { RX, TX, NONE };
#ifndef BOOL
#define BOOL unsigned char
#endif
#define kal_bool bool
#define KAL_FALSE 0
#define KAL_TRUE 1
#endif /* _CAMERA_TYPEDEFS_H */
@@ -0,0 +1,627 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#ifndef _KD_IMGSENSOR_H
#define _KD_IMGSENSOR_H
#include <linux/ioctl.h>
#ifndef ASSERT
#define ASSERT(expr) WARN_ON(!(expr))
#endif
#define IMGSENSORMAGIC 'i'
/* IOCTRL(inode * ,file * ,cmd ,arg ) */
/* S means "set through a ptr" */
/* T means "tell by a arg value" */
/* G means "get by a ptr" */
/* Q means "get by return a value" */
/* X means "switch G and S atomically" */
/* H means "switch T and Q atomically" */
/******************************************************************************
*
******************************************************************************/
/* sensorOpen */
#define KDIMGSENSORIOC_T_OPEN \
_IO(IMGSENSORMAGIC, 0)
/* sensorGetInfo */
#define KDIMGSENSORIOC_X_GET_CONFIG_INFO \
_IOWR(IMGSENSORMAGIC, 5, struct IMGSENSOR_GET_CONFIG_INFO_STRUCT)
#define KDIMGSENSORIOC_X_GETINFO \
_IOWR(IMGSENSORMAGIC, 5, struct ACDK_SENSOR_GETINFO_STRUCT)
/* sensorGetResolution */
#define KDIMGSENSORIOC_X_GETRESOLUTION \
_IOWR(IMGSENSORMAGIC, 10, struct ACDK_SENSOR_RESOLUTION_INFO_STRUCT)
/* For kernel 64-bit */
#define KDIMGSENSORIOC_X_GETRESOLUTION2 \
_IOWR(IMGSENSORMAGIC, 10, struct ACDK_SENSOR_PRESOLUTION_STRUCT)
/* sensorFeatureControl */
#define KDIMGSENSORIOC_X_FEATURECONCTROL \
_IOWR(IMGSENSORMAGIC, 15, struct ACDK_SENSOR_FEATURECONTROL_STRUCT)
/* sensorControl */
#define KDIMGSENSORIOC_X_CONTROL \
_IOWR(IMGSENSORMAGIC, 20, struct ACDK_SENSOR_CONTROL_STRUCT)
/* sensorClose */
#define KDIMGSENSORIOC_T_CLOSE \
_IO(IMGSENSORMAGIC, 25)
/* sensorSearch */
#define KDIMGSENSORIOC_T_CHECK_IS_ALIVE \
_IO(IMGSENSORMAGIC, 30)
/* set sensor driver */
#define KDIMGSENSORIOC_X_SET_DRIVER \
_IOWR(IMGSENSORMAGIC, 35, struct SENSOR_DRIVER_INDEX_STRUCT)
/* get socket postion */
#define KDIMGSENSORIOC_X_GET_SOCKET_POS \
_IOWR(IMGSENSORMAGIC, 40, u32)
/* set I2C bus */
#define KDIMGSENSORIOC_X_SET_I2CBUS \
_IOWR(IMGSENSORMAGIC, 45, u32)
/* set I2C bus */
#define KDIMGSENSORIOC_X_RELEASE_I2C_TRIGGER_LOCK \
_IO(IMGSENSORMAGIC, 50)
/* Set Shutter Gain Wait Done */
#define KDIMGSENSORIOC_X_SET_SHUTTER_GAIN_WAIT_DONE \
_IOWR(IMGSENSORMAGIC, 55, u32)
/* set mclk */
#define KDIMGSENSORIOC_X_SET_MCLK_PLL \
_IOWR(IMGSENSORMAGIC, 60, struct ACDK_SENSOR_MCLK_STRUCT)
#define KDIMGSENSORIOC_X_GETINFO2 \
_IOWR(IMGSENSORMAGIC, 65, struct IMAGESENSOR_GETINFO_STRUCT)
/* set open/close sensor index */
#define KDIMGSENSORIOC_X_SET_CURRENT_SENSOR \
_IOWR(IMGSENSORMAGIC, 70, u32)
/* set GPIO */
#define KDIMGSENSORIOC_X_SET_GPIO \
_IOWR(IMGSENSORMAGIC, 75, struct IMGSENSOR_GPIO_STRUCT)
/* Get ISP CLK */
#define KDIMGSENSORIOC_X_GET_ISP_CLK \
_IOWR(IMGSENSORMAGIC, 80, u32)
/* Get CSI CLK */
#define KDIMGSENSORIOC_X_GET_CSI_CLK \
_IOWR(IMGSENSORMAGIC, 85, u32)
/* Get ISP CLK via MMDVFS*/
#define KDIMGSENSORIOC_DFS_UPDATE \
_IOWR(IMGSENSORMAGIC, 90, unsigned int)
#define KDIMGSENSORIOC_GET_SUPPORTED_ISP_CLOCKS \
_IOWR(IMGSENSORMAGIC, 95, struct IMAGESENSOR_GET_SUPPORTED_ISP_CLK)
#define KDIMGSENSORIOC_GET_CUR_ISP_CLOCK \
_IOWR(IMGSENSORMAGIC, 100, unsigned int)
#ifdef CONFIG_COMPAT
#define COMPAT_KDIMGSENSORIOC_X_GET_CONFIG_INFO \
_IOWR(IMGSENSORMAGIC, 5, struct COMPAT_IMGSENSOR_GET_CONFIG_INFO_STRUCT)
#define COMPAT_KDIMGSENSORIOC_X_GETINFO \
_IOWR(IMGSENSORMAGIC, 5, struct COMPAT_ACDK_SENSOR_GETINFO_STRUCT)
#define COMPAT_KDIMGSENSORIOC_X_FEATURECONCTROL \
_IOWR(IMGSENSORMAGIC, 15, \
struct COMPAT_ACDK_SENSOR_FEATURECONTROL_STRUCT)
#define COMPAT_KDIMGSENSORIOC_X_CONTROL \
_IOWR(IMGSENSORMAGIC, 20, struct COMPAT_ACDK_SENSOR_CONTROL_STRUCT)
#define COMPAT_KDIMGSENSORIOC_X_GETINFO2 \
_IOWR(IMGSENSORMAGIC, 65, struct COMPAT_IMAGESENSOR_GETINFO_STRUCT)
#define COMPAT_KDIMGSENSORIOC_X_GETRESOLUTION2 \
_IOWR(IMGSENSORMAGIC, 10, struct COMPAT_ACDK_SENSOR_PRESOLUTION_STRUCT)
#endif
/************************************************************************
*
************************************************************************/
#define HI1339_SENSOR_ID 0x1339
#define SENSOR_DRVNAME_HI1339_MIPI_RAW "hi1339_mipi_raw"
#define HI1339OFILM_SENSOR_ID 0x133A
#define SENSOR_DRVNAME_HI1339OFILM_MIPI_RAW "hi1339ofilm_mipi_raw"
/* Onyx */
#define OV13B10LN_SENSOR_ID 0x0D42
#define SENSOR_DRVNAME_OV13B10LN_MIPI_RAW "ov13b10ln_mipi_raw"
#define S5K4H7LN_SENSOR_ID 0x487B
#define SENSOR_DRVNAME_S5K4H7LN_MIPI_RAW "s5k4h7ln_mipi_raw"
#define GC08A3REAR_SENSOR_ID 0x08a3
#define SENSOR_DRVNAME_GC08A3REAR_MIPI_RAW "gc08a3rear_mipi_raw"
#define S5K4H7_SENSOR_ID 0x487B
#define SENSOR_DRVNAME_S5K4H7_MIPI_RAW "s5k4h7_mipi_raw"
#define S5K4H7SUB_SENSOR_ID 0x487C
#define SENSOR_DRVNAME_S5K4H7SUB_MIPI_RAW "s5k4h7sub_mipi_raw"
/* SENSOR CHIP VERSION */
/*IMX*/
#define IMX766_SENSOR_ID 0x0766
#define IMX499_SENSOR_ID 0x0499
#define IMX481_SENSOR_ID 0x0481
#define IMX486_SENSOR_ID 0x0486
#define IMX586_SENSOR_ID 0x0586
#define IMX519_SENSOR_ID 0x0519
#define IMX576_SENSOR_ID 0x0576
#define IMX350_SENSOR_ID 0x0350
#define IMX398_SENSOR_ID 0x0398
#define IMX268_SENSOR_ID 0x0268
#define IMX386_SENSOR_ID 0x0386
#define IMX300_SENSOR_ID 0x0300
#define IMX386_MONO_SENSOR_ID 0x0286
#define IMX362_SENSOR_ID 0x0362
#define IMX338_SENSOR_ID 0x0338
#define IMX376_SENSOR_ID 0x0376
#define IMX318_SENSOR_ID 0x0318
#define IMX319_SENSOR_ID 0x0319
#define IMX377_SENSOR_ID 0x0377
#define IMX278_SENSOR_ID 0x0278
#define IMX258_SENSOR_ID 0x0258
#define IMX258_MONO_SENSOR_ID 0x0259
#define IMX230_SENSOR_ID 0x0230
#define IMX220_SENSOR_ID 0x0220
#define IMX219_SENSOR_ID 0x0219
#define IMX214_SENSOR_ID 0x0214
#define IMX214_MONO_SENSOR_ID 0x0215
#define IMX179_SENSOR_ID 0x0179
#define IMX178_SENSOR_ID 0x0178
#define IMX135_SENSOR_ID 0x0135
#define IMX132MIPI_SENSOR_ID 0x0132
#define IMX119_SENSOR_ID 0x0119
#define IMX105_SENSOR_ID 0x0105
#define IMX091_SENSOR_ID 0x0091
#define IMX073_SENSOR_ID 0x0046
#define IMX058_SENSOR_ID 0x0058
/*OV*/
#define OV23850_SENSOR_ID 0x023850
#define OV16880_SENSOR_ID 0x016880
#define OV16825MIPI_SENSOR_ID 0x016820
#define OV13855_SENSOR_ID 0xD855
#define OV13850_SENSOR_ID 0xD850
#define OV12A10_SENSOR_ID 0x1241
#define OV13870_SENSOR_ID 0x013870
#define OV13850_SENSOR_ID 0xD850
#define OV13855_SENSOR_ID 0xD855
#define OV16885_SENSOR_ID 0x16885
#define OV13855MAIN2_SENSOR_ID 0xD856
#define OV12830_SENSOR_ID 0xC830
#define OV9760MIPI_SENSOR_ID 0x9760
#define OV9740MIPI_SENSOR_ID 0x9740
#define OV9726_SENSOR_ID 0x9726
#define OV9726MIPI_SENSOR_ID 0x9726
#define OV8865_SENSOR_ID 0x8865
#define OV8858_SENSOR_ID 0x8858
#define OV8858S_SENSOR_ID (0x8858+1)
#define OV8856_SENSOR_ID 0x885A
#define OV8830_SENSOR_ID 0x8830
#define OV8825_SENSOR_ID 0x8825
#define OV7675_SENSOR_ID 0x7673
#define OV5693_SENSOR_ID 0x5690
#define OV5670MIPI_SENSOR_ID 0x5670
#define OV5670MIPI_SENSOR_ID_2 (0x5670+010000)
#define OV2281MIPI_SENSOR_ID 0x5670
#define OV5675MIPI_SENSOR_ID 0x5675
#define OV5671MIPI_SENSOR_ID 0x5671
#define OV5650_SENSOR_ID 0x5651
#define OV5650MIPI_SENSOR_ID 0x5651
#define OV5648MIPI_SENSOR_ID 0x5648
#define OV5647_SENSOR_ID 0x5647
#define OV5647MIPI_SENSOR_ID 0x5647
#define OV5645MIPI_SENSOR_ID 0x5645
#define OV5642_SENSOR_ID 0x5642
#define OV4688MIPI_SENSOR_ID 0x4688
#define OV3640_SENSOR_ID 0x364C
#define OV2724MIPI_SENSOR_ID 0x2724
#define OV2722MIPI_SENSOR_ID 0x2722
#define OV2680MIPI_SENSOR_ID 0x2680
#define OV2680_SENSOR_ID 0x2680
#define OV2659_SENSOR_ID 0x2656
#define OV2655_SENSOR_ID 0x2656
#define OV2650_SENSOR_ID 0x2652
#define OV2650_SENSOR_ID_1 0x2651
#define OV2650_SENSOR_ID_2 0x2652
#define OV2650_SENSOR_ID_3 0x2655
#define OV20880MIPI_SENSOR_ID 0x20880
#define OV05A20_SENSOR_ID 0x5305
/*S5K*/
#define S5KJD1_SENSOR_ID 0x3841
#define S5K2LQSX_SENSOR_ID 0x2c1a
#define S5K4H7_SENSOR_ID 0x487B
#define S5K4H7YXSUB_SENSOR_ID 0x487A
#define S5K3P8SP_SENSOR_ID 0x3108
#define S5K2T7SP_SENSOR_ID 0x2147
#define S5K3P8SX_SENSOR_ID 0x3108
#define S5K2L7_SENSOR_ID 0x20C7
#define S5K3L6_SENSOR_ID 0x30C6
#define S5K3L8_SENSOR_ID 0x30C8
#define S5K3M3_SENSOR_ID 0x30D3
#define S5K3M5SX_SENSOR_ID 0x30D5
#define S5K2X8_SENSOR_ID 0x2188
#define S5K2P7_SENSOR_ID 0x2107
#define S5K2P8_SENSOR_ID 0x2108
#define S5K3P3_SENSOR_ID 0x3103
#define S5K3P3SX_SENSOR_ID 0x3103
#define S5K3P8_SENSOR_ID 0x3108
#define S5K3P8STECH_SENSOR_ID 0xf3108
#define S5K3M2_SENSOR_ID 0x30D2
#define S5K4E6_SENSOR_ID 0x4e60
#define S5K3AAEA_SENSOR_ID 0x07AC
#define S5K3BAFB_SENSOR_ID 0x7070
#define S5K3H7Y_SENSOR_ID 0x3087
#define S5K3H2YX_SENSOR_ID 0x382b
#define S5KA3DFX_SENSOR_ID 0x00AB
#define S5K3E2FX_SENSOR_ID 0x3E2F
#define S5K4B2FX_SENSOR_ID 0x5080
#define S5K4E1GA_SENSOR_ID 0x4E10
#define S5K4ECGX_SENSOR_ID 0x4EC0
#define S5K53BEX_SENSOR_ID 0x45A8
#define S5K53BEB_SENSOR_ID 0x87A8
#define S5K5BAFX_SENSOR_ID 0x05BA
#define S5K5E2YA_SENSOR_ID 0x5e20
#define S5K4H5YX_2LANE_SENSOR_ID 0x485B
#define S5K4H5YC_SENSOR_ID 0x485B
#define S5K83AFX_SENSOR_ID 0x01C4
#define S5K5CAGX_SENSOR_ID 0x05ca
#define S5K8AAYX_MIPI_SENSOR_ID 0x08aa
#define S5K8AAYX_SENSOR_ID 0x08aa
#define S5K5E8YX_SENSOR_ID 0x5e80
#define S5K5E8YXREAR2_SENSOR_ID 0x5e81
#define S5K5E9_SENSOR_ID 0x559b
#define S5KHM2SP_SENSOR_ID 0x1AD2
#define S5KJN1_SENSOR_ID 0x38E1
/*HI*/
#define HI841_SENSOR_ID 0x0841
#define HI707_SENSOR_ID 0x00b8
#define HI704_SENSOR_ID 0x0096
#define HI556_SENSOR_ID 0x0556
#define HI551_SENSOR_ID 0x0551
#define HI553_SENSOR_ID 0x0553
#define HI545MIPI_SENSOR_ID 0x0545
#define HI544MIPI_SENSOR_ID 0x0544
#define HI542_SENSOR_ID 0x00B1
#define HI542MIPI_SENSOR_ID 0x00B1
#define HI253_SENSOR_ID 0x0092
#define HI251_SENSOR_ID 0x0084
#define HI191MIPI_SENSOR_ID 0x0191
#define HIVICF_SENSOR_ID 0x0081
/*MT*/
#define MT9D011_SENSOR_ID 0x1511
#define MT9D111_SENSOR_ID 0x1511
#define MT9D112_SENSOR_ID 0x1580
#define MT9M011_SENSOR_ID 0x1433
#define MT9M111_SENSOR_ID 0x143A
#define MT9M112_SENSOR_ID 0x148C
#define MT9M113_SENSOR_ID 0x2480
#define MT9P012_SENSOR_ID 0x2800
#define MT9P012_SENSOR_ID_REV7 0x2801
#define MT9T012_SENSOR_ID 0x1600
#define MT9T013_SENSOR_ID 0x2600
#define MT9T113_SENSOR_ID 0x4680
#define MT9V112_SENSOR_ID 0x1229
#define MT9DX11_SENSOR_ID 0x1519
#define MT9D113_SENSOR_ID 0x2580
#define MT9D115_SENSOR_ID 0x2580
#define MT9D115MIPI_SENSOR_ID 0x2580
#define MT9V113_SENSOR_ID 0x2280
#define MT9V114_SENSOR_ID 0x2283
#define MT9V115_SENSOR_ID 0x2284
#define MT9P015_SENSOR_ID 0x2803
#define MT9P017_SENSOR_ID 0x4800
#define MT9P017MIPI_SENSOR_ID 0x4800
#define MT9T113MIPI_SENSOR_ID 0x4680
/*GC*/
#define GC5035_SENSOR_ID 0x5035
#define GC2375_SENSOR_ID 0x2375
#define GC2375H_SENSOR_ID 0x2375
#define GC2375SUB_SENSOR_ID 0x2376
#define GC2365_SENSOR_ID 0x2365
#define GC2366_SENSOR_ID 0x2366
#define GC2355_SENSOR_ID 0x2355
#define GC2235_SENSOR_ID 0x2235
#define GC2035_SENSOR_ID 0x2035
#define GC2145_SENSOR_ID 0x2145
#define GC0330_SENSOR_ID 0xC1
#define GC0329_SENSOR_ID 0xC0
#define GC0310_SENSOR_ID 0xa310
#define GC0313MIPI_YUV_SENSOR_ID 0xD0
#define GC0312_SENSOR_ID 0xb310
#define GC8034_SENSOR_ID 0x8044
#define GC8C34_SENSOR_ID 0x80C4
#define GC08A3_SENSOR_ID 0x08a3
/*SP*/
#define SP0A19_YUV_SENSOR_ID 0xA6
#define SP2518_YUV_SENSOR_ID 0x53
#define SP2509_SENSOR_ID 0x2509
#define SP250A_SENSOR_ID 0x250A
/*A*/
#define A5141MIPI_SENSOR_ID 0x4800
#define A5142MIPI_SENSOR_ID 0x4800
/*HM*/
#define HM3451_SENSOR_ID 0x345
/*AR*/
#define AR0833_SENSOR_ID 0x4B03
/*SIV*/
#define SID020A_SENSOR_ID 0x12B4
#define SIV100B_SENSOR_ID 0x0C11
#define SIV100A_SENSOR_ID 0x0C10
#define SIV120A_SENSOR_ID 0x1210
#define SIV120B_SENSOR_ID 0x0012
#define SIV121D_SENSOR_ID 0xDE
#define SIM101B_SENSOR_ID 0x09A0
#define SIM120C_SENSOR_ID 0x0012
#define SID130B_SENSOR_ID 0x001b
#define SIC110A_SENSOR_ID 0x000D
#define SIV120B_SENSOR_ID 0x0012
/*PAS (PixArt Image)*/
#define PAS105_SENSOR_ID 0x0065
#define PAS302_SENSOR_ID 0x0064
#define PAS5101_SENSOR_ID 0x0067
#define PAS6180_SENSOR_ID 0x6179
/*Panasoic*/
#define MN34152_SENSOR_ID 0x01
/*Toshiba*/
#define T4KA7_SENSOR_ID 0x2c30
/*Others*/
#define SHARP3D_SENSOR_ID 0x003d
#define T8EV5_SENSOR_ID 0x1011
#define S5KGD1SP_SENSOR_ID 0x0841
#define HI846_SENSOR_ID 0x0846
#define OV02A10_MONO_SENSOR_ID 0x2509
#define IMX686_SENSOR_ID 0X0686
#define IMX616_SENSOR_ID 0x0616
#define OV48C_SENSOR_ID 0x564843
#define IMX355_SENSOR_ID 0x0355
#define OV13B10_SENSOR_ID 0x560d42
#define OV02B10_SENSOR_ID 0x002b
#define OV48B_SENSOR_ID 0x564842
#define S5K3P9SP_SENSOR_ID 0x3109
#define GC8054_SENSOR_ID 0x8054
#define GC02M0_SENSOR_ID 0x02d0
#define GC02M0_SENSOR_ID1 0x02d1
#define GC02M0_SENSOR_ID2 0x02d2
#define GC02K0_SENSOR_ID 0x2385
#define OV16A10_SENSOR_ID 0x561641
#define GC02M1B_SENSOR_ID 0x02e0
/* CAMERA DRIVER NAME */
#define CAMERA_HW_DEVNAME "kd_camera_hw"
/* SENSOR DEVICE DRIVER NAME */
/*IMX*/
#define SENSOR_DRVNAME_IMX499_MIPI_RAW "imx499_mipi_raw"
#define SENSOR_DRVNAME_IMX499_MIPI_RAW_13M "imx499_mipi_raw_13m"
#define SENSOR_DRVNAME_IMX481_MIPI_RAW "imx481_mipi_raw"
#define SENSOR_DRVNAME_IMX486_MIPI_RAW "imx486_mipi_raw"
#define SENSOR_DRVNAME_IMX586_MIPI_RAW "imx586_mipi_raw"
#define SENSOR_DRVNAME_IMX519_MIPI_RAW "imx519_mipi_raw"
#define SENSOR_DRVNAME_IMX519DUAL_MIPI_RAW "imx519dual_mipi_raw"
#define SENSOR_DRVNAME_IMX576_MIPI_RAW "imx576_mipi_raw"
#define SENSOR_DRVNAME_IMX350_MIPI_RAW "imx350_mipi_raw"
#define SENSOR_DRVNAME_IMX398_MIPI_RAW "imx398_mipi_raw"
#define SENSOR_DRVNAME_IMX268_MIPI_RAW "imx268_mipi_raw"
#define SENSOR_DRVNAME_IMX386_MIPI_RAW "imx386_mipi_raw"
#define SENSOR_DRVNAME_IMX300_MIPI_RAW "imx300_mipi_raw"
#define SENSOR_DRVNAME_IMX386_MIPI_MONO "imx386_mipi_mono"
#define SENSOR_DRVNAME_IMX362_MIPI_RAW "imx362_mipi_raw"
#define SENSOR_DRVNAME_IMX338_MIPI_RAW "imx338_mipi_raw"
#define SENSOR_DRVNAME_IMX376_MIPI_RAW "imx376_mipi_raw"
#define SENSOR_DRVNAME_IMX318_MIPI_RAW "imx318_mipi_raw"
#define SENSOR_DRVNAME_IMX319_MIPI_RAW "imx319_mipi_raw"
#define SENSOR_DRVNAME_IMX377_MIPI_RAW "imx377_mipi_raw"
#define SENSOR_DRVNAME_IMX278_MIPI_RAW "imx278_mipi_raw"
#define SENSOR_DRVNAME_IMX258_MIPI_RAW "imx258_mipi_raw"
#define SENSOR_DRVNAME_IMX258_MIPI_MONO "imx258_mipi_mono"
#define SENSOR_DRVNAME_IMX230_MIPI_RAW "imx230_mipi_raw"
#define SENSOR_DRVNAME_IMX220_MIPI_RAW "imx220_mipi_raw"
#define SENSOR_DRVNAME_IMX219_MIPI_RAW "imx219_mipi_raw"
#define SENSOR_DRVNAME_IMX214_MIPI_MONO "imx214_mipi_mono"
#define SENSOR_DRVNAME_IMX214_MIPI_RAW "imx214_mipi_raw"
#define SENSOR_DRVNAME_IMX179_MIPI_RAW "imx179_mipi_raw"
#define SENSOR_DRVNAME_IMX178_MIPI_RAW "imx178_mipi_raw"
#define SENSOR_DRVNAME_IMX135_MIPI_RAW "imx135_mipi_raw"
#define SENSOR_DRVNAME_IMX132_MIPI_RAW "imx132_mipi_raw"
#define SENSOR_DRVNAME_IMX119_MIPI_RAW "imx119_mipi_raw"
#define SENSOR_DRVNAME_IMX105_MIPI_RAW "imx105_mipi_raw"
#define SENSOR_DRVNAME_IMX091_MIPI_RAW "imx091_mipi_raw"
#define SENSOR_DRVNAME_IMX073_MIPI_RAW "imx073_mipi_raw"
#define SENSOR_DRVNAME_IMX766_MIPI_RAW "imx766_mipi_raw"
/*OV*/
#define SENSOR_DRVNAME_OV23850_MIPI_RAW "ov23850_mipi_raw"
#define SENSOR_DRVNAME_OV16880_MIPI_RAW "ov16880_mipi_raw"
#define SENSOR_DRVNAME_OV16885_MIPI_RAW "ov16885_mipi_raw"
#define SENSOR_DRVNAME_OV16825_MIPI_RAW "ov16825_mipi_raw"
#define SENSOR_DRVNAME_OV13855_MIPI_RAW "ov13855_mipi_raw"
#define SENSOR_DRVNAME_OV13870_MIPI_RAW "ov13870_mipi_raw"
#define SENSOR_DRVNAME_OV13855_MIPI_RAW "ov13855_mipi_raw"
#define SENSOR_DRVNAME_OV13855MAIN2_MIPI_RAW "ov13855main2_mipi_raw"
#define SENSOR_DRVNAME_OV13850_MIPI_RAW "ov13850_mipi_raw"
#define SENSOR_DRVNAME_OV12A10_MIPI_RAW "ov12a10_mipi_raw"
#define SENSOR_DRVNAME_OV12830_MIPI_RAW "ov12830_mipi_raw"
#define SENSOR_DRVNAME_OV9760_MIPI_RAW "ov9760_mipi_raw"
#define SENSOR_DRVNAME_OV9740_MIPI_YUV "ov9740_mipi_yuv"
#define SENSOR_DRVNAME_0V9726_RAW "ov9726_raw"
#define SENSOR_DRVNAME_OV9726_MIPI_RAW "ov9726_mipi_raw"
#define SENSOR_DRVNAME_OV8865_MIPI_RAW "ov8865_mipi_raw"
#define SENSOR_DRVNAME_OV8858_MIPI_RAW "ov8858_mipi_raw"
#define SENSOR_DRVNAME_OV8858S_MIPI_RAW "ov8858s_mipi_raw"
#define SENSOR_DRVNAME_OV8856_MIPI_RAW "ov8856_mipi_raw"
#define SENSOR_DRVNAME_OV8830_RAW "ov8830_raw"
#define SENSOR_DRVNAME_OV8825_MIPI_RAW "ov8825_mipi_raw"
#define SENSOR_DRVNAME_OV7675_YUV "ov7675_yuv"
#define SENSOR_DRVNAME_OV5693_MIPI_RAW "ov5693_mipi_raw"
#define SENSOR_DRVNAME_OV5670_MIPI_RAW "ov5670_mipi_raw"
#define SENSOR_DRVNAME_OV5670_MIPI_RAW_2 "ov5670_mipi_raw_2"
#define SENSOR_DRVNAME_OV2281_MIPI_RAW "ov2281_mipi_raw"
#define SENSOR_DRVNAME_OV5675_MIPI_RAW "ov5675mipiraw"
#define SENSOR_DRVNAME_OV5671_MIPI_RAW "ov5671_mipi_raw"
#define SENSOR_DRVNAME_OV5647MIPI_RAW "ov5647_mipi_raw"
#define SENSOR_DRVNAME_OV5645_MIPI_RAW "ov5645_mipi_raw"
#define SENSOR_DRVNAME_OV5645_MIPI_YUV "ov5645_mipi_yuv"
#define SENSOR_DRVNAME_OV5650MIPI_RAW "ov5650_mipi_raw"
#define SENSOR_DRVNAME_OV5650_RAW "ov5650_raw"
#define SENSOR_DRVNAME_OV5648_MIPI_RAW "ov5648_mipi_raw"
#define SENSOR_DRVNAME_OV5647_RAW "ov5647_raw"
#define SENSOR_DRVNAME_OV5642_RAW "ov5642_raw"
#define SENSOR_DRVNAME_OV5642_MIPI_YUV "ov5642_mipi_yuv"
#define SENSOR_DRVNAME_OV5642_MIPI_RGB "ov5642_mipi_rgb"
#define SENSOR_DRVNAME_OV5642_MIPI_JPG "ov5642_mipi_jpg"
#define SENSOR_DRVNAME_OV5642_YUV "ov5642_yuv"
#define SENSOR_DRVNAME_OV5642_YUV_SWI2C "ov5642_yuv_swi2c"
#define SENSOR_DRVNAME_OV4688_MIPI_RAW "ov4688_mipi_raw"
#define SENSOR_DRVNAME_OV3640_RAW "ov3640_raw"
#define SENSOR_DRVNAME_OV3640_YUV "ov3640_yuv"
#define SENSOR_DRVNAME_OV2724_MIPI_RAW "ov2724_mipi_raw"
#define SENSOR_DRVNAME_OV2722_MIPI_RAW "ov2722_mipi_raw"
#define SENSOR_DRVNAME_OV2680_MIPI_RAW "ov2680_mipi_raw"
#define SENSOR_DRVNAME_OV2659_YUV "ov2659_yuv"
#define SENSOR_DRVNAME_OV2655_YUV "ov2655_yuv"
#define SENSOR_DRVNAME_OV2650_RAW "ov265x_raw"
#define SENSOR_DRVNAME_OV20880_MIPI_RAW "ov20880_mipi_raw"
#define SENSOR_DRVNAME_OV13B10_MIPI_RAW "ov13b10_mipi_raw"
#define SENSOR_DRVNAME_OV05A20_MIPI_RAW "ov05a20_mipi_raw"
/*S5K*/
#define SENSOR_DRVNAME_S5KJD1_MIPI_RAW "s5kjd1_mipi_raw"
#define SENSOR_DRVNAME_S5K2LQSX_MIPI_RAW "s5k2lqsx_mipi_raw"
#define SENSOR_DRVNAME_S5K4H7_MIPI_RAW "s5k4h7_mipi_raw"
#define SENSOR_DRVNAME_S5K4H7YXSUB_MIPI_RAW "s5k4h7yxsub_mipi_raw"
#define SENSOR_DRVNAME_S5K3P8SP_MIPI_RAW "s5k3p8sp_mipi_raw"
#define SENSOR_DRVNAME_S5K2T7SP_MIPI_RAW "s5k2t7sp_mipi_raw"
#define SENSOR_DRVNAME_S5K2T7SP_MIPI_RAW_5M "s5k2t7sp_mipi_raw_5m"
#define SENSOR_DRVNAME_S5K3P8SX_MIPI_RAW "s5k3p8sx_mipi_raw"
#define SENSOR_DRVNAME_S5K2L7_MIPI_RAW "s5k2l7_mipi_raw"
#define SENSOR_DRVNAME_S5K3L6_MIPI_RAW "s5k3l6_mipi_raw"
#define SENSOR_DRVNAME_S5K3L8_MIPI_RAW "s5k3l8_mipi_raw"
#define SENSOR_DRVNAME_S5K3M3_MIPI_RAW "s5k3m3_mipi_raw"
#define SENSOR_DRVNAME_S5K3M5SX_MIPI_RAW "s5k3m5sx_mipi_raw"
#define SENSOR_DRVNAME_S5K2X8_MIPI_RAW "s5k2x8_mipi_raw"
#define SENSOR_DRVNAME_S5K2P7_MIPI_RAW "s5k2p7_mipi_raw"
#define SENSOR_DRVNAME_S5K2P8_MIPI_RAW "s5k2p8_mipi_raw"
#define SENSOR_DRVNAME_S5K3P3SX_MIPI_RAW "s5k3p3sx_mipi_raw"
#define SENSOR_DRVNAME_S5K3P3_MIPI_RAW "s5k3p3_mipi_raw"
#define SENSOR_DRVNAME_S5K3P8_MIPI_RAW "s5k3p8_mipi_raw"
#define SENSOR_DRVNAME_S5K3M2_MIPI_RAW "s5k3m2_mipi_raw"
#define SENSOR_DRVNAME_S5K4E6_MIPI_RAW "s5k4e6_mipi_raw"
#define SENSOR_DRVNAME_S5K3H2YX_MIPI_RAW "s5k3h2yx_mipi_raw"
#define SENSOR_DRVNAME_S5K3H7Y_MIPI_RAW "s5k3h7y_mipi_raw"
#define SENSOR_DRVNAME_S5K4H5YC_MIPI_RAW "s5k4h5yc_mipi_raw"
#define SENSOR_DRVNAME_S5K4E1GA_MIPI_RAW "s5k4e1ga_mipi_raw"
#define SENSOR_DRVNAME_S5K4ECGX_MIPI_YUV "s5k4ecgx_mipi_yuv"
#define SENSOR_DRVNAME_S5K5CAGX_YUV "s5k5cagx_yuv"
#define SENSOR_DRVNAME_S5K4H5YX_2LANE_MIPI_RAW "s5k4h5yx_2lane_mipi_raw"
#define SENSOR_DRVNAME_S5K5E2YA_MIPI_RAW "s5k5e2ya_mipi_raw"
#define SENSOR_DRVNAME_S5K8AAYX_MIPI_YUV "s5k8aayx_mipi_yuv"
#define SENSOR_DRVNAME_S5K8AAYX_YUV "s5k8aayx_yuv"
#define SENSOR_DRVNAME_S5K5E8YX_MIPI_RAW "s5k5e8yx_mipi_raw"
#define SENSOR_DRVNAME_S5K5E8YXREAR2_MIPI_RAW "s5k5e8yxrear2_mipi_raw"
#define SENSOR_DRVNAME_S5K5E9_MIPI_RAW "s5k5e9_mipi_raw"
#define SENSOR_DRVNAME_S5KHM2SP_MIPI_RAW "s5khm2sp_mipi_raw"
#define SENSOR_DRVNAME_S5KJN1_MIPI_RAW "s5kjn1_mipi_raw"
/*HI*/
#define SENSOR_DRVNAME_HI841_MIPI_RAW "hi841_mipi_raw"
#define SENSOR_DRVNAME_HI707_YUV "hi707_yuv"
#define SENSOR_DRVNAME_HI704_YUV "hi704_yuv"
#define SENSOR_DRVNAME_HI556_MIPI_RAW "hi556_mipi_raw"
#define SENSOR_DRVNAME_HI551_MIPI_RAW "hi551_mipi_raw"
#define SENSOR_DRVNAME_HI553_MIPI_RAW "hi553_mipi_raw"
#define SENSOR_DRVNAME_HI545_MIPI_RAW "hi545_mipi_raw"
#define SENSOR_DRVNAME_HI542_RAW "hi542_raw"
#define SENSOR_DRVNAME_HI542MIPI_RAW "hi542_mipi_raw"
#define SENSOR_DRVNAME_HI544_MIPI_RAW "hi544_mipi_raw"
#define SENSOR_DRVNAME_HI253_YUV "hi253_yuv"
#define SENSOR_DRVNAME_HI191_MIPI_RAW "hi191_mipi_raw"
/*MT*/
#define SENSOR_DRVNAME_MT9P012_RAW "mt9p012_raw"
#define SENSOR_DRVNAME_MT9P015_RAW "mt9p015_raw"
#define SENSOR_DRVNAME_MT9P017_RAW "mt9p017_raw"
#define SENSOR_DRVNAME_MT9P017_MIPI_RAW "mt9p017_mipi_raw"
#define SENSOR_DRVNAME_MT9D115_MIPI_RAW "mt9d115_mipi_raw"
#define SENSOR_DRVNAME_MT9V114_YUV "mt9v114_yuv"
#define SENSOR_DRVNAME_MT9V115_YUV "mt9v115_yuv"
#define SENSOR_DRVNAME_MT9T113_YUV "mt9t113_yuv"
#define SENSOR_DRVNAME_MT9V113_YUV "mt9v113_yuv"
#define SENSOR_DRVNAME_MT9T113_MIPI_YUV "mt9t113_mipi_yuv"
/*GC*/
#define SENSOR_DRVNAME_GC02M0_MIPI_RAW "gc02m0_mipi_raw"
#define SENSOR_DRVNAME_GC5035MIPI_RAW "gc5035_mipi_raw"
#define SENSOR_DRVNAME_GC2375_MIPI_RAW "gc2375_mipi_raw"
#define SENSOR_DRVNAME_GC2375H_MIPI_RAW "gc2375h_mipi_raw"
#define SENSOR_DRVNAME_GC2375SUB_MIPI_RAW "gc2375sub_mipi_raw"
#define SENSOR_DRVNAME_GC2365_MIPI_RAW "gc2365_mipi_raw"
#define SENSOR_DRVNAME_GC2366_MIPI_RAW "gc2366_mipi_raw"
#define SENSOR_DRVNAME_GC08A3_MIPI_RAW "gc08a3_mipi_raw"
#define SENSOR_DRVNAME_GC2035_YUV "gc2035_yuv"
#define SENSOR_DRVNAME_GC2235_RAW "gc2235_raw"
#define SENSOR_DRVNAME_GC2355_MIPI_RAW "gc2355_mipi_raw"
#define SENSOR_DRVNAME_GC2355_RAW "gc2355_raw"
#define SENSOR_DRVNAME_GC0330_YUV "gc0330_yuv"
#define SENSOR_DRVNAME_GC0329_YUV "gc0329_yuv"
#define SENSOR_DRVNAME_GC2145_MIPI_YUV "gc2145_mipi_yuv"
#define SENSOR_DRVNAME_GC0310_MIPI_YUV "gc0310_mipi_yuv"
#define SENSOR_DRVNAME_GC0310_YUV "gc0310_yuv"
#define SENSOR_DRVNAME_GC0312_YUV "gc0312_yuv"
#define SENSOR_DRVNAME_GC0313MIPI_YUV "gc0313_mipi_yuv"
#define SENSOR_DRVNAME_GC8C34_MIPI_RAW "gc8c34_mipi_raw"
#define SENSOR_DRVNAME_GC8034_MIPI_RAW "gc8034_mipi_raw"
/*SP*/
#define SENSOR_DRVNAME_SP0A19_YUV "sp0a19_yuv"
#define SENSOR_DRVNAME_SP2518_YUV "sp2518_yuv"
#define SENSOR_DRVNAME_SP2509_MIPI_RAW "sp2509_mipi_raw"
#define SENSOR_DRVNAME_SP250A_MIPI_RAW "sp250a_mipi_raw"
/*A*/
#define SENSOR_DRVNAME_A5141_MIPI_RAW "a5141_mipi_raw"
#define SENSOR_DRVNAME_A5142_MIPI_RAW "a5142_mipi_raw"
/*HM*/
#define SENSOR_DRVNAME_HM3451_RAW "hm3451_raw"
/*AR*/
#define SENSOR_DRVNAME_AR0833_MIPI_RAW "ar0833_mipi_raw"
/*SIV*/
#define SENSOR_DRVNAME_SIV121D_YUV "siv121d_yuv"
#define SENSOR_DRVNAME_SIV120B_YUV "siv120b_yuv"
/*PAS (PixArt Image)*/
#define SENSOR_DRVNAME_PAS6180_SERIAL_YUV "pas6180_serial_yuv"
/*Panasoic*/
#define SENSOR_DRVNAME_MN34152_MIPI_RAW "mn34152_mipi_raw"
/*Toshiba*/
#define SENSOR_DRVNAME_T4KA7_MIPI_RAW "t4ka7_mipi_raw"
/*Others*/
#define SENSOR_DRVNAME_SHARP3D_MIPI_YUV "sharp3d_mipi_yuv"
#define SENSOR_DRVNAME_T8EV5_YUV "t8ev5_yuv"
/*Test*/
#define SENSOR_DRVNAME_IMX135_MIPI_RAW_5MP "imx135_mipi_raw_5mp"
#define SENSOR_DRVNAME_IMX135_MIPI_RAW_8MP "imx135_mipi_raw_8mp"
#define SENSOR_DRVNAME_OV13870_MIPI_RAW_5MP "ov13870_mipi_raw_5mp"
#define SENSOR_DRVNAME_OV8856_MIPI_RAW_5MP "ov8856_mipi_raw_5mp"
#define SENSOR_DRVNAME_S5KGD1SP_MIPI_RAW "s5kgd1sp_mipi_raw"
#define SENSOR_DRVNAME_HI846_MIPI_RAW "hi846_mipi_raw"
#define SENSOR_DRVNAME_GC02M0_MIPI_RAW "gc02m0_mipi_raw"
#define SENSOR_DRVNAME_OV02A10_MIPI_MONO "ov02a10_mipi_mono"
#define SENSOR_DRVNAME_IMX686_MIPI_RAW "imx686_mipi_raw"
#define SENSOR_DRVNAME_IMX616_MIPI_RAW "imx616_mipi_raw"
#define SENSOR_DRVNAME_OV48B_MIPI_RAW "ov48b_mipi_raw"
#define SENSOR_DRVNAME_S5K3P9SP_MIPI_RAW "s5k3p9sp_mipi_raw"
#define SENSOR_DRVNAME_GC8054_MIPI_RAW "gc8054_mipi_raw"
#define SENSOR_DRVNAME_GC02M0B_MIPI_MONO "gc02m0b_mipi_mono"
#define SENSOR_DRVNAME_GC02M0B_MIPI_MONO1 "gc02m0b_mipi_mono1"
#define SENSOR_DRVNAME_GC02M0B_MIPI_MONO2 "gc02m0b_mipi_mono2"
#define SENSOR_DRVNAME_GC02K0B_MIPI_MONO "gc02k0b_mipi_mono"
#define SENSOR_DRVNAME_OV16A10_MIPI_RAW "ov16a10_mipi_raw"
#define SENSOR_DRVNAME_GC02M1B_MIPI_MONO "gc02m1b_mipi_mono"
#define SENSOR_DRVNAME_OV48C_MIPI_RAW "ov48c_mipi_raw"
#define SENSOR_DRVNAME_IMX355_MIPI_RAW "imx355_mipi_raw"
#define SENSOR_DRVNAME_OV13B10_MIPI_RAW "ov13b10_mipi_raw"
#define SENSOR_DRVNAME_OV02B10_MIPI_RAW "ov02b10_mipi_raw"
/******************************************************************************
*
******************************************************************************/
void KD_IMGSENSOR_PROFILE_INIT(void);
void KD_IMGSENSOR_PROFILE(char *tag);
void KD_IMGSENSOR_PROFILE_INIT_I2C(void);
void KD_IMGSENSOR_PROFILE_I2C(char *tag, int trans_num);
#define mDELAY(ms) mdelay(ms)
#define uDELAY(us) udelay(us)
#endif /* _KD_IMGSENSOR_H */
@@ -0,0 +1,21 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#ifndef _KD_IMGSENSOR_CA_TA_CMD_H_
#define _KD_IMGSENSOR_CA_TA_CMD_H_
enum IMGSENSOR_TEE_CMD {
IMGSENSOR_TEE_CMD_OPEN = 0x0,
IMGSENSOR_TEE_CMD_GET_INFO,
IMGSENSOR_TEE_CMD_GET_RESOLUTION,
IMGSENSOR_TEE_CMD_FEATURE_CONTROL,
IMGSENSOR_TEE_CMD_CONTROL,
IMGSENSOR_TEE_CMD_CLOSE,
IMGSENSOR_TEE_CMD_DUMP_REG,
IMGSENSOR_TEE_CMD_GET_I2C_BUS,
IMGSENSOR_TEE_CMD_SET_SENSOR,
};
#endif
@@ -0,0 +1,16 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#ifndef _KD_IMGSENSOR_API_H_
#define _KD_IMGSENSOR_API_H_
/* API for termal driver use*/
extern MUINT32 Get_Camera_Temperature(
enum CAMERA_DUAL_CAMERA_SENSOR_ENUM senDevId,
MUINT8 *valid,
MUINT32 *temp);
extern unsigned int Switch_Tg_For_Stagger(unsigned int camtg);
#endif
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,49 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#ifndef _KD_IMGSENSOR_ERRCODE_H_
#define _KD_IMGSENSOR_ERRCODE_H_
/* @ the same as camera_custom_errocode.h */
enum CUSTOM_CAMERA_ERROR_CODE_ENUM {
ERROR_NONE = 0,
ERROR_MSDK_IS_ACTIVATED,
ERROR_INVALID_DRIVER_MOD_ID,
ERROR_INVALID_FEATURE_ID,
ERROR_INVALID_SCENARIO_ID,
ERROR_INVALID_CTRL_CODE,
ERROR_VIDEO_ENCODER_BUSY,
ERROR_INVALID_PARA,
ERROR_OUT_OF_BUFFER_NUMBER,
ERROR_INVALID_ISP_STATE,
ERROR_INVALID_MSDK_STATE,
ERROR_PHY_VIR_MEM_MAP_FAIL,
ERROR_ENQUEUE_BUFFER_NOT_FOUND,
ERROR_MSDK_BUFFER_ALREADY_INIT,
ERROR_MSDK_BUFFER_OUT_OF_MEMORY,
ERROR_SENSOR_POWER_ON_FAIL,
ERROR_SENSOR_CONNECT_FAIL,
ERROR_SENSOR_FEATURE_NOT_IMPLEMENT,
ERROR_MSDK_IO_CONTROL_CODE,
ERROR_MSDK_IO_CONTROL_MSG_QUEUE_OPEN_FAIL,
ERROR_DRIVER_INIT_FAIL,
ERROR_WRONG_NVRAM_CAMERA_VERSION,
ERROR_NVRAM_CAMERA_FILE_FAIL,
ERROR_IMAGE_DECODE_FAIL,
ERROR_IMAGE_ENCODE_FAIL,
ERROR_LED_FLASH_POWER_ON_FAIL,
ERROR_MSDK_NOT_ALLOW_BY_MM_APP_MGR,
ERROR_LENS_NOT_SUPPORT,
ERROR_FLASH_LIGHT_NOT_SUPPORT,
ERROR_FACE_DETECTION_NOT_SUPPORT,
ERROR_PANORAMA_NOT_SUPPORT,
ERROR_TEE_CA_TA_FAIL,
ERROR_TEE_CA_TA_SECURE_CHECK_FAIL,
ERROR_TEE_SET_SENSOR_PFUNC_FAIL,
ERROR_MAX
};
#endif
@@ -0,0 +1,43 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#ifndef _KD_SENINF_H_
#define _KD_SENINF_H_
#include "kd_imgsensor_define.h"
#include "kd_seninf_define.h"
#define SENINFMAGIC 's'
/* IOCTRL(inode * ,file * ,cmd ,arg ) */
/* S means "set through a ptr" */
/* T means "tell by a arg value" */
/* G means "get by a ptr" */
/* Q means "get by return a value" */
/* X means "switch G and S atomically" */
/* H means "switch T and Q atomically" */
#define KDSENINFIOC_X_GET_REG_ADDR \
_IOWR(SENINFMAGIC, 40, struct KD_SENINF_REG)
#define KDSENINFIOC_X_SET_MCLK_PLL \
_IOWR(SENINFMAGIC, 60, struct ACDK_SENSOR_MCLK_STRUCT)
#define KDSENINFIOC_X_GET_ISP_CLK \
_IOWR(SENINFMAGIC, 80, u32)
#define KDSENINFIOC_X_GET_CSI_CLK \
_IOWR(SENINFMAGIC, 85, u32)
#define KDSENINFIOC_X_SECURE_DUMP \
_IO(SENINFMAGIC, 90)
/* Get ISP CLK via MMDVFS*/
#define KDSENINFIOC_DFS_UPDATE \
_IOWR(SENINFMAGIC, 95, unsigned int)
#define KDSENINFIOC_GET_SUPPORTED_ISP_CLOCKS \
_IOWR(SENINFMAGIC, 100, struct IMAGESENSOR_GET_SUPPORTED_ISP_CLK)
#define KDSENINFIOC_GET_CUR_ISP_CLOCK \
_IOWR(SENINFMAGIC, 105, unsigned int)
/* store numbers of cam_mux for swich later */
#define KDSENINFIOC_SET_CAM_MUX_FOR_SWITCH \
_IOWR(SENINFMAGIC, 110, unsigned int)
#define KDSENINFIOC_X_SET_SWITCH_TG_FOR_STAGGER \
_IOWR(SENINFMAGIC, 115, u32)
#endif
@@ -0,0 +1,24 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#ifndef _KD_SENINF_DEFINE_H_
#define _KD_SENINF_DEFINE_H_
/*************************************************
*
**************************************************/
struct KD_SENINF_MMAP {
MUINT32 map_addr;
MUINT32 map_length;
};
struct KD_SENINF_REG {
struct KD_SENINF_MMAP seninf;
struct KD_SENINF_MMAP ana;
struct KD_SENINF_MMAP gpio;
};
#endif
@@ -0,0 +1,78 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#ifndef _KD_SENINF_N3D_H_
#define _KD_SENINF_N3D_H_
struct sensor_info {
unsigned int sensor_id;
unsigned int sensor_idx;
unsigned int cammux_id;
unsigned int fl_active_delay;
unsigned int def_fl_lc; // default framelength_lc
unsigned int max_fl_lc; // for framelength boundary check
unsigned int def_shutter_lc; // default shutter_lc
};
struct n3d_perframe {
unsigned int sensor_id;
unsigned int sensor_idx;
/* bellow items can be query from "subdrv_ctx" */
unsigned int min_fl_lc; // also means max frame rate
unsigned int shutter_lc;
unsigned int margin_lc;
unsigned int flicker_en;
unsigned int out_fl_lc;
/* for on-the-fly mode change */
unsigned int pclk; // write_shutter(), set_max_framerate()
unsigned int linelength; // write_shutter(), set_max_framerate()
/* lineTimeInNs ~= 10^9 * (linelength/pclk) */
unsigned int lineTimeInNs;
};
struct KD_REGISTER_SENSOR {
struct sensor_info sensor;
};
struct KD_N3D_AE_INFO {
struct n3d_perframe ae_info;
};
struct KD_N3D_PERFRAME {
struct n3d_perframe per1;
struct n3d_perframe per2;
};
#define SENINF_N3D_MAGIC 'i'
/* IOCTRL(inode * ,file * ,cmd ,arg ) */
/* S means "set through a ptr" */
/* T means "tell by a arg value" */
/* G means "get by a ptr" */
/* Q means "get by return a value" */
/* X means "switch G and S atomically" */
/* H means "switch T and Q atomically" */
#define KDSENINFN3DIOC_X_REGISTER_SENSOR \
_IOWR(SENINF_N3D_MAGIC, 0, struct KD_REGISTER_SENSOR)
#define KDSENINFN3DIOC_X_UNREGISTER_SENSOR \
_IOWR(SENINF_N3D_MAGIC, 5, struct KD_REGISTER_SENSOR)
#define KDSENINFN3DIOC_X_START_SYNC \
_IO(SENINF_N3D_MAGIC, 10)
#define KDSENINFN3DIOC_X_STOP_SYNC \
_IO(SENINF_N3D_MAGIC, 15)
#define KDSENINFN3DIOC_X_UPDATE_AE_INFO \
_IOWR(SENINF_N3D_MAGIC, 20, struct KD_N3D_AE_INFO)
#define KDSENINFN3DIOC_X_PERFRAME_CTRL \
_IOWR(SENINF_N3D_MAGIC, 25, struct KD_N3D_PERFRAME)
#endif
@@ -0,0 +1,54 @@
config SPECIFY_IMGSENSOR
bool SPECIFY_IMGSENSOR
depends on MTK_IMGSENSOR
help
Specify name of each sensor to
prevent obtaining wrong sensor driver with same sensor ID.
For example, imx258_mipi_raw and imx258_mipi_mono
are of same sensor ID. If not specifying
sensor, imx258_mipi_mono may be recognized as imx258_mipi_raw.
config IMGSENSOR_MAIN
string "Custom main image sensor"
depends on SPECIFY_IMGSENSOR
help
Specify main sensor.
This config is mainly mapping to userspace.
Consider the numbers of sensors and usage on the phone.
Compare the custom usage defined in user-custom folder.
config IMGSENSOR_MAIN2
string "Custom main2 image sensor"
depends on SPECIFY_IMGSENSOR
help
Specify main2 sensor.
This config is mainly mapping to userspace.
Consider the numbers of sensors and usage on the phone.
Compare the custom usage defined in user-custom folder.
config IMGSENSOR_SUB
string "Custom sub image sensor"
depends on SPECIFY_IMGSENSOR
help
Specify sub sensor.
This config is mainly mapping to userspace.
Consider the numbers of sensors and usage on the phone.
Compare the custom usage defined in user-custom folder.
config IMGSENSOR_SUB2
string "Custom sub2 image sensor"
depends on SPECIFY_IMGSENSOR
help
Specify sub2 sensor.
This config is mainly mapping to userspace.
Consider the numbers of sensors and usage on the phone.
Compare the custom usage defined in user-custom folder.
config IMGSENSOR_MAIN3
string "Custom main3 image sensor"
depends on SPECIFY_IMGSENSOR
help
Specify main3 sensor.
This config is mainly mapping to userspace.
Consider the numbers of sensors and usage on the phone.
Compare the custom usage defined in user-custom folder.
@@ -0,0 +1,34 @@
# SPDX-License-Identifier: GPL-2.0
subdir-ccflags-y += -I$(srctree)/drivers/i2c/busses/ \
-I$(srctree)/drivers/misc/mediatek/ccu/inc
MTK_PLATFORM := $(subst ",,$(CONFIG_MTK_PLATFORM))
ARCH_MTK_PROJECT := $(subst ",,$(CONFIG_ARCH_MTK_PROJECT))
MTK_PLATFORM_PATH_ROOT := $(srctree)/drivers/misc/mediatek/mach/$(MTK_PLATFORM)
MTK_PROJECT_PATH_ROOT := $(srctree)/drivers/misc/mediatek/mach/$(MTK_PLATFORM)/$(ARCH_MTK_PROJECT)
ifeq ($(CONFIG_MACH_MT6781),y)
CONFIG_MTK_PLATFORM_SENSOR := mt6781
else
CONFIG_MTK_PLATFORM_SENSOR := $(CONFIG_MTK_PLATFORM)
endif
subdir-ccflags-y += -I$(MTK_PROJECT_PATH_ROOT)/camera/camera
MTK_DRIVER_PATH := $(srctree)/drivers/misc/mediatek
subdir-ccflags-y += -I$(MTK_DRIVER_PATH)/camera/$(MTK_PLATFORM) \
-I$(MTK_DRIVER_PATH)/imgsensor/inc \
-I$(MTK_DRIVER_PATH)/cam_cal/inc \
-I$(MTK_DRIVER_PATH)/smi \
-I$(MTK_DRIVER_PATH)/include/mt-plat/$(MTK_PLATFORM)/include/mach \
-I$(MTK_DRIVER_PATH)/imgsensor/src/$(CONFIG_MTK_PLATFORM_SENSOR)
CUSTOM_KERNEL_FLAGS := $(addprefix -D, $(shell echo \
$(CONFIG_CUSTOM_KERNEL_IMGSENSOR) | tr a-z A-Z))
subdir-ccflags-y += $(CUSTOM_KERNEL_FLAGS)
obj-y += $(subst ",,$(CONFIG_MTK_PLATFORM_SENSOR))/
@@ -0,0 +1,3 @@
# SPDX-License-Identifier: GPL-2.0
obj-y += gc2365mipi_Sensor.o
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,164 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
*/
/*****************************************************************************
*
* Filename:
* ---------
* GC2365mipi_Sensor.h
*
* Project:
* --------
* ALPS
*
* Description:
* ------------
* CMOS sensor header file
*
****************************************************************************/
#define IMAGE_NO_MIRROR
/* #define IMAGE_H_MIRROR */
/* #define IMAGE_V_MIRROR */
/* #define IMAGE_HV_MIRROR */
#ifdef IMAGE_NO_MIRROR
#define MIRROR 0xc0
#define STARTY 0x03
#define STARTX 0x02
#endif
#ifdef IMAGE_H_MIRROR
#define MIRROR 0xc1
#define STARTY 0x03
#define STARTX 0x05
#endif
#ifdef IMAGE_V_MIRROR
#define MIRROR 0xc2
#define STARTY 0x02
#define STARTX 0x02
#endif
#ifdef IMAGE_HV_MIRROR
#define MIRROR 0xc3
#define STARTY 0x02
#define STARTX 0x05
#endif
#ifndef _GC2365MIPI_SENSOR_H
#define _GC2365MIPI_SENSOR_H
enum IMGSENSOR_MODE {
IMGSENSOR_MODE_INIT,
IMGSENSOR_MODE_PREVIEW,
IMGSENSOR_MODE_CAPTURE,
IMGSENSOR_MODE_VIDEO,
IMGSENSOR_MODE_HIGH_SPEED_VIDEO,
IMGSENSOR_MODE_SLIM_VIDEO,
};
struct imgsensor_mode_struct {
kal_uint32 pclk; /* record different mode's pclk */
kal_uint32 linelength; /* record different mode's linelength */
kal_uint32 framelength; /* record different mode's framelength */
kal_uint8 startx; /* record different mode's startx of grabwindow */
kal_uint8 starty; /* record different mode's startx of grabwindow */
kal_uint16
grabwindow_width; /* record different mode's width of grabwindow */
kal_uint16 grabwindow_height; /* record different mode's height of
grabwindow */
/* following for MIPIDataLowPwr2HighSpeedSettleDelayCount by
* different scenario */
kal_uint8 mipi_data_lp2hs_settle_dc;
/* following for GetDefaultFramerateByScenario() */
kal_uint16 max_framerate;
};
/* SENSOR PRIVATE STRUCT FOR VARIABLES*/
struct imgsensor_struct {
kal_uint8 mirror; /* mirrorflip information */
kal_uint8 sensor_mode; /* record IMGSENSOR_MODE enum value */
kal_uint32 shutter; /* current shutter */
kal_uint16 gain; /* current gain */
kal_uint32 pclk; /* current pclk */
kal_uint32 frame_length; /* current framelength */
kal_uint32 line_length; /* current linelength */
kal_uint32
min_frame_length; /* current min framelength to max framerate */
kal_uint16 dummy_pixel; /* current dummypixel */
kal_uint16 dummy_line; /* current dummline */
kal_uint16 current_fps; /* current max fps */
kal_bool autoflicker_en; /* record autoflicker enable or disable */
kal_bool test_pattern; /* record test pattern mode or not */
enum MSDK_SCENARIO_ID_ENUM current_scenario_id;
kal_uint8 ihdr_en; /* ihdr enable or disable */
kal_uint8 i2c_write_id; /* record current sensor's i2c write id */
};
/* SENSOR PRIVATE STRUCT FOR CONSTANT*/
struct imgsensor_info_struct {
kal_uint32 sensor_id; /* record sensor id defined in Kd_imgsensor.h */
kal_uint32 checksum_value; /* checksum value for Camera Auto Test */
struct imgsensor_mode_struct
pre; /* preview scenario relative information */
struct imgsensor_mode_struct
cap; /* capture scenario relative information */
struct imgsensor_mode_struct cap1;
struct imgsensor_mode_struct
normal_video; /* normal video scenario relative information */
struct imgsensor_mode_struct
hs_video; /* high speed video scenario relative information */
struct imgsensor_mode_struct
slim_video; /* slim video for VT scenario relative information */
kal_uint8 ae_shut_delay_frame; /* shutter delay frame for AE cycle */
kal_uint8 ae_sensor_gain_delay_frame; /* sensor gain delay frame for AE
cycle */
kal_uint8
ae_ispGain_delay_frame; /* isp gain delay frame for AE cycle */
kal_uint8 ihdr_support; /* 1, support; 0,not support */
kal_uint8 ihdr_le_firstline; /* 1,le first ; 0, se first */
kal_uint8 sensor_mode_num; /* support sensor mode num */
kal_uint8 cap_delay_frame; /* enter capture delay frame num */
kal_uint8 pre_delay_frame; /* enter preview delay frame num */
kal_uint8 video_delay_frame; /* enter video delay frame num */
kal_uint8
hs_video_delay_frame; /* enter high speed video delay frame num */
kal_uint8 slim_video_delay_frame; /* enter slim video delay frame num */
kal_uint8 margin; /* sensor framelength & shutter margin */
kal_uint32 min_shutter; /* min shutter */
kal_uint32 max_frame_length; /* max framelength by sensor register's
limitation */
kal_uint8 isp_driving_current; /* mclk driving current */
kal_uint8 sensor_interface_type; /* sensor_interface_type */
kal_uint8 mipi_sensor_type;
kal_uint8 mipi_settle_delay_mode;
kal_uint8
sensor_output_dataformat; /* sensor output first pixel color */
kal_uint8 mclk; /* mclk value, suggest 24 or 26 for 24Mhz or 26Mhz */
kal_uint8 mipi_lane_num; /* mipi lane num */
kal_uint8 i2c_addr_table[5];
};
extern int iReadRegI2C(u8 *a_pSendData, u16 a_sizeSendData, u8 *a_pRecvData,
u16 a_sizeRecvData, u16 i2cId);
extern int iWriteRegI2C(u8 *a_pSendData, u16 a_sizeSendData, u16 i2cId);
extern int iWriteReg(u16 a_u2Addr, u32 a_u4Data, u32 a_u4Bytes, u16 i2cId);
#endif
@@ -0,0 +1,3 @@
# SPDX-License-Identifier: GPL-2.0
obj-y += gc2366mipi_Sensor.o
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,163 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
*/
/*****************************************************************************
*
* Filename:
* ---------
* GC2366mipi_Sensor.h
*
* Project:
* --------
* ALPS
*
* Description:
* ------------
* CMOS sensor header file
*
****************************************************************************/
#define IMAGE_NO_MIRROR
/* #define IMAGE_H_MIRROR */
/* #define IMAGE_V_MIRROR */
/* #define IMAGE_HV_MIRROR */
#ifdef IMAGE_NO_MIRROR
#define MIRROR 0xc0
#define STARTY 0x03
#define STARTX 0x02
#endif
#ifdef IMAGE_H_MIRROR
#define MIRROR 0xc1
#define STARTY 0x03
#define STARTX 0x05
#endif
#ifdef IMAGE_V_MIRROR
#define MIRROR 0xc2
#define STARTY 0x02
#define STARTX 0x02
#endif
#ifdef IMAGE_HV_MIRROR
#define MIRROR 0xc3
#define STARTY 0x02
#define STARTX 0x05
#endif
#ifndef _GC2366MIPI_SENSOR_H
#define _GC2366MIPI_SENSOR_H
enum IMGSENSOR_MODE {
IMGSENSOR_MODE_INIT,
IMGSENSOR_MODE_PREVIEW,
IMGSENSOR_MODE_CAPTURE,
IMGSENSOR_MODE_VIDEO,
IMGSENSOR_MODE_HIGH_SPEED_VIDEO,
IMGSENSOR_MODE_SLIM_VIDEO,
};
struct imgsensor_mode_struct {
kal_uint32 pclk; /* record different mode's pclk */
kal_uint32 linelength; /* record different mode's linelength */
kal_uint32 framelength; /* record different mode's framelength */
kal_uint8 startx; /* record different mode's startx of grabwindow */
kal_uint8 starty; /* record different mode's startx of grabwindow */
kal_uint16
grabwindow_width; /* record different mode's width of grabwindow */
kal_uint16 grabwindow_height; /* record different mode's height of
grabwindow */
/* following for MIPIDataLowPwr2HighSpeedSettleDelayCount by
* different scenario */
kal_uint8 mipi_data_lp2hs_settle_dc;
/* following for GetDefaultFramerateByScenario() */
kal_uint16 max_framerate;
};
/* SENSOR PRIVATE STRUCT FOR VARIABLES*/
struct imgsensor_struct {
kal_uint8 mirror; /* mirrorflip information */
kal_uint8 sensor_mode; /* record IMGSENSOR_MODE enum value */
kal_uint32 shutter; /* current shutter */
kal_uint16 gain; /* current gain */
kal_uint32 pclk; /* current pclk */
kal_uint32 frame_length; /* current framelength */
kal_uint32 line_length; /* current linelength */
kal_uint32
min_frame_length; /* current min framelength to max framerate */
kal_uint16 dummy_pixel; /* current dummypixel */
kal_uint16 dummy_line; /* current dummline */
kal_uint16 current_fps; /* current max fps */
kal_bool autoflicker_en; /* record autoflicker enable or disable */
kal_bool test_pattern; /* record test pattern mode or not */
enum MSDK_SCENARIO_ID_ENUM current_scenario_id;
kal_uint8 ihdr_en; /* ihdr enable or disable */
kal_uint8 i2c_write_id; /* record current sensor's i2c write id */
};
/* SENSOR PRIVATE STRUCT FOR CONSTANT*/
struct imgsensor_info_struct {
kal_uint32 sensor_id; /* record sensor id defined in Kd_imgsensor.h */
kal_uint32 checksum_value; /* checksum value for Camera Auto Test */
struct imgsensor_mode_struct
pre; /* preview scenario relative information */
struct imgsensor_mode_struct
cap; /* capture scenario relative information */
struct imgsensor_mode_struct cap1;
struct imgsensor_mode_struct
normal_video; /* normal video scenario relative information */
struct imgsensor_mode_struct
hs_video; /* high speed video scenario relative information */
struct imgsensor_mode_struct
slim_video; /* slim video for VT scenario relative information */
kal_uint8 ae_shut_delay_frame; /* shutter delay frame for AE cycle */
kal_uint8 ae_sensor_gain_delay_frame; /* sensor gain delay frame for AE
cycle */
kal_uint8
ae_ispGain_delay_frame; /* isp gain delay frame for AE cycle */
kal_uint8 ihdr_support; /* 1, support; 0,not support */
kal_uint8 ihdr_le_firstline; /* 1,le first ; 0, se first */
kal_uint8 sensor_mode_num; /* support sensor mode num */
kal_uint8 cap_delay_frame; /* enter capture delay frame num */
kal_uint8 pre_delay_frame; /* enter preview delay frame num */
kal_uint8 video_delay_frame; /* enter video delay frame num */
kal_uint8
hs_video_delay_frame; /* enter high speed video delay frame num */
kal_uint8 slim_video_delay_frame; /* enter slim video delay frame num */
kal_uint8 margin; /* sensor framelength & shutter margin */
kal_uint32 min_shutter; /* min shutter */
kal_uint32 max_frame_length; /* max framelength by sensor register's
limitation */
kal_uint8 isp_driving_current; /* mclk driving current */
kal_uint8 sensor_interface_type; /* sensor_interface_type */
kal_uint8 mipi_sensor_type;
kal_uint8 mipi_settle_delay_mode;
kal_uint8
sensor_output_dataformat; /* sensor output first pixel color */
kal_uint8 mclk; /* mclk value, suggest 24 or 26 for 24Mhz or 26Mhz */
kal_uint8 mipi_lane_num; /* mipi lane num */
kal_uint8 i2c_addr_table[5];
};
extern int iReadRegI2C(u8 *a_pSendData, u16 a_sizeSendData, u8 *a_pRecvData,
u16 a_sizeRecvData, u16 i2cId);
extern int iWriteRegI2C(u8 *a_pSendData, u16 a_sizeSendData, u16 i2cId);
extern int iWriteReg(u16 a_u2Addr, u32 a_u4Data, u32 a_u4Bytes, u16 i2cId);
#endif
@@ -0,0 +1,3 @@
# SPDX-License-Identifier: GPL-2.0
obj-y += gc2375mipi_Sensor.o
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,157 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#define IMAGE_NORMAL_MIRROR
/* #define IMAGE_H_MIRROR */
/* #define IMAGE_V_MIRROR */
/* #define IMAGE_HV_MIRROR */
#ifdef IMAGE_NORMAL_MIRROR
#define MIRROR 0xd4
#define STARTY 0x01
#define STARTX 0x01
#define BLK_Select1_H 0x00
#define BLK_Select1_L 0x3c
#define BLK_Select2_H 0x00
#define BLK_Select2_L 0x03
#endif
#ifdef IMAGE_H_MIRROR
#define MIRROR 0xd5
#define STARTY 0x01
#define STARTX 0x00
#define BLK_Select1_H 0x00
#define BLK_Select1_L 0x3c
#define BLK_Select2_H 0x00
#define BLK_Select2_L 0x03
#endif
#ifdef IMAGE_V_MIRROR
#define MIRROR 0xd6
#define STARTY 0x02
#define STARTX 0x01
#define BLK_Select1_H 0x3c
#define BLK_Select1_L 0x00
#define BLK_Select2_H 0xc0
#define BLK_Select2_L 0x00
#endif
#ifdef IMAGE_HV_MIRROR
#define MIRROR 0xd7
#define STARTY 0x02
#define STARTX 0x00
#define BLK_Select1_H 0x3c
#define BLK_Select1_L 0x00
#define BLK_Select2_H 0xc0
#define BLK_Select2_L 0x00
#endif
#ifndef _GC2375MIPI_SENSOR_H
#define _GC2375MIPI_SENSOR_H
enum IMGSENSOR_MODE {
IMGSENSOR_MODE_INIT,
IMGSENSOR_MODE_PREVIEW,
IMGSENSOR_MODE_CAPTURE,
IMGSENSOR_MODE_VIDEO,
IMGSENSOR_MODE_HIGH_SPEED_VIDEO,
IMGSENSOR_MODE_SLIM_VIDEO,
};
struct imgsensor_mode_struct {
kal_uint32 pclk; /* record different mode's pclk */
kal_uint32 linelength; /* record different mode's linelength */
kal_uint32 framelength; /* record different mode's framelength */
kal_uint8 startx;
kal_uint8 starty;
/* record different mode's width of grabwindow */
kal_uint16 grabwindow_width;
/* record different mode's height of grabwindow */
kal_uint16 grabwindow_height;
/* following for MIPIDataLowPwr2HighSpeedSettleDelayCount by scenario */
kal_uint8 mipi_data_lp2hs_settle_dc;
kal_uint32 mipi_pixel_rate; /* record the mipi pixel rate */
/* following for GetDefaultFramerateByScenario() */
kal_uint16 max_framerate;
};
/* SENSOR PRIVATE STRUCT FOR VARIABLES*/
struct imgsensor_struct {
kal_uint8 mirror; /* mirrorflip information */
kal_uint8 sensor_mode; /* record IMGSENSOR_MODE enum value */
kal_uint32 shutter; /* current shutter */
kal_uint16 gain; /* current gain */
kal_uint32 pclk; /* current pclk */
kal_uint32 frame_length; /* current framelength */
kal_uint32 line_length; /* current linelength */
/* current min framelength to max framerate */
kal_uint32 min_frame_length;
kal_uint16 dummy_pixel; /* current dummypixel */
kal_uint16 dummy_line; /* current dummline */
kal_uint16 current_fps; /* current max fps */
kal_bool autoflicker_en;
kal_bool test_pattern; /* record test pattern mode or not */
enum MSDK_SCENARIO_ID_ENUM current_scenario_id;
kal_uint8 ihdr_en; /* ihdr enable or disable */
kal_uint8 i2c_write_id; /* record current sensor's i2c write id */
};
/* SENSOR PRIVATE STRUCT FOR CONSTANT*/
struct imgsensor_info_struct {
kal_uint32 sensor_id;
kal_uint32 checksum_value;
struct imgsensor_mode_struct pre;
struct imgsensor_mode_struct cap;
struct imgsensor_mode_struct cap1;
struct imgsensor_mode_struct normal_video;
struct imgsensor_mode_struct hs_video;
struct imgsensor_mode_struct slim_video;
kal_uint8 ae_shut_delay_frame; /* shutter delay frame for AE cycle */
kal_uint8 ae_sensor_gain_delay_frame;
kal_uint8 ae_ispGain_delay_frame;
kal_uint8 ihdr_support; /* 1, support; 0,not support */
kal_uint8 ihdr_le_firstline; /* 1,le first ; 0, se first */
kal_uint8 sensor_mode_num; /* support sensor mode num */
kal_uint8 cap_delay_frame; /* enter capture delay frame num */
kal_uint8 pre_delay_frame; /* enter preview delay frame num */
kal_uint8 video_delay_frame; /* enter video delay frame num */
kal_uint8 hs_video_delay_frame;
kal_uint8 slim_video_delay_frame;
kal_uint8 margin; /* sensor framelength & shutter margin */
kal_uint32 min_shutter; /* min shutter */
kal_uint32 max_frame_length;
kal_uint8 isp_driving_current; /* mclk driving current */
kal_uint8 sensor_interface_type; /* sensor_interface_type */
kal_uint8 mipi_sensor_type;
kal_uint8 mipi_settle_delay_mode;
kal_uint8 sensor_output_dataformat;
kal_uint8 mclk;
kal_uint8 mipi_lane_num; /* mipi lane num */
kal_uint8 i2c_addr_table[5];
};
extern int iReadRegI2C(u8 *a_pSendData, u16 a_sizeSendData,
u8 *a_pRecvData, u16 a_sizeRecvData, u16 i2cId);
extern int iWriteRegI2C(u8 *a_pSendData, u16 a_sizeSendData, u16 i2cId);
extern int iWriteReg(u16 a_u2Addr, u32 a_u4Data, u32 a_u4Bytes, u16 i2cId);
#endif
@@ -0,0 +1,3 @@
# SPDX-License-Identifier: GPL-2.0
obj-y += gc2375hmipi_Sensor.o
@@ -0,0 +1,123 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
*/
/*****************************************************************************
*
* Filename:
* ---------
* gc2375hmipi_Sensor.h
*
* Project:
* --------
* ALPS
*
* Description:
* ------------
* CMOS sensor header file
*
****************************************************************************/
#ifndef _GC2375HMIPI_SENSOR_H
#define _GC2375HMIPI_SENSOR_H
/* SENSOR MIRROR FLIP INFO */
#define GC2375H_MIRROR_FLIP_ENABLE 0
#if GC2375H_MIRROR_FLIP_ENABLE
#define GC2375H_MIRROR 0xd7
#define GC2375H_BLK_Select1_H 0x3c
#define GC2375H_BLK_Select1_L 0x00
#define GC2375H_BLK_Select2_H 0xc0
#define GC2375H_BLK_Select2_L 0x00
#else
#define GC2375H_MIRROR 0xd4
#define GC2375H_BLK_Select1_H 0x00
#define GC2375H_BLK_Select1_L 0x3c
#define GC2375H_BLK_Select2_H 0x00
#define GC2375H_BLK_Select2_L 0x03
#endif
enum IMGSENSOR_MODE {
IMGSENSOR_MODE_INIT,
IMGSENSOR_MODE_PREVIEW,
IMGSENSOR_MODE_CAPTURE,
IMGSENSOR_MODE_VIDEO,
IMGSENSOR_MODE_HIGH_SPEED_VIDEO,
IMGSENSOR_MODE_SLIM_VIDEO,
};
struct imgsensor_mode_struct {
kal_uint32 pclk;
kal_uint32 linelength;
kal_uint32 framelength;
kal_uint8 startx;
kal_uint8 starty;
kal_uint16 grabwindow_width;
kal_uint16 grabwindow_height;
kal_uint8 mipi_data_lp2hs_settle_dc;
kal_uint32 mipi_pixel_rate;
kal_uint16 max_framerate;
};
/* SENSOR PRIVATE STRUCT FOR VARIABLES */
struct imgsensor_struct {
kal_uint8 mirror;
kal_uint8 sensor_mode;
kal_uint32 shutter;
kal_uint16 gain;
kal_uint32 pclk;
kal_uint32 frame_length;
kal_uint32 line_length;
kal_uint32 min_frame_length;
kal_uint16 dummy_pixel;
kal_uint16 dummy_line;
kal_uint16 current_fps;
kal_bool autoflicker_en;
kal_uint8 test_pattern;
enum MSDK_SCENARIO_ID_ENUM current_scenario_id;
kal_uint8 ihdr_en;
kal_uint8 i2c_write_id;
};
/* SENSOR PRIVATE STRUCT FOR CONSTANT */
struct imgsensor_info_struct {
kal_uint32 sensor_id;
kal_uint32 checksum_value;
struct imgsensor_mode_struct pre;
struct imgsensor_mode_struct cap;
struct imgsensor_mode_struct cap1;
struct imgsensor_mode_struct normal_video;
struct imgsensor_mode_struct hs_video;
struct imgsensor_mode_struct slim_video;
kal_uint8 ae_shut_delay_frame;
kal_uint8 ae_sensor_gain_delay_frame;
kal_uint8 ae_ispGain_delay_frame;
kal_uint8 ihdr_support;
kal_uint8 ihdr_le_firstline;
kal_uint8 sensor_mode_num;
kal_uint8 cap_delay_frame;
kal_uint8 pre_delay_frame;
kal_uint8 video_delay_frame;
kal_uint8 hs_video_delay_frame;
kal_uint8 slim_video_delay_frame;
kal_uint8 margin;
kal_uint32 min_shutter;
kal_uint32 max_frame_length;
kal_uint8 isp_driving_current;
kal_uint8 sensor_interface_type;
kal_uint8 mipi_sensor_type;
kal_uint8 mipi_settle_delay_mode;
kal_uint8 sensor_output_dataformat;
kal_uint8 mclk;
kal_uint8 mipi_lane_num;
kal_uint8 i2c_addr_table[5];
};
extern int iReadRegI2C(u8 *a_pSendData, u16 a_sizeSendData,
u8 *a_pRecvData, u16 a_sizeRecvData, u16 i2cId);
extern int iWriteRegI2C(u8 *a_pSendData, u16 a_sizeSendData, u16 i2cId);
extern int iWriteReg(u16 a_u2Addr, u32 a_u4Data, u32 a_u4Bytes, u16 i2cId);
#endif
@@ -0,0 +1,3 @@
# SPDX-License-Identifier: GPL-2.0
obj-y += gc5035mipi_Sensor.o
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,244 @@
/* SPDX-License-Identifier: GPL-2.0*/
/*
* Copyright (c) 2019 MediaTek Inc.
*/
/*****************************************************************************
*
* Filename:
* ---------
* gc5035mipi_Sensor.h
*
* Project:
* --------
* ALPS
*
* Description:
* ------------
* CMOS sensor header file
*
****************************************************************************/
#ifndef __GC5035MIPI_SENSOR_H__
#define __GC5035MIPI_SENSOR_H__
/* SENSOR MIRROR FLIP INFO */
#define GC5035_MIRROR_FLIP_ENABLE 0
#if GC5035_MIRROR_FLIP_ENABLE
#define GC5035_MIRROR 0x83
#define GC5035_RSTDUMMY1 0x03
#define GC5035_RSTDUMMY2 0xfc
#else
#define GC5035_MIRROR 0x80
#define GC5035_RSTDUMMY1 0x02
#define GC5035_RSTDUMMY2 0x7c
#endif
/* SENSOR PRIVATE INFO FOR GAIN SETTING */
#define GC5035_SENSOR_GAIN_BASE 256
#define GC5035_SENSOR_GAIN_MAX (16 * GC5035_SENSOR_GAIN_BASE)
#define GC5035_SENSOR_GAIN_MAX_VALID_INDEX 17
#define GC5035_SENSOR_GAIN_MAP_SIZE 17
#define GC5035_SENSOR_DGAIN_BASE 0x100
/* SENSOR PRIVATE INFO FOR OTP SETTINGS */
#define GC5035_OTP_FOR_CUSTOMER 0
#define GC5035_OTP_DEBUG 0
/* DEBUG */
#if GC5035_OTP_DEBUG
#define GC5035_OTP_START_ADDR 0x0000
#endif
#define GC5035_OTP_DATA_LENGTH 1024
/* OTP FLAG TYPE */
#define GC5035_OTP_FLAG_EMPTY 0x00
#define GC5035_OTP_FLAG_VALID 0x01
#define GC5035_OTP_FLAG_INVALID 0x02
#define GC5035_OTP_FLAG_INVALID2 0x03
#define GC5035_OTP_GET_OFFSET(size) (size << 3)
#define GC5035_OTP_GET_2BIT_FLAG(flag, bit) ((flag >> bit) & 0x03)
#define GC5035_OTP_CHECK_1BIT_FLAG(flag, bit) \
(((flag >> bit) & 0x01) == GC5035_OTP_FLAG_VALID)
#define GC5035_OTP_ID_SIZE 9
#define GC5035_OTP_ID_DATA_OFFSET 0x0020
/* OTP DPC PARAMETERS */
#define GC5035_OTP_DPC_FLAG_OFFSET 0x0068
#define GC5035_OTP_DPC_TOTAL_NUMBER_OFFSET 0x0070
#define GC5035_OTP_DPC_ERROR_NUMBER_OFFSET 0x0078
/* OTP REGISTER UPDATE PARAMETERS */
#define GC5035_OTP_REG_FLAG_OFFSET 0x0880
#define GC5035_OTP_REG_DATA_OFFSET 0x0888
#define GC5035_OTP_REG_MAX_GROUP 5
#define GC5035_OTP_REG_BYTE_PER_GROUP 5
#define GC5035_OTP_REG_REG_PER_GROUP 2
#define GC5035_OTP_REG_BYTE_PER_REG 2
#define GC5035_OTP_REG_DATA_SIZE \
(GC5035_OTP_REG_MAX_GROUP * GC5035_OTP_REG_BYTE_PER_GROUP)
#define GC5035_OTP_REG_REG_SIZE \
(GC5035_OTP_REG_MAX_GROUP * GC5035_OTP_REG_REG_PER_GROUP)
#if GC5035_OTP_FOR_CUSTOMER
#define GC5035_OTP_CHECK_SUM_BYTE 1
#define GC5035_OTP_GROUP_CNT 2
/* OTP MODULE INFO PARAMETERS */
#define GC5035_OTP_MODULE_FLAG_OFFSET 0x1f10
#define GC5035_OTP_MODULE_DATA_OFFSET 0x1f18
#define GC5035_OTP_MODULE_DATA_SIZE 6
/* OTP WB PARAMETERS */
#define GC5035_OTP_WB_FLAG_OFFSET 0x1f78
#define GC5035_OTP_WB_DATA_OFFSET 0x1f80
#define GC5035_OTP_WB_DATA_SIZE 4
#define GC5035_OTP_GOLDEN_DATA_OFFSET 0x1fc0
#define GC5035_OTP_GOLDEN_DATA_SIZE 4
#define GC5035_OTP_WB_CAL_BASE 0x0800
#define GC5035_OTP_WB_GAIN_BASE 0x0400
/* WB TYPICAL VALUE 0.5 */
#define GC5035_OTP_WB_RG_TYPICAL 0x0400
#define GC5035_OTP_WB_BG_TYPICAL 0x0400
#endif
enum {
otp_close = 0,
otp_open,
};
/* DPC STRUCTURE */
struct gc5035_dpc_t {
kal_uint8 flag;
kal_uint16 total_num;
};
struct gc5035_reg_t {
kal_uint8 page;
kal_uint8 addr;
kal_uint8 value;
};
/* REGISTER UPDATE STRUCTURE */
struct gc5035_reg_update_t {
kal_uint8 flag;
kal_uint8 cnt;
struct gc5035_reg_t reg[GC5035_OTP_REG_REG_SIZE];
};
#if GC5035_OTP_FOR_CUSTOMER
/* MODULE INFO STRUCTURE */
struct gc5035_module_info_t {
kal_uint8 module_id;
kal_uint8 lens_id;
kal_uint8 year;
kal_uint8 month;
kal_uint8 day;
};
/* WB STRUCTURE */
struct gc5035_wb_t {
kal_uint8 flag;
kal_uint16 rg;
kal_uint16 bg;
};
#endif
/* OTP STRUCTURE */
struct gc5035_otp_t {
kal_uint8 otp_id[GC5035_OTP_ID_SIZE];
struct gc5035_dpc_t dpc;
struct gc5035_reg_update_t regs;
#if GC5035_OTP_FOR_CUSTOMER
struct gc5035_wb_t wb;
struct gc5035_wb_t golden;
#endif
};
enum {
IMGSENSOR_MODE_INIT,
IMGSENSOR_MODE_PREVIEW,
IMGSENSOR_MODE_CAPTURE,
IMGSENSOR_MODE_VIDEO,
IMGSENSOR_MODE_HIGH_SPEED_VIDEO,
IMGSENSOR_MODE_SLIM_VIDEO,
};
struct imgsensor_mode_struct {
kal_uint32 pclk; /* record different mode's pclk */
kal_uint32 linelength; /* record different mode's linelength */
kal_uint32 framelength;
kal_uint8 startx;
kal_uint8 starty;
kal_uint16 grabwindow_width;
kal_uint16 grabwindow_height;
kal_uint32 mipi_pixel_rate;
kal_uint8 mipi_data_lp2hs_settle_dc;
/* following for GetDefaultFramerateByScenario() */
kal_uint16 max_framerate;
};
/* SENSOR PRIVATE STRUCT FOR VARIABLES */
struct imgsensor_struct {
kal_uint8 mirror;
kal_uint8 sensor_mode;
kal_uint32 shutter;
kal_uint16 gain;
kal_uint32 pclk;
kal_uint32 frame_length;
kal_uint32 line_length;
kal_uint32 min_frame_length;
kal_uint16 dummy_pixel;
kal_uint16 dummy_line;
kal_uint16 current_fps;
kal_bool autoflicker_en;
kal_uint8 test_pattern;
enum MSDK_SCENARIO_ID_ENUM current_scenario_id;
kal_uint8 ihdr_en;
kal_uint8 i2c_write_id;
};
/* SENSOR PRIVATE STRUCT FOR CONSTANT */
struct imgsensor_info_struct {
kal_uint32 sensor_id;
kal_uint32 checksum_value;
struct imgsensor_mode_struct pre;
struct imgsensor_mode_struct cap;
struct imgsensor_mode_struct cap1;
struct imgsensor_mode_struct cap2;
struct imgsensor_mode_struct normal_video;
struct imgsensor_mode_struct hs_video;
struct imgsensor_mode_struct slim_video;
kal_uint8 ae_shut_delay_frame;
kal_uint8 ae_sensor_gain_delay_frame;
kal_uint8 ae_ispGain_delay_frame;
kal_uint8 ihdr_support;
kal_uint8 ihdr_le_firstline;
kal_uint8 sensor_mode_num;
kal_uint8 cap_delay_frame;
kal_uint8 pre_delay_frame;
kal_uint8 video_delay_frame;
kal_uint8 hs_video_delay_frame;
kal_uint8 slim_video_delay_frame;
kal_uint8 margin;
kal_uint32 min_shutter;
kal_uint32 max_frame_length;
kal_uint8 isp_driving_current;
kal_uint8 sensor_interface_type;
kal_uint8 mipi_sensor_type;
kal_uint8 mipi_settle_delay_mode;
kal_uint8 sensor_output_dataformat;
kal_uint8 mclk;
kal_uint8 mipi_lane_num;
kal_uint8 i2c_addr_table[5];
};
extern int iReadRegI2C(u8 *a_pSendData, u16 a_sizeSendData,
u8 *a_pRecvData, u16 a_sizeRecvData, u16 i2cId);
extern int iWriteRegI2C(u8 *a_pSendData, u16 a_sizeSendData, u16 i2cId);
extern int iWriteReg(u16 a_u2Addr, u32 a_u4Data, u32 a_u4Bytes, u16 i2cId);
#endif
@@ -0,0 +1,6 @@
# SPDX-License-Identifier: GPL-2.0
#include $(srctree)/drivers/misc/mediatek/Makefile.custom
obj-y += gc8034_mipi_Sensor.o
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,252 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#ifndef __GC8034MIPI_SENSOR_H__
#define __GC8034MIPI_SENSOR_H__
#undef GC8034_MIRROR_NORMAL
#undef GC8034_MIRROR_H
#undef GC8034_MIRROR_V
#undef GC8034_MIRROR_HV
#define GC8034_MIRROR_NORMAL
#if defined(GC8034_MIRROR_NORMAL)
#define GC8034_MIRROR 0xc0
#define GC8034_BinStartY 0x04
#define GC8034_BinStartX 0x05
#define GC8034_FullStartY 0x08
#define GC8034_FullStartX 0x09
#elif defined(GC8034_MIRROR_H)
#define GC8034_MIRROR 0xc1
#define GC8034_BinStartY 0x04
#define GC8034_BinStartX 0x05
#define GC8034_FullStartY 0x08
#define GC8034_FullStartX 0x0b
#elif defined(GC8034_MIRROR_V)
#define GC8034_MIRROR 0xc2
#define GC8034_BinStartY 0x04
#define GC8034_BinStartX 0x05
#define GC8034_FullStartY 0x08
#define GC8034_FullStartX 0x09
#elif defined(GC8034_MIRROR_HV)
#define GC8034_MIRROR 0xc3
#define GC8034_BinStartY 0x04
#define GC8034_BinStartX 0x05
#define GC8034_FullStartY 0x08
#define GC8034_FullStartX 0x0b
#else
#define GC8034_MIRROR 0xc0
#define GC8034_BinStartY 0x04
#define GC8034_BinStartX 0x05
#define GC8034_FullStartY 0x08
#define GC8034_FullStartX 0x09
#endif
enum {
IMGSENSOR_MODE_INIT,
IMGSENSOR_MODE_PREVIEW,
IMGSENSOR_MODE_CAPTURE,
IMGSENSOR_MODE_VIDEO,
IMGSENSOR_MODE_HIGH_SPEED_VIDEO,
IMGSENSOR_MODE_SLIM_VIDEO,
};
struct imgsensor_mode_struct {
kal_uint32
pclk; /*record different mode's pclk*/
kal_uint32
linelength; /*record different mode's linelength*/
kal_uint32
framelength; /*record different mode's framelength*/
kal_uint8
startx; /*record different mode's startx of grabwindow*/
kal_uint8
starty; /*record different mode's startx of grabwindow*/
kal_uint16
grabwindow_width; /*record different mode's width of grabwindow*/
kal_uint16
grabwindow_height; /*record different mode's height of grabwindow*/
/* following for MIPIDataLowPwr2HighSpeedSettleDelayCount by different scenario */
kal_uint8 mipi_data_lp2hs_settle_dc;
kal_uint32 mipi_pixel_rate;
/* following for GetDefaultFramerateByScenario() */
kal_uint16 max_framerate;
};
/* SENSOR PRIVATE STRUCT FOR VARIABLES*/
struct imgsensor_struct {
kal_uint8
mirror; /*mirrorflip information*/
kal_uint8
sensor_mode; /*record IMGSENSOR_MODE enum value*/
kal_uint32 shutter; /*current shutter*/
kal_uint16 gain; /*current gain*/
kal_uint32 pclk; /*current pclk*/
kal_uint32 frame_length; /*current framelength*/
kal_uint32 line_length; /*current linelength*/
kal_uint32
min_frame_length; /*current min framelength to max framerate*/
kal_uint16 dummy_pixel; /*current dummypixel*/
kal_uint16 dummy_line; /*current dummline*/
kal_uint16 current_fps; /*current max fps*/
kal_bool
autoflicker_en; /*record autoflicker enable or disable*/
kal_bool
test_pattern; /*record test pattern mode or not*/
enum MSDK_SCENARIO_ID_ENUM
current_scenario_id;/*current scenario id*/
kal_bool
ihdr_en; /*ihdr enable or disable*/
kal_uint8
i2c_write_id; /*record current sensor's i2c write id*/
};
/* SENSOR PRIVATE STRUCT FOR CONSTANT*/
struct imgsensor_info_struct {
kal_uint32
sensor_id; /*record sensor id defined in Kd_imgsensor.h*/
kal_uint32
checksum_value; /*checksum value for Camera Auto Test*/
struct imgsensor_mode_struct
pre; /*preview scenario relative information*/
struct imgsensor_mode_struct
cap; /*capture scenario relative information*/
struct imgsensor_mode_struct cap1;
/*capture for PIP 24fps relative information, */
/*capture1 mode must use same framelength, */
/*linelength with Capture mode for shutter calculate*/
struct imgsensor_mode_struct cap2;
struct imgsensor_mode_struct
normal_video; /*normal video scenario relative information*/
struct imgsensor_mode_struct
hs_video; /*high speed video scenario relative information*/
struct imgsensor_mode_struct
slim_video; /*slim video for VT scenario relative information*/
kal_uint8
ae_shut_delay_frame; /*shutter delay frame for AE cycle*/
kal_uint8
ae_sensor_gain_delay_frame; /*sensor gain delay frame for AE cycle*/
kal_uint8
ae_ispGain_delay_frame; /*isp gain delay frame for AE cycle*/
kal_uint8
ihdr_support; /*1, support; 0,not support*/
kal_uint8
ihdr_le_firstline; /*1,le first ; 0, se first*/
kal_uint8
sensor_mode_num; /*support sensor mode num*/
kal_uint8
cap_delay_frame; /*enter capture delay frame num*/
kal_uint8
pre_delay_frame; /*enter preview delay frame num*/
kal_uint8
video_delay_frame; /*enter video delay frame num*/
kal_uint8
hs_video_delay_frame; /*enter high speed video delay frame num*/
kal_uint8
slim_video_delay_frame; /*enter slim video delay frame num*/
kal_uint8
margin; /*sensor framelength & shutter margin*/
kal_uint32 min_shutter; /*min shutter*/
kal_uint32
max_frame_length; /*max framelength by sensor register's limitation*/
kal_uint8
isp_driving_current; /*mclk driving current*/
kal_uint8
sensor_interface_type; /*sensor_interface_type*/
kal_uint8 mipi_sensor_type;
/*0,MIPI_OPHY_NCSI2; 1,MIPI_OPHY_CSI2, default is NCSI2, don't modify this para*/
/*don't modify this para*/
kal_uint8 mipi_settle_delay_mode;
/*0, high speed signal auto detect; 1, use settle delay,unit is ns, */
kal_uint8
sensor_output_dataformat; /*sensor output first pixel color*/
kal_uint8
mclk; /*mclk value, suggest 24 or 26 for 24Mhz or 26Mhz*/
kal_uint8 mipi_lane_num; /*mipi lane num*/
kal_uint8 i2c_addr_table[5];
/*record sensor support all write id addr, only supprt 4must end with 0xff*/
};
#define SENSOR_BASE_GAIN 0x40
#define SENSOR_MAX_GAIN (16 * SENSOR_BASE_GAIN)
#define MAX_AG_INDEX 9
#define MEAG_INDEX 7
#define AGC_REG_NUM 14
#define GC8034OTP_FOR_CUSTOMER
/* Please do not enable the following micro definition, if you are not debuging otp function*/
#undef GC8034OTP_DEBUG
#define DD_WIDTH 3284
#define DD_HEIGHT 2464
#if defined(GC8034OTP_FOR_CUSTOMER)
#define RG_TYPICAL 0x0400
#define BG_TYPICAL 0x0400
#define AF_ROM_START 0x3b
#define AF_WIDTH 0x04
#define INFO_ROM_START 0x70
#define INFO_WIDTH 0x08
#define WB_ROM_START 0x5f
#define WB_WIDTH 0x04
#define GOLDEN_ROM_START 0x67
#define GOLDEN_WIDTH 0x04
#define LSC_NUM 99 /* (7+2)*(9+2) */
#endif
struct gc8034_dd_t {
kal_uint16 x;
kal_uint16 y;
kal_uint16 t;
};
struct gc8034_otp_t {
kal_uint8 dd_cnt;
kal_uint8 dd_flag;
struct gc8034_dd_t dd_param[160];
kal_uint8 reg_flag;
kal_uint8 reg_num;
kal_uint8 reg_page[10];
kal_uint8 reg_addr[10];
kal_uint8 reg_value[10];
#if defined(GC8034OTP_FOR_CUSTOMER)
kal_uint8 module_id;
kal_uint8 lens_id;
kal_uint8 vcm_id;
kal_uint8 vcm_driver_id;
kal_uint8 year;
kal_uint8 month;
kal_uint8 day;
kal_uint8 af_flag;
kal_uint16 af_infinity;
kal_uint16 af_macro;
kal_uint8 wb_flag;
kal_uint16 rg_gain;
kal_uint16 bg_gain;
kal_uint8 golden_flag;
kal_uint16 golden_rg;
kal_uint16 golden_bg;
kal_uint8 lsc_flag; /* 0:Empty 1:Success 2:Invalid */
kal_uint8 lsc_param[396];
#endif
};
enum {
otp_close = 0,
otp_open,
};
extern int iReadRegI2C(u8 *a_pSendData, u16 a_sizeSendData,
u8 *a_pRecvData, u16 a_sizeRecvData, u16 i2cId);
extern int iWriteRegI2C(u8 *a_pSendData, u16 a_sizeSendData,
u16 i2cId);
extern int iWriteReg(u16 a_u2Addr, u32 a_u4Data, u32 a_u4Bytes,
u16 i2cId);
#ifdef CONFIG_IMPROVE_CAMERA_PERFORMANCE
extern void kdSetI2CSpeed(u32 i2cSpeed);
#endif
#endif
@@ -0,0 +1,5 @@
# SPDX-License-Identifier: GPL-2.0
obj-y += gc8c34mipi_Sensor.o
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,256 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#ifndef _GC8C34MIPI_SENSOR_H
#define _GC8C34MIPI_SENSOR_H
#undef GC8C34_MIRROR_NORMAL
#undef GC8C34_MIRROR_H
#undef GC8C34_MIRROR_V
#undef GC8C34_MIRROR_HV
#define GC8C34_MIRROR_NORMAL
#if defined(GC8C34_MIRROR_NORMAL)
#define MIRROR 0xe8
#define BinStartY 0x06
#define BinStartX 0x05
#elif defined(GC8C34_MIRROR_H)
#define MIRROR 0xe9
#define BinStartY 0x06
#define BinStartX 0x05
#elif defined(GC8C34_MIRROR_V)
#define MIRROR 0xea
#define BinStartY 0x06
#define BinStartX 0x05
#elif defined(GC8C34_MIRROR_HV)
#define MIRROR 0xeb
#define BinStartY 0x06
#define BinStartX 0x05
#else
#define MIRROR 0xe8
#define BinStartY 0x06
#define BinStartX 0x05
#endif
struct gc_register {
kal_uint8 addr;
kal_uint8 value;
};
#define MAX_GAIN_MAP 10
#define AGC_REG_NUM 15
#define LSC_X_GRID 7
#define LSC_Y_GRID 11
struct agc_params_struct {
kal_uint16 gain_level;
struct gc_register agc_register[AGC_REG_NUM];
};
#define SENSOR_BASE_GAIN 0x40
#define SENSOR_MAX_GAIN (32*0x40)
#define GC8C34OTP_FOR_CUSTOMER
/* Please do not enable the following micro definition, if you are not debuging otp function */
#undef GC8C34OTP_DEBUG
#define OB_ROM_START 0x69
#define OB_WIDTH 0x06
#define DD_WIDTH 1642
#define DD_HEIGHT 1236
#if defined(GC8C34OTP_FOR_CUSTOMER)
#define RG_TYPICAL 0x045E
#define BG_TYPICAL 0x056D
#define AF_ROM_START 0x6b
#define AF_WIDTH 0x04
#define INFO_ROM_START 0x70
#define INFO_WIDTH 0x08
#define WB_ROM_START 0x5f
#define WB_WIDTH 0x04
#define GOLDEN_ROM_START 0x67
#define GOLDEN_WIDTH 0x04
#define LSC_NUM 77 /* 7x11 */
#endif
struct gc8c34_dd_t {
kal_uint16 x;
kal_uint16 y;
kal_uint16 t;
};
struct gc8c34_otp {
kal_uint8 dd_cnt;
kal_uint8 dd_flag;
kal_uint8 ob_flag;
kal_int32 g_active;
kal_int32 g_dark;
struct gc8c34_dd_t dd_param[160];
kal_uint8 reg_flag;
kal_uint8 reg_num;
kal_uint8 reg_page[10];
kal_uint8 reg_addr[10];
kal_uint8 reg_value[10];
#if defined(GC8C34OTP_FOR_CUSTOMER)
kal_uint8 module_id;
kal_uint8 lens_id;
kal_uint8 vcm_id;
kal_uint8 vcm_driver_id;
kal_uint8 year;
kal_uint8 month;
kal_uint8 day;
kal_uint8 af_flag;
kal_uint16 af_infinity;
kal_uint16 af_macro;
kal_uint8 wb_flag;
kal_uint16 rg_gain;
kal_uint16 bg_gain;
kal_uint8 golden_flag;
kal_uint16 golden_rg;
kal_uint16 golden_bg;
kal_uint8 lsc_flag; /* 0:Empty 1:Success 2:Invalid */
kal_uint8 lsc_param[308];
#endif
};
enum {
otp_close = 0,
otp_open,
};
enum {
IMGSENSOR_MODE_INIT,
IMGSENSOR_MODE_PREVIEW,
IMGSENSOR_MODE_CAPTURE,
IMGSENSOR_MODE_VIDEO,
IMGSENSOR_MODE_HIGH_SPEED_VIDEO,
IMGSENSOR_MODE_SLIM_VIDEO,
};
struct imgsensor_mode_struct {
kal_uint32 pclk; /* record different mode's pclk */
kal_uint32 linelength; /* record different mode's linelength */
kal_uint32
framelength; /* record different mode's framelength */
kal_uint8 startx; /* record different mode's startx of grabwindow */
kal_uint8 starty; /* record different mode's startx of grabwindow */
kal_uint16
grabwindow_width; /* record different mode's width of grabwindow */
kal_uint16
grabwindow_height; /* record different mode's height of grabwindow */
/* following for MIPIDataLowPwr2HighSpeedSettleDelayCount by different scenario */
kal_uint8 mipi_data_lp2hs_settle_dc;
/* following for GetDefaultFramerateByScenario() */
kal_uint32 mipi_pixel_rate;
kal_uint16 max_framerate;
};
/* SENSOR PRIVATE STRUCT FOR VARIABLES*/
struct imgsensor_struct {
kal_uint8 mirror; /*mirrorflip information*/
kal_uint8 sensor_mode; /*record IMGSENSOR_MODE enum value*/
kal_uint32 shutter; /*current shutter*/
kal_uint16 gain; /*current gain*/
kal_uint32 pclk; /*current pclk*/
kal_uint32 frame_length; /*current framelength*/
kal_uint32 line_length; /*current linelength*/
kal_uint32
min_frame_length; /*current min framelength to max framerate*/
kal_uint16 dummy_pixel; /*current dummypixel*/
kal_uint16 dummy_line; /*current dummline*/
kal_uint16 current_fps; /*current max fps*/
kal_bool autoflicker_en; /*record autoflicker enable or disable*/
kal_bool test_pattern; /*record test pattern mode or not*/
enum MSDK_SCENARIO_ID_ENUM
current_scenario_id;/*current scenario id*/
kal_bool ihdr_en; /*ihdr enable or disable*/
kal_uint8 i2c_write_id; /*record current sensor's i2c write id*/
};
/* SENSOR PRIVATE STRUCT FOR CONSTANT */
struct imgsensor_info_struct {
kal_uint32
sensor_id; /* record sensor id defined in Kd_imgsensor.h */
kal_uint32
checksum_value; /* checksum value for Camera Auto Test */
struct imgsensor_mode_struct
pre; /* preview scenario relative information */
struct imgsensor_mode_struct
cap; /* capture scenario relative information */
struct imgsensor_mode_struct
cap1; /* capture for PIP 24fps relative information, */
/* capture1 mode must use same framelength, */
/* linelength with Capture mode for shutter calculate */
struct imgsensor_mode_struct cap2;
struct imgsensor_mode_struct
normal_video; /* normal video scenario relative information */
struct imgsensor_mode_struct
hs_video; /* high speed video scenario relative information */
struct imgsensor_mode_struct
slim_video; /* slim video for VT scenario relative information */
kal_uint8
ae_shut_delay_frame; /* shutter delay frame for AE cycle */
kal_uint8
ae_sensor_gain_delay_frame; /* sensor gain delay frame for AE cycle */
kal_uint8
ae_ispGain_delay_frame; /* isp gain delay frame for AE cycle */
kal_uint8 ihdr_support; /* 1, support; 0,not support */
kal_uint8 ihdr_le_firstline; /* 1,le first ; 0, se first */
kal_uint8 sensor_mode_num; /* support sensor mode num */
kal_uint8
cap_delay_frame; /* enter capture delay frame num */
kal_uint8
pre_delay_frame; /* enter preview delay frame num */
kal_uint8
video_delay_frame; /* enter video delay frame num */
kal_uint8
hs_video_delay_frame; /* enter high speed video delay frame num */
kal_uint8
slim_video_delay_frame; /* enter slim video delay frame num */
kal_uint8
margin; /* sensor framelength & shutter margin */
kal_uint32 min_shutter; /* min shutter */
kal_uint32
max_frame_length; /* max framelength by sensor register's limitation */
kal_uint8 isp_driving_current; /* mclk driving current */
kal_uint8 sensor_interface_type; /* sensor_interface_type */
kal_uint8
mipi_sensor_type; /* 0,MIPI_OPHY_NCSI2; 1,MIPI_OPHY_CSI2 */
/* default is NCSI2, don't modify this para */
kal_uint8
mipi_settle_delay_mode; /* 0, high speed signal auto detect; 1, use settle delay,unit is ns */
/* default is auto detect, don't modify this para */
kal_uint8
sensor_output_dataformat; /* sensor output first pixel color */
kal_uint8
mclk; /* mclk value, suggest 24 or 26 for 24Mhz or 26Mhz */
kal_uint8 mipi_lane_num; /* mipi lane num */
kal_uint8
i2c_addr_table[5]; /* record sensor support all write id addr, only supprt 4must end with 0xff */
};
extern int iReadRegI2C(u8 *a_pSendData, u16 a_sizeSendData,
u8 *a_pRecvData, u16 a_sizeRecvData, u16 i2cId);
extern int iWriteRegI2C(u8 *a_pSendData, u16 a_sizeSendData,
u16 i2cId);
extern int iWriteReg(u16 a_u2Addr, u32 a_u4Data, u32 a_u4Bytes,
u16 i2cId);
#ifdef CONFIG_IMPROVE_CAMERA_PERFORMANCE
extern void kdSetI2CSpeed(u32 i2cSpeed);
#endif
#endif
@@ -0,0 +1,3 @@
# SPDX-License-Identifier: GPL-2.0
obj-y += hi556mipiraw_Sensor.o
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,149 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
*/
/*****************************************************************************
*
* Filename:
* ---------
* hi556mipi_Sensor.h
*
* Project:
* --------
* ALPS
*
* Description:
* ------------
* CMOS sensor header file
*
****************************************************************************/
#ifndef _HI556MIPI_SENSOR_H
#define _HI556MIPI_SENSOR_H
#include "kd_camera_typedef.h"
#include "kd_imgsensor.h"
#include "kd_imgsensor_define.h"
#include "kd_imgsensor_errcode.h"
enum{
IMGSENSOR_MODE_INIT,
IMGSENSOR_MODE_PREVIEW,
IMGSENSOR_MODE_CAPTURE,
IMGSENSOR_MODE_VIDEO,
IMGSENSOR_MODE_HIGH_SPEED_VIDEO,
IMGSENSOR_MODE_SLIM_VIDEO,
IMGSENSOR_MODE_CUSTOM1,
IMGSENSOR_MODE_CUSTOM2,
IMGSENSOR_MODE_CUSTOM3,
IMGSENSOR_MODE_CUSTOM4,
IMGSENSOR_MODE_CUSTOM5,
} IMGSENSOR_MODE;
struct imgsensor_mode_struct {
kal_uint32 pclk;
kal_uint32 linelength;
kal_uint32 framelength;
kal_uint8 startx;
kal_uint8 starty;
kal_uint16 grabwindow_width;
kal_uint16 grabwindow_height;
kal_uint8 mipi_data_lp2hs_settle_dc;
/* following for GetDefaultFramerateByScenario() */
kal_uint16 max_framerate;
} imgsensor_mode_struct;
/* SENSOR PRIVATE STRUCT FOR VARIABLES*/
struct imgsensor_struct {
kal_uint8 mirror; //mirrorflip information
kal_uint8 sensor_mode; //record IMGSENSOR_MODE enum value
kal_uint32 shutter; //current shutter
kal_uint16 gain; //current gain
kal_uint32 pclk; //current pclk
kal_uint32 frame_length; //current framelength
kal_uint32 line_length; //current linelength
kal_uint32 min_frame_length; //current min framelength to max
kal_int32 dummy_pixel; //current dummypixel
kal_int32 dummy_line; //current dummline
kal_uint16 current_fps; //current max fps
kal_bool autoflicker_en; //record autoflicker enable or disable
kal_bool test_pattern; //record test pattern mode or not
enum MSDK_SCENARIO_ID_ENUM current_scenario_id; //current scenario
kal_bool ihdr_en; //ihdr enable or disable
kal_uint8 i2c_write_id; //record current sensor's i2c write id
} imgsensor_struct;
/* SENSOR PRIVATE STRUCT FOR CONSTANT*/
struct imgsensor_info_struct {
kal_uint16 sensor_id; //record sensor id defined in Kd_imgsensor.h
kal_uint32 checksum_value; //checksum value for Camera Auto Test
struct imgsensor_mode_struct pre; //preview scenario
struct imgsensor_mode_struct cap; //capture scenario
struct imgsensor_mode_struct cap1; //capture for PIP 24fps
struct imgsensor_mode_struct cap2; //capture for PIP 15ps
struct imgsensor_mode_struct normal_video;//normal video info
struct imgsensor_mode_struct hs_video; //high speed video relative info
struct imgsensor_mode_struct slim_video; //slim video for VT
struct imgsensor_mode_struct custom1; //custom1 scenario relative info
struct imgsensor_mode_struct custom2; //custom2 scenario relative info
struct imgsensor_mode_struct custom3; //custom3 scenario relative info
struct imgsensor_mode_struct custom4; //custom4 scenario relative info
struct imgsensor_mode_struct custom5; //custom5 scenario relative info
kal_uint8 ae_shut_delay_frame; //shutter delay frame for AE cycle
kal_uint8 ae_sensor_gain_delay_frame; //sensorgaindelfra for AEcycle
kal_uint8 ae_ispGain_delay_frame; //ispgaindelayframe for AEcycle
kal_uint8 ihdr_support; //1, support; 0,not support
kal_uint8 ihdr_le_firstline; //1,le first ; 0, se first
kal_uint8 sensor_mode_num; //support sensor mode num
kal_uint8 cap_delay_frame; //enter capture delay frame num
kal_uint8 pre_delay_frame; //enter preview delay frame num
kal_uint8 video_delay_frame; //enter video delay frame num
kal_uint8 hs_video_delay_frame; //enter high speed videodelayframenum
kal_uint8 slim_video_delay_frame; //enter slim video delay frame num
kal_uint8 custom1_delay_frame; //enter custom1 delay frame num
kal_uint8 custom2_delay_frame; //enter custom1 delay frame num
kal_uint8 custom3_delay_frame; //enter custom1 delay frame num
kal_uint8 custom4_delay_frame; //enter custom1 delay frame num
kal_uint8 custom5_delay_frame; //enter custom1 delay frame num
kal_uint8 margin; //sensor framelength & shutter margin
kal_uint32 min_shutter; //min shutter
kal_uint32 max_frame_length; //maxframelengthbysensor reg's limitation
kal_uint8 isp_driving_current; //mclk driving current
kal_uint8 sensor_interface_type;//sensor_interface_type
kal_uint8 mipi_sensor_type;
kal_uint8 mipi_settle_delay_mode;
kal_uint8 sensor_output_dataformat;
kal_uint8 mclk;
kal_uint8 mipi_lane_num; //mipi lane num
kal_uint8 i2c_addr_table[5];
kal_uint32 i2c_speed; //i2c speed
} imgsensor_info_struct;
extern int iReadRegI2C(u8 *a_pSendData, u16 a_sizeSendData, u8 *a_pRecvData,
u16 a_sizeRecvData, u16 i2cId);
extern int iWriteRegI2C(u8 *a_pSendData, u16 a_sizeSendData, u16 i2cId);
extern void kdSetI2CSpeed(u16 i2cSpeed);
extern int iBurstWriteReg(u8 *pData, u32 bytes, u16 i2cId);
extern int iBurstWriteReg_multi(u8 *pData, u32 bytes, u16 i2cId,
u16 transfer_length, u16 timing);
#endif
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,70 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#ifndef __IMGSENSOR_H__
#define __IMGSENSOR_H__
#define IMGSENSOR_DEVICE_NNUMBER 255
#include "imgsensor_common.h"
#include "imgsensor_i2c.h"
#include "imgsensor_hw.h"
#include "imgsensor_clk.h"
struct IMGSENSOR_STATUS {
u32 reserved:31;
u32 oc:1;
};
struct IMGSENSOR {
struct IMGSENSOR_STATUS status;
struct IMGSENSOR_HW hw;
struct IMGSENSOR_CLK clk;
struct IMGSENSOR_SENSOR sensor[IMGSENSOR_SENSOR_IDX_MAX_NUM];
atomic_t imgsensor_open_cnt;
enum IMGSENSOR_RETURN (*imgsensor_oc_irq_enable)
(enum IMGSENSOR_SENSOR_IDX sensor_idx, bool enable);
/*for driving current control*/
enum IMGSENSOR_RETURN (*mclk_set_drive_current)
(void *pinstance,
enum IMGSENSOR_SENSOR_IDX sensor_idx,
enum ISP_DRIVING_CURRENT_ENUM drive_current);
#ifdef DFS_CTRL_BY_OPP
struct imgsensor_dfs_ctx dfs_ctx;
#endif
};
MINT32
imgsensor_sensor_open(struct IMGSENSOR_SENSOR *psensor);
MINT32
imgsensor_sensor_close(struct IMGSENSOR_SENSOR *psensor);
MUINT32
imgsensor_sensor_get_info(
struct IMGSENSOR_SENSOR *psensor,
MUINT32 ScenarioId,
MSDK_SENSOR_INFO_STRUCT *pSensorInfo,
MSDK_SENSOR_CONFIG_STRUCT *pSensorConfigData);
MUINT32
imgsensor_sensor_get_resolution(
struct IMGSENSOR_SENSOR *psensor,
MSDK_SENSOR_RESOLUTION_INFO_STRUCT *pSensorResolution);
MUINT32
imgsensor_sensor_feature_control(
struct IMGSENSOR_SENSOR *psensor,
MSDK_SENSOR_FEATURE_ENUM FeatureId,
MUINT8 *pFeaturePara,
MUINT32 *pFeatureParaLen);
MUINT32
imgsensor_sensor_control(
struct IMGSENSOR_SENSOR *psensor,
enum MSDK_SCENARIO_ID_ENUM ScenarioId);
#endif
@@ -0,0 +1,50 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#ifndef __IMGSENSOR_COMMON_H__
#define __IMGSENSOR_COMMON_H__
#define PREFIX "[imgsensor]"
#define pr_fmt(fmt) PREFIX "[%s] " fmt, __func__
#include "kd_camera_feature.h"
#include "kd_imgsensor_define.h"
/************************************************************************
* Debug configuration
************************************************************************/
#define PREFIX "[imgsensor]"
#define DEBUG_CAMERA_HW_K
#ifdef DEBUG_CAMERA_HW_K
#define PK_DBG(fmt, arg...) pr_debug(PREFIX fmt, ##arg)
#define PK_INFO(fmt, arg...) pr_debug(PREFIX fmt, ##arg)
#else
#define PK_DBG(fmt, arg...)
#define PK_INFO(fmt, arg...) pr_debug(PREFIX fmt, ##arg)
#endif
#define PLATFORM_POWER_SEQ_NAME "platform_power_seq"
#define DEBUG_CAMERA_HW_K
#define IMGSENSOR_LEGACY_COMPAT
#define IMGSENSOR_TOSTRING(value) #value
#define IMGSENSOR_STRINGIZE(stringizedName) IMGSENSOR_TOSTRING(stringizedName)
enum IMGSENSOR_ARCH {
IMGSENSOR_ARCH_V1 = 0,
IMGSENSOR_ARCH_V2,
IMGSENSOR_ARCH_V3
};
enum IMGSENSOR_RETURN {
IMGSENSOR_RETURN_SUCCESS = 0,
IMGSENSOR_RETURN_ERROR = -1,
};
#define LENGTH_FOR_SNPRINTF 256
#endif
@@ -0,0 +1,218 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#include "imgsensor_sensor.h"
#include <linux/atomic.h>
#include <linux/delay.h>
#include <linux/string.h>
#include "kd_camera_typedef.h"
#include "kd_camera_feature.h"
#include "imgsensor_hw.h"
enum IMGSENSOR_RETURN imgsensor_hw_release_all(struct IMGSENSOR_HW *phw)
{
int i;
for (i = 0; i < IMGSENSOR_HW_ID_MAX_NUM; i++) {
if (phw->pdev[i]->release != NULL)
(phw->pdev[i]->release)(phw->pdev[i]->pinstance);
}
return IMGSENSOR_RETURN_SUCCESS;
}
enum IMGSENSOR_RETURN imgsensor_hw_init(struct IMGSENSOR_HW *phw)
{
struct IMGSENSOR_HW_SENSOR_POWER *psensor_pwr;
struct IMGSENSOR_HW_CFG *pcust_pwr_cfg;
struct IMGSENSOR_HW_CUSTOM_POWER_INFO *ppwr_info;
int i, j;
char str_prop_name[LENGTH_FOR_SNPRINTF];
struct device_node *of_node
= of_find_compatible_node(NULL, NULL, "mediatek,camera_hw");
for (i = 0; i < IMGSENSOR_HW_ID_MAX_NUM; i++) {
if (hw_open[i] != NULL)
(hw_open[i])(&phw->pdev[i]);
if (phw->pdev[i]->init != NULL)
(phw->pdev[i]->init)(phw->pdev[i]->pinstance);
}
for (i = 0; i < IMGSENSOR_SENSOR_IDX_MAX_NUM; i++) {
psensor_pwr = &phw->sensor_pwr[i];
pcust_pwr_cfg = imgsensor_custom_config;
while (pcust_pwr_cfg->sensor_idx != i &&
pcust_pwr_cfg->sensor_idx != IMGSENSOR_SENSOR_IDX_NONE)
pcust_pwr_cfg++;
if (pcust_pwr_cfg->sensor_idx == IMGSENSOR_SENSOR_IDX_NONE)
continue;
ppwr_info = pcust_pwr_cfg->pwr_info;
while (ppwr_info->pin != IMGSENSOR_HW_PIN_NONE) {
for (j = 0; j < IMGSENSOR_HW_ID_MAX_NUM; j++)
if (ppwr_info->id == phw->pdev[j]->id)
break;
psensor_pwr->id[ppwr_info->pin] = j;
ppwr_info++;
}
}
for (i = 0; i < IMGSENSOR_SENSOR_IDX_MAX_NUM; i++) {
memset(str_prop_name, 0, sizeof(str_prop_name));
snprintf(str_prop_name,
sizeof(str_prop_name),
"cam%d_%s",
i,
"enable_sensor");
if (of_property_read_string(
of_node,
str_prop_name,
&phw->enable_sensor_by_index[i]) < 0) {
pr_info("Property cust-sensor not defined\n");
phw->enable_sensor_by_index[i] = NULL;
}
}
return IMGSENSOR_RETURN_SUCCESS;
}
static enum IMGSENSOR_RETURN imgsensor_hw_power_sequence(
struct IMGSENSOR_HW *phw,
enum IMGSENSOR_SENSOR_IDX sensor_idx,
enum IMGSENSOR_HW_POWER_STATUS pwr_status,
struct IMGSENSOR_HW_POWER_SEQ *ppower_sequence,
char *pcurr_idx)
{
struct IMGSENSOR_HW_SENSOR_POWER *psensor_pwr =
&phw->sensor_pwr[sensor_idx];
struct IMGSENSOR_HW_POWER_SEQ *ppwr_seq = ppower_sequence;
struct IMGSENSOR_HW_POWER_INFO *ppwr_info;
struct IMGSENSOR_HW_DEVICE *pdev;
int pin_cnt = 0;
while (ppwr_seq < ppower_sequence + IMGSENSOR_HW_SENSOR_MAX_NUM &&
ppwr_seq->name != NULL) {
if (!strcmp(ppwr_seq->name, PLATFORM_POWER_SEQ_NAME)) {
if (sensor_idx == ppwr_seq->_idx)
break;
} else {
if (!strcmp(ppwr_seq->name, pcurr_idx))
break;
}
ppwr_seq++;
}
if (ppwr_seq->name == NULL)
return IMGSENSOR_RETURN_ERROR;
ppwr_info = ppwr_seq->pwr_info;
while (ppwr_info->pin != IMGSENSOR_HW_PIN_NONE &&
ppwr_info < ppwr_seq->pwr_info + IMGSENSOR_HW_POWER_INFO_MAX) {
if (pwr_status == IMGSENSOR_HW_POWER_STATUS_ON &&
ppwr_info->pin != IMGSENSOR_HW_PIN_UNDEF) {
pdev = phw->pdev[psensor_pwr->id[ppwr_info->pin]];
/*pr_debug(
* "sensor_idx = %d, pin=%d, pin_state_on=%d, hw_id =%d\n",
* sensor_idx,
* ppwr_info->pin,
* ppwr_info->pin_state_on,
* psensor_pwr->id[ppwr_info->pin]);
*/
if (pdev->set != NULL)
pdev->set(
pdev->pinstance,
sensor_idx,
ppwr_info->pin,
ppwr_info->pin_state_on);
mdelay(ppwr_info->pin_on_delay);
}
ppwr_info++;
pin_cnt++;
}
if (pwr_status == IMGSENSOR_HW_POWER_STATUS_OFF) {
while (pin_cnt) {
ppwr_info--;
pin_cnt--;
if (ppwr_info->pin != IMGSENSOR_HW_PIN_UNDEF) {
pdev =
phw->pdev[psensor_pwr->id[ppwr_info->pin]];
mdelay(ppwr_info->pin_on_delay);
if (pdev->set != NULL)
pdev->set(
pdev->pinstance,
sensor_idx,
ppwr_info->pin,
ppwr_info->pin_state_off);
}
}
}
/* wait for power stable */
if (pwr_status == IMGSENSOR_HW_POWER_STATUS_ON)
mdelay(5);
return IMGSENSOR_RETURN_SUCCESS;
}
enum IMGSENSOR_RETURN imgsensor_hw_power(
struct IMGSENSOR_HW *phw,
struct IMGSENSOR_SENSOR *psensor,
char *curr_sensor_name,
enum IMGSENSOR_HW_POWER_STATUS pwr_status)
{
enum IMGSENSOR_SENSOR_IDX sensor_idx = psensor->inst.sensor_idx;
char str_index[LENGTH_FOR_SNPRINTF];
int ret = 0;
pr_info(
"sensor_idx %d, power %d curr_sensor_name %s, enable list %s\n",
sensor_idx,
pwr_status,
curr_sensor_name,
phw->enable_sensor_by_index[(uint32_t)sensor_idx] == NULL
? "NULL"
: phw->enable_sensor_by_index[(uint32_t)sensor_idx]);
if (phw->enable_sensor_by_index[(uint32_t)sensor_idx] &&
!strstr(phw->enable_sensor_by_index[(uint32_t)sensor_idx], curr_sensor_name))
return IMGSENSOR_RETURN_ERROR;
ret = snprintf(str_index, sizeof(str_index), "%d", sensor_idx);
if (ret == 0) {
pr_info("Error! snprintf allocate 0");
ret = IMGSENSOR_RETURN_ERROR;
return ret;
}
imgsensor_hw_power_sequence(
phw,
sensor_idx,
pwr_status,
platform_power_sequence,
str_index);
imgsensor_hw_power_sequence(
phw,
sensor_idx,
pwr_status,
sensor_power_sequence,
curr_sensor_name);
return IMGSENSOR_RETURN_SUCCESS;
}
@@ -0,0 +1,39 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#ifndef __IMGSENSOR_PWR_CTRL_H__
#define __IMGSENSOR_PWR_CTRL_H__
#include "imgsensor_sensor.h"
#include "imgsensor_cfg_table.h"
#include "imgsensor_common.h"
enum IMGSENSOR_HW_POWER_STATUS {
IMGSENSOR_HW_POWER_STATUS_OFF,
IMGSENSOR_HW_POWER_STATUS_ON
};
struct IMGSENSOR_HW_SENSOR_POWER {
struct IMGSENSOR_HW_POWER_INFO *ppwr_info;
enum IMGSENSOR_HW_ID id[IMGSENSOR_HW_PIN_MAX_NUM];
};
struct IMGSENSOR_HW {
struct IMGSENSOR_HW_DEVICE *pdev[IMGSENSOR_HW_ID_MAX_NUM];
struct IMGSENSOR_HW_SENSOR_POWER
sensor_pwr[IMGSENSOR_SENSOR_IDX_MAX_NUM];
const char *enable_sensor_by_index[IMGSENSOR_SENSOR_IDX_MAX_NUM];
};
enum IMGSENSOR_RETURN imgsensor_hw_init(struct IMGSENSOR_HW *phw);
enum IMGSENSOR_RETURN imgsensor_hw_release_all(struct IMGSENSOR_HW *phw);
enum IMGSENSOR_RETURN imgsensor_hw_power(
struct IMGSENSOR_HW *phw,
struct IMGSENSOR_SENSOR *psensor,
char *curr_sensor_name,
enum IMGSENSOR_HW_POWER_STATUS pwr_status);
#endif
@@ -0,0 +1,275 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#include "imgsensor_common.h"
#include "imgsensor_i2c.h"
#include <linux/ratelimit.h>
struct IMGSENSOR_I2C gi2c;
static const struct i2c_device_id gi2c_dev_id[] = {
{IMGSENSOR_I2C_DRV_NAME_0, 0},
{IMGSENSOR_I2C_DRV_NAME_1, 0},
{IMGSENSOR_I2C_DRV_NAME_2, 0},
{}
};
#ifdef CONFIG_OF
static const struct of_device_id gof_device_id_0[] = {
{ .compatible = IMGSENSOR_I2C_OF_DRV_NAME_0, },
{}
};
static const struct of_device_id gof_device_id_1[] = {
{ .compatible = IMGSENSOR_I2C_OF_DRV_NAME_1, },
{}
};
static const struct of_device_id gof_device_id_2[] = {
{ .compatible = IMGSENSOR_I2C_OF_DRV_NAME_2, },
{}
};
#endif
static int
imgsensor_i2c_probe_0(struct i2c_client *client, const struct i2c_device_id *id)
{
gi2c.inst[IMGSENSOR_I2C_DEV_0].pi2c_client = client;
return 0;
}
static int
imgsensor_i2c_probe_1(struct i2c_client *client, const struct i2c_device_id *id)
{
gi2c.inst[IMGSENSOR_I2C_DEV_1].pi2c_client = client;
return 0;
}
static int
imgsensor_i2c_probe_2(struct i2c_client *client, const struct i2c_device_id *id)
{
gi2c.inst[IMGSENSOR_I2C_DEV_2].pi2c_client = client;
return 0;
}
static int imgsensor_i2c_remove(struct i2c_client *client)
{
return 0;
}
static struct i2c_driver gi2c_driver[IMGSENSOR_I2C_DEV_MAX_NUM] = {
{
.probe = imgsensor_i2c_probe_0,
.remove = imgsensor_i2c_remove,
.driver = {
.name = IMGSENSOR_I2C_DRV_NAME_0,
.owner = THIS_MODULE,
#ifdef CONFIG_OF
.of_match_table = gof_device_id_0,
#endif
},
.id_table = gi2c_dev_id,
},
{
.probe = imgsensor_i2c_probe_1,
.remove = imgsensor_i2c_remove,
.driver = {
.name = IMGSENSOR_I2C_DRV_NAME_1,
.owner = THIS_MODULE,
#ifdef CONFIG_OF
.of_match_table = gof_device_id_1,
#endif
},
.id_table = gi2c_dev_id,
},
{
.probe = imgsensor_i2c_probe_2,
.remove = imgsensor_i2c_remove,
.driver = {
.name = IMGSENSOR_I2C_DRV_NAME_2,
.owner = THIS_MODULE,
#ifdef CONFIG_OF
.of_match_table = gof_device_id_2,
#endif
},
.id_table = gi2c_dev_id,
}
};
enum IMGSENSOR_RETURN imgsensor_i2c_create(void)
{
int i;
for (i = 0; i < IMGSENSOR_I2C_DEV_MAX_NUM; i++)
i2c_add_driver(&gi2c_driver[i]);
return IMGSENSOR_RETURN_SUCCESS;
}
enum IMGSENSOR_RETURN imgsensor_i2c_delete(void)
{
int i;
for (i = 0; i < IMGSENSOR_I2C_DEV_MAX_NUM; i++)
i2c_del_driver(&gi2c_driver[i]);
return IMGSENSOR_RETURN_SUCCESS;
}
enum IMGSENSOR_RETURN imgsensor_i2c_init(
struct IMGSENSOR_I2C_CFG *pi2c_cfg,
enum IMGSENSOR_I2C_DEV device)
{
if (!pi2c_cfg ||
device >= IMGSENSOR_I2C_DEV_MAX_NUM)
return IMGSENSOR_RETURN_ERROR;
pi2c_cfg->pinst = &gi2c.inst[device];
pi2c_cfg->pi2c_driver = &gi2c_driver[device];
mutex_init(&pi2c_cfg->i2c_mutex);
return IMGSENSOR_RETURN_SUCCESS;
}
#ifndef NO_I2C_MTK
enum IMGSENSOR_RETURN imgsensor_i2c_buffer_mode(int enable)
{
struct IMGSENSOR_I2C_INST *pinst =
&gi2c.inst[IMGSENSOR_I2C_BUFF_MODE_DEV];
enum IMGSENSOR_RETURN ret = IMGSENSOR_RETURN_SUCCESS;
pr_debug("i2c_buf_mode_en %d\n", enable);
ret = (enable) ?
hw_trig_i2c_enable(pinst->pi2c_client->adapter) :
hw_trig_i2c_disable(pinst->pi2c_client->adapter);
return ret;
}
#else
enum IMGSENSOR_RETURN imgsensor_i2c_buffer_mode(int enable)
{
pr_info("not support i2c_buf_mode\n");
return IMGSENSOR_RETURN_SUCCESS;
}
#endif
enum IMGSENSOR_RETURN imgsensor_i2c_read(
struct IMGSENSOR_I2C_CFG *pi2c_cfg,
u8 *pwrite_data,
u16 write_length,
u8 *pread_data,
u16 read_length,
u16 id,
int speed)
{
struct IMGSENSOR_I2C_INST *pinst = pi2c_cfg->pinst;
enum IMGSENSOR_RETURN ret = IMGSENSOR_RETURN_SUCCESS;
mutex_lock(&pi2c_cfg->i2c_mutex);
pinst->msg[0].addr = id >> 1;
pinst->msg[0].flags = 0;
pinst->msg[0].len = write_length;
pinst->msg[0].buf = pwrite_data;
pinst->msg[1].addr = id >> 1;
pinst->msg[1].flags = I2C_M_RD;
pinst->msg[1].len = read_length;
pinst->msg[1].buf = pread_data;
if (mtk_i2c_transfer(
pinst->pi2c_client->adapter,
pinst->msg,
IMGSENSOR_I2C_MSG_SIZE_READ,
(pi2c_cfg->pinst->status.filter_msg) ? I2C_A_FILTER_MSG : 0,
((speed > 0) && (speed <= 1000))
? speed * 1000 : IMGSENSOR_I2C_SPEED * 1000)
!= IMGSENSOR_I2C_MSG_SIZE_READ) {
static DEFINE_RATELIMIT_STATE(ratelimit, 1 * HZ, 30);
if (__ratelimit(&ratelimit))
pr_info(
"I2C read failed (0x%x)! speed(0=%d) (0x%x)\n",
ret,
speed,
*pwrite_data);
ret = IMGSENSOR_RETURN_ERROR;
}
mutex_unlock(&pi2c_cfg->i2c_mutex);
return ret;
}
enum IMGSENSOR_RETURN imgsensor_i2c_write(
struct IMGSENSOR_I2C_CFG *pi2c_cfg,
u8 *pwrite_data,
u16 write_length,
u16 write_per_cycle,
u16 id,
int speed)
{
struct IMGSENSOR_I2C_INST *pinst = pi2c_cfg->pinst;
enum IMGSENSOR_RETURN ret = IMGSENSOR_RETURN_SUCCESS;
struct i2c_msg *pmsg = pinst->msg;
u8 *pdata = pwrite_data;
u8 *pend = pwrite_data + write_length;
int i = 0;
mutex_lock(&pi2c_cfg->i2c_mutex);
while (pdata < pend && i < IMGSENSOR_I2C_CMD_LENGTH_MAX) {
pmsg->addr = id >> 1;
pmsg->flags = 0;
pmsg->len = write_per_cycle;
pmsg->buf = pdata;
i++;
pmsg++;
pdata += write_per_cycle;
}
if (mtk_i2c_transfer(
pinst->pi2c_client->adapter,
pinst->msg,
i,
(pi2c_cfg->pinst->status.filter_msg) ? I2C_A_FILTER_MSG : 0,
((speed > 0) && (speed <= 1000))
? speed * 1000 : IMGSENSOR_I2C_SPEED * 1000)
!= i) {
static DEFINE_RATELIMIT_STATE(ratelimit, 1 * HZ, 30);
if (__ratelimit(&ratelimit))
pr_info(
"I2C write failed (0x%x)! speed(0=%d) (0x%x)\n",
ret,
speed,
*pwrite_data);
ret = IMGSENSOR_RETURN_ERROR;
}
mutex_unlock(&pi2c_cfg->i2c_mutex);
return ret;
}
void imgsensor_i2c_filter_msg(struct IMGSENSOR_I2C_CFG *pi2c_cfg, bool en)
{
pi2c_cfg->pinst->status.filter_msg = en;
}
#ifdef IMGSENSOR_LEGACY_COMPAT
struct IMGSENSOR_I2C_CFG *pgi2c_cfg_legacy;
void imgsensor_i2c_set_device(struct IMGSENSOR_I2C_CFG *pi2c_cfg)
{
pgi2c_cfg_legacy = pi2c_cfg;
}
#endif
@@ -0,0 +1,85 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#ifndef __IMGSENSOR_I2C_H__
#define __IMGSENSOR_I2C_H__
#include "imgsensor_common.h"
#include <linux/i2c.h>
#include <linux/mutex.h>
#ifndef NO_I2C_MTK
#include "i2c-mtk.h"
#else
#define mtk_i2c_transfer(adap, msgs, num, ext_flag, timing) \
i2c_transfer(adap, msgs, num)
#endif
#include "imgsensor_cfg_table.h"
#define IMGSENSOR_I2C_MSG_SIZE_READ 2
#define IMGSENSOR_I2C_BURST_WRITE_LENGTH MAX_DMA_TRANS_SIZE
#define IMGSENSOR_I2C_CMD_LENGTH_MAX 255
#define IMGSENSOR_I2C_BUFF_MODE_DEV IMGSENSOR_I2C_DEV_2
#ifdef IMGSENSOR_I2C_1000K
#define IMGSENSOR_I2C_SPEED 1000
#else
#define IMGSENSOR_I2C_SPEED 400
#endif
struct IMGSENSOR_I2C_STATUS {
u8 reserved:7;
u8 filter_msg:1;
};
struct IMGSENSOR_I2C_INST {
struct IMGSENSOR_I2C_STATUS status;
struct i2c_client *pi2c_client;
struct i2c_msg msg[IMGSENSOR_I2C_CMD_LENGTH_MAX];
};
struct IMGSENSOR_I2C_CFG {
struct IMGSENSOR_I2C_INST *pinst;
struct i2c_driver *pi2c_driver;
struct mutex i2c_mutex;
};
struct IMGSENSOR_I2C {
struct IMGSENSOR_I2C_INST inst[IMGSENSOR_I2C_DEV_MAX_NUM];
};
enum IMGSENSOR_RETURN imgsensor_i2c_create(void);
enum IMGSENSOR_RETURN imgsensor_i2c_delete(void);
enum IMGSENSOR_RETURN imgsensor_i2c_init(
struct IMGSENSOR_I2C_CFG *pi2c_cfg,
enum IMGSENSOR_I2C_DEV device);
enum IMGSENSOR_RETURN imgsensor_i2c_buffer_mode(int enable);
enum IMGSENSOR_RETURN imgsensor_i2c_read(
struct IMGSENSOR_I2C_CFG *pi2c_cfg,
u8 *pwrite_data,
u16 write_length,
u8 *pread_data,
u16 read_length,
u16 id,
int speed);
enum IMGSENSOR_RETURN imgsensor_i2c_write(
struct IMGSENSOR_I2C_CFG *pi2c_cfg,
u8 *pwrite_data,
u16 write_length,
u16 write_per_cycle,
u16 id,
int speed);
void imgsensor_i2c_filter_msg(struct IMGSENSOR_I2C_CFG *pi2c_cfg, bool en);
#ifdef IMGSENSOR_LEGACY_COMPAT
extern struct IMGSENSOR_I2C_CFG *pgi2c_cfg_legacy;
void imgsensor_i2c_set_device(struct IMGSENSOR_I2C_CFG *pi2c_cfg);
#endif
#endif
@@ -0,0 +1,105 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#include "kd_camera_typedef.h"
#include "imgsensor_i2c.h"
#ifdef IMGSENSOR_LEGACY_COMPAT
void kdSetI2CSpeed(u16 i2cSpeed)
{
}
int iReadRegI2C(
u8 *a_pSendData,
u16 a_sizeSendData,
u8 *a_pRecvData,
u16 a_sizeRecvData,
u16 i2cId)
{
return imgsensor_i2c_read(
pgi2c_cfg_legacy,
a_pSendData,
a_sizeSendData,
a_pRecvData,
a_sizeRecvData,
i2cId,
IMGSENSOR_I2C_SPEED);
}
int iReadRegI2CTiming(
u8 *a_pSendData,
u16 a_sizeSendData,
u8 *a_pRecvData,
u16 a_sizeRecvData,
u16 i2cId,
u16 timing)
{
return imgsensor_i2c_read(
pgi2c_cfg_legacy,
a_pSendData,
a_sizeSendData,
a_pRecvData,
a_sizeRecvData,
i2cId,
timing);
}
int iWriteRegI2C(u8 *a_pSendData, u16 a_sizeSendData, u16 i2cId)
{
return imgsensor_i2c_write(
pgi2c_cfg_legacy,
a_pSendData,
a_sizeSendData,
a_sizeSendData,
i2cId,
IMGSENSOR_I2C_SPEED);
}
int iWriteRegI2CTiming(
u8 *a_pSendData,
u16 a_sizeSendData,
u16 i2cId,
u16 timing)
{
return imgsensor_i2c_write(
pgi2c_cfg_legacy,
a_pSendData,
a_sizeSendData,
a_sizeSendData,
i2cId,
timing);
}
int iBurstWriteReg(u8 *pData, u32 bytes, u16 i2cId)
{
return imgsensor_i2c_write(
pgi2c_cfg_legacy,
pData,
bytes,
bytes,
i2cId,
IMGSENSOR_I2C_SPEED);
}
int iBurstWriteReg_multi(
u8 *pData,
u32 bytes,
u16 i2cId,
u16 transfer_length,
u16 timing)
{
return imgsensor_i2c_write(
pgi2c_cfg_legacy,
pData,
bytes,
transfer_length,
i2cId,
timing);
}
#endif
@@ -0,0 +1,524 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#include "imgsensor.h"
#include <linux/fs.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <linux/uaccess.h>
#include <linux/string.h>
#include "imgsensor_proc.h"
char mtk_ccm_name[camera_info_size] = { 0 };
char mtk_i2c_dump[camera_info_size] = { 0 };
static int pdaf_type_info_read(struct seq_file *m, void *v)
{
#define bufsz 512
unsigned int len = bufsz;
char pdaf_type_info[bufsz];
struct SENSOR_FUNCTION_STRUCT *psensor_func =
pgimgsensor->sensor[IMGSENSOR_SENSOR_IDX_MAIN].pfunc;
memset(pdaf_type_info, 0, 512);
if (psensor_func == NULL)
return 0;
psensor_func->SensorFeatureControl(
SENSOR_FEATURE_GET_PDAF_TYPE,
pdaf_type_info,
&len);
seq_printf(m, "%s\n", pdaf_type_info);
return 0;
};
static int proc_SensorType_open(struct inode *inode, struct file *file)
{
return single_open(file, pdaf_type_info_read, NULL);
};
static ssize_t proc_SensorType_write(
struct file *file,
const char *buffer,
size_t count,
loff_t *data)
{
char regBuf[64] = { '\0' };
u32 u4CopyBufSize =
(count < (sizeof(regBuf) - 1)) ? (count) : (sizeof(regBuf) - 1);
struct SENSOR_FUNCTION_STRUCT *psensor_func =
pgimgsensor->sensor[IMGSENSOR_SENSOR_IDX_MAIN].pfunc;
if (copy_from_user(regBuf, buffer, u4CopyBufSize))
return -EFAULT;
if (psensor_func)
psensor_func->SensorFeatureControl(
SENSOR_FEATURE_SET_PDAF_TYPE,
regBuf,
&u4CopyBufSize);
return count;
};
/************************************************************************
* CAMERA_HW_Reg_Debug()
* Used for sensor register read/write by proc file
************************************************************************/
static ssize_t CAMERA_HW_Reg_Debug(
struct file *file,
const char *buffer,
size_t count,
loff_t *data)
{
char regBuf[64] = { '\0' };
int ret = 0;
u32 u4CopyBufSize =
(count < (sizeof(regBuf) - 1)) ? (count) : (sizeof(regBuf) - 1);
struct IMGSENSOR_SENSOR *psensor =
&pgimgsensor->sensor[IMGSENSOR_SENSOR_IDX_MAIN];
MSDK_SENSOR_REG_INFO_STRUCT sensorReg;
memset(&sensorReg, 0, sizeof(MSDK_SENSOR_REG_INFO_STRUCT));
if (psensor == NULL || copy_from_user(regBuf, buffer, u4CopyBufSize))
return -EFAULT;
if (sscanf(
regBuf,
"%x %x",
&sensorReg.RegAddr,
&sensorReg.RegData) == 2) {
imgsensor_sensor_feature_control(
psensor,
SENSOR_FEATURE_SET_REGISTER,
(MUINT8 *) &sensorReg,
(MUINT32 *) sizeof(MSDK_SENSOR_REG_INFO_STRUCT));
imgsensor_sensor_feature_control(
psensor, SENSOR_FEATURE_GET_REGISTER,
(MUINT8 *) &sensorReg,
(MUINT32 *) sizeof(MSDK_SENSOR_REG_INFO_STRUCT));
pr_debug(
"write addr = 0x%08x, data = 0x%08x\n",
sensorReg.RegAddr,
sensorReg.RegData);
ret = snprintf(
mtk_i2c_dump,
sizeof(mtk_i2c_dump),
"addr = 0x%08x, data = 0x%08x\n",
sensorReg.RegAddr,
sensorReg.RegData);
if (ret == 0) {
pr_info("Error! snprintf allocate 0");
ret = IMGSENSOR_RETURN_ERROR;
return ret;
}
} else if (kstrtouint(regBuf, 16, &sensorReg.RegAddr) == 0) {
imgsensor_sensor_feature_control(
psensor,
SENSOR_FEATURE_GET_REGISTER,
(MUINT8 *) &sensorReg,
(MUINT32 *) sizeof(MSDK_SENSOR_REG_INFO_STRUCT));
pr_debug(
"read addr = 0x%08x, data = 0x%08x\n",
sensorReg.RegAddr,
sensorReg.RegData);
ret = snprintf(
mtk_i2c_dump,
sizeof(mtk_i2c_dump),
"addr = 0x%08x, data = 0x%08x\n",
sensorReg.RegAddr,
sensorReg.RegData);
if (ret == 0) {
pr_info("Error! snprintf allocate 0");
ret = IMGSENSOR_RETURN_ERROR;
return ret;
}
}
return count;
}
static ssize_t CAMERA_HW_Reg_Debug2(
struct file *file,
const char *buffer,
size_t count,
loff_t *data)
{
char regBuf[64] = { '\0' };
int ret = 0;
u32 u4CopyBufSize =
(count < (sizeof(regBuf) - 1)) ? (count) : (sizeof(regBuf) - 1);
struct IMGSENSOR_SENSOR *psensor =
&pgimgsensor->sensor[IMGSENSOR_SENSOR_IDX_SUB];
MSDK_SENSOR_REG_INFO_STRUCT sensorReg;
memset(&sensorReg, 0, sizeof(MSDK_SENSOR_REG_INFO_STRUCT));
if (psensor == NULL || copy_from_user(regBuf, buffer, u4CopyBufSize))
return -EFAULT;
if (sscanf(
regBuf,
"%x %x",
&sensorReg.RegAddr,
&sensorReg.RegData) == 2) {
imgsensor_sensor_feature_control(
psensor, SENSOR_FEATURE_SET_REGISTER,
(MUINT8 *) &sensorReg,
(MUINT32 *) sizeof(MSDK_SENSOR_REG_INFO_STRUCT));
imgsensor_sensor_feature_control(
psensor, SENSOR_FEATURE_GET_REGISTER,
(MUINT8 *) &sensorReg,
(MUINT32 *) sizeof(MSDK_SENSOR_REG_INFO_STRUCT));
pr_debug(
"write addr = 0x%08x, data = 0x%08x\n",
sensorReg.RegAddr,
sensorReg.RegData);
ret = snprintf(
mtk_i2c_dump,
sizeof(mtk_i2c_dump),
"addr = 0x%08x, data = 0x%08x\n",
sensorReg.RegAddr,
sensorReg.RegData);
if (ret == 0) {
pr_info("Error! snprintf allocate 0");
ret = IMGSENSOR_RETURN_ERROR;
return ret;
}
} else if (kstrtouint(regBuf, 16, &sensorReg.RegAddr) == 0) {
imgsensor_sensor_feature_control(
psensor,
SENSOR_FEATURE_GET_REGISTER,
(MUINT8 *) &sensorReg,
(MUINT32 *) sizeof(MSDK_SENSOR_REG_INFO_STRUCT));
pr_debug(
"read addr = 0x%08x, data = 0x%08x\n",
sensorReg.RegAddr,
sensorReg.RegData);
ret = snprintf(
mtk_i2c_dump,
sizeof(mtk_i2c_dump),
"addr = 0x%08x, data = 0x%08x\n",
sensorReg.RegAddr, sensorReg.RegData);
if (ret == 0) {
pr_info("Error! snprintf allocate 0");
ret = IMGSENSOR_RETURN_ERROR;
return ret;
}
}
return count;
}
static ssize_t CAMERA_HW_Reg_Debug3(
struct file *file,
const char *buffer,
size_t count,
loff_t *data)
{
char regBuf[64] = { '\0' };
int ret = 0;
u32 u4CopyBufSize =
(count < (sizeof(regBuf) - 1)) ? (count) : (sizeof(regBuf) - 1);
struct IMGSENSOR_SENSOR *psensor =
&pgimgsensor->sensor[IMGSENSOR_SENSOR_IDX_MAIN2];
MSDK_SENSOR_REG_INFO_STRUCT sensorReg;
memset(&sensorReg, 0, sizeof(MSDK_SENSOR_REG_INFO_STRUCT));
if (psensor == NULL || copy_from_user(regBuf, buffer, u4CopyBufSize))
return -EFAULT;
if (sscanf(
regBuf,
"%x %x",
&sensorReg.RegAddr,
&sensorReg.RegData) == 2) {
imgsensor_sensor_feature_control(
psensor,
SENSOR_FEATURE_SET_REGISTER,
(MUINT8 *) &sensorReg,
(MUINT32 *) sizeof(MSDK_SENSOR_REG_INFO_STRUCT));
imgsensor_sensor_feature_control(
psensor, SENSOR_FEATURE_GET_REGISTER,
(MUINT8 *) &sensorReg,
(MUINT32 *) sizeof(MSDK_SENSOR_REG_INFO_STRUCT));
pr_debug(
"write addr = 0x%08x, data = 0x%08x\n",
sensorReg.RegAddr,
sensorReg.RegData);
ret = snprintf(
mtk_i2c_dump,
sizeof(mtk_i2c_dump),
"addr = 0x%08x, data = 0x%08x\n",
sensorReg.RegAddr,
sensorReg.RegData);
if (ret == 0) {
pr_info("Error! snprintf allocate 0");
ret = IMGSENSOR_RETURN_ERROR;
return ret;
}
} else if (kstrtouint(regBuf, 16, &sensorReg.RegAddr) == 0) {
imgsensor_sensor_feature_control(
psensor,
SENSOR_FEATURE_GET_REGISTER,
(MUINT8 *) &sensorReg,
(MUINT32 *) sizeof(MSDK_SENSOR_REG_INFO_STRUCT));
pr_debug(
"read addr = 0x%08x, data = 0x%08x\n",
sensorReg.RegAddr,
sensorReg.RegData);
ret = snprintf(
mtk_i2c_dump,
sizeof(mtk_i2c_dump),
"addr = 0x%08x, data = 0x%08x\n",
sensorReg.RegAddr,
sensorReg.RegData);
if (ret == 0) {
pr_info("Error! snprintf allocate 0");
ret = IMGSENSOR_RETURN_ERROR;
return ret;
}
}
return count;
}
static ssize_t CAMERA_HW_Reg_Debug4(
struct file *file,
const char *buffer,
size_t count,
loff_t *data)
{
char regBuf[64] = { '\0' };
int ret = 0;
u32 u4CopyBufSize =
(count < (sizeof(regBuf) - 1)) ? (count) : (sizeof(regBuf) - 1);
struct IMGSENSOR_SENSOR *psensor =
&pgimgsensor->sensor[IMGSENSOR_SENSOR_IDX_SUB2];
MSDK_SENSOR_REG_INFO_STRUCT sensorReg;
memset(&sensorReg, 0, sizeof(MSDK_SENSOR_REG_INFO_STRUCT));
if (psensor == NULL || copy_from_user(regBuf, buffer, u4CopyBufSize))
return -EFAULT;
if (sscanf(
regBuf,
"%x %x",
&sensorReg.RegAddr,
&sensorReg.RegData) == 2) {
imgsensor_sensor_feature_control(
psensor,
SENSOR_FEATURE_SET_REGISTER,
(MUINT8 *) &sensorReg,
(MUINT32 *) sizeof(MSDK_SENSOR_REG_INFO_STRUCT));
imgsensor_sensor_feature_control(
psensor,
SENSOR_FEATURE_GET_REGISTER,
(MUINT8 *) &sensorReg,
(MUINT32 *) sizeof(MSDK_SENSOR_REG_INFO_STRUCT));
pr_debug(
"write addr = 0x%08x, data = 0x%08x\n",
sensorReg.RegAddr,
sensorReg.RegData);
ret = snprintf(
mtk_i2c_dump,
sizeof(mtk_i2c_dump),
"addr = 0x%08x, data = 0x%08x\n",
sensorReg.RegAddr,
sensorReg.RegData);
if (ret == 0) {
pr_info("Error! snprintf allocate 0");
ret = IMGSENSOR_RETURN_ERROR;
return ret;
}
} else if (kstrtouint(regBuf, 16, &sensorReg.RegAddr) == 0) {
imgsensor_sensor_feature_control(
psensor,
SENSOR_FEATURE_GET_REGISTER,
(MUINT8 *) &sensorReg,
(MUINT32 *) sizeof(MSDK_SENSOR_REG_INFO_STRUCT));
pr_debug(
"read addr = 0x%08x, data = 0x%08x\n",
sensorReg.RegAddr,
sensorReg.RegData);
ret = snprintf(
mtk_i2c_dump,
sizeof(mtk_i2c_dump),
"addr = 0x%08x, data = 0x%08x\n",
sensorReg.RegAddr,
sensorReg.RegData);
if (ret == 0) {
pr_info("Error! snprintf allocate 0");
ret = IMGSENSOR_RETURN_ERROR;
return ret;
}
}
return count;
}
/* Camera information */
static int subsys_camera_info_read(struct seq_file *m, void *v)
{
pr_debug("%s %s\n", __func__, mtk_ccm_name);
seq_printf(m, "%s\n", mtk_ccm_name);
return 0;
};
static int subsys_camsensor_read(struct seq_file *m, void *v)
{
seq_printf(m, "%s\n", mtk_i2c_dump);
return 0;
};
static int proc_camera_info_open(struct inode *inode, struct file *file)
{
return single_open(file, subsys_camera_info_read, NULL);
};
static int proc_camsensor_open(struct inode *inode, struct file *file)
{
return single_open(file, subsys_camsensor_read, NULL);
};
static int imgsensor_proc_status_read(struct seq_file *m, void *v)
{
char status_info[IMGSENSOR_STATUS_INFO_LENGTH];
int ret = 0;
ret = snprintf(status_info, sizeof(status_info),
"ERR_L0, %x\n",
*((uint32_t *)(&pgimgsensor->status)));
if (ret == 0) {
pr_info("Error! snprintf allocate 0");
ret = IMGSENSOR_RETURN_ERROR;
return ret;
}
seq_printf(m, "%s\n", status_info);
return 0;
};
static int imgsensor_proc_status_open(struct inode *inode, struct file *file)
{
return single_open(file, imgsensor_proc_status_read, NULL);
};
static const struct file_operations fcamera_proc_fops_status = {
.owner = THIS_MODULE,
.open = imgsensor_proc_status_open,
.read = seq_read,
};
static const struct file_operations fcamera_proc_fops1 = {
.owner = THIS_MODULE,
.open = proc_camera_info_open,
.read = seq_read,
};
static const struct file_operations fcamera_proc_fops = {
.owner = THIS_MODULE,
.read = seq_read,
.open = proc_camsensor_open,
.write = CAMERA_HW_Reg_Debug
};
static const struct file_operations fcamera_proc_fops2 = {
.owner = THIS_MODULE,
.read = seq_read,
.open = proc_camsensor_open,
.write = CAMERA_HW_Reg_Debug2
};
static const struct file_operations fcamera_proc_fops3 = {
.owner = THIS_MODULE,
.read = seq_read,
.open = proc_camsensor_open,
.write = CAMERA_HW_Reg_Debug3
};
static const struct file_operations fcamera_proc_fops4 = {
.owner = THIS_MODULE,
.read = seq_read,
.open = proc_camsensor_open,
.write = CAMERA_HW_Reg_Debug4
};
static const struct file_operations fcamera_proc_fops_set_pdaf_type = {
.owner = THIS_MODULE,
.open = proc_SensorType_open,
.read = seq_read,
.write = proc_SensorType_write
};
enum IMGSENSOR_RETURN imgsensor_proc_init(void)
{
memset(mtk_ccm_name, 0, camera_info_size);
proc_create("driver/camsensor", 0664, NULL, &fcamera_proc_fops);
proc_create("driver/camsensor2", 0664, NULL, &fcamera_proc_fops2);
proc_create("driver/camsensor3", 0664, NULL, &fcamera_proc_fops3);
proc_create("driver/camsensor4", 0664, NULL, &fcamera_proc_fops4);
proc_create(
"driver/pdaf_type", 0664, NULL, &fcamera_proc_fops_set_pdaf_type);
proc_create(PROC_SENSOR_STAT, 0664, NULL, &fcamera_proc_fops_status);
/* Camera information */
proc_create(PROC_CAMERA_INFO, 0664, NULL, &fcamera_proc_fops1);
return IMGSENSOR_RETURN_SUCCESS;
}
@@ -0,0 +1,24 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#ifndef __IMGSENSOR_PROC_H__
#define __IMGSENSOR_PROC_H__
#include "kd_imgsensor.h"
#include "kd_imgsensor_define.h"
#include "imgsensor_common.h"
#define PROC_CAMERA_INFO "driver/camera_info"
#define PROC_SENSOR_STAT "driver/imgsensor_status_info"
#define IMGSENSOR_STATUS_INFO_LENGTH 128
#define camera_info_size 4096
extern char mtk_ccm_name[camera_info_size];
extern struct IMGSENSOR *pgimgsensor;
enum IMGSENSOR_RETURN imgsensor_proc_init(void);
#endif
@@ -0,0 +1,39 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#ifndef __IMGSENSOR_SENSOR_H__
#define __IMGSENSOR_SENSOR_H__
#include "imgsensor_i2c.h"
#include "kd_camera_feature.h"
#include "kd_imgsensor_define.h"
enum IMGSENSOR_STATE {
IMGSENSOR_STATE_CLOSE,
IMGSENSOR_STATE_OPEN
};
struct IMGSENSOR_SENSOR_STATUS {
u32 reserved:28;
u32 arch:4;
};
struct IMGSENSOR_SENSOR_INST {
char *psensor_name;
enum IMGSENSOR_STATE state;
enum IMGSENSOR_SENSOR_IDX sensor_idx;
struct IMGSENSOR_I2C_CFG i2c_cfg;
struct IMGSENSOR_SENSOR_STATUS status;
struct mutex sensor_mutex;
struct timeval profile_time;
};
struct IMGSENSOR_SENSOR {
struct IMGSENSOR_SENSOR_INST inst;
struct SENSOR_FUNCTION_STRUCT *pfunc;
};
#endif
@@ -0,0 +1,771 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#include "kd_imgsensor.h"
#include "imgsensor_sensor_list.h"
/* Add Sensor Init function here
* Note:
* 1. Add by the resolution from ""large to small"", due to large sensor
* will be possible to be main sensor.
* This can avoid I2C error during searching sensor.
* 2. This should be the same as
* mediatek\custom\common\hal\imgsensor\src\sensorlist.cpp
*/
struct IMGSENSOR_INIT_FUNC_LIST kdSensorList[MAX_NUM_OF_SUPPORT_SENSOR] = {
#if defined(S5K4H7_MIPI_RAW)
{S5K4H7_SENSOR_ID,
SENSOR_DRVNAME_S5K4H7_MIPI_RAW,
S5K4H7_MIPI_RAW_SensorInit},
#endif
#if defined(S5K4H7SUB_MIPI_RAW)
{S5K4H7SUB_SENSOR_ID,
SENSOR_DRVNAME_S5K4H7SUB_MIPI_RAW,
S5K4H7SUB_MIPI_RAW_SensorInit},
#endif
/*IMX*/
#if defined(IMX519_MIPI_RAW)
{IMX519_SENSOR_ID,
SENSOR_DRVNAME_IMX519_MIPI_RAW,
IMX519_MIPI_RAW_SensorInit},
#endif
#if defined(IMX499_MIPI_RAW)
{IMX499_SENSOR_ID,
SENSOR_DRVNAME_IMX499_MIPI_RAW,
IMX499_MIPI_RAW_SensorInit},
#endif
#if defined(IMX499_MIPI_RAW_13M)
{IMX499_SENSOR_ID,
SENSOR_DRVNAME_IMX499_MIPI_RAW_13M,
IMX499_MIPI_RAW_SensorInit},
#endif
#if defined(IMX486_MIPI_RAW)
{IMX486_SENSOR_ID,
SENSOR_DRVNAME_IMX486_MIPI_RAW,
IMX486_MIPI_RAW_SensorInit},
#endif
#if defined(IMX398_MIPI_RAW)
{IMX398_SENSOR_ID,
SENSOR_DRVNAME_IMX398_MIPI_RAW,
IMX398_MIPI_RAW_SensorInit},
#endif
#if defined(IMX386_MIPI_RAW)
{IMX386_SENSOR_ID,
SENSOR_DRVNAME_IMX386_MIPI_RAW,
IMX386_MIPI_RAW_SensorInit},
#endif
#if defined(IMX386_MIPI_MONO)
{IMX386_MONO_SENSOR_ID,
SENSOR_DRVNAME_IMX386_MIPI_MONO,
IMX386_MIPI_MONO_SensorInit},
#endif
#if defined(IMX362_MIPI_RAW)
{IMX362_SENSOR_ID,
SENSOR_DRVNAME_IMX362_MIPI_RAW,
IMX362_MIPI_RAW_SensorInit},
#endif
#if defined(IMX338_MIPI_RAW)
{IMX338_SENSOR_ID,
SENSOR_DRVNAME_IMX338_MIPI_RAW,
IMX338_MIPI_RAW_SensorInit},
#endif
#if defined(IMX318_MIPI_RAW)
{IMX318_SENSOR_ID,
SENSOR_DRVNAME_IMX318_MIPI_RAW,
IMX318_MIPI_RAW_SensorInit},
#endif
#if defined(IMX377_MIPI_RAW)
{IMX377_SENSOR_ID,
SENSOR_DRVNAME_IMX377_MIPI_RAW,
IMX377_MIPI_RAW_SensorInit},
#endif
#if defined(IMX230_MIPI_RAW)
{IMX230_SENSOR_ID,
SENSOR_DRVNAME_IMX230_MIPI_RAW,
IMX230_MIPI_RAW_SensorInit},
#endif
#if defined(IMX220_MIPI_RAW)
{IMX220_SENSOR_ID,
SENSOR_DRVNAME_IMX220_MIPI_RAW,
IMX220_MIPI_RAW_SensorInit},
#endif
#if defined(IMX219_MIPI_RAW)
{IMX219_SENSOR_ID,
SENSOR_DRVNAME_IMX219_MIPI_RAW,
IMX219_MIPI_RAW_SensorInit},
#endif
#if defined(IMX214_MIPI_RAW)
{IMX214_SENSOR_ID,
SENSOR_DRVNAME_IMX214_MIPI_RAW,
IMX214_MIPI_RAW_SensorInit},
#endif
#if defined(IMX214_MIPI_MONO)
{IMX214_MONO_SENSOR_ID,
SENSOR_DRVNAME_IMX214_MIPI_MONO,
IMX214_MIPI_MONO_SensorInit},
#endif
#if defined(IMX179_MIPI_RAW)
{IMX179_SENSOR_ID,
SENSOR_DRVNAME_IMX179_MIPI_RAW,
IMX179_MIPI_RAW_SensorInit},
#endif
#if defined(IMX178_MIPI_RAW)
{IMX178_SENSOR_ID,
SENSOR_DRVNAME_IMX178_MIPI_RAW,
IMX178_MIPI_RAW_SensorInit},
#endif
#if defined(IMX132_MIPI_RAW)
{IMX132MIPI_SENSOR_ID,
SENSOR_DRVNAME_IMX132_MIPI_RAW,
IMX132_MIPI_RAW_SensorInit},
#endif
#if defined(IMX135_MIPI_RAW)
{IMX135_SENSOR_ID,
SENSOR_DRVNAME_IMX135_MIPI_RAW,
IMX135_MIPI_RAW_SensorInit},
#endif
#if defined(IMX105_MIPI_RAW)
{IMX105_SENSOR_ID,
SENSOR_DRVNAME_IMX105_MIPI_RAW,
IMX105_MIPI_RAW_SensorInit},
#endif
#if defined(IMX073_MIPI_RAW)
{IMX073_SENSOR_ID,
SENSOR_DRVNAME_IMX073_MIPI_RAW,
IMX073_MIPI_RAW_SensorInit},
#endif
#if defined(IMX258_MIPI_RAW)
{IMX258_SENSOR_ID,
SENSOR_DRVNAME_IMX258_MIPI_RAW,
IMX258_MIPI_RAW_SensorInit},
#endif
#if defined(IMX258_MIPI_MONO)
{IMX258_MONO_SENSOR_ID,
SENSOR_DRVNAME_IMX258_MIPI_MONO,
IMX258_MIPI_MONO_SensorInit},
#endif
/*OV (OmniVision)*/
#if defined(OV16880_MIPI_RAW)
{OV16880_SENSOR_ID,
SENSOR_DRVNAME_OV16880_MIPI_RAW,
OV16880MIPISensorInit},
#endif
#if defined(OV16825_MIPI_RAW)
{OV16825MIPI_SENSOR_ID,
SENSOR_DRVNAME_OV16825_MIPI_RAW,
OV16825MIPISensorInit},
#endif
#if defined(OV13855_MIPI_RAW)
{OV13855_SENSOR_ID,
SENSOR_DRVNAME_OV13855_MIPI_RAW,
OV13855_MIPI_RAW_SensorInit},
#endif
#if defined(OV13B10_MIPI_RAW)
{OV13B10_SENSOR_ID,
SENSOR_DRVNAME_OV13B10_MIPI_RAW,
OV13B10_MIPI_RAW_SensorInit},
#endif
#if defined(OV13870_MIPI_RAW)
{OV13870_SENSOR_ID, SENSOR_DRVNAME_OV13870_MIPI_RAW,
OV13870_MIPI_RAW_SensorInit},
#endif
#if defined(OV13850_MIPI_RAW)
{OV13850_SENSOR_ID,
SENSOR_DRVNAME_OV13850_MIPI_RAW,
OV13850_MIPI_RAW_SensorInit},
#endif
#if defined(OV12A10_MIPI_RAW)
{OV12A10_SENSOR_ID,
SENSOR_DRVNAME_OV12A10_MIPI_RAW,
OV12A10_MIPI_RAW_SensorInit},
#endif
#if defined(OV12830_MIPI_RAW)
{OV12830_SENSOR_ID,
SENSOR_DRVNAME_OV12830_MIPI_RAW,
OV12830_MIPI_RAW_SensorInit},
#endif
#if defined(OV9760_MIPI_RAW)
{OV9760MIPI_SENSOR_ID,
SENSOR_DRVNAME_OV9760_MIPI_RAW,
OV9760MIPI_RAW_SensorInit},
#endif
#if defined(OV9740_MIPI_YUV)
{OV9740MIPI_SENSOR_ID,
SENSOR_DRVNAME_OV9740_MIPI_YUV,
OV9740_MIPI_YUV_SensorInit},
#endif
#if defined(OV9726_RAW)
{OV9726_SENSOR_ID,
SENSOR_DRVNAME_0V9726_RAW,
OV9726_RAW_SensorInit},
#endif
#if defined(OV9726_MIPI_RAW)
{OV9726MIPI_SENSOR_ID,
SENSOR_DRVNAME_OV9726_MIPI_RAW,
OV9726MIPI_RAW_SensorInit},
#endif
#if defined(OV8865_MIPI_RAW)
{OV8865_SENSOR_ID,
SENSOR_DRVNAME_OV8865_MIPI_RAW,
OV8865_MIPI_RAW_SensorInit},
#endif
#if defined(OV8858_MIPI_RAW)
{OV8858_SENSOR_ID,
SENSOR_DRVNAME_OV8858_MIPI_RAW,
OV8858_MIPI_RAW_SensorInit},
#endif
#if defined(OV8856_MIPI_RAW)
{OV8856_SENSOR_ID,
SENSOR_DRVNAME_OV8856_MIPI_RAW,
OV8856_MIPI_RAW_SensorInit},
#endif
#if defined(OV8830_RAW)
{OV8830_SENSOR_ID,
SENSOR_DRVNAME_OV8830_RAW,
OV8830SensorInit},
#endif
#if defined(OV8825_MIPI_RAW)
{OV8825_SENSOR_ID,
SENSOR_DRVNAME_OV8825_MIPI_RAW,
OV8825_MIPI_RAW_SensorInit},
#endif
#if defined(OV7675_YUV)
{OV7675_SENSOR_ID,
SENSOR_DRVNAME_OV7675_YUV,
OV7675_YUV_SensorInit},
#endif
#if defined(OV5693_MIPI_RAW)
{OV5693_SENSOR_ID,
SENSOR_DRVNAME_OV5693_MIPI_RAW,
OV5693_MIPI_RAW_SensorInit},
#endif
#if defined(OV5670_MIPI_RAW)
{OV5670MIPI_SENSOR_ID,
SENSOR_DRVNAME_OV5670_MIPI_RAW,
OV5670_MIPI_RAW_SensorInit},
#endif
#if defined(OV5670_MIPI_RAW_2)
{OV5670MIPI_SENSOR_ID_2,
SENSOR_DRVNAME_OV5670_MIPI_RAW_2,
OV5670_MIPI_RAW_SensorInit_2},
#endif
#if defined(OV5650_RAW)
{OV5650_SENSOR_ID,
SENSOR_DRVNAME_OV5650_RAW,
OV5650SensorInit},
#endif
#if defined(OV5650MIPI_RAW)
{OV5650MIPI_SENSOR_ID,
SENSOR_DRVNAME_OV5650MIPI_RAW,
OV5650MIPISensorInit},
#endif
#if defined(OV5648_MIPI_RAW)
{OV5648MIPI_SENSOR_ID,
SENSOR_DRVNAME_OV5648_MIPI_RAW,
OV5648MIPISensorInit},
#endif
#if defined(OV5647_MIPI_RAW)
{OV5647MIPI_SENSOR_ID,
SENSOR_DRVNAME_OV5647MIPI_RAW,
OV5647MIPISensorInit},
#endif
#if defined(OV5647_RAW)
{OV5647_SENSOR_ID,
SENSOR_DRVNAME_OV5647_RAW,
OV5647SensorInit},
#endif
#if defined(OV5645_MIPI_YUV)
{OV5645MIPI_SENSOR_ID,
SENSOR_DRVNAME_OV5645_MIPI_YUV,
OV5645_MIPI_YUV_SensorInit},
#endif
#if defined(OV5642_RAW)
{OV5642_SENSOR_ID,
SENSOR_DRVNAME_OV5642_RAW,
OV5642_RAW_SensorInit},
#endif
#if defined(OV5642_MIPI_YUV)
{OV5642_SENSOR_ID,
SENSOR_DRVNAME_OV5642_MIPI_YUV,
OV5642_MIPI_YUV_SensorInit},
#endif
#if defined(OV5642_MIPI_RGB)
{OV5642_SENSOR_ID,
SENSOR_DRVNAME_OV5642_MIPI_RGB,
OV5642_MIPI_RGB_SensorInit},
#endif
#if defined(OV5642_MIPI_JPG)
{OV5642_SENSOR_ID,
SENSOR_DRVNAME_OV5642_MIPI_JPG,
OV5642_MIPI_JPG_SensorInit},
#endif
#if defined(OV5642_YUV)
{OV5642_SENSOR_ID,
SENSOR_DRVNAME_OV5642_YUV,
OV5642_YUV_SensorInit},
#endif
#if defined(OV4688_MIPI_RAW)
{OV4688MIPI_SENSOR_ID,
SENSOR_DRVNAME_OV4688_MIPI_RAW,
OV4688_MIPI_RAW_SensorInit},
#endif
#if defined(OV3640_RAW)
{OV3640_SENSOR_ID
, SENSOR_DRVNAME_OV3640_RAW,
OV3640SensorInit},
#endif
#if defined(OV3640_YUV)
{OV3640_SENSOR_ID,
SENSOR_DRVNAME_OV3640_YUV,
OV3640_YUV_SensorInit},
#endif
#if defined(OV3640_YUV_AF)
{OV3640_SENSOR_ID,
SENSOR_DRVNAME_OV3640_YUV,
OV3640_YUV_SensorInit},
#endif
#if defined(OV2680_MIPI_RAW)
{OV2680MIPI_SENSOR_ID,
SENSOR_DRVNAME_OV2680_MIPI_RAW,
OV2680MIPISensorInit},
#endif
#if defined(OV2722_MIPI_RAW)
{OV2722MIPI_SENSOR_ID,
SENSOR_DRVNAME_OV2722_MIPI_RAW,
OV2722MIPI_RAW_SensorInit},
#endif
#if defined(OV2659_YUV)
{OV2659_SENSOR_ID,
SENSOR_DRVNAME_OV2659_YUV,
OV2659_YUV_SensorInit},
#endif
#if defined(OV2655_YUV)
{OV2650_SENSOR_ID,
SENSOR_DRVNAME_OV2655_YUV,
OV2655_YUV_SensorInit},
#endif
#if defined(OV2650_RAW)
{OV2650_SENSOR_ID,
SENSOR_DRVNAME_OV2650_RAW,
OV2650SensorInit},
#endif
#if defined(OV23850_MIPI_RAW)
{OV23850_SENSOR_ID,
SENSOR_DRVNAME_OV23850_MIPI_RAW,
OV23850_MIPI_RAW_SensorInit},
#endif
#if defined(OV20880_MIPI_RAW)
{OV20880MIPI_SENSOR_ID,
SENSOR_DRVNAME_OV20880_MIPI_RAW,
OV20880_MIPI_RAW_SensorInit},
#endif
/*S5K*/
#if defined(S5K3P8SP_MIPI_RAW)
{S5K3P8SP_SENSOR_ID,
SENSOR_DRVNAME_S5K3P8SP_MIPI_RAW,
S5K3P8SP_MIPI_RAW_SensorInit},
#endif
#if defined(S5K2T7SP_MIPI_RAW)
{S5K2T7SP_SENSOR_ID,
SENSOR_DRVNAME_S5K2T7SP_MIPI_RAW,
S5K2T7SP_MIPI_RAW_SensorInit},
#endif
#if defined(S5K2T7SP_MIPI_RAW_5M)
{S5K2T7SP_SENSOR_ID,
SENSOR_DRVNAME_S5K2T7SP_MIPI_RAW_5M,
S5K2T7SP_MIPI_RAW_SensorInit},
#endif
#if defined(S5K4E6_MIPI_RAW)
{S5K4E6_SENSOR_ID,
SENSOR_DRVNAME_S5K4E6_MIPI_RAW,
S5K4E6_MIPI_RAW_SensorInit},
#endif
#if defined(S5K2L7_MIPI_RAW)
{S5K2L7_SENSOR_ID,
SENSOR_DRVNAME_S5K2L7_MIPI_RAW,
S5K2L7_MIPI_RAW_SensorInit},
#endif
#if defined(S5K3L6_MIPI_RAW)
{S5K3L6_SENSOR_ID,
SENSOR_DRVNAME_S5K3L6_MIPI_RAW,
S5K3L6_MIPI_RAW_SensorInit},
#endif
#if defined(S5K3L8_MIPI_RAW)
{S5K3L8_SENSOR_ID,
SENSOR_DRVNAME_S5K3L8_MIPI_RAW,
S5K3L8_MIPI_RAW_SensorInit},
#endif
#if defined(S5K3M3_MIPI_RAW)
{S5K3M3_SENSOR_ID,
SENSOR_DRVNAME_S5K3M3_MIPI_RAW,
S5K3M3_MIPI_RAW_SensorInit},
#endif
#if defined(S5K2P7_MIPI_RAW)
{S5K2P7_SENSOR_ID,
SENSOR_DRVNAME_S5K2P7_MIPI_RAW,
S5K2P7_MIPI_RAW_SensorInit},
#endif
#if defined(S5K2P8_MIPI_RAW)
{S5K2P8_SENSOR_ID,
SENSOR_DRVNAME_S5K2P8_MIPI_RAW,
S5K2P8_MIPI_RAW_SensorInit},
#endif
#if defined(S5K3P3SX_MIPI_RAW)
{S5K3P3SX_SENSOR_ID,
SENSOR_DRVNAME_S5K3P3SX_MIPI_RAW,
S5K3P3SX_MIPI_RAW_SensorInit},
#endif
#if defined(S5K2X8_MIPI_RAW)
{S5K2X8_SENSOR_ID,
SENSOR_DRVNAME_S5K2X8_MIPI_RAW,
S5K2X8_MIPI_RAW_SensorInit},
#endif
#if defined(S5K3M2_MIPI_RAW)
{S5K3M2_SENSOR_ID,
SENSOR_DRVNAME_S5K3M2_MIPI_RAW,
S5K3M2_MIPI_RAW_SensorInit},
#endif
#if defined(S5K3H2YX_MIPI_RAW)
{S5K3H2YX_SENSOR_ID,
SENSOR_DRVNAME_S5K3H2YX_MIPI_RAW,
S5K3H2YX_MIPI_RAW_SensorInit},
#endif
#if defined(S5K3H7Y_MIPI_RAW)
{S5K3H7Y_SENSOR_ID,
SENSOR_DRVNAME_S5K3H7Y_MIPI_RAW,
S5K3H7Y_MIPI_RAW_SensorInit},
#endif
#if defined(S5K4H5YC_MIPI_RAW)
{S5K4H5YC_SENSOR_ID,
SENSOR_DRVNAME_S5K4H5YC_MIPI_RAW,
S5K4H5YC_MIPI_RAW_SensorInit},
#endif
#if defined(S5K4H5YX_2LANE_MIPI_RAW)
{S5K4H5YX_2LANE_SENSOR_ID,
SENSOR_DRVNAME_S5K4H5YX_2LANE_MIPI_RAW,
S5K4H5YX_2LANE_MIPI_RAW_SensorInit},
#endif
#if defined(S5K5E2YA_MIPI_RAW)
{S5K5E2YA_SENSOR_ID,
SENSOR_DRVNAME_S5K5E2YA_MIPI_RAW,
S5K5E2YA_MIPI_RAW_SensorInit},
#endif
#if defined(S5K5CAGX_YUV)
{S5K5CAGX_SENSOR_ID,
SENSOR_DRVNAME_S5K5CAGX_YUV,
S5K5CAGX_YUV_SensorInit},
#endif
#if defined(S5K4E1GA_MIPI_RAW)
{S5K4E1GA_SENSOR_ID,
SENSOR_DRVNAME_S5K4E1GA_MIPI_RAW,
S5K4E1GA_MIPI_RAW_SensorInit},
#endif
#if defined(S5K4ECGX_YUV)
{S5K4ECGX_SENSOR_ID,
SENSOR_DRVNAME_S5K4ECGX_YUV,
S5K4ECGX_YUV_SensorInit},
#endif
#if defined(S5K4ECGX_MIPI_YUV)
{S5K4ECGX_SENSOR_ID,
SENSOR_DRVNAME_S5K4ECGX_MIPI_YUV,
S5K4ECGX_MIPI_YUV_SensorInit},
#endif
#if defined(S5K4ECGX_MIPI_JPG)
{S5K4ECGX_SENSOR_ID,
SENSOR_DRVNAME_S5K4ECGX_MIPI_JPG,
S5K4ECGX_MIPI_JPG_SensorInit},
#endif
#if defined(S5K8AAYX_MIPI_YUV)
{S5K8AAYX_MIPI_SENSOR_ID,
SENSOR_DRVNAME_S5K8AAYX_MIPI_YUV,
S5K8AAYX_MIPI_YUV_SensorInit},
#endif
#if defined(S5K8AAYX_YUV)
{S5K8AAYX_MIPI_SENSOR_ID,
SENSOR_DRVNAME_S5K8AAYX_YUV,
S5K8AAYX_PVI_YUV_SensorInit},
#endif
#if defined(S5K5E8YX_MIPI_RAW)
{S5K5E8YX_SENSOR_ID,
SENSOR_DRVNAME_S5K5E8YX_MIPI_RAW,
S5K5E8YX_MIPI_RAW_SensorInit},
#endif
#if defined(S5K5E8YXREAR2_MIPI_RAW)
{S5K5E8YXREAR2_SENSOR_ID,
SENSOR_DRVNAME_S5K5E8YXREAR2_MIPI_RAW,
S5K5E8YXREAR2_MIPI_RAW_SensorInit},
#endif
#if defined(S5KJN1_MIPI_RAW)
{S5KJN1_SENSOR_ID,
SENSOR_DRVNAME_S5KJN1_MIPI_RAW,
S5KJN1_MIPI_RAW_SensorInit},
#endif
/*HI*/
#if defined(HI841_MIPI_RAW)
{HI841_SENSOR_ID,
SENSOR_DRVNAME_HI841_MIPI_RAW,
HI841_MIPI_RAW_SensorInit},
#endif
#if defined(HI707_YUV)
{HI707_SENSOR_ID,
SENSOR_DRVNAME_HI707_YUV,
HI707_YUV_SensorInit},
#endif
#if defined(HI704_YUV)
{HI704_SENSOR_ID,
SENSOR_DRVNAME_HI704_YUV,
HI704_YUV_SensorInit},
#endif
#if defined(HI556_MIPI_RAW)
{HI556_SENSOR_ID,
SENSOR_DRVNAME_HI556_MIPI_RAW,
HI556_MIPI_RAW_SensorInit},
#endif
#if defined(HI551_MIPI_RAW)
{HI551_SENSOR_ID,
SENSOR_DRVNAME_HI551_MIPI_RAW,
HI551_MIPI_RAW_SensorInit},
#endif
#if defined(HI545_MIPI_RAW)
{HI545MIPI_SENSOR_ID,
SENSOR_DRVNAME_HI545_MIPI_RAW,
HI545_MIPI_RAW_SensorInit},
#endif
#if defined(HI544_MIPI_RAW)
{HI544MIPI_SENSOR_ID,
SENSOR_DRVNAME_HI544_MIPI_RAW,
HI544_MIPI_RAW_SensorInit},
#endif
#if defined(HI542_RAW)
{HI542_SENSOR_ID,
SENSOR_DRVNAME_HI542_RAW,
HI542_RAW_SensorInit},
#endif
#if defined(HI542_MIPI_RAW)
{HI542MIPI_SENSOR_ID,
SENSOR_DRVNAME_HI542MIPI_RAW,
HI542_MIPI_RAW_SensorInit},
#endif
#if defined(HI253_YUV)
{HI253_SENSOR_ID,
SENSOR_DRVNAME_HI253_YUV,
HI253_YUV_SensorInit},
#endif
#if defined(HI191_MIPI_RAW)
{HI191MIPI_SENSOR_ID,
SENSOR_DRVNAME_HI191_MIPI_RAW,
HI191MIPI_RAW_SensorInit},
#endif
/*MT*/
#if defined(MT9P012_RAW)
{MT9P012_SENSOR_ID,
SENSOR_DRVNAME_MT9P012_RAW,
MT9P012SensorInit},
#endif
#if defined(MT9P015_RAW)
{MT9P015_SENSOR_ID,
SENSOR_DRVNAME_MT9P015_RAW,
MT9P015SensorInit},
#endif
#if defined(MT9P017_RAW)
{MT9P017_SENSOR_ID,
SENSOR_DRVNAME_MT9P017_RAW,
MT9P017SensorInit},
#endif
#if defined(MT9P017_MIPI_RAW)
{MT9P017MIPI_SENSOR_ID,
SENSOR_DRVNAME_MT9P017_MIPI_RAW,
MT9P017MIPISensorInit},
#endif
#if defined(MT9T113_YUV)
{MT9T113_SENSOR_ID,
SENSOR_DRVNAME_MT9T113_YUV,
MT9T113_YUV_SensorInit},
#endif
#if defined(MT9T113_MIPI_YUV)
{MT9T113MIPI_SENSOR_ID,
SENSOR_DRVNAME_MT9T113_MIPI_YUV,
MT9T113MIPI_YUV_SensorInit},
#endif
#if defined(MT9V113_YUV)
{MT9V113_SENSOR_ID,
SENSOR_DRVNAME_MT9V113_YUV,
MT9V113_YUV_SensorInit},
#endif
#if defined(MT9V114_YUV)
{MT9V114_SENSOR_ID,
SENSOR_DRVNAME_MT9V114_YUV,
MT9V114_YUV_SensorInit},
#endif
#if defined(MT9D115_MIPI_RAW)
{MT9D115_SENSOR_ID,
SENSOR_DRVNAME_MT9D115_MIPI_RAW,
MT9D115MIPISensorInit},
#endif
#if defined(MT9V115_YUV)
{MT9V115_SENSOR_ID,
SENSOR_DRVNAME_MT9V115_YUV,
MT9V115_YUV_SensorInit},
#endif
/*GC*/
#if defined(GC5035_MIPI_RAW)
{GC5035_SENSOR_ID,
SENSOR_DRVNAME_GC5035MIPI_RAW,
GC5035MIPI_RAW_SensorInit},
#endif
#if defined(GC2375H_MIPI_RAW)
{GC2375H_SENSOR_ID,
SENSOR_DRVNAME_GC2375H_MIPI_RAW,
GC2375H_MIPI_RAW_SensorInit},
#endif
#if defined(GC2365_MIPI_RAW)
{GC2365_SENSOR_ID, SENSOR_DRVNAME_GC2365_MIPI_RAW,
GC2365_MIPI_RAW_SensorInit},
#endif
#if defined(GC2366_MIPI_RAW)
{GC2366_SENSOR_ID, SENSOR_DRVNAME_GC2366_MIPI_RAW,
GC2366_MIPI_RAW_SensorInit},
#endif
#if defined(GC2355_MIPI_RAW)
{GC2355_SENSOR_ID,
SENSOR_DRVNAME_GC2355_MIPI_RAW,
GC2355_MIPI_RAW_SensorInit},
#endif
#if defined(GC2235_RAW)
{GC2235_SENSOR_ID,
SENSOR_DRVNAME_GC2235_RAW,
GC2235_RAW_SensorInit},
#endif
#if defined(GC2035_YUV)
{GC2035_SENSOR_ID,
SENSOR_DRVNAME_GC2035_YUV,
GC2035_YUV_SensorInit},
#endif
#if defined(GC0330_YUV)
{GC0330_SENSOR_ID,
SENSOR_DRVNAME_GC0330_YUV,
GC0330_YUV_SensorInit},
#endif
#if defined(GC0329_YUV)
{GC0329_SENSOR_ID,
SENSOR_DRVNAME_GC0329_YUV,
GC0329_YUV_SensorInit},
#endif
#if defined(GC0313_MIPI_YUV)
{GC0313MIPI_YUV_SENSOR_ID,
SENSOR_DRVNAME_GC0313MIPI_YUV,
GC0313MIPI_YUV_SensorInit},
#endif
#if defined(GC0310_YUV)
{GC0310_SENSOR_ID,
SENSOR_DRVNAME_GC0310_YUV,
GC0310_YUV_SensorInit},
#endif
#if defined(GC8C34_MIPI_RAW)
{GC8C34_SENSOR_ID,
SENSOR_DRVNAME_GC8C34_MIPI_RAW,
GC8C34_MIPI_RAW_SensorInit},
#endif
#if defined(GC8034_MIPI_RAW)
{GC8034_SENSOR_ID,
SENSOR_DRVNAME_GC8034_MIPI_RAW,
GC8034_MIPI_RAW_SensorInit},
#endif
#if defined(GC08A3_MIPI_RAW)
{GC08A3_SENSOR_ID,
SENSOR_DRVNAME_GC08A3_MIPI_RAW,
GC08A3_MIPI_RAW_SensorInit},
#endif
/*SP*/
#if defined(SP250A_MIPI_RAW)
{SP250A_SENSOR_ID,
SENSOR_DRVNAME_SP250A_MIPI_RAW,
SP250A_MIPI_RAW_SensorInit},
#endif
#if defined(SP0A19_YUV)
{SP0A19_YUV_SENSOR_ID,
SENSOR_DRVNAME_SP0A19_YUV,
SP0A19_YUV_SensorInit},
#endif
/*A*/
#if defined(A5141_MIPI_RAW)
{A5141MIPI_SENSOR_ID,
SENSOR_DRVNAME_A5141_MIPI_RAW,
A5141_MIPI_RAW_SensorInit},
#endif
#if defined(A5142_MIPI_RAW)
{A5142MIPI_SENSOR_ID,
SENSOR_DRVNAME_A5142_MIPI_RAW,
A5142_MIPI_RAW_SensorInit},
#endif
/*HM*/
#if defined(HM3451_RAW)
{HM3451_SENSOR_ID,
SENSOR_DRVNAME_HM3451_RAW,
HM3451SensorInit},
#endif
/*AR*/
#if defined(AR0833_MIPI_RAW)
{AR0833_SENSOR_ID,
SENSOR_DRVNAME_AR0833_MIPI_RAW,
AR0833_MIPI_RAW_SensorInit},
#endif
/*SIV*/
#if defined(SIV120B_YUV)
{SIV120B_SENSOR_ID,
SENSOR_DRVNAME_SIV120B_YUV,
SIV120B_YUV_SensorInit},
#endif
#if defined(SIV121D_YUV)
{SIV121D_SENSOR_ID,
SENSOR_DRVNAME_SIV121D_YUV,
SIV121D_YUV_SensorInit},
#endif
/*PAS (PixArt Image)*/
#if defined(PAS6180_SERIAL_YUV)
{PAS6180_SENSOR_ID,
SENSOR_DRVNAME_PAS6180_SERIAL_YUV,
PAS6180_SERIAL_YUV_SensorInit},
#endif
/*Panasoic*/
#if defined(MN34152_MIPI_RAW)
{MN34152_SENSOR_ID,
SENSOR_DRVNAME_MN34152_MIPI_RAW,
MN34152_MIPI_RAW_SensorInit},
#endif
/*Toshiba*/
#if defined(T4K28_YUV)
{T4K28_SENSOR_ID,
SENSOR_DRVNAME_T4K28_YUV,
T4K28_YUV_SensorInit},
#endif
#if defined(T4KA7_MIPI_RAW)
{T4KA7_SENSOR_ID,
SENSOR_DRVNAME_T4KA7_MIPI_RAW,
T4KA7_MIPI_RAW_SensorInit},
#endif
/*Others*/
#if defined(ISX012_MIPI_YUV)
{ISX012MIPI_SENSOR_ID,
SENSOR_DRVNAME_ISX012_MIPI_YUV,
ISX012_MIPI_YUV_SensorInit},
#endif
#if defined(T8EV5_YUV)
{T8EV5_SENSOR_ID,
SENSOR_DRVNAME_T8EV5_YUV,
T8EV5_YUV_SensorInit},
#endif
/*Test*/
#if defined(OV8856_MIPI_RAW_5MP)
{OV8856_SENSOR_ID, SENSOR_DRVNAME_OV8856_MIPI_RAW_5MP,
OV8856_MIPI_RAW_SensorInit},
#endif
/* ADD sensor driver before this line */
{0, {0}, NULL}, /* end of list */
};
/* e_add new sensor driver here */
@@ -0,0 +1,185 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#ifndef __KD_SENSORLIST_H__
#define __KD_SENSORLIST_H__
#include "kd_camera_typedef.h"
#include "imgsensor_sensor.h"
struct IMGSENSOR_INIT_FUNC_LIST {
MUINT32 id;
MUINT8 name[32];
MUINT32 (*init)(struct SENSOR_FUNCTION_STRUCT **pfFunc);
};
UINT32 S5K4H7_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 S5K4H7SUB_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
/*IMX*/
UINT32 IMX519_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 IMX499_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 IMX486_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 IMX398_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 IMX268_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 IMX386_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 IMX386_MIPI_MONO_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 IMX362_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 IMX338_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 IMX318_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 IMX377_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 IMX230_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 IMX220_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 IMX219_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 IMX214_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 IMX214_MIPI_MONO_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 IMX179_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 IMX178_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 IMX132_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 IMX135_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 IMX105_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 IMX073_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 IMX258_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 IMX258_MIPI_MONO_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
/*OV*/
UINT32 OV16880MIPISensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 OV16825MIPISensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 OV13870_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 OV13855_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 OV13850_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 OV12A10_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 OV12830_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 OV9760MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 OV9740_MIPI_YUV_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 OV9726_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 OV9726MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 OV8865_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 OV8858_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 OV8856_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 OV8830SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 OV8825_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 OV7675_YUV_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 OV5693_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 OV5670_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 OV5670_MIPI_RAW_SensorInit_2(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 OV5650SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 OV5650MIPISensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 OV5648MIPISensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 OV5647MIPISensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 OV5647SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 OV5645_MIPI_YUV_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 OV5642_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 OV5642_MIPI_YUV_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 OV5642_MIPI_RGB_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 OV5642_MIPI_JPG_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 OV5642_YUV_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 OV5642_YUV_SWI2C_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 OV4688_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 OV3640SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 OV3640_YUV_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 OV2722MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 OV2680MIPISensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 OV2659_YUV_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 OV2655_YUV_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 OV2650SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 OV23850_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 OV20880_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 OV13B10_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
/*S5K*/
UINT32 S5K3P8SP_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 S5K2T7SP_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 S5K2L7_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 S5K3L8_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 S5K3M3_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 S5K2P7_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 S5K2P8_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 S5K3L6_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 S5K3P3SX_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 S5K2X8_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 S5K3M2_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 S5K4E6_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 S5K3H2YX_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 S5K3H7Y_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 S5K4H5YC_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 S5K4H5YX_2LANE_MIPI_RAW_SensorInit(
struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 S5K5E2YA_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 S5K5CAGX_YUV_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 S5K4E1GA_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 S5K4ECGX_YUV_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 S5K4ECGX_MIPI_YUV_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 S5K4ECGX_MIPI_JPG_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 S5K8AAYX_MIPI_YUV_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 S5K8AAYX_PVI_YUV_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 S5K5E8YX_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 S5K5E8YXREAR2_MIPI_RAW_SensorInit
(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 S5KJN1_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
/*HI*/
UINT32 HI841_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 HI707_YUV_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 HI704_YUV_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 HI556_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 HI551_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 HI545_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 HI544_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 HI542_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 HI542_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 HI253_YUV_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 HI191MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
/*MT*/
UINT32 MT9P012SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 MT9P015SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 MT9P017SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 MT9P017MIPISensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 MT9T113_YUV_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 MT9V113_YUV_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 MT9T113MIPI_YUV_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 MT9V114_YUV_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 MT9D115MIPISensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 MT9V115_YUV_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
/*GC*/
UINT32 GC5035MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 GC2375H_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 GC2365_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 GC2366_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 GC2355_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 GC2235_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 GC2035_YUV_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 GC0330_YUV_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 GC0329_YUV_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 GC0313MIPI_YUV_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 GC0310_YUV_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 GC08A3_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 IMX215_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 GC8C34_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 GC8034_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
/*SP*/
UINT32 SP0A19_YUV_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 SP250A_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
/*A*/
UINT32 A5141_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 A5142_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
/*HM*/
UINT32 HM3451SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
/*AR*/
UINT32 AR0833_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
/*SIV*/
UINT32 SIV120B_YUV_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 SIV121D_YUV_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
/*PAS (PixArt Image)*/
UINT32 PAS6180_SERIAL_YUV_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
/*Panasoic*/
UINT32 MN34152_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
/*Toshiba*/
UINT32 T4K28_YUV_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 T4KA7_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
/*Others*/
UINT32 ISX012_MIPI_YUV_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 T8EV5_YUV_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
extern struct IMGSENSOR_INIT_FUNC_LIST kdSensorList[];
#endif
@@ -0,0 +1,5 @@
# SPDX-License-Identifier: GPL-2.0
obj-y += imx230mipi_Sensor.o
obj-y += imx230_eeprom.o
@@ -0,0 +1,148 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#define PFX "IMX230_pdafotp"
#define pr_fmt(fmt) PFX "[%s] " fmt, __func__
#include <linux/videodev2.h>
#include <linux/i2c.h>
#include <linux/platform_device.h>
#include <linux/delay.h>
#include <linux/cdev.h>
#include <linux/uaccess.h>
#include <linux/fs.h>
#include <linux/atomic.h>
#include <linux/slab.h>
#include "kd_camera_typedef.h"
#include "kd_imgsensor.h"
#include "kd_imgsensor_define.h"
#include "kd_imgsensor_errcode.h"
#include "imx230mipi_Sensor.h"
#define USHORT unsigned short
#define BYTE unsigned char
#define Sleep(ms) mdelay(ms)
#define IMX230_EEPROM_READ_ID 0xA0
#define IMX230_EEPROM_WRITE_ID 0xA1
#define IMX230_I2C_SPEED 100
#define IMX230_MAX_OFFSET 0xFFFF
#define DATA_SIZE 2048
#define SPC_START_ADDR (0x763 + 96)
#define DCC_START_ADDR 0x448
BYTE IMX230_DCC_data[96] = { 0 };
static bool get_done_dcc;
static int last_size_dcc;
static bool get_done_spc;
static int last_size_spc;
#if 0
static bool selective_read_eeprom(kal_uint16 addr, BYTE *data)
{
char pu_send_cmd[2] = { (char)(addr >> 8), (char)(addr & 0xFF) };
if (addr > IMX230_MAX_OFFSET)
return false;
if (iReadRegI2C(pu_send_cmd,
2,
(u8 *) data,
1,
IMX230_EEPROM_READ_ID) < 0)
return false;
return true;
}
#endif
static bool _read_imx230_eeprom(kal_uint16 addr, BYTE *data, int size)
{
int i = 0;
int offset = addr;
int ret;
u8 pu_send_cmd[2];
#define MAX_READ_WRITE_SIZE 255
for (i = 0; i < size; i += MAX_READ_WRITE_SIZE) {
pu_send_cmd[0] = (u8) (offset >> 8);
pu_send_cmd[1] = (u8) (offset & 0xFF);
if (i + MAX_READ_WRITE_SIZE > size) {
ret = iReadRegI2C(pu_send_cmd, 2,
(u8 *) (data + i),
(size - i),
IMX230_EEPROM_READ_ID);
} else {
ret = iReadRegI2C(pu_send_cmd, 2,
(u8 *) (data + i),
MAX_READ_WRITE_SIZE,
IMX230_EEPROM_READ_ID);
}
if (ret < 0) {
pr_debug("read spc failed!\n");
return false;
}
offset += MAX_READ_WRITE_SIZE;
}
if (addr == SPC_START_ADDR) {
get_done_spc = true;
last_size_spc = size;
} else {
get_done_dcc = true;
last_size_dcc = size;
}
pr_debug("exit _read_eeprom size = %d\n", size);
return true;
}
void read_imx230_SPC(BYTE *data)
{
int addr = SPC_START_ADDR;
int size = 352;
pr_debug("read imx230 SPC, size = %d\n", size);
#if 1
if (!get_done_spc || last_size_spc != size) {
if (!_read_imx230_eeprom(addr, data, size)) {
get_done_spc = 0;
last_size_spc = 0;
}
}
#endif
/* return true; */
}
void read_imx230_DCC(kal_uint16 addr, BYTE *data, kal_uint32 size)
{
/* int i; */
addr = DCC_START_ADDR;
size = 96;
pr_debug("read imx230 DCC, size = %d\n", size);
if (!get_done_dcc || last_size_dcc != size) {
if (!_read_imx230_eeprom(addr, IMX230_DCC_data, size)) {
get_done_dcc = 0;
last_size_dcc = 0;
}
}
memcpy(data, IMX230_DCC_data, size);
/* return true; */
}
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,180 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#ifndef _IMX230MIPI_SENSOR_H
#define _IMX230MIPI_SENSOR_H
enum IMGSENSOR_MODE {
IMGSENSOR_MODE_INIT,
IMGSENSOR_MODE_PREVIEW,
IMGSENSOR_MODE_CAPTURE,
IMGSENSOR_MODE_VIDEO,
IMGSENSOR_MODE_HIGH_SPEED_VIDEO,
IMGSENSOR_MODE_SLIM_VIDEO,
IMGSENSOR_MODE_CUSTOM1,
IMGSENSOR_MODE_CUSTOM2,
IMGSENSOR_MODE_CUSTOM3,
IMGSENSOR_MODE_CUSTOM4,
IMGSENSOR_MODE_CUSTOM5,
};
struct imgsensor_mode_struct {
kal_uint32 pclk; /* record different mode's pclk */
kal_uint32 linelength; /* record different mode's linelength */
kal_uint32 framelength; /* record different mode's framelength */
/* record different mode's startx of grabwindow */
kal_uint8 startx;
/* record different mode's startx of grabwindow */
kal_uint8 starty;
/* record different mode's width of grabwindow */
kal_uint16 grabwindow_width;
/* record different mode's height of grabwindow */
kal_uint16 grabwindow_height;
/* following for MIPIDataLowPwr2HighSpeedSettleDelayCount
* by different scenario
*/
kal_uint8 mipi_data_lp2hs_settle_dc;
/* following for GetDefaultFramerateByScenario() */
kal_uint16 max_framerate;
kal_uint32 mipi_pixel_rate;
};
/* SENSOR PRIVATE STRUCT FOR VARIABLES*/
struct imgsensor_struct {
kal_uint8 mirror; /* mirrorflip information */
kal_uint8 sensor_mode; /* record IMGSENSOR_MODE enum value */
kal_uint32 shutter; /* current shutter */
kal_uint16 gain; /* current gain */
kal_uint32 pclk; /* current pclk */
kal_uint32 frame_length; /* current framelength */
kal_uint32 line_length; /* current linelength */
/* current min framelength to max framerate */
kal_uint32 min_frame_length;
kal_uint16 dummy_pixel; /* current dummypixel */
kal_uint16 dummy_line; /* current dummline */
kal_uint16 current_fps; /* current max fps */
kal_bool autoflicker_en; /* record autoflicker enable or disable */
kal_uint32 test_pattern; /* record test pattern mode or not */
enum MSDK_SCENARIO_ID_ENUM current_scenario_id; /* current scenario */
kal_uint8 ihdr_mode; /* ihdr enable or disable */
kal_uint8 pdaf_mode; /* ihdr enable or disable */
kal_uint8 i2c_write_id; /* record current sensor's i2c write id */
struct IMGSENSOR_AE_FRM_MODE ae_frm_mode;
kal_uint8 current_ae_effective_frame;
};
/* SENSOR PRIVATE STRUCT FOR CONSTANT*/
struct imgsensor_info_struct {
kal_uint32 sensor_id; /* record sensor id defined in Kd_imgsensor.h */
kal_uint32 checksum_value; /* checksum value for Camera Auto Test */
/* preview scenario relative information */
struct imgsensor_mode_struct pre;
/* capture scenario relative information */
struct imgsensor_mode_struct cap;
/* capture for PIP 24fps relative information,
* capture1 mode must use same framelength,
* linelength with Capture mode for shutter calculate
*/
struct imgsensor_mode_struct cap1;
/* normal video scenario relative information */
struct imgsensor_mode_struct normal_video;
/* high speed video scenario relative information */
struct imgsensor_mode_struct hs_video;
/* slim video for VT scenario relative information */
struct imgsensor_mode_struct slim_video;
kal_uint8 ae_shut_delay_frame; /* shutter delay frame for AE cycle */
/* sensor gain delay frame for AE cycle */
kal_uint8 ae_sensor_gain_delay_frame;
/* isp gain delay frame for AE cycle */
kal_uint8 ae_ispGain_delay_frame;
kal_uint8 ihdr_support; /* 1, support; 0,not support */
kal_uint8 ihdr_le_firstline; /* 1,le first ; 0, se first */
kal_uint8 temperature_support; /* 1, support; 0,not support */
kal_uint8 sensor_mode_num; /* support sensor mode num */
kal_uint8 cap_delay_frame; /* enter capture delay frame num */
kal_uint8 pre_delay_frame; /* enter preview delay frame num */
kal_uint8 video_delay_frame; /* enter video delay frame num */
/* enter high speed video delay frame num */
kal_uint8 hs_video_delay_frame;
/* enter slim video delay frame num */
kal_uint8 slim_video_delay_frame;
kal_uint8 margin; /* sensor framelength & shutter margin */
kal_uint32 min_shutter; /* min shutter */
/* max framelength by sensor register's limitation */
kal_uint32 max_frame_length;
kal_uint8 isp_driving_current; /* mclk driving current */
kal_uint8 sensor_interface_type; /* sensor_interface_type */
/* 0,MIPI_OPHY_NCSI2; 1,MIPI_OPHY_CSI2,
* default is NCSI2, don't modify this para
*/
kal_uint8 mipi_sensor_type;
kal_uint8 mipi_settle_delay_mode; /* manual mode only */
/* sensor output first pixel color */
kal_uint8 sensor_output_dataformat;
kal_uint8 mclk;
kal_uint8 mipi_lane_num; /* mipi lane num */
/* record sensor support all write id addr,
* only supprt 4must end with 0xff
*/
kal_uint8 i2c_addr_table[5];
kal_uint32 i2c_speed;
};
extern int iReadRegI2C(u8 *a_pSendData,
u16 a_sizeSendData,
u8 *a_pRecvData,
u16 a_sizeRecvData,
u16 i2cId);
extern int iWriteRegI2C(u8 *a_pSendData, u16 a_sizeSendData, u16 i2cId);
extern void read_imx230_eeprom(void);
extern void read_imx230_SPC(BYTE *data);
extern void read_imx230_DCC(kal_uint16 addr, BYTE *data, kal_uint32 size);
int iBurstWriteReg_multi(
u8 *pData,
u32 bytes,
u16 i2cId,
u16 transfer_length,
u16 timing);
#endif
@@ -0,0 +1,5 @@
# SPDX-License-Identifier: GPL-2.0
#obj-y += imx258_pdafotp.o
obj-y += imx258mipimono_Sensor.o
@@ -0,0 +1,177 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
*/
/************************************************************************
*
* Filename:
* ---------
* IMX258mipiraw_Sensor.h
*
* Project:
* --------
* ALPS
*
* Description:
* ------------
* CMOS sensor header file
*
************************************************************************/
#ifndef _IMX258MIPI_MONO_SENSOR_H
#define _IMX258MIPI_MONO_SENSOR_H
enum IMGSENSOR_MODE {
IMGSENSOR_MODE_INIT,
IMGSENSOR_MODE_PREVIEW,
IMGSENSOR_MODE_CAPTURE,
IMGSENSOR_MODE_VIDEO,
IMGSENSOR_MODE_HIGH_SPEED_VIDEO,
IMGSENSOR_MODE_SLIM_VIDEO,
IMGSENSOR_MODE_CUSTOM1,
IMGSENSOR_MODE_CUSTOM2,
};
struct imgsensor_mode_struct {
kal_uint32 pclk; /* record different mode's pclk */
kal_uint32 linelength; /* record different mode's linelength */
kal_uint32 framelength; /* record different mode's framelength */
kal_uint8 startx; /* record different mode's startx of grabwindow */
kal_uint8 starty; /* record different mode's startx of grabwindow */
/* record different mode's width of grabwindow */
kal_uint16 grabwindow_width;
/* record different mode's height of grabwindow */
kal_uint16 grabwindow_height;
/* following for MIPIDataLowPwr2HighSpeedSettleDelayCount
* by different scenario
*/
kal_uint8 mipi_data_lp2hs_settle_dc;
/* following for GetDefaultFramerateByScenario() */
kal_uint16 max_framerate;
};
/* SENSOR PRIVATE STRUCT FOR VARIABLES*/
struct imgsensor_struct {
kal_uint8 mirror; /* mirrorflip information */
kal_uint8 sensor_mode; /* record IMGSENSOR_MODE enum value */
kal_uint32 shutter; /* current shutter */
kal_uint16 gain; /* current gain */
kal_uint32 pclk; /* current pclk */
kal_uint32 frame_length; /* current framelength */
kal_uint32 line_length; /* current linelength */
/* current min framelength to max framerate */
kal_uint32 min_frame_length;
kal_uint16 dummy_pixel; /* current dummypixel */
kal_uint16 dummy_line; /* current dummline */
kal_uint16 current_fps; /* current max fps */
kal_bool autoflicker_en; /* record autoflicker enable or disable */
kal_bool test_pattern; /* record test pattern mode or not */
enum MSDK_SCENARIO_ID_ENUM current_scenario_id;/* current scenario id */
/* HDR mODE : 0: disable HDR, 1:IHDR, 2:HDR, 9:ZHDR */
kal_uint8 hdr_mode;
/* PDAF enable or disable */
kal_uint8 pdaf_mode;
kal_uint8 i2c_write_id; /* record current sensor's i2c write id */
};
/* SENSOR PRIVATE STRUCT FOR CONSTANT*/
struct imgsensor_info_struct {
kal_uint32 sensor_id; /* record sensor id defined in Kd_imgsensor.h */
kal_uint32 checksum_value; /* checksum value for Camera Auto Test */
/* preview scenario relative information */
struct imgsensor_mode_struct pre;
/* capture scenario relative information */
struct imgsensor_mode_struct cap;
/* capture for different 24fps */
struct imgsensor_mode_struct cap1;
/* normal video scenario relative information */
struct imgsensor_mode_struct normal_video;
/* high speed video scenario relative information */
struct imgsensor_mode_struct hs_video;
/* slim video for VT scenario relative information */
struct imgsensor_mode_struct slim_video;
struct imgsensor_mode_struct custom1;
struct imgsensor_mode_struct custom2;
kal_uint8 ae_shut_delay_frame; /* shutter delay frame for AE cycle */
/* sensor gain delay frame for AE cycle */
kal_uint8 ae_sensor_gain_delay_frame;
/* isp gain delay frame for AE cycle */
kal_uint8 ae_ispGain_delay_frame;
kal_uint8 frame_time_delay_frame;
kal_uint8 ihdr_support; /* 1, support; 0,not support */
kal_uint8 ihdr_le_firstline; /* 1,le first ; 0, se first */
kal_uint8 sensor_mode_num; /* support sensor mode num */
kal_uint8 cap_delay_frame; /* enter capture delay frame num */
kal_uint8 pre_delay_frame; /* enter preview delay frame num */
kal_uint8 video_delay_frame; /* enter video delay frame num */
/* enter high speed video delay frame num */
kal_uint8 hs_video_delay_frame;
kal_uint8 slim_video_delay_frame; /* enter slim video delay frame num */
kal_uint8 custom1_delay_frame; /* enter custom1 delay frame num */
kal_uint8 custom2_delay_frame; /* enter custom1 delay frame num */
kal_uint8 margin; /* sensor framelength & shutter margin */
kal_uint32 min_shutter; /* min shutter */
/* max framelength by sensor register's limitation */
kal_uint32 max_frame_length;
kal_uint8 isp_driving_current; /* mclk driving current */
kal_uint8 sensor_interface_type; /* sensor_interface_type */
kal_uint8 mipi_sensor_type;
kal_uint8 mipi_settle_delay_mode;
/* sensor output first pixel color */
kal_uint8 sensor_output_dataformat;
kal_uint8 mclk; /* mclk value, suggest 24 or 26 for 24Mhz or 26Mhz */
kal_uint8 mipi_lane_num; /* mipi lane num */
/* record sensor support all write id addr,
* only supprt 4must end with 0xff
*/
kal_uint8 i2c_addr_table[5];
kal_uint32 i2c_speed; /* i2c speed */
};
extern bool read_imx258_eeprom(
kal_uint16 addr, BYTE *data, kal_uint32 size);
extern bool read_imx258_eeprom_SPC(
kal_uint16 addr, BYTE *data, kal_uint32 size);
extern int iReadRegI2C(u8 *a_pSendData, u16 a_sizeSendData,
u8 *a_pRecvData, u16 a_sizeRecvData, u16 i2cId);
extern int iWriteRegI2C(u8 *a_pSendData, u16 a_sizeSendData, u16 i2cId);
#endif
@@ -0,0 +1,5 @@
# SPDX-License-Identifier: GPL-2.0
obj-y += imx258_pdafotp.o
obj-y += imx258mipiraw_Sensor.o
@@ -0,0 +1,140 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#define IMX258_PDAFOTP_DEBUG
#ifdef IMX258_PDAFOTP_DEBUG
#define PFX "IMX258_pdafotp"
#define pr_fmt(fmt) PFX "[%s] " fmt, __func__
#endif
#include <linux/videodev2.h>
#include <linux/i2c.h>
#include <linux/platform_device.h>
#include <linux/delay.h>
#include <linux/cdev.h>
#include <linux/uaccess.h>
#include <linux/fs.h>
#include <linux/atomic.h>
#include <linux/slab.h>
#include "kd_camera_typedef.h"
#include "kd_imgsensor.h"
#include "kd_imgsensor_define.h"
#include "kd_imgsensor_errcode.h"
#include "imx258_pdafotp.h"
#define USHORT unsigned short
#define BYTE unsigned char
#define Sleep(ms) mdelay(ms)
#define IMX258_EEPROM_READ_ID 0xA0
#define IMX258_EEPROM_WRITE_ID 0xA1
#define IMX258_I2C_SPEED 100
#define IMX258_MAX_OFFSET 0xFFFF
#define DATA_SIZE 2048
BYTE imx258_eeprom_data[DATA_SIZE] = { 0 };
static bool get_done;
static int last_size;
static int last_offset;
static bool selective_read_eeprom(kal_uint16 addr, BYTE *data)
{
char pu_send_cmd[2] = { (char)(addr >> 8), (char)(addr & 0xFF) };
if (addr > IMX258_MAX_OFFSET)
return false;
if (iReadRegI2C(pu_send_cmd, 2, (u8 *) data, 1, IMX258_EEPROM_READ_ID) < 0) {
/*20171116ken : fix coding style*/
return false;
}
return true;
}
static bool _read_imx258_eeprom(kal_uint16 addr, BYTE *data, kal_uint32 size)
{
int i = 0;
int offset = addr;
for (i = 0; i < size; i++) {
if (!selective_read_eeprom(offset, &data[i]))
return false;
pr_debug("read_eeprom 0x%0x %d\n", offset, data[i]);
offset++;
}
get_done = true;
last_size = size;
last_offset = addr;
return true;
}
bool read_imx258_pdaf(kal_uint16 addr, BYTE *data, kal_uint32 size)
{
addr = 0x0763;
size = 1404;
pr_debug("read imx258 eeprom, size = %d\n", size);
if (!get_done || last_size != size || last_offset != addr) {
if (!_read_imx258_eeprom(addr, imx258_eeprom_data, size)) {
get_done = 0;
last_size = 0;
last_offset = 0;
return false;
}
}
memcpy(data, imx258_eeprom_data, size);
return true;
}
bool read_imx258_eeprom(kal_uint16 addr, BYTE *data, kal_uint32 size)
{
addr = 0x0763;
size = 1404;
pr_debug("read imx258 eeprom, size = %d\n", size);
if (!get_done || last_size != size || last_offset != addr) {
if (!_read_imx258_eeprom(addr, imx258_eeprom_data, size)) {
get_done = 0;
last_size = 0;
last_offset = 0;
return false;
}
}
memcpy(data, imx258_eeprom_data, size);
return true;
}
bool read_imx258_eeprom_SPC(kal_uint16 addr, BYTE *data, kal_uint32 size)
{
addr = 0x0F6D; /* 0x0F73; */
size = 126;
pr_debug("read imx258 eeprom, size = %d\n", size);
if (!get_done || last_size != size || last_offset != addr) {
if (!_read_imx258_eeprom(addr, imx258_eeprom_data, size)) {
get_done = 0;
last_size = 0;
last_offset = 0;
return false;
}
}
/* memset(imx258_eeprom_data, 0x01, size); */
memcpy(data, imx258_eeprom_data, size);
return true;
}
@@ -0,0 +1,9 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
*/
extern int iReadRegI2C(u8 *a_pSendData, u16 a_sizeSendData, u8 *a_pRecvData,
u16 a_sizeRecvData, u16 i2cId);
extern int iWriteRegI2C(u8 *a_pSendData, u16 a_sizeSendData, u16 i2cId);
extern int iMultiReadReg(u16 a_u2Addr, u8 *a_puBuff, u16 i2cId, u8 number);
@@ -0,0 +1,175 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
*/
/*****************************************************************************
*
* Filename:
* ---------
* IMX258mipiraw_Sensor.h
*
* Project:
* --------
* ALPS
*
* Description:
* ------------
* CMOS sensor header file
*
****************************************************************************/
#ifndef _IMX258MIPIRAW_SENSOR_H
#define _IMX258MIPIRAW_SENSOR_H
enum IMGSENSOR_MODE {
IMGSENSOR_MODE_INIT,
IMGSENSOR_MODE_PREVIEW,
IMGSENSOR_MODE_CAPTURE,
IMGSENSOR_MODE_VIDEO,
IMGSENSOR_MODE_HIGH_SPEED_VIDEO,
IMGSENSOR_MODE_SLIM_VIDEO,
IMGSENSOR_MODE_CUSTOM1,
IMGSENSOR_MODE_CUSTOM2,
};
struct imgsensor_mode_struct {
kal_uint32 pclk; /* record different mode's pclk */
kal_uint32 linelength; /* record different mode's linelength */
kal_uint32 framelength; /* record different mode's framelength */
kal_uint8 startx; /* record different mode's startx of grabwindow */
kal_uint8 starty; /* record different mode's startx of grabwindow */
/* record different mode's width of grabwindow */
kal_uint16 grabwindow_width;
/* record different mode's height of grabwindow */
kal_uint16 grabwindow_height;
/* following for MIPIDataLowPwr2HighSpeedSettleDelayCount
* by different scenario
*/
kal_uint8 mipi_data_lp2hs_settle_dc;
/* following for GetDefaultFramerateByScenario() */
kal_uint16 max_framerate;
};
/* SENSOR PRIVATE STRUCT FOR VARIABLES*/
struct imgsensor_struct {
kal_uint8 mirror; /* mirrorflip information */
kal_uint8 sensor_mode; /* record IMGSENSOR_MODE enum value */
kal_uint32 shutter; /* current shutter */
kal_uint16 gain; /* current gain */
kal_uint32 pclk; /* current pclk */
kal_uint32 frame_length; /* current framelength */
kal_uint32 line_length; /* current linelength */
/* current min framelength to max framerate */
kal_uint32 min_frame_length;
kal_uint16 dummy_pixel; /* current dummypixel */
kal_uint16 dummy_line; /* current dummline */
kal_uint16 current_fps; /* current max fps */
kal_bool autoflicker_en; /* record autoflicker enable or disable */
kal_bool test_pattern; /* record test pattern mode or not */
enum MSDK_SCENARIO_ID_ENUM current_scenario_id;/* current scenario id */
/* HDR mODE : 0: disable HDR, 1:IHDR, 2:HDR, 9:ZHDR */
kal_uint8 hdr_mode;
kal_uint8 pdaf_mode; /* PDAF enable or disable */
kal_uint8 i2c_write_id; /* record current sensor's i2c write id */
};
/* SENSOR PRIVATE STRUCT FOR CONSTANT*/
struct imgsensor_info_struct {
kal_uint32 sensor_id; /* record sensor id defined in Kd_imgsensor.h */
kal_uint32 checksum_value; /* checksum value for Camera Auto Test */
/* preview scenario relative information */
struct imgsensor_mode_struct pre;
/* capture scenario relative information */
struct imgsensor_mode_struct cap;
struct imgsensor_mode_struct cap1;
/* normal video scenario relative information */
struct imgsensor_mode_struct normal_video;
/* high speed video scenario relative information */
struct imgsensor_mode_struct hs_video;
/* slim video for VT scenario relative information */
struct imgsensor_mode_struct slim_video;
struct imgsensor_mode_struct custom1;
struct imgsensor_mode_struct custom2;
kal_uint8 ae_shut_delay_frame; /* shutter delay frame for AE cycle */
/* sensor gain delay frame for AE cycle */
kal_uint8 ae_sensor_gain_delay_frame;
/* isp gain delay frame for AE cycle */
kal_uint8 ae_ispGain_delay_frame;
kal_uint8 frame_time_delay_frame;
kal_uint8 ihdr_support; /* 1, support; 0,not support */
kal_uint8 ihdr_le_firstline; /* 1,le first ; 0, se first */
kal_uint8 sensor_mode_num; /* support sensor mode num */
kal_uint8 cap_delay_frame; /* enter capture delay frame num */
kal_uint8 pre_delay_frame; /* enter preview delay frame num */
kal_uint8 video_delay_frame; /* enter video delay frame num */
/* enter high speed video delay frame num */
kal_uint8 hs_video_delay_frame;
/* enter slim video delay frame num */
kal_uint8 slim_video_delay_frame;
kal_uint8 custom1_delay_frame; /* enter custom1 delay frame num */
kal_uint8 custom2_delay_frame; /* enter custom1 delay frame num */
kal_uint8 margin; /* sensor framelength & shutter margin */
kal_uint32 min_shutter; /* min shutter */
/* max framelength by sensor register's limitation */
kal_uint32 max_frame_length;
kal_uint8 isp_driving_current; /* mclk driving current */
kal_uint8 sensor_interface_type; /* sensor_interface_type */
kal_uint8 mipi_sensor_type;
kal_uint8 mipi_settle_delay_mode;/* always manual*/
/* sensor output first pixel color */
kal_uint8 sensor_output_dataformat;
kal_uint8 mclk; /* mclk value, suggest 24 or 26 for 24Mhz or 26Mhz */
kal_uint8 mipi_lane_num; /* mipi lane num */
/* record sensor support all write id addr, only supprt 4must end with 0xff */
kal_uint8 i2c_addr_table[5];
kal_uint32 i2c_speed; /* i2c speed */
};
extern bool read_imx258_eeprom(kal_uint16 addr, BYTE *data, kal_uint32 size);
extern bool read_imx258_pdaf(kal_uint16 addr, BYTE *data, kal_uint32 size);
extern bool read_imx258_eeprom_SPC(
kal_uint16 addr, BYTE *data, kal_uint32 size);
extern int iReadRegI2C(u8 *a_pSendData, u16 a_sizeSendData,
u8 *a_pRecvData, u16 a_sizeRecvData, u16 i2cId);
extern int iWriteRegI2C(u8 *a_pSendData, u16 a_sizeSendData, u16 i2cId);
#endif
@@ -0,0 +1,3 @@
# SPDX-License-Identifier: GPL-2.0
obj-y += imx318mipi_Sensor.o
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,182 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
*/
/*****************************************************************************
*
* Filename:
* ---------
* IMX3183mipi_Sensor.h
*
* Project:
* --------
* ALPS
*
* Description:
* ------------
* CMOS sensor header file
*
****************************************************************************/
#ifndef _IMX318MIPI_SENSOR_H
#define _IMX318MIPI_SENSOR_H
enum IMGSENSOR_MODE {
IMGSENSOR_MODE_INIT,
IMGSENSOR_MODE_PREVIEW,
IMGSENSOR_MODE_CAPTURE,
IMGSENSOR_MODE_VIDEO,
IMGSENSOR_MODE_HIGH_SPEED_VIDEO,
IMGSENSOR_MODE_SLIM_VIDEO,
};
struct imgsensor_mode_struct {
kal_uint32 pclk; /* record different mode's pclk */
kal_uint32 linelength; /* record different mode's linelength */
kal_uint32 framelength; /* record different mode's framelength */
kal_uint8 startx; /* record different mode's startx of grabwindow */
kal_uint8 starty; /* record different mode's startx of grabwindow */
/* record different mode's width of grabwindow */
kal_uint16 grabwindow_width;
/* record different mode's height of grabwindow */
kal_uint16 grabwindow_height;
/* following for MIPIDataLowPwr2HighSpeedSettleDelayCount
* by different scenario
*/
kal_uint8 mipi_data_lp2hs_settle_dc;
kal_uint32 mipi_pixel_rate;
/* following for GetDefaultFramerateByScenario() */
kal_uint16 max_framerate;
};
/* SENSOR PRIVATE STRUCT FOR VARIABLES*/
struct imgsensor_struct {
kal_uint8 mirror; /* mirrorflip information */
kal_uint8 sensor_mode; /* record IMGSENSOR_MODE enum value */
kal_uint32 shutter; /* current shutter */
kal_uint16 gain; /* current gain */
kal_uint32 pclk; /* current pclk */
kal_uint32 frame_length; /* current framelength */
kal_uint32 line_length; /* current linelength */
/* current min framelength to max framerate */
kal_uint32 min_frame_length;
kal_uint16 dummy_pixel; /* current dummypixel */
kal_uint16 dummy_line; /* current dummline */
kal_uint16 current_fps; /* current max fps */
kal_bool autoflicker_en; /* record autoflicker enable or disable */
kal_bool test_pattern; /* record test pattern mode or not */
enum MSDK_SCENARIO_ID_ENUM current_scenario_id;/* current scenario id */
kal_uint8 ihdr_mode; /* ihdr enable or disable */
kal_uint8 pdaf_mode; /* ihdr enable or disable */
kal_uint8 i2c_write_id; /* record current sensor's i2c write id */
};
/* SENSOR PRIVATE STRUCT FOR CONSTANT*/
struct imgsensor_info_struct {
kal_uint32 sensor_id; /* record sensor id defined in Kd_imgsensor.h */
kal_uint32 checksum_value; /* checksum value for Camera Auto Test */
/* preview scenario relative information */
struct imgsensor_mode_struct pre;
/* capture scenario relative information */
struct imgsensor_mode_struct cap;
struct imgsensor_mode_struct cap1;
/* capture for PIP 24fps relative information,
* capture1 mode must use same framelength,
* linelength with Capture mode for shutter calculate
*/
/* normal video scenario relative information */
struct imgsensor_mode_struct normal_video;
/* high speed video scenario relative information */
struct imgsensor_mode_struct hs_video;
/* slim video for VT scenario relative information */
struct imgsensor_mode_struct slim_video;
kal_uint8 ae_shut_delay_frame; /* shutter delay frame for AE cycle */
/* sensor gain delay frame for AE cycle */
kal_uint8 ae_sensor_gain_delay_frame;
/* isp gain delay frame for AE cycle */
kal_uint8 ae_ispGain_delay_frame;
kal_uint8 ihdr_support; /* 1, support; 0,not support */
kal_uint8 ihdr_le_firstline; /* 1,le first ; 0, se first */
kal_uint8 temperature_support;
kal_uint8 sensor_mode_num; /* support sensor mode num */
kal_uint8 cap_delay_frame; /* enter capture delay frame num */
kal_uint8 pre_delay_frame; /* enter preview delay frame num */
kal_uint8 video_delay_frame; /* enter video delay frame num */
/* enter high speed video delay frame num */
kal_uint8 hs_video_delay_frame;
kal_uint8 slim_video_delay_frame; /* enter slim video delay frame num */
kal_uint8 margin; /* sensor framelength & shutter margin */
kal_uint32 min_shutter; /* min shutter */
/* max framelength by sensor register's limitation */
kal_uint32 max_frame_length;
kal_uint8 isp_driving_current; /* mclk driving current */
kal_uint8 sensor_interface_type; /* sensor_interface_type */
kal_uint8 mipi_sensor_type;
/* 0,MIPI_OPHY_NCSI2; 1,MIPI_OPHY_CSI2, default is NCSI2,
* don't modify this para
*/
kal_uint8 mipi_settle_delay_mode;
/* 0, high speed signal auto detect;
* 1, use settle delay,unit is ns,
* default is auto detect, don't modify this para
*/
/* sensor output first pixel color */
kal_uint8 sensor_output_dataformat;
kal_uint8 mclk; /* mclk value, suggest 24 or 26 for 24Mhz or 26Mhz */
kal_uint32 i2c_speed; /* i2c speed */
kal_uint8 mipi_lane_num; /* mipi lane num */
/* record sensor support all write id addr, only supprt 4must end with 0xff */
kal_uint8 i2c_addr_table[5];
};
/* SENSOR READ/WRITE ID */
/* #define IMGSENSOR_WRITE_ID_1 (0x6c) */
/* #define IMGSENSOR_READ_ID_1 (0x6d) */
/* #define IMGSENSOR_WRITE_ID_2 (0x20) */
/* #define IMGSENSOR_READ_ID_2 (0x21) */
extern int iReadRegI2C(u8 *a_pSendData, u16 a_sizeSendData,
u8 *a_pRecvData, u16 a_sizeRecvData, u16 i2cId);
extern int iWriteRegI2C(u8 *a_pSendData, u16 a_sizeSendData, u16 i2cId);
extern void read_imx230_eeprom(void);
int iBurstWriteReg_multi(u8 *pData, u32 bytes,
u16 i2cId, u16 transfer_length, u16 timing);
#endif
@@ -0,0 +1,4 @@
# SPDX-License-Identifier: GPL-2.0
obj-y += imx338mipi_Sensor.o
obj-y += imx338_eeprom.o
@@ -0,0 +1,126 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#define PFX "IMX338_pdafotp"
#define pr_fmt(fmt) PFX "[%s] " fmt, __func__
#include <linux/videodev2.h>
#include <linux/i2c.h>
#include <linux/platform_device.h>
#include <linux/delay.h>
#include <linux/cdev.h>
#include <linux/uaccess.h>
#include <linux/fs.h>
#include <linux/atomic.h>
#include <linux/slab.h>
#include "kd_camera_typedef.h"
#include "kd_imgsensor.h"
#include "kd_imgsensor_define.h"
#include "kd_imgsensor_errcode.h"
#include "imx338_eeprom.h"
#define USHORT unsigned short
#define BYTE unsigned char
#define Sleep(ms) mdelay(ms)
#define IMX338_EEPROM_READ_ID 0xA0
#define IMX338_EEPROM_WRITE_ID 0xA1
#define IMX338_I2C_SPEED 100
#define IMX338_MAX_OFFSET 4096
#define DATA_SIZE 2048
#define SPC_START_ADDR 0x763
#define DCC_START_ADDR 0x8c3
BYTE IMX338_DCC_data[384] = { 0 }; /* 16x12x2 */
static bool get_done_dcc;
static int last_size_dcc;
static int last_offset_dcc;
static bool get_done_spc;
static int last_size_spc;
static int last_offset_spc;
static bool selective_read_eeprom(kal_uint16 addr, BYTE *data)
{
char pu_send_cmd[2] = { (char)(addr >> 8), (char)(addr & 0xFF) };
if (addr > IMX338_MAX_OFFSET)
return false;
if (iReadRegI2C(
pu_send_cmd, 2, (u8 *) data, 1, IMX338_EEPROM_READ_ID) < 0)
return false;
return true;
}
static bool _read_imx338_eeprom(kal_uint16 addr, BYTE *data, int size)
{
int i = 0;
int offset = addr;
pr_debug("enter _read_eeprom size = %d\n", size);
for (i = 0; i < size; i++) {
if (!selective_read_eeprom(offset, &data[i]))
return false;
/* pr_debug("read_eeprom 0x%0x %d\n",offset, data[i]); */
offset++;
}
if (addr == SPC_START_ADDR) {
get_done_spc = true;
last_size_spc = size;
last_offset_spc = offset;
} else {
get_done_dcc = true;
last_size_dcc = size;
last_offset_dcc = offset;
}
return true;
}
void read_imx338_SPC(BYTE *data)
{
int addr = SPC_START_ADDR;
int size = 352;
if (!get_done_spc || last_size_spc != size) {
if (!_read_imx338_eeprom(addr, data, size)) {
get_done_spc = 0;
last_size_spc = 0;
last_offset_spc = 0;
/* return false; */
}
}
/* memcpy(data, IMX338_SPC_data , size); */
/* return true; */
}
void read_imx338_DCC(kal_uint16 addr, BYTE *data, kal_uint32 size)
{
/* int i; */
addr = DCC_START_ADDR;
size = 384;
if (!get_done_dcc || last_size_dcc != size) {
if (!_read_imx338_eeprom(addr, IMX338_DCC_data, size)) {
get_done_dcc = 0;
last_size_dcc = 0;
last_offset_dcc = 0;
/* return false; */
}
}
memcpy(data, IMX338_DCC_data, size);
/* return true; */
}
@@ -0,0 +1,19 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
*/
extern int iReadRegI2C(u8 *a_pSendData, u16 a_sizeSendData,
u8 *a_pRecvData, u16 a_sizeRecvData, u16 i2cId);
extern int iReadRegI2CTiming(
u8 *a_pSendData,
u16 a_sizeSendData,
u8 *a_pRecvData,
u16 a_sizeRecvData,
u16 i2cId,
u16 timing);
extern int iWriteRegI2C(u8 *a_pSendData, u16 a_sizeSendData, u16 i2cId);
extern int iMultiReadReg(u16 a_u2Addr, u8 *a_puBuff, u16 i2cId, u8 number);
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,227 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
*/
/************************************************************************
*
* Filename:
* ---------
* IMX338mipi_Sensor.h
*
* Project:
* --------
* ALPS
*
* Description:
* ------------
* CMOS sensor header file
*
************************************************************************/
#ifndef _IMX338MIPI_SENSOR_H
#define _IMX338MIPI_SENSOR_H
enum IMGSENSOR_MODE {
IMGSENSOR_MODE_INIT,
IMGSENSOR_MODE_PREVIEW,
IMGSENSOR_MODE_CAPTURE,
IMGSENSOR_MODE_VIDEO,
IMGSENSOR_MODE_HIGH_SPEED_VIDEO,
IMGSENSOR_MODE_SLIM_VIDEO,
IMGSENSOR_MODE_CUSTOM1,
IMGSENSOR_MODE_CUSTOM2,
IMGSENSOR_MODE_CUSTOM3,
IMGSENSOR_MODE_CUSTOM4,
IMGSENSOR_MODE_CUSTOM5,
};
struct imgsensor_mode_struct {
kal_uint32 pclk; /* record different mode's pclk */
kal_uint32 linelength; /* record different mode's linelength */
kal_uint32 framelength; /* record different mode's framelength */
/* record different mode's startx of grabwindow */
kal_uint8 startx;
/* record different mode's startx of grabwindow */
kal_uint8 starty;
/* record different mode's width of grabwindow */
kal_uint16 grabwindow_width;
/* record different mode's height of grabwindow */
kal_uint16 grabwindow_height;
/* following for MIPIDataLowPwr2HighSpeedSettleDelayCount
* by different scenario
*/
kal_uint8 mipi_data_lp2hs_settle_dc;
/* following for GetDefaultFramerateByScenario() */
kal_uint16 max_framerate;
/* record mipi pixel rate */
kal_uint32 mipi_pixel_rate;
};
/* SENSOR PRIVATE STRUCT FOR VARIABLES*/
struct imgsensor_struct {
kal_uint8 mirror; /* mirrorflip information */
kal_uint8 sensor_mode; /* record IMGSENSOR_MODE enum value */
kal_uint32 shutter; /* current shutter */
kal_uint16 gain; /* current gain */
kal_uint32 pclk; /* current pclk */
kal_uint32 frame_length; /* current framelength */
kal_uint32 line_length; /* current linelength */
/* current min framelength to max framerate */
kal_uint32 min_frame_length;
kal_uint16 dummy_pixel; /* current dummypixel */
kal_uint16 dummy_line; /* current dummline */
kal_uint16 current_fps; /* current max fps */
kal_bool autoflicker_en;/* record autoflicker enable or disable */
kal_bool test_pattern; /* record test pattern mode or not */
enum MSDK_SCENARIO_ID_ENUM current_scenario_id;/* current scenario */
kal_uint8 hdr_mode; /* HDR mode */
kal_uint8 pdaf_mode; /* ihdr enable or disable */
kal_uint8 i2c_write_id; /* record current sensor's i2c write id */
};
/* SENSOR PRIVATE STRUCT FOR CONSTANT*/
struct imgsensor_info_struct {
kal_uint32 sensor_id;/* record sensor id defined in Kd_imgsensor.h */
kal_uint32 checksum_value;/* checksum value for Camera Auto Test */
/* preview scenario relative information */
struct imgsensor_mode_struct pre;
/* capture scenario relative information */
struct imgsensor_mode_struct cap;
/* capture for PIP 24fps relative information,
* capture1 mode must use same framelength,
* linelength with Capture mode for shutter calculate
*/
struct imgsensor_mode_struct cap1;
/* normal video scenario relative information */
struct imgsensor_mode_struct normal_video;
/* high speed video scenario relative information */
struct imgsensor_mode_struct hs_video;
/* slim video for VT scenario relative information */
struct imgsensor_mode_struct slim_video;
/* custom1 scenario relative information */
struct imgsensor_mode_struct custom1;
/* custom2 scenario relative information */
struct imgsensor_mode_struct custom2;
/* custom3 scenario relative information */
struct imgsensor_mode_struct custom3;
/* custom4 scenario relative information */
struct imgsensor_mode_struct custom4;
struct imgsensor_mode_struct custom5;
kal_uint8 ae_shut_delay_frame; /* shutter delay frame for AE cycle */
/* sensor gain delay frame for AE cycle */
kal_uint8 ae_sensor_gain_delay_frame;
/* isp gain delay frame for AE cycle */
kal_uint8 ae_ispGain_delay_frame;
kal_uint8 ihdr_support; /* 1, support; 0,not support */
kal_uint8 ihdr_le_firstline; /* 1,le first ; 0, se first */
kal_uint8 temperature_support; /* 1, support; 0,not support */
kal_uint8 sensor_mode_num; /* support sensor mode num */
kal_uint8 cap_delay_frame; /* enter capture delay frame num */
kal_uint8 pre_delay_frame; /* enter preview delay frame num */
kal_uint8 video_delay_frame; /* enter video delay frame num */
/* enter high speed video delay frame num */
kal_uint8 hs_video_delay_frame;
/* enter slim video delay frame num */
kal_uint8 slim_video_delay_frame;
kal_uint8 margin; /* sensor framelength & shutter margin */
kal_uint32 min_shutter; /* min shutter */
/* max framelength by sensor register's limitation */
kal_uint32 max_frame_length;
kal_uint8 isp_driving_current; /* mclk driving current */
kal_uint8 sensor_interface_type; /* sensor_interface_type */
/* 0,MIPI_OPHY_NCSI2; 1,MIPI_OPHY_CSI2,
* default is NCSI2, don't modify this para
*/
kal_uint8 mipi_sensor_type;
kal_uint8 mipi_settle_delay_mode;/* manual mode only */
/* sensor output first pixel color */
kal_uint8 sensor_output_dataformat;
kal_uint8 mclk;
kal_uint32 i2c_speed;
kal_uint8 mipi_lane_num; /* mipi lane num */
/* record sensor support all write id addr,
* only supprt 4must end with 0xff
*/
kal_uint8 i2c_addr_table[5];
};
/* SENSOR READ/WRITE ID */
/* #define IMGSENSOR_WRITE_ID_1 (0x6c) */
/* #define IMGSENSOR_READ_ID_1 (0x6d) */
/* #define IMGSENSOR_WRITE_ID_2 (0x20) */
/* #define IMGSENSOR_READ_ID_2 (0x21) */
extern int iReadRegI2C(
u8 *a_pSendData,
u16 a_sizeSendData,
u8 *a_pRecvData,
u16 a_sizeRecvData,
u16 i2cId);
extern int iReadRegI2CTiming(
u8 *a_pSendData,
u16 a_sizeSendData,
u8 *a_pRecvData,
u16 a_sizeRecvData,
u16 i2cId,
u16 timing);
extern int iWriteRegI2C(u8 *a_pSendData, u16 a_sizeSendData, u16 i2cId);
extern int iWriteRegI2CTiming(
u8 *a_pSendData,
u16 a_sizeSendData,
u16 i2cId,
u16 timing);
extern void read_imx230_eeprom(void);
int iBurstWriteReg_multi(
u8 *pData,
u32 bytes,
u16 i2cId,
u16 transfer_length,
u16 timing);
extern void read_imx338_SPC(BYTE *data);
extern void read_imx338_DCC(kal_uint16 addr, BYTE *data, kal_uint32 size);
#endif
@@ -0,0 +1,4 @@
# SPDX-License-Identifier: GPL-2.0
obj-y += imx350mipiraw_Sensor.o
obj-y += imx350_eeprom.o
@@ -0,0 +1,121 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#include <linux/videodev2.h>
#include <linux/i2c.h>
#include <linux/platform_device.h>
#include <linux/delay.h>
#include <linux/cdev.h>
#include <linux/uaccess.h>
#include <linux/fs.h>
#include <linux/atomic.h>
#include <linux/slab.h>
#include "kd_camera_typedef.h"
#define PFX "imx350_pdafotp"
#define LOG_INF(format, args...) \
pr_debug(PFX "[%s] " format, __func__, ##args)
#include "kd_imgsensor.h"
#include "kd_imgsensor_define.h"
#include "kd_imgsensor_errcode.h"
#include "imx350_eeprom.h"
#define USHORT unsigned short
#define BYTE unsigned char
#define Sleep(ms) mdelay(ms)
#define imx350_EEPROM_READ_ID 0xA0
#define imx350_EEPROM_WRITE_ID 0xA1
#define imx350_I2C_SPEED 100
#define imx350_MAX_OFFSET 4096
#define DATA_SIZE 2048
#define SPC_START_ADDR 0x763
#define DCC_START_ADDR 0x8c3
BYTE imx350_DCC_data[384] = { 0 }; /* 16x12x2 */
static bool get_done_dcc;
static int last_size_dcc;
static int last_offset_dcc;
static bool get_done_spc;
static int last_size_spc;
static int last_offset_spc;
static bool imx350_selective_read_eeprom(kal_uint16 addr, BYTE *data)
{
char pu_send_cmd[2] = { (char)(addr >> 8), (char)(addr & 0xFF) };
if (addr > imx350_MAX_OFFSET)
return false;
if (iReadRegI2C(pu_send_cmd, 2,
(u8 *) data, 1, imx350_EEPROM_READ_ID) < 0)
return false;
return true;
}
static bool imx350_read_eeprom(kal_uint16 addr, BYTE *data, int size)
{
int i = 0;
int offset = addr;
LOG_INF("enter _read_eeprom size = %d\n", size);
for (i = 0; i < size; i++) {
if (!imx350_selective_read_eeprom(offset, &data[i]))
return false;
/* LOG_INF("read_eeprom 0x%0x %d\n",offset, data[i]); */
offset++;
}
if (addr == SPC_START_ADDR) {
get_done_spc = true;
last_size_spc = size;
last_offset_spc = offset;
} else {
get_done_dcc = true;
last_size_dcc = size;
last_offset_dcc = offset;
}
return true;
}
void imx350_read_SPC(BYTE *data)
{
int addr = SPC_START_ADDR;
int size = 352;
if (!get_done_spc || last_size_spc != size) {
if (!imx350_read_eeprom(addr, data, size)) {
get_done_spc = 0;
last_size_spc = 0;
last_offset_spc = 0;
/* return false; */
}
}
/* memcpy(data, imx350_SPC_data , size); */
/* return true; */
}
void imx350_read_DCC(kal_uint16 addr, BYTE *data, kal_uint32 size)
{
/* int i; */
addr = DCC_START_ADDR;
size = 384;
if (!get_done_dcc || last_size_dcc != size) {
if (!imx350_read_eeprom(addr, imx350_DCC_data, size)) {
get_done_dcc = 0;
last_size_dcc = 0;
last_offset_dcc = 0;
/* return false; */
}
}
memcpy(data, imx350_DCC_data, size);
/* return true; */
}
@@ -0,0 +1,25 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#ifndef __IMX350_EEPROM_H__
#define __IMX350_EEPROM_H__
#include "kd_camera_typedef.h"
void imx350_read_SPC(BYTE(*data));
void imx350_read_DCC(kal_uint16 addr, BYTE *data, kal_uint32 size);
extern int iReadRegI2C(u8 *a_pSendData, u16 a_sizeSendData,
u8 *a_pRecvData, u16 a_sizeRecvData, u16 i2cId);
extern int iReadRegI2CTiming(u8 *a_pSendData, u16 a_sizeSendData,
u8 *a_pRecvData, u16 a_sizeRecvData,
u16 i2cId, u16 timing);
extern int iWriteRegI2C(u8 *a_pSendData, u16 a_sizeSendData, u16 i2cId);
extern int iMultiReadReg(u16 a_u2Addr, u8 *a_puBuff, u16 i2cId, u8 number);
#endif
@@ -0,0 +1,172 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
*/
/*****************************************************************************
*
* Filename:
* ---------
* IMX338mipi_Sensor.h
*
* Project:
* --------
* ALPS
*
* Description:
* ------------
* CMOS sensor header file
*
****************************************************************************/
#ifndef _IMX350MIPI_SENSOR_H
#define _IMX350MIPI_SENSOR_H
enum IMGSENSOR_MODE {
IMGSENSOR_MODE_INIT,
IMGSENSOR_MODE_PREVIEW,
IMGSENSOR_MODE_CAPTURE,
IMGSENSOR_MODE_VIDEO,
IMGSENSOR_MODE_HIGH_SPEED_VIDEO,
IMGSENSOR_MODE_SLIM_VIDEO,
IMGSENSOR_MODE_CUSTOM1,
IMGSENSOR_MODE_CUSTOM2,
IMGSENSOR_MODE_CUSTOM3,
IMGSENSOR_MODE_CUSTOM4,
IMGSENSOR_MODE_CUSTOM5,
};
struct imgsensor_mode_struct {
kal_uint32 pclk; /* record different mode's pclk */
kal_uint32 linelength; /* record different mode's linelength */
kal_uint32 framelength; /* record different mode's framelength */
kal_uint8 startx; /* record different mode's startx of grabwindow */
kal_uint8 starty; /* record different mode's startx of grabwindow */
/* record different mode's width of grabwindow */
kal_uint16 grabwindow_width;
/* record different mode's height of grabwindow */
kal_uint16 grabwindow_height;
/* following for MIPIDataLowPwr2HighSpeedSettleDelayCount
* by different scenario
*/
kal_uint8 mipi_data_lp2hs_settle_dc;
kal_uint32 mipi_pixel_rate;
/* following for GetDefaultFramerateByScenario() */
kal_uint16 max_framerate;
};
/* SENSOR PRIVATE STRUCT FOR VARIABLES*/
struct imgsensor_struct {
kal_uint8 mirror; /* mirrorflip information */
kal_uint8 sensor_mode; /* record IMGSENSOR_MODE enum value */
kal_uint32 shutter; /* current shutter */
kal_uint16 gain; /* current gain */
kal_uint32 pclk; /* current pclk */
kal_uint32 frame_length; /* current framelength */
kal_uint32 line_length; /* current linelength */
/* current min framelength to max framerate */
kal_uint32 min_frame_length;
kal_uint16 dummy_pixel; /* current dummypixel */
kal_uint16 dummy_line; /* current dummline */
kal_uint16 current_fps; /* current max fps */
kal_bool autoflicker_en; /* record autoflicker enable or disable */
kal_bool test_pattern; /* record test pattern mode or not */
enum MSDK_SCENARIO_ID_ENUM current_scenario_id;/* current scenario id */
kal_uint8 hdr_mode; /* HDR mode */
kal_uint8 pdaf_mode; /* ihdr enable or disable */
kal_uint8 i2c_write_id; /* record current sensor's i2c write id */
};
/* SENSOR PRIVATE STRUCT FOR CONSTANT*/
struct imgsensor_info_struct {
kal_uint32 sensor_id; /* record sensor id defined in Kd_imgsensor.h */
kal_uint32 checksum_value; /* checksum value for Camera Auto Test */
/* preview scenario relative information */
struct imgsensor_mode_struct pre;
/* capture scenario relative information */
struct imgsensor_mode_struct cap;
/* capture for PIP 24fps relative information,
* capture1 mode must use same framelength,
* linelength with Capture mode for shutter calculate
*/
/* normal video scenario relative information */
struct imgsensor_mode_struct normal_video;
/* high speed video scenario relative information */
struct imgsensor_mode_struct hs_video;
kal_uint8 ae_shut_delay_frame; /* shutter delay frame for AE cycle */
/* sensor gain delay frame for AE cycle */
kal_uint8 ae_sensor_gain_delay_frame;
/* isp gain delay frame for AE cycle */
kal_uint8 ae_ispGain_delay_frame;
kal_uint8 ihdr_support; /* 1, support; 0,not support */
kal_uint8 ihdr_le_firstline; /* 1,le first ; 0, se first */
kal_uint8 temperature_support; /* 1, support; 0,not support */
kal_uint8 sensor_mode_num; /* support sensor mode num */
kal_uint8 cap_delay_frame; /* enter capture delay frame num */
kal_uint8 pre_delay_frame; /* enter preview delay frame num */
kal_uint8 video_delay_frame; /* enter video delay frame num */
/* enter high speed video delay frame num */
kal_uint8 hs_video_delay_frame;
kal_uint8 margin; /* sensor framelength & shutter margin */
kal_uint32 min_shutter; /* min shutter */
/* max framelength by sensor register's limitation */
kal_uint32 max_frame_length;
kal_uint8 isp_driving_current; /* mclk driving current */
kal_uint8 sensor_interface_type; /* sensor_interface_type */
kal_uint8 mipi_sensor_type;
/* 0,MIPI_OPHY_NCSI2; 1,MIPI_OPHY_CSI2,
* default is NCSI2, don't modify this para
*/
kal_uint8 mipi_settle_delay_mode;
/* 0, high speed signal auto detect; 1, use settle delay,unit is ns,
*default is auto detect, don't modify this para
*/
kal_uint8 sensor_output_dataformat;/* sensor output first pixel color */
kal_uint8 mclk; /* mclk value, suggest 24 or 26 for 24Mhz or 26Mhz */
kal_uint32 i2c_speed; /* i2c speed */
kal_uint8 mipi_lane_num; /* mipi lane num */
/* record sensor support all write id addr, only supprt 4must end with 0xff */
kal_uint8 i2c_addr_table[5];
};
/* SENSOR READ/WRITE ID */
/* #define IMGSENSOR_WRITE_ID_1 (0x6c) */
/* #define IMGSENSOR_READ_ID_1 (0x6d) */
/* #define IMGSENSOR_WRITE_ID_2 (0x20) */
/* #define IMGSENSOR_READ_ID_2 (0x21) */
extern int iReadRegI2C(u8 *a_pSendData, u16 a_sizeSendData,
u8 *a_pRecvData, u16 a_sizeRecvData,
u16 i2cId);
extern int iReadRegI2CTiming(u8 *a_pSendData, u16 a_sizeSendData,
u8 *a_pRecvData, u16 a_sizeRecvData, u16 i2cId, u16 timing);
extern int iWriteRegI2C(u8 *a_pSendData, u16 a_sizeSendData, u16 i2cId);
extern int iWriteRegI2CTiming(u8 *a_pSendData, u16 a_sizeSendData,
u16 i2cId, u16 timing);
extern int iBurstWriteReg_multi(u8 *pData, u32 bytes, u16 i2cId,
u16 transfer_length, u16 timing);
#endif
@@ -0,0 +1,3 @@
# SPDX-License-Identifier: GPL-2.0
obj-y += imx386mipimono_sensor.o
@@ -0,0 +1,115 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#ifndef _IMX386MIPI_SENSOR_H
#define _IMX386MIPI_SENSOR_H
/* preview capture video hvideo svideo */
enum {
IMGSENSOR_MODE_INIT,
IMGSENSOR_MODE_PREVIEW,
IMGSENSOR_MODE_CAPTURE,
IMGSENSOR_MODE_VIDEO,
IMGSENSOR_MODE_HIGH_SPEED_VIDEO,
IMGSENSOR_MODE_SLIM_VIDEO,
IMGSENSOR_MODE_CUSTOM1,
IMGSENSOR_MODE_CUSTOM2,
IMGSENSOR_MODE_CUSTOM3,
};
struct imgsensor_mode_struct {
kal_uint32 pclk;
kal_uint32 linelength;
kal_uint32 framelength;
kal_uint8 startx;
kal_uint8 starty;
kal_uint16 grabwindow_width;
kal_uint16 grabwindow_height;
kal_uint8 mipi_data_lp2hs_settle_dc;
kal_uint16 max_framerate;
};
/* SENSOR PRIVATE STRUCT FOR VARIABLES*/
struct imgsensor_struct {
kal_uint8 mirror;
kal_uint8 sensor_mode;
kal_uint32 shutter;
kal_uint16 gain;
kal_uint32 pclk;
kal_uint32 frame_length;
kal_uint32 line_length;
kal_uint32 min_frame_length;
kal_uint16 dummy_pixel;
kal_uint16 dummy_line;
kal_uint16 current_fps;
kal_bool autoflicker_en;
kal_bool test_pattern;
enum MSDK_SCENARIO_ID_ENUM current_scenario_id;
kal_bool ihdr_en;
kal_uint8 i2c_write_id;
};
/* SENSOR PRIVATE STRUCT FOR CONSTANT*/
struct imgsensor_info_struct {
kal_uint32 sensor_id;
kal_uint32 checksum_value;
struct imgsensor_mode_struct pre;
struct imgsensor_mode_struct cap;
struct imgsensor_mode_struct cap1;
struct imgsensor_mode_struct normal_video;
struct imgsensor_mode_struct hs_video;
struct imgsensor_mode_struct slim_video;
struct imgsensor_mode_struct custom1;
struct imgsensor_mode_struct custom2;
struct imgsensor_mode_struct custom3;
kal_uint8 ae_shut_delay_frame; /* shutter delay frame for AE cycle */
kal_uint8 ae_sensor_gain_delay_frame;
kal_uint8 ae_ispGain_delay_frame;
kal_uint8 frame_time_delay_frame;
kal_uint8 ihdr_support; /* 1, support; 0,not support */
kal_uint8 ihdr_le_firstline; /* 1,le first ; 0, se first */
kal_uint8 temperature_support; /* 1, support; 0,not support */
kal_uint8 sensor_mode_num; /* support sensor mode num */
kal_uint8 cap_delay_frame;
kal_uint8 pre_delay_frame;
kal_uint8 video_delay_frame; /* enter video delay frame num */
kal_uint8 hs_video_delay_frame;
kal_uint8 slim_video_delay_frame;
kal_uint8 custom1_delay_frame;
kal_uint8 custom2_delay_frame; /* enter custom1 delay frame num */
kal_uint8 custom3_delay_frame;
kal_uint8 margin;
kal_uint32 min_shutter;
kal_uint32 max_frame_length;
kal_uint8 isp_driving_current; /* mclk driving current */
kal_uint8 sensor_interface_type;/* sensor_interface_type */
kal_uint8 mipi_sensor_type;
kal_uint8 mipi_settle_delay_mode;
kal_uint8 sensor_output_dataformat;
kal_uint8 mclk;
kal_uint8 mipi_lane_num; /* mipi lane num */
kal_uint8 i2c_addr_table[5];
kal_uint32 i2c_speed; /* i2c speed */
};
extern int iReadRegI2C(u8 *a_pSendData, u16 a_sizeSendData,
u8 *a_pRecvData, u16 a_sizeRecvData, u16 i2cId);
extern int iWriteRegI2C(u8 *a_pSendData, u16 a_sizeSendData, u16 i2cId);
extern int iBurstWriteReg(u8 *pData, u32 bytes, u16 i2cId);
#endif
@@ -0,0 +1,5 @@
# SPDX-License-Identifier: GPL-2.0
obj-y += imx386mipi_sensor.o
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,181 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#ifndef _IMX386MIPI_SENSOR_H
#define _IMX386MIPI_SENSOR_H
/* preview capture video hvideo svideo */
enum IMGSENSOR_MODE {
IMGSENSOR_MODE_INIT,
IMGSENSOR_MODE_PREVIEW,
IMGSENSOR_MODE_CAPTURE,
IMGSENSOR_MODE_VIDEO,
IMGSENSOR_MODE_HIGH_SPEED_VIDEO,
IMGSENSOR_MODE_SLIM_VIDEO,
IMGSENSOR_MODE_CUSTOM1,
IMGSENSOR_MODE_CUSTOM2,
IMGSENSOR_MODE_CUSTOM3,
};
struct imgsensor_mode_struct {
kal_uint32 pclk; /* record different mode's pclk */
kal_uint32 linelength; /* record different mode's linelength */
kal_uint32 framelength; /* record different mode's framelength */
kal_uint8 startx; /* record different mode's startx of grabwindow */
kal_uint8 starty; /* record different mode's startx of grabwindow */
/* record different mode's width of grabwindow */
kal_uint16 grabwindow_width;
/* record different mode's height of grabwindow */
kal_uint16 grabwindow_height;
/* following for MIPIDataLowPwr2HighSpeedSettleDelayCount
* by different scenario
*/
kal_uint8 mipi_data_lp2hs_settle_dc;
/* following for GetDefaultFramerateByScenario() */
kal_uint16 max_framerate;
/* record mipi pixel rate */
kal_uint32 mipi_pixel_rate;
};
/* SENSOR PRIVATE STRUCT FOR VARIABLES */
struct imgsensor_struct {
kal_uint8 mirror; /* mirrorflip information */
kal_uint8 sensor_mode; /* record IMGSENSOR_MODE enum value */
kal_uint32 shutter; /* current shutter */
kal_uint16 gain; /* current gain */
kal_uint32 pclk; /* current pclk */
kal_uint32 frame_length; /* current framelength */
kal_uint32 line_length; /* current linelength */
/* current min framelength to max framerate */
kal_uint32 min_frame_length;
kal_uint16 dummy_pixel; /* current dummypixel */
kal_uint16 dummy_line; /* current dummline */
kal_uint16 current_fps; /* current max fps */
kal_bool autoflicker_en; /* record autoflicker enable or disable */
kal_bool test_pattern; /* record test pattern mode or not */
enum MSDK_SCENARIO_ID_ENUM current_scenario_id;/* current scenario id */
kal_bool ihdr_en; /* ihdr enable or disable */
kal_uint8 i2c_write_id; /* record current sensor's i2c write id */
};
/* SENSOR PRIVATE STRUCT FOR CONSTANT*/
struct imgsensor_info_struct {
kal_uint32 sensor_id; /* record sensor id defined in Kd_imgsensor.h */
kal_uint32 checksum_value; /* checksum value for Camera Auto Test */
/* preview scenario relative information */
struct imgsensor_mode_struct pre;
/* capture scenario relative information */
struct imgsensor_mode_struct cap;
/* normal video scenario relative information */
struct imgsensor_mode_struct normal_video;
/* high speed video scenario relative information */
struct imgsensor_mode_struct hs_video;
/* slim video for VT scenario relative information */
struct imgsensor_mode_struct slim_video;
/* custom1 scenario relative information */
struct imgsensor_mode_struct custom1;
/* custom2 scenario relative information */
struct imgsensor_mode_struct custom2;
/* custom3 scenario relative information */
struct imgsensor_mode_struct custom3;
kal_uint8 ae_shut_delay_frame; /* shutter delay frame for AE cycle */
/* sensor gain delay frame for AE cycle */
kal_uint8 ae_sensor_gain_delay_frame;
/* isp gain delay frame for AE cycle */
kal_uint8 ae_ispGain_delay_frame;
kal_uint8 ihdr_support; /* 1, support; 0,not support */
kal_uint8 ihdr_le_firstline; /* 1,le first ; 0, se first */
kal_uint8 temperature_support; /*1, support; 0,not support*/
kal_uint8 sensor_mode_num; /* support sensor mode num */
kal_uint8 cap_delay_frame; /* enter capture delay frame num */
kal_uint8 pre_delay_frame; /* enter preview delay frame num */
kal_uint8 video_delay_frame; /* enter video delay frame num */
/* enter high speed video delay frame num */
kal_uint8 hs_video_delay_frame;
/* enter slim video delay frame num */
kal_uint8 slim_video_delay_frame;
kal_uint8 custom1_delay_frame; /* enter custom1 delay frame num */
kal_uint8 custom2_delay_frame; /* enter custom2 delay frame num */
kal_uint8 custom3_delay_frame; /* enter custom3 delay frame num */
kal_uint8 frame_time_delay_frame;
kal_uint8 margin; /* sensor framelength & shutter margin */
kal_uint32 min_shutter; /* min shutter */
/* max framelength by sensor register's limitation */
kal_uint32 max_frame_length;
kal_uint8 isp_driving_current; /* mclk driving current */
kal_uint8 sensor_interface_type; /* sensor_interface_type */
kal_uint8 mipi_sensor_type;
/* 0,MIPI_OPHY_NCSI2;
* 1,MIPI_OPHY_CSI2,
* default is NCSI2, don't modify this para
*/
kal_uint8 mipi_settle_delay_mode;
/* 0, high speed signal auto detect;
* 1, use settle delay,unit is ns,
* default is auto detect, don't modify this para
*/
/* sensor output first pixel color */
kal_uint8 sensor_output_dataformat;
/* mclk value, suggest 24 or 26 for 24Mhz or 26Mhz */
kal_uint8 mclk;
kal_uint8 mipi_lane_num; /* mipi lane num */
/* record sensor support all write id addr, only supprt 4must end with 0xff */
kal_uint8 i2c_addr_table[5];
kal_uint32 i2c_speed; /* i2c speed */
};
extern int iReadRegI2C(u8 *a_pSendData, u16 a_sizeSendData,
u8 *a_pRecvData, u16 a_sizeRecvData, u16 i2cId);
extern int iWriteRegI2C(u8 *a_pSendData, u16 a_sizeSendData, u16 i2cId);
extern int iBurstWriteReg(u8 *pData, u32 bytes, u16 i2cId);
extern int iBurstWriteReg_multi(u8 *pData, u32 bytes,
u16 i2cId, u16 transfer_length, u16 timing);
extern int main_module_id;
extern int AF_Inf_pos;
extern int AF_Macro_pos;
#endif
@@ -0,0 +1,5 @@
# SPDX-License-Identifier: GPL-2.0
obj-y += imx398mipiraw_Sensor.o
obj-y += imx398_eeprom.o
@@ -0,0 +1,126 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#define PFX "imx398_pdafotp"
#define pr_fmt(fmt) PFX "[%s] " fmt, __func__
#include <linux/videodev2.h>
#include <linux/i2c.h>
#include <linux/platform_device.h>
#include <linux/delay.h>
#include <linux/cdev.h>
#include <linux/uaccess.h>
#include <linux/fs.h>
#include <linux/atomic.h>
#include <linux/slab.h>
#include "kd_camera_typedef.h"
#include "kd_imgsensor.h"
#include "kd_imgsensor_define.h"
#include "kd_imgsensor_errcode.h"
#include "imx398_eeprom.h"
#define USHORT unsigned short
#define BYTE unsigned char
#define Sleep(ms) mdelay(ms)
#define imx398_EEPROM_READ_ID 0xA0
#define imx398_EEPROM_WRITE_ID 0xA1
#define imx398_I2C_SPEED 100
#define imx398_MAX_OFFSET 0xFFFF
#define DATA_SIZE 2048
BYTE imx398_DCC_data[96] = {0};
BYTE imx398_SPC_data[252] = {0};
static bool get_done;
static int last_size;
static int last_offset;
static bool selective_read_eeprom(kal_uint16 addr, BYTE *data)
{
char pu_send_cmd[2] = {(char)(addr >> 8), (char)(addr & 0xFF)};
if (addr > imx398_MAX_OFFSET)
return false;
if (iReadRegI2C(pu_send_cmd, 2, (u8 *) data, 1, imx398_EEPROM_READ_ID) < 0) {
/* 20171116 ken : fix coding style */
return false;
}
return true;
}
static bool _read_imx398_eeprom(kal_uint16 addr, BYTE *data, int size)
{
int i = 0;
int offset = addr;
pr_debug("enter _read_eeprom size = %d\n", size);
for (i = 0; i < size; i++) {
if (!selective_read_eeprom(offset, &data[i]))
return false;
pr_debug("read_eeprom 0x%0x %d\n", offset, data[i]);
offset++;
}
get_done = true;
last_size = size;
last_offset = addr;
return true;
}
void read_imx398_SPC(BYTE *data)
{
int size = 252;
pr_debug("read imx398 SPC, size = %d\n", size);
/**********************************************************
* if(!get_done || last_size != size || last_offset != addr) {
* if(!_read_imx398_eeprom(addr, imx398_SPC_data, size)){
* get_done = 0;
* last_size = 0;
* last_offset = 0;
* return false;
* }
* }
**********************************************************/
memcpy(data, imx398_SPC_data, size);
}
void read_imx398_DCC(kal_uint16 addr, BYTE *data, kal_uint32 size)
{
addr = 0x960;
size = 96;
pr_debug("read imx398 DCC, size = %d\n", size);
if (!get_done || last_size != size || last_offset != addr) {
if (!_read_imx398_eeprom(addr, imx398_DCC_data, size)) {
get_done = 0;
last_size = 0;
last_offset = 0;
}
}
memcpy(data, imx398_DCC_data, size);
}
@@ -0,0 +1,15 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#ifndef _IMX398_EEPROM_H
#define _IMX398_EEPROM_H
extern int iReadRegI2C(u8 *a_pSendData, u16 a_sizeSendData,
u8 *a_pRecvData, u16 a_sizeRecvData, u16 i2cId);
extern int iWriteRegI2C(u8 *a_pSendData, u16 a_sizeSendData, u16 i2cId);
extern int iMultiReadReg(u16 a_u2Addr, u8 *a_puBuff, u16 i2cId, u8 number);
#endif
@@ -0,0 +1,204 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
*/
/*****************************************************************************
*
* Filename:
* ---------
* IMX398mipi_Sensor.h
*
* Project:
* --------
* ALPS
*
* Description:
* ------------
* CMOS sensor header file
*
****************************************************************************/
#ifndef _IMX398mipi_SENSOR_H
#define _IMX398mipi_SENSOR_H
enum IMGSENSOR_MODE {
IMGSENSOR_MODE_INIT,
IMGSENSOR_MODE_PREVIEW,
IMGSENSOR_MODE_CAPTURE,
IMGSENSOR_MODE_VIDEO,
IMGSENSOR_MODE_HIGH_SPEED_VIDEO,
IMGSENSOR_MODE_SLIM_VIDEO,
IMGSENSOR_MODE_CUSTOM1,
IMGSENSOR_MODE_CUSTOM2,
IMGSENSOR_MODE_CUSTOM3,
IMGSENSOR_MODE_CUSTOM4,
IMGSENSOR_MODE_CUSTOM5,
};
struct imgsensor_mode_struct {
kal_uint32 pclk; /* record different mode's pclk */
kal_uint32 linelength; /* record different mode's linelength */
kal_uint32 framelength; /* record different mode's framelength */
kal_uint8 startx; /* record different mode's startx of grabwindow */
kal_uint8 starty; /* record different mode's startx of grabwindow */
/* record different mode's width of grabwindow */
kal_uint16 grabwindow_width;
/* record different mode's height of grabwindow */
kal_uint16 grabwindow_height;
/* following for MIPIDataLowPwr2HighSpeedSettleDelayCount
* by different scenario
*/
kal_uint8 mipi_data_lp2hs_settle_dc;
/* following for GetDefaultFramerateByScenario() */
kal_uint16 max_framerate;
kal_uint32 mipi_pixel_rate;
};
/* SENSOR PRIVATE STRUCT FOR VARIABLES*/
struct imgsensor_struct {
kal_uint8 mirror; /* mirrorflip information */
kal_uint8 sensor_mode; /* record IMGSENSOR_MODE enum value */
kal_uint32 shutter; /* current shutter */
kal_uint16 gain; /* current gain */
kal_uint32 pclk; /* current pclk */
kal_uint32 frame_length; /* current framelength */
kal_uint32 line_length; /* current linelength */
/* current min framelength to max framerate */
kal_uint32 min_frame_length;
kal_uint16 dummy_pixel; /* current dummypixel */
kal_uint16 dummy_line; /* current dummline */
kal_uint16 current_fps; /* current max fps */
kal_bool autoflicker_en; /* record autoflicker enable or disable */
kal_bool test_pattern; /* record test pattern mode or not */
enum MSDK_SCENARIO_ID_ENUM current_scenario_id;/* current scenario id */
kal_uint8 ihdr_mode; /* ihdr enable or disable */
kal_uint8 pdaf_mode; /* ihdr enable or disable */
kal_uint8 i2c_write_id; /* record current sensor's i2c write id */
};
/* SENSOR PRIVATE STRUCT FOR CONSTANT*/
struct imgsensor_info_struct {
kal_uint32 sensor_id; /* record sensor id defined in Kd_imgsensor.h */
kal_uint32 checksum_value; /* checksum value for Camera Auto Test */
/* preview scenario relative information */
struct imgsensor_mode_struct pre;
/* capture scenario relative information */
struct imgsensor_mode_struct cap;
/* capture for PIP 24fps relative information */
struct imgsensor_mode_struct cap1;
/* normal video scenario relative information */
struct imgsensor_mode_struct normal_video;
/* high speed video scenario relative information */
struct imgsensor_mode_struct hs_video;
/* slim video for VT scenario relative information */
struct imgsensor_mode_struct slim_video;
/* custom1 scenario relative information */
struct imgsensor_mode_struct custom1;
/* custom2 scenario relative information */
struct imgsensor_mode_struct custom2;
/* custom3 scenario relative information */
struct imgsensor_mode_struct custom3;
/* custom4 scenario relative information */
struct imgsensor_mode_struct custom4;
/* custom5 scenario relative information */
struct imgsensor_mode_struct custom5;
kal_uint8 ae_shut_delay_frame; /* shutter delay frame for AE cycle */
/* sensor gain delay frame for AE cycle */
kal_uint8 ae_sensor_gain_delay_frame;
/* isp gain delay frame for AE cycle */
kal_uint8 ae_ispGain_delay_frame;
kal_uint8 ihdr_support; /* 1, support; 0,not support */
kal_uint8 ihdr_le_firstline; /* 1,le first ; 0, se first */
kal_uint8 sensor_mode_num; /* support sensor mode num */
kal_uint8 cap_delay_frame; /* enter capture delay frame num */
kal_uint8 pre_delay_frame; /* enter preview delay frame num */
kal_uint8 video_delay_frame; /* enter video delay frame num */
/* enter high speed video delay frame num */
kal_uint8 hs_video_delay_frame;
kal_uint8 slim_video_delay_frame; /* enter slim video delay frame num */
kal_uint8 custom1_delay_frame; /* enter custom1 delay frame num */
kal_uint8 custom2_delay_frame; /* enter custom1 delay frame num */
kal_uint8 custom3_delay_frame; /* enter custom1 delay frame num */
kal_uint8 custom4_delay_frame; /* enter custom1 delay frame num */
kal_uint8 custom5_delay_frame; /* enter custom1 delay frame num */
kal_uint8 margin; /* sensor framelength & shutter margin */
kal_uint32 min_shutter; /* min shutter */
/* max framelength by sensor register's limitation */
kal_uint32 max_frame_length;
kal_uint8 isp_driving_current; /* mclk driving current */
kal_uint8 sensor_interface_type; /* sensor_interface_type */
kal_uint8 mipi_sensor_type;
/* 0,MIPI_OPHY_NCSI2; 1,MIPI_OPHY_CSI2,
* default is NCSI2, don't modify this para
*/
kal_uint8 mipi_settle_delay_mode;
/* 0, high speed signal auto detect; 1,
* use settle delay,unit is ns,
* default is auto detect, don't modify this para
*/
kal_uint8 sensor_output_dataformat;
kal_uint8 mclk; /* mclk value, suggest 24 or 26 for 24Mhz or 26Mhz */
kal_uint8 mipi_lane_num; /* mipi lane num */
/* record sensor support all write id addr, only supprt 4must end with 0xff */
kal_uint8 i2c_addr_table[5];
kal_uint32 i2c_speed; /* i2c speed */
};
/* SENSOR READ/WRITE ID */
/* #define IMGSENSOR_WRITE_ID_1 (0x6c) */
/* #define IMGSENSOR_READ_ID_1 (0x6d) */
/* #define IMGSENSOR_WRITE_ID_2 (0x20) */
/* #define IMGSENSOR_READ_ID_2 (0x21) */
extern int iReadRegI2C(u8 *a_pSendData, u16 a_sizeSendData,
u8 *a_pRecvData, u16 a_sizeRecvData, u16 i2cId);
extern int iWriteRegI2C(u8 *a_pSendData, u16 a_sizeSendData, u16 i2cId);
extern void read_imx398_SPC(BYTE *data);
extern void read_imx398_DCC(kal_uint16 addr, BYTE *data, kal_uint32 size);
extern int iBurstWriteReg_multi(
u8 *pData, u32 bytes, u16 i2cId, u16 transfer_length, u16 timing);
/* extern void read_imx398_eeprom( void); */
#endif
@@ -0,0 +1,5 @@
# SPDX-License-Identifier: GPL-2.0
#add start by hongfei.zhang@mediatek.com
obj-y += imx486mipiraw_Sensor.o
#add end by hongfei.zhang@mediatek.com
@@ -0,0 +1,182 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
*/
/*****************************************************************************
*
* Filename:
* ---------
* IMX486mipiraw_Sensor.h
*
* Project:
* --------
* ALPS
*
* Description:
* ------------
* CMOS sensor header file
*
****************************************************************************/
#ifndef _IMX486MIPIRAW_SENSOR_H
#define _IMX486MIPIRAW_SENSOR_H
#include "kd_camera_typedef.h"
#include "kd_imgsensor.h"
#include "kd_imgsensor_define.h"
#include "kd_imgsensor_errcode.h"
enum IMGSENSOR_MODE {
IMGSENSOR_MODE_INIT,
IMGSENSOR_MODE_PREVIEW,
IMGSENSOR_MODE_CAPTURE,
IMGSENSOR_MODE_VIDEO,
IMGSENSOR_MODE_HIGH_SPEED_VIDEO,
IMGSENSOR_MODE_SLIM_VIDEO,
IMGSENSOR_MODE_CUSTOM1,
IMGSENSOR_MODE_CUSTOM2,
};
struct imgsensor_mode_struct {
kal_uint32 pclk; /* record different mode's pclk */
kal_uint32 linelength; /* record different mode's linelength */
kal_uint32 framelength; /* record different mode's framelength */
kal_uint8 startx; /* record different mode's startx of grabwindow */
kal_uint8 starty; /* record different mode's startx of grabwindow */
/* record different mode's width of grabwindow */
kal_uint16 grabwindow_width;
/* record different mode's height of grabwindow */
kal_uint16 grabwindow_height;
/* following for MIPIDataLowPwr2HighSpeedSettleDelayCount
* by different scenario
*/
kal_uint8 mipi_data_lp2hs_settle_dc;
/* following for GetDefaultFramerateByScenario() */
kal_uint16 max_framerate;
};
/* SENSOR PRIVATE STRUCT FOR VARIABLES*/
struct imgsensor_struct {
kal_uint8 mirror; /* mirrorflip information */
kal_uint8 sensor_mode; /* record IMGSENSOR_MODE enum value */
kal_uint32 shutter; /* current shutter */
kal_uint16 gain; /* current gain */
kal_uint32 pclk; /* current pclk */
kal_uint32 frame_length; /* current framelength */
kal_uint32 line_length; /* current linelength */
/* current min framelength to max framerate */
kal_uint32 min_frame_length;
kal_uint16 dummy_pixel; /* current dummypixel */
kal_uint16 dummy_line; /* current dummline */
kal_uint16 current_fps; /* current max fps */
kal_bool autoflicker_en; /* record autoflicker enable or disable */
kal_bool test_pattern; /* record test pattern mode or not */
enum MSDK_SCENARIO_ID_ENUM current_scenario_id;/* current scenario id */
/* HDR mODE : 0: disable HDR, 1:IHDR, 2:HDR, 9:ZHDR */
kal_uint8 hdr_mode;
kal_uint8 pdaf_mode; /* PDAF enable or disable */
kal_uint8 i2c_write_id; /* record current sensor's i2c write id */
};
/* SENSOR PRIVATE STRUCT FOR CONSTANT*/
struct imgsensor_info_struct {
kal_uint32 sensor_id; /* record sensor id defined in Kd_imgsensor.h */
kal_uint32 checksum_value; /* checksum value for Camera Auto Test */
/* preview scenario relative information */
struct imgsensor_mode_struct pre;
/* capture scenario relative information */
struct imgsensor_mode_struct cap;
struct imgsensor_mode_struct cap1;
/* normal video scenario relative information */
struct imgsensor_mode_struct normal_video;
/* high speed video scenario relative information */
struct imgsensor_mode_struct hs_video;
/* slim video for VT scenario relative information */
struct imgsensor_mode_struct slim_video;
struct imgsensor_mode_struct custom1;
struct imgsensor_mode_struct custom2;
kal_uint8 ae_shut_delay_frame; /* shutter delay frame for AE cycle */
/* sensor gain delay frame for AE cycle */
kal_uint8 ae_sensor_gain_delay_frame;
/* isp gain delay frame for AE cycle */
kal_uint8 ae_ispGain_delay_frame;
kal_uint8 frame_time_delay_frame;
kal_uint8 ihdr_support; /* 1, support; 0,not support */
kal_uint8 ihdr_le_firstline; /* 1,le first ; 0, se first */
kal_uint8 sensor_mode_num; /* support sensor mode num */
kal_uint8 cap_delay_frame; /* enter capture delay frame num */
kal_uint8 pre_delay_frame; /* enter preview delay frame num */
kal_uint8 video_delay_frame; /* enter video delay frame num */
/* enter high speed video delay frame num */
kal_uint8 hs_video_delay_frame;
/* enter slim video delay frame num */
kal_uint8 slim_video_delay_frame;
kal_uint8 custom1_delay_frame; /* enter custom1 delay frame num */
kal_uint8 custom2_delay_frame; /* enter custom1 delay frame num */
kal_uint8 margin; /* sensor framelength & shutter margin */
kal_uint32 min_shutter; /* min shutter */
/* max framelength by sensor register's limitation */
kal_uint32 max_frame_length;
kal_uint8 isp_driving_current; /* mclk driving current */
kal_uint8 sensor_interface_type; /* sensor_interface_type */
kal_uint8 mipi_sensor_type;
kal_uint8 mipi_settle_delay_mode;/* always manual*/
/* sensor output first pixel color */
kal_uint8 sensor_output_dataformat;
kal_uint8 mclk; /* mclk value, suggest 24 or 26 for 24Mhz or 26Mhz */
kal_uint8 mipi_lane_num; /* mipi lane num */
/* record sensor support all write id addr, only supprt 4must end with 0xff */
kal_uint8 i2c_addr_table[5];
kal_uint32 i2c_speed; /* i2c speed */
};
#if 0
extern bool read_imx258_eeprom(kal_uint16 addr, BYTE *data, kal_uint32 size);
extern bool read_imx258_pdaf(kal_uint16 addr, BYTE *data, kal_uint32 size);
extern bool read_imx258_eeprom_SPC(
kal_uint16 addr, BYTE *data, kal_uint32 size);
#endif
extern int iReadRegI2C(u8 *a_pSendData, u16 a_sizeSendData,
u8 *a_pRecvData, u16 a_sizeRecvData, u16 i2cId);
extern int iWriteRegI2C(u8 *a_pSendData, u16 a_sizeSendData, u16 i2cId);
extern int iBurstWriteReg_multi(u8 *pData, u32 bytes, u16 i2cId,
u16 transfer_length, u16 timing);
#endif
@@ -0,0 +1,3 @@
# SPDX-License-Identifier: GPL-2.0
obj-y += imx499mipiraw_Sensor.o
@@ -0,0 +1,216 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
*/
/************************************************************************
*
* Filename:
* ---------
* IMX499mipi_Sensor.h
*
* Project:
* --------
* ALPS
*
* Description:
* ------------
* CMOS sensor header file
*
************************************************************************/
#ifndef _IMX499MIPI_SENSOR_H
#define _IMX499MIPI_SENSOR_H
enum IMGSENSOR_MODE {
IMGSENSOR_MODE_INIT,
IMGSENSOR_MODE_PREVIEW,
IMGSENSOR_MODE_CAPTURE,
IMGSENSOR_MODE_VIDEO,
IMGSENSOR_MODE_HIGH_SPEED_VIDEO,
IMGSENSOR_MODE_SLIM_VIDEO,
IMGSENSOR_MODE_CUSTOM1,
IMGSENSOR_MODE_CUSTOM2,
IMGSENSOR_MODE_CUSTOM3,
IMGSENSOR_MODE_CUSTOM4,
IMGSENSOR_MODE_CUSTOM5,
};
struct imgsensor_mode_struct {
kal_uint32 pclk; /* record different mode's pclk */
kal_uint32 linelength; /* record different mode's linelength */
kal_uint32 framelength; /* record different mode's framelength */
/* record different mode's startx of grabwindow */
kal_uint8 startx;
/* record different mode's startx of grabwindow */
kal_uint8 starty;
/* record different mode's width of grabwindow */
kal_uint16 grabwindow_width;
/* record different mode's height of grabwindow */
kal_uint16 grabwindow_height;
/* following for MIPIDataLowPwr2HighSpeedSettleDelayCount
* by different scenario
*/
kal_uint8 mipi_data_lp2hs_settle_dc;
kal_uint32 mipi_pixel_rate;
/* following for GetDefaultFramerateByScenario() */
kal_uint16 max_framerate;
};
/* SENSOR PRIVATE STRUCT FOR VARIABLES*/
struct imgsensor_struct {
kal_uint8 mirror; /* mirrorflip information */
kal_uint8 sensor_mode; /* record IMGSENSOR_MODE enum value */
kal_uint32 shutter; /* current shutter */
kal_uint16 gain; /* current gain */
kal_uint32 pclk; /* current pclk */
kal_uint32 frame_length; /* current framelength */
kal_uint32 line_length; /* current linelength */
/* current min framelength to max framerate */
kal_uint32 min_frame_length;
kal_uint16 dummy_pixel; /* current dummypixel */
kal_uint16 dummy_line; /* current dummline */
kal_uint16 current_fps; /* current max fps */
kal_bool autoflicker_en;/* record autoflicker enable or disable */
kal_uint32 test_pattern; /* record test pattern mode or not */
enum MSDK_SCENARIO_ID_ENUM current_scenario_id;/* current scenario */
kal_uint8 hdr_mode; /* HDR mode */
kal_uint8 pdaf_mode; /* ihdr enable or disable */
kal_uint8 i2c_write_id; /* record current sensor's i2c write id */
};
/* SENSOR PRIVATE STRUCT FOR CONSTANT*/
struct imgsensor_info_struct {
kal_uint32 sensor_id;/* record sensor id defined in Kd_imgsensor.h */
kal_uint32 checksum_value;/* checksum value for Camera Auto Test */
/* preview scenario relative information */
struct imgsensor_mode_struct pre;
/* capture scenario relative information */
struct imgsensor_mode_struct cap;
/* normal video scenario relative information */
struct imgsensor_mode_struct normal_video;
/* high speed video scenario relative information */
struct imgsensor_mode_struct hs_video;
/* slim video for VT scenario relative information */
struct imgsensor_mode_struct slim_video;
/* custom1 scenario relative information */
struct imgsensor_mode_struct custom1;
/* custom2 scenario relative information */
struct imgsensor_mode_struct custom2;
/* custom3 scenario relative information */
struct imgsensor_mode_struct custom3;
/* custom4 scenario relative information */
struct imgsensor_mode_struct custom4;
struct imgsensor_mode_struct custom5;
kal_uint8 ae_shut_delay_frame; /* shutter delay frame for AE cycle */
/* sensor gain delay frame for AE cycle */
kal_uint8 ae_sensor_gain_delay_frame;
/* isp gain delay frame for AE cycle */
kal_uint8 ae_ispGain_delay_frame;
kal_uint8 ihdr_support; /* 1, support; 0,not support */
kal_uint8 ihdr_le_firstline; /* 1,le first ; 0, se first */
kal_uint8 temperature_support; /* 1, support; 0,not support */
kal_uint8 sensor_mode_num; /* support sensor mode num */
kal_uint8 cap_delay_frame; /* enter capture delay frame num */
kal_uint8 pre_delay_frame; /* enter preview delay frame num */
kal_uint8 video_delay_frame; /* enter video delay frame num */
/* enter high speed video delay frame num */
kal_uint8 hs_video_delay_frame;
/* enter slim video delay frame num */
kal_uint8 slim_video_delay_frame;
kal_uint8 margin; /* sensor framelength & shutter margin */
kal_uint32 min_shutter; /* min shutter */
/* max framelength by sensor register's limitation */
kal_uint32 max_frame_length;
kal_uint8 isp_driving_current; /* mclk driving current */
kal_uint8 sensor_interface_type; /* sensor_interface_type */
/* 0,MIPI_OPHY_NCSI2; 1,MIPI_OPHY_CSI2,
* default is NCSI2, don't modify this para
*/
kal_uint8 mipi_sensor_type;
kal_uint8 mipi_settle_delay_mode;/* manual mode only */
/* sensor output first pixel color */
kal_uint8 sensor_output_dataformat;
kal_uint8 mclk;
kal_uint32 i2c_speed;
kal_uint8 mipi_lane_num; /* mipi lane num */
/* record sensor support all write id addr,
* only supprt 4must end with 0xff
*/
kal_uint8 i2c_addr_table[5];
};
/* SENSOR READ/WRITE ID */
/* #define IMGSENSOR_WRITE_ID_1 (0x6c) */
/* #define IMGSENSOR_READ_ID_1 (0x6d) */
/* #define IMGSENSOR_WRITE_ID_2 (0x20) */
/* #define IMGSENSOR_READ_ID_2 (0x21) */
extern int iReadRegI2C(
u8 *a_pSendData,
u16 a_sizeSendData,
u8 *a_pRecvData,
u16 a_sizeRecvData,
u16 i2cId);
extern int iReadRegI2CTiming(
u8 *a_pSendData,
u16 a_sizeSendData,
u8 *a_pRecvData,
u16 a_sizeRecvData,
u16 i2cId,
u16 timing);
extern int iWriteRegI2C(u8 *a_pSendData, u16 a_sizeSendData, u16 i2cId);
extern int iWriteRegI2CTiming(
u8 *a_pSendData,
u16 a_sizeSendData,
u16 i2cId,
u16 timing);
extern void read_imx499_eeprom(void);
int iBurstWriteReg_multi(
u8 *pData,
u32 bytes,
u16 i2cId,
u16 transfer_length,
u16 timing);
#endif
@@ -0,0 +1,3 @@
# SPDX-License-Identifier: GPL-2.0
obj-y += imx499mipiraw_Sensor.o
@@ -0,0 +1,216 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
*/
/************************************************************************
*
* Filename:
* ---------
* IMX499mipi_Sensor.h
*
* Project:
* --------
* ALPS
*
* Description:
* ------------
* CMOS sensor header file
*
************************************************************************/
#ifndef _IMX499MIPI_SENSOR_H
#define _IMX499MIPI_SENSOR_H
enum IMGSENSOR_MODE {
IMGSENSOR_MODE_INIT,
IMGSENSOR_MODE_PREVIEW,
IMGSENSOR_MODE_CAPTURE,
IMGSENSOR_MODE_VIDEO,
IMGSENSOR_MODE_HIGH_SPEED_VIDEO,
IMGSENSOR_MODE_SLIM_VIDEO,
IMGSENSOR_MODE_CUSTOM1,
IMGSENSOR_MODE_CUSTOM2,
IMGSENSOR_MODE_CUSTOM3,
IMGSENSOR_MODE_CUSTOM4,
IMGSENSOR_MODE_CUSTOM5,
};
struct imgsensor_mode_struct {
kal_uint32 pclk; /* record different mode's pclk */
kal_uint32 linelength; /* record different mode's linelength */
kal_uint32 framelength; /* record different mode's framelength */
/* record different mode's startx of grabwindow */
kal_uint8 startx;
/* record different mode's startx of grabwindow */
kal_uint8 starty;
/* record different mode's width of grabwindow */
kal_uint16 grabwindow_width;
/* record different mode's height of grabwindow */
kal_uint16 grabwindow_height;
/* following for MIPIDataLowPwr2HighSpeedSettleDelayCount
* by different scenario
*/
kal_uint8 mipi_data_lp2hs_settle_dc;
kal_uint32 mipi_pixel_rate;
/* following for GetDefaultFramerateByScenario() */
kal_uint16 max_framerate;
};
/* SENSOR PRIVATE STRUCT FOR VARIABLES*/
struct imgsensor_struct {
kal_uint8 mirror; /* mirrorflip information */
kal_uint8 sensor_mode; /* record IMGSENSOR_MODE enum value */
kal_uint32 shutter; /* current shutter */
kal_uint16 gain; /* current gain */
kal_uint32 pclk; /* current pclk */
kal_uint32 frame_length; /* current framelength */
kal_uint32 line_length; /* current linelength */
/* current min framelength to max framerate */
kal_uint32 min_frame_length;
kal_uint16 dummy_pixel; /* current dummypixel */
kal_uint16 dummy_line; /* current dummline */
kal_uint16 current_fps; /* current max fps */
kal_bool autoflicker_en;/* record autoflicker enable or disable */
kal_uint32 test_pattern; /* record test pattern mode or not */
enum MSDK_SCENARIO_ID_ENUM current_scenario_id;/* current scenario */
kal_uint8 hdr_mode; /* HDR mode */
kal_uint8 pdaf_mode; /* ihdr enable or disable */
kal_uint8 i2c_write_id; /* record current sensor's i2c write id */
};
/* SENSOR PRIVATE STRUCT FOR CONSTANT*/
struct imgsensor_info_struct {
kal_uint32 sensor_id;/* record sensor id defined in Kd_imgsensor.h */
kal_uint32 checksum_value;/* checksum value for Camera Auto Test */
/* preview scenario relative information */
struct imgsensor_mode_struct pre;
/* capture scenario relative information */
struct imgsensor_mode_struct cap;
/* normal video scenario relative information */
struct imgsensor_mode_struct normal_video;
/* high speed video scenario relative information */
struct imgsensor_mode_struct hs_video;
/* slim video for VT scenario relative information */
struct imgsensor_mode_struct slim_video;
/* custom1 scenario relative information */
struct imgsensor_mode_struct custom1;
/* custom2 scenario relative information */
struct imgsensor_mode_struct custom2;
/* custom3 scenario relative information */
struct imgsensor_mode_struct custom3;
/* custom4 scenario relative information */
struct imgsensor_mode_struct custom4;
struct imgsensor_mode_struct custom5;
kal_uint8 ae_shut_delay_frame; /* shutter delay frame for AE cycle */
/* sensor gain delay frame for AE cycle */
kal_uint8 ae_sensor_gain_delay_frame;
/* isp gain delay frame for AE cycle */
kal_uint8 ae_ispGain_delay_frame;
kal_uint8 ihdr_support; /* 1, support; 0,not support */
kal_uint8 ihdr_le_firstline; /* 1,le first ; 0, se first */
kal_uint8 temperature_support; /* 1, support; 0,not support */
kal_uint8 sensor_mode_num; /* support sensor mode num */
kal_uint8 cap_delay_frame; /* enter capture delay frame num */
kal_uint8 pre_delay_frame; /* enter preview delay frame num */
kal_uint8 video_delay_frame; /* enter video delay frame num */
/* enter high speed video delay frame num */
kal_uint8 hs_video_delay_frame;
/* enter slim video delay frame num */
kal_uint8 slim_video_delay_frame;
kal_uint8 margin; /* sensor framelength & shutter margin */
kal_uint32 min_shutter; /* min shutter */
/* max framelength by sensor register's limitation */
kal_uint32 max_frame_length;
kal_uint8 isp_driving_current; /* mclk driving current */
kal_uint8 sensor_interface_type; /* sensor_interface_type */
/* 0,MIPI_OPHY_NCSI2; 1,MIPI_OPHY_CSI2,
* default is NCSI2, don't modify this para
*/
kal_uint8 mipi_sensor_type;
kal_uint8 mipi_settle_delay_mode;/* manual mode only */
/* sensor output first pixel color */
kal_uint8 sensor_output_dataformat;
kal_uint8 mclk;
kal_uint32 i2c_speed;
kal_uint8 mipi_lane_num; /* mipi lane num */
/* record sensor support all write id addr,
* only supprt 4must end with 0xff
*/
kal_uint8 i2c_addr_table[5];
};
/* SENSOR READ/WRITE ID */
/* #define IMGSENSOR_WRITE_ID_1 (0x6c) */
/* #define IMGSENSOR_READ_ID_1 (0x6d) */
/* #define IMGSENSOR_WRITE_ID_2 (0x20) */
/* #define IMGSENSOR_READ_ID_2 (0x21) */
extern int iReadRegI2C(
u8 *a_pSendData,
u16 a_sizeSendData,
u8 *a_pRecvData,
u16 a_sizeRecvData,
u16 i2cId);
extern int iReadRegI2CTiming(
u8 *a_pSendData,
u16 a_sizeSendData,
u8 *a_pRecvData,
u16 a_sizeRecvData,
u16 i2cId,
u16 timing);
extern int iWriteRegI2C(u8 *a_pSendData, u16 a_sizeSendData, u16 i2cId);
extern int iWriteRegI2CTiming(
u8 *a_pSendData,
u16 a_sizeSendData,
u16 i2cId,
u16 timing);
extern void read_imx499_eeprom(void);
int iBurstWriteReg_multi(
u8 *pData,
u32 bytes,
u16 i2cId,
u16 transfer_length,
u16 timing);
#endif
@@ -0,0 +1,7 @@
# SPDX-License-Identifier: GPL-2.0
#add start by hongfei.zhang@mediatek.com
obj-y += ov12a10mipiraw_Sensor.o
#obj-y += ov12a10_otp_cal.o
#obj-y += ov12a10_pdaf_cal.o
#add end by hongfei.zhang@mediatek.com
@@ -0,0 +1,185 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
*/
/*****************************************************************************
*
* Filename:
* ---------
* OV12A10mipiraw_Sensor.h
*
* Project:
* --------
* ALPS
*
* Description:
* ------------
* CMOS sensor header file
*
****************************************************************************/
#ifndef _OV12A10MIPIRAW_SENSOR_H
#define _OV12A10MIPIRAW_SENSOR_H
#include "kd_camera_typedef.h"
#include "kd_imgsensor.h"
#include "kd_imgsensor_define.h"
#include "kd_imgsensor_errcode.h"
enum IMGSENSOR_MODE {
IMGSENSOR_MODE_INIT,
IMGSENSOR_MODE_PREVIEW,
IMGSENSOR_MODE_CAPTURE,
IMGSENSOR_MODE_VIDEO,
IMGSENSOR_MODE_HIGH_SPEED_VIDEO,
IMGSENSOR_MODE_SLIM_VIDEO,
IMGSENSOR_MODE_CUSTOM1,
IMGSENSOR_MODE_CUSTOM2,
IMGSENSOR_MODE_CUSTOM3,
IMGSENSOR_MODE_CUSTOM4,
IMGSENSOR_MODE_CUSTOM5,
};
struct imgsensor_mode_struct {
kal_uint32 pclk; /* record different mode's pclk */
kal_uint32 linelength; /* record different mode's linelength */
kal_uint32 framelength; /* record different mode's framelength */
kal_uint8 startx; /* record different mode's startx of grabwindow */
kal_uint8 starty; /* record different mode's startx of grabwindow */
/* record different mode's width of grabwindow */
kal_uint16 grabwindow_width;
/* record different mode's height of grabwindow */
kal_uint16 grabwindow_height;
/* following for MIPIDataLowPwr2HighSpeedSettleDelayCount
* by different scenario
*/
kal_uint8 mipi_data_lp2hs_settle_dc;
/* following for GetDefaultFramerateByScenario() */
kal_uint16 max_framerate;
};
/* SENSOR PRIVATE STRUCT FOR VARIABLES*/
struct imgsensor_struct {
kal_uint8 mirror; /* mirrorflip information */
kal_uint8 sensor_mode; /* record IMGSENSOR_MODE enum value */
kal_uint32 shutter; /* current shutter */
kal_uint16 gain; /* current gain */
kal_uint32 pclk; /* current pclk */
kal_uint32 frame_length; /* current framelength */
kal_uint32 line_length; /* current linelength */
/* current min framelength to max framerate */
kal_uint32 min_frame_length;
kal_uint16 dummy_pixel; /* current dummypixel */
kal_uint16 dummy_line; /* current dummline */
kal_uint16 current_fps; /* current max fps */
kal_bool autoflicker_en; /* record autoflicker enable or disable */
kal_bool test_pattern; /* record test pattern mode or not */
enum MSDK_SCENARIO_ID_ENUM current_scenario_id;/* current scenario id */
/* HDR mODE : 0: disable HDR, 1:IHDR, 2:HDR, 9:ZHDR */
kal_uint8 ihdr_en; //ihdr enable or disable
kal_uint8 pdaf_mode; /* PDAF enable or disable */
kal_uint8 i2c_write_id; /* record current sensor's i2c write id */
};
/* SENSOR PRIVATE STRUCT FOR CONSTANT*/
struct imgsensor_info_struct {
kal_uint32 sensor_id; /* record sensor id defined in Kd_imgsensor.h */
kal_uint32 checksum_value; /* checksum value for Camera Auto Test */
/* preview scenario relative information */
struct imgsensor_mode_struct pre;
/* capture scenario relative information */
struct imgsensor_mode_struct cap;
struct imgsensor_mode_struct cap1;
struct imgsensor_mode_struct cap2;
/* normal video scenario relative information */
struct imgsensor_mode_struct normal_video;
/* high speed video scenario relative information */
struct imgsensor_mode_struct hs_video;
/* slim video for VT scenario relative information */
struct imgsensor_mode_struct slim_video;
struct imgsensor_mode_struct custom1;
struct imgsensor_mode_struct custom2;
struct imgsensor_mode_struct custom3;
struct imgsensor_mode_struct custom4;
struct imgsensor_mode_struct custom5;
kal_uint8 ae_shut_delay_frame; /* shutter delay frame for AE cycle */
/* sensor gain delay frame for AE cycle */
kal_uint8 ae_sensor_gain_delay_frame;
/* isp gain delay frame for AE cycle */
kal_uint8 ae_ispGain_delay_frame;
kal_uint8 frame_time_delay_frame;
kal_uint8 ihdr_support; /* 1, support; 0,not support */
kal_uint8 ihdr_le_firstline; /* 1,le first ; 0, se first */
kal_uint8 sensor_mode_num; /* support sensor mode num */
kal_uint8 cap_delay_frame; //enter capture delay frame num
kal_uint8 pre_delay_frame; //enter preview delay frame num
kal_uint8 video_delay_frame; //enter video delay frame num
//enter high speed video delay frame num
kal_uint8 hs_video_delay_frame;
kal_uint8 slim_video_delay_frame;
kal_uint8 custom1_delay_frame;
kal_uint8 custom2_delay_frame;
kal_uint8 custom3_delay_frame;
kal_uint8 custom4_delay_frame;
kal_uint8 custom5_delay_frame;
//sensor framelength & shutter margin
kal_uint8 margin; /* sensor framelength & shutter margin */
kal_uint32 min_shutter; /* min shutter */
/* max framelength by sensor register's limitation */
kal_uint32 max_frame_length;
kal_uint8 isp_driving_current; /* mclk driving current */
kal_uint8 sensor_interface_type; /* sensor_interface_type */
kal_uint8 mipi_sensor_type;
kal_uint8 mipi_settle_delay_mode;/* always manual*/
/* sensor output first pixel color */
kal_uint8 sensor_output_dataformat;
kal_uint8 mclk; /* mclk value, suggest 24 or 26 for 24Mhz or 26Mhz */
kal_uint8 mipi_lane_num; /* mipi lane num */
/* record sensor support all write id addr, only supprt 4must end with 0xff */
kal_uint8 i2c_addr_table[5];
kal_uint32 i2c_speed; /* i2c speed */
};
extern int iReadRegI2C(u8 *a_pSendData, u16 a_sizeSendData,
u8 *a_pRecvData, u16 a_sizeRecvData, u16 i2cId);
extern int iReadRegI2CTiming(u8 *a_pSendData, u16 a_sizeSendData,
u8 *a_pRecvData, u16 a_sizeRecvData, u16 i2cId, u16 timing);
extern int iWriteRegI2C(u8 *a_pSendData, u16 a_sizeSendData, u16 i2cId);
extern int iWriteRegI2CTiming(u8 *a_pSendData,
u16 a_sizeSendData, u16 i2cId, u16 timing);
extern int iBurstWriteReg_multi(u8 *pData, u32 bytes,
u16 i2cId, u16 transfer_length, u16 timing);
#endif
Loaded 100 of 80519 files, more files were not shown because too many files have changed in this diff. Show more