From 29b92ebbfe8e0ccef8d47e5ccd1769053fee6c46 Mon Sep 17 00:00:00 2001
From: Pavel Zhukov <pavel.zhukov@huawei.com>
Date: Fri, 1 Oct 2021 13:35:16 +0200
Subject: [PATCH] weston: plane_add_prop() calls break weston with musl

Upstream-commit: b3a5b64f717b39536c96627ce058cf9c51cf3ba6
Upstream-status: Backport
Signed-off-by: Pavel Zhukov <pavel.zhukov@huawei.com>

Closes: https://git.ostc-eu.org/OSTC/OHOS/meta-ohos/-/issues/119
---
 .../weston/dont-use-plane-add-prop.patch      | 23 +++++++++++++++++++
 .../wayland/weston_8.0.0.bbappend             |  2 ++
 2 files changed, 25 insertions(+)
 create mode 100644 meta-ohos-core/recipes-graphics/wayland/weston/dont-use-plane-add-prop.patch

diff --git a/meta-ohos-core/recipes-graphics/wayland/weston/dont-use-plane-add-prop.patch b/meta-ohos-core/recipes-graphics/wayland/weston/dont-use-plane-add-prop.patch
new file mode 100644
index 00000000..a4444e5d
--- /dev/null
+++ b/meta-ohos-core/recipes-graphics/wayland/weston/dont-use-plane-add-prop.patch
@@ -0,0 +1,23 @@
+Fix atomic modesetting with musl
+
+atomic modesetting seems to fail with drm weston backend and this patch fixes
+it, below errors are seen before weston exits
+
+atomic: couldn't commit new state: Invalid argument
+
+Upstream-Status: Submitted [https://gitlab.freedesktop.org/wayland/weston/-/issues/158]
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+
+--- a/libweston/backend-drm/kms.c
++++ b/libweston/backend-drm/kms.c
+@@ -1168,8 +1168,8 @@ drm_pending_state_apply_atomic(struct dr
+ 		wl_list_for_each(plane, &b->plane_list, link) {
+ 			drm_debug(b, "\t\t[atomic] starting with plane %lu disabled\n",
+ 				  (unsigned long) plane->plane_id);
+-			plane_add_prop(req, plane, WDRM_PLANE_CRTC_ID, 0);
+-			plane_add_prop(req, plane, WDRM_PLANE_FB_ID, 0);
++			//plane_add_prop(req, plane, WDRM_PLANE_CRTC_ID, 0);
++			//plane_add_prop(req, plane, WDRM_PLANE_FB_ID, 0);
+ 		}
+ 
+ 		flags |= DRM_MODE_ATOMIC_ALLOW_MODESET;
diff --git a/meta-ohos-core/recipes-graphics/wayland/weston_8.0.0.bbappend b/meta-ohos-core/recipes-graphics/wayland/weston_8.0.0.bbappend
index dd347610..affce70b 100644
--- a/meta-ohos-core/recipes-graphics/wayland/weston_8.0.0.bbappend
+++ b/meta-ohos-core/recipes-graphics/wayland/weston_8.0.0.bbappend
@@ -4,6 +4,8 @@
 FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
 
 SRC_URI += "file://systemd-notify.weston-start"
+SRC_URI_append_libc-musl = " file://dont-use-plane-add-prop.patch"
+
 do_install_append() {
         install -Dm 644 ${WORKDIR}/systemd-notify.weston-start ${D}${datadir}/weston-start/systemd-notify
 }
-- 
GitLab