-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding the new Rockchip platform headers, and one from CVITEK
- Loading branch information
Showing
10 changed files
with
2,028 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,128 @@ | ||
#pragma once | ||
|
||
#include "rk_common.h" | ||
|
||
#define RK_AUD_CHN_NUM 2 | ||
|
||
typedef enum { | ||
RK_AUD_BIT_8, | ||
RK_AUD_BIT_16, | ||
RK_AUD_BIT_24, | ||
RK_AUD_BIT_32, | ||
RK_AUD_BIT_FLOAT, | ||
RK_AUD_BIT_END | ||
} rk_aud_bit; | ||
|
||
typedef enum { | ||
RK_AUD_MODE_MONO, | ||
RK_AUD_MODE_STEREO, | ||
RK_AUD_MODE_4CH, | ||
RK_AUD_MODE_6CH, | ||
RK_AUD_MODE_8CH, | ||
RK_AUD_MODE_END | ||
} rk_aud_mode; | ||
|
||
typedef struct { | ||
unsigned int cardChnNum, cardRate; | ||
rk_aud_bit cardBit; | ||
// Accept industry standards from | ||
// 8000 to 96000Hz, plus 64000Hz | ||
unsigned int rate; | ||
rk_aud_bit bit; | ||
rk_aud_mode mode; | ||
// 8-to-16 bit, expand mode | ||
unsigned int expandOn; | ||
unsigned int frmNum; | ||
unsigned int packNumPerFrm; | ||
unsigned int chnNum; | ||
// If not setted, will use the device index | ||
// to open the audio card | ||
char cardName[8]; | ||
} rk_aud_cnf; | ||
|
||
typedef struct { | ||
void *mbBlk; | ||
rk_aud_bit bit; | ||
rk_aud_mode mode; | ||
unsigned long long timestamp; | ||
unsigned int sequence; | ||
unsigned int length; | ||
int bypassMbOn; | ||
} rk_aud_frm; | ||
|
||
typedef struct { | ||
rk_aud_frm frame; | ||
char isValid; | ||
char isSysBound; | ||
} rk_aud_efrm; | ||
|
||
typedef struct { | ||
void *handle; | ||
|
||
int (*fnDisableDevice)(int device); | ||
int (*fnEnableDevice)(int device); | ||
int (*fnSetDeviceConfig)(int device, rk_aud_cnf *config); | ||
|
||
int (*fnDisableChannel)(int device, int channel); | ||
int (*fnEnableChannel)(int device, int channel); | ||
|
||
int (*fnFreeFrame)(int device, int channel, rk_aud_frm *frame, rk_aud_efrm *encFrame); | ||
int (*fnGetFrame)(int device, int channel, rk_aud_frm *frame, rk_aud_efrm *encFrame, int millis); | ||
} rk_aud_impl; | ||
|
||
static int rk_aud_load(rk_aud_impl *aud_lib) { | ||
if (!(aud_lib->handle = dlopen("librockit.so", RTLD_LAZY | RTLD_GLOBAL))) { | ||
fprintf(stderr, "[rk_aud] Failed to load library!\nError: %s\n", dlerror()); | ||
return EXIT_FAILURE; | ||
} | ||
|
||
if (!(aud_lib->fnDisableDevice = (int(*)(int device)) | ||
dlsym(aud_lib->handle, "RK_MPI_AI_Disable"))) { | ||
fprintf(stderr, "[rk_aud] Failed to acquire symbol RK_MPI_AI_Disable!\n"); | ||
return EXIT_FAILURE; | ||
} | ||
|
||
if (!(aud_lib->fnEnableDevice = (int(*)(int device)) | ||
dlsym(aud_lib->handle, "RK_MPI_AI_Enable"))) { | ||
fprintf(stderr, "[rk_aud] Failed to acquire symbol RK_MPI_AI_Enable!\n"); | ||
return EXIT_FAILURE; | ||
} | ||
|
||
if (!(aud_lib->fnSetDeviceConfig = (int(*)(int device, rk_aud_cnf *config)) | ||
dlsym(aud_lib->handle, "RK_MPI_AI_SetPubAttr"))) { | ||
fprintf(stderr, "[rk_aud] Failed to acquire symbol RK_MPI_AI_SetPubAttr!\n"); | ||
return EXIT_FAILURE; | ||
} | ||
|
||
if (!(aud_lib->fnDisableChannel = (int(*)(int device, int channel)) | ||
dlsym(aud_lib->handle, "RK_MPI_AI_DisableChn"))) { | ||
fprintf(stderr, "[rk_aud] Failed to acquire symbol RK_MPI_AI_DisableChn!\n"); | ||
return EXIT_FAILURE; | ||
} | ||
|
||
if (!(aud_lib->fnEnableChannel = (int(*)(int device, int channel)) | ||
dlsym(aud_lib->handle, "RK_MPI_AI_EnableChn"))) { | ||
fprintf(stderr, "[rk_aud] Failed to acquire symbol RK_MPI_AI_EnableChn!\n"); | ||
return EXIT_FAILURE; | ||
} | ||
|
||
if (!(aud_lib->fnFreeFrame = (int(*)(int device, int channel, rk_aud_frm *frame, rk_aud_efrm *encFrame)) | ||
dlsym(aud_lib->handle, "RK_MPI_AI_ReleaseFrame"))) { | ||
fprintf(stderr, "[rk_aud] Failed to acquire symbol RK_MPI_AI_ReleaseFrame!\n"); | ||
return EXIT_FAILURE; | ||
} | ||
|
||
if (!(aud_lib->fnGetFrame = (int(*)(int device, int channel, rk_aud_frm *frame, rk_aud_efrm *encFrame, int millis)) | ||
dlsym(aud_lib->handle, "RK_MPI_AI_GetFrame"))) { | ||
fprintf(stderr, "[rk_aud] Failed to acquire symbol RK_MPI_AI_GetFrame!\n"); | ||
return EXIT_FAILURE; | ||
} | ||
|
||
return EXIT_SUCCESS; | ||
} | ||
|
||
static void rk_aud_unload(rk_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,158 @@ | ||
#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 { | ||
RK_BAYER_RG, | ||
RK_BAYER_GR, | ||
RK_BAYER_GB, | ||
RK_BAYER_BG, | ||
RK_BAYER_END | ||
} rk_common_bayer; | ||
|
||
typedef enum { | ||
RK_COMPR_NONE, | ||
RK_COMPR_AFBC_16x16, | ||
RK_COMPR_END | ||
} rk_common_compr; | ||
|
||
typedef enum { | ||
RK_HDR_SDR8, | ||
RK_HDR_SDR10, | ||
RK_HDR_HDR10, | ||
RK_HDR_HLG, | ||
RK_HDR_SLF, | ||
RK_HDR_XDR, | ||
RK_HDR_END | ||
} rk_common_hdr; | ||
|
||
typedef enum { | ||
RK_PIXFMT_YUV420SP, RK_PIXFMT_YUV = RK_PIXFMT_YUV420SP, | ||
RK_PIXFMT_YUV420SP_10BIT, | ||
RK_PIXFMT_YUV422SP, | ||
RK_PIXFMT_YUV422SP_10BIT, | ||
RK_PIXFMT_YUV420P, | ||
RK_PIXFMT_YUV420P_VU, | ||
RK_PIXFMT_YUV420SP_VU, | ||
RK_PIXFMT_YUV422P, | ||
RK_PIXFMT_YUV422SP_VU, | ||
RK_PIXFMT_YUV422_YUYV, | ||
RK_PIXFMT_YUV422_UYVY, | ||
RK_PIXFMT_YUV400SP, | ||
RK_PIXFMT_YUV440SP, | ||
RK_PIXFMT_YUV411SP, | ||
RK_PIXFMT_YUV444, | ||
RK_PIXFMT_YUV444SP, | ||
RK_PIXFMT_YUV444P, | ||
RK_PIXFMT_YUV422_YVYU, | ||
RK_PIXFMT_YUV422_VYUY, | ||
RK_PIXFMT_YUV_END, | ||
RK_PIXFMT_RGB565, RK_PIXFMT_RGB = RK_PIXFMT_RGB565, | ||
RK_PIXFMT_BGR565, | ||
RK_PIXFMT_RGB555, | ||
RK_PIXFMT_BGR555, | ||
RK_PIXFMT_RGB444, | ||
RK_PIXFMT_BGR444, | ||
RK_PIXFMT_RGB888, | ||
RK_PIXFMT_BGR888, | ||
RK_PIXFMT_RGB101010, | ||
RK_PIXFMT_BGR101010, | ||
RK_PIXFMT_ARGB1555, | ||
RK_PIXFMT_ABGR1555, | ||
RK_PIXFMT_ARGB4444, | ||
RK_PIXFMT_ABGR4444, | ||
RK_PIXFMT_ARGB8565, | ||
RK_PIXFMT_ABGR8565, | ||
RK_PIXFMT_ARGB8888, | ||
RK_PIXFMT_ABGR8888, | ||
RK_PIXFMT_BGRA8888, | ||
RK_PIXFMT_RGBA8888, | ||
RK_PIXFMT_RGBA5551, | ||
RK_PIXFMT_BGRA5551, | ||
RK_PIXFMT_BGRA4444, | ||
RK_PIXFMT_RGBA4444, | ||
RK_PIXFMT_XBGR8888, | ||
RK_PIXFMT_RGB_END, | ||
RK_PIXFMT_2BPP, | ||
RK_PIXFMT_BAYER_SBGGR_8BPP, RK_PIXFMT_BAYER = RK_PIXFMT_BAYER_SBGGR_8BPP, | ||
RK_PIXFMT_BAYER_SGBRG_8BPP, | ||
RK_PIXFMT_BAYER_SGRBG_8BPP, | ||
RK_PIXFMT_BAYER_SRGGB_8BPP, | ||
RK_PIXFMT_BAYER_SBGGR_10BPP, | ||
RK_PIXFMT_BAYER_SGBRG_10BPP, | ||
RK_PIXFMT_BAYER_SGRBG_10BPP, | ||
RK_PIXFMT_BAYER_SRGGB_10BPP, | ||
RK_PIXFMT_BAYER_SBGGR_12BPP, | ||
RK_PIXFMT_BAYER_SGBRG_12BPP, | ||
RK_PIXFMT_BAYER_SGRBG_12BPP, | ||
RK_PIXFMT_BAYER_SRGGB_12BPP, | ||
RK_PIXFMT_BAYER_14BPP, | ||
RK_PIXFMT_BAYER_SBGGR_16BPP, | ||
RK_PIXFMT_BAYER_END, | ||
RK_PIXFMT_END, | ||
} rk_common_pixfmt; | ||
|
||
typedef enum { | ||
RK_PREC_8BPP, | ||
RK_PREC_10BPP, | ||
RK_PREC_12BPP, | ||
RK_PREC_14BPP, | ||
RK_PREC_16BPP, | ||
RK_PREC_END | ||
} rk_common_prec; | ||
|
||
typedef enum { | ||
RK_VIDFMT_LINEAR, | ||
RK_VIDFMT_TILE_64X16, | ||
RK_VIDFMT_TILE_16X8, | ||
RK_VIDFMT_LINEAR_DISCRETE, | ||
RK_VIDFMT_END | ||
} rk_common_vidfmt; | ||
|
||
typedef enum { | ||
RK_WDR_NONE, | ||
RK_WDR_BUILTIN, | ||
RK_WDR_QUDRA, | ||
RK_WDR_2TO1_LINE, | ||
RK_WDR_2TO1_FRAME, | ||
RK_WDR_2TO1_FRAME_FULLRATE, | ||
RK_WDR_3TO1_LINE, | ||
RK_WDR_3TO1_FRAME, | ||
RK_WDR_3TO1_FRAME_FULLRATE, | ||
RK_WDR_4TO1_LINE, | ||
RK_WDR_4TO1_FRAME, | ||
RK_WDR_4TO1_FRAME_FULLRATE, | ||
RK_WDR_END | ||
} rk_common_wdr; | ||
|
||
typedef struct { | ||
unsigned int topWidth; | ||
unsigned int bottomWidth; | ||
unsigned int leftWidth; | ||
unsigned int rightWidth; | ||
unsigned int color; | ||
} rk_common_bord; | ||
|
||
typedef struct { | ||
unsigned int width; | ||
unsigned int height; | ||
} rk_common_dim; | ||
|
||
typedef struct { | ||
int x; | ||
int y; | ||
} rk_common_pnt; | ||
|
||
typedef struct { | ||
int x; | ||
int y; | ||
unsigned int width; | ||
unsigned int height; | ||
} rk_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,59 @@ | ||
#pragma once | ||
|
||
#include "rk_common.h" | ||
#include "rk_aud.h" | ||
#include "rk_mb.h" | ||
#include "rk_rgn.h" | ||
#include "rk_sys.h" | ||
#include "rk_venc.h" | ||
#include "rk_vi.h" | ||
#include "rk_vpss.h" | ||
|
||
#include <fcntl.h> | ||
#include <pthread.h> | ||
#include <sys/ioctl.h> | ||
#include <unistd.h> | ||
|
||
extern char keepRunning; | ||
|
||
extern hal_chnstate rk_state[RK_VENC_CHN_NUM]; | ||
extern int (*rk_aud_cb)(hal_audframe*); | ||
extern int (*rk_vid_cb)(char, hal_vidstream*); | ||
|
||
void rk_hal_deinit(void); | ||
int rk_hal_init(void); | ||
void *rk_audio_thread(void); | ||
|
||
void rk_audio_deinit(void); | ||
int rk_audio_init(int samplerate); | ||
|
||
int rk_channel_bind(char index); | ||
int rk_channel_create(char index, char mirror, char flip, char framerate); | ||
int rk_channel_grayscale(char enable); | ||
int rk_channel_unbind(char index); | ||
|
||
void *rk_image_thread(void); | ||
|
||
int rk_pipeline_create(void); | ||
void rk_pipeline_destroy(void); | ||
|
||
int rk_region_create(char handle, hal_rect rect, short opacity); | ||
void rk_region_destroy(char handle); | ||
int rk_region_setbitmap(int handle, hal_bitmap *bitmap); | ||
|
||
void rk_sensor_deconfig(void); | ||
int rk_sensor_config(void); | ||
void rk_sensor_deinit(void); | ||
int rk_sensor_init(char *name, char *obj); | ||
|
||
int rk_video_create(char index, hal_vidconfig *config); | ||
int rk_video_destroy(char index); | ||
int rk_video_destroy_all(void); | ||
void rk_video_request_idr(char index); | ||
int rk_video_snapshot_grab(char index, hal_jpegdata *jpeg); | ||
void *rk_video_thread(void); | ||
|
||
int rk_system_calculate_block(short width, short height, rk_common_pixfmt pixFmt, | ||
unsigned int alignWidth); | ||
void rk_system_deinit(void); | ||
int rk_system_init(char *snrConfig); |
Oops, something went wrong.