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 fb_memmove(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 fb_memmove(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 fb_memmove(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 fb_memset255(dest
, height
*fontheight(p
)*width
);
77 fb_memclear(dest
, height
*fontheight(p
)*width
);
79 for (rows
= height
*fontheight(p
); rows
--; dest
+= p
->next_line
)
81 fb_memset255(dest
, width
);
83 fb_memclear_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
) {
149 fb_writeb (~d
, dest
);
153 void fbcon_mfb_clear_margins(struct vc_data
*conp
, struct display
*p
,
158 int inverse
= conp
? attr_reverse(p
,conp
->vc_video_erase_char
) : 0;
160 /* XXX Need to handle right margin? */
162 height
= p
->var
.yres
- conp
->vc_rows
* fontheight(p
);
165 bottom
= conp
->vc_rows
+ p
->yscroll
;
166 if (bottom
>= p
->vrows
)
168 dest
= p
->screen_base
+ bottom
* fontheight(p
) * p
->next_line
;
170 fb_memset255(dest
, height
* p
->next_line
);
172 fb_memclear(dest
, height
* p
->next_line
);
177 * `switch' for the low level operations
180 struct display_switch fbcon_mfb
= {
181 fbcon_mfb_setup
, fbcon_mfb_bmove
, fbcon_mfb_clear
, fbcon_mfb_putc
,
182 fbcon_mfb_putcs
, fbcon_mfb_revc
, NULL
, NULL
, fbcon_mfb_clear_margins
,
188 int init_module(void)
193 void cleanup_module(void)
199 * Visible symbols for modules
202 EXPORT_SYMBOL(fbcon_mfb
);
203 EXPORT_SYMBOL(fbcon_mfb_setup
);
204 EXPORT_SYMBOL(fbcon_mfb_bmove
);
205 EXPORT_SYMBOL(fbcon_mfb_clear
);
206 EXPORT_SYMBOL(fbcon_mfb_putc
);
207 EXPORT_SYMBOL(fbcon_mfb_putcs
);
208 EXPORT_SYMBOL(fbcon_mfb_revc
);
209 EXPORT_SYMBOL(fbcon_mfb_clear_margins
);