1 /* Cpu detection code, extracted from mmx.h ((c)1997-99 by H. Dietz
2 and R. Fisher). Converted to C and improved by Fabrice Bellard */
5 #include "../dsputil.h"
15 /* ebx saving is necessary for PIC. gcc seems unable to see it alone */
16 #define cpuid(index,eax,ebx,ecx,edx)\
18 ("mov %%"REG_b", %%"REG_S"\n\t"\
20 "xchg %%"REG_b", %%"REG_S\
21 : "=a" (eax), "=S" (ebx),\
22 "=c" (ecx), "=d" (edx)\
25 /* Function to test if multimedia instructions are supported... */
29 int eax
, ebx
, ecx
, edx
;
30 int max_std_level
, max_ext_level
, std_caps
=0, ext_caps
=0;
33 __asm__
__volatile__ (
34 /* See if CPUID instruction is supported ... */
35 /* ... Get copies of EFLAGS into eax and ecx */
40 /* ... Toggle the ID bit in one copy and store */
41 /* to the EFLAGS reg */
42 "xor $0x200000, %0\n\t"
46 /* ... Get the (hopefully modified) EFLAGS */
55 return 0; /* CPUID not supported */
57 cpuid(0, max_std_level
, ebx
, ecx
, edx
);
59 if(max_std_level
>= 1){
60 cpuid(1, eax
, ebx
, ecx
, std_caps
);
61 if (std_caps
& (1<<23))
63 if (std_caps
& (1<<25))
64 rval
|= MM_MMXEXT
| MM_SSE
;
65 if (std_caps
& (1<<26))
69 cpuid(0x80000000, max_ext_level
, ebx
, ecx
, edx
);
71 if(max_ext_level
>= 0x80000001){
72 cpuid(0x80000001, eax
, ebx
, ecx
, ext_caps
);
73 if (ext_caps
& (1<<31))
75 if (ext_caps
& (1<<30))
77 if (ext_caps
& (1<<23))
81 cpuid(0, eax
, ebx
, ecx
, edx
);
82 if ( ebx
== 0x68747541 &&
86 if(ext_caps
& (1<<22))
88 } else if (ebx
== 0x746e6543 &&
90 ecx
== 0x736c7561) { /* "CentaurHauls" */
92 if(ext_caps
& (1<<24))
94 } else if (ebx
== 0x69727943 &&
98 /* See if extended CPUID level 80000001 is supported */
99 /* The value of CPUID/80000001 for the 6x86MX is undefined
100 according to the Cyrix CPU Detection Guide (Preliminary
101 Rev. 1.01 table 1), so we'll check the value of eax for
102 CPUID/0 to see if standard CPUID level 2 is supported.
103 According to the table, the only CPU which supports level
104 2 is also the only one which supports extended CPUID levels.
108 if (ext_caps
& (1<<24))
112 av_log(NULL
, AV_LOG_DEBUG
, "%s%s%s%s%s%s\n",
113 (rval
&MM_MMX
) ? "MMX ":"",
114 (rval
&MM_MMXEXT
) ? "MMX2 ":"",
115 (rval
&MM_SSE
) ? "SSE ":"",
116 (rval
&MM_SSE2
) ? "SSE2 ":"",
117 (rval
&MM_3DNOW
) ? "3DNow ":"",
118 (rval
&MM_3DNOWEXT
) ? "3DNowExt ":"");
127 mm_flags
= mm_support();
128 printf("mm_support = 0x%08X\n",mm_flags
);