Skip to content

Commit

Permalink
Correcting the mix-up between i6f and m6 platforms, the latter being …
Browse files Browse the repository at this point in the history
…the one truly supported
  • Loading branch information
wberube committed Dec 12, 2024
1 parent 896b1e6 commit 0f1d926
Show file tree
Hide file tree
Showing 20 changed files with 2,707 additions and 52 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ In spite of these design choices, Divinus boasts numerous features that cater to
| infinity6b0[^14] | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
| infinity6e[^15] | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
| infinity6c[^16] | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
| infinity6f[^17] | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
| mercury6[^17] | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |

_✔️ - supported, ↻ - in development, ✗ - unsupported, ⁿ/ₐ - not supported by hardware_

Expand All @@ -60,7 +60,7 @@ _* At the moment, text, RGB or bitfield bitmaps and PNG overlays are handled, mo
[^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
[^17]: SSC359G


### Documentation
Expand Down
16 changes: 8 additions & 8 deletions src/error.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,23 +52,23 @@ char *errstr(int error) {
error |= (module << 16); break;
}
break;
case HAL_PLATFORM_I6F:
case HAL_PLATFORM_M6:
level = (error >> 12) & 0xF;
error = error & 0xFF000FFF | (level > 0 ? (4 << 13) : 0);
switch (module) {
case I6F_SYS_MOD_SYS:
case M6_SYS_MOD_SYS:
error |= (V4_SYS_MOD_SYS << 16); break;
case I6F_SYS_MOD_ISP:
case M6_SYS_MOD_ISP:
error |= (V4_SYS_MOD_ISP << 16); break;
case I6F_SYS_MOD_VIF:
case M6_SYS_MOD_VIF:
error |= (V4_SYS_MOD_VIU << 16); break;
case I6F_SYS_MOD_SCL:
case M6_SYS_MOD_SCL:
error |= (V4_SYS_MOD_VPSS << 16); break;
case I6F_SYS_MOD_VENC:
case M6_SYS_MOD_VENC:
error |= (V4_SYS_MOD_VENC << 16); break;
case I6F_SYS_MOD_RGN:
case M6_SYS_MOD_RGN:
error |= (V4_SYS_MOD_RGN << 16); break;
case I6F_SYS_MOD_AI:
case M6_SYS_MOD_AI:
error |= (V4_SYS_MOD_AI << 16); break;
default:
error |= (module << 16); break;
Expand Down
191 changes: 191 additions & 0 deletions src/hal/star/m6_aud.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
#pragma once

#include "m6_common.h"

#define M6_AUD_CHN_NUM 16

typedef enum {
M6_AUD_BIT_16,
M6_AUD_BIT_24,
M6_AUD_BIT_32,
M6_AUD_BIT_END
} m6_aud_bit;

typedef enum {
M6_AUD_CLK_OFF,
M6_AUD_CLK_12_288M,
M6_AUD_CLK_16_384M,
M6_AUD_CLK_18_432M,
M6_AUD_CLK_24_576M,
M6_AUD_CLK_24M,
M6_AUD_CLK_48M
} m6_aud_clk;

typedef enum {
M6_AUD_G726_16K,
M6_AUD_G726_24K,
M6_AUD_G726_32K,
M6_AUD_G726_40K
} m6_aud_g726t;

typedef enum {
M6_AUD_INTF_I2S_MASTER,
M6_AUD_INTF_I2S_SLAVE,
M6_AUD_INTF_TDM_MASTER,
M6_AUD_INTF_TDM_SLAVE,
M6_AUD_INTF_END
} m6_aud_intf;

typedef enum {
M6_AUD_SND_MONO,
M6_AUD_SND_STEREO,
M6_AUD_SND_QUEUE,
M6_AUD_SND_END
} m6_aud_snd;

typedef enum {
M6_AUD_TYPE_G711A,
M6_AUD_TYPE_G711U,
M6_AUD_TYPE_G726,
} m6_aud_type;

typedef struct {
int leftJustOn;
m6_aud_clk clock;
char syncRxClkOn;
unsigned int tdmSlotNum;
m6_aud_bit bit;
} m6_aud_i2s;

typedef struct {
// Accept industry standards from 8000 to 96000Hz
int rate;
m6_aud_bit bit;
m6_aud_intf intf;
m6_aud_snd sound;
unsigned int frmNum;
unsigned int packNumPerFrm;
unsigned int codecChnNum;
unsigned int chnNum;
m6_aud_i2s i2s;
} m6_aud_cnf;

typedef struct {
m6_aud_bit bit;
m6_aud_snd sound;
void *addr[M6_AUD_CHN_NUM];
unsigned long long timestamp;
unsigned int sequence;
unsigned int length[M6_AUD_CHN_NUM];
unsigned int poolId[2];
void *pcmAddr[M6_AUD_CHN_NUM];
unsigned int pcmLength[M6_AUD_CHN_NUM];
} m6_aud_frm;

typedef struct {
m6_aud_frm frame;
char isValid;
} m6_aud_efrm;

typedef struct {
// Accept industry standards from 8000 to 96000Hz
int rate;
m6_aud_snd sound;
} m6_aud_g711;

typedef struct {
// Accept industry standards from 8000 to 96000Hz
int rate;
m6_aud_snd sound;
m6_aud_g726t type;
} m6_aud_g726;

typedef struct {
m6_aud_type type;
union {
m6_aud_g711 g711;
m6_aud_g726t g726;
};
} m6_aud_para;

typedef struct {
void *handle;

int (*fnDisableDevice)(int device);
int (*fnEnableDevice)(int device);
int (*fnSetDeviceConfig)(int device, m6_aud_cnf *config);

int (*fnDisableChannel)(int device, int channel);
int (*fnEnableChannel)(int device, int channel);

int (*fnDisableEncoding)(int device, int channel);
int (*fnEnableEncoding)(int device, int channel);
int (*fnSetEncodingParam)(int device, int channel, m6_aud_para *param);

int (*fnSetMute)(int device, int channel, char active);
int (*fnSetVolume)(int device, int channel, int dbLevel);

int (*fnFreeFrame)(int device, int channel, m6_aud_frm *frame, m6_aud_efrm *encFrame);
int (*fnGetFrame)(int device, int channel, m6_aud_frm *frame, m6_aud_efrm *encFrame, int millis);
} m6_aud_impl;

static int m6_aud_load(m6_aud_impl *aud_lib) {
if (!(aud_lib->handle = dlopen("libmi_ai.so", RTLD_LAZY | RTLD_GLOBAL)))
HAL_ERROR("m6_aud", "Failed to load library!\nError: %s\n", dlerror());

if (!(aud_lib->fnDisableDevice = (int(*)(int device))
hal_symbol_load("m6_aud", aud_lib->handle, "MI_AI_Disable")))
return EXIT_FAILURE;

if (!(aud_lib->fnEnableDevice = (int(*)(int device))
hal_symbol_load("m6_aud", aud_lib->handle, "MI_AI_Enable")))
return EXIT_FAILURE;

if (!(aud_lib->fnSetDeviceConfig = (int(*)(int device, m6_aud_cnf *config))
hal_symbol_load("m6_aud", aud_lib->handle, "MI_AI_SetPubAttr")))
return EXIT_FAILURE;

if (!(aud_lib->fnDisableChannel = (int(*)(int device, int channel))
hal_symbol_load("m6_aud", aud_lib->handle, "MI_AI_DisableChn")))
return EXIT_FAILURE;

if (!(aud_lib->fnEnableChannel = (int(*)(int device, int channel))
hal_symbol_load("m6_aud", aud_lib->handle, "MI_AI_EnableChn")))
return EXIT_FAILURE;

if (!(aud_lib->fnDisableEncoding = (int(*)(int device, int channel))
hal_symbol_load("m6_aud", aud_lib->handle, "MI_AI_DisableAenc")))
return EXIT_FAILURE;

if (!(aud_lib->fnEnableEncoding = (int(*)(int device, int channel))
hal_symbol_load("m6_aud", aud_lib->handle, "MI_AI_EnableAenc")))
return EXIT_FAILURE;

if (!(aud_lib->fnSetEncodingParam = (int(*)(int device, int channel, m6_aud_para *param))
hal_symbol_load("m6_aud", aud_lib->handle, "MI_AI_SetAencAttr")))
return EXIT_FAILURE;

if (!(aud_lib->fnSetMute = (int(*)(int device, int channel, char active))
hal_symbol_load("m6_aud", aud_lib->handle, "MI_AI_SetMute")))
return EXIT_FAILURE;

if (!(aud_lib->fnSetVolume = (int(*)(int device, int channel, int dbLevel))
hal_symbol_load("m6_aud", aud_lib->handle, "MI_AI_SetVqeVolume")))
return EXIT_FAILURE;

if (!(aud_lib->fnFreeFrame = (int(*)(int device, int channel, m6_aud_frm *frame, m6_aud_efrm *encFrame))
hal_symbol_load("m6_aud", aud_lib->handle, "MI_AI_ReleaseFrame")))
return EXIT_FAILURE;

if (!(aud_lib->fnGetFrame = (int(*)(int device, int channel, m6_aud_frm *frame, m6_aud_efrm *encFrame, int millis))
hal_symbol_load("m6_aud", aud_lib->handle, "MI_AI_GetFrame")))
return EXIT_FAILURE;

return EXIT_SUCCESS;
}

static void m6_aud_unload(m6_aud_impl *aud_lib) {
if (aud_lib->handle) dlclose(aud_lib->handle);
aud_lib->handle = NULL;
memset(aud_lib, 0, sizeof(*aud_lib));
}
110 changes: 110 additions & 0 deletions src/hal/star/m6_common.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
#pragma once

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "../symbols.h"
#include "../types.h"

typedef enum {
M6_BAYER_RG,
M6_BAYER_GR,
M6_BAYER_BG,
M6_BAYER_GB,
M6_BAYER_R0,
M6_BAYER_G0,
M6_BAYER_B0,
M6_BAYER_G1,
M6_BAYER_G2,
M6_BAYER_I0,
M6_BAYER_G3,
M6_BAYER_I1,
M6_BAYER_END
} m6_common_bayer;

typedef enum {
M6_COMPR_NONE,
M6_COMPR_SEG,
M6_COMPR_LINE,
M6_COMPR_FRAME,
M6_COMPR_8BIT,
M6_COMPR_END
} m6_common_compr;

typedef enum {
M6_EDGE_SINGLE_UP,
M6_EDGE_SINGLE_DOWN,
M6_EDGE_DOUBLE,
M6_EDGE_END
} m6_common_edge;

typedef enum {
M6_HDR_OFF,
M6_HDR_VC,
M6_HDR_DOL,
M6_HDR_EMBED,
M6_HDR_LI,
M6_HDR_END
} m6_common_hdr;

typedef enum {
M6_INTF_BT656,
M6_INTF_DIGITAL_CAMERA,
M6_INTF_BT1120_STANDARD,
M6_INTF_BT1120_INTERLEAVED,
M6_INTF_MIPI,
M6_INTF_END
} m6_common_intf;

typedef enum {
M6_PREC_8BPP,
M6_PREC_10BPP,
M6_PREC_12BPP,
M6_PREC_14BPP,
M6_PREC_16BPP,
M6_PREC_END
} m6_common_prec;

typedef enum {
M6_PIXFMT_YUV422_YUYV,
M6_PIXFMT_ARGB8888,
M6_PIXFMT_ABGR8888,
M6_PIXFMT_BGRA8888,
M6_PIXFMT_RGB565,
M6_PIXFMT_ARGB1555,
M6_PIXFMT_ARGB4444,
M6_PIXFMT_I2,
M6_PIXFMT_I4,
M6_PIXFMT_I8,
M6_PIXFMT_YUV422SP,
M6_PIXFMT_YUV420SP,
M6_PIXFMT_YUV420SP_NV21,
M6_PIXFMT_YUV420_TILE,
M6_PIXFMT_YUV422_UYVY,
M6_PIXFMT_YUV422_YVYU,
M6_PIXFMT_YUV422_VYUY,
M6_PIXFMT_YUV422P,
M6_PIXFMT_YUV420P,
M6_PIXFMT_YUV420_FBC,
M6_PIXFMT_RGB_BAYER,
M6_PIXFMT_RGB_BAYER_END =
M6_PIXFMT_RGB_BAYER + M6_PREC_END * M6_BAYER_END - 1,
M6_PIXFMT_RGB888,
M6_PIXFMT_BGR888,
M6_PIXFMT_GRAY8,
M6_PIXFMT_RGB101010,
M6_PIXFMT_END
} m6_common_pixfmt;

typedef struct {
unsigned short width;
unsigned short height;
} m6_common_dim;

typedef struct {
unsigned short x;
unsigned short y;
unsigned short width;
unsigned short height;
} m6_common_rect;
Loading

0 comments on commit 0f1d926

Please sign in to comment.