-
-
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 in parallel the integration of the infinity3 series
- Loading branch information
Showing
5 changed files
with
209 additions
and
11 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,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)); | ||
} |
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,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; |
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,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)); | ||
} |
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