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
157 #define vt_get_kmsg_redirect() vt_kmsg_redirect(-1)
161 int global_cursor_default = -1;
195 int want_console = -1;
204 * For each existing display, we have a pointer to console currently visible
205 * on that display, allowing consoles other than fg_console to be refreshed
206 * appropriately. Unless the low-level driver supplies its own display_fg
207 * variable, we use this one for the "master display".
213 * console since the code is (and always was) not re-entrant, so we schedule
214 * all flip requests to process context with schedule-task() and run it from
276 * Low-Level Functions
281 return vc->vc_num == fg_console; in con_is_fg()
295 p = (unsigned short *)(vc->vc_origin + offset); in screenpos()
296 else if (!vc->vc_sw->con_screen_pos) in screenpos()
297 p = (unsigned short *)(vc->vc_visible_origin + offset); in screenpos()
299 p = vc->vc_sw->con_screen_pos(vc, offset); in screenpos()
319 * Code to manage unicode-based screen buffers
357 vc_uniscr_free(vc->vc_uni_lines); in vc_uniscr_set()
358 vc->vc_uni_lines = new_uni_lines; in vc_uniscr_set()
363 if (vc->vc_uni_lines) in vc_uniscr_putc()
364 vc->vc_uni_lines[vc->state.y][vc->state.x] = uc; in vc_uniscr_putc()
369 if (vc->vc_uni_lines) { in vc_uniscr_insert()
370 u32 *ln = vc->vc_uni_lines[vc->state.y]; in vc_uniscr_insert()
371 unsigned int x = vc->state.x, cols = vc->vc_cols; in vc_uniscr_insert()
373 memmove(&ln[x + nr], &ln[x], (cols - x - nr) * sizeof(*ln)); in vc_uniscr_insert()
380 if (vc->vc_uni_lines) { in vc_uniscr_delete()
381 u32 *ln = vc->vc_uni_lines[vc->state.y]; in vc_uniscr_delete()
382 unsigned int x = vc->state.x, cols = vc->vc_cols; in vc_uniscr_delete()
384 memmove(&ln[x], &ln[x + nr], (cols - x - nr) * sizeof(*ln)); in vc_uniscr_delete()
385 memset32(&ln[cols - nr], ' ', nr); in vc_uniscr_delete()
392 if (vc->vc_uni_lines) in vc_uniscr_clear_line()
393 memset32(&vc->vc_uni_lines[vc->state.y][x], ' ', nr); in vc_uniscr_clear_line()
399 if (vc->vc_uni_lines) in vc_uniscr_clear_lines()
400 while (nr--) in vc_uniscr_clear_lines()
401 memset32(vc->vc_uni_lines[y++], ' ', vc->vc_cols); in vc_uniscr_clear_lines()
430 u32 **uni_lines = vc->vc_uni_lines; in vc_uniscr_scroll()
431 unsigned int size = bottom - top; in vc_uniscr_scroll()
437 juggle_array(&uni_lines[top], size, size - nr); in vc_uniscr_scroll()
441 vc_uniscr_clear_lines(vc, bottom - nr, nr); in vc_uniscr_scroll()
463 if (dst_cols - src_cols) in vc_uniscr_copy_area()
464 memset32(dst_line + src_cols, ' ', dst_cols - src_cols); in vc_uniscr_copy_area()
480 * In particular, -ENODATA is returned if the console is not in UTF-8 mode.
490 if (!vc->vc_utf) in vc_uniscr_check()
491 return -ENODATA; in vc_uniscr_check()
493 if (vc->vc_uni_lines) in vc_uniscr_check()
496 uni_lines = vc_uniscr_alloc(vc->vc_cols, vc->vc_rows); in vc_uniscr_check()
498 return -ENOMEM; in vc_uniscr_check()
506 p = (unsigned short *)vc->vc_origin; in vc_uniscr_check()
507 mask = vc->vc_hi_font_mask | 0xff; in vc_uniscr_check()
508 for (y = 0; y < vc->vc_rows; y++) { in vc_uniscr_check()
510 for (x = 0; x < vc->vc_cols; x++) { in vc_uniscr_check()
516 vc->vc_uni_lines = uni_lines; in vc_uniscr_check()
529 u32 **uni_lines = vc->vc_uni_lines; in vc_uniscr_copy_line()
530 int offset = row * vc->vc_size_row + col * 2; in vc_uniscr_copy_line()
537 if (pos >= vc->vc_origin && pos < vc->vc_scr_end) { in vc_uniscr_copy_line()
543 row = (pos - vc->vc_origin) / vc->vc_size_row; in vc_uniscr_copy_line()
544 col = ((pos - vc->vc_origin) % vc->vc_size_row) / 2; in vc_uniscr_copy_line()
550 * synchronize with console display drivers for a scrollback in vc_uniscr_copy_line()
554 int mask = vc->vc_hi_font_mask | 0xff; in vc_uniscr_copy_line()
556 while (nr--) { in vc_uniscr_copy_line()
567 unsigned int rows = bottom - top; in con_scroll()
571 nr = rows - 1; in con_scroll()
572 if (bottom > vc->vc_rows || top >= bottom || nr < 1) in con_scroll()
577 vc->vc_sw->con_scroll(vc, top, bottom, dir, nr)) in con_scroll()
580 src = clear = (u16 *)(vc->vc_origin + vc->vc_size_row * top); in con_scroll()
581 dst = (u16 *)(vc->vc_origin + vc->vc_size_row * (top + nr)); in con_scroll()
584 clear = src + (rows - nr) * vc->vc_cols; in con_scroll()
587 scr_memmovew(dst, src, (rows - nr) * vc->vc_size_row); in con_scroll()
588 scr_memsetw(clear, vc->vc_video_erase_char, vc->vc_size_row * nr); in con_scroll()
597 if (!vc->vc_sw->con_getxy) { in do_update_region()
598 offset = (start - vc->vc_origin) / 2; in do_update_region()
599 xx = offset % vc->vc_cols; in do_update_region()
600 yy = offset / vc->vc_cols; in do_update_region()
603 start = vc->vc_sw->con_getxy(vc, start, &nxx, &nyy); in do_update_region()
610 while (xx < vc->vc_cols && count) { in do_update_region()
613 vc->vc_sw->con_putcs(vc, q, p-q, yy, startx); in do_update_region()
620 count--; in do_update_region()
623 vc->vc_sw->con_putcs(vc, q, p-q, yy, startx); in do_update_region()
628 if (vc->vc_sw->con_getxy) { in do_update_region()
630 start = vc->vc_sw->con_getxy(vc, start, NULL, NULL); in do_update_region()
647 /* Structure of attributes is hardware-dependent */
653 if (vc->vc_sw->con_build_attr) in build_attr()
654 return vc->vc_sw->con_build_attr(vc, _color, _intensity, in build_attr()
659 * mode (!can_do_color). The formerly used MDA (monochrome display in build_attr()
669 if (!vc->vc_can_do_color) in build_attr()
676 a = (a & 0xF0) | vc->vc_itcolor; in build_attr()
678 a = (a & 0xf0) | vc->vc_ulcolor; in build_attr()
680 a = (a & 0xf0) | vc->vc_halfcolor; in build_attr()
687 if (vc->vc_hi_font_mask == 0x100) in build_attr()
695 vc->vc_attr = build_attr(vc, vc->state.color, vc->state.intensity, in update_attr()
696 vc->state.blink, vc->state.underline, in update_attr()
697 vc->state.reverse ^ vc->vc_decscnm, vc->state.italic); in update_attr()
698 vc->vc_video_erase_char = ' ' | (build_attr(vc, vc->state.color, in update_attr()
699 VCI_NORMAL, vc->state.blink, false, in update_attr()
700 vc->vc_decscnm, false) << 8); in update_attr()
712 if (vc->vc_sw->con_invert_region) { in invert_screen()
713 vc->vc_sw->con_invert_region(vc, p, count); in invert_screen()
719 if (!vc->vc_can_do_color) { in invert_screen()
720 while (cnt--) { in invert_screen()
726 } else if (vc->vc_hi_font_mask == 0x100) { in invert_screen()
727 while (cnt--) { in invert_screen()
736 while (cnt--) { in invert_screen()
755 static int old_offset = -1; in complement_pos()
761 if (old_offset != -1 && old_offset >= 0 && in complement_pos()
762 old_offset < vc->vc_screenbuf_size) { in complement_pos()
765 vc->vc_sw->con_putc(vc, old, oldy, oldx); in complement_pos()
771 if (offset != -1 && offset >= 0 && in complement_pos()
772 offset < vc->vc_screenbuf_size) { in complement_pos()
777 new = old ^ vc->vc_complement_mask; in complement_pos()
780 oldx = (offset >> 1) % vc->vc_cols; in complement_pos()
781 oldy = (offset >> 1) / vc->vc_cols; in complement_pos()
782 vc->vc_sw->con_putc(vc, new, oldy, oldx); in complement_pos()
790 unsigned short *p = (unsigned short *) vc->vc_pos; in insert_char()
793 scr_memmovew(p + nr, p, (vc->vc_cols - vc->state.x - nr) * 2); in insert_char()
794 scr_memsetw(p, vc->vc_video_erase_char, nr * 2); in insert_char()
795 vc->vc_need_wrap = 0; in insert_char()
798 vc->vc_cols - vc->state.x); in insert_char()
803 unsigned short *p = (unsigned short *) vc->vc_pos; in delete_char()
806 scr_memmovew(p, p + nr, (vc->vc_cols - vc->state.x - nr) * 2); in delete_char()
807 scr_memsetw(p + vc->vc_cols - vc->state.x - nr, vc->vc_video_erase_char, in delete_char()
809 vc->vc_need_wrap = 0; in delete_char()
812 vc->vc_cols - vc->state.x); in delete_char()
815 static int softcursor_original = -1;
819 int i = scr_readw((u16 *) vc->vc_pos); in add_softcursor()
820 u32 type = vc->vc_cursor_type; in add_softcursor()
824 if (softcursor_original != -1) in add_softcursor()
834 scr_writew(i, (u16 *)vc->vc_pos); in add_softcursor()
836 vc->vc_sw->con_putc(vc, i, vc->state.y, vc->state.x); in add_softcursor()
841 if (softcursor_original != -1) { in hide_softcursor()
842 scr_writew(softcursor_original, (u16 *)vc->vc_pos); in hide_softcursor()
844 vc->vc_sw->con_putc(vc, softcursor_original, in hide_softcursor()
845 vc->state.y, vc->state.x); in hide_softcursor()
846 softcursor_original = -1; in hide_softcursor()
855 vc->vc_sw->con_cursor(vc, CM_ERASE); in hide_cursor()
861 if (!con_is_fg(vc) || console_blanked || vc->vc_mode == KD_GRAPHICS) in set_cursor()
863 if (vc->vc_deccm) { in set_cursor()
867 if (CUR_SIZE(vc->vc_cursor_type) != CUR_NONE) in set_cursor()
868 vc->vc_sw->con_cursor(vc, CM_DRAW); in set_cursor()
878 !vc->vc_sw->con_set_origin || in set_origin()
879 !vc->vc_sw->con_set_origin(vc)) in set_origin()
880 vc->vc_origin = (unsigned long)vc->vc_screenbuf; in set_origin()
881 vc->vc_visible_origin = vc->vc_origin; in set_origin()
882 vc->vc_scr_end = vc->vc_origin + vc->vc_screenbuf_size; in set_origin()
883 vc->vc_pos = vc->vc_origin + vc->vc_size_row * vc->state.y + in set_origin()
884 2 * vc->state.x; in set_origin()
891 if (vc->vc_sw->con_save_screen) in save_screen()
892 vc->vc_sw->con_save_screen(vc); in save_screen()
900 if (vc->vc_sw->con_flush_scrollback) { in flush_scrollback()
901 vc->vc_sw->con_flush_scrollback(vc); in flush_scrollback()
912 vc->vc_sw->con_switch(vc); in flush_scrollback()
923 unsigned short *p = (unsigned short *)vc->vc_origin; in clear_buffer_attributes()
924 int count = vc->vc_screenbuf_size / 2; in clear_buffer_attributes()
925 int mask = vc->vc_hi_font_mask | 0xff; in clear_buffer_attributes()
927 for (; count > 0; count--, p++) { in clear_buffer_attributes()
928 scr_writew((scr_readw(p)&mask) | (vc->vc_video_erase_char & ~mask), p); in clear_buffer_attributes()
950 *vc->vc_display_fg = vc; in redraw_screen()
951 fg_console = vc->vc_num; in redraw_screen()
958 sysfs_notify(&tty0dev->kobj, NULL, "active"); in redraw_screen()
966 int old_was_color = vc->vc_can_do_color; in redraw_screen()
969 update = vc->vc_sw->con_switch(vc); in redraw_screen()
972 * If console changed from mono<->color, the best we can do in redraw_screen()
977 if (old_was_color != vc->vc_can_do_color) { in redraw_screen()
982 if (update && vc->vc_mode != KD_GRAPHICS) in redraw_screen()
983 do_update_region(vc, vc->vc_origin, vc->vc_screenbuf_size / 2); in redraw_screen()
1004 /* ++Geert: vc->vc_sw->con_init determines console size */ in visual_init()
1005 if (vc->vc_sw) in visual_init()
1006 module_put(vc->vc_sw->owner); in visual_init()
1007 vc->vc_sw = conswitchp; in visual_init()
1010 vc->vc_sw = con_driver_map[num]; in visual_init()
1012 __module_get(vc->vc_sw->owner); in visual_init()
1013 vc->vc_num = num; in visual_init()
1014 vc->vc_display_fg = &master_display_fg; in visual_init()
1015 if (vc->uni_pagedict_loc) in visual_init()
1017 vc->uni_pagedict_loc = &vc->uni_pagedict; in visual_init()
1018 vc->uni_pagedict = NULL; in visual_init()
1019 vc->vc_hi_font_mask = 0; in visual_init()
1020 vc->vc_complement_mask = 0; in visual_init()
1021 vc->vc_can_do_color = 0; in visual_init()
1022 vc->vc_cur_blink_ms = DEFAULT_CURSOR_BLINK_MS; in visual_init()
1023 vc->vc_sw->con_init(vc, init); in visual_init()
1024 if (!vc->vc_complement_mask) in visual_init()
1025 vc->vc_complement_mask = vc->vc_can_do_color ? 0x7700 : 0x0800; in visual_init()
1026 vc->vc_s_complement_mask = vc->vc_complement_mask; in visual_init()
1027 vc->vc_size_row = vc->vc_cols << 1; in visual_init()
1028 vc->vc_screenbuf_size = vc->vc_rows * vc->vc_size_row; in visual_init()
1034 vc->vc_sw->con_deinit(vc); in visual_deinit()
1035 module_put(vc->vc_sw->owner); in visual_deinit()
1066 return -ENXIO; in vc_allocate()
1075 point is still up-to-date and the comment still has its value in vc_allocate()
1076 even if only as a historical artifact. --mj, July 1998 */ in vc_allocate()
1079 return -ENOMEM; in vc_allocate()
1082 tty_port_init(&vc->port); in vc_allocate()
1083 vc->port.ops = &vc_port_ops; in vc_allocate()
1088 if (!*vc->uni_pagedict_loc) in vc_allocate()
1091 err = -EINVAL; in vc_allocate()
1092 if (vc->vc_cols > VC_MAXCOL || vc->vc_rows > VC_MAXROW || in vc_allocate()
1093 vc->vc_screenbuf_size > KMALLOC_MAX_SIZE || !vc->vc_screenbuf_size) in vc_allocate()
1095 err = -ENOMEM; in vc_allocate()
1096 vc->vc_screenbuf = kzalloc(vc->vc_screenbuf_size, GFP_KERNEL); in vc_allocate()
1097 if (!vc->vc_screenbuf) in vc_allocate()
1102 if (global_cursor_default == -1) in vc_allocate()
1117 static inline int resize_screen(struct vc_data *vc, int width, int height, in resize_screen() argument
1120 /* Resizes the resolution of the display adapater */ in resize_screen()
1123 if (vc->vc_sw->con_resize) in resize_screen()
1124 err = vc->vc_sw->con_resize(vc, width, height, user); in resize_screen()
1130 * vc_do_resize - resizing method for the tty
1158 return -ENXIO; in vc_do_resize()
1160 user = vc->vc_resize_user; in vc_do_resize()
1161 vc->vc_resize_user = 0; in vc_do_resize()
1164 return -EINVAL; in vc_do_resize()
1166 new_cols = (cols ? cols : vc->vc_cols); in vc_do_resize()
1167 new_rows = (lines ? lines : vc->vc_rows); in vc_do_resize()
1171 if (new_cols == vc->vc_cols && new_rows == vc->vc_rows) { in vc_do_resize()
1176 * yres/xres equal to a number non-multiple of vc_font.height in vc_do_resize()
1181 * if above, and this causes the fbcon_display->vrows to become in vc_do_resize()
1182 * negative and it eventually leads to out-of-bound in vc_do_resize()
1192 return -EINVAL; in vc_do_resize()
1195 return -ENOMEM; in vc_do_resize()
1197 if (vc->vc_uni_lines) { in vc_do_resize()
1201 return -ENOMEM; in vc_do_resize()
1208 old_rows = vc->vc_rows; in vc_do_resize()
1209 old_row_size = vc->vc_size_row; in vc_do_resize()
1218 vc->vc_rows = new_rows; in vc_do_resize()
1219 vc->vc_cols = new_cols; in vc_do_resize()
1220 vc->vc_size_row = new_row_size; in vc_do_resize()
1221 vc->vc_screenbuf_size = new_screen_size; in vc_do_resize()
1224 rrem = new_row_size - rlth; in vc_do_resize()
1225 old_origin = vc->vc_origin; in vc_do_resize()
1229 if (vc->state.y > new_rows) { in vc_do_resize()
1230 if (old_rows - vc->state.y < new_rows) { in vc_do_resize()
1235 first_copied_row = (old_rows - new_rows); in vc_do_resize()
1241 first_copied_row = (vc->state.y - new_rows/2); in vc_do_resize()
1249 vc->vc_uni_lines, rlth/2, first_copied_row, in vc_do_resize()
1260 vc->vc_video_erase_char, rrem); in vc_do_resize()
1265 scr_memsetw((void *)new_origin, vc->vc_video_erase_char, in vc_do_resize()
1266 new_scr_end - new_origin); in vc_do_resize()
1267 oldscreen = vc->vc_screenbuf; in vc_do_resize()
1268 vc->vc_screenbuf = newscreen; in vc_do_resize()
1269 vc->vc_screenbuf_size = new_screen_size; in vc_do_resize()
1274 vc->vc_top = 0; in vc_do_resize()
1275 vc->vc_bottom = vc->vc_rows; in vc_do_resize()
1276 gotoxy(vc, vc->state.x, vc->state.y); in vc_do_resize()
1284 ws.ws_row = vc->vc_rows; in vc_do_resize()
1285 ws.ws_col = vc->vc_cols; in vc_do_resize()
1286 ws.ws_ypixel = vc->vc_scan_lines; in vc_do_resize()
1292 vt_event_post(VT_EVENT_RESIZE, vc->vc_num, vc->vc_num); in vc_do_resize()
1298 * vc_resize - resize a VT
1306 * vc->port.tty
1311 return vc_do_resize(vc->port.tty, vc, cols, rows); in vc_resize()
1316 * vt_resize - resize a VT
1329 struct vc_data *vc = tty->driver_data; in vt_resize()
1333 ret = vc_do_resize(tty, vc, ws->ws_col, ws->ws_row); in vt_resize()
1352 put_pid(vc->vt_pid); in vc_deallocate()
1354 kfree(vc->vc_screenbuf); in vc_deallocate()
1366 #define set_kbd(vc, x) vt_set_kbd_mode_bit((vc)->vc_num, (x))
1367 #define clr_kbd(vc, x) vt_clr_kbd_mode_bit((vc)->vc_num, (x))
1368 #define is_kbd(vc, x) vt_get_kbd_mode_bit((vc)->vc_num, (x))
1411 vc->state.x = 0; in gotoxy()
1413 if (new_x >= vc->vc_cols) in gotoxy()
1414 vc->state.x = vc->vc_cols - 1; in gotoxy()
1416 vc->state.x = new_x; in gotoxy()
1419 if (vc->vc_decom) { in gotoxy()
1420 min_y = vc->vc_top; in gotoxy()
1421 max_y = vc->vc_bottom; in gotoxy()
1424 max_y = vc->vc_rows; in gotoxy()
1427 vc->state.y = min_y; in gotoxy()
1429 vc->state.y = max_y - 1; in gotoxy()
1431 vc->state.y = new_y; in gotoxy()
1432 vc->vc_pos = vc->vc_origin + vc->state.y * vc->vc_size_row + in gotoxy()
1433 (vc->state.x << 1); in gotoxy()
1434 vc->vc_need_wrap = 0; in gotoxy()
1440 gotoxy(vc, new_x, vc->vc_decom ? (vc->vc_top + new_y) : new_y); in gotoxay()
1445 scrolldelta(-(vc->vc_rows / 2)); in scrollback()
1451 lines = vc->vc_rows / 2; in scrollfront()
1460 if (vc->state.y + 1 == vc->vc_bottom) in lf()
1461 con_scroll(vc, vc->vc_top, vc->vc_bottom, SM_UP, 1); in lf()
1462 else if (vc->state.y < vc->vc_rows - 1) { in lf()
1463 vc->state.y++; in lf()
1464 vc->vc_pos += vc->vc_size_row; in lf()
1466 vc->vc_need_wrap = 0; in lf()
1475 if (vc->state.y == vc->vc_top) in ri()
1476 con_scroll(vc, vc->vc_top, vc->vc_bottom, SM_DOWN, 1); in ri()
1477 else if (vc->state.y > 0) { in ri()
1478 vc->state.y--; in ri()
1479 vc->vc_pos -= vc->vc_size_row; in ri()
1481 vc->vc_need_wrap = 0; in ri()
1486 vc->vc_pos -= vc->state.x << 1; in cr()
1487 vc->vc_need_wrap = vc->state.x = 0; in cr()
1493 if (vc->state.x) { in bs()
1494 vc->vc_pos -= 2; in bs()
1495 vc->state.x--; in bs()
1496 vc->vc_need_wrap = 0; in bs()
1512 case 0: /* erase from cursor to end of display */ in csi_J()
1513 vc_uniscr_clear_line(vc, vc->state.x, in csi_J()
1514 vc->vc_cols - vc->state.x); in csi_J()
1515 vc_uniscr_clear_lines(vc, vc->state.y + 1, in csi_J()
1516 vc->vc_rows - vc->state.y - 1); in csi_J()
1517 count = (vc->vc_scr_end - vc->vc_pos) >> 1; in csi_J()
1518 start = (unsigned short *)vc->vc_pos; in csi_J()
1521 vc_uniscr_clear_line(vc, 0, vc->state.x + 1); in csi_J()
1522 vc_uniscr_clear_lines(vc, 0, vc->state.y); in csi_J()
1523 count = ((vc->vc_pos - vc->vc_origin) >> 1) + 1; in csi_J()
1524 start = (unsigned short *)vc->vc_origin; in csi_J()
1529 case 2: /* erase whole display */ in csi_J()
1530 vc_uniscr_clear_lines(vc, 0, vc->vc_rows); in csi_J()
1531 count = vc->vc_cols * vc->vc_rows; in csi_J()
1532 start = (unsigned short *)vc->vc_origin; in csi_J()
1537 scr_memsetw(start, vc->vc_video_erase_char, 2 * count); in csi_J()
1540 vc->vc_need_wrap = 0; in csi_J()
1546 unsigned short *start = (unsigned short *)vc->vc_pos; in csi_K()
1552 count = vc->vc_cols - vc->state.x; in csi_K()
1555 offset = -vc->state.x; in csi_K()
1556 count = vc->state.x + 1; in csi_K()
1559 offset = -vc->state.x; in csi_K()
1560 count = vc->vc_cols; in csi_K()
1565 vc_uniscr_clear_line(vc, vc->state.x + offset, count); in csi_K()
1566 scr_memsetw(start + offset, vc->vc_video_erase_char, 2 * count); in csi_K()
1567 vc->vc_need_wrap = 0; in csi_K()
1580 count = min(vpar, vc->vc_cols - vc->state.x); in csi_X()
1582 vc_uniscr_clear_line(vc, vc->state.x, count); in csi_X()
1583 scr_memsetw((unsigned short *)vc->vc_pos, vc->vc_video_erase_char, 2 * count); in csi_X()
1585 vc->vc_sw->con_clear(vc, vc->state.y, vc->state.x, 1, count); in csi_X()
1586 vc->vc_need_wrap = 0; in csi_X()
1591 vc->state.intensity = VCI_NORMAL; in default_attr()
1592 vc->state.italic = false; in default_attr()
1593 vc->state.underline = false; in default_attr()
1594 vc->state.reverse = false; in default_attr()
1595 vc->state.blink = false; in default_attr()
1596 vc->state.color = vc->vc_def_color; in default_attr()
1604 c->r = i&1 ? 0xaa : 0x00; in rgb_from_256()
1605 c->g = i&2 ? 0xaa : 0x00; in rgb_from_256()
1606 c->b = i&4 ? 0xaa : 0x00; in rgb_from_256()
1608 c->r = i&1 ? 0xff : 0x55; in rgb_from_256()
1609 c->g = i&2 ? 0xff : 0x55; in rgb_from_256()
1610 c->b = i&4 ? 0xff : 0x55; in rgb_from_256()
1612 c->r = (i - 16) / 36 * 85 / 2; in rgb_from_256()
1613 c->g = (i - 16) / 6 % 6 * 85 / 2; in rgb_from_256()
1614 c->b = (i - 16) % 6 * 85 / 2; in rgb_from_256()
1616 c->r = c->g = c->b = i * 10 - 2312; in rgb_from_256()
1621 u8 hue = 0, max = max3(c->r, c->g, c->b); in rgb_foreground()
1623 if (c->r > max / 2) in rgb_foreground()
1625 if (c->g > max / 2) in rgb_foreground()
1627 if (c->b > max / 2) in rgb_foreground()
1632 vc->state.intensity = VCI_BOLD; in rgb_foreground()
1634 vc->state.intensity = VCI_BOLD; in rgb_foreground()
1636 vc->state.intensity = VCI_NORMAL; in rgb_foreground()
1638 vc->state.color = (vc->state.color & 0xf0) | hue; in rgb_foreground()
1644 vc->state.color = (vc->state.color & 0x0f) in rgb_background()
1645 | (c->r&0x80) >> 1 | (c->g&0x80) >> 2 | (c->b&0x80) >> 3; in rgb_background()
1663 if (i > vc->vc_npar) in vc_t416_color()
1666 if (vc->vc_par[i] == 5 && i + 1 <= vc->vc_npar) { in vc_t416_color()
1669 rgb_from_256(vc->vc_par[i], &c); in vc_t416_color()
1670 } else if (vc->vc_par[i] == 2 && i + 3 <= vc->vc_npar) { in vc_t416_color()
1672 c.r = vc->vc_par[i + 1]; in vc_t416_color()
1673 c.g = vc->vc_par[i + 2]; in vc_t416_color()
1674 c.b = vc->vc_par[i + 3]; in vc_t416_color()
1689 for (i = 0; i <= vc->vc_npar; i++) in csi_m()
1690 switch (vc->vc_par[i]) { in csi_m()
1695 vc->state.intensity = VCI_BOLD; in csi_m()
1698 vc->state.intensity = VCI_HALF_BRIGHT; in csi_m()
1701 vc->state.italic = true; in csi_m()
1709 vc->state.underline = true; in csi_m()
1712 vc->state.blink = true; in csi_m()
1715 vc->state.reverse = true; in csi_m()
1717 case 10: /* ANSI X3.64-1979 (SCO-ish?) in csi_m()
1718 * Select primary font, don't display control chars if in csi_m()
1721 vc->vc_translate = set_translate(vc->state.Gx_charset[vc->state.charset], vc); in csi_m()
1722 vc->vc_disp_ctrl = 0; in csi_m()
1723 vc->vc_toggle_meta = 0; in csi_m()
1725 case 11: /* ANSI X3.64-1979 (SCO-ish?) in csi_m()
1726 * Select first alternate font, lets chars < 32 be in csi_m()
1727 * displayed as ROM chars. in csi_m()
1729 vc->vc_translate = set_translate(IBMPC_MAP, vc); in csi_m()
1730 vc->vc_disp_ctrl = 1; in csi_m()
1731 vc->vc_toggle_meta = 0; in csi_m()
1733 case 12: /* ANSI X3.64-1979 (SCO-ish?) in csi_m()
1737 vc->vc_translate = set_translate(IBMPC_MAP, vc); in csi_m()
1738 vc->vc_disp_ctrl = 1; in csi_m()
1739 vc->vc_toggle_meta = 1; in csi_m()
1742 vc->state.intensity = VCI_NORMAL; in csi_m()
1745 vc->state.italic = false; in csi_m()
1748 vc->state.underline = false; in csi_m()
1751 vc->state.blink = false; in csi_m()
1754 vc->state.reverse = false; in csi_m()
1763 vc->state.color = (vc->vc_def_color & 0x0f) | in csi_m()
1764 (vc->state.color & 0xf0); in csi_m()
1767 vc->state.color = (vc->vc_def_color & 0xf0) | in csi_m()
1768 (vc->state.color & 0x0f); in csi_m()
1771 if (vc->vc_par[i] >= 90 && vc->vc_par[i] <= 107) { in csi_m()
1772 if (vc->vc_par[i] < 100) in csi_m()
1773 vc->state.intensity = VCI_BOLD; in csi_m()
1774 vc->vc_par[i] -= 60; in csi_m()
1776 if (vc->vc_par[i] >= 30 && vc->vc_par[i] <= 37) in csi_m()
1777 vc->state.color = color_table[vc->vc_par[i] - 30] in csi_m()
1778 | (vc->state.color & 0xf0); in csi_m()
1779 else if (vc->vc_par[i] >= 40 && vc->vc_par[i] <= 47) in csi_m()
1780 vc->state.color = (color_table[vc->vc_par[i] - 40] << 4) in csi_m()
1781 | (vc->state.color & 0x0f); in csi_m()
1798 len = sprintf(buf, "\033[%d;%dR", vc->state.y + in cursor_report()
1799 (vc->vc_decom ? vc->vc_top + 1 : 1), in cursor_report()
1800 vc->state.x + 1); in cursor_report()
1801 respond_string(buf, len, tty->port); in cursor_report()
1808 respond_string(teminal_ok, strlen(teminal_ok), tty->port); in status_report()
1813 /* terminal answer to an ESC-Z or csi0c query. */ in respond_ID()
1816 respond_string(vt102_id, strlen(vt102_id), tty->port); in respond_ID()
1826 respond_string(buf, len, tty->port); in mouse_report()
1832 return vc_cons[fg_console].d->vc_report_mouse; in mouse_reporting()
1840 for (i = 0; i <= vc->vc_npar; i++) in set_mode()
1841 if (vc->vc_priv == EPdec) { in set_mode()
1842 switch(vc->vc_par[i]) { /* DEC private modes set/reset */ in set_mode()
1851 vc_resize(deccolm ? 132 : 80, vc->vc_rows); in set_mode()
1857 if (vc->vc_decscnm != on_off) { in set_mode()
1858 vc->vc_decscnm = on_off; in set_mode()
1860 vc->vc_screenbuf_size, in set_mode()
1866 vc->vc_decom = on_off; in set_mode()
1870 vc->vc_decawm = on_off; in set_mode()
1879 vc->vc_report_mouse = on_off ? 1 : 0; in set_mode()
1882 vc->vc_deccm = on_off; in set_mode()
1885 vc->vc_report_mouse = on_off ? 2 : 0; in set_mode()
1889 switch(vc->vc_par[i]) { /* ANSI modes set/reset */ in set_mode()
1890 case 3: /* Monitor (display ctrls) */ in set_mode()
1891 vc->vc_disp_ctrl = on_off; in set_mode()
1894 vc->vc_decim = on_off; in set_mode()
1909 switch (vc->vc_par[0]) { in setterm_command()
1911 if (vc->vc_can_do_color && vc->vc_par[1] < 16) { in setterm_command()
1912 vc->vc_ulcolor = color_table[vc->vc_par[1]]; in setterm_command()
1913 if (vc->state.underline) in setterm_command()
1918 if (vc->vc_can_do_color && vc->vc_par[1] < 16) { in setterm_command()
1919 vc->vc_halfcolor = color_table[vc->vc_par[1]]; in setterm_command()
1920 if (vc->state.intensity == VCI_HALF_BRIGHT) in setterm_command()
1925 vc->vc_def_color = vc->vc_attr; in setterm_command()
1926 if (vc->vc_hi_font_mask == 0x100) in setterm_command()
1927 vc->vc_def_color >>= 1; in setterm_command()
1932 blankinterval = min(vc->vc_par[1], 60U) * 60; in setterm_command()
1936 if (vc->vc_npar >= 1) in setterm_command()
1937 vc->vc_bell_pitch = vc->vc_par[1]; in setterm_command()
1939 vc->vc_bell_pitch = DEFAULT_BELL_PITCH; in setterm_command()
1942 if (vc->vc_npar >= 1) in setterm_command()
1943 vc->vc_bell_duration = (vc->vc_par[1] < 2000) ? in setterm_command()
1944 msecs_to_jiffies(vc->vc_par[1]) : 0; in setterm_command()
1946 vc->vc_bell_duration = DEFAULT_BELL_DURATION; in setterm_command()
1949 if (vc->vc_par[1] >= 1 && vc_cons_allocated(vc->vc_par[1] - 1)) in setterm_command()
1950 set_console(vc->vc_par[1] - 1); in setterm_command()
1956 vesa_off_interval = min(vc->vc_par[1], 60U) * 60 * HZ; in setterm_command()
1962 if (vc->vc_npar >= 1 && vc->vc_par[1] >= 50 && in setterm_command()
1963 vc->vc_par[1] <= USHRT_MAX) in setterm_command()
1964 vc->vc_cur_blink_ms = vc->vc_par[1]; in setterm_command()
1966 vc->vc_cur_blink_ms = DEFAULT_CURSOR_BLINK_MS; in setterm_command()
1974 if (nr > vc->vc_cols - vc->state.x) in csi_at()
1975 nr = vc->vc_cols - vc->state.x; in csi_at()
1984 if (nr > vc->vc_rows - vc->state.y) in csi_L()
1985 nr = vc->vc_rows - vc->state.y; in csi_L()
1988 con_scroll(vc, vc->state.y, vc->vc_bottom, SM_DOWN, nr); in csi_L()
1989 vc->vc_need_wrap = 0; in csi_L()
1995 if (nr > vc->vc_cols - vc->state.x) in csi_P()
1996 nr = vc->vc_cols - vc->state.x; in csi_P()
2005 if (nr > vc->vc_rows - vc->state.y) in csi_M()
2006 nr = vc->vc_rows - vc->state.y; in csi_M()
2009 con_scroll(vc, vc->state.y, vc->vc_bottom, SM_UP, nr); in csi_M()
2010 vc->vc_need_wrap = 0; in csi_M()
2013 /* console_lock is held (except via vc_init->reset_terminal */
2016 memcpy(&vc->saved_state, &vc->state, sizeof(vc->state)); in save_cur()
2022 memcpy(&vc->state, &vc->saved_state, sizeof(vc->state)); in restore_cur()
2024 gotoxy(vc, vc->state.x, vc->state.y); in restore_cur()
2025 vc->vc_translate = set_translate(vc->state.Gx_charset[vc->state.charset], in restore_cur()
2028 vc->vc_need_wrap = 0; in restore_cur()
2040 vc->vc_top = 0; in reset_terminal()
2041 vc->vc_bottom = vc->vc_rows; in reset_terminal()
2042 vc->vc_state = ESnormal; in reset_terminal()
2043 vc->vc_priv = EPecma; in reset_terminal()
2044 vc->vc_translate = set_translate(LAT1_MAP, vc); in reset_terminal()
2045 vc->state.Gx_charset[0] = LAT1_MAP; in reset_terminal()
2046 vc->state.Gx_charset[1] = GRAF_MAP; in reset_terminal()
2047 vc->state.charset = 0; in reset_terminal()
2048 vc->vc_need_wrap = 0; in reset_terminal()
2049 vc->vc_report_mouse = 0; in reset_terminal()
2050 vc->vc_utf = default_utf8; in reset_terminal()
2051 vc->vc_utf_count = 0; in reset_terminal()
2053 vc->vc_disp_ctrl = 0; in reset_terminal()
2054 vc->vc_toggle_meta = 0; in reset_terminal()
2056 vc->vc_decscnm = 0; in reset_terminal()
2057 vc->vc_decom = 0; in reset_terminal()
2058 vc->vc_decawm = 1; in reset_terminal()
2059 vc->vc_deccm = global_cursor_default; in reset_terminal()
2060 vc->vc_decim = 0; in reset_terminal()
2062 vt_reset_keyboard(vc->vc_num); in reset_terminal()
2064 vc->vc_cursor_type = cur_default; in reset_terminal()
2065 vc->vc_complement_mask = vc->vc_s_complement_mask; in reset_terminal()
2070 bitmap_zero(vc->vc_tab_stop, VC_TABSTOPS_COUNT); in reset_terminal()
2072 set_bit(i, vc->vc_tab_stop); in reset_terminal()
2074 vc->vc_bell_pitch = DEFAULT_BELL_PITCH; in reset_terminal()
2075 vc->vc_bell_duration = DEFAULT_BELL_DURATION; in reset_terminal()
2076 vc->vc_cur_blink_ms = DEFAULT_CURSOR_BLINK_MS; in reset_terminal()
2086 unsigned char *charset = &vc->state.Gx_charset[which]; in vc_setGx()
2103 if (vc->state.charset == which) in vc_setGx()
2104 vc->vc_translate = set_translate(*charset, vc); in vc_setGx()
2122 if (ansi_control_string(vc->vc_state) && c >= 8 && c <= 13) in do_con_trol()
2128 if (ansi_control_string(vc->vc_state)) in do_con_trol()
2129 vc->vc_state = ESnormal; in do_con_trol()
2130 else if (vc->vc_bell_duration) in do_con_trol()
2131 kd_mksound(vc->vc_bell_pitch, vc->vc_bell_duration); in do_con_trol()
2137 vc->vc_pos -= (vc->state.x << 1); in do_con_trol()
2139 vc->state.x = find_next_bit(vc->vc_tab_stop, in do_con_trol()
2140 min(vc->vc_cols - 1, VC_TABSTOPS_COUNT), in do_con_trol()
2141 vc->state.x + 1); in do_con_trol()
2142 if (vc->state.x >= VC_TABSTOPS_COUNT) in do_con_trol()
2143 vc->state.x = vc->vc_cols - 1; in do_con_trol()
2145 vc->vc_pos += (vc->state.x << 1); in do_con_trol()
2157 vc->state.charset = 1; in do_con_trol()
2158 vc->vc_translate = set_translate(vc->state.Gx_charset[1], vc); in do_con_trol()
2159 vc->vc_disp_ctrl = 1; in do_con_trol()
2162 vc->state.charset = 0; in do_con_trol()
2163 vc->vc_translate = set_translate(vc->state.Gx_charset[0], vc); in do_con_trol()
2164 vc->vc_disp_ctrl = 0; in do_con_trol()
2167 vc->vc_state = ESnormal; in do_con_trol()
2170 vc->vc_state = ESesc; in do_con_trol()
2176 vc->vc_state = ESsquare; in do_con_trol()
2179 switch(vc->vc_state) { in do_con_trol()
2181 vc->vc_state = ESnormal; in do_con_trol()
2184 vc->vc_state = ESsquare; in do_con_trol()
2187 vc->vc_state = ESnonstd; in do_con_trol()
2190 vc->vc_state = ESapc; in do_con_trol()
2193 vc->vc_state = ESpm; in do_con_trol()
2196 vc->vc_state = ESpercent; in do_con_trol()
2209 if (vc->state.x < VC_TABSTOPS_COUNT) in do_con_trol()
2210 set_bit(vc->state.x, vc->vc_tab_stop); in do_con_trol()
2213 vc->vc_state = ESdcs; in do_con_trol()
2225 vc->vc_state = ESsetG0; in do_con_trol()
2228 vc->vc_state = ESsetG1; in do_con_trol()
2231 vc->vc_state = EShash; in do_con_trol()
2246 for (vc->vc_npar = 0; vc->vc_npar < NPAR; vc->vc_npar++) in do_con_trol()
2247 vc->vc_par[vc->vc_npar] = 0; in do_con_trol()
2248 vc->vc_npar = 0; in do_con_trol()
2249 vc->vc_state = ESpalette; in do_con_trol()
2253 vc->vc_state = ESnormal; in do_con_trol()
2255 vc->vc_state = ESosc; in do_con_trol()
2257 vc->vc_state = ESnormal; in do_con_trol()
2261 vc->vc_par[vc->vc_npar++] = hex_to_bin(c); in do_con_trol()
2262 if (vc->vc_npar == 7) { in do_con_trol()
2263 int i = vc->vc_par[0] * 3, j = 1; in do_con_trol()
2264 vc->vc_palette[i] = 16 * vc->vc_par[j++]; in do_con_trol()
2265 vc->vc_palette[i++] += vc->vc_par[j++]; in do_con_trol()
2266 vc->vc_palette[i] = 16 * vc->vc_par[j++]; in do_con_trol()
2267 vc->vc_palette[i++] += vc->vc_par[j++]; in do_con_trol()
2268 vc->vc_palette[i] = 16 * vc->vc_par[j++]; in do_con_trol()
2269 vc->vc_palette[i] += vc->vc_par[j]; in do_con_trol()
2271 vc->vc_state = ESnormal; in do_con_trol()
2274 vc->vc_state = ESnormal; in do_con_trol()
2277 for (vc->vc_npar = 0; vc->vc_npar < NPAR; vc->vc_npar++) in do_con_trol()
2278 vc->vc_par[vc->vc_npar] = 0; in do_con_trol()
2279 vc->vc_npar = 0; in do_con_trol()
2280 vc->vc_state = ESgetpars; in do_con_trol()
2282 vc->vc_state=ESfunckey; in do_con_trol()
2287 vc->vc_priv = EPdec; in do_con_trol()
2290 vc->vc_priv = EPgt; in do_con_trol()
2293 vc->vc_priv = EPeq; in do_con_trol()
2296 vc->vc_priv = EPlt; in do_con_trol()
2299 vc->vc_priv = EPecma; in do_con_trol()
2302 if (c == ';' && vc->vc_npar < NPAR - 1) { in do_con_trol()
2303 vc->vc_npar++; in do_con_trol()
2306 vc->vc_par[vc->vc_npar] *= 10; in do_con_trol()
2307 vc->vc_par[vc->vc_npar] += c - '0'; in do_con_trol()
2310 if (c >= 0x20 && c <= 0x3f) { /* 0x2x, 0x3a and 0x3c - 0x3f */ in do_con_trol()
2311 vc->vc_state = EScsiignore; in do_con_trol()
2314 vc->vc_state = ESnormal; in do_con_trol()
2317 if (vc->vc_priv <= EPdec) in do_con_trol()
2321 if (vc->vc_priv <= EPdec) in do_con_trol()
2325 if (vc->vc_priv == EPdec) { in do_con_trol()
2326 if (vc->vc_par[0]) in do_con_trol()
2327 vc->vc_cursor_type = in do_con_trol()
2328 CUR_MAKE(vc->vc_par[0], in do_con_trol()
2329 vc->vc_par[1], in do_con_trol()
2330 vc->vc_par[2]); in do_con_trol()
2332 vc->vc_cursor_type = cur_default; in do_con_trol()
2337 if (vc->vc_priv == EPdec) { in do_con_trol()
2339 if (vc->vc_par[0]) in do_con_trol()
2340 vc->vc_complement_mask = vc->vc_par[0] << 8 | vc->vc_par[1]; in do_con_trol()
2342 vc->vc_complement_mask = vc->vc_s_complement_mask; in do_con_trol()
2347 if (vc->vc_priv == EPecma) { in do_con_trol()
2348 if (vc->vc_par[0] == 5) in do_con_trol()
2350 else if (vc->vc_par[0] == 6) in do_con_trol()
2355 if (vc->vc_priv != EPecma) { in do_con_trol()
2356 vc->vc_priv = EPecma; in do_con_trol()
2361 if (vc->vc_par[0]) in do_con_trol()
2362 vc->vc_par[0]--; in do_con_trol()
2363 gotoxy(vc, vc->vc_par[0], vc->state.y); in do_con_trol()
2366 if (!vc->vc_par[0]) in do_con_trol()
2367 vc->vc_par[0]++; in do_con_trol()
2368 gotoxy(vc, vc->state.x, vc->state.y - vc->vc_par[0]); in do_con_trol()
2371 if (!vc->vc_par[0]) in do_con_trol()
2372 vc->vc_par[0]++; in do_con_trol()
2373 gotoxy(vc, vc->state.x, vc->state.y + vc->vc_par[0]); in do_con_trol()
2376 if (!vc->vc_par[0]) in do_con_trol()
2377 vc->vc_par[0]++; in do_con_trol()
2378 gotoxy(vc, vc->state.x + vc->vc_par[0], vc->state.y); in do_con_trol()
2381 if (!vc->vc_par[0]) in do_con_trol()
2382 vc->vc_par[0]++; in do_con_trol()
2383 gotoxy(vc, vc->state.x - vc->vc_par[0], vc->state.y); in do_con_trol()
2386 if (!vc->vc_par[0]) in do_con_trol()
2387 vc->vc_par[0]++; in do_con_trol()
2388 gotoxy(vc, 0, vc->state.y + vc->vc_par[0]); in do_con_trol()
2391 if (!vc->vc_par[0]) in do_con_trol()
2392 vc->vc_par[0]++; in do_con_trol()
2393 gotoxy(vc, 0, vc->state.y - vc->vc_par[0]); in do_con_trol()
2396 if (vc->vc_par[0]) in do_con_trol()
2397 vc->vc_par[0]--; in do_con_trol()
2398 gotoxay(vc, vc->state.x ,vc->vc_par[0]); in do_con_trol()
2401 if (vc->vc_par[0]) in do_con_trol()
2402 vc->vc_par[0]--; in do_con_trol()
2403 if (vc->vc_par[1]) in do_con_trol()
2404 vc->vc_par[1]--; in do_con_trol()
2405 gotoxay(vc, vc->vc_par[1], vc->vc_par[0]); in do_con_trol()
2408 csi_J(vc, vc->vc_par[0]); in do_con_trol()
2411 csi_K(vc, vc->vc_par[0]); in do_con_trol()
2414 csi_L(vc, vc->vc_par[0]); in do_con_trol()
2417 csi_M(vc, vc->vc_par[0]); in do_con_trol()
2420 csi_P(vc, vc->vc_par[0]); in do_con_trol()
2423 if (!vc->vc_par[0]) in do_con_trol()
2427 if (!vc->vc_par[0] && vc->state.x < VC_TABSTOPS_COUNT) in do_con_trol()
2428 set_bit(vc->state.x, vc->vc_tab_stop); in do_con_trol()
2429 else if (vc->vc_par[0] == 3) in do_con_trol()
2430 bitmap_zero(vc->vc_tab_stop, VC_TABSTOPS_COUNT); in do_con_trol()
2435 case 'q': /* DECLL - but only 3 leds */ in do_con_trol()
2437 if (vc->vc_par[0] < 4) in do_con_trol()
2438 vt_set_led_state(vc->vc_num, in do_con_trol()
2439 (vc->vc_par[0] < 3) ? vc->vc_par[0] : 4); in do_con_trol()
2442 if (!vc->vc_par[0]) in do_con_trol()
2443 vc->vc_par[0]++; in do_con_trol()
2444 if (!vc->vc_par[1]) in do_con_trol()
2445 vc->vc_par[1] = vc->vc_rows; in do_con_trol()
2447 if (vc->vc_par[0] < vc->vc_par[1] && in do_con_trol()
2448 vc->vc_par[1] <= vc->vc_rows) { in do_con_trol()
2449 vc->vc_top = vc->vc_par[0] - 1; in do_con_trol()
2450 vc->vc_bottom = vc->vc_par[1]; in do_con_trol()
2461 csi_X(vc, vc->vc_par[0]); in do_con_trol()
2464 csi_at(vc, vc->vc_par[0]); in do_con_trol()
2474 vc->vc_state = ESnormal; in do_con_trol()
2477 vc->vc_state = ESnormal; in do_con_trol()
2480 vc->vc_utf = 0; in do_con_trol()
2484 vc->vc_utf = 1; in do_con_trol()
2489 vc->vc_state = ESnormal; in do_con_trol()
2492 vc->vc_state = ESnormal; in do_con_trol()
2494 /* DEC screen alignment test. kludge :-) */ in do_con_trol()
2495 vc->vc_video_erase_char = in do_con_trol()
2496 (vc->vc_video_erase_char & 0xff00) | 'E'; in do_con_trol()
2498 vc->vc_video_erase_char = in do_con_trol()
2499 (vc->vc_video_erase_char & 0xff00) | ' '; in do_con_trol()
2500 do_update_region(vc, vc->vc_origin, vc->vc_screenbuf_size / 2); in do_con_trol()
2505 vc->vc_state = ESnormal; in do_con_trol()
2509 vc->vc_state = ESnormal; in do_con_trol()
2520 vc->vc_state = ESnormal; in do_con_trol()
2525 * Markus Kuhn -- 2007-05-26 (Unicode 5.0)
2541 return -1; in ucs_cmp()
2554 ucs > double_width[ARRAY_SIZE(double_width) - 1].last) in is_double_width()
2568 if (draw->x < 0) in con_flush()
2571 vc->vc_sw->con_putcs(vc, (u16 *)draw->from, in con_flush()
2572 (u16 *)draw->to - (u16 *)draw->from, vc->state.y, in con_flush()
2573 draw->x); in con_flush()
2574 draw->x = -1; in con_flush()
2580 if (vc->vc_toggle_meta) in vc_translate_ascii()
2583 return vc->vc_translate[c]; in vc_translate_ascii()
2591 * vc_sanitize_unicode -- Replace invalid Unicode code points with U+FFFD
2603 * vc_translate_unicode -- Combine UTF-8 into Unicode in @vc_utf_char
2608 * @vc_utf_char is the being-constructed unicode character.
2622 if (!vc->vc_utf_count) in vc_translate_unicode()
2625 vc->vc_utf_char = (vc->vc_utf_char << 6) | (c & 0x3f); in vc_translate_unicode()
2626 vc->vc_npar++; in vc_translate_unicode()
2627 if (--vc->vc_utf_count) in vc_translate_unicode()
2631 c = vc->vc_utf_char; in vc_translate_unicode()
2633 if (c <= utf8_length_changes[vc->vc_npar - 1] || in vc_translate_unicode()
2634 c > utf8_length_changes[vc->vc_npar]) in vc_translate_unicode()
2641 if (vc->vc_utf_count) { in vc_translate_unicode()
2644 vc->vc_utf_count = 0; in vc_translate_unicode()
2653 vc->vc_npar = 0; in vc_translate_unicode()
2655 vc->vc_utf_count = 1; in vc_translate_unicode()
2656 vc->vc_utf_char = (c & 0x1f); in vc_translate_unicode()
2658 vc->vc_utf_count = 2; in vc_translate_unicode()
2659 vc->vc_utf_char = (c & 0x0f); in vc_translate_unicode()
2661 vc->vc_utf_count = 3; in vc_translate_unicode()
2662 vc->vc_utf_char = (c & 0x07); in vc_translate_unicode()
2664 vc->vc_utf_count = 4; in vc_translate_unicode()
2665 vc->vc_utf_char = (c & 0x03); in vc_translate_unicode()
2667 vc->vc_utf_count = 5; in vc_translate_unicode()
2668 vc->vc_utf_char = (c & 0x01); in vc_translate_unicode()
2675 return -1; in vc_translate_unicode()
2681 if (vc->vc_state != ESnormal) in vc_translate()
2684 if (vc->vc_utf && !vc->vc_disp_ctrl) in vc_translate()
2693 if (!vc->vc_can_do_color) in vc_invert_attr()
2694 return vc->vc_attr ^ 0x08; in vc_invert_attr()
2696 if (vc->vc_hi_font_mask == 0x100) in vc_invert_attr()
2697 return (vc->vc_attr & 0x11) | in vc_invert_attr()
2698 ((vc->vc_attr & 0xe0) >> 4) | in vc_invert_attr()
2699 ((vc->vc_attr & 0x0e) << 4); in vc_invert_attr()
2701 return (vc->vc_attr & 0x88) | in vc_invert_attr()
2702 ((vc->vc_attr & 0x70) >> 4) | in vc_invert_attr()
2703 ((vc->vc_attr & 0x07) << 4); in vc_invert_attr()
2718 if (vc->vc_state != ESnormal) in vc_is_control()
2730 * useless without them; to display an arbitrary font position use the in vc_is_control()
2731 * direct-to-font zone in UTF-8 mode. in vc_is_control()
2734 if (vc->vc_disp_ctrl) in vc_is_control()
2737 return vc->vc_utf || (CTRL_ACTION & BIT(c)); in vc_is_control()
2740 if (c == 127 && !vc->vc_disp_ctrl) in vc_is_control()
2753 unsigned char vc_attr = vc->vc_attr; in vc_con_write_normal()
2754 u16 himask = vc->vc_hi_font_mask, charmask = himask ? 0x1ff : 0xff; in vc_con_write_normal()
2755 u8 width = 1; in vc_con_write_normal() local
2758 if (vc->vc_utf && !vc->vc_disp_ctrl) { in vc_con_write_normal()
2760 width = 2; in vc_con_write_normal()
2763 /* Now try to find out how to display it */ in vc_con_write_normal()
2766 if (tc == -1 || tc == -2) in vc_con_write_normal()
2767 return -1; /* nothing to display */ in vc_con_write_normal()
2770 if ((!vc->vc_utf || vc->vc_disp_ctrl || c < 128) && in vc_con_write_normal()
2783 * Display U+FFFD. If it's not found, display an inverse in vc_con_write_normal()
2801 if (vc->vc_need_wrap || vc->vc_decim) in vc_con_write_normal()
2803 if (vc->vc_need_wrap) { in vc_con_write_normal()
2807 if (vc->vc_decim) in vc_con_write_normal()
2816 scr_writew(tc, (u16 *)vc->vc_pos); in vc_con_write_normal()
2818 if (con_should_update(vc) && draw->x < 0) { in vc_con_write_normal()
2819 draw->x = vc->state.x; in vc_con_write_normal()
2820 draw->from = vc->vc_pos; in vc_con_write_normal()
2822 if (vc->state.x == vc->vc_cols - 1) { in vc_con_write_normal()
2823 vc->vc_need_wrap = vc->vc_decawm; in vc_con_write_normal()
2824 draw->to = vc->vc_pos + 2; in vc_con_write_normal()
2826 vc->state.x++; in vc_con_write_normal()
2827 draw->to = (vc->vc_pos += 2); in vc_con_write_normal()
2830 if (!--width) in vc_con_write_normal()
2851 .x = -1, in do_con_write()
2863 vc = tty->driver_data; in do_con_write()
2870 currcons = vc->vc_num; in do_con_write()
2885 while (!tty->flow.stopped && count) { in do_con_write()
2889 count--; in do_con_write()
2895 if (tc == -1) in do_con_write()
2928 * with other console code and prevention of re-entrancy is
2941 been allocated - a new console is not created in console_callback()
2944 want_console = -1; in console_callback()
2953 if (vc->vc_mode == KD_TEXT && vc->vc_sw->con_scrolldelta) in console_callback()
2954 vc->vc_sw->con_scrolldelta(vc, scrollback_delta); in console_callback()
2971 (vc->vt_mode.mode == VT_AUTO && vc->vc_mode == KD_GRAPHICS)) { in set_console()
2981 return -EINVAL; in set_console()
2995 * vt_kmsg_redirect() - Sets/gets the kernel message console
2996 * @new: The new virtual terminal number or -1 if the console should stay
3008 * The parameter -1 means that only the current console is returned, but the
3019 if (new != -1) in vt_kmsg_redirect()
3047 if (kmsg_console && vc_cons_allocated(kmsg_console - 1)) in vt_console_print()
3048 vc = vc_cons[kmsg_console - 1].d; in vt_console_print()
3056 if (vc->vc_mode != KD_TEXT) in vt_console_print()
3063 start = (ushort *)vc->vc_pos; in vt_console_print()
3064 start_x = vc->state.x; in vt_console_print()
3066 while (count--) { in vt_console_print()
3068 if (c == 10 || c == 13 || c == 8 || vc->vc_need_wrap) { in vt_console_print()
3070 vc->vc_sw->con_putcs(vc, start, cnt, vc->state.y, start_x); in vt_console_print()
3074 start = (ushort *)vc->vc_pos; in vt_console_print()
3075 start_x = vc->state.x; in vt_console_print()
3081 start = (ushort *)vc->vc_pos; in vt_console_print()
3082 start_x = vc->state.x; in vt_console_print()
3087 scr_writew((vc->vc_attr << 8) + c, (unsigned short *)vc->vc_pos); in vt_console_print()
3090 if (vc->state.x == vc->vc_cols - 1) { in vt_console_print()
3091 vc->vc_need_wrap = 1; in vt_console_print()
3093 vc->vc_pos += 2; in vt_console_print()
3094 vc->state.x++; in vt_console_print()
3098 vc->vc_sw->con_putcs(vc, start, cnt, vc->state.y, start_x); in vt_console_print()
3108 *index = c->index ? c->index-1 : fg_console; in vt_console_device()
3114 return co->index >= MAX_NR_CONSOLES ? -EINVAL : 0; in vt_console_setup()
3124 .index = -1,
3129 * Handling of Linux-specific VC ioctls
3150 if (current->signal->tty != tty && !capable(CAP_SYS_ADMIN)) in tioclinux()
3151 return -EPERM; in tioclinux()
3153 return -EFAULT; in tioclinux()
3175 * 'shift_state' is an undocumented kernel-internal variable; in tioclinux()
3196 return -EPERM; in tioclinux()
3199 return -EFAULT; in tioclinux()
3212 return -EFAULT; in tioclinux()
3231 return -EINVAL; in tioclinux()
3258 if (tty->flow.stopped) in con_write_room()
3274 struct vc_data *vc = tty->driver_data; in con_unthrottle()
3276 wake_up_interruptible(&vc->paste_wait); in con_unthrottle()
3280 * Turn the Scroll-Lock LED on when the tty is stopped
3287 console_num = tty->index; in con_stop()
3294 * Turn the Scroll-Lock LED off when the console is started
3301 console_num = tty->index; in con_start()
3316 vc = tty->driver_data; in con_flush_chars()
3327 unsigned int currcons = tty->index; in con_install()
3339 if (vc->port.tty) { in con_install()
3340 ret = -ERESTARTSYS; in con_install()
3344 ret = tty_port_install(&vc->port, driver, tty); in con_install()
3348 tty->driver_data = vc; in con_install()
3349 vc->port.tty = tty; in con_install()
3350 tty_port_get(&vc->port); in con_install()
3352 if (!tty->winsize.ws_row && !tty->winsize.ws_col) { in con_install()
3353 tty->winsize.ws_row = vc_cons[currcons].d->vc_rows; in con_install()
3354 tty->winsize.ws_col = vc_cons[currcons].d->vc_cols; in con_install()
3356 if (vc->vc_utf) in con_install()
3357 tty->termios.c_iflag |= IUTF8; in con_install()
3359 tty->termios.c_iflag &= ~IUTF8; in con_install()
3374 /* Nothing to do - we defer to shutdown */ in con_close()
3379 struct vc_data *vc = tty->driver_data; in con_shutdown()
3382 vc->port.tty = NULL; in con_shutdown()
3388 struct vc_data *vc = tty->driver_data; in con_cleanup()
3390 tty_port_put(&vc->port); in con_cleanup()
3399 return ldisc == N_TTY ? 0 : -EINVAL; in con_ldisc_ok()
3414 vc->vc_pos = vc->vc_origin; in vc_init()
3417 vc->vc_palette[k++] = default_red[j] ; in vc_init()
3418 vc->vc_palette[k++] = default_grn[j] ; in vc_init()
3419 vc->vc_palette[k++] = default_blu[j] ; in vc_init()
3421 vc->vc_def_color = default_color; in vc_init()
3422 vc->vc_ulcolor = default_underline_color; in vc_init()
3423 vc->vc_itcolor = default_italic_color; in vc_init()
3424 vc->vc_halfcolor = 0x08; /* grey */ in vc_init()
3425 init_waitqueue_head(&vc->paste_wait); in vc_init()
3432 * the appropriate escape-sequence.
3445 display_desc = conswitchp->con_startup(); in con_init()
3455 if (con_driver->con == NULL) { in con_init()
3456 con_driver->con = conswitchp; in con_init()
3457 con_driver->desc = display_desc; in con_init()
3458 con_driver->flag = CON_DRIVER_FLAG_INIT; in con_init()
3459 con_driver->first = 0; in con_init()
3460 con_driver->last = MAX_NR_CONSOLES - 1; in con_init()
3476 tty_port_init(&vc->port); in con_init()
3478 /* Assuming vc->vc_{cols,rows,screenbuf_size} are sane here. */ in con_init()
3479 vc->vc_screenbuf = kzalloc(vc->vc_screenbuf_size, GFP_NOWAIT); in con_init()
3480 vc_init(vc, currcons || !vc->vc_sw->con_save_screen); in con_init()
3486 gotoxy(vc, vc->state.x, vc->state.y); in con_init()
3490 vc->vc_can_do_color ? "colour" : "mono", in con_init()
3491 display_desc, vc->vc_cols, vc->vc_rows); in con_init()
3559 console_driver->name = "tty"; in vty_init()
3560 console_driver->name_base = 1; in vty_init()
3561 console_driver->major = TTY_MAJOR; in vty_init()
3562 console_driver->minor_start = 1; in vty_init()
3563 console_driver->type = TTY_DRIVER_TYPE_CONSOLE; in vty_init()
3564 console_driver->init_termios = tty_std_termios; in vty_init()
3566 console_driver->init_termios.c_iflag |= IUTF8; in vty_init()
3583 struct module *owner = csw->owner; in do_bind_con_driver()
3586 int i, j = -1, k = -1, retval = -ENODEV; in do_bind_con_driver()
3589 return -ENODEV; in do_bind_con_driver()
3597 if (con_driver->con == csw) { in do_bind_con_driver()
3598 desc = con_driver->desc; in do_bind_con_driver()
3607 if (!(con_driver->flag & CON_DRIVER_FLAG_INIT)) { in do_bind_con_driver()
3608 csw->con_startup(); in do_bind_con_driver()
3609 con_driver->flag |= CON_DRIVER_FLAG_INIT; in do_bind_con_driver()
3614 module_put(conswitchp->owner); in do_bind_con_driver()
3620 first = max(first, con_driver->first); in do_bind_con_driver()
3621 last = min(last, con_driver->last); in do_bind_con_driver()
3628 module_put(con_driver_map[i]->owner); in do_bind_con_driver()
3632 if (!vc || !vc->vc_sw) in do_bind_con_driver()
3642 old_was_color = vc->vc_can_do_color; in do_bind_con_driver()
3643 vc->vc_sw->con_deinit(vc); in do_bind_con_driver()
3644 vc->vc_origin = (unsigned long)vc->vc_screenbuf; in do_bind_con_driver()
3649 /* If the console changed between mono <-> color, then in do_bind_con_driver()
3653 if (old_was_color != vc->vc_can_do_color) in do_bind_con_driver()
3659 pr_cont("consoles %d-%d ", first + 1, last + 1); in do_bind_con_driver()
3664 vc->vc_can_do_color ? "colour" : "mono", in do_bind_con_driver()
3665 desc, vc->vc_cols, vc->vc_rows); in do_bind_con_driver()
3685 struct module *owner = csw->owner; in do_unbind_con_driver()
3688 int i, retval = -ENODEV; in do_unbind_con_driver()
3691 return -ENODEV; in do_unbind_con_driver()
3699 if (con_driver->con == csw && in do_unbind_con_driver()
3700 con_driver->flag & CON_DRIVER_FLAG_MODULE) { in do_unbind_con_driver()
3709 retval = -ENODEV; in do_unbind_con_driver()
3715 if (con_back->con && con_back->con != csw) { in do_unbind_con_driver()
3716 defcsw = con_back->con; in do_unbind_con_driver()
3728 first = max(first, con_driver->first); in do_unbind_con_driver()
3729 last = min(last, con_driver->last); in do_unbind_con_driver()
3733 module_put(csw->owner); in do_unbind_con_driver()
3741 defcsw->con_startup(); in do_unbind_con_driver()
3742 con_back->flag |= CON_DRIVER_FLAG_INIT; in do_unbind_con_driver()
3751 con_driver->flag &= ~CON_DRIVER_FLAG_INIT; in do_unbind_con_driver()
3765 int i, more = 1, first = -1, last = -1, deflt = 0; in vt_bind()
3767 if (!con->con || !(con->flag & CON_DRIVER_FLAG_MODULE)) in vt_bind()
3770 csw = con->con; in vt_bind()
3775 if (con->con && !(con->flag & CON_DRIVER_FLAG_MODULE)) { in vt_bind()
3776 defcsw = con->con; in vt_bind()
3787 for (i = con->first; i <= con->last; i++) { in vt_bind()
3789 if (first == -1) in vt_bind()
3793 } else if (first != -1) in vt_bind()
3797 if (first == 0 && last == MAX_NR_CONSOLES -1) in vt_bind()
3800 if (first != -1) in vt_bind()
3803 first = -1; in vt_bind()
3804 last = -1; in vt_bind()
3815 int i, more = 1, first = -1, last = -1, deflt = 0; in vt_unbind()
3818 if (!con->con || !(con->flag & CON_DRIVER_FLAG_MODULE)) in vt_unbind()
3821 csw = con->con; in vt_unbind()
3826 for (i = con->first; i <= con->last; i++) { in vt_unbind()
3828 if (first == -1) in vt_unbind()
3832 } else if (first != -1) in vt_unbind()
3836 if (first == 0 && last == MAX_NR_CONSOLES -1) in vt_unbind()
3839 if (first != -1) { in vt_unbind()
3845 first = -1; in vt_unbind()
3846 last = -1; in vt_unbind()
3889 bind = con_is_bound(con->con); in show_bind()
3901 (con->flag & CON_DRIVER_FLAG_MODULE) ? "(M)" : "(S)", in show_name()
3902 con->desc); in show_name()
3919 con->flag |= CON_DRIVER_FLAG_ATTR; in vtconsole_init_device()
3925 con->flag &= ~CON_DRIVER_FLAG_ATTR; in vtconsole_deinit_device()
3929 * con_is_bound - checks if driver is bound to the console
3955 * con_is_visible - checks whether the current console is visible
3964 return *vc->vc_display_fg == vc; in con_is_visible()
3969 * con_debug_enter - prepare the console for the kernel debugger
3987 saved_vc_mode = vc->vc_mode; in con_debug_enter()
3989 vc->vc_mode = KD_TEXT; in con_debug_enter()
3991 if (vc->vc_sw->con_debug_enter) in con_debug_enter()
3992 ret = vc->vc_sw->con_debug_enter(vc); in con_debug_enter()
3995 if (vc->vc_rows < 999) { in con_debug_enter()
4004 snprintf(lns, 4, "%i", vc->vc_rows); in con_debug_enter()
4008 if (vc->vc_cols < 999) { in con_debug_enter()
4017 snprintf(cols, 4, "%i", vc->vc_cols); in con_debug_enter()
4027 * con_debug_leave - restore console state
4045 vc_cons[fg_console].d->vc_mode = saved_vc_mode; in con_debug_leave()
4048 if (vc->vc_sw->con_debug_leave) in con_debug_leave()
4049 ret = vc->vc_sw->con_debug_leave(vc); in con_debug_leave()
4056 struct module *owner = csw->owner; in do_register_con_driver()
4064 return -ENODEV; in do_register_con_driver()
4070 if (con_driver->con == csw) { in do_register_con_driver()
4071 retval = -EBUSY; in do_register_con_driver()
4076 desc = csw->con_startup(); in do_register_con_driver()
4078 retval = -ENODEV; in do_register_con_driver()
4082 retval = -EINVAL; in do_register_con_driver()
4087 if (con_driver->con == NULL && in do_register_con_driver()
4088 !(con_driver->flag & CON_DRIVER_FLAG_ZOMBIE)) { in do_register_con_driver()
4089 con_driver->con = csw; in do_register_con_driver()
4090 con_driver->desc = desc; in do_register_con_driver()
4091 con_driver->node = i; in do_register_con_driver()
4092 con_driver->flag = CON_DRIVER_FLAG_MODULE | in do_register_con_driver()
4094 con_driver->first = first; in do_register_con_driver()
4095 con_driver->last = last; in do_register_con_driver()
4104 con_driver->dev = in do_register_con_driver()
4106 MKDEV(0, con_driver->node), in do_register_con_driver()
4108 "vtcon%i", con_driver->node); in do_register_con_driver()
4109 if (IS_ERR(con_driver->dev)) { in do_register_con_driver()
4111 con_driver->desc, PTR_ERR(con_driver->dev)); in do_register_con_driver()
4112 con_driver->dev = NULL; in do_register_con_driver()
4124 * do_unregister_con_driver - unregister console driver from console layer
4140 return -EBUSY; in do_unregister_con_driver()
4143 return -EINVAL; in do_unregister_con_driver()
4148 if (con_driver->con == csw) { in do_unregister_con_driver()
4159 con_driver->con = NULL; in do_unregister_con_driver()
4160 con_driver->flag = CON_DRIVER_FLAG_ZOMBIE; in do_unregister_con_driver()
4167 return -ENODEV; in do_unregister_con_driver()
4180 if (!(con_driver->flag & CON_DRIVER_FLAG_ZOMBIE)) in con_driver_unregister_callback()
4186 device_destroy(vtconsole_class, MKDEV(0, con_driver->node)); in con_driver_unregister_callback()
4190 if (WARN_ON_ONCE(con_driver->con)) in con_driver_unregister_callback()
4191 con_driver->con = NULL; in con_driver_unregister_callback()
4192 con_driver->desc = NULL; in con_driver_unregister_callback()
4193 con_driver->dev = NULL; in con_driver_unregister_callback()
4194 con_driver->node = 0; in con_driver_unregister_callback()
4195 WARN_ON_ONCE(con_driver->flag != CON_DRIVER_FLAG_ZOMBIE); in con_driver_unregister_callback()
4196 con_driver->flag = 0; in con_driver_unregister_callback()
4197 con_driver->first = 0; in con_driver_unregister_callback()
4198 con_driver->last = 0; in con_driver_unregister_callback()
4221 if (err == -EBUSY) in do_take_over_console()
4258 if (con->con && !con->dev) { in vtconsole_class_init()
4259 con->dev = in vtconsole_class_init()
4261 MKDEV(0, con->node), in vtconsole_class_init()
4263 "vtcon%i", con->node); in vtconsole_class_init()
4265 if (IS_ERR(con->dev)) { in vtconsole_class_init()
4267 con->desc, PTR_ERR(con->dev)); in vtconsole_class_init()
4268 con->dev = NULL; in vtconsole_class_init()
4288 return -EFAULT; in set_vesa_blanking()
4306 vc->vc_sw->con_blank(vc, vesa_blank_mode + 1, 0); in do_blank_screen()
4315 vc->vc_sw->con_blank(vc, -1, 1); in do_blank_screen()
4325 if (vc->vc_mode != KD_TEXT) { in do_blank_screen()
4336 i = vc->vc_sw->con_blank(vc, vesa_off_interval ? 1 : (vesa_blank_mode + 1), 0); in do_blank_screen()
4348 vt_event_post(VT_EVENT_BLANK, vc->vc_num, vc->vc_num); in do_blank_screen()
4378 if (vc->vc_mode != KD_TEXT) in do_unblank_screen()
4387 if (vc->vc_sw->con_blank(vc, 0, leaving_gfx)) in do_unblank_screen()
4388 /* Low-level driver cannot restore -> do it ourselves */ in do_unblank_screen()
4394 vt_event_post(VT_EVENT_UNBLANK, vc->vc_num, vc->vc_num); in do_unblank_screen()
4428 * function. --BenH. in poke_blanked_console()
4438 if (ignore_poke || !vc_cons[fg_console].d || vc_cons[fg_console].d->vc_mode == KD_GRAPHICS) in poke_blanked_console()
4456 if (vc->vc_mode != KD_GRAPHICS && vc->vc_sw->con_set_palette) in set_palette()
4457 vc->vc_sw->con_set_palette(vc, color_table); in set_palette()
4471 return -EFAULT; in con_set_cmap()
4483 vc_cons[i].d->vc_palette[k++] = default_red[j]; in con_set_cmap()
4484 vc_cons[i].d->vc_palette[k++] = default_grn[j]; in con_set_cmap()
4485 vc_cons[i].d->vc_palette[k++] = default_blu[j]; in con_set_cmap()
4508 return -EFAULT; in con_get_cmap()
4517 vc->vc_palette[k++] = default_red[j]; in reset_palette()
4518 vc->vc_palette[k++] = default_grn[j]; in reset_palette()
4519 vc->vc_palette[k++] = default_blu[j]; in reset_palette()
4529 * (shorts/ints, depending on width) reserved for each character which is
4531 * EGA/VGA fonts. It is up to the actual low-level console-driver convert data
4533 * `display' structure so we won't have to convert the fontdata all the time.
4545 int rc = -EINVAL; in con_font_get()
4547 unsigned int vpitch = op->op == KD_FONT_OP_GET_TALL ? op->height : 32; in con_font_get()
4550 return -EINVAL; in con_font_get()
4552 if (op->data) { in con_font_get()
4555 return -ENOMEM; in con_font_get()
4560 if (vc->vc_mode != KD_TEXT) in con_font_get()
4561 rc = -EINVAL; in con_font_get()
4562 else if (vc->vc_sw->con_font_get) in con_font_get()
4563 rc = vc->vc_sw->con_font_get(vc, &font, vpitch); in con_font_get()
4565 rc = -ENOSYS; in con_font_get()
4571 c = (font.width+7)/8 * vpitch * font.charcount; in con_font_get()
4573 if (op->data && font.charcount > op->charcount) in con_font_get()
4574 rc = -ENOSPC; in con_font_get()
4575 if (font.width > op->width || font.height > op->height) in con_font_get()
4576 rc = -ENOSPC; in con_font_get()
4580 op->height = font.height; in con_font_get()
4581 op->width = font.width; in con_font_get()
4582 op->charcount = font.charcount; in con_font_get()
4584 if (op->data && copy_to_user(op->data, font.data, c)) in con_font_get()
4585 rc = -EFAULT; in con_font_get()
4595 int rc = -EINVAL; in con_font_set()
4597 unsigned int vpitch = op->op == KD_FONT_OP_SET_TALL ? op->height : 32; in con_font_set()
4599 if (vc->vc_mode != KD_TEXT) in con_font_set()
4600 return -EINVAL; in con_font_set()
4601 if (!op->data) in con_font_set()
4602 return -EINVAL; in con_font_set()
4603 if (op->charcount > max_font_glyphs) in con_font_set()
4604 return -EINVAL; in con_font_set()
4605 if (op->width <= 0 || op->width > max_font_width || !op->height || in con_font_set()
4606 op->height > max_font_height) in con_font_set()
4607 return -EINVAL; in con_font_set()
4608 if (vpitch < op->height) in con_font_set()
4609 return -EINVAL; in con_font_set()
4610 size = (op->width+7)/8 * vpitch * op->charcount; in con_font_set()
4612 return -ENOSPC; in con_font_set()
4614 font.data = memdup_user(op->data, size); in con_font_set()
4618 font.charcount = op->charcount; in con_font_set()
4619 font.width = op->width; in con_font_set()
4620 font.height = op->height; in con_font_set()
4623 if (vc->vc_mode != KD_TEXT) in con_font_set()
4624 rc = -EINVAL; in con_font_set()
4625 else if (vc->vc_sw->con_font_set) { in con_font_set()
4628 rc = vc->vc_sw->con_font_set(vc, &font, vpitch, op->flags); in con_font_set()
4630 rc = -ENOSYS; in con_font_set()
4638 struct console_font font = {.width = op->width, .height = op->height}; in con_font_default()
4644 if (!op->data) in con_font_default()
4646 else if (strncpy_from_user(name, op->data, MAX_FONT_NAME - 1) < 0) in con_font_default()
4647 return -EFAULT; in con_font_default()
4649 name[MAX_FONT_NAME - 1] = 0; in con_font_default()
4652 if (vc->vc_mode != KD_TEXT) { in con_font_default()
4654 return -EINVAL; in con_font_default()
4656 if (vc->vc_sw->con_font_default) { in con_font_default()
4659 rc = vc->vc_sw->con_font_default(vc, &font, s); in con_font_default()
4661 rc = -ENOSYS; in con_font_default()
4664 op->width = font.width; in con_font_default()
4665 op->height = font.height; in con_font_default()
4672 switch (op->op) { in con_font_op()
4683 return -EINVAL; in con_font_op()
4685 return -ENOSYS; in con_font_op()
4698 if (w & vc->vc_hi_font_mask) in screen_glyph()
4706 u32 **uni_lines = vc->vc_uni_lines; in screen_glyph_unicode()
4709 return uni_lines[n / vc->vc_cols][n % vc->vc_cols]; in screen_glyph_unicode()
4715 /* used by vcs - note the word offset */
4725 xy[0] = min(vc->state.x, 0xFFu); in getconsxy()
4726 xy[1] = min(vc->state.y, 0xFFu); in getconsxy()
4738 if ((unsigned long)org == vc->vc_pos && softcursor_original != -1) in vcs_scr_readw()
4746 if ((unsigned long)org == vc->vc_pos) { in vcs_scr_writew()
4747 softcursor_original = -1; in vcs_scr_writew()
4761 ptrdiff_t scr_end = (void *)c->vc_scr_end - base; in vc_scrolldelta_helper()
4762 ptrdiff_t vorigin = (void *)c->vc_visible_origin - base; in vc_scrolldelta_helper()
4763 ptrdiff_t origin = (void *)c->vc_origin - base; in vc_scrolldelta_helper()
4764 int margin = c->vc_size_row * 4; in vc_scrolldelta_helper()
4769 c->vc_visible_origin = c->vc_origin; in vc_scrolldelta_helper()
4776 wrap = rolled_over + c->vc_size_row; in vc_scrolldelta_helper()
4782 from_off = (vorigin - from + wrap) % wrap + lines * c->vc_size_row; in vc_scrolldelta_helper()
4783 avail = (origin - from + wrap) % wrap; in vc_scrolldelta_helper()
4790 if (from_off > avail - margin) in vc_scrolldelta_helper()
4793 c->vc_visible_origin = ubase + (from + from_off) % wrap; in vc_scrolldelta_helper()