Mercurial > mplayer.hg
annotate libdha/libdha.c @ 5304:6175c9cfab11
Support for decoder specific config from mp4 header for AAC decoder.
author | atmos4 |
---|---|
date | Sun, 24 Mar 2002 03:08:20 +0000 |
parents | b782efa10c60 |
children | 567de708ab3a |
rev | line source |
---|---|
3973 | 1 /* |
2 libgha.c - Library for direct hardware access | |
3 Copyrights: | |
4 1996/10/27 - Robin Cutshaw (robin@xfree86.org) | |
5 XFree86 3.3.3 implementation | |
6 1999 - Øyvind Aabling. | |
7 Modified for GATOS/win/gfxdump. | |
8 | |
9 2002 - library implementation by Nick Kurshev | |
4474 | 10 - dhahelper and some changes by Alex Beregszaszi |
3973 | 11 |
12 supported O/S's: SVR4, UnixWare, SCO, Solaris, | |
13 FreeBSD, NetBSD, 386BSD, BSDI BSD/386, | |
14 Linux, Mach/386, ISC | |
15 DOS (WATCOM 9.5 compiler), Win9x (with mapdev.vxd) | |
16 Licence: GPL | |
17 Original location: www.linuxvideo.org/gatos | |
18 */ | |
19 | |
4474 | 20 #include "config.h" |
21 | |
3973 | 22 #include "libdha.h" |
23 #include "AsmMacros.h" | |
24 #include <stdio.h> | |
25 #include <stdlib.h> | |
26 #include <string.h> | |
27 #include <fcntl.h> | |
28 #include <sys/stat.h> | |
29 #include <sys/types.h> | |
30 #include <unistd.h> | |
31 | |
4174
4cfb6b9a6da3
api changed: enable/disable_os_io returns error-code (or zero if ok) and pciconfig_read exported for mga_vid
alex
parents:
4164
diff
changeset
|
32 /* instead exit() use libdha_exit, and do the 'mother-application' deinit |
4cfb6b9a6da3
api changed: enable/disable_os_io returns error-code (or zero if ok) and pciconfig_read exported for mga_vid
alex
parents:
4164
diff
changeset
|
33 only in this code */ |
4cfb6b9a6da3
api changed: enable/disable_os_io returns error-code (or zero if ok) and pciconfig_read exported for mga_vid
alex
parents:
4164
diff
changeset
|
34 void libdha_exit(const char *message, int level) |
4cfb6b9a6da3
api changed: enable/disable_os_io returns error-code (or zero if ok) and pciconfig_read exported for mga_vid
alex
parents:
4164
diff
changeset
|
35 { |
4cfb6b9a6da3
api changed: enable/disable_os_io returns error-code (or zero if ok) and pciconfig_read exported for mga_vid
alex
parents:
4164
diff
changeset
|
36 printf("libdha: FATAL: %s\n", message); |
4cfb6b9a6da3
api changed: enable/disable_os_io returns error-code (or zero if ok) and pciconfig_read exported for mga_vid
alex
parents:
4164
diff
changeset
|
37 exit(level); /* FIXME */ |
4cfb6b9a6da3
api changed: enable/disable_os_io returns error-code (or zero if ok) and pciconfig_read exported for mga_vid
alex
parents:
4164
diff
changeset
|
38 } |
4cfb6b9a6da3
api changed: enable/disable_os_io returns error-code (or zero if ok) and pciconfig_read exported for mga_vid
alex
parents:
4164
diff
changeset
|
39 |
4164 | 40 #if defined(_WIN32) |
41 #include "sysdep/libdha_win32.c" | |
42 #elif defined (__EMX__) | |
43 #include "sysdep/libdha_os2.c" | |
44 #else | |
3973 | 45 |
4164 | 46 #if defined(SVR4) || defined(SCO325) |
47 # if !(defined(sun) && defined (i386) && defined (SVR4)) | |
48 # define DEV_MEM "/dev/pmem" | |
49 # elif defined(PowerMAX_OS) | |
50 # define DEV_MEM "/dev/iomem" | |
51 # endif | |
52 # ifdef SCO325 | |
53 # undef DEV_MEM | |
54 # define DEV_MEM "/dev/mem" | |
55 # endif | |
56 # endif /* SVR4 */ | |
3973 | 57 |
4164 | 58 /* Generic version */ |
59 #include <sys/mman.h> | |
3973 | 60 |
4164 | 61 #ifndef DEV_MEM |
62 #define DEV_MEM "/dev/mem" | |
63 #endif | |
3973 | 64 |
4474 | 65 #ifdef CONFIG_DHAHELPER |
4938 | 66 |
67 #include "kernelhelper/dhahelper.h" | |
68 | |
3973 | 69 static int mem=-1; |
70 void *map_phys_mem(unsigned base, unsigned size) | |
71 { | |
4474 | 72 if ( (mem = open("/dev/dhahelper",O_RDWR)) < 0) |
73 { | |
74 if ( (mem = open(DEV_MEM,O_RDWR)) == -1) { | |
75 perror("libdha: open(/dev/mem) failed") ; exit(1) ; | |
76 } | |
77 } | |
78 else | |
79 { | |
80 dhahelper_memory_t mem_req; | |
81 | |
82 mem_req.operation = MEMORY_OP_MAP; | |
83 mem_req.start = base; | |
84 mem_req.offset = 0; | |
85 mem_req.size = size; | |
86 | |
87 if (ioctl(mem, DHAHELPER_MEMORY, &mem_req) < 0) | |
88 { | |
89 perror("libdha: failed mapping throught kernel helper"); | |
90 return NULL; | |
91 } | |
92 } | |
93 return mmap(0,size,PROT_READ|PROT_WRITE,MAP_SHARED,mem,base) ; | |
94 } | |
95 #else | |
96 | |
97 static int mem=-1; | |
98 void *map_phys_mem(unsigned base, unsigned size) | |
99 { | |
4164 | 100 if ( (mem = open(DEV_MEM,O_RDWR)) == -1) { |
3973 | 101 perror("libdha: open(/dev/mem) failed") ; exit(1) ; |
102 } | |
4164 | 103 return mmap(0,size,PROT_READ|PROT_WRITE,MAP_SHARED,mem,base) ; |
3973 | 104 } |
4474 | 105 #endif /* CONFIG_DHAHELPER */ |
3973 | 106 |
107 void unmap_phys_mem(void *ptr, unsigned size) | |
108 { | |
109 int res=munmap(ptr,size) ; | |
110 if (res == -1) { perror("libdha: munmap() failed") ; exit(1) ; } | |
111 close(mem); | |
112 } | |
113 #endif | |
114 | |
3995 | 115 unsigned char INPORT8(unsigned idx) |
3973 | 116 { |
117 return inb(idx); | |
118 } | |
119 | |
3995 | 120 unsigned short INPORT16(unsigned idx) |
3973 | 121 { |
122 return inw(idx); | |
123 } | |
124 | |
3995 | 125 unsigned INPORT32(unsigned idx) |
3973 | 126 { |
127 return inl(idx); | |
128 } | |
129 | |
3995 | 130 void OUTPORT8(unsigned idx,unsigned char val) |
3973 | 131 { |
132 outb(idx,val); | |
133 } | |
134 | |
3995 | 135 void OUTPORT16(unsigned idx,unsigned short val) |
3973 | 136 { |
137 outw(idx,val); | |
138 } | |
139 | |
3995 | 140 void OUTPORT32(unsigned idx,unsigned val) |
3973 | 141 { |
142 outl(idx,val); | |
143 } | |
4174
4cfb6b9a6da3
api changed: enable/disable_os_io returns error-code (or zero if ok) and pciconfig_read exported for mga_vid
alex
parents:
4164
diff
changeset
|
144 |