Path: blob/main/multimedia/aom/files/patch-aom__ports_ppc__cpudetect.c
18157 views
- Implement VSX detection on FreeBSD12--- aom_ports/ppc_cpudetect.c.orig 2025-09-02 20:59:58 UTC3+++ aom_ports/ppc_cpudetect.c4@@ -9,18 +9,11 @@5* PATENTS file, you can obtain it at www.aomedia.org/license/patent.6*/78-#include <fcntl.h>9-#include <unistd.h>10-#include <stdint.h>11-12#include "config/aom_config.h"1314#include "aom_ports/ppc.h"1516#if CONFIG_RUNTIME_CPU_DETECT17-#include <asm/cputable.h>18-#include <linux/auxvec.h>19-20static int cpu_env_flags(int *flags) {21char *env;22env = getenv("AOM_SIMD_CAPS");23@@ -38,6 +31,13 @@ static int cpu_env_mask(void) {24return env && *env ? (int)strtol(env, NULL, 0) : ~0;25}2627+#if defined(__linux__)28+#include <fcntl.h>29+#include <unistd.h>30+#include <stdint.h>31+#include <asm/cputable.h>32+#include <linux/auxvec.h>33+34int ppc_simd_caps(void) {35int flags;36int mask;37@@ -76,7 +76,35 @@ out_close:38close(fd);39return flags & mask;40}41+#elif defined(__FreeBSD__)42+#include <sys/auxv.h>43+#include <machine/cpu.h>44+45+int ppc_simd_caps(void) {46+ int flags;47+ int mask;48+ u_long hwcap = 0;49+50+ // If AOM_SIMD_CAPS is set then allow only those capabilities.51+ if (!cpu_env_flags(&flags)) {52+ return flags;53+ }54+55+ mask = cpu_env_mask();56+57+ elf_aux_info(AT_HWCAP, &hwcap, sizeof(hwcap));58+#if HAVE_VSX59+ if (hwcap & PPC_FEATURE_HAS_VSX) flags |= HAS_VSX;60+#endif61+62+ return flags & mask;63+}64#else65+#error \66+ "--enable-runtime-cpu-detect selected, but no CPU detection method " \67+"available for your platform. Reconfigure with --disable-runtime-cpu-detect."68+#endif /* end __FreeBSD__ */69+#else70// If there is no RTCD the function pointers are not used and can not be71// changed.72int ppc_simd_caps(void) { return 0; }737475