From 5ac14e42dd69eac5d043294dc950904d0355acce Mon Sep 17 00:00:00 2001 From: Tim Stableford Date: Fri, 24 May 2024 04:31:01 +0100 Subject: [PATCH] fix(drivers): drm driver not initialising with small screens (#6244) --- src/drivers/display/drm/lv_linux_drm.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/drivers/display/drm/lv_linux_drm.c b/src/drivers/display/drm/lv_linux_drm.c index 99f3405d5..288f1c8a6 100644 --- a/src/drivers/display/drm/lv_linux_drm.c +++ b/src/drivers/display/drm/lv_linux_drm.c @@ -153,9 +153,12 @@ void lv_linux_drm_set_file(lv_display_t * disp, const char * file, int64_t conne int32_t width = drm_dev->mmWidth; size_t buf_size = LV_MIN(drm_dev->drm_bufs[1].size, drm_dev->drm_bufs[0].size); + /* Resolution must be set first because if the screen is smaller than the size passed + * to lv_display_create then the buffers aren't big enough for LV_DISPLAY_RENDER_MODE_DIRECT. + */ + lv_display_set_resolution(disp, hor_res, ver_res); lv_display_set_buffers(disp, drm_dev->drm_bufs[1].map, drm_dev->drm_bufs[0].map, buf_size, LV_DISPLAY_RENDER_MODE_DIRECT); - lv_display_set_resolution(disp, hor_res, ver_res); if(width) { lv_display_set_dpi(disp, DIV_ROUND_UP(hor_res * 25400, width * 1000));