-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes an issue loading a ISP config file, adds early support for Inge…
…nic T series
- Loading branch information
Showing
13 changed files
with
1,067 additions
and
1 deletion.
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,120 @@ | ||
#pragma once | ||
|
||
#include "tx_common.h" | ||
|
||
#define TX_AUD_CHN_NUM 2 | ||
|
||
typedef enum { | ||
TX_AUD_BIT_16 | ||
} tx_aud_bit; | ||
|
||
typedef enum { | ||
TX_AUD_SND_MONO = 1, | ||
TX_AUD_SND_STEREO = 2 | ||
} tx_aud_snd; | ||
|
||
typedef struct { | ||
// Accept industry standards from 8000 to 96000Hz | ||
int rate; | ||
tx_aud_bit bit; | ||
tx_aud_snd mode; | ||
unsigned int frmNum; | ||
unsigned int packNumPerFrm; | ||
unsigned int chnNum; | ||
} tx_aud_cnf; | ||
|
||
typedef struct { | ||
tx_aud_bit bit; | ||
tx_aud_snd mode; | ||
unsigned int addr; | ||
unsigned int phy; | ||
unsigned long long timestamp; | ||
unsigned int sequence; | ||
unsigned int length; | ||
} tx_aud_frm; | ||
|
||
typedef struct { | ||
void *handle; | ||
|
||
int (*fnDisableDevice)(int device); | ||
int (*fnEnableDevice)(int device); | ||
int (*fnSetDeviceConfig)(int device, tx_aud_cnf *config); | ||
|
||
int (*fnDisableChannel)(int device, int channel); | ||
int (*fnEnableChannel)(int device, int channel); | ||
|
||
int (*fnSetMute)(int device, int channel, int active); | ||
int (*fnSetVolume)(int device, int channel, int *dbLevel); | ||
|
||
int (*fnFreeFrame)(int device, int channel, tx_aud_frm *frame); | ||
int (*fnGetFrame)(int device, int channel, tx_aud_frm *frame, int notBlocking); | ||
} tx_aud_impl; | ||
|
||
static int tx_aud_load(tx_aud_impl *aud_lib) { | ||
if (!(aud_lib->handle = dlopen("libimp.so", RTLD_LAZY | RTLD_GLOBAL))) { | ||
fprintf(stderr, "[tx_aud] Failed to load library!\nError: %s\n", dlerror()); | ||
return EXIT_FAILURE; | ||
} | ||
|
||
if (!(aud_lib->fnDisableDevice = (int(*)(int device)) | ||
dlsym(aud_lib->handle, "IMP_AI_Disable"))) { | ||
fprintf(stderr, "[tx_aud] Failed to acquire symbol IMP_AI_Disable!\n"); | ||
return EXIT_FAILURE; | ||
} | ||
|
||
if (!(aud_lib->fnEnableDevice = (int(*)(int device)) | ||
dlsym(aud_lib->handle, "IMP_AI_Enable"))) { | ||
fprintf(stderr, "[tx_aud] Failed to acquire symbol IMP_AI_Enable!\n"); | ||
return EXIT_FAILURE; | ||
} | ||
|
||
if (!(aud_lib->fnSetDeviceConfig = (int(*)(int device, tx_aud_cnf *config)) | ||
dlsym(aud_lib->handle, "IMP_AI_SetPubAttr"))) { | ||
fprintf(stderr, "[tx_aud] Failed to acquire symbol IMP_AI_SetPubAttr!\n"); | ||
return EXIT_FAILURE; | ||
} | ||
|
||
if (!(aud_lib->fnDisableChannel = (int(*)(int device, int channel)) | ||
dlsym(aud_lib->handle, "IMP_AI_DisableChn"))) { | ||
fprintf(stderr, "[tx_aud] Failed to acquire symbol IMP_AI_DisableChn!\n"); | ||
return EXIT_FAILURE; | ||
} | ||
|
||
if (!(aud_lib->fnEnableChannel = (int(*)(int device, int channel)) | ||
dlsym(aud_lib->handle, "IMP_AI_EnableChn"))) { | ||
fprintf(stderr, "[tx_aud] Failed to acquire symbol IMP_AI_EnableChn!\n"); | ||
return EXIT_FAILURE; | ||
} | ||
|
||
if (!(aud_lib->fnSetMute = (int(*)(int device, int channel, int active)) | ||
dlsym(aud_lib->handle, "IMP_AI_SetVolMute"))) { | ||
fprintf(stderr, "[tx_aud] Failed to acquire symbol IMP_AI_SetVolMute!\n"); | ||
return EXIT_FAILURE; | ||
} | ||
|
||
if (!(aud_lib->fnSetVolume = (int(*)(int device, int channel, int dbLevel)) | ||
dlsym(aud_lib->handle, "IMP_AI_SetVol"))) { | ||
fprintf(stderr, "[tx_aud] Failed to acquire symbol IMP_AI_SetVol!\n"); | ||
return EXIT_FAILURE; | ||
} | ||
|
||
if (!(aud_lib->fnFreeFrame = (int(*)(int device, int channel, tx_aud_frm *frame)) | ||
dlsym(aud_lib->handle, "IMP_AI_ReleaseFrame"))) { | ||
fprintf(stderr, "[tx_aud] Failed to acquire symbol IMP_AI_ReleaseFrame!\n"); | ||
return EXIT_FAILURE; | ||
} | ||
|
||
if (!(aud_lib->fnGetFrame = (int(*)(int device, int channel, tx_aud_frm *frame, int notBlocking)) | ||
dlsym(aud_lib->handle, "IMP_AI_GetFrame"))) { | ||
fprintf(stderr, "[tx_aud] Failed to acquire symbol IMP_AI_GetFrame!\n"); | ||
return EXIT_FAILURE; | ||
} | ||
|
||
return EXIT_SUCCESS; | ||
} | ||
|
||
static void tx_aud_unload(tx_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,74 @@ | ||
#pragma once | ||
|
||
#include <dlfcn.h> | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
#include <sys/select.h> | ||
|
||
#include "../types.h" | ||
|
||
#define TX_ERROR(x, ...) \ | ||
do { \ | ||
fprintf(stderr, "[tx_hal] \033[31m"); \ | ||
fprintf(stderr, (x), ##__VA_ARGS__); \ | ||
fprintf(stderr, "\033[0m"); \ | ||
return EXIT_FAILURE; \ | ||
} while (0) | ||
|
||
typedef enum { | ||
TX_PIXFMT_YUV420P, | ||
TX_PIXFMT_YUV422_YUYV, | ||
TX_PIXFMT_YUV422_UYVY, | ||
TX_PIXFMT_YUV422P, | ||
TX_PIXFMT_YUV444P, | ||
TX_PIXFMT_YUV410P, | ||
TX_PIXFMT_YUV411P, | ||
TX_PIXFMT_GRAY8, | ||
TX_PIXFMT_MONOWHITE, | ||
TX_PIXFMT_MONOBLACK, | ||
TX_PIXFMT_NV12, | ||
TX_PIXFMT_NV24, | ||
TX_PIXFMT_RGB888, | ||
TX_PIXFMT_BGR888, | ||
TX_PIXFMT_ARGB8888, | ||
TX_PIXFMT_RGBA8888, | ||
TX_PIXFMT_ABGR8888, | ||
TX_PIXFMT_BGRA8888, | ||
TX_PIXFMT_RGB565BE, | ||
TX_PIXFMT_RGB565LE, | ||
// Following twos have their MSB set to 1 | ||
TX_PIXFMT_RGB555BE, | ||
TX_PIXFMT_RGB555LE, | ||
TX_PIXFMT_BGR565BE, | ||
TX_PIXFMT_BGR565LE, | ||
// Following twos have their MSB set to 1 | ||
TX_PIXFMT_BGR555BE, | ||
TX_PIXFMT_BGR555LE, | ||
TX_PIXFMT_0RGB8888, | ||
TX_PIXFMT_RGB08888, | ||
TX_PIXFMT_0BGR8888, | ||
TX_PIXFMT_BGR08888, | ||
TX_PIXFMT_BAYER_BGGR8, | ||
TX_PIXFMT_BAYER_RGGB8, | ||
TX_PIXFMT_BAYER_GBRG8, | ||
TX_PIXFMT_BAYER_GRBG8, | ||
TX_PIXFMT_RAW, | ||
TX_PIXFMT_HSV888, | ||
TX_PIXFMT_END | ||
} tx_common_pixfmt; | ||
|
||
typedef struct { | ||
int width; | ||
int height; | ||
} tx_common_dim; | ||
|
||
typedef struct { | ||
int x; | ||
int y; | ||
} tx_common_pnt; | ||
|
||
typedef struct { | ||
tx_common_pnt p0; | ||
tx_common_pnt p1; | ||
} tx_common_rect; |
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,115 @@ | ||
#pragma once | ||
|
||
#include "tx_common.h" | ||
|
||
typedef struct { | ||
int enable; | ||
int left; | ||
int top; | ||
int width; | ||
int height; | ||
} tx_fs_crop; | ||
|
||
typedef struct { | ||
int enable; | ||
int width; | ||
int height; | ||
} tx_fs_scale; | ||
|
||
typedef struct { | ||
tx_common_dim dest; | ||
tx_common_pixfmt pixFmt; | ||
tx_fs_crop crop; | ||
tx_fs_scale scale; | ||
int fpsNum; | ||
int fpsDen; | ||
int bufCount; | ||
int phyOrExtChn; | ||
tx_fs_crop frame; | ||
} tx_fs_chn; | ||
|
||
typedef struct { | ||
int index; | ||
int poolId; | ||
unsigned int width; | ||
unsigned int height; | ||
tx_common_pixfmt pixFmt; | ||
unsigned int size; | ||
unsigned int phyAddr; | ||
unsigned int virtAddr; | ||
long long timestamp; | ||
int rotateFlag; | ||
unsigned int priv[0]; | ||
} tx_fs_frame; | ||
|
||
typedef struct { | ||
void *handle; | ||
|
||
int (*fnCreateChannel)(int channel, tx_fs_chn *config); | ||
int (*fnDestroyChannel)(int channel); | ||
int (*fnDisableChannel)(int channel); | ||
int (*fnEnableChannel)(int channel); | ||
int (*fnSetChannelRotate)(int channel, char rotateMode, int width, int height); | ||
int (*fnSetChannelSource)(int channel, int source); | ||
|
||
int (*fnSnapshot)(int channel, tx_common_pixfmt pixFmt, int width, int height, | ||
void *data, tx_fs_frame *info); | ||
} tx_fs_impl; | ||
|
||
static int tx_fs_load(tx_fs_impl *fs_lib) { | ||
if (!(fs_lib->handle = dlopen("libimp.so", RTLD_LAZY | RTLD_GLOBAL))) { | ||
fprintf(stderr, "[tx_fs] Failed to load library!\nError: %s\n", dlerror()); | ||
return EXIT_FAILURE; | ||
} | ||
|
||
if (!(fs_lib->fnCreateChannel = (int(*)(int channel, tx_fs_chn *config)) | ||
dlsym(fs_lib->handle, "IMP_FrameSource_CreateChn"))) { | ||
fprintf(stderr, "[tx_fs] Failed to acquire symbol IMP_FrameSource_CreateChn!\n"); | ||
return EXIT_FAILURE; | ||
} | ||
|
||
if (!(fs_lib->fnDestroyChannel = (int(*)(int channel)) | ||
dlsym(fs_lib->handle, "IMP_FrameSource_DestroyChn"))) { | ||
fprintf(stderr, "[tx_fs] Failed to acquire symbol IMP_FrameSource_DestroyChn!\n"); | ||
return EXIT_FAILURE; | ||
} | ||
|
||
if (!(fs_lib->fnDisableChannel = (int(*)(int channel)) | ||
dlsym(fs_lib->handle, "IMP_FrameSource_DisableChn"))) { | ||
fprintf(stderr, "[tx_fs] Failed to acquire symbol IMP_FrameSource_DisableChn!\n"); | ||
return EXIT_FAILURE; | ||
} | ||
|
||
if (!(fs_lib->fnEnableChannel = (int(*)(int channel)) | ||
dlsym(fs_lib->handle, "IMP_FrameSource_EnableChn"))) { | ||
fprintf(stderr, "[tx_fs] Failed to acquire symbol IMP_FrameSource_EnableChn!\n"); | ||
return EXIT_FAILURE; | ||
} | ||
|
||
if (!(fs_lib->fnSetChannelRotate = (int(*)(int channel, char rotateMode, int width, int height)) | ||
dlsym(fs_lib->handle, "IMP_FrameSource_SetChnRotate"))) { | ||
fprintf(stderr, "[tx_fs] Failed to acquire symbol IMP_FrameSource_SetChnRotate!\n"); | ||
return EXIT_FAILURE; | ||
} | ||
|
||
if (!(fs_lib->fnSetChannelSource = (int(*)(int channel, int source)) | ||
dlsym(fs_lib->handle, "IMP_FrameSource_SetSource"))) { | ||
fprintf(stderr, "[tx_fs] Failed to acquire symbol IMP_FrameSource_SetSource!\n"); | ||
return EXIT_FAILURE; | ||
} | ||
|
||
if (!(fs_lib->fnSnapshot = (int(*)(int channel, tx_common_pixfmt pixFmt, int width, int height, | ||
void *data, tx_fs_frame *info)) | ||
dlsym(fs_lib->handle, "IMP_FrameSource_SnapFrame"))) { | ||
fprintf(stderr, "[tx_fs] Failed to acquire symbol IMP_FrameSource_SnapFrame!\n"); | ||
return EXIT_FAILURE; | ||
} | ||
|
||
return EXIT_SUCCESS; | ||
} | ||
|
||
static void tx_fs_unload(tx_fs_impl *fs_lib) { | ||
if (fs_lib->handle) dlclose(fs_lib->handle); | ||
fs_lib->handle = NULL; | ||
memset(fs_lib, 0, sizeof(*fs_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,41 @@ | ||
#include "tx_hal.h" | ||
|
||
tx_aud_impl tx_aud; | ||
tx_fs_impl tx_fs; | ||
tx_isp_impl tx_isp; | ||
tx_osd_impl tx_osd; | ||
tx_sys_impl tx_sys; | ||
tx_venc_impl tx_venc; | ||
|
||
hal_chnstate tx_state[TX_VENC_CHN_NUM] = {0}; | ||
int (*tx_venc_cb)(char, hal_vidstream*); | ||
|
||
void tx_hal_deinit(void) | ||
{ | ||
tx_venc_unload(&tx_venc); | ||
tx_osd_unload(&tx_osd); | ||
tx_isp_unload(&tx_isp); | ||
tx_fs_unload(&tx_fs); | ||
tx_aud_unload(&tx_aud); | ||
tx_sys_unload(&tx_sys); | ||
} | ||
|
||
int tx_hal_init(void) | ||
{ | ||
int ret; | ||
|
||
if (ret = tx_sys_load(&tx_sys)) | ||
return ret; | ||
if (ret = tx_aud_load(&tx_aud)) | ||
return ret; | ||
if (ret = tx_fs_load(&tx_fs)) | ||
return ret; | ||
if (ret = tx_isp_load(&tx_isp)) | ||
return ret; | ||
if (ret = tx_osd_load(&tx_osd)) | ||
return ret; | ||
if (ret = tx_venc_load(&tx_venc)) | ||
return ret; | ||
|
||
return EXIT_SUCCESS; | ||
} |
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,11 @@ | ||
#pragma once | ||
|
||
#include "tx_common.h" | ||
#include "tx_aud.h" | ||
#include "tx_fs.h" | ||
#include "tx_isp.h" | ||
#include "tx_osd.h" | ||
#include "tx_sys.h" | ||
#include "tx_venc.h" | ||
|
||
extern char keepRunning; |
Oops, something went wrong.