# HG changeset patch # User ben # Date 1175873201 0 # Node ID a7605669b114991ce512b2d40960c5296fd34be8 # Parent a9e111b88c4a78b37233fa7d2a1cf5aac086eb01 renamed libdha.[hc] to dha.[hc] diff -r a9e111b88c4a -r a7605669b114 vidix/Makefile --- a/vidix/Makefile Fri Apr 06 15:20:49 2007 +0000 +++ b/vidix/Makefile Fri Apr 06 15:26:41 2007 +0000 @@ -3,7 +3,7 @@ LIBNAME_MPLAYER = libvidix.a SRCS_MPLAYER = vidixlib.c \ - libdha.c \ + dha.c \ mtrr.c \ pci.c \ pci_names.c \ diff -r a9e111b88c4a -r a7605669b114 vidix/cyberblade_vid.c --- a/vidix/cyberblade_vid.c Fri Apr 06 15:20:49 2007 +0000 +++ b/vidix/cyberblade_vid.c Fri Apr 06 15:26:41 2007 +0000 @@ -46,7 +46,7 @@ #include "vidix.h" #include "vidixlib.h" #include "fourcc.h" -#include "libdha.h" +#include "dha.h" #include "pci_ids.h" #include "pci_names.h" #include "../config.h" diff -r a9e111b88c4a -r a7605669b114 vidix/dha.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vidix/dha.c Fri Apr 06 15:26:41 2007 +0000 @@ -0,0 +1,196 @@ +/* + libgha.c - Library for direct hardware access + Copyrights: + 1996/10/27 - Robin Cutshaw (robin@xfree86.org) + XFree86 3.3.3 implementation + 1999 - Øyvind Aabling. + Modified for GATOS/win/gfxdump. + + 2002 - library implementation by Nick Kurshev + - dhahelper and some changes by Alex Beregszaszi + + supported O/S's: SVR4, UnixWare, SCO, Solaris, + FreeBSD, NetBSD, 386BSD, BSDI BSD/386, + Linux, Mach/386, ISC + DOS (WATCOM 9.5 compiler), Win9x (with mapdev.vxd) + Licence: GPL + Original location: www.linuxvideo.org/gatos +*/ + +#include "config.h" + +#include "dha.h" +#include "AsmMacros.h" +#include +#include +#include +#include +#include +#include +#ifdef ARCH_ALPHA +#include +#endif +#include + +#if defined(WIN32) +#include "sysdep/libdha_win32.c" +#elif defined (__EMX__) +#include "sysdep/libdha_os2.c" +#else + +#if defined(SVR4) || defined(SCO325) +# if !(defined(sun) && defined (i386) && defined (SVR4)) +# define DEV_MEM "/dev/pmem" +# elif defined(PowerMAX_OS) +# define DEV_MEM "/dev/iomem" +# endif +# ifdef SCO325 +# undef DEV_MEM +# define DEV_MEM "/dev/mem" +# endif +#elif defined(sun) && defined (i386) +#define DEV_MEM "/dev/xsvc" +# endif /* SVR4 */ + +#if defined(__OpenBSD__) +#define DEV_APERTURE "/dev/xf86" +#endif + +/* Generic version */ +#include + +#ifndef DEV_MEM +#define DEV_MEM "/dev/mem" +#endif + +#ifdef CONFIG_DHAHELPER +#include "kernelhelper/dhahelper.h" +#endif + +#ifdef CONFIG_SVGAHELPER +#include +#endif + +static int mem_fd = -1; + +void *map_phys_mem(unsigned long base, unsigned long size) +{ +#ifdef ARCH_ALPHA +/* TODO: move it into sysdep */ + base += bus_base(); +#endif + +#ifdef CONFIG_SVGAHELPER + if ( (mem_fd = open(DEV_SVGA,O_RDWR)) == -1) { + perror("libdha: SVGAlib kernelhelper failed"); +#ifdef CONFIG_DHAHELPER + goto dha_helper_way; +#else + goto dev_mem_way; +#endif + } + else + goto mmap; +#endif + +#ifdef CONFIG_DHAHELPER +#ifdef CONFIG_SVGAHELPER +dha_helper_way: +#endif + if ( (mem_fd = open("/dev/dhahelper",O_RDWR)) < 0) + { + perror("libdha: DHA kernelhelper failed"); + goto dev_mem_way; + } + else + { + dhahelper_memory_t mem_req; + + mem_req.operation = MEMORY_OP_MAP; + mem_req.start = base; + mem_req.offset = 0; + mem_req.size = size; + + if (ioctl(mem_fd, DHAHELPER_MEMORY, &mem_req) < 0) + { + perror("libdha: DHA kernelhelper failed"); + close(mem_fd); + goto dev_mem_way; + } + else + goto mmap; + } +#endif + +dev_mem_way: +#ifdef DEV_APERTURE + if ((mem_fd = open(DEV_APERTURE, O_RDWR)) == -1) + perror("libdha: opening aperture failed"); + else { + void *p = mmap(0,size,PROT_READ|PROT_WRITE,MAP_SHARED,mem_fd,base); + + if (p == MAP_FAILED) { + perror("libdha: mapping aperture failed"); + close(mem_fd); + } else + return p; + } +#endif + + if ( (mem_fd = open(DEV_MEM,O_RDWR)) == -1) + { + perror("libdha: opening /dev/mem failed"); + return MAP_FAILED; + } + +mmap: + return mmap(0,size,PROT_READ|PROT_WRITE,MAP_SHARED,mem_fd,base); +} + +void unmap_phys_mem(void *ptr, unsigned long size) +{ + int res = munmap(ptr,size); + + if (res == (int)MAP_FAILED) + { + perror("libdha: unmapping memory failed"); + return; + } + + close(mem_fd); + mem_fd = -1; + + return; +} + +#endif /* Generic mmap (not win32, nor os2) */ + +unsigned char INPORT8(unsigned idx) +{ + return inb(idx); +} + +unsigned short INPORT16(unsigned idx) +{ + return inw(idx); +} + +unsigned INPORT32(unsigned idx) +{ + return inl(idx); +} + +void OUTPORT8(unsigned idx,unsigned char val) +{ + outb(idx,val); +} + +void OUTPORT16(unsigned idx,unsigned short val) +{ + outw(idx,val); +} + +void OUTPORT32(unsigned idx,unsigned val) +{ + outl(idx,val); +} diff -r a9e111b88c4a -r a7605669b114 vidix/dha.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vidix/dha.h Fri Apr 06 15:26:41 2007 +0000 @@ -0,0 +1,75 @@ +/* + libgha.h - Library for direct hardware access + Copyrights: + 1996/10/27 - Robin Cutshaw (robin@xfree86.org) + XFree86 3.3.3 implementation + 1999 - Øyvind Aabling. + Modified for GATOS/win/gfxdump. + 2002 - library implementation by Nick Kurshev + + supported O/S's: SVR4, UnixWare, SCO, Solaris, + FreeBSD, NetBSD, 386BSD, BSDI BSD/386, + Linux, Mach/386, ISC + DOS (WATCOM 9.5 compiler), Win9x (with mapdev.vxd) + Licence: GPL +*/ +#ifndef LIBDHA_H +#define LIBDHA_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define MAX_DEV_PER_VENDOR_CFG1 64 +#define MAX_PCI_DEVICES_PER_BUS 32 +#define MAX_PCI_DEVICES 64 +#define PCI_MULTIFUNC_DEV 0x80 +#define PCI_COMMAND_IO 0x1 /* Enable response to I/O space */ + +typedef struct pciinfo_s +{ + int bus,card,func; /* PCI/AGP bus:card:func */ + unsigned short command; /* Device control register */ + unsigned short vendor,device; /* Card vendor+device ID */ + unsigned base0,base1,base2,baserom; /* Memory and I/O base addresses */ +// unsigned base0_limit, base1_limit, base2_limit, baserom_limit; +}pciinfo_t; + +/* needed for mga_vid */ +extern int pci_config_read(unsigned char bus, unsigned char dev, unsigned char func, + unsigned char cmd, int len, unsigned long *val); + /* Fill array pci_list which must have size MAX_PCI_DEVICES + and return 0 if sucessful */ +extern int pci_scan(pciinfo_t *pci_list,unsigned *num_card); + + + /* Enables/disables accessing to IO space from application side. + Should return 0 if o'k or errno on error. */ +extern int enable_app_io( void ); +extern int disable_app_io( void ); + +extern unsigned char INPORT8(unsigned idx); +extern unsigned short INPORT16(unsigned idx); +extern unsigned INPORT32(unsigned idx); +#define INPORT(idx) INPORT32(idx) +extern void OUTPORT8(unsigned idx,unsigned char val); +extern void OUTPORT16(unsigned idx,unsigned short val); +extern void OUTPORT32(unsigned idx,unsigned val); +#define OUTPORT(idx,val) OUTPORT32(idx,val) + +extern void * map_phys_mem(unsigned long base, unsigned long size); +extern void unmap_phys_mem(void *ptr, unsigned long size); + +/* These are the region types */ +#define MTRR_TYPE_UNCACHABLE 0 +#define MTRR_TYPE_WRCOMB 1 +#define MTRR_TYPE_WRTHROUGH 4 +#define MTRR_TYPE_WRPROT 5 +#define MTRR_TYPE_WRBACK 6 +extern int mtrr_set_type(unsigned base,unsigned size,int type); + +#ifdef __cplusplus +} +#endif + +#endif diff -r a9e111b88c4a -r a7605669b114 vidix/libdha.c --- a/vidix/libdha.c Fri Apr 06 15:20:49 2007 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,196 +0,0 @@ -/* - libgha.c - Library for direct hardware access - Copyrights: - 1996/10/27 - Robin Cutshaw (robin@xfree86.org) - XFree86 3.3.3 implementation - 1999 - Øyvind Aabling. - Modified for GATOS/win/gfxdump. - - 2002 - library implementation by Nick Kurshev - - dhahelper and some changes by Alex Beregszaszi - - supported O/S's: SVR4, UnixWare, SCO, Solaris, - FreeBSD, NetBSD, 386BSD, BSDI BSD/386, - Linux, Mach/386, ISC - DOS (WATCOM 9.5 compiler), Win9x (with mapdev.vxd) - Licence: GPL - Original location: www.linuxvideo.org/gatos -*/ - -#include "config.h" - -#include "libdha.h" -#include "AsmMacros.h" -#include -#include -#include -#include -#include -#include -#ifdef ARCH_ALPHA -#include -#endif -#include - -#if defined(WIN32) -#include "sysdep/libdha_win32.c" -#elif defined (__EMX__) -#include "sysdep/libdha_os2.c" -#else - -#if defined(SVR4) || defined(SCO325) -# if !(defined(sun) && defined (i386) && defined (SVR4)) -# define DEV_MEM "/dev/pmem" -# elif defined(PowerMAX_OS) -# define DEV_MEM "/dev/iomem" -# endif -# ifdef SCO325 -# undef DEV_MEM -# define DEV_MEM "/dev/mem" -# endif -#elif defined(sun) && defined (i386) -#define DEV_MEM "/dev/xsvc" -# endif /* SVR4 */ - -#if defined(__OpenBSD__) -#define DEV_APERTURE "/dev/xf86" -#endif - -/* Generic version */ -#include - -#ifndef DEV_MEM -#define DEV_MEM "/dev/mem" -#endif - -#ifdef CONFIG_DHAHELPER -#include "kernelhelper/dhahelper.h" -#endif - -#ifdef CONFIG_SVGAHELPER -#include -#endif - -static int mem_fd = -1; - -void *map_phys_mem(unsigned long base, unsigned long size) -{ -#ifdef ARCH_ALPHA -/* TODO: move it into sysdep */ - base += bus_base(); -#endif - -#ifdef CONFIG_SVGAHELPER - if ( (mem_fd = open(DEV_SVGA,O_RDWR)) == -1) { - perror("libdha: SVGAlib kernelhelper failed"); -#ifdef CONFIG_DHAHELPER - goto dha_helper_way; -#else - goto dev_mem_way; -#endif - } - else - goto mmap; -#endif - -#ifdef CONFIG_DHAHELPER -#ifdef CONFIG_SVGAHELPER -dha_helper_way: -#endif - if ( (mem_fd = open("/dev/dhahelper",O_RDWR)) < 0) - { - perror("libdha: DHA kernelhelper failed"); - goto dev_mem_way; - } - else - { - dhahelper_memory_t mem_req; - - mem_req.operation = MEMORY_OP_MAP; - mem_req.start = base; - mem_req.offset = 0; - mem_req.size = size; - - if (ioctl(mem_fd, DHAHELPER_MEMORY, &mem_req) < 0) - { - perror("libdha: DHA kernelhelper failed"); - close(mem_fd); - goto dev_mem_way; - } - else - goto mmap; - } -#endif - -dev_mem_way: -#ifdef DEV_APERTURE - if ((mem_fd = open(DEV_APERTURE, O_RDWR)) == -1) - perror("libdha: opening aperture failed"); - else { - void *p = mmap(0,size,PROT_READ|PROT_WRITE,MAP_SHARED,mem_fd,base); - - if (p == MAP_FAILED) { - perror("libdha: mapping aperture failed"); - close(mem_fd); - } else - return p; - } -#endif - - if ( (mem_fd = open(DEV_MEM,O_RDWR)) == -1) - { - perror("libdha: opening /dev/mem failed"); - return MAP_FAILED; - } - -mmap: - return mmap(0,size,PROT_READ|PROT_WRITE,MAP_SHARED,mem_fd,base); -} - -void unmap_phys_mem(void *ptr, unsigned long size) -{ - int res = munmap(ptr,size); - - if (res == (int)MAP_FAILED) - { - perror("libdha: unmapping memory failed"); - return; - } - - close(mem_fd); - mem_fd = -1; - - return; -} - -#endif /* Generic mmap (not win32, nor os2) */ - -unsigned char INPORT8(unsigned idx) -{ - return inb(idx); -} - -unsigned short INPORT16(unsigned idx) -{ - return inw(idx); -} - -unsigned INPORT32(unsigned idx) -{ - return inl(idx); -} - -void OUTPORT8(unsigned idx,unsigned char val) -{ - outb(idx,val); -} - -void OUTPORT16(unsigned idx,unsigned short val) -{ - outw(idx,val); -} - -void OUTPORT32(unsigned idx,unsigned val) -{ - outl(idx,val); -} diff -r a9e111b88c4a -r a7605669b114 vidix/libdha.h --- a/vidix/libdha.h Fri Apr 06 15:20:49 2007 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,75 +0,0 @@ -/* - libgha.h - Library for direct hardware access - Copyrights: - 1996/10/27 - Robin Cutshaw (robin@xfree86.org) - XFree86 3.3.3 implementation - 1999 - Øyvind Aabling. - Modified for GATOS/win/gfxdump. - 2002 - library implementation by Nick Kurshev - - supported O/S's: SVR4, UnixWare, SCO, Solaris, - FreeBSD, NetBSD, 386BSD, BSDI BSD/386, - Linux, Mach/386, ISC - DOS (WATCOM 9.5 compiler), Win9x (with mapdev.vxd) - Licence: GPL -*/ -#ifndef LIBDHA_H -#define LIBDHA_H - -#ifdef __cplusplus -extern "C" { -#endif - -#define MAX_DEV_PER_VENDOR_CFG1 64 -#define MAX_PCI_DEVICES_PER_BUS 32 -#define MAX_PCI_DEVICES 64 -#define PCI_MULTIFUNC_DEV 0x80 -#define PCI_COMMAND_IO 0x1 /* Enable response to I/O space */ - -typedef struct pciinfo_s -{ - int bus,card,func; /* PCI/AGP bus:card:func */ - unsigned short command; /* Device control register */ - unsigned short vendor,device; /* Card vendor+device ID */ - unsigned base0,base1,base2,baserom; /* Memory and I/O base addresses */ -// unsigned base0_limit, base1_limit, base2_limit, baserom_limit; -}pciinfo_t; - -/* needed for mga_vid */ -extern int pci_config_read(unsigned char bus, unsigned char dev, unsigned char func, - unsigned char cmd, int len, unsigned long *val); - /* Fill array pci_list which must have size MAX_PCI_DEVICES - and return 0 if sucessful */ -extern int pci_scan(pciinfo_t *pci_list,unsigned *num_card); - - - /* Enables/disables accessing to IO space from application side. - Should return 0 if o'k or errno on error. */ -extern int enable_app_io( void ); -extern int disable_app_io( void ); - -extern unsigned char INPORT8(unsigned idx); -extern unsigned short INPORT16(unsigned idx); -extern unsigned INPORT32(unsigned idx); -#define INPORT(idx) INPORT32(idx) -extern void OUTPORT8(unsigned idx,unsigned char val); -extern void OUTPORT16(unsigned idx,unsigned short val); -extern void OUTPORT32(unsigned idx,unsigned val); -#define OUTPORT(idx,val) OUTPORT32(idx,val) - -extern void * map_phys_mem(unsigned long base, unsigned long size); -extern void unmap_phys_mem(void *ptr, unsigned long size); - -/* These are the region types */ -#define MTRR_TYPE_UNCACHABLE 0 -#define MTRR_TYPE_WRCOMB 1 -#define MTRR_TYPE_WRTHROUGH 4 -#define MTRR_TYPE_WRPROT 5 -#define MTRR_TYPE_WRBACK 6 -extern int mtrr_set_type(unsigned base,unsigned size,int type); - -#ifdef __cplusplus -} -#endif - -#endif diff -r a9e111b88c4a -r a7605669b114 vidix/mach64_vid.c --- a/vidix/mach64_vid.c Fri Apr 06 15:20:49 2007 +0000 +++ b/vidix/mach64_vid.c Fri Apr 06 15:26:41 2007 +0000 @@ -19,7 +19,7 @@ #include "vidix.h" #include "vidixlib.h" #include "fourcc.h" -#include "libdha.h" +#include "dha.h" #include "pci_ids.h" #include "pci_names.h" diff -r a9e111b88c4a -r a7605669b114 vidix/mga_vid.c --- a/vidix/mga_vid.c Fri Apr 06 15:20:49 2007 +0000 +++ b/vidix/mga_vid.c Fri Apr 06 15:26:41 2007 +0000 @@ -57,7 +57,7 @@ #include "vidix.h" #include "vidixlib.h" #include "fourcc.h" -#include "libdha.h" +#include "dha.h" #include "pci_ids.h" #include "pci_names.h" diff -r a9e111b88c4a -r a7605669b114 vidix/mtrr.c --- a/vidix/mtrr.c Fri Apr 06 15:20:49 2007 +0000 +++ b/vidix/mtrr.c Fri Apr 06 15:26:41 2007 +0000 @@ -10,7 +10,7 @@ #include #include #include -#include "libdha.h" +#include "dha.h" #include "AsmMacros.h" #if defined (__i386__) && defined (__NetBSD__) diff -r a9e111b88c4a -r a7605669b114 vidix/nvidia_vid.c --- a/vidix/nvidia_vid.c Fri Apr 06 15:20:49 2007 +0000 +++ b/vidix/nvidia_vid.c Fri Apr 06 15:26:41 2007 +0000 @@ -21,7 +21,7 @@ #include "vidix.h" #include "vidixlib.h" #include "fourcc.h" -#include "libdha.h" +#include "dha.h" #include "pci_ids.h" #include "pci_names.h" #include "../config.h" diff -r a9e111b88c4a -r a7605669b114 vidix/pci.c --- a/vidix/pci.c Fri Apr 06 15:20:49 2007 +0000 +++ b/vidix/pci.c Fri Apr 06 15:26:41 2007 +0000 @@ -51,7 +51,7 @@ * */ -#include "libdha.h" +#include "dha.h" #include #include #include diff -r a9e111b88c4a -r a7605669b114 vidix/pm3_vid.c --- a/vidix/pm3_vid.c Fri Apr 06 15:20:49 2007 +0000 +++ b/vidix/pm3_vid.c Fri Apr 06 15:26:41 2007 +0000 @@ -28,7 +28,7 @@ #include "vidix.h" #include "vidixlib.h" #include "fourcc.h" -#include "libdha.h" +#include "dha.h" #include "pci_ids.h" #include "pci_names.h" #include "../config.h" diff -r a9e111b88c4a -r a7605669b114 vidix/radeon_vid.c --- a/vidix/radeon_vid.c Fri Apr 06 15:20:49 2007 +0000 +++ b/vidix/radeon_vid.c Fri Apr 06 15:26:41 2007 +0000 @@ -24,7 +24,7 @@ #include "vidix.h" #include "vidixlib.h" #include "fourcc.h" -#include "libdha.h" +#include "dha.h" #include "radeon.h" #ifdef HAVE_X11 diff -r a9e111b88c4a -r a7605669b114 vidix/savage_vid.c --- a/vidix/savage_vid.c Fri Apr 06 15:20:49 2007 +0000 +++ b/vidix/savage_vid.c Fri Apr 06 15:26:41 2007 +0000 @@ -41,7 +41,7 @@ #include "vidix.h" #include "vidixlib.h" #include "fourcc.h" -#include "libdha.h" +#include "dha.h" #include "pci_ids.h" #include "pci_names.h" #include "../config.h" diff -r a9e111b88c4a -r a7605669b114 vidix/sis_bridge.c --- a/vidix/sis_bridge.c Fri Apr 06 15:20:49 2007 +0000 +++ b/vidix/sis_bridge.c Fri Apr 06 15:26:41 2007 +0000 @@ -26,7 +26,7 @@ #include #include -#include "libdha.h" +#include "dha.h" #include "sis_regs.h" #include "sis_defs.h" diff -r a9e111b88c4a -r a7605669b114 vidix/sis_vid.c --- a/vidix/sis_vid.c Fri Apr 06 15:20:49 2007 +0000 +++ b/vidix/sis_vid.c Fri Apr 06 15:26:41 2007 +0000 @@ -33,7 +33,7 @@ #include "vidix.h" #include "vidixlib.h" #include "fourcc.h" -#include "libdha.h" +#include "dha.h" #include "pci_ids.h" #include "pci_names.h" #include "../config.h" diff -r a9e111b88c4a -r a7605669b114 vidix/unichrome_vid.c --- a/vidix/unichrome_vid.c Fri Apr 06 15:20:49 2007 +0000 +++ b/vidix/unichrome_vid.c Fri Apr 06 15:26:41 2007 +0000 @@ -42,7 +42,7 @@ #include "vidix.h" #include "vidixlib.h" #include "fourcc.h" -#include "libdha.h" +#include "dha.h" #include "pci_ids.h" #include "pci_names.h" #include "../config.h"