* added 0.99 linux version
[mascara-docs.git] / i386 / linux / linux-2.3.21 / drivers / video / fbcon-mfb.c
blob9aa3528dd137a4f81f4e405788ab7280adf5f6a5
1 /*
2 * linux/drivers/video/mfb.c -- Low level frame buffer operations for
3 * monochrome
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
9 * more details.
12 #include <linux/module.h>
13 #include <linux/tty.h>
14 #include <linux/console.h>
15 #include <linux/string.h>
16 #include <linux/fb.h>
18 #include <video/fbcon.h>
19 #include <video/fbcon-mfb.h>
23 * Monochrome
26 void fbcon_mfb_setup(struct display *p)
28 if (p->line_length)
29 p->next_line = p->line_length;
30 else
31 p->next_line = p->var.xres_virtual>>3;
32 p->next_plane = 0;
35 void fbcon_mfb_bmove(struct display *p, int sy, int sx, int dy, int dx,
36 int height, int width)
38 u8 *src, *dest;
39 u_int rows;
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);
50 src += p->next_line;
51 dest += p->next_line;
53 } else {
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);
58 src -= p->next_line;
59 dest -= p->next_line;
64 void fbcon_mfb_clear(struct vc_data *conp, struct display *p, int sy, int sx,
65 int height, int width)
67 u8 *dest;
68 u_int rows;
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) {
74 if (inverse)
75 fb_memset255(dest, height*fontheight(p)*width);
76 else
77 fb_memclear(dest, height*fontheight(p)*width);
78 } else
79 for (rows = height*fontheight(p); rows--; dest += p->next_line)
80 if (inverse)
81 fb_memset255(dest, width);
82 else
83 fb_memclear_small(dest, width);
86 void fbcon_mfb_putc(struct vc_data *conp, struct display *p, int c, int yy,
87 int xx)
89 u8 *dest, *cdat;
90 u_int rows, bold, revs, underl;
91 u8 d;
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) {
100 d = *cdat++;
101 if (underl && !rows)
102 d = 0xff;
103 else if (bold)
104 d |= d>>1;
105 if (revs)
106 d = ~d;
107 fb_writeb (d, dest);
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;
116 u8 d;
117 u16 c;
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));
124 while (count--) {
125 c = scr_readw(s++) & p->charmask;
126 dest = dest0++;
127 cdat = p->fontdata+c*fontheight(p);
128 for (rows = fontheight(p); rows--; dest += p->next_line) {
129 d = *cdat++;
130 if (underl && !rows)
131 d = 0xff;
132 else if (bold)
133 d |= d>>1;
134 if (revs)
135 d = ~d;
136 fb_writeb (d, dest);
141 void fbcon_mfb_revc(struct display *p, int xx, int yy)
143 u8 *dest, d;
144 u_int rows;
146 dest = p->screen_base+yy*fontheight(p)*p->next_line+xx;
147 for (rows = fontheight(p); rows--; dest += p->next_line) {
148 d = fb_readb(dest);
149 fb_writeb (~d, dest);
153 void fbcon_mfb_clear_margins(struct vc_data *conp, struct display *p,
154 int bottom_only)
156 u8 *dest;
157 int height, bottom;
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);
163 if (!height)
164 return;
165 bottom = conp->vc_rows + p->yscroll;
166 if (bottom >= p->vrows)
167 bottom -= p->vrows;
168 dest = p->screen_base + bottom * fontheight(p) * p->next_line;
169 if (inverse)
170 fb_memset255(dest, height * p->next_line);
171 else
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,
183 FONTWIDTH(8)
187 #ifdef MODULE
188 int init_module(void)
190 return 0;
193 void cleanup_module(void)
195 #endif /* MODULE */
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);