kinas299

kinas299

0个粉丝

3

问答

0

专栏

0

资料

kinas299  发布于  2017-09-29 17:00:26
采纳率 0%
3个问答
3703

Hi3536 HDMI模式不出QT界面

 

HI_VOID *SAMPLE_HIFB_COMPRESS(void *pData)
{
    HI_S32 s32Ret = HI_SUCCESS;

    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;

    pstInfo = (PTHREAD_HIFB_SAMPLE_INFO *)pData;
    switch (pstInfo->layer)
        {
                case GRAPHICS_LAYER_G0:
                        strcpy(file, "/dev/fb0");
                        break;
        case GRAPHICS_LAYER_G1:
            strcpy(file, "/dev/fb1");
                        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;
    s32Ret = ioctl(pstInfo->fd, FBIOPUT_COMPRESSION_HIFB, &bEnable);
    if (s32Ret < 0)
    {
        SAMPLE_PRT("FBIOPUT_COMPRESSION_HIFB failed!\n");
       close(pstInfo->fd);
       return HI_NULL;
    }

    if (HI_FAILURE == HI_MPI_SYS_MmzAlloc(&(stCanvasBuf.stCanvas.u32PhyAddr), ((void**)&pcBuf),
            NULL, NULL, WIDTH*HEIGHT*4))
    {
        SAMPLE_PRT("allocate memory failed\n");
        close(pstInfo->fd);
        return HI_NULL;
    }
    stCanvasBuf.stCanvas.u32Height = HEIGHT;
    stCanvasBuf.stCanvas.u32Width = WIDTH;
    stCanvasBuf.stCanvas.u32Pitch = WIDTH * 4;
    stCanvasBuf.stCanvas.enFmt = HIFB_FMT_ARGB8888;
    stCanvasBuf.UpdateRect.x = 0;
    stCanvasBuf.UpdateRect.y = 0;
    stCanvasBuf.UpdateRect.w = WIDTH;
    stCanvasBuf.UpdateRect.h = HEIGHT;
       
#ifdef DRAWBMP
    fp = fopen(SAMPLE_IMAGE2_PATH, "rb");
    if (HI_NULL == fp)
    {
        SAMPLE_PRT("fopen file failed!\n");
        HI_MPI_SYS_MmzFree(stCanvasBuf.stCanvas.u32PhyAddr, pcBuf);
        close(pstInfo->fd);
        return HI_NULL;
    }
    memset(pcBuf, 0, stCanvasBuf.stCanvas.u32Pitch * stCanvasBuf.stCanvas.u32Height);
    fread(pcBuf, 1, stCanvasBuf.stCanvas.u32Pitch * stCanvasBuf.stCanvas.u32Height, fp);
    fclose(fp);
#endif

    s32Ret = ioctl(pstInfo->fd, FBIO_REFRESH, &stCanvasBuf);
    if (s32Ret < 0)
    {
        SAMPLE_PRT("FBIO_REFRESH failed\n");
        HI_MPI_SYS_MmzFree(stCanvasBuf.stCanvas.u32PhyAddr, pcBuf);
        close(pstInfo->fd);
        return HI_NULL;
    }
    while(1)
    {
        if ('q' == gs_cExitFlag)
        {
            printf("process exit...\n");
            break;
        }
#ifdef DRAWBOX      
        printf("process DRAWBOX...\n");
        i++;
        stCanvasBuf.UpdateRect.x = WIDTH / 4;
        stCanvasBuf.UpdateRect.y = HEIGHT / 4;
        stCanvasBuf.UpdateRect.w = WIDTH / 2;
        stCanvasBuf.UpdateRect.h = HEIGHT / 2;
        DrawBox(stCanvasBuf.UpdateRect.x, stCanvasBuf.UpdateRect.y,\
            stCanvasBuf.UpdateRect.w, stCanvasBuf.UpdateRect.h, \
            stCanvasBuf.stCanvas.u32Pitch, pcBuf, 0xffff0000);
        sleep(2);
        stCanvasBuf.UpdateRect.x = WIDTH * 3/8;
        stCanvasBuf.UpdateRect.y = HEIGHT * 3/8;
        stCanvasBuf.UpdateRect.w = WIDTH / 4;
        stCanvasBuf.UpdateRect.h = HEIGHT / 4;
        DrawBox(stCanvasBuf.UpdateRect.x, stCanvasBuf.UpdateRect.y,\
            stCanvasBuf.UpdateRect.w, stCanvasBuf.UpdateRect.h, \
            stCanvasBuf.stCanvas.u32Pitch, pcBuf, 0xff00ff00);
#endif
        sleep(2);
   
    }
    HI_MPI_SYS_MmzFree(stCanvasBuf.stCanvas.u32PhyAddr, pcBuf);
    close(pstInfo->fd);
    return HI_NULL;
}

HI_S32 SAMPLE_HIFB_Compression(HI_VOID)
{
        HI_S32 s32Ret = HI_SUCCESS;
    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_720P50;
    //stPubAttr.enIntfType = VO_INTF_VGA |VO_INTF_HDMI;
    stPubAttr.enIntfType = VO_INTF_HDMI;
    //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;

    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;
        }

   
#ifndef HDMI   
    if (stPubAttr.enIntfType & VO_INTF_HDMI)
    {
        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;
            }
    }
#endif

    VoLayer = SAMPLE_VO_LAYER_VHD0;
    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;
    }

               
#ifdef HI_FPGA
    /***************************************************
    step 6: start  HD1 with 1 windows and bind to vpss
    ***************************************************/   
    /**************start Dev****************************/
    VoDev = SAMPLE_VO_DEV_DHD1;   
    //stVoPubAttr.enIntfSync = VO_OUTPUT_1080P30;
    stPubAttr.enIntfSync = VO_OUTPUT_1024x768_60;
    stPubAttr.enIntfType = VO_INTF_HDMI;
    stPubAttr.u32BgColor = 0x000000ff;
    s32Ret = SAMPLE_COMM_VO_StartDev(VoDev, &stPubAttr);   
    if (HI_SUCCESS != s32Ret)
    {
        SAMPLE_PRT("SAMPLE_COMM_VO_StartDev failed!\n");
        //goto END_PREVIEW_6;
    }
    /**************start Layer****************************/
    VoLayer = SAMPLE_VO_LAYER_VHD1;
    stLayerAttr.bClusterMode = HI_FALSE;
    stLayerAttr.bDoubleFrame = HI_FALSE;
    stLayerAttr.enPixFormat = SAMPLE_PIXEL_FORMAT;   
    s32Ret = SAMPLE_COMM_VO_GetWH(stPubAttr.enIntfSync, \
        &stLayerAttr.stDispRect.u32Width, &stLayerAttr.stDispRect.u32Height, &stLayerAttr.u32DispFrmRt);
    if (s32Ret != HI_SUCCESS)
    {
        SAMPLE_PRT("failed with %#x!\n", s32Ret);
        //goto  END_PREVIEW_7;
    }
    stLayerAttr.stImageSize.u32Width = stLayerAttr.stDispRect.u32Width;
    stLayerAttr.stImageSize.u32Height = stLayerAttr.stDispRect.u32Height;

    s32Ret = SAMPLE_COMM_VO_StartLayer(VoLayer, &stLayerAttr);   
    if (HI_SUCCESS != s32Ret)
    {
       SAMPLE_PRT("SAMPLE_COMM_VO_StartLayer failed!\n");
       //goto END_PREVIEW_8;
    }   
   
#endif

    /******************************************
     step 4:  start hifb.
    *****************************************/

    stInfo0.layer   =  0;
    stInfo0.fd      = -1;
    stInfo0.ctrlkey =  3;
    pthread_create(&phifb0, 0, SAMPLE_HIFB_COMPRESS, (void *)(&stInfo0));
    //SAMPLE_HIFB_COMPRESSExx((void *)(&stInfo0));

    //stInfo0.layer   =  1;
    //stInfo0.fd      = -1;
    //stInfo0.ctrlkey =  3;
    //pthread_create(&phifb0, 0, SAMPLE_HIFB_COMPRESSEx, (void *)(&stInfo0));
    //SAMPLE_HIFB_COMPRESSExx((void *)(&stInfo0));
       
    while(1)
    {
        HI_CHAR ch;

        printf("press 'q' to exit this sample.\n");
        ch = getchar();
        if (10 == ch)
        {
            continue;
        }
        getchar();
        if ('q' == ch)
        {
            gs_cExitFlag = ch;
            break;
        }
        else
        {
            printf("input invaild! please try again.\n");
        }
    }
    if(-1 != phifb0)
    {
        pthread_join(phifb0,0);
    }
   
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();

    return s32Ret;
}
=======================================================
./sample_hifb &
cat /proc/umap/hifb0
layer name                       :layer_0
Open count                       :2
Show state                       :ON
Start position                   :(0, 0)
xres, yres                       :(1280, 720)
xres_virtual, yres_virtual       :(1280, 720)
xoffset, yoffset                 :(0, 0)
fix.line_length                  :2560
Mem size:                        :32400 KB
Layer Scale (hw):                :NO
ColorFormat:                     :ARGB1555
Alpha Enable                     :ON
AlphaChannel Enable              :OFF
Alpha0, Alpha1                   :0, 255
Alpha Global                     :255
Colorkey Enable                  :OFF
Colorkey value                   :0x0
Deflicker Mode:                  :NONE
Deflicker Level:                 :AUTO
Display Buffer mode              :unkown
Displaying addr (register)       :0x50233000
display buffer[0] addr           :0x50233000
display buffer[1] addr           :0x503f5000
displayrect                      :(1280, 720)
screenrect                       :(1280, 720)
device max resolution            :1280, 720
IsNeedFlip(2buf)                 :NO
BufferIndexDisplaying(2buf)      :0
refresh request num(2buf)        :0
switch buf num(2buf)             :0
union rect (2buf)                :(0,0,0,0)
canavas updated addr             :0x0
canavas updated (x, y, w, h)     :(0,0,0,0)
canvas width                     :0
canvas height                    :0
canvas pitch                     :0
canvas format                    :RGB565
IsCompress                       :NO
Is DDR Dettect                   :NO
DDR Detect Zones                 :0
===========================================================
./sample_hifb
cat /proc/umap/hifb0
layer name                       :layer_0
Open count                       :1
Show state                       :ON
Start position                   :(0, 0)
xres, yres                       :(1280, 720)
xres_virtual, yres_virtual       :(1280, 720)
xoffset, yoffset                 :(0, 0)
fix.line_length                  :5120
Mem size:                        :32400 KB
Layer Scale (hw):                :NO
ColorFormat:                     :ARGB8888
Alpha Enable                     :ON
AlphaChannel Enable              :OFF
Alpha0, Alpha1                   :0, 255
Alpha Global                     :255
Colorkey Enable                  :OFF
Colorkey value                   :0x0
Deflicker Mode:                  :NONE
Deflicker Level:                 :AUTO
Display Buffer mode              :single
Displaying addr (register)       :0x53fb3000
display buffer[0] addr           :0x50233000
display buffer[1] addr           :0x505b7000
displayrect                      :(1280, 720)
screenrect                       :(1280, 720)
device max resolution            :1280, 720
IsNeedFlip(2buf)                 :NO
BufferIndexDisplaying(2buf)      :0
refresh request num(2buf)        :0
switch buf num(2buf)             :0
union rect (2buf)                :(0,0,0,0)
canavas updated addr             :0x53fb3000
canavas updated (x, y, w, h)     :(0,0,1280,720)
canvas width                     :1280
canvas height                    :720
canvas pitch                     :5120
canvas format                    :ARGB8888
IsCompress                       :YES
Is DDR Dettect                   :YES
DDR Detect Zones                 :15

通过分析可以看出hifb0参数有异常
问题总结:
1、为什么HDMI模式输出时,前台打开fb0参数正常,后台打开则参数异常?
2、同样的代码切换为VGA模式,后台打开,则QT界面可以显示
我来回答
回答0个
时间排序
认可量排序
易百纳技术社区暂无数据
或将文件直接拖到这里
悬赏:
E币
网盘
* 网盘链接:
* 提取码:
悬赏:
E币

Markdown 语法

  • 加粗**内容**
  • 斜体*内容*
  • 删除线~~内容~~
  • 引用> 引用内容
  • 代码`代码`
  • 代码块```编程语言↵代码```
  • 链接[链接标题](url)
  • 无序列表- 内容
  • 有序列表1. 内容
  • 缩进内容
  • 图片![alt](url)
+ 添加网盘链接/附件

Markdown 语法

  • 加粗**内容**
  • 斜体*内容*
  • 删除线~~内容~~
  • 引用> 引用内容
  • 代码`代码`
  • 代码块```编程语言↵代码```
  • 链接[链接标题](url)
  • 无序列表- 内容
  • 有序列表1. 内容
  • 缩进内容
  • 图片![alt](url)
相关问答
无更多相似问答 去提问
举报反馈

举报类型

  • 内容涉黄/赌/毒
  • 内容侵权/抄袭
  • 政治相关
  • 涉嫌广告
  • 侮辱谩骂
  • 其他

详细说明

易百纳技术社区