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(PIC) && !defined(__PIC__)
37 #define cpuid(op,eax,ebx,ecx,edx) \
45 #else /* PIC version : save ebx */
46 #define cpuid(op,eax,ebx,ecx,edx) \
47 __asm__ ("push %%ebx\n\t" \
63 "xorl $0x200000,%0\n\t"
74 if (eax == ebx) /* no cpuid */
77 cpuid (0x00000000, eax, ebx, ecx, edx);
78 if (!eax) /* vendor string only */
81 AMD = (ebx == 0x68747541) && (ecx == 0x444d4163) && (edx == 0x69746e65);
83 cpuid (0x00000001, eax, ebx, ecx, edx);
84 if (! (edx & 0x00800000)) /* no MMX */
87 caps = MPEG2_ACCEL_X86_MMX;
88 if (edx & 0x02000000) /* SSE - identical to AMD MMX extensions */
89 caps = MPEG2_ACCEL_X86_MMX | MPEG2_ACCEL_X86_MMXEXT;
91 cpuid (0x80000000, eax, ebx, ecx, edx);
92 if (eax < 0x80000001) /* no extended capabilities */
95 cpuid (0x80000001, eax, ebx, ecx, edx);
98 caps |= MPEG2_ACCEL_X86_3DNOW;
100 if (AMD && (edx & 0x00400000)) /* AMD MMX extensions */
101 caps |= MPEG2_ACCEL_X86_MMXEXT;
106 uint32_t mpeg2_detect_accel (void)
111 accel = arch_accel ();