diff options
author | alex <alex@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2002-12-20 21:07:27 +0000 |
---|---|---|
committer | alex <alex@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2002-12-20 21:07:27 +0000 |
commit | 6429f7e4fd55a230f471a4f1c12387db793a71dd (patch) | |
tree | 16ba159231ad1bae6e9c8583f94d8436354d65b2 /libdha/sysdep/pci_linux.c | |
parent | a75ffd19d6f674d0f05f8fc5e1763a47343c929f (diff) | |
download | mpv-6429f7e4fd55a230f471a4f1c12387db793a71dd.tar.bz2 mpv-6429f7e4fd55a230f471a4f1c12387db793a71dd.tar.xz |
svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@8504 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libdha/sysdep/pci_linux.c')
-rw-r--r-- | libdha/sysdep/pci_linux.c | 127 |
1 files changed, 127 insertions, 0 deletions
diff --git a/libdha/sysdep/pci_linux.c b/libdha/sysdep/pci_linux.c index e53ae20721..ad9715b2d8 100644 --- a/libdha/sysdep/pci_linux.c +++ b/libdha/sysdep/pci_linux.c @@ -20,8 +20,59 @@ int dhahelper_initialized = 0; 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 enable_os_io(void) 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 @@ static __inline__ int disable_os_io(void) #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@mplayerhq.hu, colin@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 |