Lines Matching +full:display +full:- +full:height +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
159 #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 memcpy(&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()
1055 /* ++Geert: vc->vc_sw->con_init determines console size */ in visual_init()
1056 if (vc->vc_sw) in visual_init()
1057 module_put(vc->vc_sw->owner); in visual_init()
1058 vc->vc_sw = conswitchp; in visual_init()
1061 vc->vc_sw = con_driver_map[num]; in visual_init()
1063 __module_get(vc->vc_sw->owner); in visual_init()
1064 vc->vc_num = num; in visual_init()
1065 vc->vc_display_fg = &master_display_fg; in visual_init()
1066 if (vc->uni_pagedict_loc) in visual_init()
1068 vc->uni_pagedict_loc = &vc->uni_pagedict; in visual_init()
1069 vc->uni_pagedict = NULL; in visual_init()
1070 vc->vc_hi_font_mask = 0; in visual_init()
1071 vc->vc_complement_mask = 0; in visual_init()
1072 vc->vc_can_do_color = 0; in visual_init()
1073 vc->vc_cur_blink_ms = DEFAULT_CURSOR_BLINK_MS; in visual_init()
1074 vc->vc_sw->con_init(vc, init); in visual_init()
1075 if (!vc->vc_complement_mask) in visual_init()
1076 vc->vc_complement_mask = vc->vc_can_do_color ? 0x7700 : 0x0800; in visual_init()
1077 vc->vc_s_complement_mask = vc->vc_complement_mask; in visual_init()
1078 vc->vc_size_row = vc->vc_cols << 1; in visual_init()
1079 vc->vc_screenbuf_size = vc->vc_rows * vc->vc_size_row; in visual_init()
1085 vc->vc_sw->con_deinit(vc); in visual_deinit()
1086 module_put(vc->vc_sw->owner); in visual_deinit()
1117 return -ENXIO; in vc_allocate()
1126 point is still up-to-date and the comment still has its value in vc_allocate()
1127 even if only as a historical artifact. --mj, July 1998 */ in vc_allocate()
1130 return -ENOMEM; in vc_allocate()
1133 tty_port_init(&vc->port); in vc_allocate()
1134 vc->port.ops = &vc_port_ops; in vc_allocate()
1139 if (!*vc->uni_pagedict_loc) in vc_allocate()
1142 err = -EINVAL; in vc_allocate()
1143 if (vc->vc_cols > VC_MAXCOL || vc->vc_rows > VC_MAXROW || in vc_allocate()
1144 vc->vc_screenbuf_size > KMALLOC_MAX_SIZE || !vc->vc_screenbuf_size) in vc_allocate()
1146 err = -ENOMEM; in vc_allocate()
1147 vc->vc_screenbuf = kzalloc(vc->vc_screenbuf_size, GFP_KERNEL); in vc_allocate()
1148 if (!vc->vc_screenbuf) in vc_allocate()
1153 if (global_cursor_default == -1) in vc_allocate()
1156 vc_init(vc, vc->vc_rows, vc->vc_cols, 1); in vc_allocate()
1168 static inline int resize_screen(struct vc_data *vc, int width, int height, in resize_screen() argument
1171 /* Resizes the resolution of the display adapater */ in resize_screen()
1174 if (vc->vc_sw->con_resize) in resize_screen()
1175 err = vc->vc_sw->con_resize(vc, width, height, user); in resize_screen()
1181 * vc_do_resize - resizing method for the tty
1209 return -ENXIO; in vc_do_resize()
1211 user = vc->vc_resize_user; in vc_do_resize()
1212 vc->vc_resize_user = 0; in vc_do_resize()
1215 return -EINVAL; in vc_do_resize()
1217 new_cols = (cols ? cols : vc->vc_cols); in vc_do_resize()
1218 new_rows = (lines ? lines : vc->vc_rows); in vc_do_resize()
1222 if (new_cols == vc->vc_cols && new_rows == vc->vc_rows) { in vc_do_resize()
1227 * yres/xres equal to a number non-multiple of vc_font.height in vc_do_resize()
1229 * vc_font.height and yres/xres. in vc_do_resize()
1232 * if above, and this causes the fbcon_display->vrows to become in vc_do_resize()
1233 * negative and it eventually leads to out-of-bound in vc_do_resize()
1243 return -EINVAL; in vc_do_resize()
1246 return -ENOMEM; in vc_do_resize()
1252 return -ENOMEM; in vc_do_resize()
1259 old_rows = vc->vc_rows; in vc_do_resize()
1260 old_row_size = vc->vc_size_row; in vc_do_resize()
1269 vc->vc_rows = new_rows; in vc_do_resize()
1270 vc->vc_cols = new_cols; in vc_do_resize()
1271 vc->vc_size_row = new_row_size; in vc_do_resize()
1272 vc->vc_screenbuf_size = new_screen_size; in vc_do_resize()
1275 rrem = new_row_size - rlth; in vc_do_resize()
1276 old_origin = vc->vc_origin; in vc_do_resize()
1280 if (vc->state.y > new_rows) { in vc_do_resize()
1281 if (old_rows - vc->state.y < new_rows) { in vc_do_resize()
1286 first_copied_row = (old_rows - new_rows); in vc_do_resize()
1292 first_copied_row = (vc->state.y - new_rows/2); in vc_do_resize()
1311 vc->vc_video_erase_char, rrem); in vc_do_resize()
1316 scr_memsetw((void *)new_origin, vc->vc_video_erase_char, in vc_do_resize()
1317 new_scr_end - new_origin); in vc_do_resize()
1318 oldscreen = vc->vc_screenbuf; in vc_do_resize()
1319 vc->vc_screenbuf = newscreen; in vc_do_resize()
1320 vc->vc_screenbuf_size = new_screen_size; in vc_do_resize()
1325 vc->vc_top = 0; in vc_do_resize()
1326 vc->vc_bottom = vc->vc_rows; in vc_do_resize()
1327 gotoxy(vc, vc->state.x, vc->state.y); in vc_do_resize()
1335 ws.ws_row = vc->vc_rows; in vc_do_resize()
1336 ws.ws_col = vc->vc_cols; in vc_do_resize()
1337 ws.ws_ypixel = vc->vc_scan_lines; in vc_do_resize()
1343 vt_event_post(VT_EVENT_RESIZE, vc->vc_num, vc->vc_num); in vc_do_resize()
1349 * vc_resize - resize a VT
1357 * vc->port.tty
1362 return vc_do_resize(vc->port.tty, vc, cols, rows); in vc_resize()
1366 * vt_resize - resize a VT
1379 struct vc_data *vc = tty->driver_data; in vt_resize()
1383 ret = vc_do_resize(tty, vc, ws->ws_col, ws->ws_row); in vt_resize()
1402 put_pid(vc->vt_pid); in vc_deallocate()
1404 kfree(vc->vc_screenbuf); in vc_deallocate()
1416 #define set_kbd(vc, x) vt_set_kbd_mode_bit((vc)->vc_num, (x))
1417 #define clr_kbd(vc, x) vt_clr_kbd_mode_bit((vc)->vc_num, (x))
1418 #define is_kbd(vc, x) vt_get_kbd_mode_bit((vc)->vc_num, (x))
1457 vc->state.x = 0; in gotoxy()
1459 if (new_x >= vc->vc_cols) in gotoxy()
1460 vc->state.x = vc->vc_cols - 1; in gotoxy()
1462 vc->state.x = new_x; in gotoxy()
1465 if (vc->vc_decom) { in gotoxy()
1466 min_y = vc->vc_top; in gotoxy()
1467 max_y = vc->vc_bottom; in gotoxy()
1470 max_y = vc->vc_rows; in gotoxy()
1473 vc->state.y = min_y; in gotoxy()
1475 vc->state.y = max_y - 1; in gotoxy()
1477 vc->state.y = new_y; in gotoxy()
1478 vc->vc_pos = vc->vc_origin + vc->state.y * vc->vc_size_row + in gotoxy()
1479 (vc->state.x << 1); in gotoxy()
1480 vc->vc_need_wrap = 0; in gotoxy()
1486 gotoxy(vc, new_x, vc->vc_decom ? (vc->vc_top + new_y) : new_y); in gotoxay()
1491 scrolldelta(-(vc->vc_rows / 2)); in scrollback()
1497 lines = vc->vc_rows / 2; in scrollfront()
1506 if (vc->state.y + 1 == vc->vc_bottom) in lf()
1507 con_scroll(vc, vc->vc_top, vc->vc_bottom, SM_UP, 1); in lf()
1508 else if (vc->state.y < vc->vc_rows - 1) { in lf()
1509 vc->state.y++; in lf()
1510 vc->vc_pos += vc->vc_size_row; in lf()
1512 vc->vc_need_wrap = 0; in lf()
1521 if (vc->state.y == vc->vc_top) in ri()
1522 con_scroll(vc, vc->vc_top, vc->vc_bottom, SM_DOWN, 1); in ri()
1523 else if (vc->state.y > 0) { in ri()
1524 vc->state.y--; in ri()
1525 vc->vc_pos -= vc->vc_size_row; in ri()
1527 vc->vc_need_wrap = 0; in ri()
1532 vc->vc_pos -= vc->state.x << 1; in cr()
1533 vc->vc_need_wrap = vc->state.x = 0; in cr()
1539 if (vc->state.x) { in bs()
1540 vc->vc_pos -= 2; in bs()
1541 vc->state.x--; in bs()
1542 vc->vc_need_wrap = 0; in bs()
1558 case 0: /* erase from cursor to end of display */ in csi_J()
1559 vc_uniscr_clear_line(vc, vc->state.x, in csi_J()
1560 vc->vc_cols - vc->state.x); in csi_J()
1561 vc_uniscr_clear_lines(vc, vc->state.y + 1, in csi_J()
1562 vc->vc_rows - vc->state.y - 1); in csi_J()
1563 count = (vc->vc_scr_end - vc->vc_pos) >> 1; in csi_J()
1564 start = (unsigned short *)vc->vc_pos; in csi_J()
1567 vc_uniscr_clear_line(vc, 0, vc->state.x + 1); in csi_J()
1568 vc_uniscr_clear_lines(vc, 0, vc->state.y); in csi_J()
1569 count = ((vc->vc_pos - vc->vc_origin) >> 1) + 1; in csi_J()
1570 start = (unsigned short *)vc->vc_origin; in csi_J()
1575 case 2: /* erase whole display */ in csi_J()
1576 vc_uniscr_clear_lines(vc, 0, vc->vc_rows); in csi_J()
1577 count = vc->vc_cols * vc->vc_rows; in csi_J()
1578 start = (unsigned short *)vc->vc_origin; in csi_J()
1583 scr_memsetw(start, vc->vc_video_erase_char, 2 * count); in csi_J()
1586 vc->vc_need_wrap = 0; in csi_J()
1592 unsigned short *start = (unsigned short *)vc->vc_pos; in csi_K()
1598 count = vc->vc_cols - vc->state.x; in csi_K()
1601 offset = -vc->state.x; in csi_K()
1602 count = vc->state.x + 1; in csi_K()
1605 offset = -vc->state.x; in csi_K()
1606 count = vc->vc_cols; in csi_K()
1611 vc_uniscr_clear_line(vc, vc->state.x + offset, count); in csi_K()
1612 scr_memsetw(start + offset, vc->vc_video_erase_char, 2 * count); in csi_K()
1613 vc->vc_need_wrap = 0; in csi_K()
1626 count = min(vpar, vc->vc_cols - vc->state.x); in csi_X()
1628 vc_uniscr_clear_line(vc, vc->state.x, count); in csi_X()
1629 scr_memsetw((unsigned short *)vc->vc_pos, vc->vc_video_erase_char, 2 * count); in csi_X()
1631 vc->vc_sw->con_clear(vc, vc->state.y, vc->state.x, 1, count); in csi_X()
1632 vc->vc_need_wrap = 0; in csi_X()
1637 vc->state.intensity = VCI_NORMAL; in default_attr()
1638 vc->state.italic = false; in default_attr()
1639 vc->state.underline = false; in default_attr()
1640 vc->state.reverse = false; in default_attr()
1641 vc->state.blink = false; in default_attr()
1642 vc->state.color = vc->vc_def_color; in default_attr()
1650 c->r = i&1 ? 0xaa : 0x00; in rgb_from_256()
1651 c->g = i&2 ? 0xaa : 0x00; in rgb_from_256()
1652 c->b = i&4 ? 0xaa : 0x00; in rgb_from_256()
1654 c->r = i&1 ? 0xff : 0x55; in rgb_from_256()
1655 c->g = i&2 ? 0xff : 0x55; in rgb_from_256()
1656 c->b = i&4 ? 0xff : 0x55; in rgb_from_256()
1658 c->r = (i - 16) / 36 * 85 / 2; in rgb_from_256()
1659 c->g = (i - 16) / 6 % 6 * 85 / 2; in rgb_from_256()
1660 c->b = (i - 16) % 6 * 85 / 2; in rgb_from_256()
1662 c->r = c->g = c->b = i * 10 - 2312; in rgb_from_256()
1667 u8 hue = 0, max = max3(c->r, c->g, c->b); in rgb_foreground()
1669 if (c->r > max / 2) in rgb_foreground()
1671 if (c->g > max / 2) in rgb_foreground()
1673 if (c->b > max / 2) in rgb_foreground()
1678 vc->state.intensity = VCI_BOLD; in rgb_foreground()
1680 vc->state.intensity = VCI_BOLD; in rgb_foreground()
1682 vc->state.intensity = VCI_NORMAL; in rgb_foreground()
1684 vc->state.color = (vc->state.color & 0xf0) | hue; in rgb_foreground()
1690 vc->state.color = (vc->state.color & 0x0f) in rgb_background()
1691 | (c->r&0x80) >> 1 | (c->g&0x80) >> 2 | (c->b&0x80) >> 3; in rgb_background()
1709 if (i > vc->vc_npar) in vc_t416_color()
1712 if (vc->vc_par[i] == 5 && i + 1 <= vc->vc_npar) { in vc_t416_color()
1715 rgb_from_256(vc->vc_par[i], &c); in vc_t416_color()
1716 } else if (vc->vc_par[i] == 2 && i + 3 <= vc->vc_npar) { in vc_t416_color()
1718 c.r = vc->vc_par[i + 1]; in vc_t416_color()
1719 c.g = vc->vc_par[i + 2]; in vc_t416_color()
1720 c.b = vc->vc_par[i + 3]; in vc_t416_color()
1735 for (i = 0; i <= vc->vc_npar; i++) in csi_m()
1736 switch (vc->vc_par[i]) { in csi_m()
1741 vc->state.intensity = VCI_BOLD; in csi_m()
1744 vc->state.intensity = VCI_HALF_BRIGHT; in csi_m()
1747 vc->state.italic = true; in csi_m()
1755 vc->state.underline = true; in csi_m()
1758 vc->state.blink = true; in csi_m()
1761 vc->state.reverse = true; in csi_m()
1763 case 10: /* ANSI X3.64-1979 (SCO-ish?) in csi_m()
1764 * Select primary font, don't display control chars if in csi_m()
1767 vc->vc_translate = set_translate(vc->state.Gx_charset[vc->state.charset], vc); in csi_m()
1768 vc->vc_disp_ctrl = 0; in csi_m()
1769 vc->vc_toggle_meta = 0; in csi_m()
1771 case 11: /* ANSI X3.64-1979 (SCO-ish?) in csi_m()
1772 * Select first alternate font, lets chars < 32 be in csi_m()
1773 * displayed as ROM chars. in csi_m()
1775 vc->vc_translate = set_translate(IBMPC_MAP, vc); in csi_m()
1776 vc->vc_disp_ctrl = 1; in csi_m()
1777 vc->vc_toggle_meta = 0; in csi_m()
1779 case 12: /* ANSI X3.64-1979 (SCO-ish?) in csi_m()
1783 vc->vc_translate = set_translate(IBMPC_MAP, vc); in csi_m()
1784 vc->vc_disp_ctrl = 1; in csi_m()
1785 vc->vc_toggle_meta = 1; in csi_m()
1788 vc->state.intensity = VCI_NORMAL; in csi_m()
1791 vc->state.italic = false; in csi_m()
1794 vc->state.underline = false; in csi_m()
1797 vc->state.blink = false; in csi_m()
1800 vc->state.reverse = false; in csi_m()
1809 vc->state.color = (vc->vc_def_color & 0x0f) | in csi_m()
1810 (vc->state.color & 0xf0); in csi_m()
1813 vc->state.color = (vc->vc_def_color & 0xf0) | in csi_m()
1814 (vc->state.color & 0x0f); in csi_m()
1817 if (vc->vc_par[i] >= 90 && vc->vc_par[i] <= 107) { in csi_m()
1818 if (vc->vc_par[i] < 100) in csi_m()
1819 vc->state.intensity = VCI_BOLD; in csi_m()
1820 vc->vc_par[i] -= 60; in csi_m()
1822 if (vc->vc_par[i] >= 30 && vc->vc_par[i] <= 37) in csi_m()
1823 vc->state.color = color_table[vc->vc_par[i] - 30] in csi_m()
1824 | (vc->state.color & 0xf0); in csi_m()
1825 else if (vc->vc_par[i] >= 40 && vc->vc_par[i] <= 47) in csi_m()
1826 vc->state.color = (color_table[vc->vc_par[i] - 40] << 4) in csi_m()
1827 | (vc->state.color & 0x0f); in csi_m()
1844 len = sprintf(buf, "\033[%d;%dR", vc->state.y + in cursor_report()
1845 (vc->vc_decom ? vc->vc_top + 1 : 1), in cursor_report()
1846 vc->state.x + 1); in cursor_report()
1847 respond_string(buf, len, tty->port); in cursor_report()
1854 respond_string(teminal_ok, strlen(teminal_ok), tty->port); in status_report()
1859 /* terminal answer to an ESC-Z or csi0c query. */ in respond_ID()
1862 respond_string(vt102_id, strlen(vt102_id), tty->port); in respond_ID()
1872 respond_string(buf, len, tty->port); in mouse_report()
1878 return vc_cons[fg_console].d->vc_report_mouse; in mouse_reporting()
1886 for (i = 0; i <= vc->vc_npar; i++) in set_mode()
1887 if (vc->vc_priv == EPdec) { in set_mode()
1888 switch(vc->vc_par[i]) { /* DEC private modes set/reset */ in set_mode()
1897 vc_resize(deccolm ? 132 : 80, vc->vc_rows); in set_mode()
1903 if (vc->vc_decscnm != on_off) { in set_mode()
1904 vc->vc_decscnm = on_off; in set_mode()
1906 vc->vc_screenbuf_size, in set_mode()
1912 vc->vc_decom = on_off; in set_mode()
1916 vc->vc_decawm = on_off; in set_mode()
1925 vc->vc_report_mouse = on_off ? 1 : 0; in set_mode()
1928 vc->vc_deccm = on_off; in set_mode()
1931 vc->vc_report_mouse = on_off ? 2 : 0; in set_mode()
1935 switch(vc->vc_par[i]) { /* ANSI modes set/reset */ in set_mode()
1936 case 3: /* Monitor (display ctrls) */ in set_mode()
1937 vc->vc_disp_ctrl = on_off; in set_mode()
1940 vc->vc_decim = on_off; in set_mode()
1955 switch (vc->vc_par[0]) { in setterm_command()
1957 if (vc->vc_can_do_color && vc->vc_par[1] < 16) { in setterm_command()
1958 vc->vc_ulcolor = color_table[vc->vc_par[1]]; in setterm_command()
1959 if (vc->state.underline) in setterm_command()
1964 if (vc->vc_can_do_color && vc->vc_par[1] < 16) { in setterm_command()
1965 vc->vc_halfcolor = color_table[vc->vc_par[1]]; in setterm_command()
1966 if (vc->state.intensity == VCI_HALF_BRIGHT) in setterm_command()
1971 vc->vc_def_color = vc->vc_attr; in setterm_command()
1972 if (vc->vc_hi_font_mask == 0x100) in setterm_command()
1973 vc->vc_def_color >>= 1; in setterm_command()
1978 blankinterval = min(vc->vc_par[1], 60U) * 60; in setterm_command()
1982 if (vc->vc_npar >= 1) in setterm_command()
1983 vc->vc_bell_pitch = vc->vc_par[1]; in setterm_command()
1985 vc->vc_bell_pitch = DEFAULT_BELL_PITCH; in setterm_command()
1988 if (vc->vc_npar >= 1) in setterm_command()
1989 vc->vc_bell_duration = (vc->vc_par[1] < 2000) ? in setterm_command()
1990 msecs_to_jiffies(vc->vc_par[1]) : 0; in setterm_command()
1992 vc->vc_bell_duration = DEFAULT_BELL_DURATION; in setterm_command()
1995 if (vc->vc_par[1] >= 1 && vc_cons_allocated(vc->vc_par[1] - 1)) in setterm_command()
1996 set_console(vc->vc_par[1] - 1); in setterm_command()
2002 vesa_off_interval = min(vc->vc_par[1], 60U) * 60 * HZ; in setterm_command()
2008 if (vc->vc_npar >= 1 && vc->vc_par[1] >= 50 && in setterm_command()
2009 vc->vc_par[1] <= USHRT_MAX) in setterm_command()
2010 vc->vc_cur_blink_ms = vc->vc_par[1]; in setterm_command()
2012 vc->vc_cur_blink_ms = DEFAULT_CURSOR_BLINK_MS; in setterm_command()
2020 if (nr > vc->vc_cols - vc->state.x) in csi_at()
2021 nr = vc->vc_cols - vc->state.x; in csi_at()
2030 if (nr > vc->vc_rows - vc->state.y) in csi_L()
2031 nr = vc->vc_rows - vc->state.y; in csi_L()
2034 con_scroll(vc, vc->state.y, vc->vc_bottom, SM_DOWN, nr); in csi_L()
2035 vc->vc_need_wrap = 0; in csi_L()
2041 if (nr > vc->vc_cols - vc->state.x) in csi_P()
2042 nr = vc->vc_cols - vc->state.x; in csi_P()
2051 if (nr > vc->vc_rows - vc->state.y) in csi_M()
2052 nr = vc->vc_rows - vc->state.y; in csi_M()
2055 con_scroll(vc, vc->state.y, vc->vc_bottom, SM_UP, nr); in csi_M()
2056 vc->vc_need_wrap = 0; in csi_M()
2059 /* console_lock is held (except via vc_init->reset_terminal */
2062 memcpy(&vc->saved_state, &vc->state, sizeof(vc->state)); in save_cur()
2068 memcpy(&vc->state, &vc->saved_state, sizeof(vc->state)); in restore_cur()
2070 gotoxy(vc, vc->state.x, vc->state.y); in restore_cur()
2071 vc->vc_translate = set_translate(vc->state.Gx_charset[vc->state.charset], in restore_cur()
2074 vc->vc_need_wrap = 0; in restore_cur()
2086 vc->vc_top = 0; in reset_terminal()
2087 vc->vc_bottom = vc->vc_rows; in reset_terminal()
2088 vc->vc_state = ESnormal; in reset_terminal()
2089 vc->vc_priv = EPecma; in reset_terminal()
2090 vc->vc_translate = set_translate(LAT1_MAP, vc); in reset_terminal()
2091 vc->state.Gx_charset[0] = LAT1_MAP; in reset_terminal()
2092 vc->state.Gx_charset[1] = GRAF_MAP; in reset_terminal()
2093 vc->state.charset = 0; in reset_terminal()
2094 vc->vc_need_wrap = 0; in reset_terminal()
2095 vc->vc_report_mouse = 0; in reset_terminal()
2096 vc->vc_utf = default_utf8; in reset_terminal()
2097 vc->vc_utf_count = 0; in reset_terminal()
2099 vc->vc_disp_ctrl = 0; in reset_terminal()
2100 vc->vc_toggle_meta = 0; in reset_terminal()
2102 vc->vc_decscnm = 0; in reset_terminal()
2103 vc->vc_decom = 0; in reset_terminal()
2104 vc->vc_decawm = 1; in reset_terminal()
2105 vc->vc_deccm = global_cursor_default; in reset_terminal()
2106 vc->vc_decim = 0; in reset_terminal()
2108 vt_reset_keyboard(vc->vc_num); in reset_terminal()
2110 vc->vc_cursor_type = cur_default; in reset_terminal()
2111 vc->vc_complement_mask = vc->vc_s_complement_mask; in reset_terminal()
2116 bitmap_zero(vc->vc_tab_stop, VC_TABSTOPS_COUNT); in reset_terminal()
2118 set_bit(i, vc->vc_tab_stop); in reset_terminal()
2120 vc->vc_bell_pitch = DEFAULT_BELL_PITCH; in reset_terminal()
2121 vc->vc_bell_duration = DEFAULT_BELL_DURATION; in reset_terminal()
2122 vc->vc_cur_blink_ms = DEFAULT_CURSOR_BLINK_MS; in reset_terminal()
2132 unsigned char *charset = &vc->state.Gx_charset[which]; in vc_setGx()
2149 if (vc->state.charset == which) in vc_setGx()
2150 vc->vc_translate = set_translate(*charset, vc); in vc_setGx()
2168 if (ansi_control_string(vc->vc_state) && c >= 8 && c <= 13) in do_con_trol()
2174 if (ansi_control_string(vc->vc_state)) in do_con_trol()
2175 vc->vc_state = ESnormal; in do_con_trol()
2176 else if (vc->vc_bell_duration) in do_con_trol()
2177 kd_mksound(vc->vc_bell_pitch, vc->vc_bell_duration); in do_con_trol()
2183 vc->vc_pos -= (vc->state.x << 1); in do_con_trol()
2185 vc->state.x = find_next_bit(vc->vc_tab_stop, in do_con_trol()
2186 min(vc->vc_cols - 1, VC_TABSTOPS_COUNT), in do_con_trol()
2187 vc->state.x + 1); in do_con_trol()
2188 if (vc->state.x >= VC_TABSTOPS_COUNT) in do_con_trol()
2189 vc->state.x = vc->vc_cols - 1; in do_con_trol()
2191 vc->vc_pos += (vc->state.x << 1); in do_con_trol()
2203 vc->state.charset = 1; in do_con_trol()
2204 vc->vc_translate = set_translate(vc->state.Gx_charset[1], vc); in do_con_trol()
2205 vc->vc_disp_ctrl = 1; in do_con_trol()
2208 vc->state.charset = 0; in do_con_trol()
2209 vc->vc_translate = set_translate(vc->state.Gx_charset[0], vc); in do_con_trol()
2210 vc->vc_disp_ctrl = 0; in do_con_trol()
2213 vc->vc_state = ESnormal; in do_con_trol()
2216 vc->vc_state = ESesc; in do_con_trol()
2222 vc->vc_state = ESsquare; in do_con_trol()
2225 switch(vc->vc_state) { in do_con_trol()
2227 vc->vc_state = ESnormal; in do_con_trol()
2230 vc->vc_state = ESsquare; in do_con_trol()
2233 vc->vc_state = ESnonstd; in do_con_trol()
2236 vc->vc_state = ESapc; in do_con_trol()
2239 vc->vc_state = ESpm; in do_con_trol()
2242 vc->vc_state = ESpercent; in do_con_trol()
2255 if (vc->state.x < VC_TABSTOPS_COUNT) in do_con_trol()
2256 set_bit(vc->state.x, vc->vc_tab_stop); in do_con_trol()
2259 vc->vc_state = ESdcs; in do_con_trol()
2271 vc->vc_state = ESsetG0; in do_con_trol()
2274 vc->vc_state = ESsetG1; in do_con_trol()
2277 vc->vc_state = EShash; in do_con_trol()
2292 for (vc->vc_npar = 0; vc->vc_npar < NPAR; vc->vc_npar++) in do_con_trol()
2293 vc->vc_par[vc->vc_npar] = 0; in do_con_trol()
2294 vc->vc_npar = 0; in do_con_trol()
2295 vc->vc_state = ESpalette; in do_con_trol()
2299 vc->vc_state = ESnormal; in do_con_trol()
2301 vc->vc_state = ESosc; in do_con_trol()
2303 vc->vc_state = ESnormal; in do_con_trol()
2307 vc->vc_par[vc->vc_npar++] = hex_to_bin(c); in do_con_trol()
2308 if (vc->vc_npar == 7) { in do_con_trol()
2309 int i = vc->vc_par[0] * 3, j = 1; in do_con_trol()
2310 vc->vc_palette[i] = 16 * vc->vc_par[j++]; in do_con_trol()
2311 vc->vc_palette[i++] += vc->vc_par[j++]; in do_con_trol()
2312 vc->vc_palette[i] = 16 * vc->vc_par[j++]; in do_con_trol()
2313 vc->vc_palette[i++] += vc->vc_par[j++]; in do_con_trol()
2314 vc->vc_palette[i] = 16 * vc->vc_par[j++]; in do_con_trol()
2315 vc->vc_palette[i] += vc->vc_par[j]; in do_con_trol()
2317 vc->vc_state = ESnormal; in do_con_trol()
2320 vc->vc_state = ESnormal; in do_con_trol()
2323 for (vc->vc_npar = 0; vc->vc_npar < NPAR; vc->vc_npar++) in do_con_trol()
2324 vc->vc_par[vc->vc_npar] = 0; in do_con_trol()
2325 vc->vc_npar = 0; in do_con_trol()
2326 vc->vc_state = ESgetpars; in do_con_trol()
2328 vc->vc_state=ESfunckey; in do_con_trol()
2333 vc->vc_priv = EPdec; in do_con_trol()
2336 vc->vc_priv = EPgt; in do_con_trol()
2339 vc->vc_priv = EPeq; in do_con_trol()
2342 vc->vc_priv = EPlt; in do_con_trol()
2345 vc->vc_priv = EPecma; in do_con_trol()
2348 if (c == ';' && vc->vc_npar < NPAR - 1) { in do_con_trol()
2349 vc->vc_npar++; in do_con_trol()
2352 vc->vc_par[vc->vc_npar] *= 10; in do_con_trol()
2353 vc->vc_par[vc->vc_npar] += c - '0'; in do_con_trol()
2356 if (c >= 0x20 && c <= 0x3f) { /* 0x2x, 0x3a and 0x3c - 0x3f */ in do_con_trol()
2357 vc->vc_state = EScsiignore; in do_con_trol()
2360 vc->vc_state = ESnormal; in do_con_trol()
2363 if (vc->vc_priv <= EPdec) in do_con_trol()
2367 if (vc->vc_priv <= EPdec) in do_con_trol()
2371 if (vc->vc_priv == EPdec) { in do_con_trol()
2372 if (vc->vc_par[0]) in do_con_trol()
2373 vc->vc_cursor_type = in do_con_trol()
2374 CUR_MAKE(vc->vc_par[0], in do_con_trol()
2375 vc->vc_par[1], in do_con_trol()
2376 vc->vc_par[2]); in do_con_trol()
2378 vc->vc_cursor_type = cur_default; in do_con_trol()
2383 if (vc->vc_priv == EPdec) { in do_con_trol()
2385 if (vc->vc_par[0]) in do_con_trol()
2386 vc->vc_complement_mask = vc->vc_par[0] << 8 | vc->vc_par[1]; in do_con_trol()
2388 vc->vc_complement_mask = vc->vc_s_complement_mask; in do_con_trol()
2393 if (vc->vc_priv == EPecma) { in do_con_trol()
2394 if (vc->vc_par[0] == 5) in do_con_trol()
2396 else if (vc->vc_par[0] == 6) in do_con_trol()
2401 if (vc->vc_priv != EPecma) { in do_con_trol()
2402 vc->vc_priv = EPecma; in do_con_trol()
2407 if (vc->vc_par[0]) in do_con_trol()
2408 vc->vc_par[0]--; in do_con_trol()
2409 gotoxy(vc, vc->vc_par[0], vc->state.y); in do_con_trol()
2412 if (!vc->vc_par[0]) in do_con_trol()
2413 vc->vc_par[0]++; in do_con_trol()
2414 gotoxy(vc, vc->state.x, vc->state.y - vc->vc_par[0]); in do_con_trol()
2417 if (!vc->vc_par[0]) in do_con_trol()
2418 vc->vc_par[0]++; in do_con_trol()
2419 gotoxy(vc, vc->state.x, vc->state.y + vc->vc_par[0]); in do_con_trol()
2422 if (!vc->vc_par[0]) in do_con_trol()
2423 vc->vc_par[0]++; in do_con_trol()
2424 gotoxy(vc, vc->state.x + vc->vc_par[0], vc->state.y); in do_con_trol()
2427 if (!vc->vc_par[0]) in do_con_trol()
2428 vc->vc_par[0]++; in do_con_trol()
2429 gotoxy(vc, vc->state.x - vc->vc_par[0], vc->state.y); in do_con_trol()
2432 if (!vc->vc_par[0]) in do_con_trol()
2433 vc->vc_par[0]++; in do_con_trol()
2434 gotoxy(vc, 0, vc->state.y + vc->vc_par[0]); in do_con_trol()
2437 if (!vc->vc_par[0]) in do_con_trol()
2438 vc->vc_par[0]++; in do_con_trol()
2439 gotoxy(vc, 0, vc->state.y - vc->vc_par[0]); in do_con_trol()
2442 if (vc->vc_par[0]) in do_con_trol()
2443 vc->vc_par[0]--; in do_con_trol()
2444 gotoxay(vc, vc->state.x ,vc->vc_par[0]); in do_con_trol()
2447 if (vc->vc_par[0]) in do_con_trol()
2448 vc->vc_par[0]--; in do_con_trol()
2449 if (vc->vc_par[1]) in do_con_trol()
2450 vc->vc_par[1]--; in do_con_trol()
2451 gotoxay(vc, vc->vc_par[1], vc->vc_par[0]); in do_con_trol()
2454 csi_J(vc, vc->vc_par[0]); in do_con_trol()
2457 csi_K(vc, vc->vc_par[0]); in do_con_trol()
2460 csi_L(vc, vc->vc_par[0]); in do_con_trol()
2463 csi_M(vc, vc->vc_par[0]); in do_con_trol()
2466 csi_P(vc, vc->vc_par[0]); in do_con_trol()
2469 if (!vc->vc_par[0]) in do_con_trol()
2473 if (!vc->vc_par[0] && vc->state.x < VC_TABSTOPS_COUNT) in do_con_trol()
2474 set_bit(vc->state.x, vc->vc_tab_stop); in do_con_trol()
2475 else if (vc->vc_par[0] == 3) in do_con_trol()
2476 bitmap_zero(vc->vc_tab_stop, VC_TABSTOPS_COUNT); in do_con_trol()
2481 case 'q': /* DECLL - but only 3 leds */ in do_con_trol()
2483 if (vc->vc_par[0] < 4) in do_con_trol()
2484 vt_set_led_state(vc->vc_num, in do_con_trol()
2485 (vc->vc_par[0] < 3) ? vc->vc_par[0] : 4); in do_con_trol()
2488 if (!vc->vc_par[0]) in do_con_trol()
2489 vc->vc_par[0]++; in do_con_trol()
2490 if (!vc->vc_par[1]) in do_con_trol()
2491 vc->vc_par[1] = vc->vc_rows; in do_con_trol()
2493 if (vc->vc_par[0] < vc->vc_par[1] && in do_con_trol()
2494 vc->vc_par[1] <= vc->vc_rows) { in do_con_trol()
2495 vc->vc_top = vc->vc_par[0] - 1; in do_con_trol()
2496 vc->vc_bottom = vc->vc_par[1]; in do_con_trol()
2507 csi_X(vc, vc->vc_par[0]); in do_con_trol()
2510 csi_at(vc, vc->vc_par[0]); in do_con_trol()
2520 vc->vc_state = ESnormal; in do_con_trol()
2523 vc->vc_state = ESnormal; in do_con_trol()
2526 vc->vc_utf = 0; in do_con_trol()
2530 vc->vc_utf = 1; in do_con_trol()
2535 vc->vc_state = ESnormal; in do_con_trol()
2538 vc->vc_state = ESnormal; in do_con_trol()
2540 /* DEC screen alignment test. kludge :-) */ in do_con_trol()
2541 vc->vc_video_erase_char = in do_con_trol()
2542 (vc->vc_video_erase_char & 0xff00) | 'E'; in do_con_trol()
2544 vc->vc_video_erase_char = in do_con_trol()
2545 (vc->vc_video_erase_char & 0xff00) | ' '; in do_con_trol()
2546 do_update_region(vc, vc->vc_origin, vc->vc_screenbuf_size / 2); in do_con_trol()
2551 vc->vc_state = ESnormal; in do_con_trol()
2555 vc->vc_state = ESnormal; in do_con_trol()
2566 vc->vc_state = ESnormal; in do_con_trol()
2571 * Markus Kuhn -- 2007-05-26 (Unicode 5.0)
2587 return -1; in ucs_cmp()
2600 ucs > double_width[ARRAY_SIZE(double_width) - 1].last) in is_double_width()
2614 if (draw->x < 0) in con_flush()
2617 vc->vc_sw->con_putcs(vc, (u16 *)draw->from, in con_flush()
2618 (u16 *)draw->to - (u16 *)draw->from, vc->state.y, in con_flush()
2619 draw->x); in con_flush()
2620 draw->x = -1; in con_flush()
2626 if (vc->vc_toggle_meta) in vc_translate_ascii()
2629 return vc->vc_translate[c]; in vc_translate_ascii()
2637 * vc_sanitize_unicode -- Replace invalid Unicode code points with U+FFFD
2649 * vc_translate_unicode -- Combine UTF-8 into Unicode in @vc_utf_char
2654 * @vc_utf_char is the being-constructed unicode character.
2668 if (!vc->vc_utf_count) in vc_translate_unicode()
2671 vc->vc_utf_char = (vc->vc_utf_char << 6) | (c & 0x3f); in vc_translate_unicode()
2672 vc->vc_npar++; in vc_translate_unicode()
2673 if (--vc->vc_utf_count) in vc_translate_unicode()
2677 c = vc->vc_utf_char; in vc_translate_unicode()
2679 if (c <= utf8_length_changes[vc->vc_npar - 1] || in vc_translate_unicode()
2680 c > utf8_length_changes[vc->vc_npar]) in vc_translate_unicode()
2687 if (vc->vc_utf_count) { in vc_translate_unicode()
2690 vc->vc_utf_count = 0; in vc_translate_unicode()
2699 vc->vc_npar = 0; in vc_translate_unicode()
2701 vc->vc_utf_count = 1; in vc_translate_unicode()
2702 vc->vc_utf_char = (c & 0x1f); in vc_translate_unicode()
2704 vc->vc_utf_count = 2; in vc_translate_unicode()
2705 vc->vc_utf_char = (c & 0x0f); in vc_translate_unicode()
2707 vc->vc_utf_count = 3; in vc_translate_unicode()
2708 vc->vc_utf_char = (c & 0x07); in vc_translate_unicode()
2710 vc->vc_utf_count = 4; in vc_translate_unicode()
2711 vc->vc_utf_char = (c & 0x03); in vc_translate_unicode()
2713 vc->vc_utf_count = 5; in vc_translate_unicode()
2714 vc->vc_utf_char = (c & 0x01); in vc_translate_unicode()
2721 return -1; in vc_translate_unicode()
2727 if (vc->vc_state != ESnormal) in vc_translate()
2730 if (vc->vc_utf && !vc->vc_disp_ctrl) in vc_translate()
2739 if (!vc->vc_can_do_color) in vc_invert_attr()
2740 return vc->vc_attr ^ 0x08; in vc_invert_attr()
2742 if (vc->vc_hi_font_mask == 0x100) in vc_invert_attr()
2743 return (vc->vc_attr & 0x11) | in vc_invert_attr()
2744 ((vc->vc_attr & 0xe0) >> 4) | in vc_invert_attr()
2745 ((vc->vc_attr & 0x0e) << 4); in vc_invert_attr()
2747 return (vc->vc_attr & 0x88) | in vc_invert_attr()
2748 ((vc->vc_attr & 0x70) >> 4) | in vc_invert_attr()
2749 ((vc->vc_attr & 0x07) << 4); in vc_invert_attr()
2764 if (vc->vc_state != ESnormal) in vc_is_control()
2776 * useless without them; to display an arbitrary font position use the in vc_is_control()
2777 * direct-to-font zone in UTF-8 mode. in vc_is_control()
2780 if (vc->vc_disp_ctrl) in vc_is_control()
2783 return vc->vc_utf || (CTRL_ACTION & BIT(c)); in vc_is_control()
2786 if (c == 127 && !vc->vc_disp_ctrl) in vc_is_control()
2799 unsigned char vc_attr = vc->vc_attr; in vc_con_write_normal()
2800 u16 himask = vc->vc_hi_font_mask, charmask = himask ? 0x1ff : 0xff; in vc_con_write_normal()
2804 if (vc->vc_utf && !vc->vc_disp_ctrl) { in vc_con_write_normal()
2809 /* Now try to find out how to display it */ in vc_con_write_normal()
2812 if (tc == -1 || tc == -2) in vc_con_write_normal()
2813 return -1; /* nothing to display */ in vc_con_write_normal()
2816 if ((!vc->vc_utf || vc->vc_disp_ctrl || c < 128) && in vc_con_write_normal()
2829 * Display U+FFFD. If it's not found, display an inverse in vc_con_write_normal()
2847 if (vc->vc_need_wrap || vc->vc_decim) in vc_con_write_normal()
2849 if (vc->vc_need_wrap) { in vc_con_write_normal()
2853 if (vc->vc_decim) in vc_con_write_normal()
2862 scr_writew(tc, (u16 *)vc->vc_pos); in vc_con_write_normal()
2864 if (con_should_update(vc) && draw->x < 0) { in vc_con_write_normal()
2865 draw->x = vc->state.x; in vc_con_write_normal()
2866 draw->from = vc->vc_pos; in vc_con_write_normal()
2868 if (vc->state.x == vc->vc_cols - 1) { in vc_con_write_normal()
2869 vc->vc_need_wrap = vc->vc_decawm; in vc_con_write_normal()
2870 draw->to = vc->vc_pos + 2; in vc_con_write_normal()
2872 vc->state.x++; in vc_con_write_normal()
2873 draw->to = (vc->vc_pos += 2); in vc_con_write_normal()
2876 if (!--width) in vc_con_write_normal()
2897 .x = -1, in do_con_write()
2909 vc = tty->driver_data; in do_con_write()
2916 currcons = vc->vc_num; in do_con_write()
2931 while (!tty->flow.stopped && count) { in do_con_write()
2935 count--; in do_con_write()
2941 if (tc == -1) in do_con_write()
2975 * with other console code and prevention of re-entrancy is
2988 been allocated - a new console is not created in console_callback()
2991 want_console = -1; in console_callback()
3000 if (vc->vc_mode == KD_TEXT && vc->vc_sw->con_scrolldelta) in console_callback()
3001 vc->vc_sw->con_scrolldelta(vc, scrollback_delta); in console_callback()
3018 (vc->vt_mode.mode == VT_AUTO && vc->vc_mode == KD_GRAPHICS)) { in set_console()
3028 return -EINVAL; in set_console()
3042 * vt_kmsg_redirect() - Sets/gets the kernel message console
3043 * @new: The new virtual terminal number or -1 if the console should stay
3055 * The parameter -1 means that only the current console is returned, but the
3066 if (new != -1) in vt_kmsg_redirect()
3094 if (kmsg_console && vc_cons_allocated(kmsg_console - 1)) in vt_console_print()
3095 vc = vc_cons[kmsg_console - 1].d; in vt_console_print()
3103 if (vc->vc_mode != KD_TEXT) in vt_console_print()
3110 start = (ushort *)vc->vc_pos; in vt_console_print()
3111 start_x = vc->state.x; in vt_console_print()
3113 while (count--) { in vt_console_print()
3115 if (c == 10 || c == 13 || c == 8 || vc->vc_need_wrap) { in vt_console_print()
3117 vc->vc_sw->con_putcs(vc, start, cnt, vc->state.y, start_x); in vt_console_print()
3121 start = (ushort *)vc->vc_pos; in vt_console_print()
3122 start_x = vc->state.x; in vt_console_print()
3128 start = (ushort *)vc->vc_pos; in vt_console_print()
3129 start_x = vc->state.x; in vt_console_print()
3134 scr_writew((vc->vc_attr << 8) + c, (unsigned short *)vc->vc_pos); in vt_console_print()
3137 if (vc->state.x == vc->vc_cols - 1) { in vt_console_print()
3138 vc->vc_need_wrap = 1; in vt_console_print()
3140 vc->vc_pos += 2; in vt_console_print()
3141 vc->state.x++; in vt_console_print()
3145 vc->vc_sw->con_putcs(vc, start, cnt, vc->state.y, start_x); in vt_console_print()
3155 *index = c->index ? c->index-1 : fg_console; in vt_console_device()
3165 .index = -1,
3170 * Handling of Linux-specific VC ioctls
3191 if (current->signal->tty != tty && !capable(CAP_SYS_ADMIN)) in tioclinux()
3192 return -EPERM; in tioclinux()
3194 return -EFAULT; in tioclinux()
3221 * kernel-internal variable; programs not closely in tioclinux()
3244 ret = -EPERM; in tioclinux()
3247 ret = -EFAULT; in tioclinux()
3260 ret = -EFAULT; in tioclinux()
3281 ret = -EINVAL; in tioclinux()
3308 if (tty->flow.stopped) in con_write_room()
3324 struct vc_data *vc = tty->driver_data; in con_unthrottle()
3326 wake_up_interruptible(&vc->paste_wait); in con_unthrottle()
3330 * Turn the Scroll-Lock LED on when the tty is stopped
3337 console_num = tty->index; in con_stop()
3344 * Turn the Scroll-Lock LED off when the console is started
3351 console_num = tty->index; in con_start()
3366 vc = tty->driver_data; in con_flush_chars()
3377 unsigned int currcons = tty->index; in con_install()
3389 if (vc->port.tty) { in con_install()
3390 ret = -ERESTARTSYS; in con_install()
3394 ret = tty_port_install(&vc->port, driver, tty); in con_install()
3398 tty->driver_data = vc; in con_install()
3399 vc->port.tty = tty; in con_install()
3400 tty_port_get(&vc->port); in con_install()
3402 if (!tty->winsize.ws_row && !tty->winsize.ws_col) { in con_install()
3403 tty->winsize.ws_row = vc_cons[currcons].d->vc_rows; in con_install()
3404 tty->winsize.ws_col = vc_cons[currcons].d->vc_cols; in con_install()
3406 if (vc->vc_utf) in con_install()
3407 tty->termios.c_iflag |= IUTF8; in con_install()
3409 tty->termios.c_iflag &= ~IUTF8; in con_install()
3424 /* Nothing to do - we defer to shutdown */ in con_close()
3429 struct vc_data *vc = tty->driver_data; in con_shutdown()
3432 vc->port.tty = NULL; in con_shutdown()
3438 struct vc_data *vc = tty->driver_data; in con_cleanup()
3440 tty_port_put(&vc->port); in con_cleanup()
3455 vc->vc_cols = cols; in vc_init()
3456 vc->vc_rows = rows; in vc_init()
3457 vc->vc_size_row = cols << 1; in vc_init()
3458 vc->vc_screenbuf_size = vc->vc_rows * vc->vc_size_row; in vc_init()
3461 vc->vc_pos = vc->vc_origin; in vc_init()
3464 vc->vc_palette[k++] = default_red[j] ; in vc_init()
3465 vc->vc_palette[k++] = default_grn[j] ; in vc_init()
3466 vc->vc_palette[k++] = default_blu[j] ; in vc_init()
3468 vc->vc_def_color = default_color; in vc_init()
3469 vc->vc_ulcolor = default_underline_color; in vc_init()
3470 vc->vc_itcolor = default_italic_color; in vc_init()
3471 vc->vc_halfcolor = 0x08; /* grey */ in vc_init()
3472 init_waitqueue_head(&vc->paste_wait); in vc_init()
3479 * the appropriate escape-sequence.
3492 display_desc = conswitchp->con_startup(); in con_init()
3502 if (con_driver->con == NULL) { in con_init()
3503 con_driver->con = conswitchp; in con_init()
3504 con_driver->desc = display_desc; in con_init()
3505 con_driver->flag = CON_DRIVER_FLAG_INIT; in con_init()
3506 con_driver->first = 0; in con_init()
3507 con_driver->last = MAX_NR_CONSOLES - 1; in con_init()
3523 tty_port_init(&vc->port); in con_init()
3525 /* Assuming vc->vc_{cols,rows,screenbuf_size} are sane here. */ in con_init()
3526 vc->vc_screenbuf = kzalloc(vc->vc_screenbuf_size, GFP_NOWAIT); in con_init()
3527 vc_init(vc, vc->vc_rows, vc->vc_cols, in con_init()
3528 currcons || !vc->vc_sw->con_save_screen); in con_init()
3534 gotoxy(vc, vc->state.x, vc->state.y); in con_init()
3538 vc->vc_can_do_color ? "colour" : "mono", in con_init()
3539 display_desc, vc->vc_cols, vc->vc_rows); in con_init()
3606 console_driver->name = "tty"; in vty_init()
3607 console_driver->name_base = 1; in vty_init()
3608 console_driver->major = TTY_MAJOR; in vty_init()
3609 console_driver->minor_start = 1; in vty_init()
3610 console_driver->type = TTY_DRIVER_TYPE_CONSOLE; in vty_init()
3611 console_driver->init_termios = tty_std_termios; in vty_init()
3613 console_driver->init_termios.c_iflag |= IUTF8; in vty_init()
3632 struct module *owner = csw->owner; in do_bind_con_driver()
3635 int i, j = -1, k = -1, retval = -ENODEV; in do_bind_con_driver()
3638 return -ENODEV; in do_bind_con_driver()
3646 if (con_driver->con == csw) { in do_bind_con_driver()
3647 desc = con_driver->desc; in do_bind_con_driver()
3656 if (!(con_driver->flag & CON_DRIVER_FLAG_INIT)) { in do_bind_con_driver()
3657 csw->con_startup(); in do_bind_con_driver()
3658 con_driver->flag |= CON_DRIVER_FLAG_INIT; in do_bind_con_driver()
3663 module_put(conswitchp->owner); in do_bind_con_driver()
3669 first = max(first, con_driver->first); in do_bind_con_driver()
3670 last = min(last, con_driver->last); in do_bind_con_driver()
3677 module_put(con_driver_map[i]->owner); in do_bind_con_driver()
3681 if (!vc || !vc->vc_sw) in do_bind_con_driver()
3691 old_was_color = vc->vc_can_do_color; in do_bind_con_driver()
3692 vc->vc_sw->con_deinit(vc); in do_bind_con_driver()
3693 vc->vc_origin = (unsigned long)vc->vc_screenbuf; in do_bind_con_driver()
3698 /* If the console changed between mono <-> color, then in do_bind_con_driver()
3702 if (old_was_color != vc->vc_can_do_color) in do_bind_con_driver()
3708 pr_cont("consoles %d-%d ", first + 1, last + 1); in do_bind_con_driver()
3713 vc->vc_can_do_color ? "colour" : "mono", in do_bind_con_driver()
3714 desc, vc->vc_cols, vc->vc_rows); in do_bind_con_driver()
3734 struct module *owner = csw->owner; in do_unbind_con_driver()
3737 int i, retval = -ENODEV; in do_unbind_con_driver()
3740 return -ENODEV; in do_unbind_con_driver()
3748 if (con_driver->con == csw && in do_unbind_con_driver()
3749 con_driver->flag & CON_DRIVER_FLAG_MODULE) { in do_unbind_con_driver()
3758 retval = -ENODEV; in do_unbind_con_driver()
3764 if (con_back->con && con_back->con != csw) { in do_unbind_con_driver()
3765 defcsw = con_back->con; in do_unbind_con_driver()
3777 first = max(first, con_driver->first); in do_unbind_con_driver()
3778 last = min(last, con_driver->last); in do_unbind_con_driver()
3782 module_put(csw->owner); in do_unbind_con_driver()
3790 defcsw->con_startup(); in do_unbind_con_driver()
3791 con_back->flag |= CON_DRIVER_FLAG_INIT; in do_unbind_con_driver()
3800 con_driver->flag &= ~CON_DRIVER_FLAG_INIT; in do_unbind_con_driver()
3814 int i, more = 1, first = -1, last = -1, deflt = 0; in vt_bind()
3816 if (!con->con || !(con->flag & CON_DRIVER_FLAG_MODULE)) in vt_bind()
3819 csw = con->con; in vt_bind()
3824 if (con->con && !(con->flag & CON_DRIVER_FLAG_MODULE)) { in vt_bind()
3825 defcsw = con->con; in vt_bind()
3836 for (i = con->first; i <= con->last; i++) { in vt_bind()
3838 if (first == -1) in vt_bind()
3842 } else if (first != -1) in vt_bind()
3846 if (first == 0 && last == MAX_NR_CONSOLES -1) in vt_bind()
3849 if (first != -1) in vt_bind()
3852 first = -1; in vt_bind()
3853 last = -1; in vt_bind()
3864 int i, more = 1, first = -1, last = -1, deflt = 0; in vt_unbind()
3867 if (!con->con || !(con->flag & CON_DRIVER_FLAG_MODULE)) in vt_unbind()
3870 csw = con->con; in vt_unbind()
3875 for (i = con->first; i <= con->last; i++) { in vt_unbind()
3877 if (first == -1) in vt_unbind()
3881 } else if (first != -1) in vt_unbind()
3885 if (first == 0 && last == MAX_NR_CONSOLES -1) in vt_unbind()
3888 if (first != -1) { in vt_unbind()
3894 first = -1; in vt_unbind()
3895 last = -1; in vt_unbind()
3938 bind = con_is_bound(con->con); in show_bind()
3950 (con->flag & CON_DRIVER_FLAG_MODULE) ? "(M)" : "(S)", in show_name()
3951 con->desc); in show_name()
3968 con->flag |= CON_DRIVER_FLAG_ATTR; in vtconsole_init_device()
3974 con->flag &= ~CON_DRIVER_FLAG_ATTR; in vtconsole_deinit_device()
3978 * con_is_bound - checks if driver is bound to the console
4004 * con_is_visible - checks whether the current console is visible
4013 return *vc->vc_display_fg == vc; in con_is_visible()
4018 * con_debug_enter - prepare the console for the kernel debugger
4036 saved_vc_mode = vc->vc_mode; in con_debug_enter()
4038 vc->vc_mode = KD_TEXT; in con_debug_enter()
4040 if (vc->vc_sw->con_debug_enter) in con_debug_enter()
4041 ret = vc->vc_sw->con_debug_enter(vc); in con_debug_enter()
4044 if (vc->vc_rows < 999) { in con_debug_enter()
4053 snprintf(lns, 4, "%i", vc->vc_rows); in con_debug_enter()
4057 if (vc->vc_cols < 999) { in con_debug_enter()
4066 snprintf(cols, 4, "%i", vc->vc_cols); in con_debug_enter()
4076 * con_debug_leave - restore console state
4094 vc_cons[fg_console].d->vc_mode = saved_vc_mode; in con_debug_leave()
4097 if (vc->vc_sw->con_debug_leave) in con_debug_leave()
4098 ret = vc->vc_sw->con_debug_leave(vc); in con_debug_leave()
4105 struct module *owner = csw->owner; in do_register_con_driver()
4113 return -ENODEV; in do_register_con_driver()
4119 if (con_driver->con == csw) { in do_register_con_driver()
4120 retval = -EBUSY; in do_register_con_driver()
4125 desc = csw->con_startup(); in do_register_con_driver()
4127 retval = -ENODEV; in do_register_con_driver()
4131 retval = -EINVAL; in do_register_con_driver()
4136 if (con_driver->con == NULL && in do_register_con_driver()
4137 !(con_driver->flag & CON_DRIVER_FLAG_ZOMBIE)) { in do_register_con_driver()
4138 con_driver->con = csw; in do_register_con_driver()
4139 con_driver->desc = desc; in do_register_con_driver()
4140 con_driver->node = i; in do_register_con_driver()
4141 con_driver->flag = CON_DRIVER_FLAG_MODULE | in do_register_con_driver()
4143 con_driver->first = first; in do_register_con_driver()
4144 con_driver->last = last; in do_register_con_driver()
4153 con_driver->dev = in do_register_con_driver()
4155 MKDEV(0, con_driver->node), in do_register_con_driver()
4157 "vtcon%i", con_driver->node); in do_register_con_driver()
4158 if (IS_ERR(con_driver->dev)) { in do_register_con_driver()
4160 con_driver->desc, PTR_ERR(con_driver->dev)); in do_register_con_driver()
4161 con_driver->dev = NULL; in do_register_con_driver()
4173 * do_unregister_con_driver - unregister console driver from console layer
4189 return -EBUSY; in do_unregister_con_driver()
4192 return -EINVAL; in do_unregister_con_driver()
4197 if (con_driver->con == csw) { in do_unregister_con_driver()
4208 con_driver->con = NULL; in do_unregister_con_driver()
4209 con_driver->flag = CON_DRIVER_FLAG_ZOMBIE; in do_unregister_con_driver()
4216 return -ENODEV; in do_unregister_con_driver()
4229 if (!(con_driver->flag & CON_DRIVER_FLAG_ZOMBIE)) in con_driver_unregister_callback()
4235 device_destroy(vtconsole_class, MKDEV(0, con_driver->node)); in con_driver_unregister_callback()
4239 if (WARN_ON_ONCE(con_driver->con)) in con_driver_unregister_callback()
4240 con_driver->con = NULL; in con_driver_unregister_callback()
4241 con_driver->desc = NULL; in con_driver_unregister_callback()
4242 con_driver->dev = NULL; in con_driver_unregister_callback()
4243 con_driver->node = 0; in con_driver_unregister_callback()
4244 WARN_ON_ONCE(con_driver->flag != CON_DRIVER_FLAG_ZOMBIE); in con_driver_unregister_callback()
4245 con_driver->flag = 0; in con_driver_unregister_callback()
4246 con_driver->first = 0; in con_driver_unregister_callback()
4247 con_driver->last = 0; in con_driver_unregister_callback()
4270 if (err == -EBUSY) in do_take_over_console()
4306 if (con->con && !con->dev) { in vtconsole_class_init()
4307 con->dev = in vtconsole_class_init()
4309 MKDEV(0, con->node), in vtconsole_class_init()
4311 "vtcon%i", con->node); in vtconsole_class_init()
4313 if (IS_ERR(con->dev)) { in vtconsole_class_init()
4315 con->desc, PTR_ERR(con->dev)); in vtconsole_class_init()
4316 con->dev = NULL; in vtconsole_class_init()
4338 return -EFAULT; in set_vesa_blanking()
4356 vc->vc_sw->con_blank(vc, vesa_blank_mode + 1, 0); in do_blank_screen()
4365 vc->vc_sw->con_blank(vc, -1, 1); in do_blank_screen()
4375 if (vc->vc_mode != KD_TEXT) { in do_blank_screen()
4386 i = vc->vc_sw->con_blank(vc, vesa_off_interval ? 1 : (vesa_blank_mode + 1), 0); in do_blank_screen()
4398 vt_event_post(VT_EVENT_BLANK, vc->vc_num, vc->vc_num); in do_blank_screen()
4428 if (vc->vc_mode != KD_TEXT) in do_unblank_screen()
4437 if (vc->vc_sw->con_blank(vc, 0, leaving_gfx)) in do_unblank_screen()
4438 /* Low-level driver cannot restore -> do it ourselves */ in do_unblank_screen()
4444 vt_event_post(VT_EVENT_UNBLANK, vc->vc_num, vc->vc_num); in do_unblank_screen()
4478 * function. --BenH. in poke_blanked_console()
4488 if (ignore_poke || !vc_cons[fg_console].d || vc_cons[fg_console].d->vc_mode == KD_GRAPHICS) in poke_blanked_console()
4506 if (vc->vc_mode != KD_GRAPHICS && vc->vc_sw->con_set_palette) in set_palette()
4507 vc->vc_sw->con_set_palette(vc, color_table); in set_palette()
4521 return -EFAULT; in con_set_cmap()
4533 vc_cons[i].d->vc_palette[k++] = default_red[j]; in con_set_cmap()
4534 vc_cons[i].d->vc_palette[k++] = default_grn[j]; in con_set_cmap()
4535 vc_cons[i].d->vc_palette[k++] = default_blu[j]; in con_set_cmap()
4558 return -EFAULT; in con_get_cmap()
4567 vc->vc_palette[k++] = default_red[j]; in reset_palette()
4568 vc->vc_palette[k++] = default_grn[j]; in reset_palette()
4569 vc->vc_palette[k++] = default_blu[j]; in reset_palette()
4577 * Currently we only support fonts up to 32 pixels wide, at a maximum height
4581 * is up to the actual low-level console-driver convert data into its favorite
4582 * format (maybe we should add a `fontoffset' field to the `display'
4592 int rc = -EINVAL; in con_font_get()
4595 if (op->data) { in con_font_get()
4598 return -ENOMEM; in con_font_get()
4603 if (vc->vc_mode != KD_TEXT) in con_font_get()
4604 rc = -EINVAL; in con_font_get()
4605 else if (vc->vc_sw->con_font_get) in con_font_get()
4606 rc = vc->vc_sw->con_font_get(vc, &font); in con_font_get()
4608 rc = -ENOSYS; in con_font_get()
4616 if (op->data && font.charcount > op->charcount) in con_font_get()
4617 rc = -ENOSPC; in con_font_get()
4618 if (font.width > op->width || font.height > op->height) in con_font_get()
4619 rc = -ENOSPC; in con_font_get()
4623 op->height = font.height; in con_font_get()
4624 op->width = font.width; in con_font_get()
4625 op->charcount = font.charcount; in con_font_get()
4627 if (op->data && copy_to_user(op->data, font.data, c)) in con_font_get()
4628 rc = -EFAULT; in con_font_get()
4638 int rc = -EINVAL; in con_font_set()
4641 if (vc->vc_mode != KD_TEXT) in con_font_set()
4642 return -EINVAL; in con_font_set()
4643 if (!op->data) in con_font_set()
4644 return -EINVAL; in con_font_set()
4645 if (op->charcount > 512) in con_font_set()
4646 return -EINVAL; in con_font_set()
4647 if (op->width <= 0 || op->width > 32 || !op->height || op->height > 32) in con_font_set()
4648 return -EINVAL; in con_font_set()
4649 size = (op->width+7)/8 * 32 * op->charcount; in con_font_set()
4651 return -ENOSPC; in con_font_set()
4653 font.data = memdup_user(op->data, size); in con_font_set()
4657 font.charcount = op->charcount; in con_font_set()
4658 font.width = op->width; in con_font_set()
4659 font.height = op->height; in con_font_set()
4662 if (vc->vc_mode != KD_TEXT) in con_font_set()
4663 rc = -EINVAL; in con_font_set()
4664 else if (vc->vc_sw->con_font_set) { in con_font_set()
4667 rc = vc->vc_sw->con_font_set(vc, &font, op->flags); in con_font_set()
4669 rc = -ENOSYS; in con_font_set()
4677 struct console_font font = {.width = op->width, .height = op->height}; in con_font_default()
4683 if (!op->data) in con_font_default()
4685 else if (strncpy_from_user(name, op->data, MAX_FONT_NAME - 1) < 0) in con_font_default()
4686 return -EFAULT; in con_font_default()
4688 name[MAX_FONT_NAME - 1] = 0; in con_font_default()
4691 if (vc->vc_mode != KD_TEXT) { in con_font_default()
4693 return -EINVAL; in con_font_default()
4695 if (vc->vc_sw->con_font_default) { in con_font_default()
4698 rc = vc->vc_sw->con_font_default(vc, &font, s); in con_font_default()
4700 rc = -ENOSYS; in con_font_default()
4703 op->width = font.width; in con_font_default()
4704 op->height = font.height; in con_font_default()
4711 switch (op->op) { in con_font_op()
4720 return -EINVAL; in con_font_op()
4722 return -ENOSYS; in con_font_op()
4735 if (w & vc->vc_hi_font_mask) in screen_glyph()
4746 return uniscr->lines[n / vc->vc_cols][n % vc->vc_cols]; in screen_glyph_unicode()
4751 /* used by vcs - note the word offset */
4761 xy[0] = min(vc->state.x, 0xFFu); in getconsxy()
4762 xy[1] = min(vc->state.y, 0xFFu); in getconsxy()
4774 if ((unsigned long)org == vc->vc_pos && softcursor_original != -1) in vcs_scr_readw()
4782 if ((unsigned long)org == vc->vc_pos) { in vcs_scr_writew()
4783 softcursor_original = -1; in vcs_scr_writew()
4797 ptrdiff_t scr_end = (void *)c->vc_scr_end - base; in vc_scrolldelta_helper()
4798 ptrdiff_t vorigin = (void *)c->vc_visible_origin - base; in vc_scrolldelta_helper()
4799 ptrdiff_t origin = (void *)c->vc_origin - base; in vc_scrolldelta_helper()
4800 int margin = c->vc_size_row * 4; in vc_scrolldelta_helper()
4805 c->vc_visible_origin = c->vc_origin; in vc_scrolldelta_helper()
4812 wrap = rolled_over + c->vc_size_row; in vc_scrolldelta_helper()
4818 from_off = (vorigin - from + wrap) % wrap + lines * c->vc_size_row; in vc_scrolldelta_helper()
4819 avail = (origin - from + wrap) % wrap; in vc_scrolldelta_helper()
4826 if (from_off > avail - margin) in vc_scrolldelta_helper()
4829 c->vc_visible_origin = ubase + (from + from_off) % wrap; in vc_scrolldelta_helper()