-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
2,326 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
#pragma once | ||
|
||
#include "v3_common.h" | ||
|
||
#define V3_AUD_CHN_NUM 2 | ||
|
||
typedef enum { | ||
V3_AUD_BIT_8, | ||
V3_AUD_BIT_16, | ||
V3_AUD_BIT_24 | ||
} v3_aud_bit; | ||
|
||
typedef enum { | ||
V3_AUD_INTF_I2S_MASTER, | ||
V3_AUD_INTF_I2S_SLAVE, | ||
V3_AUD_INTF_PCM_SLAVE_STD, | ||
V3_AUD_INTF_PCM_SLAVE_NSTD, | ||
V3_AUD_INTF_PCM_MASTER_STD, | ||
V3_AUD_INTF_PCM_MASTER_NSTD, | ||
V3_AUD_INTF_END | ||
} v3_aud_intf; | ||
|
||
typedef struct { | ||
// Accept industry standards from | ||
// 8000 to 96000Hz, plus 64000Hz | ||
int rate; | ||
v3_aud_bit bit; | ||
v3_aud_intf intf; | ||
int stereoOn; | ||
// 8-to-16 bit, expand mode | ||
int expandOn; | ||
unsigned int frmNum; | ||
unsigned int packNumPerFrm; | ||
unsigned int chnNum; | ||
unsigned int syncRxClkOn; | ||
} v3_aud_cnf; | ||
|
||
typedef struct { | ||
v3_aud_bit bit; | ||
int stereoOn; | ||
void *addr[2]; | ||
unsigned int phy[2]; | ||
unsigned long long timestamp; | ||
unsigned int sequence; | ||
unsigned int length; | ||
unsigned int poolId[2]; | ||
} v3_aud_frm; | ||
|
||
typedef struct { | ||
v3_aud_frm frame; | ||
char isValid; | ||
char isSysBound; | ||
} v3_aud_efrm; | ||
|
||
typedef struct { | ||
void *handle, *handleGoke; | ||
|
||
int (*fnDisableDevice)(int device); | ||
int (*fnEnableDevice)(int device); | ||
int (*fnSetDeviceConfig)(int device, v3_aud_cnf *config); | ||
|
||
int (*fnDisableChannel)(int device, int channel); | ||
int (*fnEnableChannel)(int device, int channel); | ||
|
||
int (*fnFreeFrame)(int device, int channel, v3_aud_frm *frame, v3_aud_efrm *encFrame); | ||
int (*fnGetFrame)(int device, int channel, v3_aud_frm *frame, v3_aud_efrm *encFrame, int millis); | ||
} v3_aud_impl; | ||
|
||
static int v3_aud_load(v3_aud_impl *aud_lib) { | ||
if (!(aud_lib->handle = dlopen("libmpi.so", RTLD_LAZY | RTLD_GLOBAL))) { | ||
fprintf(stderr, "[v3_aud] Failed to load library!\nError: %s\n", dlerror()); | ||
return EXIT_FAILURE; | ||
} | ||
|
||
if (!(aud_lib->fnDisableDevice = (int(*)(int device)) | ||
dlsym(aud_lib->handle, "HI_MPI_AI_Disable"))) { | ||
fprintf(stderr, "[v3_aud] Failed to acquire symbol HI_MPI_AI_Disable!\n"); | ||
return EXIT_FAILURE; | ||
} | ||
|
||
if (!(aud_lib->fnEnableDevice = (int(*)(int device)) | ||
dlsym(aud_lib->handle, "HI_MPI_AI_Enable"))) { | ||
fprintf(stderr, "[v3_aud] Failed to acquire symbol HI_MPI_AI_Enable!\n"); | ||
return EXIT_FAILURE; | ||
} | ||
|
||
if (!(aud_lib->fnSetDeviceConfig = (int(*)(int device, v3_aud_cnf *config)) | ||
dlsym(aud_lib->handle, "HI_MPI_AI_SetPubAttr"))) { | ||
fprintf(stderr, "[v3_aud] Failed to acquire symbol HI_MPI_AI_SetPubAttr!\n"); | ||
return EXIT_FAILURE; | ||
} | ||
|
||
if (!(aud_lib->fnDisableChannel = (int(*)(int device, int channel)) | ||
dlsym(aud_lib->handle, "HI_MPI_AI_DisableChn"))) { | ||
fprintf(stderr, "[v3_aud] Failed to acquire symbol HI_MPI_AI_DisableChn!\n"); | ||
return EXIT_FAILURE; | ||
} | ||
|
||
if (!(aud_lib->fnEnableChannel = (int(*)(int device, int channel)) | ||
dlsym(aud_lib->handle, "HI_MPI_AI_EnableChn"))) { | ||
fprintf(stderr, "[v3_aud] Failed to acquire symbol HI_MPI_AI_EnableChn!\n"); | ||
return EXIT_FAILURE; | ||
} | ||
|
||
if (!(aud_lib->fnFreeFrame = (int(*)(int device, int channel, v3_aud_frm *frame, v3_aud_efrm *encFrame)) | ||
dlsym(aud_lib->handle, "HI_MPI_AI_ReleaseFrame"))) { | ||
fprintf(stderr, "[v3_aud] Failed to acquire symbol HI_MPI_AI_ReleaseFrame!\n"); | ||
return EXIT_FAILURE; | ||
} | ||
|
||
if (!(aud_lib->fnGetFrame = (int(*)(int device, int channel, v3_aud_frm *frame, v3_aud_efrm *encFrame, int millis)) | ||
dlsym(aud_lib->handle, "HI_MPI_AI_GetFrame"))) { | ||
fprintf(stderr, "[v3_aud] Failed to acquire symbol HI_MPI_AI_GetFrame!\n"); | ||
return EXIT_FAILURE; | ||
} | ||
|
||
return EXIT_SUCCESS; | ||
} | ||
|
||
static void v3_aud_unload(v3_aud_impl *aud_lib) { | ||
if (aud_lib->handle) dlclose(aud_lib->handle); | ||
aud_lib->handle = NULL; | ||
if (aud_lib->handleGoke) dlclose(aud_lib->handleGoke); | ||
aud_lib->handleGoke = 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,125 @@ | ||
#pragma once | ||
|
||
#include <dlfcn.h> | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
#include <sys/select.h> | ||
|
||
#include "../types.h" | ||
|
||
#define V3_ERROR(x, ...) \ | ||
do { \ | ||
fprintf(stderr, "[v3_hal] \033[31m"); \ | ||
fprintf(stderr, (x), ##__VA_ARGS__); \ | ||
fprintf(stderr, "\033[0m"); \ | ||
return EXIT_FAILURE; \ | ||
} while (0) | ||
|
||
typedef enum { | ||
V3_BAYER_RG, | ||
V3_BAYER_GR, | ||
V3_BAYER_GB, | ||
V3_BAYER_BG, | ||
V3_BAYER_END | ||
} v3_common_bayer; | ||
|
||
typedef enum { | ||
V3_COMPR_NONE, | ||
V3_COMPR_SEG, | ||
V3_COMPR_SEG128, | ||
V3_COMPR_LINE, | ||
V3_COMPR_FRAME, | ||
V3_COMPR_END | ||
} v3_common_compr; | ||
|
||
typedef enum { | ||
V3_PIXFMT_1BPP, | ||
V3_PIXFMT_2BPP, | ||
V3_PIXFMT_4BPP, | ||
V3_PIXFMT_8BPP, | ||
V3_PIXFMT_RGB444, | ||
V3_PIXFMT_ARGB4444, | ||
V3_PIXFMT_RGB555, | ||
V3_PIXFMT_RGB565, | ||
V3_PIXFMT_ARGB1555, | ||
V3_PIXFMT_RGB888, | ||
V3_PIXFMT_ARGB8888, | ||
V3_PIXFMT_RGB888P, | ||
V3_PIXFMT_RGB_BAYER_8BPP, | ||
V3_PIXFMT_RGB_BAYER_10BPP, | ||
V3_PIXFMT_RGB_BAYER_12BPP, | ||
V3_PIXFMT_RGB_BAYER_14BPP, | ||
V3_PIXFMT_RGB_BAYER_16BPP, | ||
V3_PIXFMT_YUV_A422, | ||
V3_PIXFMT_YUV_A444, | ||
V3_PIXFMT_YUV422P, | ||
V3_PIXFMT_YUV420P, | ||
V3_PIXFMT_YUV444P, | ||
V3_PIXFMT_YUV422SP, | ||
V3_PIXFMT_YUV420SP, | ||
V3_PIXFMT_YUV444SP, | ||
V3_PIXFMT_YUV422_UYVY, | ||
V3_PIXFMT_YUV422_YUYV, | ||
V3_PIXFMT_YUV422_VYUY, | ||
V3_PIXFMT_YCbCrP, | ||
V3_PIXFMT_YUV400, | ||
V3_PIXFMT_END | ||
} v3_common_pixfmt; | ||
|
||
typedef enum { | ||
V3_PREC_8BPP, | ||
V3_PREC_10BPP, | ||
V3_PREC_12BPP, | ||
V3_PREC_14BPP, | ||
V3_PREC_16BPP, | ||
V3_PREC_END | ||
} v3_common_prec; | ||
|
||
typedef enum { | ||
V3_VIDFMT_LINEAR, | ||
V3_VIDFMT_TILE_256X16, | ||
V3_VIDFMT_TILE_64X16, | ||
V3_VIDFMT_END | ||
} v3_common_vidfmt; | ||
|
||
typedef enum { | ||
V3_WDR_NONE, | ||
V3_WDR_BUILTIN, | ||
V3_WDR_QUDRA, | ||
V3_WDR_2TO1_LINE, | ||
V3_WDR_2TO1_FRAME, | ||
V3_WDR_2TO1_FRAME_FULLRATE, | ||
V3_WDR_3TO1_LINE, | ||
V3_WDR_3TO1_FRAME, | ||
V3_WDR_3TO1_FRAME_FULLRATE, | ||
V3_WDR_4TO1_LINE, | ||
V3_WDR_4TO1_FRAME, | ||
V3_WDR_4TO1_FRAME_FULLRATE, | ||
V3_WDR_END | ||
} v3_common_wdr; | ||
|
||
typedef struct { | ||
unsigned int topWidth; | ||
unsigned int bottomWidth; | ||
unsigned int leftWidth; | ||
unsigned int rightWidth; | ||
unsigned int color; | ||
} v3_common_bord; | ||
|
||
typedef struct { | ||
unsigned int width; | ||
unsigned int height; | ||
} v3_common_dim; | ||
|
||
typedef struct { | ||
int x; | ||
int y; | ||
} v3_common_pnt; | ||
|
||
typedef struct { | ||
int x; | ||
int y; | ||
unsigned int width; | ||
unsigned int height; | ||
} v3_common_rect; |
Oops, something went wrong.