2 * linux/drivers/video/cfb4.c -- Low level frame buffer operations for 4 bpp
5 * Created 26 Dec 1997 by Michael Schmitz
6 * Based on the old macfb.c 4bpp code by Alan Cox
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/tty.h>
15 #include <linux/console.h>
16 #include <linux/string.h>
19 #include <video/fbcon.h>
20 #include <video/fbcon-cfb4.h>
28 * IFF the font is even pixel aligned (that is to say each
29 * character start is a byte start in the pixel pairs). That
30 * avoids us having to mask bytes and means we won't be here
31 * all week. On a MacII that matters _lots_
34 static u16 nibbletab_cfb4
[] = {
35 #if defined(__BIG_ENDIAN)
36 0x0000,0x000f,0x00f0,0x00ff,
37 0x0f00,0x0f0f,0x0ff0,0x0fff,
38 0xf000,0xf00f,0xf0f0,0xf0ff,
39 0xff00,0xff0f,0xfff0,0xffff
40 #elif defined(__LITTLE_ENDIAN)
41 0x0000,0xf000,0x0f00,0xff00,
42 0x00f0,0xf0f0,0x0ff0,0xfff0,
43 0x000f,0xf00f,0x0f0f,0xff0f,
44 0x00ff,0xf0ff,0x0fff,0xffff
46 #error FIXME: No endianness??
51 void fbcon_cfb4_setup(struct display
*p
)
53 p
->next_line
= p
->line_length
? p
->line_length
: p
->var
.xres_virtual
>>1;
57 void fbcon_cfb4_bmove(struct display
*p
, int sy
, int sx
, int dy
, int dx
,
58 int height
, int width
)
60 int bytes
= p
->next_line
, linesize
= bytes
* fontheight(p
), rows
;
63 if (sx
== 0 && dx
== 0 && width
* 4 == bytes
) {
64 mymemmove(p
->screen_base
+ dy
* linesize
,
65 p
->screen_base
+ sy
* linesize
,
69 if (dy
< sy
|| (dy
== sy
&& dx
< sx
)) {
70 src
= p
->screen_base
+ sy
* linesize
+ sx
* 4;
71 dst
= p
->screen_base
+ dy
* linesize
+ dx
* 4;
72 for (rows
= height
* fontheight(p
) ; rows
-- ;) {
73 mymemmove(dst
, src
, width
* 4);
79 src
= p
->screen_base
+ (sy
+height
) * linesize
+ sx
* 4
81 dst
= p
->screen_base
+ (dy
+height
) * linesize
+ dx
* 4
83 for (rows
= height
* fontheight(p
) ; rows
-- ;) {
84 mymemmove(dst
, src
, width
* 4);
92 void fbcon_cfb4_clear(struct vc_data
*conp
, struct display
*p
, int sy
, int sx
,
93 int height
, int width
)
96 int bytes
=p
->next_line
,lines
=height
* fontheight(p
), rows
, i
;
99 /* if(p->screen_base!=0xFDD00020)
101 dest
= p
->screen_base
+ sy
* fontheight(p
) * bytes
+ sx
* 4;
103 bgx
=attr_bgcol_ec(p
,conp
);
104 bgx
|= (bgx
<< 4); /* expand the colour to 32bits */
108 if (sx
== 0 && width
* 4 == bytes
) {
109 for (i
= 0 ; i
< lines
* width
; i
++) {
110 ((u32
*)dest
)[0]=bgx
;
115 for (rows
= lines
; rows
-- ; dest0
+= bytes
) {
117 for (i
= 0 ; i
< width
; i
++) {
119 ((u32
*)dest
)[0]=bgx
;
126 void fbcon_cfb4_putc(struct vc_data
*conp
, struct display
*p
, int c
, int yy
,
130 int bytes
=p
->next_line
,rows
;
133 dest
= p
->screen_base
+ yy
* fontheight(p
) * bytes
+ xx
* 4;
134 cdat
= p
->fontdata
+ (c
& p
->charmask
) * fontheight(p
);
144 for (rows
= fontheight(p
) ; rows
-- ; dest
+= bytes
) {
146 (nibbletab_cfb4
[*cdat
>> 4] & eorx
) ^ bgx
;
148 (nibbletab_cfb4
[*cdat
++ & 0xf] & eorx
) ^ bgx
;
152 void fbcon_cfb4_putcs(struct vc_data
*conp
, struct display
*p
,
153 const unsigned short *s
, int count
, int yy
, int xx
)
155 u8
*cdat
, *dest
, *dest0
;
157 int rows
,bytes
=p
->next_line
;
160 dest0
= p
->screen_base
+ yy
* fontheight(p
) * bytes
+ xx
* 4;
161 fgx
=attr_fgcol(p
,scr_readw(s
));
162 bgx
=attr_bgcol(p
,scr_readw(s
));
171 c
= scr_readw(s
++) & p
->charmask
;
172 cdat
= p
->fontdata
+ c
* fontheight(p
);
174 for (rows
= fontheight(p
), dest
= dest0
; rows
-- ; dest
+= bytes
) {
176 (nibbletab_cfb4
[*cdat
>> 4] & eorx
) ^ bgx
;
178 (nibbletab_cfb4
[*cdat
++ & 0xf] & eorx
) ^ bgx
;
184 void fbcon_cfb4_revc(struct display
*p
, int xx
, int yy
)
187 int bytes
=p
->next_line
, rows
;
189 dest
= p
->screen_base
+ yy
* fontheight(p
) * bytes
+ xx
* 4;
190 for (rows
= fontheight(p
) ; rows
-- ; dest
+= bytes
) {
191 ((u32
*)dest
)[0] ^= 0xffffffff;
197 * `switch' for the low level operations
200 struct display_switch fbcon_cfb4
= {
201 fbcon_cfb4_setup
, fbcon_cfb4_bmove
, fbcon_cfb4_clear
, fbcon_cfb4_putc
,
202 fbcon_cfb4_putcs
, fbcon_cfb4_revc
, NULL
, NULL
, NULL
, FONTWIDTH(8)
207 int init_module(void)
212 void cleanup_module(void)
218 * Visible symbols for modules
221 EXPORT_SYMBOL(fbcon_cfb4
);
222 EXPORT_SYMBOL(fbcon_cfb4_setup
);
223 EXPORT_SYMBOL(fbcon_cfb4_bmove
);
224 EXPORT_SYMBOL(fbcon_cfb4_clear
);
225 EXPORT_SYMBOL(fbcon_cfb4_putc
);
226 EXPORT_SYMBOL(fbcon_cfb4_putcs
);
227 EXPORT_SYMBOL(fbcon_cfb4_revc
);