From e3afae81e956c0fbf84e794ee60a5b765b3f7b15 Mon Sep 17 00:00:00 2001 From: KuRue Date: Wed, 10 Jul 2024 12:20:02 -0400 Subject: [PATCH 1/5] Add OV5647 sensor support --- .../sg2002_licheervnano_sd/sg2002_licheervnano_sd_defconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/build/boards/sg200x/sg2002_licheervnano_sd/sg2002_licheervnano_sd_defconfig b/build/boards/sg200x/sg2002_licheervnano_sd/sg2002_licheervnano_sd_defconfig index 771afd7c3..1760f6baa 100644 --- a/build/boards/sg200x/sg2002_licheervnano_sd/sg2002_licheervnano_sd_defconfig +++ b/build/boards/sg200x/sg2002_licheervnano_sd/sg2002_licheervnano_sd_defconfig @@ -15,6 +15,7 @@ CONFIG_STORAGE_TYPE_sd=y CONFIG_MIPI_PANEL_ZCT2133V1=y CONFIG_SENSOR_GCORE_GC4653=y CONFIG_SENSOR_OV_OS04A10=y +CONFIG_SENSOR_OV_OS05647=y CONFIG_SENSOR_LONTIUM_LT6911=y CONFIG_SENSOR_SMS_SC035GS=y CONFIG_UBOOT_2021_10=y From 7602b6e99e3f6248d675edaaf30cffb839407e14 Mon Sep 17 00:00:00 2001 From: KuRue Date: Wed, 10 Jul 2024 12:32:09 -0400 Subject: [PATCH 2/5] Add OV5647 sensor support --- .../v2/component/isp/sensor/cv182x/ov_ov5647/ov5647_cmos.c | 1 + 1 file changed, 1 insertion(+) diff --git a/middleware/v2/component/isp/sensor/cv182x/ov_ov5647/ov5647_cmos.c b/middleware/v2/component/isp/sensor/cv182x/ov_ov5647/ov5647_cmos.c index b7cc52d2b..383c790c6 100644 --- a/middleware/v2/component/isp/sensor/cv182x/ov_ov5647/ov5647_cmos.c +++ b/middleware/v2/component/isp/sensor/cv182x/ov_ov5647/ov5647_cmos.c @@ -869,6 +869,7 @@ static CVI_S32 sensor_set_init(VI_PIPE ViPipe, ISP_INIT_ATTR_S *pstInitAttr) } static CVI_S32 sensor_probe(VI_PIPE ViPipe) { + printf("[sensor_prob = ov547_probe] \n"); return ov5647_probe(ViPipe); } From ddde067de593879724b4aab823658be48e5d3c2d Mon Sep 17 00:00:00 2001 From: KuRue Date: Wed, 10 Jul 2024 13:52:28 -0400 Subject: [PATCH 3/5] Add OV5647 sensor support --- .../cv182x/ov_ov5647/ov5647_sensor_ctl.c | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/middleware/v2/component/isp/sensor/cv182x/ov_ov5647/ov5647_sensor_ctl.c b/middleware/v2/component/isp/sensor/cv182x/ov_ov5647/ov5647_sensor_ctl.c index 8e2c2892d..152b84a67 100644 --- a/middleware/v2/component/isp/sensor/cv182x/ov_ov5647/ov5647_sensor_ctl.c +++ b/middleware/v2/component/isp/sensor/cv182x/ov_ov5647/ov5647_sensor_ctl.c @@ -70,6 +70,7 @@ int ov5647_read_register(VI_PIPE ViPipe, int addr) CVI_U8 buf[8]; CVI_U8 idx = 0; + printf("[ov5647_read_register] : addr = %x \n", addr); if (g_fd[ViPipe] < 0) return CVI_FAILURE; @@ -113,6 +114,7 @@ int ov5647_write_register(VI_PIPE ViPipe, int addr, int data) int ret; CVI_U8 buf[8]; + printf("[ov5647_write_register] : addr = %x. data = %x \n", addr, data); if (g_fd[ViPipe] < 0) return CVI_SUCCESS; @@ -205,21 +207,42 @@ int ov5647_probe(VI_PIPE ViPipe) { int nVal, nVal2; + // PinMUX + printf("########### PinMux #######################################################################\n"); + system("devmem 0x0300116C 32 0x3"); + system("devmem 0x03001170 32 0x3"); + system("devmem 0x03001174 32 0x3"); + system("devmem 0x03001178 32 0x3"); + system("devmem 0x0300117C 32 0x3"); + system("devmem 0x03001180 32 0x3"); + system("devmem 0x03001184 32 0x3"); + system("devmem 0x03001188 32 0x3"); + system("devmem 0x0300118C 32 0x3"); + system("devmem 0x03001190 32 0x3"); + printf("########### PinMux End #######################################################################\n") + usleep(1000); + printf("[ov5647_probe] -189 \n"); if (ov5647_i2c_init(ViPipe) != CVI_SUCCESS) return CVI_FAILURE; + printf("[lt6911_probe] -195 \n"); nVal = ov5647_read_register(ViPipe, OV5647_CHIP_ID_ADDR_H); nVal2 = ov5647_read_register(ViPipe, OV5647_CHIP_ID_ADDR_L); if (nVal < 0 || nVal2 < 0) { CVI_TRACE_SNS(CVI_DBG_ERR, "read sensor id error.\n"); + printf("[ov5647_probe] jump return nVal -198 \n"); return nVal; } + printf("[ov5647_probe] -201 \n"); + printf("data:%02x %02x\n", nVal, nVal2); if ((((nVal & 0xFF) << 8) | (nVal2 & 0xFF)) != OV5647_CHIP_ID) { CVI_TRACE_SNS(CVI_DBG_ERR, "Sensor ID Mismatch! Use the wrong sensor??\n"); return CVI_FAILURE; + printf("[ov5647_probe] jump return CVI_FAILURE -206 \n"); } + printf("[ov5647_probe] -208 = exit success \n"); return CVI_SUCCESS; } From da80a8a75b30c0f55c2156d575adec6b987b5c00 Mon Sep 17 00:00:00 2001 From: KuRue Date: Wed, 10 Jul 2024 13:57:36 -0400 Subject: [PATCH 4/5] Add OV5647 sensor support --- .../sensor/cv182x/ov_ov5647/ov5647_sensor_ctl.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/middleware/v2/component/isp/sensor/cv182x/ov_ov5647/ov5647_sensor_ctl.c b/middleware/v2/component/isp/sensor/cv182x/ov_ov5647/ov5647_sensor_ctl.c index 8e2c2892d..9ead1fc31 100644 --- a/middleware/v2/component/isp/sensor/cv182x/ov_ov5647/ov5647_sensor_ctl.c +++ b/middleware/v2/component/isp/sensor/cv182x/ov_ov5647/ov5647_sensor_ctl.c @@ -225,6 +225,20 @@ int ov5647_probe(VI_PIPE ViPipe) void ov5647_init(VI_PIPE ViPipe) { + // PinMUX + printf("########### PinMux #######################################################################\n"); + system("devmem 0x0300116C 32 0x3"); + system("devmem 0x03001170 32 0x3"); + system("devmem 0x03001174 32 0x3"); + system("devmem 0x03001178 32 0x3"); + system("devmem 0x0300117C 32 0x3"); + system("devmem 0x03001180 32 0x3"); + system("devmem 0x03001184 32 0x3"); + system("devmem 0x03001188 32 0x3"); + system("devmem 0x0300118C 32 0x3"); + system("devmem 0x03001190 32 0x3"); + printf("########### PinMux End #######################################################################\n"); + ov5647_i2c_init(ViPipe); delay_ms(10); From c0aaca4508a368bab6652900f4cbe0792235d5a7 Mon Sep 17 00:00:00 2001 From: KuRue Date: Wed, 10 Jul 2024 15:36:57 -0400 Subject: [PATCH 5/5] Create sensor_cfg.ini.ov5647 --- .../overlay/mnt/data/sensor_cfg.ini.ov5647 | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 buildroot/board/cvitek/SG200X/overlay/mnt/data/sensor_cfg.ini.ov5647 diff --git a/buildroot/board/cvitek/SG200X/overlay/mnt/data/sensor_cfg.ini.ov5647 b/buildroot/board/cvitek/SG200X/overlay/mnt/data/sensor_cfg.ini.ov5647 new file mode 100644 index 000000000..62e9b9dfd --- /dev/null +++ b/buildroot/board/cvitek/SG200X/overlay/mnt/data/sensor_cfg.ini.ov5647 @@ -0,0 +1,34 @@ +[source] + +;type = SOURCE_USER_FE + +dev_num = 1 + +; section for sensor + +[sensor] + +; sensor name +name = OV_OV5647_MIPI_2M_30FPS_10BIT + +bus_id = 4 + +sns_i2c_addr = 36 + +mipi_dev = 0 + +lane_id = 0, 1, 2, 3, -1 + +pn_swap = 0, 0, 0, 0, 0 + +mclk_en = 1 + +mclk = 1 + +;port = 0 + +;pin = 2 + +;pol = 1 + +;fps = 30