From 1e3293387b8c9e3f7231839b86b55e84107f2d6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?William=20B=C3=A9rub=C3=A9?= Date: Sat, 14 Sep 2024 03:27:49 -0400 Subject: [PATCH] Better identification of hisi-gen1 chips --- src/hal/hisi/v2_hal.c | 1 - src/hal/support.c | 31 ++++++++++++++++++++++++------- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/hal/hisi/v2_hal.c b/src/hal/hisi/v2_hal.c index c6bd9f0..a90e59a 100644 --- a/src/hal/hisi/v2_hal.c +++ b/src/hal/hisi/v2_hal.c @@ -739,7 +739,6 @@ void *v2_video_thread(void) } v2_state[i].fileDesc = ret; - if (maxFd <= v2_state[i].fileDesc) maxFd = v2_state[i].fileDesc; } diff --git a/src/hal/support.c b/src/hal/support.c index a4e1265..837f380 100644 --- a/src/hal/support.c +++ b/src/hal/support.c @@ -243,18 +243,16 @@ void hal_identify(void) { fclose(file); } - char v2series = 0, v3series = 0; - switch (val) { case 0x12040000: case 0x120a0000: val = 0x12020000; break; case 0x12100000: val = 0x12020000; - v3series = 1; + series = 3; break; case 0x20080000: val = 0x20050000; - v2series = 1; + series = 2; break; default: return; @@ -268,6 +266,24 @@ void hal_identify(void) { out |= (SCSYSID[i] & 0xFF) << i * 8; } + if (out == 0x35180100) { + series = 1; + if (hal_registry(0x2005008C, &val, OP_READ)) + switch (val >> 8 & 0x7f) { + case 0x10: out = 0x3518C100; break; + case 0x57: out = 0x3518E100; break; + default: + val = 3; + if (hal_registry(0x20050088, &val, OP_WRITE) && + hal_registry(0x20050088, &val, OP_READ)) + switch (val) { + case 1: out = 0x3516C100; break; + case 2: out = 0x3518E100; break; + case 3: out = 0x3518A100; break; + } + } + } + sprintf(chip, "%s%X", ((out >> 28) == 0x7) ? "GK" : "Hi", out); if (chip[6] == '0') { @@ -280,7 +296,7 @@ void hal_identify(void) { chip[7] = 'V'; } - if (out == 0x35180100) { + if (series == 1) { plat = HAL_PLATFORM_V1; strcpy(family, "hisi-gen1"); chnCount = V1_VENC_CHN_NUM; @@ -289,7 +305,7 @@ void hal_identify(void) { isp_thread = v1_image_thread; vid_thread = v1_video_thread; return; - } else if (v2series) { + } else if (series == 2) { plat = HAL_PLATFORM_V2; strcpy(family, "hisi-gen2"); chnCount = V2_VENC_CHN_NUM; @@ -298,7 +314,7 @@ void hal_identify(void) { isp_thread = v2_image_thread; vid_thread = v2_video_thread; return; - } else if (v3series) { + } else if (series == 3) { plat = HAL_PLATFORM_V3; strcpy(family, "hisi-gen3"); chnCount = V3_VENC_CHN_NUM; @@ -309,6 +325,7 @@ void hal_identify(void) { return; } + series = 4; plat = HAL_PLATFORM_V4; strcpy(family, "hisi-gen4"); chnCount = V4_VENC_CHN_NUM;