4 * Copyright (c) 1998 Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp>
7 * This code is derived from software contributed to The DragonFly Project
8 * by Sascha Wildner <saw@online.de>.
10 * Simple font scaling code by Sascha Wildner and Matthew Dillon
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer as
17 * the first lines of this file unmodified.
18 * 2. Redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in the
20 * documentation and/or other materials provided with the distribution.
22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 * $FreeBSD: src/sys/dev/syscons/scvidctl.c,v 1.19.2.2 2000/05/05 09:16:08 nyan Exp $
36 #include "opt_syscons.h"
38 #include <sys/param.h>
39 #include <sys/systm.h>
41 #include <sys/signalvar.h>
43 #include <sys/kernel.h>
44 #include <sys/thread2.h>
46 #include <machine/console.h>
47 #include <machine/framebuffer.h>
49 #include <dev/video/fb/fbreg.h>
52 SET_DECLARE(scrndr_set, const sc_renderer_t);
55 sc_set_text_mode(scr_stat *scp, struct tty *tp, int mode, int xsize, int ysize,
64 lwkt_gettoken(&vga_token);
65 if ((*vidsw[scp->sc->adapter]->get_info)(scp->sc->adp, mode, &info)) {
66 lwkt_reltoken(&vga_token);
70 /* adjust argument values */
72 fontsize = info.vi_cheight;
75 #ifndef SC_NO_FONT_LOADING
76 if (!(scp->sc->fonts_loaded & FONT_8))
78 font = scp->sc->font_8;
82 } else if (fontsize >= 16) {
84 #ifndef SC_NO_FONT_LOADING
85 if (!(scp->sc->fonts_loaded & FONT_16))
87 font = scp->sc->font_16;
93 #ifndef SC_NO_FONT_LOADING
94 if (!(scp->sc->fonts_loaded & FONT_14))
96 font = scp->sc->font_14;
101 if ((xsize <= 0) || (xsize > info.vi_width))
102 xsize = info.vi_width;
103 if ((ysize <= 0) || (ysize > info.vi_height))
104 ysize = info.vi_height;
106 /* stop screen saver, etc */
107 if ((error = sc_clean_up(scp, FALSE))) {
108 lwkt_reltoken(&vga_token);
112 if (scp->sc->fbi != NULL &&
113 sc_render_match(scp, "kms", V_INFO_MM_TEXT) == NULL) {
114 lwkt_reltoken(&vga_token);
117 if (scp->sc->fbi == NULL &&
118 sc_render_match(scp, scp->sc->adp->va_name, V_INFO_MM_TEXT) == NULL) {
119 lwkt_reltoken(&vga_token);
125 #ifndef SC_NO_HISTORY
126 if (scp->history != NULL) {
128 new_ysize = sc_vtb_rows(scp->history);
131 prev_ysize = scp->ysize;
133 * This is a kludge to fend off scrn_update() while we
134 * muck around with scp. XXX
136 scp->status |= UNKNOWN_MODE | MOUSE_HIDDEN;
137 scp->status &= ~(GRAPHICS_MODE | PIXEL_MODE | MOUSE_VISIBLE);
139 scp->model = V_INFO_MM_TEXT;
144 scp->xpixel = scp->xsize*8;
145 scp->ypixel = scp->ysize*fontsize;
147 scp->font_height = fontsize;
150 /* allocate buffers */
151 sc_alloc_scr_buffer(scp, TRUE, TRUE);
152 sc_init_emulator(scp, NULL);
153 #ifndef SC_NO_CUTPASTE
154 sc_alloc_cut_buffer(scp, FALSE);
156 #ifndef SC_NO_HISTORY
157 sc_alloc_history_buffer(scp, new_ysize, prev_ysize, FALSE);
160 if (scp == scp->sc->cur_scp)
162 scp->status &= ~UNKNOWN_MODE;
165 DPRINTF(5, ("ws_*size (%d,%d), size (%d,%d)\n",
166 tp->t_winsize.ws_col, tp->t_winsize.ws_row,
167 scp->xsize, scp->ysize));
168 if (tp->t_winsize.ws_col != scp->xsize ||
169 tp->t_winsize.ws_row != scp->ysize) {
170 tp->t_winsize.ws_col = scp->xsize;
171 tp->t_winsize.ws_row = scp->ysize;
172 pgsignal(tp->t_pgrp, SIGWINCH, 1);
175 lwkt_reltoken(&vga_token);
181 sc_set_graphics_mode(scr_stat *scp, struct tty *tp, int mode)
183 #ifdef SC_NO_MODE_CHANGE
189 lwkt_gettoken(&vga_token);
190 if ((*vidsw[scp->sc->adapter]->get_info)(scp->sc->adp, mode, &info)) {
191 lwkt_reltoken(&vga_token);
194 lwkt_reltoken(&vga_token);
196 /* stop screen saver, etc */
198 if ((error = sc_clean_up(scp, FALSE))) {
203 if (scp->sc->fbi != NULL &&
204 sc_render_match(scp, "kms", V_INFO_MM_OTHER) == NULL) {
208 if (scp->sc->fbi == NULL &&
209 sc_render_match(scp, scp->sc->adp->va_name, V_INFO_MM_OTHER) == NULL) {
215 scp->status |= (UNKNOWN_MODE | GRAPHICS_MODE | MOUSE_HIDDEN);
216 scp->status &= ~(PIXEL_MODE | MOUSE_VISIBLE);
218 scp->model = V_INFO_MM_OTHER;
220 * Don't change xsize and ysize; preserve the previous vty
221 * and history buffers.
225 scp->xpixel = info.vi_width;
226 scp->ypixel = info.vi_height;
228 scp->font_height = 0;
230 #ifndef SC_NO_SYSMOUSE
231 /* move the mouse cursor at the center of the screen */
232 sc_mouse_move(scp, scp->xpixel / 2, scp->ypixel / 2);
234 sc_init_emulator(scp, NULL);
237 if (scp == scp->sc->cur_scp)
239 /* clear_graphics();*/
240 refresh_ega_palette(scp);
241 scp->status &= ~UNKNOWN_MODE;
244 if (tp->t_winsize.ws_xpixel != scp->xpixel ||
245 tp->t_winsize.ws_ypixel != scp->ypixel) {
246 tp->t_winsize.ws_xpixel = scp->xpixel;
247 tp->t_winsize.ws_ypixel = scp->ypixel;
248 pgsignal(tp->t_pgrp, SIGWINCH, 1);
253 #endif /* SC_NO_MODE_CHANGE */
257 sc_set_pixel_mode(scr_stat *scp, struct tty *tp, int xsize, int ysize,
260 #ifndef SC_PIXEL_MODE
269 lwkt_gettoken(&vga_token);
270 if ((*vidsw[scp->sc->adapter]->get_info)(scp->sc->adp, scp->mode, &info)) {
271 lwkt_reltoken(&vga_token);
272 return ENODEV; /* this shouldn't happen */
274 lwkt_reltoken(&vga_token);
276 /* adjust argument values */
278 fontsize = info.vi_cheight;
281 #ifndef SC_NO_FONT_LOADING
282 if (!(scp->sc->fonts_loaded & FONT_8))
284 font = scp->sc->font_8;
288 } else if (fontsize >= 16) {
290 #ifndef SC_NO_FONT_LOADING
291 if (!(scp->sc->fonts_loaded & FONT_16))
293 font = scp->sc->font_16;
299 #ifndef SC_NO_FONT_LOADING
300 if (!(scp->sc->fonts_loaded & FONT_14))
302 font = scp->sc->font_14;
308 xsize = info.vi_width/8;
310 ysize = info.vi_height/fontsize;
312 if ((info.vi_width < xsize*8) || (info.vi_height < ysize*fontsize))
316 * We currently support the following graphic modes:
318 * - 4 bpp planar modes whose memory size does not exceed 64K
319 * - 8 bbp packed pixel modes
320 * - 15, 16, 24 and 32 bpp direct modes with linear frame buffer
323 if (info.vi_mem_model == V_INFO_MM_PLANAR) {
324 if (info.vi_planes != 4)
328 * A memory size >64K requires bank switching to access the entire
332 if (info.vi_width * info.vi_height / 8 > info.vi_window_size)
334 } else if (info.vi_mem_model == V_INFO_MM_PACKED) {
335 if (info.vi_depth != 8)
337 } else if (info.vi_mem_model == V_INFO_MM_DIRECT) {
338 if (!(info.vi_flags & V_INFO_LINEAR) &&
339 (info.vi_depth != 15) && (info.vi_depth != 16) &&
340 (info.vi_depth != 24) && (info.vi_depth != 32))
345 /* stop screen saver, etc */
347 if ((error = sc_clean_up(scp, FALSE))) {
352 if (sc_render_match(scp, scp->sc->adp->va_name, info.vi_mem_model) == NULL) {
359 (*scp->tsw->te_term)(scp, scp->ts);
366 #ifndef SC_NO_HISTORY
367 if (scp->history != NULL) {
369 new_ysize = sc_vtb_rows(scp->history);
372 prev_ysize = scp->ysize;
373 scp->status |= (UNKNOWN_MODE | PIXEL_MODE | MOUSE_HIDDEN);
374 scp->status &= ~(GRAPHICS_MODE | MOUSE_VISIBLE);
375 scp->model = info.vi_mem_model;
378 scp->xoff = (scp->xpixel/8 - xsize)/2;
379 scp->yoff = (scp->ypixel/fontsize - ysize)/2;
381 scp->font_height = fontsize;
384 /* allocate buffers */
385 sc_alloc_scr_buffer(scp, TRUE, TRUE);
386 sc_init_emulator(scp, NULL);
387 #ifndef SC_NO_CUTPASTE
388 sc_alloc_cut_buffer(scp, FALSE);
390 #ifndef SC_NO_HISTORY
391 sc_alloc_history_buffer(scp, new_ysize, prev_ysize, FALSE);
395 if (scp == scp->sc->cur_scp) {
396 sc_set_border(scp, scp->border);
397 sc_set_cursor_image(scp);
400 scp->status &= ~UNKNOWN_MODE;
403 if (tp->t_winsize.ws_col != scp->xsize ||
404 tp->t_winsize.ws_row != scp->ysize) {
405 tp->t_winsize.ws_col = scp->xsize;
406 tp->t_winsize.ws_row = scp->ysize;
407 pgsignal(tp->t_pgrp, SIGWINCH, 1);
412 #endif /* SC_PIXEL_MODE */
415 #define fb_ioctl(a, c, d) \
416 (((a) == NULL) ? ENODEV : \
417 (*vidsw[(a)->va_index]->ioctl)((a), (c), (caddr_t)(d)))
420 sc_vid_ioctl(struct tty *tp, u_long cmd, caddr_t data, int flag)
423 video_adapter_t *adp;
424 #ifndef SC_NO_MODE_CHANGE
431 scp = SC_STAT(tp->t_dev);
432 if (scp == NULL) /* tp == SC_MOUSE */
435 if (adp == NULL && scp->sc->fbi == NULL) /* shouldn't happen??? */
438 lwkt_gettoken(&vga_token);
441 case CONS_CURRENTADP: /* get current adapter index */
443 if (scp->sc->fbi != NULL) {
446 ret = fb_ioctl(adp, FBIO_ADAPTER, data);
448 lwkt_reltoken(&vga_token);
451 case CONS_CURRENT: /* get current adapter type */
453 if (scp->sc->fbi != NULL) {
456 ret = fb_ioctl(adp, FBIO_ADPTYPE, data);
458 lwkt_reltoken(&vga_token);
461 case CONS_ADPINFO: /* adapter information */
463 if (scp->sc->fbi != NULL) {
464 lwkt_reltoken(&vga_token);
467 if (((video_adapter_info_t *)data)->va_index >= 0) {
468 adp = vid_get_adapter(((video_adapter_info_t *)data)->va_index);
470 lwkt_reltoken(&vga_token);
474 ret = fb_ioctl(adp, FBIO_ADPINFO, data);
475 lwkt_reltoken(&vga_token);
478 case CONS_GET: /* get current video mode */
480 *(int *)data = scp->mode;
481 lwkt_reltoken(&vga_token);
484 #ifndef SC_NO_MODE_CHANGE
486 case FBIO_SETMODE: /* set video mode */
487 if (scp->sc->fbi != NULL) {
488 lwkt_reltoken(&vga_token);
489 if (*(int *)data != 0)
494 if (!(adp->va_flags & V_ADP_MODECHANGE)) {
495 lwkt_reltoken(&vga_token);
498 info.vi_mode = *(int *)data;
499 error = fb_ioctl(adp, FBIO_MODEINFO, &info);
501 lwkt_reltoken(&vga_token);
504 if (info.vi_flags & V_INFO_GRAPHICS) {
505 lwkt_reltoken(&vga_token);
506 return sc_set_graphics_mode(scp, tp, *(int *)data);
508 lwkt_reltoken(&vga_token);
509 return sc_set_text_mode(scp, tp, *(int *)data, 0, 0, 0);
511 #endif /* SC_NO_MODE_CHANGE */
513 case CONS_MODEINFO: /* get mode information */
515 if (scp->sc->fbi != NULL) {
516 /* Fabricate some mode information for KMS framebuffer */
517 video_info_t *vinfo = (video_info_t *)data;
519 vinfo->vi_flags = V_INFO_COLOR;
520 vinfo->vi_width = scp->xsize;
521 vinfo->vi_height = scp->ysize;
522 vinfo->vi_cwidth = scp->font_width;
523 vinfo->vi_cheight = scp->font_height;
524 vinfo->vi_window = 0;
525 vinfo->vi_window_size = 0;
526 vinfo->vi_buffer = 0;
527 vinfo->vi_buffer_size = 0;
528 vinfo->vi_mem_model = V_INFO_MM_TEXT;
531 ret = fb_ioctl(adp, FBIO_MODEINFO, data);
533 lwkt_reltoken(&vga_token);
536 case CONS_FINDMODE: /* find a matching video mode */
538 if (scp->sc->fbi != NULL) {
541 ret = fb_ioctl(adp, FBIO_FINDMODE, data);
543 lwkt_reltoken(&vga_token);
546 case CONS_SETWINORG: /* set frame buffer window origin */
548 if (scp != scp->sc->cur_scp) {
549 lwkt_reltoken(&vga_token);
550 return ENODEV; /* XXX */
552 if (scp->sc->fbi != NULL) {
553 lwkt_reltoken(&vga_token);
556 ret = fb_ioctl(adp, FBIO_SETWINORG, data);
557 lwkt_reltoken(&vga_token);
560 case FBIO_GETWINORG: /* get frame buffer window origin */
561 if (scp != scp->sc->cur_scp) {
562 lwkt_reltoken(&vga_token);
563 return ENODEV; /* XXX */
565 if (scp->sc->fbi != NULL) {
568 ret = fb_ioctl(adp, FBIO_GETWINORG, data);
570 lwkt_reltoken(&vga_token);
573 case FBIO_GETDISPSTART:
574 case FBIO_SETDISPSTART:
575 case FBIO_GETLINEWIDTH:
576 case FBIO_SETLINEWIDTH:
577 if (scp != scp->sc->cur_scp) {
578 lwkt_reltoken(&vga_token);
579 return ENODEV; /* XXX */
581 if (scp->sc->fbi != NULL) {
582 if (cmd == FBIO_GETLINEWIDTH) {
583 *(u_int *)data = scp->sc->fbi->stride;
589 ret = fb_ioctl(adp, cmd, data);
591 lwkt_reltoken(&vga_token);
595 if (scp != scp->sc->cur_scp) {
596 lwkt_reltoken(&vga_token);
599 if (scp->sc->fbi != NULL && ISGRAPHSC(scp)) {
600 if (*(int *)data == V_DISPLAY_ON)
601 sc_stop_scrn_saver(scp->sc);
603 sc_start_scrn_saver(scp->sc);
608 lwkt_reltoken(&vga_token);
611 case FBIO_GETPALETTE:
612 case FBIO_SETPALETTE:
624 if (scp != scp->sc->cur_scp) {
625 lwkt_reltoken(&vga_token);
626 return ENODEV; /* XXX */
628 if (scp->sc->fbi != NULL) {
629 if (cmd == FBIOGTYPE) {
630 ((struct fbtype *)data)->fb_type = FBTYPE_DUMBFB;
631 ((struct fbtype *)data)->fb_height = scp->sc->fbi->height;
632 ((struct fbtype *)data)->fb_width = scp->sc->fbi->width;
633 ((struct fbtype *)data)->fb_depth = scp->sc->fbi->depth;
634 ((struct fbtype *)data)->fb_cmsize = 0;
635 ((struct fbtype *)data)->fb_size =
636 scp->sc->fbi->height * scp->sc->fbi->stride;
642 ret = fb_ioctl(adp, cmd, data);
644 lwkt_reltoken(&vga_token);
647 case KDSETMODE: /* set current mode of this (virtual) console */
648 switch (*(int *)data) {
649 case KD_TEXT: /* switch to TEXT (known) mode */
651 * If scp->mode is of graphics modes, we don't know which
652 * text mode to switch back to...
654 if (scp->status & GRAPHICS_MODE) {
655 lwkt_reltoken(&vga_token);
658 /* restore fonts & palette ! */
660 #ifndef SC_NO_FONT_LOADING
661 if (scp->sc->fbi == NULL && ISFONTAVAIL(adp->va_flags)
662 && !(scp->status & (GRAPHICS_MODE | PIXEL_MODE))) {
665 * Don't load fonts for now... XXX
667 if (scp->sc->fonts_loaded & FONT_8)
668 sc_load_font(scp, 0, 8, scp->sc->font_8, 0, 256);
669 if (scp->sc->fonts_loaded & FONT_14)
670 sc_load_font(scp, 0, 14, scp->sc->font_14, 0, 256);
671 if (scp->sc->fonts_loaded & FONT_16)
672 sc_load_font(scp, 0, 16, scp->sc->font_16, 0, 256);
674 #endif /* SC_NO_FONT_LOADING */
677 if (scp->sc->fbi == NULL)
678 load_palette(adp, scp->sc->palette);
680 /* move hardware cursor out of the way */
681 if (scp->sc->fbi == NULL)
682 (*vidsw[adp->va_index]->set_hw_cursor)(adp, -1, -1);
685 case KD_TEXT1: /* switch to TEXT (known) mode */
687 * If scp->mode is of graphics modes, we don't know which
688 * text/pixel mode to switch back to...
690 if (scp->status & GRAPHICS_MODE) {
691 lwkt_reltoken(&vga_token);
695 if ((error = sc_clean_up(scp, FALSE))) {
697 lwkt_reltoken(&vga_token);
700 scp->status |= UNKNOWN_MODE | MOUSE_HIDDEN;
702 /* no restore fonts & palette */
703 if (scp == scp->sc->cur_scp)
705 sc_clear_screen(scp);
706 scp->status &= ~UNKNOWN_MODE;
707 lwkt_reltoken(&vga_token);
711 case KD_PIXEL: /* pixel (raster) display */
712 if (!(scp->status & (GRAPHICS_MODE | PIXEL_MODE))) {
713 lwkt_reltoken(&vga_token);
716 if (scp->sc->fbi != NULL) {
717 lwkt_reltoken(&vga_token);
720 if (scp->status & GRAPHICS_MODE) {
721 lwkt_reltoken(&vga_token);
722 return sc_set_pixel_mode(scp, tp, scp->xsize, scp->ysize,
726 if ((error = sc_clean_up(scp, FALSE))) {
728 lwkt_reltoken(&vga_token);
731 scp->status |= (UNKNOWN_MODE | PIXEL_MODE | MOUSE_HIDDEN);
733 if (scp == scp->sc->cur_scp) {
735 load_palette(adp, scp->sc->palette);
737 sc_clear_screen(scp);
738 scp->status &= ~UNKNOWN_MODE;
739 lwkt_reltoken(&vga_token);
741 #endif /* SC_PIXEL_MODE */
743 case KD_GRAPHICS: /* switch to GRAPHICS (unknown) mode */
745 if ((error = sc_clean_up(scp, FALSE))) {
747 lwkt_reltoken(&vga_token);
750 scp->status |= UNKNOWN_MODE | MOUSE_HIDDEN;
752 lwkt_reltoken(&vga_token);
756 lwkt_reltoken(&vga_token);
762 case KDRASTER: /* set pixel (raster) display mode */
763 if (scp->sc->fbi != NULL || ISUNKNOWNSC(scp) || ISTEXTSC(scp)) {
764 lwkt_reltoken(&vga_token);
767 lwkt_reltoken(&vga_token);
768 return sc_set_pixel_mode(scp, tp, ((int *)data)[0], ((int *)data)[1],
770 #endif /* SC_PIXEL_MODE */
772 case KDGETMODE: /* get current mode of this (virtual) console */
774 * From the user program's point of view, KD_PIXEL is the same
777 *data = ISGRAPHSC(scp) ? KD_GRAPHICS : KD_TEXT;
778 lwkt_reltoken(&vga_token);
781 case KDSBORDER: /* set border color of this (virtual) console */
782 /* Only values in the range [0..15] allowed */
783 if (*(int *)data < 0 || *(int *)data > 15) {
784 lwkt_reltoken(&vga_token);
787 scp->border = *(int *)data;
788 if (scp == scp->sc->cur_scp)
789 sc_set_border(scp, scp->border);
790 lwkt_reltoken(&vga_token);
794 lwkt_reltoken(&vga_token);
798 static LIST_HEAD(, sc_renderer) sc_rndr_list =
799 LIST_HEAD_INITIALIZER(sc_rndr_list);
802 sc_render_add(sc_renderer_t *rndr)
804 LIST_INSERT_HEAD(&sc_rndr_list, rndr, link);
809 sc_render_remove(sc_renderer_t *rndr)
812 LIST_REMOVE(rndr, link);
814 return EBUSY; /* XXX */
818 sc_render_match(scr_stat *scp, char *name, int model)
820 const sc_renderer_t **list;
821 const sc_renderer_t *p;
823 if (!LIST_EMPTY(&sc_rndr_list)) {
824 LIST_FOREACH(p, &sc_rndr_list, link) {
825 if ((strcmp(p->name, name) == 0) &&
826 (model == p->model)) {
828 ~(VR_CURSOR_ON | VR_CURSOR_BLINK);
833 SET_FOREACH(list, scrndr_set) {
835 if ((strcmp(p->name, name) == 0) &&
836 (model == p->model)) {
838 ~(VR_CURSOR_ON | VR_CURSOR_BLINK);
847 #define VIRTUAL_TTY(sc, x) ((SC_DEV((sc),(x)) != NULL) ? \
848 (SC_DEV((sc),(x))->si_tty) : NULL)
851 sc_update_render(scr_stat *scp)
856 int prev_ysize, new_ysize;
857 #ifndef SC_NO_HISTORY
858 int old_xpos, old_ypos;
867 if (scp->rndr == NULL)
870 if (scp->fbi_generation == scp->sc->fbi_generation)
874 scp->fbi_generation = scp->sc->fbi_generation;
875 /* Needed in case we are implicitly leaving PIXEL_MODE here */
876 if (scp->model != V_INFO_MM_OTHER)
877 scp->model = V_INFO_MM_TEXT;
879 if (strcmp(sw->te_renderer, "*") != 0) {
880 rndr = sc_render_match(scp, sw->te_renderer, scp->model);
882 if (rndr == NULL && scp->sc->fbi != NULL) {
883 rndr = sc_render_match(scp, "kms", scp->model);
885 if (rndr == NULL) { /* this shouldn't happen */
886 rndr = sc_render_match(scp, scp->sc->adp->va_name, scp->model);
894 /* Mostly copied from sc_set_text_mode */
895 if ((error = sc_clean_up(scp, FALSE))) {
900 #ifndef SC_NO_HISTORY
901 old_xpos = old_ypos = 0;
902 if (scp->history != NULL) {
903 if (scp->xsize > 0) {
904 old_xpos = scp->xpos;
905 old_ypos = scp->ypos;
908 new_ysize = sc_vtb_rows(scp->history);
911 prev_ysize = scp->ysize;
912 scp->status |= MOUSE_HIDDEN;
913 if (scp->status & GRAPHICS_MODE) {
915 * We don't handle GRAPHICS_MODE at all when using a KMS
916 * framebuffer, so silently switch to UNKNOWN_MODE then.
918 scp->status |= UNKNOWN_MODE;
919 scp->status &= ~GRAPHICS_MODE;
921 /* Implicitly leave PIXEL_MODE, but stay in UNKNOWN mode */
922 scp->status &= ~(PIXEL_MODE | MOUSE_VISIBLE);
923 scp->xpixel = scp->sc->fbi->width;
924 scp->ypixel = scp->sc->fbi->height;
927 * Assume square pixels for now
929 sc_font_scale(scp, 0, 0);
931 DPRINTF(1, ("kms console: scale-to %dx%d cols=%d rows=%d\n",
932 scp->blk_width, scp->blk_height, scp->xsize, scp->ysize));
934 /* allocate buffers */
935 sc_alloc_scr_buffer(scp, TRUE, TRUE);
936 sc_init_emulator(scp, NULL);
937 #ifndef SC_NO_CUTPASTE
938 sc_alloc_cut_buffer(scp, FALSE);
940 #ifndef SC_NO_HISTORY
941 sc_alloc_history_buffer(scp, new_ysize, prev_ysize, FALSE);
942 if (scp->history != NULL) {
943 sc_hist_getback(scp, prev_ysize);
944 sc_move_cursor(scp, old_xpos, old_ypos);
948 tp = VIRTUAL_TTY(scp->sc, scp->index);
951 if (tp->t_winsize.ws_col != scp->xsize ||
952 tp->t_winsize.ws_row != scp->ysize) {
953 tp->t_winsize.ws_col = scp->xsize;
954 tp->t_winsize.ws_row = scp->ysize;
955 pgsignal(tp->t_pgrp, SIGWINCH, 1);