Diff for /wikisrc/tutorials/x11/how_to_use_wsfb_uefi_bios_framebuffer.md between versions 1.2 and 1.3

version 1.2, 2021/03/31 06:32:27 version 1.3, 2021/07/16 09:36:24
Line 1 Line 1
 [[[!meta title="How to use Xorg's wsfb display driver with a UEFI/BIOS framebuffer, and change its resolution"]]  [[!meta title="How to use Xorg's wsfb display driver with a UEFI/BIOS framebuffer, and change its resolution"]]
   [[!toc levels=3]]
   
 How to use Xorg's wsfb display driver with a UEFI/BIOS framebuffer, and change its resolution  Background
 =============================================================================================  ----------
   
 ### Background  
 [wsfb(4)](https://man.netbsd.org/wsfb.4) is the Xorg graphics driver for the NetBSD [wsdisplay(4)](https://man.netbsd.org/wsdisplay.4) framebuffer device. `wsdisplay(4)`, similar to Linux's `/dev/fb` devices, provide access to _non-accelerated_ framebuffers, which are provided by _almost all_ modern cards. Most, if not all, _modern_ graphics cards provide what's called a _linear_ framebuffer: a chunk of memory where contiguous address locations map onto adjacent (X, Y) _pixels_. For example, assuming a 32 bits-per-pixel colour depth display, memory location `fbmem + 0` will hold the pixel at position (0,0); `fbmem + 4` corresponds to the pixel at (1, 0), and so on. (We'll skip the complication known as `stride` or `line_length` here.)  [wsfb(4)](https://man.netbsd.org/wsfb.4) is the Xorg graphics driver for the NetBSD [wsdisplay(4)](https://man.netbsd.org/wsdisplay.4) framebuffer device. `wsdisplay(4)`, similar to Linux's `/dev/fb` devices, provide access to _non-accelerated_ framebuffers, which are provided by _almost all_ modern cards. Most, if not all, _modern_ graphics cards provide what's called a _linear_ framebuffer: a chunk of memory where contiguous address locations map onto adjacent (X, Y) _pixels_. For example, assuming a 32 bits-per-pixel colour depth display, memory location `fbmem + 0` will hold the pixel at position (0,0); `fbmem + 4` corresponds to the pixel at (1, 0), and so on. (We'll skip the complication known as `stride` or `line_length` here.)
   
 `wsdisplay(4)` can run on top of:   `wsdisplay(4)` can run on top of: 
Line 11  How to use Xorg's wsfb display driver wi Line 10  How to use Xorg's wsfb display driver wi
 1. `genfb(4)`, the Generic PCI VGA framebuffer device (provided by UEFI or BIOS on x86), and other simple software framebuffers provided by hardware or firmware (e.g. simplefb on ARM)  1. `genfb(4)`, the Generic PCI VGA framebuffer device (provided by UEFI or BIOS on x86), and other simple software framebuffers provided by hardware or firmware (e.g. simplefb on ARM)
 2. the accelerated [`drm(4)`](https://man.netbsd.org/drm.4) graphics devices (in `/dev/dri/card?`--which `wsfb` will use as a plain framebuffer).  2. the accelerated [`drm(4)`](https://man.netbsd.org/drm.4) graphics devices (in `/dev/dri/card?`--which `wsfb` will use as a plain framebuffer).
   
 ### Using `wsfb`  Using `wsfb`
   ------------
 ### Step 1: Configuring `Xorg`  ### Step 1: Configuring `Xorg`
 Use this `wsfb.conf` Xorg config fragment:  Use this `wsfb.conf` Xorg config fragment:
     
Line 23  EndSection Line 23  EndSection
 ```  ```
   
 That is all that is needed. Xorg will autoconfigure everything else. Make sure you dump the `wsfb.conf` file into the correct Xorg config. directory. `/etc/X11/xorg.conf.d/` is the correct location for the Xorg in base. If you've installed the `modular-xorg` package, then the path will need change. Use this command to find your `config directory`:  That is all that is needed. Xorg will autoconfigure everything else. Make sure you dump the `wsfb.conf` file into the correct Xorg config. directory. `/etc/X11/xorg.conf.d/` is the correct location for the Xorg in base. If you've installed the `modular-xorg` package, then the path will need change. Use this command to find your `config directory`:
   
 ```  ```
 $ fgrep directory /var/log/Xorg.0.log  $ fgrep directory /var/log/Xorg.0.log
 [    72.697] (==) Using config directory: "/usr/local/etc/X11/xorg.conf.d"  [    72.697] (==) Using config directory: "/usr/local/etc/X11/xorg.conf.d"
Line 35  If you don't have a DRM driver, or if yo Line 36  If you don't have a DRM driver, or if yo
   
 ### Step 2: Setting a better display mode.  ### Step 2: Setting a better display mode.
 Reboot, then at the bootloader menu, choose the option to get to the bootloader prompt. Here, on UEFI systems, we use the `gop` (Graphics Output Protocol) command like this:  Reboot, then at the bootloader menu, choose the option to get to the bootloader prompt. Here, on UEFI systems, we use the `gop` (Graphics Output Protocol) command like this:
 List avaibable video modes first:  
   List available video modes first:
   
 ```  ```
 > gop list  > gop list
  0: 1366x768 BGRR pitch 1376 bpp 32   0: 1366x768 BGRR pitch 1376 bpp 32
Line 44  List avaibable video modes first: Line 47  List avaibable video modes first:
  3: 1024x768 BGRR pitch 1024 bpp 32   3: 1024x768 BGRR pitch 1024 bpp 32
 >  >
 ```  ```
   
 The `*` indicates the (safe) mode that the bootloader will use by default. Note that on my laptop, mode `0` has a pitch (aka stride) of 1376 pixels. This means that on my graphics card (Asus X202E laptop), the framebuffer is _linear_, but, **not** fully contiguous. The 10 unusable pixels at the end of each row have to taken into account, or else, you'll be treated to a characteristic jagged, streaky display.  The `*` indicates the (safe) mode that the bootloader will use by default. Note that on my laptop, mode `0` has a pitch (aka stride) of 1376 pixels. This means that on my graphics card (Asus X202E laptop), the framebuffer is _linear_, but, **not** fully contiguous. The 10 unusable pixels at the end of each row have to taken into account, or else, you'll be treated to a characteristic jagged, streaky display.
   
 Choose the best mode, which is generally mode `0`:  Choose the best mode, which is generally mode `0`:
   
 ```  ```
 > gop 0  > gop 0
 >  >
 ```  ```
   
 The screen resolution will switch immediately. (And hopefully, your display won't go blank, which, these days, usually indicates a graphics card/BIOS/UEFI/whatever that doesn't implement the published standards correctly.)  The screen resolution will switch immediately. (And hopefully, your display won't go blank, which, these days, usually indicates a graphics card/BIOS/UEFI/whatever that doesn't implement the published standards correctly.)
   
 If you have/use BIOS instead of UEFI, you can try the `vesa` command instead of `gop`:  If you have/use BIOS instead of UEFI, you can try the `vesa` command instead of `gop`:
Line 61  If you have/use BIOS instead of UEFI, yo Line 67  If you have/use BIOS instead of UEFI, yo
 > vesa 0xhhh  > vesa 0xhhh
 >  >
 ```  ```
   
 If the mode you've chosen works, then you can add that `gop 0` or `vesa mode` command to `boot.cfg` so that it is activated automatically.  If the mode you've chosen works, then you can add that `gop 0` or `vesa mode` command to `boot.cfg` so that it is activated automatically.
   
 This is what `dmesg` will show, if you've disabled DRM (see below), or don't have it:  This is what `dmesg` will show, if you've disabled DRM (see below), or don't have it:
   
 ```  ```
 $ dmesg | fgrep genfb  $ dmesg | fgrep genfb
 [     1.015430] genfb0 at pci0 dev 2 function 0: vendor 8086 product 0166 (rev. 0x09)  [     1.015430] genfb0 at pci0 dev 2 function 0: vendor 8086 product 0166 (rev. 0x09)
Line 72  $ dmesg | fgrep genfb Line 80  $ dmesg | fgrep genfb
 [     1.015430] wsdisplay0 at genfb0 kbdmux 1: console (default, vt100 emulation), using wskbd0  [     1.015430] wsdisplay0 at genfb0 kbdmux 1: console (default, vt100 emulation), using wskbd0
 [     1.015430] drm at genfb0 not configured  [     1.015430] drm at genfb0 not configured
 ```  ```
   
 The resolution, depth and stride are all OK. And inside the Xorg server:  The resolution, depth and stride are all OK. And inside the Xorg server:
   
 ```  ```
 $ xdpyinfo | fgrep -B1 -A1 resolution  $ xdpyinfo | fgrep -B1 -A1 resolution
   dimensions:    1366x768 pixels (310x174 millimeters)    dimensions:    1366x768 pixels (310x174 millimeters)
Line 86  default connected 1366x768+0+0 0mm x 0mm Line 96  default connected 1366x768+0+0 0mm x 0mm
 $  $
 ```  ```
   
 ### Limitations  Limitations
   -----------
 1. No OpenGL hardware acceleration - on x86 and aarch64, llvmpipe (a parallel CPU-based just-in-time renderer) will be used instead  1. No OpenGL hardware acceleration - on x86 and aarch64, llvmpipe (a parallel CPU-based just-in-time renderer) will be used instead
 2. No X Display Power Management Signaling  2. No X Display Power Management Signaling
 3. No X video extension (used for accelerated video playback)  3. No X video extension (used for accelerated video playback)
 4. No DRI  4. No DRI
   
 #### Extra: How to disable built-in DRM driver using kernel's `userconf` manager  ## Extra: How to disable built-in DRM driver using kernel's `userconf` manager
   
 For testing, or if running `wsfb` on top of the DRM graphics driver does not work--it mostly should, actually).  For testing, or if running `wsfb` on top of the DRM graphics driver does not work--it mostly should, actually).
   
 At the bootloader prompt, pass the `-c` flag to the kernel:  At the bootloader prompt, pass the `-c` flag to the kernel:
   
 ```  ```
 > boot -c  > boot -c
 ```  ```
   
 The kernel will display a few lines, then immediately drop into the `userconf` prompt:  The kernel will display a few lines, then immediately drop into the `userconf` prompt:
   
 ```  ```
 uc> list                        # list all devs; look for your drmkms entry  uc> list                        # list all devs; look for your drmkms entry
 uc> disable i915drmkms          # disable Intel DRM  uc> disable i915drmkms          # disable Intel DRM
 uc> quit  uc> quit
 ```  ```
   
 Once you've determined the device name using `userconf`, or, by trawling through the GENERIC kernel config file, you can disable the device using the bootloader like this:  Once you've determined the device name using `userconf`, or, by trawling through the GENERIC kernel config file, you can disable the device using the bootloader like this:
   
 ```  ```
 > userconf disable i915drmkms  > userconf disable i915drmkms
 ```  ```
   
 You can of course, add `userconf` commands also to `boot.conf`  You can of course, add `userconf` commands also to `boot.conf`
   
 #### Minimal `wsfb(4)` config fragment `/etc/X11/xorg.conf.d/wsfb.conf`  ## Minimal `wsfb(4)` config fragment `/etc/X11/xorg.conf.d/wsfb.conf`
   
 ```  ```
 Section "Device"  Section "Device"
         Identifier  "Card0"          Identifier  "Card0"
Line 120  Section "Device" Line 138  Section "Device"
 EndSection  EndSection
 ```  ```
   
 #### Minimal `wsfb(4)` `/etc/X11/xorg.conf` created using `X -configure`, and then changing the graphics device driver (`Section "Device"`) from `intel` to `wsfb`  ## Minimal `wsfb(4)` `/etc/X11/xorg.conf`
   
   Created using `X -configure`, and then changing the graphics device driver (`Section "Device"`) from `intel` to `wsfb`
   
 ```  ```
 Section "ServerLayout"  Section "ServerLayout"

Removed from v.1.2  
changed lines
  Added in v.1.3


CVSweb for NetBSD wikisrc <wikimaster@NetBSD.org> software: FreeBSD-CVSweb