Skip to content

Commit

Permalink
Preparing in parallel the integration of the infinity3 series
Browse files Browse the repository at this point in the history
  • Loading branch information
wberube committed Aug 22, 2024
1 parent 702c681 commit 8580700
Show file tree
Hide file tree
Showing 5 changed files with 209 additions and 11 deletions.
22 changes: 12 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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_

Expand All @@ -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
Expand Down
95 changes: 95 additions & 0 deletions src/hal/star/i3_aud.h
Original file line number Diff line number Diff line change
@@ -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));
}
27 changes: 27 additions & 0 deletions src/hal/star/i3_common.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#pragma once

#include <dlfcn.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/select.h>

#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;
74 changes: 74 additions & 0 deletions src/hal/star/i3_sys.h
Original file line number Diff line number Diff line change
@@ -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));
}
2 changes: 1 addition & 1 deletion src/hal/star/i6_sys.h
Original file line number Diff line number Diff line change
Expand Up @@ -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")))
Expand Down

0 comments on commit 8580700

Please sign in to comment.