diff --git a/recipes-openharmony/openharmony/openharmony-standard-3.0/xf86drm.c-Add-drmWaitVBlank-hack.patch b/recipes-openharmony/openharmony/openharmony-standard-3.0/xf86drm.c-Add-drmWaitVBlank-hack.patch index 9714e3e4919f4d76021129d0029b743a7061ff13..2394595b7f6b6a6017df32456ab2e76f0d5d87d2 100644 --- a/recipes-openharmony/openharmony/openharmony-standard-3.0/xf86drm.c-Add-drmWaitVBlank-hack.patch +++ b/recipes-openharmony/openharmony/openharmony-standard-3.0/xf86drm.c-Add-drmWaitVBlank-hack.patch @@ -9,43 +9,26 @@ is essential for the inner workings of the OpenHarmony graphic stack, therefore adding a hack that simulates this behaviour until a proper solution is provided. -Signed-off-by: Robert Drab <robert.drab@huawei.com> -Upstream-Status: Inappropriate +Signed-off-by: Esben Haabendal <esben@geanix.com> +Upstream-Status: Pending diff --git a/xf86drm.c b/xf86drm.c -index b49d42f..0e2805a 100644 +index b49d42f70dbe..ab8bb563c344 100644 --- a/xf86drm.c +++ b/xf86drm.c -@@ -2171,14 +2171,15 @@ drm_public int drmWaitVBlank(int fd, drmVBlankPtr vbl) - fprintf(stderr, "clock_gettime failed: %s\n", strerror(errno)); - goto out; - } -- timeout.tv_sec++; -+ /* HACK: return 0 after 16ms - value observed on the Taurus board */ -+ timeout.tv_nsec += 16000000; - - do { - ret = ioctl(fd, DRM_IOCTL_WAIT_VBLANK, vbl); - vbl->request.type &= ~DRM_VBLANK_RELATIVE; -- if (ret && errno == EINTR) { -+ if (ret && (errno == EINTR || errno == ENOTSUP)) { - clock_gettime(CLOCK_MONOTONIC, &cur); -- /* Timeout after 1s */ -+ /* HACK: return 0 after 16ms - value observed on the Taurus board */ - if (cur.tv_sec > timeout.tv_sec + 1 || - (cur.tv_sec == timeout.tv_sec && cur.tv_nsec >= - timeout.tv_nsec)) { -@@ -2187,9 +2188,12 @@ drm_public int drmWaitVBlank(int fd, drmVBlankPtr vbl) +@@ -2187,6 +2187,15 @@ drm_public int drmWaitVBlank(int fd, drmVBlankPtr vbl) break; } -+ usleep(10000); } -- } while (ret && errno == EINTR); -+ } while (ret && (errno == EINTR || errno == ENOTSUP)); ++ else if (ret && errno == ENOTSUP) { ++ /* Simulate VBLANK @ 60Hz when DRM driver does not support VBLANK */ ++ long delay_us; ++ clock_gettime(CLOCK_MONOTONIC, &cur); ++ delay_us = (cur.tv_nsec % (1000000000L / 60)) / 1000; ++ if (delay_us >= 10) // let's not wait less than 10 us ++ usleep(delay_us); ++ return 0; ++ } + } while (ret && errno == EINTR); out: -+ if (errno == EBUSY) -+ return 0; - return ret; - } -