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) { | |
451 | if (!strncmp(options, "font:", 5)) | |
e432964a | 452 | strlcpy(fontname, options + 5, sizeof(fontname)); |
1da177e4 LT |
453 | |
454 | if (!strncmp(options, "scrollback:", 11)) { | |
455 | options += 11; | |
456 | if (*options) { | |
457 | fbcon_softback_size = simple_strtoul(options, &options, 0); | |
458 | if (*options == 'k' || *options == 'K') { | |
459 | fbcon_softback_size *= 1024; | |
460 | options++; | |
461 | } | |
462 | if (*options != ',') | |
9b41046c | 463 | return 1; |
1da177e4 LT |
464 | options++; |
465 | } else | |
9b41046c | 466 | return 1; |
1da177e4 LT |
467 | } |
468 | ||
469 | if (!strncmp(options, "map:", 4)) { | |
470 | options += 4; | |
623e71b0 | 471 | if (*options) { |
1da177e4 LT |
472 | for (i = 0, j = 0; i < MAX_NR_CONSOLES; i++) { |
473 | if (!options[j]) | |
474 | j = 0; | |
475 | con2fb_map_boot[i] = | |
476 | (options[j++]-'0') % FB_MAX; | |
477 | } | |
623e71b0 | 478 | |
4769a9a5 | 479 | fbcon_map_override(); |
623e71b0 AD |
480 | } |
481 | ||
9b41046c | 482 | return 1; |
1da177e4 LT |
483 | } |
484 | ||
485 | if (!strncmp(options, "vc:", 3)) { | |
486 | options += 3; | |
487 | if (*options) | |
488 | first_fb_vc = simple_strtoul(options, &options, 10) - 1; | |
489 | if (first_fb_vc < 0) | |
490 | first_fb_vc = 0; | |
491 | if (*options++ == '-') | |
492 | last_fb_vc = simple_strtoul(options, &options, 10) - 1; | |
493 | fbcon_is_default = 0; | |
494 | } | |
e4fc2761 AD |
495 | |
496 | if (!strncmp(options, "rotate:", 7)) { | |
497 | options += 7; | |
498 | if (*options) | |
2428e59b MS |
499 | initial_rotation = simple_strtoul(options, &options, 0); |
500 | if (initial_rotation > 3) | |
501 | initial_rotation = 0; | |
e4fc2761 | 502 | } |
1da177e4 | 503 | } |
9b41046c | 504 | return 1; |
1da177e4 LT |
505 | } |
506 | ||
507 | __setup("fbcon=", fb_console_setup); | |
508 | #endif | |
509 | ||
510 | static int search_fb_in_map(int idx) | |
511 | { | |
512 | int i, retval = 0; | |
513 | ||
e614b18d | 514 | for (i = first_fb_vc; i <= last_fb_vc; i++) { |
1da177e4 LT |
515 | if (con2fb_map[i] == idx) |
516 | retval = 1; | |
517 | } | |
518 | return retval; | |
519 | } | |
520 | ||
521 | static int search_for_mapped_con(void) | |
522 | { | |
523 | int i, retval = 0; | |
524 | ||
e614b18d | 525 | for (i = first_fb_vc; i <= last_fb_vc; i++) { |
1da177e4 LT |
526 | if (con2fb_map[i] != -1) |
527 | retval = 1; | |
528 | } | |
529 | return retval; | |
530 | } | |
531 | ||
50e244cc AC |
532 | static int do_fbcon_takeover(int show_logo) |
533 | { | |
534 | int err, i; | |
535 | ||
536 | if (!num_registered_fb) | |
537 | return -ENODEV; | |
538 | ||
539 | if (!show_logo) | |
540 | logo_shown = FBCON_LOGO_DONTSHOW; | |
541 | ||
542 | for (i = first_fb_vc; i <= last_fb_vc; i++) | |
543 | con2fb_map[i] = info_idx; | |
544 | ||
545 | err = do_take_over_console(&fb_con, first_fb_vc, last_fb_vc, | |
546 | fbcon_is_default); | |
547 | ||
548 | if (err) { | |
549 | for (i = first_fb_vc; i <= last_fb_vc; i++) | |
550 | con2fb_map[i] = -1; | |
551 | info_idx = -1; | |
552 | } else { | |
553 | fbcon_has_console_bind = 1; | |
1da177e4 LT |
554 | } |
555 | ||
556 | return err; | |
557 | } | |
558 | ||
70802c60 AD |
559 | #ifdef MODULE |
560 | static void fbcon_prepare_logo(struct vc_data *vc, struct fb_info *info, | |
561 | int cols, int rows, int new_cols, int new_rows) | |
562 | { | |
563 | logo_shown = FBCON_LOGO_DONTSHOW; | |
564 | } | |
565 | #else | |
1da177e4 LT |
566 | static void fbcon_prepare_logo(struct vc_data *vc, struct fb_info *info, |
567 | int cols, int rows, int new_cols, int new_rows) | |
568 | { | |
569 | /* Need to make room for the logo */ | |
9c44e5f6 | 570 | struct fbcon_ops *ops = info->fbcon_par; |
1da177e4 LT |
571 | int cnt, erase = vc->vc_video_erase_char, step; |
572 | unsigned short *save = NULL, *r, *q; | |
49a1d28f | 573 | int logo_height; |
1da177e4 | 574 | |
70802c60 AD |
575 | if (info->flags & FBINFO_MODULE) { |
576 | logo_shown = FBCON_LOGO_DONTSHOW; | |
577 | return; | |
578 | } | |
579 | ||
1da177e4 LT |
580 | /* |
581 | * remove underline attribute from erase character | |
582 | * if black and white framebuffer. | |
583 | */ | |
b8c90945 | 584 | if (fb_get_color_depth(&info->var, &info->fix) == 1) |
1da177e4 | 585 | erase &= ~0x400; |
9c44e5f6 | 586 | logo_height = fb_prepare_logo(info, ops->rotate); |
416e74ea | 587 | logo_lines = DIV_ROUND_UP(logo_height, vc->vc_font.height); |
1da177e4 LT |
588 | q = (unsigned short *) (vc->vc_origin + |
589 | vc->vc_size_row * rows); | |
590 | step = logo_lines * cols; | |
591 | for (r = q - logo_lines * cols; r < q; r++) | |
592 | if (scr_readw(r) != vc->vc_video_erase_char) | |
593 | break; | |
594 | if (r != q && new_rows >= rows + logo_lines) { | |
595 | save = kmalloc(logo_lines * new_cols * 2, GFP_KERNEL); | |
596 | if (save) { | |
597 | int i = cols < new_cols ? cols : new_cols; | |
598 | scr_memsetw(save, erase, logo_lines * new_cols * 2); | |
599 | r = q - step; | |
600 | for (cnt = 0; cnt < logo_lines; cnt++, r += i) | |
601 | scr_memcpyw(save + cnt * new_cols, r, 2 * i); | |
602 | r = q; | |
603 | } | |
604 | } | |
605 | if (r == q) { | |
606 | /* We can scroll screen down */ | |
607 | r = q - step - cols; | |
608 | for (cnt = rows - logo_lines; cnt > 0; cnt--) { | |
609 | scr_memcpyw(r + step, r, vc->vc_size_row); | |
610 | r -= cols; | |
611 | } | |
612 | if (!save) { | |
250038f5 GU |
613 | int lines; |
614 | if (vc->vc_y + logo_lines >= rows) | |
615 | lines = rows - vc->vc_y - 1; | |
616 | else | |
617 | lines = logo_lines; | |
618 | vc->vc_y += lines; | |
619 | vc->vc_pos += lines * vc->vc_size_row; | |
1da177e4 LT |
620 | } |
621 | } | |
622 | scr_memsetw((unsigned short *) vc->vc_origin, | |
623 | erase, | |
624 | vc->vc_size_row * logo_lines); | |
625 | ||
626 | if (CON_IS_VISIBLE(vc) && vc->vc_mode == KD_TEXT) { | |
627 | fbcon_clear_margins(vc, 0); | |
628 | update_screen(vc); | |
629 | } | |
630 | ||
631 | if (save) { | |
632 | q = (unsigned short *) (vc->vc_origin + | |
633 | vc->vc_size_row * | |
634 | rows); | |
635 | scr_memcpyw(q, save, logo_lines * new_cols * 2); | |
636 | vc->vc_y += logo_lines; | |
637 | vc->vc_pos += logo_lines * vc->vc_size_row; | |
638 | kfree(save); | |
639 | } | |
640 | ||
641 | if (logo_lines > vc->vc_bottom) { | |
642 | logo_shown = FBCON_LOGO_CANSHOW; | |
643 | printk(KERN_INFO | |
644 | "fbcon_init: disable boot-logo (boot-logo bigger than screen).\n"); | |
645 | } else if (logo_shown != FBCON_LOGO_DONTSHOW) { | |
646 | logo_shown = FBCON_LOGO_DRAW; | |
647 | vc->vc_top = logo_lines; | |
648 | } | |
649 | } | |
70802c60 | 650 | #endif /* MODULE */ |
1da177e4 LT |
651 | |
652 | #ifdef CONFIG_FB_TILEBLITTING | |
b73deed3 | 653 | static void set_blitting_type(struct vc_data *vc, struct fb_info *info) |
1da177e4 LT |
654 | { |
655 | struct fbcon_ops *ops = info->fbcon_par; | |
656 | ||
b73deed3 | 657 | ops->p = &fb_display[vc->vc_num]; |
ab767201 | 658 | |
1da177e4 | 659 | if ((info->flags & FBINFO_MISC_TILEBLITTING)) |
b73deed3 | 660 | fbcon_set_tileops(vc, info); |
e4fc2761 | 661 | else { |
b73deed3 | 662 | fbcon_set_rotation(info); |
1da177e4 | 663 | fbcon_set_bitops(ops); |
e4fc2761 | 664 | } |
1da177e4 | 665 | } |
38b4982c AD |
666 | |
667 | static int fbcon_invalid_charcount(struct fb_info *info, unsigned charcount) | |
668 | { | |
669 | int err = 0; | |
670 | ||
671 | if (info->flags & FBINFO_MISC_TILEBLITTING && | |
672 | info->tileops->fb_get_tilemax(info) < charcount) | |
673 | err = 1; | |
674 | ||
675 | return err; | |
676 | } | |
1da177e4 | 677 | #else |
b73deed3 | 678 | static void set_blitting_type(struct vc_data *vc, struct fb_info *info) |
1da177e4 LT |
679 | { |
680 | struct fbcon_ops *ops = info->fbcon_par; | |
681 | ||
682 | info->flags &= ~FBINFO_MISC_TILEBLITTING; | |
b73deed3 AD |
683 | ops->p = &fb_display[vc->vc_num]; |
684 | fbcon_set_rotation(info); | |
1da177e4 LT |
685 | fbcon_set_bitops(ops); |
686 | } | |
38b4982c AD |
687 | |
688 | static int fbcon_invalid_charcount(struct fb_info *info, unsigned charcount) | |
689 | { | |
690 | return 0; | |
691 | } | |
692 | ||
1da177e4 LT |
693 | #endif /* CONFIG_MISC_TILEBLITTING */ |
694 | ||
695 | ||
696 | static int con2fb_acquire_newinfo(struct vc_data *vc, struct fb_info *info, | |
697 | int unit, int oldidx) | |
698 | { | |
699 | struct fbcon_ops *ops = NULL; | |
700 | int err = 0; | |
701 | ||
702 | if (!try_module_get(info->fbops->owner)) | |
703 | err = -ENODEV; | |
704 | ||
705 | if (!err && info->fbops->fb_open && | |
706 | info->fbops->fb_open(info, 0)) | |
707 | err = -ENODEV; | |
708 | ||
709 | if (!err) { | |
a39bc34e | 710 | ops = kzalloc(sizeof(struct fbcon_ops), GFP_KERNEL); |
1da177e4 LT |
711 | if (!ops) |
712 | err = -ENOMEM; | |
713 | } | |
714 | ||
715 | if (!err) { | |
1da177e4 | 716 | info->fbcon_par = ops; |
d1baa4ff AD |
717 | |
718 | if (vc) | |
719 | set_blitting_type(vc, info); | |
1da177e4 LT |
720 | } |
721 | ||
722 | if (err) { | |
723 | con2fb_map[unit] = oldidx; | |
724 | module_put(info->fbops->owner); | |
725 | } | |
726 | ||
727 | return err; | |
728 | } | |
729 | ||
730 | static int con2fb_release_oldinfo(struct vc_data *vc, struct fb_info *oldinfo, | |
731 | struct fb_info *newinfo, int unit, | |
732 | int oldidx, int found) | |
733 | { | |
734 | struct fbcon_ops *ops = oldinfo->fbcon_par; | |
0fcf6ada | 735 | int err = 0, ret; |
1da177e4 LT |
736 | |
737 | if (oldinfo->fbops->fb_release && | |
738 | oldinfo->fbops->fb_release(oldinfo, 0)) { | |
739 | con2fb_map[unit] = oldidx; | |
740 | if (!found && newinfo->fbops->fb_release) | |
741 | newinfo->fbops->fb_release(newinfo, 0); | |
742 | if (!found) | |
743 | module_put(newinfo->fbops->owner); | |
744 | err = -ENODEV; | |
745 | } | |
746 | ||
747 | if (!err) { | |
88fb2c6e | 748 | fbcon_del_cursor_timer(oldinfo); |
1da177e4 LT |
749 | kfree(ops->cursor_state.mask); |
750 | kfree(ops->cursor_data); | |
7a966fbd | 751 | kfree(ops->cursor_src); |
e4fc2761 | 752 | kfree(ops->fontbuffer); |
1da177e4 LT |
753 | kfree(oldinfo->fbcon_par); |
754 | oldinfo->fbcon_par = NULL; | |
755 | module_put(oldinfo->fbops->owner); | |
dd0314f7 AD |
756 | /* |
757 | If oldinfo and newinfo are driving the same hardware, | |
758 | the fb_release() method of oldinfo may attempt to | |
759 | restore the hardware state. This will leave the | |
760 | newinfo in an undefined state. Thus, a call to | |
761 | fb_set_par() may be needed for the newinfo. | |
762 | */ | |
5f4dc28b | 763 | if (newinfo && newinfo->fbops->fb_set_par) { |
0fcf6ada FTS |
764 | ret = newinfo->fbops->fb_set_par(newinfo); |
765 | ||
766 | if (ret) | |
767 | printk(KERN_ERR "con2fb_release_oldinfo: " | |
768 | "detected unhandled fb_set_par error, " | |
769 | "error code %d\n", ret); | |
770 | } | |
1da177e4 LT |
771 | } |
772 | ||
773 | return err; | |
774 | } | |
775 | ||
1da177e4 LT |
776 | static void con2fb_init_display(struct vc_data *vc, struct fb_info *info, |
777 | int unit, int show_logo) | |
778 | { | |
779 | struct fbcon_ops *ops = info->fbcon_par; | |
0fcf6ada | 780 | int ret; |
1da177e4 LT |
781 | |
782 | ops->currcon = fg_console; | |
783 | ||
0fcf6ada FTS |
784 | if (info->fbops->fb_set_par && !(ops->flags & FBCON_FLAGS_INIT)) { |
785 | ret = info->fbops->fb_set_par(info); | |
786 | ||
787 | if (ret) | |
788 | printk(KERN_ERR "con2fb_init_display: detected " | |
789 | "unhandled fb_set_par error, " | |
790 | "error code %d\n", ret); | |
791 | } | |
1da177e4 LT |
792 | |
793 | ops->flags |= FBCON_FLAGS_INIT; | |
794 | ops->graphics = 0; | |
d1baa4ff | 795 | fbcon_set_disp(info, &info->var, unit); |
1da177e4 LT |
796 | |
797 | if (show_logo) { | |
798 | struct vc_data *fg_vc = vc_cons[fg_console].d; | |
799 | struct fb_info *fg_info = | |
800 | registered_fb[con2fb_map[fg_console]]; | |
801 | ||
802 | fbcon_prepare_logo(fg_vc, fg_info, fg_vc->vc_cols, | |
803 | fg_vc->vc_rows, fg_vc->vc_cols, | |
804 | fg_vc->vc_rows); | |
805 | } | |
806 | ||
807 | update_screen(vc_cons[fg_console].d); | |
808 | } | |
809 | ||
810 | /** | |
811 | * set_con2fb_map - map console to frame buffer device | |
812 | * @unit: virtual console number to map | |
813 | * @newidx: frame buffer index to map virtual console to | |
814 | * @user: user request | |
815 | * | |
816 | * Maps a virtual console @unit to a frame buffer device | |
817 | * @newidx. | |
054430e7 DA |
818 | * |
819 | * This should be called with the console lock held. | |
1da177e4 LT |
820 | */ |
821 | static int set_con2fb_map(int unit, int newidx, int user) | |
822 | { | |
823 | struct vc_data *vc = vc_cons[unit].d; | |
824 | int oldidx = con2fb_map[unit]; | |
825 | struct fb_info *info = registered_fb[newidx]; | |
826 | struct fb_info *oldinfo = NULL; | |
827 | int found, err = 0; | |
828 | ||
829 | if (oldidx == newidx) | |
830 | return 0; | |
831 | ||
32b98bf8 | 832 | if (!info) |
e614b18d | 833 | return -EINVAL; |
1da177e4 | 834 | |
32b98bf8 | 835 | if (!search_for_mapped_con() || !con_is_bound(&fb_con)) { |
1da177e4 | 836 | info_idx = newidx; |
054430e7 | 837 | return do_fbcon_takeover(0); |
1da177e4 LT |
838 | } |
839 | ||
840 | if (oldidx != -1) | |
841 | oldinfo = registered_fb[oldidx]; | |
842 | ||
843 | found = search_fb_in_map(newidx); | |
844 | ||
1da177e4 LT |
845 | con2fb_map[unit] = newidx; |
846 | if (!err && !found) | |
847 | err = con2fb_acquire_newinfo(vc, info, unit, oldidx); | |
848 | ||
849 | ||
850 | /* | |
851 | * If old fb is not mapped to any of the consoles, | |
852 | * fbcon should release it. | |
853 | */ | |
854 | if (!err && oldinfo && !search_fb_in_map(oldidx)) | |
855 | err = con2fb_release_oldinfo(vc, oldinfo, info, unit, oldidx, | |
856 | found); | |
857 | ||
858 | if (!err) { | |
859 | int show_logo = (fg_console == 0 && !user && | |
860 | logo_shown != FBCON_LOGO_DONTSHOW); | |
861 | ||
862 | if (!found) | |
88fb2c6e | 863 | fbcon_add_cursor_timer(info); |
1da177e4 LT |
864 | con2fb_map_boot[unit] = newidx; |
865 | con2fb_init_display(vc, info, unit, show_logo); | |
866 | } | |
867 | ||
e614b18d AD |
868 | if (!search_fb_in_map(info_idx)) |
869 | info_idx = newidx; | |
870 | ||
1da177e4 LT |
871 | return err; |
872 | } | |
873 | ||
874 | /* | |
875 | * Low Level Operations | |
876 | */ | |
155957f5 | 877 | /* NOTE: fbcon cannot be __init: it may be called from do_take_over_console later */ |
1da177e4 LT |
878 | static int var_to_display(struct display *disp, |
879 | struct fb_var_screeninfo *var, | |
880 | struct fb_info *info) | |
881 | { | |
882 | disp->xres_virtual = var->xres_virtual; | |
883 | disp->yres_virtual = var->yres_virtual; | |
884 | disp->bits_per_pixel = var->bits_per_pixel; | |
885 | disp->grayscale = var->grayscale; | |
886 | disp->nonstd = var->nonstd; | |
887 | disp->accel_flags = var->accel_flags; | |
888 | disp->height = var->height; | |
889 | disp->width = var->width; | |
890 | disp->red = var->red; | |
891 | disp->green = var->green; | |
892 | disp->blue = var->blue; | |
893 | disp->transp = var->transp; | |
894 | disp->rotate = var->rotate; | |
895 | disp->mode = fb_match_mode(var, &info->modelist); | |
896 | if (disp->mode == NULL) | |
897 | /* This should not happen */ | |
898 | return -EINVAL; | |
899 | return 0; | |
900 | } | |
901 | ||
902 | static void display_to_var(struct fb_var_screeninfo *var, | |
903 | struct display *disp) | |
904 | { | |
905 | fb_videomode_to_var(var, disp->mode); | |
906 | var->xres_virtual = disp->xres_virtual; | |
907 | var->yres_virtual = disp->yres_virtual; | |
908 | var->bits_per_pixel = disp->bits_per_pixel; | |
909 | var->grayscale = disp->grayscale; | |
910 | var->nonstd = disp->nonstd; | |
911 | var->accel_flags = disp->accel_flags; | |
912 | var->height = disp->height; | |
913 | var->width = disp->width; | |
914 | var->red = disp->red; | |
915 | var->green = disp->green; | |
916 | var->blue = disp->blue; | |
917 | var->transp = disp->transp; | |
918 | var->rotate = disp->rotate; | |
919 | } | |
920 | ||
921 | static const char *fbcon_startup(void) | |
922 | { | |
923 | const char *display_desc = "frame buffer device"; | |
924 | struct display *p = &fb_display[fg_console]; | |
925 | struct vc_data *vc = vc_cons[fg_console].d; | |
2f4516db | 926 | const struct font_desc *font = NULL; |
1da177e4 LT |
927 | struct module *owner; |
928 | struct fb_info *info = NULL; | |
929 | struct fbcon_ops *ops; | |
930 | int rows, cols; | |
1da177e4 | 931 | |
1da177e4 LT |
932 | /* |
933 | * If num_registered_fb is zero, this is a call for the dummy part. | |
934 | * The frame buffer devices weren't initialized yet. | |
935 | */ | |
936 | if (!num_registered_fb || info_idx == -1) | |
937 | return display_desc; | |
938 | /* | |
939 | * Instead of blindly using registered_fb[0], we use info_idx, set by | |
940 | * fb_console_init(); | |
941 | */ | |
942 | info = registered_fb[info_idx]; | |
943 | if (!info) | |
944 | return NULL; | |
945 | ||
946 | owner = info->fbops->owner; | |
947 | if (!try_module_get(owner)) | |
948 | return NULL; | |
949 | if (info->fbops->fb_open && info->fbops->fb_open(info, 0)) { | |
950 | module_put(owner); | |
951 | return NULL; | |
952 | } | |
953 | ||
a39bc34e | 954 | ops = kzalloc(sizeof(struct fbcon_ops), GFP_KERNEL); |
1da177e4 LT |
955 | if (!ops) { |
956 | module_put(owner); | |
957 | return NULL; | |
958 | } | |
959 | ||
1da177e4 LT |
960 | ops->currcon = -1; |
961 | ops->graphics = 1; | |
e4fc2761 | 962 | ops->cur_rotate = -1; |
1da177e4 | 963 | info->fbcon_par = ops; |
2428e59b | 964 | p->con_rotate = initial_rotation; |
b73deed3 | 965 | set_blitting_type(vc, info); |
1da177e4 LT |
966 | |
967 | if (info->fix.type != FB_TYPE_TEXT) { | |
968 | if (fbcon_softback_size) { | |
969 | if (!softback_buf) { | |
970 | softback_buf = | |
971 | (unsigned long) | |
972 | kmalloc(fbcon_softback_size, | |
973 | GFP_KERNEL); | |
974 | if (!softback_buf) { | |
975 | fbcon_softback_size = 0; | |
976 | softback_top = 0; | |
977 | } | |
978 | } | |
979 | } else { | |
980 | if (softback_buf) { | |
981 | kfree((void *) softback_buf); | |
982 | softback_buf = 0; | |
983 | softback_top = 0; | |
984 | } | |
985 | } | |
986 | if (softback_buf) | |
987 | softback_in = softback_top = softback_curr = | |
988 | softback_buf; | |
989 | softback_lines = 0; | |
990 | } | |
991 | ||
992 | /* Setup default font */ | |
ae128786 | 993 | if (!p->fontdata && !vc->vc_font.data) { |
1da177e4 LT |
994 | if (!fontname[0] || !(font = find_font(fontname))) |
995 | font = get_default_font(info->var.xres, | |
2d2699d9 AD |
996 | info->var.yres, |
997 | info->pixmap.blit_x, | |
998 | info->pixmap.blit_y); | |
1da177e4 LT |
999 | vc->vc_font.width = font->width; |
1000 | vc->vc_font.height = font->height; | |
2f4516db | 1001 | vc->vc_font.data = (void *)(p->fontdata = font->data); |
1da177e4 | 1002 | vc->vc_font.charcount = 256; /* FIXME Need to support more fonts */ |
ae128786 DA |
1003 | } else { |
1004 | p->fontdata = vc->vc_font.data; | |
1da177e4 LT |
1005 | } |
1006 | ||
e4fc2761 AD |
1007 | cols = FBCON_SWAP(ops->rotate, info->var.xres, info->var.yres); |
1008 | rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres); | |
1009 | cols /= vc->vc_font.width; | |
1010 | rows /= vc->vc_font.height; | |
1da177e4 LT |
1011 | vc_resize(vc, cols, rows); |
1012 | ||
1013 | DPRINTK("mode: %s\n", info->fix.id); | |
1014 | DPRINTK("visual: %d\n", info->fix.visual); | |
1015 | DPRINTK("res: %dx%d-%d\n", info->var.xres, | |
1016 | info->var.yres, | |
1017 | info->var.bits_per_pixel); | |
1018 | ||
88fb2c6e | 1019 | fbcon_add_cursor_timer(info); |
e614b18d | 1020 | fbcon_has_exited = 0; |
1da177e4 LT |
1021 | return display_desc; |
1022 | } | |
1023 | ||
1024 | static void fbcon_init(struct vc_data *vc, int init) | |
1025 | { | |
1026 | struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]]; | |
1027 | struct fbcon_ops *ops; | |
1028 | struct vc_data **default_mode = vc->vc_display_fg; | |
1029 | struct vc_data *svc = *default_mode; | |
1030 | struct display *t, *p = &fb_display[vc->vc_num]; | |
1031 | int logo = 1, new_rows, new_cols, rows, cols, charcnt = 256; | |
0fcf6ada | 1032 | int cap, ret; |
1da177e4 LT |
1033 | |
1034 | if (info_idx == -1 || info == NULL) | |
1035 | return; | |
306958e8 AB |
1036 | |
1037 | cap = info->flags; | |
1038 | ||
1da177e4 LT |
1039 | if (vc != svc || logo_shown == FBCON_LOGO_DONTSHOW || |
1040 | (info->fix.type == FB_TYPE_TEXT)) | |
1041 | logo = 0; | |
1042 | ||
1da177e4 LT |
1043 | if (var_to_display(p, &info->var, info)) |
1044 | return; | |
1045 | ||
d1baa4ff AD |
1046 | if (!info->fbcon_par) |
1047 | con2fb_acquire_newinfo(vc, info, vc->vc_num, -1); | |
1048 | ||
1da177e4 LT |
1049 | /* If we are not the first console on this |
1050 | fb, copy the font from that console */ | |
e614b18d AD |
1051 | t = &fb_display[fg_console]; |
1052 | if (!p->fontdata) { | |
1053 | if (t->fontdata) { | |
1054 | struct vc_data *fvc = vc_cons[fg_console].d; | |
1055 | ||
1056 | vc->vc_font.data = (void *)(p->fontdata = | |
1057 | fvc->vc_font.data); | |
1058 | vc->vc_font.width = fvc->vc_font.width; | |
1059 | vc->vc_font.height = fvc->vc_font.height; | |
1060 | p->userfont = t->userfont; | |
1061 | ||
1062 | if (p->userfont) | |
1063 | REFCOUNT(p->fontdata)++; | |
1064 | } else { | |
1065 | const struct font_desc *font = NULL; | |
1066 | ||
1067 | if (!fontname[0] || !(font = find_font(fontname))) | |
1068 | font = get_default_font(info->var.xres, | |
2d2699d9 AD |
1069 | info->var.yres, |
1070 | info->pixmap.blit_x, | |
1071 | info->pixmap.blit_y); | |
e614b18d AD |
1072 | vc->vc_font.width = font->width; |
1073 | vc->vc_font.height = font->height; | |
1074 | vc->vc_font.data = (void *)(p->fontdata = font->data); | |
1075 | vc->vc_font.charcount = 256; /* FIXME Need to | |
1076 | support more fonts */ | |
1077 | } | |
1da177e4 | 1078 | } |
e614b18d | 1079 | |
1da177e4 LT |
1080 | if (p->userfont) |
1081 | charcnt = FNTCHARCNT(p->fontdata); | |
e614b18d | 1082 | |
8fd4bd22 | 1083 | vc->vc_panic_force_write = !!(info->flags & FBINFO_CAN_FORCE_OUTPUT); |
b8c90945 | 1084 | vc->vc_can_do_color = (fb_get_color_depth(&info->var, &info->fix)!=1); |
1da177e4 LT |
1085 | vc->vc_complement_mask = vc->vc_can_do_color ? 0x7700 : 0x0800; |
1086 | if (charcnt == 256) { | |
1087 | vc->vc_hi_font_mask = 0; | |
1088 | } else { | |
1089 | vc->vc_hi_font_mask = 0x100; | |
1090 | if (vc->vc_can_do_color) | |
1091 | vc->vc_complement_mask <<= 1; | |
1092 | } | |
1093 | ||
1094 | if (!*svc->vc_uni_pagedir_loc) | |
1095 | con_set_default_unimap(svc); | |
1096 | if (!*vc->vc_uni_pagedir_loc) | |
1097 | con_copy_unimap(vc, svc); | |
1098 | ||
e4fc2761 | 1099 | ops = info->fbcon_par; |
2428e59b | 1100 | p->con_rotate = initial_rotation; |
b73deed3 | 1101 | set_blitting_type(vc, info); |
e4fc2761 | 1102 | |
1da177e4 LT |
1103 | cols = vc->vc_cols; |
1104 | rows = vc->vc_rows; | |
e4fc2761 AD |
1105 | new_cols = FBCON_SWAP(ops->rotate, info->var.xres, info->var.yres); |
1106 | new_rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres); | |
1107 | new_cols /= vc->vc_font.width; | |
1108 | new_rows /= vc->vc_font.height; | |
1da177e4 | 1109 | |
1da177e4 LT |
1110 | /* |
1111 | * We must always set the mode. The mode of the previous console | |
1112 | * driver could be in the same resolution but we are using different | |
1113 | * hardware so we have to initialize the hardware. | |
1114 | * | |
1115 | * We need to do it in fbcon_init() to prevent screen corruption. | |
1116 | */ |