2 This file is part of PulseAudio.
4 Copyright 2004-2006 Lennart Poettering
5 Copyright 2009 Wim Taymans <wim.taymans@collabora.co.uk>
7 PulseAudio is free software; you can redistribute it and/or modify
8 it under the terms of the GNU Lesser General Public License as published
9 by the Free Software Foundation; either version 2.1 of the License,
10 or (at your option) any later version.
12 PulseAudio is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 General Public License for more details.
17 You should have received a copy of the GNU Lesser General Public License
18 along with PulseAudio; if not, see <http://www.gnu.org/licenses/>.
31 #include <pulsecore/log.h>
35 void pa_cpu_get_x86_flags(pa_cpu_x86_flag_t *flags) {
36 #if (defined(__i386__) || defined(__amd64__)) && defined(HAVE_CPUID_H)
37 uint32_t eax, ebx, ecx, edx;
42 /* get standard level */
43 if (__get_cpuid(0x00000000, &level, &ebx, &ecx, &edx) == 0)
47 if (__get_cpuid(0x00000001, &eax, &ebx, &ecx, &edx) == 0)
51 *flags |= PA_CPU_X86_CMOV;
54 *flags |= PA_CPU_X86_MMX;
57 *flags |= PA_CPU_X86_SSE;
60 *flags |= PA_CPU_X86_SSE2;
63 *flags |= PA_CPU_X86_SSE3;
66 *flags |= PA_CPU_X86_SSSE3;
69 *flags |= PA_CPU_X86_SSE4_1;
72 *flags |= PA_CPU_X86_SSE4_2;
75 /* get extended level */
76 if (__get_cpuid(0x80000000, &level, &ebx, &ecx, &edx) == 0)
79 if (level >= 0x80000001) {
80 if (__get_cpuid(0x80000001, &eax, &ebx, &ecx, &edx) == 0)
84 *flags |= PA_CPU_X86_MMXEXT;
87 *flags |= PA_CPU_X86_MMX;
90 *flags |= PA_CPU_X86_3DNOWEXT;
93 *flags |= PA_CPU_X86_3DNOW;
97 pa_log_info("CPU flags: %s%s%s%s%s%s%s%s%s%s%s",
98 (*flags & PA_CPU_X86_CMOV) ? "CMOV " : "",
99 (*flags & PA_CPU_X86_MMX) ? "MMX " : "",
100 (*flags & PA_CPU_X86_SSE) ? "SSE " : "",
101 (*flags & PA_CPU_X86_SSE2) ? "SSE2 " : "",
102 (*flags & PA_CPU_X86_SSE3) ? "SSE3 " : "",
103 (*flags & PA_CPU_X86_SSSE3) ? "SSSE3 " : "",
104 (*flags & PA_CPU_X86_SSE4_1) ? "SSE4_1 " : "",
105 (*flags & PA_CPU_X86_SSE4_2) ? "SSE4_2 " : "",
106 (*flags & PA_CPU_X86_MMXEXT) ? "MMXEXT " : "",
107 (*flags & PA_CPU_X86_3DNOW) ? "3DNOW " : "",
108 (*flags & PA_CPU_X86_3DNOWEXT) ? "3DNOWEXT " : "");
109 #endif /* (defined(__i386__) || defined(__amd64__)) && defined(HAVE_CPUID_H) */
112 bool pa_cpu_init_x86(pa_cpu_x86_flag_t *flags) {
113 #if defined (__i386__) || defined (__amd64__)
114 pa_cpu_get_x86_flags(flags);
116 /* activate various optimisations */
118 if (*flags & PA_CPU_X86_MMX) {
119 pa_volume_func_init_mmx(*flags);
120 pa_remap_func_init_mmx(*flags);
125 if (*flags & (PA_CPU_X86_SSE | PA_CPU_X86_SSE2)) {
126 pa_volume_func_init_sse(*flags);
127 pa_remap_func_init_sse(*flags);
128 pa_convert_func_init_sse(*flags);
133 #else /* defined (__i386__) || defined (__amd64__) */
135 #endif /* defined (__i386__) || defined (__amd64__) */