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/fbcon.h>
72 #include <linux/vt_kern.h>
73 #include <linux/selection.h>
74 #include <linux/font.h>
75 #include <linux/smp.h>
76 #include <linux/init.h>
77 #include <linux/interrupt.h>
78 #include <linux/crc32.h> /* For counting font checksums */
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 /* console mappings */
106 static unsigned int first_fb_vc;
107 static unsigned int last_fb_vc = MAX_NR_CONSOLES - 1;
108 static int fbcon_is_default = 1;
109 static int fbcon_has_exited;
110 static int primary_device = -1;
111 static int fbcon_has_console_bind;
113 #ifdef CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY
114 static int map_override;
116 static inline void fbcon_map_override(void)
121 static inline void fbcon_map_override(void)
124 #endif /* CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY */
126 #ifdef CONFIG_FRAMEBUFFER_CONSOLE_DEFERRED_TAKEOVER
127 static bool deferred_takeover = true;
129 #define deferred_takeover false
133 static char fontname[40];
135 /* current fb_info */
136 static int info_idx = -1;
138 /* console rotation */
139 static int initial_rotation = -1;
140 static int fbcon_has_sysfs;
141 static int margin_color;
143 static const struct consw fb_con;
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 static int fbcon_cursor_noblink;
151 #define divides(a, b) ((!(a) || (b)%(a)) ? 0 : 1)
154 * Interface used by the world
157 static const char *fbcon_startup(void);
158 static void fbcon_init(struct vc_data *vc, int init);
159 static void fbcon_deinit(struct vc_data *vc);
160 static void fbcon_clear(struct vc_data *vc, int sy, int sx, int height,
162 static void fbcon_putc(struct vc_data *vc, int c, int ypos, int xpos);
163 static void fbcon_putcs(struct vc_data *vc, const unsigned short *s,
164 int count, int ypos, int xpos);
165 static void fbcon_clear_margins(struct vc_data *vc, int bottom_only);
166 static void fbcon_cursor(struct vc_data *vc, int mode);
167 static void fbcon_bmove(struct vc_data *vc, int sy, int sx, int dy, int dx,
168 int height, int width);
169 static int fbcon_switch(struct vc_data *vc);
170 static int fbcon_blank(struct vc_data *vc, int blank, int mode_switch);
171 static void fbcon_set_palette(struct vc_data *vc, const unsigned char *table);
176 static __inline__ void ywrap_up(struct vc_data *vc, int count);
177 static __inline__ void ywrap_down(struct vc_data *vc, int count);
178 static __inline__ void ypan_up(struct vc_data *vc, int count);
179 static __inline__ void ypan_down(struct vc_data *vc, int count);
180 static void fbcon_bmove_rec(struct vc_data *vc, struct display *p, int sy, int sx,
181 int dy, int dx, int height, int width, u_int y_break);
182 static void fbcon_set_disp(struct fb_info *info, struct fb_var_screeninfo *var,
184 static void fbcon_redraw_move(struct vc_data *vc, struct display *p,
185 int line, int count, int dy);
186 static void fbcon_modechanged(struct fb_info *info);
187 static void fbcon_set_all_vcs(struct fb_info *info);
188 static void fbcon_start(void);
189 static void fbcon_exit(void);
190 static struct device *fbcon_device;
192 #ifdef CONFIG_FRAMEBUFFER_CONSOLE_ROTATION
193 static inline void fbcon_set_rotation(struct fb_info *info)
195 struct fbcon_ops *ops = info->fbcon_par;
197 if (!(info->flags & FBINFO_MISC_TILEBLITTING) &&
198 ops->p->con_rotate < 4)
199 ops->rotate = ops->p->con_rotate;
204 static void fbcon_rotate(struct fb_info *info, u32 rotate)
206 struct fbcon_ops *ops= info->fbcon_par;
207 struct fb_info *fb_info;
209 if (!ops || ops->currcon == -1)
212 fb_info = registered_fb[con2fb_map[ops->currcon]];
214 if (info == fb_info) {
215 struct display *p = &fb_display[ops->currcon];
218 p->con_rotate = rotate;
222 fbcon_modechanged(info);
226 static void fbcon_rotate_all(struct fb_info *info, u32 rotate)
228 struct fbcon_ops *ops = info->fbcon_par;
233 if (!ops || ops->currcon < 0 || rotate > 3)
236 for (i = first_fb_vc; i <= last_fb_vc; i++) {
238 if (!vc || vc->vc_mode != KD_TEXT ||
239 registered_fb[con2fb_map[i]] != info)
242 p = &fb_display[vc->vc_num];
243 p->con_rotate = rotate;
246 fbcon_set_all_vcs(info);
249 static inline void fbcon_set_rotation(struct fb_info *info)
251 struct fbcon_ops *ops = info->fbcon_par;
253 ops->rotate = FB_ROTATE_UR;
256 static void fbcon_rotate(struct fb_info *info, u32 rotate)
261 static void fbcon_rotate_all(struct fb_info *info, u32 rotate)
265 #endif /* CONFIG_FRAMEBUFFER_CONSOLE_ROTATION */
267 static int fbcon_get_rotate(struct fb_info *info)
269 struct fbcon_ops *ops = info->fbcon_par;
271 return (ops) ? ops->rotate : 0;
274 static inline int fbcon_is_inactive(struct vc_data *vc, struct fb_info *info)
276 struct fbcon_ops *ops = info->fbcon_par;
278 return (info->state != FBINFO_STATE_RUNNING ||
279 vc->vc_mode != KD_TEXT || ops->graphics) &&
280 !vt_force_oops_output(vc);
283 static int get_color(struct vc_data *vc, struct fb_info *info,
286 int depth = fb_get_color_depth(&info->var, &info->fix);
289 if (console_blanked) {
290 unsigned short charmask = vc->vc_hi_font_mask ? 0x1ff : 0xff;
292 c = vc->vc_video_erase_char & charmask;
296 color = (is_fg) ? attr_fgcol((vc->vc_hi_font_mask) ? 9 : 8, c)
297 : attr_bgcol((vc->vc_hi_font_mask) ? 13 : 12, c);
302 int col = mono_col(info);
304 int fg = (info->fix.visual != FB_VISUAL_MONO01) ? col : 0;
305 int bg = (info->fix.visual != FB_VISUAL_MONO01) ? 0 : col;
310 color = (is_fg) ? fg : bg;
315 * Scale down 16-colors to 4 colors. Default 4-color palette
316 * is grayscale. However, simply dividing the values by 4
317 * will not work, as colors 1, 2 and 3 will be scaled-down
318 * to zero rendering them invisible. So empirically convert
319 * colors to a sane 4-level grayscale.
323 color = 0; /* black */
326 color = 2; /* white */
329 color = 1; /* gray */
332 color = 3; /* intense white */
338 * Last 8 entries of default 16-color palette is a more intense
339 * version of the first 8 (i.e., same chrominance, different
350 static void fb_flashcursor(struct work_struct *work)
352 struct fb_info *info = container_of(work, struct fb_info, queue);
353 struct fbcon_ops *ops = info->fbcon_par;
354 struct vc_data *vc = NULL;
359 /* FIXME: we should sort out the unbind locking instead */
360 /* instead we just fail to flash the cursor if we can't get
361 * the lock instead of blocking fbcon deinit */
362 ret = console_trylock();
366 if (ops && ops->currcon != -1)
367 vc = vc_cons[ops->currcon].d;
369 if (!vc || !con_is_visible(vc) ||
370 registered_fb[con2fb_map[vc->vc_num]] != info ||
376 c = scr_readw((u16 *) vc->vc_pos);
377 mode = (!ops->cursor_flash || ops->cursor_state.enable) ?
379 ops->cursor(vc, info, mode, get_color(vc, info, c, 1),
380 get_color(vc, info, c, 0));
384 static void cursor_timer_handler(struct timer_list *t)
386 struct fbcon_ops *ops = from_timer(ops, t, cursor_timer);
387 struct fb_info *info = ops->info;
389 queue_work(system_power_efficient_wq, &info->queue);
390 mod_timer(&ops->cursor_timer, jiffies + ops->cur_blink_jiffies);
393 static void fbcon_add_cursor_timer(struct fb_info *info)
395 struct fbcon_ops *ops = info->fbcon_par;
397 if ((!info->queue.func || info->queue.func == fb_flashcursor) &&
398 !(ops->flags & FBCON_FLAGS_CURSOR_TIMER) &&
399 !fbcon_cursor_noblink) {
400 if (!info->queue.func)
401 INIT_WORK(&info->queue, fb_flashcursor);
403 timer_setup(&ops->cursor_timer, cursor_timer_handler, 0);
404 mod_timer(&ops->cursor_timer, jiffies + ops->cur_blink_jiffies);
405 ops->flags |= FBCON_FLAGS_CURSOR_TIMER;
409 static void fbcon_del_cursor_timer(struct fb_info *info)
411 struct fbcon_ops *ops = info->fbcon_par;
413 if (info->queue.func == fb_flashcursor &&
414 ops->flags & FBCON_FLAGS_CURSOR_TIMER) {
415 del_timer_sync(&ops->cursor_timer);
416 ops->flags &= ~FBCON_FLAGS_CURSOR_TIMER;
421 static int __init fb_console_setup(char *this_opt)
426 if (!this_opt || !*this_opt)
429 while ((options = strsep(&this_opt, ",")) != NULL) {
430 if (!strncmp(options, "font:", 5)) {
431 strlcpy(fontname, options + 5, sizeof(fontname));
435 if (!strncmp(options, "scrollback:", 11)) {
436 pr_warn("Ignoring scrollback size option\n");
440 if (!strncmp(options, "map:", 4)) {
443 for (i = 0, j = 0; i < MAX_NR_CONSOLES; i++) {
447 (options[j++]-'0') % FB_MAX;
450 fbcon_map_override();
455 if (!strncmp(options, "vc:", 3)) {
458 first_fb_vc = simple_strtoul(options, &options, 10) - 1;
459 if (first_fb_vc >= MAX_NR_CONSOLES)
461 if (*options++ == '-')
462 last_fb_vc = simple_strtoul(options, &options, 10) - 1;
463 if (last_fb_vc < first_fb_vc || last_fb_vc >= MAX_NR_CONSOLES)
464 last_fb_vc = MAX_NR_CONSOLES - 1;
465 fbcon_is_default = 0;
469 if (!strncmp(options, "rotate:", 7)) {
472 initial_rotation = simple_strtoul(options, &options, 0);
473 if (initial_rotation > 3)
474 initial_rotation = 0;
478 if (!strncmp(options, "margin:", 7)) {
481 margin_color = simple_strtoul(options, &options, 0);
484 #ifdef CONFIG_FRAMEBUFFER_CONSOLE_DEFERRED_TAKEOVER
485 if (!strcmp(options, "nodefer")) {
486 deferred_takeover = false;
494 __setup("fbcon=", fb_console_setup);
497 static int search_fb_in_map(int idx)
501 for (i = first_fb_vc; i <= last_fb_vc; i++) {
502 if (con2fb_map[i] == idx)
508 static int search_for_mapped_con(void)
512 for (i = first_fb_vc; i <= last_fb_vc; i++) {
513 if (con2fb_map[i] != -1)
519 static int do_fbcon_takeover(int show_logo)
523 if (!num_registered_fb)
527 logo_shown = FBCON_LOGO_DONTSHOW;
529 for (i = first_fb_vc; i <= last_fb_vc; i++)
530 con2fb_map[i] = info_idx;
532 err = do_take_over_console(&fb_con, first_fb_vc, last_fb_vc,
536 for (i = first_fb_vc; i <= last_fb_vc; i++)
540 fbcon_has_console_bind = 1;
547 static void fbcon_prepare_logo(struct vc_data *vc, struct fb_info *info,
548 int cols, int rows, int new_cols, int new_rows)
550 logo_shown = FBCON_LOGO_DONTSHOW;
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 /* Need to make room for the logo */
557 struct fbcon_ops *ops = info->fbcon_par;
558 int cnt, erase = vc->vc_video_erase_char, step;
559 unsigned short *save = NULL, *r, *q;
562 if (info->fbops->owner) {
563 logo_shown = FBCON_LOGO_DONTSHOW;
568 * remove underline attribute from erase character
569 * if black and white framebuffer.
571 if (fb_get_color_depth(&info->var, &info->fix) == 1)
573 logo_height = fb_prepare_logo(info, ops->rotate);
574 logo_lines = DIV_ROUND_UP(logo_height, vc->vc_font.height);
575 q = (unsigned short *) (vc->vc_origin +
576 vc->vc_size_row * rows);
577 step = logo_lines * cols;
578 for (r = q - logo_lines * cols; r < q; r++)
579 if (scr_readw(r) != vc->vc_video_erase_char)
581 if (r != q && new_rows >= rows + logo_lines) {
582 save = kmalloc(array3_size(logo_lines, new_cols, 2),
585 int i = cols < new_cols ? cols : new_cols;
586 scr_memsetw(save, erase, logo_lines * new_cols * 2);
588 for (cnt = 0; cnt < logo_lines; cnt++, r += i)
589 scr_memcpyw(save + cnt * new_cols, r, 2 * i);
594 /* We can scroll screen down */
596 for (cnt = rows - logo_lines; cnt > 0; cnt--) {
597 scr_memcpyw(r + step, r, vc->vc_size_row);
602 if (vc->vc_y + logo_lines >= rows)
603 lines = rows - vc->vc_y - 1;
607 vc->vc_pos += lines * vc->vc_size_row;
610 scr_memsetw((unsigned short *) vc->vc_origin,
612 vc->vc_size_row * logo_lines);
614 if (con_is_visible(vc) && vc->vc_mode == KD_TEXT) {
615 fbcon_clear_margins(vc, 0);
620 q = (unsigned short *) (vc->vc_origin +
623 scr_memcpyw(q, save, logo_lines * new_cols * 2);
624 vc->vc_y += logo_lines;
625 vc->vc_pos += logo_lines * vc->vc_size_row;
629 if (logo_lines > vc->vc_bottom) {
630 logo_shown = FBCON_LOGO_CANSHOW;
632 "fbcon_init: disable boot-logo (boot-logo bigger than screen).\n");
633 } else if (logo_shown != FBCON_LOGO_DONTSHOW) {
634 logo_shown = FBCON_LOGO_DRAW;
635 vc->vc_top = logo_lines;
640 #ifdef CONFIG_FB_TILEBLITTING
641 static void set_blitting_type(struct vc_data *vc, struct fb_info *info)
643 struct fbcon_ops *ops = info->fbcon_par;
645 ops->p = &fb_display[vc->vc_num];
647 if ((info->flags & FBINFO_MISC_TILEBLITTING))
648 fbcon_set_tileops(vc, info);
650 fbcon_set_rotation(info);
651 fbcon_set_bitops(ops);
655 static int fbcon_invalid_charcount(struct fb_info *info, unsigned charcount)
659 if (info->flags & FBINFO_MISC_TILEBLITTING &&
660 info->tileops->fb_get_tilemax(info) < charcount)
666 static void set_blitting_type(struct vc_data *vc, struct fb_info *info)
668 struct fbcon_ops *ops = info->fbcon_par;
670 info->flags &= ~FBINFO_MISC_TILEBLITTING;
671 ops->p = &fb_display[vc->vc_num];
672 fbcon_set_rotation(info);
673 fbcon_set_bitops(ops);
676 static int fbcon_invalid_charcount(struct fb_info *info, unsigned charcount)
681 #endif /* CONFIG_MISC_TILEBLITTING */
684 static int con2fb_acquire_newinfo(struct vc_data *vc, struct fb_info *info,
685 int unit, int oldidx)
687 struct fbcon_ops *ops = NULL;
690 if (!try_module_get(info->fbops->owner))
693 if (!err && info->fbops->fb_open &&
694 info->fbops->fb_open(info, 0))
698 ops = kzalloc(sizeof(struct fbcon_ops), GFP_KERNEL);
704 ops->cur_blink_jiffies = HZ / 5;
706 info->fbcon_par = ops;
709 set_blitting_type(vc, info);
713 con2fb_map[unit] = oldidx;
714 module_put(info->fbops->owner);
720 static int con2fb_release_oldinfo(struct vc_data *vc, struct fb_info *oldinfo,
721 struct fb_info *newinfo, int unit,
722 int oldidx, int found)
724 struct fbcon_ops *ops = oldinfo->fbcon_par;
727 if (oldinfo->fbops->fb_release &&
728 oldinfo->fbops->fb_release(oldinfo, 0)) {
729 con2fb_map[unit] = oldidx;
730 if (!found && newinfo->fbops->fb_release)
731 newinfo->fbops->fb_release(newinfo, 0);
733 module_put(newinfo->fbops->owner);
738 fbcon_del_cursor_timer(oldinfo);
739 kfree(ops->cursor_state.mask);
740 kfree(ops->cursor_data);
741 kfree(ops->cursor_src);
742 kfree(ops->fontbuffer);
743 kfree(oldinfo->fbcon_par);
744 oldinfo->fbcon_par = NULL;
745 module_put(oldinfo->fbops->owner);
747 If oldinfo and newinfo are driving the same hardware,
748 the fb_release() method of oldinfo may attempt to
749 restore the hardware state. This will leave the
750 newinfo in an undefined state. Thus, a call to
751 fb_set_par() may be needed for the newinfo.
753 if (newinfo && newinfo->fbops->fb_set_par) {
754 ret = newinfo->fbops->fb_set_par(newinfo);
757 printk(KERN_ERR "con2fb_release_oldinfo: "
758 "detected unhandled fb_set_par error, "
759 "error code %d\n", ret);
766 static void con2fb_init_display(struct vc_data *vc, struct fb_info *info,
767 int unit, int show_logo)
769 struct fbcon_ops *ops = info->fbcon_par;
772 ops->currcon = fg_console;
774 if (info->fbops->fb_set_par && !(ops->flags & FBCON_FLAGS_INIT)) {
775 ret = info->fbops->fb_set_par(info);
778 printk(KERN_ERR "con2fb_init_display: detected "
779 "unhandled fb_set_par error, "
780 "error code %d\n", ret);
783 ops->flags |= FBCON_FLAGS_INIT;
785 fbcon_set_disp(info, &info->var, unit);
788 struct vc_data *fg_vc = vc_cons[fg_console].d;
789 struct fb_info *fg_info =
790 registered_fb[con2fb_map[fg_console]];
792 fbcon_prepare_logo(fg_vc, fg_info, fg_vc->vc_cols,
793 fg_vc->vc_rows, fg_vc->vc_cols,
797 update_screen(vc_cons[fg_console].d);
801 * set_con2fb_map - map console to frame buffer device
802 * @unit: virtual console number to map
803 * @newidx: frame buffer index to map virtual console to
804 * @user: user request
806 * Maps a virtual console @unit to a frame buffer device
809 * This should be called with the console lock held.
811 static int set_con2fb_map(int unit, int newidx, int user)
813 struct vc_data *vc = vc_cons[unit].d;
814 int oldidx = con2fb_map[unit];
815 struct fb_info *info = registered_fb[newidx];
816 struct fb_info *oldinfo = NULL;
819 WARN_CONSOLE_UNLOCKED();
821 if (oldidx == newidx)
827 if (!search_for_mapped_con() || !con_is_bound(&fb_con)) {
829 return do_fbcon_takeover(0);
833 oldinfo = registered_fb[oldidx];
835 found = search_fb_in_map(newidx);
837 con2fb_map[unit] = newidx;
839 err = con2fb_acquire_newinfo(vc, info, unit, oldidx);
843 * If old fb is not mapped to any of the consoles,
844 * fbcon should release it.
846 if (!err && oldinfo && !search_fb_in_map(oldidx))
847 err = con2fb_release_oldinfo(vc, oldinfo, info, unit, oldidx,
851 int show_logo = (fg_console == 0 && !user &&
852 logo_shown != FBCON_LOGO_DONTSHOW);
855 fbcon_add_cursor_timer(info);
856 con2fb_map_boot[unit] = newidx;
857 con2fb_init_display(vc, info, unit, show_logo);
860 if (!search_fb_in_map(info_idx))
867 * Low Level Operations
869 /* NOTE: fbcon cannot be __init: it may be called from do_take_over_console later */
870 static int var_to_display(struct display *disp,
871 struct fb_var_screeninfo *var,
872 struct fb_info *info)
874 disp->xres_virtual = var->xres_virtual;
875 disp->yres_virtual = var->yres_virtual;
876 disp->bits_per_pixel = var->bits_per_pixel;
877 disp->grayscale = var->grayscale;
878 disp->nonstd = var->nonstd;
879 disp->accel_flags = var->accel_flags;
880 disp->height = var->height;
881 disp->width = var->width;
882 disp->red = var->red;
883 disp->green = var->green;
884 disp->blue = var->blue;
885 disp->transp = var->transp;
886 disp->rotate = var->rotate;
887 disp->mode = fb_match_mode(var, &info->modelist);
888 if (disp->mode == NULL)
889 /* This should not happen */
894 static void display_to_var(struct fb_var_screeninfo *var,
895 struct display *disp)
897 fb_videomode_to_var(var, disp->mode);
898 var->xres_virtual = disp->xres_virtual;
899 var->yres_virtual = disp->yres_virtual;
900 var->bits_per_pixel = disp->bits_per_pixel;
901 var->grayscale = disp->grayscale;
902 var->nonstd = disp->nonstd;
903 var->accel_flags = disp->accel_flags;
904 var->height = disp->height;
905 var->width = disp->width;
906 var->red = disp->red;
907 var->green = disp->green;
908 var->blue = disp->blue;
909 var->transp = disp->transp;
910 var->rotate = disp->rotate;
913 static const char *fbcon_startup(void)
915 const char *display_desc = "frame buffer device";
916 struct display *p = &fb_display[fg_console];
917 struct vc_data *vc = vc_cons[fg_console].d;
918 const struct font_desc *font = NULL;
919 struct module *owner;
920 struct fb_info *info = NULL;
921 struct fbcon_ops *ops;
925 * If num_registered_fb is zero, this is a call for the dummy part.
926 * The frame buffer devices weren't initialized yet.
928 if (!num_registered_fb || info_idx == -1)
931 * Instead of blindly using registered_fb[0], we use info_idx, set by
934 info = registered_fb[info_idx];
938 owner = info->fbops->owner;
939 if (!try_module_get(owner))
941 if (info->fbops->fb_open && info->fbops->fb_open(info, 0)) {
946 ops = kzalloc(sizeof(struct fbcon_ops), GFP_KERNEL);
954 ops->cur_rotate = -1;
955 ops->cur_blink_jiffies = HZ / 5;
957 info->fbcon_par = ops;
959 p->con_rotate = initial_rotation;
960 if (p->con_rotate == -1)
961 p->con_rotate = info->fbcon_rotate_hint;
962 if (p->con_rotate == -1)
963 p->con_rotate = FB_ROTATE_UR;
965 set_blitting_type(vc, info);
967 /* Setup default font */
968 if (!p->fontdata && !vc->vc_font.data) {
969 if (!fontname[0] || !(font = find_font(fontname)))
970 font = get_default_font(info->var.xres,
973 info->pixmap.blit_y);
974 vc->vc_font.width = font->width;
975 vc->vc_font.height = font->height;
976 vc->vc_font.data = (void *)(p->fontdata = font->data);
977 vc->vc_font.charcount = 256; /* FIXME Need to support more fonts */
979 p->fontdata = vc->vc_font.data;
982 cols = FBCON_SWAP(ops->rotate, info->var.xres, info->var.yres);
983 rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
984 cols /= vc->vc_font.width;
985 rows /= vc->vc_font.height;
986 vc_resize(vc, cols, rows);
988 DPRINTK("mode: %s\n", info->fix.id);
989 DPRINTK("visual: %d\n", info->fix.visual);
990 DPRINTK("res: %dx%d-%d\n", info->var.xres,
992 info->var.bits_per_pixel);
994 fbcon_add_cursor_timer(info);
995 fbcon_has_exited = 0;
999 static void fbcon_init(struct vc_data *vc, int init)
1001 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
1002 struct fbcon_ops *ops;
1003 struct vc_data **default_mode = vc->vc_display_fg;
1004 struct vc_data *svc = *default_mode;
1005 struct display *t, *p = &fb_display[vc->vc_num];
1006 int logo = 1, new_rows, new_cols, rows, cols, charcnt = 256;
1009 if (info_idx == -1 || info == NULL)
1014 if (vc != svc || logo_shown == FBCON_LOGO_DONTSHOW ||
1015 (info->fix.type == FB_TYPE_TEXT))
1018 if (var_to_display(p, &info->var, info))
1021 if (!info->fbcon_par)
1022 con2fb_acquire_newinfo(vc, info, vc->vc_num, -1);
1024 /* If we are not the first console on this
1025 fb, copy the font from that console */
1026 t = &fb_display[fg_console];
1029 struct vc_data *fvc = vc_cons[fg_console].d;
1031 vc->vc_font.data = (void *)(p->fontdata =
1033 vc->vc_font.width = fvc->vc_font.width;
1034 vc->vc_font.height = fvc->vc_font.height;
1035 p->userfont = t->userfont;
1038 REFCOUNT(p->fontdata)++;
1040 const struct font_desc *font = NULL;
1042 if (!fontname[0] || !(font = find_font(fontname)))
1043 font = get_default_font(info->var.xres,
1045 info->pixmap.blit_x,
1046 info->pixmap.blit_y);
1047 vc->vc_font.width = font->width;
1048 vc->vc_font.height = font->height;
1049 vc->vc_font.data = (void *)(p->fontdata = font->data);
1050 vc->vc_font.charcount = 256; /* FIXME Need to
1051 support more fonts */
1056 charcnt = FNTCHARCNT(p->fontdata);
1058 vc->vc_panic_force_write = !!(info->flags & FBINFO_CAN_FORCE_OUTPUT);
1059 vc->vc_can_do_color = (fb_get_color_depth(&info->var, &info->fix)!=1);
1060 vc->vc_complement_mask = vc->vc_can_do_color ? 0x7700 : 0x0800;
1061 if (charcnt == 256) {
1062 vc->vc_hi_font_mask = 0;
1064 vc->vc_hi_font_mask = 0x100;
1065 if (vc->vc_can_do_color)
1066 vc->vc_complement_mask <<= 1;
1069 if (!*svc->vc_uni_pagedir_loc)
1070 con_set_default_unimap(svc);
1071 if (!*vc->vc_uni_pagedir_loc)
1072 con_copy_unimap(vc, svc);
1074 ops = info->fbcon_par;
1075 ops->cur_blink_jiffies = msecs_to_jiffies(vc->vc_cur_blink_ms);
1077 p->con_rotate = initial_rotation;
1078 if (p->con_rotate == -1)
1079 p->con_rotate = info->fbcon_rotate_hint;
1080 if (p->con_rotate == -1)
1081 p->con_rotate = FB_ROTATE_UR;
1083 set_blitting_type(vc, info);
1087 new_cols = FBCON_SWAP(ops->rotate, info->var.xres, info->var.yres);
1088 new_rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
1089 new_cols /= vc->vc_font.width;
1090 new_rows /= vc->vc_font.height;
1093 * We must always set the mode. The mode of the previous console
1094 * driver could be in the same resolution but we are using different
1095 * hardware so we have to initialize the hardware.
1097 * We need to do it in fbcon_init() to prevent screen corruption.
1099 if (con_is_visible(vc) && vc->vc_mode == KD_TEXT) {
1100 if (info->fbops->fb_set_par &&
1101 !(ops->flags & FBCON_FLAGS_INIT)) {
1102 ret = info->fbops->fb_set_par(info);
1105 printk(KERN_ERR "fbcon_init: detected "
1106 "unhandled fb_set_par error, "
1107 "error code %d\n", ret);
1110 ops->flags |= FBCON_FLAGS_INIT;
1115 if ((cap & FBINFO_HWACCEL_COPYAREA) &&
1116 !(cap & FBINFO_HWACCEL_DISABLED))
1117 p->scrollmode = SCROLL_MOVE;
1118 else /* default to something safe */
1119 p->scrollmode = SCROLL_REDRAW;
1122 * ++guenther: console.c:vc_allocate() relies on initializing
1123 * vc_{cols,rows}, but we must not set those if we are only
1124 * resizing the console.
1127 vc->vc_cols = new_cols;
1128 vc->vc_rows = new_rows;
1130 vc_resize(vc, new_cols, new_rows);
1133 fbcon_prepare_logo(vc, info, cols, rows, new_cols, new_rows);
1135 if (ops->rotate_font && ops->rotate_font(info, vc)) {
1136 ops->rotate = FB_ROTATE_UR;
1137 set_blitting_type(vc, info);
1140 ops->p = &fb_display[fg_console];
1143 static void fbcon_free_font(struct display *p, bool freefont)
1145 if (freefont && p->userfont && p->fontdata && (--REFCOUNT(p->fontdata) == 0))
1146 kfree(p->fontdata - FONT_EXTRA_WORDS * sizeof(int));
1151 static void set_vc_hi_font(struct vc_data *vc, bool set);
1153 static void fbcon_deinit(struct vc_data *vc)
1155 struct display *p = &fb_display[vc->vc_num];
1156 struct fb_info *info;
1157 struct fbcon_ops *ops;
1159 bool free_font = true;
1161 idx = con2fb_map[vc->vc_num];
1166 info = registered_fb[idx];
1171 if (info->flags & FBINFO_MISC_FIRMWARE)
1173 ops = info->fbcon_par;
1178 if (con_is_visible(vc))
1179 fbcon_del_cursor_timer(info);
1181 ops->flags &= ~FBCON_FLAGS_INIT;
1184 fbcon_free_font(p, free_font);
1186 vc->vc_font.data = NULL;
1188 if (vc->vc_hi_font_mask && vc->vc_screenbuf)
1189 set_vc_hi_font(vc, false);
1191 if (!con_is_bound(&fb_con))
1194 if (vc->vc_num == logo_shown)
1195 logo_shown = FBCON_LOGO_CANSHOW;
1200 /* ====================================================================== */
1202 /* fbcon_XXX routines - interface used by the world
1204 * This system is now divided into two levels because of complications
1205 * caused by hardware scrolling. Top level functions:
1207 * fbcon_bmove(), fbcon_clear(), fbcon_putc(), fbcon_clear_margins()
1209 * handles y values in range [0, scr_height-1] that correspond to real
1210 * screen positions. y_wrap shift means that first line of bitmap may be
1211 * anywhere on this display. These functions convert lineoffsets to
1212 * bitmap offsets and deal with the wrap-around case by splitting blits.
1214 * fbcon_bmove_physical_8() -- These functions fast implementations
1215 * fbcon_clear_physical_8() -- of original fbcon_XXX fns.
1216 * fbcon_putc_physical_8() -- (font width != 8) may be added later
1220 * At the moment fbcon_putc() cannot blit across vertical wrap boundary
1221 * Implies should only really hardware scroll in rows. Only reason for
1222 * restriction is simplicity & efficiency at the moment.
1225 static void fbcon_clear(struct vc_data *vc, int sy, int sx, int height,
1228 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
1229 struct fbcon_ops *ops = info->fbcon_par;
1231 struct display *p = &fb_display[vc->vc_num];
1234 if (fbcon_is_inactive(vc, info))
1237 if (!height || !width)
1240 if (sy < vc->vc_top && vc->vc_top == logo_lines) {
1243 * If the font dimensions are not an integral of the display
1244 * dimensions then the ops->clear below won't end up clearing
1245 * the margins. Call clear_margins here in case the logo
1246 * bitmap stretched into the margin area.
1248 fbcon_clear_margins(vc, 0);
1251 /* Split blits that cross physical y_wrap boundary */
1253 y_break = p->vrows - p->yscroll;
1254 if (sy < y_break && sy + height - 1 >= y_break) {
1255 u_int b = y_break - sy;
1256 ops->clear(vc, info, real_y(p, sy), sx, b, width);
1257 ops->clear(vc, info, real_y(p, sy + b), sx, height - b,
1260 ops->clear(vc, info, real_y(p, sy), sx, height, width);
1263 static void fbcon_putcs(struct vc_data *vc, const unsigned short *s,
1264 int count, int ypos, int xpos)
1266 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
1267 struct display *p = &fb_display[vc->vc_num];
1268 struct fbcon_ops *ops = info->fbcon_par;
1270 if (!fbcon_is_inactive(vc, info))
1271 ops->putcs(vc, info, s, count, real_y(p, ypos), xpos,
1272 get_color(vc, info, scr_readw(s), 1),
1273 get_color(vc, info, scr_readw(s), 0));
1276 static void fbcon_putc(struct vc_data *vc, int c, int ypos, int xpos)
1280 scr_writew(c, &chr);
1281 fbcon_putcs(vc, &chr, 1, ypos, xpos);
1284 static void fbcon_clear_margins(struct vc_data *vc, int bottom_only)
1286 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
1287 struct fbcon_ops *ops = info->fbcon_par;
1289 if (!fbcon_is_inactive(vc, info))
1290 ops->clear_margins(vc, info, margin_color, bottom_only);
1293 static void fbcon_cursor(struct vc_data *vc, int mode)
1295 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
1296 struct fbcon_ops *ops = info->fbcon_par;
1297 int c = scr_readw((u16 *) vc->vc_pos);
1299 ops->cur_blink_jiffies = msecs_to_jiffies(vc->vc_cur_blink_ms);
1301 if (fbcon_is_inactive(vc, info) || vc->vc_deccm != 1)
1304 if (vc->vc_cursor_type & 0x10)
1305 fbcon_del_cursor_timer(info);
1307 fbcon_add_cursor_timer(info);
1309 ops->cursor_flash = (mode == CM_ERASE) ? 0 : 1;
1314 ops->cursor(vc, info, mode, get_color(vc, info, c, 1),
1315 get_color(vc, info, c, 0));
1318 static int scrollback_phys_max = 0;
1319 static int scrollback_max = 0;
1320 static int scrollback_current = 0;
1322 static void fbcon_set_disp(struct fb_info *info, struct fb_var_screeninfo *var,
1325 struct display *p, *t;
1326 struct vc_data **default_mode, *vc;
1327 struct vc_data *svc;
1328 struct fbcon_ops *ops = info->fbcon_par;
1329 int rows, cols, charcnt = 256;
1331 p = &fb_display[unit];
1333 if (var_to_display(p, var, info))
1336 vc = vc_cons[unit].d;
1341 default_mode = vc->vc_display_fg;
1342 svc = *default_mode;
1343 t = &fb_display[svc->vc_num];
1345 if (!vc->vc_font.data) {
1346 vc->vc_font.data = (void *)(p->fontdata = t->fontdata);
1347 vc->vc_font.width = (*default_mode)->vc_font.width;
1348 vc->vc_font.height = (*default_mode)->vc_font.height;
1349 p->userfont = t->userfont;
1351 REFCOUNT(p->fontdata)++;
1354 charcnt = FNTCHARCNT(p->fontdata);
1356 var->activate = FB_ACTIVATE_NOW;
1357 info->var.activate = var->activate;
1358 var->yoffset = info->var.yoffset;
1359 var->xoffset = info->var.xoffset;
1360 fb_set_var(info, var);
1361 ops->var = info->var;
1362 vc->vc_can_do_color = (fb_get_color_depth(&info->var, &info->fix)!=1);
1363 vc->vc_complement_mask = vc->vc_can_do_color ? 0x7700 : 0x0800;
1364 if (charcnt == 256) {
1365 vc->vc_hi_font_mask = 0;
1367 vc->vc_hi_font_mask = 0x100;
1368 if (vc->vc_can_do_color)
1369 vc->vc_complement_mask <<= 1;
1372 if (!*svc->vc_uni_pagedir_loc)
1373 con_set_default_unimap(svc);
1374 if (!*vc->vc_uni_pagedir_loc)
1375 con_copy_unimap(vc, svc);
1377 cols = FBCON_SWAP(ops->rotate, info->var.xres, info->var.yres);
1378 rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
1379 cols /= vc->vc_font.width;
1380 rows /= vc->vc_font.height;
1381 vc_resize(vc, cols, rows);
1383 if (con_is_visible(vc)) {
1388 static __inline__ void ywrap_up(struct vc_data *vc, int count)
1390 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
1391 struct fbcon_ops *ops = info->fbcon_par;
1392 struct display *p = &fb_display[vc->vc_num];
1394 p->yscroll += count;
1395 if (p->yscroll >= p->vrows) /* Deal with wrap */
1396 p->yscroll -= p->vrows;
1397 ops->var.xoffset = 0;
1398 ops->var.yoffset = p->yscroll * vc->vc_font.height;
1399 ops->var.vmode |= FB_VMODE_YWRAP;
1400 ops->update_start(info);
1401 scrollback_max += count;
1402 if (scrollback_max > scrollback_phys_max)
1403 scrollback_max = scrollback_phys_max;
1404 scrollback_current = 0;
1407 static __inline__ void ywrap_down(struct vc_data *vc, int count)
1409 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
1410 struct fbcon_ops *ops = info->fbcon_par;
1411 struct display *p = &fb_display[vc->vc_num];
1413 p->yscroll -= count;
1414 if (p->yscroll < 0) /* Deal with wrap */
1415 p->yscroll += p->vrows;
1416 ops->var.xoffset = 0;
1417 ops->var.yoffset = p->yscroll * vc->vc_font.height;
1418 ops->var.vmode |= FB_VMODE_YWRAP;
1419 ops->update_start(info);
1420 scrollback_max -= count;
1421 if (scrollback_max < 0)
1423 scrollback_current = 0;
1426 static __inline__ void ypan_up(struct vc_data *vc, int count)
1428 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
1429 struct display *p = &fb_display[vc->vc_num];
1430 struct fbcon_ops *ops = info->fbcon_par;
1432 p->yscroll += count;
1433 if (p->yscroll > p->vrows - vc->vc_rows) {
1434 ops->bmove(vc, info, p->vrows - vc->vc_rows,
1435 0, 0, 0, vc->vc_rows, vc->vc_cols);
1436 p->yscroll -= p->vrows - vc->vc_rows;
1439 ops->var.xoffset = 0;
1440 ops->var.yoffset = p->yscroll * vc->vc_font.height;
1441 ops->var.vmode &= ~FB_VMODE_YWRAP;
1442 ops->update_start(info);
1443 fbcon_clear_margins(vc, 1);
1444 scrollback_max += count;
1445 if (scrollback_max > scrollback_phys_max)
1446 scrollback_max = scrollback_phys_max;
1447 scrollback_current = 0;
1450 static __inline__ void ypan_up_redraw(struct vc_data *vc, int t, int count)
1452 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
1453 struct fbcon_ops *ops = info->fbcon_par;
1454 struct display *p = &fb_display[vc->vc_num];
1456 p->yscroll += count;
1458 if (p->yscroll > p->vrows - vc->vc_rows) {
1459 p->yscroll -= p->vrows - vc->vc_rows;
1460 fbcon_redraw_move(vc, p, t + count, vc->vc_rows - count, t);
1463 ops->var.xoffset = 0;
1464 ops->var.yoffset = p->yscroll * vc->vc_font.height;
1465 ops->var.vmode &= ~FB_VMODE_YWRAP;
1466 ops->update_start(info);
1467 fbcon_clear_margins(vc, 1);
1468 scrollback_max += count;
1469 if (scrollback_max > scrollback_phys_max)
1470 scrollback_max = scrollback_phys_max;
1471 scrollback_current = 0;
1474 static __inline__ void ypan_down(struct vc_data *vc, int count)
1476 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
1477 struct display *p = &fb_display[vc->vc_num];
1478 struct fbcon_ops *ops = info->fbcon_par;
1480 p->yscroll -= count;
1481 if (p->yscroll < 0) {
1482 ops->bmove(vc, info, 0, 0, p->vrows - vc->vc_rows,
1483 0, vc->vc_rows, vc->vc_cols);
1484 p->yscroll += p->vrows - vc->vc_rows;
1487 ops->var.xoffset = 0;
1488 ops->var.yoffset = p->yscroll * vc->vc_font.height;
1489 ops->var.vmode &= ~FB_VMODE_YWRAP;
1490 ops->update_start(info);
1491 fbcon_clear_margins(vc, 1);
1492 scrollback_max -= count;
1493 if (scrollback_max < 0)
1495 scrollback_current = 0;
1498 static __inline__ void ypan_down_redraw(struct vc_data *vc, int t, int count)
1500 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
1501 struct fbcon_ops *ops = info->fbcon_par;
1502 struct display *p = &fb_display[vc->vc_num];
1504 p->yscroll -= count;
1506 if (p->yscroll < 0) {
1507 p->yscroll += p->vrows - vc->vc_rows;
1508 fbcon_redraw_move(vc, p, t, vc->vc_rows - count, t + count);
1511 ops->var.xoffset = 0;
1512 ops->var.yoffset = p->yscroll * vc->vc_font.height;
1513 ops->var.vmode &= ~FB_VMODE_YWRAP;
1514 ops->update_start(info);
1515 fbcon_clear_margins(vc, 1);
1516 scrollback_max -= count;
1517 if (scrollback_max < 0)
1519 scrollback_current = 0;
1522 static void fbcon_redraw_move(struct vc_data *vc, struct display *p,
1523 int line, int count, int dy)
1525 unsigned short *s = (unsigned short *)
1526 (vc->vc_origin + vc->vc_size_row * line);
1529 unsigned short *start = s;
1530 unsigned short *le = advance_row(s, 1);
1533 unsigned short attr = 1;
1537 if (attr != (c & 0xff00)) {
1540 fbcon_putcs(vc, start, s - start,
1546 console_conditional_schedule();
1550 fbcon_putcs(vc, start, s - start, dy, x);
1551 console_conditional_schedule();
1556 static void fbcon_redraw_blit(struct vc_data *vc, struct fb_info *info,
1557 struct display *p, int line, int count, int ycount)
1559 int offset = ycount * vc->vc_cols;
1560 unsigned short *d = (unsigned short *)
1561 (vc->vc_origin + vc->vc_size_row * line);
1562 unsigned short *s = d + offset;
1563 struct fbcon_ops *ops = info->fbcon_par;
1566 unsigned short *start = s;
1567 unsigned short *le = advance_row(s, 1);
1574 if (c == scr_readw(d)) {
1576 ops->bmove(vc, info, line + ycount, x,
1577 line, x, 1, s-start);
1587 console_conditional_schedule();
1592 ops->bmove(vc, info, line + ycount, x, line, x, 1,
1594 console_conditional_schedule();
1599 /* NOTE: We subtract two lines from these pointers */
1600 s -= vc->vc_size_row;
1601 d -= vc->vc_size_row;
1606 static void fbcon_redraw(struct vc_data *vc, struct display *p,
1607 int line, int count, int offset)
1609 unsigned short *d = (unsigned short *)
1610 (vc->vc_origin + vc->vc_size_row * line);
1611 unsigned short *s = d + offset;
1614 unsigned short *start = s;
1615 unsigned short *le = advance_row(s, 1);
1618 unsigned short attr = 1;
1622 if (attr != (c & 0xff00)) {
1625 fbcon_putcs(vc, start, s - start,
1631 if (c == scr_readw(d)) {
1633 fbcon_putcs(vc, start, s - start,
1643 console_conditional_schedule();
1648 fbcon_putcs(vc, start, s - start, line, x);
1649 console_conditional_schedule();
1654 /* NOTE: We subtract two lines from these pointers */
1655 s -= vc->vc_size_row;
1656 d -= vc->vc_size_row;
1661 static bool fbcon_scroll(struct vc_data *vc, unsigned int t, unsigned int b,
1662 enum con_scroll dir, unsigned int count)
1664 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
1665 struct display *p = &fb_display[vc->vc_num];
1666 int scroll_partial = info->flags & FBINFO_PARTIAL_PAN_OK;
1668 if (fbcon_is_inactive(vc, info))
1671 fbcon_cursor(vc, CM_ERASE);
1674 * ++Geert: Only use ywrap/ypan if the console is in text mode
1675 * ++Andrew: Only use ypan on hardware text mode when scrolling the
1676 * whole screen (prevents flicker).
1681 if (count > vc->vc_rows) /* Maximum realistic size */
1682 count = vc->vc_rows;
1683 if (logo_shown >= 0)
1685 switch (p->scrollmode) {
1687 fbcon_redraw_blit(vc, info, p, t, b - t - count,
1689 fbcon_clear(vc, b - count, 0, count, vc->vc_cols);
1690 scr_memsetw((unsigned short *) (vc->vc_origin +
1693 vc->vc_video_erase_char,
1694 vc->vc_size_row * count);
1698 case SCROLL_WRAP_MOVE:
1699 if (b - t - count > 3 * vc->vc_rows >> 2) {
1701 fbcon_bmove(vc, 0, 0, count, 0, t,
1703 ywrap_up(vc, count);
1704 if (vc->vc_rows - b > 0)
1705 fbcon_bmove(vc, b - count, 0, b, 0,
1708 } else if (info->flags & FBINFO_READS_FAST)
1709 fbcon_bmove(vc, t + count, 0, t, 0,
1710 b - t - count, vc->vc_cols);
1713 fbcon_clear(vc, b - count, 0, count, vc->vc_cols);
1716 case SCROLL_PAN_REDRAW:
1717 if ((p->yscroll + count <=
1718 2 * (p->vrows - vc->vc_rows))
1719 && ((!scroll_partial && (b - t == vc->vc_rows))
1722 3 * vc->vc_rows >> 2)))) {
1724 fbcon_redraw_move(vc, p, 0, t, count);
1725 ypan_up_redraw(vc, t, count);
1726 if (vc->vc_rows - b > 0)
1727 fbcon_redraw_move(vc, p, b,
1728 vc->vc_rows - b, b);
1730 fbcon_redraw_move(vc, p, t + count, b - t - count, t);
1731 fbcon_clear(vc, b - count, 0, count, vc->vc_cols);
1734 case SCROLL_PAN_MOVE:
1735 if ((p->yscroll + count <=
1736 2 * (p->vrows - vc->vc_rows))
1737 && ((!scroll_partial && (b - t == vc->vc_rows))
1740 3 * vc->vc_rows >> 2)))) {
1742 fbcon_bmove(vc, 0, 0, count, 0, t,
1745 if (vc->vc_rows - b > 0)
1746 fbcon_bmove(vc, b - count, 0, b, 0,
1749 } else if (info->flags & FBINFO_READS_FAST)
1750 fbcon_bmove(vc, t + count, 0, t, 0,
1751 b - t - count, vc->vc_cols);
1754 fbcon_clear(vc, b - count, 0, count, vc->vc_cols);
1759 fbcon_redraw(vc, p, t, b - t - count,
1760 count * vc->vc_cols);
1761 fbcon_clear(vc, b - count, 0, count, vc->vc_cols);
1762 scr_memsetw((unsigned short *) (vc->vc_origin +
1765 vc->vc_video_erase_char,
1766 vc->vc_size_row * count);
1772 if (count > vc->vc_rows) /* Maximum realistic size */
1773 count = vc->vc_rows;
1774 if (logo_shown >= 0)
1776 switch (p->scrollmode) {
1778 fbcon_redraw_blit(vc, info, p, b - 1, b - t - count,
1780 fbcon_clear(vc, t, 0, count, vc->vc_cols);
1781 scr_memsetw((unsigned short *) (vc->vc_origin +
1784 vc->vc_video_erase_char,
1785 vc->vc_size_row * count);
1789 case SCROLL_WRAP_MOVE:
1790 if (b - t - count > 3 * vc->vc_rows >> 2) {
1791 if (vc->vc_rows - b > 0)
1792 fbcon_bmove(vc, b, 0, b - count, 0,
1795 ywrap_down(vc, count);
1797 fbcon_bmove(vc, count, 0, 0, 0, t,
1799 } else if (info->flags & FBINFO_READS_FAST)
1800 fbcon_bmove(vc, t, 0, t + count, 0,
1801 b - t - count, vc->vc_cols);
1804 fbcon_clear(vc, t, 0, count, vc->vc_cols);
1807 case SCROLL_PAN_MOVE:
1808 if ((count - p->yscroll <= p->vrows - vc->vc_rows)
1809 && ((!scroll_partial && (b - t == vc->vc_rows))
1812 3 * vc->vc_rows >> 2)))) {
1813 if (vc->vc_rows - b > 0)
1814 fbcon_bmove(vc, b, 0, b - count, 0,
1817 ypan_down(vc, count);
1819 fbcon_bmove(vc, count, 0, 0, 0, t,
1821 } else if (info->flags & FBINFO_READS_FAST)
1822 fbcon_bmove(vc, t, 0, t + count, 0,
1823 b - t - count, vc->vc_cols);
1826 fbcon_clear(vc, t, 0, count, vc->vc_cols);
1829 case SCROLL_PAN_REDRAW:
1830 if ((count - p->yscroll <= p->vrows - vc->vc_rows)
1831 && ((!scroll_partial && (b - t == vc->vc_rows))
1834 3 * vc->vc_rows >> 2)))) {
1835 if (vc->vc_rows - b > 0)
1836 fbcon_redraw_move(vc, p, b, vc->vc_rows - b,
1838 ypan_down_redraw(vc, t, count);
1840 fbcon_redraw_move(vc, p, count, t, 0);
1842 fbcon_redraw_move(vc, p, t, b - t - count, t + count);
1843 fbcon_clear(vc, t, 0, count, vc->vc_cols);
1848 fbcon_redraw(vc, p, b - 1, b - t - count,
1849 -count * vc->vc_cols);
1850 fbcon_clear(vc, t, 0, count, vc->vc_cols);
1851 scr_memsetw((unsigned short *) (vc->vc_origin +
1854 vc->vc_video_erase_char,
1855 vc->vc_size_row * count);
1863 static void fbcon_bmove(struct vc_data *vc, int sy, int sx, int dy, int dx,
1864 int height, int width)
1866 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
1867 struct display *p = &fb_display[vc->vc_num];
1869 if (fbcon_is_inactive(vc, info))
1872 if (!width || !height)
1875 /* Split blits that cross physical y_wrap case.
1876 * Pathological case involves 4 blits, better to use recursive
1877 * code rather than unrolled case
1879 * Recursive invocations don't need to erase the cursor over and
1880 * over again, so we use fbcon_bmove_rec()
1882 fbcon_bmove_rec(vc, p, sy, sx, dy, dx, height, width,
1883 p->vrows - p->yscroll);
1886 static void fbcon_bmove_rec(struct vc_data *vc, struct display *p, int sy, int sx,
1887 int dy, int dx, int height, int width, u_int y_break)
1889 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
1890 struct fbcon_ops *ops = info->fbcon_par;
1893 if (sy < y_break && sy + height > y_break) {
1895 if (dy < sy) { /* Avoid trashing self */
1896 fbcon_bmove_rec(vc, p, sy, sx, dy, dx, b, width,
1898 fbcon_bmove_rec(vc, p, sy + b, sx, dy + b, dx,
1899 height - b, width, y_break);
1901 fbcon_bmove_rec(vc, p, sy + b, sx, dy + b, dx,
1902 height - b, width, y_break);
1903 fbcon_bmove_rec(vc, p, sy, sx, dy, dx, b, width,
1909 if (dy < y_break && dy + height > y_break) {
1911 if (dy < sy) { /* Avoid trashing self */
1912 fbcon_bmove_rec(vc, p, sy, sx, dy, dx, b, width,
1914 fbcon_bmove_rec(vc, p, sy + b, sx, dy + b, dx,
1915 height - b, width, y_break);
1917 fbcon_bmove_rec(vc, p, sy + b, sx, dy + b, dx,
1918 height - b, width, y_break);
1919 fbcon_bmove_rec(vc, p, sy, sx, dy, dx, b, width,
1924 ops->bmove(vc, info, real_y(p, sy), sx, real_y(p, dy), dx,
1928 static void updatescrollmode(struct display *p,
1929 struct fb_info *info,
1932 struct fbcon_ops *ops = info->fbcon_par;
1933 int fh = vc->vc_font.height;
1934 int cap = info->flags;
1936 int ypan = FBCON_SWAP(ops->rotate, info->fix.ypanstep,
1937 info->fix.xpanstep);
1938 int ywrap = FBCON_SWAP(ops->rotate, info->fix.ywrapstep, t);
1939 int yres = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
1940 int vyres = FBCON_SWAP(ops->rotate, info->var.yres_virtual,
1941 info->var.xres_virtual);
1942 int good_pan = (cap & FBINFO_HWACCEL_YPAN) &&
1943 divides(ypan, vc->vc_font.height) && vyres > yres;
1944 int good_wrap = (cap & FBINFO_HWACCEL_YWRAP) &&
1945 divides(ywrap, vc->vc_font.height) &&
1946 divides(vc->vc_font.height, vyres) &&
1947 divides(vc->vc_font.height, yres);
1948 int reading_fast = cap & FBINFO_READS_FAST;
1949 int fast_copyarea = (cap & FBINFO_HWACCEL_COPYAREA) &&
1950 !(cap & FBINFO_HWACCEL_DISABLED);
1951 int fast_imageblit = (cap & FBINFO_HWACCEL_IMAGEBLIT) &&
1952 !(cap & FBINFO_HWACCEL_DISABLED);
1954 p->vrows = vyres/fh;
1955 if (yres > (fh * (vc->vc_rows + 1)))
1956 p->vrows -= (yres - (fh * vc->vc_rows)) / fh;
1957 if ((yres % fh) && (vyres % fh < yres % fh))
1960 if (good_wrap || good_pan) {
1961 if (reading_fast || fast_copyarea)
1962 p->scrollmode = good_wrap ?
1963 SCROLL_WRAP_MOVE : SCROLL_PAN_MOVE;
1965 p->scrollmode = good_wrap ? SCROLL_REDRAW :
1968 if (reading_fast || (fast_copyarea && !fast_imageblit))
1969 p->scrollmode = SCROLL_MOVE;
1971 p->scrollmode = SCROLL_REDRAW;
1975 #define PITCH(w) (((w) + 7) >> 3)
1976 #define CALC_FONTSZ(h, p, c) ((h) * (p) * (c)) /* size = height * pitch * charcount */
1978 static int fbcon_resize(struct vc_data *vc, unsigned int width,
1979 unsigned int height, unsigned int user)
1981 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
1982 struct fbcon_ops *ops = info->fbcon_par;
1983 struct display *p = &fb_display[vc->vc_num];
1984 struct fb_var_screeninfo var = info->var;
1985 int x_diff, y_diff, virt_w, virt_h, virt_fw, virt_fh;
1987 if (p->userfont && FNTSIZE(vc->vc_font.data)) {
1989 int pitch = PITCH(vc->vc_font.width);
1992 * If user font, ensure that a possible change to user font
1993 * height or width will not allow a font data out-of-bounds access.
1994 * NOTE: must use original charcount in calculation as font
1995 * charcount can change and cannot be used to determine the
1996 * font data allocated size.
2000 size = CALC_FONTSZ(vc->vc_font.height, pitch, FNTCHARCNT(vc->vc_font.data));
2001 if (size > FNTSIZE(vc->vc_font.data))
2005 virt_w = FBCON_SWAP(ops->rotate, width, height);
2006 virt_h = FBCON_SWAP(ops->rotate, height, width);
2007 virt_fw = FBCON_SWAP(ops->rotate, vc->vc_font.width,
2008 vc->vc_font.height);
2009 virt_fh = FBCON_SWAP(ops->rotate, vc->vc_font.height,
2011 var.xres = virt_w * virt_fw;
2012 var.yres = virt_h * virt_fh;
2013 x_diff = info->var.xres - var.xres;
2014 y_diff = info->var.yres - var.yres;
2015 if (x_diff < 0 || x_diff > virt_fw ||
2016 y_diff < 0 || y_diff > virt_fh) {
2017 const struct fb_videomode *mode;
2019 DPRINTK("attempting resize %ix%i\n", var.xres, var.yres);
2020 mode = fb_find_best_mode(&var, &info->modelist);
2023 display_to_var(&var, p);
2024 fb_videomode_to_var(&var, mode);
2026 if (virt_w > var.xres/virt_fw || virt_h > var.yres/virt_fh)
2029 DPRINTK("resize now %ix%i\n", var.xres, var.yres);
2030 if (con_is_visible(vc) && vc->vc_mode == KD_TEXT) {
2031 var.activate = FB_ACTIVATE_NOW |
2033 fb_set_var(info, &var);
2035 var_to_display(p, &info->var, info);
2036 ops->var = info->var;
2038 updatescrollmode(p, info, vc);
2042 static int fbcon_switch(struct vc_data *vc)
2044 struct fb_info *info, *old_info = NULL;
2045 struct fbcon_ops *ops;
2046 struct display *p = &fb_display[vc->vc_num];
2047 struct fb_var_screeninfo var;
2048 int i, ret, prev_console, charcnt = 256;
2050 info = registered_fb[con2fb_map[vc->vc_num]];
2051 ops = info->fbcon_par;
2053 if (logo_shown >= 0) {
2054 struct vc_data *conp2 = vc_cons[logo_shown].d;
2056 if (conp2->vc_top == logo_lines
2057 && conp2->vc_bottom == conp2->vc_rows)
2059 logo_shown = FBCON_LOGO_CANSHOW;
2062 prev_console = ops->currcon;
2063 if (prev_console != -1)
2064 old_info = registered_fb[con2fb_map[prev_console]];
2066 * FIXME: If we have multiple fbdev's loaded, we need to
2067 * update all info->currcon. Perhaps, we can place this
2068 * in a centralized structure, but this might break some
2071 * info->currcon = vc->vc_num;
2073 for_each_registered_fb(i) {
2074 if (registered_fb[i]->fbcon_par) {
2075 struct fbcon_ops *o = registered_fb[i]->fbcon_par;
2077 o->currcon = vc->vc_num;
2080 memset(&var, 0, sizeof(struct fb_var_screeninfo));
2081 display_to_var(&var, p);
2082 var.activate = FB_ACTIVATE_NOW;
2085 * make sure we don't unnecessarily trip the memcmp()
2088 info->var.activate = var.activate;
2089 var.vmode |= info->var.vmode & ~FB_VMODE_MASK;
2090 fb_set_var(info, &var);
2091 ops->var = info->var;
2093 if (old_info != NULL && (old_info != info ||
2094 info->flags & FBINFO_MISC_ALWAYS_SETPAR)) {
2095 if (info->fbops->fb_set_par) {
2096 ret = info->fbops->fb_set_par(info);
2099 printk(KERN_ERR "fbcon_switch: detected "
2100 "unhandled fb_set_par error, "
2101 "error code %d\n", ret);
2104 if (old_info != info)
2105 fbcon_del_cursor_timer(old_info);
2108 if (fbcon_is_inactive(vc, info) ||
2109 ops->blank_state != FB_BLANK_UNBLANK)
2110 fbcon_del_cursor_timer(info);
2112 fbcon_add_cursor_timer(info);
2114 set_blitting_type(vc, info);
2115 ops->cursor_reset = 1;
2117 if (ops->rotate_font && ops->rotate_font(info, vc)) {
2118 ops->rotate = FB_ROTATE_UR;
2119 set_blitting_type(vc, info);
2122 vc->vc_can_do_color = (fb_get_color_depth(&info->var, &info->fix)!=1);
2123 vc->vc_complement_mask = vc->vc_can_do_color ? 0x7700 : 0x0800;
2126 charcnt = FNTCHARCNT(vc->vc_font.data);
2129 vc->vc_complement_mask <<= 1;
2131 updatescrollmode(p, info, vc);
2133 switch (p->scrollmode) {
2134 case SCROLL_WRAP_MOVE:
2135 scrollback_phys_max = p->vrows - vc->vc_rows;
2137 case SCROLL_PAN_MOVE:
2138 case SCROLL_PAN_REDRAW:
2139 scrollback_phys_max = p->vrows - 2 * vc->vc_rows;
2140 if (scrollback_phys_max < 0)
2141 scrollback_phys_max = 0;
2144 scrollback_phys_max = 0;
2149 scrollback_current = 0;
2151 if (!fbcon_is_inactive(vc, info)) {
2152 ops->var.xoffset = ops->var.yoffset = p->yscroll = 0;
2153 ops->update_start(info);
2156 fbcon_set_palette(vc, color_table);
2157 fbcon_clear_margins(vc, 0);
2159 if (logo_shown == FBCON_LOGO_DRAW) {
2161 logo_shown = fg_console;
2162 /* This is protected above by initmem_freed */
2163 fb_show_logo(info, ops->rotate);
2165 vc->vc_origin + vc->vc_size_row * vc->vc_top,
2166 vc->vc_size_row * (vc->vc_bottom -
2173 static void fbcon_generic_blank(struct vc_data *vc, struct fb_info *info,
2176 struct fb_event event;
2179 unsigned short charmask = vc->vc_hi_font_mask ?
2181 unsigned short oldc;
2183 oldc = vc->vc_video_erase_char;
2184 vc->vc_video_erase_char &= charmask;
2185 fbcon_clear(vc, 0, 0, vc->vc_rows, vc->vc_cols);
2186 vc->vc_video_erase_char = oldc;
2190 if (!lock_fb_info(info))
2193 event.data = ␣
2194 fb_notifier_call_chain(FB_EVENT_CONBLANK, &event);
2195 unlock_fb_info(info);
2198 static int fbcon_blank(struct vc_data *vc, int blank, int mode_switch)
2200 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
2201 struct fbcon_ops *ops = info->fbcon_par;
2204 struct fb_var_screeninfo var = info->var;
2209 var.activate = FB_ACTIVATE_NOW | FB_ACTIVATE_FORCE;
2210 fb_set_var(info, &var);
2212 ops->var = info->var;
2216 if (!fbcon_is_inactive(vc, info)) {
2217 if (ops->blank_state != blank) {
2218 ops->blank_state = blank;
2219 fbcon_cursor(vc, blank ? CM_ERASE : CM_DRAW);
2220 ops->cursor_flash = (!blank);
2222 if (!(info->flags & FBINFO_MISC_USEREVENT))
2223 if (fb_blank(info, blank))
2224 fbcon_generic_blank(vc, info, blank);
2231 if (mode_switch || fbcon_is_inactive(vc, info) ||
2232 ops->blank_state != FB_BLANK_UNBLANK)
2233 fbcon_del_cursor_timer(info);
2235 fbcon_add_cursor_timer(info);
2240 static int fbcon_debug_enter(struct vc_data *vc)
2242 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
2243 struct fbcon_ops *ops = info->fbcon_par;
2245 ops->save_graphics = ops->graphics;
2247 if (info->fbops->fb_debug_enter)
2248 info->fbops->fb_debug_enter(info);
2249 fbcon_set_palette(vc, color_table);
2253 static int fbcon_debug_leave(struct vc_data *vc)
2255 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
2256 struct fbcon_ops *ops = info->fbcon_par;
2258 ops->graphics = ops->save_graphics;
2259 if (info->fbops->fb_debug_leave)
2260 info->fbops->fb_debug_leave(info);
2264 static int fbcon_get_font(struct vc_data *vc, struct console_font *font)
2266 u8 *fontdata = vc->vc_font.data;
2267 u8 *data = font->data;
2270 font->width = vc->vc_font.width;
2271 font->height = vc->vc_font.height;
2272 font->charcount = vc->vc_hi_font_mask ? 512 : 256;
2276 if (font->width <= 8) {
2277 j = vc->vc_font.height;
2278 if (font->charcount * j > FNTSIZE(fontdata))
2281 for (i = 0; i < font->charcount; i++) {
2282 memcpy(data, fontdata, j);
2283 memset(data + j, 0, 32 - j);
2287 } else if (font->width <= 16) {
2288 j = vc->vc_font.height * 2;
2289 if (font->charcount * j > FNTSIZE(fontdata))
2292 for (i = 0; i < font->charcount; i++) {
2293 memcpy(data, fontdata, j);
2294 memset(data + j, 0, 64 - j);
2298 } else if (font->width <= 24) {
2299 if (font->charcount * (vc->vc_font.height * sizeof(u32)) > FNTSIZE(fontdata))
2302 for (i = 0; i < font->charcount; i++) {
2303 for (j = 0; j < vc->vc_font.height; j++) {
2304 *data++ = fontdata[0];
2305 *data++ = fontdata[1];
2306 *data++ = fontdata[2];
2307 fontdata += sizeof(u32);
2309 memset(data, 0, 3 * (32 - j));
2310 data += 3 * (32 - j);
2313 j = vc->vc_font.height * 4;
2314 if (font->charcount * j > FNTSIZE(fontdata))
2317 for (i = 0; i < font->charcount; i++) {
2318 memcpy(data, fontdata, j);
2319 memset(data + j, 0, 128 - j);
2327 /* set/clear vc_hi_font_mask and update vc attrs accordingly */
2328 static void set_vc_hi_font(struct vc_data *vc, bool set)
2331 vc->vc_hi_font_mask = 0;
2332 if (vc->vc_can_do_color) {
2333 vc->vc_complement_mask >>= 1;
2334 vc->vc_s_complement_mask >>= 1;
2337 /* ++Edmund: reorder the attribute bits */
2338 if (vc->vc_can_do_color) {
2339 unsigned short *cp =
2340 (unsigned short *) vc->vc_origin;
2341 int count = vc->vc_screenbuf_size / 2;
2343 for (; count > 0; count--, cp++) {
2345 scr_writew(((c & 0xfe00) >> 1) |
2348 c = vc->vc_video_erase_char;
2349 vc->vc_video_erase_char =
2350 ((c & 0xfe00) >> 1) | (c & 0xff);
2354 vc->vc_hi_font_mask = 0x100;
2355 if (vc->vc_can_do_color) {
2356 vc->vc_complement_mask <<= 1;
2357 vc->vc_s_complement_mask <<= 1;
2360 /* ++Edmund: reorder the attribute bits */
2362 unsigned short *cp =
2363 (unsigned short *) vc->vc_origin;
2364 int count = vc->vc_screenbuf_size / 2;
2366 for (; count > 0; count--, cp++) {
2367 unsigned short newc;
2369 if (vc->vc_can_do_color)
2371 ((c & 0xff00) << 1) | (c &
2375 scr_writew(newc, cp);
2377 c = vc->vc_video_erase_char;
2378 if (vc->vc_can_do_color) {
2379 vc->vc_video_erase_char =
2380 ((c & 0xff00) << 1) | (c & 0xff);
2383 vc->vc_video_erase_char = c & ~0x100;
2388 static int fbcon_do_set_font(struct vc_data *vc, int w, int h,
2389 const u8 * data, int userfont)
2391 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
2392 struct fbcon_ops *ops = info->fbcon_par;
2393 struct display *p = &fb_display[vc->vc_num];
2396 char *old_data = NULL;
2398 resize = (w != vc->vc_font.width) || (h != vc->vc_font.height);
2400 old_data = vc->vc_font.data;
2402 cnt = FNTCHARCNT(data);
2405 vc->vc_font.data = (void *)(p->fontdata = data);
2406 if ((p->userfont = userfont))
2408 vc->vc_font.width = w;
2409 vc->vc_font.height = h;
2410 if (vc->vc_hi_font_mask && cnt == 256)
2411 set_vc_hi_font(vc, false);
2412 else if (!vc->vc_hi_font_mask && cnt == 512)
2413 set_vc_hi_font(vc, true);
2418 cols = FBCON_SWAP(ops->rotate, info->var.xres, info->var.yres);
2419 rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
2422 vc_resize(vc, cols, rows);
2423 } else if (con_is_visible(vc)
2424 && vc->vc_mode == KD_TEXT) {
2425 fbcon_clear_margins(vc, 0);
2429 if (old_data && (--REFCOUNT(old_data) == 0))
2430 kfree(old_data - FONT_EXTRA_WORDS * sizeof(int));
2434 static int fbcon_copy_font(struct vc_data *vc, int con)
2436 struct display *od = &fb_display[con];
2437 struct console_font *f = &vc->vc_font;
2439 if (od->fontdata == f->data)
2440 return 0; /* already the same font... */
2441 return fbcon_do_set_font(vc, f->width, f->height, od->fontdata, od->userfont);
2445 * User asked to set font; we are guaranteed that
2446 * a) width and height are in range 1..32
2447 * b) charcount does not exceed 512
2448 * but lets not assume that, since someone might someday want to use larger
2449 * fonts. And charcount of 512 is small for unicode support.
2451 * However, user space gives the font in 32 rows , regardless of
2452 * actual font height. So a new API is needed if support for larger fonts
2453 * is ever implemented.
2456 static int fbcon_set_font(struct vc_data *vc, struct console_font *font,
2459 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
2460 unsigned charcount = font->charcount;
2461 int w = font->width;
2462 int h = font->height;
2465 u8 *new_data, *data = font->data;
2466 int pitch = PITCH(font->width);
2468 /* Is there a reason why fbconsole couldn't handle any charcount >256?
2469 * If not this check should be changed to charcount < 256 */
2470 if (charcount != 256 && charcount != 512)
2473 /* font bigger than screen resolution ? */
2474 if (w > FBCON_SWAP(info->var.rotate, info->var.xres, info->var.yres) ||
2475 h > FBCON_SWAP(info->var.rotate, info->var.yres, info->var.xres))
2478 /* Make sure drawing engine can handle the font */
2479 if (!(info->pixmap.blit_x & (1 << (font->width - 1))) ||
2480 !(info->pixmap.blit_y & (1 << (font->height - 1))))
2483 /* Make sure driver can handle the font length */
2484 if (fbcon_invalid_charcount(info, charcount))
2487 size = CALC_FONTSZ(h, pitch, charcount);
2489 new_data = kmalloc(FONT_EXTRA_WORDS * sizeof(int) + size, GFP_USER);
2494 new_data += FONT_EXTRA_WORDS * sizeof(int);
2495 FNTSIZE(new_data) = size;
2496 FNTCHARCNT(new_data) = charcount;
2497 REFCOUNT(new_data) = 0; /* usage counter */
2498 for (i=0; i< charcount; i++) {
2499 memcpy(new_data + i*h*pitch, data + i*32*pitch, h*pitch);
2502 /* Since linux has a nice crc32 function use it for counting font
2504 csum = crc32(0, new_data, size);
2506 FNTSUM(new_data) = csum;
2507 /* Check if the same font is on some other console already */
2508 for (i = first_fb_vc; i <= last_fb_vc; i++) {
2509 struct vc_data *tmp = vc_cons[i].d;
2511 if (fb_display[i].userfont &&
2512 fb_display[i].fontdata &&
2513 FNTSUM(fb_display[i].fontdata) == csum &&
2514 FNTSIZE(fb_display[i].fontdata) == size &&
2515 tmp->vc_font.width == w &&
2516 !memcmp(fb_display[i].fontdata, new_data, size)) {
2517 kfree(new_data - FONT_EXTRA_WORDS * sizeof(int));
2518 new_data = (u8 *)fb_display[i].fontdata;
2522 return fbcon_do_set_font(vc, font->width, font->height, new_data, 1);
2525 static int fbcon_set_def_font(struct vc_data *vc, struct console_font *font, char *name)
2527 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
2528 const struct font_desc *f;
2531 f = get_default_font(info->var.xres, info->var.yres,
2532 info->pixmap.blit_x, info->pixmap.blit_y);
2533 else if (!(f = find_font(name)))
2536 font->width = f->width;
2537 font->height = f->height;
2538 return fbcon_do_set_font(vc, f->width, f->height, f->data, 0);
2541 static u16 palette_red[16];
2542 static u16 palette_green[16];
2543 static u16 palette_blue[16];
2545 static struct fb_cmap palette_cmap = {
2546 0, 16, palette_red, palette_green, palette_blue, NULL
2549 static void fbcon_set_palette(struct vc_data *vc, const unsigned char *table)
2551 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
2555 if (fbcon_is_inactive(vc, info))
2558 if (!con_is_visible(vc))
2561 depth = fb_get_color_depth(&info->var, &info->fix);
2563 for (i = j = 0; i < 16; i++) {
2565 val = vc->vc_palette[j++];
2566 palette_red[k] = (val << 8) | val;
2567 val = vc->vc_palette[j++];
2568 palette_green[k] = (val << 8) | val;
2569 val = vc->vc_palette[j++];
2570 palette_blue[k] = (val << 8) | val;
2572 palette_cmap.len = 16;
2573 palette_cmap.start = 0;
2575 * If framebuffer is capable of less than 16 colors,
2576 * use default palette of fbcon.
2579 fb_copy_cmap(fb_default_cmap(1 << depth), &palette_cmap);
2581 fb_set_cmap(&palette_cmap, info);
2584 static u16 *fbcon_screen_pos(struct vc_data *vc, int offset)
2586 return (u16 *) (vc->vc_origin + offset);
2589 static unsigned long fbcon_getxy(struct vc_data *vc, unsigned long pos,
2595 if (pos >= vc->vc_origin && pos < vc->vc_scr_end) {
2596 unsigned long offset = (pos - vc->vc_origin) / 2;
2598 x = offset % vc->vc_cols;
2599 y = offset / vc->vc_cols;
2600 ret = pos + (vc->vc_cols - x) * 2;
2602 /* Should not happen */
2604 ret = vc->vc_origin;
2613 /* As we might be inside of softback, we may work with non-contiguous buffer,
2614 that's why we have to use a separate routine. */
2615 static void fbcon_invert_region(struct vc_data *vc, u16 * p, int cnt)
2618 u16 a = scr_readw(p);
2619 if (!vc->vc_can_do_color)
2621 else if (vc->vc_hi_font_mask == 0x100)
2622 a = ((a) & 0x11ff) | (((a) & 0xe000) >> 4) |
2623 (((a) & 0x0e00) << 4);
2625 a = ((a) & 0x88ff) | (((a) & 0x7000) >> 4) |
2626 (((a) & 0x0700) << 4);
2631 static int fbcon_set_origin(struct vc_data *vc)
2636 static void fbcon_suspended(struct fb_info *info)
2638 struct vc_data *vc = NULL;
2639 struct fbcon_ops *ops = info->fbcon_par;
2641 if (!ops || ops->currcon < 0)
2643 vc = vc_cons[ops->currcon].d;
2645 /* Clear cursor, restore saved data */
2646 fbcon_cursor(vc, CM_ERASE);
2649 static void fbcon_resumed(struct fb_info *info)
2652 struct fbcon_ops *ops = info->fbcon_par;
2654 if (!ops || ops->currcon < 0)
2656 vc = vc_cons[ops->currcon].d;
2661 static void fbcon_modechanged(struct fb_info *info)
2663 struct fbcon_ops *ops = info->fbcon_par;
2668 if (!ops || ops->currcon < 0)
2670 vc = vc_cons[ops->currcon].d;
2671 if (vc->vc_mode != KD_TEXT ||
2672 registered_fb[con2fb_map[ops->currcon]] != info)
2675 p = &fb_display[vc->vc_num];
2676 set_blitting_type(vc, info);
2678 if (con_is_visible(vc)) {
2679 var_to_display(p, &info->var, info);
2680 cols = FBCON_SWAP(ops->rotate, info->var.xres, info->var.yres);
2681 rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
2682 cols /= vc->vc_font.width;
2683 rows /= vc->vc_font.height;
2684 vc_resize(vc, cols, rows);
2685 updatescrollmode(p, info, vc);
2687 scrollback_current = 0;
2689 if (!fbcon_is_inactive(vc, info)) {
2690 ops->var.xoffset = ops->var.yoffset = p->yscroll = 0;
2691 ops->update_start(info);
2694 fbcon_set_palette(vc, color_table);
2699 static void fbcon_set_all_vcs(struct fb_info *info)
2701 struct fbcon_ops *ops = info->fbcon_par;
2704 int i, rows, cols, fg = -1;
2706 if (!ops || ops->currcon < 0)
2709 for (i = first_fb_vc; i <= last_fb_vc; i++) {
2711 if (!vc || vc->vc_mode != KD_TEXT ||
2712 registered_fb[con2fb_map[i]] != info)
2715 if (con_is_visible(vc)) {
2720 p = &fb_display[vc->vc_num];
2721 set_blitting_type(vc, info);
2722 var_to_display(p, &info->var, info);
2723 cols = FBCON_SWAP(ops->rotate, info->var.xres, info->var.yres);
2724 rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
2725 cols /= vc->vc_font.width;
2726 rows /= vc->vc_font.height;
2727 vc_resize(vc, cols, rows);
2731 fbcon_modechanged(info);
2734 static int fbcon_mode_deleted(struct fb_info *info,
2735 struct fb_videomode *mode)
2737 struct fb_info *fb_info;
2739 int i, j, found = 0;
2741 /* before deletion, ensure that mode is not in use */
2742 for (i = first_fb_vc; i <= last_fb_vc; i++) {
2746 fb_info = registered_fb[j];
2747 if (fb_info != info)
2752 if (fb_mode_is_equal(p->mode, mode)) {
2760 #ifdef CONFIG_VT_HW_CONSOLE_BINDING
2761 static int fbcon_unbind(void)
2765 ret = do_unbind_con_driver(&fb_con, first_fb_vc, last_fb_vc,
2769 fbcon_has_console_bind = 0;
2774 static inline int fbcon_unbind(void)
2778 #endif /* CONFIG_VT_HW_CONSOLE_BINDING */
2780 /* called with console_lock held */
2781 static int fbcon_fb_unbind(int idx)
2783 int i, new_idx = -1, ret = 0;
2785 WARN_CONSOLE_UNLOCKED();
2787 if (!fbcon_has_console_bind)
2790 for (i = first_fb_vc; i <= last_fb_vc; i++) {
2791 if (con2fb_map[i] != idx &&
2792 con2fb_map[i] != -1) {
2793 new_idx = con2fb_map[i];
2798 if (new_idx != -1) {
2799 for (i = first_fb_vc; i <= last_fb_vc; i++) {
2800 if (con2fb_map[i] == idx)
2801 set_con2fb_map(i, new_idx, 0);
2804 struct fb_info *info = registered_fb[idx];
2806 /* This is sort of like set_con2fb_map, except it maps
2807 * the consoles to no device and then releases the
2808 * oldinfo to free memory and cancel the cursor blink
2809 * timer. I can imagine this just becoming part of
2810 * set_con2fb_map where new_idx is -1
2812 for (i = first_fb_vc; i <= last_fb_vc; i++) {
2813 if (con2fb_map[i] == idx) {
2815 if (!search_fb_in_map(idx)) {
2816 ret = con2fb_release_oldinfo(vc_cons[i].d,
2820 con2fb_map[i] = idx;
2826 ret = fbcon_unbind();
2832 /* called with console_lock held */
2833 static int fbcon_fb_unregistered(struct fb_info *info)
2837 WARN_CONSOLE_UNLOCKED();
2839 if (deferred_takeover)
2843 for (i = first_fb_vc; i <= last_fb_vc; i++) {
2844 if (con2fb_map[i] == idx)
2848 if (idx == info_idx) {
2851 for_each_registered_fb(i) {
2857 if (info_idx != -1) {
2858 for (i = first_fb_vc; i <= last_fb_vc; i++) {
2859 if (con2fb_map[i] == -1)
2860 con2fb_map[i] = info_idx;
2864 if (primary_device == idx)
2865 primary_device = -1;
2867 if (!num_registered_fb)
2868 do_unregister_con_driver(&fb_con);
2873 /* called with console_lock held */
2874 static void fbcon_remap_all(int idx)
2878 WARN_CONSOLE_UNLOCKED();
2880 if (deferred_takeover) {
2881 for (i = first_fb_vc; i <= last_fb_vc; i++)
2882 con2fb_map_boot[i] = idx;
2883 fbcon_map_override();
2887 for (i = first_fb_vc; i <= last_fb_vc; i++)
2888 set_con2fb_map(i, idx, 0);
2890 if (con_is_bound(&fb_con)) {
2891 printk(KERN_INFO "fbcon: Remapping primary device, "
2892 "fb%i, to tty %i-%i\n", idx,
2893 first_fb_vc + 1, last_fb_vc + 1);
2898 #ifdef CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY
2899 static void fbcon_select_primary(struct fb_info *info)
2901 if (!map_override && primary_device == -1 &&
2902 fb_is_primary_device(info)) {
2905 printk(KERN_INFO "fbcon: %s (fb%i) is primary device\n",
2906 info->fix.id, info->node);
2907 primary_device = info->node;
2909 for (i = first_fb_vc; i <= last_fb_vc; i++)
2910 con2fb_map_boot[i] = primary_device;
2912 if (con_is_bound(&fb_con)) {
2913 printk(KERN_INFO "fbcon: Remapping primary device, "
2914 "fb%i, to tty %i-%i\n", info->node,
2915 first_fb_vc + 1, last_fb_vc + 1);
2916 info_idx = primary_device;
2922 static inline void fbcon_select_primary(struct fb_info *info)
2926 #endif /* CONFIG_FRAMEBUFFER_DETECT_PRIMARY */
2928 /* called with console_lock held */
2929 static int fbcon_fb_registered(struct fb_info *info)
2931 int ret = 0, i, idx;
2933 WARN_CONSOLE_UNLOCKED();
2936 fbcon_select_primary(info);
2938 if (deferred_takeover) {
2939 pr_info("fbcon: Deferring console take-over\n");
2943 if (info_idx == -1) {
2944 for (i = first_fb_vc; i <= last_fb_vc; i++) {
2945 if (con2fb_map_boot[i] == idx) {
2952 ret = do_fbcon_takeover(1);
2954 for (i = first_fb_vc; i <= last_fb_vc; i++) {
2955 if (con2fb_map_boot[i] == idx)
2956 set_con2fb_map(i, idx, 0);
2963 static void fbcon_fb_blanked(struct fb_info *info, int blank)
2965 struct fbcon_ops *ops = info->fbcon_par;
2968 if (!ops || ops->currcon < 0)
2971 vc = vc_cons[ops->currcon].d;
2972 if (vc->vc_mode != KD_TEXT ||
2973 registered_fb[con2fb_map[ops->currcon]] != info)
2976 if (con_is_visible(vc)) {
2980 do_unblank_screen(0);
2982 ops->blank_state = blank;
2985 static void fbcon_new_modelist(struct fb_info *info)
2989 struct fb_var_screeninfo var;
2990 const struct fb_videomode *mode;
2992 for (i = first_fb_vc; i <= last_fb_vc; i++) {
2993 if (registered_fb[con2fb_map[i]] != info)
2995 if (!fb_display[i].mode)
2998 display_to_var(&var, &fb_display[i]);
2999 mode = fb_find_nearest_mode(fb_display[i].mode,
3001 fb_videomode_to_var(&var, mode);
3002 fbcon_set_disp(info, &var, vc->vc_num);
3006 static void fbcon_get_requirement(struct fb_info *info,
3007 struct fb_blit_caps *caps)
3015 for (i = first_fb_vc; i <= last_fb_vc; i++) {
3017 if (vc && vc->vc_mode == KD_TEXT &&
3018 info->node == con2fb_map[i]) {
3020 caps->x |= 1 << (vc->vc_font.width - 1);
3021 caps->y |= 1 << (vc->vc_font.height - 1);
3022 charcnt = (p->userfont) ?
3023 FNTCHARCNT(p->fontdata) : 256;
3024 if (caps->len < charcnt)
3025 caps->len = charcnt;
3029 vc = vc_cons[fg_console].d;
3031 if (vc && vc->vc_mode == KD_TEXT &&
3032 info->node == con2fb_map[fg_console]) {
3033 p = &fb_display[fg_console];
3034 caps->x = 1 << (vc->vc_font.width - 1);
3035 caps->y = 1 << (vc->vc_font.height - 1);
3036 caps->len = (p->userfont) ?
3037 FNTCHARCNT(p->fontdata) : 256;
3042 static int fbcon_event_notify(struct notifier_block *self,
3043 unsigned long action, void *data)
3045 struct fb_event *event = data;
3046 struct fb_info *info = event->info;
3047 struct fb_videomode *mode;
3048 struct fb_con2fbmap *con2fb;
3049 struct fb_blit_caps *caps;
3053 * ignore all events except driver registration and deregistration
3054 * if fbcon is not active
3056 if (fbcon_has_exited && !(action == FB_EVENT_FB_REGISTERED ||
3057 action == FB_EVENT_FB_UNREGISTERED))
3061 case FB_EVENT_SUSPEND:
3062 fbcon_suspended(info);
3064 case FB_EVENT_RESUME:
3065 fbcon_resumed(info);
3067 case FB_EVENT_MODE_CHANGE:
3068 fbcon_modechanged(info);
3070 case FB_EVENT_MODE_CHANGE_ALL:
3071 fbcon_set_all_vcs(info);
3073 case FB_EVENT_MODE_DELETE:
3075 ret = fbcon_mode_deleted(info, mode);
3077 case FB_EVENT_FB_UNBIND:
3079 ret = fbcon_fb_unbind(idx);
3081 case FB_EVENT_FB_REGISTERED:
3082 ret = fbcon_fb_registered(info);
3084 case FB_EVENT_FB_UNREGISTERED:
3085 ret = fbcon_fb_unregistered(info);
3087 case FB_EVENT_SET_CONSOLE_MAP:
3088 /* called with console lock held */
3089 con2fb = event->data;
3090 ret = set_con2fb_map(con2fb->console - 1,
3091 con2fb->framebuffer, 1);
3093 case FB_EVENT_GET_CONSOLE_MAP:
3094 con2fb = event->data;
3095 con2fb->framebuffer = con2fb_map[con2fb->console - 1];
3097 case FB_EVENT_BLANK:
3098 fbcon_fb_blanked(info, *(int *)event->data);
3100 case FB_EVENT_NEW_MODELIST:
3101 fbcon_new_modelist(info);
3103 case FB_EVENT_GET_REQ:
3105 fbcon_get_requirement(info, caps);
3107 case FB_EVENT_REMAP_ALL_CONSOLE:
3109 fbcon_remap_all(idx);
3117 * The console `switch' structure for the frame buffer based console
3120 static const struct consw fb_con = {
3121 .owner = THIS_MODULE,
3122 .con_startup = fbcon_startup,
3123 .con_init = fbcon_init,
3124 .con_deinit = fbcon_deinit,
3125 .con_clear = fbcon_clear,
3126 .con_putc = fbcon_putc,
3127 .con_putcs = fbcon_putcs,
3128 .con_cursor = fbcon_cursor,
3129 .con_scroll = fbcon_scroll,
3130 .con_switch = fbcon_switch,
3131 .con_blank = fbcon_blank,
3132 .con_font_set = fbcon_set_font,
3133 .con_font_get = fbcon_get_font,
3134 .con_font_default = fbcon_set_def_font,
3135 .con_font_copy = fbcon_copy_font,
3136 .con_set_palette = fbcon_set_palette,
3137 .con_set_origin = fbcon_set_origin,
3138 .con_invert_region = fbcon_invert_region,
3139 .con_screen_pos = fbcon_screen_pos,
3140 .con_getxy = fbcon_getxy,
3141 .con_resize = fbcon_resize,
3142 .con_debug_enter = fbcon_debug_enter,
3143 .con_debug_leave = fbcon_debug_leave,
3146 static struct notifier_block fbcon_event_notifier = {
3147 .notifier_call = fbcon_event_notify,
3150 static ssize_t store_rotate(struct device *device,
3151 struct device_attribute *attr, const char *buf,
3154 struct fb_info *info;
3158 if (fbcon_has_exited)
3162 idx = con2fb_map[fg_console];
3164 if (idx == -1 || registered_fb[idx] == NULL)
3167 info = registered_fb[idx];
3168 rotate = simple_strtoul(buf, last, 0);
3169 fbcon_rotate(info, rotate);
3175 static ssize_t store_rotate_all(struct device *device,
3176 struct device_attribute *attr,const char *buf,
3179 struct fb_info *info;
3183 if (fbcon_has_exited)
3187 idx = con2fb_map[fg_console];
3189 if (idx == -1 || registered_fb[idx] == NULL)
3192 info = registered_fb[idx];
3193 rotate = simple_strtoul(buf, last, 0);
3194 fbcon_rotate_all(info, rotate);
3200 static ssize_t show_rotate(struct device *device,
3201 struct device_attribute *attr,char *buf)
3203 struct fb_info *info;
3204 int rotate = 0, idx;
3206 if (fbcon_has_exited)
3210 idx = con2fb_map[fg_console];
3212 if (idx == -1 || registered_fb[idx] == NULL)
3215 info = registered_fb[idx];
3216 rotate = fbcon_get_rotate(info);
3219 return snprintf(buf, PAGE_SIZE, "%d\n", rotate);
3222 static ssize_t show_cursor_blink(struct device *device,
3223 struct device_attribute *attr, char *buf)
3225 struct fb_info *info;
3226 struct fbcon_ops *ops;
3227 int idx, blink = -1;
3229 if (fbcon_has_exited)
3233 idx = con2fb_map[fg_console];
3235 if (idx == -1 || registered_fb[idx] == NULL)
3238 info = registered_fb[idx];
3239 ops = info->fbcon_par;
3244 blink = (ops->flags & FBCON_FLAGS_CURSOR_TIMER) ? 1 : 0;
3247 return snprintf(buf, PAGE_SIZE, "%d\n", blink);
3250 static ssize_t store_cursor_blink(struct device *device,
3251 struct device_attribute *attr,
3252 const char *buf, size_t count)
3254 struct fb_info *info;
3258 if (fbcon_has_exited)
3262 idx = con2fb_map[fg_console];
3264 if (idx == -1 || registered_fb[idx] == NULL)
3267 info = registered_fb[idx];
3269 if (!info->fbcon_par)
3272 blink = simple_strtoul(buf, last, 0);
3275 fbcon_cursor_noblink = 0;
3276 fbcon_add_cursor_timer(info);
3278 fbcon_cursor_noblink = 1;
3279 fbcon_del_cursor_timer(info);
3287 static struct device_attribute device_attrs[] = {
3288 __ATTR(rotate, S_IRUGO|S_IWUSR, show_rotate, store_rotate),
3289 __ATTR(rotate_all, S_IWUSR, NULL, store_rotate_all),
3290 __ATTR(cursor_blink, S_IRUGO|S_IWUSR, show_cursor_blink,
3291 store_cursor_blink),
3294 static int fbcon_init_device(void)
3298 fbcon_has_sysfs = 1;
3300 for (i = 0; i < ARRAY_SIZE(device_attrs); i++) {
3301 error = device_create_file(fbcon_device, &device_attrs[i]);
3309 device_remove_file(fbcon_device, &device_attrs[i]);
3311 fbcon_has_sysfs = 0;
3317 #ifdef CONFIG_FRAMEBUFFER_CONSOLE_DEFERRED_TAKEOVER
3318 static void fbcon_register_existing_fbs(struct work_struct *work)
3324 deferred_takeover = false;
3325 logo_shown = FBCON_LOGO_DONTSHOW;
3327 for_each_registered_fb(i)
3328 fbcon_fb_registered(registered_fb[i]);
3333 static struct notifier_block fbcon_output_nb;
3334 static DECLARE_WORK(fbcon_deferred_takeover_work, fbcon_register_existing_fbs);
3336 static int fbcon_output_notifier(struct notifier_block *nb,
3337 unsigned long action, void *data)
3339 WARN_CONSOLE_UNLOCKED();
3341 pr_info("fbcon: Taking over console\n");
3343 dummycon_unregister_output_notifier(&fbcon_output_nb);
3345 /* We may get called in atomic context */
3346 schedule_work(&fbcon_deferred_takeover_work);
3352 static void fbcon_start(void)
3354 WARN_CONSOLE_UNLOCKED();
3356 #ifdef CONFIG_FRAMEBUFFER_CONSOLE_DEFERRED_TAKEOVER
3357 if (conswitchp != &dummy_con)
3358 deferred_takeover = false;
3360 if (deferred_takeover) {
3361 fbcon_output_nb.notifier_call = fbcon_output_notifier;
3362 dummycon_register_output_notifier(&fbcon_output_nb);
3367 if (num_registered_fb) {
3370 for_each_registered_fb(i) {
3375 do_fbcon_takeover(0);
3379 static void fbcon_exit(void)
3381 struct fb_info *info;
3384 if (fbcon_has_exited)
3387 #ifdef CONFIG_FRAMEBUFFER_CONSOLE_DEFERRED_TAKEOVER
3388 if (deferred_takeover) {
3389 dummycon_unregister_output_notifier(&fbcon_output_nb);
3390 deferred_takeover = false;
3394 for_each_registered_fb(i) {
3398 info = registered_fb[i];
3400 if (info->queue.func)
3401 pending = cancel_work_sync(&info->queue);
3402 DPRINTK("fbcon: %s pending work\n", (pending ? "canceled" :
3405 for (j = first_fb_vc; j <= last_fb_vc; j++) {
3406 if (con2fb_map[j] == i) {
3413 if (info->fbops->fb_release)
3414 info->fbops->fb_release(info, 0);
3415 module_put(info->fbops->owner);
3417 if (info->fbcon_par) {
3418 struct fbcon_ops *ops = info->fbcon_par;
3420 fbcon_del_cursor_timer(info);
3421 kfree(ops->cursor_src);
3422 kfree(ops->cursor_state.mask);
3423 kfree(info->fbcon_par);
3424 info->fbcon_par = NULL;
3427 if (info->queue.func == fb_flashcursor)
3428 info->queue.func = NULL;
3432 fbcon_has_exited = 1;
3435 void __init fb_console_init(void)
3440 fb_register_client(&fbcon_event_notifier);
3441 fbcon_device = device_create(fb_class, NULL, MKDEV(0, 0), NULL,
3444 if (IS_ERR(fbcon_device)) {
3445 printk(KERN_WARNING "Unable to create device "
3446 "for fbcon; errno = %ld\n",
3447 PTR_ERR(fbcon_device));
3448 fbcon_device = NULL;
3450 fbcon_init_device();
3452 for (i = 0; i < MAX_NR_CONSOLES; i++)
3461 static void __exit fbcon_deinit_device(void)
3465 if (fbcon_has_sysfs) {
3466 for (i = 0; i < ARRAY_SIZE(device_attrs); i++)
3467 device_remove_file(fbcon_device, &device_attrs[i]);
3469 fbcon_has_sysfs = 0;
3473 void __exit fb_console_exit(void)
3476 fb_unregister_client(&fbcon_event_notifier);
3477 fbcon_deinit_device();
3478 device_destroy(fb_class, MKDEV(0, 0));
3480 do_unregister_con_driver(&fb_con);