Skip to content

Commit

Permalink
fix(drm): add tick_get_cb (lvgl#6306)
Browse files Browse the repository at this point in the history
  • Loading branch information
kisvegabor authored Jun 11, 2024
1 parent d0ddf9e commit d79ec13
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
13 changes: 13 additions & 0 deletions src/drivers/display/drm/lv_linux_drm.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <poll.h>
#include <stdint.h>
#include <sys/mman.h>
#include <time.h>
#include <unistd.h>
#include <string.h>

Expand Down Expand Up @@ -92,6 +93,8 @@ static int drm_setup_buffers(drm_dev_t * drm_dev);
static void drm_flush_wait(lv_display_t * drm_dev);
static void drm_flush(lv_display_t * disp, const lv_area_t * area, uint8_t * px_map);

static uint32_t tick_get_cb(void);

/**********************
* STATIC VARIABLES
**********************/
Expand All @@ -109,6 +112,8 @@ static void drm_flush(lv_display_t * disp, const lv_area_t * area, uint8_t * px_

lv_display_t * lv_linux_drm_create(void)
{
lv_tick_set_cb(tick_get_cb);

drm_dev_t * drm_dev = lv_malloc_zeroed(sizeof(drm_dev_t));
LV_ASSERT_MALLOC(drm_dev);
if(drm_dev == NULL) return NULL;
Expand Down Expand Up @@ -836,4 +841,12 @@ static void drm_flush(lv_display_t * disp, const lv_area_t * area, uint8_t * px_
}
}

static uint32_t tick_get_cb(void)
{
struct timespec t;
clock_gettime(CLOCK_MONOTONIC, &t);
uint64_t time_ms = t.tv_sec * 1000 + (t.tv_nsec / 1000000);
return time_ms;
}

#endif /*LV_USE_LINUX_DRM*/
15 changes: 5 additions & 10 deletions src/drivers/display/fb/lv_linux_fbdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include <fcntl.h>
#include <sys/mman.h>
#include <sys/ioctl.h>
#include <sys/time.h>
#include <time.h>

#if LV_LINUX_FBDEV_BSD
#include <sys/fcntl.h>
Expand Down Expand Up @@ -96,11 +96,7 @@ static uint32_t tick_get_cb(void);

lv_display_t * lv_linux_fbdev_create(void)
{
static bool inited = false;
if(!inited) {
lv_tick_set_cb(tick_get_cb);
inited = true;
}
lv_tick_set_cb(tick_get_cb);

lv_linux_fb_t * dsc = lv_malloc_zeroed(sizeof(lv_linux_fb_t));
LV_ASSERT_MALLOC(dsc);
Expand Down Expand Up @@ -350,10 +346,9 @@ static void flush_cb(lv_display_t * disp, const lv_area_t * area, uint8_t * colo

static uint32_t tick_get_cb(void)
{
struct timeval tv_now;
gettimeofday(&tv_now, NULL);
uint64_t time_ms;
time_ms = (tv_now.tv_sec * 1000000 + tv_now.tv_usec) / 1000;
struct timespec t;
clock_gettime(CLOCK_MONOTONIC, &t);
uint64_t time_ms = t.tv_sec * 1000 + (t.tv_nsec / 1000000);
return time_ms;
}

Expand Down

0 comments on commit d79ec13

Please sign in to comment.