2 * linux/drivers/video/iplan2p2.c -- Low level frame buffer operations for
3 * interleaved bitplanes à la Atari (2
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"
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
)
27 /* bmove() has to distinguish two major cases: If both, source and
28 * destination, start at even addresses or both are at odd
29 * addresses, just the first odd and last even column (if present)
30 * require special treatment (memmove_col()). The rest between
31 * then can be copied by normal operations, because all adjacent
32 * bytes are affected and are to be stored in the same order.
33 * The pathological case is when the move should go from an odd
34 * address to an even or vice versa. Since the bytes in the plane
35 * words must be assembled in new order, it seems wisest to make
36 * all movements by memmove_col().
43 u_int upwards
= (dy
< sy
) || (dy
== sy
&& dx
< sx
);
46 if (!((sx
^ dx
) & 15)) {
47 /* odd->odd or even->even */
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
);
53 memmove32_col(dst
, src
, 0xff00ff, height
, next_line
- BPL
* 2);
63 l
= next_line
- w
* 4;
64 for (j
= height
; j
> 0; j
--) {
65 for (i
= w
; i
> 0; i
--)
67 s
= (u32
*)((u8
*)s
+ l
);
68 d
= (u32
*)((u8
*)d
+ l
);
72 memmove32_col(dst
+ width
/ (8 / BPL
), src
+ width
/ (8 / BPL
),
73 0xff00ff00, height
, next_line
- BPL
* 2);
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
);
78 if ((sx
+ width
) & 15) {
81 memmove32_col(dst
, src
, 0xff00ff00, colsize
, -next_line
- BPL
* 2);
89 l
= next_line
- w
* 4;
90 for (j
= height
; j
> 0; j
--) {
91 for (i
= w
; i
> 0; i
--)
93 s
= (u32
*)((u8
*)s
- l
);
94 d
= (u32
*)((u8
*)d
- l
);
98 memmove32_col(dst
- (width
- 16) / (8 / BPL
),
99 src
- (width
- 16) / (8 / BPL
),
100 0xff00ff, colsize
, -next_line
- BPL
* 2);
103 /* odd->even or even->odd */
106 u32 pval
[4], v
, v1
, mask
;
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
);
119 if ((sx
+ width
) & 15)
122 for (i
= height
; i
; i
--) {
127 pval
[0] = (*src32
++ << 8) & mask
;
129 pval
[0] = dst32
[0] & mask
;
132 for (j
= w
; j
> 0; j
--) {
135 *dst32
++ = pval
[0] | (v1
>> 8);
136 pval
[0] = (v
^ v1
) << 8;
140 dst32
[0] = (dst32
[0] & mask
) | pval
[0];
148 u32 pval
[4], v
, v1
, mask
;
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
);
157 if ((dx
+ width
) & 15)
164 for (i
= height
; i
; i
--) {
169 pval
[0] = dst32
[-1] & mask
;
171 pval
[0] = (*--src32
>> 8) & mask
;
174 for (j
= w
; j
> 0; j
--) {
177 *--dst32
= pval
[0] | (v1
<< 8);
178 pval
[0] = (v
^ v1
) >> 8;
182 dst32
[-1] = (dst32
[-1] & mask
) | pval
[0];
192 void atafb_iplan2p2_fillrect(struct fb_info
*info
, u_long next_line
, u32 color
,
193 int sy
, int sx
, int height
, int width
)
199 dest
= (u32
*)(info
->screen_base
+ sy
* next_line
+ (sx
& ~15) / (8 / BPL
));
201 u8
*dest8
= (u8
*)dest
+ 1;
203 expand8_col2mask(color
, cval
);
205 for (i
= height
; i
; i
--) {
206 fill8_col(dest8
, cval
);
213 expand16_col2mask(color
, cval
);
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
);
222 dest
+= rows
* BPL
/ 2;
227 u8
*dest8
= (u8
*)dest
;
229 expand8_col2mask(color
, cval
);
231 for (i
= height
; i
; i
--) {
232 fill8_col(dest8
, cval
);
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
)
245 u32 fgm
[4], bgm
[4], m
;
247 dest
= (u32
*)(info
->screen_base
+ dy
* next_line
+ (dx
& ~15) / (8 / BPL
));
249 fill8_2col((u8
*)dest
+ 1, fgcolor
, bgcolor
, *data
++);
255 data16
= (const u16
*)data
;
256 expand16_2col2mask(fgcolor
, bgcolor
, fgm
, bgm
);
258 for (rows
= width
/ 16; rows
; rows
--) {
260 m
= d
| ((u32
)d
<< 16);
261 *dest
++ = (m
& fgm
[0]) ^ bgm
[0];
264 data
= (const u8
*)data16
;
269 fill8_2col((u8
*)dest
, fgcolor
, bgcolor
, *data
);