2 * linux/drivers/video/iplan2p4.c -- Low level frame buffer operations for
3 * interleaved bitplanes à la Atari (4
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_iplan2p4_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
;
128 pval
[1] = (*src32
++ << 8) & mask
;
130 pval
[0] = dst32
[0] & mask
;
131 pval
[1] = dst32
[1] & mask
;
134 for (j
= w
; j
> 0; j
--) {
137 *dst32
++ = pval
[0] | (v1
>> 8);
138 pval
[0] = (v
^ v1
) << 8;
141 *dst32
++ = pval
[1] | (v1
>> 8);
142 pval
[1] = (v
^ v1
) << 8;
146 dst32
[0] = (dst32
[0] & mask
) | pval
[0];
147 dst32
[1] = (dst32
[1] & mask
) | pval
[1];
155 u32 pval
[4], v
, v1
, mask
;
158 src
= (u8
*)info
->screen_base
+ (sy
- 1) * next_line
+ ((sx
+ width
+ 8) & ~15) / (8 / BPL
);
159 dst
= (u8
*)info
->screen_base
+ (dy
- 1) * next_line
+ ((dx
+ width
+ 8) & ~15) / (8 / BPL
);
164 if ((dx
+ width
) & 15)
171 for (i
= height
; i
; i
--) {
176 pval
[0] = dst32
[-1] & mask
;
177 pval
[1] = dst32
[-2] & mask
;
179 pval
[0] = (*--src32
>> 8) & mask
;
180 pval
[1] = (*--src32
>> 8) & mask
;
183 for (j
= w
; j
> 0; j
--) {
186 *--dst32
= pval
[0] | (v1
<< 8);
187 pval
[0] = (v
^ v1
) >> 8;
190 *--dst32
= pval
[1] | (v1
<< 8);
191 pval
[1] = (v
^ v1
) >> 8;
195 dst32
[-1] = (dst32
[-1] & mask
) | pval
[0];
196 dst32
[-2] = (dst32
[-2] & mask
) | pval
[1];
206 void atafb_iplan2p4_fillrect(struct fb_info
*info
, u_long next_line
, u32 color
,
207 int sy
, int sx
, int height
, int width
)
213 dest
= (u32
*)(info
->screen_base
+ sy
* next_line
+ (sx
& ~15) / (8 / BPL
));
215 u8
*dest8
= (u8
*)dest
+ 1;
217 expand8_col2mask(color
, cval
);
219 for (i
= height
; i
; i
--) {
220 fill8_col(dest8
, cval
);
227 expand16_col2mask(color
, cval
);
231 u32 off
= next_line
- rows
* BPL
* 2;
232 for (i
= height
; i
; i
--) {
233 d
= fill16_col(d
, rows
, cval
);
234 d
= (u32
*)((long)d
+ off
);
236 dest
+= rows
* BPL
/ 2;
241 u8
*dest8
= (u8
*)dest
;
243 expand8_col2mask(color
, cval
);
245 for (i
= height
; i
; i
--) {
246 fill8_col(dest8
, cval
);
252 void atafb_iplan2p4_linefill(struct fb_info
*info
, u_long next_line
,
253 int dy
, int dx
, u32 width
,
254 const u8
*data
, u32 bgcolor
, u32 fgcolor
)
259 u32 fgm
[4], bgm
[4], m
;
261 dest
= (u32
*)(info
->screen_base
+ dy
* next_line
+ (dx
& ~15) / (8 / BPL
));
263 fill8_2col((u8
*)dest
+ 1, fgcolor
, bgcolor
, *data
++);
269 data16
= (const u16
*)data
;
270 expand16_2col2mask(fgcolor
, bgcolor
, fgm
, bgm
);
272 for (rows
= width
/ 16; rows
; rows
--) {
274 m
= d
| ((u32
)d
<< 16);
275 *dest
++ = (m
& fgm
[0]) ^ bgm
[0];
276 *dest
++ = (m
& fgm
[1]) ^ bgm
[1];
279 data
= (const u8
*)data16
;
284 fill8_2col((u8
*)dest
, fgcolor
, bgcolor
, *data
);