~ubuntu-branches/ubuntu/feisty/avidemux/feisty

« back to all changes in this revision

Viewing changes to adm_lavcodec/i386/cputest.c

  • Committer: Bazaar Package Importer
  • Author(s): Christian Marillat
  • Date: 2005-05-25 13:02:29 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20050525130229-jw94cav0yhmg7vjw
Tags: 1:2.0.40-0.0
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
/* Function to test if multimedia instructions are supported...  */
26
26
int mm_support(void)
27
27
{
28
 
    int rval;
 
28
    int rval = 0;
29
29
    int eax, ebx, ecx, edx;
30
 
    long a,c;
 
30
    int max_std_level, max_ext_level, std_caps=0, ext_caps=0;
 
31
    long a, c;
31
32
    
32
33
    __asm__ __volatile__ (
33
34
                          /* See if CPUID instruction is supported ... */
52
53
    
53
54
    if (a == c)
54
55
        return 0; /* CPUID not supported */
55
 
    
56
 
    cpuid(0, eax, ebx, ecx, edx);
57
 
 
58
 
    if (ebx == 0x756e6547 &&
59
 
        edx == 0x49656e69 &&
60
 
        ecx == 0x6c65746e) {
61
 
        
62
 
        /* intel */
63
 
    inteltest:
64
 
        cpuid(1, eax, ebx, ecx, edx);
65
 
        if ((edx & 0x00800000) == 0)
66
 
            return 0;
67
 
        rval = MM_MMX;
68
 
        if (edx & 0x02000000) 
 
56
 
 
57
    cpuid(0, max_std_level, ebx, ecx, edx);
 
58
 
 
59
    if(max_std_level >= 1){
 
60
        cpuid(1, eax, ebx, ecx, std_caps);
 
61
        if (std_caps & (1<<23))
 
62
            rval |= MM_MMX;
 
63
        if (std_caps & (1<<25)) 
69
64
            rval |= MM_MMXEXT | MM_SSE;
70
 
        if (edx & 0x04000000) 
 
65
        if (std_caps & (1<<26)) 
71
66
            rval |= MM_SSE2;
72
 
        return rval;
73
 
    } else if (ebx == 0x68747541 &&
 
67
    }
 
68
 
 
69
    cpuid(0x80000000, max_ext_level, ebx, ecx, edx);
 
70
 
 
71
    if(max_ext_level >= 0x80000001){
 
72
        cpuid(0x80000001, eax, ebx, ecx, ext_caps);
 
73
        if (ext_caps & (1<<31))
 
74
            rval |= MM_3DNOW;
 
75
        if (ext_caps & (1<<30))
 
76
            rval |= MM_3DNOWEXT;
 
77
        if (ext_caps & (1<<23))
 
78
            rval |= MM_MMX;
 
79
    }
 
80
 
 
81
    cpuid(0, eax, ebx, ecx, edx);
 
82
    if (       ebx == 0x68747541 &&
74
83
               edx == 0x69746e65 &&
75
84
               ecx == 0x444d4163) {
76
85
        /* AMD */
77
 
        cpuid(0x80000000, eax, ebx, ecx, edx);
78
 
        if ((unsigned)eax < 0x80000001)
79
 
            goto inteltest;
80
 
        cpuid(0x80000001, eax, ebx, ecx, edx);
81
 
        if ((edx & 0x00800000) == 0)
82
 
            return 0;
83
 
        rval = MM_MMX;
84
 
        if (edx & 0x80000000)
85
 
            rval |= MM_3DNOW;
86
 
        if (edx & 0x00400000)
87
 
        {
88
 
                //MEANX : A64 & Xp can do sse
 
86
        if(ext_caps & (1<<22))
89
87
            rval |= MM_MMXEXT;
90
 
             cpuid(1, eax, ebx, ecx, edx);
91
 
             if(edx & 0x02000000)
92
 
                rval |= MM_SSE;
93
 
        }
94
 
        return rval;
95
88
    } else if (ebx == 0x746e6543 &&
96
89
               edx == 0x48727561 &&
97
90
               ecx == 0x736c7561) {  /*  "CentaurHauls" */
98
91
        /* VIA C3 */
99
 
        cpuid(0x80000000, eax, ebx, ecx, edx);
100
 
        if ((unsigned)eax < 0x80000001)
101
 
            goto inteltest;     
102
 
        cpuid(0x80000001, eax, ebx, ecx, edx);
103
 
        rval = 0;      
104
 
        if( edx & ( 1 << 31) )
105
 
          rval |= MM_3DNOW;
106
 
        if( edx & ( 1 << 23) )
107
 
          rval |= MM_MMX;
108
 
        if( edx & ( 1 << 24) )
 
92
        if(ext_caps & (1<<24))
109
93
          rval |= MM_MMXEXT;
110
 
        if(rval==0)
111
 
            goto inteltest;
112
 
        return rval;
113
94
    } else if (ebx == 0x69727943 &&
114
95
               edx == 0x736e4978 &&
115
96
               ecx == 0x64616574) {
122
103
           According to the table, the only CPU which supports level
123
104
           2 is also the only one which supports extended CPUID levels.
124
105
        */
125
 
        if (eax != 2) 
126
 
            goto inteltest;
127
 
        cpuid(0x80000001, eax, ebx, ecx, edx);
128
 
        if ((eax & 0x00800000) == 0)
129
 
            return 0;
130
 
        rval = MM_MMX;
131
 
        if (eax & 0x01000000)
 
106
        if (eax < 2) 
 
107
            return rval;
 
108
        if (ext_caps & (1<<24))
132
109
            rval |= MM_MMXEXT;
133
 
        return rval;
134
 
    } else if (ebx == 0x756e6547 &&
135
 
               edx == 0x54656e69 &&
136
 
               ecx == 0x3638784d) {
137
 
        /* Tranmeta Crusoe */
138
 
        cpuid(0x80000000, eax, ebx, ecx, edx);
139
 
        if ((unsigned)eax < 0x80000001)
140
 
            return 0;
141
 
        cpuid(0x80000001, eax, ebx, ecx, edx);
142
 
        if ((edx & 0x00800000) == 0)
143
 
            return 0;
144
 
        return MM_MMX;
145
 
    } else {
146
 
        return 0;
147
110
    }
 
111
#if 0
 
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 ":"");
 
119
#endif
 
120
    return rval;
148
121
}
149
122
 
150
123
#ifdef __TEST__