代码之家  ›  专栏  ›  技术社区  ›  Mich

有没有什么方法可以将EGL绘制到/dev/fb1而不是/dev/fb0,而不必在Raspberry Pi上复制数据?

  •  0
  • Mich  · 技术社区  · 6 年前

    我在这里找到了一些信息,特别是EGL没有使用/dev/fb*层 https://www.raspberrypi.org/forums/viewtopic.php?t=58952

    但是,我想知道是否有办法交换/dev/fb0和/dev/fb1,或者完全摆脱/dev/fb0?

    /dev/fb0是hdmi输出,/dev/fb1是SPI显示

    我有以下代码 mmap 帧缓冲区,但他们是不同的颜色深度,所以我不能memcpy它和复制像素的像素是痛苦的缓慢

    有没有更好的办法?

    uint16_t *fbp0;
    uint16_t *fbp1;
    DISPMANX_DISPLAY_HANDLE_T display;
    DISPMANX_RESOURCE_HANDLE_T resourceHandle;
    VC_RECT_T rect;
    struct fb_fix_screeninfo finfo;
    uint32_t pixels;
    const char *device = "/dev/fb1";
    int fbfd = open(device, O_RDWR);
    if (fbfd == -1) {printf("cannot open framebuffer device");return;}
    if (ioctl(fbfd, FBIOGET_FSCREENINFO, &finfo) == -1) {printf("cannot get framebuffer fixed information");return;}
    struct fb_var_screeninfo vinfo;
    if (ioctl(fbfd, FBIOGET_VSCREENINFO, &vinfo) == -1) {printf("cannot get framebuffer variable information");return;}
    if((vinfo.xres * 2) != finfo.line_length) {printf("assumption failed ... framebuffer lines are padded");return;}
    if ((vinfo.xres % 16) != 0) {printf("framebuffer width must be a multiple of 16");return;}
    if (vinfo.bits_per_pixel != 16){printf("framebuffer is not 16 bits per pixel");return;}
    fbp1 = (uint16_t*)mmap(0,finfo.smem_len,PROT_READ | PROT_WRITE,MAP_SHARED,fbfd,0);
    if (fbp1 == MAP_FAILED){printf("cannot map framebuffer into memory");return;}
    memset(fbp1, 0, finfo.smem_len);vc_dispmanx_resource_create(VC_IMAGE_RGB565,vinfo.xres,vinfo.yres,  &image_ptr);
    device = "/dev/fb0";
    fbfd = open(device, O_RDWR);
    if (fbfd == -1) {printf("cannot open framebuffer device"); return;}
    if (ioctl(fbfd, FBIOGET_FSCREENINFO, &finfo) == -1) {printf("cannot get framebuffer fixed information"); return;}
    if (ioctl(fbfd, FBIOGET_VSCREENINFO, &vinfo) == -1) {printf("cannot get framebuffer variable information"); return;}
    if ((vinfo.xres % 16) != 0) {printf("framebuffer width must be a multiple of 16"); return;}
    fbp0 = (uint16_t*)mmap(0, finfo.smem_len, PROT_READ | PROT_WRITE, MAP_SHARED, fbfd, 0);
    if (fbp0 == MAP_FAILED){printf("cannot map framebuffer into memory"); return;}
    memset(fbp0, 0, finfo.smem_len);
    
    1 回复  |  直到 6 年前
        1
  •  0
  •   Mich    6 年前

    https://github.com/juj/fbcp-ili9341

    它将HDMI帧缓冲区复制到SPI显示器上,以60hz的频率显示,不需要安装原始的SPI river,最好的是它在用户空间中运行