diff --git a/packages/linux-drivers/gpu-aml/modules-load.d/mali.conf b/packages/linux-drivers/gpu-aml/modules-load.d/mali.conf
deleted file mode 100644
index 29c66fc8c8..0000000000
--- a/packages/linux-drivers/gpu-aml/modules-load.d/mali.conf
+++ /dev/null
@@ -1 +0,0 @@
-mali
diff --git a/packages/linux-drivers/gpu-aml/package.mk b/packages/linux-drivers/gpu-aml/package.mk
index 6bcfbe9b0e..e90f22a120 100644
--- a/packages/linux-drivers/gpu-aml/package.mk
+++ b/packages/linux-drivers/gpu-aml/package.mk
@@ -20,11 +20,10 @@ PKG_NAME="gpu-aml"
PKG_ARCH="arm aarch64"
PKG_LICENSE="GPL"
PKG_SITE="http://openlinux.amlogic.com:8000/download/ARM/gpu/"
-# r5p1
-PKG_VERSION="9b0fbbc"
-PKG_SHA256="7ca380052b285598f1c0100cec3411f69674dcfc0f78bc2dbe407aaf85b8ebd7"
-PKG_URL="https://github.com/openwetek/gpu-aml/archive/$PKG_VERSION.tar.gz"
-PKG_SOURCE_DIR="gpu-aml-$PKG_VERSION*"
+PKG_VERSION="fe7a4d8"
+PKG_SHA256="518f855a2b191e50d09c2d0b3e671b5ed4b5e4db06aa3a718e29ef30cc0d9a57"
+PKG_URL="https://github.com/khadas/android_hardware_arm_gpu/archive/$PKG_VERSION.tar.gz"
+PKG_SOURCE_DIR="android_hardware_arm_gpu-$PKG_VERSION*"
PKG_DEPENDS_TARGET="toolchain linux"
PKG_NEED_UNPACK="$LINUX_DEPENDS"
PKG_SECTION="driver"
@@ -33,13 +32,40 @@ PKG_LONGDESC="gpu-aml: Linux drivers for Mali GPUs found in Amlogic Meson SoCs"
PKG_TOOLCHAIN="manual"
PKG_IS_KERNEL_PKG="yes"
+PKG_UTGARD_VERSION="r5p1"
+PKG_UTGARD_BUILD_DIR="$PKG_BUILD/utgard/$PKG_UTGARD_VERSION"
+PKG_MIDGARD_VERSION="r16p0"
+PKG_MIDGARD_BUILD_DIR="$PKG_BUILD/midgard/$PKG_MIDGARD_VERSION/kernel/drivers/gpu/arm/midgard"
+
+pre_configure_target() {
+ sed -e "s|shell date|shell date -R|g" -i $PKG_BUILD/utgard/*/Kbuild
+ sed -e "s|USING_GPU_UTILIZATION=1|USING_GPU_UTILIZATION=0|g" -i $PKG_BUILD/utgard/platform/Kbuild.amlogic
+}
+
+pre_make_target() {
+ ln -s $PKG_BUILD/utgard/platform $PKG_UTGARD_BUILD_DIR/platform
+}
+
make_target() {
- LDFLAGS="" make -C $(kernel_path) M=$PKG_BUILD/mali \
- CONFIG_MALI400=m CONFIG_MALI450=m
+ if [ "$MESON_FAMILY" = "gxm" ] ; then
+ LDFLAGS="" make -C $(kernel_path) M=$PKG_MIDGARD_BUILD_DIR \
+ EXTRA_CFLAGS="-DCONFIG_MALI_PLATFORM_DEVICETREE -DCONFIG_MALI_BACKEND=gpu" \
+ CONFIG_MALI_MIDGARD=m CONFIG_MALI_PLATFORM_DEVICETREE=y CONFIG_MALI_BACKEND=gpu modules
+ else
+ LDFLAGS="" make -C $(kernel_path) M=$PKG_UTGARD_BUILD_DIR \
+ EXTRA_CFLAGS="-DCONFIG_MALI450=y" \
+ CONFIG_MALI400=m CONFIG_MALI450=y
+ fi
}
makeinstall_target() {
- LDFLAGS="" make -C $(kernel_path) M=$PKG_BUILD/mali \
- INSTALL_MOD_PATH=$INSTALL/$(get_kernel_overlay_dir) INSTALL_MOD_STRIP=1 DEPMOD=: \
- modules_install
+ if [ "$MESON_FAMILY" = "gxm" ] ; then
+ LDFLAGS="" make -C $(kernel_path) M=$PKG_MIDGARD_BUILD_DIR \
+ INSTALL_MOD_PATH=$INSTALL/$(get_kernel_overlay_dir) INSTALL_MOD_STRIP=1 DEPMOD=: \
+ modules_install
+ else
+ LDFLAGS="" make -C $(kernel_path) M=$PKG_UTGARD_BUILD_DIR \
+ INSTALL_MOD_PATH=$INSTALL/$(get_kernel_overlay_dir) INSTALL_MOD_STRIP=1 DEPMOD=: \
+ modules_install
+ fi
}
diff --git a/packages/linux-drivers/gpu-aml/patches/gpu-aml-0001-dont-use-mali-utilization.patch b/packages/linux-drivers/gpu-aml/patches/gpu-aml-0001-dont-use-mali-utilization.patch
deleted file mode 100644
index 2ae609f358..0000000000
--- a/packages/linux-drivers/gpu-aml/patches/gpu-aml-0001-dont-use-mali-utilization.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-diff --git a/mali/Kbuild.orig b/mali/Kbuild
-index 7cc2225..4813c2f 100755
---- a/mali/Kbuild.orig
-+++ b/mali/Kbuild
-@@ -56,7 +56,7 @@ ifeq ($(CONFIG_MALI_DVFS),y)
- USING_GPU_UTILIZATION=0
- USING_DVFS=1
- else
-- USING_GPU_UTILIZATION=1
-+ USING_GPU_UTILIZATION=0
- USING_DVFS=0
- endif
- PROFILING_SKIP_PP_JOBS ?= 0
diff --git a/packages/linux-drivers/gpu-aml/patches/gpu-aml-0002-use-rfc-date-in-version-string.patch b/packages/linux-drivers/gpu-aml/patches/gpu-aml-0002-use-rfc-date-in-version-string.patch
deleted file mode 100644
index b21447b980..0000000000
--- a/packages/linux-drivers/gpu-aml/patches/gpu-aml-0002-use-rfc-date-in-version-string.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-diff --git a/mali/Kbuild b/mali/Kbuild
-index 7cc2225..6ce6270 100755
---- a/mali/Kbuild
-+++ b/mali/Kbuild
-@@ -312,7 +312,7 @@ VERSION_STRINGS += REPO_URL=$(REPO_URL)
- VERSION_STRINGS += REVISION=$(DRIVER_REV)
- VERSION_STRINGS += CHANGED_REVISION=$(CHANGED_REVISION)
- VERSION_STRINGS += CHANGE_DATE=$(CHANGE_DATE)
--VERSION_STRINGS += BUILD_DATE=$(shell date)
-+VERSION_STRINGS += BUILD_DATE=$(shell date -R)
- ifdef CONFIG_MALI400_DEBUG
- VERSION_STRINGS += BUILD=debug
- else
diff --git a/projects/Amlogic/devices/LePotato/options b/projects/Amlogic/devices/LePotato/options
index 02bb537187..e7e44771f4 100644
--- a/projects/Amlogic/devices/LePotato/options
+++ b/projects/Amlogic/devices/LePotato/options
@@ -9,15 +9,3 @@
# Kernel extra targets to build
KERNEL_UBOOT_EXTRA_TARGET="gxl_p212_1g_lepotato.dtb gxl_p212_2g_lepotato.dtb"
-
- # additional drivers to install:
- # for a list of additinoal drivers see packages/linux-drivers
- # Space separated list is supported,
- # e.g. ADDITIONAL_DRIVERS="DRIVER1 DRIVER2"
- ADDITIONAL_DRIVERS="gpu-aml"
-
- # additional Firmware to use (dvb-firmware, misc-firmware, wlan-firmware)
- # Space separated list is supported,
- # e.g. FIRMWARE="dvb-firmware misc-firmware wlan-firmware"
- FIRMWARE=""
-
diff --git a/projects/Amlogic/devices/S905/options b/projects/Amlogic/devices/S905/options
index c02f29c756..e5712d5be7 100644
--- a/projects/Amlogic/devices/S905/options
+++ b/projects/Amlogic/devices/S905/options
@@ -2,9 +2,4 @@
# for a list of additinoal drivers see packages/linux-drivers
# Space separated list is supported,
# e.g. ADDITIONAL_DRIVERS="DRIVER1 DRIVER2"
- ADDITIONAL_DRIVERS="$ADDITIONAL_DRIVERS gpu-aml fd628-aml"
-
- # additional packages to install:
- # Space separated list is supported,
- # e.g. ADDITIONAL_PACKAGES="PACKAGE1 PACKAGE2"
- ADDITIONAL_PACKAGES="u-boot-tools-aml"
+ ADDITIONAL_DRIVERS="$ADDITIONAL_DRIVERS fd628-aml"
diff --git a/projects/Amlogic/devices/S912/filesystem/usr/lib/systemd/system/cpufreq.service b/projects/Amlogic/devices/S912/filesystem/usr/lib/systemd/system/cpufreq.service
new file mode 100644
index 0000000000..afbc794ecb
--- /dev/null
+++ b/projects/Amlogic/devices/S912/filesystem/usr/lib/systemd/system/cpufreq.service
@@ -0,0 +1,9 @@
+[Unit]
+Description=Set minimum frequency to 1GHz for both CPU clusters
+
+[Service]
+Type=simple
+ExecStart=-/usr/bin/sh -c 'echo 1000000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq; echo 1000000 > /sys/devices/system/cpu/cpu4/cpufreq/scaling_min_freq'
+
+[Install]
+WantedBy=basic.target
diff --git a/projects/Amlogic/devices/S912/options b/projects/Amlogic/devices/S912/options
new file mode 100644
index 0000000000..2c77cc8ff7
--- /dev/null
+++ b/projects/Amlogic/devices/S912/options
@@ -0,0 +1,8 @@
+ # Kernel extra targets to build
+ KERNEL_UBOOT_EXTRA_TARGET="gxm_q200_2g.dtb gxm_q201_1g.dtb gxm_q201_2g.dtb"
+
+ # OpenGL-ES implementation to use (no / bcm2835-driver / gpu-viv-bin-mx6q / opengl-meson)
+ OPENGLES="opengl-meson-t82x"
+
+ # Amlogic Meson SOC family (8 / 6 / gxbb)
+ MESON_FAMILY="gxm"
diff --git a/projects/Amlogic/devices/S912/packages/android-headers/package.mk b/projects/Amlogic/devices/S912/packages/android-headers/package.mk
new file mode 100644
index 0000000000..d34b9a9244
--- /dev/null
+++ b/projects/Amlogic/devices/S912/packages/android-headers/package.mk
@@ -0,0 +1,29 @@
+################################################################################
+# This file is part of LibreELEC - https://libreelec.tv
+# Copyright (C) 2017-present Team LibreELEC
+#
+# LibreELEC is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
+#
+# LibreELEC 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with LibreELEC. If not, see .
+################################################################################
+
+PKG_NAME="android-headers"
+PKG_VERSION="25"
+PKG_SHA256="1e0ecdf56c33aaa523109254e2c475878d8cfc5795ebd4bb5ecbaf80926f4fe9"
+PKG_ARCH="any"
+PKG_LICENSE="Apache"
+PKG_SITE="https://android.googlesource.com/"
+PKG_URL="$DISTRO_SRC/$PKG_NAME-$PKG_VERSION.tar.gz"
+PKG_DEPENDS_TARGET="toolchain"
+PKG_SECTION="devel"
+PKG_SHORTDESC="android-headers: Android Platform Headers from AOSP releases"
+PKG_TOOLCHAIN="manual"
diff --git a/projects/Amlogic/devices/S912/packages/libhybris/package.mk b/projects/Amlogic/devices/S912/packages/libhybris/package.mk
new file mode 100644
index 0000000000..7244425c17
--- /dev/null
+++ b/projects/Amlogic/devices/S912/packages/libhybris/package.mk
@@ -0,0 +1,36 @@
+################################################################################
+# This file is part of LibreELEC - https://libreelec.tv
+# Copyright (C) 2017-present Team LibreELEC
+#
+# LibreELEC is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
+#
+# LibreELEC 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with LibreELEC. If not, see .
+################################################################################
+
+PKG_NAME="libhybris"
+PKG_VERSION="070c3ab"
+PKG_SHA256="070dcf48aa424c1c56c1d95f5116051a22a76bd5ac0c877febf04b63d9559ea2"
+PKG_ARCH="any"
+PKG_LICENSE="GPL"
+PKG_SITE="https://github.com/libhybris/libhybris"
+PKG_URL="https://github.com/libhybris/libhybris/archive/$PKG_VERSION.tar.gz"
+PKG_SOURCE_DIR="$PKG_NAME-$PKG_VERSION*/hybris"
+PKG_DEPENDS_TARGET="toolchain android-headers"
+PKG_SECTION="devel"
+PKG_SHORTDESC="libhybris: Allows to run bionic-based HW adaptations in glibc systems - libs"
+PKG_TOOLCHAIN="autotools"
+
+PKG_CONFIGURE_OPTS_TARGET="--enable-arch=$TARGET_ARCH \
+ --with-default-egl-platform=fbdev \
+ --with-android-headers=$BUILD/android-headers-25 \
+ --with-default-hybris-ld-library-path=/system/lib \
+ --enable-mali-quirks"
diff --git a/projects/Amlogic/devices/S912/packages/libhybris/patches/libhybris-Build-only-EGL-GLESv1-and-GLESv2.patch b/projects/Amlogic/devices/S912/packages/libhybris/patches/libhybris-Build-only-EGL-GLESv1-and-GLESv2.patch
new file mode 100644
index 0000000000..35178890f5
--- /dev/null
+++ b/projects/Amlogic/devices/S912/packages/libhybris/patches/libhybris-Build-only-EGL-GLESv1-and-GLESv2.patch
@@ -0,0 +1,19 @@
+diff --git a/Makefile.am b/Makefile.am
+index 906140e..75888ae 100644
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -6,13 +6,7 @@ endif
+ if HAS_ANDROID_5_0_0
+ SUBDIRS += libsync
+ endif
+-SUBDIRS += egl glesv1 glesv2 ui sf input camera vibrator media wifi
+-
+-if HAS_LIBNFC_NXP_HEADERS
+-SUBDIRS += libnfc_nxp libnfc_ndef_nxp
+-endif
+-SUBDIRS += utils tests
+-
++SUBDIRS += egl glesv1 glesv2
+
+ MAINTAINERCLEANFILES = \
+ aclocal.m4 compile config.guess config.sub \
diff --git a/projects/Amlogic/devices/S912/packages/libhybris/patches/libhybris-eglplatform_fbdev-open-new-framebuffer-when-creating.patch b/projects/Amlogic/devices/S912/packages/libhybris/patches/libhybris-eglplatform_fbdev-open-new-framebuffer-when-creating.patch
new file mode 100644
index 0000000000..db135a7c1b
--- /dev/null
+++ b/projects/Amlogic/devices/S912/packages/libhybris/patches/libhybris-eglplatform_fbdev-open-new-framebuffer-when-creating.patch
@@ -0,0 +1,51 @@
+From bd11dbc285303c0fe4039b5058360f38c5614cae Mon Sep 17 00:00:00 2001
+From: kszaq
+Date: Tue, 16 Jan 2018 23:41:52 +0100
+Subject: [PATCH] eglplatform_fbdev: open new framebuffer when creating a
+ window
+
+Framebuffer device has to be reopened when creating a new window
+to adapt its size to display. This is required e.g. after screen
+resolution changed.
+---
+ hybris/egl/platforms/fbdev/eglplatform_fbdev.cpp | 17 ++++++++++-------
+ 1 file changed, 10 insertions(+), 7 deletions(-)
+
+diff --git a/egl/platforms/fbdev/eglplatform_fbdev.cpp b/egl/platforms/fbdev/eglplatform_fbdev.cpp
+index c25a2d7..c75073f 100644
+--- a/egl/platforms/fbdev/eglplatform_fbdev.cpp
++++ b/egl/platforms/fbdev/eglplatform_fbdev.cpp
+@@ -29,13 +29,6 @@ extern "C" void fbdevws_init_module(struct ws_egl_interface *egl_iface)
+ assert(0);
+ }
+
+- err = framebuffer_open((hw_module_t *) gralloc, &framebuffer);
+- if (err) {
+- fprintf(stderr, "ERROR: failed to open framebuffer: (%s)\n",strerror(-err));
+- assert(0);
+- }
+- TRACE("** framebuffer_open: status=(%s) format=x%x", strerror(-err), framebuffer->format);
+-
+ err = gralloc_open((const hw_module_t *) gralloc, &alloc);
+ if (err) {
+ fprintf(stderr, "ERROR: failed to open gralloc: (%s)\n",strerror(-err));
+@@ -66,6 +59,16 @@ extern "C" EGLNativeWindowType fbdevws_CreateWindow(EGLNativeWindowType win, _EG
+ assert (gralloc != NULL);
+ assert (_nativewindow == NULL);
+
++ if (framebuffer)
++ framebuffer_close(framebuffer);
++
++ int err = framebuffer_open((hw_module_t *) gralloc, &framebuffer);
++ if (err) {
++ fprintf(stderr, "ERROR: failed to open framebuffer: (%s)\n",strerror(-err));
++ assert(0);
++ }
++ TRACE("** framebuffer_open: status=(%s) format=x%x", strerror(-err), framebuffer->format);
++
+ _nativewindow = new FbDevNativeWindow(alloc, framebuffer);
+ _nativewindow->common.incRef(&_nativewindow->common);
+ return (EGLNativeWindowType) static_cast(_nativewindow);
+--
+2.7.4
+
diff --git a/projects/Amlogic/devices/S912/packages/opengl-meson-t82x/package.mk b/projects/Amlogic/devices/S912/packages/opengl-meson-t82x/package.mk
new file mode 100644
index 0000000000..45150c729c
--- /dev/null
+++ b/projects/Amlogic/devices/S912/packages/opengl-meson-t82x/package.mk
@@ -0,0 +1,40 @@
+################################################################################
+# This file is part of LibreELEC - https://libreelec.tv
+# Copyright (C) 2017-present Team LibreELEC
+#
+# LibreELEC is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
+#
+# LibreELEC 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with LibreELEC. If not, see .
+################################################################################
+
+PKG_NAME="opengl-meson-t82x"
+PKG_VERSION="915cb48"
+PKG_SHA256="9b5f65afa21250b67578c250da030a5829e69131ce91b2f167b01b1ed30be781"
+PKG_ARCH="arm"
+PKG_LICENSE="nonfree"
+PKG_SITE="https://github.com/kszaq/opengl-meson-t82x"
+PKG_URL="https://github.com/kszaq/opengl-meson-t82x/archive/$PKG_VERSION.tar.gz"
+PKG_DEPENDS_TARGET="toolchain libhybris"
+PKG_SOURCE_DIR="$PKG_NAME-$PKG_VERSION*"
+PKG_SECTION="graphics"
+PKG_SHORTDESC="opengl-meson: OpenGL ES pre-compiled libraries for Mali GPUs found in Amlogic Meson SoCs"
+PKG_LONGDESC="opengl-meson: OpenGL ES pre-compiled libraries for Mali GPUs found in Amlogic Meson SoCs. The libraries were extracted from Khadas VIM2 Android firmware."
+PKG_TOOLCHAIN="manual"
+
+makeinstall_target() {
+ mkdir -p $INSTALL/system
+ cp -a system/* $INSTALL/system
+}
+
+post_install() {
+ enable_service unbind-console.service
+}
diff --git a/projects/Amlogic/devices/S912/packages/opengl-meson-t82x/system.d/unbind-console.service b/projects/Amlogic/devices/S912/packages/opengl-meson-t82x/system.d/unbind-console.service
new file mode 100644
index 0000000000..a79c37ad11
--- /dev/null
+++ b/projects/Amlogic/devices/S912/packages/opengl-meson-t82x/system.d/unbind-console.service
@@ -0,0 +1,11 @@
+[Unit]
+Description=Unbind framebuffer console
+
+ConditionPathExists=/sys/class/vtconsole/vtcon1/bind
+
+[Service]
+Type=oneshot
+ExecStart=/bin/sh -c 'echo 0 > /sys/class/vtconsole/vtcon1/bind'
+
+[Install]
+WantedBy=graphical.target
diff --git a/projects/Amlogic/options b/projects/Amlogic/options
index da9277d7af..c4e62de82b 100644
--- a/projects/Amlogic/options
+++ b/projects/Amlogic/options
@@ -112,7 +112,7 @@
# for a list of additinoal drivers see packages/linux-drivers
# Space separated list is supported,
# e.g. ADDITIONAL_DRIVERS="DRIVER1 DRIVER2"
- ADDITIONAL_DRIVERS="RTL8192CU RTL8192DU RTL8192EU RTL8812AU \
+ ADDITIONAL_DRIVERS="gpu-aml RTL8192CU RTL8192DU RTL8192EU RTL8812AU \
ap6xxx-aml mt7601u-aml mt7603u-aml qca9377-aml \
RTL8188EU-aml RTL8189ES-aml RTL8189FS-aml RTL8723BS-aml \
RTL8723DS-aml RTL8822BU-aml ssv6xxx-aml"
@@ -142,3 +142,8 @@
# for a list of additinoal drivers see packages/linux-driver-addons
# Space separated list is supported,
DRIVER_ADDONS=""
+
+ # additional packages to install:
+ # Space separated list is supported,
+ # e.g. ADDITIONAL_PACKAGES="PACKAGE1 PACKAGE2"
+ ADDITIONAL_PACKAGES="u-boot-tools-aml"