feat(fbdev): add docs and allow forcing refresh (#5444)

This commit is contained in:
Johannes Marbach
2024-01-24 14:38:18 +01:00
committed by GitHub
parent 6fa79e945f
commit 03cf1d1a0c
5 changed files with 65 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
========================
Linux Framebuffer Driver
========================
Overview
-------------
The Linux framebuffer (fbdev) is a linux subsystem used to display graphics. It is a hardware-independent API that gives user space software
access to the framebuffer (the part of a computer's video memory containing a current video frame) using only the Linux kernel's own basic
facilities and its device file system interface, avoiding the need for libraries that implement video drivers in user space.
Prerequisites
-------------
Your system has a framebuffer device configured (usually under ``/dev/fb0``).
Configuring the driver
----------------------
Enable the framebuffer driver support in lv_conf.h, by cmake compiler define or by KConfig. Additionally you may configure the rendering
mode.
.. code:: c
#define LV_USE_LINUX_FBDEV 1
#define LV_LINUX_FBDEV_RENDER_MODE LV_DISPLAY_RENDER_MODE_PARTIAL
Usage
-----
To set up a framebuffer-based display, first create a display with ``lv_linux_fbdev_create``. Afterwards set the framebuffer device
node on the display (usually this is ``/dev/fb0``).
.. code:: c
lv_display_t *disp = lv_linux_fbdev_create();
lv_linux_fbdev_set_file(disp, "/dev/fb0");
If your screen stays black or only draws partially, you can try enabling direct rendering via ``LV_DISPLAY_RENDER_MODE_DIRECT``. Additionally,
you can activate a force refresh mode with ``lv_linux_fbdev_set_force_refresh(true)``. This usually has a performance impact though and shouldn't
be enabled unless really needed.

View File

@@ -5,7 +5,10 @@ Display
.. toctree::
:maxdepth: 2
fbdev
gen_mipi
ili9341
lcd_stm32_hal
st7735
st7789
st7796

View File

@@ -84,6 +84,7 @@ lv_display_t * lv_display_create(int32_t hor_res, int32_t ver_res)
disp->layer_head->color_format = disp->color_format;
disp->inv_en_cnt = 1;
disp->last_activity_time = lv_tick_get();
_lv_ll_init(&disp->sync_areas, sizeof(lv_area_t));

View File

@@ -59,6 +59,7 @@ typedef struct {
char * fbp;
long int screensize;
int fbfd;
bool force_refresh;
} lv_linux_fb_t;
/**********************
@@ -238,6 +239,12 @@ void lv_linux_fbdev_set_file(lv_display_t * disp, const char * file)
hor_res, ver_res, lv_display_get_dpi(disp));
}
void lv_linux_fbdev_set_force_refresh(lv_display_t * disp, bool enabled)
{
lv_linux_fb_t * dsc = lv_display_get_driver_data(disp);
dsc->force_refresh = enabled;
}
/**********************
* STATIC FUNCTIONS
**********************/
@@ -275,6 +282,13 @@ static void flush_cb(lv_display_t * disp, const lv_area_t * area, uint8_t * colo
}
}
if(dsc->force_refresh) {
dsc->vinfo.activate |= FB_ACTIVATE_NOW | FB_ACTIVATE_FORCE;
if(ioctl(dsc->fbfd, FBIOPUT_VSCREENINFO, &(dsc->vinfo)) == -1) {
perror("Error setting var screen info");
}
}
lv_display_flush_ready(disp);
}

View File

@@ -33,6 +33,12 @@ lv_display_t * lv_linux_fbdev_create(void);
void lv_linux_fbdev_set_file(lv_display_t * disp, const char * file);
/**
* Force the display to be refreshed on every change.
* Expected to be used with LV_DISPLAY_RENDER_MODE_DIRECT or LV_DISPLAY_RENDER_MODE_FULL.
*/
void lv_linux_fbdev_set_force_refresh(lv_display_t * disp, bool enabled);
/**********************
* MACROS
**********************/