Import 2.3.18pre1
[davej-history.git] / drivers / video / fbcon-mfb.c
blob76caf5cc9ee0a948dd341d623a3a7368f4e12e85
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 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);
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 mymemmove(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 mymemset(dest, height*fontheight(p)*width);
76 else
77 mymemclear(dest, height*fontheight(p)*width);
78 } else
79 for (rows = height*fontheight(p); rows--; dest += p->next_line)
80 if (inverse)
81 mymemset(dest, width);
82 else
83 mymemclear_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 *dest = d;
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 *dest = d;
141 void fbcon_mfb_revc(struct display *p, int xx, int yy)
143 u8 *dest;
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 *dest = ~*dest;
151 void fbcon_mfb_clear_margins(struct vc_data *conp, struct display *p,
152 int bottom_only)
154 u8 *dest;
155 int height, bottom;
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);
161 if (!height)
162 return;
163 bottom = conp->vc_rows + p->yscroll;
164 if (bottom >= p->vrows)
165 bottom -= p->vrows;
166 dest = p->screen_base + bottom * fontheight(p) * p->next_line;
167 if (inverse)
168 mymemset(dest, height * p->next_line);
169 else
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,
181 FONTWIDTH(8)
185 #ifdef MODULE
186 int init_module(void)
188 return 0;
191 void cleanup_module(void)
193 #endif /* MODULE */
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);