初始化屏幕

在QT应用程序执行前,需要先初始化屏幕,否则无法正常显示。屏幕初始化可以参考JpegPlayer/的logo.c。

  • 将document/JpegPlayer.rar下载到Linux系统下,并解压到project同级目录下:

  • 进入解压目录,并将logo.c拷贝为disp_init.c:

  • 修改disp_init.c,将初始化以外的代码删除:

#define TEST_GFX    0


struct fb_var_screeninfo vinfo = {0};
struct fb_fix_screeninfo finfo = {0};
MI_FB_DisplayLayerAttr_t g_stLayerInfo = {0};

//Start of frame buffer mem
static char *frameBuffer = NULL;

#include <sched.h>
#include <pthread.h>

int main(int argc, char **argv)
{
    const char *devfile = "/dev/fb0";
    long int screensize = 0;
    int fbFd = 0;
    BITMAP logo;
    BITMAP fb;
    MI_DISP_PubAttr_t stDispPubAttr = {0};
    memset(&g_stLayerInfo, 0, sizeof(MI_FB_DisplayLayerAttr_t));

    sstar_disp_init(&stDispPubAttr);

    fbFd = open(devfile, O_RDWR);

    if(fbFd == -1)
    {
        perror("Error: cannot open framebuffer device");
        exit(1);
    }

    int show = 0;

    if(ioctl(fbFd, FBIOSET_SHOW, &show) < 0)
    {
        return (0);
    }

    //get fb_fix_screeninfo
    if(ioctl(fbFd, FBIOGET_FSCREENINFO, &finfo) == -1)
    {
        perror("Error reading fixed information");
        exit(2);
    }

    //get fb_var_screeninfo
    if(ioctl(fbFd, FBIOGET_VSCREENINFO, &vinfo) == -1)
    {
        perror("Error reading variable information");
        exit(3);
    }
    //get FBIOGET_DISPLAYLAYER_ATTRIBUTES
    if(ioctl(fbFd, FBIOGET_DISPLAYLAYER_ATTRIBUTES, &g_stLayerInfo) == -1)
    {
        perror("3Error reading variable information");
        exit(3);
    }


SHOW:

    //Pandisplay
    if(ioctl(fbFd, FBIOPAN_DISPLAY, &vinfo) == -1)
    {
        perror("Error: failed to FBIOPAN_DISPLAY");
        exit(5);
    }
    /*不要让他退出,否则系统会关闭fbFd,读取初始化失败,可通过后台运行的方式实现*/
    while(1)
    {
        sleep(1);
    }

#if (0)
    sstar_disp_Deinit(&stDispPubAttr);
    unmap buffer
    munmap(frameBuffer, screensize);
    fclose(fp);
    close(fbFd);
#endif

    return 0;
}
  • 将已经调好的屏参头文件拷贝到JpegPlayer目录下:

  • 修改sstardisp.c,将屏参头文件包含:

#define UI_1024_600 1
#define USE_MIPI    0


#if UI_1024_600
#include "SAT070CP50_1024x600.h"
#else
#if USE_MIPI
#include "EK79007_1024x600_MIPI.h"
#else
#include "SAT070AT50_800x480.h"
#endif
#endif

// loacl play res
#if UI_1024_600
//#define LOCAL_VIDEO_W  822
//#define LOCAL_VIDEO_H  464
//#define LOCAL_VIDEO_X  100
//#define LOCAL_VIDEO_Y  60
#define LOCAL_VIDEO_W  1024
#define LOCAL_VIDEO_H  600
#define LOCAL_VIDEO_X  0
#define LOCAL_VIDEO_Y  0
#else
//#define LOCAL_VIDEO_W  640
//#define LOCAL_VIDEO_H  360
//#define LOCAL_VIDEO_X  100
//#define LOCAL_VIDEO_Y  60
#define LOCAL_VIDEO_W  800
#define LOCAL_VIDEO_H  480
#define LOCAL_VIDEO_X  0
#define LOCAL_VIDEO_Y  0
#endif
  • 修改 makefile
LOGO_SRC:=disp_init.c  sstardisp.c bmp.c  jpeg.c common/verify_gfx.c common/blitutil.c
LOGO:=disp_init
  • 编译,将在目录下生成disp_init可执行文件:
    # make
文档更新时间: 2020-12-29 14:35   作者:Aeeditor