diff --git a/src/hal/plus/ak_common.h b/src/hal/plus/ak_common.h index 13c0efc..7e72917 100644 --- a/src/hal/plus/ak_common.h +++ b/src/hal/plus/ak_common.h @@ -7,4 +7,5 @@ #include "../symbols.h" #include "../types.h" -#define CVI_VI_CHN_NUM 2 \ No newline at end of file +#define AK_VENC_CHN_NUM 2 +#define AK_VI_CHN_NUM 2 \ No newline at end of file diff --git a/src/hal/plus/ak_hal.h b/src/hal/plus/ak_hal.h new file mode 100644 index 0000000..f006eb4 --- /dev/null +++ b/src/hal/plus/ak_hal.h @@ -0,0 +1,42 @@ +#pragma once + +#include "ak_common.h" +#include "ak_aud.h" +#include "ak_venc.h" +#include "ak_vi.h" + +extern char keepRunning; + +extern hal_chnstate ak_state[AK_VENC_CHN_NUM]; +extern int (*ak_aud_cb)(hal_audframe*); +extern int (*ak_vid_cb)(char, hal_vidstream*); + +void ak_hal_deinit(void); +int ak_hal_init(void); + +void ak_audio_deinit(void); +int ak_audio_init(int samplerate); +void *ak_audio_thread(void); + +int ak_channel_bind(char index); +int ak_channel_grayscale(char enable); +int ak_channel_unbind(char index); + +int ak_config_load(char *path); + +int ak_pipeline_create(char mirror, char flip); +void ak_pipeline_destroy(void); + +int ak_region_create(int *handle, hal_rect rect, short opacity); +void ak_region_destroy(int *handle); +int ak_region_setbitmap(int *handle, hal_bitmap *bitmap); + +int ak_video_create(char index, hal_vidconfig *config); +int ak_video_destroy(char index); +int ak_video_destroy_all(void); +void ak_video_request_idr(char index); +int ak_video_snapshot_grab(char index, hal_jpegdata *jpeg); +void *ak_video_thread(void); + +void ak_system_deinit(void); +int ak_system_init(void); \ No newline at end of file diff --git a/src/hal/plus/ak_vi.h b/src/hal/plus/ak_vi.h index 1e98b84..23e9a2c 100644 --- a/src/hal/plus/ak_vi.h +++ b/src/hal/plus/ak_vi.h @@ -24,22 +24,27 @@ typedef struct { typedef struct { void *handle; + int (*fnGetSensorResolution)(void *device, ak_vi_res *resolution); int (*fnLoadSensorConfig)(char *path); int (*fnDisableDevice)(void *device); void* (*fnEnableDevice)(int device); - int (*fnGetDeviceConfig)(void *device, ak_vi_cnf *config); + int (*fnStartDevice)(void *device); + int (*fnStopDevice)(void *device); + int (*fnSetDeviceConfig)(void *device, ak_vi_cnf *config); int (*fnSetDeviceFlipMirror)(void *device, int flipOn, int mirrorOn); int (*fnSetDeviceMode)(void *device, int nightOn); - int (*fnStartDevice)(void *device); - int (*fnStopDevice)(void *device); } ak_vi_impl; static int ak_vi_load(ak_vi_impl *vi_lib) { if (!(vi_lib->handle = dlopen("libplat_vi.so", RTLD_LAZY | RTLD_GLOBAL))) HAL_ERROR("ak_vi", "Failed to load library!\nError: %s\n", dlerror()); + if (!(vi_lib->fnGetSensorResolution = (int(*)(void* device, ak_vi_res *resolution)) + hal_symbol_load("ak_vi", vi_lib->handle, "ak_vi_get_channel_attr"))) + return EXIT_FAILURE; + if (!(vi_lib->fnLoadSensorConfig = (int(*)(char *path)) hal_symbol_load("ak_vi", vi_lib->handle, "ak_vi_match_sensor"))) return EXIT_FAILURE; @@ -52,8 +57,12 @@ static int ak_vi_load(ak_vi_impl *vi_lib) { hal_symbol_load("ak_vi", vi_lib->handle, "ak_vi_open"))) return EXIT_FAILURE; - if (!(vi_lib->fnGetDeviceConfig = (int(*)(void* device, ak_vi_cnf *config)) - hal_symbol_load("ak_vi", vi_lib->handle, "ak_vi_get_channel_attr"))) + if (!(vi_lib->fnStartDevice = (int(*)(void *device)) + hal_symbol_load("ak_vi", vi_lib->handle, "ak_vi_capture_on"))) + return EXIT_FAILURE; + + if (!(vi_lib->fnStopDevice = (int(*)(void *device)) + hal_symbol_load("ak_vi", vi_lib->handle, "ak_vi_capture_off"))) return EXIT_FAILURE; if (!(vi_lib->fnSetDeviceConfig = (int(*)(void* device, ak_vi_cnf *config)) @@ -68,14 +77,6 @@ static int ak_vi_load(ak_vi_impl *vi_lib) { hal_symbol_load("ak_vi", vi_lib->handle, "ak_vi_switch_mode"))) return EXIT_FAILURE; - if (!(vi_lib->fnStartDevice = (int(*)(void *device)) - hal_symbol_load("ak_vi", vi_lib->handle, "ak_vi_capture_on"))) - return EXIT_FAILURE; - - if (!(vi_lib->fnStopDevice = (int(*)(void *device)) - hal_symbol_load("ak_vi", vi_lib->handle, "ak_vi_capture_off"))) - return EXIT_FAILURE; - return EXIT_SUCCESS; }