Skip to content

Commit

Permalink
Preparing to add support for hisi-gen2
Browse files Browse the repository at this point in the history
  • Loading branch information
wberube committed Jul 14, 2024
1 parent 7039206 commit c0d364c
Show file tree
Hide file tree
Showing 21 changed files with 3,062 additions and 23 deletions.
44 changes: 24 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,34 +19,38 @@ In spite of these design choices, Divinus boasts numerous features that cater to
| SoC Family | Audio Stream | JPEG Snapshot | fMP4 Stream | RTSP Stream | On-Screen Display* |
|-------------------------|:------------:|:-------------:|:-----------:|:-----------:|:------------------:|
| GM813x || ✔️ | ✔️ | ✔️ ||
| Hi3516CV300[^1] | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
| Hi3516CV500[^2] | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
| Hi3516EV200[^3] | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
| GK7205V200[^4] | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
| Hi3519V100[^5] | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
| Hi3516AV100[^1] ||||||
| Hi3516CV200[^2] ||||||
| Hi3516CV300[^3] | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
| Hi3516CV500[^4] | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
| Hi3516EV200[^5] | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
| GK7205V200[^6] | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
| Hi3519V100[^7] | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
| Hi3519AV100 | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
| Hi3559AV100 | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
| T31 series | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
| infinity6[^6] | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
| infinity6b0[^7] | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
| infinity6e[^8] | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
| infinity6c[^9] | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
| infinity6f[^10] | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
| infinity6[^8] | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
| infinity6b0[^9] | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
| infinity6e[^10] | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
| infinity6c[^11] | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
| infinity6f[^12] | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |

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

_* At the moment, only text, 24-bit and 32-bit RGB overlays are handled, matricial formats and covers are to follow_

[^1]: Hi3516CV300 and Hi3516EV100
[^2]: Hi3516AV300, Hi3516CV500 and Hi3516DV300
[^3]: Hi3516DV200, Hi3516EV200/300 and Hi3518EV300
[^4]: GK7202V300, GK7205V200/300 and GK7605V100
[^5]: Hi3516AV200 and Hi3519V101
[^6]: SSC323, SSC325(D/DE) and SSC327(D/DE/Q)
[^7]: SSC333/35/37(DE)
[^8]: SSC30K\[D/Q\], SSC336\[D/Q\], SSC338\[D/G/Q\] and SSC339G
[^9]: SSC377(D/DE/QE) or SSC378\[DE/QE\]
[^10]: SSC379G
[^1]: Hi3516AV100 and Hi3516DV100
[^2]: Hi3516CV200 and Hi3518EV20\[0/1\]
[^3]: Hi3516CV300 and Hi3516EV100
[^4]: Hi3516AV300, Hi3516CV500 and Hi3516DV300
[^5]: Hi3516DV200, Hi3516EV200/300 and Hi3518EV300
[^6]: GK7202V300, GK7205V200/300 and GK7605V100
[^7]: Hi3516AV200 and Hi3519V101
[^8]: SSC323, SSC325(D/DE) and SSC327(D/DE/Q)
[^9]: SSC333/35/37(DE)
[^10]: SSC30K\[D/Q\], SSC336\[D/Q\], SSC338\[D/G/Q\] and SSC339G
[^11]: SSC377(D/DE/QE) or SSC378\[DE/QE\]
[^12]: SSC379G


### Documentation
Expand Down
108 changes: 108 additions & 0 deletions src/hal/hisi/v2_aud.h
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));
}
118 changes: 118 additions & 0 deletions src/hal/hisi/v2_common.h
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;
Loading

0 comments on commit c0d364c

Please sign in to comment.