Lines Matching refs:vc

136 struct vc vc_cons [MAX_NR_CONSOLES];
142 static void vc_init(struct vc_data *vc, int do_clear);
143 static void gotoxy(struct vc_data *vc, int new_x, int new_y);
144 static void restore_cur(struct vc_data *vc);
145 static void save_cur(struct vc_data *vc);
146 static void reset_terminal(struct vc_data *vc, int do_clear);
149 static void set_cursor(struct vc_data *vc);
150 static void hide_cursor(struct vc_data *vc);
154 static void set_palette(struct vc_data *vc);
264 static void notify_write(struct vc_data *vc, unsigned int unicode) in notify_write() argument
266 struct vt_notifier_param param = { .vc = vc, .c = unicode }; in notify_write()
270 static void notify_update(struct vc_data *vc) in notify_update() argument
272 struct vt_notifier_param param = { .vc = vc }; in notify_update()
279 static inline bool con_is_fg(const struct vc_data *vc) in con_is_fg() argument
281 return vc->vc_num == fg_console; in con_is_fg()
284 static inline bool con_should_update(const struct vc_data *vc) in con_should_update() argument
286 return con_is_visible(vc) && !console_blanked; in con_should_update()
289 static inline u16 *screenpos(const struct vc_data *vc, unsigned int offset, in screenpos() argument
292 unsigned long origin = viewed ? vc->vc_visible_origin : vc->vc_origin; in screenpos()
297 static void con_putc(struct vc_data *vc, u16 ca, unsigned int y, unsigned int x) in con_putc() argument
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()
357 static void vc_uniscr_set(struct vc_data *vc, u32 **new_uni_lines) in vc_uniscr_set() argument
359 vc_uniscr_free(vc->vc_uni_lines); in vc_uniscr_set()
360 vc->vc_uni_lines = new_uni_lines; in vc_uniscr_set()
363 static void vc_uniscr_putc(struct vc_data *vc, u32 uc) in vc_uniscr_putc() argument
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()
369 static void vc_uniscr_insert(struct vc_data *vc, unsigned int nr) in vc_uniscr_insert() argument
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()
380 static void vc_uniscr_delete(struct vc_data *vc, unsigned int nr) in vc_uniscr_delete() argument
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()
391 static void vc_uniscr_clear_line(struct vc_data *vc, unsigned int x, in vc_uniscr_clear_line() argument
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()
398 static void vc_uniscr_clear_lines(struct vc_data *vc, unsigned int y, in vc_uniscr_clear_lines() argument
401 if (vc->vc_uni_lines) in vc_uniscr_clear_lines()
403 memset32(vc->vc_uni_lines[y++], ' ', vc->vc_cols); in vc_uniscr_clear_lines()
428 static void vc_uniscr_scroll(struct vc_data *vc, unsigned int top, in vc_uniscr_scroll() argument
432 u32 **uni_lines = vc->vc_uni_lines; in vc_uniscr_scroll()
440 vc_uniscr_clear_lines(vc, top, nr); in vc_uniscr_scroll()
443 vc_uniscr_clear_lines(vc, bottom - nr, nr); in vc_uniscr_scroll()
447 static u32 vc_uniscr_getc(struct vc_data *vc, int relative_pos) in vc_uniscr_getc() argument
449 int pos = vc->state.x + vc->vc_need_wrap + relative_pos; in vc_uniscr_getc()
451 if (vc->vc_uni_lines && in_range(pos, 0, vc->vc_cols)) in vc_uniscr_getc()
452 return vc->vc_uni_lines[vc->state.y][pos]; in vc_uniscr_getc()
493 int vc_uniscr_check(struct vc_data *vc) in vc_uniscr_check() argument
501 if (!vc->vc_utf) in vc_uniscr_check()
504 if (vc->vc_uni_lines) in vc_uniscr_check()
507 uni_lines = vc_uniscr_alloc(vc->vc_cols, vc->vc_rows); in vc_uniscr_check()
517 p = (unsigned short *)vc->vc_origin; in vc_uniscr_check()
518 mask = vc->vc_hi_font_mask | 0xff; in vc_uniscr_check()
519 for (y = 0; y < vc->vc_rows; y++) { in vc_uniscr_check()
521 for (x = 0; x < vc->vc_cols; x++) { in vc_uniscr_check()
523 line[x] = inverse_translate(vc, glyph, true); in vc_uniscr_check()
527 vc->vc_uni_lines = uni_lines; in vc_uniscr_check()
537 void vc_uniscr_copy_line(const struct vc_data *vc, void *dest, bool viewed, in vc_uniscr_copy_line() argument
540 u32 **uni_lines = vc->vc_uni_lines; in vc_uniscr_copy_line()
541 int offset = row * vc->vc_size_row + col * 2; in vc_uniscr_copy_line()
547 pos = (unsigned long)screenpos(vc, offset, viewed); in vc_uniscr_copy_line()
548 if (pos >= vc->vc_origin && pos < vc->vc_scr_end) { in vc_uniscr_copy_line()
554 row = (pos - vc->vc_origin) / vc->vc_size_row; in vc_uniscr_copy_line()
555 col = ((pos - vc->vc_origin) % vc->vc_size_row) / 2; in vc_uniscr_copy_line()
565 int mask = vc->vc_hi_font_mask | 0xff; in vc_uniscr_copy_line()
569 *uni_buf++ = inverse_translate(vc, glyph, true); in vc_uniscr_copy_line()
574 static void con_scroll(struct vc_data *vc, unsigned int top, in con_scroll() argument
583 if (bottom > vc->vc_rows || top >= bottom || nr < 1) in con_scroll()
586 vc_uniscr_scroll(vc, top, bottom, dir, nr); in con_scroll()
587 if (con_is_visible(vc) && in con_scroll()
588 vc->vc_sw->con_scroll(vc, top, bottom, dir, nr)) in con_scroll()
591 src = clear = (u16 *)(vc->vc_origin + vc->vc_size_row * top); in con_scroll()
592 dst = (u16 *)(vc->vc_origin + vc->vc_size_row * (top + nr)); in con_scroll()
595 clear = src + (rows - nr) * vc->vc_cols; in con_scroll()
598 scr_memmovew(dst, src, (rows - nr) * vc->vc_size_row); in con_scroll()
599 scr_memsetw(clear, vc->vc_video_erase_char, vc->vc_size_row * nr); in con_scroll()
602 static void do_update_region(struct vc_data *vc, unsigned long start, int count) in do_update_region() argument
607 offset = (start - vc->vc_origin) / 2; in do_update_region()
608 xx = offset % vc->vc_cols; in do_update_region()
609 yy = offset / vc->vc_cols; in do_update_region()
615 while (xx < vc->vc_cols && count) { in do_update_region()
618 vc->vc_sw->con_putcs(vc, q, p-q, yy, startx); in do_update_region()
628 vc->vc_sw->con_putcs(vc, q, p-q, yy, startx); in do_update_region()
636 void update_region(struct vc_data *vc, unsigned long start, int count) in update_region() argument
640 if (con_should_update(vc)) { in update_region()
641 hide_cursor(vc); in update_region()
642 do_update_region(vc, start, count); in update_region()
643 set_cursor(vc); in update_region()
650 static u8 build_attr(struct vc_data *vc, u8 _color, in build_attr() argument
654 if (vc->vc_sw->con_build_attr) in build_attr()
655 return vc->vc_sw->con_build_attr(vc, _color, _intensity, in build_attr()
670 if (!vc->vc_can_do_color) in build_attr()
677 a = (a & 0xF0) | vc->vc_itcolor; in build_attr()
679 a = (a & 0xf0) | vc->vc_ulcolor; in build_attr()
681 a = (a & 0xf0) | vc->vc_halfcolor; in build_attr()
688 if (vc->vc_hi_font_mask == 0x100) in build_attr()
694 static void update_attr(struct vc_data *vc) in update_attr() argument
696 vc->vc_attr = build_attr(vc, vc->state.color, vc->state.intensity, in update_attr()
697 vc->state.blink, vc->state.underline, in update_attr()
698 vc->state.reverse ^ vc->vc_decscnm, vc->state.italic); in update_attr()
699 vc->vc_video_erase_char = ' ' | (build_attr(vc, vc->state.color, in update_attr()
700 VCI_NORMAL, vc->state.blink, false, in update_attr()
701 vc->vc_decscnm, false) << 8); in update_attr()
705 void invert_screen(struct vc_data *vc, int offset, int count, bool viewed) in invert_screen() argument
712 p = screenpos(vc, offset, viewed); in invert_screen()
713 if (vc->vc_sw->con_invert_region) { in invert_screen()
714 vc->vc_sw->con_invert_region(vc, p, count); in invert_screen()
720 if (!vc->vc_can_do_color) { in invert_screen()
727 } else if (vc->vc_hi_font_mask == 0x100) { in invert_screen()
748 if (con_should_update(vc)) in invert_screen()
749 do_update_region(vc, (unsigned long) p, count); in invert_screen()
750 notify_update(vc); in invert_screen()
754 void complement_pos(struct vc_data *vc, int offset) in complement_pos() argument
763 old_offset < vc->vc_screenbuf_size) { in complement_pos()
764 scr_writew(old, screenpos(vc, old_offset, true)); in complement_pos()
765 if (con_should_update(vc)) in complement_pos()
766 con_putc(vc, old, oldy, oldx); in complement_pos()
767 notify_update(vc); in complement_pos()
773 offset < vc->vc_screenbuf_size) { in complement_pos()
775 u16 *p = screenpos(vc, offset, true); in complement_pos()
777 new = old ^ vc->vc_complement_mask; in complement_pos()
779 if (con_should_update(vc)) { in complement_pos()
780 oldx = (offset >> 1) % vc->vc_cols; in complement_pos()
781 oldy = (offset >> 1) / vc->vc_cols; in complement_pos()
782 con_putc(vc, new, oldy, oldx); in complement_pos()
784 notify_update(vc); in complement_pos()
788 static void insert_char(struct vc_data *vc, unsigned int nr) in insert_char() argument
790 unsigned short *p = (unsigned short *) vc->vc_pos; in insert_char()
792 vc_uniscr_insert(vc, nr); 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()
796 if (con_should_update(vc)) in insert_char()
797 do_update_region(vc, (unsigned long) p, in insert_char()
798 vc->vc_cols - vc->state.x); in insert_char()
801 static void delete_char(struct vc_data *vc, unsigned int nr) in delete_char() argument
803 unsigned short *p = (unsigned short *) vc->vc_pos; in delete_char()
805 vc_uniscr_delete(vc, nr); 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()
810 if (con_should_update(vc)) in delete_char()
811 do_update_region(vc, (unsigned long) p, in delete_char()
812 vc->vc_cols - vc->state.x); in delete_char()
817 static void add_softcursor(struct vc_data *vc) in add_softcursor() argument
819 int i = scr_readw((u16 *) vc->vc_pos); in add_softcursor()
820 u32 type = vc->vc_cursor_type; in add_softcursor()
834 scr_writew(i, (u16 *)vc->vc_pos); in add_softcursor()
835 if (con_should_update(vc)) in add_softcursor()
836 con_putc(vc, i, vc->state.y, vc->state.x); in add_softcursor()
839 static void hide_softcursor(struct vc_data *vc) in hide_softcursor() argument
842 scr_writew(softcursor_original, (u16 *)vc->vc_pos); in hide_softcursor()
843 if (con_should_update(vc)) in hide_softcursor()
844 con_putc(vc, softcursor_original, vc->state.y, in hide_softcursor()
845 vc->state.x); in hide_softcursor()
850 static void hide_cursor(struct vc_data *vc) in hide_cursor() argument
852 if (vc_is_sel(vc)) in hide_cursor()
855 vc->vc_sw->con_cursor(vc, false); in hide_cursor()
856 hide_softcursor(vc); in hide_cursor()
859 static void set_cursor(struct vc_data *vc) in set_cursor() argument
861 if (!con_is_fg(vc) || console_blanked || vc->vc_mode == KD_GRAPHICS) in set_cursor()
863 if (vc->vc_deccm) { in set_cursor()
864 if (vc_is_sel(vc)) in set_cursor()
866 add_softcursor(vc); in set_cursor()
867 if (CUR_SIZE(vc->vc_cursor_type) != CUR_NONE) in set_cursor()
868 vc->vc_sw->con_cursor(vc, true); in set_cursor()
870 hide_cursor(vc); in set_cursor()
873 static void set_origin(struct vc_data *vc) in set_origin() argument
877 if (!con_is_visible(vc) || in set_origin()
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()
887 static void save_screen(struct vc_data *vc) in save_screen() argument
891 if (vc->vc_sw->con_save_screen) in save_screen()
892 vc->vc_sw->con_save_screen(vc); in save_screen()
895 static void flush_scrollback(struct vc_data *vc) in flush_scrollback() argument
899 set_origin(vc); in flush_scrollback()
900 if (!con_is_visible(vc)) in flush_scrollback()
909 hide_cursor(vc); in flush_scrollback()
910 vc->vc_sw->con_switch(vc); in flush_scrollback()
911 set_cursor(vc); in flush_scrollback()
918 void clear_buffer_attributes(struct vc_data *vc) in clear_buffer_attributes() argument
920 unsigned short *p = (unsigned short *)vc->vc_origin; in clear_buffer_attributes()
921 int count = vc->vc_screenbuf_size / 2; in clear_buffer_attributes()
922 int mask = vc->vc_hi_font_mask | 0xff; in clear_buffer_attributes()
925 scr_writew((scr_readw(p)&mask) | (vc->vc_video_erase_char & ~mask), p); in clear_buffer_attributes()
929 void redraw_screen(struct vc_data *vc, int is_switch) in redraw_screen() argument
935 if (!vc) { in redraw_screen()
943 if (old_vc == vc) in redraw_screen()
945 if (!con_is_visible(vc)) in redraw_screen()
947 *vc->vc_display_fg = vc; in redraw_screen()
948 fg_console = vc->vc_num; in redraw_screen()
957 hide_cursor(vc); in redraw_screen()
963 int old_was_color = vc->vc_can_do_color; in redraw_screen()
965 set_origin(vc); in redraw_screen()
966 update = vc->vc_sw->con_switch(vc); in redraw_screen()
967 set_palette(vc); in redraw_screen()
974 if (old_was_color != vc->vc_can_do_color) { in redraw_screen()
975 update_attr(vc); in redraw_screen()
976 clear_buffer_attributes(vc); in redraw_screen()
979 if (update && vc->vc_mode != KD_GRAPHICS) in redraw_screen()
980 do_update_region(vc, vc->vc_origin, vc->vc_screenbuf_size / 2); in redraw_screen()
982 set_cursor(vc); in redraw_screen()
985 notify_update(vc); in redraw_screen()
999 static void visual_init(struct vc_data *vc, int num, bool init) in visual_init() argument
1002 if (vc->vc_sw) in visual_init()
1003 module_put(vc->vc_sw->owner); in visual_init()
1004 vc->vc_sw = conswitchp; in visual_init()
1007 vc->vc_sw = con_driver_map[num]; in visual_init()
1009 __module_get(vc->vc_sw->owner); in visual_init()
1010 vc->vc_num = num; in visual_init()
1011 vc->vc_display_fg = &master_display_fg; in visual_init()
1012 if (vc->uni_pagedict_loc) in visual_init()
1013 con_free_unimap(vc); in visual_init()
1014 vc->uni_pagedict_loc = &vc->uni_pagedict; in visual_init()
1015 vc->uni_pagedict = NULL; in visual_init()
1016 vc->vc_hi_font_mask = 0; in visual_init()
1017 vc->vc_complement_mask = 0; in visual_init()
1018 vc->vc_can_do_color = 0; in visual_init()
1019 vc->vc_cur_blink_ms = DEFAULT_CURSOR_BLINK_MS; in visual_init()
1020 vc->vc_sw->con_init(vc, init); in visual_init()
1021 if (!vc->vc_complement_mask) in visual_init()
1022 vc->vc_complement_mask = vc->vc_can_do_color ? 0x7700 : 0x0800; in visual_init()
1023 vc->vc_s_complement_mask = vc->vc_complement_mask; in visual_init()
1024 vc->vc_size_row = vc->vc_cols << 1; in visual_init()
1025 vc->vc_screenbuf_size = vc->vc_rows * vc->vc_size_row; in visual_init()
1029 static void visual_deinit(struct vc_data *vc) in visual_deinit() argument
1031 vc->vc_sw->con_deinit(vc); in visual_deinit()
1032 module_put(vc->vc_sw->owner); in visual_deinit()
1037 struct vc_data *vc = container_of(port, struct vc_data, port); in vc_port_destruct() local
1039 kfree(vc); in vc_port_destruct()
1057 struct vc_data *vc; in vc_allocate() local
1074 param.vc = vc = kzalloc(sizeof(struct vc_data), GFP_KERNEL); in vc_allocate()
1075 if (!vc) in vc_allocate()
1078 vc_cons[currcons].d = vc; in vc_allocate()
1079 tty_port_init(&vc->port); in vc_allocate()
1080 vc->port.ops = &vc_port_ops; in vc_allocate()
1083 visual_init(vc, currcons, true); in vc_allocate()
1085 if (!*vc->uni_pagedict_loc) in vc_allocate()
1086 con_set_default_unimap(vc); in vc_allocate()
1089 if (vc->vc_cols > VC_MAXCOL || vc->vc_rows > VC_MAXROW || in vc_allocate()
1090 vc->vc_screenbuf_size > KMALLOC_MAX_SIZE || !vc->vc_screenbuf_size) in vc_allocate()
1093 vc->vc_screenbuf = kzalloc(vc->vc_screenbuf_size, GFP_KERNEL); in vc_allocate()
1094 if (!vc->vc_screenbuf) in vc_allocate()
1102 vc_init(vc, 1); in vc_allocate()
1108 visual_deinit(vc); in vc_allocate()
1109 kfree(vc); in vc_allocate()
1114 static inline int resize_screen(struct vc_data *vc, int width, int height, in resize_screen() argument
1120 if (vc->vc_sw->con_resize) in resize_screen()
1121 err = vc->vc_sw->con_resize(vc, width, height, from_user); in resize_screen()
1141 static int vc_do_resize(struct tty_struct *tty, struct vc_data *vc, in vc_do_resize() argument
1156 new_cols = (cols ? cols : vc->vc_cols); in vc_do_resize()
1157 new_rows = (lines ? lines : vc->vc_rows); in vc_do_resize()
1161 if (new_cols == vc->vc_cols && new_rows == vc->vc_rows) { in vc_do_resize()
1178 return resize_screen(vc, new_cols, new_rows, from_user); in vc_do_resize()
1187 if (vc->vc_uni_lines) { in vc_do_resize()
1195 if (vc_is_sel(vc)) in vc_do_resize()
1198 old_rows = vc->vc_rows; in vc_do_resize()
1199 old_row_size = vc->vc_size_row; in vc_do_resize()
1201 err = resize_screen(vc, new_cols, new_rows, from_user); in vc_do_resize()
1208 vc->vc_rows = new_rows; in vc_do_resize()
1209 vc->vc_cols = new_cols; in vc_do_resize()
1210 vc->vc_size_row = new_row_size; in vc_do_resize()
1211 vc->vc_screenbuf_size = new_screen_size; in vc_do_resize()
1215 old_origin = vc->vc_origin; in vc_do_resize()
1219 if (vc->state.y > new_rows) { in vc_do_resize()
1220 if (old_rows - vc->state.y < new_rows) { in vc_do_resize()
1231 first_copied_row = (vc->state.y - new_rows/2); in vc_do_resize()
1239 vc->vc_uni_lines, rlth/2, first_copied_row, in vc_do_resize()
1241 vc_uniscr_set(vc, new_uniscr); in vc_do_resize()
1243 update_attr(vc); in vc_do_resize()
1250 vc->vc_video_erase_char, rrem); in vc_do_resize()
1255 scr_memsetw((void *)new_origin, vc->vc_video_erase_char, in vc_do_resize()
1257 oldscreen = vc->vc_screenbuf; in vc_do_resize()
1258 vc->vc_screenbuf = newscreen; in vc_do_resize()
1259 vc->vc_screenbuf_size = new_screen_size; in vc_do_resize()
1260 set_origin(vc); in vc_do_resize()
1264 vc->vc_top = 0; in vc_do_resize()
1265 vc->vc_bottom = vc->vc_rows; in vc_do_resize()
1266 gotoxy(vc, vc->state.x, vc->state.y); in vc_do_resize()
1267 save_cur(vc); in vc_do_resize()
1274 ws.ws_row = vc->vc_rows; in vc_do_resize()
1275 ws.ws_col = vc->vc_cols; in vc_do_resize()
1276 ws.ws_ypixel = vc->vc_scan_lines; in vc_do_resize()
1280 if (con_is_visible(vc)) in vc_do_resize()
1281 update_screen(vc); in vc_do_resize()
1282 vt_event_post(VT_EVENT_RESIZE, vc->vc_num, vc->vc_num); in vc_do_resize()
1283 notify_update(vc); in vc_do_resize()
1300 int __vc_resize(struct vc_data *vc, unsigned int cols, unsigned int rows, in __vc_resize() argument
1303 return vc_do_resize(vc->port.tty, vc, cols, rows, from_user); in __vc_resize()
1320 struct vc_data *vc = tty->driver_data; in vt_resize() local
1323 return vc_do_resize(tty, vc, ws->ws_col, ws->ws_row, false); in vt_resize()
1328 struct vc_data *vc = NULL; in vc_deallocate() local
1335 param.vc = vc = vc_cons[currcons].d; in vc_deallocate()
1338 visual_deinit(vc); in vc_deallocate()
1339 con_free_unimap(vc); in vc_deallocate()
1340 put_pid(vc->vt_pid); in vc_deallocate()
1341 vc_uniscr_set(vc, NULL); in vc_deallocate()
1342 kfree(vc->vc_screenbuf); in vc_deallocate()
1344 if (vc->vc_saved_screen != NULL) { in vc_deallocate()
1345 kfree(vc->vc_saved_screen); in vc_deallocate()
1346 vc->vc_saved_screen = NULL; in vc_deallocate()
1349 return vc; in vc_deallocate()
1358 #define set_kbd(vc, x) vt_set_kbd_mode_bit((vc)->vc_num, (x)) argument
1359 #define clr_kbd(vc, x) vt_clr_kbd_mode_bit((vc)->vc_num, (x)) argument
1360 #define is_kbd(vc, x) vt_get_kbd_mode_bit((vc)->vc_num, (x)) argument
1398 static void gotoxy(struct vc_data *vc, int new_x, int new_y) in gotoxy() argument
1403 vc->state.x = 0; in gotoxy()
1405 if (new_x >= vc->vc_cols) in gotoxy()
1406 vc->state.x = vc->vc_cols - 1; in gotoxy()
1408 vc->state.x = new_x; in gotoxy()
1411 if (vc->vc_decom) { in gotoxy()
1412 min_y = vc->vc_top; in gotoxy()
1413 max_y = vc->vc_bottom; in gotoxy()
1416 max_y = vc->vc_rows; in gotoxy()
1419 vc->state.y = min_y; in gotoxy()
1421 vc->state.y = max_y - 1; in gotoxy()
1423 vc->state.y = new_y; in gotoxy()
1424 vc->vc_pos = vc->vc_origin + vc->state.y * vc->vc_size_row + in gotoxy()
1425 (vc->state.x << 1); in gotoxy()
1426 vc->vc_need_wrap = 0; in gotoxy()
1430 static void gotoxay(struct vc_data *vc, int new_x, int new_y) in gotoxay() argument
1432 gotoxy(vc, new_x, vc->vc_decom ? (vc->vc_top + new_y) : new_y); in gotoxay()
1435 void scrollback(struct vc_data *vc) in scrollback() argument
1437 scrolldelta(-(vc->vc_rows / 2)); in scrollback()
1440 void scrollfront(struct vc_data *vc, int lines) in scrollfront() argument
1443 lines = vc->vc_rows / 2; in scrollfront()
1447 static void lf(struct vc_data *vc) in lf() argument
1452 if (vc->state.y + 1 == vc->vc_bottom) in lf()
1453 con_scroll(vc, vc->vc_top, vc->vc_bottom, SM_UP, 1); in lf()
1454 else if (vc->state.y < vc->vc_rows - 1) { in lf()
1455 vc->state.y++; in lf()
1456 vc->vc_pos += vc->vc_size_row; in lf()
1458 vc->vc_need_wrap = 0; in lf()
1459 notify_write(vc, '\n'); in lf()
1462 static void ri(struct vc_data *vc) in ri() argument
1467 if (vc->state.y == vc->vc_top) in ri()
1468 con_scroll(vc, vc->vc_top, vc->vc_bottom, SM_DOWN, 1); in ri()
1469 else if (vc->state.y > 0) { in ri()
1470 vc->state.y--; in ri()
1471 vc->vc_pos -= vc->vc_size_row; in ri()
1473 vc->vc_need_wrap = 0; in ri()
1476 static inline void cr(struct vc_data *vc) in cr() argument
1478 vc->vc_pos -= vc->state.x << 1; in cr()
1479 vc->vc_need_wrap = vc->state.x = 0; in cr()
1480 notify_write(vc, '\r'); in cr()
1483 static inline void bs(struct vc_data *vc) in bs() argument
1485 if (vc->state.x) { in bs()
1486 vc->vc_pos -= 2; in bs()
1487 vc->state.x--; in bs()
1488 vc->vc_need_wrap = 0; in bs()
1489 notify_write(vc, '\b'); in bs()
1493 static inline void del(struct vc_data *vc) in del() argument
1505 static void csi_J(struct vc_data *vc, enum CSI_J vpar) in csi_J() argument
1512 vc_uniscr_clear_line(vc, vc->state.x, in csi_J()
1513 vc->vc_cols - vc->state.x); in csi_J()
1514 vc_uniscr_clear_lines(vc, vc->state.y + 1, in csi_J()
1515 vc->vc_rows - vc->state.y - 1); in csi_J()
1516 count = (vc->vc_scr_end - vc->vc_pos) >> 1; in csi_J()
1517 start = (unsigned short *)vc->vc_pos; in csi_J()
1520 vc_uniscr_clear_line(vc, 0, vc->state.x + 1); in csi_J()
1521 vc_uniscr_clear_lines(vc, 0, vc->state.y); in csi_J()
1522 count = ((vc->vc_pos - vc->vc_origin) >> 1) + 1; in csi_J()
1523 start = (unsigned short *)vc->vc_origin; in csi_J()
1526 flush_scrollback(vc); in csi_J()
1529 vc_uniscr_clear_lines(vc, 0, vc->vc_rows); in csi_J()
1530 count = vc->vc_cols * vc->vc_rows; in csi_J()
1531 start = (unsigned short *)vc->vc_origin; in csi_J()
1536 scr_memsetw(start, vc->vc_video_erase_char, 2 * count); in csi_J()
1537 if (con_should_update(vc)) in csi_J()
1538 do_update_region(vc, (unsigned long) start, count); in csi_J()
1539 vc->vc_need_wrap = 0; in csi_J()
1548 static void csi_K(struct vc_data *vc) in csi_K() argument
1551 unsigned short *start = (unsigned short *)vc->vc_pos; in csi_K()
1554 switch (vc->vc_par[0]) { in csi_K()
1557 count = vc->vc_cols - vc->state.x; in csi_K()
1560 offset = -vc->state.x; in csi_K()
1561 count = vc->state.x + 1; in csi_K()
1564 offset = -vc->state.x; in csi_K()
1565 count = vc->vc_cols; in csi_K()
1570 vc_uniscr_clear_line(vc, vc->state.x + offset, count); in csi_K()
1571 scr_memsetw(start + offset, vc->vc_video_erase_char, 2 * count); in csi_K()
1572 vc->vc_need_wrap = 0; in csi_K()
1573 if (con_should_update(vc)) in csi_K()
1574 do_update_region(vc, (unsigned long)(start + offset), count); in csi_K()
1578 static void csi_X(struct vc_data *vc) in csi_X() argument
1580 unsigned int count = clamp(vc->vc_par[0], 1, 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()
1584 if (con_should_update(vc)) in csi_X()
1585 vc->vc_sw->con_clear(vc, vc->state.y, vc->state.x, count); in csi_X()
1586 vc->vc_need_wrap = 0; in csi_X()
1589 static void default_attr(struct vc_data *vc) in default_attr() argument
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()
1622 static void rgb_foreground(struct vc_data *vc, const struct rgb *c) in rgb_foreground() argument
1635 vc->state.intensity = VCI_BOLD; in rgb_foreground()
1637 vc->state.intensity = VCI_BOLD; in rgb_foreground()
1639 vc->state.intensity = VCI_NORMAL; in rgb_foreground()
1641 vc->state.color = (vc->state.color & 0xf0) | hue; in rgb_foreground()
1644 static void rgb_background(struct vc_data *vc, const struct rgb *c) in rgb_background() argument
1647 vc->state.color = (vc->state.color & 0x0f) in rgb_background()
1660 static int vc_t416_color(struct vc_data *vc, int i, in vc_t416_color() argument
1661 void(*set_color)(struct vc_data *vc, const struct rgb *c)) in vc_t416_color() argument
1666 if (i > vc->vc_npar) in vc_t416_color()
1669 if (vc->vc_par[i] == 5 && i + 1 <= vc->vc_npar) { in vc_t416_color()
1672 rgb_from_256(vc->vc_par[i], &c); in vc_t416_color()
1673 } else if (vc->vc_par[i] == 2 && i + 3 <= vc->vc_npar) { in vc_t416_color()
1675 c.r = vc->vc_par[i + 1]; in vc_t416_color()
1676 c.g = vc->vc_par[i + 2]; in vc_t416_color()
1677 c.b = vc->vc_par[i + 3]; in vc_t416_color()
1682 set_color(vc, &c); in vc_t416_color()
1721 static void csi_m(struct vc_data *vc) in csi_m() argument
1725 for (i = 0; i <= vc->vc_npar; i++) in csi_m()
1726 switch (vc->vc_par[i]) { in csi_m()
1728 default_attr(vc); in csi_m()
1731 vc->state.intensity = VCI_BOLD; in csi_m()
1734 vc->state.intensity = VCI_HALF_BRIGHT; in csi_m()
1737 vc->state.italic = true; in csi_m()
1745 vc->state.underline = true; in csi_m()
1748 vc->state.blink = true; in csi_m()
1751 vc->state.reverse = true; in csi_m()
1757 vc->vc_translate = set_translate(vc->state.Gx_charset[vc->state.charset], vc); in csi_m()
1758 vc->vc_disp_ctrl = 0; in csi_m()
1759 vc->vc_toggle_meta = 0; in csi_m()
1765 vc->vc_translate = set_translate(IBMPC_MAP, vc); in csi_m()
1766 vc->vc_disp_ctrl = 1; in csi_m()
1767 vc->vc_toggle_meta = 0; in csi_m()
1773 vc->vc_translate = set_translate(IBMPC_MAP, vc); in csi_m()
1774 vc->vc_disp_ctrl = 1; in csi_m()
1775 vc->vc_toggle_meta = 1; in csi_m()
1778 vc->state.intensity = VCI_NORMAL; in csi_m()
1781 vc->state.italic = false; in csi_m()
1784 vc->state.underline = false; in csi_m()
1787 vc->state.blink = false; in csi_m()
1790 vc->state.reverse = false; in csi_m()
1793 i = vc_t416_color(vc, i, rgb_foreground); in csi_m()
1796 i = vc_t416_color(vc, i, rgb_background); in csi_m()
1799 vc->state.color = (vc->vc_def_color & 0x0f) | in csi_m()
1800 (vc->state.color & 0xf0); in csi_m()
1803 vc->state.color = (vc->vc_def_color & 0xf0) | in csi_m()
1804 (vc->state.color & 0x0f); in csi_m()
1807 vc->state.intensity = VCI_BOLD; in csi_m()
1808 vc->vc_par[i] -= CSI_m_BRIGHT_FG_COLOR_OFF; in csi_m()
1811 vc->vc_par[i] -= CSI_m_FG_COLOR_BEG; in csi_m()
1812 vc->state.color = color_table[vc->vc_par[i]] | in csi_m()
1813 (vc->state.color & 0xf0); in csi_m()
1816 vc->vc_par[i] -= CSI_m_BRIGHT_BG_COLOR_OFF; in csi_m()
1819 vc->vc_par[i] -= CSI_m_BG_COLOR_BEG; in csi_m()
1820 vc->state.color = (color_table[vc->vc_par[i]] << 4) | in csi_m()
1821 (vc->state.color & 0x0f); in csi_m()
1824 update_attr(vc); in csi_m()
1833 static void cursor_report(struct vc_data *vc, struct tty_struct *tty) in cursor_report() argument
1838 len = sprintf(buf, "\033[%d;%dR", vc->state.y + in cursor_report()
1839 (vc->vc_decom ? vc->vc_top + 1 : 1), in cursor_report()
1840 vc->state.x + 1); in cursor_report()
1878 struct vc_data *vc = tty->driver_data; in get_bracketed_paste() local
1880 return vc->vc_bracketed_paste; in get_bracketed_paste()
1884 static void enter_alt_screen(struct vc_data *vc) in enter_alt_screen() argument
1886 unsigned int size = vc->vc_rows * vc->vc_cols * 2; in enter_alt_screen()
1888 if (vc->vc_saved_screen != NULL) in enter_alt_screen()
1890 vc->vc_saved_screen = kmemdup((u16 *)vc->vc_origin, size, GFP_KERNEL); in enter_alt_screen()
1891 if (vc->vc_saved_screen == NULL) in enter_alt_screen()
1893 vc->vc_saved_rows = vc->vc_rows; in enter_alt_screen()
1894 vc->vc_saved_cols = vc->vc_cols; in enter_alt_screen()
1895 save_cur(vc); in enter_alt_screen()
1897 csi_J(vc, CSI_J_FULL); in enter_alt_screen()
1901 static void leave_alt_screen(struct vc_data *vc) in leave_alt_screen() argument
1903 unsigned int rows = min(vc->vc_saved_rows, vc->vc_rows); in leave_alt_screen()
1904 unsigned int cols = min(vc->vc_saved_cols, vc->vc_cols); in leave_alt_screen()
1907 if (vc->vc_saved_screen == NULL) in leave_alt_screen()
1910 src = vc->vc_saved_screen + r * vc->vc_saved_cols; in leave_alt_screen()
1911 dest = ((u16 *)vc->vc_origin) + r * vc->vc_cols; in leave_alt_screen()
1914 restore_cur(vc); in leave_alt_screen()
1916 if (con_should_update(vc)) in leave_alt_screen()
1917 do_update_region(vc, vc->vc_origin, vc->vc_screenbuf_size / 2); in leave_alt_screen()
1918 kfree(vc->vc_saved_screen); in leave_alt_screen()
1919 vc->vc_saved_screen = NULL; in leave_alt_screen()
1937 static void csi_DEC_hl(struct vc_data *vc, bool on_off) in csi_DEC_hl() argument
1941 for (i = 0; i <= vc->vc_npar; i++) in csi_DEC_hl()
1942 switch (vc->vc_par[i]) { in csi_DEC_hl()
1945 set_kbd(vc, decckm); in csi_DEC_hl()
1947 clr_kbd(vc, decckm); in csi_DEC_hl()
1951 vc_resize(deccolm ? 132 : 80, vc->vc_rows); in csi_DEC_hl()
1957 if (vc->vc_decscnm != on_off) { in csi_DEC_hl()
1958 vc->vc_decscnm = on_off; in csi_DEC_hl()
1959 invert_screen(vc, 0, vc->vc_screenbuf_size, in csi_DEC_hl()
1961 update_attr(vc); in csi_DEC_hl()
1965 vc->vc_decom = on_off; in csi_DEC_hl()
1966 gotoxay(vc, 0, 0); in csi_DEC_hl()
1969 vc->vc_decawm = on_off; in csi_DEC_hl()
1973 set_kbd(vc, decarm); in csi_DEC_hl()
1975 clr_kbd(vc, decarm); in csi_DEC_hl()
1978 vc->vc_report_mouse = on_off ? 1 : 0; in csi_DEC_hl()
1981 vc->vc_deccm = on_off; in csi_DEC_hl()
1984 vc->vc_report_mouse = on_off ? 2 : 0; in csi_DEC_hl()
1987 vc->vc_bracketed_paste = on_off; in csi_DEC_hl()
1991 enter_alt_screen(vc); in csi_DEC_hl()
1993 leave_alt_screen(vc); in csi_DEC_hl()
2005 static void csi_hl(struct vc_data *vc, bool on_off) in csi_hl() argument
2009 for (i = 0; i <= vc->vc_npar; i++) in csi_hl()
2010 switch (vc->vc_par[i]) { /* ANSI modes set/reset */ in csi_hl()
2012 vc->vc_disp_ctrl = on_off; in csi_hl()
2015 vc->vc_decim = on_off; in csi_hl()
2019 set_kbd(vc, lnm); in csi_hl()
2021 clr_kbd(vc, lnm); in csi_hl()
2047 static void csi_RSB(struct vc_data *vc) in csi_RSB() argument
2049 switch (vc->vc_par[0]) { in csi_RSB()
2051 if (vc->vc_can_do_color && vc->vc_par[1] < 16) { in csi_RSB()
2052 vc->vc_ulcolor = color_table[vc->vc_par[1]]; in csi_RSB()
2053 if (vc->state.underline) in csi_RSB()
2054 update_attr(vc); in csi_RSB()
2058 if (vc->vc_can_do_color && vc->vc_par[1] < 16) { in csi_RSB()
2059 vc->vc_halfcolor = color_table[vc->vc_par[1]]; in csi_RSB()
2060 if (vc->state.intensity == VCI_HALF_BRIGHT) in csi_RSB()
2061 update_attr(vc); in csi_RSB()
2065 vc->vc_def_color = vc->vc_attr; in csi_RSB()
2066 if (vc->vc_hi_font_mask == 0x100) in csi_RSB()
2067 vc->vc_def_color >>= 1; in csi_RSB()
2068 default_attr(vc); in csi_RSB()
2069 update_attr(vc); in csi_RSB()
2072 blankinterval = min(vc->vc_par[1], 60U) * 60; in csi_RSB()
2076 if (vc->vc_npar >= 1) in csi_RSB()
2077 vc->vc_bell_pitch = vc->vc_par[1]; in csi_RSB()
2079 vc->vc_bell_pitch = DEFAULT_BELL_PITCH; in csi_RSB()
2082 if (vc->vc_npar >= 1) in csi_RSB()
2083 vc->vc_bell_duration = (vc->vc_par[1] < 2000) ? in csi_RSB()
2084 msecs_to_jiffies(vc->vc_par[1]) : 0; in csi_RSB()
2086 vc->vc_bell_duration = DEFAULT_BELL_DURATION; in csi_RSB()
2089 if (vc->vc_par[1] >= 1 && vc_cons_allocated(vc->vc_par[1] - 1)) in csi_RSB()
2090 set_console(vc->vc_par[1] - 1); in csi_RSB()
2096 vesa_off_interval = min(vc->vc_par[1], 60U) * 60 * HZ; in csi_RSB()
2102 if (vc->vc_npar >= 1 && vc->vc_par[1] >= 50 && in csi_RSB()
2103 vc->vc_par[1] <= USHRT_MAX) in csi_RSB()
2104 vc->vc_cur_blink_ms = vc->vc_par[1]; in csi_RSB()
2106 vc->vc_cur_blink_ms = DEFAULT_CURSOR_BLINK_MS; in csi_RSB()
2112 static void csi_at(struct vc_data *vc, unsigned int nr) in csi_at() argument
2114 nr = clamp(nr, 1, vc->vc_cols - vc->state.x); in csi_at()
2115 insert_char(vc, nr); in csi_at()
2119 static void csi_L(struct vc_data *vc) in csi_L() argument
2121 unsigned int nr = clamp(vc->vc_par[0], 1, vc->vc_rows - vc->state.y); in csi_L()
2123 con_scroll(vc, vc->state.y, vc->vc_bottom, SM_DOWN, nr); in csi_L()
2124 vc->vc_need_wrap = 0; in csi_L()
2128 static void csi_P(struct vc_data *vc) in csi_P() argument
2130 unsigned int nr = clamp(vc->vc_par[0], 1, vc->vc_cols - vc->state.x); in csi_P()
2132 delete_char(vc, nr); in csi_P()
2136 static void csi_M(struct vc_data *vc) in csi_M() argument
2138 unsigned int nr = clamp(vc->vc_par[0], 1, vc->vc_rows - vc->state.y); in csi_M()
2140 con_scroll(vc, vc->state.y, vc->vc_bottom, SM_UP, nr); in csi_M()
2141 vc->vc_need_wrap = 0; in csi_M()
2145 static void save_cur(struct vc_data *vc) in save_cur() argument
2147 memcpy(&vc->saved_state, &vc->state, sizeof(vc->state)); in save_cur()
2151 static void restore_cur(struct vc_data *vc) in restore_cur() argument
2153 memcpy(&vc->state, &vc->saved_state, sizeof(vc->state)); in restore_cur()
2155 gotoxy(vc, vc->state.x, vc->state.y); in restore_cur()
2156 vc->vc_translate = set_translate(vc->state.Gx_charset[vc->state.charset], in restore_cur()
2157 vc); in restore_cur()
2158 update_attr(vc); in restore_cur()
2159 vc->vc_need_wrap = 0; in restore_cur()
2206 static void reset_terminal(struct vc_data *vc, int do_clear) in reset_terminal() argument
2210 vc->vc_top = 0; in reset_terminal()
2211 vc->vc_bottom = vc->vc_rows; in reset_terminal()
2212 vc->vc_state = ESnormal; in reset_terminal()
2213 vc->vc_priv = EPecma; in reset_terminal()
2214 vc->vc_translate = set_translate(LAT1_MAP, vc); in reset_terminal()
2215 vc->state.Gx_charset[0] = LAT1_MAP; in reset_terminal()
2216 vc->state.Gx_charset[1] = GRAF_MAP; in reset_terminal()
2217 vc->state.charset = 0; in reset_terminal()
2218 vc->vc_need_wrap = 0; in reset_terminal()
2219 vc->vc_report_mouse = 0; in reset_terminal()
2220 vc->vc_bracketed_paste = 0; in reset_terminal()
2221 vc->vc_utf = default_utf8; in reset_terminal()
2222 vc->vc_utf_count = 0; in reset_terminal()
2224 vc->vc_disp_ctrl = 0; in reset_terminal()
2225 vc->vc_toggle_meta = 0; in reset_terminal()
2227 vc->vc_decscnm = 0; in reset_terminal()
2228 vc->vc_decom = 0; in reset_terminal()
2229 vc->vc_decawm = 1; in reset_terminal()
2230 vc->vc_deccm = global_cursor_default; in reset_terminal()
2231 vc->vc_decim = 0; in reset_terminal()
2233 if (vc->vc_saved_screen != NULL) { in reset_terminal()
2234 kfree(vc->vc_saved_screen); in reset_terminal()
2235 vc->vc_saved_screen = NULL; in reset_terminal()
2236 vc->vc_saved_rows = 0; in reset_terminal()
2237 vc->vc_saved_cols = 0; in reset_terminal()
2240 vt_reset_keyboard(vc->vc_num); in reset_terminal()
2242 vc->vc_cursor_type = cur_default; in reset_terminal()
2243 vc->vc_complement_mask = vc->vc_s_complement_mask; in reset_terminal()
2245 default_attr(vc); in reset_terminal()
2246 update_attr(vc); in reset_terminal()
2248 bitmap_zero(vc->vc_tab_stop, VC_TABSTOPS_COUNT); in reset_terminal()
2250 set_bit(i, vc->vc_tab_stop); in reset_terminal()
2252 vc->vc_bell_pitch = DEFAULT_BELL_PITCH; in reset_terminal()
2253 vc->vc_bell_duration = DEFAULT_BELL_DURATION; in reset_terminal()
2254 vc->vc_cur_blink_ms = DEFAULT_CURSOR_BLINK_MS; in reset_terminal()
2256 gotoxy(vc, 0, 0); in reset_terminal()
2257 save_cur(vc); in reset_terminal()
2259 csi_J(vc, CSI_J_VISIBLE); in reset_terminal()
2262 static void vc_setGx(struct vc_data *vc, unsigned int which, u8 c) in vc_setGx() argument
2264 unsigned char *charset = &vc->state.Gx_charset[which]; in vc_setGx()
2281 if (vc->state.charset == which) in vc_setGx()
2282 vc->vc_translate = set_translate(*charset, vc); in vc_setGx()
2318 static bool handle_ascii(struct tty_struct *tty, struct vc_data *vc, u8 c) in handle_ascii() argument
2324 if (ansi_control_string(vc->vc_state)) in handle_ascii()
2325 vc->vc_state = ESnormal; in handle_ascii()
2326 else if (vc->vc_bell_duration) in handle_ascii()
2327 kd_mksound(vc->vc_bell_pitch, vc->vc_bell_duration); in handle_ascii()
2330 bs(vc); in handle_ascii()
2333 vc->vc_pos -= (vc->state.x << 1); in handle_ascii()
2335 vc->state.x = find_next_bit(vc->vc_tab_stop, in handle_ascii()
2336 min(vc->vc_cols - 1, VC_TABSTOPS_COUNT), in handle_ascii()
2337 vc->state.x + 1); in handle_ascii()
2338 if (vc->state.x >= VC_TABSTOPS_COUNT) in handle_ascii()
2339 vc->state.x = vc->vc_cols - 1; in handle_ascii()
2341 vc->vc_pos += (vc->state.x << 1); in handle_ascii()
2342 notify_write(vc, '\t'); in handle_ascii()
2347 lf(vc); in handle_ascii()
2348 if (!is_kbd(vc, lnm)) in handle_ascii()
2352 cr(vc); in handle_ascii()
2355 vc->state.charset = 1; in handle_ascii()
2356 vc->vc_translate = set_translate(vc->state.Gx_charset[1], vc); in handle_ascii()
2357 vc->vc_disp_ctrl = 1; in handle_ascii()
2360 vc->state.charset = 0; in handle_ascii()
2361 vc->vc_translate = set_translate(vc->state.Gx_charset[0], vc); in handle_ascii()
2362 vc->vc_disp_ctrl = 0; in handle_ascii()
2366 vc->vc_state = ESnormal; in handle_ascii()
2369 vc->vc_state = ESesc; in handle_ascii()
2372 del(vc); in handle_ascii()
2375 vc->vc_state = ESsquare; in handle_ascii()
2387 static void handle_esc(struct tty_struct *tty, struct vc_data *vc, u8 c) in handle_esc() argument
2389 vc->vc_state = ESnormal; in handle_esc()
2392 vc->vc_state = ESsquare; in handle_esc()
2395 vc->vc_state = ESnonstd; in handle_esc()
2398 vc->vc_state = ESapc; in handle_esc()
2401 vc->vc_state = ESpm; in handle_esc()
2404 vc->vc_state = ESpercent; in handle_esc()
2407 cr(vc); in handle_esc()
2408 lf(vc); in handle_esc()
2411 ri(vc); in handle_esc()
2414 lf(vc); in handle_esc()
2417 if (vc->state.x < VC_TABSTOPS_COUNT) in handle_esc()
2418 set_bit(vc->state.x, vc->vc_tab_stop); in handle_esc()
2421 vc->vc_state = ESdcs; in handle_esc()
2427 save_cur(vc); in handle_esc()
2430 restore_cur(vc); in handle_esc()
2433 vc->vc_state = ESsetG0; in handle_esc()
2436 vc->vc_state = ESsetG1; in handle_esc()
2439 vc->vc_state = EShash; in handle_esc()
2442 reset_terminal(vc, 1); in handle_esc()
2445 clr_kbd(vc, kbdapplic); in handle_esc()
2448 set_kbd(vc, kbdapplic); in handle_esc()
2457 static void csi_DEC(struct tty_struct *tty, struct vc_data *vc, u8 c) in csi_DEC() argument
2461 csi_DEC_hl(vc, true); in csi_DEC()
2464 csi_DEC_hl(vc, false); in csi_DEC()
2467 if (vc->vc_par[0]) in csi_DEC()
2468 vc->vc_cursor_type = CUR_MAKE(vc->vc_par[0], in csi_DEC()
2469 vc->vc_par[1], in csi_DEC()
2470 vc->vc_par[2]); in csi_DEC()
2472 vc->vc_cursor_type = cur_default; in csi_DEC()
2476 if (vc->vc_par[0]) in csi_DEC()
2477 vc->vc_complement_mask = vc->vc_par[0] << 8 | vc->vc_par[1]; in csi_DEC()
2479 vc->vc_complement_mask = vc->vc_s_complement_mask; in csi_DEC()
2482 if (vc->vc_par[0] == 5) in csi_DEC()
2484 else if (vc->vc_par[0] == 6) in csi_DEC()
2485 cursor_report(vc, tty); in csi_DEC()
2495 static void csi_ECMA(struct tty_struct *tty, struct vc_data *vc, u8 c) in csi_ECMA() argument
2500 if (vc->vc_par[0]) in csi_ECMA()
2501 vc->vc_par[0]--; in csi_ECMA()
2502 gotoxy(vc, vc->vc_par[0], vc->state.y); in csi_ECMA()
2505 if (!vc->vc_par[0]) in csi_ECMA()
2506 vc->vc_par[0]++; in csi_ECMA()
2507 gotoxy(vc, vc->state.x, vc->state.y - vc->vc_par[0]); in csi_ECMA()
2511 if (!vc->vc_par[0]) in csi_ECMA()
2512 vc->vc_par[0]++; in csi_ECMA()
2513 gotoxy(vc, vc->state.x, vc->state.y + vc->vc_par[0]); in csi_ECMA()
2517 if (!vc->vc_par[0]) in csi_ECMA()
2518 vc->vc_par[0]++; in csi_ECMA()
2519 gotoxy(vc, vc->state.x + vc->vc_par[0], vc->state.y); in csi_ECMA()
2522 if (!vc->vc_par[0]) in csi_ECMA()
2523 vc->vc_par[0]++; in csi_ECMA()
2524 gotoxy(vc, vc->state.x - vc->vc_par[0], vc->state.y); in csi_ECMA()
2527 if (!vc->vc_par[0]) in csi_ECMA()
2528 vc->vc_par[0]++; in csi_ECMA()
2529 gotoxy(vc, 0, vc->state.y + vc->vc_par[0]); in csi_ECMA()
2532 if (!vc->vc_par[0]) in csi_ECMA()
2533 vc->vc_par[0]++; in csi_ECMA()
2534 gotoxy(vc, 0, vc->state.y - vc->vc_par[0]); in csi_ECMA()
2537 if (vc->vc_par[0]) in csi_ECMA()
2538 vc->vc_par[0]--; in csi_ECMA()
2539 gotoxay(vc, vc->state.x ,vc->vc_par[0]); in csi_ECMA()
2543 if (vc->vc_par[0]) in csi_ECMA()
2544 vc->vc_par[0]--; in csi_ECMA()
2545 if (vc->vc_par[1]) in csi_ECMA()
2546 vc->vc_par[1]--; in csi_ECMA()
2547 gotoxay(vc, vc->vc_par[1], vc->vc_par[0]); in csi_ECMA()
2550 csi_J(vc, vc->vc_par[0]); in csi_ECMA()
2553 csi_K(vc); in csi_ECMA()
2556 csi_L(vc); in csi_ECMA()
2559 csi_M(vc); in csi_ECMA()
2562 csi_P(vc); in csi_ECMA()
2565 if (!vc->vc_par[0]) in csi_ECMA()
2569 if (!vc->vc_par[0] && vc->state.x < VC_TABSTOPS_COUNT) in csi_ECMA()
2570 set_bit(vc->state.x, vc->vc_tab_stop); in csi_ECMA()
2571 else if (vc->vc_par[0] == 3) in csi_ECMA()
2572 bitmap_zero(vc->vc_tab_stop, VC_TABSTOPS_COUNT); in csi_ECMA()
2575 csi_hl(vc, true); in csi_ECMA()
2578 csi_hl(vc, false); in csi_ECMA()
2581 csi_m(vc); in csi_ECMA()
2584 if (vc->vc_par[0] == 5) in csi_ECMA()
2586 else if (vc->vc_par[0] == 6) in csi_ECMA()
2587 cursor_report(vc, tty); in csi_ECMA()
2591 if (vc->vc_par[0] < 4) in csi_ECMA()
2592 vt_set_led_state(vc->vc_num, in csi_ECMA()
2593 (vc->vc_par[0] < 3) ? vc->vc_par[0] : 4); in csi_ECMA()
2596 if (!vc->vc_par[0]) in csi_ECMA()
2597 vc->vc_par[0]++; in csi_ECMA()
2598 if (!vc->vc_par[1]) in csi_ECMA()
2599 vc->vc_par[1] = vc->vc_rows; in csi_ECMA()
2601 if (vc->vc_par[0] < vc->vc_par[1] && in csi_ECMA()
2602 vc->vc_par[1] <= vc->vc_rows) { in csi_ECMA()
2603 vc->vc_top = vc->vc_par[0] - 1; in csi_ECMA()
2604 vc->vc_bottom = vc->vc_par[1]; in csi_ECMA()
2605 gotoxay(vc, 0, 0); in csi_ECMA()
2609 save_cur(vc); in csi_ECMA()
2612 restore_cur(vc); in csi_ECMA()
2615 csi_X(vc); in csi_ECMA()
2618 csi_at(vc, vc->vc_par[0]); in csi_ECMA()
2621 csi_RSB(vc); in csi_ECMA()
2627 static void vc_reset_params(struct vc_data *vc) in vc_reset_params() argument
2629 memset(vc->vc_par, 0, sizeof(vc->vc_par)); in vc_reset_params()
2630 vc->vc_npar = 0; in vc_reset_params()
2634 static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, u8 c) in do_con_trol() argument
2640 if (ansi_control_string(vc->vc_state) && c >= ASCII_IGNORE_FIRST && in do_con_trol()
2644 if (handle_ascii(tty, vc, c)) in do_con_trol()
2647 switch(vc->vc_state) { in do_con_trol()
2649 handle_esc(tty, vc, c); in do_con_trol()
2654 vc_reset_params(vc); in do_con_trol()
2655 vc->vc_state = ESpalette; in do_con_trol()
2658 reset_palette(vc); in do_con_trol()
2661 vc->vc_state = ESosc; in do_con_trol()
2664 vc->vc_state = ESnormal; in do_con_trol()
2668 vc->vc_par[vc->vc_npar++] = hex_to_bin(c); in do_con_trol()
2669 if (vc->vc_npar == 7) { in do_con_trol()
2670 int i = vc->vc_par[0] * 3, j = 1; in do_con_trol()
2671 vc->vc_palette[i] = 16 * vc->vc_par[j++]; in do_con_trol()
2672 vc->vc_palette[i++] += vc->vc_par[j++]; in do_con_trol()
2673 vc->vc_palette[i] = 16 * vc->vc_par[j++]; in do_con_trol()
2674 vc->vc_palette[i++] += vc->vc_par[j++]; in do_con_trol()
2675 vc->vc_palette[i] = 16 * vc->vc_par[j++]; in do_con_trol()
2676 vc->vc_palette[i] += vc->vc_par[j]; in do_con_trol()
2677 set_palette(vc); in do_con_trol()
2678 vc->vc_state = ESnormal; in do_con_trol()
2681 vc->vc_state = ESnormal; in do_con_trol()
2684 vc_reset_params(vc); in do_con_trol()
2686 vc->vc_state = ESgetpars; in do_con_trol()
2689 vc->vc_state = ESfunckey; in do_con_trol()
2692 vc->vc_priv = EPdec; in do_con_trol()
2695 vc->vc_priv = EPgt; in do_con_trol()
2698 vc->vc_priv = EPeq; in do_con_trol()
2701 vc->vc_priv = EPlt; in do_con_trol()
2704 vc->vc_priv = EPecma; in do_con_trol()
2709 if (vc->vc_npar < NPAR - 1) { in do_con_trol()
2710 vc->vc_npar++; in do_con_trol()
2715 vc->vc_par[vc->vc_npar] *= 10; in do_con_trol()
2716 vc->vc_par[vc->vc_npar] += c - '0'; in do_con_trol()
2720 vc->vc_state = EScsiignore; in do_con_trol()
2726 vc->vc_state = ESnormal; in do_con_trol()
2728 switch (vc->vc_priv) { in do_con_trol()
2730 csi_DEC(tty, vc, c); in do_con_trol()
2733 csi_ECMA(tty, vc, c); in do_con_trol()
2741 vc->vc_state = ESnormal; in do_con_trol()
2744 vc->vc_state = ESnormal; in do_con_trol()
2747 vc->vc_utf = 0; in do_con_trol()
2751 vc->vc_utf = 1; in do_con_trol()
2756 vc->vc_state = ESnormal; in do_con_trol()
2759 vc->vc_state = ESnormal; in do_con_trol()
2762 vc->vc_video_erase_char = in do_con_trol()
2763 (vc->vc_video_erase_char & 0xff00) | 'E'; in do_con_trol()
2764 csi_J(vc, CSI_J_VISIBLE); in do_con_trol()
2765 vc->vc_video_erase_char = in do_con_trol()
2766 (vc->vc_video_erase_char & 0xff00) | ' '; in do_con_trol()
2767 do_update_region(vc, vc->vc_origin, vc->vc_screenbuf_size / 2); in do_con_trol()
2771 vc_setGx(vc, 0, c); in do_con_trol()
2772 vc->vc_state = ESnormal; in do_con_trol()
2775 vc_setGx(vc, 1, c); in do_con_trol()
2776 vc->vc_state = ESnormal; in do_con_trol()
2787 vc->vc_state = ESnormal; in do_con_trol()
2796 static void con_flush(struct vc_data *vc, struct vc_draw_region *draw) in con_flush() argument
2801 vc->vc_sw->con_putcs(vc, (u16 *)draw->from, in con_flush()
2802 (u16 *)draw->to - (u16 *)draw->from, vc->state.y, in con_flush()
2807 static inline int vc_translate_ascii(const struct vc_data *vc, int c) in vc_translate_ascii() argument
2810 if (vc->vc_toggle_meta) in vc_translate_ascii()
2813 return vc->vc_translate[c]; in vc_translate_ascii()
2851 static int vc_translate_unicode(struct vc_data *vc, int c, bool *rescan) in vc_translate_unicode() argument
2858 if (!vc->vc_utf_count) in vc_translate_unicode()
2861 vc->vc_utf_char = (vc->vc_utf_char << 6) | (c & 0x3f); in vc_translate_unicode()
2862 vc->vc_npar++; in vc_translate_unicode()
2863 if (--vc->vc_utf_count) in vc_translate_unicode()
2867 c = vc->vc_utf_char; in vc_translate_unicode()
2869 if (c <= utf8_length_changes[vc->vc_npar - 1] || in vc_translate_unicode()
2870 c > utf8_length_changes[vc->vc_npar]) in vc_translate_unicode()
2877 if (vc->vc_utf_count) { in vc_translate_unicode()
2880 vc->vc_utf_count = 0; in vc_translate_unicode()
2889 vc->vc_npar = 0; in vc_translate_unicode()
2891 vc->vc_utf_count = 1; in vc_translate_unicode()
2892 vc->vc_utf_char = (c & 0x1f); in vc_translate_unicode()
2894 vc->vc_utf_count = 2; in vc_translate_unicode()
2895 vc->vc_utf_char = (c & 0x0f); in vc_translate_unicode()
2897 vc->vc_utf_count = 3; in vc_translate_unicode()
2898 vc->vc_utf_char = (c & 0x07); in vc_translate_unicode()
2910 static int vc_translate(struct vc_data *vc, int *c, bool *rescan) in vc_translate() argument
2913 if (vc->vc_state != ESnormal) in vc_translate()
2916 if (vc->vc_utf && !vc->vc_disp_ctrl) in vc_translate()
2917 return *c = vc_translate_unicode(vc, *c, rescan); in vc_translate()
2920 return vc_translate_ascii(vc, *c); in vc_translate()
2923 static inline unsigned char vc_invert_attr(const struct vc_data *vc) in vc_invert_attr() argument
2925 if (!vc->vc_can_do_color) in vc_invert_attr()
2926 return vc->vc_attr ^ 0x08; in vc_invert_attr()
2928 if (vc->vc_hi_font_mask == 0x100) in vc_invert_attr()
2929 return (vc->vc_attr & 0x11) | in vc_invert_attr()
2930 ((vc->vc_attr & 0xe0) >> 4) | in vc_invert_attr()
2931 ((vc->vc_attr & 0x0e) << 4); in vc_invert_attr()
2933 return (vc->vc_attr & 0x88) | in vc_invert_attr()
2934 ((vc->vc_attr & 0x70) >> 4) | in vc_invert_attr()
2935 ((vc->vc_attr & 0x07) << 4); in vc_invert_attr()
2938 static bool vc_is_control(struct vc_data *vc, int tc, int c) in vc_is_control() argument
2954 if (vc->vc_state != ESnormal) in vc_is_control()
2970 if (vc->vc_disp_ctrl) in vc_is_control()
2973 return vc->vc_utf || (CTRL_ACTION & BIT(c)); in vc_is_control()
2976 if (c == ASCII_DEL && !vc->vc_disp_ctrl) in vc_is_control()
2985 static void vc_con_rewind(struct vc_data *vc) in vc_con_rewind() argument
2987 if (vc->state.x && !vc->vc_need_wrap) { in vc_con_rewind()
2988 vc->vc_pos -= 2; in vc_con_rewind()
2989 vc->state.x--; in vc_con_rewind()
2991 vc->vc_need_wrap = 0; in vc_con_rewind()
2998 static int vc_process_ucs(struct vc_data *vc, int *c, int *tc) in vc_process_ucs() argument
3008 vc_uniscr_check(vc); in vc_process_ucs()
3017 if (ucs_is_double_width(vc_uniscr_getc(vc, -2))) { in vc_process_ucs()
3025 vc_con_rewind(vc); in vc_process_ucs()
3031 prev_c = vc_uniscr_getc(vc, -1); in vc_process_ucs()
3047 vc_con_rewind(vc); in vc_process_ucs()
3056 static int vc_get_glyph(struct vc_data *vc, int tc) in vc_get_glyph() argument
3058 int glyph = conv_uni_to_pc(vc, tc); in vc_get_glyph()
3059 u16 charmask = vc->vc_hi_font_mask ? 0x1ff : 0xff; in vc_get_glyph()
3068 if ((!vc->vc_utf || vc->vc_disp_ctrl || tc < 128) && !(tc & ~charmask)) { in vc_get_glyph()
3084 vc_uniscr_check(vc); in vc_get_glyph()
3089 return vc_get_glyph(vc, tc); in vc_get_glyph()
3092 return conv_uni_to_pc(vc, UCS_REPLACEMENT); in vc_get_glyph()
3095 static int vc_con_write_normal(struct vc_data *vc, int tc, int c, in vc_con_write_normal() argument
3099 unsigned char vc_attr = vc->vc_attr; in vc_con_write_normal()
3100 u16 himask = vc->vc_hi_font_mask; in vc_con_write_normal()
3104 if (vc->vc_utf && !vc->vc_disp_ctrl) { in vc_con_write_normal()
3105 width = vc_process_ucs(vc, &c, &tc); in vc_con_write_normal()
3111 tc = vc_get_glyph(vc, tc); in vc_con_write_normal()
3116 tc = conv_uni_to_pc(vc, '?'); in vc_con_write_normal()
3120 vc_attr = vc_invert_attr(vc); in vc_con_write_normal()
3121 con_flush(vc, draw); in vc_con_write_normal()
3126 if (vc->vc_need_wrap || vc->vc_decim) in vc_con_write_normal()
3127 con_flush(vc, draw); in vc_con_write_normal()
3128 if (vc->vc_need_wrap) { in vc_con_write_normal()
3129 cr(vc); in vc_con_write_normal()
3130 lf(vc); in vc_con_write_normal()
3132 if (vc->vc_decim) in vc_con_write_normal()
3133 insert_char(vc, 1); in vc_con_write_normal()
3134 vc_uniscr_putc(vc, next_c); in vc_con_write_normal()
3141 scr_writew(tc, (u16 *)vc->vc_pos); in vc_con_write_normal()
3143 if (con_should_update(vc) && draw->x < 0) { in vc_con_write_normal()
3144 draw->x = vc->state.x; in vc_con_write_normal()
3145 draw->from = vc->vc_pos; in vc_con_write_normal()
3147 if (vc->state.x == vc->vc_cols - 1) { in vc_con_write_normal()
3148 vc->vc_need_wrap = vc->vc_decawm; in vc_con_write_normal()
3149 draw->to = vc->vc_pos + 2; in vc_con_write_normal()
3151 vc->state.x++; in vc_con_write_normal()
3152 draw->to = (vc->vc_pos += 2); in vc_con_write_normal()
3159 tc = conv_uni_to_pc(vc, ' '); in vc_con_write_normal()
3170 notify_write(vc, c); in vc_con_write_normal()
3173 con_flush(vc, draw); in vc_con_write_normal()
3186 struct vc_data *vc = tty->driver_data; in do_con_write() local
3194 currcons = vc->vc_num; in do_con_write()
3203 if (con_is_fg(vc)) in do_con_write()
3204 hide_cursor(vc); in do_con_write()
3206 param.vc = vc; in do_con_write()
3217 tc = vc_translate(vc, &c, &rescan); in do_con_write()
3226 if (vc_is_control(vc, tc, c)) { in do_con_write()
3227 con_flush(vc, &draw); in do_con_write()
3228 do_con_trol(tty, vc, orig); in do_con_write()
3232 if (vc_con_write_normal(vc, tc, c, &draw) < 0) in do_con_write()
3238 con_flush(vc, &draw); in do_con_write()
3240 notify_update(vc); in do_con_write()
3274 struct vc_data *vc = vc_cons[fg_console].d; in console_callback() local
3276 if (vc->vc_mode == KD_TEXT && vc->vc_sw->con_scrolldelta) in console_callback()
3277 vc->vc_sw->con_scrolldelta(vc, scrollback_delta); in console_callback()
3289 struct vc_data *vc = vc_cons[fg_console].d; in set_console() local
3292 (vc->vt_mode.mode == VT_AUTO && vc->vc_mode == KD_GRAPHICS)) { in set_console()
3354 struct vc_data *vc = vc_cons[fg_console].d; in vt_console_print() local
3369 vc = vc_cons[kmsg_console - 1].d; in vt_console_print()
3377 if (vc->vc_mode != KD_TEXT) in vt_console_print()
3381 if (con_is_fg(vc)) in vt_console_print()
3382 hide_cursor(vc); in vt_console_print()
3384 start = (ushort *)vc->vc_pos; in vt_console_print()
3385 start_x = vc->state.x; in vt_console_print()
3390 c == ASCII_BACKSPACE || vc->vc_need_wrap) { in vt_console_print()
3391 if (cnt && con_is_visible(vc)) in vt_console_print()
3392 vc->vc_sw->con_putcs(vc, start, cnt, vc->state.y, start_x); in vt_console_print()
3395 bs(vc); in vt_console_print()
3396 start = (ushort *)vc->vc_pos; in vt_console_print()
3397 start_x = vc->state.x; in vt_console_print()
3401 lf(vc); in vt_console_print()
3402 cr(vc); in vt_console_print()
3403 start = (ushort *)vc->vc_pos; in vt_console_print()
3404 start_x = vc->state.x; in vt_console_print()
3408 vc_uniscr_putc(vc, c); in vt_console_print()
3409 scr_writew((vc->vc_attr << 8) + c, (unsigned short *)vc->vc_pos); in vt_console_print()
3410 notify_write(vc, c); in vt_console_print()
3412 if (vc->state.x == vc->vc_cols - 1) { in vt_console_print()
3413 vc->vc_need_wrap = 1; in vt_console_print()
3415 vc->vc_pos += 2; in vt_console_print()
3416 vc->state.x++; in vt_console_print()
3419 if (cnt && con_is_visible(vc)) in vt_console_print()
3420 vc->vc_sw->con_putcs(vc, start, cnt, vc->state.y, start_x); in vt_console_print()
3421 set_cursor(vc); in vt_console_print()
3422 notify_update(vc); in vt_console_print()
3594 struct vc_data *vc = tty->driver_data; in con_unthrottle() local
3596 wake_up_interruptible(&vc->paste_wait); in con_unthrottle()
3629 struct vc_data *vc = tty->driver_data; in con_flush_chars() local
3635 set_cursor(vc); in con_flush_chars()
3644 struct vc_data *vc; in con_install() local
3652 vc = vc_cons[currcons].d; in con_install()
3655 if (vc->port.tty) in con_install()
3658 ret = tty_port_install(&vc->port, driver, tty); in con_install()
3662 tty->driver_data = vc; in con_install()
3663 vc->port.tty = tty; in con_install()
3664 tty_port_get(&vc->port); in con_install()
3670 if (vc->vc_utf) in con_install()
3692 struct vc_data *vc = tty->driver_data; in con_shutdown() local
3693 BUG_ON(vc == NULL); in con_shutdown()
3696 vc->port.tty = NULL; in con_shutdown()
3701 struct vc_data *vc = tty->driver_data; in con_cleanup() local
3703 tty_port_put(&vc->port); in con_cleanup()
3722 static void vc_init(struct vc_data *vc, int do_clear) in vc_init() argument
3726 set_origin(vc); in vc_init()
3727 vc->vc_pos = vc->vc_origin; in vc_init()
3728 reset_vc(vc); in vc_init()
3730 vc->vc_palette[k++] = default_red[j] ; in vc_init()
3731 vc->vc_palette[k++] = default_grn[j] ; in vc_init()
3732 vc->vc_palette[k++] = default_blu[j] ; in vc_init()
3734 vc->vc_def_color = default_color; in vc_init()
3735 vc->vc_ulcolor = default_underline_color; in vc_init()
3736 vc->vc_itcolor = default_italic_color; in vc_init()
3737 vc->vc_halfcolor = 0x08; /* grey */ in vc_init()
3738 init_waitqueue_head(&vc->paste_wait); in vc_init()
3739 reset_terminal(vc, do_clear); in vc_init()
3751 struct vc_data *vc; in con_init() local
3787 vc_cons[currcons].d = vc = kzalloc(sizeof(struct vc_data), GFP_NOWAIT); in con_init()
3789 tty_port_init(&vc->port); in con_init()
3790 visual_init(vc, currcons, true); in con_init()
3792 vc->vc_screenbuf = kzalloc(vc->vc_screenbuf_size, GFP_NOWAIT); in con_init()
3793 vc_init(vc, currcons || !vc->vc_sw->con_save_screen); in con_init()
3796 master_display_fg = vc = vc_cons[currcons].d; in con_init()
3797 set_origin(vc); in con_init()
3798 save_screen(vc); in con_init()
3799 gotoxy(vc, vc->state.x, vc->state.y); in con_init()
3800 csi_J(vc, CSI_J_CURSOR_TO_END); in con_init()
3801 update_screen(vc); in con_init()
3803 vc->vc_can_do_color ? "colour" : "mono", in con_init()
3804 display_desc, vc->vc_cols, vc->vc_rows); in con_init()
3940 struct vc_data *vc = vc_cons[i].d; in do_bind_con_driver() local
3947 if (!vc || !vc->vc_sw) in do_bind_con_driver()
3952 if (con_is_visible(vc)) { in do_bind_con_driver()
3954 save_screen(vc); in do_bind_con_driver()
3957 old_was_color = vc->vc_can_do_color; in do_bind_con_driver()
3958 vc->vc_sw->con_deinit(vc); in do_bind_con_driver()
3959 vc->vc_origin = (unsigned long)vc->vc_screenbuf; in do_bind_con_driver()
3960 visual_init(vc, i, false); in do_bind_con_driver()
3961 set_origin(vc); in do_bind_con_driver()
3962 update_attr(vc); in do_bind_con_driver()
3968 if (old_was_color != vc->vc_can_do_color) in do_bind_con_driver()
3969 clear_buffer_attributes(vc); in do_bind_con_driver()
3976 struct vc_data *vc = vc_cons[j].d; in do_bind_con_driver() local
3979 vc->vc_can_do_color ? "colour" : "mono", in do_bind_con_driver()
3980 desc, vc->vc_cols, vc->vc_rows); in do_bind_con_driver()
3983 vc = vc_cons[k].d; in do_bind_con_driver()
3984 update_screen(vc); in do_bind_con_driver()
4272 bool con_is_visible(const struct vc_data *vc) in con_is_visible() argument
4276 return *vc->vc_display_fg == vc; in con_is_visible()
4288 void con_debug_enter(struct vc_data *vc) in con_debug_enter() argument
4293 saved_vc_mode = vc->vc_mode; in con_debug_enter()
4295 vc->vc_mode = KD_TEXT; in con_debug_enter()
4297 if (vc->vc_sw->con_debug_enter) in con_debug_enter()
4298 vc->vc_sw->con_debug_enter(vc); in con_debug_enter()
4301 if (vc->vc_rows < 999) { in con_debug_enter()
4310 snprintf(lns, 4, "%i", vc->vc_rows); in con_debug_enter()
4314 if (vc->vc_cols < 999) { in con_debug_enter()
4323 snprintf(cols, 4, "%i", vc->vc_cols); in con_debug_enter()
4339 struct vc_data *vc; in con_debug_leave() local
4347 vc = vc_cons[fg_console].d; in con_debug_leave()
4348 if (vc->vc_sw->con_debug_leave) in con_debug_leave()
4349 vc->vc_sw->con_debug_leave(vc); in con_debug_leave()
4591 struct vc_data *vc = vc_cons[fg_console].d; in do_blank_screen() local
4601 vc->vc_sw->con_blank(vc, vesa_blank_mode + 1, 0); in do_blank_screen()
4608 hide_cursor(vc); in do_blank_screen()
4609 save_screen(vc); in do_blank_screen()
4610 vc->vc_sw->con_blank(vc, VESA_VSYNC_SUSPEND, 1); in do_blank_screen()
4613 set_origin(vc); in do_blank_screen()
4620 if (vc->vc_mode != KD_TEXT) { in do_blank_screen()
4625 hide_cursor(vc); in do_blank_screen()
4629 save_screen(vc); in do_blank_screen()
4631 i = vc->vc_sw->con_blank(vc, vesa_off_interval ? VESA_VSYNC_SUSPEND : in do_blank_screen()
4635 set_origin(vc); in do_blank_screen()
4644 vt_event_post(VT_EVENT_BLANK, vc->vc_num, vc->vc_num); in do_blank_screen()
4653 struct vc_data *vc; in do_unblank_screen() local
4673 vc = vc_cons[fg_console].d; in do_unblank_screen()
4674 if (vc->vc_mode != KD_TEXT) in do_unblank_screen()
4683 if (vc->vc_sw->con_blank(vc, VESA_NO_BLANKING, leaving_gfx)) in do_unblank_screen()
4685 update_screen(vc); in do_unblank_screen()
4688 set_palette(vc); in do_unblank_screen()
4689 set_cursor(vc); in do_unblank_screen()
4690 vt_event_post(VT_EVENT_UNBLANK, vc->vc_num, vc->vc_num); in do_unblank_screen()
4691 notify_update(vc); in do_unblank_screen()
4749 static void set_palette(struct vc_data *vc) in set_palette() argument
4753 if (vc->vc_mode != KD_GRAPHICS && vc->vc_sw->con_set_palette) in set_palette()
4754 vc->vc_sw->con_set_palette(vc, color_table); in set_palette()
4808 void reset_palette(struct vc_data *vc) in reset_palette() argument
4812 vc->vc_palette[k++] = default_red[j]; in reset_palette()
4813 vc->vc_palette[k++] = default_grn[j]; in reset_palette()
4814 vc->vc_palette[k++] = default_blu[j]; in reset_palette()
4816 set_palette(vc); in reset_palette()
4837 static int con_font_get(struct vc_data *vc, struct console_font_op *op) in con_font_get() argument
4855 if (vc->vc_mode != KD_TEXT) in con_font_get()
4857 if (!vc->vc_sw->con_font_get) in con_font_get()
4860 int ret = vc->vc_sw->con_font_get(vc, &font, vpitch); in con_font_get()
4882 static int con_font_set(struct vc_data *vc, const struct console_font_op *op) in con_font_set() argument
4911 if (vc->vc_mode != KD_TEXT) in con_font_set()
4913 if (!vc->vc_sw->con_font_set) in con_font_set()
4916 if (vc_is_sel(vc)) in con_font_set()
4919 return vc->vc_sw->con_font_set(vc, &font, vpitch, op->flags); in con_font_set()
4922 static int con_font_default(struct vc_data *vc, struct console_font_op *op) in con_font_default() argument
4936 if (vc->vc_mode != KD_TEXT) in con_font_default()
4938 if (!vc->vc_sw->con_font_default) in con_font_default()
4941 if (vc_is_sel(vc)) in con_font_default()
4943 int ret = vc->vc_sw->con_font_default(vc, &font, s); in con_font_default()
4954 int con_font_op(struct vc_data *vc, struct console_font_op *op) in con_font_op() argument
4959 return con_font_set(vc, op); in con_font_op()
4962 return con_font_get(vc, op); in con_font_op()
4964 return con_font_default(vc, op); in con_font_op()
4977 u16 screen_glyph(const struct vc_data *vc, int offset) in screen_glyph() argument
4979 u16 w = scr_readw(screenpos(vc, offset, true)); in screen_glyph()
4982 if (w & vc->vc_hi_font_mask) in screen_glyph()
4988 u32 screen_glyph_unicode(const struct vc_data *vc, int n) in screen_glyph_unicode() argument
4990 u32 **uni_lines = vc->vc_uni_lines; in screen_glyph_unicode()
4993 return uni_lines[n / vc->vc_cols][n % vc->vc_cols]; in screen_glyph_unicode()
4995 return inverse_translate(vc, screen_glyph(vc, n * 2), true); in screen_glyph_unicode()
5000 unsigned short *screen_pos(const struct vc_data *vc, int w_offset, bool viewed) in screen_pos() argument
5002 return screenpos(vc, 2 * w_offset, viewed); in screen_pos()
5006 void getconsxy(const struct vc_data *vc, unsigned char xy[static 2]) in getconsxy() argument
5009 xy[0] = min(vc->state.x, 0xFFu); in getconsxy()
5010 xy[1] = min(vc->state.y, 0xFFu); in getconsxy()
5013 void putconsxy(struct vc_data *vc, unsigned char xy[static const 2]) in putconsxy() argument
5015 hide_cursor(vc); in putconsxy()
5016 gotoxy(vc, xy[0], xy[1]); in putconsxy()
5017 set_cursor(vc); in putconsxy()
5020 u16 vcs_scr_readw(const struct vc_data *vc, const u16 *org) in vcs_scr_readw() argument
5022 if ((unsigned long)org == vc->vc_pos && softcursor_original != -1) in vcs_scr_readw()
5027 void vcs_scr_writew(struct vc_data *vc, u16 val, u16 *org) in vcs_scr_writew() argument
5030 if ((unsigned long)org == vc->vc_pos) { in vcs_scr_writew()
5032 add_softcursor(vc); in vcs_scr_writew()
5036 void vcs_scr_updated(struct vc_data *vc) in vcs_scr_updated() argument
5038 notify_update(vc); in vcs_scr_updated()