Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * linux/drivers/video/fbcon.c -- Low level frame buffer based console driver | |
3 | * | |
4 | * Copyright (C) 1995 Geert Uytterhoeven | |
5 | * | |
6 | * | |
7 | * This file is based on the original Amiga console driver (amicon.c): | |
8 | * | |
9 | * Copyright (C) 1993 Hamish Macdonald | |
10 | * Greg Harp | |
11 | * Copyright (C) 1994 David Carter [carter@compsci.bristol.ac.uk] | |
12 | * | |
13 | * with work by William Rucklidge (wjr@cs.cornell.edu) | |
14 | * Geert Uytterhoeven | |
15 | * Jes Sorensen (jds@kom.auc.dk) | |
16 | * Martin Apel | |
17 | * | |
18 | * and on the original Atari console driver (atacon.c): | |
19 | * | |
20 | * Copyright (C) 1993 Bjoern Brauel | |
21 | * Roman Hodek | |
22 | * | |
23 | * with work by Guenther Kelleter | |
24 | * Martin Schaller | |
25 | * Andreas Schwab | |
26 | * | |
27 | * Hardware cursor support added by Emmanuel Marty (core@ggi-project.org) | |
28 | * Smart redraw scrolling, arbitrary font width support, 512char font support | |
29 | * and software scrollback added by | |
30 | * Jakub Jelinek (jj@ultra.linux.cz) | |
31 | * | |
32 | * Random hacking by Martin Mares <mj@ucw.cz> | |
33 | * | |
34 | * 2001 - Documented with DocBook | |
35 | * - Brad Douglas <brad@neruo.com> | |
36 | * | |
37 | * The low level operations for the various display memory organizations are | |
38 | * now in separate source files. | |
39 | * | |
40 | * Currently the following organizations are supported: | |
41 | * | |
42 | * o afb Amiga bitplanes | |
43 | * o cfb{2,4,8,16,24,32} Packed pixels | |
44 | * o ilbm Amiga interleaved bitplanes | |
45 | * o iplan2p[248] Atari interleaved bitplanes | |
46 | * o mfb Monochrome | |
47 | * o vga VGA characters/attributes | |
48 | * | |
49 | * To do: | |
50 | * | |
51 | * - Implement 16 plane mode (iplan2p16) | |
52 | * | |
53 | * | |
54 | * This file is subject to the terms and conditions of the GNU General Public | |
55 | * License. See the file COPYING in the main directory of this archive for | |
56 | * more details. | |
57 | */ | |
58 | ||
59 | #undef FBCONDEBUG | |
60 | ||
1da177e4 LT |
61 | #include <linux/module.h> |
62 | #include <linux/types.h> | |
1da177e4 LT |
63 | #include <linux/fs.h> |
64 | #include <linux/kernel.h> | |
65 | #include <linux/delay.h> /* MSch: for IRQ probe */ | |
1da177e4 LT |
66 | #include <linux/console.h> |
67 | #include <linux/string.h> | |
68 | #include <linux/kd.h> | |
69 | #include <linux/slab.h> | |
70 | #include <linux/fb.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 */ | |
623e71b0 | 78 | #include <asm/fb.h> |
1da177e4 LT |
79 | #include <asm/irq.h> |
80 | #include <asm/system.h> | |
1da177e4 LT |
81 | #ifdef CONFIG_ATARI |
82 | #include <asm/atariints.h> | |
83 | #endif | |
84 | #ifdef CONFIG_MAC | |
85 | #include <asm/macints.h> | |
86 | #endif | |
7b892806 | 87 | #if defined(__mc68000__) |
1da177e4 LT |
88 | #include <asm/machdep.h> |
89 | #include <asm/setup.h> | |
90 | #endif | |
91 | ||
92 | #include "fbcon.h" | |
93 | ||
94 | #ifdef FBCONDEBUG | |
5ae12170 | 95 | # define DPRINTK(fmt, args...) printk(KERN_DEBUG "%s: " fmt, __func__ , ## args) |
1da177e4 LT |
96 | #else |
97 | # define DPRINTK(fmt, args...) | |
98 | #endif | |
99 | ||
100 | enum { | |
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 */ | |
104 | }; | |
105 | ||
ab767201 | 106 | static struct display fb_display[MAX_NR_CONSOLES]; |
e4fc2761 | 107 | |
1da177e4 LT |
108 | static signed char con2fb_map[MAX_NR_CONSOLES]; |
109 | static signed char con2fb_map_boot[MAX_NR_CONSOLES]; | |
49a1d28f | 110 | |
1da177e4 LT |
111 | static int logo_lines; |
112 | /* logo_shown is an index to vc_cons when >= 0; otherwise follows FBCON_LOGO | |
113 | enums. */ | |
114 | static int logo_shown = FBCON_LOGO_CANSHOW; | |
115 | /* Software scrollback */ | |
116 | static int fbcon_softback_size = 32768; | |
117 | static unsigned long softback_buf, softback_curr; | |
118 | static unsigned long softback_in; | |
119 | static unsigned long softback_top, softback_end; | |
120 | static int softback_lines; | |
121 | /* console mappings */ | |
122 | static int first_fb_vc; | |
123 | static int last_fb_vc = MAX_NR_CONSOLES - 1; | |
124 | static int fbcon_is_default = 1; | |
e614b18d | 125 | static int fbcon_has_exited; |
623e71b0 | 126 | static int primary_device = -1; |
4769a9a5 AD |
127 | |
128 | #ifdef CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY | |
623e71b0 | 129 | static int map_override; |
e614b18d | 130 | |
4769a9a5 AD |
131 | static inline void fbcon_map_override(void) |
132 | { | |
133 | map_override = 1; | |
134 | } | |
135 | #else | |
136 | static inline void fbcon_map_override(void) | |
137 | { | |
138 | } | |
139 | #endif /* CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY */ | |
140 | ||
1da177e4 LT |
141 | /* font data */ |
142 | static char fontname[40]; | |
143 | ||
144 | /* current fb_info */ | |
145 | static int info_idx = -1; | |
146 | ||
e4fc2761 | 147 | /* console rotation */ |
2428e59b | 148 | static int initial_rotation; |
0a727dea | 149 | static int fbcon_has_sysfs; |
e4fc2761 | 150 | |
1da177e4 LT |
151 | static const struct consw fb_con; |
152 | ||
153 | #define CM_SOFTBACK (8) | |
154 | ||
155 | #define advance_row(p, delta) (unsigned short *)((unsigned long)(p) + (delta) * vc->vc_size_row) | |
156 | ||
1da177e4 LT |
157 | static int fbcon_set_origin(struct vc_data *); |
158 | ||
159 | #define CURSOR_DRAW_DELAY (1) | |
160 | ||
161 | /* # VBL ints between cursor state changes */ | |
1da177e4 LT |
162 | #define ATARI_CURSOR_BLINK_RATE (42) |
163 | #define MAC_CURSOR_BLINK_RATE (32) | |
164 | #define DEFAULT_CURSOR_BLINK_RATE (20) | |
165 | ||
166 | static int vbl_cursor_cnt; | |
acba9cd0 | 167 | static int fbcon_cursor_noblink; |
1da177e4 LT |
168 | |
169 | #define divides(a, b) ((!(a) || (b)%(a)) ? 0 : 1) | |
170 | ||
171 | /* | |
172 | * Interface used by the world | |
173 | */ | |
174 | ||
175 | static const char *fbcon_startup(void); | |
176 | static void fbcon_init(struct vc_data *vc, int init); | |
177 | static void fbcon_deinit(struct vc_data *vc); | |
178 | static void fbcon_clear(struct vc_data *vc, int sy, int sx, int height, | |
179 | int width); | |
180 | static void fbcon_putc(struct vc_data *vc, int c, int ypos, int xpos); | |
181 | static void fbcon_putcs(struct vc_data *vc, const unsigned short *s, | |
182 | int count, int ypos, int xpos); | |
183 | static void fbcon_clear_margins(struct vc_data *vc, int bottom_only); | |
184 | static void fbcon_cursor(struct vc_data *vc, int mode); | |
185 | static int fbcon_scroll(struct vc_data *vc, int t, int b, int dir, | |
186 | int count); | |
187 | static void fbcon_bmove(struct vc_data *vc, int sy, int sx, int dy, int dx, | |
188 | int height, int width); | |
189 | static int fbcon_switch(struct vc_data *vc); | |
190 | static int fbcon_blank(struct vc_data *vc, int blank, int mode_switch); | |
191 | static int fbcon_set_palette(struct vc_data *vc, unsigned char *table); | |
192 | static int fbcon_scrolldelta(struct vc_data *vc, int lines); | |
193 | ||
194 | /* | |
195 | * Internal routines | |
196 | */ | |
1da177e4 LT |
197 | static __inline__ void ywrap_up(struct vc_data *vc, int count); |
198 | static __inline__ void ywrap_down(struct vc_data *vc, int count); | |
199 | static __inline__ void ypan_up(struct vc_data *vc, int count); | |
200 | static __inline__ void ypan_down(struct vc_data *vc, int count); | |
201 | static void fbcon_bmove_rec(struct vc_data *vc, struct display *p, int sy, int sx, | |
202 | int dy, int dx, int height, int width, u_int y_break); | |
203 | static void fbcon_set_disp(struct fb_info *info, struct fb_var_screeninfo *var, | |
d1baa4ff | 204 | int unit); |
1da177e4 LT |
205 | static void fbcon_redraw_move(struct vc_data *vc, struct display *p, |
206 | int line, int count, int dy); | |
a812c94b AD |
207 | static void fbcon_modechanged(struct fb_info *info); |
208 | static void fbcon_set_all_vcs(struct fb_info *info); | |
5428b044 AD |
209 | static void fbcon_start(void); |
210 | static void fbcon_exit(void); | |
0c6c1ce0 | 211 | static struct device *fbcon_device; |
9a179176 | 212 | |
1da177e4 LT |
213 | #ifdef CONFIG_MAC |
214 | /* | |
215 | * On the Macintoy, there may or may not be a working VBL int. We need to probe | |
216 | */ | |
217 | static int vbl_detected; | |
218 | ||
7d12e780 | 219 | static irqreturn_t fb_vbl_detect(int irq, void *dummy) |
1da177e4 LT |
220 | { |
221 | vbl_detected++; | |
222 | return IRQ_HANDLED; | |
223 | } | |
224 | #endif | |
225 | ||
dbcbfe1e | 226 | #ifdef CONFIG_FRAMEBUFFER_CONSOLE_ROTATION |
b73deed3 | 227 | static inline void fbcon_set_rotation(struct fb_info *info) |
dbcbfe1e AD |
228 | { |
229 | struct fbcon_ops *ops = info->fbcon_par; | |
230 | ||
231 | if (!(info->flags & FBINFO_MISC_TILEBLITTING) && | |
b73deed3 AD |
232 | ops->p->con_rotate < 4) |
233 | ops->rotate = ops->p->con_rotate; | |
dbcbfe1e AD |
234 | else |
235 | ops->rotate = 0; | |
236 | } | |
a812c94b AD |
237 | |
238 | static void fbcon_rotate(struct fb_info *info, u32 rotate) | |
239 | { | |
240 | struct fbcon_ops *ops= info->fbcon_par; | |
241 | struct fb_info *fb_info; | |
242 | ||
243 | if (!ops || ops->currcon == -1) | |
244 | return; | |
245 | ||
246 | fb_info = registered_fb[con2fb_map[ops->currcon]]; | |
247 | ||
248 | if (info == fb_info) { | |
249 | struct display *p = &fb_display[ops->currcon]; | |
250 | ||
251 | if (rotate < 4) | |
252 | p->con_rotate = rotate; | |
253 | else | |
254 | p->con_rotate = 0; | |
255 | ||
256 | fbcon_modechanged(info); | |
257 | } | |
258 | } | |
259 | ||
260 | static void fbcon_rotate_all(struct fb_info *info, u32 rotate) | |
261 | { | |
262 | struct fbcon_ops *ops = info->fbcon_par; | |
263 | struct vc_data *vc; | |
264 | struct display *p; | |
265 | int i; | |
266 | ||
267 | if (!ops || ops->currcon < 0 || rotate > 3) | |
268 | return; | |
269 | ||
e614b18d | 270 | for (i = first_fb_vc; i <= last_fb_vc; i++) { |
a812c94b AD |
271 | vc = vc_cons[i].d; |
272 | if (!vc || vc->vc_mode != KD_TEXT || | |
273 | registered_fb[con2fb_map[i]] != info) | |
274 | continue; | |
275 | ||
276 | p = &fb_display[vc->vc_num]; | |
277 | p->con_rotate = rotate; | |
278 | } | |
279 | ||
280 | fbcon_set_all_vcs(info); | |
281 | } | |
dbcbfe1e | 282 | #else |
b73deed3 | 283 | static inline void fbcon_set_rotation(struct fb_info *info) |
e4fc2761 AD |
284 | { |
285 | struct fbcon_ops *ops = info->fbcon_par; | |
286 | ||
287 | ops->rotate = FB_ROTATE_UR; | |
288 | } | |
a812c94b AD |
289 | |
290 | static void fbcon_rotate(struct fb_info *info, u32 rotate) | |
291 | { | |
292 | return; | |
293 | } | |
294 | ||
295 | static void fbcon_rotate_all(struct fb_info *info, u32 rotate) | |
296 | { | |
297 | return; | |
298 | } | |
dbcbfe1e | 299 | #endif /* CONFIG_FRAMEBUFFER_CONSOLE_ROTATION */ |
e4fc2761 | 300 | |
a812c94b AD |
301 | static int fbcon_get_rotate(struct fb_info *info) |
302 | { | |
303 | struct fbcon_ops *ops = info->fbcon_par; | |
304 | ||
305 | return (ops) ? ops->rotate : 0; | |
306 | } | |
307 | ||
1da177e4 LT |
308 | static inline int fbcon_is_inactive(struct vc_data *vc, struct fb_info *info) |
309 | { | |
310 | struct fbcon_ops *ops = info->fbcon_par; | |
311 | ||
312 | return (info->state != FBINFO_STATE_RUNNING || | |
313 | vc->vc_mode != KD_TEXT || ops->graphics); | |
314 | } | |
315 | ||
316 | static inline int get_color(struct vc_data *vc, struct fb_info *info, | |
317 | u16 c, int is_fg) | |
318 | { | |
b8c90945 | 319 | int depth = fb_get_color_depth(&info->var, &info->fix); |
1da177e4 LT |
320 | int color = 0; |
321 | ||
322 | if (console_blanked) { | |
323 | unsigned short charmask = vc->vc_hi_font_mask ? 0x1ff : 0xff; | |
324 | ||
325 | c = vc->vc_video_erase_char & charmask; | |
326 | } | |
327 | ||
328 | if (depth != 1) | |
329 | color = (is_fg) ? attr_fgcol((vc->vc_hi_font_mask) ? 9 : 8, c) | |
330 | : attr_bgcol((vc->vc_hi_font_mask) ? 13 : 12, c); | |
331 | ||
332 | switch (depth) { | |
333 | case 1: | |
334 | { | |
91c43132 | 335 | int col = mono_col(info); |
1da177e4 | 336 | /* 0 or 1 */ |
b8c90945 AD |
337 | int fg = (info->fix.visual != FB_VISUAL_MONO01) ? col : 0; |
338 | int bg = (info->fix.visual != FB_VISUAL_MONO01) ? 0 : col; | |
1da177e4 LT |
339 | |
340 | if (console_blanked) | |
341 | fg = bg; | |
342 | ||
343 | color = (is_fg) ? fg : bg; | |
344 | break; | |
345 | } | |
346 | case 2: | |
347 | /* | |
348 | * Scale down 16-colors to 4 colors. Default 4-color palette | |
2cc38ed1 AD |
349 | * is grayscale. However, simply dividing the values by 4 |
350 | * will not work, as colors 1, 2 and 3 will be scaled-down | |
351 | * to zero rendering them invisible. So empirically convert | |
352 | * colors to a sane 4-level grayscale. | |
1da177e4 | 353 | */ |
2cc38ed1 AD |
354 | switch (color) { |
355 | case 0: | |
356 | color = 0; /* black */ | |
357 | break; | |
358 | case 1 ... 6: | |
359 | color = 2; /* white */ | |
360 | break; | |
361 | case 7 ... 8: | |
362 | color = 1; /* gray */ | |
363 | break; | |
364 | default: | |
365 | color = 3; /* intense white */ | |
366 | break; | |
367 | } | |
368 | break; | |
1da177e4 LT |
369 | case 3: |
370 | /* | |
371 | * Last 8 entries of default 16-color palette is a more intense | |
372 | * version of the first 8 (i.e., same chrominance, different | |
373 | * luminance). | |
374 | */ | |
375 | color &= 7; | |
376 | break; | |
377 | } | |
378 | ||
379 | ||
380 | return color; | |
381 | } | |
382 | ||
4d9c5b6e AD |
383 | static void fbcon_update_softback(struct vc_data *vc) |
384 | { | |
385 | int l = fbcon_softback_size / vc->vc_size_row; | |
386 | ||
387 | if (l > 5) | |
388 | softback_end = softback_buf + l * vc->vc_size_row; | |
389 | else | |
390 | /* Smaller scrollback makes no sense, and 0 would screw | |
391 | the operation totally */ | |
392 | softback_top = 0; | |
393 | } | |
394 | ||
c4028958 | 395 | static void fb_flashcursor(struct work_struct *work) |
1da177e4 | 396 | { |
c4028958 | 397 | struct fb_info *info = container_of(work, struct fb_info, queue); |
1da177e4 LT |
398 | struct fbcon_ops *ops = info->fbcon_par; |
399 | struct display *p; | |
400 | struct vc_data *vc = NULL; | |
401 | int c; | |
402 | int mode; | |
403 | ||
5428b044 AD |
404 | acquire_console_sem(); |
405 | if (ops && ops->currcon != -1) | |
1da177e4 LT |
406 | vc = vc_cons[ops->currcon].d; |
407 | ||
408 | if (!vc || !CON_IS_VISIBLE(vc) || | |
dbd4f128 | 409 | registered_fb[con2fb_map[vc->vc_num]] != info || |
212f2639 | 410 | vc->vc_deccm != 1) { |
5428b044 | 411 | release_console_sem(); |
1da177e4 | 412 | return; |
5428b044 AD |
413 | } |
414 | ||
1da177e4 LT |
415 | p = &fb_display[vc->vc_num]; |
416 | c = scr_readw((u16 *) vc->vc_pos); | |
417 | mode = (!ops->cursor_flash || ops->cursor_state.enable) ? | |
418 | CM_ERASE : CM_DRAW; | |
b73deed3 | 419 | ops->cursor(vc, info, mode, softback_lines, get_color(vc, info, c, 1), |
1da177e4 LT |
420 | get_color(vc, info, c, 0)); |
421 | release_console_sem(); | |
422 | } | |
423 | ||
41359dca | 424 | #if defined(CONFIG_ATARI) || defined(CONFIG_MAC) |
1da177e4 | 425 | static int cursor_blink_rate; |
7d12e780 | 426 | static irqreturn_t fb_vbl_handler(int irq, void *dev_id) |
1da177e4 LT |
427 | { |
428 | struct fb_info *info = dev_id; | |
429 | ||
430 | if (vbl_cursor_cnt && --vbl_cursor_cnt == 0) { | |
431 | schedule_work(&info->queue); | |
432 | vbl_cursor_cnt = cursor_blink_rate; | |
433 | } | |
434 | return IRQ_HANDLED; | |
435 | } | |
436 | #endif | |
437 | ||
438 | static void cursor_timer_handler(unsigned long dev_addr) | |
439 | { | |
440 | struct fb_info *info = (struct fb_info *) dev_addr; | |
441 | struct fbcon_ops *ops = info->fbcon_par; | |
442 | ||
443 | schedule_work(&info->queue); | |
444 | mod_timer(&ops->cursor_timer, jiffies + HZ/5); | |
445 | } | |
446 | ||
88fb2c6e AD |
447 | static void fbcon_add_cursor_timer(struct fb_info *info) |
448 | { | |
449 | struct fbcon_ops *ops = info->fbcon_par; | |
450 | ||
451 | if ((!info->queue.func || info->queue.func == fb_flashcursor) && | |
acba9cd0 AD |
452 | !(ops->flags & FBCON_FLAGS_CURSOR_TIMER) && |
453 | !fbcon_cursor_noblink) { | |
88fb2c6e | 454 | if (!info->queue.func) |
c4028958 | 455 | INIT_WORK(&info->queue, fb_flashcursor); |
88fb2c6e AD |
456 | |
457 | init_timer(&ops->cursor_timer); | |
458 | ops->cursor_timer.function = cursor_timer_handler; | |
459 | ops->cursor_timer.expires = jiffies + HZ / 5; | |
460 | ops->cursor_timer.data = (unsigned long ) info; | |
461 | add_timer(&ops->cursor_timer); | |
462 | ops->flags |= FBCON_FLAGS_CURSOR_TIMER; | |
463 | } | |
464 | } | |
465 | ||
466 | static void fbcon_del_cursor_timer(struct fb_info *info) | |
467 | { | |
468 | struct fbcon_ops *ops = info->fbcon_par; | |
469 | ||
470 | if (info->queue.func == fb_flashcursor && | |
471 | ops->flags & FBCON_FLAGS_CURSOR_TIMER) { | |
472 | del_timer_sync(&ops->cursor_timer); | |
473 | ops->flags &= ~FBCON_FLAGS_CURSOR_TIMER; | |
474 | } | |
475 | } | |
476 | ||
1da177e4 LT |
477 | #ifndef MODULE |
478 | static int __init fb_console_setup(char *this_opt) | |
479 | { | |
480 | char *options; | |
481 | int i, j; | |
482 | ||
483 | if (!this_opt || !*this_opt) | |
9b41046c | 484 | return 1; |
1da177e4 LT |
485 | |
486 | while ((options = strsep(&this_opt, ",")) != NULL) { | |
487 | if (!strncmp(options, "font:", 5)) | |
488 | strcpy(fontname, options + 5); | |
489 | ||
490 | if (!strncmp(options, "scrollback:", 11)) { | |
491 | options += 11; | |
492 | if (*options) { | |
493 | fbcon_softback_size = simple_strtoul(options, &options, 0); | |
494 | if (*options == 'k' || *options == 'K') { | |
495 | fbcon_softback_size *= 1024; | |
496 | options++; | |
497 | } | |
498 | if (*options != ',') | |
9b41046c | 499 | return 1; |
1da177e4 LT |
500 | options++; |
501 | } else | |
9b41046c | 502 | return 1; |
1da177e4 LT |
503 | } |
504 | ||
505 | if (!strncmp(options, "map:", 4)) { | |
506 | options += 4; | |
623e71b0 | 507 | if (*options) { |
1da177e4 LT |
508 | for (i = 0, j = 0; i < MAX_NR_CONSOLES; i++) { |
509 | if (!options[j]) | |
510 | j = 0; | |
511 | con2fb_map_boot[i] = | |
512 | (options[j++]-'0') % FB_MAX; | |
513 | } | |
623e71b0 | 514 | |
4769a9a5 | 515 | fbcon_map_override(); |
623e71b0 AD |
516 | } |
517 | ||
9b41046c | 518 | return 1; |
1da177e4 LT |
519 | } |
520 | ||
521 | if (!strncmp(options, "vc:", 3)) { | |
522 | options += 3; | |
523 | if (*options) | |
524 | first_fb_vc = simple_strtoul(options, &options, 10) - 1; | |
525 | if (first_fb_vc < 0) | |
526 | first_fb_vc = 0; | |
527 | if (*options++ == '-') | |
528 | last_fb_vc = simple_strtoul(options, &options, 10) - 1; | |
529 | fbcon_is_default = 0; | |
530 | } | |
e4fc2761 AD |
531 | |
532 | if (!strncmp(options, "rotate:", 7)) { | |
533 | options += 7; | |
534 | if (*options) | |
2428e59b MS |
535 | initial_rotation = simple_strtoul(options, &options, 0); |
536 | if (initial_rotation > 3) | |
537 | initial_rotation = 0; | |
e4fc2761 | 538 | } |
1da177e4 | 539 | } |
9b41046c | 540 | return 1; |
1da177e4 LT |
541 | } |
542 | ||
543 | __setup("fbcon=", fb_console_setup); | |
544 | #endif | |
545 | ||
546 | static int search_fb_in_map(int idx) | |
547 | { | |
548 | int i, retval = 0; | |
549 | ||
e614b18d | 550 | for (i = first_fb_vc; i <= last_fb_vc; i++) { |
1da177e4 LT |
551 | if (con2fb_map[i] == idx) |
552 | retval = 1; | |
553 | } | |
554 | return retval; | |
555 | } | |
556 | ||
557 | static int search_for_mapped_con(void) | |
558 | { | |
559 | int i, retval = 0; | |
560 | ||
e614b18d | 561 | for (i = first_fb_vc; i <= last_fb_vc; i++) { |
1da177e4 LT |
562 | if (con2fb_map[i] != -1) |
563 | retval = 1; | |
564 | } | |
565 | return retval; | |
566 | } | |
567 | ||
568 | static int fbcon_takeover(int show_logo) | |
569 | { | |
570 | int err, i; | |
571 | ||
572 | if (!num_registered_fb) | |
573 | return -ENODEV; | |
574 | ||
575 | if (!show_logo) | |
576 | logo_shown = FBCON_LOGO_DONTSHOW; | |
577 | ||
578 | for (i = first_fb_vc; i <= last_fb_vc; i++) | |
579 | con2fb_map[i] = info_idx; | |
580 | ||
581 | err = take_over_console(&fb_con, first_fb_vc, last_fb_vc, | |
582 | fbcon_is_default); | |
e614b18d | 583 | |
1da177e4 LT |
584 | if (err) { |
585 | for (i = first_fb_vc; i <= last_fb_vc; i++) { | |
586 | con2fb_map[i] = -1; | |
587 | } | |
588 | info_idx = -1; | |
589 | } | |
590 | ||
591 | return err; | |
592 | } | |
593 | ||
70802c60 AD |
594 | #ifdef MODULE |
595 | static void fbcon_prepare_logo(struct vc_data *vc, struct fb_info *info, | |
596 | int cols, int rows, int new_cols, int new_rows) | |
597 | { | |
598 | logo_shown = FBCON_LOGO_DONTSHOW; | |
599 | } | |
600 | #else | |
1da177e4 LT |
601 | static void fbcon_prepare_logo(struct vc_data *vc, struct fb_info *info, |
602 | int cols, int rows, int new_cols, int new_rows) | |
603 | { | |
604 | /* Need to make room for the logo */ | |
9c44e5f6 | 605 | struct fbcon_ops *ops = info->fbcon_par; |
1da177e4 LT |
606 | int cnt, erase = vc->vc_video_erase_char, step; |
607 | unsigned short *save = NULL, *r, *q; | |
49a1d28f | 608 | int logo_height; |
1da177e4 | 609 | |
70802c60 AD |
610 | if (info->flags & FBINFO_MODULE) { |
611 | logo_shown = FBCON_LOGO_DONTSHOW; | |
612 | return; | |
613 | } | |
614 | ||
1da177e4 LT |
615 | /* |
616 | * remove underline attribute from erase character | |
617 | * if black and white framebuffer. | |
618 | */ | |
b8c90945 | 619 | if (fb_get_color_depth(&info->var, &info->fix) == 1) |
1da177e4 | 620 | erase &= ~0x400; |
9c44e5f6 | 621 | logo_height = fb_prepare_logo(info, ops->rotate); |
416e74ea | 622 | logo_lines = DIV_ROUND_UP(logo_height, vc->vc_font.height); |
1da177e4 LT |
623 | q = (unsigned short *) (vc->vc_origin + |
624 | vc->vc_size_row * rows); | |
625 | step = logo_lines * cols; | |
626 | for (r = q - logo_lines * cols; r < q; r++) | |
627 | if (scr_readw(r) != vc->vc_video_erase_char) | |
628 | break; | |
629 | if (r != q && new_rows >= rows + logo_lines) { | |
630 | save = kmalloc(logo_lines * new_cols * 2, GFP_KERNEL); | |
631 | if (save) { | |
632 | int i = cols < new_cols ? cols : new_cols; | |
633 | scr_memsetw(save, erase, logo_lines * new_cols * 2); | |
634 | r = q - step; | |
635 | for (cnt = 0; cnt < logo_lines; cnt++, r += i) | |
636 | scr_memcpyw(save + cnt * new_cols, r, 2 * i); | |
637 | r = q; | |
638 | } | |
639 | } | |
640 | if (r == q) { | |
641 | /* We can scroll screen down */ | |
642 | r = q - step - cols; | |
643 | for (cnt = rows - logo_lines; cnt > 0; cnt--) { | |
644 | scr_memcpyw(r + step, r, vc->vc_size_row); | |
645 | r -= cols; | |
646 | } | |
647 | if (!save) { | |
250038f5 GU |
648 | int lines; |
649 | if (vc->vc_y + logo_lines >= rows) | |
650 | lines = rows - vc->vc_y - 1; | |
651 | else | |
652 | lines = logo_lines; | |
653 | vc->vc_y += lines; | |
654 | vc->vc_pos += lines * vc->vc_size_row; | |
1da177e4 LT |
655 | } |
656 | } | |
657 | scr_memsetw((unsigned short *) vc->vc_origin, | |
658 | erase, | |
659 | vc->vc_size_row * logo_lines); | |
660 | ||
661 | if (CON_IS_VISIBLE(vc) && vc->vc_mode == KD_TEXT) { | |
662 | fbcon_clear_margins(vc, 0); | |
663 | update_screen(vc); | |
664 | } | |
665 | ||
666 | if (save) { | |
667 | q = (unsigned short *) (vc->vc_origin + | |
668 | vc->vc_size_row * | |
669 | rows); | |
670 | scr_memcpyw(q, save, logo_lines * new_cols * 2); | |
671 | vc->vc_y += logo_lines; | |
672 | vc->vc_pos += logo_lines * vc->vc_size_row; | |
673 | kfree(save); | |
674 | } | |
675 | ||
676 | if (logo_lines > vc->vc_bottom) { | |
677 | logo_shown = FBCON_LOGO_CANSHOW; | |
678 | printk(KERN_INFO | |
679 | "fbcon_init: disable boot-logo (boot-logo bigger than screen).\n"); | |
680 | } else if (logo_shown != FBCON_LOGO_DONTSHOW) { | |
681 | logo_shown = FBCON_LOGO_DRAW; | |
682 | vc->vc_top = logo_lines; | |
683 | } | |
684 | } | |
70802c60 | 685 | #endif /* MODULE */ |
1da177e4 LT |
686 | |
687 | #ifdef CONFIG_FB_TILEBLITTING | |
b73deed3 | 688 | static void set_blitting_type(struct vc_data *vc, struct fb_info *info) |
1da177e4 LT |
689 | { |
690 | struct fbcon_ops *ops = info->fbcon_par; | |
691 | ||
b73deed3 | 692 | ops->p = &fb_display[vc->vc_num]; |
ab767201 | 693 | |
1da177e4 | 694 | if ((info->flags & FBINFO_MISC_TILEBLITTING)) |
b73deed3 | 695 | fbcon_set_tileops(vc, info); |
e4fc2761 | 696 | else { |
b73deed3 | 697 | fbcon_set_rotation(info); |
1da177e4 | 698 | fbcon_set_bitops(ops); |
e4fc2761 | 699 | } |
1da177e4 | 700 | } |
38b4982c AD |
701 | |
702 | static int fbcon_invalid_charcount(struct fb_info *info, unsigned charcount) | |
703 | { | |
704 | int err = 0; | |
705 | ||
706 | if (info->flags & FBINFO_MISC_TILEBLITTING && | |
707 | info->tileops->fb_get_tilemax(info) < charcount) | |
708 | err = 1; | |
709 | ||
710 | return err; | |
711 | } | |
1da177e4 | 712 | #else |
b73deed3 | 713 | static void set_blitting_type(struct vc_data *vc, struct fb_info *info) |
1da177e4 LT |
714 | { |
715 | struct fbcon_ops *ops = info->fbcon_par; | |
716 | ||
717 | info->flags &= ~FBINFO_MISC_TILEBLITTING; | |
b73deed3 AD |
718 | ops->p = &fb_display[vc->vc_num]; |
719 | fbcon_set_rotation(info); | |
1da177e4 LT |
720 | fbcon_set_bitops(ops); |
721 | } | |
38b4982c AD |
722 | |
723 | static int fbcon_invalid_charcount(struct fb_info *info, unsigned charcount) | |
724 | { | |
725 | return 0; | |
726 | } | |
727 | ||
1da177e4 LT |
728 | #endif /* CONFIG_MISC_TILEBLITTING */ |
729 | ||
730 | ||
731 | static int con2fb_acquire_newinfo(struct vc_data *vc, struct fb_info *info, | |
732 | int unit, int oldidx) | |
733 | { | |
734 | struct fbcon_ops *ops = NULL; | |
735 | int err = 0; | |
736 | ||
737 | if (!try_module_get(info->fbops->owner)) | |
738 | err = -ENODEV; | |
739 | ||
740 | if (!err && info->fbops->fb_open && | |
741 | info->fbops->fb_open(info, 0)) | |
742 | err = -ENODEV; | |
743 | ||
744 | if (!err) { | |
a39bc34e | 745 | ops = kzalloc(sizeof(struct fbcon_ops), GFP_KERNEL); |
1da177e4 LT |
746 | if (!ops) |
747 | err = -ENOMEM; | |
748 | } | |
749 | ||
750 | if (!err) { | |
1da177e4 | 751 | info->fbcon_par = ops; |
d1baa4ff AD |
752 | |
753 | if (vc) | |
754 | set_blitting_type(vc, info); | |
1da177e4 LT |
755 | } |
756 | ||
757 | if (err) { | |
758 | con2fb_map[unit] = oldidx; | |
759 | module_put(info->fbops->owner); | |
760 | } | |
761 | ||
762 | return err; | |
763 | } | |
764 | ||
765 | static int con2fb_release_oldinfo(struct vc_data *vc, struct fb_info *oldinfo, | |
766 | struct fb_info *newinfo, int unit, | |
767 | int oldidx, int found) | |
768 | { | |
769 | struct fbcon_ops *ops = oldinfo->fbcon_par; | |
770 | int err = 0; | |
771 | ||
772 | if (oldinfo->fbops->fb_release && | |
773 | oldinfo->fbops->fb_release(oldinfo, 0)) { | |
774 | con2fb_map[unit] = oldidx; | |
775 | if (!found && newinfo->fbops->fb_release) | |
776 | newinfo->fbops->fb_release(newinfo, 0); | |
777 | if (!found) | |
778 | module_put(newinfo->fbops->owner); | |
779 | err = -ENODEV; | |
780 | } | |
781 | ||
782 | if (!err) { | |
88fb2c6e | 783 | fbcon_del_cursor_timer(oldinfo); |
1da177e4 LT |
784 | kfree(ops->cursor_state.mask); |
785 | kfree(ops->cursor_data); | |
e4fc2761 | 786 | kfree(ops->fontbuffer); |
1da177e4 LT |
787 | kfree(oldinfo->fbcon_par); |
788 | oldinfo->fbcon_par = NULL; | |
789 | module_put(oldinfo->fbops->owner); | |
dd0314f7 AD |
790 | /* |
791 | If oldinfo and newinfo are driving the same hardware, | |
792 | the fb_release() method of oldinfo may attempt to | |
793 | restore the hardware state. This will leave the | |
794 | newinfo in an undefined state. Thus, a call to | |
795 | fb_set_par() may be needed for the newinfo. | |
796 | */ | |
797 | if (newinfo->fbops->fb_set_par) | |
798 | newinfo->fbops->fb_set_par(newinfo); | |
1da177e4 LT |
799 | } |
800 | ||
801 | return err; | |
802 | } | |
803 | ||
1da177e4 LT |
804 | static void con2fb_init_display(struct vc_data *vc, struct fb_info *info, |
805 | int unit, int show_logo) | |
806 | { | |
807 | struct fbcon_ops *ops = info->fbcon_par; | |
808 | ||
809 | ops->currcon = fg_console; | |
810 | ||
811 | if (info->fbops->fb_set_par && !(ops->flags & FBCON_FLAGS_INIT)) | |
812 | info->fbops->fb_set_par(info); | |
813 | ||
814 | ops->flags |= FBCON_FLAGS_INIT; | |
815 | ops->graphics = 0; | |
d1baa4ff | 816 | fbcon_set_disp(info, &info->var, unit); |
1da177e4 LT |
817 | |
818 | if (show_logo) { | |
819 | struct vc_data *fg_vc = vc_cons[fg_console].d; | |
820 | struct fb_info *fg_info = | |
821 | registered_fb[con2fb_map[fg_console]]; | |
822 | ||
823 | fbcon_prepare_logo(fg_vc, fg_info, fg_vc->vc_cols, | |
824 | fg_vc->vc_rows, fg_vc->vc_cols, | |
825 | fg_vc->vc_rows); | |
826 | } | |
827 | ||
828 | update_screen(vc_cons[fg_console].d); | |
829 | } | |
830 | ||
831 | /** | |
832 | * set_con2fb_map - map console to frame buffer device | |
833 | * @unit: virtual console number to map | |
834 | * @newidx: frame buffer index to map virtual console to | |
835 | * @user: user request | |
836 | * | |
837 | * Maps a virtual console @unit to a frame buffer device | |
838 | * @newidx. | |
839 | */ | |
840 | static int set_con2fb_map(int unit, int newidx, int user) | |
841 | { | |
842 | struct vc_data *vc = vc_cons[unit].d; | |
843 | int oldidx = con2fb_map[unit]; | |
844 | struct fb_info *info = registered_fb[newidx]; | |
845 | struct fb_info *oldinfo = NULL; | |
846 | int found, err = 0; | |
847 | ||
848 | if (oldidx == newidx) | |
849 | return 0; | |
850 | ||
e614b18d AD |
851 | if (!info || fbcon_has_exited) |
852 | return -EINVAL; | |
1da177e4 LT |
853 | |
854 | if (!err && !search_for_mapped_con()) { | |
855 | info_idx = newidx; | |
856 | return fbcon_takeover(0); | |
857 | } | |
858 | ||
859 | if (oldidx != -1) | |
860 | oldinfo = registered_fb[oldidx]; | |
861 | ||
862 | found = search_fb_in_map(newidx); | |
863 | ||
864 | acquire_console_sem(); | |
865 | con2fb_map[unit] = newidx; | |
866 | if (!err && !found) | |
867 | err = con2fb_acquire_newinfo(vc, info, unit, oldidx); | |
868 | ||
869 | ||
870 | /* | |
871 | * If old fb is not mapped to any of the consoles, | |
872 | * fbcon should release it. | |
873 | */ | |
874 | if (!err && oldinfo && !search_fb_in_map(oldidx)) | |
875 | err = con2fb_release_oldinfo(vc, oldinfo, info, unit, oldidx, | |
876 | found); | |
877 | ||
878 | if (!err) { | |
879 | int show_logo = (fg_console == 0 && !user && | |
880 | logo_shown != FBCON_LOGO_DONTSHOW); | |
881 | ||
882 | if (!found) | |
88fb2c6e | 883 | fbcon_add_cursor_timer(info); |
1da177e4 LT |
884 | con2fb_map_boot[unit] = newidx; |
885 | con2fb_init_display(vc, info, unit, show_logo); | |
886 | } | |
887 | ||
e614b18d AD |
888 | if (!search_fb_in_map(info_idx)) |
889 | info_idx = newidx; | |
890 | ||
1da177e4 LT |
891 | release_console_sem(); |
892 | return err; | |
893 | } | |
894 | ||
895 | /* | |
896 | * Low Level Operations | |
897 | */ | |
898 | /* NOTE: fbcon cannot be __init: it may be called from take_over_console later */ | |
899 | static int var_to_display(struct display *disp, | |
900 | struct fb_var_screeninfo *var, | |
901 | struct fb_info *info) | |
902 | { | |
903 | disp->xres_virtual = var->xres_virtual; | |
904 | disp->yres_virtual = var->yres_virtual; | |
905 | disp->bits_per_pixel = var->bits_per_pixel; | |
906 | disp->grayscale = var->grayscale; | |
907 | disp->nonstd = var->nonstd; | |
908 | disp->accel_flags = var->accel_flags; | |
909 | disp->height = var->height; | |
910 | disp->width = var->width; | |
911 | disp->red = var->red; | |
912 | disp->green = var->green; | |
913 | disp->blue = var->blue; | |
914 | disp->transp = var->transp; | |
915 | disp->rotate = var->rotate; | |
916 | disp->mode = fb_match_mode(var, &info->modelist); | |
917 | if (disp->mode == NULL) | |
918 | /* This should not happen */ | |
919 | return -EINVAL; | |
920 | return 0; | |
921 | } | |
922 | ||
923 | static void display_to_var(struct fb_var_screeninfo *var, | |
924 | struct display *disp) | |
925 | { | |
926 | fb_videomode_to_var(var, disp->mode); | |
927 | var->xres_virtual = disp->xres_virtual; | |
928 | var->yres_virtual = disp->yres_virtual; | |
929 | var->bits_per_pixel = disp->bits_per_pixel; | |
930 | var->grayscale = disp->grayscale; | |
931 | var->nonstd = disp->nonstd; | |
932 | var->accel_flags = disp->accel_flags; | |
933 | var->height = disp->height; | |
934 | var->width = disp->width; | |
935 | var->red = disp->red; | |
936 | var->green = disp->green; | |
937 | var->blue = disp->blue; | |
938 | var->transp = disp->transp; | |
939 | var->rotate = disp->rotate; | |
940 | } | |
941 | ||
942 | static const char *fbcon_startup(void) | |
943 | { | |
944 | const char *display_desc = "frame buffer device"; | |
945 | struct display *p = &fb_display[fg_console]; | |
946 | struct vc_data *vc = vc_cons[fg_console].d; | |
2f4516db | 947 | const struct font_desc *font = NULL; |
1da177e4 LT |
948 | struct module *owner; |
949 | struct fb_info *info = NULL; | |
950 | struct fbcon_ops *ops; | |
951 | int rows, cols; | |
952 | int irqres; | |
953 | ||
954 | irqres = 1; | |
955 | /* | |
956 | * If num_registered_fb is zero, this is a call for the dummy part. | |
957 | * The frame buffer devices weren't initialized yet. | |
958 | */ | |
959 | if (!num_registered_fb || info_idx == -1) | |
960 | return display_desc; | |
961 | /* | |
962 | * Instead of blindly using registered_fb[0], we use info_idx, set by | |
963 | * fb_console_init(); | |
964 | */ | |
965 | info = registered_fb[info_idx]; | |
966 | if (!info) | |
967 | return NULL; | |
968 | ||
969 | owner = info->fbops->owner; | |
970 | if (!try_module_get(owner)) | |
971 | return NULL; | |
972 | if (info->fbops->fb_open && info->fbops->fb_open(info, 0)) { | |
973 | module_put(owner); | |
974 | return NULL; | |
975 | } | |
976 | ||
a39bc34e | 977 | ops = kzalloc(sizeof(struct fbcon_ops), GFP_KERNEL); |
1da177e4 LT |
978 | if (!ops) { |
979 | module_put(owner); | |
980 | return NULL; | |
981 | } | |
982 | ||
1da177e4 LT |
983 | ops->currcon = -1; |
984 | ops->graphics = 1; | |
e4fc2761 | 985 | ops->cur_rotate = -1; |
1da177e4 | 986 | info->fbcon_par = ops; |
2428e59b | 987 | p->con_rotate = initial_rotation; |
b73deed3 | 988 | set_blitting_type(vc, info); |
1da177e4 LT |
989 | |
990 | if (info->fix.type != FB_TYPE_TEXT) { | |
991 | if (fbcon_softback_size) { | |
992 | if (!softback_buf) { | |
993 | softback_buf = | |
994 | (unsigned long) | |
995 | kmalloc(fbcon_softback_size, | |
996 | GFP_KERNEL); | |
997 | if (!softback_buf) { | |
998 | fbcon_softback_size = 0; | |
999 | softback_top = 0; | |
1000 | } | |
1001 | } | |
1002 | } else { | |
1003 | if (softback_buf) { | |
1004 | kfree((void *) softback_buf); | |
1005 | softback_buf = 0; | |
1006 | softback_top = 0; | |
1007 | } | |
1008 | } | |
1009 | if (softback_buf) | |
1010 | softback_in = softback_top = softback_curr = | |
1011 | softback_buf; | |
1012 | softback_lines = 0; | |
1013 | } | |
1014 | ||
1015 | /* Setup default font */ | |
1016 | if (!p->fontdata) { | |
1017 | if (!fontname[0] || !(font = find_font(fontname))) | |
1018 | font = get_default_font(info->var.xres, | |
2d2699d9 AD |
1019 | info->var.yres, |
1020 | info->pixmap.blit_x, | |
1021 | info->pixmap.blit_y); | |
1da177e4 LT |
1022 | vc->vc_font.width = font->width; |
1023 | vc->vc_font.height = font->height; | |
2f4516db | 1024 | vc->vc_font.data = (void *)(p->fontdata = font->data); |
1da177e4 LT |
1025 | vc->vc_font.charcount = 256; /* FIXME Need to support more fonts */ |
1026 | } | |
1027 | ||
e4fc2761 AD |
1028 | cols = FBCON_SWAP(ops->rotate, info->var.xres, info->var.yres); |
1029 | rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres); | |
1030 | cols /= vc->vc_font.width; | |
1031 | rows /= vc->vc_font.height; | |
1da177e4 LT |
1032 | vc_resize(vc, cols, rows); |
1033 | ||
1034 | DPRINTK("mode: %s\n", info->fix.id); | |
1035 | DPRINTK("visual: %d\n", info->fix.visual); | |
1036 | DPRINTK("res: %dx%d-%d\n", info->var.xres, | |
1037 | info->var.yres, | |
1038 | info->var.bits_per_pixel); | |
1039 | ||
1040 | #ifdef CONFIG_ATARI | |
1041 | if (MACH_IS_ATARI) { | |
1042 | cursor_blink_rate = ATARI_CURSOR_BLINK_RATE; | |
1043 | irqres = | |
1044 | request_irq(IRQ_AUTO_4, fb_vbl_handler, | |
1045 | IRQ_TYPE_PRIO, "framebuffer vbl", | |
1046 | info); | |
1047 | } | |
1048 | #endif /* CONFIG_ATARI */ | |
1049 | ||
1050 | #ifdef CONFIG_MAC | |
1051 | /* | |
1052 | * On a Macintoy, the VBL interrupt may or may not be active. | |
1053 | * As interrupt based cursor is more reliable and race free, we | |
1054 | * probe for VBL interrupts. | |
1055 | */ | |
1056 | if (MACH_IS_MAC) { | |
1057 | int ct = 0; | |
1058 | /* | |
1059 | * Probe for VBL: set temp. handler ... | |
1060 | */ | |
1061 | irqres = request_irq(IRQ_MAC_VBL, fb_vbl_detect, 0, | |
1062 | "framebuffer vbl", info); | |
1063 | vbl_detected = 0; | |
1064 | ||
1065 | /* | |
1066 | * ... and spin for 20 ms ... | |
1067 | */ | |
1068 | while (!vbl_detected && ++ct < 1000) | |
1069 | udelay(20); | |
1070 | ||
1071 | if (ct == 1000) | |
1072 | printk | |
1073 | ("fbcon_startup: No VBL detected, using timer based cursor.\n"); | |
1074 | ||
1075 | free_irq(IRQ_MAC_VBL, fb_vbl_detect); | |
1076 | ||
1077 | if (vbl_detected) { | |
1078 | /* | |
1079 | * interrupt based cursor ok | |
1080 | */ | |
1081 | cursor_blink_rate = MAC_CURSOR_BLINK_RATE; | |
1082 | irqres = | |
1083 | request_irq(IRQ_MAC_VBL, fb_vbl_handler, 0, | |
1084 | "framebuffer vbl", info); | |
1085 | } else { | |
1086 | /* | |
1087 | * VBL not detected: fall through, use timer based cursor | |
1088 | */ | |
1089 | irqres = 1; | |
1090 | } | |
1091 | } | |
1092 | #endif /* CONFIG_MAC */ | |
1093 | ||
88fb2c6e | 1094 | fbcon_add_cursor_timer(info); |
e614b18d | 1095 | fbcon_has_exited = 0; |
1da177e4 LT |
1096 | return display_desc; |
1097 | } | |
1098 | ||
1099 | static void fbcon_init(struct vc_data *vc, int init) | |
1100 | { | |
1101 | struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]]; | |
1102 | struct fbcon_ops *ops; | |
1103 | struct vc_data **default_mode = vc->vc_display_fg; | |
1104 | struct vc_data *svc = *default_mode; | |
1105 | struct display *t, *p = &fb_display[vc->vc_num]; | |
1106 | int logo = 1, new_rows, new_cols, rows, cols, charcnt = 256; | |
306958e8 | 1107 | int cap; |
1da177e4 LT |
1108 | |
1109 | if (info_idx == -1 || info == NULL) | |
1110 | return; | |
306958e8 AB |
1111 | |
1112 | cap = info->flags; | |
1113 | ||
1da177e4 LT |
1114 | if (vc != svc || logo_shown == FBCON_LOGO_DONTSHOW || |
1115 | (info->fix.type == FB_TYPE_TEXT)) | |
1116 | logo = 0; | |
1117 | ||
1da177e4 LT |
1118 | if (var_to_display(p, &info->var, info)) |
1119 | return; | |
1120 | ||
d1baa4ff AD |
1121 | if (!info->fbcon_par) |
1122 | con2fb_acquire_newinfo(vc, info, vc->vc_num, -1); | |
1123 | ||
1da177e4 LT |
1124 | /* If we are not the first console on this |
1125 | fb, copy the font from that console */ | |
e614b18d AD |
1126 | t = &fb_display[fg_console]; |
1127 | if (!p->fontdata) { | |
1128 | if (t->fontdata) { | |
1129 | struct vc_data *fvc = vc_cons[fg_console].d; | |
1130 | ||
1131 | vc->vc_font.data = (void *)(p->fontdata = | |
1132 | fvc->vc_font.data); | |
1133 | vc->vc_font.width = fvc->vc_font.width; | |
1134 | vc->vc_font.height = fvc->vc_font.height; | |
1135 | p->userfont = t->userfont; | |
1136 | ||
1137 | if (p->userfont) | |
1138 | REFCOUNT(p->fontdata)++; | |
1139 | } else { | |
1140 | const struct font_desc *font = NULL; | |
1141 | ||
1142 | if (!fontname[0] || !(font = find_font(fontname))) | |
1143 | font = get_default_font(info->var.xres, | |
2d2699d9 AD |
1144 | info->var.yres, |
1145 | info->pixmap.blit_x, | |
1146 | info->pixmap.blit_y); | |
e614b18d AD |
1147 | vc->vc_font.width = font->width; |
1148 | vc->vc_font.height = font->height; | |
1149 | vc->vc_font.data = (void *)(p->fontdata = font->data); | |
1150 | vc->vc_font.charcount = 256; /* FIXME Need to | |
1151 | support more fonts */ | |
1152 | } | |
1da177e4 | 1153 | } |
e614b18d | 1154 | |
1da177e4 LT |
1155 | if (p->userfont) |
1156 | charcnt = FNTCHARCNT(p->fontdata); | |
e614b18d | 1157 | |
b8c90945 | 1158 | vc->vc_can_do_color = (fb_get_color_depth(&info->var, &info->fix)!=1); |
1da177e4 LT |
1159 | vc->vc_complement_mask = vc->vc_can_do_color ? 0x7700 : 0x0800; |
1160 | if (charcnt == 256) { | |
1161 | vc->vc_hi_font_mask = 0; | |
1162 | } else { | |
1163 | vc->vc_hi_font_mask = 0x100; | |
1164 | if (vc->vc_can_do_color) | |
1165 | vc->vc_complement_mask <<= 1; | |
1166 | } | |
1167 | ||
1168 | if (!*svc->vc_uni_pagedir_loc) | |
1169 | con_set_default_unimap(svc); | |
1170 | if (!*vc->vc_uni_pagedir_loc) | |
1171 | con_copy_unimap(vc, svc); | |
1172 | ||
e4fc2761 | 1173 | ops = info->fbcon_par; |
2428e59b | 1174 | p->con_rotate = initial_rotation; |
b73deed3 | 1175 | set_blitting_type(vc, info); |
e4fc2761 | 1176 | |
1da177e4 LT |
1177 | cols = vc->vc_cols; |
1178 | rows = vc->vc_rows; | |
e4fc2761 AD |
1179 | new_cols = FBCON_SWAP(ops->rotate, info->var.xres, info->var.yres); |
1180 | new_rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres); | |
1181 | new_cols /= vc->vc_font.width; | |
1182 | new_rows /= vc->vc_font.height; | |
1da177e4 LT |
1183 | vc_resize(vc, new_cols, new_rows); |
1184 | ||
1da177e4 LT |
1185 | /* |
1186 | * We must always set the mode. The mode of the previous console | |
1187 | * driver could be in the same resolution but we are using different | |
1188 | * hardware so we have to initialize the hardware. | |
1189 | * | |
1190 | * We need to do it in fbcon_init() to prevent screen corruption. | |
1191 | */ |