2 * linux/drivers/video/mfb.c -- Low level frame buffer operations for
5 * Created 5 Apr 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-mfb.h>
26 void fbcon_mfb_setup(struct display
*p
)
29 p
->next_line
= p
->line_length
;
31 p
->next_line
= p
->var
.xres_virtual
>>3;
35 void fbcon_mfb_bmove(struct display
*p
, int sy
, int sx
, int dy
, int dx
,
36 int height
, int width
)
41 if (sx
== 0 && dx
== 0 && width
== p
->next_line
) {
42 src
= p
->screen_base
+sy
*fontheight(p
)*width
;
43 dest
= p
->screen_base
+dy
*fontheight(p
)*width
;
44 mymemmove(dest
, src
, height
*fontheight(p
)*width
);
45 } else if (dy
<= sy
) {
46 src
= p
->screen_base
+sy
*fontheight(p
)*p
->next_line
+sx
;
47 dest
= p
->screen_base
+dy
*fontheight(p
)*p
->next_line
+dx
;
48 for (rows
= height
*fontheight(p
); rows
--;) {
49 mymemmove(dest
, src
, width
);
54 src
= p
->screen_base
+((sy
+height
)*fontheight(p
)-1)*p
->next_line
+sx
;
55 dest
= p
->screen_base
+((dy
+height
)*fontheight(p
)-1)*p
->next_line
+dx
;
56 for (rows
= height
*fontheight(p
); rows
--;) {
57 mymemmove(dest
, src
, width
);
64 void fbcon_mfb_clear(struct vc_data
*conp
, struct display
*p
, int sy
, int sx
,
65 int height
, int width
)
69 int inverse
= conp
? attr_reverse(p
,conp
->vc_video_erase_char
) : 0;
71 dest
= p
->screen_base
+sy
*fontheight(p
)*p
->next_line
+sx
;
73 if (sx
== 0 && width
== p
->next_line
) {
75 mymemset(dest
, height
*fontheight(p
)*width
);
77 mymemclear(dest
, height
*fontheight(p
)*width
);
79 for (rows
= height
*fontheight(p
); rows
--; dest
+= p
->next_line
)
81 mymemset(dest
, width
);
83 mymemclear_small(dest
, width
);
86 void fbcon_mfb_putc(struct vc_data
*conp
, struct display
*p
, int c
, int yy
,
90 u_int rows
, bold
, revs
, underl
;
93 dest
= p
->screen_base
+yy
*fontheight(p
)*p
->next_line
+xx
;
94 cdat
= p
->fontdata
+(c
&p
->charmask
)*fontheight(p
);
95 bold
= attr_bold(p
,c
);
96 revs
= attr_reverse(p
,c
);
97 underl
= attr_underline(p
,c
);
99 for (rows
= fontheight(p
); rows
--; dest
+= p
->next_line
) {
111 void fbcon_mfb_putcs(struct vc_data
*conp
, struct display
*p
,
112 const unsigned short *s
, int count
, int yy
, int xx
)
114 u8
*dest
, *dest0
, *cdat
;
115 u_int rows
, bold
, revs
, underl
;
119 dest0
= p
->screen_base
+yy
*fontheight(p
)*p
->next_line
+xx
;
120 bold
= attr_bold(p
,scr_readw(s
));
121 revs
= attr_reverse(p
,scr_readw(s
));
122 underl
= attr_underline(p
,scr_readw(s
));
125 c
= scr_readw(s
++) & p
->charmask
;
127 cdat
= p
->fontdata
+c
*fontheight(p
);
128 for (rows
= fontheight(p
); rows
--; dest
+= p
->next_line
) {
141 void fbcon_mfb_revc(struct display
*p
, int xx
, int yy
)
146 dest
= p
->screen_base
+yy
*fontheight(p
)*p
->next_line
+xx
;
147 for (rows
= fontheight(p
); rows
--; dest
+= p
->next_line
)
151 void fbcon_mfb_clear_margins(struct vc_data
*conp
, struct display
*p
,
156 int inverse
= conp
? attr_reverse(p
,conp
->vc_video_erase_char
) : 0;
158 /* XXX Need to handle right margin? */
160 height
= p
->var
.yres
- conp
->vc_rows
* fontheight(p
);
163 bottom
= conp
->vc_rows
+ p
->yscroll
;
164 if (bottom
>= p
->vrows
)
166 dest
= p
->screen_base
+ bottom
* fontheight(p
) * p
->next_line
;
168 mymemset(dest
, height
* p
->next_line
);
170 mymemclear(dest
, height
* p
->next_line
);
175 * `switch' for the low level operations
178 struct display_switch fbcon_mfb
= {
179 fbcon_mfb_setup
, fbcon_mfb_bmove
, fbcon_mfb_clear
, fbcon_mfb_putc
,
180 fbcon_mfb_putcs
, fbcon_mfb_revc
, NULL
, NULL
, fbcon_mfb_clear_margins
,
186 int init_module(void)
191 void cleanup_module(void)
197 * Visible symbols for modules
200 EXPORT_SYMBOL(fbcon_mfb
);
201 EXPORT_SYMBOL(fbcon_mfb_setup
);
202 EXPORT_SYMBOL(fbcon_mfb_bmove
);
203 EXPORT_SYMBOL(fbcon_mfb_clear
);
204 EXPORT_SYMBOL(fbcon_mfb_putc
);
205 EXPORT_SYMBOL(fbcon_mfb_putcs
);
206 EXPORT_SYMBOL(fbcon_mfb_revc
);
207 EXPORT_SYMBOL(fbcon_mfb_clear_margins
);