Remove Android depenencies from openmax_dl ARM NEON detection (detect.c)

This commit is contained in:
Kevin Kofler 2016-12-03 22:55:17 +01:00
parent 392efd00b7
commit db8ac7858a
2 changed files with 103 additions and 0 deletions

View File

@ -87,6 +87,8 @@ Patch7: qtwebengine-opensource-src-5.7.0-webrtc-neon.patch
Patch8: qtwebengine-opensource-src-5.6.0-beta-system-icu54.patch
# fix missing ARM -mfpu setting (see the comment in the no-neon patch above)
Patch9: qtwebengine-opensource-src-5.7.1-arm-fpu-fix.patch
# remove Android depenencies from openmax_dl ARM NEON detection (detect.c)
Patch10: qtwebengine-opensource-src-5.7.1-openmax-dl-neon.patch
# handled by qt5-srpm-macros, which defines %%qt5_qtwebengine_arches
ExclusiveArch: %{qt5_qtwebengine_arches}
@ -315,6 +317,7 @@ BuildArch: noarch
%patch6 -p1 -b .no-sse2
%patch7 -p1 -b .webrtc-neon
%patch8 -p1 -b .system-icu54
%patch10 -p1 -b .openmax-dl-neon
# fix // in #include in content/renderer/gpu to avoid debugedit failure
sed -i -e 's!gpu//!gpu/!g' \
src/3rdparty/chromium/content/renderer/gpu/compositor_forwarding_message_filter.cc
@ -461,8 +464,10 @@ popd
%changelog
* Sat Dec 03 2016 Kevin Kofler <Kevin@tigcc.ticalc.org> - 5.7.1-2
- clean_qtwebengine.sh: Rip out openh264 sources
- Rebase no-neon patch, add new arm-fpu-fix patch where no-neon not wanted
- Try enabling arm_neon unconditionally, #1282495 should be fixed even in F23
- Remove Android depenencies from openmax_dl ARM NEON detection (detect.c)
* Thu Nov 10 2016 Helio Chissini de Castro <helio@kde.org> - 5.7.1-1
- New upstream version

View File

@ -0,0 +1,98 @@
diff -ur qtwebengine-opensource-src-5.7.1/src/3rdparty/chromium/third_party/openmax_dl/dl/dl.gyp qtwebengine-opensource-src-5.7.1-openmax-dl-neon/src/3rdparty/chromium/third_party/openmax_dl/dl/dl.gyp
--- qtwebengine-opensource-src-5.7.1/src/3rdparty/chromium/third_party/openmax_dl/dl/dl.gyp 2016-11-07 15:46:18.000000000 +0100
+++ qtwebengine-opensource-src-5.7.1-openmax-dl-neon/src/3rdparty/chromium/third_party/openmax_dl/dl/dl.gyp 2016-12-03 22:50:19.369158276 +0100
@@ -219,15 +219,6 @@
'conditions': [
['arm_neon_optional==1', {
# Run-time NEON detection.
- 'dependencies': [
- '../../../build/android/ndk.gyp:cpu_features',
- ],
- 'link_settings' : {
- 'libraries': [
- # To get the __android_log_print routine
- '-llog',
- ],
- },
'sources': [
# Detection routine
'sp/src/arm/detect.c',
diff -ur qtwebengine-opensource-src-5.7.1/src/3rdparty/chromium/third_party/openmax_dl/dl/sp/src/arm/detect.c qtwebengine-opensource-src-5.7.1-openmax-dl-neon/src/3rdparty/chromium/third_party/openmax_dl/dl/sp/src/arm/detect.c
--- qtwebengine-opensource-src-5.7.1/src/3rdparty/chromium/third_party/openmax_dl/dl/sp/src/arm/detect.c 2016-11-07 15:46:18.000000000 +0100
+++ qtwebengine-opensource-src-5.7.1-openmax-dl-neon/src/3rdparty/chromium/third_party/openmax_dl/dl/sp/src/arm/detect.c 2016-12-03 22:48:13.745095083 +0100
@@ -9,13 +9,57 @@
*
*/
-#include <cpu-features.h>
-
-#include "android/log.h"
#include "dl/sp/api/omxSP.h"
+// For ArmCpuCaps()
+#include <stdio.h>
+#include <string.h>
+
+// based on libvpx arm_cpudetect.c
+static int ArmCpuCaps(const char* cpuinfo_name) {
+ char cpuinfo_line[512];
+ FILE* f = fopen(cpuinfo_name, "r");
+ if (!f) {
+ // Assume Neon if /proc/cpuinfo is unavailable.
+ // This will occur for Chrome sandbox for Pepper or Render process.
+ return 1;
+ }
+ while (fgets(cpuinfo_line, sizeof(cpuinfo_line) - 1, f)) {
+ if (memcmp(cpuinfo_line, "Features", 8) == 0) {
+ char* p = strstr(cpuinfo_line, " neon");
+ if (p && (p[5] == ' ' || p[5] == '\n')) {
+ fclose(f);
+ return 1;
+ }
+ // aarch64 uses asimd for Neon.
+ p = strstr(cpuinfo_line, " asimd");
+ if (p && (p[6] == ' ' || p[6] == '\n')) {
+ fclose(f);
+ return 1;
+ }
+ }
+ }
+ fclose(f);
+ return 0;
+}
+
int omxSP_HasArmNeon() {
- return (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0;
+#if defined(__arm__) || defined(__aarch64__)
+// gcc -mfpu=neon defines __ARM_NEON__
+// __ARM_NEON__ generates code that requires Neon. NaCL also requires Neon.
+// For Linux, /proc/cpuinfo can be tested but without that assume Neon.
+#if defined(__ARM_NEON__) || defined(__native_client__) || !defined(__linux__)
+ return 1;
+// For aarch64(arm64), /proc/cpuinfo's feature is not complete, e.g. no neon
+// flag in it.
+// So for aarch64, neon enabling is hard coded here.
+#elif defined(__aarch64__)
+ return 1;
+#else
+ // Linux arm parse text file for neon detect.
+ return ArmCpuCaps("/proc/cpuinfo");
+#endif
+#endif // __arm__
}
static void SetFFTRoutines() {
@@ -24,13 +68,9 @@
* forward and inverse FFTs
*/
if (omxSP_HasArmNeon()) {
- __android_log_print(ANDROID_LOG_INFO, "OpenMAX DL FFT",
- "Using NEON FFT");
omxSP_FFTFwd_RToCCS_F32 = omxSP_FFTFwd_RToCCS_F32_Sfs;
omxSP_FFTInv_CCSToR_F32 = omxSP_FFTInv_CCSToR_F32_Sfs;
} else {
- __android_log_print(ANDROID_LOG_INFO, "OpenMAX DL FFT",
- "Using non-NEON FFT");
omxSP_FFTFwd_RToCCS_F32 = omxSP_FFTFwd_RToCCS_F32_Sfs_vfp;
omxSP_FFTInv_CCSToR_F32 = omxSP_FFTInv_CCSToR_F32_Sfs_vfp;
}