291 lines
6.9 KiB
C
Executable File
291 lines
6.9 KiB
C
Executable File
#define LOG_TAG "SLT"
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <stdbool.h>
|
|
#include <sys/types.h>
|
|
#include <sys/stat.h>
|
|
#include <sys/ioctl.h>
|
|
#include <sys/poll.h>
|
|
#include <sys/time.h>
|
|
#include <fcntl.h>
|
|
#include <errno.h>
|
|
#include <pthread.h>
|
|
#include <math.h>
|
|
#include <unistd.h>
|
|
#include <signal.h>
|
|
#include <sys/time.h>
|
|
#include <time.h>
|
|
#include <dirent.h>
|
|
#include <limits.h>
|
|
#include <getopt.h>
|
|
|
|
#include "fh_common.h"
|
|
#include "fh_system_mpi.h"
|
|
#include "fh_vb_mpi.h"
|
|
#include "fh_defines.h"
|
|
#include "vmm_api.h"
|
|
#include "fh_vo_mpi.h"
|
|
#include "types/bufCtrl.h"
|
|
|
|
#include "slt_common.h"
|
|
#include "xconfig.h"
|
|
#include "thpool.h"
|
|
|
|
#define SOKOL_IMPL
|
|
#include "sokol_args.h"
|
|
|
|
/*======================================================================================================*/
|
|
bool g_bRunning = false;
|
|
int g_bTestMode = 0;
|
|
static const char* SETTINGS_FILE = "slt.lua" ;
|
|
static threadpool thpool = NULL;
|
|
|
|
static FH_SINT32 __COMM_SYS_Init(VB_CONF_S *pstVbConf)
|
|
{
|
|
FH_SINT32 s32Ret = FH_FAILURE;
|
|
FH_SINT32 i;
|
|
|
|
FH_SYS_Exit();
|
|
|
|
for (i = 0; i < VB_MAX_USER; i++) {
|
|
FH_VB_ExitModCommPool(i);
|
|
}
|
|
for (i = 0; i < VB_MAX_POOLS; i++) {
|
|
FH_VB_DestroyPool(i);
|
|
}
|
|
FH_VB_Exit();
|
|
|
|
if (NULL == pstVbConf) {
|
|
printf("input parameter is null, it is invaild!\n");
|
|
return FH_FAILURE;
|
|
}
|
|
|
|
s32Ret = FH_VB_SetConf(pstVbConf);
|
|
if (FH_SUCCESS != s32Ret) {
|
|
printf("FH_VB_SetConf failed!\n");
|
|
return FH_FAILURE;
|
|
}
|
|
|
|
s32Ret = FH_VB_Init();
|
|
if (FH_SUCCESS != s32Ret) {
|
|
printf("FH_VB_Init failed!\n");
|
|
return FH_FAILURE;
|
|
}
|
|
|
|
s32Ret = FH_SYS_Init();
|
|
if (FH_SUCCESS != s32Ret) {
|
|
printf("FH_SYS_Init failed!\n");
|
|
return FH_FAILURE;
|
|
}
|
|
|
|
return FH_SUCCESS;
|
|
}
|
|
|
|
static FH_VOID __COMM_SYS_Exit(void)
|
|
{
|
|
|
|
FH_SINT32 i;
|
|
|
|
FH_SYS_Exit();
|
|
for (i = 0; i < VB_MAX_USER; i++) {
|
|
FH_VB_ExitModCommPool(i);
|
|
}
|
|
for (i = 0; i < VB_MAX_POOLS; i++) {
|
|
FH_VB_DestroyPool(i);
|
|
}
|
|
FH_VB_Exit();
|
|
log_d("exit Done!\n");
|
|
return;
|
|
}
|
|
|
|
static int __system_init()
|
|
{
|
|
int result = 0;
|
|
srand(time(NULL));
|
|
VB_CONF_S stVbConf;
|
|
int i = 0;
|
|
|
|
memset(&stVbConf, 0, sizeof(VB_CONF_S));
|
|
|
|
int cnt = config_count("slt.vbconf");
|
|
if(cnt <= 0) {
|
|
log_e("invalid vbconf\n");
|
|
return -1;
|
|
}
|
|
char prefix[16];
|
|
for(i = 0; i < cnt; i++) {
|
|
sprintf(prefix, "slt.vbconf[%d]", i + 1);
|
|
|
|
stVbConf.astCommPool[i].u32BlkSize = config_get_int(prefix, "size", 0);
|
|
if(stVbConf.astCommPool[i].u32BlkSize <= 0) {
|
|
log_e("invalid vbconf size\n");
|
|
return -1;
|
|
}
|
|
stVbConf.astCommPool[i].u32BlkCnt = config_get_int(prefix, "count", 0);
|
|
if(stVbConf.astCommPool[i].u32BlkCnt <= 0) {
|
|
log_e("invalid vbconf count\n");
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
stVbConf.u32MaxPoolCnt = cnt;
|
|
|
|
result = __COMM_SYS_Init(&stVbConf);
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void intHandler(int dummy)
|
|
{
|
|
g_bRunning = false;
|
|
}
|
|
|
|
void isp_demo_common_run(int *cancel);
|
|
|
|
static void setup_logger()
|
|
{
|
|
setbuf(stdout, NULL);
|
|
/* initialize EasyLogger */
|
|
elog_init();
|
|
/* set EasyLogger log format */
|
|
elog_set_fmt(ELOG_LVL_ASSERT, ELOG_FMT_ALL);
|
|
elog_set_fmt(ELOG_LVL_ERROR, ELOG_FMT_TIME| ELOG_FMT_LVL | ELOG_FMT_TAG | ELOG_FMT_FUNC | ELOG_FMT_LINE );
|
|
elog_set_fmt(ELOG_LVL_WARN, ELOG_FMT_TIME| ELOG_FMT_LVL | ELOG_FMT_TAG | ELOG_FMT_FUNC | ELOG_FMT_LINE );
|
|
elog_set_fmt(ELOG_LVL_INFO, ELOG_FMT_TIME| ELOG_FMT_LVL | ELOG_FMT_TAG | ELOG_FMT_FUNC | ELOG_FMT_LINE );
|
|
elog_set_fmt(ELOG_LVL_DEBUG, ELOG_FMT_TIME| ELOG_FMT_LVL | ELOG_FMT_TAG | ELOG_FMT_FUNC | ELOG_FMT_LINE );
|
|
elog_set_fmt(ELOG_LVL_VERBOSE, ELOG_FMT_ALL & ~ELOG_FMT_DIR);
|
|
#ifdef ELOG_COLOR_ENABLE
|
|
elog_set_text_color_enabled(true);
|
|
#endif
|
|
|
|
int log_level = config_int("log_level", 4);
|
|
elog_set_filter_lvl(log_level);
|
|
/* start EasyLogger */
|
|
elog_start();
|
|
}
|
|
|
|
int main(int argc, char* argv[])
|
|
{
|
|
int ret = 0;
|
|
FH_UINT64 pts;
|
|
const char *config = NULL;
|
|
const char *cmd = NULL;
|
|
const char *mode = NULL;
|
|
|
|
signal(SIGINT, intHandler);
|
|
|
|
sargs_setup(&(sargs_desc) {
|
|
.argc = argc,
|
|
.argv = argv
|
|
});
|
|
|
|
cmd = sargs_value("--cmd");
|
|
if(0 == strlen(cmd)) {
|
|
log_e("invalid cmd: %s\n", cmd);
|
|
goto exit1;
|
|
}
|
|
|
|
config = sargs_value("--config");
|
|
if (0 == strlen(config)) {
|
|
config = SETTINGS_FILE;
|
|
}
|
|
ret = config_init(config);
|
|
if((ret < 0)) {
|
|
log_e("config file load failed!\n");
|
|
goto exit1;
|
|
}
|
|
|
|
|
|
//set system registers
|
|
FH_SYS_SetReg(0x10000188, 0x09); //6M
|
|
FH_SYS_SetReg(0x2d000094, 0x01); //配置极性
|
|
|
|
FH_SYS_SetReg(0x1020001C, 0x00);
|
|
FH_SYS_SetReg(0x10200020, 0x00);
|
|
FH_SYS_SetReg(0x2c100094, 0x20);
|
|
|
|
|
|
thpool = thpool_init(10);
|
|
//testmode:
|
|
config_debug(config_int("debug", 0));
|
|
g_bTestMode = config_int("mode", 0);
|
|
|
|
mode = sargs_value("--mode");
|
|
if(0 == strcmp("test", mode)){
|
|
g_bTestMode = 0;
|
|
} else if(strlen(mode) > 0) {
|
|
g_bTestMode = 1;
|
|
}
|
|
slt_common_init();
|
|
|
|
ret = __system_init();
|
|
if(ret < 0) {
|
|
log_e("system init failed!\n");
|
|
goto exit1;
|
|
}
|
|
|
|
|
|
FH_SYS_GetCurPts(&pts);
|
|
srand((unsigned int)pts);
|
|
//start logger
|
|
setup_logger();
|
|
|
|
g_bRunning = true;
|
|
|
|
if(0 == strcmp("playback", cmd)) {
|
|
thpool_add_work(thpool, slt_playback_test, NULL);
|
|
} else if(0 == strcmp("venc", cmd)) {
|
|
thpool_add_work(thpool, slt_venc_test, NULL);
|
|
} else if(0 == strcmp("g2d", cmd)) {
|
|
thpool_add_work(thpool, slt_g2d_test, NULL);
|
|
} else if(0 == strcmp("ioe", cmd)) {
|
|
thpool_add_work(thpool, slt_ioe_test, NULL);
|
|
} else if(0 == strcmp("jpeg", cmd)) {
|
|
thpool_add_work(thpool, slt_jpege_test, NULL);
|
|
} else if(0 == strcmp("npu", cmd)) {
|
|
thpool_add_work(thpool, slt_npu_test, NULL);
|
|
} else if(0 == strcmp("preview", cmd)) {
|
|
thpool_add_work(thpool, slt_preview_test, NULL);
|
|
} else if(0 == strcmp("vdsp", cmd)) {
|
|
thpool_add_work(thpool, slt_vdsp_test, NULL);
|
|
} else if(0 == strcmp("all", cmd)) {
|
|
thpool_add_work(thpool, slt_playback_test, NULL);
|
|
thpool_add_work(thpool, slt_venc_test, NULL);
|
|
thpool_add_work(thpool, slt_g2d_test, NULL);
|
|
thpool_add_work(thpool, slt_ioe_test, NULL);
|
|
thpool_add_work(thpool, slt_jpege_test, NULL);
|
|
thpool_add_work(thpool, slt_npu_test, NULL);
|
|
thpool_add_work(thpool, slt_preview_test, NULL);
|
|
thpool_add_work(thpool, slt_vdsp_test, NULL);
|
|
} else {
|
|
log_e("invalid cmd: %s\n", cmd);
|
|
goto exit1;
|
|
}
|
|
|
|
|
|
|
|
exit1:
|
|
if(thpool) {
|
|
log_d("waiting for all thread exit ... \n");
|
|
thpool_wait(thpool);
|
|
thpool_destroy(thpool);
|
|
}
|
|
|
|
__COMM_SYS_Exit();
|
|
|
|
|
|
config_cleanup();
|
|
slt_common_exit();
|
|
// shutdown sokol-args
|
|
sargs_shutdown();
|
|
//close log
|
|
elog_stop();
|
|
elog_deinit();
|
|
return ret;
|
|
}
|
|
|