zlgopen / awtk-linux-fb

awtk port for linux framebuffer
110 stars 49 forks source link

怎么在linux嵌入式设备中启用3个framebuffer #78

Closed 18611429192 closed 3 years ago

18611429192 commented 3 years ago

我看了以前的贴子issues220,没有看的很明白,想详细了解下怎么在linux下使用三个frame buffer的方法。 目前我在awtk-port/lcd_linux/lcd_linux_fb.c中找到了使用两个frame buffer的代码,但是不知道用的是不是不对,画面有撕裂感。 我看到在下面这个函数中会调用lcd_linux_create_swappable(fb);,开启一个framebuffer,来使用,于是我把这段注释了,强制使用return lcd_linux_create_flushable(fb);来使用两个frame buffer。 结果是虽然帧率上升了,但是画面仍然不够流畅,且有撕裂感。

static lcd_t* lcd_linux_create(fb_info_t* fb) {
  init_fblist(fb_number(fb));
  printf("=========fb_number=%d\n", fb_number(fb));
  if (fb_is_1fb(fb)) {
    return lcd_linux_create_flushable(fb);
  } else {
    return lcd_linux_create_swappable(fb);
  }
}

我想直接直接使用fb方式,启用三个frame buffer。请帮我看下我的设备能不能启用三个frame buffer。我的一些打印信息如下。

fb_info_t: /dev/fb0
xres=480 yres=480
xres_virtual=480 yres_virtual=960
bits_per_pixel=32 line_length=1920
fb_info_t: red(16 8) green(8 8) blue(0 8)
xpanstep=1 ywrapstep=0
fb_size=921600 fb_total_size=1843200 fb_nr=2 smem_len=1843200
fb_open clear
fb_open ok
sh: dmidecode: not found
=========fb_number=2
---------lcd_linux_create_flushable
ratio=1.000000 480 480
ratio=1.000000 480 480
tslib_run:116: open tslib successful, filename=/dev/input/event3
input_run:254: open mouse failed, fd=-1, filename=/dev/input/mouse0
tk_strncpy:308 condition(dst != NULL && src != NULL) failed!

还有个问题,,这个tk_strncpy:308 condition(dst != NULL && src != NULL) failed!错误是因为什么呢?

18611429192 commented 3 years ago

我将awtk-port/lcd_linux/lcd_linux_fb.c中的__FB_ASYNC_SWAP定义成1,发现这个定义打开,看这个代码就有点像是三个frame buffer工作了,,两块fb.var地址fbmem0和fbmem_offline,加上在函数lcd_mem_bgr565_create_single_fb创建的内存。最后的效果感觉还行,不知道我这么理解对不对。

sohide commented 3 years ago

解决撕裂感只要fb_number>=2 就会自动有效果,不需要改代码,也不需要3fb 开启__FB_ASYNC_SWAP会使用单独的线程切换fb, 对提高帧率有一定的帮助

要使用3fb,需要用fbset命令设置虚拟高=实际高*3,要看具体的板子平台,不一定能设置成功

sohide commented 3 years ago

tk_strncpy:308 condition(dst != NULL && src != NULL) failed! 这个问题麻烦你跟踪一下,把调用栈打印出来,我们没有测试出这个问题

18611429192 commented 3 years ago

貌似只能是双buffer了,我算了下,最多只能是开2个frame buffer。1843200/1920 = 960