From 7c9dbcd339d1922fdcebaf207efec38cec33ae54 Mon Sep 17 00:00:00 2001
From: Francesco Pham <francesco.pham@huawei.com>
Date: Wed, 12 Apr 2023 10:23:43 +0200
Subject: [PATCH] openharmony-standard: use drmWaitVBlank hack also on EINVAL

On raspberry pi with VC4 drm graphics driver DRM_IOCTL_WAIT_VBLANK
is failing returning EINVAL for some reason, applying  drmWaitVBlank hack
also on EINVAL until a proper solution is provided.

Signed-off-by: Francesco Pham <francesco.pham@huawei.com>
---
 .../xf86drm.c-Add-drmWaitVBlank-hack.patch                  | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

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 2394595b..d4740ee5 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,7 +9,11 @@ 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.
 
+Apply hack also when DRM_IOCTL_WAIT_VBLANK fails for other reasons and returns
+EINVAL (e.g. on Rpi4 with VC4 drm drivers).
+
 Signed-off-by: Esben Haabendal <esben@geanix.com>
+Signed-off-by: Francesco Pham <francesco.pham@huawei.com>
 Upstream-Status: Pending
 
 diff --git a/xf86drm.c b/xf86drm.c
@@ -20,7 +24,7 @@ index b49d42f70dbe..ab8bb563c344 100644
                     break;
             }
         }
-+       else if (ret && errno == ENOTSUP) {
++       else if (ret && (errno == ENOTSUP || errno == EINVAL)) {
 +           /* Simulate VBLANK @ 60Hz when DRM driver does not support VBLANK */
 +           long delay_us;
 +           clock_gettime(CLOCK_MONOTONIC, &cur);
-- 
GitLab