Root/
Source at commit 92eebd0a3b1181ad5904903698f85b3716ae3c10 created 11 years 9 months ago. By Maarten ter Huurne, MIPS: JZ4740: Work around fbcon logo crash with SLCD | |
---|---|
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 | |
61 | #include <linux/module.h> |
62 | #include <linux/types.h> |
63 | #include <linux/fs.h> |
64 | #include <linux/kernel.h> |
65 | #include <linux/delay.h> /* MSch: for IRQ probe */ |
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 */ |
78 | #include <asm/fb.h> |
79 | #include <asm/irq.h> |
80 | |
81 | #include "fbcon.h" |
82 | |
83 | #ifdef FBCONDEBUG |
84 | # define DPRINTK(fmt, args...) printk(KERN_DEBUG "%s: " fmt, __func__ , ## args) |
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 | |
95 | static struct display fb_display[MAX_NR_CONSOLES]; |
96 | |
97 | static signed char con2fb_map[MAX_NR_CONSOLES]; |
98 | static signed char con2fb_map_boot[MAX_NR_CONSOLES]; |
99 | |
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; |
114 | static int fbcon_has_exited; |
115 | static int primary_device = -1; |
116 | static int fbcon_has_console_bind; |
117 | static unsigned int bind_on_startup = 1; |
118 | |
119 | #ifdef CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY |
120 | static int map_override; |
121 | |
122 | static inline void fbcon_map_override(void) |
123 | { |
124 | map_override = 1; |
125 | } |
126 | #else |
127 | static inline void fbcon_map_override(void) |
128 | { |
129 | } |
130 | #endif /* CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY */ |
131 | |
132 | /* font data */ |
133 | static char fontname[40]; |
134 | |
135 | /* current fb_info */ |
136 | static int info_idx = -1; |
137 | |
138 | /* console rotation */ |
139 | static int initial_rotation; |
140 | static int fbcon_has_sysfs; |
141 | |
142 | static const struct consw fb_con; |
143 | |
144 | #define CM_SOFTBACK (8) |
145 | |
146 | #define advance_row(p, delta) (unsigned short *)((unsigned long)(p) + (delta) * vc->vc_size_row) |
147 | |
148 | static int fbcon_set_origin(struct vc_data *); |
149 | |
150 | #define CURSOR_DRAW_DELAY (1) |
151 | |
152 | static int vbl_cursor_cnt; |
153 | static int fbcon_cursor_noblink; |
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 | */ |
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 | int unit); |
191 | static void fbcon_redraw_move(struct vc_data *vc, struct display *p, |
192 | int line, int count, int dy); |
193 | static void fbcon_modechanged(struct fb_info *info); |
194 | static void fbcon_set_all_vcs(struct fb_info *info); |
195 | static void fbcon_start(void); |
196 | static void fbcon_exit(void); |
197 | static struct device *fbcon_device; |
198 | |
199 | #ifdef CONFIG_FRAMEBUFFER_CONSOLE_ROTATION |
200 | static inline void fbcon_set_rotation(struct fb_info *info) |
201 | { |
202 | struct fbcon_ops *ops = info->fbcon_par; |
203 | |
204 | if (!(info->flags & FBINFO_MISC_TILEBLITTING) && |
205 | ops->p->con_rotate < 4) |
206 | ops->rotate = ops->p->con_rotate; |
207 | else |
208 | ops->rotate = 0; |
209 | } |
210 | |
211 | static void fbcon_rotate(struct fb_info *info, u32 rotate) |
212 | { |
213 | struct fbcon_ops *ops= info->fbcon_par; |
214 | struct fb_info *fb_info; |
215 | |
216 | if (!ops || ops->currcon == -1) |
217 | return; |
218 | |
219 | fb_info = registered_fb[con2fb_map[ops->currcon]]; |
220 | |
221 | if (info == fb_info) { |
222 | struct display *p = &fb_display[ops->currcon]; |
223 | |
224 | if (rotate < 4) |
225 | p->con_rotate = rotate; |
226 | else |
227 | p->con_rotate = 0; |
228 | |
229 | fbcon_modechanged(info); |
230 | } |
231 | } |
232 | |
233 | static void fbcon_rotate_all(struct fb_info *info, u32 rotate) |
234 | { |
235 | struct fbcon_ops *ops = info->fbcon_par; |
236 | struct vc_data *vc; |
237 | struct display *p; |
238 | int i; |
239 | |
240 | if (!ops || ops->currcon < 0 || rotate > 3) |
241 | return; |
242 | |
243 | for (i = first_fb_vc; i <= last_fb_vc; i++) { |
244 | vc = vc_cons[i].d; |
245 | if (!vc || vc->vc_mode != KD_TEXT || |
246 | registered_fb[con2fb_map[i]] != info) |
247 | continue; |
248 | |
249 | p = &fb_display[vc->vc_num]; |
250 | p->con_rotate = rotate; |
251 | } |
252 | |
253 | fbcon_set_all_vcs(info); |
254 | } |
255 | #else |
256 | static inline void fbcon_set_rotation(struct fb_info *info) |
257 | { |
258 | struct fbcon_ops *ops = info->fbcon_par; |
259 | |
260 | ops->rotate = FB_ROTATE_UR; |
261 | } |
262 | |
263 | static void fbcon_rotate(struct fb_info *info, u32 rotate) |
264 | { |
265 | return; |
266 | } |
267 | |
268 | static void fbcon_rotate_all(struct fb_info *info, u32 rotate) |
269 | { |
270 | return; |
271 | } |
272 | #endif /* CONFIG_FRAMEBUFFER_CONSOLE_ROTATION */ |
273 | |
274 | static int fbcon_get_rotate(struct fb_info *info) |
275 | { |
276 | struct fbcon_ops *ops = info->fbcon_par; |
277 | |
278 | return (ops) ? ops->rotate : 0; |
279 | } |
280 | |
281 | static inline int fbcon_is_inactive(struct vc_data *vc, struct fb_info *info) |
282 | { |
283 | struct fbcon_ops *ops = info->fbcon_par; |
284 | |
285 | return (info->state != FBINFO_STATE_RUNNING || |
286 | vc->vc_mode != KD_TEXT || ops->graphics) && |
287 | !vt_force_oops_output(vc); |
288 | } |
289 | |
290 | static int get_color(struct vc_data *vc, struct fb_info *info, |
291 | u16 c, int is_fg) |
292 | { |
293 | int depth = fb_get_color_depth(&info->var, &info->fix); |
294 | int color = 0; |
295 | |
296 | if (console_blanked) { |
297 | unsigned short charmask = vc->vc_hi_font_mask ? 0x1ff : 0xff; |
298 | |
299 | c = vc->vc_video_erase_char & charmask; |
300 | } |
301 | |
302 | if (depth != 1) |
303 | color = (is_fg) ? attr_fgcol((vc->vc_hi_font_mask) ? 9 : 8, c) |
304 | : attr_bgcol((vc->vc_hi_font_mask) ? 13 : 12, c); |
305 | |
306 | switch (depth) { |
307 | case 1: |
308 | { |
309 | int col = mono_col(info); |
310 | /* 0 or 1 */ |
311 | int fg = (info->fix.visual != FB_VISUAL_MONO01) ? col : 0; |
312 | int bg = (info->fix.visual != FB_VISUAL_MONO01) ? 0 : col; |
313 | |
314 | if (console_blanked) |
315 | fg = bg; |
316 | |
317 | color = (is_fg) ? fg : bg; |
318 | break; |
319 | } |
320 | case 2: |
321 | /* |
322 | * Scale down 16-colors to 4 colors. Default 4-color palette |
323 | * is grayscale. However, simply dividing the values by 4 |
324 | * will not work, as colors 1, 2 and 3 will be scaled-down |
325 | * to zero rendering them invisible. So empirically convert |
326 | * colors to a sane 4-level grayscale. |
327 | */ |
328 | switch (color) { |
329 | case 0: |
330 | color = 0; /* black */ |
331 | break; |
332 | case 1 ... 6: |
333 | color = 2; /* white */ |
334 | break; |
335 | case 7 ... 8: |
336 | color = 1; /* gray */ |
337 | break; |
338 | default: |
339 | color = 3; /* intense white */ |
340 | break; |
341 | } |
342 | break; |
343 | case 3: |
344 | /* |
345 | * Last 8 entries of default 16-color palette is a more intense |
346 | * version of the first 8 (i.e., same chrominance, different |
347 | * luminance). |
348 | */ |
349 | color &= 7; |
350 | break; |
351 | } |
352 | |
353 | |
354 | return color; |
355 | } |
356 | |
357 | static void fbcon_update_softback(struct vc_data *vc) |
358 | { |
359 | int l = fbcon_softback_size / vc->vc_size_row; |
360 | |
361 | if (l > 5) |
362 | softback_end = softback_buf + l * vc->vc_size_row; |
363 | else |
364 | /* Smaller scrollback makes no sense, and 0 would screw |
365 | the operation totally */ |
366 | softback_top = 0; |
367 | } |
368 | |
369 | static void fb_flashcursor(struct work_struct *work) |
370 | { |
371 | struct fb_info *info = container_of(work, struct fb_info, queue); |
372 | struct fbcon_ops *ops = info->fbcon_par; |
373 | struct vc_data *vc = NULL; |
374 | int c; |
375 | int mode; |
376 | int ret; |
377 | |
378 | /* FIXME: we should sort out the unbind locking instead */ |
379 | /* instead we just fail to flash the cursor if we can't get |
380 | * the lock instead of blocking fbcon deinit */ |
381 | ret = console_trylock(); |
382 | if (ret == 0) |
383 | return; |
384 | |
385 | if (ops && ops->currcon != -1) |
386 | vc = vc_cons[ops->currcon].d; |
387 | |
388 | if (!vc || !CON_IS_VISIBLE(vc) || |
389 | registered_fb[con2fb_map[vc->vc_num]] != info || |
390 | vc->vc_deccm != 1) { |
391 | console_unlock(); |
392 | return; |
393 | } |
394 | |
395 | c = scr_readw((u16 *) vc->vc_pos); |
396 | mode = (!ops->cursor_flash || ops->cursor_state.enable) ? |
397 | CM_ERASE : CM_DRAW; |
398 | ops->cursor(vc, info, mode, softback_lines, get_color(vc, info, c, 1), |
399 | get_color(vc, info, c, 0)); |
400 | console_unlock(); |
401 | } |
402 | |
403 | static void cursor_timer_handler(unsigned long dev_addr) |
404 | { |
405 | struct fb_info *info = (struct fb_info *) dev_addr; |
406 | struct fbcon_ops *ops = info->fbcon_par; |
407 | |
408 | schedule_work(&info->queue); |
409 | mod_timer(&ops->cursor_timer, jiffies + HZ/5); |
410 | } |
411 | |
412 | static void fbcon_add_cursor_timer(struct fb_info *info) |
413 | { |
414 | struct fbcon_ops *ops = info->fbcon_par; |
415 | |
416 | if ((!info->queue.func || info->queue.func == fb_flashcursor) && |
417 | !(ops->flags & FBCON_FLAGS_CURSOR_TIMER) && |
418 | !fbcon_cursor_noblink) { |
419 | if (!info->queue.func) |
420 | INIT_WORK(&info->queue, fb_flashcursor); |
421 | |
422 | init_timer(&ops->cursor_timer); |
423 | ops->cursor_timer.function = cursor_timer_handler; |
424 | ops->cursor_timer.expires = jiffies + HZ / 5; |
425 | ops->cursor_timer.data = (unsigned long ) info; |
426 | add_timer(&ops->cursor_timer); |
427 | ops->flags |= FBCON_FLAGS_CURSOR_TIMER; |
428 | } |
429 | } |
430 | |
431 | static void fbcon_del_cursor_timer(struct fb_info *info) |
432 | { |
433 | struct fbcon_ops *ops = info->fbcon_par; |
434 | |
435 | if (info->queue.func == fb_flashcursor && |
436 | ops->flags & FBCON_FLAGS_CURSOR_TIMER) { |
437 | del_timer_sync(&ops->cursor_timer); |
438 | ops->flags &= ~FBCON_FLAGS_CURSOR_TIMER; |
439 | } |
440 | } |
441 | |
442 | #ifndef MODULE |
443 | static int __init fb_console_setup(char *this_opt) |
444 | { |
445 | char *options; |
446 | int i, j, ret; |
447 | |
448 | if (!this_opt || !*this_opt) |
449 | return 1; |
450 | |
451 | while ((options = strsep(&this_opt, ",")) != NULL) { |
452 | if (!strncmp(options, "font:", 5)) { |
453 | strlcpy(fontname, options + 5, sizeof(fontname)); |
454 | continue; |
455 | } |
456 | |
457 | if (!strncmp(options, "scrollback:", 11)) { |
458 | char *k; |
459 | options += 11; |
460 | k = options; |
461 | |
462 | while (*k != '\0' && *k != 'k' && *k != 'K') |
463 | k++; |
464 | |
465 | /* Clear the 'k' or 'K' suffix to |
466 | * prevent errors with kstrtouint */ |
467 | if (*k != '\0') |
468 | *k++ = '\0'; |
469 | else |
470 | k = NULL; |
471 | |
472 | ret = kstrtouint(options, 0, (unsigned int *) |
473 | &fbcon_softback_size); |
474 | |
475 | if (!ret && k) |
476 | fbcon_softback_size *= 1024; |
477 | |
478 | /* (k && *k): Check for garbage after the suffix */ |
479 | if (ret || (k && *k)) |
480 | printk(KERN_WARNING "fbcon: scrollback: incorrect value.\n"); |
481 | continue; |
482 | } |
483 | |
484 | if (!strncmp(options, "map:", 4)) { |
485 | options += 4; |
486 | if (*options) { |
487 | for (i = 0, j = 0; i < MAX_NR_CONSOLES; i++) { |
488 | if (!options[j]) |
489 | j = 0; |
490 | con2fb_map_boot[i] = |
491 | (options[j++]-'0') % FB_MAX; |
492 | } |
493 | |
494 | fbcon_map_override(); |
495 | } else { |
496 | printk(KERN_WARNING "fbcon: map: incorrect value.\n"); |
497 | } |
498 | continue; |
499 | } |
500 | |
501 | if (!strncmp(options, "vc:", 3)) { |
502 | char *dash; |
503 | options += 3; |
504 | |
505 | dash = strchr(options, '-'); |
506 | if (dash) |
507 | *dash++ = '\0'; |
508 | |
509 | ret = kstrtouint(options, 10, |
510 | (unsigned int *) &first_fb_vc); |
511 | if (!ret) { |
512 | if (--first_fb_vc < 0) |
513 | first_fb_vc = 0; |
514 | |
515 | if (dash) { |
516 | ret = kstrtouint(dash, 10, |
517 | (unsigned int *) |
518 | &last_fb_vc); |
519 | if (!ret) |
520 | last_fb_vc--; |
521 | } |
522 | } |
523 | |
524 | if (!ret) |
525 | fbcon_is_default = 0; |
526 | else |
527 | printk(KERN_WARNING "fbcon: vc: incorrect value.\n"); |
528 | continue; |
529 | } |
530 | |
531 | if (!strncmp(options, "rotate:", 7)) { |
532 | options += 7; |
533 | ret = kstrtouint(options, 0, (unsigned int *) |
534 | &initial_rotation); |
535 | if (!ret) { |
536 | if (initial_rotation > 3) |
537 | initial_rotation = 0; |
538 | } else { |
539 | printk(KERN_WARNING "fbcon: rotate: incorrect value.\n"); |
540 | } |
541 | continue; |
542 | } |
543 | |
544 | if (!strncmp(options, "bind:", 5)) { |
545 | options += 5; |
546 | ret = kstrtouint(options, 0, &bind_on_startup); |
547 | if (ret) |
548 | printk(KERN_WARNING "fbcon: bind: incorrect value.\n"); |
549 | continue; |
550 | } |
551 | } |
552 | return 1; |
553 | } |
554 | |
555 | __setup("fbcon=", fb_console_setup); |
556 | #endif |
557 | |
558 | static int search_fb_in_map(int idx) |
559 | { |
560 | int i, retval = 0; |
561 | |
562 | for (i = first_fb_vc; i <= last_fb_vc; i++) { |
563 | if (con2fb_map[i] == idx) |
564 | retval = 1; |
565 | } |
566 | return retval; |
567 | } |
568 | |
569 | static int search_for_mapped_con(void) |
570 | { |
571 | int i, retval = 0; |
572 | |
573 | for (i = first_fb_vc; i <= last_fb_vc; i++) { |
574 | if (con2fb_map[i] != -1) |
575 | retval = 1; |
576 | } |
577 | return retval; |
578 | } |
579 | |
580 | static int fbcon_takeover(int show_logo) |
581 | { |
582 | int err, i; |
583 | |
584 | if (!num_registered_fb) |
585 | return -ENODEV; |
586 | |
587 | if (!show_logo) |
588 | logo_shown = FBCON_LOGO_DONTSHOW; |
589 | |
590 | for (i = first_fb_vc; i <= last_fb_vc; i++) |
591 | con2fb_map[i] = info_idx; |
592 | |
593 | if (bind_on_startup) |
594 | err = take_over_console(&fb_con, first_fb_vc, last_fb_vc, |
595 | fbcon_is_default); |
596 | else |
597 | err = register_con_driver(&fb_con, first_fb_vc, last_fb_vc); |
598 | |
599 | if (err) { |
600 | for (i = first_fb_vc; i <= last_fb_vc; i++) { |
601 | con2fb_map[i] = -1; |
602 | } |
603 | info_idx = -1; |
604 | } else { |
605 | fbcon_has_console_bind = bind_on_startup; |
606 | } |
607 | |
608 | return err; |
609 | } |
610 | |
611 | #ifdef MODULE |
612 | static void fbcon_prepare_logo(struct vc_data *vc, struct fb_info *info, |
613 | int cols, int rows, int new_cols, int new_rows) |
614 | { |
615 | logo_shown = FBCON_LOGO_DONTSHOW; |
616 | } |
617 | #else |
618 | static void fbcon_prepare_logo(struct vc_data *vc, struct fb_info *info, |
619 | int cols, int rows, int new_cols, int new_rows) |
620 | { |
621 | /* Need to make room for the logo */ |
622 | struct fbcon_ops *ops = info->fbcon_par; |
623 | int cnt, erase = vc->vc_video_erase_char, step; |
624 | unsigned short *save = NULL, *r, *q; |
625 | int logo_height; |
626 | |
627 | if (info->flags & FBINFO_MODULE) { |
628 | logo_shown = FBCON_LOGO_DONTSHOW; |
629 | return; |
630 | } |
631 | |
632 | /* |
633 | * remove underline attribute from erase character |
634 | * if black and white framebuffer. |
635 | */ |
636 | if (fb_get_color_depth(&info->var, &info->fix) == 1) |
637 | erase &= ~0x400; |
638 | logo_height = fb_prepare_logo(info, ops->rotate); |
639 | logo_lines = DIV_ROUND_UP(logo_height, vc->vc_font.height); |
640 | q = (unsigned short *) (vc->vc_origin + |
641 | vc->vc_size_row * rows); |
642 | step = logo_lines * cols; |
643 | for (r = q - logo_lines * cols; r < q; r++) |
644 | if (scr_readw(r) != vc->vc_video_erase_char) |
645 | break; |
646 | if (r != q && new_rows >= rows + logo_lines) { |
647 | save = kmalloc(logo_lines * new_cols * 2, GFP_KERNEL); |
648 | if (save) { |
649 | int i = cols < new_cols ? cols : new_cols; |
650 | scr_memsetw(save, erase, logo_lines * new_cols * 2); |
651 | r = q - step; |
652 | for (cnt = 0; cnt < logo_lines; cnt++, r += i) |
653 | scr_memcpyw(save + cnt * new_cols, r, 2 * i); |
654 | r = q; |
655 | } |
656 | } |
657 | if (r == q) { |
658 | /* We can scroll screen down */ |
659 | r = q - step - cols; |
660 | for (cnt = rows - logo_lines; cnt > 0; cnt--) { |
661 | scr_memcpyw(r + step, r, vc->vc_size_row); |
662 | r -= cols; |
663 | } |
664 | if (!save) { |
665 | int lines; |
666 | if (vc->vc_y + logo_lines >= rows) |
667 | lines = rows - vc->vc_y - 1; |
668 | else |
669 | lines = logo_lines; |
670 | vc->vc_y += lines; |
671 | vc->vc_pos += lines * vc->vc_size_row; |
672 | } |
673 | } |
674 | scr_memsetw((unsigned short *) vc->vc_origin, |
675 | erase, |
676 | vc->vc_size_row * logo_lines); |
677 | |
678 | if (CON_IS_VISIBLE(vc) && vc->vc_mode == KD_TEXT) { |
679 | fbcon_clear_margins(vc, 0); |
680 | update_screen(vc); |
681 | } |
682 | |
683 | if (save) { |
684 | q = (unsigned short *) (vc->vc_origin + |
685 | vc->vc_size_row * |
686 | rows); |
687 | scr_memcpyw(q, save, logo_lines * new_cols * 2); |
688 | vc->vc_y += logo_lines; |
689 | vc->vc_pos += logo_lines * vc->vc_size_row; |
690 | kfree(save); |
691 | } |
692 | |
693 | if (logo_lines > vc->vc_bottom) { |
694 | logo_shown = FBCON_LOGO_CANSHOW; |
695 | printk(KERN_INFO |
696 | "fbcon_init: disable boot-logo (boot-logo bigger than screen).\n"); |
697 | } else if (logo_shown != FBCON_LOGO_DONTSHOW) { |
698 | logo_shown = FBCON_LOGO_DRAW; |
699 | vc->vc_top = logo_lines; |
700 | } |
701 | } |
702 | #endif /* MODULE */ |
703 | |
704 | #ifdef CONFIG_FB_TILEBLITTING |
705 | static void set_blitting_type(struct vc_data *vc, struct fb_info *info) |
706 | { |
707 | struct fbcon_ops *ops = info->fbcon_par; |
708 | |
709 | ops->p = &fb_display[vc->vc_num]; |
710 | |
711 | if ((info->flags & FBINFO_MISC_TILEBLITTING)) |
712 | fbcon_set_tileops(vc, info); |
713 | else { |
714 | fbcon_set_rotation(info); |
715 | fbcon_set_bitops(ops); |
716 | } |
717 | } |
718 | |
719 | static int fbcon_invalid_charcount(struct fb_info *info, unsigned charcount) |
720 | { |
721 | int err = 0; |
722 | |
723 | if (info->flags & FBINFO_MISC_TILEBLITTING && |
724 | info->tileops->fb_get_tilemax(info) < charcount) |
725 | err = 1; |
726 | |
727 | return err; |
728 | } |
729 | #else |
730 | static void set_blitting_type(struct vc_data *vc, struct fb_info *info) |
731 | { |
732 | struct fbcon_ops *ops = info->fbcon_par; |
733 | |
734 | info->flags &= ~FBINFO_MISC_TILEBLITTING; |
735 | ops->p = &fb_display[vc->vc_num]; |
736 | fbcon_set_rotation(info); |
737 | fbcon_set_bitops(ops); |
738 | } |
739 | |
740 | static int fbcon_invalid_charcount(struct fb_info *info, unsigned charcount) |
741 | { |
742 | return 0; |
743 | } |
744 | |
745 | #endif /* CONFIG_MISC_TILEBLITTING */ |
746 | |
747 | |
748 | static int con2fb_acquire_newinfo(struct vc_data *vc, struct fb_info *info, |
749 | int unit, int oldidx) |
750 | { |
751 | struct fbcon_ops *ops = NULL; |
752 | int err = 0; |
753 | |
754 | if (!try_module_get(info->fbops->owner)) |
755 | err = -ENODEV; |
756 | |
757 | if (!err && info->fbops->fb_open && |
758 | info->fbops->fb_open(info, 0)) |
759 | err = -ENODEV; |
760 | |
761 | if (!err) { |
762 | ops = kzalloc(sizeof(struct fbcon_ops), GFP_KERNEL); |
763 | if (!ops) |
764 | err = -ENOMEM; |
765 | } |
766 | |
767 | if (!err) { |
768 | info->fbcon_par = ops; |
769 | |
770 | if (vc) |
771 | set_blitting_type(vc, info); |
772 | } |
773 | |
774 | if (err) { |
775 | con2fb_map[unit] = oldidx; |
776 | module_put(info->fbops->owner); |
777 | } |
778 | |
779 | return err; |
780 | } |
781 | |
782 | static int con2fb_release_oldinfo(struct vc_data *vc, struct fb_info *oldinfo, |
783 | struct fb_info *newinfo, int unit, |
784 | int oldidx, int found) |
785 | { |
786 | struct fbcon_ops *ops = oldinfo->fbcon_par; |
787 | int err = 0, ret; |
788 | |
789 | if (oldinfo->fbops->fb_release && |
790 | oldinfo->fbops->fb_release(oldinfo, 0)) { |
791 | con2fb_map[unit] = oldidx; |
792 | if (!found && newinfo->fbops->fb_release) |
793 | newinfo->fbops->fb_release(newinfo, 0); |
794 | if (!found) |
795 | module_put(newinfo->fbops->owner); |
796 | err = -ENODEV; |
797 | } |
798 | |
799 | if (!err) { |
800 | fbcon_del_cursor_timer(oldinfo); |
801 | kfree(ops->cursor_state.mask); |
802 | kfree(ops->cursor_data); |
803 | kfree(ops->fontbuffer); |
804 | kfree(oldinfo->fbcon_par); |
805 | oldinfo->fbcon_par = NULL; |
806 | module_put(oldinfo->fbops->owner); |
807 | /* |
808 | If oldinfo and newinfo are driving the same hardware, |
809 | the fb_release() method of oldinfo may attempt to |
810 | restore the hardware state. This will leave the |
811 | newinfo in an undefined state. Thus, a call to |
812 | fb_set_par() may be needed for the newinfo. |
813 | */ |
814 | if (newinfo->fbops->fb_set_par) { |
815 | ret = newinfo->fbops->fb_set_par(newinfo); |
816 | |
817 | if (ret) |
818 | printk(KERN_ERR "con2fb_release_oldinfo: " |
819 | "detected unhandled fb_set_par error, " |
820 | "error code %d\n", ret); |
821 | } |
822 | } |
823 | |
824 | return err; |
825 | } |
826 | |
827 | static void con2fb_init_display(struct vc_data *vc, struct fb_info *info, |
828 | int unit, int show_logo) |
829 | { |
830 | struct fbcon_ops *ops = info->fbcon_par; |
831 | int ret; |
832 | |
833 | ops->currcon = fg_console; |
834 | |
835 | if (info->fbops->fb_set_par && !(ops->flags & FBCON_FLAGS_INIT)) { |
836 | ret = info->fbops->fb_set_par(info); |
837 | |
838 | if (ret) |
839 | printk(KERN_ERR "con2fb_init_display: detected " |
840 | "unhandled fb_set_par error, " |
841 | "error code %d\n", ret); |
842 | } |
843 | |
844 | ops->flags |= FBCON_FLAGS_INIT; |
845 | ops->graphics = 0; |
846 | fbcon_set_disp(info, &info->var, unit); |
847 | |
848 | if (show_logo) { |
849 | struct vc_data *fg_vc = vc_cons[fg_console].d; |
850 | struct fb_info *fg_info = |
851 | registered_fb[con2fb_map[fg_console]]; |
852 | |
853 | fbcon_prepare_logo(fg_vc, fg_info, fg_vc->vc_cols, |
854 | fg_vc->vc_rows, fg_vc->vc_cols, |
855 | fg_vc->vc_rows); |
856 | } |
857 | |
858 | update_screen(vc_cons[fg_console].d); |
859 | } |
860 | |
861 | /** |
862 | * set_con2fb_map - map console to frame buffer device |
863 | * @unit: virtual console number to map |
864 | * @newidx: frame buffer index to map virtual console to |
865 | * @user: user request |
866 | * |
867 | * Maps a virtual console @unit to a frame buffer device |
868 | * @newidx. |
869 | */ |
870 | static int set_con2fb_map(int unit, int newidx, int user) |
871 | { |
872 | struct vc_data *vc = vc_cons[unit].d; |
873 | int oldidx = con2fb_map[unit]; |
874 | struct fb_info *info = registered_fb[newidx]; |
875 | struct fb_info *oldinfo = NULL; |
876 | int found, err = 0; |
877 | |
878 | if (oldidx == newidx) |
879 | return 0; |
880 | |
881 | if (!info) |
882 | return -EINVAL; |
883 | |
884 | if (!search_for_mapped_con() || !con_is_bound(&fb_con)) { |
885 | info_idx = newidx; |
886 | return fbcon_takeover(0); |
887 | } |
888 | |
889 | if (oldidx != -1) |
890 | oldinfo = registered_fb[oldidx]; |
891 | |
892 | found = search_fb_in_map(newidx); |
893 | |
894 | console_lock(); |
895 | con2fb_map[unit] = newidx; |
896 | if (!err && !found) |
897 | err = con2fb_acquire_newinfo(vc, info, unit, oldidx); |
898 | |
899 | |
900 | /* |
901 | * If old fb is not mapped to any of the consoles, |
902 | * fbcon should release it. |
903 | */ |
904 | if (!err && oldinfo && !search_fb_in_map(oldidx)) |
905 | err = con2fb_release_oldinfo(vc, oldinfo, info, unit, oldidx, |
906 | found); |
907 | |
908 | if (!err) { |
909 | int show_logo = (fg_console == 0 && !user && |
910 | logo_shown != FBCON_LOGO_DONTSHOW); |
911 | |
912 | if (!found) |
913 | fbcon_add_cursor_timer(info); |
914 | con2fb_map_boot[unit] = newidx; |
915 | con2fb_init_display(vc, info, unit, show_logo); |
916 | } |
917 | |
918 | if (!search_fb_in_map(info_idx)) |
919 | info_idx = newidx; |
920 | |
921 | console_unlock(); |
922 | return err; |
923 | } |
924 | |
925 | /* |
926 | * Low Level Operations |
927 | */ |
928 | /* NOTE: fbcon cannot be __init: it may be called from take_over_console later */ |
929 | static int var_to_display(struct display *disp, |
930 | struct fb_var_screeninfo *var, |
931 | struct fb_info *info) |
932 | { |
933 | disp->xres_virtual = var->xres_virtual; |
934 | disp->yres_virtual = var->yres_virtual; |
935 | disp->bits_per_pixel = var->bits_per_pixel; |
936 | disp->grayscale = var->grayscale; |
937 | disp->nonstd = var->nonstd; |
938 | disp->accel_flags = var->accel_flags; |
939 | disp->height = var->height; |
940 | disp->width = var->width; |
941 | disp->red = var->red; |
942 | disp->green = var->green; |
943 | disp->blue = var->blue; |
944 | disp->transp = var->transp; |
945 | disp->rotate = var->rotate; |
946 | disp->mode = fb_match_mode(var, &info->modelist); |
947 | if (disp->mode == NULL) |
948 | /* This should not happen */ |
949 | return -EINVAL; |
950 | return 0; |
951 | } |
952 | |
953 | static void display_to_var(struct fb_var_screeninfo *var, |
954 | struct display *disp) |
955 | { |
956 | fb_videomode_to_var(var, disp->mode); |
957 | var->xres_virtual = disp->xres_virtual; |
958 | var->yres_virtual = disp->yres_virtual; |
959 | var->bits_per_pixel = disp->bits_per_pixel; |
960 | var->grayscale = disp->grayscale; |
961 | var->nonstd = disp->nonstd; |
962 | var->accel_flags = disp->accel_flags; |
963 | var->height = disp->height; |
964 | var->width = disp->width; |
965 | var->red = disp->red; |
966 | var->green = disp->green; |
967 | var->blue = disp->blue; |
968 | var->transp = disp->transp; |
969 | var->rotate = disp->rotate; |
970 | } |
971 | |
972 | static const char *fbcon_startup(void) |
973 | { |
974 | const char *display_desc = "frame buffer device"; |
975 | struct display *p = &fb_display[fg_console]; |
976 | struct vc_data *vc = vc_cons[fg_console].d; |
977 | const struct font_desc *font = NULL; |
978 | struct module *owner; |
979 | struct fb_info *info = NULL; |
980 | struct fbcon_ops *ops; |
981 | int rows, cols; |
982 | |
983 | /* |
984 | * If num_registered_fb is zero, this is a call for the dummy part. |
985 | * The frame buffer devices weren't initialized yet. |
986 | */ |
987 | if (!num_registered_fb || info_idx == -1) |
988 | return display_desc; |
989 | /* |
990 | * Instead of blindly using registered_fb[0], we use info_idx, set by |
991 | * fb_console_init(); |
992 | */ |
993 | info = registered_fb[info_idx]; |
994 | if (!info) |
995 | return NULL; |
996 | |
997 | owner = info->fbops->owner; |
998 | if (!try_module_get(owner)) |
999 | return NULL; |
1000 | if (info->fbops->fb_open && info->fbops->fb_open(info, 0)) { |
1001 | module_put(owner); |
1002 | return NULL; |
1003 | } |
1004 | |
1005 | ops = kzalloc(sizeof(struct fbcon_ops), GFP_KERNEL); |
1006 | if (!ops) { |
1007 | module_put(owner); |
1008 | return NULL; |
1009 | } |
1010 | |
1011 | ops->currcon = -1; |
1012 | ops->graphics = 1; |
1013 | ops->cur_rotate = -1; |
1014 | info->fbcon_par = ops; |
1015 | p->con_rotate = initial_rotation; |
1016 | set_blitting_type(vc, info); |
1017 | |
1018 | if (info->fix.type != FB_TYPE_TEXT) { |
1019 | if (fbcon_softback_size) { |
1020 | if (!softback_buf) { |
1021 | softback_buf = |
1022 | (unsigned long) |
1023 | kmalloc(fbcon_softback_size, |
1024 | GFP_KERNEL); |
1025 | if (!softback_buf) { |
1026 | fbcon_softback_size = 0; |
1027 | softback_top = 0; |
1028 | } |
1029 | } |
1030 | } else { |
1031 | if (softback_buf) { |
1032 | kfree((void *) softback_buf); |
1033 | softback_buf = 0; |
1034 | softback_top = 0; |
1035 | } |
1036 | } |
1037 | if (softback_buf) |
1038 | softback_in = softback_top = softback_curr = |
1039 | softback_buf; |
1040 | softback_lines = 0; |
1041 | } |
1042 | |
1043 | /* Setup default font */ |
1044 | if (!p->fontdata) { |
1045 | if (!fontname[0] || !(font = find_font(fontname))) |
1046 | font = get_default_font(info->var.xres, |
1047 | info->var.yres, |
1048 | info->pixmap.blit_x, |
1049 | info->pixmap.blit_y); |
1050 | vc->vc_font.width = font->width; |
1051 | vc->vc_font.height = font->height; |
1052 | vc->vc_font.data = (void *)(p->fontdata = font->data); |
1053 | vc->vc_font.charcount = 256; /* FIXME Need to support more fonts */ |
1054 | } |
1055 | |
1056 | cols = FBCON_SWAP(ops->rotate, info->var.xres, info->var.yres); |
1057 | rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres); |
1058 | cols /= vc->vc_font.width; |
1059 | rows /= vc->vc_font.height; |
1060 | vc_resize(vc, cols, rows); |
1061 | |
1062 | DPRINTK("mode: %s\n", info->fix.id); |
1063 | DPRINTK("visual: %d\n", info->fix.visual); |
1064 | DPRINTK("res: %dx%d-%d\n", info->var.xres, |
1065 | info->var.yres, |
1066 | info->var.bits_per_pixel); |
1067 | |
1068 | fbcon_add_cursor_timer(info); |
1069 | fbcon_has_exited = 0; |
1070 | return display_desc; |
1071 | } |
1072 | |
1073 | static void fbcon_init(struct vc_data *vc, int init) |
1074 | { |
1075 | struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]]; |
1076 | struct fbcon_ops *ops; |
1077 | struct vc_data **default_mode = vc->vc_display_fg; |
1078 | struct vc_data *svc = *default_mode; |
1079 | struct display *t, *p = &fb_display[vc->vc_num]; |
1080 | int logo = 1, new_rows, new_cols, rows, cols, charcnt = 256; |
1081 | int cap, ret; |
1082 | |
1083 | if (info_idx == -1 || info == NULL) |
1084 | return; |
1085 | |
1086 | cap = info->flags; |
1087 | |
1088 | if (vc != svc || logo_shown == FBCON_LOGO_DONTSHOW || |
1089 | (info->fix.type == FB_TYPE_TEXT)) |
1090 | logo = 0; |
1091 | |
1092 | if (var_to_display(p, &info->var, info)) |
1093 | return; |
1094 | |
1095 | if (!info->fbcon_par) |
1096 | con2fb_acquire_newinfo(vc, info, vc->vc_num, -1); |
1097 | |
1098 | /* If we are not the first console on this |
1099 | fb, copy the font from that console */ |
1100 | t = &fb_display[fg_console]; |
1101 | if (!p->fontdata) { |
1102 | if (t->fontdata) { |
1103 | struct vc_data *fvc = vc_cons[fg_console].d; |
1104 | |
1105 | vc->vc_font.data = (void *)(p->fontdata = |
1106 | fvc->vc_font.data); |
1107 | vc->vc_font.width = fvc->vc_font.width; |
1108 | vc->vc_font.height = fvc->vc_font.height; |
1109 | p->userfont = t->userfont; |
1110 | |
1111 | if (p->userfont) |
1112 | REFCOUNT(p->fontdata)++; |
1113 | } else { |
1114 | const struct font_desc *font = NULL; |
1115 | |
1116 | if (!fontname[0] || !(font = find_font(fontname))) |
1117 | font = get_default_font(info->var.xres, |
1118 | info->var.yres, |
1119 | info->pixmap.blit_x, |
1120 | info->pixmap.blit_y); |
1121 | vc->vc_font.width = font->width; |
1122 | vc->vc_font.height = font->height; |
1123 | vc->vc_font.data = (void *)(p->fontdata = font->data); |
1124 | vc->vc_font.charcount = 256; /* FIXME Need to |
1125 | support more fonts */ |
1126 | } |
1127 | } |
1128 | |
1129 | if (p->userfont) |
1130 | charcnt = FNTCHARCNT(p->fontdata); |
1131 | |
1132 | vc->vc_panic_force_write = !!(info->flags & FBINFO_CAN_FORCE_OUTPUT); |
1133 | vc->vc_can_do_color = (fb_get_color_depth(&info->var, &info->fix)!=1); |
1134 | vc->vc_complement_mask = vc->vc_can_do_color ? 0x7700 : 0x0800; |
1135 | if (charcnt == 256) { |
1136 | vc->vc_hi_font_mask = 0; |
1137 | } else { |
1138 | vc->vc_hi_font_mask = 0x100; |
1139 | if (vc->vc_can_do_color) |
1140 | vc->vc_complement_mask <<= 1; |
1141 | } |
1142 | |
1143 | if (!*svc->vc_uni_pagedir_loc) |
1144 | con_set_default_unimap(svc); |
1145 | if (!*vc->vc_uni_pagedir_loc) |
1146 | con_copy_unimap(vc, svc); |
1147 | |
1148 | ops = info->fbcon_par; |
1149 | p->con_rotate = initial_rotation; |
1150 | set_blitting_type(vc, info); |
1151 | |
1152 | cols = vc->vc_cols; |
1153 | rows = vc->vc_rows; |
1154 | new_cols = FBCON_SWAP(ops->rotate, info->var.xres, info->var.yres); |
1155 | new_rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres); |
1156 | new_cols /= vc->vc_font.width; |
1157 | new_rows /= vc->vc_font.height; |
1158 | |
1159 | /* |
1160 | * We must always set the mode. The mode of the previous console |
1161 | * driver could be in the same resolution but we are using different |
1162 | * hardware so we have to initialize the hardware. |
1163 | * |
1164 | * We need to do it in fbcon_init() to prevent screen corruption. |
1165 | */ |
1166 | if (CON_IS_VISIBLE(vc) && vc->vc_mode == KD_TEXT) { |
1167 | if (info->fbops->fb_set_par && |
1168 | !(ops->flags & FBCON_FLAGS_INIT)) { |
1169 | ret = info->fbops->fb_set_par(info); |
1170 | |
1171 | if (ret) |
1172 | printk(KERN_ERR "fbcon_init: detected " |
1173 | "unhandled fb_set_par error, " |
1174 | "error code %d\n", ret); |
1175 | } |
1176 | |
1177 | ops->flags |= FBCON_FLAGS_INIT; |
1178 | } |
1179 | |
1180 | ops->graphics = 0; |
1181 | |
1182 | if ((cap & FBINFO_HWACCEL_COPYAREA) && |
1183 | !(cap & FBINFO_HWACCEL_DISABLED)) |
1184 | p->scrollmode = SCROLL_MOVE; |
1185 | else /* default to something safe */ |
1186 | p->scrollmode = SCROLL_REDRAW; |
1187 | |
1188 | /* |
1189 | * ++guenther: console.c:vc_allocate() relies on initializing |
1190 | * vc_{cols,rows}, but we must not set those if we are only |
1191 | * resizing the console. |
1192 | */ |
1193 | if (init) { |
1194 | vc->vc_cols = new_cols; |
1195 | vc->vc_rows = new_rows; |
1196 | } else |
1197 | vc_resize(vc, new_cols, new_rows); |
1198 | |
1199 | if (logo) |
1200 | fbcon_prepare_logo(vc, info, cols, rows, new_cols, new_rows); |
1201 | |
1202 | if (vc == svc && softback_buf) |
1203 | fbcon_update_softback(vc); |
1204 | |
1205 | if (ops->rotate_font && ops->rotate_font(info, vc)) { |
1206 | ops->rotate = FB_ROTATE_UR; |
1207 | set_blitting_type(vc, info); |
1208 | } |
1209 | |
1210 | ops->p = &fb_display[fg_console]; |
1211 | } |
1212 | |
1213 | static void fbcon_free_font(struct display *p) |
1214 | { |
1215 | if (p->userfont && p->fontdata && (--REFCOUNT(p->fontdata) == 0)) |
1216 | kfree(p->fontdata - FONT_EXTRA_WORDS * sizeof(int)); |
1217 | p->fontdata = NULL; |
1218 | p->userfont = 0; |
1219 | } |
1220 | |
1221 | static void fbcon_deinit(struct vc_data *vc) |
1222 | { |
1223 | struct display *p = &fb_display[vc->vc_num]; |
1224 | struct fb_info *info; |
1225 | struct fbcon_ops *ops; |
1226 | int idx; |
1227 | |
1228 | fbcon_free_font(p); |
1229 | idx = con2fb_map[vc->vc_num]; |
1230 | |
1231 | if (idx == -1) |
1232 | goto finished; |
1233 | |
1234 | info = registered_fb[idx]; |
1235 | |
1236 | if (!info) |
1237 | goto finished; |
1238 | |
1239 | ops = info->fbcon_par; |
1240 | |
1241 | if (!ops) |
1242 | goto finished; |
1243 | |
1244 | if (CON_IS_VISIBLE(vc)) |
1245 | fbcon_del_cursor_timer(info); |
1246 | |
1247 | ops->flags &= ~FBCON_FLAGS_INIT; |
1248 | finished: |
1249 | |
1250 | if (!con_is_bound(&fb_con)) |
1251 | fbcon_exit(); |
1252 | |
1253 | return; |
1254 | } |
1255 | |
1256 | /* ====================================================================== */ |
1257 | |
1258 | /* fbcon_XXX routines - interface used by the world |
1259 | * |
1260 | * This system is now divided into two levels because of complications |
1261 | * caused by hardware scrolling. Top level functions: |
1262 | * |
1263 | * fbcon_bmove(), fbcon_clear(), fbcon_putc(), fbcon_clear_margins() |
1264 | * |
1265 | * handles y values in range [0, scr_height-1] that correspond to real |
1266 | * screen positions. y_wrap shift means that first line of bitmap may be |
1267 | * anywhere on this display. These functions convert lineoffsets to |
1268 | * bitmap offsets and deal with the wrap-around case by splitting blits. |
1269 | * |
1270 | * fbcon_bmove_physical_8() -- These functions fast implementations |
1271 | * fbcon_clear_physical_8() -- of original fbcon_XXX fns. |
1272 | * fbcon_putc_physical_8() -- (font width != 8) may be added later |
1273 | * |
1274 | * WARNING: |
1275 | * |
1276 | * At the moment fbcon_putc() cannot blit across vertical wrap boundary |
1277 | * Implies should only really hardware scroll in rows. Only reason for |
1278 | * restriction is simplicity & efficiency at the moment. |
1279 | */ |
1280 | |
1281 | static void fbcon_clear(struct vc_data *vc, int sy, int sx, int height, |
1282 | int width) |
1283 | { |
1284 | struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]]; |
1285 | struct fbcon_ops *ops = info->fbcon_par; |
1286 | |
1287 | struct display *p = &fb_display[vc->vc_num]; |
1288 | u_int y_break; |
1289 | |
1290 | if (fbcon_is_inactive(vc, info)) |
1291 | return; |
1292 | |
1293 | if (!height || !width) |
1294 | return; |
1295 | |
1296 | if (sy < vc->vc_top && vc->vc_top == logo_lines) |
1297 | vc->vc_top = 0; |
1298 | |
1299 | /* Split blits that cross physical y_wrap boundary */ |
1300 | |
1301 | y_break = p->vrows - p->yscroll; |
1302 | if (sy < y_break && sy + height - 1 >= y_break) { |
1303 | u_int b = y_break - sy; |
1304 | ops->clear(vc, info, real_y(p, sy), sx, b, width); |
1305 | ops->clear(vc, info, real_y(p, sy + b), sx, height - b, |
1306 | width); |
1307 | } else |
1308 | ops->clear(vc, info, real_y(p, sy), sx, height, width); |
1309 | } |
1310 | |
1311 | static void fbcon_putcs(struct vc_data *vc, const unsigned short *s, |
1312 | int count, int ypos, int xpos) |
1313 | { |
1314 | struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]]; |
1315 | struct display *p = &fb_display[vc->vc_num]; |
1316 | struct fbcon_ops *ops = info->fbcon_par; |
1317 | |
1318 | if (!fbcon_is_inactive(vc, info)) |
1319 | ops->putcs(vc, info, s, count, real_y(p, ypos), xpos, |
1320 | get_color(vc, info, scr_readw(s), 1), |
1321 | get_color(vc, info, scr_readw(s), 0)); |
1322 | } |
1323 | |
1324 | static void fbcon_putc(struct vc_data *vc, int c, int ypos, int xpos) |
1325 | { |
1326 | unsigned short chr; |
1327 | |
1328 | scr_writew(c, &chr); |
1329 | fbcon_putcs(vc, &chr, 1, ypos, xpos); |
1330 | } |
1331 | |
1332 | static void fbcon_clear_margins(struct vc_data *vc, int bottom_only) |
1333 | { |
1334 | struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]]; |
1335 | struct fbcon_ops *ops = info->fbcon_par; |
1336 | |
1337 | if (!fbcon_is_inactive(vc, info)) |
1338 | ops->clear_margins(vc, info, bottom_only); |
1339 | } |
1340 | |
1341 | static void fbcon_cursor(struct vc_data *vc, int mode) |
1342 | { |
1343 | struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]]; |
1344 | struct fbcon_ops *ops = info->fbcon_par; |
1345 | int y; |
1346 | int c = scr_readw((u16 *) vc->vc_pos); |
1347 | |
1348 | if (fbcon_is_inactive(vc, info) || vc->vc_deccm != 1) |
1349 | return; |
1350 | |
1351 | if (vc->vc_cursor_type & 0x10) |
1352 | fbcon_del_cursor_timer(info); |
1353 | else |
1354 | fbcon_add_cursor_timer(info); |
1355 | |
1356 | ops->cursor_flash = (mode == CM_ERASE) ? 0 : 1; |
1357 | if (mode & CM_SOFTBACK) { |
1358 | mode &= ~CM_SOFTBACK; |
1359 | y = softback_lines; |
1360 | } else { |
1361 | if (softback_lines) |
1362 | fbcon_set_origin(vc); |
1363 | y = 0; |
1364 | } |
1365 | |
1366 | ops->cursor(vc, info, mode, y, get_color(vc, info, c, 1), |
1367 | get_color(vc, info, c, 0)); |
1368 | vbl_cursor_cnt = CURSOR_DRAW_DELAY; |
1369 | } |
1370 | |
1371 | static int scrollback_phys_max = 0; |
1372 | static int scrollback_max = 0; |
1373 | static int scrollback_current = 0; |
1374 | |
1375 | static void fbcon_set_disp(struct fb_info *info, struct fb_var_screeninfo *var, |
1376 | int unit) |
1377 | { |
1378 | struct display *p, *t; |
1379 | struct vc_data **default_mode, *vc; |
1380 | struct vc_data *svc; |
1381 | struct fbcon_ops *ops = info->fbcon_par; |
1382 | int rows, cols, charcnt = 256; |
1383 | |
1384 | p = &fb_display[unit]; |
1385 | |
1386 | if (var_to_display(p, var, info)) |
1387 | return; |
1388 | |
1389 | vc = vc_cons[unit].d; |
1390 | |
1391 | if (!vc) |
1392 | return; |
1393 | |
1394 | default_mode = vc->vc_display_fg; |
1395 | svc = *default_mode; |
1396 | t = &fb_display[svc->vc_num]; |
1397 | |
1398 | if (!vc->vc_font.data) { |
1399 | vc->vc_font.data = (void *)(p->fontdata = t->fontdata); |
1400 | vc->vc_font.width = (*default_mode)->vc_font.width; |
1401 | vc->vc_font.height = (*default_mode)->vc_font.height; |
1402 | p->userfont = t->userfont; |
1403 | if (p->userfont) |
1404 | REFCOUNT(p->fontdata)++; |
1405 | } |
1406 | if (p->userfont) |
1407 | charcnt = FNTCHARCNT(p->fontdata); |
1408 | |
1409 | var->activate = FB_ACTIVATE_NOW; |
1410 | info->var.activate = var->activate; |
1411 | var->yoffset = info->var.yoffset; |
1412 | var->xoffset = info->var.xoffset; |
1413 | fb_set_var(info, var); |
1414 | ops->var = info->var; |
1415 | vc->vc_can_do_color = (fb_get_color_depth(&info->var, &info->fix)!=1); |
1416 | vc->vc_complement_mask = vc->vc_can_do_color ? 0x7700 : 0x0800; |
1417 | if (charcnt == 256) { |
1418 | vc->vc_hi_font_mask = 0; |
1419 | } else { |
1420 | vc->vc_hi_font_mask = 0x100; |
1421 | if (vc->vc_can_do_color) |
1422 | vc->vc_complement_mask <<= 1; |
1423 | } |
1424 | |
1425 | if (!*svc->vc_uni_pagedir_loc) |
1426 | con_set_default_unimap(svc); |
1427 | if (!*vc->vc_uni_pagedir_loc) |
1428 | con_copy_unimap(vc, svc); |
1429 | |
1430 | cols = FBCON_SWAP(ops->rotate, info->var.xres, info->var.yres); |
1431 | rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres); |
1432 | cols /= vc->vc_font.width; |
1433 | rows /= vc->vc_font.height; |
1434 | vc_resize(vc, cols, rows); |
1435 | |
1436 | if (CON_IS_VISIBLE(vc)) { |
1437 | update_screen(vc); |
1438 | if (softback_buf) |
1439 | fbcon_update_softback(vc); |
1440 | } |
1441 | } |
1442 | |
1443 | static __inline__ void ywrap_up(struct vc_data *vc, int count) |
1444 | { |
1445 | struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]]; |
1446 | struct fbcon_ops *ops = info->fbcon_par; |
1447 | struct display *p = &fb_display[vc->vc_num]; |
1448 | |
1449 | p->yscroll += count; |
1450 | if (p->yscroll >= p->vrows) /* Deal with wrap */ |
1451 | p->yscroll -= p->vrows; |
1452 | ops->var.xoffset = 0; |
1453 | ops->var.yoffset = p->yscroll * vc->vc_font.height; |
1454 | ops->var.vmode |= FB_VMODE_YWRAP; |
1455 | ops->update_start(info); |
1456 | scrollback_max += count; |
1457 | if (scrollback_max > scrollback_phys_max) |
1458 | scrollback_max = scrollback_phys_max; |
1459 | scrollback_current = 0; |
1460 | } |
1461 | |
1462 | static __inline__ void ywrap_down(struct vc_data *vc, int count) |
1463 | { |
1464 | struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]]; |
1465 | struct fbcon_ops *ops = info->fbcon_par; |
1466 | struct display *p = &fb_display[vc->vc_num]; |
1467 | |
1468 | p->yscroll -= count; |
1469 | if (p->yscroll < 0) /* Deal with wrap */ |
1470 | p->yscroll += p->vrows; |
1471 | ops->var.xoffset = 0; |
1472 | ops->var.yoffset = p->yscroll * vc->vc_font.height; |
1473 | ops->var.vmode |= FB_VMODE_YWRAP; |
1474 | ops->update_start(info); |
1475 | scrollback_max -= count; |
1476 | if (scrollback_max < 0) |
1477 | scrollback_max = 0; |
1478 | scrollback_current = 0; |
1479 | } |
1480 | |
1481 | static __inline__ void ypan_up(struct vc_data *vc, int count) |
1482 | { |
1483 | struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]]; |
1484 | struct display *p = &fb_display[vc->vc_num]; |
1485 | struct fbcon_ops *ops = info->fbcon_par; |
1486 | |
1487 | p->yscroll += count; |
1488 | if (p->yscroll > p->vrows - vc->vc_rows) { |
1489 | ops->bmove(vc, info, p->vrows - vc->vc_rows, |
1490 | 0, 0, 0, vc->vc_rows, vc->vc_cols); |
1491 | p->yscroll -= p->vrows - vc->vc_rows; |
1492 | } |
1493 | |
1494 | ops->var.xoffset = 0; |
1495 | ops->var.yoffset = p->yscroll * vc->vc_font.height; |
1496 | ops->var.vmode &= ~FB_VMODE_YWRAP; |
1497 | ops->update_start(info); |
1498 | fbcon_clear_margins(vc, 1); |
1499 | scrollback_max += count; |
1500 | if (scrollback_max > scrollback_phys_max) |
1501 | scrollback_max = scrollback_phys_max; |
1502 | scrollback_current = 0; |
1503 | } |
1504 | |
1505 | static __inline__ void ypan_up_redraw(struct vc_data *vc, int t, int count) |
1506 | { |
1507 | struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]]; |
1508 | struct fbcon_ops *ops = info->fbcon_par; |
1509 | struct display *p = &fb_display[vc->vc_num]; |
1510 | |
1511 | p->yscroll += count; |
1512 | |
1513 | if (p->yscroll > p->vrows - vc->vc_rows) { |
1514 | p->yscroll -= p->vrows - vc->vc_rows; |
1515 | fbcon_redraw_move(vc, p, t + count, vc->vc_rows - count, t); |
1516 | } |
1517 | |
1518 | ops->var.xoffset = 0; |
1519 | ops->var.yoffset = p->yscroll * vc->vc_font.height; |
1520 | ops->var.vmode &= ~FB_VMODE_YWRAP; |
1521 | ops->update_start(info); |
1522 | fbcon_clear_margins(vc, 1); |
1523 | scrollback_max += count; |
1524 | if (scrollback_max > scrollback_phys_max) |
1525 | scrollback_max = scrollback_phys_max; |
1526 | scrollback_current = 0; |
1527 | } |
1528 | |
1529 | static __inline__ void ypan_down(struct vc_data *vc, int count) |
1530 | { |
1531 | struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]]; |
1532 | struct display *p = &fb_display[vc->vc_num]; |
1533 | struct fbcon_ops *ops = info->fbcon_par; |
1534 | |
1535 | p->yscroll -= count; |
1536 | if (p->yscroll < 0) { |
1537 | ops->bmove(vc, info, 0, 0, p->vrows - vc->vc_rows, |
1538 | 0, vc->vc_rows, vc->vc_cols); |
1539 | p->yscroll += p->vrows - vc->vc_rows; |
1540 | } |
1541 | |
1542 | ops->var.xoffset = 0; |
1543 | ops->var.yoffset = p->yscroll * vc->vc_font.height; |
1544 | ops->var.vmode &= ~FB_VMODE_YWRAP; |
1545 | ops->update_start(info); |
1546 | fbcon_clear_margins(vc, 1); |
1547 | scrollback_max -= count; |
1548 | if (scrollback_max < 0) |
1549 | scrollback_max = 0; |
1550 | scrollback_current = 0; |
1551 | } |
1552 | |
1553 | static __inline__ void ypan_down_redraw(struct vc_data *vc, int t, int count) |
1554 | { |
1555 | struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]]; |
1556 | struct fbcon_ops *ops = info->fbcon_par; |
1557 | struct display *p = &fb_display[vc->vc_num]; |
1558 | |
1559 | p->yscroll -= count; |
1560 | |
1561 | if (p->yscroll < 0) { |
1562 | p->yscroll += p->vrows - vc->vc_rows; |
1563 | fbcon_redraw_move(vc, p, t, vc->vc_rows - count, t + count); |
1564 | } |
1565 | |
1566 | ops->var.xoffset = 0; |
1567 | ops->var.yoffset = p->yscroll * vc->vc_font.height; |
1568 | ops->var.vmode &= ~FB_VMODE_YWRAP; |
1569 | ops->update_start(info); |
1570 | fbcon_clear_margins(vc, 1); |
1571 | scrollback_max -= count; |
1572 | if (scrollback_max < 0) |
1573 | scrollback_max = 0; |
1574 | scrollback_current = 0; |
1575 | } |
1576 | |
1577 | static void fbcon_redraw_softback(struct vc_data *vc, struct display *p, |
1578 | long delta) |
1579 | { |
1580 | int count = vc->vc_rows; |
1581 | unsigned short *d, *s; |
1582 | unsigned long n; |
1583 | int line = 0; |
1584 | |
1585 | d = (u16 *) softback_curr; |
1586 | if (d == (u16 *) softback_in) |
1587 | d = (u16 *) vc->vc_origin; |
1588 | n = softback_curr + delta * vc->vc_size_row; |
1589 | softback_lines -= delta; |
1590 | if (delta < 0) { |
1591 | if (softback_curr < softback_top && n < softback_buf) { |
1592 | n += softback_end - softback_buf; |
1593 | if (n < softback_top) { |
1594 | softback_lines -= |
1595 | (softback_top - n) / vc->vc_size_row; |
1596 | n = softback_top; |
1597 | } |
1598 | } else if (softback_curr >= softback_top |
1599 | && n < softback_top) { |
1600 | softback_lines -= |
1601 | (softback_top - n) / vc->vc_size_row; |
1602 | n = softback_top; |
1603 | } |
1604 | } else { |
1605 | if (softback_curr > softback_in && n >= softback_end) { |
1606 | n += softback_buf - softback_end; |
1607 | if (n > softback_in) { |
1608 | n = softback_in; |
1609 | softback_lines = 0; |
1610 | } |
1611 | } else if (softback_curr <= softback_in && n > softback_in) { |
1612 | n = softback_in; |
1613 | softback_lines = 0; |
1614 | } |
1615 | } |
1616 | if (n == softback_curr) |
1617 | return; |
1618 | softback_curr = n; |
1619 | s = (u16 *) softback_curr; |
1620 | if (s == (u16 *) softback_in) |
1621 | s = (u16 *) vc->vc_origin; |
1622 | while (count--) { |
1623 | unsigned short *start; |
1624 | unsigned short *le; |
1625 | unsigned short c; |
1626 | int x = 0; |
1627 | unsigned short attr = 1; |
1628 | |
1629 | start = s; |
1630 | le = advance_row(s, 1); |
1631 | do { |
1632 | c = scr_readw(s); |
1633 | if (attr != (c & 0xff00)) { |
1634 | attr = c & 0xff00; |
1635 | if (s > start) { |
1636 | fbcon_putcs(vc, start, s - start, |
1637 | line, x); |
1638 | x += s - start; |
1639 | start = s; |
1640 | } |
1641 | } |
1642 | if (c == scr_readw(d)) { |
1643 | if (s > start) { |
1644 | fbcon_putcs(vc, start, s - start, |
1645 | line, x); |
1646 | x += s - start + 1; |
1647 | start = s + 1; |
1648 | } else { |
1649 | x++; |
1650 | start++; |
1651 | } |
1652 | } |
1653 | s++; |
1654 | d++; |
1655 | } while (s < le); |
1656 | if (s > start) |
1657 | fbcon_putcs(vc, start, s - start, line, x); |
1658 | line++; |
1659 | if (d == (u16 *) softback_end) |
1660 | d = (u16 *) softback_buf; |
1661 | if (d == (u16 *) softback_in) |
1662 | d = (u16 *) vc->vc_origin; |
1663 | if (s == (u16 *) softback_end) |
1664 | s = (u16 *) softback_buf; |
1665 | if (s == (u16 *) softback_in) |
1666 | s = (u16 *) vc->vc_origin; |
1667 | } |
1668 | } |
1669 | |
1670 | static void fbcon_redraw_move(struct vc_data *vc, struct display *p, |
1671 | int line, int count, int dy) |
1672 | { |
1673 | unsigned short *s = (unsigned short *) |
1674 | (vc->vc_origin + vc->vc_size_row * line); |
1675 | |
1676 | while (count--) { |
1677 | unsigned short *start = s; |
1678 | unsigned short *le = advance_row(s, 1); |
1679 | unsigned short c; |
1680 | int x = 0; |
1681 | unsigned short attr = 1; |
1682 | |
1683 | do { |
1684 | c = scr_readw(s); |
1685 | if (attr != (c & 0xff00)) { |
1686 | attr = c & 0xff00; |
1687 | if (s > start) { |
1688 | fbcon_putcs(vc, start, s - start, |
1689 | dy, x); |
1690 | x += s - start; |
1691 | start = s; |
1692 | } |
1693 | } |
1694 | console_conditional_schedule(); |
1695 | s++; |
1696 | } while (s < le); |
1697 | if (s > start) |
1698 | fbcon_putcs(vc, start, s - start, dy, x); |
1699 | console_conditional_schedule(); |
1700 | dy++; |
1701 | } |
1702 | } |
1703 | |
1704 | static void fbcon_redraw_blit(struct vc_data *vc, struct fb_info *info, |
1705 | struct display *p, int line, int count, int ycount) |
1706 | { |
1707 | int offset = ycount * vc->vc_cols; |
1708 | unsigned short *d = (unsigned short *) |
1709 | (vc->vc_origin + vc->vc_size_row * line); |
1710 | unsigned short *s = d + offset; |
1711 | struct fbcon_ops *ops = info->fbcon_par; |
1712 | |
1713 | while (count--) { |
1714 | unsigned short *start = s; |
1715 | unsigned short *le = advance_row(s, 1); |
1716 | unsigned short c; |
1717 | int x = 0; |
1718 | |
1719 | do { |
1720 | c = scr_readw(s); |
1721 | |
1722 | if (c == scr_readw(d)) { |
1723 | if (s > start) { |
1724 | ops->bmove(vc, info, line + ycount, x, |
1725 | line, x, 1, s-start); |
1726 | x += s - start + 1; |
1727 | start = s + 1; |
1728 | } else { |
1729 | x++; |
1730 | start++; |
1731 | } |
1732 | } |
1733 | |
1734 | scr_writew(c, d); |
1735 | console_conditional_schedule(); |
1736 | s++; |
1737 | d++; |
1738 | } while (s < le); |
1739 | if (s > start) |
1740 | ops->bmove(vc, info, line + ycount, x, line, x, 1, |
1741 | s-start); |
1742 | console_conditional_schedule(); |
1743 | if (ycount > 0) |
1744 | line++; |
1745 | else { |
1746 | line--; |
1747 | /* NOTE: We subtract two lines from these pointers */ |
1748 | s -= vc->vc_size_row; |
1749 | d -= vc->vc_size_row; |
1750 | } |
1751 | } |
1752 | } |
1753 | |
1754 | static void fbcon_redraw(struct vc_data *vc, struct display *p, |
1755 | int line, int count, int offset) |
1756 | { |
1757 | unsigned short *d = (unsigned short *) |
1758 | (vc->vc_origin + vc->vc_size_row * line); |
1759 | unsigned short *s = d + offset; |
1760 | |
1761 | while (count--) { |
1762 | unsigned short *start = s; |
1763 | unsigned short *le = advance_row(s, 1); |
1764 | unsigned short c; |
1765 | int x = 0; |
1766 | unsigned short attr = 1; |
1767 | |
1768 | do { |
1769 | c = scr_readw(s); |
1770 | if (attr != (c & 0xff00)) { |
1771 | attr = c & 0xff00; |
1772 | if (s > start) { |
1773 | fbcon_putcs(vc, start, s - start, |
1774 | line, x); |
1775 | x += s - start; |
1776 | start = s; |
1777 | } |
1778 | } |
1779 | if (c == scr_readw(d)) { |
1780 | if (s > start) { |
1781 | fbcon_putcs(vc, start, s - start, |
1782 | line, x); |
1783 | x += s - start + 1; |
1784 | start = s + 1; |
1785 | } else { |
1786 | x++; |
1787 | start++; |
1788 | } |
1789 | } |
1790 | scr_writew(c, d); |
1791 | console_conditional_schedule(); |
1792 | s++; |
1793 | d++; |
1794 | } while (s < le); |
1795 | if (s > start) |
1796 | fbcon_putcs(vc, start, s - start, line, x); |
1797 | console_conditional_schedule(); |
1798 | if (offset > 0) |
1799 | line++; |
1800 | else { |
1801 | line--; |
1802 | /* NOTE: We subtract two lines from these pointers */ |
1803 | s -= vc->vc_size_row; |
1804 | d -= vc->vc_size_row; |
1805 | } |
1806 | } |
1807 | } |
1808 | |
1809 | static inline void fbcon_softback_note(struct vc_data *vc, int t, |
1810 | int count) |
1811 | { |
1812 | unsigned short *p; |
1813 | |
1814 | if (vc->vc_num != fg_console) |
1815 | return; |
1816 | p = (unsigned short *) (vc->vc_origin + t * vc->vc_size_row); |
1817 | |
1818 | while (count) { |
1819 | scr_memcpyw((u16 *) softback_in, p, vc->vc_size_row); |
1820 | count--; |
1821 | p = advance_row(p, 1); |
1822 | softback_in += vc->vc_size_row; |
1823 | if (softback_in == softback_end) |
1824 | softback_in = softback_buf; |
1825 | if (softback_in == softback_top) { |
1826 | softback_top += vc->vc_size_row; |
1827 | if (softback_top == softback_end) |
1828 | softback_top = softback_buf; |
1829 | } |
1830 | } |
1831 | softback_curr = softback_in; |
1832 | } |
1833 | |
1834 | static int fbcon_scroll(struct vc_data *vc, int t, int b, int dir, |
1835 | int count) |
1836 | { |
1837 | struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]]; |
1838 | struct display *p = &fb_display[vc->vc_num]; |
1839 | int scroll_partial = info->flags & FBINFO_PARTIAL_PAN_OK; |
1840 | |
1841 | if (fbcon_is_inactive(vc, info)) |
1842 | return -EINVAL; |
1843 | |
1844 | fbcon_cursor(vc, CM_ERASE); |
1845 | |
1846 | /* |
1847 | * ++Geert: Only use ywrap/ypan if the console is in text mode |
1848 | * ++Andrew: Only use ypan on hardware text mode when scrolling the |
1849 | * whole screen (prevents flicker). |
1850 | */ |
1851 | |
1852 | switch (dir) { |
1853 | case SM_UP: |
1854 | if (count > vc->vc_rows) /* Maximum realistic size */ |
1855 | count = vc->vc_rows; |
1856 | if (softback_top) |
1857 | fbcon_softback_note(vc, t, count); |
1858 | if (logo_shown >= 0) |
1859 | goto redraw_up; |
1860 | switch (p->scrollmode) { |
1861 | case SCROLL_MOVE: |
1862 | fbcon_redraw_blit(vc, info, p, t, b - t - count, |
1863 | count); |
1864 | fbcon_clear(vc, b - count, 0, count, vc->vc_cols); |
1865 | scr_memsetw((unsigned short *) (vc->vc_origin + |
1866 | vc->vc_size_row * |
1867 | (b - count)), |
1868 | vc->vc_video_erase_char, |
1869 | vc->vc_size_row * count); |
1870 | return 1; |
1871 | break; |
1872 | |
1873 | case SCROLL_WRAP_MOVE: |
1874 | if (b - t - count > 3 * vc->vc_rows >> 2) { |
1875 | if (t > 0) |
1876 | fbcon_bmove(vc, 0, 0, count, 0, t, |
1877 | vc->vc_cols); |
1878 | ywrap_up(vc, count); |
1879 | if (vc->vc_rows - b > 0) |
1880 | fbcon_bmove(vc, b - count, 0, b, 0, |
1881 | vc->vc_rows - b, |
1882 | vc->vc_cols); |
1883 | } else if (info->flags & FBINFO_READS_FAST) |
1884 | fbcon_bmove(vc, t + count, 0, t, 0, |
1885 | b - t - count, vc->vc_cols); |
1886 | else |
1887 | goto redraw_up; |
1888 | fbcon_clear(vc, b - count, 0, count, vc->vc_cols); |
1889 | break; |
1890 | |
1891 | case SCROLL_PAN_REDRAW: |
1892 | if ((p->yscroll + count <= |
1893 | 2 * (p->vrows - vc->vc_rows)) |
1894 | && ((!scroll_partial && (b - t == vc->vc_rows)) |
1895 | || (scroll_partial |
1896 | && (b - t - count > |
1897 | 3 * vc->vc_rows >> 2)))) { |
1898 | if (t > 0) |
1899 | fbcon_redraw_move(vc, p, 0, t, count); |
1900 | ypan_up_redraw(vc, t, count); |
1901 | if (vc->vc_rows - b > 0) |
1902 | fbcon_redraw_move(vc, p, b, |
1903 | vc->vc_rows - b, b); |
1904 | } else |
1905 | fbcon_redraw_move(vc, p, t + count, b - t - count, t); |
1906 | fbcon_clear(vc, b - count, 0, count, vc->vc_cols); |
1907 | break; |
1908 | |
1909 | case SCROLL_PAN_MOVE: |
1910 | if ((p->yscroll + count <= |
1911 | 2 * (p->vrows - vc->vc_rows)) |
1912 | && ((!scroll_partial && (b - t == vc->vc_rows)) |
1913 | || (scroll_partial |
1914 | && (b - t - count > |
1915 | 3 * vc->vc_rows >> 2)))) { |
1916 | if (t > 0) |
1917 | fbcon_bmove(vc, 0, 0, count, 0, t, |
1918 | vc->vc_cols); |
1919 | ypan_up(vc, count); |
1920 | if (vc->vc_rows - b > 0) |
1921 | fbcon_bmove(vc, b - count, 0, b, 0, |
1922 | vc->vc_rows - b, |
1923 | vc->vc_cols); |
1924 | } else if (info->flags & FBINFO_READS_FAST) |
1925 | fbcon_bmove(vc, t + count, 0, t, 0, |
1926 | b - t - count, vc->vc_cols); |
1927 | else |
1928 | goto redraw_up; |
1929 | fbcon_clear(vc, b - count, 0, count, vc->vc_cols); |
1930 | break; |
1931 | |
1932 | case SCROLL_REDRAW: |
1933 | redraw_up: |
1934 | fbcon_redraw(vc, p, t, b - t - count, |
1935 | count * vc->vc_cols); |
1936 | fbcon_clear(vc, b - count, 0, count, vc->vc_cols); |
1937 | scr_memsetw((unsigned short *) (vc->vc_origin + |
1938 | vc->vc_size_row * |
1939 | (b - count)), |
1940 | vc->vc_video_erase_char, |
1941 | vc->vc_size_row * count); |
1942 | return 1; |
1943 | } |
1944 | break; |
1945 | |
1946 | case SM_DOWN: |
1947 | if (count > vc->vc_rows) /* Maximum realistic size */ |
1948 | count = vc->vc_rows; |
1949 | if (logo_shown >= 0) |
1950 | goto redraw_down; |
1951 | switch (p->scrollmode) { |
1952 | case SCROLL_MOVE: |
1953 | fbcon_redraw_blit(vc, info, p, b - 1, b - t - count, |
1954 | -count); |
1955 | fbcon_clear(vc, t, 0, count, vc->vc_cols); |
1956 | scr_memsetw((unsigned short *) (vc->vc_origin + |
1957 | vc->vc_size_row * |
1958 | t), |
1959 | vc->vc_video_erase_char, |
1960 | vc->vc_size_row * count); |
1961 | return 1; |
1962 | break; |
1963 | |
1964 | case SCROLL_WRAP_MOVE: |
1965 | if (b - t - count > 3 * vc->vc_rows >> 2) { |
1966 | if (vc->vc_rows - b > 0) |
1967 | fbcon_bmove(vc, b, 0, b - count, 0, |
1968 | vc->vc_rows - b, |
1969 | vc->vc_cols); |
1970 | ywrap_down(vc, count); |
1971 | if (t > 0) |
1972 | fbcon_bmove(vc, count, 0, 0, 0, t, |
1973 | vc->vc_cols); |
1974 | } else if (info->flags & FBINFO_READS_FAST) |
1975 | fbcon_bmove(vc, t, 0, t + count, 0, |
1976 | b - t - count, vc->vc_cols); |
1977 | else |
1978 | goto redraw_down; |
1979 | fbcon_clear(vc, t, 0, count, vc->vc_cols); |
1980 | break; |
1981 | |
1982 | case SCROLL_PAN_MOVE: |
1983 | if ((count - p->yscroll <= p->vrows - vc->vc_rows) |
1984 | && ((!scroll_partial && (b - t == vc->vc_rows)) |
1985 | || (scroll_partial |
1986 | && (b - t - count > |
1987 | 3 * vc->vc_rows >> 2)))) { |
1988 | if (vc->vc_rows - b > 0) |
1989 | fbcon_bmove(vc, b, 0, b - count, 0, |
1990 | vc->vc_rows - b, |
1991 | vc->vc_cols); |
1992 | ypan_down(vc, count); |
1993 | if (t > 0) |
1994 | fbcon_bmove(vc, count, 0, 0, 0, t, |
1995 | vc->vc_cols); |
1996 | } else if (info->flags & FBINFO_READS_FAST) |
1997 | fbcon_bmove(vc, t, 0, t + count, 0, |
1998 | b - t - count, vc->vc_cols); |
1999 | else |
2000 | goto redraw_down; |
2001 | fbcon_clear(vc, t, 0, count, vc->vc_cols); |
2002 | break; |
2003 | |
2004 | case SCROLL_PAN_REDRAW: |
2005 | if ((count - p->yscroll <= p->vrows - vc->vc_rows) |
2006 | && ((!scroll_partial && (b - t == vc->vc_rows)) |
2007 | || (scroll_partial |
2008 | && (b - t - count > |
2009 | 3 * vc->vc_rows >> 2)))) { |
2010 | if (vc->vc_rows - b > 0) |
2011 | fbcon_redraw_move(vc, p, b, vc->vc_rows - b, |
2012 | b - count); |
2013 | ypan_down_redraw(vc, t, count); |
2014 | if (t > 0) |
2015 | fbcon_redraw_move(vc, p, count, t, 0); |
2016 | } else |
2017 | fbcon_redraw_move(vc, p, t, b - t - count, t + count); |
2018 | fbcon_clear(vc, t, 0, count, vc->vc_cols); |
2019 | break; |
2020 | |
2021 | case SCROLL_REDRAW: |
2022 | redraw_down: |
2023 | fbcon_redraw(vc, p, b - 1, b - t - count, |
2024 | -count * vc->vc_cols); |
2025 | fbcon_clear(vc, t, 0, count, vc->vc_cols); |
2026 | scr_memsetw((unsigned short *) (vc->vc_origin + |
2027 | vc->vc_size_row * |
2028 | t), |
2029 | vc->vc_video_erase_char, |
2030 | vc->vc_size_row * count); |
2031 | return 1; |
2032 | } |
2033 | } |
2034 | return 0; |
2035 | } |
2036 | |
2037 | |
2038 | static void fbcon_bmove(struct vc_data *vc, int sy, int sx, int dy, int dx, |
2039 | int height, int width) |
2040 | { |
2041 | struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]]; |
2042 | struct display *p = &fb_display[vc->vc_num]; |
2043 | |
2044 | if (fbcon_is_inactive(vc, info)) |
2045 | return; |
2046 | |
2047 | if (!width || !height) |
2048 | return; |
2049 | |
2050 | /* Split blits that cross physical y_wrap case. |
2051 | * Pathological case involves 4 blits, better to use recursive |
2052 | * code rather than unrolled case |
2053 | * |
2054 | * Recursive invocations don't need to erase the cursor over and |
2055 | * over again, so we use fbcon_bmove_rec() |
2056 | */ |
2057 | fbcon_bmove_rec(vc, p, sy, sx, dy, dx, height, width, |
2058 | p->vrows - p->yscroll); |
2059 | } |
2060 | |
2061 | static void fbcon_bmove_rec(struct vc_data *vc, struct display *p, int sy, int sx, |
2062 | int dy, int dx, int height, int width, u_int y_break) |
2063 | { |
2064 | struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]]; |
2065 | struct fbcon_ops *ops = info->fbcon_par; |
2066 | u_int b; |
2067 | |
2068 | if (sy < y_break && sy + height > y_break) { |
2069 | b = y_break - sy; |
2070 | if (dy < sy) { /* Avoid trashing self */ |
2071 | fbcon_bmove_rec(vc, p, sy, sx, dy, dx, b, width, |
2072 | y_break); |
2073 | fbcon_bmove_rec(vc, p, sy + b, sx, dy + b, dx, |
2074 | height - b, width, y_break); |
2075 | } else { |
2076 | fbcon_bmove_rec(vc, p, sy + b, sx, dy + b, dx, |
2077 | height - b, width, y_break); |
2078 | fbcon_bmove_rec(vc, p, sy, sx, dy, dx, b, width, |
2079 | y_break); |
2080 | } |
2081 | return; |
2082 | } |
2083 | |
2084 | if (dy < y_break && dy + height > y_break) { |
2085 | b = y_break - dy; |
2086 | if (dy < sy) { /* Avoid trashing self */ |
2087 | fbcon_bmove_rec(vc, p, sy, sx, dy, dx, b, width, |
2088 | y_break); |
2089 | fbcon_bmove_rec(vc, p, sy + b, sx, dy + b, dx, |
2090 | height - b, width, y_break); |
2091 | } else { |
2092 | fbcon_bmove_rec(vc, p, sy + b, sx, dy + b, dx, |
2093 | height - b, width, y_break); |
2094 | fbcon_bmove_rec(vc, p, sy, sx, dy, dx, b, width, |
2095 | y_break); |
2096 | } |
2097 | return; |
2098 | } |
2099 | ops->bmove(vc, info, real_y(p, sy), sx, real_y(p, dy), dx, |
2100 | height, width); |
2101 | } |
2102 | |
2103 | static void updatescrollmode(struct display *p, |
2104 | struct fb_info *info, |
2105 | struct vc_data *vc) |
2106 | { |
2107 | struct fbcon_ops *ops = info->fbcon_par; |
2108 | int fh = vc->vc_font.height; |
2109 | int cap = info->flags; |
2110 | u16 t = 0; |
2111 | int ypan = FBCON_SWAP(ops->rotate, info->fix.ypanstep, |
2112 | info->fix.xpanstep); |
2113 | int ywrap = FBCON_SWAP(ops->rotate, info->fix.ywrapstep, t); |
2114 | int yres = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres); |
2115 | int vyres = FBCON_SWAP(ops->rotate, info->var.yres_virtual, |
2116 | info->var.xres_virtual); |
2117 | int good_pan = (cap & FBINFO_HWACCEL_YPAN) && |
2118 | divides(ypan, vc->vc_font.height) && vyres > yres; |
2119 | int good_wrap = (cap & FBINFO_HWACCEL_YWRAP) && |
2120 | divides(ywrap, vc->vc_font.height) && |
2121 | divides(vc->vc_font.height, vyres) && |
2122 | divides(vc->vc_font.height, yres); |
2123 | int reading_fast = cap & FBINFO_READS_FAST; |
2124 | int fast_copyarea = (cap & FBINFO_HWACCEL_COPYAREA) && |
2125 | !(cap & FBINFO_HWACCEL_DISABLED); |
2126 | int fast_imageblit = (cap & FBINFO_HWACCEL_IMAGEBLIT) && |
2127 | !(cap & FBINFO_HWACCEL_DISABLED); |
2128 | |
2129 | p->vrows = vyres/fh; |
2130 | if (yres > (fh * (vc->vc_rows + 1))) |
2131 | p->vrows -= (yres - (fh * vc->vc_rows)) / fh; |
2132 | if ((yres % fh) && (vyres % fh < yres % fh)) |
2133 | p->vrows--; |
2134 | |
2135 | if (good_wrap || good_pan) { |
2136 | if (reading_fast || fast_copyarea) |
2137 | p->scrollmode = good_wrap ? |
2138 | SCROLL_WRAP_MOVE : SCROLL_PAN_MOVE; |
2139 | else |
2140 | p->scrollmode = good_wrap ? SCROLL_REDRAW : |
2141 | SCROLL_PAN_REDRAW; |
2142 | } else { |
2143 | if (reading_fast || (fast_copyarea && !fast_imageblit)) |
2144 | p->scrollmode = SCROLL_MOVE; |
2145 | else |
2146 | p->scrollmode = SCROLL_REDRAW; |
2147 | } |
2148 | } |
2149 | |
2150 | static int fbcon_resize(struct vc_data *vc, unsigned int width, |
2151 | unsigned int height, unsigned int user) |
2152 | { |
2153 | struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]]; |
2154 | struct fbcon_ops *ops = info->fbcon_par; |
2155 | struct display *p = &fb_display[vc->vc_num]; |
2156 | struct fb_var_screeninfo var = info->var; |
2157 | int x_diff, y_diff, virt_w, virt_h, virt_fw, virt_fh; |
2158 | |
2159 | virt_w = FBCON_SWAP(ops->rotate, width, height); |
2160 | virt_h = FBCON_SWAP(ops->rotate, height, width); |
2161 | virt_fw = FBCON_SWAP(ops->rotate, vc->vc_font.width, |
2162 | vc->vc_font.height); |
2163 | virt_fh = FBCON_SWAP(ops->rotate, vc->vc_font.height, |
2164 | vc->vc_font.width); |
2165 | var.xres = virt_w * virt_fw; |
2166 | var.yres = virt_h * virt_fh; |
2167 | x_diff = info->var.xres - var.xres; |
2168 | y_diff = info->var.yres - var.yres; |
2169 | if (x_diff < 0 || x_diff > virt_fw || |
2170 | y_diff < 0 || y_diff > virt_fh) { |
2171 | const struct fb_videomode *mode; |
2172 | |
2173 | DPRINTK("attempting resize %ix%i\n", var.xres, var.yres); |
2174 | mode = fb_find_best_mode(&var, &info->modelist); |
2175 | if (mode == NULL) |
2176 | return -EINVAL; |
2177 | display_to_var(&var, p); |
2178 | fb_videomode_to_var(&var, mode); |
2179 | |
2180 | if (virt_w > var.xres/virt_fw || virt_h > var.yres/virt_fh) |
2181 | return -EINVAL; |
2182 | |
2183 | DPRINTK("resize now %ix%i\n", var.xres, var.yres); |
2184 | if (CON_IS_VISIBLE(vc)) { |
2185 | var.activate = FB_ACTIVATE_NOW | |
2186 | FB_ACTIVATE_FORCE; |
2187 | fb_set_var(info, &var); |
2188 | } |
2189 | var_to_display(p, &info->var, info); |
2190 | ops->var = info->var; |
2191 | } |
2192 | updatescrollmode(p, info, vc); |
2193 | return 0; |
2194 | } |
2195 | |
2196 | static int fbcon_switch(struct vc_data *vc) |
2197 | { |
2198 | struct fb_info *info, *old_info = NULL; |
2199 | struct fbcon_ops *ops; |
2200 | struct display *p = &fb_display[vc->vc_num]; |
2201 | struct fb_var_screeninfo var; |
2202 | int i, ret, prev_console, charcnt = 256; |
2203 | |
2204 | info = registered_fb[con2fb_map[vc->vc_num]]; |
2205 | ops = info->fbcon_par; |
2206 | |
2207 | if (softback_top) { |
2208 | if (softback_lines) |
2209 | fbcon_set_origin(vc); |
2210 | softback_top = softback_curr = softback_in = softback_buf; |
2211 | softback_lines = 0; |
2212 | fbcon_update_softback(vc); |
2213 | } |
2214 | |
2215 | if (logo_shown >= 0) { |
2216 | struct vc_data *conp2 = vc_cons[logo_shown].d; |
2217 | |
2218 | if (conp2->vc_top == logo_lines |
2219 | && conp2->vc_bottom == conp2->vc_rows) |
2220 | conp2->vc_top = 0; |
2221 | logo_shown = FBCON_LOGO_CANSHOW; |
2222 | } |
2223 | |
2224 | prev_console = ops->currcon; |
2225 | if (prev_console != -1) |
2226 | old_info = registered_fb[con2fb_map[prev_console]]; |
2227 | /* |
2228 | * FIXME: If we have multiple fbdev's loaded, we need to |
2229 | * update all info->currcon. Perhaps, we can place this |
2230 | * in a centralized structure, but this might break some |
2231 | * drivers. |
2232 | * |
2233 | * info->currcon = vc->vc_num; |
2234 | */ |
2235 | for (i = 0; i < FB_MAX; i++) { |
2236 | if (registered_fb[i] != NULL && registered_fb[i]->fbcon_par) { |
2237 | struct fbcon_ops *o = registered_fb[i]->fbcon_par; |
2238 | |
2239 | o->currcon = vc->vc_num; |
2240 | } |
2241 | } |
2242 | memset(&var, 0, sizeof(struct fb_var_screeninfo)); |
2243 | display_to_var(&var, p); |
2244 | var.activate = FB_ACTIVATE_NOW; |
2245 | |
2246 | /* |
2247 | * make sure we don't unnecessarily trip the memcmp() |
2248 | * in fb_set_var() |
2249 | */ |
2250 | info->var.activate = var.activate; |
2251 | var.vmode |= info->var.vmode & ~FB_VMODE_MASK; |
2252 | fb_set_var(info, &var); |
2253 | ops->var = info->var; |
2254 | |
2255 | if (old_info != NULL && (old_info != info || |
2256 | info->flags & FBINFO_MISC_ALWAYS_SETPAR)) { |
2257 | if (info->fbops->fb_set_par) { |
2258 | ret = info->fbops->fb_set_par(info); |
2259 | |
2260 | if (ret) |
2261 | printk(KERN_ERR "fbcon_switch: detected " |
2262 | "unhandled fb_set_par error, " |
2263 | "error code %d\n", ret); |
2264 | } |
2265 | |
2266 | if (old_info != info) |
2267 | fbcon_del_cursor_timer(old_info); |
2268 | } |
2269 | |
2270 | if (fbcon_is_inactive(vc, info) || |
2271 | ops->blank_state != FB_BLANK_UNBLANK) |
2272 | fbcon_del_cursor_timer(info); |
2273 | else |
2274 | fbcon_add_cursor_timer(info); |
2275 | |
2276 | set_blitting_type(vc, info); |
2277 | ops->cursor_reset = 1; |
2278 | |
2279 | if (ops->rotate_font && ops->rotate_font(info, vc)) { |
2280 | ops->rotate = FB_ROTATE_UR; |
2281 | set_blitting_type(vc, info); |
2282 | } |
2283 | |
2284 | vc->vc_can_do_color = (fb_get_color_depth(&info->var, &info->fix)!=1); |
2285 | vc->vc_complement_mask = vc->vc_can_do_color ? 0x7700 : 0x0800; |
2286 | |
2287 | if (p->userfont) |
2288 | charcnt = FNTCHARCNT(vc->vc_font.data); |
2289 | |
2290 | if (charcnt > 256) |
2291 | vc->vc_complement_mask <<= 1; |
2292 | |
2293 | updatescrollmode(p, info, vc); |
2294 | |
2295 | switch (p->scrollmode) { |
2296 | case SCROLL_WRAP_MOVE: |
2297 | scrollback_phys_max = p->vrows - vc->vc_rows; |
2298 | break; |
2299 | case SCROLL_PAN_MOVE: |
2300 | case SCROLL_PAN_REDRAW: |
2301 | scrollback_phys_max = p->vrows - 2 * vc->vc_rows; |
2302 | if (scrollback_phys_max < 0) |
2303 | scrollback_phys_max = 0; |
2304 | break; |
2305 | default: |
2306 | scrollback_phys_max = 0; |
2307 | break; |
2308 | } |
2309 | |
2310 | scrollback_max = 0; |
2311 | scrollback_current = 0; |
2312 | |
2313 | if (!fbcon_is_inactive(vc, info)) { |
2314 | ops->var.xoffset = ops->var.yoffset = p->yscroll = 0; |
2315 | ops->update_start(info); |
2316 | } |
2317 | |
2318 | fbcon_set_palette(vc, color_table); |
2319 | fbcon_clear_margins(vc, 0); |
2320 | |
2321 | /* TODO: Figure out why the logo gets accessed after the init phase ends |
2322 | * when using the JZ4740 SLCD driver. |
2323 | */ |
2324 | #ifndef CONFIG_FB_JZ4740_SLCD |
2325 | if (logo_shown == FBCON_LOGO_DRAW) { |
2326 | |
2327 | logo_shown = fg_console; |
2328 | /* This is protected above by initmem_freed */ |
2329 | fb_show_logo(info, ops->rotate); |
2330 | update_region(vc, |
2331 | vc->vc_origin + vc->vc_size_row * vc->vc_top, |
2332 | vc->vc_size_row * (vc->vc_bottom - |
2333 | vc->vc_top) / 2); |
2334 | return 0; |
2335 | } |
2336 | #endif |
2337 | return 1; |
2338 | } |
2339 | |
2340 | static void fbcon_generic_blank(struct vc_data *vc, struct fb_info *info, |
2341 | int blank) |
2342 | { |
2343 | struct fb_event event; |
2344 | |
2345 | if (blank) { |
2346 | unsigned short charmask = vc->vc_hi_font_mask ? |
2347 | 0x1ff : 0xff; |
2348 | unsigned short oldc; |
2349 | |
2350 | oldc = vc->vc_video_erase_char; |
2351 | vc->vc_video_erase_char &= charmask; |
2352 | fbcon_clear(vc, 0, 0, vc->vc_rows, vc->vc_cols); |
2353 | vc->vc_video_erase_char = oldc; |
2354 | } |
2355 | |
2356 | |
2357 | if (!lock_fb_info(info)) |
2358 | return; |
2359 | event.info = info; |
2360 | event.data = ␣ |
2361 | fb_notifier_call_chain(FB_EVENT_CONBLANK, &event); |
2362 | unlock_fb_info(info); |
2363 | } |
2364 | |
2365 | static int fbcon_blank(struct vc_data *vc, int blank, int mode_switch) |
2366 | { |
2367 | struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]]; |
2368 | struct fbcon_ops *ops = info->fbcon_par; |
2369 | |
2370 | if (mode_switch) { |
2371 | struct fb_var_screeninfo var = info->var; |
2372 | |
2373 | ops->graphics = 1; |
2374 | |
2375 | if (!blank) { |
2376 | var.activate = FB_ACTIVATE_NOW | FB_ACTIVATE_FORCE; |
2377 | fb_set_var(info, &var); |
2378 | ops->graphics = 0; |
2379 | ops->var = info->var; |
2380 | } |
2381 | } |
2382 | |
2383 | if (!fbcon_is_inactive(vc, info)) { |
2384 | if (ops->blank_state != blank) { |
2385 | ops->blank_state = blank; |
2386 | fbcon_cursor(vc, blank ? CM_ERASE : CM_DRAW); |
2387 | ops->cursor_flash = (!blank); |
2388 | |
2389 | if (!(info->flags & FBINFO_MISC_USEREVENT)) |
2390 | if (fb_blank(info, blank)) |
2391 | fbcon_generic_blank(vc, info, blank); |
2392 | } |
2393 | |
2394 | if (!blank) |
2395 | update_screen(vc); |
2396 | } |
2397 | |
2398 | if (mode_switch || fbcon_is_inactive(vc, info) || |
2399 | ops->blank_state != FB_BLANK_UNBLANK) |
2400 | fbcon_del_cursor_timer(info); |
2401 | else |
2402 | fbcon_add_cursor_timer(info); |
2403 | |
2404 | return 0; |
2405 | } |
2406 | |
2407 | static int fbcon_debug_enter(struct vc_data *vc) |
2408 | { |
2409 | struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]]; |
2410 | struct fbcon_ops *ops = info->fbcon_par; |
2411 | |
2412 | ops->save_graphics = ops->graphics; |
2413 | ops->graphics = 0; |
2414 | if (info->fbops->fb_debug_enter) |
2415 | info->fbops->fb_debug_enter(info); |
2416 | fbcon_set_palette(vc, color_table); |
2417 | return 0; |
2418 | } |
2419 | |
2420 | static int fbcon_debug_leave(struct vc_data *vc) |
2421 | { |
2422 | struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]]; |
2423 | struct fbcon_ops *ops = info->fbcon_par; |
2424 | |
2425 | ops->graphics = ops->save_graphics; |
2426 | if (info->fbops->fb_debug_leave) |
2427 | info->fbops->fb_debug_leave(info); |
2428 | return 0; |
2429 | } |
2430 | |
2431 | static int fbcon_get_font(struct vc_data *vc, struct console_font *font) |
2432 | { |
2433 | u8 *fontdata = vc->vc_font.data; |
2434 | u8 *data = font->data; |
2435 | int i, j; |
2436 | |
2437 | font->width = vc->vc_font.width; |
2438 | font->height = vc->vc_font.height; |
2439 | font->charcount = vc->vc_hi_font_mask ? 512 : 256; |
2440 | if (!font->data) |
2441 | return 0; |
2442 | |
2443 | if (font->width <= 8) { |
2444 | j = vc->vc_font.height; |
2445 | for (i = 0; i < font->charcount; i++) { |
2446 | memcpy(data, fontdata, j); |
2447 | memset(data + j, 0, 32 - j); |
2448 | data += 32; |
2449 | fontdata += j; |
2450 | } |
2451 | } else if (font->width <= 16) { |
2452 | j = vc->vc_font.height * 2; |
2453 | for (i = 0; i < font->charcount; i++) { |
2454 | memcpy(data, fontdata, j); |
2455 | memset(data + j, 0, 64 - j); |
2456 | data += 64; |
2457 | fontdata += j; |
2458 | } |
2459 | } else if (font->width <= 24) { |
2460 | for (i = 0; i < font->charcount; i++) { |
2461 | for (j = 0; j < vc->vc_font.height; j++) { |
2462 | *data++ = fontdata[0]; |
2463 | *data++ = fontdata[1]; |
2464 | *data++ = fontdata[2]; |
2465 | fontdata += sizeof(u32); |
2466 | } |
2467 | memset(data, 0, 3 * (32 - j)); |
2468 | data += 3 * (32 - j); |
2469 | } |
2470 | } else { |
2471 | j = vc->vc_font.height * 4; |
2472 | for (i = 0; i < font->charcount; i++) { |
2473 | memcpy(data, fontdata, j); |
2474 | memset(data + j, 0, 128 - j); |
2475 | data += 128; |
2476 | fontdata += j; |
2477 | } |
2478 | } |
2479 | return 0; |
2480 | } |
2481 | |
2482 | static int fbcon_do_set_font(struct vc_data *vc, int w, int h, |
2483 | const u8 * data, int userfont) |
2484 | { |
2485 | struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]]; |
2486 | struct fbcon_ops *ops = info->fbcon_par; |
2487 | struct display *p = &fb_display[vc->vc_num]; |
2488 | int resize; |
2489 | int cnt; |
2490 | char *old_data = NULL; |
2491 | |
2492 | if (CON_IS_VISIBLE(vc) && softback_lines) |
2493 | fbcon_set_origin(vc); |
2494 | |
2495 | resize = (w != vc->vc_font.width) || (h != vc->vc_font.height); |
2496 | if (p->userfont) |
2497 | old_data = vc->vc_font.data; |
2498 | if (userfont) |
2499 | cnt = FNTCHARCNT(data); |
2500 | else |
2501 | cnt = 256; |
2502 | vc->vc_font.data = (void *)(p->fontdata = data); |
2503 | if ((p->userfont = userfont)) |
2504 | REFCOUNT(data)++; |
2505 | vc->vc_font.width = w; |
2506 | vc->vc_font.height = h; |
2507 | if (vc->vc_hi_font_mask && cnt == 256) { |
2508 | vc->vc_hi_font_mask = 0; |
2509 | if (vc->vc_can_do_color) { |
2510 | vc->vc_complement_mask >>= 1; |
2511 | vc->vc_s_complement_mask >>= 1; |
2512 | } |
2513 | |
2514 | /* ++Edmund: reorder the attribute bits */ |
2515 | if (vc->vc_can_do_color) { |
2516 | unsigned short *cp = |
2517 | (unsigned short *) vc->vc_origin; |
2518 | int count = vc->vc_screenbuf_size / 2; |
2519 | unsigned short c; |
2520 | for (; count > 0; count--, cp++) { |
2521 | c = scr_readw(cp); |
2522 | scr_writew(((c & 0xfe00) >> 1) | |
2523 | (c & 0xff), cp); |
2524 | } |
2525 | c = vc->vc_video_erase_char; |
2526 | vc->vc_video_erase_char = |
2527 | ((c & 0xfe00) >> 1) | (c & 0xff); |
2528 | vc->vc_attr >>= 1; |
2529 | } |
2530 | } else if (!vc->vc_hi_font_mask && cnt == 512) { |
2531 | vc->vc_hi_font_mask = 0x100; |
2532 | if (vc->vc_can_do_color) { |
2533 | vc->vc_complement_mask <<= 1; |
2534 | vc->vc_s_complement_mask <<= 1; |
2535 | } |
2536 | |
2537 | /* ++Edmund: reorder the attribute bits */ |
2538 | { |
2539 | unsigned short *cp = |
2540 | (unsigned short *) vc->vc_origin; |
2541 | int count = vc->vc_screenbuf_size / 2; |
2542 | unsigned short c; |
2543 | for (; count > 0; count--, cp++) { |
2544 | unsigned short newc; |
2545 | c = scr_readw(cp); |
2546 | if (vc->vc_can_do_color) |
2547 | newc = |
2548 | ((c & 0xff00) << 1) | (c & |
2549 | 0xff); |
2550 | else |
2551 | newc = c & ~0x100; |
2552 | scr_writew(newc, cp); |
2553 | } |
2554 | c = vc->vc_video_erase_char; |
2555 | if (vc->vc_can_do_color) { |
2556 | vc->vc_video_erase_char = |
2557 | ((c & 0xff00) << 1) | (c & 0xff); |
2558 | vc->vc_attr <<= 1; |
2559 | } else |
2560 | vc->vc_video_erase_char = c & ~0x100; |
2561 | } |
2562 | |
2563 | } |
2564 | |
2565 | if (resize) { |
2566 | int cols, rows; |
2567 | |
2568 | cols = FBCON_SWAP(ops->rotate, info->var.xres, info->var.yres); |
2569 | rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres); |
2570 | cols /= w; |
2571 | rows /= h; |
2572 | vc_resize(vc, cols, rows); |
2573 | if (CON_IS_VISIBLE(vc) && softback_buf) |
2574 | fbcon_update_softback(vc); |
2575 | } else if (CON_IS_VISIBLE(vc) |
2576 | && vc->vc_mode == KD_TEXT) { |
2577 | fbcon_clear_margins(vc, 0); |
2578 | update_screen(vc); |
2579 | } |
2580 | |
2581 | if (old_data && (--REFCOUNT(old_data) == 0)) |
2582 | kfree(old_data - FONT_EXTRA_WORDS * sizeof(int)); |
2583 | return 0; |
2584 | } |
2585 | |
2586 | static int fbcon_copy_font(struct vc_data *vc, int con) |
2587 | { |
2588 | struct display *od = &fb_display[con]; |
2589 | struct console_font *f = &vc->vc_font; |
2590 | |
2591 | if (od->fontdata == f->data) |
2592 | return 0; /* already the same font... */ |
2593 | return fbcon_do_set_font(vc, f->width, f->height, od->fontdata, od->userfont); |
2594 | } |
2595 | |
2596 | /* |
2597 | * User asked to set font; we are guaranteed that |
2598 | * a) width and height are in range 1..32 |
2599 | * b) charcount does not exceed 512 |
2600 | * but lets not assume that, since someone might someday want to use larger |
2601 | * fonts. And charcount of 512 is small for unicode support. |
2602 | * |
2603 | * However, user space gives the font in 32 rows , regardless of |
2604 | * actual font height. So a new API is needed if support for larger fonts |
2605 | * is ever implemented. |
2606 | */ |
2607 | |
2608 | static int fbcon_set_font(struct vc_data *vc, struct console_font *font, unsigned flags) |
2609 | { |
2610 | struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]]; |
2611 | unsigned charcount = font->charcount; |
2612 | int w = font->width; |
2613 | int h = font->height; |
2614 | int size; |
2615 | int i, csum; |
2616 | u8 *new_data, *data = font->data; |
2617 | int pitch = (font->width+7) >> 3; |
2618 | |
2619 | /* Is there a reason why fbconsole couldn't handle any charcount >256? |
2620 | * If not this check should be changed to charcount < 256 */ |
2621 | if (charcount != 256 && charcount != 512) |
2622 | return -EINVAL; |
2623 | |
2624 | /* Make sure drawing engine can handle the font */ |
2625 | if (!(info->pixmap.blit_x & (1 << (font->width - 1))) || |
2626 | !(info->pixmap.blit_y & (1 << (font->height - 1)))) |
2627 | return -EINVAL; |
2628 | |
2629 | /* Make sure driver can handle the font length */ |
2630 | if (fbcon_invalid_charcount(info, charcount)) |
2631 | return -EINVAL; |
2632 | |
2633 | size = h * pitch * charcount; |
2634 | |
2635 | new_data = kmalloc(FONT_EXTRA_WORDS * sizeof(int) + size, GFP_USER); |
2636 | |
2637 | if (!new_data) |
2638 | return -ENOMEM; |
2639 | |
2640 | new_data += FONT_EXTRA_WORDS * sizeof(int); |
2641 | FNTSIZE(new_data) = size; |
2642 | FNTCHARCNT(new_data) = charcount; |
2643 | REFCOUNT(new_data) = 0; /* usage counter */ |
2644 | for (i=0; i< charcount; i++) { |
2645 | memcpy(new_data + i*h*pitch, data + i*32*pitch, h*pitch); |
2646 | } |
2647 | |
2648 | /* Since linux has a nice crc32 function use it for counting font |
2649 | * checksums. */ |
2650 | csum = crc32(0, new_data, size); |
2651 | |
2652 | FNTSUM(new_data) = csum; |
2653 | /* Check if the same font is on some other console already */ |
2654 | for (i = first_fb_vc; i <= last_fb_vc; i++) { |
2655 | struct vc_data *tmp = vc_cons[i].d; |
2656 | |
2657 | if (fb_display[i].userfont && |
2658 | fb_display[i].fontdata && |
2659 | FNTSUM(fb_display[i].fontdata) == csum && |
2660 | FNTSIZE(fb_display[i].fontdata) == size && |
2661 | tmp->vc_font.width == w && |
2662 | !memcmp(fb_display[i].fontdata, new_data, size)) { |
2663 | kfree(new_data - FONT_EXTRA_WORDS * sizeof(int)); |
2664 | new_data = (u8 *)fb_display[i].fontdata; |
2665 | break; |
2666 | } |
2667 | } |
2668 | return fbcon_do_set_font(vc, font->width, font->height, new_data, 1); |
2669 | } |
2670 | |
2671 | static int fbcon_set_def_font(struct vc_data *vc, struct console_font *font, char *name) |
2672 | { |
2673 | struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]]; |
2674 | const struct font_desc *f; |
2675 | |
2676 | if (!name) |
2677 | f = get_default_font(info->var.xres, info->var.yres, |
2678 | info->pixmap.blit_x, info->pixmap.blit_y); |
2679 | else if (!(f = find_font(name))) |
2680 | return -ENOENT; |
2681 | |
2682 | font->width = f->width; |
2683 | font->height = f->height; |
2684 | return fbcon_do_set_font(vc, f->width, f->height, f->data, 0); |
2685 | } |
2686 | |
2687 | static u16 palette_red[16]; |
2688 | static u16 palette_green[16]; |
2689 | static u16 palette_blue[16]; |
2690 | |
2691 | static struct fb_cmap palette_cmap = { |
2692 | 0, 16, palette_red, palette_green, palette_blue, NULL |
2693 | }; |
2694 | |
2695 | static int fbcon_set_palette(struct vc_data *vc, unsigned char *table) |
2696 | { |
2697 | struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]]; |
2698 | int i, j, k, depth; |
2699 | u8 val; |
2700 | |
2701 | if (fbcon_is_inactive(vc, info)) |
2702 | return -EINVAL; |
2703 | |
2704 | if (!CON_IS_VISIBLE(vc)) |
2705 | return 0; |
2706 | |
2707 | depth = fb_get_color_depth(&info->var, &info->fix); |
2708 | if (depth > 3) { |
2709 | for (i = j = 0; i < 16; i++) { |
2710 | k = table[i]; |
2711 | val = vc->vc_palette[j++]; |
2712 | palette_red[k] = (val << 8) | val; |
2713 | val = vc->vc_palette[j++]; |
2714 | palette_green[k] = (val << 8) | val; |
2715 | val = vc->vc_palette[j++]; |
2716 | palette_blue[k] = (val << 8) | val; |
2717 | } |
2718 | palette_cmap.len = 16; |
2719 | palette_cmap.start = 0; |
2720 | /* |
2721 | * If framebuffer is capable of less than 16 colors, |
2722 | * use default palette of fbcon. |
2723 | */ |
2724 | } else |
2725 | fb_copy_cmap(fb_default_cmap(1 << depth), &palette_cmap); |
2726 | |
2727 | return fb_set_cmap(&palette_cmap, info); |
2728 | } |
2729 | |
2730 | static u16 *fbcon_screen_pos(struct vc_data *vc, int offset) |
2731 | { |
2732 | unsigned long p; |
2733 | int line; |
2734 | |
2735 | if (vc->vc_num != fg_console || !softback_lines) |
2736 | return (u16 *) (vc->vc_origin + offset); |
2737 | line = offset / vc->vc_size_row; |
2738 | if (line >= softback_lines) |
2739 | return (u16 *) (vc->vc_origin + offset - |
2740 | softback_lines * vc->vc_size_row); |
2741 | p = softback_curr + offset; |
2742 | if (p >= softback_end) |
2743 | p += softback_buf - softback_end; |
2744 | return (u16 *) p; |
2745 | } |
2746 | |
2747 | static unsigned long fbcon_getxy(struct vc_data *vc, unsigned long pos, |
2748 | int *px, int *py) |
2749 | { |
2750 | unsigned long ret; |
2751 | int x, y; |
2752 | |
2753 | if (pos >= vc->vc_origin && pos < vc->vc_scr_end) { |
2754 | unsigned long offset = (pos - vc->vc_origin) / 2; |
2755 | |
2756 | x = offset % vc->vc_cols; |
2757 | y = offset / vc->vc_cols; |
2758 | if (vc->vc_num == fg_console) |
2759 | y += softback_lines; |
2760 | ret = pos + (vc->vc_cols - x) * 2; |
2761 | } else if (vc->vc_num == fg_console && softback_lines) { |
2762 | unsigned long offset = pos - softback_curr; |
2763 | |
2764 | if (pos < softback_curr) |
2765 | offset += softback_end - softback_buf; |
2766 | offset /= 2; |
2767 | x = offset % vc->vc_cols; |
2768 | y = offset / vc->vc_cols; |
2769 | ret = pos + (vc->vc_cols - x) * 2; |
2770 | if (ret == softback_end) |
2771 | ret = softback_buf; |
2772 | if (ret == softback_in) |
2773 | ret = vc->vc_origin; |
2774 | } else { |
2775 | /* Should not happen */ |
2776 | x = y = 0; |
2777 | ret = vc->vc_origin; |
2778 | } |
2779 | if (px) |
2780 | *px = x; |
2781 | if (py) |
2782 | *py = y; |
2783 | return ret; |
2784 | } |
2785 | |
2786 | /* As we might be inside of softback, we may work with non-contiguous buffer, |
2787 | that's why we have to use a separate routine. */ |
2788 | static void fbcon_invert_region(struct vc_data *vc, u16 * p, int cnt) |
2789 | { |
2790 | while (cnt--) { |
2791 | u16 a = scr_readw(p); |
2792 | if (!vc->vc_can_do_color) |
2793 | a ^= 0x0800; |
2794 | else if (vc->vc_hi_font_mask == 0x100) |
2795 | a = ((a) & 0x11ff) | (((a) & 0xe000) >> 4) | |
2796 | (((a) & 0x0e00) << 4); |
2797 | else |
2798 | a = ((a) & 0x88ff) | (((a) & 0x7000) >> 4) | |
2799 | (((a) & 0x0700) << 4); |
2800 | scr_writew(a, p++); |
2801 | if (p == (u16 *) softback_end) |
2802 | p = (u16 *) softback_buf; |
2803 | if (p == (u16 *) softback_in) |
2804 | p = (u16 *) vc->vc_origin; |
2805 | } |
2806 | } |
2807 | |
2808 | static int fbcon_scrolldelta(struct vc_data *vc, int lines) |
2809 | { |
2810 | struct fb_info *info = registered_fb[con2fb_map[fg_console]]; |
2811 | struct fbcon_ops *ops = info->fbcon_par; |
2812 | struct display *disp = &fb_display[fg_console]; |
2813 | int offset, limit, scrollback_old; |
2814 | |
2815 | if (softback_top) { |
2816 | if (vc->vc_num != fg_console) |
2817 | return 0; |
2818 | if (vc->vc_mode != KD_TEXT || !lines) |
2819 | return 0; |
2820 | if (logo_shown >= 0) { |
2821 | struct vc_data *conp2 = vc_cons[logo_shown].d; |
2822 | |
2823 | if (conp2->vc_top == logo_lines |
2824 | && conp2->vc_bottom == conp2->vc_rows) |
2825 | conp2->vc_top = 0; |
2826 | if (logo_shown == vc->vc_num) { |
2827 | unsigned long p, q; |
2828 | int i; |
2829 | |
2830 | p = softback_in; |
2831 | q = vc->vc_origin + |
2832 | logo_lines * vc->vc_size_row; |
2833 | for (i = 0; i < logo_lines; i++) { |
2834 | if (p == softback_top) |
2835 | break; |
2836 | if (p == softback_buf) |
2837 | p = softback_end; |
2838 | p -= vc->vc_size_row; |
2839 | q -= vc->vc_size_row; |
2840 | scr_memcpyw((u16 *) q, (u16 *) p, |
2841 | vc->vc_size_row); |
2842 | } |
2843 | softback_in = softback_curr = p; |
2844 | update_region(vc, vc->vc_origin, |
2845 | logo_lines * vc->vc_cols); |
2846 | } |
2847 | logo_shown = FBCON_LOGO_CANSHOW; |
2848 | } |
2849 | fbcon_cursor(vc, CM_ERASE | CM_SOFTBACK); |
2850 | fbcon_redraw_softback(vc, disp, lines); |
2851 | fbcon_cursor(vc, CM_DRAW | CM_SOFTBACK); |
2852 | return 0; |
2853 | } |
2854 | |
2855 | if (!scrollback_phys_max) |
2856 | return -ENOSYS; |
2857 | |
2858 | scrollback_old = scrollback_current; |
2859 | scrollback_current -= lines; |
2860 | if (scrollback_current < 0) |
2861 | scrollback_current = 0; |
2862 | else if (scrollback_current > scrollback_max) |
2863 | scrollback_current = scrollback_max; |
2864 | if (scrollback_current == scrollback_old) |
2865 | return 0; |
2866 | |
2867 | if (fbcon_is_inactive(vc, info)) |
2868 | return 0; |
2869 | |
2870 | fbcon_cursor(vc, CM_ERASE); |
2871 | |
2872 | offset = disp->yscroll - scrollback_current; |
2873 | limit = disp->vrows; |
2874 | switch (disp->scrollmode) { |
2875 | case SCROLL_WRAP_MOVE: |
2876 | info->var.vmode |= FB_VMODE_YWRAP; |
2877 | break; |
2878 | case SCROLL_PAN_MOVE: |
2879 | case SCROLL_PAN_REDRAW: |
2880 | limit -= vc->vc_rows; |
2881 | info->var.vmode &= ~FB_VMODE_YWRAP; |
2882 | break; |
2883 | } |
2884 | if (offset < 0) |
2885 | offset += limit; |
2886 | else if (offset >= limit) |
2887 | offset -= limit; |
2888 | |
2889 | ops->var.xoffset = 0; |
2890 | ops->var.yoffset = offset * vc->vc_font.height; |
2891 | ops->update_start(info); |
2892 | |
2893 | if (!scrollback_current) |
2894 | fbcon_cursor(vc, CM_DRAW); |
2895 | return 0; |
2896 | } |
2897 | |
2898 | static int fbcon_set_origin(struct vc_data *vc) |
2899 | { |
2900 | if (softback_lines) |
2901 | fbcon_scrolldelta(vc, softback_lines); |
2902 | return 0; |
2903 | } |
2904 | |
2905 | static void fbcon_suspended(struct fb_info *info) |
2906 | { |
2907 | struct vc_data *vc = NULL; |
2908 | struct fbcon_ops *ops = info->fbcon_par; |
2909 | |
2910 | if (!ops || ops->currcon < 0) |
2911 | return; |
2912 | vc = vc_cons[ops->currcon].d; |
2913 | |
2914 | /* Clear cursor, restore saved data */ |
2915 | fbcon_cursor(vc, CM_ERASE); |
2916 | } |
2917 | |
2918 | static void fbcon_resumed(struct fb_info *info) |
2919 | { |
2920 | struct vc_data *vc; |
2921 | struct fbcon_ops *ops = info->fbcon_par; |
2922 | |
2923 | if (!ops || ops->currcon < 0) |
2924 | return; |
2925 | vc = vc_cons[ops->currcon].d; |
2926 | |
2927 | update_screen(vc); |
2928 | } |
2929 | |
2930 | static void fbcon_modechanged(struct fb_info *info) |
2931 | { |
2932 | struct fbcon_ops *ops = info->fbcon_par; |
2933 | struct vc_data *vc; |
2934 | struct display *p; |
2935 | int rows, cols; |
2936 | |
2937 | if (!ops || ops->currcon < 0) |
2938 | return; |
2939 | vc = vc_cons[ops->currcon].d; |
2940 | if (vc->vc_mode != KD_TEXT || |
2941 | registered_fb[con2fb_map[ops->currcon]] != info) |
2942 | return; |
2943 | |
2944 | p = &fb_display[vc->vc_num]; |
2945 | set_blitting_type(vc, info); |
2946 | |
2947 | if (CON_IS_VISIBLE(vc)) { |
2948 | var_to_display(p, &info->var, info); |
2949 | cols = FBCON_SWAP(ops->rotate, info->var.xres, info->var.yres); |
2950 | rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres); |
2951 | cols /= vc->vc_font.width; |
2952 | rows /= vc->vc_font.height; |
2953 | vc_resize(vc, cols, rows); |
2954 | updatescrollmode(p, info, vc); |
2955 | scrollback_max = 0; |
2956 | scrollback_current = 0; |
2957 | |
2958 | if (!fbcon_is_inactive(vc, info)) { |
2959 | ops->var.xoffset = ops->var.yoffset = p->yscroll = 0; |
2960 | ops->update_start(info); |
2961 | } |
2962 | |
2963 | fbcon_set_palette(vc, color_table); |
2964 | update_screen(vc); |
2965 | if (softback_buf) |
2966 | fbcon_update_softback(vc); |
2967 | } |
2968 | } |
2969 | |
2970 | static void fbcon_set_all_vcs(struct fb_info *info) |
2971 | { |
2972 | struct fbcon_ops *ops = info->fbcon_par; |
2973 | struct vc_data *vc; |
2974 | struct display *p; |
2975 | int i, rows, cols, fg = -1; |
2976 | |
2977 | if (!ops || ops->currcon < 0) |
2978 | return; |
2979 | |
2980 | for (i = first_fb_vc; i <= last_fb_vc; i++) { |
2981 | vc = vc_cons[i].d; |
2982 | if (!vc || vc->vc_mode != KD_TEXT || |
2983 | registered_fb[con2fb_map[i]] != info) |
2984 | continue; |
2985 | |
2986 | if (CON_IS_VISIBLE(vc)) { |
2987 | fg = i; |
2988 | continue; |
2989 | } |
2990 | |
2991 | p = &fb_display[vc->vc_num]; |
2992 | set_blitting_type(vc, info); |
2993 | var_to_display(p, &info->var, info); |
2994 | cols = FBCON_SWAP(ops->rotate, info->var.xres, info->var.yres); |
2995 | rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres); |
2996 | cols /= vc->vc_font.width; |
2997 | rows /= vc->vc_font.height; |
2998 | vc_resize(vc, cols, rows); |
2999 | } |
3000 | |
3001 | if (fg != -1) |
3002 | fbcon_modechanged(info); |
3003 | } |
3004 | |
3005 | static int fbcon_mode_deleted(struct fb_info *info, |
3006 | struct fb_videomode *mode) |
3007 | { |
3008 | struct fb_info *fb_info; |
3009 | struct display *p; |
3010 | int i, j, found = 0; |
3011 | |
3012 | /* before deletion, ensure that mode is not in use */ |
3013 | for (i = first_fb_vc; i <= last_fb_vc; i++) { |
3014 | j = con2fb_map[i]; |
3015 | if (j == -1) |
3016 | continue; |
3017 | fb_info = registered_fb[j]; |
3018 | if (fb_info != info) |
3019 | continue; |
3020 | p = &fb_display[i]; |
3021 | if (!p || !p->mode) |
3022 | continue; |
3023 | if (fb_mode_is_equal(p->mode, mode)) { |
3024 | found = 1; |
3025 | break; |
3026 | } |
3027 | } |
3028 | return found; |
3029 | } |
3030 | |
3031 | #ifdef CONFIG_VT_HW_CONSOLE_BINDING |
3032 | static int fbcon_unbind(void) |
3033 | { |
3034 | int ret; |
3035 | |
3036 | ret = unbind_con_driver(&fb_con, first_fb_vc, last_fb_vc, |
3037 | fbcon_is_default); |
3038 | |
3039 | if (!ret) |
3040 | fbcon_has_console_bind = 0; |
3041 | |
3042 | return ret; |
3043 | } |
3044 | #else |
3045 | static inline int fbcon_unbind(void) |
3046 | { |
3047 | return -EINVAL; |
3048 | } |
3049 | #endif /* CONFIG_VT_HW_CONSOLE_BINDING */ |
3050 | |
3051 | static int fbcon_fb_unbind(int idx) |
3052 | { |
3053 | int i, new_idx = -1, ret = 0; |
3054 | |
3055 | if (!fbcon_has_console_bind) |
3056 | return 0; |
3057 | |
3058 | for (i = first_fb_vc; i <= last_fb_vc; i++) { |
3059 | if (con2fb_map[i] != idx && |
3060 | con2fb_map[i] != -1) { |
3061 | new_idx = i; |
3062 | break; |
3063 | } |
3064 | } |
3065 | |
3066 | if (new_idx != -1) { |
3067 | for (i = first_fb_vc; i <= last_fb_vc; i++) { |
3068 | if (con2fb_map[i] == idx) |
3069 | set_con2fb_map(i, new_idx, 0); |
3070 | } |
3071 | } else |
3072 | ret = fbcon_unbind(); |
3073 | |
3074 | return ret; |
3075 | } |
3076 | |
3077 | static int fbcon_fb_unregistered(struct fb_info *info) |
3078 | { |
3079 | int i, idx; |
3080 | |
3081 | idx = info->node; |
3082 | for (i = first_fb_vc; i <= last_fb_vc; i++) { |
3083 | if (con2fb_map[i] == idx) |
3084 | con2fb_map[i] = -1; |
3085 | } |
3086 | |
3087 | if (idx == info_idx) { |
3088 | info_idx = -1; |
3089 | |
3090 | for (i = 0; i < FB_MAX; i++) { |
3091 | if (registered_fb[i] != NULL) { |
3092 | info_idx = i; |
3093 | break; |
3094 | } |
3095 | } |
3096 | } |
3097 | |
3098 | if (info_idx != -1) { |
3099 | for (i = first_fb_vc; i <= last_fb_vc; i++) { |
3100 | if (con2fb_map[i] == -1) |
3101 | con2fb_map[i] = info_idx; |
3102 | } |
3103 | } |
3104 | |
3105 | if (primary_device == idx) |
3106 | primary_device = -1; |
3107 | |
3108 | if (!num_registered_fb) |
3109 | unregister_con_driver(&fb_con); |
3110 | |
3111 | return 0; |
3112 | } |
3113 | |
3114 | static void fbcon_remap_all(int idx) |
3115 | { |
3116 | int i; |
3117 | for (i = first_fb_vc; i <= last_fb_vc; i++) |
3118 | set_con2fb_map(i, idx, 0); |
3119 | |
3120 | if (con_is_bound(&fb_con)) { |
3121 | printk(KERN_INFO "fbcon: Remapping primary device, " |
3122 | "fb%i, to tty %i-%i\n", idx, |
3123 | first_fb_vc + 1, last_fb_vc + 1); |
3124 | info_idx = idx; |
3125 | } |
3126 | } |
3127 | |
3128 | #ifdef CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY |
3129 | static void fbcon_select_primary(struct fb_info *info) |
3130 | { |
3131 | if (!map_override && primary_device == -1 && |
3132 | fb_is_primary_device(info)) { |
3133 | int i; |
3134 | |
3135 | printk(KERN_INFO "fbcon: %s (fb%i) is primary device\n", |
3136 | info->fix.id, info->node); |
3137 | primary_device = info->node; |
3138 | |
3139 | for (i = first_fb_vc; i <= last_fb_vc; i++) |
3140 | con2fb_map_boot[i] = primary_device; |
3141 | |
3142 | if (con_is_bound(&fb_con)) { |
3143 | printk(KERN_INFO "fbcon: Remapping primary device, " |
3144 | "fb%i, to tty %i-%i\n", info->node, |
3145 | first_fb_vc + 1, last_fb_vc + 1); |
3146 | info_idx = primary_device; |
3147 | } |
3148 | } |
3149 | |
3150 | } |
3151 | #else |
3152 | static inline void fbcon_select_primary(struct fb_info *info) |
3153 | { |
3154 | return; |
3155 | } |
3156 | #endif /* CONFIG_FRAMEBUFFER_DETECT_PRIMARY */ |
3157 | |
3158 | static int fbcon_fb_registered(struct fb_info *info) |
3159 | { |
3160 | int ret = 0, i, idx; |
3161 | |
3162 | idx = info->node; |
3163 | fbcon_select_primary(info); |
3164 | |
3165 | if (info_idx == -1) { |
3166 | for (i = first_fb_vc; i <= last_fb_vc; i++) { |
3167 | if (con2fb_map_boot[i] == idx) { |
3168 | info_idx = idx; |
3169 | break; |
3170 | } |
3171 | } |
3172 | |
3173 | if (info_idx != -1) |
3174 | ret = fbcon_takeover(1); |
3175 | } else { |
3176 | for (i = first_fb_vc; i <= last_fb_vc; i++) { |
3177 | if (con2fb_map_boot[i] == idx) |
3178 | set_con2fb_map(i, idx, 0); |
3179 | } |
3180 | } |
3181 | |
3182 | return ret; |
3183 | } |
3184 | |
3185 | static void fbcon_fb_blanked(struct fb_info *info, int blank) |
3186 | { |
3187 | struct fbcon_ops *ops = info->fbcon_par; |
3188 | struct vc_data *vc; |
3189 | |
3190 | if (!ops || ops->currcon < 0) |
3191 | return; |
3192 | |
3193 | vc = vc_cons[ops->currcon].d; |
3194 | if (vc->vc_mode != KD_TEXT || |
3195 | registered_fb[con2fb_map[ops->currcon]] != info) |
3196 | return; |
3197 | |
3198 | if (CON_IS_VISIBLE(vc)) { |
3199 | if (blank) |
3200 | do_blank_screen(0); |
3201 | else |
3202 | do_unblank_screen(0); |
3203 | } |
3204 | ops->blank_state = blank; |
3205 | } |
3206 | |
3207 | static void fbcon_new_modelist(struct fb_info *info) |
3208 | { |
3209 | int i; |
3210 | struct vc_data *vc; |
3211 | struct fb_var_screeninfo var; |
3212 | const struct fb_videomode *mode; |
3213 | |
3214 | for (i = first_fb_vc; i <= last_fb_vc; i++) { |
3215 | if (registered_fb[con2fb_map[i]] != info) |
3216 | continue; |
3217 | if (!fb_display[i].mode) |
3218 | continue; |
3219 | vc = vc_cons[i].d; |
3220 | display_to_var(&var, &fb_display[i]); |
3221 | mode = fb_find_nearest_mode(fb_display[i].mode, |
3222 | &info->modelist); |
3223 | fb_videomode_to_var(&var, mode); |
3224 | fbcon_set_disp(info, &var, vc->vc_num); |
3225 | } |
3226 | } |
3227 | |
3228 | static void fbcon_get_requirement(struct fb_info *info, |
3229 | struct fb_blit_caps *caps) |
3230 | { |
3231 | struct vc_data *vc; |
3232 | struct display *p; |
3233 | |
3234 | if (caps->flags) { |
3235 | int i, charcnt; |
3236 | |
3237 | for (i = first_fb_vc; i <= last_fb_vc; i++) { |
3238 | vc = vc_cons[i].d; |
3239 | if (vc && vc->vc_mode == KD_TEXT && |
3240 | info->node == con2fb_map[i]) { |
3241 | p = &fb_display[i]; |
3242 | caps->x |= 1 << (vc->vc_font.width - 1); |
3243 | caps->y |= 1 << (vc->vc_font.height - 1); |
3244 | charcnt = (p->userfont) ? |
3245 | FNTCHARCNT(p->fontdata) : 256; |
3246 | if (caps->len < charcnt) |
3247 | caps->len = charcnt; |
3248 | } |
3249 | } |
3250 | } else { |
3251 | vc = vc_cons[fg_console].d; |
3252 | |
3253 | if (vc && vc->vc_mode == KD_TEXT && |
3254 | info->node == con2fb_map[fg_console]) { |
3255 | p = &fb_display[fg_console]; |
3256 | caps->x = 1 << (vc->vc_font.width - 1); |
3257 | caps->y = 1 << (vc->vc_font.height - 1); |
3258 | caps->len = (p->userfont) ? |
3259 | FNTCHARCNT(p->fontdata) : 256; |
3260 | } |
3261 | } |
3262 | } |
3263 | |
3264 | static int fbcon_event_notify(struct notifier_block *self, |
3265 | unsigned long action, void *data) |
3266 | { |
3267 | struct fb_event *event = data; |
3268 | struct fb_info *info = event->info; |
3269 | struct fb_videomode *mode; |
3270 | struct fb_con2fbmap *con2fb; |
3271 | struct fb_blit_caps *caps; |
3272 | int idx, ret = 0; |
3273 | |
3274 | /* |
3275 | * ignore all events except driver registration and deregistration |
3276 | * if fbcon is not active |
3277 | */ |
3278 | if (fbcon_has_exited && !(action == FB_EVENT_FB_REGISTERED || |
3279 | action == FB_EVENT_FB_UNREGISTERED)) |
3280 | goto done; |
3281 | |
3282 | switch(action) { |
3283 | case FB_EVENT_SUSPEND: |
3284 | fbcon_suspended(info); |
3285 | break; |
3286 | case FB_EVENT_RESUME: |
3287 | fbcon_resumed(info); |
3288 | break; |
3289 | case FB_EVENT_MODE_CHANGE: |
3290 | fbcon_modechanged(info); |
3291 | break; |
3292 | case FB_EVENT_MODE_CHANGE_ALL: |
3293 | fbcon_set_all_vcs(info); |
3294 | break; |
3295 | case FB_EVENT_MODE_DELETE: |
3296 | mode = event->data; |
3297 | ret = fbcon_mode_deleted(info, mode); |
3298 | break; |
3299 | case FB_EVENT_FB_UNBIND: |
3300 | idx = info->node; |
3301 | ret = fbcon_fb_unbind(idx); |
3302 | break; |
3303 | case FB_EVENT_FB_REGISTERED: |
3304 | ret = fbcon_fb_registered(info); |
3305 | break; |
3306 | case FB_EVENT_FB_UNREGISTERED: |
3307 | ret = fbcon_fb_unregistered(info); |
3308 | break; |
3309 | case FB_EVENT_SET_CONSOLE_MAP: |
3310 | con2fb = event->data; |
3311 | ret = set_con2fb_map(con2fb->console - 1, |
3312 | con2fb->framebuffer, 1); |
3313 | break; |
3314 | case FB_EVENT_GET_CONSOLE_MAP: |
3315 | con2fb = event->data; |
3316 | con2fb->framebuffer = con2fb_map[con2fb->console - 1]; |
3317 | break; |
3318 | case FB_EVENT_BLANK: |
3319 | fbcon_fb_blanked(info, *(int *)event->data); |
3320 | break; |
3321 | case FB_EVENT_NEW_MODELIST: |
3322 | fbcon_new_modelist(info); |
3323 | break; |
3324 | case FB_EVENT_GET_REQ: |
3325 | caps = event->data; |
3326 | fbcon_get_requirement(info, caps); |
3327 | break; |
3328 | case FB_EVENT_REMAP_ALL_CONSOLE: |
3329 | idx = info->node; |
3330 | fbcon_remap_all(idx); |
3331 | break; |
3332 | } |
3333 | done: |
3334 | return ret; |
3335 | } |
3336 | |
3337 | /* |
3338 | * The console `switch' structure for the frame buffer based console |
3339 | */ |
3340 | |
3341 | static const struct consw fb_con = { |
3342 | .owner = THIS_MODULE, |
3343 | .con_startup = fbcon_startup, |
3344 | .con_init = fbcon_init, |
3345 | .con_deinit = fbcon_deinit, |
3346 | .con_clear = fbcon_clear, |
3347 | .con_putc = fbcon_putc, |
3348 | .con_putcs = fbcon_putcs, |
3349 | .con_cursor = fbcon_cursor, |
3350 | .con_scroll = fbcon_scroll, |
3351 | .con_bmove = fbcon_bmove, |
3352 | .con_switch = fbcon_switch, |
3353 | .con_blank = fbcon_blank, |
3354 | .con_font_set = fbcon_set_font, |
3355 | .con_font_get = fbcon_get_font, |
3356 | .con_font_default = fbcon_set_def_font, |
3357 | .con_font_copy = fbcon_copy_font, |
3358 | .con_set_palette = fbcon_set_palette, |
3359 | .con_scrolldelta = fbcon_scrolldelta, |
3360 | .con_set_origin = fbcon_set_origin, |
3361 | .con_invert_region = fbcon_invert_region, |
3362 | .con_screen_pos = fbcon_screen_pos, |
3363 | .con_getxy = fbcon_getxy, |
3364 | .con_resize = fbcon_resize, |
3365 | .con_debug_enter = fbcon_debug_enter, |
3366 | .con_debug_leave = fbcon_debug_leave, |
3367 | }; |
3368 | |
3369 | static struct notifier_block fbcon_event_notifier = { |
3370 | .notifier_call = fbcon_event_notify, |
3371 | }; |
3372 | |
3373 | static ssize_t store_rotate(struct device *device, |
3374 | struct device_attribute *attr, const char *buf, |
3375 | size_t count) |
3376 | { |
3377 | struct fb_info *info; |
3378 | int idx; |
3379 | unsigned int rotate; |
3380 | |
3381 | if (fbcon_has_exited) |
3382 | return count; |
3383 | |
3384 | console_lock(); |
3385 | idx = con2fb_map[fg_console]; |
3386 | |
3387 | if (idx == -1 || registered_fb[idx] == NULL) |
3388 | goto err; |
3389 | |
3390 | info = registered_fb[idx]; |
3391 | if (kstrtouint(buf, 0, &rotate)) |
3392 | goto err; |
3393 | fbcon_rotate(info, rotate); |
3394 | err: |
3395 | console_unlock(); |
3396 | return count; |
3397 | } |
3398 | |
3399 | static ssize_t store_rotate_all(struct device *device, |
3400 | struct device_attribute *attr,const char *buf, |
3401 | size_t count) |
3402 | { |
3403 | struct fb_info *info; |
3404 | int idx; |
3405 | unsigned int rotate; |
3406 | |
3407 | if (fbcon_has_exited) |
3408 | return count; |
3409 | |
3410 | console_lock(); |
3411 | idx = con2fb_map[fg_console]; |
3412 | |
3413 | if (idx == -1 || registered_fb[idx] == NULL) |
3414 | goto err; |
3415 | |
3416 | info = registered_fb[idx]; |
3417 | if (kstrtouint(buf, 0, &rotate)) |
3418 | goto err; |
3419 | fbcon_rotate_all(info, rotate); |
3420 | err: |
3421 | console_unlock(); |
3422 | return count; |
3423 | } |
3424 | |
3425 | static ssize_t show_rotate(struct device *device, |
3426 | struct device_attribute *attr,char *buf) |
3427 | { |
3428 | struct fb_info *info; |
3429 | int rotate = 0, idx; |
3430 | |
3431 | if (fbcon_has_exited) |
3432 | return 0; |
3433 | |
3434 | console_lock(); |
3435 | idx = con2fb_map[fg_console]; |
3436 | |
3437 | if (idx == -1 || registered_fb[idx] == NULL) |
3438 | goto err; |
3439 | |
3440 | info = registered_fb[idx]; |
3441 | rotate = fbcon_get_rotate(info); |
3442 | err: |
3443 | console_unlock(); |
3444 | return snprintf(buf, PAGE_SIZE, "%d\n", rotate); |
3445 | } |
3446 | |
3447 | static ssize_t show_cursor_blink(struct device *device, |
3448 | struct device_attribute *attr, char *buf) |
3449 | { |
3450 | struct fb_info *info; |
3451 | struct fbcon_ops *ops; |
3452 | int idx, blink = -1; |
3453 | |
3454 | if (fbcon_has_exited) |
3455 | return 0; |
3456 | |
3457 | console_lock(); |
3458 | idx = con2fb_map[fg_console]; |
3459 | |
3460 | if (idx == -1 || registered_fb[idx] == NULL) |
3461 | goto err; |
3462 | |
3463 | info = registered_fb[idx]; |
3464 | ops = info->fbcon_par; |
3465 | |
3466 | if (!ops) |
3467 | goto err; |
3468 | |
3469 | blink = (ops->flags & FBCON_FLAGS_CURSOR_TIMER) ? 1 : 0; |
3470 | err: |
3471 | console_unlock(); |
3472 | return snprintf(buf, PAGE_SIZE, "%d\n", blink); |
3473 | } |
3474 | |
3475 | static ssize_t store_cursor_blink(struct device *device, |
3476 | struct device_attribute *attr, |
3477 | const char *buf, size_t count) |
3478 | { |
3479 | struct fb_info *info; |
3480 | int idx; |
3481 | unsigned int blink; |
3482 | |
3483 | if (fbcon_has_exited) |
3484 | return count; |
3485 | |
3486 | console_lock(); |
3487 | idx = con2fb_map[fg_console]; |
3488 | |
3489 | if (idx == -1 || registered_fb[idx] == NULL) |
3490 | goto err; |
3491 | |
3492 | info = registered_fb[idx]; |
3493 | |
3494 | if (!info->fbcon_par) |
3495 | goto err; |
3496 | |
3497 | if (kstrtouint(buf, 0, &blink)) |
3498 | goto err; |
3499 | |
3500 | if (blink) { |
3501 | fbcon_cursor_noblink = 0; |
3502 | fbcon_add_cursor_timer(info); |
3503 | } else { |
3504 | fbcon_cursor_noblink = 1; |
3505 | fbcon_del_cursor_timer(info); |
3506 | } |
3507 | |
3508 | err: |
3509 | console_unlock(); |
3510 | return count; |
3511 | } |
3512 | |
3513 | static struct device_attribute device_attrs[] = { |
3514 | __ATTR(rotate, S_IRUGO|S_IWUSR, show_rotate, store_rotate), |
3515 | __ATTR(rotate_all, S_IWUSR, NULL, store_rotate_all), |
3516 | __ATTR(cursor_blink, S_IRUGO|S_IWUSR, show_cursor_blink, |
3517 | store_cursor_blink), |
3518 | }; |
3519 | |
3520 | static int fbcon_init_device(void) |
3521 | { |
3522 | int i, error = 0; |
3523 | |
3524 | fbcon_has_sysfs = 1; |
3525 | |
3526 | for (i = 0; i < ARRAY_SIZE(device_attrs); i++) { |
3527 | error = device_create_file(fbcon_device, &device_attrs[i]); |
3528 | |
3529 | if (error) |
3530 | break; |
3531 | } |
3532 | |
3533 | if (error) { |
3534 | while (--i >= 0) |
3535 | device_remove_file(fbcon_device, &device_attrs[i]); |
3536 | |
3537 | fbcon_has_sysfs = 0; |
3538 | } |
3539 | |
3540 | return 0; |
3541 | } |
3542 | |
3543 | static void fbcon_start(void) |
3544 | { |
3545 | if (num_registered_fb) { |
3546 | int i; |
3547 | |
3548 | console_lock(); |
3549 | |
3550 | for (i = 0; i < FB_MAX; i++) { |
3551 | if (registered_fb[i] != NULL) { |
3552 | info_idx = i; |
3553 | break; |
3554 | } |
3555 | } |
3556 | |
3557 | console_unlock(); |
3558 | fbcon_takeover(0); |
3559 | } |
3560 | } |
3561 | |
3562 | static void fbcon_exit(void) |
3563 | { |
3564 | struct fb_info *info; |
3565 | int i, j, mapped; |
3566 | |
3567 | if (fbcon_has_exited) |
3568 | return; |
3569 | |
3570 | kfree((void *)softback_buf); |
3571 | softback_buf = 0UL; |
3572 | |
3573 | for (i = 0; i < FB_MAX; i++) { |
3574 | int pending = 0; |
3575 | |
3576 | mapped = 0; |
3577 | info = registered_fb[i]; |
3578 | |
3579 | if (info == NULL) |
3580 | continue; |
3581 | |
3582 | if (info->queue.func) |
3583 | pending = cancel_work_sync(&info->queue); |
3584 | DPRINTK("fbcon: %s pending work\n", (pending ? "canceled" : |
3585 | "no")); |
3586 | |
3587 | for (j = first_fb_vc; j <= last_fb_vc; j++) { |
3588 | if (con2fb_map[j] == i) |
3589 | mapped = 1; |
3590 | } |
3591 | |
3592 | if (mapped) { |
3593 | if (info->fbops->fb_release) |
3594 | info->fbops->fb_release(info, 0); |
3595 | module_put(info->fbops->owner); |
3596 | |
3597 | if (info->fbcon_par) { |
3598 | struct fbcon_ops *ops = info->fbcon_par; |
3599 | |
3600 | fbcon_del_cursor_timer(info); |
3601 | kfree(ops->cursor_src); |
3602 | kfree(info->fbcon_par); |
3603 | info->fbcon_par = NULL; |
3604 | } |
3605 | |
3606 | if (info->queue.func == fb_flashcursor) |
3607 | info->queue.func = NULL; |
3608 | } |
3609 | } |
3610 | |
3611 | fbcon_has_exited = 1; |
3612 | } |
3613 | |
3614 | static int __init fb_console_init(void) |
3615 | { |
3616 | int i; |
3617 | |
3618 | console_lock(); |
3619 | fb_register_client(&fbcon_event_notifier); |
3620 | fbcon_device = device_create(fb_class, NULL, MKDEV(0, 0), NULL, |
3621 | "fbcon"); |
3622 | |
3623 | if (IS_ERR(fbcon_device)) { |
3624 | printk(KERN_WARNING "Unable to create device " |
3625 | "for fbcon; errno = %ld\n", |
3626 | PTR_ERR(fbcon_device)); |
3627 | fbcon_device = NULL; |
3628 | } else |
3629 | fbcon_init_device(); |
3630 | |
3631 | for (i = 0; i < MAX_NR_CONSOLES; i++) |
3632 | con2fb_map[i] = -1; |
3633 | |
3634 | console_unlock(); |
3635 | fbcon_start(); |
3636 | return 0; |
3637 | } |
3638 | |
3639 | module_init(fb_console_init); |
3640 | |
3641 | #ifdef MODULE |
3642 | |
3643 | static void __exit fbcon_deinit_device(void) |
3644 | { |
3645 | int i; |
3646 | |
3647 | if (fbcon_has_sysfs) { |
3648 | for (i = 0; i < ARRAY_SIZE(device_attrs); i++) |
3649 | device_remove_file(fbcon_device, &device_attrs[i]); |
3650 | |
3651 | fbcon_has_sysfs = 0; |
3652 | } |
3653 | } |
3654 | |
3655 | static void __exit fb_console_exit(void) |
3656 | { |
3657 | console_lock(); |
3658 | fb_unregister_client(&fbcon_event_notifier); |
3659 | fbcon_deinit_device(); |
3660 | device_destroy(fb_class, MKDEV(0, 0)); |
3661 | fbcon_exit(); |
3662 | console_unlock(); |
3663 | unregister_con_driver(&fb_con); |
3664 | } |
3665 | |
3666 | module_exit(fb_console_exit); |
3667 | |
3668 | #endif |
3669 | |
3670 | MODULE_LICENSE("GPL"); |
3671 |
Branches:
ben-wpan
ben-wpan-stefan
javiroman/ks7010
jz-2.6.34
jz-2.6.34-rc5
jz-2.6.34-rc6
jz-2.6.34-rc7
jz-2.6.35
jz-2.6.36
jz-2.6.37
jz-2.6.38
jz-2.6.39
jz-3.0
jz-3.1
jz-3.11
jz-3.12
jz-3.13
jz-3.15
jz-3.16
jz-3.18-dt
jz-3.2
jz-3.3
jz-3.4
jz-3.5
jz-3.6
jz-3.6-rc2-pwm
jz-3.9
jz-3.9-clk
jz-3.9-rc8
jz47xx
jz47xx-2.6.38
master
Tags:
od-2011-09-04
od-2011-09-18
v2.6.34-rc5
v2.6.34-rc6
v2.6.34-rc7
v3.9