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