summaryrefslogtreecommitdiff
path: root/hw/xfree86/xaa/xaacexp.h
blob: d78e5a3ecaff1ca45d25fdf55e912240d6dbdbb5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/* $XFree86$ */


#include "Xarch.h"

#ifndef FIXEDBASE
#define CHECKRETURN(b) if(width <= ((b) * 32)) return(base + (b))
#else
#define CHECKRETURN(b) if(width <= ((b) * 32)) return(base)
#endif

#if X_BYTE_ORDER == X_BIG_ENDIAN
# define SHIFT_L(value, shift) ((value) >> (shift))
# define SHIFT_R(value, shift) ((value) << (shift))
#else
# define SHIFT_L(value, shift) ((value) << (shift))
# define SHIFT_R(value, shift) ((value) >> (shift))
#endif

#ifndef MSBFIRST
# ifdef FIXEDBASE
#   define WRITE_IN_BITORDER(dest, offset, data) *(dest) = data; 
# else  
#   define WRITE_IN_BITORDER(dest, offset, data) *(dest + offset) = data;
# endif
#else	
# ifdef FIXEDBASE
#   define WRITE_IN_BITORDER(dest, offset, data) *(dest) = SWAP_BITS_IN_BYTES(data);
# else  
#   define WRITE_IN_BITORDER(dest, offset, data) *(dest + offset) = SWAP_BITS_IN_BYTES(data)
# endif
#endif

#ifdef FIXEDBASE
# ifdef MSBFIRST
#  define WRITE_BITS(b)   *base = SWAP_BITS_IN_BYTES(b)
#  define WRITE_BITS1(b) { \
	*base = byte_reversed_expand3[(b) & 0xFF] | \
		byte_reversed_expand3[((b) & 0xFF00) >> 8] << 24; }
#  define WRITE_BITS2(b) { \
	*base = byte_reversed_expand3[(b) & 0xFF] | \
		byte_reversed_expand3[((b) & 0xFF00) >> 8] << 24; \
	*base = byte_reversed_expand3[((b) & 0xFF00) >> 8] >> 8 | \
		byte_reversed_expand3[((b) & 0xFF0000) >> 16] << 16; }
#  define WRITE_BITS3(b) { \
	*base = byte_reversed_expand3[(b) & 0xFF] | \
		byte_reversed_expand3[((b) & 0xFF00) >> 8] << 24; \
	*base = byte_reversed_expand3[((b) & 0xFF00) >> 8] >> 8 | \
		byte_reversed_expand3[((b) & 0xFF0000) >> 16] << 16; \
	*base = byte_reversed_expand3[((b) & 0xFF0000) >> 16] >> 16 | \
		byte_reversed_expand3[((b) & 0xFF000000) >> 24] << 8; }
# else
#  define WRITE_BITS(b)   *base = (b)
#  define WRITE_BITS1(b) { \
	*base = byte_expand3[(b) & 0xFF] | \
		byte_expand3[((b) & 0xFF00) >> 8] << 24; }
#  define WRITE_BITS2(b) { \
	*base = byte_expand3[(b) & 0xFF] | \
		byte_expand3[((b) & 0xFF00) >> 8] << 24; \
	*base = byte_expand3[((b) & 0xFF00) >> 8] >> 8 | \
		byte_expand3[((b) & 0xFF0000) >> 16] << 16; }
#  define WRITE_BITS3(b) { \
	*base = byte_expand3[(b) & 0xFF] | \
		byte_expand3[((b) & 0xFF00) >> 8] << 24; \
	*base = byte_expand3[((b) & 0xFF00) >> 8] >> 8 | \
		byte_expand3[((b) & 0xFF0000) >> 16] << 16; \
	*base = byte_expand3[((b) & 0xFF0000) >> 16] >> 16 | \
		byte_expand3[((b) & 0xFF000000) >> 24] << 8; }
# endif
#else
# ifdef MSBFIRST
#  define WRITE_BITS(b)   *(base++) = SWAP_BITS_IN_BYTES(b)
#  define WRITE_BITS1(b) { \
	*(base++) = byte_reversed_expand3[(b) & 0xFF] | \
		byte_reversed_expand3[((b) & 0xFF00) >> 8] << 24; }
#  define WRITE_BITS2(b) { \
	*(base) = byte_reversed_expand3[(b) & 0xFF] | \
		byte_reversed_expand3[((b) & 0xFF00) >> 8] << 24; \
	*(base + 1) = byte_reversed_expand3[((b) & 0xFF00) >> 8] >> 8 | \
		byte_reversed_expand3[((b) & 0xFF0000) >> 16] << 16; \
	base += 2; }
#  define WRITE_BITS3(b) { \
	*(base) = byte_reversed_expand3[(b) & 0xFF] | \
		byte_reversed_expand3[((b) & 0xFF00) >> 8] << 24; \
	*(base + 1) = byte_reversed_expand3[((b) & 0xFF00) >> 8] >> 8 | \
		byte_reversed_expand3[((b) & 0xFF0000) >> 16] << 16; \
	*(base + 2) = byte_reversed_expand3[((b) & 0xFF0000) >> 16] >> 16 | \
		byte_reversed_expand3[((b) & 0xFF000000) >> 24] << 8; \
	base += 3; }
# else
#  define WRITE_BITS(b)   *(base++) = (b)
#  define WRITE_BITS1(b) { \
	*(base++) = byte_expand3[(b) & 0xFF] | \
		byte_expand3[((b) & 0xFF00) >> 8] << 24; }
#  define WRITE_BITS2(b) { \
	*(base) = byte_expand3[(b) & 0xFF] | \
		byte_expand3[((b) & 0xFF00) >> 8] << 24; \
	*(base + 1) = byte_expand3[((b) & 0xFF00) >> 8] >> 8 | \
		byte_expand3[((b) & 0xFF0000) >> 16] << 16; \
	base += 2; }
#  define WRITE_BITS3(b) { \
	*(base) = byte_expand3[(b) & 0xFF] | \
		byte_expand3[((b) & 0xFF00) >> 8] << 24; \
	*(base + 1) = byte_expand3[((b) & 0xFF00) >> 8] >> 8 | \
		byte_expand3[((b) & 0xFF0000) >> 16] << 16; \
	*(base + 2) = byte_expand3[((b) & 0xFF0000) >> 16] >> 16 | \
		byte_expand3[((b) & 0xFF000000) >> 24] << 8; \
	base += 3; }
# endif
#endif

#ifdef FIXEDBASE
# ifdef MSBFIRST
#  define EXPNAME(x) x##MSBFirstFixedBase
# else
#  define EXPNAME(x) x##LSBFirstFixedBase
# endif
#else
# ifdef MSBFIRST
#  define EXPNAME(x) x##MSBFirst
# else
#  define EXPNAME(x) x##LSBFirst
# endif
#endif