xref: /netbsd-src/share/man/man4/wsdisplay.4 (revision d3b8b43109efff38f46d2f3b794030d46d7fe9c6)
1.\" $NetBSD: wsdisplay.4,v 1.51 2024/09/02 13:41:33 gutteridge Exp $
2.\"
3.\" Copyright (c) 1999 Matthias Drochner.
4.\" Copyright (c) 2002 Ben Harris.
5.\" Copyright (c) 2004 Julio M. Merino Vidal.
6.\" 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.\"
17.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27.\" SUCH DAMAGE.
28.\"
29.Dd May 16, 2020
30.Dt WSDISPLAY 4
31.Os
32.Sh NAME
33.Nm wsdisplay
34.Nd generic display device support in wscons
35.Sh SYNOPSIS
36.Cd "wsdisplay* at ega? console ?"
37(EGA display on ISA)
38.Cd "wsdisplay* at vga? console ?"
39(VGA display on ISA or PCI)
40.Cd "wsdisplay* at pcdisplay? console ?"
41(generic PC (ISA) display)
42.Cd "wsdisplay* at tga? console ?"
43(DEC TGA display, alpha only)
44.Cd "wsdisplay* at pfb? console ?"
45(PCI framebuffer, bebox only)
46.Cd "wsdisplay0 at ofb? console ?"
47(Open Firmware framebuffer, macppc only)
48.Cd "wsdisplay* at nextdisplay? console ?"
49(NeXT display)
50.Cd "wsdisplay0 at smg0"
51(VAXstation small monochrome display)
52.Cd "wsdisplay* at ... kbdmux N"
53.Pp
54.Cd options WSDISPLAY_BORDER_COLOR=WSCOL_XXX
55.Cd options WSDISPLAY_CUSTOM_BORDER
56.Cd options WSDISPLAY_CUSTOM_OUTPUT
57.Cd options WSDISPLAY_DEFAULTSCREENS=N
58.Cd options WSDISPLAY_SCROLLSUPPORT
59.Sh DESCRIPTION
60The
61.Nm
62driver is an abstraction layer for display devices within the
63.Xr wscons 4
64framework.
65It attaches to the hardware specific display device driver and makes it
66available as a text terminal or graphics interface.
67.Pp
68A display device can have the ability to display characters on it
69(without the help of an X server), either directly by hardware or through
70software putting pixel data into the display memory.
71Such displays are called
72.Dq emulating ,
73the
74.Nm
75driver will connect a terminal emulation module and provide a tty-like
76software interface.
77In contrary, non-emulating displays can only be used by special programs
78like X servers.
79.Pp
80The
81.Cd console
82locator in the configuration line refers to the device's use as the output
83part of the operating system console.
84A device specification containing a positive value here will only match if
85the device is in use as the system console.
86(The console device selection in early system startup is not influenced.)
87This way, the console device can be connected to a known wsdisplay device
88instance.
89(Naturally, only
90.Dq emulating
91display devices are usable as console.)
92.Pp
93The
94.Cd kbdmux
95locator in the configuration line refers to the
96.Xr wsmux 4
97that will be used to get keyboard events.
98If this locator is -1 no mux will be used.
99.Pp
100The logical unit of independent contents displayed on a display
101(sometimes referred to as
102.Dq virtual terminal )
103is called a
104.Dq screen
105here.
106If the underlying device driver supports it, multiple screens can
107be used on one display.
108(As of this writing, only the
109.Xr vga 4
110and the VAX
111.Dq smg
112display drivers provide this ability.)
113Screens have different minor device numbers and separate tty instances.
114One screen possesses the
115.Dq focus ,
116this means it is visible and its tty device will get
117the keyboard input.
118(In some cases \- if no screen is set up or if a screen
119was just deleted \- it is possible that no focus is present at all.)
120The focus can be switched by either special keyboard input (typically
121.Ao "Ctrl" Ac Ns \| Ns Ao "Alt" Ac Ns \| Ns Ao "F" Ns Ar "n" Ac ,
122.Ao "Stop" Ac Ns \| Ns Ao "F" Ns Ar "n" Ac
123on Sun hardware,
124.Ao "Command" Ac Ns \| Ns Ao "F" Ns Ar "n" Ac
125on ADB keyboards)
126or an ioctl command issued by a user program.
127Screens are created and deleted through the
128.Pa /dev/ttyEcfg
129control device (preferably using the
130.Xr wsconscfg 8
131utility).
132Alternatively, the compile-time option
133.Dv WSDISPLAY_DEFAULTSCREENS Ns = Ns Ar n
134will also create (at autoconfiguration time)
135.Ar n
136initial screens of the display driver's default type with
137the system's default terminal emulator.
138.Ss Kernel options
139The following kernel options are available to configure the behavior of the
140.Nm
141driver:
142.Bl -tag -width xxxxxxxx
143.It Cd options WSDISPLAY_BORDER_COLOR=WSCOL_XXX
144Sets the border color at boot time.
145Possible values are defined in
146.Pa src/sys/dev/wscons/wsdisplayvar.h .
147Defaults to
148.Dv WSCOL_BLACK .
149.It Cd options WSDISPLAY_CUSTOM_BORDER
150Enables the
151.Dv WSDISPLAYIO_GBORDER
152and
153.Dv WSDISPLAYIO_SBORDER
154ioctls, which allow the customization of the border color from userland
155(after boot).
156See
157.Xr wsconsctl 8 .
158.It Cd options WSDISPLAY_CUSTOM_OUTPUT
159Enables the
160.Dv WSDISPLAYIO_GMSGATTRS
161and
162.Dv WSDISPLAYIO_SMSGATTRS
163ioctls, which allow the customization of the console output and kernel
164messages from userland (after boot).
165See
166.Xr wsconsctl 8 .
167.It Cd options WSDISPLAY_DEFAULTSCREENS=N
168Sets the number of virtual screens to allocate at boot time.
169Useful for small root filesystems where the
170.Xr wsconscfg 8
171utility is not wanted.
172.It Cd options WSDISPLAY_SCROLLSUPPORT
173Enables scrolling support.
174The key combinations are
175.Ao "Left\ Shift" Ac Ns \| Ns Ao "Page\ Up" Ac
176and
177.Ao "Left\ Shift" Ac Ns \| Ns Ao "Page\ Down" Ac
178by default.
179Please note that this function may not work under the system console and
180is available depending on the framebuffer you are using.
181.El
182.Ss Ioctls
183The following
184.Xr ioctl 2
185calls are provided by the
186.Nm
187driver or by devices which use it.
188Their definitions are found in
189.In dev/wscons/wsconsio.h .
190.Bl -tag -width Dv
191.It Dv WSDISPLAYIO_GTYPE Pq Li int
192Retrieve the type of the display.
193The list of types is in
194.In dev/wscons/wsconsio.h .
195.It Dv WSDISPLAYIO_GET_FBINFO Pq Li "struct wsdisplayio_fbinfo"
196Retrieve extended information about a framebuffer display,
197including the framebuffer's pixel packing layout.
198The returned structure is as follows:
199.Bd -literal -offset indent
200struct wsdisplayio_fbinfo {
201	uint64_t fbi_fbsize;
202	uint64_t fbi_fboffset;
203	uint32_t fbi_width;
204	uint32_t fbi_height;
205	uint32_t fbi_stride;
206	uint32_t fbi_bitsperpixel;
207	uint32_t fbi_pixeltype;
208	union _fbi_subtype {
209		struct _fbi_rgbmasks {
210			uint32_t red_offset;
211			uint32_t red_size;
212			uint32_t green_offset;
213			uint32_t green_size;
214			uint32_t blue_offset;
215			uint32_t blue_size;
216			uint32_t alpha_offset;
217			uint32_t alpha_size;
218		} fbi_rgbmasks;
219		struct _fbi_cmapinfo {
220			uint32_t cmap_entries;
221		} fbi_cmapinfo;
222	} fbi_subtype;
223	uint32_t fbi_flags;
224};
225.Ed
226.Pp
227For a "true colour" display, the
228.Va fbi_pixeltype
229field contains
230.Dv WSFB_RGB
231and the
232.Va fbi_rgbmasks
233field contains the pixel packing layout.
234For a colour indexed display, the
235.Va fbi_pixeltype
236field contains
237.Dv WSFB_CI
238and the
239.Va fbi_cmapinfo
240field contains the number of color map entries.
241.It Dv WSDISPLAYIO_GINFO Pq Li "struct wsdisplay_fbinfo"
242Retrieve basic information about a framebuffer display.
243The returned structure is as follows:
244.Bd -literal -offset indent
245struct wsdisplay_fbinfo {
246	u_int	height;
247	u_int	width;
248	u_int	depth;
249	u_int	cmsize;
250};
251.Ed
252.Pp
253The
254.Va height
255and
256.Va width
257members are counted in pixels.
258The
259.Va depth
260member indicates the number of bits per pixel, and
261.Va cmsize
262indicates the number of color map entries accessible through
263.Dv WSDISPLAYIO_GETCMAP
264and
265.Dv WSDISPLAYIO_PUTCMAP .
266This call is likely to be unavailable on text-only displays.
267.It Dv WSDISPLAYIO_GETCMAP Pq Li "struct wsdisplay_cmap"
268Retrieve the current color map from the display.
269This call needs the
270following structure set up beforehand:
271.Bd -literal -offset indent
272struct wsdisplay_cmap {
273	u_int	index;
274	u_int	count;
275	u_char	*red;
276	u_char	*green;
277	u_char	*blue;
278};
279.Ed
280.Pp
281The
282.Va index
283and
284.Va count
285members specify the range of color map entries to retrieve.
286The
287.Va red ,
288.Va green ,
289and
290.Va blue
291members should each point to an array of
292.Va count
293.Vt u_char Ns No \^s .
294On return, these will be filled in with the appropriate entries from the
295color map.
296On all displays that support this call, values range from 0 for minimum
297intensity to 255 for maximum intensity, even if the display does not use
298eight bits internally to represent intensity.
299.It Dv WSDISPLAYIO_PUTCMAP Pq Li "struct wsdisplay_cmap"
300Change the display's color map.
301The argument structure is the same as for
302.Dv WSDISPLAYIO_GETCMAP ,
303but
304.Va red ,
305.Va green ,
306and
307.Va blue
308are taken as pointers to the values to use to set the color map.
309This call is not available on displays with fixed color maps.
310.It Dv WSDISPLAYIO_GVIDEO Pq Li int
311Get the current state of the display's video output.
312Possible values are:
313.Bl -tag -width Dv
314.It Dv WSDISPLAYIO_VIDEO_OFF
315The display is blanked.
316.It Dv WSDISPLAYIO_VIDEO_ON
317The display is enabled.
318.El
319.It Dv WSDISPLAYIO_SVIDEO Pq Li int
320Set the state of the display's video output.
321See
322.Dv WSDISPLAYIO_GVIDEO
323above for possible values.
324.It Dv WSDISPLAYIO_GCURPOS Pq Li "struct wsdisplay_curpos"
325Retrieve the current position of the hardware cursor.
326The returned structure
327is as follows:
328.Bd -literal -offset indent
329struct wsdisplay_curpos {
330        u_int x, y;
331};
332.Ed
333.Pp
334The
335.Va x
336and
337.Va y
338members count the number of pixels right and down, respectively, from
339the top-left corner of the display to the hot spot of the cursor.
340This call is not available on displays without a hardware cursor.
341.It Dv WSDISPLAYOP_SCURPOS Pq Li "struct wsdisplay_curpos"
342Set the current cursor position.
343The argument structure, and its semantics, are the same as for
344.Dv WSDISPLAYIO_GCURPOS .
345This call is not available on displays without a hardware cursor.
346.It Dv WSDISPLAYIO_GCURMAX Pq Li "struct wsdisplay_curpos"
347Retrieve the maximum size of cursor supported by the display.
348The
349.Va x
350and
351.Va y
352members of the returned structure indicate the maximum number of pixel rows
353and columns, respectively, in a hardware cursor on this display.
354This call is not available on displays without a hardware cursor.
355.It Dv WSDISPLAYIO_GCURSOR Pq Li "struct wsdisplay_cursor"
356Retrieve some or all of the hardware cursor's attributes.
357The argument structure is as follows:
358.Bd -literal -offset indent
359struct wsdisplay_cursor {
360	u_int	which;
361	u_int	enable;
362	struct wsdisplay_curpos pos;
363	struct wsdisplay_curpos hot;
364	struct wsdisplay_cmap cmap;
365	struct wsdisplay_curpos size;
366	u_char *image;
367	u_char *mask;
368};
369.Pp
370.Ed
371The
372.Va which
373member indicates which of the values the application requires to be returned.
374It should contain the logical OR of the following flags:
375.Bl -tag -width Dv
376.It Dv WSDISPLAY_CURSOR_DOCUR
377Get
378.Va enable ,
379which indicates whether the cursor is currently displayed (non-zero) or
380not (zero).
381.It Dv WSDISPLAY_CURSOR_DOPOS
382Get
383.Va pos ,
384which indicates the current position of the cursor on the display, as
385would be returned by
386.Dv WSDISPLAYIO_GCURPOS .
387.It Dv WSDISPLAY_CURSOR_DOHOT
388Get
389.Va hot ,
390which indicates the location of the
391.Dq hot spot
392within the cursor.
393This is the point on the cursor whose position on the display is treated
394as being the position of the cursor by other calls.
395Its location is counted in pixels from the top-right corner of the cursor.
396.It Dv WSDISPLAY_CURSOR_DOCMAP
397Get
398.Va cmap ,
399which indicates the current cursor color map.
400Unlike in a call to
401.Dv WSDISPLAYIO_GETCMAP ,
402.Va cmap
403here need not have its
404.Va index
405and
406.Va count
407members initialized.
408They will be set to 0 and 2 respectively by the call.
409This means that
410.Va cmap . Ns Va red ,
411.Va cmap . Ns Va green ,
412and
413.Va cmap . Ns Va blue
414must each point to at least enough space to hold two
415.Vt u_char Ns No \^s .
416.It Dv WSDISPLAY_CURSOR_DOSHAPE
417Get
418.Va size , image ,
419and
420.Va mask .
421These are, respectively, the dimensions of the cursor in pixels, the
422bitmap of set pixels in the cursor and the bitmap of opaque pixels in
423the cursor.
424The format in which these bitmaps are returned, and hence the amount of
425space that must be provided by the application, are device-dependent.
426.It Dv WSDISPLAY_CURSOR_DOALL
427Get all of the above.
428.El
429.Pp
430The device may elect to return information that was not requested by the user,
431so those elements of
432.Li "struct wsdisplay_cursor"
433which are pointers should be initialized to
434.Dv NULL
435if not otherwise used.
436This call is not available on displays without a hardware cursor.
437.It Dv WSDISPLAYIO_SCURSOR Pq Li "struct wsdisplay_cursor"
438Set some or all of the hardware cursor's attributes.
439The argument structure is the same as for
440.Dv WSDISPLAYIO_GCURSOR .
441The
442.Va which
443member specifies which attributes of the cursor are to be changed.
444It should contain the logical OR of the following flags:
445.Bl -tag -width Dv
446.It Dv WSDISPLAY_CURSOR_DOCUR
447If
448.Va enable
449is zero, hide the cursor.
450Otherwise, display it.
451.It Dv WSDISPLAY_CURSOR_DOPOS
452Set the cursor's position on the display to
453.Va pos ,
454the same as
455.Dv WSDISPLAYIO_SCURPOS .
456.It Dv WSDISPLAY_CURSOR_DOHOT
457Set the
458.Dq hot spot
459of the cursor, as defined above, to
460.Va hot .
461.It Dv WSDISPLAY_CURSOR_DOCMAP
462Set some or all of the cursor color map based on
463.Va cmap .
464The
465.Va index
466and
467.Va count
468elements of
469.Va cmap
470indicate which color map entries to set, and the entries themselves come from
471.Va cmap . Ns Va red ,
472.Va cmap . Ns Va green ,
473and
474.Va cmap . Ns Va blue .
475.It Dv WSDISPLAY_CURSOR_DOSHAPE
476Set the cursor shape from
477.Va size , image ,
478and
479.Va mask .
480See above for their meanings.
481.It Dv WSDISPLAY_CURSOR_DOALL
482Do all of the above.
483.El
484.Pp
485This call is not available on displays without a hardware cursor.
486.It Dv WSDISPLAYIO_GMODE Pq Li u_int
487Get the current mode of the display.
488Possible results include:
489.Bl -tag -width Dv
490.It Dv WSDISPLAYIO_MODE_EMUL
491The display is in emulating (text) mode.
492.It Dv WSDISPLAYIO_MODE_MAPPED
493The display is in mapped (graphics) mode.
494.It Dv WSDISPLAYIO_MODE_DUMBFB
495The display is in mapped (frame buffer) mode.
496.El
497.It Dv WSDISPLAYIO_SMODE Pq Li u_int
498Set the current mode of the display.
499For possible arguments, see
500.Dv WSDISPLAYIO_GMODE .
501.It Dv WSDISPLAYIO_LINEBYTES Pq Li u_int
502Get the number of bytes per row, which may be the same as the number of pixels.
503.It Dv WSDISPLAYIO_GMSGATTRS Pq Li struct wsdisplay_msgattrs
504Get the attributes (colors and flags) used to print console messages, including
505separate fields for default output and kernel output.
506The returned structure is as follows:
507.Bd -literal -offset indent
508struct wsdisplay_msgattrs {
509	int default_attrs, default_bg, default_fg;
510	int kernel_attrs, kernel_bg, kernel_fg;
511};
512.Ed
513.Pp
514The
515.Va default_attrs
516and
517.Va kernel_attrs
518variables are a combination of
519.Dv WSATTR_ Ns Ar *
520bits, and specify the attributes used to draw messages.
521The
522.Va default_bg ,
523.Va default_fg ,
524.Va kernel_bg
525and
526.Va kernel_fg
527variables specify the colors used to print messages, being
528.Sq _bg
529for the background and
530.Sq _fg
531for the foreground; their values are one of all the
532.Dv WSCOL_ Ns Ar *
533macros available.
534.It Dv WSDISPLAYIO_SMSGATTRS Pq Li struct wsdisplay_msgattrs
535Set the attributes (colors and flags) used to print console messages, including
536separate fields for default output and kernel output.
537The argument structure is the same as for
538.Dv WSDISPLAYIO_GMSGATTRS .
539.It Dv WSDISPLAYIO_GBORDER Pq Li u_int
540Retrieve the color of the screen border.
541This number corresponds to an ANSI standard color.
542.It Dv WSDISPLAYIO_SBORDER Pq Li u_int
543Set the color of the screen border, if applicable.
544This number corresponds to an ANSI standard color.
545Not all drivers support this feature.
546.It Dv WSDISPLAYIO_GETWSCHAR Pq Li struct wsdisplay_char
547Gets a single character from the screen, specified by its position.
548The structure used is as follows:
549.Bd -literal -offset indent
550struct wsdisplay_char {
551	int row, col;
552	uint16_t letter;
553	uint8_t background, foreground;
554	char flags;
555};
556.Ed
557.Pp
558The
559.Va row
560and
561.Va col
562parameters are used as input; the rest of the structure is filled by the
563ioctl and is returned to you.
564.Va letter
565is the ASCII code of the letter found at the specified position,
566.Va background
567and
568.Va foreground
569are its colors and
570.Va flags
571is a combination of
572.Dv WSDISPLAY_CHAR_BRIGHT
573and/or
574.Dv WSDISPLAY_CHAR_BLINK .
575.It Dv WSDISPLAYIO_PUTWSCHAR Pq Li struct wsdisplay_char
576Puts a character on the screen.
577The structure has the same meaning as described in
578.Dv WSDISPLAY_GETWSCHAR ,
579although all of its fields are treated as input.
580.\" Splash screen control
581.It Dv WSDISPLAYIO_SSPLASH Pq Li u_int
582Toggle the splash screen.
583This call is only available with the
584.Dv SPLASHSCREEN
585kernel option.
586.It Dv WSDISPLAYIO_GET_EDID Pq Li struct wsdisplayio_edid_info
587Retrieve EDID data from a driver.
588.Bd -literal -offset indent
589struct wsdisplayio_edid_info {
590	uint32_t buffer_size;
591	uint32_t data_size;
592	void *edid_data;
593};
594.Ed
595The caller is responsible for allocating a buffer of at least 128 bytes
596(the minimum size of an EDID block) and set data_size to its size.
597If the EDID block is bigger the call will fail with
598.Er EAGAIN
599and the driver will set data_size to the required buffer size.
600Otherwise the EDID block will be written into the buffer pointed
601at by edid_data and data_size will be set to the number of bytes
602written.
603.It Dv WSDISPLAYIO_SETVERSION Pq Li "int"
604Set the wscons_event protocol version.
605The default is 0 for binary compatibility.
606The latest version is
607always available as
608.Dv WSDISPLAYIO_EVENT_VERSION ,
609and is currently 1.
610All new code should use a call similar to the below to ensure the
611correct version is returned.
612.Bd -literal -offset indent
613int ver = WSDISPLAYIO_EVENT_VERSION;
614if (ioctl(fd, WSDISPLAYIO_SETVERSION, &ver) == -1)
615    err(EXIT_FAILURE, "cannot set version");
616.Ed
617.El
618.Sh FILES
619.Bl -tag -width "/dev/ttyEstat" -compact
620.It Pa /dev/ttyE*
621Terminal devices (per screen).
622.It Pa /dev/ttyEcfg
623Control device.
624.It Pa /dev/ttyEstat
625Status device.
626.Pp
627.It Pa /usr/include/dev/wscons/wsconsio.h
628.El
629.Sh SEE ALSO
630.Xr ioctl 2 ,
631.\" .Xr ega 4 ,
632.Xr pcdisplay 4 ,
633.Xr tty 4 ,
634.Xr vga 4 ,
635.Xr wscons 4 ,
636.Xr wsconscfg 8 ,
637.Xr wsconsctl 8 ,
638.Xr wsfontload 8 ,
639.Xr wsdisplay 9
640.Sh BUGS
641The
642.Nm
643code currently limits the number of screens on one display to 8.
644.Pp
645The terms
646.Dq wscons
647and
648.Dq wsdisplay
649are not cleanly distinguished in the code and in manual pages.
650.Pp
651.Dq Non-emulating
652display devices are not tested.
653