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