Example #1
0
	/*2 run hifbTde*/
	printf("AVD_ProcessHiFbTde!\n");
	s32Ret = RunAVDHiFBTde(layer);
	if(s32Ret != HI_SUCCESS)
	{
		goto err;
	}

	err:
	DisableVoDev(HD);
	DisableVoDev(SD);
	MppSysExit();

	return 0;

}
#define PIC_IMAGE_WIDTH     800
#define PIC_IMAGE_HEIGHT    600
#define PIC_IMAGE_SIZE      (800*600*2)
#define PIC_IMAGE_NUM       14
#define PIC_IMAGE_PATH		"./res/%d.bits"
#define PIC_PEA_IMAGE_PATH1		"./res/pea1.bits"
#define PIC_PEA_IMAGE_PATH2		"./res/pea2.bits"
#define PIC_PEA_IMAGE_PATH3		"./res/pea3.bits"
#define PIC_PEA_IMAGE_PATH4		"./res/pea4.bits"
#define PIC_PEA_IMAGE_PATH5		"./res/pea5.bits"

//#define VIR_SCREEN_WIDTH	640					/*virtual screen width*/
//#define VIR_SCREEN_HEIGHT	IMAGE_HEIGHT*2		/*virtual screen height*/
#define PIC_VIR_SCREEN_WIDTH	800					/*virtual screen width*/
#define PIC_VIR_SCREEN_HEIGHT	PIC_IMAGE_HEIGHT*2		/*virtual screen height*/
#define NEW_PIC_IMAGE_WIDTH     79
#define NEW_PIC_IMAGE_HEIGHT    24
#define NEW_PIC_IMAGE_SIZE      (79*24*2)
#define NEW_PIC_IMAGE_NUM       14
#define NEW_PIC_IMAGE_PATH		"./res/%d.bits"
#define NEW_PIC_PEA_IMAGE_PATH1		"./res/pea1.bits"
#define NEW_PIC_PEA_IMAGE_PATH2		"./res/pea2.bits"
#define NEW_PIC_PEA_IMAGE_PATH3		"./res/pea3.bits"
#define NEW_PIC_PEA_IMAGE_PATH4		"./res/pea4.bits"

#define NEW_PIC_VIR_SCREEN_WIDTH	79					/*virtual screen width*/
#define NEW_PIC_VIR_SCREEN_HEIGHT	PIC_IMAGE_HEIGHT*2		/*virtual screen height*/
int AVD_RunHiFBTde_PIC(int layer)
{
    int fd;
    int i;
	int j;
    struct fb_fix_screeninfo fix;
    struct fb_var_screeninfo var;
    HIFB_CAPABILITY_S cap;
	HI_U32 u32FixScreenStride = 0;
    unsigned char *pShowScreen;
    unsigned char *pHideScreen;
	HIFB_ALPHA_S stAlpha;
    HIFB_POINT_S stPoint = {10, 10};
    FILE *fp;
    char file[12] = "/dev/fb1";
    char image_name[128];
	HI_CHAR *pDst = NULL;
    //int i = 0;
    HI_U32 u32PhyAddr;
    HI_U32 u32Size;
    HI_U32 u32CurOnShow = 0;
    HI_U32 u32NextOnShow = 1;
    /* 1. open tde device */
    HI_TDE2_Open();

    /* 1. open framebuffer device overlay 0 */
    //fd = open(file, O_RDWR, 0);
    /* 2. framebuffer operation */
    fd = open("/dev/fb1", O_RDWR);
    if(fd < 0)
    {
        printf("open %s failed!\n",file);
        return -1;
    }

    /* 2. set the screen original position */
    if (ioctl(fd, FBIOPUT_SCREEN_ORIGIN_HIFB, &stPoint) < 0)
    {
        printf("set screen original show position failed!\n");
        close(fd);
        return -1;
    }
#if 1
	SetTrasValueBydevPath(fd);
#else
	/* 3.set alpha */
	stAlpha.bAlphaEnable = HI_FALSE;
	stAlpha.bAlphaChannel = HI_FALSE;
	stAlpha.u8Alpha0 = 0xff;
	stAlpha.u8Alpha1 = 0x8f;
    stAlpha.u8GlobalAlpha = 0x80;

	if (ioctl(fd, FBIOPUT_ALPHA_HIFB,  &stAlpha) < 0)
	{
	    printf("Set alpha failed!\n");
        close(fd);
        return -1;
	}

#endif
    /* 4. get the variable screen info */
    if (ioctl(fd, FBIOGET_VSCREENINFO, &var) < 0)
    {
   	    printf("Get variable screen info failed!\n");
        close(fd);
        return -1;
    }

    /* 5. modify the variable screen info
          the screen size: IMAGE_WIDTH*IMAGE_HEIGHT
          the virtual screen size: VIR_SCREEN_WIDTH*VIR_SCREEN_HEIGHT
          (which equals to VIR_SCREEN_WIDTH*(IMAGE_HEIGHT*2))
          the pixel format: ARGB1555
    */

    var.xres_virtual = PIC_VIR_SCREEN_WIDTH;
	var.yres_virtual = PIC_VIR_SCREEN_HEIGHT;
	var.xres = PIC_IMAGE_WIDTH;
    var.yres = PIC_IMAGE_HEIGHT;

    var.transp= g_a16;
    var.red = g_r16;
    var.green = g_g16;
    var.blue = g_b16;
    var.bits_per_pixel = 16;
    var.activate = FB_ACTIVATE_FORCE;
    /* 6. set the variable screeninfo */
    if (ioctl(fd, FBIOPUT_VSCREENINFO, &var) < 0)
    {
   	    printf("Put variable screen info failed!\n");
        close(fd);
        return -1;
    }

    /* 7. get the fix screen info */
    if (ioctl(fd, FBIOGET_FSCREENINFO, &fix) < 0)
    {
   	    printf("Get fix screen info failed!\n");
        close(fd);
        return -1;
    }
	u32FixScreenStride = fix.line_length;	/*fix screen stride*/

    /* 8. map the physical video memory for user use */
    u32Size 	= fix.smem_len;
    u32PhyAddr  = fix.smem_start;
    pShowScreen = mmap(NULL, fix.smem_len, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
    if(MAP_FAILED == pShowScreen)
    {
   	    printf("mmap framebuffer failed!\n");
        close(fd);
        return -1;
    }

    pHideScreen = pShowScreen + u32FixScreenStride*PIC_IMAGE_HEIGHT;
    memset(pShowScreen, 0x0000, u32FixScreenStride*PIC_IMAGE_HEIGHT);

    /* 9. create surface */
    g_stScreen_pic[0].enColorFmt = PIXFMT;
    g_stScreen_pic[0].u32PhyAddr = u32PhyAddr;
    g_stScreen_pic[0].u32Width = PIC_VIR_SCREEN_WIDTH;
    g_stScreen_pic[0].u32Height = PIC_IMAGE_HEIGHT;
    g_stScreen_pic[0].u32Stride = fix.line_length;
    g_stScreen_pic[0].bAlphaMax255 = HI_TRUE;

  /*  g_stBackGround0 = g_stScreen_pic[0];
    g_stBackGround0.enColorFmt = PIXFMT;
    g_stBackGround0.u32PhyAddr = u32PhyAddr;
    g_stBackGround0.u32Width = NEW_PIC_VIR_SCREEN_WIDTH;
    g_stBackGround0.u32Height = NEW_PIC_IMAGE_HEIGHT;
    g_stBackGround0.u32Stride = NEW_PIC_VIR_SCREEN_WIDTH;
    g_stBackGround0.bAlphaMax255 = HI_TRUE;
    g_stBackGround0.u32PhyAddr = g_stScreen_pic[0].u32PhyAddr + g_stScreen_pic[0].u32Stride * g_stScreen_pic[0].u32Height;
    g_stBackGround1 = g_stBackGround0;
    g_stBackGround1.u32PhyAddr = g_stBackGround0.u32PhyAddr + g_stBackGround0.u32Stride * g_stBackGround0.u32Height;

    g_stBackGround2 = g_stBackGround1;
    g_stBackGround2.u32PhyAddr = g_stBackGround1.u32PhyAddr + g_stBackGround1.u32Stride * g_stBackGround1.u32Height;

    g_stBackGround3 = g_stBackGround2;
    g_stBackGround3.u32PhyAddr = g_stBackGround2.u32PhyAddr + g_stBackGround2.u32Stride * g_stBackGround2.u32Height;
*/
    g_stBackGround4 = g_stScreen_pic[0];
    g_stBackGround4.enColorFmt = PIXFMT;
    g_stBackGround4.u32PhyAddr = g_stScreen_pic[0].u32PhyAddr + g_stScreen_pic[0].u32Stride * g_stScreen_pic[0].u32Height;;
    g_stBackGround4.u32Width = 71;
    g_stBackGround4.u32Height = 167;
    g_stBackGround4.u32Stride = 71;
    g_stBackGround4.bAlphaMax255 = HI_TRUE;
   // g_stBackGround4.u32PhyAddr = g_stBackGround3.u32PhyAddr + g_stBackGround3.u32Stride * g_stBackGround3.u32Height;

    //g_stBackGround1 = g_stBackGround0;
    //g_stBackGround1.u32PhyAddr = g_stBackGround0.u32PhyAddr + g_stBackGround0.u32Stride * g_stBackGround0.u32Height;
  //  g_stBackGround1 = g_stScreen_pic[0];
  //  g_stBackGround2 = g_stScreen_pic[0];
  //  g_stBackGround3 = g_stScreen_pic[0];
    //g_stBackGround.u32PhyAddr = g_stScreen_pic[0].u32PhyAddr + g_stScreen_pic[0].u32Stride * g_stScreen_pic[0].u32Height;

    i = 0;
    while(1)
    {

        TDE_HANDLE s32Handle;
        TDE2_OPT_S stOpt = {0};
        HI_FLOAT eXMid, eYMid;
        HI_FLOAT eRadius;
        //HI_U32 i;
        HI_FLOAT f;
        HI_U32 u32NextOnShow;
        TDE2_RECT_S stSrcRect;
        TDE2_RECT_S stDstRect;
        HI_S32 s32Ret;
        HI_U32 u32FillData = 0x8010;

        /* 1. start job */
        s32Handle = HI_TDE2_BeginJob();
        if(HI_ERR_TDE_INVALID_HANDLE == s32Handle)
        {
        //    TDE_PRINT("start job failed!\n");
            printf("start job failed!\n");
            return ;
        }

        //memset(pShowScreen, 0x0000, u32FixScreenStride*IMAGE_HEIGHT);
        /*stDstRect.s32Xpos = 0;
        stDstRect.s32Ypos = 0;
        stDstRect.u32Width = PIC_VIR_SCREEN_WIDTH;
        stDstRect.u32Height = PIC_IMAGE_HEIGHT;*/
        i++;
        //if(i == 3)
         //   i = 0;

   /*     stDstRect.s32Xpos = 0;
        stDstRect.s32Ypos = 0;
        stDstRect.u32Width = g_stBackGround0.u32Width;
        stDstRect.u32Height = g_stBackGround0.u32Height;

        stSrcRect.s32Xpos = 0;
        stSrcRect.s32Ypos = 0;
        stSrcRect.u32Width = g_stBackGround0.u32Width;
        stSrcRect.u32Height = g_stBackGround0.u32Height;
        //stSrcRect.u32Width = g_stBackGround0.u32Width;*/
        //stSrcRect.u32Height = g_stBackGround0.u32Height;
        printf("i = %d\n",i);
 /*       if(i%5==0)
        {
            TDE_CreateSurfaceByFile(PIC_PEA_IMAGE_PATH1, &g_stBackGround0, pShowScreen + ((HI_U32)g_stBackGround0.u32PhyAddr - u32PhyAddr));
            HI_TDE2_QuickCopy(s32Handle, &g_stBackGround0, &stSrcRect, &g_stScreen_pic[0], &stDstRect);
        }
        else if(i%5==1)
        {
            TDE_CreateSurfaceByFile(PIC_PEA_IMAGE_PATH4, &g_stBackGround3, pShowScreen + ((HI_U32)g_stBackGround3.u32PhyAddr - u32PhyAddr));
            stDstRect.s32Xpos = (IMAGE_WIDTH>>1)+2;
            stDstRect.s32Ypos = (IMAGE_HEIGHT>>1)+2;
            stDstRect.u32Width = g_stBackGround3.u32Width;
            stDstRect.u32Height = g_stBackGround3.u32Height;

            s32Ret = HI_TDE2_QuickCopy(s32Handle, &g_stBackGround3, &stSrcRect, &g_stScreen_pic[0], &stDstRect);
            if(s32Ret < 0)
            {
                printf("Line:%d,HI_TDE2_QuickCopy failed,ret=0x%x!\n", __LINE__, s32Ret);
                return ;
            }
        }
        else if(i%5==2)
        {
            printf("TDE_CreateSurfaceByFile\n");
            TDE_CreateSurfaceByFile(PIC_PEA_IMAGE_PATH2, &g_stBackGround1, pShowScreen + ((HI_U32)g_stBackGround1.u32PhyAddr - u32PhyAddr));
            stSrcRect.s32Xpos = 0;
            stSrcRect.s32Ypos = 0;
            stSrcRect.u32Width = g_stBackGround1.u32Width;
            stSrcRect.u32Height = g_stBackGround1.u32Height;

            stDstRect.s32Xpos =(IMAGE_WIDTH>>1)+2;
            stDstRect.s32Ypos = 0;
            stDstRect.u32Width = g_stBackGround1.u32Width;
            stDstRect.u32Height = g_stBackGround1.u32Height;
            s32Ret = HI_TDE2_QuickCopy(s32Handle, &g_stBackGround1, &stSrcRect, &g_stScreen_pic[0], &stDstRect);
            if(s32Ret < 0)
            {
                printf("Line:%d,HI_TDE2_QuickCopy failed,ret=0x%x!\n", __LINE__, s32Ret);
                return ;
            }
        }
        else
        if(i%5==3)
         {
            TDE_CreateSurfaceByFile(PIC_PEA_IMAGE_PATH3, &g_stBackGround2, pShowScreen + ((HI_U32)g_stBackGround2.u32PhyAddr - u32PhyAddr));
            stDstRect.s32Xpos =0;
            stDstRect.s32Ypos = (IMAGE_HEIGHT>>1)+2;
            stDstRect.u32Width = g_stBackGround2.u32Width;
            stDstRect.u32Height = g_stBackGround2.u32Height;
            s32Ret = HI_TDE2_QuickCopy(s32Handle, &g_stBackGround2, &stSrcRect, &g_stScreen_pic[0], &stDstRect);
        }*/

        {
            TDE_CreateSurfaceByFile(PIC_PEA_IMAGE_PATH6, &g_stBackGround4, pShowScreen + ((HI_U32)g_stBackGround4.u32PhyAddr - u32PhyAddr));
            stSrcRect.s32Xpos = 0;
            stSrcRect.s32Ypos = 0;
            stSrcRect.u32Width = 79;
            stSrcRect.u32Height = g_stBackGround4.u32Height;
            stDstRect.s32Xpos = 2+20;
            stDstRect.s32Ypos = 35+3;
            stDstRect.u32Width = 79;
            stDstRect.u32Height = g_stBackGround4.u32Height;
            s32Ret = HI_TDE2_QuickCopy(s32Handle, &g_stBackGround4, &stSrcRect, &g_stScreen_pic[0], &stDstRect);
        }
        //printf("g_stBackGround1.u32Width:%d,g_stBackGround1.u32Height:%d\n",g_stBackGround1.u32Width,g_stBackGround1.u32Height);
/*

*/


   /*
*/
        /* 5. submit job */
        s32Ret = HI_TDE2_EndJob(s32Handle, HI_FALSE, HI_TRUE, 10);
        if(s32Ret < 0)
        {
          //  TDE_PRINT("Line:%d,HI_TDE2_EndJob failed,ret=0x%x!\n", __LINE__, s32Ret);
            HI_TDE2_CancelJob(s32Handle);
            return ;
        }
        printf("TDE2_PIC_EndJob5!\n");

        var.yoffset = 0;
        if (ioctl(fd, FBIOPAN_DISPLAY, &var) < 0)
        {
             //TDE_PRINT("process frame buffer device error\n");
             printf("process frame buffer device error\n");
             //goto FB_PROCESS_ERROR1;
        }
        usleep(2000000);
    }
     /* 2. bitblt background to screen */
   // HI_TDE2_QuickCopy(s32Handle, &g_stBackGround, &stSrcRect, &g_stScreen_pic[0], &stSrcRect);


    /* 10.unmap the physical memory */
    munmap(pShowScreen, fix.smem_len);

    /* 11. close the framebuffer device */
    close(fd);

    HI_TDE2_Close();
    return 0;
}
Example #2
0
IMP_S32 RunAVDHiFBTde(IMP_S32 layer)
{
    IMP_S32 fd;
    IMP_S32 i;
	IMP_S32 j;
    struct fb_fix_screeninfo fix;
    struct fb_var_screeninfo var;
    HIFB_CAPABILITY_S cap;
	HI_U32 u32FixScreenStride = 0;
    unsigned char *pShowScreen;
    unsigned char *pHideScreen;
	HIFB_ALPHA_S stAlpha;
    HIFB_POINT_S stPoIMP_S32 = {0, 0};
    FILE *fp;
    char file[12] = "/dev/fb0";
    char image_name[128];
	HI_CHAR *pDst = NULL;
    TDE2_OPT_S pstOpt;
    HI_U32 u32PhyAddr;
    HI_U32 u32Size;
    HI_U32 u32CurOnShow = 0;
    HI_U32 u32NextOnShow = 1;

    TDE2_RECT_S stSrcRect;
    TDE2_RECT_S stDstRect;
    HI_S32 s32Ret;
    /* 1. open tde device */
    HI_TDE2_Open();

    /* 1. open framebuffer device overlay 0 */
    //fd = open(file, O_RDWR, 0);
    /* 2. framebuffer operation */
    fd = open("/dev/fb0", O_RDWR);
    if(fd < 0)
    {
        printf("open %s failed!\n",file);
        return -1;
    }

    /* 2. set the screen original position */
    if (ioctl(fd, FBIOPUT_SCREEN_ORIGIN_HIFB, &stPoIMP_S32) < 0)
    {
        printf("set screen original show position failed!\n");
        close(fd);
        return -1;
    }
#if 1
	SetTrasValueBydevPath(fd);
#else
	/* 3.set alpha */
	stAlpha.bAlphaEnable = HI_FALSE;
	stAlpha.bAlphaChannel = HI_FALSE;
	stAlpha.u8Alpha0 = 0xff;
	stAlpha.u8Alpha1 = 0x8f;
    stAlpha.u8GlobalAlpha = 0x80;

	if (ioctl(fd, FBIOPUT_ALPHA_HIFB,  &stAlpha) < 0)
	{
	    printf("Set alpha failed!\n");
        close(fd);
        return -1;
	}

#endif
    /* 4. get the variable screen info */
    if (ioctl(fd, FBIOGET_VSCREENINFO, &var) < 0)
    {
   	    printf("Get variable screen info failed!\n");
        close(fd);
        return -1;
    }

    /* 5. modify the variable screen info
          the screen size: IMAGE_WIDTH*IMAGE_HEIGHT
          the virtual screen size: VIR_SCREEN_WIDTH*VIR_SCREEN_HEIGHT
          (which equals to VIR_SCREEN_WIDTH*(IMAGE_HEIGHT*2))
          the pixel format: ARGB1555
    */

    var.xres_virtual = AVD_VIR_SCREEN_WIDTH;
	var.yres_virtual = AVD_VIR_SCREEN_HEIGHT;
	var.xres = AVD_IMAGE_WIDTH;
    var.yres = AVD_IMAGE_HEIGHT;

    var.transp= g_a16;
    var.red = g_r16;
    var.green = g_g16;
    var.blue = g_b16;
    var.bits_per_pixel = 16;
    var.activate = FB_ACTIVATE_FORCE;
    /* 6. set the variable screeninfo */
    if (ioctl(fd, FBIOPUT_VSCREENINFO, &var) < 0)
    {
   	    printf("Put variable screen info failed!\n");
        close(fd);
        return -1;
    }

    /* 7. get the fix screen info */
    if (ioctl(fd, FBIOGET_FSCREENINFO, &fix) < 0)
    {
   	    printf("Get fix screen info failed!\n");
        close(fd);
        return -1;
    }
	u32FixScreenStride = fix.line_length;	/*fix screen stride*/

    /* 8. map the physical video memory for user use */
    u32Size 	= fix.smem_len;
    u32PhyAddr  = fix.smem_start;
    pShowScreen = mmap(NULL, fix.smem_len, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
    if(MAP_FAILED == pShowScreen)
    {
   	    printf("mmap framebuffer failed!\n");
        close(fd);
        return -1;
    }

    pHideScreen = pShowScreen + u32FixScreenStride*AVD_IMAGE_HEIGHT;
    memset(pShowScreen, 0x0000, u32FixScreenStride*AVD_IMAGE_HEIGHT);

    /* 9. create surface */
    g_AVDstScreen[0].enColorFmt = PIXFMT;
    g_AVDstScreen[0].u32PhyAddr = u32PhyAddr;
    g_AVDstScreen[0].u32Width = AVD_VIR_SCREEN_WIDTH;
    g_AVDstScreen[0].u32Height = AVD_IMAGE_HEIGHT;
    g_AVDstScreen[0].u32Stride = fix.line_length;
    g_AVDstScreen[0].bAlphaMax255 = HI_TRUE;
    g_AVDstScreen[1] = g_AVDstScreen[0];
    g_AVDstScreen[1].u32PhyAddr = g_AVDstScreen[0].u32PhyAddr + g_AVDstScreen[0].u32Stride * g_AVDstScreen[0].u32Height;

    g_stBackGround = g_AVDstScreen[1];
    g_stBackGround.u32PhyAddr = g_AVDstScreen[1].u32PhyAddr + g_AVDstScreen[1].u32Stride * g_AVDstScreen[1].u32Height;
    //g_stBackGround = g_stScreen[0];

    g_AVDstPingBuf = g_AVDstScreen[0];
    g_AVDstPangBuf = g_AVDstScreen[1];

 //   printf("g_AVDstPingBuf:%d\n",g_AVDstPingBuf.u32Stride);
 //   printf("g_AVDstPangBuf:%d\n",g_AVDstPangBuf.u32Stride);
    //g_stBackGround.u32PhyAddr = g_stScreen[1].u32PhyAddr + g_stScreen[1].u32Stride * g_stScreen[1].u32Height;

        // var.yoffset = (i%2)?0:1024;
         //var.yoffset = 0;
        /*set frame buffer start position*/

    i = 0;
    while(1)
    {
        IMP_S32 target_num = 0;
        i++;
        u32CurOnShow = i%2;
        u32NextOnShow = !u32CurOnShow;
        if(u32CurOnShow == 1)
        {
            g_AVDpstBackGround = &g_AVDstPingBuf;
        }
        else
        {
            g_AVDpstBackGround = &g_AVDstPangBuf;
        }
        TDE_HANDLE s32Handle;
        TDE2_OPT_S stOpt = {0};
        HI_FLOAT eXMid, eYMid;
        HI_FLOAT eRadius;
        HI_U32 i;
        HI_FLOAT f;
        HI_U32 u32NextOnShow;


        HI_U32 u32FillData = 0x8010;

        {printf("TDE2_BeginJob!\n");
        /* 1. start job */
        s32Handle = HI_TDE2_BeginJob();
        if(HI_ERR_TDE_INVALID_HANDLE == s32Handle)
        {
        //    TDE_PRINT("start job failed!\n");
            printf("start job failed!\n");
            return ;
        }

        //memset(pShowScreen, 0x0000, u32FixScreenStride*IMAGE_HEIGHT);
        stDstRect.s32Xpos = 0;
        stDstRect.s32Ypos = 0;
        stDstRect.u32Width = AVD_VIR_SCREEN_WIDTH;
        stDstRect.u32Height = AVD_IMAGE_HEIGHT;
        s32Ret = HI_TDE2_QuickFill( s32Handle, g_AVDpstBackGround,&stDstRect, 0);



        printf("TDE2_BeginJob2!\n");
        stDstRect.s32Xpos = 0;
        stDstRect.s32Ypos = 0;
        stDstRect.u32Width = 120;
        stDstRect.u32Height = 120;
        stSrcRect.s32Xpos = 0;
        stSrcRect.s32Ypos = 0;
        stSrcRect.u32Width = g_AVDpstBackGround->u32Width;
        stSrcRect.u32Height = g_AVDpstBackGround->u32Height;


        //TDE_OUTPUT_PEA_RESULT(s32Handle, g_pstBackGround,&g_IP_Result);//,&stDstRect);
        printf("TDE_OUTPUT_AVD_RESULT start!\n");
        TDE_OUTPUT_AVD_RESULT(s32Handle, g_AVDpstBackGround,&g_AVD_Reslut);//,&stDstRect);
        printf("TDE_OUTPUT_AVD_RESULT end!\n");
        memset(&pstOpt,0,sizeof(pstOpt));
        pstOpt.bDeflicker = HI_TRUE;

        /* {
            TDE_CreateSurfaceByFile(PIC_PEA_IMAGE_PATH6, g_AVDpstBackGround, pShowScreen + ((HI_U32)g_AVDpstBackGround->u32PhyAddr - u32PhyAddr));
            stSrcRect.s32Xpos = 0;
            stSrcRect.s32Ypos = 0;
            stSrcRect.u32Width = 79;
            stSrcRect.u32Height = g_AVDpstBackGround->u32Height;
            stDstRect.s32Xpos = 2;
            stDstRect.s32Ypos = 35;
            stDstRect.u32Width = 79;
            stDstRect.u32Height = g_AVDpstBackGround->u32Height;
            s32Ret = HI_TDE2_QuickCopy(s32Handle, g_AVDpstBackGround, &stSrcRect, g_AVDpstBackGround, &stDstRect);
        }*/
        /*TDE_CreateSurfaceByFile(AVD_IMAGE_PATH, g_AVDpstBackGround, pShowScreen + ((HI_U32)g_AVDpstBackGround->u32PhyAddr - u32PhyAddr));
        stDstRect.s32Xpos = 0;
        stDstRect.s32Ypos = 0;
        stDstRect.u32Width = 720;
        stDstRect.u32Height = 576;
        s32Ret = HI_TDE2_QuickCopy(s32Handle, g_AVDpstBackGround, &stDstRect, g_AVDpstBackGround, &stDstRect);
        */
        /* 4. bitblt image to screen */
        //s32Ret = HI_TDE2_Bitblit(s32Handle, NULL, &stDstRect, g_AVDpstBackGround, &stSrcRect, g_AVDpstBackGround , &stDstRect, &pstOpt);
        if(s32Ret < 0)
        {
            printf("Line:%d,HI_TDE2_QuickFill failed,ret=0x%x!\n", __LINE__, s32Ret);
            return ;
        }
         printf("TDE2_BeginJob3!\n");

        /* 5. submit job */
        s32Ret = HI_TDE2_EndJob(s32Handle, HI_FALSE, HI_TRUE, 10);
        if(s32Ret < 0)
        {
          //  TDE_PRINT("Line:%d,HI_TDE2_EndJob failed,ret=0x%x!\n", __LINE__, s32Ret);
            HI_TDE2_CancelJob(s32Handle);
            return ;
        }
        printf("TDE2_EndJob5!\n");
        }
        var.yoffset = (u32CurOnShow==1) ? 0 : AVD_IMAGE_HEIGHT;
        if (ioctl(fd, FBIOPAN_DISPLAY, &var) < 0)
        {
             //TDE_PRINT("process frame buffer device error\n");
             printf("process frame buffer device error\n");
             //goto FB_PROCESS_ERROR1;
        }
        usleep(40000);
    }


    printf("Enter to quit!\n");
    getchar();

    /* 10.unmap the physical memory */
    munmap(pShowScreen, fix.smem_len);

    /* 11. close the framebuffer device */
    close(fd);

    HI_TDE2_Close();
    return 0;
}
Example #3
0
static HI_VOID circumrotate (HI_U32 u32CurOnShow)
{
    TDE_HANDLE s32Handle;
	TDE2_OPT_S stOpt = {0};
	TDE2_RECT_S stSrcRect;
	TDE2_RECT_S stDstRect;
	HI_U32 u32NextOnShow;
	u32NextOnShow = !u32CurOnShow;
	HI_U32 s32Ret;
	HI_U32 u32FillData = 0x8000;
	TDE2_RECT_S pstScreenRect;
	/* 1. start job */
	s32Handle = HI_TDE2_BeginJob();
	if(HI_ERR_TDE_INVALID_HANDLE == s32Handle)
	{
		TDE_PRINT("start job failed!\n");
		return ;
	}   
	pstScreenRect.s32Xpos = 0;
	pstScreenRect.s32Ypos = 0;
	pstScreenRect.u32Width = SCREEN_WIDTH;
	pstScreenRect.u32Height = SCREEN_HEIGHT;
	
	s32Ret = HI_TDE2_QuickFill(s32Handle, &g_stScreen[u32NextOnShow], &pstScreenRect, u32FillData);
	if(s32Ret < 0)
	{
		TDE_PRINT("Line:%d,HI_TDE2_QuickFill failed,ret=0x%x!\n", __LINE__, s32Ret);
		HI_TDE2_CancelJob(s32Handle);
		return ;
	}	
	stOpt.enColorKeyMode = TDE2_COLORKEY_MODE_FOREGROUND;
    stOpt.unColorKeyValue.struCkARGB.stBlue.bCompIgnore = HI_FALSE;
    stOpt.unColorKeyValue.struCkARGB.stBlue.bCompOut = HI_FALSE;
    stOpt.unColorKeyValue.struCkARGB.stBlue.u8CompMin = 0xff;
    stOpt.unColorKeyValue.struCkARGB.stBlue.u8CompMax = 0xff;
    stOpt.unColorKeyValue.struCkARGB.stBlue.u8CompMask = 0xff;

    stOpt.unColorKeyValue.struCkARGB.stGreen.bCompIgnore = HI_TRUE;
    stOpt.unColorKeyValue.struCkARGB.stRed.bCompIgnore = HI_TRUE;    
    stOpt.unColorKeyValue.struCkARGB.stAlpha.bCompIgnore = HI_TRUE;
	
    stSrcRect.s32Xpos = 0;
    stSrcRect.s32Ypos = 0;
    stSrcRect.u32Width = g_stImgSur.u32Width;
    stSrcRect.u32Height = g_stImgSur.u32Height;

    stDstRect.s32Xpos = 100;
    stDstRect.s32Ypos = 100;
    stDstRect.u32Width = g_stImgSur.u32Width;
    stDstRect.u32Height = g_stImgSur.u32Height;

    /* 4. bitblt image to screen */
    s32Ret = HI_TDE2_Bitblit(s32Handle, &g_stScreen[u32NextOnShow], &stDstRect, 
        &g_stImgSur, &stSrcRect, &g_stScreen[u32NextOnShow], &stDstRect, &stOpt);
	if(s32Ret < 0)
	{
		TDE_PRINT("Line:%d,HI_TDE2_Bitblit failed,ret=0x%x!\n", __LINE__, s32Ret);
		HI_TDE2_CancelJob(s32Handle);
		return ;
	}
    /* 5. submit job */
    s32Ret = HI_TDE2_EndJob(s32Handle, HI_FALSE, HI_TRUE, 10);
	if(s32Ret < 0)
	{
		TDE_PRINT("Line:%d,HI_TDE2_EndJob failed,ret=0x%x!\n", __LINE__, s32Ret);
		HI_TDE2_CancelJob(s32Handle);
		return ;
	}


    return;
}
static HI_VOID circumrotate (HI_U32 u32CurOnShow)
{
    TDE_HANDLE s32Handle;
    TDE2_OPT_S stOpt = {0};
    HI_FLOAT eXMid, eYMid;
    HI_FLOAT eRadius;
    HI_U32 i;
    HI_FLOAT f;
    HI_U32 u32NextOnShow;
    TDE2_RECT_S stSrcRect;
    TDE2_RECT_S stDstRect;
		HI_S32 s32Ret = HI_SUCCESS;

    u32NextOnShow = !u32CurOnShow;
    
    f = (float) (g_s32FrameNum % CYCLE_LEN) / CYCLE_LEN;

    stSrcRect.s32Xpos = 0;
    stSrcRect.s32Ypos = 0;
    stSrcRect.u32Width = g_stBackGround.u32Width;
    stSrcRect.u32Height = g_stBackGround.u32Height;

    eXMid = g_stBackGround.u32Width/2.16f;
    eYMid = g_stBackGround.u32Height/2.304f;

    eRadius = MIN (eXMid, eYMid) / 2.0f;

    /* 1. start job */
    s32Handle = HI_TDE2_BeginJob();
    if(HI_ERR_TDE_INVALID_HANDLE == s32Handle)
    {
        TDE_PRINT("start job failed!\n");
        return ;
    }

    /* 2. bitblt background to screen */
    s32Ret = HI_TDE2_QuickCopy(s32Handle, &g_stBackGround, &stSrcRect, 
        &g_stScreen[u32NextOnShow], &stSrcRect);
    if(s32Ret < 0)
	{
        TDE_PRINT("Line:%d failed,ret=0x%x!\n", __LINE__, s32Ret);
		HI_TDE2_CancelJob(s32Handle);
        return ;
	}
    
    for(i = 0; i < N_IMAGES; i++)
    {
        HI_FLOAT ang;
        HI_FLOAT r;

        stSrcRect.s32Xpos = 0;
        stSrcRect.s32Ypos = 0;
        stSrcRect.u32Width = g_stImgSur[i].u32Width;
        stSrcRect.u32Height = g_stImgSur[i].u32Height;

        /* 3. calculate new pisition */
        ang = 2.0f * (HI_FLOAT) M_PI * (HI_FLOAT) i / N_IMAGES - f * 2.0f * (HI_FLOAT) M_PI;
        r = eRadius + (eRadius / 3.0f) * sinf (f * 2.0 * M_PI);

        stDstRect.s32Xpos = eXMid + r * cosf (ang) - g_stImgSur[i].u32Width / 2.0f;;
        stDstRect.s32Ypos = eYMid + r * sinf (ang) - g_stImgSur[i].u32Height / 2.0f;
        stDstRect.u32Width = g_stImgSur[i].u32Width;
        stDstRect.u32Height = g_stImgSur[i].u32Height;

        /* 4. bitblt image to screen */
        s32Ret = HI_TDE2_Bitblit(s32Handle, NULL, NULL, 
            &g_stImgSur[i], &stSrcRect, &g_stScreen[u32NextOnShow], &stDstRect, &stOpt);
		if(s32Ret < 0)
		{
			TDE_PRINT("Line:%d,HI_TDE2_Bitblit failed,ret=0x%x!\n", __LINE__, s32Ret);
			HI_TDE2_CancelJob(s32Handle);
			return ;
		}
    }

    /* 5. submit job */
    s32Ret = HI_TDE2_EndJob(s32Handle, HI_FALSE, HI_TRUE, 10);
	if(s32Ret < 0)
	{
		TDE_PRINT("Line:%d,HI_TDE2_EndJob failed,ret=0x%x!\n", __LINE__, s32Ret);
		HI_TDE2_CancelJob(s32Handle);
		return ;
	}

    g_s32FrameNum++;
    return;
}
Example #5
0
HI_S32 SAMPLE_VIO_TDE_1Screen_VoVGA()
{
    VB_CONF_S stVbConf   = {0};
    HI_S32 s32ViChnTotal = 1;
    HI_S32 s32VoChnTotal = 1;
    VO_DEV VoDev;
    VO_CHN VoChn;
    VI_DEV ViDev;
    VI_CHN ViChn;
    VI_PUB_ATTR_S stViDevAttr;
    VI_CHN_ATTR_S stViChnAttr;
    VO_PUB_ATTR_S stVoDevAttr;
    VO_VIDEO_LAYER_ATTR_S stVideoLayerAttr;
    VIDEO_FRAME_INFO_S stFrame;
    HI_S32 s32Ret = HI_SUCCESS;

    HI_S32 u32PhyAddr;

    stVbConf.astCommPool[0].u32BlkSize = 704 * 576 * 2;
    stVbConf.astCommPool[0].u32BlkCnt  = 20;
    stVbConf.astCommPool[1].u32BlkSize = 384 * 288 * 2;
    stVbConf.astCommPool[1].u32BlkCnt = 20;
    if (HI_SUCCESS != SAMPLE_InitMPP(&stVbConf))
    {
       return -1;
    }

    /* Config VI to input standard-definition video */
    ViDev = 0;
    SAMPLE_GetViCfg_SD(PIC_D1, &stViDevAttr, &stViChnAttr);
   // SAMPLE_GetViCfg_SD(PIC_CIF, &stViDevAttr, &stViChnAttr);
    s32Ret = SAMPLE_StartViByChn(s32ViChnTotal, &stViDevAttr, &stViChnAttr);
    if (HI_SUCCESS != s32Ret)
    {
        return HI_FAILURE;
    }

    /* display VGA video on vo HD divice. */
    VoDev = VO_DEV_HD;
    SAMPLE_GetVoCfg_VGA_800x600(&stVoDevAttr, &stVideoLayerAttr);
    s32Ret = SAMPLE_StartVo(s32VoChnTotal, VoDev, &stVoDevAttr, &stVideoLayerAttr);
    if (HI_SUCCESS != s32Ret)
    {
        return HI_FAILURE;
    }

    printf("start VI to VO preview \n");

    master_thread_init_ok = 1;

    sleep(3);

	/** 1. 打开TDE */
    HI_TDE2_Open();

    /** 2. 创建Y U V OSD surface */
    g_stOsdYSurface.enColorFmt = TDE2_COLOR_FMT_ARGB1555;
    g_stOsdYSurface.bYCbCrClut = 1;
    g_stOsdYSurface.bAlphaMax255 = HI_TRUE;
    g_stOsdYSurface.enColorSpaceConv = TDE2_ITU_R_BT601_VIDEO;

    g_stOsdUSurface.enColorFmt = TDE2_COLOR_FMT_ARGB1555;
    g_stOsdUSurface.bYCbCrClut = 0;
    g_stOsdUSurface.bAlphaMax255 = HI_TRUE;
    g_stOsdUSurface.enColorSpaceConv = TDE2_ITU_R_BT601_VIDEO;

    g_stOsdVSurface.enColorFmt = TDE2_COLOR_FMT_ARGB1555;
    g_stOsdVSurface.bYCbCrClut = 1;
    g_stOsdVSurface.bAlphaMax255 = HI_TRUE;
    g_stOsdVSurface.enColorSpaceConv = TDE2_ITU_R_BT601_VIDEO;

    while(1)
    {
        TGT_SET_S	*target_set = &gstPeaResult.stTargetSet;
        EVT_SET_S *event_set = &gstPeaResult.stEventSet;
        IMP_S32 s32TargetNum = target_set->s32TargetNum;

		/** 获取图像 */
        if (HI_MPI_VI_GetFrame(ViDev, 0, &stFrame))
        {
            printf("HI_MPI_VI_GetFrame err, vi(%d,%d)\n", ViDev, 0);
            return -1;
        }
        if(s32TargetNum > 0 )
        {
            TDE_HANDLE s32Handle;

			/* 3. 开始TDE任务 */
            s32Handle = HI_TDE2_BeginJob();
            if(HI_ERR_TDE_INVALID_HANDLE == s32Handle)
            {
                printf("start job failed!\n");
                continue;
            }
			/** 4. 配置YUV Surface数据 长度、宽度、stride、物理地址等 */
            u32PhyAddr = stFrame.stVFrame.u32PhyAddr[0];

            g_stOsdYSurface.u32Width = stFrame.stVFrame.u32Width;
            g_stOsdYSurface.u32Height = stFrame.stVFrame.u32Height;
            g_stOsdYSurface.u32Stride = stFrame.stVFrame.u32Stride[0];
            g_stOsdYSurface.u32PhyAddr = u32PhyAddr;

            g_stOsdUSurface.u32Width = stFrame.stVFrame.u32Width>>1;
            g_stOsdUSurface.u32Height = stFrame.stVFrame.u32Height>>1;
            g_stOsdUSurface.u32Stride = stFrame.stVFrame.u32Stride[1];
            g_stOsdUSurface.u32PhyAddr = stFrame.stVFrame.u32PhyAddr[1]+1;

            g_stOsdVSurface = g_stOsdUSurface;
            g_stOsdVSurface.u32PhyAddr = stFrame.stVFrame.u32PhyAddr[1];

			/** 5. 通过TDE绘制修改YUV数据显示PEA数据结果 TDE只支持绘制矩形区域、直线等*/
            IMP_TDE_DrawPeaResult( s32Handle, &g_stOsdYSurface,&g_stOsdVSurface, &gstPeaResult,IMP_D1,IMP_QCIF );

			/** 6. 直接修改YUV数据显示PEA数据结果 绘制轨迹线、用户配置的规则信息等*/
            IMP_DrawPeaResult( &stFrame.stVFrame, &gstPeaResult,IMP_D1,IMP_QCIF );

            /** 7. 结束TDE任务 */
            s32Ret = HI_TDE2_EndJob(s32Handle, HI_FALSE, HI_TRUE, 10);
            if(s32Ret < 0)
            {
                printf("Line:%d,HI_TDE2_EndJob failed,ret=0x%x!\n", __LINE__, s32Ret);
                HI_TDE2_CancelJob(s32Handle);
                return ;
            }
        }
		/** 8. 将修改后的YUV数据送给VO设备 */
        HI_MPI_VO_SendFrame( VoDev,0,&stFrame);

		/** 9. 释放图像 */
        HI_MPI_VI_ReleaseFrame(ViDev, 0, &stFrame);
    }