有没有办法将 EGL 绘制到 /dev/fb1 而不是 /dev/fb0,而无需在树莓派上复制数据

Is there any way to draw EGL to /dev/fb1 instead of /dev/fb0 without copying data on a Raspberry Pi?

本文关键字:dev 复制 数据 EGL 绘制 有没有 fb1 fb0      更新时间:2023-10-16

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

但是,我想知道是否有办法交换/dev/fb0 和/dev/

fb1,或者完全摆脱/dev/fb0?

/

dev/fb0 是 HDMI 输出,/dev/fb1 是 SPI 显示器

我不需要hdmi显示器做任何事情,如果有办法永久禁用它,所以SPI显示器成为主要的fb0显示器,那将起作用。

我有以下代码来mmap帧缓冲区,但它们的颜色深度不同,所以我无法对其进行修改,并且逐个像素复制非常缓慢

有没有更好的方法可以做到这一点?

谢谢

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

我发现了另一个我注意到使用fbcp(帧缓冲复制)的驱动程序。https://github.com/juj/fbcp-ili9341

它将HDMI帧缓冲复制到60hz的SPI显示器上,并且不需要安装原始的SPI河,最重要的是它在用户空间中运行

仍然不是我正在寻找的解决方案,但对于任何寻找此信息的人,请尝试上面的驱动程序