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, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
29 #include <pulsecore/log.h>
33 #if defined (__i386__) || defined (__amd64__)
35 get_cpuid (uint32_t op, uint32_t *a, uint32_t *b, uint32_t *c, uint32_t *d)
37 __asm__ __volatile__ (
38 " push %%"PA_REG_b" \n\t"
40 " mov %%ebx, %%esi \n\t"
41 " pop %%"PA_REG_b" \n\t"
43 : "=a" (*a), "=S" (*b), "=c" (*c), "=d" (*d)
49 void pa_cpu_init_x86 (void) {
50 #if defined (__i386__) || defined (__amd64__)
51 uint32_t eax, ebx, ecx, edx;
53 pa_cpu_x86_flag_t flags = 0;
55 /* get standard level */
56 get_cpuid (0x00000000, &level, &ebx, &ecx, &edx);
58 get_cpuid (0x00000001, &eax, &ebx, &ecx, &edx);
61 flags |= PA_CPU_X86_MMX;
64 flags |= PA_CPU_X86_SSE;
67 flags |= PA_CPU_X86_SSE2;
70 flags |= PA_CPU_X86_SSE3;
73 flags |= PA_CPU_X86_SSSE3;
76 flags |= PA_CPU_X86_SSE4_1;
79 flags |= PA_CPU_X86_SSE4_2;
82 /* get extended level */
83 get_cpuid (0x80000000, &level, &ebx, &ecx, &edx);
84 if (level >= 0x80000001) {
85 get_cpuid (0x80000001, &eax, &ebx, &ecx, &edx);
88 flags |= PA_CPU_X86_MMXEXT;
91 flags |= PA_CPU_X86_MMX;
94 flags |= PA_CPU_X86_3DNOWEXT;
97 flags |= PA_CPU_X86_3DNOW;
100 pa_log_info ("CPU flags: %s%s%s%s%s%s%s%s%s%s",
101 (flags & PA_CPU_X86_MMX) ? "MMX " : "",
102 (flags & PA_CPU_X86_SSE) ? "SSE " : "",
103 (flags & PA_CPU_X86_SSE2) ? "SSE2 " : "",
104 (flags & PA_CPU_X86_SSE3) ? "SSE3 " : "",
105 (flags & PA_CPU_X86_SSSE3) ? "SSSE3 " : "",
106 (flags & PA_CPU_X86_SSE4_1) ? "SSE4_1 " : "",
107 (flags & PA_CPU_X86_SSE4_2) ? "SSE4_2 " : "",
108 (flags & PA_CPU_X86_MMXEXT) ? "MMXEXT " : "",
109 (flags & PA_CPU_X86_3DNOW) ? "3DNOW " : "",
110 (flags & PA_CPU_X86_3DNOWEXT) ? "3DNOWEXT " : "");
112 /* activate various optimisations */
113 if (flags & PA_CPU_X86_MMX) {
114 pa_volume_func_init_mmx (flags);
115 pa_remap_func_init_mmx (flags);
118 if (flags & PA_CPU_X86_SSE) {
119 pa_volume_func_init_sse (flags);
120 pa_remap_func_init_sse (flags);
121 pa_convert_func_init_sse (flags);
124 #endif /* defined (__i386__) || defined (__amd64__) */