servermd.h revision bce81337
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#if defined(__arm32__) || defined(__arm__)
87
88#ifdef __ARMEB__
89#define IMAGE_BYTE_ORDER        MSBFirst
90#define BITMAP_BIT_ORDER        MSBFirst
91#else
92#define IMAGE_BYTE_ORDER        LSBFirst
93#define BITMAP_BIT_ORDER        LSBFirst
94#endif
95#define GLYPHPADBYTES           4
96
97#endif /* __arm32__ */
98
99#if defined(__nds32__)
100
101#define IMAGE_BYTE_ORDER	LSBFirst
102
103#if defined(XF86MONOVGA) || defined(XF86VGA16) || defined(XF86MONO)
104# define BITMAP_BIT_ORDER	MSBFirst
105#else
106# define BITMAP_BIT_ORDER	LSBFirst
107#endif
108
109#if defined(XF86MONOVGA) || defined(XF86VGA16)
110# define BITMAP_SCANLINE_UNIT	8
111#endif
112
113#define GLYPHPADBYTES		4
114#define GETLEFTBITS_ALIGNMENT	1
115#define LARGE_INSTRUCTION_CACHE
116#define AVOID_MEMORY_READ
117
118#endif /* __nds32__ */
119
120#if defined __hppa__
121
122#define IMAGE_BYTE_ORDER	MSBFirst
123#define BITMAP_BIT_ORDER	MSBFirst
124#define GLYPHPADBYTES		4	/* to make fb work */
125					/* byte boundries */
126#endif /* hpux || __hppa__ */
127
128#if defined(__powerpc__) || defined(__ppc__) || defined(__ppc64__)
129
130#define IMAGE_BYTE_ORDER        MSBFirst
131#define BITMAP_BIT_ORDER        MSBFirst
132#define GLYPHPADBYTES           4
133
134#endif /* PowerPC */
135
136#if defined(__sh__)
137
138#if defined(__BIG_ENDIAN__)
139# define IMAGE_BYTE_ORDER	MSBFirst
140# define BITMAP_BIT_ORDER	MSBFirst
141# define GLYPHPADBYTES		4
142#else
143# define IMAGE_BYTE_ORDER	LSBFirst
144# define BITMAP_BIT_ORDER	LSBFirst
145# define GLYPHPADBYTES		4
146#endif
147
148#endif /* SuperH */
149
150#if defined(__m32r__)
151
152#if defined(__BIG_ENDIAN__)
153# define IMAGE_BYTE_ORDER      MSBFirst
154# define BITMAP_BIT_ORDER      MSBFirst
155# define GLYPHPADBYTES         4
156#else
157# define IMAGE_BYTE_ORDER      LSBFirst
158# define BITMAP_BIT_ORDER      LSBFirst
159# define GLYPHPADBYTES         4
160#endif
161
162#endif /* __m32r__ */
163
164#if (defined(sun) && (defined(__sparc) || defined(sparc))) || \
165    (defined(__uxp__) && (defined(sparc) || defined(mc68000))) || \
166    defined(__sparc__) || defined(__mc68000__)
167
168#if defined(__sparc) || defined(__sparc__)
169# if !defined(sparc)
170#  define sparc 1
171# endif
172#endif
173
174#if defined(sun386) || defined(sun5)
175# define IMAGE_BYTE_ORDER	LSBFirst        /* Values for the SUN only */
176# define BITMAP_BIT_ORDER	LSBFirst
177#else
178# define IMAGE_BYTE_ORDER	MSBFirst        /* Values for the SUN only */
179# define BITMAP_BIT_ORDER	MSBFirst
180#endif
181
182#define	GLYPHPADBYTES		4
183
184#endif /* sun && !(i386 && SVR4) */
185
186
187#if defined(ibm032) || defined (ibm)
188
189#ifdef __i386__
190# define IMAGE_BYTE_ORDER	LSBFirst	/* Value for PS/2 only */
191#else
192# define IMAGE_BYTE_ORDER	MSBFirst        /* Values for the RT only*/
193#endif
194#define BITMAP_BIT_ORDER	MSBFirst
195#define	GLYPHPADBYTES		1
196/* ibm pcc doesn't understand pragmas. */
197
198#ifdef __i386__
199#define BITMAP_SCANLINE_UNIT	8
200#endif
201
202#endif /* ibm */
203
204#if (defined(mips) || defined(__mips))
205
206#if defined(MIPSEL) || defined(__MIPSEL__)
207# define IMAGE_BYTE_ORDER	LSBFirst        /* Values for the PMAX only */
208# define BITMAP_BIT_ORDER	LSBFirst
209# define GLYPHPADBYTES		4
210#else
211# define IMAGE_BYTE_ORDER	MSBFirst        /* Values for the MIPS only */
212# define BITMAP_BIT_ORDER	MSBFirst
213# define GLYPHPADBYTES		4
214#endif
215
216#endif /* mips */
217
218#if defined(__alpha) || defined(__alpha__)
219# define IMAGE_BYTE_ORDER	LSBFirst	/* Values for the Alpha only */
220# define BITMAP_BIT_ORDER       LSBFirst
221# define GLYPHPADBYTES		4
222
223#endif /* alpha */
224
225#if defined (linux) && defined (__s390__)
226
227#define IMAGE_BYTE_ORDER      	MSBFirst
228#define BITMAP_BIT_ORDER      	MSBFirst
229#define GLYPHPADBYTES         	4
230
231#define BITMAP_SCANLINE_UNIT	8
232#define FAST_UNALIGNED_READ
233
234#endif /* linux/s390 */
235
236#if defined (linux) && defined (__s390x__)
237
238#define IMAGE_BYTE_ORDER       MSBFirst
239#define BITMAP_BIT_ORDER       MSBFirst
240#define GLYPHPADBYTES          4
241
242#define BITMAP_SCANLINE_UNIT	8
243#define FAST_UNALIGNED_READ
244
245#endif /* linux/s390x */
246
247
248#if defined(__ia64__) || defined(ia64)
249
250# define IMAGE_BYTE_ORDER	LSBFirst
251# define BITMAP_BIT_ORDER       LSBFirst
252# define GLYPHPADBYTES		4
253
254#endif /* ia64 */
255
256#if defined(__amd64__) || defined(amd64) || defined(__amd64)
257# define IMAGE_BYTE_ORDER	LSBFirst
258# define BITMAP_BIT_ORDER       LSBFirst
259# define GLYPHPADBYTES		4
260/* ???? */
261#endif /* AMD64 */
262
263#if	defined(SVR4) && (defined(__i386__) || defined(__i386) ) ||	\
264	defined(__alpha__) || defined(__alpha) || \
265	defined(__i386__) || \
266	defined(__s390x__) || defined(__s390__)
267
268#ifndef IMAGE_BYTE_ORDER
269#define IMAGE_BYTE_ORDER	LSBFirst
270#endif
271
272#ifndef BITMAP_BIT_ORDER
273# define BITMAP_BIT_ORDER      LSBFirst
274#endif
275
276#ifndef GLYPHPADBYTES
277#define GLYPHPADBYTES           4
278#endif
279
280#endif /* SVR4 / BSD / i386 */
281
282#if defined (linux) && defined (__mc68000__)
283
284#define IMAGE_BYTE_ORDER       MSBFirst
285#define BITMAP_BIT_ORDER       MSBFirst
286#define GLYPHPADBYTES          4
287
288#endif /* linux/m68k */
289
290
291/* linux on ARM */
292#if defined(linux) && defined(__arm__)
293#define IMAGE_BYTE_ORDER	LSBFirst
294#define BITMAP_BIT_ORDER	LSBFirst
295#define GLYPHPADBYTES		4
296#endif
297
298/* linux on IBM S/390 */
299#if defined (linux) && defined (__s390__)
300#define IMAGE_BYTE_ORDER	MSBFirst
301#define BITMAP_BIT_ORDER	MSBFirst
302#define GLYPHPADBYTES		4
303#endif /* linux/s390 */
304
305/* size of buffer to use with GetImage, measured in bytes. There's obviously
306 * a trade-off between the amount of heap used and the number of times the
307 * ddx routine has to be called.
308 */
309#ifndef IMAGE_BUFSIZE
310#define IMAGE_BUFSIZE		(64*1024)
311#endif
312
313/* pad scanline to a longword */
314#ifndef BITMAP_SCANLINE_UNIT
315#define BITMAP_SCANLINE_UNIT	32
316#endif
317
318#ifndef BITMAP_SCANLINE_PAD
319#define BITMAP_SCANLINE_PAD  32
320#define LOG2_BITMAP_PAD		5
321#define LOG2_BYTES_PER_SCANLINE_PAD	2
322#endif
323
324#include <X11/Xfuncproto.h>
325/*
326 *   This returns the number of padding units, for depth d and width w.
327 * For bitmaps this can be calculated with the macros above.
328 * Other depths require either grovelling over the formats field of the
329 * screenInfo or hardwired constants.
330 */
331
332typedef struct _PaddingInfo {
333	int     padRoundUp;	/* pixels per pad unit - 1 */
334	int	padPixelsLog2;	/* log 2 (pixels per pad unit) */
335	int     padBytesLog2;	/* log 2 (bytes per pad unit) */
336	int	notPower2;	/* bitsPerPixel not a power of 2 */
337	int	bytesPerPixel;	/* only set when notPower2 is TRUE */
338	int	bitsPerPixel;	/* bits per pixel */
339} PaddingInfo;
340extern _X_EXPORT PaddingInfo PixmapWidthPaddingInfo[];
341
342/* The only portable way to get the bpp from the depth is to look it up */
343#define BitsPerPixel(d) (PixmapWidthPaddingInfo[d].bitsPerPixel)
344
345#define PixmapWidthInPadUnits(w, d) \
346    (PixmapWidthPaddingInfo[d].notPower2 ? \
347    (((int)(w) * PixmapWidthPaddingInfo[d].bytesPerPixel +  \
348	         PixmapWidthPaddingInfo[d].bytesPerPixel) >> \
349	PixmapWidthPaddingInfo[d].padBytesLog2) : \
350    ((int)((w) + PixmapWidthPaddingInfo[d].padRoundUp) >> \
351	PixmapWidthPaddingInfo[d].padPixelsLog2))
352
353/*
354 *	Return the number of bytes to which a scanline of the given
355 * depth and width will be padded.
356 */
357#define PixmapBytePad(w, d) \
358    (PixmapWidthInPadUnits(w, d) << PixmapWidthPaddingInfo[d].padBytesLog2)
359
360#define BitmapBytePad(w) \
361    (((int)((w) + BITMAP_SCANLINE_PAD - 1) >> LOG2_BITMAP_PAD) << LOG2_BYTES_PER_SCANLINE_PAD)
362
363#define PixmapWidthInPadUnitsProto(w, d) PixmapWidthInPadUnits(w, d)
364#define PixmapBytePadProto(w, d) PixmapBytePad(w, d)
365#define BitmapBytePadProto(w) BitmapBytePad(w)
366
367#endif /* SERVERMD_H */
368