3
* Copyright (C) 2000-2002 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
32
static inline uint32_t arch_accel (void)
34
uint32_t eax, ebx, ecx, edx;
39
#define cpuid(op,eax,ebx,ecx,edx) \
47
#else /* PIC version : save ebx */
48
#define cpuid(op,eax,ebx,ecx,edx) \
49
__asm__ ("pushl %%ebx\n\t" \
65
"xorl $0x200000,%0\n\t"
76
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 = MM_ACCEL_X86_MMX;
90
if (edx & 0x02000000) /* SSE - identical to AMD MMX extensions */
91
caps = MM_ACCEL_X86_MMX | MM_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 |= MM_ACCEL_X86_3DNOW;
102
if (AMD && (edx & 0x00400000)) /* AMD MMX extensions */
103
caps |= MM_ACCEL_X86_MMXEXT;
107
#endif /* ARCH_X86 */
113
static sigjmp_buf jmpbuf;
114
static volatile sig_atomic_t canjump = 0;
116
static RETSIGTYPE sigill_handler (int sig)
119
signal (sig, SIG_DFL);
124
siglongjmp (jmpbuf, 1);
127
static inline uint32_t arch_accel (void)
129
signal (SIGILL, sigill_handler);
130
if (sigsetjmp (jmpbuf, 1)) {
131
signal (SIGILL, SIG_DFL);
137
asm volatile ("mtspr 256, %0\n\t"
138
"vand %%v0, %%v0, %%v0"
142
signal (SIGILL, SIG_DFL);
143
return MM_ACCEL_PPC_ALTIVEC;
145
#endif /* ARCH_PPC */
147
uint32_t mm_accel (void)
149
#if defined (ARCH_X86) || defined (ARCH_PPC)
150
static int got_accel = 0;
151
static uint32_t accel;
155
accel = arch_accel ();