scvesactl.c revision 39668
11096SN/A/*- 26073SN/A * Copyright (c) 1998 Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp> 31096SN/A * All rights reserved. 41096SN/A * 51096SN/A * Redistribution and use in source and binary forms, with or without 61096SN/A * modification, are permitted provided that the following conditions 72362SN/A * are met: 81096SN/A * 1. Redistributions of source code must retain the above copyright 92362SN/A * notice, this list of conditions and the following disclaimer as 101096SN/A * the first lines of this file unmodified. 111096SN/A * 2. Redistributions in binary form must reproduce the above copyright 121096SN/A * notice, this list of conditions and the following disclaimer in the 131096SN/A * documentation and/or other materials provided with the distribution. 141096SN/A * 151096SN/A * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 161096SN/A * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 171096SN/A * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 181096SN/A * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 191096SN/A * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 201096SN/A * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 212362SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 222362SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 232362SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 241096SN/A * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 251096SN/A * 265012SN/A * $Id: scvesactl.c,v 1.4 1998/09/26 03:34:10 yokota Exp $ 271096SN/A */ 281096SN/A 291096SN/A#include "sc.h" 301096SN/A#include "opt_vesa.h" 311096SN/A#include "opt_vm86.h" 321096SN/A 331096SN/A#if (NSC > 0 && defined(VESA) && defined(VM86)) || defined(VESA_MODULE) 341096SN/A 355012SN/A#include <sys/param.h> 361096SN/A#include <sys/systm.h> 371096SN/A#include <sys/conf.h> 381096SN/A#include <sys/tty.h> 395012SN/A#include <sys/kernel.h> 401096SN/A 411096SN/A#include <machine/apm_bios.h> 421096SN/A#include <machine/console.h> 431096SN/A#include <machine/pc/vesa.h> 441096SN/A 455012SN/A#include <i386/isa/videoio.h> 461096SN/A#include <i386/isa/syscons.h> 471096SN/A 481096SN/Astatic d_ioctl_t *prev_user_ioctl; 495012SN/A 501096SN/Astatic int 511096SN/Avesa_ioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) 521096SN/A{ 531096SN/A scr_stat *scp; 54 struct tty *tp; 55 video_info_t info; 56 video_adapter_t *adp; 57 int mode; 58 int error; 59 int s; 60 61 tp = scdevtotty(dev); 62 if (!tp) 63 return ENXIO; 64 scp = sc_get_scr_stat(tp->t_dev); 65 66 switch (cmd) { 67 case SW_VESA_USER: 68 69 mode = (int)data; 70 if ((*biosvidsw.get_info)(scp->adp, mode, &info)) 71 return ENODEV; 72 if (info.vi_flags & V_INFO_GRAPHICS) 73 goto vesa_graphics; 74 else 75 goto vesa_text; 76 77 /* generic text modes */ 78 case SW_TEXT_132x25: case SW_TEXT_132x30: 79 case SW_TEXT_132x43: case SW_TEXT_132x50: 80 case SW_TEXT_132x60: 81 adp = get_adapter(scp); 82 if (!(adp->va_flags & V_ADP_MODECHANGE)) 83 return ENODEV; 84 return sc_set_text_mode(scp, tp, cmd & 0xff, 0, 0, 0); 85 86 /* text modes */ 87 case SW_VESA_C80x60: 88 case SW_VESA_C132x25: 89 case SW_VESA_C132x43: 90 case SW_VESA_C132x50: 91 case SW_VESA_C132x60: 92 adp = get_adapter(scp); 93 if (!(adp->va_flags & V_ADP_MODECHANGE)) 94 return ENODEV; 95 mode = (cmd & 0xff) + M_VESA_BASE; 96vesa_text: 97 return sc_set_text_mode(scp, tp, mode, 0, 0, 0); 98 99 /* graphics modes */ 100 case SW_VESA_32K_320: case SW_VESA_64K_320: 101 case SW_VESA_FULL_320: 102 103 case SW_VESA_CG640x400: 104 105 case SW_VESA_CG640x480: 106 case SW_VESA_32K_640: case SW_VESA_64K_640: 107 case SW_VESA_FULL_640: 108 109 case SW_VESA_800x600: case SW_VESA_CG800x600: 110 case SW_VESA_32K_800: case SW_VESA_64K_800: 111 case SW_VESA_FULL_800: 112 113 case SW_VESA_1024x768: case SW_VESA_CG1024x768: 114 case SW_VESA_32K_1024: case SW_VESA_64K_1024: 115 case SW_VESA_FULL_1024: 116 117 case SW_VESA_1280x1024: case SW_VESA_CG1280x1024: 118 case SW_VESA_32K_1280: case SW_VESA_64K_1280: 119 case SW_VESA_FULL_1280: 120 adp = get_adapter(scp); 121 if (!(adp->va_flags & V_ADP_MODECHANGE)) 122 return ENODEV; 123 mode = (cmd & 0xff) + M_VESA_BASE; 124vesa_graphics: 125 return sc_set_graphics_mode(scp, tp, mode); 126 } 127 128 if (prev_user_ioctl) 129 return (*prev_user_ioctl)(dev, cmd, data, flag, p); 130 else 131 return ENOIOCTL; 132} 133 134int 135vesa_load_ioctl(void) 136{ 137 if (prev_user_ioctl) 138 return EBUSY; 139 prev_user_ioctl = sc_user_ioctl; 140 sc_user_ioctl = vesa_ioctl; 141 return 0; 142} 143 144int 145vesa_unload_ioctl(void) 146{ 147 if (sc_user_ioctl != vesa_ioctl) 148 return EBUSY; 149 sc_user_ioctl = prev_user_ioctl; 150 prev_user_ioctl = NULL; 151 return 0; 152} 153 154#endif /* (NSC > 0 && VESA && VM86) || VESA_MODULE */ 155