Deleted Added
sdiff udiff text old ( 53008 ) new ( 56043 )
full compact
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 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
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;
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
182 if (sc_render_match(scp, scp->sc->adp->va_name, 0) == NULL) {
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);
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
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;
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
258 if (sc_render_match(scp, scp->sc->adp->va_name, GRAPHICS_MODE) == NULL) {
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
281 sc_init_emulator(scp, NULL);
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;
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
376 if (sc_render_match(scp, scp->sc->adp->va_name, PIXEL_MODE) == NULL) {
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
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);
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
412 splx(s);
413
414 if (scp == scp->sc->cur_scp) {
415 sc_set_border(scp, scp->border);
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
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)
649 sc_load_font(scp, 0, 8, scp->sc->font_8, 0, 256);
650 if (scp->sc->fonts_loaded & FONT_14)
651 sc_load_font(scp, 0, 14, scp->sc->font_14, 0, 256);
652 if (scp->sc->fonts_loaded & FONT_16)
653 sc_load_font(scp, 0, 16, scp->sc->font_16, 0, 256);
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)
762 sc_set_border(scp, scp->border);
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
818#endif /* NSC > 0 */