Mercurial > mplayer.hg
annotate libdha/libdha.c @ 11007:48b7d7aa444d
configure altivec patch by Magnus Damm <damm@opensource.se>
* CC is not checked for Altivec support (see above).
The patch adds checks for FSF-style flags and Darwin-style flags.
The check is performed regardless of the gcc version.
* Disabling of Altivec.
--disable-altivec is broken today if /proc/cpuinfo shows that your cpu
supports altivec. The patch takes care of that.
* "GCC & CPU optimization abilities" always show that it is optimizing
for the cpu configure is running on, it should show the optimization that
is enabled for gcc instead. Cosmetic change only, but confusing as it is
today IMHO.
* Runtime CPU-detection now enables altivec for powerpc.
Now with the patch it should be possible to use --enable-altivec,
--disable-altivec, --enable-runtime-cpudetection regardless of powerpc cpu type.
The configure script handles altivec support in the following order:
1. Altivec is enabled by default if your cpu supports it.
2. --enable-runtime-cpudetection will enable altivec support.
3. If you have forced altivec on/off with --enable-altivec/--disable-altivec, then
your selection will override the previous altivec configuration.
4. If altivec is enabled but the compiler doesn't support it, altivec gets turned off.
author | attila |
---|---|
date | Sat, 04 Oct 2003 23:06:04 +0000 |
parents | e687fa1d55c6 |
children | 841fd0c2f2e3 |
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> | |
5702 | 30 #ifdef ARCH_ALPHA |
31 #include <sys/io.h> | |
32 #endif | |
3973 | 33 #include <unistd.h> |
34 | |
4164 | 35 #if defined(_WIN32) |
36 #include "sysdep/libdha_win32.c" | |
37 #elif defined (__EMX__) | |
38 #include "sysdep/libdha_os2.c" | |
39 #else | |
3973 | 40 |
4164 | 41 #if defined(SVR4) || defined(SCO325) |
42 # if !(defined(sun) && defined (i386) && defined (SVR4)) | |
43 # define DEV_MEM "/dev/pmem" | |
44 # elif defined(PowerMAX_OS) | |
45 # define DEV_MEM "/dev/iomem" | |
46 # endif | |
47 # ifdef SCO325 | |
48 # undef DEV_MEM | |
49 # define DEV_MEM "/dev/mem" | |
50 # endif | |
51 # endif /* SVR4 */ | |
3973 | 52 |
4164 | 53 /* Generic version */ |
54 #include <sys/mman.h> | |
3973 | 55 |
4164 | 56 #ifndef DEV_MEM |
57 #define DEV_MEM "/dev/mem" | |
58 #endif | |
3973 | 59 |
4474 | 60 #ifdef CONFIG_DHAHELPER |
8503
9dbb9c710480
svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents:
5702
diff
changeset
|
61 #include "kernelhelper/dhahelper.h" |
9dbb9c710480
svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents:
5702
diff
changeset
|
62 #endif |
4938 | 63 |
8503
9dbb9c710480
svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents:
5702
diff
changeset
|
64 #ifdef CONFIG_SVGAHELPER |
9dbb9c710480
svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents:
5702
diff
changeset
|
65 #include <svgalib_helper.h> |
9dbb9c710480
svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents:
5702
diff
changeset
|
66 #endif |
4938 | 67 |
9025
ae0507e107b7
cleanup and removal of libdha_exit. forgot to commit this
alex
parents:
8503
diff
changeset
|
68 static int mem_fd = -1; |
ae0507e107b7
cleanup and removal of libdha_exit. forgot to commit this
alex
parents:
8503
diff
changeset
|
69 |
5702 | 70 void *map_phys_mem(unsigned long base, unsigned long size) |
8503
9dbb9c710480
svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents:
5702
diff
changeset
|
71 { |
5702 | 72 #ifdef ARCH_ALPHA |
73 /* TODO: move it into sysdep */ | |
74 base += bus_base(); | |
75 #endif | |
8503
9dbb9c710480
svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents:
5702
diff
changeset
|
76 |
9dbb9c710480
svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents:
5702
diff
changeset
|
77 #ifdef CONFIG_SVGAHELPER |
9025
ae0507e107b7
cleanup and removal of libdha_exit. forgot to commit this
alex
parents:
8503
diff
changeset
|
78 if ( (mem_fd = open(DEV_SVGA,O_RDWR)) == -1) { |
8503
9dbb9c710480
svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents:
5702
diff
changeset
|
79 perror("libdha: SVGAlib kernelhelper failed"); |
9dbb9c710480
svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents:
5702
diff
changeset
|
80 #ifdef CONFIG_DHAHELPER |
9dbb9c710480
svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents:
5702
diff
changeset
|
81 goto dha_helper_way; |
9dbb9c710480
svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents:
5702
diff
changeset
|
82 #else |
9dbb9c710480
svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents:
5702
diff
changeset
|
83 goto dev_mem_way; |
9dbb9c710480
svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents:
5702
diff
changeset
|
84 #endif |
9dbb9c710480
svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents:
5702
diff
changeset
|
85 } |
9dbb9c710480
svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents:
5702
diff
changeset
|
86 else |
9dbb9c710480
svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents:
5702
diff
changeset
|
87 goto mmap; |
9dbb9c710480
svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents:
5702
diff
changeset
|
88 #endif |
9dbb9c710480
svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents:
5702
diff
changeset
|
89 |
9dbb9c710480
svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents:
5702
diff
changeset
|
90 #ifdef CONFIG_DHAHELPER |
9219
4a5b01c405b6
compiler warning fixes by Domink and some other changes by me
alex
parents:
9025
diff
changeset
|
91 #ifdef CONFIG_SVGAHELPER |
8503
9dbb9c710480
svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents:
5702
diff
changeset
|
92 dha_helper_way: |
9219
4a5b01c405b6
compiler warning fixes by Domink and some other changes by me
alex
parents:
9025
diff
changeset
|
93 #endif |
9025
ae0507e107b7
cleanup and removal of libdha_exit. forgot to commit this
alex
parents:
8503
diff
changeset
|
94 if ( (mem_fd = open("/dev/dhahelper",O_RDWR)) < 0) |
4474 | 95 { |
8503
9dbb9c710480
svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents:
5702
diff
changeset
|
96 perror("libdha: DHA kernelhelper failed"); |
9dbb9c710480
svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents:
5702
diff
changeset
|
97 goto dev_mem_way; |
4474 | 98 } |
99 else | |
100 { | |
101 dhahelper_memory_t mem_req; | |
102 | |
103 mem_req.operation = MEMORY_OP_MAP; | |
104 mem_req.start = base; | |
105 mem_req.offset = 0; | |
106 mem_req.size = size; | |
107 | |
9025
ae0507e107b7
cleanup and removal of libdha_exit. forgot to commit this
alex
parents:
8503
diff
changeset
|
108 if (ioctl(mem_fd, DHAHELPER_MEMORY, &mem_req) < 0) |
4474 | 109 { |
8503
9dbb9c710480
svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents:
5702
diff
changeset
|
110 perror("libdha: DHA kernelhelper failed"); |
9025
ae0507e107b7
cleanup and removal of libdha_exit. forgot to commit this
alex
parents:
8503
diff
changeset
|
111 close(mem_fd); |
8503
9dbb9c710480
svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents:
5702
diff
changeset
|
112 goto dev_mem_way; |
4474 | 113 } |
8503
9dbb9c710480
svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents:
5702
diff
changeset
|
114 else |
9dbb9c710480
svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents:
5702
diff
changeset
|
115 goto mmap; |
4474 | 116 } |
8503
9dbb9c710480
svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents:
5702
diff
changeset
|
117 #endif |
4474 | 118 |
8503
9dbb9c710480
svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents:
5702
diff
changeset
|
119 dev_mem_way: |
9025
ae0507e107b7
cleanup and removal of libdha_exit. forgot to commit this
alex
parents:
8503
diff
changeset
|
120 if ( (mem_fd = open(DEV_MEM,O_RDWR)) == -1) |
8503
9dbb9c710480
svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents:
5702
diff
changeset
|
121 { |
9dbb9c710480
svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents:
5702
diff
changeset
|
122 perror("libdha: opening /dev/mem failed"); |
9219
4a5b01c405b6
compiler warning fixes by Domink and some other changes by me
alex
parents:
9025
diff
changeset
|
123 return MAP_FAILED; |
3973 | 124 } |
8503
9dbb9c710480
svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents:
5702
diff
changeset
|
125 |
9dbb9c710480
svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents:
5702
diff
changeset
|
126 mmap: |
9025
ae0507e107b7
cleanup and removal of libdha_exit. forgot to commit this
alex
parents:
8503
diff
changeset
|
127 return mmap(0,size,PROT_READ|PROT_WRITE,MAP_SHARED,mem_fd,base); |
3973 | 128 } |
129 | |
5702 | 130 void unmap_phys_mem(void *ptr, unsigned long size) |
3973 | 131 { |
8503
9dbb9c710480
svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents:
5702
diff
changeset
|
132 int res = munmap(ptr,size); |
9dbb9c710480
svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents:
5702
diff
changeset
|
133 |
9219
4a5b01c405b6
compiler warning fixes by Domink and some other changes by me
alex
parents:
9025
diff
changeset
|
134 if (res == (int)MAP_FAILED) |
8503
9dbb9c710480
svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents:
5702
diff
changeset
|
135 { |
9dbb9c710480
svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents:
5702
diff
changeset
|
136 perror("libdha: unmapping memory failed"); |
9219
4a5b01c405b6
compiler warning fixes by Domink and some other changes by me
alex
parents:
9025
diff
changeset
|
137 return; |
8503
9dbb9c710480
svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents:
5702
diff
changeset
|
138 } |
9025
ae0507e107b7
cleanup and removal of libdha_exit. forgot to commit this
alex
parents:
8503
diff
changeset
|
139 |
ae0507e107b7
cleanup and removal of libdha_exit. forgot to commit this
alex
parents:
8503
diff
changeset
|
140 close(mem_fd); |
ae0507e107b7
cleanup and removal of libdha_exit. forgot to commit this
alex
parents:
8503
diff
changeset
|
141 mem_fd = -1; |
ae0507e107b7
cleanup and removal of libdha_exit. forgot to commit this
alex
parents:
8503
diff
changeset
|
142 |
ae0507e107b7
cleanup and removal of libdha_exit. forgot to commit this
alex
parents:
8503
diff
changeset
|
143 return; |
3973 | 144 } |
145 | |
10980 | 146 #endif /* Generic mmap (not win32, nor os2) */ |
147 | |
8503
9dbb9c710480
svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents:
5702
diff
changeset
|
148 unsigned char INPORT8(unsigned idx) |
3973 | 149 { |
150 return inb(idx); | |
151 } | |
152 | |
3995 | 153 unsigned short INPORT16(unsigned idx) |
3973 | 154 { |
155 return inw(idx); | |
156 } | |
157 | |
8503
9dbb9c710480
svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents:
5702
diff
changeset
|
158 unsigned INPORT32(unsigned idx) |
3973 | 159 { |
160 return inl(idx); | |
161 } | |
162 | |
8503
9dbb9c710480
svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents:
5702
diff
changeset
|
163 void OUTPORT8(unsigned idx,unsigned char val) |
3973 | 164 { |
165 outb(idx,val); | |
166 } | |
167 | |
8503
9dbb9c710480
svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents:
5702
diff
changeset
|
168 void OUTPORT16(unsigned idx,unsigned short val) |
3973 | 169 { |
170 outw(idx,val); | |
171 } | |
172 | |
8503
9dbb9c710480
svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents:
5702
diff
changeset
|
173 void OUTPORT32(unsigned idx,unsigned val) |
3973 | 174 { |
175 outl(idx,val); | |
176 } |