Commit a78ebd14 authored by Sam Hocevar's avatar Sam Hocevar

  * CPU detection under BeOS.
  * Fixed XVideo port selection.
parent 09fed885
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* vout_xvideo.c: Xvideo video output display method * vout_xvideo.c: Xvideo video output display method
***************************************************************************** *****************************************************************************
* Copyright (C) 1998-2001 VideoLAN * Copyright (C) 1998-2001 VideoLAN
* $Id: vout_xvideo.c,v 1.36.2.1 2001/12/10 10:59:14 massiot Exp $ * $Id: vout_xvideo.c,v 1.36.2.2 2001/12/17 03:48:12 sam Exp $
* *
* Authors: Shane Harper <shanegh@optusnet.com.au> * Authors: Shane Harper <shanegh@optusnet.com.au>
* Vincent Seguin <seguin@via.ecp.fr> * Vincent Seguin <seguin@via.ecp.fr>
...@@ -1204,6 +1204,8 @@ static int XVideoGetPort( Display *dpy ) ...@@ -1204,6 +1204,8 @@ static int XVideoGetPort( Display *dpy )
/* No special xv port has been requested so try all of them */ /* No special xv port has been requested so try all of them */
for( i_adaptor = 0; i_adaptor < i_num_adaptors; ++i_adaptor ) for( i_adaptor = 0; i_adaptor < i_num_adaptors; ++i_adaptor )
{ {
XvImageFormatValues *p_formats;
int i_format, i_num_formats;
int i_port; int i_port;
/* If we requested an adaptor and it's not this one, we aren't /* If we requested an adaptor and it's not this one, we aren't
...@@ -1213,29 +1215,9 @@ static int XVideoGetPort( Display *dpy ) ...@@ -1213,29 +1215,9 @@ static int XVideoGetPort( Display *dpy )
continue; continue;
} }
/* If the adaptor doesn't have the required properties, skip it */
if( !( p_adaptor[ i_adaptor ].type & XvInputMask ) ||
!( p_adaptor[ i_adaptor ].type & XvImageMask ) )
{
continue;
}
for( i_port = p_adaptor[i_adaptor].base_id;
i_port < p_adaptor[i_adaptor].base_id
+ p_adaptor[i_adaptor].num_ports;
i_port++ )
{
XvImageFormatValues *p_formats;
int i_format, i_num_formats;
/* If we already found a port, we aren't interested */
if( i_selected_port != -1 )
{
continue;
}
/* Check that port supports YUV12 planar format... */ /* Check that port supports YUV12 planar format... */
p_formats = XvListImageFormats( dpy, i_port, &i_num_formats ); p_formats = XvListImageFormats( dpy, p_adaptor[i_adaptor].base_id,
&i_num_formats );
for( i_format = 0; i_format < i_num_formats; i_format++ ) for( i_format = 0; i_format < i_num_formats; i_format++ )
{ {
...@@ -1244,16 +1226,34 @@ static int XVideoGetPort( Display *dpy ) ...@@ -1244,16 +1226,34 @@ static int XVideoGetPort( Display *dpy )
XvAttribute *p_attr; XvAttribute *p_attr;
int i_attr, i_num_attributes; int i_attr, i_num_attributes;
/* If this is not the format we want, forget it */
if( p_formats[ i_format ].id != GUID_YUV12_PLANAR ) if( p_formats[ i_format ].id != GUID_YUV12_PLANAR )
{ {
continue; continue;
} }
/* Found a matching port, print a description of this port */ /* Look for the first available port supporting this format */
for( i_port = p_adaptor[i_adaptor].base_id;
( i_port < p_adaptor[i_adaptor].base_id
+ p_adaptor[i_adaptor].num_ports )
&& ( i_selected_port == -1 );
i_port++ )
{
if( XvGrabPort( dpy, i_port, CurrentTime ) == Success )
{
i_selected_port = i_port; i_selected_port = i_port;
}
}
intf_WarnMsg( 3, "vout: XVideoGetPort found adaptor %i port %i", /* If no free port was found, forget it */
i_adaptor, i_port); if( i_selected_port == -1 )
{
continue;
}
/* If we found a port, print information about it */
intf_WarnMsg( 3, "vout: GetXVideoPort found adaptor %i, port %i",
i_adaptor, i_selected_port );
intf_WarnMsg( 3, " image format 0x%x (%4.4s) %s supported", intf_WarnMsg( 3, " image format 0x%x (%4.4s) %s supported",
p_formats[ i_format ].id, p_formats[ i_format ].id,
(char *)&p_formats[ i_format ].id, (char *)&p_formats[ i_format ].id,
...@@ -1262,7 +1262,8 @@ static int XVideoGetPort( Display *dpy ) ...@@ -1262,7 +1262,8 @@ static int XVideoGetPort( Display *dpy )
intf_WarnMsg( 4, " encoding list:" ); intf_WarnMsg( 4, " encoding list:" );
if( XvQueryEncodings( dpy, i_port, &i_num_encodings, &p_enc ) if( XvQueryEncodings( dpy, i_selected_port,
&i_num_encodings, &p_enc )
!= Success ) != Success )
{ {
intf_WarnMsg( 4, " XvQueryEncodings failed" ); intf_WarnMsg( 4, " XvQueryEncodings failed" );
...@@ -1285,7 +1286,7 @@ static int XVideoGetPort( Display *dpy ) ...@@ -1285,7 +1286,7 @@ static int XVideoGetPort( Display *dpy )
} }
intf_WarnMsg( 4, " attribute list:" ); intf_WarnMsg( 4, " attribute list:" );
p_attr = XvQueryPortAttributes( dpy, i_port, p_attr = XvQueryPortAttributes( dpy, i_selected_port,
&i_num_attributes ); &i_num_attributes );
for( i_attr = 0; i_attr < i_num_attributes; i_attr++ ) for( i_attr = 0; i_attr < i_num_attributes; i_attr++ )
{ {
...@@ -1307,7 +1308,7 @@ static int XVideoGetPort( Display *dpy ) ...@@ -1307,7 +1308,7 @@ static int XVideoGetPort( Display *dpy )
{ {
XFree( p_formats ); XFree( p_formats );
} }
}
} }
if( i_num_adaptors > 0 ) if( i_num_adaptors > 0 )
...@@ -1319,12 +1320,12 @@ static int XVideoGetPort( Display *dpy ) ...@@ -1319,12 +1320,12 @@ static int XVideoGetPort( Display *dpy )
{ {
if( i_requested_adaptor == -1 ) if( i_requested_adaptor == -1 )
{ {
intf_WarnMsg( 3, "vout: no XVideo port found supporting YUV12" ); intf_WarnMsg( 3, "vout: no free XVideo port found for YV12" );
} }
else else
{ {
intf_WarnMsg( 3, "vout: XVideo adaptor %i does not support YUV12", intf_WarnMsg( 3, "vout: XVideo adaptor %i does not have a free "
i_requested_adaptor ); "XVideo port for YV12", i_requested_adaptor );
} }
} }
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* and spawn threads. * and spawn threads.
***************************************************************************** *****************************************************************************
* Copyright (C) 1998-2001 VideoLAN * Copyright (C) 1998-2001 VideoLAN
* $Id: main.c,v 1.132.2.1 2001/12/10 04:54:17 sam Exp $ * $Id: main.c,v 1.132.2.2 2001/12/17 03:48:12 sam Exp $
* *
* Authors: Vincent Seguin <seguin@via.ecp.fr> * Authors: Vincent Seguin <seguin@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org> * Samuel Hocevar <sam@zoy.org>
...@@ -150,16 +150,6 @@ ...@@ -150,16 +150,6 @@
#define SHORT_HELP 1 #define SHORT_HELP 1
#define LONG_HELP 2 #define LONG_HELP 2
/* Needed for x86 CPU capabilities detection */
#define cpuid( a ) \
asm volatile ( "cpuid" \
: "=a" ( i_eax ), \
"=b" ( i_ebx ), \
"=c" ( i_ecx ), \
"=d" ( i_edx ) \
: "a" ( a ) \
: "cc" );
/* Long options */ /* Long options */
static const struct option longopts[] = static const struct option longopts[] =
{ {
...@@ -1129,15 +1119,7 @@ static int CPUCapabilities( void ) ...@@ -1129,15 +1119,7 @@ static int CPUCapabilities( void )
{ {
volatile int i_capabilities = CPU_CAPABILITY_NONE; volatile int i_capabilities = CPU_CAPABILITY_NONE;
#if defined( SYS_BEOS ) #if defined( SYS_DARWIN )
i_capabilities |= CPU_CAPABILITY_FPU
| CPU_CAPABILITY_486
| CPU_CAPABILITY_586
| CPU_CAPABILITY_MMX;
return( i_capabilities );
#elif defined( SYS_DARWIN )
struct host_basic_info hi; struct host_basic_info hi;
kern_return_t ret; kern_return_t ret;
host_name_port_t host; host_name_port_t host;
...@@ -1173,21 +1155,37 @@ static int CPUCapabilities( void ) ...@@ -1173,21 +1155,37 @@ static int CPUCapabilities( void )
volatile unsigned int i_eax, i_ebx, i_ecx, i_edx; volatile unsigned int i_eax, i_ebx, i_ecx, i_edx;
volatile boolean_t b_amd; volatile boolean_t b_amd;
/* Needed for x86 CPU capabilities detection */
# define cpuid( a ) \
asm volatile ( "pushl %%ebx\n\t" \
"cpuid\n\t" \
"movl %%ebx,%1\n\t" \
"popl %%ebx\n\t" \
: "=a" ( i_eax ), \
"=r" ( i_ebx ), \
"=c" ( i_ecx ), \
"=d" ( i_edx ) \
: "a" ( a ) \
: "cc" );
i_capabilities |= CPU_CAPABILITY_FPU; i_capabilities |= CPU_CAPABILITY_FPU;
signal( SIGILL, InstructionSignalHandler ); signal( SIGILL, InstructionSignalHandler );
/* test for a 486 CPU */ /* test for a 486 CPU */
asm volatile ( "pushfl\n\t" asm volatile ( "pushl %%ebx\n\t"
"pushfl\n\t"
"popl %%eax\n\t" "popl %%eax\n\t"
"movl %%eax, %%ebx\n\t" "movl %%eax, %%ebx\n\t"
"xorl $0x200000, %%eax\n\t" "xorl $0x200000, %%eax\n\t"
"pushl %%eax\n\t" "pushl %%eax\n\t"
"popfl\n\t" "popfl\n\t"
"pushfl\n\t" "pushfl\n\t"
"popl %%eax" "popl %%eax\n\t"
"movl %%ebx,%1\n\t"
"popl %%ebx\n\t"
: "=a" ( i_eax ), : "=a" ( i_eax ),
"=b" ( i_ebx ) "=r" ( i_ebx )
: :
: "cc" ); : "cc" );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment