301 lines
6.0 KiB
C
Executable File
301 lines
6.0 KiB
C
Executable File
#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 "common.h"
|
|
#include "xconfig.h"
|
|
#include "thpool.h"
|
|
#include "npu_com.h"
|
|
|
|
|
|
#define SOKOL_IMPL
|
|
#include "sokol_args.h"
|
|
|
|
/*======================================================================================================*/
|
|
bool g_bRunning = false;
|
|
static const char* SETTINGS_FILE = "ipon_nn.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();
|
|
IPO_LOG_PRT("exit Done!\n");
|
|
return;
|
|
}
|
|
|
|
static int __system_init()
|
|
{
|
|
int result = 0;
|
|
srand(time(NULL));
|
|
VB_CONF_S stVbConf;
|
|
int i = 0;
|
|
FH_UINT32 u32BlkSize = 0;
|
|
|
|
memset(&stVbConf, 0, sizeof(VB_CONF_S));
|
|
|
|
u32BlkSize = 4096 * 2160 * 2 + 4096;
|
|
stVbConf.astCommPool[i].u32BlkSize = u32BlkSize;
|
|
stVbConf.astCommPool[i].u32BlkCnt = 20;
|
|
++i;
|
|
|
|
u32BlkSize = 4096 * 2160 * 3 + 4096;
|
|
stVbConf.astCommPool[i].u32BlkSize = u32BlkSize;
|
|
stVbConf.astCommPool[i].u32BlkCnt = 5;
|
|
++i;
|
|
|
|
u32BlkSize = 720 * 576 * 2 + 4096;
|
|
stVbConf.astCommPool[i].u32BlkSize = u32BlkSize;
|
|
stVbConf.astCommPool[i].u32BlkCnt = 12;
|
|
++i;
|
|
|
|
stVbConf.u32MaxPoolCnt = i;
|
|
|
|
result = __COMM_SYS_Init(&stVbConf);
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
static void __maybe_unused bind_vpss_vou(int vpu_chn, int vou_chn)
|
|
{
|
|
FH_BIND_INFO SrcChn, DestChn;
|
|
|
|
SrcChn.obj_id = FH_OBJ_VPU_VO;
|
|
SrcChn.dev_id = 0;
|
|
SrcChn.chn_id = vpu_chn;
|
|
DestChn.obj_id = FH_OBJ_VOU;
|
|
DestChn.dev_id = 0;
|
|
DestChn.chn_id = vou_chn;
|
|
|
|
FH_SYS_Bind(SrcChn, DestChn);
|
|
|
|
}
|
|
|
|
static void __maybe_unused bind_vpss_jpege(int vpu_chn, int jpeg_chn)
|
|
{
|
|
FH_BIND_INFO SrcChn, DestChn;
|
|
|
|
SrcChn.obj_id = FH_OBJ_VPU_VO;
|
|
SrcChn.dev_id = 0;
|
|
SrcChn.chn_id = vpu_chn;
|
|
DestChn.obj_id = FH_OBJ_JPEG;
|
|
DestChn.dev_id = 0;
|
|
DestChn.chn_id = jpeg_chn;
|
|
|
|
FH_SYS_Bind(SrcChn, DestChn);
|
|
|
|
}
|
|
|
|
|
|
static void __maybe_unused bind_isp_vpss(int vpu_chn, int vou_chn)
|
|
{
|
|
FH_BIND_INFO SrcChn, DestChn;
|
|
|
|
SrcChn.obj_id = FH_OBJ_ISP;
|
|
SrcChn.dev_id = 0;
|
|
SrcChn.chn_id = vpu_chn;
|
|
DestChn.obj_id = FH_OBJ_VPU_VI;
|
|
DestChn.dev_id = 0;
|
|
DestChn.chn_id = vou_chn;
|
|
|
|
FH_SYS_Bind(SrcChn, DestChn);
|
|
|
|
}
|
|
|
|
void intHandler(int dummy)
|
|
{
|
|
g_bRunning = false;
|
|
}
|
|
|
|
void isp_demo_common_run(int *cancel);
|
|
|
|
int main(int argc, char* argv[])
|
|
{
|
|
int ret = 0;
|
|
FH_UINT64 pts;
|
|
const char *config = NULL;
|
|
const char *cmd = NULL;
|
|
int test_case = 0;
|
|
int has_isp = 0;
|
|
char prex[64];
|
|
|
|
signal(SIGINT, intHandler);
|
|
|
|
sargs_setup(&(sargs_desc) {
|
|
.argc = argc,
|
|
.argv = argv
|
|
});
|
|
|
|
config = sargs_value("config");
|
|
cmd = sargs_value("cmd");
|
|
if (NULL == cmd) {
|
|
printf("The command must be specified!\n");
|
|
goto exit1;
|
|
|
|
}
|
|
if (0 == strlen(config)) {
|
|
config = SETTINGS_FILE;
|
|
}
|
|
|
|
ret = config_init(config);
|
|
if (ret < 0) {
|
|
printf("config file load failed!\n");
|
|
ret = -1;
|
|
goto exit1;
|
|
}
|
|
test_case = config_get_int("testcase", "", 0);
|
|
sprintf(prex, "test_cases[%d]", test_case);
|
|
printf("run test case [%d] .... \n", test_case);
|
|
|
|
thpool = thpool_init(4);
|
|
|
|
__system_init();
|
|
|
|
FH_SYS_GetCurPts(&pts);
|
|
srand((unsigned int)pts);
|
|
|
|
//start isp
|
|
has_isp = config_has_key(prex, NULL, "isp");
|
|
printf("has isp = 0x%x\n", has_isp);
|
|
|
|
|
|
g_bRunning = true;
|
|
|
|
static int isp_cancel = 0;
|
|
if (has_isp) {
|
|
isp_demo_common_run(&isp_cancel);
|
|
|
|
}
|
|
|
|
vpu_test_init();
|
|
//vo_test_init(FH_TRUE, VO_OUTPUT_640x480_60);
|
|
//vo_test_startlayer(0, VO_MODE_1MUX);
|
|
|
|
|
|
vpu_test_case(test_case);
|
|
//vpu_test_case_format();
|
|
npu_test_init();
|
|
|
|
printf("\n binding .... \n");
|
|
if (has_isp) {
|
|
bind_isp_vpss(0, 0);
|
|
}
|
|
bind_vpss_jpege(0, 0);
|
|
|
|
//tick the isp to run
|
|
const char *scmd = config_get_string(prex, "isp.cmd", NULL);
|
|
if (cmd) {
|
|
system(scmd);
|
|
}
|
|
|
|
if (!has_isp) {
|
|
thpool_add_work(thpool, vpu_send_offline_pic, "test_cases[0].vpu");
|
|
}
|
|
//thpool_add_work(thpool, vpu_test_channels, NULL);
|
|
sample_npu_test_start();
|
|
jpege_test(test_case);
|
|
|
|
while (g_bRunning) {
|
|
sleep(1);
|
|
}
|
|
|
|
//wait all thread exit
|
|
thpool_wait(thpool);
|
|
thpool_destroy(thpool);
|
|
|
|
if (has_isp) {
|
|
//sample_common_isp_stop(1);
|
|
}
|
|
|
|
sample_npu_test_stop();
|
|
vpu_test_exit();
|
|
//vo_test_exit(FH_TRUE);
|
|
|
|
exit1:
|
|
|
|
__COMM_SYS_Exit();
|
|
|
|
config_cleanup();
|
|
// shutdown sokol-args
|
|
sargs_shutdown();
|
|
return ret;
|
|
}
|
|
|