diff --git a/.gitlab-ci/testcases/test_directory_structure.py b/.gitlab-ci/testcases/test_directory_structure.py
index e64abf78fb54f95d500d28fbfe75003ff8fbaf02..d05e7556f61d89b59dd897af76a588b7dcca0e14 100644
--- a/.gitlab-ci/testcases/test_directory_structure.py
+++ b/.gitlab-ci/testcases/test_directory_structure.py
@@ -10,7 +10,6 @@ expected_directories = [
     "device/community",
     "device/main",
     "device/testing",
-    "hybris",
     "kde",
     "maemo",
     "main",
diff --git a/hybris/android-headers-4.4/APKBUILD b/hybris/android-headers-4.4/APKBUILD
deleted file mode 100644
index 4f53f9f86494f6252107bc301c44b2a652f25bc9..0000000000000000000000000000000000000000
--- a/hybris/android-headers-4.4/APKBUILD
+++ /dev/null
@@ -1,26 +0,0 @@
-# Maintainer: TheKit <nekit1000@gmail.com>
-pkgname=android-headers-4.4
-_pkgname=android-headers
-pkgver=4.4_git20171022
-_pkgver=4.4
-pkgrel=0
-arch="aarch64 armhf armv7"
-url="https://github.com/ubports/android-headers"
-license="Apache-2.0"
-_commit="f636fa26a61b36bef284a7aeba95eb767344b8b4"
-source="$pkgname-$_commit.tar.gz::https://github.com/ubports/android-headers/archive/$_commit.tar.gz
-	android-headers.pc"
-pkgdesc="Android headers used for building libhybris"
-options="!check"
-
-builddir="$srcdir/$_pkgname-$_commit"
-
-package() {
-	mkdir -p "$pkgdir/usr/include"
-	cp -r "$builddir/19" "$pkgdir/usr/include/android-$_pkgver"
-
-	install -Dm644 "$srcdir/android-headers.pc" "$pkgdir/usr/lib/pkgconfig/android-headers-$_pkgver.pc"
-}
-
-sha512sums="c146753908ae0dd9aca0138a0a63e8578d65200d6d9b5154b846a0ac3309d9e33f6edddd92cd420e7b7dcaf73630546eb1bd45927cf8b4921f67dec7db7bb55c  android-headers-4.4-f636fa26a61b36bef284a7aeba95eb767344b8b4.tar.gz
-331f2670da9ce2690225694196265a55e2f41c35a1a12b71a75de3478b3b266c215be9bd451ab5ea13d4802e9f7d4e1bab8aa006d0df81fc264b2a132a022640  android-headers.pc"
diff --git a/hybris/android-headers-4.4/android-headers.pc b/hybris/android-headers-4.4/android-headers.pc
deleted file mode 100644
index 5c6338d05aad941a473aff7419b882056b7f187c..0000000000000000000000000000000000000000
--- a/hybris/android-headers-4.4/android-headers.pc
+++ /dev/null
@@ -1,9 +0,0 @@
-Name: Android header files
-Description: Header files needed to write applications for the Android platform
-Version: 4.4
-
-prefix=/usr
-exec_prefix=${prefix}
-includedir=${prefix}/include
-
-Cflags: -I${includedir}/android-4.4
diff --git a/hybris/android-headers-7.1/APKBUILD b/hybris/android-headers-7.1/APKBUILD
deleted file mode 100644
index b0b7ddd52d4b6377608c2a42d297cb724fc82904..0000000000000000000000000000000000000000
--- a/hybris/android-headers-7.1/APKBUILD
+++ /dev/null
@@ -1,37 +0,0 @@
-# Maintainer: TheKit <nekit1000@gmail.com>
-pkgname=android-headers-7.1
-_pkgname=android-headers
-pkgver=7.1_git20170630
-_pkgver=7.1
-pkgrel=0
-arch="aarch64 armhf armv7"
-url="https://github.com/Halium/android-headers"
-license="Apache-2.0"
-_commit="1f6591ba7d42b91c32acf5a65a2a4fae983d6865"
-source="$pkgname-$_commit.tar.gz::https://github.com/Halium/android-headers/archive/$_commit.tar.gz"
-pkgdesc="Android headers used for building libhybris"
-subpackages="$pkgname-caf:package_caf"
-
-builddir="$srcdir/$_pkgname-$_commit"
-
-package() {
-	make PREFIX=/usr DESTDIR="$pkgdir" install
-
-	mv "$pkgdir/usr/include/android" "$pkgdir/usr/include/android-$_pkgver"
-	sed -i "s~$includedir/android~$includedir/android-$_pkgver~g" "$pkgdir"/usr/lib/pkgconfig/android-headers.pc
-	mv "$pkgdir/usr/lib/pkgconfig/android-headers.pc" "$pkgdir/usr/lib/pkgconfig/android-headers-$_pkgver.pc"
-}
-
-
-package_caf() {
-	cd "$builddir"
-
-	sed -i 's~/\* CONFIG GOES HERE \*/~#define QCOM_BSP 1\n#define QTI_BSP 1~g' android-config.h
-	make PREFIX=/usr DESTDIR="$subpkgdir" install
-
-	mv "$subpkgdir/usr/include/android" "$subpkgdir/usr/include/android-$_pkgver-caf"
-	sed -i "s~$includedir/android~$includedir/android-$_pkgver-caf~g" "$subpkgdir"/usr/lib/pkgconfig/android-headers.pc
-	mv "$subpkgdir/usr/lib/pkgconfig/android-headers.pc" "$subpkgdir/usr/lib/pkgconfig/android-headers-$_pkgver-caf.pc"
-}
-
-sha512sums="652641b469f7faf90c7adf03b14047f9eb24fdb190d9ab131d72f73b2d9357aad80cad48867ede66b0a737661cfb9e26fb4583b9fed15b8d6d667fe53ea14419  android-headers-7.1-1f6591ba7d42b91c32acf5a65a2a4fae983d6865.tar.gz"
diff --git a/hybris/android-headers-9.0/APKBUILD b/hybris/android-headers-9.0/APKBUILD
deleted file mode 100644
index ea74ae4e725913e75c7d3abb6a24d855110e8355..0000000000000000000000000000000000000000
--- a/hybris/android-headers-9.0/APKBUILD
+++ /dev/null
@@ -1,24 +0,0 @@
-# Maintainer: TheKit <nekit1000@gmail.com>
-pkgname=android-headers-9.0
-_pkgname=android-headers
-pkgver=9.0_git20190803
-_pkgver=9.0
-pkgrel=0
-arch="aarch64 armhf armv7"
-url="https://github.com/Halium/android-headers"
-license="Apache-2.0"
-_commit="00543b4ff3f56a9f96be336df276365aef46f8a2"
-source="$pkgname-$_commit.tar.gz::https://github.com/Halium/android-headers/archive/$_commit.tar.gz"
-pkgdesc="Android headers used for building libhybris"
-
-builddir="$srcdir/$_pkgname-$_commit"
-
-package() {
-	make PREFIX=/usr DESTDIR="$pkgdir" install
-
-	mv "$pkgdir/usr/include/android" "$pkgdir/usr/include/android-$_pkgver"
-	sed -i "s~$includedir/android~$includedir/android-$_pkgver~g" "$pkgdir/usr/lib/pkgconfig/android-headers.pc"
-	mv "$pkgdir/usr/lib/pkgconfig/android-headers.pc" "$pkgdir/usr/lib/pkgconfig/android-headers-$_pkgver.pc"
-}
-
-sha512sums="9b2ab8d7ee56f8e5a875ed139814ed4f6171c3ccd1542a19b74a23cea0fd03ed9aa9b1ee70f2660d858dab891fc55681af6e7510f10995083d23a06a058e6d6d  android-headers-9.0-00543b4ff3f56a9f96be336df276365aef46f8a2.tar.gz"
diff --git a/hybris/drihybris/APKBUILD b/hybris/drihybris/APKBUILD
deleted file mode 100644
index 9d5274858406f5350a0f293695522f227638e075..0000000000000000000000000000000000000000
--- a/hybris/drihybris/APKBUILD
+++ /dev/null
@@ -1,31 +0,0 @@
-# Maintainer: TheKit <nekit1000@gmail.com>
-pkgname=drihybris
-pkgver=1.0_git20191009
-pkgrel=0
-_commit="6bc4f4a2c438ace0db4df2ccaae812465572a840"
-pkgdesc="custom DRI3-based Xorg extension for use with libhybris"
-url="https://github.com/NotKit/drihybris"
-arch="armhf armv7 aarch64"
-license="MIT"
-subpackages="$pkgname-doc $pkgname-dev"
-makedepends="autoconf automake libtool util-macros
-	xorg-server-dev libxi-dev"
-source="$pkgname-$_commit.tar.gz::https://github.com/NotKit/drihybris/archive/$_commit.tar.gz"
-options="!check" # no testsuite
-
-builddir="$srcdir"/$pkgname-$_commit
-
-build() {
-	export LDFLAGS="$LDFLAGS -Wl,-z,lazy"
-	./autogen.sh \
-		--build=$CBUILD \
-		--host=$CHOST \
-		--prefix=/usr \
-	make
-}
-
-package() {
-	make DESTDIR="$pkgdir" install
-	install -Dm644 COPYING "$pkgdir"/usr/share/licenses/$pkgname/COPYING
-}
-sha512sums="969f934d8d43acef879d534734b29357e68d23f6861e2dbc92a20a67b68507e8670bc99e8591eaa4df47640b774615ab64a4ee651eda81df7f112075cf370e75  drihybris-6bc4f4a2c438ace0db4df2ccaae812465572a840.tar.gz"
diff --git a/hybris/glamor-hybris/APKBUILD b/hybris/glamor-hybris/APKBUILD
deleted file mode 100644
index bddd0edfb38ad08633603837e2262cba0ed62813..0000000000000000000000000000000000000000
--- a/hybris/glamor-hybris/APKBUILD
+++ /dev/null
@@ -1,38 +0,0 @@
-# Maintainer: TheKit <nekit1000@gmail.com>
-pkgname=glamor-hybris
-pkgver=1.0_git20191007
-pkgrel=0
-_commit="28f342f937a5f9a606273b48dcede7eefbab4bab"
-pkgdesc="glamor Xserver 2D acceleration modified to work with libhybris drivers"
-url="https://github.com/NotKit/glamor-hybris"
-arch="armhf aarch64"
-license="MIT"
-subpackages="$pkgname-doc $pkgname-dev"
-makedepends="autoconf automake util-macros libtool
-	xorg-server-dev libxi-dev fontsproto randrproto
-	videoproto renderproto drihybris-dev libepoxy-dev
-	libhybris-dev"
-
-source="$pkgname-$_commit.tar.gz::https://github.com/NotKit/glamor-hybris/archive/$_commit.tar.gz"
-options="!check" # no testsuite
-
-builddir="$srcdir"/$pkgname-$_commit
-
-build() {
-	export LDFLAGS="$LDFLAGS -Wl,-z,lazy"
-	export CPPFLAGS="$CPPFLAGS -I/usr/include/android-7.1"
-
-	./autogen.sh \
-		--build=$CBUILD \
-		--host=$CHOST \
-		--prefix=/usr \
-		--enable-glamor-gles2
-	make
-}
-
-package() {
-	make DESTDIR="$pkgdir" install
-	mv "$pkgdir/usr/include/xorg/glamor.h" "$pkgdir/usr/include/xorg/glamor-hybris.h"
-	install -Dm644 COPYING "$pkgdir"/usr/share/licenses/$pkgname/COPYING
-}
-sha512sums="49a323d40b56f15fe96a7371c864abc78669c7e58585d689c284127f1a01660504938e0dcf6e1199da4f6d382087232a00091d22efa5b12059867e45c301a584  glamor-hybris-28f342f937a5f9a606273b48dcede7eefbab4bab.tar.gz"
diff --git a/hybris/hybris-base/APKBUILD b/hybris/hybris-base/APKBUILD
deleted file mode 100644
index 18aee68180ca1026b2daafb1b76beb4fc2faab55..0000000000000000000000000000000000000000
--- a/hybris/hybris-base/APKBUILD
+++ /dev/null
@@ -1,25 +0,0 @@
-pkgname=hybris-base
-pkgver=1.0
-pkgrel=0
-pkgdesc="Meta package to use libhybris adaptation"
-url="https://postmarketos.org"
-license="GPL-3.0-or-later"
-options="!check"
-# libhybris cannot be built for arch x86_64
-arch="armhf aarch64"
-depends="lxc-android libhybris libhybris-7.1 libhybris-egl libhybris-gles libhybris-libwayland-egl wayland-libs-client wayland-libs-server"
-subpackages="$pkgname-x11-generic:x11_generic $pkgname-x11-caf:x11_caf"
-
-package() {
-	mkdir -p "$pkgdir"
-}
-
-x11_generic() {
-	depends="xf86-video-hwcomposer xf86-video-hwcomposer-7.1"
-	mkdir -p "$subpkgdir"
-}
-
-x11_caf() {
-	depends="xf86-video-hwcomposer xf86-video-hwcomposer-7.1-caf"
-	mkdir -p "$subpkgdir"
-}
diff --git a/hybris/libhybris/0001-Make-libhybris-compile-with-musl.patch b/hybris/libhybris/0001-Make-libhybris-compile-with-musl.patch
deleted file mode 100644
index cb618059358b46df89ddfa88129c8e16fa2f50bc..0000000000000000000000000000000000000000
--- a/hybris/libhybris/0001-Make-libhybris-compile-with-musl.patch
+++ /dev/null
@@ -1,698 +0,0 @@
-From eb4efbb1320271a74cb1ee01dcdce3c088ce5abe Mon Sep 17 00:00:00 2001
-From: NeKit <nekit1000@gmail.com>
-Date: Wed, 1 Nov 2017 15:39:45 +0300
-Subject: [PATCH 1/2] Make libhybris compile with musl
-
-Hooks for some functions had to be disabled due to musl not having/exposing
-them, which might lead to problems depending on how musl/bionic are
-(in)compatible.
----
- hybris/common/hooks.c                         | 44 +++++++++++++++++++
- hybris/common/hooks_shm.c                     |  4 ++
- hybris/common/jb/dlfcn.c                      |  4 ++
- hybris/common/legacy_properties/properties.c  |  3 ++
- hybris/common/mm/bionic/libc/include/link.h   |  1 +
- .../mm/bionic/libc/private/libc_logging.h     | 13 ++++++
- hybris/common/mm/dlfcn.cpp                    |  4 ++
- hybris/common/mm/hybris_compat.h              | 11 +++++
- hybris/common/mm/linker.cpp                   | 11 +++++
- hybris/common/n/bionic/libc/include/dlfcn.h   |  4 +-
- hybris/common/n/bionic/libc/include/link.h    |  1 +
- .../n/bionic/libc/private/libc_logging.h      | 15 ++++++-
- hybris/common/n/dlfcn.cpp                     |  4 ++
- hybris/common/n/hybris_compat.cpp             |  8 ++++
- hybris/common/n/hybris_compat.h               | 22 ++++++++++
- hybris/common/o/bionic/libc/include/dlfcn.h   |  8 ++--
- hybris/common/o/dlfcn.cpp                     |  4 ++
- hybris/common/o/hybris_compat.cpp             |  8 ++++
- hybris/common/o/hybris_compat.h               | 22 ++++++++++
- hybris/include/hybris/common/musl_compat.h    | 10 +++++
- hybris/libsync/sync.c                         |  1 +
- hybris/tests/test_camera.c                    |  4 ++
- 22 files changed, 199 insertions(+), 7 deletions(-)
- create mode 100644 hybris/include/hybris/common/musl_compat.h
-
-diff --git a/hybris/common/hooks.c b/hybris/common/hooks.c
-index 03b29d4..2a3a20b 100644
---- a/hybris/common/hooks.c
-+++ b/hybris/common/hooks.c
-@@ -80,6 +80,10 @@ extern int my_property_list(void (*propfn)(const char *key, const char *value, v
- 
- #include <hybris/common/hooks.h>
- 
-+#ifndef __GLIBC__
-+#include <hybris/common/musl_compat.h>
-+#endif
-+
- #include <android-config.h>
- 
- // this is also used in bionic:
-@@ -531,6 +535,7 @@ static int _hybris_hook_pthread_attr_getstacksize(pthread_attr_t const *__attr,
-     return pthread_attr_getstacksize(realattr, stack_size);
- }
- 
-+#ifdef __GLIBC__
- static int _hybris_hook_pthread_attr_setstackaddr(pthread_attr_t *__attr, void *stack_addr)
- {
-     pthread_attr_t *realattr = (pthread_attr_t *) *(uintptr_t *) __attr;
-@@ -548,6 +553,7 @@ static int _hybris_hook_pthread_attr_getstackaddr(pthread_attr_t const *__attr,
- 
-     return pthread_attr_getstackaddr(realattr, stack_addr);
- }
-+#endif
- 
- static int _hybris_hook_pthread_attr_setstack(pthread_attr_t *__attr, void *stack_base, size_t stack_size)
- {
-@@ -1134,6 +1140,7 @@ static int _hybris_hook_pthread_rwlockattr_getpshared(pthread_rwlockattr_t *__at
-     return pthread_rwlockattr_getpshared(realattr, pshared);
- }
- 
-+#ifdef __GLIBC__
- int _hybris_hook_pthread_rwlockattr_setkind_np(pthread_rwlockattr_t *attr, int pref)
- {
-     pthread_rwlockattr_t *realattr = (pthread_rwlockattr_t *) *(uintptr_t *) attr;
-@@ -1151,6 +1158,7 @@ int _hybris_hook_pthread_rwlockattr_getkind_np(const pthread_rwlockattr_t *attr,
- 
-     return pthread_rwlockattr_getkind_np(realattr, pref);
- }
-+#endif
- 
- /*
-  * pthread_rwlock_* functions
-@@ -1500,10 +1508,14 @@ static int _hybris_hook_fgetpos(FILE *fp, bionic_fpos_t *pos)
- {
-     TRACE_HOOK("fp %p pos %p", fp, pos);
- 
-+#ifdef __GLIBC__
-     fpos_t my_fpos;
-     int ret = fgetpos(_get_actual_fp(fp), &my_fpos);
- 
-     *pos = my_fpos.__pos;
-+#else
-+    int ret = fgetpos(_get_actual_fp(fp), pos);
-+#endif
- 
-     return ret;
- }
-@@ -1589,12 +1601,16 @@ static int _hybris_hook_fsetpos(FILE *fp, const bionic_fpos_t *pos)
- {
-     TRACE_HOOK("fp %p pos %p", fp, pos);
- 
-+#ifdef __GLIBC__
-     fpos_t my_fpos;
-     my_fpos.__pos = *pos;
-     memset(&my_fpos.__state, 0, sizeof(mbstate_t));
-     mbsinit(&my_fpos.__state);
- 
-     return fsetpos(_get_actual_fp(fp), &my_fpos);
-+#else
-+    return fsetpos(_get_actual_fp(fp), pos);
-+#endif
- }
- 
- static long _hybris_hook_ftell(FILE *fp)
-@@ -1872,6 +1888,7 @@ static int _hybris_hook_versionsort(struct bionic_dirent **a,
-     return strverscmp((*a)->d_name, (*b)->d_name);
- }
- 
-+#ifdef __GLIBC__
- static int _hybris_hook_scandirat(int fd, const char *dir,
-                       struct bionic_dirent ***namelist,
-                       int (*filter) (const struct bionic_dirent *),
-@@ -1933,6 +1950,7 @@ static int _hybris_hook_scandir(const char *dir,
- {
-     return _hybris_hook_scandirat(AT_FDCWD, dir, namelist, filter, compar);
- }
-+#endif
- 
- static inline void swap(void **a, void **b)
- {
-@@ -2190,6 +2208,7 @@ int _hybris_hook_open(const char *pathname, int flags, ...)
-     return open(target_path, flags, mode);
- }
- 
-+#ifdef __GLIBC__
- /**
-  * Wrap some GCC builtin functions, which don't have any address
-  */
-@@ -2215,6 +2234,7 @@ __THROW int _hybris_hook___snprintf_chk (char *__restrict __s, size_t __n, int _
- 
-     return ret;
- }
-+#endif
- 
- static __thread void *tls_hooks[16];
- 
-@@ -2360,6 +2380,7 @@ static char* _hybris_hook_setlocale(int category, const char *locale)
-     return setlocale(category, locale);
- }
- 
-+#ifdef __GLIBC__
- static void* _hybris_hook_mmap(void *addr, size_t len, int prot,
-                   int flags, int fd, off_t offset)
- {
-@@ -2375,6 +2396,7 @@ static int _hybris_hook_munmap(void *addr, size_t length)
- 
-     return munmap(addr, length);
- }
-+#endif
- 
- extern size_t strlcat(char *dst, const char *src, size_t siz);
- extern size_t strlcpy(char *dst, const char *src, size_t siz);
-@@ -2635,7 +2657,9 @@ static struct _hook hooks_common[] = {
-     HOOK_DIRECT_NO_DEBUG(realloc),
-     HOOK_DIRECT_NO_DEBUG(memalign),
-     HOOK_DIRECT_NO_DEBUG(valloc),
-+#ifdef __GLIBC__
-     HOOK_DIRECT_NO_DEBUG(pvalloc),
-+#endif
-     HOOK_DIRECT(fread),
-     HOOK_DIRECT_NO_DEBUG(getxattr),
-     HOOK_DIRECT(mprotect),
-@@ -2685,8 +2709,10 @@ static struct _hook hooks_common[] = {
-     HOOK_DIRECT_NO_DEBUG(bcopy),
-     HOOK_DIRECT_NO_DEBUG(bzero),
-     HOOK_DIRECT_NO_DEBUG(ffs),
-+#ifdef __GLIBC__
-     HOOK_INDIRECT(__sprintf_chk),
-     HOOK_INDIRECT(__snprintf_chk),
-+#endif
-     /* pthread.h */
-     HOOK_DIRECT_NO_DEBUG(getauxval),
-     HOOK_INDIRECT(gettid),
-@@ -2745,8 +2771,10 @@ static struct _hook hooks_common[] = {
-     HOOK_INDIRECT(pthread_attr_getschedparam),
-     HOOK_INDIRECT(pthread_attr_setstacksize),
-     HOOK_INDIRECT(pthread_attr_getstacksize),
-+#ifdef __GLIBC__
-     HOOK_INDIRECT(pthread_attr_setstackaddr),
-     HOOK_INDIRECT(pthread_attr_getstackaddr),
-+#endif
-     HOOK_INDIRECT(pthread_attr_setstack),
-     HOOK_INDIRECT(pthread_attr_getstack),
-     HOOK_INDIRECT(pthread_attr_setguardsize),
-@@ -2868,8 +2896,10 @@ static struct _hook hooks_common[] = {
-     HOOK_DIRECT_NO_DEBUG(seekdir),
-     HOOK_DIRECT_NO_DEBUG(telldir),
-     HOOK_DIRECT_NO_DEBUG(dirfd),
-+#ifdef __GLIBC__
-     HOOK_INDIRECT(scandir),
-     HOOK_INDIRECT(scandirat),
-+#endif
-     HOOK_INDIRECT(alphasort),
-     HOOK_INDIRECT(versionsort),
-     /* fcntl.h */
-@@ -2893,7 +2923,9 @@ static struct _hook hooks_common[] = {
-     HOOK_DIRECT_NO_DEBUG(localtime_r),
-     HOOK_DIRECT_NO_DEBUG(gmtime),
-     HOOK_DIRECT_NO_DEBUG(abort),
-+#ifdef __GLIBC__
-     HOOK_DIRECT_NO_DEBUG(writev),
-+#endif
-     /* unistd.h */
-     HOOK_DIRECT_NO_DEBUG(access),
-     /* grp.h */
-@@ -2912,13 +2944,17 @@ static struct _hook hooks_mm[] = {
-     HOOK_DIRECT(putenv),
-     HOOK_DIRECT(clearenv),
-     HOOK_DIRECT_NO_DEBUG(dprintf),
-+#ifdef __GLIBC__
-     HOOK_DIRECT_NO_DEBUG(mallinfo),
-+#endif
-     HOOK_DIRECT(malloc_usable_size),
-     HOOK_DIRECT(posix_memalign),
-     HOOK_DIRECT(mprotect),
-     HOOK_TO(__gnu_strerror_r, _hybris_hook__gnu_strerror_r),
-+#ifdef __GLIBC__
-     HOOK_INDIRECT(pthread_rwlockattr_getkind_np),
-     HOOK_INDIRECT(pthread_rwlockattr_setkind_np),
-+#endif
-     /* unistd.h */
-     HOOK_DIRECT(fork),
-     HOOK_DIRECT_NO_DEBUG(ttyname),
-@@ -2940,15 +2976,21 @@ static struct _hook hooks_mm[] = {
-     HOOK_DIRECT(localeconv),
-     HOOK_DIRECT(setlocale),
-     /* sys/mman.h */
-+#ifdef __GLIBC__
-+    // mmap from musl considers offsets from gralloc to be invalid,
-+    // so avoid hooking it
-     HOOK_DIRECT(mmap),
-     HOOK_DIRECT(munmap),
-+#endif
-     /* wchar.h */
-     HOOK_DIRECT_NO_DEBUG(wmemchr),
-     HOOK_DIRECT_NO_DEBUG(wmemcmp),
-     HOOK_DIRECT_NO_DEBUG(wmemcpy),
-     HOOK_DIRECT_NO_DEBUG(wmemmove),
-     HOOK_DIRECT_NO_DEBUG(wmemset),
-+#ifdef __GLIBC__
-     HOOK_DIRECT_NO_DEBUG(wmempcpy),
-+#endif
-     HOOK_INDIRECT(fputws),
-     // It's enough to hook vfwprintf here as fwprintf will call it with a
-     // proper va_list in place so we don't have to handle this here.
-@@ -3002,9 +3044,11 @@ static struct _hook hooks_mm[] = {
-     /* dirent.h */
-     HOOK_TO(readdir64, _hybris_hook_readdir),
-     HOOK_TO(readdir64_r, _hybris_hook_readdir_r),
-+#ifdef __GLIBC__
-     HOOK_INDIRECT(scandir),
-     HOOK_INDIRECT(scandirat),
-     HOOK_TO(scandir64, _hybris_hook_scandir),
-+#endif
- };
- 
- 
-diff --git a/hybris/common/hooks_shm.c b/hybris/common/hooks_shm.c
-index c90cee5..27dfeef 100644
---- a/hybris/common/hooks_shm.c
-+++ b/hybris/common/hooks_shm.c
-@@ -33,6 +33,10 @@
- #include <sys/shm.h>
- #include <sys/mman.h>
- 
-+#ifndef __GLIBC__
-+#include <hybris/common/musl_compat.h>
-+#endif
-+
- /* Debug */
- #include "logging.h"
- #define LOGD(message, ...) HYBRIS_DEBUG_LOG(HOOKS, message, ##__VA_ARGS__)
-diff --git a/hybris/common/jb/dlfcn.c b/hybris/common/jb/dlfcn.c
-index 78500e4..6996527 100644
---- a/hybris/common/jb/dlfcn.c
-+++ b/hybris/common/jb/dlfcn.c
-@@ -23,6 +23,10 @@
- #include "linker.h"
- #include "linker_format.h"
- 
-+#ifndef PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
-+#define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP {{PTHREAD_MUTEX_RECURSIVE}}
-+#endif
-+
- /* This file hijacks the symbols stubbed out in libdl.so. */
- 
- #define DL_SUCCESS                    0
-diff --git a/hybris/common/legacy_properties/properties.c b/hybris/common/legacy_properties/properties.c
-index 0191e7c..c96bd59 100644
---- a/hybris/common/legacy_properties/properties.c
-+++ b/hybris/common/legacy_properties/properties.c
-@@ -36,6 +36,9 @@
- #include <poll.h>
- 
- #include <hybris/properties/properties.h>
-+#ifndef __GLIBC__
-+#include <hybris/common/musl_compat.h>
-+#endif
- #include "properties_p.h"
- 
- static const char property_service_socket[] = "/dev/socket/" PROP_SERVICE_NAME;
-diff --git a/hybris/common/mm/bionic/libc/include/link.h b/hybris/common/mm/bionic/libc/include/link.h
-index cb8e139..10d105d 100644
---- a/hybris/common/mm/bionic/libc/include/link.h
-+++ b/hybris/common/mm/bionic/libc/include/link.h
-@@ -29,6 +29,7 @@
- #define _LINK_H_
- 
- #include <sys/types.h>
-+#include <sys/cdefs.h>
- #include <elf.h>
- 
- __BEGIN_DECLS
-diff --git a/hybris/common/mm/bionic/libc/private/libc_logging.h b/hybris/common/mm/bionic/libc/private/libc_logging.h
-index 6beb47e..e526c03 100644
---- a/hybris/common/mm/bionic/libc/private/libc_logging.h
-+++ b/hybris/common/mm/bionic/libc/private/libc_logging.h
-@@ -33,6 +33,8 @@
- #include <stdarg.h>
- #include <stddef.h>
- #include <stdint.h>
-+#include <stdio.h>
-+#include <stdlib.h>
- 
- __BEGIN_DECLS
- 
-@@ -73,7 +75,18 @@ struct abort_msg_t {
- // Formats a message to the log (priority 'fatal'), then aborts.
- //
- 
-+#ifdef __GLIBC__
-  void __libc_fatal(const char* format, ...);
-+#else
-+void inline __libc_fatal(const char* format, ...)
-+{
-+  va_list ap;
-+  va_start(ap, format);
-+  vfprintf(stderr, format, ap);
-+  va_end(ap);
-+  abort();
-+}
-+#endif
- 
- //
- // Formats a message to the log (priority 'fatal'), but doesn't abort.
-diff --git a/hybris/common/mm/dlfcn.cpp b/hybris/common/mm/dlfcn.cpp
-index 13976db..d0ec9e5 100644
---- a/hybris/common/mm/dlfcn.cpp
-+++ b/hybris/common/mm/dlfcn.cpp
-@@ -31,6 +31,10 @@
- 
- #include "hybris_compat.h"
- 
-+#ifndef PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
-+#define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP {{PTHREAD_MUTEX_RECURSIVE}}
-+#endif
-+
- #ifdef WANT_ARM_TRACING
- #include "../wrappers.h"
- #endif
-diff --git a/hybris/common/mm/hybris_compat.h b/hybris/common/mm/hybris_compat.h
-index 2e10383..de1d852 100644
---- a/hybris/common/mm/hybris_compat.h
-+++ b/hybris/common/mm/hybris_compat.h
-@@ -32,6 +32,9 @@
- 
- #include <string.h>
- #include <memory.h>
-+#ifndef __GLIBC__
-+#include <hybris/common/musl_compat.h>
-+#endif
- 
- extern "C" size_t strlcpy(char *dest, const char *src, size_t size);
- extern "C" size_t strlcat(char *dst, const char *src, size_t size);
-@@ -55,4 +58,12 @@ extern "C" size_t strlcat(char *dst, const char *src, size_t size);
- #define DT_ANDROID_RELA (DT_LOOS + 4)
- #define DT_ANDROID_RELASZ (DT_LOOS + 5)
- 
-+#if defined (__aarch64__)
-+
-+#ifndef R_AARCH64_IRELATIVE
-+#define R_AARCH64_IRELATIVE 1032
-+#endif
-+
-+#endif
-+
- #endif
-diff --git a/hybris/common/mm/linker.cpp b/hybris/common/mm/linker.cpp
-index 42340cc..986d065 100644
---- a/hybris/common/mm/linker.cpp
-+++ b/hybris/common/mm/linker.cpp
-@@ -38,6 +38,9 @@
- #include <sys/mman.h>
- #include <sys/param.h>
- #include <unistd.h>
-+#ifndef __GLIBC__
-+#include <libgen.h>
-+#endif
- 
- #include <new>
- #include <string>
-@@ -1193,7 +1196,11 @@ static const char* fix_dt_needed(const char* dt_needed, const char* sopath) {
- #if !defined(__LP64__)
-   // Work around incorrect DT_NEEDED entries for old apps: http://b/21364029
-   if (get_application_target_sdk_version() <= 22) {
-+#ifdef __GLIBC__
-     const char* bname = basename(dt_needed);
-+#else
-+    const char* bname = (const char*) basename((char*)dt_needed);
-+#endif
-     if (bname != dt_needed) {
-       DL_WARN("'%s' library has invalid DT_NEEDED entry '%s'", sopath, dt_needed);
-     }
-@@ -2924,7 +2931,11 @@ bool soinfo::prelink_image() {
-   // the main executable and linker; they do not need to have dt_soname
-   if (soname_ == nullptr && this != somain && (flags_ & FLAG_LINKER) == 0 &&
-       get_application_target_sdk_version() <= 22) {
-+#ifdef __GLIBC__
-     soname_ = basename(realpath_.c_str());
-+#else
-+    soname_ = (const char*) basename((char*) realpath_.c_str());
-+#endif
-     DL_WARN("%s: is missing DT_SONAME will use basename as a replacement: \"%s\"",
-         get_realpath(), soname_);
-   }
-diff --git a/hybris/common/n/bionic/libc/include/dlfcn.h b/hybris/common/n/bionic/libc/include/dlfcn.h
-index c2e8980..692ce52 100644
---- a/hybris/common/n/bionic/libc/include/dlfcn.h
-+++ b/hybris/common/n/bionic/libc/include/dlfcn.h
-@@ -46,8 +46,8 @@ typedef struct {
- extern void* dlopen(const char*  filename, int flag);
- extern int dlclose(void*  handle);
- extern const char* dlerror(void);
--extern void* dlsym(void* handle, const char* symbol) __nonnull((2));
--extern void* dlvsym(void* handle, const char* symbol, const char* version) __nonnull((2, 3));
-+extern void* dlsym(void* handle, const char* symbol) __attribute__((nonnull((2))));
-+extern void* dlvsym(void* handle, const char* symbol, const char* version) __attribute__((nonnull((2, 3))));
- extern int dladdr(const void* addr, Dl_info *info);
- 
- enum {
-diff --git a/hybris/common/n/bionic/libc/include/link.h b/hybris/common/n/bionic/libc/include/link.h
-index cb8e139..10d105d 100644
---- a/hybris/common/n/bionic/libc/include/link.h
-+++ b/hybris/common/n/bionic/libc/include/link.h
-@@ -29,6 +29,7 @@
- #define _LINK_H_
- 
- #include <sys/types.h>
-+#include <sys/cdefs.h>
- #include <elf.h>
- 
- __BEGIN_DECLS
-diff --git a/hybris/common/n/bionic/libc/private/libc_logging.h b/hybris/common/n/bionic/libc/private/libc_logging.h
-index a696cec..2da0238 100644
---- a/hybris/common/n/bionic/libc/private/libc_logging.h
-+++ b/hybris/common/n/bionic/libc/private/libc_logging.h
-@@ -33,6 +33,8 @@
- #include <stdarg.h>
- #include <stddef.h>
- #include <stdint.h>
-+#include <stdio.h>
-+#include <stdlib.h>
- 
- __BEGIN_DECLS
- 
-@@ -73,7 +75,18 @@ struct abort_msg_t {
- // Formats a message to the log (priority 'fatal'), then aborts.
- //
- 
--void __libc_fatal(const char* format, ...);
-+#ifdef __GLIBC__
-+ void __libc_fatal(const char* format, ...);
-+#else
-+void inline __libc_fatal(const char* format, ...)
-+{
-+  va_list ap;
-+  va_start(ap, format);
-+  vfprintf(stderr, format, ap);
-+  va_end(ap);
-+  abort();
-+}
-+#endif
- 
- //
- // Formats a message to the log (priority 'fatal'), but doesn't abort.
-diff --git a/hybris/common/n/dlfcn.cpp b/hybris/common/n/dlfcn.cpp
-index 92c1349..bfdbb9c 100644
---- a/hybris/common/n/dlfcn.cpp
-+++ b/hybris/common/n/dlfcn.cpp
-@@ -30,6 +30,10 @@
- 
- #include "hybris_compat.h"
- 
-+#ifndef PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
-+#define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP {{PTHREAD_MUTEX_RECURSIVE}}
-+#endif
-+
- /* This file hijacks the symbols stubbed out in libdl.so. */
- 
- static pthread_mutex_t g_dl_mutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
-diff --git a/hybris/common/n/hybris_compat.cpp b/hybris/common/n/hybris_compat.cpp
-index cfe1e78..5238409 100644
---- a/hybris/common/n/hybris_compat.cpp
-+++ b/hybris/common/n/hybris_compat.cpp
-@@ -27,3 +27,11 @@
-  */
- 
- #include "hybris_compat.h"
-+
-+#ifndef __GLIBC__
-+const char *gnu_basename(const char *path)
-+{
-+    char *base = strrchr(path, '/');
-+    return base ? base + 1 : path;
-+}
-+#endif
-diff --git a/hybris/common/n/hybris_compat.h b/hybris/common/n/hybris_compat.h
-index 2e10383..77a0919 100644
---- a/hybris/common/n/hybris_compat.h
-+++ b/hybris/common/n/hybris_compat.h
-@@ -32,6 +32,9 @@
- 
- #include <string.h>
- #include <memory.h>
-+#ifndef __GLIBC__
-+#include <hybris/common/musl_compat.h>
-+#endif
- 
- extern "C" size_t strlcpy(char *dest, const char *src, size_t size);
- extern "C" size_t strlcat(char *dst, const char *src, size_t size);
-@@ -55,4 +58,23 @@ extern "C" size_t strlcat(char *dst, const char *src, size_t size);
- #define DT_ANDROID_RELA (DT_LOOS + 4)
- #define DT_ANDROID_RELASZ (DT_LOOS + 5)
- 
-+#if defined (__aarch64__)
-+
-+#ifndef R_AARCH64_TLS_DTPREL32
-+#define R_AARCH64_TLS_DTPREL32 1031
-+#endif
-+
-+#ifndef R_AARCH64_IRELATIVE
-+#define R_AARCH64_IRELATIVE 1032
-+#endif
-+
-+#endif
-+
-+#ifndef __GLIBC__
-+#ifndef basename
-+const char *gnu_basename(const char *path);
-+#define basename gnu_basename
-+#endif
-+#endif
-+
- #endif
-diff --git a/hybris/common/o/bionic/libc/include/dlfcn.h b/hybris/common/o/bionic/libc/include/dlfcn.h
-index acec4a2..3943882 100644
---- a/hybris/common/o/bionic/libc/include/dlfcn.h
-+++ b/hybris/common/o/bionic/libc/include/dlfcn.h
-@@ -57,11 +57,11 @@ typedef struct {
- } Dl_info;
- 
- void* dlopen(const char* filename, int flag);
--int dlclose(void* handle) __nonnull((1));
-+int dlclose(void* handle) __attribute__((nonnull((1))));
- char* dlerror(void);
--void* dlsym(void* handle, const char* symbol) __nonnull((2));
--void* dlvsym(void* handle, const char* symbol, const char* version) __nonnull((2, 3));
--int dladdr(const void* addr, Dl_info* info) __nonnull((2));
-+void* dlsym(void* handle, const char* symbol) __attribute__((nonnull((2))));
-+void* dlvsym(void* handle, const char* symbol, const char* version) __attribute__((nonnull((2, 3))));
-+int dladdr(const void* addr, Dl_info* info) __attribute__((nonnull((2))));
- 
- #define RTLD_LOCAL    0
- #define RTLD_LAZY     0x00001
-diff --git a/hybris/common/o/dlfcn.cpp b/hybris/common/o/dlfcn.cpp
-index 6fddbbb..f98f4d2 100644
---- a/hybris/common/o/dlfcn.cpp
-+++ b/hybris/common/o/dlfcn.cpp
-@@ -42,6 +42,10 @@
- #include "private/bionic_tls.h"
- #include "private/ScopedPthreadMutexLocker.h"
- 
-+#ifndef PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
-+#define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP {{PTHREAD_MUTEX_RECURSIVE}}
-+#endif
-+
- static pthread_mutex_t g_dl_mutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
- 
- static __thread char *dl_err_str;
-diff --git a/hybris/common/o/hybris_compat.cpp b/hybris/common/o/hybris_compat.cpp
-index cfe1e78..5238409 100644
---- a/hybris/common/o/hybris_compat.cpp
-+++ b/hybris/common/o/hybris_compat.cpp
-@@ -27,3 +27,11 @@
-  */
- 
- #include "hybris_compat.h"
-+
-+#ifndef __GLIBC__
-+const char *gnu_basename(const char *path)
-+{
-+    char *base = strrchr(path, '/');
-+    return base ? base + 1 : path;
-+}
-+#endif
-diff --git a/hybris/common/o/hybris_compat.h b/hybris/common/o/hybris_compat.h
-index 2e10383..77a0919 100644
---- a/hybris/common/o/hybris_compat.h
-+++ b/hybris/common/o/hybris_compat.h
-@@ -32,6 +32,9 @@
- 
- #include <string.h>
- #include <memory.h>
-+#ifndef __GLIBC__
-+#include <hybris/common/musl_compat.h>
-+#endif
- 
- extern "C" size_t strlcpy(char *dest, const char *src, size_t size);
- extern "C" size_t strlcat(char *dst, const char *src, size_t size);
-@@ -55,4 +58,23 @@ extern "C" size_t strlcat(char *dst, const char *src, size_t size);
- #define DT_ANDROID_RELA (DT_LOOS + 4)
- #define DT_ANDROID_RELASZ (DT_LOOS + 5)
- 
-+#if defined (__aarch64__)
-+
-+#ifndef R_AARCH64_TLS_DTPREL32
-+#define R_AARCH64_TLS_DTPREL32 1031
-+#endif
-+
-+#ifndef R_AARCH64_IRELATIVE
-+#define R_AARCH64_IRELATIVE 1032
-+#endif
-+
-+#endif
-+
-+#ifndef __GLIBC__
-+#ifndef basename
-+const char *gnu_basename(const char *path);
-+#define basename gnu_basename
-+#endif
-+#endif
-+
- #endif
-diff --git a/hybris/include/hybris/common/musl_compat.h b/hybris/include/hybris/common/musl_compat.h
-new file mode 100644
-index 0000000..c5f86f2
---- /dev/null
-+++ b/hybris/include/hybris/common/musl_compat.h
-@@ -0,0 +1,10 @@
-+#include <unistd.h>
-+/* taken from glibc unistd.h and fixes musl */
-+#ifndef TEMP_FAILURE_RETRY
-+#define TEMP_FAILURE_RETRY(expression) \
-+  (__extension__                                                              \
-+    ({ long int __result;                                                     \
-+       do __result = (long int) (expression);                                 \
-+       while (__result == -1L && errno == EINTR);                             \
-+       __result; }))
-+#endif
-diff --git a/hybris/libsync/sync.c b/hybris/libsync/sync.c
-index dbc3eba..e66840a 100644
---- a/hybris/libsync/sync.c
-+++ b/hybris/libsync/sync.c
-@@ -27,6 +27,7 @@
- #include <linux/sync.h>
- #include <linux/sw_sync.h>
- #else
-+#include <sys/cdefs.h>
- #include <sync/sync.h>
- #endif
- 
-diff --git a/hybris/tests/test_camera.c b/hybris/tests/test_camera.c
-index 7ac81f4..b7993a9 100644
---- a/hybris/tests/test_camera.c
-+++ b/hybris/tests/test_camera.c
-@@ -45,6 +45,10 @@
- #include <sys/stat.h>
- #include <sys/types.h>
- 
-+#ifndef __GLIBC__
-+#include <hybris/common/musl_compat.h>
-+#endif
-+
- int shot_counter = 1;
- int32_t current_zoom_level = 1;
- bool new_camera_frame_available = true;
--- 
-2.23.0
-
diff --git a/hybris/libhybris/0002-tests-Regression-test-for-EGL-glibc-TLS-conflict.patch b/hybris/libhybris/0002-tests-Regression-test-for-EGL-glibc-TLS-conflict.patch
deleted file mode 100644
index 45822729cf0bb918bc677f6ca66058db9883be7d..0000000000000000000000000000000000000000
--- a/hybris/libhybris/0002-tests-Regression-test-for-EGL-glibc-TLS-conflict.patch
+++ /dev/null
@@ -1,75 +0,0 @@
-From dd95903bd734aed6407f682aa843a293814d2ec5 Mon Sep 17 00:00:00 2001
-From: Richard Braakman <richard.braakman@jollamobile.com>
-Date: Wed, 1 Nov 2017 23:35:31 +0300
-Subject: [PATCH 2/3] [tests] Regression test for EGL-glibc TLS conflict bionic
- and glibc have different layouts for TLS space. Since libEGL used a bionic
- slot directly (in inlined code), libhybris's hooks didn't translate it
- properly and libEGL ended up overwriting some unrelated thread-local values
- in glibc.
-
-The problem only showed up when linking with libGLESv2 (which
-pulls in libEGL), not when linking with libEGL directly. That's
-why the test was added to test_glesv2.c
----
- hybris/tests/test_hwcomposer.cpp | 31 ++++++++++++++++++++++++++++++-
- 1 file changed, 30 insertions(+), 1 deletion(-)
-
-diff --git a/hybris/tests/test_hwcomposer.cpp b/hybris/tests/test_hwcomposer.cpp
-index 68917db..695291e 100644
---- a/hybris/tests/test_hwcomposer.cpp
-+++ b/hybris/tests/test_hwcomposer.cpp
-@@ -32,6 +32,23 @@
- #include <malloc.h>
- #include <sync/sync.h>
- 
-+/* Regression test: make sure that there's no conflict between
-+ * the TLS (thread-local storage) slots used via libEGL/bionic
-+ * and the TLS space allocated by the host toolchain. The array
-+ * declared here should remain unchanged regardless of GL activity.
-+ * Since this array is the first __thread storage declared in the main
-+ * program, glibc will allocate it before any others.
-+ */
-+#define SLOT_FILLER (void *) 0x11122111  /* arbitrary non-zero value */
-+#define S SLOT_FILLER
-+__thread void *tls_space[64] = {
-+    S, S, S, S, S, S, S, S,  S, S, S, S, S, S, S, S,
-+    S, S, S, S, S, S, S, S,  S, S, S, S, S, S, S, S,
-+    S, S, S, S, S, S, S, S,  S, S, S, S, S, S, S, S,
-+    S, S, S, S, S, S, S, S,  S, S, S, S, S, S, S, S,
-+};
-+#undef S
-+
- const char vertex_src [] =
- "                                        \
-    attribute vec4        position;       \
-@@ -346,7 +363,7 @@ int main(int argc, char **argv)
- 	glClearColor ( 1. , 1. , 1. , 1.);    // background color
- 	float phase = 0;
- 	int i, oldretire = -1, oldrelease = -1, oldrelease2 = -1;
--	for (i=0; i<1020*60; ++i) {
-+	for (i=0; i<60*60; ++i) {
- 		glClear(GL_COLOR_BUFFER_BIT);
- 		glUniform1f ( phase_loc , phase );  // write the value of phase to the shaders phase
- 		phase  =  fmodf ( phase + 0.5f , 2.f * 3.141f );    // and update the local variable
-@@ -372,6 +389,18 @@ int main(int argc, char **argv)
- 	printf("terminated\n");
- 	android_dlclose(baz);
- #endif
-+
-+	int bad_tls = 0;
-+	for (i=0; i<64; ++i) {
-+		if (tls_space[i] != SLOT_FILLER) {
-+			printf("TLS array slot %d polluted: %p\n", i, tls_space[i]);
-+			bad_tls++;
-+		}
-+	}
-+	if (bad_tls)
-+		return 1;
-+
-+	return 0;
- }
- 
- #else
--- 
-2.23.0
-
diff --git a/hybris/libhybris/0003-PATCH-v2-Implement-X11-EGL-platform-based-on-wayland.patch b/hybris/libhybris/0003-PATCH-v2-Implement-X11-EGL-platform-based-on-wayland.patch
deleted file mode 100644
index 27c93c06a22c475018fb13a684e4e0bb585a8fec..0000000000000000000000000000000000000000
--- a/hybris/libhybris/0003-PATCH-v2-Implement-X11-EGL-platform-based-on-wayland.patch
+++ /dev/null
@@ -1,1662 +0,0 @@
-From d3fece21813f0a0e00e751703a8998b40f8dad73 Mon Sep 17 00:00:00 2001
-From: Danct12 <danct12@disroot.org>
-Date: Sat, 8 Jun 2019 16:56:10 +0700
-Subject: [PATCH] [PATCH v2] Implement X11 EGL platform based on wayland code.
-
-Original patch by NeKit <nekit1000@gmail.com>
-Patched up for compatibility with libhybris gralloc support by Danct12 <danct12@disroot.org>
-
-* Allow window system to hook eglGetConfigAttrib (needed for X11 EGL_NATIVE_VISUAL_ID)
-
-* Use custom DRIHYBRIS Xorg extension for buffer sharing to Xorg/glamor when possible
-  Gives huge speedup over XShmPutImage, but requires patched Glamor and DDX driver to
-  utilize it
-
-* Check for window resizes using Present extension when possible
-
-* x11nativewindow: use same depth as target window for pixmap.
-  Call xcb_present_pixmap instead of xcb_copy_area to present pixmap
-
-Signed-off-by: Danct12 <danct12@disroot.org>
----
- hybris/configure.ac                          |   1 +
- hybris/egl/egl.c                             |  13 +-
- hybris/egl/platforms/Makefile.am             |   2 +-
- hybris/egl/platforms/x11/Makefile.am         |  43 ++
- hybris/egl/platforms/x11/eglplatform_x11.cpp | 229 ++++++
- hybris/egl/platforms/x11/x11_window.cpp      | 739 +++++++++++++++++++
- hybris/egl/platforms/x11/x11_window.h        | 195 +++++
- hybris/egl/platforms/x11/xcb_drihybris.c     | 167 +++++
- hybris/egl/platforms/x11/xcb_drihybris.h     | 122 +++
- hybris/egl/ws.c                              |   9 +
- hybris/egl/ws.h                              |   2 +
- 11 files changed, 1520 insertions(+), 2 deletions(-)
- create mode 100644 hybris/egl/platforms/x11/Makefile.am
- create mode 100644 hybris/egl/platforms/x11/eglplatform_x11.cpp
- create mode 100644 hybris/egl/platforms/x11/x11_window.cpp
- create mode 100644 hybris/egl/platforms/x11/x11_window.h
- create mode 100644 hybris/egl/platforms/x11/xcb_drihybris.c
- create mode 100644 hybris/egl/platforms/x11/xcb_drihybris.h
-
-diff --git a/hybris/configure.ac b/hybris/configure.ac
-index b3ddc50..7d20c34 100644
---- a/hybris/configure.ac
-+++ b/hybris/configure.ac
-@@ -264,6 +264,7 @@ AC_CONFIG_FILES([
- 	egl/platforms/null/Makefile
- 	egl/platforms/fbdev/Makefile
- 	egl/platforms/wayland/Makefile
-+	egl/platforms/x11/Makefile
- 	egl/platforms/hwcomposer/Makefile
- 	egl/platforms/hwcomposer/hwcomposer-egl.pc
- 	glesv1/glesv1_cm.pc
-diff --git a/hybris/egl/egl.c b/hybris/egl/egl.c
-index f6dcd09..4c02ebf 100644
---- a/hybris/egl/egl.c
-+++ b/hybris/egl/egl.c
-@@ -228,7 +228,6 @@ const char * eglQueryString(EGLDisplay dpy, EGLint name)
- 
- HYBRIS_IMPLEMENT_FUNCTION4(egl, EGLBoolean, eglGetConfigs, EGLDisplay, EGLConfig *, EGLint, EGLint *);
- HYBRIS_IMPLEMENT_FUNCTION5(egl, EGLBoolean, eglChooseConfig, EGLDisplay, const EGLint *, EGLConfig *, EGLint, EGLint *);
--HYBRIS_IMPLEMENT_FUNCTION4(egl, EGLBoolean, eglGetConfigAttrib, EGLDisplay, EGLConfig, EGLint, EGLint *);
- 
- EGLSurface eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config,
- 		EGLNativeWindowType win,
-@@ -461,4 +460,16 @@ EGLBoolean eglDestroyImageKHR(EGLDisplay dpy, EGLImageKHR image)
- 	return ret;
- }
- 
-+EGLBoolean eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value)
-+{
-+	HYBRIS_DLSYSM(egl, &_eglGetConfigAttrib, "eglGetConfigAttrib");
-+	struct _EGLDisplay *display = hybris_egl_display_get_mapping(dpy);
-+
-+    EGLBoolean ret = ws_eglGetConfigAttrib(display, config, attribute, value);
-+    if (ret == EGL_FALSE) {
-+        return (*_eglGetConfigAttrib)(dpy, config, attribute, value);
-+    }
-+    return ret;
-+}
-+
- // vim:ts=4:sw=4:noexpandtab
-diff --git a/hybris/egl/platforms/Makefile.am b/hybris/egl/platforms/Makefile.am
-index 4126752..c52de15 100644
---- a/hybris/egl/platforms/Makefile.am
-+++ b/hybris/egl/platforms/Makefile.am
-@@ -11,4 +11,4 @@ if WANT_WAYLAND
- SUBDIRS += wayland
- endif
- 
--
-+SUBDIRS += x11
-diff --git a/hybris/egl/platforms/x11/Makefile.am b/hybris/egl/platforms/x11/Makefile.am
-new file mode 100644
-index 0000000..4ab00f2
---- /dev/null
-+++ b/hybris/egl/platforms/x11/Makefile.am
-@@ -0,0 +1,43 @@
-+pkglib_LTLIBRARIES = eglplatform_x11.la
-+
-+eglplatform_x11_la_SOURCES = eglplatform_x11.cpp x11_window.cpp xcb_drihybris.c
-+eglplatform_x11_la_CXXFLAGS = \
-+	-I$(top_srcdir)/common \
-+	-I$(top_srcdir)/include \
-+	-I$(top_srcdir)/egl \
-+	-I$(top_srcdir)/egl/platforms/common \
-+	$(ANDROID_HEADERS_CFLAGS) \
-+	$(WAYLAND_CLIENT_CFLAGS)
-+
-+if WANT_DEBUG
-+eglplatform_x11_la_CXXFLAGS += -I$(top_srcdir)/common
-+endif
-+
-+if WANT_TRACE
-+eglplatform_x11_la_CXXFLAGS += -DDEBUG
-+endif
-+
-+if WANT_DEBUG
-+eglplatform_x11_la_CXXFLAGS += -ggdb -O0
-+endif
-+
-+if !WANT_WL_SERVERSIDE_BUFFERS
-+eglplatform_x11_la_CXXFLAGS += -DHYBRIS_NO_SERVER_SIDE_BUFFERS
-+endif
-+
-+
-+
-+eglplatform_x11_la_LDFLAGS = \
-+	-avoid-version -module -shared -export-dynamic \
-+	$(top_builddir)/egl/platforms/common/libhybris-eglplatformcommon.la \
-+	$(top_builddir)/gralloc/libgralloc.la \
-+	-lXext -lxcb -lX11-xcb -lxcb-present
-+
-+if HAS_ANDROID_4_2_0
-+eglplatform_x11_la_LDFLAGS += $(top_builddir)/libsync/libsync.la
-+endif
-+
-+if HAS_ANDROID_5_0_0
-+eglplatform_x11_la_LDFLAGS += $(top_builddir)/libsync/libsync.la
-+endif
-+
-diff --git a/hybris/egl/platforms/x11/eglplatform_x11.cpp b/hybris/egl/platforms/x11/eglplatform_x11.cpp
-new file mode 100644
-index 0000000..3a1ac4f
---- /dev/null
-+++ b/hybris/egl/platforms/x11/eglplatform_x11.cpp
-@@ -0,0 +1,229 @@
-+/****************************************************************************************
-+**
-+** Copyright (C) 2013 Jolla Ltd.
-+** Contact: Carsten Munk <carsten.munk@jollamobile.com>
-+** All rights reserved.
-+**
-+** This file is part of X11 enablement for libhybris
-+**
-+** You may use this file under the terms of the GNU Lesser General
-+** Public License version 2.1 as published by the Free Software Foundation
-+** and appearing in the file license.lgpl included in the packaging
-+** of this file.
-+**
-+** This library is free software; you can redistribute it and/or
-+** modify it under the terms of the GNU Lesser General Public
-+** License version 2.1 as published by the Free Software Foundation
-+** and appearing in the file license.lgpl included in the packaging
-+** of this file.
-+**
-+** This library is distributed in the hope that it will be useful,
-+** but WITHOUT ANY WARRANTY; without even the implied warranty of
-+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-+** Lesser General Public License for more details.
-+**
-+****************************************************************************************/
-+
-+#include <android-config.h>
-+#include <ws.h>
-+#include <malloc.h>
-+#include <assert.h>
-+#include <fcntl.h>
-+#include <stdio.h>
-+#include <stdlib.h>
-+#include <string.h>
-+#include <sys/stat.h>
-+#include <unistd.h>
-+#include <assert.h>
-+#include <stdlib.h>
-+extern "C" {
-+#include <eglplatformcommon.h>
-+};
-+#include <eglhybris.h>
-+
-+#include <EGL/eglext.h>
-+
-+extern "C" {
-+#include <wayland-client.h>
-+#include <wayland-egl.h>
-+}
-+
-+#include <hybris/gralloc/gralloc.h>
-+#include "x11_window.h"
-+#include "logging.h"
-+
-+#include <X11/Xlib.h>
-+#include <X11/Xutil.h>
-+
-+static const char *  (*_eglQueryString)(EGLDisplay dpy, EGLint name) = NULL;
-+static __eglMustCastToProperFunctionPointerType (*_eglGetProcAddress)(const char *procname) = NULL;
-+static EGLSyncKHR (*_eglCreateSyncKHR)(EGLDisplay dpy, EGLenum type, const EGLint *attrib_list) = NULL;
-+static EGLBoolean (*_eglDestroySyncKHR)(EGLDisplay dpy, EGLSyncKHR sync) = NULL;
-+static EGLint (*_eglClientWaitSyncKHR)(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout) = NULL;
-+
-+struct X11Display {
-+	_EGLDisplay base;
-+	Display *xl_display;
-+};
-+
-+extern "C" void x11ws_init_module(struct ws_egl_interface *egl_iface)
-+{
-+	hybris_gralloc_initialize(0);
-+	eglplatformcommon_init(egl_iface);
-+}
-+
-+static void _init_egl_funcs(EGLDisplay display)
-+{
-+	if (_eglQueryString != NULL)
-+		return;
-+
-+	_eglQueryString = (const char * (*)(void*, int))
-+			hybris_android_egl_dlsym("eglQueryString");
-+	assert(_eglQueryString);
-+	_eglGetProcAddress = (__eglMustCastToProperFunctionPointerType (*)(const char *))
-+			hybris_android_egl_dlsym("eglGetProcAddress");
-+	assert(_eglGetProcAddress);
-+
-+	const char *extensions = (*_eglQueryString)(display, EGL_EXTENSIONS);
-+
-+	if (strstr(extensions, "EGL_KHR_fence_sync")) {
-+		_eglCreateSyncKHR = (PFNEGLCREATESYNCKHRPROC)
-+				(*_eglGetProcAddress)("eglCreateSyncKHR");
-+		assert(_eglCreateSyncKHR);
-+		_eglDestroySyncKHR = (PFNEGLDESTROYSYNCKHRPROC)
-+				(*_eglGetProcAddress)("eglDestroySyncKHR");
-+		assert(_eglDestroySyncKHR);
-+		_eglClientWaitSyncKHR = (PFNEGLCLIENTWAITSYNCKHRPROC)
-+				(*_eglGetProcAddress)("eglClientWaitSyncKHR");
-+		assert(_eglClientWaitSyncKHR);
-+	}
-+}
-+
-+extern "C" _EGLDisplay *x11ws_GetDisplay(EGLNativeDisplayType display)
-+{
-+	X11Display *xdpy = new X11Display;
-+	xdpy->xl_display = (Display *)display;
-+
-+	return &xdpy->base;
-+}
-+
-+extern "C" void x11ws_Terminate(_EGLDisplay *dpy)
-+{
-+	X11Display *xdpy = (X11Display *)dpy;
-+	int ret = 0;
-+	delete xdpy;
-+}
-+
-+extern "C" EGLNativeWindowType x11ws_CreateWindow(EGLNativeWindowType win, _EGLDisplay *display)
-+{
-+	Window xlib_window = (Window) win;
-+	X11Display *xdpy = (X11Display *)display;
-+
-+	if (win == 0 || xdpy->xl_display == 0) {
-+		HYBRIS_ERROR("Running with EGL_PLATFORM=x11 without X server is not possible");
-+		HYBRIS_ERROR("If you want to run a standlone EGL client do it like this:");
-+		HYBRIS_ERROR(" $ export EGL_PLATFORM=null");
-+		HYBRIS_ERROR(" $ test_glevs2");
-+		abort();
-+	}
-+
-+	X11NativeWindow *window = new X11NativeWindow(xdpy->xl_display, xlib_window);
-+	window->common.incRef(&window->common);
-+	return (EGLNativeWindowType) static_cast<struct ANativeWindow *>(window);
-+}
-+
-+extern "C" void x11ws_DestroyWindow(EGLNativeWindowType win)
-+{
-+	X11NativeWindow *window = static_cast<X11NativeWindow *>((struct ANativeWindow *)win);
-+	window->common.decRef(&window->common);
-+}
-+
-+extern "C" __eglMustCastToProperFunctionPointerType x11ws_eglGetProcAddress(const char *procname)
-+{
-+	return eglplatformcommon_eglGetProcAddress(procname);
-+}
-+
-+extern "C" void x11ws_passthroughImageKHR(EGLContext *ctx, EGLenum *target, EGLClientBuffer *buffer, const EGLint **attrib_list)
-+{
-+	eglplatformcommon_passthroughImageKHR(ctx, target, buffer, attrib_list);
-+}
-+
-+extern "C" const char *x11ws_eglQueryString(EGLDisplay dpy, EGLint name, const char *(*real_eglQueryString)(EGLDisplay dpy, EGLint name))
-+{
-+	const char *ret = eglplatformcommon_eglQueryString(dpy, name, real_eglQueryString);
-+	if (ret && name == EGL_EXTENSIONS)
-+	{
-+		static char eglextensionsbuf[1024];
-+		snprintf(eglextensionsbuf, 1022, "%s %s", ret,
-+			"EGL_EXT_swap_buffers_with_damage EGL_WL_create_x11_buffer_from_image"
-+		);
-+		ret = eglextensionsbuf;
-+	}
-+	return ret;
-+}
-+
-+extern "C" void x11ws_prepareSwap(EGLDisplay dpy, EGLNativeWindowType win, EGLint *damage_rects, EGLint damage_n_rects)
-+{
-+	X11NativeWindow *window = static_cast<X11NativeWindow *>((struct ANativeWindow *)win);
-+	window->prepareSwap(damage_rects, damage_n_rects);
-+}
-+
-+extern "C" void x11ws_finishSwap(EGLDisplay dpy, EGLNativeWindowType win)
-+{
-+	_init_egl_funcs(dpy);
-+	X11NativeWindow *window = static_cast<X11NativeWindow *>((struct ANativeWindow *)win);
-+	if (_eglCreateSyncKHR) {
-+		EGLSyncKHR sync = (*_eglCreateSyncKHR)(dpy, EGL_SYNC_FENCE_KHR, NULL);
-+		(*_eglClientWaitSyncKHR)(dpy, sync, EGL_SYNC_FLUSH_COMMANDS_BIT_KHR, EGL_FOREVER_KHR);
-+		(*_eglDestroySyncKHR)(dpy, sync);
-+	}
-+	window->finishSwap();
-+}
-+
-+extern "C" void x11ws_setSwapInterval(EGLDisplay dpy, EGLNativeWindowType win, EGLint interval)
-+{
-+	X11NativeWindow *window = static_cast<X11NativeWindow *>((struct ANativeWindow *)win);
-+	window->setSwapInterval(interval);
-+}
-+
-+extern "C" EGLBoolean x11ws_eglGetConfigAttrib(struct _EGLDisplay *display, EGLConfig config, EGLint attribute, EGLint *value)
-+{
-+    TRACE("attribute:%i", attribute);
-+    if (attribute == EGL_NATIVE_VISUAL_ID)
-+    {
-+        X11Display *xdpy = (X11Display *)display;
-+        XVisualInfo visinfo_template;
-+        XVisualInfo *visinfo = NULL;
-+        int visinfos_count = 0;
-+
-+        visinfo_template.depth = 32;
-+        visinfo = XGetVisualInfo (xdpy->xl_display,
-+                            VisualDepthMask,
-+                            &visinfo_template,
-+                            &visinfos_count);
-+
-+        if (visinfos_count)
-+        {
-+            TRACE("visinfo.visualid:%i", attribute);
-+            *value = visinfo->visualid;
-+            return EGL_TRUE;
-+        }
-+
-+    }
-+    return EGL_FALSE;
-+}
-+
-+struct ws_module ws_module_info = {
-+	x11ws_init_module,
-+	x11ws_GetDisplay,
-+	x11ws_Terminate,
-+	x11ws_CreateWindow,
-+	x11ws_DestroyWindow,
-+	x11ws_eglGetProcAddress,
-+	x11ws_passthroughImageKHR,
-+	x11ws_eglQueryString,
-+	x11ws_prepareSwap,
-+	x11ws_finishSwap,
-+	x11ws_setSwapInterval,
-+    x11ws_eglGetConfigAttrib
-+};
-diff --git a/hybris/egl/platforms/x11/x11_window.cpp b/hybris/egl/platforms/x11/x11_window.cpp
-new file mode 100644
-index 0000000..6eea75b
---- /dev/null
-+++ b/hybris/egl/platforms/x11/x11_window.cpp
-@@ -0,0 +1,739 @@
-+/****************************************************************************************
-+ **
-+ ** Copyright (C) 2013 Jolla Ltd.
-+ ** Contact: Carsten Munk <carsten.munk@jollamobile.com>
-+ ** All rights reserved.
-+ **
-+ ** This file is part of Wayland enablement for libhybris
-+ **
-+ ** You may use this file under the terms of the GNU Lesser General
-+ ** Public License version 2.1 as published by the Free Software Foundation
-+ ** and appearing in the file license.lgpl included in the packaging
-+ ** of this file.
-+ **
-+ ** This library is free software; you can redistribute it and/or
-+ ** modify it under the terms of the GNU Lesser General Public
-+ ** License version 2.1 as published by the Free Software Foundation
-+ ** and appearing in the file license.lgpl included in the packaging
-+ ** of this file.
-+ **
-+ ** This library is distributed in the hope that it will be useful,
-+ ** but WITHOUT ANY WARRANTY; without even the implied warranty of
-+ ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-+ ** Lesser General Public License for more details.
-+ **
-+ ****************************************************************************************/
-+
-+#include <android-config.h>
-+#include "x11_window.h"
-+#include <assert.h>
-+#include <stdlib.h>
-+#include <string.h>
-+#include <errno.h>
-+
-+#include "logging.h"
-+#include <eglhybris.h>
-+#include "xcb_drihybris.h"
-+
-+#if ANDROID_VERSION_MAJOR>=4 && ANDROID_VERSION_MINOR>=2 || ANDROID_VERSION_MAJOR>=5
-+extern "C" {
-+#include <sync/sync.h>
-+}
-+#endif
-+
-+void X11NativeWindow::resize(unsigned int width, unsigned int height)
-+{
-+    lock();
-+    this->m_defaultWidth = this->m_width = width;
-+    this->m_defaultHeight = this->m_height = height;
-+    unlock();
-+}
-+
-+void X11NativeWindow::lock()
-+{
-+    pthread_mutex_lock(&this->mutex);
-+}
-+
-+void X11NativeWindow::unlock()
-+{
-+    pthread_mutex_unlock(&this->mutex);
-+}
-+
-+X11NativeWindow::X11NativeWindow(Display* xl_display, Window xl_window)
-+{
-+    int wayland_ok;
-+
-+    HYBRIS_TRACE_BEGIN("x11-platform", "create_window", "");
-+    this->m_window = xl_window;
-+    this->m_display = xl_display;
-+    this->m_connection = XGetXCBConnection(xl_display);
-+    this->m_image = 0;
-+    this->m_useShm = true;
-+    this->m_format = HAL_PIXEL_FORMAT_RGBA_8888;
-+
-+    const_cast<int&>(ANativeWindow::minSwapInterval) = 0;
-+    const_cast<int&>(ANativeWindow::maxSwapInterval) = 1;
-+    // This is the default as per the EGL documentation
-+    this->m_swap_interval = 1;
-+
-+    TRACE("getting X11 window information");
-+
-+    XWindowAttributes window_attributes;
-+    XGetWindowAttributes(m_display, m_window, &window_attributes);
-+
-+    TRACE("window x=%d y=%d width=%d height=%d depth=%d",
-+        window_attributes.x,
-+        window_attributes.y,
-+        window_attributes.width,
-+        window_attributes.height,
-+        window_attributes.depth);
-+
-+    m_width = window_attributes.width;
-+    m_height = window_attributes.height;
-+    m_depth = window_attributes.depth;
-+
-+    const char *env = getenv("HYBRIS_X11_FORCE_WIDTH");
-+    if (env != NULL)
-+    {
-+        m_width = atoi(env);
-+        TRACE("forced width=%d", m_width);
-+    }
-+
-+    env = getenv("HYBRIS_X11_FORCE_HEIGHT");
-+    if (env != NULL)
-+    {
-+        m_height = atoi(env);
-+        TRACE("forced height=%d", m_height);
-+    }
-+
-+    m_defaultWidth = m_width;
-+    m_defaultHeight = m_height;
-+
-+    env = getenv("HYBRIS_X11_DISABLE_SHM");
-+    if (env != NULL)
-+    {
-+        m_useShm = false;
-+        TRACE("won't use MIT-SHM");
-+    }
-+
-+    XGCValues gcvalues;
-+    m_gc = XCreateGC(m_display, m_window, 0, &gcvalues);
-+
-+    m_xcb_gc = xcb_generate_id(m_connection);
-+    xcb_create_gc(m_connection, m_xcb_gc, m_window, 0, 0);
-+
-+    m_specialEvent = 0;
-+    m_haveDRIHybris = false;
-+    tryEnableDRIHybris();
-+
-+    m_usage=GRALLOC_USAGE_HW_RENDER | GRALLOC_USAGE_HW_TEXTURE | GRALLOC_USAGE_SW_READ_OFTEN;
-+    pthread_mutex_init(&mutex, NULL);
-+    pthread_cond_init(&cond, NULL);
-+    m_queueReads = 0;
-+    m_freeBufs = 0;
-+    m_damage_rects = NULL;
-+    m_damage_n_rects = 0;
-+    m_lastBuffer = 0;
-+    setBufferCount(3);
-+    HYBRIS_TRACE_END("x11-platform", "create_window", "");
-+}
-+
-+X11NativeWindow::~X11NativeWindow()
-+{
-+    std::list<X11NativeWindowBuffer *>::iterator it = m_bufList.begin();
-+    destroyBuffers();
-+}
-+
-+// overloads from BaseNativeWindow
-+int X11NativeWindow::setSwapInterval(int interval) {
-+    TRACE("interval:%i", interval);
-+
-+    if (interval < 0)
-+        interval = 0;
-+    if (interval > 1)
-+        interval = 1;
-+
-+    HYBRIS_TRACE_BEGIN("x11-platform", "swap_interval", "=%d", interval);
-+
-+    lock();
-+    m_swap_interval = interval;
-+    unlock();
-+
-+    HYBRIS_TRACE_END("x11-platform", "swap_interval", "");
-+
-+    return 0;
-+}
-+
-+int X11NativeWindow::dequeueBuffer(BaseNativeWindowBuffer **buffer, int *fenceFd){
-+    HYBRIS_TRACE_BEGIN("x11-platform", "dequeueBuffer", "");
-+
-+    X11NativeWindowBuffer *wnb=NULL;
-+    TRACE("%p", buffer);
-+
-+    readQueue(false);
-+
-+    HYBRIS_TRACE_BEGIN("x11-platform", "dequeueBuffer_wait_for_buffer", "");
-+
-+    HYBRIS_TRACE_COUNTER("x11-platform", "m_freeBufs", "%i", m_freeBufs);
-+
-+    while (m_freeBufs == 0) {
-+        HYBRIS_TRACE_COUNTER("x11-platform", "m_freeBufs", "%i", m_freeBufs);
-+        readQueue(true);
-+    }
-+
-+    lock();
-+
-+    std::list<X11NativeWindowBuffer *>::iterator it = m_bufList.begin();
-+    for (; it != m_bufList.end(); it++)
-+    {
-+        if ((*it)->busy)
-+            continue;
-+        if ((*it)->youngest == 1)
-+            continue;
-+        break;
-+    }
-+
-+    if (it==m_bufList.end()) {
-+        HYBRIS_TRACE_BEGIN("x11-platform", "dequeueBuffer_worst_case_scenario", "");
-+        HYBRIS_TRACE_END("x11-platform", "dequeueBuffer_worst_case_scenario", "");
-+
-+        it = m_bufList.begin();
-+        for (; it != m_bufList.end() && (*it)->busy; it++)
-+        {}
-+
-+    }
-+    if (it==m_bufList.end()) {
-+        unlock();
-+        HYBRIS_TRACE_BEGIN("x11-platform", "dequeueBuffer_no_free_buffers", "");
-+        HYBRIS_TRACE_END("x11-platform", "dequeueBuffer_no_free_buffers", "");
-+        TRACE("%p: no free buffers", buffer);
-+        return NO_ERROR;
-+    }
-+
-+    wnb = *it;
-+    assert(wnb!=NULL);
-+    HYBRIS_TRACE_END("x11-platform", "dequeueBuffer_wait_for_buffer", "");
-+
-+    /* If the buffer doesn't match the window anymore, re-allocate */
-+    if (wnb->width != m_width || wnb->height != m_height
-+        || wnb->format != m_format || wnb->usage != m_usage)
-+    {
-+        TRACE("wnb:%p,win:%p %i,%i %i,%i x%x,x%x x%x,x%x",
-+            wnb,m_window,
-+            wnb->width,m_width, wnb->height,m_height,
-+            wnb->format,m_format, wnb->usage,m_usage);
-+        destroyBuffer(wnb);
-+        m_bufList.erase(it);
-+        wnb = addBuffer();
-+    }
-+
-+    wnb->busy = 1;
-+    *buffer = wnb;
-+    queue.push_back(wnb);
-+    --m_freeBufs;
-+
-+    HYBRIS_TRACE_COUNTER("x11-platform", "m_freeBufs", "%i", m_freeBufs);
-+    HYBRIS_TRACE_BEGIN("x11-platform", "dequeueBuffer_gotBuffer", "-%p", wnb);
-+    HYBRIS_TRACE_END("x11-platform", "dequeueBuffer_gotBuffer", "-%p", wnb);
-+    HYBRIS_TRACE_END("x11-platform", "dequeueBuffer_wait_for_buffer", "");
-+
-+    unlock();
-+    return NO_ERROR;
-+}
-+
-+int X11NativeWindow::lockBuffer(BaseNativeWindowBuffer* buffer){
-+    X11NativeWindowBuffer *wnb = (X11NativeWindowBuffer*) buffer;
-+    HYBRIS_TRACE_BEGIN("x11-platform", "lockBuffer", "-%p", wnb);
-+    HYBRIS_TRACE_END("x11-platform", "lockBuffer", "-%p", wnb);
-+    return NO_ERROR;
-+}
-+
-+int X11NativeWindow::readQueue(bool block)
-+{
-+    int ret = 0;
-+
-+    if (++m_queueReads == 1) {
-+        if (m_specialEvent) {
-+            xcb_generic_event_t    *ev;
-+
-+            if (!block)
-+            {
-+                while ((ev = xcb_poll_for_special_event(m_connection,
-+                                                        m_specialEvent)) != NULL) {
-+                    xcb_present_generic_event_t *ge = (xcb_present_generic_event_t *) ev;
-+                    handlePresentEvent(ge);
-+                }
-+            }
-+        }
-+
-+        // all threads waiting on the false branch will wake and return now, so we
-+        // can safely set m_queueReads to 0 here instead of relying on every thread
-+        // to decrement it. This prevents a race condition when a thread enters readQueue()
-+        // before the one in this thread returns.
-+        // The new thread would go in the false branch, and there would be no thread in the
-+        // true branch, blocking the new thread and any other that will call readQueue in
-+        // the future.
-+        m_queueReads = 0;
-+
-+        pthread_cond_broadcast(&cond);
-+
-+    } else if (block) {
-+        while (m_queueReads > 0) {
-+            pthread_cond_wait(&cond, &mutex);
-+        }
-+    }
-+
-+    return ret;
-+}
-+
-+void X11NativeWindow::prepareSwap(EGLint *damage_rects, EGLint damage_n_rects)
-+{
-+    lock();
-+    m_damage_rects = damage_rects;
-+    m_damage_n_rects = damage_n_rects;
-+    unlock();
-+}
-+
-+void X11NativeWindow::finishSwap()
-+{
-+    static int serial = 0;
-+    int ret = 0;
-+    lock();
-+
-+    X11NativeWindowBuffer *wnb = queue.front();
-+    if (!wnb) {
-+        wnb = m_lastBuffer;
-+    } else {
-+        queue.pop_front();
-+    }
-+    assert(wnb);
-+    m_lastBuffer = wnb;
-+    wnb->busy = 1;
-+
-+    // fronted.push_back(wnb);
-+
-+    m_damage_rects = NULL;
-+    m_damage_n_rects = 0;
-+    unlock();
-+
-+    if (m_haveDRIHybris) {
-+        if (wnb->pixmap == 0)
-+            wnb->pixmap_from_buffer(m_connection, m_window);
-+
-+        xcb_present_pixmap(m_connection,
-+                            m_window,
-+                            wnb->pixmap,
-+                            (uint32_t) serial++,
-+                            0,                                    /* valid */
-+                            0,                                    /* update */
-+                            0,                                    /* x_off */
-+                            0,                                    /* y_off */
-+                            None,                                 /* target_crtc */
-+                            None,
-+                            NULL,
-+                            XCB_PRESENT_OPTION_NONE,
-+                            0,
-+                            0,
-+                            0, 0, NULL);
-+        xcb_flush(m_connection);
-+
-+        lock();
-+
-+        ++m_freeBufs;
-+        HYBRIS_TRACE_COUNTER("x11-platform", "m_freeBufs", "%i", m_freeBufs);
-+
-+        std::list<X11NativeWindowBuffer *>::iterator it;
-+        for (it = m_bufList.begin(); it != m_bufList.end(); it++)
-+        {
-+            (*it)->youngest = 0;
-+        }
-+        wnb->youngest = 1;
-+        wnb->busy = 0;
-+
-+        unlock();
-+    } else {
-+        copyToX11(wnb);
-+    }
-+}
-+
-+static int debugenvchecked = 0;
-+
-+int X11NativeWindow::queueBuffer(BaseNativeWindowBuffer* buffer, int fenceFd)
-+{
-+    X11NativeWindowBuffer *wnb = (X11NativeWindowBuffer*) buffer;
-+    int ret = 0;
-+
-+    HYBRIS_TRACE_BEGIN("x11-platform", "queueBuffer", "-%p", wnb);
-+    lock();
-+
-+    if (debugenvchecked == 0)
-+    {
-+        if (getenv("HYBRIS_WAYLAND_DUMP_BUFFERS") != NULL)
-+            debugenvchecked = 2;
-+        else
-+            debugenvchecked = 1;
-+    }
-+    if (debugenvchecked == 2)
-+    {
-+        HYBRIS_TRACE_BEGIN("x11-platform", "queueBuffer_dumping_buffer", "-%p", wnb);
-+        hybris_dump_buffer_to_file(wnb->getNativeBuffer());
-+        HYBRIS_TRACE_END("x11-platform", "queueBuffer_dumping_buffer", "-%p", wnb);
-+
-+    }
-+
-+#if ANDROID_VERSION_MAJOR>=4 && ANDROID_VERSION_MINOR>=2 || ANDROID_VERSION_MAJOR>=5
-+    HYBRIS_TRACE_BEGIN("x11-platform", "queueBuffer_waiting_for_fence", "-%p", wnb);
-+    if (fenceFd >= 0)
-+    {
-+        sync_wait(fenceFd, -1);
-+        close(fenceFd);
-+    }
-+    HYBRIS_TRACE_END("x11-platform", "queueBuffer_waiting_for_fence", "-%p", wnb);
-+#endif
-+
-+    HYBRIS_TRACE_COUNTER("x11-platform", "fronted.size", "%i", fronted.size());
-+    HYBRIS_TRACE_END("x11-platform", "queueBuffer", "-%p", wnb);
-+
-+    unlock();
-+
-+    return NO_ERROR;
-+}
-+
-+int X11NativeWindow::cancelBuffer(BaseNativeWindowBuffer* buffer, int fenceFd){
-+    std::list<X11NativeWindowBuffer *>::iterator it;
-+    X11NativeWindowBuffer *wnb = (X11NativeWindowBuffer*) buffer;
-+
-+    lock();
-+    HYBRIS_TRACE_BEGIN("x11-platform", "cancelBuffer", "-%p", wnb);
-+
-+    /* Check first that it really is our buffer */
-+    for (it = m_bufList.begin(); it != m_bufList.end(); it++)
-+    {
-+        if ((*it) == wnb)
-+            break;
-+    }
-+    assert(it != m_bufList.end());
-+
-+    wnb->busy = 0;
-+    ++m_freeBufs;
-+    HYBRIS_TRACE_COUNTER("x11-platform", "m_freeBufs", "%i", m_freeBufs);
-+
-+    for (it = m_bufList.begin(); it != m_bufList.end(); it++)
-+    {
-+        (*it)->youngest = 0;
-+    }
-+    wnb->youngest = 1;
-+
-+    if (m_queueReads != 0) {
-+        // Some thread is waiting on wl_display_dispatch_queue(), possibly waiting for a wl_buffer.release
-+        // event. Since we have now cancelled a buffer push an artificial event so that the dispatch returns
-+        // and the thread can notice the cancelled buffer. This means there is a delay of one roundtrip,
-+        // but I don't see other solution except having one dedicated thread for calling wl_display_dispatch_queue().
-+        //wl_callback_destroy(wl_display_sync(m_display));
-+    }
-+
-+    HYBRIS_TRACE_END("x11-platform", "cancelBuffer", "-%p", wnb);
-+    unlock();
-+
-+    return 0;
-+}
-+
-+unsigned int X11NativeWindow::width() const {
-+    TRACE("value:%i", m_width);
-+    return m_width;
-+}
-+
-+unsigned int X11NativeWindow::height() const {
-+    TRACE("value:%i", m_height);
-+    return m_height;
-+}
-+
-+unsigned int X11NativeWindow::format() const {
-+    TRACE("value:%i", m_format);
-+    return m_format;
-+}
-+
-+unsigned int X11NativeWindow::defaultWidth() const {
-+    TRACE("value:%i", m_defaultWidth);
-+    return m_defaultWidth;
-+}
-+
-+unsigned int X11NativeWindow::defaultHeight() const {
-+    TRACE("value:%i", m_defaultHeight);
-+    return m_defaultHeight;
-+}
-+
-+unsigned int X11NativeWindow::queueLength() const {
-+    TRACE("WARN: stub");
-+    return 1;
-+}
-+
-+unsigned int X11NativeWindow::type() const {
-+    TRACE("");
-+#if ANDROID_VERSION_MAJOR>=4 && ANDROID_VERSION_MINOR>=3 || ANDROID_VERSION_MAJOR>=5
-+    /* https://android.googlesource.com/platform/system/core/+/bcfa910611b42018db580b3459101c564f802552%5E!/ */
-+    return NATIVE_WINDOW_SURFACE;
-+#else
-+    return NATIVE_WINDOW_SURFACE_TEXTURE_CLIENT;
-+#endif
-+}
-+
-+unsigned int X11NativeWindow::transformHint() const {
-+    TRACE("WARN: stub");
-+    return 0;
-+}
-+
-+/*
-+ * returns the current usage of this window
-+ */
-+unsigned int X11NativeWindow::getUsage() const {
-+    return m_usage;
-+}
-+
-+int X11NativeWindow::setBuffersFormat(int format) {
-+    if (format != m_format)
-+    {
-+        TRACE("old-format:x%x new-format:x%x", m_format, format);
-+        m_format = format;
-+        /* Buffers will be re-allocated when dequeued */
-+    } else {
-+        TRACE("format:x%x", format);
-+    }
-+    return NO_ERROR;
-+}
-+
-+void X11NativeWindow::destroyBuffer(X11NativeWindowBuffer* wnb)
-+{
-+    TRACE("wnb:%p", wnb);
-+
-+    assert(wnb != NULL);
-+
-+    int ret = 0;
-+
-+    wnb->common.decRef(&wnb->common);
-+    m_freeBufs--;
-+}
-+
-+void X11NativeWindow::destroyBuffers()
-+{
-+    TRACE("");
-+
-+    std::list<X11NativeWindowBuffer*>::iterator it = m_bufList.begin();
-+    for (; it!=m_bufList.end(); ++it)
-+    {
-+        destroyBuffer(*it);
-+        it = m_bufList.erase(it);
-+    }
-+    m_bufList.clear();
-+    m_freeBufs = 0;
-+}
-+
-+X11NativeWindowBuffer *X11NativeWindow::addBuffer() {
-+
-+    X11NativeWindowBuffer *wnb;
-+
-+    wnb = new ClientX11Buffer(m_width, m_height, m_format, m_usage, m_depth);
-+    m_bufList.push_back(wnb);
-+    ++m_freeBufs;
-+
-+    TRACE("wnb:%p width:%i height:%i format:x%x usage:x%x",
-+        wnb, wnb->width, wnb->height, wnb->format, wnb->usage);
-+
-+    return wnb;
-+}
-+
-+int X11NativeWindow::setBufferCount(int cnt) {
-+    int start = 0;
-+
-+    TRACE("cnt:%d", cnt);
-+
-+    if (m_bufList.size() == cnt)
-+        return NO_ERROR;
-+
-+    lock();
-+
-+    if (m_bufList.size() > cnt) {
-+        /* Decreasing buffer count, remove from beginning */
-+        std::list<X11NativeWindowBuffer*>::iterator it = m_bufList.begin();
-+        for (int i = 0; i <= m_bufList.size() - cnt; i++ )
-+        {
-+            destroyBuffer(*it);
-+            ++it;
-+            m_bufList.pop_front();
-+        }
-+
-+    } else {
-+        /* Increasing buffer count, start from current size */
-+        for (int i = m_bufList.size(); i < cnt; i++)
-+            X11NativeWindowBuffer *unused = addBuffer();
-+
-+    }
-+
-+    unlock();
-+
-+    return NO_ERROR;
-+}
-+
-+int X11NativeWindow::setBuffersDimensions(int width, int height) {
-+    if (m_width != width || m_height != height)
-+    {
-+        TRACE("old-size:%ix%i new-size:%ix%i", m_width, m_height, width, height);
-+        m_width = width;
-+        m_height = height;
-+        /* Buffers will be re-allocated when dequeued */
-+    } else {
-+        TRACE("size:%ix%i", width, height);
-+    }
-+    return NO_ERROR;
-+}
-+
-+int X11NativeWindow::setUsage(int usage) {
-+//     if ((usage | GRALLOC_USAGE_HW_TEXTURE) != m_usage)
-+//     {
-+//         TRACE("old-usage:x%x new-usage:x%x", m_usage, usage);
-+//         m_usage = usage | GRALLOC_USAGE_HW_TEXTURE;
-+//         /* Buffers will be re-allocated when dequeued */
-+//     } else {
-+//         TRACE("usage:x%x", usage);
-+//     }
-+    return NO_ERROR;
-+}
-+
-+void X11NativeWindow::copyToX11(X11NativeWindowBuffer *wnb) {
-+    int ret;
-+    void *vaddr;
-+    std::list<X11NativeWindowBuffer *>::iterator it;
-+
-+    ret = hybris_gralloc_lock(wnb->handle, wnb->usage, 0, 0, wnb->width, wnb->height, &vaddr);
-+    TRACE("wnb:%p gralloc lock returns %i", wnb, ret);
-+    TRACE("wnb:%p lock to vaddr %p", wnb, vaddr);
-+    TRACE("wnb:%p width=%d stride=%d height=%d format=%d", wnb, wnb->width, wnb->stride, wnb->height, wnb->format);
-+
-+    if (!m_image)
-+    {
-+        if (m_useShm)
-+        {
-+            m_image = XShmCreateImage(m_display,
-+                        CopyFromParent,
-+                        32,
-+                        ZPixmap, 0, &m_shminfo, wnb->stride, wnb->height);
-+
-+            m_shminfo.shmid = shmget(IPC_PRIVATE,
-+                m_image->bytes_per_line * m_image->height,
-+                IPC_CREAT|0777);
-+
-+            m_shminfo.shmaddr = m_image->data = (char *)shmat(m_shminfo.shmid, 0, 0);
-+            m_shminfo.readOnly = 0;
-+
-+            TRACE("m_shminfo.shmaddr %p", m_shminfo.shmaddr);
-+
-+            XShmAttach(m_display, &m_shminfo);
-+        }
-+        else
-+        {
-+            m_image = XCreateImage(m_display,
-+                                CopyFromParent,
-+                                32,
-+                                ZPixmap, 0, (char *)vaddr, wnb->stride, wnb->height, 32, 0);
-+        }
-+    }
-+
-+
-+    if (m_useShm)
-+    {
-+        memcpy(m_image->data, vaddr, m_image->bytes_per_line * m_image->height);
-+        hybris_gralloc_unlock(wnb->handle);
-+        XShmPutImage(m_display, m_window, m_gc, m_image, 0, 0, 0, 0, m_width, m_height, 0);
-+    }
-+    else
-+    {
-+        m_image->data = (char *)vaddr;
-+        XPutImage(m_display, m_window, m_gc, m_image, 0, 0, 0, 0, m_width, m_height);
-+        hybris_gralloc_unlock(wnb->handle);
-+    }
-+
-+    lock();
-+
-+    ++m_freeBufs;
-+    HYBRIS_TRACE_COUNTER("x11-platform", "m_freeBufs", "%i", m_freeBufs);
-+    for (it = m_bufList.begin(); it != m_bufList.end(); it++)
-+    {
-+        (*it)->youngest = 0;
-+    }
-+    wnb->youngest = 1;
-+    wnb->busy = 0;
-+
-+    unlock();
-+}
-+
-+void X11NativeWindow::tryEnableDRIHybris()
-+{
-+    const xcb_query_extension_reply_t *extension;
-+    xcb_void_cookie_t cookie;
-+    xcb_generic_error_t *error;
-+
-+    xcb_prefetch_extension_data (m_connection, &xcb_drihybris_id);
-+    xcb_prefetch_extension_data (m_connection, &xcb_present_id);
-+
-+    extension = xcb_get_extension_data(m_connection, &xcb_drihybris_id);
-+    if (!(extension && extension->present))
-+        return;
-+
-+    extension = xcb_get_extension_data(m_connection, &xcb_present_id);
-+    if (!(extension && extension->present))
-+        return;
-+
-+    m_specialEventId = xcb_generate_id(m_connection);
-+    m_specialEvent = xcb_register_for_special_xge(m_connection,
-+                            &xcb_present_id, m_specialEventId, NULL);
-+
-+    cookie = xcb_present_select_input_checked(m_connection,
-+            m_specialEventId, m_window,
-+            XCB_PRESENT_EVENT_MASK_COMPLETE_NOTIFY |
-+            XCB_PRESENT_EVENT_MASK_CONFIGURE_NOTIFY);
-+
-+    error = xcb_request_check(m_connection, cookie);
-+    if (error) {
-+        return;
-+    }
-+
-+    m_haveDRIHybris = true;
-+    // HYBRIS_PIXEL_FORMAT_RGBA_8888 is used in glamor for buffer import
-+    m_format = HAL_PIXEL_FORMAT_RGBA_8888;
-+}
-+
-+void X11NativeWindow::handlePresentEvent(xcb_present_generic_event_t *ge)
-+{
-+    switch (ge->evtype) {
-+    case XCB_PRESENT_CONFIGURE_NOTIFY: {
-+        xcb_present_configure_notify_event_t *ce = (xcb_present_configure_notify_event_t *) ge;
-+        printf("XCB_PRESENT_CONFIGURE_NOTIFY: %dx%d\n", ce->width, ce->height);
-+        resize(ce->width, ce->height);
-+        break;
-+    }
-+    }
-+}
-+
-+void X11NativeWindowBuffer::pixmap_from_buffer(xcb_connection_t *connection, xcb_drawable_t drawable)
-+{
-+    int32_t * fds;
-+    fds = (int32_t *)calloc(handle->numFds, sizeof(int));
-+    for (int i = 0; i < handle->numFds; i++) {
-+        fds[i] = dup(handle->data[i]);
-+    }
-+
-+    xcb_drihybris_pixmap_from_buffer_checked(connection,
-+                               (pixmap = xcb_generate_id(connection)),
-+                               drawable,
-+                               stride * height * 4,
-+                               this->width, height, stride,
-+                               windowDepth, 32,
-+                               handle->numInts,
-+                               handle->numFds,
-+                               (const uint32_t *)(handle->data + handle->numFds),
-+                               (const int32_t *)fds);
-+    xcb_flush(connection);
-+    free(fds);
-+}
-+
-+// vim: noai:ts=4:sw=4:ss=4:expandtab
-diff --git a/hybris/egl/platforms/x11/x11_window.h b/hybris/egl/platforms/x11/x11_window.h
-new file mode 100644
-index 0000000..e4464db
---- /dev/null
-+++ b/hybris/egl/platforms/x11/x11_window.h
-@@ -0,0 +1,195 @@
-+/****************************************************************************************
-+ **
-+ ** Copyright (C) 2013 Jolla Ltd.
-+ ** Contact: Carsten Munk <carsten.munk@jollamobile.com>
-+ ** All rights reserved.
-+ **
-+ ** This file is part of Wayland enablement for libhybris
-+ **
-+ ** You may use this file under the terms of the GNU Lesser General
-+ ** Public License version 2.1 as published by the Free Software Foundation
-+ ** and appearing in the file license.lgpl included in the packaging
-+ ** of this file.
-+ **
-+ ** This library is free software; you can redistribute it and/or
-+ ** modify it under the terms of the GNU Lesser General Public
-+ ** License version 2.1 as published by the Free Software Foundation
-+ ** and appearing in the file license.lgpl included in the packaging
-+ ** of this file.
-+ **
-+ ** This library is distributed in the hope that it will be useful,
-+ ** but WITHOUT ANY WARRANTY; without even the implied warranty of
-+ ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-+ ** Lesser General Public License for more details.
-+ **
-+ ****************************************************************************************/
-+
-+#ifndef X11_WINDOW_H
-+#define X11_WINDOW_H
-+#include "nativewindowbase.h"
-+#include <linux/fb.h>
-+#include <hybris/gralloc/gralloc.h>
-+extern "C" {
-+#include <X11/Xlib-xcb.h>
-+#include <xcb/present.h>
-+#include <sys/shm.h>
-+#include <X11/extensions/XShm.h>
-+#include <pthread.h>
-+}
-+#include <list>
-+#include <deque>
-+
-+class X11NativeWindowBuffer : public BaseNativeWindowBuffer
-+{
-+public:
-+    X11NativeWindowBuffer() : busy(0), youngest(0), other(0) {}
-+    X11NativeWindowBuffer(ANativeWindowBuffer *other)
-+    {
-+        ANativeWindowBuffer::width = other->width;
-+        ANativeWindowBuffer::height = other->height;
-+        ANativeWindowBuffer::format = other->format;
-+        ANativeWindowBuffer::usage = other->usage;
-+        ANativeWindowBuffer::handle = other->handle;
-+        ANativeWindowBuffer::stride = other->stride;
-+
-+        this->busy = 0;
-+        this->other = other;
-+        this->youngest = 0;
-+        this->pixmap = 0;
-+    }
-+
-+    int busy;
-+    int youngest;
-+    ANativeWindowBuffer *other;
-+    int windowDepth;
-+    xcb_pixmap_t pixmap;
-+
-+    void pixmap_from_buffer(xcb_connection_t *connection, xcb_drawable_t drawable);
-+};
-+
-+class ClientX11Buffer : public X11NativeWindowBuffer
-+{
-+friend class X11NativeWindow;
-+protected:
-+    ClientX11Buffer(        unsigned int width,
-+                            unsigned int height,
-+                            unsigned int format,
-+                            unsigned int usage,
-+                            unsigned int windowDepth)
-+    {
-+        // Base members
-+        ANativeWindowBuffer::width = width;
-+        ANativeWindowBuffer::height = height;
-+        ANativeWindowBuffer::format = format;
-+        ANativeWindowBuffer::usage = usage;
-+
-+        this->busy = 0;
-+        this->other = NULL;
-+        int alloc_ok = hybris_gralloc_allocate(this->width ? this->width : 1, this->height ? this->height : 1,
-+                this->format, this->usage,
-+                &this->handle, (uint32_t*)&this->stride);
-+        assert(alloc_ok == 0);
-+        this->youngest = 0;
-+        this->common.incRef(&this->common);
-+
-+        this->windowDepth = windowDepth;
-+        this->pixmap = 0;
-+    }
-+
-+    ~ClientX11Buffer()
-+    {
-+        hybris_gralloc_release(this->handle, 1);
-+    }
-+
-+protected:
-+    void* vaddr;
-+
-+public:
-+
-+};
-+
-+class X11NativeWindow : public BaseNativeWindow {
-+public:
-+    X11NativeWindow(Display* xl_display, Window xl_window);
-+    ~X11NativeWindow();
-+
-+    void lock();
-+    void unlock();
-+    void frame();
-+    void resize(unsigned int width, unsigned int height);
-+    void releaseBuffer(struct wl_buffer *buffer);
-+
-+    virtual int setSwapInterval(int interval);
-+    void prepareSwap(EGLint *damage_rects, EGLint damage_n_rects);
-+    void finishSwap();
-+
-+protected:
-+    // overloads from BaseNativeWindow
-+    virtual int dequeueBuffer(BaseNativeWindowBuffer **buffer, int *fenceFd);
-+    virtual int lockBuffer(BaseNativeWindowBuffer* buffer);
-+    virtual int queueBuffer(BaseNativeWindowBuffer* buffer, int fenceFd);
-+    virtual int cancelBuffer(BaseNativeWindowBuffer* buffer, int fenceFd);
-+    virtual unsigned int type() const;
-+    virtual unsigned int width() const;
-+    virtual unsigned int height() const;
-+    virtual unsigned int format() const;
-+    virtual unsigned int defaultWidth() const;
-+    virtual unsigned int defaultHeight() const;
-+    virtual unsigned int queueLength() const;
-+    virtual unsigned int transformHint() const;
-+    virtual unsigned int getUsage() const;
-+    // perform calls
-+    virtual int setUsage(int usage);
-+    virtual int setBuffersFormat(int format);
-+    virtual int setBuffersDimensions(int width, int height);
-+    virtual int setBufferCount(int cnt);
-+
-+private:
-+    X11NativeWindowBuffer *addBuffer();
-+    void destroyBuffer(X11NativeWindowBuffer *);
-+    void destroyBuffers();
-+    int readQueue(bool block);
-+
-+    void copyToX11(X11NativeWindowBuffer *wnb);
-+    void tryEnableDRIHybris();
-+    void handlePresentEvent(xcb_present_generic_event_t *ge);
-+
-+    std::list<X11NativeWindowBuffer *> m_bufList;
-+    std::list<X11NativeWindowBuffer *> fronted;
-+    std::list<X11NativeWindowBuffer *> posted;
-+    std::list<X11NativeWindowBuffer *> post_registered;
-+    std::deque<X11NativeWindowBuffer *> queue;
-+
-+    Display* m_display;
-+    Window m_window;
-+    XImage *m_image;
-+    XShmSegmentInfo m_shminfo;
-+    GC m_gc;
-+
-+    xcb_connection_t *m_connection;
-+    xcb_gcontext_t m_xcb_gc;
-+    xcb_present_event_t m_specialEventId;
-+    xcb_special_event_t *m_specialEvent;
-+
-+    bool m_useShm;
-+    bool m_haveDRIHybris;
-+    
-+    X11NativeWindowBuffer *m_lastBuffer;
-+    unsigned int m_width;
-+    unsigned int m_height;
-+    unsigned int m_depth;
-+    unsigned int m_format;
-+    unsigned int m_defaultWidth;
-+    unsigned int m_defaultHeight;
-+    unsigned int m_usage;
-+
-+    pthread_mutex_t mutex;
-+    pthread_cond_t cond;
-+    int m_queueReads;
-+    int m_freeBufs;
-+    EGLint *m_damage_rects, m_damage_n_rects;
-+    int m_swap_interval;
-+};
-+
-+#endif
-+// vim: noai:ts=4:sw=4:ss=4:expandtab
-diff --git a/hybris/egl/platforms/x11/xcb_drihybris.c b/hybris/egl/platforms/x11/xcb_drihybris.c
-new file mode 100644
-index 0000000..bec3722
---- /dev/null
-+++ b/hybris/egl/platforms/x11/xcb_drihybris.c
-@@ -0,0 +1,167 @@
-+/*
-+ * This file generated automatically from drihybris.xml by c_client.py.
-+ * Edit at your peril.
-+ */
-+
-+#include "xcb_drihybris.h"
-+#include <stddef.h>  /* for offsetof() */
-+
-+xcb_extension_t xcb_drihybris_id = { "DRIHYBRIS", 0 };
-+
-+#define ALIGNOF(type) offsetof(struct { char dummy; type member; }, member)
-+
-+int
-+xcb_drihybris_pixmap_from_buffer_sizeof (const void  *_buffer,
-+                                         int32_t      pixmap_fd)
-+{
-+    char *xcb_tmp = (char *)_buffer;
-+    const xcb_drihybris_pixmap_from_buffer_request_t *_aux = (xcb_drihybris_pixmap_from_buffer_request_t *)_buffer;
-+    unsigned int xcb_buffer_len = 0;
-+    unsigned int xcb_block_len = 0;
-+    unsigned int xcb_pad = 0;
-+    unsigned int xcb_align_to = 0;
-+
-+
-+    xcb_block_len += sizeof(xcb_drihybris_pixmap_from_buffer_request_t);
-+    xcb_tmp += xcb_block_len;
-+    xcb_buffer_len += xcb_block_len;
-+    xcb_block_len = 0;
-+    /* ints */
-+    xcb_block_len += _aux->num_ints * sizeof(uint32_t);
-+    xcb_tmp += xcb_block_len;
-+    xcb_align_to = ALIGNOF(uint32_t);
-+    /* insert padding */
-+    xcb_pad = -xcb_block_len & (xcb_align_to - 1);
-+    xcb_buffer_len += xcb_block_len + xcb_pad;
-+    if (0 != xcb_pad) {
-+        xcb_tmp += xcb_pad;
-+        xcb_pad = 0;
-+    }
-+    xcb_block_len = 0;
-+
-+    return xcb_buffer_len;
-+}
-+
-+xcb_void_cookie_t
-+xcb_drihybris_pixmap_from_buffer_checked (xcb_connection_t *c,
-+                                          xcb_pixmap_t      pixmap,
-+                                          xcb_drawable_t    drawable,
-+                                          uint32_t          size,
-+                                          uint16_t          width,
-+                                          uint16_t          height,
-+                                          uint16_t          stride,
-+                                          uint8_t           depth,
-+                                          uint8_t           bpp,
-+                                          uint16_t          num_ints,
-+                                          uint16_t          num_fds,
-+                                          const uint32_t   *ints,
-+                                          const int32_t    *fds)
-+{
-+    static const xcb_protocol_request_t xcb_req = {
-+        .count = 4,
-+        .ext = &xcb_drihybris_id,
-+        .opcode = XCB_DRIHYBRIS_PIXMAP_FROM_BUFFER,
-+        .isvoid = 1
-+    };
-+
-+    struct iovec xcb_parts[6];
-+    xcb_void_cookie_t xcb_ret;
-+    xcb_drihybris_pixmap_from_buffer_request_t xcb_out;
-+
-+    xcb_out.pixmap = pixmap;
-+    xcb_out.drawable = drawable;
-+    xcb_out.size = size;
-+    xcb_out.width = width;
-+    xcb_out.height = height;
-+    xcb_out.stride = stride;
-+    xcb_out.depth = depth;
-+    xcb_out.bpp = bpp;
-+    xcb_out.num_ints = num_ints;
-+    xcb_out.num_fds = num_fds;
-+
-+    xcb_parts[2].iov_base = (char *) &xcb_out;
-+    xcb_parts[2].iov_len = sizeof(xcb_out);
-+    xcb_parts[3].iov_base = 0;
-+    xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
-+    /* uint32_t ints */
-+    xcb_parts[4].iov_base = (char *) ints;
-+    xcb_parts[4].iov_len = num_ints * sizeof(uint32_t);
-+    xcb_parts[5].iov_base = 0;
-+    xcb_parts[5].iov_len = -xcb_parts[4].iov_len & 3;
-+
-+    xcb_ret.sequence = xcb_send_request_with_fds(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req, num_fds, fds);
-+    return xcb_ret;
-+}
-+
-+xcb_void_cookie_t
-+xcb_drihybris_pixmap_from_buffer (xcb_connection_t *c,
-+                                  xcb_pixmap_t      pixmap,
-+                                  xcb_drawable_t    drawable,
-+                                  uint32_t          size,
-+                                  uint16_t          width,
-+                                  uint16_t          height,
-+                                  uint16_t          stride,
-+                                  uint8_t           depth,
-+                                  uint8_t           bpp,
-+                                  uint16_t          num_ints,
-+                                  uint16_t          num_fds,
-+                                  const uint32_t   *ints,
-+                                  const int32_t    *fds)
-+{
-+    static const xcb_protocol_request_t xcb_req = {
-+        .count = 4,
-+        .ext = &xcb_drihybris_id,
-+        .opcode = XCB_DRIHYBRIS_PIXMAP_FROM_BUFFER,
-+        .isvoid = 1
-+    };
-+
-+    struct iovec xcb_parts[6];
-+    xcb_void_cookie_t xcb_ret;
-+    xcb_drihybris_pixmap_from_buffer_request_t xcb_out;
-+
-+    xcb_out.pixmap = pixmap;
-+    xcb_out.drawable = drawable;
-+    xcb_out.size = size;
-+    xcb_out.width = width;
-+    xcb_out.height = height;
-+    xcb_out.stride = stride;
-+    xcb_out.depth = depth;
-+    xcb_out.bpp = bpp;
-+    xcb_out.num_ints = num_ints;
-+    xcb_out.num_fds = num_fds;
-+
-+    xcb_parts[2].iov_base = (char *) &xcb_out;
-+    xcb_parts[2].iov_len = sizeof(xcb_out);
-+    xcb_parts[3].iov_base = 0;
-+    xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
-+    /* uint32_t ints */
-+    xcb_parts[4].iov_base = (char *) ints;
-+    xcb_parts[4].iov_len = num_ints * sizeof(uint32_t);
-+    xcb_parts[5].iov_base = 0;
-+    xcb_parts[5].iov_len = -xcb_parts[4].iov_len & 3;
-+
-+    xcb_ret.sequence = xcb_send_request_with_fds(c, 0, xcb_parts + 2, &xcb_req, num_fds, fds);
-+    return xcb_ret;
-+}
-+
-+uint32_t *
-+xcb_drihybris_pixmap_from_buffer_ints (const xcb_drihybris_pixmap_from_buffer_request_t *R)
-+{
-+    return (uint32_t *) (R + 1);
-+}
-+
-+int
-+xcb_drihybris_pixmap_from_buffer_ints_length (const xcb_drihybris_pixmap_from_buffer_request_t *R)
-+{
-+    return R->num_ints;
-+}
-+
-+xcb_generic_iterator_t
-+xcb_drihybris_pixmap_from_buffer_ints_end (const xcb_drihybris_pixmap_from_buffer_request_t *R)
-+{
-+    xcb_generic_iterator_t i;
-+    i.data = ((uint32_t *) (R + 1)) + (R->num_ints);
-+    i.rem = 0;
-+    i.index = (char *) i.data - (char *) R;
-+    return i;
-+}
-diff --git a/hybris/egl/platforms/x11/xcb_drihybris.h b/hybris/egl/platforms/x11/xcb_drihybris.h
-new file mode 100644
-index 0000000..974828d
---- /dev/null
-+++ b/hybris/egl/platforms/x11/xcb_drihybris.h
-@@ -0,0 +1,122 @@
-+/*
-+ * This file generated automatically from drihybris.xml by c_client.py.
-+ * Edit at your peril.
-+ */
-+
-+/**
-+ * @defgroup XCB_DRIHYBRIS_API XCB DRIHYBRIS API
-+ * @brief DRIHYBRIS XCB Protocol Implementation.
-+ * @{
-+ **/
-+
-+#ifndef DRIHYBRIS_PROTO_H
-+#define DRIHYBRIS_PROTO_H
-+
-+#include <xcb/xcb.h>
-+#include <xcb/xcbext.h>
-+
-+#ifdef __cplusplus
-+extern "C" {
-+#endif
-+
-+#define XCB_DRIHYBRIS_MAJOR_VERSION 1
-+#define XCB_DRIHYBRIS_MINOR_VERSION 0
-+
-+extern xcb_extension_t xcb_drihybris_id;
-+
-+/** Opcode for xcb_drihybris_pixmap_from_buffer. */
-+#define XCB_DRIHYBRIS_PIXMAP_FROM_BUFFER 1
-+
-+/**
-+ * @brief xcb_drihybris_pixmap_from_buffer_request_t
-+ **/
-+typedef struct xcb_drihybris_pixmap_from_buffer_request_t {
-+    uint8_t        major_opcode;
-+    uint8_t        minor_opcode;
-+    uint16_t       length;
-+    xcb_pixmap_t   pixmap;
-+    xcb_drawable_t drawable;
-+    uint32_t       size;
-+    uint16_t       width;
-+    uint16_t       height;
-+    uint16_t       stride;
-+    uint8_t        depth;
-+    uint8_t        bpp;
-+    uint16_t       num_ints;
-+    uint16_t       num_fds;
-+} xcb_drihybris_pixmap_from_buffer_request_t;
-+
-+/**
-+ * @brief xcb_drihybris_buffer_from_pixmap_cookie_t
-+ **/
-+typedef struct xcb_drihybris_buffer_from_pixmap_cookie_t {
-+    unsigned int sequence;
-+} xcb_drihybris_buffer_from_pixmap_cookie_t;
-+
-+int
-+xcb_drihybris_pixmap_from_buffer_sizeof (const void  *_buffer,
-+                                         int32_t      pixmap_fd);
-+
-+/**
-+ *
-+ * @param c The connection
-+ * @return A cookie
-+ *
-+ * Delivers a request to the X server.
-+ *
-+ * This form can be used only if the request will not cause
-+ * a reply to be generated. Any returned error will be
-+ * saved for handling by xcb_request_check().
-+ */
-+xcb_void_cookie_t
-+xcb_drihybris_pixmap_from_buffer_checked (xcb_connection_t *c,
-+                                          xcb_pixmap_t      pixmap,
-+                                          xcb_drawable_t    drawable,
-+                                          uint32_t          size,
-+                                          uint16_t          width,
-+                                          uint16_t          height,
-+                                          uint16_t          stride,
-+                                          uint8_t           depth,
-+                                          uint8_t           bpp,
-+                                          uint16_t          num_ints,
-+                                          uint16_t          num_fds,
-+                                          const uint32_t   *ints,
-+                                          const int32_t    *fds);
-+
-+/**
-+ *
-+ * @param c The connection
-+ * @return A cookie
-+ *
-+ * Delivers a request to the X server.
-+ *
-+ */
-+xcb_void_cookie_t
-+xcb_drihybris_pixmap_from_buffer (xcb_connection_t *c,
-+                                  xcb_pixmap_t      pixmap,
-+                                  xcb_drawable_t    drawable,
-+                                  uint32_t          size,
-+                                  uint16_t          width,
-+                                  uint16_t          height,
-+                                  uint16_t          stride,
-+                                  uint8_t           depth,
-+                                  uint8_t           bpp,
-+                                  uint16_t          num_ints,
-+                                  uint16_t          num_fds,
-+                                  const uint32_t   *ints,
-+                                  const int32_t    *fds);
-+
-+uint32_t *
-+xcb_drihybris_pixmap_from_buffer_ints (const xcb_drihybris_pixmap_from_buffer_request_t *R);
-+
-+int
-+xcb_drihybris_pixmap_from_buffer_ints_length (const xcb_drihybris_pixmap_from_buffer_request_t *R);
-+
-+xcb_generic_iterator_t
-+xcb_drihybris_pixmap_from_buffer_ints_end (const xcb_drihybris_pixmap_from_buffer_request_t *R);
-+
-+#ifdef __cplusplus
-+}
-+#endif
-+
-+#endif //DRIHYBRIS_PROTO_H
-diff --git a/hybris/egl/ws.c b/hybris/egl/ws.c
-index b10c704..36bc180 100644
---- a/hybris/egl/ws.c
-+++ b/hybris/egl/ws.c
-@@ -118,4 +118,13 @@ void ws_setSwapInterval(EGLDisplay dpy, EGLNativeWindowType win, EGLint interval
- 		ws->setSwapInterval(dpy, win, interval);
- }
- 
-+EGLBoolean ws_eglGetConfigAttrib(struct _EGLDisplay *display, EGLConfig config, EGLint attribute, EGLint *value)
-+{
-+	_init_ws();
-+	if (ws->eglGetConfigAttrib)
-+		return ws->eglGetConfigAttrib(display, config, attribute, value);
-+    else
-+        return EGL_FALSE;
-+}
-+
- // vim:ts=4:sw=4:noexpandtab
-diff --git a/hybris/egl/ws.h b/hybris/egl/ws.h
-index c4811c0..92b221a 100644
---- a/hybris/egl/ws.h
-+++ b/hybris/egl/ws.h
-@@ -37,6 +37,7 @@ struct ws_module {
- 	void (*prepareSwap)(EGLDisplay dpy, EGLNativeWindowType win, EGLint *damage_rects, EGLint damage_n_rects);
- 	void (*finishSwap)(EGLDisplay dpy, EGLNativeWindowType win);
- 	void (*setSwapInterval)(EGLDisplay dpy, EGLNativeWindowType win, EGLint interval);
-+    EGLBoolean (*eglGetConfigAttrib)(struct _EGLDisplay *display, EGLConfig config, EGLint attribute, EGLint *value);
- };
- 
- struct _EGLDisplay *ws_GetDisplay(EGLNativeDisplayType native);
-@@ -49,5 +50,6 @@ const char *ws_eglQueryString(EGLDisplay dpy, EGLint name, const char *(*real_eg
- void ws_prepareSwap(EGLDisplay dpy, EGLNativeWindowType win, EGLint *damage_rects, EGLint damage_n_rects);
- void ws_finishSwap(EGLDisplay dpy, EGLNativeWindowType win);
- void ws_setSwapInterval(EGLDisplay dpy, EGLNativeWindowType win, EGLint interval);
-+EGLBoolean ws_eglGetConfigAttrib(struct _EGLDisplay *display, EGLConfig config, EGLint attribute, EGLint *value);
- 
- #endif
--- 
-2.21.0
-
diff --git a/hybris/libhybris/0004-Build-test-hwcomposer-7-caf.patch b/hybris/libhybris/0004-Build-test-hwcomposer-7-caf.patch
deleted file mode 100644
index 76e19c901fd26d47f7dfe94c1fbcf76b8b68fc94..0000000000000000000000000000000000000000
--- a/hybris/libhybris/0004-Build-test-hwcomposer-7-caf.patch
+++ /dev/null
@@ -1,55 +0,0 @@
-From d1ba53c0eabdc706a19d83f5845a48012a6eb566 Mon Sep 17 00:00:00 2001
-From: NeKit <nekit1000@gmail.com>
-Date: Sat, 1 Dec 2018 00:02:52 +0100
-Subject: [PATCH] test_hwcomposer: hack to build version for Android 7 CAF
- devices
-
-Android headers from LineageOS 14.1 include needed changes in structs,
-which are conditionally activated by QTI_BSP define. By enabling that
-define we can build a separate binary of test_hwcomposer which will
-work on Android 7 CAF devices with Halium.
----
- hybris/tests/Makefile.am | 27 +++++++++++++++++++++++++++
- 1 file changed, 27 insertions(+)
-
-diff --git a/hybris/tests/Makefile.am b/hybris/tests/Makefile.am
-index 242436b..2255694 100644
---- a/hybris/tests/Makefile.am
-+++ b/hybris/tests/Makefile.am
-@@ -105,6 +105,33 @@ test_hwcomposer_LDADD = \
- 	$(top_builddir)/libsync/libsync.la \
- 	$(top_builddir)/hardware/libhardware.la
- 
-+if HAS_ANDROID_7_0_0
-+bin_PROGRAMS += test_hwcomposer_7_caf
-+endif
-+
-+test_hwcomposer_7_caf_SOURCES = test_hwcomposer.cpp
-+test_hwcomposer_7_caf_CXXFLAGS = \
-+	-I$(top_srcdir)/include \
-+	$(ANDROID_HEADERS_CFLAGS) \
-+	-DQCOM_BSP=1 -DQTI_BSP=1 \
-+	-I$(top_srcdir)/common \
-+	-I$(top_srcdir)/egl/platforms/common \
-+	-I$(top_srcdir)/egl/platforms/hwcomposer \
-+	-I$(top_srcdir)/libsync
-+
-+if WANT_MESA
-+test_hwcomposer_7_caf_CXXFLAGS += -DLIBHYBRIS_WANTS_MESA_X11_HEADERS
-+endif
-+test_hwcomposer_7_caf_LDADD = \
-+	-lm \
-+	$(top_builddir)/common/libhybris-common.la \
-+	$(top_builddir)/egl/platforms/hwcomposer/libhybris-hwcomposerwindow.la \
-+	$(top_builddir)/egl/platforms/common/libhybris-eglplatformcommon.la \
-+	$(top_builddir)/egl/libEGL.la \
-+	$(top_builddir)/glesv2/libGLESv2.la \
-+	$(top_builddir)/libsync/libsync.la \
-+	$(top_builddir)/hardware/libhardware.la
-+
- test_sensors_SOURCES = test_sensors.c
- test_sensors_CFLAGS = \
- 	-I$(top_srcdir)/include \
--- 
-2.19.1
-
diff --git a/hybris/libhybris/APKBUILD b/hybris/libhybris/APKBUILD
deleted file mode 100644
index 8a8cb205b3d7346b773f0988a9d454e5b6c940d9..0000000000000000000000000000000000000000
--- a/hybris/libhybris/APKBUILD
+++ /dev/null
@@ -1,180 +0,0 @@
-# Maintainer: TheKit <nekit1000@gmail.com>
-pkgname=libhybris
-pkgver=1.0_git20200117
-pkgrel=1
-arch="armhf aarch64"
-url="https://github.com/libhybris/libhybris"
-license="Apache-2.0"
-pkgdesc="libhybris allows to use bionic-based HW adaptations"
-_commit="605f294d3cdf70e3072b9a3077cd14758a174124"
-makedepends="autoconf automake libtool wayland-dev linux-headers bsd-compat-headers
-	libx11-dev libxcb-dev libxext-dev
-	android-headers-9.0 android-headers-7.1 android-headers-4.4"
-depends_dev="bsd-compat-headers android-headers-9.0"
-source="$pkgname-$_commit.tar.gz::https://github.com/libhybris/libhybris/archive/$_commit.tar.gz
-	0001-Make-libhybris-compile-with-musl.patch
-	0002-tests-Regression-test-for-EGL-glibc-TLS-conflict.patch
-	0003-PATCH-v2-Implement-X11-EGL-platform-based-on-wayland.patch
-	0004-Build-test-hwcomposer-7-caf.patch
-"
-_base_subpackages="$pkgname-dev
-	$pkgname-dbg
-	$pkgname-egl
-	$pkgname-gles
-	$pkgname-libwayland-egl:_wayland"
-subpackages="$_base_subpackages
-	$pkgname-9.0:_specific
-	$pkgname-7.1:_specific
-	$pkgname-4.4:_specific"
-
-# Override subpackages list for some specific arches
-if [ "$CARCH" == "aarch64" ]; then
-	subpackages="$_base_subpackages $pkgname-9.0:_specific $pkgname-7.1:_specific"
-elif [ "$CARCH" == "x86" ]; then
-	subpackages="$_base_subpackages $pkgname-9.0:_specific $pkgname-7.1:_specific $pkgname-4.4:_specific"
-fi
-
-options="!check !strip !tracedeps"
-
-builddir="$srcdir/$pkgname-$_commit"
-_tmppkgdir="$srcdir/tmpinstall"
-_main_headers_ver=9.0
-
-_bins_specific="test_audio test_camera test_egl_configs	test_gps
-	test_hwcomposer	test_hwcomposer_7_caf test_input test_lights test_media test_nfc
-	test_recorder test_sensors test_sf test_vibrator test_wifi"
-
-_libs_specific="libcamera.so.1.0.0 libhardware.so.2.0.0
-	libhybris-common.so.1.0.0 libhybris-eglplatformcommon.so.1.0.0
-	libhybris-hwcomposerwindow.so.1.0.0 libis.so.1.0.0 libmedia.so.1
-	libmedia.so.1.0.0 libnfc_ndef_nxp.so.1.0.0 libnfc_nxp.so.1.0.0
-	libsf.so.1.0.0 libsync.so.2.0.0 libui.so.1.0.0 libvibrator.so.1.0.0
-	libwifi.so.1.0.0
-	libhybris/eglplatform_fbdev.so libhybris/eglplatform_hwcomposer.so
-	libhybris/eglplatform_null.so libhybris/eglplatform_wayland.so
-	libhybris/eglplatform_x11.so"
-
-build() {
-	cd "$builddir/hybris"
-
-	NOCONFIGURE=1 ./autogen.sh
-
-	if [ "$CARCH" == "armhf" -o "$CARCH" == "armv7" ]; then
-		_vers="9.0 7.1 4.4"
-		_ldpath="/usr/libexec/droid-hybris/system/lib:/vendor/lib:/system/lib"
-		_arch="arm"
-		_enable_quirks="--enable-mali-quirks \
-				--enable-adreno-quirks"
-	elif [ "$CARCH" == "aarch64" ]; then
-		_vers="9.0 7.1"
-		_ldpath="/usr/libexec/droid-hybris/system/lib64:/vendor/lib64:/system/lib64"
-		_arch="arm64"
-		_enable_quirks="--enable-mali-quirks \
-				--enable-adreno-quirks"
-	elif [ "$CARCH" == "x86" ]; then
-		_vers="9.0 7.1 4.4"
-		_ldpath="/usr/libexec/droid-hybris/system/lib:/vendor/lib:/system/lib"
-		_arch="x86"
-	fi
-
-	for _headers_ver in $_vers; do
-		msg "building $pkgname-$_headers_ver"
-		./configure \
-			--prefix=/usr \
-			--enable-wayland \
-			--enable-trace \
-			--enable-debug \
-			--enable-experimental \
-			--with-android-headers=/usr/include/android-$_headers_ver \
-			--with-default-hybris-ld-library-path=$_ldpath \
-			--enable-arch=$_arch \
-			$_enable_quirks \
-			--enable-property-cache
-		make clean
-		make
-		make DESTDIR="$_tmppkgdir/$pkgname-$_headers_ver" install
-	done
-}
-
-package() {
-	cd "$builddir/hybris"
-
-	# make DESTDIR="$pkgdir" install
-	mkdir -p "$pkgdir"
-	cp -a "$_tmppkgdir"/"$pkgname-$_main_headers_ver"/* "$pkgdir"
-
-	for _bin in $_bins_specific; do
-		rm "$pkgdir/usr/bin/$_bin" || true
-	done
-
-	for _lib in $_libs_specific; do
-		rm "$pkgdir/usr/lib/$_lib"
-	done
-}
-
-_specific() {
-	depends="$pkgname"
-
-	for _bin in $_bins_specific; do
-		install -Dm755 "$_tmppkgdir/$subpkgname/usr/bin/$_bin" \
-			"$subpkgdir/usr/bin/$_bin" || true
-	done
-
-	for _lib in $_libs_specific; do
-		install -Dm755 "$_tmppkgdir/$subpkgname/usr/lib/$_lib" \
-			"$subpkgdir/usr/lib/$_lib"
-	done
-}
-
-egl() {
-	depends="$pkgname"
-	pkgdesc="libhybris libEGL runtime libraries"
-	install="$subpkgname.post-install"
-
-	install -d "$subpkgdir"/usr/lib/libhybris-egl
-	mv "$pkgdir"/usr/lib/libEGL.so.* \
-		"$subpkgdir"/usr/lib/libhybris-egl/
-}
-
-gles() {
-	depends="$pkgname"
-	pkgdesc="libhybris libGLESv2 runtime libraries"
-	install -d "$subpkgdir"/usr/lib/libhybris-egl
-	mv "$pkgdir"/usr/lib/libGLES*.so.* \
-		"$subpkgdir"/usr/lib/libhybris-egl/
-}
-
-_wayland() {
-	depends="$pkgname"
-	pkgdesc="libhybris libwayland-egl library"
-	mkdir -p "$subpkgdir"/usr/lib/libhybris-egl
-	mv "$pkgdir"/usr/lib/libwayland-egl.so.* "$subpkgdir"/usr/lib/libhybris-egl/
-}
-
-dev() {
-	default_dev
-
-	# Avoid conflicts with mesa-dev
-	install -d "$subpkgdir"/usr/lib/libhybris-egl
-
-	mv "$subpkgdir"/usr/lib/lib*GL*.so "$subpkgdir"/usr/lib/libhybris-egl
-	mv "$subpkgdir"/usr/lib/libwayland-egl.so "$subpkgdir"/usr/lib/libhybris-egl
-
-	cd "$subpkgdir"/usr/lib/pkgconfig
-	rm -f egl.pc glesv*.pc wayland-egl.pc
-
-	cd "$subpkgdir"/usr/include
-	# Move libhybris-provided headers into hybris dir
-	mv CL EGL GLES GLES2 KHR VG hybris
-
-	# Symlink eglhybris.h
-	mkdir -p EGL
-	cd EGL
-	ln -s ../hybris/EGL/eglhybris.h .
-}
-
-sha512sums="9d4705eab02d0f1cd8c2e9fba39f03a7ea73dd0afebd544cf56343b9d002cdb07cc1fd4ffa44802c610782b32cd94d97b0b33a4fdbb7dd80a090965128d03998  libhybris-605f294d3cdf70e3072b9a3077cd14758a174124.tar.gz
-a1b707c9aaa7bde2907d04742d7d582df57949415e1afe16c3b461671421a18643008e19aa006e9e67b9644392ec4e2d58c6de725d2db2df077a49526f2893ce  0001-Make-libhybris-compile-with-musl.patch
-64fa516c823859c062d175a51fc86846dc85f4e98989cf12c7cb8c9a13ffffb748f6152543f1a6e22f5fe78eb619880262b3c8ff3b6cbd314241fec16ef2eff5  0002-tests-Regression-test-for-EGL-glibc-TLS-conflict.patch
-db7bb0ffc04042b32d870db364df4d38d9769978f26d71f98dd2569b4cae7fb3839c7a0c421b465f931a57fcde38b8eca091b7ae0062e32a7e09b93a701397f3  0003-PATCH-v2-Implement-X11-EGL-platform-based-on-wayland.patch
-eda57804fefa1d586e90fb2198c310f65e6dbc7e09b5d1dd7d15df4ab152c4c8915c212230a92c35ec8a013d3ec7a7b1d289653bedb46b7eb2850a477ccebe16  0004-Build-test-hwcomposer-7-caf.patch"
diff --git a/hybris/libhybris/libhybris-egl.post-install b/hybris/libhybris/libhybris-egl.post-install
deleted file mode 100644
index 90180972671310e7a3932b5998aaf1153654f29b..0000000000000000000000000000000000000000
--- a/hybris/libhybris/libhybris-egl.post-install
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/bin/sh
-KARCH=$(uname -m)
-
-case "$KARCH" in
-	armv7l)
-		ARCH=armhf
-		;;
-	*)
-		ARCH="$KARCH"
-		;;
-esac
-
-if [ ! -f /etc/ld-musl-$ARCH.path ]; then
-	echo "/usr/lib/libhybris-egl:/lib:/usr/local/lib:/usr/lib" > /etc/ld-musl-$ARCH.path
-fi
diff --git a/hybris/lxc-android/0001-lxcconfig.patch b/hybris/lxc-android/0001-lxcconfig.patch
deleted file mode 100644
index a6ae990345bcebc6da5c5a7db8ca24fce38ab619..0000000000000000000000000000000000000000
--- a/hybris/lxc-android/0001-lxcconfig.patch
+++ /dev/null
@@ -1,31 +0,0 @@
-diff --git a/var/lib/lxc/android/config b/var/lib/lxc/android/config
-index 912b72c..af33a23 100644
---- a/var/lib/lxc/android/config
-+++ b/var/lib/lxc/android/config
-@@ -1,18 +1,17 @@
--lxc.rootfs = /var/lib/lxc/android/rootfs
--lxc.utsname = armhf
-+lxc.rootfs.path = /var/lib/lxc/android/rootfs
-+lxc.uts.name = armhf
- 
--lxc.network.type = none
-+lxc.net.0.type = none
- 
--lxc.devttydir = lxc
--lxc.tty = 4
--lxc.pts = 1024
-+lxc.tty.dir = lxc
-+lxc.tty.max  = 4
-+lxc.pty.max = 1024
- lxc.arch = armhf
- lxc.cap.drop = mac_admin mac_override
--lxc.pivotdir = lxc_putold
- 
- lxc.hook.pre-start = /var/lib/lxc/android/pre-start.sh
- 
--lxc.init_cmd = /init
-+lxc.init.cmd = /init
- 
--lxc.aa_profile = unconfined
-+lxc.apparmor.profile = unconfined
- lxc.autodev = 0
diff --git a/hybris/lxc-android/0002-fix-android-rules.patch b/hybris/lxc-android/0002-fix-android-rules.patch
deleted file mode 100644
index 67e4642110163014e822ae08957cde829442f463..0000000000000000000000000000000000000000
--- a/hybris/lxc-android/0002-fix-android-rules.patch
+++ /dev/null
@@ -1,25 +0,0 @@
-diff --git a/lib/udev/rules.d/65-android.rules b/lib/udev/rules.d/65-android.rules
-index b3233aa..99fac2f 100644
---- a/lib/udev/rules.d/65-android.rules
-+++ b/lib/udev/rules.d/65-android.rules
-@@ -12,15 +12,15 @@ ACTION=="add", KERNEL=="binder", MODE="0666"
- SUBSYSTEM=="graphics", KERNEL=="*", SYMLINK+="graphics/%k"
- 
- # input devices
--ACTION=="add", KERNEL=="event[0-9]*", GROUP="android_input", MODE="0660"
-+ACTION=="add", KERNEL=="event[0-9]*", GROUP="aid_input", MODE="0660"
- 
- # misc devices
--ACTION=="add", KERNEL=="alarm", OWNER="system", GROUP="phablet", MODE="0660"
--ACTION=="add", KERNEL=="uhid", OWNER="system", GROUP="system", MODE="0660"
-+ACTION=="add", KERNEL=="alarm", OWNER="aid_system", GROUP="plugdev", MODE="0660"
-+ACTION=="add", KERNEL=="uhid", OWNER="aid_system", GROUP="aid_system", MODE="0660"
- ACTION=="add", KERNEL=="mtp_usb", OWNER="root", GROUP="plugdev", MODE="0660"
- 
- # memory
--ACTION=="add", KERNEL=="ashmem", OWNER="system", GROUP="system", MODE="0666"
-+ACTION=="add", KERNEL=="ashmem", OWNER="aid_system", GROUP="aid_system", MODE="0666"
- 
- # rfkill
--ACTION=="add", KERNEL=="rfkill", GROUP="android_input", MODE="0660"
-+ACTION=="add", KERNEL=="rfkill", GROUP="aid_input", MODE="0660"
diff --git a/hybris/lxc-android/APKBUILD b/hybris/lxc-android/APKBUILD
deleted file mode 100644
index 619a8e2717647a19377fedf056278d05f8c34e24..0000000000000000000000000000000000000000
--- a/hybris/lxc-android/APKBUILD
+++ /dev/null
@@ -1,55 +0,0 @@
-# Maintainer: TheKit <nekit1000@gmail.com>
-pkgname=lxc-android
-pkgver=1.0_git20190315
-pkgrel=2
-arch="aarch64 armhf armv7"
-url="https://github.com/Halium/lxc-android"
-license="Apache"
-depends="lxc shadow"
-_commit="9551443e5ab11d0d21cb544f681bcb7603b870de"
-install="$pkgname.post-install"
-source="$pkgname-$_commit.tar.gz::https://github.com/Halium/lxc-android/archive/$_commit.tar.gz
-	add_android_groups.sh
-	logcat
-	pre-start.sh
-	0001-lxcconfig.patch
-	0002-fix-android-rules.patch
-	lxc-android.init"
-pkgdesc="Configuration for starting Halium build of Android inside LXC container"
-options="!check"
-
-builddir="$srcdir/$pkgname-$_commit"
-
-package() {
-	mkdir -p "$pkgdir"
-	cp -r "$builddir"/* "$pkgdir"
-
-	# Remove unneeded udev rule override
-	rm -f "$pkgdir/etc/udev/rules.d/50-firmware.rules"
-	rm -f "$pkgdir/etc/udev/rules.d/60-persistent-v4l.rules"
-
-	# Remove systemd units
-	rm -rf "$pkgdir/etc/systemd"
-	rm -rf "$pkgdir/lib/systemd"
-
-	# Install wrapper so pre-start.sh could be provided by device package
-	mv "$pkgdir/var/lib/lxc/android/pre-start.sh" "$pkgdir/var/lib/lxc/android/pre-start.default.sh"
-	install -m755 "$srcdir/pre-start.sh" "$pkgdir/var/lib/lxc/android/pre-start.sh"
-
-	# OpenRC services
-	install -Dm755 "$srcdir/lxc-android.init" \
-		"$pkgdir/etc/init.d/lxc-android"
-
-	install -Dm755 "$srcdir/logcat" \
-		"$pkgdir/usr/bin/logcat"
-
-	install -Dm755 "$srcdir/add_android_groups.sh" \
-		"$pkgdir/usr/sbin/add_android_groups.sh"
-}
-sha512sums="348650f24464abb7a5d2b3e86e762efbdf770bf5f91d4fb12eb62290e3e29b94bcb91fac36cb0b550f4cb1ad9941b97ea7b7c44cccdf9af51d6b35233b6fe46d  lxc-android-9551443e5ab11d0d21cb544f681bcb7603b870de.tar.gz
-5917947c88e47e7ce982822b8d286073da6b8104a0c3df335b1358908cff0e3d819573a341392958aafb533503847ed2b188cb0e88086a8be16244383a577862  add_android_groups.sh
-7c5931671a78ab8222f1c99b9720be328883c8961b7966daf71fd8a7093365d1a2b8785196399534c323585b1c70d723df7c1b52a94d533c62c4942e0eb267f0  logcat
-ef7081ea55a1acd5a6c5a973b4a7fc79bad4d5fdc721bc481e4ed92962a8ba9b70634e2a0a8f0afd28c14bd1fd4e1956914f68239c3dc34e41e167254252b1df  pre-start.sh
-7e8981ba9c779bf893dfddbe495dcaacfa43154748e21dd14fed2696d50b55807585d7168b79d73769d1381bb9974d7661479a303bacef883da0e0cf07dd0ad7  0001-lxcconfig.patch
-d5772e4776464acc016854cec8a7348e4226696c343eae3bf5e08fb5ad23155d883c23ed5d00e7ff3876907f516e66dd4438c7894c8441dd9b00d1f8f9f22620  0002-fix-android-rules.patch
-ad373e26fb4850f887ca0be76a4c5f19115e214dcbdc315cf24e41eabfd03eebf8f19085a49c97661861b16e8005355c7fd10e86acdb4593d43250e3fed998fb  lxc-android.init"
diff --git a/hybris/lxc-android/add_android_groups.sh b/hybris/lxc-android/add_android_groups.sh
deleted file mode 100644
index cde2a065c06b03c9d9cb5055ac9a6268b8baf88a..0000000000000000000000000000000000000000
--- a/hybris/lxc-android/add_android_groups.sh
+++ /dev/null
@@ -1,219 +0,0 @@
-#!/bin/sh
-groupadd --gid 1000 aid_system
-useradd --gid 1000 --no-create-home --no-user-group --system --uid 1000 aid_system
-
-groupadd --gid 1001 aid_radio
-useradd --gid 1001 --no-create-home --no-user-group --system --uid 1001 aid_radio
-
-groupadd --gid 1002 aid_bluetooth
-useradd --gid 1002 --no-create-home --no-user-group --system --uid 1002 aid_bluetooth
-
-groupadd --gid 1003 aid_graphics
-useradd --gid 1003 --no-create-home --no-user-group --system --uid 1003 aid_graphics
-
-groupadd --gid 1004 aid_input
-useradd --gid 1004 --no-create-home --no-user-group --system --uid 1004 aid_input
-
-groupadd --gid 1005 aid_audio
-useradd --gid 1005 --no-create-home --no-user-group --system --uid 1005 aid_audio
-
-groupadd --gid 1006 aid_camera
-useradd --gid 1006 --no-create-home --no-user-group --system --uid 1006 aid_camera
-
-groupadd --gid 1007 aid_log
-useradd --gid 1007 --no-create-home --no-user-group --system --uid 1007 aid_log
-
-groupadd --gid 1008 aid_compass
-useradd --gid 1008 --no-create-home --no-user-group --system --uid 1008 aid_compass
-
-groupadd --gid 1009 aid_mount
-useradd --gid 1009 --no-create-home --no-user-group --system --uid 1009 aid_mount
-
-groupadd --gid 1010 aid_wifi
-useradd --gid 1010 --no-create-home --no-user-group --system --uid 1010 aid_wifi
-
-groupadd --gid 1011 aid_adb
-useradd --gid 1011 --no-create-home --no-user-group --system --uid 1011 aid_adb
-
-groupadd --gid 1012 aid_install
-useradd --gid 1012 --no-create-home --no-user-group --system --uid 1012 aid_install
-
-groupadd --gid 1013 aid_media
-useradd --gid 1013 --no-create-home --no-user-group --system --uid 1013 aid_media
-
-groupadd --gid 1014 aid_dhcp
-useradd --gid 1014 --no-create-home --no-user-group --system --uid 1014 aid_dhcp
-
-groupadd --gid 1015 aid_sdcard_rw
-useradd --gid 1015 --no-create-home --no-user-group --system --uid 1015 aid_sdcard_rw
-
-groupadd --gid 1016 aid_vpn
-useradd --gid 1016 --no-create-home --no-user-group --system --uid 1016 aid_vpn
-
-groupadd --gid 1017 aid_keystore
-useradd --gid 1017 --no-create-home --no-user-group --system --uid 1017 aid_keystore
-
-groupadd --gid 1018 aid_usb
-useradd --gid 1018 --no-create-home --no-user-group --system --uid 1018 aid_usb
-
-groupadd --gid 1019 aid_drm
-useradd --gid 1019 --no-create-home --no-user-group --system --uid 1019 aid_drm
-
-groupadd --gid 1020 aid_mdnsr
-useradd --gid 1020 --no-create-home --no-user-group --system --uid 1020 aid_mdnsr
-
-groupadd --gid 1021 aid_gps
-useradd --gid 1021 --no-create-home --no-user-group --system --uid 1021 aid_gps
-
-groupadd --gid 1023 aid_media_rw
-useradd --gid 1023 --no-create-home --no-user-group --system --uid 1023 aid_media_rw
-
-groupadd --gid 1024 aid_mtp
-useradd --gid 1024 --no-create-home --no-user-group --system --uid 1024 aid_mtp
-
-groupadd --gid 1026 aid_drmrpc
-useradd --gid 1026 --no-create-home --no-user-group --system --uid 1026 aid_drmrpc
-
-groupadd --gid 1027 aid_nfc
-useradd --gid 1027 --no-create-home --no-user-group --system --uid 1027 aid_nfc
-
-groupadd --gid 1028 aid_sdcard_r
-useradd --gid 1028 --no-create-home --no-user-group --system --uid 1028 aid_sdcard_r
-
-groupadd --gid 1029 aid_clat
-useradd --gid 1029 --no-create-home --no-user-group --system --uid 1029 aid_clat
-
-groupadd --gid 1030 aid_loop_radio
-useradd --gid 1030 --no-create-home --no-user-group --system --uid 1030 aid_loop_radio
-
-groupadd --gid 1031 aid_mediadrm
-useradd --gid 1031 --no-create-home --no-user-group --system --uid 1031 aid_mediadrm
-
-groupadd --gid 1032 aid_package_info
-useradd --gid 1032 --no-create-home --no-user-group --system --uid 1032 aid_package_info
-
-groupadd --gid 1033 aid_sdcard_pics
-useradd --gid 1033 --no-create-home --no-user-group --system --uid 1033 aid_sdcard_pics
-
-groupadd --gid 1034 aid_sdcard_av
-useradd --gid 1034 --no-create-home --no-user-group --system --uid 1034 aid_sdcard_av
-
-groupadd --gid 1035 aid_sdcard_all
-useradd --gid 1035 --no-create-home --no-user-group --system --uid 1035 aid_sdcard_all
-
-groupadd --gid 1036 aid_logd
-useradd --gid 1036 --no-create-home --no-user-group --system --uid 1036 aid_logd
-
-groupadd --gid 1037 aid_shared_relro
-useradd --gid 1037 --no-create-home --no-user-group --system --uid 1037 aid_shared_relro
-
-groupadd --gid 1038 aid_dbus
-useradd --gid 1038 --no-create-home --no-user-group --system --uid 1038 aid_dbus
-
-groupadd --gid 1039 aid_tlsdate
-useradd --gid 1039 --no-create-home --no-user-group --system --uid 1039 aid_tlsdate
-
-groupadd --gid 1040 aid_mediaex
-useradd --gid 1040 --no-create-home --no-user-group --system --uid 1040 aid_mediaex
-
-groupadd --gid 1041 aid_audioserver
-useradd --gid 1041 --no-create-home --no-user-group --system --uid 1041 aid_audioserver
-
-groupadd --gid 1042 aid_metrics_coll
-useradd --gid 1042 --no-create-home --no-user-group --system --uid 1042 aid_metrics_coll
-
-groupadd --gid 1043 aid_metricsd
-useradd --gid 1043 --no-create-home --no-user-group --system --uid 1043 aid_metricsd
-
-groupadd --gid 1044 aid_webserv
-useradd --gid 1044 --no-create-home --no-user-group --system --uid 1044 aid_webserv
-
-groupadd --gid 1045 aid_debuggerd
-useradd --gid 1045 --no-create-home --no-user-group --system --uid 1045 aid_debuggerd
-
-groupadd --gid 1046 aid_mediacodec
-useradd --gid 1046 --no-create-home --no-user-group --system --uid 1046 aid_mediacodec
-
-groupadd --gid 1047 aid_cameraserver
-useradd --gid 1047 --no-create-home --no-user-group --system --uid 1047 aid_cameraserver
-
-groupadd --gid 1048 aid_firewall
-useradd --gid 1048 --no-create-home --no-user-group --system --uid 1048 aid_firewall
-
-groupadd --gid 1049 aid_trunks
-useradd --gid 1049 --no-create-home --no-user-group --system --uid 1049 aid_trunks
-
-groupadd --gid 1050 aid_nvram
-useradd --gid 1050 --no-create-home --no-user-group --system --uid 1050 aid_nvram
-
-groupadd --gid 1051 aid_dns
-useradd --gid 1051 --no-create-home --no-user-group --system --uid 1051 aid_dns
-
-groupadd --gid 1052 aid_dns_tether
-useradd --gid 1052 --no-create-home --no-user-group --system --uid 1052 aid_dns_tether
-
-groupadd --gid 2000 aid_shell
-useradd --gid 2000 --no-create-home --no-user-group --system --uid 2000 aid_shell
-
-groupadd --gid 2001 aid_cache
-useradd --gid 2001 --no-create-home --no-user-group --system --uid 2001 aid_cache
-
-groupadd --gid 2002 aid_diag
-useradd --gid 2002 --no-create-home --no-user-group --system --uid 2002 aid_diag
-
-groupadd --gid 2950 aid_qcom_diag
-useradd --gid 2950 --no-create-home --no-user-group --system --uid 2950 aid_qcom_diag
-
-groupadd --gid 2951 aid_rfs
-useradd --gid 2951 --no-create-home --no-user-group --system --uid 2951 aid_rfs
-
-groupadd --gid 2952 aid_rfs_shared
-useradd --gid 2952 --no-create-home --no-user-group --system --uid 2952 aid_rfs_shared
-
-groupadd --gid 3001 aid_net_bt_admin
-useradd --gid 3001 --no-create-home --no-user-group --system --uid 3001 aid_net_bt_admin
-
-groupadd --gid 3002 aid_net_bt
-useradd --gid 3002 --no-create-home --no-user-group --system --uid 3002 aid_net_bt
-
-groupadd --gid 3003 aid_inet
-useradd --gid 3003 --no-create-home --no-user-group --system --uid 3003 aid_inet
-
-groupadd --gid 3004 aid_net_raw
-useradd --gid 3004 --no-create-home --no-user-group --system --uid 3004 aid_net_raw
-
-groupadd --gid 3005 aid_net_admin
-useradd --gid 3005 --no-create-home --no-user-group --system --uid 3005 aid_net_admin
-
-groupadd --gid 3006 aid_net_bw_stats
-useradd --gid 3006 --no-create-home --no-user-group --system --uid 3006 aid_net_bw_stats
-
-groupadd --gid 3007 aid_net_bw_acct
-useradd --gid 3007 --no-create-home --no-user-group --system --uid 3007 aid_net_bw_acct
-
-groupadd --gid 3008 aid_net_bt_stack
-useradd --gid 3008 --no-create-home --no-user-group --system --uid 3008 aid_net_bt_stack
-
-groupadd --gid 3009 aid_readproc
-useradd --gid 3009 --no-create-home --no-user-group --system --uid 3009 aid_readproc
-
-groupadd --gid 3010 aid_wakelock
-useradd --gid 3010 --no-create-home --no-user-group --system --uid 3010 aid_wakelock
-
-groupadd --gid 3011 aid_sensors
-useradd --gid 3011 --no-create-home --no-user-group --system --uid 3011 aid_sensors
-
-groupadd --gid 3012 aid_rfs_old
-useradd --gid 3012 --no-create-home --no-user-group --system --uid 3012 aid_rfs_old
-
-groupadd --gid 3013 aid_rfs_shared_old
-useradd --gid 3013 --no-create-home --no-user-group --system --uid 3013 aid_rfs_shared_old
-
-groupadd --gid 9997 aid_everybody
-useradd --gid 9997 --no-create-home --no-user-group --system --uid 9997 aid_everybody
-
-groupadd --gid 9998 aid_misc
-useradd --gid 9998 --no-create-home --no-user-group --system --uid 9998 aid_misc
-
-groupadd --gid 9999 aid_nobody
-useradd --gid 9999 --no-create-home --no-user-group --system --uid 9999 aid_nobody
diff --git a/hybris/lxc-android/logcat b/hybris/lxc-android/logcat
deleted file mode 100644
index 3e68ad9fb4eb155524caa08ca9b43db18d1a50aa..0000000000000000000000000000000000000000
--- a/hybris/lxc-android/logcat
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/bin/sh
-sudo /system/bin/logcat "$@"
diff --git a/hybris/lxc-android/lxc-android.init b/hybris/lxc-android/lxc-android.init
deleted file mode 100644
index 3f2a682ddd4b2fa6c94a7be2654cc7b840a08dd1..0000000000000000000000000000000000000000
--- a/hybris/lxc-android/lxc-android.init
+++ /dev/null
@@ -1,56 +0,0 @@
-#!/sbin/openrc-run
-# Copyright 1999-2012 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/app-emulation/lxc/files/lxc.initd.2,v 1.5 2012/07/21 05:07:15 flameeyes Exp $
-
-extra_started_commands="reboot"
-
-description="Android/Halium LXC container"
-
-CONTAINER=android
-: ${logdir:=/var/log/lxc}
-: ${systemimage:=/var/lib/lxc/android/system.img}
-
-command="/usr/bin/lxc-start"
-pidfile="/var/run/lxc/$CONTAINER.pid"
-
-depend() {
-	need localmount sysfs cgroups
-	after firewall net
-}
-
-start() {
-	checkpath -d /data
-	checkpath -d /system
-
-	ebegin "Mounting Android filesystems and starting Halium LXC container"
-	mount -o ro,loop $systemimage /system
-
-	/usr/lib/lxc-android/mount-android
-
-	rm -f "$logdir"/${CONTAINER}.log
-
-	checkpath -d -m 750 -o root:wheel $logdir
-
-	checkpath -d ${pidfile%/*}
-	start-stop-daemon --start $command \
-		--pidfile $pidfile \
-		-- \
-		--daemon \
-		--pidfile $pidfile \
-		--name ${CONTAINER} \
-		--logpriority WARN \
-		--logfile $logdir/${CONTAINER}.log \
-		|| eend $? || return $?
-	lxc-wait -n ${CONTAINER} -t 5 -s RUNNING
-	eend $?
-}
-
-stop() {
-	ebegin "Stopping container ${CONTAINER}"
-	lxc-stop -k --name ${CONTAINER}
-	start-stop-daemon --stop --pidfile ${pidfile} \
-		--retry ${POWEROFF_SIGNAL:-SIGUSR2}/${TIMEOUT:-30} \
-		--progress
-	eend $?
-}
diff --git a/hybris/lxc-android/lxc-android.post-install b/hybris/lxc-android/lxc-android.post-install
deleted file mode 100644
index f7a813b38214a3d3a15e7e2a76fb6614dc282be6..0000000000000000000000000000000000000000
--- a/hybris/lxc-android/lxc-android.post-install
+++ /dev/null
@@ -1,22 +0,0 @@
-#!/bin/sh
-# Add all Android groups with their predefined IDs
-echo "Adding android groups to system"
-/usr/sbin/add_android_groups.sh
-
-# Add user to all needed Android groups
-username=$(getent passwd 10000 | cut -d ":" -f 1)
-if [ x$username == "x" ]; then
-	echo "Warning: no user with ID 10000 found!"
-else
-	echo "Adding $username to android groups"
-	usermod -a -G aid_system,aid_graphics,aid_input,aid_audio,aid_net_bt_admin,aid_net_bt,aid_inet,aid_net_raw,aid_net_admin $username
-fi
-
-
-rc-update add cgroups default
-rc-update add lxc-android default
-
-# postmarketOS firmware loader conflicts with ueventd one
-if [ -f "/etc/udev/rules.d/50-firmware.rules" ]; then
-	rm /etc/udev/rules.d/50-firmware.rules
-fi
diff --git a/hybris/lxc-android/lxc-android.sh b/hybris/lxc-android/lxc-android.sh
deleted file mode 100644
index 1c72e90c0626ecfad72e38e3812b21a874189f9f..0000000000000000000000000000000000000000
--- a/hybris/lxc-android/lxc-android.sh
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/sh
-cd /
-exec chroot /run/android /init
-
diff --git a/hybris/lxc-android/pre-start.sh b/hybris/lxc-android/pre-start.sh
deleted file mode 100644
index f632bf3d403c3cd3633377b0c2c39021bcc00f9c..0000000000000000000000000000000000000000
--- a/hybris/lxc-android/pre-start.sh
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/bin/sh
-lxc_config_path="$(dirname $LXC_CONFIG_FILE)"
-
-# Allow pre-start.sh to be provided by device package, otherwise use the default one
-if [ -f "$lxc_config_path/pre-start.custom.sh" ]; then
-	exec $lxc_config_path/pre-start.custom.sh
-else
-	exec $lxc_config_path/pre-start.default.sh
-fi
diff --git a/hybris/pulseaudio-modules-droid/0001-configure-ac-compat.patch b/hybris/pulseaudio-modules-droid/0001-configure-ac-compat.patch
deleted file mode 100644
index 80af8e332d137a837d4275082919da7da794de7c..0000000000000000000000000000000000000000
--- a/hybris/pulseaudio-modules-droid/0001-configure-ac-compat.patch
+++ /dev/null
@@ -1,35 +0,0 @@
-diff --git a/configure.ac b/configure.ac
-index 31134c3..412bce9 100644
---- a/configure.ac
-+++ b/configure.ac
-@@ -6,7 +6,7 @@ AM_INIT_AUTOMAKE([foreign -Wall silent-rules])
- AC_CONFIG_MACRO_DIR(m4)
- AM_SILENT_RULES([yes])
- 
--AS_IF([! test -n "$VERSION"], [
-+AS_IF([! test -n "$PACKAGE_VERSION"], [
-    AC_MSG_ERROR([git-version-gen failed])
- ])
- 
-@@ -20,9 +20,9 @@ AC_PROG_CC_C99
- AM_PROG_CC_C_O
- AC_PROG_GCC_TRADITIONAL
- 
--m4_define(pa_major, `echo $VERSION | cut -d. -f1 | cut -d- -f1`)
--m4_define(pa_minor, `echo $VERSION | cut -d. -f2 | cut -d- -f1`)
--m4_define(pa_module_version, `echo $VERSION | cut -d. -f3 | cut -d- -f1`)
-+m4_define(pa_major, `echo $PACKAGE_VERSION | cut -d. -f1 | cut -d- -f1`)
-+m4_define(pa_minor, `echo $PACKAGE_VERSION | cut -d. -f2 | cut -d- -f1`)
-+m4_define(pa_module_version, `echo $PACKAGE_VERSION | cut -d. -f3 | cut -d- -f1`)
- 
- AC_SUBST(PA_MAJOR, pa_major)
- AC_SUBST(PA_MAJORMINOR, pa_major.pa_minor)
-@@ -326,7 +326,7 @@ AC_OUTPUT
- 
- echo "
- 
-- ---{ $PACKAGE_NAME $VERSION }---
-+ ---{ $PACKAGE_NAME $PACKAGE_VERSION }---
- 
-     compiler:               ${CC}
-     CFLAGS:                 ${CFLAGS}
diff --git a/hybris/pulseaudio-modules-droid/APKBUILD b/hybris/pulseaudio-modules-droid/APKBUILD
deleted file mode 100644
index 7425e3111b2625bd000a2cf4d0585cbd6a01f54a..0000000000000000000000000000000000000000
--- a/hybris/pulseaudio-modules-droid/APKBUILD
+++ /dev/null
@@ -1,97 +0,0 @@
-# Maintainer: Alexey Min <alexey.min@gmail.com>
-pkgname=pulseaudio-modules-droid
-# pkgver should match MAJOR.MINOR pulseaudio version
-pkgver=13.0
-# _pkgver used in URL to download tarball
-# Yes, we can build slightly older modules version against newer pulseaudio, if we are lucky
-_pkgver=12.2.84
-pkgrel=2
-pkgdesc="PulseAudio Droid modules by Mer project"
-url="https://github.com/mer-hybris/pulseaudio-modules-droid"
-arch="armhf aarch64"
-license="LGPL-2.1-or-later"
-depends="pulseaudio"
-makedepends="autoconf automake libtool m4 intltool dbus-dev expat-dev pulseaudio-dev pulsecore-private-headers android-headers-7.1 android-headers-7.1-caf libhybris-dev libhybris-7.1"
-options="!check"  # No test suite available
-source="
-	$pkgname-$_pkgver.tar.gz::https://github.com/mer-hybris/pulseaudio-modules-droid/archive/$_pkgver.tar.gz
-	0001-configure-ac-compat.patch
-"
-install="$pkgname.post-install"
-_headers_variants="7.1 7.1-caf"
-for _ver in $_headers_variants; do
-	subpackages="$subpackages $pkgname-$_ver:_variant"
-done
-
-builddir="$srcdir/$pkgname-$_pkgver"
-_tmppkgdir="$srcdir/tmpinstall"
-_list_of_libs="
-	libdroid-sink.so
-	libdroid-source.so
-	libdroid-util.so
-	module-droid-card.so
-	module-droid-sink.so
-	module-droid-source.so
-"
-
-prepare() {
-	default_prepare
-	echo $pkgver > .tarball-version
-	autoreconf --force --install
-}
-
-build() {
-	# Hack to build against CAF android headers:
-	#   use our own local pkg-config path folder
-	mkdir pkgconfig
-	ln -s /usr/lib/pkgconfig/android-headers-7.1.pc pkgconfig/android-headers.pc
-	export PKG_CONFIG_PATH="$builddir/pkgconfig"
-
-	./configure \
-		--build=$CBUILD \
-		--host=$CHOST \
-		--prefix=/usr \
-		--sysconfdir=/etc \
-		--mandir=/usr/share/man \
-		--localstatedir=/var \
-		--enable-shared \
-		--disable-static
-
-	# build several times against different android headers variation
-	for _ver in $_headers_variants; do
-		msg "building $pkgname-$_ver"
-
-		# Before each build make sure that include path points to correct location:
-		# instead of re-symlinking android-headers.pc file and re-running
-		# configure every time, just rewrite include paths in every Makefile
-		for _makefile in "Makefile src/Makefile src/common/Makefile src/droid/Makefile"; do
-			sed -i -E "s~/usr/include/android-[^ ]+~/usr/include/android-$_ver~g" $_makefile
-		done
-
-		make clean
-		make
-
-		# each variation is installed into a unique temporary directory
-		make DESTDIR="$_tmppkgdir/$pkgname-$_ver" install
-	done
-}
-
-package() {
-	# here we should run install for some common files
-	# for both subpackages, but we don't have anything like that
-	# pkgdir is still needed, otherwise "rootpkg failed"
-	mkdir -p "$pkgdir"
-}
-
-_variant() {
-	depends="$pkgname"
-	mkdir -p "$subpkgdir"
-	# Copy libs from temp install folder to a proper subpackage dir
-	for _lib in $_list_of_libs; do
-		install -Dm644 "$_tmppkgdir/$subpkgname/usr/lib/pulse-$pkgver/modules/$_lib" \
-			"$subpkgdir/usr/lib/pulse-$pkgver/modules/$_lib"
-	done
-}
-
-sha512sums="7a573573bbcfb3a6b3b82a6d75a79506809b00ab2f000b31cd2f81c6fa433daaa81eeb6a7965ab995e2e36ac87c02252dc1aad413447e82e3b70031dfa9d5e82  pulseaudio-modules-droid-12.2.84.tar.gz
-2aa283c64d8623c035522b89b62c80130d14c145a73e6193e2e98c26525cc12670e50f8db4649029e731b61d08c1e5ab2bd4e1a3dae8ca077bbdabe3a69eaa17  0001-configure-ac-compat.patch"
diff --git a/hybris/pulseaudio-modules-droid/pulseaudio-modules-droid.post-install b/hybris/pulseaudio-modules-droid/pulseaudio-modules-droid.post-install
deleted file mode 100644
index 43e379bcd00233954a55a6bd1b909954403098a4..0000000000000000000000000000000000000000
--- a/hybris/pulseaudio-modules-droid/pulseaudio-modules-droid.post-install
+++ /dev/null
@@ -1,17 +0,0 @@
-#!/bin/sh
-# pulseaudio default config file name
-DEFAULT_PA=/etc/pulse/default.pa
-# configuration lines
-PA_LINES="
-.ifexists /etc/pulse/arm_droid_card_custom.pa
-.include /etc/pulse/arm_droid_card_custom.pa
-.else
-load-module module-droid-card
-.endif
-"
-
-if [ -f ${DEFAULT_PA} ]; then
-	if ! grep -q "module-droid-card" $DEFAULT_PA; then
-		echo "$PA_LINES" >> $DEFAULT_PA
-	fi
-fi
diff --git a/hybris/pulsecore-private-headers/0001-core-util-add-socket-h.patch b/hybris/pulsecore-private-headers/0001-core-util-add-socket-h.patch
deleted file mode 100644
index 63368e2a6e3841a2a7a07dd88f7b6fef70703a4a..0000000000000000000000000000000000000000
--- a/hybris/pulsecore-private-headers/0001-core-util-add-socket-h.patch
+++ /dev/null
@@ -1,12 +0,0 @@
-diff --git a/src/pulsecore/core-util.h b/src/pulsecore/core-util.h
-index e28b6aa..fb0f941 100644
---- a/src/pulsecore/core-util.h
-+++ b/src/pulsecore/core-util.h
-@@ -26,6 +26,7 @@
- #include <stdarg.h>
- #include <stdio.h>
- #include <string.h>
-+#include <sys/socket.h>
- 
- #ifdef HAVE_SYS_RESOURCE_H
- #include <sys/resource.h>
diff --git a/hybris/pulsecore-private-headers/APKBUILD b/hybris/pulsecore-private-headers/APKBUILD
deleted file mode 100644
index 6b967ec029ac3775b7b79ae6eeb1718c159ac6df..0000000000000000000000000000000000000000
--- a/hybris/pulsecore-private-headers/APKBUILD
+++ /dev/null
@@ -1,34 +0,0 @@
-# Maintainer: Alexey Min <alexey.min@gmail.com>
-pkgname=pulsecore-private-headers
-pkgver=13.0
-pkgrel=0
-pkgdesc="PulseAudio internal development library (headers and pkg-config)"
-url="http://www.freedesktop.org/wiki/Software/PulseAudio"
-arch="all !x86 !x86_64"
-license="LGPL-2.1-or-later"
-depends="pulseaudio-dev libpulse pkgconfig"
-options="!check"  # No test suite available
-source="
-	https://freedesktop.org/software/pulseaudio/releases/pulseaudio-$pkgver.tar.xz
-	pulsecore.pc
-	0001-core-util-add-socket-h.patch
-"
-
-builddir="$srcdir/pulseaudio-$pkgver"
-
-build() {
-	sed -i "s/@PA_MAJORMINOR@/$pkgver/" "$srcdir"/pulsecore.pc
-}
-
-package() {
-	install -Dm644 "$srcdir"/pulsecore.pc "$pkgdir"/usr/lib/pkgconfig/pulsecore.pc
-
-	mkdir -p "$pkgdir"/usr/include/pulsecore
-	mkdir -p "$pkgdir"/usr/include/pulsecore/filter
-	cp -r "$builddir"/src/pulsecore/*.h "$pkgdir"/usr/include/pulsecore/
-	cp -r "$builddir"/src/pulsecore/filter/*.h "$pkgdir"/usr/include/pulsecore/filter/
-}
-
-sha512sums="d445b8ccd43029a0ca0e456fc9291a79d3434d6496ead7eb329ab348d5249235e8bde6cf2be68765d8f761452dbe1486fb10c739e40b1e67ed75787bbd24ac0c  pulseaudio-13.0.tar.xz
-e419ceab4779e061fb0378fc4ce0d24e2a738610b5d837866c47e9fd8044c206bb32485f7aaf0df336c2944d67b856fdee95ea6ca9e7c12954d15ae521adad66  pulsecore.pc
-4e24295e5e03d3f89f5197657e7946c56e9d776c1b64306d2798075df322700ca1f89a19f1fa9ab7f379b1b33196eb316dc17a20efdc5b0e41ff47c41b567e34  0001-core-util-add-socket-h.patch"
diff --git a/hybris/pulsecore-private-headers/pulsecore.pc b/hybris/pulsecore-private-headers/pulsecore.pc
deleted file mode 100644
index c7aeafbfe8d98298c2f979a078a983167d1ff53a..0000000000000000000000000000000000000000
--- a/hybris/pulsecore-private-headers/pulsecore.pc
+++ /dev/null
@@ -1,10 +0,0 @@
-prefix=/usr
-libdir=/usr/lib
-includedir=${prefix}/include
-ver=@PA_MAJORMINOR@
-
-Name: pulsecore
-Description: Module building interface for pulseaudio
-Version: @PA_MAJORMINOR@
-Libs: -L${libdir} -L${libdir}/pulseaudio -L${libdir}/pulse-${ver}/modules -lpulsecore-${ver} -lpulsecommon-${ver} -lpulse
-Cflags: -D_REENTRANT -D__INCLUDED_FROM_PULSE_AUDIO -DPA_DEFAULT_CONFIG_DIR=\"/etc/pulse\" -I${includedir}
diff --git a/hybris/xf86-video-hwcomposer/30-modules-hybris.conf b/hybris/xf86-video-hwcomposer/30-modules-hybris.conf
deleted file mode 100644
index ab84e6cd205eb7b827f6f0d1283ad0edb16a6960..0000000000000000000000000000000000000000
--- a/hybris/xf86-video-hwcomposer/30-modules-hybris.conf
+++ /dev/null
@@ -1,4 +0,0 @@
-Section "Module"
-    Load "drihybris"
-    Load "glamoreglhybris"
-EndSection
diff --git a/hybris/xf86-video-hwcomposer/APKBUILD b/hybris/xf86-video-hwcomposer/APKBUILD
deleted file mode 100644
index 8c29b0f79ef41c1fed4fa09b86004d844a90486a..0000000000000000000000000000000000000000
--- a/hybris/xf86-video-hwcomposer/APKBUILD
+++ /dev/null
@@ -1,79 +0,0 @@
-# Maintainer: TheKit <nekit1000@gmail.com>
-pkgname=xf86-video-hwcomposer
-pkgver=1.0_git20190925
-pkgrel=2
-pkgdesc="X.Org driver for Android devices rendering through HWComposer API"
-url="https://github.com/NotKit/xf86-video-hwcomposer"
-arch="armhf aarch64"
-license="MIT"
-depends="drihybris glamor-hybris libepoxy libhybris"
-makedepends="autoconf automake util-macros libtool
-	xorg-server-dev libxi-dev fontsproto randrproto
-	videoproto renderproto xf86dgaproto glamor-hybris-dev drihybris-dev
-	android-headers-4.4 android-headers-7.1 android-headers-7.1-caf
-	android-headers-9.0
-	libhybris-dev libhybris libhybris-9.0"
-_commit="b33e119005158ddc1988b495121591496bddb915"
-source="$pkgname-$_commit.tar.gz::https://github.com/NotKit/xf86-video-hwcomposer/archive/$_commit.tar.gz
-	fix-hwcomposer.patch
-	30-modules-hybris.conf"
-
-options="!tracedeps"
-subpackages="$pkgname-doc"
-
-if [ "$CARCH" == "armhf" -o "$CARCH" == "armv7" ]; then
-	_vers="9.0 7.1 7.1-caf 4.4"
-elif [ "$CARCH" == "aarch64" ]; then
-	_vers="9.0 7.1 7.1-caf"
-fi
-
-for _ver in $_vers; do
-	subpackages="$subpackages $pkgname-$_ver:_specific"
-done
-
-builddir="$srcdir/$pkgname-$_commit"
-_tmppkgdir="$srcdir/tmpinstall"
-
-build() {
-	export LDFLAGS="$LDFLAGS -Wl,-z,lazy"
-	export CPPFLAGS="$CPPFLAGS -I/usr/include/android-9.0 -DMESA_EGL_NO_X11_HEADERS"
-
-	NOCONFIGURE=1 ./autogen.sh
-
-	./configure \
-		--build=$CBUILD \
-		--host=$CHOST \
-		--prefix=/usr \
-		--enable-drihybris \
-		--enable-glamor-hybris
-
-	for _ver in $_vers; do
-		msg "building $pkgname-$_ver"
-
-		for _makefile in "Makefile src/Makefile"; do
-			sed -i -E "s~/usr/include/android-[^ ]+~/usr/include/android-$_ver~g" $_makefile
-		done
-
-		make clean
-		make
-		make DESTDIR="$_tmppkgdir/$pkgname-$_ver" install
-	done
-}
-
-package() {
-	install -Dm644 COPYING "$pkgdir"/usr/share/licenses/$pkgname/COPYING
-	install -Dm644 "$srcdir"/30-modules-hybris.conf \
-		"$pkgdir"/etc/X11/xorg.conf.d/30-modules-hybris.conf
-}
-
-_specific() {
-	_hybrisver="$(echo $subpkgname | cut -d '-' -f4)"
-	depends="$depends libhybris-$_hybrisver"
-	_lib="xorg/modules/drivers/hwcomposer_drv.so"
-	install -Dm644 "$_tmppkgdir/$subpkgname/usr/lib/$_lib" \
-			"$subpkgdir/usr/lib/$_lib"
-}
-
-sha512sums="61c7f528c0f8848edc72b4f926095a610abf9b7ea1512cce518d6dae359e76a6eb50fc18558238fc3dc6a31ce3cc3237e4663198a05744400282db2825ee6ddb  xf86-video-hwcomposer-b33e119005158ddc1988b495121591496bddb915.tar.gz
-b76bceba0e784e079b4093f6e4405763f17c4d817ca977e9f8f8878294d37a3876efbbb0dc6ef7f4ce466ccd77bce7e72362c0e3b5ac6dfdb0144ccaac503876  fix-hwcomposer.patch
-e8f9f6ec337e88ec440c4bdc3f3441a8252031d1a4265a251b500a087a2c88336861c7e3f81972019f6a492324e94253726ce031fedad60ff582dd8db73efac6  30-modules-hybris.conf"
diff --git a/hybris/xf86-video-hwcomposer/fix-hwcomposer.patch b/hybris/xf86-video-hwcomposer/fix-hwcomposer.patch
deleted file mode 100644
index 9439b36798ddcd4500722f2e16843d65245010c2..0000000000000000000000000000000000000000
--- a/hybris/xf86-video-hwcomposer/fix-hwcomposer.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-diff --git a/src/hwcomposer.c b/src/hwcomposer.c
-index bb6d204..52e06df 100644
---- a/src/hwcomposer.c
-+++ b/src/hwcomposer.c
-@@ -123,7 +123,7 @@ Bool hwc_hwcomposer_init(ScrnInfoPtr pScrn)
- 		return hwc_hwcomposer2_init(pScrn);
- #endif
- 	
--	hwc_composer_device_1_t *hwcDevicePtr = (hwc_composer_device_1_t*) hwcDevice;
-+	hwc_composer_device_1_t *hwcDevicePtr = hwc->hwcDevicePtr = (hwc_composer_device_1_t*) hwcDevice;
- 	hwc_set_power_mode(pScrn, HWC_DISPLAY_PRIMARY, 1);
- 
- 	uint32_t configs[5];