2 * linux/drivers/video/cfb32.c -- Low level frame buffer operations for 32 bpp
3 * truecolor packed pixels
5 * Created 28 Dec 1997 by Geert Uytterhoeven
7 * This file is subject to the terms and conditions of the GNU General Public
8 * License. See the file COPYING in the main directory of this archive for
12 #include <linux/module.h>
13 #include <linux/tty.h>
14 #include <linux/console.h>
15 #include <linux/string.h>
18 #include <video/fbcon.h>
19 #include <video/fbcon-cfb32.h>
23 * 32 bpp packed pixels
26 void fbcon_cfb32_setup(struct display
*p
)
28 p
->next_line
= p
->line_length
? p
->line_length
: p
->var
.xres_virtual
<<2;
32 void fbcon_cfb32_bmove(struct display
*p
, int sy
, int sx
, int dy
, int dx
,
33 int height
, int width
)
35 int bytes
= p
->next_line
, linesize
= bytes
* fontheight(p
), rows
;
38 if (sx
== 0 && dx
== 0 && width
* fontwidth(p
) * 4 == bytes
) {
39 mymemmove(p
->screen_base
+ dy
* linesize
,
40 p
->screen_base
+ sy
* linesize
,
44 if (fontwidthlog(p
)) {
45 sx
<<= fontwidthlog(p
)+2;
46 dx
<<= fontwidthlog(p
)+2;
47 width
<<= fontwidthlog(p
)+2;
51 width
*= fontwidth(p
)*4;
53 if (dy
< sy
|| (dy
== sy
&& dx
< sx
)) {
54 src
= p
->screen_base
+ sy
* linesize
+ sx
;
55 dst
= p
->screen_base
+ dy
* linesize
+ dx
;
56 for (rows
= height
* fontheight(p
); rows
--;) {
57 mymemmove(dst
, src
, width
);
62 src
= p
->screen_base
+ (sy
+height
) * linesize
+ sx
- bytes
;
63 dst
= p
->screen_base
+ (dy
+height
) * linesize
+ dx
- bytes
;
64 for (rows
= height
* fontheight(p
); rows
--;) {
65 mymemmove(dst
, src
, width
);
72 static inline void rectfill(u8
*dest
, int width
, int height
, u32 data
,
77 while (height
-- > 0) {
79 for (i
= 0; i
< width
/4; i
++) {
95 void fbcon_cfb32_clear(struct vc_data
*conp
, struct display
*p
, int sy
, int sx
,
96 int height
, int width
)
99 int bytes
= p
->next_line
, lines
= height
* fontheight(p
);
102 dest
= p
->screen_base
+ sy
* fontheight(p
) * bytes
+ sx
* fontwidth(p
) * 4;
104 bgx
= ((u32
*)p
->dispsw_data
)[attr_bgcol_ec(p
, conp
)];
106 width
*= fontwidth(p
)/4;
107 if (width
* 16 == bytes
)
108 rectfill(dest
, lines
* width
* 4, 1, bgx
, bytes
);
110 rectfill(dest
, width
* 4, lines
, bgx
, bytes
);
113 void fbcon_cfb32_putc(struct vc_data
*conp
, struct display
*p
, int c
, int yy
,
116 u8
*dest
, *cdat
, bits
;
117 int bytes
= p
->next_line
, rows
;
120 dest
= p
->screen_base
+ yy
* fontheight(p
) * bytes
+ xx
* fontwidth(p
) * 4;
121 if (fontwidth(p
) <= 8)
122 cdat
= p
->fontdata
+ (c
& p
->charmask
) * fontheight(p
);
124 cdat
= p
->fontdata
+ ((c
& p
->charmask
) * fontheight(p
) << 1);
125 fgx
= ((u32
*)p
->dispsw_data
)[attr_fgcol(p
, c
)];
126 bgx
= ((u32
*)p
->dispsw_data
)[attr_bgcol(p
, c
)];
129 for (rows
= fontheight(p
); rows
--; dest
+= bytes
) {
131 ((u32
*)dest
)[0] = (-(bits
>> 7) & eorx
) ^ bgx
;
132 ((u32
*)dest
)[1] = (-(bits
>> 6 & 1) & eorx
) ^ bgx
;
133 ((u32
*)dest
)[2] = (-(bits
>> 5 & 1) & eorx
) ^ bgx
;
134 ((u32
*)dest
)[3] = (-(bits
>> 4 & 1) & eorx
) ^ bgx
;
135 if (fontwidth(p
) < 8)
137 ((u32
*)dest
)[4] = (-(bits
>> 3 & 1) & eorx
) ^ bgx
;
138 ((u32
*)dest
)[5] = (-(bits
>> 2 & 1) & eorx
) ^ bgx
;
139 ((u32
*)dest
)[6] = (-(bits
>> 1 & 1) & eorx
) ^ bgx
;
140 ((u32
*)dest
)[7] = (-(bits
& 1) & eorx
) ^ bgx
;
141 if (fontwidth(p
) < 12)
144 ((u32
*)dest
)[8] = (-(bits
>> 7) & eorx
) ^ bgx
;
145 ((u32
*)dest
)[9] = (-(bits
>> 6 & 1) & eorx
) ^ bgx
;
146 ((u32
*)dest
)[10] = (-(bits
>> 5 & 1) & eorx
) ^ bgx
;
147 ((u32
*)dest
)[11] = (-(bits
>> 4 & 1) & eorx
) ^ bgx
;
148 if (fontwidth(p
) < 16)
150 ((u32
*)dest
)[12] = (-(bits
>> 3 & 1) & eorx
) ^ bgx
;
151 ((u32
*)dest
)[13] = (-(bits
>> 2 & 1) & eorx
) ^ bgx
;
152 ((u32
*)dest
)[14] = (-(bits
>> 1 & 1) & eorx
) ^ bgx
;
153 ((u32
*)dest
)[15] = (-(bits
& 1) & eorx
) ^ bgx
;
157 void fbcon_cfb32_putcs(struct vc_data
*conp
, struct display
*p
,
158 const unsigned short *s
, int count
, int yy
, int xx
)
160 u8
*cdat
, *dest
, *dest0
, bits
;
162 int rows
, bytes
= p
->next_line
;
165 dest0
= p
->screen_base
+ yy
* fontheight(p
) * bytes
+ xx
* fontwidth(p
) * 4;
166 fgx
= ((u32
*)p
->dispsw_data
)[attr_fgcol(p
, scr_readw(s
))];
167 bgx
= ((u32
*)p
->dispsw_data
)[attr_bgcol(p
, scr_readw(s
))];
170 c
= scr_readw(s
++) & p
->charmask
;
171 if (fontwidth(p
) <= 8)
172 cdat
= p
->fontdata
+ c
* fontheight(p
);
174 cdat
= p
->fontdata
+ (c
* fontheight(p
) << 1);
175 for (rows
= fontheight(p
), dest
= dest0
; rows
--; dest
+= bytes
) {
177 ((u32
*)dest
)[0] = (-(bits
>> 7) & eorx
) ^ bgx
;
178 ((u32
*)dest
)[1] = (-(bits
>> 6 & 1) & eorx
) ^ bgx
;
179 ((u32
*)dest
)[2] = (-(bits
>> 5 & 1) & eorx
) ^ bgx
;
180 ((u32
*)dest
)[3] = (-(bits
>> 4 & 1) & eorx
) ^ bgx
;
181 if (fontwidth(p
) < 8)
183 ((u32
*)dest
)[4] = (-(bits
>> 3 & 1) & eorx
) ^ bgx
;
184 ((u32
*)dest
)[5] = (-(bits
>> 2 & 1) & eorx
) ^ bgx
;
185 ((u32
*)dest
)[6] = (-(bits
>> 1 & 1) & eorx
) ^ bgx
;
186 ((u32
*)dest
)[7] = (-(bits
& 1) & eorx
) ^ bgx
;
187 if (fontwidth(p
) < 12)
190 ((u32
*)dest
)[8] = (-(bits
>> 7) & eorx
) ^ bgx
;
191 ((u32
*)dest
)[9] = (-(bits
>> 6 & 1) & eorx
) ^ bgx
;
192 ((u32
*)dest
)[10] = (-(bits
>> 5 & 1) & eorx
) ^ bgx
;
193 ((u32
*)dest
)[11] = (-(bits
>> 4 & 1) & eorx
) ^ bgx
;
194 if (fontwidth(p
) < 16)
196 ((u32
*)dest
)[12] = (-(bits
>> 3 & 1) & eorx
) ^ bgx
;
197 ((u32
*)dest
)[13] = (-(bits
>> 2 & 1) & eorx
) ^ bgx
;
198 ((u32
*)dest
)[14] = (-(bits
>> 1 & 1) & eorx
) ^ bgx
;
199 ((u32
*)dest
)[15] = (-(bits
& 1) & eorx
) ^ bgx
;
201 dest0
+= fontwidth(p
)*4;
205 void fbcon_cfb32_revc(struct display
*p
, int xx
, int yy
)
208 int bytes
= p
->next_line
, rows
;
210 dest
= p
->screen_base
+ yy
* fontheight(p
) * bytes
+ xx
* fontwidth(p
) * 4;
211 for (rows
= fontheight(p
); rows
--; dest
+= bytes
) {
212 switch (fontwidth(p
)) {
214 ((u32
*)dest
)[12] ^= 0xffffffff; ((u32
*)dest
)[13] ^= 0xffffffff;
215 ((u32
*)dest
)[14] ^= 0xffffffff; ((u32
*)dest
)[15] ^= 0xffffffff;
218 ((u32
*)dest
)[8] ^= 0xffffffff; ((u32
*)dest
)[9] ^= 0xffffffff;
219 ((u32
*)dest
)[10] ^= 0xffffffff; ((u32
*)dest
)[11] ^= 0xffffffff;
222 ((u32
*)dest
)[4] ^= 0xffffffff; ((u32
*)dest
)[5] ^= 0xffffffff;
223 ((u32
*)dest
)[6] ^= 0xffffffff; ((u32
*)dest
)[7] ^= 0xffffffff;
226 ((u32
*)dest
)[0] ^= 0xffffffff; ((u32
*)dest
)[1] ^= 0xffffffff;
227 ((u32
*)dest
)[2] ^= 0xffffffff; ((u32
*)dest
)[3] ^= 0xffffffff;
233 void fbcon_cfb32_clear_margins(struct vc_data
*conp
, struct display
*p
,
236 int bytes
= p
->next_line
;
239 unsigned int right_start
= conp
->vc_cols
*fontwidth(p
);
240 unsigned int bottom_start
= conp
->vc_rows
*fontheight(p
);
241 unsigned int right_width
, bottom_width
;
243 bgx
= ((u32
*)p
->dispsw_data
)[attr_bgcol_ec(p
, conp
)];
245 if (!bottom_only
&& (right_width
= p
->var
.xres
-right_start
))
246 rectfill(p
->screen_base
+right_start
*4, right_width
,
247 p
->var
.yres_virtual
, bgx
, bytes
);
248 if ((bottom_width
= p
->var
.yres
-bottom_start
))
249 rectfill(p
->screen_base
+(p
->var
.yoffset
+bottom_start
)*bytes
,
250 right_start
, bottom_width
, bgx
, bytes
);
255 * `switch' for the low level operations
258 struct display_switch fbcon_cfb32
= {
259 fbcon_cfb32_setup
, fbcon_cfb32_bmove
, fbcon_cfb32_clear
, fbcon_cfb32_putc
,
260 fbcon_cfb32_putcs
, fbcon_cfb32_revc
, NULL
, NULL
, fbcon_cfb32_clear_margins
,
261 FONTWIDTH(4)|FONTWIDTH(8)|FONTWIDTH(12)|FONTWIDTH(16)
266 int init_module(void)
271 void cleanup_module(void)
277 * Visible symbols for modules
280 EXPORT_SYMBOL(fbcon_cfb32
);
281 EXPORT_SYMBOL(fbcon_cfb32_setup
);
282 EXPORT_SYMBOL(fbcon_cfb32_bmove
);
283 EXPORT_SYMBOL(fbcon_cfb32_clear
);
284 EXPORT_SYMBOL(fbcon_cfb32_putc
);
285 EXPORT_SYMBOL(fbcon_cfb32_putcs
);
286 EXPORT_SYMBOL(fbcon_cfb32_revc
);
287 EXPORT_SYMBOL(fbcon_cfb32_clear_margins
);