3 * Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org>
4 * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
6 * This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
7 * See http://libmpeg2.sourceforge.net/ for updates.
9 * mpeg2dec is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * mpeg2dec is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 #include "attributes.h"
28 #include "mpeg2_internal.h"
30 static inline uint32_t arch_accel( void )
32 uint32_t eax, ebx, ecx, edx;
36 #if defined(__x86_64__) || (!defined(PIC) && !defined(__PIC__))
37 #define cpuid(op,eax,ebx,ecx,edx) \
45 #else /* PIC version : save ebx (not needed on x86_64) */
46 #define cpuid(op,eax,ebx,ecx,edx) \
47 __asm__ ("push %%ebx\n\t" \
59 #ifndef __x86_64__ /* x86_64 supports the cpuid op */
64 "xorl $0x200000,%0\n\t"
75 if (eax == ebx) /* no cpuid */
79 cpuid (0x00000000, eax, ebx, ecx, edx);
80 if (!eax) /* vendor string only */
83 AMD = (ebx == 0x68747541) && (ecx == 0x444d4163) && (edx == 0x69746e65);
85 cpuid (0x00000001, eax, ebx, ecx, edx);
86 if (! (edx & 0x00800000)) /* no MMX */
89 caps = MPEG2_ACCEL_X86_MMX;
90 if (edx & 0x02000000) /* SSE - identical to AMD MMX extensions */
91 caps = MPEG2_ACCEL_X86_MMX | MPEG2_ACCEL_X86_MMXEXT;
93 cpuid (0x80000000, eax, ebx, ecx, edx);
94 if (eax < 0x80000001) /* no extended capabilities */
97 cpuid (0x80000001, eax, ebx, ecx, edx);
100 caps |= MPEG2_ACCEL_X86_3DNOW;
102 if (AMD && (edx & 0x00400000)) /* AMD MMX extensions */
103 caps |= MPEG2_ACCEL_X86_MMXEXT;
108 uint32_t mpeg2_detect_accel (void)
113 accel = arch_accel ();