aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad Smith <brad@comstyle.com>2024-06-22 22:49:14 -0400
committerBrad Smith <brad@comstyle.com>2024-06-26 02:06:53 -0400
commit41190da9e11f536cb590df45ce9839974e5e6777 (patch)
treed20ee206463bdf26ead10deb0e9df1a9a2362c01
parent23531c97768f79d55d369e3dd1e4b52acd72f6ec (diff)
downloadffmpeg-41190da9e11f536cb590df45ce9839974e5e6777.tar.gz
aarch64: Add OpenBSD runtime detection of dotprod and i8mm using sysctl
Signed-off-by: Brad Smith <brad@comstyle.com>
-rw-r--r--libavutil/aarch64/cpu.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/libavutil/aarch64/cpu.c b/libavutil/aarch64/cpu.c
index 196bdaf6b0..cfa9306663 100644
--- a/libavutil/aarch64/cpu.c
+++ b/libavutil/aarch64/cpu.c
@@ -65,6 +65,44 @@ static int detect_flags(void)
return flags;
}
+#elif defined(__OpenBSD__)
+#include <machine/armreg.h>
+#include <machine/cpu.h>
+#include <sys/types.h>
+#include <sys/sysctl.h>
+
+static int detect_flags(void)
+{
+ int flags = 0;
+
+#ifdef CPU_ID_AA64ISAR0
+ int mib[2];
+ uint64_t isar0;
+ uint64_t isar1;
+ size_t len;
+
+ mib[0] = CTL_MACHDEP;
+ mib[1] = CPU_ID_AA64ISAR0;
+ len = sizeof(isar0);
+ if (sysctl(mib, 2, &isar0, &len, NULL, 0) != -1) {
+ if (ID_AA64ISAR0_DP(isar0) >= ID_AA64ISAR0_DP_IMPL)
+ flags |= AV_CPU_FLAG_DOTPROD;
+ }
+
+ mib[0] = CTL_MACHDEP;
+ mib[1] = CPU_ID_AA64ISAR1;
+ len = sizeof(isar1);
+ if (sysctl(mib, 2, &isar1, &len, NULL, 0) != -1) {
+#ifdef ID_AA64ISAR1_I8MM_IMPL
+ if (ID_AA64ISAR1_I8MM(isar1) >= ID_AA64ISAR1_I8MM_IMPL)
+ flags |= AV_CPU_FLAG_I8MM;
+#endif
+ }
+#endif
+
+ return flags;
+}
+
#elif defined(_WIN32)
#include <windows.h>