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 */
84 # define DPRINTK(fmt, args...) printk(KERN_DEBUG "%s: " fmt, __func__ , ## args)
86 # define DPRINTK(fmt, args...)
90 FBCON_LOGO_CANSHOW = -1, /* the logo can be shown */
91 FBCON_LOGO_DRAW = -2, /* draw the logo to a console */
92 FBCON_LOGO_DONTSHOW = -3 /* do not show the logo */
95 static struct display fb_display[MAX_NR_CONSOLES];
97 static signed char con2fb_map[MAX_NR_CONSOLES];
98 static signed char con2fb_map_boot[MAX_NR_CONSOLES];
100 static int logo_lines;
101 /* logo_shown is an index to vc_cons when >= 0; otherwise follows FBCON_LOGO
103 static int logo_shown = FBCON_LOGO_CANSHOW;
104 /* Software scrollback */
105 static int fbcon_softback_size = 32768;
106 static unsigned long softback_buf, softback_curr;
107 static unsigned long softback_in;
108 static unsigned long softback_top, softback_end;
109 static int softback_lines;
110 /* console mappings */
111 static int first_fb_vc;
112 static int last_fb_vc = MAX_NR_CONSOLES - 1;
113 static int fbcon_is_default = 1;
114 static int fbcon_has_exited;
115 static int primary_device = -1;
116 static int fbcon_has_console_bind;
118 #ifdef CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY
119 static int map_override;
121 static inline void fbcon_map_override(void)
126 static inline void fbcon_map_override(void)
129 #endif /* CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY */
132 static char fontname[40];
134 /* current fb_info */
135 static int info_idx = -1;
137 /* console rotation */
138 static int initial_rotation;
139 static int fbcon_has_sysfs;
141 static const struct consw fb_con;
143 #define CM_SOFTBACK (8)
145 #define advance_row(p, delta) (unsigned short *)((unsigned long)(p) + (delta) * vc->vc_size_row)
147 static int fbcon_set_origin(struct vc_data *);
149 #define CURSOR_DRAW_DELAY (1)
151 static int vbl_cursor_cnt;
152 static int fbcon_cursor_noblink;
154 #define divides(a, b) ((!(a) || (b)%(a)) ? 0 : 1)
157 * Interface used by the world
160 static const char *fbcon_startup(void);
161 static void fbcon_init(struct vc_data *vc, int init);
162 static void fbcon_deinit(struct vc_data *vc);
163 static void fbcon_clear(struct vc_data *vc, int sy, int sx, int height,
165 static void fbcon_putc(struct vc_data *vc, int c, int ypos, int xpos);
166 static void fbcon_putcs(struct vc_data *vc, const unsigned short *s,
167 int count, int ypos, int xpos);
168 static void fbcon_clear_margins(struct vc_data *vc, int bottom_only);
169 static void fbcon_cursor(struct vc_data *vc, int mode);
170 static int fbcon_scroll(struct vc_data *vc, int t, int b, int dir,
172 static void fbcon_bmove(struct vc_data *vc, int sy, int sx, int dy, int dx,
173 int height, int width);
174 static int fbcon_switch(struct vc_data *vc);
175 static int fbcon_blank(struct vc_data *vc, int blank, int mode_switch);
176 static int fbcon_set_palette(struct vc_data *vc, unsigned char *table);
177 static int fbcon_scrolldelta(struct vc_data *vc, int lines);
182 static __inline__ void ywrap_up(struct vc_data *vc, int count);
183 static __inline__ void ywrap_down(struct vc_data *vc, int count);
184 static __inline__ void ypan_up(struct vc_data *vc, int count);
185 static __inline__ void ypan_down(struct vc_data *vc, int count);
186 static void fbcon_bmove_rec(struct vc_data *vc, struct display *p, int sy, int sx,
187 int dy, int dx, int height, int width, u_int y_break);
188 static void fbcon_set_disp(struct fb_info *info, struct fb_var_screeninfo *var,
190 static void fbcon_redraw_move(struct vc_data *vc, struct display *p,
191 int line, int count, int dy);
192 static void fbcon_modechanged(struct fb_info *info);
193 static void fbcon_set_all_vcs(struct fb_info *info);
194 static void fbcon_start(void);
195 static void fbcon_exit(void);
196 static struct device *fbcon_device;
198 #ifdef CONFIG_FRAMEBUFFER_CONSOLE_ROTATION
199 static inline void fbcon_set_rotation(struct fb_info *info)
201 struct fbcon_ops *ops = info->fbcon_par;
203 if (!(info->flags & FBINFO_MISC_TILEBLITTING) &&
204 ops->p->con_rotate < 4)
205 ops->rotate = ops->p->con_rotate;
210 static void fbcon_rotate(struct fb_info *info, u32 rotate)
212 struct fbcon_ops *ops= info->fbcon_par;
213 struct fb_info *fb_info;
215 if (!ops || ops->currcon == -1)
218 fb_info = registered_fb[con2fb_map[ops->currcon]];
220 if (info == fb_info) {
221 struct display *p = &fb_display[ops->currcon];
224 p->con_rotate = rotate;
228 fbcon_modechanged(info);
232 static void fbcon_rotate_all(struct fb_info *info, u32 rotate)
234 struct fbcon_ops *ops = info->fbcon_par;
239 if (!ops || ops->currcon < 0 || rotate > 3)
242 for (i = first_fb_vc; i <= last_fb_vc; i++) {
244 if (!vc || vc->vc_mode != KD_TEXT ||
245 registered_fb[con2fb_map[i]] != info)
248 p = &fb_display[vc->vc_num];
249 p->con_rotate = rotate;
252 fbcon_set_all_vcs(info);
255 static inline void fbcon_set_rotation(struct fb_info *info)
257 struct fbcon_ops *ops = info->fbcon_par;
259 ops->rotate = FB_ROTATE_UR;
262 static void fbcon_rotate(struct fb_info *info, u32 rotate)
267 static void fbcon_rotate_all(struct fb_info *info, u32 rotate)
271 #endif /* CONFIG_FRAMEBUFFER_CONSOLE_ROTATION */
273 static int fbcon_get_rotate(struct fb_info *info)
275 struct fbcon_ops *ops = info->fbcon_par;
277 return (ops) ? ops->rotate : 0;
280 static inline int fbcon_is_inactive(struct vc_data *vc, struct fb_info *info)
282 struct fbcon_ops *ops = info->fbcon_par;
284 return (info->state != FBINFO_STATE_RUNNING ||
285 vc->vc_mode != KD_TEXT || ops->graphics) &&
286 !vt_force_oops_output(vc);
289 static int get_color(struct vc_data *vc, struct fb_info *info,
292 int depth = fb_get_color_depth(&info->var, &info->fix);
295 if (console_blanked) {
296 unsigned short charmask = vc->vc_hi_font_mask ? 0x1ff : 0xff;
298 c = vc->vc_video_erase_char & charmask;
302 color = (is_fg) ? attr_fgcol((vc->vc_hi_font_mask) ? 9 : 8, c)
303 : attr_bgcol((vc->vc_hi_font_mask) ? 13 : 12, c);
308 int col = mono_col(info);
310 int fg = (info->fix.visual != FB_VISUAL_MONO01) ? col : 0;
311 int bg = (info->fix.visual != FB_VISUAL_MONO01) ? 0 : col;
316 color = (is_fg) ? fg : bg;
321 * Scale down 16-colors to 4 colors. Default 4-color palette
322 * is grayscale. However, simply dividing the values by 4
323 * will not work, as colors 1, 2 and 3 will be scaled-down
324 * to zero rendering them invisible. So empirically convert
325 * colors to a sane 4-level grayscale.
329 color = 0; /* black */
332 color = 2; /* white */
335 color = 1; /* gray */
338 color = 3; /* intense white */
344 * Last 8 entries of default 16-color palette is a more intense
345 * version of the first 8 (i.e., same chrominance, different
356 static void fbcon_update_softback(struct vc_data *vc)
358 int l = fbcon_softback_size / vc->vc_size_row;
361 softback_end = softback_buf + l * vc->vc_size_row;
363 /* Smaller scrollback makes no sense, and 0 would screw
364 the operation totally */
368 static void fb_flashcursor(struct work_struct *work)
370 struct fb_info *info = container_of(work, struct fb_info, queue);
371 struct fbcon_ops *ops = info->fbcon_par;
372 struct vc_data *vc = NULL;
377 if (ops && ops->currcon != -1)
378 vc = vc_cons[ops->currcon].d;
380 if (!vc || !CON_IS_VISIBLE(vc) ||
381 registered_fb[con2fb_map[vc->vc_num]] != info ||
387 c = scr_readw((u16 *) vc->vc_pos);
388 mode = (!ops->cursor_flash || ops->cursor_state.enable) ?
390 ops->cursor(vc, info, mode, softback_lines, get_color(vc, info, c, 1),
391 get_color(vc, info, c, 0));
395 static void cursor_timer_handler(unsigned long dev_addr)
397 struct fb_info *info = (struct fb_info *) dev_addr;
398 struct fbcon_ops *ops = info->fbcon_par;
400 schedule_work(&info->queue);
401 mod_timer(&ops->cursor_timer, jiffies + HZ/5);
404 static void fbcon_add_cursor_timer(struct fb_info *info)
406 struct fbcon_ops *ops = info->fbcon_par;
408 if ((!info->queue.func || info->queue.func == fb_flashcursor) &&
409 !(ops->flags & FBCON_FLAGS_CURSOR_TIMER) &&
410 !fbcon_cursor_noblink) {
411 if (!info->queue.func)
412 INIT_WORK(&info->queue, fb_flashcursor);
414 init_timer(&ops->cursor_timer);
415 ops->cursor_timer.function = cursor_timer_handler;
416 ops->cursor_timer.expires = jiffies + HZ / 5;
417 ops->cursor_timer.data = (unsigned long ) info;
418 add_timer(&ops->cursor_timer);
419 ops->flags |= FBCON_FLAGS_CURSOR_TIMER;
423 static void fbcon_del_cursor_timer(struct fb_info *info)
425 struct fbcon_ops *ops = info->fbcon_par;
427 if (info->queue.func == fb_flashcursor &&
428 ops->flags & FBCON_FLAGS_CURSOR_TIMER) {
429 del_timer_sync(&ops->cursor_timer);
430 ops->flags &= ~FBCON_FLAGS_CURSOR_TIMER;
435 static int __init fb_console_setup(char *this_opt)
440 if (!this_opt || !*this_opt)
443 while ((options = strsep(&this_opt, ",")) != NULL) {
444 if (!strncmp(options, "font:", 5))
445 strcpy(fontname, options + 5);
447 if (!strncmp(options, "scrollback:", 11)) {
450 fbcon_softback_size = simple_strtoul(options, &options, 0);
451 if (*options == 'k' || *options == 'K') {
452 fbcon_softback_size *= 1024;
462 if (!strncmp(options, "map:", 4)) {
465 for (i = 0, j = 0; i < MAX_NR_CONSOLES; i++) {
469 (options[j++]-'0') % FB_MAX;
472 fbcon_map_override();
478 if (!strncmp(options, "vc:", 3)) {
481 first_fb_vc = simple_strtoul(options, &options, 10) - 1;
484 if (*options++ == '-')
485 last_fb_vc = simple_strtoul(options, &options, 10) - 1;
486 fbcon_is_default = 0;
489 if (!strncmp(options, "rotate:", 7)) {
492 initial_rotation = simple_strtoul(options, &options, 0);
493 if (initial_rotation > 3)
494 initial_rotation = 0;
500 __setup("fbcon=", fb_console_setup);
503 static int search_fb_in_map(int idx)
507 for (i = first_fb_vc; i <= last_fb_vc; i++) {
508 if (con2fb_map[i] == idx)
514 static int search_for_mapped_con(void)
518 for (i = first_fb_vc; i <= last_fb_vc; i++) {
519 if (con2fb_map[i] != -1)
525 static int fbcon_takeover(int show_logo)
529 if (!num_registered_fb)
533 logo_shown = FBCON_LOGO_DONTSHOW;
535 for (i = first_fb_vc; i <= last_fb_vc; i++)
536 con2fb_map[i] = info_idx;
538 err = take_over_console(&fb_con, first_fb_vc, last_fb_vc,
542 for (i = first_fb_vc; i <= last_fb_vc; i++) {
547 fbcon_has_console_bind = 1;
554 static void fbcon_prepare_logo(struct vc_data *vc, struct fb_info *info,
555 int cols, int rows, int new_cols, int new_rows)
557 logo_shown = FBCON_LOGO_DONTSHOW;
560 static void fbcon_prepare_logo(struct vc_data *vc, struct fb_info *info,
561 int cols, int rows, int new_cols, int new_rows)
563 /* Need to make room for the logo */
564 struct fbcon_ops *ops = info->fbcon_par;
565 int cnt, erase = vc->vc_video_erase_char, step;
566 unsigned short *save = NULL, *r, *q;
569 if (info->flags & FBINFO_MODULE) {
570 logo_shown = FBCON_LOGO_DONTSHOW;
575 * remove underline attribute from erase character
576 * if black and white framebuffer.
578 if (fb_get_color_depth(&info->var, &info->fix) == 1)
580 logo_height = fb_prepare_logo(info, ops->rotate);
581 logo_lines = DIV_ROUND_UP(logo_height, vc->vc_font.height);
582 q = (unsigned short *) (vc->vc_origin +
583 vc->vc_size_row * rows);
584 step = logo_lines * cols;
585 for (r = q - logo_lines * cols; r < q; r++)
586 if (scr_readw(r) != vc->vc_video_erase_char)
588 if (r != q && new_rows >= rows + logo_lines) {
589 save = kmalloc(logo_lines * new_cols * 2, GFP_KERNEL);
591 int i = cols < new_cols ? cols : new_cols;
592 scr_memsetw(save, erase, logo_lines * new_cols * 2);
594 for (cnt = 0; cnt < logo_lines; cnt++, r += i)
595 scr_memcpyw(save + cnt * new_cols, r, 2 * i);
600 /* We can scroll screen down */
602 for (cnt = rows - logo_lines; cnt > 0; cnt--) {
603 scr_memcpyw(r + step, r, vc->vc_size_row);
608 if (vc->vc_y + logo_lines >= rows)
609 lines = rows - vc->vc_y - 1;
613 vc->vc_pos += lines * vc->vc_size_row;
616 scr_memsetw((unsigned short *) vc->vc_origin,
618 vc->vc_size_row * logo_lines);
620 if (CON_IS_VISIBLE(vc) && vc->vc_mode == KD_TEXT) {
621 fbcon_clear_margins(vc, 0);
626 q = (unsigned short *) (vc->vc_origin +
629 scr_memcpyw(q, save, logo_lines * new_cols * 2);
630 vc->vc_y += logo_lines;
631 vc->vc_pos += logo_lines * vc->vc_size_row;
635 if (logo_lines > vc->vc_bottom) {
636 logo_shown = FBCON_LOGO_CANSHOW;
638 "fbcon_init: disable boot-logo (boot-logo bigger than screen).\n");
639 } else if (logo_shown != FBCON_LOGO_DONTSHOW) {
640 logo_shown = FBCON_LOGO_DRAW;
641 vc->vc_top = logo_lines;
646 #ifdef CONFIG_FB_TILEBLITTING
647 static void set_blitting_type(struct vc_data *vc, struct fb_info *info)
649 struct fbcon_ops *ops = info->fbcon_par;
651 ops->p = &fb_display[vc->vc_num];
653 if ((info->flags & FBINFO_MISC_TILEBLITTING))
654 fbcon_set_tileops(vc, info);
656 fbcon_set_rotation(info);
657 fbcon_set_bitops(ops);
661 static int fbcon_invalid_charcount(struct fb_info *info, unsigned charcount)
665 if (info->flags & FBINFO_MISC_TILEBLITTING &&
666 info->tileops->fb_get_tilemax(info) < charcount)
672 static void set_blitting_type(struct vc_data *vc, struct fb_info *info)
674 struct fbcon_ops *ops = info->fbcon_par;
676 info->flags &= ~FBINFO_MISC_TILEBLITTING;
677 ops->p = &fb_display[vc->vc_num];
678 fbcon_set_rotation(info);
679 fbcon_set_bitops(ops);
682 static int fbcon_invalid_charcount(struct fb_info *info, unsigned charcount)
687 #endif /* CONFIG_MISC_TILEBLITTING */
690 static int con2fb_acquire_newinfo(struct vc_data *vc, struct fb_info *info,
691 int unit, int oldidx)
693 struct fbcon_ops *ops = NULL;
696 if (!try_module_get(info->fbops->owner))
699 if (!err && info->fbops->fb_open &&
700 info->fbops->fb_open(info, 0))
704 ops = kzalloc(sizeof(struct fbcon_ops), GFP_KERNEL);
710 info->fbcon_par = ops;
713 set_blitting_type(vc, info);
717 con2fb_map[unit] = oldidx;
718 module_put(info->fbops->owner);
724 static int con2fb_release_oldinfo(struct vc_data *vc, struct fb_info *oldinfo,
725 struct fb_info *newinfo, int unit,
726 int oldidx, int found)
728 struct fbcon_ops *ops = oldinfo->fbcon_par;
731 if (oldinfo->fbops->fb_release &&
732 oldinfo->fbops->fb_release(oldinfo, 0)) {
733 con2fb_map[unit] = oldidx;
734 if (!found && newinfo->fbops->fb_release)
735 newinfo->fbops->fb_release(newinfo, 0);
737 module_put(newinfo->fbops->owner);
742 fbcon_del_cursor_timer(oldinfo);
743 kfree(ops->cursor_state.mask);
744 kfree(ops->cursor_data);
745 kfree(ops->fontbuffer);
746 kfree(oldinfo->fbcon_par);
747 oldinfo->fbcon_par = NULL;
748 module_put(oldinfo->fbops->owner);
750 If oldinfo and newinfo are driving the same hardware,
751 the fb_release() method of oldinfo may attempt to
752 restore the hardware state. This will leave the
753 newinfo in an undefined state. Thus, a call to
754 fb_set_par() may be needed for the newinfo.
756 if (newinfo->fbops->fb_set_par) {
757 ret = newinfo->fbops->fb_set_par(newinfo);
760 printk(KERN_ERR "con2fb_release_oldinfo: "
761 "detected unhandled fb_set_par error, "
762 "error code %d\n", ret);
769 static void con2fb_init_display(struct vc_data *vc, struct fb_info *info,
770 int unit, int show_logo)
772 struct fbcon_ops *ops = info->fbcon_par;
775 ops->currcon = fg_console;
777 if (info->fbops->fb_set_par && !(ops->flags & FBCON_FLAGS_INIT)) {
778 ret = info->fbops->fb_set_par(info);
781 printk(KERN_ERR "con2fb_init_display: detected "
782 "unhandled fb_set_par error, "
783 "error code %d\n", ret);
786 ops->flags |= FBCON_FLAGS_INIT;
788 fbcon_set_disp(info, &info->var, unit);
791 struct vc_data *fg_vc = vc_cons[fg_console].d;
792 struct fb_info *fg_info =
793 registered_fb[con2fb_map[fg_console]];
795 fbcon_prepare_logo(fg_vc, fg_info, fg_vc->vc_cols,
796 fg_vc->vc_rows, fg_vc->vc_cols,
800 update_screen(vc_cons[fg_console].d);
804 * set_con2fb_map - map console to frame buffer device
805 * @unit: virtual console number to map
806 * @newidx: frame buffer index to map virtual console to
807 * @user: user request
809 * Maps a virtual console @unit to a frame buffer device
812 static int set_con2fb_map(int unit, int newidx, int user)
814 struct vc_data *vc = vc_cons[unit].d;
815 int oldidx = con2fb_map[unit];
816 struct fb_info *info = registered_fb[newidx];
817 struct fb_info *oldinfo = NULL;
820 if (oldidx == newidx)
826 if (!search_for_mapped_con() || !con_is_bound(&fb_con)) {
828 return fbcon_takeover(0);
832 oldinfo = registered_fb[oldidx];
834 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))
868 * Low Level Operations
870 /* NOTE: fbcon cannot be __init: it may be called from take_over_console later */
871 static int var_to_display(struct display *disp,
872 struct fb_var_screeninfo *var,
873 struct fb_info *info)
875 disp->xres_virtual = var->xres_virtual;
876 disp->yres_virtual = var->yres_virtual;
877 disp->bits_per_pixel = var->bits_per_pixel;
878 disp->grayscale = var->grayscale;
879 disp->nonstd = var->nonstd;
880 disp->accel_flags = var->accel_flags;
881 disp->height = var->height;
882 disp->width = var->width;
883 disp->red = var->red;
884 disp->green = var->green;
885 disp->blue = var->blue;
886 disp->transp = var->transp;
887 disp->rotate = var->rotate;
888 disp->mode = fb_match_mode(var, &info->modelist);
889 if (disp->mode == NULL)
890 /* This should not happen */
895 static void display_to_var(struct fb_var_screeninfo *var,
896 struct display *disp)
898 fb_videomode_to_var(var, disp->mode);
899 var->xres_virtual = disp->xres_virtual;
900 var->yres_virtual = disp->yres_virtual;
901 var->bits_per_pixel = disp->bits_per_pixel;
902 var->grayscale = disp->grayscale;
903 var->nonstd = disp->nonstd;
904 var->accel_flags = disp->accel_flags;
905 var->height = disp->height;
906 var->width = disp->width;
907 var->red = disp->red;
908 var->green = disp->green;
909 var->blue = disp->blue;
910 var->transp = disp->transp;
911 var->rotate = disp->rotate;
914 static const char *fbcon_startup(void)
916 const char *display_desc = "frame buffer device";
917 struct display *p = &fb_display[fg_console];
918 struct vc_data *vc = vc_cons[fg_console].d;
919 const struct font_desc *font = NULL;
920 struct module *owner;
921 struct fb_info *info = NULL;
922 struct fbcon_ops *ops;
926 * If num_registered_fb is zero, this is a call for the dummy part.
927 * The frame buffer devices weren't initialized yet.
929 if (!num_registered_fb || info_idx == -1)
932 * Instead of blindly using registered_fb[0], we use info_idx, set by
935 info = registered_fb[info_idx];
939 owner = info->fbops->owner;
940 if (!try_module_get(owner))
942 if (info->fbops->fb_open && info->fbops->fb_open(info, 0)) {
947 ops = kzalloc(sizeof(struct fbcon_ops), GFP_KERNEL);
955 ops->cur_rotate = -1;
956 info->fbcon_par = ops;
957 p->con_rotate = initial_rotation;
958 set_blitting_type(vc, info);
960 if (info->fix.type != FB_TYPE_TEXT) {
961 if (fbcon_softback_size) {
965 kmalloc(fbcon_softback_size,
968 fbcon_softback_size = 0;
974 kfree((void *) softback_buf);
980 softback_in = softback_top = softback_curr =
985 /* Setup default font */
987 if (!fontname[0] || !(font = find_font(fontname)))
988 font = get_default_font(info->var.xres,
991 info->pixmap.blit_y);
992 vc->vc_font.width = font->width;
993 vc->vc_font.height = font->height;
994 vc->vc_font.data = (void *)(p->fontdata = font->data);
995 vc->vc_font.charcount = 256; /* FIXME Need to support more fonts */
998 cols = FBCON_SWAP(ops->rotate, info->var.xres, info->var.yres);
999 rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
1000 cols /= vc->vc_font.width;
1001 rows /= vc->vc_font.height;
1002 vc_resize(vc, cols, rows);
1004 DPRINTK("mode: %s\n", info->fix.id);
1005 DPRINTK("visual: %d\n", info->fix.visual);
1006 DPRINTK("res: %dx%d-%d\n", info->var.xres,
1008 info->var.bits_per_pixel);
1010 fbcon_add_cursor_timer(info);
1011 fbcon_has_exited = 0;
1012 return display_desc;
1015 static void fbcon_init(struct vc_data *vc, int init)
1017 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
1018 struct fbcon_ops *ops;
1019 struct vc_data **default_mode = vc->vc_display_fg;
1020 struct vc_data *svc = *default_mode;
1021 struct display *t, *p = &fb_display[vc->vc_num];
1022 int logo = 1, new_rows, new_cols, rows, cols, charcnt = 256;
1025 if (info_idx == -1 || info == NULL)
1030 if (vc != svc || logo_shown == FBCON_LOGO_DONTSHOW ||
1031 (info->fix.type == FB_TYPE_TEXT))
1034 if (var_to_display(p, &info->var, info))
1037 if (!info->fbcon_par)
1038 con2fb_acquire_newinfo(vc, info, vc->vc_num, -1);
1040 /* If we are not the first console on this
1041 fb, copy the font from that console */
1042 t = &fb_display[fg_console];
1045 struct vc_data *fvc = vc_cons[fg_console].d;
1047 vc->vc_font.data = (void *)(p->fontdata =
1049 vc->vc_font.width = fvc->vc_font.width;
1050 vc->vc_font.height = fvc->vc_font.height;
1051 p->userfont = t->userfont;
1054 REFCOUNT(p->fontdata)++;
1056 const struct font_desc *font = NULL;
1058 if (!fontname[0] || !(font = find_font(fontname)))
1059 font = get_default_font(info->var.xres,
1061 info->pixmap.blit_x,
1062 info->pixmap.blit_y);
1063 vc->vc_font.width = font->width;
1064 vc->vc_font.height = font->height;
1065 vc->vc_font.data = (void *)(p->fontdata = font->data);
1066 vc->vc_font.charcount = 256; /* FIXME Need to
1067 support more fonts */
1072 charcnt = FNTCHARCNT(p->fontdata);
1074 vc->vc_panic_force_write = !!(info->flags & FBINFO_CAN_FORCE_OUTPUT);
1075 vc->vc_can_do_color = (fb_get_color_depth(&info->var, &info->fix)!=1);
1076 vc->vc_complement_mask = vc->vc_can_do_color ? 0x7700 : 0x0800;
1077 if (charcnt == 256) {
1078 vc->vc_hi_font_mask = 0;
1080 vc->vc_hi_font_mask = 0x100;
1081 if (vc->vc_can_do_color)
1082 vc->vc_complement_mask <<= 1;
1085 if (!*svc->vc_uni_pagedir_loc)
1086 con_set_default_unimap(svc);
1087 if (!*vc->vc_uni_pagedir_loc)
1088 con_copy_unimap(vc, svc);
1090 ops = info->fbcon_par;
1091 p->con_rotate = initial_rotation;
1092 set_blitting_type(vc, info);
1096 new_cols = FBCON_SWAP(ops->rotate, info->var.xres, info->var.yres);
1097 new_rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
1098 new_cols /= vc->vc_font.width;
1099 new_rows /= vc->vc_font.height;
1102 * We must always set the mode. The mode of the previous console
1103 * driver could be in the same resolution but we are using different
1104 * hardware so we have to initialize the hardware.
1106 * We need to do it in fbcon_init() to prevent screen corruption.
1108 if (CON_IS_VISIBLE(vc) && vc->vc_mode == KD_TEXT) {
1109 if (info->fbops->fb_set_par &&
1110 !(ops->flags & FBCON_FLAGS_INIT)) {
1111 ret = info->fbops->fb_set_par(info);
1114 printk(KERN_ERR "fbcon_init: detected "
1115 "unhandled fb_set_par error, "
1116 "error code %d\n", ret);
1119 ops->flags |= FBCON_FLAGS_INIT;
1124 if ((cap & FBINFO_HWACCEL_COPYAREA) &&
1125 !(cap & FBINFO_HWACCEL_DISABLED))
1126 p->scrollmode = SCROLL_MOVE;
1127 else /* default to something safe */
1128 p->scrollmode = SCROLL_REDRAW;
1131 * ++guenther: console.c:vc_allocate() relies on initializing
1132 * vc_{cols,rows}, but we must not set those if we are only
1133 * resizing the console.
1136 vc->vc_cols = new_cols;
1137 vc->vc_rows = new_rows;
1139 vc_resize(vc, new_cols, new_rows);
1142 fbcon_prepare_logo(vc, info, cols, rows, new_cols, new_rows);
1144 if (vc == svc && softback_buf)
1145 fbcon_update_softback(vc);
1147 if (ops->rotate_font && ops->rotate_font(info, vc)) {
1148 ops->rotate = FB_ROTATE_UR;
1149 set_blitting_type(vc, info);
1152 ops->p = &fb_display[fg_console];
1155 static void fbcon_free_font(struct display *p)
1157 if (p->userfont && p->fontdata && (--REFCOUNT(p->fontdata) == 0))
1158 kfree(p->fontdata - FONT_EXTRA_WORDS * sizeof(int));
1163 static void fbcon_deinit(struct vc_data *vc)
1165 struct display *p = &fb_display[vc->vc_num];
1166 struct fb_info *info;
1167 struct fbcon_ops *ops;
1171 idx = con2fb_map[vc->vc_num];
1176 info = registered_fb[idx];
1181 ops = info->fbcon_par;
1186 if (CON_IS_VISIBLE(vc))
1187 fbcon_del_cursor_timer(info);
1189 ops->flags &= ~FBCON_FLAGS_INIT;
1192 if (!con_is_bound(&fb_con))
1198 /* ====================================================================== */
1200 /* fbcon_XXX routines - interface used by the world
1202 * This system is now divided into two levels because of complications
1203 * caused by hardware scrolling. Top level functions:
1205 * fbcon_bmove(), fbcon_clear(), fbcon_putc(), fbcon_clear_margins()
1207 * handles y values in range [0, scr_height-1] that correspond to real
1208 * screen positions. y_wrap shift means that first line of bitmap may be
1209 * anywhere on this display. These functions convert lineoffsets to
1210 * bitmap offsets and deal with the wrap-around case by splitting blits.
1212 * fbcon_bmove_physical_8() -- These functions fast implementations
1213 * fbcon_clear_physical_8() -- of original fbcon_XXX fns.
1214 * fbcon_putc_physical_8() -- (font width != 8) may be added later
1218 * At the moment fbcon_putc() cannot blit across vertical wrap boundary
1219 * Implies should only really hardware scroll in rows. Only reason for
1220 * restriction is simplicity & efficiency at the moment.
1223 static void fbcon_clear(struct vc_data *vc, int sy, int sx, int height,
1226 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
1227 struct fbcon_ops *ops = info->fbcon_par;
1229 struct display *p = &fb_display[vc->vc_num];
1232 if (fbcon_is_inactive(vc, info))
1235 if (!height || !width)
1238 if (sy < vc->vc_top && vc->vc_top == logo_lines)
1241 /* Split blits that cross physical y_wrap boundary */
1243 y_break = p->vrows - p->yscroll;
1244 if (sy < y_break && sy + height - 1 >= y_break) {
1245 u_int b = y_break - sy;
1246 ops->clear(vc, info, real_y(p, sy), sx, b, width);
1247 ops->clear(vc, info, real_y(p, sy + b), sx, height - b,
1250 ops->clear(vc, info, real_y(p, sy), sx, height, width);
1253 static void fbcon_putcs(struct vc_data *vc, const unsigned short *s,
1254 int count, int ypos, int xpos)
1256 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
1257 struct display *p = &fb_display[vc->vc_num];
1258 struct fbcon_ops *ops = info->fbcon_par;
1260 if (!fbcon_is_inactive(vc, info))
1261 ops->putcs(vc, info, s, count, real_y(p, ypos), xpos,
1262 get_color(vc, info, scr_readw(s), 1),
1263 get_color(vc, info, scr_readw(s), 0));
1266 static void fbcon_putc(struct vc_data *vc, int c, int ypos, int xpos)
1270 scr_writew(c, &chr);
1271 fbcon_putcs(vc, &chr, 1, ypos, xpos);
1274 static void fbcon_clear_margins(struct vc_data *vc, int bottom_only)
1276 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
1277 struct fbcon_ops *ops = info->fbcon_par;
1279 if (!fbcon_is_inactive(vc, info))
1280 ops->clear_margins(vc, info, bottom_only);
1283 static void fbcon_cursor(struct vc_data *vc, int mode)
1285 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
1286 struct fbcon_ops *ops = info->fbcon_par;
1288 int c = scr_readw((u16 *) vc->vc_pos);
1290 if (fbcon_is_inactive(vc, info) || vc->vc_deccm != 1)
1293 if (vc->vc_cursor_type & 0x10)
1294 fbcon_del_cursor_timer(info);
1296 fbcon_add_cursor_timer(info);
1298 ops->cursor_flash = (mode == CM_ERASE) ? 0 : 1;
1299 if (mode & CM_SOFTBACK) {
1300 mode &= ~CM_SOFTBACK;
1304 fbcon_set_origin(vc);
1308 ops->cursor(vc, info, mode, y, get_color(vc, info, c, 1),
1309 get_color(vc, info, c, 0));
1310 vbl_cursor_cnt = CURSOR_DRAW_DELAY;
1313 static int scrollback_phys_max = 0;
1314 static int scrollback_max = 0;
1315 static int scrollback_current = 0;
1317 static void fbcon_set_disp(struct fb_info *info, struct fb_var_screeninfo *var,
1320 struct display *p, *t;
1321 struct vc_data **default_mode, *vc;
1322 struct vc_data *svc;
1323 struct fbcon_ops *ops = info->fbcon_par;
1324 int rows, cols, charcnt = 256;
1326 p = &fb_display[unit];
1328 if (var_to_display(p, var, info))
1331 vc = vc_cons[unit].d;
1336 default_mode = vc->vc_display_fg;
1337 svc = *default_mode;
1338 t = &fb_display[svc->vc_num];
1340 if (!vc->vc_font.data) {
1341 vc->vc_font.data = (void *)(p->fontdata = t->fontdata);
1342 vc->vc_font.width = (*default_mode)->vc_font.width;
1343 vc->vc_font.height = (*default_mode)->vc_font.height;
1344 p->userfont = t->userfont;
1346 REFCOUNT(p->fontdata)++;
1349 charcnt = FNTCHARCNT(p->fontdata);
1351 var->activate = FB_ACTIVATE_NOW;
1352 info->var.activate = var->activate;
1353 var->yoffset = info->var.yoffset;
1354 var->xoffset = info->var.xoffset;
1355 fb_set_var(info, var);
1356 ops->var = info->var;
1357 vc->vc_can_do_color = (fb_get_color_depth(&info->var, &info->fix)!=1);
1358 vc->vc_complement_mask = vc->vc_can_do_color ? 0x7700 : 0x0800;
1359 if (charcnt == 256) {
1360 vc->vc_hi_font_mask = 0;
1362 vc->vc_hi_font_mask = 0x100;
1363 if (vc->vc_can_do_color)
1364 vc->vc_complement_mask <<= 1;
1367 if (!*svc->vc_uni_pagedir_loc)
1368 con_set_default_unimap(svc);
1369 if (!*vc->vc_uni_pagedir_loc)
1370 con_copy_unimap(vc, svc);
1372 cols = FBCON_SWAP(ops->rotate, info->var.xres, info->var.yres);
1373 rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
1374 cols /= vc->vc_font.width;
1375 rows /= vc->vc_font.height;
1376 vc_resize(vc, cols, rows);
1378 if (CON_IS_VISIBLE(vc)) {
1381 fbcon_update_softback(vc);
1385 static __inline__ void ywrap_up(struct vc_data *vc, int count)
1387 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
1388 struct fbcon_ops *ops = info->fbcon_par;
1389 struct display *p = &fb_display[vc->vc_num];
1391 p->yscroll += count;
1392 if (p->yscroll >= p->vrows) /* Deal with wrap */
1393 p->yscroll -= p->vrows;
1394 ops->var.xoffset = 0;
1395 ops->var.yoffset = p->yscroll * vc->vc_font.height;
1396 ops->var.vmode |= FB_VMODE_YWRAP;
1397 ops->update_start(info);
1398 scrollback_max += count;
1399 if (scrollback_max > scrollback_phys_max)
1400 scrollback_max = scrollback_phys_max;
1401 scrollback_current = 0;
1404 static __inline__ void ywrap_down(struct vc_data *vc, int count)
1406 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
1407 struct fbcon_ops *ops = info->fbcon_par;
1408 struct display *p = &fb_display[vc->vc_num];
1410 p->yscroll -= count;
1411 if (p->yscroll < 0) /* Deal with wrap */
1412 p->yscroll += p->vrows;
1413 ops->var.xoffset = 0;
1414 ops->var.yoffset = p->yscroll * vc->vc_font.height;
1415 ops->var.vmode |= FB_VMODE_YWRAP;
1416 ops->update_start(info);
1417 scrollback_max -= count;
1418 if (scrollback_max < 0)
1420 scrollback_current = 0;
1423 static __inline__ void ypan_up(struct vc_data *vc, int count)
1425 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
1426 struct display *p = &fb_display[vc->vc_num];
1427 struct fbcon_ops *ops = info->fbcon_par;
1429 p->yscroll += count;
1430 if (p->yscroll > p->vrows - vc->vc_rows) {
1431 ops->bmove(vc, info, p->vrows - vc->vc_rows,
1432 0, 0, 0, vc->vc_rows, vc->vc_cols);
1433 p->yscroll -= p->vrows - vc->vc_rows;
1436 ops->var.xoffset = 0;
1437 ops->var.yoffset = p->yscroll * vc->vc_font.height;
1438 ops->var.vmode &= ~FB_VMODE_YWRAP;
1439 ops->update_start(info);
1440 fbcon_clear_margins(vc, 1);
1441 scrollback_max += count;
1442 if (scrollback_max > scrollback_phys_max)
1443 scrollback_max = scrollback_phys_max;
1444 scrollback_current = 0;
1447 static __inline__ void ypan_up_redraw(struct vc_data *vc, int t, int count)
1449 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
1450 struct fbcon_ops *ops = info->fbcon_par;
1451 struct display *p = &fb_display[vc->vc_num];
1453 p->yscroll += count;
1455 if (p->yscroll > p->vrows - vc->vc_rows) {
1456 p->yscroll -= p->vrows - vc->vc_rows;
1457 fbcon_redraw_move(vc, p, t + count, vc->vc_rows - count, t);
1460 ops->var.xoffset = 0;
1461 ops->var.yoffset = p->yscroll * vc->vc_font.height;
1462 ops->var.vmode &= ~FB_VMODE_YWRAP;
1463 ops->update_start(info);
1464 fbcon_clear_margins(vc, 1);
1465 scrollback_max += count;
1466 if (scrollback_max > scrollback_phys_max)
1467 scrollback_max = scrollback_phys_max;
1468 scrollback_current = 0;
1471 static __inline__ void ypan_down(struct vc_data *vc, int count)
1473 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
1474 struct display *p = &fb_display[vc->vc_num];
1475 struct fbcon_ops *ops = info->fbcon_par;
1477 p->yscroll -= count;
1478 if (p->yscroll < 0) {
1479 ops->bmove(vc, info, 0, 0, p->vrows - vc->vc_rows,
1480 0, vc->vc_rows, vc->vc_cols);
1481 p->yscroll += p->vrows - vc->vc_rows;
1484 ops->var.xoffset = 0;
1485 ops->var.yoffset = p->yscroll * vc->vc_font.height;
1486 ops->var.vmode &= ~FB_VMODE_YWRAP;
1487 ops->update_start(info);
1488 fbcon_clear_margins(vc, 1);
1489 scrollback_max -= count;
1490 if (scrollback_max < 0)
1492 scrollback_current = 0;
1495 static __inline__ void ypan_down_redraw(struct vc_data *vc, int t, int count)
1497 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
1498 struct fbcon_ops *ops = info->fbcon_par;
1499 struct display *p = &fb_display[vc->vc_num];
1501 p->yscroll -= count;
1503 if (p->yscroll < 0) {
1504 p->yscroll += p->vrows - vc->vc_rows;
1505 fbcon_redraw_move(vc, p, t, vc->vc_rows - count, t + count);
1508 ops->var.xoffset = 0;
1509 ops->var.yoffset = p->yscroll * vc->vc_font.height;
1510 ops->var.vmode &= ~FB_VMODE_YWRAP;
1511 ops->update_start(info);
1512 fbcon_clear_margins(vc, 1);
1513 scrollback_max -= count;
1514 if (scrollback_max < 0)
1516 scrollback_current = 0;
1519 static void fbcon_redraw_softback(struct vc_data *vc, struct display *p,
1522 int count = vc->vc_rows;
1523 unsigned short *d, *s;
1527 d = (u16 *) softback_curr;
1528 if (d == (u16 *) softback_in)
1529 d = (u16 *) vc->vc_origin;
1530 n = softback_curr + delta * vc->vc_size_row;
1531 softback_lines -= delta;
1533 if (softback_curr < softback_top && n < softback_buf) {
1534 n += softback_end - softback_buf;
1535 if (n < softback_top) {
1537 (softback_top - n) / vc->vc_size_row;
1540 } else if (softback_curr >= softback_top
1541 && n < softback_top) {
1543 (softback_top - n) / vc->vc_size_row;
1547 if (softback_curr > softback_in && n >= softback_end) {
1548 n += softback_buf - softback_end;
1549 if (n > softback_in) {
1553 } else if (softback_curr <= softback_in && n > softback_in) {
1558 if (n == softback_curr)
1561 s = (u16 *) softback_curr;
1562 if (s == (u16 *) softback_in)
1563 s = (u16 *) vc->vc_origin;
1565 unsigned short *start;
1569 unsigned short attr = 1;
1572 le = advance_row(s, 1);
1575 if (attr != (c & 0xff00)) {
1578 fbcon_putcs(vc, start, s - start,
1584 if (c == scr_readw(d)) {
1586 fbcon_putcs(vc, start, s - start,
1599 fbcon_putcs(vc, start, s - start, line, x);
1601 if (d == (u16 *) softback_end)
1602 d = (u16 *) softback_buf;
1603 if (d == (u16 *) softback_in)
1604 d = (u16 *) vc->vc_origin;
1605 if (s == (u16 *) softback_end)
1606 s = (u16 *) softback_buf;
1607 if (s == (u16 *) softback_in)
1608 s = (u16 *) vc->vc_origin;
1612 static void fbcon_redraw_move(struct vc_data *vc, struct display *p,
1613 int line, int count, int dy)
1615 unsigned short *s = (unsigned short *)
1616 (vc->vc_origin + vc->vc_size_row * line);
1619 unsigned short *start = s;
1620 unsigned short *le = advance_row(s, 1);
1623 unsigned short attr = 1;
1627 if (attr != (c & 0xff00)) {
1630 fbcon_putcs(vc, start, s - start,
1636 console_conditional_schedule();
1640 fbcon_putcs(vc, start, s - start, dy, x);
1641 console_conditional_schedule();
1646 static void fbcon_redraw_blit(struct vc_data *vc, struct fb_info *info,
1647 struct display *p, int line, int count, int ycount)
1649 int offset = ycount * vc->vc_cols;
1650 unsigned short *d = (unsigned short *)
1651 (vc->vc_origin + vc->vc_size_row * line);
1652 unsigned short *s = d + offset;
1653 struct fbcon_ops *ops = info->fbcon_par;
1656 unsigned short *start = s;
1657 unsigned short *le = advance_row(s, 1);
1664 if (c == scr_readw(d)) {
1666 ops->bmove(vc, info, line + ycount, x,
1667 line, x, 1, s-start);
1677 console_conditional_schedule();
1682 ops->bmove(vc, info, line + ycount, x, line, x, 1,
1684 console_conditional_schedule();
1689 /* NOTE: We subtract two lines from these pointers */
1690 s -= vc->vc_size_row;
1691 d -= vc->vc_size_row;
1696 static void fbcon_redraw(struct vc_data *vc, struct display *p,
1697 int line, int count, int offset)
1699 unsigned short *d = (unsigned short *)
1700 (vc->vc_origin + vc->vc_size_row * line);
1701 unsigned short *s = d + offset;
1704 unsigned short *start = s;
1705 unsigned short *le = advance_row(s, 1);
1708 unsigned short attr = 1;
1712 if (attr != (c & 0xff00)) {
1715 fbcon_putcs(vc, start, s - start,
1721 if (c == scr_readw(d)) {
1723 fbcon_putcs(vc, start, s - start,
1733 console_conditional_schedule();
1738 fbcon_putcs(vc, start, s - start, line, x);
1739 console_conditional_schedule();
1744 /* NOTE: We subtract two lines from these pointers */
1745 s -= vc->vc_size_row;
1746 d -= vc->vc_size_row;
1751 static inline void fbcon_softback_note(struct vc_data *vc, int t,
1756 if (vc->vc_num != fg_console)
1758 p = (unsigned short *) (vc->vc_origin + t * vc->vc_size_row);
1761 scr_memcpyw((u16 *) softback_in, p, vc->vc_size_row);
1763 p = advance_row(p, 1);
1764 softback_in += vc->vc_size_row;
1765 if (softback_in == softback_end)
1766 softback_in = softback_buf;
1767 if (softback_in == softback_top) {
1768 softback_top += vc->vc_size_row;
1769 if (softback_top == softback_end)
1770 softback_top = softback_buf;
1773 softback_curr = softback_in;
1776 static int fbcon_scroll(struct vc_data *vc, int t, int b, int dir,
1779 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
1780 struct display *p = &fb_display[vc->vc_num];
1781 int scroll_partial = info->flags & FBINFO_PARTIAL_PAN_OK;
1783 if (fbcon_is_inactive(vc, info))
1786 fbcon_cursor(vc, CM_ERASE);
1789 * ++Geert: Only use ywrap/ypan if the console is in text mode
1790 * ++Andrew: Only use ypan on hardware text mode when scrolling the
1791 * whole screen (prevents flicker).
1796 if (count > vc->vc_rows) /* Maximum realistic size */
1797 count = vc->vc_rows;
1799 fbcon_softback_note(vc, t, count);
1800 if (logo_shown >= 0)
1802 switch (p->scrollmode) {
1804 fbcon_redraw_blit(vc, info, p, t, b - t - count,
1806 fbcon_clear(vc, b - count, 0, count, vc->vc_cols);
1807 scr_memsetw((unsigned short *) (vc->vc_origin +
1810 vc->vc_video_erase_char,
1811 vc->vc_size_row * count);
1815 case SCROLL_WRAP_MOVE:
1816 if (b - t - count > 3 * vc->vc_rows >> 2) {
1818 fbcon_bmove(vc, 0, 0, count, 0, t,
1820 ywrap_up(vc, count);
1821 if (vc->vc_rows - b > 0)
1822 fbcon_bmove(vc, b - count, 0, b, 0,
1825 } else if (info->flags & FBINFO_READS_FAST)
1826 fbcon_bmove(vc, t + count, 0, t, 0,
1827 b - t - count, vc->vc_cols);
1830 fbcon_clear(vc, b - count, 0, count, vc->vc_cols);
1833 case SCROLL_PAN_REDRAW:
1834 if ((p->yscroll + count <=
1835 2 * (p->vrows - vc->vc_rows))
1836 && ((!scroll_partial && (b - t == vc->vc_rows))
1839 3 * vc->vc_rows >> 2)))) {
1841 fbcon_redraw_move(vc, p, 0, t, count);
1842 ypan_up_redraw(vc, t, count);
1843 if (vc->vc_rows - b > 0)
1844 fbcon_redraw_move(vc, p, b,
1845 vc->vc_rows - b, b);
1847 fbcon_redraw_move(vc, p, t + count, b - t - count, t);
1848 fbcon_clear(vc, b - count, 0, count, vc->vc_cols);
1851 case SCROLL_PAN_MOVE:
1852 if ((p->yscroll + count <=
1853 2 * (p->vrows - vc->vc_rows))
1854 && ((!scroll_partial && (b - t == vc->vc_rows))
1857 3 * vc->vc_rows >> 2)))) {
1859 fbcon_bmove(vc, 0, 0, count, 0, t,
1862 if (vc->vc_rows - b > 0)
1863 fbcon_bmove(vc, b - count, 0, b, 0,
1866 } else if (info->flags & FBINFO_READS_FAST)
1867 fbcon_bmove(vc, t + count, 0, t, 0,
1868 b - t - count, vc->vc_cols);
1871 fbcon_clear(vc, b - count, 0, count, vc->vc_cols);
1876 fbcon_redraw(vc, p, t, b - t - count,
1877 count * vc->vc_cols);
1878 fbcon_clear(vc, b - count, 0, count, vc->vc_cols);
1879 scr_memsetw((unsigned short *) (vc->vc_origin +
1882 vc->vc_video_erase_char,
1883 vc->vc_size_row * count);
1889 if (count > vc->vc_rows) /* Maximum realistic size */
1890 count = vc->vc_rows;
1891 if (logo_shown >= 0)
1893 switch (p->scrollmode) {
1895 fbcon_redraw_blit(vc, info, p, b - 1, b - t - count,
1897 fbcon_clear(vc, t, 0, count, vc->vc_cols);
1898 scr_memsetw((unsigned short *) (vc->vc_origin +
1901 vc->vc_video_erase_char,
1902 vc->vc_size_row * count);
1906 case SCROLL_WRAP_MOVE:
1907 if (b - t - count > 3 * vc->vc_rows >> 2) {
1908 if (vc->vc_rows - b > 0)
1909 fbcon_bmove(vc, b, 0, b - count, 0,
1912 ywrap_down(vc, count);
1914 fbcon_bmove(vc, count, 0, 0, 0, t,
1916 } else if (info->flags & FBINFO_READS_FAST)
1917 fbcon_bmove(vc, t, 0, t + count, 0,
1918 b - t - count, vc->vc_cols);
1921 fbcon_clear(vc, t, 0, count, vc->vc_cols);
1924 case SCROLL_PAN_MOVE:
1925 if ((count - p->yscroll <= p->vrows - vc->vc_rows)
1926 && ((!scroll_partial && (b - t == vc->vc_rows))
1929 3 * vc->vc_rows >> 2)))) {
1930 if (vc->vc_rows - b > 0)
1931 fbcon_bmove(vc, b, 0, b - count, 0,
1934 ypan_down(vc, count);
1936 fbcon_bmove(vc, count, 0, 0, 0, t,
1938 } else if (info->flags & FBINFO_READS_FAST)
1939 fbcon_bmove(vc, t, 0, t + count, 0,
1940 b - t - count, vc->vc_cols);
1943 fbcon_clear(vc, t, 0, count, vc->vc_cols);
1946 case SCROLL_PAN_REDRAW:
1947 if ((count - p->yscroll <= p->vrows - vc->vc_rows)
1948 && ((!scroll_partial && (b - t == vc->vc_rows))
1951 3 * vc->vc_rows >> 2)))) {
1952 if (vc->vc_rows - b > 0)
1953 fbcon_redraw_move(vc, p, b, vc->vc_rows - b,
1955 ypan_down_redraw(vc, t, count);
1957 fbcon_redraw_move(vc, p, count, t, 0);
1959 fbcon_redraw_move(vc, p, t, b - t - count, t + count);
1960 fbcon_clear(vc, t, 0, count, vc->vc_cols);
1965 fbcon_redraw(vc, p, b - 1, b - t - count,
1966 -count * vc->vc_cols);
1967 fbcon_clear(vc, t, 0, count, vc->vc_cols);
1968 scr_memsetw((unsigned short *) (vc->vc_origin +
1971 vc->vc_video_erase_char,
1972 vc->vc_size_row * count);
1980 static void fbcon_bmove(struct vc_data *vc, int sy, int sx, int dy, int dx,
1981 int height, int width)
1983 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
1984 struct display *p = &fb_display[vc->vc_num];
1986 if (fbcon_is_inactive(vc, info))
1989 if (!width || !height)
1992 /* Split blits that cross physical y_wrap case.
1993 * Pathological case involves 4 blits, better to use recursive
1994 * code rather than unrolled case
1996 * Recursive invocations don't need to erase the cursor over and
1997 * over again, so we use fbcon_bmove_rec()
1999 fbcon_bmove_rec(vc, p, sy, sx, dy, dx, height, width,
2000 p->vrows - p->yscroll);
2003 static void fbcon_bmove_rec(struct vc_data *vc, struct display *p, int sy, int sx,
2004 int dy, int dx, int height, int width, u_int y_break)
2006 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
2007 struct fbcon_ops *ops = info->fbcon_par;
2010 if (sy < y_break && sy + height > y_break) {
2012 if (dy < sy) { /* Avoid trashing self */
2013 fbcon_bmove_rec(vc, p, sy, sx, dy, dx, b, width,
2015 fbcon_bmove_rec(vc, p, sy + b, sx, dy + b, dx,
2016 height - b, width, y_break);
2018 fbcon_bmove_rec(vc, p, sy + b, sx, dy + b, dx,
2019 height - b, width, y_break);
2020 fbcon_bmove_rec(vc, p, sy, sx, dy, dx, b, width,
2026 if (dy < y_break && dy + height > y_break) {
2028 if (dy < sy) { /* Avoid trashing self */
2029 fbcon_bmove_rec(vc, p, sy, sx, dy, dx, b, width,
2031 fbcon_bmove_rec(vc, p, sy + b, sx, dy + b, dx,
2032 height - b, width, y_break);
2034 fbcon_bmove_rec(vc, p, sy + b, sx, dy + b, dx,
2035 height - b, width, y_break);
2036 fbcon_bmove_rec(vc, p, sy, sx, dy, dx, b, width,
2041 ops->bmove(vc, info, real_y(p, sy), sx, real_y(p, dy), dx,
2045 static void updatescrollmode(struct display *p,
2046 struct fb_info *info,
2049 struct fbcon_ops *ops = info->fbcon_par;
2050 int fh = vc->vc_font.height;
2051 int cap = info->flags;
2053 int ypan = FBCON_SWAP(ops->rotate, info->fix.ypanstep,
2054 info->fix.xpanstep);
2055 int ywrap = FBCON_SWAP(ops->rotate, info->fix.ywrapstep, t);
2056 int yres = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
2057 int vyres = FBCON_SWAP(ops->rotate, info->var.yres_virtual,
2058 info->var.xres_virtual);
2059 int good_pan = (cap & FBINFO_HWACCEL_YPAN) &&
2060 divides(ypan, vc->vc_font.height) && vyres > yres;
2061 int good_wrap = (cap & FBINFO_HWACCEL_YWRAP) &&
2062 divides(ywrap, vc->vc_font.height) &&
2063 divides(vc->vc_font.height, vyres) &&
2064 divides(vc->vc_font.height, yres);
2065 int reading_fast = cap & FBINFO_READS_FAST;
2066 int fast_copyarea = (cap & FBINFO_HWACCEL_COPYAREA) &&
2067 !(cap & FBINFO_HWACCEL_DISABLED);
2068 int fast_imageblit = (cap & FBINFO_HWACCEL_IMAGEBLIT) &&
2069 !(cap & FBINFO_HWACCEL_DISABLED);
2071 p->vrows = vyres/fh;
2072 if (yres > (fh * (vc->vc_rows + 1)))
2073 p->vrows -= (yres - (fh * vc->vc_rows)) / fh;
2074 if ((yres % fh) && (vyres % fh < yres % fh))
2077 if (good_wrap || good_pan) {
2078 if (reading_fast || fast_copyarea)
2079 p->scrollmode = good_wrap ?
2080 SCROLL_WRAP_MOVE : SCROLL_PAN_MOVE;
2082 p->scrollmode = good_wrap ? SCROLL_REDRAW :
2085 if (reading_fast || (fast_copyarea && !fast_imageblit))
2086 p->scrollmode = SCROLL_MOVE;
2088 p->scrollmode = SCROLL_REDRAW;
2092 static int fbcon_resize(struct vc_data *vc, unsigned int width,
2093 unsigned int height, unsigned int user)
2095 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
2096 struct fbcon_ops *ops = info->fbcon_par;
2097 struct display *p = &fb_display[vc->vc_num];
2098 struct fb_var_screeninfo var = info->var;
2099 int x_diff, y_diff, virt_w, virt_h, virt_fw, virt_fh;
2101 virt_w = FBCON_SWAP(ops->rotate, width, height);
2102 virt_h = FBCON_SWAP(ops->rotate, height, width);
2103 virt_fw = FBCON_SWAP(ops->rotate, vc->vc_font.width,
2104 vc->vc_font.height);
2105 virt_fh = FBCON_SWAP(ops->rotate, vc->vc_font.height,
2107 var.xres = virt_w * virt_fw;
2108 var.yres = virt_h * virt_fh;
2109 x_diff = info->var.xres - var.xres;
2110 y_diff = info->var.yres - var.yres;
2111 if (x_diff < 0 || x_diff > virt_fw ||
2112 y_diff < 0 || y_diff > virt_fh) {
2113 const struct fb_videomode *mode;
2115 DPRINTK("attempting resize %ix%i\n", var.xres, var.yres);
2116 mode = fb_find_best_mode(&var, &info->modelist);
2119 display_to_var(&var, p);
2120 fb_videomode_to_var(&var, mode);
2122 if (virt_w > var.xres/virt_fw || virt_h > var.yres/virt_fh)
2125 DPRINTK("resize now %ix%i\n", var.xres, var.yres);
2126 if (CON_IS_VISIBLE(vc)) {
2127 var.activate = FB_ACTIVATE_NOW |
2129 fb_set_var(info, &var);
2131 var_to_display(p, &info->var, info);
2132 ops->var = info->var;
2134 updatescrollmode(p, info, vc);
2138 static int fbcon_switch(struct vc_data *vc)
2140 struct fb_info *info, *old_info = NULL;
2141 struct fbcon_ops *ops;
2142 struct display *p = &fb_display[vc->vc_num];
2143 struct fb_var_screeninfo var;
2144 int i, ret, prev_console, charcnt = 256;
2146 info = registered_fb[con2fb_map[vc->vc_num]];
2147 ops = info->fbcon_par;
2151 fbcon_set_origin(vc);
2152 softback_top = softback_curr = softback_in = softback_buf;
2154 fbcon_update_softback(vc);
2157 if (logo_shown >= 0) {
2158 struct vc_data *conp2 = vc_cons[logo_shown].d;
2160 if (conp2->vc_top == logo_lines
2161 && conp2->vc_bottom == conp2->vc_rows)
2163 logo_shown = FBCON_LOGO_CANSHOW;
2166 prev_console = ops->currcon;
2167 if (prev_console != -1)
2168 old_info = registered_fb[con2fb_map[prev_console]];
2170 * FIXME: If we have multiple fbdev's loaded, we need to
2171 * update all info->currcon. Perhaps, we can place this
2172 * in a centralized structure, but this might break some
2175 * info->currcon = vc->vc_num;
2177 for (i = 0; i < FB_MAX; i++) {
2178 if (registered_fb[i] != NULL && registered_fb[i]->fbcon_par) {
2179 struct fbcon_ops *o = registered_fb[i]->fbcon_par;
2181 o->currcon = vc->vc_num;
2184 memset(&var, 0, sizeof(struct fb_var_screeninfo));
2185 display_to_var(&var, p);
2186 var.activate = FB_ACTIVATE_NOW;
2189 * make sure we don't unnecessarily trip the memcmp()
2192 info->var.activate = var.activate;
2193 var.vmode |= info->var.vmode & ~FB_VMODE_MASK;
2194 fb_set_var(info, &var);
2195 ops->var = info->var;
2197 if (old_info != NULL && (old_info != info ||
2198 info->flags & FBINFO_MISC_ALWAYS_SETPAR)) {
2199 if (info->fbops->fb_set_par) {
2200 ret = info->fbops->fb_set_par(info);
2203 printk(KERN_ERR "fbcon_switch: detected "
2204 "unhandled fb_set_par error, "
2205 "error code %d\n", ret);
2208 if (old_info != info)
2209 fbcon_del_cursor_timer(old_info);
2212 if (fbcon_is_inactive(vc, info) ||
2213 ops->blank_state != FB_BLANK_UNBLANK)
2214 fbcon_del_cursor_timer(info);
2216 fbcon_add_cursor_timer(info);
2218 set_blitting_type(vc, info);
2219 ops->cursor_reset = 1;
2221 if (ops->rotate_font && ops->rotate_font(info, vc)) {
2222 ops->rotate = FB_ROTATE_UR;
2223 set_blitting_type(vc, info);
2226 vc->vc_can_do_color = (fb_get_color_depth(&info->var, &info->fix)!=1);
2227 vc->vc_complement_mask = vc->vc_can_do_color ? 0x7700 : 0x0800;
2230 charcnt = FNTCHARCNT(vc->vc_font.data);
2233 vc->vc_complement_mask <<= 1;
2235 updatescrollmode(p, info, vc);
2237 switch (p->scrollmode) {
2238 case SCROLL_WRAP_MOVE:
2239 scrollback_phys_max = p->vrows - vc->vc_rows;
2241 case SCROLL_PAN_MOVE:
2242 case SCROLL_PAN_REDRAW:
2243 scrollback_phys_max = p->vrows - 2 * vc->vc_rows;
2244 if (scrollback_phys_max < 0)
2245 scrollback_phys_max = 0;
2248 scrollback_phys_max = 0;
2253 scrollback_current = 0;
2255 if (!fbcon_is_inactive(vc, info)) {
2256 ops->var.xoffset = ops->var.yoffset = p->yscroll = 0;
2257 ops->update_start(info);
2260 fbcon_set_palette(vc, color_table);
2261 fbcon_clear_margins(vc, 0);
2263 if (logo_shown == FBCON_LOGO_DRAW) {
2265 logo_shown = fg_console;
2266 /* This is protected above by initmem_freed */
2267 fb_show_logo(info, ops->rotate);
2269 vc->vc_origin + vc->vc_size_row * vc->vc_top,
2270 vc->vc_size_row * (vc->vc_bottom -
2277 static void fbcon_generic_blank(struct vc_data *vc, struct fb_info *info,
2280 struct fb_event event;
2283 unsigned short charmask = vc->vc_hi_font_mask ?
2285 unsigned short oldc;
2287 oldc = vc->vc_video_erase_char;
2288 vc->vc_video_erase_char &= charmask;
2289 fbcon_clear(vc, 0, 0, vc->vc_rows, vc->vc_cols);
2290 vc->vc_video_erase_char = oldc;
2294 if (!lock_fb_info(info))
2297 event.data = ␣
2298 fb_notifier_call_chain(FB_EVENT_CONBLANK, &event);
2299 unlock_fb_info(info);
2302 static int fbcon_blank(struct vc_data *vc, int blank, int mode_switch)
2304 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
2305 struct fbcon_ops *ops = info->fbcon_par;
2308 struct fb_var_screeninfo var = info->var;
2313 var.activate = FB_ACTIVATE_NOW | FB_ACTIVATE_FORCE;
2314 fb_set_var(info, &var);
2316 ops->var = info->var;
2320 if (!fbcon_is_inactive(vc, info)) {
2321 if (ops->blank_state != blank) {
2322 ops->blank_state = blank;
2323 fbcon_cursor(vc, blank ? CM_ERASE : CM_DRAW);
2324 ops->cursor_flash = (!blank);
2326 if (!(info->flags & FBINFO_MISC_USEREVENT))
2327 if (fb_blank(info, blank))
2328 fbcon_generic_blank(vc, info, blank);
2335 if (mode_switch || fbcon_is_inactive(vc, info) ||
2336 ops->blank_state != FB_BLANK_UNBLANK)
2337 fbcon_del_cursor_timer(info);
2339 fbcon_add_cursor_timer(info);
2344 static int fbcon_debug_enter(struct vc_data *vc)
2346 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
2347 struct fbcon_ops *ops = info->fbcon_par;
2349 ops->save_graphics = ops->graphics;
2351 if (info->fbops->fb_debug_enter)
2352 info->fbops->fb_debug_enter(info);
2353 fbcon_set_palette(vc, color_table);
2357 static int fbcon_debug_leave(struct vc_data *vc)
2359 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
2360 struct fbcon_ops *ops = info->fbcon_par;
2362 ops->graphics = ops->save_graphics;
2363 if (info->fbops->fb_debug_leave)
2364 info->fbops->fb_debug_leave(info);
2368 static int fbcon_get_font(struct vc_data *vc, struct console_font *font)
2370 u8 *fontdata = vc->vc_font.data;
2371 u8 *data = font->data;
2374 font->width = vc->vc_font.width;
2375 font->height = vc->vc_font.height;
2376 font->charcount = vc->vc_hi_font_mask ? 512 : 256;
2380 if (font->width <= 8) {
2381 j = vc->vc_font.height;
2382 for (i = 0; i < font->charcount; i++) {
2383 memcpy(data, fontdata, j);
2384 memset(data + j, 0, 32 - j);
2388 } else if (font->width <= 16) {
2389 j = vc->vc_font.height * 2;
2390 for (i = 0; i < font->charcount; i++) {
2391 memcpy(data, fontdata, j);
2392 memset(data + j, 0, 64 - j);
2396 } else if (font->width <= 24) {
2397 for (i = 0; i < font->charcount; i++) {
2398 for (j = 0; j < vc->vc_font.height; j++) {
2399 *data++ = fontdata[0];
2400 *data++ = fontdata[1];
2401 *data++ = fontdata[2];
2402 fontdata += sizeof(u32);
2404 memset(data, 0, 3 * (32 - j));
2405 data += 3 * (32 - j);
2408 j = vc->vc_font.height * 4;
2409 for (i = 0; i < font->charcount; i++) {
2410 memcpy(data, fontdata, j);
2411 memset(data + j, 0, 128 - j);
2419 static int fbcon_do_set_font(struct vc_data *vc, int w, int h,
2420 const u8 * data, int userfont)
2422 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
2423 struct fbcon_ops *ops = info->fbcon_par;
2424 struct display *p = &fb_display[vc->vc_num];
2427 char *old_data = NULL;
2429 if (CON_IS_VISIBLE(vc) && softback_lines)
2430 fbcon_set_origin(vc);
2432 resize = (w != vc->vc_font.width) || (h != vc->vc_font.height);
2434 old_data = vc->vc_font.data;
2436 cnt = FNTCHARCNT(data);
2439 vc->vc_font.data = (void *)(p->fontdata = data);
2440 if ((p->userfont = userfont))
2442 vc->vc_font.width = w;
2443 vc->vc_font.height = h;
2444 if (vc->vc_hi_font_mask && cnt == 256) {
2445 vc->vc_hi_font_mask = 0;
2446 if (vc->vc_can_do_color) {
2447 vc->vc_complement_mask >>= 1;
2448 vc->vc_s_complement_mask >>= 1;
2451 /* ++Edmund: reorder the attribute bits */
2452 if (vc->vc_can_do_color) {
2453 unsigned short *cp =
2454 (unsigned short *) vc->vc_origin;
2455 int count = vc->vc_screenbuf_size / 2;
2457 for (; count > 0; count--, cp++) {
2459 scr_writew(((c & 0xfe00) >> 1) |
2462 c = vc->vc_video_erase_char;
2463 vc->vc_video_erase_char =
2464 ((c & 0xfe00) >> 1) | (c & 0xff);
2467 } else if (!vc->vc_hi_font_mask && cnt == 512) {
2468 vc->vc_hi_font_mask = 0x100;
2469 if (vc->vc_can_do_color) {
2470 vc->vc_complement_mask <<= 1;
2471 vc->vc_s_complement_mask <<= 1;
2474 /* ++Edmund: reorder the attribute bits */
2476 unsigned short *cp =
2477 (unsigned short *) vc->vc_origin;
2478 int count = vc->vc_screenbuf_size / 2;
2480 for (; count > 0; count--, cp++) {
2481 unsigned short newc;
2483 if (vc->vc_can_do_color)
2485 ((c & 0xff00) << 1) | (c &
2489 scr_writew(newc, cp);
2491 c = vc->vc_video_erase_char;
2492 if (vc->vc_can_do_color) {
2493 vc->vc_video_erase_char =
2494 ((c & 0xff00) << 1) | (c & 0xff);
2497 vc->vc_video_erase_char = c & ~0x100;
2505 cols = FBCON_SWAP(ops->rotate, info->var.xres, info->var.yres);
2506 rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
2509 vc_resize(vc, cols, rows);
2510 if (CON_IS_VISIBLE(vc) && softback_buf)
2511 fbcon_update_softback(vc);
2512 } else if (CON_IS_VISIBLE(vc)
2513 && vc->vc_mode == KD_TEXT) {
2514 fbcon_clear_margins(vc, 0);
2518 if (old_data && (--REFCOUNT(old_data) == 0))
2519 kfree(old_data - FONT_EXTRA_WORDS * sizeof(int));
2523 static int fbcon_copy_font(struct vc_data *vc, int con)
2525 struct display *od = &fb_display[con];
2526 struct console_font *f = &vc->vc_font;
2528 if (od->fontdata == f->data)
2529 return 0; /* already the same font... */
2530 return fbcon_do_set_font(vc, f->width, f->height, od->fontdata, od->userfont);
2534 * User asked to set font; we are guaranteed that
2535 * a) width and height are in range 1..32
2536 * b) charcount does not exceed 512
2537 * but lets not assume that, since someone might someday want to use larger
2538 * fonts. And charcount of 512 is small for unicode support.
2540 * However, user space gives the font in 32 rows , regardless of
2541 * actual font height. So a new API is needed if support for larger fonts
2542 * is ever implemented.
2545 static int fbcon_set_font(struct vc_data *vc, struct console_font *font, unsigned flags)
2547 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
2548 unsigned charcount = font->charcount;
2549 int w = font->width;
2550 int h = font->height;
2553 u8 *new_data, *data = font->data;
2554 int pitch = (font->width+7) >> 3;
2556 /* Is there a reason why fbconsole couldn't handle any charcount >256?
2557 * If not this check should be changed to charcount < 256 */
2558 if (charcount != 256 && charcount != 512)
2561 /* Make sure drawing engine can handle the font */
2562 if (!(info->pixmap.blit_x & (1 << (font->width - 1))) ||
2563 !(info->pixmap.blit_y & (1 << (font->height - 1))))
2566 /* Make sure driver can handle the font length */
2567 if (fbcon_invalid_charcount(info, charcount))
2570 size = h * pitch * charcount;
2572 new_data = kmalloc(FONT_EXTRA_WORDS * sizeof(int) + size, GFP_USER);
2577 new_data += FONT_EXTRA_WORDS * sizeof(int);
2578 FNTSIZE(new_data) = size;
2579 FNTCHARCNT(new_data) = charcount;
2580 REFCOUNT(new_data) = 0; /* usage counter */
2581 for (i=0; i< charcount; i++) {
2582 memcpy(new_data + i*h*pitch, data + i*32*pitch, h*pitch);
2585 /* Since linux has a nice crc32 function use it for counting font
2587 csum = crc32(0, new_data, size);
2589 FNTSUM(new_data) = csum;
2590 /* Check if the same font is on some other console already */
2591 for (i = first_fb_vc; i <= last_fb_vc; i++) {
2592 struct vc_data *tmp = vc_cons[i].d;
2594 if (fb_display[i].userfont &&
2595 fb_display[i].fontdata &&
2596 FNTSUM(fb_display[i].fontdata) == csum &&
2597 FNTSIZE(fb_display[i].fontdata) == size &&
2598 tmp->vc_font.width == w &&
2599 !memcmp(fb_display[i].fontdata, new_data, size)) {
2600 kfree(new_data - FONT_EXTRA_WORDS * sizeof(int));
2601 new_data = (u8 *)fb_display[i].fontdata;
2605 return fbcon_do_set_font(vc, font->width, font->height, new_data, 1);
2608 static int fbcon_set_def_font(struct vc_data *vc, struct console_font *font, char *name)
2610 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
2611 const struct font_desc *f;
2614 f = get_default_font(info->var.xres, info->var.yres,
2615 info->pixmap.blit_x, info->pixmap.blit_y);
2616 else if (!(f = find_font(name)))
2619 font->width = f->width;
2620 font->height = f->height;
2621 return fbcon_do_set_font(vc, f->width, f->height, f->data, 0);
2624 static u16 palette_red[16];
2625 static u16 palette_green[16];
2626 static u16 palette_blue[16];
2628 static struct fb_cmap palette_cmap = {
2629 0, 16, palette_red, palette_green, palette_blue, NULL
2632 static int fbcon_set_palette(struct vc_data *vc, unsigned char *table)
2634 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
2638 if (fbcon_is_inactive(vc, info))
2641 if (!CON_IS_VISIBLE(vc))
2644 depth = fb_get_color_depth(&info->var, &info->fix);
2646 for (i = j = 0; i < 16; i++) {
2648 val = vc->vc_palette[j++];
2649 palette_red[k] = (val << 8) | val;
2650 val = vc->vc_palette[j++];
2651 palette_green[k] = (val << 8) | val;
2652 val = vc->vc_palette[j++];
2653 palette_blue[k] = (val << 8) | val;
2655 palette_cmap.len = 16;
2656 palette_cmap.start = 0;
2658 * If framebuffer is capable of less than 16 colors,
2659 * use default palette of fbcon.
2662 fb_copy_cmap(fb_default_cmap(1 << depth), &palette_cmap);
2664 return fb_set_cmap(&palette_cmap, info);
2667 static u16 *fbcon_screen_pos(struct vc_data *vc, int offset)
2672 if (vc->vc_num != fg_console || !softback_lines)
2673 return (u16 *) (vc->vc_origin + offset);
2674 line = offset / vc->vc_size_row;
2675 if (line >= softback_lines)
2676 return (u16 *) (vc->vc_origin + offset -
2677 softback_lines * vc->vc_size_row);
2678 p = softback_curr + offset;
2679 if (p >= softback_end)
2680 p += softback_buf - softback_end;
2684 static unsigned long fbcon_getxy(struct vc_data *vc, unsigned long pos,
2690 if (pos >= vc->vc_origin && pos < vc->vc_scr_end) {
2691 unsigned long offset = (pos - vc->vc_origin) / 2;
2693 x = offset % vc->vc_cols;
2694 y = offset / vc->vc_cols;
2695 if (vc->vc_num == fg_console)
2696 y += softback_lines;
2697 ret = pos + (vc->vc_cols - x) * 2;
2698 } else if (vc->vc_num == fg_console && softback_lines) {
2699 unsigned long offset = pos - softback_curr;
2701 if (pos < softback_curr)
2702 offset += softback_end - softback_buf;
2704 x = offset % vc->vc_cols;
2705 y = offset / vc->vc_cols;
2706 ret = pos + (vc->vc_cols - x) * 2;
2707 if (ret == softback_end)
2709 if (ret == softback_in)
2710 ret = vc->vc_origin;
2712 /* Should not happen */
2714 ret = vc->vc_origin;
2723 /* As we might be inside of softback, we may work with non-contiguous buffer,
2724 that's why we have to use a separate routine. */
2725 static void fbcon_invert_region(struct vc_data *vc, u16 * p, int cnt)
2728 u16 a = scr_readw(p);
2729 if (!vc->vc_can_do_color)
2731 else if (vc->vc_hi_font_mask == 0x100)
2732 a = ((a) & 0x11ff) | (((a) & 0xe000) >> 4) |
2733 (((a) & 0x0e00) << 4);
2735 a = ((a) & 0x88ff) | (((a) & 0x7000) >> 4) |
2736 (((a) & 0x0700) << 4);
2738 if (p == (u16 *) softback_end)
2739 p = (u16 *) softback_buf;
2740 if (p == (u16 *) softback_in)
2741 p = (u16 *) vc->vc_origin;
2745 static int fbcon_scrolldelta(struct vc_data *vc, int lines)
2747 struct fb_info *info = registered_fb[con2fb_map[fg_console]];
2748 struct fbcon_ops *ops = info->fbcon_par;
2749 struct display *disp = &fb_display[fg_console];
2750 int offset, limit, scrollback_old;
2753 if (vc->vc_num != fg_console)
2755 if (vc->vc_mode != KD_TEXT || !lines)
2757 if (logo_shown >= 0) {
2758 struct vc_data *conp2 = vc_cons[logo_shown].d;
2760 if (conp2->vc_top == logo_lines
2761 && conp2->vc_bottom == conp2->vc_rows)
2763 if (logo_shown == vc->vc_num) {
2769 logo_lines * vc->vc_size_row;
2770 for (i = 0; i < logo_lines; i++) {
2771 if (p == softback_top)
2773 if (p == softback_buf)
2775 p -= vc->vc_size_row;
2776 q -= vc->vc_size_row;
2777 scr_memcpyw((u16 *) q, (u16 *) p,
2780 softback_in = softback_curr = p;
2781 update_region(vc, vc->vc_origin,
2782 logo_lines * vc->vc_cols);
2784 logo_shown = FBCON_LOGO_CANSHOW;
2786 fbcon_cursor(vc, CM_ERASE | CM_SOFTBACK);
2787 fbcon_redraw_softback(vc, disp, lines);
2788 fbcon_cursor(vc, CM_DRAW | CM_SOFTBACK);
2792 if (!scrollback_phys_max)
2795 scrollback_old = scrollback_current;
2796 scrollback_current -= lines;
2797 if (scrollback_current < 0)
2798 scrollback_current = 0;
2799 else if (scrollback_current > scrollback_max)
2800 scrollback_current = scrollback_max;
2801 if (scrollback_current == scrollback_old)
2804 if (fbcon_is_inactive(vc, info))
2807 fbcon_cursor(vc, CM_ERASE);
2809 offset = disp->yscroll - scrollback_current;
2810 limit = disp->vrows;
2811 switch (disp->scrollmode) {
2812 case SCROLL_WRAP_MOVE:
2813 info->var.vmode |= FB_VMODE_YWRAP;
2815 case SCROLL_PAN_MOVE:
2816 case SCROLL_PAN_REDRAW:
2817 limit -= vc->vc_rows;
2818 info->var.vmode &= ~FB_VMODE_YWRAP;
2823 else if (offset >= limit)
2826 ops->var.xoffset = 0;
2827 ops->var.yoffset = offset * vc->vc_font.height;
2828 ops->update_start(info);
2830 if (!scrollback_current)
2831 fbcon_cursor(vc, CM_DRAW);
2835 static int fbcon_set_origin(struct vc_data *vc)
2838 fbcon_scrolldelta(vc, softback_lines);
2842 static void fbcon_suspended(struct fb_info *info)
2844 struct vc_data *vc = NULL;
2845 struct fbcon_ops *ops = info->fbcon_par;
2847 if (!ops || ops->currcon < 0)
2849 vc = vc_cons[ops->currcon].d;
2851 /* Clear cursor, restore saved data */
2852 fbcon_cursor(vc, CM_ERASE);
2855 static void fbcon_resumed(struct fb_info *info)
2858 struct fbcon_ops *ops = info->fbcon_par;
2860 if (!ops || ops->currcon < 0)
2862 vc = vc_cons[ops->currcon].d;
2867 static void fbcon_modechanged(struct fb_info *info)
2869 struct fbcon_ops *ops = info->fbcon_par;
2874 if (!ops || ops->currcon < 0)
2876 vc = vc_cons[ops->currcon].d;
2877 if (vc->vc_mode != KD_TEXT ||
2878 registered_fb[con2fb_map[ops->currcon]] != info)
2881 p = &fb_display[vc->vc_num];
2882 set_blitting_type(vc, info);
2884 if (CON_IS_VISIBLE(vc)) {
2885 var_to_display(p, &info->var, info);
2886 cols = FBCON_SWAP(ops->rotate, info->var.xres, info->var.yres);
2887 rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
2888 cols /= vc->vc_font.width;
2889 rows /= vc->vc_font.height;
2890 vc_resize(vc, cols, rows);
2891 updatescrollmode(p, info, vc);
2893 scrollback_current = 0;
2895 if (!fbcon_is_inactive(vc, info)) {
2896 ops->var.xoffset = ops->var.yoffset = p->yscroll = 0;
2897 ops->update_start(info);
2900 fbcon_set_palette(vc, color_table);
2903 fbcon_update_softback(vc);
2907 static void fbcon_set_all_vcs(struct fb_info *info)
2909 struct fbcon_ops *ops = info->fbcon_par;
2912 int i, rows, cols, fg = -1;
2914 if (!ops || ops->currcon < 0)
2917 for (i = first_fb_vc; i <= last_fb_vc; i++) {
2919 if (!vc || vc->vc_mode != KD_TEXT ||
2920 registered_fb[con2fb_map[i]] != info)
2923 if (CON_IS_VISIBLE(vc)) {
2928 p = &fb_display[vc->vc_num];
2929 set_blitting_type(vc, info);
2930 var_to_display(p, &info->var, info);
2931 cols = FBCON_SWAP(ops->rotate, info->var.xres, info->var.yres);
2932 rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
2933 cols /= vc->vc_font.width;
2934 rows /= vc->vc_font.height;
2935 vc_resize(vc, cols, rows);
2939 fbcon_modechanged(info);
2942 static int fbcon_mode_deleted(struct fb_info *info,
2943 struct fb_videomode *mode)
2945 struct fb_info *fb_info;
2947 int i, j, found = 0;
2949 /* before deletion, ensure that mode is not in use */
2950 for (i = first_fb_vc; i <= last_fb_vc; i++) {
2954 fb_info = registered_fb[j];
2955 if (fb_info != info)
2960 if (fb_mode_is_equal(p->mode, mode)) {
2968 #ifdef CONFIG_VT_HW_CONSOLE_BINDING
2969 static int fbcon_unbind(void)
2973 ret = unbind_con_driver(&fb_con, first_fb_vc, last_fb_vc,
2977 fbcon_has_console_bind = 0;
2982 static inline int fbcon_unbind(void)
2986 #endif /* CONFIG_VT_HW_CONSOLE_BINDING */
2988 static int fbcon_fb_unbind(int idx)
2990 int i, new_idx = -1, ret = 0;
2992 if (!fbcon_has_console_bind)
2995 for (i = first_fb_vc; i <= last_fb_vc; i++) {
2996 if (con2fb_map[i] != idx &&
2997 con2fb_map[i] != -1) {
3003 if (new_idx != -1) {
3004 for (i = first_fb_vc; i <= last_fb_vc; i++) {
3005 if (con2fb_map[i] == idx)
3006 set_con2fb_map(i, new_idx, 0);
3009 ret = fbcon_unbind();
3014 static int fbcon_fb_unregistered(struct fb_info *info)
3019 for (i = first_fb_vc; i <= last_fb_vc; i++) {
3020 if (con2fb_map[i] == idx)
3024 if (idx == info_idx) {
3027 for (i = 0; i < FB_MAX; i++) {
3028 if (registered_fb[i] != NULL) {
3035 if (info_idx != -1) {
3036 for (i = first_fb_vc; i <= last_fb_vc; i++) {
3037 if (con2fb_map[i] == -1)
3038 con2fb_map[i] = info_idx;
3042 if (primary_device == idx)
3043 primary_device = -1;
3045 if (!num_registered_fb)
3046 unregister_con_driver(&fb_con);
3051 static void fbcon_remap_all(int idx)
3054 for (i = first_fb_vc; i <= last_fb_vc; i++)
3055 set_con2fb_map(i, idx, 0);
3057 if (con_is_bound(&fb_con)) {
3058 printk(KERN_INFO "fbcon: Remapping primary device, "
3059 "fb%i, to tty %i-%i\n", idx,
3060 first_fb_vc + 1, last_fb_vc + 1);
3065 #ifdef CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY
3066 static void fbcon_select_primary(struct fb_info *info)
3068 if (!map_override && primary_device == -1 &&
3069 fb_is_primary_device(info)) {
3072 printk(KERN_INFO "fbcon: %s (fb%i) is primary device\n",
3073 info->fix.id, info->node);
3074 primary_device = info->node;
3076 for (i = first_fb_vc; i <= last_fb_vc; i++)
3077 con2fb_map_boot[i] = primary_device;
3079 if (con_is_bound(&fb_con)) {
3080 printk(KERN_INFO "fbcon: Remapping primary device, "
3081 "fb%i, to tty %i-%i\n", info->node,
3082 first_fb_vc + 1, last_fb_vc + 1);
3083 info_idx = primary_device;
3089 static inline void fbcon_select_primary(struct fb_info *info)
3093 #endif /* CONFIG_FRAMEBUFFER_DETECT_PRIMARY */
3095 static int fbcon_fb_registered(struct fb_info *info)
3097 int ret = 0, i, idx;
3100 fbcon_select_primary(info);
3102 if (info_idx == -1) {
3103 for (i = first_fb_vc; i <= last_fb_vc; i++) {
3104 if (con2fb_map_boot[i] == idx) {
3111 ret = fbcon_takeover(1);
3113 for (i = first_fb_vc; i <= last_fb_vc; i++) {
3114 if (con2fb_map_boot[i] == idx)
3115 set_con2fb_map(i, idx, 0);
3122 static void fbcon_fb_blanked(struct fb_info *info, int blank)
3124 struct fbcon_ops *ops = info->fbcon_par;
3127 if (!ops || ops->currcon < 0)
3130 vc = vc_cons[ops->currcon].d;
3131 if (vc->vc_mode != KD_TEXT ||
3132 registered_fb[con2fb_map[ops->currcon]] != info)
3135 if (CON_IS_VISIBLE(vc)) {
3139 do_unblank_screen(0);
3141 ops->blank_state = blank;
3144 static void fbcon_new_modelist(struct fb_info *info)
3148 struct fb_var_screeninfo var;
3149 const struct fb_videomode *mode;
3151 for (i = first_fb_vc; i <= last_fb_vc; i++) {
3152 if (registered_fb[con2fb_map[i]] != info)
3154 if (!fb_display[i].mode)
3157 display_to_var(&var, &fb_display[i]);
3158 mode = fb_find_nearest_mode(fb_display[i].mode,
3160 fb_videomode_to_var(&var, mode);
3161 fbcon_set_disp(info, &var, vc->vc_num);
3165 static void fbcon_get_requirement(struct fb_info *info,
3166 struct fb_blit_caps *caps)
3174 for (i = first_fb_vc; i <= last_fb_vc; i++) {
3176 if (vc && vc->vc_mode == KD_TEXT &&
3177 info->node == con2fb_map[i]) {
3179 caps->x |= 1 << (vc->vc_font.width - 1);
3180 caps->y |= 1 << (vc->vc_font.height - 1);
3181 charcnt = (p->userfont) ?
3182 FNTCHARCNT(p->fontdata) : 256;
3183 if (caps->len < charcnt)
3184 caps->len = charcnt;
3188 vc = vc_cons[fg_console].d;
3190 if (vc && vc->vc_mode == KD_TEXT &&
3191 info->node == con2fb_map[fg_console]) {
3192 p = &fb_display[fg_console];
3193 caps->x = 1 << (vc->vc_font.width - 1);
3194 caps->y = 1 << (vc->vc_font.height - 1);
3195 caps->len = (p->userfont) ?
3196 FNTCHARCNT(p->fontdata) : 256;
3201 static int fbcon_event_notify(struct notifier_block *self,
3202 unsigned long action, void *data)
3204 struct fb_event *event = data;
3205 struct fb_info *info = event->info;
3206 struct fb_videomode *mode;
3207 struct fb_con2fbmap *con2fb;
3208 struct fb_blit_caps *caps;
3212 * ignore all events except driver registration and deregistration
3213 * if fbcon is not active
3215 if (fbcon_has_exited && !(action == FB_EVENT_FB_REGISTERED ||
3216 action == FB_EVENT_FB_UNREGISTERED))
3220 case FB_EVENT_SUSPEND:
3221 fbcon_suspended(info);
3223 case FB_EVENT_RESUME:
3224 fbcon_resumed(info);
3226 case FB_EVENT_MODE_CHANGE:
3227 fbcon_modechanged(info);
3229 case FB_EVENT_MODE_CHANGE_ALL:
3230 fbcon_set_all_vcs(info);
3232 case FB_EVENT_MODE_DELETE:
3234 ret = fbcon_mode_deleted(info, mode);
3236 case FB_EVENT_FB_UNBIND:
3238 ret = fbcon_fb_unbind(idx);
3240 case FB_EVENT_FB_REGISTERED:
3241 ret = fbcon_fb_registered(info);
3243 case FB_EVENT_FB_UNREGISTERED:
3244 ret = fbcon_fb_unregistered(info);
3246 case FB_EVENT_SET_CONSOLE_MAP:
3247 con2fb = event->data;
3248 ret = set_con2fb_map(con2fb->console - 1,
3249 con2fb->framebuffer, 1);
3251 case FB_EVENT_GET_CONSOLE_MAP:
3252 con2fb = event->data;
3253 con2fb->framebuffer = con2fb_map[con2fb->console - 1];
3255 case FB_EVENT_BLANK:
3256 fbcon_fb_blanked(info, *(int *)event->data);
3258 case FB_EVENT_NEW_MODELIST:
3259 fbcon_new_modelist(info);
3261 case FB_EVENT_GET_REQ:
3263 fbcon_get_requirement(info, caps);
3265 case FB_EVENT_REMAP_ALL_CONSOLE:
3267 fbcon_remap_all(idx);
3275 * The console `switch' structure for the frame buffer based console
3278 static const struct consw fb_con = {
3279 .owner = THIS_MODULE,
3280 .con_startup = fbcon_startup,
3281 .con_init = fbcon_init,
3282 .con_deinit = fbcon_deinit,
3283 .con_clear = fbcon_clear,
3284 .con_putc = fbcon_putc,
3285 .con_putcs = fbcon_putcs,
3286 .con_cursor = fbcon_cursor,
3287 .con_scroll = fbcon_scroll,
3288 .con_bmove = fbcon_bmove,
3289 .con_switch = fbcon_switch,
3290 .con_blank = fbcon_blank,
3291 .con_font_set = fbcon_set_font,
3292 .con_font_get = fbcon_get_font,
3293 .con_font_default = fbcon_set_def_font,
3294 .con_font_copy = fbcon_copy_font,
3295 .con_set_palette = fbcon_set_palette,
3296 .con_scrolldelta = fbcon_scrolldelta,
3297 .con_set_origin = fbcon_set_origin,
3298 .con_invert_region = fbcon_invert_region,
3299 .con_screen_pos = fbcon_screen_pos,
3300 .con_getxy = fbcon_getxy,
3301 .con_resize = fbcon_resize,
3302 .con_debug_enter = fbcon_debug_enter,
3303 .con_debug_leave = fbcon_debug_leave,
3306 static struct notifier_block fbcon_event_notifier = {
3307 .notifier_call = fbcon_event_notify,
3310 static ssize_t store_rotate(struct device *device,
3311 struct device_attribute *attr, const char *buf,
3314 struct fb_info *info;
3318 if (fbcon_has_exited)
3322 idx = con2fb_map[fg_console];
3324 if (idx == -1 || registered_fb[idx] == NULL)
3327 info = registered_fb[idx];
3328 rotate = simple_strtoul(buf, last, 0);
3329 fbcon_rotate(info, rotate);
3335 static ssize_t store_rotate_all(struct device *device,
3336 struct device_attribute *attr,const char *buf,
3339 struct fb_info *info;
3343 if (fbcon_has_exited)
3347 idx = con2fb_map[fg_console];
3349 if (idx == -1 || registered_fb[idx] == NULL)
3352 info = registered_fb[idx];
3353 rotate = simple_strtoul(buf, last, 0);
3354 fbcon_rotate_all(info, rotate);
3360 static ssize_t show_rotate(struct device *device,
3361 struct device_attribute *attr,char *buf)
3363 struct fb_info *info;
3364 int rotate = 0, idx;
3366 if (fbcon_has_exited)
3370 idx = con2fb_map[fg_console];
3372 if (idx == -1 || registered_fb[idx] == NULL)
3375 info = registered_fb[idx];
3376 rotate = fbcon_get_rotate(info);
3379 return snprintf(buf, PAGE_SIZE, "%d\n", rotate);
3382 static ssize_t show_cursor_blink(struct device *device,
3383 struct device_attribute *attr, char *buf)
3385 struct fb_info *info;
3386 struct fbcon_ops *ops;
3387 int idx, blink = -1;
3389 if (fbcon_has_exited)
3393 idx = con2fb_map[fg_console];
3395 if (idx == -1 || registered_fb[idx] == NULL)
3398 info = registered_fb[idx];
3399 ops = info->fbcon_par;
3404 blink = (ops->flags & FBCON_FLAGS_CURSOR_TIMER) ? 1 : 0;
3407 return snprintf(buf, PAGE_SIZE, "%d\n", blink);
3410 static ssize_t store_cursor_blink(struct device *device,
3411 struct device_attribute *attr,
3412 const char *buf, size_t count)
3414 struct fb_info *info;
3418 if (fbcon_has_exited)
3422 idx = con2fb_map[fg_console];
3424 if (idx == -1 || registered_fb[idx] == NULL)
3427 info = registered_fb[idx];
3429 if (!info->fbcon_par)
3432 blink = simple_strtoul(buf, last, 0);
3435 fbcon_cursor_noblink = 0;
3436 fbcon_add_cursor_timer(info);
3438 fbcon_cursor_noblink = 1;
3439 fbcon_del_cursor_timer(info);
3447 static struct device_attribute device_attrs[] = {
3448 __ATTR(rotate, S_IRUGO|S_IWUSR, show_rotate, store_rotate),
3449 __ATTR(rotate_all, S_IWUSR, NULL, store_rotate_all),
3450 __ATTR(cursor_blink, S_IRUGO|S_IWUSR, show_cursor_blink,
3451 store_cursor_blink),
3454 static int fbcon_init_device(void)
3458 fbcon_has_sysfs = 1;
3460 for (i = 0; i < ARRAY_SIZE(device_attrs); i++) {
3461 error = device_create_file(fbcon_device, &device_attrs[i]);
3469 device_remove_file(fbcon_device, &device_attrs[i]);
3471 fbcon_has_sysfs = 0;
3477 static void fbcon_start(void)
3479 if (num_registered_fb) {
3484 for (i = 0; i < FB_MAX; i++) {
3485 if (registered_fb[i] != NULL) {
3496 static void fbcon_exit(void)
3498 struct fb_info *info;
3501 if (fbcon_has_exited)
3504 kfree((void *)softback_buf);
3507 for (i = 0; i < FB_MAX; i++) {
3511 info = registered_fb[i];
3516 if (info->queue.func)
3517 pending = cancel_work_sync(&info->queue);
3518 DPRINTK("fbcon: %s pending work\n", (pending ? "canceled" :
3521 for (j = first_fb_vc; j <= last_fb_vc; j++) {
3522 if (con2fb_map[j] == i)
3527 if (info->fbops->fb_release)
3528 info->fbops->fb_release(info, 0);
3529 module_put(info->fbops->owner);
3531 if (info->fbcon_par) {
3532 struct fbcon_ops *ops = info->fbcon_par;
3534 fbcon_del_cursor_timer(info);
3535 kfree(ops->cursor_src);
3536 kfree(info->fbcon_par);
3537 info->fbcon_par = NULL;
3540 if (info->queue.func == fb_flashcursor)
3541 info->queue.func = NULL;
3545 fbcon_has_exited = 1;
3548 static int __init fb_console_init(void)
3553 fb_register_client(&fbcon_event_notifier);
3554 fbcon_device = device_create(fb_class, NULL, MKDEV(0, 0), NULL,
3557 if (IS_ERR(fbcon_device)) {
3558 printk(KERN_WARNING "Unable to create device "
3559 "for fbcon; errno = %ld\n",
3560 PTR_ERR(fbcon_device));
3561 fbcon_device = NULL;
3563 fbcon_init_device();
3565 for (i = 0; i < MAX_NR_CONSOLES; i++)
3573 module_init(fb_console_init);
3577 static void __exit fbcon_deinit_device(void)
3581 if (fbcon_has_sysfs) {
3582 for (i = 0; i < ARRAY_SIZE(device_attrs); i++)
3583 device_remove_file(fbcon_device, &device_attrs[i]);
3585 fbcon_has_sysfs = 0;
3589 static void __exit fb_console_exit(void)
3592 fb_unregister_client(&fbcon_event_notifier);
3593 fbcon_deinit_device();
3594 device_destroy(fb_class, MKDEV(0, 0));
3597 unregister_con_driver(&fb_con);
3600 module_exit(fb_console_exit);
3604 MODULE_LICENSE("GPL");