vp8,get_sub_mv_ref_prob: change arguments to uint32_t
[platform/upstream/libvpx.git] / vpx_ports / mips_cpudetect.c
1 /*
2  *  Copyright (c) 2020 The WebM project authors. All Rights Reserved.
3  *
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.
9  */
10 #include <stdio.h>
11 #include <string.h>
12 #include "./vpx_config.h"
13 #include "vpx_ports/mips.h"
14
15 #if CONFIG_RUNTIME_CPU_DETECT
16 #if defined(__mips__) && defined(__linux__)
17 int mips_cpu_caps(void) {
18   char cpuinfo_line[512];
19   int flag = 0x0;
20   FILE *f = fopen("/proc/cpuinfo", "r");
21   if (!f) {
22     // Assume nothing if /proc/cpuinfo is unavailable.
23     // This will occur for Chrome sandbox for Pepper or Render process.
24     return 0;
25   }
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")) {
30         flag |= HAS_MMI;
31       } else if (strstr(cpuinfo_line, "Loongson-2K")) {
32         flag |= HAS_MMI | HAS_MSA;
33       }
34     }
35     if (memcmp(cpuinfo_line, "ASEs implemented", 16) == 0) {
36       if (strstr(cpuinfo_line, "loongson-mmi") &&
37           strstr(cpuinfo_line, "loongson-ext")) {
38         flag |= HAS_MMI;
39       }
40       if (strstr(cpuinfo_line, "msa")) {
41         flag |= HAS_MSA;
42       }
43       // ASEs is the last line, so we can break here.
44       break;
45     }
46   }
47   fclose(f);
48   return flag;
49 }
50 #else /* end __mips__ && __linux__ */
51 #error \
52     "--enable-runtime-cpu-detect selected, but no CPU detection method " \
53 "available for your platform. Reconfigure with --disable-runtime-cpu-detect."
54 #endif
55 #else /* end CONFIG_RUNTIME_CPU_DETECT */
56 int mips_cpu_caps(void) { return 0; }
57 #endif