2 * linux/drivers/video/iplan2p8.c -- Low level frame buffer operations for
3 * interleaved bitplanes à la Atari (8
4 * planes, 2 bytes interleave)
6 * Created 5 Apr 1997 by Geert Uytterhoeven
8 * This file is subject to the terms and conditions of the GNU General Public
9 * License. See the file COPYING in the main directory of this archive for
13 #include <linux/string.h>
16 #include <asm/setup.h>
21 #include "atafb_utils.h"
24 /* Copies a 8 plane column from 's', height 'h', to 'd'. */
26 /* This expands a 8 bit color into two longs for two movepl (8 plane)
30 void atafb_iplan2p8_copyarea(struct fb_info
*info
, u_long next_line
,
31 int sy
, int sx
, int dy
, int dx
,
32 int height
, int width
)
34 /* bmove() has to distinguish two major cases: If both, source and
35 * destination, start at even addresses or both are at odd
36 * addresses, just the first odd and last even column (if present)
37 * require special treatment (memmove_col()). The rest between
38 * then can be copied by normal operations, because all adjacent
39 * bytes are affected and are to be stored in the same order.
40 * The pathological case is when the move should go from an odd
41 * address to an even or vice versa. Since the bytes in the plane
42 * words must be assembled in new order, it seems wisest to make
43 * all movements by memmove_col().
50 u_int upwards
= (dy
< sy
) || (dy
== sy
&& dx
< sx
);
53 if (!((sx
^ dx
) & 15)) {
54 /* odd->odd or even->even */
57 src
= (u8
*)info
->screen_base
+ sy
* next_line
+ (sx
& ~15) / (8 / BPL
);
58 dst
= (u8
*)info
->screen_base
+ dy
* next_line
+ (dx
& ~15) / (8 / BPL
);
60 memmove32_col(dst
, src
, 0xff00ff, height
, next_line
- BPL
* 2);
70 l
= next_line
- w
* 4;
71 for (j
= height
; j
> 0; j
--) {
72 for (i
= w
; i
> 0; i
--)
74 s
= (u32
*)((u8
*)s
+ l
);
75 d
= (u32
*)((u8
*)d
+ l
);
79 memmove32_col(dst
+ width
/ (8 / BPL
), src
+ width
/ (8 / BPL
),
80 0xff00ff00, height
, next_line
- BPL
* 2);
82 src
= (u8
*)info
->screen_base
+ (sy
- 1) * next_line
+ ((sx
+ width
+ 8) & ~15) / (8 / BPL
);
83 dst
= (u8
*)info
->screen_base
+ (dy
- 1) * next_line
+ ((dx
+ width
+ 8) & ~15) / (8 / BPL
);
85 if ((sx
+ width
) & 15) {
88 memmove32_col(dst
, src
, 0xff00ff00, colsize
, -next_line
- BPL
* 2);
96 l
= next_line
- w
* 4;
97 for (j
= height
; j
> 0; j
--) {
98 for (i
= w
; i
> 0; i
--)
100 s
= (u32
*)((u8
*)s
- l
);
101 d
= (u32
*)((u8
*)d
- l
);
105 memmove32_col(dst
- (width
- 16) / (8 / BPL
),
106 src
- (width
- 16) / (8 / BPL
),
107 0xff00ff, colsize
, -next_line
- BPL
* 2);
110 /* odd->even or even->odd */
113 u32 pval
[4], v
, v1
, mask
;
116 src
= (u8
*)info
->screen_base
+ sy
* next_line
+ (sx
& ~15) / (8 / BPL
);
117 dst
= (u8
*)info
->screen_base
+ dy
* next_line
+ (dx
& ~15) / (8 / BPL
);
126 if ((sx
+ width
) & 15)
129 for (i
= height
; i
; i
--) {
134 pval
[0] = (*src32
++ << 8) & mask
;
135 pval
[1] = (*src32
++ << 8) & mask
;
136 pval
[2] = (*src32
++ << 8) & mask
;
137 pval
[3] = (*src32
++ << 8) & mask
;
139 pval
[0] = dst32
[0] & mask
;
140 pval
[1] = dst32
[1] & mask
;
141 pval
[2] = dst32
[2] & mask
;
142 pval
[3] = dst32
[3] & mask
;
145 for (j
= w
; j
> 0; j
--) {
148 *dst32
++ = pval
[0] | (v1
>> 8);
149 pval
[0] = (v
^ v1
) << 8;
152 *dst32
++ = pval
[1] | (v1
>> 8);
153 pval
[1] = (v
^ v1
) << 8;
156 *dst32
++ = pval
[2] | (v1
>> 8);
157 pval
[2] = (v
^ v1
) << 8;
160 *dst32
++ = pval
[3] | (v1
>> 8);
161 pval
[3] = (v
^ v1
) << 8;
165 dst32
[0] = (dst32
[0] & mask
) | pval
[0];
166 dst32
[1] = (dst32
[1] & mask
) | pval
[1];
167 dst32
[2] = (dst32
[2] & mask
) | pval
[2];
168 dst32
[3] = (dst32
[3] & mask
) | pval
[3];
176 u32 pval
[4], v
, v1
, mask
;
179 src
= (u8
*)info
->screen_base
+ (sy
- 1) * next_line
+ ((sx
+ width
+ 8) & ~15) / (8 / BPL
);
180 dst
= (u8
*)info
->screen_base
+ (dy
- 1) * next_line
+ ((dx
+ width
+ 8) & ~15) / (8 / BPL
);
185 if ((dx
+ width
) & 15)
192 for (i
= height
; i
; i
--) {
197 pval
[0] = dst32
[-1] & mask
;
198 pval
[1] = dst32
[-2] & mask
;
199 pval
[2] = dst32
[-3] & mask
;
200 pval
[3] = dst32
[-4] & mask
;
202 pval
[0] = (*--src32
>> 8) & mask
;
203 pval
[1] = (*--src32
>> 8) & mask
;
204 pval
[2] = (*--src32
>> 8) & mask
;
205 pval
[3] = (*--src32
>> 8) & mask
;
208 for (j
= w
; j
> 0; j
--) {
211 *--dst32
= pval
[0] | (v1
<< 8);
212 pval
[0] = (v
^ v1
) >> 8;
215 *--dst32
= pval
[1] | (v1
<< 8);
216 pval
[1] = (v
^ v1
) >> 8;
219 *--dst32
= pval
[2] | (v1
<< 8);
220 pval
[2] = (v
^ v1
) >> 8;
223 *--dst32
= pval
[3] | (v1
<< 8);
224 pval
[3] = (v
^ v1
) >> 8;
228 dst32
[-1] = (dst32
[-1] & mask
) | pval
[0];
229 dst32
[-2] = (dst32
[-2] & mask
) | pval
[1];
230 dst32
[-3] = (dst32
[-3] & mask
) | pval
[2];
231 dst32
[-4] = (dst32
[-4] & mask
) | pval
[3];
241 void atafb_iplan2p8_fillrect(struct fb_info
*info
, u_long next_line
, u32 color
,
242 int sy
, int sx
, int height
, int width
)
248 dest
= (u32
*)(info
->screen_base
+ sy
* next_line
+ (sx
& ~15) / (8 / BPL
));
250 u8
*dest8
= (u8
*)dest
+ 1;
252 expand8_col2mask(color
, cval
);
254 for (i
= height
; i
; i
--) {
255 fill8_col(dest8
, cval
);
262 expand16_col2mask(color
, cval
);
266 u32 off
= next_line
- rows
* BPL
* 2;
267 for (i
= height
; i
; i
--) {
268 d
= fill16_col(d
, rows
, cval
);
269 d
= (u32
*)((long)d
+ off
);
271 dest
+= rows
* BPL
/ 2;
276 u8
*dest8
= (u8
*)dest
;
278 expand8_col2mask(color
, cval
);
280 for (i
= height
; i
; i
--) {
281 fill8_col(dest8
, cval
);
287 void atafb_iplan2p8_linefill(struct fb_info
*info
, u_long next_line
,
288 int dy
, int dx
, u32 width
,
289 const u8
*data
, u32 bgcolor
, u32 fgcolor
)
294 u32 fgm
[4], bgm
[4], m
;
296 dest
= (u32
*)(info
->screen_base
+ dy
* next_line
+ (dx
& ~15) / (8 / BPL
));
298 fill8_2col((u8
*)dest
+ 1, fgcolor
, bgcolor
, *data
++);
304 data16
= (const u16
*)data
;
305 expand16_2col2mask(fgcolor
, bgcolor
, fgm
, bgm
);
307 for (rows
= width
/ 16; rows
; rows
--) {
309 m
= d
| ((u32
)d
<< 16);
310 *dest
++ = (m
& fgm
[0]) ^ bgm
[0];
311 *dest
++ = (m
& fgm
[1]) ^ bgm
[1];
312 *dest
++ = (m
& fgm
[2]) ^ bgm
[2];
313 *dest
++ = (m
& fgm
[3]) ^ bgm
[3];
316 data
= (const u8
*)data16
;
321 fill8_2col((u8
*)dest
, fgcolor
, bgcolor
, *data
);