1 /* $OpenBSD: wsdisplayvar.h,v 1.29 2013/11/04 05:45:04 miod Exp $ */ 2 /* $NetBSD: wsdisplayvar.h,v 1.30 2005/02/04 02:10:49 perry Exp $ */ 3 4 /* 5 * Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 3. All advertising materials mentioning features or use of this software 16 * must display the following acknowledgement: 17 * This product includes software developed by Christopher G. Demetriou 18 * for the NetBSD Project. 19 * 4. The name of the author may not be used to endorse or promote products 20 * derived from this software without specific prior written permission 21 * 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. 32 */ 33 34 /* 35 * Default to white on black except on Sun hardware, where we default 36 * to black on white to match the firmware console. 37 */ 38 #ifndef WS_DEFAULT_FG 39 #if defined(__sparc__) || defined(__sparc64__) 40 #define WS_DEFAULT_FG WSCOL_BLACK 41 #else 42 #define WS_DEFAULT_FG WSCOL_WHITE 43 #endif 44 #endif 45 #ifndef WS_DEFAULT_BG 46 #if defined(__sparc__) || defined(__sparc64__) 47 #define WS_DEFAULT_BG WSCOL_WHITE 48 #else 49 #define WS_DEFAULT_BG WSCOL_BLACK 50 #endif 51 #endif 52 53 struct device; 54 55 /* 56 * WSDISPLAY interfaces 57 */ 58 59 #define WSDISPLAY_MAXSCREEN 12 60 61 /* 62 * Emulation functions, for displays that can support glass-tty terminal 63 * emulations. These are character oriented, with row and column 64 * numbers starting at zero in the upper left hand corner of the 65 * screen. 66 * 67 * These are used only when emulating a terminal. Therefore, displays 68 * drivers which cannot emulate terminals do not have to provide them. 69 * 70 * There is a "void *" cookie provided by the display driver associated 71 * with these functions, which is passed to them when they are invoked. 72 */ 73 struct wsdisplay_emulops { 74 int (*cursor)(void *c, int on, int row, int col); 75 int (*mapchar)(void *, int, unsigned int *); 76 int (*putchar)(void *c, int row, int col, u_int uc, long attr); 77 int (*copycols)(void *c, int row, int srccol, int dstcol, 78 int ncols); 79 int (*erasecols)(void *c, int row, int startcol, int ncols, long); 80 int (*copyrows)(void *c, int srcrow, int dstrow, int nrows); 81 int (*eraserows)(void *c, int row, int nrows, long attr); 82 int (*alloc_attr)(void *c, int fg, int bg, int flags, long *attrp); 83 void (*unpack_attr)(void *c, long attr, int *fg, int *bg, int *ul); 84 /* fg / bg values. Made identical to ANSI terminal color codes. */ 85 #define WSCOL_BLACK 0 86 #define WSCOL_RED 1 87 #define WSCOL_GREEN 2 88 #define WSCOL_BROWN 3 89 #define WSCOL_BLUE 4 90 #define WSCOL_MAGENTA 5 91 #define WSCOL_CYAN 6 92 #define WSCOL_WHITE 7 93 /* flag values: */ 94 #define WSATTR_REVERSE 1 95 #define WSATTR_HILIT 2 96 #define WSATTR_BLINK 4 97 #define WSATTR_UNDERLINE 8 98 #define WSATTR_WSCOLORS 16 99 /* XXX need a free_attr() ??? */ 100 }; 101 102 #define WSSCREEN_NAME_SIZE 16 103 104 struct wsscreen_descr { 105 char name[WSSCREEN_NAME_SIZE]; 106 int ncols, nrows; 107 const struct wsdisplay_emulops *textops; 108 int fontwidth, fontheight; 109 int capabilities; 110 #define WSSCREEN_WSCOLORS 1 /* minimal color capability */ 111 #define WSSCREEN_REVERSE 2 /* can display reversed */ 112 #define WSSCREEN_HILIT 4 /* can highlight (however) */ 113 #define WSSCREEN_BLINK 8 /* can blink */ 114 #define WSSCREEN_UNDERLINE 16 /* can underline */ 115 }; 116 117 /* 118 * Character cell description (for emulation mode). 119 */ 120 struct wsdisplay_charcell { 121 u_int uc; 122 long attr; 123 }; 124 125 struct wsdisplay_font; 126 /* 127 * Display access functions, invoked by user-land programs which require 128 * direct device access, such as X11. 129 * 130 * There is a "void *" cookie provided by the display driver associated 131 * with these functions, which is passed to them when they are invoked. 132 */ 133 struct wsdisplay_accessops { 134 int (*ioctl)(void *v, u_long cmd, caddr_t data, int flag, 135 struct proc *p); 136 paddr_t (*mmap)(void *v, off_t off, int prot); 137 int (*alloc_screen)(void *, const struct wsscreen_descr *, 138 void **, int *, int *, long *); 139 void (*free_screen)(void *, void *); 140 int (*show_screen)(void *, void *, int, 141 void (*) (void *, int, int), void *); 142 int (*load_font)(void *, void *, struct wsdisplay_font *); 143 int (*list_font)(void *, struct wsdisplay_font *); 144 void (*scrollback)(void *, void *, int); 145 int (*getchar)(void *, int, int, struct wsdisplay_charcell *); 146 void (*burn_screen)(void *, u_int, u_int); 147 void (*pollc)(void *, int); 148 }; 149 150 /* passed to wscons by the video driver to tell about its capabilities */ 151 struct wsscreen_list { 152 int nscreens; 153 const struct wsscreen_descr **screens; 154 }; 155 156 /* 157 * Attachment information provided by wsemuldisplaydev devices when attaching 158 * wsdisplay units. 159 */ 160 struct wsemuldisplaydev_attach_args { 161 int console; /* is it console? */ 162 const struct wsscreen_list *scrdata; /* screen cfg info */ 163 const struct wsdisplay_accessops *accessops; /* access ops */ 164 void *accesscookie; /* access cookie */ 165 u_int defaultscreens; /* screens to create */ 166 }; 167 168 #define WSEMULDISPLAYDEVCF_CONSOLE 0 169 #define wsemuldisplaydevcf_console cf_loc[WSEMULDISPLAYDEVCF_CONSOLE] /* spec'd as console? */ 170 #define WSEMULDISPLAYDEVCF_CONSOLE_UNK -1 171 #define WSDISPLAYDEVCF_MUX 0 172 #define wsdisplaydevcf_mux cf_loc[WSDISPLAYDEVCF_MUX] 173 #define WSEMULDISPLAYDEVCF_MUX 1 174 #define wsemuldisplaydevcf_mux cf_loc[WSEMULDISPLAYDEVCF_MUX] 175 176 struct wscons_syncops { 177 int (*detach)(void *, int, void (*)(void *, int, int), void *); 178 int (*attach)(void *, int, void (*)(void *, int, int), void *); 179 int (*check)(void *); 180 void (*destroy)(void *); 181 }; 182 183 /* 184 * Autoconfiguration helper functions. 185 */ 186 void wsdisplay_cnattach(const struct wsscreen_descr *, void *, 187 int, int, long); 188 int wsemuldisplaydevprint(void *, const char *); 189 int wsemuldisplaydevsubmatch(struct device *, void *, void *); 190 191 /* 192 * Console interface. 193 */ 194 void wsdisplay_cnputc(dev_t dev, int i); 195 196 /* 197 * for use by compatibility code 198 */ 199 struct wsdisplay_softc; 200 struct wsscreen; 201 int wsscreen_attach_sync(struct wsscreen *, 202 const struct wscons_syncops *, void *); 203 int wsscreen_detach_sync(struct wsscreen *); 204 int wsscreen_lookup_sync(struct wsscreen *, 205 const struct wscons_syncops *, void **); 206 207 int wsdisplay_maxscreenidx(struct wsdisplay_softc *); 208 int wsdisplay_screenstate(struct wsdisplay_softc *, int); 209 int wsdisplay_getactivescreen(struct wsdisplay_softc *); 210 int wsscreen_switchwait(struct wsdisplay_softc *, int); 211 212 int wsdisplay_internal_ioctl(struct wsdisplay_softc *sc, 213 struct wsscreen *, 214 u_long cmd, caddr_t data, 215 int flag, struct proc *p); 216 217 int wsdisplay_usl_ioctl1(struct wsdisplay_softc *, 218 u_long, caddr_t, int, struct proc *); 219 220 int wsdisplay_usl_ioctl2(struct wsdisplay_softc *, struct wsscreen *, 221 u_long, caddr_t, int, struct proc *); 222 223 int wsdisplay_cfg_ioctl(struct wsdisplay_softc *sc, 224 u_long cmd, caddr_t data, 225 int flag, struct proc *p); 226 227 /* 228 * for general use 229 */ 230 #define WSDISPLAY_NULLSCREEN -1 231 void wsdisplay_switchtoconsole(void); 232 void wsdisplay_suspend(void); 233 void wsdisplay_resume(void); 234 const struct wsscreen_descr * 235 wsdisplay_screentype_pick(const struct wsscreen_list *, const char *); 236 237 /* 238 * for use by wskbd 239 */ 240 void wsdisplay_burn(void *v, u_int flags); 241 void wsscrollback(void *v, int op); 242 243 #define WSDISPLAY_SCROLL_BACKWARD 0 244 #define WSDISPLAY_SCROLL_FORWARD 1 245 #define WSDISPLAY_SCROLL_RESET 2 246 247 /* 248 * screen burner 249 */ 250 #define WSDISPLAY_DEFBURNOUT 0 /* disabled */ 251 #define WSDISPLAY_DEFBURNIN 250 /* ms */ 252 253