- 收藏
- 点赞
- 分享
- 举报
[已实现]QT应用界面程序与海斯MPI应用程序分别运行
[i=s] 本帖最后由 ngswfx 于 2016-7-5 01:01 编辑 [/i]
这几天着手弄QT或者MiniGUI。
///miniGUI弄了一天,没装成功,估计我的stdc++库环境异常,被卡在这里了,准备往后暂放一下,看miniGUI编程方法,非常像win32编程,准备优先考虑,没辙,只能放一放。
//暂先尝试QT,虽然占用空间大一些,但也有不少优点,感觉做大众化的美观界面,可能容易一些。但我[color=Red]不想把这些东西揉到现有程序里面,而是想将界面类程序独立出来,编译成一个独立程序,被现有程序调用,调用前确保环境已经准备OK。[/color]
///当然,执行前,如果需要启动VO,或者FBI,这都可以通过其他机制确保。
//和海斯底层的各种功能交互,通过特定模块实现,例如网络模块方式,或者共享内存方式,这个都比较容易实现,按照应用环境自定义即可。
其实也没有太多交互,主要是鼠标按钮命令传递。是否开启某个视频窗体,窗体的显示位置等等。
//////////////////目前就是需要了解,这种方式是否可行,大家是不是这么做的,我看论坛上都是把海斯的东西封装了一下,然后放到main里面了,QApplication之前。
////根据我的了解,这个QT用的应该就是linux的/dev/fb0而已,海斯的fb,应该是在fb0基础上,又增强封装了一层,加强了些2D的处理,利用了显卡的加速。按理说,在开启vo以及fb的情况下,应该可以实现才对。即便做成让海斯SDK程序开启VO,由QT界面程序独立开启fb,实现UI,也能接受。但如果都通过一个QT程序来实现,感觉揉到一块,模块化程度不高。代码维护稍麻烦。
http://www.ebaina.com/bbs/forum.php?mod=viewthread&tid=8086&highlight=qt //////2016_6_15 使用goodman共享出来的东西,在3520D 32M spi上独立运行,正常,屏蔽// Mal_SYS_Init();以后,先运行我自己写的海斯SDK很紧密的主应用程序,再启动QT界面程序,执行程序没反应,看不到任何东西,我估计有2中可能,一种是可能是/dev/fb0如果被另外一个程序占用,是独占的,不能被gui_test访问到了,另一种可能性是一切正常,只不过看不到而已。 接下来尝试,把fb0启动过程封装到gui_test内部执行,海斯SDK程序,仅仅负责开VO [color=Blue]///后面的验证测试表明,fb0的调用不是独占的,可以被几个程序同时打开使用,并且都挺正常。[/color]
/////[color=Blue]测试先通过gui_test开启fb0后,再启动SDK视频程序,内部也再次开启fb0,显示内容虽然乱,但的确是希望看到的结果,只要动鼠标,窗体在,鼠标指针也移动,有变化。网络控制SDK视频应用程序,绘制到fb0的内容也能刷新,视频一切正常,自己视频叠加的内容显示正常,再次移动QT gui_test程序的鼠标,QT界面还在,由于QT用的是32 RGB8888,我程序里面用的是1555,所以显示的内容很乱。但基本说明QT界面程序可以独立出来,只不过需要先启动。[/color]
////////最新的测试情况:3个程序,一个是gui_test 这个里面没有进行任何海斯动作。一个是gui_test11里面有初始化VO以及FBI。还有一个自己的程序。 //如果先启动gui_test11 界面出来正常,然后再启动我自己的程序。里面也有VO以及FBI动作,然后启动gui_test,里面没有VO以及FBI任何动作。然后再强制关闭gui_test11。 //这一连串动作后,结果非常满意,QT程序界面一切正常,由不带海斯动作的gui_test接管了界面处理。
//这么看来,只要前期抢占住需要的资源,后期可以用另外一个独立的程序接管。
[size=5]//[color=Red]哈哈哈哈,太激动了,成功了,QT程序本身彻底抛弃了海斯SDK[/color][/size]
[color=Blue][size=4]只需要写主程序,把VO以及FBI打开,QT程序无需连接MPI等库,不用去参与芯片的VO初始化动作等,呵呵。 同一个程序,已经验证过了,在3520D上面能开启QT界面,直接放到3536上就可以直接运行,不依赖MPI,这样通用性就增强了,不同海斯芯片,界面程序直接运行了。 //只需要确保主程序能够正确开启VO,开启FBI,能实现FBI叠加后,在执行打开QT界面程序即可。这样用来做设置程序最方便了。 //具体做法其实很简单,就是把海斯的FBI初始化的过程,全都移植到QT的main.cpp里面,缺少什么定义就加什么。 //稍微麻烦的就是HI_MPI_SYS_MmzAlloc移植,这个就是个分配内存而已,自己用通用的代码解决,实际测试,只要确保主程序在运行,再运行QT程序,界面就出来了,:lol [/size][/color]。
注意: 下面2个最好都配置好,tde也要配置的大一些,否则QT打开容易失败,我弄成320 *240就不行 insmod hi3520D_tde.ko g_u32TdeTmpBufW=1920 g_u32TdeTmpBufH=1080 insmod hifb.ko video="hifb:vram0_size:8100,vram1_size:32,vram2_size:32,vram3_size:32" softcursor="off" u32VcmpBufNum=2
////////main验证程序代码,内部可能有错,各个模块简单叠加,揉到一起,做构架验证,不考虑具体细节。
include "widget.h"
include
include
include
void signal_handle(int signo) {
if (SIGINT == signo || SIGTSTP == signo) {
// Mal_SYS_Exit();
qDebug()<<"program exit abnormally!";
}
exit(-1);
}
define FBIOGET_VSCREENINFO 0x4600
define FBIOPUT_VSCREENINFO 0x4601
define FBIOGET_FSCREENINFO 0x4602
typedef enum { HI_FALSE = 0, HI_TRUE = 1, } HI_BOOL;
define BK_SCR_TRANS_COLOR_KEY 0x00
include <linux/fb.h>
include
include
include
include
include
using namespace std;
include <sys/types.h>
include <sys/stat.h>
include <sys/ioctl.h>
include
include
include
include
include
include
include <sys/time.h>
include <sys/mman.h>
include
include <linux/fb.h>
include <linux/fb.h>
include "locale.h"
typedef struct { HI_BOOL bKeyEnable; / colorkey enable flag / int u32Key; / colorkey value, maybe contains alpha / }HIFB_COLORKEY_S; typedef struct { int s32XPos; /< horizontal position *//*<CNcomment:水平位置 / int s32YPos; /< vertical position *//*<CNcomment:垂直位置 / }HIFB_POINT_S;
define IOC_TYPE_HIFB 'F'
define HI_S32 int
define HI_U32 unsigned int
define HI_U16 unsigned short
typedef struct hiHIFB_DEFLICKER_S { int u32HDfLevel; /< horizontal deflicker level */ int u32VDfLevel; /< vertical deflicker level / char pu8HDfCoef; /< horizontal deflicker coefficient / char pu8VDfCoef; /*< vertical deflicker coefficient / }HIFB_DEFLICKER_S; /refresh mode/ typedef enum { HIFB_LAYER_ANTIFLICKER_NONE = 0x0, /< no antiflicker*/ HIFB_LAYER_ANTIFLICKER_LOW = 0x1, /< low level*/ HIFB_LAYER_ANTIFLICKER_MIDDLE = 0x2,/*< middle level/ HIFB_LAYER_ANTIFLICKER_HIGH = 0x3, /< high level*/ HIFB_LAYER_ANTIFLICKER_AUTO = 0x4, /< auto/ HIFB_LAYER_ANTIFLICKER_BUTT }HIFB_LAYER_ANTIFLICKER_LEVEL_E; /refresh mode*/ typedef enum { HIFB_LAYER_BUF_DOUBLE = 0x0, /*< 2 display buf in fb / HIFB_LAYER_BUF_ONE = 0x1, /< 1 display buf in fb */ HIFB_LAYER_BUF_NONE = 0x2, /< no display buf in fb,the buf user refreshed will be directly set to VO*/ HIFB_LAYER_BUF_DOUBLE_IMMEDIATE=0x3, /*< 2 display buf in fb, each refresh will be displayed/ HIFB_LAYER_BUF_BUTT } HIFB_LAYER_BUF_E; /layer info maskbit/ typedef enum { HIFB_LAYERMASK_BUFMODE = 0x1, /< BUFMODE bitmask */ HIFB_LAYERMASK_ANTIFLICKER_MODE = 0x2, /< ANTIFLICKER_MODE bitmask */ HIFB_LAYERMASK_POS = 0x4, /*< the position bitmask / HIFB_LAYERMASK_CANVASSIZE = 0x8, /< canvassize bitmask */ HIFB_LAYERMASK_DISPSIZE = 0x10, /< displaysize bitmask */ HIFB_LAYERMASK_SCREENSIZE = 0x20, /*< screensize bitmask / HIFB_LAYERMASK_BMUL = 0x40, /< pre-mult bitmask */ HIFB_LAYERMASK_BUTT }HIFB_LAYER_INFO_MASKBIT; /layer info*/ typedef struct { HIFB_LAYER_BUF_E BufMode; HIFB_LAYER_ANTIFLICKER_LEVEL_E eAntiflickerLevel; HI_S32 s32XPos; /*< the x pos of origion point in screen / HI_S32 s32YPos; /< the y pos of origion point in screen */ HI_S32 u32CanvasWidth; /< the width of canvas buffer */ HI_S32 u32CanvasHeight; /*< the height of canvas buffer / HI_U32 u32DisplayWidth; /< the width of display buf in fb.for 0 buf ,there is no display buf in fb, so it's effectless*/ HI_U32 u32DisplayHeight; /< the height of display buf in fb. */ HI_U32 u32ScreenWidth; /*< the width of screen / HI_U32 u32ScreenHeight; /< the height of screen */ HI_BOOL bPreMul; /< The data drawed in buf is premul data or not*/ HI_U32 u32Mask; /*< param modify mask bit/ }HIFB_LAYER_INFO_S; typedef struct { HI_S32 x, y; /<x: horizontal coordinate of the upper left point of the rectangle; y: vertical coordinate of the upper left point of the rectangle*//<CNcomment: x:矩形左上点横坐标 y:矩形左上点纵坐标*/ HI_S32 w, h; /*< w: rectangle width; h: rectangle height//<CNcomment: w:矩形宽度 h:矩形高度*/ } HIFB_RECT; /Pixel format*/ /*CNcomment:像素格式枚举 / typedef enum { HIFB_FMT_RGB565 = 0, /< RGB565 16bpp */ HIFB_FMT_RGB888, /< RGB888 24bpp */ HIFB_FMT_KRGB444, /*< RGB444 16bpp / HIFB_FMT_KRGB555, /< RGB555 16bpp */
HIFB_FMT_KRGB888, /**< RGB888 32bpp */
HIFB_FMT_ARGB4444, /**< ARGB4444 */
HIFB_FMT_ARGB1555, /**< ARGB1555 */
HIFB_FMT_ARGB8888, /**< ARGB8888 */
HIFB_FMT_ARGB8565, /**< ARGB8565 */
HIFB_FMT_RGBA4444, /**< ARGB4444 */
HIFB_FMT_RGBA5551, /**< RGBA5551 */
HIFB_FMT_RGBA5658, /**< RGBA5658 */
HIFB_FMT_RGBA8888, /**< RGBA8888 */
HIFB_FMT_BGR565, /**< BGR565 */
HIFB_FMT_BGR888, /**< BGR888 */
HIFB_FMT_ABGR4444, /**< ABGR4444 */
HIFB_FMT_ABGR1555, /**< ABGR1555 */
HIFB_FMT_ABGR8888, /**< ABGR8888 */
HIFB_FMT_ABGR8565, /**< ABGR8565 */
HIFB_FMT_KBGR444, /**< BGR444 16bpp */
HIFB_FMT_KBGR555, /**< BGR555 16bpp */
HIFB_FMT_KBGR888, /**< BGR888 32bpp */
HIFB_FMT_1BPP, /**< clut1 */
HIFB_FMT_2BPP, /**< clut2 */
HIFB_FMT_4BPP, /**< clut4 */
HIFB_FMT_8BPP, /**< clut8 */
HIFB_FMT_ACLUT44, /**< AClUT44*/
HIFB_FMT_ACLUT88, /**< ACLUT88 */
HIFB_FMT_PUYVY, /**< UYVY */
HIFB_FMT_PYUYV, /**< YUYV */
HIFB_FMT_PYVYU, /**< YVYU */
HIFB_FMT_YUV888, /**< YUV888 */
HIFB_FMT_AYUV8888, /**< AYUV8888 */
HIFB_FMT_YUVA8888, /**< YUVA8888 */
HIFB_FMT_BUTT
}HIFB_COLOR_FMT_E; / surface info / typedef struct { HI_U32 u32PhyAddr; /< start physical address */ HI_U32 u32Width; /*< width pixels / HI_U32 u32Height; /< height pixels */ HI_U32 u32Pitch; /< line pixels */ HIFB_COLOR_FMT_E enFmt; /*< color format / }HIFB_SURFACE_S; / refresh surface info / typedef struct { HIFB_SURFACE_S stCanvas; HIFB_RECT UpdateRect; /< refresh region*/ }HIFB_BUFFER_S; /* To set the layer information /
define FBIOPUT_LAYER_INFO _IOW(IOC_TYPE_HIFB, 120, HIFB_LAYER_INFO_S*)
/* To get the layer information /
define FBIOGET_LAYER_INFO _IOR(IOC_TYPE_HIFB, 121, HIFB_LAYER_INFO_S*)
/* To get canvas buf /
define FBIOGET_CANVAS_BUFFER _IOR(IOC_TYPE_HIFB, 123, HIFB_BUFFER_S*)
/* To refresh the displayed contents in extended mode /
define FBIO_REFRESH _IOW(IOC_TYPE_HIFB, 124, HIFB_BUFFER_S*)
define FBIOPUT_COLORKEY_HIFB _IOW(IOC_TYPE_HIFB, 91, HIFB_COLORKEY_S)
define FBIOPUT_SCREEN_ORIGIN_HIFB _IOW(IOC_TYPE_HIFB, 95, HIFB_POINT_S)
/*To set the compression function status of an overlay layer/
define FBIOPUT_COMPRESSION_HIFB _IOW(IOC_TYPE_HIFB, 133, HI_BOOL)
define FBIOPUT_SHOW_HIFB _IOW(IOC_TYPE_HIFB, 101, HI_BOOL)
////////////////////////////////////////// typedef struct tag_MMAP_Node { unsigned int Start_P; unsigned int Start_V; unsigned int length; unsigned int refcount; / map后的空间段的引用计数 / struct tag_MMAP_Node next; }TMMAP_Node_t; int _memunmap(void addr_mapped); TMMAP_Node_t * pTMMAPNode = NULL; int HB_STATE_okEx = false;
define PAGE_SIZE 0x1000
define PAGE_SIZE_MASK 0xfffff000
static int fd_MEM = -1; static const char dev[]="/dev/mem"; void _memmapEx(unsigned int phy_addr, unsigned int size) { unsigned int phy_addr_in_page; unsigned int page_diff; unsigned int size_in_page; TMMAP_Node_t pTmp; TMMAP_Node_t pNew; void addr=NULL; if(size == 0) return NULL; / check if the physical memory space have been mmaped / pTmp = pTMMAPNode; while(pTmp != NULL) { if( (phy_addr >= pTmp->Start_P) && ( (phy_addr + size) <= (pTmp->Start_P + pTmp->length) ) ) { pTmp->refcount++; / referrence count increase by 1 / return (void )(pTmp->Start_V + phy_addr - pTmp->Start_P); } pTmp = pTmp->next; } / not mmaped yet / if(fd_MEM < 0) { / dev not opened yet, so open it / fd_MEM = open (dev, O_RDWR | O_SYNC); if (fd_MEM < 0) return NULL; } / addr align in page_size(4K) / phy_addr_in_page = phy_addr & PAGE_SIZE_MASK; page_diff = phy_addr - phy_addr_in_page; size_in_page =((size + page_diff - 1) & PAGE_SIZE_MASK) + PAGE_SIZE; addr = mmap ((void )0, size_in_page, PROT_READ|PROT_WRITE, MAP_SHARED, fd_MEM, phy_addr_in_page); if (addr == MAP_FAILED) return NULL; pNew = (TMMAP_Node_t )malloc(sizeof(TMMAP_Node_t)); if(NULL == pNew) return NULL; pNew->Start_P = phy_addr_in_page; pNew->Start_V = (unsigned int)addr; pNew->length = size_in_page; pNew->refcount = 1; pNew->next = NULL; if(pTMMAPNode == NULL) pTMMAPNode = pNew; else { pTmp = pTMMAPNode; while(pTmp->next != NULL) pTmp = pTmp->next; pTmp->next = pNew; } return (void )(addr+page_diff); } int _memunmapEx(void addr_mapped) { TMMAP_Node_t pPre; TMMAP_Node_t pTmp; if(pTMMAPNode == NULL) return -1; / check if the physical memory space have been mmaped / pTmp = pTMMAPNode; pPre = pTMMAPNode; do { if( ((unsigned int)addr_mapped >= pTmp->Start_V) &&((unsigned int)addr_mapped <= (pTmp->Start_V + pTmp->length)) ) { pTmp->refcount--; / referrence count decrease by 1 / if(0 == pTmp->refcount) { / 引用计数变为0, 被map的内存空间不再使用,此时需要进行munmap回收 / // printf("memunmap(): map node will be remove!\n"); / delete this map node from pMMAPNode / if(pTmp == pTMMAPNode) pTMMAPNode = NULL; else pPre->next = pTmp->next; / munmap / if(munmap((void )pTmp->Start_V, pTmp->length) != 0 ){ // printf("memunmap(): munmap failed!\n"); } free(pTmp); } return 0; } pPre = pTmp; pTmp = pTmp->next; }while(pTmp != NULL); return -1; } int CheckInitFb() { struct fb_var_screeninfo stVarInfo; HIFB_COLORKEY_S stColorKey; HIFB_LAYER_INFO_S stLayerInfo; HI_BOOL Show; HI_BOOL bCompress = HI_FALSE; HIFB_POINT_S stPoint = {0}; int s32Ret = 0; char file[12] = "/dev/fb0"; strcpy(file, "/dev/fb0"); int fdOSD = open(file, O_RDWR, 0); printf("qt fdOSD:%d 1\n",fdOSD); s32Ret = ioctl(fdOSD, FBIOGET_VSCREENINFO, &stVarInfo); if(s32Ret < 0){ close(fdOSD);fdOSD=0; return 0; } printf("qt fdOSD:%d 2\n",fdOSD); int _nWndWidth=1024; int _nWndHeight=768; int maxH=768; int maxW=1024; stColorKey.bKeyEnable = HI_TRUE; stColorKey.u32Key = BK_SCR_TRANS_COLOR_KEY; if (ioctl(fdOSD, FBIOPUT_COLORKEY_HIFB, &stColorKey) < 0) { close(fdOSD);fdOSD=0; return 0; } if (ioctl(fdOSD, FBIOPUT_SCREEN_ORIGIN_HIFB, &stPoint) < 0){ close(fdOSD);fdOSD=0; return 0; } printf("qt fdOSD:%d 5\n",fdOSD); stLayerInfo.BufMode = HIFB_LAYER_BUF_ONE; stLayerInfo.u32Mask = HIFB_LAYERMASK_BUFMODE; // HIFB_LAYERMASK_BUFMODE HIFB_LAYERMASK_ANTIFLICKER_MODE stLayerInfo.u32DisplayWidth = _nWndWidth; stLayerInfo.u32DisplayHeight = _nWndHeight; stLayerInfo. s32XPos = 0; stLayerInfo. s32YPos = 0; stLayerInfo.u32Mask |= HIFB_LAYERMASK_DISPSIZE; //HIFB_LAYERMASK_POS s32Ret = ioctl(fdOSD, FBIOPUT_LAYER_INFO, &stLayerInfo); if(s32Ret < 0){ close(fdOSD);fdOSD=0; return 0; } printf("qt fdOSD:%d 6\n",fdOSD); //printf("Check_InitOSD_ENV: pos6.1 \n"); if (ioctl(fdOSD, FBIOPUT_COMPRESSION_HIFB, &bCompress) < 0) { close(fdOSD);fdOSD=0; return 0; } printf("qt fdOSD:%d 7\n",fdOSD); Show = HI_TRUE; if (ioctl(fdOSD, FBIOPUT_SHOW_HIFB, &Show) < 0){ close(fdOSD);fdOSD=0; return 0; } unsigned short pOSDBuf=NULL; HIFB_BUFFER_S stOsdCanvasBuf; stOsdCanvasBuf.stCanvas.u32Height = maxH; stOsdCanvasBuf.stCanvas.u32Width = maxW; stOsdCanvasBuf.stCanvas.u32Pitch = maxW2; stOsdCanvasBuf.stCanvas.enFmt = HIFB_FMT_ARGB1555;//HIFB_FMT_RGB565 HIFB_FMT_ARGB1555 HIFB_FMT_RGB888 stOsdCanvasBuf.stCanvas.u32PhyAddr=0; pOSDBuf = (HI_U16)_memmapEx(stOsdCanvasBuf.stCanvas.u32PhyAddr, maxWmaxH2); memset(pOSDBuf, BK_SCR_TRANS_COLOR_KEY, stOsdCanvasBuf.stCanvas.u32PitchstOsdCanvasBuf.stCanvas.u32Height); printf("qt fdOSD:%d end \n",fdOSD); return 0; }
int main(int argc, char *argv[]) { signal(SIGINT, signal_handle); signal(SIGTERM, signal_handle); CheckInitFb();
QApplication a(argc, argv);
Widget w;
w.show();
qApp->setFont(QFont("WenQuanYi Zen Hei",16)); int result = a.exec(); while(1){ usleep(100); } return result; }
Markdown 语法
- 加粗**内容**
- 斜体*内容*
- 删除线~~内容~~
- 引用> 引用内容
- 代码`代码`
- 代码块```编程语言↵代码```
- 链接[链接标题](url)
- 无序列表- 内容
- 有序列表1. 内容
- 缩进内容
- 图片![alt](url)
-
2020-10-09 16:52:48
-
2016-06-09 09:30:49
-
2008-08-23 16:16:51
-
2020-10-30 11:02:35
-
2016-10-31 17:04:15
-
2012-12-04 11:52:00
-
2013-03-11 15:15:55
-
2008-08-23 16:07:24
-
2008-12-19 13:05:51
-
2018-11-15 22:00:41
-
02008-11-24 10:13:32
-
2017-01-22 17:21:17
-
2014-12-03 17:17:06
-
2016-01-07 11:47:12
-
2017-02-16 21:32:50
-
2019-12-27 11:18:26
-
2008-08-23 16:14:41
-
2015-11-26 22:22:56
-
2015-03-19 17:26:19
-
5RK3588的DPHY0接lt6911uxe转HDMI抓帧分辨率不对
-
20求rv1106板子的sdk包或者开发板资料
-
10ss928烧录uboot失败
-
10求助,3588调试imx586和ov50c40时,按照瑞芯微的单摄8k配置好设备树后,驱动配置的8k分辨率的,但是只能抓到4k的图,且颜色偏粉
-
50帮忙解决个交叉编译的问题
-
20帮忙交叉编译个源码
-
5Hi3516CV610 如何使用SD卡升级固件
-
5cat /dev/logmpp 报错 <3>[ vi] [func]:vi_send_frame_node [line]:99 [info]:vi pic queue is full!
-
50如何获取vpss chn的图像修改后发送至vo
-
5FPGA通过Bt1120传YUV422数据过来,vi接收不到数据——3516dv500
举报类型
- 内容涉黄/赌/毒
- 内容侵权/抄袭
- 政治相关
- 涉嫌广告
- 侮辱谩骂
- 其他
详细说明