Lines Matching +full:display +full:- +full:rows

2  *  linux/drivers/video/vgacon.c -- Low level VGA based console driver
16 * Improved loadable font/UTF-8 support by H. Peter Anvin
17 * Feb-Sep 1995 <peter.anvin@linux.org>
20 * 17-Jun-95 <sgt20@cam.ac.uk>
22 * if 512 char mode is already enabled don't re-enable it,
24 * 5-May-96 <mitja.horvat@guest.arnes.si>
100 * Disabling scrollback is required for the Braillex ib80-piezo in no_scroll()
102 * Use the "no-scroll" bootflag. in no_scroll()
108 __setup("no-scroll", no_scroll);
114 * possibility that some pre-dinosaur hardware won't like the back to back
124 * handlers, thus the write has to be IRQ-atomic. in write_vga()
136 write_vga(12, (c->vc_visible_origin - vga_vram_base) / 2); in vga_set_mem_top()
141 unsigned long scr_end = c->vc_scr_end - vga_vram_base; in vgacon_scrolldelta()
142 unsigned long vorigin = c->vc_visible_origin - vga_vram_base; in vgacon_scrolldelta()
143 unsigned long origin = c->vc_origin - vga_vram_base; in vgacon_scrolldelta()
144 int margin = c->vc_size_row * 4; in vgacon_scrolldelta()
149 c->vc_visible_origin = c->vc_origin; in vgacon_scrolldelta()
156 wrap = vga_rolled_over + c->vc_size_row; in vgacon_scrolldelta()
162 from_off = (vorigin - from + wrap) % wrap + lines * c->vc_size_row; in vgacon_scrolldelta()
163 avail = (origin - from + wrap) % wrap; in vgacon_scrolldelta()
170 if (from_off > avail - margin) in vgacon_scrolldelta()
173 c->vc_visible_origin = vga_vram_base + (from + from_off) % wrap; in vgacon_scrolldelta()
180 if (c->vc_origin != c->vc_visible_origin) in vgacon_restore_screen()
191 vga_si->orig_video_isVGA == VIDEO_TYPE_VLFB || in vgacon_startup()
192 vga_si->orig_video_isVGA == VIDEO_TYPE_EFI) { in vgacon_startup()
196 return conswitchp->con_startup(); in vgacon_startup()
203 if ((vga_si->orig_video_lines == 0) || in vgacon_startup()
204 (vga_si->orig_video_cols == 0)) in vgacon_startup()
208 if ((vga_si->orig_video_mode == 0x0D) || /* 320x200/4 */ in vgacon_startup()
209 (vga_si->orig_video_mode == 0x0E) || /* 640x200/4 */ in vgacon_startup()
210 (vga_si->orig_video_mode == 0x10) || /* 640x350/4 */ in vgacon_startup()
211 (vga_si->orig_video_mode == 0x12) || /* 640x480/4 */ in vgacon_startup()
212 (vga_si->orig_video_mode == 0x6A)) /* 800x600/4 (VESA) */ in vgacon_startup()
215 vga_video_num_lines = vga_si->orig_video_lines; in vgacon_startup()
216 vga_video_num_columns = vga_si->orig_video_cols; in vgacon_startup()
219 if (vga_si->orig_video_mode == 7) { in vgacon_startup()
220 /* Monochrome display */ in vgacon_startup()
224 if ((vga_si->orig_video_ega_bx & 0xff) != 0x10) { in vgacon_startup()
261 if ((vga_si->orig_video_ega_bx & 0xff) != 0x10) { in vgacon_startup()
266 if (!vga_si->orig_video_isVGA) { in vgacon_startup()
357 vga_default_font_height = vga_si->orig_video_points; in vgacon_startup()
358 vga_video_font_height = vga_si->orig_video_points; in vgacon_startup()
359 /* This may be suboptimal but is a safe bet - go with it */ in vgacon_startup()
364 vgacon_xres = vga_si->orig_video_cols * VGA_FONTWIDTH; in vgacon_startup()
383 c->vc_can_do_color = vga_can_do_color; in vgacon_init()
384 c->vc_scan_lines = vga_scan_lines; in vgacon_init()
385 c->vc_font.height = c->vc_cell_height = vga_video_font_height; in vgacon_init()
389 c->vc_cols = vga_video_num_columns; in vgacon_init()
390 c->vc_rows = vga_video_num_lines; in vgacon_init()
394 c->vc_complement_mask = 0x7700; in vgacon_init()
396 c->vc_hi_font_mask = 0x0800; in vgacon_init()
397 p = *c->uni_pagedict_loc; in vgacon_init()
398 if (c->uni_pagedict_loc != &vgacon_uni_pagedir) { in vgacon_init()
400 c->uni_pagedict_loc = &vgacon_uni_pagedir; in vgacon_init()
407 if (global_cursor_default == -1) in vgacon_init()
409 !(vga_si->flags & VIDEO_FLAGS_NOCURSOR); in vgacon_init()
416 c->vc_visible_origin = vga_vram_base; in vgacon_deinit()
420 if (!--vgacon_refcount) in vgacon_deinit()
422 c->uni_pagedict_loc = &c->uni_pagedict; in vgacon_deinit()
435 attr = (attr & 0xF0) | c->vc_itcolor; in vgacon_build_attr()
437 attr = (attr & 0xf0) | c->vc_ulcolor; in vgacon_build_attr()
439 attr = (attr & 0xf0) | c->vc_halfcolor; in vgacon_build_attr()
464 while (count--) { in vgacon_invert_region()
510 if (c->vc_mode != KD_TEXT) in vgacon_cursor()
515 c_height = c->vc_cell_height; in vgacon_cursor()
517 write_vga(14, (c->vc_pos - vga_vram_base) / 2); in vgacon_cursor()
527 switch (CUR_SIZE(c->vc_cursor_type)) { in vgacon_cursor()
529 vgacon_set_cursor_size(c_height - (c_height < 10 ? 2 : 3), in vgacon_cursor()
530 c_height - (c_height < 10 ? 1 : 2)); in vgacon_cursor()
534 c_height - (c_height < 10 ? 1 : 2)); in vgacon_cursor()
538 c_height - (c_height < 10 ? 1 : 2)); in vgacon_cursor()
542 c_height - (c_height < 10 ? 1 : 2)); in vgacon_cursor()
560 unsigned int scanlines = height * c->vc_cell_height; in vgacon_doresize()
566 vgacon_yres = height * c->vc_cell_height; in vgacon_doresize()
580 scanlines -= 1; in vgacon_doresize()
599 outb_p(width - 1, vga_video_port_val); in vgacon_doresize()
619 int x = c->vc_cols * VGA_FONTWIDTH; in vgacon_switch()
620 int y = c->vc_rows * c->vc_cell_height; in vgacon_switch()
621 int rows = vga_si->orig_video_lines * vga_default_font_height/ in vgacon_switch() local
622 c->vc_cell_height; in vgacon_switch()
628 vga_video_num_columns = c->vc_cols; in vgacon_switch()
629 vga_video_num_lines = c->vc_rows; in vgacon_switch()
635 scr_memcpyw((u16 *) c->vc_origin, (u16 *) c->vc_screenbuf, in vgacon_switch()
636 c->vc_screenbuf_size > vga_vram_size ? in vgacon_switch()
637 vga_vram_size : c->vc_screenbuf_size); in vgacon_switch()
641 vga_video_num_columns <= vga_si->orig_video_cols && in vgacon_switch()
642 vga_video_num_lines <= rows)) in vgacon_switch()
643 vgacon_doresize(c, c->vc_cols, c->vc_rows); in vgacon_switch()
656 vga_w(vgastate.vgabase, VGA_PEL_D, vc->vc_palette[j++] >> 2); in vga_set_palette()
657 vga_w(vgastate.vgabase, VGA_PEL_D, vc->vc_palette[j++] >> 2); in vga_set_palette()
658 vga_w(vgastate.vgabase, VGA_PEL_D, vc->vc_palette[j++] >> 2); in vga_set_palette()
673 unsigned char CrtCtrlIndex; /* CRT-Contr. Index reg. */
675 unsigned char HorizontalTotal; /* CRT-Controller:00h */
676 unsigned char HorizDisplayEnd; /* CRT-Controller:01h */
677 unsigned char StartHorizRetrace; /* CRT-Controller:04h */
678 unsigned char EndHorizRetrace; /* CRT-Controller:05h */
679 unsigned char Overflow; /* CRT-Controller:07h */
680 unsigned char StartVertRetrace; /* CRT-Controller:10h */
681 unsigned char EndVertRetrace; /* CRT-Controller:11h */
682 unsigned char ModeControl; /* CRT-Controller:17h */
683 unsigned char ClockingMode; /* Seq-Controller:01h */
691 vga_state.SeqCtrlIndex = vga_r(state->vgabase, VGA_SEQ_I); in vga_vesa_blank()
693 vga_state.CrtMiscIO = vga_r(state->vgabase, VGA_MIS_R); in vga_vesa_blank()
712 vga_state.ClockingMode = vga_rseq(state->vgabase, VGA_SEQ_CLOCK_MODE); in vga_vesa_blank()
718 vga_wseq(state->vgabase, VGA_SEQ_CLOCK_MODE, vga_state.ClockingMode | 0x20); in vga_vesa_blank()
722 vga_w(state->vgabase, VGA_MIS_W, vga_state.CrtMiscIO & 0xEF); in vga_vesa_blank()
751 vga_w(state->vgabase, VGA_SEQ_I, vga_state.SeqCtrlIndex); in vga_vesa_blank()
760 vga_w(state->vgabase, VGA_MIS_W, vga_state.CrtMiscIO); in vga_vesa_unblank()
779 vga_wseq(state->vgabase, VGA_SEQ_CLOCK_MODE, vga_state.ClockingMode); in vga_vesa_unblank()
782 vga_w(state->vgabase, VGA_SEQ_I, vga_state.SeqCtrlIndex); in vga_vesa_unblank()
791 vga_w(state->vgabase, VGA_PEL_MSK, 0xff); in vga_pal_blank()
793 vga_w(state->vgabase, VGA_PEL_IW, i); in vga_pal_blank()
794 vga_w(state->vgabase, VGA_PEL_D, 0); in vga_pal_blank()
795 vga_w(state->vgabase, VGA_PEL_D, 0); in vga_pal_blank()
796 vga_w(state->vgabase, VGA_PEL_D, 0); in vga_pal_blank()
825 c->vc_screenbuf_size); in vgacon_blank()
831 vga_vesa_blank(&vgastate, blank - 1); in vgacon_blank()
876 return -EINVAL; /* Return to default font not supported */ in vgacon_do_font_op()
882 vga_wseq(state->vgabase, VGA_SEQ_RESET, 0x1); in vgacon_do_font_op()
884 vga_wseq(state->vgabase, VGA_SEQ_PLANE_WRITE, 0x04); in vgacon_do_font_op()
886 vga_wseq(state->vgabase, VGA_SEQ_MEMORY_MODE, 0x07); in vgacon_do_font_op()
888 vga_wseq(state->vgabase, VGA_SEQ_RESET, 0x03); in vgacon_do_font_op()
891 vga_wgfx(state->vgabase, VGA_GFX_PLANE_READ, 0x02); in vgacon_do_font_op()
892 /* disable odd-even addressing */ in vgacon_do_font_op()
893 vga_wgfx(state->vgabase, VGA_GFX_MODE, 0x00); in vgacon_do_font_op()
895 vga_wgfx(state->vgabase, VGA_GFX_MISC, 0x00); in vgacon_do_font_op()
911 * In 512-character mode, the character map is not contiguous if in vgacon_do_font_op()
912 * we want to remain EGA compatible -- which we do in vgacon_do_font_op()
933 vga_wseq(state->vgabase, VGA_SEQ_RESET, 0x01); in vgacon_do_font_op()
935 vga_wseq(state->vgabase, VGA_SEQ_PLANE_WRITE, 0x03); in vgacon_do_font_op()
936 /* odd-even addressing */ in vgacon_do_font_op()
937 vga_wseq(state->vgabase, VGA_SEQ_MEMORY_MODE, 0x03); in vgacon_do_font_op()
940 vga_wseq(state->vgabase, VGA_SEQ_CHARACTER_MAP, font_select); in vgacon_do_font_op()
942 vga_wseq(state->vgabase, VGA_SEQ_RESET, 0x03); in vgacon_do_font_op()
945 vga_wgfx(state->vgabase, VGA_GFX_PLANE_READ, 0x00); in vgacon_do_font_op()
946 /* enable even-odd addressing */ in vgacon_do_font_op()
947 vga_wgfx(state->vgabase, VGA_GFX_MODE, 0x10); in vgacon_do_font_op()
949 vga_wgfx(state->vgabase, VGA_GFX_MISC, beg); in vgacon_do_font_op()
951 /* if 512 char mode is already enabled don't re-enable it. */ in vgacon_do_font_op()
954 /* 256-char: enable intensity bit in vgacon_do_font_op()
955 512-char: disable intensity bit */ in vgacon_do_font_op()
956 inb_p(video_port_status); /* clear address flip-flop */ in vgacon_do_font_op()
958 vga_wattr(state->vgabase, VGA_ATC_PLANE_ENABLE, ch512 ? 0x07 : 0x0f); in vgacon_do_font_op()
962 vga_wattr(state->vgabase, VGA_AR_ENABLE_DISPLAY, 0); in vgacon_do_font_op()
970 if (c && c->vc_sw == &vga_con) { in vgacon_do_font_op()
973 c->vc_hi_font_mask = 0x00; in vgacon_do_font_op()
975 c->vc_hi_font_mask = ch512 ? 0x0800 : 0; in vgacon_do_font_op()
988 int rows, maxscan, i; in vgacon_adjust_height() local
990 rows = vc->vc_scan_lines / fontheight; /* Number of video rows we end up with */ in vgacon_adjust_height()
991 maxscan = rows * fontheight - 1; /* Scan lines to actually display-1 */ in vgacon_adjust_height()
996 be OK for EGA text modes in the range 257-512 scan lines, so I in vgacon_adjust_height()
1000 registers; they are write-only on EGA, but it appears that they in vgacon_adjust_height()
1010 vde = maxscan & 0xff; /* Vertical display end reg */ in vgacon_adjust_height()
1013 fsr = (fsr & 0xe0) + (fontheight - 1); /* Font size register */ in vgacon_adjust_height()
1020 outb_p(0x12, vga_video_port_reg); /* Vertical display limit */ in vgacon_adjust_height()
1028 if (c && c->vc_sw == &vga_con) { in vgacon_adjust_height()
1033 c->vc_sw->con_cursor(c, true); in vgacon_adjust_height()
1035 c->vc_font.height = c->vc_cell_height = fontheight; in vgacon_adjust_height()
1036 vc_resize(c, 0, rows); /* Adjust console size */ in vgacon_adjust_height()
1045 unsigned charcount = font->charcount; in vgacon_font_set()
1049 return -EINVAL; in vgacon_font_set()
1051 if (font->width != VGA_FONTWIDTH || font->height > 32 || vpitch != 32 || in vgacon_font_set()
1053 return -EINVAL; in vgacon_font_set()
1055 rc = vgacon_do_font_op(&vgastate, font->data, 1, charcount == 512); in vgacon_font_set()
1060 rc = vgacon_adjust_height(c, font->height); in vgacon_font_set()
1067 return -EINVAL; in vgacon_font_get()
1069 font->width = VGA_FONTWIDTH; in vgacon_font_get()
1070 font->height = c->vc_font.height; in vgacon_font_get()
1071 font->charcount = vga_512_chars ? 512 : 256; in vgacon_font_get()
1072 if (!font->data) in vgacon_font_get()
1074 return vgacon_do_font_op(&vgastate, font->data, 0, vga_512_chars); in vgacon_font_get()
1081 return -EINVAL; in vgacon_resize()
1088 vga_si->orig_video_cols = width; in vgacon_resize()
1089 vga_si->orig_video_lines = height; in vgacon_resize()
1090 vga_default_font_height = c->vc_cell_height; in vgacon_resize()
1093 if (width % 2 || width > vga_si->orig_video_cols || in vgacon_resize()
1094 height > (vga_si->orig_video_lines * vga_default_font_height)/ in vgacon_resize()
1095 c->vc_cell_height) in vgacon_resize()
1096 return -EINVAL; in vgacon_resize()
1108 c->vc_origin = c->vc_visible_origin = vga_vram_base; in vgacon_set_origin()
1124 c->state.x = vga_si->orig_x; in vgacon_save_screen()
1125 c->state.y = vga_si->orig_y; in vgacon_save_screen()
1132 scr_memcpyw((u16 *) c->vc_screenbuf, (u16 *) c->vc_origin, in vgacon_save_screen()
1133 c->vc_screenbuf_size > vga_vram_size ? vga_vram_size : c->vc_screenbuf_size); in vgacon_save_screen()
1142 if (t || b != c->vc_rows || vga_is_gfx || c->vc_mode != KD_TEXT) in vgacon_scroll()
1145 if (!vga_hardscroll_enabled || lines >= c->vc_rows / 2) in vgacon_scroll()
1149 oldo = c->vc_origin; in vgacon_scroll()
1150 delta = lines * c->vc_size_row; in vgacon_scroll()
1152 if (c->vc_scr_end + delta >= vga_vram_end) { in vgacon_scroll()
1155 c->vc_screenbuf_size - delta); in vgacon_scroll()
1156 c->vc_origin = vga_vram_base; in vgacon_scroll()
1157 vga_rolled_over = oldo - vga_vram_base; in vgacon_scroll()
1159 c->vc_origin += delta; in vgacon_scroll()
1160 scr_memsetw((u16 *) (c->vc_origin + c->vc_screenbuf_size - in vgacon_scroll()
1161 delta), c->vc_video_erase_char, in vgacon_scroll()
1164 if (oldo - delta < vga_vram_base) { in vgacon_scroll()
1165 scr_memmovew((u16 *) (vga_vram_end - in vgacon_scroll()
1166 c->vc_screenbuf_size + in vgacon_scroll()
1168 c->vc_screenbuf_size - delta); in vgacon_scroll()
1169 c->vc_origin = vga_vram_end - c->vc_screenbuf_size; in vgacon_scroll()
1172 c->vc_origin -= delta; in vgacon_scroll()
1173 c->vc_scr_end = c->vc_origin + c->vc_screenbuf_size; in vgacon_scroll()
1174 scr_memsetw((u16 *) (c->vc_origin), c->vc_video_erase_char, in vgacon_scroll()
1177 c->vc_scr_end = c->vc_origin + c->vc_screenbuf_size; in vgacon_scroll()
1178 c->vc_visible_origin = c->vc_origin; in vgacon_scroll()
1180 c->vc_pos = (c->vc_pos - oldo) + c->vc_origin; in vgacon_scroll()