This source file includes following definitions.
- atafb_iplan2p2_copyarea
- atafb_iplan2p2_fillrect
- atafb_iplan2p2_linefill
1
2
3
4
5
6
7
8
9
10
11
12
13 #include <linux/string.h>
14 #include <linux/fb.h>
15
16 #include <asm/setup.h>
17
18 #include "atafb.h"
19
20 #define BPL 2
21 #include "atafb_utils.h"
22
23 void atafb_iplan2p2_copyarea(struct fb_info *info, u_long next_line,
24 int sy, int sx, int dy, int dx,
25 int height, int width)
26 {
27
28
29
30
31
32
33
34
35
36
37
38
39 u8 *src, *dst;
40 u32 *s, *d;
41 int w, l , i, j;
42 u_int colsize;
43 u_int upwards = (dy < sy) || (dy == sy && dx < sx);
44
45 colsize = height;
46 if (!((sx ^ dx) & 15)) {
47
48
49 if (upwards) {
50 src = (u8 *)info->screen_base + sy * next_line + (sx & ~15) / (8 / BPL);
51 dst = (u8 *)info->screen_base + dy * next_line + (dx & ~15) / (8 / BPL);
52 if (sx & 15) {
53 memmove32_col(dst, src, 0xff00ff, height, next_line - BPL * 2);
54 src += BPL * 2;
55 dst += BPL * 2;
56 width -= 8;
57 }
58 w = width >> 4;
59 if (w) {
60 s = (u32 *)src;
61 d = (u32 *)dst;
62 w *= BPL / 2;
63 l = next_line - w * 4;
64 for (j = height; j > 0; j--) {
65 for (i = w; i > 0; i--)
66 *d++ = *s++;
67 s = (u32 *)((u8 *)s + l);
68 d = (u32 *)((u8 *)d + l);
69 }
70 }
71 if (width & 15)
72 memmove32_col(dst + width / (8 / BPL), src + width / (8 / BPL),
73 0xff00ff00, height, next_line - BPL * 2);
74 } else {
75 src = (u8 *)info->screen_base + (sy - 1) * next_line + ((sx + width + 8) & ~15) / (8 / BPL);
76 dst = (u8 *)info->screen_base + (dy - 1) * next_line + ((dx + width + 8) & ~15) / (8 / BPL);
77
78 if ((sx + width) & 15) {
79 src -= BPL * 2;
80 dst -= BPL * 2;
81 memmove32_col(dst, src, 0xff00ff00, colsize, -next_line - BPL * 2);
82 width -= 8;
83 }
84 w = width >> 4;
85 if (w) {
86 s = (u32 *)src;
87 d = (u32 *)dst;
88 w *= BPL / 2;
89 l = next_line - w * 4;
90 for (j = height; j > 0; j--) {
91 for (i = w; i > 0; i--)
92 *--d = *--s;
93 s = (u32 *)((u8 *)s - l);
94 d = (u32 *)((u8 *)d - l);
95 }
96 }
97 if (sx & 15)
98 memmove32_col(dst - (width - 16) / (8 / BPL),
99 src - (width - 16) / (8 / BPL),
100 0xff00ff, colsize, -next_line - BPL * 2);
101 }
102 } else {
103
104 if (upwards) {
105 u32 *src32, *dst32;
106 u32 pval[4], v, v1, mask;
107 int i, j, w, f;
108
109 src = (u8 *)info->screen_base + sy * next_line + (sx & ~15) / (8 / BPL);
110 dst = (u8 *)info->screen_base + dy * next_line + (dx & ~15) / (8 / BPL);
111
112 mask = 0xff00ff00;
113 f = 0;
114 w = width;
115 if (sx & 15) {
116 f = 1;
117 w += 8;
118 }
119 if ((sx + width) & 15)
120 f |= 2;
121 w >>= 4;
122 for (i = height; i; i--) {
123 src32 = (u32 *)src;
124 dst32 = (u32 *)dst;
125
126 if (f & 1) {
127 pval[0] = (*src32++ << 8) & mask;
128 } else {
129 pval[0] = dst32[0] & mask;
130 }
131
132 for (j = w; j > 0; j--) {
133 v = *src32++;
134 v1 = v & mask;
135 *dst32++ = pval[0] | (v1 >> 8);
136 pval[0] = (v ^ v1) << 8;
137 }
138
139 if (f & 2) {
140 dst32[0] = (dst32[0] & mask) | pval[0];
141 }
142
143 src += next_line;
144 dst += next_line;
145 }
146 } else {
147 u32 *src32, *dst32;
148 u32 pval[4], v, v1, mask;
149 int i, j, w, f;
150
151 src = (u8 *)info->screen_base + (sy - 1) * next_line + ((sx + width + 8) & ~15) / (8 / BPL);
152 dst = (u8 *)info->screen_base + (dy - 1) * next_line + ((dx + width + 8) & ~15) / (8 / BPL);
153
154 mask = 0xff00ff;
155 f = 0;
156 w = width;
157 if ((dx + width) & 15)
158 f = 1;
159 if (sx & 15) {
160 f |= 2;
161 w += 8;
162 }
163 w >>= 4;
164 for (i = height; i; i--) {
165 src32 = (u32 *)src;
166 dst32 = (u32 *)dst;
167
168 if (f & 1) {
169 pval[0] = dst32[-1] & mask;
170 } else {
171 pval[0] = (*--src32 >> 8) & mask;
172 }
173
174 for (j = w; j > 0; j--) {
175 v = *--src32;
176 v1 = v & mask;
177 *--dst32 = pval[0] | (v1 << 8);
178 pval[0] = (v ^ v1) >> 8;
179 }
180
181 if (!(f & 2)) {
182 dst32[-1] = (dst32[-1] & mask) | pval[0];
183 }
184
185 src -= next_line;
186 dst -= next_line;
187 }
188 }
189 }
190 }
191
192 void atafb_iplan2p2_fillrect(struct fb_info *info, u_long next_line, u32 color,
193 int sy, int sx, int height, int width)
194 {
195 u32 *dest;
196 int rows, i;
197 u32 cval[4];
198
199 dest = (u32 *)(info->screen_base + sy * next_line + (sx & ~15) / (8 / BPL));
200 if (sx & 15) {
201 u8 *dest8 = (u8 *)dest + 1;
202
203 expand8_col2mask(color, cval);
204
205 for (i = height; i; i--) {
206 fill8_col(dest8, cval);
207 dest8 += next_line;
208 }
209 dest += BPL / 2;
210 width -= 8;
211 }
212
213 expand16_col2mask(color, cval);
214 rows = width >> 4;
215 if (rows) {
216 u32 *d = dest;
217 u32 off = next_line - rows * BPL * 2;
218 for (i = height; i; i--) {
219 d = fill16_col(d, rows, cval);
220 d = (u32 *)((long)d + off);
221 }
222 dest += rows * BPL / 2;
223 width &= 15;
224 }
225
226 if (width) {
227 u8 *dest8 = (u8 *)dest;
228
229 expand8_col2mask(color, cval);
230
231 for (i = height; i; i--) {
232 fill8_col(dest8, cval);
233 dest8 += next_line;
234 }
235 }
236 }
237
238 void atafb_iplan2p2_linefill(struct fb_info *info, u_long next_line,
239 int dy, int dx, u32 width,
240 const u8 *data, u32 bgcolor, u32 fgcolor)
241 {
242 u32 *dest;
243 const u16 *data16;
244 int rows;
245 u32 fgm[4], bgm[4], m;
246
247 dest = (u32 *)(info->screen_base + dy * next_line + (dx & ~15) / (8 / BPL));
248 if (dx & 15) {
249 fill8_2col((u8 *)dest + 1, fgcolor, bgcolor, *data++);
250 dest += BPL / 2;
251 width -= 8;
252 }
253
254 if (width >= 16) {
255 data16 = (const u16 *)data;
256 expand16_2col2mask(fgcolor, bgcolor, fgm, bgm);
257
258 for (rows = width / 16; rows; rows--) {
259 u16 d = *data16++;
260 m = d | ((u32)d << 16);
261 *dest++ = (m & fgm[0]) ^ bgm[0];
262 }
263
264 data = (const u8 *)data16;
265 width &= 15;
266 }
267
268 if (width)
269 fill8_2col((u8 *)dest, fgcolor, bgcolor, *data);
270 }