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