From 753da76d95e2dd0addb168a60a38650b7c98aa7b Mon Sep 17 00:00:00 2001 From: Robert Drab <robert.drab@huawei.com> Date: Tue, 28 Jun 2022 22:02:52 +0200 Subject: [PATCH] openharmony-standard-3.0: Add drmWaitVBlank hack patch Signed-off-by: Robert Drab <robert.drab@huawei.com> --- .../xf86drm.c-Add-drmWaitVBlank-hack.patch | 50 +++++++++++++++++++ .../openharmony/openharmony-standard_3.0.bb | 1 + 2 files changed, 51 insertions(+) create mode 100644 recipes-openharmony/openharmony/openharmony-standard-3.0/xf86drm.c-Add-drmWaitVBlank-hack.patch 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 new file mode 100644 index 00000000..f3250372 --- /dev/null +++ b/recipes-openharmony/openharmony/openharmony-standard-3.0/xf86drm.c-Add-drmWaitVBlank-hack.patch @@ -0,0 +1,50 @@ +# SPDX-FileCopyrightText: Huawei Inc. +# +# SPDX-License-Identifier: Apache-2.0 + +xf86drm.c: Add drmWaitVBlank hack + +DRM_IOCTL_WAIT_VBLANK is not supported by the virtio drm driver. This feature +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 + +diff --git a/xf86drm.c b/xf86drm.c +index b49d42f..0e2805a 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,11 @@ drm_public int drmWaitVBlank(int fd, drmVBlankPtr vbl) + break; + } + } +- } while (ret && errno == EINTR); ++ } while (ret && (errno == EINTR || errno == ENOTSUP)); + + out: ++ if (errno == EBUSY) ++ return 0; + return ret; + } + diff --git a/recipes-openharmony/openharmony/openharmony-standard_3.0.bb b/recipes-openharmony/openharmony/openharmony-standard_3.0.bb index d5b4141a..1c82fdb5 100644 --- a/recipes-openharmony/openharmony/openharmony-standard_3.0.bb +++ b/recipes-openharmony/openharmony/openharmony-standard_3.0.bb @@ -60,6 +60,7 @@ SRC_URI += "file://display-Use-temporary-qemuarm-implementation.patch;patchdir=$ SRC_URI += "file://display_gralloc_gbm.c-Use-card-drm-node.patch;patchdir=${S}/device/hihope" SRC_URI += "file://hihope-gralloc-Backport-to-3.0.patch;patchdir=${S}/device/hihope" SRC_URI += "file://ivi-input-controller.c-Fix-g_ctx-declaration-causing-segfault.patch;patchdir=${S}/third_party/wayland-ivi-extension" +SRC_URI += "file://xf86drm.c-Add-drmWaitVBlank-hack.patch;patchdir=${S}/third_party/libdrm" inherit python3native gn_base ptest -- GitLab