summaryrefslogtreecommitdiffstats
path: root/meta-xilinx-bsp
diff options
context:
space:
mode:
authorAlejandro Enedino Hernandez Samaniego <alejandr@xilinx.com>2019-02-12 17:10:26 -0800
committerSai Hari Chandana Kalluri <chandana.kalluri@xilinx.com>2019-11-19 16:01:14 -0800
commitf78918f0077a8d013b1b40bcb3e8f798438f8a3e (patch)
treee8d9bd184d7140da691ae93266f4a6cdd5215c75 /meta-xilinx-bsp
parentf795bf5e7a715ad7d9c827361bba1f5e95d36a81 (diff)
downloadmeta-xilinx-f78918f0077a8d013b1b40bcb3e8f798438f8a3e.tar.gz
libmali-xlnx: Use update-alternatives to switch between GL backends
libmali provides GL backends based on x11, fbdev and wayland, we should be able to switch between them at runtime since it is the same ABI, it should only be a matter of loading the correct shared library by the interpreter (dynamic linker). Use the update-alternatives class, to provide a way for the user to choose the desired backend at runtime, do this by setting priorities, the package with the highest priority will be chosen as default at build time, but it can easily be changed at runtime afterwards. This change implies that the libmali package will install all backends regardless of which one was chosen, but it will only use one as default. Use the x11 backend by default at build time; given that it is the same ABI, applications which depend on libmali, can build regardless of the chosen backend at build time. Update-alternatives uses a set of commands on the postinst scripts when creating the root filesystem, which basically create the soft link between the chosen alternative and the binary/library. This usually works seamlessly (for binaries), but it does not in the case of libraries, because ldconfig is run at the end of the do_rootfs task, and it removes the link that was just created, it is important to note that this is simply normal ldconfig behavior and its not something we can fix, so we defer execution of update-alternatives until the first boot, hence avoiding the link removal by ldconfig. Switching backends at build time will also help to avoid longer build times, since it will only invalidate the do_package task, rebuilding an image after switching a backend (at build time) should only execute the do_package task along with the do_rootfs task. Signed-off-by: Alejandro Enedino Hernandez Samaniego <alejandr@xilinx.com> Signed-off-by: Manjukumar Matha <manjukumar.harthikote-matha@xilinx.com>
Diffstat (limited to 'meta-xilinx-bsp')
-rw-r--r--meta-xilinx-bsp/recipes-graphics/libgles/libmali-xlnx.bb101
1 files changed, 67 insertions, 34 deletions
diff --git a/meta-xilinx-bsp/recipes-graphics/libgles/libmali-xlnx.bb b/meta-xilinx-bsp/recipes-graphics/libgles/libmali-xlnx.bb
index ca8f522e..d3c7646a 100644
--- a/meta-xilinx-bsp/recipes-graphics/libgles/libmali-xlnx.bb
+++ b/meta-xilinx-bsp/recipes-graphics/libgles/libmali-xlnx.bb
@@ -3,9 +3,9 @@ DESCRIPTION = "libGLES for ZynqMP with Mali 400"
3LICENSE = "Proprietary" 3LICENSE = "Proprietary"
4LIC_FILES_CHKSUM = "file://EULA;md5=82e466d0ed92c5a15f568dbe6b31089c" 4LIC_FILES_CHKSUM = "file://EULA;md5=82e466d0ed92c5a15f568dbe6b31089c"
5 5
6inherit distro_features_check 6inherit distro_features_check update-alternatives
7 7
8ANY_OF_DISTRO_FEATURES = "fbdev x11" 8REQUIRED_DISTRO_FEATURES = "x11 fbdev wayland"
9 9
10PROVIDES += "virtual/libgles1 virtual/libgles2 virtual/egl virtual/libgbm" 10PROVIDES += "virtual/libgles1 virtual/libgles2 virtual/egl virtual/libgbm"
11 11
@@ -39,22 +39,14 @@ PACKAGE_ARCH = "${SOC_FAMILY}"
39 39
40S = "${WORKDIR}/git" 40S = "${WORKDIR}/git"
41 41
42X11RDEPENDS = "libxdamage libxext libx11 libdrm libxfixes" 42# If were switching at runtime, we need all RDEPENDS needed for all backends available
43X11DEPENDS = "libxdamage libxext virtual/libx11 libdrm libxfixes" 43RDEPENDS_${PN} = " kernel-module-mali libxdamage libxext libx11 libdrm libxfixes"
44 44
45RDEPENDS_${PN} = " \ 45# We dont build anything but we want to avoid QA warning build-deps
46 kernel-module-mali \ 46DEPENDS = "wayland"
47 ${@bb.utils.contains('DISTRO_FEATURES', 'x11', '${X11RDEPENDS}', '', d)} \
48 "
49 47
50DEPENDS = "\ 48# x11 is default, set to "fbdev" , "wayland", or "headless" if required
51 ${@bb.utils.contains('DISTRO_FEATURES', 'x11', '${X11DEPENDS}', '', d)} \ 49MALI_BACKEND_DEFAULT ?= "x11"
52 ${@bb.utils.contains('DISTRO_FEATURES', 'wayland', 'wayland libdrm', '', d)} \
53 "
54
55USE_X11 = "${@bb.utils.contains("DISTRO_FEATURES", "x11", "yes", "no", d)}"
56USE_FB = "${@bb.utils.contains("DISTRO_FEATURES", "fbdev", "yes", "no", d)}"
57USE_WL = "${@bb.utils.contains("DISTRO_FEATURES", "wayland", "yes", "no", d)}"
58 50
59do_install() { 51do_install() {
60 #Identify the ARCH type 52 #Identify the ARCH type
@@ -86,25 +78,66 @@ do_install() {
86 78
87 cp -a --no-preserve=ownership ${S}/${PV}/${ARCH_PLATFORM_DIR}/common/*.so* ${D}${libdir} 79 cp -a --no-preserve=ownership ${S}/${PV}/${ARCH_PLATFORM_DIR}/common/*.so* ${D}${libdir}
88 80
89 if [ "${USE_WL}" = "yes" ]; then
90 install -m 0644 ${S}/${PV}/glesHeaders/GBM/gbm.h ${D}${includedir}/
91 install -m 0644 ${WORKDIR}/gbm.pc ${D}${libdir}/pkgconfig/gbm.pc
92 install -Dm 0644 ${S}/${PV}/${ARCH_PLATFORM_DIR}/wayland/libMali.so.8.0 ${D}${libdir}/wayland/libMali.so.8.0
93 ln -snf wayland/libMali.so.8.0 ${D}${libdir}/libMali.so.8.0
94 elif [ "${USE_X11}" = "yes" ]; then
95 install -Dm 0644 ${S}/${PV}/${ARCH_PLATFORM_DIR}/x11/libMali.so.8.0 ${D}${libdir}/x11/libMali.so.8.0
96 ln -snf x11/libMali.so.8.0 ${D}${libdir}/libMali.so.8.0
97 elif [ "${USE_FB}" = "yes" ]; then
98 install -Dm 0644 ${S}/${PV}/${ARCH_PLATFORM_DIR}/fbdev/libMali.so.8.0 ${D}${libdir}/fbdev/libMali.so.8.0
99 ln -snf fbdev/libMali.so.8.0 ${D}${libdir}/libMali.so.8.0
100 else
101 install -Dm 0644 ${S}/${PV}/${ARCH_PLATFORM_DIR}/headless/libMali.so.8.0 ${D}${libdir}/headless/libMali.so.8.0
102 ln -snf headless/libMali.so.8.0 ${D}${libdir}/libMali.so.8.0
103 fi
104 81
105 if ${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'false', 'true', d)}; then 82 install -m 0644 ${S}/${PV}/glesHeaders/GBM/gbm.h ${D}${includedir}/
106 sed -i -e 's/^#if defined(MESA_EGL_NO_X11_HEADERS)$/#if (1)/' ${D}${includedir}/EGL/eglplatform.h 83 install -m 0644 ${WORKDIR}/gbm.pc ${D}${libdir}/pkgconfig/gbm.pc
107 fi 84 install -Dm 0644 ${S}/${PV}/${ARCH_PLATFORM_DIR}/wayland/libMali.so.8.0 ${D}${libdir}/wayland/libMali.so.8.0
85 install -Dm 0644 ${S}/${PV}/${ARCH_PLATFORM_DIR}/x11/libMali.so.8.0 ${D}${libdir}/x11/libMali.so.8.0
86 install -Dm 0644 ${S}/${PV}/${ARCH_PLATFORM_DIR}/fbdev/libMali.so.8.0 ${D}${libdir}/fbdev/libMali.so.8.0
87 install -Dm 0644 ${S}/${PV}/${ARCH_PLATFORM_DIR}/headless/libMali.so.8.0 ${D}${libdir}/headless/libMali.so.8.0
88
89 # We need to have one of the libraries available at build time for the linker
90 ln -snf x11/libMali.so.8.0 ${D}${libdir}/libMali.so.8.0
91}
92
93
94# We need separate packages to provide multiple alternatives, at this point we install
95# everything on the default one but that can be split if necessary
96PACKAGES += "${PN}-x11 ${PN}-fbdev ${PN}-wayland ${PN}-headless"
97
98# This is default/common for all alternatives
99ALTERNATIVE_LINK_NAME[libmali-xlnx] = "${libdir}/libMali.so.8.0"
100
101
102# Declare alternatives and corresponding library location
103ALTERNATIVE_${PN}-x11 = "libmali-xlnx"
104ALTERNATIVE_TARGET_libmali-xlnx-x11[libmali-xlnx] = "${libdir}/x11/libMali.so.8.0"
105
106ALTERNATIVE_${PN}-fbdev = "libmali-xlnx"
107ALTERNATIVE_TARGET_libmali-xlnx-fbdev[libmali-xlnx] = "${libdir}/fbdev/libMali.so.8.0"
108
109ALTERNATIVE_${PN}-wayland = "libmali-xlnx"
110ALTERNATIVE_TARGET_libmali-xlnx-wayland[libmali-xlnx] = "${libdir}/wayland/libMali.so.8.0"
111
112ALTERNATIVE_${PN}-headless = "libmali-xlnx"
113ALTERNATIVE_TARGET_libmali-xlnx-headless[libmali-xlnx] = "${libdir}/headless/libMali.so.8.0"
114
115# Set priorities according to what we prveiously defined
116ALTERNATIVE_PRIORITY_libmali-xlnx-x11[libmali-xlnx] = "${@bb.utils.contains("MALI_BACKEND_DEFAULT", "x11", "20", "10", d)}"
117ALTERNATIVE_PRIORITY_libmali-xlnx-fbdev[libmali-xlnx] = "${@bb.utils.contains("MALI_BACKEND_DEFAULT", "fbdev", "20", "10", d)}"
118ALTERNATIVE_PRIORITY_libmali-xlnx-wayland[libmali-xlnx] = "${@bb.utils.contains("MALI_BACKEND_DEFAULT", "wayland", "20", "10", d)}"
119ALTERNATIVE_PRIORITY_libmali-xlnx-headless[libmali-xlnx] = "${@bb.utils.contains("MALI_BACKEND_DEFAULT", "headless", "20", "10", d)}"
120
121
122# Package gets renamed on the debian class, but we want to keep -xlnx
123DEBIAN_NOAUTONAME_libmali-xlnx = "1"
124
125# Update alternatives will actually have separate postinst scripts (one for each package)
126# This wont work for us, so we create a common postinst script and we pass that as the general
127# libmali-xlnx postinst script, but we defer execution to run on first boot (pkg_postinst_ontarget).
128# This will avoid ldconfig removing the symbolic links when creating the root filesystem.
129python populate_packages_updatealternatives_append () {
130 # We need to remove the 'fake' libmali-xlnx before creating any links
131 libdir = d.getVar('libdir')
132 common_postinst = "#!/bin/sh\nrm " + libdir + "/libMali.so.8.0\n"
133 for pkg in (d.getVar('PACKAGES') or "").split():
134 # Not all packages provide an alternative (e.g. ${PN}-lic)
135 postinst = d.getVar('pkg_postinst_%s' % pkg)
136 if postinst:
137 old_postinst = postinst
138 new_postinst = postinst.replace('#!/bin/sh','')
139 common_postinst += new_postinst
140 d.setVar('pkg_postinst_ontarget_%s' % 'libmali-xlnx', common_postinst)
108} 141}
109 142
110 143