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