xref: /netbsd-src/share/man/man4/wsdisplay.4 (revision 7335d92d06715a3753b14a8a2eaf6d08617a561c)
1.\" $NetBSD: wsdisplay.4,v 1.46 2018/01/13 23:43:46 wiz 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 October 25, 2015
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 an 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_GINFO Pq Li "struct wsdisplay_fbinfo"
196Retrieve basic information about a framebuffer display.
197The returned structure is as follows:
198.Bd -literal -offset indent
199struct wsdisplay_fbinfo {
200	u_int	height;
201	u_int	width;
202	u_int	depth;
203	u_int	cmsize;
204};
205.Ed
206.Pp
207The
208.Va height
209and
210.Va width
211members are counted in pixels.
212The
213.Va depth
214member indicates the number of bits per pixel, and
215.Va cmsize
216indicates the number of color map entries accessible through
217.Dv WSDISPLAYIO_GETCMAP
218and
219.Dv WSDISPLAYIO_PUTCMAP .
220This call is likely to be unavailable on text-only displays.
221.It Dv WSDISPLAYIO_GETCMAP Pq Li "struct wsdisplay_cmap"
222Retrieve the current color map from the display.
223This call needs the
224following structure set up beforehand:
225.Bd -literal -offset indent
226struct wsdisplay_cmap {
227	u_int	index;
228	u_int	count;
229	u_char	*red;
230	u_char	*green;
231	u_char	*blue;
232};
233.Ed
234.Pp
235The
236.Va index
237and
238.Va count
239members specify the range of color map entries to retrieve.
240The
241.Va red ,
242.Va green ,
243and
244.Va blue
245members should each point to an array of
246.Va count
247.Vt u_char Ns No \^s .
248On return, these will be filled in with the appropriate entries from the
249color map.
250On all displays that support this call, values range from 0 for minimum
251intensity to 255 for maximum intensity, even if the display does not use
252eight bits internally to represent intensity.
253.It Dv WSDISPLAYIO_PUTCMAP Pq Li "struct wsdisplay_cmap"
254Change the display's color map.
255The argument structure is the same as for
256.Dv WSDISPLAYIO_GETCMAP ,
257but
258.Va red ,
259.Va green ,
260and
261.Va blue
262are taken as pointers to the values to use to set the color map.
263This call is not available on displays with fixed color maps.
264.It Dv WSDISPLAYIO_GVIDEO Pq Li int
265Get the current state of the display's video output.
266Possible values are:
267.Bl -tag -width Dv
268.It Dv WSDISPLAYIO_VIDEO_OFF
269The display is blanked.
270.It Dv WSDISPLAYIO_VIDEO_ON
271The display is enabled.
272.El
273.It Dv WSDISPLAYIO_SVIDEO Pq Li int
274Set the state of the display's video output.
275See
276.Dv WSDISPLAYIO_GVIDEO
277above for possible values.
278.It Dv WSDISPLAYIO_GCURPOS Pq Li "struct wsdisplay_curpos"
279Retrieve the current position of the hardware cursor.
280The returned structure
281is as follows:
282.Bd -literal -offset indent
283struct wsdisplay_curpos {
284        u_int x, y;
285};
286.Ed
287.Pp
288The
289.Va x
290and
291.Va y
292members count the number of pixels right and down, respectively, from
293the top-left corner of the display to the hot spot of the cursor.
294This call is not available on displays without a hardware cursor.
295.It Dv WSDISPLAYOP_SCURPOS Pq Li "struct wsdisplay_curpos"
296Set the current cursor position.
297The argument structure, and its semantics, are the same as for
298.Dv WSDISPLAYIO_GCURPOS .
299This call is not available on displays without a hardware cursor.
300.It Dv WSDISPLAYIO_GCURMAX Pq Li "struct wsdisplay_curpos"
301Retrieve the maximum size of cursor supported by the display.
302The
303.Va x
304and
305.Va y
306members of the returned structure indicate the maximum number of pixel rows
307and columns, respectively, in a hardware cursor on this display.
308This call is not available on displays without a hardware cursor.
309.It Dv WSDISPLAYIO_GCURSOR Pq Li "struct wsdisplay_cursor"
310Retrieve some or all of the hardware cursor's attributes.
311The argument structure is as follows:
312.Bd -literal -offset indent
313struct wsdisplay_cursor {
314	u_int	which;
315	u_int	enable;
316	struct wsdisplay_curpos pos;
317	struct wsdisplay_curpos hot;
318	struct wsdisplay_cmap cmap;
319	struct wsdisplay_curpos size;
320	u_char *image;
321	u_char *mask;
322};
323.Pp
324.Ed
325The
326.Va which
327member indicates which of the values the application requires to be returned.
328It should contain the logical OR of the following flags:
329.Bl -tag -width Dv
330.It Dv WSDISPLAY_CURSOR_DOCUR
331Get
332.Va enable ,
333which indicates whether the cursor is currently displayed (non-zero) or
334not (zero).
335.It Dv WSDISPLAY_CURSOR_DOPOS
336Get
337.Va pos ,
338which indicates the current position of the cursor on the display, as
339would be returned by
340.Dv WSDISPLAYIO_GCURPOS .
341.It Dv WSDISPLAY_CURSOR_DOHOT
342Get
343.Va hot ,
344which indicates the location of the
345.Dq hot spot
346within the cursor.
347This is the point on the cursor whose position on the display is treated
348as being the position of the cursor by other calls.
349Its location is counted in pixels from the top-right corner of the cursor.
350.It Dv WSDISPLAY_CURSOR_DOCMAP
351Get
352.Va cmap ,
353which indicates the current cursor color map.
354Unlike in a call to
355.Dv WSDISPLAYIO_GETCMAP ,
356.Va cmap
357here need not have its
358.Va index
359and
360.Va count
361members initialized.
362They will be set to 0 and 2 respectively by the call.
363This means that
364.Va cmap . Ns Va red ,
365.Va cmap . Ns Va green ,
366and
367.Va cmap . Ns Va blue
368must each point to at least enough space to hold two
369.Vt u_char Ns No \^s .
370.It Dv WSDISPLAY_CURSOR_DOSHAPE
371Get
372.Va size , image ,
373and
374.Va mask .
375These are, respectively, the dimensions of the cursor in pixels, the
376bitmap of set pixels in the cursor and the bitmap of opaque pixels in
377the cursor.
378The format in which these bitmaps are returned, and hence the amount of
379space that must be provided by the application, are device-dependent.
380.It Dv WSDISPLAY_CURSOR_DOALL
381Get all of the above.
382.El
383.Pp
384The device may elect to return information that was not requested by the user,
385so those elements of
386.Li "struct wsdisplay_cursor"
387which are pointers should be initialized to
388.Dv NULL
389if not otherwise used.
390This call is not available on displays without a hardware cursor.
391.It Dv WSDISPLAYIO_SCURSOR Pq Li "struct wsdisplay_cursor"
392Set some or all of the hardware cursor's attributes.
393The argument structure is the same as for
394.Dv WSDISPLAYIO_GCURSOR .
395The
396.Va which
397member specifies which attributes of the cursor are to be changed.
398It should contain the logical OR of the following flags:
399.Bl -tag -width Dv
400.It Dv WSDISPLAY_CURSOR_DOCUR
401If
402.Va enable
403is zero, hide the cursor.
404Otherwise, display it.
405.It Dv WSDISPLAY_CURSOR_DOPOS
406Set the cursor's position on the display to
407.Va pos ,
408the same as
409.Dv WSDISPLAYIO_SCURPOS .
410.It Dv WSDISPLAY_CURSOR_DOHOT
411Set the
412.Dq hot spot
413of the cursor, as defined above, to
414.Va hot .
415.It Dv WSDISPLAY_CURSOR_DOCMAP
416Set some or all of the cursor color map based on
417.Va cmap .
418The
419.Va index
420and
421.Va count
422elements of
423.Va cmap
424indicate which color map entries to set, and the entries themselves come from
425.Va cmap . Ns Va red ,
426.Va cmap . Ns Va green ,
427and
428.Va cmap . Ns Va blue .
429.It Dv WSDISPLAY_CURSOR_DOSHAPE
430Set the cursor shape from
431.Va size , image ,
432and
433.Va mask .
434See above for their meanings.
435.It Dv WSDISPLAY_CURSOR_DOALL
436Do all of the above.
437.El
438.Pp
439This call is not available on displays without a hardware cursor.
440.It Dv WSDISPLAYIO_GMODE Pq Li u_int
441Get the current mode of the display.
442Possible results include:
443.Bl -tag -width Dv
444.It Dv WSDISPLAYIO_MODE_EMUL
445The display is in emulating (text) mode.
446.It Dv WSDISPLAYIO_MODE_MAPPED
447The display is in mapped (graphics) mode.
448.It Dv WSDISPLAYIO_MODE_DUMBFB
449The display is in mapped (frame buffer) mode.
450.El
451.It Dv WSDISPLAYIO_SMODE Pq Li u_int
452Set the current mode of the display.
453For possible arguments, see
454.Dv WSDISPLAYIO_GMODE .
455.It Dv WSDISPLAYIO_LINEBYTES Pq Li u_int
456Get the number of bytes per row, which may be the same as the number of pixels.
457.It Dv WSDISPLAYIO_GMSGATTRS Pq Li struct wsdisplay_msgattrs
458Get the attributes (colors and flags) used to print console messages, including
459separate fields for default output and kernel output.
460The returned structure is as follows:
461.Bd -literal -offset indent
462struct wsdisplay_msgattrs {
463	int default_attrs, default_bg, default_fg;
464	int kernel_attrs, kernel_bg, kernel_fg;
465};
466.Ed
467.Pp
468The
469.Va default_attrs
470and
471.Va kernel_attrs
472variables are a combination of
473.Dv WSATTR_ Ns Ar *
474bits, and specify the attributes used to draw messages.
475The
476.Va default_bg ,
477.Va default_fg ,
478.Va kernel_bg
479and
480.Va kernel_fg
481variables specify the colors used to print messages, being
482.Sq _bg
483for the background and
484.Sq _fg
485for the foreground; their values are one of all the
486.Dv WSCOL_ Ns Ar *
487macros available.
488.It Dv WSDISPLAYIO_SMSGATTRS Pq Li struct wsdisplay_msgattrs
489Set the attributes (colors and flags) used to print console messages, including
490separate fields for default output and kernel output.
491The argument structure is the same as for
492.Dv WSDISPLAYIO_GMSGATTRS .
493.It Dv WSDISPLAYIO_GBORDER Pq Li u_int
494Retrieve the color of the screen border.
495This number corresponds to an ANSI standard color.
496.It Dv WSDISPLAYIO_SBORDER Pq Li u_int
497Set the color of the screen border, if applicable.
498This number corresponds to an ANSI standard color.
499Not all drivers support this feature.
500.It Dv WSDISPLAYIO_GETWSCHAR Pq Li struct wsdisplay_char
501Gets a single character from the screen, specified by its position.
502The structure used is as follows:
503.Bd -literal -offset indent
504struct wsdisplay_char {
505	int row, col;
506	uint16_t letter;
507	uint8_t background, foreground;
508	char flags;
509};
510.Ed
511.Pp
512The
513.Va row
514and
515.Va col
516parameters are used as input; the rest of the structure is filled by the
517ioctl and is returned to you.
518.Va letter
519is the ASCII code of the letter found at the specified position,
520.Va background
521and
522.Va foreground
523are its colors and
524.Va flags
525is a combination of
526.Dv WSDISPLAY_CHAR_BRIGHT
527and/or
528.Dv WSDISPLAY_CHAR_BLINK .
529.It Dv WSDISPLAYIO_PUTWSCHAR Pq Li struct wsdisplay_char
530Puts a character on the screen.
531The structure has the same meaning as described in
532.Dv WSDISPLAY_GETWSCHAR ,
533although all of its fields are treated as input.
534.\" Splash screen control
535.It Dv WSDISPLAYIO_SSPLASH Pq Li u_int
536Toggle the splash screen.
537This call is only available with the
538.Dv SPLASHSCREEN
539kernel option.
540.It Dv WSDISPLAYIO_GET_EDID Pq Li struct wsdisplay_edid_info
541Retrieve EDID data from a driver.
542.Bd -literal -offset indent
543struct wsdisplayio_edid_info {
544	uint32_t buffer_size;
545	uint32_t data_size;
546	void *edid_data;
547};
548.Ed
549The caller is responsible for allocating a buffer of at least 128 bytes
550(the minimum size of an EDID block) and set data_size to its size.
551If the EDID block is bigger the call will fail with
552.Er EAGAIN
553and the driver will set data_size to the required buffer size.
554Otherwise the EDID block will be written into the buffer pointed
555at by edid_data and data_size will be set to the number of bytes
556written.
557.It Dv WSDISPLAYIO_SETVERSION Pq Li "int"
558Set the wscons_event protocol version.
559The default is 0 for binary compatibility.
560The latest version is
561always available as
562.Dv WSDISPLAYIO_EVENT_VERSION ,
563and is currently 1.
564All new code should use a call similar to the below to ensure the
565correct version is returned.
566.Bd -literal -offset indent
567int ver = WSDISPLAY_EVENT_VERSION;
568if (ioctl(fd, WSDISPLAYIO_SETVERSION, &ver) == -1)
569    err(EXIT_FAILURE, "cannot set version");
570.Ed
571.El
572.Sh FILES
573.Bl -tag -width "/dev/ttyEstat" -compact
574.It Pa /dev/ttyE*
575Terminal devices (per screen).
576.It Pa /dev/ttyEcfg
577Control device.
578.It Pa /dev/ttyEstat
579Status device.
580.Pp
581.It Pa /usr/include/dev/wscons/wsconsio.h
582.El
583.Sh SEE ALSO
584.Xr ioctl 2 ,
585.\" .Xr ega 4 ,
586.Xr pcdisplay 4 ,
587.Xr tty 4 ,
588.Xr vga 4 ,
589.Xr wscons 4 ,
590.Xr wsconscfg 8 ,
591.Xr wsconsctl 8 ,
592.Xr wsfontload 8 ,
593.Xr wsdisplay 9
594.Sh BUGS
595The
596.Nm
597code currently limits the number of screens on one display to 8.
598.Pp
599The terms
600.Dq wscons
601and
602.Dq wsdisplay
603are not cleanly distinguished in the code and in manual pages.
604.Pp
605.Dq non-emulating
606display devices are not tested.
607