-
-
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.
Preparing to add support for hisi-gen2
- Loading branch information
Showing
21 changed files
with
3,062 additions
and
23 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,108 @@ | ||
#pragma once | ||
|
||
#include "v2_common.h" | ||
|
||
#define V2_AUD_CHN_NUM 2 | ||
|
||
typedef enum { | ||
V2_AUD_BIT_8, | ||
V2_AUD_BIT_16, | ||
V2_AUD_BIT_24 | ||
} v2_aud_bit; | ||
|
||
typedef enum { | ||
V2_AUD_INTF_I2S_MASTER, | ||
V2_AUD_INTF_I2S_SLAVE, | ||
V2_AUD_INTF_PCM_SLAVE_STD, | ||
V2_AUD_INTF_PCM_SLAVE_NSTD, | ||
V2_AUD_INTF_PCM_MASTER_STD, | ||
V2_AUD_INTF_PCM_MASTER_NSTD, | ||
V2_AUD_INTF_END | ||
} v2_aud_intf; | ||
|
||
typedef struct { | ||
// Accept industry standards from | ||
// 8000 to 96000Hz, plus 64000Hz | ||
int rate; | ||
v2_aud_bit bit; | ||
v2_aud_intf intf; | ||
int stereoOn; | ||
// 8-to-16 bit, expand mode | ||
unsigned int expandOn; | ||
unsigned int frmNum; | ||
unsigned int packNumPerFrm; | ||
unsigned int chnNum; | ||
unsigned int syncRxClkOn; | ||
} v2_aud_cnf; | ||
|
||
typedef struct { | ||
v2_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]; | ||
} v2_aud_frm; | ||
|
||
typedef struct { | ||
v2_aud_frm frame; | ||
char isValid; | ||
char isSysBound; | ||
} v2_aud_efrm; | ||
|
||
typedef struct { | ||
void *handle; | ||
|
||
int (*fnDisableDevice)(int device); | ||
int (*fnEnableDevice)(int device); | ||
int (*fnSetDeviceConfig)(int device, v2_aud_cnf *config); | ||
|
||
int (*fnDisableChannel)(int device, int channel); | ||
int (*fnEnableChannel)(int device, int channel); | ||
|
||
int (*fnFreeFrame)(int device, int channel, v2_aud_frm *frame, v2_aud_efrm *encFrame); | ||
int (*fnGetFrame)(int device, int channel, v2_aud_frm *frame, v2_aud_efrm *encFrame, int millis); | ||
} v2_aud_impl; | ||
|
||
static int v2_aud_load(v2_aud_impl *aud_lib) { | ||
if (!(aud_lib->handle = dlopen("libmpi.so", RTLD_LAZY | RTLD_GLOBAL))) | ||
HAL_ERROR("v2_aud", "Failed to load library!\nError: %s\n", dlerror()); | ||
|
||
if (!(aud_lib->fnDisableDevice = (int(*)(int device)) | ||
hal_symbol_load("v2_aud", aud_lib->handle, "HI_MPI_AI_Disable"))) | ||
return EXIT_FAILURE; | ||
|
||
if (!(aud_lib->fnEnableDevice = (int(*)(int device)) | ||
hal_symbol_load("v2_aud", aud_lib->handle, "HI_MPI_AI_Enable"))) | ||
return EXIT_FAILURE; | ||
|
||
if (!(aud_lib->fnSetDeviceConfig = (int(*)(int device, v2_aud_cnf *config)) | ||
hal_symbol_load("v2_aud", aud_lib->handle, "HI_MPI_AI_SetPubAttr"))) | ||
return EXIT_FAILURE; | ||
|
||
if (!(aud_lib->fnDisableChannel = (int(*)(int device, int channel)) | ||
hal_symbol_load("v2_aud", aud_lib->handle, "HI_MPI_AI_DisableChn"))) | ||
return EXIT_FAILURE; | ||
|
||
if (!(aud_lib->fnEnableChannel = (int(*)(int device, int channel)) | ||
hal_symbol_load("v2_aud", aud_lib->handle, "HI_MPI_AI_EnableChn"))) | ||
return EXIT_FAILURE; | ||
|
||
if (!(aud_lib->fnFreeFrame = (int(*)(int device, int channel, v2_aud_frm *frame, v2_aud_efrm *encFrame)) | ||
hal_symbol_load("v2_aud", aud_lib->handle, "HI_MPI_AI_ReleaseFrame"))) | ||
return EXIT_FAILURE; | ||
|
||
if (!(aud_lib->fnGetFrame = (int(*)(int device, int channel, v2_aud_frm *frame, v2_aud_efrm *encFrame, int millis)) | ||
hal_symbol_load("v2_aud", aud_lib->handle, "HI_MPI_AI_GetFrame"))) | ||
return EXIT_FAILURE; | ||
|
||
return EXIT_SUCCESS; | ||
} | ||
|
||
static void v2_aud_unload(v2_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,118 @@ | ||
#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 { | ||
V2_BAYER_RG, | ||
V2_BAYER_GR, | ||
V2_BAYER_GB, | ||
V2_BAYER_BG, | ||
V2_BAYER_END | ||
} v2_common_bayer; | ||
|
||
typedef enum { | ||
V2_COMPR_NONE, | ||
V2_COMPR_SEG, | ||
V2_COMPR_SEG128, | ||
V2_COMPR_LINE, | ||
V2_COMPR_FRAME, | ||
V2_COMPR_END | ||
} v2_common_compr; | ||
|
||
typedef enum { | ||
V2_PIXFMT_1BPP, | ||
V2_PIXFMT_2BPP, | ||
V2_PIXFMT_4BPP, | ||
V2_PIXFMT_8BPP, | ||
V2_PIXFMT_RGB444, | ||
V2_PIXFMT_ARGB4444, | ||
V2_PIXFMT_RGB555, | ||
V2_PIXFMT_RGB565, | ||
V2_PIXFMT_ARGB1555, | ||
V2_PIXFMT_RGB888, | ||
V2_PIXFMT_ARGB8888, | ||
V2_PIXFMT_RGB888P, | ||
V2_PIXFMT_RGB_BAYER_8BPP, | ||
V2_PIXFMT_RGB_BAYER_10BPP, | ||
V2_PIXFMT_RGB_BAYER_12BPP, | ||
V2_PIXFMT_RGB_BAYER_14BPP, | ||
V2_PIXFMT_RGB_BAYER_16BPP, | ||
V2_PIXFMT_YUV_A422, | ||
V2_PIXFMT_YUV_A444, | ||
V2_PIXFMT_YUV422P, | ||
V2_PIXFMT_YUV420P, | ||
V2_PIXFMT_YUV444P, | ||
V2_PIXFMT_YUV422SP, | ||
V2_PIXFMT_YUV420SP, | ||
V2_PIXFMT_YUV444SP, | ||
V2_PIXFMT_YUV422_UYVY, | ||
V2_PIXFMT_YUV422_YUYV, | ||
V2_PIXFMT_YUV422_VYUY, | ||
V2_PIXFMT_YCbCrP, | ||
V2_PIXFMT_YUV400, | ||
V2_PIXFMT_END | ||
} v2_common_pixfmt; | ||
|
||
typedef enum { | ||
V2_PREC_8BPP, | ||
V2_PREC_10BPP, | ||
V2_PREC_12BPP, | ||
V2_PREC_14BPP, | ||
V2_PREC_16BPP, | ||
V2_PREC_END | ||
} v2_common_prec; | ||
|
||
typedef enum { | ||
V2_VIDFMT_LINEAR, | ||
V2_VIDFMT_TILE_256X16, | ||
V2_VIDFMT_TILE_64X16, | ||
V2_VIDFMT_END | ||
} v2_common_vidfmt; | ||
|
||
typedef enum { | ||
V2_WDR_NONE, | ||
V2_WDR_BUILTIN, | ||
V2_WDR_QUDRA, | ||
V2_WDR_2TO1_LINE, | ||
V2_WDR_2TO1_FRAME, | ||
V2_WDR_2TO1_FRAME_FULLRATE, | ||
V2_WDR_3TO1_LINE, | ||
V2_WDR_3TO1_FRAME, | ||
V2_WDR_3TO1_FRAME_FULLRATE, | ||
V2_WDR_4TO1_LINE, | ||
V2_WDR_4TO1_FRAME, | ||
V2_WDR_4TO1_FRAME_FULLRATE, | ||
V2_WDR_END | ||
} v2_common_wdr; | ||
|
||
typedef struct { | ||
unsigned int topWidth; | ||
unsigned int bottomWidth; | ||
unsigned int leftWidth; | ||
unsigned int rightWidth; | ||
unsigned int color; | ||
} v2_common_bord; | ||
|
||
typedef struct { | ||
unsigned int width; | ||
unsigned int height; | ||
} v2_common_dim; | ||
|
||
typedef struct { | ||
int x; | ||
int y; | ||
} v2_common_pnt; | ||
|
||
typedef struct { | ||
int x; | ||
int y; | ||
unsigned int width; | ||
unsigned int height; | ||
} v2_common_rect; |
Oops, something went wrong.