What DRM and libinput library versions is LVGL expecting?

Description

What MCU/Processor/Board and compiler are you using?

  • Processor: Allwinner V3s on a LicheePi Zero at the moment (soon to be custom hardware)
  • Compiler: Buildroot 2024.02.3 to compile a very lean version of Linux 6.6.0. Compiling lv_port_linux with either GCC (for local testing) or cross-compile for the V3s (arm-linux-gnueabihf-gcc)
  • LVGL v9.2.0

What do you want to achieve?

I have been able to successfully get LVGL to run using “legacy” framebuffer (that’s how it’s listed in the Linux menuconfig!), as well as “evdev” (two lines, poof the touchscreen works perfectly!) Getting 30fps (seems to be a hard limit there for some reason…haven’t dug into why), with very decent performance on an 800x480 LCD panel. I can’t complain here!

However, I would like to be able to compile LVGL to use both DRM (video) and LIBINPUT (touch) as they are not “legacy” Linux device access methods. It’s kinda difficult to justify using “legacy” functionality on “new” systems!

What have you tried so far?

Tried compiling with DRM

Switched the “lv_conf.h” enables:

#define LV_USE_LINUX_FBDEV      0
#define LV_USE_LINUX_DRM        1

Compiling provides the classic error:

.../lv_linux_drm.c:21:10: fatal error: xf86drm.h: No such file or directory

Installed “libdrm-dev”, and recompiled. Then got this error:

xf86drm.h:40:10: fatal error: drm.h: No such file or directory

Spent awhile chasing this one before finally adding “-I/usr/include/libdrm” to the CFLAGS in the Makefile. That resulted in a huge cornucopia of errors in the following genre:

lv_port_linux/lvgl/src/drivers/display/drm/lv_linux_drm.o: in function `page_flip_handler':
lv_linux_drm.c:(.text+0x8): undefined reference to `drmModeAtomicFree'

Lots and lots of “undefined references.”

My LibDRM library version is as follows:

Package: libdrm-dev
Version: 2.4.118-0xneon+22.04+jammy+release+build10

Tried compiling for LIBINPUT

Similar story. Switched the “lv_conf.h” flags as follows (NOTE: I switched display back to framebuffer so that wasn’t a problem!)

/*Driver for evdev input devices*/
#define LV_USE_EVDEV    0

/*Driver for libinput input devices*/
#define LV_USE_LIBINPUT    1

Note that I did modify the default “lv_port_linux” sample init code so the “lv_linux_disp_init()” calls would return an “lv_display_t*” pointer to the created display. That enabled code like this to work:

    /*Linux display device init*/
    lv_display_t* disp = lv_linux_disp_init();

    // Initialize the touch driver.
#if LV_USE_LIBINPUT
    lv_indev_t *indev = lv_libinput_create(LV_INDEV_TYPE_POINTER, "/dev/input/event0");
#elif LV_USE_EVDEV
    lv_indev_t *indev = lv_evdev_create(LV_INDEV_TYPE_POINTER, "/dev/input/event0");
#endif
    lv_indev_set_display(indev, disp);

Compiling the project for libinput resulted in a similar “file not found” error, so I installed “libinput-dev” (already installed!??!) followed by “libinput-tool” as needed to run the “libinput list-devices” command referenced in the docs.
Retrying compilation now results in a similar cornucopia of errors (only the first few shown here):

lv_port_linux/lvgl/src/drivers/libinput/lv_libinput.o: in function `_delete':
lv_libinput.c:(.text+0xe4): undefined reference to `libinput_path_remove_device'
/usr/lib/gcc-cross/arm-linux-gnueabihf/11/../../../../arm-linux-gnueabihf/bin/ld: lv_libinput.c:(.text+0xec): undefined reference to `libinput_device_unref'
/usr/lib/gcc-cross/arm-linux-gnueabihf/11/../../../../arm-linux-gnueabihf/bin/ld: lv_libinput.c:(.text+0xf6): undefined reference to `libinput_unref'

More “undefined references” for page after page of errors.

My LibInput version is:

Package: libinput-dev
Version: 1.20.0-1ubuntu0.3

My conclusion

While I can very much utilize LVGL with FB and EVDEV, it seems that both DRM and LibInput need a little bit of upkeep (or at least documentation) if they are going to be viable options.

It appears that both DRM and LibInput were coded against a (presumably) much earlier version of the Linux drivers. Apparently they are not compatible with Linux 5.15 (i.e. Ubuntu 22.04 / KDE Neon 6.0).

Does anyone know what specific Linux version “lv_port_linux” was coded to be compatible with? Or am I missing something more major?

Seems the issue might be something else: libinput driver not linking · Issue #90 · lvgl/lv_drivers · GitHub

Turns out it was a bit of a compound issue:

  • The “libdrm-dev” and “libinput-dev” packages only contain headers: they do not contain source code.
  • I have to tell Make specifically which libraries to pull in:
    • add “-linput” to the LDFLAGS pulls in “libinput”
    • add “-ldrm” to the LDFLAGS pulls in “libdrm”
  • BUT…I have to disable static compilation!

This of course results in a binary that can be run on the desktop environment…but not the cross-compile environment. Test results here show that there is no “version” of LibInput / LibDRM that LVGL is expecting…but rather just some basic C Makefile stuff.

Digging into LibInput for ARMv7, I noticed the long list of “dependencies”–oh, the quagmire gets deep really fast: libinput (armv7h) | Packages | Arch Linux ARM

Now I completely understand why almost every time this pops up on the LVGL forums, the answer is “just use evdev” or “just use framebuffer”. For tiny embedded systems, less truly is more.

I’ll say it again: for small embedded Linux systems, just use evdev instead of libinput…and just use fb instead of DRM! Works a treat.