From: Peter Meerwald Date: Thu, 5 Jul 2012 12:32:59 +0000 (+0200) Subject: core: Distinguish Cortex processors: A8 vs later (A9, A15) X-Git-Url: https://code.delx.au/pulseaudio/commitdiff_plain/40450bdbf21b415b54b6fc1d86fcb8b6f372bef8 core: Distinguish Cortex processors: A8 vs later (A9, A15) Signed-off-by: Peter Meerwald --- diff --git a/src/pulsecore/cpu-arm.c b/src/pulsecore/cpu-arm.c index cce3b917..32f0e536 100644 --- a/src/pulsecore/cpu-arm.c +++ b/src/pulsecore/cpu-arm.c @@ -80,10 +80,9 @@ static char *get_cpuinfo(void) { #endif /* defined (__arm__) && defined (__linux__) */ void pa_cpu_get_arm_flags(pa_cpu_arm_flag_t *flags) { -#if defined (__arm__) -#if defined (__linux__) +#if defined (__arm__) && defined (__linux__) char *cpuinfo, *line; - int arch; + int arch, part; /* We need to read the CPU flags from /proc/cpuinfo because there is no user * space support to get the CPU features. This only works on linux AFAIK. */ @@ -104,6 +103,7 @@ void pa_cpu_get_arm_flags(pa_cpu_arm_flag_t *flags) { pa_xfree(line); } + /* get the CPU features */ if ((line = get_cpuinfo_line(cpuinfo, "Features"))) { const char *state = NULL; @@ -122,16 +122,24 @@ void pa_cpu_get_arm_flags(pa_cpu_arm_flag_t *flags) { pa_xfree(current); } } + + /* get the CPU part number */ + if ((line = get_cpuinfo_line(cpuinfo, "CPU part"))) { + part = strtoul(line, NULL, 0); + if (part == 0xc08) + *flags |= PA_CPU_ARM_CORTEX_A8; + pa_xfree(line); + } pa_xfree(cpuinfo); - pa_log_info("CPU flags: %s%s%s%s%s%s", + pa_log_info("CPU flags: %s%s%s%s%s%s%s", (*flags & PA_CPU_ARM_V6) ? "V6 " : "", (*flags & PA_CPU_ARM_V7) ? "V7 " : "", (*flags & PA_CPU_ARM_VFP) ? "VFP " : "", (*flags & PA_CPU_ARM_EDSP) ? "EDSP " : "", (*flags & PA_CPU_ARM_NEON) ? "NEON " : "", - (*flags & PA_CPU_ARM_VFPV3) ? "VFPV3 " : ""); -#endif + (*flags & PA_CPU_ARM_VFPV3) ? "VFPV3 " : "", + (*flags & PA_CPU_ARM_CORTEX_A8) ? "Cortex-A8 " : ""); #endif } diff --git a/src/pulsecore/cpu-arm.h b/src/pulsecore/cpu-arm.h index 5bc7d3b1..51f73951 100644 --- a/src/pulsecore/cpu-arm.h +++ b/src/pulsecore/cpu-arm.h @@ -36,7 +36,8 @@ typedef enum pa_cpu_arm_flag { PA_CPU_ARM_VFP = (1 << 2), PA_CPU_ARM_EDSP = (1 << 3), PA_CPU_ARM_NEON = (1 << 4), - PA_CPU_ARM_VFPV3 = (1 << 5) + PA_CPU_ARM_VFPV3 = (1 << 5), + PA_CPU_ARM_CORTEX_A8 = (1 << 6), } pa_cpu_arm_flag_t; void pa_cpu_get_arm_flags(pa_cpu_arm_flag_t *flags);