2 * Copyright (c) 2017 The WebM project authors. All Rights Reserved.
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
14 #include <asm/cputable.h>
15 #include <linux/auxvec.h>
17 #include "./vpx_config.h"
18 #include "vpx_ports/ppc.h"
20 #if CONFIG_RUNTIME_CPU_DETECT
21 static int cpu_env_flags(int *flags) {
23 env = getenv("VPX_SIMD_CAPS");
25 *flags = (int)strtol(env, NULL, 0);
32 static int cpu_env_mask(void) {
34 env = getenv("VPX_SIMD_CAPS_MASK");
35 return env && *env ? (int)strtol(env, NULL, 0) : ~0;
38 int ppc_simd_caps(void) {
46 // If VPX_SIMD_CAPS is set then allow only those capabilities.
47 if (!cpu_env_flags(&flags)) {
51 mask = cpu_env_mask();
53 fd = open("/proc/self/auxv", O_RDONLY);
58 while ((count = read(fd, buf, sizeof(buf))) > 0) {
59 for (i = 0; i < (count / sizeof(*buf)); i += 2) {
60 if (buf[i] == AT_HWCAP) {
62 if (buf[i + 1] & PPC_FEATURE_HAS_VSX) {
67 } else if (buf[i] == AT_NULL) {
77 // If there is no RTCD the function pointers are not used and can not be
79 int ppc_simd_caps(void) { return 0; }
80 #endif // CONFIG_RUNTIME_CPU_DETECT