servermd.h revision 65b04b38
1/***********************************************************
2
3Copyright 1987, 1998  The Open Group
4
5Permission to use, copy, modify, distribute, and sell this software and its
6documentation for any purpose is hereby granted without fee, provided that
7the above copyright notice appear in all copies and that both that
8copyright notice and this permission notice appear in supporting
9documentation.
10
11The above copyright notice and this permission notice shall be included in
12all copies or substantial portions of the Software.
13
14THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
17OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20
21Except as contained in this notice, the name of The Open Group shall not be
22used in advertising or otherwise to promote the sale, use or other dealings
23in this Software without prior written authorization from The Open Group.
24
25
26Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
27
28                        All Rights Reserved
29
30Permission to use, copy, modify, and distribute this software and its
31documentation for any purpose and without fee is hereby granted,
32provided that the above copyright notice appear in all copies and that
33both that copyright notice and this permission notice appear in
34supporting documentation, and that the name of Digital not be
35used in advertising or publicity pertaining to distribution of the
36software without specific, written prior permission.
37
38DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
39ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
40DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
41ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
42WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
43ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
44SOFTWARE.
45
46******************************************************************/
47
48#ifndef SERVERMD_H
49#define SERVERMD_H 1
50
51/*
52 * Note: much of this is vestigial from mfb/cfb times.  This should
53 * really be simplified even further.
54 */
55
56/*
57 * Machine dependent values:
58 * GLYPHPADBYTES should be chosen with consideration for the space-time
59 * trade-off.  Padding to 0 bytes means that there is no wasted space
60 * in the font bitmaps (both on disk and in memory), but that access of
61 * the bitmaps will cause odd-address memory references.  Padding to
62 * 2 bytes would ensure even address memory references and would
63 * be suitable for a 68010-class machine, but at the expense of wasted
64 * space in the font bitmaps.  Padding to 4 bytes would be good
65 * for real 32 bit machines, etc.  Be sure that you tell the font
66 * compiler what kind of padding you want because its defines are
67 * kept separate from this.  See server/include/font.h for how
68 * GLYPHPADBYTES is used.
69 */
70
71#if defined(vax) || defined(__vax__)
72#define IMAGE_BYTE_ORDER	LSBFirst        /* Values for the VAX only */
73#define BITMAP_BIT_ORDER	LSBFirst
74#define	GLYPHPADBYTES		4
75#define GETLEFTBITS_ALIGNMENT	1
76#define FAST_UNALIGNED_READS
77#endif /* __vax__ */
78
79#ifdef __avr32__
80#define IMAGE_BYTE_ORDER        MSBFirst
81#define BITMAP_BIT_ORDER        MSBFirst
82#define GLYPHPADBYTES           4
83
84#endif /* __avr32__ */
85
86/* XXX arm is not always LE */
87#if defined(__arm32__) || defined(__arm__)
88
89#define IMAGE_BYTE_ORDER        LSBFirst
90#define BITMAP_BIT_ORDER        LSBFirst
91#define GLYPHPADBYTES           4
92
93#endif /* __arm32__ */
94
95#if defined(__nds32__)
96
97#define IMAGE_BYTE_ORDER	LSBFirst
98
99#if defined(XF86MONOVGA) || defined(XF86VGA16) || defined(XF86MONO)
100# define BITMAP_BIT_ORDER	MSBFirst
101#else
102# define BITMAP_BIT_ORDER	LSBFirst
103#endif
104
105#if defined(XF86MONOVGA) || defined(XF86VGA16)
106# define BITMAP_SCANLINE_UNIT	8
107#endif
108
109#define GLYPHPADBYTES		4
110#define GETLEFTBITS_ALIGNMENT	1
111#define LARGE_INSTRUCTION_CACHE
112#define AVOID_MEMORY_READ
113
114#endif /* __nds32__ */
115
116#if defined __hppa__
117
118#define IMAGE_BYTE_ORDER	MSBFirst
119#define BITMAP_BIT_ORDER	MSBFirst
120#define GLYPHPADBYTES		4	/* to make fb work */
121					/* byte boundries */
122#endif /* hpux || __hppa__ */
123
124#if defined(__powerpc__) || defined(__ppc__) || defined(__ppc64__)
125
126#define IMAGE_BYTE_ORDER        MSBFirst
127#define BITMAP_BIT_ORDER        MSBFirst
128#define GLYPHPADBYTES           4
129
130#endif /* PowerPC */
131
132#if defined(__sh__)
133
134#if defined(__BIG_ENDIAN__)
135# define IMAGE_BYTE_ORDER	MSBFirst
136# define BITMAP_BIT_ORDER	MSBFirst
137# define GLYPHPADBYTES		4
138#else
139# define IMAGE_BYTE_ORDER	LSBFirst
140# define BITMAP_BIT_ORDER	LSBFirst
141# define GLYPHPADBYTES		4
142#endif
143
144#endif /* SuperH */
145
146#if defined(__m32r__)
147
148#if defined(__BIG_ENDIAN__)
149# define IMAGE_BYTE_ORDER      MSBFirst
150# define BITMAP_BIT_ORDER      MSBFirst
151# define GLYPHPADBYTES         4
152#else
153# define IMAGE_BYTE_ORDER      LSBFirst
154# define BITMAP_BIT_ORDER      LSBFirst
155# define GLYPHPADBYTES         4
156#endif
157
158#endif /* __m32r__ */
159
160#if (defined(sun) && (defined(__sparc) || defined(sparc))) || \
161    (defined(__uxp__) && (defined(sparc) || defined(mc68000))) || \
162    defined(__sparc__) || defined(__mc68000__)
163
164#if defined(__sparc) || defined(__sparc__)
165# if !defined(sparc)
166#  define sparc 1
167# endif
168#endif
169
170#if defined(sun386) || defined(sun5)
171# define IMAGE_BYTE_ORDER	LSBFirst        /* Values for the SUN only */
172# define BITMAP_BIT_ORDER	LSBFirst
173#else
174# define IMAGE_BYTE_ORDER	MSBFirst        /* Values for the SUN only */
175# define BITMAP_BIT_ORDER	MSBFirst
176#endif
177
178#define	GLYPHPADBYTES		4
179
180#endif /* sun && !(i386 && SVR4) */
181
182
183#if defined(ibm032) || defined (ibm)
184
185#ifdef __i386__
186# define IMAGE_BYTE_ORDER	LSBFirst	/* Value for PS/2 only */
187#else
188# define IMAGE_BYTE_ORDER	MSBFirst        /* Values for the RT only*/
189#endif
190#define BITMAP_BIT_ORDER	MSBFirst
191#define	GLYPHPADBYTES		1
192/* ibm pcc doesn't understand pragmas. */
193
194#ifdef __i386__
195#define BITMAP_SCANLINE_UNIT	8
196#endif
197
198#endif /* ibm */
199
200#if (defined(mips) || defined(__mips))
201
202#if defined(MIPSEL) || defined(__MIPSEL__)
203# define IMAGE_BYTE_ORDER	LSBFirst        /* Values for the PMAX only */
204# define BITMAP_BIT_ORDER	LSBFirst
205# define GLYPHPADBYTES		4
206#else
207# define IMAGE_BYTE_ORDER	MSBFirst        /* Values for the MIPS only */
208# define BITMAP_BIT_ORDER	MSBFirst
209# define GLYPHPADBYTES		4
210#endif
211
212#endif /* mips */
213
214#if defined(__alpha) || defined(__alpha__)
215# define IMAGE_BYTE_ORDER	LSBFirst	/* Values for the Alpha only */
216# define BITMAP_BIT_ORDER       LSBFirst
217# define GLYPHPADBYTES		4
218
219#endif /* alpha */
220
221#if defined (linux) && defined (__s390__)
222
223#define IMAGE_BYTE_ORDER      	MSBFirst
224#define BITMAP_BIT_ORDER      	MSBFirst
225#define GLYPHPADBYTES         	4
226
227#define BITMAP_SCANLINE_UNIT	8
228#define FAST_UNALIGNED_READ
229
230#endif /* linux/s390 */
231
232#if defined (linux) && defined (__s390x__)
233
234#define IMAGE_BYTE_ORDER       MSBFirst
235#define BITMAP_BIT_ORDER       MSBFirst
236#define GLYPHPADBYTES          4
237
238#define BITMAP_SCANLINE_UNIT	8
239#define FAST_UNALIGNED_READ
240
241#endif /* linux/s390x */
242
243
244#if defined(__ia64__) || defined(ia64)
245
246# define IMAGE_BYTE_ORDER	LSBFirst
247# define BITMAP_BIT_ORDER       LSBFirst
248# define GLYPHPADBYTES		4
249
250#endif /* ia64 */
251
252#if defined(__amd64__) || defined(amd64) || defined(__amd64)
253# define IMAGE_BYTE_ORDER	LSBFirst
254# define BITMAP_BIT_ORDER       LSBFirst
255# define GLYPHPADBYTES		4
256/* ???? */
257#endif /* AMD64 */
258
259#if	defined(SVR4) && (defined(__i386__) || defined(__i386) ) ||	\
260	defined(__alpha__) || defined(__alpha) || \
261	defined(__i386__) || \
262	defined(__s390x__) || defined(__s390__)
263
264#ifndef IMAGE_BYTE_ORDER
265#define IMAGE_BYTE_ORDER	LSBFirst
266#endif
267
268#ifndef BITMAP_BIT_ORDER
269# define BITMAP_BIT_ORDER      LSBFirst
270#endif
271
272#ifndef GLYPHPADBYTES
273#define GLYPHPADBYTES           4
274#endif
275
276#endif /* SVR4 / BSD / i386 */
277
278#if defined (linux) && defined (__mc68000__)
279
280#define IMAGE_BYTE_ORDER       MSBFirst
281#define BITMAP_BIT_ORDER       MSBFirst
282#define GLYPHPADBYTES          4
283
284#endif /* linux/m68k */
285
286
287/* linux on ARM */
288#if defined(linux) && defined(__arm__)
289#define IMAGE_BYTE_ORDER	LSBFirst
290#define BITMAP_BIT_ORDER	LSBFirst
291#define GLYPHPADBYTES		4
292#endif
293
294/* linux on IBM S/390 */
295#if defined (linux) && defined (__s390__)
296#define IMAGE_BYTE_ORDER	MSBFirst
297#define BITMAP_BIT_ORDER	MSBFirst
298#define GLYPHPADBYTES		4
299#endif /* linux/s390 */
300
301/* size of buffer to use with GetImage, measured in bytes. There's obviously
302 * a trade-off between the amount of heap used and the number of times the
303 * ddx routine has to be called.
304 */
305#ifndef IMAGE_BUFSIZE
306#define IMAGE_BUFSIZE		(64*1024)
307#endif
308
309/* pad scanline to a longword */
310#ifndef BITMAP_SCANLINE_UNIT
311#define BITMAP_SCANLINE_UNIT	32
312#endif
313
314#ifndef BITMAP_SCANLINE_PAD
315#define BITMAP_SCANLINE_PAD  32
316#define LOG2_BITMAP_PAD		5
317#define LOG2_BYTES_PER_SCANLINE_PAD	2
318#endif
319
320#include <X11/Xfuncproto.h>
321/*
322 *   This returns the number of padding units, for depth d and width w.
323 * For bitmaps this can be calculated with the macros above.
324 * Other depths require either grovelling over the formats field of the
325 * screenInfo or hardwired constants.
326 */
327
328typedef struct _PaddingInfo {
329	int     padRoundUp;	/* pixels per pad unit - 1 */
330	int	padPixelsLog2;	/* log 2 (pixels per pad unit) */
331	int     padBytesLog2;	/* log 2 (bytes per pad unit) */
332	int	notPower2;	/* bitsPerPixel not a power of 2 */
333	int	bytesPerPixel;	/* only set when notPower2 is TRUE */
334	int	bitsPerPixel;	/* bits per pixel */
335} PaddingInfo;
336extern _X_EXPORT PaddingInfo PixmapWidthPaddingInfo[];
337
338/* The only portable way to get the bpp from the depth is to look it up */
339#define BitsPerPixel(d) (PixmapWidthPaddingInfo[d].bitsPerPixel)
340
341#define PixmapWidthInPadUnits(w, d) \
342    (PixmapWidthPaddingInfo[d].notPower2 ? \
343    (((int)(w) * PixmapWidthPaddingInfo[d].bytesPerPixel +  \
344	         PixmapWidthPaddingInfo[d].bytesPerPixel) >> \
345	PixmapWidthPaddingInfo[d].padBytesLog2) : \
346    ((int)((w) + PixmapWidthPaddingInfo[d].padRoundUp) >> \
347	PixmapWidthPaddingInfo[d].padPixelsLog2))
348
349/*
350 *	Return the number of bytes to which a scanline of the given
351 * depth and width will be padded.
352 */
353#define PixmapBytePad(w, d) \
354    (PixmapWidthInPadUnits(w, d) << PixmapWidthPaddingInfo[d].padBytesLog2)
355
356#define BitmapBytePad(w) \
357    (((int)((w) + BITMAP_SCANLINE_PAD - 1) >> LOG2_BITMAP_PAD) << LOG2_BYTES_PER_SCANLINE_PAD)
358
359#define PixmapWidthInPadUnitsProto(w, d) PixmapWidthInPadUnits(w, d)
360#define PixmapBytePadProto(w, d) PixmapBytePad(w, d)
361#define BitmapBytePadProto(w) BitmapBytePad(w)
362
363#endif /* SERVERMD_H */
364