1.\" $OpenBSD: wsdisplay.4,v 1.57 2022/03/31 17:27:21 naddy Exp $ 2.\" $NetBSD: wsdisplay.4,v 1.5 2000/05/13 15:22:19 mycroft Exp $ 3.\" 4.\" Copyright (c) 2005, Miodrag Vallat. 5.\" Copyright (c) 1999 Matthias Drochner. 6.\" Copyright (c) 2002 Ben Harris. 7.\" All rights reserved. 8.\" 9.\" Redistribution and use in source and binary forms, with or without 10.\" modification, are permitted provided that the following conditions 11.\" are met: 12.\" 1. Redistributions of source code must retain the above copyright 13.\" notice, this list of conditions and the following disclaimer. 14.\" 2. Redistributions in binary form must reproduce the above copyright 15.\" notice, this list of conditions and the following disclaimer in the 16.\" documentation and/or other materials provided with the distribution. 17.\" 18.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 19.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 22.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28.\" SUCH DAMAGE. 29.\" 30.Dd $Mdocdate: March 31 2022 $ 31.Dt WSDISPLAY 4 32.Os 33.Sh NAME 34.Nm wsdisplay 35.Nd generic display device support in wscons 36.Sh SYNOPSIS 37.Cd "wsdisplay* at ..." 38.Cd "option WSDISPLAY_DEFAULTSCREENS=N" 39.Sh DESCRIPTION 40The 41.Nm 42driver is an abstraction layer for display devices within the 43.Xr wscons 4 44framework. 45It attaches to the hardware specific display device driver and 46makes it available as text terminal or graphics interface. 47.Pp 48Display devices have the ability to display characters on them 49(without help of an X server), either directly by hardware or through 50software drawing pixel data into the display memory. 51The 52.Nm 53driver will connect a terminal emulation module and provide a 54tty-like software interface. 55.Pp 56The 57.Em console 58locator in the configuration line refers to the device's use as output 59part of the operating system console. 60A device specification containing a positive value here will only match 61if the device is in use as system console. 62(The console device selection in early system startup is not influenced.) 63This way, the console device can be connected to a known 64.Nm wsdisplay 65device instance. 66.Pp 67The 68.Em mux 69locator in the configuration line refers to the 70.Xr wsmux 4 71that will be used to get keyboard events. 72If this locator is -1, no mux will be used. 73.Pp 74The logical unit of an independent contents displayed on a display 75(sometimes referred to as 76.Dq virtual terminal ) 77is called a 78.Dq screen 79here. 80If the underlying device driver supports it, multiple screens can 81be used on one display. 82(As of this writing, only the 83.Xr lcd 4 84and 85.Xr vga 4 86display drivers provide this ability.) 87Screens have different minor device numbers and separate tty instances. 88One screen possesses the 89.Dq focus , 90this means it is displayed on the display and its tty device will get 91the keyboard input. 92(In some cases, if no screen is set up or if a screen 93was just deleted, it is possible that no focus is present at all.) 94The focus can be switched by either special keyboard input (typically 95CTL-ALT-Fn) or an ioctl command issued by a user program. 96Screens are set up or deleted through the 97.Pa /dev/ttyCcfg 98control device (preferably using the 99.Xr wsconscfg 8 100utility). 101Alternatively, the compile-time 102.Cd "option WSDISPLAY_DEFAULTSCREENS=N" 103will set up N screens of the display driver's default type and using 104the system's default terminal emulator at autoconfiguration time. 105.Pp 106In addition and with help from backend drivers the following features 107are also provided: 108.Bl -bullet 109.It 110Loading, deleting and listing the loaded fonts. 111.It 112Browsing backwards in the screen output, the size of the 113buffer for saved text is defined by the particular hardware driver. 114.It 115Blanking the screen by timing out on inactivity in the 116screen holding the input focus. 117Awakening activities consist of: 118.Pp 119.Bl -bullet -compact 120.It 121pressing any keys on the keyboard; 122.It 123moving or clicking the mouse; 124.It 125any output to the screen. 126.El 127.Pp 128Blanking the screen is usually done by disabling the horizontal sync 129signal on video output, but may also include blanking the vertical 130sync in which case most monitors go into power saving mode. 131See 132.Xr wsconsctl 8 133for controlling variables. 134.El 135.Pp 136Consult the back-end drivers' documentation for which features are supported 137for each particular hardware type. 138.Ss IOCTL INTERFACE 139The following 140.Xr ioctl 2 141calls are provided by the 142.Nm 143driver or by devices which use it. 144Their definitions are found in 145.In dev/wscons/wsconsio.h . 146.Bl -tag -width 4n 147.It Dv WSDISPLAYIO_GTYPE Fa u_int 148Retrieve the type of the display. 149The list of types is in 150.In dev/wscons/wsconsio.h . 151.It Dv WSDISPLAYIO_GINFO Fa "struct wsdisplay_fbinfo" 152Retrieve basic information about a framebuffer display. 153The returned structure is as follows: 154.Bd -literal -offset indent 155struct wsdisplay_fbinfo { 156 u_int height; 157 u_int width; 158 u_int depth; 159 u_int cmsize; 160}; 161.Ed 162.Pp 163The 164.Va height 165and 166.Va width 167members are counted in pixels. 168The 169.Va depth 170member indicates the number of bits per pixel, and 171.Va cmsize 172indicates the number of color map entries accessible through 173.Dv WSDISPLAYIO_GETCMAP 174and 175.Dv WSDISPLAYIO_PUTCMAP . 176This call is likely to be unavailable on text-only displays. 177.It Dv WSDISPLAYIO_GETSCREENTYPE Fa "struct wsdisplay_screentype" 178Retrieve basic information about a screen. 179The returned structure is as follows: 180.Bd -literal -offset indent 181struct wsdisplay_screentype { 182 int idx; 183 int nidx; 184 char name[WSSCREEN_NAME_SIZE]; 185 int ncols, nrows; 186 int fontwidth, fontheight; 187}; 188.Ed 189.Pp 190The 191.Va idx 192field indicates the index of the screen. 193The 194.Va nidx 195field indicates the number of screens. 196The 197.Va name 198field contains a human readable string used to identify the screen. 199The 200.Va ncols 201and 202.Va nrows 203fields indicate the available number of columns and rows. 204The 205.Va fontwidth 206and 207.Va fontheight 208fields indicate the dimensions of a character cell, in pixels. 209.It Dv WSDISPLAYIO_GETCMAP Fa "struct wsdisplay_cmap" 210Retrieve the current color map from the display. 211This call needs the 212following structure set up beforehand: 213.Bd -literal -offset indent 214struct wsdisplay_cmap { 215 u_int index; 216 u_int count; 217 u_char *red; 218 u_char *green; 219 u_char *blue; 220}; 221.Ed 222.Pp 223The 224.Va index 225and 226.Va count 227members specify the range of color map entries to retrieve. 228The 229.Va red , 230.Va green , 231and 232.Va blue 233members should each point to an array of 234.Va count 235.Vt u_char Ns s . 236On return, these will be filled in with the appropriate entries from the 237color map. 238On all displays that support this call, values range from 0 for minimum 239intensity to 255 for maximum intensity, even if the display does not use 240eight bits internally to represent intensity. 241.It Dv WSDISPLAYIO_PUTCMAP Fa "struct wsdisplay_cmap" 242Change the display's color map. 243The argument structure is the same as for 244.Dv WSDISPLAYIO_GETCMAP , 245but 246.Va red , 247.Va green , 248and 249.Va blue 250are taken as pointers to the values to use to set the color map. 251This call is not available on displays with fixed color maps. 252.It Dv WSDISPLAYIO_GVIDEO Fa u_int 253Get the current state of the display's video output. 254Possible values are: 255.Bl -tag -width 21n 256.It Dv WSDISPLAYIO_VIDEO_OFF 257The display is blanked. 258.It Dv WSDISPLAYIO_VIDEO_ON 259The display is enabled. 260.El 261.It Dv WSDISPLAYIO_SVIDEO Fa u_int 262Set the state of the display's video output. 263See 264.Dv WSDISPLAYIO_GVIDEO 265above for possible values. 266.It Dv WSDISPLAYIO_GCURPOS Fa "struct wsdisplay_curpos" 267Retrieve the current position of the hardware cursor. 268The returned structure 269is as follows: 270.Bd -literal -offset indent 271struct wsdisplay_curpos { 272 u_int x, y; 273}; 274.Ed 275.Pp 276The 277.Va x 278and 279.Va y 280members count the number of pixels right and down, respectively, from 281the top-left corner of the display to the hot spot of the cursor. 282This call is not available on displays without a hardware cursor. 283.It Dv WSDISPLAYIO_SCURPOS Fa "struct wsdisplay_curpos" 284Set the current cursor position. 285The argument structure, and its semantics, 286are the same as for 287.Dv WSDISPLAYIO_GCURPOS . 288This call is not available on displays without a hardware cursor. 289.It Dv WSDISPLAYIO_GCURMAX Fa "struct wsdisplay_curpos" 290Retrieve the maximum size of cursor supported by the display. 291The 292.Va x 293and 294.Va y 295members of the returned structure indicate the maximum number of pixel rows 296and columns, respectively, in a hardware cursor on this display. 297This call is not available on displays without a hardware cursor. 298.It Dv WSDISPLAYIO_GCURSOR Fa "struct wsdisplay_cursor" 299Retrieve some or all of the hardware cursor's attributes. 300The argument structure is as follows: 301.Bd -literal -offset indent 302struct wsdisplay_cursor { 303 u_int which; 304 u_int enable; 305 struct wsdisplay_curpos pos; 306 struct wsdisplay_curpos hot; 307 struct wsdisplay_cmap cmap; 308 struct wsdisplay_curpos size; 309 u_char *image; 310 u_char *mask; 311}; 312.Pp 313.Ed 314The 315.Va which 316member indicates which of the values the application requires to be returned. 317It should contain the logical OR of the following flags: 318.Bl -tag -width 4n 319.It Dv WSDISPLAY_CURSOR_DOCUR 320Get 321.Va enable , 322which indicates whether the cursor is currently displayed (non-zero) or 323not (zero). 324.It Dv WSDISPLAY_CURSOR_DOPOS 325Get 326.Va pos , 327which indicates the current position of the cursor on the display, as 328would be returned by 329.Dv WSDISPLAYIO_GCURPOS . 330.It Dv WSDISPLAY_CURSOR_DOHOT 331Get 332.Va hot , 333which indicates the location of the 334.Dq hot spot 335within the cursor. 336This is the point on the cursor whose position on the display is treated 337as being the position of the cursor by other calls. 338Its location is counted in pixels from the top-left corner of the cursor. 339.It Dv WSDISPLAY_CURSOR_DOCMAP 340Get 341.Va cmap , 342which indicates the current cursor color map. 343Unlike in a call to 344.Dv WSDISPLAYIO_GETCMAP , 345.Va cmap 346here need not have its 347.Va index 348and 349.Va count 350members initialized. 351They will be set to 0 and 2 respectively by the call. 352This means that 353.Va cmap . Ns Va red , 354.Va cmap . Ns Va green , 355and 356.Va cmap . Ns Va blue 357must each point to at least enough space to hold two 358.Vt u_char Ns s . 359.It Dv WSDISPLAY_CURSOR_DOSHAPE 360Get 361.Va size , image , 362and 363.Va mask . 364These are, respectively, the dimensions of the cursor in pixels, the 365bitmap of set pixels in the cursor and the bitmap of opaque pixels in 366the cursor. 367The format in which these bitmaps are returned, and hence the amount of 368space that must be provided by the application, are device-dependent. 369.It Dv WSDISPLAY_CURSOR_DOALL 370Get all of the above. 371.El 372.Pp 373The device may elect to return information that was not requested by the user, 374so those elements of 375.Vt struct wsdisplay_cursor 376which are pointers should be initialized to 377.Dv NULL 378if not otherwise used. 379This call is not available on displays without a hardware cursor. 380.It Dv WSDISPLAYIO_SCURSOR Fa "struct wsdisplay_cursor" 381Set some or all of the hardware cursor's attributes. 382The argument structure is the same as for 383.Dv WSDISPLAYIO_GCURSOR . 384The 385.Va which 386member specifies which attributes of the cursor are to be changed. 387It should contain the logical OR of the following flags: 388.Bl -tag -width 4n 389.It Dv WSDISPLAY_CURSOR_DOCUR 390If 391.Va enable 392is zero, hide the cursor. 393Otherwise, display it. 394.It Dv WSDISPLAY_CURSOR_DOPOS 395Set the cursor's position on the display to 396.Va pos , 397the same as 398.Dv WSDISPLAYIO_SCURPOS . 399.It Dv WSDISPLAY_CURSOR_DOHOT 400Set the 401.Dq hot spot 402of the cursor, as defined above, to 403.Va hot . 404.It Dv WSDISPLAY_CURSOR_DOCMAP 405Set some or all of the cursor color map based on 406.Va cmap . 407The 408.Va index 409and 410.Va count 411elements of 412.Va cmap 413indicate which color map entries to set, and the entries themselves come from 414.Va cmap . Ns Va red , 415.Va cmap . Ns Va green , 416and 417.Va cmap . Ns Va blue . 418.It Dv WSDISPLAY_CURSOR_DOSHAPE 419Set the cursor shape from 420.Va size , image , 421.Va mask . 422See above for their meanings. 423.It Dv WSDISPLAY_CURSOR_DOALL 424Do all of the above. 425.El 426.Pp 427This call is not available on displays without a hardware cursor. 428.It Dv WSDISPLAYIO_GMODE Fa u_int 429Get the current mode of the display. 430Possible results include: 431.Bl -tag -width 4n 432.It Dv WSDISPLAYIO_MODE_EMUL 433The display is in emulating (text) mode. 434.It Dv WSDISPLAYIO_MODE_MAPPED 435The display is in mapped (graphics) mode. 436.It Dv WSDISPLAYIO_MODE_DUMBFB 437The display is in mapped (frame buffer) mode. 438.El 439.It Dv WSDISPLAYIO_SMODE Fa u_int 440Set the current mode of the display. 441For possible arguments, see 442.Dv WSDISPLAYIO_GMODE . 443.It Dv WSDISPLAYIO_LDFONT Fa "struct wsdisplay_font" 444Loads a font specified by the wsdisplay_font structure. 445.Bd -literal -offset indent 446struct wsdisplay_font { 447 char name[WSFONT_NAME_SIZE]; 448 int index; 449 int firstchar, numchars; 450 int encoding; 451 u_int fontwidth, fontheight, stride; 452 int bitorder, byteorder; 453 void *cookie; 454 void *data; 455}; 456.Ed 457.Pp 458The 459.Va name 460field contains a human readable string used to identify the font. 461The 462.Va index 463field may be used to select a driver-specific font resource (for non-raster 464frame buffers). 465A value of -1 will pick the first available slot. 466The 467.Va firstchar 468field contains the index of the first character in the font, starting at zero. 469The 470.Va numchars 471field contains the number of characters in the font. 472The 473.Va encoding 474field describes the font character encoding, using one of the following values: 475.Bl -tag -width 4n 476.It Dv WSDISPLAY_FONTENC_ISO 477ISO-8859-1 encoding 478.Pq also known as Latin-1 . 479This is the preferred encoding for raster frame buffers. 480.It Dv WSDISPLAY_FONTENC_IBM 481IBM code page number 437. 482This is the preferred encoding for text-mode displays. 483.El 484.Pp 485The 486.Va fontwidth 487and 488.Va fontheight 489fields specify the dimensions of a character cell. 490The 491.Va stride 492field specify the number of bytes of font data per character cell line (usually 493.Va fontwidth 494rounded up to a byte boundary). 495The 496.Va bitorder 497and 498.Va byteorder 499fields specify the bit- and byte-ordering of the font data, using either one of 500the following values: 501.Bl -tag -width 4n 502.It Dv WSDISPLAY_FONTORDER_L2R 503Leftmost data contained in the most significant bits (left-to-right ordering). 504This is the most commonly encountered case. 505.It Dv WSDISPLAY_FONTORDER_R2L 506Leftmost data contained in the least significant bits (right-to-left ordering). 507.El 508.Pp 509The 510.Va data 511field contains the font character data to be loaded. 512The 513.Va cookie 514field is reserved for internal purposes. 515.It Dv WSDISPLAYIO_LSFONT Fa "struct wsdisplay_font" 516Retrieves the data for a loaded font into the wsdisplay_font structure. 517The 518.Va index 519field is set to the font resource to query. 520For the argument structure, see 521.Dv WSDISPLAYIO_LDFONT . 522.\" Dv WSDISPLAYIO_DELFONT Fa "struct wsdisplay_font" 523.It Dv WSDISPLAYIO_USEFONT Fa "struct wsdisplay_font" 524Selects the font specified in the 525.Va name 526field. 527An empty 528.Va name 529selects the next available font. 530For the argument structure, see 531.Dv WSDISPLAYIO_LDFONT . 532.It Dv WSDISPLAYIO_GBURNER Fa "struct wsdisplay_burner" 533Retrieves the state of the screen burner. 534The returned structure is as follows: 535.Bd -literal -offset indent 536struct wsdisplay_burner { 537 u_int off; 538 u_int on; 539 u_int flags; 540}; 541.Ed 542.Pp 543The 544.Va off 545member contains the inactivity time before the screen is turned off, 546in milliseconds. 547The 548.Va on 549member contains the time before the screen is turned back on, 550in milliseconds. 551The 552.Va flags 553member contains a logical OR of the following flags: 554.Bl -tag -width 4n 555.It Dv WSDISPLAY_BURN_VBLANK 556When turning the display off, disable the vertical synchronization signal. 557.It Dv WSDISPLAY_BURN_KBD 558Monitor keyboard activity. 559.It Dv WSDISPLAY_BURN_MOUSE 560Monitor mouse activity 561(this only works for mice using the 562.Xr wsmouse 4 563driver). 564.It Dv WSDISPLAY_BURN_OUTPUT 565Monitor display output activity. 566.El 567.Pp 568If none of the activity source flags are set, the screen burner is disabled. 569.It Dv WSDISPLAYIO_SBURNER Fa "struct wsdisplay_burner" 570Sets the state of the screen burner. 571The argument structure, and its semantics, are the same as for 572.Dv WSDISPLAYIO_GBURNER . 573.It Dv WSDISPLAYIO_ADDSCREEN Fa "struct wsdisplay_addscreendata" 574Creates a new screen. 575.Bd -literal -offset indent 576struct wsdisplay_addscreendata { 577 int idx; /* screen index */ 578 char screentype[WSSCREEN_NAME_SIZE]; 579 char emul[WSEMUL_NAME_SIZE]; 580}; 581.Ed 582.Pp 583The 584.Va idx 585field is the index of the screen to be configured. 586The 587.Va screentype 588field is matched against builtin screen types, which will be driver-dependent. 589The 590.Va emul 591field indicates the terminal emulation type. 592Available terminal emulations are: 593.Bl -tag -width 5n 594.It sun 595Sun terminal emulation. 596This is the default on the sparc64 architecture. 597.It vt100 598Dec VT100 terminal emulation, with some VT220 features. 599This is the default on all other architectures. 600.It dumb 601Dumb terminal. 602.El 603.Pp 604An empty string will select the default emulation. 605.It Dv WSDISPLAYIO_DELSCREEN Fa "struct wsdisplay_delscreendata" 606Deletes an existing screen. 607.Bd -literal -offset indent 608struct wsdisplay_delscreendata { 609 int idx; /* screen index */ 610 int flags; 611}; 612.Ed 613.Pp 614The 615.Va idx 616field indicates the index of the screen to be deleted. 617The 618.Va flags 619field is a logical OR of zero or more of the following: 620.Bl -tag -width 4n 621.It Dv WSDISPLAY_DELSCR_FORCE 622Force deletion of screen even if in use by a userspace program. 623.It Dv WSDISPLAY_DELSCR_QUIET 624Don't report deletion to console. 625.El 626.It Dv WSDISPLAYIO_GETSCREEN Fa "struct wsdisplay_addscreendata" 627Returns information on the screen indicated by 628.Va idx 629or the current screen if 630.Va idx 631is -1. 632The screen and emulation types are returned in the same structure 633.Pq see Dv WSDISPLAYIO_GETPARAM . 634.It Dv WSDISPLAYIO_SETSCREEN Fa u_int 635Switch to the screen with the given index. 636.It Dv WSDISPLAYIO_WSMOUSED Fa "struct wscons_event" 637This call is used by the 638.Xr wsmoused 8 639daemon to inject mouse events gathered from serial mice, as well as 640various control events. 641.It Dv WSDISPLAYIO_GETPARAM Fa "struct wsdisplay_param" 642Retrieves the state of a display parameter. 643This call needs the following structure set up beforehand: 644.Bd -literal -offset indent 645struct wsdisplay_param { 646 int param; 647 int min, max, curval; 648 int reserved[4]; 649}; 650.Ed 651.Pp 652The 653.Va param 654member should be set with the parameter to be returned. 655The following parameters are supported: 656.Bl -tag -width 4n 657.It Dv WSDISPLAYIO_PARAM_BACKLIGHT 658The intensity of the display backlight (usually on laptop computers). 659.It Dv WSDISPLAYIO_PARAM_BRIGHTNESS 660The brightness level. 661.It Dv WSDISPLAYIO_PARAM_CONTRAST 662The contrast level. 663.El 664.Pp 665On return, 666.Va min 667and 668.Va max 669specify the allowed range for the value, while 670.Va curval 671specifies the current setting. 672Not all parameters are supported by all display drivers. 673.It Dv WSDISPLAYIO_SETPARAM Fa "struct wsdisplay_param" 674Sets a display parameter. 675The argument structure is the same as for 676.Dv WSDISPLAYIO_GETPARAM , 677with the 678.Va param 679and 680.Va curval 681members filled in. 682Not all parameters are supported by all display drivers. 683.It Dv WSDISPLAYIO_LINEBYTES Fa u_int 684Get the number of bytes per row when the device is in 685.Dv WSDISPLAYIO_MODE_DUMBFB 686mode. 687.El 688.Sh FILES 689.Bl -tag -width /usr/include/dev/wscons/wsconsio.h -compact 690.It Pa /dev/tty[C-F]* 691terminal devices (per screen) 692.It Pa /dev/tty[C-F]cfg 693control device (per screen) 694.It Pa /usr/include/dev/wscons/wsconsio.h 695.El 696.Sh SEE ALSO 697.Xr intro 4 , 698.Xr tty 4 , 699.Xr wscons 4 , 700.Xr wsmux 4 , 701.Xr wsconscfg 8 , 702.Xr wsconsctl 8 , 703.Xr wsfontload 8 704.Sh BUGS 705The 706.Nm 707code currently limits the number of screens on one display to 12. 708.Pp 709The terms 710.Dq wscons 711and 712.Dq wsdisplay 713are not cleanly distinguished in the code and in manual pages. 714