~emersion/wlr-randr#6: 
Selecting modes with same resolution and refresh rate

I have a AOC monitor which advertises two 1920x1080@60Hz timings but only of them actually works. I can see both modes in wlr-randr output but cannot figure out how to select the preferred one. wlr-randr --output DP-1 --mode 1920x1080 60 doesn't change it and swaymsg output DP-1 mode 1920x1080@60Hz doesn't change it either.

DP-1 "Unknown 2369M ABPEA9A000199 (DP-1)"
  Physical size: 510x290 mm
  Enabled: yes
  Modes:
    1920x1080 px, 60.000000 Hz (preferred)
    1920x1080 px, 60.000000 Hz (current)
    1920x1080 px, 59.939999 Hz
    1920x1080 px, 50.000000 Hz
    1680x1050 px, 59.882999 Hz
    1280x1024 px, 75.025002 Hz
    1280x1024 px, 60.020000 Hz
    1440x900 px, 59.901001 Hz
    1280x960 px, 60.000000 Hz
    1280x720 px, 60.000000 Hz
    1280x720 px, 60.000000 Hz
    1280x720 px, 59.939999 Hz
    1280x720 px, 50.000000 Hz
    1024x768 px, 75.028999 Hz
    1024x768 px, 70.069000 Hz
    1024x768 px, 60.004002 Hz
    832x624 px, 74.551003 Hz
    800x600 px, 75.000000 Hz
    800x600 px, 72.188004 Hz
    800x600 px, 60.317001 Hz
    800x600 px, 56.250000 Hz
    720x576 px, 50.000000 Hz
    720x576 px, 50.000000 Hz
    720x576 px, 50.000000 Hz
    720x480 px, 60.000000 Hz
    720x480 px, 60.000000 Hz
    720x480 px, 59.939999 Hz
    720x480 px, 59.939999 Hz
    720x480 px, 59.939999 Hz
    640x480 px, 75.000000 Hz
    640x480 px, 72.808998 Hz
    640x480 px, 66.667000 Hz
    640x480 px, 60.000000 Hz
    640x480 px, 59.939999 Hz
    640x480 px, 59.939999 Hz
    720x400 px, 70.082001 Hz
  Position: 0,0
  Transform: normal
  Scale: 1.000000

Is there some way to select the mode by for example index or with vesa timings? And is there a feature to extract the vesa timings from the available modes to see which ones I should set?

Status
REPORTED
Submitter
github.com:Jaakkonen (unverified)
Assigned to
No-one
Submitted
4 years ago
Updated
11 months ago
Labels
No labels applied.

github.com:emersion (unverified) 4 years ago · edit

xrandr has --preferred to select the preferred mode.

github.com:Jaakkonen (unverified) 4 years ago · edit

Looking into monitor EDID there's

  • STI (standard timing information): X-res8 1920 pix, V-freq 60 Hz, pix_ratio 0b11.
  • DTD (detailed timing descriptor): Pixel clock Float 148.50 MHz, H-Active pix 1920 pix, H-Blank pix 280 pix, V-Active lines 1080 pix, V-Blank lines 45 pix, H-Sync offs 88 pix, H-Sync width 44pix, V-Sync offs 4pix, V-Sync width 5 pix, H-Size 509 mm, V-Size 286 mm, H-Border 0 pix, V-Border 0 pix, sync_type 0b11, Hsync_type 1, Vsync_type 1, il2w_stereo 0, stereo_mode 0b00, interlace 0

Both of these get interpreted as 1920x1080@60Hz. For some reason sway-output and wlr-randr both use the non-preferred mode when provided with this name. That might be due to the implementation of the output management protocol in wlroots.

In EDID versions 1.3 and onwards (I have 1.3) the first DTD should be considered the preferred resolution. That is shown right by wlr-randr and xrandr but only xrandr has ability to enable the preferred mode.

The wayland protocol used for setting modes in this tool (wlr_output_management_unstable_v1) uses set_mode with parameter zwlr_output_mode_v1 to specify which mode is wanted.

I'll try to add a --preferred option to call the protocol with the preferred mode and make a PR if I succeed.

Currently only way I could find to set the mode without a restart is to install xorg server and run xrandr to set the mode and remove all output mode configuration for that monitor from sway/wlroots compositor config. With restart it's possible to override drm.edid_firmware with a customized one (edit with for example wxEdid) where the STI entry is modified to other resolution.

github.com:emersion (unverified) 4 years ago · edit

wlroots just uses the modes reported by the kernel. You can inspect those via drm_info.

github.com:Jaakkonen (unverified) 4 years ago · edit

The modes gotten by wlr-randr are always in the right order with preferred mode first (wlroots passes those from libdrm and kernel in right order). So when using some specific resolution and refresh rate in case of a duplicate the preferred resolution is used.

In my case it seems that some change in i915 driver from kernel, firmware or some library I haven't checked has caused that the preferred resolution is not used and cannot be used. Even weston crashes when connecting this display with assertion failing weston: ../weston-9.0.0/libweston/backend-drm/kms.c:1409: atomic_flip_handler: Assertion `output->atomic_complete_pending' failed.. So for some reason the atomic mode change is failing. Tested with the 5.11-rc4 kernel too but no luck.

So the issue isn't in wlr-randr. If it's helpful I can/will create a PR for the --preferred option to make the tool a little easier to use when just wanting to put a monitor back to default mode.

github.com:emersion (unverified) 4 years ago · edit

If it's helpful I can/will create a PR for the --preferred option to make the tool a little easier to use when just wanting to put a monitor back to default mode.

Sure, would be helpful :)