Skip to content

Commit 3e06846

Browse files
committed
Preparing for hisi gen3 support
1 parent d8a09f2 commit 3e06846

File tree

15 files changed

+2326
-22
lines changed

15 files changed

+2326
-22
lines changed

src/error.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ char *errstr(int error) {
2828
case I6_SYS_MOD_AO:
2929
error |= (V4_SYS_MOD_AO << 16); break;
3030
case I6_SYS_MOD_LDC:
31-
error |= (V4_SYS_MOD_FISHEYE << 16); break;
31+
error |= (V4_SYS_MOD_GDC << 16); break;
3232
case I6_SYS_MOD_CIPHER:
3333
error |= (0x4D << 16); break;
3434
case I6_SYS_MOD_IVE:
@@ -58,7 +58,7 @@ char *errstr(int error) {
5858
case I6C_SYS_MOD_AO:
5959
error |= (V4_SYS_MOD_AO << 16); break;
6060
case I6C_SYS_MOD_LDC:
61-
error |= (V4_SYS_MOD_FISHEYE << 16); break;
61+
error |= (V4_SYS_MOD_GDC << 16); break;
6262
case I6C_SYS_MOD_CIPHER:
6363
error |= (0x4D << 16); break;
6464
case I6C_SYS_MOD_IVE:
@@ -88,7 +88,7 @@ char *errstr(int error) {
8888
case I6F_SYS_MOD_AO:
8989
error |= (V4_SYS_MOD_AO << 16); break;
9090
case I6F_SYS_MOD_LDC:
91-
error |= (V4_SYS_MOD_FISHEYE << 16); break;
91+
error |= (V4_SYS_MOD_GDC << 16); break;
9292
case I6F_SYS_MOD_CIPHER:
9393
error |= (0x4D << 16); break;
9494
case I6F_SYS_MOD_IVE:

src/hal/hisi/v3_aud.h

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
#pragma once
2+
3+
#include "v3_common.h"
4+
5+
#define V3_AUD_CHN_NUM 2
6+
7+
typedef enum {
8+
V3_AUD_BIT_8,
9+
V3_AUD_BIT_16,
10+
V3_AUD_BIT_24
11+
} v3_aud_bit;
12+
13+
typedef enum {
14+
V3_AUD_INTF_I2S_MASTER,
15+
V3_AUD_INTF_I2S_SLAVE,
16+
V3_AUD_INTF_PCM_SLAVE_STD,
17+
V3_AUD_INTF_PCM_SLAVE_NSTD,
18+
V3_AUD_INTF_PCM_MASTER_STD,
19+
V3_AUD_INTF_PCM_MASTER_NSTD,
20+
V3_AUD_INTF_END
21+
} v3_aud_intf;
22+
23+
typedef struct {
24+
// Accept industry standards from
25+
// 8000 to 96000Hz, plus 64000Hz
26+
int rate;
27+
v3_aud_bit bit;
28+
v3_aud_intf intf;
29+
int stereoOn;
30+
// 8-to-16 bit, expand mode
31+
int expandOn;
32+
unsigned int frmNum;
33+
unsigned int packNumPerFrm;
34+
unsigned int chnNum;
35+
unsigned int syncRxClkOn;
36+
} v3_aud_cnf;
37+
38+
typedef struct {
39+
v3_aud_bit bit;
40+
int stereoOn;
41+
void *addr[2];
42+
unsigned int phy[2];
43+
unsigned long long timestamp;
44+
unsigned int sequence;
45+
unsigned int length;
46+
unsigned int poolId[2];
47+
} v3_aud_frm;
48+
49+
typedef struct {
50+
v3_aud_frm frame;
51+
char isValid;
52+
char isSysBound;
53+
} v3_aud_efrm;
54+
55+
typedef struct {
56+
void *handle, *handleGoke;
57+
58+
int (*fnDisableDevice)(int device);
59+
int (*fnEnableDevice)(int device);
60+
int (*fnSetDeviceConfig)(int device, v3_aud_cnf *config);
61+
62+
int (*fnDisableChannel)(int device, int channel);
63+
int (*fnEnableChannel)(int device, int channel);
64+
65+
int (*fnFreeFrame)(int device, int channel, v3_aud_frm *frame, v3_aud_efrm *encFrame);
66+
int (*fnGetFrame)(int device, int channel, v3_aud_frm *frame, v3_aud_efrm *encFrame, int millis);
67+
} v3_aud_impl;
68+
69+
static int v3_aud_load(v3_aud_impl *aud_lib) {
70+
if (!(aud_lib->handle = dlopen("libmpi.so", RTLD_LAZY | RTLD_GLOBAL))) {
71+
fprintf(stderr, "[v3_aud] Failed to load library!\nError: %s\n", dlerror());
72+
return EXIT_FAILURE;
73+
}
74+
75+
if (!(aud_lib->fnDisableDevice = (int(*)(int device))
76+
dlsym(aud_lib->handle, "HI_MPI_AI_Disable"))) {
77+
fprintf(stderr, "[v3_aud] Failed to acquire symbol HI_MPI_AI_Disable!\n");
78+
return EXIT_FAILURE;
79+
}
80+
81+
if (!(aud_lib->fnEnableDevice = (int(*)(int device))
82+
dlsym(aud_lib->handle, "HI_MPI_AI_Enable"))) {
83+
fprintf(stderr, "[v3_aud] Failed to acquire symbol HI_MPI_AI_Enable!\n");
84+
return EXIT_FAILURE;
85+
}
86+
87+
if (!(aud_lib->fnSetDeviceConfig = (int(*)(int device, v3_aud_cnf *config))
88+
dlsym(aud_lib->handle, "HI_MPI_AI_SetPubAttr"))) {
89+
fprintf(stderr, "[v3_aud] Failed to acquire symbol HI_MPI_AI_SetPubAttr!\n");
90+
return EXIT_FAILURE;
91+
}
92+
93+
if (!(aud_lib->fnDisableChannel = (int(*)(int device, int channel))
94+
dlsym(aud_lib->handle, "HI_MPI_AI_DisableChn"))) {
95+
fprintf(stderr, "[v3_aud] Failed to acquire symbol HI_MPI_AI_DisableChn!\n");
96+
return EXIT_FAILURE;
97+
}
98+
99+
if (!(aud_lib->fnEnableChannel = (int(*)(int device, int channel))
100+
dlsym(aud_lib->handle, "HI_MPI_AI_EnableChn"))) {
101+
fprintf(stderr, "[v3_aud] Failed to acquire symbol HI_MPI_AI_EnableChn!\n");
102+
return EXIT_FAILURE;
103+
}
104+
105+
if (!(aud_lib->fnFreeFrame = (int(*)(int device, int channel, v3_aud_frm *frame, v3_aud_efrm *encFrame))
106+
dlsym(aud_lib->handle, "HI_MPI_AI_ReleaseFrame"))) {
107+
fprintf(stderr, "[v3_aud] Failed to acquire symbol HI_MPI_AI_ReleaseFrame!\n");
108+
return EXIT_FAILURE;
109+
}
110+
111+
if (!(aud_lib->fnGetFrame = (int(*)(int device, int channel, v3_aud_frm *frame, v3_aud_efrm *encFrame, int millis))
112+
dlsym(aud_lib->handle, "HI_MPI_AI_GetFrame"))) {
113+
fprintf(stderr, "[v3_aud] Failed to acquire symbol HI_MPI_AI_GetFrame!\n");
114+
return EXIT_FAILURE;
115+
}
116+
117+
return EXIT_SUCCESS;
118+
}
119+
120+
static void v3_aud_unload(v3_aud_impl *aud_lib) {
121+
if (aud_lib->handle) dlclose(aud_lib->handle);
122+
aud_lib->handle = NULL;
123+
if (aud_lib->handleGoke) dlclose(aud_lib->handleGoke);
124+
aud_lib->handleGoke = NULL;
125+
memset(aud_lib, 0, sizeof(*aud_lib));
126+
}

src/hal/hisi/v3_common.h

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
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 V3_ERROR(x, ...) \
12+
do { \
13+
fprintf(stderr, "[v3_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+
V3_BAYER_RG,
21+
V3_BAYER_GR,
22+
V3_BAYER_GB,
23+
V3_BAYER_BG,
24+
V3_BAYER_END
25+
} v3_common_bayer;
26+
27+
typedef enum {
28+
V3_COMPR_NONE,
29+
V3_COMPR_SEG,
30+
V3_COMPR_SEG128,
31+
V3_COMPR_LINE,
32+
V3_COMPR_FRAME,
33+
V3_COMPR_END
34+
} v3_common_compr;
35+
36+
typedef enum {
37+
V3_PIXFMT_1BPP,
38+
V3_PIXFMT_2BPP,
39+
V3_PIXFMT_4BPP,
40+
V3_PIXFMT_8BPP,
41+
V3_PIXFMT_RGB444,
42+
V3_PIXFMT_ARGB4444,
43+
V3_PIXFMT_RGB555,
44+
V3_PIXFMT_RGB565,
45+
V3_PIXFMT_ARGB1555,
46+
V3_PIXFMT_RGB888,
47+
V3_PIXFMT_ARGB8888,
48+
V3_PIXFMT_RGB888P,
49+
V3_PIXFMT_RGB_BAYER_8BPP,
50+
V3_PIXFMT_RGB_BAYER_10BPP,
51+
V3_PIXFMT_RGB_BAYER_12BPP,
52+
V3_PIXFMT_RGB_BAYER_14BPP,
53+
V3_PIXFMT_RGB_BAYER_16BPP,
54+
V3_PIXFMT_YUV_A422,
55+
V3_PIXFMT_YUV_A444,
56+
V3_PIXFMT_YUV422P,
57+
V3_PIXFMT_YUV420P,
58+
V3_PIXFMT_YUV444P,
59+
V3_PIXFMT_YUV422SP,
60+
V3_PIXFMT_YUV420SP,
61+
V3_PIXFMT_YUV444SP,
62+
V3_PIXFMT_YUV422_UYVY,
63+
V3_PIXFMT_YUV422_YUYV,
64+
V3_PIXFMT_YUV422_VYUY,
65+
V3_PIXFMT_YCbCrP,
66+
V3_PIXFMT_YUV400,
67+
V3_PIXFMT_END
68+
} v3_common_pixfmt;
69+
70+
typedef enum {
71+
V3_PREC_8BPP,
72+
V3_PREC_10BPP,
73+
V3_PREC_12BPP,
74+
V3_PREC_14BPP,
75+
V3_PREC_16BPP,
76+
V3_PREC_END
77+
} v3_common_prec;
78+
79+
typedef enum {
80+
V3_VIDFMT_LINEAR,
81+
V3_VIDFMT_TILE_256X16,
82+
V3_VIDFMT_TILE_64X16,
83+
V3_VIDFMT_END
84+
} v3_common_vidfmt;
85+
86+
typedef enum {
87+
V3_WDR_NONE,
88+
V3_WDR_BUILTIN,
89+
V3_WDR_QUDRA,
90+
V3_WDR_2TO1_LINE,
91+
V3_WDR_2TO1_FRAME,
92+
V3_WDR_2TO1_FRAME_FULLRATE,
93+
V3_WDR_3TO1_LINE,
94+
V3_WDR_3TO1_FRAME,
95+
V3_WDR_3TO1_FRAME_FULLRATE,
96+
V3_WDR_4TO1_LINE,
97+
V3_WDR_4TO1_FRAME,
98+
V3_WDR_4TO1_FRAME_FULLRATE,
99+
V3_WDR_END
100+
} v3_common_wdr;
101+
102+
typedef struct {
103+
unsigned int topWidth;
104+
unsigned int bottomWidth;
105+
unsigned int leftWidth;
106+
unsigned int rightWidth;
107+
unsigned int color;
108+
} v3_common_bord;
109+
110+
typedef struct {
111+
unsigned int width;
112+
unsigned int height;
113+
} v3_common_dim;
114+
115+
typedef struct {
116+
int x;
117+
int y;
118+
} v3_common_pnt;
119+
120+
typedef struct {
121+
int x;
122+
int y;
123+
unsigned int width;
124+
unsigned int height;
125+
} v3_common_rect;

0 commit comments

Comments
 (0)