不知是新手还是什么原因,MiniGUI的安装和移植显得特别的麻烦,前前后后折腾了好几天。MiniGUI自带了hi3510和hi3560的编译参数,如果要移植海思其他的平台还是需要修改不少东西。这里记录移植到Hi3521A/Hi3520DV300的一个过程,以供参考。
前期准备:
先确定设备能正常运行显示屏能够正常显示,使用海思sample提供的hifb,看设备是否能够正常显示。设备和显示正常后进行下面的移植。
(一)文件下载
去MiniGUI官网下载原始文件,我这里移植的版本是MiniGUI3.0.12。MiniGUI移植到ARM平台与在PC机上安装是不同的,实际需要移植到海思平台的只要MiniGUI Core Lib (V3.0.12, Linux) 和MiniGUI Resource (V3.0.12) 就可以了。如果要跑应用,再编译MiniGUI Samples (V3.0.12) 就可以了。并不需要像PC机上安装一样全部库安装移植,那样全部库文件将达到六十多M,太大了。这里我们将不需要的功能关闭了。
(二)移植MiniGUI Core Lib(libminigui-3.0.12-linux)
(1)新建安装目录
cd libminigui-3.0.12-linux;mkdir _install
新建_install目录,编译生成的文件全部安装到该目录中,如下:
biao@ubuntu:~/NVR_Hi3520/MiniGUI/libminigui-3.0.12-linux/_install$ ls
etc include lib share
biao@ubuntu:~/NVR_Hi3520/MiniGUI/libminigui-3.0.12-linux/_install$ tree -L 2
.
├── etc
│ └── MiniGUI.cfg
├── include
│ └── minigui
├── lib
│ ├── libminigui_ths-3.0.so.12 -> libminigui_ths-3.0.so.12.0.0
│ ├── libminigui_ths-3.0.so.12.0.0
│ ├── libminigui_ths.a
│ ├── libminigui_ths.la
│ ├── libminigui_ths.so -> libminigui_ths-3.0.so.12.0.0
│ └── pkgconfig
└── share
└── minigui
7 directories, 6 files
biao@ubuntu:~/NVR_Hi3520/MiniGUI/libminigui-3.0.12-linux/_install$
(2)修改configure 文件
可以参考官方的hi3560a 添加hi3521a的配置
(a)在enable_videohi3560a 后面添加enable_videohi3521a
(b)--enable-videohi3560a 后面添加--enable-videohi3521a
(c)--with-targetname= 最后面添加hi3521a
(d)enable_video_hi3560a="no" 后面添加enable_video_hi3521a="no"
(e)CheckHI3560AVideo() 后面添加函数
CheckHI3521AVideo()
{
# Check whether --enable-videohi3521a was given.
if test "${enable_videohi3521a+set}" = set; then :
enableval=$enable_videohi3521a; enable_video_hi3521a=$enableval
fi
if test "x$enable_video_hi3521a" = "xyes"; then
$as_echo "#define _MGGAL_HI3521A 1" >>confdefs.h
VIDEO_SUBDIRS="$VIDEO_SUBDIRS hisi"
VIDEO_DRIVERS="$VIDEO_DRIVERS hisi/libvideo_hisifbcon.la"
fi
}
(f)CheckHI3560AVideo后面添加CheckHI3521AVideo
(g)CFLAGS="$CFLAGS -D_WITH_TARGET_HI3560A" 后面添加
hi3521a)
CFLAGS="$CFLAGS -D_WITH_TARGET_HI3521A"
;;
(3)修改configure.in 文件
(a)enable_video_hi3560a="no"后加enable_video_hi3521a="no"
(b)CheckHI3560AVideo()函数后面加
dnl Check HI3521A video driver
CheckHI3521AVideo()
{
AC_ARG_ENABLE(videohi3521a,
[ --enable-videohi3521a include Hi3521A Video NEWGAL engine <default=no>],
enable_video_hi3521a=$enableval)
if test "x$enable_video_hi3521a" = "xyes"; then
AC_DEFINE(_MGGAL_HI3521A, 1,
[Define if include Hi3521A Video NEWGAL engine])
VIDEO_SUBDIRS="$VIDEO_SUBDIRS hisi"
VIDEO_DRIVERS="$VIDEO_DRIVERS hisi/libvideo_hisifbcon.la"
fi
}
(c)CheckHI3560AVideo后加CheckHI3521AVideo
(d)--with-targetname 最后加/hi3521a
(e)CFLAGS="$CFLAGS -D_WITH_TARGET_HI3560A" 后面加
hi3521a)
CFLAGS="$CFLAGS -D_WITH_TARGET_HI3521A"
(4)修改mgconfig.h.in
#undef _MGGAL_HI3560A 后面添加
/* Define if include Hi3521A Video NEWGAL engine */
#undef _MGGAL_HI3521A
这里必须要添加,不然的话启动的时候找不到 hi3521a gal_engine。会出现如下打印:
NEWGAL: Does not find matched engine: hi3521a.
KERNEL>InitGUI: Can not get graphics engine information!
(5)修改/src/newgal/sysvideo.h
添加:
#ifdef _MGGAL_HI3521A
extern VideoBootStrap HI3521A_bootstrap;
#endif
(6)修改\src\newgal\video.c
添加:
#ifdef _MGGAL_HI3521A
&HI3521A_bootstrap,
#endif
(7)添加hi3521a_fbvideo.c和hi3521a_fbvideo.h文件
hi3521a_fbvideo.c和hi3521a_fbvideo.h两个文件是与平台相关的,所以最好参考海思的官方手册来修改。
hi3521a_fbvideo.c
/******************************************************************************
Copyright (C), 2012-2015, Prime Electronic Satellite Inc.
******************************************************************************
File Name : Hi3521a_fbvideo.c
Version : Initial Draft
Author : Caibiao Lee
Created : 2019/1/13
Last Modified :
Description : Implement all the functions for the framebuffer on the
Hi3521a platform.
Function List :
History :
1.Date : 2019/1/13
Author : Caibiao Lee
Modification: Created file
******************************************************************************/
/*----------------------------------------------*
* includes *
*----------------------------------------------*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <assert.h>
#include "common.h"
#ifdef _MGGAL_HI3521A
#include "minigui.h"
#include "misc.h"
#include "newgal.h"
#include "pixels_c.h"
#include "hifb.h"
#include "hi3521a_fbvideo.h"
/*----------------------------------------------*
* macros *
*----------------------------------------------*/
#define DEFAULT_SCREEN_WIDTH 1920
#define DEFAULT_SCREEN_HEIGHT 1080
#define WIDTH 1280
#define HEIGHT 720
#ifndef _MGRM_THREADS
#define REQID_HWSURFACE 0x0013
#endif
/*----------------------------------------------*
* data type definitions *
*----------------------------------------------*/
/*----------------------------------------------*
* external variables *
*----------------------------------------------*/
extern BOOL mgIsServer;
/*----------------------------------------------*
* external routine prototypes *
*----------------------------------------------*/
/*----------------------------------------------*
* internal routine prototypes *
*----------------------------------------------*/
/* Initialization/Query functions */
static int HI3521A_VideoInit(GAL_VideoDevice *this, GAL_PixelFormat *vformat);
static GAL_Rect **HI3521A_ListModes(GAL_VideoDevice *this, GAL_PixelFormat *format, Uint32 flags);
static GAL_Surface *HI3521A_SetVideoMode(GAL_VideoDevice *this, GAL_Surface *current, int width, int height, int bpp, Uint32 flags);
static int HI3521A_ToggleFullScreen(GAL_VideoDevice *this, int on);
static int HI3521A_SetColors(GAL_VideoDevice *this, int firstcolor, int ncolors, GAL_Color *colors);
static void HI3521A_UpdateRects(GAL_VideoDevice *this, int numrects, GAL_Rect *rects);
static void HI3521A_VideoQuit(GAL_VideoDevice *this);
/* Hardware surface functions */
#ifndef _MGRM_THREADS
static void HI3521A_RequestHWSurface (GAL_VideoDevice *this, const REQ_HWSURFACE* request, REP_HWSURFACE* reply);
#endif
static int HI3521A_AllocHWSurface(GAL_VideoDevice *this, GAL_Surface *surface);
static int HI3521A_CheckHWBlit(GAL_VideoDevice *this, GAL_Surface *src, GAL_Surface *dst);
static int HI3521A_FillHWRect(GAL_VideoDevice *this, GAL_Surface *dst, GAL_Rect *rect, Uint32 color);
static int HI3521A_SetHWColorKey(GAL_VideoDevice *this, GAL_Surface *surface, Uint32 key);
static int HI3521A_SetHWAlpha(GAL_VideoDevice *this, GAL_Surface *surface, Uint8 value);
static void HI3521A_FreeHWSurface(GAL_VideoDevice *this, GAL_Surface *surface);
static void HI3521A_FBFree(GAL_VideoDevice *this);
static void HI3521A_DeleteSurface(GAL_VideoDevice *this, GAL_Surface* surface);
static int HI3521A_SetSurfaceColors(GAL_Surface* surface, int firstcolor, int ncolors, GAL_Color *colors);
static int HI3521A_GetFBInfo(VIDEO_MEM_INFO *video_mem_info);
static void HI3521A_UpdateSurfaceRects(GAL_VideoDevice *this, GAL_Surface* surface, int numrects, GAL_Rect *rects);
#if 0
static void HI3521A_WaitVBL(GAL_VideoDevice *this);
static void HI3521A_WaitIdle(GAL_VideoDevice *this);
#endif
static void HI3521A_DeleteDevice(GAL_VideoDevice *device);
/*----------------------------------------------*
* project-wide global variables *
*----------------------------------------------*/
/*----------------------------------------------*
* module-wide global variables *
*----------------------------------------------*/
static struct fb_bitfield s_r16 = {10, 5, 0};
static struct fb_bitfield s_g16 = {5, 5, 0};
static struct fb_bitfield s_b16 = {0, 5, 0};
static struct fb_bitfield s_a16 = {15, 1, 0};
static int hi3521a_console = 0;
GAL_Surface logosurface;
/*----------------------------------------------*
* constants *
*----------------------------------------------*/
/*----------------------------------------------*
* routines' implementations *
*----------------------------------------------*/
static int HI3521A_Available(void)
{
const char *GAL_fbdev;
int fd;
GAL_fbdev = getenv("FRAMEBUFFER");
if ( GAL_fbdev == NULL )
{
GAL_fbdev = "/dev/fb0";
}
fd = open(GAL_fbdev, O_RDWR, 0);
return 1;
if ( fd < 0 )
{
return 0;
}
else
{
close(fd);
return 1;
}
}
static GAL_VideoDevice *HI3521A_CreateDevice (int devindex)
{
GAL_VideoDevice *this;
/* Initialize all variables that we clean on shutdown */
this = (GAL_VideoDevice *)malloc(sizeof(GAL_VideoDevice));
if ( this )
{
memset(this, 0, (sizeof *this));
this->hidden = (struct GAL_PrivateVideoData *)malloc(sizeof (struct GAL_PrivateVideoData));
this->name = "hi3521a";
}
if ( (this == NULL) || (this->hidden == NULL) )
{
GAL_OutOfMemory();
if ( this )
{
free(this);
}
return(0);
}
memset(this->hidden, 0, (sizeof (struct GAL_PrivateVideoData)));
/* Set the function pointers */
this->VideoInit = HI3521A_VideoInit;
this->ListModes = HI3521A_ListModes;
this->SetVideoMode = HI3521A_SetVideoMode;
this->ToggleFullScreen = HI3521A_ToggleFullScreen;
this->SetColors = HI3521A_SetColors;
this->UpdateRects = HI3521A_UpdateRects;
this->VideoQuit = HI3521A_VideoQuit;
#ifndef _MGRM_THREADS
this->RequestHWSurface = HI3521A_RequestHWSurface;
#endif
this->AllocHWSurface = HI3521A_AllocHWSurface;
this->CheckHWBlit = HI3521A_CheckHWBlit;
this->FillHWRect = HI3521A_FillHWRect;
this->SetHWColorKey = HI3521A_SetHWColorKey;
this->SetHWAlpha = HI3521A_SetHWAlpha;
this->FreeHWSurface = HI3521A_FreeHWSurface;
this->free = HI3521A_FBFree;
this->DeleteSurface = HI3521A_DeleteSurface;
this->SetSurfaceColors = HI3521A_SetSurfaceColors;
this->GetFBInfo = HI3521A_GetFBInfo;
this->UpdateSurfaceRects = HI3521A_UpdateSurfaceRects;
return this;
}
extern int hi3521a_board_init(void);
#if 0
extern HI_S32 HI_MPI_SYS_MmzAlloc(HI_U32 *pu32PhyAddr, HI_VOID **ppVirtAddr,
const HI_CHAR *strMmb, const HI_CHAR *strZone, HI_U32 u32Len);
#endif
#if 0
static void HI3521A_FBTest(GAL_VideoDevice *this)
{
int xPos = 0, yPos = 0;
//Uint16 *pBuff = this->hidden->pVirBuff;//this->hidden->stCanvasBuf.stCanvas.u32PhyAddr;
Uint16 *pBuff = (Uint16 *)(this->hidden->stCanvasBuf.stCanvas.u32PhyAddr);
Uint32 xRes = this->hidden->stCanvasBuf.stCanvas.u32Width;
Uint32 yRes = this->hidden->stCanvasBuf.stCanvas.u32Height;
for (yPos = 100; yPos < 200; yPos++)
{
for (xPos = 100; xPos < 200; xPos++)
{
*(pBuff + yPos * 1920 + xPos) = 0xFC00;
}
}
#if 0
this->hidden->stCanvasBuf.UpdateRect.x = 100;
this->hidden->stCanvasBuf.UpdateRect.y = 100;
this->hidden->stCanvasBuf.UpdateRect.w = 200;
this->hidden->stCanvasBuf.UpdateRect.h = 200;
if(ioctl(this->hidden->fd, FBIO_REFRESH, &(this->hidden->stCanvasBuf)) < 0)
{
GAL_SetError("NEWGAL>HI3521A: Updat Test Rect failed!\n");
}
#endif
}
#endif
static int HI3521A_VideoInit(GAL_VideoDevice *this, GAL_PixelFormat *vformat)
{
struct fb_fix_screeninfo finfo;
struct fb_var_screeninfo vinfo;
int i;
const char *GAL_fbdev;
GAL_VideoInfo* paccel_info = &this->info;
HIFB_COLORKEY_S stColorKey;
HIFB_POINT_S stPoint;
HIFB_LAYER_INFO_S stLayerInfo = {0};
HI_BOOL bShow;
hi3521a_board_init();
/* 1. open Framebuffer device overlay 0 */
GAL_fbdev = getenv("FRAMEBUFFER");
if ( GAL_fbdev == NULL )
{
GAL_fbdev = "/dev/fb0";
}
this->hidden->fd = open(GAL_fbdev, O_RDWR, 0);
if ( this->hidden->fd < 0 )
{
GAL_SetError("NEWGAL>HI3521A: Unable to open %s\n", GAL_fbdev);
return -1;
}
/*2. all layer surport colorkey*/
//stColorKey.bKeyEnable = HI_TRUE;
//stColorKey.u32Key = 0x0;
bShow = HI_FALSE;
if (ioctl(this->hidden->fd, FBIOPUT_COLORKEY_HIFB, &bShow) < 0)
{
GAL_SetError("NEWGAL>HI3521A:FBIOPUT_COLORKEY_HIFB!\n");
return -2;
}
/* 3. set the screen original position */
stPoint.s32XPos = 0;
stPoint.s32YPos = 0;
if (ioctl(this->hidden->fd, FBIOPUT_SCREEN_ORIGIN_HIFB, &stPoint) < 0)
{
GAL_SetError("NEWGAL>HI3521A:set screen original show position failed!\n");
return -3;
}
/* 4. get the variable screen info */
if(ioctl(this->hidden->fd, FBIOGET_VSCREENINFO, &vinfo) < 0)
{
GAL_SetError("NEWGAL>HI3521A:GET_VSCREENINFO failed!\n");
return -4;
}
/* 5. config the default parameters of the variable screen. */
vinfo.xres_virtual = WIDTH;;
vinfo.yres_virtual = HEIGHT*2;
vinfo.xres = WIDTH;
vinfo.yres = HEIGHT;;
vinfo.transp = s_a16;
vinfo.red = s_r16;
vinfo.green = s_g16;
vinfo.blue = s_b16;
vinfo.bits_per_pixel = 16;
vinfo.activate = FB_ACTIVATE_NOW;
if (ioctl(this->hidden->fd, FBIOPUT_VSCREENINFO, &vinfo) < 0)
{
GAL_SetError("NEWGAL>HI3521A: Put variable screen info failed!\n");
return -5;
}
/* 7. Get the type of video hardware */
if ( ioctl(this->hidden->fd, FBIOGET_FSCREENINFO, &finfo) < 0 )
{
GAL_SetError("NEWGAL>HI3521A: Couldn't get console hardware info\n");
HI3521A_VideoQuit(this);
return -6;
}
/* Memory map the device, compensating for buggy PPC mmap() */
this->hidden->stCanvasBuf.stCanvas.u32PhyAddr = mmap(NULL, finfo.smem_len,PROT_READ|PROT_WRITE, MAP_SHARED, this->hidden->fd, 0);
this->hidden->stCanvasBuf.stCanvas.u32Width = vinfo.xres;
this->hidden->stCanvasBuf.stCanvas.u32Height = vinfo.yres;
this->hidden->stCanvasBuf.stCanvas.u32Pitch = vinfo.xres*2;
this->hidden->stCanvasBuf.stCanvas.enFmt = HIFB_FMT_ARGB1555;
memset((Uint16*)(this->hidden->stCanvasBuf.stCanvas.u32PhyAddr), 0x00, this->hidden->stCanvasBuf.stCanvas.u32Pitch*this->hidden->stCanvasBuf.stCanvas.u32Height);
this->hidden->memLen = finfo.smem_len;
bShow = HI_TRUE;
if (ioctl(this->hidden->fd, FBIOPUT_SHOW_HIFB, &bShow) < 0)
{
GAL_SetError("NEWGAL>HI3521A:FBIOPUT_SHOW_HIFB failed!\n");
return -7;
}
vformat->BitsPerPixel = vinfo.bits_per_pixel;
for ( i=0; i<vinfo.red.length; ++i )
{
vformat->Rmask <<= 1;
vformat->Rmask |= (0x00000001<<vinfo.red.offset);
}
for ( i=0; i<vinfo.green.length; ++i )
{
vformat->Gmask <<= 1;
vformat->Gmask |= (0x00000001<<vinfo.green.offset);
}
for ( i=0; i<vinfo.blue.length; ++i )
{
vformat->Bmask <<= 1;
vformat->Bmask |= (0x00000001<<vinfo.blue.offset);
}
for ( i=0; i<vinfo.transp.length; ++i )
{
vformat->Amask <<= 1;
vformat->Amask |= (0x00000001<<vinfo.transp.offset);
}
paccel_info->hw_available = 1;
paccel_info->video_mem = finfo.smem_len/1024;
paccel_info->blit_fill = 1;
paccel_info->blit_hw = 1;
paccel_info->blit_hw_A = 1;
paccel_info->blit_hw_CC = 1;
//HI3521A_FBTest(this);
return(0);
}
static GAL_Rect **HI3521A_ListModes(GAL_VideoDevice *this, GAL_PixelFormat *format, Uint32 flags)
{
return (GAL_Rect**)(-1);
}
static GAL_Surface *HI3521A_SetVideoMode(GAL_VideoDevice *this, GAL_Surface *current, int width, int height, int bpp, Uint32 flags)
{
struct fb_fix_screeninfo finfo;
struct fb_var_screeninfo vinfo;
int i;
Uint32 Rmask;
Uint32 Gmask;
Uint32 Bmask;
Uint32 Amask;
char *surfaces_mem;
int surfaces_len;
/* Set the video mode and get the final screen format */
if ( ioctl(this->hidden->fd, FBIOGET_VSCREENINFO, &vinfo) < 0 )
{
fprintf (stderr, "Couldn't get console screen info");
return(NULL);
}
if ((vinfo.xres != width) || (vinfo.yres != height) ||(vinfo.bits_per_pixel != bpp))
{
vinfo.transp= s_a16;
vinfo.red = s_r16;
vinfo.green = s_g16;
vinfo.blue = s_b16;
vinfo.bits_per_pixel = 16;
vinfo.activate = FB_ACTIVATE_NOW;
vinfo.xres = vinfo.xres_virtual = 1280;
vinfo.yres = vinfo.yres_virtual = 300;
if ( ioctl(this->hidden->fd, FBIOPUT_VSCREENINFO, &vinfo) < 0 )
{
GAL_SetError("NEWGAL>HI3521A: Couldn't set console screen info\n");
vinfo.yres_virtual = height;
if ( ioctl(this->hidden->fd, FBIOPUT_VSCREENINFO, &vinfo) < 0 )
{
GAL_SetError("NEWGAL>HI3521A: Couldn't set console screen info[2]\n");
return(NULL);
}
}
}
else
{
int maxheight;
/* Figure out how much video memory is available */
maxheight = height;
if ( vinfo.yres_virtual > maxheight )
{
vinfo.yres_virtual = maxheight;
}
}
Rmask = 0;
for ( i=0; i<vinfo.red.length; ++i )
{
Rmask <<= 1;
Rmask |= (0x00000001<<vinfo.red.offset);
}
Gmask = 0;
for ( i=0; i<vinfo.green.length; ++i )
{
Gmask <<= 1;
Gmask |= (0x00000001<<vinfo.green.offset);
}
Bmask = 0;
for ( i=0; i<vinfo.blue.length; ++i )
{
Bmask <<= 1;
Bmask |= (0x00000001<<vinfo.blue.offset);
}
Amask = 0;
for ( i=0; i<vinfo.transp.length; ++i )
{
Amask <<= 1;
Amask |= (0x00000001<<vinfo.transp.offset);
}
if (!GAL_ReallocFormat(current, vinfo.bits_per_pixel,Rmask, Gmask, Bmask, Amask) )
{
return(NULL);
}
if ( vinfo.bits_per_pixel < 8 )
{
current->format->MSBLeft = !(vinfo.red.msb_right);
}
/* Set up the new mode framebuffer */
current->flags = GAL_FULLSCREEN;
current->w = vinfo.xres;
current->h = vinfo.yres;
current->pitch = vinfo.xres*2;
current->pixels = this->hidden->stCanvasBuf.stCanvas.u32PhyAddr;
return(current);
}
static int HI3521A_ToggleFullScreen(GAL_VideoDevice *this, int on)
{
printf("enter %s ....\n",__FUNCTION__);
return 0;
}
static int HI3521A_SetColors(GAL_VideoDevice *this, int firstcolor, int ncolors, GAL_Color *colors)
{
printf("enter %s ....\n",__FUNCTION__);
return 0;
}
static void HI3521A_UpdateRects(GAL_VideoDevice *this, int numrects, GAL_Rect *rects)
{
int i;
//printf("enter %s ....\n",__FUNCTION__);
#if 0
for(i=0;i<numrects;i++)
{
this->hidden->stCanvasBuf.UpdateRect.x = rects[i].x;
this->hidden->stCanvasBuf.UpdateRect.y = rects[i].y;
this->hidden->stCanvasBuf.UpdateRect.w = rects[i].w;
this->hidden->stCanvasBuf.UpdateRect.h = rects[i].h;
if(ioctl(this->hidden->fd, FBIO_REFRESH, &(this->hidden->stCanvasBuf)) < 0)
{
GAL_SetError("NEWGAL>HI3521A: Updat Rect[%d,%d,%d,%d] failed!\n",rects[i].x,rects[i].y,rects[i].w,rects[i].h);
break;
}
}
#endif
}
/* Note: If we are terminated, this could be called in the middle of
another SDL video routine -- notably UpdateRects.
*/
static void HI3521A_VideoQuit(GAL_VideoDevice *this)
{
//printf("enter %s ....\n",__FUNCTION__);
close(this->hidden->fd);
}
#ifndef _MGRM_THREADS
static void HI3521A_RequestHWSurface (GAL_VideoDevice *this, const REQ_HWSURFACE* request, REP_HWSURFACE* reply)
{
printf("enter %s ....\n",__FUNCTION__);
}
#endif
static int HI3521A_AllocHWSurface(GAL_VideoDevice *this, GAL_Surface *surface)
{
printf("enter %s ....\n",__FUNCTION__);
return 0;
}
static int HI3521A_CheckHWBlit(GAL_VideoDevice *this, GAL_Surface *src, GAL_Surface *dst)
{
printf("enter %s ....\n",__FUNCTION__);
return 0;
}
static int HI3521A_FillHWRect(GAL_VideoDevice *this, GAL_Surface *dst, GAL_Rect *rect, Uint32 color)
{
#if 0
int xPos = 0, yPos = 0;
Uint16 *pBuff = (short*)(this->hidden->stCanvasBuf.stCanvas.u32PhyAddr);
Uint32 xRes = this->hidden->stCanvasBuf.stCanvas.u32Width;
Uint32 yRes = this->hidden->stCanvasBuf.stCanvas.u32Height;
//printf("enter %s ....\n",__FUNCTION__);
//printf("Rect:[%d,%d,%d,%d]\n",rect->x,rect->y,rect->w,rect->h);
//printf("Color:%x\n",color);
for(yPos = rect->y; yPos < rect->h; yPos++)
{
memset(pBuff+yPos*xRes + rect->x, color, rect->w);
}
#endif
return 0;
}
static int HI3521A_SetHWColorKey(GAL_VideoDevice *this, GAL_Surface *surface, Uint32 key)
{
printf("enter %s ....\n",__FUNCTION__);
return 0;
}
static int HI3521A_SetHWAlpha(GAL_VideoDevice *this, GAL_Surface *surface, Uint8 value)
{
printf("enter %s ....\n",__FUNCTION__);
return 0;
}
static void HI3521A_FreeHWSurface(GAL_VideoDevice *this, GAL_Surface *surface)
{
printf("enter %s ....\n",__FUNCTION__);
}
static void HI3521A_FBFree(GAL_VideoDevice *this)
{
//printf("enter %s ....\n",__FUNCTION__);
munmap((Uint16*)(this->hidden->stCanvasBuf.stCanvas.u32PhyAddr), this->hidden->memLen);
free(this);
}
static void HI3521A_DeleteSurface(GAL_VideoDevice *this, GAL_Surface* surface)
{
printf("enter %s ....\n",__FUNCTION__);
}
static int HI3521A_SetSurfaceColors(GAL_Surface* surface, int firstcolor, int ncolors, GAL_Color *colors)
{
printf("enter %s ....\n",__FUNCTION__);
return 0;
}
static int HI3521A_GetFBInfo(VIDEO_MEM_INFO *video_mem_info)
{
printf("enter %s ....\n",__FUNCTION__);
return 0;
}
static void HI3521A_UpdateSurfaceRects(GAL_VideoDevice *this, GAL_Surface* surface, int numrects, GAL_Rect *rects)
{
printf("enter %s ....\n",__FUNCTION__);
}
#if 0
static void HI3521A_WaitVBL(GAL_VideoDevice *this)
{
printf("enter %s ....\n",__FUNCTION__);
return;
}
static void HI3521A_WaitIdle(GAL_VideoDevice *this)
{
printf("enter %s ....\n",__FUNCTION__);
return;
}
#endif
VideoBootStrap HI3521A_bootstrap = {
"hi3521a", "HI3521A Framebuffer Console",
HI3521A_Available, HI3521A_CreateDevice
};
#endif
/******************************************************************************
Copyright (C), 2012-2015, Prime Electronic Satellite Inc.
******************************************************************************
File Name : Hi3521a_fbvideo.h
Version : Initial Draft
Author : Caibiao Lee
Created : 2019/01/13
Last Modified :
Description : Header file of Hi3521a framebuffer interface.
Function List :
History :
1.Date : 2019/01/13
Author : Caibiao Lee
Modification: Created file
******************************************************************************/
#ifndef _HI3521A_FBVIDEO_H_
#define _HI3521A_FBVIDEO_H_
/*----------------------------------------------*
* includes *
*----------------------------------------------*/
#include <sys/types.h>
#include <linux/fb.h>
#include "sysvideo.h"
/*----------------------------------------------*
* data type definitions *
*----------------------------------------------*/
/* This is the structure we use to keep track of video memory */
typedef struct vidmem_bucket
{
struct vidmem_bucket *prev;
int used;
Uint8 *base;
unsigned int size;
struct vidmem_bucket *next;
} vidmem_bucket;
/* Private display data */
struct GAL_PrivateVideoData
{
Uint32 fd;
HIFB_BUFFER_S stCanvasBuf;
Uint32 memLen;
};
/*----------------------------------------------*
* macros *
*----------------------------------------------*/
/*----------------------------------------------*
* external variables *
*----------------------------------------------*/
/*----------------------------------------------*
* external routine prototypes *
*----------------------------------------------*/
#ifndef _MGRM_THREADS
BOOL FB_CreateDevice(GAL_VideoDevice *device, const Sint8* pszLayerName);
#else
BOOL FB_CreateDevice(GAL_VideoDevice *device);
#endif
/*----------------------------------------------*
* internal routine prototypes *
*----------------------------------------------*/
/*----------------------------------------------*
* project-wide global variables *
*----------------------------------------------*/
/*----------------------------------------------*
* module-wide global variables *
*----------------------------------------------*/
/*----------------------------------------------*
* constants *
*----------------------------------------------*/
/*----------------------------------------------*
* routines' implementations *
*----------------------------------------------*/
#endif /* _GAL_hi3521a_fbvideo_h */
(8)修改\src\newgal\hisi\Makefile.in
修改am__objects_1 编译目标,把不需要的平台去掉,以免编译出错。
am__objects_1 = hi3521a_fbvideo.lo \
pix_array.lo tde.lo
修改SRC_FILES
SRC_FILES = hi3521a_fbvideo.c pix_array.c tde.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gal_hi3560a.Plo@am__quote@后面添加:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hi3521_fbvideo.Plo@am__quote@
(9)拷贝 hi_type.h 和hifb.h 到hisi目录
(10)配置,编译,加载
如果之前有配置编译过,先执行 make distclean 清楚以前的全部配置。
./configure --prefix=/home/biao/NVR_Hi3520/MiniGUI/libminigui-3.0.12-linux/_install CC=arm-hisiv300-linux-gcc --host=arm-hisiv300-linux --disable-pcxvfb --disable-screensaver --disable-splash --disable-jpgsupport --enable-videoqvfb=no --enable-rtosxvfb=no --enable-pcxvfb=no --enable-videohi3521a=yes
make
sudo make install
(三)编译资源文件minigui-res-be-3.0.12
./configure --host=arm-hisiv300-linux --prefix=/home/biao/NVR_Hi3520/MiniGUI/minigui-res-be-3.0.12/__install
make
sudo make install
(四)编译测试程序mg-samples-3.0.12
samples 的程序依赖很多其他的库,我们这里没有使用到的先不管它。这里单独编译一个helloworld 程序。在海思的/sample/中添加miniGUI文件夹,MiniGUI的库文件和头文件与mpp的其他库文件和头文件放一起。仿照其他例子写个Makefile。
biao@ubuntu:~/Hi3521A_SDK/Hi3521A_SDK_V1.0.3.1/mpp/sample/miniGUI$ tree
.
├── board.c
├── board.h
├── helloworld.c
├── helloworld_res_cn.h
├── helloworld_res_en.h
├── helloworld_res_tw.h
└── Makefile
0 directories, 7 files
biao@ubuntu:~/Hi3521A_SDK/Hi3521A_SDK_V1.0.3.1/mpp/sample/miniGUI$
(五)运行
将./helloworld 放到开发板,将资源文件放置到根目录下的MiniGUI目录下,将MiniGUI.cfg 放到/etc/目录下,并修改下面内容:
[system]
# GAL engine and default options
#gal_engine=hi3521a
gal_engine=hi3521a
defaultmode=800x600-16bpp
# IAL engine
ial_engine=dummy
mdev=/dev/input/mice
mtype=IMPS2
#{{ifdef _MGGAL_PCXVFB
[hi3521a]
defaultmode=1280x720-16bpp
#window_caption=XVFB-for-MiniGUI-3.0-(Gtk-Version)
#exec_file=/Minigui
#}}
respath=/Minigui/res/
cursorpath=/Minigui/res/cursor/
运行结果如下:
完整工程下载路径:HI3521A HI3520DV300移植MiniGUI