Deleted Added
full compact
scvidctl.c (53008) scvidctl.c (56043)
1/*-
2 * Copyright (c) 1998 Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 *
1/*-
2 * Copyright (c) 1998 Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 *
26 * $FreeBSD: head/sys/dev/syscons/scvidctl.c 53008 1999-11-08 09:57:16Z yokota $
26 * $FreeBSD: head/sys/dev/syscons/scvidctl.c 56043 2000-01-15 15:25:43Z yokota $
27 */
28
29#include "sc.h"
30#include "opt_syscons.h"
31
32#if NSC > 0
33
34#include <sys/param.h>
35#include <sys/systm.h>
36#include <sys/conf.h>
37#include <sys/signalvar.h>
38#include <sys/tty.h>
39#include <sys/kernel.h>
40
27 */
28
29#include "sc.h"
30#include "opt_syscons.h"
31
32#if NSC > 0
33
34#include <sys/param.h>
35#include <sys/systm.h>
36#include <sys/conf.h>
37#include <sys/signalvar.h>
38#include <sys/tty.h>
39#include <sys/kernel.h>
40
41#include <vm/vm.h>
42#include <vm/pmap.h>
43
44#include <machine/console.h>
45
46#include <dev/fb/fbreg.h>
47#include <dev/syscons/syscons.h>
48
49/* for compatibility with previous versions */
50/* 3.0-RELEASE used the following structure */
51typedef struct old_video_adapter {

--- 74 unchanged lines hidden (view full) ---

126#define OLD_CONS_MODEINFO _IOWR('c', 102, old_video_info_t)
127#define OLD_CONS_FINDMODE _IOWR('c', 103, old_video_info_t)
128
129int
130sc_set_text_mode(scr_stat *scp, struct tty *tp, int mode, int xsize, int ysize,
131 int fontsize)
132{
133 video_info_t info;
41#include <machine/console.h>
42
43#include <dev/fb/fbreg.h>
44#include <dev/syscons/syscons.h>
45
46/* for compatibility with previous versions */
47/* 3.0-RELEASE used the following structure */
48typedef struct old_video_adapter {

--- 74 unchanged lines hidden (view full) ---

123#define OLD_CONS_MODEINFO _IOWR('c', 102, old_video_info_t)
124#define OLD_CONS_FINDMODE _IOWR('c', 103, old_video_info_t)
125
126int
127sc_set_text_mode(scr_stat *scp, struct tty *tp, int mode, int xsize, int ysize,
128 int fontsize)
129{
130 video_info_t info;
134 sc_rndr_sw_t *rndr;
135 u_char *font;
136 int prev_ysize;
137 int error;
138 int s;
139
140 if ((*vidsw[scp->sc->adapter]->get_info)(scp->sc->adp, mode, &info))
141 return ENODEV;
142

--- 35 unchanged lines hidden (view full) ---

178
179 /* stop screen saver, etc */
180 s = spltty();
181 if ((error = sc_clean_up(scp))) {
182 splx(s);
183 return error;
184 }
185
131 u_char *font;
132 int prev_ysize;
133 int error;
134 int s;
135
136 if ((*vidsw[scp->sc->adapter]->get_info)(scp->sc->adp, mode, &info))
137 return ENODEV;
138

--- 35 unchanged lines hidden (view full) ---

174
175 /* stop screen saver, etc */
176 s = spltty();
177 if ((error = sc_clean_up(scp))) {
178 splx(s);
179 return error;
180 }
181
186 rndr = sc_render_match(scp, scp->sc->adp, 0);
187 if (rndr == NULL) {
182 if (sc_render_match(scp, scp->sc->adp->va_name, 0) == NULL) {
188 splx(s);
189 return ENODEV;
190 }
191
192 /* set up scp */
193#ifndef SC_NO_HISTORY
194 if (scp->history != NULL)
195 sc_hist_save(scp);

--- 12 unchanged lines hidden (view full) ---

208 scp->yoff = 0;
209 scp->xpixel = scp->xsize*8;
210 scp->ypixel = scp->ysize*fontsize;
211 scp->font = font;
212 scp->font_size = fontsize;
213
214 /* allocate buffers */
215 sc_alloc_scr_buffer(scp, TRUE, TRUE);
183 splx(s);
184 return ENODEV;
185 }
186
187 /* set up scp */
188#ifndef SC_NO_HISTORY
189 if (scp->history != NULL)
190 sc_hist_save(scp);

--- 12 unchanged lines hidden (view full) ---

203 scp->yoff = 0;
204 scp->xpixel = scp->xsize*8;
205 scp->ypixel = scp->ysize*fontsize;
206 scp->font = font;
207 scp->font_size = fontsize;
208
209 /* allocate buffers */
210 sc_alloc_scr_buffer(scp, TRUE, TRUE);
211 sc_init_emulator(scp, NULL);
216#ifndef SC_NO_CUTPASTE
217 sc_alloc_cut_buffer(scp, FALSE);
218#endif
219#ifndef SC_NO_HISTORY
220 sc_alloc_history_buffer(scp, 0, prev_ysize, FALSE);
221#endif
212#ifndef SC_NO_CUTPASTE
213 sc_alloc_cut_buffer(scp, FALSE);
214#endif
215#ifndef SC_NO_HISTORY
216 sc_alloc_history_buffer(scp, 0, prev_ysize, FALSE);
217#endif
222 scp->rndr = rndr;
223 splx(s);
224
225 if (scp == scp->sc->cur_scp)
226 set_mode(scp);
227 scp->status &= ~UNKNOWN_MODE;
228
229 if (tp == NULL)
230 return 0;

--- 11 unchanged lines hidden (view full) ---

242
243int
244sc_set_graphics_mode(scr_stat *scp, struct tty *tp, int mode)
245{
246#ifdef SC_NO_MODE_CHANGE
247 return ENODEV;
248#else
249 video_info_t info;
218 splx(s);
219
220 if (scp == scp->sc->cur_scp)
221 set_mode(scp);
222 scp->status &= ~UNKNOWN_MODE;
223
224 if (tp == NULL)
225 return 0;

--- 11 unchanged lines hidden (view full) ---

237
238int
239sc_set_graphics_mode(scr_stat *scp, struct tty *tp, int mode)
240{
241#ifdef SC_NO_MODE_CHANGE
242 return ENODEV;
243#else
244 video_info_t info;
250 sc_rndr_sw_t *rndr;
251 int error;
252 int s;
253
254 if ((*vidsw[scp->sc->adapter]->get_info)(scp->sc->adp, mode, &info))
255 return ENODEV;
256
257 /* stop screen saver, etc */
258 s = spltty();
259 if ((error = sc_clean_up(scp))) {
260 splx(s);
261 return error;
262 }
263
245 int error;
246 int s;
247
248 if ((*vidsw[scp->sc->adapter]->get_info)(scp->sc->adp, mode, &info))
249 return ENODEV;
250
251 /* stop screen saver, etc */
252 s = spltty();
253 if ((error = sc_clean_up(scp))) {
254 splx(s);
255 return error;
256 }
257
264 rndr = sc_render_match(scp, scp->sc->adp, GRAPHICS_MODE);
265 if (rndr == NULL) {
258 if (sc_render_match(scp, scp->sc->adp->va_name, GRAPHICS_MODE) == NULL) {
266 splx(s);
267 return ENODEV;
268 }
269
270 /* set up scp */
271 scp->status |= (UNKNOWN_MODE | GRAPHICS_MODE);
272 scp->status &= ~PIXEL_MODE;
273 scp->mode = mode;

--- 6 unchanged lines hidden (view full) ---

280 scp->xpixel = info.vi_width;
281 scp->ypixel = info.vi_height;
282 scp->font = NULL;
283 scp->font_size = FONT_NONE;
284#ifndef SC_NO_SYSMOUSE
285 /* move the mouse cursor at the center of the screen */
286 sc_mouse_move(scp, scp->xpixel / 2, scp->ypixel / 2);
287#endif
259 splx(s);
260 return ENODEV;
261 }
262
263 /* set up scp */
264 scp->status |= (UNKNOWN_MODE | GRAPHICS_MODE);
265 scp->status &= ~PIXEL_MODE;
266 scp->mode = mode;

--- 6 unchanged lines hidden (view full) ---

273 scp->xpixel = info.vi_width;
274 scp->ypixel = info.vi_height;
275 scp->font = NULL;
276 scp->font_size = FONT_NONE;
277#ifndef SC_NO_SYSMOUSE
278 /* move the mouse cursor at the center of the screen */
279 sc_mouse_move(scp, scp->xpixel / 2, scp->ypixel / 2);
280#endif
288 scp->rndr = rndr;
281 sc_init_emulator(scp, NULL);
289 splx(s);
290
291 if (scp == scp->sc->cur_scp)
292 set_mode(scp);
293 /* clear_graphics();*/
294 scp->status &= ~UNKNOWN_MODE;
295
296 if (tp == NULL)

--- 12 unchanged lines hidden (view full) ---

309int
310sc_set_pixel_mode(scr_stat *scp, struct tty *tp, int xsize, int ysize,
311 int fontsize)
312{
313#ifndef SC_PIXEL_MODE
314 return ENODEV;
315#else
316 video_info_t info;
282 splx(s);
283
284 if (scp == scp->sc->cur_scp)
285 set_mode(scp);
286 /* clear_graphics();*/
287 scp->status &= ~UNKNOWN_MODE;
288
289 if (tp == NULL)

--- 12 unchanged lines hidden (view full) ---

302int
303sc_set_pixel_mode(scr_stat *scp, struct tty *tp, int xsize, int ysize,
304 int fontsize)
305{
306#ifndef SC_PIXEL_MODE
307 return ENODEV;
308#else
309 video_info_t info;
317 sc_rndr_sw_t *rndr;
318 u_char *font;
319 int prev_ysize;
320 int error;
321 int s;
322
323 if ((*vidsw[scp->sc->adapter]->get_info)(scp->sc->adp, scp->mode, &info))
324 return ENODEV; /* this shouldn't happen */
325

--- 50 unchanged lines hidden (view full) ---

376
377 /* stop screen saver, etc */
378 s = spltty();
379 if ((error = sc_clean_up(scp))) {
380 splx(s);
381 return error;
382 }
383
310 u_char *font;
311 int prev_ysize;
312 int error;
313 int s;
314
315 if ((*vidsw[scp->sc->adapter]->get_info)(scp->sc->adp, scp->mode, &info))
316 return ENODEV; /* this shouldn't happen */
317

--- 50 unchanged lines hidden (view full) ---

368
369 /* stop screen saver, etc */
370 s = spltty();
371 if ((error = sc_clean_up(scp))) {
372 splx(s);
373 return error;
374 }
375
384 rndr = sc_render_match(scp, scp->sc->adp, PIXEL_MODE);
385 if (rndr == NULL) {
376 if (sc_render_match(scp, scp->sc->adp->va_name, PIXEL_MODE) == NULL) {
386 splx(s);
387 return ENODEV;
388 }
389
377 splx(s);
378 return ENODEV;
379 }
380
381#if 0
382 if (scp->tsw)
383 (*scp->tsw->te_term)(scp, scp->ts);
384 scp->tsw = NULL;
385 scp->ts = NULL;
386#endif
387
390 /* set up scp */
391#ifndef SC_NO_HISTORY
392 if (scp->history != NULL)
393 sc_hist_save(scp);
394#endif
395 prev_ysize = scp->ysize;
396 scp->status |= (UNKNOWN_MODE | PIXEL_MODE);
397 scp->status &= ~GRAPHICS_MODE;
398 scp->xsize = xsize;
399 scp->ysize = ysize;
400 scp->xoff = (scp->xpixel/8 - xsize)/2;
401 scp->yoff = (scp->ypixel/fontsize - ysize)/2;
402 scp->font = font;
403 scp->font_size = fontsize;
404
405 /* allocate buffers */
406 sc_alloc_scr_buffer(scp, TRUE, TRUE);
388 /* set up scp */
389#ifndef SC_NO_HISTORY
390 if (scp->history != NULL)
391 sc_hist_save(scp);
392#endif
393 prev_ysize = scp->ysize;
394 scp->status |= (UNKNOWN_MODE | PIXEL_MODE);
395 scp->status &= ~GRAPHICS_MODE;
396 scp->xsize = xsize;
397 scp->ysize = ysize;
398 scp->xoff = (scp->xpixel/8 - xsize)/2;
399 scp->yoff = (scp->ypixel/fontsize - ysize)/2;
400 scp->font = font;
401 scp->font_size = fontsize;
402
403 /* allocate buffers */
404 sc_alloc_scr_buffer(scp, TRUE, TRUE);
405 sc_init_emulator(scp, NULL);
407#ifndef SC_NO_CUTPASTE
408 sc_alloc_cut_buffer(scp, FALSE);
409#endif
410#ifndef SC_NO_HISTORY
411 sc_alloc_history_buffer(scp, 0, prev_ysize, FALSE);
412#endif
406#ifndef SC_NO_CUTPASTE
407 sc_alloc_cut_buffer(scp, FALSE);
408#endif
409#ifndef SC_NO_HISTORY
410 sc_alloc_history_buffer(scp, 0, prev_ysize, FALSE);
411#endif
413 scp->rndr = rndr;
414 splx(s);
415
416 if (scp == scp->sc->cur_scp) {
412 splx(s);
413
414 if (scp == scp->sc->cur_scp) {
417 set_border(scp, scp->border);
415 sc_set_border(scp, scp->border);
418 sc_set_cursor_image(scp);
419 }
420
421 scp->status &= ~UNKNOWN_MODE;
422
423 if (tp == NULL)
424 return 0;
425 if (tp->t_winsize.ws_col != scp->xsize
426 || tp->t_winsize.ws_row != scp->ysize) {
427 tp->t_winsize.ws_col = scp->xsize;
428 tp->t_winsize.ws_row = scp->ysize;
429 pgsignal(tp->t_pgrp, SIGWINCH, 1);
430 }
431
432 return 0;
433#endif /* SC_PIXEL_MODE */
434}
435
416 sc_set_cursor_image(scp);
417 }
418
419 scp->status &= ~UNKNOWN_MODE;
420
421 if (tp == NULL)
422 return 0;
423 if (tp->t_winsize.ws_col != scp->xsize
424 || tp->t_winsize.ws_row != scp->ysize) {
425 tp->t_winsize.ws_col = scp->xsize;
426 tp->t_winsize.ws_row = scp->ysize;
427 pgsignal(tp->t_pgrp, SIGWINCH, 1);
428 }
429
430 return 0;
431#endif /* SC_PIXEL_MODE */
432}
433
436sc_rndr_sw_t
437*sc_render_match(scr_stat *scp, video_adapter_t *adp, int mode)
438{
439 const sc_renderer_t **list;
440 const sc_renderer_t *p;
441
442 list = (const sc_renderer_t **)scrndr_set.ls_items;
443 while ((p = *list++) != NULL) {
444 if ((strcmp(p->name, adp->va_name) == 0)
445 && (mode == p->mode)) {
446 scp->status &= ~(VR_CURSOR_ON | VR_CURSOR_BLINK);
447 return p->rndrsw;
448 }
449 }
450
451 return NULL;
452}
453
454#define fb_ioctl(a, c, d) \
455 (((a) == NULL) ? ENODEV : \
456 (*vidsw[(a)->va_index]->ioctl)((a), (c), (caddr_t)(d)))
457
458int
459sc_vid_ioctl(struct tty *tp, u_long cmd, caddr_t data, int flag, struct proc *p)
460{
461 scr_stat *scp;

--- 199 unchanged lines hidden (view full) ---

661#ifndef SC_NO_FONT_LOADING
662 if (ISFONTAVAIL(adp->va_flags)
663 && !(scp->status & (GRAPHICS_MODE | PIXEL_MODE)))
664 /*
665 * FONT KLUDGE
666 * Don't load fonts for now... XXX
667 */
668 if (scp->sc->fonts_loaded & FONT_8)
434#define fb_ioctl(a, c, d) \
435 (((a) == NULL) ? ENODEV : \
436 (*vidsw[(a)->va_index]->ioctl)((a), (c), (caddr_t)(d)))
437
438int
439sc_vid_ioctl(struct tty *tp, u_long cmd, caddr_t data, int flag, struct proc *p)
440{
441 scr_stat *scp;

--- 199 unchanged lines hidden (view full) ---

641#ifndef SC_NO_FONT_LOADING
642 if (ISFONTAVAIL(adp->va_flags)
643 && !(scp->status & (GRAPHICS_MODE | PIXEL_MODE)))
644 /*
645 * FONT KLUDGE
646 * Don't load fonts for now... XXX
647 */
648 if (scp->sc->fonts_loaded & FONT_8)
669 copy_font(scp, LOAD, 8, scp->sc->font_8);
649 sc_load_font(scp, 0, 8, scp->sc->font_8, 0, 256);
670 if (scp->sc->fonts_loaded & FONT_14)
650 if (scp->sc->fonts_loaded & FONT_14)
671 copy_font(scp, LOAD, 14, scp->sc->font_14);
651 sc_load_font(scp, 0, 14, scp->sc->font_14, 0, 256);
672 if (scp->sc->fonts_loaded & FONT_16)
652 if (scp->sc->fonts_loaded & FONT_16)
673 copy_font(scp, LOAD, 16, scp->sc->font_16);
653 sc_load_font(scp, 0, 16, scp->sc->font_16, 0, 256);
674 }
675#endif /* SC_NO_FONT_LOADING */
676#endif
677
678#ifndef SC_NO_PALETTE_LOADING
679 load_palette(adp, scp->sc->palette);
680#endif
681

--- 92 unchanged lines hidden (view full) ---

774 * as KD_TEXT...
775 */
776 *data = ISGRAPHSC(scp) ? KD_GRAPHICS : KD_TEXT;
777 return 0;
778
779 case KDSBORDER: /* set border color of this (virtual) console */
780 scp->border = *data;
781 if (scp == scp->sc->cur_scp)
654 }
655#endif /* SC_NO_FONT_LOADING */
656#endif
657
658#ifndef SC_NO_PALETTE_LOADING
659 load_palette(adp, scp->sc->palette);
660#endif
661

--- 92 unchanged lines hidden (view full) ---

754 * as KD_TEXT...
755 */
756 *data = ISGRAPHSC(scp) ? KD_GRAPHICS : KD_TEXT;
757 return 0;
758
759 case KDSBORDER: /* set border color of this (virtual) console */
760 scp->border = *data;
761 if (scp == scp->sc->cur_scp)
782 set_border(scp, scp->border);
762 sc_set_border(scp, scp->border);
783 return 0;
784 }
785
786 return ENOIOCTL;
787}
788
763 return 0;
764 }
765
766 return ENOIOCTL;
767}
768
769static LIST_HEAD(, sc_renderer) sc_rndr_list =
770 LIST_HEAD_INITIALIZER(sc_rndr_list);
771
772int
773sc_render_add(sc_renderer_t *rndr)
774{
775 LIST_INSERT_HEAD(&sc_rndr_list, rndr, link);
776 return 0;
777}
778
779int
780sc_render_remove(sc_renderer_t *rndr)
781{
782 /*
783 LIST_REMOVE(rndr, link);
784 */
785 return EBUSY; /* XXX */
786}
787
788sc_rndr_sw_t
789*sc_render_match(scr_stat *scp, char *name, int mode)
790{
791 const sc_renderer_t **list;
792 const sc_renderer_t *p;
793
794 if (!LIST_EMPTY(&sc_rndr_list)) {
795 LIST_FOREACH(p, &sc_rndr_list, link) {
796 if ((strcmp(p->name, name) == 0)
797 && (mode == p->mode)) {
798 scp->status &=
799 ~(VR_CURSOR_ON | VR_CURSOR_BLINK);
800 return p->rndrsw;
801 }
802 }
803 } else {
804 list = (const sc_renderer_t **)scrndr_set.ls_items;
805 while ((p = *list++) != NULL) {
806 if ((strcmp(p->name, name) == 0)
807 && (mode == p->mode)) {
808 scp->status &=
809 ~(VR_CURSOR_ON | VR_CURSOR_BLINK);
810 return p->rndrsw;
811 }
812 }
813 }
814
815 return NULL;
816}
817
789#endif /* NSC > 0 */
818#endif /* NSC > 0 */