Skip to content

feat: link with g2d and generate wayland dmabuf protocols #84

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,10 @@ target_link_libraries(lvgl PUBLIC ${PKG_CONFIG_LIB} m pthread)
add_executable(lvglsim src/main.c ${LV_LINUX_SRC} ${LV_LINUX_BACKEND_SRC})
target_link_libraries(lvglsim lvgl_linux lvgl)

if (CONFIG_LV_USE_DRAW_G2D)
target_link_libraries(lvglsim g2d)
endif()

# Install the lvgl_linux library and its headers
install(DIRECTORY src/lib/
DESTINATION include/lvgl
Expand Down
8 changes: 6 additions & 2 deletions lv_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -1187,8 +1187,12 @@
/** Use Wayland to open a window and handle input on Linux or BSD desktops */
#define LV_USE_WAYLAND 0
#if LV_USE_WAYLAND
#define LV_WAYLAND_WINDOW_DECORATIONS 0 /**< Draw client side window decorations only necessary on Mutter/GNOME */
#define LV_WAYLAND_WL_SHELL 0 /**< Use the legacy wl_shell protocol instead of the default XDG shell */
#define LV_WAYLAND_BUF_COUNT 1 /**< Use 1 for single buffer with partial render mode or 2 for double buffer with full render mode*/
#define LV_WAYLAND_USE_DMABUF 0 /**< Use DMA buffers for frame buffers. Requires LV_DRAW_USE_G2D */
#define LV_WAYLAND_RENDER_MODE LV_DISPLAY_RENDER_MODE_PARTIAL /**< DMABUF supports LV_DISPLAY_RENDER_MODE_FULL and LV_DISPLAY_RENDER_MODE_DIRECT*/
/**< When LV_WAYLAND_USE_DMABUF is disabled, only LV_DISPLAY_RENDER_MODE_PARTIAL is supported*/
#define LV_WAYLAND_WINDOW_DECORATIONS 0 /**< Draw client side window decorations only necessary on Mutter/GNOME. Not supported using DMABUF*/
#define LV_WAYLAND_WL_SHELL 0 /**< Use the legacy wl_shell protocol instead of the default XDG shell*/
#endif

/** Driver for /dev/fb */
Expand Down
5 changes: 4 additions & 1 deletion scripts/gen_wl_protocols.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Generate wayland xdg shell protocol

OUTPUT_DIR="$1"
PROTOCOL_ROOT="${SYSROOT:-}/usr/share/wayland-protocols"
PROTOCOL_ROOT="${SDKTARGETSYSROOT:-}/usr/share/wayland-protocols"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe SYSROOT is more generic for other platforms. Doesn't nxp support it?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SDKTARGETSYSROOT is the one that comes from the toolchain

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to keep this as SYSROOT since it's more generic and will cover more use-cases down the line. What do you think ?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me check one more time what env vars are set on the toolchain, and I'll come back with an answer / alternative.

Thanks

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @cosmindanielradu19 and @anaGrad

So I just checked and indeed, the sdk exports SDKTARGETSYSROOT and not SYSROOT
I also found that a OEToolchainConfig.cmake exists inside the SDK and thus we could pass the current CMAKE_SYSROOT as an argument to the script

So I was thinking that we could either use the CMAKE_SYSROOT variable when invoking the script and basically it would be mandatory to call cmake like this:

cmake -B build -DCMAKE_TOOLCHAIN_FILE=$OECORE_NATIVE_SYSROOT/usr/share/cmake/OEToolchainConfig.cmake

OR option 2 would be check for both SYSROOT and SDKTARGETSYSROOT and produce an error if both are set

I'm tending more towards option 2 as it's the easiest and more beginner friendly approach

What do you think ?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with option 2 as well


if ! test -d $PROTOCOL_ROOT
then
Expand All @@ -16,6 +16,9 @@ then
mkdir $OUTPUT_DIR
wayland-scanner client-header "$PROTOCOL_ROOT/stable/xdg-shell/xdg-shell.xml" "$OUTPUT_DIR/wayland_xdg_shell.h"
wayland-scanner private-code "$PROTOCOL_ROOT/stable/xdg-shell/xdg-shell.xml" "$OUTPUT_DIR/wayland_xdg_shell.c"
wayland-scanner client-header "$PROTOCOL_ROOT/stable/linux-dmabuf/linux-dmabuf-v1.xml" "$OUTPUT_DIR/wayland_linux_dmabuf.h"
wayland-scanner private-code "$PROTOCOL_ROOT/stable/linux-dmabuf/linux-dmabuf-v1.xml" "$OUTPUT_DIR/wayland_linux_dmabuf.c"
fi

echo "$OUTPUT_DIR/wayland_xdg_shell.c"
echo "$OUTPUT_DIR/wayland_linux_dmabuf.c"
9 changes: 4 additions & 5 deletions src/lib/display_backends/wayland.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,16 +122,15 @@ static lv_display_t *init_wayland(void)
static void run_loop_wayland(void)
{

bool completed;
uint32_t idle_time;

/* Handle LVGL tasks */
while (true) {

completed = lv_wayland_timer_handler();
idle_time = lv_wayland_timer_handler();

if (completed) {
/* wait only if the cycle was completed */
usleep(LV_DEF_REFR_PERIOD * 1000);
if(idle_time != 0) {
usleep(idle_time * 1000);
}

/* Run until the last window closes */
Expand Down