wsdisplayvar.h revision 1.33
1/* $OpenBSD: wsdisplayvar.h,v 1.33 2019/07/01 19:38:40 kn 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(__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(__sparc64__)
47#define WS_DEFAULT_BG WSCOL_WHITE
48#else
49#define WS_DEFAULT_BG WSCOL_BLACK
50#endif
51#endif
52
53struct 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 */
73struct 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
104struct 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 */
120struct wsdisplay_charcell {
121	u_int	uc;
122	long	attr;
123};
124
125struct 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 */
133struct 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	void	(*enter_ddb)(void *, void *);
149};
150
151/* passed to wscons by the video driver to tell about its capabilities */
152struct wsscreen_list {
153	int nscreens;
154	const struct wsscreen_descr **screens;
155};
156
157/*
158 * Attachment information provided by wsemuldisplaydev devices when attaching
159 * wsdisplay units.
160 */
161struct wsemuldisplaydev_attach_args {
162	int	console;				/* is it console? */
163	int	primary;				/* is it primry? */
164	const struct wsscreen_list *scrdata;		/* screen cfg info */
165	const struct wsdisplay_accessops *accessops;	/* access ops */
166	void	*accesscookie;				/* access cookie */
167	u_int	defaultscreens;				/* screens to create */
168};
169
170#define	WSEMULDISPLAYDEVCF_CONSOLE	0
171#define	wsemuldisplaydevcf_console	cf_loc[WSEMULDISPLAYDEVCF_CONSOLE]	/* spec'd as console? */
172#define	WSEMULDISPLAYDEVCF_CONSOLE_UNK	-1
173#define WSEMULDISPLAYDEVCF_PRIMARY	1
174#define	wsemuldisplaydevcf_primary	cf_loc[WSEMULDISPLAYDEVCF_PRIMARY]	/* spec'd as primary? */
175#define	WSEMULDISPLAYDEVCF_PRIMARY_UNK	-1
176#define	WSEMULDISPLAYDEVCF_MUX		2
177#define	wsemuldisplaydevcf_mux		cf_loc[WSEMULDISPLAYDEVCF_MUX]
178#define	WSDISPLAYDEVCF_MUX		0
179#define	wsdisplaydevcf_mux		cf_loc[WSDISPLAYDEVCF_MUX]
180
181struct wscons_syncops {
182	int (*detach)(void *, int, void (*)(void *, int, int), void *);
183	int (*attach)(void *, int, void (*)(void *, int, int), void *);
184	int (*check)(void *);
185	void (*destroy)(void *);
186};
187
188/*
189 * Autoconfiguration helper functions.
190 */
191void	wsdisplay_cnattach(const struct wsscreen_descr *, void *,
192				int, int, long);
193int	wsemuldisplaydevprint(void *, const char *);
194int	wsemuldisplaydevsubmatch(struct device *, void *, void *);
195
196/*
197 * Console interface.
198 */
199void	wsdisplay_cnputc(dev_t dev, int i);
200
201/*
202 * for use by compatibility code
203 */
204struct wsdisplay_softc;
205struct wsscreen;
206int wsscreen_attach_sync(struct wsscreen *,
207			      const struct wscons_syncops *, void *);
208int wsscreen_detach_sync(struct wsscreen *);
209int wsscreen_lookup_sync(struct wsscreen *,
210			      const struct wscons_syncops *, void **);
211
212int wsdisplay_maxscreenidx(struct wsdisplay_softc *);
213int wsdisplay_screenstate(struct wsdisplay_softc *, int);
214int wsdisplay_getactivescreen(struct wsdisplay_softc *);
215int wsscreen_switchwait(struct wsdisplay_softc *, int);
216
217int wsdisplay_internal_ioctl(struct wsdisplay_softc *sc,
218				  struct wsscreen *,
219				  u_long cmd, caddr_t data,
220				  int flag, struct proc *p);
221
222int wsdisplay_usl_ioctl1(struct wsdisplay_softc *,
223			     u_long, caddr_t, int, struct proc *);
224
225int wsdisplay_usl_ioctl2(struct wsdisplay_softc *, struct wsscreen *,
226			     u_long, caddr_t, int, struct proc *);
227
228int wsdisplay_cfg_ioctl(struct wsdisplay_softc *sc,
229			     u_long cmd, caddr_t data,
230			     int flag, struct proc *p);
231
232/*
233 * for general use
234 */
235#define WSDISPLAY_NULLSCREEN	-1
236void wsdisplay_switchtoconsole(void);
237void wsdisplay_enter_ddb(void);
238void wsdisplay_suspend(void);
239void wsdisplay_resume(void);
240const struct wsscreen_descr *
241    wsdisplay_screentype_pick(const struct wsscreen_list *, const char *);
242
243/*
244 * for use by wskbd
245 */
246void wsdisplay_burn(void *v, u_int flags);
247void wsscrollback(void *v, int op);
248
249#define WSDISPLAY_SCROLL_BACKWARD	0
250#define WSDISPLAY_SCROLL_FORWARD	1
251#define WSDISPLAY_SCROLL_RESET		2
252
253/*
254 * screen burner
255 */
256#define	WSDISPLAY_DEFBURNOUT_MSEC	0	/* disabled */
257#define	WSDISPLAY_DEFBURNIN_MSEC	250	/* milliseconds */
258