8732
- 收藏
- 点赞
- 分享
- 举报
海思开启fb的代码后台运行,运行qt应用,qt有界面,把这两个代码放到一起qt没界面
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "sample_comm.h"
#include
#include "hifb.h"
static VO_DEV VoDev = SAMPLE_VO_DEV_DHD0;
static struct fb_bitfield s_a32 = {24,8,0};
static struct fb_bitfield s_r32 = {16,8,0};
static struct fb_bitfield s_g32 = {8,8,0};
static struct fb_bitfield s_b32 = {0,8,0};//ARGB
/*static struct fb_bitfield g_r16 = {10, 5, 0};
static struct fb_bitfield g_g16 = {5, 5, 0};
static struct fb_bitfield g_b16 = {0, 5, 0};
static struct fb_bitfield g_a16 = {15, 1, 0};*/
/*#define WIDTH 1920
#define HEIGHT 1080*/
#define WIDTH 1024
#define HEIGHT 720
#define GRAPHICS_LAYER_HC0 2
#define GRAPHICS_LAYER_G0 0
#define GRAPHICS_LAYER_G1 1
typedef struct hiPTHREAD_HIFB_SAMPLE
{
HI_S32 fd;
HI_S32 layer;
HI_S32 ctrlkey;
}PTHREAD_HIFB_SAMPLE_INFO;
HI_VOID SAMPLE_HIFB_HandleSig(HI_S32 signo)
{
if (SIGINT == signo || SIGTSTP == signo)
{
SAMPLE_COMM_SYS_Exit();
printf("\033[0;31mprogram exit abnormally!\033[0;39m\n");
}
exit(0);
}
HI_VOID *init_hifb()
{
HI_S32 s32Ret = HI_SUCCESS;
HI_BOOL bShow;
struct fb_var_screeninfo stVarInfo;
HI_CHAR file[12] = "/dev/fb0";
PTHREAD_HIFB_SAMPLE_INFO pstInfo;
// FILE *fp;
HI_BOOL bEnable;
HIFB_DDRZONE_S stDDRZonePara;
HIFB_LAYER_INFO_S stLayerinfo;
//HIFB_BUFFER_S stCanvasBuf;
// HI_CHAR *pcBuf;
// HI_S32 i = 0;
//pthread_t phifb0 = -1;
//PTHREAD_HIFB_SAMPLE_INFO stInfo0;
HI_U32 u32PicWidth = WIDTH;
HI_U32 u32PicHeight = HEIGHT;
SIZE_S stSize;
VO_LAYER VoLayer = 0;
VO_PUB_ATTR_S stPubAttr;
VO_VIDEO_LAYER_ATTR_S stLayerAttr;
HI_U32 u32VoFrmRate;
VB_CONF_S stVbConf;
HI_U32 u32BlkSize;
/******************************************
step 1: init variable
******************************************/
memset(&stVbConf,0,sizeof(VB_CONF_S));
u32BlkSize = CEILING_2_POWER(u32PicWidth,SAMPLE_SYS_ALIGN_WIDTH)\
* CEILING_2_POWER(u32PicHeight,SAMPLE_SYS_ALIGN_WIDTH) *2;
stVbConf.u32MaxPoolCnt = 128;
stVbConf.astCommPool[0].u32BlkSize = u32BlkSize;
stVbConf.astCommPool[0].u32BlkCnt = 6;
/******************************************
step 2: mpp system init.
******************************************/
s32Ret = SAMPLE_COMM_SYS_Init(&stVbConf);
if (HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("system init failed with %d!\n", s32Ret);
goto SAMPLE_HIFB_NoneBufMode_0;
}
/******************************************
step 3: start vo hd0.
*****************************************/
s32Ret = HI_MPI_VO_UnBindGraphicLayer(GRAPHICS_LAYER_HC0, VoDev);
if (HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("UnBindGraphicLayer failed with %d!\n", s32Ret);
goto SAMPLE_HIFB_NoneBufMode_0;
}
s32Ret = HI_MPI_VO_BindGraphicLayer(GRAPHICS_LAYER_HC0, VoDev);
if (HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("BindGraphicLayer failed with %d!\n", s32Ret);
goto SAMPLE_HIFB_NoneBufMode_0;
}
stPubAttr.enIntfSync = VO_OUTPUT_720P60;
// stPubAttr.enIntfSync = VO_OUTPUT_1080P60;
stPubAttr.enIntfType = VO_INTF_VGA;
stPubAttr.u32BgColor = 0x00ff00;
stLayerAttr.bClusterMode = HI_FALSE;
stLayerAttr.bDoubleFrame = HI_FALSE;
stLayerAttr.enPixFormat = PIXEL_FORMAT_YUV_SEMIPLANAR_420;
s32Ret = SAMPLE_COMM_VO_GetWH(stPubAttr.enIntfSync,&stSize.u32Width,\
&stSize.u32Height,&u32VoFrmRate);
if (HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("get vo wh failed with %d!\n", s32Ret);
goto SAMPLE_HIFB_NoneBufMode_0;
}
memcpy(&stLayerAttr.stImageSize,&stSize,sizeof(stSize));
stLayerAttr.u32DispFrmRt = 30 ;
stLayerAttr.stDispRect.s32X = 0;
stLayerAttr.stDispRect.s32Y = 0;
stLayerAttr.stDispRect.u32Width = stSize.u32Width;
stLayerAttr.stDispRect.u32Height = stSize.u32Height;
printf("hello\n");
s32Ret = SAMPLE_COMM_VO_StartDev(VoDev, &stPubAttr);
if (HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("start vo dev failed with %d!\n", s32Ret);
goto SAMPLE_HIFB_NoneBufMode_0;
}
s32Ret = SAMPLE_COMM_VO_StartLayer(VoLayer, &stLayerAttr);
if (HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("start vo layer failed with %d!\n", s32Ret);
goto SAMPLE_HIFB_NoneBufMode_1;
}
if (stPubAttr.enIntfType & VO_INTF_HDMI)
{
printf("HDMI\n");
s32Ret = SAMPLE_COMM_VO_HdmiStart(stPubAttr.enIntfSync);
if (HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("start HDMI failed with %d!\n", s32Ret);
goto SAMPLE_HIFB_NoneBufMode_2;
}
}
/******************************************
step 4: start hifb.
*****************************************/
//stInfo0.layer = 0;
//stInfo0.fd = -1;
//stInfo0.ctrlkey = 3;
//pthread_create(&phifb0, 0, SAMPLE_HIFB_COMPRESS, (void *)(&stInfo0));
pstInfo.layer = 0;
pstInfo.fd = -1;
pstInfo.ctrlkey = 3;
switch (pstInfo.layer)
{
case GRAPHICS_LAYER_G0:
strcpy(file, "/dev/fb0");
break;
default:
strcpy(file, "/dev/fb0");
break;
}
/* 1. open framebuffer device overlay 0 */
pstInfo.fd = open(file, O_RDWR, 0);
if(pstInfo.fd < 0)
{
SAMPLE_PRT("open %s failed!\n",file);
return HI_NULL;
}
s32Ret = ioctl (pstInfo.fd, FBIOGET_VSCREENINFO, &stVarInfo);
if (s32Ret < 0)
{
SAMPLE_PRT("FBIOGET_VSCREENINFO failed!\n");
close(pstInfo.fd);
return HI_NULL;
}
stVarInfo.red = s_r32;
stVarInfo.green = s_g32;
stVarInfo.blue = s_b32;
stVarInfo.transp = s_a32;
stVarInfo.bits_per_pixel = 32;
stVarInfo.xres=WIDTH;
stVarInfo.yres=HEIGHT;
stVarInfo.activate=FB_ACTIVATE_NOW;
stVarInfo.xres_virtual=WIDTH;
stVarInfo.yres_virtual = HEIGHT;
stVarInfo.xoffset=0;
stVarInfo.yoffset=0;
s32Ret = ioctl (pstInfo.fd, FBIOPUT_VSCREENINFO, &stVarInfo);
if (s32Ret < 0)
{
SAMPLE_PRT("FBIOPUT_VSCREENINFO failed!\n");
close(pstInfo.fd);
return HI_NULL;
}
s32Ret = ioctl(pstInfo.fd, FBIOGET_LAYER_INFO, &stLayerinfo);
if (s32Ret < 0)
{
SAMPLE_PRT("FBIOGET_LAYER_INFO failed!\n");
close(pstInfo.fd);
return HI_NULL;
}
stLayerinfo.u32Mask = 0;
stLayerinfo.BufMode = HIFB_LAYER_BUF_NONE;
stLayerinfo.u32Mask |= HIFB_LAYERMASK_BUFMODE;
s32Ret = ioctl(pstInfo.fd, FBIOPUT_LAYER_INFO, &stLayerinfo);
if (s32Ret < 0)
{
SAMPLE_PRT("FBIOPUT_LAYER_INFO failed!\n");
close(pstInfo.fd);
return HI_NULL;
}
stDDRZonePara.u32StartSection = 0;
stDDRZonePara.u32ZoneNums = 15;
s32Ret = ioctl(pstInfo.fd, FBIOPUT_MDDRDETECT_HIFB, &stDDRZonePara);
if (s32Ret < 0)
{
SAMPLE_PRT("FBIOPUT_MDDRDETECT_HIFB failed!\n");
close(pstInfo.fd);
return HI_NULL;
}
/* 2. open compress */
//bEnable = HI_TRUE;
bEnable=HI_FALSE;
s32Ret = ioctl(pstInfo.fd, FBIOPUT_COMPRESSION_HIFB, &bEnable);
if (s32Ret < 0)
{
SAMPLE_PRT("FBIOPUT_COMPRESSION_HIFB failed!\n");
close(pstInfo.fd);
return HI_NULL;
}
bShow = HI_TRUE;
if (ioctl(pstInfo.fd, FBIOPUT_SHOW_HIFB, &bShow) < 0)
{
printf("FBIOPUT_SHOW_HIFB failed!\n");
return HI_NULL;
}
SAMPLE_HIFB_NoneBufMode_2:
SAMPLE_COMM_VO_StopLayer(VoLayer);
SAMPLE_HIFB_NoneBufMode_1:
SAMPLE_COMM_VO_StopDev(VoDev);
SAMPLE_HIFB_NoneBufMode_0:
SAMPLE_COMM_SYS_Exit();
}
int main(int argc,char **argv)
{
signal(SIGINT, SAMPLE_HIFB_HandleSig);
signal(SIGTERM, SAMPLE_HIFB_HandleSig);
printf("qt \n");
QApplication app(argc,argv);
app.setApplicationName("panorama");
init_hifb();
mywidget w;
printf("w.show\n");
w.show();
printf("w.show\n");
return app.exec();
}
init_hifb();单独做一个程序后台运行就可以显示qt界面放到一起就不行了。很奇怪。
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "sample_comm.h"
#include
#include "hifb.h"
static VO_DEV VoDev = SAMPLE_VO_DEV_DHD0;
static struct fb_bitfield s_a32 = {24,8,0};
static struct fb_bitfield s_r32 = {16,8,0};
static struct fb_bitfield s_g32 = {8,8,0};
static struct fb_bitfield s_b32 = {0,8,0};//ARGB
/*static struct fb_bitfield g_r16 = {10, 5, 0};
static struct fb_bitfield g_g16 = {5, 5, 0};
static struct fb_bitfield g_b16 = {0, 5, 0};
static struct fb_bitfield g_a16 = {15, 1, 0};*/
/*#define WIDTH 1920
#define HEIGHT 1080*/
#define WIDTH 1024
#define HEIGHT 720
#define GRAPHICS_LAYER_HC0 2
#define GRAPHICS_LAYER_G0 0
#define GRAPHICS_LAYER_G1 1
typedef struct hiPTHREAD_HIFB_SAMPLE
{
HI_S32 fd;
HI_S32 layer;
HI_S32 ctrlkey;
}PTHREAD_HIFB_SAMPLE_INFO;
HI_VOID SAMPLE_HIFB_HandleSig(HI_S32 signo)
{
if (SIGINT == signo || SIGTSTP == signo)
{
SAMPLE_COMM_SYS_Exit();
printf("\033[0;31mprogram exit abnormally!\033[0;39m\n");
}
exit(0);
}
HI_VOID *init_hifb()
{
HI_S32 s32Ret = HI_SUCCESS;
HI_BOOL bShow;
struct fb_var_screeninfo stVarInfo;
HI_CHAR file[12] = "/dev/fb0";
PTHREAD_HIFB_SAMPLE_INFO pstInfo;
// FILE *fp;
HI_BOOL bEnable;
HIFB_DDRZONE_S stDDRZonePara;
HIFB_LAYER_INFO_S stLayerinfo;
//HIFB_BUFFER_S stCanvasBuf;
// HI_CHAR *pcBuf;
// HI_S32 i = 0;
//pthread_t phifb0 = -1;
//PTHREAD_HIFB_SAMPLE_INFO stInfo0;
HI_U32 u32PicWidth = WIDTH;
HI_U32 u32PicHeight = HEIGHT;
SIZE_S stSize;
VO_LAYER VoLayer = 0;
VO_PUB_ATTR_S stPubAttr;
VO_VIDEO_LAYER_ATTR_S stLayerAttr;
HI_U32 u32VoFrmRate;
VB_CONF_S stVbConf;
HI_U32 u32BlkSize;
/******************************************
step 1: init variable
******************************************/
memset(&stVbConf,0,sizeof(VB_CONF_S));
u32BlkSize = CEILING_2_POWER(u32PicWidth,SAMPLE_SYS_ALIGN_WIDTH)\
* CEILING_2_POWER(u32PicHeight,SAMPLE_SYS_ALIGN_WIDTH) *2;
stVbConf.u32MaxPoolCnt = 128;
stVbConf.astCommPool[0].u32BlkSize = u32BlkSize;
stVbConf.astCommPool[0].u32BlkCnt = 6;
/******************************************
step 2: mpp system init.
******************************************/
s32Ret = SAMPLE_COMM_SYS_Init(&stVbConf);
if (HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("system init failed with %d!\n", s32Ret);
goto SAMPLE_HIFB_NoneBufMode_0;
}
/******************************************
step 3: start vo hd0.
*****************************************/
s32Ret = HI_MPI_VO_UnBindGraphicLayer(GRAPHICS_LAYER_HC0, VoDev);
if (HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("UnBindGraphicLayer failed with %d!\n", s32Ret);
goto SAMPLE_HIFB_NoneBufMode_0;
}
s32Ret = HI_MPI_VO_BindGraphicLayer(GRAPHICS_LAYER_HC0, VoDev);
if (HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("BindGraphicLayer failed with %d!\n", s32Ret);
goto SAMPLE_HIFB_NoneBufMode_0;
}
stPubAttr.enIntfSync = VO_OUTPUT_720P60;
// stPubAttr.enIntfSync = VO_OUTPUT_1080P60;
stPubAttr.enIntfType = VO_INTF_VGA;
stPubAttr.u32BgColor = 0x00ff00;
stLayerAttr.bClusterMode = HI_FALSE;
stLayerAttr.bDoubleFrame = HI_FALSE;
stLayerAttr.enPixFormat = PIXEL_FORMAT_YUV_SEMIPLANAR_420;
s32Ret = SAMPLE_COMM_VO_GetWH(stPubAttr.enIntfSync,&stSize.u32Width,\
&stSize.u32Height,&u32VoFrmRate);
if (HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("get vo wh failed with %d!\n", s32Ret);
goto SAMPLE_HIFB_NoneBufMode_0;
}
memcpy(&stLayerAttr.stImageSize,&stSize,sizeof(stSize));
stLayerAttr.u32DispFrmRt = 30 ;
stLayerAttr.stDispRect.s32X = 0;
stLayerAttr.stDispRect.s32Y = 0;
stLayerAttr.stDispRect.u32Width = stSize.u32Width;
stLayerAttr.stDispRect.u32Height = stSize.u32Height;
printf("hello\n");
s32Ret = SAMPLE_COMM_VO_StartDev(VoDev, &stPubAttr);
if (HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("start vo dev failed with %d!\n", s32Ret);
goto SAMPLE_HIFB_NoneBufMode_0;
}
s32Ret = SAMPLE_COMM_VO_StartLayer(VoLayer, &stLayerAttr);
if (HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("start vo layer failed with %d!\n", s32Ret);
goto SAMPLE_HIFB_NoneBufMode_1;
}
if (stPubAttr.enIntfType & VO_INTF_HDMI)
{
printf("HDMI\n");
s32Ret = SAMPLE_COMM_VO_HdmiStart(stPubAttr.enIntfSync);
if (HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("start HDMI failed with %d!\n", s32Ret);
goto SAMPLE_HIFB_NoneBufMode_2;
}
}
/******************************************
step 4: start hifb.
*****************************************/
//stInfo0.layer = 0;
//stInfo0.fd = -1;
//stInfo0.ctrlkey = 3;
//pthread_create(&phifb0, 0, SAMPLE_HIFB_COMPRESS, (void *)(&stInfo0));
pstInfo.layer = 0;
pstInfo.fd = -1;
pstInfo.ctrlkey = 3;
switch (pstInfo.layer)
{
case GRAPHICS_LAYER_G0:
strcpy(file, "/dev/fb0");
break;
default:
strcpy(file, "/dev/fb0");
break;
}
/* 1. open framebuffer device overlay 0 */
pstInfo.fd = open(file, O_RDWR, 0);
if(pstInfo.fd < 0)
{
SAMPLE_PRT("open %s failed!\n",file);
return HI_NULL;
}
s32Ret = ioctl (pstInfo.fd, FBIOGET_VSCREENINFO, &stVarInfo);
if (s32Ret < 0)
{
SAMPLE_PRT("FBIOGET_VSCREENINFO failed!\n");
close(pstInfo.fd);
return HI_NULL;
}
stVarInfo.red = s_r32;
stVarInfo.green = s_g32;
stVarInfo.blue = s_b32;
stVarInfo.transp = s_a32;
stVarInfo.bits_per_pixel = 32;
stVarInfo.xres=WIDTH;
stVarInfo.yres=HEIGHT;
stVarInfo.activate=FB_ACTIVATE_NOW;
stVarInfo.xres_virtual=WIDTH;
stVarInfo.yres_virtual = HEIGHT;
stVarInfo.xoffset=0;
stVarInfo.yoffset=0;
s32Ret = ioctl (pstInfo.fd, FBIOPUT_VSCREENINFO, &stVarInfo);
if (s32Ret < 0)
{
SAMPLE_PRT("FBIOPUT_VSCREENINFO failed!\n");
close(pstInfo.fd);
return HI_NULL;
}
s32Ret = ioctl(pstInfo.fd, FBIOGET_LAYER_INFO, &stLayerinfo);
if (s32Ret < 0)
{
SAMPLE_PRT("FBIOGET_LAYER_INFO failed!\n");
close(pstInfo.fd);
return HI_NULL;
}
stLayerinfo.u32Mask = 0;
stLayerinfo.BufMode = HIFB_LAYER_BUF_NONE;
stLayerinfo.u32Mask |= HIFB_LAYERMASK_BUFMODE;
s32Ret = ioctl(pstInfo.fd, FBIOPUT_LAYER_INFO, &stLayerinfo);
if (s32Ret < 0)
{
SAMPLE_PRT("FBIOPUT_LAYER_INFO failed!\n");
close(pstInfo.fd);
return HI_NULL;
}
stDDRZonePara.u32StartSection = 0;
stDDRZonePara.u32ZoneNums = 15;
s32Ret = ioctl(pstInfo.fd, FBIOPUT_MDDRDETECT_HIFB, &stDDRZonePara);
if (s32Ret < 0)
{
SAMPLE_PRT("FBIOPUT_MDDRDETECT_HIFB failed!\n");
close(pstInfo.fd);
return HI_NULL;
}
/* 2. open compress */
//bEnable = HI_TRUE;
bEnable=HI_FALSE;
s32Ret = ioctl(pstInfo.fd, FBIOPUT_COMPRESSION_HIFB, &bEnable);
if (s32Ret < 0)
{
SAMPLE_PRT("FBIOPUT_COMPRESSION_HIFB failed!\n");
close(pstInfo.fd);
return HI_NULL;
}
bShow = HI_TRUE;
if (ioctl(pstInfo.fd, FBIOPUT_SHOW_HIFB, &bShow) < 0)
{
printf("FBIOPUT_SHOW_HIFB failed!\n");
return HI_NULL;
}
SAMPLE_HIFB_NoneBufMode_2:
SAMPLE_COMM_VO_StopLayer(VoLayer);
SAMPLE_HIFB_NoneBufMode_1:
SAMPLE_COMM_VO_StopDev(VoDev);
SAMPLE_HIFB_NoneBufMode_0:
SAMPLE_COMM_SYS_Exit();
}
int main(int argc,char **argv)
{
signal(SIGINT, SAMPLE_HIFB_HandleSig);
signal(SIGTERM, SAMPLE_HIFB_HandleSig);
printf("qt \n");
QApplication app(argc,argv);
app.setApplicationName("panorama");
init_hifb();
mywidget w;
printf("w.show\n");
w.show();
printf("w.show\n");
return app.exec();
}
init_hifb();单独做一个程序后台运行就可以显示qt界面放到一起就不行了。很奇怪。
我来回答
回答3个
时间排序
认可量排序
认可0
认可0
认可0
或将文件直接拖到这里
悬赏:
E币
网盘
* 网盘链接:
* 提取码:
悬赏:
E币
Markdown 语法
- 加粗**内容**
- 斜体*内容*
- 删除线~~内容~~
- 引用> 引用内容
- 代码`代码`
- 代码块```编程语言↵代码```
- 链接[链接标题](url)
- 无序列表- 内容
- 有序列表1. 内容
- 缩进内容
- 图片![alt](url)
相关问答
-
2021-02-04 16:26:35
-
2019-07-01 17:21:35
-
2016-06-15 00:27:43
-
2016-10-14 12:12:02
-
2018-03-21 11:08:20
-
2013-07-22 21:18:28
-
2013-07-22 21:21:59
-
2021-05-31 17:34:29
-
2016-06-23 21:49:13
-
2017-04-07 17:56:51
-
2022-10-13 10:04:52
-
2013-07-22 11:03:44
-
162014-05-21 14:55:10
-
2017-10-26 09:55:50
-
2017-09-26 14:28:34
-
2020-07-06 13:59:49
-
2020-10-22 15:31:02
-
2015-07-28 00:29:44
-
2015-12-01 16:21:53
无更多相似问答 去提问
点击登录
-- 积分
-- E币
提问
—
收益
—
被采纳
—
我要提问
切换马甲
上一页
下一页
悬赏问答
-
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
-
50SS928 运行PQtools 拼接 推到设备里有一半画面会异常
-
53536AV100的sample_vdec输出到CVBS显示
-
10海思板子mpp怎么在vi阶段改变视频数据尺寸
-
10HI3559AV100 多摄像头同步模式
-
9海思ss928单路摄像头vio中加入opencv处理并显示
-
10EB-RV1126-BC-191板子运行自己编码的程序
举报反馈
举报类型
- 内容涉黄/赌/毒
- 内容侵权/抄袭
- 政治相关
- 涉嫌广告
- 侮辱谩骂
- 其他
详细说明
提醒
你的问题还没有最佳答案,是否结题,结题后将扣除20%的悬赏金
取消
确认
提醒
你的问题还没有最佳答案,是否结题,结题后将根据回答情况扣除相应悬赏金(1回答=1E币)
取消
确认