[MPlayer-cvslog] CVS: main cpudetect.c,1.43,1.44
Ivan Kalvachev CVS
syncmail at mplayerhq.hu
Thu Feb 9 16:11:16 CET 2006
- Previous message: [MPlayer-cvslog] CVS: main/libvo font_load.h, 1.13, 1.14 font_load_ft.c, 1.16, 1.17 gl_common.c, 1.40, 1.41 gl_common.h, 1.24, 1.25 osd.c, 1.24, 1.25 osd.h, 1.4, 1.5 sub.c, 1.82, 1.83 sub.h, 1.30, 1.31 video_out.c, 1.103, 1.104 video_out.h, 1.62, 1.63 vo_aa.c, 1.47, 1.48 vo_cvidix.c, 1.16, 1.17 vo_gl.c, 1.113, 1.114 vo_gl2.c, 1.86, 1.87 vo_x11.c, 1.144, 1.145 x11_common.c, 1.203, 1.204 x11_common.h, 1.44, 1.45
- Next message: [MPlayer-cvslog] CVS: main cpudetect.c,1.43,1.44
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
CVS change done by Ivan Kalvachev CVS
Update of /cvsroot/mplayer/main
In directory mail:/var2/tmp/cvs-serv20348
Modified Files:
cpudetect.c
Log Message:
Revert and Restore cpu speed detection originally writen by atmos (with few modifications).
Now when we have MPLAYER_VERBOSE envermoment variable it is possible to disable it without
compleatly removing detection from the source.
Index: cpudetect.c
===================================================================
RCS file: /cvsroot/mplayer/main/cpudetect.c,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -r1.43 -r1.44
--- cpudetect.c 9 Feb 2006 14:07:51 -0000 1.43
+++ cpudetect.c 9 Feb 2006 15:11:14 -0000 1.44
@@ -13,6 +13,7 @@
#include <stdio.h>
#include <string.h>
+#include "osdep/timer.h"
#if defined (__NetBSD__) || defined(__OpenBSD__)
#include <sys/param.h>
@@ -211,6 +212,27 @@
#endif
}
+static inline unsigned long long int rdtsc( void )
+{
+ unsigned long long int retval;
+ __asm __volatile ("rdtsc":"=A"(retval)::"memory");
+ return retval;
+}
+
+/* Returns CPU clock in khz */
+static unsigned int GetCpuSpeed(void)
+{
+ unsigned long long int tscstart, tscstop;
+ unsigned int start, stop;
+
+ tscstart = rdtsc();
+ start = GetTimer();
+ usec_sleep(50000);
+ stop = GetTimer();
+ tscstop = rdtsc();
+
+ return((tscstop-tscstart)/((stop-start)/1000.0));
+}
#define CPUID_EXTFAMILY ((regs2[0] >> 20)&0xFF) /* 27..20 */
#define CPUID_EXTMODEL ((regs2[0] >> 16)&0x0F) /* 19..16 */
@@ -221,7 +243,7 @@
char *GetCpuFriendlyName(unsigned int regs[], unsigned int regs2[]){
#include "cputable.h" /* get cpuname and cpuvendors */
- char vendor[17];
+ char vendor[17], cpuspeed[16];
char *retname;
int i;
@@ -232,10 +254,24 @@
sprintf(vendor,"%.4s%.4s%.4s",(char*)(regs+1),(char*)(regs+3),(char*)(regs+2));
+ /* Measure CPU speed */
+ if (verbose >=0 && gCpuCaps.hasTSC && (i = GetCpuSpeed()) > 0) {
+ if (i < 1000000) {
+ i += 50; /* for rounding */
+ snprintf(cpuspeed,15, " %d.%d MHz", i/1000, (i/100)%10);
+ } else {
+ //i += 500; /* for rounding */
+ snprintf(cpuspeed,15, " %d MHz", i/1000);
+ }
+ cpuspeed[15]='\0';
+ } else { /* No TSC Support */
+ cpuspeed[0]='\0';
+ }
+
for(i=0; i<MAX_VENDORS; i++){
if(!strcmp(cpuvendors[i].string,vendor)){
if(cpuname[i][CPUID_FAMILY][CPUID_MODEL]){
- snprintf(retname,255,"%s %s",cpuvendors[i].name,cpuname[i][CPUID_FAMILY][CPUID_MODEL]);
+ snprintf(retname,255,"%s %s%s",cpuvendors[i].name,cpuname[i][CPUID_FAMILY][CPUID_MODEL],cpuspeed);
} else {
snprintf(retname,255,"unknown %s %d. Generation CPU",cpuvendors[i].name,CPUID_FAMILY);
mp_msg(MSGT_CPUDETECT,MSGL_WARN,"unknown %s CPU:\n",cpuvendors[i].name);
- Previous message: [MPlayer-cvslog] CVS: main/libvo font_load.h, 1.13, 1.14 font_load_ft.c, 1.16, 1.17 gl_common.c, 1.40, 1.41 gl_common.h, 1.24, 1.25 osd.c, 1.24, 1.25 osd.h, 1.4, 1.5 sub.c, 1.82, 1.83 sub.h, 1.30, 1.31 video_out.c, 1.103, 1.104 video_out.h, 1.62, 1.63 vo_aa.c, 1.47, 1.48 vo_cvidix.c, 1.16, 1.17 vo_gl.c, 1.113, 1.114 vo_gl2.c, 1.86, 1.87 vo_x11.c, 1.144, 1.145 x11_common.c, 1.203, 1.204 x11_common.h, 1.44, 1.45
- Next message: [MPlayer-cvslog] CVS: main cpudetect.c,1.43,1.44
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the MPlayer-cvslog
mailing list