2 * linux/drivers/video/cfb2.c -- Low level frame buffer operations for 2 bpp
5 * Created 26 Dec 1997 by Michael Schmitz
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-cfb2.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 u_char nibbletab_cfb2
[]={
35 #if defined(__BIG_ENDIAN)
40 #elif defined(__LITTLE_ENDIAN)
46 #error FIXME: No endianness??
51 void fbcon_cfb2_setup(struct display
*p
)
53 p
->next_line
= p
->line_length
? p
->line_length
: p
->var
.xres_virtual
>>2;
57 void fbcon_cfb2_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
* 2 == 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
* 2;
71 dst
= p
->screen_base
+ dy
* linesize
+ dx
* 2;
72 for (rows
= height
* fontheight(p
) ; rows
-- ;) {
73 mymemmove(dst
, src
, width
* 2);
79 src
= p
->screen_base
+ (sy
+height
) * linesize
+ sx
* 2
81 dst
= p
->screen_base
+ (dy
+height
) * linesize
+ dx
* 2
83 for (rows
= height
* fontheight(p
) ; rows
-- ;) {
84 mymemmove(dst
, src
, width
* 2);
92 void fbcon_cfb2_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 dest
= p
->screen_base
+ sy
* fontheight(p
) * bytes
+ sx
* 2;
101 bgx
=attr_bgcol_ec(p
,conp
);
102 bgx
|= (bgx
<< 2); /* expand the colour to 16 bits */
106 if (sx
== 0 && width
* 2 == bytes
) {
107 for (i
= 0 ; i
< lines
* width
; i
++) {
108 ((u16
*)dest
)[0]=bgx
;
113 for (rows
= lines
; rows
-- ; dest0
+= bytes
) {
115 for (i
= 0 ; i
< width
; i
++) {
117 ((u16
*)dest
)[0]=bgx
;
124 void fbcon_cfb2_putc(struct vc_data
*conp
, struct display
*p
, int c
, int yy
,
128 int bytes
=p
->next_line
,rows
;
131 dest
= p
->screen_base
+ yy
* fontheight(p
) * bytes
+ xx
* 2;
132 cdat
= p
->fontdata
+ (c
& p
->charmask
) * fontheight(p
);
134 fgx
=3;/*attr_fgcol(p,c);*/
136 fgx
|= (fgx
<< 2); /* expand color to 8 bits */
142 for (rows
= fontheight(p
) ; rows
-- ; dest
+= bytes
) {
144 (nibbletab_cfb2
[*cdat
>> 4] & eorx
) ^ bgx
;
146 (nibbletab_cfb2
[*cdat
++ & 0xf] & eorx
) ^ bgx
;
150 void fbcon_cfb2_putcs(struct vc_data
*conp
, struct display
*p
, const unsigned short *s
,
151 int count
, int yy
, int xx
)
153 u8
*cdat
, *dest
, *dest0
;
155 int rows
,bytes
=p
->next_line
;
158 dest0
= p
->screen_base
+ yy
* fontheight(p
) * bytes
+ xx
* 2;
159 fgx
=3/*attr_fgcol(p,scr_readw(s))*/;
160 bgx
=attr_bgcol(p
,scr_readw(s
));
167 c
= scr_readw(s
++) & p
->charmask
;
168 cdat
= p
->fontdata
+ c
* fontheight(p
);
170 for (rows
= fontheight(p
), dest
= dest0
; rows
-- ; dest
+= bytes
) {
172 (nibbletab_cfb2
[*cdat
>> 4] & eorx
) ^ bgx
;
174 (nibbletab_cfb2
[*cdat
++ & 0xf] & eorx
) ^ bgx
;
180 void fbcon_cfb2_revc(struct display
*p
, int xx
, int yy
)
183 int bytes
=p
->next_line
, rows
;
185 dest
= p
->screen_base
+ yy
* fontheight(p
) * bytes
+ xx
* 2;
186 for (rows
= fontheight(p
) ; rows
-- ; dest
+= bytes
) {
187 ((u16
*)dest
)[0] ^= 0xffff;
193 * `switch' for the low level operations
196 struct display_switch fbcon_cfb2
= {
197 fbcon_cfb2_setup
, fbcon_cfb2_bmove
, fbcon_cfb2_clear
, fbcon_cfb2_putc
,
198 fbcon_cfb2_putcs
, fbcon_cfb2_revc
, NULL
, NULL
, NULL
, FONTWIDTH(8)
203 int init_module(void)
208 void cleanup_module(void)
214 * Visible symbols for modules
217 EXPORT_SYMBOL(fbcon_cfb2
);
218 EXPORT_SYMBOL(fbcon_cfb2_setup
);
219 EXPORT_SYMBOL(fbcon_cfb2_bmove
);
220 EXPORT_SYMBOL(fbcon_cfb2_clear
);
221 EXPORT_SYMBOL(fbcon_cfb2_putc
);
222 EXPORT_SYMBOL(fbcon_cfb2_putcs
);
223 EXPORT_SYMBOL(fbcon_cfb2_revc
);