xref: /netbsd/sys/dev/wscons/wsconsio.h (revision 1e2b573f)
1 /* $NetBSD: wsconsio.h,v 1.126 2021/09/28 06:14:27 nia Exp $ */
2 
3 /*
4  * Copyright (c) 1996, 1997 Christopher G. Demetriou.  All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  * 3. All advertising materials mentioning features or use of this software
15  *    must display the following acknowledgement:
16  *      This product includes software developed by Christopher G. Demetriou
17  *	for the NetBSD Project.
18  * 4. The name of the author may not be used to endorse or promote products
19  *    derived from this software without specific prior written permission
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 #ifndef _DEV_WSCONS_WSCONSIO_H_
34 #define	_DEV_WSCONS_WSCONSIO_H_
35 
36 /*
37  * WSCONS (wsdisplay, wskbd, wsmouse) exported interfaces.
38  *
39  * Ioctls are all in group 'W'.  Ioctl number space is partitioned like:
40  *	0-31	keyboard ioctls (WSKBDIO)
41  *	32-63	mouse ioctls (WSMOUSEIO)
42  *	64-95	display ioctls (WSDISPLAYIO)
43  *	96-127	mux ioctls (WSMUXIO)
44  *	128-255	reserved for future use
45  */
46 
47 #include <sys/types.h>
48 #include <sys/ioccom.h>
49 #include <sys/time.h>
50 #include <dev/wscons/wsksymvar.h>
51 
52 
53 /*
54  * Common event structure (used by keyboard and mouse)
55  */
56 struct wscons_event {
57 	u_int		type;
58 	int		value;
59 	struct timespec	time;
60 };
61 #define WSEVENT_VERSION	1
62 
63 /* Event type definitions.  Comment for each is information in value. */
64 #define	WSCONS_EVENT_KEY_UP		1	/* key code */
65 #define	WSCONS_EVENT_KEY_DOWN		2	/* key code */
66 #define	WSCONS_EVENT_ALL_KEYS_UP	3	/* void */
67 #define	WSCONS_EVENT_MOUSE_UP		4	/* button # (leftmost = 0) */
68 #define	WSCONS_EVENT_MOUSE_DOWN		5	/* button # (leftmost = 0)  */
69 #define	WSCONS_EVENT_MOUSE_DELTA_X	6	/* X delta amount */
70 #define	WSCONS_EVENT_MOUSE_DELTA_Y	7	/* Y delta amount */
71 #define	WSCONS_EVENT_MOUSE_ABSOLUTE_X	8	/* X location */
72 #define	WSCONS_EVENT_MOUSE_ABSOLUTE_Y	9	/* Y location */
73 #define	WSCONS_EVENT_MOUSE_DELTA_Z	10	/* Z delta amount */
74 #define	WSCONS_EVENT_MOUSE_ABSOLUTE_Z	11	/* Z location */
75 #define	WSCONS_EVENT_SCREEN_SWITCH	12	/* New screen number */
76 #define	WSCONS_EVENT_ASCII		13	/* key code is already ascii */
77 #define	WSCONS_EVENT_MOUSE_DELTA_W	14	/* W delta amount */
78 #define	WSCONS_EVENT_MOUSE_ABSOLUTE_W	15	/* W location */
79 #define	WSCONS_EVENT_HSCROLL		16	/* X axis precision scrolling */
80 #define	WSCONS_EVENT_VSCROLL		17	/* Y axis precision scrolling */
81 
82 /*
83  * Keyboard ioctls (0 - 31)
84  */
85 
86 /* Get keyboard type. */
87 #define	WSKBDIO_GTYPE		_IOR('W', 0, u_int)
88 #define	WSKBD_TYPE_LK201	1	/* lk-201 */
89 #define	WSKBD_TYPE_LK401	2	/* lk-401 */
90 #define	WSKBD_TYPE_PC_XT	3	/* PC-ish, XT scancode */
91 #define	WSKBD_TYPE_PC_AT	4	/* PC-ish, AT scancode, not used by modern kernels */
92 #define	WSKBD_TYPE_USB		5	/* USB, XT scancode */
93 #define	WSKBD_TYPE_NEXT		6	/* NeXT keyboard */
94 #define	WSKBD_TYPE_HPC_KBD	7	/* HPC bultin keyboard */
95 #define	WSKBD_TYPE_HPC_BTN	8	/* HPC/PsPC buttons */
96 #define	WSKBD_TYPE_ARCHIMEDES	9	/* Archimedes keyboard */
97 #define	WSKBD_TYPE_RISCPC	10	/* RiscPC keyboard, resembling AT codes */
98 #define	WSKBD_TYPE_ADB		11	/* ADB */
99 #define	WSKBD_TYPE_HIL		12	/* HIL keyboard */
100 #define	WSKBD_TYPE_AMIGA	13	/* Amiga keyboard */
101 #define	WSKBD_TYPE_MAPLE	14	/* Dreamcast Maple keyboard */
102 #define	WSKBD_TYPE_ATARI	15	/* Atari keyboard */
103 #define	WSKBD_TYPE_SUN		16	/* Sun Type3/4 */
104 #define	WSKBD_TYPE_SUN5		17	/* Sun Type5 */
105 #define	WSKBD_TYPE_SGI		18	/* SGI keyboard */
106 #define	WSKBD_TYPE_MATRIXKP	19	/* Matrix keypads/buttons */
107 #define	WSKBD_TYPE_EWS4800	20	/* NEC EWS4800 */
108 #define	WSKBD_TYPE_BLUETOOTH	21	/* Bluetooth keyboard */
109 #define	WSKBD_TYPE_ZAURUS	22	/* Sharp Zaurus keyboard */
110 #define	WSKBD_TYPE_LUNA		23	/* OMRON SX-9100 LUNA */
111 #define	WSKBD_TYPE_RFB		24	/* Usermode vnc remote keyboard */
112 #define	WSKBD_TYPE_EPOC		25	/* Psion EPOC machine keyboard */
113 #define	WSKBD_TYPE_HYPERV	26	/* Hyper-V synthetic keyboard */
114 
115 /* Manipulate the keyboard bell. */
116 struct wskbd_bell_data {
117 	u_int	which;				/* values to get/set */
118 #define	WSKBD_BELL_DOPITCH	0x1		/* get/set pitch */
119 #define	WSKBD_BELL_DOPERIOD	0x2		/* get/set period */
120 #define	WSKBD_BELL_DOVOLUME	0x4		/* get/set volume */
121 #define	WSKBD_BELL_DOALL	0x7		/* all of the above */
122 	u_int	pitch;				/* pitch, in Hz */
123 	u_int	period;				/* period, in milliseconds */
124 	u_int	volume;				/* percentage of max volume */
125 };
126 
127 #define	WSKBDIO_BELL		_IO('W', 1)
128 #define	WSKBDIO_COMPLEXBELL	_IOW('W', 2, struct wskbd_bell_data)
129 #define	WSKBDIO_SETBELL		_IOW('W', 3, struct wskbd_bell_data)
130 #define	WSKBDIO_GETBELL		_IOR('W', 4, struct wskbd_bell_data)
131 #define	WSKBDIO_SETDEFAULTBELL	_IOW('W', 5, struct wskbd_bell_data)
132 #define	WSKBDIO_GETDEFAULTBELL	_IOR('W', 6, struct wskbd_bell_data)
133 
134 /* Manipulate the emulation key repeat settings. */
135 struct wskbd_keyrepeat_data {
136 	u_int	which;				/* values to get/set */
137 #define	WSKBD_KEYREPEAT_DODEL1	0x1		/* get/set del1 */
138 #define	WSKBD_KEYREPEAT_DODELN	0x2		/* get/set delN */
139 #define	WSKBD_KEYREPEAT_DOALL	0x3		/* all of the above */
140 	u_int	del1;				/* delay before first, ms */
141 	u_int	delN;				/* delay before rest, ms */
142 };
143 
144 #define	WSKBDIO_SETKEYREPEAT	_IOW('W', 7, struct wskbd_keyrepeat_data)
145 #define	WSKBDIO_GETKEYREPEAT	_IOR('W', 8, struct wskbd_keyrepeat_data)
146 #define	WSKBDIO_SETDEFAULTKEYREPEAT _IOW('W', 9, struct wskbd_keyrepeat_data)
147 #define	WSKBDIO_GETDEFAULTKEYREPEAT _IOR('W', 10, struct wskbd_keyrepeat_data)
148 
149 /* Get/set keyboard leds */
150 #define	WSKBD_LED_CAPS		0x01
151 #define	WSKBD_LED_NUM		0x02
152 #define	WSKBD_LED_SCROLL	0x04
153 #define	WSKBD_LED_COMPOSE	0x08
154 
155 #define	WSKBDIO_SETLEDS		_IOW('W', 11, int)
156 #define	WSKBDIO_GETLEDS		_IOR('W', 12, int)
157 
158 /* Manipulate keysym groups. */
159 struct wskbd_map_data {
160 	u_int	maplen;				/* number of entries in map */
161 #define	WSKBDIO_MAXMAPLEN	65536
162 	struct wscons_keymap *map;		/* map to get or set */
163 };
164 #define	WSKBDIO_GETMAP		_IOWR('W', 13, struct wskbd_map_data)
165 #define	WSKBDIO_SETMAP		_IOW('W', 14, struct wskbd_map_data)
166 #define	WSKBDIO_GETENCODING	_IOR('W', 15, kbd_t)
167 #define	WSKBDIO_SETENCODING	_IOW('W', 16, kbd_t)
168 
169 /* internal use only */
170 #define	WSKBDIO_SETMODE		_IOW('W', 19, int)
171 #define	WSKBDIO_GETMODE		_IOR('W', 20, int)
172 #define	WSKBD_TRANSLATED	0
173 #define	WSKBD_RAW		1
174 
175 #define	WSKBDIO_SETKEYCLICK	_IOW('W', 21, int)
176 #define	WSKBDIO_GETKEYCLICK	_IOR('W', 22, int)
177 
178 /* Manipulate the scrolling modifiers and mode */
179 struct wskbd_scroll_data {
180 	u_int		which;
181 #define	WSKBD_SCROLL_DOMODIFIER		0x01
182 #define	WSKBD_SCROLL_DOMODE		0x02
183 #define	WSKBD_SCROLL_DOALL		0x03
184 	u_int		mode;
185 #define	WSKBD_SCROLL_MODE_NORMAL	0x00
186 #define	WSKBD_SCROLL_MODE_HOLD		0x01
187 	u_int		modifier;
188 };
189 
190 #define	WSKBDIO_GETSCROLL	_IOR('W', 23, struct wskbd_scroll_data)
191 #define	WSKBDIO_SETSCROLL	_IOW('W', 24, struct wskbd_scroll_data)
192 
193 /* Set event struct version */
194 #define WSKBDIO_SETVERSION	_IOW('W', 25, int)
195 #define WSKBDIO_EVENT_VERSION	WSEVENT_VERSION
196 
197 /*
198  * Mouse ioctls (32 - 63)
199  */
200 
201 /* Get mouse type */
202 #define	WSMOUSEIO_GTYPE		_IOR('W', 32, u_int)
203 #define	WSMOUSE_TYPE_VSXXX	1	/* DEC serial */
204 #define	WSMOUSE_TYPE_PS2	2	/* PS/2-compatible */
205 #define	WSMOUSE_TYPE_USB	3	/* USB mouse */
206 #define	WSMOUSE_TYPE_LMS	4	/* Logitech busmouse */
207 #define	WSMOUSE_TYPE_MMS	5	/* Microsoft InPort mouse */
208 #define	WSMOUSE_TYPE_TPANEL	6	/* Generic Touch Panel */
209 #define	WSMOUSE_TYPE_NEXT	7	/* NeXT mouse */
210 #define	WSMOUSE_TYPE_ARCHIMEDES	8	/* Archimedes mouse */
211 #define	WSMOUSE_TYPE_HIL	9	/* HIL mouse */
212 #define	WSMOUSE_TYPE_AMIGA	10	/* Amiga mouse */
213 #define	WSMOUSE_TYPE_MAXINE	11	/* DEC maxine mouse */
214 #define	WSMOUSE_TYPE_MAPLE	12	/* Dreamcast Maple mouse */
215 #define	WSMOUSE_TYPE_SGI	13	/* SGI mouse */
216 #define	WSMOUSE_TYPE_BLUETOOTH	14	/* Bluetooth mouse */
217 #define WSMOUSE_TYPE_ADB	15	/* ADB mouse or touchpad */
218 #define WSMOUSE_TYPE_PSEUDO	16	/* not actually a mouse */
219 
220 /* Set resolution.  Not applicable to all mouse types. */
221 #define	WSMOUSEIO_SRES		_IOW('W', 33, u_int)
222 #define	WSMOUSE_RES_MIN		0
223 #define	WSMOUSE_RES_DEFAULT	75
224 #define	WSMOUSE_RES_MAX		100
225 
226 /* Set scale factor (num / den).  Not applicable to all mouse types. */
227 #define	WSMOUSEIO_SSCALE	_IOW('W', 34, u_int[2])
228 
229 /* Set sample rate.  Not applicable to all mouse types. */
230 #define	WSMOUSEIO_SRATE		_IOW('W', 35, u_int)
231 #define	WSMOUSE_RATE_MIN	0
232 #define	WSMOUSE_RATE_DEFAULT	50
233 #define	WSMOUSE_RATE_MAX	100
234 
235 /* Set/get sample coordinates for calibration */
236 #define	WSMOUSE_CALIBCOORDS_MAX		16
237 #define	WSMOUSE_CALIBCOORDS_RESET	-1
238 struct wsmouse_calibcoords {
239 	int minx, miny;		/* minimum value of X/Y */
240 	int maxx, maxy;		/* maximum value of X/Y */
241 	int samplelen;		/* number of samples available or
242 				   WSMOUSE_CALIBCOORDS_RESET for raw mode */
243 	struct wsmouse_calibcoord {
244 		int rawx, rawy;	/* raw coordinate */
245 		int x, y;	/* translated coordinate */
246 	} samples[WSMOUSE_CALIBCOORDS_MAX];	/* sample coordinates */
247 };
248 #define	WSMOUSEIO_SCALIBCOORDS	_IOW('W', 36, struct wsmouse_calibcoords)
249 #define	WSMOUSEIO_GCALIBCOORDS	_IOR('W', 37, struct wsmouse_calibcoords)
250 
251 /* get device id for calibration */
252 struct wsmouse_id {
253 	u_int type;
254 #define	WSMOUSE_ID_TYPE_UIDSTR	0	/* ID string (null terminated) */
255 	u_int length;
256 #define	WSMOUSE_ID_MAXLEN	256
257 	u_char data[WSMOUSE_ID_MAXLEN];
258 };
259 #define	WSMOUSEIO_GETID		_IOWR('W', 38, struct wsmouse_id)
260 
261 /* Get/set button repeating. */
262 struct wsmouse_repeat {
263 	unsigned long	wr_buttons;
264 	unsigned int	wr_delay_first;
265 	unsigned int	wr_delay_decrement;
266 	unsigned int	wr_delay_minimum;
267 };
268 #define WSMOUSEIO_GETREPEAT	_IOR('W', 39, struct wsmouse_repeat)
269 #define WSMOUSEIO_SETREPEAT	_IOW('W', 40, struct wsmouse_repeat)
270 
271 #define WSMOUSEIO_SETVERSION	_IOW('W', 41, int)
272 #define WSMOUSE_EVENT_VERSION	WSEVENT_VERSION
273 
274 enum wsmousecfg {
275 	WSMOUSECFG_REVERSE_SCROLLING = 0,
276 	/* Touchpad parameters */
277 	WSMOUSECFG_HORIZSCROLLDIST,
278 	WSMOUSECFG_VERTSCROLLDIST
279 };
280 
281 struct wsmouse_param {
282 	enum wsmousecfg key;
283 	int value;
284 };
285 
286 struct wsmouse_parameters {
287 	struct wsmouse_param *params;
288 	unsigned int nparams;
289 };
290 
291 #define WSMOUSECFG_MAX		(128) /* maximum number of wsmouse_params */
292 
293 #define WSMOUSEIO_GETPARAMS	_IOW('W', 42, struct wsmouse_parameters)
294 #define WSMOUSEIO_SETPARAMS	_IOW('W', 43, struct wsmouse_parameters)
295 
296 /*
297  * Display ioctls (64 - 95)
298  */
299 
300 /* Get display type */
301 #define	WSDISPLAYIO_GTYPE	_IOR('W', 64, u_int)
302 #define	WSDISPLAY_TYPE_UNKNOWN	0	/* unknown */
303 #define	WSDISPLAY_TYPE_PM_MONO	1	/* DEC [23]100 mono */
304 #define	WSDISPLAY_TYPE_PM_COLOR	2	/* DEC [23]100 color */
305 #define	WSDISPLAY_TYPE_CFB	3	/* DEC TC CFB (CX) */
306 #define	WSDISPLAY_TYPE_XCFB	4	/* DEC `maxine' onboard fb */
307 #define	WSDISPLAY_TYPE_MFB	5	/* DEC TC MFB (MX) */
308 #define	WSDISPLAY_TYPE_SFB	6	/* DEC TC SFB (HX) */
309 #define	WSDISPLAY_TYPE_ISAVGA	7	/* (generic) ISA VGA */
310 #define	WSDISPLAY_TYPE_PCIVGA	8	/* (generic) PCI VGA */
311 #define	WSDISPLAY_TYPE_TGA	9	/* DEC PCI TGA */
312 #define	WSDISPLAY_TYPE_SFBP	10	/* DEC TC SFB+ (HX+) */
313 #define	WSDISPLAY_TYPE_PCIMISC	11	/* (generic) PCI misc. disp. */
314 #define	WSDISPLAY_TYPE_NEXTMONO	12	/* NeXT mono display */
315 #define	WSDISPLAY_TYPE_PX	13	/* DEC TC PX */
316 #define	WSDISPLAY_TYPE_PXG	14	/* DEC TC PXG */
317 #define	WSDISPLAY_TYPE_TX	15	/* DEC TC TX */
318 #define	WSDISPLAY_TYPE_HPCFB	16	/* Handheld/PalmSize PC */
319 #define	WSDISPLAY_TYPE_VIDC	17	/* Acorn/ARM VIDC */
320 #define	WSDISPLAY_TYPE_SPX	18	/* DEC SPX (VS3100/VS4000) */
321 #define	WSDISPLAY_TYPE_GPX	19	/* DEC GPX (uVAX/VS2K/VS3100 */
322 #define	WSDISPLAY_TYPE_LCG	20	/* DEC LCG (VS4000) */
323 #define	WSDISPLAY_TYPE_VAX_MONO	21	/* DEC VS2K/VS3100 mono */
324 #define	WSDISPLAY_TYPE_SB_P9100	22	/* Tadpole SPARCbook P9100 */
325 #define	WSDISPLAY_TYPE_EGA	23	/* (generic) EGA */
326 #define	WSDISPLAY_TYPE_DCPVR	24	/* Dreamcast PowerVR */
327 #define	WSDISPLAY_TYPE_GBOX	25	/* HP Gator */
328 #define	WSDISPLAY_TYPE_TOPCAT	26	/* HP TopCat */
329 #define	WSDISPLAY_TYPE_RBOX	27	/* HP Renaissance */
330 #define	WSDISPLAY_TYPE_CATSEYE	28	/* HP CatsEye */
331 #define	WSDISPLAY_TYPE_DVBOX	29	/* HP DaVinci */
332 #define	WSDISPLAY_TYPE_TVRX	30	/* HP TigerShark */
333 #define	WSDISPLAY_TYPE_HYPERION	31	/* HP Hyperion */
334 #define	WSDISPLAY_TYPE_AMIGACC	32	/* Amiga custom chips */
335 #define	WSDISPLAY_TYPE_SUN24	33	/* Sun 24 bit framebuffers */
336 #define	WSDISPLAY_TYPE_NEWPORT	34	/* SGI Newport */
337 #define	WSDISPLAY_TYPE_GR2	35	/* SGI GR2 */
338 #define	WSDISPLAY_TYPE_SUNCG12	36	/* Sun cgtwelve */
339 #define	WSDISPLAY_TYPE_SUNCG14	37	/* Sun cgfourteen */
340 #define	WSDISPLAY_TYPE_SUNTCX	38	/* Sun TCX */
341 #define	WSDISPLAY_TYPE_SUNFFB	39	/* Sun creator FFB */
342 #define	WSDISPLAY_TYPE_STI	40	/* HP STI framebuffers */
343 #define	WSDISPLAY_TYPE_HDLCD	41	/* Hitachi HD44780 based LCDs */
344 #define	WSDISPLAY_TYPE_VESA	42	/* VESA BIOS framebuffer */
345 #define	WSDISPLAY_TYPE_XILFB	43 	/* Xilinx TFT cores */
346 #define	WSDISPLAY_TYPE_LIGHT	44	/* SGI Light (a.k.a. Entry/Starter) */
347 #define	WSDISPLAY_TYPE_GENFB	45	/* generic nondescript framebuffer */
348 #define	WSDISPLAY_TYPE_CRIME	46	/* SGI O2 */
349 #define	WSDISPLAY_TYPE_PXALCD	47	/* PXA2x0 LCD controller */
350 #define	WSDISPLAY_TYPE_AG10	48	/* Fujitsu AG-10e */
351 #define	WSDISPLAY_TYPE_DL	49	/* DisplayLink DL-1x0/DL-1x5 */
352 #define	WSDISPLAY_TYPE_XVR1000	50	/* Sun XVR-1000 */
353 #define	WSDISPLAY_TYPE_LUNA	51	/* OMRON SX-9100 LUNA */
354 #define	WSDISPLAY_TYPE_GRF	52	/* wsdisplay on top of grf(4) */
355 #define	WSDISPLAY_TYPE_VNC	53	/* Usermode vnc framebuffer */
356 #define	WSDISPLAY_TYPE_VALKYRIE	54	/* Apple onboard video 'valkyrie' */
357 #define	WSDISPLAY_TYPE_IMXIPU	55	/* i.MX ipu */
358 #define	WSDISPLAY_TYPE_VC4	56	/* Broadcom VideoCore 4 */
359 #define	WSDISPLAY_TYPE_OMAP3	57	/* OMAP 3530 */
360 #define	WSDISPLAY_TYPE_WINDERMERE 58	/* SoC for EPOC32 Series 5mx */
361 #define	WSDISPLAY_TYPE_CLPS711X	59	/* CL PS-711x  */
362 #define	WSDISPLAY_TYPE_ALLWINNER 60	/* Allwinner ARM SoC */
363 #define	WSDISPLAY_TYPE_MGX	61	/* SSB 4096V-MGX */
364 #define	WSDISPLAY_TYPE_MESON	62	/* Amlogic Meson ARM SoC */
365 #define	WSDISPLAY_TYPE_TEGRA	63	/* NVIDIA Tegra ARM SoC */
366 #define	WSDISPLAY_TYPE_PLATINUM	64	/* onboard fb in PowerMac 7200 */
367 #define	WSDISPLAY_TYPE_PLFB	65	/* ARM PrimeCell PL11x */
368 #define	WSDISPLAY_TYPE_SSDFB	66	/* ssdfb(4) */
369 
370 /* Basic display information.  Not applicable to all display types. */
371 struct wsdisplay_fbinfo {
372 	u_int	height;				/* height in pixels */
373 	u_int	width;				/* width in pixels */
374 	u_int	depth;				/* bits per pixel */
375 	u_int	cmsize;				/* color map size (entries) */
376 };
377 #define	WSDISPLAYIO_GINFO	_IOR('W', 65, struct wsdisplay_fbinfo)
378 
379 /* Colormap operations.  Not applicable to all display types. */
380 struct wsdisplay_cmap {
381 	u_int	index;				/* first element (0 origin) */
382 	u_int	count;				/* number of elements */
383 	u_char	*red;				/* red color map elements */
384 	u_char	*green;				/* green color map elements */
385 	u_char	*blue;				/* blue color map elements */
386 };
387 #define	WSDISPLAYIO_GETCMAP	_IOW('W', 66, struct wsdisplay_cmap)
388 #define	WSDISPLAYIO_PUTCMAP	_IOW('W', 67, struct wsdisplay_cmap)
389 
390 /* Video control.  Not applicable to all display types. */
391 #define	WSDISPLAYIO_GVIDEO	_IOR('W', 68, u_int)
392 #define	WSDISPLAYIO_SVIDEO	_IOW('W', 69, u_int)
393 #define	WSDISPLAYIO_VIDEO_OFF	0	/* video off */
394 #define	WSDISPLAYIO_VIDEO_ON	1	/* video on */
395 
396 /* Cursor control.  Not applicable to all display types. */
397 struct wsdisplay_curpos {			/* cursor "position" */
398 	u_int x, y;
399 };
400 
401 struct wsdisplay_cursor {
402 	u_int	which;				/* values to get/set */
403 #define	WSDISPLAY_CURSOR_DOCUR		0x01	/* get/set enable */
404 #define	WSDISPLAY_CURSOR_DOPOS		0x02	/* get/set pos */
405 #define	WSDISPLAY_CURSOR_DOHOT		0x04	/* get/set hot spot */
406 #define	WSDISPLAY_CURSOR_DOCMAP		0x08	/* get/set cmap */
407 #define	WSDISPLAY_CURSOR_DOSHAPE	0x10	/* get/set img/mask */
408 #define	WSDISPLAY_CURSOR_DOALL		0x1f	/* all of the above */
409 	u_int	enable;				/* enable/disable */
410 	struct wsdisplay_curpos pos;		/* position */
411 	struct wsdisplay_curpos hot;		/* hot spot */
412 	struct wsdisplay_cmap cmap;		/* color map info */
413 	struct wsdisplay_curpos size;		/* bit map size */
414 	u_char *image;				/* image data */
415 	u_char *mask;				/* mask data */
416 };
417 
418 /* Cursor control: get and set position */
419 #define	WSDISPLAYIO_GCURPOS	_IOR('W', 70, struct wsdisplay_curpos)
420 #define	WSDISPLAYIO_SCURPOS	_IOW('W', 71, struct wsdisplay_curpos)
421 
422 /* Cursor control: get maximum size */
423 #define	WSDISPLAYIO_GCURMAX	_IOR('W', 72, struct wsdisplay_curpos)
424 
425 /* Cursor control: get/set cursor attributes/shape */
426 #define	WSDISPLAYIO_GCURSOR	_IOWR('W', 73, struct wsdisplay_cursor)
427 #define	WSDISPLAYIO_SCURSOR	_IOW('W', 74, struct wsdisplay_cursor)
428 
429 /* Display mode: Emulation (text) vs. Mapped (graphics) mode */
430 #define	WSDISPLAYIO_GMODE	_IOR('W', 75, u_int)
431 #define	WSDISPLAYIO_SMODE	_IOW('W', 76, u_int)
432 #define	WSDISPLAYIO_MODE_EMUL	0	/* emulation (text) mode */
433 #define	WSDISPLAYIO_MODE_MAPPED	1	/* mapped (graphics) mode */
434 #define	WSDISPLAYIO_MODE_DUMBFB	2	/* mapped (graphics) fb mode */
435 
436 
437 /*
438  * XXX WARNING
439  * XXX The following wsdisplay definitions are very preliminary and are likely
440  * XXX to be changed without care about backwards compatibility!
441  */
442 struct wsdisplay_font {
443 	const char *name;
444 	int firstchar, numchars;
445 	int encoding;
446 #define	WSDISPLAY_FONTENC_ISO 0
447 #define	WSDISPLAY_FONTENC_IBM 1
448 #define	WSDISPLAY_FONTENC_PCVT 2
449 #define	WSDISPLAY_FONTENC_ISO7 3 /* greek */
450 #define	WSDISPLAY_FONTENC_ISO2 4 /* east european */
451 #define	WSDISPLAY_FONTENC_KOI8_R 5 /* russian */
452 	u_int fontwidth, fontheight, stride;
453 #define	WSDISPLAY_MAXFONTSZ	(512*1024)
454 	int bitorder, byteorder;
455 #define	WSDISPLAY_FONTORDER_KNOWN 0	/* i.e, no need to convert */
456 #define	WSDISPLAY_FONTORDER_L2R 1
457 #define	WSDISPLAY_FONTORDER_R2L 2
458 	void *data;
459 };
460 #define	WSDISPLAYIO_LDFONT	_IOW('W', 77, struct wsdisplay_font)
461 
462 struct wsdisplay_addscreendata {
463 	int idx; /* screen index */
464 	char *screentype;
465 	char *emul;
466 };
467 #define	WSDISPLAYIO_ADDSCREEN	_IOW('W', 78, struct wsdisplay_addscreendata)
468 
469 struct wsdisplay_delscreendata {
470 	int idx; /* screen index */
471 	int flags;
472 #define	WSDISPLAY_DELSCR_FORCE 1
473 };
474 #define	WSDISPLAYIO_DELSCREEN	_IOW('W', 79, struct wsdisplay_delscreendata)
475 
476 struct wsdisplay_usefontdata {
477 	char *name;
478 };
479 #define	WSDISPLAYIO_SFONT	_IOW('W', 80, struct wsdisplay_usefontdata)
480 
481 /* Obsolete, replaced by WSMUXIO_{ADD,REMOVE}_DEVICE */
482 struct wsdisplay_kbddata {
483 	int op;
484 #define	_O_WSDISPLAY_KBD_ADD 0
485 #define	_O_WSDISPLAY_KBD_DEL 1
486 	int idx;
487 };
488 #define	_O_WSDISPLAYIO_SETKEYBOARD	_IOWR('W', 81, struct wsdisplay_kbddata)
489 
490 /*
491  * Misc control.  Not applicable to all display types.
492  * - WSDISPLAYIO_PARAM_BACKLIGHT should be an on/off switch for screensavers,
493  *   it should turn the display dark / turn the backlight off without changing
494  *   the brightness value so screensavers and such can just flip the switch
495  *   without caring about actual brightness settings
496  * - WSDISPLAYIO_PARAM_BRIGHTNESS should set display / backlight brightness
497  */
498 struct wsdisplay_param {
499 	int param;
500 #define	WSDISPLAYIO_PARAM_BACKLIGHT	1
501 #define	WSDISPLAYIO_PARAM_BRIGHTNESS	2
502 #define	WSDISPLAYIO_PARAM_CONTRAST	3
503 	int min, max, curval;
504 	int reserved[4];
505 };
506 #define	WSDISPLAYIO_GETPARAM	_IOWR('W', 82, struct wsdisplay_param)
507 #define	WSDISPLAYIO_SETPARAM	_IOWR('W', 83, struct wsdisplay_param)
508 
509 #define	WSDISPLAYIO_GETACTIVESCREEN	_IOR('W', 84, int)
510 
511 /* Character functions */
512 struct wsdisplay_char {
513 	int row, col;
514 	uint16_t letter;
515 	uint8_t background, foreground;
516 	char flags;
517 #define	WSDISPLAY_CHAR_BRIGHT 1
518 #define	WSDISPLAY_CHAR_BLINK  2
519 };
520 #define	WSDISPLAYIO_GETWSCHAR	_IOWR('W', 85, struct wsdisplay_char)
521 #define	WSDISPLAYIO_PUTWSCHAR	_IOWR('W', 86, struct wsdisplay_char)
522 
523 /* Manipulate the scrolling values (how many lines to scroll) */
524 
525 struct wsdisplay_scroll_data {
526 	u_int		which;
527 #define	WSDISPLAY_SCROLL_DOFASTLINES	0x01
528 #define	WSDISPLAY_SCROLL_DOSLOWLINES	0x02
529 #define	WSDISPLAY_SCROLL_DOALL		0x03
530 	u_int		fastlines;
531 	u_int		slowlines;
532 };
533 
534 #define	WSDISPLAYIO_DGSCROLL	_IOR('W', 87, struct wsdisplay_scroll_data)
535 #define	WSDISPLAYIO_DSSCROLL	_IOW('W', 88, struct wsdisplay_scroll_data)
536 
537 struct wsdisplay_msgattrs {
538 	int default_attrs, default_bg, default_fg;
539 	int kernel_attrs, kernel_bg, kernel_fg;
540 };
541 
542 #define	WSDISPLAYIO_GMSGATTRS	_IOR('W', 89, struct wsdisplay_msgattrs)
543 #define	WSDISPLAYIO_SMSGATTRS	_IOW('W', 90, struct wsdisplay_msgattrs)
544 
545 #define	WSDISPLAYIO_GBORDER	_IOR('W', 91, int)
546 #define	WSDISPLAYIO_SBORDER	_IOW('W', 92, int)
547 
548 /* Splash screen control */
549 #define	WSDISPLAYIO_SSPLASH	_IOW('W', 93, int)
550 #define	WSDISPLAYIO_SPROGRESS	_IOW('W', 94, int)
551 
552 /* XXX NOT YET DEFINED */
553 /* Mapping information retrieval. */
554 
555 /* Display information: number of bytes per row, may be same as pixels */
556 #define	WSDISPLAYIO_LINEBYTES	_IOR('W', 95, u_int)
557 
558 /* WSMUXIO_OINJECTEVENT	was 96, but does not conflict because arg sizes */
559 
560 #define WSDISPLAYIO_SETVERSION	_IOW('W', 96, int)
561 #define WSDISPLAYIO_EVENT_VERSION	WSEVENT_VERSION
562 
563 /*
564  * Mux ioctls (97 - 127)
565  */
566 
567 struct wsmux_device {
568 	int type;
569 #define	WSMUX_MOUSE	1
570 #define	WSMUX_KBD	2
571 #define	WSMUX_MUX	3
572 #define	WSMUX_BELL	4
573 	int idx;
574 };
575 #define	WSMUXIO_ADD_DEVICE	_IOW('W', 97, struct wsmux_device)
576 #define	WSMUX_ADD_DEVICE	WSMUXIO_ADD_DEVICE /* XXX compat */
577 #define	WSMUXIO_REMOVE_DEVICE	_IOW('W', 98, struct wsmux_device)
578 #define	WSMUX_REMOVE_DEVICE	WSMUXIO_REMOVE_DEVICE /* XXX compat */
579 
580 #define	WSMUX_MAXDEV 32
581 struct wsmux_device_list {
582 	int ndevices;
583 	struct wsmux_device devices[WSMUX_MAXDEV];
584 };
585 #define	WSMUXIO_LIST_DEVICES	_IOWR('W', 99, struct wsmux_device_list)
586 #define	WSMUX_LIST_DEVICES	WSMUXIO_LIST_DEVICES /* XXX compat */
587 
588 #define	WSMUXIO_INJECTEVENT	_IOW('W', 100, struct wscons_event)
589 #define	WSMUX_INJECTEVENT	WSMUXIO_INJECTEVENT /* XXX compat */
590 
591 /* Mapping information retrieval. */
592 struct wsdisplayio_bus_id {
593     u_int bus_type;
594 #define WSDISPLAYIO_BUS_PCI	0
595 #define WSDISPLAYIO_BUS_SBUS	1
596 #define WSDISPLAYIO_BUS_SOC	2
597     union bus_data {
598         struct bus_pci {
599             uint32_t domain;
600             uint32_t bus;
601             uint32_t device;
602             uint32_t function;
603         } pci;
604         struct bus_sbus {
605             uint32_t fb_instance;
606         } sbus;
607         /* so the size doesn't change if we add more bus types */
608         char pad[32];
609     } ubus;
610 };
611 
612 #define WSDISPLAYIO_GET_BUSID	_IOR('W', 101, struct wsdisplayio_bus_id)
613 
614 /*
615  * retrieving EDID data from a wsdisplay driver
616  * The EDID block will be written into a buffer pointed at by edid_data,
617  * the caller must fill in buffer_size and edid_data, the driver will set
618  * data_size to the number of bytes actually written.
619  * If the buffer is too small the call will fail with EAGAIN and the driver
620  * will set data_size without writing anything into the buffer.
621  */
622 
623 struct wsdisplayio_edid_info {
624 	uint32_t buffer_size;
625 	uint32_t data_size;
626 	void *edid_data;
627 };
628 #define WSDISPLAYIO_GET_EDID	_IOWR('W', 102, struct wsdisplayio_edid_info)
629 
630 /*
631  * this is for enabling and disabling interrupt-driven drawing
632  * pass 1 to enable polling, 0 to go back to normal
633  * the kernel itself will call this on the console device when entering or
634  * leaving ddb and on panic
635  * may have side effects like hard switching to the virtual console which
636  * shows kernel output, resetting the video hardware etc. - not really for
637  * userland to mess with
638  */
639 #define WSDISPLAYIO_SET_POLLING	_IOW('W', 103, int)
640 #define WSDISPLAYIOMGWEHITANDKILLEDASKUNK WSDISPLAYIO_SET_POLLING
641 
642 /*
643  * this is supposed to replace WSDISPLAYIO_GINFO, WSDISPLAYIO_GTYPE,
644  * WSDISPLAYIO_LINEBYTES etc.
645  */
646 
647 /* format type - colour index, 'true' colour etc. */
648 #define WSFB_RGB	0
649 #define WSFB_CI		1	/* colour indexed, see subtype */
650 #define WSFB_GREYSCALE	2
651 #define WSFB_YUV	3
652 
653 struct wsdisplayio_fbinfo {
654 	uint64_t fbi_fbsize;		/* framebuffer size in bytes */
655 	uint64_t fbi_fboffset;		/* start of visible fb, in bytes */
656 	uint32_t fbi_width;		/* in pixels */
657 	uint32_t fbi_height;		/* in lines */
658 	uint32_t fbi_stride;		/* in bytes */
659 	uint32_t fbi_bitsperpixel;
660 	uint32_t fbi_pixeltype;		/* see above */
661 	union _fbi_subtype {
662 		struct _fbi_rgbmasks {
663 			/* offsets from the right, size in bits */
664 			uint32_t red_offset;
665 			uint32_t red_size;
666 			uint32_t green_offset;
667 			uint32_t green_size;
668 			uint32_t blue_offset;
669 			uint32_t blue_size;
670 			uint32_t alpha_offset;
671 			uint32_t alpha_size;
672 		} fbi_rgbmasks;
673 		struct _fbi_cmapinfo {
674 			uint32_t cmap_entries;
675 		} fbi_cmapinfo;
676 		/*
677 		 * TODO:
678 		 * add parameter blocks for greyscale, yuv etc.
679 		 */
680 	} fbi_subtype;
681 	uint32_t fbi_flags;
682 };
683 
684 /* fbi_flags */
685 #define WSFB_VRAM_IS_RAM	0x0001	/* hint for wsfb - don't shadow */
686 #define WSFB_VRAM_IS_SPLIT	0x0002	/* workaround for wildcat... */
687 
688 #define WSDISPLAYIO_GET_FBINFO	_IOWR('W', 104, struct wsdisplayio_fbinfo)
689 
690 struct wsdisplayio_blit {
691 	uint32_t serial;
692 	uint32_t op;
693 	uint32_t srcx;
694 	uint32_t srcy;
695 	uint32_t dstx;
696 	uint32_t dsty;
697 	uint32_t width;
698 	uint32_t height;
699 	uint32_t pen;
700 };
701 
702 /* blit ops */
703 #define WSFB_BLIT_FILL		1	/* fill rectangle */
704 #define WSFB_BLIT_COPY		2	/* copy rectangle */
705 #define WSFB_BLIT_TRANS		3	/* copy rectangle with color key */
706 
707 #define WSDISPLAYIO_DOBLIT   	_IOWR('W', 105, struct wsdisplayio_blit)
708 #define WSDISPLAYIO_WAITBLIT 	_IOWR('W', 106, struct wsdisplayio_blit)
709 
710 struct wsdisplayio_fontdesc {
711 		char fd_name[64];
712 		uint16_t fd_height;
713 		uint16_t fd_width;
714 };
715 
716 struct wsdisplayio_fontinfo {
717 	uint32_t fi_buffersize;
718 	uint32_t fi_numentries;
719 	struct wsdisplayio_fontdesc *fi_fonts;
720 };
721 
722 /*
723  * fill buffer pointed at by fi_fonts with wsdisplayio_fontdesc until either
724  * full or all fonts are listed
725  * just return the number of entries needed if fi_fonts is NULL
726  */
727 
728 #define WSDISPLAYIO_LISTFONTS	_IOWR('W', 107, struct wsdisplayio_fontinfo)
729 
730 #endif /* _DEV_WSCONS_WSCONSIO_H_ */
731