Skip to content
Snippets Groups Projects
Commit d947f503 authored by Esben Haabendal's avatar Esben Haabendal
Browse files

openharmony-standard: Simplified version of drmWaitVBlank hack


This simplifies and improves the hack added to libdrm to handle drivers (like
virtio drm) that does not support DRM_IOCTL_WAIT_VBLANK, and tries to return at
60 Hz points in time.

Signed-off-by: default avatarEsben Haabendal <esben@geanix.com>
parent ed86c8be
No related branches found
No related tags found
1 merge request!98openharmony-standard: Simplified version of drmWaitVBlank hack
...@@ -9,43 +9,26 @@ is essential for the inner workings of the OpenHarmony graphic stack, therefore ...@@ -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 adding a hack that simulates this behaviour until a proper solution is
provided. provided.
Signed-off-by: Robert Drab <robert.drab@huawei.com> Signed-off-by: Esben Haabendal <esben@geanix.com>
Upstream-Status: Inappropriate Upstream-Status: Pending
diff --git a/xf86drm.c b/xf86drm.c diff --git a/xf86drm.c b/xf86drm.c
index b49d42f..0e2805a 100644 index b49d42f70dbe..ab8bb563c344 100644
--- a/xf86drm.c --- a/xf86drm.c
+++ b/xf86drm.c +++ b/xf86drm.c
@@ -2171,14 +2171,15 @@ drm_public int drmWaitVBlank(int fd, drmVBlankPtr vbl) @@ -2187,6 +2187,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)
break; break;
} }
+ usleep(10000);
} }
- } while (ret && errno == EINTR); + else if (ret && errno == ENOTSUP) {
+ } while (ret && (errno == EINTR || 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: out:
+ if (errno == EBUSY)
+ return 0;
return ret;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment