[Mplayer-cvslog] CVS: main/libdha/sysdep AsmMacros_x86.h,1.2,1.3 pci_linux.c,1.6,1.7 pci_powerpc.c,1.3,1.4

Alex Beregszaszi alex at mplayerhq.hu
Fri Dec 20 22:07:30 CET 2002


Update of /cvsroot/mplayer/main/libdha/sysdep
In directory mail:/var/tmp.root/cvs-serv7528/sysdep

Modified Files:
	AsmMacros_x86.h pci_linux.c pci_powerpc.c 
Log Message:
svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan at svgalib.org>) and some reordering/cleanup (part #1 ;)

Index: AsmMacros_x86.h
===================================================================
RCS file: /cvsroot/mplayer/main/libdha/sysdep/AsmMacros_x86.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- AsmMacros_x86.h	2 Feb 2002 07:05:52 -0000	1.2
+++ AsmMacros_x86.h	20 Dec 2002 21:07:27 -0000	1.3
@@ -21,8 +21,81 @@
 extern int dhahelper_initialized;
 #endif
 
+#ifdef CONFIG_SVGAHELPER
+#include <sys/ioctl.h>
+#include <svgalib_helper.h>
+
+extern int svgahelper_fd;
+extern int svgahelper_initialized;
+
+static __inline__ void svga_outb(short port, char value)
+{
+    io_t iov;
+    
+    iov.val = value;
+    iov.port = port;
+    ioctl(svgahelper_fd, SVGALIB_HELPER_IOCSOUTB, &iov);
+}
+
+static __inline__ void svga_outw(short port, char value)
+{
+    io_t iov;
+    
+    iov.val = value;
+    iov.port = port;
+    ioctl(svgahelper_fd, SVGALIB_HELPER_IOCSOUTW, &iov);
+}
+
+static __inline__ void svga_outl(short port, unsigned int value)
+{
+    io_t iov;
+    
+    iov.val = value;
+    iov.port = port;
+    ioctl(svgahelper_fd, SVGALIB_HELPER_IOCSOUTL, &iov);
+}
+
+static __inline__ unsigned int svga_inb(short port)
+{
+    io_t iov;
+    
+    iov.port = port;
+    ioctl(svgahelper_fd, SVGALIB_HELPER_IOCGINB, &iov);
+    
+    return iov.val;
+}
+
+static __inline__ unsigned int svga_inw(short port)
+{
+    io_t iov;
+    
+    iov.port = port;
+    ioctl(svgahelper_fd, SVGALIB_HELPER_IOCGINW, &iov);
+    
+    return iov.val;
+}
+
+static __inline__ unsigned int svga_inl(short port)
+{
+    io_t iov;
+    
+    iov.port = port;
+    ioctl(svgahelper_fd, SVGALIB_HELPER_IOCGINL, &iov);
+    
+    return iov.val;
+}
+#endif /* CONIFG_SVGAHELPER */
+
 static __inline__ void outb(short port,char val)
 {
+#ifdef CONFIG_SVGAHELPER
+    if (svgahelper_initialized == 1)
+    {
+	svga_outb(port, val);
+	return;
+    }
+#endif
+
 #ifdef CONFIG_DHAHELPER
     if (dhahelper_initialized == 1)
     {
@@ -43,6 +116,14 @@
 
 static __inline__ void outw(short port,short val)
 {
+#ifdef CONFIG_SVGAHELPER
+    if (svgahelper_initialized == 1)
+    {
+	svga_outw(port, val);
+	return;
+    }
+#endif
+
 #ifdef CONFIG_DHAHELPER
     if (dhahelper_initialized == 1)
     {
@@ -63,6 +144,14 @@
 
 static __inline__ void outl(short port,unsigned int val)
 {
+#ifdef CONFIG_SVGAHELPER
+    if (svgahelper_initialized == 1)
+    {
+	svga_outl(port, val);
+	return;
+    }
+#endif
+
 #ifdef CONFIG_DHAHELPER
     if (dhahelper_initialized == 1)
     {
@@ -83,7 +172,15 @@
 
 static __inline__ unsigned int inb(short port)
 {
-   unsigned char ret;
+   unsigned char ret = 0;
+
+#ifdef CONFIG_SVGAHELPER
+    if (svgahelper_initialized == 1)
+    {
+	return svga_inb(port);
+    }
+#endif
+
 #ifdef CONFIG_DHAHELPER
     if (dhahelper_initialized == 1)
     {
@@ -105,7 +202,15 @@
 
 static __inline__ unsigned int inw(short port)
 {
-   unsigned short ret;
+   unsigned short ret = 0;
+
+#ifdef CONFIG_SVGAHELPER
+    if (svgahelper_initialized == 1)
+    {
+	return svga_inw(port);
+    }
+#endif
+
 #ifdef CONFIG_DHAHELPER
     if (dhahelper_initialized == 1)
     {
@@ -127,7 +232,15 @@
 
 static __inline__ unsigned int inl(short port)
 {
-   unsigned int ret;
+   unsigned int ret = 0;
+
+#ifdef CONFIG_SVGAHELPER
+    if (svgahelper_initialized == 1)
+    {
+	return svga_inl(port);
+    }
+#endif
+
 #ifdef CONFIG_DHAHELPER
     if (dhahelper_initialized == 1)
     {
@@ -149,11 +262,19 @@
 
 static __inline__ void intr_disable()
 {
+#ifdef CONFIG_SVGAHELPER
+    if (svgahelper_initialized == 1)
+	return;
+#endif
   __asm__ __volatile__("cli");
 }
 
 static __inline__ void intr_enable()
 {
+#ifdef CONFIG_SVGAHELPER
+    if (svgahelper_initialized == 1)
+	return;
+#endif
   __asm__ __volatile__("sti");
 }
 

Index: pci_linux.c
===================================================================
RCS file: /cvsroot/mplayer/main/libdha/sysdep/pci_linux.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- pci_linux.c	15 Dec 2002 18:22:16 -0000	1.6
+++ pci_linux.c	20 Dec 2002 21:07:27 -0000	1.7
@@ -20,8 +20,59 @@
 int dhahelper_fd = 0;
 #endif
 
+#ifdef CONFIG_SVGAHELPER
+#include <svgalib_helper.h>
+#ifdef __linux__
+#include <linux/ioctl.h>
+#endif
+#include <fcntl.h>
+int svgahelper_initialized = 0;
+int svgahelper_fd = 0;
+
+static int pci_config_type(void)
+{
+    return 1;
+}
+
+static long pci_config_read_long(
+          unsigned char bus,
+          unsigned char dev,
+          int func, 
+          unsigned cmd)
+{
+    unsigned long config_cmd;
+    pcic_t p;
+    
+    p.address = cmd;
+    p.pcipos = (bus << 8) | dev | (func << 5);
+    
+    if (ioctl(svgahelper_fd, SVGALIB_HELPER_IOCGPCIINL, &p))
+	return -1;
+
+    return p.val;
+}
+
+static int pci_get_vendor(
+          unsigned char bus,
+          unsigned char dev,
+          int func)
+{
+    return pci_config_read_long(bus, dev, func, 0);
+}
+#endif
+
 static __inline__ int enable_os_io(void)
 {
+#ifdef CONFIG_SVGAHELPER
+    svgahelper_fd = open(DEV_SVGA, O_RDWR);
+    if (svgahelper_fd > 0)
+    {
+	svgahelper_initialized = 1;
+	return(0);
+    }
+    svgahelper_initialized = -1;
+#endif
+
 #ifdef CONFIG_DHAHELPER
     dhahelper_fd = open("/dev/dhahelper", O_RDWR);
     if (dhahelper_fd > 0)
@@ -43,6 +94,11 @@
 
 static __inline__ int disable_os_io(void)
 {
+#ifdef CONFIG_SVGAHELPER
+    if (svgahelper_initialized == 1)
+	close(svgahelper_fd);
+    else
+#endif
 #ifdef CONFIG_DHAHELPER
     if (dhahelper_initialized == 1)
 	close(dhahelper_fd);
@@ -56,3 +112,74 @@
 #endif    
     return(0);
 }
+
+#if (defined(__powerpc__) || defined(__sparc__) || defined(__sparc64__)) \
+    && defined(__linux__) && !defined(CONFIG_SVGAHELPER)
+#define CONFIG_PCI_LINUX_PROC
+#endif
+
+#if defined(CONFIG_PCI_LINUX_PROC)
+static int pci_config_type( void ) { return 1; }
+
+/* pci operations for (powerpc) Linux 
+   questions, suggestions etc: 
+   mplayer-dev-eng at mplayerhq.hu, colin at colino.net*/
+#include <fcntl.h>
+//#include <sys/io.h>
+#include <linux/pci.h>
+#include "../../bswap.h"
+
+static int pci_get_vendor(
+          unsigned char bus,
+          unsigned char dev,
+          int func)
+{
+    int retval;
+    char path[100];
+    int fd;
+    short vendor, device;
+    sprintf(path,"/proc/bus/pci/%02d/%02x.0", bus, dev);
+    fd = open(path,O_RDONLY|O_SYNC);
+    if (fd == -1) {
+	    retval=0xFFFF;
+    }
+    else if (pread(fd, &vendor, 2, PCI_VENDOR_ID) == 2 &&
+             pread(fd, &device, 2, PCI_DEVICE_ID) == 2) {
+	    vendor = le2me_16(vendor);
+	    device = le2me_16(device);
+	    retval = vendor + (device<<16); /*no worries about byte order, 
+	    				      all ppc are bigendian*/
+    } else {
+	    retval = 0xFFFF;
+    }   
+    if (fd > 0) {
+	    close(fd);
+    }
+    return retval;
+}
+
+static long pci_config_read_long(
+          unsigned char bus,
+          unsigned char dev,
+          int func, 
+          unsigned cmd)
+{
+    long retval;
+    char path[100];
+    int fd;
+    sprintf(path,"/proc/bus/pci/%02d/%02x.0", bus, dev);
+    fd = open(path,O_RDONLY|O_SYNC);
+    if (fd == -1) {
+	    retval=0;
+    }
+    else if (pread(fd, &retval, 4, cmd) == 4) {
+	    retval = le2me_32(retval);
+    } else {
+	    retval = 0;
+    }   
+    if (fd > 0) {
+	    close(fd);
+    }
+    return retval;
+}
+#endif

Index: pci_powerpc.c
===================================================================
RCS file: /cvsroot/mplayer/main/libdha/sysdep/pci_powerpc.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- pci_powerpc.c	15 Dec 2002 18:22:16 -0000	1.3
+++ pci_powerpc.c	20 Dec 2002 21:07:27 -0000	1.4
@@ -4,72 +4,8 @@
    Modified for readability by Nick Kurshev
 */
 
+#if defined(Lynx) || defined(__OpenBSD__)
 static int pci_config_type( void ) { return 1; }
-
-#if defined(__powerpc__) && defined(__linux__)
-/* pci operations for powerpc Linux 
-   questions, suggestions etc: 
-   mplayer-dev-eng at mplayerhq.hu, colin at colino.net*/
-#include <fcntl.h>
-//#include <sys/io.h>
-#include <linux/pci.h>
-#include "../../bswap.h"
-
-static int pci_get_vendor(
-          unsigned char bus,
-          unsigned char dev,
-          int func)
-{
-    int retval;
-    char path[100];
-    int fd;
-    short vendor, device;
-    sprintf(path,"/proc/bus/pci/%02d/%02x.0", bus, dev);
-    fd = open(path,O_RDONLY|O_SYNC);
-    if (fd == -1) {
-	    retval=0xFFFF;
-    }
-    else if (pread(fd, &vendor, 2, PCI_VENDOR_ID) == 2 &&
-             pread(fd, &device, 2, PCI_DEVICE_ID) == 2) {
-	    vendor = bswap_16(vendor);
-	    device = bswap_16(device);
-	    retval = vendor + (device<<16); /*no worries about byte order, 
-	    				      all ppc are bigendian*/
-    } else {
-	    retval = 0xFFFF;
-    }   
-    if (fd > 0) {
-	    close(fd);
-    }
-    return retval;
-}
-
-static long pci_config_read_long(
-          unsigned char bus,
-          unsigned char dev,
-          int func, 
-          unsigned cmd)
-{
-    long retval;
-    char path[100];
-    int fd;
-    sprintf(path,"/proc/bus/pci/%02d/%02x.0", bus, dev);
-    fd = open(path,O_RDONLY|O_SYNC);
-    if (fd == -1) {
-	    retval=0;
-    }
-    else if (pread(fd, &retval, 4, cmd) == 4) {
-	    retval = bswap_32(retval);
-    } else {
-	    retval = 0;
-    }   
-    if (fd > 0) {
-	    close(fd);
-    }
-    return retval;
-}
-
-#else /*Lynx/OpenBSD*/
 
 static int pci_get_vendor(
           unsigned char bus,




More information about the MPlayer-cvslog mailing list