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