2 * linux/drivers/video/fbcon.c -- Low level frame buffer based console driver
4 * Copyright (C) 1995 Geert Uytterhoeven
7 * This file is based on the original Amiga console driver (amicon.c):
9 * Copyright (C) 1993 Hamish Macdonald
11 * Copyright (C) 1994 David Carter [carter@compsci.bristol.ac.uk]
13 * with work by William Rucklidge (wjr@cs.cornell.edu)
15 * Jes Sorensen (jds@kom.auc.dk)
18 * and on the original Atari console driver (atacon.c):
20 * Copyright (C) 1993 Bjoern Brauel
23 * with work by Guenther Kelleter
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)
32 * Random hacking by Martin Mares <mj@ucw.cz>
34 * 2001 - Documented with DocBook
35 * - Brad Douglas <brad@neruo.com>
37 * The low level operations for the various display memory organizations are
38 * now in separate source files.
40 * Currently the following organizations are supported:
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
47 * o vga VGA characters/attributes
51 * - Implement 16 plane mode (iplan2p16)
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
61 #include <linux/module.h>
62 #include <linux/types.h>
64 #include <linux/kernel.h>
65 #include <linux/delay.h> /* MSch: for IRQ probe */
66 #include <linux/console.h>
67 #include <linux/string.h>
69 #include <linux/slab.h>
71 #include <linux/vt_kern.h>
72 #include <linux/selection.h>
73 #include <linux/font.h>
74 #include <linux/smp.h>
75 #include <linux/init.h>
76 #include <linux/interrupt.h>
77 #include <linux/crc32.h> /* For counting font checksums */
80 #include <asm/system.h>
85 # define DPRINTK(fmt, args...) printk(KERN_DEBUG "%s: " fmt, __func__ , ## args)
87 # define DPRINTK(fmt, args...)
91 FBCON_LOGO_CANSHOW = -1, /* the logo can be shown */
92 FBCON_LOGO_DRAW = -2, /* draw the logo to a console */
93 FBCON_LOGO_DONTSHOW = -3 /* do not show the logo */
96 static struct display fb_display[MAX_NR_CONSOLES];
98 static signed char con2fb_map[MAX_NR_CONSOLES];
99 static signed char con2fb_map_boot[MAX_NR_CONSOLES];
101 static int logo_lines;
102 /* logo_shown is an index to vc_cons when >= 0; otherwise follows FBCON_LOGO
104 static int logo_shown = FBCON_LOGO_CANSHOW;
105 /* Software scrollback */
106 static int fbcon_softback_size = 32768;
107 static unsigned long softback_buf, softback_curr;
108 static unsigned long softback_in;
109 static unsigned long softback_top, softback_end;
110 static int softback_lines;
111 /* console mappings */
112 static int first_fb_vc;
113 static int last_fb_vc = MAX_NR_CONSOLES - 1;
114 static int fbcon_is_default = 1;
115 static int fbcon_has_exited;
116 static int primary_device = -1;
118 #ifdef CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY
119 static int map_override;
121 static inline void fbcon_map_override(void)
126 static inline void fbcon_map_override(void)
129 #endif /* CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY */
132 static char fontname[40];
134 /* current fb_info */
135 static int info_idx = -1;
137 /* console rotation */
138 static int initial_rotation;
139 static int fbcon_has_sysfs;
141 static const struct consw fb_con;
143 #define CM_SOFTBACK (8)
145 #define advance_row(p, delta) (unsigned short *)((unsigned long)(p) + (delta) * vc->vc_size_row)
147 static int fbcon_set_origin(struct vc_data *);
149 #define CURSOR_DRAW_DELAY (1)
151 static int vbl_cursor_cnt;
152 static int fbcon_cursor_noblink;
154 #define divides(a, b) ((!(a) || (b)%(a)) ? 0 : 1)
157 * Interface used by the world
160 static const char *fbcon_startup(void);
161 static void fbcon_init(struct vc_data *vc, int init);
162 static void fbcon_deinit(struct vc_data *vc);
163 static void fbcon_clear(struct vc_data *vc, int sy, int sx, int height,
165 static void fbcon_putc(struct vc_data *vc, int c, int ypos, int xpos);
166 static void fbcon_putcs(struct vc_data *vc, const unsigned short *s,
167 int count, int ypos, int xpos);
168 static void fbcon_clear_margins(struct vc_data *vc, int bottom_only);
169 static void fbcon_cursor(struct vc_data *vc, int mode);
170 static int fbcon_scroll(struct vc_data *vc, int t, int b, int dir,
172 static void fbcon_bmove(struct vc_data *vc, int sy, int sx, int dy, int dx,
173 int height, int width);
174 static int fbcon_switch(struct vc_data *vc);
175 static int fbcon_blank(struct vc_data *vc, int blank, int mode_switch);
176 static int fbcon_set_palette(struct vc_data *vc, unsigned char *table);
177 static int fbcon_scrolldelta(struct vc_data *vc, int lines);
182 static __inline__ void ywrap_up(struct vc_data *vc, int count);
183 static __inline__ void ywrap_down(struct vc_data *vc, int count);
184 static __inline__ void ypan_up(struct vc_data *vc, int count);
185 static __inline__ void ypan_down(struct vc_data *vc, int count);
186 static void fbcon_bmove_rec(struct vc_data *vc, struct display *p, int sy, int sx,
187 int dy, int dx, int height, int width, u_int y_break);
188 static void fbcon_set_disp(struct fb_info *info, struct fb_var_screeninfo *var,
190 static void fbcon_redraw_move(struct vc_data *vc, struct display *p,
191 int line, int count, int dy);
192 static void fbcon_modechanged(struct fb_info *info);
193 static void fbcon_set_all_vcs(struct fb_info *info);
194 static void fbcon_start(void);
195 static void fbcon_exit(void);
196 static struct device *fbcon_device;
198 #ifdef CONFIG_FRAMEBUFFER_CONSOLE_ROTATION
199 static inline void fbcon_set_rotation(struct fb_info *info)
201 struct fbcon_ops *ops = info->fbcon_par;
203 if (!(info->flags & FBINFO_MISC_TILEBLITTING) &&
204 ops->p->con_rotate < 4)
205 ops->rotate = ops->p->con_rotate;
210 static void fbcon_rotate(struct fb_info *info, u32 rotate)
212 struct fbcon_ops *ops= info->fbcon_par;
213 struct fb_info *fb_info;
215 if (!ops || ops->currcon == -1)
218 fb_info = registered_fb[con2fb_map[ops->currcon]];
220 if (info == fb_info) {
221 struct display *p = &fb_display[ops->currcon];
224 p->con_rotate = rotate;
228 fbcon_modechanged(info);
232 static void fbcon_rotate_all(struct fb_info *info, u32 rotate)
234 struct fbcon_ops *ops = info->fbcon_par;
239 if (!ops || ops->currcon < 0 || rotate > 3)
242 for (i = first_fb_vc; i <= last_fb_vc; i++) {
244 if (!vc || vc->vc_mode != KD_TEXT ||
245 registered_fb[con2fb_map[i]] != info)
248 p = &fb_display[vc->vc_num];
249 p->con_rotate = rotate;
252 fbcon_set_all_vcs(info);
255 static inline void fbcon_set_rotation(struct fb_info *info)
257 struct fbcon_ops *ops = info->fbcon_par;
259 ops->rotate = FB_ROTATE_UR;
262 static void fbcon_rotate(struct fb_info *info, u32 rotate)
267 static void fbcon_rotate_all(struct fb_info *info, u32 rotate)
271 #endif /* CONFIG_FRAMEBUFFER_CONSOLE_ROTATION */
273 static int fbcon_get_rotate(struct fb_info *info)
275 struct fbcon_ops *ops = info->fbcon_par;
277 return (ops) ? ops->rotate : 0;
280 static inline int fbcon_is_inactive(struct vc_data *vc, struct fb_info *info)
282 struct fbcon_ops *ops = info->fbcon_par;
284 return (info->state != FBINFO_STATE_RUNNING ||
285 vc->vc_mode != KD_TEXT || ops->graphics);
288 static inline int get_color(struct vc_data *vc, struct fb_info *info,
291 int depth = fb_get_color_depth(&info->var, &info->fix);
294 if (console_blanked) {
295 unsigned short charmask = vc->vc_hi_font_mask ? 0x1ff : 0xff;
297 c = vc->vc_video_erase_char & charmask;
301 color = (is_fg) ? attr_fgcol((vc->vc_hi_font_mask) ? 9 : 8, c)
302 : attr_bgcol((vc->vc_hi_font_mask) ? 13 : 12, c);
307 int col = mono_col(info);
309 int fg = (info->fix.visual != FB_VISUAL_MONO01) ? col : 0;
310 int bg = (info->fix.visual != FB_VISUAL_MONO01) ? 0 : col;
315 color = (is_fg) ? fg : bg;
320 * Scale down 16-colors to 4 colors. Default 4-color palette
321 * is grayscale. However, simply dividing the values by 4
322 * will not work, as colors 1, 2 and 3 will be scaled-down
323 * to zero rendering them invisible. So empirically convert
324 * colors to a sane 4-level grayscale.
328 color = 0; /* black */
331 color = 2; /* white */
334 color = 1; /* gray */
337 color = 3; /* intense white */
343 * Last 8 entries of default 16-color palette is a more intense
344 * version of the first 8 (i.e., same chrominance, different
355 static void fbcon_update_softback(struct vc_data *vc)
357 int l = fbcon_softback_size / vc->vc_size_row;
360 softback_end = softback_buf + l * vc->vc_size_row;
362 /* Smaller scrollback makes no sense, and 0 would screw
363 the operation totally */
367 static void fb_flashcursor(struct work_struct *work)
369 struct fb_info *info = container_of(work, struct fb_info, queue);
370 struct fbcon_ops *ops = info->fbcon_par;
372 struct vc_data *vc = NULL;
376 acquire_console_sem();
377 if (ops && ops->currcon != -1)
378 vc = vc_cons[ops->currcon].d;
380 if (!vc || !CON_IS_VISIBLE(vc) ||
381 registered_fb[con2fb_map[vc->vc_num]] != info ||
383 release_console_sem();
387 p = &fb_display[vc->vc_num];
388 c = scr_readw((u16 *) vc->vc_pos);
389 mode = (!ops->cursor_flash || ops->cursor_state.enable) ?
391 ops->cursor(vc, info, mode, softback_lines, get_color(vc, info, c, 1),
392 get_color(vc, info, c, 0));
393 release_console_sem();
396 static void cursor_timer_handler(unsigned long dev_addr)
398 struct fb_info *info = (struct fb_info *) dev_addr;
399 struct fbcon_ops *ops = info->fbcon_par;
401 schedule_work(&info->queue);
402 mod_timer(&ops->cursor_timer, jiffies + HZ/5);
405 static void fbcon_add_cursor_timer(struct fb_info *info)
407 struct fbcon_ops *ops = info->fbcon_par;
409 if ((!info->queue.func || info->queue.func == fb_flashcursor) &&
410 !(ops->flags & FBCON_FLAGS_CURSOR_TIMER) &&
411 !fbcon_cursor_noblink) {
412 if (!info->queue.func)
413 INIT_WORK(&info->queue, fb_flashcursor);
415 init_timer(&ops->cursor_timer);
416 ops->cursor_timer.function = cursor_timer_handler;
417 ops->cursor_timer.expires = jiffies + HZ / 5;
418 ops->cursor_timer.data = (unsigned long ) info;
419 add_timer(&ops->cursor_timer);
420 ops->flags |= FBCON_FLAGS_CURSOR_TIMER;
424 static void fbcon_del_cursor_timer(struct fb_info *info)
426 struct fbcon_ops *ops = info->fbcon_par;
428 if (info->queue.func == fb_flashcursor &&
429 ops->flags & FBCON_FLAGS_CURSOR_TIMER) {
430 del_timer_sync(&ops->cursor_timer);
431 ops->flags &= ~FBCON_FLAGS_CURSOR_TIMER;
436 static int __init fb_console_setup(char *this_opt)
441 if (!this_opt || !*this_opt)
444 while ((options = strsep(&this_opt, ",")) != NULL) {
445 if (!strncmp(options, "font:", 5))
446 strcpy(fontname, options + 5);
448 if (!strncmp(options, "scrollback:", 11)) {
451 fbcon_softback_size = simple_strtoul(options, &options, 0);
452 if (*options == 'k' || *options == 'K') {
453 fbcon_softback_size *= 1024;
463 if (!strncmp(options, "map:", 4)) {
466 for (i = 0, j = 0; i < MAX_NR_CONSOLES; i++) {
470 (options[j++]-'0') % FB_MAX;
473 fbcon_map_override();
479 if (!strncmp(options, "vc:", 3)) {
482 first_fb_vc = simple_strtoul(options, &options, 10) - 1;
485 if (*options++ == '-')
486 last_fb_vc = simple_strtoul(options, &options, 10) - 1;
487 fbcon_is_default = 0;
490 if (!strncmp(options, "rotate:", 7)) {
493 initial_rotation = simple_strtoul(options, &options, 0);
494 if (initial_rotation > 3)
495 initial_rotation = 0;
501 __setup("fbcon=", fb_console_setup);
504 static int search_fb_in_map(int idx)
508 for (i = first_fb_vc; i <= last_fb_vc; i++) {
509 if (con2fb_map[i] == idx)
515 static int search_for_mapped_con(void)
519 for (i = first_fb_vc; i <= last_fb_vc; i++) {
520 if (con2fb_map[i] != -1)
526 static int fbcon_takeover(int show_logo)
530 if (!num_registered_fb)
534 logo_shown = FBCON_LOGO_DONTSHOW;
536 for (i = first_fb_vc; i <= last_fb_vc; i++)
537 con2fb_map[i] = info_idx;
539 err = take_over_console(&fb_con, first_fb_vc, last_fb_vc,
543 for (i = first_fb_vc; i <= last_fb_vc; i++) {
553 static void fbcon_prepare_logo(struct vc_data *vc, struct fb_info *info,
554 int cols, int rows, int new_cols, int new_rows)
556 logo_shown = FBCON_LOGO_DONTSHOW;
559 static void fbcon_prepare_logo(struct vc_data *vc, struct fb_info *info,
560 int cols, int rows, int new_cols, int new_rows)
562 /* Need to make room for the logo */
563 struct fbcon_ops *ops = info->fbcon_par;
564 int cnt, erase = vc->vc_video_erase_char, step;
565 unsigned short *save = NULL, *r, *q;
568 if (info->flags & FBINFO_MODULE) {
569 logo_shown = FBCON_LOGO_DONTSHOW;
574 * remove underline attribute from erase character
575 * if black and white framebuffer.
577 if (fb_get_color_depth(&info->var, &info->fix) == 1)
579 logo_height = fb_prepare_logo(info, ops->rotate);
580 logo_lines = DIV_ROUND_UP(logo_height, vc->vc_font.height);
581 q = (unsigned short *) (vc->vc_origin +
582 vc->vc_size_row * rows);
583 step = logo_lines * cols;
584 for (r = q - logo_lines * cols; r < q; r++)
585 if (scr_readw(r) != vc->vc_video_erase_char)
587 if (r != q && new_rows >= rows + logo_lines) {
588 save = kmalloc(logo_lines * new_cols * 2, GFP_KERNEL);
590 int i = cols < new_cols ? cols : new_cols;
591 scr_memsetw(save, erase, logo_lines * new_cols * 2);
593 for (cnt = 0; cnt < logo_lines; cnt++, r += i)
594 scr_memcpyw(save + cnt * new_cols, r, 2 * i);
599 /* We can scroll screen down */
601 for (cnt = rows - logo_lines; cnt > 0; cnt--) {
602 scr_memcpyw(r + step, r, vc->vc_size_row);
607 if (vc->vc_y + logo_lines >= rows)
608 lines = rows - vc->vc_y - 1;
612 vc->vc_pos += lines * vc->vc_size_row;
615 scr_memsetw((unsigned short *) vc->vc_origin,
617 vc->vc_size_row * logo_lines);
619 if (CON_IS_VISIBLE(vc) && vc->vc_mode == KD_TEXT) {
620 fbcon_clear_margins(vc, 0);
625 q = (unsigned short *) (vc->vc_origin +
628 scr_memcpyw(q, save, logo_lines * new_cols * 2);
629 vc->vc_y += logo_lines;
630 vc->vc_pos += logo_lines * vc->vc_size_row;
634 if (logo_lines > vc->vc_bottom) {
635 logo_shown = FBCON_LOGO_CANSHOW;
637 "fbcon_init: disable boot-logo (boot-logo bigger than screen).\n");
638 } else if (logo_shown != FBCON_LOGO_DONTSHOW) {
639 logo_shown = FBCON_LOGO_DRAW;
640 vc->vc_top = logo_lines;
645 #ifdef CONFIG_FB_TILEBLITTING
646 static void set_blitting_type(struct vc_data *vc, struct fb_info *info)
648 struct fbcon_ops *ops = info->fbcon_par;
650 ops->p = &fb_display[vc->vc_num];
652 if ((info->flags & FBINFO_MISC_TILEBLITTING))
653 fbcon_set_tileops(vc, info);
655 fbcon_set_rotation(info);
656 fbcon_set_bitops(ops);
660 static int fbcon_invalid_charcount(struct fb_info *info, unsigned charcount)
664 if (info->flags & FBINFO_MISC_TILEBLITTING &&
665 info->tileops->fb_get_tilemax(info) < charcount)
671 static void set_blitting_type(struct vc_data *vc, struct fb_info *info)
673 struct fbcon_ops *ops = info->fbcon_par;
675 info->flags &= ~FBINFO_MISC_TILEBLITTING;
676 ops->p = &fb_display[vc->vc_num];
677 fbcon_set_rotation(info);
678 fbcon_set_bitops(ops);
681 static int fbcon_invalid_charcount(struct fb_info *info, unsigned charcount)
686 #endif /* CONFIG_MISC_TILEBLITTING */
689 static int con2fb_acquire_newinfo(struct vc_data *vc, struct fb_info *info,
690 int unit, int oldidx)
692 struct fbcon_ops *ops = NULL;
695 if (!try_module_get(info->fbops->owner))
698 if (!err && info->fbops->fb_open &&
699 info->fbops->fb_open(info, 0))
703 ops = kzalloc(sizeof(struct fbcon_ops), GFP_KERNEL);
709 info->fbcon_par = ops;
712 set_blitting_type(vc, info);
716 con2fb_map[unit] = oldidx;
717 module_put(info->fbops->owner);
723 static int con2fb_release_oldinfo(struct vc_data *vc, struct fb_info *oldinfo,
724 struct fb_info *newinfo, int unit,
725 int oldidx, int found)
727 struct fbcon_ops *ops = oldinfo->fbcon_par;
730 if (oldinfo->fbops->fb_release &&
731 oldinfo->fbops->fb_release(oldinfo, 0)) {
732 con2fb_map[unit] = oldidx;
733 if (!found && newinfo->fbops->fb_release)
734 newinfo->fbops->fb_release(newinfo, 0);
736 module_put(newinfo->fbops->owner);
741 fbcon_del_cursor_timer(oldinfo);
742 kfree(ops->cursor_state.mask);
743 kfree(ops->cursor_data);
744 kfree(ops->fontbuffer);
745 kfree(oldinfo->fbcon_par);
746 oldinfo->fbcon_par = NULL;
747 module_put(oldinfo->fbops->owner);
749 If oldinfo and newinfo are driving the same hardware,
750 the fb_release() method of oldinfo may attempt to
751 restore the hardware state. This will leave the
752 newinfo in an undefined state. Thus, a call to
753 fb_set_par() may be needed for the newinfo.
755 if (newinfo->fbops->fb_set_par)
756 newinfo->fbops->fb_set_par(newinfo);
762 static void con2fb_init_display(struct vc_data *vc, struct fb_info *info,
763 int unit, int show_logo)
765 struct fbcon_ops *ops = info->fbcon_par;
767 ops->currcon = fg_console;
769 if (info->fbops->fb_set_par && !(ops->flags & FBCON_FLAGS_INIT))
770 info->fbops->fb_set_par(info);
772 ops->flags |= FBCON_FLAGS_INIT;
774 fbcon_set_disp(info, &info->var, unit);
777 struct vc_data *fg_vc = vc_cons[fg_console].d;
778 struct fb_info *fg_info =
779 registered_fb[con2fb_map[fg_console]];
781 fbcon_prepare_logo(fg_vc, fg_info, fg_vc->vc_cols,
782 fg_vc->vc_rows, fg_vc->vc_cols,
786 update_screen(vc_cons[fg_console].d);
790 * set_con2fb_map - map console to frame buffer device
791 * @unit: virtual console number to map
792 * @newidx: frame buffer index to map virtual console to
793 * @user: user request
795 * Maps a virtual console @unit to a frame buffer device
798 static int set_con2fb_map(int unit, int newidx, int user)
800 struct vc_data *vc = vc_cons[unit].d;
801 int oldidx = con2fb_map[unit];
802 struct fb_info *info = registered_fb[newidx];
803 struct fb_info *oldinfo = NULL;
806 if (oldidx == newidx)
809 if (!info || fbcon_has_exited)
812 if (!err && !search_for_mapped_con()) {
814 return fbcon_takeover(0);
818 oldinfo = registered_fb[oldidx];
820 found = search_fb_in_map(newidx);
822 acquire_console_sem();
823 con2fb_map[unit] = newidx;
825 err = con2fb_acquire_newinfo(vc, info, unit, oldidx);
829 * If old fb is not mapped to any of the consoles,
830 * fbcon should release it.
832 if (!err && oldinfo && !search_fb_in_map(oldidx))
833 err = con2fb_release_oldinfo(vc, oldinfo, info, unit, oldidx,
837 int show_logo = (fg_console == 0 && !user &&
838 logo_shown != FBCON_LOGO_DONTSHOW);
841 fbcon_add_cursor_timer(info);
842 con2fb_map_boot[unit] = newidx;
843 con2fb_init_display(vc, info, unit, show_logo);
846 if (!search_fb_in_map(info_idx))
849 release_console_sem();
854 * Low Level Operations
856 /* NOTE: fbcon cannot be __init: it may be called from take_over_console later */
857 static int var_to_display(struct display *disp,
858 struct fb_var_screeninfo *var,
859 struct fb_info *info)
861 disp->xres_virtual = var->xres_virtual;
862 disp->yres_virtual = var->yres_virtual;
863 disp->bits_per_pixel = var->bits_per_pixel;
864 disp->grayscale = var->grayscale;
865 disp->nonstd = var->nonstd;
866 disp->accel_flags = var->accel_flags;
867 disp->height = var->height;
868 disp->width = var->width;
869 disp->red = var->red;
870 disp->green = var->green;
871 disp->blue = var->blue;
872 disp->transp = var->transp;
873 disp->rotate = var->rotate;
874 disp->mode = fb_match_mode(var, &info->modelist);
875 if (disp->mode == NULL)
876 /* This should not happen */
881 static void display_to_var(struct fb_var_screeninfo *var,
882 struct display *disp)
884 fb_videomode_to_var(var, disp->mode);
885 var->xres_virtual = disp->xres_virtual;
886 var->yres_virtual = disp->yres_virtual;
887 var->bits_per_pixel = disp->bits_per_pixel;
888 var->grayscale = disp->grayscale;
889 var->nonstd = disp->nonstd;
890 var->accel_flags = disp->accel_flags;
891 var->height = disp->height;
892 var->width = disp->width;
893 var->red = disp->red;
894 var->green = disp->green;
895 var->blue = disp->blue;
896 var->transp = disp->transp;
897 var->rotate = disp->rotate;
900 static const char *fbcon_startup(void)
902 const char *display_desc = "frame buffer device";
903 struct display *p = &fb_display[fg_console];
904 struct vc_data *vc = vc_cons[fg_console].d;
905 const struct font_desc *font = NULL;
906 struct module *owner;
907 struct fb_info *info = NULL;
908 struct fbcon_ops *ops;
912 * If num_registered_fb is zero, this is a call for the dummy part.
913 * The frame buffer devices weren't initialized yet.
915 if (!num_registered_fb || info_idx == -1)
918 * Instead of blindly using registered_fb[0], we use info_idx, set by
921 info = registered_fb[info_idx];
925 owner = info->fbops->owner;
926 if (!try_module_get(owner))
928 if (info->fbops->fb_open && info->fbops->fb_open(info, 0)) {
933 ops = kzalloc(sizeof(struct fbcon_ops), GFP_KERNEL);
941 ops->cur_rotate = -1;
942 info->fbcon_par = ops;
943 p->con_rotate = initial_rotation;
944 set_blitting_type(vc, info);
946 if (info->fix.type != FB_TYPE_TEXT) {
947 if (fbcon_softback_size) {
951 kmalloc(fbcon_softback_size,
954 fbcon_softback_size = 0;
960 kfree((void *) softback_buf);
966 softback_in = softback_top = softback_curr =
971 /* Setup default font */
973 if (!fontname[0] || !(font = find_font(fontname)))
974 font = get_default_font(info->var.xres,
977 info->pixmap.blit_y);
978 vc->vc_font.width = font->width;
979 vc->vc_font.height = font->height;
980 vc->vc_font.data = (void *)(p->fontdata = font->data);
981 vc->vc_font.charcount = 256; /* FIXME Need to support more fonts */
984 cols = FBCON_SWAP(ops->rotate, info->var.xres, info->var.yres);
985 rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
986 cols /= vc->vc_font.width;
987 rows /= vc->vc_font.height;
988 vc_resize(vc, cols, rows);
990 DPRINTK("mode: %s\n", info->fix.id);
991 DPRINTK("visual: %d\n", info->fix.visual);
992 DPRINTK("res: %dx%d-%d\n", info->var.xres,
994 info->var.bits_per_pixel);
996 fbcon_add_cursor_timer(info);
997 fbcon_has_exited = 0;
1001 static void fbcon_init(struct vc_data *vc, int init)
1003 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
1004 struct fbcon_ops *ops;
1005 struct vc_data **default_mode = vc->vc_display_fg;
1006 struct vc_data *svc = *default_mode;
1007 struct display *t, *p = &fb_display[vc->vc_num];
1008 int logo = 1, new_rows, new_cols, rows, cols, charcnt = 256;
1011 if (info_idx == -1 || info == NULL)
1016 if (vc != svc || logo_shown == FBCON_LOGO_DONTSHOW ||
1017 (info->fix.type == FB_TYPE_TEXT))
1020 if (var_to_display(p, &info->var, info))
1023 if (!info->fbcon_par)
1024 con2fb_acquire_newinfo(vc, info, vc->vc_num, -1);
1026 /* If we are not the first console on this
1027 fb, copy the font from that console */
1028 t = &fb_display[fg_console];
1031 struct vc_data *fvc = vc_cons[fg_console].d;
1033 vc->vc_font.data = (void *)(p->fontdata =
1035 vc->vc_font.width = fvc->vc_font.width;
1036 vc->vc_font.height = fvc->vc_font.height;
1037 p->userfont = t->userfont;
1040 REFCOUNT(p->fontdata)++;
1042 const struct font_desc *font = NULL;
1044 if (!fontname[0] || !(font = find_font(fontname)))
1045 font = get_default_font(info->var.xres,
1047 info->pixmap.blit_x,
1048 info->pixmap.blit_y);
1049 vc->vc_font.width = font->width;
1050 vc->vc_font.height = font->height;
1051 vc->vc_font.data = (void *)(p->fontdata = font->data);
1052 vc->vc_font.charcount = 256; /* FIXME Need to
1053 support more fonts */
1058 charcnt = FNTCHARCNT(p->fontdata);
1060 vc->vc_can_do_color = (fb_get_color_depth(&info->var, &info->fix)!=1);
1061 vc->vc_complement_mask = vc->vc_can_do_color ? 0x7700 : 0x0800;
1062 if (charcnt == 256) {
1063 vc->vc_hi_font_mask = 0;
1065 vc->vc_hi_font_mask = 0x100;
1066 if (vc->vc_can_do_color)
1067 vc->vc_complement_mask <<= 1;
1070 if (!*svc->vc_uni_pagedir_loc)
1071 con_set_default_unimap(svc);
1072 if (!*vc->vc_uni_pagedir_loc)
1073 con_copy_unimap(vc, svc);
1075 ops = info->fbcon_par;
1076 p->con_rotate = initial_rotation;
1077 set_blitting_type(vc, info);
1081 new_cols = FBCON_SWAP(ops->rotate, info->var.xres, info->var.yres);
1082 new_rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
1083 new_cols /= vc->vc_font.width;
1084 new_rows /= vc->vc_font.height;
1085 vc_resize(vc, new_cols, new_rows);
1088 * We must always set the mode. The mode of the previous console
1089 * driver could be in the same resolution but we are using different
1090 * hardware so we have to initialize the hardware.
1092 * We need to do it in fbcon_init() to prevent screen corruption.
1094 if (CON_IS_VISIBLE(vc) && vc->vc_mode == KD_TEXT) {
1095 if (info->fbops->fb_set_par &&
1096 !(ops->flags & FBCON_FLAGS_INIT))
1097 info->fbops->fb_set_par(info);
1098 ops->flags |= FBCON_FLAGS_INIT;
1103 if ((cap & FBINFO_HWACCEL_COPYAREA) &&
1104 !(cap & FBINFO_HWACCEL_DISABLED))
1105 p->scrollmode = SCROLL_MOVE;
1106 else /* default to something safe */
1107 p->scrollmode = SCROLL_REDRAW;
1110 * ++guenther: console.c:vc_allocate() relies on initializing
1111 * vc_{cols,rows}, but we must not set those if we are only
1112 * resizing the console.
1115 vc->vc_cols = new_cols;
1116 vc->vc_rows = new_rows;
1120 fbcon_prepare_logo(vc, info, cols, rows, new_cols, new_rows);
1122 if (vc == svc && softback_buf)
1123 fbcon_update_softback(vc);
1125 if (ops->rotate_font && ops->rotate_font(info, vc)) {
1126 ops->rotate = FB_ROTATE_UR;
1127 set_blitting_type(vc, info);
1130 ops->p = &fb_display[fg_console];
1133 static void fbcon_free_font(struct display *p)
1135 if (p->userfont && p->fontdata && (--REFCOUNT(p->fontdata) == 0))
1136 kfree(p->fontdata - FONT_EXTRA_WORDS * sizeof(int));
1141 static void fbcon_deinit(struct vc_data *vc)
1143 struct display *p = &fb_display[vc->vc_num];
1144 struct fb_info *info;
1145 struct fbcon_ops *ops;
1149 idx = con2fb_map[vc->vc_num];
1154 info = registered_fb[idx];
1159 ops = info->fbcon_par;
1164 if (CON_IS_VISIBLE(vc))
1165 fbcon_del_cursor_timer(info);
1167 ops->flags &= ~FBCON_FLAGS_INIT;
1170 if (!con_is_bound(&fb_con))
1176 /* ====================================================================== */
1178 /* fbcon_XXX routines - interface used by the world
1180 * This system is now divided into two levels because of complications
1181 * caused by hardware scrolling. Top level functions:
1183 * fbcon_bmove(), fbcon_clear(), fbcon_putc(), fbcon_clear_margins()
1185 * handles y values in range [0, scr_height-1] that correspond to real
1186 * screen positions. y_wrap shift means that first line of bitmap may be
1187 * anywhere on this display. These functions convert lineoffsets to
1188 * bitmap offsets and deal with the wrap-around case by splitting blits.
1190 * fbcon_bmove_physical_8() -- These functions fast implementations
1191 * fbcon_clear_physical_8() -- of original fbcon_XXX fns.
1192 * fbcon_putc_physical_8() -- (font width != 8) may be added later
1196 * At the moment fbcon_putc() cannot blit across vertical wrap boundary
1197 * Implies should only really hardware scroll in rows. Only reason for
1198 * restriction is simplicity & efficiency at the moment.
1201 static void fbcon_clear(struct vc_data *vc, int sy, int sx, int height,
1204 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
1205 struct fbcon_ops *ops = info->fbcon_par;
1207 struct display *p = &fb_display[vc->vc_num];
1210 if (fbcon_is_inactive(vc, info))
1213 if (!height || !width)
1216 if (sy < vc->vc_top && vc->vc_top == logo_lines)
1219 /* Split blits that cross physical y_wrap boundary */
1221 y_break = p->vrows - p->yscroll;
1222 if (sy < y_break && sy + height - 1 >= y_break) {
1223 u_int b = y_break - sy;
1224 ops->clear(vc, info, real_y(p, sy), sx, b, width);
1225 ops->clear(vc, info, real_y(p, sy + b), sx, height - b,
1228 ops->clear(vc, info, real_y(p, sy), sx, height, width);
1231 static void fbcon_putcs(struct vc_data *vc, const unsigned short *s,
1232 int count, int ypos, int xpos)
1234 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
1235 struct display *p = &fb_display[vc->vc_num];
1236 struct fbcon_ops *ops = info->fbcon_par;
1238 if (!fbcon_is_inactive(vc, info))
1239 ops->putcs(vc, info, s, count, real_y(p, ypos), xpos,
1240 get_color(vc, info, scr_readw(s), 1),
1241 get_color(vc, info, scr_readw(s), 0));
1244 static void fbcon_putc(struct vc_data *vc, int c, int ypos, int xpos)
1248 scr_writew(c, &chr);
1249 fbcon_putcs(vc, &chr, 1, ypos, xpos);
1252 static void fbcon_clear_margins(struct vc_data *vc, int bottom_only)
1254 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
1255 struct fbcon_ops *ops = info->fbcon_par;
1257 if (!fbcon_is_inactive(vc, info))
1258 ops->clear_margins(vc, info, bottom_only);
1261 static void fbcon_cursor(struct vc_data *vc, int mode)
1263 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
1264 struct fbcon_ops *ops = info->fbcon_par;
1266 int c = scr_readw((u16 *) vc->vc_pos);
1268 if (fbcon_is_inactive(vc, info) || vc->vc_deccm != 1)
1271 if (vc->vc_cursor_type & 0x10)
1272 fbcon_del_cursor_timer(info);
1274 fbcon_add_cursor_timer(info);
1276 ops->cursor_flash = (mode == CM_ERASE) ? 0 : 1;
1277 if (mode & CM_SOFTBACK) {
1278 mode &= ~CM_SOFTBACK;
1282 fbcon_set_origin(vc);
1286 ops->cursor(vc, info, mode, y, get_color(vc, info, c, 1),
1287 get_color(vc, info, c, 0));
1288 vbl_cursor_cnt = CURSOR_DRAW_DELAY;
1291 static int scrollback_phys_max = 0;
1292 static int scrollback_max = 0;
1293 static int scrollback_current = 0;
1295 static void fbcon_set_disp(struct fb_info *info, struct fb_var_screeninfo *var,
1298 struct display *p, *t;
1299 struct vc_data **default_mode, *vc;
1300 struct vc_data *svc;
1301 struct fbcon_ops *ops = info->fbcon_par;
1302 int rows, cols, charcnt = 256;
1304 p = &fb_display[unit];
1306 if (var_to_display(p, var, info))
1309 vc = vc_cons[unit].d;
1314 default_mode = vc->vc_display_fg;
1315 svc = *default_mode;
1316 t = &fb_display[svc->vc_num];
1318 if (!vc->vc_font.data) {
1319 vc->vc_font.data = (void *)(p->fontdata = t->fontdata);
1320 vc->vc_font.width = (*default_mode)->vc_font.width;
1321 vc->vc_font.height = (*default_mode)->vc_font.height;
1322 p->userfont = t->userfont;
1324 REFCOUNT(p->fontdata)++;
1327 charcnt = FNTCHARCNT(p->fontdata);
1329 var->activate = FB_ACTIVATE_NOW;
1330 info->var.activate = var->activate;
1331 var->yoffset = info->var.yoffset;
1332 var->xoffset = info->var.xoffset;
1333 fb_set_var(info, var);
1334 ops->var = info->var;
1335 vc->vc_can_do_color = (fb_get_color_depth(&info->var, &info->fix)!=1);
1336 vc->vc_complement_mask = vc->vc_can_do_color ? 0x7700 : 0x0800;
1337 if (charcnt == 256) {
1338 vc->vc_hi_font_mask = 0;
1340 vc->vc_hi_font_mask = 0x100;
1341 if (vc->vc_can_do_color)
1342 vc->vc_complement_mask <<= 1;
1345 if (!*svc->vc_uni_pagedir_loc)
1346 con_set_default_unimap(svc);
1347 if (!*vc->vc_uni_pagedir_loc)
1348 con_copy_unimap(vc, svc);
1350 cols = FBCON_SWAP(ops->rotate, info->var.xres, info->var.yres);
1351 rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
1352 cols /= vc->vc_font.width;
1353 rows /= vc->vc_font.height;
1354 vc_resize(vc, cols, rows);
1356 if (CON_IS_VISIBLE(vc)) {
1359 fbcon_update_softback(vc);
1363 static __inline__ void ywrap_up(struct vc_data *vc, int count)
1365 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
1366 struct fbcon_ops *ops = info->fbcon_par;
1367 struct display *p = &fb_display[vc->vc_num];
1369 p->yscroll += count;
1370 if (p->yscroll >= p->vrows) /* Deal with wrap */
1371 p->yscroll -= p->vrows;
1372 ops->var.xoffset = 0;
1373 ops->var.yoffset = p->yscroll * vc->vc_font.height;
1374 ops->var.vmode |= FB_VMODE_YWRAP;
1375 ops->update_start(info);
1376 scrollback_max += count;
1377 if (scrollback_max > scrollback_phys_max)
1378 scrollback_max = scrollback_phys_max;
1379 scrollback_current = 0;
1382 static __inline__ void ywrap_down(struct vc_data *vc, int count)
1384 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
1385 struct fbcon_ops *ops = info->fbcon_par;
1386 struct display *p = &fb_display[vc->vc_num];
1388 p->yscroll -= count;
1389 if (p->yscroll < 0) /* Deal with wrap */
1390 p->yscroll += p->vrows;
1391 ops->var.xoffset = 0;
1392 ops->var.yoffset = p->yscroll * vc->vc_font.height;
1393 ops->var.vmode |= FB_VMODE_YWRAP;
1394 ops->update_start(info);
1395 scrollback_max -= count;
1396 if (scrollback_max < 0)
1398 scrollback_current = 0;
1401 static __inline__ void ypan_up(struct vc_data *vc, int count)
1403 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
1404 struct display *p = &fb_display[vc->vc_num];
1405 struct fbcon_ops *ops = info->fbcon_par;
1407 p->yscroll += count;
1408 if (p->yscroll > p->vrows - vc->vc_rows) {
1409 ops->bmove(vc, info, p->vrows - vc->vc_rows,
1410 0, 0, 0, vc->vc_rows, vc->vc_cols);
1411 p->yscroll -= p->vrows - vc->vc_rows;
1414 ops->var.xoffset = 0;
1415 ops->var.yoffset = p->yscroll * vc->vc_font.height;
1416 ops->var.vmode &= ~FB_VMODE_YWRAP;
1417 ops->update_start(info);
1418 fbcon_clear_margins(vc, 1);
1419 scrollback_max += count;
1420 if (scrollback_max > scrollback_phys_max)
1421 scrollback_max = scrollback_phys_max;
1422 scrollback_current = 0;
1425 static __inline__ void ypan_up_redraw(struct vc_data *vc, int t, int count)
1427 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
1428 struct fbcon_ops *ops = info->fbcon_par;
1429 struct display *p = &fb_display[vc->vc_num];
1431 p->yscroll += count;
1433 if (p->yscroll > p->vrows - vc->vc_rows) {
1434 p->yscroll -= p->vrows - vc->vc_rows;
1435 fbcon_redraw_move(vc, p, t + count, vc->vc_rows - count, t);
1438 ops->var.xoffset = 0;
1439 ops->var.yoffset = p->yscroll * vc->vc_font.height;
1440 ops->var.vmode &= ~FB_VMODE_YWRAP;
1441 ops->update_start(info);
1442 fbcon_clear_margins(vc, 1);
1443 scrollback_max += count;
1444 if (scrollback_max > scrollback_phys_max)
1445 scrollback_max = scrollback_phys_max;
1446 scrollback_current = 0;
1449 static __inline__ void ypan_down(struct vc_data *vc, int count)
1451 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
1452 struct display *p = &fb_display[vc->vc_num];
1453 struct fbcon_ops *ops = info->fbcon_par;
1455 p->yscroll -= count;
1456 if (p->yscroll < 0) {
1457 ops->bmove(vc, info, 0, 0, p->vrows - vc->vc_rows,
1458 0, vc->vc_rows, vc->vc_cols);
1459 p->yscroll += p->vrows - vc->vc_rows;
1462 ops->var.xoffset = 0;
1463 ops->var.yoffset = p->yscroll * vc->vc_font.height;
1464 ops->var.vmode &= ~FB_VMODE_YWRAP;
1465 ops->update_start(info);
1466 fbcon_clear_margins(vc, 1);
1467 scrollback_max -= count;
1468 if (scrollback_max < 0)
1470 scrollback_current = 0;
1473 static __inline__ void ypan_down_redraw(struct vc_data *vc, int t, int count)
1475 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
1476 struct fbcon_ops *ops = info->fbcon_par;
1477 struct display *p = &fb_display[vc->vc_num];
1479 p->yscroll -= count;
1481 if (p->yscroll < 0) {
1482 p->yscroll += p->vrows - vc->vc_rows;
1483 fbcon_redraw_move(vc, p, t, vc->vc_rows - count, t + count);
1486 ops->var.xoffset = 0;
1487 ops->var.yoffset = p->yscroll * vc->vc_font.height;
1488 ops->var.vmode &= ~FB_VMODE_YWRAP;
1489 ops->update_start(info);
1490 fbcon_clear_margins(vc, 1);
1491 scrollback_max -= count;
1492 if (scrollback_max < 0)
1494 scrollback_current = 0;
1497 static void fbcon_redraw_softback(struct vc_data *vc, struct display *p,
1500 int count = vc->vc_rows;
1501 unsigned short *d, *s;
1505 d = (u16 *) softback_curr;
1506 if (d == (u16 *) softback_in)
1507 d = (u16 *) vc->vc_origin;
1508 n = softback_curr + delta * vc->vc_size_row;
1509 softback_lines -= delta;
1511 if (softback_curr < softback_top && n < softback_buf) {
1512 n += softback_end - softback_buf;
1513 if (n < softback_top) {
1515 (softback_top - n) / vc->vc_size_row;
1518 } else if (softback_curr >= softback_top
1519 && n < softback_top) {
1521 (softback_top - n) / vc->vc_size_row;
1525 if (softback_curr > softback_in && n >= softback_end) {
1526 n += softback_buf - softback_end;
1527 if (n > softback_in) {
1531 } else if (softback_curr <= softback_in && n > softback_in) {
1536 if (n == softback_curr)
1539 s = (u16 *) softback_curr;
1540 if (s == (u16 *) softback_in)
1541 s = (u16 *) vc->vc_origin;
1543 unsigned short *start;
1547 unsigned short attr = 1;
1550 le = advance_row(s, 1);
1553 if (attr != (c & 0xff00)) {
1556 fbcon_putcs(vc, start, s - start,
1562 if (c == scr_readw(d)) {
1564 fbcon_putcs(vc, start, s - start,
1577 fbcon_putcs(vc, start, s - start, line, x);
1579 if (d == (u16 *) softback_end)
1580 d = (u16 *) softback_buf;
1581 if (d == (u16 *) softback_in)
1582 d = (u16 *) vc->vc_origin;
1583 if (s == (u16 *) softback_end)
1584 s = (u16 *) softback_buf;
1585 if (s == (u16 *) softback_in)
1586 s = (u16 *) vc->vc_origin;
1590 static void fbcon_redraw_move(struct vc_data *vc, struct display *p,
1591 int line, int count, int dy)
1593 unsigned short *s = (unsigned short *)
1594 (vc->vc_origin + vc->vc_size_row * line);
1597 unsigned short *start = s;
1598 unsigned short *le = advance_row(s, 1);
1601 unsigned short attr = 1;
1605 if (attr != (c & 0xff00)) {
1608 fbcon_putcs(vc, start, s - start,
1614 console_conditional_schedule();
1618 fbcon_putcs(vc, start, s - start, dy, x);
1619 console_conditional_schedule();
1624 static void fbcon_redraw_blit(struct vc_data *vc, struct fb_info *info,
1625 struct display *p, int line, int count, int ycount)
1627 int offset = ycount * vc->vc_cols;
1628 unsigned short *d = (unsigned short *)
1629 (vc->vc_origin + vc->vc_size_row * line);
1630 unsigned short *s = d + offset;
1631 struct fbcon_ops *ops = info->fbcon_par;
1634 unsigned short *start = s;
1635 unsigned short *le = advance_row(s, 1);
1642 if (c == scr_readw(d)) {
1644 ops->bmove(vc, info, line + ycount, x,
1645 line, x, 1, s-start);
1655 console_conditional_schedule();
1660 ops->bmove(vc, info, line + ycount, x, line, x, 1,
1662 console_conditional_schedule();
1667 /* NOTE: We subtract two lines from these pointers */
1668 s -= vc->vc_size_row;
1669 d -= vc->vc_size_row;
1674 static void fbcon_redraw(struct vc_data *vc, struct display *p,
1675 int line, int count, int offset)
1677 unsigned short *d = (unsigned short *)
1678 (vc->vc_origin + vc->vc_size_row * line);
1679 unsigned short *s = d + offset;
1682 unsigned short *start = s;
1683 unsigned short *le = advance_row(s, 1);
1686 unsigned short attr = 1;
1690 if (attr != (c & 0xff00)) {
1693 fbcon_putcs(vc, start, s - start,
1699 if (c == scr_readw(d)) {
1701 fbcon_putcs(vc, start, s - start,
1711 console_conditional_schedule();
1716 fbcon_putcs(vc, start, s - start, line, x);
1717 console_conditional_schedule();
1722 /* NOTE: We subtract two lines from these pointers */
1723 s -= vc->vc_size_row;
1724 d -= vc->vc_size_row;
1729 static inline void fbcon_softback_note(struct vc_data *vc, int t,
1734 if (vc->vc_num != fg_console)
1736 p = (unsigned short *) (vc->vc_origin + t * vc->vc_size_row);
1739 scr_memcpyw((u16 *) softback_in, p, vc->vc_size_row);
1741 p = advance_row(p, 1);
1742 softback_in += vc->vc_size_row;
1743 if (softback_in == softback_end)
1744 softback_in = softback_buf;
1745 if (softback_in == softback_top) {
1746 softback_top += vc->vc_size_row;
1747 if (softback_top == softback_end)
1748 softback_top = softback_buf;
1751 softback_curr = softback_in;
1754 static int fbcon_scroll(struct vc_data *vc, int t, int b, int dir,
1757 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
1758 struct display *p = &fb_display[vc->vc_num];
1759 int scroll_partial = info->flags & FBINFO_PARTIAL_PAN_OK;
1761 if (fbcon_is_inactive(vc, info))
1764 fbcon_cursor(vc, CM_ERASE);
1767 * ++Geert: Only use ywrap/ypan if the console is in text mode
1768 * ++Andrew: Only use ypan on hardware text mode when scrolling the
1769 * whole screen (prevents flicker).
1774 if (count > vc->vc_rows) /* Maximum realistic size */
1775 count = vc->vc_rows;
1777 fbcon_softback_note(vc, t, count);
1778 if (logo_shown >= 0)
1780 switch (p->scrollmode) {
1782 fbcon_redraw_blit(vc, info, p, t, b - t - count,
1784 fbcon_clear(vc, b - count, 0, count, vc->vc_cols);
1785 scr_memsetw((unsigned short *) (vc->vc_origin +
1788 vc->vc_video_erase_char,
1789 vc->vc_size_row * count);
1793 case SCROLL_WRAP_MOVE:
1794 if (b - t - count > 3 * vc->vc_rows >> 2) {
1796 fbcon_bmove(vc, 0, 0, count, 0, t,
1798 ywrap_up(vc, count);
1799 if (vc->vc_rows - b > 0)
1800 fbcon_bmove(vc, b - count, 0, b, 0,
1803 } else if (info->flags & FBINFO_READS_FAST)
1804 fbcon_bmove(vc, t + count, 0, t, 0,
1805 b - t - count, vc->vc_cols);
1808 fbcon_clear(vc, b - count, 0, count, vc->vc_cols);
1811 case SCROLL_PAN_REDRAW:
1812 if ((p->yscroll + count <=
1813 2 * (p->vrows - vc->vc_rows))
1814 && ((!scroll_partial && (b - t == vc->vc_rows))
1817 3 * vc->vc_rows >> 2)))) {
1819 fbcon_redraw_move(vc, p, 0, t, count);
1820 ypan_up_redraw(vc, t, count);
1821 if (vc->vc_rows - b > 0)
1822 fbcon_redraw_move(vc, p, b,
1823 vc->vc_rows - b, b);
1825 fbcon_redraw_move(vc, p, t + count, b - t - count, t);
1826 fbcon_clear(vc, b - count, 0, count, vc->vc_cols);
1829 case SCROLL_PAN_MOVE:
1830 if ((p->yscroll + count <=
1831 2 * (p->vrows - vc->vc_rows))
1832 && ((!scroll_partial && (b - t == vc->vc_rows))
1835 3 * vc->vc_rows >> 2)))) {
1837 fbcon_bmove(vc, 0, 0, count, 0, t,
1840 if (vc->vc_rows - b > 0)
1841 fbcon_bmove(vc, b - count, 0, b, 0,
1844 } else if (info->flags & FBINFO_READS_FAST)
1845 fbcon_bmove(vc, t + count, 0, t, 0,
1846 b - t - count, vc->vc_cols);
1849 fbcon_clear(vc, b - count, 0, count, vc->vc_cols);
1854 fbcon_redraw(vc, p, t, b - t - count,
1855 count * vc->vc_cols);
1856 fbcon_clear(vc, b - count, 0, count, vc->vc_cols);
1857 scr_memsetw((unsigned short *) (vc->vc_origin +
1860 vc->vc_video_erase_char,
1861 vc->vc_size_row * count);
1867 if (count > vc->vc_rows) /* Maximum realistic size */
1868 count = vc->vc_rows;
1869 if (logo_shown >= 0)
1871 switch (p->scrollmode) {
1873 fbcon_redraw_blit(vc, info, p, b - 1, b - t - count,
1875 fbcon_clear(vc, t, 0, count, vc->vc_cols);
1876 scr_memsetw((unsigned short *) (vc->vc_origin +
1879 vc->vc_video_erase_char,
1880 vc->vc_size_row * count);
1884 case SCROLL_WRAP_MOVE:
1885 if (b - t - count > 3 * vc->vc_rows >> 2) {
1886 if (vc->vc_rows - b > 0)
1887 fbcon_bmove(vc, b, 0, b - count, 0,
1890 ywrap_down(vc, count);
1892 fbcon_bmove(vc, count, 0, 0, 0, t,
1894 } else if (info->flags & FBINFO_READS_FAST)
1895 fbcon_bmove(vc, t, 0, t + count, 0,
1896 b - t - count, vc->vc_cols);
1899 fbcon_clear(vc, t, 0, count, vc->vc_cols);
1902 case SCROLL_PAN_MOVE:
1903 if ((count - p->yscroll <= p->vrows - vc->vc_rows)
1904 && ((!scroll_partial && (b - t == vc->vc_rows))
1907 3 * vc->vc_rows >> 2)))) {
1908 if (vc->vc_rows - b > 0)
1909 fbcon_bmove(vc, b, 0, b - count, 0,
1912 ypan_down(vc, count);
1914 fbcon_bmove(vc, count, 0, 0, 0, t,
1916 } else if (info->flags & FBINFO_READS_FAST)
1917 fbcon_bmove(vc, t, 0, t + count, 0,
1918 b - t - count, vc->vc_cols);
1921 fbcon_clear(vc, t, 0, count, vc->vc_cols);
1924 case SCROLL_PAN_REDRAW:
1925 if ((count - p->yscroll <= p->vrows - vc->vc_rows)
1926 && ((!scroll_partial && (b - t == vc->vc_rows))
1929 3 * vc->vc_rows >> 2)))) {
1930 if (vc->vc_rows - b > 0)
1931 fbcon_redraw_move(vc, p, b, vc->vc_rows - b,
1933 ypan_down_redraw(vc, t, count);
1935 fbcon_redraw_move(vc, p, count, t, 0);
1937 fbcon_redraw_move(vc, p, t, b - t - count, t + count);
1938 fbcon_clear(vc, t, 0, count, vc->vc_cols);
1943 fbcon_redraw(vc, p, b - 1, b - t - count,
1944 -count * vc->vc_cols);
1945 fbcon_clear(vc, t, 0, count, vc->vc_cols);
1946 scr_memsetw((unsigned short *) (vc->vc_origin +
1949 vc->vc_video_erase_char,
1950 vc->vc_size_row * count);
1958 static void fbcon_bmove(struct vc_data *vc, int sy, int sx, int dy, int dx,
1959 int height, int width)
1961 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
1962 struct display *p = &fb_display[vc->vc_num];
1964 if (fbcon_is_inactive(vc, info))
1967 if (!width || !height)
1970 /* Split blits that cross physical y_wrap case.
1971 * Pathological case involves 4 blits, better to use recursive
1972 * code rather than unrolled case
1974 * Recursive invocations don't need to erase the cursor over and
1975 * over again, so we use fbcon_bmove_rec()
1977 fbcon_bmove_rec(vc, p, sy, sx, dy, dx, height, width,
1978 p->vrows - p->yscroll);
1981 static void fbcon_bmove_rec(struct vc_data *vc, struct display *p, int sy, int sx,
1982 int dy, int dx, int height, int width, u_int y_break)
1984 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
1985 struct fbcon_ops *ops = info->fbcon_par;
1988 if (sy < y_break && sy + height > y_break) {
1990 if (dy < sy) { /* Avoid trashing self */
1991 fbcon_bmove_rec(vc, p, sy, sx, dy, dx, b, width,
1993 fbcon_bmove_rec(vc, p, sy + b, sx, dy + b, dx,
1994 height - b, width, y_break);
1996 fbcon_bmove_rec(vc, p, sy + b, sx, dy + b, dx,
1997 height - b, width, y_break);
1998 fbcon_bmove_rec(vc, p, sy, sx, dy, dx, b, width,
2004 if (dy < y_break && dy + height > y_break) {
2006 if (dy < sy) { /* Avoid trashing self */
2007 fbcon_bmove_rec(vc, p, sy, sx, dy, dx, b, width,
2009 fbcon_bmove_rec(vc, p, sy + b, sx, dy + b, dx,
2010 height - b, width, y_break);
2012 fbcon_bmove_rec(vc, p, sy + b, sx, dy + b, dx,
2013 height - b, width, y_break);
2014 fbcon_bmove_rec(vc, p, sy, sx, dy, dx, b, width,
2019 ops->bmove(vc, info, real_y(p, sy), sx, real_y(p, dy), dx,
2023 static void updatescrollmode(struct display *p,
2024 struct fb_info *info,
2027 struct fbcon_ops *ops = info->fbcon_par;
2028 int fh = vc->vc_font.height;
2029 int cap = info->flags;
2031 int ypan = FBCON_SWAP(ops->rotate, info->fix.ypanstep,
2032 info->fix.xpanstep);
2033 int ywrap = FBCON_SWAP(ops->rotate, info->fix.ywrapstep, t);
2034 int yres = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
2035 int vyres = FBCON_SWAP(ops->rotate, info->var.yres_virtual,
2036 info->var.xres_virtual);
2037 int good_pan = (cap & FBINFO_HWACCEL_YPAN) &&
2038 divides(ypan, vc->vc_font.height) && vyres > yres;
2039 int good_wrap = (cap & FBINFO_HWACCEL_YWRAP) &&
2040 divides(ywrap, vc->vc_font.height) &&
2041 divides(vc->vc_font.height, vyres) &&
2042 divides(vc->vc_font.height, yres);
2043 int reading_fast = cap & FBINFO_READS_FAST;
2044 int fast_copyarea = (cap & FBINFO_HWACCEL_COPYAREA) &&
2045 !(cap & FBINFO_HWACCEL_DISABLED);
2046 int fast_imageblit = (cap & FBINFO_HWACCEL_IMAGEBLIT) &&
2047 !(cap & FBINFO_HWACCEL_DISABLED);
2049 p->vrows = vyres/fh;
2050 if (yres > (fh * (vc->vc_rows + 1)))
2051 p->vrows -= (yres - (fh * vc->vc_rows)) / fh;
2052 if ((yres % fh) && (vyres % fh < yres % fh))
2055 if (good_wrap || good_pan) {
2056 if (reading_fast || fast_copyarea)
2057 p->scrollmode = good_wrap ?
2058 SCROLL_WRAP_MOVE : SCROLL_PAN_MOVE;
2060 p->scrollmode = good_wrap ? SCROLL_REDRAW :
2063 if (reading_fast || (fast_copyarea && !fast_imageblit))
2064 p->scrollmode = SCROLL_MOVE;
2066 p->scrollmode = SCROLL_REDRAW;
2070 static int fbcon_resize(struct vc_data *vc, unsigned int width,
2071 unsigned int height, unsigned int user)
2073 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
2074 struct fbcon_ops *ops = info->fbcon_par;
2075 struct display *p = &fb_display[vc->vc_num];
2076 struct fb_var_screeninfo var = info->var;
2077 int x_diff, y_diff, virt_w, virt_h, virt_fw, virt_fh;
2079 virt_w = FBCON_SWAP(ops->rotate, width, height);
2080 virt_h = FBCON_SWAP(ops->rotate, height, width);
2081 virt_fw = FBCON_SWAP(ops->rotate, vc->vc_font.width,
2082 vc->vc_font.height);
2083 virt_fh = FBCON_SWAP(ops->rotate, vc->vc_font.height,
2085 var.xres = virt_w * virt_fw;
2086 var.yres = virt_h * virt_fh;
2087 x_diff = info->var.xres - var.xres;
2088 y_diff = info->var.yres - var.yres;
2089 if (x_diff < 0 || x_diff > virt_fw ||
2090 y_diff < 0 || y_diff > virt_fh) {
2091 const struct fb_videomode *mode;
2093 DPRINTK("attempting resize %ix%i\n", var.xres, var.yres);
2094 mode = fb_find_best_mode(&var, &info->modelist);
2097 display_to_var(&var, p);
2098 fb_videomode_to_var(&var, mode);
2100 if (virt_w > var.xres/virt_fw || virt_h > var.yres/virt_fh)
2103 DPRINTK("resize now %ix%i\n", var.xres, var.yres);
2104 if (CON_IS_VISIBLE(vc)) {
2105 var.activate = FB_ACTIVATE_NOW |
2107 fb_set_var(info, &var);
2109 var_to_display(p, &info->var, info);
2110 ops->var = info->var;
2112 updatescrollmode(p, info, vc);
2116 static int fbcon_switch(struct vc_data *vc)
2118 struct fb_info *info, *old_info = NULL;
2119 struct fbcon_ops *ops;
2120 struct display *p = &fb_display[vc->vc_num];
2121 struct fb_var_screeninfo var;
2122 int i, prev_console, charcnt = 256;
2124 info = registered_fb[con2fb_map[vc->vc_num]];
2125 ops = info->fbcon_par;
2129 fbcon_set_origin(vc);
2130 softback_top = softback_curr = softback_in = softback_buf;
2132 fbcon_update_softback(vc);
2135 if (logo_shown >= 0) {
2136 struct vc_data *conp2 = vc_cons[logo_shown].d;
2138 if (conp2->vc_top == logo_lines
2139 && conp2->vc_bottom == conp2->vc_rows)
2141 logo_shown = FBCON_LOGO_CANSHOW;
2144 prev_console = ops->currcon;
2145 if (prev_console != -1)
2146 old_info = registered_fb[con2fb_map[prev_console]];
2148 * FIXME: If we have multiple fbdev's loaded, we need to
2149 * update all info->currcon. Perhaps, we can place this
2150 * in a centralized structure, but this might break some
2153 * info->currcon = vc->vc_num;
2155 for (i = 0; i < FB_MAX; i++) {
2156 if (registered_fb[i] != NULL && registered_fb[i]->fbcon_par) {
2157 struct fbcon_ops *o = registered_fb[i]->fbcon_par;
2159 o->currcon = vc->vc_num;
2162 memset(&var, 0, sizeof(struct fb_var_screeninfo));
2163 display_to_var(&var, p);
2164 var.activate = FB_ACTIVATE_NOW;
2167 * make sure we don't unnecessarily trip the memcmp()
2170 info->var.activate = var.activate;
2171 var.vmode |= info->var.vmode & ~FB_VMODE_MASK;
2172 fb_set_var(info, &var);
2173 ops->var = info->var;
2175 if (old_info != NULL && (old_info != info ||
2176 info->flags & FBINFO_MISC_ALWAYS_SETPAR)) {
2177 if (info->fbops->fb_set_par)
2178 info->fbops->fb_set_par(info);
2180 if (old_info != info)
2181 fbcon_del_cursor_timer(old_info);
2184 if (fbcon_is_inactive(vc, info) ||
2185 ops->blank_state != FB_BLANK_UNBLANK)
2186 fbcon_del_cursor_timer(info);
2188 fbcon_add_cursor_timer(info);
2190 set_blitting_type(vc, info);
2191 ops->cursor_reset = 1;
2193 if (ops->rotate_font && ops->rotate_font(info, vc)) {
2194 ops->rotate = FB_ROTATE_UR;
2195 set_blitting_type(vc, info);
2198 vc->vc_can_do_color = (fb_get_color_depth(&info->var, &info->fix)!=1);
2199 vc->vc_complement_mask = vc->vc_can_do_color ? 0x7700 : 0x0800;
2202 charcnt = FNTCHARCNT(vc->vc_font.data);
2205 vc->vc_complement_mask <<= 1;
2207 updatescrollmode(p, info, vc);
2209 switch (p->scrollmode) {
2210 case SCROLL_WRAP_MOVE:
2211 scrollback_phys_max = p->vrows - vc->vc_rows;
2213 case SCROLL_PAN_MOVE:
2214 case SCROLL_PAN_REDRAW:
2215 scrollback_phys_max = p->vrows - 2 * vc->vc_rows;
2216 if (scrollback_phys_max < 0)
2217 scrollback_phys_max = 0;
2220 scrollback_phys_max = 0;
2225 scrollback_current = 0;
2227 if (!fbcon_is_inactive(vc, info)) {
2228 ops->var.xoffset = ops->var.yoffset = p->yscroll = 0;
2229 ops->update_start(info);
2232 fbcon_set_palette(vc, color_table);
2233 fbcon_clear_margins(vc, 0);
2235 if (logo_shown == FBCON_LOGO_DRAW) {
2237 logo_shown = fg_console;
2238 /* This is protected above by initmem_freed */
2239 fb_show_logo(info, ops->rotate);
2241 vc->vc_origin + vc->vc_size_row * vc->vc_top,
2242 vc->vc_size_row * (vc->vc_bottom -
2249 static void fbcon_generic_blank(struct vc_data *vc, struct fb_info *info,
2252 struct fb_event event;
2255 unsigned short charmask = vc->vc_hi_font_mask ?
2257 unsigned short oldc;
2259 oldc = vc->vc_video_erase_char;
2260 vc->vc_video_erase_char &= charmask;
2261 fbcon_clear(vc, 0, 0, vc->vc_rows, vc->vc_cols);
2262 vc->vc_video_erase_char = oldc;
2266 if (!lock_fb_info(info))
2269 event.data = ␣
2270 fb_notifier_call_chain(FB_EVENT_CONBLANK, &event);
2271 unlock_fb_info(info);
2274 static int fbcon_blank(struct vc_data *vc, int blank, int mode_switch)
2276 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
2277 struct fbcon_ops *ops = info->fbcon_par;
2280 struct fb_var_screeninfo var = info->var;
2285 if (info->fbops->fb_save_state)
2286 info->fbops->fb_save_state(info);
2287 var.activate = FB_ACTIVATE_NOW | FB_ACTIVATE_FORCE;
2288 fb_set_var(info, &var);
2290 ops->var = info->var;
2291 } else if (info->fbops->fb_restore_state)
2292 info->fbops->fb_restore_state(info);
2295 if (!fbcon_is_inactive(vc, info)) {
2296 if (ops->blank_state != blank) {
2297 ops->blank_state = blank;
2298 fbcon_cursor(vc, blank ? CM_ERASE : CM_DRAW);
2299 ops->cursor_flash = (!blank);
2301 if (!(info->flags & FBINFO_MISC_USEREVENT))
2302 if (fb_blank(info, blank))
2303 fbcon_generic_blank(vc, info, blank);
2310 if (mode_switch || fbcon_is_inactive(vc, info) ||
2311 ops->blank_state != FB_BLANK_UNBLANK)
2312 fbcon_del_cursor_timer(info);
2314 fbcon_add_cursor_timer(info);
2319 static int fbcon_get_font(struct vc_data *vc, struct console_font *font)
2321 u8 *fontdata = vc->vc_font.data;
2322 u8 *data = font->data;
2325 font->width = vc->vc_font.width;
2326 font->height = vc->vc_font.height;
2327 font->charcount = vc->vc_hi_font_mask ? 512 : 256;
2331 if (font->width <= 8) {
2332 j = vc->vc_font.height;
2333 for (i = 0; i < font->charcount; i++) {
2334 memcpy(data, fontdata, j);
2335 memset(data + j, 0, 32 - j);
2339 } else if (font->width <= 16) {
2340 j = vc->vc_font.height * 2;
2341 for (i = 0; i < font->charcount; i++) {
2342 memcpy(data, fontdata, j);
2343 memset(data + j, 0, 64 - j);
2347 } else if (font->width <= 24) {
2348 for (i = 0; i < font->charcount; i++) {
2349 for (j = 0; j < vc->vc_font.height; j++) {
2350 *data++ = fontdata[0];
2351 *data++ = fontdata[1];
2352 *data++ = fontdata[2];
2353 fontdata += sizeof(u32);
2355 memset(data, 0, 3 * (32 - j));
2356 data += 3 * (32 - j);
2359 j = vc->vc_font.height * 4;
2360 for (i = 0; i < font->charcount; i++) {
2361 memcpy(data, fontdata, j);
2362 memset(data + j, 0, 128 - j);
2370 static int fbcon_do_set_font(struct vc_data *vc, int w, int h,
2371 const u8 * data, int userfont)
2373 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
2374 struct fbcon_ops *ops = info->fbcon_par;
2375 struct display *p = &fb_display[vc->vc_num];
2378 char *old_data = NULL;
2380 if (CON_IS_VISIBLE(vc) && softback_lines)
2381 fbcon_set_origin(vc);
2383 resize = (w != vc->vc_font.width) || (h != vc->vc_font.height);
2385 old_data = vc->vc_font.data;
2387 cnt = FNTCHARCNT(data);
2390 vc->vc_font.data = (void *)(p->fontdata = data);
2391 if ((p->userfont = userfont))
2393 vc->vc_font.width = w;
2394 vc->vc_font.height = h;
2395 if (vc->vc_hi_font_mask && cnt == 256) {
2396 vc->vc_hi_font_mask = 0;
2397 if (vc->vc_can_do_color) {
2398 vc->vc_complement_mask >>= 1;
2399 vc->vc_s_complement_mask >>= 1;
2402 /* ++Edmund: reorder the attribute bits */
2403 if (vc->vc_can_do_color) {
2404 unsigned short *cp =
2405 (unsigned short *) vc->vc_origin;
2406 int count = vc->vc_screenbuf_size / 2;
2408 for (; count > 0; count--, cp++) {
2410 scr_writew(((c & 0xfe00) >> 1) |
2413 c = vc->vc_video_erase_char;
2414 vc->vc_video_erase_char =
2415 ((c & 0xfe00) >> 1) | (c & 0xff);
2418 } else if (!vc->vc_hi_font_mask && cnt == 512) {
2419 vc->vc_hi_font_mask = 0x100;
2420 if (vc->vc_can_do_color) {
2421 vc->vc_complement_mask <<= 1;
2422 vc->vc_s_complement_mask <<= 1;
2425 /* ++Edmund: reorder the attribute bits */
2427 unsigned short *cp =
2428 (unsigned short *) vc->vc_origin;
2429 int count = vc->vc_screenbuf_size / 2;
2431 for (; count > 0; count--, cp++) {
2432 unsigned short newc;
2434 if (vc->vc_can_do_color)
2436 ((c & 0xff00) << 1) | (c &
2440 scr_writew(newc, cp);
2442 c = vc->vc_video_erase_char;
2443 if (vc->vc_can_do_color) {
2444 vc->vc_video_erase_char =
2445 ((c & 0xff00) << 1) | (c & 0xff);
2448 vc->vc_video_erase_char = c & ~0x100;
2456 cols = FBCON_SWAP(ops->rotate, info->var.xres, info->var.yres);
2457 rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
2460 vc_resize(vc, cols, rows);
2461 if (CON_IS_VISIBLE(vc) && softback_buf)
2462 fbcon_update_softback(vc);
2463 } else if (CON_IS_VISIBLE(vc)
2464 && vc->vc_mode == KD_TEXT) {
2465 fbcon_clear_margins(vc, 0);
2469 if (old_data && (--REFCOUNT(old_data) == 0))
2470 kfree(old_data - FONT_EXTRA_WORDS * sizeof(int));
2474 static int fbcon_copy_font(struct vc_data *vc, int con)
2476 struct display *od = &fb_display[con];
2477 struct console_font *f = &vc->vc_font;
2479 if (od->fontdata == f->data)
2480 return 0; /* already the same font... */
2481 return fbcon_do_set_font(vc, f->width, f->height, od->fontdata, od->userfont);
2485 * User asked to set font; we are guaranteed that
2486 * a) width and height are in range 1..32
2487 * b) charcount does not exceed 512
2488 * but lets not assume that, since someone might someday want to use larger
2489 * fonts. And charcount of 512 is small for unicode support.
2491 * However, user space gives the font in 32 rows , regardless of
2492 * actual font height. So a new API is needed if support for larger fonts
2493 * is ever implemented.
2496 static int fbcon_set_font(struct vc_data *vc, struct console_font *font, unsigned flags)
2498 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
2499 unsigned charcount = font->charcount;
2500 int w = font->width;
2501 int h = font->height;
2504 u8 *new_data, *data = font->data;
2505 int pitch = (font->width+7) >> 3;
2507 /* Is there a reason why fbconsole couldn't handle any charcount >256?
2508 * If not this check should be changed to charcount < 256 */
2509 if (charcount != 256 && charcount != 512)
2512 /* Make sure drawing engine can handle the font */
2513 if (!(info->pixmap.blit_x & (1 << (font->width - 1))) ||
2514 !(info->pixmap.blit_y & (1 << (font->height - 1))))
2517 /* Make sure driver can handle the font length */
2518 if (fbcon_invalid_charcount(info, charcount))
2521 size = h * pitch * charcount;
2523 new_data = kmalloc(FONT_EXTRA_WORDS * sizeof(int) + size, GFP_USER);
2528 new_data += FONT_EXTRA_WORDS * sizeof(int);
2529 FNTSIZE(new_data) = size;
2530 FNTCHARCNT(new_data) = charcount;
2531 REFCOUNT(new_data) = 0; /* usage counter */
2532 for (i=0; i< charcount; i++) {
2533 memcpy(new_data + i*h*pitch, data + i*32*pitch, h*pitch);
2536 /* Since linux has a nice crc32 function use it for counting font
2538 csum = crc32(0, new_data, size);
2540 FNTSUM(new_data) = csum;
2541 /* Check if the same font is on some other console already */
2542 for (i = first_fb_vc; i <= last_fb_vc; i++) {
2543 struct vc_data *tmp = vc_cons[i].d;
2545 if (fb_display[i].userfont &&
2546 fb_display[i].fontdata &&
2547 FNTSUM(fb_display[i].fontdata) == csum &&
2548 FNTSIZE(fb_display[i].fontdata) == size &&
2549 tmp->vc_font.width == w &&
2550 !memcmp(fb_display[i].fontdata, new_data, size)) {
2551 kfree(new_data - FONT_EXTRA_WORDS * sizeof(int));
2552 new_data = (u8 *)fb_display[i].fontdata;
2556 return fbcon_do_set_font(vc, font->width, font->height, new_data, 1);
2559 static int fbcon_set_def_font(struct vc_data *vc, struct console_font *font, char *name)
2561 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
2562 const struct font_desc *f;
2565 f = get_default_font(info->var.xres, info->var.yres,
2566 info->pixmap.blit_x, info->pixmap.blit_y);
2567 else if (!(f = find_font(name)))
2570 font->width = f->width;
2571 font->height = f->height;
2572 return fbcon_do_set_font(vc, f->width, f->height, f->data, 0);
2575 static u16 palette_red[16];
2576 static u16 palette_green[16];
2577 static u16 palette_blue[16];
2579 static struct fb_cmap palette_cmap = {
2580 0, 16, palette_red, palette_green, palette_blue, NULL
2583 static int fbcon_set_palette(struct vc_data *vc, unsigned char *table)
2585 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
2589 if (fbcon_is_inactive(vc, info))
2592 if (!CON_IS_VISIBLE(vc))
2595 depth = fb_get_color_depth(&info->var, &info->fix);
2597 for (i = j = 0; i < 16; i++) {
2599 val = vc->vc_palette[j++];
2600 palette_red[k] = (val << 8) | val;
2601 val = vc->vc_palette[j++];
2602 palette_green[k] = (val << 8) | val;
2603 val = vc->vc_palette[j++];
2604 palette_blue[k] = (val << 8) | val;
2606 palette_cmap.len = 16;
2607 palette_cmap.start = 0;
2609 * If framebuffer is capable of less than 16 colors,
2610 * use default palette of fbcon.
2613 fb_copy_cmap(fb_default_cmap(1 << depth), &palette_cmap);
2615 return fb_set_cmap(&palette_cmap, info);
2618 static u16 *fbcon_screen_pos(struct vc_data *vc, int offset)
2623 if (vc->vc_num != fg_console || !softback_lines)
2624 return (u16 *) (vc->vc_origin + offset);
2625 line = offset / vc->vc_size_row;
2626 if (line >= softback_lines)
2627 return (u16 *) (vc->vc_origin + offset -
2628 softback_lines * vc->vc_size_row);
2629 p = softback_curr + offset;
2630 if (p >= softback_end)
2631 p += softback_buf - softback_end;
2635 static unsigned long fbcon_getxy(struct vc_data *vc, unsigned long pos,
2641 if (pos >= vc->vc_origin && pos < vc->vc_scr_end) {
2642 unsigned long offset = (pos - vc->vc_origin) / 2;
2644 x = offset % vc->vc_cols;
2645 y = offset / vc->vc_cols;
2646 if (vc->vc_num == fg_console)
2647 y += softback_lines;
2648 ret = pos + (vc->vc_cols - x) * 2;
2649 } else if (vc->vc_num == fg_console && softback_lines) {
2650 unsigned long offset = pos - softback_curr;
2652 if (pos < softback_curr)
2653 offset += softback_end - softback_buf;
2655 x = offset % vc->vc_cols;
2656 y = offset / vc->vc_cols;
2657 ret = pos + (vc->vc_cols - x) * 2;
2658 if (ret == softback_end)
2660 if (ret == softback_in)
2661 ret = vc->vc_origin;
2663 /* Should not happen */
2665 ret = vc->vc_origin;
2674 /* As we might be inside of softback, we may work with non-contiguous buffer,
2675 that's why we have to use a separate routine. */
2676 static void fbcon_invert_region(struct vc_data *vc, u16 * p, int cnt)
2679 u16 a = scr_readw(p);
2680 if (!vc->vc_can_do_color)
2682 else if (vc->vc_hi_font_mask == 0x100)
2683 a = ((a) & 0x11ff) | (((a) & 0xe000) >> 4) |
2684 (((a) & 0x0e00) << 4);
2686 a = ((a) & 0x88ff) | (((a) & 0x7000) >> 4) |
2687 (((a) & 0x0700) << 4);
2689 if (p == (u16 *) softback_end)
2690 p = (u16 *) softback_buf;
2691 if (p == (u16 *) softback_in)
2692 p = (u16 *) vc->vc_origin;
2696 static int fbcon_scrolldelta(struct vc_data *vc, int lines)
2698 struct fb_info *info = registered_fb[con2fb_map[fg_console]];
2699 struct fbcon_ops *ops = info->fbcon_par;
2700 struct display *disp = &fb_display[fg_console];
2701 int offset, limit, scrollback_old;
2704 if (vc->vc_num != fg_console)
2706 if (vc->vc_mode != KD_TEXT || !lines)
2708 if (logo_shown >= 0) {
2709 struct vc_data *conp2 = vc_cons[logo_shown].d;
2711 if (conp2->vc_top == logo_lines
2712 && conp2->vc_bottom == conp2->vc_rows)
2714 if (logo_shown == vc->vc_num) {
2720 logo_lines * vc->vc_size_row;
2721 for (i = 0; i < logo_lines; i++) {
2722 if (p == softback_top)
2724 if (p == softback_buf)
2726 p -= vc->vc_size_row;
2727 q -= vc->vc_size_row;
2728 scr_memcpyw((u16 *) q, (u16 *) p,
2731 softback_in = softback_curr = p;
2732 update_region(vc, vc->vc_origin,
2733 logo_lines * vc->vc_cols);
2735 logo_shown = FBCON_LOGO_CANSHOW;
2737 fbcon_cursor(vc, CM_ERASE | CM_SOFTBACK);
2738 fbcon_redraw_softback(vc, disp, lines);
2739 fbcon_cursor(vc, CM_DRAW | CM_SOFTBACK);
2743 if (!scrollback_phys_max)
2746 scrollback_old = scrollback_current;
2747 scrollback_current -= lines;
2748 if (scrollback_current < 0)
2749 scrollback_current = 0;
2750 else if (scrollback_current > scrollback_max)
2751 scrollback_current = scrollback_max;
2752 if (scrollback_current == scrollback_old)
2755 if (fbcon_is_inactive(vc, info))
2758 fbcon_cursor(vc, CM_ERASE);
2760 offset = disp->yscroll - scrollback_current;
2761 limit = disp->vrows;
2762 switch (disp->scrollmode) {
2763 case SCROLL_WRAP_MOVE:
2764 info->var.vmode |= FB_VMODE_YWRAP;
2766 case SCROLL_PAN_MOVE:
2767 case SCROLL_PAN_REDRAW:
2768 limit -= vc->vc_rows;
2769 info->var.vmode &= ~FB_VMODE_YWRAP;
2774 else if (offset >= limit)
2777 ops->var.xoffset = 0;
2778 ops->var.yoffset = offset * vc->vc_font.height;
2779 ops->update_start(info);
2781 if (!scrollback_current)
2782 fbcon_cursor(vc, CM_DRAW);
2786 static int fbcon_set_origin(struct vc_data *vc)
2789 fbcon_scrolldelta(vc, softback_lines);
2793 static void fbcon_suspended(struct fb_info *info)
2795 struct vc_data *vc = NULL;
2796 struct fbcon_ops *ops = info->fbcon_par;
2798 if (!ops || ops->currcon < 0)
2800 vc = vc_cons[ops->currcon].d;
2802 /* Clear cursor, restore saved data */
2803 fbcon_cursor(vc, CM_ERASE);
2806 static void fbcon_resumed(struct fb_info *info)
2809 struct fbcon_ops *ops = info->fbcon_par;
2811 if (!ops || ops->currcon < 0)
2813 vc = vc_cons[ops->currcon].d;
2818 static void fbcon_modechanged(struct fb_info *info)
2820 struct fbcon_ops *ops = info->fbcon_par;
2825 if (!ops || ops->currcon < 0)
2827 vc = vc_cons[ops->currcon].d;
2828 if (vc->vc_mode != KD_TEXT ||
2829 registered_fb[con2fb_map[ops->currcon]] != info)
2832 p = &fb_display[vc->vc_num];
2833 set_blitting_type(vc, info);
2835 if (CON_IS_VISIBLE(vc)) {
2836 var_to_display(p, &info->var, info);
2837 cols = FBCON_SWAP(ops->rotate, info->var.xres, info->var.yres);
2838 rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
2839 cols /= vc->vc_font.width;
2840 rows /= vc->vc_font.height;
2841 vc_resize(vc, cols, rows);
2842 updatescrollmode(p, info, vc);
2844 scrollback_current = 0;
2846 if (!fbcon_is_inactive(vc, info)) {
2847 ops->var.xoffset = ops->var.yoffset = p->yscroll = 0;
2848 ops->update_start(info);
2851 fbcon_set_palette(vc, color_table);
2854 fbcon_update_softback(vc);
2858 static void fbcon_set_all_vcs(struct fb_info *info)
2860 struct fbcon_ops *ops = info->fbcon_par;
2863 int i, rows, cols, fg = -1;
2865 if (!ops || ops->currcon < 0)
2868 for (i = first_fb_vc; i <= last_fb_vc; i++) {
2870 if (!vc || vc->vc_mode != KD_TEXT ||
2871 registered_fb[con2fb_map[i]] != info)
2874 if (CON_IS_VISIBLE(vc)) {
2879 p = &fb_display[vc->vc_num];
2880 set_blitting_type(vc, info);
2881 var_to_display(p, &info->var, info);
2882 cols = FBCON_SWAP(ops->rotate, info->var.xres, info->var.yres);
2883 rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
2884 cols /= vc->vc_font.width;
2885 rows /= vc->vc_font.height;
2886 vc_resize(vc, cols, rows);
2890 fbcon_modechanged(info);
2893 static int fbcon_mode_deleted(struct fb_info *info,
2894 struct fb_videomode *mode)
2896 struct fb_info *fb_info;
2898 int i, j, found = 0;
2900 /* before deletion, ensure that mode is not in use */
2901 for (i = first_fb_vc; i <= last_fb_vc; i++) {
2905 fb_info = registered_fb[j];
2906 if (fb_info != info)
2911 if (fb_mode_is_equal(p->mode, mode)) {
2919 #ifdef CONFIG_VT_HW_CONSOLE_BINDING
2920 static int fbcon_unbind(void)
2924 ret = unbind_con_driver(&fb_con, first_fb_vc, last_fb_vc,
2929 static inline int fbcon_unbind(void)
2933 #endif /* CONFIG_VT_HW_CONSOLE_BINDING */
2935 static int fbcon_fb_unbind(int idx)
2937 int i, new_idx = -1, ret = 0;
2939 for (i = first_fb_vc; i <= last_fb_vc; i++) {
2940 if (con2fb_map[i] != idx &&
2941 con2fb_map[i] != -1) {
2947 if (new_idx != -1) {
2948 for (i = first_fb_vc; i <= last_fb_vc; i++) {
2949 if (con2fb_map[i] == idx)
2950 set_con2fb_map(i, new_idx, 0);
2953 ret = fbcon_unbind();
2958 static int fbcon_fb_unregistered(struct fb_info *info)
2963 for (i = first_fb_vc; i <= last_fb_vc; i++) {
2964 if (con2fb_map[i] == idx)
2968 if (idx == info_idx) {
2971 for (i = 0; i < FB_MAX; i++) {
2972 if (registered_fb[i] != NULL) {
2979 if (info_idx != -1) {
2980 for (i = first_fb_vc; i <= last_fb_vc; i++) {
2981 if (con2fb_map[i] == -1)
2982 con2fb_map[i] = info_idx;
2986 if (primary_device == idx)
2987 primary_device = -1;
2989 if (!num_registered_fb)
2990 unregister_con_driver(&fb_con);
2995 #ifdef CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY
2996 static void fbcon_select_primary(struct fb_info *info)
2998 if (!map_override && primary_device == -1 &&
2999 fb_is_primary_device(info)) {
3002 printk(KERN_INFO "fbcon: %s (fb%i) is primary device\n",
3003 info->fix.id, info->node);
3004 primary_device = info->node;
3006 for (i = first_fb_vc; i <= last_fb_vc; i++)
3007 con2fb_map_boot[i] = primary_device;
3009 if (con_is_bound(&fb_con)) {
3010 printk(KERN_INFO "fbcon: Remapping primary device, "
3011 "fb%i, to tty %i-%i\n", info->node,
3012 first_fb_vc + 1, last_fb_vc + 1);
3013 info_idx = primary_device;
3019 static inline void fbcon_select_primary(struct fb_info *info)
3023 #endif /* CONFIG_FRAMEBUFFER_DETECT_PRIMARY */
3025 static int fbcon_fb_registered(struct fb_info *info)
3027 int ret = 0, i, idx;
3030 fbcon_select_primary(info);
3032 if (info_idx == -1) {
3033 for (i = first_fb_vc; i <= last_fb_vc; i++) {
3034 if (con2fb_map_boot[i] == idx) {
3041 ret = fbcon_takeover(1);
3043 for (i = first_fb_vc; i <= last_fb_vc; i++) {
3044 if (con2fb_map_boot[i] == idx)
3045 set_con2fb_map(i, idx, 0);
3052 static void fbcon_fb_blanked(struct fb_info *info, int blank)
3054 struct fbcon_ops *ops = info->fbcon_par;
3057 if (!ops || ops->currcon < 0)
3060 vc = vc_cons[ops->currcon].d;
3061 if (vc->vc_mode != KD_TEXT ||
3062 registered_fb[con2fb_map[ops->currcon]] != info)
3065 if (CON_IS_VISIBLE(vc)) {
3069 do_unblank_screen(0);
3071 ops->blank_state = blank;
3074 static void fbcon_new_modelist(struct fb_info *info)
3078 struct fb_var_screeninfo var;
3079 const struct fb_videomode *mode;
3081 for (i = first_fb_vc; i <= last_fb_vc; i++) {
3082 if (registered_fb[con2fb_map[i]] != info)
3084 if (!fb_display[i].mode)
3087 display_to_var(&var, &fb_display[i]);
3088 mode = fb_find_nearest_mode(fb_display[i].mode,
3090 fb_videomode_to_var(&var, mode);
3091 fbcon_set_disp(info, &var, vc->vc_num);
3095 static void fbcon_get_requirement(struct fb_info *info,
3096 struct fb_blit_caps *caps)
3104 for (i = first_fb_vc; i <= last_fb_vc; i++) {
3106 if (vc && vc->vc_mode == KD_TEXT &&
3107 info->node == con2fb_map[i]) {
3109 caps->x |= 1 << (vc->vc_font.width - 1);
3110 caps->y |= 1 << (vc->vc_font.height - 1);
3111 charcnt = (p->userfont) ?
3112 FNTCHARCNT(p->fontdata) : 256;
3113 if (caps->len < charcnt)
3114 caps->len = charcnt;
3118 vc = vc_cons[fg_console].d;
3120 if (vc && vc->vc_mode == KD_TEXT &&
3121 info->node == con2fb_map[fg_console]) {
3122 p = &fb_display[fg_console];
3123 caps->x = 1 << (vc->vc_font.width - 1);
3124 caps->y = 1 << (vc->vc_font.height - 1);
3125 caps->len = (p->userfont) ?
3126 FNTCHARCNT(p->fontdata) : 256;
3131 static int fbcon_event_notify(struct notifier_block *self,
3132 unsigned long action, void *data)
3134 struct fb_event *event = data;
3135 struct fb_info *info = event->info;
3136 struct fb_videomode *mode;
3137 struct fb_con2fbmap *con2fb;
3138 struct fb_blit_caps *caps;
3142 * ignore all events except driver registration and deregistration
3143 * if fbcon is not active
3145 if (fbcon_has_exited && !(action == FB_EVENT_FB_REGISTERED ||
3146 action == FB_EVENT_FB_UNREGISTERED))
3150 case FB_EVENT_SUSPEND:
3151 fbcon_suspended(info);
3153 case FB_EVENT_RESUME:
3154 fbcon_resumed(info);
3156 case FB_EVENT_MODE_CHANGE:
3157 fbcon_modechanged(info);
3159 case FB_EVENT_MODE_CHANGE_ALL:
3160 fbcon_set_all_vcs(info);
3162 case FB_EVENT_MODE_DELETE:
3164 ret = fbcon_mode_deleted(info, mode);
3166 case FB_EVENT_FB_UNBIND:
3168 ret = fbcon_fb_unbind(idx);
3170 case FB_EVENT_FB_REGISTERED:
3171 ret = fbcon_fb_registered(info);
3173 case FB_EVENT_FB_UNREGISTERED:
3174 ret = fbcon_fb_unregistered(info);
3176 case FB_EVENT_SET_CONSOLE_MAP:
3177 con2fb = event->data;
3178 ret = set_con2fb_map(con2fb->console - 1,
3179 con2fb->framebuffer, 1);
3181 case FB_EVENT_GET_CONSOLE_MAP:
3182 con2fb = event->data;
3183 con2fb->framebuffer = con2fb_map[con2fb->console - 1];
3185 case FB_EVENT_BLANK:
3186 fbcon_fb_blanked(info, *(int *)event->data);
3188 case FB_EVENT_NEW_MODELIST:
3189 fbcon_new_modelist(info);
3191 case FB_EVENT_GET_REQ:
3193 fbcon_get_requirement(info, caps);
3201 * The console `switch' structure for the frame buffer based console
3204 static const struct consw fb_con = {
3205 .owner = THIS_MODULE,
3206 .con_startup = fbcon_startup,
3207 .con_init = fbcon_init,
3208 .con_deinit = fbcon_deinit,
3209 .con_clear = fbcon_clear,
3210 .con_putc = fbcon_putc,
3211 .con_putcs = fbcon_putcs,
3212 .con_cursor = fbcon_cursor,
3213 .con_scroll = fbcon_scroll,
3214 .con_bmove = fbcon_bmove,
3215 .con_switch = fbcon_switch,
3216 .con_blank = fbcon_blank,
3217 .con_font_set = fbcon_set_font,
3218 .con_font_get = fbcon_get_font,
3219 .con_font_default = fbcon_set_def_font,
3220 .con_font_copy = fbcon_copy_font,
3221 .con_set_palette = fbcon_set_palette,
3222 .con_scrolldelta = fbcon_scrolldelta,
3223 .con_set_origin = fbcon_set_origin,
3224 .con_invert_region = fbcon_invert_region,
3225 .con_screen_pos = fbcon_screen_pos,
3226 .con_getxy = fbcon_getxy,
3227 .con_resize = fbcon_resize,
3230 static struct notifier_block fbcon_event_notifier = {
3231 .notifier_call = fbcon_event_notify,
3234 static ssize_t store_rotate(struct device *device,
3235 struct device_attribute *attr, const char *buf,
3238 struct fb_info *info;
3242 if (fbcon_has_exited)
3245 acquire_console_sem();
3246 idx = con2fb_map[fg_console];
3248 if (idx == -1 || registered_fb[idx] == NULL)
3251 info = registered_fb[idx];
3252 rotate = simple_strtoul(buf, last, 0);
3253 fbcon_rotate(info, rotate);
3255 release_console_sem();
3259 static ssize_t store_rotate_all(struct device *device,
3260 struct device_attribute *attr,const char *buf,
3263 struct fb_info *info;
3267 if (fbcon_has_exited)
3270 acquire_console_sem();
3271 idx = con2fb_map[fg_console];
3273 if (idx == -1 || registered_fb[idx] == NULL)
3276 info = registered_fb[idx];
3277 rotate = simple_strtoul(buf, last, 0);
3278 fbcon_rotate_all(info, rotate);
3280 release_console_sem();
3284 static ssize_t show_rotate(struct device *device,
3285 struct device_attribute *attr,char *buf)
3287 struct fb_info *info;
3288 int rotate = 0, idx;
3290 if (fbcon_has_exited)
3293 acquire_console_sem();
3294 idx = con2fb_map[fg_console];
3296 if (idx == -1 || registered_fb[idx] == NULL)
3299 info = registered_fb[idx];
3300 rotate = fbcon_get_rotate(info);
3302 release_console_sem();
3303 return snprintf(buf, PAGE_SIZE, "%d\n", rotate);
3306 static ssize_t show_cursor_blink(struct device *device,
3307 struct device_attribute *attr, char *buf)
3309 struct fb_info *info;
3310 struct fbcon_ops *ops;
3311 int idx, blink = -1;
3313 if (fbcon_has_exited)
3316 acquire_console_sem();
3317 idx = con2fb_map[fg_console];
3319 if (idx == -1 || registered_fb[idx] == NULL)
3322 info = registered_fb[idx];
3323 ops = info->fbcon_par;
3328 blink = (ops->flags & FBCON_FLAGS_CURSOR_TIMER) ? 1 : 0;
3330 release_console_sem();
3331 return snprintf(buf, PAGE_SIZE, "%d\n", blink);
3334 static ssize_t store_cursor_blink(struct device *device,
3335 struct device_attribute *attr,
3336 const char *buf, size_t count)
3338 struct fb_info *info;
3342 if (fbcon_has_exited)
3345 acquire_console_sem();
3346 idx = con2fb_map[fg_console];
3348 if (idx == -1 || registered_fb[idx] == NULL)
3351 info = registered_fb[idx];
3353 if (!info->fbcon_par)
3356 blink = simple_strtoul(buf, last, 0);
3359 fbcon_cursor_noblink = 0;
3360 fbcon_add_cursor_timer(info);
3362 fbcon_cursor_noblink = 1;
3363 fbcon_del_cursor_timer(info);
3367 release_console_sem();
3371 static struct device_attribute device_attrs[] = {
3372 __ATTR(rotate, S_IRUGO|S_IWUSR, show_rotate, store_rotate),
3373 __ATTR(rotate_all, S_IWUSR, NULL, store_rotate_all),
3374 __ATTR(cursor_blink, S_IRUGO|S_IWUSR, show_cursor_blink,
3375 store_cursor_blink),
3378 static int fbcon_init_device(void)
3382 fbcon_has_sysfs = 1;
3384 for (i = 0; i < ARRAY_SIZE(device_attrs); i++) {
3385 error = device_create_file(fbcon_device, &device_attrs[i]);
3393 device_remove_file(fbcon_device, &device_attrs[i]);
3395 fbcon_has_sysfs = 0;
3401 static void fbcon_start(void)
3403 if (num_registered_fb) {
3406 acquire_console_sem();
3408 for (i = 0; i < FB_MAX; i++) {
3409 if (registered_fb[i] != NULL) {
3415 release_console_sem();
3420 static void fbcon_exit(void)
3422 struct fb_info *info;
3425 if (fbcon_has_exited)
3428 kfree((void *)softback_buf);
3431 for (i = 0; i < FB_MAX; i++) {
3435 info = registered_fb[i];
3440 pending = cancel_work_sync(&info->queue);
3441 DPRINTK("fbcon: %s pending work\n", (pending ? "canceled" :
3444 for (j = first_fb_vc; j <= last_fb_vc; j++) {
3445 if (con2fb_map[j] == i)
3450 if (info->fbops->fb_release)
3451 info->fbops->fb_release(info, 0);
3452 module_put(info->fbops->owner);
3454 if (info->fbcon_par) {
3455 struct fbcon_ops *ops = info->fbcon_par;
3457 fbcon_del_cursor_timer(info);
3458 kfree(ops->cursor_src);
3459 kfree(info->fbcon_par);
3460 info->fbcon_par = NULL;
3463 if (info->queue.func == fb_flashcursor)
3464 info->queue.func = NULL;
3468 fbcon_has_exited = 1;
3471 static int __init fb_console_init(void)
3475 acquire_console_sem();
3476 fb_register_client(&fbcon_event_notifier);
3477 fbcon_device = device_create(fb_class, NULL, MKDEV(0, 0), NULL,
3480 if (IS_ERR(fbcon_device)) {
3481 printk(KERN_WARNING "Unable to create device "
3482 "for fbcon; errno = %ld\n",
3483 PTR_ERR(fbcon_device));
3484 fbcon_device = NULL;
3486 fbcon_init_device();
3488 for (i = 0; i < MAX_NR_CONSOLES; i++)
3491 release_console_sem();
3496 module_init(fb_console_init);
3500 static void __exit fbcon_deinit_device(void)
3504 if (fbcon_has_sysfs) {
3505 for (i = 0; i < ARRAY_SIZE(device_attrs); i++)
3506 device_remove_file(fbcon_device, &device_attrs[i]);
3508 fbcon_has_sysfs = 0;
3512 static void __exit fb_console_exit(void)
3514 acquire_console_sem();
3515 fb_unregister_client(&fbcon_event_notifier);
3516 fbcon_deinit_device();
3517 device_destroy(fb_class, MKDEV(0, 0));
3519 release_console_sem();
3520 unregister_con_driver(&fb_con);
3523 module_exit(fb_console_exit);
3527 MODULE_LICENSE("GPL");