2 * linux/drivers/video/fbcon-hga.c -- Low level frame buffer operations for
3 * the Hercules graphics adaptor
5 * Created 25 Nov 1999 by Ferenc Bakonyi (fero@drama.obuda.kando.hu)
6 * Based on fbcon-mfb.c by Geert Uytterhoeven
10 * - Revision 0.1.0 (6 Dec 1999): comment changes
11 * - First release (25 Nov 1999)
13 * This file is subject to the terms and conditions of the GNU General Public
14 * License. See the file COPYING in the main directory of this archive for
18 #include <linux/module.h>
19 #include <linux/tty.h>
20 #include <linux/console.h>
21 #include <linux/string.h>
24 #include <video/fbcon.h>
25 #include <video/fbcon-hga.h>
28 #define DPRINTK(args...) printk(KERN_DEBUG __FILE__": " ##args)
30 #define DPRINTK(args...)
33 #define HGA_ROWADDR(row) ((row%4)*8192 + (row>>2)*90)
39 static inline u8* rowaddr(struct display *p, u_int row)
41 return p->screen_base + HGA_ROWADDR(row);
44 void fbcon_hga_setup(struct display *p)
46 DPRINTK("fbcon_hga_setup: ll:%d\n", (int)p->line_length);
48 p->next_line = p->line_length;
52 void fbcon_hga_bmove(struct display *p, int sy, int sx, int dy, int dx,
53 int height, int width)
59 if (sx == 0 && dx == 0 && width == p->next_line) {
60 src = p->screen_base+sy*fontheight(p)*width;
61 dest = p->screen_base+dy*fontheight(p)*width;
62 fb_memmove(dest, src, height*fontheight(p)*width);
66 y1 = sy*fontheight(p);
67 y2 = dy*fontheight(p);
68 for (rows = height*fontheight(p); rows--; ) {
69 src = rowaddr(p, y1)+sx;
70 dest = rowaddr(p, y2)+dx;
71 fb_memmove(dest, src, width);
76 y1 = (sy+height)*fontheight(p)-1;
77 y2 = (dy+height)*fontheight(p)-1;
78 for (rows = height*fontheight(p); rows--;) {
79 src = rowaddr(p, y1)+sx;
80 dest = rowaddr(p, y2)+dx;
81 fb_memmove(dest, src, width);
88 void fbcon_hga_clear(struct vc_data *conp, struct display *p, int sy, int sx,
89 int height, int width)
93 int inverse = conp ? attr_reverse(p,conp->vc_video_erase_char) : 0;
95 DPRINTK("fbcon_hga_clear: sx:%d, sy:%d, height:%d, width:%d\n", sx, sy, height, width);
99 if (sx == 0 && width == p->next_line) {
101 fb_memset255(dest, height*fontheight(p)*width);
103 fb_memclear(dest, height*fontheight(p)*width);
107 for (rows = height*fontheight(p); rows--; y++) {
108 dest = rowaddr(p, y)+sx;
110 fb_memset255(dest, width);
112 fb_memclear(dest, width);
117 void fbcon_hga_putc(struct vc_data *conp, struct display *p, int c, int yy,
121 u_int rows, y, bold, revs, underl;
124 cdat = p->fontdata+(c&p->charmask)*fontheight(p);
125 bold = attr_bold(p, c);
126 revs = attr_reverse(p, c);
127 underl = attr_underline(p, c);
128 y = yy*fontheight(p);
130 for (rows = fontheight(p); rows--; y++) {
138 dest = rowaddr(p, y)+xx;
143 void fbcon_hga_putcs(struct vc_data *conp, struct display *p,
144 const unsigned short *s, int count, int yy, int xx)
147 u_int rows, y, y0, bold, revs, underl;
152 bold = attr_bold(p, c);
153 revs = attr_reverse(p, c);
154 underl = attr_underline(p, c);
155 y0 = yy*fontheight(p);
158 c = scr_readw(s++) & p->charmask;
159 cdat = p->fontdata+c*fontheight(p);
161 for (rows = fontheight(p); rows--; y++) {
169 dest = rowaddr(p, y)+xx;
176 void fbcon_hga_revc(struct display *p, int xx, int yy)
181 y = yy*fontheight(p);
182 for (rows = fontheight(p); rows--; y++) {
183 dest = rowaddr(p, y)+xx;
188 void fbcon_hga_clear_margins(struct vc_data *conp, struct display *p,
193 int inverse = conp ? attr_reverse(p,conp->vc_video_erase_char) : 0;
195 DPRINTK("fbcon_hga_clear_margins: enter\n");
197 /* No need to handle right margin. */
199 y = conp->vc_rows * fontheight(p);
200 for (height = p->var.yres - y; height-- > 0; y++) {
201 DPRINTK("fbcon_hga_clear_margins: y:%d, height:%d\n", y, height);
202 dest = rowaddr(p, y);
204 fb_memset255(dest, p->next_line);
206 fb_memclear(dest, p->next_line);
213 * `switch' for the low level operations
216 struct display_switch fbcon_hga = {
217 setup: fbcon_hga_setup,
218 bmove: fbcon_hga_bmove,
219 clear: fbcon_hga_clear,
220 putc: fbcon_hga_putc,
221 putcs: fbcon_hga_putcs,
222 revc: fbcon_hga_revc,
223 clear_margins: fbcon_hga_clear_margins,
224 fontwidthmask: FONTWIDTH(8)
229 MODULE_LICENSE("GPL");
231 int init_module(void)
236 void cleanup_module(void)
243 * Visible symbols for modules
246 EXPORT_SYMBOL(fbcon_hga);
247 EXPORT_SYMBOL(fbcon_hga_setup);
248 EXPORT_SYMBOL(fbcon_hga_bmove);
249 EXPORT_SYMBOL(fbcon_hga_clear);
250 EXPORT_SYMBOL(fbcon_hga_putc);
251 EXPORT_SYMBOL(fbcon_hga_putcs);
252 EXPORT_SYMBOL(fbcon_hga_revc);
253 EXPORT_SYMBOL(fbcon_hga_clear_margins);