summaryrefslogtreecommitdiff
path: root/sys/dev/wscons/wsdisplayvar.h
blob: 3329671e6a8df99e505b7a69f3901d07f5dbed5f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
/* $NetBSD: wsdisplayvar.h,v 1.57 2023/03/01 08:42:33 riastradh Exp $ */

/*
 * Copyright (c) 1996, 1997 Christopher G. Demetriou.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *      This product includes software developed by Christopher G. Demetriou
 *	for the NetBSD Project.
 * 4. The name of the author may not be used to endorse or promote products
 *    derived from this software without specific prior written permission
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#ifndef _DEV_WSCONS_WSDISPLAYVAR_H
#define _DEV_WSCONS_WSDISPLAYVAR_H

#include <sys/device.h>

/*
 * WSDISPLAY interfaces
 */

/*
 * Emulation functions, for displays that can support glass-tty terminal
 * emulations.  These are character oriented, with row and column
 * numbers starting at zero in the upper left hand corner of the
 * screen.
 *
 * These are used only when emulating a terminal.  Therefore, displays
 * drivers which cannot emulate terminals do not have to provide them.
 *
 * There is a "void *" cookie provided by the display driver associated
 * with these functions, which is passed to them when they are invoked.
 */
struct wsdisplay_emulops {
	void	(*cursor)(void *, int, int, int);
	int	(*mapchar)(void *, int, unsigned int *);
	void	(*putchar)(void *, int, int, u_int, long);
	void	(*copycols)(void *, int, int, int, int);
	void	(*erasecols)(void *, int, int, int, long);
	void	(*copyrows)(void *, int, int, int);
	void	(*eraserows)(void *, int, int, long);
	int	(*allocattr)(void *, int, int, int, long *);
/* fg / bg values. Made identical to ANSI terminal color codes. */
#define WSCOL_BLACK	0
#define WSCOL_RED	1
#define WSCOL_GREEN	2
#define WSCOL_BROWN	3
#define WSCOL_BLUE	4
#define WSCOL_MAGENTA	5
#define WSCOL_CYAN	6
#define WSCOL_WHITE	7
#define WSCOL_LIGHT_GREY	(WSCOL_BLACK+8)
#define WSCOL_LIGHT_RED		(WSCOL_RED+8)
#define WSCOL_LIGHT_GREEN	(WSCOL_GREEN+8)
#define WSCOL_LIGHT_BROWN	(WSCOL_BROWN+8)
#define WSCOL_LIGHT_BLUE	(WSCOL_BLUE+8)
#define WSCOL_LIGHT_MAGENTA	(WSCOL_MAGENTA+8)
#define WSCOL_LIGHT_CYAN	(WSCOL_CYAN+8)
#define WSCOL_LIGHT_WHITE	(WSCOL_WHITE+8)
/* flag values: */
#define WSATTR_REVERSE	1
#define WSATTR_HILIT	2
#define WSATTR_BLINK	4
#define WSATTR_UNDERLINE 8
#define WSATTR_WSCOLORS 16
#define WSATTR_USERMASK 0x0fff
/* private flags used by the driver */
#define WSATTR_PRIVATE1  4096
#define WSATTR_PRIVATE2  8192
#define WSATTR_PRIVATE3 16384
#define WSATTR_PRIVATE4 32768
	/* XXX need a free_attr() ??? */
	void	(*replaceattr)(void *, long, long);
};

struct wsscreen_descr {
	const char *name;
	int ncols, nrows;
	const struct wsdisplay_emulops *textops;
	int fontwidth, fontheight;
	int capabilities;
#define WSSCREEN_WSCOLORS	1	/* minimal color capability */
#define WSSCREEN_REVERSE	2	/* can display reversed */
#define WSSCREEN_HILIT		4	/* can highlight (however) */
#define WSSCREEN_BLINK		8	/* can blink */
#define WSSCREEN_UNDERLINE	16	/* can underline */
#define WSSCREEN_RESIZE		32	/* can resize */
#define WSSCREEN_FREE		64	/* free() this struct when deleting
					 * internal only, do not set */
	void *modecookie;
};

struct wsdisplay_font;
struct wsdisplay_char;
/*
 * Display access functions, invoked by user-land programs which require
 * direct device access, such as X11.
 *
 * There is a "void *" cookie provided by the display driver associated
 * with these functions, which is passed to them when they are invoked.
 */
struct wsdisplay_accessops {
	int	(*ioctl)(void *, void *, u_long, void *, int, struct lwp *);
	paddr_t	(*mmap)(void *, void *, off_t, int);
	int	(*alloc_screen)(void *, const struct wsscreen_descr *,
				void **, int *, int *, long *);
	void	(*free_screen)(void *, void *);
	int	(*show_screen)(void *, void *, int,
			       void (*)(void *, int, int), void *);
	int	(*load_font)(void *, void *, struct wsdisplay_font *);
	void	(*pollc)(void *, int);
	void	(*scroll)(void *, void *, int);
};

/*
 * Attachment information provided by wsdisplaydev devices when attaching
 * wsdisplay units.
 */
struct wsdisplaydev_attach_args {
	const struct wsdisplay_accessops *accessops;	/* access ops */
	void	*accesscookie;				/* access cookie */
};

/* passed to wscons by the video driver to tell about its capabilities */
struct wsscreen_list {
	int nscreens;
	const struct wsscreen_descr **screens;
};

/*
 * Attachment information provided by wsemuldisplaydev devices when attaching
 * wsdisplay units.
 */
struct wsemuldisplaydev_attach_args {
	int	console;				/* is it console? */
	const struct wsscreen_list *scrdata;		/* screen cfg info */
	const struct wsdisplay_accessops *accessops;	/* access ops */
	void	*accesscookie;				/* access cookie */
};

struct wscons_syncops {
	int (*detach)(void *, int, void (*)(void *, int, int), void *);
	int (*attach)(void *, int, void (*)(void *, int, int), void *);
	int (*check)(void *);
	void (*destroy)(void *);
};

/*
 * Autoconfiguration helper functions.
 */
void	wsdisplay_cnattach(const struct wsscreen_descr *, void *, int, int,
            long);
void	wsdisplay_preattach(const struct wsscreen_descr *, void *, int, int,
            long);
void	wsdisplay_predetach(void);
void	wsdisplay_cndetach(void);
void	wsdisplay_multicons_suspend(bool);

int	wsdisplaydevprint(void *, const char *);
int	wsemuldisplaydevprint(void *, const char *);

int	wsdisplay_handlex(int);

/*
 * Console interface.
 */
void	wsdisplay_cnputc(dev_t, int);

/*
 * for use by compatibility code
 */
struct wsdisplay_softc;
struct wsscreen;
int wsscreen_attach_sync(struct wsscreen *,
			 const struct wscons_syncops *, void *);
int wsscreen_detach_sync(struct wsscreen *);
int wsscreen_lookup_sync(struct wsscreen *,
			 const struct wscons_syncops *, void **);

int wsdisplay_maxscreenidx(struct wsdisplay_softc *);
int wsdisplay_screenstate(struct wsdisplay_softc *, int);
int wsdisplay_getactivescreen(struct wsdisplay_softc *);
int wsscreen_switchwait(struct wsdisplay_softc *, int);

int wsdisplay_internal_ioctl(struct wsdisplay_softc *, struct wsscreen *,
			     u_long, void *, int, struct lwp *);

int wsdisplay_usl_ioctl1(device_t, u_long, void *, int, struct lwp *);

int wsdisplay_usl_ioctl2(struct wsdisplay_softc *, struct wsscreen *,
			 u_long, void *, int, struct lwp *);

int wsdisplay_stat_ioctl(struct wsdisplay_softc *, u_long, void *,
			 int, struct lwp *);

int wsdisplay_cfg_ioctl(struct wsdisplay_softc *, u_long, void *,
			int, struct lwp *);

bool wsdisplay_isconsole(struct wsdisplay_softc *);

struct wsdisplayio_edid_info;
int wsdisplayio_get_edid(device_t, struct wsdisplayio_edid_info *);

struct wsdisplayio_fbinfo;
struct rasops_info;
int wsdisplayio_get_fbinfo(struct rasops_info *, struct wsdisplayio_fbinfo *);

#ifdef WSDISPLAY_SCROLLSUPPORT
void wsdisplay_scroll(void *, int);
#endif

#define WSDISPLAY_SCROLL_BACKWARD	1
#define WSDISPLAY_SCROLL_FORWARD	(1 << 1)
#define WSDISPLAY_SCROLL_RESET		(1 << 2)
#define WSDISPLAY_SCROLL_LOW		(1 << 3)

int wsdisplay_stat_inject(device_t, u_int, int);

/*
 * for general use
 */
#define WSDISPLAY_NULLSCREEN	-1
const struct wsscreen_descr *wsdisplay_screentype_pick(
    const struct wsscreen_list *, const char *);

#if defined(_KERNEL)
#  if defined(_KERNEL_OPT)
#    include "opt_wsmsgattrs.h"
#  endif
#  if !defined(WS_DEFAULT_FG)
#    define WS_DEFAULT_FG WSCOL_WHITE
#  endif
#  if !defined(WS_DEFAULT_BG)
#    define WS_DEFAULT_BG WSCOL_BLACK
#  endif
#  if !defined(WS_DEFAULT_COLATTR)
#    define WS_DEFAULT_COLATTR 0
#  endif
#  if !defined(WS_DEFAULT_MONOATTR)
#    define WS_DEFAULT_MONOATTR 0
#  endif
#  if defined(WS_KERNEL_FG) || defined(WS_KERNEL_BG) || \
      defined(WS_KERNEL_COLATTR) || defined(WS_KERNEL_MONOATTR)
#    define WS_KERNEL_CUSTOMIZED
#  else
#    undef WS_KERNEL_CUSTOMIZED
#  endif
#  if !defined(WS_KERNEL_FG)
#    define WS_KERNEL_FG WS_DEFAULT_FG
#  endif
#  if !defined(WS_KERNEL_BG)
#    define WS_KERNEL_BG WS_DEFAULT_BG
#  endif
#  if !defined(WS_KERNEL_COLATTR)
#    define WS_KERNEL_COLATTR WS_DEFAULT_COLATTR
#  endif
#  if !defined(WS_KERNEL_MONOATTR)
#    define WS_KERNEL_MONOATTR WS_DEFAULT_MONOATTR
#  endif
#  if !defined(WSDISPLAY_BORDER_COLOR)
#    define WSDISPLAY_BORDER_COLOR WS_DEFAULT_BG
#  endif
#endif /* _KERNEL */

#endif /* !_DEV_WSCONS_WSDISPLAYVAR_H */