Skip to content

Commit ae85ecf

Browse files
committed
Fixes an issue loading a ISP config file, adds early support for Ingenic T series
1 parent 86034e5 commit ae85ecf

File tree

13 files changed

+1067
-1
lines changed

13 files changed

+1067
-1
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ In spite of these design choices, Divinus boasts numerous features that cater to
2828
| infinity6e[^6] || ✔️ | ✔️ || ✔️ |
2929
| infinity6c[^7] || ✔️ | ✔️ || ✔️ |
3030
| infinity6f[^8] || ✔️ | ✔️ || ✔️ |
31+
| T2X series ||||||
32+
| T3X series ||||||
3133

3234
_✔️ - supported, ↻ - in development, ✗ - unsupported, ⁿ/ₐ - not supported by hardware_
3335

src/hal/inge/tx_aud.h

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
#pragma once
2+
3+
#include "tx_common.h"
4+
5+
#define TX_AUD_CHN_NUM 2
6+
7+
typedef enum {
8+
TX_AUD_BIT_16
9+
} tx_aud_bit;
10+
11+
typedef enum {
12+
TX_AUD_SND_MONO = 1,
13+
TX_AUD_SND_STEREO = 2
14+
} tx_aud_snd;
15+
16+
typedef struct {
17+
// Accept industry standards from 8000 to 96000Hz
18+
int rate;
19+
tx_aud_bit bit;
20+
tx_aud_snd mode;
21+
unsigned int frmNum;
22+
unsigned int packNumPerFrm;
23+
unsigned int chnNum;
24+
} tx_aud_cnf;
25+
26+
typedef struct {
27+
tx_aud_bit bit;
28+
tx_aud_snd mode;
29+
unsigned int addr;
30+
unsigned int phy;
31+
unsigned long long timestamp;
32+
unsigned int sequence;
33+
unsigned int length;
34+
} tx_aud_frm;
35+
36+
typedef struct {
37+
void *handle;
38+
39+
int (*fnDisableDevice)(int device);
40+
int (*fnEnableDevice)(int device);
41+
int (*fnSetDeviceConfig)(int device, tx_aud_cnf *config);
42+
43+
int (*fnDisableChannel)(int device, int channel);
44+
int (*fnEnableChannel)(int device, int channel);
45+
46+
int (*fnSetMute)(int device, int channel, int active);
47+
int (*fnSetVolume)(int device, int channel, int *dbLevel);
48+
49+
int (*fnFreeFrame)(int device, int channel, tx_aud_frm *frame);
50+
int (*fnGetFrame)(int device, int channel, tx_aud_frm *frame, int notBlocking);
51+
} tx_aud_impl;
52+
53+
static int tx_aud_load(tx_aud_impl *aud_lib) {
54+
if (!(aud_lib->handle = dlopen("libimp.so", RTLD_LAZY | RTLD_GLOBAL))) {
55+
fprintf(stderr, "[tx_aud] Failed to load library!\nError: %s\n", dlerror());
56+
return EXIT_FAILURE;
57+
}
58+
59+
if (!(aud_lib->fnDisableDevice = (int(*)(int device))
60+
dlsym(aud_lib->handle, "IMP_AI_Disable"))) {
61+
fprintf(stderr, "[tx_aud] Failed to acquire symbol IMP_AI_Disable!\n");
62+
return EXIT_FAILURE;
63+
}
64+
65+
if (!(aud_lib->fnEnableDevice = (int(*)(int device))
66+
dlsym(aud_lib->handle, "IMP_AI_Enable"))) {
67+
fprintf(stderr, "[tx_aud] Failed to acquire symbol IMP_AI_Enable!\n");
68+
return EXIT_FAILURE;
69+
}
70+
71+
if (!(aud_lib->fnSetDeviceConfig = (int(*)(int device, tx_aud_cnf *config))
72+
dlsym(aud_lib->handle, "IMP_AI_SetPubAttr"))) {
73+
fprintf(stderr, "[tx_aud] Failed to acquire symbol IMP_AI_SetPubAttr!\n");
74+
return EXIT_FAILURE;
75+
}
76+
77+
if (!(aud_lib->fnDisableChannel = (int(*)(int device, int channel))
78+
dlsym(aud_lib->handle, "IMP_AI_DisableChn"))) {
79+
fprintf(stderr, "[tx_aud] Failed to acquire symbol IMP_AI_DisableChn!\n");
80+
return EXIT_FAILURE;
81+
}
82+
83+
if (!(aud_lib->fnEnableChannel = (int(*)(int device, int channel))
84+
dlsym(aud_lib->handle, "IMP_AI_EnableChn"))) {
85+
fprintf(stderr, "[tx_aud] Failed to acquire symbol IMP_AI_EnableChn!\n");
86+
return EXIT_FAILURE;
87+
}
88+
89+
if (!(aud_lib->fnSetMute = (int(*)(int device, int channel, int active))
90+
dlsym(aud_lib->handle, "IMP_AI_SetVolMute"))) {
91+
fprintf(stderr, "[tx_aud] Failed to acquire symbol IMP_AI_SetVolMute!\n");
92+
return EXIT_FAILURE;
93+
}
94+
95+
if (!(aud_lib->fnSetVolume = (int(*)(int device, int channel, int dbLevel))
96+
dlsym(aud_lib->handle, "IMP_AI_SetVol"))) {
97+
fprintf(stderr, "[tx_aud] Failed to acquire symbol IMP_AI_SetVol!\n");
98+
return EXIT_FAILURE;
99+
}
100+
101+
if (!(aud_lib->fnFreeFrame = (int(*)(int device, int channel, tx_aud_frm *frame))
102+
dlsym(aud_lib->handle, "IMP_AI_ReleaseFrame"))) {
103+
fprintf(stderr, "[tx_aud] Failed to acquire symbol IMP_AI_ReleaseFrame!\n");
104+
return EXIT_FAILURE;
105+
}
106+
107+
if (!(aud_lib->fnGetFrame = (int(*)(int device, int channel, tx_aud_frm *frame, int notBlocking))
108+
dlsym(aud_lib->handle, "IMP_AI_GetFrame"))) {
109+
fprintf(stderr, "[tx_aud] Failed to acquire symbol IMP_AI_GetFrame!\n");
110+
return EXIT_FAILURE;
111+
}
112+
113+
return EXIT_SUCCESS;
114+
}
115+
116+
static void tx_aud_unload(tx_aud_impl *aud_lib) {
117+
if (aud_lib->handle) dlclose(aud_lib->handle);
118+
aud_lib->handle = NULL;
119+
memset(aud_lib, 0, sizeof(*aud_lib));
120+
}

src/hal/inge/tx_common.h

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#pragma once
2+
3+
#include <dlfcn.h>
4+
#include <stdio.h>
5+
#include <stdlib.h>
6+
#include <string.h>
7+
#include <sys/select.h>
8+
9+
#include "../types.h"
10+
11+
#define TX_ERROR(x, ...) \
12+
do { \
13+
fprintf(stderr, "[tx_hal] \033[31m"); \
14+
fprintf(stderr, (x), ##__VA_ARGS__); \
15+
fprintf(stderr, "\033[0m"); \
16+
return EXIT_FAILURE; \
17+
} while (0)
18+
19+
typedef enum {
20+
TX_PIXFMT_YUV420P,
21+
TX_PIXFMT_YUV422_YUYV,
22+
TX_PIXFMT_YUV422_UYVY,
23+
TX_PIXFMT_YUV422P,
24+
TX_PIXFMT_YUV444P,
25+
TX_PIXFMT_YUV410P,
26+
TX_PIXFMT_YUV411P,
27+
TX_PIXFMT_GRAY8,
28+
TX_PIXFMT_MONOWHITE,
29+
TX_PIXFMT_MONOBLACK,
30+
TX_PIXFMT_NV12,
31+
TX_PIXFMT_NV24,
32+
TX_PIXFMT_RGB888,
33+
TX_PIXFMT_BGR888,
34+
TX_PIXFMT_ARGB8888,
35+
TX_PIXFMT_RGBA8888,
36+
TX_PIXFMT_ABGR8888,
37+
TX_PIXFMT_BGRA8888,
38+
TX_PIXFMT_RGB565BE,
39+
TX_PIXFMT_RGB565LE,
40+
// Following twos have their MSB set to 1
41+
TX_PIXFMT_RGB555BE,
42+
TX_PIXFMT_RGB555LE,
43+
TX_PIXFMT_BGR565BE,
44+
TX_PIXFMT_BGR565LE,
45+
// Following twos have their MSB set to 1
46+
TX_PIXFMT_BGR555BE,
47+
TX_PIXFMT_BGR555LE,
48+
TX_PIXFMT_0RGB8888,
49+
TX_PIXFMT_RGB08888,
50+
TX_PIXFMT_0BGR8888,
51+
TX_PIXFMT_BGR08888,
52+
TX_PIXFMT_BAYER_BGGR8,
53+
TX_PIXFMT_BAYER_RGGB8,
54+
TX_PIXFMT_BAYER_GBRG8,
55+
TX_PIXFMT_BAYER_GRBG8,
56+
TX_PIXFMT_RAW,
57+
TX_PIXFMT_HSV888,
58+
TX_PIXFMT_END
59+
} tx_common_pixfmt;
60+
61+
typedef struct {
62+
int width;
63+
int height;
64+
} tx_common_dim;
65+
66+
typedef struct {
67+
int x;
68+
int y;
69+
} tx_common_pnt;
70+
71+
typedef struct {
72+
tx_common_pnt p0;
73+
tx_common_pnt p1;
74+
} tx_common_rect;

src/hal/inge/tx_fs.h

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
#pragma once
2+
3+
#include "tx_common.h"
4+
5+
typedef struct {
6+
int enable;
7+
int left;
8+
int top;
9+
int width;
10+
int height;
11+
} tx_fs_crop;
12+
13+
typedef struct {
14+
int enable;
15+
int width;
16+
int height;
17+
} tx_fs_scale;
18+
19+
typedef struct {
20+
tx_common_dim dest;
21+
tx_common_pixfmt pixFmt;
22+
tx_fs_crop crop;
23+
tx_fs_scale scale;
24+
int fpsNum;
25+
int fpsDen;
26+
int bufCount;
27+
int phyOrExtChn;
28+
tx_fs_crop frame;
29+
} tx_fs_chn;
30+
31+
typedef struct {
32+
int index;
33+
int poolId;
34+
unsigned int width;
35+
unsigned int height;
36+
tx_common_pixfmt pixFmt;
37+
unsigned int size;
38+
unsigned int phyAddr;
39+
unsigned int virtAddr;
40+
long long timestamp;
41+
int rotateFlag;
42+
unsigned int priv[0];
43+
} tx_fs_frame;
44+
45+
typedef struct {
46+
void *handle;
47+
48+
int (*fnCreateChannel)(int channel, tx_fs_chn *config);
49+
int (*fnDestroyChannel)(int channel);
50+
int (*fnDisableChannel)(int channel);
51+
int (*fnEnableChannel)(int channel);
52+
int (*fnSetChannelRotate)(int channel, char rotateMode, int width, int height);
53+
int (*fnSetChannelSource)(int channel, int source);
54+
55+
int (*fnSnapshot)(int channel, tx_common_pixfmt pixFmt, int width, int height,
56+
void *data, tx_fs_frame *info);
57+
} tx_fs_impl;
58+
59+
static int tx_fs_load(tx_fs_impl *fs_lib) {
60+
if (!(fs_lib->handle = dlopen("libimp.so", RTLD_LAZY | RTLD_GLOBAL))) {
61+
fprintf(stderr, "[tx_fs] Failed to load library!\nError: %s\n", dlerror());
62+
return EXIT_FAILURE;
63+
}
64+
65+
if (!(fs_lib->fnCreateChannel = (int(*)(int channel, tx_fs_chn *config))
66+
dlsym(fs_lib->handle, "IMP_FrameSource_CreateChn"))) {
67+
fprintf(stderr, "[tx_fs] Failed to acquire symbol IMP_FrameSource_CreateChn!\n");
68+
return EXIT_FAILURE;
69+
}
70+
71+
if (!(fs_lib->fnDestroyChannel = (int(*)(int channel))
72+
dlsym(fs_lib->handle, "IMP_FrameSource_DestroyChn"))) {
73+
fprintf(stderr, "[tx_fs] Failed to acquire symbol IMP_FrameSource_DestroyChn!\n");
74+
return EXIT_FAILURE;
75+
}
76+
77+
if (!(fs_lib->fnDisableChannel = (int(*)(int channel))
78+
dlsym(fs_lib->handle, "IMP_FrameSource_DisableChn"))) {
79+
fprintf(stderr, "[tx_fs] Failed to acquire symbol IMP_FrameSource_DisableChn!\n");
80+
return EXIT_FAILURE;
81+
}
82+
83+
if (!(fs_lib->fnEnableChannel = (int(*)(int channel))
84+
dlsym(fs_lib->handle, "IMP_FrameSource_EnableChn"))) {
85+
fprintf(stderr, "[tx_fs] Failed to acquire symbol IMP_FrameSource_EnableChn!\n");
86+
return EXIT_FAILURE;
87+
}
88+
89+
if (!(fs_lib->fnSetChannelRotate = (int(*)(int channel, char rotateMode, int width, int height))
90+
dlsym(fs_lib->handle, "IMP_FrameSource_SetChnRotate"))) {
91+
fprintf(stderr, "[tx_fs] Failed to acquire symbol IMP_FrameSource_SetChnRotate!\n");
92+
return EXIT_FAILURE;
93+
}
94+
95+
if (!(fs_lib->fnSetChannelSource = (int(*)(int channel, int source))
96+
dlsym(fs_lib->handle, "IMP_FrameSource_SetSource"))) {
97+
fprintf(stderr, "[tx_fs] Failed to acquire symbol IMP_FrameSource_SetSource!\n");
98+
return EXIT_FAILURE;
99+
}
100+
101+
if (!(fs_lib->fnSnapshot = (int(*)(int channel, tx_common_pixfmt pixFmt, int width, int height,
102+
void *data, tx_fs_frame *info))
103+
dlsym(fs_lib->handle, "IMP_FrameSource_SnapFrame"))) {
104+
fprintf(stderr, "[tx_fs] Failed to acquire symbol IMP_FrameSource_SnapFrame!\n");
105+
return EXIT_FAILURE;
106+
}
107+
108+
return EXIT_SUCCESS;
109+
}
110+
111+
static void tx_fs_unload(tx_fs_impl *fs_lib) {
112+
if (fs_lib->handle) dlclose(fs_lib->handle);
113+
fs_lib->handle = NULL;
114+
memset(fs_lib, 0, sizeof(*fs_lib));
115+
}

src/hal/inge/tx_hal.c

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#include "tx_hal.h"
2+
3+
tx_aud_impl tx_aud;
4+
tx_fs_impl tx_fs;
5+
tx_isp_impl tx_isp;
6+
tx_osd_impl tx_osd;
7+
tx_sys_impl tx_sys;
8+
tx_venc_impl tx_venc;
9+
10+
hal_chnstate tx_state[TX_VENC_CHN_NUM] = {0};
11+
int (*tx_venc_cb)(char, hal_vidstream*);
12+
13+
void tx_hal_deinit(void)
14+
{
15+
tx_venc_unload(&tx_venc);
16+
tx_osd_unload(&tx_osd);
17+
tx_isp_unload(&tx_isp);
18+
tx_fs_unload(&tx_fs);
19+
tx_aud_unload(&tx_aud);
20+
tx_sys_unload(&tx_sys);
21+
}
22+
23+
int tx_hal_init(void)
24+
{
25+
int ret;
26+
27+
if (ret = tx_sys_load(&tx_sys))
28+
return ret;
29+
if (ret = tx_aud_load(&tx_aud))
30+
return ret;
31+
if (ret = tx_fs_load(&tx_fs))
32+
return ret;
33+
if (ret = tx_isp_load(&tx_isp))
34+
return ret;
35+
if (ret = tx_osd_load(&tx_osd))
36+
return ret;
37+
if (ret = tx_venc_load(&tx_venc))
38+
return ret;
39+
40+
return EXIT_SUCCESS;
41+
}

src/hal/inge/tx_hal.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#pragma once
2+
3+
#include "tx_common.h"
4+
#include "tx_aud.h"
5+
#include "tx_fs.h"
6+
#include "tx_isp.h"
7+
#include "tx_osd.h"
8+
#include "tx_sys.h"
9+
#include "tx_venc.h"
10+
11+
extern char keepRunning;

0 commit comments

Comments
 (0)