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/module.h>
14 #include <linux/string.h>
17 #include <asm/setup.h>
22 #include "atafb_utils.h"
24 void atafb_iplan2p2_copyarea(struct fb_info *info, u_long next_line,
25 int sy, int sx, int dy, int dx,
26 int height, int width)
28 /* bmove() has to distinguish two major cases: If both, source and
29 * destination, start at even addresses or both are at odd
30 * addresses, just the first odd and last even column (if present)
31 * require special treatment (memmove_col()). The rest between
32 * then can be copied by normal operations, because all adjacent
33 * bytes are affected and are to be stored in the same order.
34 * The pathological case is when the move should go from an odd
35 * address to an even or vice versa. Since the bytes in the plane
36 * words must be assembled in new order, it seems wisest to make
37 * all movements by memmove_col().
44 u_int upwards = (dy < sy) || (dy == sy && dx < sx);
47 if (!((sx ^ dx) & 15)) {
48 /* odd->odd or even->even */
51 src = (u8 *)info->screen_base + sy * next_line + (sx & ~15) / (8 / BPL);
52 dst = (u8 *)info->screen_base + dy * next_line + (dx & ~15) / (8 / BPL);
54 memmove32_col(dst, src, 0xff00ff, height, next_line - BPL * 2);
64 l = next_line - w * 4;
65 for (j = height; j > 0; j--) {
66 for (i = w; i > 0; i--)
68 s = (u32 *)((u8 *)s + l);
69 d = (u32 *)((u8 *)d + l);
73 memmove32_col(dst + width / (8 / BPL), src + width / (8 / BPL),
74 0xff00ff00, height, next_line - BPL * 2);
76 src = (u8 *)info->screen_base + (sy - 1) * next_line + ((sx + width + 8) & ~15) / (8 / BPL);
77 dst = (u8 *)info->screen_base + (dy - 1) * next_line + ((dx + width + 8) & ~15) / (8 / BPL);
79 if ((sx + width) & 15) {
82 memmove32_col(dst, src, 0xff00ff00, colsize, -next_line - BPL * 2);
90 l = next_line - w * 4;
91 for (j = height; j > 0; j--) {
92 for (i = w; i > 0; i--)
94 s = (u32 *)((u8 *)s - l);
95 d = (u32 *)((u8 *)d - l);
99 memmove32_col(dst - (width - 16) / (8 / BPL),
100 src - (width - 16) / (8 / BPL),
101 0xff00ff, colsize, -next_line - BPL * 2);
104 /* odd->even or even->odd */
107 u32 pval[4], v, v1, mask;
110 src = (u8 *)info->screen_base + sy * next_line + (sx & ~15) / (8 / BPL);
111 dst = (u8 *)info->screen_base + dy * next_line + (dx & ~15) / (8 / BPL);
120 if ((sx + width) & 15)
123 for (i = height; i; i--) {
128 pval[0] = (*src32++ << 8) & mask;
130 pval[0] = dst32[0] & mask;
133 for (j = w; j > 0; j--) {
136 *dst32++ = pval[0] | (v1 >> 8);
137 pval[0] = (v ^ v1) << 8;
141 dst32[0] = (dst32[0] & mask) | pval[0];
149 u32 pval[4], v, v1, mask;
152 src = (u8 *)info->screen_base + (sy - 1) * next_line + ((sx + width + 8) & ~15) / (8 / BPL);
153 dst = (u8 *)info->screen_base + (dy - 1) * next_line + ((dx + width + 8) & ~15) / (8 / BPL);
158 if ((dx + width) & 15)
165 for (i = height; i; i--) {
170 pval[0] = dst32[-1] & mask;
172 pval[0] = (*--src32 >> 8) & mask;
175 for (j = w; j > 0; j--) {
178 *--dst32 = pval[0] | (v1 << 8);
179 pval[0] = (v ^ v1) >> 8;
183 dst32[-1] = (dst32[-1] & mask) | pval[0];
193 void atafb_iplan2p2_fillrect(struct fb_info *info, u_long next_line, u32 color,
194 int sy, int sx, int height, int width)
200 dest = (u32 *)(info->screen_base + sy * next_line + (sx & ~15) / (8 / BPL));
202 u8 *dest8 = (u8 *)dest + 1;
204 expand8_col2mask(color, cval);
206 for (i = height; i; i--) {
207 fill8_col(dest8, cval);
214 expand16_col2mask(color, cval);
218 u32 off = next_line - rows * BPL * 2;
219 for (i = height; i; i--) {
220 d = fill16_col(d, rows, cval);
221 d = (u32 *)((long)d + off);
223 dest += rows * BPL / 2;
228 u8 *dest8 = (u8 *)dest;
230 expand8_col2mask(color, cval);
232 for (i = height; i; i--) {
233 fill8_col(dest8, cval);
239 void atafb_iplan2p2_linefill(struct fb_info *info, u_long next_line,
240 int dy, int dx, u32 width,
241 const u8 *data, u32 bgcolor, u32 fgcolor)
246 u32 fgm[4], bgm[4], m;
248 dest = (u32 *)(info->screen_base + dy * next_line + (dx & ~15) / (8 / BPL));
250 fill8_2col((u8 *)dest + 1, fgcolor, bgcolor, *data++);
256 data16 = (const u16 *)data;
257 expand16_2col2mask(fgcolor, bgcolor, fgm, bgm);
259 for (rows = width / 16; rows; rows--) {
261 m = d | ((u32)d << 16);
262 *dest++ = (m & fgm[0]) ^ bgm[0];
265 data = (const u8 *)data16;
270 fill8_2col((u8 *)dest, fgcolor, bgcolor, *data);
274 MODULE_LICENSE("GPL");
276 int init_module(void)
281 void cleanup_module(void)
288 * Visible symbols for modules
291 EXPORT_SYMBOL(atafb_iplan2p2_copyarea);
292 EXPORT_SYMBOL(atafb_iplan2p2_fillrect);
293 EXPORT_SYMBOL(atafb_iplan2p2_linefill);