2 * Copyright (c) 2020 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.
12 #include "./vpx_config.h"
13 #include "vpx_ports/mips.h"
15 #if CONFIG_RUNTIME_CPU_DETECT
16 #if defined(__mips__) && defined(__linux__)
17 int mips_cpu_caps(void) {
18 char cpuinfo_line[512];
20 FILE *f = fopen("/proc/cpuinfo", "r");
22 // Assume nothing if /proc/cpuinfo is unavailable.
23 // This will occur for Chrome sandbox for Pepper or Render process.
26 while (fgets(cpuinfo_line, sizeof(cpuinfo_line) - 1, f)) {
27 if (memcmp(cpuinfo_line, "cpu model", 9) == 0) {
28 // Workaround early kernel without mmi in ASEs line.
29 if (strstr(cpuinfo_line, "Loongson-3")) {
31 } else if (strstr(cpuinfo_line, "Loongson-2K")) {
32 flag |= HAS_MMI | HAS_MSA;
35 if (memcmp(cpuinfo_line, "ASEs implemented", 16) == 0) {
36 if (strstr(cpuinfo_line, "loongson-mmi") &&
37 strstr(cpuinfo_line, "loongson-ext")) {
40 if (strstr(cpuinfo_line, "msa")) {
43 // ASEs is the last line, so we can break here.
50 #else /* end __mips__ && __linux__ */
52 "--enable-runtime-cpu-detect selected, but no CPU detection method " \
53 "available for your platform. Reconfigure with --disable-runtime-cpu-detect."
55 #else /* end CONFIG_RUNTIME_CPU_DETECT */
56 int mips_cpu_caps(void) { return 0; }