[PATCH] cpu support for VIA and Transmeta processors

David Kuehling <[email protected]>
Newsgroups gmane.comp.multimedia.ogg.theora.devel
Message-ID <[email protected]>
Hi,

after suffering from extremely low encoding speed on my VIA C7 system, I
had a look at the sources and found out, that MMX and SSE optimization
are only enabled for Intel and AMD CPUs.

The attached patch adds proper CPU capability detection for Via C7, Via
C3 and Transmeta (Crusoe, Efficeon) processors.

Tested on a Via C7 and on a Transmeta Crusoe TM5800.  Via C3 code was
just checked against the output of the 'cpuid' tool.

cheers,

David
-- 
GnuPG public key: http://user.cs.tu-berlin.de/~dvdkhlng/dk.gpg
Fingerprint: B17A DC95 D293 657B 4205  D016 7DEF 5323 C174 7D40

_______________________________________________
theora-dev mailing list
[email protected]
http://lists.xiph.org/mailman/listinfo/theora-dev
theora-cpuid-20080429.diff (text/x-diff, 1.3 KB)
Index: lib/cpu.c
===================================================================
--- lib/cpu.c	(revision 14812)
+++ lib/cpu.c	(working copy)
@@ -116,8 +116,10 @@
 # endif /* GCC, x86_32 */
 
   cpuid(0,eax,ebx,ecx,edx);
-  if(ebx==0x756e6547&&edx==0x49656e69&&ecx==0x6c65746e){
+  if(ebx==0x756e6547&&edx==0x49656e69&&ecx==0x6c65746e ||
+     ebx==0x756e6547&&edx==0x54656e69&&ecx==0x3638784d) {
     /*Intel:*/
+    /*Transmeta (tested with Crusoe TM5800): */
 inteltest:
     cpuid(1,eax,ebx,ecx,edx);
     if((edx&0x00800000)==0)return 0;
@@ -137,6 +139,25 @@
     if(edx&0x80000000)flags|=OC_CPU_X86_3DNOW;
     if(edx&0x40000000)flags|=OC_CPU_X86_3DNOWEXT;
     if(edx&0x00400000)flags|=OC_CPU_X86_MMXEXT;
+  } else if (ebx == 0x746e6543&&edx==0x48727561&&ecx==0x736c7561) {
+    /* VIA: */
+
+    /* VIA C7 supports Intel-like cpuid info */
+    cpuid(1,eax,ebx,ecx,edx);
+    if((edx&0x00800000)) {
+      flags=OC_CPU_X86_MMX;
+      if(edx&0x02000000)flags|=OC_CPU_X86_MMXEXT|OC_CPU_X86_SSE;
+      if(edx&0x04000000)flags|=OC_CPU_X86_SSE2;
+    }
+
+    /* VIA C3 (Samuel, without PadLock) has AMD-like cpuid info */
+    cpuid(0x80000001,eax,ebx,ecx,edx);
+    if((edx&0x00800000)) {
+      flags=OC_CPU_X86_MMX;
+      if(edx&0x80000000) flags|=OC_CPU_X86_3DNOW;
+    }
+
+    /* What about C3-2 ? don't own one :( */
   }
   else{
     /*Implement me.*/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.