• Home
  • Raw
  • Download

Lines Matching +full:display +full:- +full:width +full:- +full:chars

1 // SPDX-License-Identifier: GPL-2.0
12 * Chars, and VT100 enhancements by Peter MacDonald.
17 * Code to check for different video-cards mostly by Galen Hunt,
18 * <g-hunt@ee.utah.edu>
20 * Rudimentary ISO 10646/Unicode/UTF-8 character set support by
21 * Markus Kuhn, <mskuhn@immd4.informatik.uni-erlangen.de>.
26 * Code for xterm like mouse click reporting by Peter Orbaek 20-Jul-94
29 * User-defined bell sound, new setterm control sequences and printk
30 * redirection by Martin Mares <mj@k332.feld.cvut.cz> 19-Nov-95
35 * <geert@linux-m68k.org>, Jan 1997.
39 * - Arno Griffioen <arno@usn.nl>
40 * - David Carter <carter@cs.bris.ac.uk>
55 * by Emmanuel Marty <core@ggi-project.org>, April 1998
60 * Removed old-style timers, introduced console_timer, made timer
61 * deletion SMP-safe. 17Jun00, Andrew Morton
66 * Fixed UTF-8 mode so alternate charset modes always work according
158 #define vt_get_kmsg_redirect() vt_kmsg_redirect(-1)
163 int global_cursor_default = -1;
194 int want_console = -1;
202 * For each existing display, we have a pointer to console currently visible
203 * on that display, allowing consoles other than fg_console to be refreshed
204 * appropriately. Unless the low-level driver supplies its own display_fg
205 * variable, we use this one for the "master display".
211 * console since the code is (and always was) not re-entrant, so we schedule
212 * all flip requests to process context with schedule-task() and run it from
273 * Low-Level Functions
278 return vc->vc_num == fg_console; in con_is_fg()
292 p = (unsigned short *)(vc->vc_origin + offset); in screenpos()
293 else if (!vc->vc_sw->con_screen_pos) in screenpos()
294 p = (unsigned short *)(vc->vc_visible_origin + offset); in screenpos()
296 p = vc->vc_sw->con_screen_pos(vc, offset); in screenpos()
316 * Code to manage unicode-based screen buffers
323 #define get_vc_uniscr(vc) vc->vc_uni_screen
353 p = uniscr->lines + rows; in vc_uniscr_alloc()
355 uniscr->lines[i] = p; in vc_uniscr_alloc()
368 vc_uniscr_free(vc->vc_uni_screen); in vc_uniscr_set()
369 vc->vc_uni_screen = new_uniscr; in vc_uniscr_set()
377 uniscr->lines[vc->state.y][vc->state.x] = uc; in vc_uniscr_putc()
385 char32_t *ln = uniscr->lines[vc->state.y]; in vc_uniscr_insert()
386 unsigned int x = vc->state.x, cols = vc->vc_cols; in vc_uniscr_insert()
388 memmove(&ln[x + nr], &ln[x], (cols - x - nr) * sizeof(*ln)); in vc_uniscr_insert()
398 char32_t *ln = uniscr->lines[vc->state.y]; in vc_uniscr_delete()
399 unsigned int x = vc->state.x, cols = vc->vc_cols; in vc_uniscr_delete()
401 memmove(&ln[x], &ln[x + nr], (cols - x - nr) * sizeof(*ln)); in vc_uniscr_delete()
402 memset32(&ln[cols - nr], ' ', nr); in vc_uniscr_delete()
412 char32_t *ln = uniscr->lines[vc->state.y]; in vc_uniscr_clear_line()
424 unsigned int cols = vc->vc_cols; in vc_uniscr_clear_lines()
426 while (nr--) in vc_uniscr_clear_lines()
427 memset32(uniscr->lines[y++], ' ', cols); in vc_uniscr_clear_lines()
439 sz = b - t; in vc_uniscr_scroll()
440 clear = b - nr; in vc_uniscr_scroll()
444 d = sz - nr; in vc_uniscr_scroll()
447 char32_t *tmp = uniscr->lines[t + i]; in vc_uniscr_scroll()
452 k -= sz; in vc_uniscr_scroll()
455 uniscr->lines[t + j] = uniscr->lines[t + k]; in vc_uniscr_scroll()
458 uniscr->lines[t + j] = tmp; in vc_uniscr_scroll()
478 char32_t *src_line = src->lines[src_top_row]; in vc_uniscr_copy_area()
479 char32_t *dst_line = dst->lines[dst_row]; in vc_uniscr_copy_area()
482 if (dst_cols - src_cols) in vc_uniscr_copy_area()
483 memset32(dst_line + src_cols, ' ', dst_cols - src_cols); in vc_uniscr_copy_area()
488 char32_t *dst_line = dst->lines[dst_row]; in vc_uniscr_copy_area()
499 * In particular, -ENODATA is returned if the console is not in UTF-8 mode.
508 return -EOPNOTSUPP; in vc_uniscr_check()
512 if (!vc->vc_utf) in vc_uniscr_check()
513 return -ENODATA; in vc_uniscr_check()
515 if (vc->vc_uni_screen) in vc_uniscr_check()
518 uniscr = vc_uniscr_alloc(vc->vc_cols, vc->vc_rows); in vc_uniscr_check()
520 return -ENOMEM; in vc_uniscr_check()
528 p = (unsigned short *)vc->vc_origin; in vc_uniscr_check()
529 mask = vc->vc_hi_font_mask | 0xff; in vc_uniscr_check()
530 for (y = 0; y < vc->vc_rows; y++) { in vc_uniscr_check()
531 char32_t *line = uniscr->lines[y]; in vc_uniscr_check()
532 for (x = 0; x < vc->vc_cols; x++) { in vc_uniscr_check()
538 vc->vc_uni_screen = uniscr; in vc_uniscr_check()
551 int offset = row * vc->vc_size_row + col * 2; in vc_uniscr_copy_line()
557 if (pos >= vc->vc_origin && pos < vc->vc_scr_end) { in vc_uniscr_copy_line()
563 row = (pos - vc->vc_origin) / vc->vc_size_row; in vc_uniscr_copy_line()
564 col = ((pos - vc->vc_origin) % vc->vc_size_row) / 2; in vc_uniscr_copy_line()
565 memcpy(dest, &uniscr->lines[row][col], nr * sizeof(char32_t)); in vc_uniscr_copy_line()
570 * synchronize with console display drivers for a scrollback in vc_uniscr_copy_line()
574 int mask = vc->vc_hi_font_mask | 0xff; in vc_uniscr_copy_line()
576 while (nr--) { in vc_uniscr_copy_line()
599 p = (unsigned short *)vc->vc_origin; in vc_uniscr_debug_check()
600 mask = vc->vc_hi_font_mask | 0xff; in vc_uniscr_debug_check()
601 for (y = 0; y < vc->vc_rows; y++) { in vc_uniscr_debug_check()
602 char32_t *line = uniscr->lines[y]; in vc_uniscr_debug_check()
603 for (x = 0; x < vc->vc_cols; x++) { in vc_uniscr_debug_check()
607 if (tc == -4) in vc_uniscr_debug_check()
609 if (tc == -4) in vc_uniscr_debug_check()
626 nr = b - t - 1; in con_scroll()
627 if (b > vc->vc_rows || t >= b || nr < 1) in con_scroll()
630 if (con_is_visible(vc) && vc->vc_sw->con_scroll(vc, t, b, dir, nr)) in con_scroll()
633 s = clear = (u16 *)(vc->vc_origin + vc->vc_size_row * t); in con_scroll()
634 d = (u16 *)(vc->vc_origin + vc->vc_size_row * (t + nr)); in con_scroll()
637 clear = s + (b - t - nr) * vc->vc_cols; in con_scroll()
640 scr_memmovew(d, s, (b - t - nr) * vc->vc_size_row); in con_scroll()
641 scr_memsetw(clear, vc->vc_video_erase_char, vc->vc_size_row * nr); in con_scroll()
650 if (!vc->vc_sw->con_getxy) { in do_update_region()
651 offset = (start - vc->vc_origin) / 2; in do_update_region()
652 xx = offset % vc->vc_cols; in do_update_region()
653 yy = offset / vc->vc_cols; in do_update_region()
656 start = vc->vc_sw->con_getxy(vc, start, &nxx, &nyy); in do_update_region()
663 while (xx < vc->vc_cols && count) { in do_update_region()
666 vc->vc_sw->con_putcs(vc, q, p-q, yy, startx); in do_update_region()
673 count--; in do_update_region()
676 vc->vc_sw->con_putcs(vc, q, p-q, yy, startx); in do_update_region()
681 if (vc->vc_sw->con_getxy) { in do_update_region()
683 start = vc->vc_sw->con_getxy(vc, start, NULL, NULL); in do_update_region()
699 /* Structure of attributes is hardware-dependent */
705 if (vc->vc_sw->con_build_attr) in build_attr()
706 return vc->vc_sw->con_build_attr(vc, _color, _intensity, in build_attr()
711 * mode (!can_do_color). The formerly used MDA (monochrome display in build_attr()
721 if (!vc->vc_can_do_color) in build_attr()
728 a = (a & 0xF0) | vc->vc_itcolor; in build_attr()
730 a = (a & 0xf0) | vc->vc_ulcolor; in build_attr()
732 a = (a & 0xf0) | vc->vc_halfcolor; in build_attr()
739 if (vc->vc_hi_font_mask == 0x100) in build_attr()
747 vc->vc_attr = build_attr(vc, vc->state.color, vc->state.intensity, in update_attr()
748 vc->state.blink, vc->state.underline, in update_attr()
749 vc->state.reverse ^ vc->vc_decscnm, vc->state.italic); in update_attr()
750 vc->vc_video_erase_char = ' ' | (build_attr(vc, vc->state.color, in update_attr()
751 VCI_NORMAL, vc->state.blink, false, in update_attr()
752 vc->vc_decscnm, false) << 8); in update_attr()
764 if (vc->vc_sw->con_invert_region) { in invert_screen()
765 vc->vc_sw->con_invert_region(vc, p, count); in invert_screen()
771 if (!vc->vc_can_do_color) { in invert_screen()
772 while (cnt--) { in invert_screen()
778 } else if (vc->vc_hi_font_mask == 0x100) { in invert_screen()
779 while (cnt--) { in invert_screen()
788 while (cnt--) { in invert_screen()
807 static int old_offset = -1; in complement_pos()
813 if (old_offset != -1 && old_offset >= 0 && in complement_pos()
814 old_offset < vc->vc_screenbuf_size) { in complement_pos()
817 vc->vc_sw->con_putc(vc, old, oldy, oldx); in complement_pos()
823 if (offset != -1 && offset >= 0 && in complement_pos()
824 offset < vc->vc_screenbuf_size) { in complement_pos()
829 new = old ^ vc->vc_complement_mask; in complement_pos()
832 oldx = (offset >> 1) % vc->vc_cols; in complement_pos()
833 oldy = (offset >> 1) / vc->vc_cols; in complement_pos()
834 vc->vc_sw->con_putc(vc, new, oldy, oldx); in complement_pos()
842 unsigned short *p = (unsigned short *) vc->vc_pos; in insert_char()
845 scr_memmovew(p + nr, p, (vc->vc_cols - vc->state.x - nr) * 2); in insert_char()
846 scr_memsetw(p, vc->vc_video_erase_char, nr * 2); in insert_char()
847 vc->vc_need_wrap = 0; in insert_char()
850 vc->vc_cols - vc->state.x); in insert_char()
855 unsigned short *p = (unsigned short *) vc->vc_pos; in delete_char()
858 scr_memmovew(p, p + nr, (vc->vc_cols - vc->state.x - nr) * 2); in delete_char()
859 scr_memsetw(p + vc->vc_cols - vc->state.x - nr, vc->vc_video_erase_char, in delete_char()
861 vc->vc_need_wrap = 0; in delete_char()
864 vc->vc_cols - vc->state.x); in delete_char()
867 static int softcursor_original = -1;
871 int i = scr_readw((u16 *) vc->vc_pos); in add_softcursor()
872 u32 type = vc->vc_cursor_type; in add_softcursor()
876 if (softcursor_original != -1) in add_softcursor()
886 scr_writew(i, (u16 *)vc->vc_pos); in add_softcursor()
888 vc->vc_sw->con_putc(vc, i, vc->state.y, vc->state.x); in add_softcursor()
893 if (softcursor_original != -1) { in hide_softcursor()
894 scr_writew(softcursor_original, (u16 *)vc->vc_pos); in hide_softcursor()
896 vc->vc_sw->con_putc(vc, softcursor_original, in hide_softcursor()
897 vc->state.y, vc->state.x); in hide_softcursor()
898 softcursor_original = -1; in hide_softcursor()
907 vc->vc_sw->con_cursor(vc, CM_ERASE); in hide_cursor()
913 if (!con_is_fg(vc) || console_blanked || vc->vc_mode == KD_GRAPHICS) in set_cursor()
915 if (vc->vc_deccm) { in set_cursor()
919 if (CUR_SIZE(vc->vc_cursor_type) != CUR_NONE) in set_cursor()
920 vc->vc_sw->con_cursor(vc, CM_DRAW); in set_cursor()
930 !vc->vc_sw->con_set_origin || in set_origin()
931 !vc->vc_sw->con_set_origin(vc)) in set_origin()
932 vc->vc_origin = (unsigned long)vc->vc_screenbuf; in set_origin()
933 vc->vc_visible_origin = vc->vc_origin; in set_origin()
934 vc->vc_scr_end = vc->vc_origin + vc->vc_screenbuf_size; in set_origin()
935 vc->vc_pos = vc->vc_origin + vc->vc_size_row * vc->state.y + in set_origin()
936 2 * vc->state.x; in set_origin()
943 if (vc->vc_sw->con_save_screen) in save_screen()
944 vc->vc_sw->con_save_screen(vc); in save_screen()
952 if (vc->vc_sw->con_flush_scrollback) { in flush_scrollback()
953 vc->vc_sw->con_flush_scrollback(vc); in flush_scrollback()
964 vc->vc_sw->con_switch(vc); in flush_scrollback()
975 unsigned short *p = (unsigned short *)vc->vc_origin; in clear_buffer_attributes()
976 int count = vc->vc_screenbuf_size / 2; in clear_buffer_attributes()
977 int mask = vc->vc_hi_font_mask | 0xff; in clear_buffer_attributes()
979 for (; count > 0; count--, p++) { in clear_buffer_attributes()
980 scr_writew((scr_readw(p)&mask) | (vc->vc_video_erase_char & ~mask), p); in clear_buffer_attributes()
1002 *vc->vc_display_fg = vc; in redraw_screen()
1003 fg_console = vc->vc_num; in redraw_screen()
1010 sysfs_notify(&tty0dev->kobj, NULL, "active"); in redraw_screen()
1018 int old_was_color = vc->vc_can_do_color; in redraw_screen()
1021 update = vc->vc_sw->con_switch(vc); in redraw_screen()
1024 * If console changed from mono<->color, the best we can do in redraw_screen()
1029 if (old_was_color != vc->vc_can_do_color) { in redraw_screen()
1034 if (update && vc->vc_mode != KD_GRAPHICS) in redraw_screen()
1035 do_update_region(vc, vc->vc_origin, vc->vc_screenbuf_size / 2); in redraw_screen()
1056 /* ++Geert: vc->vc_sw->con_init determines console size */ in visual_init()
1057 if (vc->vc_sw) in visual_init()
1058 module_put(vc->vc_sw->owner); in visual_init()
1059 vc->vc_sw = conswitchp; in visual_init()
1062 vc->vc_sw = con_driver_map[num]; in visual_init()
1064 __module_get(vc->vc_sw->owner); in visual_init()
1065 vc->vc_num = num; in visual_init()
1066 vc->vc_display_fg = &master_display_fg; in visual_init()
1067 if (vc->vc_uni_pagedir_loc) in visual_init()
1069 vc->vc_uni_pagedir_loc = &vc->vc_uni_pagedir; in visual_init()
1070 vc->vc_uni_pagedir = NULL; in visual_init()
1071 vc->vc_hi_font_mask = 0; in visual_init()
1072 vc->vc_complement_mask = 0; in visual_init()
1073 vc->vc_can_do_color = 0; in visual_init()
1074 vc->vc_cur_blink_ms = DEFAULT_CURSOR_BLINK_MS; in visual_init()
1075 vc->vc_sw->con_init(vc, init); in visual_init()
1076 if (!vc->vc_complement_mask) in visual_init()
1077 vc->vc_complement_mask = vc->vc_can_do_color ? 0x7700 : 0x0800; in visual_init()
1078 vc->vc_s_complement_mask = vc->vc_complement_mask; in visual_init()
1079 vc->vc_size_row = vc->vc_cols << 1; in visual_init()
1080 vc->vc_screenbuf_size = vc->vc_rows * vc->vc_size_row; in visual_init()
1086 vc->vc_sw->con_deinit(vc); in visual_deinit()
1087 module_put(vc->vc_sw->owner); in visual_deinit()
1118 return -ENXIO; in vc_allocate()
1127 point is still up-to-date and the comment still has its value in vc_allocate()
1128 even if only as a historical artifact. --mj, July 1998 */ in vc_allocate()
1131 return -ENOMEM; in vc_allocate()
1134 tty_port_init(&vc->port); in vc_allocate()
1135 vc->port.ops = &vc_port_ops; in vc_allocate()
1140 if (!*vc->vc_uni_pagedir_loc) in vc_allocate()
1143 err = -EINVAL; in vc_allocate()
1144 if (vc->vc_cols > VC_MAXCOL || vc->vc_rows > VC_MAXROW || in vc_allocate()
1145 vc->vc_screenbuf_size > KMALLOC_MAX_SIZE || !vc->vc_screenbuf_size) in vc_allocate()
1147 err = -ENOMEM; in vc_allocate()
1148 vc->vc_screenbuf = kzalloc(vc->vc_screenbuf_size, GFP_KERNEL); in vc_allocate()
1149 if (!vc->vc_screenbuf) in vc_allocate()
1154 if (global_cursor_default == -1) in vc_allocate()
1157 vc_init(vc, vc->vc_rows, vc->vc_cols, 1); in vc_allocate()
1169 static inline int resize_screen(struct vc_data *vc, int width, int height, in resize_screen() argument
1172 /* Resizes the resolution of the display adapater */ in resize_screen()
1175 if (vc->vc_sw->con_resize) in resize_screen()
1176 err = vc->vc_sw->con_resize(vc, width, height, user); in resize_screen()
1182 * vc_do_resize - resizing method for the tty
1210 return -ENXIO; in vc_do_resize()
1212 user = vc->vc_resize_user; in vc_do_resize()
1213 vc->vc_resize_user = 0; in vc_do_resize()
1216 return -EINVAL; in vc_do_resize()
1218 new_cols = (cols ? cols : vc->vc_cols); in vc_do_resize()
1219 new_rows = (lines ? lines : vc->vc_rows); in vc_do_resize()
1223 if (new_cols == vc->vc_cols && new_rows == vc->vc_rows) { in vc_do_resize()
1228 * yres/xres equal to a number non-multiple of vc_font.height in vc_do_resize()
1233 * if above, and this causes the fbcon_display->vrows to become in vc_do_resize()
1234 * negative and it eventually leads to out-of-bound in vc_do_resize()
1244 return -EINVAL; in vc_do_resize()
1247 return -ENOMEM; in vc_do_resize()
1253 return -ENOMEM; in vc_do_resize()
1260 old_rows = vc->vc_rows; in vc_do_resize()
1261 old_row_size = vc->vc_size_row; in vc_do_resize()
1270 vc->vc_rows = new_rows; in vc_do_resize()
1271 vc->vc_cols = new_cols; in vc_do_resize()
1272 vc->vc_size_row = new_row_size; in vc_do_resize()
1273 vc->vc_screenbuf_size = new_screen_size; in vc_do_resize()
1276 rrem = new_row_size - rlth; in vc_do_resize()
1277 old_origin = vc->vc_origin; in vc_do_resize()
1281 if (vc->state.y > new_rows) { in vc_do_resize()
1282 if (old_rows - vc->state.y < new_rows) { in vc_do_resize()
1287 first_copied_row = (old_rows - new_rows); in vc_do_resize()
1293 first_copied_row = (vc->state.y - new_rows/2); in vc_do_resize()
1312 vc->vc_video_erase_char, rrem); in vc_do_resize()
1317 scr_memsetw((void *)new_origin, vc->vc_video_erase_char, in vc_do_resize()
1318 new_scr_end - new_origin); in vc_do_resize()
1319 oldscreen = vc->vc_screenbuf; in vc_do_resize()
1320 vc->vc_screenbuf = newscreen; in vc_do_resize()
1321 vc->vc_screenbuf_size = new_screen_size; in vc_do_resize()
1326 vc->vc_top = 0; in vc_do_resize()
1327 vc->vc_bottom = vc->vc_rows; in vc_do_resize()
1328 gotoxy(vc, vc->state.x, vc->state.y); in vc_do_resize()
1336 ws.ws_row = vc->vc_rows; in vc_do_resize()
1337 ws.ws_col = vc->vc_cols; in vc_do_resize()
1338 ws.ws_ypixel = vc->vc_scan_lines; in vc_do_resize()
1344 vt_event_post(VT_EVENT_RESIZE, vc->vc_num, vc->vc_num); in vc_do_resize()
1350 * vc_resize - resize a VT
1358 * vc->port.tty
1363 return vc_do_resize(vc->port.tty, vc, cols, rows); in vc_resize()
1367 * vt_resize - resize a VT
1380 struct vc_data *vc = tty->driver_data; in vt_resize()
1384 ret = vc_do_resize(tty, vc, ws->ws_col, ws->ws_row); in vt_resize()
1403 put_pid(vc->vt_pid); in vc_deallocate()
1405 kfree(vc->vc_screenbuf); in vc_deallocate()
1417 #define set_kbd(vc, x) vt_set_kbd_mode_bit((vc)->vc_num, (x))
1418 #define clr_kbd(vc, x) vt_clr_kbd_mode_bit((vc)->vc_num, (x))
1419 #define is_kbd(vc, x) vt_get_kbd_mode_bit((vc)->vc_num, (x))
1458 vc->state.x = 0; in gotoxy()
1460 if (new_x >= vc->vc_cols) in gotoxy()
1461 vc->state.x = vc->vc_cols - 1; in gotoxy()
1463 vc->state.x = new_x; in gotoxy()
1466 if (vc->vc_decom) { in gotoxy()
1467 min_y = vc->vc_top; in gotoxy()
1468 max_y = vc->vc_bottom; in gotoxy()
1471 max_y = vc->vc_rows; in gotoxy()
1474 vc->state.y = min_y; in gotoxy()
1476 vc->state.y = max_y - 1; in gotoxy()
1478 vc->state.y = new_y; in gotoxy()
1479 vc->vc_pos = vc->vc_origin + vc->state.y * vc->vc_size_row + in gotoxy()
1480 (vc->state.x << 1); in gotoxy()
1481 vc->vc_need_wrap = 0; in gotoxy()
1487 gotoxy(vc, new_x, vc->vc_decom ? (vc->vc_top + new_y) : new_y); in gotoxay()
1492 scrolldelta(-(vc->vc_rows / 2)); in scrollback()
1498 lines = vc->vc_rows / 2; in scrollfront()
1507 if (vc->state.y + 1 == vc->vc_bottom) in lf()
1508 con_scroll(vc, vc->vc_top, vc->vc_bottom, SM_UP, 1); in lf()
1509 else if (vc->state.y < vc->vc_rows - 1) { in lf()
1510 vc->state.y++; in lf()
1511 vc->vc_pos += vc->vc_size_row; in lf()
1513 vc->vc_need_wrap = 0; in lf()
1522 if (vc->state.y == vc->vc_top) in ri()
1523 con_scroll(vc, vc->vc_top, vc->vc_bottom, SM_DOWN, 1); in ri()
1524 else if (vc->state.y > 0) { in ri()
1525 vc->state.y--; in ri()
1526 vc->vc_pos -= vc->vc_size_row; in ri()
1528 vc->vc_need_wrap = 0; in ri()
1533 vc->vc_pos -= vc->state.x << 1; in cr()
1534 vc->vc_need_wrap = vc->state.x = 0; in cr()
1540 if (vc->state.x) { in bs()
1541 vc->vc_pos -= 2; in bs()
1542 vc->state.x--; in bs()
1543 vc->vc_need_wrap = 0; in bs()
1559 case 0: /* erase from cursor to end of display */ in csi_J()
1560 vc_uniscr_clear_line(vc, vc->state.x, in csi_J()
1561 vc->vc_cols - vc->state.x); in csi_J()
1562 vc_uniscr_clear_lines(vc, vc->state.y + 1, in csi_J()
1563 vc->vc_rows - vc->state.y - 1); in csi_J()
1564 count = (vc->vc_scr_end - vc->vc_pos) >> 1; in csi_J()
1565 start = (unsigned short *)vc->vc_pos; in csi_J()
1568 vc_uniscr_clear_line(vc, 0, vc->state.x + 1); in csi_J()
1569 vc_uniscr_clear_lines(vc, 0, vc->state.y); in csi_J()
1570 count = ((vc->vc_pos - vc->vc_origin) >> 1) + 1; in csi_J()
1571 start = (unsigned short *)vc->vc_origin; in csi_J()
1576 case 2: /* erase whole display */ in csi_J()
1577 vc_uniscr_clear_lines(vc, 0, vc->vc_rows); in csi_J()
1578 count = vc->vc_cols * vc->vc_rows; in csi_J()
1579 start = (unsigned short *)vc->vc_origin; in csi_J()
1584 scr_memsetw(start, vc->vc_video_erase_char, 2 * count); in csi_J()
1587 vc->vc_need_wrap = 0; in csi_J()
1593 unsigned short *start = (unsigned short *)vc->vc_pos; in csi_K()
1599 count = vc->vc_cols - vc->state.x; in csi_K()
1602 offset = -vc->state.x; in csi_K()
1603 count = vc->state.x + 1; in csi_K()
1606 offset = -vc->state.x; in csi_K()
1607 count = vc->vc_cols; in csi_K()
1612 vc_uniscr_clear_line(vc, vc->state.x + offset, count); in csi_K()
1613 scr_memsetw(start + offset, vc->vc_video_erase_char, 2 * count); in csi_K()
1614 vc->vc_need_wrap = 0; in csi_K()
1627 count = min(vpar, vc->vc_cols - vc->state.x); in csi_X()
1629 vc_uniscr_clear_line(vc, vc->state.x, count); in csi_X()
1630 scr_memsetw((unsigned short *)vc->vc_pos, vc->vc_video_erase_char, 2 * count); in csi_X()
1632 vc->vc_sw->con_clear(vc, vc->state.y, vc->state.x, 1, count); in csi_X()
1633 vc->vc_need_wrap = 0; in csi_X()
1638 vc->state.intensity = VCI_NORMAL; in default_attr()
1639 vc->state.italic = false; in default_attr()
1640 vc->state.underline = false; in default_attr()
1641 vc->state.reverse = false; in default_attr()
1642 vc->state.blink = false; in default_attr()
1643 vc->state.color = vc->vc_def_color; in default_attr()
1651 c->r = i&1 ? 0xaa : 0x00; in rgb_from_256()
1652 c->g = i&2 ? 0xaa : 0x00; in rgb_from_256()
1653 c->b = i&4 ? 0xaa : 0x00; in rgb_from_256()
1655 c->r = i&1 ? 0xff : 0x55; in rgb_from_256()
1656 c->g = i&2 ? 0xff : 0x55; in rgb_from_256()
1657 c->b = i&4 ? 0xff : 0x55; in rgb_from_256()
1659 c->r = (i - 16) / 36 * 85 / 2; in rgb_from_256()
1660 c->g = (i - 16) / 6 % 6 * 85 / 2; in rgb_from_256()
1661 c->b = (i - 16) % 6 * 85 / 2; in rgb_from_256()
1663 c->r = c->g = c->b = i * 10 - 2312; in rgb_from_256()
1668 u8 hue = 0, max = max3(c->r, c->g, c->b); in rgb_foreground()
1670 if (c->r > max / 2) in rgb_foreground()
1672 if (c->g > max / 2) in rgb_foreground()
1674 if (c->b > max / 2) in rgb_foreground()
1679 vc->state.intensity = VCI_BOLD; in rgb_foreground()
1681 vc->state.intensity = VCI_BOLD; in rgb_foreground()
1683 vc->state.intensity = VCI_NORMAL; in rgb_foreground()
1685 vc->state.color = (vc->state.color & 0xf0) | hue; in rgb_foreground()
1691 vc->state.color = (vc->state.color & 0x0f) in rgb_background()
1692 | (c->r&0x80) >> 1 | (c->g&0x80) >> 2 | (c->b&0x80) >> 3; in rgb_background()
1710 if (i > vc->vc_npar) in vc_t416_color()
1713 if (vc->vc_par[i] == 5 && i + 1 <= vc->vc_npar) { in vc_t416_color()
1716 rgb_from_256(vc->vc_par[i], &c); in vc_t416_color()
1717 } else if (vc->vc_par[i] == 2 && i + 3 <= vc->vc_npar) { in vc_t416_color()
1719 c.r = vc->vc_par[i + 1]; in vc_t416_color()
1720 c.g = vc->vc_par[i + 2]; in vc_t416_color()
1721 c.b = vc->vc_par[i + 3]; in vc_t416_color()
1736 for (i = 0; i <= vc->vc_npar; i++) in csi_m()
1737 switch (vc->vc_par[i]) { in csi_m()
1742 vc->state.intensity = VCI_BOLD; in csi_m()
1745 vc->state.intensity = VCI_HALF_BRIGHT; in csi_m()
1748 vc->state.italic = true; in csi_m()
1756 vc->state.underline = true; in csi_m()
1759 vc->state.blink = true; in csi_m()
1762 vc->state.reverse = true; in csi_m()
1764 case 10: /* ANSI X3.64-1979 (SCO-ish?) in csi_m()
1765 * Select primary font, don't display control chars if in csi_m()
1768 vc->vc_translate = set_translate(vc->state.Gx_charset[vc->state.charset], vc); in csi_m()
1769 vc->vc_disp_ctrl = 0; in csi_m()
1770 vc->vc_toggle_meta = 0; in csi_m()
1772 case 11: /* ANSI X3.64-1979 (SCO-ish?) in csi_m()
1773 * Select first alternate font, lets chars < 32 be in csi_m()
1774 * displayed as ROM chars. in csi_m()
1776 vc->vc_translate = set_translate(IBMPC_MAP, vc); in csi_m()
1777 vc->vc_disp_ctrl = 1; in csi_m()
1778 vc->vc_toggle_meta = 0; in csi_m()
1780 case 12: /* ANSI X3.64-1979 (SCO-ish?) in csi_m()
1784 vc->vc_translate = set_translate(IBMPC_MAP, vc); in csi_m()
1785 vc->vc_disp_ctrl = 1; in csi_m()
1786 vc->vc_toggle_meta = 1; in csi_m()
1789 vc->state.intensity = VCI_NORMAL; in csi_m()
1792 vc->state.italic = false; in csi_m()
1795 vc->state.underline = false; in csi_m()
1798 vc->state.blink = false; in csi_m()
1801 vc->state.reverse = false; in csi_m()
1810 vc->state.color = (vc->vc_def_color & 0x0f) | in csi_m()
1811 (vc->state.color & 0xf0); in csi_m()
1814 vc->state.color = (vc->vc_def_color & 0xf0) | in csi_m()
1815 (vc->state.color & 0x0f); in csi_m()
1818 if (vc->vc_par[i] >= 90 && vc->vc_par[i] <= 107) { in csi_m()
1819 if (vc->vc_par[i] < 100) in csi_m()
1820 vc->state.intensity = VCI_BOLD; in csi_m()
1821 vc->vc_par[i] -= 60; in csi_m()
1823 if (vc->vc_par[i] >= 30 && vc->vc_par[i] <= 37) in csi_m()
1824 vc->state.color = color_table[vc->vc_par[i] - 30] in csi_m()
1825 | (vc->state.color & 0xf0); in csi_m()
1826 else if (vc->vc_par[i] >= 40 && vc->vc_par[i] <= 47) in csi_m()
1827 vc->state.color = (color_table[vc->vc_par[i] - 40] << 4) in csi_m()
1828 | (vc->state.color & 0x0f); in csi_m()
1845 len = sprintf(buf, "\033[%d;%dR", vc->state.y + in cursor_report()
1846 (vc->vc_decom ? vc->vc_top + 1 : 1), in cursor_report()
1847 vc->state.x + 1); in cursor_report()
1848 respond_string(buf, len, tty->port); in cursor_report()
1855 respond_string(teminal_ok, strlen(teminal_ok), tty->port); in status_report()
1860 /* terminal answer to an ESC-Z or csi0c query. */ in respond_ID()
1863 respond_string(vt102_id, strlen(vt102_id), tty->port); in respond_ID()
1873 respond_string(buf, len, tty->port); in mouse_report()
1879 return vc_cons[fg_console].d->vc_report_mouse; in mouse_reporting()
1887 for (i = 0; i <= vc->vc_npar; i++) in set_mode()
1888 if (vc->vc_priv == EPdec) { in set_mode()
1889 switch(vc->vc_par[i]) { /* DEC private modes set/reset */ in set_mode()
1898 vc_resize(deccolm ? 132 : 80, vc->vc_rows); in set_mode()
1904 if (vc->vc_decscnm != on_off) { in set_mode()
1905 vc->vc_decscnm = on_off; in set_mode()
1907 vc->vc_screenbuf_size, in set_mode()
1913 vc->vc_decom = on_off; in set_mode()
1917 vc->vc_decawm = on_off; in set_mode()
1926 vc->vc_report_mouse = on_off ? 1 : 0; in set_mode()
1929 vc->vc_deccm = on_off; in set_mode()
1932 vc->vc_report_mouse = on_off ? 2 : 0; in set_mode()
1936 switch(vc->vc_par[i]) { /* ANSI modes set/reset */ in set_mode()
1937 case 3: /* Monitor (display ctrls) */ in set_mode()
1938 vc->vc_disp_ctrl = on_off; in set_mode()
1941 vc->vc_decim = on_off; in set_mode()
1956 switch (vc->vc_par[0]) { in setterm_command()
1958 if (vc->vc_can_do_color && vc->vc_par[1] < 16) { in setterm_command()
1959 vc->vc_ulcolor = color_table[vc->vc_par[1]]; in setterm_command()
1960 if (vc->state.underline) in setterm_command()
1965 if (vc->vc_can_do_color && vc->vc_par[1] < 16) { in setterm_command()
1966 vc->vc_halfcolor = color_table[vc->vc_par[1]]; in setterm_command()
1967 if (vc->state.intensity == VCI_HALF_BRIGHT) in setterm_command()
1972 vc->vc_def_color = vc->vc_attr; in setterm_command()
1973 if (vc->vc_hi_font_mask == 0x100) in setterm_command()
1974 vc->vc_def_color >>= 1; in setterm_command()
1979 blankinterval = min(vc->vc_par[1], 60U) * 60; in setterm_command()
1983 if (vc->vc_npar >= 1) in setterm_command()
1984 vc->vc_bell_pitch = vc->vc_par[1]; in setterm_command()
1986 vc->vc_bell_pitch = DEFAULT_BELL_PITCH; in setterm_command()
1989 if (vc->vc_npar >= 1) in setterm_command()
1990 vc->vc_bell_duration = (vc->vc_par[1] < 2000) ? in setterm_command()
1991 msecs_to_jiffies(vc->vc_par[1]) : 0; in setterm_command()
1993 vc->vc_bell_duration = DEFAULT_BELL_DURATION; in setterm_command()
1996 if (vc->vc_par[1] >= 1 && vc_cons_allocated(vc->vc_par[1] - 1)) in setterm_command()
1997 set_console(vc->vc_par[1] - 1); in setterm_command()
2003 vesa_off_interval = min(vc->vc_par[1], 60U) * 60 * HZ; in setterm_command()
2009 if (vc->vc_npar >= 1 && vc->vc_par[1] >= 50 && in setterm_command()
2010 vc->vc_par[1] <= USHRT_MAX) in setterm_command()
2011 vc->vc_cur_blink_ms = vc->vc_par[1]; in setterm_command()
2013 vc->vc_cur_blink_ms = DEFAULT_CURSOR_BLINK_MS; in setterm_command()
2021 if (nr > vc->vc_cols - vc->state.x) in csi_at()
2022 nr = vc->vc_cols - vc->state.x; in csi_at()
2031 if (nr > vc->vc_rows - vc->state.y) in csi_L()
2032 nr = vc->vc_rows - vc->state.y; in csi_L()
2035 con_scroll(vc, vc->state.y, vc->vc_bottom, SM_DOWN, nr); in csi_L()
2036 vc->vc_need_wrap = 0; in csi_L()
2042 if (nr > vc->vc_cols - vc->state.x) in csi_P()
2043 nr = vc->vc_cols - vc->state.x; in csi_P()
2052 if (nr > vc->vc_rows - vc->state.y) in csi_M()
2053 nr = vc->vc_rows - vc->state.y; in csi_M()
2056 con_scroll(vc, vc->state.y, vc->vc_bottom, SM_UP, nr); in csi_M()
2057 vc->vc_need_wrap = 0; in csi_M()
2060 /* console_lock is held (except via vc_init->reset_terminal */
2063 memcpy(&vc->saved_state, &vc->state, sizeof(vc->state)); in save_cur()
2069 memcpy(&vc->state, &vc->saved_state, sizeof(vc->state)); in restore_cur()
2071 gotoxy(vc, vc->state.x, vc->state.y); in restore_cur()
2072 vc->vc_translate = set_translate(vc->state.Gx_charset[vc->state.charset], in restore_cur()
2075 vc->vc_need_wrap = 0; in restore_cur()
2087 vc->vc_top = 0; in reset_terminal()
2088 vc->vc_bottom = vc->vc_rows; in reset_terminal()
2089 vc->vc_state = ESnormal; in reset_terminal()
2090 vc->vc_priv = EPecma; in reset_terminal()
2091 vc->vc_translate = set_translate(LAT1_MAP, vc); in reset_terminal()
2092 vc->state.Gx_charset[0] = LAT1_MAP; in reset_terminal()
2093 vc->state.Gx_charset[1] = GRAF_MAP; in reset_terminal()
2094 vc->state.charset = 0; in reset_terminal()
2095 vc->vc_need_wrap = 0; in reset_terminal()
2096 vc->vc_report_mouse = 0; in reset_terminal()
2097 vc->vc_utf = default_utf8; in reset_terminal()
2098 vc->vc_utf_count = 0; in reset_terminal()
2100 vc->vc_disp_ctrl = 0; in reset_terminal()
2101 vc->vc_toggle_meta = 0; in reset_terminal()
2103 vc->vc_decscnm = 0; in reset_terminal()
2104 vc->vc_decom = 0; in reset_terminal()
2105 vc->vc_decawm = 1; in reset_terminal()
2106 vc->vc_deccm = global_cursor_default; in reset_terminal()
2107 vc->vc_decim = 0; in reset_terminal()
2109 vt_reset_keyboard(vc->vc_num); in reset_terminal()
2111 vc->vc_cursor_type = cur_default; in reset_terminal()
2112 vc->vc_complement_mask = vc->vc_s_complement_mask; in reset_terminal()
2117 bitmap_zero(vc->vc_tab_stop, VC_TABSTOPS_COUNT); in reset_terminal()
2119 set_bit(i, vc->vc_tab_stop); in reset_terminal()
2121 vc->vc_bell_pitch = DEFAULT_BELL_PITCH; in reset_terminal()
2122 vc->vc_bell_duration = DEFAULT_BELL_DURATION; in reset_terminal()
2123 vc->vc_cur_blink_ms = DEFAULT_CURSOR_BLINK_MS; in reset_terminal()
2133 unsigned char *charset = &vc->state.Gx_charset[which]; in vc_setGx()
2150 if (vc->state.charset == which) in vc_setGx()
2151 vc->vc_translate = set_translate(*charset, vc); in vc_setGx()
2169 if (ansi_control_string(vc->vc_state) && c >= 8 && c <= 13) in do_con_trol()
2175 if (ansi_control_string(vc->vc_state)) in do_con_trol()
2176 vc->vc_state = ESnormal; in do_con_trol()
2177 else if (vc->vc_bell_duration) in do_con_trol()
2178 kd_mksound(vc->vc_bell_pitch, vc->vc_bell_duration); in do_con_trol()
2184 vc->vc_pos -= (vc->state.x << 1); in do_con_trol()
2186 vc->state.x = find_next_bit(vc->vc_tab_stop, in do_con_trol()
2187 min(vc->vc_cols - 1, VC_TABSTOPS_COUNT), in do_con_trol()
2188 vc->state.x + 1); in do_con_trol()
2189 if (vc->state.x >= VC_TABSTOPS_COUNT) in do_con_trol()
2190 vc->state.x = vc->vc_cols - 1; in do_con_trol()
2192 vc->vc_pos += (vc->state.x << 1); in do_con_trol()
2204 vc->state.charset = 1; in do_con_trol()
2205 vc->vc_translate = set_translate(vc->state.Gx_charset[1], vc); in do_con_trol()
2206 vc->vc_disp_ctrl = 1; in do_con_trol()
2209 vc->state.charset = 0; in do_con_trol()
2210 vc->vc_translate = set_translate(vc->state.Gx_charset[0], vc); in do_con_trol()
2211 vc->vc_disp_ctrl = 0; in do_con_trol()
2214 vc->vc_state = ESnormal; in do_con_trol()
2217 vc->vc_state = ESesc; in do_con_trol()
2223 vc->vc_state = ESsquare; in do_con_trol()
2226 switch(vc->vc_state) { in do_con_trol()
2228 vc->vc_state = ESnormal; in do_con_trol()
2231 vc->vc_state = ESsquare; in do_con_trol()
2234 vc->vc_state = ESnonstd; in do_con_trol()
2237 vc->vc_state = ESapc; in do_con_trol()
2240 vc->vc_state = ESpm; in do_con_trol()
2243 vc->vc_state = ESpercent; in do_con_trol()
2256 if (vc->state.x < VC_TABSTOPS_COUNT) in do_con_trol()
2257 set_bit(vc->state.x, vc->vc_tab_stop); in do_con_trol()
2260 vc->vc_state = ESdcs; in do_con_trol()
2272 vc->vc_state = ESsetG0; in do_con_trol()
2275 vc->vc_state = ESsetG1; in do_con_trol()
2278 vc->vc_state = EShash; in do_con_trol()
2293 for (vc->vc_npar = 0; vc->vc_npar < NPAR; vc->vc_npar++) in do_con_trol()
2294 vc->vc_par[vc->vc_npar] = 0; in do_con_trol()
2295 vc->vc_npar = 0; in do_con_trol()
2296 vc->vc_state = ESpalette; in do_con_trol()
2300 vc->vc_state = ESnormal; in do_con_trol()
2302 vc->vc_state = ESosc; in do_con_trol()
2304 vc->vc_state = ESnormal; in do_con_trol()
2308 vc->vc_par[vc->vc_npar++] = hex_to_bin(c); in do_con_trol()
2309 if (vc->vc_npar == 7) { in do_con_trol()
2310 int i = vc->vc_par[0] * 3, j = 1; in do_con_trol()
2311 vc->vc_palette[i] = 16 * vc->vc_par[j++]; in do_con_trol()
2312 vc->vc_palette[i++] += vc->vc_par[j++]; in do_con_trol()
2313 vc->vc_palette[i] = 16 * vc->vc_par[j++]; in do_con_trol()
2314 vc->vc_palette[i++] += vc->vc_par[j++]; in do_con_trol()
2315 vc->vc_palette[i] = 16 * vc->vc_par[j++]; in do_con_trol()
2316 vc->vc_palette[i] += vc->vc_par[j]; in do_con_trol()
2318 vc->vc_state = ESnormal; in do_con_trol()
2321 vc->vc_state = ESnormal; in do_con_trol()
2324 for (vc->vc_npar = 0; vc->vc_npar < NPAR; vc->vc_npar++) in do_con_trol()
2325 vc->vc_par[vc->vc_npar] = 0; in do_con_trol()
2326 vc->vc_npar = 0; in do_con_trol()
2327 vc->vc_state = ESgetpars; in do_con_trol()
2329 vc->vc_state=ESfunckey; in do_con_trol()
2334 vc->vc_priv = EPdec; in do_con_trol()
2337 vc->vc_priv = EPgt; in do_con_trol()
2340 vc->vc_priv = EPeq; in do_con_trol()
2343 vc->vc_priv = EPlt; in do_con_trol()
2346 vc->vc_priv = EPecma; in do_con_trol()
2349 if (c == ';' && vc->vc_npar < NPAR - 1) { in do_con_trol()
2350 vc->vc_npar++; in do_con_trol()
2353 vc->vc_par[vc->vc_npar] *= 10; in do_con_trol()
2354 vc->vc_par[vc->vc_npar] += c - '0'; in do_con_trol()
2357 if (c >= 0x20 && c <= 0x3f) { /* 0x2x, 0x3a and 0x3c - 0x3f */ in do_con_trol()
2358 vc->vc_state = EScsiignore; in do_con_trol()
2361 vc->vc_state = ESnormal; in do_con_trol()
2364 if (vc->vc_priv <= EPdec) in do_con_trol()
2368 if (vc->vc_priv <= EPdec) in do_con_trol()
2372 if (vc->vc_priv == EPdec) { in do_con_trol()
2373 if (vc->vc_par[0]) in do_con_trol()
2374 vc->vc_cursor_type = in do_con_trol()
2375 CUR_MAKE(vc->vc_par[0], in do_con_trol()
2376 vc->vc_par[1], in do_con_trol()
2377 vc->vc_par[2]); in do_con_trol()
2379 vc->vc_cursor_type = cur_default; in do_con_trol()
2384 if (vc->vc_priv == EPdec) { in do_con_trol()
2386 if (vc->vc_par[0]) in do_con_trol()
2387 vc->vc_complement_mask = vc->vc_par[0] << 8 | vc->vc_par[1]; in do_con_trol()
2389 vc->vc_complement_mask = vc->vc_s_complement_mask; in do_con_trol()
2394 if (vc->vc_priv == EPecma) { in do_con_trol()
2395 if (vc->vc_par[0] == 5) in do_con_trol()
2397 else if (vc->vc_par[0] == 6) in do_con_trol()
2402 if (vc->vc_priv != EPecma) { in do_con_trol()
2403 vc->vc_priv = EPecma; in do_con_trol()
2408 if (vc->vc_par[0]) in do_con_trol()
2409 vc->vc_par[0]--; in do_con_trol()
2410 gotoxy(vc, vc->vc_par[0], vc->state.y); in do_con_trol()
2413 if (!vc->vc_par[0]) in do_con_trol()
2414 vc->vc_par[0]++; in do_con_trol()
2415 gotoxy(vc, vc->state.x, vc->state.y - vc->vc_par[0]); in do_con_trol()
2418 if (!vc->vc_par[0]) in do_con_trol()
2419 vc->vc_par[0]++; in do_con_trol()
2420 gotoxy(vc, vc->state.x, vc->state.y + vc->vc_par[0]); in do_con_trol()
2423 if (!vc->vc_par[0]) in do_con_trol()
2424 vc->vc_par[0]++; in do_con_trol()
2425 gotoxy(vc, vc->state.x + vc->vc_par[0], vc->state.y); in do_con_trol()
2428 if (!vc->vc_par[0]) in do_con_trol()
2429 vc->vc_par[0]++; in do_con_trol()
2430 gotoxy(vc, vc->state.x - vc->vc_par[0], vc->state.y); in do_con_trol()
2433 if (!vc->vc_par[0]) in do_con_trol()
2434 vc->vc_par[0]++; in do_con_trol()
2435 gotoxy(vc, 0, vc->state.y + vc->vc_par[0]); in do_con_trol()
2438 if (!vc->vc_par[0]) in do_con_trol()
2439 vc->vc_par[0]++; in do_con_trol()
2440 gotoxy(vc, 0, vc->state.y - vc->vc_par[0]); in do_con_trol()
2443 if (vc->vc_par[0]) in do_con_trol()
2444 vc->vc_par[0]--; in do_con_trol()
2445 gotoxay(vc, vc->state.x ,vc->vc_par[0]); in do_con_trol()
2448 if (vc->vc_par[0]) in do_con_trol()
2449 vc->vc_par[0]--; in do_con_trol()
2450 if (vc->vc_par[1]) in do_con_trol()
2451 vc->vc_par[1]--; in do_con_trol()
2452 gotoxay(vc, vc->vc_par[1], vc->vc_par[0]); in do_con_trol()
2455 csi_J(vc, vc->vc_par[0]); in do_con_trol()
2458 csi_K(vc, vc->vc_par[0]); in do_con_trol()
2461 csi_L(vc, vc->vc_par[0]); in do_con_trol()
2464 csi_M(vc, vc->vc_par[0]); in do_con_trol()
2467 csi_P(vc, vc->vc_par[0]); in do_con_trol()
2470 if (!vc->vc_par[0]) in do_con_trol()
2474 if (!vc->vc_par[0] && vc->state.x < VC_TABSTOPS_COUNT) in do_con_trol()
2475 set_bit(vc->state.x, vc->vc_tab_stop); in do_con_trol()
2476 else if (vc->vc_par[0] == 3) in do_con_trol()
2477 bitmap_zero(vc->vc_tab_stop, VC_TABSTOPS_COUNT); in do_con_trol()
2482 case 'q': /* DECLL - but only 3 leds */ in do_con_trol()
2484 if (vc->vc_par[0] < 4) in do_con_trol()
2485 vt_set_led_state(vc->vc_num, in do_con_trol()
2486 (vc->vc_par[0] < 3) ? vc->vc_par[0] : 4); in do_con_trol()
2489 if (!vc->vc_par[0]) in do_con_trol()
2490 vc->vc_par[0]++; in do_con_trol()
2491 if (!vc->vc_par[1]) in do_con_trol()
2492 vc->vc_par[1] = vc->vc_rows; in do_con_trol()
2494 if (vc->vc_par[0] < vc->vc_par[1] && in do_con_trol()
2495 vc->vc_par[1] <= vc->vc_rows) { in do_con_trol()
2496 vc->vc_top = vc->vc_par[0] - 1; in do_con_trol()
2497 vc->vc_bottom = vc->vc_par[1]; in do_con_trol()
2508 csi_X(vc, vc->vc_par[0]); in do_con_trol()
2511 csi_at(vc, vc->vc_par[0]); in do_con_trol()
2521 vc->vc_state = ESnormal; in do_con_trol()
2524 vc->vc_state = ESnormal; in do_con_trol()
2527 vc->vc_utf = 0; in do_con_trol()
2531 vc->vc_utf = 1; in do_con_trol()
2536 vc->vc_state = ESnormal; in do_con_trol()
2539 vc->vc_state = ESnormal; in do_con_trol()
2541 /* DEC screen alignment test. kludge :-) */ in do_con_trol()
2542 vc->vc_video_erase_char = in do_con_trol()
2543 (vc->vc_video_erase_char & 0xff00) | 'E'; in do_con_trol()
2545 vc->vc_video_erase_char = in do_con_trol()
2546 (vc->vc_video_erase_char & 0xff00) | ' '; in do_con_trol()
2547 do_update_region(vc, vc->vc_origin, vc->vc_screenbuf_size / 2); in do_con_trol()
2552 vc->vc_state = ESnormal; in do_con_trol()
2556 vc->vc_state = ESnormal; in do_con_trol()
2567 vc->vc_state = ESnormal; in do_con_trol()
2572 * Markus Kuhn -- 2007-05-26 (Unicode 5.0)
2588 return -1; in ucs_cmp()
2601 ucs > double_width[ARRAY_SIZE(double_width) - 1].last) in is_double_width()
2615 if (draw->x < 0) in con_flush()
2618 vc->vc_sw->con_putcs(vc, (u16 *)draw->from, in con_flush()
2619 (u16 *)draw->to - (u16 *)draw->from, vc->state.y, in con_flush()
2620 draw->x); in con_flush()
2621 draw->x = -1; in con_flush()
2627 if (vc->vc_toggle_meta) in vc_translate_ascii()
2630 return vc->vc_translate[c]; in vc_translate_ascii()
2638 * vc_sanitize_unicode -- Replace invalid Unicode code points with U+FFFD
2650 * vc_translate_unicode -- Combine UTF-8 into Unicode in @vc_utf_char
2655 * @vc_utf_char is the being-constructed unicode character.
2669 if (!vc->vc_utf_count) in vc_translate_unicode()
2672 vc->vc_utf_char = (vc->vc_utf_char << 6) | (c & 0x3f); in vc_translate_unicode()
2673 vc->vc_npar++; in vc_translate_unicode()
2674 if (--vc->vc_utf_count) in vc_translate_unicode()
2678 c = vc->vc_utf_char; in vc_translate_unicode()
2680 if (c <= utf8_length_changes[vc->vc_npar - 1] || in vc_translate_unicode()
2681 c > utf8_length_changes[vc->vc_npar]) in vc_translate_unicode()
2688 if (vc->vc_utf_count) { in vc_translate_unicode()
2691 vc->vc_utf_count = 0; in vc_translate_unicode()
2700 vc->vc_npar = 0; in vc_translate_unicode()
2702 vc->vc_utf_count = 1; in vc_translate_unicode()
2703 vc->vc_utf_char = (c & 0x1f); in vc_translate_unicode()
2705 vc->vc_utf_count = 2; in vc_translate_unicode()
2706 vc->vc_utf_char = (c & 0x0f); in vc_translate_unicode()
2708 vc->vc_utf_count = 3; in vc_translate_unicode()
2709 vc->vc_utf_char = (c & 0x07); in vc_translate_unicode()
2711 vc->vc_utf_count = 4; in vc_translate_unicode()
2712 vc->vc_utf_char = (c & 0x03); in vc_translate_unicode()
2714 vc->vc_utf_count = 5; in vc_translate_unicode()
2715 vc->vc_utf_char = (c & 0x01); in vc_translate_unicode()
2722 return -1; in vc_translate_unicode()
2728 if (vc->vc_state != ESnormal) in vc_translate()
2731 if (vc->vc_utf && !vc->vc_disp_ctrl) in vc_translate()
2740 if (!vc->vc_can_do_color) in vc_invert_attr()
2741 return vc->vc_attr ^ 0x08; in vc_invert_attr()
2743 if (vc->vc_hi_font_mask == 0x100) in vc_invert_attr()
2744 return (vc->vc_attr & 0x11) | in vc_invert_attr()
2745 ((vc->vc_attr & 0xe0) >> 4) | in vc_invert_attr()
2746 ((vc->vc_attr & 0x0e) << 4); in vc_invert_attr()
2748 return (vc->vc_attr & 0x88) | in vc_invert_attr()
2749 ((vc->vc_attr & 0x70) >> 4) | in vc_invert_attr()
2750 ((vc->vc_attr & 0x07) << 4); in vc_invert_attr()
2765 if (vc->vc_state != ESnormal) in vc_is_control()
2777 * useless without them; to display an arbitrary font position use the in vc_is_control()
2778 * direct-to-font zone in UTF-8 mode. in vc_is_control()
2781 if (vc->vc_disp_ctrl) in vc_is_control()
2784 return vc->vc_utf || (CTRL_ACTION & BIT(c)); in vc_is_control()
2787 if (c == 127 && !vc->vc_disp_ctrl) in vc_is_control()
2800 unsigned char vc_attr = vc->vc_attr; in vc_con_write_normal()
2801 u16 himask = vc->vc_hi_font_mask, charmask = himask ? 0x1ff : 0xff; in vc_con_write_normal()
2802 u8 width = 1; in vc_con_write_normal() local
2805 if (vc->vc_utf && !vc->vc_disp_ctrl) { in vc_con_write_normal()
2807 width = 2; in vc_con_write_normal()
2810 /* Now try to find out how to display it */ in vc_con_write_normal()
2813 if (tc == -1 || tc == -2) in vc_con_write_normal()
2814 return -1; /* nothing to display */ in vc_con_write_normal()
2817 if ((!vc->vc_utf || vc->vc_disp_ctrl || c < 128) && in vc_con_write_normal()
2830 * Display U+FFFD. If it's not found, display an inverse in vc_con_write_normal()
2848 if (vc->vc_need_wrap || vc->vc_decim) in vc_con_write_normal()
2850 if (vc->vc_need_wrap) { in vc_con_write_normal()
2854 if (vc->vc_decim) in vc_con_write_normal()
2863 scr_writew(tc, (u16 *)vc->vc_pos); in vc_con_write_normal()
2865 if (con_should_update(vc) && draw->x < 0) { in vc_con_write_normal()
2866 draw->x = vc->state.x; in vc_con_write_normal()
2867 draw->from = vc->vc_pos; in vc_con_write_normal()
2869 if (vc->state.x == vc->vc_cols - 1) { in vc_con_write_normal()
2870 vc->vc_need_wrap = vc->vc_decawm; in vc_con_write_normal()
2871 draw->to = vc->vc_pos + 2; in vc_con_write_normal()
2873 vc->state.x++; in vc_con_write_normal()
2874 draw->to = (vc->vc_pos += 2); in vc_con_write_normal()
2877 if (!--width) in vc_con_write_normal()
2898 .x = -1, in do_con_write()
2910 vc = tty->driver_data; in do_con_write()
2917 currcons = vc->vc_num; in do_con_write()
2932 while (!tty->stopped && count) { in do_con_write()
2936 count--; in do_con_write()
2942 if (tc == -1) in do_con_write()
2976 * with other console code and prevention of re-entrancy is
2989 been allocated - a new console is not created in console_callback()
2992 want_console = -1; in console_callback()
3001 if (vc->vc_mode == KD_TEXT && vc->vc_sw->con_scrolldelta) in console_callback()
3002 vc->vc_sw->con_scrolldelta(vc, scrollback_delta); in console_callback()
3019 (vc->vt_mode.mode == VT_AUTO && vc->vc_mode == KD_GRAPHICS)) { in set_console()
3029 return -EINVAL; in set_console()
3043 * vt_kmsg_redirect() - Sets/gets the kernel message console
3044 * @new: The new virtual terminal number or -1 if the console should stay
3056 * The parameter -1 means that only the current console is returned, but the
3067 if (new != -1) in vt_kmsg_redirect()
3095 if (kmsg_console && vc_cons_allocated(kmsg_console - 1)) in vt_console_print()
3096 vc = vc_cons[kmsg_console - 1].d; in vt_console_print()
3104 if (vc->vc_mode != KD_TEXT) in vt_console_print()
3111 start = (ushort *)vc->vc_pos; in vt_console_print()
3112 start_x = vc->state.x; in vt_console_print()
3114 while (count--) { in vt_console_print()
3116 if (c == 10 || c == 13 || c == 8 || vc->vc_need_wrap) { in vt_console_print()
3118 vc->vc_sw->con_putcs(vc, start, cnt, vc->state.y, start_x); in vt_console_print()
3122 start = (ushort *)vc->vc_pos; in vt_console_print()
3123 start_x = vc->state.x; in vt_console_print()
3129 start = (ushort *)vc->vc_pos; in vt_console_print()
3130 start_x = vc->state.x; in vt_console_print()
3135 scr_writew((vc->vc_attr << 8) + c, (unsigned short *)vc->vc_pos); in vt_console_print()
3138 if (vc->state.x == vc->vc_cols - 1) { in vt_console_print()
3139 vc->vc_need_wrap = 1; in vt_console_print()
3141 vc->vc_pos += 2; in vt_console_print()
3142 vc->state.x++; in vt_console_print()
3146 vc->vc_sw->con_putcs(vc, start, cnt, vc->state.y, start_x); in vt_console_print()
3156 *index = c->index ? c->index-1 : fg_console; in vt_console_device()
3166 .index = -1,
3171 * Handling of Linux-specific VC ioctls
3192 if (current->signal->tty != tty && !capable(CAP_SYS_ADMIN)) in tioclinux()
3193 return -EPERM; in tioclinux()
3195 return -EFAULT; in tioclinux()
3222 * kernel-internal variable; programs not closely in tioclinux()
3245 ret = -EPERM; in tioclinux()
3248 ret = -EFAULT; in tioclinux()
3261 ret = -EFAULT; in tioclinux()
3282 ret = -EINVAL; in tioclinux()
3311 if (tty->stopped) in con_write_room()
3332 struct vc_data *vc = tty->driver_data; in con_unthrottle()
3334 wake_up_interruptible(&vc->paste_wait); in con_unthrottle()
3338 * Turn the Scroll-Lock LED on when the tty is stopped
3345 console_num = tty->index; in con_stop()
3352 * Turn the Scroll-Lock LED off when the console is started
3359 console_num = tty->index; in con_start()
3374 vc = tty->driver_data; in con_flush_chars()
3385 unsigned int currcons = tty->index; in con_install()
3397 if (vc->port.tty) { in con_install()
3398 ret = -ERESTARTSYS; in con_install()
3402 ret = tty_port_install(&vc->port, driver, tty); in con_install()
3406 tty->driver_data = vc; in con_install()
3407 vc->port.tty = tty; in con_install()
3408 tty_port_get(&vc->port); in con_install()
3410 if (!tty->winsize.ws_row && !tty->winsize.ws_col) { in con_install()
3411 tty->winsize.ws_row = vc_cons[currcons].d->vc_rows; in con_install()
3412 tty->winsize.ws_col = vc_cons[currcons].d->vc_cols; in con_install()
3414 if (vc->vc_utf) in con_install()
3415 tty->termios.c_iflag |= IUTF8; in con_install()
3417 tty->termios.c_iflag &= ~IUTF8; in con_install()
3432 /* Nothing to do - we defer to shutdown */ in con_close()
3437 struct vc_data *vc = tty->driver_data; in con_shutdown()
3440 vc->port.tty = NULL; in con_shutdown()
3446 struct vc_data *vc = tty->driver_data; in con_cleanup()
3448 tty_port_put(&vc->port); in con_cleanup()
3463 vc->vc_cols = cols; in vc_init()
3464 vc->vc_rows = rows; in vc_init()
3465 vc->vc_size_row = cols << 1; in vc_init()
3466 vc->vc_screenbuf_size = vc->vc_rows * vc->vc_size_row; in vc_init()
3469 vc->vc_pos = vc->vc_origin; in vc_init()
3472 vc->vc_palette[k++] = default_red[j] ; in vc_init()
3473 vc->vc_palette[k++] = default_grn[j] ; in vc_init()
3474 vc->vc_palette[k++] = default_blu[j] ; in vc_init()
3476 vc->vc_def_color = default_color; in vc_init()
3477 vc->vc_ulcolor = default_underline_color; in vc_init()
3478 vc->vc_itcolor = default_italic_color; in vc_init()
3479 vc->vc_halfcolor = 0x08; /* grey */ in vc_init()
3480 init_waitqueue_head(&vc->paste_wait); in vc_init()
3487 * the appropriate escape-sequence.
3500 display_desc = conswitchp->con_startup(); in con_init()
3510 if (con_driver->con == NULL) { in con_init()
3511 con_driver->con = conswitchp; in con_init()
3512 con_driver->desc = display_desc; in con_init()
3513 con_driver->flag = CON_DRIVER_FLAG_INIT; in con_init()
3514 con_driver->first = 0; in con_init()
3515 con_driver->last = MAX_NR_CONSOLES - 1; in con_init()
3531 tty_port_init(&vc->port); in con_init()
3533 /* Assuming vc->vc_{cols,rows,screenbuf_size} are sane here. */ in con_init()
3534 vc->vc_screenbuf = kzalloc(vc->vc_screenbuf_size, GFP_NOWAIT); in con_init()
3535 vc_init(vc, vc->vc_rows, vc->vc_cols, in con_init()
3536 currcons || !vc->vc_sw->con_save_screen); in con_init()
3542 gotoxy(vc, vc->state.x, vc->state.y); in con_init()
3546 vc->vc_can_do_color ? "colour" : "mono", in con_init()
3547 display_desc, vc->vc_cols, vc->vc_rows); in con_init()
3615 console_driver->name = "tty"; in vty_init()
3616 console_driver->name_base = 1; in vty_init()
3617 console_driver->major = TTY_MAJOR; in vty_init()
3618 console_driver->minor_start = 1; in vty_init()
3619 console_driver->type = TTY_DRIVER_TYPE_CONSOLE; in vty_init()
3620 console_driver->init_termios = tty_std_termios; in vty_init()
3622 console_driver->init_termios.c_iflag |= IUTF8; in vty_init()
3623 console_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_RESET_TERMIOS; in vty_init()
3642 struct module *owner = csw->owner; in do_bind_con_driver()
3645 int i, j = -1, k = -1, retval = -ENODEV; in do_bind_con_driver()
3648 return -ENODEV; in do_bind_con_driver()
3656 if (con_driver->con == csw) { in do_bind_con_driver()
3657 desc = con_driver->desc; in do_bind_con_driver()
3666 if (!(con_driver->flag & CON_DRIVER_FLAG_INIT)) { in do_bind_con_driver()
3667 csw->con_startup(); in do_bind_con_driver()
3668 con_driver->flag |= CON_DRIVER_FLAG_INIT; in do_bind_con_driver()
3673 module_put(conswitchp->owner); in do_bind_con_driver()
3679 first = max(first, con_driver->first); in do_bind_con_driver()
3680 last = min(last, con_driver->last); in do_bind_con_driver()
3687 module_put(con_driver_map[i]->owner); in do_bind_con_driver()
3691 if (!vc || !vc->vc_sw) in do_bind_con_driver()
3701 old_was_color = vc->vc_can_do_color; in do_bind_con_driver()
3702 vc->vc_sw->con_deinit(vc); in do_bind_con_driver()
3703 vc->vc_origin = (unsigned long)vc->vc_screenbuf; in do_bind_con_driver()
3708 /* If the console changed between mono <-> color, then in do_bind_con_driver()
3712 if (old_was_color != vc->vc_can_do_color) in do_bind_con_driver()
3718 pr_cont("consoles %d-%d ", first + 1, last + 1); in do_bind_con_driver()
3723 vc->vc_can_do_color ? "colour" : "mono", in do_bind_con_driver()
3724 desc, vc->vc_cols, vc->vc_rows); in do_bind_con_driver()
3744 struct module *owner = csw->owner; in do_unbind_con_driver()
3747 int i, retval = -ENODEV; in do_unbind_con_driver()
3750 return -ENODEV; in do_unbind_con_driver()
3758 if (con_driver->con == csw && in do_unbind_con_driver()
3759 con_driver->flag & CON_DRIVER_FLAG_MODULE) { in do_unbind_con_driver()
3768 retval = -ENODEV; in do_unbind_con_driver()
3774 if (con_back->con && con_back->con != csw) { in do_unbind_con_driver()
3775 defcsw = con_back->con; in do_unbind_con_driver()
3787 first = max(first, con_driver->first); in do_unbind_con_driver()
3788 last = min(last, con_driver->last); in do_unbind_con_driver()
3792 module_put(csw->owner); in do_unbind_con_driver()
3800 defcsw->con_startup(); in do_unbind_con_driver()
3801 con_back->flag |= CON_DRIVER_FLAG_INIT; in do_unbind_con_driver()
3810 con_driver->flag &= ~CON_DRIVER_FLAG_INIT; in do_unbind_con_driver()
3824 int i, more = 1, first = -1, last = -1, deflt = 0; in vt_bind()
3826 if (!con->con || !(con->flag & CON_DRIVER_FLAG_MODULE)) in vt_bind()
3829 csw = con->con; in vt_bind()
3834 if (con->con && !(con->flag & CON_DRIVER_FLAG_MODULE)) { in vt_bind()
3835 defcsw = con->con; in vt_bind()
3846 for (i = con->first; i <= con->last; i++) { in vt_bind()
3848 if (first == -1) in vt_bind()
3852 } else if (first != -1) in vt_bind()
3856 if (first == 0 && last == MAX_NR_CONSOLES -1) in vt_bind()
3859 if (first != -1) in vt_bind()
3862 first = -1; in vt_bind()
3863 last = -1; in vt_bind()
3874 int i, more = 1, first = -1, last = -1, deflt = 0; in vt_unbind()
3877 if (!con->con || !(con->flag & CON_DRIVER_FLAG_MODULE)) in vt_unbind()
3880 csw = con->con; in vt_unbind()
3885 for (i = con->first; i <= con->last; i++) { in vt_unbind()
3887 if (first == -1) in vt_unbind()
3891 } else if (first != -1) in vt_unbind()
3895 if (first == 0 && last == MAX_NR_CONSOLES -1) in vt_unbind()
3898 if (first != -1) { in vt_unbind()
3904 first = -1; in vt_unbind()
3905 last = -1; in vt_unbind()
3948 bind = con_is_bound(con->con); in show_bind()
3960 (con->flag & CON_DRIVER_FLAG_MODULE) ? "(M)" : "(S)", in show_name()
3961 con->desc); in show_name()
3978 con->flag |= CON_DRIVER_FLAG_ATTR; in vtconsole_init_device()
3984 con->flag &= ~CON_DRIVER_FLAG_ATTR; in vtconsole_deinit_device()
3988 * con_is_bound - checks if driver is bound to the console
4014 * con_is_visible - checks whether the current console is visible
4023 return *vc->vc_display_fg == vc; in con_is_visible()
4028 * con_debug_enter - prepare the console for the kernel debugger
4046 saved_vc_mode = vc->vc_mode; in con_debug_enter()
4048 vc->vc_mode = KD_TEXT; in con_debug_enter()
4050 if (vc->vc_sw->con_debug_enter) in con_debug_enter()
4051 ret = vc->vc_sw->con_debug_enter(vc); in con_debug_enter()
4054 if (vc->vc_rows < 999) { in con_debug_enter()
4063 snprintf(lns, 4, "%i", vc->vc_rows); in con_debug_enter()
4067 if (vc->vc_cols < 999) { in con_debug_enter()
4076 snprintf(cols, 4, "%i", vc->vc_cols); in con_debug_enter()
4086 * con_debug_leave - restore console state
4104 vc_cons[fg_console].d->vc_mode = saved_vc_mode; in con_debug_leave()
4107 if (vc->vc_sw->con_debug_leave) in con_debug_leave()
4108 ret = vc->vc_sw->con_debug_leave(vc); in con_debug_leave()
4115 struct module *owner = csw->owner; in do_register_con_driver()
4123 return -ENODEV; in do_register_con_driver()
4129 if (con_driver->con == csw) { in do_register_con_driver()
4130 retval = -EBUSY; in do_register_con_driver()
4135 desc = csw->con_startup(); in do_register_con_driver()
4137 retval = -ENODEV; in do_register_con_driver()
4141 retval = -EINVAL; in do_register_con_driver()
4146 if (con_driver->con == NULL && in do_register_con_driver()
4147 !(con_driver->flag & CON_DRIVER_FLAG_ZOMBIE)) { in do_register_con_driver()
4148 con_driver->con = csw; in do_register_con_driver()
4149 con_driver->desc = desc; in do_register_con_driver()
4150 con_driver->node = i; in do_register_con_driver()
4151 con_driver->flag = CON_DRIVER_FLAG_MODULE | in do_register_con_driver()
4153 con_driver->first = first; in do_register_con_driver()
4154 con_driver->last = last; in do_register_con_driver()
4163 con_driver->dev = in do_register_con_driver()
4165 MKDEV(0, con_driver->node), in do_register_con_driver()
4167 "vtcon%i", con_driver->node); in do_register_con_driver()
4168 if (IS_ERR(con_driver->dev)) { in do_register_con_driver()
4170 con_driver->desc, PTR_ERR(con_driver->dev)); in do_register_con_driver()
4171 con_driver->dev = NULL; in do_register_con_driver()
4183 * do_unregister_con_driver - unregister console driver from console layer
4199 return -EBUSY; in do_unregister_con_driver()
4202 return -EINVAL; in do_unregister_con_driver()
4207 if (con_driver->con == csw) { in do_unregister_con_driver()
4218 con_driver->con = NULL; in do_unregister_con_driver()
4219 con_driver->flag = CON_DRIVER_FLAG_ZOMBIE; in do_unregister_con_driver()
4226 return -ENODEV; in do_unregister_con_driver()
4239 if (!(con_driver->flag & CON_DRIVER_FLAG_ZOMBIE)) in con_driver_unregister_callback()
4245 device_destroy(vtconsole_class, MKDEV(0, con_driver->node)); in con_driver_unregister_callback()
4249 if (WARN_ON_ONCE(con_driver->con)) in con_driver_unregister_callback()
4250 con_driver->con = NULL; in con_driver_unregister_callback()
4251 con_driver->desc = NULL; in con_driver_unregister_callback()
4252 con_driver->dev = NULL; in con_driver_unregister_callback()
4253 con_driver->node = 0; in con_driver_unregister_callback()
4254 WARN_ON_ONCE(con_driver->flag != CON_DRIVER_FLAG_ZOMBIE); in con_driver_unregister_callback()
4255 con_driver->flag = 0; in con_driver_unregister_callback()
4256 con_driver->first = 0; in con_driver_unregister_callback()
4257 con_driver->last = 0; in con_driver_unregister_callback()
4280 if (err == -EBUSY) in do_take_over_console()
4316 if (con->con && !con->dev) { in vtconsole_class_init()
4317 con->dev = in vtconsole_class_init()
4319 MKDEV(0, con->node), in vtconsole_class_init()
4321 "vtcon%i", con->node); in vtconsole_class_init()
4323 if (IS_ERR(con->dev)) { in vtconsole_class_init()
4325 con->desc, PTR_ERR(con->dev)); in vtconsole_class_init()
4326 con->dev = NULL; in vtconsole_class_init()
4348 return -EFAULT; in set_vesa_blanking()
4366 vc->vc_sw->con_blank(vc, vesa_blank_mode + 1, 0); in do_blank_screen()
4375 vc->vc_sw->con_blank(vc, -1, 1); in do_blank_screen()
4385 if (vc->vc_mode != KD_TEXT) { in do_blank_screen()
4396 i = vc->vc_sw->con_blank(vc, vesa_off_interval ? 1 : (vesa_blank_mode + 1), 0); in do_blank_screen()
4408 vt_event_post(VT_EVENT_BLANK, vc->vc_num, vc->vc_num); in do_blank_screen()
4438 if (vc->vc_mode != KD_TEXT) in do_unblank_screen()
4447 if (vc->vc_sw->con_blank(vc, 0, leaving_gfx)) in do_unblank_screen()
4448 /* Low-level driver cannot restore -> do it ourselves */ in do_unblank_screen()
4454 vt_event_post(VT_EVENT_UNBLANK, vc->vc_num, vc->vc_num); in do_unblank_screen()
4488 * function. --BenH. in poke_blanked_console()
4498 if (ignore_poke || !vc_cons[fg_console].d || vc_cons[fg_console].d->vc_mode == KD_GRAPHICS) in poke_blanked_console()
4516 if (vc->vc_mode != KD_GRAPHICS && vc->vc_sw->con_set_palette) in set_palette()
4517 vc->vc_sw->con_set_palette(vc, color_table); in set_palette()
4531 return -EFAULT; in con_set_cmap()
4543 vc_cons[i].d->vc_palette[k++] = default_red[j]; in con_set_cmap()
4544 vc_cons[i].d->vc_palette[k++] = default_grn[j]; in con_set_cmap()
4545 vc_cons[i].d->vc_palette[k++] = default_blu[j]; in con_set_cmap()
4568 return -EFAULT; in con_get_cmap()
4577 vc->vc_palette[k++] = default_red[j]; in reset_palette()
4578 vc->vc_palette[k++] = default_grn[j]; in reset_palette()
4579 vc->vc_palette[k++] = default_blu[j]; in reset_palette()
4589 * depending on width) reserved for each character which is kinda wasty, but
4591 * is up to the actual low-level console-driver convert data into its favorite
4592 * format (maybe we should add a `fontoffset' field to the `display'
4602 int rc = -EINVAL; in con_font_get()
4605 if (op->data) { in con_font_get()
4608 return -ENOMEM; in con_font_get()
4613 if (vc->vc_mode != KD_TEXT) in con_font_get()
4614 rc = -EINVAL; in con_font_get()
4615 else if (vc->vc_sw->con_font_get) in con_font_get()
4616 rc = vc->vc_sw->con_font_get(vc, &font); in con_font_get()
4618 rc = -ENOSYS; in con_font_get()
4624 c = (font.width+7)/8 * 32 * font.charcount; in con_font_get()
4626 if (op->data && font.charcount > op->charcount) in con_font_get()
4627 rc = -ENOSPC; in con_font_get()
4628 if (font.width > op->width || font.height > op->height) in con_font_get()
4629 rc = -ENOSPC; in con_font_get()
4633 op->height = font.height; in con_font_get()
4634 op->width = font.width; in con_font_get()
4635 op->charcount = font.charcount; in con_font_get()
4637 if (op->data && copy_to_user(op->data, font.data, c)) in con_font_get()
4638 rc = -EFAULT; in con_font_get()
4648 int rc = -EINVAL; in con_font_set()
4651 if (vc->vc_mode != KD_TEXT) in con_font_set()
4652 return -EINVAL; in con_font_set()
4653 if (!op->data) in con_font_set()
4654 return -EINVAL; in con_font_set()
4655 if (op->charcount > 512) in con_font_set()
4656 return -EINVAL; in con_font_set()
4657 if (op->width <= 0 || op->width > 32 || !op->height || op->height > 32) in con_font_set()
4658 return -EINVAL; in con_font_set()
4659 size = (op->width+7)/8 * 32 * op->charcount; in con_font_set()
4661 return -ENOSPC; in con_font_set()
4663 font.data = memdup_user(op->data, size); in con_font_set()
4667 font.charcount = op->charcount; in con_font_set()
4668 font.width = op->width; in con_font_set()
4669 font.height = op->height; in con_font_set()
4672 if (vc->vc_mode != KD_TEXT) in con_font_set()
4673 rc = -EINVAL; in con_font_set()
4674 else if (vc->vc_sw->con_font_set) { in con_font_set()
4677 rc = vc->vc_sw->con_font_set(vc, &font, op->flags); in con_font_set()
4679 rc = -ENOSYS; in con_font_set()
4687 struct console_font font = {.width = op->width, .height = op->height}; in con_font_default()
4693 if (!op->data) in con_font_default()
4695 else if (strncpy_from_user(name, op->data, MAX_FONT_NAME - 1) < 0) in con_font_default()
4696 return -EFAULT; in con_font_default()
4698 name[MAX_FONT_NAME - 1] = 0; in con_font_default()
4701 if (vc->vc_mode != KD_TEXT) { in con_font_default()
4703 return -EINVAL; in con_font_default()
4705 if (vc->vc_sw->con_font_default) { in con_font_default()
4708 rc = vc->vc_sw->con_font_default(vc, &font, s); in con_font_default()
4710 rc = -ENOSYS; in con_font_default()
4713 op->width = font.width; in con_font_default()
4714 op->height = font.height; in con_font_default()
4721 switch (op->op) { in con_font_op()
4730 return -EINVAL; in con_font_op()
4732 return -ENOSYS; in con_font_op()
4745 if (w & vc->vc_hi_font_mask) in screen_glyph()
4756 return uniscr->lines[n / vc->vc_cols][n % vc->vc_cols]; in screen_glyph_unicode()
4761 /* used by vcs - note the word offset */
4771 xy[0] = min(vc->state.x, 0xFFu); in getconsxy()
4772 xy[1] = min(vc->state.y, 0xFFu); in getconsxy()
4784 if ((unsigned long)org == vc->vc_pos && softcursor_original != -1) in vcs_scr_readw()
4792 if ((unsigned long)org == vc->vc_pos) { in vcs_scr_writew()
4793 softcursor_original = -1; in vcs_scr_writew()
4807 ptrdiff_t scr_end = (void *)c->vc_scr_end - base; in vc_scrolldelta_helper()
4808 ptrdiff_t vorigin = (void *)c->vc_visible_origin - base; in vc_scrolldelta_helper()
4809 ptrdiff_t origin = (void *)c->vc_origin - base; in vc_scrolldelta_helper()
4810 int margin = c->vc_size_row * 4; in vc_scrolldelta_helper()
4815 c->vc_visible_origin = c->vc_origin; in vc_scrolldelta_helper()
4822 wrap = rolled_over + c->vc_size_row; in vc_scrolldelta_helper()
4828 from_off = (vorigin - from + wrap) % wrap + lines * c->vc_size_row; in vc_scrolldelta_helper()
4829 avail = (origin - from + wrap) % wrap; in vc_scrolldelta_helper()
4836 if (from_off > avail - margin) in vc_scrolldelta_helper()
4839 c->vc_visible_origin = ubase + (from + from_off) % wrap; in vc_scrolldelta_helper()