sdk-hwV1.3/external/eyesee-mpp/dragonboard/apps/DragonBoard/testcase/isetester/isetester.c

466 lines
12 KiB
C
Raw Normal View History

2024-05-07 10:09:20 +00:00
// ise_bi.c : ˫Ŀ<CBAB><C4BF><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>̬<EFBFBD><CCAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD>˫Ŀ<CBAB><C4BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// Ϊ<>ӿں<D3BF><DABA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӿ<EFBFBD><D3BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ķ<EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// <20>Ľ<EFBFBD><C4BD>ڲ<EFBFBD><DAB2><EFBFBD><EFBFBD>ķ<EFBFBD>װ<EFBFBD><D7B0><EFBFBD><EFBFBD>NBBuffer/LUT_ROIP_Buffer
// LUTBuffer/ROIPBuffer<65><72><EFBFBD>ݷ<EFBFBD>װ<EFBFBD><D7B0>handle<6C>ڲ<EFBFBD><DAB2><EFBFBD>ʵ<EFBFBD>ֲ<EFBFBD>ͬʵ<CDAC><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݸ<EFBFBD><DDB8><EFBFBD>
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <string.h>
#include <errno.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include "ISE_lib_bi.h"
#include "ISE_proc_bi.h"
#define TAG "lsetester"
#include <dragonboard/dragonboard.h>
#define FIFO_DEV "/tmp/fifo_ise"
#ifndef FALSE
#define FALSE 0
#endif
#ifndef TRUE
#define TRUE 1
#endif
#define TEST_TIMES 1 // <20><><EFBFBD>Դ<EFBFBD><D4B4><EFBFBD>
#define NUM_FRAM 1 // <20><><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define YUV_SOURCE_IMG "/usr/share/ISE/fisheye_asia_320.yuv420"
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD>h<EFBFBD><68>w<EFBFBD><77><EFBFBD><EFBFBD>Ϊ4<CEAA>ı<EFBFBD><C4B1><EFBFBD><EFBFBD><EFBFBD>strideΪ32<33><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ռ䰴32<33><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define TEST_SRC_HEIGHT 320
#define TEST_SRC_WIDTH 320
#define TEST_SRC_STRIDE 320 //luma&chroma <20><><EFBFBD><EFBFBD>stride<64><65><EFBFBD><EFBFBD>
// <20><><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD>w<EFBFBD><77><EFBFBD><EFBFBD>Ϊ8<CEAA>ı<EFBFBD><C4B1><EFBFBD><EFBFBD><EFBFBD>hΪ4<CEAA>ı<EFBFBD><C4B1><EFBFBD><EFBFBD><EFBFBD>strideΪ16<31><36>32<33><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ռ䰴16<31><36>32<33><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>planeģʽʱ<CABD><CAB1>CHROMA_STRIDE<44><45>Ҫ<EFBFBD><D2AA>2
#define TEST_PANO_HEIGHT 320
#define TEST_PANO_WIDTH 640
#define TEST_PANO_LUMA_STRIDE 640
#define TEST_PANO_CHROMA_STRIDE 640
#define TEST_PANO_FLIP FALSE
#define TEST_PANO_MIRROR FALSE
#define TEST_SCALAR_EN_CHN0 FALSE
#define TEST_SCALAR_HEIGHT0 160
#define TEST_SCALAR_WIDTH0 320
#define TEST_SCALAR_LUMA_STRIDE0 320
#define TEST_SCALAR_CHROMA_STRIDE0 320
#define TEST_SCALAR_FLIP0 FALSE
#define TEST_SCALAR_MIRROR0 FALSE
// chn1
#define TEST_SCALAR_EN_CHN1 FALSE
#define TEST_SCALAR_HEIGHT1 80
#define TEST_SCALAR_WIDTH1 160
#define TEST_SCALAR_LUMA_STRIDE1 160
#define TEST_SCALAR_CHROMA_STRIDE1 160
#define TEST_SCALAR_FLIP1 FALSE
#define TEST_SCALAR_MIRROR1 TRUE
// chn2
#define TEST_SCALAR_EN_CHN2 FALSE
#define TEST_SCALAR_HEIGHT2 40
#define TEST_SCALAR_WIDTH2 80
#define TEST_SCALAR_LUMA_STRIDE2 80
#define TEST_SCALAR_CHROMA_STRIDE2 80
#define TEST_SCALAR_FLIP2 FALSE
#define TEST_SCALAR_MIRROR2 FALSE
#define TEST_IN_YUV_TYPE YUV420
#define TEST_PANO_YUV_TYPE YUV420
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define TEST_P0 (TEST_SRC_HEIGHT/3.1415)
#define TEST_CX0 (TEST_SRC_WIDTH/2)
#define TEST_CY0 (TEST_SRC_HEIGHT/2)
#define TEST_P1 (TEST_SRC_HEIGHT/3.1415)
#define TEST_CX1 (TEST_SRC_WIDTH/2)
#define TEST_CY1 (TEST_SRC_HEIGHT/2)
int main( )
{
/**********************variable************************/
ISE_HANDLE_BI *handle0 = NULL;
FILE* fp_src;
char filename[128];
int i, j;
int malloc_ret = 0;
ISE_CFG_PARA_BI ise_cfg;
ISE_PROCIN_PARA_BI ise_procin;
ISE_PROCOUT_PARA_BI ise_procout;
unsigned int block_size, n_readsize;
unsigned int hresult = -1;
/* Դ<><D4B4><EFBFBD>ݴ<EFBFBD><DDB4>Žṹ<C5BD><E1B9B9> */
static myAddr Y_Src_Buffer[2];
static myAddr C_Src_Buffer[2];
/* Ӳ<><D3B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݴ<EFBFBD><DDB4>Žṹ<C5BD><E1B9B9> */
static myAddr Y_Dst_Buffer_HW[4];
static myAddr U_Dst_Buffer_HW[4];
int frm_num;
/**************variable init*******************/
// cfg para init
ise_cfg.in_h = TEST_SRC_HEIGHT;
ise_cfg.in_w = TEST_SRC_WIDTH;
ise_cfg.out_h[0] = TEST_PANO_HEIGHT;
ise_cfg.out_w[0] = TEST_PANO_WIDTH;
ise_cfg.p0 = TEST_P0;
ise_cfg.cx0 = TEST_CX0;
ise_cfg.cy0 = TEST_CY0;
ise_cfg.p1 = TEST_P1;
ise_cfg.cx1 = TEST_CX1;
ise_cfg.cy1 = TEST_CY1;
ise_cfg.in_yuv_type = TEST_IN_YUV_TYPE;
ise_cfg.out_flip[0] = TEST_PANO_FLIP;
ise_cfg.out_mirror[0] = TEST_PANO_MIRROR;
ise_cfg.out_yuv_type = TEST_PANO_YUV_TYPE;
ise_cfg.in_luma_pitch =TEST_SRC_STRIDE ;
ise_cfg.in_chroma_pitch = TEST_SRC_STRIDE;
ise_cfg.out_luma_pitch[0] = TEST_PANO_LUMA_STRIDE;
ise_cfg.out_chroma_pitch[0] = TEST_PANO_CHROMA_STRIDE;
//chn0
ise_cfg.out_en[1+0] = TEST_SCALAR_EN_CHN0;
if(ise_cfg.out_en[1+0])
{
printf("chn0 enable! \n");
ise_cfg.out_h[1+0] = TEST_SCALAR_HEIGHT0;
ise_cfg.out_w[1+0] = TEST_SCALAR_WIDTH0;
ise_cfg.out_flip[1+0] = TEST_SCALAR_FLIP0;
ise_cfg.out_mirror[1+0] = TEST_SCALAR_MIRROR0;
ise_cfg.out_luma_pitch[1+0] = TEST_SCALAR_LUMA_STRIDE0;
ise_cfg.out_chroma_pitch[1+0] = TEST_SCALAR_CHROMA_STRIDE0;
}
//chn1
ise_cfg.out_en[1+1] = TEST_SCALAR_EN_CHN1;
if(ise_cfg.out_en[1+1])
{
printf("chn1 enable! \n");
ise_cfg.out_h[1+1] = TEST_SCALAR_HEIGHT1;
ise_cfg.out_w[1+1] = TEST_SCALAR_WIDTH1;
ise_cfg.out_flip[1+1]=TEST_SCALAR_FLIP1;
ise_cfg.out_mirror[1+1]=TEST_SCALAR_MIRROR1;
ise_cfg.out_luma_pitch[1+1] = TEST_SCALAR_LUMA_STRIDE1;
ise_cfg.out_chroma_pitch[1+1]=TEST_SCALAR_CHROMA_STRIDE1;
}
//chn2
ise_cfg.out_en[1+2] = TEST_SCALAR_EN_CHN2;
if(ise_cfg.out_en[1+2])
{
printf("chn2 enable! \n");
ise_cfg.out_h[1+2] = TEST_SCALAR_HEIGHT2;
ise_cfg.out_w[1+2] = TEST_SCALAR_WIDTH2;
ise_cfg.out_flip[1+2] = TEST_SCALAR_FLIP2;
ise_cfg.out_mirror[1+2] = TEST_SCALAR_MIRROR2;
ise_cfg.out_luma_pitch[1+2] = TEST_SCALAR_LUMA_STRIDE2;
ise_cfg.out_chroma_pitch[1+2] = TEST_SCALAR_CHROMA_STRIDE2;
}
system("rmmod /lib/modules/4.4.55/sunxi_ise.ko");
usleep(1000);
system("insmod /lib/modules/4.4.55/sunxi_ise.ko");
int fifoFd = 0;
// this part works well since then, so no need to notify server if open fifo failed
// if we want to notify server, use other ipc tools, such as message, shared memory
#if 1
if ((fifoFd = open(FIFO_DEV, O_WRONLY)) < 0) { // fifo's write-endian block until read-endian open
if (mkfifo(FIFO_DEV, 0666) < 0) {
db_error("mkfifo failed(%s)\n", strerror(errno));
return -1;
} else {
fifoFd = open(FIFO_DEV, O_WRONLY);
}
}
#endif
/*****************input&output mem alloc*****************/
unsigned int test_time = 0;
while(test_time < TEST_TIMES)
{
handle0 = ISE_Create_Bi(&ise_cfg);
if (NULL == handle0)
{
printf("Create ISE fail\n");
goto termi;
}
// initial LUT and write register
hresult = ISE_SetAttr_Bi(handle0);
if (0 != hresult)
{
printf("Set ISE fail\n");
goto termi;
}
/**********************<2A><>ȡfion,Ϊ<><CEAA><EFBFBD>ٿռ<D9BF>ʹ<EFBFBD><CAB9>**********************/
int fion = -1;
ISE_Context_BI *ise_ctx = (ISE_Context_BI*)handle0;
fion = ise_ctx->fion;
/**********************<2A><>ȡfion,Ϊ<><CEAA><EFBFBD>ٿռ<D9BF>ʹ<EFBFBD><CAB9>**********************/
// src memory malloc
for (i = 0; i < 2; i++)
{
block_size = ise_cfg.in_luma_pitch * ise_cfg.in_h * sizeof(unsigned char);
malloc_ret = myMalloc(fion, Y_Src_Buffer+i, block_size);
if (malloc_ret == -1)
{
printf("malloc Y_Src_Buffer fail\n");
goto termi;
}
myMemSet(fion, Y_Src_Buffer + i, 0);
ise_procin.in_luma[i] = &(Y_Src_Buffer[i]);
block_size = ise_cfg.in_chroma_pitch * ise_cfg.in_h * sizeof(unsigned char) / 2;
if (ise_cfg.in_yuv_type == YUV422)
{
block_size *= 2;
}
malloc_ret = myMalloc(fion, C_Src_Buffer + i, block_size);
if (malloc_ret == -1)
{
printf("malloc C_Src_Buffer fail\n");
goto termi;
}
myMemSet(fion, C_Src_Buffer + i, 0);
ise_procin.in_chroma[i] = &(C_Src_Buffer[i]);
}
// pano out memory malloc
block_size = ise_cfg.out_h[0] * ise_cfg.out_luma_pitch[0] * sizeof(unsigned char);
malloc_ret = myMalloc(fion, Y_Dst_Buffer_HW, block_size);
if (malloc_ret == -1)
{
printf("malloc Y_Dst_Buffer_HW fail\n");
goto termi;
}
myMemSet(fion, Y_Dst_Buffer_HW, 0);
ise_procout.out_luma[0] = &(Y_Dst_Buffer_HW[0]);
block_size = ise_cfg.out_h[0] * ise_cfg.out_chroma_pitch[0] * sizeof(unsigned char) / 2;
if (ise_cfg.in_yuv_type == YUV422)
block_size *= 2;
malloc_ret = myMalloc(fion, U_Dst_Buffer_HW, block_size);
if (malloc_ret == -1)
{
printf("malloc U_Dst_Buffer_HW fail\n");
goto termi;
}
myMemSet(fion, U_Dst_Buffer_HW, 0);
ise_procout.out_chroma_u[0] = &(U_Dst_Buffer_HW[0]);
// scale chanel memory malloc
for (j = 0; j < MAX_SCALAR_CHNL; j++)
{
if(ise_cfg.out_en[1+j])
{
ise_procout.out_luma[1+j] = NULL;
ise_procout.out_chroma_u[1+j] = NULL;
ise_procout.out_chroma_v[1+j] = NULL;
block_size = ise_cfg.out_h[1+j] * ise_cfg.out_luma_pitch[1+j] * sizeof(unsigned char);
malloc_ret = myMalloc(fion, Y_Dst_Buffer_HW+(j+1), block_size);
if (malloc_ret == -1)
{
printf("malloc Y_Dst_Buffer_HW[%d] fail! \r\n",j);
goto termi;
}
myMemSet(fion, Y_Dst_Buffer_HW+(j+1), 0);
ise_procout.out_luma[1+j] = &(Y_Dst_Buffer_HW[j+1]);
block_size = ise_cfg.out_h[1+j] * ise_cfg.out_chroma_pitch[1+j] * sizeof(unsigned char) / 2;
if (ise_cfg.in_yuv_type == YUV422)
{
block_size *= 2;
}
malloc_ret = myMalloc(fion, U_Dst_Buffer_HW+(j+1), block_size);
if (malloc_ret == -1)
{
printf("malloc U_Dst_Buffer_HW[%d] fail! \r\n", j);
goto termi;
}
myMemSet(fion, U_Dst_Buffer_HW+(j+1), 0);
ise_procout.out_chroma_u[1+j] = &(U_Dst_Buffer_HW[j+1]);
}
}
// <20><>ȡSRC<52>ļ<EFBFBD>
for (i = 0; i < 2; i++)
{
switch(i)
{
case 0:
if (ise_cfg.in_yuv_type == YUV420)
{
//sprintf(filename, "fisheye_asia_320.yuv420");
sprintf(filename, YUV_SOURCE_IMG);
}
else
{
goto termi;
}
fp_src = fopen(filename, "rb");
break;
case 1:
if (ise_cfg.in_yuv_type == YUV420)
{
//sprintf(filename, "fisheye_asia_320.yuv420");
sprintf(filename,YUV_SOURCE_IMG);
}
else
{
goto termi;
}
fp_src = fopen(filename, "rb");
break;
default:
fp_src= NULL;
break;
}
if(!fp_src)
{
printf("Src file does not exist\n");
goto termi;
}
block_size = ise_cfg.in_luma_pitch * ise_cfg.in_h * sizeof(unsigned char);
n_readsize = fread(ise_procin.in_luma[i]->mmu_Addr, 1, block_size, fp_src);
if (n_readsize != block_size)
{
printf("read yuv file fail\n");
fclose(fp_src);
fp_src = NULL;
goto termi;
}
block_size = ise_cfg.in_chroma_pitch * ise_cfg.in_h * sizeof(unsigned char) / 2;
n_readsize = fread(ise_procin.in_chroma[i]->mmu_Addr, 1, block_size, fp_src);
if (n_readsize != block_size)
{
printf("read yuv file fail\n");
fclose(fp_src);
fp_src = NULL;
goto termi;
}
fclose(fp_src);
fp_src = NULL;
}
// ѭ<><D1AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>TEST_NIMG<4D><47>
frm_num = 0;
while(frm_num < NUM_FRAM)
{
ISE_Proc_Bi(handle0, &ise_procin, &ise_procout);
hresult = ISE_CheckResult_Bi(handle0, &ise_procout);
printf("frm_num:%d!\n", frm_num);
frm_num++;
}
#if 1
for(i = 0;i < 3; i++)
{
if(0 == hresult)
{
printf("ISE Process success!\n");
write(fifoFd, "P[ISE] OK", 50);
}
else
{
printf("ISE Process fail!\n");
write(fifoFd, "F[ISE] fail", 50);
}
sleep(1);
}
#endif
//close(fifoFd);
termi:
ISE_Destroy_Bi(handle0);
printf("%s %s(Line %d)\n\r",__FILE__,__FUNCTION__,__LINE__);
//free SRC
for (i = 0; i < 2; i++)
{
if (NULL != ise_procin.in_luma[i])
{
myFree(fion, ise_procin.in_luma[i]);
}
if (NULL != ise_procin.in_chroma[i])
{
myFree(fion, ise_procin.in_chroma[i]);
}
}
// free DST
if (NULL != ise_procout.out_luma[0])
{
myFree(fion, ise_procout.out_luma[0]);
}
if (NULL != ise_procout.out_chroma_u[0])
{
myFree(fion, ise_procout.out_chroma_u[0]);
}
if (NULL != ise_procout.out_chroma_v[0])
{
myFree(fion, ise_procout.out_chroma_v[0]);
}
// free SCA
for (i = 0; i < MAX_SCALAR_CHNL; i++)
{
if(ise_cfg.out_en[1+i])
{
if(NULL != ise_procout.out_luma[1+i])
{
myFree(fion, ise_procout.out_luma[1+i]);
}
if(NULL != ise_procout.out_chroma_u[1+i])
{
myFree(fion, ise_procout.out_chroma_u[1+i]);
}
if(NULL != ise_procout.out_chroma_v[1+i])
{
myFree(fion, ise_procout.out_chroma_v[1+i]);
}
}
}
printf("------------->test_time:%d<-------------\n", test_time);
test_time++;
}
return 0;
}