-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Correcting the mix-up between i6f and m6 platforms, the latter being …
…the one truly supported
- Loading branch information
Showing
20 changed files
with
2,707 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
Oops, something went wrong.