Lines Matching +full:swap +full:- +full:xy
1 // SPDX-License-Identifier: GPL-2.0
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;
206 * appropriately. Unless the low-level driver supplies its own display_fg
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()
292 unsigned long origin = viewed ? vc->vc_visible_origin : vc->vc_origin; in screenpos()
299 if (vc->vc_sw->con_putc) in con_putc()
300 vc->vc_sw->con_putc(vc, ca, y, x); in con_putc()
302 vc->vc_sw->con_putcs(vc, &ca, 1, y, x); in con_putc()
321 * Code to manage unicode-based screen buffers
359 vc_uniscr_free(vc->vc_uni_lines); in vc_uniscr_set()
360 vc->vc_uni_lines = new_uni_lines; in vc_uniscr_set()
365 if (vc->vc_uni_lines) in vc_uniscr_putc()
366 vc->vc_uni_lines[vc->state.y][vc->state.x] = uc; in vc_uniscr_putc()
371 if (vc->vc_uni_lines) { in vc_uniscr_insert()
372 u32 *ln = vc->vc_uni_lines[vc->state.y]; in vc_uniscr_insert()
373 unsigned int x = vc->state.x, cols = vc->vc_cols; in vc_uniscr_insert()
375 memmove(&ln[x + nr], &ln[x], (cols - x - nr) * sizeof(*ln)); in vc_uniscr_insert()
382 if (vc->vc_uni_lines) { in vc_uniscr_delete()
383 u32 *ln = vc->vc_uni_lines[vc->state.y]; in vc_uniscr_delete()
384 unsigned int x = vc->state.x, cols = vc->vc_cols; in vc_uniscr_delete()
386 memmove(&ln[x], &ln[x + nr], (cols - x - nr) * sizeof(*ln)); in vc_uniscr_delete()
387 memset32(&ln[cols - nr], ' ', nr); in vc_uniscr_delete()
394 if (vc->vc_uni_lines) in vc_uniscr_clear_line()
395 memset32(&vc->vc_uni_lines[vc->state.y][x], ' ', nr); in vc_uniscr_clear_line()
401 if (vc->vc_uni_lines) in vc_uniscr_clear_lines()
402 while (nr--) in vc_uniscr_clear_lines()
403 memset32(vc->vc_uni_lines[y++], ' ', vc->vc_cols); in vc_uniscr_clear_lines()
432 u32 **uni_lines = vc->vc_uni_lines; in vc_uniscr_scroll()
433 unsigned int size = bottom - top; in vc_uniscr_scroll()
439 juggle_array(&uni_lines[top], size, size - nr); in vc_uniscr_scroll()
443 vc_uniscr_clear_lines(vc, bottom - nr, nr); in vc_uniscr_scroll()
465 if (dst_cols - src_cols) in vc_uniscr_copy_area()
466 memset32(dst_line + src_cols, ' ', dst_cols - src_cols); in vc_uniscr_copy_area()
482 * In particular, -ENODATA is returned if the console is not in UTF-8 mode.
492 if (!vc->vc_utf) in vc_uniscr_check()
493 return -ENODATA; in vc_uniscr_check()
495 if (vc->vc_uni_lines) in vc_uniscr_check()
498 uni_lines = vc_uniscr_alloc(vc->vc_cols, vc->vc_rows); in vc_uniscr_check()
500 return -ENOMEM; in vc_uniscr_check()
508 p = (unsigned short *)vc->vc_origin; in vc_uniscr_check()
509 mask = vc->vc_hi_font_mask | 0xff; in vc_uniscr_check()
510 for (y = 0; y < vc->vc_rows; y++) { in vc_uniscr_check()
512 for (x = 0; x < vc->vc_cols; x++) { in vc_uniscr_check()
518 vc->vc_uni_lines = uni_lines; in vc_uniscr_check()
531 u32 **uni_lines = vc->vc_uni_lines; in vc_uniscr_copy_line()
532 int offset = row * vc->vc_size_row + col * 2; in vc_uniscr_copy_line()
539 if (pos >= vc->vc_origin && pos < vc->vc_scr_end) { in vc_uniscr_copy_line()
545 row = (pos - vc->vc_origin) / vc->vc_size_row; in vc_uniscr_copy_line()
546 col = ((pos - vc->vc_origin) % vc->vc_size_row) / 2; in vc_uniscr_copy_line()
556 int mask = vc->vc_hi_font_mask | 0xff; in vc_uniscr_copy_line()
558 while (nr--) { in vc_uniscr_copy_line()
569 unsigned int rows = bottom - top; in con_scroll()
573 nr = rows - 1; in con_scroll()
574 if (bottom > vc->vc_rows || top >= bottom || nr < 1) in con_scroll()
579 vc->vc_sw->con_scroll(vc, top, bottom, dir, nr)) in con_scroll()
582 src = clear = (u16 *)(vc->vc_origin + vc->vc_size_row * top); in con_scroll()
583 dst = (u16 *)(vc->vc_origin + vc->vc_size_row * (top + nr)); in con_scroll()
586 clear = src + (rows - nr) * vc->vc_cols; in con_scroll()
587 swap(src, dst); in con_scroll()
589 scr_memmovew(dst, src, (rows - nr) * vc->vc_size_row); in con_scroll()
590 scr_memsetw(clear, vc->vc_video_erase_char, vc->vc_size_row * nr); in con_scroll()
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()
606 while (xx < vc->vc_cols && count) { in do_update_region()
609 vc->vc_sw->con_putcs(vc, q, p-q, yy, startx); in do_update_region()
616 count--; in do_update_region()
619 vc->vc_sw->con_putcs(vc, q, p-q, yy, startx); in do_update_region()
639 /* Structure of attributes is hardware-dependent */
645 if (vc->vc_sw->con_build_attr) in build_attr()
646 return vc->vc_sw->con_build_attr(vc, _color, _intensity, in build_attr()
661 if (!vc->vc_can_do_color) in build_attr()
668 a = (a & 0xF0) | vc->vc_itcolor; in build_attr()
670 a = (a & 0xf0) | vc->vc_ulcolor; in build_attr()
672 a = (a & 0xf0) | vc->vc_halfcolor; in build_attr()
679 if (vc->vc_hi_font_mask == 0x100) in build_attr()
687 vc->vc_attr = build_attr(vc, vc->state.color, vc->state.intensity, in update_attr()
688 vc->state.blink, vc->state.underline, in update_attr()
689 vc->state.reverse ^ vc->vc_decscnm, vc->state.italic); in update_attr()
690 vc->vc_video_erase_char = ' ' | (build_attr(vc, vc->state.color, in update_attr()
691 VCI_NORMAL, vc->state.blink, false, in update_attr()
692 vc->vc_decscnm, false) << 8); in update_attr()
704 if (vc->vc_sw->con_invert_region) { in invert_screen()
705 vc->vc_sw->con_invert_region(vc, p, count); in invert_screen()
711 if (!vc->vc_can_do_color) { in invert_screen()
712 while (cnt--) { in invert_screen()
718 } else if (vc->vc_hi_font_mask == 0x100) { in invert_screen()
719 while (cnt--) { in invert_screen()
728 while (cnt--) { in invert_screen()
747 static int old_offset = -1; in complement_pos()
753 if (old_offset != -1 && old_offset >= 0 && in complement_pos()
754 old_offset < vc->vc_screenbuf_size) { in complement_pos()
763 if (offset != -1 && offset >= 0 && in complement_pos()
764 offset < vc->vc_screenbuf_size) { in complement_pos()
768 new = old ^ vc->vc_complement_mask; in complement_pos()
771 oldx = (offset >> 1) % vc->vc_cols; in complement_pos()
772 oldy = (offset >> 1) / vc->vc_cols; in complement_pos()
781 unsigned short *p = (unsigned short *) vc->vc_pos; in insert_char()
784 scr_memmovew(p + nr, p, (vc->vc_cols - vc->state.x - nr) * 2); in insert_char()
785 scr_memsetw(p, vc->vc_video_erase_char, nr * 2); in insert_char()
786 vc->vc_need_wrap = 0; in insert_char()
789 vc->vc_cols - vc->state.x); in insert_char()
794 unsigned short *p = (unsigned short *) vc->vc_pos; in delete_char()
797 scr_memmovew(p, p + nr, (vc->vc_cols - vc->state.x - nr) * 2); in delete_char()
798 scr_memsetw(p + vc->vc_cols - vc->state.x - nr, vc->vc_video_erase_char, in delete_char()
800 vc->vc_need_wrap = 0; in delete_char()
803 vc->vc_cols - vc->state.x); in delete_char()
806 static int softcursor_original = -1;
810 int i = scr_readw((u16 *) vc->vc_pos); in add_softcursor()
811 u32 type = vc->vc_cursor_type; in add_softcursor()
815 if (softcursor_original != -1) in add_softcursor()
825 scr_writew(i, (u16 *)vc->vc_pos); in add_softcursor()
827 con_putc(vc, i, vc->state.y, vc->state.x); in add_softcursor()
832 if (softcursor_original != -1) { in hide_softcursor()
833 scr_writew(softcursor_original, (u16 *)vc->vc_pos); in hide_softcursor()
835 con_putc(vc, softcursor_original, vc->state.y, in hide_softcursor()
836 vc->state.x); in hide_softcursor()
837 softcursor_original = -1; in hide_softcursor()
846 vc->vc_sw->con_cursor(vc, false); in hide_cursor()
852 if (!con_is_fg(vc) || console_blanked || vc->vc_mode == KD_GRAPHICS) in set_cursor()
854 if (vc->vc_deccm) { in set_cursor()
858 if (CUR_SIZE(vc->vc_cursor_type) != CUR_NONE) in set_cursor()
859 vc->vc_sw->con_cursor(vc, true); in set_cursor()
869 !vc->vc_sw->con_set_origin || in set_origin()
870 !vc->vc_sw->con_set_origin(vc)) in set_origin()
871 vc->vc_origin = (unsigned long)vc->vc_screenbuf; in set_origin()
872 vc->vc_visible_origin = vc->vc_origin; in set_origin()
873 vc->vc_scr_end = vc->vc_origin + vc->vc_screenbuf_size; in set_origin()
874 vc->vc_pos = vc->vc_origin + vc->vc_size_row * vc->state.y + in set_origin()
875 2 * vc->state.x; in set_origin()
882 if (vc->vc_sw->con_save_screen) in save_screen()
883 vc->vc_sw->con_save_screen(vc); in save_screen()
901 vc->vc_sw->con_switch(vc); in flush_scrollback()
911 unsigned short *p = (unsigned short *)vc->vc_origin; in clear_buffer_attributes()
912 int count = vc->vc_screenbuf_size / 2; in clear_buffer_attributes()
913 int mask = vc->vc_hi_font_mask | 0xff; in clear_buffer_attributes()
915 for (; count > 0; count--, p++) { in clear_buffer_attributes()
916 scr_writew((scr_readw(p)&mask) | (vc->vc_video_erase_char & ~mask), p); in clear_buffer_attributes()
938 *vc->vc_display_fg = vc; in redraw_screen()
939 fg_console = vc->vc_num; in redraw_screen()
946 sysfs_notify(&tty0dev->kobj, NULL, "active"); in redraw_screen()
954 int old_was_color = vc->vc_can_do_color; in redraw_screen()
957 update = vc->vc_sw->con_switch(vc); in redraw_screen()
960 * If console changed from mono<->color, the best we can do in redraw_screen()
965 if (old_was_color != vc->vc_can_do_color) { in redraw_screen()
970 if (update && vc->vc_mode != KD_GRAPHICS) in redraw_screen()
971 do_update_region(vc, vc->vc_origin, vc->vc_screenbuf_size / 2); in redraw_screen()
992 /* ++Geert: vc->vc_sw->con_init determines console size */ in visual_init()
993 if (vc->vc_sw) in visual_init()
994 module_put(vc->vc_sw->owner); in visual_init()
995 vc->vc_sw = conswitchp; in visual_init()
998 vc->vc_sw = con_driver_map[num]; in visual_init()
1000 __module_get(vc->vc_sw->owner); in visual_init()
1001 vc->vc_num = num; in visual_init()
1002 vc->vc_display_fg = &master_display_fg; in visual_init()
1003 if (vc->uni_pagedict_loc) in visual_init()
1005 vc->uni_pagedict_loc = &vc->uni_pagedict; in visual_init()
1006 vc->uni_pagedict = NULL; in visual_init()
1007 vc->vc_hi_font_mask = 0; in visual_init()
1008 vc->vc_complement_mask = 0; in visual_init()
1009 vc->vc_can_do_color = 0; in visual_init()
1010 vc->vc_cur_blink_ms = DEFAULT_CURSOR_BLINK_MS; in visual_init()
1011 vc->vc_sw->con_init(vc, init); in visual_init()
1012 if (!vc->vc_complement_mask) in visual_init()
1013 vc->vc_complement_mask = vc->vc_can_do_color ? 0x7700 : 0x0800; in visual_init()
1014 vc->vc_s_complement_mask = vc->vc_complement_mask; in visual_init()
1015 vc->vc_size_row = vc->vc_cols << 1; in visual_init()
1016 vc->vc_screenbuf_size = vc->vc_rows * vc->vc_size_row; in visual_init()
1022 vc->vc_sw->con_deinit(vc); in visual_deinit()
1023 module_put(vc->vc_sw->owner); in visual_deinit()
1054 return -ENXIO; in vc_allocate()
1063 point is still up-to-date and the comment still has its value in vc_allocate()
1064 even if only as a historical artifact. --mj, July 1998 */ in vc_allocate()
1067 return -ENOMEM; in vc_allocate()
1070 tty_port_init(&vc->port); in vc_allocate()
1071 vc->port.ops = &vc_port_ops; in vc_allocate()
1076 if (!*vc->uni_pagedict_loc) in vc_allocate()
1079 err = -EINVAL; in vc_allocate()
1080 if (vc->vc_cols > VC_MAXCOL || vc->vc_rows > VC_MAXROW || in vc_allocate()
1081 vc->vc_screenbuf_size > KMALLOC_MAX_SIZE || !vc->vc_screenbuf_size) in vc_allocate()
1083 err = -ENOMEM; in vc_allocate()
1084 vc->vc_screenbuf = kzalloc(vc->vc_screenbuf_size, GFP_KERNEL); in vc_allocate()
1085 if (!vc->vc_screenbuf) in vc_allocate()
1090 if (global_cursor_default == -1) in vc_allocate()
1111 if (vc->vc_sw->con_resize) in resize_screen()
1112 err = vc->vc_sw->con_resize(vc, width, height, from_user); in resize_screen()
1118 * vc_do_resize - resizing method for the tty
1145 return -EINVAL; in vc_do_resize()
1147 new_cols = (cols ? cols : vc->vc_cols); in vc_do_resize()
1148 new_rows = (lines ? lines : vc->vc_rows); in vc_do_resize()
1152 if (new_cols == vc->vc_cols && new_rows == vc->vc_rows) { in vc_do_resize()
1157 * yres/xres equal to a number non-multiple of vc_font.height in vc_do_resize()
1162 * if above, and this causes the fbcon_display->vrows to become in vc_do_resize()
1163 * negative and it eventually leads to out-of-bound in vc_do_resize()
1173 return -EINVAL; in vc_do_resize()
1176 return -ENOMEM; in vc_do_resize()
1178 if (vc->vc_uni_lines) { in vc_do_resize()
1182 return -ENOMEM; in vc_do_resize()
1189 old_rows = vc->vc_rows; in vc_do_resize()
1190 old_row_size = vc->vc_size_row; in vc_do_resize()
1199 vc->vc_rows = new_rows; in vc_do_resize()
1200 vc->vc_cols = new_cols; in vc_do_resize()
1201 vc->vc_size_row = new_row_size; in vc_do_resize()
1202 vc->vc_screenbuf_size = new_screen_size; in vc_do_resize()
1205 rrem = new_row_size - rlth; in vc_do_resize()
1206 old_origin = vc->vc_origin; in vc_do_resize()
1210 if (vc->state.y > new_rows) { in vc_do_resize()
1211 if (old_rows - vc->state.y < new_rows) { in vc_do_resize()
1216 first_copied_row = (old_rows - new_rows); in vc_do_resize()
1222 first_copied_row = (vc->state.y - new_rows/2); in vc_do_resize()
1230 vc->vc_uni_lines, rlth/2, first_copied_row, in vc_do_resize()
1241 vc->vc_video_erase_char, rrem); in vc_do_resize()
1246 scr_memsetw((void *)new_origin, vc->vc_video_erase_char, in vc_do_resize()
1247 new_scr_end - new_origin); in vc_do_resize()
1248 oldscreen = vc->vc_screenbuf; in vc_do_resize()
1249 vc->vc_screenbuf = newscreen; in vc_do_resize()
1250 vc->vc_screenbuf_size = new_screen_size; in vc_do_resize()
1255 vc->vc_top = 0; in vc_do_resize()
1256 vc->vc_bottom = vc->vc_rows; in vc_do_resize()
1257 gotoxy(vc, vc->state.x, vc->state.y); in vc_do_resize()
1265 ws.ws_row = vc->vc_rows; in vc_do_resize()
1266 ws.ws_col = vc->vc_cols; in vc_do_resize()
1267 ws.ws_ypixel = vc->vc_scan_lines; in vc_do_resize()
1273 vt_event_post(VT_EVENT_RESIZE, vc->vc_num, vc->vc_num); in vc_do_resize()
1279 * __vc_resize - resize a VT
1289 * and @vc->port.tty.
1294 return vc_do_resize(vc->port.tty, vc, cols, rows, from_user); in __vc_resize()
1299 * vt_resize - resize a VT
1311 struct vc_data *vc = tty->driver_data; in vt_resize()
1315 ret = vc_do_resize(tty, vc, ws->ws_col, ws->ws_row, false); in vt_resize()
1334 put_pid(vc->vt_pid); in vc_deallocate()
1336 kfree(vc->vc_screenbuf); in vc_deallocate()
1348 #define set_kbd(vc, x) vt_set_kbd_mode_bit((vc)->vc_num, (x))
1349 #define clr_kbd(vc, x) vt_clr_kbd_mode_bit((vc)->vc_num, (x))
1350 #define is_kbd(vc, x) vt_get_kbd_mode_bit((vc)->vc_num, (x))
1393 vc->state.x = 0; in gotoxy()
1395 if (new_x >= vc->vc_cols) in gotoxy()
1396 vc->state.x = vc->vc_cols - 1; in gotoxy()
1398 vc->state.x = new_x; in gotoxy()
1401 if (vc->vc_decom) { in gotoxy()
1402 min_y = vc->vc_top; in gotoxy()
1403 max_y = vc->vc_bottom; in gotoxy()
1406 max_y = vc->vc_rows; in gotoxy()
1409 vc->state.y = min_y; in gotoxy()
1411 vc->state.y = max_y - 1; in gotoxy()
1413 vc->state.y = new_y; in gotoxy()
1414 vc->vc_pos = vc->vc_origin + vc->state.y * vc->vc_size_row + in gotoxy()
1415 (vc->state.x << 1); in gotoxy()
1416 vc->vc_need_wrap = 0; in gotoxy()
1422 gotoxy(vc, new_x, vc->vc_decom ? (vc->vc_top + new_y) : new_y); in gotoxay()
1427 scrolldelta(-(vc->vc_rows / 2)); in scrollback()
1433 lines = vc->vc_rows / 2; in scrollfront()
1442 if (vc->state.y + 1 == vc->vc_bottom) in lf()
1443 con_scroll(vc, vc->vc_top, vc->vc_bottom, SM_UP, 1); in lf()
1444 else if (vc->state.y < vc->vc_rows - 1) { in lf()
1445 vc->state.y++; in lf()
1446 vc->vc_pos += vc->vc_size_row; in lf()
1448 vc->vc_need_wrap = 0; in lf()
1457 if (vc->state.y == vc->vc_top) in ri()
1458 con_scroll(vc, vc->vc_top, vc->vc_bottom, SM_DOWN, 1); in ri()
1459 else if (vc->state.y > 0) { in ri()
1460 vc->state.y--; in ri()
1461 vc->vc_pos -= vc->vc_size_row; in ri()
1463 vc->vc_need_wrap = 0; in ri()
1468 vc->vc_pos -= vc->state.x << 1; in cr()
1469 vc->vc_need_wrap = vc->state.x = 0; in cr()
1475 if (vc->state.x) { in bs()
1476 vc->vc_pos -= 2; in bs()
1477 vc->state.x--; in bs()
1478 vc->vc_need_wrap = 0; in bs()
1502 vc_uniscr_clear_line(vc, vc->state.x, in csi_J()
1503 vc->vc_cols - vc->state.x); in csi_J()
1504 vc_uniscr_clear_lines(vc, vc->state.y + 1, in csi_J()
1505 vc->vc_rows - vc->state.y - 1); in csi_J()
1506 count = (vc->vc_scr_end - vc->vc_pos) >> 1; in csi_J()
1507 start = (unsigned short *)vc->vc_pos; in csi_J()
1510 vc_uniscr_clear_line(vc, 0, vc->state.x + 1); in csi_J()
1511 vc_uniscr_clear_lines(vc, 0, vc->state.y); in csi_J()
1512 count = ((vc->vc_pos - vc->vc_origin) >> 1) + 1; in csi_J()
1513 start = (unsigned short *)vc->vc_origin; in csi_J()
1519 vc_uniscr_clear_lines(vc, 0, vc->vc_rows); in csi_J()
1520 count = vc->vc_cols * vc->vc_rows; in csi_J()
1521 start = (unsigned short *)vc->vc_origin; in csi_J()
1526 scr_memsetw(start, vc->vc_video_erase_char, 2 * count); in csi_J()
1529 vc->vc_need_wrap = 0; in csi_J()
1541 unsigned short *start = (unsigned short *)vc->vc_pos; in csi_K()
1544 switch (vc->vc_par[0]) { in csi_K()
1547 count = vc->vc_cols - vc->state.x; in csi_K()
1550 offset = -vc->state.x; in csi_K()
1551 count = vc->state.x + 1; in csi_K()
1554 offset = -vc->state.x; in csi_K()
1555 count = vc->vc_cols; in csi_K()
1560 vc_uniscr_clear_line(vc, vc->state.x + offset, count); in csi_K()
1561 scr_memsetw(start + offset, vc->vc_video_erase_char, 2 * count); in csi_K()
1562 vc->vc_need_wrap = 0; in csi_K()
1570 unsigned int count = clamp(vc->vc_par[0], 1, vc->vc_cols - vc->state.x); in csi_X()
1572 vc_uniscr_clear_line(vc, vc->state.x, count); in csi_X()
1573 scr_memsetw((unsigned short *)vc->vc_pos, vc->vc_video_erase_char, 2 * count); in csi_X()
1575 vc->vc_sw->con_clear(vc, vc->state.y, vc->state.x, count); in csi_X()
1576 vc->vc_need_wrap = 0; in csi_X()
1581 vc->state.intensity = VCI_NORMAL; in default_attr()
1582 vc->state.italic = false; in default_attr()
1583 vc->state.underline = false; in default_attr()
1584 vc->state.reverse = false; in default_attr()
1585 vc->state.blink = false; in default_attr()
1586 vc->state.color = vc->vc_def_color; in default_attr()
1594 c->r = i&1 ? 0xaa : 0x00; in rgb_from_256()
1595 c->g = i&2 ? 0xaa : 0x00; in rgb_from_256()
1596 c->b = i&4 ? 0xaa : 0x00; in rgb_from_256()
1598 c->r = i&1 ? 0xff : 0x55; in rgb_from_256()
1599 c->g = i&2 ? 0xff : 0x55; in rgb_from_256()
1600 c->b = i&4 ? 0xff : 0x55; in rgb_from_256()
1602 i -= 16; in rgb_from_256()
1603 c->b = i % 6 * 255 / 6; in rgb_from_256()
1605 c->g = i % 6 * 255 / 6; in rgb_from_256()
1607 c->r = i * 255 / 6; in rgb_from_256()
1609 c->r = c->g = c->b = i * 10 - 2312; in rgb_from_256()
1614 u8 hue = 0, max = max3(c->r, c->g, c->b); in rgb_foreground()
1616 if (c->r > max / 2) in rgb_foreground()
1618 if (c->g > max / 2) in rgb_foreground()
1620 if (c->b > max / 2) in rgb_foreground()
1625 vc->state.intensity = VCI_BOLD; in rgb_foreground()
1627 vc->state.intensity = VCI_BOLD; in rgb_foreground()
1629 vc->state.intensity = VCI_NORMAL; in rgb_foreground()
1631 vc->state.color = (vc->state.color & 0xf0) | hue; in rgb_foreground()
1637 vc->state.color = (vc->state.color & 0x0f) in rgb_background()
1638 | (c->r&0x80) >> 1 | (c->g&0x80) >> 2 | (c->b&0x80) >> 3; in rgb_background()
1656 if (i > vc->vc_npar) in vc_t416_color()
1659 if (vc->vc_par[i] == 5 && i + 1 <= vc->vc_npar) { in vc_t416_color()
1662 rgb_from_256(vc->vc_par[i], &c); in vc_t416_color()
1663 } else if (vc->vc_par[i] == 2 && i + 3 <= vc->vc_npar) { in vc_t416_color()
1665 c.r = vc->vc_par[i + 1]; in vc_t416_color()
1666 c.g = vc->vc_par[i + 2]; in vc_t416_color()
1667 c.b = vc->vc_par[i + 3]; in vc_t416_color()
1704 CSI_m_BRIGHT_FG_COLOR_OFF = CSI_m_BRIGHT_FG_COLOR_BEG - CSI_m_FG_COLOR_BEG,
1707 CSI_m_BRIGHT_BG_COLOR_OFF = CSI_m_BRIGHT_BG_COLOR_BEG - CSI_m_BG_COLOR_BEG,
1715 for (i = 0; i <= vc->vc_npar; i++) in csi_m()
1716 switch (vc->vc_par[i]) { in csi_m()
1721 vc->state.intensity = VCI_BOLD; in csi_m()
1724 vc->state.intensity = VCI_HALF_BRIGHT; in csi_m()
1727 vc->state.italic = true; in csi_m()
1735 vc->state.underline = true; in csi_m()
1738 vc->state.blink = true; in csi_m()
1741 vc->state.reverse = true; in csi_m()
1743 case CSI_m_PRI_FONT: /* ANSI X3.64-1979 (SCO-ish?) in csi_m()
1747 vc->vc_translate = set_translate(vc->state.Gx_charset[vc->state.charset], vc); in csi_m()
1748 vc->vc_disp_ctrl = 0; in csi_m()
1749 vc->vc_toggle_meta = 0; in csi_m()
1751 case CSI_m_ALT_FONT1: /* ANSI X3.64-1979 (SCO-ish?) in csi_m()
1755 vc->vc_translate = set_translate(IBMPC_MAP, vc); in csi_m()
1756 vc->vc_disp_ctrl = 1; in csi_m()
1757 vc->vc_toggle_meta = 0; in csi_m()
1759 case CSI_m_ALT_FONT2: /* ANSI X3.64-1979 (SCO-ish?) in csi_m()
1763 vc->vc_translate = set_translate(IBMPC_MAP, vc); in csi_m()
1764 vc->vc_disp_ctrl = 1; in csi_m()
1765 vc->vc_toggle_meta = 1; in csi_m()
1768 vc->state.intensity = VCI_NORMAL; in csi_m()
1771 vc->state.italic = false; in csi_m()
1774 vc->state.underline = false; in csi_m()
1777 vc->state.blink = false; in csi_m()
1780 vc->state.reverse = false; in csi_m()
1789 vc->state.color = (vc->vc_def_color & 0x0f) | in csi_m()
1790 (vc->state.color & 0xf0); in csi_m()
1793 vc->state.color = (vc->vc_def_color & 0xf0) | in csi_m()
1794 (vc->state.color & 0x0f); in csi_m()
1797 vc->state.intensity = VCI_BOLD; in csi_m()
1798 vc->vc_par[i] -= CSI_m_BRIGHT_FG_COLOR_OFF; in csi_m()
1801 vc->vc_par[i] -= CSI_m_FG_COLOR_BEG; in csi_m()
1802 vc->state.color = color_table[vc->vc_par[i]] | in csi_m()
1803 (vc->state.color & 0xf0); in csi_m()
1806 vc->vc_par[i] -= CSI_m_BRIGHT_BG_COLOR_OFF; in csi_m()
1809 vc->vc_par[i] -= CSI_m_BG_COLOR_BEG; in csi_m()
1810 vc->state.color = (color_table[vc->vc_par[i]] << 4) | in csi_m()
1811 (vc->state.color & 0x0f); in csi_m()
1828 len = sprintf(buf, "\033[%d;%dR", vc->state.y + in cursor_report()
1829 (vc->vc_decom ? vc->vc_top + 1 : 1), in cursor_report()
1830 vc->state.x + 1); in cursor_report()
1831 respond_string(buf, len, tty->port); in cursor_report()
1838 respond_string(teminal_ok, strlen(teminal_ok), tty->port); in status_report()
1843 /* terminal answer to an ESC-Z or csi0c query. */ in respond_ID()
1846 respond_string(vt102_id, strlen(vt102_id), tty->port); in respond_ID()
1856 respond_string(buf, len, tty->port); in mouse_report()
1862 return vc_cons[fg_console].d->vc_report_mouse; in mouse_reporting()
1882 for (i = 0; i <= vc->vc_npar; i++) in csi_DEC_hl()
1883 switch (vc->vc_par[i]) { in csi_DEC_hl()
1892 vc_resize(deccolm ? 132 : 80, vc->vc_rows); in csi_DEC_hl()
1898 if (vc->vc_decscnm != on_off) { in csi_DEC_hl()
1899 vc->vc_decscnm = on_off; in csi_DEC_hl()
1900 invert_screen(vc, 0, vc->vc_screenbuf_size, in csi_DEC_hl()
1906 vc->vc_decom = on_off; in csi_DEC_hl()
1910 vc->vc_decawm = on_off; in csi_DEC_hl()
1919 vc->vc_report_mouse = on_off ? 1 : 0; in csi_DEC_hl()
1922 vc->vc_deccm = on_off; in csi_DEC_hl()
1925 vc->vc_report_mouse = on_off ? 2 : 0; in csi_DEC_hl()
1941 for (i = 0; i <= vc->vc_npar; i++) in csi_hl()
1942 switch (vc->vc_par[i]) { /* ANSI modes set/reset */ in csi_hl()
1944 vc->vc_disp_ctrl = on_off; in csi_hl()
1947 vc->vc_decim = on_off; in csi_hl()
1973 * csi_RSB - csi+] (Right Square Bracket) handler
1981 switch (vc->vc_par[0]) { in csi_RSB()
1983 if (vc->vc_can_do_color && vc->vc_par[1] < 16) { in csi_RSB()
1984 vc->vc_ulcolor = color_table[vc->vc_par[1]]; in csi_RSB()
1985 if (vc->state.underline) in csi_RSB()
1990 if (vc->vc_can_do_color && vc->vc_par[1] < 16) { in csi_RSB()
1991 vc->vc_halfcolor = color_table[vc->vc_par[1]]; in csi_RSB()
1992 if (vc->state.intensity == VCI_HALF_BRIGHT) in csi_RSB()
1997 vc->vc_def_color = vc->vc_attr; in csi_RSB()
1998 if (vc->vc_hi_font_mask == 0x100) in csi_RSB()
1999 vc->vc_def_color >>= 1; in csi_RSB()
2004 blankinterval = min(vc->vc_par[1], 60U) * 60; in csi_RSB()
2008 if (vc->vc_npar >= 1) in csi_RSB()
2009 vc->vc_bell_pitch = vc->vc_par[1]; in csi_RSB()
2011 vc->vc_bell_pitch = DEFAULT_BELL_PITCH; in csi_RSB()
2014 if (vc->vc_npar >= 1) in csi_RSB()
2015 vc->vc_bell_duration = (vc->vc_par[1] < 2000) ? in csi_RSB()
2016 msecs_to_jiffies(vc->vc_par[1]) : 0; in csi_RSB()
2018 vc->vc_bell_duration = DEFAULT_BELL_DURATION; in csi_RSB()
2021 if (vc->vc_par[1] >= 1 && vc_cons_allocated(vc->vc_par[1] - 1)) in csi_RSB()
2022 set_console(vc->vc_par[1] - 1); in csi_RSB()
2028 vesa_off_interval = min(vc->vc_par[1], 60U) * 60 * HZ; in csi_RSB()
2034 if (vc->vc_npar >= 1 && vc->vc_par[1] >= 50 && in csi_RSB()
2035 vc->vc_par[1] <= USHRT_MAX) in csi_RSB()
2036 vc->vc_cur_blink_ms = vc->vc_par[1]; in csi_RSB()
2038 vc->vc_cur_blink_ms = DEFAULT_CURSOR_BLINK_MS; in csi_RSB()
2046 nr = clamp(nr, 1, vc->vc_cols - vc->state.x); in csi_at()
2053 unsigned int nr = clamp(vc->vc_par[0], 1, vc->vc_rows - vc->state.y); in csi_L()
2055 con_scroll(vc, vc->state.y, vc->vc_bottom, SM_DOWN, nr); in csi_L()
2056 vc->vc_need_wrap = 0; in csi_L()
2062 unsigned int nr = clamp(vc->vc_par[0], 1, vc->vc_cols - vc->state.x); in csi_P()
2070 unsigned int nr = clamp(vc->vc_par[0], 1, vc->vc_rows - vc->state.y); in csi_M()
2072 con_scroll(vc, vc->state.y, vc->vc_bottom, SM_UP, nr); in csi_M()
2073 vc->vc_need_wrap = 0; in csi_M()
2076 /* console_lock is held (except via vc_init->reset_terminal */
2079 memcpy(&vc->saved_state, &vc->state, sizeof(vc->state)); in save_cur()
2085 memcpy(&vc->state, &vc->saved_state, sizeof(vc->state)); in restore_cur()
2087 gotoxy(vc, vc->state.x, vc->state.y); in restore_cur()
2088 vc->vc_translate = set_translate(vc->state.Gx_charset[vc->state.charset], in restore_cur()
2091 vc->vc_need_wrap = 0; in restore_cur()
2095 * enum vc_ctl_state - control characters state of a vt
2099 * @ESsquare: CSI parsed -- modifiers/parameters/ctrl chars expected
2100 * @ESgetpars: CSI parsed -- parameters/ctrl chars expected
2106 * @EScsiignore: CSI [0x20-0x3f] parsed
2109 * @ESosc: OSC [0-9] parsed
2142 vc->vc_top = 0; in reset_terminal()
2143 vc->vc_bottom = vc->vc_rows; in reset_terminal()
2144 vc->vc_state = ESnormal; in reset_terminal()
2145 vc->vc_priv = EPecma; in reset_terminal()
2146 vc->vc_translate = set_translate(LAT1_MAP, vc); in reset_terminal()
2147 vc->state.Gx_charset[0] = LAT1_MAP; in reset_terminal()
2148 vc->state.Gx_charset[1] = GRAF_MAP; in reset_terminal()
2149 vc->state.charset = 0; in reset_terminal()
2150 vc->vc_need_wrap = 0; in reset_terminal()
2151 vc->vc_report_mouse = 0; in reset_terminal()
2152 vc->vc_utf = default_utf8; in reset_terminal()
2153 vc->vc_utf_count = 0; in reset_terminal()
2155 vc->vc_disp_ctrl = 0; in reset_terminal()
2156 vc->vc_toggle_meta = 0; in reset_terminal()
2158 vc->vc_decscnm = 0; in reset_terminal()
2159 vc->vc_decom = 0; in reset_terminal()
2160 vc->vc_decawm = 1; in reset_terminal()
2161 vc->vc_deccm = global_cursor_default; in reset_terminal()
2162 vc->vc_decim = 0; in reset_terminal()
2164 vt_reset_keyboard(vc->vc_num); in reset_terminal()
2166 vc->vc_cursor_type = cur_default; in reset_terminal()
2167 vc->vc_complement_mask = vc->vc_s_complement_mask; in reset_terminal()
2172 bitmap_zero(vc->vc_tab_stop, VC_TABSTOPS_COUNT); in reset_terminal()
2174 set_bit(i, vc->vc_tab_stop); in reset_terminal()
2176 vc->vc_bell_pitch = DEFAULT_BELL_PITCH; in reset_terminal()
2177 vc->vc_bell_duration = DEFAULT_BELL_DURATION; in reset_terminal()
2178 vc->vc_cur_blink_ms = DEFAULT_CURSOR_BLINK_MS; in reset_terminal()
2188 unsigned char *charset = &vc->state.Gx_charset[which]; in vc_setGx()
2205 if (vc->state.charset == which) in vc_setGx()
2206 vc->vc_translate = set_translate(*charset, vc); in vc_setGx()
2230 ASCII_CSI_IGNORE_FIRST = ' ', /* 0x2x, 0x3a and 0x3c - 0x3f */
2248 if (ansi_control_string(vc->vc_state)) in handle_ascii()
2249 vc->vc_state = ESnormal; in handle_ascii()
2250 else if (vc->vc_bell_duration) in handle_ascii()
2251 kd_mksound(vc->vc_bell_pitch, vc->vc_bell_duration); in handle_ascii()
2257 vc->vc_pos -= (vc->state.x << 1); in handle_ascii()
2259 vc->state.x = find_next_bit(vc->vc_tab_stop, in handle_ascii()
2260 min(vc->vc_cols - 1, VC_TABSTOPS_COUNT), in handle_ascii()
2261 vc->state.x + 1); in handle_ascii()
2262 if (vc->state.x >= VC_TABSTOPS_COUNT) in handle_ascii()
2263 vc->state.x = vc->vc_cols - 1; in handle_ascii()
2265 vc->vc_pos += (vc->state.x << 1); in handle_ascii()
2279 vc->state.charset = 1; in handle_ascii()
2280 vc->vc_translate = set_translate(vc->state.Gx_charset[1], vc); in handle_ascii()
2281 vc->vc_disp_ctrl = 1; in handle_ascii()
2284 vc->state.charset = 0; in handle_ascii()
2285 vc->vc_translate = set_translate(vc->state.Gx_charset[0], vc); in handle_ascii()
2286 vc->vc_disp_ctrl = 0; in handle_ascii()
2290 vc->vc_state = ESnormal; in handle_ascii()
2293 vc->vc_state = ESesc; in handle_ascii()
2299 vc->vc_state = ESsquare; in handle_ascii()
2313 vc->vc_state = ESnormal; in handle_esc()
2316 vc->vc_state = ESsquare; in handle_esc()
2319 vc->vc_state = ESnonstd; in handle_esc()
2322 vc->vc_state = ESapc; in handle_esc()
2325 vc->vc_state = ESpm; in handle_esc()
2328 vc->vc_state = ESpercent; in handle_esc()
2341 if (vc->state.x < VC_TABSTOPS_COUNT) in handle_esc()
2342 set_bit(vc->state.x, vc->vc_tab_stop); in handle_esc()
2345 vc->vc_state = ESdcs; in handle_esc()
2357 vc->vc_state = ESsetG0; in handle_esc()
2360 vc->vc_state = ESsetG1; in handle_esc()
2363 vc->vc_state = EShash; in handle_esc()
2379 * are in @vc->vc_par and the char is in @c here.
2391 if (vc->vc_par[0]) in csi_DEC()
2392 vc->vc_cursor_type = CUR_MAKE(vc->vc_par[0], in csi_DEC()
2393 vc->vc_par[1], in csi_DEC()
2394 vc->vc_par[2]); in csi_DEC()
2396 vc->vc_cursor_type = cur_default; in csi_DEC()
2400 if (vc->vc_par[0]) in csi_DEC()
2401 vc->vc_complement_mask = vc->vc_par[0] << 8 | vc->vc_par[1]; in csi_DEC()
2403 vc->vc_complement_mask = vc->vc_s_complement_mask; in csi_DEC()
2406 if (vc->vc_par[0] == 5) in csi_DEC()
2408 else if (vc->vc_par[0] == 6) in csi_DEC()
2416 * "ESC [ parameters char". Parameters are in @vc->vc_par and the char is in
2424 if (vc->vc_par[0]) in csi_ECMA()
2425 vc->vc_par[0]--; in csi_ECMA()
2426 gotoxy(vc, vc->vc_par[0], vc->state.y); in csi_ECMA()
2429 if (!vc->vc_par[0]) in csi_ECMA()
2430 vc->vc_par[0]++; in csi_ECMA()
2431 gotoxy(vc, vc->state.x, vc->state.y - vc->vc_par[0]); in csi_ECMA()
2435 if (!vc->vc_par[0]) in csi_ECMA()
2436 vc->vc_par[0]++; in csi_ECMA()
2437 gotoxy(vc, vc->state.x, vc->state.y + vc->vc_par[0]); in csi_ECMA()
2441 if (!vc->vc_par[0]) in csi_ECMA()
2442 vc->vc_par[0]++; in csi_ECMA()
2443 gotoxy(vc, vc->state.x + vc->vc_par[0], vc->state.y); in csi_ECMA()
2446 if (!vc->vc_par[0]) in csi_ECMA()
2447 vc->vc_par[0]++; in csi_ECMA()
2448 gotoxy(vc, vc->state.x - vc->vc_par[0], vc->state.y); in csi_ECMA()
2451 if (!vc->vc_par[0]) in csi_ECMA()
2452 vc->vc_par[0]++; in csi_ECMA()
2453 gotoxy(vc, 0, vc->state.y + vc->vc_par[0]); in csi_ECMA()
2456 if (!vc->vc_par[0]) in csi_ECMA()
2457 vc->vc_par[0]++; in csi_ECMA()
2458 gotoxy(vc, 0, vc->state.y - vc->vc_par[0]); in csi_ECMA()
2461 if (vc->vc_par[0]) in csi_ECMA()
2462 vc->vc_par[0]--; in csi_ECMA()
2463 gotoxay(vc, vc->state.x ,vc->vc_par[0]); in csi_ECMA()
2467 if (vc->vc_par[0]) in csi_ECMA()
2468 vc->vc_par[0]--; in csi_ECMA()
2469 if (vc->vc_par[1]) in csi_ECMA()
2470 vc->vc_par[1]--; in csi_ECMA()
2471 gotoxay(vc, vc->vc_par[1], vc->vc_par[0]); in csi_ECMA()
2474 csi_J(vc, vc->vc_par[0]); in csi_ECMA()
2489 if (!vc->vc_par[0]) in csi_ECMA()
2493 if (!vc->vc_par[0] && vc->state.x < VC_TABSTOPS_COUNT) in csi_ECMA()
2494 set_bit(vc->state.x, vc->vc_tab_stop); in csi_ECMA()
2495 else if (vc->vc_par[0] == 3) in csi_ECMA()
2496 bitmap_zero(vc->vc_tab_stop, VC_TABSTOPS_COUNT); in csi_ECMA()
2508 if (vc->vc_par[0] == 5) in csi_ECMA()
2510 else if (vc->vc_par[0] == 6) in csi_ECMA()
2513 case 'q': /* DECLL - but only 3 leds */ in csi_ECMA()
2515 if (vc->vc_par[0] < 4) in csi_ECMA()
2516 vt_set_led_state(vc->vc_num, in csi_ECMA()
2517 (vc->vc_par[0] < 3) ? vc->vc_par[0] : 4); in csi_ECMA()
2520 if (!vc->vc_par[0]) in csi_ECMA()
2521 vc->vc_par[0]++; in csi_ECMA()
2522 if (!vc->vc_par[1]) in csi_ECMA()
2523 vc->vc_par[1] = vc->vc_rows; in csi_ECMA()
2525 if (vc->vc_par[0] < vc->vc_par[1] && in csi_ECMA()
2526 vc->vc_par[1] <= vc->vc_rows) { in csi_ECMA()
2527 vc->vc_top = vc->vc_par[0] - 1; in csi_ECMA()
2528 vc->vc_bottom = vc->vc_par[1]; in csi_ECMA()
2542 csi_at(vc, vc->vc_par[0]); in csi_ECMA()
2553 memset(vc->vc_par, 0, sizeof(vc->vc_par)); in vc_reset_params()
2554 vc->vc_npar = 0; in vc_reset_params()
2564 if (ansi_control_string(vc->vc_state) && c >= ASCII_IGNORE_FIRST && in do_con_trol()
2571 switch(vc->vc_state) { in do_con_trol()
2579 vc->vc_state = ESpalette; in do_con_trol()
2585 vc->vc_state = ESosc; in do_con_trol()
2588 vc->vc_state = ESnormal; in do_con_trol()
2592 vc->vc_par[vc->vc_npar++] = hex_to_bin(c); in do_con_trol()
2593 if (vc->vc_npar == 7) { in do_con_trol()
2594 int i = vc->vc_par[0] * 3, j = 1; in do_con_trol()
2595 vc->vc_palette[i] = 16 * vc->vc_par[j++]; in do_con_trol()
2596 vc->vc_palette[i++] += vc->vc_par[j++]; in do_con_trol()
2597 vc->vc_palette[i] = 16 * vc->vc_par[j++]; in do_con_trol()
2598 vc->vc_palette[i++] += vc->vc_par[j++]; in do_con_trol()
2599 vc->vc_palette[i] = 16 * vc->vc_par[j++]; in do_con_trol()
2600 vc->vc_palette[i] += vc->vc_par[j]; in do_con_trol()
2602 vc->vc_state = ESnormal; in do_con_trol()
2605 vc->vc_state = ESnormal; in do_con_trol()
2610 vc->vc_state = ESgetpars; in do_con_trol()
2613 vc->vc_state = ESfunckey; in do_con_trol()
2616 vc->vc_priv = EPdec; in do_con_trol()
2619 vc->vc_priv = EPgt; in do_con_trol()
2622 vc->vc_priv = EPeq; in do_con_trol()
2625 vc->vc_priv = EPlt; in do_con_trol()
2628 vc->vc_priv = EPecma; in do_con_trol()
2633 if (vc->vc_npar < NPAR - 1) { in do_con_trol()
2634 vc->vc_npar++; in do_con_trol()
2639 vc->vc_par[vc->vc_npar] *= 10; in do_con_trol()
2640 vc->vc_par[vc->vc_npar] += c - '0'; in do_con_trol()
2644 vc->vc_state = EScsiignore; in do_con_trol()
2650 vc->vc_state = ESnormal; in do_con_trol()
2652 switch (vc->vc_priv) { in do_con_trol()
2665 vc->vc_state = ESnormal; in do_con_trol()
2668 vc->vc_state = ESnormal; in do_con_trol()
2671 vc->vc_utf = 0; in do_con_trol()
2675 vc->vc_utf = 1; in do_con_trol()
2680 vc->vc_state = ESnormal; in do_con_trol()
2683 vc->vc_state = ESnormal; in do_con_trol()
2685 /* DEC screen alignment test. kludge :-) */ in do_con_trol()
2686 vc->vc_video_erase_char = in do_con_trol()
2687 (vc->vc_video_erase_char & 0xff00) | 'E'; in do_con_trol()
2689 vc->vc_video_erase_char = in do_con_trol()
2690 (vc->vc_video_erase_char & 0xff00) | ' '; in do_con_trol()
2691 do_update_region(vc, vc->vc_origin, vc->vc_screenbuf_size / 2); in do_con_trol()
2696 vc->vc_state = ESnormal; in do_con_trol()
2700 vc->vc_state = ESnormal; in do_con_trol()
2704 case ESosc: /* ESC ] [0-9] aka OSC [0-9] */ in do_con_trol()
2711 vc->vc_state = ESnormal; in do_con_trol()
2716 * Markus Kuhn -- 2007-05-26 (Unicode 5.0)
2732 return -1; in ucs_cmp()
2745 ucs > double_width[ARRAY_SIZE(double_width) - 1].last) in is_double_width()
2759 if (draw->x < 0) in con_flush()
2762 vc->vc_sw->con_putcs(vc, (u16 *)draw->from, in con_flush()
2763 (u16 *)draw->to - (u16 *)draw->from, vc->state.y, in con_flush()
2764 draw->x); in con_flush()
2765 draw->x = -1; in con_flush()
2771 if (vc->vc_toggle_meta) in vc_translate_ascii()
2774 return vc->vc_translate[c]; in vc_translate_ascii()
2782 * vc_sanitize_unicode - Replace invalid Unicode code points with ``U+FFFD``
2794 * vc_translate_unicode - Combine UTF-8 into Unicode in &vc_data.vc_utf_char
2796 * @c: UTF-8 byte to translate
2797 * @rescan: set to true iff @c wasn't consumed here and needs to be re-processed
2799 * * &vc_data.vc_utf_char is the being-constructed Unicode code point.
2805 * * %-1 - Input OK so far, @c consumed, further bytes expected.
2806 * * %0xFFFD - Possibility 1: input invalid, @c may have been consumed (see
2810 * * otherwise - Input OK, @c consumed, resulting code point returned.
2819 if (!vc->vc_utf_count) in vc_translate_unicode()
2822 vc->vc_utf_char = (vc->vc_utf_char << 6) | (c & 0x3f); in vc_translate_unicode()
2823 vc->vc_npar++; in vc_translate_unicode()
2824 if (--vc->vc_utf_count) in vc_translate_unicode()
2828 c = vc->vc_utf_char; in vc_translate_unicode()
2830 if (c <= utf8_length_changes[vc->vc_npar - 1] || in vc_translate_unicode()
2831 c > utf8_length_changes[vc->vc_npar]) in vc_translate_unicode()
2838 if (vc->vc_utf_count) { in vc_translate_unicode()
2841 vc->vc_utf_count = 0; in vc_translate_unicode()
2850 vc->vc_npar = 0; in vc_translate_unicode()
2852 vc->vc_utf_count = 1; in vc_translate_unicode()
2853 vc->vc_utf_char = (c & 0x1f); in vc_translate_unicode()
2855 vc->vc_utf_count = 2; in vc_translate_unicode()
2856 vc->vc_utf_char = (c & 0x0f); in vc_translate_unicode()
2858 vc->vc_utf_count = 3; in vc_translate_unicode()
2859 vc->vc_utf_char = (c & 0x07); in vc_translate_unicode()
2865 return -1; in vc_translate_unicode()
2871 if (vc->vc_state != ESnormal) in vc_translate()
2874 if (vc->vc_utf && !vc->vc_disp_ctrl) in vc_translate()
2883 if (!vc->vc_can_do_color) in vc_invert_attr()
2884 return vc->vc_attr ^ 0x08; in vc_invert_attr()
2886 if (vc->vc_hi_font_mask == 0x100) in vc_invert_attr()
2887 return (vc->vc_attr & 0x11) | in vc_invert_attr()
2888 ((vc->vc_attr & 0xe0) >> 4) | in vc_invert_attr()
2889 ((vc->vc_attr & 0x0e) << 4); in vc_invert_attr()
2891 return (vc->vc_attr & 0x88) | in vc_invert_attr()
2892 ((vc->vc_attr & 0x70) >> 4) | in vc_invert_attr()
2893 ((vc->vc_attr & 0x07) << 4); in vc_invert_attr()
2912 if (vc->vc_state != ESnormal) in vc_is_control()
2925 * direct-to-font zone in UTF-8 mode. in vc_is_control()
2928 if (vc->vc_disp_ctrl) in vc_is_control()
2931 return vc->vc_utf || (CTRL_ACTION & BIT(c)); in vc_is_control()
2934 if (c == ASCII_DEL && !vc->vc_disp_ctrl) in vc_is_control()
2947 unsigned char vc_attr = vc->vc_attr; in vc_con_write_normal()
2948 u16 himask = vc->vc_hi_font_mask, charmask = himask ? 0x1ff : 0xff; in vc_con_write_normal()
2952 if (vc->vc_utf && !vc->vc_disp_ctrl) { in vc_con_write_normal()
2960 if (tc == -1 || tc == -2) in vc_con_write_normal()
2961 return -1; /* nothing to display */ in vc_con_write_normal()
2964 if ((!vc->vc_utf || vc->vc_disp_ctrl || c < 128) && in vc_con_write_normal()
2995 if (vc->vc_need_wrap || vc->vc_decim) in vc_con_write_normal()
2997 if (vc->vc_need_wrap) { in vc_con_write_normal()
3001 if (vc->vc_decim) in vc_con_write_normal()
3010 scr_writew(tc, (u16 *)vc->vc_pos); in vc_con_write_normal()
3012 if (con_should_update(vc) && draw->x < 0) { in vc_con_write_normal()
3013 draw->x = vc->state.x; in vc_con_write_normal()
3014 draw->from = vc->vc_pos; in vc_con_write_normal()
3016 if (vc->state.x == vc->vc_cols - 1) { in vc_con_write_normal()
3017 vc->vc_need_wrap = vc->vc_decawm; in vc_con_write_normal()
3018 draw->to = vc->vc_pos + 2; in vc_con_write_normal()
3020 vc->state.x++; in vc_con_write_normal()
3021 draw->to = (vc->vc_pos += 2); in vc_con_write_normal()
3024 if (!--width) in vc_con_write_normal()
3045 .x = -1, in do_con_write()
3049 struct vc_data *vc = tty->driver_data; in do_con_write()
3057 currcons = vc->vc_num; in do_con_write()
3072 while (!tty->flow.stopped && count) { in do_con_write()
3076 count--; in do_con_write()
3082 if (tc == -1) in do_con_write()
3115 * with other console code and prevention of re-entrancy is
3128 been allocated - a new console is not created in console_callback()
3131 want_console = -1; in console_callback()
3140 if (vc->vc_mode == KD_TEXT && vc->vc_sw->con_scrolldelta) in console_callback()
3141 vc->vc_sw->con_scrolldelta(vc, scrollback_delta); in console_callback()
3158 (vc->vt_mode.mode == VT_AUTO && vc->vc_mode == KD_GRAPHICS)) { in set_console()
3168 return -EINVAL; in set_console()
3182 * vt_kmsg_redirect() - sets/gets the kernel message console
3183 * @new: the new virtual terminal number or -1 if the console should stay
3195 * The parameter -1 means that only the current console is returned, but the
3206 if (new != -1) in vt_kmsg_redirect()
3234 if (kmsg_console && vc_cons_allocated(kmsg_console - 1)) in vt_console_print()
3235 vc = vc_cons[kmsg_console - 1].d; in vt_console_print()
3243 if (vc->vc_mode != KD_TEXT) in vt_console_print()
3250 start = (ushort *)vc->vc_pos; in vt_console_print()
3251 start_x = vc->state.x; in vt_console_print()
3253 while (count--) { in vt_console_print()
3256 c == ASCII_BACKSPACE || vc->vc_need_wrap) { in vt_console_print()
3258 vc->vc_sw->con_putcs(vc, start, cnt, vc->state.y, start_x); in vt_console_print()
3262 start = (ushort *)vc->vc_pos; in vt_console_print()
3263 start_x = vc->state.x; in vt_console_print()
3269 start = (ushort *)vc->vc_pos; in vt_console_print()
3270 start_x = vc->state.x; in vt_console_print()
3275 scr_writew((vc->vc_attr << 8) + c, (unsigned short *)vc->vc_pos); in vt_console_print()
3278 if (vc->state.x == vc->vc_cols - 1) { in vt_console_print()
3279 vc->vc_need_wrap = 1; in vt_console_print()
3281 vc->vc_pos += 2; in vt_console_print()
3282 vc->state.x++; in vt_console_print()
3286 vc->vc_sw->con_putcs(vc, start, cnt, vc->state.y, start_x); in vt_console_print()
3296 *index = c->index ? c->index-1 : fg_console; in vt_console_device()
3302 return co->index >= MAX_NR_CONSOLES ? -EINVAL : 0; in vt_console_setup()
3312 .index = -1,
3317 * Handling of Linux-specific VC ioctls
3340 if (current->signal->tty != tty && !capable(CAP_SYS_ADMIN)) in tioclinux()
3341 return -EPERM; in tioclinux()
3343 return -EFAULT; in tioclinux()
3349 return -EPERM; in tioclinux()
3353 return -EPERM; in tioclinux()
3362 return -EPERM; in tioclinux()
3367 * 'shift_state' is an undocumented kernel-internal variable; in tioclinux()
3385 return -EPERM; in tioclinux()
3388 return -EFAULT; in tioclinux()
3401 return -EFAULT; in tioclinux()
3420 return -EINVAL; in tioclinux()
3447 if (tty->flow.stopped) in con_write_room()
3463 struct vc_data *vc = tty->driver_data; in con_unthrottle()
3465 wake_up_interruptible(&vc->paste_wait); in con_unthrottle()
3469 * Turn the Scroll-Lock LED on when the tty is stopped
3476 console_num = tty->index; in con_stop()
3483 * Turn the Scroll-Lock LED off when the console is started
3490 console_num = tty->index; in con_start()
3498 struct vc_data *vc = tty->driver_data; in con_flush_chars()
3513 unsigned int currcons = tty->index; in con_install()
3525 if (vc->port.tty) { in con_install()
3526 ret = -ERESTARTSYS; in con_install()
3530 ret = tty_port_install(&vc->port, driver, tty); in con_install()
3534 tty->driver_data = vc; in con_install()
3535 vc->port.tty = tty; in con_install()
3536 tty_port_get(&vc->port); in con_install()
3538 if (!tty->winsize.ws_row && !tty->winsize.ws_col) { in con_install()
3539 tty->winsize.ws_row = vc_cons[currcons].d->vc_rows; in con_install()
3540 tty->winsize.ws_col = vc_cons[currcons].d->vc_cols; in con_install()
3542 if (vc->vc_utf) in con_install()
3543 tty->termios.c_iflag |= IUTF8; in con_install()
3545 tty->termios.c_iflag &= ~IUTF8; in con_install()
3560 /* Nothing to do - we defer to shutdown */ in con_close()
3565 struct vc_data *vc = tty->driver_data; in con_shutdown()
3568 vc->port.tty = NULL; in con_shutdown()
3574 struct vc_data *vc = tty->driver_data; in con_cleanup()
3576 tty_port_put(&vc->port); in con_cleanup()
3585 return ldisc == N_TTY ? 0 : -EINVAL; in con_ldisc_ok()
3600 vc->vc_pos = vc->vc_origin; in vc_init()
3603 vc->vc_palette[k++] = default_red[j] ; in vc_init()
3604 vc->vc_palette[k++] = default_grn[j] ; in vc_init()
3605 vc->vc_palette[k++] = default_blu[j] ; in vc_init()
3607 vc->vc_def_color = default_color; in vc_init()
3608 vc->vc_ulcolor = default_underline_color; in vc_init()
3609 vc->vc_itcolor = default_italic_color; in vc_init()
3610 vc->vc_halfcolor = 0x08; /* grey */ in vc_init()
3611 init_waitqueue_head(&vc->paste_wait); in vc_init()
3618 * the appropriate escape-sequence.
3631 display_desc = conswitchp->con_startup(); in con_init()
3641 if (con_driver->con == NULL) { in con_init()
3642 con_driver->con = conswitchp; in con_init()
3643 con_driver->desc = display_desc; in con_init()
3644 con_driver->flag = CON_DRIVER_FLAG_INIT; in con_init()
3645 con_driver->first = 0; in con_init()
3646 con_driver->last = MAX_NR_CONSOLES - 1; in con_init()
3662 tty_port_init(&vc->port); in con_init()
3664 /* Assuming vc->vc_{cols,rows,screenbuf_size} are sane here. */ in con_init()
3665 vc->vc_screenbuf = kzalloc(vc->vc_screenbuf_size, GFP_NOWAIT); in con_init()
3666 vc_init(vc, currcons || !vc->vc_sw->con_save_screen); in con_init()
3672 gotoxy(vc, vc->state.x, vc->state.y); in con_init()
3676 vc->vc_can_do_color ? "colour" : "mono", in con_init()
3677 display_desc, vc->vc_cols, vc->vc_rows); in con_init()
3745 console_driver->name = "tty"; in vty_init()
3746 console_driver->name_base = 1; in vty_init()
3747 console_driver->major = TTY_MAJOR; in vty_init()
3748 console_driver->minor_start = 1; in vty_init()
3749 console_driver->type = TTY_DRIVER_TYPE_CONSOLE; in vty_init()
3750 console_driver->init_termios = tty_std_termios; in vty_init()
3752 console_driver->init_termios.c_iflag |= IUTF8; in vty_init()
3771 struct module *owner = csw->owner; in do_bind_con_driver()
3774 int i, j = -1, k = -1, retval = -ENODEV; in do_bind_con_driver()
3777 return -ENODEV; in do_bind_con_driver()
3785 if (con_driver->con == csw) { in do_bind_con_driver()
3786 desc = con_driver->desc; in do_bind_con_driver()
3795 if (!(con_driver->flag & CON_DRIVER_FLAG_INIT)) { in do_bind_con_driver()
3796 csw->con_startup(); in do_bind_con_driver()
3797 con_driver->flag |= CON_DRIVER_FLAG_INIT; in do_bind_con_driver()
3802 module_put(conswitchp->owner); in do_bind_con_driver()
3808 first = max(first, con_driver->first); in do_bind_con_driver()
3809 last = min(last, con_driver->last); in do_bind_con_driver()
3816 module_put(con_driver_map[i]->owner); in do_bind_con_driver()
3820 if (!vc || !vc->vc_sw) in do_bind_con_driver()
3830 old_was_color = vc->vc_can_do_color; in do_bind_con_driver()
3831 vc->vc_sw->con_deinit(vc); in do_bind_con_driver()
3832 vc->vc_origin = (unsigned long)vc->vc_screenbuf; in do_bind_con_driver()
3837 /* If the console changed between mono <-> color, then in do_bind_con_driver()
3841 if (old_was_color != vc->vc_can_do_color) in do_bind_con_driver()
3847 pr_cont("consoles %d-%d ", first + 1, last + 1); in do_bind_con_driver()
3852 vc->vc_can_do_color ? "colour" : "mono", in do_bind_con_driver()
3853 desc, vc->vc_cols, vc->vc_rows); in do_bind_con_driver()
3873 struct module *owner = csw->owner; in do_unbind_con_driver()
3876 int i, retval = -ENODEV; in do_unbind_con_driver()
3879 return -ENODEV; in do_unbind_con_driver()
3887 if (con_driver->con == csw && in do_unbind_con_driver()
3888 con_driver->flag & CON_DRIVER_FLAG_MODULE) { in do_unbind_con_driver()
3897 retval = -ENODEV; in do_unbind_con_driver()
3903 if (con_back->con && con_back->con != csw) { in do_unbind_con_driver()
3904 defcsw = con_back->con; in do_unbind_con_driver()
3916 first = max(first, con_driver->first); in do_unbind_con_driver()
3917 last = min(last, con_driver->last); in do_unbind_con_driver()
3921 module_put(csw->owner); in do_unbind_con_driver()
3929 defcsw->con_startup(); in do_unbind_con_driver()
3930 con_back->flag |= CON_DRIVER_FLAG_INIT; in do_unbind_con_driver()
3939 con_driver->flag &= ~CON_DRIVER_FLAG_INIT; in do_unbind_con_driver()
3953 int i, more = 1, first = -1, last = -1, deflt = 0; in vt_bind()
3955 if (!con->con || !(con->flag & CON_DRIVER_FLAG_MODULE)) in vt_bind()
3958 csw = con->con; in vt_bind()
3963 if (con->con && !(con->flag & CON_DRIVER_FLAG_MODULE)) { in vt_bind()
3964 defcsw = con->con; in vt_bind()
3975 for (i = con->first; i <= con->last; i++) { in vt_bind()
3977 if (first == -1) in vt_bind()
3981 } else if (first != -1) in vt_bind()
3985 if (first == 0 && last == MAX_NR_CONSOLES -1) in vt_bind()
3988 if (first != -1) in vt_bind()
3991 first = -1; in vt_bind()
3992 last = -1; in vt_bind()
4003 int i, more = 1, first = -1, last = -1, deflt = 0; in vt_unbind()
4006 if (!con->con || !(con->flag & CON_DRIVER_FLAG_MODULE)) in vt_unbind()
4009 csw = con->con; in vt_unbind()
4014 for (i = con->first; i <= con->last; i++) { in vt_unbind()
4016 if (first == -1) in vt_unbind()
4020 } else if (first != -1) in vt_unbind()
4024 if (first == 0 && last == MAX_NR_CONSOLES -1) in vt_unbind()
4027 if (first != -1) { in vt_unbind()
4033 first = -1; in vt_unbind()
4034 last = -1; in vt_unbind()
4077 bind = con_is_bound(con->con); in show_bind()
4089 (con->flag & CON_DRIVER_FLAG_MODULE) ? "(M)" : "(S)", in show_name()
4090 con->desc); in show_name()
4107 con->flag |= CON_DRIVER_FLAG_ATTR; in vtconsole_init_device()
4113 con->flag &= ~CON_DRIVER_FLAG_ATTR; in vtconsole_deinit_device()
4117 * con_is_bound - checks if driver is bound to the console
4143 * con_is_visible - checks whether the current console is visible
4152 return *vc->vc_display_fg == vc; in con_is_visible()
4157 * con_debug_enter - prepare the console for the kernel debugger
4169 saved_vc_mode = vc->vc_mode; in con_debug_enter()
4171 vc->vc_mode = KD_TEXT; in con_debug_enter()
4173 if (vc->vc_sw->con_debug_enter) in con_debug_enter()
4174 vc->vc_sw->con_debug_enter(vc); in con_debug_enter()
4177 if (vc->vc_rows < 999) { in con_debug_enter()
4186 snprintf(lns, 4, "%i", vc->vc_rows); in con_debug_enter()
4190 if (vc->vc_cols < 999) { in con_debug_enter()
4199 snprintf(cols, 4, "%i", vc->vc_cols); in con_debug_enter()
4208 * con_debug_leave - restore console state
4221 vc_cons[fg_console].d->vc_mode = saved_vc_mode; in con_debug_leave()
4224 if (vc->vc_sw->con_debug_leave) in con_debug_leave()
4225 vc->vc_sw->con_debug_leave(vc); in con_debug_leave()
4231 struct module *owner = csw->owner; in do_register_con_driver()
4239 return -ENODEV; in do_register_con_driver()
4245 if (con_driver->con == csw) { in do_register_con_driver()
4246 retval = -EBUSY; in do_register_con_driver()
4251 desc = csw->con_startup(); in do_register_con_driver()
4253 retval = -ENODEV; in do_register_con_driver()
4257 retval = -EINVAL; in do_register_con_driver()
4262 if (con_driver->con == NULL && in do_register_con_driver()
4263 !(con_driver->flag & CON_DRIVER_FLAG_ZOMBIE)) { in do_register_con_driver()
4264 con_driver->con = csw; in do_register_con_driver()
4265 con_driver->desc = desc; in do_register_con_driver()
4266 con_driver->node = i; in do_register_con_driver()
4267 con_driver->flag = CON_DRIVER_FLAG_MODULE | in do_register_con_driver()
4269 con_driver->first = first; in do_register_con_driver()
4270 con_driver->last = last; in do_register_con_driver()
4279 con_driver->dev = in do_register_con_driver()
4281 MKDEV(0, con_driver->node), in do_register_con_driver()
4283 "vtcon%i", con_driver->node); in do_register_con_driver()
4284 if (IS_ERR(con_driver->dev)) { in do_register_con_driver()
4286 con_driver->desc, PTR_ERR(con_driver->dev)); in do_register_con_driver()
4287 con_driver->dev = NULL; in do_register_con_driver()
4299 * do_unregister_con_driver - unregister console driver from console layer
4315 return -EBUSY; in do_unregister_con_driver()
4318 return -EINVAL; in do_unregister_con_driver()
4323 if (con_driver->con == csw) { in do_unregister_con_driver()
4334 con_driver->con = NULL; in do_unregister_con_driver()
4335 con_driver->flag = CON_DRIVER_FLAG_ZOMBIE; in do_unregister_con_driver()
4342 return -ENODEV; in do_unregister_con_driver()
4355 if (!(con_driver->flag & CON_DRIVER_FLAG_ZOMBIE)) in con_driver_unregister_callback()
4361 device_destroy(&vtconsole_class, MKDEV(0, con_driver->node)); in con_driver_unregister_callback()
4365 if (WARN_ON_ONCE(con_driver->con)) in con_driver_unregister_callback()
4366 con_driver->con = NULL; in con_driver_unregister_callback()
4367 con_driver->desc = NULL; in con_driver_unregister_callback()
4368 con_driver->dev = NULL; in con_driver_unregister_callback()
4369 con_driver->node = 0; in con_driver_unregister_callback()
4370 WARN_ON_ONCE(con_driver->flag != CON_DRIVER_FLAG_ZOMBIE); in con_driver_unregister_callback()
4371 con_driver->flag = 0; in con_driver_unregister_callback()
4372 con_driver->first = 0; in con_driver_unregister_callback()
4373 con_driver->last = 0; in con_driver_unregister_callback()
4396 if (err == -EBUSY) in do_take_over_console()
4430 if (con->con && !con->dev) { in vtconsole_class_init()
4431 con->dev = in vtconsole_class_init()
4433 MKDEV(0, con->node), in vtconsole_class_init()
4435 "vtcon%i", con->node); in vtconsole_class_init()
4437 if (IS_ERR(con->dev)) { in vtconsole_class_init()
4439 con->desc, PTR_ERR(con->dev)); in vtconsole_class_init()
4440 con->dev = NULL; in vtconsole_class_init()
4460 return -EFAULT; in set_vesa_blanking()
4481 vc->vc_sw->con_blank(vc, vesa_blank_mode + 1, 0); in do_blank_screen()
4490 vc->vc_sw->con_blank(vc, VESA_VSYNC_SUSPEND, 1); in do_blank_screen()
4500 if (vc->vc_mode != KD_TEXT) { in do_blank_screen()
4511 i = vc->vc_sw->con_blank(vc, vesa_off_interval ? VESA_VSYNC_SUSPEND : in do_blank_screen()
4524 vt_event_post(VT_EVENT_BLANK, vc->vc_num, vc->vc_num); in do_blank_screen()
4554 if (vc->vc_mode != KD_TEXT) in do_unblank_screen()
4563 if (vc->vc_sw->con_blank(vc, VESA_NO_BLANKING, leaving_gfx)) in do_unblank_screen()
4564 /* Low-level driver cannot restore -> do it ourselves */ in do_unblank_screen()
4570 vt_event_post(VT_EVENT_UNBLANK, vc->vc_num, vc->vc_num); in do_unblank_screen()
4604 * function. --BenH. in poke_blanked_console()
4614 if (ignore_poke || !vc_cons[fg_console].d || vc_cons[fg_console].d->vc_mode == KD_GRAPHICS) in poke_blanked_console()
4632 if (vc->vc_mode != KD_GRAPHICS && vc->vc_sw->con_set_palette) in set_palette()
4633 vc->vc_sw->con_set_palette(vc, color_table); in set_palette()
4647 return -EFAULT; in con_set_cmap()
4659 vc_cons[i].d->vc_palette[k++] = default_red[j]; in con_set_cmap()
4660 vc_cons[i].d->vc_palette[k++] = default_grn[j]; in con_set_cmap()
4661 vc_cons[i].d->vc_palette[k++] = default_blu[j]; in con_set_cmap()
4684 return -EFAULT; in con_get_cmap()
4693 vc->vc_palette[k++] = default_red[j]; in reset_palette()
4694 vc->vc_palette[k++] = default_grn[j]; in reset_palette()
4695 vc->vc_palette[k++] = default_blu[j]; in reset_palette()
4707 * EGA/VGA fonts. It is up to the actual low-level console-driver convert data
4721 int rc = -EINVAL; in con_font_get()
4723 unsigned int vpitch = op->op == KD_FONT_OP_GET_TALL ? op->height : 32; in con_font_get()
4726 return -EINVAL; in con_font_get()
4728 if (op->data) { in con_font_get()
4731 return -ENOMEM; in con_font_get()
4736 if (vc->vc_mode != KD_TEXT) in con_font_get()
4737 rc = -EINVAL; in con_font_get()
4738 else if (vc->vc_sw->con_font_get) in con_font_get()
4739 rc = vc->vc_sw->con_font_get(vc, &font, vpitch); in con_font_get()
4741 rc = -ENOSYS; in con_font_get()
4749 if (op->data && font.charcount > op->charcount) in con_font_get()
4750 rc = -ENOSPC; in con_font_get()
4751 if (font.width > op->width || font.height > op->height) in con_font_get()
4752 rc = -ENOSPC; in con_font_get()
4756 op->height = font.height; in con_font_get()
4757 op->width = font.width; in con_font_get()
4758 op->charcount = font.charcount; in con_font_get()
4760 if (op->data && copy_to_user(op->data, font.data, c)) in con_font_get()
4761 rc = -EFAULT; in con_font_get()
4771 int rc = -EINVAL; in con_font_set()
4773 unsigned int vpitch = op->op == KD_FONT_OP_SET_TALL ? op->height : 32; in con_font_set()
4775 if (vc->vc_mode != KD_TEXT) in con_font_set()
4776 return -EINVAL; in con_font_set()
4777 if (!op->data) in con_font_set()
4778 return -EINVAL; in con_font_set()
4779 if (op->charcount > max_font_glyphs) in con_font_set()
4780 return -EINVAL; in con_font_set()
4781 if (op->width <= 0 || op->width > max_font_width || !op->height || in con_font_set()
4782 op->height > max_font_height) in con_font_set()
4783 return -EINVAL; in con_font_set()
4784 if (vpitch < op->height) in con_font_set()
4785 return -EINVAL; in con_font_set()
4786 size = (op->width+7)/8 * vpitch * op->charcount; in con_font_set()
4788 return -ENOSPC; in con_font_set()
4790 font.data = memdup_user(op->data, size); in con_font_set()
4794 font.charcount = op->charcount; in con_font_set()
4795 font.width = op->width; in con_font_set()
4796 font.height = op->height; in con_font_set()
4799 if (vc->vc_mode != KD_TEXT) in con_font_set()
4800 rc = -EINVAL; in con_font_set()
4801 else if (vc->vc_sw->con_font_set) { in con_font_set()
4804 rc = vc->vc_sw->con_font_set(vc, &font, vpitch, op->flags); in con_font_set()
4806 rc = -ENOSYS; in con_font_set()
4814 struct console_font font = {.width = op->width, .height = op->height}; in con_font_default()
4820 if (!op->data) in con_font_default()
4822 else if (strncpy_from_user(name, op->data, MAX_FONT_NAME - 1) < 0) in con_font_default()
4823 return -EFAULT; in con_font_default()
4825 name[MAX_FONT_NAME - 1] = 0; in con_font_default()
4828 if (vc->vc_mode != KD_TEXT) { in con_font_default()
4830 return -EINVAL; in con_font_default()
4832 if (vc->vc_sw->con_font_default) { in con_font_default()
4835 rc = vc->vc_sw->con_font_default(vc, &font, s); in con_font_default()
4837 rc = -ENOSYS; in con_font_default()
4840 op->width = font.width; in con_font_default()
4841 op->height = font.height; in con_font_default()
4848 switch (op->op) { in con_font_op()
4859 return -EINVAL; in con_font_op()
4861 return -ENOSYS; in con_font_op()
4874 if (w & vc->vc_hi_font_mask) in screen_glyph()
4882 u32 **uni_lines = vc->vc_uni_lines; in screen_glyph_unicode()
4885 return uni_lines[n / vc->vc_cols][n % vc->vc_cols]; in screen_glyph_unicode()
4891 /* used by vcs - note the word offset */
4898 void getconsxy(const struct vc_data *vc, unsigned char xy[static 2]) in getconsxy()
4901 xy[0] = min(vc->state.x, 0xFFu); in getconsxy()
4902 xy[1] = min(vc->state.y, 0xFFu); in getconsxy()
4905 void putconsxy(struct vc_data *vc, unsigned char xy[static const 2]) in putconsxy()
4908 gotoxy(vc, xy[0], xy[1]); in putconsxy()
4914 if ((unsigned long)org == vc->vc_pos && softcursor_original != -1) in vcs_scr_readw()
4922 if ((unsigned long)org == vc->vc_pos) { in vcs_scr_writew()
4923 softcursor_original = -1; in vcs_scr_writew()