1 /*
2 * linux/drivers/video/fbcon.c -- Low level frame buffer based console driver
3 *
4 * Copyright (C) 1995 Geert Uytterhoeven
5 *
6 *
7 * This file is based on the original Amiga console driver (amicon.c):
8 *
9 * Copyright (C) 1993 Hamish Macdonald
10 * Greg Harp
11 * Copyright (C) 1994 David Carter [carter@compsci.bristol.ac.uk]
12 *
13 * with work by William Rucklidge (wjr@cs.cornell.edu)
14 * Geert Uytterhoeven
15 * Jes Sorensen (jds@kom.auc.dk)
16 * Martin Apel
17 *
18 * and on the original Atari console driver (atacon.c):
19 *
20 * Copyright (C) 1993 Bjoern Brauel
21 * Roman Hodek
22 *
23 * with work by Guenther Kelleter
24 * Martin Schaller
25 * Andreas Schwab
26 *
27 * Hardware cursor support added by Emmanuel Marty (core@ggi-project.org)
28 * Smart redraw scrolling, arbitrary font width support, 512char font support
29 * and software scrollback added by
30 * Jakub Jelinek (jj@ultra.linux.cz)
31 *
32 * Random hacking by Martin Mares <mj@ucw.cz>
33 *
34 * 2001 - Documented with DocBook
35 * - Brad Douglas <brad@neruo.com>
36 *
37 * The low level operations for the various display memory organizations are
38 * now in separate source files.
39 *
40 * Currently the following organizations are supported:
41 *
42 * o afb Amiga bitplanes
43 * o cfb{2,4,8,16,24,32} Packed pixels
44 * o ilbm Amiga interleaved bitplanes
45 * o iplan2p[248] Atari interleaved bitplanes
46 * o mfb Monochrome
47 * o vga VGA characters/attributes
48 *
49 * To do:
50 *
51 * - Implement 16 plane mode (iplan2p16)
52 *
53 *
54 * This file is subject to the terms and conditions of the GNU General Public
55 * License. See the file COPYING in the main directory of this archive for
56 * more details.
57 */
58
59 #undef FBCONDEBUG
60
61 #include <linux/config.h>
62 #include <linux/module.h>
63 #include <linux/types.h>
64 #include <linux/sched.h>
65 #include <linux/fs.h>
66 #include <linux/kernel.h>
67 #include <linux/delay.h> /* MSch: for IRQ probe */
68 #include <linux/tty.h>
69 #include <linux/console.h>
70 #include <linux/string.h>
71 #include <linux/kd.h>
72 #include <linux/slab.h>
73 #include <linux/fb.h>
74 #include <linux/vt_kern.h>
75 #include <linux/selection.h>
76 #include <linux/smp.h>
77 #include <linux/init.h>
78 #include <linux/pm.h>
79
80 #include <asm/irq.h>
81 #include <asm/system.h>
82 #include <asm/uaccess.h>
83 #ifdef CONFIG_AMIGA
84 #include <asm/amigahw.h>
85 #include <asm/amigaints.h>
86 #endif /* CONFIG_AMIGA */
87 #ifdef CONFIG_ATARI
88 #include <asm/atariints.h>
89 #endif
90 #ifdef CONFIG_MAC
91 #include <asm/macints.h>
92 #endif
93 #if defined(__mc68000__) || defined(CONFIG_APUS)
94 #include <asm/machdep.h>
95 #include <asm/setup.h>
96 #endif
97 #ifdef CONFIG_FBCON_VGA_PLANES
98 #include <asm/io.h>
99 #endif
100 #define INCLUDE_LINUX_LOGO_DATA
101 #include <asm/linux_logo.h>
102
103 #include <video/fbcon.h>
104 #include <video/fbcon-mac.h> /* for 6x11 font on mac */
105 #include <video/font.h>
106
107 #ifdef FBCONDEBUG
108 # define DPRINTK(fmt, args...) printk(KERN_DEBUG "%s: " fmt, __FUNCTION__ , ## args)
109 #else
110 # define DPRINTK(fmt, args...)
111 #endif
112
113 #define LOGO_H 80
114 #define LOGO_W 80
115 #define LOGO_LINE (LOGO_W/8)
116
117 struct display fb_display[MAX_NR_CONSOLES];
118 char con2fb_map[MAX_NR_CONSOLES];
119 static int logo_lines;
120 static int logo_shown = -1;
121 /* Software scrollback */
122 int fbcon_softback_size = 32768;
123 static unsigned long softback_buf, softback_curr;
124 static unsigned long softback_in;
125 static unsigned long softback_top, softback_end;
126 static int softback_lines;
127
128 #define REFCOUNT(fd) (((int *)(fd))[-1])
129 #define FNTSIZE(fd) (((int *)(fd))[-2])
130 #define FNTCHARCNT(fd) (((int *)(fd))[-3])
131 #define FNTSUM(fd) (((int *)(fd))[-4])
132 #define FONT_EXTRA_WORDS 4
133
134 #define CM_SOFTBACK (8)
135
136 #define advance_row(p, delta) (unsigned short *)((unsigned long)(p) + (delta) * conp->vc_size_row)
137
138 static void fbcon_free_font(struct display *);
139 static int fbcon_set_origin(struct vc_data *);
140
141 #ifdef CONFIG_PM
142 static int pm_fbcon_request(struct pm_dev *dev, pm_request_t rqst, void *data);
143 static struct pm_dev *pm_fbcon;
144 static int fbcon_sleeping;
145 #endif
146
147 /*
148 * Emmanuel: fbcon will now use a hardware cursor if the
149 * low-level driver provides a non-NULL dispsw->cursor pointer,
150 * in which case the hardware should do blinking, etc.
151 *
152 * if dispsw->cursor is NULL, use Atari alike software cursor
153 */
154
155 static int cursor_drawn;
156
157 #define CURSOR_DRAW_DELAY (1)
158
159 /* # VBL ints between cursor state changes */
160 #define ARM_CURSOR_BLINK_RATE (10)
161 #define AMIGA_CURSOR_BLINK_RATE (20)
162 #define ATARI_CURSOR_BLINK_RATE (42)
163 #define MAC_CURSOR_BLINK_RATE (32)
164 #define DEFAULT_CURSOR_BLINK_RATE (20)
165
166 static int vbl_cursor_cnt;
167 static int cursor_on;
168 static int cursor_blink_rate;
169
cursor_undrawn(void)170 static inline void cursor_undrawn(void)
171 {
172 vbl_cursor_cnt = 0;
173 cursor_drawn = 0;
174 }
175
176
177 #define divides(a, b) ((!(a) || (b)%(a)) ? 0 : 1)
178
179
180 /*
181 * Interface used by the world
182 */
183
184 static const char *fbcon_startup(void);
185 static void fbcon_init(struct vc_data *conp, int init);
186 static void fbcon_deinit(struct vc_data *conp);
187 static int fbcon_changevar(int con);
188 static void fbcon_clear(struct vc_data *conp, int sy, int sx, int height,
189 int width);
190 static void fbcon_putc(struct vc_data *conp, int c, int ypos, int xpos);
191 static void fbcon_putcs(struct vc_data *conp, const unsigned short *s, int count,
192 int ypos, int xpos);
193 static void fbcon_cursor(struct vc_data *conp, int mode);
194 static int fbcon_scroll(struct vc_data *conp, int t, int b, int dir,
195 int count);
196 static void fbcon_bmove(struct vc_data *conp, int sy, int sx, int dy, int dx,
197 int height, int width);
198 static int fbcon_switch(struct vc_data *conp);
199 static int fbcon_blank(struct vc_data *conp, int blank);
200 static int fbcon_font_op(struct vc_data *conp, struct console_font_op *op);
201 static int fbcon_set_palette(struct vc_data *conp, unsigned char *table);
202 static int fbcon_scrolldelta(struct vc_data *conp, int lines);
203
204
205 /*
206 * Internal routines
207 */
208
209 static void fbcon_setup(int con, int init, int logo);
210 static __inline__ int real_y(struct display *p, int ypos);
211 static void fbcon_vbl_handler(int irq, void *dummy, struct pt_regs *fp);
212 static __inline__ void updatescrollmode(struct display *p);
213 static __inline__ void ywrap_up(int unit, struct vc_data *conp,
214 struct display *p, int count);
215 static __inline__ void ywrap_down(int unit, struct vc_data *conp,
216 struct display *p, int count);
217 static __inline__ void ypan_up(int unit, struct vc_data *conp,
218 struct display *p, int count);
219 static __inline__ void ypan_down(int unit, struct vc_data *conp,
220 struct display *p, int count);
221 static void fbcon_bmove_rec(struct display *p, int sy, int sx, int dy, int dx,
222 int height, int width, u_int y_break);
223
224 static int fbcon_show_logo(void);
225
226 #ifdef CONFIG_MAC
227 /*
228 * On the Macintoy, there may or may not be a working VBL int. We need to probe
229 */
230 static int vbl_detected;
231
fbcon_vbl_detect(int irq,void * dummy,struct pt_regs * fp)232 static void fbcon_vbl_detect(int irq, void *dummy, struct pt_regs *fp)
233 {
234 vbl_detected++;
235 }
236 #endif
237
238 static void cursor_timer_handler(unsigned long dev_addr);
239
240 static struct timer_list cursor_timer = {
241 function: cursor_timer_handler
242 };
243 static int use_timer_cursor;
244
cursor_timer_handler(unsigned long dev_addr)245 static void cursor_timer_handler(unsigned long dev_addr)
246 {
247 fbcon_vbl_handler(0, NULL, NULL);
248 cursor_timer.expires = jiffies+HZ/50;
249 add_timer(&cursor_timer);
250 }
251
252
253 /**
254 * PROC_CONSOLE - find the attached tty or visible console
255 * @info: frame buffer info structure
256 *
257 * Finds the tty attached to the process or visible console if
258 * the process is not directly attached to a tty (e.g. remote
259 * user) for device @info.
260 *
261 * Returns -1 errno on error, or tty/visible console number
262 * on success.
263 *
264 */
265
PROC_CONSOLE(const struct fb_info * info)266 int PROC_CONSOLE(const struct fb_info *info)
267 {
268 int fgc;
269
270 if (info->display_fg == NULL)
271 return -1;
272
273 if (!current->tty ||
274 current->tty->driver.type != TTY_DRIVER_TYPE_CONSOLE ||
275 MINOR(current->tty->device) < 1)
276 fgc = info->display_fg->vc_num;
277 else
278 fgc = MINOR(current->tty->device)-1;
279
280 /* Does this virtual console belong to the specified fbdev? */
281 if (fb_display[fgc].fb_info != info)
282 return -1;
283
284 return fgc;
285 }
286
287
288 /**
289 * set_all_vcs - set all virtual consoles to match
290 * @fbidx: frame buffer index (e.g. fb0, fb1, ...)
291 * @fb: frame buffer ops structure
292 * @var: frame buffer screen structure to set
293 * @info: frame buffer info structure
294 *
295 * Set all virtual consoles to match screen info set in @var
296 * for device @info.
297 *
298 * Returns negative errno on error, or zero on success.
299 *
300 */
301
set_all_vcs(int fbidx,struct fb_ops * fb,struct fb_var_screeninfo * var,struct fb_info * info)302 int set_all_vcs(int fbidx, struct fb_ops *fb, struct fb_var_screeninfo *var,
303 struct fb_info *info)
304 {
305 int unit, err;
306
307 var->activate |= FB_ACTIVATE_TEST;
308 err = fb->fb_set_var(var, PROC_CONSOLE(info), info);
309 var->activate &= ~FB_ACTIVATE_TEST;
310 if (err)
311 return err;
312 for (unit = 0; unit < MAX_NR_CONSOLES; unit++)
313 if (fb_display[unit].conp && con2fb_map[unit] == fbidx)
314 fb->fb_set_var(var, unit, info);
315 return 0;
316 }
317
318
319 /**
320 * set_con2fb_map - map console to frame buffer device
321 * @unit: virtual console number to map
322 * @newidx: frame buffer index to map virtual console to
323 *
324 * Maps a virtual console @unit to a frame buffer device
325 * @newidx.
326 *
327 */
328
set_con2fb_map(int unit,int newidx)329 void set_con2fb_map(int unit, int newidx)
330 {
331 int oldidx = con2fb_map[unit];
332 struct fb_info *oldfb, *newfb;
333 struct vc_data *conp;
334 char *fontdata;
335 unsigned short fontwidth, fontheight, fontwidthlog, fontheightlog;
336 int userfont;
337
338 if (newidx != con2fb_map[unit]) {
339 oldfb = registered_fb[oldidx];
340 newfb = registered_fb[newidx];
341 if (newfb->fbops->owner)
342 __MOD_INC_USE_COUNT(newfb->fbops->owner);
343 if (newfb->fbops->fb_open && newfb->fbops->fb_open(newfb,0)) {
344 if (newfb->fbops->owner)
345 __MOD_DEC_USE_COUNT(newfb->fbops->owner);
346 return;
347 }
348 if (oldfb->fbops->fb_release)
349 oldfb->fbops->fb_release(oldfb,0);
350 if (oldfb->fbops->owner)
351 __MOD_DEC_USE_COUNT(oldfb->fbops->owner);
352 conp = fb_display[unit].conp;
353 fontdata = fb_display[unit].fontdata;
354 fontwidth = fb_display[unit]._fontwidth;
355 fontheight = fb_display[unit]._fontheight;
356 fontwidthlog = fb_display[unit]._fontwidthlog;
357 fontheightlog = fb_display[unit]._fontheightlog;
358 userfont = fb_display[unit].userfont;
359 con2fb_map[unit] = newidx;
360 fb_display[unit] = *(newfb->disp);
361 fb_display[unit].conp = conp;
362 fb_display[unit].fontdata = fontdata;
363 fb_display[unit]._fontwidth = fontwidth;
364 fb_display[unit]._fontheight = fontheight;
365 fb_display[unit]._fontwidthlog = fontwidthlog;
366 fb_display[unit]._fontheightlog = fontheightlog;
367 fb_display[unit].userfont = userfont;
368 fb_display[unit].fb_info = newfb;
369 if (conp)
370 conp->vc_display_fg = &newfb->display_fg;
371 if (!newfb->display_fg)
372 newfb->display_fg = conp;
373 if (!newfb->changevar)
374 newfb->changevar = oldfb->changevar;
375 /* tell console var has changed */
376 if (newfb->changevar)
377 newfb->changevar(unit);
378 }
379 }
380
381 /*
382 * Low Level Operations
383 */
384
385 struct display_switch fbcon_dummy;
386
387 /* NOTE: fbcon cannot be __init: it may be called from take_over_console later */
388
fbcon_startup(void)389 static const char *fbcon_startup(void)
390 {
391 const char *display_desc = "frame buffer device";
392 int irqres = 1;
393 static int done = 0;
394
395 /*
396 * If num_registered_fb is zero, this is a call for the dummy part.
397 * The frame buffer devices weren't initialized yet.
398 */
399 if (!num_registered_fb || done)
400 return display_desc;
401 done = 1;
402
403 #ifdef CONFIG_AMIGA
404 if (MACH_IS_AMIGA) {
405 cursor_blink_rate = AMIGA_CURSOR_BLINK_RATE;
406 irqres = request_irq(IRQ_AMIGA_VERTB, fbcon_vbl_handler, 0,
407 "console/cursor", fbcon_vbl_handler);
408 }
409 #endif /* CONFIG_AMIGA */
410 #ifdef CONFIG_ATARI
411 if (MACH_IS_ATARI) {
412 cursor_blink_rate = ATARI_CURSOR_BLINK_RATE;
413 irqres = request_irq(IRQ_AUTO_4, fbcon_vbl_handler, IRQ_TYPE_PRIO,
414 "console/cursor", fbcon_vbl_handler);
415 }
416 #endif /* CONFIG_ATARI */
417
418 #ifdef CONFIG_MAC
419 /*
420 * On a Macintoy, the VBL interrupt may or may not be active.
421 * As interrupt based cursor is more reliable and race free, we
422 * probe for VBL interrupts.
423 */
424 if (MACH_IS_MAC) {
425 int ct = 0;
426 /*
427 * Probe for VBL: set temp. handler ...
428 */
429 irqres = request_irq(IRQ_MAC_VBL, fbcon_vbl_detect, 0,
430 "console/cursor", fbcon_vbl_detect);
431 vbl_detected = 0;
432
433 /*
434 * ... and spin for 20 ms ...
435 */
436 while (!vbl_detected && ++ct<1000)
437 udelay(20);
438
439 if(ct==1000)
440 printk("fbcon_startup: No VBL detected, using timer based cursor.\n");
441
442 free_irq(IRQ_MAC_VBL, fbcon_vbl_detect);
443
444 if (vbl_detected) {
445 /*
446 * interrupt based cursor ok
447 */
448 cursor_blink_rate = MAC_CURSOR_BLINK_RATE;
449 irqres = request_irq(IRQ_MAC_VBL, fbcon_vbl_handler, 0,
450 "console/cursor", fbcon_vbl_handler);
451 } else {
452 /*
453 * VBL not detected: fall through, use timer based cursor
454 */
455 irqres = 1;
456 }
457 }
458 #endif /* CONFIG_MAC */
459
460 #if defined(__arm__) && defined(IRQ_VSYNCPULSE)
461 cursor_blink_rate = ARM_CURSOR_BLINK_RATE;
462 irqres = request_irq(IRQ_VSYNCPULSE, fbcon_vbl_handler, SA_SHIRQ,
463 "console/cursor", fbcon_vbl_handler);
464 #endif
465
466 if (irqres) {
467 use_timer_cursor = 1;
468 cursor_blink_rate = DEFAULT_CURSOR_BLINK_RATE;
469 cursor_timer.expires = jiffies+HZ/50;
470 add_timer(&cursor_timer);
471 }
472
473 #ifdef CONFIG_PM
474 pm_fbcon = pm_register(PM_SYS_DEV, PM_SYS_VGA, pm_fbcon_request);
475 #endif
476
477 return display_desc;
478 }
479
480
fbcon_init(struct vc_data * conp,int init)481 static void fbcon_init(struct vc_data *conp, int init)
482 {
483 int unit = conp->vc_num;
484 struct fb_info *info;
485
486 /* on which frame buffer will we open this console? */
487 info = registered_fb[(int)con2fb_map[unit]];
488
489 info->changevar = &fbcon_changevar;
490 fb_display[unit] = *(info->disp); /* copy from default */
491 DPRINTK("mode: %s\n",info->modename);
492 DPRINTK("visual: %d\n",fb_display[unit].visual);
493 DPRINTK("res: %dx%d-%d\n",fb_display[unit].var.xres,
494 fb_display[unit].var.yres,
495 fb_display[unit].var.bits_per_pixel);
496 fb_display[unit].conp = conp;
497 fb_display[unit].fb_info = info;
498 /* clear out the cmap so we don't have dangling pointers */
499 fb_display[unit].cmap.len = 0;
500 fb_display[unit].cmap.red = 0;
501 fb_display[unit].cmap.green = 0;
502 fb_display[unit].cmap.blue = 0;
503 fb_display[unit].cmap.transp = 0;
504 fbcon_setup(unit, init, !init);
505 /* Must be done after fbcon_setup to prevent excess updates */
506 conp->vc_display_fg = &info->display_fg;
507 if (!info->display_fg)
508 info->display_fg = conp;
509 }
510
511
fbcon_deinit(struct vc_data * conp)512 static void fbcon_deinit(struct vc_data *conp)
513 {
514 int unit = conp->vc_num;
515 struct display *p = &fb_display[unit];
516
517 fbcon_free_font(p);
518 p->dispsw = &fbcon_dummy;
519 p->conp = 0;
520 }
521
522
fbcon_changevar(int con)523 static int fbcon_changevar(int con)
524 {
525 if (fb_display[con].conp)
526 fbcon_setup(con, 0, 0);
527 return 0;
528 }
529
530
updatescrollmode(struct display * p)531 static __inline__ void updatescrollmode(struct display *p)
532 {
533 int m;
534 if (p->scrollmode & __SCROLL_YFIXED)
535 return;
536 if (divides(p->ywrapstep, fontheight(p)) &&
537 divides(fontheight(p), p->var.yres_virtual))
538 m = __SCROLL_YWRAP;
539 else if (divides(p->ypanstep, fontheight(p)) &&
540 p->var.yres_virtual >= p->var.yres+fontheight(p))
541 m = __SCROLL_YPAN;
542 else if (p->scrollmode & __SCROLL_YNOMOVE)
543 m = __SCROLL_YREDRAW;
544 else
545 m = __SCROLL_YMOVE;
546 p->scrollmode = (p->scrollmode & ~__SCROLL_YMASK) | m;
547 }
548
fbcon_font_widths(struct display * p)549 static void fbcon_font_widths(struct display *p)
550 {
551 int i;
552
553 p->_fontwidthlog = 0;
554 for (i = 2; i <= 6; i++)
555 if (fontwidth(p) == (1 << i))
556 p->_fontwidthlog = i;
557 p->_fontheightlog = 0;
558 for (i = 2; i <= 6; i++)
559 if (fontheight(p) == (1 << i))
560 p->_fontheightlog = i;
561 }
562
563 #define fontwidthvalid(p,w) ((p)->dispsw->fontwidthmask & FONTWIDTH(w))
564
fbcon_setup(int con,int init,int logo)565 static void fbcon_setup(int con, int init, int logo)
566 {
567 struct display *p = &fb_display[con];
568 struct vc_data *conp = p->conp;
569 int nr_rows, nr_cols;
570 int old_rows, old_cols;
571 unsigned short *save = NULL, *r, *q;
572 int i, charcnt = 256;
573 struct fbcon_font_desc *font;
574
575 if (con != fg_console || (p->fb_info->flags & FBINFO_FLAG_MODULE) ||
576 p->type == FB_TYPE_TEXT)
577 logo = 0;
578
579 p->var.xoffset = p->var.yoffset = p->yscroll = 0; /* reset wrap/pan */
580
581 if (con == fg_console && p->type != FB_TYPE_TEXT) {
582 if (fbcon_softback_size) {
583 if (!softback_buf) {
584 softback_buf = (unsigned long)kmalloc(fbcon_softback_size, GFP_KERNEL);
585 if (!softback_buf) {
586 fbcon_softback_size = 0;
587 softback_top = 0;
588 }
589 }
590 } else {
591 if (softback_buf) {
592 kfree((void *)softback_buf);
593 softback_buf = 0;
594 softback_top = 0;
595 }
596 }
597 if (softback_buf)
598 softback_in = softback_top = softback_curr = softback_buf;
599 softback_lines = 0;
600 }
601
602 for (i = 0; i < MAX_NR_CONSOLES; i++)
603 if (i != con && fb_display[i].fb_info == p->fb_info &&
604 fb_display[i].conp && fb_display[i].fontdata)
605 break;
606
607 fbcon_free_font(p);
608 if (i < MAX_NR_CONSOLES) {
609 struct display *q = &fb_display[i];
610
611 if (fontwidthvalid(p,fontwidth(q))) {
612 /* If we are not the first console on this
613 fb, copy the font from that console */
614 p->_fontwidth = q->_fontwidth;
615 p->_fontheight = q->_fontheight;
616 p->_fontwidthlog = q->_fontwidthlog;
617 p->_fontheightlog = q->_fontheightlog;
618 p->fontdata = q->fontdata;
619 p->userfont = q->userfont;
620 if (p->userfont) {
621 REFCOUNT(p->fontdata)++;
622 charcnt = FNTCHARCNT(p->fontdata);
623 }
624 con_copy_unimap(con, i);
625 }
626 }
627
628 if (!p->fontdata) {
629 if (!p->fb_info->fontname[0] ||
630 !(font = fbcon_find_font(p->fb_info->fontname)))
631 font = fbcon_get_default_font(p->var.xres, p->var.yres);
632 p->_fontwidth = font->width;
633 p->_fontheight = font->height;
634 p->fontdata = font->data;
635 fbcon_font_widths(p);
636 }
637
638 if (!fontwidthvalid(p,fontwidth(p))) {
639 #if defined(CONFIG_FBCON_MAC) && defined(CONFIG_MAC)
640 if (MACH_IS_MAC)
641 /* ++Geert: hack to make 6x11 fonts work on mac */
642 p->dispsw = &fbcon_mac;
643 else
644 #endif
645 {
646 /* ++Geert: changed from panic() to `correct and continue' */
647 printk(KERN_ERR "fbcon_setup: No support for fontwidth %d\n", fontwidth(p));
648 p->dispsw = &fbcon_dummy;
649 }
650 }
651 if (p->dispsw->set_font)
652 p->dispsw->set_font(p, fontwidth(p), fontheight(p));
653 updatescrollmode(p);
654
655 old_cols = conp->vc_cols;
656 old_rows = conp->vc_rows;
657
658 nr_cols = p->var.xres/fontwidth(p);
659 nr_rows = p->var.yres/fontheight(p);
660
661 if (logo) {
662 /* Need to make room for the logo */
663 int cnt, step, erase_char;
664
665 logo_lines = (LOGO_H + fontheight(p) - 1) / fontheight(p);
666 q = (unsigned short *)(conp->vc_origin + conp->vc_size_row * old_rows);
667 step = logo_lines * old_cols;
668 for (r = q - logo_lines * old_cols; r < q; r++)
669 if (scr_readw(r) != conp->vc_video_erase_char)
670 break;
671 if (r != q && nr_rows >= old_rows + logo_lines) {
672 save = kmalloc(logo_lines * nr_cols * 2, GFP_KERNEL);
673 if (save) {
674 int i = old_cols < nr_cols ? old_cols : nr_cols;
675 scr_memsetw(save, conp->vc_video_erase_char, logo_lines * nr_cols * 2);
676 r = q - step;
677 for (cnt = 0; cnt < logo_lines; cnt++, r += i)
678 scr_memcpyw(save + cnt * nr_cols, r, 2 * i);
679 r = q;
680 }
681 }
682 if (r == q) {
683 /* We can scroll screen down */
684 r = q - step - old_cols;
685 for (cnt = old_rows - logo_lines; cnt > 0; cnt--) {
686 scr_memcpyw(r + step, r, conp->vc_size_row);
687 r -= old_cols;
688 }
689 if (!save) {
690 conp->vc_y += logo_lines;
691 conp->vc_pos += logo_lines * conp->vc_size_row;
692 }
693 }
694 erase_char = conp->vc_video_erase_char;
695 if (! conp->vc_can_do_color)
696 erase_char &= ~0x400; /* disable underline */
697 scr_memsetw((unsigned short *)conp->vc_origin, erase_char,
698 conp->vc_size_row * logo_lines);
699 }
700
701 /*
702 * ++guenther: console.c:vc_allocate() relies on initializing
703 * vc_{cols,rows}, but we must not set those if we are only
704 * resizing the console.
705 */
706 if (init) {
707 conp->vc_cols = nr_cols;
708 conp->vc_rows = nr_rows;
709 }
710 p->vrows = p->var.yres_virtual/fontheight(p);
711 if ((p->var.yres % fontheight(p)) &&
712 (p->var.yres_virtual % fontheight(p) < p->var.yres % fontheight(p)))
713 p->vrows--;
714 conp->vc_can_do_color = p->var.bits_per_pixel != 1;
715 conp->vc_complement_mask = conp->vc_can_do_color ? 0x7700 : 0x0800;
716 if (charcnt == 256) {
717 conp->vc_hi_font_mask = 0;
718 p->fgshift = 8;
719 p->bgshift = 12;
720 p->charmask = 0xff;
721 } else {
722 conp->vc_hi_font_mask = 0x100;
723 if (conp->vc_can_do_color)
724 conp->vc_complement_mask <<= 1;
725 p->fgshift = 9;
726 p->bgshift = 13;
727 p->charmask = 0x1ff;
728 }
729
730 if (p->dispsw == &fbcon_dummy)
731 printk(KERN_WARNING "fbcon_setup: type %d (aux %d, depth %d) not "
732 "supported\n", p->type, p->type_aux, p->var.bits_per_pixel);
733 p->dispsw->setup(p);
734
735 p->fgcol = p->var.bits_per_pixel > 2 ? 7 : (1<<p->var.bits_per_pixel)-1;
736 p->bgcol = 0;
737
738 if (!init) {
739 if (conp->vc_cols != nr_cols || conp->vc_rows != nr_rows)
740 vc_resize_con(nr_rows, nr_cols, con);
741 else if (CON_IS_VISIBLE(conp) &&
742 vt_cons[conp->vc_num]->vc_mode == KD_TEXT) {
743 if (p->dispsw->clear_margins)
744 p->dispsw->clear_margins(conp, p, 0);
745 update_screen(con);
746 }
747 if (save) {
748 q = (unsigned short *)(conp->vc_origin + conp->vc_size_row * old_rows);
749 scr_memcpyw(q, save, logo_lines * nr_cols * 2);
750 conp->vc_y += logo_lines;
751 conp->vc_pos += logo_lines * conp->vc_size_row;
752 kfree(save);
753 }
754 }
755
756 if (logo) {
757 logo_shown = -2;
758 conp->vc_top = logo_lines;
759 }
760
761 if (con == fg_console && softback_buf) {
762 int l = fbcon_softback_size / conp->vc_size_row;
763 if (l > 5)
764 softback_end = softback_buf + l * conp->vc_size_row;
765 else {
766 /* Smaller scrollback makes no sense, and 0 would screw
767 the operation totally */
768 softback_top = 0;
769 }
770 }
771 }
772
773
774 /* ====================================================================== */
775
776 /* fbcon_XXX routines - interface used by the world
777 *
778 * This system is now divided into two levels because of complications
779 * caused by hardware scrolling. Top level functions:
780 *
781 * fbcon_bmove(), fbcon_clear(), fbcon_putc()
782 *
783 * handles y values in range [0, scr_height-1] that correspond to real
784 * screen positions. y_wrap shift means that first line of bitmap may be
785 * anywhere on this display. These functions convert lineoffsets to
786 * bitmap offsets and deal with the wrap-around case by splitting blits.
787 *
788 * fbcon_bmove_physical_8() -- These functions fast implementations
789 * fbcon_clear_physical_8() -- of original fbcon_XXX fns.
790 * fbcon_putc_physical_8() -- (fontwidth != 8) may be added later
791 *
792 * WARNING:
793 *
794 * At the moment fbcon_putc() cannot blit across vertical wrap boundary
795 * Implies should only really hardware scroll in rows. Only reason for
796 * restriction is simplicity & efficiency at the moment.
797 */
798
real_y(struct display * p,int ypos)799 static __inline__ int real_y(struct display *p, int ypos)
800 {
801 int rows = p->vrows;
802
803 ypos += p->yscroll;
804 return ypos < rows ? ypos : ypos-rows;
805 }
806
807
fbcon_clear(struct vc_data * conp,int sy,int sx,int height,int width)808 static void fbcon_clear(struct vc_data *conp, int sy, int sx, int height,
809 int width)
810 {
811 int unit = conp->vc_num;
812 struct display *p = &fb_display[unit];
813 u_int y_break;
814 int redraw_cursor = 0;
815
816 if (!p->can_soft_blank && console_blanked)
817 return;
818
819 if (!height || !width)
820 return;
821
822 if ((sy <= p->cursor_y) && (p->cursor_y < sy+height) &&
823 (sx <= p->cursor_x) && (p->cursor_x < sx+width)) {
824 cursor_undrawn();
825 redraw_cursor = 1;
826 }
827
828 /* Split blits that cross physical y_wrap boundary */
829
830 y_break = p->vrows-p->yscroll;
831 if (sy < y_break && sy+height-1 >= y_break) {
832 u_int b = y_break-sy;
833 p->dispsw->clear(conp, p, real_y(p, sy), sx, b, width);
834 p->dispsw->clear(conp, p, real_y(p, sy+b), sx, height-b, width);
835 } else
836 p->dispsw->clear(conp, p, real_y(p, sy), sx, height, width);
837
838 if (redraw_cursor)
839 vbl_cursor_cnt = CURSOR_DRAW_DELAY;
840 }
841
842
fbcon_putc(struct vc_data * conp,int c,int ypos,int xpos)843 static void fbcon_putc(struct vc_data *conp, int c, int ypos, int xpos)
844 {
845 int unit = conp->vc_num;
846 struct display *p = &fb_display[unit];
847 int redraw_cursor = 0;
848
849 if (!p->can_soft_blank && console_blanked)
850 return;
851
852 if (vt_cons[unit]->vc_mode != KD_TEXT)
853 return;
854
855 if ((p->cursor_x == xpos) && (p->cursor_y == ypos)) {
856 cursor_undrawn();
857 redraw_cursor = 1;
858 }
859
860 p->dispsw->putc(conp, p, c, real_y(p, ypos), xpos);
861
862 if (redraw_cursor)
863 vbl_cursor_cnt = CURSOR_DRAW_DELAY;
864 }
865
866
fbcon_putcs(struct vc_data * conp,const unsigned short * s,int count,int ypos,int xpos)867 static void fbcon_putcs(struct vc_data *conp, const unsigned short *s, int count,
868 int ypos, int xpos)
869 {
870 int unit = conp->vc_num;
871 struct display *p = &fb_display[unit];
872 int redraw_cursor = 0;
873
874 if (!p->can_soft_blank && console_blanked)
875 return;
876
877 if (vt_cons[unit]->vc_mode != KD_TEXT)
878 return;
879
880 if ((p->cursor_y == ypos) && (xpos <= p->cursor_x) &&
881 (p->cursor_x < (xpos + count))) {
882 cursor_undrawn();
883 redraw_cursor = 1;
884 }
885 p->dispsw->putcs(conp, p, s, count, real_y(p, ypos), xpos);
886 if (redraw_cursor)
887 vbl_cursor_cnt = CURSOR_DRAW_DELAY;
888 }
889
890
fbcon_cursor(struct vc_data * conp,int mode)891 static void fbcon_cursor(struct vc_data *conp, int mode)
892 {
893 int unit = conp->vc_num;
894 struct display *p = &fb_display[unit];
895 int y = conp->vc_y;
896
897 if (mode & CM_SOFTBACK) {
898 mode &= ~CM_SOFTBACK;
899 if (softback_lines) {
900 if (y + softback_lines >= conp->vc_rows)
901 mode = CM_ERASE;
902 else
903 y += softback_lines;
904 }
905 } else if (softback_lines)
906 fbcon_set_origin(conp);
907
908 /* do we have a hardware cursor ? */
909 if (p->dispsw->cursor) {
910 p->cursor_x = conp->vc_x;
911 p->cursor_y = y;
912 p->dispsw->cursor(p, mode, p->cursor_x, real_y(p, p->cursor_y));
913 return;
914 }
915
916 /* Avoid flickering if there's no real change. */
917 if (p->cursor_x == conp->vc_x && p->cursor_y == y &&
918 (mode == CM_ERASE) == !cursor_on)
919 return;
920
921 cursor_on = 0;
922 if (cursor_drawn && p->cursor_x < conp->vc_cols &&
923 p->cursor_y < conp->vc_rows)
924 p->dispsw->revc(p, p->cursor_x, real_y(p, p->cursor_y));
925
926 p->cursor_x = conp->vc_x;
927 p->cursor_y = y;
928
929 switch (mode) {
930 case CM_ERASE:
931 cursor_drawn = 0;
932 break;
933 case CM_MOVE:
934 case CM_DRAW:
935 if (cursor_drawn)
936 p->dispsw->revc(p, p->cursor_x, real_y(p, p->cursor_y));
937 vbl_cursor_cnt = CURSOR_DRAW_DELAY;
938 cursor_on = 1;
939 break;
940 }
941 }
942
943
fbcon_vbl_handler(int irq,void * dummy,struct pt_regs * fp)944 static void fbcon_vbl_handler(int irq, void *dummy, struct pt_regs *fp)
945 {
946 struct display *p;
947
948 if (!cursor_on)
949 return;
950
951 if (vbl_cursor_cnt && --vbl_cursor_cnt == 0) {
952 p = &fb_display[fg_console];
953 if (p->dispsw->revc)
954 p->dispsw->revc(p, p->cursor_x, real_y(p, p->cursor_y));
955 cursor_drawn ^= 1;
956 vbl_cursor_cnt = cursor_blink_rate;
957 }
958 }
959
960 static int scrollback_phys_max = 0;
961 static int scrollback_max = 0;
962 static int scrollback_current = 0;
963
ywrap_up(int unit,struct vc_data * conp,struct display * p,int count)964 static __inline__ void ywrap_up(int unit, struct vc_data *conp,
965 struct display *p, int count)
966 {
967 p->yscroll += count;
968 if (p->yscroll >= p->vrows) /* Deal with wrap */
969 p->yscroll -= p->vrows;
970 p->var.xoffset = 0;
971 p->var.yoffset = p->yscroll*fontheight(p);
972 p->var.vmode |= FB_VMODE_YWRAP;
973 p->fb_info->updatevar(unit, p->fb_info);
974 scrollback_max += count;
975 if (scrollback_max > scrollback_phys_max)
976 scrollback_max = scrollback_phys_max;
977 scrollback_current = 0;
978 }
979
980
ywrap_down(int unit,struct vc_data * conp,struct display * p,int count)981 static __inline__ void ywrap_down(int unit, struct vc_data *conp,
982 struct display *p, int count)
983 {
984 p->yscroll -= count;
985 if (p->yscroll < 0) /* Deal with wrap */
986 p->yscroll += p->vrows;
987 p->var.xoffset = 0;
988 p->var.yoffset = p->yscroll*fontheight(p);
989 p->var.vmode |= FB_VMODE_YWRAP;
990 p->fb_info->updatevar(unit, p->fb_info);
991 scrollback_max -= count;
992 if (scrollback_max < 0)
993 scrollback_max = 0;
994 scrollback_current = 0;
995 }
996
997
ypan_up(int unit,struct vc_data * conp,struct display * p,int count)998 static __inline__ void ypan_up(int unit, struct vc_data *conp,
999 struct display *p, int count)
1000 {
1001 p->yscroll += count;
1002 if (p->yscroll > p->vrows-conp->vc_rows) {
1003 p->dispsw->bmove(p, p->vrows-conp->vc_rows, 0, 0, 0,
1004 conp->vc_rows, conp->vc_cols);
1005 p->yscroll -= p->vrows-conp->vc_rows;
1006 }
1007 p->var.xoffset = 0;
1008 p->var.yoffset = p->yscroll*fontheight(p);
1009 p->var.vmode &= ~FB_VMODE_YWRAP;
1010 p->fb_info->updatevar(unit, p->fb_info);
1011 if (p->dispsw->clear_margins)
1012 p->dispsw->clear_margins(conp, p, 1);
1013 scrollback_max += count;
1014 if (scrollback_max > scrollback_phys_max)
1015 scrollback_max = scrollback_phys_max;
1016 scrollback_current = 0;
1017 }
1018
1019
ypan_down(int unit,struct vc_data * conp,struct display * p,int count)1020 static __inline__ void ypan_down(int unit, struct vc_data *conp,
1021 struct display *p, int count)
1022 {
1023 p->yscroll -= count;
1024 if (p->yscroll < 0) {
1025 p->dispsw->bmove(p, 0, 0, p->vrows-conp->vc_rows, 0,
1026 conp->vc_rows, conp->vc_cols);
1027 p->yscroll += p->vrows-conp->vc_rows;
1028 }
1029 p->var.xoffset = 0;
1030 p->var.yoffset = p->yscroll*fontheight(p);
1031 p->var.vmode &= ~FB_VMODE_YWRAP;
1032 p->fb_info->updatevar(unit, p->fb_info);
1033 if (p->dispsw->clear_margins)
1034 p->dispsw->clear_margins(conp, p, 1);
1035 scrollback_max -= count;
1036 if (scrollback_max < 0)
1037 scrollback_max = 0;
1038 scrollback_current = 0;
1039 }
1040
fbcon_redraw_softback(struct vc_data * conp,struct display * p,long delta)1041 static void fbcon_redraw_softback(struct vc_data *conp, struct display *p, long delta)
1042 {
1043 unsigned short *d, *s;
1044 unsigned long n;
1045 int line = 0;
1046 int count = conp->vc_rows;
1047
1048 d = (u16 *)softback_curr;
1049 if (d == (u16 *)softback_in)
1050 d = (u16 *)conp->vc_origin;
1051 n = softback_curr + delta * conp->vc_size_row;
1052 softback_lines -= delta;
1053 if (delta < 0) {
1054 if (softback_curr < softback_top && n < softback_buf) {
1055 n += softback_end - softback_buf;
1056 if (n < softback_top) {
1057 softback_lines -= (softback_top - n) / conp->vc_size_row;
1058 n = softback_top;
1059 }
1060 } else if (softback_curr >= softback_top && n < softback_top) {
1061 softback_lines -= (softback_top - n) / conp->vc_size_row;
1062 n = softback_top;
1063 }
1064 } else {
1065 if (softback_curr > softback_in && n >= softback_end) {
1066 n += softback_buf - softback_end;
1067 if (n > softback_in) {
1068 n = softback_in;
1069 softback_lines = 0;
1070 }
1071 } else if (softback_curr <= softback_in && n > softback_in) {
1072 n = softback_in;
1073 softback_lines = 0;
1074 }
1075 }
1076 if (n == softback_curr)
1077 return;
1078 softback_curr = n;
1079 s = (u16 *)softback_curr;
1080 if (s == (u16 *)softback_in)
1081 s = (u16 *)conp->vc_origin;
1082 while (count--) {
1083 unsigned short *start;
1084 unsigned short *le;
1085 unsigned short c;
1086 int x = 0;
1087 unsigned short attr = 1;
1088
1089 start = s;
1090 le = advance_row(s, 1);
1091 do {
1092 c = scr_readw(s);
1093 if (attr != (c & 0xff00)) {
1094 attr = c & 0xff00;
1095 if (s > start) {
1096 p->dispsw->putcs(conp, p, start, s - start,
1097 real_y(p, line), x);
1098 x += s - start;
1099 start = s;
1100 }
1101 }
1102 if (c == scr_readw(d)) {
1103 if (s > start) {
1104 p->dispsw->putcs(conp, p, start, s - start,
1105 real_y(p, line), x);
1106 x += s - start + 1;
1107 start = s + 1;
1108 } else {
1109 x++;
1110 start++;
1111 }
1112 }
1113 s++;
1114 d++;
1115 } while (s < le);
1116 if (s > start)
1117 p->dispsw->putcs(conp, p, start, s - start, real_y(p, line), x);
1118 line++;
1119 if (d == (u16 *)softback_end)
1120 d = (u16 *)softback_buf;
1121 if (d == (u16 *)softback_in)
1122 d = (u16 *)conp->vc_origin;
1123 if (s == (u16 *)softback_end)
1124 s = (u16 *)softback_buf;
1125 if (s == (u16 *)softback_in)
1126 s = (u16 *)conp->vc_origin;
1127 }
1128 }
1129
fbcon_redraw(struct vc_data * conp,struct display * p,int line,int count,int offset)1130 static void fbcon_redraw(struct vc_data *conp, struct display *p,
1131 int line, int count, int offset)
1132 {
1133 unsigned short *d = (unsigned short *)
1134 (conp->vc_origin + conp->vc_size_row * line);
1135 unsigned short *s = d + offset;
1136
1137 while (count--) {
1138 unsigned short *start = s;
1139 unsigned short *le = advance_row(s, 1);
1140 unsigned short c;
1141 int x = 0;
1142 unsigned short attr = 1;
1143
1144 do {
1145 c = scr_readw(s);
1146 if (attr != (c & 0xff00)) {
1147 attr = c & 0xff00;
1148 if (s > start) {
1149 p->dispsw->putcs(conp, p, start, s - start,
1150 real_y(p, line), x);
1151 x += s - start;
1152 start = s;
1153 }
1154 }
1155 if (c == scr_readw(d)) {
1156 if (s > start) {
1157 p->dispsw->putcs(conp, p, start, s - start,
1158 real_y(p, line), x);
1159 x += s - start + 1;
1160 start = s + 1;
1161 } else {
1162 x++;
1163 start++;
1164 }
1165 }
1166 scr_writew(c, d);
1167 console_conditional_schedule();
1168 s++;
1169 d++;
1170 } while (s < le);
1171 if (s > start)
1172 p->dispsw->putcs(conp, p, start, s - start, real_y(p, line), x);
1173 console_conditional_schedule();
1174 if (offset > 0)
1175 line++;
1176 else {
1177 line--;
1178 /* NOTE: We subtract two lines from these pointers */
1179 s -= conp->vc_size_row;
1180 d -= conp->vc_size_row;
1181 }
1182 }
1183 }
1184
1185 /**
1186 * fbcon_redraw_clear - clear area of the screen
1187 * @conp: stucture pointing to current active virtual console
1188 * @p: display structure
1189 * @sy: starting Y coordinate
1190 * @sx: starting X coordinate
1191 * @height: height of area to clear
1192 * @width: width of area to clear
1193 *
1194 * Clears a specified area of the screen. All dimensions are in
1195 * pixels.
1196 *
1197 */
1198
fbcon_redraw_clear(struct vc_data * conp,struct display * p,int sy,int sx,int height,int width)1199 void fbcon_redraw_clear(struct vc_data *conp, struct display *p, int sy, int sx,
1200 int height, int width)
1201 {
1202 int x, y;
1203 for (y=0; y<height; y++)
1204 for (x=0; x<width; x++)
1205 fbcon_putc(conp, ' ', sy+y, sx+x);
1206 }
1207
1208
1209 /**
1210 * fbcon_redraw_bmove - copy area of screen to another area
1211 * @p: display structure
1212 * @sy: origin Y coordinate
1213 * @sx: origin X coordinate
1214 * @dy: destination Y coordinate
1215 * @dx: destination X coordinate
1216 * @h: height of area to copy
1217 * @w: width of area to copy
1218 *
1219 * Copies an area of the screen to another area of the same screen.
1220 * All dimensions are in pixels.
1221 *
1222 * Note that this function cannot be used together with ypan or
1223 * ywrap.
1224 *
1225 */
1226
fbcon_redraw_bmove(struct display * p,int sy,int sx,int dy,int dx,int h,int w)1227 void fbcon_redraw_bmove(struct display *p, int sy, int sx, int dy, int dx, int h, int w)
1228 {
1229 if (sy != dy)
1230 panic("fbcon_redraw_bmove width sy != dy");
1231 /* h will be always 1, but it does not matter if we are more generic */
1232
1233 while (h-- > 0) {
1234 struct vc_data *conp = p->conp;
1235 unsigned short *d = (unsigned short *)
1236 (conp->vc_origin + conp->vc_size_row * dy + dx * 2);
1237 unsigned short *s = d + (dx - sx);
1238 unsigned short *start = d;
1239 unsigned short *ls = d;
1240 unsigned short *le = d + w;
1241 unsigned short c;
1242 int x = dx;
1243 unsigned short attr = 1;
1244
1245 do {
1246 c = scr_readw(d);
1247 if (attr != (c & 0xff00)) {
1248 attr = c & 0xff00;
1249 if (d > start) {
1250 p->dispsw->putcs(conp, p, start, d - start, dy, x);
1251 x += d - start;
1252 start = d;
1253 }
1254 }
1255 if (s >= ls && s < le && c == scr_readw(s)) {
1256 if (d > start) {
1257 p->dispsw->putcs(conp, p, start, d - start, dy, x);
1258 x += d - start + 1;
1259 start = d + 1;
1260 } else {
1261 x++;
1262 start++;
1263 }
1264 }
1265 s++;
1266 d++;
1267 } while (d < le);
1268 if (d > start)
1269 p->dispsw->putcs(conp, p, start, d - start, dy, x);
1270 sy++;
1271 dy++;
1272 }
1273 }
1274
fbcon_softback_note(struct vc_data * conp,int t,int count)1275 static inline void fbcon_softback_note(struct vc_data *conp, int t, int count)
1276 {
1277 unsigned short *p;
1278
1279 if (conp->vc_num != fg_console)
1280 return;
1281 p = (unsigned short *)(conp->vc_origin + t * conp->vc_size_row);
1282
1283 while (count) {
1284 scr_memcpyw((u16 *)softback_in, p, conp->vc_size_row);
1285 count--;
1286 p = advance_row(p, 1);
1287 softback_in += conp->vc_size_row;
1288 if (softback_in == softback_end)
1289 softback_in = softback_buf;
1290 if (softback_in == softback_top) {
1291 softback_top += conp->vc_size_row;
1292 if (softback_top == softback_end)
1293 softback_top = softback_buf;
1294 }
1295 }
1296 softback_curr = softback_in;
1297 }
1298
fbcon_scroll(struct vc_data * conp,int t,int b,int dir,int count)1299 static int fbcon_scroll(struct vc_data *conp, int t, int b, int dir,
1300 int count)
1301 {
1302 int unit = conp->vc_num;
1303 struct display *p = &fb_display[unit];
1304 int scroll_partial = !(p->scrollmode & __SCROLL_YNOPARTIAL);
1305
1306 if (!p->can_soft_blank && console_blanked)
1307 return 0;
1308
1309 if (!count || vt_cons[unit]->vc_mode != KD_TEXT)
1310 return 0;
1311
1312 fbcon_cursor(conp, CM_ERASE);
1313
1314 /*
1315 * ++Geert: Only use ywrap/ypan if the console is in text mode
1316 * ++Andrew: Only use ypan on hardware text mode when scrolling the
1317 * whole screen (prevents flicker).
1318 */
1319
1320 switch (dir) {
1321 case SM_UP:
1322 if (count > conp->vc_rows) /* Maximum realistic size */
1323 count = conp->vc_rows;
1324 if (softback_top)
1325 fbcon_softback_note(conp, t, count);
1326 if (logo_shown >= 0) goto redraw_up;
1327 switch (p->scrollmode & __SCROLL_YMASK) {
1328 case __SCROLL_YMOVE:
1329 p->dispsw->bmove(p, t+count, 0, t, 0, b-t-count,
1330 conp->vc_cols);
1331 p->dispsw->clear(conp, p, b-count, 0, count,
1332 conp->vc_cols);
1333 break;
1334
1335 case __SCROLL_YWRAP:
1336 if (b-t-count > 3*conp->vc_rows>>2) {
1337 if (t > 0)
1338 fbcon_bmove(conp, 0, 0, count, 0, t,
1339 conp->vc_cols);
1340 ywrap_up(unit, conp, p, count);
1341 if (conp->vc_rows-b > 0)
1342 fbcon_bmove(conp, b-count, 0, b, 0,
1343 conp->vc_rows-b, conp->vc_cols);
1344 } else if (p->scrollmode & __SCROLL_YPANREDRAW)
1345 goto redraw_up;
1346 else
1347 fbcon_bmove(conp, t+count, 0, t, 0, b-t-count,
1348 conp->vc_cols);
1349 fbcon_clear(conp, b-count, 0, count, conp->vc_cols);
1350 break;
1351
1352 case __SCROLL_YPAN:
1353 if (( p->yscroll + count <= 2 * (p->vrows - conp->vc_rows)) &&
1354 (( !scroll_partial && (b-t == conp->vc_rows)) ||
1355 ( scroll_partial && (b-t-count > 3*conp->vc_rows>>2)))) {
1356 if (t > 0)
1357 fbcon_bmove(conp, 0, 0, count, 0, t,
1358 conp->vc_cols);
1359 ypan_up(unit, conp, p, count);
1360 if (conp->vc_rows-b > 0)
1361 fbcon_bmove(conp, b-count, 0, b, 0,
1362 conp->vc_rows-b, conp->vc_cols);
1363 } else if (p->scrollmode & __SCROLL_YPANREDRAW)
1364 goto redraw_up;
1365 else
1366 fbcon_bmove(conp, t+count, 0, t, 0, b-t-count,
1367 conp->vc_cols);
1368 fbcon_clear(conp, b-count, 0, count, conp->vc_cols);
1369 break;
1370
1371 case __SCROLL_YREDRAW:
1372 redraw_up:
1373 fbcon_redraw(conp, p, t, b-t-count, count*conp->vc_cols);
1374 p->dispsw->clear(conp, p, real_y(p, b-count), 0,
1375 count, conp->vc_cols);
1376 scr_memsetw((unsigned short *)(conp->vc_origin +
1377 conp->vc_size_row * (b-count)),
1378 conp->vc_video_erase_char,
1379 conp->vc_size_row * count);
1380 return 1;
1381 }
1382 break;
1383
1384 case SM_DOWN:
1385 if (count > conp->vc_rows) /* Maximum realistic size */
1386 count = conp->vc_rows;
1387 switch (p->scrollmode & __SCROLL_YMASK) {
1388 case __SCROLL_YMOVE:
1389 p->dispsw->bmove(p, t, 0, t+count, 0, b-t-count,
1390 conp->vc_cols);
1391 p->dispsw->clear(conp, p, t, 0,
1392 count, conp->vc_cols);
1393 break;
1394
1395 case __SCROLL_YWRAP:
1396 if (b-t-count > 3*conp->vc_rows>>2) {
1397 if (conp->vc_rows-b > 0)
1398 fbcon_bmove(conp, b, 0, b-count, 0,
1399 conp->vc_rows-b, conp->vc_cols);
1400 ywrap_down(unit, conp, p, count);
1401 if (t > 0)
1402 fbcon_bmove(conp, count, 0, 0, 0, t,
1403 conp->vc_cols);
1404 } else if (p->scrollmode & __SCROLL_YPANREDRAW)
1405 goto redraw_down;
1406 else
1407 fbcon_bmove(conp, t, 0, t+count, 0, b-t-count,
1408 conp->vc_cols);
1409 fbcon_clear(conp, t, 0, count, conp->vc_cols);
1410 break;
1411
1412 case __SCROLL_YPAN:
1413 if (( count-p->yscroll <= p->vrows-conp->vc_rows) &&
1414 (( !scroll_partial && (b-t == conp->vc_rows)) ||
1415 ( scroll_partial && (b-t-count > 3*conp->vc_rows>>2)))) {
1416 if (conp->vc_rows-b > 0)
1417 fbcon_bmove(conp, b, 0, b-count, 0,
1418 conp->vc_rows-b, conp->vc_cols);
1419 ypan_down(unit, conp, p, count);
1420 if (t > 0)
1421 fbcon_bmove(conp, count, 0, 0, 0, t,
1422 conp->vc_cols);
1423 } else if (p->scrollmode & __SCROLL_YPANREDRAW)
1424 goto redraw_down;
1425 else
1426 fbcon_bmove(conp, t, 0, t+count, 0, b-t-count,
1427 conp->vc_cols);
1428 fbcon_clear(conp, t, 0, count, conp->vc_cols);
1429 break;
1430
1431 case __SCROLL_YREDRAW:
1432 redraw_down:
1433 fbcon_redraw(conp, p, b - 1, b-t-count, -count*conp->vc_cols);
1434 p->dispsw->clear(conp, p, real_y(p, t), 0,
1435 count, conp->vc_cols);
1436 scr_memsetw((unsigned short *)(conp->vc_origin +
1437 conp->vc_size_row * t),
1438 conp->vc_video_erase_char,
1439 conp->vc_size_row * count);
1440 return 1;
1441 }
1442 }
1443 return 0;
1444 }
1445
1446
fbcon_bmove(struct vc_data * conp,int sy,int sx,int dy,int dx,int height,int width)1447 static void fbcon_bmove(struct vc_data *conp, int sy, int sx, int dy, int dx,
1448 int height, int width)
1449 {
1450 int unit = conp->vc_num;
1451 struct display *p = &fb_display[unit];
1452
1453 if (!p->can_soft_blank && console_blanked)
1454 return;
1455
1456 if (!width || !height)
1457 return;
1458
1459 if (((sy <= p->cursor_y) && (p->cursor_y < sy+height) &&
1460 (sx <= p->cursor_x) && (p->cursor_x < sx+width)) ||
1461 ((dy <= p->cursor_y) && (p->cursor_y < dy+height) &&
1462 (dx <= p->cursor_x) && (p->cursor_x < dx+width)))
1463 fbcon_cursor(conp, CM_ERASE|CM_SOFTBACK);
1464
1465 /* Split blits that cross physical y_wrap case.
1466 * Pathological case involves 4 blits, better to use recursive
1467 * code rather than unrolled case
1468 *
1469 * Recursive invocations don't need to erase the cursor over and
1470 * over again, so we use fbcon_bmove_rec()
1471 */
1472 fbcon_bmove_rec(p, sy, sx, dy, dx, height, width, p->vrows-p->yscroll);
1473 }
1474
fbcon_bmove_rec(struct display * p,int sy,int sx,int dy,int dx,int height,int width,u_int y_break)1475 static void fbcon_bmove_rec(struct display *p, int sy, int sx, int dy, int dx,
1476 int height, int width, u_int y_break)
1477 {
1478 u_int b;
1479
1480 if (sy < y_break && sy+height > y_break) {
1481 b = y_break-sy;
1482 if (dy < sy) { /* Avoid trashing self */
1483 fbcon_bmove_rec(p, sy, sx, dy, dx, b, width, y_break);
1484 fbcon_bmove_rec(p, sy+b, sx, dy+b, dx, height-b, width, y_break);
1485 } else {
1486 fbcon_bmove_rec(p, sy+b, sx, dy+b, dx, height-b, width, y_break);
1487 fbcon_bmove_rec(p, sy, sx, dy, dx, b, width, y_break);
1488 }
1489 return;
1490 }
1491
1492 if (dy < y_break && dy+height > y_break) {
1493 b = y_break-dy;
1494 if (dy < sy) { /* Avoid trashing self */
1495 fbcon_bmove_rec(p, sy, sx, dy, dx, b, width, y_break);
1496 fbcon_bmove_rec(p, sy+b, sx, dy+b, dx, height-b, width, y_break);
1497 } else {
1498 fbcon_bmove_rec(p, sy+b, sx, dy+b, dx, height-b, width, y_break);
1499 fbcon_bmove_rec(p, sy, sx, dy, dx, b, width, y_break);
1500 }
1501 return;
1502 }
1503 p->dispsw->bmove(p, real_y(p, sy), sx, real_y(p, dy), dx, height, width);
1504 }
1505
1506
fbcon_switch(struct vc_data * conp)1507 static int fbcon_switch(struct vc_data *conp)
1508 {
1509 int unit = conp->vc_num;
1510 struct display *p = &fb_display[unit];
1511 struct fb_info *info = p->fb_info;
1512
1513 if (softback_top) {
1514 int l = fbcon_softback_size / conp->vc_size_row;
1515 if (softback_lines)
1516 fbcon_set_origin(conp);
1517 softback_top = softback_curr = softback_in = softback_buf;
1518 softback_lines = 0;
1519
1520 if (l > 5)
1521 softback_end = softback_buf + l * conp->vc_size_row;
1522 else {
1523 /* Smaller scrollback makes no sense, and 0 would screw
1524 the operation totally */
1525 softback_top = 0;
1526 }
1527 }
1528 if (logo_shown >= 0) {
1529 struct vc_data *conp2 = vc_cons[logo_shown].d;
1530
1531 if (conp2->vc_top == logo_lines && conp2->vc_bottom == conp2->vc_rows)
1532 conp2->vc_top = 0;
1533 logo_shown = -1;
1534 }
1535 p->var.yoffset = p->yscroll = 0;
1536 switch (p->scrollmode & __SCROLL_YMASK) {
1537 case __SCROLL_YWRAP:
1538 scrollback_phys_max = p->vrows-conp->vc_rows;
1539 break;
1540 case __SCROLL_YPAN:
1541 scrollback_phys_max = p->vrows-2*conp->vc_rows;
1542 if (scrollback_phys_max < 0)
1543 scrollback_phys_max = 0;
1544 break;
1545 default:
1546 scrollback_phys_max = 0;
1547 break;
1548 }
1549 scrollback_max = 0;
1550 scrollback_current = 0;
1551
1552 if (info && info->switch_con)
1553 (*info->switch_con)(unit, info);
1554 if (p->dispsw->clear_margins && vt_cons[unit]->vc_mode == KD_TEXT)
1555 p->dispsw->clear_margins(conp, p, 0);
1556 if (logo_shown == -2) {
1557 logo_shown = fg_console;
1558 fbcon_show_logo(); /* This is protected above by initmem_freed */
1559 update_region(fg_console,
1560 conp->vc_origin + conp->vc_size_row * conp->vc_top,
1561 conp->vc_size_row * (conp->vc_bottom - conp->vc_top) / 2);
1562 return 0;
1563 }
1564 return 1;
1565 }
1566
1567
fbcon_blank(struct vc_data * conp,int blank)1568 static int fbcon_blank(struct vc_data *conp, int blank)
1569 {
1570 struct display *p = &fb_display[conp->vc_num];
1571 struct fb_info *info = p->fb_info;
1572
1573 if (blank < 0) /* Entering graphics mode */
1574 return 0;
1575
1576 fbcon_cursor(p->conp, blank ? CM_ERASE : CM_DRAW);
1577
1578 if (!p->can_soft_blank) {
1579 if (blank) {
1580 if (p->visual == FB_VISUAL_MONO01) {
1581 if (p->screen_base)
1582 fb_memset255(p->screen_base,
1583 p->var.xres_virtual*p->var.yres_virtual*
1584 p->var.bits_per_pixel>>3);
1585 } else {
1586 unsigned short oldc;
1587 u_int height;
1588 u_int y_break;
1589
1590 oldc = conp->vc_video_erase_char;
1591 conp->vc_video_erase_char &= p->charmask;
1592 height = conp->vc_rows;
1593 y_break = p->vrows-p->yscroll;
1594 if (height > y_break) {
1595 p->dispsw->clear(conp, p, real_y(p, 0), 0, y_break, conp->vc_cols);
1596 p->dispsw->clear(conp, p, real_y(p, y_break), 0, height-y_break, conp->vc_cols);
1597 } else
1598 p->dispsw->clear(conp, p, real_y(p, 0), 0, height, conp->vc_cols);
1599 conp->vc_video_erase_char = oldc;
1600 }
1601 return 0;
1602 } else {
1603 /* Tell console.c that it has to restore the screen itself */
1604 return 1;
1605 }
1606 }
1607 (*info->blank)(blank, info);
1608 return 0;
1609 }
1610
fbcon_free_font(struct display * p)1611 static void fbcon_free_font(struct display *p)
1612 {
1613 if (p->userfont && p->fontdata &&
1614 (--REFCOUNT(p->fontdata) == 0))
1615 kfree(p->fontdata - FONT_EXTRA_WORDS*sizeof(int));
1616 p->fontdata = NULL;
1617 p->userfont = 0;
1618 }
1619
fbcon_get_font(int unit,struct console_font_op * op)1620 static inline int fbcon_get_font(int unit, struct console_font_op *op)
1621 {
1622 struct display *p = &fb_display[unit];
1623 u8 *data = op->data;
1624 u8 *fontdata = p->fontdata;
1625 int i, j;
1626
1627 #ifdef CONFIG_FBCON_FONTWIDTH8_ONLY
1628 if (fontwidth(p) != 8) return -EINVAL;
1629 #endif
1630 op->width = fontwidth(p);
1631 op->height = fontheight(p);
1632 op->charcount = (p->charmask == 0x1ff) ? 512 : 256;
1633 if (!op->data) return 0;
1634
1635 if (op->width <= 8) {
1636 j = fontheight(p);
1637 for (i = 0; i < op->charcount; i++) {
1638 memcpy(data, fontdata, j);
1639 memset(data+j, 0, 32-j);
1640 data += 32;
1641 fontdata += j;
1642 }
1643 }
1644 #ifndef CONFIG_FBCON_FONTWIDTH8_ONLY
1645 else if (op->width <= 16) {
1646 j = fontheight(p) * 2;
1647 for (i = 0; i < op->charcount; i++) {
1648 memcpy(data, fontdata, j);
1649 memset(data+j, 0, 64-j);
1650 data += 64;
1651 fontdata += j;
1652 }
1653 } else if (op->width <= 24) {
1654 for (i = 0; i < op->charcount; i++) {
1655 for (j = 0; j < fontheight(p); j++) {
1656 *data++ = fontdata[0];
1657 *data++ = fontdata[1];
1658 *data++ = fontdata[2];
1659 fontdata += sizeof(u32);
1660 }
1661 memset(data, 0, 3*(32-j));
1662 data += 3 * (32 - j);
1663 }
1664 } else {
1665 j = fontheight(p) * 4;
1666 for (i = 0; i < op->charcount; i++) {
1667 memcpy(data, fontdata, j);
1668 memset(data+j, 0, 128-j);
1669 data += 128;
1670 fontdata += j;
1671 }
1672 }
1673 #endif
1674 return 0;
1675 }
1676
fbcon_do_set_font(int unit,struct console_font_op * op,u8 * data,int userfont)1677 static int fbcon_do_set_font(int unit, struct console_font_op *op, u8 *data, int userfont)
1678 {
1679 struct display *p = &fb_display[unit];
1680 int resize;
1681 int w = op->width;
1682 int h = op->height;
1683 int cnt;
1684 char *old_data = NULL;
1685
1686 if (!fontwidthvalid(p,w)) {
1687 if (userfont && op->op != KD_FONT_OP_COPY)
1688 kfree(data - FONT_EXTRA_WORDS*sizeof(int));
1689 return -ENXIO;
1690 }
1691
1692 if (CON_IS_VISIBLE(p->conp) && softback_lines)
1693 fbcon_set_origin(p->conp);
1694
1695 resize = (w != fontwidth(p)) || (h != fontheight(p));
1696 if (p->userfont)
1697 old_data = p->fontdata;
1698 if (userfont)
1699 cnt = FNTCHARCNT(data);
1700 else
1701 cnt = 256;
1702 p->fontdata = data;
1703 if ((p->userfont = userfont))
1704 REFCOUNT(data)++;
1705 p->_fontwidth = w;
1706 p->_fontheight = h;
1707 if (p->conp->vc_hi_font_mask && cnt == 256) {
1708 p->conp->vc_hi_font_mask = 0;
1709 if (p->conp->vc_can_do_color)
1710 p->conp->vc_complement_mask >>= 1;
1711 p->fgshift--;
1712 p->bgshift--;
1713 p->charmask = 0xff;
1714
1715 /* ++Edmund: reorder the attribute bits */
1716 if (p->conp->vc_can_do_color) {
1717 struct vc_data *conp = p->conp;
1718 unsigned short *cp = (unsigned short *) conp->vc_origin;
1719 int count = conp->vc_screenbuf_size/2;
1720 unsigned short c;
1721 for (; count > 0; count--, cp++) {
1722 c = scr_readw(cp);
1723 scr_writew(((c & 0xfe00) >> 1) | (c & 0xff), cp);
1724 }
1725 c = conp->vc_video_erase_char;
1726 conp->vc_video_erase_char = ((c & 0xfe00) >> 1) | (c & 0xff);
1727 conp->vc_attr >>= 1;
1728 }
1729
1730 } else if (!p->conp->vc_hi_font_mask && cnt == 512) {
1731 p->conp->vc_hi_font_mask = 0x100;
1732 if (p->conp->vc_can_do_color)
1733 p->conp->vc_complement_mask <<= 1;
1734 p->fgshift++;
1735 p->bgshift++;
1736 p->charmask = 0x1ff;
1737
1738 /* ++Edmund: reorder the attribute bits */
1739 {
1740 struct vc_data *conp = p->conp;
1741 unsigned short *cp = (unsigned short *) conp->vc_origin;
1742 int count = conp->vc_screenbuf_size/2;
1743 unsigned short c;
1744 for (; count > 0; count--, cp++) {
1745 unsigned short newc;
1746 c = scr_readw(cp);
1747 if (conp->vc_can_do_color)
1748 newc = ((c & 0xff00) << 1) | (c & 0xff);
1749 else
1750 newc = c & ~0x100;
1751 scr_writew(newc, cp);
1752 }
1753 c = conp->vc_video_erase_char;
1754 if (conp->vc_can_do_color) {
1755 conp->vc_video_erase_char = ((c & 0xff00) << 1) | (c & 0xff);
1756 conp->vc_attr <<= 1;
1757 } else
1758 conp->vc_video_erase_char = c & ~0x100;
1759 }
1760
1761 }
1762 fbcon_font_widths(p);
1763
1764 if (resize) {
1765 struct vc_data *conp = p->conp;
1766 /* reset wrap/pan */
1767 p->var.xoffset = p->var.yoffset = p->yscroll = 0;
1768 p->vrows = p->var.yres_virtual/h;
1769 if ((p->var.yres % h) && (p->var.yres_virtual % h < p->var.yres % h))
1770 p->vrows--;
1771 updatescrollmode(p);
1772 vc_resize_con( p->var.yres/h, p->var.xres/w, unit );
1773 if (CON_IS_VISIBLE(conp) && softback_buf) {
1774 int l = fbcon_softback_size / conp->vc_size_row;
1775 if (l > 5)
1776 softback_end = softback_buf + l * conp->vc_size_row;
1777 else {
1778 /* Smaller scrollback makes no sense, and 0 would screw
1779 the operation totally */
1780 softback_top = 0;
1781 }
1782 }
1783 } else if (CON_IS_VISIBLE(p->conp) && vt_cons[unit]->vc_mode == KD_TEXT) {
1784 if (p->dispsw->clear_margins)
1785 p->dispsw->clear_margins(p->conp, p, 0);
1786 update_screen(unit);
1787 }
1788
1789 if (old_data && (--REFCOUNT(old_data) == 0))
1790 kfree(old_data - FONT_EXTRA_WORDS*sizeof(int));
1791
1792 return 0;
1793 }
1794
fbcon_copy_font(int unit,struct console_font_op * op)1795 static inline int fbcon_copy_font(int unit, struct console_font_op *op)
1796 {
1797 struct display *od, *p = &fb_display[unit];
1798 int h = op->height;
1799
1800 if (h < 0 || !vc_cons_allocated( h ))
1801 return -ENOTTY;
1802 if (h == unit)
1803 return 0; /* nothing to do */
1804 od = &fb_display[h];
1805 if (od->fontdata == p->fontdata)
1806 return 0; /* already the same font... */
1807 op->width = fontwidth(od);
1808 op->height = fontheight(od);
1809 return fbcon_do_set_font(unit, op, od->fontdata, od->userfont);
1810 }
1811
fbcon_set_font(int unit,struct console_font_op * op)1812 static inline int fbcon_set_font(int unit, struct console_font_op *op)
1813 {
1814 int w = op->width;
1815 int h = op->height;
1816 int size = h;
1817 int i, k;
1818 u8 *new_data, *data = op->data, *p;
1819
1820 #ifdef CONFIG_FBCON_FONTWIDTH8_ONLY
1821 if (w != 8)
1822 return -EINVAL;
1823 #endif
1824 if ((w <= 0) || (w > 32) || (op->charcount != 256 && op->charcount != 512))
1825 return -EINVAL;
1826
1827 if (w > 8) {
1828 if (w <= 16)
1829 size *= 2;
1830 else
1831 size *= 4;
1832 }
1833 size *= op->charcount;
1834
1835 if (!(new_data = kmalloc(FONT_EXTRA_WORDS*sizeof(int)+size, GFP_USER)))
1836 return -ENOMEM;
1837 new_data += FONT_EXTRA_WORDS*sizeof(int);
1838 FNTSIZE(new_data) = size;
1839 FNTCHARCNT(new_data) = op->charcount;
1840 REFCOUNT(new_data) = 0; /* usage counter */
1841 p = new_data;
1842 if (w <= 8) {
1843 for (i = 0; i < op->charcount; i++) {
1844 memcpy(p, data, h);
1845 data += 32;
1846 p += h;
1847 }
1848 }
1849 #ifndef CONFIG_FBCON_FONTWIDTH8_ONLY
1850 else if (w <= 16) {
1851 h *= 2;
1852 for (i = 0; i < op->charcount; i++) {
1853 memcpy(p, data, h);
1854 data += 64;
1855 p += h;
1856 }
1857 } else if (w <= 24) {
1858 for (i = 0; i < op->charcount; i++) {
1859 int j;
1860 for (j = 0; j < h; j++) {
1861 memcpy(p, data, 3);
1862 p[3] = 0;
1863 data += 3;
1864 p += sizeof(u32);
1865 }
1866 data += 3*(32 - h);
1867 }
1868 } else {
1869 h *= 4;
1870 for (i = 0; i < op->charcount; i++) {
1871 memcpy(p, data, h);
1872 data += 128;
1873 p += h;
1874 }
1875 }
1876 #endif
1877 /* we can do it in u32 chunks because of charcount is 256 or 512, so
1878 font length must be multiple of 256, at least. And 256 is multiple
1879 of 4 */
1880 k = 0;
1881 while (p > new_data) {
1882 p = (u8 *)((u32 *)p - 1);
1883 k += *(u32 *) p;
1884 }
1885 FNTSUM(new_data) = k;
1886 /* Check if the same font is on some other console already */
1887 for (i = 0; i < MAX_NR_CONSOLES; i++) {
1888 if (fb_display[i].userfont &&
1889 fb_display[i].fontdata &&
1890 FNTSUM(fb_display[i].fontdata) == k &&
1891 FNTSIZE(fb_display[i].fontdata) == size &&
1892 fontwidth(&fb_display[i]) == w &&
1893 !memcmp(fb_display[i].fontdata, new_data, size)) {
1894 kfree(new_data - FONT_EXTRA_WORDS*sizeof(int));
1895 new_data = fb_display[i].fontdata;
1896 break;
1897 }
1898 }
1899 return fbcon_do_set_font(unit, op, new_data, 1);
1900 }
1901
fbcon_set_def_font(int unit,struct console_font_op * op)1902 static inline int fbcon_set_def_font(int unit, struct console_font_op *op)
1903 {
1904 char name[MAX_FONT_NAME];
1905 struct fbcon_font_desc *f;
1906 struct display *p = &fb_display[unit];
1907
1908 if (!op->data)
1909 f = fbcon_get_default_font(p->var.xres, p->var.yres);
1910 else if (strncpy_from_user(name, op->data, MAX_FONT_NAME-1) < 0)
1911 return -EFAULT;
1912 else {
1913 name[MAX_FONT_NAME-1] = 0;
1914 if (!(f = fbcon_find_font(name)))
1915 return -ENOENT;
1916 }
1917 op->width = f->width;
1918 op->height = f->height;
1919 return fbcon_do_set_font(unit, op, f->data, 0);
1920 }
1921
fbcon_font_op(struct vc_data * conp,struct console_font_op * op)1922 static int fbcon_font_op(struct vc_data *conp, struct console_font_op *op)
1923 {
1924 int unit = conp->vc_num;
1925
1926 switch (op->op) {
1927 case KD_FONT_OP_SET:
1928 return fbcon_set_font(unit, op);
1929 case KD_FONT_OP_GET:
1930 return fbcon_get_font(unit, op);
1931 case KD_FONT_OP_SET_DEFAULT:
1932 return fbcon_set_def_font(unit, op);
1933 case KD_FONT_OP_COPY:
1934 return fbcon_copy_font(unit, op);
1935 default:
1936 return -ENOSYS;
1937 }
1938 }
1939
1940 static u16 palette_red[16];
1941 static u16 palette_green[16];
1942 static u16 palette_blue[16];
1943
1944 static struct fb_cmap palette_cmap = {
1945 0, 16, palette_red, palette_green, palette_blue, NULL
1946 };
1947
fbcon_set_palette(struct vc_data * conp,unsigned char * table)1948 static int fbcon_set_palette(struct vc_data *conp, unsigned char *table)
1949 {
1950 int unit = conp->vc_num;
1951 struct display *p = &fb_display[unit];
1952 int i, j, k;
1953 u8 val;
1954
1955 if (!conp->vc_can_do_color || (!p->can_soft_blank && console_blanked))
1956 return -EINVAL;
1957 for (i = j = 0; i < 16; i++) {
1958 k = table[i];
1959 val = conp->vc_palette[j++];
1960 palette_red[k] = (val<<8)|val;
1961 val = conp->vc_palette[j++];
1962 palette_green[k] = (val<<8)|val;
1963 val = conp->vc_palette[j++];
1964 palette_blue[k] = (val<<8)|val;
1965 }
1966 if (p->var.bits_per_pixel <= 4)
1967 palette_cmap.len = 1<<p->var.bits_per_pixel;
1968 else
1969 palette_cmap.len = 16;
1970 palette_cmap.start = 0;
1971 return p->fb_info->fbops->fb_set_cmap(&palette_cmap, 1, unit, p->fb_info);
1972 }
1973
fbcon_screen_pos(struct vc_data * conp,int offset)1974 static u16 *fbcon_screen_pos(struct vc_data *conp, int offset)
1975 {
1976 int line;
1977 unsigned long p;
1978
1979 if (conp->vc_num != fg_console || !softback_lines)
1980 return (u16 *)(conp->vc_origin + offset);
1981 line = offset / conp->vc_size_row;
1982 if (line >= softback_lines)
1983 return (u16 *)(conp->vc_origin + offset - softback_lines * conp->vc_size_row);
1984 p = softback_curr + offset;
1985 if (p >= softback_end)
1986 p += softback_buf - softback_end;
1987 return (u16 *)p;
1988 }
1989
fbcon_getxy(struct vc_data * conp,unsigned long pos,int * px,int * py)1990 static unsigned long fbcon_getxy(struct vc_data *conp, unsigned long pos, int *px, int *py)
1991 {
1992 int x, y;
1993 unsigned long ret;
1994 if (pos >= conp->vc_origin && pos < conp->vc_scr_end) {
1995 unsigned long offset = (pos - conp->vc_origin) / 2;
1996
1997 x = offset % conp->vc_cols;
1998 y = offset / conp->vc_cols;
1999 if (conp->vc_num == fg_console)
2000 y += softback_lines;
2001 ret = pos + (conp->vc_cols - x) * 2;
2002 } else if (conp->vc_num == fg_console && softback_lines) {
2003 unsigned long offset = pos - softback_curr;
2004
2005 if (pos < softback_curr)
2006 offset += softback_end - softback_buf;
2007 offset /= 2;
2008 x = offset % conp->vc_cols;
2009 y = offset / conp->vc_cols;
2010 ret = pos + (conp->vc_cols - x) * 2;
2011 if (ret == softback_end)
2012 ret = softback_buf;
2013 if (ret == softback_in)
2014 ret = conp->vc_origin;
2015 } else {
2016 /* Should not happen */
2017 x = y = 0;
2018 ret = conp->vc_origin;
2019 }
2020 if (px) *px = x;
2021 if (py) *py = y;
2022 return ret;
2023 }
2024
2025 /* As we might be inside of softback, we may work with non-contiguous buffer,
2026 that's why we have to use a separate routine. */
fbcon_invert_region(struct vc_data * conp,u16 * p,int cnt)2027 static void fbcon_invert_region(struct vc_data *conp, u16 *p, int cnt)
2028 {
2029 while (cnt--) {
2030 u16 a = scr_readw(p);
2031 if (!conp->vc_can_do_color)
2032 a ^= 0x0800;
2033 else if (conp->vc_hi_font_mask == 0x100)
2034 a = ((a) & 0x11ff) | (((a) & 0xe000) >> 4) | (((a) & 0x0e00) << 4);
2035 else
2036 a = ((a) & 0x88ff) | (((a) & 0x7000) >> 4) | (((a) & 0x0700) << 4);
2037 scr_writew(a, p++);
2038 if (p == (u16 *)softback_end)
2039 p = (u16 *)softback_buf;
2040 if (p == (u16 *)softback_in)
2041 p = (u16 *)conp->vc_origin;
2042 }
2043 }
2044
fbcon_scrolldelta(struct vc_data * conp,int lines)2045 static int fbcon_scrolldelta(struct vc_data *conp, int lines)
2046 {
2047 int unit, offset, limit, scrollback_old;
2048 struct display *p;
2049
2050 unit = fg_console;
2051 p = &fb_display[unit];
2052 if (softback_top) {
2053 if (conp->vc_num != unit)
2054 return 0;
2055 if (vt_cons[unit]->vc_mode != KD_TEXT || !lines)
2056 return 0;
2057 if (logo_shown >= 0) {
2058 struct vc_data *conp2 = vc_cons[logo_shown].d;
2059
2060 if (conp2->vc_top == logo_lines && conp2->vc_bottom == conp2->vc_rows)
2061 conp2->vc_top = 0;
2062 if (logo_shown == unit) {
2063 unsigned long p, q;
2064 int i;
2065
2066 p = softback_in;
2067 q = conp->vc_origin + logo_lines * conp->vc_size_row;
2068 for (i = 0; i < logo_lines; i++) {
2069 if (p == softback_top) break;
2070 if (p == softback_buf) p = softback_end;
2071 p -= conp->vc_size_row;
2072 q -= conp->vc_size_row;
2073 scr_memcpyw((u16 *)q, (u16 *)p, conp->vc_size_row);
2074 }
2075 softback_in = p;
2076 update_region(unit, conp->vc_origin, logo_lines * conp->vc_cols);
2077 }
2078 logo_shown = -1;
2079 }
2080 fbcon_cursor(conp, CM_ERASE|CM_SOFTBACK);
2081 fbcon_redraw_softback(conp, p, lines);
2082 fbcon_cursor(conp, CM_DRAW|CM_SOFTBACK);
2083 return 0;
2084 }
2085
2086 if (!scrollback_phys_max)
2087 return -ENOSYS;
2088
2089 scrollback_old = scrollback_current;
2090 scrollback_current -= lines;
2091 if (scrollback_current < 0)
2092 scrollback_current = 0;
2093 else if (scrollback_current > scrollback_max)
2094 scrollback_current = scrollback_max;
2095 if (scrollback_current == scrollback_old)
2096 return 0;
2097
2098 if (!p->can_soft_blank &&
2099 (console_blanked || vt_cons[unit]->vc_mode != KD_TEXT || !lines))
2100 return 0;
2101 fbcon_cursor(conp, CM_ERASE);
2102
2103 offset = p->yscroll-scrollback_current;
2104 limit = p->vrows;
2105 switch (p->scrollmode & __SCROLL_YMASK) {
2106 case __SCROLL_YWRAP:
2107 p->var.vmode |= FB_VMODE_YWRAP;
2108 break;
2109 case __SCROLL_YPAN:
2110 limit -= conp->vc_rows;
2111 p->var.vmode &= ~FB_VMODE_YWRAP;
2112 break;
2113 }
2114 if (offset < 0)
2115 offset += limit;
2116 else if (offset >= limit)
2117 offset -= limit;
2118 p->var.xoffset = 0;
2119 p->var.yoffset = offset*fontheight(p);
2120 p->fb_info->updatevar(unit, p->fb_info);
2121 if (!scrollback_current)
2122 fbcon_cursor(conp, CM_DRAW);
2123 return 0;
2124 }
2125
fbcon_set_origin(struct vc_data * conp)2126 static int fbcon_set_origin(struct vc_data *conp)
2127 {
2128 if (softback_lines && !console_blanked)
2129 fbcon_scrolldelta(conp, softback_lines);
2130 return 0;
2131 }
2132
safe_shift(unsigned d,int n)2133 static inline unsigned safe_shift(unsigned d,int n)
2134 {
2135 return n<0 ? d>>-n : d<<n;
2136 }
2137
fbcon_show_logo(void)2138 static int __init fbcon_show_logo( void )
2139 {
2140 struct display *p = &fb_display[fg_console]; /* draw to vt in foreground */
2141 int depth = p->var.bits_per_pixel;
2142 int line = p->next_line;
2143 unsigned char *fb = p->screen_base;
2144 unsigned char *logo;
2145 unsigned char *dst, *src;
2146 int i, j, n, x1, y1, x;
2147 int logo_depth, done = 0;
2148
2149 /* Return if the frame buffer is not mapped */
2150 if (!fb)
2151 return 0;
2152
2153 /*
2154 * Set colors if visual is PSEUDOCOLOR and we have enough colors, or for
2155 * DIRECTCOLOR
2156 * We don't have to set the colors for the 16-color logo, since that logo
2157 * uses the standard VGA text console palette
2158 */
2159 if ((p->visual == FB_VISUAL_PSEUDOCOLOR && depth >= 8) ||
2160 (p->visual == FB_VISUAL_DIRECTCOLOR && depth >= 24))
2161 for (i = 0; i < LINUX_LOGO_COLORS; i += n) {
2162 n = LINUX_LOGO_COLORS - i;
2163 if (n > 16)
2164 /* palette_cmap provides space for only 16 colors at once */
2165 n = 16;
2166 palette_cmap.start = 32 + i;
2167 palette_cmap.len = n;
2168 for( j = 0; j < n; ++j ) {
2169 palette_cmap.red[j] = (linux_logo_red[i+j] << 8) |
2170 linux_logo_red[i+j];
2171 palette_cmap.green[j] = (linux_logo_green[i+j] << 8) |
2172 linux_logo_green[i+j];
2173 palette_cmap.blue[j] = (linux_logo_blue[i+j] << 8) |
2174 linux_logo_blue[i+j];
2175 }
2176 p->fb_info->fbops->fb_set_cmap(&palette_cmap, 1, fg_console,
2177 p->fb_info);
2178 }
2179
2180 if (depth >= 8) {
2181 logo = linux_logo;
2182 logo_depth = 8;
2183 }
2184 else if (depth >= 4) {
2185 logo = linux_logo16;
2186 logo_depth = 4;
2187 }
2188 else {
2189 logo = linux_logo_bw;
2190 logo_depth = 1;
2191 }
2192
2193 if (p->fb_info->fbops->fb_rasterimg)
2194 p->fb_info->fbops->fb_rasterimg(p->fb_info, 1);
2195
2196 for (x = 0; x < smp_num_cpus * (LOGO_W + 8) &&
2197 x < p->var.xres - (LOGO_W + 8); x += (LOGO_W + 8)) {
2198
2199 #if defined(CONFIG_FBCON_CFB16) || defined(CONFIG_FBCON_CFB24) || \
2200 defined(CONFIG_FBCON_CFB32) || defined(CONFIG_FB_SBUS)
2201 if (p->visual == FB_VISUAL_DIRECTCOLOR) {
2202 unsigned int val; /* max. depth 32! */
2203 int bdepth;
2204 int redshift, greenshift, blueshift;
2205
2206 /* Bug: Doesn't obey msb_right ... (who needs that?) */
2207 redshift = p->var.red.offset;
2208 greenshift = p->var.green.offset;
2209 blueshift = p->var.blue.offset;
2210
2211 if (depth >= 24 && (depth % 8) == 0) {
2212 /* have at least 8 bits per color */
2213 src = logo;
2214 bdepth = depth/8;
2215 for( y1 = 0; y1 < LOGO_H; y1++ ) {
2216 dst = fb + y1*line + x*bdepth;
2217 for( x1 = 0; x1 < LOGO_W; x1++, src++ ) {
2218 val = (*src << redshift) |
2219 (*src << greenshift) |
2220 (*src << blueshift);
2221 if (bdepth == 4 && !((long)dst & 3)) {
2222 /* Some cards require 32bit access */
2223 fb_writel (val, dst);
2224 dst += 4;
2225 } else if (bdepth == 2 && !((long)dst & 1)) {
2226 /* others require 16bit access */
2227 fb_writew (val,dst);
2228 dst +=2;
2229 } else {
2230 #ifdef __LITTLE_ENDIAN
2231 for( i = 0; i < bdepth; ++i )
2232 #else
2233 for( i = bdepth-1; i >= 0; --i )
2234 #endif
2235 fb_writeb (val >> (i*8), dst++);
2236 }
2237 }
2238 }
2239 }
2240 else if (depth >= 12 && depth <= 23) {
2241 /* have 4..7 bits per color, using 16 color image */
2242 unsigned int pix;
2243 src = linux_logo16;
2244 bdepth = (depth+7)/8;
2245 for( y1 = 0; y1 < LOGO_H; y1++ ) {
2246 dst = fb + y1*line + x*bdepth;
2247 for( x1 = 0; x1 < LOGO_W/2; x1++, src++ ) {
2248 pix = *src >> 4; /* upper nibble */
2249 val = (pix << redshift) |
2250 (pix << greenshift) |
2251 (pix << blueshift);
2252 #ifdef __LITTLE_ENDIAN
2253 for( i = 0; i < bdepth; ++i )
2254 #else
2255 for( i = bdepth-1; i >= 0; --i )
2256 #endif
2257 fb_writeb (val >> (i*8), dst++);
2258 pix = *src & 0x0f; /* lower nibble */
2259 val = (pix << redshift) |
2260 (pix << greenshift) |
2261 (pix << blueshift);
2262 #ifdef __LITTLE_ENDIAN
2263 for( i = 0; i < bdepth; ++i )
2264 #else
2265 for( i = bdepth-1; i >= 0; --i )
2266 #endif
2267 fb_writeb (val >> (i*8), dst++);
2268 }
2269 }
2270 }
2271 done = 1;
2272 }
2273 #endif
2274 #if defined(CONFIG_FBCON_CFB16) || defined(CONFIG_FBCON_CFB24) || \
2275 defined(CONFIG_FBCON_CFB32) || defined(CONFIG_FB_SBUS)
2276 if ((depth % 8 == 0) && (p->visual == FB_VISUAL_TRUECOLOR)) {
2277 /* Modes without color mapping, needs special data transformation... */
2278 unsigned int val; /* max. depth 32! */
2279 int bdepth = depth/8;
2280 unsigned char mask[9] = { 0,0x80,0xc0,0xe0,0xf0,0xf8,0xfc,0xfe,0xff };
2281 unsigned char redmask, greenmask, bluemask;
2282 int redshift, greenshift, blueshift;
2283
2284 /* Bug: Doesn't obey msb_right ... (who needs that?) */
2285 redmask = mask[p->var.red.length < 8 ? p->var.red.length : 8];
2286 greenmask = mask[p->var.green.length < 8 ? p->var.green.length : 8];
2287 bluemask = mask[p->var.blue.length < 8 ? p->var.blue.length : 8];
2288 redshift = p->var.red.offset - (8-p->var.red.length);
2289 greenshift = p->var.green.offset - (8-p->var.green.length);
2290 blueshift = p->var.blue.offset - (8-p->var.blue.length);
2291
2292 src = logo;
2293 for( y1 = 0; y1 < LOGO_H; y1++ ) {
2294 dst = fb + y1*line + x*bdepth;
2295 for( x1 = 0; x1 < LOGO_W; x1++, src++ ) {
2296 val = safe_shift((linux_logo_red[*src-32] & redmask), redshift) |
2297 safe_shift((linux_logo_green[*src-32] & greenmask), greenshift) |
2298 safe_shift((linux_logo_blue[*src-32] & bluemask), blueshift);
2299 if (bdepth == 4 && !((long)dst & 3)) {
2300 /* Some cards require 32bit access */
2301 fb_writel (val, dst);
2302 dst += 4;
2303 } else if (bdepth == 2 && !((long)dst & 1)) {
2304 /* others require 16bit access */
2305 fb_writew (val,dst);
2306 dst +=2;
2307 } else {
2308 #ifdef __LITTLE_ENDIAN
2309 for( i = 0; i < bdepth; ++i )
2310 #else
2311 for( i = bdepth-1; i >= 0; --i )
2312 #endif
2313 fb_writeb (val >> (i*8), dst++);
2314 }
2315 }
2316 }
2317 done = 1;
2318 }
2319 #endif
2320 #if defined(CONFIG_FBCON_CFB4)
2321 if (depth == 4 && p->type == FB_TYPE_PACKED_PIXELS) {
2322 src = logo;
2323 for( y1 = 0; y1 < LOGO_H; y1++) {
2324 dst = fb + y1*line + x/2;
2325 for( x1 = 0; x1 < LOGO_W/2; x1++) {
2326 u8 q = *src++;
2327 q = (q << 4) | (q >> 4);
2328 fb_writeb (q, dst++);
2329 }
2330 }
2331 done = 1;
2332 }
2333 #endif
2334 #if defined(CONFIG_FBCON_CFB8) || defined(CONFIG_FB_SBUS)
2335 if (depth == 8 && p->type == FB_TYPE_PACKED_PIXELS) {
2336 /* depth 8 or more, packed, with color registers */
2337
2338 src = logo;
2339 for( y1 = 0; y1 < LOGO_H; y1++ ) {
2340 dst = fb + y1*line + x;
2341 for( x1 = 0; x1 < LOGO_W; x1++ )
2342 fb_writeb (*src++, dst++);
2343 }
2344 done = 1;
2345 }
2346 #endif
2347 #if defined(CONFIG_FBCON_AFB) || defined(CONFIG_FBCON_ILBM) || \
2348 defined(CONFIG_FBCON_IPLAN2P2) || defined(CONFIG_FBCON_IPLAN2P4) || \
2349 defined(CONFIG_FBCON_IPLAN2P8)
2350 if (depth >= 2 && (p->type == FB_TYPE_PLANES ||
2351 p->type == FB_TYPE_INTERLEAVED_PLANES)) {
2352 /* planes (normal or interleaved), with color registers */
2353 int bit;
2354 unsigned char val, mask;
2355 int plane = p->next_plane;
2356
2357 #if defined(CONFIG_FBCON_IPLAN2P2) || defined(CONFIG_FBCON_IPLAN2P4) || \
2358 defined(CONFIG_FBCON_IPLAN2P8)
2359 int line_length = p->line_length;
2360
2361 /* for support of Atari interleaved planes */
2362 #define MAP_X(x) (line_length ? (x) : ((x) & ~1)*depth + ((x) & 1))
2363 #else
2364 #define MAP_X(x) (x)
2365 #endif
2366 /* extract a bit from the source image */
2367 #define BIT(p,pix,bit) (p[pix*logo_depth/8] & \
2368 (1 << ((8-((pix*logo_depth)&7)-logo_depth) + bit)))
2369
2370 src = logo;
2371 for( y1 = 0; y1 < LOGO_H; y1++ ) {
2372 for( x1 = 0; x1 < LOGO_LINE; x1++, src += logo_depth ) {
2373 dst = fb + y1*line + MAP_X(x/8+x1);
2374 for( bit = 0; bit < logo_depth; bit++ ) {
2375 val = 0;
2376 for( mask = 0x80, i = 0; i < 8; mask >>= 1, i++ ) {
2377 if (BIT( src, i, bit ))
2378 val |= mask;
2379 }
2380 *dst = val;
2381 dst += plane;
2382 }
2383 }
2384 }
2385
2386 /* fill remaining planes */
2387 if (depth > logo_depth) {
2388 for( y1 = 0; y1 < LOGO_H; y1++ ) {
2389 for( x1 = 0; x1 < LOGO_LINE; x1++ ) {
2390 dst = fb + y1*line + MAP_X(x/8+x1) + logo_depth*plane;
2391 for( i = logo_depth; i < depth; i++, dst += plane )
2392 *dst = 0x00;
2393 }
2394 }
2395 }
2396 done = 1;
2397 break;
2398 }
2399 #endif
2400 #if defined(CONFIG_FBCON_MFB) || defined(CONFIG_FBCON_AFB) || \
2401 defined(CONFIG_FBCON_ILBM) || defined(CONFIG_FBCON_HGA)
2402
2403 if (depth == 1 && (p->type == FB_TYPE_PACKED_PIXELS ||
2404 p->type == FB_TYPE_PLANES ||
2405 p->type == FB_TYPE_INTERLEAVED_PLANES)) {
2406
2407 /* monochrome */
2408 unsigned char inverse = p->inverse || p->visual == FB_VISUAL_MONO01
2409 ? 0x00 : 0xff;
2410
2411 int is_hga = !strncmp(p->fb_info->modename, "HGA", 3);
2412 /* can't use simply memcpy because need to apply inverse */
2413 for( y1 = 0; y1 < LOGO_H; y1++ ) {
2414 src = logo + y1*LOGO_LINE;
2415 if (is_hga)
2416 dst = fb + (y1%4)*8192 + (y1>>2)*line + x/8;
2417 else
2418 dst = fb + y1*line + x/8;
2419 for( x1 = 0; x1 < LOGO_LINE; ++x1 )
2420 fb_writeb(*src++ ^ inverse, dst++);
2421 }
2422 done = 1;
2423 }
2424 #endif
2425 #if defined(CONFIG_FBCON_VGA_PLANES)
2426 if (depth == 4 && p->type == FB_TYPE_VGA_PLANES) {
2427 outb_p(1,0x3ce); outb_p(0xf,0x3cf);
2428 outb_p(3,0x3ce); outb_p(0,0x3cf);
2429 outb_p(5,0x3ce); outb_p(0,0x3cf);
2430
2431 src = logo;
2432 for (y1 = 0; y1 < LOGO_H; y1++) {
2433 for (x1 = 0; x1 < LOGO_W / 2; x1++) {
2434 dst = fb + y1*line + x1/4 + x/8;
2435
2436 outb_p(0,0x3ce);
2437 outb_p(*src >> 4,0x3cf);
2438 outb_p(8,0x3ce);
2439 outb_p(1 << (7 - x1 % 4 * 2),0x3cf);
2440 fb_readb (dst);
2441 fb_writeb (0, dst);
2442
2443 outb_p(0,0x3ce);
2444 outb_p(*src & 0xf,0x3cf);
2445 outb_p(8,0x3ce);
2446 outb_p(1 << (7 - (1 + x1 % 4 * 2)),0x3cf);
2447 fb_readb (dst);
2448 fb_writeb (0, dst);
2449
2450 src++;
2451 }
2452 }
2453 done = 1;
2454 }
2455 #endif
2456 }
2457
2458 if (p->fb_info->fbops->fb_rasterimg)
2459 p->fb_info->fbops->fb_rasterimg(p->fb_info, 0);
2460
2461 /* Modes not yet supported: packed pixels with depth != 8 (does such a
2462 * thing exist in reality?) */
2463
2464 return done ? (LOGO_H + fontheight(p) - 1) / fontheight(p) : 0 ;
2465 }
2466
2467 #ifdef CONFIG_PM
2468 /* console.c doesn't do enough here */
2469 static int
pm_fbcon_request(struct pm_dev * dev,pm_request_t rqst,void * data)2470 pm_fbcon_request(struct pm_dev *dev, pm_request_t rqst, void *data)
2471 {
2472 unsigned long flags;
2473
2474 switch (rqst)
2475 {
2476 case PM_RESUME:
2477 acquire_console_sem();
2478 fbcon_sleeping = 0;
2479 if (use_timer_cursor) {
2480 cursor_timer.expires = jiffies+HZ/50;
2481 add_timer(&cursor_timer);
2482 }
2483 release_console_sem();
2484 break;
2485 case PM_SUSPEND:
2486 acquire_console_sem();
2487 save_flags(flags);
2488 cli();
2489 if (use_timer_cursor)
2490 del_timer(&cursor_timer);
2491 fbcon_sleeping = 1;
2492 restore_flags(flags);
2493 release_console_sem();
2494 break;
2495 }
2496 return 0;
2497 }
2498 #endif /* CONFIG_PM */
2499
2500 /*
2501 * The console `switch' structure for the frame buffer based console
2502 */
2503
2504 const struct consw fb_con = {
2505 con_startup: fbcon_startup,
2506 con_init: fbcon_init,
2507 con_deinit: fbcon_deinit,
2508 con_clear: fbcon_clear,
2509 con_putc: fbcon_putc,
2510 con_putcs: fbcon_putcs,
2511 con_cursor: fbcon_cursor,
2512 con_scroll: fbcon_scroll,
2513 con_bmove: fbcon_bmove,
2514 con_switch: fbcon_switch,
2515 con_blank: fbcon_blank,
2516 con_font_op: fbcon_font_op,
2517 con_set_palette: fbcon_set_palette,
2518 con_scrolldelta: fbcon_scrolldelta,
2519 con_set_origin: fbcon_set_origin,
2520 con_invert_region: fbcon_invert_region,
2521 con_screen_pos: fbcon_screen_pos,
2522 con_getxy: fbcon_getxy,
2523 };
2524
2525
2526 /*
2527 * Dummy Low Level Operations
2528 */
2529
fbcon_dummy_op(void)2530 static void fbcon_dummy_op(void) {}
2531
2532 #define DUMMY (void *)fbcon_dummy_op
2533
2534 struct display_switch fbcon_dummy = {
2535 setup: DUMMY,
2536 bmove: DUMMY,
2537 clear: DUMMY,
2538 putc: DUMMY,
2539 putcs: DUMMY,
2540 revc: DUMMY,
2541 };
2542
2543
2544 /*
2545 * Visible symbols for modules
2546 */
2547
2548 EXPORT_SYMBOL(fb_display);
2549 EXPORT_SYMBOL(fbcon_redraw_bmove);
2550 EXPORT_SYMBOL(fbcon_redraw_clear);
2551 EXPORT_SYMBOL(fbcon_dummy);
2552 EXPORT_SYMBOL(fb_con);
2553
2554 MODULE_LICENSE("GPL");
2555