说明:
在MTK平台添加一款新的Camera IC 需要如下三个步骤:
-
device目录下面添加相关宏定义。
-
kernel目录下面添加dts配置,即硬件管脚、时钟、电源、I2C等的配置和 添加相关的驱动。
-
vendor 目录下面添加相关的效果文件。
下面是自己在MTK8175 kernel-4.14 android9.0中添加GC5035的记录,供参考
1.device目录
2.kernel目录
diff --git a/kernel-4.14/arch/arm/boot/dts/xxx.dts b/kernel-4.14/arch/arm/boot/dts/xxx.dts
index 920957710c..2435094cb0 100644
--- a/kernel-4.14/arch/arm/boot/dts/xxx.dts
+++ b/kernel-4.14/arch/arm/boot/dts/xxx.dts
@@ -255,9 +255,9 @@ ROOT_NODE {
clock-frequency = <100000>;
status = "okay";
- kd_camera_hw1@20 {
+ kd_camera_hw1@6e {
compatible = "mediatek,camera_main";
- reg = <0x3c>;
+ reg = <0x6e>;
};
};
@@ -299,9 +299,9 @@ ROOT_NODE {
vcamio-supply = <&mt_pmic_vcamio_ldo_reg>; /* DOVDD */
/* sub cam power supply */
- vcama_sub-supply = <&mt_pmic_vcama_ldo_reg>; /* AVDD */
- vcamd_sub-supply = <&mt_pmic_vcamd_ldo_reg>; /* DVDD */
- vcamio_sub-supply = <&mt_pmic_vcamio_ldo_reg>; /* DOVDD */
+ //vcama_sub-supply = <&mt_pmic_vcama_ldo_reg>; /* AVDD */
+ //vcamd_sub-supply = <&mt_pmic_vcamd_ldo_reg>; /* DVDD */
+ //vcamio_sub-supply = <&mt_pmic_vcamio_ldo_reg>; /* DOVDD */
pinctrl-names = "default",
"cam0_rst0", "cam0_rst1", "cam0_pnd0", "cam0_pnd1",
@@ -527,7 +527,7 @@ ROOT_NODE {
camera_pins_cam0_rst0: cam0@0 {
pins_cmd_dat {
- pinmux = <MT8168_PIN_2_GPIO2__FUNC_GPIO2>;
+ pinmux = <MT8168_PIN_16_GPIO16__FUNC_GPIO16>;
slew-rate = <1>; /*direction 0:in, 1:out*/
output-low;
};
@@ -535,7 +535,7 @@ ROOT_NODE {
camera_pins_cam0_rst1: cam0@1 {
pins_cmd_dat {
- pinmux = <MT8168_PIN_2_GPIO2__FUNC_GPIO2>;
+ pinmux = <MT8168_PIN_16_GPIO16__FUNC_GPIO16>;
slew-rate = <1>;
output-high;
};
@@ -543,7 +543,7 @@ ROOT_NODE {
camera_pins_cam0_pnd0: cam0@2 {
pins_cmd_dat {
- pinmux = <MT8168_PIN_3_GPIO3__FUNC_GPIO3>;
+ pinmux = <MT8168_PIN_17_GPIO17__FUNC_GPIO17>;
slew-rate = <1>;
output-low;
};
@@ -551,7 +551,7 @@ ROOT_NODE {
camera_pins_cam0_pnd1: cam0@3 {
pins_cmd_dat {
- pinmux = <MT8168_PIN_3_GPIO3__FUNC_GPIO3>;
+ pinmux = <MT8168_PIN_17_GPIO17__FUNC_GPIO17>;
slew-rate = <1>;
output-high;
};
diff --git a/kernel-4.14/arch/arm/configs/xxx_debug_defconfig b/kernel-4.14/arch/arm/configs/xxx_debug_defconfig
index ebd6959eb2..93f0efd24a 100644
--- a/kernel-4.14/arch/arm/configs/xxx_debug_defconfig
+++ b/kernel-4.14/arch/arm/configs/xxx_debug_defconfig
@@ -103,7 +103,7 @@ CONFIG_MTK_PMIC_WRAP_HAL=y
CONFIG_MTK_STATIC_POWER=y
CONFIG_MTK_UNIFY_POWER=y
CONFIG_MTK_CM_MGR=y
-CONFIG_CUSTOM_KERNEL_IMGSENSOR="gc2375_mipi_raw sp2509_mipi_raw"
+CONFIG_CUSTOM_KERNEL_IMGSENSOR="gc5035_mipi_raw sp2509_mipi_raw"
CONFIG_MTK_CMDQ=y
CONFIG_MTK_IMGSENSOR=y
CONFIG_MTK_LCM=y
diff --git a/kernel-4.14/arch/arm/configs/insight10s_defconfig b/kernel-4.14/arch/arm/configs/insight10s_defconfig
index 3d1566de19..d68524f835 100644
--- a/kernel-4.14/arch/arm/configs/insight10s_defconfig
+++ b/kernel-4.14/arch/arm/configs/insight10s_defconfig
@@ -101,7 +101,7 @@ CONFIG_MTK_PMIC_WRAP_HAL=y
CONFIG_MTK_STATIC_POWER=y
CONFIG_MTK_UNIFY_POWER=y
CONFIG_MTK_CM_MGR=y
-CONFIG_CUSTOM_KERNEL_IMGSENSOR="gc2375_mipi_raw sp2509_mipi_raw"
+CONFIG_CUSTOM_KERNEL_IMGSENSOR="gc5035_mipi_raw sp2509_mipi_raw"
CONFIG_MTK_CMDQ=y
CONFIG_MTK_IMGSENSOR=y
CONFIG_MTK_LCM=y
diff --git a/kernel-4.14/drivers/misc/mediatek/imgsensor/inc/kd_imgsensor.h b/kernel-4.14/drivers/misc/mediatek/imgsensor/inc/kd_imgsensor.h
index 45c1299792..14937cb94d 100644
--- a/kernel-4.14/drivers/misc/mediatek/imgsensor/inc/kd_imgsensor.h
+++ b/kernel-4.14/drivers/misc/mediatek/imgsensor/inc/kd_imgsensor.h
@@ -288,6 +288,7 @@
#define GC0310_SENSOR_ID 0xa310
#define GC0313MIPI_YUV_SENSOR_ID 0xD0
#define GC0312_SENSOR_ID 0xb310
+#define GC5035_SENSOR_ID 0x5035
/*SP*/
#define SP0A19_YUV_SENSOR_ID 0xA6
#define SP2518_YUV_SENSOR_ID 0x53
@@ -471,6 +472,7 @@
#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_GC5035_MIPI_RAW "gc5035_mipi_raw"
/*SP*/
#define SENSOR_DRVNAME_SP0A19_YUV "sp0a19_yuv"
#define SENSOR_DRVNAME_SP2518_YUV "sp2518_yuv"
diff --git a/kernel-4.14/drivers/misc/mediatek/imgsensor/src/common/v1/imgsensor_sensor_list.c b/kernel-4.14/drivers/misc/mediatek/imgsensor/src/common/v1/imgsensor_sensor_list.c
index 38f84ce412..e28665a880 100644
--- a/kernel-4.14/drivers/misc/mediatek/imgsensor/src/common/v1/imgsensor_sensor_list.c
+++ b/kernel-4.14/drivers/misc/mediatek/imgsensor/src/common/v1/imgsensor_sensor_list.c
@@ -444,6 +444,9 @@ struct IMGSENSOR_SENSOR_LIST
#endif
#if defined(GC0310_YUV)
{GC0310_SENSOR_ID, SENSOR_DRVNAME_GC0310_YUV, GC0310_YUV_SensorInit},
+#endif
+#if defined(GC5035_MIPI_RAW)
+{GC5035_SENSOR_ID, SENSOR_DRVNAME_GC5035_MIPI_RAW, GC5035_MIPI_RAW_SensorInit},
#endif
/*SP*/
#if defined(SP2509_MIPI_RAW)
diff --git a/kernel-4.14/drivers/misc/mediatek/imgsensor/src/common/v1/imgsensor_sensor_list.h b/kernel-4.14/drivers/misc/mediatek/imgsensor/src/common/v1/imgsensor_sensor_list.h
index 618dc1e22b..ba4e8742a6 100644
--- a/kernel-4.14/drivers/misc/mediatek/imgsensor/src/common/v1/imgsensor_sensor_list.h
+++ b/kernel-4.14/drivers/misc/mediatek/imgsensor/src/common/v1/imgsensor_sensor_list.h
@@ -149,7 +149,9 @@ 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 GC5035_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 IMX215_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
+
/*SP*/
UINT32 SP0A19_YUV_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 SP2509_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
diff --git a/kernel-4.14/drivers/misc/mediatek/imgsensor/src/mt8168/camera_hw/imgsensor_cfg_table.c b/kernel-4.14/drivers/misc/mediatek/imgsensor/src/mt8168/camera_hw/imgsensor_cfg_table.c
index c3d0e1035c..0001d78ef8 100644
--- a/kernel-4.14/drivers/misc/mediatek/imgsensor/src/mt8168/camera_hw/imgsensor_cfg_table.c
+++ b/kernel-4.14/drivers/misc/mediatek/imgsensor/src/mt8168/camera_hw/imgsensor_cfg_table.c
@@ -145,6 +145,21 @@ struct IMGSENSOR_HW_POWER_SEQ platform_power_sequence[] = {
/* Legacy design */
struct IMGSENSOR_HW_POWER_SEQ sensor_power_sequence[] = {
/* GC */
+#if defined(GC5035_MIPI_RAW)
+ {
+ SENSOR_DRVNAME_GC5035_MIPI_RAW,
+ {
+ {SensorMCLK, Vol_High, 0},
+ {PDN, Vol_Low,0},
+ {RST, Vol_Low, 0},
+ {DOVDD, Vol_1800, 1},
+ {DVDD, Vol_1200, 5},
+ {AVDD, Vol_2800, 5},
+ {PDN, Vol_High, 5},
+ {RST, Vol_High, 5}
+ },
+ },
+#endif
#if defined(GC2385MIPI_RAW_CHXT_REAR)
{
SENSOR_DRVNAME_GC2385MIPI_RAW_CHXT_REAR,
3.vendor目录
4.上述kernel和vendor添加的文件目录有
按照上述的修改,添加文件需找FAE提供。或者找个相近的替换先调通整个流程。
这样修改后全编译后,使用自带的camera2即可打开camera预览。
调试时可使用:
adb查看是否读到id
cat /proc/driver/camera_info
调试vendor下面代码时可打开日志
文件位置vendor/mediatek/proprietary/hardware/mtkcam/legacy/include/mtkcam/Log.h
把 1改成 4即可。