]> git.sesse.net Git - vlc/commitdiff
. d�tection d'un processeur MMX.
authorSam Hocevar <sam@videolan.org>
Sun, 13 Feb 2000 19:43:02 +0000 (19:43 +0000)
committerSam Hocevar <sam@videolan.org>
Sun, 13 Feb 2000 19:43:02 +0000 (19:43 +0000)
 . l'output fb remet le terminal comme il faut en sortant.
 . s�paration du flag MMX et de l'architecture dans le Makefile

Makefile
src/interface/control.c
src/interface/interface.c
src/interface/main.c
src/video_output/video_fb.c

index 4337898d4a59313840499ed4611cef7a43621e0f..f3d5005eb0dbdf32a2185451f31553831270fae3 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -26,9 +26,8 @@ VIDEO=X11
 #VIDEO=BEOS
 #VIDEO=DGA
 
-# Target architecture and optimization
-#ARCH=
-ARCH=MMX
+# Target architecture
+ARCH=X86
 #ARCH=PPC
 #ARCH=SPARC
 
@@ -37,6 +36,10 @@ SYS=LINUX
 #SYS=BSD
 #SYS=BEOS
 
+# For x86 architecture, choose MMX support
+MMX=YES
+#MMX=NO
+
 # Decoder choice - ?? old decoder will be removed soon
 #DECODER=old
 DECODER=new
@@ -126,19 +129,13 @@ CCFLAGS += -O6
 CCFLAGS += -ffast-math -funroll-loops -fargument-noalias-global
 CCFLAGS += -fomit-frame-pointer
 
-# Optimizations for x86 familiy, without MMX
-ifeq ($(ARCH),)
+# Optimizations for x86 familiy
+ifeq ($(ARCH),X86)
 CCFLAGS += -malign-double
 CCFLAGS += -march=pentiumpro
 #CCFLAGS += -march=pentium
 endif
 
-# Optimization for x86 with MMX support
-ifeq ($(ARCH),MMX)
-CCFLAGS += -malign-double
-CCFLAGS += -march=pentiumpro
-endif
-
 # Optimizations for PowerPC
 ifeq ($(ARCH),PPC)
 CCFLAGS += -mcpu=604e -mmultiple -mhard-float -mstring
@@ -166,10 +163,12 @@ LCFLAGS += -Wall
 # C compiler flags: common flags
 #
 
-# Optimizations for x86 with MMX support
-ifeq ($(ARCH),MMX)
+# Eventual MMX optimizations for x86
+ifeq ($(ARCH),X86)
+ifeq ($(MMX), YES) # MMX is YES or AUTO
 CFLAGS += -DHAVE_MMX
 endif
+endif
 
 #
 # Additionnal debugging flags
@@ -276,15 +275,17 @@ C_OBJ = $(interface_obj) \
 #
 # Assembler Objects
 # 
-ifeq ($(ARCH),MMX)
-ifeq ($(DECODER),old)
-ASM_OBJ =                      video_decoder_ref/idctmmx.o \
+ifeq ($(ARCH),X86)
+ifeq ($(MMX), YES)
+ifeq ($(DECODER),new)
+ASM_OBJ =                      video_decoder/idctmmx.o \
                                                video_output/video_yuv_mmx.o
 else
-ASM_OBJ =                      video_decoder/idctmmx.o \
+ASM_OBJ =                      video_decoder_ref/idctmmx.o \
                                                video_output/video_yuv_mmx.o
 endif
 endif
+endif
 
 #
 # Other lists of files
index 3c18d17e8c1918f48302ef81166a49602698abf7..0c0bf640d1c6b7bbe93878c802c9ce4db7fa90f7 100644 (file)
  * Preamble
  *****************************************************************************/
 #include "vlc.h"
-/*??
-#include <pthread.h>
-#include <stdio.h>
-#include <netinet/in.h>
-#include <sys/soundcard.h>
-#include <sys/uio.h>
-
-#include "config.h"
-#include "common.h"
-#include "mtime.h"
-#include "vlc_thread.h"
-
-#include "input.h"
-#include "input_vlan.h"
-
-#include "audio_output.h"
-
-#include "video.h"
-#include "video_output.h"
-
-#include "xconsole.h"
-#include "interface.h"
-#include "intf_msg.h"
-#include "control.h"
-
-#include "pgm_data.h"*/
-
 
index 412be62257f879e9ef235792afe2645923af5b57..967d4221c5bfdc2b6de173f09bb83bb0f51ff3c4 100644 (file)
@@ -14,7 +14,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <sys/types.h>
-#include <sys/uio.h>                                        /* for input.h */
+#include <sys/uio.h>                                          /* for input.h */
 
 #include "config.h"
 #include "common.h"
index 568f1d48b2244a3e592efe7a0797c014b446dd5c..13b9b330420620f7f03f692fb024f06704161a3c 100644 (file)
@@ -97,6 +97,7 @@ static void Version                 ( void );
 
 static void InitSignalHandler       ( void );
 static void SignalHandler           ( int i_signal );
+static int  TestMMX                 ( void );
 
 /*****************************************************************************
  * main: parse command line, start interface and spawn threads
@@ -116,6 +117,13 @@ int main( int i_argc, char *ppsz_argv[], char *ppsz_env[] )
     /*
      * Read configuration, initialize messages interface and set up program
      */
+#ifdef HAVE_MMX
+    if( !TestMMX() )
+    {
+        fprintf( stderr, "Sorry, this program needs an MMX processor. Please run the non-MMX version.\n" );
+       return(0);
+    }
+#endif
     p_main->p_msg = intf_MsgCreate();
     if( !p_main->p_msg )                         /* start messages interface */
     {
@@ -496,5 +504,73 @@ static void SignalHandler( int i_signal )
     p_main->p_intf->b_die = 1;
 }
 
-
-
+#ifdef HAVE_MMX
+/*****************************************************************************
+ * TestMMX: tests if the processor has MMX support.
+ *****************************************************************************
+ * This function is called if HAVE_MMX is enabled, to check whether the
+ * cpu really supports MMX.
+ *****************************************************************************/
+static int TestMMX( void )
+{
+    int reg, dummy;
+
+    /* test for a 386 cpu */
+    asm volatile ( "pushfl
+                    popl %%eax
+                    movl %%eax, %%ecx
+                    xorl $0x40000, %%eax
+                    pushl %%eax
+                    popfl
+                    pushfl
+                    popl %%eax
+                    xorl %%ecx, %%eax
+                    andl $0x40000, %%eax"
+                 : "=a" ( reg ) );
+    
+    if( !reg )
+        return( 0 );
+
+    /* test for a 486 cpu */
+    asm volatile ( "movl %%ecx, %%eax
+                    xorl $0x200000, %%eax
+                    pushl %%eax
+                    popfl
+                    pushfl
+                    popl %%eax
+                    xorl %%ecx, %%eax
+                    pushl %%ecx 
+                    popfl
+                    andl $0x200000, %%eax"
+                 : "=a" ( reg ) );
+    
+    if( !reg )
+        return( 0 );
+
+    /* the cpu supports the CPUID instruction - get its level */
+    asm volatile ( "cpuid"
+                 : "=a" ( reg ),
+                   "=b" ( dummy ),
+                   "=c" ( dummy ),
+                   "=d" ( dummy )
+                 : "a"  ( 0 ) ); /* level 0 */
+
+    /* this shouldn't happen on a normal cpu */
+    if( !reg )
+        return( 0 );
+
+    /* test for the MMX flag */
+    asm volatile ( "cpuid
+                    andl $0x00800000, %%edx" /* X86_FEATURE_MMX */
+                 : "=a" ( dummy ),
+                   "=b" ( dummy ),
+                   "=c" ( dummy ),
+                   "=d" ( reg )
+                 : "a"  ( 1 ) ); /* level 1 */
+
+    if( !reg )
+        return( 0 );
+
+    return( 1 );
+}
+#endif
index 60907fe327a12b05a9e9d7d74d15dff1123eb77b..507f999bf2a5c8e820e24b579b527ba3ea748c98 100644 (file)
@@ -1,6 +1,6 @@
 /*****************************************************************************
  * vout_fb.c: Linux framebuffer video output display method
- * (c)1998 VideoLAN
+ * (c)1999 VideoLAN
  *****************************************************************************/
 
 /*****************************************************************************
@@ -133,9 +133,11 @@ int vout_SysManage( vout_thread_t *p_vout )
  *****************************************************************************/
 void vout_SysDisplay( vout_thread_t *p_vout )
 {
-    /* tout est bien affiché, on peut échanger les 2 écrans */
-    p_vout->p_sys->var_info.xoffset = 0;
+    /* swap the two Y offsets */
     p_vout->p_sys->var_info.yoffset = p_vout->i_buffer_index ? p_vout->p_sys->var_info.yres : 0;
+    /* the X offset should be 0, but who knows ...
+     * some other app might have played with the framebuffer */
+    p_vout->p_sys->var_info.xoffset = 0;
 
     //ioctl( p_vout->p_sys->i_fb_dev, FBIOPUT_VSCREENINFO, &p_vout->p_sys->var_info ); 
     ioctl( p_vout->p_sys->i_fb_dev, FBIOPAN_DISPLAY, &p_vout->p_sys->var_info );       
@@ -218,12 +220,9 @@ static int FBOpenDisplay( vout_thread_t *p_vout )
         p_vout->p_sys->fb_cmap.blue = p_vout->p_sys->fb_palette + 2 * 256 * sizeof(unsigned short);
         p_vout->p_sys->fb_cmap.transp = p_vout->p_sys->fb_palette + 3 * 256 * sizeof(unsigned short);
 
+        /* saves the colormap */
         ioctl( p_vout->p_sys->i_fb_dev, FBIOGETCMAP, &p_vout->p_sys->fb_cmap );
 
-        /* initializes black & white palette */
-        //FBInitRGBPalette( p_vout );
-       //FBInitBWPalette( p_vout );
-
         p_vout->i_bytes_per_pixel = 1;
         p_vout->i_bytes_per_line = p_vout->i_width;
         break;
@@ -247,7 +246,7 @@ static int FBOpenDisplay( vout_thread_t *p_vout )
     default:                                     /* unsupported screen depth */
         intf_ErrMsg("vout error: screen depth %d is not supported\n",
                                     p_vout->i_screen_depth);
-        return( 1  );
+        return( 1 );
         break;
     }
 
@@ -303,8 +302,8 @@ static void FBCloseDisplay( vout_thread_t *p_vout )
         free( p_vout->p_sys->fb_palette );
     }
 
-    // Destroy window and close display
-    close( p_vout->p_sys->i_fb_dev );
+    /* Destroy window and close display */
+    close( p_vout->p_sys->i_fb_dev );    
 }
 
 /*****************************************************************************