[Mplayer-cvslog] CVS: main cpudetect.c,1.6,1.7

Arpi of Ize arpi at mplayer.dev.hu
Fri Oct 19 16:02:14 CEST 2001


Update of /cvsroot/mplayer/main
In directory mplayer:/var/tmp.root/cvs-serv11671

Modified Files:
	cpudetect.c 
Log Message:
final fix?

Index: cpudetect.c
===================================================================
RCS file: /cvsroot/mplayer/main/cpudetect.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- cpudetect.c	19 Oct 2001 13:28:59 -0000	1.6
+++ cpudetect.c	19 Oct 2001 14:02:12 -0000	1.7
@@ -86,83 +86,35 @@
 	unsigned int regs2[4];
 	
 	bzero(caps, sizeof(*caps));
-	printf("CPUid available: %s\n",has_cpuid()?"yes":"no");
-	/*if (!has_cpuid())
-		return;*/
-	do_cpuid(0x00000000, regs);
-	printf("CPU vendor name: %.4s%.4s%.4s  cpuid level: %d\n",&regs[1],&regs[3],&regs[2],regs[0]);
-	if (regs[0]>0x00000001) 
+	if (!has_cpuid()) {
+	    printf("CPUID not supported!???\n");
+	    return;
+	}
+	do_cpuid(0x00000000, regs); // get _max_ cpuid level and vendor name
+	printf("CPU vendor name: %.4s%.4s%.4s  max cpuid level: %d\n",&regs[1],&regs[3],&regs[2],regs[0]);
+	if (regs[0]>=0x00000001)
 	{
 		do_cpuid(0x00000001, regs2);
-		printf("CPU family: %d\n",(regs2[0] >> 8)&0xf);
-		switch ((regs2[0] >> 8)&0xf) {
-			case 3:
-				caps->cpuType=CPUTYPE_I386;
-				break;
-			case 4:
-				caps->cpuType=CPUTYPE_I486;
-				break;
-			case 5:
-				caps->cpuType=CPUTYPE_I586;
-				break;
-			case 6:
-				caps->cpuType=CPUTYPE_I686;
-				break;
-			default:
-				caps->cpuType=CPUTYPE_I386;
-				printf("Unknown cpu type, default to i386\n");
-				break;
+		caps->cpuType=(regs2[0] >> 8)&0xf;
+		if(caps->cpuType==0xf){
+		    // use extended family (P4, IA64)
+		    caps->cpuType=8+((regs2[0]>>20)&255);
 		}
+
+		// general feature flags:
 		caps->hasMMX  = (regs2[3] & (1 << 23 )) >> 23; // 0x0800000
-		
-		// FIXME: is this ok for non-intel CPUs too? (cyrix,amd)
 		caps->hasSSE  = (regs2[3] & (1 << 25 )) >> 25; // 0x2000000
 		caps->hasSSE2 = (regs2[3] & (1 << 26 )) >> 26; // 0x4000000
-		/* FIXME: Does SSE2 need more OS support, too? */
-#if defined(__linux__) || defined(__FreeBSD__)
-		if (caps->hasSSE)
-			check_os_katmai_support();
-		if (!caps->hasSSE)
-			caps->hasSSE2 = 0;
-#else
-		caps->hasSSE=0;
-		caps->hasSSE2 = 0;
-#endif
-		/* FIXME: Are MMX2 ops on the same set of processors as SSE?  Do they need OS support?*/
-		caps->hasMMX2 = caps->hasSSE;
+		caps->hasMMX2 = caps->hasSSE; // SSE cpus supports mmxext too
 	}
-	if (regs[1] == 0x68747541 &&    // AuthenticAMD
-            regs[3] == 0x69746e65 &&
-            regs[2] == 0x444d4163) {
-		do_cpuid(0x00000001, regs2);
-		printf("CPU family: %d\n",(regs2[0] >> 8)&0xf);
-		switch ((regs2[0] >> 8)&0xf) {
-			case 3:
-				caps->cpuType=CPUTYPE_I386;
-				break;
-			case 4:
-				caps->cpuType=CPUTYPE_I486;
-				break;
-			case 5:
-				caps->cpuType=CPUTYPE_I586;
-				break;
-			case 6:
-				caps->cpuType=CPUTYPE_I686;
-				break;
-			default:
-				caps->cpuType=CPUTYPE_I386;
-				printf("Unknown cpu type, default to i386\n");
-				break;
-		}
-		do_cpuid(0x80000000, regs);
-		printf("AMD cpuid-level: 0x%X\n",regs[0]);
-		if (regs[0]>=0x80000001) {
-			do_cpuid(0x80000001, regs2);
-			caps->hasMMX  = (regs2[3] & (1 << 23 )) >> 23; // 0x0800000
-			caps->hasMMX2 = (regs2[3] & (1 << 22 )) >> 22; // 0x400000
-			caps->has3DNow    = (regs2[3] & (1 << 31 )) >> 31; //0x80000000
-			caps->has3DNowExt = (regs2[3] & (1 << 30 )) >> 30;
-		}
+	do_cpuid(0x80000000, regs);
+	if (regs[0]>=0x80000001) {
+		printf("extended cpuid-level: %d\n",regs[0]&0x7FFFFFFF);
+		do_cpuid(0x80000001, regs2);
+		caps->hasMMX  = (regs2[3] & (1 << 23 )) >> 23; // 0x0800000
+		caps->hasMMX2 = (regs2[3] & (1 << 22 )) >> 22; // 0x400000
+		caps->has3DNow    = (regs2[3] & (1 << 31 )) >> 31; //0x80000000
+		caps->has3DNowExt = (regs2[3] & (1 << 30 )) >> 30;
 	}
 #if 0
 	printf("cpudetect: MMX=%d MMX2=%d SSE=%d SSE2=%d 3DNow=%d 3DNowExt=%d\n",
@@ -173,6 +125,18 @@
 		gCpuCaps.has3DNow,
 		gCpuCaps.has3DNowExt );
 #endif
+
+		/* FIXME: Does SSE2 need more OS support, too? */
+#if defined(__linux__) || defined(__FreeBSD__)
+		if (caps->hasSSE)
+			check_os_katmai_support();
+		if (!caps->hasSSE)
+			caps->hasSSE2 = 0;
+#else
+		caps->hasSSE=0;
+		caps->hasSSE2 = 0;
+#endif
+
 
 }
 




More information about the MPlayer-cvslog mailing list