1 /***********************************************************
3 Copyright (c) 1987 X Consortium
5 Permission is hereby granted, free of charge, to any person obtaining a copy
6 of this software and associated documentation files (the "Software"), to deal
7 in the Software without restriction, including without limitation the rights
8 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 copies of the Software, and to permit persons to whom the Software is
10 furnished to do so, subject to the following conditions:
12 The above copyright notice and this permission notice shall be included in
13 all copies or substantial portions of the Software.
15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
19 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 Except as contained in this notice, the name of the X Consortium shall not be
23 used in advertising or otherwise to promote the sale, use or other dealings
24 in this Software without prior written authorization from the X Consortium.
27 Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
31 Permission to use, copy, modify, and distribute this software and its
32 documentation for any purpose and without fee is hereby granted,
33 provided that the above copyright notice appear in all copies and that
34 both that copyright notice and this permission notice appear in
35 supporting documentation, and that the name of Digital not be
36 used in advertising or publicity pertaining to distribution of the
37 software without specific, written prior permission.
39 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
40 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
41 DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
42 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
43 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
44 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
47 ******************************************************************/
50 /* $XConsortium: servermd.h /main/58 1996/12/02 10:22:09 lehors $ */
51 /* $XFree86: xc/programs/Xserver/include/servermd.h,v 3.19.2.3 1997/07/28 14:17:34 dawes Exp $ */
54 * Machine dependent values:
55 * GLYPHPADBYTES should be chosen with consideration for the space-time
56 * trade-off. Padding to 0 bytes means that there is no wasted space
57 * in the font bitmaps (both on disk and in memory), but that access of
58 * the bitmaps will cause odd-address memory references. Padding to
59 * 2 bytes would ensure even address memory references and would
60 * be suitable for a 68010-class machine, but at the expense of wasted
61 * space in the font bitmaps. Padding to 4 bytes would be good
62 * for real 32 bit machines, etc. Be sure that you tell the font
63 * compiler what kind of padding you want because its defines are
64 * kept separate from this. See server/include/font.h for how
65 * GLYPHPADBYTES is used.
67 * Along with this, you should choose an appropriate value for
68 * GETLEFTBITS_ALIGNMENT, which is used in ddx/mfb/maskbits.h. This
69 * constant choses what kind of memory references are guarenteed during
70 * font access; either 1, 2 or 4, for byte, word or longword access,
71 * respectively. For instance, if you have decided to to have
72 * GLYPHPADBYTES == 4, then it is pointless for you to have a
73 * GETLEFTBITS_ALIGNMENT > 1, because the padding of the fonts has already
74 * guarenteed you that your fonts are longword aligned. On the other
75 * hand, even if you have chosen GLYPHPADBYTES == 1 to save space, you may
76 * also decide that the computing involved in aligning the pointer is more
77 * costly than an odd-address access; you choose GETLEFTBITS_ALIGNMENT == 1.
79 * Next, choose the tuning parameters which are appropriate for your
80 * hardware; these modify the behaviour of the raw frame buffer code
81 * in ddx/mfb and ddx/cfb. Defining these incorrectly will not cause
82 * the server to run incorrectly, but defining these correctly will
83 * cause some noticeable speed improvements:
85 * AVOID_MEMORY_READ - (8-bit cfb only)
86 * When stippling pixels on the screen (polytext and pushpixels),
87 * don't read long words from the display and mask in the
88 * appropriate values. Rather, perform multiple byte/short/long
89 * writes as appropriate. This option uses many more instructions
90 * but runs much faster when the destination is much slower than
91 * the CPU and at least 1 level of write buffer is availible (2
92 * is much better). Defined currently for SPARC and MIPS.
94 * FAST_CONSTANT_OFFSET_MODE - (cfb and mfb)
95 * This define is used on machines which have no auto-increment
96 * addressing mode, but do have an effectively free constant-offset
97 * addressing mode. Currently defined for MIPS and SPARC, even though
98 * I remember the cg6 as performing better without it (cg3 definitely
99 * performs better with it).
101 * LARGE_INSTRUCTION_CACHE -
102 * This define increases the number of times some loops are
103 * unrolled. On 68020 machines (with 256 bytes of i-cache),
104 * this define will slow execution down as instructions miss
105 * the cache frequently. On machines with real i-caches, this
106 * reduces loop overhead, causing a slight performance improvement.
107 * Currently defined for MIPS and SPARC
109 * FAST_UNALIGNED_READS -
110 * For machines with more memory bandwidth than CPU, this
111 * define uses unaligned reads for 8-bit BitBLT instead of doing
112 * aligned reads and combining the results with shifts and
113 * logical-ors. Currently defined for 68020 and vax.
114 * PLENTIFUL_REGISTERS -
115 * For machines with > 20 registers. Currently used for
116 * unrolling the text painting code a bit more. Currently
119 * For non-Harvard RISC machines, those which share the same
120 * CPU memory bus for instructions and data. This unrolls some
121 * solid fill loops which are otherwise best left rolled up.
122 * Currently defined for SPARC.
127 #define IMAGE_BYTE_ORDER LSBFirst /* Values for the VAX only */
128 #define BITMAP_BIT_ORDER LSBFirst
129 #define GLYPHPADBYTES 1
130 #define GETLEFTBITS_ALIGNMENT 4
131 #define FAST_UNALIGNED_READS
135 #if (defined(Lynx) && defined(__powerpc__))
137 /* For now this is for Xvfb only */
138 #define IMAGE_BYTE_ORDER MSBFirst
139 #define BITMAP_BIT_ORDER MSBFirst
140 #define GLYPHPADBYTES 4
141 #define GETLEFTBITS_ALIGNMENT 1
143 #define LARGE_INSTRUCTION_CACHE
144 #define FAST_CONSTANT_OFFSET_MODE
145 #define PLENTIFUL_REGISTERS
146 #define AVOID_MEMORY_READ
150 #endif /* LynxOS PowerPC */
152 #if (defined(sun) && !(defined(i386) && defined(SVR4))) || \
153 (defined(AMOEBA) && (defined(sparc) || defined(mc68000))) || \
154 (defined(__uxp__) && (defined(sparc) || defined(mc68000))) || \
155 (defined(Lynx) && defined(__sparc__)) || \
156 ((defined(__NetBSD__) || defined(__OpenBSD__)) && \
157 (defined(__sparc__) || defined(__mc68000__)))
159 #if defined(sun386) || defined(sun5)
160 # define IMAGE_BYTE_ORDER LSBFirst /* Values for the SUN only */
161 # define BITMAP_BIT_ORDER LSBFirst
163 # define IMAGE_BYTE_ORDER MSBFirst /* Values for the SUN only */
164 # define BITMAP_BIT_ORDER MSBFirst
168 # define AVOID_MEMORY_READ
169 # define LARGE_INSTRUCTION_CACHE
170 # define FAST_CONSTANT_OFFSET_MODE
171 # define SHARED_IDCACHE
175 #define FAST_UNALIGNED_READS
178 #define GLYPHPADBYTES 4
179 #define GETLEFTBITS_ALIGNMENT 1
181 #endif /* sun && !(i386 && SVR4) */
186 #define IMAGE_BYTE_ORDER MSBFirst /* Values for the RISC/6000 */
187 #define BITMAP_BIT_ORDER MSBFirst
188 #define GLYPHPADBYTES 4
189 #define GETLEFTBITS_ALIGNMENT 1
191 #define LARGE_INSTRUCTION_CACHE
192 #define FAST_CONSTANT_OFFSET_MODE
193 #define PLENTIFUL_REGISTERS
194 #define AVOID_MEMORY_READ
199 #if defined(ibm032) || defined (ibm)
202 # define IMAGE_BYTE_ORDER LSBFirst /* Value for PS/2 only */
204 # define IMAGE_BYTE_ORDER MSBFirst /* Values for the RT only*/
206 #define BITMAP_BIT_ORDER MSBFirst
207 #define GLYPHPADBYTES 1
208 #define GETLEFTBITS_ALIGNMENT 4
209 /* ibm pcc doesn't understand pragmas. */
212 #define BITMAP_SCANLINE_UNIT 8
219 #define IMAGE_BYTE_ORDER MSBFirst /* Values for the HP only */
220 #define BITMAP_BIT_ORDER MSBFirst
221 #define GLYPHPADBYTES 2 /* to match product server */
222 #define GETLEFTBITS_ALIGNMENT 4 /* PA forces longs to 4 */
224 #define AVOID_MEMORY_READ
225 #define FAST_CONSTANT_OFFSET_MODE
226 #define LARGE_INSTRUCTION_CACHE
227 #define PLENTIFUL_REGISTERS
231 #if defined (M4310) || defined(M4315) || defined(M4317) || defined(M4319) || defined(M4330)
233 #define IMAGE_BYTE_ORDER MSBFirst /* Values for Pegasus only */
234 #define BITMAP_BIT_ORDER MSBFirst
235 #define GLYPHPADBYTES 4
236 #define GETLEFTBITS_ALIGNMENT 1
238 #define FAST_UNALIGNED_READS
240 #endif /* tektronix */
244 #define IMAGE_BYTE_ORDER MSBFirst /* Values for the MacII only */
245 #define BITMAP_BIT_ORDER MSBFirst
246 #define GLYPHPADBYTES 4
247 #define GETLEFTBITS_ALIGNMENT 1
249 /* might want FAST_UNALIGNED_READS for frame buffers with < 1us latency */
253 #if (defined(mips) || defined(__mips)) && !defined(sgi)
255 #if defined(MIPSEL) || defined(__MIPSEL__)
256 # define IMAGE_BYTE_ORDER LSBFirst /* Values for the PMAX only */
257 # define BITMAP_BIT_ORDER LSBFirst
258 # define GLYPHPADBYTES 4
259 # define GETLEFTBITS_ALIGNMENT 1
261 # define IMAGE_BYTE_ORDER MSBFirst /* Values for the MIPS only */
262 # define BITMAP_BIT_ORDER MSBFirst
263 # define GLYPHPADBYTES 4
264 # define GETLEFTBITS_ALIGNMENT 1
267 #define AVOID_MEMORY_READ
268 #define FAST_CONSTANT_OFFSET_MODE
269 #define LARGE_INSTRUCTION_CACHE
270 #define PLENTIFUL_REGISTERS
274 #if defined(__alpha) || defined(__alpha__) || defined(__alphaCross)
275 # define IMAGE_BYTE_ORDER LSBFirst /* Values for the Alpha only */
277 # if defined(XF86MONOVGA) || defined(XF86VGA16) || defined(XF86MONO)
278 # define BITMAP_BIT_ORDER MSBFirst
280 # define BITMAP_BIT_ORDER LSBFirst
283 # if defined(XF86MONOVGA) || defined(XF86VGA16)
284 # define BITMAP_SCANLINE_UNIT 8
286 /* pad scanline to a longword */
287 # define BITMAP_SCANLINE_UNIT 64
290 # define BITMAP_SCANLINE_PAD 64
291 # define LOG2_BITMAP_PAD 6
292 # define LOG2_BYTES_PER_SCANLINE_PAD 3
293 # define GLYPHPADBYTES 4
294 # define GETLEFTBITS_ALIGNMENT 1
295 # define FAST_CONSTANT_OFFSET_MODE
296 # define LARGE_INSTRUCTION_CACHE
297 # define PLENTIFUL_REGISTERS
299 /* Add for handling protocol XPutImage and XGetImage; see comment below */
300 #define INTERNAL_VS_EXTERNAL_PADDING
301 #define BITMAP_SCANLINE_UNIT_PROTO 32
303 #define BITMAP_SCANLINE_PAD_PROTO 32
304 #define LOG2_BITMAP_PAD_PROTO 5
305 #define LOG2_BYTES_PER_SCANLINE_PAD_PROTO 2
311 #define IMAGE_BYTE_ORDER MSBFirst /* Values for the stellar only*/
312 #define BITMAP_BIT_ORDER MSBFirst
313 #define GLYPHPADBYTES 4
314 #define GETLEFTBITS_ALIGNMENT 4
315 #define IMAGE_BUFSIZE (64*1024)
317 * Use SysV random number generator.
325 #define IMAGE_BYTE_ORDER MSBFirst /* Values for the OMRON only*/
326 #define BITMAP_BIT_ORDER MSBFirst
327 #define GLYPHPADBYTES 4
328 #define GETLEFTBITS_ALIGNMENT 1
331 #define FAST_CONSTANT_OFFSET_MODE
332 #define AVOID_MEMORY_READ
333 #define LARGE_INSTRUCTION_CACHE
334 #define PLENTIFUL_REGISTERS
339 #if (defined(i386) && (defined(SVR4) || defined(SYSV) || (defined(sun) && defined(SVR4))) || defined(__bsdi__) || (defined(__NetBSD__) && defined(__i386__)) || (defined(__OpenBSD__) && defined(__i386__)) || defined(__FreeBSD__) || defined(MACH386) || (defined(linux) && !(defined(__mc68000__) || defined(PPC) || defined(__sparc__) || defined(__s390__))) || (defined(AMOEBA) && defined(i80386)) || defined(MINIX) || defined(__EMX__) || (defined(Lynx) && defined(__i386__)))
341 #ifndef IMAGE_BYTE_ORDER
342 #define IMAGE_BYTE_ORDER LSBFirst
345 #ifndef BITMAP_BIT_ORDER
346 # if defined(XF86MONOVGA) || defined(XF86VGA16) || defined(XF86MONO)
347 # define BITMAP_BIT_ORDER MSBFirst
349 # define BITMAP_BIT_ORDER LSBFirst
353 #ifndef BITMAP_SCANLINE_UNIT
354 # if defined(XF86MONOVGA) || defined(XF86VGA16)
355 # define BITMAP_SCANLINE_UNIT 8
359 #ifndef GLYPHPADBYTES
360 #define GLYPHPADBYTES 4
363 #define GETLEFTBITS_ALIGNMENT 1
364 #define AVOID_MEMORY_READ
366 #define AVOID_GLYPHBLT
367 #define FAST_CONSTANT_OFFSET_MODE
372 #endif /* SVR4 / BSD / i386 */
374 #if defined (linux) && defined (__mc68000__)
376 #define IMAGE_BYTE_ORDER MSBFirst
377 #define BITMAP_BIT_ORDER MSBFirst
378 #define FAST_UNALIGNED_READS
379 #define GLYPHPADBYTES 4
380 #define GETLEFTBITS_ALIGNMENT 1
382 #endif /* linux/m68k */
384 #if defined (linux) && defined (PPC)
386 #define IMAGE_BYTE_ORDER MSBFirst
387 #define BITMAP_BIT_ORDER MSBFirst
388 #define GLYPHPADBYTES 4
389 #define GETLEFTBITS_ALIGNMENT 1
391 #define LARGE_INSTRUCTION_CACHE
392 #define FAST_CONSTANT_OFFSET_MODE
394 #endif /* linux/PPC */
396 #if defined (linux) && defined (__sparc__)
398 #define IMAGE_BYTE_ORDER MSBFirst
399 #define BITMAP_BIT_ORDER MSBFirst
400 #define GLYPHPADBYTES 4
401 #define GETLEFTBITS_ALIGNMENT 1
403 #endif /* linux/__sparc__ */
405 #if defined (linux) && defined (__s390__)
407 #define IMAGE_BYTE_ORDER MSBFirst
408 #define BITMAP_BIT_ORDER MSBFirst
409 #define GLYPHPADBYTES 4
410 #define GETLEFTBITS_ALIGNMENT 1
412 #endif /* linux/__s390__ */
414 #if defined (linux) && defined (PPC)
416 #define IMAGE_BYTE_ORDER MSBFirst
417 #define BITMAP_BIT_ORDER MSBFirst
418 #define GLYPHPADBYTES 4
419 #define GETLEFTBITS_ALIGNMENT 1
421 #define LARGE_INSTRUCTION_CACHE
422 #define FAST_CONSTANT_OFFSET_MODE
424 #endif /* linux/PPC */
428 #define IMAGE_BYTE_ORDER MSBFirst
429 #define BITMAP_BIT_ORDER MSBFirst
431 #if (_MIPS_SZLONG == 64)
433 # define GLYPHPADBYTES 4
434 # define GETLEFTBITS_ALIGNMENT 1
436 /* pad scanline to a longword */
437 #define BITMAP_SCANLINE_UNIT 64
439 #define BITMAP_SCANLINE_PAD 64
440 #define LOG2_BITMAP_PAD 6
441 #define LOG2_BYTES_PER_SCANLINE_PAD 3
443 /* Add for handling protocol XPutImage and XGetImage; see comment below */
444 #define INTERNAL_VS_EXTERNAL_PADDING
445 #define BITMAP_SCANLINE_UNIT_PROTO 32
447 #define BITMAP_SCANLINE_PAD_PROTO 32
448 #define LOG2_BITMAP_PAD_PROTO 5
449 #define LOG2_BYTES_PER_SCANLINE_PAD_PROTO 2
453 #define GLYPHPADBYTES 2
454 #define GETLEFTBITS_ALIGNMENT 4
458 #define AVOID_MEMORY_READ
459 #define FAST_CONSTANT_OFFSET_MODE
460 #define LARGE_INSTRUCTION_CACHE
461 #define PLENTIFUL_REGISTERS
465 /* size of buffer to use with GetImage, measured in bytes. There's obviously
466 * a trade-off between the amount of stack (or whatever ALLOCATE_LOCAL gives
467 * you) used and the number of times the ddx routine has to be called.
469 * for a 1024 x 864 bit monochrome screen with a 32 bit word we get
470 * 8192/4 words per buffer
471 * (1024/32) = 32 words per scanline
472 * 2048 words per buffer / 32 words per scanline = 64 scanlines per buffer
473 * 864 scanlines / 64 scanlines = 14 buffers to draw a full screen
475 #ifndef IMAGE_BUFSIZE
476 #define IMAGE_BUFSIZE 8192
479 /* pad scanline to a longword */
480 #ifndef BITMAP_SCANLINE_UNIT
481 #define BITMAP_SCANLINE_UNIT 32
484 #ifndef BITMAP_SCANLINE_PAD
485 #define BITMAP_SCANLINE_PAD 32
486 #define LOG2_BITMAP_PAD 5
487 #define LOG2_BYTES_PER_SCANLINE_PAD 2
491 * This returns the number of padding units, for depth d and width w.
492 * For bitmaps this can be calculated with the macros above.
493 * Other depths require either grovelling over the formats field of the
494 * screenInfo or hardwired constants.
497 typedef struct _PaddingInfo {
498 int padRoundUp; /* pixels per pad unit - 1 */
499 int padPixelsLog2; /* log 2 (pixels per pad unit) */
500 int padBytesLog2; /* log 2 (bytes per pad unit) */
501 int notPower2; /* bitsPerPixel not a power of 2 */
502 int bytesPerPixel; /* only set when notPower2 is TRUE */
504 extern PaddingInfo PixmapWidthPaddingInfo[];
506 #define PixmapWidthInPadUnits(w, d) \
507 (PixmapWidthPaddingInfo[d].notPower2 ? \
508 (((int)(w) * PixmapWidthPaddingInfo[d].bytesPerPixel + \
509 PixmapWidthPaddingInfo[d].bytesPerPixel) >> \
510 PixmapWidthPaddingInfo[d].padBytesLog2) : \
511 ((int)((w) + PixmapWidthPaddingInfo[d].padRoundUp) >> \
512 PixmapWidthPaddingInfo[d].padPixelsLog2))
515 * Return the number of bytes to which a scanline of the given
516 * depth and width will be padded.
518 #define PixmapBytePad(w, d) \
519 (PixmapWidthInPadUnits(w, d) << PixmapWidthPaddingInfo[d].padBytesLog2)
521 #define BitmapBytePad(w) \
522 (((int)((w) + BITMAP_SCANLINE_PAD - 1) >> LOG2_BITMAP_PAD) << LOG2_BYTES_PER_SCANLINE_PAD)
524 #ifdef INTERNAL_VS_EXTERNAL_PADDING
526 /* This is defined if the server's internal padding is different from the padding
527 * advertised in the protocol. The protocol does not allow for padding to
528 * 64 bits, for example, so if the server wants to use 64 bit padding internally,
529 * it has to advertise 32 bit padding and do padding fixups whenever images
530 * cross the wire. (See ProcGetImage and ProcPutImage.)
532 * The macros and constants that end in Proto or PROTO refer to the advertised
533 * padding, and the ones without Proto are for internal padding.
536 extern PaddingInfo PixmapWidthPaddingInfoProto[];
538 #define PixmapWidthInPadUnitsProto(w, d) \
539 (PixmapWidthPaddingInfoProto[d].notPower2 ? \
540 (((int)(w) * PixmapWidthPaddingInfoProto[d].bytesPerPixel + \
541 PixmapWidthPaddingInfoProto[d].bytesPerPixel) >> \
542 PixmapWidthPaddingInfoProto[d].padBytesLog2) : \
543 ((int)((w) + PixmapWidthPaddingInfoProto[d].padRoundUp) >> \
544 PixmapWidthPaddingInfoProto[d].padPixelsLog2))
546 #define PixmapBytePadProto(w, d) \
547 (PixmapWidthInPadUnitsProto(w, d) << \
548 PixmapWidthPaddingInfoProto[d].padBytesLog2)
550 #define BitmapBytePadProto(w) \
551 ((((w) + BITMAP_SCANLINE_PAD_PROTO - 1) >> LOG2_BITMAP_PAD_PROTO) \
552 << LOG2_BYTES_PER_SCANLINE_PAD_PROTO)
554 #else /* protocol and internal padding is the same */
556 #define PixmapWidthInPadUnitsProto(w, d) PixmapWidthInPadUnits(w, d)
557 #define PixmapBytePadProto(w, d) PixmapBytePad(w, d)
558 #define BitmapBytePadProto(w) BitmapBytePad(w)
560 #endif /* protocol vs. internal padding */
562 #endif /* SERVERMD_H */