From 858070042af3c73f89323cd4e383ab74b6890b6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?William=20B=C3=A9rub=C3=A9?= Date: Thu, 22 Aug 2024 17:00:43 -0400 Subject: [PATCH] Preparing in parallel the integration of the infinity3 series --- README.md | 22 +++++----- src/hal/star/i3_aud.h | 95 ++++++++++++++++++++++++++++++++++++++++ src/hal/star/i3_common.h | 27 ++++++++++++ src/hal/star/i3_sys.h | 74 +++++++++++++++++++++++++++++++ src/hal/star/i6_sys.h | 2 +- 5 files changed, 209 insertions(+), 11 deletions(-) create mode 100644 src/hal/star/i3_aud.h create mode 100644 src/hal/star/i3_common.h create mode 100644 src/hal/star/i3_sys.h diff --git a/README.md b/README.md index 9306b4f..40c8d7f 100644 --- a/README.md +++ b/README.md @@ -32,11 +32,12 @@ In spite of these design choices, Divinus boasts numerous features that cater to | Hi3559AV100 | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | RV11xx[^11] | ↻ | ↻ | ↻ | ↻ | ↻ | | T31 series | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | -| infinity6[^12] | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | -| infinity6b0[^13] | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | -| infinity6e[^14] | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | -| infinity6c[^15] | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | -| infinity6f[^16] | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | +| infinity3[^12] | ↻ | ↻ | ↻ | ↻ | ↻ | +| infinity6[^13] | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | +| infinity6b0[^14] | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | +| infinity6e[^15] | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | +| infinity6c[^16] | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | +| infinity6f[^17] | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | _✔️ - supported, ↻ - in development, ✗ - unsupported, ⁿ/ₐ - not supported by hardware_ @@ -53,11 +54,12 @@ _* At the moment, only text, 24-bit and 32-bit RGB overlays are handled, matrici [^9]: GK7202V300, GK7205V200/300 and GK7605V100 [^10]: Hi3516AV200 and Hi3519V101 [^11]: RV110\[3/7/8/9\] and RV1106\(G2/G3\) -[^12]: SSC323, SSC325\(D/DE\) and SSC327\(D/DE/Q\) -[^13]: SSC33\[3/5/7\]\(DE\) -[^14]: SSC30K\[D/Q\], SSC336\[D/Q\], SSC338\[D/G/Q\] and SSC339G -[^15]: SSC377\(D/DE/QE\) or SSC378\[DE/QE\] -[^16]: SSC379G +[^12]: MSC313E, MSC316\[DC/Q\] and MSC318 +[^13]: SSC323, SSC325\(D/DE\) and SSC327\(D/DE/Q\) +[^14]: SSC33\[3/5/7\]\(DE\) +[^15]: SSC30K\[D/Q\], SSC336\[D/Q\], SSC338\[D/G/Q\] and SSC339G +[^16]: SSC377\(D/DE/QE\) or SSC378\[DE/QE\] +[^17]: SSC379G ### Documentation diff --git a/src/hal/star/i3_aud.h b/src/hal/star/i3_aud.h new file mode 100644 index 0000000..892b685 --- /dev/null +++ b/src/hal/star/i3_aud.h @@ -0,0 +1,95 @@ +#pragma once + +#include "i3_common.h" + +typedef struct { + // Accept industry standards from 8000 to 48000Hz + int rate; + // Accepts from 4 to 24 bits + int bit; + int stereoOn; + unsigned int length; + int leftOrRight; + int absTimeOn; +} i3_aud_cnf; + +typedef struct { + unsigned char *addr; + int bit; + int stereoOn; + unsigned long long timestamp; + unsigned int sequence; + unsigned int length; + void *reserved; +} i3_aud_frm; + +typedef struct { + void *handle; + + int (*fnDisableDevice)(int device); + int (*fnEnableDevice)(int device); + int (*fnSetDeviceConfig)(int device, i3_aud_cnf *config); + + int (*fnDisableChannel)(int device, int channel); + int (*fnEnableChannel)(int device, int channel); + + int (*fnSetMute)(int device, int *muteOn); + int (*fnSetVolume)(int device, int dbLevel); + + int (*fnFreeFrame)(int device, int channel, i3_aud_frm *frame); + int (*fnGetFrame)(int device, int channel, i3_aud_frm *frame, int millis); + int (*fnStartFrame)(int device, int channel); +} i3_aud_impl; + +static int i3_aud_load(i3_aud_impl *aud_lib) { + if (!(aud_lib->handle = dlopen("libmi.so", RTLD_LAZY | RTLD_GLOBAL))) + HAL_ERROR("i3_aud", "Failed to load library!\nError: %s\n", dlerror()); + + if (!(aud_lib->fnDisableDevice = (int(*)(int device)) + hal_symbol_load("i3_aud", aud_lib->handle, "MI_AI_Disable"))) + return EXIT_FAILURE; + + if (!(aud_lib->fnEnableDevice = (int(*)(int device)) + hal_symbol_load("i3_aud", aud_lib->handle, "MI_AI_Enable"))) + return EXIT_FAILURE; + + if (!(aud_lib->fnSetDeviceConfig = (int(*)(int device, i3_aud_cnf *config)) + hal_symbol_load("i3_aud", aud_lib->handle, "MI_AI_SetDevAttr"))) + return EXIT_FAILURE; + + if (!(aud_lib->fnDisableChannel = (int(*)(int device, int channel)) + hal_symbol_load("i3_aud", aud_lib->handle, "MI_AI_DisableChn"))) + return EXIT_FAILURE; + + if (!(aud_lib->fnEnableChannel = (int(*)(int device, int channel)) + hal_symbol_load("i3_aud", aud_lib->handle, "MI_AI_EnableChn"))) + return EXIT_FAILURE; + + if (!(aud_lib->fnSetMute = (int(*)(int device,int *muteOn)) + hal_symbol_load("i3_aud", aud_lib->handle, "MI_AI_SetMute"))) + return EXIT_FAILURE; + + if (!(aud_lib->fnSetVolume = (int(*)(int device, int dbLevel)) + hal_symbol_load("i3_aud", aud_lib->handle, "MI_AI_SetVolume"))) + return EXIT_FAILURE; + + if (!(aud_lib->fnFreeFrame = (int(*)(int device, int channel, i3_aud_frm *frame)) + hal_symbol_load("i3_aud", aud_lib->handle, "MI_AI_ReleaseFrame"))) + return EXIT_FAILURE; + + if (!(aud_lib->fnGetFrame = (int(*)(int device, int channel, i3_aud_frm *frame, int millis)) + hal_symbol_load("i3_aud", aud_lib->handle, "MI_AI_GetFrame"))) + return EXIT_FAILURE; + + if (!(aud_lib->fnStartFrame = (int(*)(int device, int channel)) + hal_symbol_load("i3_aud", aud_lib->handle, "MI_AI_StartFrame"))) + return EXIT_FAILURE; + + return EXIT_SUCCESS; +} + +static void i3_aud_unload(i3_aud_impl *aud_lib) { + if (aud_lib->handle) dlclose(aud_lib->handle); + aud_lib->handle = NULL; + memset(aud_lib, 0, sizeof(*aud_lib)); +} \ No newline at end of file diff --git a/src/hal/star/i3_common.h b/src/hal/star/i3_common.h new file mode 100644 index 0000000..91c070b --- /dev/null +++ b/src/hal/star/i3_common.h @@ -0,0 +1,27 @@ +#pragma once + +#include +#include +#include +#include +#include + +#include "../symbols.h" +#include "../types.h" + +typedef enum { + I3_PIXFMT_UNUSED, + I3_PIXFMT_YUV422_YUYV, + I3_PIXFMT_MSTAR_RAW16, + I3_PIXFMT_MSTAR_YC16, + I3_PIXFMT_MSTAR_STS16, + I3_PIXFMT_YUV420SP, + I3_PIXFMT_YUV420P, + I3_PIXFMT_BGR565, + I3_PIXFMT_ARGB4444, + I3_PIXFMT_ARGB1555, + I3_PIXFMT_RGB888, + I3_PIXFMT_ABGR8888, + I3_PIXFMT_YUV400, + I3_PIXFMT_END +} i3_common_pixfmt; \ No newline at end of file diff --git a/src/hal/star/i3_sys.h b/src/hal/star/i3_sys.h new file mode 100644 index 0000000..7be0740 --- /dev/null +++ b/src/hal/star/i3_sys.h @@ -0,0 +1,74 @@ +#pragma once + +#include "i3_common.h" + +#define I3_SYS_API "1.0" + +typedef enum { + I3_SYS_MOD_AI, + I3_SYS_MOD_AO, + I3_SYS_MOD_AENC, + I3_SYS_MOD_ADEC, + I3_SYS_MOD_VI, + I3_SYS_MOD_VENC, + I3_SYS_MOD_END, +} i3_sys_mod; + +typedef struct { + i3_sys_mod module; + unsigned int device; + unsigned int channel; +} i3_sys_bind; + +typedef struct { + char version[64]; +} i3_sys_ver; + +typedef struct { + void *handle; + + int (*fnExit)(void); + int (*fnGetVersion)(i3_sys_ver *version); + int (*fnInit)(void); + int (*fnSetAlignment)(unsigned int *width); + + int (*fnBind)(i3_sys_bind *source, i3_sys_bind *dest); + int (*fnUnbind)(i3_sys_bind *source, i3_sys_bind *dest); +} i3_sys_impl; + +static int i3_sys_load(i3_sys_impl *sys_lib) { + if (!(sys_lib->handle = dlopen("libmi.so", RTLD_LAZY | RTLD_GLOBAL))) + HAL_ERROR("i3_sys", "Failed to load library!\nError: %s\n", dlerror()); + + if (!(sys_lib->fnExit = (int(*)(void)) + hal_symbol_load("i3_sys", sys_lib->handle, "MI_SYS_Exit"))) + return EXIT_FAILURE; + + if (!(sys_lib->fnGetVersion = (int(*)(i3_sys_ver *version)) + hal_symbol_load("i3_sys", sys_lib->handle, "MI_SYS_GetVersion"))) + return EXIT_FAILURE; + + if (!(sys_lib->fnInit = (int(*)(void)) + hal_symbol_load("i3_sys", sys_lib->handle, "MI_SYS_Init"))) + return EXIT_FAILURE; + + if (!(sys_lib->fnSetAlignment = (int(*)(unsigned int *width)) + hal_symbol_load("i3_sys", sys_lib->handle, "MI_SYS_SetConf"))) + return EXIT_FAILURE; + + if (!(sys_lib->fnBind = (int(*)(i3_sys_bind *source, i3_sys_bind *dest)) + hal_symbol_load("i3_sys", sys_lib->handle, "MI_SYS_Bind"))) + return EXIT_FAILURE; + + if (!(sys_lib->fnUnbind = (int(*)(i3_sys_bind *source, i3_sys_bind *dest)) + hal_symbol_load("i3_sys", sys_lib->handle, "MI_SYS_UnBind"))) + return EXIT_FAILURE; + + return EXIT_SUCCESS; +} + +static void i3_sys_unload(i3_sys_impl *sys_lib) { + if (sys_lib->handle) dlclose(sys_lib->handle); + sys_lib->handle = NULL; + memset(sys_lib, 0, sizeof(*sys_lib)); +} \ No newline at end of file diff --git a/src/hal/star/i6_sys.h b/src/hal/star/i6_sys.h index 993e5ee..88447f2 100644 --- a/src/hal/star/i6_sys.h +++ b/src/hal/star/i6_sys.h @@ -87,7 +87,7 @@ static int i6_sys_load(i6_sys_impl *sys_lib) { sys_lib->handleCamOsWrapper = dlopen("libcam_os_wrapper.so", RTLD_LAZY | RTLD_GLOBAL); if (!(sys_lib->handle = dlopen("libmi_sys.so", RTLD_LAZY | RTLD_GLOBAL))) - HAL_ERROR("i6c_sys", "Failed to load library!\nError: %s\n", dlerror()); + HAL_ERROR("i6_sys", "Failed to load library!\nError: %s\n", dlerror()); if (!(sys_lib->fnExit = (int(*)(void)) hal_symbol_load("i6_sys", sys_lib->handle, "MI_SYS_Exit")))