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 */
79 #include <asm/system.h>
80 #include <asm/uaccess.h>
82 #include <asm/atariints.h>
85 #include <asm/macints.h>
87 #if defined(__mc68000__) || defined(CONFIG_APUS)
88 #include <asm/machdep.h>
89 #include <asm/setup.h>
95 # define DPRINTK(fmt, args...) printk(KERN_DEBUG "%s: " fmt, __FUNCTION__ , ## args)
97 # define DPRINTK(fmt, args...)
101 FBCON_LOGO_CANSHOW = -1, /* the logo can be shown */
102 FBCON_LOGO_DRAW = -2, /* draw the logo to a console */
103 FBCON_LOGO_DONTSHOW = -3 /* do not show the logo */
106 static struct display fb_display[MAX_NR_CONSOLES];
108 static signed char con2fb_map[MAX_NR_CONSOLES];
109 static signed char con2fb_map_boot[MAX_NR_CONSOLES];
111 static int logo_height;
113 static int logo_lines;
114 /* logo_shown is an index to vc_cons when >= 0; otherwise follows FBCON_LOGO
116 static int logo_shown = FBCON_LOGO_CANSHOW;
117 /* Software scrollback */
118 static int fbcon_softback_size = 32768;
119 static unsigned long softback_buf, softback_curr;
120 static unsigned long softback_in;
121 static unsigned long softback_top, softback_end;
122 static int softback_lines;
123 /* console mappings */
124 static int first_fb_vc;
125 static int last_fb_vc = MAX_NR_CONSOLES - 1;
126 static int fbcon_is_default = 1;
127 static int fbcon_has_exited;
130 static char fontname[40];
132 /* current fb_info */
133 static int info_idx = -1;
135 /* console rotation */
137 static int fbcon_has_sysfs;
139 static const struct consw fb_con;
141 #define CM_SOFTBACK (8)
143 #define advance_row(p, delta) (unsigned short *)((unsigned long)(p) + (delta) * vc->vc_size_row)
145 static int fbcon_set_origin(struct vc_data *);
147 #define CURSOR_DRAW_DELAY (1)
149 /* # VBL ints between cursor state changes */
150 #define ATARI_CURSOR_BLINK_RATE (42)
151 #define MAC_CURSOR_BLINK_RATE (32)
152 #define DEFAULT_CURSOR_BLINK_RATE (20)
154 static int vbl_cursor_cnt;
155 static int fbcon_cursor_noblink;
157 #define divides(a, b) ((!(a) || (b)%(a)) ? 0 : 1)
160 * Interface used by the world
163 static const char *fbcon_startup(void);
164 static void fbcon_init(struct vc_data *vc, int init);
165 static void fbcon_deinit(struct vc_data *vc);
166 static void fbcon_clear(struct vc_data *vc, int sy, int sx, int height,
168 static void fbcon_putc(struct vc_data *vc, int c, int ypos, int xpos);
169 static void fbcon_putcs(struct vc_data *vc, const unsigned short *s,
170 int count, int ypos, int xpos);
171 static void fbcon_clear_margins(struct vc_data *vc, int bottom_only);
172 static void fbcon_cursor(struct vc_data *vc, int mode);
173 static int fbcon_scroll(struct vc_data *vc, int t, int b, int dir,
175 static void fbcon_bmove(struct vc_data *vc, int sy, int sx, int dy, int dx,
176 int height, int width);
177 static int fbcon_switch(struct vc_data *vc);
178 static int fbcon_blank(struct vc_data *vc, int blank, int mode_switch);
179 static int fbcon_set_palette(struct vc_data *vc, unsigned char *table);
180 static int fbcon_scrolldelta(struct vc_data *vc, int lines);
185 static __inline__ void ywrap_up(struct vc_data *vc, int count);
186 static __inline__ void ywrap_down(struct vc_data *vc, int count);
187 static __inline__ void ypan_up(struct vc_data *vc, int count);
188 static __inline__ void ypan_down(struct vc_data *vc, int count);
189 static void fbcon_bmove_rec(struct vc_data *vc, struct display *p, int sy, int sx,
190 int dy, int dx, int height, int width, u_int y_break);
191 static void fbcon_set_disp(struct fb_info *info, struct fb_var_screeninfo *var,
193 static void fbcon_preset_disp(struct fb_info *info, struct fb_var_screeninfo *var,
195 static void fbcon_redraw_move(struct vc_data *vc, struct display *p,
196 int line, int count, int dy);
197 static void fbcon_modechanged(struct fb_info *info);
198 static void fbcon_set_all_vcs(struct fb_info *info);
199 static void fbcon_start(void);
200 static void fbcon_exit(void);
201 static struct class_device *fbcon_class_device;
205 * On the Macintoy, there may or may not be a working VBL int. We need to probe
207 static int vbl_detected;
209 static irqreturn_t fb_vbl_detect(int irq, void *dummy)
216 #ifdef CONFIG_FRAMEBUFFER_CONSOLE_ROTATION
217 static inline void fbcon_set_rotation(struct fb_info *info)
219 struct fbcon_ops *ops = info->fbcon_par;
221 if (!(info->flags & FBINFO_MISC_TILEBLITTING) &&
222 ops->p->con_rotate < 4)
223 ops->rotate = ops->p->con_rotate;
228 static void fbcon_rotate(struct fb_info *info, u32 rotate)
230 struct fbcon_ops *ops= info->fbcon_par;
231 struct fb_info *fb_info;
233 if (!ops || ops->currcon == -1)
236 fb_info = registered_fb[con2fb_map[ops->currcon]];
238 if (info == fb_info) {
239 struct display *p = &fb_display[ops->currcon];
242 p->con_rotate = rotate;
246 fbcon_modechanged(info);
250 static void fbcon_rotate_all(struct fb_info *info, u32 rotate)
252 struct fbcon_ops *ops = info->fbcon_par;
257 if (!ops || ops->currcon < 0 || rotate > 3)
260 for (i = first_fb_vc; i <= last_fb_vc; i++) {
262 if (!vc || vc->vc_mode != KD_TEXT ||
263 registered_fb[con2fb_map[i]] != info)
266 p = &fb_display[vc->vc_num];
267 p->con_rotate = rotate;
270 fbcon_set_all_vcs(info);
273 static inline void fbcon_set_rotation(struct fb_info *info)
275 struct fbcon_ops *ops = info->fbcon_par;
277 ops->rotate = FB_ROTATE_UR;
280 static void fbcon_rotate(struct fb_info *info, u32 rotate)
285 static void fbcon_rotate_all(struct fb_info *info, u32 rotate)
289 #endif /* CONFIG_FRAMEBUFFER_CONSOLE_ROTATION */
291 static int fbcon_get_rotate(struct fb_info *info)
293 struct fbcon_ops *ops = info->fbcon_par;
295 return (ops) ? ops->rotate : 0;
298 static inline int fbcon_is_inactive(struct vc_data *vc, struct fb_info *info)
300 struct fbcon_ops *ops = info->fbcon_par;
302 return (info->state != FBINFO_STATE_RUNNING ||
303 vc->vc_mode != KD_TEXT || ops->graphics);
306 static inline int get_color(struct vc_data *vc, struct fb_info *info,
309 int depth = fb_get_color_depth(&info->var, &info->fix);
312 if (console_blanked) {
313 unsigned short charmask = vc->vc_hi_font_mask ? 0x1ff : 0xff;
315 c = vc->vc_video_erase_char & charmask;
319 color = (is_fg) ? attr_fgcol((vc->vc_hi_font_mask) ? 9 : 8, c)
320 : attr_bgcol((vc->vc_hi_font_mask) ? 13 : 12, c);
325 int col = ~(0xfff << (max(info->var.green.length,
326 max(info->var.red.length,
327 info->var.blue.length)))) & 0xff;
330 int fg = (info->fix.visual != FB_VISUAL_MONO01) ? col : 0;
331 int bg = (info->fix.visual != FB_VISUAL_MONO01) ? 0 : col;
336 color = (is_fg) ? fg : bg;
341 * Scale down 16-colors to 4 colors. Default 4-color palette
342 * is grayscale. However, simply dividing the values by 4
343 * will not work, as colors 1, 2 and 3 will be scaled-down
344 * to zero rendering them invisible. So empirically convert
345 * colors to a sane 4-level grayscale.
349 color = 0; /* black */
352 color = 2; /* white */
355 color = 1; /* gray */
358 color = 3; /* intense white */
364 * Last 8 entries of default 16-color palette is a more intense
365 * version of the first 8 (i.e., same chrominance, different
376 static void fbcon_update_softback(struct vc_data *vc)
378 int l = fbcon_softback_size / vc->vc_size_row;
381 softback_end = softback_buf + l * vc->vc_size_row;
383 /* Smaller scrollback makes no sense, and 0 would screw
384 the operation totally */
388 static void fb_flashcursor(struct work_struct *work)
390 struct fb_info *info = container_of(work, struct fb_info, queue);
391 struct fbcon_ops *ops = info->fbcon_par;
393 struct vc_data *vc = NULL;
397 acquire_console_sem();
398 if (ops && ops->currcon != -1)
399 vc = vc_cons[ops->currcon].d;
401 if (!vc || !CON_IS_VISIBLE(vc) ||
402 registered_fb[con2fb_map[vc->vc_num]] != info ||
404 release_console_sem();
408 p = &fb_display[vc->vc_num];
409 c = scr_readw((u16 *) vc->vc_pos);
410 mode = (!ops->cursor_flash || ops->cursor_state.enable) ?
412 ops->cursor(vc, info, mode, softback_lines, get_color(vc, info, c, 1),
413 get_color(vc, info, c, 0));
414 release_console_sem();
417 #if defined(CONFIG_ATARI) || defined(CONFIG_MAC)
418 static int cursor_blink_rate;
419 static irqreturn_t fb_vbl_handler(int irq, void *dev_id)
421 struct fb_info *info = dev_id;
423 if (vbl_cursor_cnt && --vbl_cursor_cnt == 0) {
424 schedule_work(&info->queue);
425 vbl_cursor_cnt = cursor_blink_rate;
431 static void cursor_timer_handler(unsigned long dev_addr)
433 struct fb_info *info = (struct fb_info *) dev_addr;
434 struct fbcon_ops *ops = info->fbcon_par;
436 schedule_work(&info->queue);
437 mod_timer(&ops->cursor_timer, jiffies + HZ/5);
440 static void fbcon_add_cursor_timer(struct fb_info *info)
442 struct fbcon_ops *ops = info->fbcon_par;
444 if ((!info->queue.func || info->queue.func == fb_flashcursor) &&
445 !(ops->flags & FBCON_FLAGS_CURSOR_TIMER) &&
446 !fbcon_cursor_noblink) {
447 if (!info->queue.func)
448 INIT_WORK(&info->queue, fb_flashcursor);
450 init_timer(&ops->cursor_timer);
451 ops->cursor_timer.function = cursor_timer_handler;
452 ops->cursor_timer.expires = jiffies + HZ / 5;
453 ops->cursor_timer.data = (unsigned long ) info;
454 add_timer(&ops->cursor_timer);
455 ops->flags |= FBCON_FLAGS_CURSOR_TIMER;
459 static void fbcon_del_cursor_timer(struct fb_info *info)
461 struct fbcon_ops *ops = info->fbcon_par;
463 if (info->queue.func == fb_flashcursor &&
464 ops->flags & FBCON_FLAGS_CURSOR_TIMER) {
465 del_timer_sync(&ops->cursor_timer);
466 ops->flags &= ~FBCON_FLAGS_CURSOR_TIMER;
471 static int __init fb_console_setup(char *this_opt)
476 if (!this_opt || !*this_opt)
479 while ((options = strsep(&this_opt, ",")) != NULL) {
480 if (!strncmp(options, "font:", 5))
481 strcpy(fontname, options + 5);
483 if (!strncmp(options, "scrollback:", 11)) {
486 fbcon_softback_size = simple_strtoul(options, &options, 0);
487 if (*options == 'k' || *options == 'K') {
488 fbcon_softback_size *= 1024;
498 if (!strncmp(options, "map:", 4)) {
501 for (i = 0, j = 0; i < MAX_NR_CONSOLES; i++) {
505 (options[j++]-'0') % FB_MAX;
510 if (!strncmp(options, "vc:", 3)) {
513 first_fb_vc = simple_strtoul(options, &options, 10) - 1;
516 if (*options++ == '-')
517 last_fb_vc = simple_strtoul(options, &options, 10) - 1;
518 fbcon_is_default = 0;
521 if (!strncmp(options, "rotate:", 7)) {
524 rotate = simple_strtoul(options, &options, 0);
532 __setup("fbcon=", fb_console_setup);
535 static int search_fb_in_map(int idx)
539 for (i = first_fb_vc; i <= last_fb_vc; i++) {
540 if (con2fb_map[i] == idx)
546 static int search_for_mapped_con(void)
550 for (i = first_fb_vc; i <= last_fb_vc; i++) {
551 if (con2fb_map[i] != -1)
557 static int fbcon_takeover(int show_logo)
561 if (!num_registered_fb)
565 logo_shown = FBCON_LOGO_DONTSHOW;
567 for (i = first_fb_vc; i <= last_fb_vc; i++)
568 con2fb_map[i] = info_idx;
570 err = take_over_console(&fb_con, first_fb_vc, last_fb_vc,
574 for (i = first_fb_vc; i <= last_fb_vc; i++) {
584 static void fbcon_prepare_logo(struct vc_data *vc, struct fb_info *info,
585 int cols, int rows, int new_cols, int new_rows)
587 logo_shown = FBCON_LOGO_DONTSHOW;
590 static void fbcon_prepare_logo(struct vc_data *vc, struct fb_info *info,
591 int cols, int rows, int new_cols, int new_rows)
593 /* Need to make room for the logo */
594 struct fbcon_ops *ops = info->fbcon_par;
595 int cnt, erase = vc->vc_video_erase_char, step;
596 unsigned short *save = NULL, *r, *q;
598 if (info->flags & FBINFO_MODULE) {
599 logo_shown = FBCON_LOGO_DONTSHOW;
604 * remove underline attribute from erase character
605 * if black and white framebuffer.
607 if (fb_get_color_depth(&info->var, &info->fix) == 1)
609 logo_height = fb_prepare_logo(info, ops->rotate);
610 logo_lines = (logo_height + vc->vc_font.height - 1) /
612 q = (unsigned short *) (vc->vc_origin +
613 vc->vc_size_row * rows);
614 step = logo_lines * cols;
615 for (r = q - logo_lines * cols; r < q; r++)
616 if (scr_readw(r) != vc->vc_video_erase_char)
618 if (r != q && new_rows >= rows + logo_lines) {
619 save = kmalloc(logo_lines * new_cols * 2, GFP_KERNEL);
621 int i = cols < new_cols ? cols : new_cols;
622 scr_memsetw(save, erase, logo_lines * new_cols * 2);
624 for (cnt = 0; cnt < logo_lines; cnt++, r += i)
625 scr_memcpyw(save + cnt * new_cols, r, 2 * i);
630 /* We can scroll screen down */
632 for (cnt = rows - logo_lines; cnt > 0; cnt--) {
633 scr_memcpyw(r + step, r, vc->vc_size_row);
638 if (vc->vc_y + logo_lines >= rows)
639 lines = rows - vc->vc_y - 1;
643 vc->vc_pos += lines * vc->vc_size_row;
646 scr_memsetw((unsigned short *) vc->vc_origin,
648 vc->vc_size_row * logo_lines);
650 if (CON_IS_VISIBLE(vc) && vc->vc_mode == KD_TEXT) {
651 fbcon_clear_margins(vc, 0);
656 q = (unsigned short *) (vc->vc_origin +
659 scr_memcpyw(q, save, logo_lines * new_cols * 2);
660 vc->vc_y += logo_lines;
661 vc->vc_pos += logo_lines * vc->vc_size_row;
665 if (logo_lines > vc->vc_bottom) {
666 logo_shown = FBCON_LOGO_CANSHOW;
668 "fbcon_init: disable boot-logo (boot-logo bigger than screen).\n");
669 } else if (logo_shown != FBCON_LOGO_DONTSHOW) {
670 logo_shown = FBCON_LOGO_DRAW;
671 vc->vc_top = logo_lines;
676 #ifdef CONFIG_FB_TILEBLITTING
677 static void set_blitting_type(struct vc_data *vc, struct fb_info *info)
679 struct fbcon_ops *ops = info->fbcon_par;
681 ops->p = &fb_display[vc->vc_num];
683 if ((info->flags & FBINFO_MISC_TILEBLITTING))
684 fbcon_set_tileops(vc, info);
686 fbcon_set_rotation(info);
687 fbcon_set_bitops(ops);
691 static int fbcon_invalid_charcount(struct fb_info *info, unsigned charcount)
695 if (info->flags & FBINFO_MISC_TILEBLITTING &&
696 info->tileops->fb_get_tilemax(info) < charcount)
702 static void set_blitting_type(struct vc_data *vc, struct fb_info *info)
704 struct fbcon_ops *ops = info->fbcon_par;
706 info->flags &= ~FBINFO_MISC_TILEBLITTING;
707 ops->p = &fb_display[vc->vc_num];
708 fbcon_set_rotation(info);
709 fbcon_set_bitops(ops);
712 static int fbcon_invalid_charcount(struct fb_info *info, unsigned charcount)
717 #endif /* CONFIG_MISC_TILEBLITTING */
720 static int con2fb_acquire_newinfo(struct vc_data *vc, struct fb_info *info,
721 int unit, int oldidx)
723 struct fbcon_ops *ops = NULL;
726 if (!try_module_get(info->fbops->owner))
729 if (!err && info->fbops->fb_open &&
730 info->fbops->fb_open(info, 0))
734 ops = kzalloc(sizeof(struct fbcon_ops), GFP_KERNEL);
740 info->fbcon_par = ops;
741 set_blitting_type(vc, info);
745 con2fb_map[unit] = oldidx;
746 module_put(info->fbops->owner);
752 static int con2fb_release_oldinfo(struct vc_data *vc, struct fb_info *oldinfo,
753 struct fb_info *newinfo, int unit,
754 int oldidx, int found)
756 struct fbcon_ops *ops = oldinfo->fbcon_par;
759 if (oldinfo->fbops->fb_release &&
760 oldinfo->fbops->fb_release(oldinfo, 0)) {
761 con2fb_map[unit] = oldidx;
762 if (!found && newinfo->fbops->fb_release)
763 newinfo->fbops->fb_release(newinfo, 0);
765 module_put(newinfo->fbops->owner);
770 fbcon_del_cursor_timer(oldinfo);
771 kfree(ops->cursor_state.mask);
772 kfree(ops->cursor_data);
773 kfree(ops->fontbuffer);
774 kfree(oldinfo->fbcon_par);
775 oldinfo->fbcon_par = NULL;
776 module_put(oldinfo->fbops->owner);
778 If oldinfo and newinfo are driving the same hardware,
779 the fb_release() method of oldinfo may attempt to
780 restore the hardware state. This will leave the
781 newinfo in an undefined state. Thus, a call to
782 fb_set_par() may be needed for the newinfo.
784 if (newinfo->fbops->fb_set_par)
785 newinfo->fbops->fb_set_par(newinfo);
791 static void con2fb_init_display(struct vc_data *vc, struct fb_info *info,
792 int unit, int show_logo)
794 struct fbcon_ops *ops = info->fbcon_par;
796 ops->currcon = fg_console;
798 if (info->fbops->fb_set_par && !(ops->flags & FBCON_FLAGS_INIT))
799 info->fbops->fb_set_par(info);
801 ops->flags |= FBCON_FLAGS_INIT;
805 fbcon_set_disp(info, &info->var, vc);
807 fbcon_preset_disp(info, &info->var, unit);
810 struct vc_data *fg_vc = vc_cons[fg_console].d;
811 struct fb_info *fg_info =
812 registered_fb[con2fb_map[fg_console]];
814 fbcon_prepare_logo(fg_vc, fg_info, fg_vc->vc_cols,
815 fg_vc->vc_rows, fg_vc->vc_cols,
819 update_screen(vc_cons[fg_console].d);
823 * set_con2fb_map - map console to frame buffer device
824 * @unit: virtual console number to map
825 * @newidx: frame buffer index to map virtual console to
826 * @user: user request
828 * Maps a virtual console @unit to a frame buffer device
831 static int set_con2fb_map(int unit, int newidx, int user)
833 struct vc_data *vc = vc_cons[unit].d;
834 int oldidx = con2fb_map[unit];
835 struct fb_info *info = registered_fb[newidx];
836 struct fb_info *oldinfo = NULL;
839 if (oldidx == newidx)
842 if (!info || fbcon_has_exited)
845 if (!err && !search_for_mapped_con()) {
847 return fbcon_takeover(0);
851 oldinfo = registered_fb[oldidx];
853 found = search_fb_in_map(newidx);
855 acquire_console_sem();
856 con2fb_map[unit] = newidx;
858 err = con2fb_acquire_newinfo(vc, info, unit, oldidx);
862 * If old fb is not mapped to any of the consoles,
863 * fbcon should release it.
865 if (!err && oldinfo && !search_fb_in_map(oldidx))
866 err = con2fb_release_oldinfo(vc, oldinfo, info, unit, oldidx,
870 int show_logo = (fg_console == 0 && !user &&
871 logo_shown != FBCON_LOGO_DONTSHOW);
874 fbcon_add_cursor_timer(info);
875 con2fb_map_boot[unit] = newidx;
876 con2fb_init_display(vc, info, unit, show_logo);
879 if (!search_fb_in_map(info_idx))
882 release_console_sem();
887 * Low Level Operations
889 /* NOTE: fbcon cannot be __init: it may be called from take_over_console later */
890 static int var_to_display(struct display *disp,
891 struct fb_var_screeninfo *var,
892 struct fb_info *info)
894 disp->xres_virtual = var->xres_virtual;
895 disp->yres_virtual = var->yres_virtual;
896 disp->bits_per_pixel = var->bits_per_pixel;
897 disp->grayscale = var->grayscale;
898 disp->nonstd = var->nonstd;
899 disp->accel_flags = var->accel_flags;
900 disp->height = var->height;
901 disp->width = var->width;
902 disp->red = var->red;
903 disp->green = var->green;
904 disp->blue = var->blue;
905 disp->transp = var->transp;
906 disp->rotate = var->rotate;
907 disp->mode = fb_match_mode(var, &info->modelist);
908 if (disp->mode == NULL)
909 /* This should not happen */
914 static void display_to_var(struct fb_var_screeninfo *var,
915 struct display *disp)
917 fb_videomode_to_var(var, disp->mode);
918 var->xres_virtual = disp->xres_virtual;
919 var->yres_virtual = disp->yres_virtual;
920 var->bits_per_pixel = disp->bits_per_pixel;
921 var->grayscale = disp->grayscale;
922 var->nonstd = disp->nonstd;
923 var->accel_flags = disp->accel_flags;
924 var->height = disp->height;
925 var->width = disp->width;
926 var->red = disp->red;
927 var->green = disp->green;
928 var->blue = disp->blue;
929 var->transp = disp->transp;
930 var->rotate = disp->rotate;
933 static const char *fbcon_startup(void)
935 const char *display_desc = "frame buffer device";
936 struct display *p = &fb_display[fg_console];
937 struct vc_data *vc = vc_cons[fg_console].d;
938 const struct font_desc *font = NULL;
939 struct module *owner;
940 struct fb_info *info = NULL;
941 struct fbcon_ops *ops;
947 * If num_registered_fb is zero, this is a call for the dummy part.
948 * The frame buffer devices weren't initialized yet.
950 if (!num_registered_fb || info_idx == -1)
953 * Instead of blindly using registered_fb[0], we use info_idx, set by
956 info = registered_fb[info_idx];
960 owner = info->fbops->owner;
961 if (!try_module_get(owner))
963 if (info->fbops->fb_open && info->fbops->fb_open(info, 0)) {
968 ops = kzalloc(sizeof(struct fbcon_ops), GFP_KERNEL);
976 ops->cur_rotate = -1;
977 info->fbcon_par = ops;
978 p->con_rotate = rotate;
979 set_blitting_type(vc, info);
981 if (info->fix.type != FB_TYPE_TEXT) {
982 if (fbcon_softback_size) {
986 kmalloc(fbcon_softback_size,
989 fbcon_softback_size = 0;
995 kfree((void *) softback_buf);
1001 softback_in = softback_top = softback_curr =
1006 /* Setup default font */
1008 if (!fontname[0] || !(font = find_font(fontname)))
1009 font = get_default_font(info->var.xres,
1011 info->pixmap.blit_x,
1012 info->pixmap.blit_y);
1013 vc->vc_font.width = font->width;
1014 vc->vc_font.height = font->height;
1015 vc->vc_font.data = (void *)(p->fontdata = font->data);
1016 vc->vc_font.charcount = 256; /* FIXME Need to support more fonts */
1019 cols = FBCON_SWAP(ops->rotate, info->var.xres, info->var.yres);
1020 rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
1021 cols /= vc->vc_font.width;
1022 rows /= vc->vc_font.height;
1023 vc_resize(vc, cols, rows);
1025 DPRINTK("mode: %s\n", info->fix.id);
1026 DPRINTK("visual: %d\n", info->fix.visual);
1027 DPRINTK("res: %dx%d-%d\n", info->var.xres,
1029 info->var.bits_per_pixel);
1032 if (MACH_IS_ATARI) {
1033 cursor_blink_rate = ATARI_CURSOR_BLINK_RATE;
1035 request_irq(IRQ_AUTO_4, fb_vbl_handler,
1036 IRQ_TYPE_PRIO, "framebuffer vbl",
1039 #endif /* CONFIG_ATARI */
1043 * On a Macintoy, the VBL interrupt may or may not be active.
1044 * As interrupt based cursor is more reliable and race free, we
1045 * probe for VBL interrupts.
1050 * Probe for VBL: set temp. handler ...
1052 irqres = request_irq(IRQ_MAC_VBL, fb_vbl_detect, 0,
1053 "framebuffer vbl", info);
1057 * ... and spin for 20 ms ...
1059 while (!vbl_detected && ++ct < 1000)
1064 ("fbcon_startup: No VBL detected, using timer based cursor.\n");
1066 free_irq(IRQ_MAC_VBL, fb_vbl_detect);
1070 * interrupt based cursor ok
1072 cursor_blink_rate = MAC_CURSOR_BLINK_RATE;
1074 request_irq(IRQ_MAC_VBL, fb_vbl_handler, 0,
1075 "framebuffer vbl", info);
1078 * VBL not detected: fall through, use timer based cursor
1083 #endif /* CONFIG_MAC */
1085 fbcon_add_cursor_timer(info);
1086 fbcon_has_exited = 0;
1087 return display_desc;
1090 static void fbcon_init(struct vc_data *vc, int init)
1092 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
1093 struct fbcon_ops *ops;
1094 struct vc_data **default_mode = vc->vc_display_fg;
1095 struct vc_data *svc = *default_mode;
1096 struct display *t, *p = &fb_display[vc->vc_num];
1097 int logo = 1, new_rows, new_cols, rows, cols, charcnt = 256;
1100 if (info_idx == -1 || info == NULL)
1105 if (vc != svc || logo_shown == FBCON_LOGO_DONTSHOW ||
1106 (info->fix.type == FB_TYPE_TEXT))
1109 if (var_to_display(p, &info->var, info))
1112 /* If we are not the first console on this
1113 fb, copy the font from that console */
1114 t = &fb_display[fg_console];
1117 struct vc_data *fvc = vc_cons[fg_console].d;
1119 vc->vc_font.data = (void *)(p->fontdata =
1121 vc->vc_font.width = fvc->vc_font.width;
1122 vc->vc_font.height = fvc->vc_font.height;
1123 p->userfont = t->userfont;
1126 REFCOUNT(p->fontdata)++;
1128 const struct font_desc *font = NULL;
1130 if (!fontname[0] || !(font = find_font(fontname)))
1131 font = get_default_font(info->var.xres,
1133 info->pixmap.blit_x,
1134 info->pixmap.blit_y);
1135 vc->vc_font.width = font->width;
1136 vc->vc_font.height = font->height;
1137 vc->vc_font.data = (void *)(p->fontdata = font->data);
1138 vc->vc_font.charcount = 256; /* FIXME Need to
1139 support more fonts */
1144 charcnt = FNTCHARCNT(p->fontdata);
1146 vc->vc_can_do_color = (fb_get_color_depth(&info->var, &info->fix)!=1);
1147 vc->vc_complement_mask = vc->vc_can_do_color ? 0x7700 : 0x0800;
1148 if (charcnt == 256) {
1149 vc->vc_hi_font_mask = 0;
1151 vc->vc_hi_font_mask = 0x100;
1152 if (vc->vc_can_do_color)
1153 vc->vc_complement_mask <<= 1;
1156 if (!*svc->vc_uni_pagedir_loc)
1157 con_set_default_unimap(svc);
1158 if (!*vc->vc_uni_pagedir_loc)
1159 con_copy_unimap(vc, svc);
1161 ops = info->fbcon_par;
1162 p->con_rotate = rotate;
1163 set_blitting_type(vc, info);
1167 new_cols = FBCON_SWAP(ops->rotate, info->var.xres, info->var.yres);
1168 new_rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
1169 new_cols /= vc->vc_font.width;
1170 new_rows /= vc->vc_font.height;
1171 vc_resize(vc, new_cols, new_rows);
1174 * We must always set the mode. The mode of the previous console
1175 * driver could be in the same resolution but we are using different
1176 * hardware so we have to initialize the hardware.
1178 * We need to do it in fbcon_init() to prevent screen corruption.
1180 if (CON_IS_VISIBLE(vc) && vc->vc_mode == KD_TEXT) {
1181 if (info->fbops->fb_set_par &&
1182 !(ops->flags & FBCON_FLAGS_INIT))
1183 info->fbops->fb_set_par(info);
1184 ops->flags |= FBCON_FLAGS_INIT;
1189 if ((cap & FBINFO_HWACCEL_COPYAREA) &&
1190 !(cap & FBINFO_HWACCEL_DISABLED))
1191 p->scrollmode = SCROLL_MOVE;
1192 else /* default to something safe */
1193 p->scrollmode = SCROLL_REDRAW;
1196 * ++guenther: console.c:vc_allocate() relies on initializing
1197 * vc_{cols,rows}, but we must not set those if we are only
1198 * resizing the console.
1201 vc->vc_cols = new_cols;
1202 vc->vc_rows = new_rows;
1206 fbcon_prepare_logo(vc, info, cols, rows, new_cols, new_rows);
1208 if (vc == svc && softback_buf)
1209 fbcon_update_softback(vc);
1211 if (ops->rotate_font && ops->rotate_font(info, vc)) {
1212 ops->rotate = FB_ROTATE_UR;
1213 set_blitting_type(vc, info);
1216 ops->p = &fb_display[fg_console];
1219 static void fbcon_free_font(struct display *p)
1221 if (p->userfont && p->fontdata && (--REFCOUNT(p->fontdata) == 0))
1222 kfree(p->fontdata - FONT_EXTRA_WORDS * sizeof(int));
1227 static void fbcon_deinit(struct vc_data *vc)
1229 struct display *p = &fb_display[vc->vc_num];
1230 struct fb_info *info;
1231 struct fbcon_ops *ops;
1235 idx = con2fb_map[vc->vc_num];
1240 info = registered_fb[idx];
1245 ops = info->fbcon_par;
1250 if (CON_IS_VISIBLE(vc))
1251 fbcon_del_cursor_timer(info);
1253 ops->flags &= ~FBCON_FLAGS_INIT;
1256 if (!con_is_bound(&fb_con))
1262 /* ====================================================================== */
1264 /* fbcon_XXX routines - interface used by the world
1266 * This system is now divided into two levels because of complications
1267 * caused by hardware scrolling. Top level functions:
1269 * fbcon_bmove(), fbcon_clear(), fbcon_putc(), fbcon_clear_margins()
1271 * handles y values in range [0, scr_height-1] that correspond to real
1272 * screen positions. y_wrap shift means that first line of bitmap may be
1273 * anywhere on this display. These functions convert lineoffsets to
1274 * bitmap offsets and deal with the wrap-around case by splitting blits.
1276 * fbcon_bmove_physical_8() -- These functions fast implementations
1277 * fbcon_clear_physical_8() -- of original fbcon_XXX fns.
1278 * fbcon_putc_physical_8() -- (font width != 8) may be added later
1282 * At the moment fbcon_putc() cannot blit across vertical wrap boundary
1283 * Implies should only really hardware scroll in rows. Only reason for
1284 * restriction is simplicity & efficiency at the moment.
1287 static void fbcon_clear(struct vc_data *vc, int sy, int sx, int height,
1290 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
1291 struct fbcon_ops *ops = info->fbcon_par;
1293 struct display *p = &fb_display[vc->vc_num];
1296 if (fbcon_is_inactive(vc, info))
1299 if (!height || !width)
1302 /* Split blits that cross physical y_wrap boundary */
1304 y_break = p->vrows - p->yscroll;
1305 if (sy < y_break && sy + height - 1 >= y_break) {
1306 u_int b = y_break - sy;
1307 ops->clear(vc, info, real_y(p, sy), sx, b, width);
1308 ops->clear(vc, info, real_y(p, sy + b), sx, height - b,
1311 ops->clear(vc, info, real_y(p, sy), sx, height, width);
1314 static void fbcon_putcs(struct vc_data *vc, const unsigned short *s,
1315 int count, int ypos, int xpos)
1317 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
1318 struct display *p = &fb_display[vc->vc_num];
1319 struct fbcon_ops *ops = info->fbcon_par;
1321 if (!fbcon_is_inactive(vc, info))
1322 ops->putcs(vc, info, s, count, real_y(p, ypos), xpos,
1323 get_color(vc, info, scr_readw(s), 1),
1324 get_color(vc, info, scr_readw(s), 0));
1327 static void fbcon_putc(struct vc_data *vc, int c, int ypos, int xpos)
1331 scr_writew(c, &chr);
1332 fbcon_putcs(vc, &chr, 1, ypos, xpos);
1335 static void fbcon_clear_margins(struct vc_data *vc, int bottom_only)
1337 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
1338 struct fbcon_ops *ops = info->fbcon_par;
1340 if (!fbcon_is_inactive(vc, info))
1341 ops->clear_margins(vc, info, bottom_only);
1344 static void fbcon_cursor(struct vc_data *vc, int mode)
1346 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
1347 struct fbcon_ops *ops = info->fbcon_par;
1349 int c = scr_readw((u16 *) vc->vc_pos);
1351 if (fbcon_is_inactive(vc, info) || vc->vc_deccm != 1)
1354 if (vc->vc_cursor_type & 0x10)
1355 fbcon_del_cursor_timer(info);
1357 fbcon_add_cursor_timer(info);
1359 ops->cursor_flash = (mode == CM_ERASE) ? 0 : 1;
1360 if (mode & CM_SOFTBACK) {
1361 mode &= ~CM_SOFTBACK;
1365 fbcon_set_origin(vc);
1369 ops->cursor(vc, info, mode, y, get_color(vc, info, c, 1),
1370 get_color(vc, info, c, 0));
1371 vbl_cursor_cnt = CURSOR_DRAW_DELAY;
1374 static int scrollback_phys_max = 0;
1375 static int scrollback_max = 0;
1376 static int scrollback_current = 0;
1379 * If no vc is existent yet, just set struct display
1381 static void fbcon_preset_disp(struct fb_info *info, struct fb_var_screeninfo *var,
1384 struct display *p = &fb_display[unit];
1385 struct display *t = &fb_display[fg_console];
1387 if (var_to_display(p, var, info))
1390 p->fontdata = t->fontdata;
1391 p->userfont = t->userfont;
1393 REFCOUNT(p->fontdata)++;
1396 static void fbcon_set_disp(struct fb_info *info, struct fb_var_screeninfo *var,
1399 struct display *p = &fb_display[vc->vc_num], *t;
1400 struct vc_data **default_mode = vc->vc_display_fg;
1401 struct vc_data *svc = *default_mode;
1402 struct fbcon_ops *ops = info->fbcon_par;
1403 int rows, cols, charcnt = 256;
1405 if (var_to_display(p, var, info))
1407 t = &fb_display[svc->vc_num];
1408 if (!vc->vc_font.data) {
1409 vc->vc_font.data = (void *)(p->fontdata = t->fontdata);
1410 vc->vc_font.width = (*default_mode)->vc_font.width;
1411 vc->vc_font.height = (*default_mode)->vc_font.height;
1412 p->userfont = t->userfont;
1414 REFCOUNT(p->fontdata)++;
1417 charcnt = FNTCHARCNT(p->fontdata);
1419 var->activate = FB_ACTIVATE_NOW;
1420 info->var.activate = var->activate;
1421 var->yoffset = info->var.yoffset;
1422 var->xoffset = info->var.xoffset;
1423 fb_set_var(info, var);
1424 ops->var = info->var;
1425 vc->vc_can_do_color = (fb_get_color_depth(&info->var, &info->fix)!=1);
1426 vc->vc_complement_mask = vc->vc_can_do_color ? 0x7700 : 0x0800;
1427 if (charcnt == 256) {
1428 vc->vc_hi_font_mask = 0;
1430 vc->vc_hi_font_mask = 0x100;
1431 if (vc->vc_can_do_color)
1432 vc->vc_complement_mask <<= 1;
1435 if (!*svc->vc_uni_pagedir_loc)
1436 con_set_default_unimap(svc);
1437 if (!*vc->vc_uni_pagedir_loc)
1438 con_copy_unimap(vc, svc);
1440 cols = FBCON_SWAP(ops->rotate, info->var.xres, info->var.yres);
1441 rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
1442 cols /= vc->vc_font.width;
1443 rows /= vc->vc_font.height;
1444 vc_resize(vc, cols, rows);
1446 if (CON_IS_VISIBLE(vc)) {
1449 fbcon_update_softback(vc);
1453 static __inline__ void ywrap_up(struct vc_data *vc, int count)
1455 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
1456 struct fbcon_ops *ops = info->fbcon_par;
1457 struct display *p = &fb_display[vc->vc_num];
1459 p->yscroll += count;
1460 if (p->yscroll >= p->vrows) /* Deal with wrap */
1461 p->yscroll -= p->vrows;
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 scrollback_max += count;
1467 if (scrollback_max > scrollback_phys_max)
1468 scrollback_max = scrollback_phys_max;
1469 scrollback_current = 0;
1472 static __inline__ void ywrap_down(struct vc_data *vc, int count)
1474 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
1475 struct fbcon_ops *ops = info->fbcon_par;
1476 struct display *p = &fb_display[vc->vc_num];
1478 p->yscroll -= count;
1479 if (p->yscroll < 0) /* Deal with wrap */
1480 p->yscroll += p->vrows;
1481 ops->var.xoffset = 0;
1482 ops->var.yoffset = p->yscroll * vc->vc_font.height;
1483 ops->var.vmode |= FB_VMODE_YWRAP;
1484 ops->update_start(info);
1485 scrollback_max -= count;
1486 if (scrollback_max < 0)
1488 scrollback_current = 0;
1491 static __inline__ void ypan_up(struct vc_data *vc, int count)
1493 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
1494 struct display *p = &fb_display[vc->vc_num];
1495 struct fbcon_ops *ops = info->fbcon_par;
1497 p->yscroll += count;
1498 if (p->yscroll > p->vrows - vc->vc_rows) {
1499 ops->bmove(vc, info, p->vrows - vc->vc_rows,
1500 0, 0, 0, vc->vc_rows, vc->vc_cols);
1501 p->yscroll -= p->vrows - vc->vc_rows;
1504 ops->var.xoffset = 0;
1505 ops->var.yoffset = p->yscroll * vc->vc_font.height;
1506 ops->var.vmode &= ~FB_VMODE_YWRAP;
1507 ops->update_start(info);
1508 fbcon_clear_margins(vc, 1);
1509 scrollback_max += count;
1510 if (scrollback_max > scrollback_phys_max)
1511 scrollback_max = scrollback_phys_max;
1512 scrollback_current = 0;
1515 static __inline__ void ypan_up_redraw(struct vc_data *vc, int t, int count)
1517 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
1518 struct fbcon_ops *ops = info->fbcon_par;
1519 struct display *p = &fb_display[vc->vc_num];
1521 p->yscroll += count;
1523 if (p->yscroll > p->vrows - vc->vc_rows) {
1524 p->yscroll -= p->vrows - vc->vc_rows;
1525 fbcon_redraw_move(vc, p, t + count, vc->vc_rows - count, t);
1528 ops->var.xoffset = 0;
1529 ops->var.yoffset = p->yscroll * vc->vc_font.height;
1530 ops->var.vmode &= ~FB_VMODE_YWRAP;
1531 ops->update_start(info);
1532 fbcon_clear_margins(vc, 1);
1533 scrollback_max += count;
1534 if (scrollback_max > scrollback_phys_max)
1535 scrollback_max = scrollback_phys_max;
1536 scrollback_current = 0;
1539 static __inline__ void ypan_down(struct vc_data *vc, int count)
1541 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
1542 struct display *p = &fb_display[vc->vc_num];
1543 struct fbcon_ops *ops = info->fbcon_par;
1545 p->yscroll -= count;
1546 if (p->yscroll < 0) {
1547 ops->bmove(vc, info, 0, 0, p->vrows - vc->vc_rows,
1548 0, vc->vc_rows, vc->vc_cols);
1549 p->yscroll += p->vrows - vc->vc_rows;
1552 ops->var.xoffset = 0;
1553 ops->var.yoffset = p->yscroll * vc->vc_font.height;
1554 ops->var.vmode &= ~FB_VMODE_YWRAP;
1555 ops->update_start(info);
1556 fbcon_clear_margins(vc, 1);
1557 scrollback_max -= count;
1558 if (scrollback_max < 0)
1560 scrollback_current = 0;
1563 static __inline__ void ypan_down_redraw(struct vc_data *vc, int t, int count)
1565 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
1566 struct fbcon_ops *ops = info->fbcon_par;
1567 struct display *p = &fb_display[vc->vc_num];
1569 p->yscroll -= count;
1571 if (p->yscroll < 0) {
1572 p->yscroll += p->vrows - vc->vc_rows;
1573 fbcon_redraw_move(vc, p, t, vc->vc_rows - count, t + count);
1576 ops->var.xoffset = 0;
1577 ops->var.yoffset = p->yscroll * vc->vc_font.height;
1578 ops->var.vmode &= ~FB_VMODE_YWRAP;
1579 ops->update_start(info);
1580 fbcon_clear_margins(vc, 1);
1581 scrollback_max -= count;
1582 if (scrollback_max < 0)
1584 scrollback_current = 0;
1587 static void fbcon_redraw_softback(struct vc_data *vc, struct display *p,
1590 int count = vc->vc_rows;
1591 unsigned short *d, *s;
1595 d = (u16 *) softback_curr;
1596 if (d == (u16 *) softback_in)
1597 d = (u16 *) vc->vc_origin;
1598 n = softback_curr + delta * vc->vc_size_row;
1599 softback_lines -= delta;
1601 if (softback_curr < softback_top && n < softback_buf) {
1602 n += softback_end - softback_buf;
1603 if (n < softback_top) {
1605 (softback_top - n) / vc->vc_size_row;
1608 } else if (softback_curr >= softback_top
1609 && n < softback_top) {
1611 (softback_top - n) / vc->vc_size_row;
1615 if (softback_curr > softback_in && n >= softback_end) {
1616 n += softback_buf - softback_end;
1617 if (n > softback_in) {
1621 } else if (softback_curr <= softback_in && n > softback_in) {
1626 if (n == softback_curr)
1629 s = (u16 *) softback_curr;
1630 if (s == (u16 *) softback_in)
1631 s = (u16 *) vc->vc_origin;
1633 unsigned short *start;
1637 unsigned short attr = 1;
1640 le = advance_row(s, 1);
1643 if (attr != (c & 0xff00)) {
1646 fbcon_putcs(vc, start, s - start,
1652 if (c == scr_readw(d)) {
1654 fbcon_putcs(vc, start, s - start,
1667 fbcon_putcs(vc, start, s - start, line, x);
1669 if (d == (u16 *) softback_end)
1670 d = (u16 *) softback_buf;
1671 if (d == (u16 *) softback_in)
1672 d = (u16 *) vc->vc_origin;
1673 if (s == (u16 *) softback_end)
1674 s = (u16 *) softback_buf;
1675 if (s == (u16 *) softback_in)
1676 s = (u16 *) vc->vc_origin;
1680 static void fbcon_redraw_move(struct vc_data *vc, struct display *p,
1681 int line, int count, int dy)
1683 unsigned short *s = (unsigned short *)
1684 (vc->vc_origin + vc->vc_size_row * line);
1687 unsigned short *start = s;
1688 unsigned short *le = advance_row(s, 1);
1691 unsigned short attr = 1;
1695 if (attr != (c & 0xff00)) {
1698 fbcon_putcs(vc, start, s - start,
1704 console_conditional_schedule();
1708 fbcon_putcs(vc, start, s - start, dy, x);
1709 console_conditional_schedule();
1714 static void fbcon_redraw_blit(struct vc_data *vc, struct fb_info *info,
1715 struct display *p, int line, int count, int ycount)
1717 int offset = ycount * vc->vc_cols;
1718 unsigned short *d = (unsigned short *)
1719 (vc->vc_origin + vc->vc_size_row * line);
1720 unsigned short *s = d + offset;
1721 struct fbcon_ops *ops = info->fbcon_par;
1724 unsigned short *start = s;
1725 unsigned short *le = advance_row(s, 1);
1732 if (c == scr_readw(d)) {
1734 ops->bmove(vc, info, line + ycount, x,
1735 line, x, 1, s-start);
1745 console_conditional_schedule();
1750 ops->bmove(vc, info, line + ycount, x, line, x, 1,
1752 console_conditional_schedule();
1757 /* NOTE: We subtract two lines from these pointers */
1758 s -= vc->vc_size_row;
1759 d -= vc->vc_size_row;
1764 static void fbcon_redraw(struct vc_data *vc, struct display *p,
1765 int line, int count, int offset)
1767 unsigned short *d = (unsigned short *)
1768 (vc->vc_origin + vc->vc_size_row * line);
1769 unsigned short *s = d + offset;
1772 unsigned short *start = s;
1773 unsigned short *le = advance_row(s, 1);
1776 unsigned short attr = 1;
1780 if (attr != (c & 0xff00)) {
1783 fbcon_putcs(vc, start, s - start,
1789 if (c == scr_readw(d)) {
1791 fbcon_putcs(vc, start, s - start,
1801 console_conditional_schedule();
1806 fbcon_putcs(vc, start, s - start, line, x);
1807 console_conditional_schedule();
1812 /* NOTE: We subtract two lines from these pointers */
1813 s -= vc->vc_size_row;
1814 d -= vc->vc_size_row;
1819 static inline void fbcon_softback_note(struct vc_data *vc, int t,
1824 if (vc->vc_num != fg_console)
1826 p = (unsigned short *) (vc->vc_origin + t * vc->vc_size_row);
1829 scr_memcpyw((u16 *) softback_in, p, vc->vc_size_row);
1831 p = advance_row(p, 1);
1832 softback_in += vc->vc_size_row;
1833 if (softback_in == softback_end)
1834 softback_in = softback_buf;
1835 if (softback_in == softback_top) {
1836 softback_top += vc->vc_size_row;
1837 if (softback_top == softback_end)
1838 softback_top = softback_buf;
1841 softback_curr = softback_in;
1844 static int fbcon_scroll(struct vc_data *vc, int t, int b, int dir,
1847 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
1848 struct display *p = &fb_display[vc->vc_num];
1849 int scroll_partial = info->flags & FBINFO_PARTIAL_PAN_OK;
1851 if (fbcon_is_inactive(vc, info))
1854 fbcon_cursor(vc, CM_ERASE);
1857 * ++Geert: Only use ywrap/ypan if the console is in text mode
1858 * ++Andrew: Only use ypan on hardware text mode when scrolling the
1859 * whole screen (prevents flicker).
1864 if (count > vc->vc_rows) /* Maximum realistic size */
1865 count = vc->vc_rows;
1867 fbcon_softback_note(vc, t, count);
1868 if (logo_shown >= 0)
1870 switch (p->scrollmode) {
1872 fbcon_redraw_blit(vc, info, p, t, b - t - count,
1874 fbcon_clear(vc, b - count, 0, count, vc->vc_cols);
1875 scr_memsetw((unsigned short *) (vc->vc_origin +
1878 vc->vc_video_erase_char,
1879 vc->vc_size_row * count);
1883 case SCROLL_WRAP_MOVE:
1884 if (b - t - count > 3 * vc->vc_rows >> 2) {
1886 fbcon_bmove(vc, 0, 0, count, 0, t,
1888 ywrap_up(vc, count);
1889 if (vc->vc_rows - b > 0)
1890 fbcon_bmove(vc, b - count, 0, b, 0,
1893 } else if (info->flags & FBINFO_READS_FAST)
1894 fbcon_bmove(vc, t + count, 0, t, 0,
1895 b - t - count, vc->vc_cols);
1898 fbcon_clear(vc, b - count, 0, count, vc->vc_cols);
1901 case SCROLL_PAN_REDRAW:
1902 if ((p->yscroll + count <=
1903 2 * (p->vrows - vc->vc_rows))
1904 && ((!scroll_partial && (b - t == vc->vc_rows))
1907 3 * vc->vc_rows >> 2)))) {
1909 fbcon_redraw_move(vc, p, 0, t, count);
1910 ypan_up_redraw(vc, t, count);
1911 if (vc->vc_rows - b > 0)
1912 fbcon_redraw_move(vc, p, b,
1913 vc->vc_rows - b, b);
1915 fbcon_redraw_move(vc, p, t + count, b - t - count, t);
1916 fbcon_clear(vc, b - count, 0, count, vc->vc_cols);
1919 case SCROLL_PAN_MOVE:
1920 if ((p->yscroll + count <=
1921 2 * (p->vrows - vc->vc_rows))
1922 && ((!scroll_partial && (b - t == vc->vc_rows))
1925 3 * vc->vc_rows >> 2)))) {
1927 fbcon_bmove(vc, 0, 0, count, 0, t,
1930 if (vc->vc_rows - b > 0)
1931 fbcon_bmove(vc, b - count, 0, b, 0,
1934 } else if (info->flags & FBINFO_READS_FAST)
1935 fbcon_bmove(vc, t + count, 0, t, 0,
1936 b - t - count, vc->vc_cols);
1939 fbcon_clear(vc, b - count, 0, count, vc->vc_cols);
1944 fbcon_redraw(vc, p, t, b - t - count,
1945 count * vc->vc_cols);
1946 fbcon_clear(vc, b - count, 0, count, vc->vc_cols);
1947 scr_memsetw((unsigned short *) (vc->vc_origin +
1950 vc->vc_video_erase_char,
1951 vc->vc_size_row * count);
1957 if (count > vc->vc_rows) /* Maximum realistic size */
1958 count = vc->vc_rows;
1959 if (logo_shown >= 0)
1961 switch (p->scrollmode) {
1963 fbcon_redraw_blit(vc, info, p, b - 1, b - t - count,
1965 fbcon_clear(vc, t, 0, count, vc->vc_cols);
1966 scr_memsetw((unsigned short *) (vc->vc_origin +
1969 vc->vc_video_erase_char,
1970 vc->vc_size_row * count);
1974 case SCROLL_WRAP_MOVE:
1975 if (b - t - count > 3 * vc->vc_rows >> 2) {
1976 if (vc->vc_rows - b > 0)
1977 fbcon_bmove(vc, b, 0, b - count, 0,
1980 ywrap_down(vc, count);
1982 fbcon_bmove(vc, count, 0, 0, 0, t,
1984 } else if (info->flags & FBINFO_READS_FAST)
1985 fbcon_bmove(vc, t, 0, t + count, 0,
1986 b - t - count, vc->vc_cols);
1989 fbcon_clear(vc, t, 0, count, vc->vc_cols);
1992 case SCROLL_PAN_MOVE:
1993 if ((count - p->yscroll <= p->vrows - vc->vc_rows)
1994 && ((!scroll_partial && (b - t == vc->vc_rows))
1997 3 * vc->vc_rows >> 2)))) {
1998 if (vc->vc_rows - b > 0)
1999 fbcon_bmove(vc, b, 0, b - count, 0,
2002 ypan_down(vc, count);
2004 fbcon_bmove(vc, count, 0, 0, 0, t,
2006 } else if (info->flags & FBINFO_READS_FAST)
2007 fbcon_bmove(vc, t, 0, t + count, 0,
2008 b - t - count, vc->vc_cols);
2011 fbcon_clear(vc, t, 0, count, vc->vc_cols);
2014 case SCROLL_PAN_REDRAW:
2015 if ((count - p->yscroll <= p->vrows - vc->vc_rows)
2016 && ((!scroll_partial && (b - t == vc->vc_rows))
2019 3 * vc->vc_rows >> 2)))) {
2020 if (vc->vc_rows - b > 0)
2021 fbcon_redraw_move(vc, p, b, vc->vc_rows - b,
2023 ypan_down_redraw(vc, t, count);
2025 fbcon_redraw_move(vc, p, count, t, 0);
2027 fbcon_redraw_move(vc, p, t, b - t - count, t + count);
2028 fbcon_clear(vc, t, 0, count, vc->vc_cols);
2033 fbcon_redraw(vc, p, b - 1, b - t - count,
2034 -count * vc->vc_cols);
2035 fbcon_clear(vc, t, 0, count, vc->vc_cols);
2036 scr_memsetw((unsigned short *) (vc->vc_origin +
2039 vc->vc_video_erase_char,
2040 vc->vc_size_row * count);
2048 static void fbcon_bmove(struct vc_data *vc, int sy, int sx, int dy, int dx,
2049 int height, int width)
2051 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
2052 struct display *p = &fb_display[vc->vc_num];
2054 if (fbcon_is_inactive(vc, info))
2057 if (!width || !height)
2060 /* Split blits that cross physical y_wrap case.
2061 * Pathological case involves 4 blits, better to use recursive
2062 * code rather than unrolled case
2064 * Recursive invocations don't need to erase the cursor over and
2065 * over again, so we use fbcon_bmove_rec()
2067 fbcon_bmove_rec(vc, p, sy, sx, dy, dx, height, width,
2068 p->vrows - p->yscroll);
2071 static void fbcon_bmove_rec(struct vc_data *vc, struct display *p, int sy, int sx,
2072 int dy, int dx, int height, int width, u_int y_break)
2074 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
2075 struct fbcon_ops *ops = info->fbcon_par;
2078 if (sy < y_break && sy + height > y_break) {
2080 if (dy < sy) { /* Avoid trashing self */
2081 fbcon_bmove_rec(vc, p, sy, sx, dy, dx, b, width,
2083 fbcon_bmove_rec(vc, p, sy + b, sx, dy + b, dx,
2084 height - b, width, y_break);
2086 fbcon_bmove_rec(vc, p, sy + b, sx, dy + b, dx,
2087 height - b, width, y_break);
2088 fbcon_bmove_rec(vc, p, sy, sx, dy, dx, b, width,
2094 if (dy < y_break && dy + height > y_break) {
2096 if (dy < sy) { /* Avoid trashing self */
2097 fbcon_bmove_rec(vc, p, sy, sx, dy, dx, b, width,
2099 fbcon_bmove_rec(vc, p, sy + b, sx, dy + b, dx,
2100 height - b, width, y_break);
2102 fbcon_bmove_rec(vc, p, sy + b, sx, dy + b, dx,
2103 height - b, width, y_break);
2104 fbcon_bmove_rec(vc, p, sy, sx, dy, dx, b, width,
2109 ops->bmove(vc, info, real_y(p, sy), sx, real_y(p, dy), dx,
2113 static __inline__ void updatescrollmode(struct display *p,
2114 struct fb_info *info,
2117 struct fbcon_ops *ops = info->fbcon_par;
2118 int fh = vc->vc_font.height;
2119 int cap = info->flags;
2121 int ypan = FBCON_SWAP(ops->rotate, info->fix.ypanstep,
2122 info->fix.xpanstep);
2123 int ywrap = FBCON_SWAP(ops->rotate, info->fix.ywrapstep, t);
2124 int yres = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
2125 int vyres = FBCON_SWAP(ops->rotate, info->var.yres_virtual,
2126 info->var.xres_virtual);
2127 int good_pan = (cap & FBINFO_HWACCEL_YPAN) &&
2128 divides(ypan, vc->vc_font.height) && vyres > yres;
2129 int good_wrap = (cap & FBINFO_HWACCEL_YWRAP) &&
2130 divides(ywrap, vc->vc_font.height) &&
2131 divides(vc->vc_font.height, vyres) &&
2132 divides(vc->vc_font.height, yres);
2133 int reading_fast = cap & FBINFO_READS_FAST;
2134 int fast_copyarea = (cap & FBINFO_HWACCEL_COPYAREA) &&
2135 !(cap & FBINFO_HWACCEL_DISABLED);
2136 int fast_imageblit = (cap & FBINFO_HWACCEL_IMAGEBLIT) &&
2137 !(cap & FBINFO_HWACCEL_DISABLED);
2139 p->vrows = vyres/fh;
2140 if (yres > (fh * (vc->vc_rows + 1)))
2141 p->vrows -= (yres - (fh * vc->vc_rows)) / fh;
2142 if ((yres % fh) && (vyres % fh < yres % fh))
2145 if (good_wrap || good_pan) {
2146 if (reading_fast || fast_copyarea)
2147 p->scrollmode = good_wrap ?
2148 SCROLL_WRAP_MOVE : SCROLL_PAN_MOVE;
2150 p->scrollmode = good_wrap ? SCROLL_REDRAW :
2153 if (reading_fast || (fast_copyarea && !fast_imageblit))
2154 p->scrollmode = SCROLL_MOVE;
2156 p->scrollmode = SCROLL_REDRAW;
2160 static int fbcon_resize(struct vc_data *vc, unsigned int width,
2161 unsigned int height)
2163 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
2164 struct fbcon_ops *ops = info->fbcon_par;
2165 struct display *p = &fb_display[vc->vc_num];
2166 struct fb_var_screeninfo var = info->var;
2167 int x_diff, y_diff, virt_w, virt_h, virt_fw, virt_fh;
2169 virt_w = FBCON_SWAP(ops->rotate, width, height);
2170 virt_h = FBCON_SWAP(ops->rotate, height, width);
2171 virt_fw = FBCON_SWAP(ops->rotate, vc->vc_font.width,
2172 vc->vc_font.height);
2173 virt_fh = FBCON_SWAP(ops->rotate, vc->vc_font.height,
2175 var.xres = virt_w * virt_fw;
2176 var.yres = virt_h * virt_fh;
2177 x_diff = info->var.xres - var.xres;
2178 y_diff = info->var.yres - var.yres;
2179 if (x_diff < 0 || x_diff > virt_fw ||
2180 y_diff < 0 || y_diff > virt_fh) {
2181 const struct fb_videomode *mode;
2183 DPRINTK("attempting resize %ix%i\n", var.xres, var.yres);
2184 mode = fb_find_best_mode(&var, &info->modelist);
2187 display_to_var(&var, p);
2188 fb_videomode_to_var(&var, mode);
2190 if (virt_w > var.xres/virt_fw || virt_h > var.yres/virt_fh)
2193 DPRINTK("resize now %ix%i\n", var.xres, var.yres);
2194 if (CON_IS_VISIBLE(vc)) {
2195 var.activate = FB_ACTIVATE_NOW |
2197 fb_set_var(info, &var);
2199 var_to_display(p, &info->var, info);
2200 ops->var = info->var;
2202 updatescrollmode(p, info, vc);
2206 static int fbcon_switch(struct vc_data *vc)
2208 struct fb_info *info, *old_info = NULL;
2209 struct fbcon_ops *ops;
2210 struct display *p = &fb_display[vc->vc_num];
2211 struct fb_var_screeninfo var;
2212 int i, prev_console, charcnt = 256;
2214 info = registered_fb[con2fb_map[vc->vc_num]];
2215 ops = info->fbcon_par;
2219 fbcon_set_origin(vc);
2220 softback_top = softback_curr = softback_in = softback_buf;
2222 fbcon_update_softback(vc);
2225 if (logo_shown >= 0) {
2226 struct vc_data *conp2 = vc_cons[logo_shown].d;
2228 if (conp2->vc_top == logo_lines
2229 && conp2->vc_bottom == conp2->vc_rows)
2231 logo_shown = FBCON_LOGO_CANSHOW;
2234 prev_console = ops->currcon;
2235 if (prev_console != -1)
2236 old_info = registered_fb[con2fb_map[prev_console]];
2238 * FIXME: If we have multiple fbdev's loaded, we need to
2239 * update all info->currcon. Perhaps, we can place this
2240 * in a centralized structure, but this might break some
2243 * info->currcon = vc->vc_num;
2245 for (i = 0; i < FB_MAX; i++) {
2246 if (registered_fb[i] != NULL && registered_fb[i]->fbcon_par) {
2247 struct fbcon_ops *o = registered_fb[i]->fbcon_par;
2249 o->currcon = vc->vc_num;
2252 memset(&var, 0, sizeof(struct fb_var_screeninfo));
2253 display_to_var(&var, p);
2254 var.activate = FB_ACTIVATE_NOW;
2257 * make sure we don't unnecessarily trip the memcmp()
2260 info->var.activate = var.activate;
2261 var.yoffset = info->var.yoffset;
2262 var.xoffset = info->var.xoffset;
2263 var.vmode = info->var.vmode;
2264 fb_set_var(info, &var);
2265 ops->var = info->var;
2267 if (old_info != NULL && (old_info != info ||
2268 info->flags & FBINFO_MISC_ALWAYS_SETPAR)) {
2269 if (info->fbops->fb_set_par)
2270 info->fbops->fb_set_par(info);
2272 if (old_info != info)
2273 fbcon_del_cursor_timer(old_info);
2276 if (fbcon_is_inactive(vc, info) ||
2277 ops->blank_state != FB_BLANK_UNBLANK)
2278 fbcon_del_cursor_timer(info);
2280 fbcon_add_cursor_timer(info);
2282 set_blitting_type(vc, info);
2283 ops->cursor_reset = 1;
2285 if (ops->rotate_font && ops->rotate_font(info, vc)) {
2286 ops->rotate = FB_ROTATE_UR;
2287 set_blitting_type(vc, info);
2290 vc->vc_can_do_color = (fb_get_color_depth(&info->var, &info->fix)!=1);
2291 vc->vc_complement_mask = vc->vc_can_do_color ? 0x7700 : 0x0800;
2294 charcnt = FNTCHARCNT(vc->vc_font.data);
2297 vc->vc_complement_mask <<= 1;
2299 updatescrollmode(p, info, vc);
2301 switch (p->scrollmode) {
2302 case SCROLL_WRAP_MOVE:
2303 scrollback_phys_max = p->vrows - vc->vc_rows;
2305 case SCROLL_PAN_MOVE:
2306 case SCROLL_PAN_REDRAW:
2307 scrollback_phys_max = p->vrows - 2 * vc->vc_rows;
2308 if (scrollback_phys_max < 0)
2309 scrollback_phys_max = 0;
2312 scrollback_phys_max = 0;
2317 scrollback_current = 0;
2319 if (!fbcon_is_inactive(vc, info)) {
2320 ops->var.xoffset = ops->var.yoffset = p->yscroll = 0;
2321 ops->update_start(info);
2324 fbcon_set_palette(vc, color_table);
2325 fbcon_clear_margins(vc, 0);
2327 if (logo_shown == FBCON_LOGO_DRAW) {
2329 logo_shown = fg_console;
2330 /* This is protected above by initmem_freed */
2331 fb_show_logo(info, ops->rotate);
2333 vc->vc_origin + vc->vc_size_row * vc->vc_top,
2334 vc->vc_size_row * (vc->vc_bottom -
2341 static void fbcon_generic_blank(struct vc_data *vc, struct fb_info *info,
2344 struct fb_event event;
2347 unsigned short charmask = vc->vc_hi_font_mask ?
2349 unsigned short oldc;
2351 oldc = vc->vc_video_erase_char;
2352 vc->vc_video_erase_char &= charmask;
2353 fbcon_clear(vc, 0, 0, vc->vc_rows, vc->vc_cols);
2354 vc->vc_video_erase_char = oldc;
2359 event.data = ␣
2360 fb_notifier_call_chain(FB_EVENT_CONBLANK, &event);
2363 static int fbcon_blank(struct vc_data *vc, int blank, int mode_switch)
2365 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
2366 struct fbcon_ops *ops = info->fbcon_par;
2369 struct fb_var_screeninfo var = info->var;
2374 if (info->fbops->fb_save_state)
2375 info->fbops->fb_save_state(info);
2376 var.activate = FB_ACTIVATE_NOW | FB_ACTIVATE_FORCE;
2377 fb_set_var(info, &var);
2379 ops->var = info->var;
2380 } else if (info->fbops->fb_restore_state)
2381 info->fbops->fb_restore_state(info);
2384 if (!fbcon_is_inactive(vc, info)) {
2385 if (ops->blank_state != blank) {
2386 ops->blank_state = blank;
2387 fbcon_cursor(vc, blank ? CM_ERASE : CM_DRAW);
2388 ops->cursor_flash = (!blank);
2390 if (fb_blank(info, blank))
2391 fbcon_generic_blank(vc, info, blank);
2398 if (fbcon_is_inactive(vc, info) ||
2399 ops->blank_state != FB_BLANK_UNBLANK)
2400 fbcon_del_cursor_timer(info);
2402 fbcon_add_cursor_timer(info);
2407 static int fbcon_get_font(struct vc_data *vc, struct console_font *font)
2409 u8 *fontdata = vc->vc_font.data;
2410 u8 *data = font->data;
2413 font->width = vc->vc_font.width;
2414 font->height = vc->vc_font.height;
2415 font->charcount = vc->vc_hi_font_mask ? 512 : 256;
2419 if (font->width <= 8) {
2420 j = vc->vc_font.height;
2421 for (i = 0; i < font->charcount; i++) {
2422 memcpy(data, fontdata, j);
2423 memset(data + j, 0, 32 - j);
2427 } else if (font->width <= 16) {
2428 j = vc->vc_font.height * 2;
2429 for (i = 0; i < font->charcount; i++) {
2430 memcpy(data, fontdata, j);
2431 memset(data + j, 0, 64 - j);
2435 } else if (font->width <= 24) {
2436 for (i = 0; i < font->charcount; i++) {
2437 for (j = 0; j < vc->vc_font.height; j++) {
2438 *data++ = fontdata[0];
2439 *data++ = fontdata[1];
2440 *data++ = fontdata[2];
2441 fontdata += sizeof(u32);
2443 memset(data, 0, 3 * (32 - j));
2444 data += 3 * (32 - j);
2447 j = vc->vc_font.height * 4;
2448 for (i = 0; i < font->charcount; i++) {
2449 memcpy(data, fontdata, j);
2450 memset(data + j, 0, 128 - j);
2458 static int fbcon_do_set_font(struct vc_data *vc, int w, int h,
2459 const u8 * data, int userfont)
2461 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
2462 struct fbcon_ops *ops = info->fbcon_par;
2463 struct display *p = &fb_display[vc->vc_num];
2466 char *old_data = NULL;
2468 if (CON_IS_VISIBLE(vc) && softback_lines)
2469 fbcon_set_origin(vc);
2471 resize = (w != vc->vc_font.width) || (h != vc->vc_font.height);
2473 old_data = vc->vc_font.data;
2475 cnt = FNTCHARCNT(data);
2478 vc->vc_font.data = (void *)(p->fontdata = data);
2479 if ((p->userfont = userfont))
2481 vc->vc_font.width = w;
2482 vc->vc_font.height = h;
2483 if (vc->vc_hi_font_mask && cnt == 256) {
2484 vc->vc_hi_font_mask = 0;
2485 if (vc->vc_can_do_color) {
2486 vc->vc_complement_mask >>= 1;
2487 vc->vc_s_complement_mask >>= 1;
2490 /* ++Edmund: reorder the attribute bits */
2491 if (vc->vc_can_do_color) {
2492 unsigned short *cp =
2493 (unsigned short *) vc->vc_origin;
2494 int count = vc->vc_screenbuf_size / 2;
2496 for (; count > 0; count--, cp++) {
2498 scr_writew(((c & 0xfe00) >> 1) |
2501 c = vc->vc_video_erase_char;
2502 vc->vc_video_erase_char =
2503 ((c & 0xfe00) >> 1) | (c & 0xff);
2506 } else if (!vc->vc_hi_font_mask && cnt == 512) {
2507 vc->vc_hi_font_mask = 0x100;
2508 if (vc->vc_can_do_color) {
2509 vc->vc_complement_mask <<= 1;
2510 vc->vc_s_complement_mask <<= 1;
2513 /* ++Edmund: reorder the attribute bits */
2515 unsigned short *cp =
2516 (unsigned short *) vc->vc_origin;
2517 int count = vc->vc_screenbuf_size / 2;
2519 for (; count > 0; count--, cp++) {
2520 unsigned short newc;
2522 if (vc->vc_can_do_color)
2524 ((c & 0xff00) << 1) | (c &
2528 scr_writew(newc, cp);
2530 c = vc->vc_video_erase_char;
2531 if (vc->vc_can_do_color) {
2532 vc->vc_video_erase_char =
2533 ((c & 0xff00) << 1) | (c & 0xff);
2536 vc->vc_video_erase_char = c & ~0x100;
2544 cols = FBCON_SWAP(ops->rotate, info->var.xres, info->var.yres);
2545 rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
2548 vc_resize(vc, cols, rows);
2549 if (CON_IS_VISIBLE(vc) && softback_buf)
2550 fbcon_update_softback(vc);
2551 } else if (CON_IS_VISIBLE(vc)
2552 && vc->vc_mode == KD_TEXT) {
2553 fbcon_clear_margins(vc, 0);
2557 if (old_data && (--REFCOUNT(old_data) == 0))
2558 kfree(old_data - FONT_EXTRA_WORDS * sizeof(int));
2562 static int fbcon_copy_font(struct vc_data *vc, int con)
2564 struct display *od = &fb_display[con];
2565 struct console_font *f = &vc->vc_font;
2567 if (od->fontdata == f->data)
2568 return 0; /* already the same font... */
2569 return fbcon_do_set_font(vc, f->width, f->height, od->fontdata, od->userfont);
2573 * User asked to set font; we are guaranteed that
2574 * a) width and height are in range 1..32
2575 * b) charcount does not exceed 512
2576 * but lets not assume that, since someone might someday want to use larger
2577 * fonts. And charcount of 512 is small for unicode support.
2579 * However, user space gives the font in 32 rows , regardless of
2580 * actual font height. So a new API is needed if support for larger fonts
2581 * is ever implemented.
2584 static int fbcon_set_font(struct vc_data *vc, struct console_font *font, unsigned flags)
2586 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
2587 unsigned charcount = font->charcount;
2588 int w = font->width;
2589 int h = font->height;
2592 u8 *new_data, *data = font->data;
2593 int pitch = (font->width+7) >> 3;
2595 /* Is there a reason why fbconsole couldn't handle any charcount >256?
2596 * If not this check should be changed to charcount < 256 */
2597 if (charcount != 256 && charcount != 512)
2600 /* Make sure drawing engine can handle the font */
2601 if (!(info->pixmap.blit_x & (1 << (font->width - 1))) ||
2602 !(info->pixmap.blit_y & (1 << (font->height - 1))))
2605 /* Make sure driver can handle the font length */
2606 if (fbcon_invalid_charcount(info, charcount))
2609 size = h * pitch * charcount;
2611 new_data = kmalloc(FONT_EXTRA_WORDS * sizeof(int) + size, GFP_USER);
2616 new_data += FONT_EXTRA_WORDS * sizeof(int);
2617 FNTSIZE(new_data) = size;
2618 FNTCHARCNT(new_data) = charcount;
2619 REFCOUNT(new_data) = 0; /* usage counter */
2620 for (i=0; i< charcount; i++) {
2621 memcpy(new_data + i*h*pitch, data + i*32*pitch, h*pitch);
2624 /* Since linux has a nice crc32 function use it for counting font
2626 csum = crc32(0, new_data, size);
2628 FNTSUM(new_data) = csum;
2629 /* Check if the same font is on some other console already */
2630 for (i = first_fb_vc; i <= last_fb_vc; i++) {
2631 struct vc_data *tmp = vc_cons[i].d;
2633 if (fb_display[i].userfont &&
2634 fb_display[i].fontdata &&
2635 FNTSUM(fb_display[i].fontdata) == csum &&
2636 FNTSIZE(fb_display[i].fontdata) == size &&
2637 tmp->vc_font.width == w &&
2638 !memcmp(fb_display[i].fontdata, new_data, size)) {
2639 kfree(new_data - FONT_EXTRA_WORDS * sizeof(int));
2640 new_data = (u8 *)fb_display[i].fontdata;
2644 return fbcon_do_set_font(vc, font->width, font->height, new_data, 1);
2647 static int fbcon_set_def_font(struct vc_data *vc, struct console_font *font, char *name)
2649 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
2650 const struct font_desc *f;
2653 f = get_default_font(info->var.xres, info->var.yres,
2654 info->pixmap.blit_x, info->pixmap.blit_y);
2655 else if (!(f = find_font(name)))
2658 font->width = f->width;
2659 font->height = f->height;
2660 return fbcon_do_set_font(vc, f->width, f->height, f->data, 0);
2663 static u16 palette_red[16];
2664 static u16 palette_green[16];
2665 static u16 palette_blue[16];
2667 static struct fb_cmap palette_cmap = {
2668 0, 16, palette_red, palette_green, palette_blue, NULL
2671 static int fbcon_set_palette(struct vc_data *vc, unsigned char *table)
2673 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
2677 if (fbcon_is_inactive(vc, info))
2680 if (!CON_IS_VISIBLE(vc))
2683 depth = fb_get_color_depth(&info->var, &info->fix);
2685 for (i = j = 0; i < 16; i++) {
2687 val = vc->vc_palette[j++];
2688 palette_red[k] = (val << 8) | val;
2689 val = vc->vc_palette[j++];
2690 palette_green[k] = (val << 8) | val;
2691 val = vc->vc_palette[j++];
2692 palette_blue[k] = (val << 8) | val;
2694 palette_cmap.len = 16;
2695 palette_cmap.start = 0;
2697 * If framebuffer is capable of less than 16 colors,
2698 * use default palette of fbcon.
2701 fb_copy_cmap(fb_default_cmap(1 << depth), &palette_cmap);
2703 return fb_set_cmap(&palette_cmap, info);
2706 static u16 *fbcon_screen_pos(struct vc_data *vc, int offset)
2711 if (vc->vc_num != fg_console || !softback_lines)
2712 return (u16 *) (vc->vc_origin + offset);
2713 line = offset / vc->vc_size_row;
2714 if (line >= softback_lines)
2715 return (u16 *) (vc->vc_origin + offset -
2716 softback_lines * vc->vc_size_row);
2717 p = softback_curr + offset;
2718 if (p >= softback_end)
2719 p += softback_buf - softback_end;
2723 static unsigned long fbcon_getxy(struct vc_data *vc, unsigned long pos,
2729 if (pos >= vc->vc_origin && pos < vc->vc_scr_end) {
2730 unsigned long offset = (pos - vc->vc_origin) / 2;
2732 x = offset % vc->vc_cols;
2733 y = offset / vc->vc_cols;
2734 if (vc->vc_num == fg_console)
2735 y += softback_lines;
2736 ret = pos + (vc->vc_cols - x) * 2;
2737 } else if (vc->vc_num == fg_console && softback_lines) {
2738 unsigned long offset = pos - softback_curr;
2740 if (pos < softback_curr)
2741 offset += softback_end - softback_buf;
2743 x = offset % vc->vc_cols;
2744 y = offset / vc->vc_cols;
2745 ret = pos + (vc->vc_cols - x) * 2;
2746 if (ret == softback_end)
2748 if (ret == softback_in)
2749 ret = vc->vc_origin;
2751 /* Should not happen */
2753 ret = vc->vc_origin;
2762 /* As we might be inside of softback, we may work with non-contiguous buffer,
2763 that's why we have to use a separate routine. */
2764 static void fbcon_invert_region(struct vc_data *vc, u16 * p, int cnt)
2767 u16 a = scr_readw(p);
2768 if (!vc->vc_can_do_color)
2770 else if (vc->vc_hi_font_mask == 0x100)
2771 a = ((a) & 0x11ff) | (((a) & 0xe000) >> 4) |
2772 (((a) & 0x0e00) << 4);
2774 a = ((a) & 0x88ff) | (((a) & 0x7000) >> 4) |
2775 (((a) & 0x0700) << 4);
2777 if (p == (u16 *) softback_end)
2778 p = (u16 *) softback_buf;
2779 if (p == (u16 *) softback_in)
2780 p = (u16 *) vc->vc_origin;
2784 static int fbcon_scrolldelta(struct vc_data *vc, int lines)
2786 struct fb_info *info = registered_fb[con2fb_map[fg_console]];
2787 struct fbcon_ops *ops = info->fbcon_par;
2788 struct display *p = &fb_display[fg_console];
2789 int offset, limit, scrollback_old;
2792 if (vc->vc_num != fg_console)
2794 if (vc->vc_mode != KD_TEXT || !lines)
2796 if (logo_shown >= 0) {
2797 struct vc_data *conp2 = vc_cons[logo_shown].d;
2799 if (conp2->vc_top == logo_lines
2800 && conp2->vc_bottom == conp2->vc_rows)
2802 if (logo_shown == vc->vc_num) {
2808 logo_lines * vc->vc_size_row;
2809 for (i = 0; i < logo_lines; i++) {
2810 if (p == softback_top)
2812 if (p == softback_buf)
2814 p -= vc->vc_size_row;
2815 q -= vc->vc_size_row;
2816 scr_memcpyw((u16 *) q, (u16 *) p,
2819 softback_in = softback_curr = p;
2820 update_region(vc, vc->vc_origin,
2821 logo_lines * vc->vc_cols);
2823 logo_shown = FBCON_LOGO_CANSHOW;
2825 fbcon_cursor(vc, CM_ERASE | CM_SOFTBACK);
2826 fbcon_redraw_softback(vc, p, lines);
2827 fbcon_cursor(vc, CM_DRAW | CM_SOFTBACK);
2831 if (!scrollback_phys_max)
2834 scrollback_old = scrollback_current;
2835 scrollback_current -= lines;
2836 if (scrollback_current < 0)
2837 scrollback_current = 0;
2838 else if (scrollback_current > scrollback_max)
2839 scrollback_current = scrollback_max;
2840 if (scrollback_current == scrollback_old)
2843 if (fbcon_is_inactive(vc, info))
2846 fbcon_cursor(vc, CM_ERASE);
2848 offset = p->yscroll - scrollback_current;
2850 switch (p->scrollmode) {
2851 case SCROLL_WRAP_MOVE:
2852 info->var.vmode |= FB_VMODE_YWRAP;
2854 case SCROLL_PAN_MOVE:
2855 case SCROLL_PAN_REDRAW:
2856 limit -= vc->vc_rows;
2857 info->var.vmode &= ~FB_VMODE_YWRAP;
2862 else if (offset >= limit)
2865 ops->var.xoffset = 0;
2866 ops->var.yoffset = offset * vc->vc_font.height;
2867 ops->update_start(info);
2869 if (!scrollback_current)
2870 fbcon_cursor(vc, CM_DRAW);
2874 static int fbcon_set_origin(struct vc_data *vc)
2877 fbcon_scrolldelta(vc, softback_lines);
2881 static void fbcon_suspended(struct fb_info *info)
2883 struct vc_data *vc = NULL;
2884 struct fbcon_ops *ops = info->fbcon_par;
2886 if (!ops || ops->currcon < 0)
2888 vc = vc_cons[ops->currcon].d;
2890 /* Clear cursor, restore saved data */
2891 fbcon_cursor(vc, CM_ERASE);
2894 static void fbcon_resumed(struct fb_info *info)
2897 struct fbcon_ops *ops = info->fbcon_par;
2899 if (!ops || ops->currcon < 0)
2901 vc = vc_cons[ops->currcon].d;
2906 static void fbcon_modechanged(struct fb_info *info)
2908 struct fbcon_ops *ops = info->fbcon_par;
2913 if (!ops || ops->currcon < 0)
2915 vc = vc_cons[ops->currcon].d;
2916 if (vc->vc_mode != KD_TEXT ||
2917 registered_fb[con2fb_map[ops->currcon]] != info)
2920 p = &fb_display[vc->vc_num];
2921 set_blitting_type(vc, info);
2923 if (CON_IS_VISIBLE(vc)) {
2924 var_to_display(p, &info->var, info);
2925 cols = FBCON_SWAP(ops->rotate, info->var.xres, info->var.yres);
2926 rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
2927 cols /= vc->vc_font.width;
2928 rows /= vc->vc_font.height;
2929 vc_resize(vc, cols, rows);
2930 updatescrollmode(p, info, vc);
2932 scrollback_current = 0;
2934 if (!fbcon_is_inactive(vc, info)) {
2935 ops->var.xoffset = ops->var.yoffset = p->yscroll = 0;
2936 ops->update_start(info);
2939 fbcon_set_palette(vc, color_table);
2942 fbcon_update_softback(vc);
2946 static void fbcon_set_all_vcs(struct fb_info *info)
2948 struct fbcon_ops *ops = info->fbcon_par;
2951 int i, rows, cols, fg = -1;
2953 if (!ops || ops->currcon < 0)
2956 for (i = first_fb_vc; i <= last_fb_vc; i++) {
2958 if (!vc || vc->vc_mode != KD_TEXT ||
2959 registered_fb[con2fb_map[i]] != info)
2962 if (CON_IS_VISIBLE(vc)) {
2967 p = &fb_display[vc->vc_num];
2968 set_blitting_type(vc, info);
2969 var_to_display(p, &info->var, info);
2970 cols = FBCON_SWAP(p->rotate, info->var.xres, info->var.yres);
2971 rows = FBCON_SWAP(p->rotate, info->var.yres, info->var.xres);
2972 cols /= vc->vc_font.width;
2973 rows /= vc->vc_font.height;
2974 vc_resize(vc, cols, rows);
2978 fbcon_modechanged(info);
2981 static int fbcon_mode_deleted(struct fb_info *info,
2982 struct fb_videomode *mode)
2984 struct fb_info *fb_info;
2986 int i, j, found = 0;
2988 /* before deletion, ensure that mode is not in use */
2989 for (i = first_fb_vc; i <= last_fb_vc; i++) {
2993 fb_info = registered_fb[j];
2994 if (fb_info != info)
2999 if (fb_mode_is_equal(p->mode, mode)) {
3007 static int fbcon_fb_unregistered(int idx)
3011 for (i = first_fb_vc; i <= last_fb_vc; i++) {
3012 if (con2fb_map[i] == idx)
3016 if (idx == info_idx) {
3019 for (i = 0; i < FB_MAX; i++) {
3020 if (registered_fb[i] != NULL) {
3027 if (info_idx != -1) {
3028 for (i = first_fb_vc; i <= last_fb_vc; i++) {
3029 if (con2fb_map[i] == -1)
3030 con2fb_map[i] = info_idx;
3034 if (!num_registered_fb)
3035 unregister_con_driver(&fb_con);
3040 static int fbcon_fb_registered(int idx)
3044 if (info_idx == -1) {
3045 for (i = first_fb_vc; i <= last_fb_vc; i++) {
3046 if (con2fb_map_boot[i] == idx) {
3053 ret = fbcon_takeover(1);
3055 for (i = first_fb_vc; i <= last_fb_vc; i++) {
3056 if (con2fb_map_boot[i] == idx &&
3057 con2fb_map[i] == -1)
3058 set_con2fb_map(i, idx, 0);
3065 static void fbcon_fb_blanked(struct fb_info *info, int blank)
3067 struct fbcon_ops *ops = info->fbcon_par;
3070 if (!ops || ops->currcon < 0)
3073 vc = vc_cons[ops->currcon].d;
3074 if (vc->vc_mode != KD_TEXT ||
3075 registered_fb[con2fb_map[ops->currcon]] != info)
3078 if (CON_IS_VISIBLE(vc)) {
3082 do_unblank_screen(0);
3084 ops->blank_state = blank;
3087 static void fbcon_new_modelist(struct fb_info *info)
3091 struct fb_var_screeninfo var;
3092 const struct fb_videomode *mode;
3094 for (i = first_fb_vc; i <= last_fb_vc; i++) {
3095 if (registered_fb[con2fb_map[i]] != info)
3097 if (!fb_display[i].mode)
3100 display_to_var(&var, &fb_display[i]);
3101 mode = fb_find_nearest_mode(fb_display[i].mode,
3103 fb_videomode_to_var(&var, mode);
3106 fbcon_set_disp(info, &var, vc);
3108 fbcon_preset_disp(info, &var, i);
3113 static void fbcon_get_requirement(struct fb_info *info,
3114 struct fb_blit_caps *caps)
3122 for (i = first_fb_vc; i <= last_fb_vc; i++) {
3124 if (vc && vc->vc_mode == KD_TEXT &&
3125 info->node == con2fb_map[i]) {
3127 caps->x |= 1 << (vc->vc_font.width - 1);
3128 caps->y |= 1 << (vc->vc_font.height - 1);
3129 charcnt = (p->userfont) ?
3130 FNTCHARCNT(p->fontdata) : 256;
3131 if (caps->len < charcnt)
3132 caps->len = charcnt;
3136 vc = vc_cons[fg_console].d;
3138 if (vc && vc->vc_mode == KD_TEXT &&
3139 info->node == con2fb_map[fg_console]) {
3140 p = &fb_display[fg_console];
3141 caps->x = 1 << (vc->vc_font.width - 1);
3142 caps->y = 1 << (vc->vc_font.height - 1);
3143 caps->len = (p->userfont) ?
3144 FNTCHARCNT(p->fontdata) : 256;
3149 static int fbcon_event_notify(struct notifier_block *self,
3150 unsigned long action, void *data)
3152 struct fb_event *event = data;
3153 struct fb_info *info = event->info;
3154 struct fb_videomode *mode;
3155 struct fb_con2fbmap *con2fb;
3156 struct fb_blit_caps *caps;
3160 * ignore all events except driver registration and deregistration
3161 * if fbcon is not active
3163 if (fbcon_has_exited && !(action == FB_EVENT_FB_REGISTERED ||
3164 action == FB_EVENT_FB_UNREGISTERED))
3168 case FB_EVENT_SUSPEND:
3169 fbcon_suspended(info);
3171 case FB_EVENT_RESUME:
3172 fbcon_resumed(info);
3174 case FB_EVENT_MODE_CHANGE:
3175 fbcon_modechanged(info);
3177 case FB_EVENT_MODE_CHANGE_ALL:
3178 fbcon_set_all_vcs(info);
3180 case FB_EVENT_MODE_DELETE:
3182 ret = fbcon_mode_deleted(info, mode);
3184 case FB_EVENT_FB_REGISTERED:
3185 ret = fbcon_fb_registered(info->node);
3187 case FB_EVENT_FB_UNREGISTERED:
3188 ret = fbcon_fb_unregistered(info->node);
3190 case FB_EVENT_SET_CONSOLE_MAP:
3191 con2fb = event->data;
3192 ret = set_con2fb_map(con2fb->console - 1,
3193 con2fb->framebuffer, 1);
3195 case FB_EVENT_GET_CONSOLE_MAP:
3196 con2fb = event->data;
3197 con2fb->framebuffer = con2fb_map[con2fb->console - 1];
3199 case FB_EVENT_BLANK:
3200 fbcon_fb_blanked(info, *(int *)event->data);
3202 case FB_EVENT_NEW_MODELIST:
3203 fbcon_new_modelist(info);
3205 case FB_EVENT_GET_REQ:
3207 fbcon_get_requirement(info, caps);
3216 * The console `switch' structure for the frame buffer based console
3219 static const struct consw fb_con = {
3220 .owner = THIS_MODULE,
3221 .con_startup = fbcon_startup,
3222 .con_init = fbcon_init,
3223 .con_deinit = fbcon_deinit,
3224 .con_clear = fbcon_clear,
3225 .con_putc = fbcon_putc,
3226 .con_putcs = fbcon_putcs,
3227 .con_cursor = fbcon_cursor,
3228 .con_scroll = fbcon_scroll,
3229 .con_bmove = fbcon_bmove,
3230 .con_switch = fbcon_switch,
3231 .con_blank = fbcon_blank,
3232 .con_font_set = fbcon_set_font,
3233 .con_font_get = fbcon_get_font,
3234 .con_font_default = fbcon_set_def_font,
3235 .con_font_copy = fbcon_copy_font,
3236 .con_set_palette = fbcon_set_palette,
3237 .con_scrolldelta = fbcon_scrolldelta,
3238 .con_set_origin = fbcon_set_origin,
3239 .con_invert_region = fbcon_invert_region,
3240 .con_screen_pos = fbcon_screen_pos,
3241 .con_getxy = fbcon_getxy,
3242 .con_resize = fbcon_resize,
3245 static struct notifier_block fbcon_event_notifier = {
3246 .notifier_call = fbcon_event_notify,
3249 static ssize_t store_rotate(struct class_device *class_device,
3250 const char *buf, size_t count)
3252 struct fb_info *info;
3256 if (fbcon_has_exited)
3259 acquire_console_sem();
3260 idx = con2fb_map[fg_console];
3262 if (idx == -1 || registered_fb[idx] == NULL)
3265 info = registered_fb[idx];
3266 rotate = simple_strtoul(buf, last, 0);
3267 fbcon_rotate(info, rotate);
3269 release_console_sem();
3273 static ssize_t store_rotate_all(struct class_device *class_device,
3274 const char *buf, size_t count)
3276 struct fb_info *info;
3280 if (fbcon_has_exited)
3283 acquire_console_sem();
3284 idx = con2fb_map[fg_console];
3286 if (idx == -1 || registered_fb[idx] == NULL)
3289 info = registered_fb[idx];
3290 rotate = simple_strtoul(buf, last, 0);
3291 fbcon_rotate_all(info, rotate);
3293 release_console_sem();
3297 static ssize_t show_rotate(struct class_device *class_device, char *buf)
3299 struct fb_info *info;
3300 int rotate = 0, idx;
3302 if (fbcon_has_exited)
3305 acquire_console_sem();
3306 idx = con2fb_map[fg_console];
3308 if (idx == -1 || registered_fb[idx] == NULL)
3311 info = registered_fb[idx];
3312 rotate = fbcon_get_rotate(info);
3314 release_console_sem();
3315 return snprintf(buf, PAGE_SIZE, "%d\n", rotate);
3318 static ssize_t show_cursor_blink(struct class_device *class_device, char *buf)
3320 struct fb_info *info;
3321 struct fbcon_ops *ops;
3322 int idx, blink = -1;
3324 if (fbcon_has_exited)
3327 acquire_console_sem();
3328 idx = con2fb_map[fg_console];
3330 if (idx == -1 || registered_fb[idx] == NULL)
3333 info = registered_fb[idx];
3334 ops = info->fbcon_par;
3339 blink = (ops->flags & FBCON_FLAGS_CURSOR_TIMER) ? 1 : 0;
3341 release_console_sem();
3342 return snprintf(buf, PAGE_SIZE, "%d\n", blink);
3345 static ssize_t store_cursor_blink(struct class_device *clas_device,
3346 const char *buf, size_t count)
3348 struct fb_info *info;
3352 if (fbcon_has_exited)
3355 acquire_console_sem();
3356 idx = con2fb_map[fg_console];
3358 if (idx == -1 || registered_fb[idx] == NULL)
3361 info = registered_fb[idx];
3363 if (!info->fbcon_par)
3366 blink = simple_strtoul(buf, last, 0);
3369 fbcon_cursor_noblink = 0;
3370 fbcon_add_cursor_timer(info);
3372 fbcon_cursor_noblink = 1;
3373 fbcon_del_cursor_timer(info);
3377 release_console_sem();
3381 static struct class_device_attribute class_device_attrs[] = {
3382 __ATTR(rotate, S_IRUGO|S_IWUSR, show_rotate, store_rotate),
3383 __ATTR(rotate_all, S_IWUSR, NULL, store_rotate_all),
3384 __ATTR(cursor_blink, S_IRUGO|S_IWUSR, show_cursor_blink,
3385 store_cursor_blink),
3388 static int fbcon_init_class_device(void)
3392 fbcon_has_sysfs = 1;
3394 for (i = 0; i < ARRAY_SIZE(class_device_attrs); i++) {
3395 error = class_device_create_file(fbcon_class_device,
3396 &class_device_attrs[i]);
3404 class_device_remove_file(fbcon_class_device,
3405 &class_device_attrs[i]);
3407 fbcon_has_sysfs = 0;
3413 static void fbcon_start(void)
3415 if (num_registered_fb) {
3418 acquire_console_sem();
3420 for (i = 0; i < FB_MAX; i++) {
3421 if (registered_fb[i] != NULL) {
3427 release_console_sem();
3432 static void fbcon_exit(void)
3434 struct fb_info *info;
3437 if (fbcon_has_exited)
3441 free_irq(IRQ_AUTO_4, fb_vbl_handler);
3444 if (MACH_IS_MAC && vbl_detected)
3445 free_irq(IRQ_MAC_VBL, fb_vbl_handler);
3448 kfree((void *)softback_buf);
3451 for (i = 0; i < FB_MAX; i++) {
3453 info = registered_fb[i];
3458 for (j = first_fb_vc; j <= last_fb_vc; j++) {
3459 if (con2fb_map[j] == i)
3464 if (info->fbops->fb_release)
3465 info->fbops->fb_release(info, 0);
3466 module_put(info->fbops->owner);
3468 if (info->fbcon_par) {
3469 struct fbcon_ops *ops = info->fbcon_par;
3471 fbcon_del_cursor_timer(info);
3472 kfree(ops->cursor_src);
3473 kfree(info->fbcon_par);
3474 info->fbcon_par = NULL;
3477 if (info->queue.func == fb_flashcursor)
3478 info->queue.func = NULL;
3482 fbcon_has_exited = 1;
3485 static int __init fb_console_init(void)
3489 acquire_console_sem();
3490 fb_register_client(&fbcon_event_notifier);
3491 fbcon_class_device =
3492 class_device_create(fb_class, NULL, MKDEV(0, 0), NULL, "fbcon");
3494 if (IS_ERR(fbcon_class_device)) {
3495 printk(KERN_WARNING "Unable to create class_device "
3496 "for fbcon; errno = %ld\n",
3497 PTR_ERR(fbcon_class_device));
3498 fbcon_class_device = NULL;
3500 fbcon_init_class_device();
3502 for (i = 0; i < MAX_NR_CONSOLES; i++)
3505 release_console_sem();
3510 module_init(fb_console_init);
3514 static void __exit fbcon_deinit_class_device(void)
3518 if (fbcon_has_sysfs) {
3519 for (i = 0; i < ARRAY_SIZE(class_device_attrs); i++)
3520 class_device_remove_file(fbcon_class_device,
3521 &class_device_attrs[i]);
3523 fbcon_has_sysfs = 0;
3527 static void __exit fb_console_exit(void)
3529 acquire_console_sem();
3530 fb_unregister_client(&fbcon_event_notifier);
3531 fbcon_deinit_class_device();
3532 class_device_destroy(fb_class, MKDEV(0, 0));
3534 release_console_sem();
3535 unregister_con_driver(&fb_con);
3538 module_exit(fb_console_exit);
3542 MODULE_LICENSE("GPL");