Andrew Geissler | 3eeda90 | 2023-05-19 10:14:02 -0500 | [diff] [blame] | 1 | From 1d92e1854c19c06c553243d29170bb4d1a9e3863 Mon Sep 17 00:00:00 2001 |
| 2 | From: Marek Vasut <marex@denx.de> |
| 3 | Date: Tue, 9 May 2023 02:57:30 +0200 |
| 4 | Subject: [PATCH 1/2] wayland: Switch to custom timer tick |
| 5 | |
| 6 | The OE LVGL is configured to obtain timer tick from system timer |
| 7 | instead of using ad-hoc mechanisms to emulate timer tick using |
| 8 | threads or such. Use system timer to provide the tick. |
| 9 | |
| 10 | The tick handling implementation comes from: |
| 11 | https://github.com/lvgl/lv_port_linux_frame_buffer.git |
| 12 | as of commit adf2c4490e17a1b9ec1902cc412a24b3b8235c8e |
| 13 | |
| 14 | Upstream-Status: Inappropriate [Upstream repo is archived] |
| 15 | Signed-off-by: Marek Vasut <marex@denx.de> |
| 16 | --- |
| 17 | src/drivers/wayland.c | 24 ++++++++++++++++-------- |
| 18 | 1 file changed, 16 insertions(+), 8 deletions(-) |
| 19 | |
| 20 | diff --git a/src/drivers/wayland.c b/src/drivers/wayland.c |
| 21 | index 633dc18..bcebf4d 100644 |
| 22 | --- a/src/drivers/wayland.c |
| 23 | +++ b/src/drivers/wayland.c |
| 24 | @@ -6,6 +6,7 @@ |
| 25 | #if defined(USE_WAYLAND) && USE_WAYLAND |
| 26 | |
| 27 | #include <pthread.h> |
| 28 | +#include <sys/time.h> |
| 29 | #include <unistd.h> |
| 30 | |
| 31 | #include <lv_drivers/wayland/wayland.h> |
| 32 | @@ -18,13 +19,22 @@ |
| 33 | #define WAYLAND_VER_RES 320 |
| 34 | #endif |
| 35 | |
| 36 | -static void * tick_thread(void * data) |
| 37 | +uint32_t custom_tick_get(void) |
| 38 | { |
| 39 | - (void) data; |
| 40 | - while(true) { |
| 41 | - usleep(5 * 1000); |
| 42 | - lv_tick_inc(5); |
| 43 | - } |
| 44 | + static uint64_t start_ms = 0; |
| 45 | + if(start_ms == 0) { |
| 46 | + struct timeval tv_start; |
| 47 | + gettimeofday(&tv_start, NULL); |
| 48 | + start_ms = (tv_start.tv_sec * 1000000 + tv_start.tv_usec) / 1000; |
| 49 | + } |
| 50 | + |
| 51 | + struct timeval tv_now; |
| 52 | + gettimeofday(&tv_now, NULL); |
| 53 | + uint64_t now_ms; |
| 54 | + now_ms = (tv_now.tv_sec * 1000000 + tv_now.tv_usec) / 1000; |
| 55 | + |
| 56 | + uint32_t time_ms = now_ms - start_ms; |
| 57 | + return time_ms; |
| 58 | } |
| 59 | |
| 60 | |
| 61 | @@ -47,8 +57,6 @@ void hal_init(void) |
| 62 | |
| 63 | lv_group_t * g = lv_group_create(); |
| 64 | lv_group_set_default(g); |
| 65 | - static pthread_t hal_thread; |
| 66 | - pthread_create(&hal_thread, NULL, tick_thread, NULL); |
| 67 | } |
| 68 | |
| 69 | #endif |
| 70 | -- |
| 71 | 2.39.2 |
| 72 | |